summaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2020-03-13lib: sbi_hsm: Optimize sbi_hsm_hart_get_state() implementationAnup Patel1-6/+2
Now that sbi_hart_id_to_scratch() is optimized, we don't need the "if ()" statement. Also, the hstate local variable is redundant so we remove that as well. Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Atish Patra <atish.patra@wdc.com>
2020-03-13firmware: fw_base: Optimize _hartid_to_scratch() implementationAnup Patel1-23/+14
This patch optimizes _hartid_to_scratch() in following ways: 1. Use caller saved registers instead of callee saved registers so that we don't need to save/restore registers on stack 2. Remove second redundant mul instruction by re-arranging instructions Overall, we reduce 9 instructions in _hartid_to_scratch() implementation. Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Atish Patra <atish.patra@wdc.com> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
2020-03-13include: Make sbi_hart_id_to_scratch() as macroAnup Patel3-11/+6
The sbi_hart_id_to_scratch() just forwards call to firmware specific hartid_to_scratch() callback so we make sbi_hart_id_to_scratch() as macro in sbi_scratch.h instead of regular function in sbi_hart.c. Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Atish Patra <atish.patra@wdc.com> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
2020-03-13libfdt: Upgrade to v1.5.1 releaseBin Meng15-655/+394
Sync with latest libfdt v1.5.1 release source codes. Signed-off-by: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Anup Patel <anup.patel@wdc.com>
2020-03-13libfdt: Add INT32_MAX and UINT32_MAX in libfdt_env.hBin Meng1-0/+2
Add two macros in preparation to sync libfdt codes to latest v1.5.1 release from upstream. Signed-off-by: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Anup Patel <anup.patel@wdc.com>
2020-03-13sbi: Add definitions for true/falseBin Meng1-0/+2
We currently have TRUE/FALSE, but it could be convenient to have true/false as well. Signed-off-by: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Anup Patel <anup.patel@wdc.com>
2020-03-13platform: ariane-fpga: Change license for ariane-fpga from GPL-2.0 to BSD-2Panagiotis Peristerakis3-3/+3
Signed-off-by: Panagiotis Peristerakis <perister@ics.forth.gr> Reviewed-by: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Anup Patel <anup.patel@wdc.com>
2020-03-13lib: sbi: Fix misaligned trap handlingDamien Le Moal1-4/+0
Compile time checks of __riscv_compressed can only check if OpenSBI is being compiled using compressed instructions or not. Checking this macro does not indicate if an instruction that generated a misaligned trap is a compressed instruction or not. Since the misaligned trap handling code inspects instructions _C_ bits to detect compressed instructions, we can remove all static checks on __riscv_compressed and dissociate hanlding of misaligned traps and OpenSBI compilation. Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com> Reviewed-by: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Anup Patel <anup.patel@wdc.com>
2020-03-11docs: Remove out-of-date documentationAtish Patra1-27/+2
Upstream U-Boot now have SMP support and doesn't require any additional patches for HiFive Unleashed. Update the documentation. Signed-off-by: Atish Patra <atish.patra@wdc.com> Reviewed-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
2020-03-11lib: sbi_hart: Remove HART available mask and related APIsAnup Patel3-41/+0
The HART available mask and related APIs are now totally redundant because of more extensive HART state machine implemented by sbi_hsm. Due to above, we remove HART available mask and related APIs. Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
2020-03-11lib: sbi_ipi: Use sbi_hsm_hart_started_mask() APIAnup Patel1-24/+22
This patch replaces use of sbi_hart_available_mask() API with sbi_hsm_hart_started_mask() API. Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
2020-03-11lib: sbi_system: Use sbi_hsm_hart_started_mask() APIAnup Patel1-6/+20
This patch replaces use of sbi_hart_available_mask() API with sbi_hsm_hart_started_mask() API. Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
2020-03-11lib: sbi_ecall_legacy: Use sbi_hsm_hart_started_mask() APIAnup Patel1-1/+3
This patch replaces use of sbi_hart_available_mask() API with sbi_hsm_hart_started_mask API. Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
2020-03-11lib: Introduce sbi_hsm_hart_started_mask() APIAnup Patel2-0/+41
This patch introduce sbi_hsm_hart_started_mask() API as a replacement of sbi_hart_available_mask() API. Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
2020-03-11include: Remove disabled_hart_mask from sbi_platformAnup Patel9-18/+13
The disabled_hard_mask in sbi_platform is only 64bits wide so we cannot disable a HART with HARTID > 63. To tackle this, we remove disabled_hart_mask and replace it with hart_disabled() platform callback. Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Atish Patra <atish.patra@wdc.com>
2020-03-11lib: sbi_init: Use hartmask for coldboot waitAnup Patel1-9/+6
The coldboot_wait_bitmap is of fixed size and has __riscv_xlen bits. This limits us to scale beyond __riscv_xlen HARTs hence we replace coldboot_wait_bitmap with coldboot_wait_hmask which is of type struct sbi_hartmask. Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Atish Patra <atish.patra@wdc.com>
2020-03-11lib: Move all coldboot wait APIs to sbi_init.cAnup Patel3-76/+70
The coldboot wait APIs are only used by sbi_init.c so no point in having coldboot related code in sbi_hart.c. As per-above rationale, we move all coldboot wait related APIs to sbi_init.c as static/local functions. Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
2020-03-11lib: sbi_tlb: Use sbi_hartmask in sbi_tlb_infoAnup Patel2-12/+10
Instead of using single ulong as source mask for sbi_tlb_info, we use sbi_hartmask. This way sbi_tlb_info can easily scale for large number of HARTs. Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Atish Patra <atish.patra@wdc.com>
2020-03-11lib: Introduce SBI_TLB_INFO_INIT() helper macroAnup Patel3-49/+36
We introduce SBI_TLB_INFO_INIT() helper macro to help easy initialization of struct sbi_tlb_info which is passed to the sbi_tlb_request() API. Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Atish Patra <atish.patra@wdc.com>
2020-03-11lib: sbi_init: Don't allow HARTID greater than SBI_HARTMASK_MAX_BITSAnup Patel1-1/+3
We only allow HARTs with HARTID less than SBI_HARTMASK_MAX_BITS in sbi_init() function so that sbi_hartmask can safely used across OpenSBI sources. Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Atish Patra <atish.patra@wdc.com>
2020-03-11include: Simple hartmask libraryAnup Patel1-0/+141
We add a simple hartmask library to create and maintain HART mask in different parts of OpenSBI sources. This new library is build as wrapper library on-top-of bitmap library. Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Atish Patra <atish.patra@wdc.com>
2020-03-11lib: Simple bitmap libraryAnup Patel3-0/+169
We add simple bitmap library which will help us create and maintain bitmaps. It will also help us create a simple HART mask library. Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Atish Patra <atish.patra@wdc.com>
2020-03-10lib: serial: Fix coding style issuesBin Meng2-11/+11
This fixes various coding style issues found in the serial codes. No functional changes. Signed-off-by: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Anup Patel <anup.patel@wdc.com>
2020-03-10lib: sbi: Fix coding style issuesBin Meng19-103/+113
This fixes various coding style issues found in the SBI codes. No functional changes. Signed-off-by: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Anup Patel <anup.patel@wdc.com>
2020-03-10platform: ae350: Sort build objects in alphabetical orderBin Meng1-1/+1
Signed-off-by: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Anup Patel <anup.patel@wdc.com>
2020-03-10lib: Sort build objects in alphabetical orderBin Meng3-6/+6
Signed-off-by: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Anup Patel <anup.patel@wdc.com>
2020-03-08include: sbi_scratch: Set per-HART scratch size to 4KBAnup Patel1-2/+2
Currently, the per-HART scratch size is 256 bytes on RV32 and 512 bytes on RV64. This patch set per-HART scratch size to 4KB (4096 bytes) for both RV32 and RV64 so that we don't run-out of scratch space anytime soon. Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Atish Patra <atish.patra@wdc.com>
2020-03-08platform: kendryte/k210: Set per-HART stack size to 8KBAnup Patel1-1/+1
All platform except kendryte/k210 use 8KB of per-HART stack hence this patch set per-HART stack size of kendryte/k210 to 8KB for consistency. Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Atish Patra <atish.patra@wdc.com>
2020-03-08include: sbi_bitops: More useful bit operationsAnup Patel3-2/+340
This patch extends our bit operation library with mechanism to: 1. Iteratively traverse bits 2. Set bit 3. Clear bit 4. Change bit 5. ... other helpful functions ... Most the above is adopted from Xvisor sources. Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Atish Patra <atish.patra@wdc.com>
2020-03-08include: Move bits related defines and macros to sbi_bitops.hAnup Patel10-33/+27
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 <anup.patel@wdc.com> Reviewed-by: Atish Patra <atish.patra@wdc.com>
2020-03-08lib: Fix return type of sbi_hsm_hart_started()Anup Patel1-2/+1
The return type of sbi_hsm_hart_started() should be bool. Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Atish Patra <atish.patra@wdc.com> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
2020-03-08platform: sifive: fu540: allow sv32 as an mmu-typeSören Tempel1-1/+2
There has already been a commit to master which added 32-bit specific fdt/payload addresses for the sifive/fu540 platform [0]. This commit introduces another change for using sifive/fu540 as a 32-bit platform. On 32-bit platforms, cores with the SV32 MMU type should not be disabled. For this reason, this commit also allows using this MMU type on the sifive/fu540 platform. Alternatively it would also be possible to only allow SV39 and SV48 if `__riscv_xlen == 64` and SV32 if `__riscv_xlen == 32`. Removing the check entirely would also be an option. [0]: 66fb729a1e46a9a46e809f3b7867fef91477e494 Signed-off-by: Sören Tempel <tempel@uni-bremen.de> Reviewed-by: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
2020-03-08makefile: Do setup of the install target more flexibleNikita Ermakov1-20/+47
- Add possibility to setup include, libs, firmware and docs paths. - Change the default installation paths for include, libs, firmware and docs to meet FHS [1]. [1] https://refspecs.linuxfoundation.org/FHS_3.0/fhs/index.html Signed-off-by: Nikita Ermakov <coffe92@gmail.com> Reviewed-by: Anup Patel <anup.patel@wdc.com>
2020-03-07lib: Check MSIP bit after returning from WFIAtish Patra1-2/+5
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 <atish.patra@wdc.com> Reviewed-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
2020-02-24lib: Implement Hart State Management (HSM) SBI extensionAtish Patra5-0/+62
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 <atish.patra@wdc.com> Reviewed-by: Anup Patel <anup.patel@wdc.com>
2020-02-24lib: Add possible hart status valuesAtish Patra3-0/+31
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 <atish.patra@wdc.com> Reviewed-by: Anup Patel <anup.patel@wdc.com>
2020-02-24lib: Implement hart hotplugAtish Patra10-2/+343
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 <atish.patra@wdc.com> Reviewed-by: Anup Patel <anup.patel@wdc.com>
2020-02-24lib: Add a new platform feature to bringup secondary hartsAtish Patra1-0/+5
A platform may have a specific method to bring-up secondary harts for the first time but may rely on generic WFI based approach for hart hotplug in absence of a platform specific hart hotplug method. Define a platform feature flag for such platforms. The platform needs to implement platform specific bring-up method in hart_start and not define hart_stop method in this case. They must only define SBI_PLATFORM_HAS_HART_SECONDARY_BOOT. SBI_PLATFORM_HAS_HART_HOTPLUG should only be defined when the platform intend to support both hart_start and hart_stop and do not intend to rely on generic WFI based approach. Signed-off-by: Atish Patra <atish.patra@wdc.com> Reviewed-by: Anup Patel <anup.patel@wdc.com>
2020-02-24include: Bump-up version to 0.6v0.6Anup Patel1-1/+1
This patch updates OpenSBI version to 0.6 as part of release preparation. Signed-off-by: Anup Patel <anup.patel@wdc.com>
2020-02-24lib: Simplify the for-loop in sbi_ipi_send_many()Anup Patel1-9/+1
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 <anup.patel@wdc.com> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
2020-02-22lib: Use available hart mask for correct hbase valueAtish Patra1-13/+16
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 <atish.patra@wdc.com> Reviewed-by: Anup Patel <anup.patel@wdc.com>
2020-02-22lib: Fix typo in atomic exchange functionsAtish Patra1-1/+1
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 <atish.patra@wdc.com> Reviewed-by: Anup Patel <anup.patel@wdc.com>
2020-02-19platform: qemu: virt: Correct the typo in config.mkBin Meng1-4/+4
It should be "aligned". Signed-off-by: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Anup Patel <anup.patel@wdc.com>
2020-02-19platform: sifive: fu540: Add 32-bit specific fdt/payload addressesBin Meng2-2/+18
For testing 32-bit SiFive specific drivers with QEMU riscv32, add 32-bit specific FW_JUMP_FDT_ADDR and FW_PAYLOAD_OFFSET. Signed-off-by: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Anup Patel <anup.patel@wdc.com>
2020-02-19lib: Print interrupt and exception delegation in boot printsAnup Patel3-2/+15
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 <anup.patel@wdc.com> Reviewed-by: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Atish Patra <atish.patra@wdc.com>
2020-02-19lib: Don't check MIDELEG and MEDELEG at end of delegate_traps()Anup Patel1-5/+0
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 <anup.patel@wdc.com> Reviewed-by: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Atish Patra <atish.patra@wdc.com>
2020-02-18lib: utils: htif: Fix 32-bit buildBin Meng1-3/+3
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 <bmeng.cn@gmail.com> Reviewed-by: Anup Patel <anup.patel@wdc.com>
2020-02-18Revert "lib: Use __builtin_ctzl() in pmp_get()"Anup Patel1-1/+13
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 <anup.patel@wdc.com>
2020-02-18doc: thead-c910: Fix doc stylesBin Meng1-3/+3
- make title underline the same length as the title itself - satisfy the 80 character per line rule as much as possible Signed-off-by: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Anup Patel <anup.patel@wdc.com>
2020-02-18doc: sifive_fu540: Fix doc stylesBin Meng1-8/+10
- make title underline the same length as the title itself - put all URLs at the end of the doc Signed-off-by: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Anup Patel <anup.patel@wdc.com>