paravirt.h 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318
  1. /******************************************************************************
  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. #ifndef __ASM_PARAVIRT_H
  21. #define __ASM_PARAVIRT_H
  22. #ifndef __ASSEMBLY__
  23. /******************************************************************************
  24. * fsys related addresses
  25. */
  26. struct pv_fsys_data {
  27. unsigned long *fsyscall_table;
  28. void *fsys_bubble_down;
  29. };
  30. extern struct pv_fsys_data pv_fsys_data;
  31. unsigned long *paravirt_get_fsyscall_table(void);
  32. char *paravirt_get_fsys_bubble_down(void);
  33. /******************************************************************************
  34. * patchlist addresses for gate page
  35. */
  36. enum pv_gate_patchlist {
  37. PV_GATE_START_FSYSCALL,
  38. PV_GATE_END_FSYSCALL,
  39. PV_GATE_START_BRL_FSYS_BUBBLE_DOWN,
  40. PV_GATE_END_BRL_FSYS_BUBBLE_DOWN,
  41. PV_GATE_START_VTOP,
  42. PV_GATE_END_VTOP,
  43. PV_GATE_START_MCKINLEY_E9,
  44. PV_GATE_END_MCKINLEY_E9,
  45. };
  46. struct pv_patchdata {
  47. unsigned long start_fsyscall_patchlist;
  48. unsigned long end_fsyscall_patchlist;
  49. unsigned long start_brl_fsys_bubble_down_patchlist;
  50. unsigned long end_brl_fsys_bubble_down_patchlist;
  51. unsigned long start_vtop_patchlist;
  52. unsigned long end_vtop_patchlist;
  53. unsigned long start_mckinley_e9_patchlist;
  54. unsigned long end_mckinley_e9_patchlist;
  55. void *gate_section;
  56. };
  57. extern struct pv_patchdata pv_patchdata;
  58. unsigned long paravirt_get_gate_patchlist(enum pv_gate_patchlist type);
  59. void *paravirt_get_gate_section(void);
  60. #endif
  61. #ifdef CONFIG_PARAVIRT_GUEST
  62. #define PARAVIRT_HYPERVISOR_TYPE_DEFAULT 0
  63. #define PARAVIRT_HYPERVISOR_TYPE_XEN 1
  64. #ifndef __ASSEMBLY__
  65. #include <asm/hw_irq.h>
  66. #include <asm/meminit.h>
  67. /******************************************************************************
  68. * general info
  69. */
  70. struct pv_info {
  71. unsigned int kernel_rpl;
  72. int paravirt_enabled;
  73. const char *name;
  74. };
  75. extern struct pv_info pv_info;
  76. static inline int paravirt_enabled(void)
  77. {
  78. return pv_info.paravirt_enabled;
  79. }
  80. static inline unsigned int get_kernel_rpl(void)
  81. {
  82. return pv_info.kernel_rpl;
  83. }
  84. /******************************************************************************
  85. * initialization hooks.
  86. */
  87. struct rsvd_region;
  88. struct pv_init_ops {
  89. void (*banner)(void);
  90. int (*reserve_memory)(struct rsvd_region *region);
  91. void (*arch_setup_early)(void);
  92. void (*arch_setup_console)(char **cmdline_p);
  93. int (*arch_setup_nomca)(void);
  94. void (*post_smp_prepare_boot_cpu)(void);
  95. #ifdef ASM_SUPPORTED
  96. unsigned long (*patch_bundle)(void *sbundle, void *ebundle,
  97. unsigned long type);
  98. unsigned long (*patch_inst)(unsigned long stag, unsigned long etag,
  99. unsigned long type);
  100. #endif
  101. void (*patch_branch)(unsigned long tag, unsigned long type);
  102. };
  103. extern struct pv_init_ops pv_init_ops;
  104. static inline void paravirt_banner(void)
  105. {
  106. if (pv_init_ops.banner)
  107. pv_init_ops.banner();
  108. }
  109. static inline int paravirt_reserve_memory(struct rsvd_region *region)
  110. {
  111. if (pv_init_ops.reserve_memory)
  112. return pv_init_ops.reserve_memory(region);
  113. return 0;
  114. }
  115. static inline void paravirt_arch_setup_early(void)
  116. {
  117. if (pv_init_ops.arch_setup_early)
  118. pv_init_ops.arch_setup_early();
  119. }
  120. static inline void paravirt_arch_setup_console(char **cmdline_p)
  121. {
  122. if (pv_init_ops.arch_setup_console)
  123. pv_init_ops.arch_setup_console(cmdline_p);
  124. }
  125. static inline int paravirt_arch_setup_nomca(void)
  126. {
  127. if (pv_init_ops.arch_setup_nomca)
  128. return pv_init_ops.arch_setup_nomca();
  129. return 0;
  130. }
  131. static inline void paravirt_post_smp_prepare_boot_cpu(void)
  132. {
  133. if (pv_init_ops.post_smp_prepare_boot_cpu)
  134. pv_init_ops.post_smp_prepare_boot_cpu();
  135. }
  136. /******************************************************************************
  137. * replacement of iosapic operations.
  138. */
  139. struct pv_iosapic_ops {
  140. void (*pcat_compat_init)(void);
  141. struct irq_chip *(*__get_irq_chip)(unsigned long trigger);
  142. unsigned int (*__read)(char __iomem *iosapic, unsigned int reg);
  143. void (*__write)(char __iomem *iosapic, unsigned int reg, u32 val);
  144. };
  145. extern struct pv_iosapic_ops pv_iosapic_ops;
  146. static inline void
  147. iosapic_pcat_compat_init(void)
  148. {
  149. if (pv_iosapic_ops.pcat_compat_init)
  150. pv_iosapic_ops.pcat_compat_init();
  151. }
  152. static inline struct irq_chip*
  153. iosapic_get_irq_chip(unsigned long trigger)
  154. {
  155. return pv_iosapic_ops.__get_irq_chip(trigger);
  156. }
  157. static inline unsigned int
  158. __iosapic_read(char __iomem *iosapic, unsigned int reg)
  159. {
  160. return pv_iosapic_ops.__read(iosapic, reg);
  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. /******************************************************************************
  168. * replacement of irq operations.
  169. */
  170. struct pv_irq_ops {
  171. void (*register_ipi)(void);
  172. int (*assign_irq_vector)(int irq);
  173. void (*free_irq_vector)(int vector);
  174. void (*register_percpu_irq)(ia64_vector vec,
  175. struct irqaction *action);
  176. void (*resend_irq)(unsigned int vector);
  177. };
  178. extern struct pv_irq_ops pv_irq_ops;
  179. static inline void
  180. ia64_register_ipi(void)
  181. {
  182. pv_irq_ops.register_ipi();
  183. }
  184. static inline int
  185. assign_irq_vector(int irq)
  186. {
  187. return pv_irq_ops.assign_irq_vector(irq);
  188. }
  189. static inline void
  190. free_irq_vector(int vector)
  191. {
  192. return pv_irq_ops.free_irq_vector(vector);
  193. }
  194. static inline void
  195. register_percpu_irq(ia64_vector vec, struct irqaction *action)
  196. {
  197. pv_irq_ops.register_percpu_irq(vec, action);
  198. }
  199. static inline void
  200. ia64_resend_irq(unsigned int vector)
  201. {
  202. pv_irq_ops.resend_irq(vector);
  203. }
  204. /******************************************************************************
  205. * replacement of time operations.
  206. */
  207. extern struct itc_jitter_data_t itc_jitter_data;
  208. extern volatile int time_keeper_id;
  209. struct pv_time_ops {
  210. void (*init_missing_ticks_accounting)(int cpu);
  211. int (*do_steal_accounting)(unsigned long *new_itm);
  212. void (*clocksource_resume)(void);
  213. unsigned long long (*sched_clock)(void);
  214. };
  215. extern struct pv_time_ops pv_time_ops;
  216. static inline void
  217. paravirt_init_missing_ticks_accounting(int cpu)
  218. {
  219. if (pv_time_ops.init_missing_ticks_accounting)
  220. pv_time_ops.init_missing_ticks_accounting(cpu);
  221. }
  222. static inline int
  223. paravirt_do_steal_accounting(unsigned long *new_itm)
  224. {
  225. return pv_time_ops.do_steal_accounting(new_itm);
  226. }
  227. static inline unsigned long long paravirt_sched_clock(void)
  228. {
  229. return pv_time_ops.sched_clock();
  230. }
  231. #endif /* !__ASSEMBLY__ */
  232. #else
  233. /* fallback for native case */
  234. #ifndef __ASSEMBLY__
  235. #define paravirt_banner() do { } while (0)
  236. #define paravirt_reserve_memory(region) 0
  237. #define paravirt_arch_setup_early() do { } while (0)
  238. #define paravirt_arch_setup_console(cmdline_p) do { } while (0)
  239. #define paravirt_arch_setup_nomca() 0
  240. #define paravirt_post_smp_prepare_boot_cpu() do { } while (0)
  241. #define paravirt_init_missing_ticks_accounting(cpu) do { } while (0)
  242. #define paravirt_do_steal_accounting(new_itm) 0
  243. #endif /* __ASSEMBLY__ */
  244. #endif /* CONFIG_PARAVIRT_GUEST */
  245. #endif /* __ASM_PARAVIRT_H */