46 lines
1015 B
C
46 lines
1015 B
C
#include <interrupt.h>
|
|
#include <uart.h>
|
|
#include <timer.h>
|
|
#include <utils.h>
|
|
#include <logger.h>
|
|
#include <errcode.h>
|
|
|
|
#define CORE0_TIMER_IRQ_CTRL ((volatile uint32_t *)0x40000040)
|
|
#define CORE0_IRQ_SOURCE ((volatile uint32_t *)0x40000060)
|
|
|
|
static inline
|
|
void _enable_interrupt(void)
|
|
{ W_SYSREG_IMM(DAIFClr, 0xf); }
|
|
|
|
static inline
|
|
void _disable_interrupt(void)
|
|
{ W_SYSREG_IMM(DAIFSet, 0xf); }
|
|
|
|
MMIO_W_HELPER(_enable_timer_irq, CORE0_TIMER_IRQ_CTRL, 0x1, 1);
|
|
|
|
MMIO_R_HELPER(_irq_source_timer, CORE0_IRQ_SOURCE, 0x1, 1);
|
|
MMIO_R_HELPER(_irq_source_uart, CORE0_IRQ_SOURCE, 0x1, 8);
|
|
|
|
void init_interrupt(void)
|
|
{
|
|
uint64_t cntfrq_el0;
|
|
W_SYSREG(cntp_ctl_el0, 1);
|
|
R_SYSREG(cntfrq_el0, cntfrq_el0);
|
|
W_SYSREG(cntp_tval_el0, cntfrq_el0);
|
|
|
|
_enable_timer_irq(true);
|
|
_enable_interrupt();
|
|
}
|
|
|
|
void irq_handler(void)
|
|
{
|
|
// uint64_t core0_irq_source = *CORE0_IRQ_SOURCE;
|
|
// DEBUG_EXCEP(core0_irq_source);
|
|
|
|
if (_irq_source_timer())
|
|
timer_irq_handler();
|
|
|
|
if (_irq_source_uart())
|
|
uart_irq_handler();
|
|
}
|