Commit graph

839 commits

Author SHA1 Message Date
Alistair Francis
9829a86e8d
Merge pull request #16 from damien-lemoal/master
Various fixes
2019-01-03 07:52:42 -08:00
Damien Le Moal
c37a8508d1 platform: kendryte/k210: Simplify sysctl code
Simplify sysctl.c code to only the used CPU freqency function.
This reduces the size of the final firmware by 4KB.

Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
2019-01-03 14:32:25 +09:00
Damien Le Moal
4079df63a7 platform: kendryte/k210: Declare local function static
k210_console_putc() and k210_console_init() are local functions. Declare
them as static.

Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
2019-01-03 13:34:32 +09:00
Damien Le Moal
da86853a51 Makefile: Fix messages
Instead of printing the generic "<build_directory>" and
"<install_directory>" strings, print the actual paths for the build
and install directories during "make clean" and "make distclean".

Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
2019-01-03 13:27:17 +09:00
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
24bfa687fc include: Replace #csr with __ASM_STR(csr) in csr_xyz() macros
We replace #csr with __ASM_STR(csr) in all csr_xyz() macros
so that we can pass CSR number instead of CSR name when GCC
is not aware of CSR name.

Signed-off-by: Anup Patel <anup.patel@wdc.com>
2019-01-02 09:57:12 +05:30
Anup Patel
81e8950abe include: Remove redundant csr_read_n() and csr_write_n()
The patch removes redundant csr_read_n() and csr_write_n()
because same thing can be achieved by using __ASM_STR()
macro in csr_read() and csr_write() macros.

Signed-off-by: Anup Patel <anup.patel@wdc.com>
2019-01-02 09:57:12 +05:30
Anup Patel
d0bbbbb8fd docs: Add documenation for QEMU platforms
This patch adds documentation for qemu/virt and
qemu/sifive_u platform supports.

Signed-off-by: Anup Patel <anup.patel@wdc.com>
2018-12-31 09:33:04 +05:30
Anup Patel
5688b4d8fc top: Minor typo fixes in top-level README.md
This patch does minor typo fixes in top-level README.md.

Signed-off-by: Anup Patel <anup.patel@wdc.com>
2018-12-31 09:33:04 +05:30
Anup Patel
5959312a5c lib: Redirect illegal instruction trap to S-mode when not handled
Currently, we fail with error SBI_ENOTSUPP when we are not able
to handle illegal instruction trap. Instead, we should just
redirect illegal instruction trap to S-mode when not handled.

This redirection of illegal instruction trap will help lazy
save/restore of floating point registers to work correctly in
Linux kernel.

Signed-off-by: Anup Patel <anup.patel@wdc.com>
2018-12-31 09:28:26 +05:30
Anup Patel
56e41f7a8d platform: Fix author name for Kendryte K210 platform
The Kendryte K210 platform support was contributed by Damien
hence fix author name.

Signed-off-by: Anup Patel <anup.patel@wdc.com>
2018-12-31 09:27:50 +05:30
Anup Patel
d461d5b790 platform: Rename sifive/hifive_u540 to sifive/fu540
We rename sifive/hifive_u540 platform support to sifive/fu540
to match the SoC name which is SiFive FU540 (as-per user manual).

In fact, we can expect no (or very minimal) board specific
quirks in sifive/fu540 platform support. These board specific
quirks can be turned on/off in-future using PLATFORM_<xyz>
make command-line option.

Signed-off-by: Anup Patel <anup.patel@wdc.com>
Signed-off-by: Atish Patra <atish.patra@wdc.com>
2018-12-31 09:27:50 +05:30
Anup Patel
f2d4c5f291 lib: Print mtval in sbi_trap_error()
The mtval CSR is very useful information when debugging hence
print it upon trap error in sbi_trap_error().

Signed-off-by: Anup Patel <anup.patel@wdc.com>
2018-12-27 10:06:38 +05:30
Anup Patel
45f874da6c lib: Rename target_hart parameter to hartid for PMP platform callbacks
We rename target_hart parameter of PMP platform callbacks to
hartid for clarity because the parameter represents current
hartid.

Signed-off-by: Anup Patel <anup.patel@wdc.com>
2018-12-27 09:35:09 +05:30
Anup Patel
52ed1d1709 lib: Simplify sbi_platform timer_init() hooks
Instead of having separate timer_init() hooks for cold and
warm boot, this patch updates struct sbi_platform to have just
one timer_init() hook. The type of boot (cold or warm) is now
a boolean flag parameter for the updated timer_init() hook.

