]> rtime.felk.cvut.cz Git - jailhouse.git/blob - inmates/lib/arm/gic.c
inmates: arm: Flatten include path
[jailhouse.git] / inmates / lib / arm / gic.c
1 /*
2  * Jailhouse, a Linux-based partitioning hypervisor
3  *
4  * Copyright (c) ARM Limited, 2014
5  *
6  * Authors:
7  *  Jean-Philippe Brucker <jean-philippe.brucker@arm.com>
8  *
9  * This work is licensed under the terms of the GNU GPL, version 2.  See
10  * the COPYING file in the top-level directory.
11  */
12
13 #include <inmate.h>
14 #include <gic.h>
15
16 static irq_handler_t irq_handler = (irq_handler_t)NULL;
17 static __attribute__((aligned(0x1000))) u32 irq_stack[1024];
18
19 /* Replaces the weak reference in header.S */
20 void vector_irq(void)
21 {
22         u32 irqn;
23
24         do {
25                 irqn = gic_read_ack();
26
27                 if (irq_handler)
28                         irq_handler(irqn);
29
30                 gic_write_eoi(irqn);
31
32         } while (irqn != 0x3ff);
33 }
34
35 void gic_setup(irq_handler_t handler)
36 {
37         gic_init();
38         irq_handler = handler;
39
40         asm volatile (".arch_extension virt\n");
41         asm volatile ("msr      SP_irq, %0\n" : : "r" (irq_stack));
42         asm volatile ("cpsie    i\n");
43 }
44
45 void gic_enable_irq(unsigned int irq)
46 {
47         gic_enable(irq);
48 }