[coreboot-gerrit] Patch set updated for coreboot: riscv: Move mcall numbers to mcall.h, adjust their names

Jonathan Neuschäfer (j.neuschaefer@gmx.net) gerrit at coreboot.org
Mon Jan 16 00:35:12 CET 2017


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/18146

-gerrit

commit b1b0941bc4ef4e382e552f078e5274090e84f8ec
Author: Jonathan Neuschäfer <j.neuschaefer at gmx.net>
Date:   Mon Jan 16 00:31:34 2017 +0100

    riscv: Move mcall numbers to mcall.h, adjust their names
    
    The new name and location make more sense:
    
     - The instruction used to call into machine mode isn't called "ecall"
       anymore; it's mcall now.
     - Having SBI_ in the name is slightly wrong, too: these numbers are not
       part of the Supervisor Binary Interface, they are just used to
       forward SBI calls (they could be renumbered arbitrarily without
       breaking an OS that's run under coreboot).
    
    Also remove mcall_dev_{req,resp} and the corresponding mcall numbers,
    which are no longer used.
    
    Change-Id: I76a8cb04e4ace51964b1cb4f67d49cfee9850da7
    Signed-off-by: Jonathan Neuschäfer <j.neuschaefer at gmx.net>
---
 src/arch/riscv/include/arch/sbi.h | 11 -----------
 src/arch/riscv/include/mcall.h    | 14 ++++++++++++++
 src/arch/riscv/mcall.c            | 12 ------------
 src/arch/riscv/sbi.S              | 14 +++++++-------
 src/arch/riscv/trap_handler.c     | 24 ++++++++----------------
 5 files changed, 29 insertions(+), 46 deletions(-)

diff --git a/src/arch/riscv/include/arch/sbi.h b/src/arch/riscv/include/arch/sbi.h
index df7f6cc..4f05521 100644
--- a/src/arch/riscv/include/arch/sbi.h
+++ b/src/arch/riscv/include/arch/sbi.h
@@ -17,17 +17,6 @@
 #ifndef _ARCH_SBI_H
 #define _ARCH_SBI_H
 
-#define SBI_ECALL_HART_ID 0
-#define SBI_ECALL_CONSOLE_PUT 1
-#define SBI_ECALL_SEND_DEVICE_REQUEST 2
-#define SBI_ECALL_RECEIVE_DEVICE_RESPONSE 3
-#define SBI_ECALL_SEND_IPI 4
-#define SBI_ECALL_CLEAR_IPI 5
-#define SBI_ECALL_SHUTDOWN 6
-#define SBI_ECALL_SET_TIMER 7
-#define SBI_ECALL_QUERY_MEMORY 8
-#define SBI_ECALL_NUM_HARTS 9
-
 #ifndef __ASSEMBLY__
 struct opaque;
 extern struct opaque sbi_page;
diff --git a/src/arch/riscv/include/mcall.h b/src/arch/riscv/include/mcall.h
index e303d0d..1e74ed3 100644
--- a/src/arch/riscv/include/mcall.h
+++ b/src/arch/riscv/include/mcall.h
@@ -23,6 +23,20 @@
 /* We save 37 registers, currently. */
 #define MENTRY_FRAME_SIZE (HLS_SIZE + 37 * 8)
 
+#define MCALL_HART_ID			 0
+#define MCALL_NUM_HARTS			 1
+#define MCALL_QUERY_MEMORY		 2
+#define MCALL_CONSOLE_PUTCHAR		 3
+#define MCALL_CONSOLE_GETCHAR		 4
+#define MCALL_SEND_IPI			 6
+#define MCALL_CLEAR_IPI			 7
+#define MCALL_SHUTDOWN			 8
+#define MCALL_SET_TIMER			 9
+#define MCALL_REMOTE_SFENCE_VM		10
+#define MCALL_REMOTE_FENCE_I		11
+#define MCALL_CONFIG_STRING_BASE	12
+#define MCALL_CONFIG_STRING_SIZE	13
+
 #ifndef __ASSEMBLER__
 
 #include <arch/encoding.h>
diff --git a/src/arch/riscv/mcall.c b/src/arch/riscv/mcall.c
index 37a9366..7728fba 100644
--- a/src/arch/riscv/mcall.c
+++ b/src/arch/riscv/mcall.c
@@ -90,18 +90,6 @@ uintptr_t mcall_set_timer(uint64_t when)
 	return 0;
 }
 
