![]() |
NMSIS-Core
Version 1.4.0
NMSIS-Core support for Nuclei processor-based devices
|
Functions for interrupt, exception and nmi handle available in system_<device>.c. More...
Macros | |
#define | MAX_SYSTEM_EXCEPTION_NUM 20 |
Max exception handler number, don't include the NMI(0xFFF) one. More... | |
#define | SYSTEM_CORE_INTNUM 16 |
Typedefs | |
typedef void(* | EXC_HANDLER) (unsigned long cause, unsigned long sp) |
Exception Handler Function Typedef. More... | |
typedef void(* | INT_HANDLER) (unsigned long cause, unsigned long sp) |
Functions | |
static void | system_mmode_extirq_handler (unsigned long exccode, unsigned long sp) |
M-Mode external interrupt handler common entry for plic interrupt mode. More... | |
static void | core_interrupt_handler (unsigned long exccode, unsigned long sp) |
M-Mode Common Interrupt handler entry when in clint/plic mode. More... | |
uint32_t | core_exception_handler (unsigned long mcause, unsigned long sp) |
M-Mode Common NMI/Exception/Interrupt handler entry. More... | |
static void | system_default_interrupt_handler_s (unsigned long scause, unsigned long sp) |
s-mode System Default Interrupt Handler for CLINT/PLIC Interrupt Mode More... | |
static void | system_smode_extirq_handler (unsigned long exccode, unsigned long sp) |
S-Mode external interrupt handler common entry for plic interrupt mode. More... | |
static void | core_interrupt_handler_s (unsigned long exccode, unsigned long sp) |
S-Mode Common Interrupt handler entry when in clint/plic mode. More... | |
void | Exception_DumpFrame (unsigned long sp, uint8_t mode) |
Dump Exception Frame. More... | |
static void | system_default_interrupt_handler (unsigned long mcause, unsigned long sp) |
M-Mode System Default Interrupt Handler for CLINT/PLIC Interrupt Mode. More... | |
void | Interrupt_Register_CoreIRQ (uint32_t irqn, unsigned long int_handler) |
Register a m-mode core interrupt handler for core interrupt number. More... | |
unsigned long | Interrupt_Get_CoreIRQ (uint32_t irqn) |
Get a m-mode core interrupt handler for core interrupt number. More... | |
void | Interrupt_Register_ExtIRQ (uint32_t irqn, unsigned long int_handler) |
Register a m-mode external interrupt handler for plic external interrupt number. More... | |
unsigned long | Interrupt_Get_ExtIRQ (uint32_t irqn) |
Get a m-mode external interrupt handler for external interrupt number. More... | |
void | Exception_Register_EXC (uint32_t EXCn, unsigned long exc_handler) |
Register a m-mode exception handler for exception code EXCn. More... | |
unsigned long | Exception_Get_EXC (uint32_t EXCn) |
Get current m-mode exception handler for exception code EXCn. More... | |
static void | Exception_Init (void) |
Initialize all the default core exception handlers. More... | |
uint32_t | core_exception_handler_s (unsigned long scause, unsigned long sp) |
common Exception handler entry of supervisor mode More... | |
void | Exception_Register_EXC_S (uint32_t EXCn, unsigned long exc_handler) |
Register an exception handler for exception code EXCn of supervisor mode. More... | |
unsigned long | Exception_Get_EXC_S (uint32_t EXCn) |
Get current exception handler for exception code EXCn of supervisor mode. More... | |
void | Interrupt_Register_CoreIRQ_S (uint32_t irqn, unsigned long int_handler) |
Register an s-mode core interrupt handler for core interrupt number. More... | |
unsigned long | Interrupt_Get_CoreIRQ_S (uint32_t irqn) |
Get a s-mode core interrupt handler for core interrupt number. More... | |
void | Interrupt_Register_ExtIRQ_S (uint32_t irqn, unsigned long int_handler) |
Register an s-mode external interrupt handler for plic external interrupt number. More... | |
unsigned long | Interrupt_Get_ExtIRQ_S (uint32_t irqn) |
Get an s-mode external interrupt handler for external interrupt number. More... | |
static void | system_default_exception_handler (unsigned long mcause, unsigned long sp) |
M-Mode System Default Exception Handler. More... | |
static void | system_default_exception_handler_s (unsigned long scause, unsigned long sp) |
Supervisor mode system Default Exception Handler. More... | |
Variables | |
static unsigned long | SystemExceptionHandlers [MAX_SYSTEM_EXCEPTION_NUM+1] |
Store the exception handlers for each exception ID. More... | |
static unsigned long | SystemMExtInterruptHandlers [__PLIC_INTNUM] |
static unsigned long | SystemCoreInterruptHandlers [SYSTEM_CORE_INTNUM] |
static INT_HANDLER | system_core_interrupt_handler = NULL |
static unsigned long | SystemExceptionHandlers_S [MAX_SYSTEM_EXCEPTION_NUM] |
Store the exception handlers for each exception ID in supervisor mode. More... | |
static INT_HANDLER | system_core_interrupt_handler_s = NULL |
static unsigned long | SystemCoreInterruptHandlers_S [SYSTEM_CORE_INTNUM] |
static unsigned long | SystemSExtInterruptHandlers [__PLIC_INTNUM] |
Functions for interrupt, exception and nmi handle available in system_<device>.c.
Nuclei provide a template for interrupt, exception and NMI handling. Silicon Vendor could adapat according to their requirement. Silicon vendor could implement interface for different exception code and replace current implementation.
#define MAX_SYSTEM_EXCEPTION_NUM 20 |
Max exception handler number, don't include the NMI(0xFFF) one.
Definition at line 243 of file system_Device.c.
#define SYSTEM_CORE_INTNUM 16 |
Definition at line 258 of file system_Device.c.
typedef void(* EXC_HANDLER) (unsigned long cause, unsigned long sp) |
Exception Handler Function Typedef.
Definition at line 239 of file system_Device.c.
typedef void(* INT_HANDLER) (unsigned long cause, unsigned long sp) |
Definition at line 240 of file system_Device.c.
uint32_t core_exception_handler | ( | unsigned long | mcause, |
unsigned long | sp | ||
) |
M-Mode Common NMI/Exception/Interrupt handler entry.
This function provided a command entry for NMI and exception. Silicon Vendor could modify this template implementation according to requirement.
[in] | mcause | code indicating the reason that caused the trap in machine mode |
[in] | sp | stack pointer |
Definition at line 406 of file system_Device.c.
References MAX_SYSTEM_EXCEPTION_NUM, MCAUSE_CAUSE, MCAUSE_INTR, system_core_interrupt_handler, system_default_exception_handler(), and SystemExceptionHandlers.
uint32_t core_exception_handler_s | ( | unsigned long | scause, |
unsigned long | sp | ||
) |
common Exception handler entry of supervisor mode
This function provided a supervisor mode common entry for exception. Silicon Vendor could modify this template implementation according to requirement.
[in] | scause | code indicating the reason that caused the trap in supervisor mode |
[in] | sp | stack pointer |
Definition at line 704 of file system_Device.c.
References MAX_SYSTEM_EXCEPTION_NUM, MCAUSE_INTR, SCAUSE_CAUSE, system_core_interrupt_handler_s, system_default_exception_handler_s(), and SystemExceptionHandlers_S.
|
static |
M-Mode Common Interrupt handler entry when in clint/plic mode.
This function provided a command entry for interrupt in clint/plic mode
[in] | exccode | Exception Code |
[in] | sp | stack pointer |
Definition at line 381 of file system_Device.c.
References SystemCoreInterruptHandlers.
Referenced by CLINT_Interrupt_Init().
|
static |
S-Mode Common Interrupt handler entry when in clint/plic mode.
This function provided a command entry for interrupt in clint/plic mode
[in] | exccode | Exception Code |
[in] | sp | stack pointer |
Definition at line 658 of file system_Device.c.
References SystemCoreInterruptHandlers_S.
Referenced by CLINT_Interrupt_Init().
void Exception_DumpFrame | ( | unsigned long | sp, |
uint8_t | mode | ||
) |
Dump Exception Frame.
This function provided feature to dump exception frame stored in stack.
[in] | sp | stackpoint |
[in] | mode | privileged mode to decide whether to dump msubm CSR |
Definition at line 294 of file system_Device.c.
References PRV_M.
Referenced by system_default_exception_handler(), and system_default_exception_handler_s().
unsigned long Exception_Get_EXC | ( | uint32_t | EXCn | ) |
Get current m-mode exception handler for exception code EXCn.
[in] | EXCn | See EXCn_Type |
Definition at line 559 of file system_Device.c.
References MAX_SYSTEM_EXCEPTION_NUM, and SystemExceptionHandlers.
unsigned long Exception_Get_EXC_S | ( | uint32_t | EXCn | ) |
Get current exception handler for exception code EXCn of supervisor mode.
[in] | EXCn | See EXCn_Type |
Definition at line 758 of file system_Device.c.
References MAX_SYSTEM_EXCEPTION_NUM, and SystemExceptionHandlers_S.
|
static |
Initialize all the default core exception handlers.
The core exception handler for each exception id will be initialized to system_default_exception_handler.
Definition at line 582 of file system_Device.c.
References MAX_SYSTEM_EXCEPTION_NUM, system_default_exception_handler(), system_default_exception_handler_s(), SystemExceptionHandlers, and SystemExceptionHandlers_S.
Referenced by _premain_init().
void Exception_Register_EXC | ( | uint32_t | EXCn, |
unsigned long | exc_handler | ||
) |
Register a m-mode exception handler for exception code EXCn.
[in] | EXCn | See EXCn_Type |
[in] | exc_handler | The exception handler for this exception code EXCn |
Definition at line 538 of file system_Device.c.
References MAX_SYSTEM_EXCEPTION_NUM, and SystemExceptionHandlers.
void Exception_Register_EXC_S | ( | uint32_t | EXCn, |
unsigned long | exc_handler | ||
) |
Register an exception handler for exception code EXCn of supervisor mode.
-For EXCn < MAX_SYSTEM_EXCEPTION_NUM, it will be registered into SystemExceptionHandlers_S[EXCn-1]. -For EXCn == NMI_EXCn, The NMI (Non-maskable-interrupt) cannot be trapped to the supervisor-mode or user-mode for any configuration, so NMI won't be registered into SystemExceptionHandlers_S.
[in] | EXCn | See EXCn_Type |
[in] | exc_handler | The exception handler for this exception code EXCn |
Definition at line 741 of file system_Device.c.
References MAX_SYSTEM_EXCEPTION_NUM, and SystemExceptionHandlers_S.
unsigned long Interrupt_Get_CoreIRQ | ( | uint32_t | irqn | ) |
Get a m-mode core interrupt handler for core interrupt number.
irqn | See IRQn |
Definition at line 485 of file system_Device.c.
References SYSTEM_CORE_INTNUM, and SystemCoreInterruptHandlers.
unsigned long Interrupt_Get_CoreIRQ_S | ( | uint32_t | irqn | ) |
Get a s-mode core interrupt handler for core interrupt number.
irqn | See IRQn |
Definition at line 795 of file system_Device.c.
References SYSTEM_CORE_INTNUM, and SystemCoreInterruptHandlers_S.
unsigned long Interrupt_Get_ExtIRQ | ( | uint32_t | irqn | ) |
Get a m-mode external interrupt handler for external interrupt number.
irqn | See IRQn |
Definition at line 519 of file system_Device.c.
References SystemMExtInterruptHandlers.
unsigned long Interrupt_Get_ExtIRQ_S | ( | uint32_t | irqn | ) |
Get an s-mode external interrupt handler for external interrupt number.
irqn | See IRQn |
Definition at line 831 of file system_Device.c.
References SystemSExtInterruptHandlers.
void Interrupt_Register_CoreIRQ | ( | uint32_t | irqn, |
unsigned long | int_handler | ||
) |
Register a m-mode core interrupt handler for core interrupt number.
irqn | See IRQn |
int_handler | The core interrupt handler for this interrupt code irqn |
Definition at line 470 of file system_Device.c.
References SYSTEM_CORE_INTNUM, and SystemCoreInterruptHandlers.
Referenced by Core_Register_IRQ().
void Interrupt_Register_CoreIRQ_S | ( | uint32_t | irqn, |
unsigned long | int_handler | ||
) |
Register an s-mode core interrupt handler for core interrupt number.
irqn | See IRQn |
int_handler | The core interrupt handler for this interrupt code irqn |
Definition at line 780 of file system_Device.c.
References SYSTEM_CORE_INTNUM, and SystemCoreInterruptHandlers_S.
Referenced by Core_Register_IRQ_S().
void Interrupt_Register_ExtIRQ | ( | uint32_t | irqn, |
unsigned long | int_handler | ||
) |
Register a m-mode external interrupt handler for plic external interrupt number.
irqn | See IRQn |
int_handler | The external interrupt handler for this interrupt code irqn |
Definition at line 502 of file system_Device.c.
References SystemMExtInterruptHandlers.
Referenced by PLIC_Register_IRQ().
void Interrupt_Register_ExtIRQ_S | ( | uint32_t | irqn, |
unsigned long | int_handler | ||
) |
Register an s-mode external interrupt handler for plic external interrupt number.
irqn | See IRQn |
int_handler | The external interrupt handler for this interrupt code irqn |
Definition at line 812 of file system_Device.c.
References SystemSExtInterruptHandlers.
Referenced by PLIC_Register_IRQ_S().
|
static |
M-Mode System Default Exception Handler.
This function provides a default exception and NMI handler for all exception ids. By default, It will just print some information for debug, Vendor can customize it according to its requirements.
[in] | mcause | code indicating the reason that caused the trap in machine mode |
[in] | sp | stack pointer |
Definition at line 331 of file system_Device.c.
References __get_hart_id(), __RV_CSR_READ, CSR_MDCAUSE, CSR_MEPC, CSR_MTVAL, Exception_DumpFrame(), and PRV_M.
Referenced by core_exception_handler(), and Exception_Init().
|
static |
Supervisor mode system Default Exception Handler.
This function provided a default supervisor mode exception and NMI handling code for all exception ids. By default, It will just print some information for debug, Vendor can customize it according to its requirements.
[in] | scause | code indicating the reason that caused the trap in supervisor mode |
[in] | sp | stack pointer |
Definition at line 609 of file system_Device.c.
References __RV_CSR_READ, CSR_SDCAUSE, CSR_SEPC, CSR_STVAL, Exception_DumpFrame(), and PRV_S.
Referenced by core_exception_handler_s(), and Exception_Init().
|
static |
M-Mode System Default Interrupt Handler for CLINT/PLIC Interrupt Mode.
This function provided a default interrupt handling code for all interrupt ids.
Definition at line 357 of file system_Device.c.
References __RV_CSR_READ, CSR_MEPC, and CSR_MTVAL.
Referenced by CLINT_Interrupt_Init(), and PLIC_Interrupt_Init().
|
static |
s-mode System Default Interrupt Handler for CLINT/PLIC Interrupt Mode
This function provided a default interrupt handling code for all interrupt ids.
Definition at line 634 of file system_Device.c.
References __RV_CSR_READ, CSR_SEPC, and CSR_STVAL.
Referenced by CLINT_Interrupt_Init(), and PLIC_Interrupt_Init().
|
static |
M-Mode external interrupt handler common entry for plic interrupt mode.
This function provide common entry for m-mode external interrupt for plic interrupt mode.
[in] | exccode | exception code indicating the reason that caused the trap in machine mode |
[in] | sp | stack pointer |
Definition at line 446 of file system_Device.c.
References PLIC_ClaimInterrupt, PLIC_CompleteInterrupt, and SystemMExtInterruptHandlers.
Referenced by PLIC_Interrupt_Init().
|
static |
S-Mode external interrupt handler common entry for plic interrupt mode.
This function provide common entry for s-mode external interrupt for plic interrupt mode.
[in] | exccode | exception code indicating the reason that caused the trap in supervisor mode |
[in] | sp | stack pointer |
Definition at line 676 of file system_Device.c.
References PLIC_ClaimInterrupt_S, PLIC_CompleteInterrupt_S, and SystemSExtInterruptHandlers.
Referenced by PLIC_Interrupt_Init().
|
static |
Definition at line 265 of file system_Device.c.
Referenced by CLINT_Interrupt_Init(), and core_exception_handler().
|
static |
Definition at line 280 of file system_Device.c.
Referenced by CLINT_Interrupt_Init(), and core_exception_handler_s().
|
static |
Definition at line 262 of file system_Device.c.
Referenced by CLINT_Interrupt_Init(), core_interrupt_handler(), Interrupt_Get_CoreIRQ(), Interrupt_Register_CoreIRQ(), and PLIC_Interrupt_Init().
|
static |
Definition at line 281 of file system_Device.c.
Referenced by CLINT_Interrupt_Init(), core_interrupt_handler_s(), Interrupt_Get_CoreIRQ_S(), Interrupt_Register_CoreIRQ_S(), and PLIC_Interrupt_Init().
|
static |
Store the exception handlers for each exception ID.
Definition at line 252 of file system_Device.c.
Referenced by core_exception_handler(), Exception_Get_EXC(), Exception_Init(), and Exception_Register_EXC().
|
static |
Store the exception handlers for each exception ID in supervisor mode.
Definition at line 275 of file system_Device.c.
Referenced by core_exception_handler_s(), Exception_Get_EXC_S(), Exception_Init(), and Exception_Register_EXC_S().
|
static |
Definition at line 255 of file system_Device.c.
Referenced by Interrupt_Get_ExtIRQ(), Interrupt_Register_ExtIRQ(), PLIC_Interrupt_Init(), and system_mmode_extirq_handler().
|
static |
Definition at line 283 of file system_Device.c.
Referenced by Interrupt_Get_ExtIRQ_S(), Interrupt_Register_ExtIRQ_S(), PLIC_Interrupt_Init(), and system_smode_extirq_handler().