Signed-off-by: Anup Patel <anup.patel@wdc.com>
2018-12-27 09:35:09 +05:30
Anup Patel
c1b6200653 lib: Simplify sbi_platform ipi_init() hooks
Instead of having separate ipi_init() hooks for cold and warm boot,
this patch updates struct sbi_platform to have just one ipi_init()
hook. The type of boot (cold or warm) is now a boolean flag parameter
for the updated ipi_init() hook.

Signed-off-by: Anup Patel <anup.patel@wdc.com>
2018-12-27 09:35:09 +05:30
Anup Patel
e34aa8a671 lib: Simplify sbi_platform irqchip_init() hooks
Instead of having separate irqchip_init() hooks for cold and
warm boot, this patch updates struct sbi_platform to have just
one irqchip_init() hook. The type of boot (cold or warm) is now
a boolean flag parameter for the updated irqchip_init() hook.

Signed-off-by: Anup Patel <anup.patel@wdc.com>
2018-12-27 09:35:09 +05:30
Anup Patel
7b59571758 lib: Simplify sbi_platform early_init() and final_init() hooks
Instead of having separate early_init() and final_init() hooks
for cold and warm boot, this patch updates struct sbi_platform
to have just one early_init() and one final_init() hook. The
type of boot (cold or warm) is now a boolean flag parameter for
the updated early_init() and final_init() hooks.

Signed-off-by: Anup Patel <anup.patel@wdc.com>
2018-12-27 09:35:09 +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
4c1d5a5d2d top: Improve 'clean' and 'distclean' makefile targets
This improves 'clean' and 'distclean' makefile target as follows:
1. Remove only .o, .a, .elf, and .bin files for 'clean'
2. Remove .dep in-addition to what 'clean' does for 'distclean'
3. Remove default build and install directory for 'distclean'

Signed-off-by: Anup Patel <anup.patel@wdc.com>
2018-12-27 09:30:12 +05:30
Anup Patel
a4ce793121 top: Improve inst_file_list() in Makefile for payloads installation
We now have payloads sub-directory under firmware directory which
means payload BINs and ELFs should be installed under firmware/payloads.

This patch improves inst_file_list() to handle payloads sub-directory
under firmware installation directory.

Signed-off-by: Anup Patel <anup.patel@wdc.com>
2018-12-27 09:29:29 +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
b46970b47e lib: Move ECALL defines to sbi_ecall_interface.h
This patch moves all ECALL defines to sbi_ecall_interface.h so
that it can be shared with firmware payloads.

