Isaku Yamahata | 90aeb16 | 2008-05-19 22:13:32 +0900 | [diff] [blame] | 1 | /****************************************************************************** |
| 2 | * include/asm-ia64/paravirt.h |
| 3 | * |
| 4 | * Copyright (c) 2008 Isaku Yamahata <yamahata at valinux co jp> |
| 5 | * VA Linux Systems Japan K.K. |
| 6 | * |
| 7 | * This program is free software; you can redistribute it and/or modify |
| 8 | * it under the terms of the GNU General Public License as published by |
| 9 | * the Free Software Foundation; either version 2 of the License, or |
| 10 | * (at your option) any later version. |
| 11 | * |
| 12 | * This program is distributed in the hope that it will be useful, |
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | * GNU General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU General Public License |
| 18 | * along with this program; if not, write to the Free Software |
| 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 20 | * |
| 21 | */ |
| 22 | |
| 23 | |
| 24 | #ifndef __ASM_PARAVIRT_H |
| 25 | #define __ASM_PARAVIRT_H |
| 26 | |
| 27 | #ifdef CONFIG_PARAVIRT_GUEST |
| 28 | |
Isaku Yamahata | 3e0879d | 2008-05-19 22:13:33 +0900 | [diff] [blame] | 29 | #define PARAVIRT_HYPERVISOR_TYPE_DEFAULT 0 |
| 30 | #define PARAVIRT_HYPERVISOR_TYPE_XEN 1 |
| 31 | |
Isaku Yamahata | 90aeb16 | 2008-05-19 22:13:32 +0900 | [diff] [blame] | 32 | #ifndef __ASSEMBLY__ |
| 33 | |
| 34 | #include <asm/hw_irq.h> |
| 35 | #include <asm/meminit.h> |
| 36 | |
| 37 | /****************************************************************************** |
| 38 | * general info |
| 39 | */ |
| 40 | struct pv_info { |
| 41 | unsigned int kernel_rpl; |
| 42 | int paravirt_enabled; |
| 43 | const char *name; |
| 44 | }; |
| 45 | |
| 46 | extern struct pv_info pv_info; |
| 47 | |
| 48 | static inline int paravirt_enabled(void) |
| 49 | { |
| 50 | return pv_info.paravirt_enabled; |
| 51 | } |
| 52 | |
| 53 | static inline unsigned int get_kernel_rpl(void) |
| 54 | { |
| 55 | return pv_info.kernel_rpl; |
| 56 | } |
| 57 | |
Isaku Yamahata | e51835d | 2008-05-19 22:13:41 +0900 | [diff] [blame] | 58 | /****************************************************************************** |
| 59 | * initialization hooks. |
| 60 | */ |
| 61 | struct rsvd_region; |
| 62 | |
| 63 | struct pv_init_ops { |
| 64 | void (*banner)(void); |
| 65 | |
| 66 | int (*reserve_memory)(struct rsvd_region *region); |
| 67 | |
| 68 | void (*arch_setup_early)(void); |
| 69 | void (*arch_setup_console)(char **cmdline_p); |
| 70 | int (*arch_setup_nomca)(void); |
| 71 | |
| 72 | void (*post_smp_prepare_boot_cpu)(void); |
| 73 | }; |
| 74 | |
| 75 | extern struct pv_init_ops pv_init_ops; |
| 76 | |
| 77 | static inline void paravirt_banner(void) |
| 78 | { |
| 79 | if (pv_init_ops.banner) |
| 80 | pv_init_ops.banner(); |
| 81 | } |
| 82 | |
| 83 | static inline int paravirt_reserve_memory(struct rsvd_region *region) |
| 84 | { |
| 85 | if (pv_init_ops.reserve_memory) |
| 86 | return pv_init_ops.reserve_memory(region); |
| 87 | return 0; |
| 88 | } |
| 89 | |
| 90 | static inline void paravirt_arch_setup_early(void) |
| 91 | { |
| 92 | if (pv_init_ops.arch_setup_early) |
| 93 | pv_init_ops.arch_setup_early(); |
| 94 | } |
| 95 | |
| 96 | static inline void paravirt_arch_setup_console(char **cmdline_p) |
| 97 | { |
| 98 | if (pv_init_ops.arch_setup_console) |
| 99 | pv_init_ops.arch_setup_console(cmdline_p); |
| 100 | } |
| 101 | |
| 102 | static inline int paravirt_arch_setup_nomca(void) |
| 103 | { |
| 104 | if (pv_init_ops.arch_setup_nomca) |
| 105 | return pv_init_ops.arch_setup_nomca(); |
| 106 | return 0; |
| 107 | } |
| 108 | |
| 109 | static inline void paravirt_post_smp_prepare_boot_cpu(void) |
| 110 | { |
| 111 | if (pv_init_ops.post_smp_prepare_boot_cpu) |
| 112 | pv_init_ops.post_smp_prepare_boot_cpu(); |
| 113 | } |
| 114 | |
Isaku Yamahata | 33b39e8 | 2008-05-19 22:13:42 +0900 | [diff] [blame] | 115 | /****************************************************************************** |
| 116 | * replacement of iosapic operations. |
| 117 | */ |
| 118 | |
| 119 | struct pv_iosapic_ops { |
| 120 | void (*pcat_compat_init)(void); |
| 121 | |
| 122 | struct irq_chip *(*get_irq_chip)(unsigned long trigger); |
| 123 | |
| 124 | unsigned int (*__read)(char __iomem *iosapic, unsigned int reg); |
| 125 | void (*__write)(char __iomem *iosapic, unsigned int reg, u32 val); |
| 126 | }; |
| 127 | |
| 128 | extern struct pv_iosapic_ops pv_iosapic_ops; |
| 129 | |
| 130 | static inline void |
| 131 | iosapic_pcat_compat_init(void) |
| 132 | { |
| 133 | if (pv_iosapic_ops.pcat_compat_init) |
| 134 | pv_iosapic_ops.pcat_compat_init(); |
| 135 | } |
| 136 | |
| 137 | static inline struct irq_chip* |
| 138 | iosapic_get_irq_chip(unsigned long trigger) |
| 139 | { |
| 140 | return pv_iosapic_ops.get_irq_chip(trigger); |
| 141 | } |
| 142 | |
| 143 | static inline unsigned int |
| 144 | __iosapic_read(char __iomem *iosapic, unsigned int reg) |
| 145 | { |
| 146 | return pv_iosapic_ops.__read(iosapic, reg); |
| 147 | } |
| 148 | |
| 149 | static inline void |
| 150 | __iosapic_write(char __iomem *iosapic, unsigned int reg, u32 val) |
| 151 | { |
| 152 | return pv_iosapic_ops.__write(iosapic, reg, val); |
| 153 | } |
| 154 | |
Isaku Yamahata | 85cbc50 | 2008-05-19 22:13:43 +0900 | [diff] [blame] | 155 | /****************************************************************************** |
| 156 | * replacement of irq operations. |
| 157 | */ |
| 158 | |
| 159 | struct pv_irq_ops { |
| 160 | void (*register_ipi)(void); |
| 161 | |
| 162 | int (*assign_irq_vector)(int irq); |
| 163 | void (*free_irq_vector)(int vector); |
| 164 | |
| 165 | void (*register_percpu_irq)(ia64_vector vec, |
| 166 | struct irqaction *action); |
| 167 | |
| 168 | void (*resend_irq)(unsigned int vector); |
| 169 | }; |
| 170 | |
| 171 | extern struct pv_irq_ops pv_irq_ops; |
| 172 | |
| 173 | static inline void |
| 174 | ia64_register_ipi(void) |
| 175 | { |
| 176 | pv_irq_ops.register_ipi(); |
| 177 | } |
| 178 | |
| 179 | static inline int |
| 180 | assign_irq_vector(int irq) |
| 181 | { |
| 182 | return pv_irq_ops.assign_irq_vector(irq); |
| 183 | } |
| 184 | |
| 185 | static inline void |
| 186 | free_irq_vector(int vector) |
| 187 | { |
| 188 | return pv_irq_ops.free_irq_vector(vector); |
| 189 | } |
| 190 | |
| 191 | static inline void |
| 192 | register_percpu_irq(ia64_vector vec, struct irqaction *action) |
| 193 | { |
| 194 | pv_irq_ops.register_percpu_irq(vec, action); |
| 195 | } |
| 196 | |
| 197 | static inline void |
| 198 | ia64_resend_irq(unsigned int vector) |
| 199 | { |
| 200 | pv_irq_ops.resend_irq(vector); |
| 201 | } |
| 202 | |
Isaku Yamahata | 00d21d8 | 2008-05-19 22:13:44 +0900 | [diff] [blame] | 203 | /****************************************************************************** |
| 204 | * replacement of time operations. |
| 205 | */ |
| 206 | |
| 207 | extern struct itc_jitter_data_t itc_jitter_data; |
| 208 | extern volatile int time_keeper_id; |
| 209 | |
| 210 | struct pv_time_ops { |
| 211 | void (*init_missing_ticks_accounting)(int cpu); |
| 212 | int (*do_steal_accounting)(unsigned long *new_itm); |
| 213 | |
| 214 | void (*clocksource_resume)(void); |
| 215 | }; |
| 216 | |
| 217 | extern struct pv_time_ops pv_time_ops; |
| 218 | |
| 219 | static inline void |
| 220 | paravirt_init_missing_ticks_accounting(int cpu) |
| 221 | { |
| 222 | if (pv_time_ops.init_missing_ticks_accounting) |
| 223 | pv_time_ops.init_missing_ticks_accounting(cpu); |
| 224 | } |
| 225 | |
| 226 | static inline int |
| 227 | paravirt_do_steal_accounting(unsigned long *new_itm) |
| 228 | { |
| 229 | return pv_time_ops.do_steal_accounting(new_itm); |
| 230 | } |
| 231 | |
Isaku Yamahata | 90aeb16 | 2008-05-19 22:13:32 +0900 | [diff] [blame] | 232 | #endif /* !__ASSEMBLY__ */ |
| 233 | |
| 234 | #else |
| 235 | /* fallback for native case */ |
| 236 | |
Isaku Yamahata | e51835d | 2008-05-19 22:13:41 +0900 | [diff] [blame] | 237 | #ifndef __ASSEMBLY__ |
| 238 | |
| 239 | #define paravirt_banner() do { } while (0) |
| 240 | #define paravirt_reserve_memory(region) 0 |
| 241 | |
| 242 | #define paravirt_arch_setup_early() do { } while (0) |
| 243 | #define paravirt_arch_setup_console(cmdline_p) do { } while (0) |
| 244 | #define paravirt_arch_setup_nomca() 0 |
| 245 | #define paravirt_post_smp_prepare_boot_cpu() do { } while (0) |
| 246 | |
Isaku Yamahata | 00d21d8 | 2008-05-19 22:13:44 +0900 | [diff] [blame] | 247 | #define paravirt_init_missing_ticks_accounting(cpu) do { } while (0) |
| 248 | #define paravirt_do_steal_accounting(new_itm) 0 |
| 249 | |
Isaku Yamahata | e51835d | 2008-05-19 22:13:41 +0900 | [diff] [blame] | 250 | #endif /* __ASSEMBLY__ */ |
| 251 | |
| 252 | |
Isaku Yamahata | 90aeb16 | 2008-05-19 22:13:32 +0900 | [diff] [blame] | 253 | #endif /* CONFIG_PARAVIRT_GUEST */ |
| 254 | |
| 255 | #endif /* __ASM_PARAVIRT_H */ |