aboutsummaryrefslogtreecommitdiff
path: root/arch/riscv64/init/init.c
diff options
context:
space:
mode:
authorKimplul <kimi.h.kuparinen@gmail.com>2022-04-21 23:25:57 +0300
committerKimplul <kimi.h.kuparinen@gmail.com>2022-04-21 23:25:57 +0300
commit42451ed4718af3f93770feb201bd023625d69b3a (patch)
tree7f69bc86e0fc0591f176ca086db377e1cb99a718 /arch/riscv64/init/init.c
parent1a5248bb177242a34fd51efadb4af941853d5e35 (diff)
downloadkmi-42451ed4718af3f93770feb201bd023625d69b3a.tar.gz
kmi-42451ed4718af3f93770feb201bd023625d69b3a.zip
fix warnings on 32bit riscv
+ Will most probably not work on 32bit, but nice to make 'portable' code.
Diffstat (limited to 'arch/riscv64/init/init.c')
-rw-r--r--arch/riscv64/init/init.c20
1 files changed, 8 insertions, 12 deletions
diff --git a/arch/riscv64/init/init.c b/arch/riscv64/init/init.c
index f844dbb..b28c581 100644
--- a/arch/riscv64/init/init.c
+++ b/arch/riscv64/init/init.c
@@ -6,11 +6,7 @@
#include <csr.h>
/* assume 64 bit for now */
-struct __packed init_vmem {
- int *leaf[512];
-};
-
-struct init_vmem *root_branch;
+struct vm_branch *root_branch;
#define to_pte(a, f) (((a) >> 12) << 10 | (f))
@@ -20,23 +16,23 @@ void init_bootmem()
size_t flags = VM_V | VM_X | VM_R | VM_W;
extern char *__init_start;
- root_branch = (struct init_vmem *)align_down(
- (size_t)&__init_start - SZ_4K, SZ_4K);
+ root_branch = (struct vm_branch *)align_down(
+ (uintptr_t)&__init_start - SZ_4K, SZ_4K);
/* direct mapping (temp) */
for (size_t i = 0; i < CSTACK_PAGE; ++i)
- root_branch->leaf[i] = (int *)to_pte(SZ_1G * i, flags);
+ root_branch->leaf[i] = (struct vm_branch *)to_pte(SZ_1G * 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] =
- (int *)to_pte(RAM_BASE + SZ_1G * (i - 256), flags);
+ (struct vm_branch *)to_pte(RAM_BASE + SZ_1G * (i - 256), flags);
/* kernel IO, map to 0 for now, will be updated in the future */
- root_branch->leaf[IO_PAGE] = (int *)to_pte(0, flags);
+ root_branch->leaf[IO_PAGE] = (struct vm_branch *)to_pte(0, flags);
- csr_write(CSR_SATP, SATP_MODE_Sv39 | ((size_t)root_branch >> 12));
+ csr_write(CSR_SATP, SATP_MODE_Sv39 | ((uintptr_t)root_branch >> 12));
}
void move_kernel()
@@ -44,7 +40,7 @@ void move_kernel()
extern char *__init_end;
extern char *__kernel_size;
- size_t sz = (size_t)&__kernel_size;
+ unsigned long sz = (unsigned long)&__kernel_size;
char *src = (char *)&__init_end;
char *dst = (char *)VM_KERN;
for (size_t i = 0; i < sz; ++i)