Commit Graph

33 Commits

Author SHA1 Message Date
Olof Johansson 10baa64c02 all: run clang-format and update checked-in files
Noisy commit, no functional changes.

Generated with an current upstream clang-format and:

clang-format -i $(find . -name \*.[ch])

Signed-off-by: Olof Johansson <olof@lixom.net>
2019-04-24 09:49:46 +05:30
Olof Johansson fbf986ac2a all: Annotate some tables to have clang-format leave them alone
One of the shortcomings of clang-format is that it doesn't allow
for aligned define tables, which is used for a number of constants.

Add annotation to disable the automatic formatting where needed.

Signed-off-by: Olof Johansson <olof@lixom.net>
2019-04-24 09:49:46 +05:30
Damien Le Moal 14dadeab09 kendryte/k210: Fix file headers
Add missing SPDX and copyright information.

Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
2019-04-03 10:22:57 +09:00
Xiang Wang 9eb8f0f90d platform: Make the `platform` read-only
platform should be a read-only variable, if it is placed in the data
segment, it may be exploited.

Signed-off-by: Xiang Wang <wxjstz@126.com>
2019-03-06 11:10:35 -08:00
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
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
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 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 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 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
Anup patel 18ec89e46e lib: Remove source_hart and hartid parameter from IPI callbacks
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>
2019-01-23 08:39:26 +05:30
Damien Le Moal 868ad0b0e5 kendryte/k210: Add device tree support
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>
2019-01-21 09:58:33 +05:30
Damien Le Moal 58d9f2983a kendryte/k210: Fix console
Clear console input when intializing it.

Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
2019-01-21 09:58:33 +05:30
Damien Le Moal ac3041f4e9 build: Introduce FW_PAYLOAD_ALIGN
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>
2019-01-21 09:58:33 +05:30
Atish Patra 00f77d9ba0 platform: Remove string functions from tinyfdt.c
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>
2019-01-18 10:05:12 +05:30
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
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 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 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 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
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
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
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
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 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
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