sighndh.inc 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. {
  2. This file is part of the Free Pascal run time library.
  3. Copyright (c) 2005 by Thomas Schatzl,
  4. member of the FreePascal development team
  5. TSigContext and associated structures.
  6. See also in the *kernel* sources arch/ppc64/kernel/signal.c,
  7. function setup_rt_sigframe() for more information about the
  8. passed structures.
  9. See the file COPYING.FPC, included in this distribution,
  10. for details about the copyright.
  11. This program is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  14. **********************************************************************}
  15. {$packrecords C}
  16. type
  17. gpr_reg = cULong;
  18. fpr_reg = double;
  19. vvr_reg = array[0..1] of cULong;
  20. type
  21. { from include/asm-ppc64/ptrace.h }
  22. ppt_regs = ^pt_regs;
  23. pt_regs = record
  24. gpr : array[0..31] of gpr_reg;
  25. nip : gpr_reg;
  26. msr : gpr_reg;
  27. orig_gpr3 : gpr_reg; { Used for restarting system calls }
  28. ctr : gpr_reg;
  29. link : gpr_reg;
  30. xer : gpr_reg;
  31. ccr : gpr_reg;
  32. softe : gpr_reg; { Soft enabled/disabled }
  33. trap : gpr_reg; { Reason for being here }
  34. dar : gpr_reg; { Fault registers }
  35. dsisr : gpr_reg;
  36. result : gpr_reg; { Result of a system call }
  37. end;
  38. { index constants for the different register set arrays in TSigContext.
  39. Comments were directly pasted from the sources.
  40. }
  41. const
  42. PT_R0 = 0;
  43. PT_R1 = 1;
  44. PT_R2 = 2;
  45. PT_R3 = 3;
  46. PT_R4 = 4;
  47. PT_R5 = 5;
  48. PT_R6 = 6;
  49. PT_R7 = 7;
  50. PT_R8 = 8;
  51. PT_R9 = 9;
  52. PT_R10 = 10;
  53. PT_R11 = 11;
  54. PT_R12 = 12;
  55. PT_R13 = 13;
  56. PT_R14 = 14;
  57. PT_R15 = 15;
  58. PT_R16 = 16;
  59. PT_R17 = 17;
  60. PT_R18 = 18;
  61. PT_R19 = 19;
  62. PT_R20 = 20;
  63. PT_R21 = 21;
  64. PT_R22 = 22;
  65. PT_R23 = 23;
  66. PT_R24 = 24;
  67. PT_R25 = 25;
  68. PT_R26 = 26;
  69. PT_R27 = 27;
  70. PT_R28 = 28;
  71. PT_R29 = 29;
  72. PT_R30 = 30;
  73. PT_R31 = 31;
  74. PT_NIP = 32;
  75. PT_MSR = 33;
  76. PT_CTR = 35;
  77. PT_LNK = 36;
  78. PT_XER = 37;
  79. PT_CCR = 38;
  80. PT_SOFTE = 39;
  81. PT_RESULT = 43;
  82. PT_FPR0 = 48;
  83. PT_FPR31 = PT_FPR0+31;
  84. { Kernel and userspace will both use this PT_FPSCR value. 32-bit apps will have
  85. visibility to the asm-ppc/ptrace.h header instead of this one. }
  86. { each FP reg occupies 1 slot in 64-bit space }
  87. PT_FPSCR = PT_FPR0+32;
  88. { each Vector reg occupies 2 slots in 64-bit }
  89. PT_VR0 = 82;
  90. PT_VSCR = (PT_VR0+(32*2))+1;
  91. PT_VRSAVE = PT_VR0+(33*2);
  92. { from include/asm-ppc64/signal.h }
  93. type
  94. stack_t = record
  95. ss_sp : pointer;
  96. ss_flags : cInt;
  97. ss_size : size_t;
  98. end;
  99. { from include/asm-ppc64/sigcontext.h and
  100. include/asm-ppc64/elf.h
  101. }
  102. const
  103. ELF_NGREG = 48; { includes nip, msr, lr, etc. }
  104. ELF_NFPREG = 33; { includes fpscr }
  105. ELF_NVRREG = 34; { includes vscr & vrsave in split vectors }
  106. type
  107. elf_gregset_t = array[0..ELF_NGREG-1] of gpr_reg;
  108. elf_fpregset_t = array[0..ELF_NFPREG-1] of fpr_reg;
  109. elf_vrreg_t = array[0..ELF_NVRREG-1] of vvr_reg;
  110. TSigContext = record
  111. _unused : array[0..3] of cULong;
  112. signal : cInt;
  113. _pad0 : cInt;
  114. handler : cULong;
  115. oldmask : cULong;
  116. regs : ppt_regs;
  117. gp_regs : elf_gregset_t;
  118. fp_regs : elf_fpregset_t;
  119. { To maintain compatibility with current implementations the sigcontext is
  120. extended by appending a pointer (v_regs) to a quadword type (elf_vrreg_t)
  121. followed by an unstructured (vmx_reserve) field of 69 doublewords. This
  122. allows the array of vector registers to be quadword aligned independent of
  123. the alignment of the containing sigcontext or ucontext. It is the
  124. responsibility of the code setting the sigcontext to set this pointer to
  125. either NULL (if this processor does not support the VMX feature) or the
  126. address of the first quadword within the allocated (vmx_reserve) area.
  127. The pointer (v_regs) of vector type (elf_vrreg_t) is type compatible with
  128. an array of 34 quadword entries (elf_vrregset_t). The entries with
  129. indexes 0-31 contain the corresponding vector registers. The entry with
  130. index 32 contains the vscr as the last word (offset 12) within the
  131. quadword. This allows the vscr to be stored as either a quadword (since
  132. it must be copied via a vector register to/from storage) or as a word.
  133. The entry with index 33 contains the vrsave as the first word (offset 0)
  134. within the quadword. }
  135. v_regs : ^elf_vrreg_t;
  136. vmx_reserve : array[0..ELF_NVRREG+ELF_NVRREG] of cLong;
  137. end;
  138. { the kernel uses a different sigset_t type for the ucontext structure and the
  139. sigset_t used for masking signals. To avoid name clash, and still use a dedicated
  140. type for the fields, use _sigset_t }
  141. _sigset_t = cULong;
  142. { from include/asm-ppc64/ucontext.h }
  143. pucontext = ^tucontext;
  144. tucontext = record
  145. uc_flags : cuLong;
  146. uc_link : pucontext;
  147. uc_stack : stack_t;
  148. uc_sigmask : _sigset_t;
  149. __unused : array[0..14] of _sigset_t; { Allow for uc_sigmask growth }
  150. uc_mcontext : TSigContext; { last for extensibility }
  151. end;
  152. PSigContext = ^TUContext;