The source_hart and hartid parameter is really not required in
IPI callbacks of sbi_platform because current hartid can always
be obtained by calling sbi_current_hartid() API.
Signed-off-by: Anup Patel <anup.patel@wdc.com>
Add a space before (FW_JUMP) to make it more readable.
This also fixes "No newline at end of file" warning.
Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
There are 2 markdown links that are currently broken in top-level
README.md. Fix them so that github could render the URL correctly.
This also fixes "No newline at end of file" warning.
Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
This patch adds doxygen style documenation for struct sbi_platform
and related functions/macros/defines.
Signed-off-by: Anup Patel <anup.patel@wdc.com>
We don't need to pre-enable MSIP in MIE CSR when
calling sbi_init() from firmware. This patch updates
documentation accordingly.
Signed-off-by: Anup Patel <anup.patel@wdc.com>
We don't need to install generic headers separately for every
platforn under <install_dir>/platform. It is unnecessary duplication
of files hence updating install_libplatsbi in top-level makefile.
Signed-off-by: Anup Patel <anup.patel@wdc.com>
The PDF document generated by doxygen should have OpenSBI version
hence this patch adds OpenSBI version to doxygen.cfg.
Signed-off-by: Anup Patel <anup.patel@wdc.com>
As per the RISC-V ISA, mideleg and medeleg registers should not exist
if S-mode is not present for a hart.
We shouldn't access these CSRs if non S-mode harts.
Signed-off-by: Atish Patra <atish.patra@wdc.com>
S-mode software may send IPI to self. For example,
tlbflush may be executed for the same hart.
Let the hart send IPI to itself. It's an overhead
but doesn't break anything. However, if we don't
allow it, it breaks if S-mode keep sending IPIs.
Signed-off-by: Atish Patra <atish.patra@wdc.com>
IPIs are updated in scratch space by source hart.
However, different harts or same hart may want to
send different IPIs before previous IPI was read
by the target hart. Currently, previous IPI type
is overwritten in that case.
Use atomic bit set/clear operations to update IPIs.
Signed-off-by: Atish Patra <atish.patra@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>
We should use AMO instructions whenever __riscv_atomic is
defined (i.e. atomics are supported). We use LR/SC only when
__riscv_atomic is not defined.
Signed-off-by: Anup Patel <anup.patel@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>
The Kendryte k210 board initial loader does not provide a device tree
for the firmware and subsequent payload. Add the k210.dts device tree
description file to solve this. This file describes only the SoC core
components: CPUs, memory and PLIC.
Automatically compile and add this file to the firmware generated
using the FW_PAYLOAD_FDT_PATH configuration parameter.
Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
Repeating "ifdef CROSS_COMPILE" multiple times does not help with
readability. Simplify by grouping compilation command setup under a
single ifdef statement.
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>
Use commonly accepted styles: newlines after declarations and before
return to make the code more readable.
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>
Avoid using standard includes namely stdint.h, string.h, stdlib.h, etc.
All standard include except stddef.h give compilation error due
to differences in RISC-V toolchain configuration. Typically, the
compilation error is related to "gnu-stubs-lp64.h".
This patch fixes compile error caused by standard includes by
providing substitutes of definetions provided by standard includes
wherever required.
Signed-off-by: Anup Patel <anup.patel@wdc.com>
PLIC DT entry fixup can be done by comparing external
interrupt number instead of context id. No need to invoke
fixup for each plic context.
Signed-off-by: Atish Patra <atish.patra@wdc.com>
Perform following DT updates.
1. Mask hart if mmu is not supported.
2. Add stdout-path under chosen node.
Signed-off-by: Atish Patra <atish.patra@wdc.com>
There are couple of string function defined in platform
code. We no longer need them as we can directly link minimal
libc.
Every platform required to inclde this as PLIC driver required
libc functions.
Signed-off-by: Atish Patra <atish.patra@wdc.com>
Some of the platform (i.e. SiFive FU540) requires Device
Tree modification before it is passed to higher stages.
Add libfdt support now to help this process. Libfdt should
only be included per platform basis.
Signed-off-by: Atish Patra <atish.patra@wdc.com>
This patch adds doxygen style documentation for struct sbi_trap_regs
and related macros/defines/functions.
Signed-off-by: Anup Patel <anup.patel@wdc.com>
There are quite a few noreturn functions in OpenSBI hence
we add commong __noreturn define for noreturn functin attribute.
Signed-off-by: Anup Patel <anup.patel@wdc.com>
This patch extends top-level makefile to build and install
documentation. The 'docs' make target is for building the
documentation PDF whereas 'install_docs' make target is for
installing the documentation PDF.
Signed-off-by: Anup Patel <anup.patel@wdc.com>
The '?=' will not assign value if the target make variable is
overriden via command-line or is set in environment variable.
On other hand, '=' will not assign value only if variable is
overriden via command-line parameter.
It is quite common to have CC, AS, CPP, LD, etc to be set as
environment variables pointing to native compiler and binutils.
If '-rR' option is not set in MAKEFLAGS then this results in
compile error because '?=' will use the native compiler and
binutils. If '-rR' option is set in MAKEFLAGS then this again
results in compile error because CC, AS, CPP, etc are set to
empty strings which causes '?=' to use empty string as compiler
and binutils.
To handle this, we use '?=' only when CROSS_COMPILE is not
defined and we use '=' when CROSS_COMPILE is defined.
Signed-off-by: Anup Patel <anup.patel@wdc.com>
To avoid this message (and subsequent errors):
warning: linker input file unused because linking not done
force GCC to treat the linker script preprocessing as a C file.
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
Convert the Makefile to a more standard format and don't forcefully
overwrite a users enviroment.
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
Instead of using a confusing and custom option, allow verbose Makefile
with the standard V=1.
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>