~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/tools/testing/selftests/kvm/lib/aarch64/gic.c

Version: ~ [ linux-6.11-rc3 ] ~ [ linux-6.10.4 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.45 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.104 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.164 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.223 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.281 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.319 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 // SPDX-License-Identifier: GPL-2.0
  2 /*
  3  * ARM Generic Interrupt Controller (GIC) support
  4  */
  5 
  6 #include <errno.h>
  7 #include <linux/bits.h>
  8 #include <linux/sizes.h>
  9 
 10 #include "kvm_util.h"
 11 
 12 #include <gic.h>
 13 #include "gic_private.h"
 14 #include "processor.h"
 15 #include "spinlock.h"
 16 
 17 static const struct gic_common_ops *gic_common_ops;
 18 static struct spinlock gic_lock;
 19 
 20 static void gic_cpu_init(unsigned int cpu)
 21 {
 22         gic_common_ops->gic_cpu_init(cpu);
 23 }
 24 
 25 static void gic_dist_init(enum gic_type type, unsigned int nr_cpus)
 26 {
 27         const struct gic_common_ops *gic_ops = NULL;
 28 
 29         spin_lock(&gic_lock);
 30 
 31         /* Distributor initialization is needed only once per VM */
 32         if (gic_common_ops) {
 33                 spin_unlock(&gic_lock);
 34                 return;
 35         }
 36 
 37         if (type == GIC_V3)
 38                 gic_ops = &gicv3_ops;
 39 
 40         GUEST_ASSERT(gic_ops);
 41 
 42         gic_ops->gic_init(nr_cpus);
 43         gic_common_ops = gic_ops;
 44 
 45         /* Make sure that the initialized data is visible to all the vCPUs */
 46         dsb(sy);
 47 
 48         spin_unlock(&gic_lock);
 49 }
 50 
 51 void gic_init(enum gic_type type, unsigned int nr_cpus)
 52 {
 53         uint32_t cpu = guest_get_vcpuid();
 54 
 55         GUEST_ASSERT(type < GIC_TYPE_MAX);
 56         GUEST_ASSERT(nr_cpus);
 57 
 58         gic_dist_init(type, nr_cpus);
 59         gic_cpu_init(cpu);
 60 }
 61 
 62 void gic_irq_enable(unsigned int intid)
 63 {
 64         GUEST_ASSERT(gic_common_ops);
 65         gic_common_ops->gic_irq_enable(intid);
 66 }
 67 
 68 void gic_irq_disable(unsigned int intid)
 69 {
 70         GUEST_ASSERT(gic_common_ops);
 71         gic_common_ops->gic_irq_disable(intid);
 72 }
 73 
 74 unsigned int gic_get_and_ack_irq(void)
 75 {
 76         uint64_t irqstat;
 77         unsigned int intid;
 78 
 79         GUEST_ASSERT(gic_common_ops);
 80 
 81         irqstat = gic_common_ops->gic_read_iar();
 82         intid = irqstat & GENMASK(23, 0);
 83 
 84         return intid;
 85 }
 86 
 87 void gic_set_eoi(unsigned int intid)
 88 {
 89         GUEST_ASSERT(gic_common_ops);
 90         gic_common_ops->gic_write_eoir(intid);
 91 }
 92 
 93 void gic_set_dir(unsigned int intid)
 94 {
 95         GUEST_ASSERT(gic_common_ops);
 96         gic_common_ops->gic_write_dir(intid);
 97 }
 98 
 99 void gic_set_eoi_split(bool split)
100 {
101         GUEST_ASSERT(gic_common_ops);
102         gic_common_ops->gic_set_eoi_split(split);
103 }
104 
105 void gic_set_priority_mask(uint64_t pmr)
106 {
107         GUEST_ASSERT(gic_common_ops);
108         gic_common_ops->gic_set_priority_mask(pmr);
109 }
110 
111 void gic_set_priority(unsigned int intid, unsigned int prio)
112 {
113         GUEST_ASSERT(gic_common_ops);
114         gic_common_ops->gic_set_priority(intid, prio);
115 }
116 
117 void gic_irq_set_active(unsigned int intid)
118 {
119         GUEST_ASSERT(gic_common_ops);
120         gic_common_ops->gic_irq_set_active(intid);
121 }
122 
123 void gic_irq_clear_active(unsigned int intid)
124 {
125         GUEST_ASSERT(gic_common_ops);
126         gic_common_ops->gic_irq_clear_active(intid);
127 }
128 
129 bool gic_irq_get_active(unsigned int intid)
130 {
131         GUEST_ASSERT(gic_common_ops);
132         return gic_common_ops->gic_irq_get_active(intid);
133 }
134 
135 void gic_irq_set_pending(unsigned int intid)
136 {
137         GUEST_ASSERT(gic_common_ops);
138         gic_common_ops->gic_irq_set_pending(intid);
139 }
140 
141 void gic_irq_clear_pending(unsigned int intid)
142 {
143         GUEST_ASSERT(gic_common_ops);
144         gic_common_ops->gic_irq_clear_pending(intid);
145 }
146 
147 bool gic_irq_get_pending(unsigned int intid)
148 {
149         GUEST_ASSERT(gic_common_ops);
150         return gic_common_ops->gic_irq_get_pending(intid);
151 }
152 
153 void gic_irq_set_config(unsigned int intid, bool is_edge)
154 {
155         GUEST_ASSERT(gic_common_ops);
156         gic_common_ops->gic_irq_set_config(intid, is_edge);
157 }
158 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php