Bin Meng [Tue, 18 Feb 2020 10:18:33 +0000 (02:18 -0800)]
platform: qemu: virt: Correct the typo in config.mk
It should be "aligned".
Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Anup Patel <anup.patel@wdc.com>
Bin Meng [Tue, 18 Feb 2020 10:15:59 +0000 (02:15 -0800)]
platform: sifive: fu540: Add 32-bit specific fdt/payload addresses
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>
Anup Patel [Tue, 18 Feb 2020 06:23:52 +0000 (11:53 +0530)]
lib: Print interrupt and exception delegation in boot prints
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>
Anup Patel [Tue, 18 Feb 2020 06:07:16 +0000 (11:37 +0530)]
lib: Don't check MIDELEG and MEDELEG at end of delegate_traps()
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>
Bin Meng [Tue, 18 Feb 2020 04:55:12 +0000 (20:55 -0800)]
lib: utils: htif: Fix 32-bit build
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>
Anup Patel [Tue, 18 Feb 2020 03:56:33 +0000 (09:26 +0530)]
Revert "lib: Use __builtin_ctzl() in pmp_get()"
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>
Bin Meng [Sun, 16 Feb 2020 15:19:39 +0000 (07:19 -0800)]
doc: thead-c910: Fix doc styles
- 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>
Bin Meng [Sun, 16 Feb 2020 15:19:38 +0000 (07:19 -0800)]
doc: sifive_fu540: Fix doc styles
- 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>
Bin Meng [Sun, 16 Feb 2020 15:19:37 +0000 (07:19 -0800)]
doc: qemu_virt: Fix doc styles
Remove the unnecessary blank line at the end of the doc.
Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Anup Patel <anup.patel@wdc.com>
Bin Meng [Sun, 16 Feb 2020 15:19:36 +0000 (07:19 -0800)]
doc: ariane-fpga: Fix doc styles
Various styles fixes including:
- satisfy the 80 character per line rule as much as possible
- make title underline the same length as the title itself
- remove the redundant FPGA (was FPGA FPGA SoC)
Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Anup Patel <anup.patel@wdc.com>
Bin Meng [Sun, 16 Feb 2020 15:19:35 +0000 (07:19 -0800)]
doc: andes-ae350: Fix doc styles
Various styles fixes including:
- satisfy the 80 character per line rule as much as possible
- remove unnecessary spaces between words
Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Anup Patel <anup.patel@wdc.com>
Bin Meng [Sun, 16 Feb 2020 15:19:34 +0000 (07:19 -0800)]
doc: payload_linux: Fix doc styles
Remove the unnecessary blank line at the end of the doc.
Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Anup Patel <anup.patel@wdc.com>
Bin Meng [Sun, 16 Feb 2020 15:19:33 +0000 (07:19 -0800)]
doc: coreboot: Fix doc styles
- put all URLs at the end of the doc
- 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>
Bin Meng [Sun, 16 Feb 2020 15:19:32 +0000 (07:19 -0800)]
ThirdPartyNotices: Fix doc styles
Remove the unnecessary blank line at the end of the doc.
Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Anup Patel <anup.patel@wdc.com>
Anup Patel [Thu, 13 Feb 2020 12:10:17 +0000 (17:40 +0530)]
docs: platform: Add documentation for Spike platform
This patch adds documentation to build and run OpenSBI on
Spike simulator and QEMU Spike machine.
Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Anup Patel [Thu, 13 Feb 2020 11:35:15 +0000 (17:05 +0530)]
scripts: Add Spike to platform list of binary archive script
The Spike platform support works perfectly fine on QEMU RV64 Spike
machine and Spike emulator.
Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Anup Patel [Thu, 13 Feb 2020 11:32:41 +0000 (17:02 +0530)]
platform: Remove stale options from config.mk files
This patch removes stale options from config.mk files of
Ariane FPGA and QEMU virt platform support.
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>
James Clarke [Sat, 1 Feb 2020 01:07:51 +0000 (01:07 +0000)]
platform: Add Spike initial support
This patch adds initial platform support Spike emulator.
Signed-off-by: James Clarke <jrtc27@jrtc27.com>
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>
Atish Patra [Wed, 12 Feb 2020 01:42:50 +0000 (17:42 -0800)]
lib: irqchip/plic: Disable all contexts and IRQs
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 <anup.patel@wdc.com>
Signed-off-by: Atish Patra <atish.patra@wdc.com>
Atish Patra [Wed, 12 Feb 2020 01:39:45 +0000 (17:39 -0800)]
lib: Initialize out value in SBI calls
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 <atish.patra@wdc.com>
Reviewed-by: Anup Patel <anup.patel@wdc.com>
Li Jinpei [Tue, 11 Feb 2020 10:07:24 +0000 (15:37 +0530)]
lib: Use __builtin_ctzl() in pmp_get()
We should should __builtin_ctzl() in pmp_get() instead of
custom ctz() function.
Signed-off-by: Li Jinpei <leekingp1994@163.com>
Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
Li Jinpei [Tue, 11 Feb 2020 09:57:49 +0000 (15:27 +0530)]
lib: sbi_scratch: use bitwise ops in sbi_scratch_alloc_offset()
Instead of using loop to make "size" machine word aligned, we should
use bitwise ops.
Signed-off-by: Li Jinpei <leekingp1994@163.com>
Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
Bin Meng [Mon, 10 Feb 2020 15:42:03 +0000 (07:42 -0800)]
doc: sifive: fu540: Update QEMU instruction when using U-Boot as the payload
Document that when U-Boot v2020.01 (or higher) is used as the payload,
we need adjust the instructions a little bit when testing OpenSBI with
QEMU 'sifive_u' machine.
Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
Bin Meng [Thu, 6 Feb 2020 12:15:21 +0000 (04:15 -0800)]
platform: sifive: fu540: Add platform specific 'make run' cmd
This adds sifive/fu540 specific QEMU run command.
Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Anup Patel <anup.patel@wdc.com>
Bin Meng [Thu, 6 Feb 2020 11:51:23 +0000 (03:51 -0800)]
platform: Drop qemu/sifive_u support
With QEMU v4.2 RISC-V changes to improve the emulation fidelity
of 'sifive_u' machine, OpenSBI v0.4 / U-Boot v2019.10 / Linux
kernel v5.3 images built for the SiFive HiFive Unleashed board
can be used out of the box without any special hack. Hence there
is no need for us to continue supporting such a special target in
OpenSBI. Going forward, sifive/fu540 platform can be used on both
real hardware and QEMU 'sifive_u' machine.
Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Anup Patel <anup.patel@wdc.com>
Alex Richardson [Thu, 6 Feb 2020 04:27:34 +0000 (09:57 +0530)]
makefile: add support for building on macOS
On macOS the readlink command does not include a -f flag. Instead default
to using GNU readlink (which is often installed as greadlink).
Signed-off-by: Alex Richardson <Alexander.Richardson@cl.cam.ac.uk>
Signed-off-by: Anup Patel <anup.patel@wdc.com>
Atish Patra [Tue, 4 Feb 2020 23:09:15 +0000 (15:09 -0800)]
platform: sifive/fu540: Set tlb range flush limit to zero
It was reported that tlb range flush is not working on fu540.
Only tlb full flush seems to work on fu540 probably due to some
hardware errata.
Set the tlb flush limit to zero so that all tlb flush requests
are converted to full flush.
Signed-off-by: Atish Patra <atish.patra@wdc.com>
Reviewed-by: Anup Patel <anup.patel@wdc.com>
Atish Patra [Tue, 4 Feb 2020 23:09:14 +0000 (15:09 -0800)]
platform: Add an platform ops to return platform specific tlb flush limit
If a platform requires to perform a tlb full flush, they should set
the tlb_range_flush_limit value to zero. However, corresponding platform
API ignore the value and continue to return the default value.
Add a platform ops to retrieve platform specific tlb range flush limit.
The platform variable becomes redundant in presence of the platform ops.
Take this opportunity to remove the variable as well.
The default is still set to smallest page size in RISC-V (4KB), as there
is no way to figure out a best value for all platforms. Individual platform
should set it to the optimal value for their platform.
Signed-off-by: Atish Patra <atish.patra@wdc.com>
Reviewed-by: Anup Patel <anup.patel@wdc.com>
Nikita Ermakov [Fri, 24 Jan 2020 13:47:32 +0000 (16:47 +0300)]
platform: Update UART base addresses for qemu/sifve_u
In the QEMU [1] there was a change of the UART base addresses for
sifive_u machine to match the hardware. Make corresponding changes in
the opensbi for qemu/sifive_u platform.
[1] https://git.qemu.org/?p=qemu.git;a=commitdiff;h=
4b55bc2b5f7ff065da5d2b813ee5153c598d3764
Signed-off-by: Nikita Ermakov <coffe92@gmail.com>
Reviewed-by: Anup Patel <anup.patel@wdc.com>
Jiuyang Liu (Sequencer) [Fri, 24 Jan 2020 02:04:10 +0000 (07:34 +0530)]
platform: template: typo fix in system reboot/shutdown names
This patch does minor typo fix in system reboot/shutdown names
in platform operations.
Signed-off-by: Jiuyang Liu (Sequencer) <liujiuyang1994@gmail.com>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Signed-off-by: Anup Patel <anup.patel@wdc.com>
Anup Patel [Fri, 17 Jan 2020 13:55:24 +0000 (19:25 +0530)]
lib: Factor-out SBI base extension
This patch factor-out SBI base extension into its own source
for better modularity of SBI implementation.
Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
Anup Patel [Fri, 17 Jan 2020 13:42:52 +0000 (19:12 +0530)]
lib: Factor-out SBI vendor extension
This patch factor-out SBI vendor extension into its own source
for better modularity of SBI implementation.
Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
Anup Patel [Fri, 17 Jan 2020 13:02:07 +0000 (18:32 +0530)]
lib: Factor-out SBI replacement extensions
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 <anup.patel@wdc.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
Anup Patel [Fri, 17 Jan 2020 12:39:49 +0000 (18:09 +0530)]
lib: Factor-out SBI legacy extension
This patch factor-out SBI legacy extension into its own source
for better modularity of SBI implementation.
Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
Anup Patel [Thu, 16 Jan 2020 06:08:49 +0000 (11:38 +0530)]
lib: Add dynamic registration of SBI extensions
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 <anup.patel@wdc.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
Anup Patel [Fri, 17 Jan 2020 11:12:41 +0000 (16:42 +0530)]
include: Add generic and simple list handling APIs
This patch adds generic and simple list handling APIs adapted
from Xvisor sources.
Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
Anup Patel [Wed, 15 Jan 2020 08:01:12 +0000 (13:31 +0530)]
lib: Initialize TLB management directly from coldboot/warmboot path
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 <anup.patel@wdc.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
Anup Patel [Wed, 15 Jan 2020 07:51:47 +0000 (13:21 +0530)]
lib: Drop _fifo from the name of various sbi_tlb_fifo_xyz() functions
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 <anup.patel@wdc.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
Anup Patel [Wed, 15 Jan 2020 07:14:10 +0000 (12:44 +0530)]
lib: Introduce sbi_ipi_event_create/destroy() APIs
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 <anup.patel@wdc.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
Anup Patel [Wed, 15 Jan 2020 06:12:51 +0000 (11:42 +0530)]
lib: Introduce sbi_tlb_fifo_request() API
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 <anup.patel@wdc.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
Anup Patel [Wed, 15 Jan 2020 05:46:54 +0000 (11:16 +0530)]
lib: Introduce sbi_ipi_send_halt() API
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 <anup.patel@wdc.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
Anup Patel [Wed, 15 Jan 2020 05:32:14 +0000 (11:02 +0530)]
lib: Introduce sbi_ipi_send_smode() API
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 <anup.patel@wdc.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
Anup Patel [Wed, 15 Jan 2020 05:18:56 +0000 (10:48 +0530)]
lib: Move struct sbi_ipi_data definition to sbi_ipi.c
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 <anup.patel@wdc.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
Anup Patel [Wed, 15 Jan 2020 05:15:45 +0000 (10:45 +0530)]
include: Typo fix in comment for SBI_SCRATCH_SIZE define
This patch fixes a minor typo in comment for SBI_SCRATCH_SIZE define.
Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
Liu Yibin [Sun, 19 Jan 2020 07:31:02 +0000 (15:31 +0800)]
scripts: Add C910 to platform list in the binary archive script
This patch adds T-HEAD C910 to RV64 platform list in the binary
archive script.
Signed-off-by: Liu Yibin <yibin_liu@c-sky.com>
Reviewed-by: Anup Patel <anup.patel@wdc.com>
Liu Yibin [Mon, 13 Jan 2020 03:20:57 +0000 (11:20 +0800)]
platform: thead/c910: Don't set plic/clint address in warm boot
Since all harts share the same plic/clint address now, setting
them during cold boot is just fine.
Signed-off-by: Liu Yibin <yibin_liu@c-sky.com>
Reviewed-by: Anup Patel <anup.patel@wdc.com>
Liu Yibin [Mon, 13 Jan 2020 03:20:56 +0000 (11:20 +0800)]
platform: thead/c910: Don't enable L2 cache in warm boot
Since all harts share the same L2 cache now, there's
no need to Enable L2 cache in warm boot.
Signed-off-by: Liu Yibin <yibin_liu@c-sky.com>
Reviewed-by: Anup Patel <anup.patel@wdc.com>
Andreas Schwab [Thu, 9 Jan 2020 11:49:38 +0000 (12:49 +0100)]
firmware: Fix placement of .align directives
Move the .align directives after switching the section. We want to align
the start of the current section, not the end of the previous section.
This also obsoletes the misguided workaround of disabling relaxation.
Signed-off-by: Andreas Schwab <schwab@suse.de>
Reviewed-by: Anup Patel <anup.patel@wdc.com>
Anup Patel [Wed, 8 Jan 2020 04:06:09 +0000 (09:36 +0530)]
docs: platform: Update SiFive FU540 doc as-per U-Boot v2020.01
With U-Boot v2020.01, the SiFive FU540 DTB required by U-Boot is
embedded in U-Boot binary itself so we don't need to do anything
special for U-Boot v2020.01 as payload to OpenSBI firmware.
This patch updates SiFive FU540 documenation assuming we use
latest U-Boot v2020.01 release.
Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Liu Yibin [Wed, 8 Jan 2020 06:50:35 +0000 (14:50 +0800)]
platform: thead/c910: Remove SBI_PLATFORM_HAS_PMP
T-head c910 is a generic FPGA platform so we cannot
define PMP configuration for it in OpenSBI because
PMP configuration tend to be SOC specific.
Signed-off-by: Liu Yibin <yibin_liu@c-sky.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
Abner Chang [Wed, 8 Jan 2020 04:54:34 +0000 (12:54 +0800)]
docs: Add description of using OPENSBI_EXTERNAL_SBI_TYPES
Add description of using OPENSBI_EXTERNAL_SBI_TYPES in external
firmware code base.
Signed-off-by: Abner Chang <abner.chang@hpe.com>
Cc: Leif Lindholm <leif.lindholm@linaro.org>
Reviewed-by: Anup Patel <anup.patel@wdc.com>
Abner Chang [Tue, 7 Jan 2020 07:08:26 +0000 (15:08 +0800)]
include: Add OPENSBI_EXTERNAL_SBI_TYPES in sbi_types.h
Add OPENSBI_EXTERNAL_SBI_TYPES macro to allow external definitions of data
types and common macros. Also move some common definitions from sbi_bits.h to sbi_types.h.
Signed-off-by: Abner Chang <abner.chang@hpe.com>
Cc: Leif Lindholm <leif.lindholm@linaro.org>
Reviewed-by: Anup Patel <anup.patel@wdc.com>
Khem Raj [Tue, 7 Jan 2020 02:41:06 +0000 (18:41 -0800)]
build: Use -ffreestanding
this is a stand-alone/baremetal application, therefore demanding
-ffreestanding would help it compile with hosted toolchains e.g. ( linux
toolchains ), it also ensures that it won't be using platform
optimizations like inlining mem* str* functions which gcc might decide
especially with wrapper string functions in opensbi code
Signed-off-by: Khem Raj <raj.khem@gmail.com>
Reviewed-by: Anup Patel <anup.patel@wdc.com>
Anup Patel [Fri, 3 Jan 2020 09:43:33 +0000 (15:13 +0530)]
lib: Add sbi_init_count() API
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 <anup@brainfault.org>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
Anup Patel [Fri, 3 Jan 2020 09:25:04 +0000 (14:55 +0530)]
lib: zero-out memory allocated using sbi_scratch_alloc_offset()
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 <anup@brainfault.org>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
Anup Patel [Fri, 3 Jan 2020 05:47:44 +0000 (11:17 +0530)]
lib: improve system reboot and shutdown implementation
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 <anup.patel@wdc.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
Anup Patel [Fri, 3 Jan 2020 05:44:21 +0000 (11:14 +0530)]
lib: do sbi_exit() upon halt IPI
Instead of doing sbi_hang() we should do sbi_exit() upon
halt IPI.
Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
Anup Patel [Fri, 3 Jan 2020 04:50:12 +0000 (10:20 +0530)]
lib: save/restore MIE CSR in sbi_hart_wait_for_coldboot()
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 <anup.patel@wdc.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
Anup Patel [Fri, 3 Jan 2020 04:21:58 +0000 (09:51 +0530)]
lib: Add irqchip exit API
We add an optional platform irqchip exit hook for exit path handling
in sbi_exit() implementation.
Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
Anup Patel [Fri, 3 Jan 2020 04:09:10 +0000 (09:39 +0530)]
lib: Add ipi exit API
We add sbi_ipi_exit() API for exit path handling in sbi_exit()
implementation.
Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
Anup Patel [Fri, 3 Jan 2020 03:48:42 +0000 (09:18 +0530)]
lib: Add timer exit API
We add sbi_timer_exit() API for OpenSBI exit path handling in
sbi_exit() implementation.
Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
Anup Patel [Fri, 3 Jan 2020 03:40:41 +0000 (09:10 +0530)]
lib: Add system early_exit and final_exit APIs
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 <anup.patel@wdc.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
Anup Patel [Fri, 3 Jan 2020 03:19:23 +0000 (08:49 +0530)]
lib: Add initial sbi_exit() API
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 <anup.patel@wdc.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
Anup Patel [Fri, 3 Jan 2020 03:04:51 +0000 (08:34 +0530)]
lib: Remove unnecessary checks from init_coldboot() and init_warmboot()
We remove unnecessary checks related to hart hotplug and disabled
hart in coldboot and warmboot init path.
Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
Liu Yibin [Thu, 2 Jan 2020 04:21:36 +0000 (12:21 +0800)]
platform: Add T-head C910 initial support
This commit provides basic support for the Thead/C910 platform.
Signed-off-by: Liu Yibin <yibin_liu@c-sky.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
Reviewed-by: Anup Patel <anup.patel@wdc.com>
Anup Patel [Mon, 30 Dec 2019 06:01:59 +0000 (11:31 +0530)]
lib: utils: Support CLINT with 32bit MMIO access on RV64 system
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 <anup.patel@wdc.com>
Reviewed-by: Atish Patra<atish.patra@wdc.com>
Reviewed-by: Zong Li <zong.li@sifive.com>
Liu Yibin [Sun, 29 Dec 2019 07:47:51 +0000 (15:47 +0800)]
docs: Improve docs for FDT address passing
This patch updates FW_JUMP and FW_PAYLOAD documentation for the
case where FW_xyz_FDT_ADDR is not specified.
Signed-off-by: Liu Yibin <yibin_liu@c-sky.com>
Reviewed-by: Anup Patel <anup.patel@wdc.com>
Anup Patel [Fri, 27 Dec 2019 03:24:24 +0000 (08:54 +0530)]
firmware: Improve comments for fw_prev_arg1() and fw_next_arg1()
The state of a0, a1, and a2 registers in fw_prev_arg1() and
fw_next_arg1() is same as passed by previous booting stage
so we add this info in comments for both these functions.
Signed-off-by: Anup Patel <anup.patel@wdc.com>
Liu Yibin [Thu, 26 Dec 2019 09:38:55 +0000 (17:38 +0800)]
firmware: Return real DTB address when FW_xyz_FDT_ADDR is not defined
Function fw_next_arg1 in firmware/fw_jump.S:59 and
firmware/fw_payload.S:63 should return real dtb
address(if specified in a1) in a0, in case we don't
want to specify FW_xyz_FDT_ADDR when compiling.
Signed-off-by: Liu Yibin <yibin_liu@c-sky.com>
Reviewed-by: Anup Patel <anup.patel@wdc.com>
Atish Patra [Mon, 25 Nov 2019 07:33:50 +0000 (23:33 -0800)]
lib: Implement RFENCE extension
This patch adds RFENCE extension support in OpenSBI.
Signed-off-by: Atish Patra <atish.patra@wdc.com>
Reviewed-by: Anup Patel <anup.patel@wdc.com>
Atish Patra [Mon, 25 Nov 2019 07:33:49 +0000 (23:33 -0800)]
lib: Support stage1 and stage2 tlb flushing
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 <atish.patra@wdc.com>
Reviewed-by: Anup Patel <anup.patel@wdc.com>
Atish Patra [Mon, 25 Nov 2019 07:33:48 +0000 (23:33 -0800)]
lib: Add hfence instruction encoding
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 <atish.patra@wdc.com>
Reviewed-by: Anup Patel <anup.patel@wdc.com>
Atish Patra [Mon, 25 Nov 2019 07:33:47 +0000 (23:33 -0800)]
lib: Add IPI extension in SBI
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 <atish.patra@wdc.com>
Reviewed-by: Anup Patel <anup.patel@wdc.com>
Atish Patra [Mon, 25 Nov 2019 07:33:46 +0000 (23:33 -0800)]
lib: Add TIME extension in SBI
This patch adds support for TIME extension which replaces v0.1
timer extension.
Signed-off-by: Atish Patra <atish.patra@wdc.com>
Reviewed-by: Anup Patel <anup.patel@wdc.com>
Atish Patra [Mon, 25 Nov 2019 07:33:45 +0000 (23:33 -0800)]
lib: Remove redundant IPI types
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 <atish.patra@wdc.com>
Reviewed-by: Anup Patel <anup.patel@wdc.com>
Atish Patra [Mon, 25 Nov 2019 07:33:44 +0000 (23:33 -0800)]
lib: Add replacement extension and function ids
Take this opportunity to move the enums to macros as enums make
sbi_ecall_interface.h unusable in assembly files.
Signed-off-by: Atish Patra <atish.patra@wdc.com>
Reviewed-by: Anup Patel <anup.patel@wdc.com>
Anup Patel [Thu, 12 Dec 2019 17:21:42 +0000 (22:51 +0530)]
lib: Use MTINST CSR in misaligned load/store emulation
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 <anup.patel@wdc.com>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Anup Patel [Thu, 12 Dec 2019 16:53:30 +0000 (22:23 +0530)]
lib: Extend trap redirection for hypervisor v0.5 spec
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 <anup.patel@wdc.com>
Anup Patel [Thu, 12 Dec 2019 02:01:38 +0000 (07:31 +0530)]
lib: Fix sbi_get_insn() for load guest page fault
We should treat load guest page fault in sbi_get_insn() as
fetch guest patch fault.
Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Anup Patel [Thu, 12 Dec 2019 01:52:03 +0000 (07:22 +0530)]
include: Extend struct sbi_trap_info for mtval2 and mtinst
We have two new trap CSRs namely mtval2 and mtinst when
RISC-V hypervisor extension is available hence we extend
struct sbi_trap_info accordingly.
Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Anup Patel [Thu, 12 Dec 2019 01:30:59 +0000 (07:00 +0530)]
lib: Delegate guest page faults to HS-mode
As-per RISC-V hypervisor v0.5 spec, we have new guest page faults
which need to be delegated to HS-mode.
Also, we can have bits in in MIDELEG and MEDELEG hardwired to 1
which means we need to fix the sainty check on these CSRs at the
end of delegate_traps() function.
Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Anup Patel [Thu, 12 Dec 2019 17:35:03 +0000 (23:05 +0530)]
include: Add guest external interrupt related defines
With RISC-V H-extension v0.5 draft, we have special support for guest
external interrupts so this patch adds related defines which were
missed-out previously.
Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Martin Pietryka [Wed, 4 Dec 2019 06:25:51 +0000 (07:25 +0100)]
include: sbi_platform: fix compilation for GCC-9
GCC-9 will throw a warning when using the %s format specifier with a
possible NULL parameter and since -Werror is used, the compilation breaks
for GCC-9.
In function 'sbi_boot_prints',
inlined from 'init_coldboot' at <redacted>/opensbi/lib/sbi/sbi_init.c:107:3,
inlined from 'sbi_init' at <redacted>/opensbi/lib/sbi/sbi_init.c:189:3:
<redacted>/opensbi/lib/sbi/sbi_init.c:56:2: error: '%s' directive argument is null [-Werror=format-overflow=]
56 | sbi_printf("Platform Name : %s\n", sbi_platform_name(plat));
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
This is one way to fix this, currently there is nothing in the tree
checking for `sbi_platfrom_name() == NULL` so we can just return "Unknown"
instead of NULL on failure.
Signed-off-by: Martin Pietryka <martin@pietryka.at>
Reviewed-by: Anup Patel <anup.patel@wdc.com>
Tested-by: David Abdurachmanov <david.abdurachmanov@sifive.com>
Xiang W [Wed, 27 Nov 2019 06:16:52 +0000 (14:16 +0800)]
lib: Add error detection for misa_extension
Add assertions for misa_extension to prevent incoming illegal
characters.
Signed-off-by: Xiang Wang <merle@hardenedlinux.org>
Reviewed-by: Anup Patel <anup.patel@wdc.com>
Atish Patra [Tue, 26 Nov 2019 03:24:29 +0000 (19:24 -0800)]
lib: Fix probe extension
The break statement is missing in base extension function handling.
Fix the typo.
Signed-off-by: Atish Patra <atish.patra@wdc.com>
Reviewed-by: Xiang Wang <merle@hardenedlinux.org>
Reviewed-by: Anup Patel <anup.patel@wdc.com>
Xiang Wang [Tue, 26 Nov 2019 10:36:29 +0000 (16:06 +0530)]
lib: Fix CPU capabilities detection function
On some platforms, misa may not be implemented. On such a platform,
reading misa will get 0. At this time, platform is required to
implement a non-standard function to detect the CPU's capabilities.
Therefore, this modification add interfaces for non-standard function.
The MXL field of misa is always at the highest two bits, whether it
is a 32-bit 64-bit or a 128-bit machine. Therefore, this modification
fixes the use of a fixed offset to detect the machine length.
Signed-off-by: Xiang Wang <merle@hardenedlinux.org>
Signed-off-by: Anup Patel <anup.patel@wdc.com>
Anup Patel [Sun, 17 Nov 2019 09:55:41 +0000 (15:25 +0530)]
lib: Simplify trap parameters in sbi_ecall functions
The out_tcause and out_tval parameters are not sufficient for most
sbi_ecall functions because this will grow in-future when we support
RISC-V hypervisor v0.5 draft. We replace these parameters with out_trap
which is a pointer to struct sbi_trap_info.
Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
Anup Patel [Sun, 17 Nov 2019 08:46:24 +0000 (14:16 +0530)]
lib: Better naming of unpriv APIs for wider use
The unpriv APIs can be useful to external firmware and out-of-tree
platform support code.
This patch adds "sbi_" prefix to unpriv load/store APIs and rename
struct riscv_unpriv to struct sbi_trap_info everywhere. We also
place struct sbi_trap_info in sbi/sbi_trap.h so that we can use
it for sbi_trap_redirect() as well.
Overall, this patch will make naming of unpriv APIs consistent
with other OpenSBI APIs.
Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
Anup Patel [Sat, 16 Nov 2019 11:08:53 +0000 (16:38 +0530)]
lib: No need to set VSSTATUS.MXR bit in get_insn()
We don't need to set VSSTATUS.MXR bit in get_insn() for
unpriv instruction read because MSTATUS.MXR bit applies
to both "Stage1" and "Stage2" page tables.
This also allows us to remove the "virt" parameter of
get_insn() function.
Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
Anup Patel [Sat, 16 Nov 2019 10:38:27 +0000 (16:08 +0530)]
include: Remove ilen member of struct unpriv_trap
We simplify struct unpriv_trap by removing ilen member. This
can be achieved by ensuring that at all unpriv load/store
instructions are 4 bytes long using GCC assembler option.
Additionally, this also reduces few instructions from unpriv
load/store functions.
Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
Alistair Francis [Tue, 12 Nov 2019 00:40:34 +0000 (16:40 -0800)]
lib: Remove date and time from init message
Building the date and time into the binary means the OpenSBI isn't
reproducible. We don't really need the time so let's remove it.
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
Reviewed-by: Anup Patel <anup.patel@wdc.com>
Anup Patel [Wed, 6 Nov 2019 10:54:35 +0000 (16:24 +0530)]
firmware: Add preferred boot HART field in struct fw_dynamic_info
It has been reported that link address range of previous booting stage
(such as U-Boot SPL) can overlap the link address rage of FW_DYNAMIC.
This means self-relocation in FW_DYNAMIC can potentially corrupt
previous booting stage if any of the secondary HART enter FW_DYNAMIC
before primary HART.
To tackle this, we add preferred boot HART field (i.e boot_hart) in
struct fw_dyanmic_info. We use this field to force secondary HARTs
into relocation wait loop till preferred/primary boot HART enters
FW_DYNAMIC completes self-relocation. If preferred boot HART is not
available then we fall back to relocation lottery approach.
Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
Anup Patel [Tue, 5 Nov 2019 06:12:09 +0000 (11:42 +0530)]
include: Use _UL() and _ULL() for defines in riscv_encoding.h
The riscv_encoding.h is shared with assembly sources so we use
_UL() and _ULL() for register fields related defines.
Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
Anup Patel [Tue, 5 Nov 2019 06:02:57 +0000 (11:32 +0530)]
include: Sync-up encoding with priv v1.12-draft and hypervisor v0.5-draft
This patch sync-up encoding header with the latest privilege
specifications draft v1.12 and hypervisor specifications draft v0.5.
The MSTATUS.MTL and HSTATUS.STL bits are not present anymore and
will be removed by another patch series for hypervisor v0.5-draft.
Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
Anup Patel [Thu, 31 Oct 2019 08:41:55 +0000 (14:11 +0530)]
firmware: Introduce relocation lottery
Instead of forcing HART0 to do the relocation and scratch init
work, we should have an atomic lottery to decide which HART does
the relocation and scratch init.
This way any HART can be boot/main HART.
Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
Anup Patel [Wed, 23 Oct 2019 07:14:14 +0000 (12:44 +0530)]
firmware: Fix compile error for FW_PAYLOAD with latest GCC binutils
We get following compile error for FW_PAYLOAD with latest GCC
binutils:
fw_payload.o(.text+0x1961): 15 bytes required for alignment to 16-byte
boundary, but only 14 present
Further investigating, it turn-out to be a known issue with RISC-V
GCC binutils.
(Refer, https://github.com/riscv/riscv-gnu-toolchain/issues/298)
As a work-around, we disable relaxation when including DTB and
PAYLOAD binary in fw_payload.S.
Reported-by: David Abdurachmanov <david.abdurachmanov@sifive.com>
Signed-off-by: Anup Patel <anup.patel@wdc.com>
Tested-by: David Abdurachmanov <david.abdurachmanov@sifive.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
Anup Patel [Wed, 9 Oct 2019 06:03:53 +0000 (11:33 +0530)]
include: Bump-up version to 0.5
This patch updates OpenSBI version to 0.5 as part of
release preparation.
Signed-off-by: Anup Patel <anup.patel@wdc.com>
Atish Patra [Wed, 2 Oct 2019 20:59:40 +0000 (13:59 -0700)]
lib: Provide a platform hook to implement vendor specific SBI extensions.
SBI v0.2 specification allows vendor extensions and it should be
implemented in a independent of the core sbi library.
Introduce a single platform callback that will let platforms handle
all vendor extensions in platform specific code if they want.
Signed-off-by: Atish Patra <atish.patra@wdc.com>
Reviewed-by: Anup Patel <anup.patel@wdc.com>
Atish Patra [Wed, 2 Oct 2019 20:59:39 +0000 (13:59 -0700)]
lib: Implement SBI v0.2
SBI v0.2 introduces a base specification which is mandatory to
implement for any SBI implementations that is not legacy.
Add support for the base extension.
Signed-off-by: Atish Patra <atish.patra@wdc.com>
Reviewed-by: Anup Patel <anup.patel@wdc.com>
Atish Patra [Wed, 2 Oct 2019 20:59:38 +0000 (13:59 -0700)]
lib: Remove redundant variable assignment
An ecall handler should only return error if valid SBI function
fails. Otherwise, it should succeed with appropriate error in a0.
Get rid of unnecessary setting of the temporary return variable to
zero for the cases where errors are not expected.
Signed-off-by: Atish Patra <atish.patra@wdc.com>
Reviewed-by: Anup Patel <anup.patel@wdc.com>