registers.h 4.3 KB

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