platform/kernel/opensbi-spacemit.git
4 years agoplatform: Set per-HART stack size to 8KB in the template platform codes
Bin Meng [Fri, 13 Mar 2020 05:39:53 +0000 (22:39 -0700)]
platform: Set per-HART stack size to 8KB in the template platform codes

The template platform codes should set per-HART stack size to 8KB
to avoid possible mistakes of future platform ports.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Anup Patel <anup.patel@wdc.com>
4 years agoplatform: ariane-fpga: Set per-HART stack size to 8KB
Bin Meng [Fri, 13 Mar 2020 05:39:52 +0000 (22:39 -0700)]
platform: ariane-fpga: Set per-HART stack size to 8KB

Recent commit

  4a603eb ("platform: kendryte/k210: Set per-HART stack size to 8KB")

forgot to update ariane-fpga codes, and the following commit

  678c3c3 ("include: sbi_scratch: Set per-HART scratch size to 4KB")

changed the per-HART scratch size to 4KB, which potentially breaks
ariane-fpga platform.

This patch set per-HART stack size of ariane-fpga to 8KB for consistency.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Anup Patel <anup.patel@wdc.com>
4 years agoMakefile: Fix distclean make target
Anup Patel [Wed, 11 Mar 2020 14:26:45 +0000 (19:56 +0530)]
Makefile: Fix distclean make target

The default install directory is not being removed correctly by
distclean make target due to recent changes. This patch fixes
distclean make target to fix default install directory removal.

