opensbi: weekly rls 2024.09.21
-67d579e, [fix](serial): Round UART8250 baud rate divisor to nearest integer
-3732ed4, [feat](opensbi):kernel log controled by CONFIG_SKIP_UBOOT_DEBUG while open CONFIG_SKIP_UBOOT
-e526777, [feat](opensbi): Add debug function in fastboot
This commit is contained in:
11
Makefile
11
Makefile
@@ -203,6 +203,17 @@ GENFLAGS += $(libsbiutils-genflags-y)
|
|||||||
GENFLAGS += $(platform-genflags-y)
|
GENFLAGS += $(platform-genflags-y)
|
||||||
GENFLAGS += $(firmware-genflags-y)
|
GENFLAGS += $(firmware-genflags-y)
|
||||||
|
|
||||||
|
define add_define
|
||||||
|
GENFLAGS += -D$(1)$(if $(value $(1)),=$(value $(1)),)
|
||||||
|
endef
|
||||||
|
|
||||||
|
ifeq (${CONFIG_SKIP_UBOOT},y)
|
||||||
|
$(eval $(call add_define,CONFIG_SKIP_UBOOT))
|
||||||
|
endif
|
||||||
|
ifeq (${CONFIG_SKIP_UBOOT_DEBUG},y)
|
||||||
|
$(eval $(call add_define,CONFIG_SKIP_UBOOT_DEBUG))
|
||||||
|
endif
|
||||||
|
|
||||||
CFLAGS = -g -Wall -Werror -ffreestanding -nostdlib -fno-strict-aliasing -O2
|
CFLAGS = -g -Wall -Werror -ffreestanding -nostdlib -fno-strict-aliasing -O2
|
||||||
CFLAGS += -fno-omit-frame-pointer -fno-optimize-sibling-calls
|
CFLAGS += -fno-omit-frame-pointer -fno-optimize-sibling-calls
|
||||||
CFLAGS += -mno-save-restore -mstrict-align
|
CFLAGS += -mno-save-restore -mstrict-align
|
||||||
|
|||||||
286
README.md
286
README.md
@@ -1,286 +0,0 @@
|
|||||||
RISC-V Open Source Supervisor Binary Interface (OpenSBI)
|
|
||||||
========================================================
|
|
||||||
|
|
||||||
Copyright and License
|
|
||||||
---------------------
|
|
||||||
|
|
||||||
The OpenSBI project is copyright (c) 2019 Western Digital Corporation
|
|
||||||
or its affiliates and other contributors.
|
|
||||||
|
|
||||||
It is distributed under the terms of the BSD 2-clause license
|
|
||||||
("Simplified BSD License" or "FreeBSD License", SPDX: *BSD-2-Clause*).
|
|
||||||
A copy of this license with OpenSBI copyright can be found in the file
|
|
||||||
[COPYING.BSD].
|
|
||||||
|
|
||||||
All source files in OpenSBI contain the 2-Clause BSD license SPDX short
|
|
||||||
identifier in place of the full license text.
|
|
||||||
|
|
||||||
```
|
|
||||||
SPDX-License-Identifier: BSD-2-Clause
|
|
||||||
```
|
|
||||||
|
|
||||||
This enables machine processing of license information based on the SPDX
|
|
||||||
License Identifiers that are available on the [SPDX] web site.
|
|
||||||
|
|
||||||
OpenSBI source code also contains code reused from other projects as listed
|
|
||||||
below. The original license text of these projects is included in the source
|
|
||||||
files where the reused code is present.
|
|
||||||
|
|
||||||
* The libfdt source code is disjunctively dual licensed
|
|
||||||
(GPL-2.0+ OR BSD-2-Clause). Some of this project code is used in OpenSBI
|
|
||||||
under the terms of the BSD 2-Clause license. Any contributions to this
|
|
||||||
code must be made under the terms of both licenses.
|
|
||||||
|
|
||||||
See also the [third party notices] file for more information.
|
|
||||||
|
|
||||||
Introduction
|
|
||||||
------------
|
|
||||||
|
|
||||||
The **RISC-V Supervisor Binary Interface (SBI)** is the recommended interface
|
|
||||||
between:
|
|
||||||
|
|
||||||
1. A platform-specific firmware running in M-mode and a bootloader, a
|
|
||||||
hypervisor or a general-purpose OS executing in S-mode or HS-mode.
|
|
||||||
2. A hypervisor running in HS-mode and a bootloader or a general-purpose OS
|
|
||||||
executing in VS-mode.
|
|
||||||
|
|
||||||
The *RISC-V SBI specification* is maintained as an independent project by the
|
|
||||||
RISC-V Foundation on [Github].
|
|
||||||
|
|
||||||
The goal of the OpenSBI project is to provide an open-source reference
|
|
||||||
implementation of the RISC-V SBI specifications for platform-specific firmwares
|
|
||||||
executing in M-mode (case 1 mentioned above). An OpenSBI implementation can be
|
|
||||||
easily extended by RISC-V platform and system-on-chip vendors to fit a
|
|
||||||
particular hardware configuration.
|
|
||||||
|
|
||||||
The main component of OpenSBI is provided in the form of a platform-independent
|
|
||||||
static library **libsbi.a** implementing the SBI interface. A firmware or
|
|
||||||
bootloader implementation can link against this library to ensure conformance
|
|
||||||
with the SBI interface specifications. *libsbi.a* also defines an interface for
|
|
||||||
integrating with platform-specific operations provided by the platform firmware
|
|
||||||
implementation (e.g. console access functions, inter-processor interrupt
|
|
||||||
control, etc).
|
|
||||||
|
|
||||||
To illustrate the use of the *libsbi.a* library, OpenSBI also provides a set of
|
|
||||||
platform-specific support examples. For each example, a platform-specific
|
|
||||||
static library *libplatsbi.a* can be compiled. This library implements
|
|
||||||
SBI call processing by integrating *libsbi.a* with the necessary
|
|
||||||
platform-dependent hardware manipulation functions. For all supported platforms,
|
|
||||||
OpenSBI also provides several runtime firmware examples built using the platform
|
|
||||||
*libplatsbi.a*. These example firmwares can be used to replace the legacy
|
|
||||||
*riscv-pk* bootloader (aka BBL) and enable the use of well-known bootloaders
|
|
||||||
such as [U-Boot].
|
|
||||||
|
|
||||||
Supported SBI version
|
|
||||||
---------------------
|
|
||||||
Currently, OpenSBI fully supports SBI specification *v0.2*. OpenSBI also
|
|
||||||
supports Hart State Management (HSM) SBI extension starting from OpenSBI v0.7.
|
|
||||||
HSM extension allows S-mode software to boot all the harts a defined order
|
|
||||||
rather than legacy method of random booting of harts. As a result, many
|
|
||||||
required features such as CPU hotplug, kexec/kdump can also be supported easily
|
|
||||||
in S-mode. HSM extension in OpenSBI is implemented in a non-backward compatible
|
|
||||||
manner to reduce the maintenance burden and avoid confusion. That's why, any
|
|
||||||
S-mode software using OpenSBI will not be able to boot more than 1 hart if HSM
|
|
||||||
extension is not supported in S-mode.
|
|
||||||
|
|
||||||
Linux kernel already supports SBI v0.2 and HSM SBI extension starting from
|
|
||||||
**v5.7-rc1**. If you are using an Linux kernel older than **5.7-rc1** or any
|
|
||||||
other S-mode software without HSM SBI extension, you should stick to OpenSBI
|
|
||||||
v0.6 to boot all the harts. For a UMP systems, it doesn't matter.
|
|
||||||
|
|
||||||
N.B. Any S-mode boot loader (i.e. U-Boot) doesn't need to support HSM extension,
|
|
||||||
as it doesn't need to boot all the harts. The operating system should be
|
|
||||||
capable enough to bring up all other non-booting harts using HSM extension.
|
|
||||||
|
|
||||||
Required Toolchain
|
|
||||||
------------------
|
|
||||||
|
|
||||||
OpenSBI can be compiled natively or cross-compiled on a x86 host. For
|
|
||||||
cross-compilation, you can build your own toolchain or just download
|
|
||||||
a prebuilt one from the [Bootlin toolchain repository].
|
|
||||||
|
|
||||||
Please note that only a 64-bit version of the toolchain is available in
|
|
||||||
the Bootlin toolchain repository for now.
|
|
||||||
|
|
||||||
Building and Installing the OpenSBI Platform-Independent Library
|
|
||||||
----------------------------------------------------------------
|
|
||||||
|
|
||||||
The OpenSBI platform-independent static library *libsbi.a* can be compiled
|
|
||||||
natively or it can be cross-compiled on a host with a different base
|
|
||||||
architecture than RISC-V.
|
|
||||||
|
|
||||||
For cross-compiling, the environment variable *CROSS_COMPILE* must be defined
|
|
||||||
to specify the name prefix of the RISC-V compiler toolchain executables, e.g.
|
|
||||||
*riscv64-unknown-elf-* if the gcc executable used is *riscv64-unknown-elf-gcc*.
|
|
||||||
|
|
||||||
To build *libsbi.a* simply execute:
|
|
||||||
```
|
|
||||||
make
|
|
||||||
```
|
|
||||||
|
|
||||||
All compiled binaries as well as the resulting *libsbi.a* static library file
|
|
||||||
will be placed in the *build/lib* directory. To specify an alternate build root
|
|
||||||
directory path, run:
|
|
||||||
```
|
|
||||||
make O=<build_directory>
|
|
||||||
```
|
|
||||||
|
|
||||||
To generate files to be installed for using *libsbi.a* in other projects, run:
|
|
||||||
```
|
|
||||||
make install
|
|
||||||
```
|
|
||||||
|
|
||||||
This will create the *install* directory with all necessary include files
|
|
||||||
copied under the *install/include* directory and the library file copied into
|
|
||||||
the *install/lib* directory. To specify an alternate installation root
|
|
||||||
directory path, run:
|
|
||||||
```
|
|
||||||
make I=<install_directory> install
|
|
||||||
```
|
|
||||||
|
|
||||||
Building and Installing a Reference Platform Static Library and Firmware
|
|
||||||
------------------------------------------------------------------------
|
|
||||||
|
|
||||||
When the *PLATFORM=<platform_subdir>* argument is specified on the make command
|
|
||||||
line, the platform-specific static library *libplatsbi.a* and firmware examples
|
|
||||||
are built for the platform *<platform_subdir>* present in the directory
|
|
||||||
*platform* in the OpenSBI top directory. For example, to compile the platform
|
|
||||||
library and the firmware examples for the QEMU RISC-V *virt* machine,
|
|
||||||
*<platform_subdir>* should be *generic*.
|
|
||||||
|
|
||||||
To build *libsbi.a*, *libplatsbi.a* and the firmware for one of the supported
|
|
||||||
platforms, run:
|
|
||||||
```
|
|
||||||
make PLATFORM=<platform_subdir>
|
|
||||||
```
|
|
||||||
|
|
||||||
An alternate build directory path can also be specified:
|
|
||||||
```
|
|
||||||
make PLATFORM=<platform_subdir> O=<build_directory>
|
|
||||||
```
|
|
||||||
|
|
||||||
The platform-specific library *libplatsbi.a* will be generated in the
|
|
||||||
*build/platform/<platform_subdir>/lib* directory. The platform firmware files
|
|
||||||
will be under the *build/platform/<platform_subdir>/firmware* directory.
|
|
||||||
The compiled firmwares will be available in two different formats: an ELF file
|
|
||||||
and an expanded image file.
|
|
||||||
|
|
||||||
To install *libsbi.a*, *libplatsbi.a*, and the compiled firmwares, run:
|
|
||||||
```
|
|
||||||
make PLATFORM=<platform_subdir> install
|
|
||||||
```
|
|
||||||
|
|
||||||
This will copy the compiled platform-specific libraries and firmware files
|
|
||||||
under the *install/platform/<platform_subdir>/* directory. An alternate
|
|
||||||
install root directory path can be specified as follows:
|
|
||||||
```
|
|
||||||
make PLATFORM=<platform_subdir> I=<install_directory> install
|
|
||||||
```
|
|
||||||
|
|
||||||
In addition, platform-specific configuration options can be specified with the
|
|
||||||
top-level make command line. These options, such as *PLATFORM_<xyz>* or
|
|
||||||
*FW_<abc>*, are platform-specific and described in more details in the
|
|
||||||
*docs/platform/<platform_name>.md* files and
|
|
||||||
*docs/firmware/<firmware_name>.md* files.
|
|
||||||
|
|
||||||
Building 32-bit / 64-bit OpenSBI Images
|
|
||||||
---------------------------------------
|
|
||||||
By default, building OpenSBI generates 32-bit or 64-bit images based on the
|
|
||||||
supplied RISC-V cross-compile toolchain. For example if *CROSS_COMPILE* is set
|
|
||||||
to *riscv64-unknown-elf-*, 64-bit OpenSBI images will be generated. If building
|
|
||||||
32-bit OpenSBI images, *CROSS_COMPILE* should be set to a toolchain that is
|
|
||||||
pre-configured to generate 32-bit RISC-V codes, like *riscv32-unknown-elf-*.
|
|
||||||
|
|
||||||
However it's possible to explicitly specify the image bits we want to build with
|
|
||||||
a given RISC-V toolchain. This can be done by setting the environment variable
|
|
||||||
*PLATFORM_RISCV_XLEN* to the desired width, for example:
|
|
||||||
|
|
||||||
```
|
|
||||||
export CROSS_COMPILE=riscv64-unknown-elf-
|
|
||||||
export PLATFORM_RISCV_XLEN=32
|
|
||||||
```
|
|
||||||
|
|
||||||
will generate 32-bit OpenSBI images. And vice vesa.
|
|
||||||
|
|
||||||
Contributing to OpenSBI
|
|
||||||
-----------------------
|
|
||||||
|
|
||||||
The OpenSBI project encourages and welcomes contributions. Contributions should
|
|
||||||
follow the rules described in the OpenSBI [Contribution Guideline] document.
|
|
||||||
In particular, all patches sent should contain a Signed-off-by tag.
|
|
||||||
|
|
||||||
The [Contributors List] document provides a list of individuals and
|
|
||||||
organizations actively contributing to the OpenSBI project.
|
|
||||||
|
|
||||||
Documentation
|
|
||||||
-------------
|
|
||||||
|
|
||||||
Detailed documentation of various aspects of OpenSBI can be found under the
|
|
||||||
*docs* directory. The documentation covers the following topics.
|
|
||||||
|
|
||||||
* [Contribution Guideline]: Guideline for contributing code to OpenSBI project
|
|
||||||
* [Library Usage]: API documentation of OpenSBI static library *libsbi.a*
|
|
||||||
* [Platform Requirements]: Requirements for using OpenSBI on a platform
|
|
||||||
* [Platform Support Guide]: Guideline for implementing support for new platforms
|
|
||||||
* [Platform Documentation]: Documentation of the platforms currently supported.
|
|
||||||
* [Firmware Documentation]: Documentation for the different types of firmware
|
|
||||||
examples build supported by OpenSBI.
|
|
||||||
* [Domain Support]: Documentation for the OpenSBI domain support which helps
|
|
||||||
users achieve system-level partitioning using OpenSBI.
|
|
||||||
|
|
||||||
OpenSBI source code is also well documented. For source level documentation,
|
|
||||||
doxygen style is used. Please refer to the [Doxygen manual] for details on this
|
|
||||||
format.
|
|
||||||
|
|
||||||
Doxygen can be installed on Linux distributions using *.deb* packages using
|
|
||||||
the following command.
|
|
||||||
```
|
|
||||||
sudo apt-get install doxygen doxygen-latex doxygen-doc doxygen-gui graphviz
|
|
||||||
```
|
|
||||||
|
|
||||||
For *.rpm* based Linux distributions, the following commands can be used.
|
|
||||||
```
|
|
||||||
sudo yum install doxygen doxygen-latex doxywizard graphviz
|
|
||||||
```
|
|
||||||
or
|
|
||||||
```
|
|
||||||
sudo yum install doxygen doxygen-latex doxywizard graphviz
|
|
||||||
```
|
|
||||||
|
|
||||||
To build a consolidated *refman.pdf* of all documentation, run:
|
|
||||||
```
|
|
||||||
make docs
|
|
||||||
```
|
|
||||||
or
|
|
||||||
```
|
|
||||||
make O=<build_directory> docs
|
|
||||||
```
|
|
||||||
|
|
||||||
the resulting *refman.pdf* will be available under the directory
|
|
||||||
*<build_directory>/docs/latex*. To install this file, run:
|
|
||||||
```
|
|
||||||
make install_docs
|
|
||||||
```
|
|
||||||
or
|
|
||||||
```
|
|
||||||
make I=<install_directory> install_docs
|
|
||||||
```
|
|
||||||
|
|
||||||
*refman.pdf* will be installed under *<install_directory>/docs*.
|
|
||||||
|
|
||||||
[Github]: https://github.com/riscv/riscv-sbi-doc
|
|
||||||
[U-Boot]: https://www.denx.de/wiki/U-Boot/SourceCode
|
|
||||||
[Bootlin toolchain repository]: https://toolchains.bootlin.com/
|
|
||||||
[COPYING.BSD]: COPYING.BSD
|
|
||||||
[SPDX]: http://spdx.org/licenses/
|
|
||||||
[Contribution Guideline]: docs/contributing.md
|
|
||||||
[Contributors List]: CONTRIBUTORS.md
|
|
||||||
[Library Usage]: docs/library_usage.md
|
|
||||||
[Platform Requirements]: docs/platform_requirements.md
|
|
||||||
[Platform Support Guide]: docs/platform_guide.md
|
|
||||||
[Platform Documentation]: docs/platform/platform.md
|
|
||||||
[Firmware Documentation]: docs/firmware/fw.md
|
|
||||||
[Domain Support]: docs/domain_support.md
|
|
||||||
[Doxygen manual]: http://www.doxygen.nl/manual/index.html
|
|
||||||
[Kendryte standalone SDK]: https://github.com/kendryte/kendryte-standalone-sdk
|
|
||||||
[third party notices]: ThirdPartyNotices.md
|
|
||||||
@@ -37,9 +37,6 @@
|
|||||||
#define SBI_EXT_BASE_GET_MVENDORID 0x4
|
#define SBI_EXT_BASE_GET_MVENDORID 0x4
|
||||||
#define SBI_EXT_BASE_GET_MARCHID 0x5
|
#define SBI_EXT_BASE_GET_MARCHID 0x5
|
||||||
#define SBI_EXT_BASE_GET_MIMPID 0x6
|
#define SBI_EXT_BASE_GET_MIMPID 0x6
|
||||||
#define SBI_EXT_BASE_RESET_C906L 0x7
|
|
||||||
#define SBI_EXT_BASE_RST_C906L 0x8
|
|
||||||
#define SBI_EXT_BASE_UNRST_C906L 0x9
|
|
||||||
|
|
||||||
/* SBI function IDs for TIME extension*/
|
/* SBI function IDs for TIME extension*/
|
||||||
#define SBI_EXT_TIME_SET_TIMER 0x0
|
#define SBI_EXT_TIME_SET_TIMER 0x0
|
||||||
|
|||||||
@@ -14,7 +14,6 @@
|
|||||||
#include <sbi/sbi_trap.h>
|
#include <sbi/sbi_trap.h>
|
||||||
#include <sbi/sbi_version.h>
|
#include <sbi/sbi_version.h>
|
||||||
#include <sbi/riscv_asm.h>
|
#include <sbi/riscv_asm.h>
|
||||||
#include <sbi/riscv_io.h>
|
|
||||||
|
|
||||||
static int sbi_ecall_base_probe(unsigned long extid, unsigned long *out_val)
|
static int sbi_ecall_base_probe(unsigned long extid, unsigned long *out_val)
|
||||||
{
|
{
|
||||||
@@ -33,41 +32,6 @@ static int sbi_ecall_base_probe(unsigned long extid, unsigned long *out_val)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define SEC_SYS_BASE (0x020B0000)
|
|
||||||
static int sbi_ecall_base_rst_c906l(void)
|
|
||||||
{
|
|
||||||
unsigned int value;
|
|
||||||
|
|
||||||
value = readl((void *)0x3003024);
|
|
||||||
writel((value & (~(1 << 6))), (void *)0x3003024);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int sbi_ecall_base_unrst_c906l(const unsigned long address)
|
|
||||||
{
|
|
||||||
unsigned int value;
|
|
||||||
|
|
||||||
value = readl((void *)SEC_SYS_BASE + 0x04);
|
|
||||||
writel((value | (1 << 13)), (void *)SEC_SYS_BASE + 0x04);
|
|
||||||
writel(address, (void *)SEC_SYS_BASE + 0x20);
|
|
||||||
writel((address >> 32), (void *)SEC_SYS_BASE + 0x24);
|
|
||||||
|
|
||||||
value = readl((void *)0x3003024);
|
|
||||||
writel((value | (1 << 6)), (void *)0x3003024);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int sbi_ecall_base_reset_c906l(const unsigned long address)
|
|
||||||
{
|
|
||||||
sbi_ecall_base_rst_c906l();
|
|
||||||
|
|
||||||
sbi_ecall_base_unrst_c906l(address);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int sbi_ecall_base_handler(unsigned long extid, unsigned long funcid,
|
static int sbi_ecall_base_handler(unsigned long extid, unsigned long funcid,
|
||||||
const struct sbi_trap_regs *regs,
|
const struct sbi_trap_regs *regs,
|
||||||
unsigned long *out_val,
|
unsigned long *out_val,
|
||||||
@@ -101,16 +65,6 @@ static int sbi_ecall_base_handler(unsigned long extid, unsigned long funcid,
|
|||||||
case SBI_EXT_BASE_PROBE_EXT:
|
case SBI_EXT_BASE_PROBE_EXT:
|
||||||
ret = sbi_ecall_base_probe(regs->a0, out_val);
|
ret = sbi_ecall_base_probe(regs->a0, out_val);
|
||||||
break;
|
break;
|
||||||
case SBI_EXT_BASE_RESET_C906L:
|
|
||||||
ret = sbi_ecall_base_reset_c906l(regs->a0);
|
|
||||||
*out_val = regs->a0;
|
|
||||||
break;
|
|
||||||
case SBI_EXT_BASE_RST_C906L:
|
|
||||||
ret = sbi_ecall_base_rst_c906l();
|
|
||||||
break;
|
|
||||||
case SBI_EXT_BASE_UNRST_C906L:
|
|
||||||
ret = sbi_ecall_base_unrst_c906l(regs->a0);
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
ret = SBI_ENOTSUPP;
|
ret = SBI_ENOTSUPP;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,10 +21,19 @@
|
|||||||
#include <sbi/sbi_platform.h>
|
#include <sbi/sbi_platform.h>
|
||||||
#include <sbi/sbi_string.h>
|
#include <sbi/sbi_string.h>
|
||||||
#include <sbi/sbi_trap.h>
|
#include <sbi/sbi_trap.h>
|
||||||
|
#include <sbi/sbi_timer.h>
|
||||||
|
|
||||||
extern void __sbi_expected_trap(void);
|
extern void __sbi_expected_trap(void);
|
||||||
extern void __sbi_expected_trap_hext(void);
|
extern void __sbi_expected_trap_hext(void);
|
||||||
|
|
||||||
|
|
||||||
|
// Frequency of ARM arch timer and RISC-V rdtime
|
||||||
|
#define SYS_COUNTER_FREQ_IN_SECOND 25000000
|
||||||
|
#define TIME_RECORDS_ADDR ( 0x0E000000 + 0x10) // 0x0E000010
|
||||||
|
#define TIME_RECORDS_FIELD_KERNEL_START (TIME_RECORDS_ADDR + 0x16)
|
||||||
|
|
||||||
|
#define DIV_ROUND_UP(n, d) (((n) + (d) - 1) / (d))
|
||||||
|
|
||||||
void (*sbi_hart_expected_trap)(void) = &__sbi_expected_trap;
|
void (*sbi_hart_expected_trap)(void) = &__sbi_expected_trap;
|
||||||
|
|
||||||
struct hart_features {
|
struct hart_features {
|
||||||
@@ -469,6 +478,15 @@ void __attribute__((noreturn)) sbi_hart_hang(void)
|
|||||||
__builtin_unreachable();
|
__builtin_unreachable();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int get_time()
|
||||||
|
{
|
||||||
|
unsigned long long boot_us = 0;
|
||||||
|
|
||||||
|
boot_us = sbi_timer_value() / (SYS_COUNTER_FREQ_IN_SECOND / 1000000 );
|
||||||
|
|
||||||
|
return DIV_ROUND_UP(boot_us, 1000);
|
||||||
|
}
|
||||||
|
|
||||||
void __attribute__((noreturn))
|
void __attribute__((noreturn))
|
||||||
sbi_hart_switch_mode(unsigned long arg0, unsigned long arg1,
|
sbi_hart_switch_mode(unsigned long arg0, unsigned long arg1,
|
||||||
unsigned long next_addr, unsigned long next_mode,
|
unsigned long next_addr, unsigned long next_mode,
|
||||||
@@ -531,6 +549,8 @@ sbi_hart_switch_mode(unsigned long arg0, unsigned long arg1,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
*(volatile uint16_t*)TIME_RECORDS_FIELD_KERNEL_START = get_time();
|
||||||
|
|
||||||
register unsigned long a0 asm("a0") = arg0;
|
register unsigned long a0 asm("a0") = arg0;
|
||||||
register unsigned long a1 asm("a1") = arg1;
|
register unsigned long a1 asm("a1") = arg1;
|
||||||
__asm__ __volatile__("mret" : : "r"(a0), "r"(a1));
|
__asm__ __volatile__("mret" : : "r"(a0), "r"(a1));
|
||||||
|
|||||||
@@ -35,112 +35,6 @@
|
|||||||
" | |\n" \
|
" | |\n" \
|
||||||
" |_|\n\n"
|
" |_|\n\n"
|
||||||
|
|
||||||
static void sbi_boot_print_banner(struct sbi_scratch *scratch)
|
|
||||||
{
|
|
||||||
if (scratch->options & SBI_SCRATCH_NO_BOOT_PRINTS)
|
|
||||||
return;
|
|
||||||
|
|
||||||
#ifdef OPENSBI_VERSION_GIT
|
|
||||||
sbi_printf("\nOpenSBI %s\n", OPENSBI_VERSION_GIT);
|
|
||||||
#else
|
|
||||||
sbi_printf("\nOpenSBI v%d.%d\n", OPENSBI_VERSION_MAJOR,
|
|
||||||
OPENSBI_VERSION_MINOR);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
sbi_printf(BANNER);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void sbi_boot_print_general(struct sbi_scratch *scratch)
|
|
||||||
{
|
|
||||||
char str[128];
|
|
||||||
const struct sbi_hsm_device *hdev;
|
|
||||||
const struct sbi_ipi_device *idev;
|
|
||||||
const struct sbi_timer_device *tdev;
|
|
||||||
const struct sbi_console_device *cdev;
|
|
||||||
const struct sbi_system_reset_device *srdev;
|
|
||||||
const struct sbi_platform *plat = sbi_platform_ptr(scratch);
|
|
||||||
|
|
||||||
if (scratch->options & SBI_SCRATCH_NO_BOOT_PRINTS)
|
|
||||||
return;
|
|
||||||
|
|
||||||
/* Platform details */
|
|
||||||
sbi_printf("Platform Name : %s\n",
|
|
||||||
sbi_platform_name(plat));
|
|
||||||
sbi_platform_get_features_str(plat, str, sizeof(str));
|
|
||||||
sbi_printf("Platform Features : %s\n", str);
|
|
||||||
sbi_printf("Platform HART Count : %u\n",
|
|
||||||
sbi_platform_hart_count(plat));
|
|
||||||
idev = sbi_ipi_get_device();
|
|
||||||
sbi_printf("Platform IPI Device : %s\n",
|
|
||||||
(idev) ? idev->name : "---");
|
|
||||||
tdev = sbi_timer_get_device();
|
|
||||||
sbi_printf("Platform Timer Device : %s\n",
|
|
||||||
(tdev) ? tdev->name : "---");
|
|
||||||
cdev = sbi_console_get_device();
|
|
||||||
sbi_printf("Platform Console Device : %s\n",
|
|
||||||
(cdev) ? cdev->name : "---");
|
|
||||||
hdev = sbi_hsm_get_device();
|
|
||||||
sbi_printf("Platform HSM Device : %s\n",
|
|
||||||
(hdev) ? hdev->name : "---");
|
|
||||||
srdev = sbi_system_reset_get_device();
|
|
||||||
sbi_printf("Platform SysReset Device : %s\n",
|
|
||||||
(srdev) ? srdev->name : "---");
|
|
||||||
|
|
||||||
/* Firmware details */
|
|
||||||
sbi_printf("Firmware Base : 0x%lx\n", scratch->fw_start);
|
|
||||||
sbi_printf("Firmware Size : %d KB\n",
|
|
||||||
(u32)(scratch->fw_size / 1024));
|
|
||||||
|
|
||||||
/* SBI details */
|
|
||||||
sbi_printf("Runtime SBI Version : %d.%d\n",
|
|
||||||
sbi_ecall_version_major(), sbi_ecall_version_minor());
|
|
||||||
sbi_printf("\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
static void sbi_boot_print_domains(struct sbi_scratch *scratch)
|
|
||||||
{
|
|
||||||
if (scratch->options & SBI_SCRATCH_NO_BOOT_PRINTS)
|
|
||||||
return;
|
|
||||||
|
|
||||||
/* Domain details */
|
|
||||||
sbi_domain_dump_all(" ");
|
|
||||||
}
|
|
||||||
|
|
||||||
static void sbi_boot_print_hart(struct sbi_scratch *scratch, u32 hartid)
|
|
||||||
{
|
|
||||||
int xlen;
|
|
||||||
char str[128];
|
|
||||||
const struct sbi_domain *dom = sbi_domain_thishart_ptr();
|
|
||||||
|
|
||||||
if (scratch->options & SBI_SCRATCH_NO_BOOT_PRINTS)
|
|
||||||
return;
|
|
||||||
|
|
||||||
/* Determine MISA XLEN and MISA string */
|
|
||||||
xlen = misa_xlen();
|
|
||||||
if (xlen < 1) {
|
|
||||||
sbi_printf("Error %d getting MISA XLEN\n", xlen);
|
|
||||||
sbi_hart_hang();
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Boot HART details */
|
|
||||||
sbi_printf("Boot HART ID : %u\n", hartid);
|
|
||||||
sbi_printf("Boot HART Domain : %s\n", dom->name);
|
|
||||||
misa_string(xlen, str, sizeof(str));
|
|
||||||
sbi_printf("Boot HART ISA : %s\n", str);
|
|
||||||
sbi_hart_get_features_str(scratch, str, sizeof(str));
|
|
||||||
sbi_printf("Boot HART Features : %s\n", str);
|
|
||||||
sbi_printf("Boot HART PMP Count : %d\n",
|
|
||||||
sbi_hart_pmp_count(scratch));
|
|
||||||
sbi_printf("Boot HART PMP Granularity : %lu\n",
|
|
||||||
sbi_hart_pmp_granularity(scratch));
|
|
||||||
sbi_printf("Boot HART PMP Address Bits: %d\n",
|
|
||||||
sbi_hart_pmp_addrbits(scratch));
|
|
||||||
sbi_printf("Boot HART MHPM Count : %d\n",
|
|
||||||
sbi_hart_mhpm_count(scratch));
|
|
||||||
sbi_printf("Boot HART MHPM Count : %d\n",
|
|
||||||
sbi_hart_mhpm_count(scratch));
|
|
||||||
sbi_hart_delegation_dump(scratch, "Boot HART ", " ");
|
|
||||||
}
|
|
||||||
|
|
||||||
static spinlock_t coldboot_lock = SPIN_LOCK_INITIALIZER;
|
static spinlock_t coldboot_lock = SPIN_LOCK_INITIALIZER;
|
||||||
static struct sbi_hartmask coldboot_wait_hmask = { 0 };
|
static struct sbi_hartmask coldboot_wait_hmask = { 0 };
|
||||||
@@ -217,11 +111,14 @@ static void wake_coldboot_harts(struct sbi_scratch *scratch, u32 hartid)
|
|||||||
|
|
||||||
static unsigned long init_count_offset;
|
static unsigned long init_count_offset;
|
||||||
|
|
||||||
|
#ifdef CONFIG_SKIP_UBOOT
|
||||||
|
extern void generic_fdt_fixup_chosen(void);
|
||||||
|
#endif
|
||||||
static void __noreturn init_coldboot(struct sbi_scratch *scratch, u32 hartid)
|
static void __noreturn init_coldboot(struct sbi_scratch *scratch, u32 hartid)
|
||||||
{
|
{
|
||||||
int rc;
|
int rc;
|
||||||
unsigned long *init_count;
|
unsigned long *init_count;
|
||||||
const struct sbi_platform *plat = sbi_platform_ptr(scratch);
|
// const struct sbi_platform *plat = sbi_platform_ptr(scratch);
|
||||||
|
|
||||||
/* Note: This has to be first thing in coldboot init sequence */
|
/* Note: This has to be first thing in coldboot init sequence */
|
||||||
rc = sbi_scratch_init(scratch);
|
rc = sbi_scratch_init(scratch);
|
||||||
@@ -242,32 +139,32 @@ static void __noreturn init_coldboot(struct sbi_scratch *scratch, u32 hartid)
|
|||||||
if (rc)
|
if (rc)
|
||||||
sbi_hart_hang();
|
sbi_hart_hang();
|
||||||
|
|
||||||
rc = sbi_platform_early_init(plat, TRUE);
|
// rc = sbi_platform_early_init(plat, TRUE);
|
||||||
if (rc)
|
// if (rc)
|
||||||
sbi_hart_hang();
|
// sbi_hart_hang();
|
||||||
|
|
||||||
rc = sbi_hart_init(scratch, TRUE);
|
rc = sbi_hart_init(scratch, TRUE);
|
||||||
if (rc)
|
if (rc)
|
||||||
sbi_hart_hang();
|
sbi_hart_hang();
|
||||||
|
|
||||||
|
#if defined(CONFIG_SKIP_UBOOT_DEBUG)
|
||||||
rc = sbi_console_init(scratch);
|
rc = sbi_console_init(scratch);
|
||||||
if (rc)
|
if (rc)
|
||||||
sbi_hart_hang();
|
sbi_hart_hang();
|
||||||
|
#endif
|
||||||
|
|
||||||
sbi_boot_print_banner(scratch);
|
// rc = sbi_platform_irqchip_init(plat, TRUE);
|
||||||
|
// if (rc) {
|
||||||
|
// sbi_printf("%s: platform irqchip init failed (error %d)\n",
|
||||||
|
// __func__, rc);
|
||||||
|
// sbi_hart_hang();
|
||||||
|
// }
|
||||||
|
|
||||||
rc = sbi_platform_irqchip_init(plat, TRUE);
|
// rc = sbi_ipi_init(scratch, TRUE);
|
||||||
if (rc) {
|
// if (rc) {
|
||||||
sbi_printf("%s: platform irqchip init failed (error %d)\n",
|
// sbi_printf("%s: ipi init failed (error %d)\n", __func__, rc);
|
||||||
__func__, rc);
|
// sbi_hart_hang();
|
||||||
sbi_hart_hang();
|
// }
|
||||||
}
|
|
||||||
|
|
||||||
rc = sbi_ipi_init(scratch, TRUE);
|
|
||||||
if (rc) {
|
|
||||||
sbi_printf("%s: ipi init failed (error %d)\n", __func__, rc);
|
|
||||||
sbi_hart_hang();
|
|
||||||
}
|
|
||||||
|
|
||||||
rc = sbi_tlb_init(scratch, TRUE);
|
rc = sbi_tlb_init(scratch, TRUE);
|
||||||
if (rc) {
|
if (rc) {
|
||||||
@@ -287,8 +184,6 @@ static void __noreturn init_coldboot(struct sbi_scratch *scratch, u32 hartid)
|
|||||||
sbi_hart_hang();
|
sbi_hart_hang();
|
||||||
}
|
}
|
||||||
|
|
||||||
sbi_boot_print_general(scratch);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Note: Finalize domains after HSM initialization so that we
|
* Note: Finalize domains after HSM initialization so that we
|
||||||
* can startup non-root domains.
|
* can startup non-root domains.
|
||||||
@@ -302,8 +197,6 @@ static void __noreturn init_coldboot(struct sbi_scratch *scratch, u32 hartid)
|
|||||||
sbi_hart_hang();
|
sbi_hart_hang();
|
||||||
}
|
}
|
||||||
|
|
||||||
sbi_boot_print_domains(scratch);
|
|
||||||
|
|
||||||
rc = sbi_hart_pmp_configure(scratch);
|
rc = sbi_hart_pmp_configure(scratch);
|
||||||
if (rc) {
|
if (rc) {
|
||||||
sbi_printf("%s: PMP configure failed (error %d)\n",
|
sbi_printf("%s: PMP configure failed (error %d)\n",
|
||||||
@@ -315,14 +208,15 @@ static void __noreturn init_coldboot(struct sbi_scratch *scratch, u32 hartid)
|
|||||||
* Note: Platform final initialization should be last so that
|
* Note: Platform final initialization should be last so that
|
||||||
* it sees correct domain assignment and PMP configuration.
|
* it sees correct domain assignment and PMP configuration.
|
||||||
*/
|
*/
|
||||||
rc = sbi_platform_final_init(plat, TRUE);
|
// rc = sbi_platform_final_init(plat, TRUE);
|
||||||
if (rc) {
|
// if (rc) {
|
||||||
sbi_printf("%s: platform final init failed (error %d)\n",
|
// sbi_printf("%s: platform final init failed (error %d)\n",
|
||||||
__func__, rc);
|
// __func__, rc);
|
||||||
sbi_hart_hang();
|
// sbi_hart_hang();
|
||||||
}
|
// }
|
||||||
|
#ifdef CONFIG_SKIP_UBOOT
|
||||||
sbi_boot_print_hart(scratch, hartid);
|
generic_fdt_fixup_chosen();
|
||||||
|
#endif
|
||||||
|
|
||||||
wake_coldboot_harts(scratch, hartid);
|
wake_coldboot_harts(scratch, hartid);
|
||||||
|
|
||||||
|
|||||||
@@ -17,6 +17,43 @@
|
|||||||
#include <sbi_utils/fdt/fdt_fixup.h>
|
#include <sbi_utils/fdt/fdt_fixup.h>
|
||||||
#include <sbi_utils/fdt/fdt_helper.h>
|
#include <sbi_utils/fdt/fdt_helper.h>
|
||||||
|
|
||||||
|
#ifdef CONFIG_SKIP_UBOOT
|
||||||
|
#include "cvipart.h"
|
||||||
|
|
||||||
|
/* config root */
|
||||||
|
#ifdef CONFIG_NAND_SUPPORT
|
||||||
|
#ifdef CONFIG_SKIP_RAMDISK
|
||||||
|
#define ROOTARGS "ubi.mtd=ROOTFS ubi.block=0,0 root=/dev/ubiblock0_0 rootfstype=squashfs"
|
||||||
|
|
||||||
|
#else
|
||||||
|
#define ROOTARGS "ubi.mtd=ROOTFS ubi.block=0,0"
|
||||||
|
#endif /* CONFIG_SKIP_RAMDISK */
|
||||||
|
#else
|
||||||
|
#define ROOTARGS "rootfstype=squashfs rootwait ro root=" ROOTFS_DEV
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* BOOTARGS */
|
||||||
|
#define PARTS PART_LAYOUT
|
||||||
|
|
||||||
|
/* config loglevel */
|
||||||
|
#if defined(CONFIG_BUILD_FOR_DEBUG)
|
||||||
|
#define CONSOLE_LOGLEVEL " loglevel=9 \0"
|
||||||
|
#define EARLYCON_RELEASE " "
|
||||||
|
#elif defined(CONFIG_SKIP_UBOOT_DEBUG)
|
||||||
|
#define CONSOLE_LOGLEVEL " loglevel=9 \0"
|
||||||
|
#define EARLYCON_RELEASE " release "
|
||||||
|
#else
|
||||||
|
#define CONSOLE_LOGLEVEL " loglevel=0 \0"
|
||||||
|
#define EARLYCON_RELEASE " release "
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#define CVI_BOOTAGRS \
|
||||||
|
PARTS " " \
|
||||||
|
ROOTARGS " " \
|
||||||
|
"console=ttyS0,115200 earlycon=sbi riscv.fwsz=0x80000" CONSOLE_LOGLEVEL
|
||||||
|
#endif
|
||||||
|
|
||||||
void fdt_cpu_fixup(void *fdt)
|
void fdt_cpu_fixup(void *fdt)
|
||||||
{
|
{
|
||||||
struct sbi_domain *dom = sbi_domain_thishart_ptr();
|
struct sbi_domain *dom = sbi_domain_thishart_ptr();
|
||||||
@@ -265,4 +302,19 @@ void fdt_fixups(void *fdt)
|
|||||||
fdt_reserved_memory_fixup(fdt);
|
fdt_reserved_memory_fixup(fdt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef CONFIG_SKIP_UBOOT
|
||||||
|
void generic_fdt_fixup_chosen(void)
|
||||||
|
{
|
||||||
|
void *fdt;
|
||||||
|
int nodeoffset;
|
||||||
|
char *str; /* used to set string properties */
|
||||||
|
|
||||||
|
fdt = sbi_scratch_thishart_arg1_ptr();
|
||||||
|
|
||||||
|
nodeoffset = fdt_path_offset(fdt, "/chosen");
|
||||||
|
|
||||||
|
// str = "mtdparts=10000000.cvi-spif:512K(fip),1792K(2nd),3072K(jump),384K(PQ),64K(PARAM),64K(PARAM_BAK),64K(ENV),64K(ENV_BAK),2048K(ROOTFS),4096K(DATA) rootwait ro root=/dev/mtdblock8 rootfstype=squashfs console=ttyS0,115200 earlycon=sbi riscv.fwsz=0x80000 loglevel=9";
|
||||||
|
str = CVI_BOOTAGRS;
|
||||||
|
fdt_setprop(fdt, nodeoffset, "bootargs", str, strlen(str) + 1);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|||||||
@@ -15,7 +15,9 @@
|
|||||||
#define CLINT_TIMER_MAX_NR 16
|
#define CLINT_TIMER_MAX_NR 16
|
||||||
|
|
||||||
static unsigned long clint_timer_count = 0;
|
static unsigned long clint_timer_count = 0;
|
||||||
static struct clint_data clint_timer[CLINT_TIMER_MAX_NR];
|
static struct clint_data clint_timer[CLINT_TIMER_MAX_NR] = {
|
||||||
|
{.addr = 0x74000000, .first_hartid = 0, .hart_count = 1, .has_64bit_mmio = 0, },
|
||||||
|
};
|
||||||
|
|
||||||
static int timer_clint_cold_init(void *fdt, int nodeoff,
|
static int timer_clint_cold_init(void *fdt, int nodeoff,
|
||||||
const struct fdt_match *match)
|
const struct fdt_match *match)
|
||||||
@@ -29,9 +31,11 @@ static int timer_clint_cold_init(void *fdt, int nodeoff,
|
|||||||
if (1 < clint_timer_count)
|
if (1 < clint_timer_count)
|
||||||
ctmaster = &clint_timer[0];
|
ctmaster = &clint_timer[0];
|
||||||
|
|
||||||
rc = fdt_parse_clint_node(fdt, nodeoff, TRUE, ct);
|
if (clint_timer_count != 1) {
|
||||||
if (rc)
|
rc = fdt_parse_clint_node(fdt, nodeoff, TRUE, ct);
|
||||||
return rc;
|
if (rc)
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
return clint_cold_timer_init(ct, ctmaster);
|
return clint_cold_timer_init(ct, ctmaster);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ else
|
|||||||
FW_JUMP_ADDR=$(shell printf "0x%X" $$(($(FW_TEXT_START) + 0x200000)))
|
FW_JUMP_ADDR=$(shell printf "0x%X" $$(($(FW_TEXT_START) + 0x200000)))
|
||||||
endif
|
endif
|
||||||
#set FDT_ADDR 0xB0000000
|
#set FDT_ADDR 0xB0000000
|
||||||
FW_JUMP_FDT_ADDR=$(shell printf "0x%X" $$(($(FW_TEXT_START) + 0x30000000)))
|
FW_JUMP_FDT_ADDR=$(shell printf "0x%X" $$(($(FW_TEXT_START) + 0x80000)))
|
||||||
FW_PAYLOAD=y
|
FW_PAYLOAD=y
|
||||||
ifeq ($(PLATFORM_RISCV_XLEN), 32)
|
ifeq ($(PLATFORM_RISCV_XLEN), 32)
|
||||||
# This needs to be 4MB aligned for 32-bit system
|
# This needs to be 4MB aligned for 32-bit system
|
||||||
|
|||||||
Reference in New Issue
Block a user