- Sep 03, 2021
-
-
Dong Du authored
sbi_platform_get_features_str() uses sbi_snprintf() to construct the features_str. However, it passes the wrong length value (i.e., the nfstr), which should be (nfstr-offset) as the starting point of str (i.e., features_str + offset) changes. This commit also checks the return value of snprintf, and handles the corner case that the string buffer is full. Signed-off-by:
Dong Du <Dd_nirvana@sjtu.edu.cn> Reviewed-by:
Atish Patra <atish.patra@wdc.com>
-
Dong Du authored
As other exported fifo functions, we should check whether the fifo is valid in sbi_fifo_is_empty and sbi_fifo_is_full. To this end, this patch changes the retval from bool to int, and the two functions will return SBI_EINVAL in the case the fifo is invalid. Signed-off-by:
Dong Du <Dd_nirvana@sjtu.edu.cn> Reviewed-by:
Atish Patra <atish.patra@wdc.com>
-
- Aug 30, 2021
-
-
Dong Du authored
Avoid getting messages from multiple harts (using dprintf and printf) concurrently with a spinlock serializaing calls to sbi_dprintf(), sbi_printf() and sbi_puts() Signed-off-by:
Dong Du <Dd_nirvana@sjtu.edu.cn> Reviewed-by:
Xiang W <wxjstz@126.com> Reviewed-by:
Anup Patel <anup.patel@wdc.com>
-
Rahul Pathak authored
Correcting the name of faults delegation CSR %s/mfdeleg/medeleg Signed-off-by:
Rahul Pathak <rpathak@ventanamicro.com> Reviewed-by:
Anup Patel <anup.patel@wdc.com>
-
- Aug 20, 2021
-
-
Samuel Holland authored
It can be useful to make SBI v0.2 or newer ecalls from this payload for testing purposes. To support this, convert the macros to use the extension/function parameter convention. Signed-off-by:
Samuel Holland <samuel@sholland.org> Reviewed-by:
Atish Patra <atish.patra@wdc.com>
-
Samuel Holland authored
commit 764a17d8 ("lib: sbi: Implement firmware counters") added switch cases for CAUSE_LOAD_ACCESS and CAUSE_STORE_ACCESS. This caused them to stop being redirected to U or S mode, as that is handled in the default switch case. As a result, an error in userspace could cause the system to hang. Fix this by allowing the acces fault case to fall through to the default case. Fixes: 764a17d8 ("lib: sbi: Implement firmware counters") Signed-off-by:
Samuel Holland <samuel@sholland.org> Reviewed-by:
Atish Patra <atish.patra@wdc.com> Reviewed-by:
Bin Meng <bmeng.cn@gmail.com>
-
Dong Du authored
In sbi_ecall_rfence_handler, it will compare the funcid with REMOTE_HFENCE_GVMA and REMOTE_HFENCE_VVMA_ASID. Later it check whether the misa includes H-extension. This checking is incomplete which misses REMOTE_HFENCE_GVMA_VMID and REMOTE_HFENCE_VVMA. Fix the issue by updating the checking range. Signed-off-by:
Dong Du <Dd_nirvana@sjtu.edu.cn> Reviewed-by:
Atish Patra <atish.patra@wdc.com>
-
- Aug 14, 2021
-
-
Anup Patel authored
We simplify MTIMER synchronization as follows: 1) Detect MTIMER devices with unique (or non-shared) MTIME register at boot-time 2) Select first MTIMER device with no associated HART as our reference MTIMER device 3) Only synchronize MTIMER devices with unique (or non-shared) MTIME register using reference MTIMER device 4) Directly update the MTIME register at time of synchronization because MTIME is a read/write register. Signed-off-by:
Anup Patel <anup.patel@wdc.com> Reviewed-by:
Atish Patra <atish.patra@wdc.com>
-
Anup Patel authored
We can have ACLINT MTIMER devices which only support 32-bit MMIO accesses on RV64 system so this patch adds a boolean DT property "mtimer,no-64bit-mmio" to detect this from MTIMER DT node. Signed-off-by:
Anup Patel <anup.patel@wdc.com> Reviewed-by:
Atish Patra <atish.patra@wdc.com>
-
Anup Patel authored
The fdt_parse_aclint_node() is used to parse DT node for SiFive CLINT, ACLINT MTIMER, and ACLINT MSWI devices. The ACLINT MTIMER has undergone following changes: 1) MTIMER DT node now requires separate addresses in for MTIME register and MTIMECMPx registers in the reg DT property. 2) MTIMER DT node might have no interrupts-extended DT property when the MTIMER device has no associated HARTs (i.e. the MTIMER device has no MTIMECMPx registers) This patch extends fdt_parse_aclint_node() to handle above mentioned changes in ACLINT MTIMER DT bindings. Signed-off-by:
Anup Patel <anup.patel@wdc.com> Reviewed-by:
Atish Patra <atish.patra@wdc.com>
-
Anup Patel authored
We add "index" parameter to fdt_get_node_addr_size() API so that calling function can specify index of desired register set. This will allow fdt_get_node_addr_size() to handle DT nodes with multiple register sets. Signed-off-by:
Anup Patel <anup.patel@wdc.com> Reviewed-by:
Atish Patra <atish.patra@wdc.com>
-
Anup Patel authored
We extend the ACLINT library to support separate base addresses for MTIME and MTIMECMP registers. Signed-off-by:
Anup Patel <anup.patel@wdc.com> Reviewed-by:
Atish Patra <atish.patra@wdc.com>
-
- Aug 07, 2021
-
-
Bin Meng authored
The maximum address and size encoded in DT are 64-bit numbers, so we should use uint64_t for 'addr' and 'size' in fdt_get_node_addr_size(). Signed-off-by:
Bin Meng <bmeng.cn@gmail.com> Reviewed-by:
Anup Patel <anup.patel@wdc.com>
-
Dong Du authored
No need to compare characters when the count turns to 0. Fix the issue in sbi_strncmp. Signed-off-by:
Dong Du <Dd_nirvana@sjtu.edu.cn> Reviewed-by:
Bin Meng <bmeng.cn@gmail.com> Reviewed-by:
Anup Patel <anup.patel@wdc.com>
-
- Jul 27, 2021
-
-
Heinrich Schuchardt authored
The generic GPIO reset driver has two entries in the match table: "gpio-poweroff", "gpio-reset". Only the first entry is considered by fdt_reset_init(). Define "gpio-poweroff" and "gpio-reset" as compatibility strings of two separate reset drivers. They still can share code. Fixes: e3d6919d ("lib: utils/reset: Add generic GPIO reset driver") Signed-off-by:
Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by:
Atish Patra <atish.patra@wdc.com>
-
Heinrich Schuchardt authored
The value of variable current_driver is unused. Remove the variable. Signed-off-by:
Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by:
Atish Patra <atish.patra@wdc.com>
-
David Abdurachmanov authored
Instruction TLB can fail to respect a non-global SFENCE thus we need to flush the TLB using SFENCE.VMA x0, x0 See full description of CIP-1200 in Errata_FU740-C000_20210205 from https://www.sifive.com/boards/hifive-unmatched Signed-off-by:
David Abdurachmanov <david.abdurachmanov@sifive.com> Signed-off-by:
Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
-
Xiang W authored
The previous code uses _start as the load address, this default .entry is the first segment, using _fw_start does not need to make this assumption. Signed-off-by:
Xiang W <wxjstz@126.com> Reviewed-by:
Anup Patel <anup.patel@wdc.com>
-
Bin Meng authored
When generating code with -mno-relax, GCC puts .option norelax in the generated assembly, and so doesn’t bother passing on -mno-relax to the assembler. This has the unfortunate effect that, when using GCC to assemble hand-written assembly, -mno-relax does nothing, and we have to pass -Wa,-mno-relax to manually forward it to the assembler. This is an old GCC bug that was fixed [1] recently. For the time being, let's pass "-Wa,-mno-relax" to ASFLAGS for the GCC + LLD combination to work, e.g.: $ make CC=riscv64-unknown-elf-gcc LLVM=1 PLATFORM=generic [1] https://github.com/gcc-mirror/gcc/commit/3b0a7d624e64eeb81e4d5e8c62c46d86ef521857 Signed-off-by:
Bin Meng <bmeng.cn@gmail.com> Reviewed-by:
Anup Patel <anup.patel@wdc.com>
-
- Jul 17, 2021
-
-
Bin Meng authored
Recent FW_PIC=y changes actually require toolchains with PIE support and it is on by default. Existing doc uses a GNU bare-metal toolchain as examples but it does not support PIE. Replace references of bare-metal toolchain prefix with Linux toolchain prefix everywhere in documentation. Also indicate that "riscv64-unknown-freebsd-" as an alternative to "riscv64-linux-" GNU toolchain. Signed-off-by:
Bin Meng <bmeng.cn@gmail.com> Reviewed-by:
Anup Patel <anup.patel@wdc.com>
-
Bin Meng authored
FW_PIC=y is on by default, but the doc is missing when this was introduced. Add some description for it. Signed-off-by:
Bin Meng <bmeng.cn@gmail.com> Reviewed-by:
Anup Patel <anup.patel@wdc.com>
-
Bin Meng authored
This updates documentation to describe parameters passed to firmware from previous booting stage, and corresponding address alignment requirement. This also fixes a typo in fw_dynamic.md (it's => its). Signed-off-by:
Bin Meng <bmeng.cn@gmail.com> Reviewed-by:
Anup Patel <anup.patel@wdc.com>
-
Bin Meng authored
If the device tree is at an address that is not __SIZEOF_POINTER__ aligned, the fdt relocation code tries to align both source and destination address to __SIZEOF_POINTER__ before the memory copy. But such alignment can lead to unexpected results if either source or destination address is not aligned. In fact libfdt requires that the device tree must be at an 8-byte aligned address. Hence remove the unhelpful alignment codes. Signed-off-by:
Bin Meng <bmeng.cn@gmail.com> Reviewed-by:
Anup Patel <anup.patel@wdc.com>
-
Alex Richardson authored
Clang provides a __builtin_offsetof which can be detected using __has_builtin(). Signed-off-by:
Alex Richardson <Alexander.Richardson@cl.cam.ac.uk> Reviewed-by:
Anup Patel <anup.patel@wdc.com>
-
Alex Richardson authored
The fields are of type unsigned long and are not pointers. While this happens to be the same for RV32/RV64, it is not correct when compiling for a CHERI-RISC-V system where pointers are twice the size of long. Signed-off-by:
Alex Richardson <Alexander.Richardson@cl.cam.ac.uk> Reviewed-by:
Bin Meng <bmeng.cn@gmail.com> Reviewed-by:
Anup Patel <anup.patel@wdc.com>
-
Green Wan authored
We add generic GPIO reset driver inspired from gpio-restart and gpio-poweroff drivers of Linux kernel. Signed-off-by:
Green Wan <green.wan@sifive.com> Signed-off-by:
Anup Patel <anup.patel@wdc.com> Reviewed-by:
Atish Patra <atish.patra@wdc.com>
-
Green Wan authored
We add a minimal SiFive GPIO driver so that we can do GPIO based system power-off and reset. Signed-off-by:
Green Wan <green.wan@sifive.com> Signed-off-by:
Anup Patel <anup.patel@wdc.com> Reviewed-by:
Atish Patra <atish.patra@wdc.com>
-
Anup Patel authored
We add a simple FDT based GPIO framework which is built on top of generic GPIO library. The phandle of FDT GPIO chip DT node is treated as unique GPIO chip ID required by the generic GPIO library. The FDT based GPIO chip drivers will be probed on-demand from fdt_gpio_pin_get() called by the GPIO client drivers. Signed-off-by:
Anup Patel <anup.patel@wdc.com> Reviewed-by:
Atish Patra <atish.patra@wdc.com>
-
Anup Patel authored
We add generic GPIO configuration library which is independent of hardware description format (FDT or ACPI). The OpenSBI platform support or GPIO drivers can register GPIO chip instances which can be discovered and used by different GPIO clients. Each GPIO chip instance has a unique ID which can be used by GPIO clients to lookup GPIO chip instance. Signed-off-by:
Anup Patel <anup.patel@wdc.com> Reviewed-by:
Atish Patra <atish.patra@wdc.com>
-
Anup Patel authored
The libfdt project does not have a generic API to parse phandle with args from a DT node so we add fdt_parse_phandle_with_args() for this purpose. This new API will be useful to FDT based drivers. Signed-off-by:
Anup Patel <anup.patel@wdc.com> Reviewed-by:
Atish Patra <atish.patra@wdc.com>
-
- Jul 11, 2021
-
-
Jessica Clarke authored
We only need libgcc for 64-bit division on RV32. Whilst GCC toolchains bundle libgcc, Clang toolchains tend not to ship libclang_rt.builtins given every compiler is a cross-compiler for every target and so you would need a silly number of builds of it, with only the native library available; only vendor-provided Clang toolchains specifically for bare metal cross-compiling are likely to provide it. Thus, import part of FreeBSD's implementation of the division support functions needed and stop linking against libgcc. Signed-off-by:
Jessica Clarke <jrtc27@jrtc27.com> Reviewed-by:
Anup Patel <anup.patel@wdc.com> Tested-by:
Anup Patel <anup.patel@wdc.com>
-
Jessica Clarke authored
This is intended to mirror the Linux kernel. Building with CC=clang will use Clang as the compiler but default to using the existing binutils. Building with LLVM=1 will default to using Clang and LLVM binutils. Whilst GCC will accept the -N linker option and forward it on to the linker, Clang will not, and so in order to support both compilers we must use -Wl, to forward it to the linker as is required for most other linker options. Note that there is currently a bug when using Clang as the compiler and riscv64-linux-gnu-ld as the linker for FW_PIC=y. At first glance this appears to be a bug in GNU binutils, but this could also be Clang or OpenSBI at fault in some subtle way. Thus, for now, advise that this combination be avoided. Signed-off-by:
Jessica Clarke <jrtc27@jrtc27.com> Reviewed-by:
Anup Patel <anup.patel@wdc.com> Tested-by:
Anup Patel <anup.patel@wdc.com>
-
Jessica Clarke authored
Bare-metal GNU ld does not support PIE, so if using it this will result in a failure to build. Instead, default to FW_PIC=n if not supported. Note that an explicit FW_PIC=y is not overridden, to ensure the build fails rather than silently producing a position-dependent binary. Signed-off-by:
Jessica Clarke <jrtc27@jrtc27.com> Reviewed-by:
Bin Meng <bmeng.cn@gmail.com> Tested-by:
Bin Meng <bmeng.cn@gmail.com> Reviewed-by:
Anup Patel <anup.patel@wdc.com>
-
Jessica Clarke authored
When using Clang with a bare-metal triple, -pie does not get passed to the linker as it's not normally a thing that makes sense, unlike GCC which will unconditionally forward it on and potentially result in a linker error. However, LLD does support it, and manually forwarding it on works as desired, so do so to fully support FW_PIC with Clang and LLD. Signed-off-by:
Jessica Clarke <jrtc27@jrtc27.com> Reviewed-by:
Bin Meng <bmeng.cn@gmail.com> Tested-by:
Bin Meng <bmeng.cn@gmail.com> Reviewed-by:
Anup Patel <anup.patel@wdc.com>
-
Jessica Clarke authored
The -N linker option is supposed to make .text writable, but GNU ld and LLD differ in interpreting what that means. GNU ld will happily let you have relocations in it, but LLD will see that the input section is read-only (even though the output section is writable) and give an error. It's unclear if either of them intend to have that behaviour in this edge case, but regardless there's no reason not to just put the data in a writable .data section. Signed-off-by:
Jessica Clarke <jrtc27@jrtc27.com> Reviewed-by:
Bin Meng <bmeng.cn@gmail.com> Tested-by:
Bin Meng <bmeng.cn@gmail.com> Reviewed-by:
Anup Patel <anup.patel@wdc.com>
-
Jessica Clarke authored
These are mutually exclusive. GNU as and LLVM both let later binding directives override earlier ones so this works as intended, but LLVM 12 turned this into a warning as there's no good reason to do such a thing and could be a potential bug. Thus, remove the redundant and incorrect .globl directive for fw_platform_init. Signed-off-by:
Jessica Clarke <jrtc27@jrtc27.com> Reviewed-by:
Bin Meng <bmeng.cn@gmail.com> Tested-by:
Bin Meng <bmeng.cn@gmail.com> Reviewed-by:
Anup Patel <anup.patel@wdc.com>
-
Anup Patel authored
The sbi_pmu_exit() crashes on systems not having MCOUNTINHIBIT csr so to fix this we check SBI_HART_HAS_MCOUNTINHIBIT feature in sbi_pmu_exit() and do nothing if it is not available. Fixes: 13d40f21 ("lib: sbi: Add PMU support") Signed-off-by:
Anup Patel <anup.patel@wdc.com>
-
Bin Meng authored
Avoid using a magic number, instead use a macro for the version of struct fw_dynamic_info. Signed-off-by:
Bin Meng <bmeng.cn@gmail.com> Reviewed-by:
Xiang W <wxjstz@126.com> Reviewed-by:
Anup Patel <anup.patel@wdc.com>
-
Bin Meng authored
The sanity checks on the magic and version was already done in fw_boot_hart(), which happens before fw_save_info() is called. Signed-off-by:
Bin Meng <bmeng.cn@gmail.com> Reviewed-by:
Xiang W <wxjstz@126.com> Reviewed-by:
Anup Patel <anup.patel@wdc.com>
-
Bin Meng authored
At present in the rendered platform guide, all instances of <xyz> are missing. Use < and > to replace <> to make them visible. Signed-off-by:
Bin Meng <bmeng.cn@gmail.com> Reviewed-by:
Xiang W <wxjstz@126.com> Reviewed-by:
Anup Patel <anup.patel@wdc.com>
-