blob: a73e77add7e21bca7a8536fd149b59448c138ef5 [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
Isaku Yamahatadd97d5c2009-03-04 21:05:34 +090025#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);
38#endif
39
Isaku Yamahata90aeb162008-05-19 22:13:32 +090040#ifdef CONFIG_PARAVIRT_GUEST
41
Isaku Yamahata3e0879d2008-05-19 22:13:33 +090042#define PARAVIRT_HYPERVISOR_TYPE_DEFAULT 0
43#define PARAVIRT_HYPERVISOR_TYPE_XEN 1
44
Isaku Yamahata90aeb162008-05-19 22:13:32 +090045#ifndef __ASSEMBLY__
46
47#include <asm/hw_irq.h>
48#include <asm/meminit.h>
49
50/******************************************************************************
51 * general info
52 */
53struct pv_info {
54 unsigned int kernel_rpl;
55 int paravirt_enabled;
56 const char *name;
57};
58
59extern struct pv_info pv_info;
60
61static inline int paravirt_enabled(void)
62{
63 return pv_info.paravirt_enabled;
64}
65
66static inline unsigned int get_kernel_rpl(void)
67{
68 return pv_info.kernel_rpl;
69}
70
Isaku Yamahatae51835d2008-05-19 22:13:41 +090071/******************************************************************************
72 * initialization hooks.
73 */
74struct rsvd_region;
75
76struct 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
88extern struct pv_init_ops pv_init_ops;
89
90static inline void paravirt_banner(void)
91{
92 if (pv_init_ops.banner)
93 pv_init_ops.banner();
94}
95
96static 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
103static 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
109static 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
115static 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
122static 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
Isaku Yamahata33b39e82008-05-19 22:13:42 +0900128/******************************************************************************
129 * replacement of iosapic operations.
130 */
131
132struct pv_iosapic_ops {
133 void (*pcat_compat_init)(void);
134
Isaku Yamahatace1fc742008-10-17 11:17:42 +0900135 struct irq_chip *(*__get_irq_chip)(unsigned long trigger);
Isaku Yamahata33b39e82008-05-19 22:13:42 +0900136
137 unsigned int (*__read)(char __iomem *iosapic, unsigned int reg);
138 void (*__write)(char __iomem *iosapic, unsigned int reg, u32 val);
139};
140
141extern struct pv_iosapic_ops pv_iosapic_ops;
142
143static inline void
144iosapic_pcat_compat_init(void)
145{
146 if (pv_iosapic_ops.pcat_compat_init)
147 pv_iosapic_ops.pcat_compat_init();
148}
149
150static inline struct irq_chip*
151iosapic_get_irq_chip(unsigned long trigger)
152{
Isaku Yamahatace1fc742008-10-17 11:17:42 +0900153 return pv_iosapic_ops.__get_irq_chip(trigger);
Isaku Yamahata33b39e82008-05-19 22:13:42 +0900154}
155
156static inline unsigned int
157__iosapic_read(char __iomem *iosapic, unsigned int reg)
158{
159 return pv_iosapic_ops.__read(iosapic, reg);
160}
161
162static 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
Isaku Yamahata85cbc502008-05-19 22:13:43 +0900168/******************************************************************************
169 * replacement of irq operations.
170 */
171
172struct 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
184extern struct pv_irq_ops pv_irq_ops;
185
186static inline void
187ia64_register_ipi(void)
188{
189 pv_irq_ops.register_ipi();
190}
191
192static inline int
193assign_irq_vector(int irq)
194{
195 return pv_irq_ops.assign_irq_vector(irq);
196}
197
198static inline void
199free_irq_vector(int vector)
200{
201 return pv_irq_ops.free_irq_vector(vector);
202}
203
204static inline void
205register_percpu_irq(ia64_vector vec, struct irqaction *action)
206{
207 pv_irq_ops.register_percpu_irq(vec, action);
208}
209
210static inline void
211ia64_resend_irq(unsigned int vector)
212{
213 pv_irq_ops.resend_irq(vector);
214}
215
Isaku Yamahata00d21d82008-05-19 22:13:44 +0900216/******************************************************************************
217 * replacement of time operations.
218 */
219
220extern struct itc_jitter_data_t itc_jitter_data;
221extern volatile int time_keeper_id;
222
223struct 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);
Isaku Yamahataf927da12009-03-04 21:05:40 +0900228
229 unsigned long long (*sched_clock)(void);
Isaku Yamahata00d21d82008-05-19 22:13:44 +0900230};
231
232extern struct pv_time_ops pv_time_ops;
233
234static inline void
235paravirt_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
241static inline int
242paravirt_do_steal_accounting(unsigned long *new_itm)
243{
244 return pv_time_ops.do_steal_accounting(new_itm);
245}
246
Isaku Yamahataf927da12009-03-04 21:05:40 +0900247static inline unsigned long long paravirt_sched_clock(void)
248{
249 return pv_time_ops.sched_clock();
250}
251
Isaku Yamahata90aeb162008-05-19 22:13:32 +0900252#endif /* !__ASSEMBLY__ */
253
254#else
255/* fallback for native case */
256
Isaku Yamahatae51835d2008-05-19 22:13:41 +0900257#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
Isaku Yamahata00d21d82008-05-19 22:13:44 +0900267#define paravirt_init_missing_ticks_accounting(cpu) do { } while (0)
268#define paravirt_do_steal_accounting(new_itm) 0
269
Isaku Yamahatae51835d2008-05-19 22:13:41 +0900270#endif /* __ASSEMBLY__ */
271
272
Isaku Yamahata90aeb162008-05-19 22:13:32 +0900273#endif /* CONFIG_PARAVIRT_GUEST */
274
275#endif /* __ASM_PARAVIRT_H */