Commit graph

126 commits

Author SHA1 Message Date
Alistair Francis
d369e721e8 firmware: Ensure the payloads are 4 bit alligned
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-15 09:56:47 +05:30
Atish Patra
35e617385f firmware: Use CSR_<FOO> instead of <foo> for csr*
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-14 09:31:18 +05:30
Alistair Francis
4f32b13802 firmware: Use lw instead of lwu for 32-bit architectures
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
2019-02-08 09:18:46 +05:30
Andreas Schwab
93f806af32 firwmare: don't expand macros in FW_PAYLOAD_PATH
Signed-off-by: Andreas Schwab <schwab@suse.de>
2019-02-06 10:39:17 +05:30
Anup patel
20990ee0ab all: Update copyright header in all files
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-24 14:07:47 +05:30
Atish Patra
784a4657c0 lib: Move software interrupt enablement from firmware to lib
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-22 10:03:49 +05:30
Damien Le Moal
b5be19f9e5 sbi: Add ecall helpers
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-21 09:58:33 +05:30
Damien Le Moal
42283461d3 payload: rename dummy payload to test payload
Use a more neutral term more representative of this payload intent.

Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
2019-01-21 09:58:33 +05:30
Damien Le Moal
0df8269477 Makefile: Add support for device tree compilation
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-21 09:58:33 +05:30
Damien Le Moal
ac3041f4e9 build: Introduce FW_PAYLOAD_ALIGN
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-21 09:58:33 +05:30
Alistair Francis
d6ddfdce39 Makefile: Use generic flags for the firmware
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
2019-01-04 08:20:50 +05:30
Anup Patel
5797ae2035 include: Remove redundant tmp0 from struct sbi_scratch
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-02 18:06:14 -08:00
Anup Patel
dc7be34d52 include: Move RISCV_TRAP_REGS_xyz defines to sbi_trap.h
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-02 09:57:12 +05:30
Anup Patel
5ed3cf3707 include: Move RISCV_PLATFORM_xyz defines to sbi_platform.h
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-02 09:57:12 +05:30
Anup Patel
e0d6914b3c include: Move RISCV_SCRATCH_xyz defines to sbi_scratch.h
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>
2019-01-02 09:57:12 +05:30
Anup Patel
cfa3fba14f firmware: Rename fw_common.S to fw_base.S
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-27 09:30:12 +05:30
Anup Patel
2d90226e04 firmware: Use dummy payload for FW_PAYLOAD
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-27 09:29:29 +05:30
Anup Patel
bb3665d0f0 firmware: Add separate dummy payload for FW_PAYLOAD
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-27 09:29:29 +05:30
Anup Patel
58ca525a7d firmware: Don't depend on PLAT_HART_COUNT and PLAT_HART_STACK_SIZE
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-22 20:49:52 +05:30
Anup Patel
1cf7ec9e3b firmware: Remove stack section from common linker script
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-22 20:49:52 +05:30
Anup Patel
ef5f4e149c firmware: Remove redundant write to mideleg and medeleg
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-21 15:05:59 +05:30
Anup Patel
4e15d79419 Revert "Fix FDT relocation"
This patch reverts "Fix FDT relocation" because it breaks
fw_jump firmware.

Signed-off-by: Anup Patel <anup.patel@wdc.com>
2018-12-21 15:04:21 +05:30
Damien Le Moal
4fb23c49eb Fiw comment typo
Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
2018-12-21 16:35:33 +09:00
Damien Le Moal
8f91d1142e fw: Disable delegation
Also disable interrupts and exceptions delegation when clearing mie and
mip.

Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
2018-12-21 15:09:13 +09:00
Damien Le Moal
513474cd1b Fix FDT relocation
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-21 15:09:13 +09:00
Anup Patel
b023176c17 top: Rename "blob" to "firmware" everywhere
This patch renames "blob" to "firmware" everywhere for better
and intutive naming.

Signed-off-by: Anup Patel <anup@brainfault.org>
2018-12-21 09:52:27 +05:30