platform/kernel/opensbi.git
4 years agoREADME: Update license information
Damien Le Moal [Wed, 4 Sep 2019 04:27:29 +0000 (13:27 +0900)]
README: Update license information

With the Kendryte K210 platform code cleanup, none of the code copied
from Kendryte standalone SDK remains and this platform code is now
entirely licensed under OpenSBI BSD-2-clause license. Update the
README.md and ThirdPartyNotices.md files to reflect this.

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>
4 years agokendryte/k210: remove sysctl code
Damien Le Moal [Wed, 4 Sep 2019 04:27:28 +0000 (13:27 +0900)]
kendryte/k210: remove sysctl code

Directly implement frequency discovery, making the sysctl code
unnecessary. While at it, Move all macro definitions from platform.c
into platform.h and cleanup that file, removing the need for the
Apache 2.0 license and Canaan Inc copyright.

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>
4 years agokendryte/k210: Use sifive UART driver
Damien Le Moal [Wed, 4 Sep 2019 04:27:27 +0000 (13:27 +0900)]
kendryte/k210: Use sifive UART driver

The Kendryte K210 UARTHS is compatible with SiFive UART. So use the
sifive uart driver and remove the k210 uarths platform code.

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>
4 years agodocs: Update the fu540 platform guide as per U-Boot documents.
Atish Patra [Thu, 29 Aug 2019 22:19:14 +0000 (15:19 -0700)]
docs: Update the fu540 platform guide as per U-Boot documents.

U-Boot readme for fu540 platform suggest that fdt_addr_r should be used
as DT address after DT is copied via tftpboot.

Update the OpenSBI docs to reflect that. Remove other stale informations
as well.

Signed-off-by: Atish Patra <atish.patra@wdc.com>
Reviewed-by: Anup Patel <anup.patel@wdc.com>
4 years agolib: Upgrade to full flush if size is at least threshold
Atish Patra [Thu, 29 Aug 2019 22:19:13 +0000 (15:19 -0700)]
lib: Upgrade to full flush if size is at least threshold

Currently, we upgrade to a full tlb flush only If a tlb flush request
size is greater than the threshold. This is done as sfence in RISC-V
can only flush 4KB at a time. Doing a large number of flushes page by
page impacts the performance. It is better to do a full tlbflush if the
request size is at least equal to the threshold size.

Signed-off-by: Atish Patra <atish.patra@wdc.com>
Reviewed-by: Anup Patel <anup.patel@wdc.com>
4 years agolib: Support atomic swap instructions
Atish Patra [Thu, 29 Aug 2019 22:19:12 +0000 (15:19 -0700)]
lib: Support atomic swap instructions

If compiler supports riscv atomic instructions, we should
use them instead of legacy gcc built-in macros
__sync_lock_test_and_set in atomic exchange functions.

Signed-off-by: Atish Patra <atish.patra@wdc.com>
Reviewed-by: Anup Patel <anup.patel@wdc.com>
4 years agolib: Fix timer for 32 bit
Atish Patra [Thu, 29 Aug 2019 22:19:11 +0000 (15:19 -0700)]
lib: Fix timer for 32 bit

To read 64bit time in 32 bit we have to read lower & upper half
separately and 'or' them together. However, upper half time may
have changed by the time we read lower half. Thus, the resultant
64 bit time may not be accurate.

Consider lower half time value only if upper half time value has
not changed.

Signed-off-by: Atish Patra <atish.patra@wdc.com>
Reviewed-by: Anup Patel <anup.patel@wdc.com>
4 years agoscripts: Add AE350 to platform list in the binary archive script
Nylon Chen [Thu, 29 Aug 2019 03:03:56 +0000 (11:03 +0800)]
scripts: Add AE350 to platform list in the binary archive script

This patch adds Andes AE350 to RV64 platform list in the binary
archive script.

Signed-off-by: Nylon Chen <nylon7@andestech.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Anup Patel <anup.patel@wdc.com>
4 years agoplatform: Add Andes AE350 initial support
Nylon Chen [Thu, 18 Jul 2019 07:52:25 +0000 (15:52 +0800)]
platform: Add Andes AE350 initial support

This commit provides basic support for the AE350 platform.

Signed-off-by: Zong Li <zongbox@gmail.com>
Signed-off-by: Nylon Chen <nylon7@andestech.com>
4 years agoInclude `git describe` in OpenSBI
Palmer Dabbelt [Sat, 17 Aug 2019 14:11:09 +0000 (19:41 +0530)]
Include `git describe` in OpenSBI

OpenSBI includes a version, but that is only updated when tagged.  For
users that are using the git releases we instead end up with an
ambiguous version number, which makes it hard to figure out what
everyone is using.  This patch checks for a git directory and prints out
the result of `git describe`, which is a mix of pretty and unambiguous.

Signed-off-by: Palmer Dabbelt <palmer@sifive.com>
Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Tested-by: Bin Meng <bmeng.cn@gmail.com>
4 years agoplatform: Remove the ipi_sync method from all platforms.
Atish Patra [Thu, 15 Aug 2019 01:02:15 +0000 (18:02 -0700)]
platform: Remove the ipi_sync method from all platforms.

OpenSBI manages outstanding TLB flush requests by queueing
them in a fifo synchronously. An ipi sync which uses an
atomic operation on MMIO address is no longer required.

Remove the ipi sync method from platform header and all usage.

Signed-off-by: Atish Patra <atish.patra@wdc.com>
Reviewed-by: Anup Patel <anup.patel@wdc.com>
4 years agolib: Fix race conditions in tlb fifo access.
Atish Patra [Thu, 15 Aug 2019 01:02:14 +0000 (18:02 -0700)]
lib: Fix race conditions in tlb fifo access.

Linux kernel expects tlb flush SBI call to be completely synchronous i.e.
the SBI call should only return once corresponding *fence* instruction is
executed.

OpenSBI manages the outstanding TLB flush requests by keeping them in a
per hart based fifo. However, there are few corner cases that may lead to
race conditions while updating the fifo.

