Isaku Yamahata | 90aeb16 | 2008-05-19 22:13:32 +0900 | [diff] [blame] | 1 | /****************************************************************************** |
Isaku Yamahata | 90aeb16 | 2008-05-19 22:13:32 +0900 | [diff] [blame] | 2 | * 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 Yamahata | 3e0879d | 2008-05-19 22:13:33 +0900 | [diff] [blame] | 27 | #define PARAVIRT_HYPERVISOR_TYPE_DEFAULT 0 |
| 28 | #define PARAVIRT_HYPERVISOR_TYPE_XEN 1 |
| 29 | |
Isaku Yamahata | 90aeb16 | 2008-05-19 22:13:32 +0900 | [diff] [blame] | 30 | #ifndef __ASSEMBLY__ |
| 31 | |
| 32 | #include <asm/hw_irq.h> |
| 33 | #include <asm/meminit.h> |
| 34 | |
| 35 | /****************************************************************************** |
| 36 | * general info |
| 37 | */ |
| 38 | struct pv_info { |
| 39 | unsigned int kernel_rpl; |
| 40 | int paravirt_enabled; |
| 41 | const char *name; |
| 42 | }; |
| 43 | |
| 44 | extern struct pv_info pv_info; |
| 45 | |
| 46 | static inline int paravirt_enabled(void) |
| 47 | { |
| 48 | return pv_info.paravirt_enabled; |
| 49 | } |
| 50 | |
| 51 | static inline unsigned int get_kernel_rpl(void) |
| 52 | { |
| 53 | return pv_info.kernel_rpl; |
| 54 | } |
| 55 | |
Isaku Yamahata | e51835d | 2008-05-19 22:13:41 +0900 | [diff] [blame] | 56 | /****************************************************************************** |
| 57 | * initialization hooks. |
| 58 | */ |
| 59 | struct rsvd_region; |
| 60 | |
| 61 | struct 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 | |
| 73 | extern struct pv_init_ops pv_init_ops; |
| 74 | |
| 75 | static inline void paravirt_banner(void) |
| 76 | { |
| 77 | if (pv_init_ops.banner) |
| 78 | pv_init_ops.banner(); |
| 79 | } |
| 80 | |
| 81 | static 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 | |
| 88 | static 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 | |
| 94 | static 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 | |
| 100 | static 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 | |
| 107 | static 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 Yamahata | 33b39e8 | 2008-05-19 22:13:42 +0900 | [diff] [blame] | 113 | /****************************************************************************** |
| 114 | * replacement of iosapic operations. |
| 115 | */ |
| 116 | |
| 117 | struct pv_iosapic_ops { |
| 118 | void (*pcat_compat_init)(void); |
| 119 | |
Isaku Yamahata | ce1fc74 | 2008-10-17 11:17:42 +0900 | [diff] [blame] | 120 | struct irq_chip *(*__get_irq_chip)(unsigned long trigger); |
Isaku Yamahata | 33b39e8 | 2008-05-19 22:13:42 +0900 | [diff] [blame] | 121 | |
| 122 | unsigned int (*__read)(char __iomem *iosapic, unsigned int reg); |
| 123 | void (*__write)(char __iomem *iosapic, unsigned int reg, u32 val); |
| 124 | }; |
| 125 | |
| 126 | extern struct pv_iosapic_ops pv_iosapic_ops; |
| 127 | |
| 128 | static inline void |
| 129 | iosapic_pcat_compat_init(void) |
| 130 | { |
| 131 | if (pv_iosapic_ops.pcat_compat_init) |
| 132 | pv_iosapic_ops.pcat_compat_init(); |
| 133 | } |
| 134 | |
| 135 | static inline struct irq_chip* |
| 136 | iosapic_get_irq_chip(unsigned long trigger) |
| 137 | { |
Isaku Yamahata | ce1fc74 | 2008-10-17 11:17:42 +0900 | [diff] [blame] | 138 | return pv_iosapic_ops.__get_irq_chip(trigger); |
Isaku Yamahata | 33b39e8 | 2008-05-19 22:13:42 +0900 | [diff] [blame] | 139 | } |
| 140 | |
| 141 | static inline unsigned int |
| 142 | __iosapic_read(char __iomem *iosapic, unsigned int reg) |
| 143 | { |
| 144 | return pv_iosapic_ops.__read(iosapic, reg); |
| 145 | } |
| 146 | |
| 147 | static 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 Yamahata | 85cbc50 | 2008-05-19 22:13:43 +0900 | [diff] [blame] | 153 | /****************************************************************************** |
| 154 | * replacement of irq operations. |
| 155 | */ |
| 156 | |
| 157 | struct 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 | |
| 169 | extern struct pv_irq_ops pv_irq_ops; |
| 170 | |
| 171 | static inline void |
| 172 | ia64_register_ipi(void) |
| 173 | { |
| 174 | pv_irq_ops.register_ipi(); |
| 175 | } |
| 176 | |
| 177 | static inline int |
| 178 | assign_irq_vector(int irq) |
| 179 | { |
| 180 | return pv_irq_ops.assign_irq_vector(irq); |
| 181 | } |
| 182 | |
| 183 | static inline void |
| 184 | free_irq_vector(int vector) |
| 185 | { |
| 186 | return pv_irq_ops.free_irq_vector(vector); |
| 187 | } |
| 188 | |
| 189 | static inline void |
| 190 | register_percpu_irq(ia64_vector vec, struct irqaction *action) |
| 191 | { |
| 192 | pv_irq_ops.register_percpu_irq(vec, action); |
| 193 | } |
| 194 | |
| 195 | static inline void |
| 196 | ia64_resend_irq(unsigned int vector) |
| 197 | { |
| 198 | pv_irq_ops.resend_irq(vector); |
| 199 | } |
| 200 | |
Isaku Yamahata | 00d21d8 | 2008-05-19 22:13:44 +0900 | [diff] [blame] | 201 | /****************************************************************************** |
| 202 | * replacement of time operations. |
| 203 | */ |
| 204 | |
| 205 | extern struct itc_jitter_data_t itc_jitter_data; |
| 206 | extern volatile int time_keeper_id; |
| 207 | |
| 208 | struct 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 | |
| 215 | extern struct pv_time_ops pv_time_ops; |
| 216 | |
| 217 | static inline void |
| 218 | paravirt_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 | |
| 224 | static inline int |
| 225 | paravirt_do_steal_accounting(unsigned long *new_itm) |
| 226 | { |
| 227 | return pv_time_ops.do_steal_accounting(new_itm); |
| 228 | } |
| 229 | |
Isaku Yamahata | 90aeb16 | 2008-05-19 22:13:32 +0900 | [diff] [blame] | 230 | #endif /* !__ASSEMBLY__ */ |
| 231 | |
| 232 | #else |
| 233 | /* fallback for native case */ |
| 234 | |
Isaku Yamahata | e51835d | 2008-05-19 22:13:41 +0900 | [diff] [blame] | 235 | #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 Yamahata | 00d21d8 | 2008-05-19 22:13:44 +0900 | [diff] [blame] | 245 | #define paravirt_init_missing_ticks_accounting(cpu) do { } while (0) |
| 246 | #define paravirt_do_steal_accounting(new_itm) 0 |
| 247 | |
Isaku Yamahata | e51835d | 2008-05-19 22:13:41 +0900 | [diff] [blame] | 248 | #endif /* __ASSEMBLY__ */ |
| 249 | |
| 250 | |
Isaku Yamahata | 90aeb16 | 2008-05-19 22:13:32 +0900 | [diff] [blame] | 251 | #endif /* CONFIG_PARAVIRT_GUEST */ |
| 252 | |
| 253 | #endif /* __ASM_PARAVIRT_H */ |