arm64_state.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. #ifndef arm64_state_h
  2. #define arm64_state_h
  3. /*
  4. * GPR context
  5. */
  6. struct arm_saved_state32 {
  7. uint32_t r[13]; /* General purpose register r0-r12 */
  8. uint32_t sp; /* Stack pointer r13 */
  9. uint32_t lr; /* Link register r14 */
  10. uint32_t pc; /* Program counter r15 */
  11. uint32_t cpsr; /* Current program status register */
  12. uint32_t far; /* Virtual fault address */
  13. uint32_t esr; /* Exception syndrome register */
  14. uint32_t exception; /* Exception number */
  15. };
  16. typedef struct arm_saved_state32 arm_saved_state32_t;
  17. struct arm_saved_state32_tagged {
  18. uint32_t tag;
  19. struct arm_saved_state32 state;
  20. };
  21. typedef struct arm_saved_state32_tagged arm_saved_state32_tagged_t;
  22. #define ARM_SAVED_STATE32_COUNT ((mach_msg_type_number_t) \
  23. (sizeof (arm_saved_state32_t)/sizeof(unsigned int)))
  24. struct arm_saved_state64 {
  25. uint64_t x[29]; /* General purpose registers x0-x28 */
  26. uint64_t fp; /* Frame pointer x29 */
  27. uint64_t lr; /* Link register x30 */
  28. uint64_t sp; /* Stack pointer x31 */
  29. uint64_t pc; /* Program counter */
  30. uint32_t cpsr; /* Current program status register */
  31. uint32_t reserved; /* Reserved padding */
  32. uint64_t far; /* Virtual fault address */
  33. uint32_t esr; /* Exception syndrome register */
  34. uint32_t exception; /* Exception number */
  35. };
  36. typedef struct arm_saved_state64 arm_saved_state64_t;
  37. #define ARM_SAVED_STATE64_COUNT ((mach_msg_type_number_t) \
  38. (sizeof (arm_saved_state64_t)/sizeof(unsigned int)))
  39. struct arm_saved_state {
  40. arm_state_hdr_t ash;
  41. union {
  42. struct arm_saved_state32 ss_32;
  43. struct arm_saved_state64 ss_64;
  44. } uss;
  45. } __attribute__((aligned(16)));
  46. #define ss_32 uss.ss_32
  47. #define ss_64 uss.ss_64
  48. typedef struct arm_saved_state arm_saved_state_t;
  49. /*
  50. * NEON context
  51. */
  52. typedef __uint128_t uint128_t;
  53. typedef uint64_t uint64x2_t __attribute__((ext_vector_type(2)));
  54. typedef uint32_t uint32x4_t __attribute__((ext_vector_type(4)));
  55. struct arm_neon_saved_state32 {
  56. union {
  57. uint128_t q[16];
  58. uint64_t d[32];
  59. uint32_t s[32];
  60. } v;
  61. uint32_t fpsr;
  62. uint32_t fpcr;
  63. };
  64. typedef struct arm_neon_saved_state32 arm_neon_saved_state32_t;
  65. #define ARM_NEON_SAVED_STATE32_COUNT ((mach_msg_type_number_t) \
  66. (sizeof (arm_neon_saved_state32_t)/sizeof(unsigned int)))
  67. struct arm_neon_saved_state64 {
  68. union {
  69. uint128_t q[32];
  70. uint64x2_t d[32];
  71. uint32x4_t s[32];
  72. } v;
  73. uint32_t fpsr;
  74. uint32_t fpcr;
  75. };
  76. typedef struct arm_neon_saved_state64 arm_neon_saved_state64_t;
  77. #define ARM_NEON_SAVED_STATE64_COUNT ((mach_msg_type_number_t) \
  78. (sizeof (arm_neon_saved_state64_t)/sizeof(unsigned int)))
  79. struct arm_neon_saved_state {
  80. arm_state_hdr_t nsh;
  81. union {
  82. struct arm_neon_saved_state32 ns_32;
  83. struct arm_neon_saved_state64 ns_64;
  84. } uns;
  85. };
  86. typedef struct arm_neon_saved_state arm_neon_saved_state_t;
  87. #define ns_32 uns.ns_32
  88. #define ns_64 uns.ns_64
  89. struct arm_context {
  90. struct arm_saved_state ss;
  91. struct arm_neon_saved_state ns;
  92. };
  93. typedef struct arm_context arm_context_t;
  94. #define ARM_SAVED_STATE64 0x15
  95. #define ARM_DEBUG_STATE64 15
  96. const uint64_t ACT_DEBUGDATA_OFFSET = 0x438;
  97. struct arm64_debug_state
  98. {
  99. __uint64_t bvr[16];
  100. __uint64_t bcr[16];
  101. __uint64_t wvr[16];
  102. __uint64_t wcr[16];
  103. __uint64_t mdscr_el1; /* Bit 0 is SS (Hardware Single Step) */
  104. };
  105. struct arm_debug_aggregate_state {
  106. arm_state_hdr_t dsh;
  107. struct arm64_debug_state ds64;
  108. } __attribute__((aligned(16)));
  109. #endif