Currently, the caller hart waits for IPI acknowledgement via clint
address which is not a very good method as synchronization on MMIO may not
be supported in every platform. Moreover, the waiter doesn't have any way of
identifying if the IPI is received for specific tlb flush request or any
other IPI. This may lead to unpredictable behavior in supervisor/user space.

Fix this by waiting on individual fifo entries rather than MMIO address.
Currently, a relaxed loop is being used because wfi again involves MMIO write
which would be slower compared to relaxed loop. To avoid deadlock, fifo
is processed every time a hart loops for fifo enqueue or fifo sync to consume
the tlb flush requests sent by other harts.

Signed-off-by: Anup Patel <anup.patel@wdc.com>
Signed-off-by: Atish Patra <atish.patra@wdc.com>
4 years agolib: Provide an atomic exchange function unsigned long
Atish Patra [Thu, 15 Aug 2019 01:02:13 +0000 (18:02 -0700)]
lib: Provide an atomic exchange function unsigned long

Signed-off-by: Anup Patel <anup.patel@wdc.com>
Signed-off-by: Atish Patra <atish.patra@wdc.com>
4 years agolib: Handle traps when doing unpriv load/store in get_insn()
Anup Patel [Mon, 12 Aug 2019 06:20:22 +0000 (11:50 +0530)]
lib: Handle traps when doing unpriv load/store in get_insn()

We can get a page/access trap when doing unpriv load/store in
get_insn() function because on a SMP system Linux swapper running
on HART A can unmap pages from page table used by HART B.

To tackle this we extend get_insn() implementation so that if
we get trap in get_insn() then we redirect it to S-mode as fetch
page/access fault.

Signed-off-by: Anup Patel <anup.patel@wdc.com>
4 years agofirmware: do not use relocated _boot_status before it is valid
Lukas Auer [Mon, 12 Aug 2019 21:50:42 +0000 (23:50 +0200)]
firmware: do not use relocated _boot_status before it is valid

When OpenSBI is started from an address not equal to the link address,
it is first relocated to the link address. Hart 0 performs the
relocation and notifies the other harts of its completion with the
_boot_status variable. It uses the copy of the variable relative to the
link address. This copy contains valid data only after relocation has
finished. The waiting harts will therefore read invalid data until
relocation has finished. This can cause them to continue execution too
early.

Fix this by using the _boot_status variable relative to the load address
while OpenSBI has not finished relocation.

Signed-off-by: Lukas Auer <lukas.auer@aisec.fraunhofer.de>
Reviewed-by: Anup Patel <anup.patel@wdc.com>
4 years agolib: Correct null pointer check
Jacob Garber [Fri, 9 Aug 2019 23:14:00 +0000 (17:14 -0600)]
lib: Correct null pointer check

In order to prevent a possible null pointer dereference, return early if
either one of 'in' or 'data' is null.

Signed-off-by: Jacob Garber <jgarber1@ualberta.ca>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
4 years agolib: Prevent unintended sign extensions
Jacob Garber [Fri, 9 Aug 2019 23:13:59 +0000 (17:13 -0600)]
lib: Prevent unintended sign extensions

In the last argument to sbi_memset() we essentially have the following
multiplication:

    size_t = u16 * u16

Due to C's integer semantics, both u16's are implicitly converted to int
before the multiplication, which cannot hold all possible values of a
u16 * u16. If the multiplication overflows, the intermediate result will
be a negative number. On 64-bit platforms, this will be sign-extended to
a huge integer in the conversion to a u64 (aka size_t). Being the size
argument to sbi_memset(), this could potentially cause a large
out-of-bounds write. The solution is to manually cast one of the u16 to
a size_t, which will make it large enough to avoid the implicit
conversion and any overflow.

Signed-off-by: Jacob Garber <jgarber1@ualberta.ca>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
4 years agolib: Use correct type for return value
Jacob Garber [Fri, 9 Aug 2019 23:13:58 +0000 (17:13 -0600)]
lib: Use correct type for return value

The error check 'plic_off < 0' does nothing, since plic_off is stored as
a u32. Fix this by changing it to an int, which matches the return type of
fdt_node_offset_by_compatible().

Signed-off-by: Jacob Garber <jgarber1@ualberta.ca>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
4 years agolib: Use bitwise & instead of boolean &&
Jacob Garber [Fri, 9 Aug 2019 23:13:57 +0000 (17:13 -0600)]
lib: Use bitwise & instead of boolean &&

!(mipval && MIP_MSIP) simplifies to !mipval, which checks if the entire
variable is zero, not just a single bit. Fix this to use bitwise &
instead.

Signed-off-by: Jacob Garber <jgarber1@ualberta.ca>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
4 years agolib: Use sbi_dprintf() for invalid CSRs
Anup Patel [Thu, 8 Aug 2019 06:48:22 +0000 (12:18 +0530)]
lib: Use sbi_dprintf() for invalid CSRs

We should sbi_dprintf() instead of sbi_printf() for invalid CSRs
because we are forwarding invalid CSR access back to S-mode.

Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
4 years agolib: Introduce sbi_dprintf() API
Anup Patel [Thu, 8 Aug 2019 06:40:22 +0000 (12:10 +0530)]
lib: Introduce sbi_dprintf() API

This patch introduces new sbi_dprintf() API for runtime debug
prints. The sbi_dprintf() will print to console for a given
HART only when SBI_SCRATCH_DEBUG_PRINTS option in enabled in
sbi_scratch for this HART.

We can now add debug prints using sbi_dprintf() at important
places in OpenSBI sources. These debug prints will only show
up when previous booting stage or compile time parameter sets
the SBI_SCRATCH_DEBUG_PRINTS option in scratch space.

Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
4 years agofirmware: Use macro instead of magic number for boot status
Bin Meng [Thu, 8 Aug 2019 08:59:31 +0000 (01:59 -0700)]
firmware: Use macro instead of magic number for boot status

The boot status is currently hard-coded. Define some macros for it.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Anup Patel <anup.patel@wdc.com>
4 years agoplatform: sifive: fu540: Expand FDT size before any patching
Bin Meng [Thu, 8 Aug 2019 07:20:23 +0000 (00:20 -0700)]
platform: sifive: fu540: Expand FDT size before any patching

