registers.h 4.5 KB

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