embox
1/**
2* @file
3*
4* @date 11.07.10
5* @author Anton Kozlov
6*/
7
8#include <assert.h>9#include <stdint.h>10
11#include <asm/interrupts.h>12#include <drivers/irqctrl.h>13
14#include <framework/mod/options.h>15
16struct epic_regs {17volatile uint32_t MASK_EDGE_SET; /* 0x00 */18volatile uint32_t MASK_EDGE_CLEAR; /* 0x04 */19volatile uint32_t MASK_LEVEL_SET; /* 0x08 */20volatile uint32_t MASK_LEVEL_CLEAR; /* 0x0C */21volatile uint32_t reserved[2];22volatile uint32_t CLEAR; /* 0x18 */23volatile uint32_t STATUS; /* 0x1C */24volatile uint32_t RAW_STATUS; /* 0x20 */25};26
27#define BASE_ADDR OPTION_GET(NUMBER, base_addr)28
29#define EPIC_REGS ((struct epic_regs *)(uintptr_t)(BASE_ADDR))30
31static int epic_init(void) {32enable_external_interrupts();33return 0;34}
35
36void irqctrl_enable(unsigned int interrupt_nr) {37EPIC_REGS->MASK_EDGE_SET |= (1U << interrupt_nr);38}
39
40void irqctrl_disable(unsigned int interrupt_nr) {41EPIC_REGS->MASK_EDGE_CLEAR |= (1U << interrupt_nr);42}
43
44void irqctrl_eoi(unsigned int irq) {45EPIC_REGS->CLEAR |= (1U << irq);46}
47
48unsigned int irqctrl_get_intid(void) {49return EPIC_REGS->RAW_STATUS;50}
51
52IRQCTRL_DEF(mikron_epic, epic_init);53