We should expand the FDT size before any patching, otherwise it's
possible the "status" fix up might fail due to insufficient space.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Anup Patel <anup.patel@wdc.com>
4 years agofirmware: Fix the loop condition of _wait_relocate_copy_done section
Nylon Chen [Fri, 2 Aug 2019 05:34:42 +0000 (13:34 +0800)]
firmware: Fix the loop condition of _wait_relocate_copy_done section

If core-0 have finished _fdt_reloc_done but any of other cores has not
yet left the loop in _wait_relocate_copy_done, they could never leave
the loop because _boot_status is not equal to 1.

4 years agolib: Allow compiling without FP support
Anup Patel [Thu, 25 Jul 2019 05:05:03 +0000 (05:05 +0000)]
lib: Allow compiling without FP support

Currently, we mandate 'F' and 'D' extension in riscv_fp.h so that
misaligned load/store emulation has access to FP registers.

The above is too restrictive and we should certainly allow compilation
for soft-FP toolchains and explicit PLATFORM_RISCV_ISA not having 'F'
and 'D' extensions.

This patch extends riscv_fp.h and misaligned load/store emulation to
allow compiling OpenSBI without FP support.

Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
5 years agotreewide: Use conventional names for 32-bit and 64-bit
Bin Meng [Wed, 24 Jul 2019 04:29:59 +0000 (21:29 -0700)]
treewide: Use conventional names for 32-bit and 64-bit

There are several places in the source tree that have:

  32bit, 32 bit, 64bit, 64 bit

Fix by using the conventional names with a hyphen.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Lukas Auer <lukas.auer@aisec.fraunhofer.de>
Acked-by: Anup Patel <anup.patel@wdc.com>
5 years agoREADME: Document 32-bit / 64-bit images build
Bin Meng [Wed, 24 Jul 2019 04:29:58 +0000 (21:29 -0700)]
README: Document 32-bit / 64-bit images build

At present the exact details of building 32-bit or 64-bit OpenSBI
images are missing in the docs. This adds the missing part.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Lukas Auer <lukas.auer@aisec.fraunhofer.de>
Acked-by: Anup Patel <anup.patel@wdc.com>
5 years agoutils: Use cpu_to_fdt32() when writing to fdt
Georg Kotheimer [Wed, 24 Jul 2019 09:38:14 +0000 (11:38 +0200)]
utils: Use cpu_to_fdt32() when writing to fdt

Although it does not make a functional difference, both cpu_to_fdt32()
and fdt32_to_cpu() pass on to CPU_TO_FDT32, we should use cpu_to_fdt32()
to be semantically correct.

Signed-off-by: Georg Kotheimer <georg.kotheimer@kernkonzept.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
Acked-by: Anup Patel <anup.patel@wdc.com>
5 years agoplatform: sifive/fu540: Move FDT further up
Anup Patel [Mon, 22 Jul 2019 05:16:28 +0000 (05:16 +0000)]
platform: sifive/fu540: Move FDT further up

This patch changes FW_xyz_FDT_ADDR to RAM_START+128MB (i.e. 0x88000000)
so that next stage bootloader (i.e. U-Boot) has enough space to unpack
bigger kernel images.

Reported-by: David Abdurachmanov <david.abdurachmanov@sifive.com>
Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: David Abdurachmanov <david.abdurachmanov@sifive.com>
Tested-by: David Abdurachmanov <david.abdurachmanov@sifive.com>
5 years agoplatform: sifive: fu540: Use standard value string for cpu node status
Bin Meng [Fri, 5 Jul 2019 02:30:50 +0000 (19:30 -0700)]
platform: sifive: fu540: Use standard value string for cpu node status

Per device tree spec, the standard value string for the "status"
property of a cpu node is either "okay" or "disabled". "masked"
was once used but it is unfortunately a spec violation.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Acked-by: Anup Patel <anup.patel@wdc.com>
5 years agoinclude: Bump-up version to 0.4 v0.4
Anup Patel [Tue, 2 Jul 2019 05:41:08 +0000 (11:11 +0530)]
include: Bump-up version to 0.4

This patch updates OpenSBI version to 0.4 as part of
release preparation.

Signed-off-by: Anup Patel <anup.patel@wdc.com>
5 years agoplatform: Remove the HiFive Unleashed expansion board DT.
Atish Patra [Tue, 2 Jul 2019 02:47:33 +0000 (19:47 -0700)]
platform: Remove the HiFive Unleashed expansion board DT.

The Linux kernel will maintain the device tree (DT) for HiFive Unleashed
from release v5.2-rc6. This DT is incompatible with previous DT
present for Microsemi expansion board in OpenSBI.

Since, OpenSBI will directly load the pre-built DTB from kernel now onwards,
no need to keep the out-of-date DT in openSBI. Remove this DT and
it's related documentation.

Signed-off-by: Atish Patra <atish.patra@wdc.com>
Acked-by: Anup Patel <anup.patel@wdc.com>
5 years agofirmware: For no relocation skip two stage wait for secondary HARTs
Anup Patel [Mon, 1 Jul 2019 03:24:13 +0000 (08:54 +0530)]
firmware: For no relocation skip two stage wait for secondary HARTs

When relocation is not required (i.e. _load_start == _link_start), we
can skip two stage wait for secondary HARTs. This means secondary HARTs
can skip the _wait_relocate_copy_done() loop and directly jump to the
_wait_for_boot_hart() loop when no relocation not required.

Signed-off-by: Anup Patel <anup.patel@wdc.com>
5 years agoscripts: Add Ariane FPGA to platform list in binary archive script
Anup Patel [Sun, 30 Jun 2019 06:33:40 +0000 (12:03 +0530)]
scripts: Add Ariane FPGA to platform list in binary archive script

This patch adds Ariane FPGA to RV64 platform list in the binary
archive script.

Signed-off-by: Anup Patel <anup.patel@wdc.com>
5 years agodocs: Update the fu540 platform guide for new DT.
Atish Patra [Sat, 29 Jun 2019 01:00:15 +0000 (18:00 -0700)]
docs: Update the fu540 platform guide for new DT.

