Linux-2.6.12-rc2
[linux-2.6] / include / asm-um / archparam-i386.h
1 /* 
2  * Copyright (C) 2000 - 2003 Jeff Dike (jdike@addtoit.com)
3  * Licensed under the GPL
4  */
5
6 #ifndef __UM_ARCHPARAM_I386_H
7 #define __UM_ARCHPARAM_I386_H
8
9 /********* Bits for asm-um/elf.h ************/
10
11 #include <asm/user.h>
12
13 extern char * elf_aux_platform;
14 #define ELF_PLATFORM (elf_aux_platform)
15
16 #define ELF_ET_DYN_BASE (2 * TASK_SIZE / 3)
17
18 typedef struct user_i387_struct elf_fpregset_t;
19 typedef unsigned long elf_greg_t;
20
21 #define ELF_NGREG (sizeof (struct user_regs_struct) / sizeof(elf_greg_t))
22 typedef elf_greg_t elf_gregset_t[ELF_NGREG];
23
24 #define ELF_DATA        ELFDATA2LSB
25 #define ELF_ARCH        EM_386
26
27 #define ELF_PLAT_INIT(regs, load_addr) do { \
28         PT_REGS_EBX(regs) = 0; \
29         PT_REGS_ECX(regs) = 0; \
30         PT_REGS_EDX(regs) = 0; \
31         PT_REGS_ESI(regs) = 0; \
32         PT_REGS_EDI(regs) = 0; \
33         PT_REGS_EBP(regs) = 0; \
34         PT_REGS_EAX(regs) = 0; \
35 } while(0)
36
37 /* Shamelessly stolen from include/asm-i386/elf.h */
38
39 #define ELF_CORE_COPY_REGS(pr_reg, regs) do {   \
40         pr_reg[0] = PT_REGS_EBX(regs);          \
41         pr_reg[1] = PT_REGS_ECX(regs);          \
42         pr_reg[2] = PT_REGS_EDX(regs);          \
43         pr_reg[3] = PT_REGS_ESI(regs);          \
44         pr_reg[4] = PT_REGS_EDI(regs);          \
45         pr_reg[5] = PT_REGS_EBP(regs);          \
46         pr_reg[6] = PT_REGS_EAX(regs);          \
47         pr_reg[7] = PT_REGS_DS(regs);           \
48         pr_reg[8] = PT_REGS_ES(regs);           \
49         /* fake once used fs and gs selectors? */       \
50         pr_reg[9] = PT_REGS_DS(regs);           \
51         pr_reg[10] = PT_REGS_DS(regs);          \
52         pr_reg[11] = PT_REGS_SYSCALL_NR(regs);  \
53         pr_reg[12] = PT_REGS_IP(regs);          \
54         pr_reg[13] = PT_REGS_CS(regs);          \
55         pr_reg[14] = PT_REGS_EFLAGS(regs);      \
56         pr_reg[15] = PT_REGS_SP(regs);          \
57         pr_reg[16] = PT_REGS_SS(regs);          \
58 } while(0);
59
60
61 extern unsigned long vsyscall_ehdr;
62 extern unsigned long vsyscall_end;
63 extern unsigned long __kernel_vsyscall;
64
65 #define VSYSCALL_BASE vsyscall_ehdr
66 #define VSYSCALL_END vsyscall_end
67
68 /*
69  * This is the range that is readable by user mode, and things
70  * acting like user mode such as get_user_pages.
71  */
72 #define FIXADDR_USER_START      VSYSCALL_BASE
73 #define FIXADDR_USER_END        VSYSCALL_END
74
75 /*
76  * Architecture-neutral AT_ values in 0-17, leave some room
77  * for more of them, start the x86-specific ones at 32.
78  */
79 #define AT_SYSINFO              32
80 #define AT_SYSINFO_EHDR         33
81
82 #define ARCH_DLINFO                                             \
83 do {                                                            \
84         if ( vsyscall_ehdr ) {                                  \
85                 NEW_AUX_ENT(AT_SYSINFO, __kernel_vsyscall);     \
86                 NEW_AUX_ENT(AT_SYSINFO_EHDR, vsyscall_ehdr);    \
87         }                                                       \
88 } while (0)
89
90 /*
91  * These macros parameterize elf_core_dump in fs/binfmt_elf.c to write out
92  * extra segments containing the vsyscall DSO contents.  Dumping its
93  * contents makes post-mortem fully interpretable later without matching up
94  * the same kernel and hardware config to see what PC values meant.
95  * Dumping its extra ELF program headers includes all the other information
96  * a debugger needs to easily find how the vsyscall DSO was being used.
97  */
98 #define ELF_CORE_EXTRA_PHDRS                                                  \
99         (vsyscall_ehdr ? (((struct elfhdr *)vsyscall_ehdr)->e_phnum) : 0 )
100
101 #define ELF_CORE_WRITE_EXTRA_PHDRS                                            \
102 if ( vsyscall_ehdr ) {                                                        \
103         const struct elfhdr *const ehdrp = (struct elfhdr *)vsyscall_ehdr;    \
104         const struct elf_phdr *const phdrp =                                  \
105                 (const struct elf_phdr *) (vsyscall_ehdr + ehdrp->e_phoff);   \
106         int i;                                                                \
107         Elf32_Off ofs = 0;                                                    \
108         for (i = 0; i < ehdrp->e_phnum; ++i) {                                \
109                 struct elf_phdr phdr = phdrp[i];                              \
110                 if (phdr.p_type == PT_LOAD) {                                 \
111                         ofs = phdr.p_offset = offset;                         \
112                         offset += phdr.p_filesz;                              \
113                 }                                                             \
114                 else                                                          \
115                         phdr.p_offset += ofs;                                 \
116                 phdr.p_paddr = 0; /* match other core phdrs */                \
117                 DUMP_WRITE(&phdr, sizeof(phdr));                              \
118         }                                                                     \
119 }
120 #define ELF_CORE_WRITE_EXTRA_DATA                                             \
121 if ( vsyscall_ehdr ) {                                                        \
122         const struct elfhdr *const ehdrp = (struct elfhdr *)vsyscall_ehdr;    \
123         const struct elf_phdr *const phdrp =                                  \
124                 (const struct elf_phdr *) (vsyscall_ehdr + ehdrp->e_phoff);   \
125         int i;                                                                \
126         for (i = 0; i < ehdrp->e_phnum; ++i) {                                \
127                 if (phdrp[i].p_type == PT_LOAD)                               \
128                         DUMP_WRITE((void *) phdrp[i].p_vaddr,                 \
129                                    phdrp[i].p_filesz);                        \
130         }                                                                     \
131 }
132
133 #define R_386_NONE      0
134 #define R_386_32        1
135 #define R_386_PC32      2
136 #define R_386_GOT32     3
137 #define R_386_PLT32     4
138 #define R_386_COPY      5
139 #define R_386_GLOB_DAT  6
140 #define R_386_JMP_SLOT  7
141 #define R_386_RELATIVE  8
142 #define R_386_GOTOFF    9
143 #define R_386_GOTPC     10
144 #define R_386_NUM       11
145
146 /********* Nothing for asm-um/hardirq.h **********/
147
148 /********* Nothing for asm-um/hw_irq.h **********/
149
150 /********* Nothing for asm-um/string.h **********/
151
152 #endif
153
154 /*
155  * Overrides for Emacs so that we follow Linus's tabbing style.
156  * Emacs will notice this stuff at the end of the file and automatically
157  * adjust the settings for this buffer only.  This must remain at the end
158  * of the file.
159  * ---------------------------------------------------------------------------
160  * Local variables:
161  * c-file-style: "linux"
162  * End:
163  */