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
12
13
14
15typedef unsigned int __kernel_size_t32;
16typedef int __kernel_ssize_t32;
17typedef int __kernel_ptrdiff_t32;
18typedef int __kernel_time_t32;
19typedef int __kernel_clock_t32;
20typedef int __kernel_pid_t32;
21typedef unsigned short __kernel_ipc_pid_t32;
22typedef unsigned short __kernel_uid_t32;
23typedef unsigned int __kernel_uid32_t32;
24typedef unsigned short __kernel_gid_t32;
25typedef unsigned int __kernel_gid32_t32;
26typedef unsigned short __kernel_dev_t32;
27typedef unsigned int __kernel_ino_t32;
28typedef unsigned short __kernel_mode_t32;
29typedef unsigned short __kernel_umode_t32;
30typedef short __kernel_nlink_t32;
31typedef int __kernel_daddr_t32;
32typedef int __kernel_off_t32;
33typedef unsigned int __kernel_caddr_t32;
34typedef long __kernel_loff_t32;
35typedef __kernel_fsid_t __kernel_fsid_t32;
36
37#define IA32_PAGE_SHIFT 12
38#define IA32_PAGE_SIZE (1UL << IA32_PAGE_SHIFT)
39#define IA32_PAGE_MASK (~(IA32_PAGE_SIZE - 1))
40#define IA32_PAGE_ALIGN(addr) (((addr) + IA32_PAGE_SIZE - 1) & IA32_PAGE_MASK)
41#define IA32_CLOCKS_PER_SEC 100
42#define IA32_TICK(tick) ((unsigned long long)(tick) * IA32_CLOCKS_PER_SEC / CLOCKS_PER_SEC)
43
44struct timespec32 {
45 int tv_sec;
46 int tv_nsec;
47};
48
49
50struct flock32 {
51 short l_type;
52 short l_whence;
53 __kernel_off_t32 l_start;
54 __kernel_off_t32 l_len;
55 __kernel_pid_t32 l_pid;
56};
57
58#define F_GETLK64 12
59#define F_SETLK64 13
60#define F_SETLKW64 14
61
62
63
64
65
66
67
68
69
70
71struct _fpreg_ia32 {
72 unsigned short significand[4];
73 unsigned short exponent;
74};
75
76struct _fpxreg_ia32 {
77 unsigned short significand[4];
78 unsigned short exponent;
79 unsigned short padding[3];
80};
81
82struct _xmmreg_ia32 {
83 unsigned int element[4];
84};
85
86
87struct _fpstate_ia32 {
88 unsigned int cw,
89 sw,
90 tag,
91 ipoff,
92 cssel,
93 dataoff,
94 datasel;
95 struct _fpreg_ia32 _st[8];
96 unsigned short status;
97 unsigned short magic;
98
99
100 unsigned int _fxsr_env[6];
101 unsigned int mxcsr;
102 unsigned int reserved;
103 struct _fpxreg_ia32 _fxsr_st[8];
104 struct _xmmreg_ia32 _xmm[8];
105 unsigned int padding[56];
106};
107
108struct sigcontext_ia32 {
109 unsigned short gs, __gsh;
110 unsigned short fs, __fsh;
111 unsigned short es, __esh;
112 unsigned short ds, __dsh;
113 unsigned int edi;
114 unsigned int esi;
115 unsigned int ebp;
116 unsigned int esp;
117 unsigned int ebx;
118 unsigned int edx;
119 unsigned int ecx;
120 unsigned int eax;
121 unsigned int trapno;
122 unsigned int err;
123 unsigned int eip;
124 unsigned short cs, __csh;
125 unsigned int eflags;
126 unsigned int esp_at_signal;
127 unsigned short ss, __ssh;
128 unsigned int fpstate;
129 unsigned int oldmask;
130 unsigned int cr2;
131};
132
133
134
135
136
137
138
139
140
141
142
143
144struct ia32_user_i387_struct {
145 int cwd;
146 int swd;
147 int twd;
148 int fip;
149 int fcs;
150 int foo;
151 int fos;
152
153 struct _fpreg_ia32 st_space[8];
154};
155
156struct ia32_user_fxsr_struct {
157 unsigned short cwd;
158 unsigned short swd;
159 unsigned short twd;
160 unsigned short fop;
161 int fip;
162 int fcs;
163 int foo;
164 int fos;
165 int mxcsr;
166 int reserved;
167 int st_space[32];
168 int xmm_space[32];
169 int padding[56];
170};
171
172
173#define _IA32_NSIG 64
174#define _IA32_NSIG_BPW 32
175#define _IA32_NSIG_WORDS (_IA32_NSIG / _IA32_NSIG_BPW)
176
177#define IA32_SET_SA_HANDLER(ka,handler,restorer) \
178 ((ka)->sa.sa_handler = (__sighandler_t) \
179 (((unsigned long)(restorer) << 32) \
180 | ((handler) & 0xffffffff)))
181#define IA32_SA_HANDLER(ka) ((unsigned long) (ka)->sa.sa_handler & 0xffffffff)
182#define IA32_SA_RESTORER(ka) ((unsigned long) (ka)->sa.sa_handler >> 32)
183
184typedef struct {
185 unsigned int sig[_IA32_NSIG_WORDS];
186} sigset32_t;
187
188struct sigaction32 {
189 unsigned int sa_handler;
190 unsigned int sa_flags;
191 unsigned int sa_restorer;
192 sigset32_t sa_mask;
193};
194
195typedef unsigned int old_sigset32_t;
196
197struct old_sigaction32 {
198 unsigned int sa_handler;
199
200 old_sigset32_t sa_mask;
201 unsigned int sa_flags;
202 unsigned int sa_restorer;
203};
204
205typedef struct sigaltstack_ia32 {
206 unsigned int ss_sp;
207 int ss_flags;
208 unsigned int ss_size;
209} stack_ia32_t;
210
211struct ucontext_ia32 {
212 unsigned int uc_flags;
213 unsigned int uc_link;
214 stack_ia32_t uc_stack;
215 struct sigcontext_ia32 uc_mcontext;
216 sigset_t uc_sigmask;
217};
218
219struct stat32 {
220 unsigned short st_dev;
221 unsigned short __pad1;
222 unsigned int st_ino;
223 unsigned short st_mode;
224 unsigned short st_nlink;
225 unsigned short st_uid;
226 unsigned short st_gid;
227 unsigned short st_rdev;
228 unsigned short __pad2;
229 unsigned int st_size;
230 unsigned int st_blksize;
231 unsigned int st_blocks;
232 unsigned int st_atime;
233 unsigned int __unused1;
234 unsigned int st_mtime;
235 unsigned int __unused2;
236 unsigned int st_ctime;
237 unsigned int __unused3;
238 unsigned int __unused4;
239 unsigned int __unused5;
240};
241
242struct stat64 {
243 unsigned short st_dev;
244 unsigned char __pad0[10];
245 unsigned int __st_ino;
246 unsigned int st_mode;
247 unsigned int st_nlink;
248 unsigned int st_uid;
249 unsigned int st_gid;
250 unsigned short st_rdev;
251 unsigned char __pad3[10];
252 unsigned int st_size_lo;
253 unsigned int st_size_hi;
254 unsigned int st_blksize;
255 unsigned int st_blocks;
256 unsigned int __pad4;
257 unsigned int st_atime;
258 unsigned int __pad5;
259 unsigned int st_mtime;
260 unsigned int __pad6;
261 unsigned int st_ctime;
262 unsigned int __pad7;
263 unsigned int st_ino_lo;
264 unsigned int st_ino_hi;
265};
266
267struct statfs32 {
268 int f_type;
269 int f_bsize;
270 int f_blocks;
271 int f_bfree;
272 int f_bavail;
273 int f_files;
274 int f_ffree;
275 __kernel_fsid_t32 f_fsid;
276 int f_namelen;
277 int f_spare[6];
278};
279
280typedef union sigval32 {
281 int sival_int;
282 unsigned int sival_ptr;
283} sigval_t32;
284
285typedef struct siginfo32 {
286 int si_signo;
287 int si_errno;
288 int si_code;
289
290 union {
291 int _pad[((128/sizeof(int)) - 3)];
292
293
294 struct {
295 unsigned int _pid;
296 unsigned int _uid;
297 } _kill;
298
299
300 struct {
301 unsigned int _timer1;
302 unsigned int _timer2;
303 } _timer;
304
305
306 struct {
307 unsigned int _pid;
308 unsigned int _uid;
309 sigval_t32 _sigval;
310 } _rt;
311
312
313 struct {
314 unsigned int _pid;
315 unsigned int _uid;
316 int _status;
317 __kernel_clock_t32 _utime;
318 __kernel_clock_t32 _stime;
319 } _sigchld;
320
321
322 struct {
323 unsigned int _addr;
324 } _sigfault;
325
326
327 struct {
328 int _band;
329 int _fd;
330 } _sigpoll;
331 } _sifields;
332} siginfo_t32;
333
334struct linux32_dirent {
335 u32 d_ino;
336 u32 d_off;
337 u16 d_reclen;
338 char d_name[256];
339};
340
341struct old_linux32_dirent {
342 u32 d_ino;
343 u32 d_offset;
344 u16 d_namlen;
345 char d_name[1];
346};
347
348
349
350
351
352#define _ASM_IA64_ELF_H
353
354#include <linux/sched.h>
355#include <asm/processor.h>
356
357
358
359
360#define elf_check_arch(x) ((x)->e_machine == EM_386)
361
362
363
364
365#define ELF_CLASS ELFCLASS32
366#define ELF_DATA ELFDATA2LSB
367#define ELF_ARCH EM_386
368
369#define IA32_PAGE_OFFSET 0xc0000000
370#define IA32_STACK_TOP IA32_PAGE_OFFSET
371
372
373
374
375
376#define IA32_GDT_OFFSET (IA32_PAGE_OFFSET)
377#define IA32_TSS_OFFSET (IA32_PAGE_OFFSET + PAGE_SIZE)
378#define IA32_LDT_OFFSET (IA32_PAGE_OFFSET + 2*PAGE_SIZE)
379
380#define ELF_EXEC_PAGESIZE IA32_PAGE_SIZE
381
382
383
384
385
386
387
388
389#define ELF_ET_DYN_BASE (IA32_PAGE_OFFSET/3 + 0x1000000)
390
391void ia64_elf32_init(struct pt_regs *regs);
392#define ELF_PLAT_INIT(_r, load_addr) ia64_elf32_init(_r)
393
394#define elf_addr_t u32
395#define elf_caddr_t u32
396
397
398
399#define ELF_HWCAP 0
400
401
402
403
404#define ELF_PLATFORM 0
405
406#ifdef __KERNEL__
407# define SET_PERSONALITY(EX,IBCS2) \
408 (current->personality = (IBCS2) ? PER_SVR4 : PER_LINUX)
409#endif
410
411#define IA32_EFLAG 0x200
412
413
414
415
416
417#define __USER_CS 0x23
418#define __USER_DS 0x2B
419
420#define FIRST_TSS_ENTRY 6
421#define FIRST_LDT_ENTRY (FIRST_TSS_ENTRY+1)
422#define _TSS(n) ((((unsigned long) n)<<4)+(FIRST_TSS_ENTRY<<3))
423#define _LDT(n) ((((unsigned long) n)<<4)+(FIRST_LDT_ENTRY<<3))
424
425#define IA32_SEGSEL_RPL (0x3 << 0)
426#define IA32_SEGSEL_TI (0x1 << 2)
427#define IA32_SEGSEL_INDEX_SHIFT 3
428
429#define IA32_SEG_BASE 16
430#define IA32_SEG_TYPE 40
431#define IA32_SEG_SYS 44
432#define IA32_SEG_DPL 45
433#define IA32_SEG_P 47
434#define IA32_SEG_HIGH_LIMIT 48
435#define IA32_SEG_AVL 52
436#define IA32_SEG_DB 54
437#define IA32_SEG_G 55
438#define IA32_SEG_HIGH_BASE 56
439
440#define IA32_SEG_DESCRIPTOR(base, limit, segtype, nonsysseg, dpl, segpresent, avl, segdb, gran) \
441 (((limit) & 0xffff) \
442 | (((unsigned long) (base) & 0xffffff) << IA32_SEG_BASE) \
443 | ((unsigned long) (segtype) << IA32_SEG_TYPE) \
444 | ((unsigned long) (nonsysseg) << IA32_SEG_SYS) \
445 | ((unsigned long) (dpl) << IA32_SEG_DPL) \
446 | ((unsigned long) (segpresent) << IA32_SEG_P) \
447 | ((((unsigned long) (limit) >> 16) & 0xf) << IA32_SEG_HIGH_LIMIT) \
448 | ((unsigned long) (avl) << IA32_SEG_AVL) \
449 | ((unsigned long) (segdb) << IA32_SEG_DB) \
450 | ((unsigned long) (gran) << IA32_SEG_G) \
451 | ((((unsigned long) (base) >> 24) & 0xff) << IA32_SEG_HIGH_BASE))
452
453#define SEG_LIM 32
454#define SEG_TYPE 52
455#define SEG_SYS 56
456#define SEG_DPL 57
457#define SEG_P 59
458#define SEG_AVL 60
459#define SEG_DB 62
460#define SEG_G 63
461
462
463#define IA32_SEG_UNSCRAMBLE(sd) \
464 ( (((sd) >> IA32_SEG_BASE) & 0xffffff) | ((((sd) >> IA32_SEG_HIGH_BASE) & 0xff) << 24) \
465 | ((((sd) & 0xffff) | ((((sd) >> IA32_SEG_HIGH_LIMIT) & 0xf) << 16)) << SEG_LIM) \
466 | ((((sd) >> IA32_SEG_TYPE) & 0xf) << SEG_TYPE) \
467 | ((((sd) >> IA32_SEG_SYS) & 0x1) << SEG_SYS) \
468 | ((((sd) >> IA32_SEG_DPL) & 0x3) << SEG_DPL) \
469 | ((((sd) >> IA32_SEG_P) & 0x1) << SEG_P) \
470 | ((((sd) >> IA32_SEG_AVL) & 0x1) << SEG_AVL) \
471 | ((((sd) >> IA32_SEG_DB) & 0x1) << SEG_DB) \
472 | ((((sd) >> IA32_SEG_G) & 0x1) << SEG_G))
473
474#define IA32_IOBASE 0x2000000000000000
475
476#define IA32_CR0 0x80000001
477#define IA32_CR4 0x600
478
479
480
481
482
483#define IA32_FSR_DEFAULT 0x55550000
484#define IA32_FCR_DEFAULT 0x17800000037fUL
485
486#define IA32_PTRACE_GETREGS 12
487#define IA32_PTRACE_SETREGS 13
488#define IA32_PTRACE_GETFPREGS 14
489#define IA32_PTRACE_SETFPREGS 15
490#define IA32_PTRACE_GETFPXREGS 18
491#define IA32_PTRACE_SETFPXREGS 19
492
493#define ia32_start_thread(regs,new_ip,new_sp) do { \
494 set_fs(USER_DS); \
495 ia64_psr(regs)->cpl = 3; \
496 ia64_psr(regs)->ri = 0; \
497 ia64_psr(regs)->is = 1; \
498 regs->cr_iip = new_ip; \
499 regs->ar_rsc = 0xc; \
500 regs->ar_rnat = 0; \
501 regs->loadrs = 0; \
502 regs->r12 = new_sp; \
503} while (0)
504
505
506
507
508
509#define IA32_LDT_ENTRIES 8192
510#define IA32_LDT_ENTRY_SIZE 8
511
512struct ia32_modify_ldt_ldt_s {
513 unsigned int entry_number;
514 unsigned int base_addr;
515 unsigned int limit;
516 unsigned int seg_32bit:1;
517 unsigned int contents:2;
518 unsigned int read_exec_only:1;
519 unsigned int limit_in_pages:1;
520 unsigned int seg_not_present:1;
521 unsigned int useable:1;
522};
523
524extern void ia32_gdt_init (void);
525extern int ia32_setup_frame1 (int sig, struct k_sigaction *ka, siginfo_t *info,
526 sigset_t *set, struct pt_regs *regs);
527extern void ia32_init_addr_space (struct pt_regs *regs);
528extern int ia32_setup_arg_pages (struct linux_binprm *bprm);
529extern int ia32_exception (struct pt_regs *regs, unsigned long isr);
530extern int ia32_intercept (struct pt_regs *regs, unsigned long isr);
531extern unsigned long ia32_do_mmap (struct file *, unsigned long, unsigned long, int, int, loff_t);
532extern void ia32_load_segment_descriptors (struct task_struct *task);
533
534#define ia32f2ia64f(dst,src) \
535 do { \
536 register double f6 asm ("f6"); \
537 asm volatile ("ldfe f6=[%2];; stf.spill [%1]=f6" : "=f"(f6): "r"(dst), "r"(src) : "memory"); \
538 } while(0)
539
540#define ia64f2ia32f(dst,src) \
541 do { \
542 register double f6 asm ("f6"); \
543 asm volatile ("ldf.fill f6=[%2];; stfe [%1]=f6" : "=f"(f6): "r"(dst), "r"(src) : "memory"); \
544 } while(0)
545
546struct user_regs_struct32 {
547 __u32 ebx, ecx, edx, esi, edi, ebp, eax;
548 unsigned short ds, __ds, es, __es;
549 unsigned short fs, __fs, gs, __gs;
550 __u32 orig_eax, eip;
551 unsigned short cs, __cs;
552 __u32 eflags, esp;
553 unsigned short ss, __ss;
554};
555
556
557int save_ia32_fpstate (struct task_struct *tsk,
558 struct ia32_user_i387_struct *save);
559
560int save_ia32_fpxstate (struct task_struct *tsk,
561 struct ia32_user_fxsr_struct *save);
562
563#endif
564
565#endif
566