Commit graph

221 commits

Author SHA1 Message Date
Atish Patra
86cc9b8633 lib:platform: Fix sbi_getc return type.
As per the current SBI specification, sbi_getc should return
an int instead of char.

In case of FIFO is empty, return -1 as per the specification.

Reported-by: Sergi Granell <xerpi.g.12@gmail.com>
Suggested-by:Thadeu Lima de Souza Cascardo <cascardo@cascardo.eti.br>
Signed-off-by: Atish Patra <atish.patra@wdc.com>
2019-03-05 14:05:12 +05:30
Xiang Wang
05602e2bf4 firmware: Add a barrier instruction for wait for boot hart
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-05 09:09:40 +05:30
Xiang Wang
1c87f0f9b1 firmware: Move _boot_hart_done to the data section
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-03-05 09:09:40 +05:30
Xiang Wang
a72467f574 Add tags to .gitignore for being development friendly
Signed-off-by: Xiang Wang <wxjstz@126.com>
2019-03-05 09:07:23 +05:30
Andreas Schwab
87fbcf9376 Fix missing quotes in Makefile 2019-02-28 09:02:54 +05:30
Andreas Schwab
178a0307a2 Fix makefile dependency generation 2019-02-28 09:02:54 +05:30
Anup Patel
ca20ac0cd4 include: Bump-up version to 0.3
This patch updates OpenSBI version to 0.3 as part of
release preparation.

Signed-off-by: Anup Patel <anup.patel@wdc.com>
2019-02-26 22:24:59 +05:30
Alistair Francis
42e9ad556d Makefile: Set the platform variables before parsing the platforms
Ensure the platform variable PLATFORM_RISCV_XLEN is set before we parse
the platform files.

This fixes the 32-bit openSBI FW_JUMP_ADDR.

Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
2019-02-26 19:23:26 +05:30
Anup Patel
a1ffba1ac9 include: Bump-up version to 0.2
This patch increases OpenSBI version to 0.2.

Signed-off-by: Anup Patel <anup.patel@wdc.com>
2019-02-22 11:33:22 +05:30
Anup Patel
d022c5d3ae scripts: Add script for creating binary archive
This patch adds scripts/create-binary-archive.sh which helps
us create a common tarball containing headers, static library
and firmware ELFs for all platforms.

This script can be used for release purpose OR for compile
testing all platforms.

Example usage commands are as follows:

1) Binary release archive for 32bit systems
./scripts/create-binary-archive.sh -s "bin" -x 32 -d

2) Binary release archive for 64bit systems
./scripts/create-binary-archive.sh -s "bin" -d

3) Compile test for 32bit systems
./scripts/create-binary-archive.sh -x 32 -t

4) Compile test for 64bit systems
./scripts/create-binary-archive.sh -t

Signed-off-by: Anup Patel <anup.patel@wdc.com>
2019-02-22 11:28:41 +05:30
Anup Patel
889e746fd7 Makefile: Rename compile_ld() to compile_elf()
The compile_ld() is actually used to create ELF files so
the name is misleading hence this patch renames it to
compile_elf(). We also rename LDFLAGS to ELFFLAGS because
these will be used for ELF creation only.

Signed-off-by: Anup Patel <anup.patel@wdc.com>
2019-02-22 11:28:41 +05:30
Atish Patra
fde1c42db3 doc: Fix root partition details for fu540.
Signed-off-by: Atish Patra <atish.patra@wdc.com>
2019-02-22 09:58:55 +05:30
Anup Patel
122d00ba67 firmware: Improve low-level trap handler for M-mode to M-mode traps
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-20 12:02:40 +05:30
Anup Patel
ce6189f7a5 include: Add PRILX define to help print unsigned long
The unsigned long is always machine word size. This means it is
4 bytes on 32bit system and 8 bytes on 64bit system.

This patch adds PRILX define for sbi_printf() which will help us
print unsigned long without worrying whether it is 32bit or 64bit
system.

Signed-off-by: Anup Patel <anup.patel@wdc.com>
2019-02-20 12:02:40 +05:30
Sergi Granell
db5b25af49 template: Fix some callback names 2019-02-19 18:22:58 +05:30
Sergi Granell
72a8272066 template: Remove trailing ';' 2019-02-19 18:22:58 +05:30
Sergi Granell
4b92518959 template: Fix typo in platform_final_init
There was a space instead of '_' in the function `platform_final_init`.
2019-02-19 18:22:58 +05:30
Atish Patra
d046974cf6 docs: Update unleashed platform guide.
Following updates to fu540 platform guide.

1. Update a section about flashing the firmware binary
to sdcard with correct partition identifier.
2. Refer the individual payload section.
3. Update uboot booting section.

