mirror of
https://github.com/riscv-software-src/opensbi.git
synced 2025-08-24 15:31:22 +01:00

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>
37 lines
970 B
C
37 lines
970 B
C
/*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*
|
|
* Copyright (c) 2024 Rivos Inc.
|
|
*
|
|
* Authors:
|
|
* Clément Léger <clement.leger@rivosinc.com>
|
|
*/
|
|
|
|
#include <sbi/sbi_console.h>
|
|
#include <sbi/sbi_ecall_interface.h>
|
|
#include <sbi/sbi_error.h>
|
|
#include <sbi/sbi_hart.h>
|
|
#include <sbi/sbi_sse.h>
|
|
#include <sbi/sbi_trap.h>
|
|
|
|
int sbi_double_trap_handler(struct sbi_trap_context *tcntx)
|
|
{
|
|
struct sbi_trap_regs *regs = &tcntx->regs;
|
|
const struct sbi_trap_info *trap = &tcntx->trap;
|
|
bool prev_virt = sbi_regs_from_virt(regs);
|
|
|
|
if (sbi_mstatus_prev_mode(regs->mstatus) != PRV_S)
|
|
return SBI_ERR_INVALID_PARAM;
|
|
|
|
/* Exception was taken in VS-mode, redirect it to S-mode */
|
|
if (prev_virt)
|
|
return sbi_trap_redirect(regs, trap);
|
|
|
|
return sbi_sse_inject_event(SBI_SSE_EVENT_LOCAL_DOUBLE_TRAP);
|
|
}
|
|
|
|
void sbi_double_trap_init(struct sbi_scratch *scratch)
|
|
{
|
|
if (sbi_hart_has_extension(scratch, SBI_HART_EXT_SSDBLTRP))
|
|
sbi_sse_add_event(SBI_SSE_EVENT_LOCAL_DOUBLE_TRAP, NULL);
|
|
} |