[SPARC64]: Use regsets for ELF core dumping.
[sfrench/cifs-2.6.git] / include / asm-sparc64 / elf.h
1 /* $Id: elf.h,v 1.32 2002/02/09 19:49:31 davem Exp $ */
2 #ifndef __ASM_SPARC64_ELF_H
3 #define __ASM_SPARC64_ELF_H
4
5 /*
6  * ELF register definitions..
7  */
8
9 #include <asm/ptrace.h>
10 #ifdef __KERNEL__
11 #include <asm/processor.h>
12 #include <asm/uaccess.h>
13 #include <asm/spitfire.h>
14 #endif
15
16 /*
17  * Sparc section types
18  */
19 #define STT_REGISTER            13
20
21 /*
22  * Sparc ELF relocation types
23  */
24 #define R_SPARC_NONE            0
25 #define R_SPARC_8               1
26 #define R_SPARC_16              2
27 #define R_SPARC_32              3
28 #define R_SPARC_DISP8           4
29 #define R_SPARC_DISP16          5
30 #define R_SPARC_DISP32          6
31 #define R_SPARC_WDISP30         7
32 #define R_SPARC_WDISP22         8
33 #define R_SPARC_HI22            9
34 #define R_SPARC_22              10
35 #define R_SPARC_13              11
36 #define R_SPARC_LO10            12
37 #define R_SPARC_GOT10           13
38 #define R_SPARC_GOT13           14
39 #define R_SPARC_GOT22           15
40 #define R_SPARC_PC10            16
41 #define R_SPARC_PC22            17
42 #define R_SPARC_WPLT30          18
43 #define R_SPARC_COPY            19
44 #define R_SPARC_GLOB_DAT        20
45 #define R_SPARC_JMP_SLOT        21
46 #define R_SPARC_RELATIVE        22
47 #define R_SPARC_UA32            23
48 #define R_SPARC_PLT32           24
49 #define R_SPARC_HIPLT22         25
50 #define R_SPARC_LOPLT10         26
51 #define R_SPARC_PCPLT32         27
52 #define R_SPARC_PCPLT22         28
53 #define R_SPARC_PCPLT10         29
54 #define R_SPARC_10              30
55 #define R_SPARC_11              31
56 #define R_SPARC_64              32
57 #define R_SPARC_OLO10           33
58 #define R_SPARC_WDISP16         40
59 #define R_SPARC_WDISP19         41
60 #define R_SPARC_7               43
61 #define R_SPARC_5               44
62 #define R_SPARC_6               45
63
64 /* Bits present in AT_HWCAP, primarily for Sparc32.  */
65
66 #define HWCAP_SPARC_FLUSH       1    /* CPU supports flush instruction. */
67 #define HWCAP_SPARC_STBAR       2
68 #define HWCAP_SPARC_SWAP        4
69 #define HWCAP_SPARC_MULDIV      8
70 #define HWCAP_SPARC_V9          16
71 #define HWCAP_SPARC_ULTRA3      32
72 #define HWCAP_SPARC_BLKINIT     64
73 #define HWCAP_SPARC_N2          128
74
75 #define CORE_DUMP_USE_REGSET
76
77 /*
78  * These are used to set parameters in the core dumps.
79  */
80 #ifndef ELF_ARCH
81 #define ELF_ARCH                EM_SPARCV9
82 #define ELF_CLASS               ELFCLASS64
83 #define ELF_DATA                ELFDATA2MSB
84
85 /* Format of 64-bit elf_gregset_t is:
86  *      G0 --> G7
87  *      O0 --> O7
88  *      L0 --> L7
89  *      I0 --> I7
90  *      TSTATE
91  *      TPC
92  *      TNPC
93  *      Y
94  */
95 typedef unsigned long elf_greg_t;
96 #define ELF_NGREG 36
97 typedef elf_greg_t elf_gregset_t[ELF_NGREG];
98
99 typedef struct {
100         unsigned long   pr_regs[32];
101         unsigned long   pr_fsr;
102         unsigned long   pr_gsr;
103         unsigned long   pr_fprs;
104 } elf_fpregset_t;
105 #endif
106
107 /*
108  * This is used to ensure we don't load something for the wrong architecture.
109  */
110 #ifndef elf_check_arch
111 #define elf_check_arch(x) ((x)->e_machine == ELF_ARCH)  /* Might be EM_SPARCV9 or EM_SPARC */
112 #endif
113
114 #define USE_ELF_CORE_DUMP
115 #define ELF_EXEC_PAGESIZE       PAGE_SIZE
116
117 /* This is the location that an ET_DYN program is loaded if exec'ed.  Typical
118    use of this is to invoke "./ld.so someprog" to test out a new version of
119    the loader.  We need to make sure that it is out of the way of the program
120    that it will "exec", and that there is sufficient room for the brk.  */
121
122 #ifndef ELF_ET_DYN_BASE
123 #define ELF_ET_DYN_BASE         0x0000010000000000UL
124 #endif
125
126
127 /* This yields a mask that user programs can use to figure out what
128    instruction set this cpu supports.  */
129
130 /* On Ultra, we support all of the v8 capabilities. */
131 static inline unsigned int sparc64_elf_hwcap(void)
132 {
133         unsigned int cap = (HWCAP_SPARC_FLUSH | HWCAP_SPARC_STBAR |
134                             HWCAP_SPARC_SWAP | HWCAP_SPARC_MULDIV |
135                             HWCAP_SPARC_V9);
136
137         if (tlb_type == cheetah || tlb_type == cheetah_plus)
138                 cap |= HWCAP_SPARC_ULTRA3;
139         else if (tlb_type == hypervisor) {
140                 if (sun4v_chip_type == SUN4V_CHIP_NIAGARA1 ||
141                     sun4v_chip_type == SUN4V_CHIP_NIAGARA2)
142                         cap |= HWCAP_SPARC_BLKINIT;
143                 if (sun4v_chip_type == SUN4V_CHIP_NIAGARA2)
144                         cap |= HWCAP_SPARC_N2;
145         }
146
147         return cap;
148 }
149
150 #define ELF_HWCAP       sparc64_elf_hwcap();
151
152 /* This yields a string that ld.so will use to load implementation
153    specific libraries for optimization.  This is more specific in
154    intent than poking at uname or /proc/cpuinfo.  */
155
156 #define ELF_PLATFORM    (NULL)
157
158 #ifdef __KERNEL__
159 #define SET_PERSONALITY(ex, ibcs2)                      \
160 do {    unsigned long new_flags = current_thread_info()->flags; \
161         new_flags &= _TIF_32BIT;                        \
162         if ((ex).e_ident[EI_CLASS] == ELFCLASS32)       \
163                 new_flags |= _TIF_32BIT;                \
164         else                                            \
165                 new_flags &= ~_TIF_32BIT;               \
166         if ((current_thread_info()->flags & _TIF_32BIT) \
167             != new_flags)                               \
168                 set_thread_flag(TIF_ABI_PENDING);       \
169         else                                            \
170                 clear_thread_flag(TIF_ABI_PENDING);     \
171         /* flush_thread will update pgd cache */        \
172         if (ibcs2)                                      \
173                 set_personality(PER_SVR4);              \
174         else if (current->personality != PER_LINUX32)   \
175                 set_personality(PER_LINUX);             \
176 } while (0)
177 #endif
178
179 #endif /* !(__ASM_SPARC64_ELF_H) */