summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJonathan Neuschäfer <j.neuschaefer@gmx.net>2016-07-25 00:42:24 +0200
committerRonald G. Minnich <rminnich@gmail.com>2016-07-28 18:20:05 +0200
commit62bd9f93dd58e32baeddb4404fec6d04c9be3484 (patch)
tree984c664c8a082c459129e78eac2818c963dd0965 /src
parent0cc02efb23911bb77ce134224da15f82a26ca199 (diff)
downloadcoreboot-62bd9f93dd58e32baeddb4404fec6d04c9be3484.tar.xz
arch/riscv: Only initialize virtual memory if it's available
And do the detection just before the initialization. Change-Id: I9a52430262f799baa298dc4f4ea459880abe250e Signed-off-by: Jonathan Neuschäfer <j.neuschaefer@gmx.net> Reviewed-on: https://review.coreboot.org/15831 Tested-by: build bot (Jenkins) Reviewed-by: Ronald G. Minnich <rminnich@gmail.com>
Diffstat (limited to 'src')
-rw-r--r--src/arch/riscv/virtual_memory.c26
1 files changed, 16 insertions, 10 deletions
diff --git a/src/arch/riscv/virtual_memory.c b/src/arch/riscv/virtual_memory.c
index a7a81fbab5..cda9057939 100644
--- a/src/arch/riscv/virtual_memory.c
+++ b/src/arch/riscv/virtual_memory.c
@@ -95,6 +95,22 @@ void init_vm(uintptr_t virtMemStart, uintptr_t physMemStart, uintptr_t pageTable
}
void initVirtualMemory(void) {
+ uintptr_t ms;
+
+ ms = read_csr(mstatus);
+ ms = INSERT_FIELD(ms, MSTATUS_VM, VM_CHOICE);
+ write_csr(mstatus, ms);
+ ms = read_csr(mstatus);
+
+ if (EXTRACT_FIELD(ms, MSTATUS_VM) != VM_CHOICE) {
+ printk(BIOS_DEBUG, "We don't have virtual memory...\n");
+ return;
+ } else {
+ printk(BIOS_DEBUG, "-----------------------------\n");
+ printk(BIOS_DEBUG, "Virtual memory status enabled\n");
+ printk(BIOS_DEBUG, "-----------------------------\n");
+ }
+
printk(BIOS_DEBUG, "Initializing virtual memory...\n");
uintptr_t physicalStart = 0x1000000; // TODO: Figure out how to grab this from cbfs
uintptr_t virtualStart = 0xffffffff81000000;
@@ -114,19 +130,9 @@ void mstatus_init(void)
ms = INSERT_FIELD(ms, MSTATUS_PRV1, PRV_S);
ms = INSERT_FIELD(ms, MSTATUS_PRV2, PRV_U);
ms = INSERT_FIELD(ms, MSTATUS_IE2, 1);
- ms = INSERT_FIELD(ms, MSTATUS_VM, VM_CHOICE);
ms = INSERT_FIELD(ms, MSTATUS_FS, 3);
ms = INSERT_FIELD(ms, MSTATUS_XS, 3);
write_csr(mstatus, ms);
- ms = read_csr(mstatus);
-
- if (EXTRACT_FIELD(ms, MSTATUS_VM) != VM_CHOICE) {
- printk(BIOS_DEBUG, "we don't have virtual memory...\n");
- } else {
- printk(BIOS_DEBUG, "-----------------------------\n");
- printk(BIOS_DEBUG, "virtual memory status enabled\n");
- printk(BIOS_DEBUG, "-----------------------------\n");
- }
clear_csr(mip, MIP_MSIP);
set_csr(mie, MIP_MSIP);