[coreboot-gerrit] New patch to review for coreboot: [WIP] arch/riscv: Implement the SBI again
Jonathan Neuschäfer (j.neuschaefer@gmx.net)
gerrit at coreboot.org
Tue Aug 9 03:06:44 CEST 2016
Jonathan Neuschäfer (j.neuschaefer at gmx.net) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/16119
-gerrit
commit b5c9f6a7e1d0909c32ffb9c0ef961b76868b228b
Author: Jonathan Neuschäfer <j.neuschaefer at gmx.net>
Date: Tue Aug 9 02:07:12 2016 +0200
[WIP] arch/riscv: Implement the SBI again
This is just a draft, so far. I didn't implement everything that Linux
needs, and the SBI is still in flux:
https://groups.google.com/a/groups.riscv.org/forum/#!topic/sw-dev/6oNhlW0OFKM
Change-Id: I80e4fe508336d6428ca7136bc388fbc3cda4f1e4
Signed-off-by: Jonathan Neuschäfer <j.neuschaefer at gmx.net>
---
src/arch/riscv/Makefile.inc | 1 +
src/arch/riscv/include/vm.h | 3 ++
src/arch/riscv/sbi.S | 103 ++++++++++++++++++++++++++++++++++++++++
src/arch/riscv/virtual_memory.c | 2 +-
4 files changed, 108 insertions(+), 1 deletion(-)
diff --git a/src/arch/riscv/Makefile.inc b/src/arch/riscv/Makefile.inc
index 718aad9..4bab459 100644
--- a/src/arch/riscv/Makefile.inc
+++ b/src/arch/riscv/Makefile.inc
@@ -95,6 +95,7 @@ ramstage-y += stages.c
ramstage-y += misc.c
ramstage-y += boot.c
ramstage-y += tables.c
+ramstage-y += sbi.S
ramstage-y += \
$(top)/src/lib/memchr.c \
$(top)/src/lib/memcmp.c \
diff --git a/src/arch/riscv/include/vm.h b/src/arch/riscv/include/vm.h
index cd82b0a..985deec 100644
--- a/src/arch/riscv/include/vm.h
+++ b/src/arch/riscv/include/vm.h
@@ -70,4 +70,7 @@ void mstatus_init(void); // need to setup mstatus so we know we have virtual mem
void flush_tlb(void);
+struct opaque;
+extern struct opaque sbi_page;
+
#endif
diff --git a/src/arch/riscv/sbi.S b/src/arch/riscv/sbi.S
new file mode 100644
index 0000000..e4da3f3
--- /dev/null
+++ b/src/arch/riscv/sbi.S
@@ -0,0 +1,103 @@
+/*
+ * RISC-V supervisor binary interface (SBI) trampoline page
+ *
+ * Copyright 2016 Jonathan Neuschäfer <j.neuschaefer at gmx.net>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; version 2 of
+ * the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
+ * GNU General Public License for more details.
+ */
+
+#include <arch/encoding.h>
+
+.section ".text.sbi", "ax", %progbits
+
+/* align to a page boundary */
+.align RISCV_PGSHIFT
+
+.globl sbi_page
+sbi_page:
+
+ /*
+ * None of the SBI entry points is located in the first half of the
+ * page
+ */
+ .skip 0x800
+
+ /* -2048: size_t sbi_hart_id(void); */
+ li a0, 0
+ jr ra
+ .align 4
+
+ /* -2032: size_t sbi_num_harts(viod); */
+ li a0, 1
+ jr ra
+ .align 4
+
+ /* -2016: sbi_query_memory (DEPRECATED!) */
+ ebreak
+ .align 4
+
+ /* -2000: int sbi_console_putchar(uint8_t ch); */
+ ebreak
+ .align 4
+
+ /* -1984: int sbi_console_putchar(uint8_t ch); */
+ li a0, -1 /* failure */
+ jr ra
+ .align 4
+
+ /* -1968: Not allocated */
+ ebreak
+ .align 4
+
+ /* -1952: int sbi_send_ipi(size_t hart_id); */
+ ebreak
+ .align 4
+
+ /* -1936: int bool sbi_clear_ipi(void); */
+ ebreak
+ .align 4
+
+ /* -1920: sbi_timebase (DEPRECATED!) */
+ ebreak
+ .align 4
+
+ /* -1904: void sbi_shutdown(void); */
+ ebreak
+ .align 4
+
+ /* -1888: sbi_set_timer (DEPRECATED!) */
+ ebreak
+ .align 4
+
+ /* -1872: int sbi_mask_interrupt(int which); */
+ ebreak
+ .align 4
+
+ /* -1856: int sbi_unmask_interrupt(int which); */
+ ebreak
+ .align 4
+
+ /* -1840: void sbi_remote_sfence_vm(const uintptr_t* harts,
+ size_t asid); */
+ ebreak
+ .align 4
+
+ /* -1824: void sbi_remote_sfence_vm_range(const uintptr_t* harts,
+ size_t asid, uintptr_t start, uintptr_t size); */
+ ebreak
+ .align 4
+
+ /* -1808: void sbi_remote_fence_i(const uintptr_t* harts); */
+ ebreak
+ .align 4
+
+/* Fill the remainder of the page */
+.align RISCV_PGSHIFT
diff --git a/src/arch/riscv/virtual_memory.c b/src/arch/riscv/virtual_memory.c
index 8370415..71dc48d 100644
--- a/src/arch/riscv/virtual_memory.c
+++ b/src/arch/riscv/virtual_memory.c
@@ -137,7 +137,7 @@ void init_vm(uintptr_t virtMemStart, uintptr_t physMemStart, uintptr_t pageTable
// map SBI at top of vaddr space
uintptr_t num_sbi_pages = 1; // only need to map a single page for sbi interface
- uintptr_t sbiStartAddress = 0x2000; // the start of the sbi mapping
+ uintptr_t sbiStartAddress = (uintptr_t) &sbi_page;
uintptr_t sbiAddr = sbiStartAddress;
for (uintptr_t i = 0; i < num_sbi_pages; i++) {
uintptr_t idx = (1 << RISCV_PGLEVEL_BITS) - num_sbi_pages + i;
More information about the coreboot-gerrit
mailing list