aboutsummaryrefslogtreecommitdiffhomepage
path: root/source/Core/BSP/Pinecilv2/bl_irq.c
blob: b8cda6f90d261b2d722adc3c314e524b257685ae (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include "bl_irq.h"

extern pFunc __Interrupt_Handlers[IRQn_LAST];

void bl_irq_enable(unsigned int source) { *(volatile uint8_t *)(CLIC_HART0_ADDR + CLIC_INTIE + source) = 1; }

void bl_irq_disable(unsigned int source) { *(volatile uint8_t *)(CLIC_HART0_ADDR + CLIC_INTIE + source) = 0; }

void bl_irq_pending_set(unsigned int source) { *(volatile uint8_t *)(CLIC_HART0_ADDR + CLIC_INTIP + source) = 1; }

void bl_irq_pending_clear(unsigned int source) { *(volatile uint8_t *)(CLIC_HART0_ADDR + CLIC_INTIP + source) = 0; }

void bl_irq_register(int irqnum, void *handler) {
  if (irqnum < IRQn_LAST) {
    __Interrupt_Handlers[irqnum] = handler;
  }
}

void bl_irq_unregister(int irqnum, void *handler) {
  if (irqnum < IRQn_LAST) {
    __Interrupt_Handlers[irqnum] = NULL;
  }
}

void bl_irq_handler_get(int irqnum, void **handler) {
  if (irqnum < IRQn_LAST) {
    *handler = __Interrupt_Handlers[irqnum];
  }
}