aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2021-07-11firmware: Minor optimization in _scratch_init()Bin Meng
Before entering _scratch_init(), register t3 already holds a copy of the firmware end address, hence there is no need to calculate it again. This reduces 3 instructions in each _scratch_init() loop. Signed-off-by: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Xiang W <wxjstz@126.com> Reviewed-by: Atish Patra <atish.patra@wdc.com>
2021-07-11platform: generic: Add PMU supportAtish Patra
Add PMU support for generic platform. Generic platform solely relies on the device tree to parse all pmu related information. If any event is not described in device tree, generic platform will not support it. Reviewed-by: Anup Patel <anup.patel@wdc.com> Signed-off-by: Atish Patra <atish.patra@wdc.com>
2021-07-11lib: sbi: Improve TLB function namingAtish Patra
Follow the standard conventon for static function names: All global functions should be start with sbi_<module name>_ All static functions should be start with <module name>_ Reviewed-by: Anup Patel <anup.patel@wdc.com> Signed-off-by: Atish Patra <atish.patra@wdc.com>
2021-07-11lib: sbi: Implement firmware countersAtish Patra
RISC-V SBI v0.3 specification defines a set of firmware events that can provide additional information about the current firmware context. All of the firmware event monitoring are enabled now. The firmware events must be defined as raw perf event with MSB set as specified in the specification. Reviewed-by: Anup Patel <anup.patel@wdc.com> Signed-off-by: Atish Patra <atish.patra@wdc.com>
2021-07-11lib: sbi: Implement SBI PMU extensionAtish Patra
RISC-V SBI specfication 0.3 defines a PMU extension that allows supervisor mode to start/stop/configure pmu related events. This patch implements all of the functionality defined in the specification. Reviewed-by: Anup Patel <anup.patel@wdc.com> Signed-off-by: Atish Patra <atish.patra@wdc.com>
2021-07-11utils: fdt: Add fdt helper functions to parse PMU DT nodesAtish Patra
The PMU DT node bindings are defined in docs/pmu_support.md Add few fdt helper functions to parse the DT node and update the event-counter mapping tables. Reviewed-by: Anup Patel <anup.patel@wdc.com> Signed-off-by: Atish Patra <atish.patra@wdc.com>
2021-07-11lib: sbi: Add PMU supportAtish Patra
RISC-V SBI v0.3 specification defined a PMU extension to configure/start/stop the hardware/firmware pmu events. Implement PMU support in OpenSBI library. The implementation is agnostic of event to counter mapping & mhpmevent value configuration. That means, it expects platform hooks will be used to set up the mapping and provide the mhpmevent value at runtime. Reviewed-by: Anup Patel <anup.patel@wdc.com> Signed-off-by: Atish Patra <atish.patra@wdc.com>
2021-07-11lib: sbi: Add PMU specific platform hooksAtish Patra
A platform hook to initialize PMU allows platform vendors to provide their own mechanism to define pmu event-counter mappings in addition to the DT based approach. Another platform hook that allows platform vendors customize the final mhpmevent value configuration. Reviewed-by: Anup Patel <anup.patel@wdc.com> Signed-off-by: Atish Patra <atish.patra@wdc.com>
2021-07-11lib: sbi: Use csr_read/write_num to read/update PMU countersAtish Patra
Currently, csr_read/write_num functions are used to read/write PMP related CSRs where CSR value is decided at runtime. Expand this function to include PMU related CSRs as well. Reviewed-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Xiang W <wxjstz@126.com> Signed-off-by: Atish Patra <atish.patra@wdc.com>
2021-07-11lib: sbi: Remove redundant boot time print statementAtish Patra
This patch removes redundant print from sbi_boot_print_hart(). Reviewed-by: Anup Patel <anup.patel@wdc.com> Signed-off-by: Atish Patra <atish.patra@wdc.com>
2021-07-11include: Add a list empty check functionAtish Patra
Implement a list helper function that checks for empty lists. Reviewed-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Xiang W <wxjstz@126.com> Signed-off-by: Atish Patra <atish.patra@wdc.com>
2021-07-11lib: sbi: Disable m/scounteren & enable mcountinhibitAtish Patra
Currently, all bits in mcountern are enabled unconditionally at boot time. With SBI PMU extension, all the programmable counters should enabled only during performance monitoring for a particular event. However, this is done only if mcountinhibit is implemented because the supervisor mode can not start/stop any event without mcountinhibit. Similarly, supervisor should take care enabling scounteren which allows U-mode to access programmable pmu counters. All the non-programmable ones (CY, TM, IR) should be enabled in M-mode because some userspace may rely on builtins such as __builtin_readcyclecounter. Supervisor OS can still disable them during initial configuration. Reviewed-by: Anup Patel <anup.patel@wdc.com> Signed-off-by: Atish Patra <atish.patra@wdc.com>
2021-07-11lib: sbi: Detect number of bits implemented in mhpmcounterAtish Patra
RISC-V privilege specification allows the implementation to have less than 64 bits. Add a function to detect the number of implemented bits in mhpmcounter dynamically at runtime. Reviewed-by: Xiang W <wxjstz@126.com> Reviewed-by: Anup Patel <anup.patel@wdc.com> Signed-off-by: Atish Patra <atish.patra@wdc.com>
2021-07-11lib: sbi: Remove stray '\' characterAtish Patra
Reviewed-by: Xiang W <wxjstz@126.com> Reviewed-by: Anup Patel <anup.patel@wdc.com> Signed-off-by: Atish Patra <atish.patra@wdc.com>
2021-07-11lib: sbi: Detect mcountinihibit support at runtimeAtish Patra
RISC-V ISA specification v1.11 defined mcountinhibit CSR that allows software to stop any counter from incrementing. The SBI PMU extension depends on this CSR support in hardware. Define mcountinhibit as a hart specific feature and detect it at runtime. Reviewed-by: Anup Patel <anup.patel@wdc.com> Signed-off-by: Atish Patra <atish.patra@wdc.com>
2021-07-11docs: Add device tree bindings for SBI PMU extensionAtish Patra
SBI PMU extension requires a firmware to be aware of the event to counter/mhpmevent mappings supported by the hardware. One approach is to encode that information in the device tree. Define a device tree binding that allows a hardware to describe all the PMU mappings required in concise format. Reviewed-by: Anup Patel <anup.patel@wdc.com> Signed-off-by: Atish Patra <atish.patra@wdc.com>
2021-07-06platform: generic: Terminate platform.name with nullBin Meng
fw_platform_init() fills platform.name without considering the ending null character. Fix it. Signed-off-by: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Anup Patel <anup.patel@wdc.com>
2021-07-06docs/platform: thead-c9xx: Remove FW_PIC=yBin Meng
FW_PIC is on by default. Hence no need to explicitly require it. Signed-off-by: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Anup Patel <anup.patel@wdc.com>
2021-07-05lib: utils: reset: unify naming of 'sifive_test' deviceGreen Wan
Unify all the file and function names of 'sifive_test' device, to use the same prefix. This is also a preparatory patch for upcoming sifive reset device. Signed-off-by: Green Wan <green.wan@sifive.com> Reviewed-by: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Anup Patel <anup.patel@wdc.com>
2021-06-24platform: Replace CLINT library usage with ACLINT libraryAnup Patel
The ACLINT devices are backward compatible with SiFive CLINT so we replace all CLINT library usage in various platforms with ACLINT library. As a result of this replacement, the CLINT library is not used by any part of OpenSBI hence we remove it. Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Xiang W <wxjstz@126.com>
2021-06-24lib: utils/timer: Add FDT based ACLINT MTIMER driverAnup Patel
We add a new FDT based ACLINT MTIMER driver which works for both CLINT device and standalone ACLINT MTIMER device. Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Xiang W <wxjstz@126.com>
2021-06-24lib: utils/ipi: Add FDT based ACLINT MSWI IPI driverAnup Patel
We add a new FDT based ACLINT MSWI IPI driver which works for both CLINT device and standalone ACLINT MSWI device. Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Xiang W <wxjstz@126.com>
2021-06-24lib: utils: Add FDT parsing API common for both ACLINT and CLINTAnup Patel
We add fdt_parse_aclint_node() which can parse both ACLINT and CLINT DT nodes. This means fdt_parse_clint_node() is not required anymore so we remove it as well. Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Xiang W <wxjstz@126.com>
2021-06-24lib: utils/ipi: Add ACLINT MSWI libraryAnup Patel
We add common ACLINT MSWI library similar to the CLINT library so that OpenSBI platforms can use it. Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Xiang W <wxjstz@126.com>
2021-06-24lib: utils/timer: Add ACLINT MTIMER libraryAnup Patel
We add common ACLINT MTIMER library similar to the CLINT library so that OpenSBI platforms can use it. Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Xiang W <wxjstz@126.com>
2021-06-22lib: simplify sbi_fifo_inplace_update()Heinrich Schuchardt
Don't assign an unused value to variable index. Use operator '-=' where applicable. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Atish Patra <atish.patra@wdc.com> Reviewed-by: Xiang W <wxjstz@126.com>
2021-06-22lib: sign conflict in wake_coldboot_harts()Heinrich Schuchardt
Compiling wake_coldboot_harts() with GCC 11 and -Wextra yields: lib/sbi/sbi_init.c:208:27: error: comparison of integer expressions of different signedness: ‘int’ and ‘u32’ {aka ‘unsigned int’} [-Werror=sign-compare] 208 | for (int i = 0; i <= sbi_scratch_last_hartid(); i++) { | ^~ Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Atish Patra <atish.patra@wdc.com> Reviewed-by: Xiang W <wxjstz@126.com>
2021-06-22lib: sign conflict in sbi_tlb_entry_process()Heinrich Schuchardt
Compiling sbi_tlb_entry_process() with GCC 11 and -Wextra yields: lib/sbi/sbi_tlb.c: In function ‘sbi_tlb_process_count’: lib/sbi/sbi_tlb.c:206:31: error: comparison of integer expressions of different signedness: ‘u32’ {aka ‘unsigned int’} and ‘int’ [-Werror=sign-compare] 206 | if (deq_count > count) Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Atish Patra <atish.patra@wdc.com> Reviewed-by: Xiang W <wxjstz@126.com>
2021-06-22lib: utils/libfdt: Upgrade to v1.6.1 releaseBin Meng
Sync with libfdt v1.6.1 release source codes. Signed-off-by: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Anup Patel <anup.patel@wdc.com>
2021-06-12lib: sbi: Fix GET_F64_REG inline assemblyCharles Papon
Current, GET_F64_REG() macro does not generate correct inline assembly for the RV32 systems. This patch provides separate definitions of GET_F64_REG() macro for RV32 and RV64 systems. Signed-off-by: Charles Papon <charles.papon.90@gmail.com> Signed-off-by: Anup Patel <anup.patel@wdc.com>
2021-06-11lib: utils: missing initialization in thead_reset_initHeinrich Schuchardt
If property csr-copy does not exist, fdt_getprop() will return NULL and cnt will have a random value from the stack. Call clone_csrs() only if cnt is initialized to a non-zero value. Fixes: 49e422c5ad7a ("lib: utils: reset: Add T-HEAD sample platform reset driver") Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Anup Patel <anup.patel@wdc.com>
2021-06-11lib: sbi_scratch: zero out scratch memory on all hartsHeinrich Schuchardt
In sbi_scratch_init() we determine the last hart. The index of the last hart cannot exceed SBI_HARTMASK_MAX_BITS - 1. We should not initialize last_hartid_having_scratch to a higher number to avoid buffer overflows when using this value before calling sbi_scratch_init(). When allocating scratch memory in sbi_scratch_alloc_offset() we zero out the allocated memory for all harts except for the last one. We should not skip the last hart. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Anup Patel <anup.patel@wdc.com>
2021-06-11platform: andes/ae350: Drop plicsw_ipi_sync()Bin Meng
plicsw_ipi_sync() is a forward declaration but without the actual implementation. Drop it. Signed-off-by: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Anup Patel <anup.patel@wdc.com>
2021-06-11platform: andes/ae350: Drop plicsw_get_pending()Bin Meng
This is not used anywhere. Drop it. Signed-off-by: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Anup Patel <anup.patel@wdc.com>
2021-06-11docs/platform: andes-ae350: Fix missing spacesBin Meng
Fix several places in the docmentation that are missing spaces. Signed-off-by: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Anup Patel <anup.patel@wdc.com>
2021-06-11platform: andes/ae350: Cosmetic fixes in plicsw.cBin Meng
- %s/CLINT/PLICSW - replace '.' with a space - add a space around * in plicsw_cold_ipi_init() Signed-off-by: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Anup Patel <anup.patel@wdc.com>
2021-06-02lib: sbi_scratch: remove owner from sbi_scratch_alloc_offsetHeinrich Schuchardt
The parameter owner of function sbi_scratch_alloc_offset() is never used. The scratch memory is small. We should not use it for debug information in future. Hence eliminate the parameter. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Xiang W <wxjstz@126.com> Reviewed-by: Anup Patel <anup.patel@wdc.com>
2021-06-02lib: utils: consider ':' in stdout-pathHeinrich Schuchardt
The value of the /chosen/stdout-path devicetree property is used to determine the UART used by openSBI. According to the devicetree specification the value may contain a hyphen, e.g. chosen {                 stdout-path = "/serial@f00:115200";         }; If the character ':' is present, it terminates the path of the device. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Atish Patra <atish.patra@wdc.com>
2021-06-02docs: debugging OpenSBIHeinrich Schuchardt
Describe how to debug OpenSBI on QEMU with GDB. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Atish Patra <atish.patra@wdc.com>
2021-05-24lib: utils: Try other FDT drivers when we see SBI_ENODEVAnup Patel
We should try other FDT drivers when we see SBI_ENODEV returned by cold_init() of FDT driver. Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Atish Patra <atish.patra@wdc.com> Reviewed-by: Xiang W <wxjstz@126.com>
2021-05-24lib: Check region base for merging in sbi_domain_root_add_memregion()Anup Patel
We can merge region B onto region A only if base of region A is aligned to region A order + 1. Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Atish Patra <atish.patra@wdc.com> Reviewed-by: Xiang W <wxjstz@126.com>
2021-05-19lib: utils/fdt: Replace strcmp with strncmpDaniel Schaefer
Use strncmp() instead of strcmp() in __fixup_find_domain_offset() so that it compiles fine when linking with external firmware (such as EDK2). Signed-off-by: Daniel Schaefer <daniel.schaefer@hpe.com> Reviewed-by: Xiang W <wxjstz@126.com> Reviewed-by: Abner Chang <abner.chang@hpe.com> Reviewed-by: Anup Patel <anup.patel@wdc.com>
2021-05-19lib: utils/fdt: Don't use sbi_string functionsDaniel Schaefer
When SBI is built by external firmware, we need to use their functions, defined in libfdt_env.h. Just like 2cfd2fc9048806353298a1b967abf985901e36e8 Signed-off-by: Daniel Schaefer <daniel.schaefer@hpe.com> Reviewed-by: Abner Chang <abner.chang@hpe.com> Reviewed-by: Xiang W <wxjstz@126.com> Reviewed-by: Anup Patel <anup.patel@wdc.com>
2021-05-19lib: utils: Add strncpy macro to libfdt_env.hDaniel Schaefer
we want to use sbi_strncpy as strncpy in the OpenSBI implementation for libfdt. Just like 2845d2d2cf4fb74a89452ba223995aa4a118c07e Signed-off-by: Daniel Schaefer <daniel.schaefer@hpe.com> Reviewed-by: Abner Chang <abner.chang@hpe.com> Reviewed-by: Xiang W <wxjstz@126.com> Reviewed-by: Anup Patel <anup.patel@wdc.com>
2021-05-19Makefile: unconditionally disable SSPFabrice Fontaine
Though -nostdlib is passed in CFLAGS, -fno-stack-protector must also be passed to avoid linking errors related to undefined references to '__stack_chk_guard' and '__stack_chk_fail' if toolchain enforces -fstack-protector. Fixes: - https://gitlab.com/kubu93/buildroot/-/jobs/1247043359 Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com> Reviewed-by: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Xiang W <wxjstz@126.com>
2021-05-19lib: utils/serial: Support Synopsys DesignWare APB UARTBin Meng
Synopsys DesignWare APB UART is seen on the StarFive JH7100 SoC. Its programming interface is compatible with the existing 8250 UART driver. Simply add its compatible string to the driver makes it work with the StarFive JH7100 SoC on a BeagleV board. With this patch, the generic platform firmware can be used out of the box on the BeagleV board. Signed-off-by: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Anup Patel <anup.patel@wdc.com>
2021-05-14lib: sbi: Have spinlock checks return boolDaniel Schaefer
spin_lock_check already returned bool in the source file but not in the header. With some toolchains that causes an error, as it should. Because it and related functions all essentially return a bool, we can use this opportunity to change them. Signed-off-by: Daniel Schaefer <git@danielschaefer.me> Reviewed-by: Anup Patel <anup.patel@wdc.com>
2021-05-06platform: Remove sifive/fu540 platformBin Meng
Now that SiFive HiFive Unleashed board is using the generic platform support in OpenSBI, let's remove the old non-generic one. Signed-off-by: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Anup Patel <anup.patel@wdc.com>
2021-05-06docs: platform: Describe sifive_fu540 as supported generic platformBin Meng
The upstream U-Boot/QEMU have been using generic platform for SiFive HiFive Unleashed board for some time. Let's document sifive_fu540 as one of the supported targets for "generic" platform. Signed-off-by: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Anup Patel <anup.patel@wdc.com>
2021-05-06docs: platform: Sort platform namesBin Meng
Let's sort the platform names in alphabetical order. Signed-off-by: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Anup Patel <anup.patel@wdc.com>