diff options
Diffstat (limited to 'include')
| -rw-r--r-- | include/apos/assert.h | 13 | ||||
| -rw-r--r-- | include/apos/mem_regions.h | 5 | ||||
| -rw-r--r-- | include/apos/syscalls.h | 3 | ||||
| -rw-r--r-- | include/apos/tcb.h | 21 | ||||
| -rw-r--r-- | include/apos/uapi.h | 3 | ||||
| -rw-r--r-- | include/apos/vmem.h | 2 | ||||
| -rw-r--r-- | include/arch/vmem.h | 6 |
7 files changed, 38 insertions, 15 deletions
diff --git a/include/apos/assert.h b/include/apos/assert.h index 7200fd2..f3d9a4d 100644 --- a/include/apos/assert.h +++ b/include/apos/assert.h @@ -8,24 +8,25 @@ #if !defined(DNDEBUG) #define catastrophic_assert(x) \ do { \ - if (x) { \ - err("catastrophic assertion failed: %s\n", QUOTE(x)); \ + if (unlikely(!(x))) { \ + error("catastrophic assertion failed: %s\n", \ + QUOTE(x)); \ while (1) \ ; \ } \ } while (0); #define hard_assert(x, r) \ - do { \ - if (x) { \ + { \ + if (unlikely(!(x))) { \ warn("hard assertion failed: %s\n", QUOTE(x)); \ return r; \ } \ - } while (0); + } #define soft_assert(x) \ do { \ - if (x) { \ + if (unlikely(!(x))) { \ info("soft assertion failed: %s\n", QUOTE(x)); \ } \ } while (0); diff --git a/include/apos/mem_regions.h b/include/apos/mem_regions.h index efe0592..9f09eff 100644 --- a/include/apos/mem_regions.h +++ b/include/apos/mem_regions.h @@ -7,10 +7,12 @@ #include <arch/vmem.h> #define mem_container(ptr) container_of(ptr, struct mem_region, sp_n) +#define is_region_used(r) __is_set(r->flags, MR_USED) struct mem_region_root { struct sp_root free_regions; struct sp_root used_regions; + struct mem_region *first; }; struct mem_region { @@ -26,7 +28,7 @@ struct mem_region { }; stat_t init_region(struct mem_region_root *r, vm_t start, size_t arena_size); -void destroy_region(struct mem_region_root *r); +stat_t destroy_region(struct mem_region_root *r); vm_t alloc_region(struct mem_region_root *r, size_t size, size_t *actual_size, vmflags_t flags); @@ -35,6 +37,7 @@ vm_t alloc_fixed_region(struct mem_region_root *r, vm_t start, size_t size, stat_t free_region(struct mem_region_root *r, vm_t start); stat_t free_known_region(struct mem_region_root *r, struct mem_region *m); +struct mem_region *find_first_region(struct mem_region_root *r); struct mem_region *find_used_region(struct mem_region_root *r, vm_t start); struct mem_region *find_closest_used_region(struct mem_region_root *r, vm_t start); diff --git a/include/apos/syscalls.h b/include/apos/syscalls.h index 9346da3..e7b1cd5 100644 --- a/include/apos/syscalls.h +++ b/include/apos/syscalls.h @@ -25,7 +25,8 @@ enum { * structure of the OS, but these following syscalls are probably * required */ SYS_IPC_SERVER, /* inform kernel that process should be treated as a server */ - SYS_IPC_REQ, /* IPC request to server */ + SYS_IPC_REQ_PROC, /* IPC request to server on behalf of process */ + SYS_IPC_REQ_THREAD, /* IPC request to server on behalf of thread */ SYS_IPC_RESP, /* IPC response from server */ /* process management */ diff --git a/include/apos/tcb.h b/include/apos/tcb.h index 11e1b5a..f31bf77 100644 --- a/include/apos/tcb.h +++ b/include/apos/tcb.h @@ -5,14 +5,24 @@ #include <apos/types.h> #include <tcb.h> /* arch-specific data */ +/* process(/main) threads don't have any previous threads */ +#define is_proc(t) (!t->prev) + struct tcb { struct arch_tcbd tcbd; /* mapping data * TODO: should mem_region_root be renamed mem_root or something? feels * kind of clunky */ - struct mem_region_root sp_r; + union { + /* if we're the main thread, we control the memory regions */ + struct mem_region_root sp_r; + /* if we're not the main thread, we have a pointer to the main + * thread */ + struct tcb *proc; + }; + id_t pid; id_t tid; vm_t callback; @@ -29,15 +39,18 @@ struct tcb { /* vm root branch */ struct vm_branch *b_r; - struct tcb *parent; + /* linked list of threads in this process */ struct tcb *next; + struct tcb *prev; }; void init_tcbs(); void destroy_tcbs(); -struct tcb *new_thread(); -void destroy_thread(struct tcb *); +struct tcb *create_thread(struct tcb *p); +struct tcb *create_proc(struct tcb *p); +stat_t destroy_thread(struct tcb *t); +stat_t destroy_proc(struct tcb *p); struct tcb *cur_tcb(); void use_tcb(struct tcb *); diff --git a/include/apos/uapi.h b/include/apos/uapi.h index a3b54d5..b3d345f 100644 --- a/include/apos/uapi.h +++ b/include/apos/uapi.h @@ -94,7 +94,8 @@ SYSCALL_DECLARE(free_timer); /* ipc */ SYSCALL_DECLARE(ipc_server); -SYSCALL_DECLARE(ipc_req); +SYSCALL_DECLARE(ipc_req_proc); +SYSCALL_DECLARE(ipc_req_thread); SYSCALL_DECLARE(ipc_resp); /* proc */ diff --git a/include/apos/vmem.h b/include/apos/vmem.h index f1b0d19..036780f 100644 --- a/include/apos/vmem.h +++ b/include/apos/vmem.h @@ -12,7 +12,9 @@ vm_t alloc_shared_uvmem(struct tcb *r, size_t size, vmflags_t flags); vm_t ref_shared_uvmem(struct tcb *r1, struct tcb *r2, vm_t va, vmflags_t flags); stat_t free_uvmem(struct tcb *r, vm_t a); + stat_t init_uvmem(struct tcb *r, vm_t base, vm_t top); +stat_t destroy_uvmem(struct tcb *r); stat_t alloc_uvmem_wrapper(struct vm_branch *b, pm_t *offset, vm_t vaddr, vmflags_t flags, enum mm_order order, void *data); diff --git a/include/arch/vmem.h b/include/arch/vmem.h index 74b0aa5..5197c67 100644 --- a/include/arch/vmem.h +++ b/include/arch/vmem.h @@ -16,13 +16,15 @@ stat_t stat_vpage(struct vm_branch *branch, vm_t vaddr, pm_t *paddr, void flush_tlb(); void flush_tlb_all(); -void populate_root_branch(struct vm_branch *b); +stat_t populate_kvmem(struct vm_branch *b); struct vm_branch *init_vmem(void *fdt); #if defined(DEBUG) vm_t setup_kernel_io(struct vm_branch *b, vm_t paddr); #endif -stat_t clone_vmbranch(struct vm_branch *, struct vm_branch *); +struct vm_branch *create_vmem(); +stat_t destroy_vmem(struct vm_branch *); +stat_t clone_uvmem(struct vm_branch *, struct vm_branch *); #endif /* APOS_ARCH_PAGES_H */ |
