- Jan 22, 2022
-
-
Jukka Laitinen authored
Using "void *" in arithmetic causes errors with strict compiler settings: "error: pointer of type 'void *' used in arithmetic [-Werror=pointer-arith]" Avoid these by calculating on "char *" where 1-byte data size is assumed. Signed-off-by:
Jukka Laitinen <jukkax@ssrc.tii.ae> Reviewed-by:
Dong Du <Dd_nirvana@sjtu.edu.cn> Reviewed-by:
Xiang W <wxjstz@126.com> Reviewed-by:
Anup Patel <anup@brainfault.org>
-
Aurelien Jarno authored
When the watchdog is running the HiFive Unmatched board does not reboot properly and shuts down itself a few seconds after reboot, in the early stages of the u-boot loading. On a Linux kernel this happens when the da9063_wdt module is loaded. This does not happen if the module is unloaded before reboot or if the watchdog module is loaded with "stop_on_reboot=1". Fix that by stopping the watchdog before attempting to reset the board. This is done by zeroing the TWDSCALE field of CONTROL_D register, unless it was already set to 0. Reported-by:
Tianon Gravi <tianon@debian.org> Signed-off-by:
Aurelien Jarno <aurelien@aurel32.net> Reviewed-by:
Nikita Shubin <n.shubin@yadro.com> Tested-by:
Nikita Shubin <n.shubin@yadro.com> Reviewed-by:
Anup Patel <anup@brainfault.org>
-
Aurelien Jarno authored
da9063_reset() and da9063_shutdown() take the chip address in argument (like similar functions), but in practice use the da9063 global struct instead. Fix that. Signed-off-by:
Aurelien Jarno <aurelien@aurel32.net> Reviewed-by:
Nikita Shubin <n.shubin@yadro.com> Reviewed-by:
Anup Patel <anup@brainfault.org> Reviewed-by:
Xiang W <wxjstz@126.com>
-
- Jan 11, 2022
-
-
Anup Patel authored
Some of RISC-V emulators provide HTIF at fixed base address so for such emulators users have to hard-code HTIF base address in the linker script. To address this problem, we let users optionally provide fixed HTIF base address via platform support (or device tree). Signed-off-by:
Anup Patel <apatel@ventanamicro.com> Reviewed-by:
Dong Du <Dd_nirvana@sjtu.edu.cn> Reviewed-by:
Atish Patra <atishp@rivosinc.com>
-
Anup Patel authored
Currently, the ACLINT MSWI size check is forcing size to be at least 0x4000. This is inappropriate check because most systems will never utilize full 16KB for a single ACLINT MSWI device so instead we should check that ACLINT MSWI size is enough for on the associated HARTs. Signed-off-by:
Anup Patel <apatel@ventanamicro.com> Reviewed-by:
Dong Du <Dd_nirvana@sjtu.edu.cn> Reviewed-by:
Alistair Francis <alistair.francis@wdc.com>
-
- Dec 24, 2021
-
-
Anup Patel authored
This patch updates OpenSBI version to 1.0 as part of release preparation. Signed-off-by:Anup Patel <anup.patel@wdc.com>
-
- Dec 23, 2021
-
-
Anup Patel authored
Some of the external firmwares using OpenSBI as library are facing issues with the weak memcpy() and memset() aliases in libsbi.a so we move these to fw_base.S. This way mapping of implicit memcpy() or memset() calls to sbi_memcpy() or sbi_memset() will only be done for OpenSBI firmwares. (Refer, https://github.com/riscv-software-src/opensbi/issues/234 ) In addition, we also add memmove() and memcmp() mappings in fw_base.S because as-per the GCC documentation the freestanding environment must provide memcpy(), memmove(), memset(), and memcmp(). Signed-off-by:
Anup Patel <anup.patel@wdc.com> Reviewed-by:
Atish Patra <atishp@rivosinc.com>
-
- Dec 22, 2021
-
-
Heinrich Schuchardt authored
pmpcfg_csr and pmpcfg_shift are only negative for an unexpected value of __riscv_xlen. We can immediately return in this case. Signed-off-by:
Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by:
Dong Du <Dd_nirvana@sjtu.edu.cn> Reviewed-by:
Anup Patel <anup.patel@wdc.com>
-
- Dec 16, 2021
-
-
Xiang W authored
The commit 69d7e536 disables the -m(no-)save-restore option for clang, but clang11 supports this option. This patch uses the output information of the compiler to check whether the compiler supports this option. Signed-off-by:
Xiang W <wxjstz@126.com> Reviewed-by:
Anup Patel <anup.patel@wdc.com>
-
- Dec 11, 2021
-
-
Anup Patel authored
When compiling with -Os option along with -ffreestanding, both GCC and clang will add implicit calls to memcpy() and memset() for stack variables initialized in declaration. The C standard as per Clause 4, the compiler cannot necessarily assume that anything beyond: * float.h * iso646.h * limits.h * stdalign.h * stdarg.h * stdbool.h * stddef.h * stdint.h * stdnoreturn.h * fenv.h * math.h * and the numeric conversion functions of stdlib.h. This patch maps memcpy() and memset() as weak-alias of sbi_memcpy() and sbi_memset() respectively so that implicit calls to memcpy() and memset() will compile properly. Signed-off-by:
Anup Patel <anup.patel@wdc.com> Reviewed-by:
Dong Du <Dd_nirvana@sjtu.edu.cn> Reviewed-by:
Xiang W <wxjstz@126.com>
-
Anup Patel authored
The riscv target of CLANG-10 (or lower) does not support the -m(no-)save-restore option so we get compile warnings. This patch fixes compile warning by using -m(no-)save-restore option only for GCC. Signed-off-by:
Anup Patel <anup.patel@wdc.com> Reviewed-by:
Dong Du <Dd_nirvana@sjtu.edu.cn>
-
Nikita Shubin authored
We should check if SSCOF extension is present, before applying inhibit mask and clearing overflow, otherwise undesirable value can be written in MHPMEVENT_N CSR. Signed-off-by:
Nikita Shubin <n.shubin@yadro.com> Reviewed-by:
Anup Patel <anup.patel@wdc.com> Reviewed-by:
Xiang W <wxjstz@126.com>
-
Tsukasa OI authored
This commit makes Spike usable as QEMU (in fact, those are based on QEMU examples). Signed-off-by:
Tsukasa OI <research_trasio@irq.a4lg.com> Reviewed-by:
Anup Patel <anup.patel@wdc.com>
-
- Dec 03, 2021
-
-
Vincent Chen authored
RISC-V privilege specification does not specify how to encode the event ID. Therefore, each platform is allowed to customize its own encoding rule. The common encoding methods are as follow, directly assigning a number to an event, or every bit in the mphmevent CSR controls one specified event or mixes the above two methods. To enable OpenSBI to support the above three encoding methods simultaneously, this patch repurpose the dt property "riscv,raw-event-to-mhpmcounters". The "riscv,raw-event-to-mhpmcounters" will describes the one or multiple raw events that could be counted by a set of counters. But, the column number of "riscv,raw-event-to-mhpmcounters" is extended from 2 to 3. The 1st column (64bit) is the ID of the raw events. The 2nd column (64bit) represents a select_mask now to represent the bits used for event ID encoding. If a platform directly encodes each raw PMU event as a unique ID, the value of select_mask will be 0xffffffff_ffffffff. Signed-off-by:
Vincent Chen <vincent.chen@sifive.com> Signed-off-by:
Atish <Patra<atishp@rivosinc.com> Reviewed-by:
Anup Patel <anup.patel@wdc.com>
-
- Dec 02, 2021
-
-
Jessica Clarke authored
BUG and BUG_ON are not informative and are rather lazy interfaces, only telling the user that something went wrong in a given function, but not what, requiring the user to find the sources corresponding to their firmware (which may not be available) and figure out how that BUG(_ON) was hit. Even SBI_ASSERT in its current form, which does include the condition that triggered it in the output, isn't necessarily very informative. In some cases, the error may be fixable by the user, but they need to know the problem in order to have any hope of fixing it. It's also a nuisance for developers, whose development trees may have changed significantly since the release in question being used, and so line numbers can make it harder for them to understand which error case a user has hit. This patch introduces a new sbi_panic function which is printf-like, allowing detailed error messages to be printed to the console. BUG and BUG_ON are removed, since the former is just a worse form of sbi_panic and the latter is a worse version of SBI_ASSERT. Finally, SBI_ASSERT is augmented to take a set of arguments to pass to sbi_panic on failure, used like so (sbi_boot_print_hart's current error case, which currently manually calls sbi_printf and sbi_hart_hang): SBI_ASSERT(xlen >= 1, ("Error %d getting MISA XLEN\n", xlen)); The existing users of BUG are replaced with calls to sbi_panic along with informative error messages. BUG_ON and SBI_ASSERT were unused (and, in the case of SBI_ASSERT, remain unused). Many existing users of sbi_hart_hang should be converted to use either sbi_panic or SBI_ASSERT after this commit. Signed-off-by:Jessica Clarke <jrtc27@jrtc27.com> Reviewed-by:
Anup Patel <anup.patel@wdc.com> Reviewed-by:
Xiang W <wxjstz@126.com> Reviewed-by:
Atish Patra <atishp@rivosinc.com>
-
- Nov 30, 2021
-
-
Dong Du authored
A recent commit (b28f0700 ) turns to read from CSR_MCOUNTINHIBIT after checking the SBI_HART_HAS_MCOUNTINHIBIT HART feature, which leaves the mctr_inhbt uninitialized in pmu_ctr_find_hw(). As a result, compiler will complain: error: 'mctr_inhbt' may be used uninitialized in this function. This commit resolves the issue by assigning an initial value to mctr_inhbt. Signed-off-by:
Dong Du <Dd_nirvana@sjtu.edu.cn> Reviewed-by:
Xiang W <wxjstz@126.com> Reviewed-by:
Anup Patel <anup.patel@wdc.com>
-
Nikita Shubin authored
Fix missing space in sbi_hart_pmp_configure error printing. Signed-off-by:
Nikita Shubin <n.shubin@yadro.com> Reviewed-by:
Dong Du <Dd_nirvana@sjtu.edu.cn> Reviewed-by:
Xiang w <wxjstz@126.com>
-
- Nov 23, 2021
-
-
Vagrant Cascadian authored
Fix a spelling typo in error print. Signed-off-by:
Vagrant Cascadian <vagrant@debian.org> Signed-off-by:
Anup Patel <anup.patel@wdc.com> Reviewed-by:
Xiang W <wxjstz@126.com>
-
- Nov 18, 2021
-
-
Gabriel Somlo authored
Add support for the UART provided by the LiteX SoC framework (https://github.com/enjoy-digital/litex ), based on its FDT info (described in the Linux tree at Documentation/devicetree/bindings/serial/litex,liteuart.yaml). Signed-off-by:
Gabriel Somlo <gsomlo@gmail.com> Reviewed-by:
Xiang W <wxjstz@126.com> Reviewed-by:
Anup Patel <anup.patel@wdc.com>
-
- Nov 12, 2021
-
-
Xiang W authored
We should clear A bits in prot variable before enabling A_NA4 or A_NAPOT. Signed-off-by:
Xiang W <wxjstz@126.com> Reviewed-by:
Anup Patel <anup.patel@wdc.com>
-
Nikita Shubin authored
da9063 PMIC can be used to reset/shutdown the Sifive Unmatched board. shutdown is done simply by writing SHUTDOWN bit to DA9063_REG_CONTROL_F register. reset via setting WAKEUP bit in DA9063_REG_CONTROL_F register followed by masking POWER and POWER1 domains and setting STANDBY bit in DA9063_REG_CONTROL_A, originally discovered by Alexandre Ghiti on linux-riscv maillists. Tested-by:
Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by:
Alexandre Ghiti <alexandre.ghiti@canonical.com> Tested-by:
Alexandre Ghiti <alexandre.ghiti@canonical.com> Signed-off-by:
Nikita Shubin <n.shubin@yadro.com>
-
Nikita Shubin authored
Minimum SiFive I2C driver to read/send bytes over I2C bus. This allows querying information and perform operation of onboard PMIC, as well as power-off and reset. Tested-by:
Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by:
Alexandre Ghiti <alexandre.ghiti@canonical.com> Tested-by:
Alexandre Ghiti <alexandre.ghiti@canonical.com> Signed-off-by:
Nikita Shubin <n.shubin@yadro.com>
-
Nikita Shubin authored
FDT based I2C framework on the top of I2C library. The drivers are probed on demand by fdt_i2c_adapter_get function. Tested-by:
Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by:
Alexandre Ghiti <alexandre.ghiti@canonical.com> Tested-by:
Alexandre Ghiti <alexandre.ghiti@canonical.com> Signed-off-by:
Nikita Shubin <n.shubin@yadro.com>
-
Nikita Shubin authored
Helper library to keep track of registered I2C adapters, identified by dts offset, basic send/read functions and adapter configuration (enable, set dividers, etc...). Tested-by:
Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by:
Alexandre Ghiti <alexandre.ghiti@canonical.com> Tested-by:
Alexandre Ghiti <alexandre.ghiti@canonical.com> Signed-off-by:
Nikita Shubin <n.shubin@yadro.com>
-
Nikita Shubin authored
Move driver init code to separate function, so it can be reused elsewhere. Tested-by:
Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by:
Alexandre Ghiti <alexandre.ghiti@canonical.com> Tested-by:
Alexandre Ghiti <alexandre.ghiti@canonical.com> Signed-off-by:
Nikita Shubin <n.shubin@yadro.com>
-
Nikita Shubin authored
Make gpio_system_reset_check return priority instead of just true/false. Make default 128 priority for reset/shutdown. Tested-by:
Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by:
Alexandre Ghiti <alexandre.ghiti@canonical.com> Tested-by:
Alexandre Ghiti <alexandre.ghiti@canonical.com> Signed-off-by:
Nikita Shubin <n.shubin@yadro.com>
-
- Nov 11, 2021
-
-
Vasan VS authored
We should ensure that pmpcfg0.pmp0cfg is set to zero before using pmpaddr0 CSR for detecting implemented PMP address bits. Fixes: bf216328 ("lib: sbi: Detect PMP granularity and number of address bits") Signed-off-by:
Vasan VS <vasan.vs@gmail.com> Signed-off-by:
Anup Patel <anup.patel@wdc.com> Reviewed-by:
Atish Patra <atish.patra@wdc.com> Reviewed-by:
Dong Du <Dd_nirvana@sjtu.edu.cn>
-
Atish Patra authored
The first 32 bits of the initial value for the counter should be preserved while updating the mhpmcounter for 32bit. Fixes: 13d40f21 ("lib: sbi: Add PMU support") Signed-off-by:
Atish Patra <atish.patra@wdc.com> Reviewed-by:
Bin Meng <bmeng.cn@gmail.com> Reviewed-by:
Dong Du <Dd_nirvana@sjtu.edu.cn> Reviewed-by:
Anup Patel <anup.patel@wdc.com>
-
Atish Patra authored
As per the DT schema rules, the prefix should be vendor. As the PMU properties are generic for all vendors, change the prefix to riscv instead of pmu. Reviewed-by:
Anup Patel <anup.patel@wdc.com> Reviewed-by:
Bin Meng <bmeng.cn@gmail.com> Signed-off-by:
Atish Patra <atish.patra@wdc.com>
-
Atish Patra authored
Some platforms such as hifive unmatched doesn't implement mcountinhibit csr. However, it has hardware events that can be monitored using 2 hpmcounter it has (i.e. mhpmcounter3 & mhpmcounter4). Currently, PMU extension disabled if mcountinhibit is absent. That's not really necessary as long as the supervisor OS keeps track of the delta value of the counters. Without mcountinhibit, the delta value won't be entirely accurate because the counters are freely running. However, that should be fine to produce an approximate counter value which can help performance analysis. Perf sampling won't work though as sscof extension is not present in hifive unmatched. Reviewed-by:
Anup Patel <anup.patel@wdc.com> Reviewed-by:
Bin Meng <bmeng.cn@gmail.com> Signed-off-by:
Atish Patra <atish.patra@wdc.com>
-
Atish Patra authored
The mhpm bits represent the number of bits available in mhpmcounter while counter width describes a zero indexed value. Fix the counter width calculation. Fixes: 13d40f21 ("lib: sbi: Add PMU support") Reviewed-by:
Bin Meng <bmeng.cn@gmail.com> Reviewed-by:
Anup Patel <anup.patel@wdc.com> Signed-off-by:
Atish Patra <atish.patra@wdc.com>
-
Atish Patra authored
The hardware solely relies on the event selector value in mhpmevent to figure out what event to monitor using that counter. It should be reset when counter reset happens. Reviewed-by:
Anup Patel <anup.patel@wdc.com> Reviewed-by:
Bin Meng <bmeng.cn@gmail.com> Signed-off-by:
Atish Patra <atish.patra@wdc.com>
-
Atish Patra authored
A platform may use programmable counters for cycle/instret events. The priv spec allows that provided that cycle/instret also report those events in addition to the programmable counters. We should allow that functionality in OpenSBI. Reviewed-by:
Anup Patel <anup.patel@wdc.com> Reviewed-by:
Bin Meng <bmeng.cn@gmail.com> Signed-off-by:
Atish Patra <atish.patra@wdc.com>
-
Atish Patra authored
OpenSBI doesn't use any counters for its own usage. Thus, all the counters can be made accessible for lower privilege mode always. However, the mcountinhibit must be set so that the counter doesn't increment. As a result, we don't have to enable/disable mcounteren at every start/stop. Reviewed-by:
Bin Meng <bmeng.cn@gmail.com> Reviewed-by:
Anup Patel <anup.patel@wdc.com> Signed-off-by:
Atish Patra <atish.patra@wdc.com>
-
Atish Patra authored
This patch adds sscofpmf extension in pmu module which includes following things. 1. Enable overflow irq when starting a counter. 2. Setting the correct event filters passed from supervisor. 3. Delegating the overflow interrupt to the supervisor. 4. Add RV32 support for sscofpmf. Reviewed-by:
Anup Patel <anup.patel@wdc.com> Reviewed-by:
Bin Meng <bmeng.cn@gmail.com> Signed-off-by:
Atish Patra <atish.patra@wdc.com>
-
Atish Patra authored
OpenSBI doesn't handle PMU counters for now. Delegate the overflow counter to S-mode always. Reviewed-by:
Bin Meng <bmeng.cn@gmail.com> Reviewed-by:
Anup Patel <anup.patel@wdc.com> Signed-off-by:
Atish Patra <atish.patra@wdc.com>
-
Atish Patra authored
Sscofpmf ISA extension introduces PMU counter overflow and filtering support. It introduces a read only `scountovf` csr that can be used to detect if a hart supports this extension at runtime. However, this feature is only useful if the hart already supports mcounteren and mcountinhibit. Add a dynamic detection mechanism and boot time print message if sscofpmf is present. Reviewed-by:
Anup Patel <anup.patel@wdc.com> Reviewed-by:
Bin Meng <bmeng.cn@gmail.com> Signed-off-by:
Atish Patra <atish.patra@wdc.com>
-
Atish Patra authored
The Sscofpmf extension introduces mhpmevent[h] csrs to handle filtering /overflow bits in RV32. There is no way to read/write mcountinhibit using mcountinhibit csr using a variable. Updated the support to read/write mhpmevent[h] and mcountinhibit csr. Reviewed-by:
Anup Patel <anup.patel@wdc.com> Reviewed-by:
Bin Meng <bmeng.cn@gmail.com> Signed-off-by:
Atish Patra <atish.patra@wdc.com>
-
Atish Patra authored
[1] https://drive.google.com/file/d/1KcjgbLM5L1ZKY8934aJl8aQwGlMz6Cbo/view Reviewed-by:
Xiang W <wxjstz@126.com> Reviewed-by:
Bin Meng <bmeng.cn@gmail.com> Reviewed-by:
Anup Patel <anup.patel@wdc.com> Signed-off-by:
Atish Patra <atish.patra@wdc.com>
-
- Nov 08, 2021
-
-
Heinrich Schuchardt authored
The initialization of a reset driver may fail for various reasons, like a PMIC based reset driver not finding the required I2C driver. The return code of the init routine may take other error values than -ENODEV. If the initialization of a reset driver fails, this should not lead to the board hanging. It is enough that the reset driver does not call sbi_system_reset_add_device() to avoid invoking the driver for a device that could not be initialized. Change the return type of fdt_reset_init() to void. Print a message if an error occurs. Signed-off-by:
Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by:
Dong Du <Dd_nirvana@sjtu.edu.cn> Reviewed-by:
Anup Patel <anup.patel@wdc.com>
-