1 #ifndef _ASM_IA64_IA32_H
2 #define _ASM_IA64_IA32_H
3
4 #include <linux/config.h>
5
6 #ifdef CONFIG_IA32_SUPPORT
7
8 #include <linux/param.h>
9
10 /*
11 * 32 bit structures for IA32 support.
12 */
13
14 /* 32bit compatibility types */
15 typedef unsigned int __kernel_size_t32;
16 typedef int __kernel_ssize_t32;
17 typedef int __kernel_ptrdiff_t32;
18 typedef int __kernel_time_t32;
19 typedef int __kernel_clock_t32;
20 typedef int __kernel_pid_t32;
21 typedef unsigned short __kernel_ipc_pid_t32;
22 typedef unsigned short __kernel_uid_t32;
23 typedef unsigned short __kernel_gid_t32;
24 typedef unsigned short __kernel_dev_t32;
25 typedef unsigned int __kernel_ino_t32;
26 typedef unsigned short __kernel_mode_t32;
27 typedef unsigned short __kernel_umode_t32;
28 typedef short __kernel_nlink_t32;
29 typedef int __kernel_daddr_t32;
30 typedef int __kernel_off_t32;
31 typedef unsigned int __kernel_caddr_t32;
32 typedef long __kernel_loff_t32;
33 typedef __kernel_fsid_t __kernel_fsid_t32;
34
35 #define IA32_PAGE_SHIFT 12 /* 4KB pages */
36 #define IA32_PAGE_SIZE (1ULL << IA32_PAGE_SHIFT)
37 #define IA32_CLOCKS_PER_SEC 100 /* Cast in stone for IA32 Linux */
38 #define IA32_TICK(tick) ((unsigned long long)(tick) * IA32_CLOCKS_PER_SEC / CLOCKS_PER_SEC)
39
40 /* fcntl.h */
41 struct flock32 {
42 short l_type;
43 short l_whence;
44 __kernel_off_t32 l_start;
45 __kernel_off_t32 l_len;
46 __kernel_pid_t32 l_pid;
47 };
48
49
50 /* sigcontext.h */
51 /*
52 * As documented in the iBCS2 standard..
53 *
54 * The first part of "struct _fpstate" is just the
55 * normal i387 hardware setup, the extra "status"
56 * word is used to save the coprocessor status word
57 * before entering the handler.
58 */
59 struct _fpreg_ia32 {
60 unsigned short significand[4];
61 unsigned short exponent;
62 };
63
64 struct _fpstate_ia32 {
65 unsigned int cw,
66 sw,
67 tag,
68 ipoff,
69 cssel,
70 dataoff,
71 datasel;
72 struct _fpreg_ia32 _st[8];
73 unsigned int status;
74 };
75
76 struct sigcontext_ia32 {
77 unsigned short gs, __gsh;
78 unsigned short fs, __fsh;
79 unsigned short es, __esh;
80 unsigned short ds, __dsh;
81 unsigned int edi;
82 unsigned int esi;
83 unsigned int ebp;
84 unsigned int esp;
85 unsigned int ebx;
86 unsigned int edx;
87 unsigned int ecx;
88 unsigned int eax;
89 unsigned int trapno;
90 unsigned int err;
91 unsigned int eip;
92 unsigned short cs, __csh;
93 unsigned int eflags;
94 unsigned int esp_at_signal;
95 unsigned short ss, __ssh;
96 unsigned int fpstate; /* really (struct _fpstate_ia32 *) */
97 unsigned int oldmask;
98 unsigned int cr2;
99 };
100
101 /* signal.h */
102 #define _IA32_NSIG 64
103 #define _IA32_NSIG_BPW 32
104 #define _IA32_NSIG_WORDS (_IA32_NSIG / _IA32_NSIG_BPW)
105
106 typedef struct {
107 unsigned int sig[_IA32_NSIG_WORDS];
108 } sigset32_t;
109
110 struct sigaction32 {
111 unsigned int sa_handler; /* Really a pointer, but need to deal
112 with 32 bits */
113 unsigned int sa_flags;
114 unsigned int sa_restorer; /* Another 32 bit pointer */
115 sigset32_t sa_mask; /* A 32 bit mask */
116 };
117
118 typedef unsigned int old_sigset32_t; /* at least 32 bits */
119
120 struct old_sigaction32 {
121 unsigned int sa_handler; /* Really a pointer, but need to deal
122 with 32 bits */
123 old_sigset32_t sa_mask; /* A 32 bit mask */
124 unsigned int sa_flags;
125 unsigned int sa_restorer; /* Another 32 bit pointer */
126 };
127
128 typedef struct sigaltstack_ia32 {
129 unsigned int ss_sp;
130 int ss_flags;
131 unsigned int ss_size;
132 } stack_ia32_t;
133
134 struct ucontext_ia32 {
135 unsigned int uc_flags;
136 unsigned int uc_link;
137 stack_ia32_t uc_stack;
138 struct sigcontext_ia32 uc_mcontext;
139 sigset_t uc_sigmask; /* mask last for extensibility */
140 };
141
142 struct stat32 {
143 unsigned short st_dev;
144 unsigned short __pad1;
145 unsigned int st_ino;
146 unsigned short st_mode;
147 unsigned short st_nlink;
148 unsigned short st_uid;
149 unsigned short st_gid;
150 unsigned short st_rdev;
151 unsigned short __pad2;
152 unsigned int st_size;
153 unsigned int st_blksize;
154 unsigned int st_blocks;
155 unsigned int st_atime;
156 unsigned int __unused1;
157 unsigned int st_mtime;
158 unsigned int __unused2;
159 unsigned int st_ctime;
160 unsigned int __unused3;
161 unsigned int __unused4;
162 unsigned int __unused5;
163 };
164
165 struct statfs32 {
166 int f_type;
167 int f_bsize;
168 int f_blocks;
169 int f_bfree;
170 int f_bavail;
171 int f_files;
172 int f_ffree;
173 __kernel_fsid_t32 f_fsid;
174 int f_namelen; /* SunOS ignores this field. */
175 int f_spare[6];
176 };
177
178 typedef union sigval32 {
179 int sival_int;
180 unsigned int sival_ptr;
181 } sigval_t32;
182
183 typedef struct siginfo32 {
184 int si_signo;
185 int si_errno;
186 int si_code;
187
188 union {
189 int _pad[((128/sizeof(int)) - 3)];
190
191 /* kill() */
192 struct {
193 unsigned int _pid; /* sender's pid */
194 unsigned int _uid; /* sender's uid */
195 } _kill;
196
197 /* POSIX.1b timers */
198 struct {
199 unsigned int _timer1;
200 unsigned int _timer2;
201 } _timer;
202
203 /* POSIX.1b signals */
204 struct {
205 unsigned int _pid; /* sender's pid */
206 unsigned int _uid; /* sender's uid */
207 sigval_t32 _sigval;
208 } _rt;
209
210 /* SIGCHLD */
211 struct {
212 unsigned int _pid; /* which child */
213 unsigned int _uid; /* sender's uid */
214 int _status; /* exit code */
215 __kernel_clock_t32 _utime;
216 __kernel_clock_t32 _stime;
217 } _sigchld;
218
219 /* SIGILL, SIGFPE, SIGSEGV, SIGBUS */
220 struct {
221 unsigned int _addr; /* faulting insn/memory ref. */
222 } _sigfault;
223
224 /* SIGPOLL */
225 struct {
226 int _band; /* POLL_IN, POLL_OUT, POLL_MSG */
227 int _fd;
228 } _sigpoll;
229 } _sifields;
230 } siginfo_t32;
231
232
233 /*
234 * IA-32 ELF specific definitions for IA-64.
235 */
236
237 #define _ASM_IA64_ELF_H /* Don't include elf.h */
238
239 #include <linux/sched.h>
240 #include <asm/processor.h>
241
242 /*
243 * This is used to ensure we don't load something for the wrong architecture.
244 */
245 #define elf_check_arch(x) ((x)->e_machine == EM_386)
246
247 /*
248 * These are used to set parameters in the core dumps.
249 */
250 #define ELF_CLASS ELFCLASS32
251 #define ELF_DATA ELFDATA2LSB
252 #define ELF_ARCH EM_386
253
254 #define IA32_PAGE_OFFSET 0xc0000000
255
256 #define USE_ELF_CORE_DUMP
257 #define ELF_EXEC_PAGESIZE IA32_PAGE_SIZE
258
259 /*
260 * This is the location that an ET_DYN program is loaded if exec'ed.
261 * Typical use of this is to invoke "./ld.so someprog" to test out a
262 * new version of the loader. We need to make sure that it is out of
263 * the way of the program that it will "exec", and that there is
264 * sufficient room for the brk.
265 */
266 #define ELF_ET_DYN_BASE (IA32_PAGE_OFFSET/3 + 0x1000000)
267
268 void ia64_elf32_init(struct pt_regs *regs);
269 #define ELF_PLAT_INIT(_r) ia64_elf32_init(_r)
270
271 #define elf_addr_t u32
272 #define elf_caddr_t u32
273
274 /* ELF register definitions. This is needed for core dump support. */
275
276 #define ELF_NGREG 128 /* XXX fix me */
277 #define ELF_NFPREG 128 /* XXX fix me */
278
279 typedef unsigned long elf_greg_t;
280 typedef elf_greg_t elf_gregset_t[ELF_NGREG];
281
282 typedef struct {
283 unsigned long w0;
284 unsigned long w1;
285 } elf_fpreg_t;
286 typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
287
288 /* This macro yields a bitmask that programs can use to figure out
289 what instruction set this CPU supports. */
290 #define ELF_HWCAP 0
291
292 /* This macro yields a string that ld.so will use to load
293 implementation specific libraries for optimization. Not terribly
294 relevant until we have real hardware to play with... */
295 #define ELF_PLATFORM 0
296
297 #ifdef __KERNEL__
298 # define SET_PERSONALITY(EX,IBCS2) \
299 (current->personality = (IBCS2) ? PER_SVR4 : PER_LINUX)
300 #endif
301
302 #define IA32_EFLAG 0x200
303
304 /*
305 * IA-32 ELF specific definitions for IA-64.
306 */
307
308 #define __USER_CS 0x23
309 #define __USER_DS 0x2B
310
311 #define SEG_LIM 32
312 #define SEG_TYPE 52
313 #define SEG_SYS 56
314 #define SEG_DPL 57
315 #define SEG_P 59
316 #define SEG_DB 62
317 #define SEG_G 63
318
319 #define FIRST_TSS_ENTRY 6
320 #define FIRST_LDT_ENTRY (FIRST_TSS_ENTRY+1)
321 #define _TSS(n) ((((unsigned long) n)<<4)+(FIRST_TSS_ENTRY<<3))
322 #define _LDT(n) ((((unsigned long) n)<<4)+(FIRST_LDT_ENTRY<<3))
323
324 #define IA64_SEG_DESCRIPTOR(base, limit, segtype, nonsysseg, dpl, segpresent, segdb, granularity) \
325 ((base) | \
326 (limit << SEG_LIM) | \
327 (segtype << SEG_TYPE) | \
328 (nonsysseg << SEG_SYS) | \
329 (dpl << SEG_DPL) | \
330 (segpresent << SEG_P) | \
331 (segdb << SEG_DB) | \
332 (granularity << SEG_G))
333
334 #define IA32_SEG_BASE 16
335 #define IA32_SEG_TYPE 40
336 #define IA32_SEG_SYS 44
337 #define IA32_SEG_DPL 45
338 #define IA32_SEG_P 47
339 #define IA32_SEG_HIGH_LIMIT 48
340 #define IA32_SEG_AVL 52
341 #define IA32_SEG_DB 54
342 #define IA32_SEG_G 55
343 #define IA32_SEG_HIGH_BASE 56
344
345 #define IA32_SEG_DESCRIPTOR(base, limit, segtype, nonsysseg, dpl, segpresent, avl, segdb, granularity) \
346 ((limit & 0xFFFF) | \
347 (base & 0xFFFFFF << IA32_SEG_BASE) | \
348 (segtype << IA32_SEG_TYPE) | \
349 (nonsysseg << IA32_SEG_SYS) | \
350 (dpl << IA32_SEG_DPL) | \
351 (segpresent << IA32_SEG_P) | \
352 (((limit >> 16) & 0xF) << IA32_SEG_HIGH_LIMIT) | \
353 (avl << IA32_SEG_AVL) | \
354 (segdb << IA32_SEG_DB) | \
355 (granularity << IA32_SEG_G) | \
356 (((base >> 24) & 0xFF) << IA32_SEG_HIGH_BASE))
357
358 #define IA32_IOBASE 0x2000000000000000 /* Virtual addres for I/O space */
359
360 #define IA32_CR0 0x80000001 /* Enable PG and PE bits */
361 #define IA32_CR4 0 /* No architectural extensions */
362
363 /*
364 * IA32 floating point control registers starting values
365 */
366
367 #define IA32_FSR_DEFAULT 0x55550000 /* set all tag bits */
368 #define IA32_FCR_DEFAULT 0x17800000037fULL /* extended precision, all masks */
369
370 #define IA32_PTRACE_GETREGS 12
371 #define IA32_PTRACE_SETREGS 13
372 #define IA32_PTRACE_GETFPREGS 14
373 #define IA32_PTRACE_SETFPREGS 15
374
375 #define ia32_start_thread(regs,new_ip,new_sp) do { \
376 set_fs(USER_DS); \
377 ia64_psr(regs)->cpl = 3; /* set user mode */ \
378 ia64_psr(regs)->ri = 0; /* clear return slot number */ \
379 ia64_psr(regs)->is = 1; /* IA-32 instruction set */ \
380 regs->cr_iip = new_ip; \
381 regs->r12 = new_sp; \
382 regs->ar_rnat = 0; \
383 regs->loadrs = 0; \
384 } while (0)
385
386 extern void ia32_gdt_init (void);
387 extern int ia32_setup_frame1 (int sig, struct k_sigaction *ka, siginfo_t *info,
388 sigset_t *set, struct pt_regs *regs);
389 extern void ia32_init_addr_space (struct pt_regs *regs);
390 extern int ia32_setup_arg_pages (struct linux_binprm *bprm);
391 extern int ia32_exception (struct pt_regs *regs, unsigned long isr);
392
393 #endif /* !CONFIG_IA32_SUPPORT */
394
395 #endif /* _ASM_IA64_IA32_H */
396
This page was automatically generated by the
LXR engine.
Visit the LXR main site for more
information.