My Project
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
gic.h
Go to the documentation of this file.
1 /*
2  * OpenVirtualization:
3  * For additional details and support contact developer@sierraware.com.
4  * Additional documentation can be found at www.openvirtualization.org
5  *
6  * Copyright (C) 2010-2014 SierraWare
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * as published by the Free Software Foundation; either version 2
11  * of the License, or (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21  *
22  */
23 /*
24  * Header file GIC functions.
25  */
26 
27 #ifndef __COMMON_GIC_H__
28 #define __COMMON_GIC_H__
29 
30 #include <sw_types.h>
31 #include <system_context.h> /* tzhyp switching support */
32 #include <sw_board.h>
33 #include <sw_io.h>
34 #include <sw_debug.h>
35 
36 #define GIC_CPU_CTRL 0x00
37 #define GIC_CPU_PRIMASK 0x04
38 #define GIC_CPU_BINPOINT 0x08
39 #define GIC_CPU_INTACK 0x0c
40 #define GIC_CPU_EOI 0x10
41 #define GIC_CPU_RUNNINGPRI 0x14
42 #define GIC_CPU_HIGHPRI 0x18
43 
44 #define GIC_DIST_CTRL 0x000
45 #define GIC_DIST_CTR 0x004
46 #define GIC_DIST_SECURITY 0x80
47 #define GIC_DIST_ENABLE_SET 0x100
48 #define GIC_DIST_ENABLE_CLEAR 0x180
49 #define GIC_DIST_PENDING_SET 0x200
50 #define GIC_DIST_PENDING_CLEAR 0x280
51 #define GIC_DIST_ACTIVE_BIT 0x300
52 #define GIC_DIST_CLEAR_ACTIVE_BIT 0x380
53 #define GIC_DIST_PRI 0x400
54 #define GIC_DIST_TARGET 0x800
55 #define GIC_DIST_CONFIG 0xc00
56 #define GIC_DIST_SOFTINT 0xf00
57 
58 #define GIC_DIST_SOFTINT_NSATT_SET (1 << 15)
59 
60 #define GIC_DIST_SOFTINT_TAR_CORE0 (1 << 16)
61 #define GIC_DIST_SOFTINT_TAR_CORE1 (1 << 17)
62 
63 #ifdef SCHEDULE_HIGH_PRIORITY_GUEST
64 
71 int is_guest_irq_active(u32 guest);
72 #endif
73 
81 int gic_active_irq(u32 gic_nr);
82 
91 int gic_ack_irq(u32 gic_nr, u32 irq);
92 
101 int gic_mask(u32 gic_nr, u32 irq);
102 
111 int gic_unmask(u32 gic_nr, u32 irq);
112 
118 int gic_dist_init(void);
119 
125 int gic_cpu_init(void);
126 
132 void generate_soft_int(u32 int_id);
133 
139 void generate_soft_int_to_core0(u32 int_id);
140 
146 static inline void gic_write(u32 val, va_t addr)
147 {
148  sw_writel(val, (void *)(addr));
149 }
150 
158 static inline u32 gic_read(va_t addr)
159 {
160  return sw_readl((void *)(addr));
161 }
162 
168 static inline void gic_dist_restore(struct gic_context *x)
169 {
170  int i;
171 
172  for (i = 0; i <= GIC_ITLINES; i++) {
173  gic_write(x->gic_icdiser[i],
174  GIC_DIST + GIC_DIST_ENABLE_SET + i * 4 );
175  }
176 }
177 
178 
184 static inline void gic_dist_save(struct gic_context *x)
185 {
186  int i;
187 
188  for (i = 0; i <= GIC_ITLINES; i++) {
189  x->gic_icdiser[i] =
190  gic_read(GIC_DIST + GIC_DIST_ENABLE_SET + i * 4 );
191  /* disable the interrupts for a clean restore */
192  gic_write(x->gic_icdiser[i],
193  GIC_DIST + GIC_DIST_ENABLE_CLEAR + i * 4 );
194  }
195 
196 }
197 #endif
int gic_unmask(u32 gic_nr, u32 irq)
Unmask a particular interrupt request of the Generic interrupt controller.
Definition: gic.c:171
#define GIC_ITLINES
Definition: sw_board.h:130
int gic_dist_init(void)
This function is to initialize distributor block of Generic interrupt controller. ...
Definition: gic.c:197
void generate_soft_int(u32 int_id)
int gic_ack_irq(u32 gic_nr, u32 irq)
Acknowledges the interrupt request of Generic interrupt controller.
Definition: gic.c:115
int gic_active_irq(u32 gic_nr)
reads the generic interrupt control register
Definition: gic.c:91
Definition: system_context.h:100
void generate_soft_int_to_core0(u32 int_id)
Generate software interrupt specific to core0.
Definition: gic.c:358
int gic_mask(u32 gic_nr, u32 irq)
Masks a particular interrupt request of the generic interrupt controller.
Definition: gic.c:143
int gic_cpu_init(void)
This function is used to initialize CPU interfaces of Generic interrupt controller.
Definition: gic.c:314
#define GIC_DIST_ENABLE_SET
Definition: gic.h:47
#define GIC_DIST
Definition: sw_board.h:48
#define GIC_DIST_ENABLE_CLEAR
Definition: gic.h:48
u32 gic_icdiser[GIC_ITLINES]
Definition: system_context.h:101