xref: /OK3568_Linux_fs/kernel/arch/microblaze/include/uapi/asm/elf.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2*4882a593Smuzhiyun /*
3*4882a593Smuzhiyun  * Copyright (C) 2008-2009 Michal Simek <monstr@monstr.eu>
4*4882a593Smuzhiyun  * Copyright (C) 2008-2009 PetaLogix
5*4882a593Smuzhiyun  * Copyright (C) 2006 Atmark Techno, Inc.
6*4882a593Smuzhiyun  *
7*4882a593Smuzhiyun  * This file is subject to the terms and conditions of the GNU General Public
8*4882a593Smuzhiyun  * License. See the file "COPYING" in the main directory of this archive
9*4882a593Smuzhiyun  * for more details.
10*4882a593Smuzhiyun  */
11*4882a593Smuzhiyun 
12*4882a593Smuzhiyun #ifndef _UAPI_ASM_MICROBLAZE_ELF_H
13*4882a593Smuzhiyun #define _UAPI_ASM_MICROBLAZE_ELF_H
14*4882a593Smuzhiyun 
15*4882a593Smuzhiyun #include <linux/elf-em.h>
16*4882a593Smuzhiyun 
17*4882a593Smuzhiyun /*
18*4882a593Smuzhiyun  * Note there is no "official" ELF designation for Microblaze.
19*4882a593Smuzhiyun  * I've snaffled the value from the microblaze binutils source code
20*4882a593Smuzhiyun  * /binutils/microblaze/include/elf/microblaze.h
21*4882a593Smuzhiyun  */
22*4882a593Smuzhiyun #define EM_MICROBLAZE_OLD	0xbaab
23*4882a593Smuzhiyun #define ELF_ARCH		EM_MICROBLAZE
24*4882a593Smuzhiyun 
25*4882a593Smuzhiyun /*
26*4882a593Smuzhiyun  * This is used to ensure we don't load something for the wrong architecture.
27*4882a593Smuzhiyun  */
28*4882a593Smuzhiyun #define elf_check_arch(x)	((x)->e_machine == EM_MICROBLAZE \
29*4882a593Smuzhiyun 				 || (x)->e_machine == EM_MICROBLAZE_OLD)
30*4882a593Smuzhiyun 
31*4882a593Smuzhiyun /*
32*4882a593Smuzhiyun  * These are used to set parameters in the core dumps.
33*4882a593Smuzhiyun  */
34*4882a593Smuzhiyun #define ELF_CLASS	ELFCLASS32
35*4882a593Smuzhiyun 
36*4882a593Smuzhiyun #ifndef __uClinux__
37*4882a593Smuzhiyun 
38*4882a593Smuzhiyun /*
39*4882a593Smuzhiyun  * ELF register definitions..
40*4882a593Smuzhiyun  */
41*4882a593Smuzhiyun 
42*4882a593Smuzhiyun #include <asm/ptrace.h>
43*4882a593Smuzhiyun #include <asm/byteorder.h>
44*4882a593Smuzhiyun 
45*4882a593Smuzhiyun #ifndef ELF_GREG_T
46*4882a593Smuzhiyun #define ELF_GREG_T
47*4882a593Smuzhiyun typedef unsigned long elf_greg_t;
48*4882a593Smuzhiyun #endif
49*4882a593Smuzhiyun 
50*4882a593Smuzhiyun #ifndef ELF_NGREG
51*4882a593Smuzhiyun #define ELF_NGREG (sizeof(struct pt_regs) / sizeof(elf_greg_t))
52*4882a593Smuzhiyun #endif
53*4882a593Smuzhiyun 
54*4882a593Smuzhiyun #ifndef ELF_GREGSET_T
55*4882a593Smuzhiyun #define ELF_GREGSET_T
56*4882a593Smuzhiyun typedef elf_greg_t elf_gregset_t[ELF_NGREG];
57*4882a593Smuzhiyun #endif
58*4882a593Smuzhiyun 
59*4882a593Smuzhiyun #ifndef ELF_FPREGSET_T
60*4882a593Smuzhiyun #define ELF_FPREGSET_T
61*4882a593Smuzhiyun 
62*4882a593Smuzhiyun /* TBD */
63*4882a593Smuzhiyun #define ELF_NFPREG	33	/* includes fsr */
64*4882a593Smuzhiyun typedef unsigned long elf_fpreg_t;
65*4882a593Smuzhiyun typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
66*4882a593Smuzhiyun 
67*4882a593Smuzhiyun /* typedef struct user_fpu_struct elf_fpregset_t; */
68*4882a593Smuzhiyun #endif
69*4882a593Smuzhiyun 
70*4882a593Smuzhiyun /* This is the location that an ET_DYN program is loaded if exec'ed.  Typical
71*4882a593Smuzhiyun  * use of this is to invoke "./ld.so someprog" to test out a new version of
72*4882a593Smuzhiyun  * the loader.  We need to make sure that it is out of the way of the program
73*4882a593Smuzhiyun  * that it will "exec", and that there is sufficient room for the brk.
74*4882a593Smuzhiyun  */
75*4882a593Smuzhiyun 
76*4882a593Smuzhiyun #define ELF_ET_DYN_BASE         (0x08000000)
77*4882a593Smuzhiyun 
78*4882a593Smuzhiyun #ifdef __MICROBLAZEEL__
79*4882a593Smuzhiyun #define ELF_DATA	ELFDATA2LSB
80*4882a593Smuzhiyun #else
81*4882a593Smuzhiyun #define ELF_DATA	ELFDATA2MSB
82*4882a593Smuzhiyun #endif
83*4882a593Smuzhiyun 
84*4882a593Smuzhiyun #define ELF_EXEC_PAGESIZE	PAGE_SIZE
85*4882a593Smuzhiyun 
86*4882a593Smuzhiyun 
87*4882a593Smuzhiyun #define ELF_CORE_COPY_REGS(_dest, _regs)			\
88*4882a593Smuzhiyun 	memcpy((char *) &_dest, (char *) _regs,		\
89*4882a593Smuzhiyun 	sizeof(struct pt_regs));
90*4882a593Smuzhiyun 
91*4882a593Smuzhiyun /* This yields a mask that user programs can use to figure out what
92*4882a593Smuzhiyun  * instruction set this CPU supports.  This could be done in user space,
93*4882a593Smuzhiyun  * but it's not easy, and we've already done it here.
94*4882a593Smuzhiyun  */
95*4882a593Smuzhiyun #define ELF_HWCAP	(0)
96*4882a593Smuzhiyun 
97*4882a593Smuzhiyun /* This yields a string that ld.so will use to load implementation
98*4882a593Smuzhiyun  * specific libraries for optimization.  This is more specific in
99*4882a593Smuzhiyun  * intent than poking at uname or /proc/cpuinfo.
100*4882a593Smuzhiyun 
101*4882a593Smuzhiyun  * For the moment, we have only optimizations for the Intel generations,
102*4882a593Smuzhiyun  * but that could change...
103*4882a593Smuzhiyun  */
104*4882a593Smuzhiyun #define ELF_PLATFORM  (NULL)
105*4882a593Smuzhiyun 
106*4882a593Smuzhiyun /* Added _f parameter. Is this definition correct: TBD */
107*4882a593Smuzhiyun #define ELF_PLAT_INIT(_r, _f)				\
108*4882a593Smuzhiyun do {							\
109*4882a593Smuzhiyun 	_r->r0 =  _r->r1 =  _r->r2 =  _r->r3 =		\
110*4882a593Smuzhiyun 	_r->r4 =  _r->r5 =  _r->r6 =  _r->r7 =		\
111*4882a593Smuzhiyun 	_r->r8 =  _r->r9 =  _r->r10 = _r->r11 =		\
112*4882a593Smuzhiyun 	_r->r12 = _r->r13 = _r->r14 = _r->r15 =		\
113*4882a593Smuzhiyun 	_r->r16 = _r->r17 = _r->r18 = _r->r19 =		\
114*4882a593Smuzhiyun 	_r->r20 = _r->r21 = _r->r22 = _r->r23 =		\
115*4882a593Smuzhiyun 	_r->r24 = _r->r25 = _r->r26 = _r->r27 =		\
116*4882a593Smuzhiyun 	_r->r28 = _r->r29 = _r->r30 = _r->r31 =		\
117*4882a593Smuzhiyun 	0;						\
118*4882a593Smuzhiyun } while (0)
119*4882a593Smuzhiyun 
120*4882a593Smuzhiyun 
121*4882a593Smuzhiyun #endif /* __uClinux__ */
122*4882a593Smuzhiyun 
123*4882a593Smuzhiyun #endif /* _UAPI_ASM_MICROBLAZE_ELF_H */
124