OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [linux/] [linux-2.4/] [include/] [asm-ia64/] [ia32.h] - Blame information for rev 1774

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1275 phoenix
#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 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;
36
 
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)
43
 
44
struct timespec32 {
45
        int     tv_sec;
46
        int     tv_nsec;
47
};
48
 
49
/* fcntl.h */
50
struct 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
/* sigcontext.h */
63
/*
64
 * As documented in the iBCS2 standard..
65
 *
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.
70
 */
71
struct _fpreg_ia32 {
72
       unsigned short significand[4];
73
       unsigned short exponent;
74
};
75
 
76
struct _fpxreg_ia32 {
77
        unsigned short significand[4];
78
        unsigned short exponent;
79
        unsigned short padding[3];
80
};
81
 
82
struct _xmmreg_ia32 {
83
        unsigned int element[4];
84
};
85
 
86
 
87
struct _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;          /* 0xffff = regular FPU data only */
98
 
99
       /* FXSR FPU environment */
100
       unsigned int         _fxsr_env[6];   /* FXSR FPU env is ignored */
101
       unsigned int         mxcsr;
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];
106
};
107
 
108
struct 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;            /* really (struct _fpstate_ia32 *) */
129
       unsigned int oldmask;
130
       unsigned int cr2;
131
};
132
 
133
/* user.h */
134
/*
135
 * IA32 (Pentium III/4) FXSR, SSE support
136
 *
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.
143
 */
144
struct 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
        /* 8*10 bytes for each FP-reg = 80 bytes */
153
        struct _fpreg_ia32      st_space[8];
154
};
155
 
156
struct 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];   /* 8*16 bytes for each FP-reg = 128 bytes */
168
        int     xmm_space[32];  /* 8*16 bytes for each XMM-reg = 128 bytes */
169
        int     padding[56];
170
};
171
 
172
/* signal.h */
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
 
184
typedef struct {
185
       unsigned int sig[_IA32_NSIG_WORDS];
186
} sigset32_t;
187
 
188
struct sigaction32 {
189
       unsigned int sa_handler;         /* Really a pointer, but need to deal with 32 bits */
190
       unsigned int sa_flags;
191
       unsigned int sa_restorer;        /* Another 32 bit pointer */
192
       sigset32_t sa_mask;              /* A 32 bit mask */
193
};
194
 
195
typedef unsigned int old_sigset32_t;    /* at least 32 bits */
196
 
197
struct old_sigaction32 {
198
       unsigned int  sa_handler;        /* Really a pointer, but need to deal
199
                                             with 32 bits */
200
       old_sigset32_t sa_mask;          /* A 32 bit mask */
201
       unsigned int sa_flags;
202
       unsigned int sa_restorer;        /* Another 32 bit pointer */
203
};
204
 
205
typedef struct sigaltstack_ia32 {
206
        unsigned int    ss_sp;
207
        int             ss_flags;
208
        unsigned int    ss_size;
209
} stack_ia32_t;
210
 
211
struct 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;   /* mask last for extensibility */
217
};
218
 
219
struct 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
 
242
struct 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;      /* Number 512-byte blocks allocated. */
256
        unsigned int    __pad4;         /* future possible st_blocks high bits */
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;         /* will be high 32 bits of ctime someday */
263
        unsigned int    st_ino_lo;
264
        unsigned int    st_ino_hi;
265
};
266
 
267
struct 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;  /* SunOS ignores this field. */
277
       int f_spare[6];
278
};
279
 
280
typedef union sigval32 {
281
        int sival_int;
282
        unsigned int sival_ptr;
283
} sigval_t32;
284
 
285
typedef 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
                /* kill() */
294
                struct {
295
                        unsigned int _pid;      /* sender's pid */
296
                        unsigned int _uid;      /* sender's uid */
297
                } _kill;
298
 
299
                /* POSIX.1b timers */
300
                struct {
301
                        unsigned int _timer1;
302
                        unsigned int _timer2;
303
                } _timer;
304
 
