Compare commits
14 Commits
278fe39c0d
...
1db6de6bc2
| Author | SHA1 | Date | |
|---|---|---|---|
| 1db6de6bc2 | |||
| 560da0daa0 | |||
| 61f0aa1aba | |||
| ed54dca3ba | |||
| 4a6809e2df | |||
| d63c2dbd12 | |||
| 607efa961f | |||
| 02a44f67b9 | |||
| 562b856488 | |||
| 8f77eb1ed0 | |||
| 3ad479aa17 | |||
| 546fee7890 | |||
| 5654c02f36 | |||
| d5c7a9f030 |
+4
-4
@@ -1,5 +1,5 @@
|
|||||||
cmake_minimum_required(VERSION 3.31)
|
cmake_minimum_required(VERSION 3.31)
|
||||||
project(mango C ASM)
|
project(magenta C ASM)
|
||||||
|
|
||||||
if (NOT BUILD_TOOLS_DIR)
|
if (NOT BUILD_TOOLS_DIR)
|
||||||
message(FATAL_ERROR "No build tools directory specified. Please run build.sh")
|
message(FATAL_ERROR "No build tools directory specified. Please run build.sh")
|
||||||
@@ -9,8 +9,8 @@ set(CMAKE_C_STANDARD 17)
|
|||||||
|
|
||||||
set(kernel_arch x86_64)
|
set(kernel_arch x86_64)
|
||||||
|
|
||||||
set(kernel_name "Mango")
|
set(kernel_name "Magenta")
|
||||||
set(kernel_exe_name "mango_kernel")
|
set(kernel_exe_name "magenta_kernel")
|
||||||
|
|
||||||
set(generic_src_dirs ds init kernel libc sched util vm syscall)
|
set(generic_src_dirs ds init kernel libc sched util vm syscall)
|
||||||
set(kernel_sources "")
|
set(kernel_sources "")
|
||||||
@@ -38,7 +38,7 @@ add_executable(${kernel_exe_name}
|
|||||||
target_include_directories(${kernel_exe_name} PRIVATE
|
target_include_directories(${kernel_exe_name} PRIVATE
|
||||||
include
|
include
|
||||||
libc/include
|
libc/include
|
||||||
libmango/include
|
libmagenta/include
|
||||||
arch/${kernel_arch}/include)
|
arch/${kernel_arch}/include)
|
||||||
target_compile_options(${kernel_exe_name} PRIVATE
|
target_compile_options(${kernel_exe_name} PRIVATE
|
||||||
-nostdlib -ffreestanding
|
-nostdlib -ffreestanding
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#ifndef MANGO_USER_CPU_H_
|
#ifndef MAGENTA_USER_CPU_H_
|
||||||
#define MANGO_USER_CPU_H_
|
#define MAGENTA_USER_CPU_H_
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#ifndef MANGO_USER_HWLOCK_H_
|
#ifndef MAGENTA_USER_HWLOCK_H_
|
||||||
#define MANGO_USER_HWLOCK_H_
|
#define MAGENTA_USER_HWLOCK_H_
|
||||||
|
|
||||||
#define ML_HWLOCK_INIT (0)
|
#define ML_HWLOCK_INIT (0)
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#ifndef MANGO_X86_64_INIT_H_
|
#ifndef MAGENTA_X86_64_INIT_H_
|
||||||
#define MANGO_X86_64_INIT_H_
|
#define MAGENTA_X86_64_INIT_H_
|
||||||
|
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#ifndef MANGO_X86_64_IRQ_H_
|
#ifndef MAGENTA_X86_64_IRQ_H_
|
||||||
#define MANGO_X86_64_IRQ_H_
|
#define MAGENTA_X86_64_IRQ_H_
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#ifndef MANGO_USER_PMAP_H_
|
#ifndef MAGENTA_USER_PMAP_H_
|
||||||
#define MANGO_USER_PMAP_H_
|
#define MAGENTA_USER_PMAP_H_
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#ifndef MANGO_USER_VM_H_
|
#ifndef MAGENTA_USER_VM_H_
|
||||||
#define MANGO_USER_VM_H_
|
#define MAGENTA_USER_VM_H_
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
|
|||||||
+3
-1
@@ -56,7 +56,9 @@ static void early_vm_init(uintptr_t reserve_end)
|
|||||||
uintptr_t alloc_end = VM_KERNEL_VOFFSET + 0x7fffffff;
|
uintptr_t alloc_end = VM_KERNEL_VOFFSET + 0x7fffffff;
|
||||||
|
|
||||||
memblock_init(alloc_start, alloc_end, VM_KERNEL_VOFFSET);
|
memblock_init(alloc_start, alloc_end, VM_KERNEL_VOFFSET);
|
||||||
printk("memblock: allocating from [0x%llx-0x%llx]", alloc_start, alloc_end);
|
printk("memblock: allocating from [0x%llx-0x%llx]",
|
||||||
|
alloc_start,
|
||||||
|
alloc_end);
|
||||||
|
|
||||||
memblock_reserve(0x00, reserve_end);
|
memblock_reserve(0x00, reserve_end);
|
||||||
printk("memblock: reserved bios+kernel at [0x%016llx-0x%016llx]",
|
printk("memblock: reserved bios+kernel at [0x%016llx-0x%016llx]",
|
||||||
|
|||||||
+13
-1
@@ -9,7 +9,7 @@
|
|||||||
#include <kernel/types.h>
|
#include <kernel/types.h>
|
||||||
#include <kernel/vm-object.h>
|
#include <kernel/vm-object.h>
|
||||||
#include <kernel/vm.h>
|
#include <kernel/vm.h>
|
||||||
#include <mango/status.h>
|
#include <magenta/status.h>
|
||||||
|
|
||||||
/* some helpful datasize constants */
|
/* some helpful datasize constants */
|
||||||
#define C_1GiB 0x40000000ULL
|
#define C_1GiB 0x40000000ULL
|
||||||
@@ -321,6 +321,10 @@ static kern_status_t do_pmap_remove(
|
|||||||
virt_addr_t pv,
|
virt_addr_t pv,
|
||||||
enum page_size size)
|
enum page_size size)
|
||||||
{
|
{
|
||||||
|
if (pmap == PMAP_INVALID) {
|
||||||
|
return KERN_OK;
|
||||||
|
}
|
||||||
|
|
||||||
unsigned int pml4t_index = BAD_INDEX, pdpt_index = BAD_INDEX,
|
unsigned int pml4t_index = BAD_INDEX, pdpt_index = BAD_INDEX,
|
||||||
pd_index = BAD_INDEX, pt_index = BAD_INDEX;
|
pd_index = BAD_INDEX, pt_index = BAD_INDEX;
|
||||||
|
|
||||||
@@ -622,5 +626,13 @@ kern_status_t pmap_remove(pmap_t pmap, virt_addr_t p)
|
|||||||
|
|
||||||
kern_status_t pmap_remove_range(pmap_t pmap, virt_addr_t p, size_t len)
|
kern_status_t pmap_remove_range(pmap_t pmap, virt_addr_t p, size_t len)
|
||||||
{
|
{
|
||||||
|
if (pmap == PMAP_INVALID) {
|
||||||
|
return KERN_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (size_t i = p; i < p + len; i += VM_PAGE_SIZE) {
|
||||||
|
pmap_remove(pmap, i);
|
||||||
|
}
|
||||||
|
|
||||||
return KERN_OK;
|
return KERN_OK;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,11 @@
|
|||||||
|
.global pmap_flush
|
||||||
|
.type pmap_flush, @function
|
||||||
|
|
||||||
|
pmap_flush:
|
||||||
|
mov %cr3, %rax
|
||||||
|
mov %rax, %cr3
|
||||||
|
ret
|
||||||
|
|
||||||
|
|
||||||
.global pmap_switch
|
.global pmap_switch
|
||||||
.type pmap_switch, @function
|
.type pmap_switch, @function
|
||||||
@@ -6,6 +14,7 @@ pmap_switch:
|
|||||||
mov %rdi, %cr3
|
mov %rdi, %cr3
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
|
||||||
.global gigabyte_pages
|
.global gigabyte_pages
|
||||||
.type gigabyte_pages, @function
|
.type gigabyte_pages, @function
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# the name of the target operating system
|
# the name of the target operating system
|
||||||
set(CMAKE_SYSTEM_NAME Mango)
|
set(CMAKE_SYSTEM_NAME Magenta)
|
||||||
|
|
||||||
# which compilers to use for C and C++
|
# which compilers to use for C and C++
|
||||||
set(CMAKE_C_COMPILER x86_64-elf-gcc)
|
set(CMAKE_C_COMPILER x86_64-elf-gcc)
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#ifndef KERNEL_ARG_H_
|
#ifndef KERNEL_ARG_H_
|
||||||
#define KERNEL_ARG_H_
|
#define KERNEL_ARG_H_
|
||||||
|
|
||||||
#include <mango/types.h>
|
#include <magenta/types.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
#define CMDLINE_MAX 4096
|
#define CMDLINE_MAX 4096
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
#define KERNEL_BSP_H_
|
#define KERNEL_BSP_H_
|
||||||
|
|
||||||
#include <kernel/compiler.h>
|
#include <kernel/compiler.h>
|
||||||
#include <mango/status.h>
|
#include <magenta/status.h>
|
||||||
#include <kernel/types.h>
|
#include <kernel/types.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|||||||
@@ -16,8 +16,8 @@
|
|||||||
*/
|
*/
|
||||||
#include <kernel/locks.h>
|
#include <kernel/locks.h>
|
||||||
#include <kernel/queue.h>
|
#include <kernel/queue.h>
|
||||||
#include <mango/status.h>
|
#include <magenta/status.h>
|
||||||
#include <mango/types.h>
|
#include <magenta/types.h>
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
#include <kernel/locks.h>
|
#include <kernel/locks.h>
|
||||||
#include <kernel/object.h>
|
#include <kernel/object.h>
|
||||||
#include <kernel/sched.h>
|
#include <kernel/sched.h>
|
||||||
#include <mango/types.h>
|
#include <magenta/types.h>
|
||||||
|
|
||||||
#define EQUEUE_PACKET_MAX 100
|
#define EQUEUE_PACKET_MAX 100
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
#include <kernel/btree.h>
|
#include <kernel/btree.h>
|
||||||
#include <kernel/wait.h>
|
#include <kernel/wait.h>
|
||||||
#include <mango/types.h>
|
#include <magenta/types.h>
|
||||||
|
|
||||||
struct task;
|
struct task;
|
||||||
struct address_space;
|
struct address_space;
|
||||||
|
|||||||
@@ -2,8 +2,8 @@
|
|||||||
#define KERNEL_HANDLE_H_
|
#define KERNEL_HANDLE_H_
|
||||||
|
|
||||||
#include <kernel/bitmap.h>
|
#include <kernel/bitmap.h>
|
||||||
#include <mango/status.h>
|
#include <magenta/status.h>
|
||||||
#include <mango/types.h>
|
#include <magenta/types.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#ifndef KERNEL_IOVEC_H_
|
#ifndef KERNEL_IOVEC_H_
|
||||||
#define KERNEL_IOVEC_H_
|
#define KERNEL_IOVEC_H_
|
||||||
|
|
||||||
#include <mango/types.h>
|
#include <magenta/types.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
|
||||||
struct address_space;
|
struct address_space;
|
||||||
|
|||||||
@@ -3,8 +3,8 @@
|
|||||||
|
|
||||||
#include <kernel/btree.h>
|
#include <kernel/btree.h>
|
||||||
#include <kernel/locks.h>
|
#include <kernel/locks.h>
|
||||||
#include <mango/status.h>
|
#include <magenta/status.h>
|
||||||
#include <mango/types.h>
|
#include <magenta/types.h>
|
||||||
|
|
||||||
struct port;
|
struct port;
|
||||||
struct thread;
|
struct thread;
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
#include <kernel/locks.h>
|
#include <kernel/locks.h>
|
||||||
#include <kernel/vm.h>
|
#include <kernel/vm.h>
|
||||||
#include <kernel/wait.h>
|
#include <kernel/wait.h>
|
||||||
#include <mango/status.h>
|
#include <magenta/status.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#ifndef KERNEL_PERCPU_H_
|
#ifndef KERNEL_PERCPU_H_
|
||||||
#define KERNEL_PERCPU_H_
|
#define KERNEL_PERCPU_H_
|
||||||
|
|
||||||
#include <mango/status.h>
|
#include <magenta/status.h>
|
||||||
#include <kernel/compiler.h>
|
#include <kernel/compiler.h>
|
||||||
#include <kernel/sched.h>
|
#include <kernel/sched.h>
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
#include <kernel/machine/pmap.h>
|
#include <kernel/machine/pmap.h>
|
||||||
#include <kernel/vm.h>
|
#include <kernel/vm.h>
|
||||||
#include <mango/status.h>
|
#include <magenta/status.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
|
||||||
#define PMAP_INVALID ML_PMAP_INVALID
|
#define PMAP_INVALID ML_PMAP_INVALID
|
||||||
@@ -52,6 +52,10 @@ extern pmap_t pmap_create(void);
|
|||||||
extern void pmap_destroy(pmap_t pmap);
|
extern void pmap_destroy(pmap_t pmap);
|
||||||
extern void pmap_switch(pmap_t pmap);
|
extern void pmap_switch(pmap_t pmap);
|
||||||
|
|
||||||
|
extern void pmap_flush(void);
|
||||||
|
extern void pmap_flush_page(virt_addr_t p);
|
||||||
|
extern void pmap_flush_range(virt_addr_t start, size_t length);
|
||||||
|
|
||||||
extern kern_status_t pmap_handle_fault(
|
extern kern_status_t pmap_handle_fault(
|
||||||
virt_addr_t fault_addr,
|
virt_addr_t fault_addr,
|
||||||
enum pmap_fault_flags flags);
|
enum pmap_fault_flags flags);
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
#include <kernel/locks.h>
|
#include <kernel/locks.h>
|
||||||
#include <kernel/queue.h>
|
#include <kernel/queue.h>
|
||||||
#include <kernel/types.h>
|
#include <kernel/types.h>
|
||||||
#include <mango/status.h>
|
#include <magenta/status.h>
|
||||||
|
|
||||||
#define PRIO_MAX 32
|
#define PRIO_MAX 32
|
||||||
|
|
||||||
|
|||||||
@@ -5,8 +5,8 @@
|
|||||||
#include <kernel/handle.h>
|
#include <kernel/handle.h>
|
||||||
#include <kernel/task.h>
|
#include <kernel/task.h>
|
||||||
#include <kernel/vm.h>
|
#include <kernel/vm.h>
|
||||||
#include <mango/status.h>
|
#include <magenta/status.h>
|
||||||
#include <mango/syscall.h>
|
#include <magenta/syscall.h>
|
||||||
|
|
||||||
#define validate_access(task, ptr, len, flags) \
|
#define validate_access(task, ptr, len, flags) \
|
||||||
__validate_access(task, (const void *)ptr, len, flags)
|
__validate_access(task, (const void *)ptr, len, flags)
|
||||||
@@ -42,6 +42,7 @@ extern kern_status_t sys_task_exit(int status);
|
|||||||
extern kern_status_t sys_task_self(kern_handle_t *out);
|
extern kern_status_t sys_task_self(kern_handle_t *out);
|
||||||
extern kern_status_t sys_task_create(
|
extern kern_status_t sys_task_create(
|
||||||
kern_handle_t parent_handle,
|
kern_handle_t parent_handle,
|
||||||
|
task_flags_t flags,
|
||||||
const char *name,
|
const char *name,
|
||||||
size_t name_len,
|
size_t name_len,
|
||||||
kern_handle_t *out_task,
|
kern_handle_t *out_task,
|
||||||
|
|||||||
+13
-2
@@ -40,9 +40,10 @@ struct task {
|
|||||||
extern struct task *task_alloc(void);
|
extern struct task *task_alloc(void);
|
||||||
extern struct task *task_cast(struct object *obj);
|
extern struct task *task_cast(struct object *obj);
|
||||||
extern struct task *task_create(
|
extern struct task *task_create(
|
||||||
|
struct task *parent,
|
||||||
|
task_flags_t flags,
|
||||||
const char *name,
|
const char *name,
|
||||||
size_t name_len,
|
size_t name_len);
|
||||||
struct handle_table *handles);
|
|
||||||
static inline struct task *task_ref(struct task *task)
|
static inline struct task *task_ref(struct task *task)
|
||||||
{
|
{
|
||||||
return OBJECT_CAST(struct task, t_base, object_ref(&task->t_base));
|
return OBJECT_CAST(struct task, t_base, object_ref(&task->t_base));
|
||||||
@@ -69,6 +70,16 @@ extern kern_status_t task_resolve_handle(
|
|||||||
kern_handle_t handle,
|
kern_handle_t handle,
|
||||||
struct object **out_obj,
|
struct object **out_obj,
|
||||||
handle_flags_t *out_flags);
|
handle_flags_t *out_flags);
|
||||||
|
extern kern_status_t task_config_get(
|
||||||
|
struct task *task,
|
||||||
|
kern_config_key_t key,
|
||||||
|
void *out,
|
||||||
|
size_t max);
|
||||||
|
extern kern_status_t task_config_set(
|
||||||
|
struct task *task,
|
||||||
|
kern_config_key_t key,
|
||||||
|
const void *ptr,
|
||||||
|
size_t len);
|
||||||
extern kern_status_t task_close_handle(struct task *task, kern_handle_t handle);
|
extern kern_status_t task_close_handle(struct task *task, kern_handle_t handle);
|
||||||
extern struct thread *task_create_thread(struct task *parent);
|
extern struct thread *task_create_thread(struct task *parent);
|
||||||
extern struct task *kernel_task(void);
|
extern struct task *kernel_task(void);
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#ifndef KERNEL_TYPES_H_
|
#ifndef KERNEL_TYPES_H_
|
||||||
#define KERNEL_TYPES_H_
|
#define KERNEL_TYPES_H_
|
||||||
|
|
||||||
#include <mango/types.h>
|
#include <magenta/types.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#ifndef KERNEL_UTIL_H_
|
#ifndef KERNEL_UTIL_H_
|
||||||
#define KERNEL_UTIL_H_
|
#define KERNEL_UTIL_H_
|
||||||
|
|
||||||
#include <mango/types.h>
|
#include <magenta/types.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
#include <kernel/locks.h>
|
#include <kernel/locks.h>
|
||||||
#include <kernel/object.h>
|
#include <kernel/object.h>
|
||||||
#include <mango/types.h>
|
#include <magenta/types.h>
|
||||||
|
|
||||||
struct thread;
|
struct thread;
|
||||||
struct equeue;
|
struct equeue;
|
||||||
|
|||||||
@@ -98,6 +98,16 @@ extern kern_status_t vm_object_attach_cow(
|
|||||||
struct vm_object *vmo,
|
struct vm_object *vmo,
|
||||||
unsigned long *irq_flags);
|
unsigned long *irq_flags);
|
||||||
|
|
||||||
|
/* prefetch any missing pages in the specified range of a vm-object.
|
||||||
|
* any lazy-allocated pages will be allocated.
|
||||||
|
* any missing pages will be requested from the vm-controller, if one is
|
||||||
|
* attached. */
|
||||||
|
extern kern_status_t vm_object_prefetch(
|
||||||
|
struct vm_object *vo,
|
||||||
|
off_t offset,
|
||||||
|
size_t length,
|
||||||
|
unsigned long *irq_flags);
|
||||||
|
|
||||||
extern struct vm_page *vm_object_get_page(
|
extern struct vm_page *vm_object_get_page(
|
||||||
struct vm_object *vo,
|
struct vm_object *vo,
|
||||||
off_t offset,
|
off_t offset,
|
||||||
|
|||||||
+1
-1
@@ -8,7 +8,7 @@
|
|||||||
#include <kernel/machine/vm.h>
|
#include <kernel/machine/vm.h>
|
||||||
#include <kernel/queue.h>
|
#include <kernel/queue.h>
|
||||||
#include <kernel/types.h>
|
#include <kernel/types.h>
|
||||||
#include <mango/status.h>
|
#include <magenta/status.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|||||||
+3
-2
@@ -23,7 +23,7 @@ extern char __pstart[], __pend[];
|
|||||||
|
|
||||||
void print_kernel_banner(void)
|
void print_kernel_banner(void)
|
||||||
{
|
{
|
||||||
printk("Mango kernel version " BUILD_ID);
|
printk("Magenta kernel version " BUILD_ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void hang(void)
|
static void hang(void)
|
||||||
@@ -108,7 +108,8 @@ void kernel_init(uintptr_t arg)
|
|||||||
bsp.bsp_trailer.bsp_exec_entry,
|
bsp.bsp_trailer.bsp_exec_entry,
|
||||||
bsp.bsp_vmo);
|
bsp.bsp_vmo);
|
||||||
|
|
||||||
struct task *bootstrap_task = task_create("bootstrap", 9, NULL);
|
struct task *bootstrap_task
|
||||||
|
= task_create(NULL, TASK_F_DEFAULT, "bootstrap", 9);
|
||||||
tracek("created bootstrap task (pid=%u)", bootstrap_task->t_id);
|
tracek("created bootstrap task (pid=%u)", bootstrap_task->t_id);
|
||||||
|
|
||||||
status = bsp_launch_async(&bsp, bootstrap_task);
|
status = bsp_launch_async(&bsp, bootstrap_task);
|
||||||
|
|||||||
+1
-1
@@ -1,7 +1,7 @@
|
|||||||
#include <kernel/arg.h>
|
#include <kernel/arg.h>
|
||||||
#include <kernel/libc/ctype.h>
|
#include <kernel/libc/ctype.h>
|
||||||
#include <kernel/libc/string.h>
|
#include <kernel/libc/string.h>
|
||||||
#include <mango/status.h>
|
#include <magenta/status.h>
|
||||||
|
|
||||||
static char g_cmdline[CMDLINE_MAX + 1] = {0};
|
static char g_cmdline[CMDLINE_MAX + 1] = {0};
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -6,7 +6,7 @@
|
|||||||
#include <kernel/task.h>
|
#include <kernel/task.h>
|
||||||
#include <kernel/thread.h>
|
#include <kernel/thread.h>
|
||||||
#include <kernel/util.h>
|
#include <kernel/util.h>
|
||||||
#include <mango/signal.h>
|
#include <magenta/signal.h>
|
||||||
|
|
||||||
#define CHANNEL_CAST(p) OBJECT_C_CAST(struct channel, c_base, &channel_type, p)
|
#define CHANNEL_CAST(p) OBJECT_C_CAST(struct channel, c_base, &channel_type, p)
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -2,7 +2,7 @@
|
|||||||
#include <kernel/futex.h>
|
#include <kernel/futex.h>
|
||||||
#include <kernel/sched.h>
|
#include <kernel/sched.h>
|
||||||
#include <kernel/task.h>
|
#include <kernel/task.h>
|
||||||
#include <mango/status.h>
|
#include <magenta/status.h>
|
||||||
|
|
||||||
#define FUTEX_CREATE 0x40u
|
#define FUTEX_CREATE 0x40u
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -5,7 +5,7 @@
|
|||||||
#include <kernel/sched.h>
|
#include <kernel/sched.h>
|
||||||
#include <kernel/util.h>
|
#include <kernel/util.h>
|
||||||
#include <kernel/vm.h>
|
#include <kernel/vm.h>
|
||||||
#include <mango/types.h>
|
#include <magenta/types.h>
|
||||||
|
|
||||||
/* depth=3 gives a maximum of ~66.6 million handles */
|
/* depth=3 gives a maximum of ~66.6 million handles */
|
||||||
#define MAX_TABLE_DEPTH 3
|
#define MAX_TABLE_DEPTH 3
|
||||||
|
|||||||
+2
-2
@@ -1,5 +1,5 @@
|
|||||||
#include <mango/status.h>
|
#include <magenta/status.h>
|
||||||
#include <mango/types.h>
|
#include <magenta/types.h>
|
||||||
|
|
||||||
#define ERROR_STRING_CASE(code) \
|
#define ERROR_STRING_CASE(code) \
|
||||||
case code: \
|
case code: \
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
file(GLOB headers ${CMAKE_CURRENT_SOURCE_DIR}/include/mango/*.h)
|
file(GLOB headers ${CMAKE_CURRENT_SOURCE_DIR}/include/magenta/*.h)
|
||||||
file(GLOB asm_sources
|
file(GLOB asm_sources
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/arch/${CMAKE_SYSTEM_PROCESSOR}/*.S)
|
${CMAKE_CURRENT_SOURCE_DIR}/arch/${CMAKE_SYSTEM_PROCESSOR}/*.S)
|
||||||
|
|
||||||
@@ -6,7 +6,7 @@ set(public_include_dirs
|
|||||||
${CMAKE_CURRENT_SOURCE_DIR}/include
|
${CMAKE_CURRENT_SOURCE_DIR}/include
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/include-user)
|
${CMAKE_CURRENT_SOURCE_DIR}/include-user)
|
||||||
|
|
||||||
add_library(libmango STATIC ${asm_sources})
|
add_library(libmagenta STATIC ${asm_sources})
|
||||||
target_include_directories(libmango PUBLIC
|
target_include_directories(libmagenta PUBLIC
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/include
|
${CMAKE_CURRENT_SOURCE_DIR}/include
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/include-user)
|
${CMAKE_CURRENT_SOURCE_DIR}/include-user)
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
#include "mango/syscall.h"
|
#include "magenta/syscall.h"
|
||||||
|
|
||||||
# Registers:
|
# Registers:
|
||||||
# rax = syscall ID + return value
|
# rax = syscall ID + return value
|
||||||
@@ -57,7 +57,7 @@
|
|||||||
|
|
||||||
SYSCALL_GATE task_exit SYS_TASK_EXIT 1
|
SYSCALL_GATE task_exit SYS_TASK_EXIT 1
|
||||||
SYSCALL_GATE task_self SYS_TASK_SELF 1
|
SYSCALL_GATE task_self SYS_TASK_SELF 1
|
||||||
SYSCALL_GATE task_create SYS_TASK_CREATE 5
|
SYSCALL_GATE task_create SYS_TASK_CREATE 6
|
||||||
SYSCALL_GATE task_duplicate SYS_TASK_DUPLICATE 2
|
SYSCALL_GATE task_duplicate SYS_TASK_DUPLICATE 2
|
||||||
SYSCALL_GATE task_create_thread SYS_TASK_CREATE_THREAD 6
|
SYSCALL_GATE task_create_thread SYS_TASK_CREATE_THREAD 6
|
||||||
SYSCALL_GATE task_get_address_space SYS_TASK_GET_ADDRESS_SPACE 1
|
SYSCALL_GATE task_get_address_space SYS_TASK_GET_ADDRESS_SPACE 1
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
#ifndef MANGO_CONFIG_H_
|
#ifndef MAGENTA_CONFIG_H_
|
||||||
#define MANGO_CONFIG_H_
|
#define MAGENTA_CONFIG_H_
|
||||||
|
|
||||||
#include <mango/status.h>
|
#include <magenta/status.h>
|
||||||
#include <mango/types.h>
|
#include <magenta/types.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
|
||||||
extern kern_status_t kern_config_get(
|
extern kern_status_t kern_config_get(
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
#ifndef MANGO_EQUEUE_H_
|
#ifndef MAGENTA_EQUEUE_H_
|
||||||
#define MANGO_EQUEUE_H_
|
#define MAGENTA_EQUEUE_H_
|
||||||
|
|
||||||
#include <mango/types.h>
|
#include <magenta/types.h>
|
||||||
|
|
||||||
extern kern_status_t equeue_create(kern_handle_t *out);
|
extern kern_status_t equeue_create(kern_handle_t *out);
|
||||||
extern kern_status_t equeue_dequeue(kern_handle_t eq, equeue_packet_t *out);
|
extern kern_status_t equeue_dequeue(kern_handle_t eq, equeue_packet_t *out);
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
#ifndef MANGO_FUTEX_H_
|
#ifndef MAGENTA_FUTEX_H_
|
||||||
#define MANGO_FUTEX_H_
|
#define MAGENTA_FUTEX_H_
|
||||||
|
|
||||||
#include <mango/status.h>
|
#include <magenta/status.h>
|
||||||
#include <mango/types.h>
|
#include <magenta/types.h>
|
||||||
|
|
||||||
extern kern_status_t futex_wait(
|
extern kern_status_t futex_wait(
|
||||||
kern_futex_t *futex,
|
kern_futex_t *futex,
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
#ifndef MANGO_HANDLE_H_
|
#ifndef MAGENTA_HANDLE_H_
|
||||||
#define MANGO_HANDLE_H_
|
#define MAGENTA_HANDLE_H_
|
||||||
|
|
||||||
#include <mango/status.h>
|
#include <magenta/status.h>
|
||||||
#include <mango/types.h>
|
#include <magenta/types.h>
|
||||||
|
|
||||||
extern kern_status_t kern_handle_close(kern_handle_t handle);
|
extern kern_status_t kern_handle_close(kern_handle_t handle);
|
||||||
extern kern_status_t kern_handle_transfer(
|
extern kern_status_t kern_handle_transfer(
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
#ifndef MANGO_LOG_H_
|
#ifndef MAGENTA_LOG_H_
|
||||||
#define MANGO_LOG_H_
|
#define MAGENTA_LOG_H_
|
||||||
|
|
||||||
#include <mango/status.h>
|
#include <magenta/status.h>
|
||||||
#include <mango/types.h>
|
#include <magenta/types.h>
|
||||||
|
|
||||||
#undef TRACE
|
#undef TRACE
|
||||||
|
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
#ifndef MANGO_MSG_H_
|
#ifndef MAGENTA_MSG_H_
|
||||||
#define MANGO_MSG_H_
|
#define MAGENTA_MSG_H_
|
||||||
|
|
||||||
#include <mango/status.h>
|
#include <magenta/status.h>
|
||||||
#include <mango/types.h>
|
#include <magenta/types.h>
|
||||||
|
|
||||||
extern kern_status_t channel_create(unsigned int id, kern_handle_t *out);
|
extern kern_status_t channel_create(unsigned int id, kern_handle_t *out);
|
||||||
extern kern_status_t port_create(kern_handle_t *out);
|
extern kern_status_t port_create(kern_handle_t *out);
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
#ifndef MANGO_OBJECT_H_
|
#ifndef MAGENTA_OBJECT_H_
|
||||||
#define MANGO_OBJECT_H_
|
#define MAGENTA_OBJECT_H_
|
||||||
|
|
||||||
#include <mango/types.h>
|
#include <magenta/types.h>
|
||||||
|
|
||||||
extern kern_status_t kern_object_wait(kern_wait_item_t *items, size_t nr_items);
|
extern kern_status_t kern_object_wait(kern_wait_item_t *items, size_t nr_items);
|
||||||
extern kern_status_t kern_object_query(
|
extern kern_status_t kern_object_query(
|
||||||
@@ -1,14 +1,15 @@
|
|||||||
#ifndef MANGO_TASK_H_
|
#ifndef MAGENTA_TASK_H_
|
||||||
#define MANGO_TASK_H_
|
#define MAGENTA_TASK_H_
|
||||||
|
|
||||||
#include <mango/status.h>
|
#include <magenta/status.h>
|
||||||
#include <mango/types.h>
|
#include <magenta/types.h>
|
||||||
|
|
||||||
extern kern_status_t task_exit(int status);
|
extern kern_status_t task_exit(int status);
|
||||||
extern kern_status_t task_self(kern_handle_t *out);
|
extern kern_status_t task_self(kern_handle_t *out);
|
||||||
|
|
||||||
extern kern_status_t task_create(
|
extern kern_status_t task_create(
|
||||||
kern_handle_t parent,
|
kern_handle_t parent,
|
||||||
|
task_flags_t flags,
|
||||||
const char *name,
|
const char *name,
|
||||||
size_t name_len,
|
size_t name_len,
|
||||||
kern_handle_t *out_task,
|
kern_handle_t *out_task,
|
||||||
@@ -36,6 +37,13 @@ extern kern_status_t task_config_set(
|
|||||||
extern kern_status_t task_duplicate(
|
extern kern_status_t task_duplicate(
|
||||||
kern_handle_t *out_task,
|
kern_handle_t *out_task,
|
||||||
kern_handle_t *out_address_space);
|
kern_handle_t *out_address_space);
|
||||||
|
extern kern_status_t task_reset(
|
||||||
|
virt_addr_t ip,
|
||||||
|
virt_addr_t sp,
|
||||||
|
uintptr_t *args,
|
||||||
|
size_t nr_args,
|
||||||
|
virt_addr_t unmap_base,
|
||||||
|
size_t unmap_length);
|
||||||
|
|
||||||
extern kern_status_t thread_self(kern_handle_t *out);
|
extern kern_status_t thread_self(kern_handle_t *out);
|
||||||
extern kern_status_t thread_start(kern_handle_t thread);
|
extern kern_status_t thread_start(kern_handle_t thread);
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
#ifndef MANGO_VM_H_
|
#ifndef MAGENTA_VM_H_
|
||||||
#define MANGO_VM_H_
|
#define MAGENTA_VM_H_
|
||||||
|
|
||||||
#include <mango/status.h>
|
#include <magenta/status.h>
|
||||||
#include <mango/types.h>
|
#include <magenta/types.h>
|
||||||
|
|
||||||
extern kern_status_t vm_object_create(
|
extern kern_status_t vm_object_create(
|
||||||
const char *name,
|
const char *name,
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
#ifndef MANGO_SIGNAL_H_
|
#ifndef MAGENTA_SIGNAL_H_
|
||||||
#define MANGO_SIGNAL_H_
|
#define MAGENTA_SIGNAL_H_
|
||||||
|
|
||||||
#define THREAD_SIGNAL_STOPPED 0x01u
|
#define THREAD_SIGNAL_STOPPED 0x01u
|
||||||
|
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
#ifndef MANGO_STATUS_H_
|
#ifndef MAGENTA_STATUS_H_
|
||||||
#define MANGO_STATUS_H_
|
#define MAGENTA_STATUS_H_
|
||||||
|
|
||||||
#define KERN_OK (0)
|
#define KERN_OK (0)
|
||||||
#define KERN_UNIMPLEMENTED (1)
|
#define KERN_UNIMPLEMENTED (1)
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
#ifndef MANGO_SYSCALL_H_
|
#ifndef MAGENTA_SYSCALL_H_
|
||||||
#define MANGO_SYSCALL_H_
|
#define MAGENTA_SYSCALL_H_
|
||||||
|
|
||||||
#define SYS_KERN_LOG 1
|
#define SYS_KERN_LOG 1
|
||||||
#define SYS_KERN_HANDLE_CLOSE 2
|
#define SYS_KERN_HANDLE_CLOSE 2
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
#ifndef MANGO_TYPES_H_
|
#ifndef MAGENTA_TYPES_H_
|
||||||
#define MANGO_TYPES_H_
|
#define MAGENTA_TYPES_H_
|
||||||
|
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
@@ -16,12 +16,17 @@
|
|||||||
#define MAP_ADDRESS_INVALID ((virt_addr_t)0)
|
#define MAP_ADDRESS_INVALID ((virt_addr_t)0)
|
||||||
#define KERN_HANDLE_INVALID ((kern_handle_t)0xFFFFFFFF)
|
#define KERN_HANDLE_INVALID ((kern_handle_t)0xFFFFFFFF)
|
||||||
|
|
||||||
|
/* task creation flags */
|
||||||
|
#define TASK_F_DEFAULT 0x0000u
|
||||||
|
#define TASK_F_CLONE_ALL_HANDLES 0x0001u
|
||||||
|
|
||||||
/* config keys for use with kern_config_get/kern_config_set */
|
/* config keys for use with kern_config_get/kern_config_set */
|
||||||
#define KERN_CFG_INVALID 0x00000u
|
#define KERN_CFG_INVALID 0x00000u
|
||||||
#define KERN_CFG_PAGE_SIZE 0x00001u
|
#define KERN_CFG_PAGE_SIZE 0x00001u
|
||||||
|
|
||||||
/* config keys for use with task_config_get/task_config_set */
|
/* config keys for use with task_config_get/task_config_set */
|
||||||
#define TASK_CFG_INVALID 0x00000u
|
#define TASK_CFG_INVALID 0x00000u
|
||||||
|
#define TASK_CFG_ID 0x10001u
|
||||||
|
|
||||||
/* config keys for use with thread_config_get/thread_config_set */
|
/* config keys for use with thread_config_get/thread_config_set */
|
||||||
#define THREAD_CFG_INVALID 0x00000u
|
#define THREAD_CFG_INVALID 0x00000u
|
||||||
@@ -118,6 +123,7 @@ typedef uint32_t kern_handle_t;
|
|||||||
typedef uint32_t kern_config_key_t;
|
typedef uint32_t kern_config_key_t;
|
||||||
typedef uint32_t vm_prot_t;
|
typedef uint32_t vm_prot_t;
|
||||||
typedef uint32_t vm_flags_t;
|
typedef uint32_t vm_flags_t;
|
||||||
|
typedef uint32_t task_flags_t;
|
||||||
typedef int64_t ssize_t;
|
typedef int64_t ssize_t;
|
||||||
typedef uint32_t kern_futex_t;
|
typedef uint32_t kern_futex_t;
|
||||||
typedef uint32_t kern_msg_type_t;
|
typedef uint32_t kern_msg_type_t;
|
||||||
+50
-5
@@ -172,10 +172,12 @@ struct task *task_alloc(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
struct task *task_create(
|
struct task *task_create(
|
||||||
|
struct task *parent,
|
||||||
|
task_flags_t task_flags,
|
||||||
const char *name,
|
const char *name,
|
||||||
size_t name_len,
|
size_t name_len)
|
||||||
struct handle_table *handles)
|
|
||||||
{
|
{
|
||||||
|
kern_status_t status = KERN_OK;
|
||||||
struct task *task = task_alloc();
|
struct task *task = task_alloc();
|
||||||
if (!task) {
|
if (!task) {
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -194,13 +196,21 @@ struct task *task_create(
|
|||||||
VM_USER_LIMIT,
|
VM_USER_LIMIT,
|
||||||
&task->t_address_space);
|
&task->t_address_space);
|
||||||
|
|
||||||
if (!handles) {
|
if (task_flags & TASK_F_CLONE_ALL_HANDLES) {
|
||||||
handles = handle_table_create();
|
status = handle_table_duplicate(
|
||||||
|
parent->t_handles,
|
||||||
|
&task->t_handles);
|
||||||
|
} else {
|
||||||
|
task->t_handles = handle_table_create();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (status != KERN_OK) {
|
||||||
|
object_unref(&task->t_base);
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
task->t_address_space->s_pmap = pmap;
|
task->t_address_space->s_pmap = pmap;
|
||||||
task->t_state = TASK_RUNNING;
|
task->t_state = TASK_RUNNING;
|
||||||
task->t_handles = handles;
|
|
||||||
|
|
||||||
if (name) {
|
if (name) {
|
||||||
name_len = MIN(name_len, sizeof task->t_name - 1);
|
name_len = MIN(name_len, sizeof task->t_name - 1);
|
||||||
@@ -287,6 +297,40 @@ struct task *task_from_tid(tid_t id)
|
|||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
kern_status_t task_config_get(
|
||||||
|
struct task *task,
|
||||||
|
kern_config_key_t key,
|
||||||
|
void *out,
|
||||||
|
size_t max)
|
||||||
|
{
|
||||||
|
switch (key) {
|
||||||
|
case TASK_CFG_ID: {
|
||||||
|
if (max != sizeof(tid_t)) {
|
||||||
|
return KERN_INVALID_ARGUMENT;
|
||||||
|
}
|
||||||
|
|
||||||
|
tid_t *value = out;
|
||||||
|
*value = task->t_id;
|
||||||
|
return KERN_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
return KERN_INVALID_ARGUMENT;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
kern_status_t task_config_set(
|
||||||
|
struct task *task,
|
||||||
|
kern_config_key_t key,
|
||||||
|
const void *ptr,
|
||||||
|
size_t len)
|
||||||
|
{
|
||||||
|
switch (key) {
|
||||||
|
default:
|
||||||
|
return KERN_INVALID_ARGUMENT;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void task_exit(int status)
|
void task_exit(int status)
|
||||||
{
|
{
|
||||||
struct task *self = get_current_task();
|
struct task *self = get_current_task();
|
||||||
@@ -332,6 +376,7 @@ void task_exit(int status)
|
|||||||
spin_lock(&self->t_handles_lock);
|
spin_lock(&self->t_handles_lock);
|
||||||
|
|
||||||
pmap_switch(get_kernel_pmap());
|
pmap_switch(get_kernel_pmap());
|
||||||
|
self->t_address_space->s_pmap = PMAP_INVALID;
|
||||||
pmap_destroy(self->t_pmap);
|
pmap_destroy(self->t_pmap);
|
||||||
|
|
||||||
task_unlock(self);
|
task_unlock(self);
|
||||||
|
|||||||
+1
-1
@@ -5,7 +5,7 @@
|
|||||||
#include <kernel/printk.h>
|
#include <kernel/printk.h>
|
||||||
#include <kernel/task.h>
|
#include <kernel/task.h>
|
||||||
#include <kernel/thread.h>
|
#include <kernel/thread.h>
|
||||||
#include <mango/signal.h>
|
#include <magenta/signal.h>
|
||||||
|
|
||||||
#define THREAD_CAST(p) OBJECT_C_CAST(struct thread, tr_base, &thread_type, p)
|
#define THREAD_CAST(p) OBJECT_C_CAST(struct thread, tr_base, &thread_type, p)
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,8 @@ static const virt_addr_t syscall_table[] = {
|
|||||||
SYSCALL_TABLE_ENTRY(TASK_CREATE_THREAD, task_create_thread),
|
SYSCALL_TABLE_ENTRY(TASK_CREATE_THREAD, task_create_thread),
|
||||||
SYSCALL_TABLE_ENTRY(TASK_GET_ADDRESS_SPACE, task_get_address_space),
|
SYSCALL_TABLE_ENTRY(TASK_GET_ADDRESS_SPACE, task_get_address_space),
|
||||||
SYSCALL_TABLE_ENTRY(TASK_DUPLICATE, task_duplicate),
|
SYSCALL_TABLE_ENTRY(TASK_DUPLICATE, task_duplicate),
|
||||||
|
SYSCALL_TABLE_ENTRY(TASK_CONFIG_GET, task_config_get),
|
||||||
|
SYSCALL_TABLE_ENTRY(TASK_CONFIG_SET, task_config_set),
|
||||||
SYSCALL_TABLE_ENTRY(THREAD_SELF, thread_self),
|
SYSCALL_TABLE_ENTRY(THREAD_SELF, thread_self),
|
||||||
SYSCALL_TABLE_ENTRY(THREAD_START, thread_start),
|
SYSCALL_TABLE_ENTRY(THREAD_START, thread_start),
|
||||||
SYSCALL_TABLE_ENTRY(THREAD_EXIT, thread_exit),
|
SYSCALL_TABLE_ENTRY(THREAD_EXIT, thread_exit),
|
||||||
|
|||||||
+4
-2
@@ -61,6 +61,7 @@ kern_status_t sys_kern_handle_transfer(
|
|||||||
src_task = task_cast(obj);
|
src_task = task_cast(obj);
|
||||||
if (!src_task) {
|
if (!src_task) {
|
||||||
status = KERN_INVALID_ARGUMENT;
|
status = KERN_INVALID_ARGUMENT;
|
||||||
|
task_unlock_irqrestore(self, flags);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -81,6 +82,7 @@ kern_status_t sys_kern_handle_transfer(
|
|||||||
dest_task = task_cast(obj);
|
dest_task = task_cast(obj);
|
||||||
if (!dest_task) {
|
if (!dest_task) {
|
||||||
status = KERN_INVALID_ARGUMENT;
|
status = KERN_INVALID_ARGUMENT;
|
||||||
|
task_unlock_irqrestore(self, flags);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -92,12 +94,12 @@ kern_status_t sys_kern_handle_transfer(
|
|||||||
src_handle,
|
src_handle,
|
||||||
&src_object,
|
&src_object,
|
||||||
&handle_flags);
|
&handle_flags);
|
||||||
|
task_unlock_irqrestore(self, flags);
|
||||||
|
|
||||||
if (status != KERN_OK) {
|
if (status != KERN_OK) {
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
task_unlock_irqrestore(self, flags);
|
|
||||||
|
|
||||||
struct handle *dest = NULL;
|
struct handle *dest = NULL;
|
||||||
task_lock_irqsave(dest_task, &flags);
|
task_lock_irqsave(dest_task, &flags);
|
||||||
status = handle_table_alloc_handle(
|
status = handle_table_alloc_handle(
|
||||||
|
|||||||
+2
-2
@@ -4,8 +4,8 @@
|
|||||||
#include <kernel/task.h>
|
#include <kernel/task.h>
|
||||||
#include <kernel/thread.h>
|
#include <kernel/thread.h>
|
||||||
#include <kernel/wait.h>
|
#include <kernel/wait.h>
|
||||||
#include <mango/status.h>
|
#include <magenta/status.h>
|
||||||
#include <mango/types.h>
|
#include <magenta/types.h>
|
||||||
|
|
||||||
kern_status_t sys_kern_object_wait(kern_wait_item_t *items, size_t nr_items)
|
kern_status_t sys_kern_object_wait(kern_wait_item_t *items, size_t nr_items)
|
||||||
{
|
{
|
||||||
|
|||||||
+89
-15
@@ -53,6 +53,7 @@ kern_status_t sys_task_self(kern_handle_t *out)
|
|||||||
|
|
||||||
kern_status_t sys_task_create(
|
kern_status_t sys_task_create(
|
||||||
kern_handle_t parent_handle,
|
kern_handle_t parent_handle,
|
||||||
|
task_flags_t task_flags,
|
||||||
const char *name,
|
const char *name,
|
||||||
size_t name_len,
|
size_t name_len,
|
||||||
kern_handle_t *out_task,
|
kern_handle_t *out_task,
|
||||||
@@ -124,7 +125,7 @@ kern_status_t sys_task_create(
|
|||||||
|
|
||||||
task_unlock_irqrestore(self, flags);
|
task_unlock_irqrestore(self, flags);
|
||||||
|
|
||||||
struct task *child = task_create(name, name_len, NULL);
|
struct task *child = task_create(parent, task_flags, name, name_len);
|
||||||
if (!child) {
|
if (!child) {
|
||||||
object_unref(parent_obj);
|
object_unref(parent_obj);
|
||||||
|
|
||||||
@@ -291,6 +292,89 @@ kern_status_t sys_task_get_address_space(
|
|||||||
return KERN_OK;
|
return KERN_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
kern_status_t sys_task_config_get(
|
||||||
|
kern_handle_t task_handle,
|
||||||
|
kern_config_key_t key,
|
||||||
|
void *ptr,
|
||||||
|
size_t len)
|
||||||
|
{
|
||||||
|
unsigned long flags;
|
||||||
|
struct task *self = get_current_task();
|
||||||
|
|
||||||
|
if (!validate_access_w(self, ptr, len)) {
|
||||||
|
put_current_task(self);
|
||||||
|
return KERN_MEMORY_FAULT;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct object *task_obj;
|
||||||
|
handle_flags_t task_flags;
|
||||||
|
task_lock_irqsave(self, &flags);
|
||||||
|
kern_status_t status = task_resolve_handle(
|
||||||
|
self,
|
||||||
|
task_handle,
|
||||||
|
&task_obj,
|
||||||
|
&task_flags);
|
||||||
|
put_current_task(self);
|
||||||
|
task_unlock_irqrestore(self, flags);
|
||||||
|
|
||||||
|
if (status != KERN_OK) {
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct task *task = task_cast(task_obj);
|
||||||
|
task_unlock_irqrestore(self, flags);
|
||||||
|
|
||||||
|
if (task) {
|
||||||
|
status = task_config_get(task, key, ptr, len);
|
||||||
|
} else {
|
||||||
|
status = KERN_INVALID_ARGUMENT;
|
||||||
|
}
|
||||||
|
|
||||||
|
object_unref(task_obj);
|
||||||
|
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
kern_status_t sys_task_config_set(
|
||||||
|
kern_handle_t task_handle,
|
||||||
|
kern_config_key_t key,
|
||||||
|
const void *ptr,
|
||||||
|
size_t len)
|
||||||
|
{
|
||||||
|
unsigned long flags;
|
||||||
|
struct task *self = get_current_task();
|
||||||
|
|
||||||
|
if (!validate_access_w(self, ptr, len)) {
|
||||||
|
put_current_task(self);
|
||||||
|
return KERN_MEMORY_FAULT;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct object *task_obj;
|
||||||
|
handle_flags_t task_flags;
|
||||||
|
task_lock_irqsave(self, &flags);
|
||||||
|
kern_status_t status = task_resolve_handle(
|
||||||
|
self,
|
||||||
|
task_handle,
|
||||||
|
&task_obj,
|
||||||
|
&task_flags);
|
||||||
|
task_unlock_irqrestore(self, flags);
|
||||||
|
put_current_task(self);
|
||||||
|
if (status != KERN_OK) {
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct task *task = task_cast(task_obj);
|
||||||
|
if (task) {
|
||||||
|
status = task_config_set(task, key, ptr, len);
|
||||||
|
} else {
|
||||||
|
status = KERN_INVALID_ARGUMENT;
|
||||||
|
}
|
||||||
|
|
||||||
|
object_unref(task_obj);
|
||||||
|
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
kern_status_t sys_thread_self(kern_handle_t *out)
|
kern_status_t sys_thread_self(kern_handle_t *out)
|
||||||
{
|
{
|
||||||
struct task *self = get_current_task();
|
struct task *self = get_current_task();
|
||||||
@@ -468,14 +552,6 @@ kern_status_t sys_task_duplicate(
|
|||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
task_lock_irqsave(self, &flags);
|
task_lock_irqsave(self, &flags);
|
||||||
|
|
||||||
struct handle_table *child_handle_table = NULL;
|
|
||||||
status = handle_table_duplicate(self->t_handles, &child_handle_table);
|
|
||||||
if (status != KERN_OK) {
|
|
||||||
task_unlock_irqrestore(self, flags);
|
|
||||||
put_current_task(self);
|
|
||||||
return status;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct handle *child_handle_slot = NULL, *space_handle_slot = NULL;
|
struct handle *child_handle_slot = NULL, *space_handle_slot = NULL;
|
||||||
kern_handle_t child_handle, space_handle;
|
kern_handle_t child_handle, space_handle;
|
||||||
status = handle_table_alloc_handle(
|
status = handle_table_alloc_handle(
|
||||||
@@ -484,7 +560,6 @@ kern_status_t sys_task_duplicate(
|
|||||||
&child_handle_slot,
|
&child_handle_slot,
|
||||||
&child_handle);
|
&child_handle);
|
||||||
if (status != KERN_OK) {
|
if (status != KERN_OK) {
|
||||||
handle_table_destroy(child_handle_table);
|
|
||||||
task_unlock_irqrestore(self, flags);
|
task_unlock_irqrestore(self, flags);
|
||||||
put_current_task(self);
|
put_current_task(self);
|
||||||
return status;
|
return status;
|
||||||
@@ -496,7 +571,6 @@ kern_status_t sys_task_duplicate(
|
|||||||
&space_handle_slot,
|
&space_handle_slot,
|
||||||
&space_handle);
|
&space_handle);
|
||||||
if (status != KERN_OK) {
|
if (status != KERN_OK) {
|
||||||
handle_table_destroy(child_handle_table);
|
|
||||||
handle_table_free_handle(self->t_handles, child_handle);
|
handle_table_free_handle(self->t_handles, child_handle);
|
||||||
task_unlock_irqrestore(self, flags);
|
task_unlock_irqrestore(self, flags);
|
||||||
put_current_task(self);
|
put_current_task(self);
|
||||||
@@ -504,11 +578,11 @@ kern_status_t sys_task_duplicate(
|
|||||||
}
|
}
|
||||||
|
|
||||||
struct task *new_task = task_create(
|
struct task *new_task = task_create(
|
||||||
|
self,
|
||||||
|
TASK_F_CLONE_ALL_HANDLES,
|
||||||
self->t_name,
|
self->t_name,
|
||||||
strlen(self->t_name),
|
strlen(self->t_name));
|
||||||
child_handle_table);
|
|
||||||
if (!new_task) {
|
if (!new_task) {
|
||||||
handle_table_destroy(child_handle_table);
|
|
||||||
put_current_task(self);
|
put_current_task(self);
|
||||||
return KERN_NO_MEMORY;
|
return KERN_NO_MEMORY;
|
||||||
}
|
}
|
||||||
@@ -546,7 +620,7 @@ kern_status_t sys_task_duplicate(
|
|||||||
task_unlock_irqrestore(self, flags);
|
task_unlock_irqrestore(self, flags);
|
||||||
|
|
||||||
/* clear TLB */
|
/* clear TLB */
|
||||||
pmap_switch(self->t_pmap);
|
pmap_flush();
|
||||||
put_current_task(self);
|
put_current_task(self);
|
||||||
|
|
||||||
*out_task = child_handle;
|
*out_task = child_handle;
|
||||||
|
|||||||
@@ -448,5 +448,8 @@ kern_status_t sys_vm_controller_supply_pages(
|
|||||||
object_unref(src_obj);
|
object_unref(src_obj);
|
||||||
put_current_task(self);
|
put_current_task(self);
|
||||||
|
|
||||||
|
/* TODO flush individual pages in vm_object_transfer */
|
||||||
|
pmap_flush();
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|||||||
+41
-9
@@ -58,20 +58,31 @@ kern_status_t sys_vm_object_read(
|
|||||||
|
|
||||||
struct object *obj = NULL;
|
struct object *obj = NULL;
|
||||||
handle_flags_t flags = 0;
|
handle_flags_t flags = 0;
|
||||||
|
unsigned long irq_flags = 0;
|
||||||
|
task_lock_irqsave(self, &irq_flags);
|
||||||
kern_status_t status = task_resolve_handle(self, object, &obj, &flags);
|
kern_status_t status = task_resolve_handle(self, object, &obj, &flags);
|
||||||
|
task_unlock_irqrestore(self, irq_flags);
|
||||||
|
put_current_task(self);
|
||||||
|
|
||||||
if (status != KERN_OK) {
|
if (status != KERN_OK) {
|
||||||
put_current_task(self);
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct vm_object *vmo = vm_object_cast(obj);
|
struct vm_object *vmo = vm_object_cast(obj);
|
||||||
if (!vmo) {
|
if (!vmo) {
|
||||||
put_current_task(self);
|
object_unref(obj);
|
||||||
return KERN_INVALID_ARGUMENT;
|
return KERN_INVALID_ARGUMENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
status = vm_object_read(vmo, dst, offset, count, nr_read);
|
vm_object_lock_irqsave(vmo, &irq_flags);
|
||||||
put_current_task(self);
|
status = vm_object_prefetch(vmo, offset, count, &irq_flags);
|
||||||
|
if (status == KERN_OK) {
|
||||||
|
status = vm_object_read(vmo, dst, offset, count, nr_read);
|
||||||
|
}
|
||||||
|
|
||||||
|
vm_object_unlock_irqrestore(vmo, irq_flags);
|
||||||
|
object_unref(obj);
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -97,20 +108,25 @@ kern_status_t sys_vm_object_write(
|
|||||||
|
|
||||||
struct object *obj = NULL;
|
struct object *obj = NULL;
|
||||||
handle_flags_t flags = 0;
|
handle_flags_t flags = 0;
|
||||||
|
unsigned long irq_flags = 0;
|
||||||
|
task_lock_irqsave(self, &irq_flags);
|
||||||
kern_status_t status = task_resolve_handle(self, object, &obj, &flags);
|
kern_status_t status = task_resolve_handle(self, object, &obj, &flags);
|
||||||
|
task_unlock_irqrestore(self, irq_flags);
|
||||||
|
put_current_task(self);
|
||||||
|
|
||||||
if (status != KERN_OK) {
|
if (status != KERN_OK) {
|
||||||
put_current_task(self);
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct vm_object *vmo = vm_object_cast(obj);
|
struct vm_object *vmo = vm_object_cast(obj);
|
||||||
if (!vmo) {
|
if (!vmo) {
|
||||||
put_current_task(self);
|
|
||||||
return KERN_INVALID_ARGUMENT;
|
return KERN_INVALID_ARGUMENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vm_object_lock_irqsave(vmo, &irq_flags);
|
||||||
status = vm_object_write(vmo, src, offset, count, nr_written);
|
status = vm_object_write(vmo, src, offset, count, nr_written);
|
||||||
put_current_task(self);
|
vm_object_unlock_irqrestore(vmo, irq_flags);
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -162,13 +178,28 @@ kern_status_t sys_vm_object_copy(
|
|||||||
put_current_task(self);
|
put_current_task(self);
|
||||||
|
|
||||||
struct vm_object *dst_vmo = vm_object_cast(dst_obj);
|
struct vm_object *dst_vmo = vm_object_cast(dst_obj);
|
||||||
|
if (!dst_vmo) {
|
||||||
|
return KERN_INVALID_ARGUMENT;
|
||||||
|
}
|
||||||
|
|
||||||
struct vm_object *src_vmo = vm_object_cast(src_obj);
|
struct vm_object *src_vmo = vm_object_cast(src_obj);
|
||||||
if (!dst_vmo || !src_vmo) {
|
if (!src_vmo) {
|
||||||
object_unref(src_obj);
|
|
||||||
object_unref(dst_obj);
|
object_unref(dst_obj);
|
||||||
return KERN_INVALID_ARGUMENT;
|
return KERN_INVALID_ARGUMENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned long irq_flags = 0;
|
||||||
|
vm_object_lock_irqsave(src_vmo, &irq_flags);
|
||||||
|
status = vm_object_prefetch(src_vmo, src_offset, count, &irq_flags);
|
||||||
|
vm_object_unlock_irqrestore(src_vmo, irq_flags);
|
||||||
|
|
||||||
|
if (status != KERN_OK) {
|
||||||
|
object_unref(src_obj);
|
||||||
|
object_unref(dst_obj);
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
vm_object_lock_pair_irqsave(src_vmo, dst_vmo, &irq_flags);
|
||||||
status = vm_object_copy(
|
status = vm_object_copy(
|
||||||
dst_vmo,
|
dst_vmo,
|
||||||
dst_offset,
|
dst_offset,
|
||||||
@@ -176,6 +207,7 @@ kern_status_t sys_vm_object_copy(
|
|||||||
src_offset,
|
src_offset,
|
||||||
count,
|
count,
|
||||||
nr_copied);
|
nr_copied);
|
||||||
|
vm_object_unlock_pair_irqrestore(src_vmo, dst_vmo, irq_flags);
|
||||||
|
|
||||||
object_unref(src_obj);
|
object_unref(src_obj);
|
||||||
object_unref(dst_obj);
|
object_unref(dst_obj);
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
cmake_minimum_required(VERSION 3.13)
|
cmake_minimum_required(VERSION 3.13)
|
||||||
project(mango-tools C)
|
project(magenta-tools C)
|
||||||
|
|
||||||
set(tool_dirs e64patch)
|
set(tool_dirs e64patch)
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -10,7 +10,7 @@ floppy_bootsig_check: disabled=0
|
|||||||
floppya: type=1_44
|
floppya: type=1_44
|
||||||
# no floppyb
|
# no floppyb
|
||||||
ata0: enabled=true, ioaddr1=0x1f0, ioaddr2=0x3f0, irq=14
|
ata0: enabled=true, ioaddr1=0x1f0, ioaddr2=0x3f0, irq=14
|
||||||
ata0-master: type=cdrom, path="build/mango-kernel.iso", status=inserted, model="Generic 1234", biosdetect=auto
|
ata0-master: type=cdrom, path="build/magenta-kernel.iso", status=inserted, model="Generic 1234", biosdetect=auto
|
||||||
ata0-slave: type=none
|
ata0-slave: type=none
|
||||||
ata1: enabled=true, ioaddr1=0x170, ioaddr2=0x370, irq=15
|
ata1: enabled=true, ioaddr1=0x170, ioaddr2=0x370, irq=15
|
||||||
ata1-master: type=none
|
ata1-master: type=none
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
menuentry "Mango Kernel" {
|
menuentry "Magenta Kernel" {
|
||||||
multiboot /boot/mango_kernel
|
multiboot /boot/magenta_kernel
|
||||||
boot
|
boot
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,9 +5,9 @@ lldb_cfg=$2
|
|||||||
shift 2
|
shift 2
|
||||||
|
|
||||||
if command -v gdb &> /dev/null; then
|
if command -v gdb &> /dev/null; then
|
||||||
printf " \033[93;1mGDB\033[0m boot/mango_kernel\n"
|
printf " \033[93;1mGDB\033[0m boot/magenta_kernel\n"
|
||||||
tmux \
|
tmux \
|
||||||
new-session -d -s mango-debug "sleep 0.3; gdb -tui -x $gdb_cfg" \; \
|
new-session -d -s magenta-debug "sleep 0.3; gdb -tui -x $gdb_cfg" \; \
|
||||||
split-window -h -l 80 \; \
|
split-window -h -l 80 \; \
|
||||||
split-window -v -l 25 "$@"\; \
|
split-window -v -l 25 "$@"\; \
|
||||||
select-pane -t 1 \; \
|
select-pane -t 1 \; \
|
||||||
@@ -15,9 +15,9 @@ if command -v gdb &> /dev/null; then
|
|||||||
select-pane -t 0
|
select-pane -t 0
|
||||||
|
|
||||||
elif command -v lldb &> /dev/null; then
|
elif command -v lldb &> /dev/null; then
|
||||||
printf " \033[93;1mLLDB\033[0m boot/mango_kernel\n"
|
printf " \033[93;1mLLDB\033[0m boot/magenta_kernel\n"
|
||||||
tmux \
|
tmux \
|
||||||
new-session -d -s mango-debug "sleep 0.1; lldb --source $lldb_cfg" \; \
|
new-session -d -s magenta-debug "sleep 0.1; lldb --source $lldb_cfg" \; \
|
||||||
split-window -h -l 160 \; \
|
split-window -h -l 160 \; \
|
||||||
split-window -v -l 25 "$@"\; \
|
split-window -v -l 25 "$@"\; \
|
||||||
select-pane -t 1 \; \
|
select-pane -t 1 \; \
|
||||||
@@ -28,6 +28,6 @@ else
|
|||||||
exit -1
|
exit -1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
tmux a -t mango-debug
|
tmux a -t magenta-debug
|
||||||
tmux kill-session -t mango-debug
|
tmux kill-session -t magenta-debug
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
set confirm off
|
set confirm off
|
||||||
symbol-file mango_kernel.debug
|
symbol-file magenta_kernel.debug
|
||||||
target remote localhost:1234
|
target remote localhost:1234
|
||||||
set confirm on
|
set confirm on
|
||||||
|
|||||||
@@ -1,2 +1,2 @@
|
|||||||
file mango_kernel.debug
|
file magenta_kernel.debug
|
||||||
gdb-remote localhost:1234
|
gdb-remote localhost:1234
|
||||||
|
|||||||
@@ -116,7 +116,7 @@ def choice_options(num_devices):
|
|||||||
return '1-{}'.format(num_devices)
|
return '1-{}'.format(num_devices)
|
||||||
|
|
||||||
|
|
||||||
if not os.path.isfile('build/mango-kernel.iso'):
|
if not os.path.isfile('build/magenta-kernel.iso'):
|
||||||
print('No system ISO image found.')
|
print('No system ISO image found.')
|
||||||
print('Please run \'make cd\' to generate an ISO image')
|
print('Please run \'make cd\' to generate an ISO image')
|
||||||
exit(-1)
|
exit(-1)
|
||||||
@@ -157,7 +157,7 @@ disk_prewrite(devices[choice][0])
|
|||||||
dd_args = [
|
dd_args = [
|
||||||
'sudo',
|
'sudo',
|
||||||
'dd',
|
'dd',
|
||||||
'if=build/mango-kernel.iso',
|
'if=build/magenta-kernel.iso',
|
||||||
'of={}'.format(devices[choice][0]),
|
'of={}'.format(devices[choice][0]),
|
||||||
'bs=1{}'.format('m' if sys.platform == 'darwin' else 'M')
|
'bs=1{}'.format('m' if sys.platform == 'darwin' else 'M')
|
||||||
]
|
]
|
||||||
@@ -7,22 +7,22 @@ import sys
|
|||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
|
|
||||||
kernel_src_path = os.path.join('build', 'mango_kernel')
|
kernel_src_path = os.path.join('build', 'magenta_kernel')
|
||||||
grub_cfg_src_path = os.path.join('tools', 'boot-image', 'grub.cfg')
|
grub_cfg_src_path = os.path.join('tools', 'boot-image', 'grub.cfg')
|
||||||
iso_build_dir = os.path.join('build', 'mango-kernel.iso-build')
|
iso_build_dir = os.path.join('build', 'magenta-kernel.iso-build')
|
||||||
iso_path = os.path.join('build', 'mango-kernel.iso')
|
iso_path = os.path.join('build', 'magenta-kernel.iso')
|
||||||
|
|
||||||
|
|
||||||
def in_source_tree():
|
def in_source_tree():
|
||||||
return os.path.isfile('tools/mango.sync')
|
return os.path.isfile('tools/magenta.sync')
|
||||||
|
|
||||||
|
|
||||||
if not in_source_tree():
|
if not in_source_tree():
|
||||||
print('This script must be executed from the root of the Mango source tree')
|
print('This script must be executed from the root of the Magenta source tree')
|
||||||
exit(-1)
|
exit(-1)
|
||||||
|
|
||||||
if not os.path.isdir('build'):
|
if not os.path.isdir('build'):
|
||||||
print('Please build the Mango kernel before using this tool')
|
print('Please build the Magenta kernel before using this tool')
|
||||||
exit(-1)
|
exit(-1)
|
||||||
|
|
||||||
if os.path.isdir(iso_build_dir):
|
if os.path.isdir(iso_build_dir):
|
||||||
@@ -33,7 +33,7 @@ os.mkdir(iso_build_dir)
|
|||||||
os.mkdir(os.path.join(iso_build_dir, 'boot'))
|
os.mkdir(os.path.join(iso_build_dir, 'boot'))
|
||||||
os.mkdir(os.path.join(iso_build_dir, 'boot', 'grub'))
|
os.mkdir(os.path.join(iso_build_dir, 'boot', 'grub'))
|
||||||
|
|
||||||
shutil.copyfile(kernel_src_path, os.path.join(iso_build_dir, 'boot', 'mango_kernel'))
|
shutil.copyfile(kernel_src_path, os.path.join(iso_build_dir, 'boot', 'magenta_kernel'))
|
||||||
shutil.copyfile(grub_cfg_src_path, os.path.join(iso_build_dir, 'boot', 'grub', 'grub.cfg'))
|
shutil.copyfile(grub_cfg_src_path, os.path.join(iso_build_dir, 'boot', 'grub', 'grub.cfg'))
|
||||||
|
|
||||||
subprocess.run(['grub-mkrescue', '-o', iso_path, iso_build_dir])
|
subprocess.run(['grub-mkrescue', '-o', iso_path, iso_build_dir])
|
||||||
@@ -16,7 +16,7 @@ rsync_path = os.getenv('RSYNC_PATH', default = 'rsync')
|
|||||||
|
|
||||||
|
|
||||||
def in_source_tree():
|
def in_source_tree():
|
||||||
return os.path.isfile('tools/mango.sync')
|
return os.path.isfile('tools/magenta.sync')
|
||||||
|
|
||||||
|
|
||||||
def create_sample_config():
|
def create_sample_config():
|
||||||
@@ -78,7 +78,7 @@ def print_available_targets(targets):
|
|||||||
|
|
||||||
|
|
||||||
if not in_source_tree():
|
if not in_source_tree():
|
||||||
print('This script must be executed from the root of the Mango source tree')
|
print('This script must be executed from the root of the Magenta source tree')
|
||||||
exit(-1)
|
exit(-1)
|
||||||
|
|
||||||
config = read_config()
|
config = read_config()
|
||||||
+14
-20
@@ -10,7 +10,7 @@
|
|||||||
#include <kernel/util.h>
|
#include <kernel/util.h>
|
||||||
#include <kernel/vm-controller.h>
|
#include <kernel/vm-controller.h>
|
||||||
#include <kernel/vm-object.h>
|
#include <kernel/vm-object.h>
|
||||||
#include <mango/status.h>
|
#include <magenta/status.h>
|
||||||
|
|
||||||
/*** STATIC DATA + MACROS *****************************************************/
|
/*** STATIC DATA + MACROS *****************************************************/
|
||||||
|
|
||||||
@@ -661,9 +661,8 @@ static void area_unmap(struct vm_area *area)
|
|||||||
pmap_t pmap = area->vma_space->s_pmap;
|
pmap_t pmap = area->vma_space->s_pmap;
|
||||||
virt_addr_t base = area->vma_base;
|
virt_addr_t base = area->vma_base;
|
||||||
virt_addr_t limit = area->vma_limit;
|
virt_addr_t limit = area->vma_limit;
|
||||||
for (virt_addr_t i = base; i < limit; i += VM_PAGE_SIZE) {
|
pmap_remove_range(pmap, base, limit - base);
|
||||||
pmap_remove(pmap, i);
|
pmap_flush();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static kern_status_t address_space_cleanup(struct object *obj)
|
static kern_status_t address_space_cleanup(struct object *obj)
|
||||||
@@ -844,11 +843,9 @@ static kern_status_t split_area(
|
|||||||
}
|
}
|
||||||
|
|
||||||
put_entry(&root->s_mappings, right);
|
put_entry(&root->s_mappings, right);
|
||||||
for (size_t i = unmap_base; i < unmap_limit; i += VM_PAGE_SIZE) {
|
|
||||||
tracek("pmap_remove %zx", i);
|
|
||||||
pmap_remove(root->s_pmap, i);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
pmap_remove_range(root->s_pmap, unmap_base, unmap_limit - unmap_base);
|
||||||
|
pmap_flush();
|
||||||
return KERN_OK;
|
return KERN_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -883,10 +880,8 @@ static kern_status_t left_reduce_area(
|
|||||||
}
|
}
|
||||||
|
|
||||||
tracek(" pmap_remove %zx-%zx (%zx bytes)", base, base + length, length);
|
tracek(" pmap_remove %zx-%zx (%zx bytes)", base, base + length, length);
|
||||||
for (size_t i = base; i < limit; i += VM_PAGE_SIZE) {
|
pmap_remove_range(root->s_pmap, base, length);
|
||||||
pmap_remove(root->s_pmap, i);
|
pmap_flush();
|
||||||
}
|
|
||||||
|
|
||||||
return KERN_OK;
|
return KERN_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -920,10 +915,8 @@ static kern_status_t right_reduce_area(
|
|||||||
}
|
}
|
||||||
|
|
||||||
tracek(" pmap_remove %zx-%zx (%zx bytes)", base, base + length, length);
|
tracek(" pmap_remove %zx-%zx (%zx bytes)", base, base + length, length);
|
||||||
for (size_t i = base; i < limit; i += VM_PAGE_SIZE) {
|
pmap_remove_range(root->s_pmap, base, limit - base);
|
||||||
pmap_remove(root->s_pmap, i);
|
pmap_flush();
|
||||||
}
|
|
||||||
|
|
||||||
return KERN_OK;
|
return KERN_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -942,10 +935,11 @@ static kern_status_t delete_area(
|
|||||||
mapping->vma_limit,
|
mapping->vma_limit,
|
||||||
mapping->vma_limit - mapping->vma_base);
|
mapping->vma_limit - mapping->vma_base);
|
||||||
|
|
||||||
for (size_t i = mapping->vma_base; i < mapping->vma_limit;
|
pmap_remove_range(
|
||||||
i += VM_PAGE_SIZE) {
|
root->s_pmap,
|
||||||
pmap_remove(root->s_pmap, i);
|
mapping->vma_base,
|
||||||
}
|
mapping->vma_limit - mapping->vma_base);
|
||||||
|
pmap_flush();
|
||||||
|
|
||||||
struct vm_object *object = mapping->vma_object;
|
struct vm_object *object = mapping->vma_object;
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
|
|||||||
+1
-1
@@ -6,7 +6,7 @@
|
|||||||
#include <kernel/vm-object.h>
|
#include <kernel/vm-object.h>
|
||||||
#include <kernel/vm.h>
|
#include <kernel/vm.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <mango/status.h>
|
#include <magenta/status.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -4,7 +4,7 @@
|
|||||||
#include <kernel/util.h>
|
#include <kernel/util.h>
|
||||||
#include <kernel/vm-controller.h>
|
#include <kernel/vm-controller.h>
|
||||||
#include <kernel/vm-object.h>
|
#include <kernel/vm-object.h>
|
||||||
#include <mango/signal.h>
|
#include <magenta/signal.h>
|
||||||
|
|
||||||
#define VM_CONTROLLER_CAST(p) \
|
#define VM_CONTROLLER_CAST(p) \
|
||||||
OBJECT_C_CAST(struct vm_controller, vc_base, &vm_controller_type, p)
|
OBJECT_C_CAST(struct vm_controller, vc_base, &vm_controller_type, p)
|
||||||
|
|||||||
@@ -516,6 +516,33 @@ static kern_status_t request_page(
|
|||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
kern_status_t vm_object_prefetch(
|
||||||
|
struct vm_object *vo,
|
||||||
|
off_t offset,
|
||||||
|
size_t length,
|
||||||
|
unsigned long *irq_flags)
|
||||||
|
{
|
||||||
|
offset &= ~VM_PAGE_MASK;
|
||||||
|
if (length & VM_PAGE_MASK) {
|
||||||
|
length &= ~VM_PAGE_MASK;
|
||||||
|
length += VM_PAGE_SIZE;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (off_t i = offset; i < offset + length; i += VM_PAGE_SIZE) {
|
||||||
|
struct vm_page *pg = vm_object_get_page(
|
||||||
|
vo,
|
||||||
|
i,
|
||||||
|
VMO_ALLOCATE_MISSING_PAGE | VMO_REQUEST_MISSING_PAGE,
|
||||||
|
irq_flags);
|
||||||
|
if (!pg) {
|
||||||
|
/* TODO get error code from vm_object_get_page */
|
||||||
|
return KERN_NO_MEMORY;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return KERN_OK;
|
||||||
|
}
|
||||||
|
|
||||||
struct vm_page *vm_object_get_page(
|
struct vm_page *vm_object_get_page(
|
||||||
struct vm_object *vo,
|
struct vm_object *vo,
|
||||||
off_t offset,
|
off_t offset,
|
||||||
|
|||||||
Reference in New Issue
Block a user