ia64/pv_ops: gate page paravirtualization.
[linux-2.6-block.git] / arch / ia64 / include / asm / paravirt.h
CommitLineData
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 */
29struct pv_fsys_data {
30 unsigned long *fsyscall_table;
31 void *fsys_bubble_down;
32};
33
34extern struct pv_fsys_data pv_fsys_data;
35
36unsigned long *paravirt_get_fsyscall_table(void);
37char *paravirt_get_fsys_bubble_down(void);
e4ff5b8f
IY
38
39/******************************************************************************
40 * patchlist addresses for gate page
41 */
42enum pv_gate_patchlist {
43 PV_GATE_START_FSYSCALL,
44 PV_GATE_END_FSYSCALL,
45
46 PV_GATE_START_BRL_FSYS_BUBBLE_DOWN,
47 PV_GATE_END_BRL_FSYS_BUBBLE_DOWN,
48
49 PV_GATE_START_VTOP,
50 PV_GATE_END_VTOP,
51
52 PV_GATE_START_MCKINLEY_E9,
53 PV_GATE_END_MCKINLEY_E9,
54};
55
56struct pv_patchdata {
57 unsigned long start_fsyscall_patchlist;
58 unsigned long end_fsyscall_patchlist;
59 unsigned long start_brl_fsys_bubble_down_patchlist;
60 unsigned long end_brl_fsys_bubble_down_patchlist;
61 unsigned long start_vtop_patchlist;
62 unsigned long end_vtop_patchlist;
63 unsigned long start_mckinley_e9_patchlist;
64 unsigned long end_mckinley_e9_patchlist;
65
66 void *gate_section;
67};
68
69extern struct pv_patchdata pv_patchdata;
70
71unsigned long paravirt_get_gate_patchlist(enum pv_gate_patchlist type);
72void *paravirt_get_gate_section(void);
dd97d5cb
IY
73#endif
74
90aeb169
IY
75#ifdef CONFIG_PARAVIRT_GUEST
76
3e0879de
IY
77#define PARAVIRT_HYPERVISOR_TYPE_DEFAULT 0
78#define PARAVIRT_HYPERVISOR_TYPE_XEN 1
79
90aeb169
IY
80#ifndef __ASSEMBLY__
81
82#include <asm/hw_irq.h>
83#include <asm/meminit.h>
84
85/******************************************************************************
86 * general info
87 */
88struct pv_info {
89 unsigned int kernel_rpl;
90 int paravirt_enabled;
91 const char *name;
92};
93
94extern struct pv_info pv_info;
95
96static inline int paravirt_enabled(void)
97{
98 return pv_info.paravirt_enabled;
99}
100
101static inline unsigned int get_kernel_rpl(void)
102{
103 return pv_info.kernel_rpl;
104}
105
e51835d5
IY
106/******************************************************************************
107 * initialization hooks.
108 */
109struct rsvd_region;
110
111struct pv_init_ops {
112 void (*banner)(void);
113
114 int (*reserve_memory)(struct rsvd_region *region);
115
116 void (*arch_setup_early)(void);
117 void (*arch_setup_console)(char **cmdline_p);
118 int (*arch_setup_nomca)(void);
119
120 void (*post_smp_prepare_boot_cpu)(void);
121};
122
123extern struct pv_init_ops pv_init_ops;
124
125static inline void paravirt_banner(void)
126{
127 if (pv_init_ops.banner)
128 pv_init_ops.banner();
129}
130
131static inline int paravirt_reserve_memory(struct rsvd_region *region)
132{
133 if (pv_init_ops.reserve_memory)
134 return pv_init_ops.reserve_memory(region);
135 return 0;
136}
137
138static inline void paravirt_arch_setup_early(void)
139{
140 if (pv_init_ops.arch_setup_early)
141 pv_init_ops.arch_setup_early();
142}
143
144static inline void paravirt_arch_setup_console(char **cmdline_p)
145{
146 if (pv_init_ops.arch_setup_console)
147 pv_init_ops.arch_setup_console(cmdline_p);
148}
149
150static inline int paravirt_arch_setup_nomca(void)
151{
152 if (pv_init_ops.arch_setup_nomca)
153 return pv_init_ops.arch_setup_nomca();
154 return 0;
155}
156
157static inline void paravirt_post_smp_prepare_boot_cpu(void)
158{
159 if (pv_init_ops.post_smp_prepare_boot_cpu)
160 pv_init_ops.post_smp_prepare_boot_cpu();
161}
162
33b39e84
IY
163/******************************************************************************
164 * replacement of iosapic operations.
165 */
166
167struct pv_iosapic_ops {
168 void (*pcat_compat_init)(void);
169
ce1fc742 170 struct irq_chip *(*__get_irq_chip)(unsigned long trigger);
33b39e84
IY
171
172 unsigned int (*__read)(char __iomem *iosapic, unsigned int reg);
173 void (*__write)(char __iomem *iosapic, unsigned int reg, u32 val);
174};
175
176extern struct pv_iosapic_ops pv_iosapic_ops;
177
178static inline void
179iosapic_pcat_compat_init(void)
180{
181 if (pv_iosapic_ops.pcat_compat_init)
182 pv_iosapic_ops.pcat_compat_init();
183}
184
185static inline struct irq_chip*
186iosapic_get_irq_chip(unsigned long trigger)
187{
ce1fc742 188 return pv_iosapic_ops.__get_irq_chip(trigger);
33b39e84
IY
189}
190
191static inline unsigned int
192__iosapic_read(char __iomem *iosapic, unsigned int reg)
193{
194 return pv_iosapic_ops.__read(iosapic, reg);
195}
196
197static inline void
198__iosapic_write(char __iomem *iosapic, unsigned int reg, u32 val)
199{
200 return pv_iosapic_ops.__write(iosapic, reg, val);
201}
202
85cbc503
IY
203/******************************************************************************
204 * replacement of irq operations.
205 */
206
207struct pv_irq_ops {
208 void (*register_ipi)(void);
209
210 int (*assign_irq_vector)(int irq);
211 void (*free_irq_vector)(int vector);
212
213 void (*register_percpu_irq)(ia64_vector vec,
214 struct irqaction *action);
215
216 void (*resend_irq)(unsigned int vector);
217};
218
219extern struct pv_irq_ops pv_irq_ops;
220
221static inline void
222ia64_register_ipi(void)
223{
224 pv_irq_ops.register_ipi();
225}
226
227static inline int
228assign_irq_vector(int irq)
229{
230 return pv_irq_ops.assign_irq_vector(irq);
231}
232
233static inline void
234free_irq_vector(int vector)
235{
236 return pv_irq_ops.free_irq_vector(vector);
237}
238
239static inline void
240register_percpu_irq(ia64_vector vec, struct irqaction *action)
241{
242 pv_irq_ops.register_percpu_irq(vec, action);
243}
244
245static inline void
246ia64_resend_irq(unsigned int vector)
247{
248 pv_irq_ops.resend_irq(vector);
249}
250
00d21d82
IY
251/******************************************************************************
252 * replacement of time operations.
253 */
254
255extern struct itc_jitter_data_t itc_jitter_data;
256extern volatile int time_keeper_id;
257
258struct pv_time_ops {
259 void (*init_missing_ticks_accounting)(int cpu);
260 int (*do_steal_accounting)(unsigned long *new_itm);
261
262 void (*clocksource_resume)(void);
f927da17
IY
263
264 unsigned long long (*sched_clock)(void);
00d21d82
IY
265};
266
267extern struct pv_time_ops pv_time_ops;
268
269static inline void
270paravirt_init_missing_ticks_accounting(int cpu)
271{
272 if (pv_time_ops.init_missing_ticks_accounting)
273 pv_time_ops.init_missing_ticks_accounting(cpu);
274}
275
276static inline int
277paravirt_do_steal_accounting(unsigned long *new_itm)
278{
279 return pv_time_ops.do_steal_accounting(new_itm);
280}
281
f927da17
IY
282static inline unsigned long long paravirt_sched_clock(void)
283{
284 return pv_time_ops.sched_clock();
285}
286
90aeb169
IY
287#endif /* !__ASSEMBLY__ */
288
289#else
290/* fallback for native case */
291
e51835d5
IY
292#ifndef __ASSEMBLY__
293
294#define paravirt_banner() do { } while (0)
295#define paravirt_reserve_memory(region) 0
296
297#define paravirt_arch_setup_early() do { } while (0)
298#define paravirt_arch_setup_console(cmdline_p) do { } while (0)
299#define paravirt_arch_setup_nomca() 0
300#define paravirt_post_smp_prepare_boot_cpu() do { } while (0)
301
00d21d82
IY
302#define paravirt_init_missing_ticks_accounting(cpu) do { } while (0)
303#define paravirt_do_steal_accounting(new_itm) 0
304
e51835d5
IY
305#endif /* __ASSEMBLY__ */
306
307
90aeb169
IY
308#endif /* CONFIG_PARAVIRT_GUEST */
309
310#endif /* __ASM_PARAVIRT_H */