paravirt.h 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  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. #ifndef __ASM_PARAVIRT_H
  23. #define __ASM_PARAVIRT_H
  24. #ifdef CONFIG_PARAVIRT_GUEST
  25. #define PARAVIRT_HYPERVISOR_TYPE_DEFAULT 0
  26. #define PARAVIRT_HYPERVISOR_TYPE_XEN 1
  27. #ifndef __ASSEMBLY__
  28. #include <asm/hw_irq.h>
  29. #include <asm/meminit.h>
  30. /******************************************************************************
  31. * general info
  32. */
  33. struct pv_info {
  34. unsigned int kernel_rpl;
  35. int paravirt_enabled;
  36. const char *name;
  37. };
  38. extern struct pv_info pv_info;
  39. static inline int paravirt_enabled(void)
  40. {
  41. return pv_info.paravirt_enabled;
  42. }
  43. static inline unsigned int get_kernel_rpl(void)
  44. {
  45. return pv_info.kernel_rpl;
  46. }
  47. /******************************************************************************
  48. * initialization hooks.
  49. */
  50. struct rsvd_region;
  51. struct pv_init_ops {
  52. void (*banner)(void);
  53. int (*reserve_memory)(struct rsvd_region *region);
  54. void (*arch_setup_early)(void);
  55. void (*arch_setup_console)(char **cmdline_p);
  56. int (*arch_setup_nomca)(void);
  57. void (*post_smp_prepare_boot_cpu)(void);
  58. };
  59. extern struct pv_init_ops pv_init_ops;
  60. static inline void paravirt_banner(void)
  61. {
  62. if (pv_init_ops.banner)
  63. pv_init_ops.banner();
  64. }
  65. static inline int paravirt_reserve_memory(struct rsvd_region *region)
  66. {
  67. if (pv_init_ops.reserve_memory)
  68. return pv_init_ops.reserve_memory(region);
  69. return 0;
  70. }
  71. static inline void paravirt_arch_setup_early(void)
  72. {
  73. if (pv_init_ops.arch_setup_early)
  74. pv_init_ops.arch_setup_early();
  75. }
  76. static inline void paravirt_arch_setup_console(char **cmdline_p)
  77. {
  78. if (pv_init_ops.arch_setup_console)
  79. pv_init_ops.arch_setup_console(cmdline_p);
  80. }
  81. static inline int paravirt_arch_setup_nomca(void)
  82. {
  83. if (pv_init_ops.arch_setup_nomca)
  84. return pv_init_ops.arch_setup_nomca();
  85. return 0;
  86. }
  87. static inline void paravirt_post_smp_prepare_boot_cpu(void)
  88. {
  89. if (pv_init_ops.post_smp_prepare_boot_cpu)
  90. pv_init_ops.post_smp_prepare_boot_cpu();
  91. }
  92. /******************************************************************************
  93. * replacement of iosapic operations.
  94. */
  95. struct pv_iosapic_ops {
  96. void (*pcat_compat_init)(void);
  97. struct irq_chip *(*get_irq_chip)(unsigned long trigger);
  98. unsigned int (*__read)(char __iomem *iosapic, unsigned int reg);
  99. void (*__write)(char __iomem *iosapic, unsigned int reg, u32 val);
  100. };
  101. extern struct pv_iosapic_ops pv_iosapic_ops;
  102. static inline void
  103. iosapic_pcat_compat_init(void)
  104. {
  105. if (pv_iosapic_ops.pcat_compat_init)
  106. pv_iosapic_ops.pcat_compat_init();
  107. }
  108. static inline struct irq_chip*
  109. iosapic_get_irq_chip(unsigned long trigger)
  110. {
  111. return pv_iosapic_ops.get_irq_chip(trigger);
  112. }
  113. static inline unsigned int
  114. __iosapic_read(char __iomem *iosapic, unsigned int reg)
  115. {
  116. return pv_iosapic_ops.__read(iosapic, reg);
  117. }
  118. static inline void
  119. __iosapic_write(char __iomem *iosapic, unsigned int reg, u32 val)
  120. {
  121. return pv_iosapic_ops.__write(iosapic, reg, val);
  122. }
  123. /******************************************************************************
  124. * replacement of irq operations.
  125. */
  126. struct pv_irq_ops {
  127. void (*register_ipi)(void);
  128. int (*assign_irq_vector)(int irq);
  129. void (*free_irq_vector)(int vector);
  130. void (*register_percpu_irq)(ia64_vector vec,
  131. struct irqaction *action);
  132. void (*resend_irq)(unsigned int vector);
  133. };
  134. extern struct pv_irq_ops pv_irq_ops;
  135. static inline void
  136. ia64_register_ipi(void)
  137. {
  138. pv_irq_ops.register_ipi();
  139. }
  140. static inline int
  141. assign_irq_vector(int irq)
  142. {
  143. return pv_irq_ops.assign_irq_vector(irq);
  144. }
  145. static inline void
  146. free_irq_vector(int vector)
  147. {
  148. return pv_irq_ops.free_irq_vector(vector);
  149. }
  150. static inline void
  151. register_percpu_irq(ia64_vector vec, struct irqaction *action)
  152. {
  153. pv_irq_ops.register_percpu_irq(vec, action);
  154. }
  155. static inline void
  156. ia64_resend_irq(unsigned int vector)
  157. {
  158. pv_irq_ops.resend_irq(vector);
  159. }
  160. /******************************************************************************
  161. * replacement of time operations.
  162. */
  163. extern struct itc_jitter_data_t itc_jitter_data;
  164. extern volatile int time_keeper_id;
  165. struct pv_time_ops {
  166. void (*init_missing_ticks_accounting)(int cpu);
  167. int (*do_steal_accounting)(unsigned long *new_itm);
  168. void (*clocksource_resume)(void);
  169. };
  170. extern struct pv_time_ops pv_time_ops;
  171. static inline void
  172. paravirt_init_missing_ticks_accounting(int cpu)
  173. {
  174. if (pv_time_ops.init_missing_ticks_accounting)
  175. pv_time_ops.init_missing_ticks_accounting(cpu);
  176. }
  177. static inline int
  178. paravirt_do_steal_accounting(unsigned long *new_itm)
  179. {
  180. return pv_time_ops.do_steal_accounting(new_itm);
  181. }
  182. #endif /* !__ASSEMBLY__ */
  183. #else
  184. /* fallback for native case */
  185. #ifndef __ASSEMBLY__
  186. #define paravirt_banner() do { } while (0)
  187. #define paravirt_reserve_memory(region) 0
  188. #define paravirt_arch_setup_early() do { } while (0)
  189. #define paravirt_arch_setup_console(cmdline_p) do { } while (0)
  190. #define paravirt_arch_setup_nomca() 0
  191. #define paravirt_post_smp_prepare_boot_cpu() do { } while (0)
  192. #define paravirt_init_missing_ticks_accounting(cpu) do { } while (0)
  193. #define paravirt_do_steal_accounting(new_itm) 0
  194. #endif /* __ASSEMBLY__ */
  195. #endif /* CONFIG_PARAVIRT_GUEST */
  196. #endif /* __ASM_PARAVIRT_H */