embox
69 строк · 1.3 Кб
1/**
2* @file
3*
4* @date 05 aug 2015
5* @author: Anton Bondarev
6*/
7#include <assert.h>8#include <stdint.h>9#include <sys/mman.h>10
11#include <drivers/common/memory.h>12#include <drivers/irqctrl.h>13#include <hal/ipl.h>14#include <hal/reg.h>15#include <kernel/critical.h>16#include <kernel/irq.h>17#include <kernel/printk.h>18
19#define ICU_BASE 0x1400000020/* Registers for interrupt control unit - enable/flag/master */
21#define ICU_IRQSTS (ICU_BASE + 0x00)22#define ICU_IRQENSET (ICU_BASE + 0x08)23#define ICU_IRQENCLR (ICU_BASE + 0x0C)24
25/**
26* Initialize the PIC
27*/
28static int integrator_pic_init(void) {29REG32_STORE(ICU_IRQENCLR, ((1 << IRQCTRL_IRQS_TOTAL) - 1));30return 0;31}
32
33void irqctrl_enable(unsigned int irq) {34REG32_ORIN(ICU_IRQENSET, 1 << irq);35}
36
37void irqctrl_disable(unsigned int irq) {38REG32_STORE(ICU_IRQENCLR, 1 << irq);39}
40
41void irqctrl_force(unsigned int irq) {42}
43
44int irqctrl_pending(unsigned int irq) {45return 0;46}
47
48/* Sends an EOI (end of interrupt) signal to the PICs. */
49void irqctrl_eoi(unsigned int irq) {50}
51
52unsigned int irqctrl_get_intid(void) {53unsigned int stat;54unsigned int irq;55
56stat = REG32_LOAD(ICU_IRQSTS);57
58for (irq = 0; irq < IRQCTRL_IRQS_TOTAL; irq++) {59if (stat & (uint32_t)(1 << irq)) {60return irq;61}62}63
64return -1;65}
66
67IRQCTRL_DEF(integrator_pic, integrator_pic_init);68
69PERIPH_MEMORY_DEFINE(icu, ICU_BASE, 0x10);70