registers.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  1. /*
  2. * Register definitions for the Hexagon architecture
  3. *
  4. * Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved.
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License version 2 and
  8. * only version 2 as published by the Free Software Foundation.
  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., 51 Franklin Street, Fifth Floor, Boston, MA
  18. * 02110-1301, USA.
  19. */
  20. #ifndef _ASM_REGISTERS_H
  21. #define _ASM_REGISTERS_H
  22. #define SP r29
  23. #ifndef __ASSEMBLY__
  24. /* See kernel/entry.S for further documentation. */
  25. /*
  26. * Entry code copies the event record out of guest registers into
  27. * this structure (which is on the stack).
  28. */
  29. struct hvm_event_record {
  30. unsigned long vmel; /* Event Linkage (return address) */
  31. unsigned long vmest; /* Event context - pre-event SSR values */
  32. unsigned long vmpsp; /* Previous stack pointer */
  33. unsigned long vmbadva; /* Bad virtual address for addressing events */
  34. };
  35. struct pt_regs {
  36. long restart_r0; /* R0 checkpoint for syscall restart */
  37. long syscall_nr; /* Only used in system calls */
  38. union {
  39. struct {
  40. unsigned long usr;
  41. unsigned long preds;
  42. };
  43. long long int predsusr;
  44. };
  45. union {
  46. struct {
  47. unsigned long m0;
  48. unsigned long m1;
  49. };
  50. long long int m1m0;
  51. };
  52. union {
  53. struct {
  54. unsigned long sa1;
  55. unsigned long lc1;
  56. };
  57. long long int lc1sa1;
  58. };
  59. union {
  60. struct {
  61. unsigned long sa0;
  62. unsigned long lc0;
  63. };
  64. long long int lc0sa0;
  65. };
  66. union {
  67. struct {
  68. unsigned long gp;
  69. unsigned long ugp;
  70. };
  71. long long int ugpgp;
  72. };
  73. /*
  74. * Be extremely careful with rearranging these, if at all. Some code
  75. * assumes the 32 registers exist exactly like this in memory;
  76. * e.g. kernel/ptrace.c
  77. * e.g. kernel/signal.c (restore_sigcontext)
  78. */
  79. union {
  80. struct {
  81. unsigned long r00;
  82. unsigned long r01;
  83. };
  84. long long int r0100;
  85. };
  86. union {
  87. struct {
  88. unsigned long r02;
  89. unsigned long r03;
  90. };
  91. long long int r0302;
  92. };
  93. union {
  94. struct {
  95. unsigned long r04;
  96. unsigned long r05;
  97. };
  98. long long int r0504;
  99. };
  100. union {
  101. struct {
  102. unsigned long r06;
  103. unsigned long r07;
  104. };
  105. long long int r0706;
  106. };
  107. union {
  108. struct {
  109. unsigned long r08;
  110. unsigned long r09;
  111. };
  112. long long int r0908;
  113. };
  114. union {
  115. struct {
  116. unsigned long r10;
  117. unsigned long r11;
  118. };
  119. long long int r1110;
  120. };
  121. union {
  122. struct {
  123. unsigned long r12;
  124. unsigned long r13;
  125. };
  126. long long int r1312;
  127. };
  128. union {
  129. struct {
  130. unsigned long r14;
  131. unsigned long r15;
  132. };
  133. long long int r1514;
  134. };
  135. union {
  136. struct {
  137. unsigned long r16;
  138. unsigned long r17;
  139. };
  140. long long int r1716;
  141. };
  142. union {
  143. struct {
  144. unsigned long r18;
  145. unsigned long r19;
  146. };
  147. long long int r1918;
  148. };
  149. union {
  150. struct {
  151. unsigned long r20;
  152. unsigned long r21;
  153. };
  154. long long int r2120;
  155. };
  156. union {
  157. struct {
  158. unsigned long r22;
  159. unsigned long r23;
  160. };
  161. long long int r2322;
  162. };
  163. union {
  164. struct {
  165. unsigned long r24;
  166. unsigned long r25;
  167. };
  168. long long int r2524;
  169. };
  170. union {
  171. struct {
  172. unsigned long r26;
  173. unsigned long r27;
  174. };
  175. long long int r2726;
  176. };
  177. union {
  178. struct {
  179. unsigned long r28;
  180. unsigned long r29;
  181. };
  182. long long int r2928;
  183. };
  184. union {
  185. struct {
  186. unsigned long r30;
  187. unsigned long r31;
  188. };
  189. long long int r3130;
  190. };
  191. /* VM dispatch pushes event record onto stack - we can build on it */
  192. struct hvm_event_record hvmer;
  193. };
  194. /* Defines to conveniently access the values */
  195. /*
  196. * As of the VM spec 0.5, these registers are now set/retrieved via a
  197. * VM call. On the in-bound side, we just fetch the values
  198. * at the entry points and stuff them into the old record in pt_regs.
  199. * However, on the outbound side, probably at VM rte, we set the
  200. * registers back.
  201. */
  202. #define pt_elr(regs) ((regs)->hvmer.vmel)
  203. #define pt_set_elr(regs, val) ((regs)->hvmer.vmel = (val))
  204. #define pt_cause(regs) ((regs)->hvmer.vmest & (HVM_VMEST_CAUSE_MSK))
  205. #define user_mode(regs) \
  206. (((regs)->hvmer.vmest & (HVM_VMEST_UM_MSK << HVM_VMEST_UM_SFT)) != 0)
  207. #define ints_enabled(regs) \
  208. (((regs)->hvmer.vmest & (HVM_VMEST_IE_MSK << HVM_VMEST_IE_SFT)) != 0)
  209. #define pt_psp(regs) ((regs)->hvmer.vmpsp)
  210. #define pt_badva(regs) ((regs)->hvmer.vmbadva)
  211. #define pt_set_rte_sp(regs, sp) do {\
  212. pt_psp(regs) = (sp);\
  213. (regs)->SP = (unsigned long) &((regs)->hvmer);\
  214. } while (0)
  215. #define pt_set_kmode(regs) \
  216. (regs)->hvmer.vmest = (HVM_VMEST_IE_MSK << HVM_VMEST_IE_SFT)
  217. #define pt_set_usermode(regs) \
  218. (regs)->hvmer.vmest = (HVM_VMEST_UM_MSK << HVM_VMEST_UM_SFT) \
  219. | (HVM_VMEST_IE_MSK << HVM_VMEST_IE_SFT)
  220. #endif /* ifndef __ASSEMBLY */
  221. #endif