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

Rather than registering all extensions on their behalf in sbi_ecall_init(), introduce another extension callback and invoke that instead. For now, implement each callback by simply registering the extension, which means this patch has no intended functional change. In later patches, extension callbacks will be modified to choose when to register and to possibly narrow the extension ID range prior to registering. When an extension range needs to remove IDs, leaving gaps, then multiple invocations of sbi_ecall_register_extension() may be used. In summary, later patches for current extensions and the introductions of future extensions will use the new callback to ensure that only valid extension IDs from the initial range, which are also available, will be registered. Signed-off-by: Andrew Jones <ajones@ventanamicro.com> Reviewed-by: Anup Patel <anup@brainfault.org>
45 lines
1.0 KiB
C
45 lines
1.0 KiB
C
/*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*
|
|
* Copyright (c) 2020 Western Digital Corporation or its affiliates.
|
|
*
|
|
* Authors:
|
|
* Anup Patel <anup.patel@wdc.com>
|
|
* Atish Patra <atish.patra@wdc.com>
|
|
*/
|
|
|
|
#include <sbi/sbi_error.h>
|
|
#include <sbi/sbi_ecall.h>
|
|
#include <sbi/sbi_ecall_interface.h>
|
|
#include <sbi/sbi_trap.h>
|
|
#include <sbi/sbi_ipi.h>
|
|
|
|
static int sbi_ecall_ipi_handler(unsigned long extid, unsigned long funcid,
|
|
const struct sbi_trap_regs *regs,
|
|
unsigned long *out_val,
|
|
struct sbi_trap_info *out_trap)
|
|
{
|
|
int ret = 0;
|
|
|
|
if (funcid == SBI_EXT_IPI_SEND_IPI)
|
|
ret = sbi_ipi_send_smode(regs->a0, regs->a1);
|
|
else
|
|
ret = SBI_ENOTSUPP;
|
|
|
|
return ret;
|
|
}
|
|
|
|
struct sbi_ecall_extension ecall_ipi;
|
|
|
|
static int sbi_ecall_ipi_register_extensions(void)
|
|
{
|
|
return sbi_ecall_register_extension(&ecall_ipi);
|
|
}
|
|
|
|
struct sbi_ecall_extension ecall_ipi = {
|
|
.extid_start = SBI_EXT_IPI,
|
|
.extid_end = SBI_EXT_IPI,
|
|
.register_extensions = sbi_ecall_ipi_register_extensions,
|
|
.handle = sbi_ecall_ipi_handler,
|
|
};
|