Commit graph

839 commits

Author SHA1 Message Date
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
Alistair Francis
9f44d07df5 platform: qemu/virt: Move kernel start address to 4MB alligned
In order to support 32-bit guests move the start address to a 4MB
allignment. As 64-bit kernels have a requirement on being 2MB alligned
let's just make this the default for both 32 and 64 bit kernels.

Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
2019-02-08 09:18:46 +05:30
Alistair Francis
a5f06b30c1 platform: template: Move kernel start address to 4MB alligned
In order to support 32-bit guests move the start address to a 4MB
allignment. As 64-bit kernels have a requirement on being 2MB alligned
let's just make this the default for both 32 and 64 bit kernels.

Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
2019-02-08 09:18:46 +05:30
Alistair Francis
5a91fec1a8 platform/qemu/virt: Dynamically calculate xlen
The QEMU virt machine can be either 32 or 66 bit. Don't hard code the
CPU bit length and instead let the compiler determine it.

Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
2019-02-08 09:18:46 +05:30
Alistair Francis
b4c72deba9 sbi_ecall: Fix logical OR to be bitwise OR
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
Andreas Schwab
190a80dc40 Makefile: don't disable built-in variables
Signed-off-by: Andreas Schwab <schwab@suse.de>
2019-02-06 10:39:17 +05:30
Olof Johansson
9a72e5006c Makefile: Don't rely on "echo -n"
Turns out it doesn't behave as expected on MacOS, it doesn't honor
-n and echoes that to the file instead. Add a slash and just let
the newline be there instead.

Signed-off-by: Olof Johansson <olof@lixom.net>
2019-02-05 18:53:27 +05:30
Olof Johansson
c0addfe751 riscv_asm.h: Use CSR_<FOO> instead of <foo> for csr_read()
Some toolchains might not have all the CSRs available (as seen with
GCC 7.2). So, instead use the defined CSR_ values.

Signed-off-by: Olof Johansson <olof@lixom.net>
2019-02-05 18:53:09 +05:30
Anup Patel
30dfdf6e0e docs: Update doxygen config file
This patch updates doxygen config file to include
docs/platform_guide.md and docs/library_usage.md in
generated PDF document.

Signed-off-by: Anup Patel <anup.patel@wdc.com>
2019-01-30 12:14:30 +05:30
Anup Patel
8af20068d1 docs: Add library usage guide
This patch adds static library usage guide (i.e.
docs/library_usage.md).

Signed-off-by: Anup Patel <anup.patel@wdc.com>
2019-01-30 12:14:30 +05:30
Anup Patel
27b55bb4da docs: Add platform support guide
This patch adds initial platform support guide (i.e.
docs/platform_guide.md).

Signed-off-by: Anup Patel <anup.patel@wdc.com>
2019-01-30 12:14:30 +05:30
Anup Patel
130230ff59 top: Fix typo in README.md
This patch renames <platform_sub_dir> to <platform_subdir> to be
consistent everywhere.

Signed-off-by: Anup Patel <anup.patel@wdc.com>
2019-01-30 12:14:30 +05:30
Atish Patra
02810f151c docs: Add a fu540 document.
Add a readme guide for fu540 with different types of build & booting steps.

Signed-off-by: Atish Patra <atish.patra@wdc.com>
2019-01-29 07:17:14 +05:30
Atish Patra
3211b6c542 docs: Typo fixes
Signed-off-by: Atish Patra <atish.patra@wdc.com>
2019-01-29 07:17:14 +05:30
Atish Patra
d70f8aab45 platform: fu540: Provide a compile time option selective hart booting.
Currently, only hart 1 is enabled for fu540 platform to support U-boot.

Introduce a compile time FU540_ENABLED_HART_MASK option so that specific
harts can be selected for booting. As fu540 is a multicore, we should
boot all cores by default except hart 0.

Signed-off-by: Atish Patra <atish.patra@wdc.com>
2019-01-29 07:17:14 +05:30
Anup Patel
bd98d77298 include: Add separate header for OpenSBI version
Currently, the OpenSBI version is in top-level Makefile so
firmware linking to OpenSBI static library have no-way to
know OpenSBI version.

This patch moves OpenSBI version from top-level Makefile to
sbi/sbi_version.h header which provides OPENSBI_VERSION_MAJOR
and OPENSBI_VERSION_MINOR defines.

