Commit | Line | Data |
---|---|---|
1da177e4 LT |
1 | /* $Id: elf.h,v 1.32 2002/02/09 19:49:31 davem Exp $ */ |
2 | #ifndef __ASM_SPARC64_ELF_H | |
3 | #define __ASM_SPARC64_ELF_H | |
4 | ||
5 | /* | |
6 | * ELF register definitions.. | |
7 | */ | |
8 | ||
9 | #include <asm/ptrace.h> | |
1da177e4 LT |
10 | #include <asm/processor.h> |
11 | #include <asm/uaccess.h> | |
97532f59 | 12 | #include <asm/spitfire.h> |
1da177e4 LT |
13 | |
14 | /* | |
15 | * Sparc section types | |
16 | */ | |
17 | #define STT_REGISTER 13 | |
18 | ||
19 | /* | |
20 | * Sparc ELF relocation types | |
21 | */ | |
22 | #define R_SPARC_NONE 0 | |
23 | #define R_SPARC_8 1 | |
24 | #define R_SPARC_16 2 | |
25 | #define R_SPARC_32 3 | |
26 | #define R_SPARC_DISP8 4 | |
27 | #define R_SPARC_DISP16 5 | |
28 | #define R_SPARC_DISP32 6 | |
29 | #define R_SPARC_WDISP30 7 | |
30 | #define R_SPARC_WDISP22 8 | |
31 | #define R_SPARC_HI22 9 | |
32 | #define R_SPARC_22 10 | |
33 | #define R_SPARC_13 11 | |
34 | #define R_SPARC_LO10 12 | |
35 | #define R_SPARC_GOT10 13 | |
36 | #define R_SPARC_GOT13 14 | |
37 | #define R_SPARC_GOT22 15 | |
38 | #define R_SPARC_PC10 16 | |
39 | #define R_SPARC_PC22 17 | |
40 | #define R_SPARC_WPLT30 18 | |
41 | #define R_SPARC_COPY 19 | |
42 | #define R_SPARC_GLOB_DAT 20 | |
43 | #define R_SPARC_JMP_SLOT 21 | |
44 | #define R_SPARC_RELATIVE 22 | |
45 | #define R_SPARC_UA32 23 | |
46 | #define R_SPARC_PLT32 24 | |
47 | #define R_SPARC_HIPLT22 25 | |
48 | #define R_SPARC_LOPLT10 26 | |
49 | #define R_SPARC_PCPLT32 27 | |
50 | #define R_SPARC_PCPLT22 28 | |
51 | #define R_SPARC_PCPLT10 29 | |
52 | #define R_SPARC_10 30 | |
53 | #define R_SPARC_11 31 | |
54 | #define R_SPARC_64 32 | |
55 | #define R_SPARC_OLO10 33 | |
56 | #define R_SPARC_WDISP16 40 | |
57 | #define R_SPARC_WDISP19 41 | |
58 | #define R_SPARC_7 43 | |
59 | #define R_SPARC_5 44 | |
60 | #define R_SPARC_6 45 | |
61 | ||
62 | /* Bits present in AT_HWCAP, primarily for Sparc32. */ | |
63 | ||
64 | #define HWCAP_SPARC_FLUSH 1 /* CPU supports flush instruction. */ | |
65 | #define HWCAP_SPARC_STBAR 2 | |
66 | #define HWCAP_SPARC_SWAP 4 | |
67 | #define HWCAP_SPARC_MULDIV 8 | |
68 | #define HWCAP_SPARC_V9 16 | |
69 | #define HWCAP_SPARC_ULTRA3 32 | |
97532f59 | 70 | #define HWCAP_SPARC_BLKINIT 64 |
8b224b81 | 71 | #define HWCAP_SPARC_N2 128 |
1da177e4 LT |
72 | |
73 | /* | |
74 | * These are used to set parameters in the core dumps. | |
75 | */ | |
76 | #ifndef ELF_ARCH | |
77 | #define ELF_ARCH EM_SPARCV9 | |
78 | #define ELF_CLASS ELFCLASS64 | |
79 | #define ELF_DATA ELFDATA2MSB | |
80 | ||
81 | typedef unsigned long elf_greg_t; | |
82 | ||
83 | #define ELF_NGREG 36 | |
84 | typedef elf_greg_t elf_gregset_t[ELF_NGREG]; | |
85 | /* Format of 64-bit elf_gregset_t is: | |
86 | * G0 --> G7 | |
87 | * O0 --> O7 | |
88 | * L0 --> L7 | |
89 | * I0 --> I7 | |
90 | * TSTATE | |
91 | * TPC | |
92 | * TNPC | |
93 | * Y | |
94 | */ | |
95 | #define ELF_CORE_COPY_REGS(__elf_regs, __pt_regs) \ | |
96 | do { unsigned long *dest = &(__elf_regs[0]); \ | |
97 | struct pt_regs *src = (__pt_regs); \ | |
98 | unsigned long __user *sp; \ | |
99 | int i; \ | |
100 | for(i = 0; i < 16; i++) \ | |
101 | dest[i] = src->u_regs[i]; \ | |
102 | /* Don't try this at home kids... */ \ | |
103 | sp = (unsigned long __user *) \ | |
104 | ((src->u_regs[14] + STACK_BIAS) \ | |
105 | & 0xfffffffffffffff8UL); \ | |
106 | for(i = 0; i < 16; i++) \ | |
107 | __get_user(dest[i+16], &sp[i]); \ | |
108 | dest[32] = src->tstate; \ | |
109 | dest[33] = src->tpc; \ | |
110 | dest[34] = src->tnpc; \ | |
111 | dest[35] = src->y; \ | |
112 | } while (0); | |
113 | ||
114 | typedef struct { | |
115 | unsigned long pr_regs[32]; | |
116 | unsigned long pr_fsr; | |
117 | unsigned long pr_gsr; | |
118 | unsigned long pr_fprs; | |
119 | } elf_fpregset_t; | |
120 | #endif | |
121 | ||
122 | #define ELF_CORE_COPY_TASK_REGS(__tsk, __elf_regs) \ | |
26ecbdea | 123 | ({ ELF_CORE_COPY_REGS((*(__elf_regs)), task_pt_regs(__tsk)); 1; }) |
1da177e4 LT |
124 | |
125 | /* | |
126 | * This is used to ensure we don't load something for the wrong architecture. | |
127 | */ | |
128 | #ifndef elf_check_arch | |
129 | #define elf_check_arch(x) ((x)->e_machine == ELF_ARCH) /* Might be EM_SPARCV9 or EM_SPARC */ | |
130 | #endif | |
131 | ||
132 | #define USE_ELF_CORE_DUMP | |
133 | #define ELF_EXEC_PAGESIZE PAGE_SIZE | |
134 | ||
135 | /* This is the location that an ET_DYN program is loaded if exec'ed. Typical | |
136 | use of this is to invoke "./ld.so someprog" to test out a new version of | |
137 | the loader. We need to make sure that it is out of the way of the program | |
138 | that it will "exec", and that there is sufficient room for the brk. */ | |
139 | ||
140 | #ifndef ELF_ET_DYN_BASE | |
141 | #define ELF_ET_DYN_BASE 0x0000010000000000UL | |
142 | #endif | |
143 | ||
144 | ||
145 | /* This yields a mask that user programs can use to figure out what | |
146 | instruction set this cpu supports. */ | |
147 | ||
148 | /* On Ultra, we support all of the v8 capabilities. */ | |
97532f59 DM |
149 | static inline unsigned int sparc64_elf_hwcap(void) |
150 | { | |
151 | unsigned int cap = (HWCAP_SPARC_FLUSH | HWCAP_SPARC_STBAR | | |
152 | HWCAP_SPARC_SWAP | HWCAP_SPARC_MULDIV | | |
153 | HWCAP_SPARC_V9); | |
154 | ||
155 | if (tlb_type == cheetah || tlb_type == cheetah_plus) | |
156 | cap |= HWCAP_SPARC_ULTRA3; | |
8b224b81 DM |
157 | else if (tlb_type == hypervisor) { |
158 | if (sun4v_chip_type == SUN4V_CHIP_NIAGARA1 || | |
159 | sun4v_chip_type == SUN4V_CHIP_NIAGARA2) | |
160 | cap |= HWCAP_SPARC_BLKINIT; | |
161 | if (sun4v_chip_type == SUN4V_CHIP_NIAGARA2) | |
162 | cap |= HWCAP_SPARC_N2; | |
163 | } | |
97532f59 DM |
164 | |
165 | return cap; | |
166 | } | |
167 | ||
168 | #define ELF_HWCAP sparc64_elf_hwcap(); | |
1da177e4 LT |
169 | |
170 | /* This yields a string that ld.so will use to load implementation | |
171 | specific libraries for optimization. This is more specific in | |
172 | intent than poking at uname or /proc/cpuinfo. */ | |
173 | ||
174 | #define ELF_PLATFORM (NULL) | |
175 | ||
1da177e4 LT |
176 | #define SET_PERSONALITY(ex, ibcs2) \ |
177 | do { unsigned long new_flags = current_thread_info()->flags; \ | |
178 | new_flags &= _TIF_32BIT; \ | |
179 | if ((ex).e_ident[EI_CLASS] == ELFCLASS32) \ | |
180 | new_flags |= _TIF_32BIT; \ | |
181 | else \ | |
182 | new_flags &= ~_TIF_32BIT; \ | |
183 | if ((current_thread_info()->flags & _TIF_32BIT) \ | |
184 | != new_flags) \ | |
185 | set_thread_flag(TIF_ABI_PENDING); \ | |
186 | else \ | |
187 | clear_thread_flag(TIF_ABI_PENDING); \ | |
188 | /* flush_thread will update pgd cache */ \ | |
189 | if (ibcs2) \ | |
190 | set_personality(PER_SVR4); \ | |
191 | else if (current->personality != PER_LINUX32) \ | |
192 | set_personality(PER_LINUX); \ | |
193 | } while (0) | |
1da177e4 LT |
194 | |
195 | #endif /* !(__ASM_SPARC64_ELF_H) */ |