Commit | Line | Data |
---|---|---|
867e359b CM |
1 | /* |
2 | * Copyright 2010 Tilera Corporation. All Rights Reserved. | |
3 | * | |
4 | * This program is free software; you can redistribute it and/or | |
5 | * modify it under the terms of the GNU General Public License | |
6 | * as published by the Free Software Foundation, version 2. | |
7 | * | |
8 | * This program is distributed in the hope that it will be useful, but | |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | |
10 | * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or | |
11 | * NON INFRINGEMENT. See the GNU General Public License for | |
12 | * more details. | |
13 | */ | |
14 | ||
15 | #ifndef _ASM_TILE_ELF_H | |
16 | #define _ASM_TILE_ELF_H | |
17 | ||
18 | /* | |
19 | * ELF register definitions. | |
20 | */ | |
21 | ||
22 | #include <arch/chip.h> | |
23 | ||
24 | #include <linux/ptrace.h> | |
25 | #include <asm/byteorder.h> | |
26 | #include <asm/page.h> | |
27 | ||
28 | typedef unsigned long elf_greg_t; | |
29 | ||
30 | #define ELF_NGREG (sizeof(struct pt_regs) / sizeof(elf_greg_t)) | |
31 | typedef elf_greg_t elf_gregset_t[ELF_NGREG]; | |
32 | ||
33 | #define EM_TILE64 187 | |
34 | #define EM_TILEPRO 188 | |
35 | #define EM_TILEGX 191 | |
36 | ||
37 | /* Provide a nominal data structure. */ | |
38 | #define ELF_NFPREG 0 | |
39 | typedef double elf_fpreg_t; | |
40 | typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG]; | |
41 | ||
42 | #ifdef __tilegx__ | |
43 | #define ELF_CLASS ELFCLASS64 | |
44 | #else | |
45 | #define ELF_CLASS ELFCLASS32 | |
46 | #endif | |
1efea40d CM |
47 | #ifdef __BIG_ENDIAN__ |
48 | #define ELF_DATA ELFDATA2MSB | |
49 | #else | |
867e359b | 50 | #define ELF_DATA ELFDATA2LSB |
1efea40d | 51 | #endif |
867e359b CM |
52 | |
53 | /* | |
54 | * There seems to be a bug in how compat_binfmt_elf.c works: it | |
55 | * #undefs ELF_ARCH, but it is then used in binfmt_elf.c for fill_note_info(). | |
56 | * Hack around this by providing an enum value of ELF_ARCH. | |
57 | */ | |
58 | enum { ELF_ARCH = CHIP_ELF_TYPE() }; | |
59 | #define ELF_ARCH ELF_ARCH | |
60 | ||
61 | /* | |
62 | * This is used to ensure we don't load something for the wrong architecture. | |
63 | */ | |
64 | #define elf_check_arch(x) \ | |
65 | ((x)->e_ident[EI_CLASS] == ELF_CLASS && \ | |
1efea40d | 66 | (x)->e_ident[EI_DATA] == ELF_DATA && \ |
0707ad30 | 67 | (x)->e_machine == CHIP_ELF_TYPE()) |
867e359b CM |
68 | |
69 | /* The module loader only handles a few relocation types. */ | |
70 | #ifndef __tilegx__ | |
71 | #define R_TILE_32 1 | |
72 | #define R_TILE_JOFFLONG_X1 15 | |
73 | #define R_TILE_IMM16_X0_LO 25 | |
74 | #define R_TILE_IMM16_X1_LO 26 | |
75 | #define R_TILE_IMM16_X0_HA 29 | |
76 | #define R_TILE_IMM16_X1_HA 30 | |
77 | #else | |
78 | #define R_TILEGX_64 1 | |
79 | #define R_TILEGX_JUMPOFF_X1 21 | |
80 | #define R_TILEGX_IMM16_X0_HW0 36 | |
81 | #define R_TILEGX_IMM16_X1_HW0 37 | |
82 | #define R_TILEGX_IMM16_X0_HW1 38 | |
83 | #define R_TILEGX_IMM16_X1_HW1 39 | |
84 | #define R_TILEGX_IMM16_X0_HW2_LAST 48 | |
85 | #define R_TILEGX_IMM16_X1_HW2_LAST 49 | |
86 | #endif | |
87 | ||
88 | /* Use standard page size for core dumps. */ | |
89 | #define ELF_EXEC_PAGESIZE PAGE_SIZE | |
90 | ||
91 | /* | |
92 | * This is the location that an ET_DYN program is loaded if exec'ed. Typical | |
93 | * use of this is to invoke "./ld.so someprog" to test out a new version of | |
94 | * the loader. We need to make sure that it is out of the way of the program | |
95 | * that it will "exec", and that there is sufficient room for the brk. | |
96 | */ | |
97 | #define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2) | |
98 | ||
99 | #define ELF_CORE_COPY_REGS(_dest, _regs) \ | |
100 | memcpy((char *) &_dest, (char *) _regs, \ | |
101 | sizeof(struct pt_regs)); | |
102 | ||
103 | /* No additional FP registers to copy. */ | |
104 | #define ELF_CORE_COPY_FPREGS(t, fpu) 0 | |
105 | ||
106 | /* | |
107 | * This yields a mask that user programs can use to figure out what | |
108 | * instruction set this CPU supports. This could be done in user space, | |
109 | * but it's not easy, and we've already done it here. | |
110 | */ | |
111 | #define ELF_HWCAP (0) | |
112 | ||
113 | /* | |
114 | * This yields a string that ld.so will use to load implementation | |
115 | * specific libraries for optimization. This is more specific in | |
116 | * intent than poking at uname or /proc/cpuinfo. | |
117 | */ | |
118 | #define ELF_PLATFORM (NULL) | |
119 | ||
120 | extern void elf_plat_init(struct pt_regs *regs, unsigned long load_addr); | |
121 | ||
122 | #define ELF_PLAT_INIT(_r, load_addr) elf_plat_init(_r, load_addr) | |
123 | ||
124 | extern int dump_task_regs(struct task_struct *, elf_gregset_t *); | |
125 | #define ELF_CORE_COPY_TASK_REGS(tsk, elf_regs) dump_task_regs(tsk, elf_regs) | |
126 | ||
127 | /* Tilera Linux has no personalities currently, so no need to do anything. */ | |
128 | #define SET_PERSONALITY(ex) do { } while (0) | |
129 | ||
130 | #define ARCH_HAS_SETUP_ADDITIONAL_PAGES | |
131 | /* Support auto-mapping of the user interrupt vectors. */ | |
132 | struct linux_binprm; | |
133 | extern int arch_setup_additional_pages(struct linux_binprm *bprm, | |
134 | int executable_stack); | |
4a556f4f CM |
135 | #define ARCH_DLINFO \ |
136 | do { \ | |
137 | NEW_AUX_ENT(AT_SYSINFO_EHDR, VDSO_BASE); \ | |
138 | } while (0) | |
139 | ||
867e359b CM |
140 | #ifdef CONFIG_COMPAT |
141 | ||
142 | #define COMPAT_ELF_PLATFORM "tilegx-m32" | |
143 | ||
144 | /* | |
145 | * "Compat" binaries have the same machine type, but 32-bit class, | |
146 | * since they're not a separate machine type, but just a 32-bit | |
147 | * variant of the standard 64-bit architecture. | |
148 | */ | |
149 | #define compat_elf_check_arch(x) \ | |
150 | ((x)->e_ident[EI_CLASS] == ELFCLASS32 && \ | |
0707ad30 | 151 | (x)->e_machine == CHIP_ELF_TYPE()) |
867e359b CM |
152 | |
153 | #define compat_start_thread(regs, ip, usp) do { \ | |
154 | regs->pc = ptr_to_compat_reg((void *)(ip)); \ | |
155 | regs->sp = ptr_to_compat_reg((void *)(usp)); \ | |
53055065 | 156 | single_step_execve(); \ |
867e359b CM |
157 | } while (0) |
158 | ||
159 | /* | |
160 | * Use SET_PERSONALITY to indicate compatibility via TS_COMPAT. | |
161 | */ | |
162 | #undef SET_PERSONALITY | |
163 | #define SET_PERSONALITY(ex) \ | |
164 | do { \ | |
9f6547a3 | 165 | set_personality(PER_LINUX | (current->personality & (~PER_MASK))); \ |
867e359b CM |
166 | current_thread_info()->status &= ~TS_COMPAT; \ |
167 | } while (0) | |
168 | #define COMPAT_SET_PERSONALITY(ex) \ | |
169 | do { \ | |
9f6547a3 | 170 | set_personality(PER_LINUX | (current->personality & (~PER_MASK))); \ |
867e359b CM |
171 | current_thread_info()->status |= TS_COMPAT; \ |
172 | } while (0) | |
173 | ||
174 | #define COMPAT_ELF_ET_DYN_BASE (0xffffffff / 3 * 2) | |
175 | ||
176 | #endif /* CONFIG_COMPAT */ | |
177 | ||
e6cdebdf SM |
178 | #define CORE_DUMP_USE_REGSET |
179 | ||
867e359b | 180 | #endif /* _ASM_TILE_ELF_H */ |