diff options
| author | Kimplul <kimi.h.kuparinen@gmail.com> | 2022-09-11 01:07:52 +0300 |
|---|---|---|
| committer | Kimplul <kimi.h.kuparinen@gmail.com> | 2022-09-11 01:09:02 +0300 |
| commit | 7101970b3cdb2a0190e69a98352275907ab935a4 (patch) | |
| tree | 3081ce0e6fb986b340db7e1a18f0e6074cdd746e /arch | |
| parent | d9b427cab53849c503306af1ebebed30c35fb81f (diff) | |
| download | kmi-7101970b3cdb2a0190e69a98352275907ab935a4.tar.gz kmi-7101970b3cdb2a0190e69a98352275907ab935a4.zip | |
allow building with riscv64-linux-gnu
+ May warn about PHDR not being in LOAD, there is a flag to silence it
(--no-warn-rwx-segment) but it doesn't seem to exist in
riscv64-unknown-elf for some reason.
Diffstat (limited to 'arch')
| -rw-r--r-- | arch/riscv64/conf/init-link.S | 5 | ||||
| -rw-r--r-- | arch/riscv64/conf/kernel-link.S | 5 | ||||
| -rw-r--r-- | arch/riscv64/config.h | 4 | ||||
| -rw-r--r-- | arch/riscv64/init/init.c | 15 |
4 files changed, 25 insertions, 4 deletions
diff --git a/arch/riscv64/conf/init-link.S b/arch/riscv64/conf/init-link.S index ac7f858..f827245 100644 --- a/arch/riscv64/conf/init-link.S +++ b/arch/riscv64/conf/init-link.S @@ -31,4 +31,9 @@ SECTIONS { __init_end = . ; __kernel_size = <KERNEL_SIZE>; + + .garbage : { + *(.note*) + *(.riscv.attributes) + } } diff --git a/arch/riscv64/conf/kernel-link.S b/arch/riscv64/conf/kernel-link.S index 5673a64..2f000c9 100644 --- a/arch/riscv64/conf/kernel-link.S +++ b/arch/riscv64/conf/kernel-link.S @@ -26,4 +26,9 @@ SECTIONS { } __kernel_end = .; + + .garbage : { + *(.note*) + *(.riscv.attributes) + } } diff --git a/arch/riscv64/config.h b/arch/riscv64/config.h index 5ea5482..7606e38 100644 --- a/arch/riscv64/config.h +++ b/arch/riscv64/config.h @@ -98,7 +98,7 @@ #define UVMEM_START (SZ_4K) #define UVMEM_END (SZ_4G - SZ_8M) -#define PROC_STACK_TOP (SZ_4G) -#define PROC_STACK_BASE (SZ_4G - SZ_8M) +#define RPC_STACK_TOP (SZ_4G) +#define RPC_STACK_BASE (SZ_4G - SZ_8M) #endif #endif /* APOS_RISCV_CONFIG_H */ diff --git a/arch/riscv64/init/init.c b/arch/riscv64/init/init.c index c91d192..0ea1f37 100644 --- a/arch/riscv64/init/init.c +++ b/arch/riscv64/init/init.c @@ -42,19 +42,30 @@ static void init_bootmem() * @todo Allocate root_branch statically? */ root_branch = (struct vmem *)align_up(top, SZ_4K); +#if defined(riscv64) + const size_t top_size = SZ_1G; +#else + const size_t top_size = SZ_4M; +#endif + /* direct mapping (temp) */ for (size_t i = 0; i < CSTACK_PAGE; ++i) - root_branch->leaf[i] = (struct vmem *)to_pte(SZ_1G * i, flags); + root_branch->leaf[i] = (struct vmem *)to_pte(top_size * i, flags); /* kernel (also sort of direct mapping) */ flags |= VM_G; for (size_t i = KSTART_PAGE; i < IO_PAGE; ++i) root_branch->leaf[i] = (struct vmem *)to_pte( - RAM_BASE + SZ_1G * (i - 256), flags); + RAM_BASE + top_size * (i - KSTART_PAGE), flags); /* kernel IO, map to 0 for now, will be updated in the future */ root_branch->leaf[IO_PAGE] = (struct vmem *)to_pte(0, flags); +#if defined(riscv64) + const uintmax_t mode = SATP_MODE_Sv39; +#else + const uintmax_t mode = SATP_MODE_Sv32; +#endif csr_write(CSR_SATP, SATP_MODE_Sv39 | ((uintptr_t)root_branch >> 12)); } |
