1#ifndef _ASM_IA64_IA32_PRIV_H
2#define _ASM_IA64_IA32_PRIV_H
3
4
5#include <asm/ia32.h>
6
7#ifdef CONFIG_IA32_SUPPORT
8
9#include <linux/binfmts.h>
10#include <linux/compat.h>
11#include <linux/rbtree.h>
12
13#include <asm/processor.h>
14
15
16
17
18
19#define IA32_PAGE_SIZE (1UL << IA32_PAGE_SHIFT)
20#define IA32_PAGE_MASK (~(IA32_PAGE_SIZE - 1))
21#define IA32_PAGE_ALIGN(addr) (((addr) + IA32_PAGE_SIZE - 1) & IA32_PAGE_MASK)
22#define IA32_CLOCKS_PER_SEC 100
23
24
25
26
27
28struct ia64_partial_page {
29 struct ia64_partial_page *next;
30 struct rb_node pp_rb;
31
32
33 unsigned long bitmap;
34 unsigned int base;
35};
36
37struct ia64_partial_page_list {
38 struct ia64_partial_page *pp_head;
39
40 struct rb_root ppl_rb;
41 struct ia64_partial_page *pp_hint;
42
43 atomic_t pp_count;
44};
45
46#if PAGE_SHIFT > IA32_PAGE_SHIFT
47struct ia64_partial_page_list* ia32_init_pp_list (void);
48#else
49# define ia32_init_pp_list() 0
50#endif
51
52
53
54
55
56
57
58
59
60
61struct _fpreg_ia32 {
62 unsigned short significand[4];
63 unsigned short exponent;
64};
65
66struct _fpxreg_ia32 {
67 unsigned short significand[4];
68 unsigned short exponent;
69 unsigned short padding[3];
70};
71
72struct _xmmreg_ia32 {
73 unsigned int element[4];
74};
75
76
77struct _fpstate_ia32 {
78 unsigned int cw,
79 sw,
80 tag,
81 ipoff,
82 cssel,
83 dataoff,
84 datasel;
85 struct _fpreg_ia32 _st[8];
86 unsigned short status;
87 unsigned short magic;
88
89
90 unsigned int _fxsr_env[6];
91 unsigned int mxcsr;
92 unsigned int reserved;
93 struct _fpxreg_ia32 _fxsr_st[8];
94 struct _xmmreg_ia32 _xmm[8];
95 unsigned int padding[56];
96};
97
98struct sigcontext_ia32 {
99 unsigned short gs, __gsh;
100 unsigned short fs, __fsh;
101 unsigned short es, __esh;
102 unsigned short ds, __dsh;
103 unsigned int edi;
104 unsigned int esi;
105 unsigned int ebp;
106 unsigned int esp;
107 unsigned int ebx;
108 unsigned int edx;
109 unsigned int ecx;
110 unsigned int eax;
111 unsigned int trapno;
112 unsigned int err;
113 unsigned int eip;
114 unsigned short cs, __csh;
115 unsigned int eflags;
116 unsigned int esp_at_signal;
117 unsigned short ss, __ssh;
118 unsigned int fpstate;
119 unsigned int oldmask;
120 unsigned int cr2;
121};
122
123
124
125
126
127
128
129
130
131
132
133
134struct ia32_user_i387_struct {
135 int cwd;
136 int swd;
137 int twd;
138 int fip;
139 int fcs;
140 int foo;
141 int fos;
142
143 struct _fpreg_ia32 st_space[8];
144};
145
146struct ia32_user_fxsr_struct {
147 unsigned short cwd;
148 unsigned short swd;
149 unsigned short twd;
150 unsigned short fop;
151 int fip;
152 int fcs;
153 int foo;
154 int fos;
155 int mxcsr;
156 int reserved;
157 int st_space[32];
158 int xmm_space[32];
159 int padding[56];
160};
161
162
163#define IA32_SET_SA_HANDLER(ka,handler,restorer) \
164 ((ka)->sa.sa_handler = (__sighandler_t) \
165 (((unsigned long)(restorer) << 32) \
166 | ((handler) & 0xffffffff)))
167#define IA32_SA_HANDLER(ka) ((unsigned long) (ka)->sa.sa_handler & 0xffffffff)
168#define IA32_SA_RESTORER(ka) ((unsigned long) (ka)->sa.sa_handler >> 32)
169
170#define __IA32_NR_sigreturn 119
171#define __IA32_NR_rt_sigreturn 173
172
173struct sigaction32 {
174 unsigned int sa_handler;
175 unsigned int sa_flags;
176 unsigned int sa_restorer;
177 compat_sigset_t sa_mask;
178};
179
180struct old_sigaction32 {
181 unsigned int sa_handler;
182
183 compat_old_sigset_t sa_mask;
184 unsigned int sa_flags;
185 unsigned int sa_restorer;
186};
187
188typedef struct sigaltstack_ia32 {
189 unsigned int ss_sp;
190 int ss_flags;
191 unsigned int ss_size;
192} stack_ia32_t;
193
194struct ucontext_ia32 {
195 unsigned int uc_flags;
196 unsigned int uc_link;
197 stack_ia32_t uc_stack;
198 struct sigcontext_ia32 uc_mcontext;
199 sigset_t uc_sigmask;
200};
201
202struct stat64 {
203 unsigned long long st_dev;
204 unsigned char __pad0[4];
205 unsigned int __st_ino;
206 unsigned int st_mode;
207 unsigned int st_nlink;
208 unsigned int st_uid;
209 unsigned int st_gid;
210 unsigned long long st_rdev;
211 unsigned char __pad3[4];
212 unsigned int st_size_lo;
213 unsigned int st_size_hi;
214 unsigned int st_blksize;
215 unsigned int st_blocks;
216 unsigned int __pad4;
217 unsigned int st_atime;
218 unsigned int st_atime_nsec;
219 unsigned int st_mtime;
220 unsigned int st_mtime_nsec;
221 unsigned int st_ctime;
222 unsigned int st_ctime_nsec;
223 unsigned int st_ino_lo;
224 unsigned int st_ino_hi;
225};
226
227typedef struct compat_siginfo {
228 int si_signo;
229 int si_errno;
230 int si_code;
231
232 union {
233 int _pad[((128/sizeof(int)) - 3)];
234
235
236 struct {
237 unsigned int _pid;
238 unsigned int _uid;
239 } _kill;
240
241
242 struct {
243 compat_timer_t _tid;
244 int _overrun;
245 char _pad[sizeof(unsigned int) - sizeof(int)];
246 compat_sigval_t _sigval;
247 int _sys_private;
248 } _timer;
249
250
251 struct {
252 unsigned int _pid;
253 unsigned int _uid;
254 compat_sigval_t _sigval;
255 } _rt;
256
257
258 struct {
259 unsigned int _pid;
260 unsigned int _uid;
261 int _status;
262 compat_clock_t _utime;
263 compat_clock_t _stime;
264 } _sigchld;
265
266
267 struct {
268 unsigned int _addr;
269 } _sigfault;
270
271
272 struct {
273 int _band;
274 int _fd;
275 } _sigpoll;
276 } _sifields;
277} compat_siginfo_t;
278
279
280
281
282
283#define _ASM_IA64_ELF_H
284
285#include <linux/sched.h>
286
287
288
289
290#define elf_check_arch(x) ((x)->e_machine == EM_386)
291
292
293
294
295#define ELF_CLASS ELFCLASS32
296#define ELF_DATA ELFDATA2LSB
297#define ELF_ARCH EM_386
298
299#define IA32_STACK_TOP IA32_PAGE_OFFSET
300#define IA32_GATE_OFFSET IA32_PAGE_OFFSET
301#define IA32_GATE_END IA32_PAGE_OFFSET + PAGE_SIZE
302
303
304
305
306
307#define IA32_GDT_OFFSET (IA32_PAGE_OFFSET + PAGE_SIZE)
308#define IA32_TSS_OFFSET (IA32_PAGE_OFFSET + 2*PAGE_SIZE)
309#define IA32_LDT_OFFSET (IA32_PAGE_OFFSET + 3*PAGE_SIZE)
310
311#define ELF_EXEC_PAGESIZE IA32_PAGE_SIZE
312
313
314
315
316
317
318
319
320#define ELF_ET_DYN_BASE (IA32_PAGE_OFFSET/3 + 0x1000000)
321
322void ia64_elf32_init(struct pt_regs *regs);
323#define ELF_PLAT_INIT(_r, load_addr) ia64_elf32_init(_r)
324
325
326
327#define ELF_HWCAP 0
328
329
330
331
332#define ELF_PLATFORM NULL
333
334#ifdef __KERNEL__
335# define SET_PERSONALITY(EX) \
336 (current->personality = PER_LINUX)
337#endif
338
339#define IA32_EFLAG 0x200
340
341
342
343
344
345#define __USER_CS 0x23
346#define __USER_DS 0x2B
347
348
349
350
351#define GDT_ENTRIES 32
352
353#define GDT_SIZE (GDT_ENTRIES * 8)
354
355#define TSS_ENTRY 14
356#define LDT_ENTRY (TSS_ENTRY + 1)
357
358#define IA32_SEGSEL_RPL (0x3 << 0)
359#define IA32_SEGSEL_TI (0x1 << 2)
360#define IA32_SEGSEL_INDEX_SHIFT 3
361
362#define _TSS ((unsigned long) TSS_ENTRY << IA32_SEGSEL_INDEX_SHIFT)
363#define _LDT ((unsigned long) LDT_ENTRY << IA32_SEGSEL_INDEX_SHIFT)
364
365#define IA32_SEG_BASE 16
366#define IA32_SEG_TYPE 40
367#define IA32_SEG_SYS 44
368#define IA32_SEG_DPL 45
369#define IA32_SEG_P 47
370#define IA32_SEG_HIGH_LIMIT 48
371#define IA32_SEG_AVL 52
372#define IA32_SEG_DB 54
373#define IA32_SEG_G 55
374#define IA32_SEG_HIGH_BASE 56
375
376#define IA32_SEG_DESCRIPTOR(base, limit, segtype, nonsysseg, dpl, segpresent, avl, segdb, gran) \
377 (((limit) & 0xffff) \
378 | (((unsigned long) (base) & 0xffffff) << IA32_SEG_BASE) \
379 | ((unsigned long) (segtype) << IA32_SEG_TYPE) \
380 | ((unsigned long) (nonsysseg) << IA32_SEG_SYS) \
381 | ((unsigned long) (dpl) << IA32_SEG_DPL) \
382 | ((unsigned long) (segpresent) << IA32_SEG_P) \
383 | ((((unsigned long) (limit) >> 16) & 0xf) << IA32_SEG_HIGH_LIMIT) \
384 | ((unsigned long) (avl) << IA32_SEG_AVL) \
385 | ((unsigned long) (segdb) << IA32_SEG_DB) \
386 | ((unsigned long) (gran) << IA32_SEG_G) \
387 | ((((unsigned long) (base) >> 24) & 0xff) << IA32_SEG_HIGH_BASE))
388
389#define SEG_LIM 32
390#define SEG_TYPE 52
391#define SEG_SYS 56
392#define SEG_DPL 57
393#define SEG_P 59
394#define SEG_AVL 60
395#define SEG_DB 62
396#define SEG_G 63
397
398
399#define IA32_SEG_UNSCRAMBLE(sd) \
400 ( (((sd) >> IA32_SEG_BASE) & 0xffffff) | ((((sd) >> IA32_SEG_HIGH_BASE) & 0xff) << 24) \
401 | ((((sd) & 0xffff) | ((((sd) >> IA32_SEG_HIGH_LIMIT) & 0xf) << 16)) << SEG_LIM) \
402 | ((((sd) >> IA32_SEG_TYPE) & 0xf) << SEG_TYPE) \
403 | ((((sd) >> IA32_SEG_SYS) & 0x1) << SEG_SYS) \
404 | ((((sd) >> IA32_SEG_DPL) & 0x3) << SEG_DPL) \
405 | ((((sd) >> IA32_SEG_P) & 0x1) << SEG_P) \
406 | ((((sd) >> IA32_SEG_AVL) & 0x1) << SEG_AVL) \
407 | ((((sd) >> IA32_SEG_DB) & 0x1) << SEG_DB) \
408 | ((((sd) >> IA32_SEG_G) & 0x1) << SEG_G))
409
410#define IA32_IOBASE 0x2000000000000000UL
411
412#define IA32_CR0 0x80000001
413#define IA32_CR4 0x600
414
415
416
417
418
419#define IA32_FSR_DEFAULT 0x55550000
420#define IA32_FCR_DEFAULT 0x17800000037fUL
421
422#define IA32_PTRACE_GETREGS 12
423#define IA32_PTRACE_SETREGS 13
424#define IA32_PTRACE_GETFPREGS 14
425#define IA32_PTRACE_SETFPREGS 15
426#define IA32_PTRACE_GETFPXREGS 18
427#define IA32_PTRACE_SETFPXREGS 19
428
429#define ia32_start_thread(regs,new_ip,new_sp) do { \
430 set_fs(USER_DS); \
431 ia64_psr(regs)->cpl = 3; \
432 ia64_psr(regs)->ri = 0; \
433 ia64_psr(regs)->is = 1; \
434 regs->cr_iip = new_ip; \
435 regs->ar_rsc = 0xc; \
436 regs->ar_rnat = 0; \
437 regs->loadrs = 0; \
438 regs->r12 = new_sp; \
439} while (0)
440
441
442
443
444
445#define IA32_LDT_ENTRIES 8192
446#define IA32_LDT_ENTRY_SIZE 8
447
448#define LDT_entry_a(info) \
449 ((((info)->base_addr & 0x0000ffff) << 16) | ((info)->limit & 0x0ffff))
450
451#define LDT_entry_b(info) \
452 (((info)->base_addr & 0xff000000) | \
453 (((info)->base_addr & 0x00ff0000) >> 16) | \
454 ((info)->limit & 0xf0000) | \
455 (((info)->read_exec_only ^ 1) << 9) | \
456 ((info)->contents << 10) | \
457 (((info)->seg_not_present ^ 1) << 15) | \
458 ((info)->seg_32bit << 22) | \
459 ((info)->limit_in_pages << 23) | \
460 ((info)->useable << 20) | \
461 0x7100)
462
463#define LDT_empty(info) ( \
464 (info)->base_addr == 0 && \
465 (info)->limit == 0 && \
466 (info)->contents == 0 && \
467 (info)->read_exec_only == 1 && \
468 (info)->seg_32bit == 0 && \
469 (info)->limit_in_pages == 0 && \
470 (info)->seg_not_present == 1 && \
471 (info)->useable == 0 )
472
473static inline void
474load_TLS (struct thread_struct *t, unsigned int cpu)
475{
476 extern unsigned long *cpu_gdt_table[NR_CPUS];
477
478 memcpy(cpu_gdt_table[cpu] + GDT_ENTRY_TLS_MIN + 0, &t->tls_array[0], sizeof(long));
479 memcpy(cpu_gdt_table[cpu] + GDT_ENTRY_TLS_MIN + 1, &t->tls_array[1], sizeof(long));
480 memcpy(cpu_gdt_table[cpu] + GDT_ENTRY_TLS_MIN + 2, &t->tls_array[2], sizeof(long));
481}
482
483struct ia32_user_desc {
484 unsigned int entry_number;
485 unsigned int base_addr;
486 unsigned int limit;
487 unsigned int seg_32bit:1;
488 unsigned int contents:2;
489 unsigned int read_exec_only:1;
490 unsigned int limit_in_pages:1;
491 unsigned int seg_not_present:1;
492 unsigned int useable:1;
493};
494
495struct linux_binprm;
496
497extern void ia32_init_addr_space (struct pt_regs *regs);
498extern int ia32_setup_arg_pages (struct linux_binprm *bprm, int exec_stack);
499extern unsigned long ia32_do_mmap (struct file *, unsigned long, unsigned long, int, int, loff_t);
500extern void ia32_load_segment_descriptors (struct task_struct *task);
501
502#define ia32f2ia64f(dst,src) \
503do { \
504 ia64_ldfe(6,src); \
505 ia64_stop(); \
506 ia64_stf_spill(dst, 6); \
507} while(0)
508
509#define ia64f2ia32f(dst,src) \
510do { \
511 ia64_ldf_fill(6, src); \
512 ia64_stop(); \
513 ia64_stfe(dst, 6); \
514} while(0)
515
516struct user_regs_struct32 {
517 __u32 ebx, ecx, edx, esi, edi, ebp, eax;
518 unsigned short ds, __ds, es, __es;
519 unsigned short fs, __fs, gs, __gs;
520 __u32 orig_eax, eip;
521 unsigned short cs, __cs;
522 __u32 eflags, esp;
523 unsigned short ss, __ss;
524};
525
526
527extern int save_ia32_fpstate (struct task_struct *, struct ia32_user_i387_struct __user *);
528extern int save_ia32_fpxstate (struct task_struct *, struct ia32_user_fxsr_struct __user *);
529
530#endif
531
532#endif
533