Signed-off-by: Anup Patel <anup.patel@wdc.com>
2018-12-27 09:29:29 +05:30
Anup Patel
b5ae8e8a65 lib: Add misaligned load/store trap handling
We generally don't get misaligned load/store traps from Linux/U-Boot
compiled using GCC 8.2 or higher but this is not true with older
GCC toolchains. To tackle this we add misaligned load/store trap
handling adopted from BBL sources but much more simpler.
(Note: BBL sources can be found at https://github.com/riscv/riscv-pk.git)

Signed-off-by: Anup Patel <anup.patel@wdc.com>
2018-12-26 11:14:22 +05:30
Anup Patel
96f66f79ca lib: Move instruction encoding macros to riscv_encoding.h
This patch moves all instruction encoding macros to
riscv_encoding.h.

Signed-off-by: Anup Patel <anup.patel@wdc.com>
2018-12-26 11:14:22 +05:30
Anup Patel
fd7199920e top: Rename back CROSS_COMPILE_PREFIX to CROSS_COMPILE
The name CROSS_COMPILE is an industry standard used across
open-source project to specify cross-compiler prefix.

In fact, distro build systems such as buildroot and yocto
assume CROSS_COMPILE to be supported by projects added
as packages to these build systems.

This patch rename back CROSS_COMPILE_PREFIX to CROSS_COMPILE.

Signed-off-by: Anup Patel <anup.patel@wdc.com>
2018-12-26 10:57:15 +05:30
Damien Le Moal
23e2c594cc README: Update
Some rewrite with a more formal style.

Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
2018-12-25 16:01:27 +09:00
Damien Le Moal
fb3cbe6481 Makefile: Fix clean
Clean was doing nothing. Fix it to remove all compiled files, leaving
only dependency files.

Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
2018-12-25 16:01:27 +09:00
Damien Le Moal
d06dca9bcc Makefile: Rename CROSS_COMPILE to CROSS_COMPILE_PREFIX
Make it clear what this environment variable defines and update
the README.md file to explain that.

Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
2018-12-25 15:37:48 +09:00
Atish Patra
fef12701fd
Merge pull request #4 from riscv/avpatel/master
Remove PLAT_<xyz> defines from platform and firmwares
2018-12-22 10:02:52 -08:00
Anup Patel
4e8d078613 top: Typo fix in top-level README.md
The platform specific options will be PLATFORM_<xyz> and not
PLAT_<xyz> hence this patch fixes typo in top-level README.md.

Signed-off-by: Anup Patel <anup.patel@wdc.com>
2018-12-22 21:14:23 +05:30
Anup Patel
472d3f4e17 platform: Remove PLAT_HART_COUNT and PLAT_HART_STACK_SIZE
The PLAT_HART_COUNT and PLAT_HART_STACK_SIZE are only used
by platform code so no need of exposing these to everyone
by adding it to platform-cppflags-y.

Signed-off-by: Anup Patel <anup.patel@wdc.com>
2018-12-22 21:01:40 +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
24b4d48674 platform: Remove PLAT_NAME from all platforms
The PLAT_NAME is used only in platform.c for all platforms hence
remove it.

Signed-off-by: Anup Patel <anup.patel@wdc.com>
2018-12-22 20:49:52 +05:30
Anup Patel
51d3964f07
Merge pull request #3 from riscv/unleashed_working_12_21
Unleashed working 12 21
2018-12-22 20:42:48 +05:30
Atish Patra
8304ee9424 Disable all interrupts during warm irqchip init.
M mode is not expected to recieve any interrupts.
S mode interrupts shouldn't be enabled in M mode.

Signed-off-by: Atish Patra <atish.patra@wdc.com>
2018-12-21 22:11:21 -08:00
Atish Patra
88b173b33b Introduce hart disabled parameter in platform.
As of now, uboot doesn't have support for SMP.
Moreover, unleashed board has a E51 hart which
doesn't not support S mode.

We should only boot only 1 non-zero hart.

Signed-off-by: Atish Patra <atish.patra@wdc.com>
2018-12-21 22:11:21 -08:00
Anup Patel
a6a5bb22a8 Fix plic warm init in platform code.
Pass S-Mode and M-mode context id separately to common warm init.

Signed-off-by: Atish Patra <atish.patra@wdc.com>
Signed-off-by: Anup Patel <anup.patel@wdc.com>
2018-12-21 22:11:21 -08:00
Anup Patel
5148499e03 Fix plic warm init in common code.
Unleashed doesn't have S mode for hart 0.
PLIC register base calculation is current wrong because of that.

Signed-off-by: Atish Patra <atish.patra@wdc.com>
Signed-off-by: Anup Patel <anup.patel@wdc.com>
2018-12-21 22:11:10 -08:00
Atish Patra
95fbe7d495 Move hardcoded uart constant to macros.
Signed-off-by: Atish Patra <atish.patra@wdc.com>
2018-12-21 16:00:28 -08:00
Damien Le Moal
27332e63fa Introduce HAS_MFAULTS_DELEGATION feature
Conditionnally delegate page fault exceptions from M mode to S mode
based on the platform features.

Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
2018-12-21 16:32:30 +05:30
Anup Patel
db6c1fe78b platform: kendryte/k210: Don't include math.h
The math.h is not required anymore and it also gives
compile error for certain toolchains hence thsi patch
removes math.h include from kendryte/k210/sysctl.c.

Signed-off-by: Anup Patel <anup.patel@wdc.com>
2018-12-21 15:32:28 +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
Anup Patel
a18913200a lib: Remove prints from sbi_hart_switch_mode()
The sbi_hart_switch_mode() will be used by CPU hotplug. This means
if we have prints in sbi_hart_switch_mode() then these prints will
mix with Linux prints.

Being a runtime firmware, we should be verbose only at coldboot
time and error situations.

Signed-off-by: Anup Patel <anup.patel@wdc.com>
2018-12-21 14:54:06 +05:30