With 5.2-rc6 release, Linux kernel hosts the DT for Unleashed board
which is incompatible with the default DT from FSBL.

Update the document to use the DT from kernel.

Signed-off-by: Atish Patra <atish.patra@wdc.com>
Acked-by: Anup Patel <anup.patel@wdc.com>
5 years agoinclude: Add firmware context to sbi_platform
Abner Chang [Sat, 29 Jun 2019 14:10:47 +0000 (19:40 +0530)]
include: Add firmware context to sbi_platform

Add firmware context field struct sbi_platform to carry firmware
specific information.

Signed-off-by: Abner Chang <abner.chang@hpe.com>
Acked-by: Anup Patel <anup.patel@wdc.com>
5 years agoinclude: Add version info to struct sbi_platform
Abner Chang [Sat, 29 Jun 2019 08:18:05 +0000 (16:18 +0800)]
include: Add version info to struct sbi_platform

Add version control of sbi_platform structure
- Add opensbi_version, this gives information of opensbi revision on
which the sbi_platform table was created.
- Add platform_version field in sbi_platform structure for platform
level version control.

Signed-off-by: Abner Chang <abner.chang@hpe.com>
Acked-by: Anup Patel <anup.patel@wdc.com>
5 years agoinclude: Move callbacks in sbi_platform to separate struct
Abner Chang [Sat, 29 Jun 2019 08:18:04 +0000 (16:18 +0800)]
include: Move callbacks in sbi_platform to separate struct

Move platform opensbi functions to sbi_platform_operations structure.
Both sbi_platform and sbi_platform_operations structures are maintained
by platform vendors.

Signed-off-by: Abner Chang <abner.chang@hpe.com>
Acked-by: Anup Patel <anup.patel@wdc.com>
5 years agoAdd documentation for Ariane FPGA platform
Panagiotis Peristerakis [Thu, 27 Jun 2019 15:28:50 +0000 (18:28 +0300)]
Add documentation for Ariane FPGA platform

Signed-off-by: Panagiotis Peristerakis <perister@ics.forth.gr>
5 years agoAdd support for Ariane FPGA SoC
Panagiotis Peristerakis [Fri, 28 Jun 2019 13:51:52 +0000 (16:51 +0300)]
Add support for Ariane FPGA SoC

This patch adds support for Ariane platform.
We needed to enable PLIC interrupts early(like on BBL) due to some issue of the design.
Otherwise, Linux would not get any external interrupts.

Signed-off-by: Panagiotis Peristerakis <perister@ics.forth.gr>
5 years agoChanged plic_set_thresh() and plic_set_ie() to public
Panagiotis Peristerakis [Fri, 21 Jun 2019 08:47:35 +0000 (11:47 +0300)]
Changed plic_set_thresh() and plic_set_ie() to public

Signed-off-by: Panagiotis Peristerakis <perister@ics.forth.gr>
5 years agofirmware: Handle overlapping load and link addresses in relocation
Xiang W [Thu, 20 Jun 2019 07:01:10 +0000 (15:01 +0800)]
firmware: Handle overlapping load and link addresses in relocation

The old code may corrupt the code of the waiting hart hence this patch
keeps waiting HART within relocation code range at time of relocation.

Signed-off-by: Xiang W <wxjstz@126.com>
Acked-by: Anup Patel <anup.patel@wdc.com>
5 years agodocs: Update docs as per new static library.
Atish Patra [Tue, 18 Jun 2019 21:54:07 +0000 (14:54 -0700)]
docs: Update docs as per new static library.

Signed-off-by: Atish Patra <atish.patra@wdc.com>
Acked-by: Anup Patel <anup.patel@wdc.com>
5 years agoutils: Remove tinyfdt.c
Atish Patra [Tue, 18 Jun 2019 21:54:06 +0000 (14:54 -0700)]
utils: Remove tinyfdt.c

tinyfdt.c was originally added to provide a minimal implementation of
fdt parsing. However, we have already included libfdt in OpenSBI for
more complicated operations.

Remove tinfdt and replace its functiolity using libfdt.

Signed-off-by: Atish Patra <atish.patra@wdc.com>
Acked-by: Anup Patel <anup.patel@wdc.com>
5 years agoplatform: Enable all drivers by default.
Atish Patra [Tue, 18 Jun 2019 21:54:05 +0000 (14:54 -0700)]
platform: Enable all drivers by default.

The drivers and libfdt are built as libsbiutils.a
instead of libplatsbi.a.

libsbiutils.a are not built per platform specific. Thus,
enable all drivers by default.

Signed-off-by: Atish Patra <atish.patra@wdc.com>
Acked-by: Anup Patel <anup.patel@wdc.com>
5 years agolib: Rename string.x to sbi_string.x
Atish Patra [Tue, 18 Jun 2019 21:54:04 +0000 (14:54 -0700)]
lib: Rename string.x to sbi_string.x

All string functions are part of libsbi. It makes more sense
to rename them to sbi_string.x as the libsbi can be linked
with external libraries that can have similar implementation.

Signed-off-by: Atish Patra <atish.patra@wdc.com>
Acked-by: Anup Patel <anup.patel@wdc.com>
5 years agoplatform: Move platform common to lib/utils.
Atish Patra [Tue, 18 Jun 2019 21:54:03 +0000 (14:54 -0700)]
platform: Move platform common to lib/utils.

Currently, platform/common contains platform/non-platform specific
common minimal drivers and libraries. This is helpful is all platforms
are built within opensbi framework.

Move them to lib/utils so that any external platform code also can
reuse the minimalistic drivers or other common libraries.

This patch doesn't introduce any functional changes.

Signed-off-by: Atish Patra <atish.patra@wdc.com>
Acked-by: Anup Patel <anup.patel@wdc.com>
5 years agolib: Include helper libc functions directly in libsbi.
Atish Patra [Tue, 18 Jun 2019 21:54:02 +0000 (14:54 -0700)]
lib: Include helper libc functions directly in libsbi.

libsbi needs some of the custom libc functions. It should be directly
included in libsbi instead of platform specific libraries.

