paravirt_privop.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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_IA64_PARAVIRT_PRIVOP_H
  21. #define _ASM_IA64_PARAVIRT_PRIVOP_H
  22. #ifdef CONFIG_PARAVIRT
  23. #ifndef __ASSEMBLY__
  24. #include <linux/types.h>
  25. #include <asm/kregs.h> /* for IA64_PSR_I */
  26. /******************************************************************************
  27. * replacement of intrinsics operations.
  28. */
  29. struct pv_cpu_ops {
  30. void (*fc)(unsigned long addr);
  31. unsigned long (*thash)(unsigned long addr);
  32. unsigned long (*get_cpuid)(int index);
  33. unsigned long (*get_pmd)(int index);
  34. unsigned long (*getreg)(int reg);
  35. void (*setreg)(int reg, unsigned long val);
  36. void (*ptcga)(unsigned long addr, unsigned long size);
  37. unsigned long (*get_rr)(unsigned long index);
  38. void (*set_rr)(unsigned long index, unsigned long val);
  39. void (*set_rr0_to_rr4)(unsigned long val0, unsigned long val1,
  40. unsigned long val2, unsigned long val3,
  41. unsigned long val4);
  42. void (*ssm_i)(void);
  43. void (*rsm_i)(void);
  44. unsigned long (*get_psr_i)(void);
  45. void (*intrin_local_irq_restore)(unsigned long flags);
  46. };
  47. extern struct pv_cpu_ops pv_cpu_ops;
  48. extern void ia64_native_setreg_func(int regnum, unsigned long val);
  49. extern unsigned long ia64_native_getreg_func(int regnum);
  50. /************************************************/
  51. /* Instructions paravirtualized for performance */
  52. /************************************************/
  53. /* mask for ia64_native_ssm/rsm() must be constant.("i" constraing).
  54. * static inline function doesn't satisfy it. */
  55. #define paravirt_ssm(mask) \
  56. do { \
  57. if ((mask) == IA64_PSR_I) \
  58. pv_cpu_ops.ssm_i(); \
  59. else \
  60. ia64_native_ssm(mask); \
  61. } while (0)
  62. #define paravirt_rsm(mask) \
  63. do { \
  64. if ((mask) == IA64_PSR_I) \
  65. pv_cpu_ops.rsm_i(); \
  66. else \
  67. ia64_native_rsm(mask); \
  68. } while (0)
  69. /******************************************************************************
  70. * replacement of hand written assembly codes.
  71. */
  72. struct pv_cpu_asm_switch {
  73. unsigned long switch_to;
  74. unsigned long leave_syscall;
  75. unsigned long work_processed_syscall;
  76. unsigned long leave_kernel;
  77. };
  78. void paravirt_cpu_asm_init(const struct pv_cpu_asm_switch *cpu_asm_switch);
  79. #endif /* __ASSEMBLY__ */
  80. #define IA64_PARAVIRT_ASM_FUNC(name) paravirt_ ## name
  81. #else
  82. /* fallback for native case */
  83. #define IA64_PARAVIRT_ASM_FUNC(name) ia64_native_ ## name
  84. #endif /* CONFIG_PARAVIRT */
  85. /* these routines utilize privilege-sensitive or performance-sensitive
  86. * privileged instructions so the code must be replaced with
  87. * paravirtualized versions */
  88. #define ia64_switch_to IA64_PARAVIRT_ASM_FUNC(switch_to)
  89. #define ia64_leave_syscall IA64_PARAVIRT_ASM_FUNC(leave_syscall)
  90. #define ia64_work_processed_syscall \
  91. IA64_PARAVIRT_ASM_FUNC(work_processed_syscall)
  92. #define ia64_leave_kernel IA64_PARAVIRT_ASM_FUNC(leave_kernel)
  93. #endif /* _ASM_IA64_PARAVIRT_PRIVOP_H */