ucontext.h 10 KB

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