Signed-off-by: Atish Patra <atish.patra@wdc.com>
2019-02-19 18:22:26 +05:30
Atish Patra
0db43770b3 docs: Add a payload section describing different payloads.
Signed-off-by: Atish Patra <atish.patra@wdc.com>
2019-02-19 18:22:26 +05:30
Atish Patra
3265310b05 docs: Wrap text to 80 columns.
Signed-off-by: Atish Patra <atish.patra@wdc.com>
2019-02-19 18:22:26 +05:30
Atish Patra
34bf6d4a0f docs: Update about toolchain section.
Signed-off-by: Atish Patra <atish.patra@wdc.com>
2019-02-19 18:22:26 +05:30
Anup Patel
6a3dc84f66 Makefile: Use sed instead of awk to parse OpenSBI version
This patch replaces use of awk with sed in top-level makefile
to parse OpenSBI version from include/sbi/sbi_version.h.

Signed-off-by: Anup Patel <anup.patel@wdc.com>
2019-02-19 13:47:18 +05:30
Anup Patel
f4a17177ce Makefile: Fix error evaluating OPENSBI_CC_XLEN
We get following error evaluating OPENSBI_CC_XLEN on
Ubuntu-18.04:
/bin/sh: 1: Bad substitution

This patch fixes above error by using "awk" in string
assigned to OPENSBI_CC_XLEN and it also moves "Setup
compilation commands" before OPENSBI_CC_XLEN.

Signed-off-by: Anup Patel <anup.patel@wdc.com>
2019-02-19 13:47:18 +05:30
Anup Patel
4e774f5470 lib: Fix mask shift in sbi_ipi_send_many()
The mask shift in for-loop of sbi_ipi_send_many() is
broken with commit 918c1354b7
("lib: Improve delivery of SBI_IPI_EVENT_HALT")

This patch fix it.

Signed-off-by: Anup Patel <anup.patel@wdc.com>
2019-02-18 18:39:02 +05:30
Nick Kossifidis
148423d141 lib: Fix small typo on sbi_ipi.c 2019-02-18 09:21:58 +05:30
Nick Kossifidis
918c1354b7 lib: Improve delivery of SBI_IPI_EVENT_HALT
When sbi_ipi_send_many gets called with the current hartid
included on pmask (or when pmask is NULL), and we send
a HALT event, since the for loop works sequentially over
all hartids on the mask, we may send a HALT event to the
current hart before the loop finishes. So we will halt
the current hart before it can deliver a HALT IPI to the
rest and some harts will remain active.

Make sure we send an IPI to the current hart after we've
finished with everybody else.

Signed-off-by: Nick Kossifidis <mick@ics.forth.gr>
2019-02-18 09:21:58 +05:30
Nick Kossifidis
51e543511a platform: qemu-virt: Implement system shutdown
In order for QEMU to be compatible with Spike, it implements
a simple protocol used for reporting back the simulation's
status, through the memory-mapped "test finisher" device. We
use that protocol to make QEMU exit on system shutdown.

Signed-off-by: Nick Kossifidis <mick@ics.forth.gr>
2019-02-18 09:21:58 +05:30
Nick Kossifidis
b44878b773 lib: Send IPI for all harts to hang on system shutdown
In case the platform specific method for shutting down
the system fails (or is not implemented), at least make
sure that all harts hang instead of just the current hart.

Signed-off-by: Nick Kossifidis <mick@ics.forth.gr>
2019-02-18 09:21:58 +05:30
Alistair Francis
16426420b5 Makefile: Fix the assignment of OPENSBI_CC_XLEN
Previously OPENSBI_CC_XLEN was not being correctly assigned either 32 or
64. It also was not assigned before config.mk was parsed. Ensure that it
will always be assigned.

Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
2019-02-17 16:21:18 +05:30
Alistair Francis
3c53950b00
Merge pull request #59 from avpatel/make-run
Add 'make run' command for platform specific run
2019-02-15 15:02:19 -08:00
Olof Johansson
868e20df8b Makefile: Add 'make run' command for platform specific run
Makes for easy and quick build-run one-stop command.

For now only added for qemu targets. It can be added for
any platform having simulator/emulator (such as QEMU).

Signed-off-by: Olof Johansson <olof@lixom.net>
Signed-off-by: Anup Patel <anup.patel@wdc.com>
2019-02-15 15:54:44 +05:30
Alistair Francis
5cd69a496b docs: fu540: Add steps for the Microsemi Expansion board
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
2019-02-15 09:56:47 +05:30
Alistair Francis
ae4e0de700 platform: fu540: Initial commit of Microsemi device tree
Add a device tree for th HiFive Unleashed that includes the Microsemi
PCIe root complex.

