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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
Loys Ollivier [Fri, 3 May 2019 09:08:59 +0000 (11:08 +0200)]
Update sifive_fu540.md
Fix typo on parenthesis.
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
Atish Patra [Wed, 13 Mar 2019 18:08:31 +0000 (11:08 -0700)]
lib: Return ENOTSUPP incase of invalid SBI function ID
OpenSBI should show error trace only if any valid SBI function
does not perform as expected.
However, OpenSBI should show notify the caller with a negative
error if given SBI function ID is not valid.
Signed-off-by: Atish Patra <atish.patra@wdc.com>
Bin Meng [Wed, 13 Mar 2019 16:13:32 +0000 (00:13 +0800)]
platform: plic: Bypass interrupt ID 0's priority programming
Per PLIC spec, interrupt ID 0 is defined to mean "no interrupt".
We should bypass it.
Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Bin Meng [Wed, 13 Mar 2019 16:00:35 +0000 (00:00 +0800)]
platform: plic: Fix plic_set_priority()
At present plic_set_priority() ignores the 'source' and the priority
register to be programmed is constant. Fix it.
Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Atish Patra [Mon, 4 Mar 2019 21:58:37 +0000 (13:58 -0800)]
firmware: Move scratch setup to _start instead of _start_warm
Scratch space setup needs to be done once for reboot for each
hart. _start_warm may be called several times if hart hotplug
is implemented.
Move scratch space setup to the beginning so that it is done
only once.
Signed-off-by: Atish Patra <atish.patra@wdc.com>
Atish Patra [Tue, 12 Mar 2019 20:50:37 +0000 (13:50 -0700)]
lib: Fix full tlb flush behavior
Currently, global page mappings are not flushed if start and size
arguments are zero.
Flush entire TLB if both size and start argument is passed as zero.
Fixes : 90cb491 (lib: Implement sfence.vma correctly)
Signed-off-by: Atish Patra <atish.patra@wdc.com>
Bin Meng [Tue, 12 Mar 2019 13:40:28 +0000 (21:40 +0800)]
platform: fu540: Fix cosmetic styling issues
There are some spaces or mixed usage of spaces and tabs in the macro
definition. Change to use tab consistently.
Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Bin Meng [Tue, 12 Mar 2019 13:32:35 +0000 (21:32 +0800)]
docs: firmware: Fix spelling of U-Boot
It's U-Boot, not U-boot.
Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Atish Patra [Sat, 9 Mar 2019 20:57:20 +0000 (12:57 -0800)]
lib: Implement sfence.vma correctly.
Currently, OpenSBI doesn't distinguish between sfence.vma
and sfence.vm asid calls. Moreover, it ignores the page
ranges and just flush entire TLB everytime.
Fix the sfence implementation by keeping all the tlb flush
info in scratch area.
The relevant Linux kernel code was added by
https://patchwork.kernel.org/project/linux-riscv/list/?series=89695
However, this patch is backward compatible with older version kernel
that doesn't have the above patches as well.
Fixes #87
Signed-off-by: Atish Patra <atish.patra@wdc.com>
Alistair Francis [Fri, 8 Mar 2019 19:22:22 +0000 (11:22 -0800)]
lib: Create a sbi_ipi_data structure
Create a sbi_ipi_data structure that holds unpacked IPI information. At
the same time remove ipi_type from the sbi_scratch struct and use a
fixed offset to access it.
This structure fits in behind the sbi_scratch structure.
This fixes https://github.com/riscv/opensbi/issues/81
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
Atish Patra [Wed, 6 Mar 2019 23:18:29 +0000 (15:18 -0800)]
firmware: Reset all registers and flush icache
A warm reset using reset button may put icache and registers
in non-coherent state.
Flush the icache and reset all registers for every hart.
Signed-off-by: Atish Patra <atish.patra@wdc.com>
Atish Patra [Wed, 6 Mar 2019 02:03:27 +0000 (18:03 -0800)]
firmware: Add nop to reduce bus traffic.
All the non-boot harts run in a tight loop which may cause a heavy load
on the memory bus. This may delay the boot hart to complete the cold boot
process.
Introduce few nop that will ease up the traffic.
Signed-off-by: Atish Patra <atish.patra@wdc.com>
Atish Patra [Wed, 6 Mar 2019 02:01:00 +0000 (18:01 -0800)]
Revert "firmware: Add a barrier instruction for wait for boot hart"
This reverts commit
05602e2bf4812533adcb7acb1a67e43726c0e7bb.
Introducing a fence causes warm reset issue to reappear. Revert it
for the time being.
Xiang Wang [Wed, 6 Mar 2019 07:29:34 +0000 (15:29 +0800)]
platform: Make the `platform` read-only
platform should be a read-only variable, if it is placed in the data
segment, it may be exploited.
Signed-off-by: Xiang Wang <wxjstz@126.com>
Atish Patra [Mon, 4 Mar 2019 22:08:17 +0000 (14:08 -0800)]
firmware: Reset all the general purpose registers to zero.
A warm reset by pressing the reset button may not initialize all the
registers to zero. Do it for every hart during warm boot.
Signed-off-by: Atish Patra <atish.patra@wdc.com>
Atish Patra [Wed, 27 Feb 2019 19:08:26 +0000 (11:08 -0800)]
firmware: Ensure the mtvec is updated.
Signed-off-by: Atish Patra <atish.patra@wdc.com>
Atish Patra [Thu, 28 Feb 2019 00:07:56 +0000 (16:07 -0800)]
firmware: Fix a typo
Signed-off-by: Atish Patra <atish.patra@wdc.com>
Atish Patra [Thu, 28 Feb 2019 01:42:17 +0000 (17:42 -0800)]
lib:platform: Fix sbi_getc return type.
As per the current SBI specification, sbi_getc should return
an int instead of char.
In case of FIFO is empty, return -1 as per the specification.
Reported-by: Sergi Granell <xerpi.g.12@gmail.com>
Suggested-by:Thadeu Lima de Souza Cascardo <cascardo@cascardo.eti.br>
Signed-off-by: Atish Patra <atish.patra@wdc.com>
Xiang Wang [Mon, 4 Mar 2019 09:22:37 +0000 (17:22 +0800)]
firmware: Add a barrier instruction for wait for boot hart
Multi-core communication via memory requires the addition of a barrier
instructions to ensure cache coherency.
Signed-off-by: Xiang Wang <wxjstz@126.com>
Xiang Wang [Mon, 4 Mar 2019 09:17:08 +0000 (17:17 +0800)]
firmware: Move _boot_hart_done to the data section
Writable code section can cause some security problems, so move _boot_hart_done
to the data section
Signed-off-by: Xiang Wang <wxjstz@126.com>
Xiang Wang [Mon, 4 Mar 2019 03:20:58 +0000 (11:20 +0800)]
Add tags to .gitignore for being development friendly
Signed-off-by: Xiang Wang <wxjstz@126.com>
Andreas Schwab [Wed, 27 Feb 2019 11:57:56 +0000 (12:57 +0100)]
Fix missing quotes in Makefile
Andreas Schwab [Wed, 27 Feb 2019 11:53:07 +0000 (12:53 +0100)]
Fix makefile dependency generation
Anup Patel [Tue, 26 Feb 2019 16:54:59 +0000 (22:24 +0530)]
include: Bump-up version to 0.3
This patch updates OpenSBI version to 0.3 as part of
release preparation.
Signed-off-by: Anup Patel <anup.patel@wdc.com>
Alistair Francis [Fri, 22 Feb 2019 23:02:55 +0000 (15:02 -0800)]
Makefile: Set the platform variables before parsing the platforms
Ensure the platform variable PLATFORM_RISCV_XLEN is set before we parse
the platform files.
This fixes the 32-bit openSBI FW_JUMP_ADDR.
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
Anup Patel [Fri, 22 Feb 2019 06:03:22 +0000 (11:33 +0530)]
include: Bump-up version to 0.2
This patch increases OpenSBI version to 0.2.
Signed-off-by: Anup Patel <anup.patel@wdc.com>
Anup Patel [Wed, 20 Feb 2019 08:48:12 +0000 (14:18 +0530)]
scripts: Add script for creating binary archive
This patch adds scripts/create-binary-archive.sh which helps
us create a common tarball containing headers, static library
and firmware ELFs for all platforms.
This script can be used for release purpose OR for compile
testing all platforms.
Example usage commands are as follows:
1) Binary release archive for 32bit systems
./scripts/create-binary-archive.sh -s "bin" -x 32 -d
2) Binary release archive for 64bit systems
./scripts/create-binary-archive.sh -s "bin" -d
3) Compile test for 32bit systems
./scripts/create-binary-archive.sh -x 32 -t
4) Compile test for 64bit systems
./scripts/create-binary-archive.sh -t
Signed-off-by: Anup Patel <anup.patel@wdc.com>
Anup Patel [Wed, 20 Feb 2019 08:46:48 +0000 (14:16 +0530)]
Makefile: Rename compile_ld() to compile_elf()
The compile_ld() is actually used to create ELF files so
the name is misleading hence this patch renames it to
compile_elf(). We also rename LDFLAGS to ELFFLAGS because
these will be used for ELF creation only.
Signed-off-by: Anup Patel <anup.patel@wdc.com>