Age | Commit message (Collapse) | Author | Files | Lines |
|
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>
|
|
The struct sbi_platform related defines RISCV_PLATFORM_xyz should
be in sbi_platform.h so that we can keep these defines in-sync
with changes in struct sbi_platform.
Signed-off-by: Anup Patel <anup.patel@wdc.com>
|
|
The struct sbi_scratch related defines RISCV_SCRATCH_xyz should
be in sbi_scratch.h so that we can keep these defines in-sync
with changes in struct sbi_scratch.
Signed-off-by: Anup Patel <anup.patel@wdc.com>
|
|
The fw_common.S is the base firmware extendend by fw_jump and
fw_payload. This patch renames fw_common.S to fw_base.S to
have more clear/intutive name for base firmware.
Signed-off-by: Anup Patel <anup.patel@wdc.com>
|
|
We use recently added separate dummy payload for FW_PAYLOAD
when FW_PAYLOAD_PATH is not specified.
Signed-off-by: Anup Patel <anup.patel@wdc.com>
|
|
Currently, the default payload for FW_PAYLOAD is embedded
fw_payload.S itself. This means people have to hack fw_payload.S
if they want to have some temporary S-mode test code.
This patch adds a separate dummy payload for FW_PAYLOAD which
can be easily hacked for some S-mode testing.
Signed-off-by: Anup Patel <anup.patel@wdc.com>
|
|
The hart_count and hart_stack_size information is already available
in "struct sbi_platform" so we use that instead of depending on
PLAT_HART_COUNT and PLAT_HART_STACK_SIZE.
Signed-off-by: Anup Patel <anup.patel@wdc.com>
|
|
We don't need a separate stack section for per-HART stack
instead we create per-HART stack at the end of firmware
(i.e. after _fw_end symbol).
Signed-off-by: Anup Patel <anup.patel@wdc.com>
|
|
The mideleg and medeleg are already programmed in delegate_traps()
so no need to set it here.
Any CSR setup in our reference firmware becomes a requirement
for bootloader linking to libsbi.a so we should have minimum
possible CSR setup in our reference firmware.
Signed-off-by: Anup Patel <anup.patel@wdc.com>
|
|
This patch reverts "Fix FDT relocation" because it breaks
fw_jump firmware.
Signed-off-by: Anup Patel <anup.patel@wdc.com>
|
|
Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
|
|
Also disable interrupts and exceptions delegation when clearing mie and
mip.
Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
|
|
Or rather, disable it if FW_PAYLOAD_FDT_ADDR is not defined. This
correspond to cases where the underlying FW that loaded and started
opensbi did not provide any FDT. In such case, the platform code will
need to prepare one.
Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
|
|
This patch renames "blob" to "firmware" everywhere for better
and intutive naming.
Signed-off-by: Anup Patel <anup@brainfault.org>
|