2 * Copyright 2010 Tilera Corporation. All Rights Reserved.
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.
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
15 #ifndef _ASM_TILE_ELF_H
16 #define _ASM_TILE_ELF_H
19 * ELF register definitions.
22 #include <arch/chip.h>
24 #include <linux/ptrace.h>
25 #include <asm/byteorder.h>
28 typedef unsigned long elf_greg_t
;
30 #define ELF_NGREG (sizeof(struct pt_regs) / sizeof(elf_greg_t))
31 typedef elf_greg_t elf_gregset_t
[ELF_NGREG
];
33 #define EM_TILEPRO 188
36 /* Provide a nominal data structure. */
38 typedef double elf_fpreg_t
;
39 typedef elf_fpreg_t elf_fpregset_t
[ELF_NFPREG
];
42 #define ELF_CLASS ELFCLASS64
44 #define ELF_CLASS ELFCLASS32
47 #define ELF_DATA ELFDATA2MSB
49 #define ELF_DATA ELFDATA2LSB
53 * There seems to be a bug in how compat_binfmt_elf.c works: it
54 * #undefs ELF_ARCH, but it is then used in binfmt_elf.c for fill_note_info().
55 * Hack around this by providing an enum value of ELF_ARCH.
57 enum { ELF_ARCH
= CHIP_ELF_TYPE() };
58 #define ELF_ARCH ELF_ARCH
61 * This is used to ensure we don't load something for the wrong architecture.
63 #define elf_check_arch(x) \
64 ((x)->e_ident[EI_CLASS] == ELF_CLASS && \
65 (x)->e_ident[EI_DATA] == ELF_DATA && \
66 (x)->e_machine == CHIP_ELF_TYPE())
68 /* The module loader only handles a few relocation types. */
71 #define R_TILE_JOFFLONG_X1 15
72 #define R_TILE_IMM16_X0_LO 25
73 #define R_TILE_IMM16_X1_LO 26
74 #define R_TILE_IMM16_X0_HA 29
75 #define R_TILE_IMM16_X1_HA 30
78 #define R_TILEGX_JUMPOFF_X1 21
79 #define R_TILEGX_IMM16_X0_HW0 36
80 #define R_TILEGX_IMM16_X1_HW0 37
81 #define R_TILEGX_IMM16_X0_HW1 38
82 #define R_TILEGX_IMM16_X1_HW1 39
83 #define R_TILEGX_IMM16_X0_HW2_LAST 48
84 #define R_TILEGX_IMM16_X1_HW2_LAST 49
87 /* Use standard page size for core dumps. */
88 #define ELF_EXEC_PAGESIZE PAGE_SIZE
91 * This is the location that an ET_DYN program is loaded if exec'ed. Typical
92 * use of this is to invoke "./ld.so someprog" to test out a new version of
93 * the loader. We need to make sure that it is out of the way of the program
94 * that it will "exec", and that there is sufficient room for the brk.
96 #define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
98 #define ELF_CORE_COPY_REGS(_dest, _regs) \
99 memcpy((char *) &_dest, (char *) _regs, \
100 sizeof(struct pt_regs));
102 /* No additional FP registers to copy. */
103 #define ELF_CORE_COPY_FPREGS(t, fpu) 0
106 * This yields a mask that user programs can use to figure out what
107 * instruction set this CPU supports. This could be done in user space,
108 * but it's not easy, and we've already done it here.
110 #define ELF_HWCAP (0)
113 * This yields a string that ld.so will use to load implementation
114 * specific libraries for optimization. This is more specific in
115 * intent than poking at uname or /proc/cpuinfo.
117 #define ELF_PLATFORM (NULL)
119 extern void elf_plat_init(struct pt_regs
*regs
, unsigned long load_addr
);
121 #define ELF_PLAT_INIT(_r, load_addr) elf_plat_init(_r, load_addr)
123 extern int dump_task_regs(struct task_struct
*, elf_gregset_t
*);
124 #define ELF_CORE_COPY_TASK_REGS(tsk, elf_regs) dump_task_regs(tsk, elf_regs)
126 /* Tilera Linux has no personalities currently, so no need to do anything. */
127 #define SET_PERSONALITY(ex) do { } while (0)
129 #define ARCH_HAS_SETUP_ADDITIONAL_PAGES
130 /* Support auto-mapping of the user interrupt vectors. */
132 extern int arch_setup_additional_pages(struct linux_binprm
*bprm
,
133 int executable_stack
);
134 #define ARCH_DLINFO \
136 NEW_AUX_ENT(AT_SYSINFO_EHDR, VDSO_BASE); \
140 extern unsigned long arch_randomize_brk(struct mm_struct
*mm
);
141 #define arch_randomize_brk arch_randomize_brk
145 #define COMPAT_ELF_PLATFORM "tilegx-m32"
148 * "Compat" binaries have the same machine type, but 32-bit class,
149 * since they're not a separate machine type, but just a 32-bit
150 * variant of the standard 64-bit architecture.
152 #define compat_elf_check_arch(x) \
153 ((x)->e_ident[EI_CLASS] == ELFCLASS32 && \
154 (x)->e_machine == CHIP_ELF_TYPE())
156 #define compat_start_thread(regs, ip, usp) do { \
157 regs->pc = ptr_to_compat_reg((void *)(ip)); \
158 regs->sp = ptr_to_compat_reg((void *)(usp)); \
159 single_step_execve(); \
163 * Use SET_PERSONALITY to indicate compatibility via TS_COMPAT.
165 #undef SET_PERSONALITY
166 #define SET_PERSONALITY(ex) \
168 set_personality(PER_LINUX | (current->personality & (~PER_MASK))); \
169 current_thread_info()->status &= ~TS_COMPAT; \
171 #define COMPAT_SET_PERSONALITY(ex) \
173 set_personality(PER_LINUX | (current->personality & (~PER_MASK))); \
174 current_thread_info()->status |= TS_COMPAT; \
177 #define COMPAT_ELF_ET_DYN_BASE (0xffffffff / 3 * 2)
179 #endif /* CONFIG_COMPAT */
181 #define CORE_DUMP_USE_REGSET
183 #endif /* _ASM_TILE_ELF_H */