blob: 1bca0debdb0fc32050022e0f99d67df77ea3e7a3 [file] [log] [blame]
Chris Metcalf867e3592010-05-28 23:09:12 -04001/*
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
28typedef unsigned long elf_greg_t;
29
30#define ELF_NGREG (sizeof(struct pt_regs) / sizeof(elf_greg_t))
31typedef 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
39typedef double elf_fpreg_t;
40typedef 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
47#define ELF_DATA ELFDATA2LSB
48
49/*
50 * There seems to be a bug in how compat_binfmt_elf.c works: it
51 * #undefs ELF_ARCH, but it is then used in binfmt_elf.c for fill_note_info().
52 * Hack around this by providing an enum value of ELF_ARCH.
53 */
54enum { ELF_ARCH = CHIP_ELF_TYPE() };
55#define ELF_ARCH ELF_ARCH
56
57/*
58 * This is used to ensure we don't load something for the wrong architecture.
59 */
60#define elf_check_arch(x) \
61 ((x)->e_ident[EI_CLASS] == ELF_CLASS && \
62 ((x)->e_machine == CHIP_ELF_TYPE() || \
63 (x)->e_machine == CHIP_COMPAT_ELF_TYPE()))
64
65/* The module loader only handles a few relocation types. */
66#ifndef __tilegx__
67#define R_TILE_32 1
68#define R_TILE_JOFFLONG_X1 15
69#define R_TILE_IMM16_X0_LO 25
70#define R_TILE_IMM16_X1_LO 26
71#define R_TILE_IMM16_X0_HA 29
72#define R_TILE_IMM16_X1_HA 30
73#else
74#define R_TILEGX_64 1
75#define R_TILEGX_JUMPOFF_X1 21
76#define R_TILEGX_IMM16_X0_HW0 36
77#define R_TILEGX_IMM16_X1_HW0 37
78#define R_TILEGX_IMM16_X0_HW1 38
79#define R_TILEGX_IMM16_X1_HW1 39
80#define R_TILEGX_IMM16_X0_HW2_LAST 48
81#define R_TILEGX_IMM16_X1_HW2_LAST 49
82#endif
83
84/* Use standard page size for core dumps. */
85#define ELF_EXEC_PAGESIZE PAGE_SIZE
86
87/*
88 * This is the location that an ET_DYN program is loaded if exec'ed. Typical
89 * use of this is to invoke "./ld.so someprog" to test out a new version of
90 * the loader. We need to make sure that it is out of the way of the program
91 * that it will "exec", and that there is sufficient room for the brk.
92 */
93#define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
94
95#define ELF_CORE_COPY_REGS(_dest, _regs) \
96 memcpy((char *) &_dest, (char *) _regs, \
97 sizeof(struct pt_regs));
98
99/* No additional FP registers to copy. */
100#define ELF_CORE_COPY_FPREGS(t, fpu) 0
101
102/*
103 * This yields a mask that user programs can use to figure out what
104 * instruction set this CPU supports. This could be done in user space,
105 * but it's not easy, and we've already done it here.
106 */
107#define ELF_HWCAP (0)
108
109/*
110 * This yields a string that ld.so will use to load implementation
111 * specific libraries for optimization. This is more specific in
112 * intent than poking at uname or /proc/cpuinfo.
113 */
114#define ELF_PLATFORM (NULL)
115
116extern void elf_plat_init(struct pt_regs *regs, unsigned long load_addr);
117
118#define ELF_PLAT_INIT(_r, load_addr) elf_plat_init(_r, load_addr)
119
120extern int dump_task_regs(struct task_struct *, elf_gregset_t *);
121#define ELF_CORE_COPY_TASK_REGS(tsk, elf_regs) dump_task_regs(tsk, elf_regs)
122
123/* Tilera Linux has no personalities currently, so no need to do anything. */
124#define SET_PERSONALITY(ex) do { } while (0)
125
126#define ARCH_HAS_SETUP_ADDITIONAL_PAGES
127/* Support auto-mapping of the user interrupt vectors. */
128struct linux_binprm;
129extern int arch_setup_additional_pages(struct linux_binprm *bprm,
130 int executable_stack);
131#ifdef CONFIG_COMPAT
132
133#define COMPAT_ELF_PLATFORM "tilegx-m32"
134
135/*
136 * "Compat" binaries have the same machine type, but 32-bit class,
137 * since they're not a separate machine type, but just a 32-bit
138 * variant of the standard 64-bit architecture.
139 */
140#define compat_elf_check_arch(x) \
141 ((x)->e_ident[EI_CLASS] == ELFCLASS32 && \
142 ((x)->e_machine == CHIP_ELF_TYPE() || \
143 (x)->e_machine == CHIP_COMPAT_ELF_TYPE()))
144
145#define compat_start_thread(regs, ip, usp) do { \
146 regs->pc = ptr_to_compat_reg((void *)(ip)); \
147 regs->sp = ptr_to_compat_reg((void *)(usp)); \
148 } while (0)
149
150/*
151 * Use SET_PERSONALITY to indicate compatibility via TS_COMPAT.
152 */
153#undef SET_PERSONALITY
154#define SET_PERSONALITY(ex) \
155do { \
156 current->personality = PER_LINUX; \
157 current_thread_info()->status &= ~TS_COMPAT; \
158} while (0)
159#define COMPAT_SET_PERSONALITY(ex) \
160do { \
161 current->personality = PER_LINUX_32BIT; \
162 current_thread_info()->status |= TS_COMPAT; \
163} while (0)
164
165#define COMPAT_ELF_ET_DYN_BASE (0xffffffff / 3 * 2)
166
167#endif /* CONFIG_COMPAT */
168
169#endif /* _ASM_TILE_ELF_H */