ucontext.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450
  1. /* Copyright (C) 1999, 2000, 2001, 2003, 2004 Free Software Foundation, Inc.
  2. This file is part of the GNU C Library.
  3. The GNU C Library is free software; you can redistribute it and/or
  4. modify it under the terms of the GNU Library General Public License as
  5. published by the Free Software Foundation; either version 2 of the
  6. License, or (at your option) any later version.
  7. The GNU C Library is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  10. Library General Public License for more details.
  11. You should have received a copy of the GNU Library General Public
  12. License along with the GNU C Library; see the file COPYING.LIB. If not,
  13. see <http://www.gnu.org/licenses/>. */
  14. #ifndef _SYS_UCONTEXT_H
  15. #define _SYS_UCONTEXT_H 1
  16. #include <features.h>
  17. #include <signal.h>
  18. /* We need the signal context definitions even if they are not used
  19. included in <signal.h>. */
  20. #include <bits/sigcontext.h>
  21. typedef unsigned long greg_t;
  22. /* Number of general registers. */
  23. #define NGREG (10+2+64)
  24. /* Container for all general registers. */
  25. typedef greg_t gregset_t[NGREG];
  26. #ifdef __USE_GNU
  27. /* Number of each register is the `gregset_t' array. */
  28. enum
  29. {
  30. REG_PSR = 0,
  31. #define REG_PSR REG_PSR
  32. REG_ISR = 1,
  33. #define REG_ISR REG_ISR
  34. REG_CCR = 2,
  35. #define REG_CCR REG_CCR
  36. REG_CCCR = 3,
  37. #define REG_CCCR REG_CCCR
  38. REG_LR = 4,
  39. #define REG_LR REG_LR
  40. REG_LCR = 5,
  41. #define REG_LCR REG_LCR
  42. REG_PC = 6,
  43. #define REG_PC REG_PC
  44. REG___STATUS = 7,
  45. #define REG___STATUS REG___STATUS
  46. REG_SYSCALLNO = 8,
  47. #define REG_SYSCALLNO REG_SYSCALLNO
  48. REG_ORIG_GR8 = 9,
  49. #define REG_ORIG_GR8 REG_ORIG_GR8
  50. REG_GNER0 = 10,
  51. #define REG_GNER0 REG_GNER0
  52. REG_GNER1 = 11,
  53. #define REG_GNER1 REG_GNER1
  54. REG_GR0 = 12,
  55. #define REG_GR0 REG_GR0
  56. REG_GR1 = 13,
  57. #define REG_GR1 REG_GR1
  58. REG_GR2 = 14,
  59. #define REG_GR2 REG_GR2
  60. REG_GR3 = 15,
  61. #define REG_GR3 REG_GR3
  62. REG_GR4 = 16,
  63. #define REG_GR4 REG_GR4
  64. REG_GR5 = 17,
  65. #define REG_GR5 REG_GR5
  66. REG_GR6 = 18,
  67. #define REG_GR6 REG_GR6
  68. REG_GR7 = 19,
  69. #define REG_GR7 REG_GR7
  70. REG_GR8 = 20,
  71. #define REG_GR8 REG_GR8
  72. REG_GR9 = 21,
  73. #define REG_GR9 REG_GR9
  74. REG_GR10 = 22,
  75. #define REG_GR10 REG_GR10
  76. REG_GR11 = 23,
  77. #define REG_GR11 REG_GR11
  78. REG_GR12 = 24,
  79. #define REG_GR12 REG_GR12
  80. REG_GR13 = 25,
  81. #define REG_GR13 REG_GR13
  82. REG_GR14 = 26,
  83. #define REG_GR14 REG_GR14
  84. REG_GR15 = 27,
  85. #define REG_GR15 REG_GR15
  86. REG_GR16 = 28,
  87. #define REG_GR16 REG_GR16
  88. REG_GR17 = 29,
  89. #define REG_GR17 REG_GR17
  90. REG_GR18 = 30,
  91. #define REG_GR18 REG_GR18
  92. REG_GR19 = 31,
  93. #define REG_GR19 REG_GR19
  94. REG_GR20 = 32,
  95. #define REG_GR20 REG_GR20
  96. REG_GR21 = 33,
  97. #define REG_GR21 REG_GR21
  98. REG_GR22 = 34,
  99. #define REG_GR22 REG_GR22
  100. REG_GR23 = 35,
  101. #define REG_GR23 REG_GR23
  102. REG_GR24 = 36,
  103. #define REG_GR24 REG_GR24
  104. REG_GR25 = 37,
  105. #define REG_GR25 REG_GR25
  106. REG_GR26 = 38,
  107. #define REG_GR26 REG_GR26
  108. REG_GR27 = 39,
  109. #define REG_GR27 REG_GR27
  110. REG_GR28 = 40,
  111. #define REG_GR28 REG_GR28
  112. REG_GR29 = 41,
  113. #define REG_GR29 REG_GR29
  114. REG_GR30 = 42,
  115. #define REG_GR30 REG_GR30
  116. REG_GR31 = 43,
  117. #define REG_GR31 REG_GR31
  118. REG_GR32 = 44,
  119. #define REG_GR32 REG_GR32
  120. REG_GR33 = 45,
  121. #define REG_GR33 REG_GR33
  122. REG_GR34 = 46,
  123. #define REG_GR34 REG_GR34
  124. REG_GR35 = 47,
  125. #define REG_GR35 REG_GR35
  126. REG_GR36 = 48,
  127. #define REG_GR36 REG_GR36
  128. REG_GR37 = 49,
  129. #define REG_GR37 REG_GR37
  130. REG_GR38 = 50,
  131. #define REG_GR38 REG_GR38
  132. REG_GR39 = 51,
  133. #define REG_GR39 REG_GR39
  134. REG_GR40 = 52,
  135. #define REG_GR40 REG_GR40
  136. REG_GR41 = 53,
  137. #define REG_GR41 REG_GR41
  138. REG_GR42 = 54,
  139. #define REG_GR42 REG_GR42
  140. REG_GR43 = 55,
  141. #define REG_GR43 REG_GR43
  142. REG_GR44 = 56,
  143. #define REG_GR44 REG_GR44
  144. REG_GR45 = 57,
  145. #define REG_GR45 REG_GR45
  146. REG_GR46 = 58,
  147. #define REG_GR46 REG_GR46
  148. REG_GR47 = 59,
  149. #define REG_GR47 REG_GR47
  150. REG_GR48 = 60,
  151. #define REG_GR48 REG_GR48
  152. REG_GR49 = 61,
  153. #define REG_GR49 REG_GR49
  154. REG_GR50 = 62,
  155. #define REG_GR50 REG_GR50
  156. REG_GR51 = 63,
  157. #define REG_GR51 REG_GR51
  158. REG_GR52 = 64,
  159. #define REG_GR52 REG_GR52
  160. REG_GR53 = 65,
  161. #define REG_GR53 REG_GR53
  162. REG_GR54 = 66,
  163. #define REG_GR54 REG_GR54
  164. REG_GR55 = 67,
  165. #define REG_GR55 REG_GR55
  166. REG_GR56 = 68,
  167. #define REG_GR56 REG_GR56
  168. REG_GR57 = 69,
  169. #define REG_GR57 REG_GR57
  170. REG_GR58 = 70,
  171. #define REG_GR58 REG_GR58
  172. REG_GR59 = 71,
  173. #define REG_GR59 REG_GR59
  174. REG_GR60 = 72,
  175. #define REG_GR60 REG_GR60
  176. REG_GR61 = 73,
  177. #define REG_GR61 REG_GR61
  178. REG_GR62 = 74,
  179. #define REG_GR62 REG_GR62
  180. REG_GR63 = 75,
  181. #define REG_GR63 REG_GR63
  182. };
  183. #endif
  184. typedef unsigned long freg_t;
  185. /* Number of FPU registers. */
  186. #define NFPREG (64+2+2+8+2+1)
  187. #ifdef __USE_GNU
  188. /* Number of each register is the `gregset_t' array. */
  189. enum
  190. {
  191. REG_FR0 = 0,
  192. #define REG_FR0 REG_FR0
  193. REG_FR1 = 1,
  194. #define REG_FR1 REG_FR1
  195. REG_FR2 = 2,
  196. #define REG_FR2 REG_FR2
  197. REG_FR3 = 3,
  198. #define REG_FR3 REG_FR3
  199. REG_FR4 = 4,
  200. #define REG_FR4 REG_FR4
  201. REG_FR5 = 5,
  202. #define REG_FR5 REG_FR5
  203. REG_FR6 = 6,
  204. #define REG_FR6 REG_FR6
  205. REG_FR7 = 7,
  206. #define REG_FR7 REG_FR7
  207. REG_FR8 = 8,
  208. #define REG_FR8 REG_FR8
  209. REG_FR9 = 9,
  210. #define REG_FR9 REG_FR9
  211. REG_FR10 = 10,
  212. #define REG_FR10 REG_FR10
  213. REG_FR11 = 11,
  214. #define REG_FR11 REG_FR11
  215. REG_FR12 = 12,
  216. #define REG_FR12 REG_FR12
  217. REG_FR13 = 13,
  218. #define REG_FR13 REG_FR13
  219. REG_FR14 = 14,
  220. #define REG_FR14 REG_FR14
  221. REG_FR15 = 15,
  222. #define REG_FR15 REG_FR15
  223. REG_FR16 = 16,
  224. #define REG_FR16 REG_FR16
  225. REG_FR17 = 17,
  226. #define REG_FR17 REG_FR17
  227. REG_FR18 = 18,
  228. #define REG_FR18 REG_FR18
  229. REG_FR19 = 19,
  230. #define REG_FR19 REG_FR19
  231. REG_FR20 = 20,
  232. #define REG_FR20 REG_FR20
  233. REG_FR21 = 21,
  234. #define REG_FR21 REG_FR21
  235. REG_FR22 = 22,
  236. #define REG_FR22 REG_FR22
  237. REG_FR23 = 23,
  238. #define REG_FR23 REG_FR23
  239. REG_FR24 = 24,
  240. #define REG_FR24 REG_FR24
  241. REG_FR25 = 25,
  242. #define REG_FR25 REG_FR25
  243. REG_FR26 = 26,
  244. #define REG_FR26 REG_FR26
  245. REG_FR27 = 27,
  246. #define REG_FR27 REG_FR27
  247. REG_FR28 = 28,
  248. #define REG_FR28 REG_FR28
  249. REG_FR29 = 29,
  250. #define REG_FR29 REG_FR29
  251. REG_FR30 = 30,
  252. #define REG_FR30 REG_FR30
  253. REG_FR31 = 31,
  254. #define REG_FR31 REG_FR31
  255. REG_FR32 = 32,
  256. #define REG_FR32 REG_FR32
  257. REG_FR33 = 33,
  258. #define REG_FR33 REG_FR33
  259. REG_FR34 = 34,
  260. #define REG_FR34 REG_FR34
  261. REG_FR35 = 35,
  262. #define REG_FR35 REG_FR35
  263. REG_FR36 = 36,
  264. #define REG_FR36 REG_FR36
  265. REG_FR37 = 37,
  266. #define REG_FR37 REG_FR37
  267. REG_FR38 = 38,
  268. #define REG_FR38 REG_FR38
  269. REG_FR39 = 39,
  270. #define REG_FR39 REG_FR39
  271. REG_FR40 = 40,
  272. #define REG_FR40 REG_FR40
  273. REG_FR41 = 41,
  274. #define REG_FR41 REG_FR41
  275. REG_FR42 = 42,
  276. #define REG_FR42 REG_FR42
  277. REG_FR43 = 43,
  278. #define REG_FR43 REG_FR43
  279. REG_FR44 = 44,
  280. #define REG_FR44 REG_FR44
  281. REG_FR45 = 45,
  282. #define REG_FR45 REG_FR45
  283. REG_FR46 = 46,
  284. #define REG_FR46 REG_FR46
  285. REG_FR47 = 47,
  286. #define REG_FR47 REG_FR47
  287. REG_FR48 = 48,
  288. #define REG_FR48 REG_FR48
  289. REG_FR49 = 49,
  290. #define REG_FR49 REG_FR49
  291. REG_FR50 = 50,
  292. #define REG_FR50 REG_FR50
  293. REG_FR51 = 51,
  294. #define REG_FR51 REG_FR51
  295. REG_FR52 = 52,
  296. #define REG_FR52 REG_FR52
  297. REG_FR53 = 53,
  298. #define REG_FR53 REG_FR53
  299. REG_FR54 = 54,
  300. #define REG_FR54 REG_FR54
  301. REG_FR55 = 55,
  302. #define REG_FR55 REG_FR55
  303. REG_FR56 = 56,
  304. #define REG_FR56 REG_FR56
  305. REG_FR57 = 57,
  306. #define REG_FR57 REG_FR57
  307. REG_FR58 = 58,
  308. #define REG_FR58 REG_FR58
  309. REG_FR59 = 59,
  310. #define REG_FR59 REG_FR59
  311. REG_FR60 = 60,
  312. #define REG_FR60 REG_FR60
  313. REG_FR61 = 61,
  314. #define REG_FR61 REG_FR61
  315. REG_FR62 = 62,
  316. #define REG_FR62 REG_FR62
  317. REG_FR63 = 63,
  318. #define REG_FR63 REG_FR63
  319. REG_FNER0 = 64,
  320. #define REG_FNER0 REG_FNER0
  321. REG_FNER1 = 65,
  322. #define REG_FNER1 REG_FNER1
  323. REG_MSR0 = 66,
  324. #define REG_MSR0 REG_MSR0
  325. REG_MSR1 = 67,
  326. #define REG_MSR1 REG_MSR1
  327. REG_ACC0 = 68,
  328. #define REG_ACC0 REG_ACC0
  329. REG_ACC1 = 69,
  330. #define REG_ACC1 REG_ACC1
  331. REG_ACC2 = 70,
  332. #define REG_ACC2 REG_ACC2
  333. REG_ACC3 = 71,
  334. #define REG_ACC3 REG_ACC3
  335. REG_ACC4 = 72,
  336. #define REG_ACC4 REG_ACC4
  337. REG_ACC5 = 73,
  338. #define REG_ACC5 REG_ACC5
  339. REG_ACC6 = 74,
  340. #define REG_ACC6 REG_ACC6
  341. REG_ACC7 = 75,
  342. #define REG_ACC7 REG_ACC7
  343. REG_ACCG0123 = 76,
  344. #define REG_ACCG0123 REG_ACCG0123
  345. REG_ACCG4567 = 77,
  346. #define REG_ACCG4567 REG_ACCG4567
  347. REG_FSR0 = 78,
  348. #define REG_FSR0 REG_FSR0
  349. };
  350. #endif
  351. /* Structure to describe FPU registers. */
  352. typedef freg_t fpregset_t[NFPREG];
  353. /* Context to describe whole processor state. */
  354. typedef struct
  355. {
  356. gregset_t gregs;
  357. fpregset_t fpregs;
  358. void *extension;
  359. unsigned long sc_oldmask; /* old sigmask */
  360. } __attribute__((aligned(8))) mcontext_t;
  361. #ifdef __USE_GNU
  362. struct kernel_user_int_regs
  363. {
  364. /* integer registers
  365. * - up to gr[31] mirror pt_regs in the kernel
  366. */
  367. unsigned long psr; /* Processor Status Register */
  368. unsigned long isr; /* Integer Status Register */
  369. unsigned long ccr; /* Condition Code Register */
  370. unsigned long cccr; /* Condition Code for Conditional Insns Register */
  371. unsigned long lr; /* Link Register */
  372. unsigned long lcr; /* Loop Count Register */
  373. unsigned long pc; /* Program Counter Register */
  374. unsigned long __status; /* exception status */
  375. unsigned long syscallno; /* syscall number or -1 */
  376. unsigned long orig_gr8; /* original syscall arg #1 */
  377. unsigned long gner[2];
  378. union {
  379. unsigned long tbr;
  380. unsigned long gr[64];
  381. };
  382. };
  383. struct kernel_user_fpmedia_regs
  384. {
  385. /* FP/Media registers */
  386. unsigned long fr[64];
  387. unsigned long fner[2];
  388. unsigned long msr[2];
  389. unsigned long acc[8];
  390. unsigned char accg[8];
  391. unsigned long fsr[1];
  392. };
  393. struct kernel_user_context
  394. {
  395. struct kernel_user_int_regs i;
  396. struct kernel_user_fpmedia_regs f;
  397. /* we provide a context extension so that we can save the regs for CPUs that
  398. * implement many more of Fujitsu's lavish register spec
  399. */
  400. void *extension;
  401. /* This is not part of the kernel's struct user_context, but
  402. rather of the enclosing struct sigcontext, but we add it
  403. here to parallel mcontext_t, just for completeness. */
  404. unsigned long sc_oldmask; /* old sigmask */
  405. } __attribute__((aligned(8)));
  406. /* This union enables alias-safe casts from mcontext_t* to the union
  407. type, that can then be dereferenced as_aliases. */
  408. union kmcontext_t
  409. {
  410. mcontext_t as_regsets;
  411. /* as_aliases is actually missing sc_oldmask, that is present in
  412. mcontext_t. */
  413. struct kernel_user_context as_aliases;
  414. };
  415. #endif
  416. /* Userlevel context. */
  417. typedef struct ucontext
  418. {
  419. unsigned long int uc_flags;
  420. struct ucontext *uc_link;
  421. stack_t uc_stack;
  422. mcontext_t uc_mcontext;
  423. __sigset_t uc_sigmask;
  424. } ucontext_t;
  425. #endif /* sys/ucontext.h */