Sapphire SoC DS Sapphire SoC UG Sapphire HP SoC DS Sapphire HP SoC UG RISC-V Embedded IDE UG Board Support Package
Loading...
Searching...
No Matches
irq.c
Go to the documentation of this file.
1
2// Copyright (C) 2013-2026 Efinix Inc. All rights reserved.
3// Full license header bsp/efinix/EfxSapphireSocRV64/include/LICENSE.MD
5
13
14#include <stdint.h>
15#include <stddef.h>
16#include "irq.h"
17
18
19/* ========================================================================== */
20/* EXTERNAL INTERRUPT FUNCTIONS (PLIC) */
21/* ========================================================================== */
22
29void irq_registerExt(u32 gateway, irq_handler_t handler)
30{
31 if (gateway < 64) {
32 interrupt_vector_table[gateway] = handler;
33 }
34}
35
36
37/* ========================================================================== */
38/* CORE INTERRUPT CONTROL (CSR Operations) */
39/* ========================================================================== */
40
46void irq_setTrapVector(void (*trap_vector)(void))
47{
48 /* Write direct address to mtvec (MODE bits assumed 0 or handled by caller) */
49 csr_write(mtvec, (unsigned long)trap_vector);
50}
51
56void irq_enable(void)
57{
58 /* Atomic Set Bit: csrs mstatus, MSTATUS_MIE */
59 csr_set(mstatus, MSTATUS_MIE);
60}
61
66void irq_disable(void)
67{
68 /* Atomic Clear Bit: csrc mstatus, MSTATUS_MIE */
69 csr_clear(mstatus, MSTATUS_MIE);
70}
71
77{
78 csr_set(mie, enable);
79}
80
86{
87 csr_clear(mie, disable);
88}
void irq_enable(void)
Enable Global Interrupts (MIE bit).
Definition irq.c:56
void irq_registerExt(u32 gateway, irq_handler_t handler)
Override the default external IRQ handler for a specific gateway.
Definition irq.c:29
void irq_setType(cpu_irq_t enable)
Enable specific CPU interrupt sources.
Definition irq.c:76
void irq_setTrapVector(void(*trap_vector)(void))
Set the Machine Trap Vector (mtvec).
Definition irq.c:46
void irq_clearType(cpu_irq_t disable)
Disable specific CPU interrupt sources.
Definition irq.c:85
void irq_disable(void)
Disable Global Interrupts (MIE bit).
Definition irq.c:66
int(* interrupt_vector_table[64])(void)
Global Interrupt Vector Table.
Definition mtrap.c:20
int(* irq_handler_t)(void)
Standard Interrupt Handler Function Pointer.
Definition irq.h:82
cpu_irq_t
CPU Interrupt Type (Standard RISC-V MIE bits).
Definition irq.h:95
#define csr_clear(csr, val)
This function is used to clear a CSR.
Definition riscv.h:263
#define csr_set(csr, val)
This function is used to set a CSR to a specified value.
Definition riscv.h:234
#define csr_write(csr, val)
This function is used to write a value to a CSR.
Definition riscv.h:205
RISC-V Core Interrupt Handling and Vector Table.
uint32_t u32
Definition type.h:22