NOTE: the SBI spec (or SBI ecall interface) version is
different. The SBI spec version is provided by functions
sbi_ecall_version_major() and sbi_ecall_version_minor().

Signed-off-by: Anup Patel <anup.patel@wdc.com>
2019-01-25 11:05:49 -08:00
Damien Le Moal
fba7e7c3ea docs: README.md update
Reformat to fit lines within 80 chars, fix hyperlinks, etc.

Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
2019-01-24 18:45:01 +05:30
Damien Le Moal
84cd4b7cd0 docs/platform: Update QEMU platforms documentation
Mostly reformating. Some minor edits.

Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
2019-01-24 18:45:01 +05:30
Damien Le Moal
ecfd63025d docs/platform: Add top level document file
List supported platforms and point to the platform specific document.

Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
2019-01-24 18:45:01 +05:30
Damien Le Moal
560147b264 docs/firmware: Update FW_PAYLOAD documentation
Reformatting, typos, and various corrections.

Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
2019-01-24 18:45:01 +05:30
Damien Le Moal
fff48ee2bf docs/firmware: Update FW_JUMP documentation
Reformatting, typos, and various corrections.

Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
2019-01-24 18:45:01 +05:30
Damien Le Moal
808fe4b82a docs/firmware: Add top level document file
Provide an overview of all supported firmware files and point to each
firmware type documentation file.

Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
2019-01-24 18:45:01 +05:30
Damien Le Moal
e580b86a41 docs: Contribution guideline update
Explicitely mention that this project adheres to the Developer
Certificate of Origin (DCO) and include this short text.

Also reformat the file to have lines bounded at 80 chars and add some
more details regarding the expected commit message format.

Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
2019-01-24 18:45:01 +05:30
Damien Le Moal
36195f52c1 top: Rename LICENSE file to COPYING.BSD
Also make sure that this file contains only the official BSD 2-clause
license text, nothing else.

Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
2019-01-24 18:45:01 +05:30
Damien Le Moal
8c25dcbf76 platform: add template platform files
Create commented template files to use as a base for new platforms
support implementation.

Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
2019-01-24 18:45:01 +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
Anup Patel
d68741d8b1 include: Use TRUE/FALSE as return values in sbi_platform_hart_disabled()
The sbi_platform_hart_disabled() returns bool hence explicitly return
TRUE or FALSE instead of 1 or 0.

Signed-off-by: Anup Patel <anup.patel@wdc.com>
2019-01-23 09:00:35 +05:30
Anup Patel
025d0ae994 include: Rename ipi_inject() to ipi_send() for sbi_platform
For better naming, we rename ipi_inject() to ipi_send() in
struct sbi_platform. We also replace term "inject" with
"send" in all related places.

Signed-off-by: Anup Patel <anup.patel@wdc.com>
2019-01-23 08:39:26 +05:30
Anup Patel
36394d2f24 include: Drop MMIO from SBI_PLATFORM_HAS_MMIO_TIMER_VALUE
It is not necessary that platform has MMIO-based timer value
register. It can also have some custom (implementation specific)
CSR for timer value.

This patch renames SBI_PLATFORM_HAS_MMIO_TIMER_VALUE to
SBI_PLATFORM_HAS_TIMER_VALUE to imply "platform timer value"
instead of "mmio timer value".

Signed-off-by: Anup Patel <anup.patel@wdc.com>
2019-01-23 08:39:26 +05:30
Anup Patel
d25774ff96 include: Update documentation of sbi_platform after callback cleanup
The prototypes of sbi_platform callbacks have changed hence we
update related documentation.

Signed-off-by: Anup Patel <anup.patel@wdc.com>
2019-01-23 08:39:26 +05:30
Anup Patel
9895d446ae lib: Remove target_hart and hartid parameter from TIMER callbacks
The target_hart and hartid paramter of TIMER callbacks is not
required because it always current hartid which can be obtained
using sbi_current_hartid() API.

Signed-off-by: Anup Patel <anup.patel@wdc.com>
2019-01-23 08:39:26 +05:30
Anup Patel
74fd2e5bb2 lib: Remove hartid parameter from IRQCHIP callbacks
The hartid parameter in IRQCHIP callbacks of sbi_platform
is not required because current hartid can be determined
using sbi_current_hartid() API.

Signed-off-by: Anup Patel <anup.patel@wdc.com>
2019-01-23 08:39:26 +05:30