- Mar 19, 2024
-
-
Anup Patel authored
The irqchip handlers will typically not need pointer to trap registers so remove regs parameter of sbi_irqchip_process(). Signed-off-by:
Anup Patel <apatel@ventanamicro.com> Reviewed-by:
Samuel Holland <samuel.holland@sifive.com> Tested-by:
Samuel Holland <samuel.holland@sifive.com> Reviewed-by:
Clément Léger <cleger@rivosinc.com>
-
Anup Patel authored
The struct sbi_trap_context already has the information needed by sbi_illegal_insn_handler() so directly pass struct sbi_trap_context pointer to this function. Signed-off-by:
Anup Patel <apatel@ventanamicro.com> Reviewed-by:
Samuel Holland <samuel.holland@sifive.com> Tested-by:
Samuel Holland <samuel.holland@sifive.com>
-
Anup Patel authored
The struct sbi_trap_context already has the information needed by misaligned load/store and access fault load/store handlers so directly pass struct sbi_trap_context pointer to these functions. Signed-off-by:
Anup Patel <apatel@ventanamicro.com> Reviewed-by:
Samuel Holland <samuel.holland@sifive.com> Tested-by:
Samuel Holland <samuel.holland@sifive.com> Reviewed-by:
Clément Léger <cleger@rivosinc.com>
-
Anup Patel authored
Club the struct sbi_trap_regs and struct sbi_trap_info a new struct sbi_trap_context (aka trap context) which must be saved by low-level trap handler before calling sbi_trap_handler(). To track nested traps, the struct sbi_scratch points to the current trap context and the trap context has pointer to pervious context of previous trap. Signed-off-by:
Anup Patel <apatel@ventanamicro.com> Reviewed-by:
Samuel Holland <samuel.holland@sifive.com> Tested-by:
Samuel Holland <samuel.holland@sifive.com>
-
Anup Patel authored
To track nested traps, the struct sbi_scratch needs a pointer the current trap context so add trap_context pointer in struct sbi_context. Signed-off-by:
Anup Patel <apatel@ventanamicro.com> Reviewed-by:
Samuel Holland <samuel.holland@sifive.com> Tested-by:
Samuel Holland <samuel.holland@sifive.com>
-
Anup Patel authored
Over the years, no uses of sbi_trap_exit() have been found so remove it and also remove related code from fw_base.S and sbi_scratch.h. Signed-off-by:
Anup Patel <apatel@ventanamicro.com> Reviewed-by:
Samuel Holland <samuel.holland@sifive.com> Tested-by:
Samuel Holland <samuel.holland@sifive.com>
-
Samuel Holland authored
In the only places this value is used, it duplicates mepc from struct sbi_trap_regs. Signed-off-by:
Samuel Holland <samuel.holland@sifive.com> Reviewed-by:
Anup Patel <anup@brainfault.org>
-
Ivan Orlov authored
Since the tests should be moved to the lib/sbi/tests directory, the documentation should be updated correspondingly. So, update the paths where they have to be changed. Signed-off-by:
Ivan Orlov <ivan.orlov0322@gmail.com> Reviewed-by:
Anup Patel <anup@brainfault.org>
-
Ivan Orlov authored
Move all of the SBIUnit-related code into the lib/sbi/tests directory. Update 'Makefile' to index objects from the tests subdirectory. I don't think creating the full separate list of Makefile variables (libsbitests-objs-path-y, libsbitests-object-mks, etc. as it is done for libsbiutils) is necessary for the tests because: 1) `lib/sbi/tests/objects.mk` is already indexed into 'libsbi-objects-mks' since the find expression for the libsbi-object-mks variable looks for objects.mk files in the nested directories as well). 2) Tests are tightly coupled with the `lib/sbi/` sources, therefore it may be reasonable to store the list of lib/sbi and lib/sbi/tests object files together in the libsbi-objs-path-y variable. Additionally, update relative paths in the tests where necessary. Signed-off-by:
Ivan Orlov <ivan.orlov0322@gmail.com> Reviewed-by:
Anup Patel <anup@brainfault.org>
-
- Mar 11, 2024
-
-
Bo Gan authored
sbi_load/store_access_handler now tries to call platform emulators if defined. Otherwise, redirects the fault. If the platform code returns failure, this means the H/S/U has accessed the emulated devices in an unexpected manner, which is very likely caused by buggy code in H/S/U. We redirect the fault, so lower privileged level can get notified, and act accordingly. (E.g., oops in Linux) We let the handler truly fail if the trap was originated from M mode. In this case, something must be very wrong and we should just fail. Signed-off-by:
Bo Gan <ganboing@gmail.com> Reviewed-by:
Anup Patel <anup@brainfault.org>
-
Bo Gan authored
This patch allows the platform to define load/store emulators. This enables a platform to trap-and-emulate special devices or filter access to existing physical devices. Signed-off-by:
Bo Gan <ganboing@gmail.com> Reviewed-by:
Anup Patel <anup@brainfault.org>
-
Bo Gan authored
This patch abstracts out the instruction decoding part of misaligned ld/st fault handlers, so it can be reused by ld/st access fault handlers. Also Added lb/lbu/sb decoding. (previously unreachable by misaligned fault) sbi_trap_emulate_load/store is now the common handler which takes a `emu` parameter that is responsible for emulating the misaligned or access fault. The `emu` callback is expected to fixup the fault, and based on the return code of `emu`, sbi_trap_emulate_load/store will: r/wlen => the fixup is successful and regs/mepc needs to be updated. 0 => the fixup is successful, but regs/mepc should be left untouched (this is usually used if `emu` does `sbi_trap_redirect`) -err => failed, sbi_trap_error will be called For now, load/store access faults are blindly redirected. It will be enhanced in the following patches. Signed-off-by:Bo Gan <ganboing@gmail.com> Reviewed-by:
Anup Patel <anup@brainfault.org>
-
Bo Gan authored
This simplifies both handlers such that when the handler needs to redirect the original trap, it's readily available. Signed-off-by:
Bo Gan <ganboing@gmail.com> Reviewed-by:
Anup Patel <anup@brainfault.org>
-
Bo Gan authored
sbi_trap_redirect now uses const pointer to `trap`. This ensures the caller that we never change `trap` in sbi_trap_redirect. Signed-off-by:
Bo Gan <ganboing@gmail.com> Reviewed-by:
Anup Patel <anup@brainfault.org>
-
Bo Gan authored
Signed-off-by:
Bo Gan <ganboing@gmail.com> Reviewed-by:
Anup Patel <anup@brainfault.org>
-
Bo Gan authored
Signed-off-by:
Bo Gan <ganboing@gmail.com> Reviewed-by:
Anup Patel <anup@brainfault.org>
-
- Mar 10, 2024
-
-
Qingyu Shang authored
The domain context management component in OpenSBI provides basic CPU context management routines for existing OpenSBI domain. As domain extension, it was initially designed to facilitate the suspension and resumption of domains, enabling secure domains to efficiently share CPU resources. The patch also provides an addition to the OpenSBI domain to provide updates on hart-domain assignment and declarations of contexts within the domain. Signed-off-by:
Qingyu Shang <2931013282@sjtu.edu.cn> Reviewed-by:
Yu Chien Peter Lin <peterlin@andestech.com> Tested-by:
Yu Chien Peter Lin <peterlin@andestech.com> Reviewed-by:
Anup Patel <anup@brainfault.org>
-
Ivan Orlov authored
Add the test suite covering some of the functions from lib/sbi/sbi_console.c: putc, puts and printf. The test covers a variety of format specifiers for printf and different strings and characters for putc and puts. In order to do that, the test "mocks" the sbi_console_device structure by setting the 'console_dev' variable to the virtual console. Signed-off-by:
Ivan Orlov <ivan.orlov0322@gmail.com> Reviewed-by:
Andrew Jones <ajones@ventanamicro.com>
-
Ivan Orlov authored
Add test suite covering all of the functions from lib/sbi/sbi_bitmap.c: __bitmap_and, __bitmap_or and __bitmap_xor. Signed-off-by:
Ivan Orlov <ivan.orlov0322@gmail.com> Reviewed-by:
Andrew Jones <ajones@ventanamicro.com>
-
Ivan Orlov authored
This patch introduces all of the SBIUnit macros and functions which can be used during the test development process. Also, it defines the 'run_all_tests' function, which is being called during the 'init_coldboot' right after printing the boot hart information. Also, add the CONFIG_SBIUNIT Kconfig entry in order to be able to turn the tests on and off. When the CONFIG_SBIUNIT is disabled, the tests and all related code is excluded completely on the compilation stage. Signed-off-by:
Ivan Orlov <ivan.orlov0322@gmail.com> Reviewed-by:
Andrew Jones <ajones@ventanamicro.com>
-
Ivan Orlov authored
This patch contains the documentation for SBIUnit. It describes: - What is SBIUnit - Simple test writing scenario - How we can cover static functions - How we can "mock" structures in order to test the functions which operate on them - SBIUnit API Reference Signed-off-by:
Ivan Orlov <ivan.orlov0322@gmail.com> Reviewed-by:
Andrew Jones <ajones@ventanamicro.com>
-
- Mar 09, 2024
-
-
Xiang W authored
a3 and a4 cannot be reset because used in fw_platform_init. Signed-off-by:
Xiang W <wxjstz@126.com> Reviewed-by:
Anup Patel <anup@brainfault.org>
-
Xiang W authored
Remove _relocate_lottery and use _boot_status instead. Signed-off-by:
Xiang W <wxjstz@126.com> Reviewed-by:
Anup Patel <anup@brainfault.org>
-
Xiang W authored
_bad_dynamic_info is same as _start_hang, so remove it. Signed-off-by:
Xiang W <wxjstz@126.com> Reviewed-by:
Anup Patel <anup@brainfault.org>
-
Xiang W authored
The same detection was done twice when setting mtvec and trap_exit. Merging can reduce code size. Signed-off-by:
Xiang W <wxjstz@126.com> Reviewed-by:
Anup Patel <anup@brainfault.org>
-
Xiang W authored
Simplify address get and remove _link_start _link_end _load_start. Signed-off-by:
Xiang W <wxjstz@126.com> Reviewed-by:
Anup Patel <anup@brainfault.org>
-
- Mar 05, 2024
-
-
Nylon Chen authored
Added exception handling for compressed instructions C.LHU, C.LH, and C.SH from the zcb extension to the sbi_misaligned_ldst library. Signed-off-by:
Nylon Chen <nylon.chen@sifive.com> Reviewed-by:
Anup Patel <anup@brainfault.org>
-
- Mar 04, 2024
-
-
Yu Chien Peter Lin authored
andes_pmu_setup() [1] was intended to populate event mapping from hardcoded arrays, however, this increases firmware size and we should just use PMU DT node [2] instead. Link: https://lists.infradead.org/pipermail/opensbi/2023-November/006032.html [1] Link: https://github.com/riscv-software-src/opensbi/blob/v1.4/docs/pmu_support.md#example-3 [2] Signed-off-by:
Yu Chien Peter Lin <peterlin@andestech.com> Reviewed-by:
Anup Patel <anup@brainfault.org>
-
Atish Patra authored
Smcsrind allows generic indirect CSR access mechanism while Smcdeleg allows delegating hpmcounters in Supervisor mode. Enable both extensions and set the appropriate bits in mstateen and menvcfg. Co-developed-by:
Kaiwen Xue <kaiwenxue1@gmail.com> Signed-off-by:
Atish Patra <atishp@rivosinc.com> Reviewed-by:
Anup Patel <anup@brainfault.org>
-
- Feb 24, 2024
-
-
Joshua Yeong authored
Hart state should change back to hart stop when hsm_device_hart_start() or sbi_ipi_raw_send() fails to perform hart start. Signed-off-by:
Joshua Yeong <joshua.yeong@starfivetech.com> Reviewed-by:
Xiang W <wxjstz@126.com> Reviewed-by:
Anup Patel <anup@brainfault.org>
-
Inochi Amaoto authored
Adding relocatable address brings new configuration options for jump and payload firmwares. Describe these new options in documentation. Signed-off-by:
Inochi Amaoto <inochiama@outlook.com> Reviewed-by:
Anup Patel <anup@brainfault.org>
-
Inochi Amaoto authored
Since jump and payload firmware support relocatable address, make general platform use runtime relocatable address. Signed-off-by:
Inochi Amaoto <inochiama@outlook.com> Reviewed-by:
Anup Patel <anup@brainfault.org>
-
Inochi Amaoto authored
The fw_payload.bin has the same issue as described in previous patch. But only FW_PAYLOAD_FDT_ADDR is affected. Add FW_PAYLOAD_FDT_OFFSET to identify relocatable payload fdt address. Signed-off-by:
Inochi Amaoto <inochiama@outlook.com> Reviewed-by:
Anup Patel <anup@brainfault.org>
-
Inochi Amaoto authored
If FW_PIC=y is defined, the fw_jump.bin will be broken if FW_TEXT_START is wrong. This is not the desired behavior. Add two new variables to identify relocatable jump address: FW_JUMP_OFFSET and FW_JUMP_FDT_ADDR. To keep the existing ABI, FW_JUMP_ADDR and FW_JUMP_FDT_ADDR is prefered if they are defined. Signed-off-by:
Inochi Amaoto <inochiama@outlook.com> Reviewed-by:
Anup Patel <anup@brainfault.org>
-
- Feb 22, 2024
-
-
Nam Cao authored
The function starfive_jh7110_inst_init() initialize some power management unit address and clock addresses, needed for the reset driver. It doesn't do anything else, and also the reset driver doesn't work without calling this function. Thus, it does not make much sense that this function is independent from pm_reset_init(). Delete the separate call to starfive_jh7110_inst_init(), and instead just call this function inside pm_reset_init(). Doing this also fixes another problem: if starfive_jh7110_inst_init() returns an error code, it gets propagated to final_init() and OpenSBI hangs. This hang is not necessary, because failures within starfive_jh7110_inst_init() only mean OpenSBI cannot perform reboot or shutdown, but the system can still function normally. Signed-off-by:
Nam Cao <namcao@linutronix.de> Tested-by:
Minda Chen <minda.chen@starfivetech.com> Reviewed-by:
Anup Patel <anup@brainfault.org>
-
Nam Cao authored
Jh7110's reset driver needs power management device and clock controller device to work. Currently, the driver proceed anyway without these devices, and invalid addresses (jh7110_inst.pmu_reg_base and jh7110_inst.clk_reg_base) are used during reboot, which causes unpredictable broken behaviors. If these devices are not present, return -SBI_ENODEV. Signed-off-by:
Nam Cao <namcao@linutronix.de> Tested-by:
Minda Chen <minda.chen@starfivetech.com> Reviewed-by:
Anup Patel <anup@brainfault.org>
-
Nam Cao authored
OpenSBI uses the device tree compatible string "stf,axp15060-regulator" for the regulator node. However, the string used by U-Boot (and Linux) is actually "x-powers,axp15060". As OpenSBI gets the device tree from U-Boot, this causes the regulator device to be undetected, and OpenSBI does not use this device to perform board reset/shutdown. Rename this device tree compatible string to match U-Boot (and Linux). Signed-off-by:
Nam Cao <namcao@linutronix.de> Acked-by:
Minda Chen <minda.chen@starfivetech.com> Tested-by:
Minda Chen <minda.chen@starfivetech.com> Reviewed-by:
Anup Patel <anup@brainfault.org>
-
Nam Cao authored
pmic_ops() is only called if a compatible device is found in device tree. It is redundant for this function to check the compability again. Remove this check. Signed-off-by:
Nam Cao <namcao@linutronix.de> Tested-by:
Minda Chen <minda.chen@starfivetech.com> Reviewed-by:
Anup Patel <anup@brainfault.org>
-
Nam Cao authored
The current code gets the I2C offset address using the device tree node name: it get the I2C device index from the 4th character in the node name (for example, "i2c5" -> i2c device 5). However, the device tree node's name in U-Boot is actually just "i2c" without the number, so the current code cannot be used with the device tree from U-Boot. Get the I2C offset address from the "clocks" property instead. Signed-off-by:
Nam Cao <namcao@linutronix.de> Reviewed-by:
Minda Chen <minda.chen@starfivetech.com> Tested-by:
Minda Chen <minda.chen@starfivetech.com> Reviewed-by:
Anup Patel <anup@brainfault.org>
-
Nam Cao authored
Starfive names the system clock device tree node "starfive,jh7110-clkgen" in all their git repositories. However, a different name is used in upstream U-Boot (and also Linux): "starfive,jh7110-syscrg". Since OpenSBI gets the device tree from U-Boot, this inconsistency leads the problem that OpenSBI doesn't know the system clock device exists. Correct this name to keep the consistency. Signed-off-by:
Nam Cao <namcao@linutronix.de> Acked-by:
Minda Chen <minda.chen@starfivetech.com> Tested-by:
Minda Chen <minda.chen@starfivetech.com> Reviewed-by:
Anup Patel <anup@brainfault.org>
-