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);
40 #ifdef CONFIG_PARAVIRT_GUEST
42 #define PARAVIRT_HYPERVISOR_TYPE_DEFAULT 0
43 #define PARAVIRT_HYPERVISOR_TYPE_XEN 1
47 #include <asm/hw_irq.h>
48 #include <asm/meminit.h>
50 /******************************************************************************
54 unsigned int kernel_rpl;
59 extern struct pv_info pv_info;
61 static inline int paravirt_enabled(void)
63 return pv_info.paravirt_enabled;
66 static inline unsigned int get_kernel_rpl(void)
68 return pv_info.kernel_rpl;
71 /******************************************************************************
72 * initialization hooks.
79 int (*reserve_memory)(struct rsvd_region *region);
81 void (*arch_setup_early)(void);
82 void (*arch_setup_console)(char **cmdline_p);
83 int (*arch_setup_nomca)(void);
85 void (*post_smp_prepare_boot_cpu)(void);
88 extern struct pv_init_ops pv_init_ops;
90 static inline void paravirt_banner(void)
92 if (pv_init_ops.banner)
96 static inline int paravirt_reserve_memory(struct rsvd_region *region)
98 if (pv_init_ops.reserve_memory)
99 return pv_init_ops.reserve_memory(region);
103 static inline void paravirt_arch_setup_early(void)
105 if (pv_init_ops.arch_setup_early)
106 pv_init_ops.arch_setup_early();
109 static inline void paravirt_arch_setup_console(char **cmdline_p)
111 if (pv_init_ops.arch_setup_console)
112 pv_init_ops.arch_setup_console(cmdline_p);
115 static inline int paravirt_arch_setup_nomca(void)
117 if (pv_init_ops.arch_setup_nomca)
118 return pv_init_ops.arch_setup_nomca();
122 static inline void paravirt_post_smp_prepare_boot_cpu(void)
124 if (pv_init_ops.post_smp_prepare_boot_cpu)
125 pv_init_ops.post_smp_prepare_boot_cpu();
128 /******************************************************************************
129 * replacement of iosapic operations.
132 struct pv_iosapic_ops {
133 void (*pcat_compat_init)(void);
135 struct irq_chip *(*__get_irq_chip)(unsigned long trigger);
137 unsigned int (*__read)(char __iomem *iosapic, unsigned int reg);
138 void (*__write)(char __iomem *iosapic, unsigned int reg, u32 val);
141 extern struct pv_iosapic_ops pv_iosapic_ops;
144 iosapic_pcat_compat_init(void)
146 if (pv_iosapic_ops.pcat_compat_init)
147 pv_iosapic_ops.pcat_compat_init();
150 static inline struct irq_chip*
151 iosapic_get_irq_chip(unsigned long trigger)
153 return pv_iosapic_ops.__get_irq_chip(trigger);
156 static inline unsigned int
157 __iosapic_read(char __iomem *iosapic, unsigned int reg)
159 return pv_iosapic_ops.__read(iosapic, reg);
163 __iosapic_write(char __iomem *iosapic, unsigned int reg, u32 val)
165 return pv_iosapic_ops.__write(iosapic, reg, val);
168 /******************************************************************************
169 * replacement of irq operations.
173 void (*register_ipi)(void);
175 int (*assign_irq_vector)(int irq);
176 void (*free_irq_vector)(int vector);
178 void (*register_percpu_irq)(ia64_vector vec,
179 struct irqaction *action);
181 void (*resend_irq)(unsigned int vector);
184 extern struct pv_irq_ops pv_irq_ops;
187 ia64_register_ipi(void)
189 pv_irq_ops.register_ipi();
193 assign_irq_vector(int irq)
195 return pv_irq_ops.assign_irq_vector(irq);
199 free_irq_vector(int vector)
201 return pv_irq_ops.free_irq_vector(vector);
205 register_percpu_irq(ia64_vector vec, struct irqaction *action)
207 pv_irq_ops.register_percpu_irq(vec, action);
211 ia64_resend_irq(unsigned int vector)
213 pv_irq_ops.resend_irq(vector);
216 /******************************************************************************
217 * replacement of time operations.
220 extern struct itc_jitter_data_t itc_jitter_data;
221 extern volatile int time_keeper_id;
224 void (*init_missing_ticks_accounting)(int cpu);
225 int (*do_steal_accounting)(unsigned long *new_itm);
227 void (*clocksource_resume)(void);
230 extern struct pv_time_ops pv_time_ops;
233 paravirt_init_missing_ticks_accounting(int cpu)
235 if (pv_time_ops.init_missing_ticks_accounting)
236 pv_time_ops.init_missing_ticks_accounting(cpu);
240 paravirt_do_steal_accounting(unsigned long *new_itm)
242 return pv_time_ops.do_steal_accounting(new_itm);
245 #endif /* !__ASSEMBLY__ */
248 /* fallback for native case */
252 #define paravirt_banner() do { } while (0)
253 #define paravirt_reserve_memory(region) 0
255 #define paravirt_arch_setup_early() do { } while (0)
256 #define paravirt_arch_setup_console(cmdline_p) do { } while (0)
257 #define paravirt_arch_setup_nomca() 0
258 #define paravirt_post_smp_prepare_boot_cpu() do { } while (0)
260 #define paravirt_init_missing_ticks_accounting(cpu) do { } while (0)
261 #define paravirt_do_steal_accounting(new_itm) 0
263 #endif /* __ASSEMBLY__ */
266 #endif /* CONFIG_PARAVIRT_GUEST */
268 #endif /* __ASM_PARAVIRT_H */