diff options
| author | Kimplul <kimi.h.kuparinen@gmail.com> | 2021-09-12 21:51:10 +0300 |
|---|---|---|
| committer | Kimplul <kimi.h.kuparinen@gmail.com> | 2021-09-12 21:51:10 +0300 |
| commit | d95c714c8cfdc5818b0e0f0c99cf2e5be66de202 (patch) | |
| tree | 3b7b7a4fda733f284a4f77a9e67cc509201cfeca /arch | |
| parent | 1ab464d959b9ee3d3bb6758ac0d9d33fc6c77e46 (diff) | |
| download | kmi-d95c714c8cfdc5818b0e0f0c99cf2e5be66de202.tar.gz kmi-d95c714c8cfdc5818b0e0f0c99cf2e5be66de202.zip | |
Initial physical page manager
+ Will probably still need a fair bit of tweakind and documentation
improvements, but seems to work outside of the kernel. Also no valgrind
errors, which is quite promising I guess.
Diffstat (limited to 'arch')
| -rw-r--r-- | arch/riscv/config.h | 7 | ||||
| -rw-r--r-- | arch/riscv/init/init.c | 15 | ||||
| -rw-r--r-- | arch/riscv/kernel/main.c (renamed from arch/riscv/main.c) | 0 | ||||
| -rw-r--r-- | arch/riscv/source.mk | 2 |
4 files changed, 20 insertions, 4 deletions
diff --git a/arch/riscv/config.h b/arch/riscv/config.h index 1818316..3eedb39 100644 --- a/arch/riscv/config.h +++ b/arch/riscv/config.h @@ -1,3 +1,10 @@ #include <apos/sizes.h> #define PM_KERN 0x83800000 #define VM_KERN ((-1) - SZ_1G) + +#define MAX_ORDER 3 +#define PAGE_SHIFT 12 +#define O0_WIDTH 9 +#define O1_WIDTH 9 +#define O2_WIDTH 9 +#define O3_WIDTH 0 diff --git a/arch/riscv/init/init.c b/arch/riscv/init/init.c index 6bb6bc3..e12c351 100644 --- a/arch/riscv/init/init.c +++ b/arch/riscv/init/init.c @@ -3,6 +3,7 @@ #include <apos/types.h> #include <apos/string.h> #include <apos/debug.h> +#include <apos/pmem.h> #include <libfdt.h> #include <pages.h> #include <csr.h> @@ -118,11 +119,19 @@ void init_debug(void *fdt) #endif -void init(void *fdt) +void __noreturn init(void *fdt) { init_debug(fdt); - dbg("hello\n"); + /* basic memory layout info */ struct mem_layout pmem = get_memlayout(fdt); - /* struct mm_ptinfo ptbl = create_pagetable(pmem); */ + + /* TODO: find first contiguous region */ + + /* generate pagetable at contiguous region */ + populate_pmap(pmem.base, pmem.top - pmem.base, 0/* something */); + + /* TODO: mark all used pages */ + update_pmap(0/* TODO: figure out where in virtual memory the page map should be mapped */); + /* TODO: jump to kernel */ } diff --git a/arch/riscv/main.c b/arch/riscv/kernel/main.c index 9334fb3..9334fb3 100644 --- a/arch/riscv/main.c +++ b/arch/riscv/kernel/main.c diff --git a/arch/riscv/source.mk b/arch/riscv/source.mk index 50e0f5f..2d79625 100644 --- a/arch/riscv/source.mk +++ b/arch/riscv/source.mk @@ -1,4 +1,4 @@ -KERNEL_LOCAL != echo arch/riscv/*.[cS] +KERNEL_LOCAL != echo arch/riscv/kernel/*.[cS] KERNEL_SOURCES += $(KERNEL_LOCAL) INIT_LOCAL != echo arch/riscv/init/*.[cS] |
