os-core/kernel/leos/irq.c

84 lines
1.4 KiB
C
Raw Normal View History

2019-12-01 22:57:02 +01:00
/******************************************************************************
*
* Copyright (c) 2017-2019 by Löwenware Ltd
* Please, refer LICENSE file for legal information
*
******************************************************************************/
/**
* @file irq.c
* @author Ilja Kartašov <ik@lowenware.com>
* @brief
*
* @see https://lowenware.com/
*/
2020-01-17 10:13:01 +01:00
#include <drivers/soc/bcm2837/bcm2837.h>
#include <drivers/timer/timer.h>
2019-12-01 22:57:02 +01:00
#include "log.h"
2020-01-15 10:56:04 +01:00
#include "task.h"
2019-12-01 22:57:02 +01:00
#include "irq.h"
static const char *m_types[] = {
"EL1t_SYNC",
"EL1t_IRQ",
"EL1t_FIQ",
"EL1t_ERROR",
"EL1h_SYNC",
"EL1h_IRQ",
"EL1h_FIQ",
"EL1h_ERROR",
"EL0_64_SYNC",
"EL0_64_IRQ",
"EL0_64_FIQ",
"EL0_64_ERROR",
"EL0_32_SYNC",
"EL0_32_IRQ",
"EL0_32_FIQ",
"EL0_32_ERROR"
};
2020-01-15 10:56:04 +01:00
2020-01-29 12:01:32 +01:00
static void
2020-01-15 10:56:04 +01:00
IRQ_onTimerInterrupt(void)
2019-12-01 22:57:02 +01:00
{
2020-01-15 10:56:04 +01:00
Timer_incFromISR();
2020-01-29 12:01:32 +01:00
Task_scheduleFromISR();
2019-12-01 22:57:02 +01:00
}
void
2020-01-15 10:56:04 +01:00
IRQ_init()
2019-12-01 22:57:02 +01:00
{
2020-01-15 10:56:04 +01:00
AArch64_setReg32(ENABLE_IRQS_1, SYSTEM_TIMER_IRQ_1);
}
2020-01-29 12:01:32 +01:00
void
2020-01-15 10:56:04 +01:00
IRQ_onInterrupt(void)
{
unsigned int irq = AArch64_getReg32(IRQ_PENDING_1);
2019-12-01 22:57:02 +01:00
switch(irq) {
2020-01-29 12:01:32 +01:00
#if CONFIG_ARM_TIMER == 1
case LOCAL_TIMER_IRQ:
2020-01-29 12:01:32 +01:00
#endif
2019-12-01 22:57:02 +01:00
case SYSTEM_TIMER_IRQ_1:
2020-01-15 10:56:04 +01:00
return IRQ_onTimerInterrupt();
2019-12-01 22:57:02 +01:00
default:
2020-01-15 10:56:04 +01:00
Log_putS("Unhandled irq: ");
Log_putU(irq, 16);
Log_putS("\n");
2019-12-01 22:57:02 +01:00
}
}
void
2020-01-15 10:56:04 +01:00
IRQ_fallback(int type, unsigned long esr, unsigned long address)
2019-12-01 22:57:02 +01:00
{
2020-01-15 10:56:04 +01:00
Log_putS(m_types[type]);
Log_putS(" -> ESR: ");
Log_putU(esr, 16);
Log_putS(", address: ");
Log_putU(address, 16);
Log_putS("\r\n");
2019-12-01 22:57:02 +01:00
}