Once we have support for u-boot and in tree Linux kernel device trees
this device tree should be removed.

Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
2019-02-15 09:56:47 +05:30
Alistair Francis
afbb0cdf80 platform: fu540: Fix missing newline
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
2019-02-15 09:56:47 +05:30
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
Nick Kossifidis
286b80768b Makefile: Make sure ld is always aware of the target abi/emulation
On Makefile merge_objs calls ld without providing any hints
on the target so on a multilib toolchain for example it will
always pick the default one (elf64-littleriscv) which will
then result a failure when compiling on RV32 since the objects
will be 32bits and the target will be 64bits. The same happens
on compile_ld that calls gcc without CFLAGS so it doesn't
get mabi/march.

With this patch OpenSBI compiles on RV32 (PLATFORM_RISCV_XLEN=32),
I tested fw_jump.elf on qemu (but it doesn't boot the kernel yet
-bbl also doesn't boot the kernel so it may be something else).

Signed-off-by: Nick Kossifidis <mickflemm@gmail.com>
2019-02-15 08:55:45 +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
Atish Patra
28d1dd2430 platform: 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.

Suggested-by: Olof Johansson <olof@lixom.net>
Signed-off-by: Atish Patra <atish.patra@wdc.com>
2019-02-14 09:31:18 +05:30
Atish Patra
70a474d2c2 lib: 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.

Suggested-by: Olof Johansson <olof@lixom.net>
Signed-off-by: Atish Patra <atish.patra@wdc.com>
2019-02-14 09:31:18 +05:30
Atish Patra
4cb4d46875 docs: Use normal hyphen instead of non-breaking hyphen
Usage non-breaking hyphen breaks make docs as doxygen doesn't know
how to handle this.

Signed-off-by: Atish Patra <atish.patra@wdc.com>
2019-02-14 09:29:56 +05:30
Anup Patel
c5467fce46 Makefile: Set ABI, ISA and Code Model in top-level make
This patch introduces following optional PLATFORM options:
PLATFORM_RISCV_XLEN -> RISC-V register width
PLATFORM_RISCV_ABI -> RISC-V GCC ABI
PLATFORM_RISCV_ISA -> RISC-V GCC ISA string
PLATFORM_RISCV_CODE_MODEL -> RISC-V GCC Code Model

If the above options are not provided by platform config.mk
or by command-line parameters then:
1. PLATFORM_RISCV_XLEN will be determined using toolchain
capability
2. PLATFORM_RISCV_ABI, PLATFORM_RISCV_ISA, and
PLATFORM_RISCV_CODE_MODEL is set to value best suited for
generic libsbi.a

As a result of these optional PLATFORM options, the
platform-cflags-y and platform-asflags-y is further
simplified for platform config.mk.

Signed-off-by: Anup Patel <anup.patel@wdc.com>
2019-02-12 15:55:15 +05:30
Anup Patel
84169e2e69 platform: qemu: Set FW_JUMP_ADDR and FW_PAYLOAD_OFFSET as-per XLEN
The current 4MB aligned FW_JUMP_ADDR and FW_PAYLOAD_OFFSET breaks
U-Boot on QEMU virt and sifive_u machines.

Instead of using 4MB aligned for both 32bit and 64bit systems, we
use different values based compiler XLEN. Another advantage of this
approach will be that our fw_payload.bin will smaller for 64bit
systems.

Signed-off-by: Anup Patel <anup.patel@wdc.com>
2019-02-12 15:55:15 +05:30
Anup Patel
ab12d6ef8f platform: template: Improve comments for FW_JUMP_ADDR and FW_PAYLOAD_OFFSET
Both FW_JUMP_ADDR and FW_PAYLOAD_OFFSET, should be:
1. 4MB aligned for 32bit system
2. 2MB aligned for 64bit system

Explicitly specify the above details in config.mk comments
for template platform.

Signed-off-by: Anup Patel <anup.patel@wdc.com>
2019-02-12 15:55:15 +05:30
Damien Le Moal
01fe779113 docs: improve library usage document
Clarify the libraries descriptions.

Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
2019-02-08 09:36:06 +05:30
Damien Le Moal
b1b7e49c63 docs: platform guide updates
Clarify platform support description.
Also fix some Typos, grammar and document style.

Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
2019-02-08 09:36:06 +05:30
Damien Le Moal
7b3da0ef0d top: README.md updates
Clarify OpenSBI components explanation.

Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
2019-02-08 09:36:06 +05:30
Alistair Francis
76c759df6a Makefile: Ensure lgcc is included
This fixes errors like this:
  undefined reference to `__umoddi3'
when buildilng for 32-bit systems

Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
2019-02-08 09:18:46 +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
Alistair Francis
f9b033e577 platform: clint: Allow running on 32-bit systems
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
2019-02-08 09:18:46 +05:30
Alistair Francis
f4cf6da7ff sbi_emulate_csr: Shift sbi_timer_value directly
csr_val is a tartget length based variable, so on 32-bit devices it's
only 32-bits. To avoid clearing the entire register perform both steps
in a single line.

Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
2019-02-08 09:18:46 +05:30