Signed-off-by: Atish Patra <atish.patra@wdc.com>
Acked-by: Anup Patel <anup.patel@wdc.com>
5 years agolib: Move sbi core library to lib/sbi
Atish Patra [Tue, 18 Jun 2019 21:54:01 +0000 (14:54 -0700)]
lib: Move sbi core library to lib/sbi

Signed-off-by: Atish Patra <atish.patra@wdc.com>
Acked-by: Anup Patel <anup.patel@wdc.com>
5 years agofirmware: Handle overlapping load and link addresses in relocation
Xiang W [Thu, 13 Jun 2019 07:23:12 +0000 (12:53 +0530)]
firmware: Handle overlapping load and link addresses in relocation

This patch extends relocation to handle overlapping load and link
addresses.

The updated relocation will work fine in most cases except when the
relocate copy loop itself falls in overlapping load and link addresses.

Signed-off-by: Xiang W <wxjstz@126.com>
Signed-off-by: Anup Patel <anup.patel@wdc.com>
5 years agofirmware: Relocate when load address is not equal to link address
Anup Patel [Fri, 7 Jun 2019 14:56:55 +0000 (20:26 +0530)]
firmware: Relocate when load address is not equal to link address

This patch extends fw_base to relocate to link address whenever
firmware load address is not equal to link address.

The relocation will not work when load start to load end overlap
link start to link end.

Signed-off-by: Anup Patel <anup.patel@wdc.com>
Tested-by: Lukas Auer <lukas.auer@aisec.fraunhofer.de>
5 years agofirmware: add missing linker sections to fw_base.ldS
Lukas Auer [Tue, 11 Jun 2019 11:11:48 +0000 (13:11 +0200)]
firmware: add missing linker sections to fw_base.ldS

The linker sections .sdata and .sbss are missing from the linker script
fw_base.ldS. Add them to the .data and .bss sections.

On current builds, most variables are in the .sbss section. They are not
correctly initialized to zero, because they are not within the
boundaries indicated by _bss_start and _bss_end. Currently, this does
not cause any issues, however with relocation support lock-ups may occur
due to incorrectly initialized lock variables.

Signed-off-by: Lukas Auer <lukas.auer@aisec.fraunhofer.de>
Acked-by: Anup Patel <anup.patel@wdc.com>
5 years agodocs: update CONTRIBUTORS.md
Karsten Merker [Thu, 30 May 2019 18:31:59 +0000 (20:31 +0200)]
docs: update CONTRIBUTORS.md

Add Andreas Schwab to the contributors list.

Signed-off-by: Karsten Merker <merker@debian.org>
Acked-by: Andreas Schwab <schwab@suse.de>
5 years agodocs: qemu/sifive_u: miscellaneous documentation fixes
Bin Meng [Fri, 17 May 2019 15:49:02 +0000 (08:49 -0700)]
docs: qemu/sifive_u: miscellaneous documentation fixes

- OpenSBI build target should be: qemu/sifive_u
- U-Boot config name should be: sifive_fu540_defconfig

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
5 years agoplatform: qemu/sifive_u: Update the hart count to 4
Bin Meng [Fri, 17 May 2019 15:49:01 +0000 (08:49 -0700)]
platform: qemu/sifive_u: Update the hart count to 4

Since QEMU commit 8b1d0714bfdd
"riscv: sifive_u: Allow up to 4 CPUs to be created",
the maximum number of hart for sifive_u is 4.

Change our hart count to match that.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
5 years agolib: Handle page/access fault caused by unpriv load/store
Anup Patel [Thu, 23 May 2019 08:00:58 +0000 (13:30 +0530)]
lib: Handle page/access fault caused by unpriv load/store

The unpriv load/store instruction from M-mode can cause page/access
fault to M-mode if S-mode page table did not have mappings OR it did
not have PMP access permission.

To tackle this, we redirect trap back to S-mode if unpriv load/store
instruction traps in M-mode.

Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
5 years agolib: Add per-HART trap info pointer
Anup Patel [Tue, 21 May 2019 11:25:04 +0000 (16:55 +0530)]
lib: Add per-HART trap info pointer

This patch adds per-HART trap info pointer which can be used to
communicate trap information to sbi_trap_handler().

Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
5 years agoinclude: Make unprivilege load/store functions as non-inline functions
Anup Patel [Tue, 21 May 2019 10:42:33 +0000 (16:12 +0530)]
include: Make unprivilege load/store functions as non-inline functions

Currently, the unprivilege load/store functions are inline functions.

We will be extending these functions to track whether a page/access
fault occurs when we execute unprivilege load/store instruction.

To make things simpler and debugable, we reduce number of places which
can potentially generate a page/access fault by making all unprivilege
load/store functions as regular (non-inline) functions.

Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
5 years agolib: Factor-out TLB management from IPI management
Anup Patel [Fri, 24 May 2019 02:28:05 +0000 (07:58 +0530)]
lib: Factor-out TLB management from IPI management

This patch factor-out TLB management from IPI management to separate
sources sbi_tlb.c and sbi_tlb.h.

Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
5 years agolib: Add a simple brain-dead allocator to manage extra scratch space
Anup Patel [Tue, 21 May 2019 06:21:01 +0000 (11:51 +0530)]
lib: Add a simple brain-dead allocator to manage extra scratch space

We have extra space above scratch space (sbi_scratch) which we are
currently using to manage per-HART IPI data and TLB request management.

In future, more parts of OpenSBI will use the extra scratch space so
it will become difficult to manage extra scratch space using just
defines and macros.

This patch adds a simple brain-dead allocator to manage extra scratch
space. This allocator never expects anything to be free-ed hence it
keeps incrementing to next allocation offset until it runs-out of space.

In future, we can have more sophisticated allocator which will allow
us to re-claim free-ed space and also allows us to track owner of
allocated space.

Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
5 years agolib: Flush everything when remote TLB flush range is too large
Anup Patel [Mon, 20 May 2019 05:50:53 +0000 (11:20 +0530)]
lib: Flush everything when remote TLB flush range is too large

