embox

Форк
0
52 строки · 1.2 Кб
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

16
struct epic_regs {  
17
	volatile uint32_t MASK_EDGE_SET;        /* 0x00 */
18
	volatile uint32_t MASK_EDGE_CLEAR;      /* 0x04 */
19
	volatile uint32_t MASK_LEVEL_SET;       /* 0x08 */
20
	volatile uint32_t MASK_LEVEL_CLEAR;     /* 0x0C */
21
	volatile uint32_t reserved[2];
22
	volatile uint32_t CLEAR;                /* 0x18 */
23
	volatile uint32_t STATUS;               /* 0x1C */
24
	volatile 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

31
static int epic_init(void) {
32
	enable_external_interrupts();
33
	return 0;
34
}
35

36
void irqctrl_enable(unsigned int interrupt_nr) {
37
	EPIC_REGS->MASK_EDGE_SET |= (1U << interrupt_nr);
38
}
39

40
void irqctrl_disable(unsigned int interrupt_nr) {
41
	EPIC_REGS->MASK_EDGE_CLEAR |= (1U << interrupt_nr);
42
}
43

44
void irqctrl_eoi(unsigned int irq) {
45
	EPIC_REGS->CLEAR |= (1U << irq);
46
}
47

48
unsigned int irqctrl_get_intid(void) {
49
	return EPIC_REGS->RAW_STATUS;
50
}
51

52
IRQCTRL_DEF(mikron_epic, epic_init);
53

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.