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