Age | Commit message (Collapse) | Author | Files | Lines |
|
This patch simplify sbi_trap_handler() API as follows:
1. Remove current hartid local variable because sbi_trap_handler()
itself does not need it.
2. Remove scratch parameter because none of the functions directly
called by sbi_trap_handler() require it.
Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
|
|
A platform can have discontinuous and/or sparse HART ids so we
cannot always assume a set of HARTs with continuous HART ids.
This patch adds support for discontinuous and sparse HART ids by
introducing HART index to HART id table. This table has platform
hart_count entries and it maps HART index to HART id.
The HART index to HART id table has only two restrictions:
1. HART index < sbi_platform hart_count
2. HART id < SBI_HARTMASK_MAX_BITS
Example1:
Let's say we have a platform with 2 HART ids 11 and 22, for such a
a platform:
hart_count = 2
hart_index2id[0] = 11
hart_index2id[1] = 22
Example2:
Let's say we have a platform with 5 HARTs ids 0, 1, 2, 3, and 4
but out of these HART with id 0 is not usable so for such a platform:
hart_count = 5
hart_index2id[0] = -1U
hart_index2id[1] = 1
hart_index2id[2] = 2
hart_index2id[3] = 3
hart_index2id[4] = 4
OR
hart_count = 4
hart_index2id[0] = 1
hart_index2id[1] = 2
hart_index2id[2] = 3
hart_index2id[3] = 4
With HART index to HART id table in place, the hart_disabled()
callback is now redundant so we remove it as well.
Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
|
|
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>
|
|
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>
|
|
The state of a0, a1, and a2 registers in fw_prev_arg1() and
fw_next_arg1() is same as passed by previous booting stage
so we add this info in comments for both these functions.
Signed-off-by: Anup Patel <anup.patel@wdc.com>
|
|
Function fw_next_arg1 in firmware/fw_jump.S:59 and
firmware/fw_payload.S:63 should return real dtb
address(if specified in a1) in a0, in case we don't
want to specify FW_xyz_FDT_ADDR when compiling.
Signed-off-by: Liu Yibin <yibin_liu@c-sky.com>
Reviewed-by: Anup Patel <anup.patel@wdc.com>
|
|
It has been reported that link address range of previous booting stage
(such as U-Boot SPL) can overlap the link address rage of FW_DYNAMIC.
This means self-relocation in FW_DYNAMIC can potentially corrupt
previous booting stage if any of the secondary HART enter FW_DYNAMIC
before primary HART.
To tackle this, we add preferred boot HART field (i.e boot_hart) in
struct fw_dyanmic_info. We use this field to force secondary HARTs
into relocation wait loop till preferred/primary boot HART enters
FW_DYNAMIC completes self-relocation. If preferred boot HART is not
available then we fall back to relocation lottery approach.
Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
|
|
Instead of forcing HART0 to do the relocation and scratch init
work, we should have an atomic lottery to decide which HART does
the relocation and scratch init.
This way any HART can be boot/main HART.
Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
|
|
We get following compile error for FW_PAYLOAD with latest GCC
binutils:
fw_payload.o(.text+0x1961): 15 bytes required for alignment to 16-byte
boundary, but only 14 present
Further investigating, it turn-out to be a known issue with RISC-V
GCC binutils.
(Refer, https://github.com/riscv/riscv-gnu-toolchain/issues/298)
As a work-around, we disable relaxation when including DTB and
PAYLOAD binary in fw_payload.S.
Reported-by: David Abdurachmanov <david.abdurachmanov@sifive.com>
Signed-off-by: Anup Patel <anup.patel@wdc.com>
Tested-by: David Abdurachmanov <david.abdurachmanov@sifive.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
|
|
Current SBI implementation is now considered as version 0.1 and will be
removed/replaced with newer extension/functions in future.
Rename the existing implementations accordingly to be in sync with the
specification.
Signed-off-by: Atish Patra <atish.patra@wdc.com>
Reviewed-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Zong Li <zong.li@sifive.com>
|
|
Test payload uses an SBI call and uses the macros defined in interface
header which is not the correct place to have these definitions.
The interface header file should be used to keep SBI specification
related macros.
Keep all the test payload related code in test itself.
Signed-off-by: Atish Patra <atish.patra@wdc.com>
Reviewed-by: Anup Patel <anup.patel@wdc.com>
|
|
When hypervisor extension is available, we can get traps from VS/VU
modes. We should be able to force redirect some of these traps to
HS-mode. In other words, we should be able forward traps from VS/VU
mode to HS-mode using sbi_trap_redirect() hence this patch.
Signed-off-by: Atish Patra <atish.patra@wdc.com>
Signed-off-by: Anup Patel <anup.patel@wdc.com>
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
|
|
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>
|
|
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>
|
|
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.
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
This reverts commit 05602e2bf4812533adcb7acb1a67e43726c0e7bb.
Introducing a fence causes warm reset issue to reappear. Revert it
for the time being.
|
|
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>
|
|
Signed-off-by: Atish Patra <atish.patra@wdc.com>
|
|
Signed-off-by: Atish Patra <atish.patra@wdc.com>
|
|
Multi-core communication via memory requires the addition of a barrier
instructions to ensure cache coherency.
Signed-off-by: Xiang Wang <wxjstz@126.com>
|
|
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>
|
|
This patch extends our low-level trap handler in fw_base.S for
handling M-mode to M-mode traps without overwritting stack.
Signed-off-by: Anup Patel <anup.patel@wdc.com>
|
|
We expect the payloads to be 4 bit alligned as we later AND them
with ~0xf. As most of the addresses are manually specified we don't
really need this, but better to be over cautious.
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
|
|
Some older toolchains may not have all the csr's defined. Update all
the csr functions to use the CSR_ #define values instead of the
toolchain defined values.
Signed-off-by: Atish Patra <atish.patra@wdc.com>
|
|
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
|
|
Signed-off-by: Andreas Schwab <schwab@suse.de>
|
|
This patch updates copyright header in all files as follows:
1. Makes "SPDX-License-Identifier: BSD-2-Clause" as first line
2. Change copyright year to 2019 for Western Digital
Signed-off-by: Anup Patel <anup.patel@wdc.com>
|
|
The secondary hart waits for an IPI signal from the boot hart to
executing boot code (hot boot). As a result, software generated
interrupts have to be enabled for secondary harts before waiting for
the boot hart boot completion IPI signal.
Enabling software generated interrupts (IPI) can be done independently
of the firmware code and moved to libsbi code so that the different
firmware do not have to implement this.
Signed-off-by: Atish Patra <atish.patra@wdc.com>
|
|
Define sbi_ecall_console_puts() using sbi_ecall_console_putchar()
renamed as sbi_ecall_console_putc() and remove the hardcoded version
of the same funtion in the test payload code.
Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
|
|
Use a more neutral term more representative of this payload intent.
Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
|
|
Add rules to compile dts files into dtb files using the device tree
compiler (dtc). A platform can specify the DTS file to compile using
the platform-dtb-y variable. The flattened device tree binary file to be
used for building the final polatform firmware can be specified using
the new FW_PAYLOAD_FDT firmware configuration option to point to the
automatically compiled FDT file. Using the existing FW_PAYLOAD_FDT_PATH
configuration option is still possible and will take precedence over
the FW_PAYLOAD_FDT definition.
Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
|
|
The firmware payload offset defined by FW_PAYLOAD_OFFSET must
specify a value large enough so the the payload does not overlap
with the base firmware data, bss and text. For platforms without
any strong requirement on the payload address, introduce the
FW_PAYLOAD_ALIGN build parameter to automatically place the payload
right after the base firmware at an address aligned with the defined
value.
Either FW_PAYLOAD_OFFSET or FW_PAYLOAD_ALIGN should be defined by a
platform configuration. If both FW_PAYLOAD_OFFSET and FW_PAYLOAD_ALIGN
are defined by a platform, FW_PAYLOAD_OFFSET has precedence and is
used for building the final firmawre image.
Using FW_PAYLOAD_ALIGN=4096 with the Kendryte platform rather than
the abitrary FW_PAYLOAD_OFFSET=0x10000 value reduces the final
firmware image size by about 20KB.
Add a description of the FW_PAYLOAD_ALIGN configuration parameter in the
fw_payload documentation file as well. And while at it, also fix
various grammar and style issues in that file..
Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
|
|
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
|
|
The tmp0 member was added in struct sbi_scratch to assist
register save/restore at time of trap handling. This tmp0
is not unsed any more hence removing it.
Signed-off-by: Anup Patel <anup.patel@wdc.com>
|
|
The struct sbi_trap_regs related defines RISCV_TRAP_REGS_xyz should
be in sbi_trap.h so that we can keep these defines in-sync with changes
in struct sbi_trap_regs.
Signed-off-by: Anup Patel <anup.patel@wdc.com>
|