305
                /* POSIX.1b signals */
306
                struct {
307
                        unsigned int _pid;      /* sender's pid */
308
                        unsigned int _uid;      /* sender's uid */
309
                        sigval_t32 _sigval;
310
                } _rt;
311
 
312
                /* SIGCHLD */
313
                struct {
314
                        unsigned int _pid;      /* which child */
315
                        unsigned int _uid;      /* sender's uid */
316
                        int _status;            /* exit code */
317
                        __kernel_clock_t32 _utime;
318
                        __kernel_clock_t32 _stime;
319
                } _sigchld;
320
 
321
                /* SIGILL, SIGFPE, SIGSEGV, SIGBUS */
322
                struct {
323
                        unsigned int _addr;     /* faulting insn/memory ref. */
324
                } _sigfault;
325
 
326
                /* SIGPOLL */
327
                struct {
328
                        int _band;      /* POLL_IN, POLL_OUT, POLL_MSG */
329
                        int _fd;
330
                } _sigpoll;
331
        } _sifields;
332
} siginfo_t32;
333
 
334
struct linux32_dirent {
335
        u32     d_ino;
336
        u32     d_off;
337
        u16     d_reclen;
338
        char    d_name[256];
339
};
340
 
341
struct old_linux32_dirent {
342
        u32     d_ino;
343
        u32     d_offset;
344
        u16     d_namlen;
345
        char    d_name[1];
346
};
347
 
348
/*
349
 * IA-32 ELF specific definitions for IA-64.
350
 */
351
 
352
#define _ASM_IA64_ELF_H         /* Don't include elf.h */
353
 
354
#include <linux/sched.h>
355
#include <asm/processor.h>
356
 
357
/*
358
 * This is used to ensure we don't load something for the wrong architecture.
359
 */
360
#define elf_check_arch(x) ((x)->e_machine == EM_386)
361
 
362
/*
363
 * These are used to set parameters in the core dumps.
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
 * The system segments (GDT, TSS, LDT) have to be mapped below 4GB so the IA-32 engine can
374
 * access them.
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 USE_ELF_CORE_DUMP
381
#define ELF_EXEC_PAGESIZE       IA32_PAGE_SIZE
382
 
383
/*
384
 * This is the location that an ET_DYN program is loaded if exec'ed.
385
 * Typical use of this is to invoke "./ld.so someprog" to test out a
386
 * new version of the loader.  We need to make sure that it is out of
387
 * the way of the program that it will "exec", and that there is
388
 * sufficient room for the brk.
389
 */
390
#define ELF_ET_DYN_BASE         (IA32_PAGE_OFFSET/3 + 0x1000000)
391
 
392
void ia64_elf32_init(struct pt_regs *regs);
393
#define ELF_PLAT_INIT(_r, load_addr)    ia64_elf32_init(_r)
394
 
395
#define elf_addr_t      u32
396
#define elf_caddr_t     u32
397
 
398
/* ELF register definitions.  This is needed for core dump support.  */
399
 
400
#define ELF_NGREG       128                     /* XXX fix me */
401
#define ELF_NFPREG      128                     /* XXX fix me */
402
 
403
typedef unsigned long elf_greg_t;
404
typedef elf_greg_t elf_gregset_t[ELF_NGREG];
405
 
406
typedef struct {
407
        unsigned long w0;
408
        unsigned long w1;
409
} elf_fpreg_t;
410
typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
411
 
412
/* This macro yields a bitmask that programs can use to figure out
413
   what instruction set this CPU supports.  */
414
#define ELF_HWCAP       0
415
 
416
/* This macro yields a string that ld.so will use to load
417
   implementation specific libraries for optimization.  Not terribly
418
   relevant until we have real hardware to play with... */
419
#define ELF_PLATFORM    0
420
 
421
#ifdef __KERNEL__
422
# define SET_PERSONALITY(EX,IBCS2)                              \
423
        (current->personality = (IBCS2) ? PER_SVR4 : PER_LINUX)
