summaryrefslogtreecommitdiff
path: root/lib
AgeCommit message (Collapse)Author
2023-01-23lib: sbi: Add separate entries for firmware RX and RW regionsHimanshu Chauhan
Add two entries for firmware in the root domain: 1. TEXT: fw_start to _fw_rw_offset with RX permissions 2. DATA: _fw_rw_offset to fw_size with RW permissions These permissions are still not enforced from M-mode but lay the ground work for enforcing them for M-mode. SU-mode don't have any access to these regions. Sample output: Domain0 Region01 : 0x0000000080000000-0x000000008001ffff M: (R,X) S/U: () Domain0 Region02 : 0x0000000080020000-0x000000008003ffff M: (R,W) S/U: () Signed-off-by: Himanshu Chauhan <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2023-01-23lib: sbi: Print the RW section offsetHimanshu Chauhan
Print the RW section offset when firmware base and size is being printed. Signed-off-by: Himanshu Chauhan <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2023-01-22lib: utils: Fix reserved memory node for firmware memoryMayuresh Chitale
The commit 9e0ba090 introduced more fine grained permissions for memory regions and did not update the fdt_reserved_memory_fixup() function. As a result, the fdt_reserved_memory_fixup continued to use the older coarse permissions which causes the reserved memory node to be not inserted into the DT. To fix the above issue, we correct the flags used for memory region permission checks in the fdt_reserved_memory_fixup() function. Fixes: 9e0ba090 ("include: sbi: Fine grain the permissions for M and SU modes") Signed-off-by: Mayuresh Chitale <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2023-01-22lib: reset/fdt_reset_atcwdt200: Use defined macros and function in atcsmu.hYu Chien Peter Lin
Reuse the smu related macros and function in atcsmu.h. Signed-off-by: Yu Chien Peter Lin <[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-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: Add M-mode {R/W} flags to the MMIO regionsHimanshu Chauhan
Add the M-mode readable/writable flags to mmio regions of various drivers. Signed-off-by: Himanshu Chauhan <[email protected]> Reviewed-by: Anup Patel <[email protected]> Tested-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-09lib: utils: Use SU-{R/W/X} flags for region permissions during parsingHimanshu Chauhan
Use the newer SU-{R/W/X} flags for checking and assigning region permissions. Signed-off-by: Himanshu Chauhan <[email protected]> Reviewed-by: Anup Patel <[email protected]> Tested-by: Anup Patel <[email protected]>
2023-01-09lib: sbi: Modify the boot time region flag printsHimanshu Chauhan
With the finer permission semantics, the region access permissions must be displayed separately for M and SU mode. Signed-off-by: Himanshu Chauhan <[email protected]> Reviewed-by: Anup Patel <[email protected]> Tested-by: Anup Patel <[email protected]>
2023-01-09lib: sbi: Use finer permission sematics to decide on PMP bitsHimanshu Chauhan
Use the fine grained permission bits to decide if the region permissions are to be enforced on all modes. Also use the new permission bits for deciding on R/W/X bits in pmpcfg register. Signed-off-by: Himanshu Chauhan <[email protected]> Reviewed-by: Anup Patel <[email protected]> Tested-by: Anup Patel <[email protected]>
2023-01-09lib: sbi: Add permissions for the firmware start till endHimanshu Chauhan
Change the zero flag to M-mode R/W/X flag for the firmware region. Signed-off-by: Himanshu Chauhan <[email protected]> Reviewed-by: Anup Patel <[email protected]> Tested-by: Anup Patel <[email protected]>
2023-01-09lib: sbi: Use finer permission semantics for address validationHimanshu Chauhan
Use the fine grained permisssion semantics for address validation of a given 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-06lib: utils/sys: Allow custom HTIF base address for RV32Bin Meng
commit 6dde43584f18 ("lib: utils/sys: Extend HTIF library to allow custom base address") forgot to update do_tohost_fromhost() codes for RV32, which still accesses the HTIF registers using the ELF symbol address directly. Fixes: 6dde43584f18 ("lib: utils/sys: Extend HTIF library to allow custom base address") Signed-off-by: Bin Meng <[email protected]> Tested-by: Daniel Henrique Barboza <[email protected]> Reviewed-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-17lib: utils/timer: mtimer: add T-Head C9xx CLINT compatibleIcenowy Zheng
As we already added the quirk for lacking mtime register to MTIMER driver, add T-Head C9xx CLINT compatible to it and wire the quirk. Signed-off-by: Icenowy Zheng <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2022-12-17lib: utils/timer: mtimer: add a quirk for lacking mtime registerIcenowy Zheng
T-Head developers surely have a different understanding of time CSR and CLINT's mtime register with SiFive ones, that they did not implement the mtime register at all -- as shown in openC906 source code, their time CSR value is just exposed at the top of their processor IP block and expects an external continous counter, which makes it not overrideable, and thus mtime register is not implemented, even not for reading. However, if CLINTEE is not enabled in T-Head's MXSTATUS extended CSR, these systems still rely on the mtimecmp registers to generate timer interrupts. This makes it necessary to implement T-Head C9xx CLINT support in OpenSBI MTIMER driver, which skips implementing reading mtime register and falls back to default code that reads time CSR. Add a quirk into MTIMER driver, which represents a mtime register is lacking and time CSR value should be used instead. Signed-off-by: Icenowy Zheng <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2022-12-17lib: utils/ipi: mswi: add T-Head C9xx CLINT compatibleIcenowy Zheng
Althoug the MTIMER part of a C9xx CLINT differs from a SiFive one, the MSWI part is compliant. Add T-Head C9xx CLINT compatible string to fdt_ipi_mswi code, sharing the same codepath with SiFive CLINT. Signed-off-by: Icenowy Zheng <[email protected]> Reviewed-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: Fix the off-by-one error in context save/restore ↵Bin Meng
helpers plic->num_src holds the number of interrupt sources without interrupt source 0 but the interrupt enable register includes a bit for the interrupt source 0 in the first word. Fixes: 415ecf28f7ad ("lib: irqchip/plic: Add context save/restore helpers") Signed-off-by: Bin Meng <[email protected]> Reviewed-by: Anup Patel <[email protected]> Reviewed-by: Samuel Holland <[email protected]>
2022-12-17lib: utils/irqchip: plic: Fix the off-by-one error in plic_context_init()Bin Meng
The number of interrupt enable register in words was once correct, but was wrongly changed to have an off-by-one error since commit 8c362e7d065e ("lib: irqchip/plic: Factor out a context init function"). Fixes: 8c362e7d065e ("lib: irqchip/plic: Factor out a context init function") Signed-off-by: Bin Meng <[email protected]> Reviewed-by: Anup Patel <[email protected]> Reviewed-by: Samuel Holland <[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-17lib: utils/irqchip: plic: Fix the off-by-one error in priority save/restore ↵Bin Meng
helpers Interrupt source 0 is reserved. Hence the irq should start from 1. Fixes: 2b79b694a805 ("lib: irqchip/plic: Add priority save/restore helpers") Signed-off-by: Bin Meng <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2022-12-12lib: utils/irqchip: Add compatible string for Andestech NCEPLIC100Lad Prabhakar
Add compatible string for Andestech NCEPLIC100 found on Renesas RZ/Five SoC which is equipped with AX45MP AndesCore. While at it drop the comma after the sentinel as it does not make sense to have a comma after a sentinel, as any new elements must be added before the sentinel. dts example (Single-core AX45MP): soc: soc { .... plic: interrupt-controller@12c00000 { compatible = "renesas,r9a07g043-plic", "andestech,nceplic100"; #interrupt-cells = <2>; #address-cells = <0>; riscv,ndev = <511>; interrupt-controller; reg = <0x0 0x12c00000 0 0x400000>; clocks = <&cpg CPG_MOD R9A07G043_NCEPLIC_ACLK>; power-domains = <&cpg>; resets = <&cpg R9A07G043_NCEPLIC_ARESETN>; interrupts-extended = <&cpu0_intc 11 &cpu0_intc 9>; }; .... }; Signed-off-by: Lad Prabhakar <[email protected]> Reviewed-by: Anup Patel <[email protected]> Reviewed-by: Bin Meng <[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-12-09lib: sbi: Synchronize PMP settings with virtual memory systemHimanshu Chauhan
As per section 3.7.2 of RISC-V Privileged Specification, PMP settings must be synchronized with the virtual memory system after PMP settings have been written. Signed-off-by: Himanshu Chauhan <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2022-12-09lib: fix irqchip_plic_update_hartid_tableHeinrich Schuchardt
After determining cpu_offset we have to check this value. Addresses-Coverity-ID: 1529706 ("Logically dead code") Signed-off-by: Heinrich Schuchardt <[email protected]> Reviewed-by: Xiang W <[email protected]> Reviewed-by: Atish Patra <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2022-12-09lib: fix __fdt_parse_region()Heinrich Schuchardt
If fdt_getprop() returns NULL, this indicates an error. In this case lenp is set to an error code. But even if lenp = 0 we should not continue. If fdt_getprop() returns a wider value than we expect this is a separate error condition. In both cases the device-tree is invalid. Addresses-Coverity-ID: 1529703 ("Dereference after null check") Signed-off-by: Heinrich Schuchardt <[email protected]> Reviewed-by: Xiang W <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2022-12-09lib: fix is_region_valid()Heinrich Schuchardt
For 'reg->order == __riscv_xlen' the term 'BIT(reg->order)' is undefined. Addresses-Coverity-ID: 1529706 ("Bad bit shift operation") Signed-off-by: Heinrich Schuchardt <[email protected]> Reviewed-by: Xiang W <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2022-12-05lib: utils: Add fdt_fixup_node() helper functionLad Prabhakar
Add a helper function fdt_fixup_node() based on the compatible string. This will avoid code duplication for every new node fixup being added. Signed-off-by: Lad Prabhakar <[email protected]> Reviewed-by: Bin Meng <[email protected]> Reviewed-by: Xiang W <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2022-12-05lib: fix fdt_parse_aclint_node()Heinrich Schuchardt
After determining cpu_offset we have to check this variable and not cpu_intc_offset. Signed-off-by: Heinrich Schuchardt <[email protected]> Reviewed-by: Xiang W <[email protected]> Reviewed-by: Bin Meng <[email protected]>
2022-12-05lib: simplify fdt_translate_address()Heinrich Schuchardt
Don't assign a value to offset which is never used. Signed-off-by: Heinrich Schuchardt <[email protected]> Reviewed-by: Xiang W <[email protected]> Reviewed-by: Bin Meng <[email protected]>
2022-12-05lib: fix fdt_parse_plicsw_node()Heinrich Schuchardt
cpu_offset and cpu_intc_offset must be int to detect failed invocations of fdt_node_offset_by_phandle() or fdt_parent_offset(). After determining cpu_offset we have to check this value and not cpu_intc_offset. Signed-off-by: Heinrich Schuchardt <[email protected]> Reviewed-by: Xiang W <[email protected]> Reviewed-by: Yu Chien Peter Lin <[email protected]> Reviewed-by: Bin Meng <[email protected]>
2022-12-05lib: fix fdt_parse_plmt_node()Heinrich Schuchardt
cpu_offset, cpu_intc_offset must be int to discover failed invocations of fdt_node_offset_by_phandle() or fdt_parent_offset(). After determining cpu_offset we have to check this value and not cpu_intc_offset. Signed-off-by: Heinrich Schuchardt <[email protected]> Reviewed-by: Xiang W <[email protected]> Reviewed-by: Yu Chien Peter Lin <[email protected]> Reviewed-by: Bin Meng <[email protected]>
2022-12-05lib: simplify fdt_parse_plicsw_node()Heinrich Schuchardt
We should not check !plicsw_base || !size twice. Signed-off-by: Heinrich Schuchardt <[email protected]> Reviewed-by: Xiang W <[email protected]> Reviewed-by: Yu Chien Peter Lin <[email protected]> Reviewed-by: Bin Meng <[email protected]>
2022-12-05lib: simplify fdt_parse_plmt_node()Heinrich Schuchardt
We should not check !plmt_base || !plmt_size twice. Signed-off-by: Heinrich Schuchardt <[email protected]> Reviewed-by: Xiang W <[email protected]> Reviewed-by: Yu Chien Peter Lin <[email protected]> Reviewed-by: Bin Meng <[email protected]>
2022-12-04lib: sbi: Fix is_region_valid()Xiang W
When order is equal to __riscv_xlen, the shift operation will not perform any operation, which will cause reg->base & (BIT(reg->order) - 1) to always be 0, and the condition has not been established. This patch fixes this bug. Signed-off-by: Xiang W <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2022-12-04lib: sbi: Simplified mmio match checkingXiang W
We simplify the mmio flag matching in sbi_domain_check_addr(). Signed-off-by: Xiang W <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2022-11-15lib: sbi_ecall: Split up sbi_ecall_replaceVivian Wang
Split up sbi_ecall_replace so that each extension is in its individual file. Also reorganize the corresponding section in lib/sbi/objects.mk so that it is grouped by extension, now that the object file targets are split up. Signed-off-by: Vivian Wang <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2022-11-15lib: utils/serial: Fix semihosting compile error using LLVMAnup Patel
We fix the following semihosting compile error observed using LLVM: lib/utils/serial/semihosting.c:158:12: error: result of comparison of constant -1 with expression of type 'char' is always true [-Werror,-Wtautological-constant-out-of-range-compare] ret = ch > -1 ? ch : -1; ~~ ^ ~~ Fixes: 7f09fba86e43 ("lib: utils/serial: add semihosting support") Signed-off-by: Anup Patel <[email protected]> Reviewed-by: Xiang W <[email protected]> Reviewed-by: Bin Meng <[email protected]>
2022-11-14lib: utils/fdt: Simplified codeXiang W
Simplified fdt_parse_xxx_uart_node which direct call fdt_parse_uart_node_common. Signed-off-by: Xiang W <[email protected]> Reviewed-by: Atish Patra <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2022-11-14lib: utils/fdt: Remove redundant codeXiang W
uart->reg_offset and uart->reg_io_width are only used on uart8250 and not required on other platforms. Remove for sifive and gaisler. Signed-off-by: Xiang W <[email protected]> Reviewed-by: Atish Patra <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2022-10-23lib: sbi_ecall: Add Kconfig option for each extensionVivian Wang
For each SBI extension, we: - Add a Kconfig option for it - Add the extension to sbi_ecall_exts only if the extension is enabled - Add the corresponding sbi_ecall_* object file only if the extension is enabled Special cases are as follows: - The legacy extensions are lumped together as one 'big' extension, as has always been the case in OpenSBI code. - The platform-defined vendor extensions are regarded as one extension. - The Base extension cannot be disabled. - sbi_ecall_replace implements multiple extensions, so it's not easy to avoid linking it in. Enable it always, and use #ifdef to disable/enable individual extensions. Signed-off-by: Vivian Wang <[email protected]> Reviewed-by: Andrew Jones <[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/reset: Add Andes fdt reset driver supportYu Chien Peter Lin
Add ATCWDT200 as reset device of AE350 platform, this driver requires SMU to program the reset vector registers before triggering WDT software restart signal. dts example: smu@f0100000 { compatible = "andestech,atcsmu"; reg = <0x00000000 0xf0100000 0x00000000 0x00001000>; }; wdt: wdt@f0500000 { compatible = "andestech,atcwdt200"; reg = <0x00000000 0xf0500000 0x00000000 0x00001000>; interrupts = <3 4>; interrupt-parent = <&plic0>; clock-frequency = <15000000>; }; Signed-off-by: Yu Chien Peter Lin <[email protected]> Reviewed-by: Leo Yu-Chi Liang <[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]>