- Sep 01, 2022
-
-
Anup Patel authored
Let us print the platform PMU device name at the boot-time so that users know whether the underlying platform has custom per-HART PMU operations. Signed-off-by:
Anup Patel <apatel@ventanamicro.com> Reviewed-by:
Andrew Jones <ajones@ventanamicro.com> Reviewed-by:
Atish Patra <atishp@rivosinc.com>
-
Anup Patel authored
We extend SBI PMU implementation to allow custom PMU device operations which a platform can use for platform specific quirks. The custom PMU device operations added by this patch include: 1) Operations to allow a platform implement custom firmware events. These custom firmware events can be SBI vendor extension related events or platform specific per-HART events are not possible to count through HPM CSRs. 2) Operations to allow a platform implement custom way for enabling (or disabling) an overflow interrupt (e.g. T-Head C9xx). Signed-off-by:
Anup Patel <apatel@ventanamicro.com> Reviewed-by:
Andrew Jones <ajones@ventanamicro.com> Reviewed-by:
Atish Patra <atishp@rivosinc.com>
-
Anup Patel authored
Currently, we have 32 elements (i.e. SBI_PMU_FW_EVENT_MAX) array of "struct sbi_pmu_fw_event" for each of 128 possible HARTs (i.e. SBI_HARTMASK_MAX_BITS). To reduce memory usage of OpenSBI, we update FW counter implementation as follows: 1) Remove SBI_PMU_FW_EVENT_MAX 2) Remove "struct sbi_pmu_fw_event" 3) Create per-HART bitmap of XLEN bits to track FW counters which are started on each HART 4) Create per-HART uint64_t array to track values of FW counters on each HART. Signed-off-by:
Anup Patel <apatel@ventanamicro.com> Reviewed-by:
Andrew Jones <ajones@ventanamicro.com> Reviewed-by:
Atish Patra <atishp@rivosinc.com>
-
Anup Patel authored
As-per SBI specification, all firmware counters are always 64 bits wide so let us update the SBI PMU implementation to reflect this fact. Signed-off-by:
Anup Patel <apatel@ventanamicro.com> Reviewed-by:
Andrew Jones <ajones@ventanamicro.com> Reviewed-by:
Atish Patra <atishp@rivosinc.com>
-
Anup Patel authored
The "read a firmware counter" SBI call should only work for firmware counters so let us replace sbi_pmu_ctr_read() with sbi_pmu_ctr_fw_read() which works only on firmware counters. Signed-off-by:
Anup Patel <apatel@ventanamicro.com> Reviewed-by:
Andrew Jones <ajones@ventanamicro.com> Reviewed-by:
Atish Patra <atishp@rivosinc.com>
-
Anup Patel authored
The "event_idx" member of struct sbi_pmu_fw_event is not used anywhere so let us remove it. Signed-off-by:
Anup Patel <apatel@ventanamicro.com> Reviewed-by:
Andrew Jones <ajones@ventanamicro.com> Reviewed-by:
Atish Patra <atishp@rivosinc.com>
-
Rahul Pathak authored
sideleg and sedeleg csrs are not part of riscv isa spec anymore, these csrs were part of N extension which is removed from the riscv isa specification. These commits removed all traces of these csrs from riscv spec (https://github.com/riscv/riscv-isa-manual ) - commit f8d27f805b65 ("Remove or downgrade more references to N extension (#674)") commit b6cade07034d ("Remove N extension chapter for now") Signed-off-by:
Rahul Pathak <rpathak@ventanamicro.com> Reviewed-by:
Andrew Jones <ajones@ventanamicro.com> Reviewed-by:
Anup Patel <anup@brainfault.org>
-
- Aug 23, 2022
-
-
Jun Liang Tan authored
Add Cadence UART driver Signed-off-by:
Jun Liang Tan <junliang.tan@linux.starfivetech.com> Signed-off-by:
Wei Liang Lim <weiliang.lim@linux.starfivetech.com> Reviewed-by:
Andrew Jones <ajones@ventanamicro.com> Reviewed-by:
Anup Patel <anup@brainfault.org>
-
- Aug 22, 2022
-
-
Anup Patel authored
The arch review of AIA spec is completed and we now have official extension names for AIA: Smaia (M-mode AIA CSRs) and Ssaia (S-mode AIA CSRs). Refer, section 1.6 of the latest AIA v0.3.1 stable specification at https://github.com/riscv/riscv-aia/releases/download/0.3.1-draft.32/riscv-interrupts-032.pdf ) Based on above, we update generic library to use "Smaia" extension name for AIA M-mode CSRs. Signed-off-by:
Anup Patel <apatel@ventanamicro.com> Reviewed-by:
Andrew Jones <ajones@ventanamicro.com> Reviewed-by:
Atish Patra <atishp@rivosinc.com>
-
Rahul Pathak authored
In case of missing "FENCE.TSO" instruction implementation, opensbi can emulate the "FENCE.TSO" with "FENCE RW,RW", but mepc was not incremented to continue from the next instruction causing infinite trap. Fixes: cb8271c8 ("lib: sbi_illegal_insn: Add emulation for fence.tso") Signed-off-by:
Rahul Pathak <rpathak@ventanamicro.com> Reviewed-by:
Andrew Jones <ajones@ventanamicro.com> Reviewed-by:
Xiang W <wxjstz@126.com> Reviewed-by:
Samuel Holland <samuel@sholland.org>
-
Vivian Wang authored
The privileged spec specifies that on a trap to HS-mode, hstatus.GVA should be set to 1 if stval is written with a guest virtual address, and to 0 otherwise. Implement this by setting hstatus.GVA to trap->gva when redirecting traps to HS-mode. Signed-off-by:
Vivian Wang <dramforever@live.com> Reviewed-by:
Andrew Jones <ajones@ventanamicro.com> Reviewed-by:
Anup Patel <anup@brainfault.org>
-
Vivian Wang authored
The hypervisor CSRs hstatus, htval, htinst should always be set if the trap is to be taken in HS-mode, regardless of which mode it came from. Signed-off-by:
Vivian Wang <dramforever@live.com> Reviewed-by:
Andrew Jones <ajones@ventanamicro.com> Reviewed-by:
Anup Patel <anup@brainfault.org>
-
Vivian Wang authored
In some cases the sbi_trap_info argument passed to sbi_trap_redirect is created from scratch by filling its fields. Since we previously added a gva field to struct sbi_trap_info, initialize gva in these cases also. Suggested-by:
Andrew Jones <ajones@ventanamicro.com> Signed-off-by:
Vivian Wang <dramforever@live.com> Reviewed-by:
Andrew Jones <ajones@ventanamicro.com> Reviewed-by:
Anup Patel <anup@brainfault.org>
-
Vivian Wang authored
The machine mode GVA field is available if the hypervisor extension is implemented, and indicates if mtval is a guest virtual address. Add a gva field to sbi_trap_info for this, and in __sbi_expected_trap_hext, save mstatus[h].GVA to it, so that gva indicates if tval is a guest virtual address. If the hypervisor extension is not implemented, always set gva to 0. Signed-off-by:
Vivian Wang <dramforever@live.com> Reviewed-by:
Andrew Jones <ajones@ventanamicro.com> Reviewed-by:
Anup Patel <anup@brainfault.org>
-
Vivian Wang authored
The machine mode GVA field is in mstatus for RV64 and mstatush for RV32, and is available if the hypervisor extension is available. If an exception occurs, we may need to redirect the trap to HS-mode, in which case, hstatus.GVA should be set to same as the machine mode GVA bit. Add MSTATUS_GVA for RV64, MSTATUSH_GVA for RV32, and their SHIFT encodings. The SHIFT index is helpful in assembly code, since field extraction can be implemented in only one register. In pseudocode: - For RV32: gva = (mstatus >> MSTATUS_GVA_SHIFT) & 1; - For RV64: gva = (mstatush >> MSTATUSH_GVA_SHIFT) & 1; Signed-off-by:
Vivian Wang <dramforever@live.com> Reviewed-by:
Andrew Jones <ajones@ventanamicro.com> Reviewed-by:
Anup Patel <anup@brainfault.org>
-
- Aug 08, 2022
-
-
Anup Patel authored
The "object.mk" name referred in top-level makefile should be "objects.mk". Signed-off-by:
Anup Patel <apatel@ventanamicro.com> Reviewed-by:
Andrew Jones <ajones@ventanamicro.com> Tested-by:
Andrew Jones <ajones@ventanamicro.com> Acked-by:
Atish Patra <atishp@rivosinc.com> Tested-by:
Atish Patra <atishp@rivosinc.com>
-
Anup Patel authored
We update all documentation files to: 1) Remove references to platform specific config.mk file since it is has been removed. 2) Add details about platform specific configs/defconfig and Kconfig files mandatory for each platform. 3) Add required packages in top-level README.md 4) Fix typo releated to object.mk in docs/platform/platform.md Signed-off-by:
Anup Patel <apatel@ventanamicro.com> Reviewed-by:
Andrew Jones <ajones@ventanamicro.com> Tested-by:
Andrew Jones <ajones@ventanamicro.com> Acked-by:
Atish Patra <atishp@rivosinc.com> Tested-by:
Atish Patra <atishp@rivosinc.com>
-
Anup Patel authored
The options defined in config.mk can be specified in objects.mk of each platform so let us remove config.mk from all platforms. Signed-off-by:
Anup Patel <apatel@ventanamicro.com> Tested-by:
Andrew Jones <ajones@ventanamicro.com> Acked-by:
Atish Patra <atishp@rivosinc.com> Tested-by:
Atish Patra <atishp@rivosinc.com>
-
Anup Patel authored
The generic platform version and default name should be set based on kconfig options so that users can override it. Signed-off-by:
Anup Patel <apatel@ventanamicro.com> Reviewed-by:
Andrew Jones <ajones@ventanamicro.com> Tested-by:
Andrew Jones <ajones@ventanamicro.com> Acked-by:
Atish Patra <atishp@rivosinc.com> Tested-by:
Atish Patra <atishp@rivosinc.com>
-
Anup Patel authored
We update generic platform to use kconfig for enabling/disabling platform overrides. We also enable all platform overrides in generic platform defconfig. Signed-off-by:
Anup Patel <apatel@ventanamicro.com> Tested-by:
Andrew Jones <ajones@ventanamicro.com> Acked-by:
Atish Patra <atishp@rivosinc.com> Tested-by:
Atish Patra <atishp@rivosinc.com>
-
Anup Patel authored
We update FDT support makefile to use kconfig for enabling/disabling. To avoid compilation errors, we also enable FDT for each platform. Signed-off-by:
Anup Patel <apatel@ventanamicro.com> Tested-by:
Andrew Jones <ajones@ventanamicro.com> Acked-by:
Atish Patra <atishp@rivosinc.com> Tested-by:
Atish Patra <atishp@rivosinc.com>
-
Anup Patel authored
We update gpio drivers makefile to use kconfig for enabling/disabling drivers. To avoid compile errors, we also enable appropriate gpio drivers for each platform. Signed-off-by:
Anup Patel <apatel@ventanamicro.com> Tested-by:
Andrew Jones <ajones@ventanamicro.com> Acked-by:
Atish Patra <atishp@rivosinc.com> Tested-by:
Atish Patra <atishp@rivosinc.com>
-
Anup Patel authored
We update i2c drivers makefile to use kconfig for enabling/disabling drivers. To avoid compile errors, we also enable appropriate i2c drivers for each platform. Signed-off-by:
Anup Patel <apatel@ventanamicro.com> Tested-by:
Andrew Jones <ajones@ventanamicro.com> Acked-by:
Atish Patra <atishp@rivosinc.com> Tested-by:
Atish Patra <atishp@rivosinc.com>
-
Anup Patel authored
We update irqchip drivers makefile to use kconfig for enabling/disabling drivers. To avoid compile errors, we also enable appropriate irqchip drivers for each platform. Signed-off-by:
Anup Patel <apatel@ventanamicro.com> Tested-by:
Andrew Jones <ajones@ventanamicro.com> Acked-by:
Atish Patra <atishp@rivosinc.com> Tested-by:
Atish Patra <atishp@rivosinc.com>
-
Anup Patel authored
We update ipi drivers makefile to use kconfig for enabling/disabling drivers. To avoid compile errors, we also enable appropriate ipi drivers for each platform. Signed-off-by:
Anup Patel <apatel@ventanamicro.com> Tested-by:
Andrew Jones <ajones@ventanamicro.com> Acked-by:
Atish Patra <atishp@rivosinc.com> Tested-by:
Atish Patra <atishp@rivosinc.com>
-
Anup Patel authored
We update timer drivers makefile to use kconfig for enabling/disabling drivers. To avoid compile errors, we also enable appropriate timer drivers for each platform. Signed-off-by:
Anup Patel <apatel@ventanamicro.com> Tested-by:
Andrew Jones <ajones@ventanamicro.com> Acked-by:
Atish Patra <atishp@rivosinc.com> Tested-by:
Atish Patra <atishp@rivosinc.com>
-
Anup Patel authored
We update system drivers makefile to use kconfig for enabling/disabling drivers. To avoid compile errors, we also enable appropriate system drivers for each platform. Signed-off-by:
Anup Patel <apatel@ventanamicro.com> Tested-by:
Andrew Jones <ajones@ventanamicro.com> Acked-by:
Atish Patra <atishp@rivosinc.com> Tested-by:
Atish Patra <atishp@rivosinc.com>
-
Anup Patel authored
We update reset drivers makefile to use kconfig for enabling/disabling drivers. To avoid compile errors, we also enable appropriate reset drivers for each platform. Signed-off-by:
Anup Patel <apatel@ventanamicro.com> Tested-by:
Andrew Jones <ajones@ventanamicro.com> Acked-by:
Atish Patra <atishp@rivosinc.com> Tested-by:
Atish Patra <atishp@rivosinc.com>
-
Anup Patel authored
We update serial drivers makefile to use kconfig for enabling/disabling drivers. To avoid compile errors, we also enable appropriate serial drivers for each platform. Signed-off-by:
Anup Patel <apatel@ventanamicro.com> Tested-by:
Andrew Jones <ajones@ventanamicro.com> Acked-by:
Atish Patra <atishp@rivosinc.com> Tested-by:
Atish Patra <atishp@rivosinc.com>
-
Anup Patel authored
Currently, if same build directory is used to compile two different platforms then lib/utils objects are shared for these platforms. We will be having platform specific configs to enable/disable drivers in lib/utils and select compile time options for lib/utils sources. This means lib/utils sources will now be compiled in a platform specific way. To tackle above, we update top-level Makefile as follows: 1) Don't create libsbiutils.a anymore because this can't be shared between platforms. 2) Compile lib/utils sources separately for each platform. 3) Add comments showing which make rules are for lib/sbi, lib/utils, firmware, and platform sources. Signed-off-by:
Anup Patel <apatel@ventanamicro.com> Tested-by:
Andrew Jones <ajones@ventanamicro.com> Acked-by:
Atish Patra <atishp@rivosinc.com> Tested-by:
Atish Patra <atishp@rivosinc.com>
-
Anup Patel authored
We extend the top-level makefile to allow kconfig based configuration for each platform where each platform has it's own set of configs with "defconfig" being the default config. Signed-off-by:
Anup Patel <apatel@ventanamicro.com> Tested-by:
Andrew Jones <ajones@ventanamicro.com> Acked-by:
Atish Patra <atishp@rivosinc.com> Tested-by:
Atish Patra <atishp@rivosinc.com>
-
Anup Patel authored
We adopt Kconfiglib v14.1.0 sources under scripts directory so that top-level OpenSBI makefile can directly use Kconfiglib scripts without expecting users to install a particular version of Kconfiglib on their build system. Signed-off-by:
Anup Patel <apatel@ventanamicro.com> Tested-by:
Andrew Jones <ajones@ventanamicro.com> Acked-by:
Atish Patra <atishp@rivosinc.com> Tested-by:
Atish Patra <atishp@rivosinc.com>
-
- Jul 30, 2022
-
-
dramforever authored
Read long long arguments directly using va_arg. Remove original hack for RV32 that read a long long arg as two long args. This un-breaks the case on RV64 where e.g. the long long is followed by an odd number of ints: sbi_printf("%d %lld", (int) 1, (long long) 2LL); Also remove the acnt variable, which is now unused. Signed-off-by:dramforever <dramforever@live.com> Reviewed-by:
Andrew Jones <ajones@ventanamicro.com> Reviewed-by:
Anup Patel <anup@brainfault.org>
-
Andrew Jones authored
RISC-V doesn't generate exceptions on divide-by-zero, but the result, all bits set, is not likely what people expect either. In all cases where we divide by baudrate there's a chance it's zero (when the DT it came from is "bad"). To avoid difficult to debug situations, leave baudrate dependent registers alone when baudrate is zero, as, also in all cases, it appears we can skip initialization of those registers and still [hopefully] have a functioning UART. Signed-off-by:
Andrew Jones <ajones@ventanamicro.com> Reviewed-by:
Anup Patel <anup@brainfault.org>
-
Andrew Jones authored
Signed-off-by:
Andrew Jones <ajones@ventanamicro.com> Reviewed-by:
Xiang W <wxjstz@126.com> Reviewed-by:
Anup Patel <anup@brainfault.org>
-
Andrew Jones authored
While it doesn't look like there are any current cases of using uninitialized data, let's zero all the UART data members to be safe. Zero may not actually be better than a random number in some cases, so all structure members should still be validated before use, but at least zero is usually easier to debug than some random stack garbage... Signed-off-by:
Andrew Jones <ajones@ventanamicro.com> Reviewed-by:
Anup Patel <anup@brainfault.org>
-
Andrew Jones authored
Factor out the common code used by the fdt UART node parsers, allowing us to drop duplicate code. Signed-off-by:
Andrew Jones <ajones@ventanamicro.com> Reviewed-by:
Anup Patel <anup@brainfault.org>
-
Atish Patra authored
fw_event_map represents array of firmware events. It should initialized for maximum number of firmware events not counters. Reviewed-by:
Andrew Jones <ajones@ventanamicro.com> Signed-off-by:
Atish Patra <atishp@rivosinc.com> Reviewed-by:
Anup Patel <anup@brainfault.org>
-
Atish Patra authored
The active_events array is accessed with counter ID passed from the supervisor software before the counter ID bound check. This may cause a buffer overrun if a supervisor passes an invalid counter ID. Fix this by moving the access part after the bound check. Reported-by:
Andrew Jones <ajones@ventanamicro.com> Reviewed-by:
Andrew Jones <ajones@ventanamicro.com> Signed-off-by:
Atish Patra <atishp@rivosinc.com> Reviewed-by:
Anup Patel <anup@brainfault.org>
-
Atish Patra authored
Currently, there is no sanity check for firmware event code. We don't see any issue as Linux kernel driver does a bound check on firmware events already. However, OpenSBI can't assume sane supervisor mode software always. Thus, an invalid event idx can cause a buffer overflow error. For hardware events, the match will fail for invalid event code anyways. However, a search is unecessary if event code is invalid. Add a event ID validation function to solve the issue. Signed-off-by:
Atish Patra <atishp@rivosinc.com> Reviewed-by:
Andrew Jones <ajones@ventanamicro.com> Reviewed-by:
Anup Patel <anup@brainfault.org>
-