On latest Linux kernel (i.e. 5.2-rc1), we get large TLB flush
request for user space addresses (typically, start=x and end=-1).
This is caused by Linux kernel commit a21344dfc6 ("riscv: fix
sbi_remote_sfence_vma{,_asid}").

It's not practical to execute large number of sfence instructions
for a large TLB flush range because it takes too much time and
eventually causes CPU stall in Linux kernel.

This patch addresses above issue by upgrading TLB flush range to
TLB flush all whenever TLB flush range is greater than 1GB.

Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
5 years agodocs: Add documentation about dynamic firmware
Anup Patel [Mon, 29 Apr 2019 07:20:33 +0000 (12:50 +0530)]
docs: Add documentation about dynamic firmware

This patch adds documenation about dynamic firmware.

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>
5 years agoplatform: Enable dynamic firmware for appropriate platforms
Anup Patel [Mon, 29 Apr 2019 06:41:06 +0000 (12:11 +0530)]
platform: Enable dynamic firmware for appropriate platforms

This patch enables FW_DYNAMIC option (i.e. dynamic firmware) for
all appropriate/applicable platforms.

Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
5 years agofirmware: Add fw_dynamic firmware
Anup Patel [Mon, 29 Apr 2019 06:25:19 +0000 (11:55 +0530)]
firmware: Add fw_dynamic firmware

This patch provides first-cut implementation of fw_dynamic firmware.

As compared to fw_jump and fw_payload, the fw_dynamic obtains next
address, next mode and OpenSBI options from struct fw_dynamic_info.

The previous booting stage can create struct fw_dynamic_info in memory
and pass address of struct fw_dynamic_info in 'a2' register. Also, the
struct fw_dynamic_info has versioning as well so changes to the struct
fw_dynamic_info can be done in a backward compatible manner.

Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
5 years agofirmware: Allow firmwares to provide next mode and options
Anup Patel [Mon, 29 Apr 2019 05:14:15 +0000 (10:44 +0530)]
firmware: Allow firmwares to provide next mode and options

This patch extends existing firmwares (i.e. fw_jump and fw_payload)
to explicitly provide next mode and options to fw_base.

We also introduce fw_save_info() which is called by fw_base very
early on boot HART. This function can be used by existing firmwares
(i.e. fw_jump and fw_payload) to save information passed by previous
booting stage.

Overall, this is a preparatory patch for implementing fw_dynamic.

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>
5 years agodocs: update CONTRIBUTORS.md from git history
Karsten Merker [Sun, 5 May 2019 10:33:26 +0000 (12:33 +0200)]
docs: update CONTRIBUTORS.md from git history

OpenSBI has recently gained a CONTRIBUTORS.md file as a way
to make contributions to OpenSBI more visible.  Add previous
contributors from the git history who have acked their
inclusion in the list to the file.

Signed-off-by: Karsten Merker <merker@debian.org>
Acked-by: Alistair Francis <alistair@alistair23.me>
Acked-by: Anup Patel <anup.patel@wdc.com>
Acked-by: Atish Patra <atish.patra@wdc.com>
Acked-by: Bin Meng <bmeng.cn@gmail.com>
Acked-by: Damien Le Moal <damien.lemoal@wdc.com>
Acked-by: Nick Kossifidis <mickflemm@gmail.com>
Acked-by: Shawn Chang <citypw@gmail.com>
Acked-by: Xiang Wang <wxjstz@126.com>
5 years agodocs: miscellaneous documentation fixes and updates
Karsten Merker [Sun, 5 May 2019 10:33:25 +0000 (12:33 +0200)]
docs: miscellaneous documentation fixes and updates

- fix some broken hyperlinks
- add additional hyperlinks to references to external documents
- reformat some paragraphs to keep lines under 80 characters
- unify the enumeration style between different parts of the
  documentation
- fix spelling/grammar mistakes
- extend the copyright notice in README.md to be the same as the
  one in COPYING.BSD

Signed-off-by: Karsten Merker <merker@debian.org>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
5 years agoUpdate sifive_fu540.md
Loys Ollivier [Fri, 3 May 2019 09:08:59 +0000 (11:08 +0200)]
Update sifive_fu540.md

Fix typo on parenthesis.

5 years agoMakefile: explicitly disable PIE
Karsten Merker [Fri, 26 Apr 2019 10:04:06 +0000 (12:04 +0200)]
Makefile: explicitly disable PIE

The various available RISC-V toolchains differ in their default
configuration regarding PIE, e.g. the buildroot RISC-V toolchain
has PIE disabled by default while the Debian toolchain has it
enabled by default.

OpenSBI currently doesn't support being built with PIE enabled,
therefore disable it explicitly by passing "-fno-pie -no-pie" in
CFLAGS.

Signed-off-by: Karsten Merker <merker@debian.org>
Acked-by: Anup Patel <anup.patel@wdc.com>
5 years agoplatform/common/libfdt: fix unnecessary multiple inclusions
Xiang Wang [Thu, 25 Apr 2019 03:52:08 +0000 (11:52 +0800)]
platform/common/libfdt: fix unnecessary multiple inclusions

Signed-off-by: Xiang Wang <wxjstz@126.com>
5 years agodocs: Add a payload section about coreboot support #116
Shawn Chang [Wed, 24 Apr 2019 09:44:58 +0000 (17:44 +0800)]
docs: Add a payload section about coreboot support #116

Signed-off-by: Shawn Chang <citypw@gmail.com>
5 years agoall: run clang-format and update checked-in files
Olof Johansson [Thu, 11 Apr 2019 00:41:52 +0000 (17:41 -0700)]
all: run clang-format and update checked-in files

Noisy commit, no functional changes.

Generated with an current upstream clang-format and:

clang-format -i $(find . -name \*.[ch])

Signed-off-by: Olof Johansson <olof@lixom.net>
5 years agoall: Annotate some tables to have clang-format leave them alone
Olof Johansson [Thu, 11 Apr 2019 00:41:46 +0000 (17:41 -0700)]
all: Annotate some tables to have clang-format leave them alone

One of the shortcomings of clang-format is that it doesn't allow
for aligned define tables, which is used for a number of constants.

Add annotation to disable the automatic formatting where needed.

Signed-off-by: Olof Johansson <olof@lixom.net>
5 years agolibfdt: don't try to clang-format
Olof Johansson [Thu, 11 Apr 2019 00:41:42 +0000 (17:41 -0700)]
libfdt: don't try to clang-format

Add an empty clang-format to disable reformatting of imported code and
make it easier to merge in upstream changes of that project over time.

Signed-off-by: Olof Johansson <olof@lixom.net>
5 years agotop: add .clang-format
Olof Johansson [Thu, 11 Apr 2019 00:41:37 +0000 (17:41 -0700)]
top: add .clang-format

Add a clang-format to automate consistent code formatting.

Automating coding style reformatting removes a lot of manual
checkpatch-type fixups, and can easily be implemented as a linter in
code review environments.

Signed-off-by: Olof Johansson <olof@lixom.net>
5 years agolib: Redirect unhandled traps from non-M modes to S mode
Nick Kossifidis [Tue, 16 Apr 2019 17:21:55 +0000 (20:21 +0300)]
lib: Redirect unhandled traps from non-M modes to S mode

In case we didn't handle a trap with one of the available
handlers, check if the trap comes from S or U mode and
redirect it to S mode's trap handler.

Signed-off-by: Nick Kossifidis <mick@ics.forth.gr>
5 years agodoc: Update docs as per latest kernel/u-boot status.
Atish Patra [Thu, 11 Apr 2019 17:46:27 +0000 (10:46 -0700)]
doc: Update docs as per latest kernel/u-boot status.

All dependant patches are merged in U-Boot and Linux kernel now.
Update the unleashed guide to reflect that and fix the documentation
about tftp loading path as well.

Signed-off-by: Atish Patra <atish.patra@wdc.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
5 years agotop: Add CONTRIBUTORS.md file
Anup Pate [Mon, 15 Apr 2019 03:44:53 +0000 (09:14 +0530)]
top: Add CONTRIBUTORS.md file

We add CONTRIBUTORS.md file to provide a list of individuals and
organizations actively contributing to the OpenSBI project.

Signed-off-by: Anup Patel <anup.patel@wdc.com>
5 years agodocs: qemu/virt platform documentation fixes and updates
Karsten Merker [Sun, 14 Apr 2019 18:47:17 +0000 (20:47 +0200)]
docs: qemu/virt platform documentation fixes and updates

- Correct the payload address in the RV64 examples that use
  fw_jump.elf.

- Change the qemu console configuration in the examples from
  "-display none -serial stdio" to "-nographic". This results in
  qemu handing down a CTRL-C on the emulated console to the VM
  instead of terminating the qemu process.

- Provide examples for RV32.

- Various text corrections.

Signed-off-by: Karsten Merker <merker@debian.org>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
5 years agolib: Optimize TLB flush IPIs
Atish Patra [Fri, 5 Apr 2019 00:21:09 +0000 (17:21 -0700)]
lib: Optimize TLB flush IPIs

Simulatenous requests for tlbflush IPIs can have overlapping address
ranges.

Ignore if address range is same or within already existing fifo entries.
Update the tlb flush info in fifo directly if the one of the existing
entry lies within the new flush request.
Delete all entries if flush all request is recieved for the vma.

Signed-off-by: Atish Patra <atish.patra@wdc.com>
5 years agolib: Provide a lock enabled iteration of fifo.
Atish Patra [Fri, 5 Apr 2019 00:10:12 +0000 (17:10 -0700)]
lib: Provide a lock enabled iteration of fifo.

Implement a lock enabled iteration for fifo so that
caller can determine if next entry can be skipped or
any existing entries in fifo can be updated before enqueue.

Signed-off-by: Atish Patra <atish.patra@wdc.com>
5 years agoTOP: Allow building platform out-of-tree
Anup Patel [Thu, 4 Apr 2019 06:19:43 +0000 (11:49 +0530)]
TOP: Allow building platform out-of-tree

This patch extends our current build-system for building platform
sources which are not part of OpenSBI sources.

For example:

Let's say we have out-of-tree ABC platform sources. We place these
sources under <XYZ>/ABC directory along with its config.mk and
objects.mk.

To build out-of-tree ABC platform from OpenSBI directory:
$ make PLATFORM_DIR=<XYZ>/ABC
OR
$ make PLATFORM_DIR=<XYZ> PLATFORM=ABC

To build out-of-tree ABC platform from <XYZ>/ABC directory:
$ make PLATFORM_DIR=<XYZ>/ABC -C <path_to_opensbi>
OR
$ make PLATFORM_DIR=<XYZ> PLATFORM=ABC -C <path_to_opensbi>

Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
5 years agolib: Fix the ecall macro definitions
Alistair Francis [Fri, 5 Apr 2019 21:05:15 +0000 (14:05 -0700)]
lib: Fix the ecall macro definitions

Fix the ECALL definitions to matc the latest information in the
privlidge spec table 5.5.

Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
5 years agofirmware: Fix source fdt alignment
Xiang Wang [Tue, 2 Apr 2019 08:57:22 +0000 (16:57 +0800)]
firmware: Fix source fdt alignment

When I tried to start opensbi with coreboot, I found that aligning to a 16-byte
boundary would make a copy error.

Corrected to align to an machine word length boundary.

Signed-off-by: Xiang Wang <wxjstz@126.com>
5 years agolib: Pack struct sbi_fifo
Anup Patel [Wed, 3 Apr 2019 06:57:27 +0000 (12:27 +0530)]
lib: Pack struct sbi_fifo

This patch reduces memory consumed by struct sbi_fifo by droping
redundant "head" member and using u16 in-place of "unsigned long".

Signed-off-by: Anup Patel <anup.patel@wdc.com>
5 years agolib: More improvements to sbi_fifo
Anup Patel [Wed, 3 Apr 2019 04:54:03 +0000 (10:24 +0530)]
lib: More improvements to sbi_fifo

This patch does following improvements to sbi_fifo:
1. Use valid SBI_Exxxx error codes instead of -1
2. The sbi_fifo_is_full() and sbi_fifo_is_empty() did
   not acquire qlock before accessing head and tail
   hence fixed it
3. Added avail member for ease in debugging and simplifying
   head/tail updates.

Due to above changes size of sbi_fifo changes from 48 bytes
to 56 bytes.

Signed-off-by: Anup Patel <anup.patel@wdc.com>
5 years agodocs: Update mailing list details in contributing.md
Anup Patel [Wed, 3 Apr 2019 05:29:12 +0000 (10:59 +0530)]
docs: Update mailing list details in contributing.md

We now have an OpenSBI mailing list available for development
and discussiong so update contributing.md accordingly. The
Github PR based review and issue tracking will also continue
to exist.

Signed-off-by: Anup Patel <anup.patel@wdc.com>
5 years agolib: Use a fifo to keep track of sfence related IPIs.
Atish Patra [Tue, 2 Apr 2019 00:07:54 +0000 (17:07 -0700)]
lib: Use a fifo to keep track of sfence related IPIs.

Currently, there is no provision for tracking multiple IPIs sent
to a single hart at the same time by different harts.

Use a fifo manage the outstanding requests. While dequeueing, read all
the entries once, because we have only 1 bit to track the type of IPI.
Once the queue is full, busy wait until the there is space available in
queue. This is not the most elegant approach. It should be changed in
favor of a wakeup event once available in opensbi.

Signed-off-by: Atish Patra <atish.patra@wdc.com>
5 years agolib: Increase the scratch space to 512 bytes.
Atish Patra [Tue, 2 Apr 2019 00:05:53 +0000 (17:05 -0700)]
lib: Increase the scratch space to 512 bytes.

Currently scratch space per hart is 256 bytes. Increase it to 512 bytes
to accomodate ipi queue.

Signed-off-by: Atish Patra <atish.patra@wdc.com>
5 years agolib: Introduce a tlb info type.
Atish Patra [Tue, 2 Apr 2019 00:04:57 +0000 (17:04 -0700)]
lib: Introduce a tlb info type.

Add a tlb info to distinguish between different type of tlb flush
request pending.

Signed-off-by: Atish Patra <atish.patra@wdc.com>
5 years agolib: Add a fifo implementation.
Atish Patra [Tue, 2 Apr 2019 00:04:05 +0000 (17:04 -0700)]
lib: Add a fifo implementation.

Implement a fifo to accomodate outstanding IPIs for a specific hart
at the same time.

Signed-off-by: Atish Patra <atish.patra@wdc.com>
5 years agokendryte/k210: Fix file headers
Damien Le Moal [Wed, 3 Apr 2019 01:22:13 +0000 (10:22 +0900)]
kendryte/k210: Fix file headers

Add missing SPDX and copyright information.

Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
5 years agoREADME: Update license information
Damien Le Moal [Tue, 2 Apr 2019 13:38:15 +0000 (22:38 +0900)]
README: Update license information

Add information regarding the Apache License Version 2.0 of some of the
Kendryte/k210 platform files. Also repeat this information in a new
ThirdPartyNotices.md file.

Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
5 years agoinclude: Make mstatus parameter optional for get_insn()
Anup Patel [Sat, 30 Mar 2019 13:13:49 +0000 (18:43 +0530)]
include: Make mstatus parameter optional for get_insn()

The mstatus parameter of get_insn() is used to return MSTATUS CSR
value which get_insn() saw. Most of the get_insn() callers don't
use the value returned in mstatus so this patch makes mstatus
parameter optional for get_insn().

Signed-off-by: Anup Patel <anup.patel@wdc.com>
5 years agoinclude: Rename sbi_unpriv.h to riscv_unpriv.h
Anup Patel [Sat, 30 Mar 2019 12:13:23 +0000 (17:43 +0530)]
include: Rename sbi_unpriv.h to riscv_unpriv.h

The sbi_unpriv.h has quite a few load_xyz() and store_xyz() helper
routines based on RISC-V inline assembly for unpriviledged accesses
from M-mode. These helper routines are similar to helper routines
present in riscv_locks.h, riscv_io.h, and riscv_atomic.h so let's
rename sbi_unpriv.h to riscv_unpriv.h.

Signed-off-by: Anup Patel <anup.patel@wdc.com>
5 years agolib: Remove unused mepc arg from load_xyz() and store_xyz() functions
Anup Patel [Sat, 30 Mar 2019 12:05:48 +0000 (17:35 +0530)]
lib: Remove unused mepc arg from load_xyz() and store_xyz() functions

This patch removes unused mepc arg from load_xyz() and store_xyz()
unpriviledge access functions.

Signed-off-by: Anup Patel <anup.patel@wdc.com>
5 years agolib: Disable the boot prints if SBI_SCRATCH_NO_BOOT_PRINTS is set
Bin Meng [Wed, 27 Mar 2019 14:58:49 +0000 (22:58 +0800)]
lib: Disable the boot prints if SBI_SCRATCH_NO_BOOT_PRINTS is set

Use the newly introduced "options" in "struct sbi_scratch" to
conditionally disable the boot prints.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
5 years agolib: Group all prints during boot into sbi_boot_prints()
Bin Meng [Wed, 27 Mar 2019 14:39:08 +0000 (22:39 +0800)]
lib: Group all prints during boot into sbi_boot_prints()

Refactor the codes a little bit to put all prints during boot into
sbi_boot_prints().

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
5 years agofirmware: Introduce "options" in "struct sbi_scratch"
Bin Meng [Wed, 27 Mar 2019 14:57:20 +0000 (22:57 +0800)]
firmware: Introduce "options" in "struct sbi_scratch"

Introduce "options" in "struct sbi_scratch" and firmware can update
it based on optional compile time flags before calling sbi_init().

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
5 years agoplatform: plic: Fix comments of programming the interrupt enable register
Bin Meng [Thu, 14 Mar 2019 08:12:44 +0000 (16:12 +0800)]
platform: plic: Fix comments of programming the interrupt enable register

The codes that currently program the interrupt enable register for
S-mode disagrees with what the comments say. Fix the comments.

While we are here, add one line comment to describe what is done
for M-mode too.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>