synchronousMemoryDatabase.h 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  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)(void *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. #ifndef ASM_SUPPORTED
  54. #define paravirt_ssm_i() pv_cpu_ops.ssm_i()
  55. #define paravirt_rsm_i() pv_cpu_ops.rsm_i()
  56. #define __paravirt_getreg() pv_cpu_ops.getreg()
  57. #endif
  58. /* mask for ia64_native_ssm/rsm() must be constant.("i" constraing).
  59. * static inline function doesn't satisfy it. */
  60. #define paravirt_ssm(mask) \
  61. do { \
  62. if ((mask) == IA64_PSR_I) \
  63. paravirt_ssm_i(); \
  64. else \
  65. ia64_native_ssm(mask); \
  66. } while (0)
  67. #define paravirt_rsm(mask) \
  68. do { \
  69. if ((mask) == IA64_PSR_I) \
  70. paravirt_rsm_i(); \
  71. else \
  72. ia64_native_rsm(mask); \
  73. } while (0)
  74. /* returned ip value should be the one in the caller,
  75. * not in __paravirt_getreg() */
  76. #define paravirt_getreg(reg) \
  77. ({ \
  78. unsigned long res; \
  79. if ((reg) == _IA64_REG_IP) \
  80. res = ia64_native_getreg(_IA64_REG_IP); \
  81. else \
  82. res = __paravirt_getreg(reg); \
  83. res; \
  84. })
  85. /******************************************************************************
  86. * replacement of hand written assembly codes.
  87. */
  88. struct pv_cpu_asm_switch {
  89. unsigned long switch_to;
  90. unsigned long leave_syscall;
  91. unsigned long work_processed_syscall;
  92. unsigned long leave_kernel;
  93. };
  94. void paravirt_cpu_asm_init(const struct pv_cpu_asm_switch *cpu_asm_switch);
  95. #endif /* __ASSEMBLY__ */
  96. #define IA64_PARAVIRT_ASM_FUNC(name) paravirt_ ## name
  97. #else
  98. /* fallback for native case */
  99. #define IA64_PARAVIRT_ASM_FUNC(name) ia64_native_ ## name
  100. #endif /* CONFIG_PARAVIRT */
  101. #if defined(CONFIG_PARAVIRT) && defined(ASM_SUPPORTED)
  102. #define paravirt_dv_serialize_data() ia64_dv_serialize_data()
  103. #else
  104. #define paravirt_dv_serialize_data() /* nothing */
  105. #endif
  106. /* these routines utilize privilege-sensitive or performance-sensitive
  107. * privileged instructions so the code must be replaced with
  108. * paravirtualized versions */
  109. #define ia64_switch_to IA64_PARAVIRT_ASM_FUNC(switch_to)
  110. #define ia64_leave_syscall IA64_PARAVIRT_ASM_FUNC(leave_syscall)
  111. #define ia64_work_processed_syscall \
  112. IA64_PARAVIRT_ASM_FUNC(work_processed_syscall)
  113. #define ia64_leave_kernel IA64_PARAVIRT_ASM_FUNC(leave_kernel)
  114. #if defined(CONFIG_PARAVIRT)
  115. /******************************************************************************
  116. * binary patching infrastructure
  117. */
  118. #define PARAVIRT_PATCH_TYPE_FC 1
  119. #define PARAVIRT_PATCH_TYPE_THASH 2
  120. #define PARAVIRT_PATCH_TYPE_GET_CPUID 3
  121. #define PARAVIRT_PATCH_TYPE_GET_PMD 4
  122. #define PARAVIRT_PATCH_TYPE_PTCGA 5
  123. #define PARAVIRT_PATCH_TYPE_GET_RR 6
  124. #define PARAVIRT_PATCH_TYPE_SET_RR 7
  125. #define PARAVIRT_PATCH_TYPE_SET_RR0_TO_RR4 8
  126. #define PARAVIRT_PATCH_TYPE_SSM_I 9
  127. #define PARAVIRT_PATCH_TYPE_RSM_I 10
  128. #define PARAVIRT_PATCH_TYPE_GET_PSR_I 11
  129. #define PARAVIRT_PATCH_TYPE_INTRIN_LOCAL_IRQ_RESTORE 12
  130. /* PARAVIRT_PATY_TYPE_[GS]ETREG + _IA64_REG_xxx */
  131. #define PARAVIRT_PATCH_TYPE_GETREG 0x10000000
  132. #define PARAVIRT_PATCH_TYPE_SETREG 0x20000000
  133. /*
  134. * struct task_struct* (*ia64_switch_to)(void* next_task);
  135. * void *ia64_leave_syscall;
  136. * void *ia64_work_processed_syscall
  137. * void *ia64_leave_kernel;
  138. */
  139. #define PARAVIRT_PATCH_TYPE_BR_START 0x30000000
  140. #define PARAVIRT_PATCH_TYPE_BR_SWITCH_TO \
  141. (PARAVIRT_PATCH_TYPE_BR_START + 0)
  142. #define PARAVIRT_PATCH_TYPE_BR_LEAVE_SYSCALL \
  143. (PARAVIRT_PATCH_TYPE_BR_START + 1)
  144. #define PARAVIRT_PATCH_TYPE_BR_WORK_PROCESSED_SYSCALL \
  145. (PARAVIRT_PATCH_TYPE_BR_START + 2)