Commit | Line | Data |
---|---|---|
90aeb169 | 1 | /****************************************************************************** |
90aeb169 IY |
2 | * Copyright (c) 2008 Isaku Yamahata <yamahata at valinux co jp> |
3 | * VA Linux Systems Japan K.K. | |
4 | * | |
5 | * This program is free software; you can redistribute it and/or modify | |
6 | * it under the terms of the GNU General Public License as published by | |
7 | * the Free Software Foundation; either version 2 of the License, or | |
8 | * (at your option) any later version. | |
9 | * | |
10 | * This program is distributed in the hope that it will be useful, | |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | * GNU General Public License for more details. | |
14 | * | |
15 | * You should have received a copy of the GNU General Public License | |
16 | * along with this program; if not, write to the Free Software | |
17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
18 | * | |
19 | */ | |
20 | ||
21 | ||
22 | #ifndef __ASM_PARAVIRT_H | |
23 | #define __ASM_PARAVIRT_H | |
24 | ||
dd97d5cb IY |
25 | #ifndef __ASSEMBLY__ |
26 | /****************************************************************************** | |
27 | * fsys related addresses | |
28 | */ | |
29 | struct pv_fsys_data { | |
30 | unsigned long *fsyscall_table; | |
31 | void *fsys_bubble_down; | |
32 | }; | |
33 | ||
34 | extern struct pv_fsys_data pv_fsys_data; | |
35 | ||
36 | unsigned long *paravirt_get_fsyscall_table(void); | |
37 | char *paravirt_get_fsys_bubble_down(void); | |
38 | #endif | |
39 | ||
90aeb169 IY |
40 | #ifdef CONFIG_PARAVIRT_GUEST |
41 | ||
3e0879de IY |
42 | #define PARAVIRT_HYPERVISOR_TYPE_DEFAULT 0 |
43 | #define PARAVIRT_HYPERVISOR_TYPE_XEN 1 | |
44 | ||
90aeb169 IY |
45 | #ifndef __ASSEMBLY__ |
46 | ||
47 | #include <asm/hw_irq.h> | |
48 | #include <asm/meminit.h> | |
49 | ||
50 | /****************************************************************************** | |
51 | * general info | |
52 | */ | |
53 | struct pv_info { | |
54 | unsigned int kernel_rpl; | |
55 | int paravirt_enabled; | |
56 | const char *name; | |
57 | }; | |
58 | ||
59 | extern struct pv_info pv_info; | |
60 | ||
61 | static inline int paravirt_enabled(void) | |
62 | { | |
63 | return pv_info.paravirt_enabled; | |
64 | } | |
65 | ||
66 | static inline unsigned int get_kernel_rpl(void) | |
67 | { | |
68 | return pv_info.kernel_rpl; | |
69 | } | |
70 | ||
e51835d5 IY |
71 | /****************************************************************************** |
72 | * initialization hooks. | |
73 | */ | |
74 | struct rsvd_region; | |
75 | ||
76 | struct pv_init_ops { | |
77 | void (*banner)(void); | |
78 | ||
79 | int (*reserve_memory)(struct rsvd_region *region); | |
80 | ||
81 | void (*arch_setup_early)(void); | |
82 | void (*arch_setup_console)(char **cmdline_p); | |
83 | int (*arch_setup_nomca)(void); | |
84 | ||
85 | void (*post_smp_prepare_boot_cpu)(void); | |
86 | }; | |
87 | ||
88 | extern struct pv_init_ops pv_init_ops; | |
89 | ||
90 | static inline void paravirt_banner(void) | |
91 | { | |
92 | if (pv_init_ops.banner) | |
93 | pv_init_ops.banner(); | |
94 | } | |
95 | ||
96 | static inline int paravirt_reserve_memory(struct rsvd_region *region) | |
97 | { | |
98 | if (pv_init_ops.reserve_memory) | |
99 | return pv_init_ops.reserve_memory(region); | |
100 | return 0; | |
101 | } | |
102 | ||
103 | static inline void paravirt_arch_setup_early(void) | |
104 | { | |
105 | if (pv_init_ops.arch_setup_early) | |
106 | pv_init_ops.arch_setup_early(); | |
107 | } | |
108 | ||
109 | static inline void paravirt_arch_setup_console(char **cmdline_p) | |
110 | { | |
111 | if (pv_init_ops.arch_setup_console) | |
112 | pv_init_ops.arch_setup_console(cmdline_p); | |
113 | } | |
114 | ||
115 | static inline int paravirt_arch_setup_nomca(void) | |
116 | { | |
117 | if (pv_init_ops.arch_setup_nomca) | |
118 | return pv_init_ops.arch_setup_nomca(); | |
119 | return 0; | |
120 | } | |
121 | ||
122 | static inline void paravirt_post_smp_prepare_boot_cpu(void) | |
123 | { | |
124 | if (pv_init_ops.post_smp_prepare_boot_cpu) | |
125 | pv_init_ops.post_smp_prepare_boot_cpu(); | |
126 | } | |
127 | ||
33b39e84 IY |
128 | /****************************************************************************** |
129 | * replacement of iosapic operations. | |
130 | */ | |
131 | ||
132 | struct pv_iosapic_ops { | |
133 | void (*pcat_compat_init)(void); | |
134 | ||
ce1fc742 | 135 | struct irq_chip *(*__get_irq_chip)(unsigned long trigger); |
33b39e84 IY |
136 | |
137 | unsigned int (*__read)(char __iomem *iosapic, unsigned int reg); | |
138 | void (*__write)(char __iomem *iosapic, unsigned int reg, u32 val); | |
139 | }; | |
140 | ||
141 | extern struct pv_iosapic_ops pv_iosapic_ops; | |
142 | ||
143 | static inline void | |
144 | iosapic_pcat_compat_init(void) | |
145 | { | |
146 | if (pv_iosapic_ops.pcat_compat_init) | |
147 | pv_iosapic_ops.pcat_compat_init(); | |
148 | } | |
149 | ||
150 | static inline struct irq_chip* | |
151 | iosapic_get_irq_chip(unsigned long trigger) | |
152 | { | |
ce1fc742 | 153 | return pv_iosapic_ops.__get_irq_chip(trigger); |
33b39e84 IY |
154 | } |
155 | ||
156 | static inline unsigned int | |
157 | __iosapic_read(char __iomem *iosapic, unsigned int reg) | |
158 | { | |
159 | return pv_iosapic_ops.__read(iosapic, reg); | |
160 | } | |
161 | ||
162 | static inline void | |
163 | __iosapic_write(char __iomem *iosapic, unsigned int reg, u32 val) | |
164 | { | |
165 | return pv_iosapic_ops.__write(iosapic, reg, val); | |
166 | } | |
167 | ||
85cbc503 IY |
168 | /****************************************************************************** |
169 | * replacement of irq operations. | |
170 | */ | |
171 | ||
172 | struct pv_irq_ops { | |
173 | void (*register_ipi)(void); | |
174 | ||
175 | int (*assign_irq_vector)(int irq); | |
176 | void (*free_irq_vector)(int vector); | |
177 | ||
178 | void (*register_percpu_irq)(ia64_vector vec, | |
179 | struct irqaction *action); | |
180 | ||
181 | void (*resend_irq)(unsigned int vector); | |
182 | }; | |
183 | ||
184 | extern struct pv_irq_ops pv_irq_ops; | |
185 | ||
186 | static inline void | |
187 | ia64_register_ipi(void) | |
188 | { | |
189 | pv_irq_ops.register_ipi(); | |
190 | } | |
191 | ||
192 | static inline int | |
193 | assign_irq_vector(int irq) | |
194 | { | |
195 | return pv_irq_ops.assign_irq_vector(irq); | |
196 | } | |
197 | ||
198 | static inline void | |
199 | free_irq_vector(int vector) | |
200 | { | |
201 | return pv_irq_ops.free_irq_vector(vector); | |
202 | } | |
203 | ||
204 | static inline void | |
205 | register_percpu_irq(ia64_vector vec, struct irqaction *action) | |
206 | { | |
207 | pv_irq_ops.register_percpu_irq(vec, action); | |
208 | } | |
209 | ||
210 | static inline void | |
211 | ia64_resend_irq(unsigned int vector) | |
212 | { | |
213 | pv_irq_ops.resend_irq(vector); | |
214 | } | |
215 | ||
00d21d82 IY |
216 | /****************************************************************************** |
217 | * replacement of time operations. | |
218 | */ | |
219 | ||
220 | extern struct itc_jitter_data_t itc_jitter_data; | |
221 | extern volatile int time_keeper_id; | |
222 | ||
223 | struct pv_time_ops { | |
224 | void (*init_missing_ticks_accounting)(int cpu); | |
225 | int (*do_steal_accounting)(unsigned long *new_itm); | |
226 | ||
227 | void (*clocksource_resume)(void); | |
f927da17 IY |
228 | |
229 | unsigned long long (*sched_clock)(void); | |
00d21d82 IY |
230 | }; |
231 | ||
232 | extern struct pv_time_ops pv_time_ops; | |
233 | ||
234 | static inline void | |
235 | paravirt_init_missing_ticks_accounting(int cpu) | |
236 | { | |
237 | if (pv_time_ops.init_missing_ticks_accounting) | |
238 | pv_time_ops.init_missing_ticks_accounting(cpu); | |
239 | } | |
240 | ||
241 | static inline int | |
242 | paravirt_do_steal_accounting(unsigned long *new_itm) | |
243 | { | |
244 | return pv_time_ops.do_steal_accounting(new_itm); | |
245 | } | |
246 | ||
f927da17 IY |
247 | static inline unsigned long long paravirt_sched_clock(void) |
248 | { | |
249 | return pv_time_ops.sched_clock(); | |
250 | } | |
251 | ||
90aeb169 IY |
252 | #endif /* !__ASSEMBLY__ */ |
253 | ||
254 | #else | |
255 | /* fallback for native case */ | |
256 | ||
e51835d5 IY |
257 | #ifndef __ASSEMBLY__ |
258 | ||
259 | #define paravirt_banner() do { } while (0) | |
260 | #define paravirt_reserve_memory(region) 0 | |
261 | ||
262 | #define paravirt_arch_setup_early() do { } while (0) | |
263 | #define paravirt_arch_setup_console(cmdline_p) do { } while (0) | |
264 | #define paravirt_arch_setup_nomca() 0 | |
265 | #define paravirt_post_smp_prepare_boot_cpu() do { } while (0) | |
266 | ||
00d21d82 IY |
267 | #define paravirt_init_missing_ticks_accounting(cpu) do { } while (0) |
268 | #define paravirt_do_steal_accounting(new_itm) 0 | |
269 | ||
e51835d5 IY |
270 | #endif /* __ASSEMBLY__ */ |
271 | ||
272 | ||
90aeb169 IY |
273 | #endif /* CONFIG_PARAVIRT_GUEST */ |
274 | ||
275 | #endif /* __ASM_PARAVIRT_H */ |