Fixes: 82ae8e8fe2a3 ("makefile: Do setup of the install target
more flexible")
Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
4 years agoinclude: Make sbi_current_hartid() as macro in riscv_asm.h
Anup Patel [Thu, 12 Mar 2020 04:51:25 +0000 (10:21 +0530)]
include: Make sbi_current_hartid() as macro in riscv_asm.h

The sbi_current_hartid() being a regular function is quite
expensive because for callers it is a function call instead
of a direct CSR read. This patch converts sbi_current_hartid()
into a macro in riscv_asm.h.

Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
4 years agolib: sbi_hsm: Optimize sbi_hsm_hart_get_state() implementation
Anup Patel [Wed, 11 Mar 2020 14:04:39 +0000 (19:34 +0530)]
lib: sbi_hsm: Optimize sbi_hsm_hart_get_state() implementation

Now that sbi_hart_id_to_scratch() is optimized, we don't need
the "if ()" statement. Also, the hstate local variable is
redundant so we remove that as well.

Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
4 years agofirmware: fw_base: Optimize _hartid_to_scratch() implementation
Anup Patel [Wed, 11 Mar 2020 13:55:24 +0000 (19:25 +0530)]
firmware: fw_base: Optimize _hartid_to_scratch() implementation

This patch optimizes _hartid_to_scratch() in following ways:
1. Use caller saved registers instead of callee saved registers
   so that we don't need to save/restore registers on stack
2. Remove second redundant mul instruction by re-arranging
   instructions

Overall, we reduce 9 instructions in _hartid_to_scratch()
implementation.

Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
4 years agoinclude: Make sbi_hart_id_to_scratch() as macro
Anup Patel [Wed, 11 Mar 2020 13:38:08 +0000 (19:08 +0530)]
include: Make sbi_hart_id_to_scratch() as macro

The sbi_hart_id_to_scratch() just forwards call to firmware specific
hartid_to_scratch() callback so we make sbi_hart_id_to_scratch() as
macro in sbi_scratch.h instead of regular function in sbi_hart.c.

Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
4 years agolibfdt: Upgrade to v1.5.1 release
Bin Meng [Thu, 12 Mar 2020 05:46:28 +0000 (22:46 -0700)]
libfdt: Upgrade to v1.5.1 release

Sync with latest libfdt v1.5.1 release source codes.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Anup Patel <anup.patel@wdc.com>
4 years agolibfdt: Add INT32_MAX and UINT32_MAX in libfdt_env.h
Bin Meng [Thu, 12 Mar 2020 05:46:27 +0000 (22:46 -0700)]
libfdt: Add INT32_MAX and UINT32_MAX in libfdt_env.h

Add two macros in preparation to sync libfdt codes to latest v1.5.1
release from upstream.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Anup Patel <anup.patel@wdc.com>
4 years agosbi: Add definitions for true/false
Bin Meng [Thu, 12 Mar 2020 05:46:26 +0000 (22:46 -0700)]
sbi: Add definitions for true/false

We currently have TRUE/FALSE, but it could be convenient to have
true/false as well.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Anup Patel <anup.patel@wdc.com>
4 years agoplatform: ariane-fpga: Change license for ariane-fpga from GPL-2.0 to BSD-2
Panagiotis Peristerakis [Thu, 12 Mar 2020 13:56:24 +0000 (15:56 +0200)]
platform: ariane-fpga: Change license for ariane-fpga from GPL-2.0 to BSD-2

Signed-off-by: Panagiotis Peristerakis <perister@ics.forth.gr>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Anup Patel <anup.patel@wdc.com>
4 years agolib: sbi: Fix misaligned trap handling
Damien Le Moal [Thu, 12 Mar 2020 05:20:37 +0000 (14:20 +0900)]
lib: sbi: Fix misaligned trap handling

Compile time checks of __riscv_compressed can only check if OpenSBI is
being compiled using compressed instructions or not. Checking this macro
does not indicate if an instruction that generated a misaligned trap is
a compressed instruction or not.

Since the misaligned trap handling code inspects instructions _C_ bits
to detect compressed instructions, we can remove all static checks on
__riscv_compressed and dissociate hanlding of misaligned traps and
OpenSBI compilation.

Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Anup Patel <anup.patel@wdc.com>
4 years agodocs: Remove out-of-date documentation
Atish Patra [Tue, 10 Mar 2020 23:46:53 +0000 (16:46 -0700)]
docs: Remove out-of-date documentation

Upstream U-Boot now have SMP support and doesn't require any additional
patches for HiFive Unleashed.

Update the documentation.

Signed-off-by: Atish Patra <atish.patra@wdc.com>
Reviewed-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
4 years agolib: sbi_hart: Remove HART available mask and related APIs
Anup Patel [Mon, 2 Mar 2020 11:03:07 +0000 (16:33 +0530)]
lib: sbi_hart: Remove HART available mask and related APIs

The HART available mask and related APIs are now totally redundant
because of more extensive HART state machine implemented by sbi_hsm.

Due to above, we remove HART available mask and related APIs.

Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
4 years agolib: sbi_ipi: Use sbi_hsm_hart_started_mask() API
Anup Patel [Mon, 2 Mar 2020 10:51:38 +0000 (16:21 +0530)]
lib: sbi_ipi: Use sbi_hsm_hart_started_mask() API

This patch replaces use of sbi_hart_available_mask() API with
sbi_hsm_hart_started_mask() API.

Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
4 years agolib: sbi_system: Use sbi_hsm_hart_started_mask() API
Anup Patel [Mon, 2 Mar 2020 10:49:49 +0000 (16:19 +0530)]
lib: sbi_system: Use sbi_hsm_hart_started_mask() API

This patch replaces use of sbi_hart_available_mask() API with
sbi_hsm_hart_started_mask() API.

Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
4 years agolib: sbi_ecall_legacy: Use sbi_hsm_hart_started_mask() API
Anup Patel [Mon, 2 Mar 2020 10:47:49 +0000 (16:17 +0530)]
lib: sbi_ecall_legacy: Use sbi_hsm_hart_started_mask() API

This patch replaces use of sbi_hart_available_mask() API with
sbi_hsm_hart_started_mask API.

Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
4 years agolib: Introduce sbi_hsm_hart_started_mask() API
Anup Patel [Mon, 2 Mar 2020 10:43:50 +0000 (16:13 +0530)]
lib: Introduce sbi_hsm_hart_started_mask() API

This patch introduce sbi_hsm_hart_started_mask() API as
a replacement of sbi_hart_available_mask() API.

Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
4 years agoinclude: Remove disabled_hart_mask from sbi_platform
Anup Patel [Mon, 2 Mar 2020 12:19:17 +0000 (17:49 +0530)]
include: Remove disabled_hart_mask from sbi_platform

The disabled_hard_mask in sbi_platform is only 64bits wide so we
cannot disable a HART with HARTID > 63. To tackle this, we remove
disabled_hart_mask and replace it with hart_disabled() platform
callback.

Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
4 years agolib: sbi_init: Use hartmask for coldboot wait
Anup Patel [Wed, 4 Mar 2020 12:00:21 +0000 (17:30 +0530)]
lib: sbi_init: Use hartmask for coldboot wait

The coldboot_wait_bitmap is of fixed size and has __riscv_xlen
bits. This limits us to scale beyond __riscv_xlen HARTs hence
we replace coldboot_wait_bitmap with coldboot_wait_hmask which
is of type struct sbi_hartmask.

Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
4 years agolib: Move all coldboot wait APIs to sbi_init.c
Anup Patel [Mon, 2 Mar 2020 11:20:01 +0000 (16:50 +0530)]
lib: Move all coldboot wait APIs to sbi_init.c

The coldboot wait APIs are only used by sbi_init.c so no point in
having coldboot related code in sbi_hart.c.

As per-above rationale, we move all coldboot wait related APIs to
sbi_init.c as static/local functions.

Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
4 years agolib: sbi_tlb: Use sbi_hartmask in sbi_tlb_info
Anup Patel [Wed, 4 Mar 2020 08:51:42 +0000 (14:21 +0530)]
lib: sbi_tlb: Use sbi_hartmask in sbi_tlb_info

Instead of using single ulong as source mask for sbi_tlb_info,
we use sbi_hartmask. This way sbi_tlb_info can easily scale
for large number of HARTs.

Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
4 years agolib: Introduce SBI_TLB_INFO_INIT() helper macro
Anup Patel [Tue, 3 Mar 2020 14:11:09 +0000 (19:41 +0530)]
lib: Introduce SBI_TLB_INFO_INIT() helper macro

We introduce SBI_TLB_INFO_INIT() helper macro to help easy
initialization of struct sbi_tlb_info which is passed to the
sbi_tlb_request() API.

Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
4 years agolib: sbi_init: Don't allow HARTID greater than SBI_HARTMASK_MAX_BITS
Anup Patel [Wed, 4 Mar 2020 09:00:49 +0000 (14:30 +0530)]
lib: sbi_init: Don't allow HARTID greater than SBI_HARTMASK_MAX_BITS

We only allow HARTs with HARTID less than SBI_HARTMASK_MAX_BITS in
sbi_init() function so that sbi_hartmask can safely used across
OpenSBI sources.

Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
4 years agoinclude: Simple hartmask library
Anup Patel [Wed, 4 Mar 2020 08:28:22 +0000 (13:58 +0530)]
include: Simple hartmask library

We add a simple hartmask library to create and maintain HART mask
in different parts of OpenSBI sources. This new library is build
as wrapper library on-top-of bitmap library.

Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
4 years agolib: Simple bitmap library
Anup Patel [Wed, 4 Mar 2020 06:59:15 +0000 (12:29 +0530)]
lib: Simple bitmap library

We add simple bitmap library which will help us create and maintain
bitmaps. It will also help us create a simple HART mask library.

Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
4 years agolib: serial: Fix coding style issues
Bin Meng [Mon, 9 Mar 2020 03:52:42 +0000 (20:52 -0700)]
lib: serial: Fix coding style issues

This fixes various coding style issues found in the serial codes.
No functional changes.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Anup Patel <anup.patel@wdc.com>
4 years agolib: sbi: Fix coding style issues
Bin Meng [Mon, 9 Mar 2020 03:52:41 +0000 (20:52 -0700)]
lib: sbi: Fix coding style issues

This fixes various coding style issues found in the SBI codes.
No functional changes.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Anup Patel <anup.patel@wdc.com>
4 years agoplatform: ae350: Sort build objects in alphabetical order
Bin Meng [Mon, 9 Mar 2020 02:17:58 +0000 (19:17 -0700)]
platform: ae350: Sort build objects in alphabetical order

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Anup Patel <anup.patel@wdc.com>
4 years agolib: Sort build objects in alphabetical order
Bin Meng [Mon, 9 Mar 2020 02:17:57 +0000 (19:17 -0700)]
lib: Sort build objects in alphabetical order

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Anup Patel <anup.patel@wdc.com>
4 years agoinclude: sbi_scratch: Set per-HART scratch size to 4KB
Anup Patel [Wed, 4 Mar 2020 08:46:42 +0000 (14:16 +0530)]
include: sbi_scratch: Set per-HART scratch size to 4KB

Currently, the per-HART scratch size is 256 bytes on RV32 and
512 bytes on RV64. This patch set per-HART scratch size to 4KB
(4096 bytes) for both RV32 and RV64 so that we don't run-out
of scratch space anytime soon.

Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
4 years agoplatform: kendryte/k210: Set per-HART stack size to 8KB
Anup Patel [Wed, 4 Mar 2020 08:40:03 +0000 (14:10 +0530)]
platform: kendryte/k210: Set per-HART stack size to 8KB

All platform except kendryte/k210 use 8KB of per-HART stack hence
this patch set per-HART stack size of kendryte/k210 to 8KB for
consistency.

Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
4 years agoinclude: sbi_bitops: More useful bit operations
Anup Patel [Wed, 4 Mar 2020 06:18:31 +0000 (11:48 +0530)]
include: sbi_bitops: More useful bit operations

This patch extends our bit operation library with mechanism to:
1. Iteratively traverse bits
2. Set bit
3. Clear bit
4. Change bit
5. ... other helpful functions ...

Most the above is adopted from Xvisor sources.

Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
4 years agoinclude: Move bits related defines and macros to sbi_bitops.h
Anup Patel [Wed, 4 Mar 2020 05:38:35 +0000 (11:08 +0530)]
include: Move bits related defines and macros to sbi_bitops.h

The right location for all bits related defines and macros is
sbi_bitops.h hence this patch. With this patch, the sbi_bits.h
is redundant so we remove it.

Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
4 years agolib: Fix return type of sbi_hsm_hart_started()
Anup Patel [Mon, 2 Mar 2020 07:45:17 +0000 (13:15 +0530)]
lib: Fix return type of sbi_hsm_hart_started()

The return type of sbi_hsm_hart_started() should be bool.

Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
4 years agoplatform: sifive: fu540: allow sv32 as an mmu-type
Sören Tempel [Sun, 8 Mar 2020 05:05:32 +0000 (10:35 +0530)]
platform: sifive: fu540: allow sv32 as an mmu-type

There has already been a commit to master which added 32-bit specific
fdt/payload addresses for the sifive/fu540 platform [0]. This commit
introduces another change for using sifive/fu540 as a 32-bit platform.
On 32-bit platforms, cores with the SV32 MMU type should not be
disabled. For this reason, this commit also allows using this MMU type
on the sifive/fu540 platform.

Alternatively it would also be possible to only allow SV39 and SV48 if
`__riscv_xlen == 64` and SV32 if `__riscv_xlen == 32`. Removing the
check entirely would also be an option.

[0]: 66fb729a1e46a9a46e809f3b7867fef91477e494

Signed-off-by: Sören Tempel <tempel@uni-bremen.de>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
4 years agomakefile: Do setup of the install target more flexible
Nikita Ermakov [Sat, 7 Mar 2020 22:31:02 +0000 (01:31 +0300)]
makefile: Do setup of the install target more flexible

- Add possibility to setup include, libs, firmware and docs paths.

- Change the default installation paths for include, libs, firmware
  and docs to meet FHS [1].

[1] https://refspecs.linuxfoundation.org/FHS_3.0/fhs/index.html

Signed-off-by: Nikita Ermakov <coffe92@gmail.com>
Reviewed-by: Anup Patel <anup.patel@wdc.com>
4 years agolib: Check MSIP bit after returning from WFI
Atish Patra [Fri, 6 Mar 2020 19:44:44 +0000 (11:44 -0800)]
lib: Check MSIP bit after returning from WFI

As per the RISC-V privilege specification, WFI can be implemented as
a NOP. Software should ensure that relevant interrupt pending bits
are set. Otherwise, loop back to WFI.

Signed-off-by: Atish Patra <atish.patra@wdc.com>
Reviewed-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
4 years agolib: Implement Hart State Management (HSM) SBI extension
Atish Patra [Wed, 12 Feb 2020 01:32:39 +0000 (17:32 -0800)]
lib: Implement Hart State Management (HSM) SBI extension

This patch adds support HSM extension. The specification is available
at https://github.com/riscv/riscv-sbi-doc.

It allows to implement hart hotplug and fixed ordered hart booting in
supervisor.

Signed-off-by: Atish Patra <atish.patra@wdc.com>
Reviewed-by: Anup Patel <anup.patel@wdc.com>
4 years agolib: Add possible hart status values
Atish Patra [Wed, 12 Feb 2020 01:32:38 +0000 (17:32 -0800)]
lib: Add possible hart status values

SBI HSM extension defines possible hart status values in the
specification.

Define all possible status values. Add a helper function to
convert hart state to status because hart states are internal
to OpenSBI only and may not match the status values defined in
the specification.

Signed-off-by: Atish Patra <atish.patra@wdc.com>
Reviewed-by: Anup Patel <anup.patel@wdc.com>
4 years agolib: Implement hart hotplug
Atish Patra [Wed, 12 Feb 2020 01:32:37 +0000 (17:32 -0800)]
lib: Implement hart hotplug

This patch adds support for hart hotplug in OpenSBI using a generic WFI
based approach. Hart hotplug can be achieved via SBI HSM extension which
allows supervisor mode software to start or stop any harts anytime.

Any platform wishes to implement platform specific hart hotplug must
implement both hart_start and hart_stop in addition to enable platform
feature SBI_PLATFORM_HAS_HART_HOTPLUG.

Signed-off-by: Atish Patra <atish.patra@wdc.com>
Reviewed-by: Anup Patel <anup.patel@wdc.com>
4 years agolib: Add a new platform feature to bringup secondary harts
Atish Patra [Wed, 12 Feb 2020 01:32:36 +0000 (17:32 -0800)]
lib: Add a new platform feature to bringup secondary harts

A platform may have a specific method to bring-up secondary harts for the
first time but may rely on generic WFI based approach for hart hotplug in
absence of a platform specific hart hotplug method.

Define a platform feature flag for such platforms. The platform needs to
implement platform specific bring-up method in hart_start and not define
hart_stop method in this case. They must only define
SBI_PLATFORM_HAS_HART_SECONDARY_BOOT.

SBI_PLATFORM_HAS_HART_HOTPLUG should only be defined when the platform
intend to support both hart_start and hart_stop and do not intend to rely
on generic WFI based approach.

Signed-off-by: Atish Patra <atish.patra@wdc.com>
Reviewed-by: Anup Patel <anup.patel@wdc.com>
4 years agoinclude: Bump-up version to 0.6
Anup Patel [Mon, 24 Feb 2020 05:57:57 +0000 (11:27 +0530)]
include: Bump-up version to 0.6

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

Signed-off-by: Anup Patel <anup.patel@wdc.com>
4 years agolib: Simplify the for-loop in sbi_ipi_send_many()
Anup Patel [Sat, 22 Feb 2020 06:20:55 +0000 (11:50 +0530)]
lib: Simplify the for-loop in sbi_ipi_send_many()

We don't need to separately call sbi_ipi_send() for current HART
in sbi_ipi_send_many(). Instead, we can simplify the for-loop in
sbi_ipi_send_many() and call sbi_ipi_send() for all HARTs in the
for-loop itself.

Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
4 years agolib: Use available hart mask for correct hbase value
Atish Patra [Fri, 21 Feb 2020 23:47:54 +0000 (15:47 -0800)]
lib: Use available hart mask for correct hbase value

As per the latest SBI specification, all online harts should receive
IPI if hbase is set to -1.

Set the target mask to all available hart mask if hbase is -1.

Signed-off-by: Atish Patra <atish.patra@wdc.com>
Reviewed-by: Anup Patel <anup.patel@wdc.com>
4 years agolib: Fix typo in atomic exchange functions
Atish Patra [Fri, 21 Feb 2020 23:47:53 +0000 (15:47 -0800)]
lib: Fix typo in atomic exchange functions

There is a typo in atomic operations code which prevents the
usage of riscv atomic instructions even if it is supported.

Fix the typo.

Signed-off-by: Atish Patra <atish.patra@wdc.com>
Reviewed-by: Anup Patel <anup.patel@wdc.com>
4 years agoplatform: qemu: virt: Correct the typo in config.mk
Bin Meng [Tue, 18 Feb 2020 10:18:33 +0000 (02:18 -0800)]
platform: qemu: virt: Correct the typo in config.mk

It should be "aligned".

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Anup Patel <anup.patel@wdc.com>
4 years agoplatform: sifive: fu540: Add 32-bit specific fdt/payload addresses
Bin Meng [Tue, 18 Feb 2020 10:15:59 +0000 (02:15 -0800)]
platform: sifive: fu540: Add 32-bit specific fdt/payload addresses

For testing 32-bit SiFive specific drivers with QEMU riscv32, add
32-bit specific FW_JUMP_FDT_ADDR and FW_PAYLOAD_OFFSET.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Anup Patel <anup.patel@wdc.com>
4 years agolib: Print interrupt and exception delegation in boot prints
Anup Patel [Tue, 18 Feb 2020 06:23:52 +0000 (11:53 +0530)]
lib: Print interrupt and exception delegation in boot prints

We print MIDELEG and MEDELEG CSRs as part of boot prints so that
boot log shows the interrupts and exceptions delegated to S-mode.

Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
4 years agolib: Don't check MIDELEG and MEDELEG at end of delegate_traps()
Anup Patel [Tue, 18 Feb 2020 06:07:16 +0000 (11:37 +0530)]
lib: Don't check MIDELEG and MEDELEG at end of delegate_traps()

The MIDELEG and MEDELEG CSR checks at end of delegate_traps() were
added for initial bring-up on SiFive Unleashed and QEMU. These
checks are not required any more and in-future these checks can
cause failures because some of the MIDELEG/MEDELEG bits will be
hard-wired to 0 or 1.

For related discussion, refer github issue:
https://github.com/riscv/opensbi/issues/157

Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
4 years agolib: utils: htif: Fix 32-bit build
Bin Meng [Tue, 18 Feb 2020 04:55:12 +0000 (20:55 -0800)]
lib: utils: htif: Fix 32-bit build

When building 32-bit OpenSBI images, we get:

  lib/utils/sys/htif.c: In function '__check_fromhost':
  lib/utils/sys/htif.c:12:31: error: left shift count >= width of type
                                     [-Werror=shift-count-overflow]
   #define HTIF_DATA_MASK  ((1UL << HTIF_DATA_BITS) - 1)
                                 ^~

Fixes: c2f23cc6edd7 ("platform: Add Spike initial support")
Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Anup Patel <anup.patel@wdc.com>
4 years agoRevert "lib: Use __builtin_ctzl() in pmp_get()"
Anup Patel [Tue, 18 Feb 2020 03:56:33 +0000 (09:26 +0530)]
Revert "lib: Use __builtin_ctzl() in pmp_get()"

This reverts commit 897b8fbdd92fcfad194417d348b8dad16ab0e17a.

We are seeing compile errors using newlib based GCC cross-toolchain
so we restore back old ctz() implementation.

Signed-off-by: Anup Patel <anup.patel@wdc.com>
4 years agodoc: thead-c910: Fix doc styles
Bin Meng [Sun, 16 Feb 2020 15:19:39 +0000 (07:19 -0800)]
doc: thead-c910: Fix doc styles

- make title underline the same length as the title itself
- satisfy the 80 character per line rule as much as possible

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Anup Patel <anup.patel@wdc.com>
4 years agodoc: sifive_fu540: Fix doc styles
Bin Meng [Sun, 16 Feb 2020 15:19:38 +0000 (07:19 -0800)]
doc: sifive_fu540: Fix doc styles

- make title underline the same length as the title itself
- put all URLs at the end of the doc

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Anup Patel <anup.patel@wdc.com>
4 years agodoc: qemu_virt: Fix doc styles
Bin Meng [Sun, 16 Feb 2020 15:19:37 +0000 (07:19 -0800)]
doc: qemu_virt: Fix doc styles

Remove the unnecessary blank line at the end of the doc.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Anup Patel <anup.patel@wdc.com>
4 years agodoc: ariane-fpga: Fix doc styles
Bin Meng [Sun, 16 Feb 2020 15:19:36 +0000 (07:19 -0800)]
doc: ariane-fpga: Fix doc styles

Various styles fixes including:

- satisfy the 80 character per line rule as much as possible
- make title underline the same length as the title itself
- remove the redundant FPGA (was FPGA FPGA SoC)

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Anup Patel <anup.patel@wdc.com>
4 years agodoc: andes-ae350: Fix doc styles
Bin Meng [Sun, 16 Feb 2020 15:19:35 +0000 (07:19 -0800)]
doc: andes-ae350: Fix doc styles

Various styles fixes including:

- satisfy the 80 character per line rule as much as possible
- remove unnecessary spaces between words

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Anup Patel <anup.patel@wdc.com>
4 years agodoc: payload_linux: Fix doc styles
Bin Meng [Sun, 16 Feb 2020 15:19:34 +0000 (07:19 -0800)]
doc: payload_linux: Fix doc styles

Remove the unnecessary blank line at the end of the doc.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Anup Patel <anup.patel@wdc.com>
4 years agodoc: coreboot: Fix doc styles
Bin Meng [Sun, 16 Feb 2020 15:19:33 +0000 (07:19 -0800)]
doc: coreboot: Fix doc styles

- put all URLs at the end of the doc
- satisfy the 80 character per line rule as much as possible

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Anup Patel <anup.patel@wdc.com>
4 years agoThirdPartyNotices: Fix doc styles
Bin Meng [Sun, 16 Feb 2020 15:19:32 +0000 (07:19 -0800)]
ThirdPartyNotices: Fix doc styles

Remove the unnecessary blank line at the end of the doc.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Anup Patel <anup.patel@wdc.com>
4 years agodocs: platform: Add documentation for Spike platform
Anup Patel [Thu, 13 Feb 2020 12:10:17 +0000 (17:40 +0530)]
docs: platform: Add documentation for Spike platform

This patch adds documentation to build and run OpenSBI on
Spike simulator and QEMU Spike machine.

Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
4 years agoscripts: Add Spike to platform list of binary archive script
Anup Patel [Thu, 13 Feb 2020 11:35:15 +0000 (17:05 +0530)]
scripts: Add Spike to platform list of binary archive script

The Spike platform support works perfectly fine on QEMU RV64 Spike
machine and Spike emulator.

Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
4 years agoplatform: Remove stale options from config.mk files
Anup Patel [Thu, 13 Feb 2020 11:32:41 +0000 (17:02 +0530)]
platform: Remove stale options from config.mk files

This patch removes stale options from config.mk files of
Ariane FPGA and QEMU virt platform support.

Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
4 years agoplatform: Add Spike initial support
James Clarke [Sat, 1 Feb 2020 01:07:51 +0000 (01:07 +0000)]
platform: Add Spike initial support

This patch adds initial platform support Spike emulator.

Signed-off-by: James Clarke <jrtc27@jrtc27.com>
Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
4 years agolib: irqchip/plic: Disable all contexts and IRQs
Atish Patra [Wed, 12 Feb 2020 01:42:50 +0000 (17:42 -0800)]
lib: irqchip/plic: Disable all contexts and IRQs

To initialize PLIC in sane state, we should:
1. set maximum threshold value of M-mode PLIC contexts
2. set maximum threshold value of S-mode PLIC contexts
3. set irq priorities to miniumum

Fix the comment and initialize the threshold/priorities correctly.

Signed-off-by: Anup Patel <anup.patel@wdc.com>
Signed-off-by: Atish Patra <atish.patra@wdc.com>
4 years agolib: Initialize out value in SBI calls
Atish Patra [Wed, 12 Feb 2020 01:39:45 +0000 (17:39 -0800)]
lib: Initialize out value in SBI calls

As per the SBI specification, the return value in sbiret is undefined
if not explicitly described in the function. However, supervisor may
check this value by mistake and get a garbage value.

Initialize it to zero to avoid nasty supervisor bugs.

Signed-off-by: Atish Patra <atish.patra@wdc.com>
Reviewed-by: Anup Patel <anup.patel@wdc.com>
4 years agolib: Use __builtin_ctzl() in pmp_get()
Li Jinpei [Tue, 11 Feb 2020 10:07:24 +0000 (15:37 +0530)]
lib: Use __builtin_ctzl() in pmp_get()

We should should __builtin_ctzl() in pmp_get() instead of
custom ctz() function.

Signed-off-by: Li Jinpei <leekingp1994@163.com>
Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
4 years agolib: sbi_scratch: use bitwise ops in sbi_scratch_alloc_offset()
Li Jinpei [Tue, 11 Feb 2020 09:57:49 +0000 (15:27 +0530)]
lib: sbi_scratch: use bitwise ops in sbi_scratch_alloc_offset()

Instead of using loop to make "size" machine word aligned, we should
use bitwise ops.

Signed-off-by: Li Jinpei <leekingp1994@163.com>
Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
4 years agodoc: sifive: fu540: Update QEMU instruction when using U-Boot as the payload
Bin Meng [Mon, 10 Feb 2020 15:42:03 +0000 (07:42 -0800)]
doc: sifive: fu540: Update QEMU instruction when using U-Boot as the payload

Document that when U-Boot v2020.01 (or higher) is used as the payload,
we need adjust the instructions a little bit when testing OpenSBI with
QEMU 'sifive_u' machine.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
4 years agoplatform: sifive: fu540: Add platform specific 'make run' cmd
Bin Meng [Thu, 6 Feb 2020 12:15:21 +0000 (04:15 -0800)]
platform: sifive: fu540: Add platform specific 'make run' cmd

This adds sifive/fu540 specific QEMU run command.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Anup Patel <anup.patel@wdc.com>
4 years agoplatform: Drop qemu/sifive_u support
Bin Meng [Thu, 6 Feb 2020 11:51:23 +0000 (03:51 -0800)]
platform: Drop qemu/sifive_u support

With QEMU v4.2 RISC-V changes to improve the emulation fidelity
of 'sifive_u' machine, OpenSBI v0.4 / U-Boot v2019.10 / Linux
kernel v5.3 images built for the SiFive HiFive Unleashed board
can be used out of the box without any special hack. Hence there
is no need for us to continue supporting such a special target in
OpenSBI. Going forward, sifive/fu540 platform can be used on both
real hardware and QEMU 'sifive_u' machine.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Anup Patel <anup.patel@wdc.com>
4 years agomakefile: add support for building on macOS
Alex Richardson [Thu, 6 Feb 2020 04:27:34 +0000 (09:57 +0530)]
makefile: add support for building on macOS

On macOS the readlink command does not include a -f flag. Instead default
to using GNU readlink (which is often installed as greadlink).

Signed-off-by: Alex Richardson <Alexander.Richardson@cl.cam.ac.uk>
Signed-off-by: Anup Patel <anup.patel@wdc.com>
4 years agoplatform: sifive/fu540: Set tlb range flush limit to zero
Atish Patra [Tue, 4 Feb 2020 23:09:15 +0000 (15:09 -0800)]
platform: sifive/fu540: Set tlb range flush limit to zero

It was reported that tlb range flush is not working on fu540.
Only tlb full flush seems to work on fu540 probably due to some
hardware errata.

Set the tlb flush limit to zero so that all tlb flush requests
are converted to full flush.

Signed-off-by: Atish Patra <atish.patra@wdc.com>
Reviewed-by: Anup Patel <anup.patel@wdc.com>
4 years agoplatform: Add an platform ops to return platform specific tlb flush limit
Atish Patra [Tue, 4 Feb 2020 23:09:14 +0000 (15:09 -0800)]
platform: Add an platform ops to return platform specific tlb flush limit

If a platform requires to perform a tlb full flush, they should set
the tlb_range_flush_limit value to zero. However, corresponding platform
API ignore the value and continue to return the default value.

Add a platform ops to retrieve platform specific tlb range flush limit.
The platform variable becomes redundant in presence of the platform ops.
Take this opportunity to remove the variable as well.

The default is still set to smallest page size in RISC-V (4KB), as there
is no way to figure out a best value for all platforms. Individual platform
should set it to the optimal value for their platform.

Signed-off-by: Atish Patra <atish.patra@wdc.com>
Reviewed-by: Anup Patel <anup.patel@wdc.com>
4 years agoplatform: Update UART base addresses for qemu/sifve_u
Nikita Ermakov [Fri, 24 Jan 2020 13:47:32 +0000 (16:47 +0300)]
platform: Update UART base addresses for qemu/sifve_u

In the QEMU [1] there was a change of the UART base addresses for
sifive_u machine to match the hardware. Make corresponding changes in
the opensbi for qemu/sifive_u platform.

[1] https://git.qemu.org/?p=qemu.git;a=commitdiff;h=4b55bc2b5f7ff065da5d2b813ee5153c598d3764

Signed-off-by: Nikita Ermakov <coffe92@gmail.com>
Reviewed-by: Anup Patel <anup.patel@wdc.com>
4 years agoplatform: template: typo fix in system reboot/shutdown names
Jiuyang Liu (Sequencer) [Fri, 24 Jan 2020 02:04:10 +0000 (07:34 +0530)]
platform: template: typo fix in system reboot/shutdown names

This patch does minor typo fix in system reboot/shutdown names
in platform operations.

Signed-off-by: Jiuyang Liu (Sequencer) <liujiuyang1994@gmail.com>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Signed-off-by: Anup Patel <anup.patel@wdc.com>
4 years agolib: Factor-out SBI base extension
Anup Patel [Fri, 17 Jan 2020 13:55:24 +0000 (19:25 +0530)]
lib: Factor-out SBI base extension

This patch factor-out SBI base extension into its own source
for better modularity of SBI implementation.

Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
4 years agolib: Factor-out SBI vendor extension
Anup Patel [Fri, 17 Jan 2020 13:42:52 +0000 (19:12 +0530)]
lib: Factor-out SBI vendor extension

This patch factor-out SBI vendor extension into its own source
for better modularity of SBI implementation.

Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
4 years agolib: Factor-out SBI replacement extensions
Anup Patel [Fri, 17 Jan 2020 13:02:07 +0000 (18:32 +0530)]
lib: Factor-out SBI replacement extensions

This patch factor-out SBI replacement extensions (such as RFENCE,
IPI, and TIME) into its own source for better modularity of SBI
implementation.

Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
4 years agolib: Factor-out SBI legacy extension
Anup Patel [Fri, 17 Jan 2020 12:39:49 +0000 (18:09 +0530)]
lib: Factor-out SBI legacy extension

This patch factor-out SBI legacy extension into its own source
for better modularity of SBI implementation.

Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
4 years agolib: Add dynamic registration of SBI extensions
Anup Patel [Thu, 16 Jan 2020 06:08:49 +0000 (11:38 +0530)]
lib: Add dynamic registration of SBI extensions

This patch extends our SBI ecall implementation to allow
dynamic registration of various SBI extensions. Using this
dynamic registration we can break-up SBI ecall implementation
into multiple files and even register experimental/custom
SBI extensions from platform code.

Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
4 years agoinclude: Add generic and simple list handling APIs
Anup Patel [Fri, 17 Jan 2020 11:12:41 +0000 (16:42 +0530)]
include: Add generic and simple list handling APIs

This patch adds generic and simple list handling APIs adapted
from Xvisor sources.

Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
4 years agolib: Initialize TLB management directly from coldboot/warmboot path
Anup Patel [Wed, 15 Jan 2020 08:01:12 +0000 (13:31 +0530)]
lib: Initialize TLB management directly from coldboot/warmboot path

Currently, the remote TLB management is initialized via IPI init
which is counter intuitive. This patch initializes remote TLB
management directly from init_coldboot() and init_warmboot()
after IPI init is done.

Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
4 years agolib: Drop _fifo from the name of various sbi_tlb_fifo_xyz() functions
Anup Patel [Wed, 15 Jan 2020 07:51:47 +0000 (13:21 +0530)]
lib: Drop _fifo from the name of various sbi_tlb_fifo_xyz() functions

This patch drops _fifo from the name of various sbi_tlb_fifo_xyz()
functions because all these functions deal with remote TLB managment
and FIFO is the per-HART data structure used internally by remote
TLB implementation.

Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
4 years agolib: Introduce sbi_ipi_event_create/destroy() APIs
Anup Patel [Wed, 15 Jan 2020 07:14:10 +0000 (12:44 +0530)]
lib: Introduce sbi_ipi_event_create/destroy() APIs

This patch introduces sbi_ipi_event_create/destroy() APIs and
struct sbi_ipi_event_ops for creating/destroying IPI events
at runtime based of event operations.

This new APIs will help platform code and utils code to create
custom IPI events which are not part of generic OpenSBI library.

Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
4 years agolib: Introduce sbi_tlb_fifo_request() API
Anup Patel [Wed, 15 Jan 2020 06:12:51 +0000 (11:42 +0530)]
lib: Introduce sbi_tlb_fifo_request() API

Instead of directly calling sbi_ipi_send_many(), we introduce
sbi_tlb_fifo_request() for halting a set of HARTs.

This way in future we can assign any IPI event number for remote
FENCE within sbi_tlb.c only.

Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
4 years agolib: Introduce sbi_ipi_send_halt() API
Anup Patel [Wed, 15 Jan 2020 05:46:54 +0000 (11:16 +0530)]
lib: Introduce sbi_ipi_send_halt() API

Instead of directly calling sbi_ipi_send_many(), we introduce
sbi_ipi_send_halt() for halting a set of HARTs.

This way in future we can assign any IPI event number for HART
halting within sbi_ipi.c only.

Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
4 years agolib: Introduce sbi_ipi_send_smode() API
Anup Patel [Wed, 15 Jan 2020 05:32:14 +0000 (11:02 +0530)]
lib: Introduce sbi_ipi_send_smode() API

Instead of directly calling sbi_ipi_send_many(), we introduce
sbi_ipi_send_smode() for injecting S-mode software interrupts.

This way in future we can assign any IPI event number for S-mode
IPIs within sbi_ipi.c only.

Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
4 years agolib: Move struct sbi_ipi_data definition to sbi_ipi.c
Anup Patel [Wed, 15 Jan 2020 05:18:56 +0000 (10:48 +0530)]
lib: Move struct sbi_ipi_data definition to sbi_ipi.c

The struct sbi_ipi_data is only used in sbi_ipi.c so move it
to sbi_ipi.c from sbi_ipi.h.

Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
4 years agoinclude: Typo fix in comment for SBI_SCRATCH_SIZE define
Anup Patel [Wed, 15 Jan 2020 05:15:45 +0000 (10:45 +0530)]
include: Typo fix in comment for SBI_SCRATCH_SIZE define

This patch fixes a minor typo in comment for SBI_SCRATCH_SIZE define.

Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
4 years agoscripts: Add C910 to platform list in the binary archive script
Liu Yibin [Sun, 19 Jan 2020 07:31:02 +0000 (15:31 +0800)]
scripts: Add C910 to platform list in the binary archive script

This patch adds T-HEAD C910 to RV64 platform list in the binary
archive script.

Signed-off-by: Liu Yibin <yibin_liu@c-sky.com>
Reviewed-by: Anup Patel <anup.patel@wdc.com>
4 years agoplatform: thead/c910: Don't set plic/clint address in warm boot
Liu Yibin [Mon, 13 Jan 2020 03:20:57 +0000 (11:20 +0800)]
platform: thead/c910: Don't set plic/clint address in warm boot

Since all harts share the same plic/clint address now, setting
them during cold boot is just fine.

Signed-off-by: Liu Yibin <yibin_liu@c-sky.com>
Reviewed-by: Anup Patel <anup.patel@wdc.com>
4 years agoplatform: thead/c910: Don't enable L2 cache in warm boot
Liu Yibin [Mon, 13 Jan 2020 03:20:56 +0000 (11:20 +0800)]
platform: thead/c910: Don't enable L2 cache in warm boot

Since all harts share the same L2 cache now, there's
no need to Enable L2 cache in warm boot.

Signed-off-by: Liu Yibin <yibin_liu@c-sky.com>
Reviewed-by: Anup Patel <anup.patel@wdc.com>
4 years agofirmware: Fix placement of .align directives
Andreas Schwab [Thu, 9 Jan 2020 11:49:38 +0000 (12:49 +0100)]
firmware: Fix placement of .align directives

Move the .align directives after switching the section.  We want to align
the start of the current section, not the end of the previous section.
This also obsoletes the misguided workaround of disabling relaxation.

Signed-off-by: Andreas Schwab <schwab@suse.de>
Reviewed-by: Anup Patel <anup.patel@wdc.com>
4 years agodocs: platform: Update SiFive FU540 doc as-per U-Boot v2020.01
Anup Patel [Wed, 8 Jan 2020 04:06:09 +0000 (09:36 +0530)]
docs: platform: Update SiFive FU540 doc as-per U-Boot v2020.01

With U-Boot v2020.01, the SiFive FU540 DTB required by U-Boot is
embedded in U-Boot binary itself so we don't need to do anything
special for U-Boot v2020.01 as payload to OpenSBI firmware.

This patch updates SiFive FU540 documenation assuming we use
latest U-Boot v2020.01 release.

Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
4 years agoplatform: thead/c910: Remove SBI_PLATFORM_HAS_PMP
Liu Yibin [Wed, 8 Jan 2020 06:50:35 +0000 (14:50 +0800)]
platform: thead/c910: Remove SBI_PLATFORM_HAS_PMP

T-head c910 is a generic FPGA platform so we cannot
define PMP configuration for it in OpenSBI because
PMP configuration tend to be SOC specific.

Signed-off-by: Liu Yibin <yibin_liu@c-sky.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
4 years agodocs: Add description of using OPENSBI_EXTERNAL_SBI_TYPES
Abner Chang [Wed, 8 Jan 2020 04:54:34 +0000 (12:54 +0800)]
docs: Add description of using OPENSBI_EXTERNAL_SBI_TYPES

Add description of using OPENSBI_EXTERNAL_SBI_TYPES in external
firmware code base.

Signed-off-by: Abner Chang <abner.chang@hpe.com>
Cc: Leif Lindholm <leif.lindholm@linaro.org>
Reviewed-by: Anup Patel <anup.patel@wdc.com>
4 years agoinclude: Add OPENSBI_EXTERNAL_SBI_TYPES in sbi_types.h
Abner Chang [Tue, 7 Jan 2020 07:08:26 +0000 (15:08 +0800)]
include: Add OPENSBI_EXTERNAL_SBI_TYPES in sbi_types.h

Add OPENSBI_EXTERNAL_SBI_TYPES macro to allow external definitions of data
types and common macros. Also move some common definitions from sbi_bits.h to sbi_types.h.

Signed-off-by: Abner Chang <abner.chang@hpe.com>
Cc: Leif Lindholm <leif.lindholm@linaro.org>
Reviewed-by: Anup Patel <anup.patel@wdc.com>
4 years agobuild: Use -ffreestanding
Khem Raj [Tue, 7 Jan 2020 02:41:06 +0000 (18:41 -0800)]
build: Use -ffreestanding

this is a stand-alone/baremetal application, therefore demanding
-ffreestanding would help it compile with hosted toolchains e.g. ( linux
toolchains ), it also ensures that it won't be using platform
optimizations like inlining mem* str* functions which gcc might decide
especially with wrapper string functions in opensbi code

Signed-off-by: Khem Raj <raj.khem@gmail.com>
Reviewed-by: Anup Patel <anup.patel@wdc.com>
4 years agolib: Add sbi_init_count() API
Anup Patel [Fri, 3 Jan 2020 09:43:33 +0000 (15:13 +0530)]
lib: Add sbi_init_count() API

We add sbi_init_count() API which provides number of times a
given HART completed init sequence (warmboot/coldboot).

This will be very useful in debugging. With upcoming SBI HSM
extension, it will also help in implementing one-time init
code for each HART.

Signed-off-by: Anup Patel <anup@brainfault.org>
Reviewed-by: Atish Patra <atish.patra@wdc.com>