summaryrefslogtreecommitdiff
path: root/src/arch/riscv/mcall.c
diff options
context:
space:
mode:
authorRonald G. Minnich <rminnich@gmail.com>2017-01-15 17:40:51 +0100
committerRonald G. Minnich <rminnich@gmail.com>2017-01-16 00:26:08 +0100
commit6f3a53b6f61126f05db950e1c0a2c0b4f1552e5f (patch)
treed2d9e98c7abed0b671d3d7d57f1d129f59256f6e /src/arch/riscv/mcall.c
parenta19d44d2764be4dba55cad96abea12d92c8e1f0d (diff)
downloadcoreboot-6f3a53b6f61126f05db950e1c0a2c0b4f1552e5f.tar.xz
riscv: get SBI calls to work
SBI calls, as it turned out, were never right. They did not set the stack correctly on traps. They were not correctly setting the MIP instead of the SIP (although this was not really well documented). On Harvey, we were trying to avoid using them, and due to a bug in SPIKE, our avoidance worked. Once SPIKE was fixed, our avoidance broke. This set of changes is tested and working with Harvey which, for the first time, is making SBI calls. It's not pretty and we're going to want to rework trap_util.S in coming days. Change-Id: Ibef530adcc58d33e2c44ff758e0b7d2acbdc5e99 Signed-off-by: Ronald G. Minnich <rminnich@gmail.com> Signed-off-by: Jonathan Neuschäfer <j.neuschaefer@gmx.net> Reviewed-on: https://review.coreboot.org/18097 Tested-by: build bot (Jenkins)
Diffstat (limited to 'src/arch/riscv/mcall.c')
-rw-r--r--src/arch/riscv/mcall.c25
1 files changed, 23 insertions, 2 deletions
diff --git a/src/arch/riscv/mcall.c b/src/arch/riscv/mcall.c
index aa61ae464a..37a9366821 100644
--- a/src/arch/riscv/mcall.c
+++ b/src/arch/riscv/mcall.c
@@ -34,6 +34,8 @@
#include <string.h>
#include <vm.h>
+int mcalldebug; // set this interactively for copious debug.
+
uintptr_t mcall_query_memory(uintptr_t id, memory_block_info *info)
{
if (id == 0) {
@@ -74,9 +76,17 @@ uintptr_t mcall_shutdown(void)
return 0;
}
-uintptr_t mcall_set_timer(unsigned long long when)
+uintptr_t mcall_set_timer(uint64_t when)
{
- printk(BIOS_DEBUG, "mcall_set_timer is currently not implemented, ignoring\n");
+ uint64_t *timecmp = HLS()->timecmp;
+
+ if (mcalldebug)
+ printk(BIOS_SPEW,
+ "hart %d: HLS %p: mcall timecmp@%p to 0x%llx\n",
+ HLS()->hart_id, HLS(), timecmp, when);
+ *timecmp = when;
+ clear_csr(mip, MIP_STIP);
+ set_csr(mie, MIP_MTIP);
return 0;
}
@@ -94,8 +104,19 @@ uintptr_t mcall_dev_resp(void)
void hls_init(uint32_t hart_id)
{
+ query_result res;
+
+ printk(BIOS_SPEW, "hart %d: HLS is %p\n", hart_id, HLS());
memset(HLS(), 0, sizeof(*HLS()));
HLS()->hart_id = hart_id;
+
+ res = query_config_string(configstring(), "rtc{addr");
+ HLS()->time = (void *)get_uint(res);
+ res = query_config_string(configstring(), "core{0{0{timecmp");
+ HLS()->timecmp = (void *)get_uint(res);
+
+ printk(BIOS_SPEW, "Time is %p and timecmp is %p\n",
+ HLS()->time, HLS()->timecmp);
}
uintptr_t mcall_console_putchar(uint8_t ch)