aboutsummaryrefslogtreecommitdiff
path: root/firmware
AgeCommit message (Collapse)Author
2019-04-24all: run clang-format and update checked-in filesOlof Johansson
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>
2019-04-09TOP: Allow building platform out-of-treeAnup Patel
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>
2019-04-04firmware: Fix source fdt alignmentXiang Wang
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>
2019-03-29firmware: Introduce "options" in "struct sbi_scratch"Bin Meng
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>
2019-03-14firmware: Move scratch setup to _start instead of _start_warmAtish Patra
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>
2019-03-10lib: Create a sbi_ipi_data structureAlistair Francis
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>
2019-03-07firmware: Reset all registers and flush icacheAtish Patra
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>
2019-03-07firmware: Add nop to reduce bus traffic.Atish Patra
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>
2019-03-07Revert "firmware: Add a barrier instruction for wait for boot hart"Atish Patra
This reverts commit 05602e2bf4812533adcb7acb1a67e43726c0e7bb. Introducing a fence causes warm reset issue to reappear. Revert it for the time being.
2019-03-06firmware: Reset all the general purpose registers to zero.Atish Patra
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>
2019-03-06firmware: Ensure the mtvec is updated.Atish Patra
Signed-off-by: Atish Patra <atish.patra@wdc.com>
2019-03-06firmware: Fix a typoAtish Patra
Signed-off-by: Atish Patra <atish.patra@wdc.com>
2019-03-05firmware: Add a barrier instruction for wait for boot hartXiang Wang
Multi-core communication via memory requires the addition of a barrier instructions to ensure cache coherency. Signed-off-by: Xiang Wang <wxjstz@126.com>
2019-03-05firmware: Move _boot_hart_done to the data sectionXiang Wang
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>
2019-02-20firmware: Improve low-level trap handler for M-mode to M-mode trapsAnup Patel
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>
2019-02-15firmware: Ensure the payloads are 4 bit allignedAlistair Francis
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>
2019-02-14firmware: Use CSR_<FOO> instead of <foo> for csr*Atish Patra
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>
2019-02-08firmware: Use lw instead of lwu for 32-bit architecturesAlistair Francis
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
2019-02-06firwmare: don't expand macros in FW_PAYLOAD_PATHAndreas Schwab
Signed-off-by: Andreas Schwab <schwab@suse.de>
2019-01-24all: Update copyright header in all filesAnup patel
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>
2019-01-22lib: Move software interrupt enablement from firmware to libAtish Patra
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>
2019-01-21sbi: Add ecall helpersDamien Le Moal
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>
2019-01-21payload: rename dummy payload to test payloadDamien Le Moal
Use a more neutral term more representative of this payload intent. Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
2019-01-21Makefile: Add support for device tree compilationDamien Le Moal
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>
2019-01-21build: Introduce FW_PAYLOAD_ALIGNDamien Le Moal
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>
2019-01-04Makefile: Use generic flags for the firmwareAlistair Francis
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
2019-01-02include: Remove redundant tmp0 from struct sbi_scratchAnup Patel
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>
2019-01-02include: Move RISCV_TRAP_REGS_xyz defines to sbi_trap.hAnup Patel
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>
2019-01-02include: Move RISCV_PLATFORM_xyz defines to sbi_platform.hAnup Patel
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>
2019-01-02include: Move RISCV_SCRATCH_xyz defines to sbi_scratch.hAnup Patel
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>
2018-12-27firmware: Rename fw_common.S to fw_base.SAnup Patel
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>
2018-12-27firmware: Use dummy payload for FW_PAYLOADAnup Patel
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>
2018-12-27firmware: Add separate dummy payload for FW_PAYLOADAnup Patel
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>
2018-12-22firmware: Don't depend on PLAT_HART_COUNT and PLAT_HART_STACK_SIZEAnup Patel
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>
2018-12-22firmware: Remove stack section from common linker scriptAnup Patel
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>
2018-12-21firmware: Remove redundant write to mideleg and medelegAnup Patel
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>
2018-12-21Revert "Fix FDT relocation"Anup Patel
This patch reverts "Fix FDT relocation" because it breaks fw_jump firmware. Signed-off-by: Anup Patel <anup.patel@wdc.com>
2018-12-21Fiw comment typoDamien Le Moal
Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
2018-12-21fw: Disable delegationDamien Le Moal
Also disable interrupts and exceptions delegation when clearing mie and mip. Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
2018-12-21Fix FDT relocationDamien Le Moal
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>
2018-12-21top: Rename "blob" to "firmware" everywhereAnup Patel
This patch renames "blob" to "firmware" everywhere for better and intutive naming. Signed-off-by: Anup Patel <anup@brainfault.org>