aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2025-01-30lib: sbi: pmu: add the PMU SSE event only if overflow IRQ is supportedClément Léger1-1/+2
Add the PMU SSE event only if an overflow irq bit is present. Signed-off-by: Clément Léger <cleger@rivosinc.com> Reviewed-by: Samuel Holland <samuel.holland@sifive.com> Reviewed-by: Atish Patra <atishp@rivosinc.com>
2025-01-30lib: sbi: sse: return SBI_ENOTSUPP for unsupported eventsClément Léger1-0/+30
If a standard event was not found in the list of events that are handled by harts but belongs to the standard event list defined by the specification, return SBI_ENOTSUPP. Without that, we can not distinguish a non implemented standard event from a non valid one. Signed-off-by: Clément Léger <cleger@rivosinc.com> Reviewed-by: Samuel Holland <samuel.holland@sifive.com> Reviewed-by: Atish Patra <atishp@rivosinc.com>
2025-01-30lib: sbi: sse: allow adding new eventsClément Léger5-59/+106
In order to allow events to be dynamically added, remove the existing static array of events and use a simply linked list of supported events. This allows us to move the cb_ops into this list and associated it with an event_id. Drivers can now register cb_ops before bringing up the sse core to handle additional events (platform ones for instance). sbi_sse_init() now allocates as many events as present in the linked list. Events can now be added with sbi_sse_add_event() which allows to add new supported events with some callback operations if any. If an event is not to be supported, then sbi_sse_add_event() should not be called. This approach currently consider that local events are to be supported on all harts (ie, they all support the same ISA or dependencies). If per-hart event availability needs to be supported, then, an is_supported() callback could be added later and called for each hart. Signed-off-by: Clément Léger <cleger@rivosinc.com> Reviewed-by: Samuel Holland <samuel.holland@sifive.com>
2025-01-30include: lib: add a simple singly linked list implementationClément Léger1-0/+33
Add a simple singly linked list implementation when double linked list are not needed. This allows to easily have statically defined linked list that can be extended at runtime. Signed-off-by: Clément Léger <cleger@rivosinc.com> Reviewed-by: Anup Patel <anup@brainfault.org>
2025-01-30lib: sbi: sse: return an error value from sse_event_get()Clément Léger1-34/+38
Since event support will be checked in the next commits, return a value from sse_event_get() to allow propagating it. This will be used to report SBI_ERR_NOT_SUPPORTED when an event isn't supported. Signed-off-by: Clément Léger <cleger@rivosinc.com> Reviewed-by: Samuel Holland <samuel.holland@sifive.com> Reviewed-by: Atish Patra <atishp@rivosinc.com>
2025-01-30lib: sbi: move sbi_double_trap_handler() to a dedicated headerClément Léger3-2/+21
We will add new functions to sbi_double_trap.c in order to register an SSE event, split this to a header as part of preparation work. Signed-off-by: Clément Léger <cleger@rivosinc.com> Reviewed-by: Anup Patel <anup@brainfault.org>
2025-01-30lib: sbi: pmu: fix usage of sbi_pmu_irq_bit()Clément Léger6-24/+41
While sbi_pmu_irq_bit() was used to delegate irq to S-mode, LCOFIP usage was still hardcoded in various places. This led to change the returned value of sbi_pmu_irq_bit() to be a bit number rather than a bit mask since it returns an 'int' and we need to obtain the bit number itself to handle it in the IRQs handlers. Add a similar function to return the irq mask which can also be used where the mask is required rather than the bit itself. Signed-off-by: Clément Léger <cleger@rivosinc.com> Reviewed-by: Samuel Holland <samuel.holland@sifive.com> Reviewed-by: Atish Patra <atishp@rivosinc.com>
2024-12-24include: Bump-up version to 1.6v1.6Anup Patel1-1/+1
Update the OpenSBI version to 1.6 as part of release preparation. Signed-off-by: Anup Patel <apatel@ventanamicro.com> Signed-off-by: Anup Patel <anup@brainfault.org>
2024-12-24lib: utils: Fix irqchip registration for PLIC and APLICAnup Patel4-11/+11
Currently, the same irqchip instance is registered for multiple PLIC and APLIC instances which causes the sbi_list_for_each_entry() loop in the sbi_irqchip_init() to hang at boot-time. To address the above issue, register a separate irqchip instance for each PLIC and APLIC instance. Fixes: 2dd6eaf68055 ("lib: sbi_irqchip: Call driver warm_init from SBI core") Reported-by: Himanshu Chauhan <hchauhan@ventanamicro.com> Signed-off-by: Anup Patel <apatel@ventanamicro.com> Reviewed-by: Himanshu Chauhan <hchauhan@ventanamicro.com>
2024-12-24lib: sbi: Improve the alignment of boot-time printsAnup Patel1-31/+31
Addition of "Experimental SBI Extensions" to the boot-time prints disturbs the alignment of other prints so adjust all boot-time prints accordingly. Signed-off-by: Anup Patel <apatel@ventanamicro.com>
2024-12-22lib: sbi: Print list of available SBI extensions at boot-timeAnup Patel19-9/+63
Add boot-time prints for list of available standard and experimental SBI extensions. Signed-off-by: Anup Patel <apatel@ventanamicro.com>
2024-12-21include: sbi: Fix compiling with C23 enabled compilersMichael Neuling2-5/+7
C23 pre-defines bool so we need to gate our defines. Signed-off-by: Michael Neuling <michaelneuling@tenstorrent.com> Reviewed-by: Anup Patel <anup@brainfault.org>
2024-12-21inclue: sbi_utils: Cleanup int vs bool in semihosting_init() definitionsMichael Neuling1-2/+2
This is needed for a future patches to enable the new C23 language dialect. Signed-off-by: Michael Neuling <michaelneuling@tenstorrent.com> Reviewed-by: Anup Patel <anup@brainfault.org>
2024-12-21lib: utils: Mark RPMI drivers as experimentalSamuel Holland8-0/+11
These drivers were merged on an experimental basis without the RPMI specification being frozen. As a result, they may not be compatible with the frozen version of the RPMI protocol. Additionally, their devicetree bindings have not been reviewed and are subject to change. Warn the user that these drivers make no compatibility guarantees, and that their behavior and devicetree bindings may change incompatibly in future versions of OpenSBI. Signed-off-by: Samuel Holland <samuel.holland@sifive.com> Reviewed-by: Anup Patel <anup@brainfault.org>
2024-12-21platform: generic: Initialize console before other driversSamuel Holland1-5/+5
Initialize serial drivers first, so messages printed by other drivers do not need to use the early console buffer. Suggested-by: Anup Patel <anup@brainfault.org> Signed-off-by: Samuel Holland <samuel.holland@sifive.com> Reviewed-by: Anup Patel <anup@brainfault.org>
2024-12-19lib: utils: Improve rpmi_cppc_fc_db_trigger() for RV32Xiang W1-14/+7
Improve 64-bit operation under rv32 and remove db_val_u32_hi in rpmi_cppc_fc_db_trigger(). Signed-off-by: Xiang W <wxjstz@126.com> Reviewed-by: Anup Patel <anup@brainfault.org>
2024-12-15lib: sbi_pmu: Verify the raw events first during event infoAtish Patra1-7/+6
The raw events have same event_idx. Thus, the event info sanity check only relies on the select mask. The raw event check should be done first so that regular hardware events can be verified using event idx range check. Fixes: e4345842168b ("lib: sbi_pmu: Implement SBI PMU event info function") Signed-off-by: Atish Patra <atishp@rivosinc.com> Reviewed-by: Anup Patel <anup@brainfault.org>
2024-12-15lib: sbi_pmu: Fix the sanity check condition for hw event mapAtish Patra1-2/+2
The hardware event map function invoked from platform code should exclude any raw events as there is a separate function for the raw events. Fixes: d8a483fc7fd0 ("lib: sbi_pmu: PMU raw event v2 support") Signed-off-by: Atish Patra <atishp@rivosinc.com> Reviewed-by: Anup Patel <anup@brainfault.org>
2024-12-15scripts/carray: change to using single awk invocation to generate .cBen Dooks1-33/+99
The shell script makes multiple call-outs to awk to get information from the configuration file. It would be easier to just write the whole thing in one .awk script and have the makefile altered to call that instead. There should be no functional difference other than the script type and has been tested with PLATFORM=generic build. This should be both quicker and easier to understand. Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk> Reviewed-by: Anup Patel <anup@brainfault.org>
2024-12-15script/carry.sh: send error to stderrBen Dooks1-6/+8
Send the errors to stderr, otherwise they end up being written to the file the script was redirecting to in the Makefile Also, use EOF block to make it easier to redirect Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk> Reviewed-by: Anup Patel <anup@brainfault.org>
2024-12-15Makefile: remove carry output if scripts/carray.sh failsBen Dooks1-1/+1
If the script fails, we end up trying to build either an empty or damaged .c file. Just remove it and let gcc fail on non-existent file. Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk> Reviewed-by: Anup Patel <anup@brainfault.org>
2024-12-15top: add ~ files to .gitignoreBen Dooks1-0/+1
Ignore temporary files, and avoid accidentally adding them to a commit. Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk> Reviewed-by: Anup Patel <anup@brainfault.org>
2024-12-15lib: sbi: sse: Fix a6 and a7 register content upon injectionClément Léger1-2/+2
The specification states that a6 contains the current hart id and a7 contains the entry argument. This was inverted in the current implementation. Reported-by: Andrew Jones <andrew.jones@linux.dev> Signed-off-by: Clément Léger <cleger@rivosinc.com> Reviewed-by: Anup Patel <anup@brainfault.org>
2024-12-15lib: sbi: fix GLOBAL_PLAT_DEFINEClément Léger1-2/+2
Fix GLOBAL_PLAT_0_START/END definitions. The specification states that the beginning of the range is 0xc000 and the end is 0xffff. Reported-by: Andrew Jones <andrew.jones@linux.dev> Signed-off-by: Clément Léger <cleger@rivosinc.com> Reviewed-by: Anup Patel <anup@brainfault.org>
2024-12-15Makefile: Don't enable V-extension using -march optionAnup Patel2-6/+7
Enabling V-extension using -march option causes OpenSBI boot-time hang with LLVM compiler. As a work-around, don't enable V-extension using -march option and instead use a custom OpenSBI specific define inform availability of V-extension to lib/sbi/sbi_trap_v_ldst.c. Fixes: c2acc5e5b0d8 ("lib: sbi_misaligned_ldst: Add handling of vector load/store") Signed-off-by: Anup Patel <apatel@ventanamicro.com> Reviewed-by: Samuel Holland <samuel.holland@sifive.com>
2024-12-15lib: utils/fdt_cppc_rpmi: Fix compile error with LLVMAnup Patel1-2/+5
The following error is observed when compiling fdt_cppc_rpmi driver using LLVM: lib/utils/cppc/fdt_cppc_rpmi.c:87:3: error: label followed by a declaration is a C23 extension [-Werror,-Wc23-extensions] 87 | u64 db_val_u64 = 0; To fix the above issue, move the variable declaration at the start of function. Fixes: 591a98bdd549 ("lib: utils/cppc: Add RPMI CPPC driver") Signed-off-by: Anup Patel <apatel@ventanamicro.com> Reviewed-by: Samuel Holland <samuel.holland@sifive.com>
2024-12-06lib: sbi_misaligned_ldst: Add handling of vector load/storeNylon Chen6-12/+760
Add misaligned load/store handling for the vector extension to the sbi_misaligned_ldst library. This implementation is inspired from the misaligned_vec_ldst implementation in the riscv-pk project. Co-developed-by: Zong Li <zong.li@sifive.com> Signed-off-by: Zong Li <zong.li@sifive.com> Signed-off-by: Nylon Chen <nylon.chen@sifive.com> Reviewed-by: Andy Chiu <andy.chiu@sifive.com> Reviewed-by: Anup Patel <anup@brainfault.org>
2024-12-06lib: utils/mpxy: Add RPMI client driver for MPXYRahul Pathak5-0/+548
Add a generic RPMI mailbox client driver which provides a MPXY channel. Initially, this driver only supports RPMI clock service group but can be extended to support multiple RPMI service groups. Signed-off-by: Rahul Pathak <rpathak@ventanamicro.com> Co-developed-by: Anup Patel <apatel@ventanamicro.com> Signed-off-by: Anup Patel <apatel@ventanamicro.com>
2024-12-06lib: utils: Add simple FDT based MPXY driver frameworkAnup Patel8-0/+85
The generic platform can have multiple MPXY drivers so add a simple FDT based MPXY driver framework. Signed-off-by: Anup Patel <apatel@ventanamicro.com>
2024-12-06lib: sbi: Implement SBI MPXY extensionAnup Patel4-0/+84
Implement the SBI MPXY extension which provides an SBI interface to the supervisor software for send messages via MPXY framework. Signed-off-by: Rahul Pathak <rpathak@ventanamicro.com> Co-developed-by: Anup Patel <apatel@ventanamicro.com> Signed-off-by: Anup Patel <apatel@ventanamicro.com>
2024-12-06lib: sbi: Add SBI Message Proxy (MPXY) frameworkRahul Pathak7-7/+915
Introduce SBI Message Proxy (MPXY) framework which allows platform specific code or drivers to register message protocol specific channels. This framework enables the supervisor software to send messages belonging to different message protocols via OpenSBI firmware. Signed-off-by: Rahul Pathak <rpathak@ventanamicro.com> Co-developed-by: Himanshu Chauhan <hchauhan@ventanamicro.com> Signed-off-by: Himanshu Chauhan <hchauhan@ventanamicro.com> Co-developed-by: Anup Patel <apatel@ventanamicro.com> Signed-off-by: Anup Patel <apatel@ventanamicro.com>
2024-12-06lib: utils/cppc: Add RPMI CPPC driverSubrahmanya Lingappa5-0/+495
Add RPMI based driver for CPPC register read, write and probe. Signed-off-by: Subrahmanya Lingappa <slingappa@ventanamicro.com> Co-developed-by: Rahul Pathak <rpathak@ventanamicro.com> Signed-off-by: Rahul Pathak <rpathak@ventanamicro.com> Co-developed-by: Sunil V L <sunilvl@ventanamicro.com> Signed-off-by: Sunil V L <sunilvl@ventanamicro.com> Signed-off-by: Anup Patel <apatel@ventanamicro.com>
2024-12-06lib: utils: Add simple FDT based CPPC driver frameworkAnup Patel8-0/+77
The generic platform can have multiple CPPC drivers so add a simple FDT based CPPC driver framework. Signed-off-by: Anup Patel <apatel@ventanamicro.com>
2024-12-06lib: utils/hsm: Add RPMI HSM driverSubrahmanya Lingappa5-0/+467
The RPMI HSM service group provides set of routine to query and control power states of a Hart. Add RPMI based Hart State Management (HSM) driver. Signed-off-by: Subrahmanya Lingappa <slingappa@ventanamicro.com> Signed-off-by: Anup Patel <apatel@ventanamicro.com>
2024-12-06lib: utils: Add simple FDT based HSM driver frameworkAnup Patel8-0/+77
The generic platform can have multiple HSM drivers so add a simple FDT based HSM driver framework. Signed-off-by: Anup Patel <apatel@ventanamicro.com>
2024-12-06lib: utils/fdt: Allow dynamic registration of FDT fixup callbacksAnup Patel2-0/+48
It should possible to fixup FDT from any part of OpenSBI so add fdt_register_general_fixup() which allows dynamic registration of FDT fixup callbacks. Signed-off-by: Anup Patel <apatel@ventanamicro.com>
2024-12-06lib: sbi: Add optional resume address to hart suspendSubrahmanya Lingappa3-5/+9
Add an optional resume address to the platform specific hart suspend call. Signed-off-by: Subrahmanya Lingappa <slingappa@ventanamicro.com> Signed-off-by: Anup Patel <apatel@ventanamicro.com>
2024-12-06lib: utils/suspend: Add RPMI system suspend driverSubrahmanya Lingappa5-0/+186
Add RPMI based system suspend driver. To test this, execute the follwoing in Linux: $ echo mem > /sys/power/state To wake up, execute the following command on qemu monitor terminal: (qemu) system_wakeup Signed-off-by: Subrahmanya Lingappa <slingappa@ventanamicro.com> Signed-off-by: Anup Patel <apatel@ventanamicro.com>
2024-12-06lib: utils: Add simple FDT based system suspend driver frameworkAnup Patel8-0/+77
The generic platform can have multiple system suspend drivers so add a simple FDT based system suspend driver framework. Signed-off-by: Anup Patel <apatel@ventanamicro.com>
2024-12-06lib/utils: reset: Add RPMI System Reset driverRahul Pathak5-0/+177
Add RPMI based driver for system reset and enable it in the generic platform defconfig Signed-off-by: Rahul Pathak <rpathak@ventanamicro.com> Signed-off-by: Anup Patel <apatel@ventanamicro.com>
2024-12-06lib/utils: Add RPMI messaging protocol and shared memory transport supportRahul Pathak7-0/+1173
The RISC-V Platform Management Interface (RPMI) defines a messaging protocol and shared memory based transport for bi-directional communication with an on-chip or external microcontroller. To support RPMI in OpenSBI, add: 1) The RPMI messaging protocol defines and helper macros 2) A FDT mailbox driver for the RPMI shared memory transport Signed-off-by: Rahul Pathak <rpathak@ventanamicro.com> Co-developed-by: Subrahmanya Lingappa <slingappa@ventanamicro.com> Signed-off-by: Subrahmanya Lingappa <slingappa@ventanamicro.com> Co-developed-by: Anup Patel <apatel@ventanamicro.com> Signed-off-by: Anup Patel <apatel@ventanamicro.com>
2024-12-06lib: utils/mailbox: Add simple FDT based mailbox frameworkAnup Patel5-0/+145
Add a simple FDT based mailbox framework which is built on top of the generic mailbox library. The phandle of FDT mailbox DT node is treated as the unique mailbox controller ID which is required by the generic mailbox library. The FDT based mailbox drivers will be probed on-demand from fdt_mailbox_request_chan() called by the mailbox client drivers. Signed-off-by: Anup Patel <apatel@ventanamicro.com>
2024-12-06lib: utils/mailbox: Add generic mailbox libraryAnup Patel5-0/+339
Add generic mailbox library which is independent of hardware description format. The OpenSBI platform support or mailbox drivers can register mailbox controller instances which can be discovered and used by different mailbox client drivers. Each mailbox controller instance has a unique ID which can be used by mailbox client drivers for find the mailbox controller instance. The mailbox client drivers will typically request a mailbox channel from the mailbox controller and use it to do data transfer with the remote end of mailbox channel. Signed-off-by: Anup Patel <apatel@ventanamicro.com>
2024-12-06lib: Increase ROOT_REGION_MAX to accomodate more memregionsRahul Pathak1-1/+1
As more drivers adding memregions into root domain, the current static limit of ROOT_REGION_MAX is not sufficient. Increase the limit to accomodate more memregions. Signed-off-by: Rahul Pathak <rpathak@ventanamicro.com> Signed-off-by: Anup Patel <apatel@ventanamicro.com>
2024-12-02lib: sbi_pmu: Implement SBI PMU event info functionAtish Patra3-0/+81
Allow the supervisor software to query about the event using the new function. This supports both firmware and hardware events. The hardware event presence is verified hw_event_map which is populated via PMU device tree node. The firmware event presence is checked through event validation function which should take care of both standard and platform firmware events. Signed-off-by: Atish Patra <atishp@rivosinc.com> Reviewed-by: Anup Patel <anup@brainfault.org>
2024-12-02lib: sbi_pmu: Add SBI PMU event info function details.Atish Patra1-0/+9
The SBI v3.0 introduced a new function to query about the events without invoking CFG_MATCH. This allows supervisor software to identify which events are supported on the platform with single SBI call instead of a CFG_MATCH for each event. Signed-off-by: Atish Patra <atishp@rivosinc.com> Reviewed-by: Anup Patel <anup@brainfault.org>
2024-12-02lib: sbi_pmu: Remove redundant check for fw eventsAtish Patra1-5/+0
The pmu_validate_event already has the same check for fw events. The validate function is called prior to the current function to find a counter for firmware. That's why, the redudant check can be removed from the find counter function. Signed-off-by: Atish Patra <atishp@rivosinc.com> Reviewed-by: Anup Patel <anup@brainfault.org>
2024-12-02lib: sbi_pmu: PMU raw event v2 supportAtish Patra3-6/+12
As per the updated ISA specification and SBI PMU v3.0, lower 56 bits are available for the platform to implement mhpmeventX encoding. Implement the PMU raw event V2 support defined in SBI v3.0 which allows more bits for platforms to encode the raw events. Signed-off-by: Atish Patra <atishp@rivosinc.com> Reviewed-by: Anup Patel <anup@brainfault.org>
2024-12-01Makefile: Fix POSIX grep for multiple patternsIgor Melnikov1-2/+2
grep -e "-mstrict-align\|-mno-unaligned-access" makes use of GNU grep's backslash-escaped alternation operator \| which is available in basic regular expression syntax (BRE) mode. However, in POSIX grep's BRE mode | is an ordinary character which, when backslash-escaped, matches itself. Therefore, the search pattern becomes a plain string '-mstrict-align|-mno-unaligned-access' which obviously never matches the expected error and CC_SUPPORT_STRICT_ALIGN is always set to y. When cross-compiling with LLVM on amd64-unknown-openbsd7.6 host for riscv64-unknown-elf target this results in a compilation error: clang: error: unsupported option '-mno-unaligned-access' for target 'riscv64-unknown-elf' Using multiple -e options for this case maintains consistent behaviour across different grep implementations and fixes the issue. Signed-off-by: Igor Melnikov <imel@purelymail.com> Reviewed-by: Anup Patel <anup@brainfault.org>
2024-11-28lib: utils/timer: Use fdt_driver for initializationSamuel Holland5-45/+10
The timer driver subsystem does not need any extra data, so it can use `struct fdt_driver` directly. The generic fdt_timer_init() performs a best-effort initialization of all matching DT nodes. Signed-off-by: Samuel Holland <samuel.holland@sifive.com> Reviewed-by: Anup Patel <anup@brainfault.org>