Draft: lab 3 irq wtf
This commit is contained in:
58
kernel/lib/interrupt.c
Normal file
58
kernel/lib/interrupt.c
Normal file
@@ -0,0 +1,58 @@
|
||||
#include <interrupt.h>
|
||||
#include <utils.h>
|
||||
#include <logger.h>
|
||||
#include <errcode.h>
|
||||
|
||||
void init_interrupt(void)
|
||||
{
|
||||
uint64_t cntfrq_el0;
|
||||
R_SYSREG(cntfrq_el0, cntfrq_el0);
|
||||
W_SYSREG(cntp_tval_el0, cntfrq_el0);
|
||||
|
||||
*CORE0_TIMER_IRQ_CTRL = 0x2;
|
||||
}
|
||||
|
||||
static inline
|
||||
void _uart_irq_handler(void)
|
||||
{
|
||||
DEBUG_EXCEP("uart irq");
|
||||
}
|
||||
|
||||
static inline
|
||||
void _timer_irq_handler(void)
|
||||
{
|
||||
LOG("timer irq");
|
||||
|
||||
uint64_t cntpct_el0;
|
||||
R_SYSREG(cntpct_el0, cntpct_el0);
|
||||
DEBUG_EXCEP(cntpct_el0);
|
||||
|
||||
uint64_t cntfrq_el0;
|
||||
R_SYSREG(cntfrq_el0, cntfrq_el0);
|
||||
W_SYSREG(cntp_tval_el0, cntfrq_el0);
|
||||
}
|
||||
|
||||
void irq_handler(void)
|
||||
{
|
||||
LOG("irq caught");
|
||||
uint64_t irq_source = *CORE0_IRQ_SOURCE;
|
||||
DEBUG_EXCEP(irq_source);
|
||||
|
||||
*CORE0_TIMER_IRQ_CTRL = 0x0;
|
||||
if (irq_source & GPU_INT)
|
||||
_uart_irq_handler();
|
||||
if (irq_source & CNTPNSIRQ_INT)
|
||||
_timer_irq_handler();
|
||||
|
||||
*CORE0_TIMER_IRQ_CTRL = 0x2;
|
||||
}
|
||||
|
||||
void enable_interrupt(void)
|
||||
{
|
||||
asm volatile("msr DAIFClr, 0xf");
|
||||
}
|
||||
|
||||
void disable_interrupt(void)
|
||||
{
|
||||
asm volatile("msr DAIFSet, 0xf");
|
||||
}
|
||||
Reference in New Issue
Block a user