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 | |
Isaku Yamahata | dd97d5c | 2009-03-04 21:05:34 +0900 | [diff] [blame^] | 25 | #ifndef __ASSEMBLY__ |
| 26 | /****************************************************************************** |
| 27 | * fsys related addresses |
| 28 | */ |
| 29 | struct pv_fsys_data { |
| 30 | unsigned long *fsyscall_table; |
| 31 | void *fsys_bubble_down; |
| 32 | }; |
| 33 | |
| 34 | extern struct pv_fsys_data pv_fsys_data; |
| 35 | |
| 36 | unsigned long *paravirt_get_fsyscall_table(void); |
| 37 | char *paravirt_get_fsys_bubble_down(void); |
| 38 | #endif |
| 39 | |
Isaku Yamahata | 90aeb16 | 2008-05-19 22:13:32 +0900 | [diff] [blame] | 40 | #ifdef CONFIG_PARAVIRT_GUEST |
| 41 | |
Isaku Yamahata | 3e0879d | 2008-05-19 22:13:33 +0900 | [diff] [blame] | 42 | #define PARAVIRT_HYPERVISOR_TYPE_DEFAULT 0 |
| 43 | #define PARAVIRT_HYPERVISOR_TYPE_XEN 1 |
| 44 | |
Isaku Yamahata | 90aeb16 | 2008-05-19 22:13:32 +0900 | [diff] [blame] | 45 | #ifndef __ASSEMBLY__ |
| 46 | |
| 47 | #include <asm/hw_irq.h> |
| 48 | #include <asm/meminit.h> |
| 49 | |
| 50 | /****************************************************************************** |
| 51 | * general info |
| 52 | */ |
| 53 | struct pv_info { |
| 54 | unsigned int kernel_rpl; |
| 55 | int paravirt_enabled; |
| 56 | const char *name; |
| 57 | }; |
| 58 | |
| 59 | extern struct pv_info pv_info; |
| 60 | |
| 61 | static inline int paravirt_enabled(void) |
| 62 | { |
| 63 | return pv_info.paravirt_enabled; |
| 64 | } |
| 65 | |
| 66 | static inline unsigned int get_kernel_rpl(void) |
| 67 | { |
| 68 | return pv_info.kernel_rpl; |
| 69 | } |
| 70 | |
Isaku Yamahata | e51835d | 2008-05-19 22:13:41 +0900 | [diff] [blame] | 71 | /****************************************************************************** |
| 72 | * initialization hooks. |
| 73 | */ |
| 74 | struct rsvd_region; |
| 75 | |
| 76 | struct 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 | |
| 88 | extern struct pv_init_ops pv_init_ops; |
| 89 | |
| 90 | static inline void paravirt_banner(void) |
| 91 | { |
| 92 | if (pv_init_ops.banner) |
| 93 | pv_init_ops.banner(); |
| 94 | } |
| 95 | |
| 96 | static 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 | |
| 103 | static 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 | |
| 109 | static 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 | |
| 115 | static 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 | |
| 122 | static 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 Yamahata | 33b39e8 | 2008-05-19 22:13:42 +0900 | [diff] [blame] | 128 | /****************************************************************************** |
| 129 | * replacement of iosapic operations. |
| 130 | */ |
| 131 | |
| 132 | struct pv_iosapic_ops { |
| 133 | void (*pcat_compat_init)(void); |
| 134 | |
Isaku Yamahata | ce1fc74 | 2008-10-17 11:17:42 +0900 | [diff] [blame] | 135 | struct irq_chip *(*__get_irq_chip)(unsigned long trigger); |
Isaku Yamahata | 33b39e8 | 2008-05-19 22:13:42 +0900 | [diff] [blame] | 136 | |
| 137 | unsigned int (*__read)(char __iomem *iosapic, unsigned int reg); |
| 138 | void (*__write)(char __iomem *iosapic, unsigned int reg, u32 val); |
| 139 | }; |
| 140 | |
| 141 | extern struct pv_iosapic_ops pv_iosapic_ops; |
| 142 | |
| 143 | static inline void |
| 144 | iosapic_pcat_compat_init(void) |
| 145 | { |
| 146 | if (pv_iosapic_ops.pcat_compat_init) |
| 147 | pv_iosapic_ops.pcat_compat_init(); |
| 148 | } |
| 149 | |
| 150 | static inline struct irq_chip* |
| 151 | iosapic_get_irq_chip(unsigned long trigger) |
| 152 | { |
Isaku Yamahata | ce1fc74 | 2008-10-17 11:17:42 +0900 | [diff] [blame] | 153 | return pv_iosapic_ops.__get_irq_chip(trigger); |
Isaku Yamahata | 33b39e8 | 2008-05-19 22:13:42 +0900 | [diff] [blame] | 154 | } |
| 155 | |
| 156 | static inline unsigned int |
| 157 | __iosapic_read(char __iomem *iosapic, unsigned int reg) |
| 158 | { |
| 159 | return pv_iosapic_ops.__read(iosapic, reg); |
| 160 | } |
| 161 | |
| 162 | static 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 Yamahata | 85cbc50 | 2008-05-19 22:13:43 +0900 | [diff] [blame] | 168 | /****************************************************************************** |
| 169 | * replacement of irq operations. |
| 170 | */ |
| 171 | |
| 172 | struct 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 | |
| 184 | extern struct pv_irq_ops pv_irq_ops; |
| 185 | |
| 186 | static inline void |
| 187 | ia64_register_ipi(void) |
| 188 | { |
| 189 | pv_irq_ops.register_ipi(); |
| 190 | } |
| 191 | |
| 192 | static inline int |
| 193 | assign_irq_vector(int irq) |
| 194 | { |
| 195 | return pv_irq_ops.assign_irq_vector(irq); |
| 196 | } |
| 197 | |
| 198 | static inline void |
| 199 | free_irq_vector(int vector) |
| 200 | { |
| 201 | return pv_irq_ops.free_irq_vector(vector); |
| 202 | } |
| 203 | |
| 204 | static inline void |
| 205 | register_percpu_irq(ia64_vector vec, struct irqaction *action) |
| 206 | { |
| 207 | pv_irq_ops.register_percpu_irq(vec, action); |
| 208 | } |
| 209 | |
| 210 | static inline void |
| 211 | ia64_resend_irq(unsigned int vector) |
| 212 | { |
| 213 | pv_irq_ops.resend_irq(vector); |
| 214 | } |
| 215 | |
Isaku Yamahata | 00d21d8 | 2008-05-19 22:13:44 +0900 | [diff] [blame] | 216 | /****************************************************************************** |
| 217 | * replacement of time operations. |
| 218 | */ |
| 219 | |
| 220 | extern struct itc_jitter_data_t itc_jitter_data; |
| 221 | extern volatile int time_keeper_id; |
| 222 | |
| 223 | struct 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); |
| 228 | }; |
| 229 | |
| 230 | extern struct pv_time_ops pv_time_ops; |
| 231 | |
| 232 | static inline void |
| 233 | paravirt_init_missing_ticks_accounting(int cpu) |
| 234 | { |
| 235 | if (pv_time_ops.init_missing_ticks_accounting) |
| 236 | pv_time_ops.init_missing_ticks_accounting(cpu); |
| 237 | } |
| 238 | |
| 239 | static inline int |
| 240 | paravirt_do_steal_accounting(unsigned long *new_itm) |
| 241 | { |
| 242 | return pv_time_ops.do_steal_accounting(new_itm); |
| 243 | } |
| 244 | |
Isaku Yamahata | 90aeb16 | 2008-05-19 22:13:32 +0900 | [diff] [blame] | 245 | #endif /* !__ASSEMBLY__ */ |
| 246 | |
| 247 | #else |
| 248 | /* fallback for native case */ |
| 249 | |
Isaku Yamahata | e51835d | 2008-05-19 22:13:41 +0900 | [diff] [blame] | 250 | #ifndef __ASSEMBLY__ |
| 251 | |
| 252 | #define paravirt_banner() do { } while (0) |
| 253 | #define paravirt_reserve_memory(region) 0 |
| 254 | |
| 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) |
| 259 | |
Isaku Yamahata | 00d21d8 | 2008-05-19 22:13:44 +0900 | [diff] [blame] | 260 | #define paravirt_init_missing_ticks_accounting(cpu) do { } while (0) |
| 261 | #define paravirt_do_steal_accounting(new_itm) 0 |
| 262 | |
Isaku Yamahata | e51835d | 2008-05-19 22:13:41 +0900 | [diff] [blame] | 263 | #endif /* __ASSEMBLY__ */ |
| 264 | |
| 265 | |
Isaku Yamahata | 90aeb16 | 2008-05-19 22:13:32 +0900 | [diff] [blame] | 266 | #endif /* CONFIG_PARAVIRT_GUEST */ |
| 267 | |
| 268 | #endif /* __ASM_PARAVIRT_H */ |