-uintptr_t mcall_dev_req(sbi_device_message *m)
-{
-	die("mcall_dev_req is currently not implemented");
-	return 0;
-}
-
-uintptr_t mcall_dev_resp(void)
-{
-	die("mcall_dev_resp is currently not implemented");
-	return 0;
-}
-
 void hls_init(uint32_t hart_id)
 {
 	query_result res;
diff --git a/src/arch/riscv/sbi.S b/src/arch/riscv/sbi.S
index 528e4ca..0ff7c3b 100644
--- a/src/arch/riscv/sbi.S
+++ b/src/arch/riscv/sbi.S
@@ -16,7 +16,7 @@
 
 #define __ASSEMBLY__
 #include <arch/encoding.h>
-#include <arch/sbi.h>
+#include <mcall.h>
 
 .section ".text.sbi", "ax", %progbits
 
@@ -33,26 +33,26 @@ sbi_page:
 	.skip 0x800
 
 	/* -2048: size_t sbi_hart_id(void); */
-	li a7, SBI_ECALL_HART_ID
+	li a7, MCALL_HART_ID
 	ecall
 	jr ra
 	.align 4
 
 	/* -2032: size_t sbi_num_harts(void); */
-	li a7, SBI_ECALL_NUM_HARTS
+	li a7, MCALL_NUM_HARTS
 	ecall
 	jr ra
 	.align 4
 
 	/* -2016: unsigned long sbi_query_memory(unsigned long id,
 			memory_block_info *p); */
-	li a7, SBI_ECALL_QUERY_MEMORY
+	li a7, MCALL_QUERY_MEMORY
 	ecall
 	jr ra
 	.align 4
 
 	/* -2000: int sbi_console_putchar(uint8_t ch); */
-	li a7, SBI_ECALL_CONSOLE_PUT
+	li a7, MCALL_CONSOLE_PUTCHAR
 	ecall
 	jr ra
 	.align 4
@@ -80,13 +80,13 @@ sbi_page:
 	.align 4
 
 	/* -1904: void sbi_shutdown(void); */
-	li a7, SBI_ECALL_SHUTDOWN
+	li a7, MCALL_SHUTDOWN
 	ecall
 	jr ra
 	.align 4
 
 	/* -1888: void sbi_set_timer(unsigned long long stime_value); */
-	li a7, SBI_ECALL_SET_TIMER
+	li a7, MCALL_SET_TIMER
 	ecall
 	jr ra
 	.align 4
diff --git a/src/arch/riscv/trap_handler.c b/src/arch/riscv/trap_handler.c
index 9a8947c..4dd3d5b 100644
--- a/src/arch/riscv/trap_handler.c
+++ b/src/arch/riscv/trap_handler.c
@@ -31,42 +31,34 @@ void handle_supervisor_call(trapframe *tf) {
 	uintptr_t arg1 = tf->gpr[11]; /* a1 */
 	uintptr_t returnValue;
 	switch(call) {
-		case SBI_ECALL_HART_ID:
+		case MCALL_HART_ID:
 			printk(BIOS_DEBUG, "Getting hart id...\n");
 			returnValue = read_csr(0xf14);//mhartid);
 			break;
-		case SBI_ECALL_NUM_HARTS:
+		case MCALL_NUM_HARTS:
 			/* TODO: parse the hardware-supplied config string and
 			   return the correct value */
 			returnValue = 1;
 			break;
-		case SBI_ECALL_CONSOLE_PUT:
+		case MCALL_CONSOLE_PUTCHAR:
 			returnValue = mcall_console_putchar(arg0);
 			break;
-		case SBI_ECALL_SEND_DEVICE_REQUEST:
-			printk(BIOS_DEBUG, "Sending device request...\n");
-			returnValue = mcall_dev_req((sbi_device_message*) arg0);
-			break;
-		case SBI_ECALL_RECEIVE_DEVICE_RESPONSE:
-			printk(BIOS_DEBUG, "Getting device response...\n");
-			returnValue = mcall_dev_resp();
-			break;
-		case SBI_ECALL_SEND_IPI:
+		case MCALL_SEND_IPI:
 			printk(BIOS_DEBUG, "Sending IPI...\n");
 			returnValue = mcall_send_ipi(arg0);
 			break;
-		case SBI_ECALL_CLEAR_IPI:
+		case MCALL_CLEAR_IPI:
 			printk(BIOS_DEBUG, "Clearing IPI...\n");
 			returnValue = mcall_clear_ipi();
 			break;
-		case SBI_ECALL_SHUTDOWN:
+		case MCALL_SHUTDOWN:
 			printk(BIOS_DEBUG, "Shutting down...\n");
 			returnValue = mcall_shutdown();
 			break;
-		case SBI_ECALL_SET_TIMER:
+		case MCALL_SET_TIMER:
 			returnValue = mcall_set_timer(arg0);
 			break;
-		case SBI_ECALL_QUERY_MEMORY:
+		case MCALL_QUERY_MEMORY:
 			printk(BIOS_DEBUG, "Querying memory, CPU #%lld...\n", arg0);
 			returnValue = mcall_query_memory(arg0, (memory_block_info*) arg1);
 			break;



More information about the coreboot-gerrit mailing list