s390-tdep.h 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323
  1. /* Target-dependent code for s390.
  2. Copyright (C) 2003-2022 Free Software Foundation, Inc.
  3. This file is part of GDB.
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 3 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program. If not, see <http://www.gnu.org/licenses/>. */
  14. #ifndef S390_TDEP_H
  15. #define S390_TDEP_H
  16. #include "prologue-value.h"
  17. #include "gdbarch.h"
  18. enum s390_abi_kind
  19. {
  20. ABI_NONE,
  21. ABI_LINUX_S390,
  22. ABI_LINUX_ZSERIES
  23. };
  24. enum s390_vector_abi_kind
  25. {
  26. S390_VECTOR_ABI_NONE,
  27. S390_VECTOR_ABI_128
  28. };
  29. /* The tdep structure. */
  30. struct s390_gdbarch_tdep : gdbarch_tdep
  31. {
  32. /* Target description. */
  33. const struct target_desc *tdesc = nullptr;
  34. /* ABI version. */
  35. enum s390_abi_kind abi {};
  36. /* Vector ABI. */
  37. enum s390_vector_abi_kind vector_abi {};
  38. /* Pseudo register numbers. */
  39. int gpr_full_regnum = 0;
  40. int pc_regnum = 0;
  41. int cc_regnum = 0;
  42. int v0_full_regnum = 0;
  43. bool have_upper = 0;
  44. bool have_linux_v1 = 0;
  45. bool have_linux_v2 = 0;
  46. bool have_tdb = 0;
  47. bool have_vx = 0;
  48. bool have_gs = 0;
  49. /* Hook to record OS specific systemcall. */
  50. int (*s390_syscall_record) (struct regcache *regcache, LONGEST svc_number)
  51. = nullptr;
  52. };
  53. /* Decoding S/390 instructions. */
  54. /* Named opcode values for the S/390 instructions we recognize. Some
  55. instructions have their opcode split across two fields; those are the
  56. op1_* and op2_* enums. */
  57. enum
  58. {
  59. op1_lhi = 0xa7, op2_lhi = 0x08,
  60. op1_lghi = 0xa7, op2_lghi = 0x09,
  61. op1_lgfi = 0xc0, op2_lgfi = 0x01,
  62. op_lr = 0x18,
  63. op_lgr = 0xb904,
  64. op_l = 0x58,
  65. op1_ly = 0xe3, op2_ly = 0x58,
  66. op1_lg = 0xe3, op2_lg = 0x04,
  67. op_lm = 0x98,
  68. op1_lmy = 0xeb, op2_lmy = 0x98,
  69. op1_lmg = 0xeb, op2_lmg = 0x04,
  70. op_st = 0x50,
  71. op1_sty = 0xe3, op2_sty = 0x50,
  72. op1_stg = 0xe3, op2_stg = 0x24,
  73. op_std = 0x60,
  74. op_stm = 0x90,
  75. op1_stmy = 0xeb, op2_stmy = 0x90,
  76. op1_stmg = 0xeb, op2_stmg = 0x24,
  77. op1_aghi = 0xa7, op2_aghi = 0x0b,
  78. op1_ahi = 0xa7, op2_ahi = 0x0a,
  79. op1_agfi = 0xc2, op2_agfi = 0x08,
  80. op1_afi = 0xc2, op2_afi = 0x09,
  81. op1_algfi= 0xc2, op2_algfi= 0x0a,
  82. op1_alfi = 0xc2, op2_alfi = 0x0b,
  83. op_ar = 0x1a,
  84. op_agr = 0xb908,
  85. op_a = 0x5a,
  86. op1_ay = 0xe3, op2_ay = 0x5a,
  87. op1_ag = 0xe3, op2_ag = 0x08,
  88. op1_slgfi= 0xc2, op2_slgfi= 0x04,
  89. op1_slfi = 0xc2, op2_slfi = 0x05,
  90. op_sr = 0x1b,
  91. op_sgr = 0xb909,
  92. op_s = 0x5b,
  93. op1_sy = 0xe3, op2_sy = 0x5b,
  94. op1_sg = 0xe3, op2_sg = 0x09,
  95. op_nr = 0x14,
  96. op_ngr = 0xb980,
  97. op_la = 0x41,
  98. op1_lay = 0xe3, op2_lay = 0x71,
  99. op1_larl = 0xc0, op2_larl = 0x00,
  100. op_basr = 0x0d,
  101. op_bas = 0x4d,
  102. op_bcr = 0x07,
  103. op_bc = 0x47,
  104. op_bctr = 0x06,
  105. op_bctgr = 0xb946,
  106. op_bct = 0x46,
  107. op1_bctg = 0xe3, op2_bctg = 0x46,
  108. op_bxh = 0x86,
  109. op1_bxhg = 0xeb, op2_bxhg = 0x44,
  110. op_bxle = 0x87,
  111. op1_bxleg= 0xeb, op2_bxleg= 0x45,
  112. op1_bras = 0xa7, op2_bras = 0x05,
  113. op1_brasl= 0xc0, op2_brasl= 0x05,
  114. op1_brc = 0xa7, op2_brc = 0x04,
  115. op1_brcl = 0xc0, op2_brcl = 0x04,
  116. op1_brct = 0xa7, op2_brct = 0x06,
  117. op1_brctg= 0xa7, op2_brctg= 0x07,
  118. op_brxh = 0x84,
  119. op1_brxhg= 0xec, op2_brxhg= 0x44,
  120. op_brxle = 0x85,
  121. op1_brxlg= 0xec, op2_brxlg= 0x45,
  122. op_svc = 0x0a,
  123. };
  124. /* Hardware capabilities. */
  125. #ifndef HWCAP_S390_HIGH_GPRS
  126. #define HWCAP_S390_HIGH_GPRS 512
  127. #endif
  128. #ifndef HWCAP_S390_TE
  129. #define HWCAP_S390_TE 1024
  130. #endif
  131. #ifndef HWCAP_S390_VX
  132. #define HWCAP_S390_VX 2048
  133. #endif
  134. #ifndef HWCAP_S390_GS
  135. #define HWCAP_S390_GS 16384
  136. #endif
  137. /* Register information. */
  138. /* Program Status Word. */
  139. #define S390_PSWM_REGNUM 0
  140. #define S390_PSWA_REGNUM 1
  141. /* General Purpose Registers. */
  142. #define S390_R0_REGNUM 2
  143. #define S390_R1_REGNUM 3
  144. #define S390_R2_REGNUM 4
  145. #define S390_R3_REGNUM 5
  146. #define S390_R4_REGNUM 6
  147. #define S390_R5_REGNUM 7
  148. #define S390_R6_REGNUM 8
  149. #define S390_R7_REGNUM 9
  150. #define S390_R8_REGNUM 10
  151. #define S390_R9_REGNUM 11
  152. #define S390_R10_REGNUM 12
  153. #define S390_R11_REGNUM 13
  154. #define S390_R12_REGNUM 14
  155. #define S390_R13_REGNUM 15
  156. #define S390_R14_REGNUM 16
  157. #define S390_R15_REGNUM 17
  158. /* Access Registers. */
  159. #define S390_A0_REGNUM 18
  160. #define S390_A1_REGNUM 19
  161. #define S390_A2_REGNUM 20
  162. #define S390_A3_REGNUM 21
  163. #define S390_A4_REGNUM 22
  164. #define S390_A5_REGNUM 23
  165. #define S390_A6_REGNUM 24
  166. #define S390_A7_REGNUM 25
  167. #define S390_A8_REGNUM 26
  168. #define S390_A9_REGNUM 27
  169. #define S390_A10_REGNUM 28
  170. #define S390_A11_REGNUM 29
  171. #define S390_A12_REGNUM 30
  172. #define S390_A13_REGNUM 31
  173. #define S390_A14_REGNUM 32
  174. #define S390_A15_REGNUM 33
  175. /* Floating Point Control Word. */
  176. #define S390_FPC_REGNUM 34
  177. /* Floating Point Registers. */
  178. #define S390_F0_REGNUM 35
  179. #define S390_F1_REGNUM 36
  180. #define S390_F2_REGNUM 37
  181. #define S390_F3_REGNUM 38
  182. #define S390_F4_REGNUM 39
  183. #define S390_F5_REGNUM 40
  184. #define S390_F6_REGNUM 41
  185. #define S390_F7_REGNUM 42
  186. #define S390_F8_REGNUM 43
  187. #define S390_F9_REGNUM 44
  188. #define S390_F10_REGNUM 45
  189. #define S390_F11_REGNUM 46
  190. #define S390_F12_REGNUM 47
  191. #define S390_F13_REGNUM 48
  192. #define S390_F14_REGNUM 49
  193. #define S390_F15_REGNUM 50
  194. /* General Purpose Register Upper Halves. */
  195. #define S390_R0_UPPER_REGNUM 51
  196. #define S390_R1_UPPER_REGNUM 52
  197. #define S390_R2_UPPER_REGNUM 53
  198. #define S390_R3_UPPER_REGNUM 54
  199. #define S390_R4_UPPER_REGNUM 55
  200. #define S390_R5_UPPER_REGNUM 56
  201. #define S390_R6_UPPER_REGNUM 57
  202. #define S390_R7_UPPER_REGNUM 58
  203. #define S390_R8_UPPER_REGNUM 59
  204. #define S390_R9_UPPER_REGNUM 60
  205. #define S390_R10_UPPER_REGNUM 61
  206. #define S390_R11_UPPER_REGNUM 62
  207. #define S390_R12_UPPER_REGNUM 63
  208. #define S390_R13_UPPER_REGNUM 64
  209. #define S390_R14_UPPER_REGNUM 65
  210. #define S390_R15_UPPER_REGNUM 66
  211. /* GNU/Linux-specific optional registers. */
  212. #define S390_ORIG_R2_REGNUM 67
  213. #define S390_LAST_BREAK_REGNUM 68
  214. #define S390_SYSTEM_CALL_REGNUM 69
  215. /* Transaction diagnostic block. */
  216. #define S390_TDB_DWORD0_REGNUM 70
  217. #define S390_TDB_ABORT_CODE_REGNUM 71
  218. #define S390_TDB_CONFLICT_TOKEN_REGNUM 72
  219. #define S390_TDB_ATIA_REGNUM 73
  220. #define S390_TDB_R0_REGNUM 74
  221. #define S390_TDB_R1_REGNUM 75
  222. #define S390_TDB_R2_REGNUM 76
  223. #define S390_TDB_R3_REGNUM 77
  224. #define S390_TDB_R4_REGNUM 78
  225. #define S390_TDB_R5_REGNUM 79
  226. #define S390_TDB_R6_REGNUM 80
  227. #define S390_TDB_R7_REGNUM 81
  228. #define S390_TDB_R8_REGNUM 82
  229. #define S390_TDB_R9_REGNUM 83
  230. #define S390_TDB_R10_REGNUM 84
  231. #define S390_TDB_R11_REGNUM 85
  232. #define S390_TDB_R12_REGNUM 86
  233. #define S390_TDB_R13_REGNUM 87
  234. #define S390_TDB_R14_REGNUM 88
  235. #define S390_TDB_R15_REGNUM 89
  236. /* Vector registers. */
  237. #define S390_V0_LOWER_REGNUM 90
  238. #define S390_V1_LOWER_REGNUM 91
  239. #define S390_V2_LOWER_REGNUM 92
  240. #define S390_V3_LOWER_REGNUM 93
  241. #define S390_V4_LOWER_REGNUM 94
  242. #define S390_V5_LOWER_REGNUM 95
  243. #define S390_V6_LOWER_REGNUM 96
  244. #define S390_V7_LOWER_REGNUM 97
  245. #define S390_V8_LOWER_REGNUM 98
  246. #define S390_V9_LOWER_REGNUM 99
  247. #define S390_V10_LOWER_REGNUM 100
  248. #define S390_V11_LOWER_REGNUM 101
  249. #define S390_V12_LOWER_REGNUM 102
  250. #define S390_V13_LOWER_REGNUM 103
  251. #define S390_V14_LOWER_REGNUM 104
  252. #define S390_V15_LOWER_REGNUM 105
  253. #define S390_V16_REGNUM 106
  254. #define S390_V17_REGNUM 107
  255. #define S390_V18_REGNUM 108
  256. #define S390_V19_REGNUM 109
  257. #define S390_V20_REGNUM 110
  258. #define S390_V21_REGNUM 111
  259. #define S390_V22_REGNUM 112
  260. #define S390_V23_REGNUM 113
  261. #define S390_V24_REGNUM 114
  262. #define S390_V25_REGNUM 115
  263. #define S390_V26_REGNUM 116
  264. #define S390_V27_REGNUM 117
  265. #define S390_V28_REGNUM 118
  266. #define S390_V29_REGNUM 119
  267. #define S390_V30_REGNUM 120
  268. #define S390_V31_REGNUM 121
  269. #define S390_GSD_REGNUM 122
  270. #define S390_GSSM_REGNUM 123
  271. #define S390_GSEPLA_REGNUM 124
  272. #define S390_BC_GSD_REGNUM 125
  273. #define S390_BC_GSSM_REGNUM 126
  274. #define S390_BC_GSEPLA_REGNUM 127
  275. /* Total. */
  276. #define S390_NUM_REGS 128
  277. #define S390_NUM_GPRS 16
  278. #define S390_NUM_FPRS 16
  279. #define S390_MAX_INSTR_SIZE 6
  280. /* Special register usage. */
  281. #define S390_SP_REGNUM S390_R15_REGNUM
  282. #define S390_RETADDR_REGNUM S390_R14_REGNUM
  283. #define S390_FRAME_REGNUM S390_R11_REGNUM
  284. /* Frame unwinding. */
  285. extern struct value *s390_trad_frame_prev_register
  286. (struct frame_info *this_frame, struct trad_frame_saved_reg saved_regs[],
  287. int regnum);
  288. extern struct target_desc *tdesc_s390_linux32;
  289. extern struct target_desc *tdesc_s390x_linux64;
  290. #endif /* S390_TDEP_H */