From 9da9b5045f0d13ef303adf88ff5e771601f0d6b1 Mon Sep 17 00:00:00 2001 From: vhaudiquet Date: Thu, 19 Oct 2023 20:56:18 +0200 Subject: [PATCH] Added SBI functions support --- src/devices/sbi/sbi.c | 11 +++++++++++ src/devices/sbi/sbi.h | 11 +++++++++++ 2 files changed, 22 insertions(+) diff --git a/src/devices/sbi/sbi.c b/src/devices/sbi/sbi.c index 5c87ef1..14305bc 100644 --- a/src/devices/sbi/sbi.c +++ b/src/devices/sbi/sbi.c @@ -10,6 +10,11 @@ void sbi_call(rv32_cpu_t* cpu, uint32_t extension_id, uint32_t func_id) { switch(func_id) { + case SBI_FUNCTION_GET_SPEC_VERSION: + // Format: [31(reserved,0) 7 bits(major) 24 bits(minor)] + // Version 2.0 + cpu->regs.a0 = 0x2000000; + break; case SBI_FUNCTION_GET_MVENDOR_ID: cpu->regs.a0 = 0; break; @@ -25,6 +30,12 @@ void sbi_call(rv32_cpu_t* cpu, uint32_t extension_id, uint32_t func_id) } break; } + case SBI_EXTENSION_SET_TIMER: + { + // TODO : Correctly implement that + cpu->regs.a0 = 0; + break; + } case SBI_EXTENSION_LEGACY_CONSOLE_PUTCHAR: { printf("%c", cpu->regs.a0); diff --git a/src/devices/sbi/sbi.h b/src/devices/sbi/sbi.h index ce4f182..45d8e34 100644 --- a/src/devices/sbi/sbi.h +++ b/src/devices/sbi/sbi.h @@ -3,6 +3,17 @@ #include "cpu/rv32cpu.h" +/* SBI Base extension */ +#define SBI_EXTENSION_BASE 0x10 +#define SBI_FUNCTION_GET_SPEC_VERSION 0x0 +#define SBI_FUNCTION_GET_IMPL_ID 0x1 +#define SBI_FUNCTION_GET_IMPL_VERSION 0x2 +#define SBI_FUNCTION_PROBE_EXTENSION 0x3 +#define SBI_FUNCTION_GET_MVENDOR_ID 0x4 +#define SBI_FUNCTION_GET_MARCH_ID 0x5 +#define SBI_FUNCTION_GET_MIMPL_ID 0x6 + +#define SBI_EXTENSION_SET_TIMER 0x0 #define SBI_EXTENSION_LEGACY_CONSOLE_PUTCHAR 0x1 #define SBI_EXTENSION_LEGACY_SHUTDOWN 0x8