diff options
| author | Kimplul <kimi.h.kuparinen@gmail.com> | 2022-01-07 17:33:55 +0200 |
|---|---|---|
| committer | Kimplul <kimi.h.kuparinen@gmail.com> | 2022-01-07 17:33:55 +0200 |
| commit | ebe6fe5d44d58fcb1b9d0ac52fa98a0a3ff309a7 (patch) | |
| tree | 1273c7815d6790e746f6e7ecfcd464e5cab39f2e /include/apos | |
| parent | be78fcb0acc665d4db8edb9cda53f6863d27dd85 (diff) | |
| download | kmi-ebe6fe5d44d58fcb1b9d0ac52fa98a0a3ff309a7.tar.gz kmi-ebe6fe5d44d58fcb1b9d0ac52fa98a0a3ff309a7.zip | |
Steps towards better status/debugging control
Diffstat (limited to 'include/apos')
| -rw-r--r-- | include/apos/dmem.h | 6 | ||||
| -rw-r--r-- | include/apos/mem.h | 1 | ||||
| -rw-r--r-- | include/apos/mem_regions.h | 9 | ||||
| -rw-r--r-- | include/apos/proc.h | 4 | ||||
| -rw-r--r-- | include/apos/tcb.h | 2 | ||||
| -rw-r--r-- | include/apos/types.h | 4 | ||||
| -rw-r--r-- | include/apos/vmem.h | 14 |
7 files changed, 23 insertions, 17 deletions
diff --git a/include/apos/dmem.h b/include/apos/dmem.h index 936a902..811f56d 100644 --- a/include/apos/dmem.h +++ b/include/apos/dmem.h @@ -10,10 +10,10 @@ extern pm_t __post_base; extern pm_t __post_top; stat_t init_devmem(pm_t ram_base, pm_t ram_top); -vm_t alloc_devmem(struct tcb *t, pm_t dev_start, size_t bytes, uint8_t flags); +vm_t alloc_devmem(struct tcb *t, pm_t dev_start, size_t bytes, vmflags_t flags); stat_t free_devmem(struct tcb *t, vm_t dev_start); -stat_t dev_free_wrapper(struct vm_branch *b, pm_t *offset, vm_t vaddr, uint8_t flags, enum mm_order t); -stat_t dev_alloc_wrapper(struct vm_branch *b, pm_t *offset, vm_t vaddr, uint8_t flags, enum mm_order t); +stat_t dev_free_wrapper(struct vm_branch *b, pm_t *offset, vm_t vaddr, vmflags_t flags, enum mm_order t); +stat_t dev_alloc_wrapper(struct vm_branch *b, pm_t *offset, vm_t vaddr, vmflags_t flags, enum mm_order t); #endif /* APOS_DEV_H */ diff --git a/include/apos/mem.h b/include/apos/mem.h index 01edcf6..61528df 100644 --- a/include/apos/mem.h +++ b/include/apos/mem.h @@ -3,7 +3,6 @@ #include <apos/utils.h> #include <apos/types.h> -#include <pages.h> #define MM_OINFO_WIDTH (sizeof(mm_info_t) * 8) diff --git a/include/apos/mem_regions.h b/include/apos/mem_regions.h index eb81e63..35428e1 100644 --- a/include/apos/mem_regions.h +++ b/include/apos/mem_regions.h @@ -1,8 +1,10 @@ #ifndef APOS_MEM_REGIONS_H #define APOS_MEM_REGIONS_H +#include <apos/mem.h> #include <apos/types.h> #include <apos/sp_tree.h> +#include <arch/vmem.h> #define mem_container(ptr)\ container_of(ptr, struct sp_mem, sp_n) @@ -33,4 +35,11 @@ struct sp_mem *sp_used_find(struct sp_reg_root *r, vm_t start); struct sp_mem *sp_find_used_closest(struct sp_reg_root *r, vm_t start); struct sp_mem *sp_find_free(struct sp_reg_root *r, size_t size, size_t *align); +#define MEM_REGION_TRY_AGAIN 1 +typedef stat_t mem_region_callback_t(struct vm_branch *b, + pm_t *offset, vm_t vaddr, vmflags_t flags, enum mm_order order); + +vm_t map_fill_region(struct vm_branch *b, mem_region_callback_t *mem_handler, + pm_t offset, vm_t start, size_t bytes, vmflags_t flags); + #endif /* APOS_MEM_REGIONS_H */ diff --git a/include/apos/proc.h b/include/apos/proc.h index f835394..e1ea7b6 100644 --- a/include/apos/proc.h +++ b/include/apos/proc.h @@ -4,7 +4,7 @@ #include <apos/tcb.h> #include <apos/vmem.h> -void jump_to_userspace(struct tcb *t, int argc, char **argv); -void init_proc(void *fdt, struct vm_branch *b); +stat_t jump_to_userspace(struct tcb *t, int argc, char **argv); +stat_t init_proc(void *fdt, struct vm_branch *b); #endif /* APOS_PROC_H */ diff --git a/include/apos/tcb.h b/include/apos/tcb.h index 4872bd0..bd66aff 100644 --- a/include/apos/tcb.h +++ b/include/apos/tcb.h @@ -22,7 +22,7 @@ struct tcb { struct vm_branch *b_r; }; -void threads_insert(struct tcb *t); +stat_t threads_insert(struct tcb *t); struct tcb *cur_tcb(); struct tcb *get_tcb(id_t tid); diff --git a/include/apos/types.h b/include/apos/types.h index 7d690de..2d9bef1 100644 --- a/include/apos/types.h +++ b/include/apos/types.h @@ -178,12 +178,14 @@ typedef intmax_t ssize_t; /* some common types used throughout the kernel */ typedef int_fast8_t stat_t; typedef uint_fast32_t id_t; -typedef uint_fast8_t mflags_t; +typedef uint_fast8_t vmflags_t; /* error types (should this go somewhere else? */ /* negative error codes are reserved for general usage, positive error codes are * allowed to be function-specific. */ enum { + ERR_EXT = -5, /* already exists */ + ERR_OOMEM = -4, /* out of memory */ ERR_ADDR = -3, /* illegal address */ ERR_ALIGN = -2, /* wrong alignment */ ERR_NF = -1, /* not found */ diff --git a/include/apos/vmem.h b/include/apos/vmem.h index bd6b89e..083df87 100644 --- a/include/apos/vmem.h +++ b/include/apos/vmem.h @@ -2,22 +2,18 @@ #define APOS_VMEM_H #include <apos/tcb.h> +#include <apos/mem.h> #include <apos/pmem.h> #include <apos/sp_tree.h> -#include <arch/vmem.h> -vm_t alloc_uvmem(struct tcb *r, size_t size, uint8_t flags); -vm_t alloc_fixed_uvmem(struct tcb *r, vm_t start, size_t size, uint8_t flags); +vm_t alloc_uvmem(struct tcb *r, size_t size, vmflags_t flags); +vm_t alloc_fixed_uvmem(struct tcb *r, vm_t start, size_t size, 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); -vm_t map_fill_region(struct vm_branch *b, - int (*vmem_handler)(struct vm_branch *, pm_t *, vm_t, uint8_t, enum mm_order), - pm_t offset, vm_t start, size_t bytes, uint8_t flags); - -stat_t alloc_uvmem_wrapper(struct vm_branch *b, pm_t *offset, vm_t vaddr, uint8_t flags, enum mm_order order); -stat_t free_uvmem_wrapper(struct vm_branch *b, pm_t *offset, vm_t vaddr, uint8_t flags, enum mm_order order); +stat_t alloc_uvmem_wrapper(struct vm_branch *b, pm_t *offset, vm_t vaddr, vmflags_t flags, enum mm_order order); +stat_t free_uvmem_wrapper(struct vm_branch *b, pm_t *offset, vm_t vaddr, vmflags_t flags, enum mm_order order); #define map_allocd_region(b, start, bytes, flags)\ map_fill_region(b, &alloc_uvmem_wrapper, 0, start, bytes, flags) |
