paravirt.h 6.3 KB

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