diff options
| author | Kimplul <kimi.h.kuparinen@gmail.com> | 2021-10-01 20:36:15 +0300 |
|---|---|---|
| committer | Kimplul <kimi.h.kuparinen@gmail.com> | 2021-10-01 20:36:15 +0300 |
| commit | b30ee14270a44e48167934b9b3923b4280bdc855 (patch) | |
| tree | fe900fd442e834f857927e9094ce7cbdda59b9fd /arch/riscv/include/csr.h | |
| parent | 2d173beb3392aff35c8a33f4ac001bf63bb9adc6 (diff) | |
| download | kmi-b30ee14270a44e48167934b9b3923b4280bdc855.tar.gz kmi-b30ee14270a44e48167934b9b3923b4280bdc855.zip | |
First jump to virtual memory!
+ Lots of bughunting to do, probably lots of off-by-one and so on
errors, and I make a lot of naive and possibly dangerous assumptions.
But cool start nonetheless. Should also come up with some method of
exchanging data between the init and actual kernel, probably some struct
of some sort. TODO
Diffstat (limited to 'arch/riscv/include/csr.h')
| -rw-r--r-- | arch/riscv/include/csr.h | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/arch/riscv/include/csr.h b/arch/riscv/include/csr.h index 694000b..5da0882 100644 --- a/arch/riscv/include/csr.h +++ b/arch/riscv/include/csr.h @@ -1,8 +1,22 @@ #ifndef APOS_CSR_H #define APOS_CSR_H -#define csr_write(csr, val) - #define SATP_MODE_39 0x8000000000000000 +#define SATP_MODE_48 0x9000000000000000 + +#define CSR_SATP 0x180 + +/* directly lifted from Linux:/arch/riscv/include/asm/asm.h:9-13 */ +#ifdef __ASSEMBLY__ +#define __ASM_STR(x) x +#else +#define __ASM_STR(x) #x +#endif + +#define csr_read(csr, res)\ + __asm__ ("csrr %0, " __ASM_STR(csr) : "=r" (res) : : "memory") + +#define csr_write(csr, val)\ + __asm__ ("csrw " __ASM_STR(csr) ", %0" : : "rK" (val) : "memory") #endif /* APOS_CSR_H */ |