424
#endif
425
 
426
#define IA32_EFLAG      0x200
427
 
428
/*
429
 * IA-32 ELF specific definitions for IA-64.
430
 */
431
 
432
#define __USER_CS      0x23
433
#define __USER_DS      0x2B
434
 
435
#define FIRST_TSS_ENTRY 6
436
#define FIRST_LDT_ENTRY (FIRST_TSS_ENTRY+1)
437
#define _TSS(n) ((((unsigned long) n)<<4)+(FIRST_TSS_ENTRY<<3))
438
#define _LDT(n) ((((unsigned long) n)<<4)+(FIRST_LDT_ENTRY<<3))
439
 
440
#define IA32_SEGSEL_RPL         (0x3 << 0)
441
#define IA32_SEGSEL_TI          (0x1 << 2)
442
#define IA32_SEGSEL_INDEX_SHIFT 3
443
 
444
#define IA32_SEG_BASE           16
445
#define IA32_SEG_TYPE           40
446
#define IA32_SEG_SYS            44
447
#define IA32_SEG_DPL            45
448
#define IA32_SEG_P              47
449
#define IA32_SEG_HIGH_LIMIT     48
450
#define IA32_SEG_AVL            52
451
#define IA32_SEG_DB             54
452
#define IA32_SEG_G              55
453
#define IA32_SEG_HIGH_BASE      56
454
 
455
#define IA32_SEG_DESCRIPTOR(base, limit, segtype, nonsysseg, dpl, segpresent, avl, segdb, gran) \
456
               (((limit) & 0xffff)                                                              \
457
                | (((unsigned long) (base) & 0xffffff) << IA32_SEG_BASE)                        \
458
                | ((unsigned long) (segtype) << IA32_SEG_TYPE)                                  \
459
                | ((unsigned long) (nonsysseg) << IA32_SEG_SYS)                                 \
460
                | ((unsigned long) (dpl) << IA32_SEG_DPL)                                       \
461
                | ((unsigned long) (segpresent) << IA32_SEG_P)                                  \
462
                | ((((unsigned long) (limit) >> 16) & 0xf) << IA32_SEG_HIGH_LIMIT)              \
463
                | ((unsigned long) (avl) << IA32_SEG_AVL)                                       \
464
                | ((unsigned long) (segdb) << IA32_SEG_DB)                                      \
465
                | ((unsigned long) (gran) << IA32_SEG_G)                                        \
466
                | ((((unsigned long) (base) >> 24) & 0xff) << IA32_SEG_HIGH_BASE))
467
 
468
#define SEG_LIM         32
469
#define SEG_TYPE        52
470
#define SEG_SYS         56
471
#define SEG_DPL         57
472
#define SEG_P           59
473
#define SEG_AVL         60
474
#define SEG_DB          62
475
#define SEG_G           63
476
 
477
/* Unscramble an IA-32 segment descriptor into the IA-64 format.  */
478
#define IA32_SEG_UNSCRAMBLE(sd)                                                                  \
479
        (   (((sd) >> IA32_SEG_BASE) & 0xffffff) | ((((sd) >> IA32_SEG_HIGH_BASE) & 0xff) << 24) \
480
         | ((((sd) & 0xffff) | ((((sd) >> IA32_SEG_HIGH_LIMIT) & 0xf) << 16)) << SEG_LIM)        \
481
         | ((((sd) >> IA32_SEG_TYPE) & 0xf) << SEG_TYPE)                                         \
482
         | ((((sd) >> IA32_SEG_SYS) & 0x1) << SEG_SYS)                                           \
483
         | ((((sd) >> IA32_SEG_DPL) & 0x3) << SEG_DPL)                                           \
484
         | ((((sd) >> IA32_SEG_P) & 0x1) << SEG_P)                                               \
485
         | ((((sd) >> IA32_SEG_AVL) & 0x1) << SEG_AVL)                                           \
486
         | ((((sd) >> IA32_SEG_DB) & 0x1) << SEG_DB)                                             \
487
         | ((((sd) >> IA32_SEG_G) & 0x1) << SEG_G))
