diff options
| author | Kimplul <kimi.h.kuparinen@gmail.com> | 2024-07-05 19:38:11 +0300 |
|---|---|---|
| committer | Kimplul <kimi.h.kuparinen@gmail.com> | 2024-07-05 19:38:11 +0300 |
| commit | e09edb5d54e39bd9509a1dc450df5ab320759f97 (patch) | |
| tree | 78e050b0db87df3a3ddfbb6570d44513ac34e02a /include | |
| parent | 98f21e694a6b0964d6d08196cb6bfbc1c2ae2ff4 (diff) | |
| download | kmi-e09edb5d54e39bd9509a1dc450df5ab320759f97.tar.gz kmi-e09edb5d54e39bd9509a1dc450df5ab320759f97.zip | |
allow booting with Qemu's -kernel flag directly
+ Took some fairly significant changes, for one the kernel is no longer
relocated at the start of a boot, instead it sits wherever the user
decides the kernel should sit. Similarly, the initial kernel stack and
page table are stored within the binary, slightly bloating the size
but making it much safer to boot since there's really no chance of us
overwriting the fdt or initrd in memory.
Diffstat (limited to 'include')
| -rw-r--r-- | include/arch/proc.h | 2 | ||||
| -rw-r--r-- | include/arch/vmem.h | 5 | ||||
| -rw-r--r-- | include/kmi/initrd.h | 2 | ||||
| -rw-r--r-- | include/kmi/mem.h | 6 | ||||
| -rw-r--r-- | include/kmi/pmem.h | 2 | ||||
| -rw-r--r-- | include/kmi/proc.h | 2 | ||||
| -rw-r--r-- | include/kmi/tcb.h | 3 | ||||
| -rw-r--r-- | include/kmi/vmem.h | 2 |
8 files changed, 19 insertions, 5 deletions
diff --git a/include/arch/proc.h b/include/arch/proc.h index 345f812..429f688 100644 --- a/include/arch/proc.h +++ b/include/arch/proc.h @@ -114,7 +114,7 @@ void adjust_syscall(struct tcb *t); * @param fdt Pointer to FDT that is passed to \c init. * @param initrd Pointer to initrd that is passed to \c init. */ -__noreturn void run_init(struct tcb *t, void *fdt, void *initrd); +__noreturn void run_init(struct tcb *t, vm_t fdt, vm_t initrd); /** * Return to userspace fast. diff --git a/include/arch/vmem.h b/include/arch/vmem.h index 118e6ff..238b12a 100644 --- a/include/arch/vmem.h +++ b/include/arch/vmem.h @@ -140,6 +140,8 @@ struct vmem *init_vmem(void *fdt); vm_t setup_kernel_io(struct vmem *b, vm_t paddr); #endif +struct vmem *direct_mapping(); + /** * Create new virtual memory space. * @@ -171,4 +173,7 @@ stat_t destroy_vmem(struct vmem *b); */ void clone_uvmem(struct vmem * restrict r, struct vmem * restrict b); +__noreturn void to_kernelspace(void *fdt, uintptr_t load_addr, + struct vmem *direct_mapping, pm_t ram_base, + pm_t dmap); #endif /* KMI_ARCH_PAGES_H */ diff --git a/include/kmi/initrd.h b/include/kmi/initrd.h index 06bbaac..58fafd5 100644 --- a/include/kmi/initrd.h +++ b/include/kmi/initrd.h @@ -45,6 +45,8 @@ pm_t get_initrdtop(const void *fdt); */ pm_t get_initrdbase(const void *fdt); +size_t get_initrdsize(const void *fdt); + /** * Move \c init program to some other region in memory. * diff --git a/include/kmi/mem.h b/include/kmi/mem.h index f43ee08..ec8d2ea 100644 --- a/include/kmi/mem.h +++ b/include/kmi/mem.h @@ -211,7 +211,7 @@ enum mm_order nearest_order(size_t size); * @param page_shift Width in bits of base page size. * \todo Should likely also be stat_t? */ -void init_mem(size_t max_order, size_t shifts[10], size_t page_shift); +void init_mem(void *mem); /** * Set RAM base address for global access. @@ -221,6 +221,8 @@ void init_mem(size_t max_order, size_t shifts[10], size_t page_shift); */ void set_ram_base(pm_t base); +void set_ram_size(size_t size); + /** * Get RAM base address. * Very much assumes set_ram_base() has been called beforehand. @@ -229,6 +231,8 @@ void set_ram_base(pm_t base); */ pm_t get_ram_base(); +size_t get_ram_size(); + /** Base page size. */ #define BASE_PAGE_SIZE (order_size(BASE_PAGE)) diff --git a/include/kmi/pmem.h b/include/kmi/pmem.h index 1917174..96a4447 100644 --- a/include/kmi/pmem.h +++ b/include/kmi/pmem.h @@ -68,6 +68,6 @@ size_t probe_pmap(pm_t ram_base, size_t ram_size, pm_t cont); * * @param fdt Global FDT pointer. */ -void init_pmem(void *fdt); +void init_pmem(void *fdt, uintptr_t load_addr); #endif /* KMI_PMEM_H */ diff --git a/include/kmi/proc.h b/include/kmi/proc.h index c49be78..4b8807f 100644 --- a/include/kmi/proc.h +++ b/include/kmi/proc.h @@ -32,6 +32,6 @@ stat_t prepare_proc(struct tcb *t, vm_t bin, vm_t interp); * @return \ref ERR_OOMEM when out of memory, \ref ERR_INVAL if loading \c init * failed, \ref OK otherwise. */ -stat_t init_proc(void *fdt); +stat_t init_proc(void *fdt, vm_t *proc_fdt, vm_t *proc_initrd); #endif /* KMI_PROC_H */ diff --git a/include/kmi/tcb.h b/include/kmi/tcb.h index df161b3..54f6e82 100644 --- a/include/kmi/tcb.h +++ b/include/kmi/tcb.h @@ -13,6 +13,7 @@ struct tcb; #include <kmi/mem_regions.h> +#include <kmi/orphanage.h> #include <kmi/syscalls.h> #include <kmi/atomic.h> #include <kmi/queue.h> @@ -26,7 +27,7 @@ struct tcb; * @param t Thread to check. * @return \c true if thread is process thread, \c false otherwise. */ -#define is_proc(t) (t->rid == t->tid) +#define is_proc(t) ((t->rid == t->tid) && !orphan(t)) /** * Check if thread is in RPC. diff --git a/include/kmi/vmem.h b/include/kmi/vmem.h index 63b931b..3205e00 100644 --- a/include/kmi/vmem.h +++ b/include/kmi/vmem.h @@ -131,6 +131,8 @@ stat_t init_uvmem(struct tcb *r, vm_t base, vm_t top); */ stat_t destroy_uvmem(struct tcb *r); +vm_t map_fixed_mem(struct tcb *r, pm_t base, size_t size, vmflags_t flags); + /** * Clone process memory. * |
