Commit Graph

263 Commits

Author SHA1 Message Date
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
Anup Patel
1bfa244505 lib: Fix delegate_traps() for Linux boot
commit d403c70fb1 breaks Linux
booting because of fewer exceptions delegated to S-mode. This
patch fixes Linux booting by having all required exceptions
delegated to S-mode.

Signed-off-by: Anup Patel <anup.patel@wdc.com>
2018-12-21 14:54:06 +05:30
Damien Le Moal
e1e8f18130 console: protect output with a spinlock
Avoid getting messages from multiple harts mingled into garbage text
with a spinlock serializing calls to sbi_puts() and sbi_printf().

Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
2018-12-21 18:12:58 +09:00
Damien Le Moal
07ee5f2e32 Kendryte-k210: Remove unnecessary asm functions
Use functions defined in sbi/riscv_asm.h.

Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
2018-12-21 17:20:56 +09:00
Damien Le Moal
5563a03354 Introduce sbi_current_hartid()
Use this helper instead of hardcoding csr_read(mhartid).

Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
2018-12-21 17:06:59 +09:00
Damien Le Moal
426adf9f60 Cleanup and rename sbi_hart_boot_next()
Cleanup sbi_hart_boot_nexti() code, adding messages for clarity and
rename the function to sbi_hart_switch_mode() to reflect what the
function actually does.

Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
2018-12-21 16:44:53 +09:00
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
745ae45e65 Update Kendryte k210 support
Booting now.

Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
2018-12-21 15:12:22 +09:00
Damien Le Moal
d403c70fb1 Fix interrupt and exception delegation
When S mode is not supported, simply clear mideleg and medeleg.
Otherwise, set delegation from M-mode to S-mode, removing the page
fault exceptions as those would not happen in M-mode.

Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
2018-12-21 15:12:22 +09:00
Damien Le Moal
9c183df632 Add a hang message
Make it clear that the end of the FW execution was reached without the
hand being passed to any payload.

Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
2018-12-21 15:12:22 +09:00
Damien Le Moal
84df181c84 Add a banner
Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
2018-12-21 15:09:13 +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
Damien Le Moal
aa68f0252f Refine platform features control
Allow a platform to report its supported features in more details.
The new features defined are:
* SBI_PLATFORM_HAS_PMP
* SBI_PLATFORM_HAS_SCOUNTEREN
* SBI_PLATFORM_HAS_MCOUNTEREN

In addition, define the macro SBI_PLATFORM_DEFAULT_FEATURES as the set
of features that are generally expected to be supported by a Linux
capable platform.

Operations touching the features controlled with these falgs are not
executed if the platform does not set the corresponding feature flags.

Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
2018-12-21 15:09:13 +09:00
Atish Patra
f003787455 lib: Hang in sbi_hart_boot_next() if next mode is not supported
We should not jump to next stage if next mode (S-mode or U-mode)
is not supported by HART.

Signed-off-by: Atish Patra <atish.patra@wdc.com>
Signed-off-by: Anup Patel <anup.patel@wdc.com>
2018-12-21 11:09:47 +05:30
Anup Patel
089f70a179 top: Rename "plat" to "platform" everywhere
This patch renames "plat" to "platform" everywhere for better
readablility.

Signed-off-by: Anup Patel <anup.patel@wdc.com>
2018-12-21 10:35:04 +05:30
Anup Patel
6f02b6938f lib: Introduce bitmap to track HARTs waiting for coldboot
On QEMU Virt, max supported HARTs are 8 but number of HARTs
actually depend on "-smp" command-line parameter passed to
QEMU. This creates problems in sbi_hart_wake_coldboot_harts()
because when number of HARTs are less than 8.

To tackle this, we introduce a bitmap to track HARTs waiting
for coldboot to finish. We wake only those HARTs who have
set their bit in coldboot bitmap.

Signed-off-by: Anup Patel <anup.patel@wdc.com>
2018-12-21 10:09:33 +05:30
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
Anup Patel
ab5b228ff5 lib: sbi_hart: Remove unwanted sbi_printf()
This patch removes unwanted sbi_printf() from
sbi_hart_wait_for_coldboot().

Signed-off-by: Anup Patel <anup.patel@wdc.com>
2018-12-21 07:51:59 +05:30
Anup Patel
33ec85c9ab docs: Add documentation for firmware blobs
This patch adds documentation for fw_jump and fw_payload
firmware blobs.

Signed-off-by: Anup Patel <anup.patel@wdc.com>
2018-12-21 07:28:33 +05:30
Anup Patel
ef1f669cb7 top: More detailed top-level README.md
This patch adds more details to top-level README.md based on
current state of OpenSBI.

Signed-off-by: Anup Patel <anup.patel@wdc.com>
2018-12-21 07:28:33 +05:30
Anup Patel
f02926c896 Merge pull request #1 from riscv/atish_fix_1
Various fixes for unleashed board
2018-12-21 07:23:26 +05:30
Atish Patra
1d4e36edf8 Support unsigned long in sbi_printf
Signed-off-by: Atish Patra <atish.patra@wdc.com>
2018-12-20 15:55:32 -08:00
Atish Patra
84971c0bc0 Use wfi for coldboot finish call.
Signed-off-by: Atish Patra <atish.patra@wdc.com>
2018-12-20 15:55:27 -08:00
Atish Patra
e0a660ec5b Fix baud rate divisor computation for U540.
Signed-off-by: Atish Patra <atish.patra@wdc.com>
2018-12-20 15:38:43 -08:00
Atish Patra
3250fe7299 Support /r/n as newline character.
Signed-off-by: Atish Patra <atish.patra@wdc.com>
2018-12-20 15:38:43 -08:00
Atish Patra
5adf2fdc9e HiFive Unleashed has 5 harts. Fix the config to reflect that.
Signed-off-by: Atish Patra <atish.patra@wdc.com>
2018-12-20 15:38:43 -08:00