From 43ac621ecba8d472a5e697527143f9d3317df3e1 Mon Sep 17 00:00:00 2001 From: Anup Patel Date: Fri, 17 Jan 2020 19:12:52 +0530 Subject: [PATCH] lib: Factor-out SBI vendor extension This patch factor-out SBI vendor extension into its own source for better modularity of SBI implementation. Signed-off-by: Anup Patel Reviewed-by: Atish Patra --- include/sbi/sbi_ecall.h | 1 + lib/sbi/objects.mk | 1 + lib/sbi/sbi_ecall.c | 29 ++------------------------- lib/sbi/sbi_ecall_vendor.c | 40 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 44 insertions(+), 27 deletions(-) create mode 100644 lib/sbi/sbi_ecall_vendor.c diff --git a/include/sbi/sbi_ecall.h b/include/sbi/sbi_ecall.h index 2357f79..80c99be 100644 --- a/include/sbi/sbi_ecall.h +++ b/include/sbi/sbi_ecall.h @@ -33,6 +33,7 @@ extern struct sbi_ecall_extension ecall_legacy; extern struct sbi_ecall_extension ecall_time; extern struct sbi_ecall_extension ecall_rfence; extern struct sbi_ecall_extension ecall_ipi; +extern struct sbi_ecall_extension ecall_vendor; u16 sbi_ecall_version_major(void); diff --git a/lib/sbi/objects.mk b/lib/sbi/objects.mk index 1c343be..48e7530 100644 --- a/lib/sbi/objects.mk +++ b/lib/sbi/objects.mk @@ -16,6 +16,7 @@ libsbi-objs-y += sbi_console.o libsbi-objs-y += sbi_ecall.o libsbi-objs-y += sbi_ecall_legacy.o libsbi-objs-y += sbi_ecall_replace.o +libsbi-objs-y += sbi_ecall_vendor.o libsbi-objs-y += sbi_emulate_csr.o libsbi-objs-y += sbi_fifo.o libsbi-objs-y += sbi_hfence.o diff --git a/lib/sbi/sbi_ecall.c b/lib/sbi/sbi_ecall.c index d817fef..d34bc49 100644 --- a/lib/sbi/sbi_ecall.c +++ b/lib/sbi/sbi_ecall.c @@ -10,8 +10,9 @@ #include #include #include -#include +#include #include +#include #define SBI_ECALL_VERSION_MAJOR 0 #define SBI_ECALL_VERSION_MINOR 2 @@ -92,32 +93,6 @@ static struct sbi_ecall_extension ecall_base = { .handle = sbi_ecall_base_handler, }; -static int sbi_ecall_vendor_probe(struct sbi_scratch *scratch, - unsigned long extid, - unsigned long *out_val) -{ - *out_val = sbi_platform_vendor_ext_check(sbi_platform_ptr(scratch), - extid); - return 0; -} - -static int sbi_ecall_vendor_handler(struct sbi_scratch *scratch, - 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), - extid, funcid, args, - out_val, out_trap); -} - -static struct sbi_ecall_extension ecall_vendor = { - .extid_start = SBI_EXT_VENDOR_START, - .extid_end = SBI_EXT_VENDOR_END, - .probe = sbi_ecall_vendor_probe, - .handle = sbi_ecall_vendor_handler, -}; - static SBI_LIST_HEAD(ecall_exts_list); struct sbi_ecall_extension *sbi_ecall_find_extension(unsigned long extid) diff --git a/lib/sbi/sbi_ecall_vendor.c b/lib/sbi/sbi_ecall_vendor.c new file mode 100644 index 0000000..70d0446 --- /dev/null +++ b/lib/sbi/sbi_ecall_vendor.c @@ -0,0 +1,40 @@ +/* + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2020 Western Digital Corporation or its affiliates. + * + * Authors: + * Anup Patel + * Atish Patra + */ + +#include +#include +#include +#include + +static int sbi_ecall_vendor_probe(struct sbi_scratch *scratch, + unsigned long extid, + unsigned long *out_val) +{ + *out_val = sbi_platform_vendor_ext_check(sbi_platform_ptr(scratch), + extid); + return 0; +} + +static int sbi_ecall_vendor_handler(struct sbi_scratch *scratch, + 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), + extid, funcid, args, + out_val, out_trap); +} + +struct sbi_ecall_extension ecall_vendor = { + .extid_start = SBI_EXT_VENDOR_START, + .extid_end = SBI_EXT_VENDOR_END, + .probe = sbi_ecall_vendor_probe, + .handle = sbi_ecall_vendor_handler, +};