diff options
author | Anup Patel <anup.patel@wdc.com> | 2020-01-17 19:25:24 +0530 |
---|---|---|
committer | Anup Patel <anup@brainfault.org> | 2020-01-22 12:13:47 +0530 |
commit | 021b9e7c767f101e80fdd4868ad95177fa1cf1da (patch) | |
tree | 0eeda6168e2960d66c94b4847ad0a2f5e182de70 /lib/sbi/sbi_ecall.c | |
parent | 43ac621ecba8d472a5e697527143f9d3317df3e1 (diff) |
lib: Factor-out SBI base extension
This patch factor-out SBI base extension into its own source
for better modularity of SBI implementation.
Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
Diffstat (limited to 'lib/sbi/sbi_ecall.c')
-rw-r--r-- | lib/sbi/sbi_ecall.c | 71 |
1 files changed, 0 insertions, 71 deletions
diff --git a/lib/sbi/sbi_ecall.c b/lib/sbi/sbi_ecall.c index d34bc49..e52a654 100644 --- a/lib/sbi/sbi_ecall.c +++ b/lib/sbi/sbi_ecall.c @@ -11,12 +11,6 @@ #include <sbi/sbi_ecall_interface.h> #include <sbi/sbi_error.h> #include <sbi/sbi_trap.h> -#include <sbi/sbi_version.h> -#include <sbi/riscv_asm.h> - -#define SBI_ECALL_VERSION_MAJOR 0 -#define SBI_ECALL_VERSION_MINOR 2 -#define SBI_OPENSBI_IMPID 1 u16 sbi_ecall_version_major(void) { @@ -28,71 +22,6 @@ u16 sbi_ecall_version_minor(void) return SBI_ECALL_VERSION_MINOR; } -static int sbi_ecall_base_probe(struct sbi_scratch *scratch, - unsigned long extid, - unsigned long *out_val) -{ - struct sbi_ecall_extension *ext; - - ext = sbi_ecall_find_extension(extid); - if (!ext) { - *out_val = 0; - return 0; - } - - if (ext->probe) - return ext->probe(scratch, extid, out_val); - - *out_val = 1; - return 0; -} - -static int sbi_ecall_base_handler(struct sbi_scratch *scratch, - unsigned long extid, unsigned long funcid, - unsigned long *args, unsigned long *out_val, - struct sbi_trap_info *out_trap) -{ - int ret = 0; - - switch (funcid) { - case SBI_EXT_BASE_GET_SPEC_VERSION: - *out_val = (SBI_ECALL_VERSION_MAJOR << - SBI_SPEC_VERSION_MAJOR_OFFSET) & - (SBI_SPEC_VERSION_MAJOR_MASK << - SBI_SPEC_VERSION_MAJOR_OFFSET); - *out_val = *out_val | SBI_ECALL_VERSION_MINOR; - break; - case SBI_EXT_BASE_GET_IMP_ID: - *out_val = SBI_OPENSBI_IMPID; - break; - case SBI_EXT_BASE_GET_IMP_VERSION: - *out_val = OPENSBI_VERSION; - break; - case SBI_EXT_BASE_GET_MVENDORID: - *out_val = csr_read(CSR_MVENDORID); - break; - case SBI_EXT_BASE_GET_MARCHID: - *out_val = csr_read(CSR_MARCHID); - break; - case SBI_EXT_BASE_GET_MIMPID: - *out_val = csr_read(CSR_MIMPID); - break; - case SBI_EXT_BASE_PROBE_EXT: - ret = sbi_ecall_base_probe(scratch, args[0], out_val); - break; - default: - ret = SBI_ENOTSUPP; - } - - return ret; -} - -static struct sbi_ecall_extension ecall_base = { - .extid_start = SBI_EXT_BASE, - .extid_end = SBI_EXT_BASE, - .handle = sbi_ecall_base_handler, -}; - static SBI_LIST_HEAD(ecall_exts_list); struct sbi_ecall_extension *sbi_ecall_find_extension(unsigned long extid) |