1 /******************************************************************************
2 * Copyright (c) 2008 Isaku Yamahata <yamahata at valinux co jp>
3 * VA Linux Systems Japan K.K.
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.
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.
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
22 #ifndef __ASM_PARAVIRT_H
23 #define __ASM_PARAVIRT_H
26 /******************************************************************************
27 * fsys related addresses
30 unsigned long *fsyscall_table
;
31 void *fsys_bubble_down
;
34 extern struct pv_fsys_data pv_fsys_data
;
36 unsigned long *paravirt_get_fsyscall_table(void);
37 char *paravirt_get_fsys_bubble_down(void);
39 /******************************************************************************
40 * patchlist addresses for gate page
42 enum pv_gate_patchlist
{
43 PV_GATE_START_FSYSCALL
,
46 PV_GATE_START_BRL_FSYS_BUBBLE_DOWN
,
47 PV_GATE_END_BRL_FSYS_BUBBLE_DOWN
,
52 PV_GATE_START_MCKINLEY_E9
,
53 PV_GATE_END_MCKINLEY_E9
,
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
;
69 extern struct pv_patchdata pv_patchdata
;
71 unsigned long paravirt_get_gate_patchlist(enum pv_gate_patchlist type
);
72 void *paravirt_get_gate_section(void);
75 #ifdef CONFIG_PARAVIRT_GUEST
77 #define PARAVIRT_HYPERVISOR_TYPE_DEFAULT 0
78 #define PARAVIRT_HYPERVISOR_TYPE_XEN 1
82 #include <asm/hw_irq.h>
83 #include <asm/meminit.h>
85 /******************************************************************************
89 unsigned int kernel_rpl
;
94 extern struct pv_info pv_info
;
96 static inline int paravirt_enabled(void)
98 return pv_info
.paravirt_enabled
;
101 static inline unsigned int get_kernel_rpl(void)
103 return pv_info
.kernel_rpl
;
106 /******************************************************************************
107 * initialization hooks.
112 void (*banner
)(void);
114 int (*reserve_memory
)(struct rsvd_region
*region
);
116 void (*arch_setup_early
)(void);
117 void (*arch_setup_console
)(char **cmdline_p
);
118 int (*arch_setup_nomca
)(void);
120 void (*post_smp_prepare_boot_cpu
)(void);
123 unsigned long (*patch_bundle
)(void *sbundle
, void *ebundle
,
125 unsigned long (*patch_inst
)(unsigned long stag
, unsigned long etag
,
128 void (*patch_branch
)(unsigned long tag
, unsigned long type
);
131 extern struct pv_init_ops pv_init_ops
;
133 static inline void paravirt_banner(void)
135 if (pv_init_ops
.banner
)
136 pv_init_ops
.banner();
139 static inline int paravirt_reserve_memory(struct rsvd_region
*region
)
141 if (pv_init_ops
.reserve_memory
)
142 return pv_init_ops
.reserve_memory(region
);
146 static inline void paravirt_arch_setup_early(void)
148 if (pv_init_ops
.arch_setup_early
)
149 pv_init_ops
.arch_setup_early();
152 static inline void paravirt_arch_setup_console(char **cmdline_p
)
154 if (pv_init_ops
.arch_setup_console
)
155 pv_init_ops
.arch_setup_console(cmdline_p
);
158 static inline int paravirt_arch_setup_nomca(void)
160 if (pv_init_ops
.arch_setup_nomca
)
161 return pv_init_ops
.arch_setup_nomca();
165 static inline void paravirt_post_smp_prepare_boot_cpu(void)
167 if (pv_init_ops
.post_smp_prepare_boot_cpu
)
168 pv_init_ops
.post_smp_prepare_boot_cpu();
171 /******************************************************************************
172 * replacement of iosapic operations.
175 struct pv_iosapic_ops
{
176 void (*pcat_compat_init
)(void);
178 struct irq_chip
*(*__get_irq_chip
)(unsigned long trigger
);
180 unsigned int (*__read
)(char __iomem
*iosapic
, unsigned int reg
);
181 void (*__write
)(char __iomem
*iosapic
, unsigned int reg
, u32 val
);
184 extern struct pv_iosapic_ops pv_iosapic_ops
;
187 iosapic_pcat_compat_init(void)
189 if (pv_iosapic_ops
.pcat_compat_init
)
190 pv_iosapic_ops
.pcat_compat_init();
193 static inline struct irq_chip
*
194 iosapic_get_irq_chip(unsigned long trigger
)
196 return pv_iosapic_ops
.__get_irq_chip(trigger
);
199 static inline unsigned int
200 __iosapic_read(char __iomem
*iosapic
, unsigned int reg
)
202 return pv_iosapic_ops
.__read(iosapic
, reg
);
206 __iosapic_write(char __iomem
*iosapic
, unsigned int reg
, u32 val
)
208 return pv_iosapic_ops
.__write(iosapic
, reg
, val
);
211 /******************************************************************************
212 * replacement of irq operations.
216 void (*register_ipi
)(void);
218 int (*assign_irq_vector
)(int irq
);
219 void (*free_irq_vector
)(int vector
);
221 void (*register_percpu_irq
)(ia64_vector vec
,
222 struct irqaction
*action
);
224 void (*resend_irq
)(unsigned int vector
);
227 extern struct pv_irq_ops pv_irq_ops
;
230 ia64_register_ipi(void)
232 pv_irq_ops
.register_ipi();
236 assign_irq_vector(int irq
)
238 return pv_irq_ops
.assign_irq_vector(irq
);
242 free_irq_vector(int vector
)
244 return pv_irq_ops
.free_irq_vector(vector
);
248 register_percpu_irq(ia64_vector vec
, struct irqaction
*action
)
250 pv_irq_ops
.register_percpu_irq(vec
, action
);
254 ia64_resend_irq(unsigned int vector
)
256 pv_irq_ops
.resend_irq(vector
);
259 /******************************************************************************
260 * replacement of time operations.
263 extern struct itc_jitter_data_t itc_jitter_data
;
264 extern volatile int time_keeper_id
;
267 void (*init_missing_ticks_accounting
)(int cpu
);
268 int (*do_steal_accounting
)(unsigned long *new_itm
);
270 void (*clocksource_resume
)(void);
272 unsigned long long (*sched_clock
)(void);
275 extern struct pv_time_ops pv_time_ops
;
278 paravirt_init_missing_ticks_accounting(int cpu
)
280 if (pv_time_ops
.init_missing_ticks_accounting
)
281 pv_time_ops
.init_missing_ticks_accounting(cpu
);
285 paravirt_do_steal_accounting(unsigned long *new_itm
)
287 return pv_time_ops
.do_steal_accounting(new_itm
);
290 static inline unsigned long long paravirt_sched_clock(void)
292 return pv_time_ops
.sched_clock();
295 #endif /* !__ASSEMBLY__ */
298 /* fallback for native case */
302 #define paravirt_banner() do { } while (0)
303 #define paravirt_reserve_memory(region) 0
305 #define paravirt_arch_setup_early() do { } while (0)
306 #define paravirt_arch_setup_console(cmdline_p) do { } while (0)
307 #define paravirt_arch_setup_nomca() 0
308 #define paravirt_post_smp_prepare_boot_cpu() do { } while (0)
310 #define paravirt_init_missing_ticks_accounting(cpu) do { } while (0)
311 #define paravirt_do_steal_accounting(new_itm) 0
313 #endif /* __ASSEMBLY__ */
316 #endif /* CONFIG_PARAVIRT_GUEST */
318 #endif /* __ASM_PARAVIRT_H */