From e5aef873a267b9a440e6b4d2885170742740b5c7 Mon Sep 17 00:00:00 2001 From: Ville Juven Date: Fri, 4 Oct 2024 12:58:24 +0300 Subject: [PATCH] riscv_internal.h: Remove riscv_sbi.h from the file riscv_internal.h is used literally everywhere, while the SBI definitions are needed only by whomever needs the services. Having the SBI definitions: a) Copied from OpenSBI (why has this been done? even the names are same) b) Presented publicly to 99% of risc-v modules creates a build error when building with OpenSBI, due to duplicate definitions of the SBI service identifiers: In file included from /nuttx/arch/risc-v/src/common/riscv_internal.h:40, from /nuttx/arch/risc-v/src/chip/chip.h:32, from board/mpfs_domain.c:30: /nuttx/arch/risc-v/src/common/riscv_sbi.h:36: error: "SBI_EXT_BASE" redefined [-Werror] 36 | #define SBI_EXT_BASE 0x00000010 and so forth... Fix this by removing riscv_sbi.h i.e. not exposing the ABI publicly. --- arch/risc-v/src/common/riscv_internal.h | 1 - arch/risc-v/src/common/riscv_ipi.h | 1 + arch/risc-v/src/common/riscv_mtimer.c | 3 ++- arch/risc-v/src/nuttsbi/sbi_mcall.c | 1 + arch/risc-v/src/qemu-rv/qemu_rv_start.c | 3 ++- boards/risc-v/qemu-rv/rv-virt/src/qemu_rv_appinit.c | 1 + 6 files changed, 7 insertions(+), 3 deletions(-) diff --git a/arch/risc-v/src/common/riscv_internal.h b/arch/risc-v/src/common/riscv_internal.h index 8557ef8396b3e..be3fe07ad6c1b 100644 --- a/arch/risc-v/src/common/riscv_internal.h +++ b/arch/risc-v/src/common/riscv_internal.h @@ -37,7 +37,6 @@ #include -#include "riscv_sbi.h" #include "riscv_common_memorymap.h" /**************************************************************************** diff --git a/arch/risc-v/src/common/riscv_ipi.h b/arch/risc-v/src/common/riscv_ipi.h index 8c3989d7ee778..5d8d2a400bdbb 100644 --- a/arch/risc-v/src/common/riscv_ipi.h +++ b/arch/risc-v/src/common/riscv_ipi.h @@ -26,6 +26,7 @@ ****************************************************************************/ #include "riscv_internal.h" +#include "riscv_sbi.h" #include "chip.h" /**************************************************************************** diff --git a/arch/risc-v/src/common/riscv_mtimer.c b/arch/risc-v/src/common/riscv_mtimer.c index 0efc19b093959..b611c3dd99914 100644 --- a/arch/risc-v/src/common/riscv_mtimer.c +++ b/arch/risc-v/src/common/riscv_mtimer.c @@ -27,8 +27,9 @@ #include -#include "riscv_mtimer.h" #include "riscv_internal.h" +#include "riscv_mtimer.h" +#include "riscv_sbi.h" /**************************************************************************** * Private Types diff --git a/arch/risc-v/src/nuttsbi/sbi_mcall.c b/arch/risc-v/src/nuttsbi/sbi_mcall.c index 02f0eeb2a9c1d..24536ef5da951 100644 --- a/arch/risc-v/src/nuttsbi/sbi_mcall.c +++ b/arch/risc-v/src/nuttsbi/sbi_mcall.c @@ -28,6 +28,7 @@ #include #include "riscv_internal.h" +#include "riscv_sbi.h" #include "sbi_mcall.h" #include "sbi_internal.h" diff --git a/arch/risc-v/src/qemu-rv/qemu_rv_start.c b/arch/risc-v/src/qemu-rv/qemu_rv_start.c index 89a771d256110..652bf9082bcd5 100644 --- a/arch/risc-v/src/qemu-rv/qemu_rv_start.c +++ b/arch/risc-v/src/qemu-rv/qemu_rv_start.c @@ -31,6 +31,7 @@ #include #include "riscv_internal.h" +#include "riscv_sbi.h" #include "chip.h" #include "qemu_rv_userspace.h" @@ -253,4 +254,4 @@ void sbi_late_initialize(void) riscv_append_pmp_region(NAPOT_RW, 0, SIZE_HALF); riscv_append_pmp_region(NAPOT_RWX, SIZE_HALF, SIZE_HALF); } -#endif \ No newline at end of file +#endif diff --git a/boards/risc-v/qemu-rv/rv-virt/src/qemu_rv_appinit.c b/boards/risc-v/qemu-rv/rv-virt/src/qemu_rv_appinit.c index 345d85f489b66..786a08d771551 100644 --- a/boards/risc-v/qemu-rv/rv-virt/src/qemu_rv_appinit.c +++ b/boards/risc-v/qemu-rv/rv-virt/src/qemu_rv_appinit.c @@ -41,6 +41,7 @@ #include "qemu_rv_rptun.h" #include "riscv_internal.h" +#include "riscv_sbi.h" #include "romfs.h" #ifdef CONFIG_USERLED