blob: 2bf3636473fe9c5b826b53488f00ff4aa5a1f33b [file] [log] [blame]
Isaku Yamahata90aeb162008-05-19 22:13:32 +09001/******************************************************************************
Isaku Yamahata90aeb162008-05-19 22:13:32 +09002 * 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
25#ifdef CONFIG_PARAVIRT_GUEST
26
Isaku Yamahata3e0879d2008-05-19 22:13:33 +090027#define PARAVIRT_HYPERVISOR_TYPE_DEFAULT 0
28#define PARAVIRT_HYPERVISOR_TYPE_XEN 1
29
Isaku Yamahata90aeb162008-05-19 22:13:32 +090030#ifndef __ASSEMBLY__
31
32#include <asm/hw_irq.h>
33#include <asm/meminit.h>
34
35/******************************************************************************
36 * general info
37 */
38struct pv_info {
39 unsigned int kernel_rpl;
40 int paravirt_enabled;
41 const char *name;
42};
43
44extern struct pv_info pv_info;
45
46static inline int paravirt_enabled(void)
47{
48 return pv_info.paravirt_enabled;
49}
50
51static inline unsigned int get_kernel_rpl(void)
52{
53 return pv_info.kernel_rpl;
54}
55
Isaku Yamahatae51835d2008-05-19 22:13:41 +090056/******************************************************************************
57 * initialization hooks.
58 */
59struct rsvd_region;
60
61struct pv_init_ops {
62 void (*banner)(void);
63
64 int (*reserve_memory)(struct rsvd_region *region);
65
66 void (*arch_setup_early)(void);
67 void (*arch_setup_console)(char **cmdline_p);
68 int (*arch_setup_nomca)(void);
69
70 void (*post_smp_prepare_boot_cpu)(void);
71};
72
73extern struct pv_init_ops pv_init_ops;
74
75static inline void paravirt_banner(void)
76{
77 if (pv_init_ops.banner)
78 pv_init_ops.banner();
79}
80
81static inline int paravirt_reserve_memory(struct rsvd_region *region)
82{
83 if (pv_init_ops.reserve_memory)
84 return pv_init_ops.reserve_memory(region);
85 return 0;
86}
87
88static inline void paravirt_arch_setup_early(void)
89{
90 if (pv_init_ops.arch_setup_early)
91 pv_init_ops.arch_setup_early();
92}
93
94static inline void paravirt_arch_setup_console(char **cmdline_p)
95{
96 if (pv_init_ops.arch_setup_console)
97 pv_init_ops.arch_setup_console(cmdline_p);
98}
99
100static inline int paravirt_arch_setup_nomca(void)
101{
102 if (pv_init_ops.arch_setup_nomca)
103 return pv_init_ops.arch_setup_nomca();
104 return 0;
105}
106
107static inline void paravirt_post_smp_prepare_boot_cpu(void)
108{
109 if (pv_init_ops.post_smp_prepare_boot_cpu)
110 pv_init_ops.post_smp_prepare_boot_cpu();
111}
112
Isaku Yamahata33b39e82008-05-19 22:13:42 +0900113/******************************************************************************
114 * replacement of iosapic operations.
115 */
116
117struct pv_iosapic_ops {
118 void (*pcat_compat_init)(void);
119
Isaku Yamahatace1fc742008-10-17 11:17:42 +0900120 struct irq_chip *(*__get_irq_chip)(unsigned long trigger);
Isaku Yamahata33b39e82008-05-19 22:13:42 +0900121
122 unsigned int (*__read)(char __iomem *iosapic, unsigned int reg);
123 void (*__write)(char __iomem *iosapic, unsigned int reg, u32 val);
124};
125
126extern struct pv_iosapic_ops pv_iosapic_ops;
127
128static inline void
129iosapic_pcat_compat_init(void)
130{
131 if (pv_iosapic_ops.pcat_compat_init)
132 pv_iosapic_ops.pcat_compat_init();
133}
134
135static inline struct irq_chip*
136iosapic_get_irq_chip(unsigned long trigger)
137{
Isaku Yamahatace1fc742008-10-17 11:17:42 +0900138 return pv_iosapic_ops.__get_irq_chip(trigger);
Isaku Yamahata33b39e82008-05-19 22:13:42 +0900139}
140
141static inline unsigned int
142__iosapic_read(char __iomem *iosapic, unsigned int reg)
143{
144 return pv_iosapic_ops.__read(iosapic, reg);
145}
146
147static inline void
148__iosapic_write(char __iomem *iosapic, unsigned int reg, u32 val)
149{
150 return pv_iosapic_ops.__write(iosapic, reg, val);
151}
152
Isaku Yamahata85cbc502008-05-19 22:13:43 +0900153/******************************************************************************
154 * replacement of irq operations.
155 */
156
157struct pv_irq_ops {
158 void (*register_ipi)(void);
159
160 int (*assign_irq_vector)(int irq);
161 void (*free_irq_vector)(int vector);
162
163 void (*register_percpu_irq)(ia64_vector vec,
164 struct irqaction *action);
165
166 void (*resend_irq)(unsigned int vector);
167};
168
169extern struct pv_irq_ops pv_irq_ops;
170
171static inline void
172ia64_register_ipi(void)
173{
174 pv_irq_ops.register_ipi();
175}
176
177static inline int
178assign_irq_vector(int irq)
179{
180 return pv_irq_ops.assign_irq_vector(irq);
181}
182
183static inline void
184free_irq_vector(int vector)
185{
186 return pv_irq_ops.free_irq_vector(vector);
187}
188
189static inline void
190register_percpu_irq(ia64_vector vec, struct irqaction *action)
191{
192 pv_irq_ops.register_percpu_irq(vec, action);
193}
194
195static inline void
196ia64_resend_irq(unsigned int vector)
197{
198 pv_irq_ops.resend_irq(vector);
199}
200
Isaku Yamahata00d21d82008-05-19 22:13:44 +0900201/******************************************************************************
202 * replacement of time operations.
203 */
204
205extern struct itc_jitter_data_t itc_jitter_data;
206extern volatile int time_keeper_id;
207
208struct pv_time_ops {
209 void (*init_missing_ticks_accounting)(int cpu);
210 int (*do_steal_accounting)(unsigned long *new_itm);
211
212 void (*clocksource_resume)(void);
213};
214
215extern struct pv_time_ops pv_time_ops;
216
217static inline void
218paravirt_init_missing_ticks_accounting(int cpu)
219{
220 if (pv_time_ops.init_missing_ticks_accounting)
221 pv_time_ops.init_missing_ticks_accounting(cpu);
222}
223
224static inline int
225paravirt_do_steal_accounting(unsigned long *new_itm)
226{
227 return pv_time_ops.do_steal_accounting(new_itm);
228}
229
Isaku Yamahata90aeb162008-05-19 22:13:32 +0900230#endif /* !__ASSEMBLY__ */
231
232#else
233/* fallback for native case */
234
Isaku Yamahatae51835d2008-05-19 22:13:41 +0900235#ifndef __ASSEMBLY__
236
237#define paravirt_banner() do { } while (0)
238#define paravirt_reserve_memory(region) 0
239
240#define paravirt_arch_setup_early() do { } while (0)
241#define paravirt_arch_setup_console(cmdline_p) do { } while (0)
242#define paravirt_arch_setup_nomca() 0
243#define paravirt_post_smp_prepare_boot_cpu() do { } while (0)
244
Isaku Yamahata00d21d82008-05-19 22:13:44 +0900245#define paravirt_init_missing_ticks_accounting(cpu) do { } while (0)
246#define paravirt_do_steal_accounting(new_itm) 0
247
Isaku Yamahatae51835d2008-05-19 22:13:41 +0900248#endif /* __ASSEMBLY__ */
249
250
Isaku Yamahata90aeb162008-05-19 22:13:32 +0900251#endif /* CONFIG_PARAVIRT_GUEST */
252
253#endif /* __ASM_PARAVIRT_H */