488
 
489
#define IA32_IOBASE     0x2000000000000000 /* Virtual address for I/O space */
490
 
491
#define IA32_CR0        0x80000001      /* Enable PG and PE bits */
492
#define IA32_CR4        0x600           /* MMXEX and FXSR on */
493
 
494
/*
495
 *  IA32 floating point control registers starting values
496
 */
497
 
498
#define IA32_FSR_DEFAULT        0x55550000              /* set all tag bits */
499
#define IA32_FCR_DEFAULT        0x17800000037fUL        /* extended precision, all masks */
500
 
501
#define IA32_PTRACE_GETREGS     12
502
#define IA32_PTRACE_SETREGS     13
503
#define IA32_PTRACE_GETFPREGS   14
504
#define IA32_PTRACE_SETFPREGS   15
505
#define IA32_PTRACE_GETFPXREGS  18
506
#define IA32_PTRACE_SETFPXREGS  19
507
 
508
#define ia32_start_thread(regs,new_ip,new_sp) do {                              \
509
        set_fs(USER_DS);                                                        \
510
        ia64_psr(regs)->cpl = 3;        /* set user mode */                     \
511
        ia64_psr(regs)->ri = 0;          /* clear return slot number */          \
512
        ia64_psr(regs)->is = 1;         /* IA-32 instruction set */             \
513
        regs->cr_iip = new_ip;                                                  \
514
        regs->ar_rsc = 0xc;             /* enforced lazy mode, priv. level 3 */ \
515
        regs->ar_rnat = 0;                                                       \
516
        regs->loadrs = 0;                                                        \
517
        regs->r12 = new_sp;                                                     \
518
} while (0)
519
 
520
/*
521
 * Local Descriptor Table (LDT) related declarations.
522
 */
523
 
524
#define IA32_LDT_ENTRIES        8192            /* Maximum number of LDT entries supported. */
525
#define IA32_LDT_ENTRY_SIZE     8               /* The size of each LDT entry. */
526
 
527
struct ia32_modify_ldt_ldt_s {
528
        unsigned int entry_number;
529
        unsigned int base_addr;
530
        unsigned int limit;
531
        unsigned int seg_32bit:1;
532
        unsigned int contents:2;
533
        unsigned int read_exec_only:1;
534
        unsigned int limit_in_pages:1;
535
        unsigned int seg_not_present:1;
536
        unsigned int useable:1;
537
};
538
 
539
extern void ia32_gdt_init (void);
540
extern int ia32_setup_frame1 (int sig, struct k_sigaction *ka, siginfo_t *info,
541
                               sigset_t *set, struct pt_regs *regs);
542
extern void ia32_init_addr_space (struct pt_regs *regs);
543
extern int ia32_setup_arg_pages (struct linux_binprm *bprm);
544
extern int ia32_exception (struct pt_regs *regs, unsigned long isr);
545
extern int ia32_intercept (struct pt_regs *regs, unsigned long isr);
546
extern unsigned long ia32_do_mmap (struct file *, unsigned long, unsigned long, int, int, loff_t);
547
extern void ia32_load_segment_descriptors (struct task_struct *task);
548
 
549
#define ia32f2ia64f(dst,src) \
550
        do { \
551
        register double f6 asm ("f6"); \
552
        asm volatile ("ldfe f6=[%2];; stf.spill [%1]=f6" : "=f"(f6): "r"(dst), "r"(src) : "memory"); \
553
        } while(0)
554
 
555
#define ia64f2ia32f(dst,src) \
556
        do { \
557
        register double f6 asm ("f6"); \
558
        asm volatile ("ldf.fill f6=[%2];; stfe [%1]=f6" : "=f"(f6): "r"(dst),  "r"(src) : "memory"); \
559
        } while(0)
560
 
561
#endif /* !CONFIG_IA32_SUPPORT */
562
 
563
#endif /* _ASM_IA64_IA32_H */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.