embox

Форк
0
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     0x14000000
20
/* 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
 */
28
static int integrator_pic_init(void) {
29
	REG32_STORE(ICU_IRQENCLR, ((1 << IRQCTRL_IRQS_TOTAL) - 1));
30
	return 0;
31
}
32

33
void irqctrl_enable(unsigned int irq) {
34
	REG32_ORIN(ICU_IRQENSET, 1 << irq);
35
}
36

37
void irqctrl_disable(unsigned int irq) {
38
	REG32_STORE(ICU_IRQENCLR, 1 << irq);
39
}
40

41
void irqctrl_force(unsigned int irq) {
42
}
43

44
int irqctrl_pending(unsigned int irq) {
45
	return 0;
46
}
47

48
/* Sends an EOI (end of interrupt) signal to the PICs. */
49
void irqctrl_eoi(unsigned int irq) {
50
}
51

52
unsigned int irqctrl_get_intid(void) {
53
	unsigned int stat;
54
	unsigned int irq;
55

56
	stat = REG32_LOAD(ICU_IRQSTS);
57

58
	for (irq = 0; irq < IRQCTRL_IRQS_TOTAL; irq++) {
59
		if (stat & (uint32_t)(1 << irq)) {
60
			return irq;
61
		}
62
	}
63

64
	return -1;
65
}
66

67
IRQCTRL_DEF(integrator_pic, integrator_pic_init);
68

69
PERIPH_MEMORY_DEFINE(icu, ICU_BASE, 0x10);
70

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

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

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

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