diff options
| author | Kimplul <kimi.h.kuparinen@gmail.com> | 2021-12-19 17:10:36 +0200 |
|---|---|---|
| committer | Kimplul <kimi.h.kuparinen@gmail.com> | 2021-12-19 17:10:36 +0200 |
| commit | 9966b49db468de0168c7a455dfb5b4c66c413c4d (patch) | |
| tree | df31febe5e1ae52bae68ebe1df8b4469b97e0546 /include/apos | |
| parent | 8bb1e280280c2f30740defca68ea643c56a3d880 (diff) | |
| download | kmi-9966b49db468de0168c7a455dfb5b4c66c413c4d.tar.gz kmi-9966b49db468de0168c7a455dfb5b4c66c413c4d.zip | |
Massive changes to jump to userspace
Diffstat (limited to 'include/apos')
| -rw-r--r-- | include/apos/elf.h | 33 | ||||
| -rw-r--r-- | include/apos/init.h | 31 | ||||
| -rw-r--r-- | include/apos/initrd.h | 9 | ||||
| -rw-r--r-- | include/apos/pmem.h | 6 | ||||
| -rw-r--r-- | include/apos/proc.h | 7 | ||||
| -rw-r--r-- | include/apos/tcb.h | 34 | ||||
| -rw-r--r-- | include/apos/vmem.h | 18 |
7 files changed, 93 insertions, 45 deletions
diff --git a/include/apos/elf.h b/include/apos/elf.h new file mode 100644 index 0000000..492c414 --- /dev/null +++ b/include/apos/elf.h @@ -0,0 +1,33 @@ +#ifndef APOS_ELF_H +#define APOS_ELF_H + +#include <apos/attrs.h> +#include <apos/types.h> +#include <apos/vmem.h> + +__packed struct elf_header { + uint64_t ei_magic; + uint8_t ei_class; + uint8_t ei_data; + uint8_t ei_version; + uint8_t ei_osabi; + uint8_t ei_abiversion; + uint8_t e_pad; + uint16_t e_type; + uint16_t e_machine; + uint32_t e_version; + void *e_entry; + void *e_phoff; + void *e_shoff; + uint32_t e_flags; + uint16_t e_ehsize; + uint16_t e_phentsize; + uint16_t e_phnum; + uint16_t e_shentsize; + uint16_t e_shnum; + uint16_t e_shstrndx; +}; + +vm_t bin_entry(vm_t bin); + +#endif /* APOS_ELF_H */ diff --git a/include/apos/init.h b/include/apos/init.h deleted file mode 100644 index 2dd8a27..0000000 --- a/include/apos/init.h +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef APOS_INIT_H -#define APOS_INIT_H - -#include <apos/pmem.h> -#include <apos/vmem.h> - -struct init_data_t { - pm_t init_base; - pm_t init_top; - - pm_t initrd_base; - pm_t initrd_top; - - pm_t pmap_base; - pm_t pmap_top; - - pm_t fdt_base; - pm_t fdt_top; - - pm_t stack_base; - pm_t stack_top; - - struct vm_branch_t *kernel_vm_base; - vm_t tmp_pte; - - size_t max_order; - size_t bits[10]; - size_t page_shift; -}; - -#endif /* APOS_INIT_H */ diff --git a/include/apos/initrd.h b/include/apos/initrd.h new file mode 100644 index 0000000..942875f --- /dev/null +++ b/include/apos/initrd.h @@ -0,0 +1,9 @@ +#ifndef APOS_INITRD_H +#define APOS_INITRD_H + +#include <apos/types.h> + +size_t get_init_size(void *fdt); +void move_init(void *fdt, void *target, size_t sz); + +#endif /* APOS_INITRD_H */ diff --git a/include/apos/pmem.h b/include/apos/pmem.h index 38dd670..01d89ce 100644 --- a/include/apos/pmem.h +++ b/include/apos/pmem.h @@ -25,13 +25,7 @@ void free_page(enum mm_order_t order, pm_t paddr); void mark_used(enum mm_order_t order, pm_t paddr); pm_t alloc_page(enum mm_order_t order, pm_t offset); -#if defined(INIT) pm_t populate_pmap(pm_t ram_base, size_t ram_size, pm_t cont); pm_t probe_pmap(pm_t ram_base, size_t ram_size); -#endif - -#if defined(KERNEL) -void init_pmap(void *p); -#endif #endif /* APOS_PMEM_H */ diff --git a/include/apos/proc.h b/include/apos/proc.h new file mode 100644 index 0000000..7506b10 --- /dev/null +++ b/include/apos/proc.h @@ -0,0 +1,7 @@ +#ifndef APOS_PROC_H +#define APOS_PROC_H + +#include <apos/tcb.h> +void jump_to_userspace(struct tcb *t, char **argv, int argc); + +#endif /* APOS_PROC_H */ diff --git a/include/apos/tcb.h b/include/apos/tcb.h new file mode 100644 index 0000000..9cef386 --- /dev/null +++ b/include/apos/tcb.h @@ -0,0 +1,34 @@ +#ifndef APOS_TCB_H +#define APOS_TCB_H + +struct tcb; +struct sp_reg_root; + +#include <vmem.h> +#include <apos/vmem.h> +#include <apos/types.h> +#include <apos/sp_tree.h> + +typedef size_t id_t; + +struct sp_reg_root { + struct sp_root free_regions; + struct sp_root used_regions; +}; + +struct tcb { + struct sp_node sp_n; + + id_t pid; + id_t tid; + + vm_t stack; + vm_t bin; + + struct vm_branch_t *b_r; + struct sp_reg_root sp_r; +}; + +void threads_insert(struct tcb *t); + +#endif /* APOS_TCB_H */ diff --git a/include/apos/vmem.h b/include/apos/vmem.h index eb7ad17..fe2a76f 100644 --- a/include/apos/vmem.h +++ b/include/apos/vmem.h @@ -1,11 +1,14 @@ #ifndef APOS_VMEM_H #define APOS_VMEM_H +struct sp_mem; + /* arch-specific data */ #include <vmem.h> /* common */ #include <apos/pmem.h> +#include <apos/tcb.h> #include <apos/sp_tree.h> struct sp_mem { @@ -24,6 +27,7 @@ struct sp_mem { container_of(ptr, struct sp_mem, sp_n) + /* general overview of the different functions: * (un)map_vmem: map one known page of physical memory to one known page of * virtual memory @@ -35,16 +39,14 @@ struct sp_mem { */ /* defined by arch */ -void map_vmem(struct vm_branch_t *branch, - pm_t paddr, vm_t vaddr, - uint8_t flags, enum mm_order_t order); +int sp_mem_init(struct sp_reg_root *r, size_t nums); -void unmap_vmem(struct vm_branch_t *branch, vm_t vaddr, enum mm_order_t order); +vm_t alloc_uvmem(struct tcb *r, size_t s, uint8_t flags); +void free_uvmem(struct tcb *r, vm_t a); +vm_t map_fill_region(struct vm_branch_t *b, vm_t start, size_t bytes, uint8_t flags); -vm_t map_vregion(struct vm_branch_t *branch, pm_t base, vm_t start, size_t size, - uint8_t flags); -void unmap_vregion(struct vm_branch_t *branch, vm_t start); +size_t uvmem_size(); +void set_uvmem_size(size_t s); -void init_vmem(struct vm_branch_t *branch, vm_t tmp_pte); #endif /* APOS_VMEM_H */ |
