Atish Patra [Sat, 9 May 2020 23:47:29 +0000 (16:47 -0700)]
platform: fpga: Remove redundant platform specific features
Any platform feature that belongs to a hart, have already been moved to
hart features and are detected at run time. The remaining platform features
are identical to platform default features.
Use the platform default features instead of defining a separate copy of it.
Signed-off-by: Atish Patra <atish.patra@wdc.com>
Tested-by: Jonathan Balkind <jbalkind@cs.princeton.edu>
Reviewed-by: Anup Patel <anup.patel@wdc.com>
Atish Patra [Sat, 9 May 2020 23:47:28 +0000 (16:47 -0700)]
platform: Move platform features to hart
PMP & performance counters belong to a hart rather than a platform.
In addition to that, these features enable reading/writing from a
particular csr. Thus, they can be detected and set at runtime rather
than compile time.
Move PMP/MCOUNTEREN/SCOUNTEREN features to hart and detect them at runtime.
Signed-off-by: Atish Patra <atish.patra@wdc.com>
Tested-by: Jonathan Balkind <jbalkind@cs.princeton.edu>
Reviewed-by: Anup Patel <anup.patel@wdc.com>
Atish Patra [Sat, 9 May 2020 23:47:27 +0000 (16:47 -0700)]
lib: Add support for hart specific features
There may be some features which are hart specific rather than a platform
specific feature. Add a framework to support that.
Signed-off-by: Atish Patra <atish.patra@wdc.com>
Tested-by: Jonathan Balkind <jbalkind@cs.princeton.edu>
Reviewed-by: Anup Patel <anup.patel@wdc.com>
Atish Patra [Sat, 9 May 2020 23:47:26 +0000 (16:47 -0700)]
lib: utils: Update reserved memory fdt node even if PMP is not present
As per RISC-V ISA, pmp is not mandatory. Currently, we only add reserved
memory node in DT only if PMP is present. That allows supervisor to access
the memory where OpenSBI continue to exist without realizing it for non-pmp
based platforms. It may result in corrupting OpenSBI. That's why OpenSBI
should at least let the supervisor know where it continue to exist.
This a best effort service provided by OpenSBI expecting that supervisor
software is not buggy and properly sets up its memory after parsing the
reserved-memory device tree node.
Signed-off-by: Atish Patra <atish.patra@wdc.com>
Reviewed-by: Anup Patel <anup.patel@wdc.com>
Atish Patra [Sat, 9 May 2020 23:47:25 +0000 (16:47 -0700)]
lib: Create a separate math helper function file
There may be few common mathematics helper functions which can be used
anywhere in OpenSBI project.
Add a separate math helper function file to add these functions.
Signed-off-by: Atish Patra <atish.patra@wdc.com>
Reviewed-by: Anup Patel <anup.patel@wdc.com>
Atish Patra [Sat, 9 May 2020 23:47:24 +0000 (16:47 -0700)]
lib: Add csr detect support
As RISC-V ISA allows many CSRs such as pmp, s/mcounteren to be optional
in hardware, OpenSBI should provide an option to dynamically detect
these csr access capability at run time.
Implement a csr read/write access check helper macros.
Signed-off-by: Atish Patra <atish.patra@wdc.com>
Tested-by: Jonathan Balkind <jbalkind@cs.princeton.edu>
Reviewed-by: Anup Patel <anup.patel@wdc.com>
Atish Patra [Sat, 9 May 2020 23:47:23 +0000 (16:47 -0700)]
lib: Rename unprivileged trap handler
Unprivileged trap handler can be reused for any cases where the executing
code expects a trap.
Rename it to "expected" trap handler as it will be used in other cases in
future.
Signed-off-by: Atish Patra <atish.patra@wdc.com>
Tested-by: Jonathan Balkind <jbalkind@cs.princeton.edu>
Reviewed-by: Anup Patel <anup.patel@wdc.com>
Anup Patel [Wed, 6 May 2020 06:57:38 +0000 (12:27 +0530)]
docs: Don't use italic text in page title
Doxygen does not support italic text in page title so fix
some of the markdown files accordingly.
Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
Anup Patel [Wed, 6 May 2020 06:46:48 +0000 (12:16 +0530)]
docs: Fix ordering of pages in table of contents
Currently, all markdown pages are randomly arranged in table of
contents so to fix this we treat top-level README.md as mainpage
and enable Doxygen TREEVIEW.
Also, there should not be any text before title of a markdown
page so we move project copyright as separate section in top-level
README.md.
Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
Anup Patel [Tue, 5 May 2020 04:16:46 +0000 (09:46 +0530)]
docs: Add platform requirements document
We add platform requirements document to clarify OpenSBI
expectations from a RISC-V platform.
Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
Reviewed-by: Bin Meng <bin.meng@windriver.com>
Anup Patel [Wed, 6 May 2020 04:42:11 +0000 (10:12 +0530)]
docs: platform/generic: Add details about IPI and timer expectations
The generic platform provides IPI and timer functionality based on
DT node provided in the FDT passed by previous booting stage. This
patch updates generic platform documentation about IPI and timer
expectations.
Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Bin Meng <bin.meng@windriver.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
Anup Patel [Tue, 5 May 2020 04:23:40 +0000 (09:53 +0530)]
docs: platform/generic: Add details about stdout-path DT property
The generic platform will try to select serial console based on the
stdout-path DT property in /chosen DT node hence we document this.
Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Bin Meng <bin.meng@windriver.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
Anup Patel [Tue, 5 May 2020 06:16:25 +0000 (11:46 +0530)]
lib: sbi: Improve misa_string() implementation
The RISC-V ISA string does not follow alphabetical order. Instead,
we have a RISC-V specific ordering of extensions in the RISC-V ISA
string. This patch improves misa_string() implementation to return
a valid RISC-V ISA string.
Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
Anup Patel [Mon, 4 May 2020 05:28:07 +0000 (10:58 +0530)]
lib: sbi_tlb: Fix remote TLB HFENCE VVMA implementation
The HFENCE VVMA instructions flushes TLB based on the VMID
present in HGATP CSR. To handle this, we get the current
VMID for SBI HFENCE VVMA call and we use this current VMID
to do remote TLB HFENCE VVMA on desired set of HARTs.
Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
Anup Patel [Wed, 6 May 2020 08:05:00 +0000 (13:35 +0530)]
include: sbi: Remove redundant page table related defines
We don't have page table programming in OpenSBI so let's remove
redundant page table related defines from riscv_encoding.h.
Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
Anup Patel [Fri, 1 May 2020 09:50:47 +0000 (15:20 +0530)]
docs: Add missing links in platform.md
The links to some of the platforms were missing in platform.md
file hence this patch.
Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Bin Meng <bin.meng@windriver.com>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Anup Patel [Fri, 1 May 2020 06:45:50 +0000 (12:15 +0530)]
platform: Remove spike directory
The OpenSBI generic platform works perfectly fine on the QEMU spike
machine and Spike emulator so let's remove dedicated Spike platform
from OpenSBI.
All Spike platform related documentation in OpenSBI will now suggest
using OpenSBI generic platform.
Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Bin Meng <bin.meng@windriver.com>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Anup Patel [Fri, 1 May 2020 06:36:56 +0000 (12:06 +0530)]
platform: Remove qemu/virt directory
The OpenSBI generic platform works perfectly fine on the QEMU virt
machine so let's remove dedicated QEMU virt machine platform from
OpenSBI.
All QEMU virt machine related documentation in OpenSBI will now
suggest using OpenSBI generic platform.
Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Bin Meng <bin.meng@windriver.com>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Anup Patel [Tue, 28 Apr 2020 04:05:32 +0000 (09:35 +0530)]
platform: generic: Add Sifive FU540 TLB flush range limit override
We need to override the remote TLB flush range limit for SiFive FU540
so we add platform override to achieve this.
Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
Anup Patel [Mon, 27 Apr 2020 13:02:19 +0000 (18:32 +0530)]
scripts: Add generic platform to create-binary-archive.sh
This patch adds generic platform to create-binary-archive.sh
script.
Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
Anup Patel [Sun, 26 Apr 2020 10:22:26 +0000 (15:52 +0530)]
lib: sbi: Print platform hart count at boot time
Now that we have generic platform which detects hart count from
DTB, we should print platform hart count at boot time.
Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
Anup Patel [Tue, 28 Apr 2020 03:53:30 +0000 (09:23 +0530)]
platform: Add generic FDT based platform support
We add generic FDT based platform support which provides platform
specific functionality based on the FDT passed by previous booting
stage.
By default, the generic FDT platform makes following assumptions:
1. platform FW_TEXT_START is 0x80000000
2. platform features are default
3. platform stack size is default
4. platform has no quirks or work-arounds
The above assumptions (except 1) can be overridden by adding special
platform callbacks which will be called based on the FDT root node
compatible string.
By default, we compile OpenSBI generic platform as follows:
$ make PLATFORM=generic
For a non-standard FW_TEXT_START, we can compile OpenSBI generic
platform as follows:
$ make PLATFORM=generic FW_TEXT_START=<non_standard_text_start>
Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
Anup Patel [Sun, 26 Apr 2020 09:01:28 +0000 (14:31 +0530)]
firmware: fw_base: Introduce optional fw_platform_init()
We add optional fw_platform_init() function which will allow
platform specific code to update "struct sbi_platform platform"
before it is used.
The fw_platform_init() can be a regular C function so before
callint it we:
1. zero-out BSS section
2. Setup temporary trap handler to catch bugs
3. Setup temporary stack pointer
Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
Anup Patel [Fri, 24 Apr 2020 11:32:48 +0000 (17:02 +0530)]
lib: utils: Add simple FDT reset framework
We add simple reset framework which will select and use reset driver
based on details in FDT passed by previous booting stage.
Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
Anup Patel [Fri, 24 Apr 2020 11:30:37 +0000 (17:00 +0530)]
lib: utils: Add simple FDT serial framework
We add simple serial framework which will select and use serial driver
based on details in FDT passed by previous booting stage.
Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
Anup Patel [Fri, 24 Apr 2020 11:26:33 +0000 (16:56 +0530)]
lib: utils: Add simple FDT irqchip framework
We add simple irqchip framework which will select and use irqchip driver
based on details in FDT passed by previous booting stage.
Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
Anup Patel [Fri, 24 Apr 2020 11:23:32 +0000 (16:53 +0530)]
lib: utils: Add simple FDT ipi framework
We add simple ipi framework which will select and use ipi driver
based on details in FDT passed by previous booting stage.
Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
Anup Patel [Fri, 24 Apr 2020 11:20:40 +0000 (16:50 +0530)]
lib: utils: Add simple FDT timer framework
We add simple timer framework which will select and use timer driver
based on details in FDT passed by previous booting stage.
Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
Anup Patel [Fri, 24 Apr 2020 13:07:10 +0000 (18:37 +0530)]
include: Add array_size() macro
Getting array size of a dynmaic array can be very handy hence
this patch.
Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Anup Patel [Wed, 29 Apr 2020 08:51:52 +0000 (14:21 +0530)]
lib: utils: Add fdt_parse_plic_node() function
We add fdt_parse_plic_node() function which will allow us to parse
a particular DT node as PLIC node. This will be useful in parsing
the DT node which we have found by matching compatible string.
Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
Anup Patel [Fri, 24 Apr 2020 09:38:19 +0000 (15:08 +0530)]
lib: utils: Add fdt_parse_max_hart_id() API
We add fdt_parse_max_hart_id() API which return max HART id based
on CPU DT nodes. This will be used by generic FDT based drivers in
subsequent patches.
Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Anup Patel [Sun, 26 Apr 2020 07:09:13 +0000 (12:39 +0530)]
lib: utils: Add fdt_parse_hart_id() function
Parsing HART id from a CPU DT node is a common requirement for
RISC-V systems. The newly added fdt_parse_hart_id() also helps
reduce duplicate code between fdt_cpu_fixup() function and
fdt_parse_hart_count() function.
Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Anup Patel [Sat, 25 Apr 2020 13:20:37 +0000 (18:50 +0530)]
lib: utils: Add fdt_parse_sifive_uart_node() function
We add fdt_parse_sifive_uart_node() function which will allow
us to parse a particular DT node as SiFive UART node. This will
be useful in parsing the node pointed by stdout-path.
Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
Anup Patel [Fri, 24 Apr 2020 13:05:25 +0000 (18:35 +0530)]
lib: utils: Make fdt_get_node_addr_size() public function
The fdt_get_node_addr_size() will be useful in FDT based simple
driver frameworks so we make it a public function.
Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Anup Patel [Fri, 24 Apr 2020 13:02:10 +0000 (18:32 +0530)]
lib: utils: Add FDT match table based node lookup
This patch adds FDT match table based node lookup funcitons.
These functions will be useful in implementing simple FDT
based driver frameworks.
Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
Anup Patel [Fri, 24 Apr 2020 11:11:06 +0000 (16:41 +0530)]
lib: utils: Rename fdt_parse_clint() to fdt_parse_compat_addr()
The fdt_parse_clint() is quite generic and can be used for other
types of devices so we rename it to fdt_parse_compat_addr().
Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
Anup Patel [Fri, 24 Apr 2020 10:52:45 +0000 (16:22 +0530)]
lib: utils: Remove redundant clint_ipi_sync() declaration
The clint_ipi_sync() was removed long time back hence we remove
redundant declaration from clint.h
Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
Anup Patel [Sat, 25 Apr 2020 13:03:54 +0000 (18:33 +0530)]
lib: utils: Add fdt_parse_uart8250_node() function
We add fdt_parse_uart8250_node() function which will allow us
to parse a particular DT node as UART 8250 node. This will be
useful in parsing the node pointed by stdout-path.
Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
Anup Patel [Fri, 24 Apr 2020 09:51:34 +0000 (15:21 +0530)]
lib: utils: Improve fdt_parse_uart8250() API
The information parsed by fdt_parse_uart8250() API is not complete.
We need to parse reg-shift and reg-io-width for UART 8520 as well.
Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Anup Patel [Sat, 25 Apr 2020 05:41:49 +0000 (11:11 +0530)]
lib: utils/serial: Skip baudrate config if input frequency is zero
We should skip baudrate config for UART8250 and SiFive UART when
input frequency is zero.
Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Charles Papon [Fri, 1 May 2020 03:58:38 +0000 (09:28 +0530)]
firmware: fw_base: Remove CSR_MTVEC update check
Remove unnecessary CSR_MTVEC read to reduce the openSBI CSR requirement.
Mux are costly in FPGA. Allowing CSR_MTVEC to be write only is usefull
for the FMax/Area of FPGA softcore.
https://github.com/SpinalHDL/opensbi.git branch mtvec
Signed-off-by: Charles Papon <charles.papon.90@gmail.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
Reviewed-by: Anup Patel <anup.patel@wdc.com>
Huaqi Fang [Wed, 29 Apr 2020 10:05:51 +0000 (18:05 +0800)]
scripts: adapt binary archive script for Nuclei UX600
Signed-off-by: Huaqi Fang <578567190@qq.com>
Reviewed-by: Anup Patel <anup.patel@wdc.com>
Huaqi Fang [Tue, 28 Apr 2020 14:43:40 +0000 (22:43 +0800)]
platform: Add Nuclei UX600 platform
* Nuclei UX600 is a 64-bit RISC-V core developed
by Nuclei System Technology, see https://nucleisys.com/product.php
* The ISA is configurable in hardware on your demand
Signed-off-by: Huaqi Fang <578567190@qq.com>
Reviewed-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Anup Patel [Fri, 24 Apr 2020 06:56:23 +0000 (12:26 +0530)]
lib: utils: Add SiFive test device
This patch factor-out SiFive test device related stuff into
it's own source file from qemu/virt platform. In future, we
can find SiFive test device address from device tree as well.
Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
Anup Patel [Fri, 24 Apr 2020 06:56:22 +0000 (12:26 +0530)]
include: sbi_platform: Combine reboot and shutdown into one callback
We can achieve shutdown, cold reboot, and warm reboot using just
one sbi_platform callback so we combine system_reboot() and
system_shutdown() callbacks into one system_reset() callback.
Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
Anup Patel [Thu, 23 Apr 2020 06:22:30 +0000 (11:52 +0530)]
lib: No need to provide default PMP region using platform callbacks
The default (usually last) PMP region provides S-mode access to
complete memory range not covered by other PMP regions.
Currently, the default PMP region is described as platform specific
PMP region which is not appropriate because all platforms need it
and default PMP region should be part of generic library.
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>
Anup Patel [Mon, 20 Apr 2020 10:58:42 +0000 (16:28 +0530)]
include: Bump-up version to 0.7
This patch updates OpenSBI version to 0.7 as part of
release preparation.
Signed-off-by: Anup Patel <anup.patel@wdc.com>
Anup Patel [Fri, 17 Apr 2020 09:40:10 +0000 (15:10 +0530)]
lib: Allow overriding SBI implementation ID
Ideally, the SBI implementation ID for OpenSBI should always be
0x1 (as mentioned in SBI v0.2 spec) but external firmware (such
as EDK2) which use OpenSBI as library might want to override the
SBI implementation ID with their custom implementation ID.
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 [Fri, 17 Apr 2020 01:56:31 +0000 (18:56 -0700)]
docs: Update README about supported SBI versions
Signed-off-by: Atish Patra <atish.patra@wdc.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Anup Patel <anup.patel@wdc.com>
Atish Patra [Fri, 17 Apr 2020 01:56:30 +0000 (18:56 -0700)]
lib: Support vector extension
Enable vector context in mstatus by updating the corresponding bits
in mstatus if vector extension is supported by the hart.
Signed-off-by: Atish Patra <atish.patra@wdc.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Anup Patel <anup.patel@wdc.com>
Atish Patra [Fri, 3 Apr 2020 18:13:08 +0000 (11:13 -0700)]
lib: irqchip/plic: Fix maximum priority threshold value
As per the PLIC specification, maximum priority threshold value is 0x7.
Even though, writing a higher value doesn't cause any error in qemu
hifive unleashed, there may be some implementation which checks the upper
and may result in an illegal access.
Signed-off-by: Atish Patra <atish.patra@wdc.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Anup Patel <anup.patel@wdc.com>
Liu Yibin [Fri, 27 Mar 2020 03:31:48 +0000 (11:31 +0800)]
platform: thead/c910: Use HSM extension to boot secondary cores
Remove custom vendor extension and use HSM extension
to boot secondary cores
Signed-off-by: Liu Yibin <yibin_liu@c-sky.com>
Reviewed-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Anup Patel [Fri, 27 Mar 2020 06:46:16 +0000 (12:16 +0530)]
include: sbi_console: Remove scratch parameter from sbi_dprintf()
This patch removes scratch parameter from sbi_dprintf() function
because sbi_dprintf() can use sbi_scratch_thishart_ptr() to get
current HART scratch space.
Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
Anup Patel [Fri, 27 Mar 2020 06:38:34 +0000 (12:08 +0530)]
include: sbi_timer: Remove scratch parameter from most funcitons
This patch removes scratch parameter from most sbi_timer functions.
Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
Anup Patel [Fri, 27 Mar 2020 06:13:37 +0000 (11:43 +0530)]
include: sbi_system: Remove scratch parameter and redundant functions
This patch removes scratch parameter and redundant functions from
sbi_system.
Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
Anup Patel [Fri, 27 Mar 2020 05:56:11 +0000 (11:26 +0530)]
include: sbi_ipi: Remove scratch parameter from most functions
This patch removes scratch parameter from most sbi_ipi functions.
Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
Anup Patel [Fri, 27 Mar 2020 05:28:47 +0000 (10:58 +0530)]
include: sbi_tlb: Remove scratch parameter from sbi_tlb_request()
The sbi_ipi_send_many() should get current HART scratch pointer
on it's own using eventually hence removing scratch parameter from
sbi_tlb_request().
Signed-off-by: Anup Patel <anup.patel@wdc.com>
Anup Patel [Thu, 26 Mar 2020 13:05:38 +0000 (18:35 +0530)]
lib: sbi_scratch: Introduce sbi_scratch_last_hartid() API
The patch adds sbi_scratch_last_hartid() API which returns
last HART id having a scratch space. We can use this new API
to optimize places where we iterate over HART id from 0 to
SBI_HARTMASK_MAX_BITS.
Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
Anup Patel [Thu, 26 Mar 2020 12:40:02 +0000 (18:10 +0530)]
include: Use more consistent name for atomic xchg() and cmpxchg()
We should remove the "arch_" prefix from atomic xchg() and cmpxchg()
function names to have consistent naming of all atomic functions.
Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
Anup Patel [Fri, 20 Mar 2020 11:14:38 +0000 (16:44 +0530)]
include: sbi_platform: Remove priv parameter from hart_start() callback
The priv parameter in hart_start() platform callback is redundant hence
we remove it.
Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
Anup Patel [Fri, 20 Mar 2020 03:23:35 +0000 (08:53 +0530)]
lib: sbi_trap: Simplify sbi_trap_handler() API
This patch simplify sbi_trap_handler() API as follows:
1. Remove current hartid local variable because sbi_trap_handler()
itself does not need it.
2. Remove scratch parameter because none of the functions directly
called by sbi_trap_handler() require it.
Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
Anup Patel [Thu, 19 Mar 2020 16:25:12 +0000 (21:55 +0530)]
lib: sbi_ecall: Remove mcause, scratch and hartid parameters
We remove mcause, scratch and hartid parameters from various
functions for ecall handling because we can always get current
HART id and current scratch pointer using just one CSR access.
Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
Anup Patel [Thu, 19 Mar 2020 16:00:02 +0000 (21:30 +0530)]
lib: sbi_misaligned_ldst: Remove mcause, scratch and hartid parameters
We remove mcause, scratch and hartid parameters from various functions
for misaligned load/store handling because we can always get current
HART id and current scratch pointer using just one CSR access.
Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
Anup Patel [Thu, 19 Mar 2020 14:24:32 +0000 (19:54 +0530)]
lib: sbi_illegal_insn: Remove mcause, scratch and hartid parameters
We remove mcause, scratch and hartid parameters from various
functions for illegal instruction handling because we can always
get current HART id and current scratch pointer using just one
CSR access.
Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
Anup Patel [Thu, 19 Mar 2020 14:16:00 +0000 (19:46 +0530)]
lib: sbi_emulate_csr: Remove scratch and hartid parameter
We remove scratch and hartid parameter from various functions
for CSR emulation because we can always get current HART id
and current scratch pointer using just one CSR access.
Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
Anup Patel [Thu, 19 Mar 2020 14:03:25 +0000 (19:33 +0530)]
lib: sbi_trap: Remove scratch parameter from sbi_trap_redirect()
The scratch parameter of sbi_trap_redirect() is not used hence we
remove it.
Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
Anup Patel [Thu, 19 Mar 2020 12:07:54 +0000 (17:37 +0530)]
lib: Remove scratch parameter from unpriv load/store functions
The scratch parameter of unpriv load/store functions is now redundant
hence we remove it.
Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
Anup Patel [Thu, 19 Mar 2020 11:43:16 +0000 (17:13 +0530)]
lib: Optimize unpriv load/store implementation
This patch optimize unpriv load/store implementation by having
dedicated unpriv trap handler (just like KVM RISC-V).
As a result of this optimization:
1. We have reduced roughly 13+ instruction in all unpriv load/store
functions. The reduced instruction also include two function calls.
2. Per-HART trap info pointer in scratch space is now redundant
hence removed.
3. The sbi_trap_handler() is now much cleaner because we don't have
to handle unpriv load/store traps.
Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
Anup Patel [Thu, 19 Mar 2020 05:53:41 +0000 (11:23 +0530)]
lib: utils: Improve fdt_cpu_fixup() implementation
Currently, the fdt_cpu_fixup() implementation assumes:
1. We have one CPU DT for each HART under /cpus DT node
2. The CPU DT nodes are named sequentially (i.e cpu@0,
cpu@1, ...) which is not true for discontinuous and
sparse HART ids (i.e. cpu@0, cpu@4, cpu@5). Generally,
CPU DT node are named based on HART id and not HART
index
If any of the above assumptions are violated then the
fdt_cpu_fixup() will not work.
This improves fdt_cpu_fixup() implementation and makes
it independent of above assumptions.
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, 24 Mar 2020 12:44:28 +0000 (18:14 +0530)]
scripts: Extend create-binary-archive.sh for unified binary tar ball
This patch extends/revamps create-binary-archive.sh to allow creating
unified binary tar ball containing both RV32 and RV64 images. Users
can also create "RV32 only" or "RV64 only" tar balls as well.
Few example commands are as follows:
./scripts/create-binary-archive.sh (Build both RV32 & RV64 images)
./scripts/create-binary-archive.sh -x 32 (Build RV32 only images)
./scripts/create-binary-archive.sh -x 64 (Build RV64 only images)
Signed-off-by: Anup Patel <anup.patel@wdc.com>
Xiang Wang [Tue, 24 Mar 2020 10:11:48 +0000 (10:11 +0000)]
lib: prevent coldboot_lottery from overflowing
HSM_STOP will trigger multiple executions of sbi_init, atomic_add_return may
trigger coldboot_lottery overflow
Signed-off-by: Xiang Wang <merle@hardenedlinux.org>
Reviewed-by: Anup Patel <anup.patel@wdc.com>
Atish Patra [Mon, 23 Mar 2020 19:48:59 +0000 (12:48 -0700)]
platform: openpiton: Read the device configurations from device tree
OpenPiton is designed to run on different FPGAs with different
configurations. Use the fdt parser to retrieve the required values
from device tree instead of using fixed values.
Signed-off-by: Atish Patra <atish.patra@wdc.com>
Tested-by: Jonathan Balkind <jbalkind@cs.princeton.edu>
Reviewed-by: Anup Patel <anup.patel@wdc.com>
Atish Patra [Mon, 23 Mar 2020 19:48:58 +0000 (12:48 -0700)]
lib: utils: Move fdt fixup helper routines to a different file
FDT helper file contain both fdt fixup and parsing functions.
Split the fixup related functions to a separate file for a better code
organization.
Signed-off-by: Atish Patra <atish.patra@wdc.com>
Reviewed-by: Anup Patel <anup.patel@wdc.com>
Atish Patra [Mon, 23 Mar 2020 19:48:57 +0000 (12:48 -0700)]
platform: fpga/common: Add a fdt parsing helper functions
Different DT based platforms from the sam family may reuse IP blocks with
different configurations. These different configurations can be obtained
by parsing the device tree.
Add a FDT parser framework that can parse various device configurations from
device tree. Currently, the parsing algorithms doesn't cover all the use cases
or possible combination of DT configurations. It will be improved over time.
Signed-off-by: Atish Patra <atish.patra@wdc.com>
Reviewed-by: Anup Patel <anup.patel@wdc.com>
Atish Patra [Mon, 23 Mar 2020 19:48:56 +0000 (12:48 -0700)]
platform: Add OpenPiton platform support
OpenPiton is a research platform from Princeton University [1].
"OpenPiton is the world's first open source, general purpose,
multithreaded manycore processor. It is a tiled manycore
framework scalable from one to 1/2 billion cores."
Add OpenSBI support for OpenPiton. As it is based on ariane core,
it reuses the platform code from arine project.
[1]. https://github.com/PrincetonUniversity/openpiton
Signed-off-by: Atish Patra <atish.patra@wdc.com>
Reviewed-by: Anup Patel <anup.patel@wdc.com>
Atish Patra [Mon, 23 Mar 2020 19:48:55 +0000 (12:48 -0700)]
platform: fpga/ariane: Remove redundant plic address macros
All the common PLIC specific macros are already defined in plic.c.
Remove it from platform code. While at it, Fix the other coding style
issues.
Signed-off-by: Atish Patra <atish.patra@wdc.com>
Reviewed-by: Anup Patel <anup.patel@wdc.com>
Atish Patra [Mon, 23 Mar 2020 19:48:54 +0000 (12:48 -0700)]
platform: Move ariane standalone fpga project to its own project
Signed-off-by: Atish Patra <atish.patra@wdc.com>
Reviewed-by: Anup Patel <anup.patel@wdc.com>
Atish Patra [Fri, 20 Mar 2020 22:10:36 +0000 (15:10 -0700)]
lib: Check MSIP bit after returning from WFI
Commit
71d2b837c46e (lib: Move all coldboot wait APIs to sbi_init.c)
caused a regression while moving the code from sbi_hart.c to sbi_init.c.
As per original commit text, WFI can be implemented as a NOP according
to the RISC-V privilege specification. Software should ensure that
relevant interrupt pending bits are set. Otherwise, loop back to WFI.
Fix the regression by applying the original patch to sbi_init.c.
Fixes:
71d2b837c46e ("lib: Move all coldboot wait APIs to sbi_init.c")
Signed-off-by: Atish Patra <atish.patra@wdc.com>
Reviewed-by: Anup Patel <anup.patel@wdc.com>
Xiang Wang [Thu, 19 Mar 2020 03:15:47 +0000 (03:15 +0000)]
lib: Fix sbi_ecall_register_extension to prevent extension IDs overlap
The original code does not prevent the following scenarios:
> sbi_ecall_register_extension(ext1); /* extension id (70-80) */
> sbi_ecall_register_extension(ext2); /* extension id (50-100) */
Signed-off-by: Xiang Wang <merle@hardenedlinux.org>
Reviewed-by: Anup Patel <anup.patel@wdc.com>
Anup Patel [Mon, 16 Mar 2020 04:59:34 +0000 (10:29 +0530)]
platform: sifive/fu540: Remove FU540_ENABLED_HART_MASK option
The FU540_ENABLED_HART_MASK compile time option was added for initial
bring-up on SiFive Unleashed. This option is redundant now because
disabled_hart_mask is already removed. Based on this rationale, we
remove FU540_ENABLED_HART_MASK compile time option.
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 [Sun, 15 Mar 2020 06:09:25 +0000 (11:39 +0530)]
include: sbi_platform: Introduce HART index to HART id table
A platform can have discontinuous and/or sparse HART ids so we
cannot always assume a set of HARTs with continuous HART ids.
This patch adds support for discontinuous and sparse HART ids by
introducing HART index to HART id table. This table has platform
hart_count entries and it maps HART index to HART id.
The HART index to HART id table has only two restrictions:
1. HART index < sbi_platform hart_count
2. HART id < SBI_HARTMASK_MAX_BITS
Example1:
Let's say we have a platform with 2 HART ids 11 and 22, for such a
a platform:
hart_count = 2
hart_index2id[0] = 11
hart_index2id[1] = 22
Example2:
Let's say we have a platform with 5 HARTs ids 0, 1, 2, 3, and 4
but out of these HART with id 0 is not usable so for such a platform:
hart_count = 5
hart_index2id[0] = -1U
hart_index2id[1] = 1
hart_index2id[2] = 2
hart_index2id[3] = 3
hart_index2id[4] = 4
OR
hart_count = 4
hart_index2id[0] = 1
hart_index2id[1] = 2
hart_index2id[2] = 3
hart_index2id[3] = 4
With HART index to HART id table in place, the hart_disabled()
callback is now redundant so we remove it as well.
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 [Sat, 14 Mar 2020 14:13:26 +0000 (19:43 +0530)]
lib: Don't use sbi_platform_hart_count() API
We don't need to use sbi_platform_hart_count() in sbi_init and
sbi_scratch because checking sbi_platform_hart_disabled() or
return value of sbi_hartid_to_scratch() is sufficient.
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 [Sat, 14 Mar 2020 13:56:22 +0000 (19:26 +0530)]
lib: sbi_hsm: Don't use sbi_platform_hart_disabled() API
Checking return value of sbi_hartid_to_scratch() is sufficient
so no need to explicitly check for disabled HART using the
sbi_platform_hart_disabled() 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>
Anup Patel [Wed, 18 Mar 2020 09:50:12 +0000 (15:20 +0530)]
lib: sbi_hsm: Remove scratch parameter from hart_started_mask() API
The scratch parameter in sbi_hsm_hart_started_mask() API is now
redundant hence removing it.
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 [Wed, 18 Mar 2020 09:43:06 +0000 (15:13 +0530)]
lib: sbi_hsm: Don't use sbi_platform_hart_count() API
We remove usage of sbi_platform_hart_count() API from sbi_hsm
so that discontinuous and sparse HART ids can be supported.
Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Anup Patel [Sat, 14 Mar 2020 13:51:24 +0000 (19:21 +0530)]
lib: sbi_scratch: Don't set hartid_to_scratch table for disabled HART
As a step towards supporting discontinuous and sparse HART ids, we
don't set hartid_to_scratch table for disabled 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>
Anup Patel [Sat, 14 Mar 2020 14:09:15 +0000 (19:39 +0530)]
include: sbi_platform: Improve sbi_platform_hart_disabled() API
The sbi_platform_hart_disabled() should return TRUE for HART id
greater than platform hart count.
Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Anup Patel [Sat, 14 Mar 2020 13:25:53 +0000 (18:55 +0530)]
lib: Handle failure of sbi_hartid_to_scratch() API
The sbi_hartid_to_scratch() API can fail for non-existent HARTs so
all uses of sbi_hartid_to_scratch() API should check return value.
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 [Sat, 14 Mar 2020 09:18:00 +0000 (14:48 +0530)]
lib: sbi_tlb: Simplify sbi_tlb_entry_process() function
We remove redundant scratch parameter from sbi_tlb_entry_process()
function.
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 [Sat, 14 Mar 2020 09:09:56 +0000 (14:39 +0530)]
lib: sbi_hsm: Simplify hart_get_state() and hart_started() APIs
We remove redundant scratch parameter from sbi_hsm_hart_get_state()
and sbi_hsm_hart_started() APIs.
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 [Sat, 14 Mar 2020 08:50:22 +0000 (14:20 +0530)]
include: Simplify HART id to scratch macro
This patch simplify HART id to scratch macro as follows:
1. Remove current "scratch" pointer argument because now we
use HART id to scratch table
2. Rename sbi_hart_id_to_scratch() to sbi_hartid_to_scratch()
to have macro name consistent with the name of callback
in struct sbi_scratch
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 [Sat, 14 Mar 2020 04:27:45 +0000 (09:57 +0530)]
lib: sbi_scratch: Introduce HART id to scratch table
Instead of calling hartid_to_scratch() callback every time when
we want sbi_scratch pointer from HART id, we create a table of
sbi_scratch pointers and use that to get sbi_scratch pointer.
As a result of HART id to scratch table, the conversion of
HART id to sbi_scratch pointer is just 2-3 instructions which
was 9 instructions previously.
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, 17 Mar 2020 14:59:51 +0000 (07:59 -0700)]
platform: Update to call general DT fix-up helper
Platform andes/ae350, ariane-fpga, qemu/virt and sifive/fu540 codes
have been updated to call this general DT fix-up helper.
Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Anup Patel <anup.patel@wdc.com>
Bin Meng [Tue, 17 Mar 2020 14:59:50 +0000 (07:59 -0700)]
lib: utils: Add a general device tree fix-up helper
This adds a general device tree fix-up helper to do all required
device tree fix-ups for a typical platform.
Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Anup Patel <anup.patel@wdc.com>
Bin Meng [Tue, 17 Mar 2020 14:59:49 +0000 (07:59 -0700)]
platform: sifive/fu540: Replace cpu0 node fix-up with the new helper
This replaces the FU540 specific cpu0 node "status" property fix-up
with the newly introduced generic fdt_cpu_fixup() helper.
Unlike previous logic, the helper routine does not test the "mmu-type"
property to determine which node we should fix up, instead it uses
sbi_platform_hart_disabled() API.
Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Anup Patel <anup.patel@wdc.com>
Bin Meng [Tue, 17 Mar 2020 14:59:48 +0000 (07:59 -0700)]
lib: utils: Add a fdt_cpu_fixup() helper
Add a helper routine to updates the "status" property of a CPU node
in the device tree to "disabled" if that hart is in disabled state.
Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Anup Patel <anup.patel@wdc.com>
Bin Meng [Tue, 17 Mar 2020 14:59:47 +0000 (07:59 -0700)]
platform: sifive/fu540: Remove "stdout-path" fix-up
As of today the upstream U-Boot & Linux kernel ships a device tree
that already has "stdout-path" properly set in the "/chosen" node.
This is the same with the QEMU 'sifive_u' machine. Hence the codes
to fix up the "stdout-path" in OpenSBI is not necessary.
Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
Bin Meng [Tue, 17 Mar 2020 14:59:46 +0000 (07:59 -0700)]
platform: sifive/fu540: Fix up DT for reserved memory
This calls fdt_reserved_memory_fixup() helper in the platform's
final_init() routine.
Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
Bin Meng [Tue, 17 Mar 2020 14:59:45 +0000 (07:59 -0700)]
platform: qemu/virt: Fix up DT for reserved memory
This calls fdt_reserved_memory_fixup() helper in the platform's
final_init() routine.
Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Anup Patel <anup.patel@wdc.com>
Bin Meng [Tue, 17 Mar 2020 14:59:44 +0000 (07:59 -0700)]
platform: ariane-fpga: Fix up DT for reserved memory
This calls fdt_reserved_memory_fixup() helper in the platform's
final_init() routine.
Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>