summaryrefslogtreecommitdiff
path: root/include
AgeCommit message (Collapse)Author
2023-01-24lib: utils: Add fdt_add_cpu_idle_states() helper functionSamuel Holland
Since the availability and latency properties of CPU idle states depend on the specific SBI HSM implementation, it is appropriate that the idle states are added to the devicetree at runtime by that implementation. This helper function adds a platform-provided array of idle states to the devicetree, following the SBI idle state binding. Reviewed-by: Anup Patel <[email protected]> Signed-off-by: Samuel Holland <[email protected]>
2023-01-23firmware: Add RW section offset in scratchHimanshu Chauhan
Add the RW section offset, provided by _fw_rw_offset symbol, to the scratch structure. This will be used to program separate pmp entry for RW section. Signed-off-by: Himanshu Chauhan <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2023-01-22lib: utils: atcsmu: Add Andes System Management Unit supportYu Chien Peter Lin
This patch adds atcsmu support for Andes AE350 platforms. The SMU provides system management capabilities, including clock, reset and power control based on power domain partitions. Signed-off-by: Yu Chien Peter Lin <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2023-01-22include: types: add always inline compiler attributeYu Chien Peter Lin
Provide __always_inline to sbi_types header. Signed-off-by: Yu Chien Peter Lin <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2023-01-22lib: sbi_hsm: handle failure when hart_stop returns SBI_ENOTSUPPYu Chien Peter Lin
Make use of generic warm-boot path when platform hart_stop callback returns SBI_ENOTSUPP, in case certain hart can not turn off its power domain, or it detects some error occured in power management unit, it can fall through warm-boot flow and wait for interrupt in sbi_hsm_hart_wait(). Also improves comment in sbi_hsm_hart_wait(). Signed-off-by: Yu Chien Peter Lin <[email protected]> Reviewed-by: Andrew Jones <[email protected]> Reviewed-by: Atish Patra <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2023-01-09lib: utils: Disallow non-root domains from adding M-mode regionsHimanshu Chauhan
The M-mode regions can only be added to the root domain. The non-root domains shouldn't be able to add them from FDT. Signed-off-by: Himanshu Chauhan <[email protected]> Reviewed-by: Anup Patel <[email protected]> Tested-by: Anup Patel <[email protected]>
2023-01-09include: sbi: Fine grain the permissions for M and SU modesHimanshu Chauhan
Split the permissions for M-mode and SU-mode. This would help if different sections of OpenSBI need to be given different permissions and if M-mode has different permisssions than the SU-mode over a region. Signed-off-by: Himanshu Chauhan <[email protected]> Reviewed-by: Anup Patel <[email protected]> Tested-by: Anup Patel <[email protected]>
2023-01-09lib: sbi_hsm: Rename 'priv' argument to 'arg1'Bin Meng
'priv' argument of sbi_hsm_hart_start() and sbi_hsm_hart_suspend() may mislead people to think it stands for 'privilege mode', but it is not. Change it to 'arg1' to clearly indicate the a1 register. Signed-off-by: Bin Meng <[email protected]> Reviewed-by: Samuel Holland <[email protected]> Tested-by: Samuel Holland <[email protected]> Reviewed-by: Atish Patra <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2023-01-07lib: sbi: Allow platform to influence cold boot HART selectionAnup Patel
We add an optional cold_boot_allowed() platform callback which allows platform support to decide which HARTs can do cold boot initialization. If this platform callback is not available then any HART can do cold boot initialization. Signed-off-by: Anup Patel <[email protected]>
2023-01-06treewide: Replace TRUE/FALSE with true/falseBin Meng
C language standard uses true/false for the boolean type. Let's switch to that for better language compatibility. Signed-off-by: Bin Meng <[email protected]> Reviewed-by: Anup Patel <[email protected]> Reviewed-by: Samuel Holland <[email protected]> Tested-by: Samuel Holland <[email protected]>
2022-12-24include: Bump-up version to 1.2v1.2Anup Patel
This patch updates OpenSBI version to 1.2 as part of release preparation. Signed-off-by: Anup Patel <[email protected]>
2022-12-17lib: utils/irqchip: plic: Ensure no out-of-bound access in context ↵Bin Meng
save/restore helpers Currently the context save/restore helpers writes/reads the provided array using an index whose maximum value is determined by PLIC, which potentially may disagree with the caller to these helpers. Add a parameter to ask the caller to provide the size limit of the array to ensure no out-of-bound access happens. Signed-off-by: Bin Meng <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2022-12-17lib: utils/irqchip: plic: Ensure no out-of-bound access in priority ↵Bin Meng
save/restore helpers Currently the priority save/restore helpers writes/reads the provided array using an index whose maximum value is determined by PLIC, which potentially may disagree with the caller to these helpers. Add a parameter to ask the caller to provide the size limit of the array to ensure no out-of-bound access happens. Signed-off-by: Bin Meng <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2022-12-12lib: utils: serial: Add FDT driver for Renesas SCIFLad Prabhakar
Add FDT driver for Renesas SCIF. dts example: soc: soc { .... scif0: serial@1004b800 { compatible = "renesas,scif-r9a07g043", "renesas,scif-r9a07g044"; reg = <0 0x1004b800 0 0x400>; interrupts = <412 IRQ_TYPE_LEVEL_HIGH>, <414 IRQ_TYPE_LEVEL_HIGH>, <415 IRQ_TYPE_LEVEL_HIGH>, <413 IRQ_TYPE_LEVEL_HIGH>, <416 IRQ_TYPE_LEVEL_HIGH>, <416 IRQ_TYPE_LEVEL_HIGH>; interrupt-names = "eri", "rxi", "txi", "bri", "dri", "tei"; clocks = <&cpg CPG_MOD R9A07G043_SCIF0_CLK_PCK>; clock-names = "fck"; power-domains = <&cpg>; resets = <&cpg R9A07G043_SCIF0_RST_SYSTEM_N>; status = "disabled"; }; .... }; Signed-off-by: Lad Prabhakar <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2022-12-12lib: utils: serial: Add Renesas SCIF driverLad Prabhakar
Add Renesas SCIF driver. Based on a patch in the BSP by Takeki Hamada <[email protected]> Link: https://github.com/renesas-rz/rz_opensbi/commits/work/OpenSBI-PMA Signed-off-by: Lad Prabhakar <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2022-10-23lib: sbi_ecall: Generate extensions list with carrayVivian Wang
Instead of hard-coding the list of extensions in C code, use carray to generate the list of extensions. Using carray makes adding and removing extensions slightly cleaner. This also paves the way for using Kconfig to disable unneeded extensions. Signed-off-by: Vivian Wang <[email protected]> Reviewed-by: Andrew Jones <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2022-10-23lib: utils/ipi: Add Andes fdt ipi driver supportYu Chien Peter Lin
Move Andes PLICSW ipi device to fdt ipi framework, this patch is based on Leo's modified IPI scheme on PLICSW. Current IPI scheme uses bit 0 of pending reigster on PLICSW to send IPI from hart 0 to hart 7, but bit 0 needs to be hardwired to 0 according to spec. After some investigation, self-IPI seems to be seldom or never used, so we re-order the IPI scheme to support 8 core platforms. dts example (Quad-core AX45MP): plicsw: interrupt-controller@e6400000 { compatible = "andestech,plicsw"; reg = <0x00000000 0xe6400000 0x00000000 0x00400000>; interrupts-extended = <&CPU0_intc 3 &CPU1_intc 3 &CPU2_intc 3 &CPU3_intc 3>; interrupt-controller; #address-cells = <2>; #interrupt-cells = <2>; }; Signed-off-by: Yu Chien Peter Lin <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2022-10-23lib: utils/timer: Add Andes fdt timer supportYu Chien Peter Lin
Since we can get the PLMT base address and timer frequency from device tree, move plmt timer device to fdt timer framework. dts example (Quad-core AX45MP): cpus { ... timebase-frequency = <0x3938700>; ... } soc { ... plmt0@e6000000 { compatible = "andestech,plmt0"; reg = <0x00 0xe6000000 0x00 0x100000>; interrupts-extended = <&cpu0_intc 0x07 &cpu1_intc 0x07 &cpu2_intc 0x07 &cpu3_intc 0x07>; }; ... } Signed-off-by: Yu Chien Peter Lin <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2022-10-23lib: sbi: Add sbi_domain_root_add_memrange() APIYu Chien Peter Lin
This patch generalizes the logic to add a memory range with desired alignment and flags of consecutive regions to the root domain. Signed-off-by: Yu Chien Peter Lin <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2022-10-23include: sbi: Fix grammar in commentYu Chien Peter Lin
Fix minor grammar issue in function description. Signed-off-by: Yu Chien Peter Lin <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2022-10-23include: sbi: Fix typo in commentYu Chien Peter Lin
%s/Priviledge/Privilege Signed-off-by: Yu Chien Peter Lin <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2022-10-13lib: sbi_platform: expose hart_features to extension_init callbackHeiko Stuebner
The platform-specific extension_init callback is supposed to set specific things for the platform opensbi is running on. So it's also the right place to override specific hart_features if needed - when it's know that autodetection has provided wrong results for example. Suggested-by: Atish Patra <[email protected]> Reviewed-by: Andrew Jones <[email protected]> Reviewed-by: Guo Ren <[email protected]> Reviewed-by: Anup Patel <[email protected]> Signed-off-by: Heiko Stuebner <[email protected]>
2022-10-13lib: sbi_hart: move hart_features struct to a public locationHeiko Stuebner
Platforms may need to override auto-detected hart features in their override functions. So move the hart_features struct to the sbi_hart.h header allowing us to pass it over to platform-handlers. Suggested-by: Atish Patra <[email protected]> Reviewed-by: Andrew Jones <[email protected]> Reviewed-by: Guo Ren <[email protected]> Reviewed-by: Anup Patel <[email protected]> Signed-off-by: Heiko Stuebner <[email protected]>
2022-10-13lib: sbi_pmu: move pmu irq information into pmu itselfHeiko Stuebner
Don't spread checking for pmu extensions through the code but instead introduce a sbi-pmu function that other code can call to get the correct information about the existence of the pmu interrupt. Add a sbi_pmu_device override function to allow overridung this bit as well if needed. Reviewed-by: Atish Patra <[email protected]> Reviewed-by: Andrew Jones <[email protected]> Reviewed-by: Guo Ren <[email protected]> Reviewed-by: Anup Patel <[email protected]> Signed-off-by: Heiko Stuebner <[email protected]>
2022-09-13lib: utils/serial: add semihosting supportKautuk Consul
We add RISC-V semihosting based serial console for JTAG based early debugging. The RISC-V semihosting specification is available at: https://github.com/riscv/riscv-semihosting-spec/blob/main/riscv-semihosting-spec.adoc Signed-off-by: Anup Patel <[email protected]> Signed-off-by: Kautuk Consul <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2022-09-13lib: sbi_trap: Add helper to get GVA in sbi_trap_regsVivian Wang
The GVA bit is in mstatus on RV64, and in mstatush in RV32. Refactor code handling this in sbi_trap_handler into a helper function to extract GVA from sbi_trap_regs, so that future code accessing GVA can be XLEN-agnostic. Signed-off-by: Vivian Wang <[email protected]> Reviewed-by: Andrew Jones <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2022-09-01include: sbi: Reduce includes in sbi_pmu.hAnup Patel
The sbi_pmu.h should only include minimal required headers whereas sbi_pmu.c should include all required headers. Signed-off-by: Anup Patel <[email protected]> Reviewed-by: Andrew Jones <[email protected]> Reviewed-by: Atish Patra <[email protected]>
2022-09-01lib: sbi_pmu: Add custom PMU device operationsAnup Patel
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 <[email protected]> Reviewed-by: Andrew Jones <[email protected]> Reviewed-by: Atish Patra <[email protected]>
2022-09-01lib: sbi_pmu: Simplify FW counters to reduce memory usageAnup Patel
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 <[email protected]> Reviewed-by: Andrew Jones <[email protected]> Reviewed-by: Atish Patra <[email protected]>
2022-09-01lib: sbi_pmu: Replace sbi_pmu_ctr_read() with sbi_pmu_ctr_fw_read()Anup Patel
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 <[email protected]> Reviewed-by: Andrew Jones <[email protected]> Reviewed-by: Atish Patra <[email protected]>
2022-09-01include: Remove sideleg and sedelegRahul Pathak
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 <[email protected]> Reviewed-by: Andrew Jones <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2022-08-23lib: utils: serial: Add Cadence UART driverJun Liang Tan
Add Cadence UART driver Signed-off-by: Jun Liang Tan <[email protected]> Signed-off-by: Wei Liang Lim <[email protected]> Reviewed-by: Andrew Jones <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2022-08-22lib: sbi: Use the official extension name for AIA M-mode CSRsAnup Patel
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 <[email protected]> Reviewed-by: Andrew Jones <[email protected]> Reviewed-by: Atish Patra <[email protected]>
2022-08-22lib: sbi_trap: Save mstatus[h].GVA in trap->gvaVivian Wang
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 <[email protected]> Reviewed-by: Andrew Jones <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2022-08-22include: Add mstatus[h].GVA encodingsVivian Wang
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 <[email protected]> Reviewed-by: Andrew Jones <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2022-08-08lib: utils/fdt: Use kconfig for enabling/disablingAnup Patel
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 <[email protected]> Tested-by: Andrew Jones <[email protected]> Acked-by: Atish Patra <[email protected]> Tested-by: Atish Patra <[email protected]>
2022-08-08lib: utils/irqchip: Use kconfig for enabling/disabling driversAnup Patel
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 <[email protected]> Tested-by: Andrew Jones <[email protected]> Acked-by: Atish Patra <[email protected]> Tested-by: Atish Patra <[email protected]>
2022-08-08lib: utils/ipi: Use kconfig for enabling/disabling driversAnup Patel
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 <[email protected]> Tested-by: Andrew Jones <[email protected]> Acked-by: Atish Patra <[email protected]> Tested-by: Atish Patra <[email protected]>
2022-08-08lib: utils/timer: Use kconfig for enabling/disabling driversAnup Patel
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 <[email protected]> Tested-by: Andrew Jones <[email protected]> Acked-by: Atish Patra <[email protected]> Tested-by: Atish Patra <[email protected]>
2022-08-08lib: utils/reset: Use kconfig for enabling/disabling driversAnup Patel
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 <[email protected]> Tested-by: Andrew Jones <[email protected]> Acked-by: Atish Patra <[email protected]> Tested-by: Atish Patra <[email protected]>
2022-08-08lib: utils/serial: Use kconfig for enabling/disabling driversAnup Patel
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 <[email protected]> Tested-by: Andrew Jones <[email protected]> Acked-by: Atish Patra <[email protected]> Tested-by: Atish Patra <[email protected]>
2022-07-30lib: sbi: Add the bound check for events during config matchAtish Patra
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 <[email protected]> Reviewed-by: Andrew Jones <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2022-07-11lib: sbi: add check for ipi device for hsm startBen Dooks
If the ecall SBI_EXT_HSM_HART_START is called it might try to wake the secondary hart using sbi_ipi_raw_send() to send an IPI to the hart. This can fail if there is no IPI device but no error is returned from sbi_ipi_raw_send() so the ecall returns as if the action completed and the caller continues without noticing (in the case of Linux it just hangs waiting for the secondary hart to become active) Fix this by changing sbi_ipi_raw_send() to return and error, and if an error is returned, then return it via SBI_EXT_HSM_HART_START call. Signed-off-by: Ben Dooks <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2022-07-08lib: sbi_timer: Added a conditional wait function which can timeoutAdnan Rahman Chowdhury
Motivation: Suppose a peripheral needs to be configured to transmit data. There is an SFR bit which indicates that the peripheral is ready to transmit. The firmware should check the bit and will only transmit data when the peripheral is ready. When the firmware starts polling the SFR, the peripheral could be busy transmitting/receiving other data so the firmware must wait till that completes. Assuming that there is no other way, the firmware shouldn't wait indefinitely. The function sbi_timer_waitms_until() will constantly check whether a certain condition is satisfied, or timeout occurs. It can be used for the cases when a timeout is required. Signed-off-by: Adnan Rahman Chowdhury <[email protected]> Reviewed-by: Xiang W <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2022-06-25include: Bump-up version to 1.1v1.1Anup Patel
This patch updates OpenSBI version to 1.1 as part of release preparation. Signed-off-by: Anup Patel <[email protected]>
2022-06-24include: sbi: Change spec version to 1.0Anup Patel
Now that SBI v1.0 specification is ratified, we change spec verion implemented by OpenSBI to v1.0. Signed-off-by: Anup Patel <[email protected]> Reviewed-by: Atish Patra <[email protected]>
2022-06-21lib: utils: Remove CSRs that set/clear an IMSIC interrupt file bitsAnup Patel
Based on architecture review committee feedback, the [m|s|vs]seteienum, [m|s|vs]clreienum, [m|s|vs]seteipnum, and [m|s|vs]clreipnum CSRs are removed in the latest AIA draft v0.3.0 specification. (Refer, https://github.com/riscv/riscv-aia/releases/tag/0.3.0-draft.31) These CSRs were mostly for software convenience and software can always use [m|s|vs]iselect and [m|s|vs]ireg CSRs to update the IMSIC interrupt file bits. We update the IMSIC programming as-per above to match the latest AIA draft specification. Signed-off-by: Anup Patel <[email protected]> Reviewed-by: Atish Patra <[email protected]>
2022-06-21include: sbi: Add mtinst/htinst psuedoinstructionsdramforever
Add psuedoinstruction encodings written to mtinst/htinst for faults caused by implicit memory access for VS-stage address translation Signed-off-by: dramforever <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2022-06-13lib: utils/irqchip: Add wrapper for T-HEAD PLIC delegationSamuel Holland
The delegation bit is lost along with the rest of the PLIC state when the CPU power domain in the Allwinner D1 is powered down, so the PLIC needs to be re-delegated to S-mode during the hart resume path. Reviewed-by: Anup Patel <[email protected]> Signed-off-by: Samuel Holland <[email protected]>
2022-06-13lib: utils/irqchip: Add FDT wrappers for PLIC save/restore functionsSamuel Holland
These functions save/restore the state of the PLIC associated with the current hart. The context save/restore functions only manipulate a single context, since most likely the M-mode context is unused and does not need to be saved. Signed-off-by: Samuel Holland <[email protected]> Reviewed-by: Anup Patel <[email protected]>