Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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> |
David S. Miller | 97532f5 | 2006-02-17 10:14:38 -0800 | [diff] [blame] | 13 | #include <asm/spitfire.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 |
David S. Miller | 97532f5 | 2006-02-17 10:14:38 -0800 | [diff] [blame] | 72 | #define HWCAP_SPARC_BLKINIT 64 |
David S. Miller | 8b224b8 | 2007-08-16 13:56:39 -0700 | [diff] [blame] | 73 | #define HWCAP_SPARC_N2 128 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 74 | |
| 75 | /* |
| 76 | * These are used to set parameters in the core dumps. |
| 77 | */ |
| 78 | #ifndef ELF_ARCH |
| 79 | #define ELF_ARCH EM_SPARCV9 |
| 80 | #define ELF_CLASS ELFCLASS64 |
| 81 | #define ELF_DATA ELFDATA2MSB |
| 82 | |
| 83 | typedef unsigned long elf_greg_t; |
| 84 | |
| 85 | #define ELF_NGREG 36 |
| 86 | typedef elf_greg_t elf_gregset_t[ELF_NGREG]; |
| 87 | /* Format of 64-bit elf_gregset_t is: |
| 88 | * G0 --> G7 |
| 89 | * O0 --> O7 |
| 90 | * L0 --> L7 |
| 91 | * I0 --> I7 |
| 92 | * TSTATE |
| 93 | * TPC |
| 94 | * TNPC |
| 95 | * Y |
| 96 | */ |
| 97 | #define ELF_CORE_COPY_REGS(__elf_regs, __pt_regs) \ |
| 98 | do { unsigned long *dest = &(__elf_regs[0]); \ |
| 99 | struct pt_regs *src = (__pt_regs); \ |
| 100 | unsigned long __user *sp; \ |
| 101 | int i; \ |
| 102 | for(i = 0; i < 16; i++) \ |
| 103 | dest[i] = src->u_regs[i]; \ |
| 104 | /* Don't try this at home kids... */ \ |
| 105 | sp = (unsigned long __user *) \ |
| 106 | ((src->u_regs[14] + STACK_BIAS) \ |
| 107 | & 0xfffffffffffffff8UL); \ |
| 108 | for(i = 0; i < 16; i++) \ |
| 109 | __get_user(dest[i+16], &sp[i]); \ |
| 110 | dest[32] = src->tstate; \ |
| 111 | dest[33] = src->tpc; \ |
| 112 | dest[34] = src->tnpc; \ |
| 113 | dest[35] = src->y; \ |
| 114 | } while (0); |
| 115 | |
| 116 | typedef struct { |
| 117 | unsigned long pr_regs[32]; |
| 118 | unsigned long pr_fsr; |
| 119 | unsigned long pr_gsr; |
| 120 | unsigned long pr_fprs; |
| 121 | } elf_fpregset_t; |
| 122 | #endif |
| 123 | |
| 124 | #define ELF_CORE_COPY_TASK_REGS(__tsk, __elf_regs) \ |
Al Viro | 26ecbde | 2006-01-12 01:05:43 -0800 | [diff] [blame] | 125 | ({ ELF_CORE_COPY_REGS((*(__elf_regs)), task_pt_regs(__tsk)); 1; }) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 126 | |
| 127 | /* |
| 128 | * This is used to ensure we don't load something for the wrong architecture. |
| 129 | */ |
| 130 | #ifndef elf_check_arch |
| 131 | #define elf_check_arch(x) ((x)->e_machine == ELF_ARCH) /* Might be EM_SPARCV9 or EM_SPARC */ |
| 132 | #endif |
| 133 | |
| 134 | #define USE_ELF_CORE_DUMP |
| 135 | #define ELF_EXEC_PAGESIZE PAGE_SIZE |
| 136 | |
| 137 | /* This is the location that an ET_DYN program is loaded if exec'ed. Typical |
| 138 | use of this is to invoke "./ld.so someprog" to test out a new version of |
| 139 | the loader. We need to make sure that it is out of the way of the program |
| 140 | that it will "exec", and that there is sufficient room for the brk. */ |
| 141 | |
| 142 | #ifndef ELF_ET_DYN_BASE |
| 143 | #define ELF_ET_DYN_BASE 0x0000010000000000UL |
| 144 | #endif |
| 145 | |
| 146 | |
| 147 | /* This yields a mask that user programs can use to figure out what |
| 148 | instruction set this cpu supports. */ |
| 149 | |
| 150 | /* On Ultra, we support all of the v8 capabilities. */ |
David S. Miller | 97532f5 | 2006-02-17 10:14:38 -0800 | [diff] [blame] | 151 | static inline unsigned int sparc64_elf_hwcap(void) |
| 152 | { |
| 153 | unsigned int cap = (HWCAP_SPARC_FLUSH | HWCAP_SPARC_STBAR | |
| 154 | HWCAP_SPARC_SWAP | HWCAP_SPARC_MULDIV | |
| 155 | HWCAP_SPARC_V9); |
| 156 | |
| 157 | if (tlb_type == cheetah || tlb_type == cheetah_plus) |
| 158 | cap |= HWCAP_SPARC_ULTRA3; |
David S. Miller | 8b224b8 | 2007-08-16 13:56:39 -0700 | [diff] [blame] | 159 | else if (tlb_type == hypervisor) { |
| 160 | if (sun4v_chip_type == SUN4V_CHIP_NIAGARA1 || |
| 161 | sun4v_chip_type == SUN4V_CHIP_NIAGARA2) |
| 162 | cap |= HWCAP_SPARC_BLKINIT; |
| 163 | if (sun4v_chip_type == SUN4V_CHIP_NIAGARA2) |
| 164 | cap |= HWCAP_SPARC_N2; |
| 165 | } |
David S. Miller | 97532f5 | 2006-02-17 10:14:38 -0800 | [diff] [blame] | 166 | |
| 167 | return cap; |
| 168 | } |
| 169 | |
| 170 | #define ELF_HWCAP sparc64_elf_hwcap(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 171 | |
| 172 | /* This yields a string that ld.so will use to load implementation |
| 173 | specific libraries for optimization. This is more specific in |
| 174 | intent than poking at uname or /proc/cpuinfo. */ |
| 175 | |
| 176 | #define ELF_PLATFORM (NULL) |
| 177 | |
| 178 | #ifdef __KERNEL__ |
| 179 | #define SET_PERSONALITY(ex, ibcs2) \ |
| 180 | do { unsigned long new_flags = current_thread_info()->flags; \ |
| 181 | new_flags &= _TIF_32BIT; \ |
| 182 | if ((ex).e_ident[EI_CLASS] == ELFCLASS32) \ |
| 183 | new_flags |= _TIF_32BIT; \ |
| 184 | else \ |
| 185 | new_flags &= ~_TIF_32BIT; \ |
| 186 | if ((current_thread_info()->flags & _TIF_32BIT) \ |
| 187 | != new_flags) \ |
| 188 | set_thread_flag(TIF_ABI_PENDING); \ |
| 189 | else \ |
| 190 | clear_thread_flag(TIF_ABI_PENDING); \ |
| 191 | /* flush_thread will update pgd cache */ \ |
| 192 | if (ibcs2) \ |
| 193 | set_personality(PER_SVR4); \ |
| 194 | else if (current->personality != PER_LINUX32) \ |
| 195 | set_personality(PER_LINUX); \ |
| 196 | } while (0) |
| 197 | #endif |
| 198 | |
| 199 | #endif /* !(__ASM_SPARC64_ELF_H) */ |