1 #ifndef _ASM_IA64_IA32_H
2 #define _ASM_IA64_IA32_H
4 #include <linux/config.h>
6 #ifdef CONFIG_IA32_SUPPORT
8 #include <linux/param.h>
11 * 32 bit structures for IA32 support.
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 int __kernel_uid32_t32;
24 typedef unsigned short __kernel_gid_t32;
25 typedef unsigned int __kernel_gid32_t32;
26 typedef unsigned short __kernel_dev_t32;
27 typedef unsigned int __kernel_ino_t32;
28 typedef unsigned short __kernel_mode_t32;
29 typedef unsigned short __kernel_umode_t32;
30 typedef short __kernel_nlink_t32;
31 typedef int __kernel_daddr_t32;
32 typedef int __kernel_off_t32;
33 typedef unsigned int __kernel_caddr_t32;
34 typedef long __kernel_loff_t32;
35 typedef __kernel_fsid_t __kernel_fsid_t32;
37 #define IA32_PAGE_SHIFT 12 /* 4KB pages */
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 /* Cast in stone for IA32 Linux */
42 #define IA32_TICK(tick) ((unsigned long long)(tick) * IA32_CLOCKS_PER_SEC / CLOCKS_PER_SEC)
53 __kernel_off_t32 l_start;
54 __kernel_off_t32 l_len;
55 __kernel_pid_t32 l_pid;
64 * As documented in the iBCS2 standard..
66 * The first part of "struct _fpstate" is just the
67 * normal i387 hardware setup, the extra "status"
68 * word is used to save the coprocessor status word
69 * before entering the handler.
72 unsigned short significand[4];
73 unsigned short exponent;
77 unsigned short significand[4];
78 unsigned short exponent;
79 unsigned short padding[3];
83 unsigned int element[4];
87 struct _fpstate_ia32 {
95 struct _fpreg_ia32 _st[8];
96 unsigned short status;
97 unsigned short magic; /* 0xffff = regular FPU data only */
99 /* FXSR FPU environment */
100 unsigned int _fxsr_env[6]; /* FXSR FPU env is ignored */
102 unsigned int reserved;
103 struct _fpxreg_ia32 _fxsr_st[8]; /* FXSR FPU reg data is ignored */
104 struct _xmmreg_ia32 _xmm[8];
105 unsigned int padding[56];
108 struct sigcontext_ia32 {
109 unsigned short gs, __gsh;
110 unsigned short fs, __fsh;
111 unsigned short es, __esh;
112 unsigned short ds, __dsh;
124 unsigned short cs, __csh;
126 unsigned int esp_at_signal;
127 unsigned short ss, __ssh;
128 unsigned int fpstate; /* really (struct _fpstate_ia32 *) */
129 unsigned int oldmask;
135 * IA32 (Pentium III/4) FXSR, SSE support
137 * Provide support for the GDB 5.0+ PTRACE_{GET|SET}FPXREGS requests for
138 * interacting with the FXSR-format floating point environment. Floating
139 * point data can be accessed in the regular format in the usual manner,
140 * and both the standard and SIMD floating point data can be accessed via
141 * the new ptrace requests. In either case, changes to the FPU environment
142 * will be reflected in the task's state as expected.
144 struct ia32_user_i387_struct {
152 int st_space[20]; /* 8*10 bytes for each FP-reg = 80 bytes */
155 struct ia32_user_fxsr_struct {
166 int st_space[32]; /* 8*16 bytes for each FP-reg = 128 bytes */
167 int xmm_space[32]; /* 8*16 bytes for each XMM-reg = 128 bytes */
172 #define _IA32_NSIG 64
173 #define _IA32_NSIG_BPW 32
174 #define _IA32_NSIG_WORDS (_IA32_NSIG / _IA32_NSIG_BPW)
176 #define IA32_SET_SA_HANDLER(ka,handler,restorer) \
177 ((ka)->sa.sa_handler = (__sighandler_t) \
178 (((unsigned long)(restorer) << 32) \
179 | ((handler) & 0xffffffff)))
180 #define IA32_SA_HANDLER(ka) ((unsigned long) (ka)->sa.sa_handler & 0xffffffff)
181 #define IA32_SA_RESTORER(ka) ((unsigned long) (ka)->sa.sa_handler >> 32)
184 unsigned int sig[_IA32_NSIG_WORDS];
188 unsigned int sa_handler; /* Really a pointer, but need to deal with 32 bits */
189 unsigned int sa_flags;
190 unsigned int sa_restorer; /* Another 32 bit pointer */
191 sigset32_t sa_mask; /* A 32 bit mask */
194 typedef unsigned int old_sigset32_t; /* at least 32 bits */
196 struct old_sigaction32 {
197 unsigned int sa_handler; /* Really a pointer, but need to deal
199 old_sigset32_t sa_mask; /* A 32 bit mask */
200 unsigned int sa_flags;
201 unsigned int sa_restorer; /* Another 32 bit pointer */
204 typedef struct sigaltstack_ia32 {
207 unsigned int ss_size;
210 struct ucontext_ia32 {
211 unsigned int uc_flags;
212 unsigned int uc_link;
213 stack_ia32_t uc_stack;
214 struct sigcontext_ia32 uc_mcontext;
215 sigset_t uc_sigmask; /* mask last for extensibility */
219 unsigned short st_dev;
220 unsigned short __pad1;
222 unsigned short st_mode;
223 unsigned short st_nlink;
224 unsigned short st_uid;
225 unsigned short st_gid;
226 unsigned short st_rdev;
227 unsigned short __pad2;
228 unsigned int st_size;
229 unsigned int st_blksize;
230 unsigned int st_blocks;
231 unsigned int st_atime;
232 unsigned int __unused1;
233 unsigned int st_mtime;
234 unsigned int __unused2;
235 unsigned int st_ctime;
236 unsigned int __unused3;
237 unsigned int __unused4;
238 unsigned int __unused5;
242 unsigned short st_dev;
243 unsigned char __pad0[10];
244 unsigned int __st_ino;
245 unsigned int st_mode;
246 unsigned int st_nlink;
249 unsigned short st_rdev;
250 unsigned char __pad3[10];
251 unsigned int st_size_lo;
252 unsigned int st_size_hi;
253 unsigned int st_blksize;
254 unsigned int st_blocks; /* Number 512-byte blocks allocated. */
255 unsigned int __pad4; /* future possible st_blocks high bits */
256 unsigned int st_atime;
258 unsigned int st_mtime;
260 unsigned int st_ctime;
261 unsigned int __pad7; /* will be high 32 bits of ctime someday */
262 unsigned int st_ino_lo;
263 unsigned int st_ino_hi;
274 __kernel_fsid_t32 f_fsid;
275 int f_namelen; /* SunOS ignores this field. */
279 typedef union sigval32 {
281 unsigned int sival_ptr;
284 typedef struct siginfo32 {
290 int _pad[((128/sizeof(int)) - 3)];
294 unsigned int _pid; /* sender's pid */
295 unsigned int _uid; /* sender's uid */
298 /* POSIX.1b timers */
300 unsigned int _timer1;
301 unsigned int _timer2;
304 /* POSIX.1b signals */
306 unsigned int _pid; /* sender's pid */
307 unsigned int _uid; /* sender's uid */
313 unsigned int _pid; /* which child */
314 unsigned int _uid; /* sender's uid */
315 int _status; /* exit code */
316 __kernel_clock_t32 _utime;
317 __kernel_clock_t32 _stime;
320 /* SIGILL, SIGFPE, SIGSEGV, SIGBUS */
322 unsigned int _addr; /* faulting insn/memory ref. */
327 int _band; /* POLL_IN, POLL_OUT, POLL_MSG */
333 struct linux32_dirent {
340 struct old_linux32_dirent {
348 * IA-32 ELF specific definitions for IA-64.
351 #define _ASM_IA64_ELF_H /* Don't include elf.h */
353 #include <linux/sched.h>
354 #include <asm/processor.h>
357 * This is used to ensure we don't load something for the wrong architecture.
359 #define elf_check_arch(x) ((x)->e_machine == EM_386)
362 * These are used to set parameters in the core dumps.
364 #define ELF_CLASS ELFCLASS32
365 #define ELF_DATA ELFDATA2LSB
366 #define ELF_ARCH EM_386
368 #define IA32_PAGE_OFFSET 0xc0000000
369 #define IA32_STACK_TOP IA32_PAGE_OFFSET
372 * The system segments (GDT, TSS, LDT) have to be mapped below 4GB so the IA-32 engine can
375 #define IA32_GDT_OFFSET (IA32_PAGE_OFFSET)
376 #define IA32_TSS_OFFSET (IA32_PAGE_OFFSET + PAGE_SIZE)
377 #define IA32_LDT_OFFSET (IA32_PAGE_OFFSET + 2*PAGE_SIZE)
379 #define USE_ELF_CORE_DUMP
380 #define ELF_EXEC_PAGESIZE IA32_PAGE_SIZE
383 * This is the location that an ET_DYN program is loaded if exec'ed.
384 * Typical use of this is to invoke "./ld.so someprog" to test out a
385 * new version of the loader. We need to make sure that it is out of
386 * the way of the program that it will "exec", and that there is
387 * sufficient room for the brk.
389 #define ELF_ET_DYN_BASE (IA32_PAGE_OFFSET/3 + 0x1000000)
391 void ia64_elf32_init(struct pt_regs *regs);
392 #define ELF_PLAT_INIT(_r) ia64_elf32_init(_r)
394 #define elf_addr_t u32
395 #define elf_caddr_t u32
397 /* ELF register definitions. This is needed for core dump support. */
399 #define ELF_NGREG 128 /* XXX fix me */
400 #define ELF_NFPREG 128 /* XXX fix me */
402 typedef unsigned long elf_greg_t;
403 typedef elf_greg_t elf_gregset_t[ELF_NGREG];
409 typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
411 /* This macro yields a bitmask that programs can use to figure out
412 what instruction set this CPU supports. */
415 /* This macro yields a string that ld.so will use to load
416 implementation specific libraries for optimization. Not terribly
417 relevant until we have real hardware to play with... */
418 #define ELF_PLATFORM 0
421 # define SET_PERSONALITY(EX,IBCS2) \
422 (current->personality = (IBCS2) ? PER_SVR4 : PER_LINUX)
425 #define IA32_EFLAG 0x200
428 * IA-32 ELF specific definitions for IA-64.
431 #define __USER_CS 0x23
432 #define __USER_DS 0x2B
434 #define FIRST_TSS_ENTRY 6
435 #define FIRST_LDT_ENTRY (FIRST_TSS_ENTRY+1)
436 #define _TSS(n) ((((unsigned long) n)<<4)+(FIRST_TSS_ENTRY<<3))
437 #define _LDT(n) ((((unsigned long) n)<<4)+(FIRST_LDT_ENTRY<<3))
439 #define IA32_SEGSEL_RPL (0x3 << 0)
440 #define IA32_SEGSEL_TI (0x1 << 2)
441 #define IA32_SEGSEL_INDEX_SHIFT 3
443 #define IA32_SEG_BASE 16
444 #define IA32_SEG_TYPE 40
445 #define IA32_SEG_SYS 44
446 #define IA32_SEG_DPL 45
447 #define IA32_SEG_P 47
448 #define IA32_SEG_HIGH_LIMIT 48
449 #define IA32_SEG_AVL 52
450 #define IA32_SEG_DB 54
451 #define IA32_SEG_G 55
452 #define IA32_SEG_HIGH_BASE 56
454 #define IA32_SEG_DESCRIPTOR(base, limit, segtype, nonsysseg, dpl, segpresent, avl, segdb, gran) \
455 (((limit) & 0xffff) \
456 | (((unsigned long) (base) & 0xffffff) << IA32_SEG_BASE) \
457 | ((unsigned long) (segtype) << IA32_SEG_TYPE) \
458 | ((unsigned long) (nonsysseg) << IA32_SEG_SYS) \
459 | ((unsigned long) (dpl) << IA32_SEG_DPL) \
460 | ((unsigned long) (segpresent) << IA32_SEG_P) \
461 | ((((unsigned long) (limit) >> 16) & 0xf) << IA32_SEG_HIGH_LIMIT) \
462 | ((unsigned long) (avl) << IA32_SEG_AVL) \
463 | ((unsigned long) (segdb) << IA32_SEG_DB) \
464 | ((unsigned long) (gran) << IA32_SEG_G) \
465 | ((((unsigned long) (base) >> 24) & 0xff) << IA32_SEG_HIGH_BASE))
476 /* Unscramble an IA-32 segment descriptor into the IA-64 format. */
477 #define IA32_SEG_UNSCRAMBLE(sd) \
478 ( (((sd) >> IA32_SEG_BASE) & 0xffffff) | ((((sd) >> IA32_SEG_HIGH_BASE) & 0xff) << 24) \
479 | ((((sd) & 0xffff) | ((((sd) >> IA32_SEG_HIGH_LIMIT) & 0xf) << 16)) << SEG_LIM) \
480 | ((((sd) >> IA32_SEG_TYPE) & 0xf) << SEG_TYPE) \
481 | ((((sd) >> IA32_SEG_SYS) & 0x1) << SEG_SYS) \
482 | ((((sd) >> IA32_SEG_DPL) & 0x3) << SEG_DPL) \
483 | ((((sd) >> IA32_SEG_P) & 0x1) << SEG_P) \
484 | ((((sd) >> IA32_SEG_AVL) & 0x1) << SEG_AVL) \
485 | ((((sd) >> IA32_SEG_DB) & 0x1) << SEG_DB) \
486 | ((((sd) >> IA32_SEG_G) & 0x1) << SEG_G))
488 #define IA32_IOBASE 0x2000000000000000 /* Virtual address for I/O space */
490 #define IA32_CR0 0x80000001 /* Enable PG and PE bits */
491 #define IA32_CR4 0x600 /* MMXEX and FXSR on */
494 * IA32 floating point control registers starting values
497 #define IA32_FSR_DEFAULT 0x55550000 /* set all tag bits */
498 #define IA32_FCR_DEFAULT 0x17800000037fUL /* extended precision, all masks */
500 #define IA32_PTRACE_GETREGS 12
501 #define IA32_PTRACE_SETREGS 13
502 #define IA32_PTRACE_GETFPREGS 14
503 #define IA32_PTRACE_SETFPREGS 15
504 #define IA32_PTRACE_GETFPXREGS 18
505 #define IA32_PTRACE_SETFPXREGS 19
507 #define ia32_start_thread(regs,new_ip,new_sp) do { \
509 ia64_psr(regs)->cpl = 3; /* set user mode */ \
510 ia64_psr(regs)->ri = 0; /* clear return slot number */ \
511 ia64_psr(regs)->is = 1; /* IA-32 instruction set */ \
512 regs->cr_iip = new_ip; \
513 regs->ar_rsc = 0xc; /* enforced lazy mode, priv. level 3 */ \
516 regs->r12 = new_sp; \
520 * Local Descriptor Table (LDT) related declarations.
523 #define IA32_LDT_ENTRIES 8192 /* Maximum number of LDT entries supported. */
524 #define IA32_LDT_ENTRY_SIZE 8 /* The size of each LDT entry. */
526 struct ia32_modify_ldt_ldt_s {
527 unsigned int entry_number;
528 unsigned int base_addr;
530 unsigned int seg_32bit:1;
531 unsigned int contents:2;
532 unsigned int read_exec_only:1;
533 unsigned int limit_in_pages:1;
534 unsigned int seg_not_present:1;
535 unsigned int useable:1;
538 extern void ia32_gdt_init (void);
539 extern int ia32_setup_frame1 (int sig, struct k_sigaction *ka, siginfo_t *info,
540 sigset_t *set, struct pt_regs *regs);
541 extern void ia32_init_addr_space (struct pt_regs *regs);
542 extern int ia32_setup_arg_pages (struct linux_binprm *bprm);
543 extern int ia32_exception (struct pt_regs *regs, unsigned long isr);
544 extern int ia32_intercept (struct pt_regs *regs, unsigned long isr);
545 extern unsigned long ia32_do_mmap (struct file *, unsigned long, unsigned long, int, int, loff_t);
546 extern void ia32_load_segment_descriptors (struct task_struct *task);
548 #define ia32f2ia64f(dst,src) \
550 register double f6 asm ("f6"); \
551 asm volatile ("ldfe f6=[%2];; stf.spill [%1]=f6" : "=f"(f6): "r"(dst), "r"(src) : "memory"); \
554 #define ia64f2ia32f(dst,src) \
556 register double f6 asm ("f6"); \
557 asm volatile ("ldf.fill f6=[%2];; stfe [%1]=f6" : "=f"(f6): "r"(dst), "r"(src) : "memory"); \
560 #endif /* !CONFIG_IA32_SUPPORT */
562 #endif /* _ASM_IA64_IA32_H */