summaryrefslogtreecommitdiff
path: root/lib/sbi
diff options
context:
space:
mode:
authorAnup Patel <anup.patel@wdc.com>2020-03-19 19:25:12 +0300
committerAnup Patel <anup@brainfault.org>2020-03-28 11:02:20 +0300
commit7487116b41e6c06d3903b600a2231d2a68d0c4a4 (patch)
tree1ed0174c5271e57a4554d8bdd6ffea16cbe60b2a /lib/sbi
parentfe37d7da29f67ae8ccc31f06e0f3e6c9a6b58054 (diff)
downloadopensbi-7487116b41e6c06d3903b600a2231d2a68d0c4a4.tar.xz
lib: sbi_ecall: Remove mcause, scratch and hartid parameters
We remove mcause, scratch and hartid parameters from various functions for ecall handling because we can always get current HART id and current scratch pointer using just one CSR access. Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Atish Patra <atish.patra@wdc.com>
Diffstat (limited to 'lib/sbi')
-rw-r--r--lib/sbi/sbi_ecall.c5
-rw-r--r--lib/sbi/sbi_ecall_base.c11
-rw-r--r--lib/sbi/sbi_ecall_hsm.c8
-rw-r--r--lib/sbi/sbi_ecall_legacy.c5
-rw-r--r--lib/sbi/sbi_ecall_replace.c19
-rw-r--r--lib/sbi/sbi_ecall_vendor.c10
-rw-r--r--lib/sbi/sbi_trap.c2
7 files changed, 28 insertions, 32 deletions
diff --git a/lib/sbi/sbi_ecall.c b/lib/sbi/sbi_ecall.c
index 230dfa3..6c42553 100644
--- a/lib/sbi/sbi_ecall.c
+++ b/lib/sbi/sbi_ecall.c
@@ -79,8 +79,7 @@ void sbi_ecall_unregister_extension(struct sbi_ecall_extension *ext)
sbi_list_del_init(&ext->head);
}
-int sbi_ecall_handler(u32 hartid, ulong mcause, struct sbi_trap_regs *regs,
- struct sbi_scratch *scratch)
+int sbi_ecall_handler(struct sbi_trap_regs *regs)
{
int ret = 0;
struct sbi_ecall_extension *ext;
@@ -100,7 +99,7 @@ int sbi_ecall_handler(u32 hartid, ulong mcause, struct sbi_trap_regs *regs,
ext = sbi_ecall_find_extension(extension_id);
if (ext && ext->handle) {
- ret = ext->handle(scratch, extension_id, func_id,
+ ret = ext->handle(extension_id, func_id,
args, &out_val, &trap);
if (extension_id >= SBI_EXT_0_1_SET_TIMER &&
extension_id <= SBI_EXT_0_1_SHUTDOWN)
diff --git a/lib/sbi/sbi_ecall_base.c b/lib/sbi/sbi_ecall_base.c
index 6475745..1049c80 100644
--- a/lib/sbi/sbi_ecall_base.c
+++ b/lib/sbi/sbi_ecall_base.c
@@ -14,9 +14,7 @@
#include <sbi/sbi_version.h>
#include <sbi/riscv_asm.h>
-static int sbi_ecall_base_probe(struct sbi_scratch *scratch,
- unsigned long extid,
- unsigned long *out_val)
+static int sbi_ecall_base_probe(unsigned long extid, unsigned long *out_val)
{
struct sbi_ecall_extension *ext;
@@ -27,14 +25,13 @@ static int sbi_ecall_base_probe(struct sbi_scratch *scratch,
}
if (ext->probe)
- return ext->probe(scratch, extid, out_val);
+ return ext->probe(extid, out_val);
*out_val = 1;
return 0;
}
-static int sbi_ecall_base_handler(struct sbi_scratch *scratch,
- unsigned long extid, unsigned long funcid,
+static int sbi_ecall_base_handler(unsigned long extid, unsigned long funcid,
unsigned long *args, unsigned long *out_val,
struct sbi_trap_info *out_trap)
{
@@ -64,7 +61,7 @@ static int sbi_ecall_base_handler(struct sbi_scratch *scratch,
*out_val = csr_read(CSR_MIMPID);
break;
case SBI_EXT_BASE_PROBE_EXT:
- ret = sbi_ecall_base_probe(scratch, args[0], out_val);
+ ret = sbi_ecall_base_probe(args[0], out_val);
break;
default:
ret = SBI_ENOTSUPP;
diff --git a/lib/sbi/sbi_ecall_hsm.c b/lib/sbi/sbi_ecall_hsm.c
index 5b77726..028bf68 100644
--- a/lib/sbi/sbi_ecall_hsm.c
+++ b/lib/sbi/sbi_ecall_hsm.c
@@ -12,15 +12,15 @@
#include <sbi/sbi_error.h>
#include <sbi/sbi_version.h>
#include <sbi/sbi_hsm.h>
+#include <sbi/sbi_scratch.h>
#include <sbi/riscv_asm.h>
-static int sbi_ecall_hsm_handler(struct sbi_scratch *scratch,
- unsigned long extid, unsigned long funcid,
+static int sbi_ecall_hsm_handler(unsigned long extid, unsigned long funcid,
unsigned long *args, unsigned long *out_val,
struct sbi_trap_info *out_trap)
{
- int ret = 0;
- int hstate;
+ int ret = 0, hstate;
+ struct sbi_scratch *scratch = sbi_scratch_thishart_ptr();
switch (funcid) {
case SBI_EXT_HSM_HART_START:
diff --git a/lib/sbi/sbi_ecall_legacy.c b/lib/sbi/sbi_ecall_legacy.c
index 70981e4..95f612a 100644
--- a/lib/sbi/sbi_ecall_legacy.c
+++ b/lib/sbi/sbi_ecall_legacy.c
@@ -15,6 +15,7 @@
#include <sbi/sbi_error.h>
#include <sbi/sbi_hsm.h>
#include <sbi/sbi_ipi.h>
+#include <sbi/sbi_scratch.h>
#include <sbi/sbi_system.h>
#include <sbi/sbi_timer.h>
#include <sbi/sbi_tlb.h>
@@ -39,14 +40,14 @@ static int sbi_load_hart_mask_unpriv(ulong *pmask, ulong *hmask,
return 0;
}
-static int sbi_ecall_legacy_handler(struct sbi_scratch *scratch,
- unsigned long extid, unsigned long funcid,
+static int sbi_ecall_legacy_handler(unsigned long extid, unsigned long funcid,
unsigned long *args, unsigned long *out_val,
struct sbi_trap_info *out_trap)
{
int ret = 0;
struct sbi_tlb_info tlb_info;
u32 source_hart = current_hartid();
+ struct sbi_scratch *scratch = sbi_scratch_thishart_ptr();
ulong hmask = 0;
switch (extid) {
diff --git a/lib/sbi/sbi_ecall_replace.c b/lib/sbi/sbi_ecall_replace.c
index 21f3809..36a5c5c 100644
--- a/lib/sbi/sbi_ecall_replace.c
+++ b/lib/sbi/sbi_ecall_replace.c
@@ -14,11 +14,11 @@
#include <sbi/sbi_error.h>
#include <sbi/sbi_hart.h>
#include <sbi/sbi_ipi.h>
+#include <sbi/sbi_scratch.h>
#include <sbi/sbi_timer.h>
#include <sbi/sbi_tlb.h>
-static int sbi_ecall_time_handler(struct sbi_scratch *scratch,
- unsigned long extid, unsigned long funcid,
+static int sbi_ecall_time_handler(unsigned long extid, unsigned long funcid,
unsigned long *args, unsigned long *out_val,
struct sbi_trap_info *out_trap)
{
@@ -26,10 +26,11 @@ static int sbi_ecall_time_handler(struct sbi_scratch *scratch,
if (funcid == SBI_EXT_TIME_SET_TIMER) {
#if __riscv_xlen == 32
- sbi_timer_event_start(scratch,
+ sbi_timer_event_start(sbi_scratch_thishart_ptr(),
(((u64)args[1] << 32) | (u64)args[0]));
#else
- sbi_timer_event_start(scratch, (u64)args[0]);
+ sbi_timer_event_start(sbi_scratch_thishart_ptr(),
+ (u64)args[0]);
#endif
} else
ret = SBI_ENOTSUPP;
@@ -43,14 +44,14 @@ struct sbi_ecall_extension ecall_time = {
.handle = sbi_ecall_time_handler,
};
-static int sbi_ecall_rfence_handler(struct sbi_scratch *scratch,
- unsigned long extid, unsigned long funcid,
+static int sbi_ecall_rfence_handler(unsigned long extid, unsigned long funcid,
unsigned long *args, unsigned long *out_val,
struct sbi_trap_info *out_trap)
{
int ret = 0;
struct sbi_tlb_info tlb_info;
u32 source_hart = current_hartid();
+ struct sbi_scratch *scratch = sbi_scratch_thishart_ptr();
if (funcid >= SBI_EXT_RFENCE_REMOTE_HFENCE_GVMA &&
funcid <= SBI_EXT_RFENCE_REMOTE_HFENCE_VVMA_ASID)
@@ -106,15 +107,15 @@ struct sbi_ecall_extension ecall_rfence = {
.handle = sbi_ecall_rfence_handler,
};
-static int sbi_ecall_ipi_handler(struct sbi_scratch *scratch,
- unsigned long extid, unsigned long funcid,
+static int sbi_ecall_ipi_handler(unsigned long extid, unsigned long funcid,
unsigned long *args, unsigned long *out_val,
struct sbi_trap_info *out_trap)
{
int ret = 0;
if (funcid == SBI_EXT_IPI_SEND_IPI)
- ret = sbi_ipi_send_smode(scratch, args[0], args[1]);
+ ret = sbi_ipi_send_smode(sbi_scratch_thishart_ptr(),
+ args[0], args[1]);
else
ret = SBI_ENOTSUPP;
diff --git a/lib/sbi/sbi_ecall_vendor.c b/lib/sbi/sbi_ecall_vendor.c
index 70d0446..34c0be6 100644
--- a/lib/sbi/sbi_ecall_vendor.c
+++ b/lib/sbi/sbi_ecall_vendor.c
@@ -13,21 +13,19 @@
#include <sbi/sbi_error.h>
#include <sbi/sbi_platform.h>
-static int sbi_ecall_vendor_probe(struct sbi_scratch *scratch,
- unsigned long extid,
+static int sbi_ecall_vendor_probe(unsigned long extid,
unsigned long *out_val)
{
- *out_val = sbi_platform_vendor_ext_check(sbi_platform_ptr(scratch),
+ *out_val = sbi_platform_vendor_ext_check(sbi_platform_thishart_ptr(),
extid);
return 0;
}
-static int sbi_ecall_vendor_handler(struct sbi_scratch *scratch,
- unsigned long extid, unsigned long funcid,
+static int sbi_ecall_vendor_handler(unsigned long extid, unsigned long funcid,
unsigned long *args, unsigned long *out_val,
struct sbi_trap_info *out_trap)
{
- return sbi_platform_vendor_ext_provider(sbi_platform_ptr(scratch),
+ return sbi_platform_vendor_ext_provider(sbi_platform_thishart_ptr(),
extid, funcid, args,
out_val, out_trap);
}
diff --git a/lib/sbi/sbi_trap.c b/lib/sbi/sbi_trap.c
index b06b33f..7f8f30f 100644
--- a/lib/sbi/sbi_trap.c
+++ b/lib/sbi/sbi_trap.c
@@ -256,7 +256,7 @@ void sbi_trap_handler(struct sbi_trap_regs *regs,
break;
case CAUSE_SUPERVISOR_ECALL:
case CAUSE_HYPERVISOR_ECALL:
- rc = sbi_ecall_handler(hartid, mcause, regs, scratch);
+ rc = sbi_ecall_handler(regs);
msg = "ecall handler failed";
break;
default: