summaryrefslogtreecommitdiff
path: root/lib
AgeCommit message (Collapse)Author
2020-03-08include: Move bits related defines and macros to sbi_bitops.hAnup Patel
The right location for all bits related defines and macros is sbi_bitops.h hence this patch. With this patch, the sbi_bits.h is redundant so we remove it. Signed-off-by: Anup Patel <[email protected]> Reviewed-by: Atish Patra <[email protected]>
2020-03-08lib: Fix return type of sbi_hsm_hart_started()Anup Patel
The return type of sbi_hsm_hart_started() should be bool. Signed-off-by: Anup Patel <[email protected]> Reviewed-by: Atish Patra <[email protected]> Reviewed-by: Bin Meng <[email protected]>
2020-03-07lib: Check MSIP bit after returning from WFIAtish Patra
As per the RISC-V privilege specification, WFI can be implemented as a NOP. Software should ensure that relevant interrupt pending bits are set. Otherwise, loop back to WFI. Signed-off-by: Atish Patra <[email protected]> Reviewed-by: Anup Patel <[email protected]> Reviewed-by: Bin Meng <[email protected]>
2020-02-24lib: Implement Hart State Management (HSM) SBI extensionAtish Patra
This patch adds support HSM extension. The specification is available at https://github.com/riscv/riscv-sbi-doc. It allows to implement hart hotplug and fixed ordered hart booting in supervisor. Signed-off-by: Atish Patra <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2020-02-24lib: Add possible hart status valuesAtish Patra
SBI HSM extension defines possible hart status values in the specification. Define all possible status values. Add a helper function to convert hart state to status because hart states are internal to OpenSBI only and may not match the status values defined in the specification. Signed-off-by: Atish Patra <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2020-02-24lib: Implement hart hotplugAtish Patra
This patch adds support for hart hotplug in OpenSBI using a generic WFI based approach. Hart hotplug can be achieved via SBI HSM extension which allows supervisor mode software to start or stop any harts anytime. Any platform wishes to implement platform specific hart hotplug must implement both hart_start and hart_stop in addition to enable platform feature SBI_PLATFORM_HAS_HART_HOTPLUG. Signed-off-by: Atish Patra <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2020-02-24lib: Simplify the for-loop in sbi_ipi_send_many()Anup Patel
We don't need to separately call sbi_ipi_send() for current HART in sbi_ipi_send_many(). Instead, we can simplify the for-loop in sbi_ipi_send_many() and call sbi_ipi_send() for all HARTs in the for-loop itself. Signed-off-by: Anup Patel <[email protected]> Reviewed-by: Bin Meng <[email protected]>
2020-02-22lib: Use available hart mask for correct hbase valueAtish Patra
As per the latest SBI specification, all online harts should receive IPI if hbase is set to -1. Set the target mask to all available hart mask if hbase is -1. Signed-off-by: Atish Patra <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2020-02-22lib: Fix typo in atomic exchange functionsAtish Patra
There is a typo in atomic operations code which prevents the usage of riscv atomic instructions even if it is supported. Fix the typo. Signed-off-by: Atish Patra <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2020-02-19lib: Print interrupt and exception delegation in boot printsAnup Patel
We print MIDELEG and MEDELEG CSRs as part of boot prints so that boot log shows the interrupts and exceptions delegated to S-mode. Signed-off-by: Anup Patel <[email protected]> Reviewed-by: Bin Meng <[email protected]> Reviewed-by: Atish Patra <[email protected]>
2020-02-19lib: Don't check MIDELEG and MEDELEG at end of delegate_traps()Anup Patel
The MIDELEG and MEDELEG CSR checks at end of delegate_traps() were added for initial bring-up on SiFive Unleashed and QEMU. These checks are not required any more and in-future these checks can cause failures because some of the MIDELEG/MEDELEG bits will be hard-wired to 0 or 1. For related discussion, refer github issue: https://github.com/riscv/opensbi/issues/157 Signed-off-by: Anup Patel <[email protected]> Reviewed-by: Bin Meng <[email protected]> Reviewed-by: Atish Patra <[email protected]>
2020-02-18lib: utils: htif: Fix 32-bit buildBin Meng
When building 32-bit OpenSBI images, we get: lib/utils/sys/htif.c: In function '__check_fromhost': lib/utils/sys/htif.c:12:31: error: left shift count >= width of type [-Werror=shift-count-overflow] #define HTIF_DATA_MASK ((1UL << HTIF_DATA_BITS) - 1) ^~ Fixes: c2f23cc6edd7 ("platform: Add Spike initial support") Signed-off-by: Bin Meng <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2020-02-18Revert "lib: Use __builtin_ctzl() in pmp_get()"Anup Patel
This reverts commit 897b8fbdd92fcfad194417d348b8dad16ab0e17a. We are seeing compile errors using newlib based GCC cross-toolchain so we restore back old ctz() implementation. Signed-off-by: Anup Patel <[email protected]>
2020-02-17platform: Add Spike initial supportJames Clarke
This patch adds initial platform support Spike emulator. Signed-off-by: James Clarke <[email protected]> Signed-off-by: Anup Patel <[email protected]> Reviewed-by: Bin Meng <[email protected]> Reviewed-by: Atish Patra <[email protected]>
2020-02-13lib: irqchip/plic: Disable all contexts and IRQsAtish Patra
To initialize PLIC in sane state, we should: 1. set maximum threshold value of M-mode PLIC contexts 2. set maximum threshold value of S-mode PLIC contexts 3. set irq priorities to miniumum Fix the comment and initialize the threshold/priorities correctly. Signed-off-by: Anup Patel <[email protected]> Signed-off-by: Atish Patra <[email protected]>
2020-02-13lib: Initialize out value in SBI callsAtish Patra
As per the SBI specification, the return value in sbiret is undefined if not explicitly described in the function. However, supervisor may check this value by mistake and get a garbage value. Initialize it to zero to avoid nasty supervisor bugs. Signed-off-by: Atish Patra <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2020-02-13lib: Use __builtin_ctzl() in pmp_get()Li Jinpei
We should should __builtin_ctzl() in pmp_get() instead of custom ctz() function. Signed-off-by: Li Jinpei <[email protected]> Signed-off-by: Anup Patel <[email protected]> Reviewed-by: Atish Patra <[email protected]>
2020-02-13lib: sbi_scratch: use bitwise ops in sbi_scratch_alloc_offset()Li Jinpei
Instead of using loop to make "size" machine word aligned, we should use bitwise ops. Signed-off-by: Li Jinpei <[email protected]> Signed-off-by: Anup Patel <[email protected]> Reviewed-by: Atish Patra <[email protected]>
2020-01-22lib: Factor-out SBI base extensionAnup Patel
This patch factor-out SBI base extension into its own source for better modularity of SBI implementation. Signed-off-by: Anup Patel <[email protected]> Reviewed-by: Atish Patra <[email protected]>
2020-01-22lib: Factor-out SBI vendor extensionAnup Patel
This patch factor-out SBI vendor extension into its own source for better modularity of SBI implementation. Signed-off-by: Anup Patel <[email protected]> Reviewed-by: Atish Patra <[email protected]>
2020-01-22lib: Factor-out SBI replacement extensionsAnup Patel
This patch factor-out SBI replacement extensions (such as RFENCE, IPI, and TIME) into its own source for better modularity of SBI implementation. Signed-off-by: Anup Patel <[email protected]> Reviewed-by: Atish Patra <[email protected]>
2020-01-22lib: Factor-out SBI legacy extensionAnup Patel
This patch factor-out SBI legacy extension into its own source for better modularity of SBI implementation. Signed-off-by: Anup Patel <[email protected]> Reviewed-by: Atish Patra <[email protected]>
2020-01-22lib: Add dynamic registration of SBI extensionsAnup Patel
This patch extends our SBI ecall implementation to allow dynamic registration of various SBI extensions. Using this dynamic registration we can break-up SBI ecall implementation into multiple files and even register experimental/custom SBI extensions from platform code. Signed-off-by: Anup Patel <[email protected]> Reviewed-by: Atish Patra <[email protected]>
2020-01-22lib: Initialize TLB management directly from coldboot/warmboot pathAnup Patel
Currently, the remote TLB management is initialized via IPI init which is counter intuitive. This patch initializes remote TLB management directly from init_coldboot() and init_warmboot() after IPI init is done. Signed-off-by: Anup Patel <[email protected]> Reviewed-by: Atish Patra <[email protected]>
2020-01-22lib: Drop _fifo from the name of various sbi_tlb_fifo_xyz() functionsAnup Patel
This patch drops _fifo from the name of various sbi_tlb_fifo_xyz() functions because all these functions deal with remote TLB managment and FIFO is the per-HART data structure used internally by remote TLB implementation. Signed-off-by: Anup Patel <[email protected]> Reviewed-by: Atish Patra <[email protected]>
2020-01-22lib: Introduce sbi_ipi_event_create/destroy() APIsAnup Patel
This patch introduces sbi_ipi_event_create/destroy() APIs and struct sbi_ipi_event_ops for creating/destroying IPI events at runtime based of event operations. This new APIs will help platform code and utils code to create custom IPI events which are not part of generic OpenSBI library. Signed-off-by: Anup Patel <[email protected]> Reviewed-by: Atish Patra <[email protected]>
2020-01-22lib: Introduce sbi_tlb_fifo_request() APIAnup Patel
Instead of directly calling sbi_ipi_send_many(), we introduce sbi_tlb_fifo_request() for halting a set of HARTs. This way in future we can assign any IPI event number for remote FENCE within sbi_tlb.c only. Signed-off-by: Anup Patel <[email protected]> Reviewed-by: Atish Patra <[email protected]>
2020-01-22lib: Introduce sbi_ipi_send_halt() APIAnup Patel
Instead of directly calling sbi_ipi_send_many(), we introduce sbi_ipi_send_halt() for halting a set of HARTs. This way in future we can assign any IPI event number for HART halting within sbi_ipi.c only. Signed-off-by: Anup Patel <[email protected]> Reviewed-by: Atish Patra <[email protected]>
2020-01-22lib: Introduce sbi_ipi_send_smode() APIAnup Patel
Instead of directly calling sbi_ipi_send_many(), we introduce sbi_ipi_send_smode() for injecting S-mode software interrupts. This way in future we can assign any IPI event number for S-mode IPIs within sbi_ipi.c only. Signed-off-by: Anup Patel <[email protected]> Reviewed-by: Atish Patra <[email protected]>
2020-01-22lib: Move struct sbi_ipi_data definition to sbi_ipi.cAnup Patel
The struct sbi_ipi_data is only used in sbi_ipi.c so move it to sbi_ipi.c from sbi_ipi.h. Signed-off-by: Anup Patel <[email protected]> Reviewed-by: Atish Patra <[email protected]>
2020-01-07lib: Add sbi_init_count() APIAnup Patel
We add sbi_init_count() API which provides number of times a given HART completed init sequence (warmboot/coldboot). This will be very useful in debugging. With upcoming SBI HSM extension, it will also help in implementing one-time init code for each HART. Signed-off-by: Anup Patel <[email protected]> Reviewed-by: Atish Patra <[email protected]>
2020-01-07lib: zero-out memory allocated using sbi_scratch_alloc_offset()Anup Patel
We should zero-out memory allocated from extra scratch space using sbi_scratch_alloc_offset() API hence this patch. This will not impact performance because we mostly allocate from extra scratch space only at cold boot time. Signed-off-by: Anup Patel <[email protected]> Reviewed-by: Atish Patra <[email protected]>
2020-01-07lib: improve system reboot and shutdown implementationAnup Patel
We improve sbi_system_reboot() an sbi_system_shutdown() by: 1. Calling halt IPI to all harts (except current HART) before calling platform reboot/shutdown hook. 2. Calling sbi_exit() instead of sbi_hang() in-case platform reboot/shutdown hook failed. Signed-off-by: Anup Patel <[email protected]> Reviewed-by: Atish Patra <[email protected]>
2020-01-07lib: do sbi_exit() upon halt IPIAnup Patel
Instead of doing sbi_hang() we should do sbi_exit() upon halt IPI. Signed-off-by: Anup Patel <[email protected]> Reviewed-by: Atish Patra <[email protected]>
2020-01-07lib: save/restore MIE CSR in sbi_hart_wait_for_coldboot()Anup Patel
Currently, sbi_hart_wait_for_coldboot() leaves MIE.MSIP bit set when it returns which is not correct because MIE.MSIP should be left enabled only by sbi_ipi_init(). This patch does save/restore of MIE CSR to ensure that MIE CSR is in original state after sbi_hart_wait_for_coldboot() returns. Signed-off-by: Anup Patel <[email protected]> Reviewed-by: Atish Patra <[email protected]>
2020-01-07lib: Add irqchip exit APIAnup Patel
We add an optional platform irqchip exit hook for exit path handling in sbi_exit() implementation. Signed-off-by: Anup Patel <[email protected]> Reviewed-by: Atish Patra <[email protected]>
2020-01-07lib: Add ipi exit APIAnup Patel
We add sbi_ipi_exit() API for exit path handling in sbi_exit() implementation. Signed-off-by: Anup Patel <[email protected]> Reviewed-by: Atish Patra <[email protected]>
2020-01-07lib: Add timer exit APIAnup Patel
We add sbi_timer_exit() API for OpenSBI exit path handling in sbi_exit() implementation. Signed-off-by: Anup Patel <[email protected]> Reviewed-by: Atish Patra <[email protected]>
2020-01-07lib: Add system early_exit and final_exit APIsAnup Patel
This patch adds system-level early_exit and final_exit APIs with corresponding platform hooks. These new APIs will be primarily used by sbi_exit() in OpenSBI exit path. Signed-off-by: Anup Patel <[email protected]> Reviewed-by: Atish Patra <[email protected]>
2020-01-07lib: Add initial sbi_exit() APIAnup Patel
This patch adds initial implementation of sbi_exit() API which can be used to perform OpenSBI exit sequence for current HART. The sbi_exit() implementation will be further extended by subsequent patches. Signed-off-by: Anup Patel <[email protected]> Reviewed-by: Atish Patra <[email protected]>
2020-01-07lib: Remove unnecessary checks from init_coldboot() and init_warmboot()Anup Patel
We remove unnecessary checks related to hart hotplug and disabled hart in coldboot and warmboot init path. Signed-off-by: Anup Patel <[email protected]> Reviewed-by: Atish Patra <[email protected]>
2020-01-02lib: utils: Support CLINT with 32bit MMIO access on RV64 systemAnup Patel
It is possible to have a CLINT implementation which supports only 32bit MMIO accesses on RV64 system so this patch extends our CLINT driver such that platform code can specify whether CLINT supports 64bit MMIO access. Signed-off-by: Anup Patel <[email protected]> Reviewed-by: Atish Patra<[email protected]> Reviewed-by: Zong Li <[email protected]>
2019-12-23lib: Implement RFENCE extensionAtish Patra
This patch adds RFENCE extension support in OpenSBI. Signed-off-by: Atish Patra <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2019-12-23lib: Support stage1 and stage2 tlb flushingAtish Patra
The hypervisor specification support hfence calls which can be used issue tlb flush requests at both level of address translation. Currently, these requests are issued only via SBI which are defined in v0.2. Signed-off-by: Atish Patra <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2019-12-23lib: Add hfence instruction encodingAtish Patra
Currently, the toolchains do not have support for hfence instruction. Hence, the instruction are hardcode until we have toolchain support. Signed-off-by: Atish Patra <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2019-12-23lib: Add IPI extension in SBIAtish Patra
This patch adds new IPI extension which replaces ipi related v0.1 extensions. This also adds a new API for ipi sending as trap handling is not necessary in v0.2 SBI IPI related extensions. It also modifies the IPI sending code which now accepts hart mask as a value instead of S-mode virtual address. Thus, the caller should set it to exact hart mask value everytime. Signed-off-by: Atish Patra <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2019-12-23lib: Add TIME extension in SBIAtish Patra
This patch adds support for TIME extension which replaces v0.1 timer extension. Signed-off-by: Atish Patra <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2019-12-23lib: Remove redundant IPI typesAtish Patra
We just need to distinguish only between FENCE and non FENCE related IPIs as all of the fence related requests are handled via fifo now. Remove the unnecessary IPI types related to individual fence types. Signed-off-by: Atish Patra <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2019-12-16lib: Use MTINST CSR in misaligned load/store emulationAnup Patel
We should use MTINST CSR in misaligned load/store emulation whenever possible to avoid unpriv read in getting trapped instruction. This will improve preformance on HW having proper implementation of MTINST CSR. Signed-off-by: Anup Patel <[email protected]> Reviewed-by: Alistair Francis <[email protected]>
2019-12-16lib: Extend trap redirection for hypervisor v0.5 specAnup Patel
The hypervisor v0.5 spec introduces two new CSRs for both M-mode and HS-mode which need to be considered when redirecting traps hence this patch. Signed-off-by: Anup Patel <[email protected]>