1#ifndef __ASM_ALPHA_ELF_H
2#define __ASM_ALPHA_ELF_H
3
4/*
5 * ELF register definitions..
6 */
7
8/*
9 * The OSF/1 version of <sys/procfs.h> makes gregset_t 46 entries long.
10 * I have no idea why that is so.  For now, we just leave it at 33
11 * (32 general regs + processor status word).
12 */
13#define ELF_NGREG	33
14#define ELF_NFPREG	32
15
16typedef unsigned long elf_greg_t;
17typedef elf_greg_t elf_gregset_t[ELF_NGREG];
18
19typedef double elf_fpreg_t;
20typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
21
22/*
23 * This is used to ensure we don't load something for the wrong architecture.
24 */
25#define elf_check_arch(x) ((x)->e_machine == EM_ALPHA)
26
27/*
28 * These are used to set parameters in the core dumps.
29 */
30#define ELF_CLASS	ELFCLASS64
31#define ELF_DATA	ELFDATA2LSB
32#define ELF_ARCH	EM_ALPHA
33
34#define USE_ELF_CORE_DUMP
35#define ELF_EXEC_PAGESIZE	8192
36
37/* This is the location that an ET_DYN program is loaded if exec'ed.  Typical
38   use of this is to invoke "./ld.so someprog" to test out a new version of
39   the loader.  We need to make sure that it is out of the way of the program
40   that it will "exec", and that there is sufficient room for the brk.  */
41
42#define ELF_ET_DYN_BASE		(TASK_UNMAPPED_BASE + 0x1000000)
43
44/* $0 is set by ld.so to a pointer to a function which might be
45   registered using atexit.  This provides a mean for the dynamic
46   linker to call DT_FINI functions for shared libraries that have
47   been loaded before the code runs.
48
49   So that we can use the same startup file with static executables,
50   we start programs with a value of 0 to indicate that there is no
51   such function.  */
52
53#define ELF_PLAT_INIT(_r)       _r->r0 = 0
54
55/* Use the same format as the OSF/1 procfs interface.  The register
56   layout is sane.  However, since dump_thread() creates the funky
57   layout that ECOFF coredumps want, we need to undo that layout here.
58   Eventually, it would be nice if the ECOFF core-dump had to do the
59   translation, then ELF_CORE_COPY_REGS() would become trivial and
60   faster.  */
61#define ELF_CORE_COPY_REGS(_dest,_regs)				\
62{								\
63	struct user _dump;					\
64								\
65	dump_thread(_regs, &_dump);				\
66	_dest[ 0] = _dump.regs[EF_V0];				\
67	_dest[ 1] = _dump.regs[EF_T0];				\
68	_dest[ 2] = _dump.regs[EF_T1];				\
69	_dest[ 3] = _dump.regs[EF_T2];				\
70	_dest[ 4] = _dump.regs[EF_T3];				\
71	_dest[ 5] = _dump.regs[EF_T4];				\
72	_dest[ 6] = _dump.regs[EF_T5];				\
73	_dest[ 7] = _dump.regs[EF_T6];				\
74	_dest[ 8] = _dump.regs[EF_T7];				\
75	_dest[ 9] = _dump.regs[EF_S0];				\
76	_dest[10] = _dump.regs[EF_S1];				\
77	_dest[11] = _dump.regs[EF_S2];				\
78	_dest[12] = _dump.regs[EF_S3];				\
79	_dest[13] = _dump.regs[EF_S4];				\
80	_dest[14] = _dump.regs[EF_S5];				\
81	_dest[15] = _dump.regs[EF_S6];				\
82	_dest[16] = _dump.regs[EF_A0];				\
83	_dest[17] = _dump.regs[EF_A1];				\
84	_dest[18] = _dump.regs[EF_A2];				\
85	_dest[19] = _dump.regs[EF_A3];				\
86	_dest[20] = _dump.regs[EF_A4];				\
87	_dest[21] = _dump.regs[EF_A5];				\
88	_dest[22] = _dump.regs[EF_T8];				\
89	_dest[23] = _dump.regs[EF_T9];				\
90	_dest[24] = _dump.regs[EF_T10];				\
91	_dest[25] = _dump.regs[EF_T11];				\
92	_dest[26] = _dump.regs[EF_RA];				\
93	_dest[27] = _dump.regs[EF_T12];				\
94	_dest[28] = _dump.regs[EF_AT];				\
95	_dest[29] = _dump.regs[EF_GP];				\
96	_dest[30] = _dump.regs[EF_SP];				\
97	_dest[31] = _dump.regs[EF_PC];	/* store PC here */	\
98	_dest[32] = _dump.regs[EF_PS];				\
99}
100
101/* This yields a mask that user programs can use to figure out what
102   instruction set this CPU supports.  This is trivial on Alpha,
103   but not so on other machines. */
104
105#define ELF_HWCAP							\
106({									\
107	/* Sadly, most folks don't yet have assemblers that know about	\
108	   amask.  This is "amask v0, v0" */				\
109	register long _v0 __asm("$0") = -1;				\
110	__asm(".long 0x47e00c20" : "=r"(_v0) : "0"(_v0));		\
111	~_v0;								\
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   This might do with checking bwx simultaneously...  */
119
120#define ELF_PLATFORM				\
121({						\
122	/* Or "implver v0" ... */		\
123	register long _v0 __asm("$0");		\
124	__asm(".long 0x47e03d80" : "=r"(_v0));	\
125	_v0 == 0 ? "ev4" : "ev5";		\
126})
127
128#ifdef __KERNEL__
129#define SET_PERSONALITY(EX, IBCS2)				\
130	set_personality(((EX).e_flags & EF_ALPHA_32BIT)		\
131	   ? PER_LINUX_32BIT : (IBCS2) ? PER_SVR4 : PER_LINUX)
132#endif
133
134#endif
135