diff options
| author | Kimplul <kimi.h.kuparinen@gmail.com> | 2021-12-20 21:03:37 +0200 |
|---|---|---|
| committer | Kimplul <kimi.h.kuparinen@gmail.com> | 2021-12-20 21:03:37 +0200 |
| commit | 61291639524e4aebf93a3315661e7180ac1b9c1e (patch) | |
| tree | b524cd94fe1c59c9733e913f1de1e1c68b313bda /arch/riscv/init/init.c | |
| parent | 6f8e5772d17d277842be3f6162ddd665a17e5be9 (diff) | |
| download | kmi-61291639524e4aebf93a3315661e7180ac1b9c1e.tar.gz kmi-61291639524e4aebf93a3315661e7180ac1b9c1e.zip | |
Right up to init_proc, FUCK YEAH
+ Lots to do still, should keep a more detailed TODO.txt, among other
things implement Sv48 support, make more things single truths etc.
Diffstat (limited to 'arch/riscv/init/init.c')
| -rw-r--r-- | arch/riscv/init/init.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/arch/riscv/init/init.c b/arch/riscv/init/init.c index 728f8dd..029c855 100644 --- a/arch/riscv/init/init.c +++ b/arch/riscv/init/init.c @@ -11,6 +11,8 @@ struct __packed init_vmem { struct init_vmem *root_branch; +#define to_pte(a, f) (((a) >> 12) << 10 | (f)) + /* assume Sv39 for now */ void init_vmem() { @@ -23,12 +25,13 @@ void init_vmem() /* direct mapping (temp) */ for(size_t i = 0; i < 256; ++i) - root_branch->leaf[i] = (int *)((1UL << 28) * i | flags); + root_branch->leaf[i] = (int*)to_pte(SZ_1G * i, flags); /* kernel (also sort of direct mapping) */ /* FIXME set up actually correct addressing retard */ + flags |= VM_G; for(size_t i = 256; i < 512; ++i) - root_branch->leaf[256] = (int *)(((RAM_BASE >> 12) << 10) | flags); + root_branch->leaf[i] = (int *)to_pte(RAM_BASE + SZ_1G * (i - 256), flags); csr_write(CSR_SATP, SATP_MODE_Sv39 | ((size_t)root_branch >> 12)); } |
