user.h 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. //
  2. // Copyright 2026 Aarav Ravindra Kharade
  3. //
  4. // Licensed under the Apache License, Version 2.0 (the "License");
  5. // you may not use this file except in compliance with the License.
  6. // You may obtain a copy of the License at
  7. //
  8. // http://www.apache.org/licenses/LICENSE-2.0
  9. //
  10. // Unless required by applicable law or agreed to in writing, software
  11. // distributed under the License is distributed on an "AS IS" BASIS,
  12. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. // See the License for the specific language governing permissions and
  14. // limitations under the License.
  15. //
  16. /* Copyright (C) 2001-2026 Free Software Foundation, Inc.
  17. This file is part of the GNU C Library.
  18. The GNU C Library is free software; you can redistribute it and/or
  19. modify it under the terms of the GNU Lesser General Public
  20. License as published by the Free Software Foundation; either
  21. version 2.1 of the License, or (at your option) any later version.
  22. The GNU C Library is distributed in the hope that it will be useful,
  23. but WITHOUT ANY WARRANTY; without even the implied warranty of
  24. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  25. Lesser General Public License for more details.
  26. You should have received a copy of the GNU Lesser General Public
  27. License along with the GNU C Library; if not, see
  28. <https://www.gnu.org/licenses/>. */
  29. #ifndef _SYS_USER_H
  30. #define _SYS_USER_H 1
  31. /* The whole purpose of this file is for GDB and GDB only. Don't read
  32. too much into it. Don't use it for anything other than GDB unless
  33. you know what you are doing. */
  34. #ifdef __x86_64__
  35. struct user_fpregs_struct
  36. {
  37. unsigned short int cwd;
  38. unsigned short int swd;
  39. unsigned short int ftw;
  40. unsigned short int fop;
  41. __extension__ unsigned long long int rip;
  42. __extension__ unsigned long long int rdp;
  43. unsigned int mxcsr;
  44. unsigned int mxcr_mask;
  45. unsigned int st_space[32]; /* 8*16 bytes for each FP-reg = 128 bytes */
  46. unsigned int xmm_space[64]; /* 16*16 bytes for each XMM-reg = 256 bytes */
  47. unsigned int padding[24];
  48. };
  49. struct user_regs_struct
  50. {
  51. __extension__ unsigned long long int r15;
  52. __extension__ unsigned long long int r14;
  53. __extension__ unsigned long long int r13;
  54. __extension__ unsigned long long int r12;
  55. __extension__ unsigned long long int rbp;
  56. __extension__ unsigned long long int rbx;
  57. __extension__ unsigned long long int r11;
  58. __extension__ unsigned long long int r10;
  59. __extension__ unsigned long long int r9;
  60. __extension__ unsigned long long int r8;
  61. __extension__ unsigned long long int rax;
  62. __extension__ unsigned long long int rcx;
  63. __extension__ unsigned long long int rdx;
  64. __extension__ unsigned long long int rsi;
  65. __extension__ unsigned long long int rdi;
  66. __extension__ unsigned long long int orig_rax;
  67. __extension__ unsigned long long int rip;
  68. __extension__ unsigned long long int cs;
  69. __extension__ unsigned long long int eflags;
  70. __extension__ unsigned long long int rsp;
  71. __extension__ unsigned long long int ss;
  72. __extension__ unsigned long long int fs_base;
  73. __extension__ unsigned long long int gs_base;
  74. __extension__ unsigned long long int ds;
  75. __extension__ unsigned long long int es;
  76. __extension__ unsigned long long int fs;
  77. __extension__ unsigned long long int gs;
  78. };
  79. struct user
  80. {
  81. struct user_regs_struct regs;
  82. int u_fpvalid;
  83. struct user_fpregs_struct i387;
  84. __extension__ unsigned long long int u_tsize;
  85. __extension__ unsigned long long int u_dsize;
  86. __extension__ unsigned long long int u_ssize;
  87. __extension__ unsigned long long int start_code;
  88. __extension__ unsigned long long int start_stack;
  89. __extension__ long long int signal;
  90. int reserved;
  91. __extension__ union
  92. {
  93. struct user_regs_struct* u_ar0;
  94. __extension__ unsigned long long int __u_ar0_word;
  95. };
  96. __extension__ union
  97. {
  98. struct user_fpregs_struct* u_fpstate;
  99. __extension__ unsigned long long int __u_fpstate_word;
  100. };
  101. __extension__ unsigned long long int magic;
  102. char u_comm [32];
  103. __extension__ unsigned long long int u_debugreg [8];
  104. };
  105. #else
  106. /* These are the 32-bit x86 structures. */
  107. struct user_fpregs_struct
  108. {
  109. long int cwd;
  110. long int swd;
  111. long int twd;
  112. long int fip;
  113. long int fcs;
  114. long int foo;
  115. long int fos;
  116. long int st_space [20];
  117. };
  118. struct user_fpxregs_struct
  119. {
  120. unsigned short int cwd;
  121. unsigned short int swd;
  122. unsigned short int twd;
  123. unsigned short int fop;
  124. long int fip;
  125. long int fcs;
  126. long int foo;
  127. long int fos;
  128. long int mxcsr;
  129. long int reserved;
  130. long int st_space[32]; /* 8*16 bytes for each FP-reg = 128 bytes */
  131. long int xmm_space[32]; /* 8*16 bytes for each XMM-reg = 128 bytes */
  132. long int padding[56];
  133. };
  134. struct user_regs_struct
  135. {
  136. long int ebx;
  137. long int ecx;
  138. long int edx;
  139. long int esi;
  140. long int edi;
  141. long int ebp;
  142. long int eax;
  143. long int xds;
  144. long int xes;
  145. long int xfs;
  146. long int xgs;
  147. long int orig_eax;
  148. long int eip;
  149. long int xcs;
  150. long int eflags;
  151. long int esp;
  152. long int xss;
  153. };
  154. struct user
  155. {
  156. struct user_regs_struct regs;
  157. int u_fpvalid;
  158. struct user_fpregs_struct i387;
  159. unsigned long int u_tsize;
  160. unsigned long int u_dsize;
  161. unsigned long int u_ssize;
  162. unsigned long int start_code;
  163. unsigned long int start_stack;
  164. long int signal;
  165. int reserved;
  166. struct user_regs_struct* u_ar0;
  167. struct user_fpregs_struct* u_fpstate;
  168. unsigned long int magic;
  169. char u_comm [32];
  170. int u_debugreg [8];
  171. };
  172. #endif /* __x86_64__ */
  173. #define PAGE_SHIFT 12
  174. #define PAGE_SIZE (1UL << PAGE_SHIFT)
  175. #define PAGE_MASK (~(PAGE_SIZE-1))
  176. #define NBPG PAGE_SIZE
  177. #define UPAGES 1
  178. #define HOST_TEXT_START_ADDR (u.start_code)
  179. #define HOST_STACK_END_ADDR (u.start_stack + u.u_ssize * NBPG)
  180. #endif /* _SYS_USER_H */