1/* $Id: elf.h,v 1.1.1.1 2008/10/15 03:27:26 james26_jang 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#endif 13 14/* 15 * These are used to set parameters in the core dumps. 16 */ 17#ifndef ELF_ARCH 18#define ELF_ARCH EM_SPARCV9 19#define ELF_CLASS ELFCLASS64 20#define ELF_DATA ELFDATA2MSB 21 22typedef unsigned long elf_greg_t; 23 24#define ELF_NGREG 36 25typedef elf_greg_t elf_gregset_t[ELF_NGREG]; 26/* Format of 64-bit elf_gregset_t is: 27 * G0 --> G7 28 * O0 --> O7 29 * L0 --> L7 30 * I0 --> I7 31 * TSTATE 32 * TPC 33 * TNPC 34 * Y 35 */ 36#include <asm/psrcompat.h> 37#define ELF_CORE_COPY_REGS(__elf_regs, __pt_regs) \ 38do { unsigned long *dest = &(__elf_regs[0]); \ 39 struct pt_regs *src = (__pt_regs); \ 40 unsigned long *sp; \ 41 int i; \ 42 for(i = 0; i < 16; i++) \ 43 dest[i] = src->u_regs[i]; \ 44 /* Don't try this at home kids... */ \ 45 set_fs(USER_DS); \ 46 sp = (unsigned long *) \ 47 ((src->u_regs[14] + STACK_BIAS) \ 48 & 0xfffffffffffffff8UL); \ 49 for(i = 0; i < 16; i++) \ 50 __get_user(dest[i+16], &sp[i]); \ 51 set_fs(KERNEL_DS); \ 52 dest[32] = src->tstate; \ 53 dest[33] = src->tpc; \ 54 dest[34] = src->tnpc; \ 55 dest[35] = src->y; \ 56} while (0); 57 58typedef struct { 59 unsigned long pr_regs[32]; 60 unsigned long pr_fsr; 61 unsigned long pr_gsr; 62 unsigned long pr_fprs; 63} elf_fpregset_t; 64#endif 65 66/* 67 * This is used to ensure we don't load something for the wrong architecture. 68 */ 69#ifndef elf_check_arch 70#define elf_check_arch(x) ((x)->e_machine == ELF_ARCH) /* Might be EM_SPARCV9 or EM_SPARC */ 71#endif 72 73#define USE_ELF_CORE_DUMP 74#define ELF_EXEC_PAGESIZE PAGE_SIZE 75 76/* This is the location that an ET_DYN program is loaded if exec'ed. Typical 77 use of this is to invoke "./ld.so someprog" to test out a new version of 78 the loader. We need to make sure that it is out of the way of the program 79 that it will "exec", and that there is sufficient room for the brk. */ 80 81#ifndef ELF_ET_DYN_BASE 82#define ELF_ET_DYN_BASE 0x0000010000000000UL 83#endif 84 85 86/* This yields a mask that user programs can use to figure out what 87 instruction set this cpu supports. */ 88 89/* On Ultra, we support all of the v8 capabilities. */ 90#define ELF_HWCAP ((HWCAP_SPARC_FLUSH | HWCAP_SPARC_STBAR | \ 91 HWCAP_SPARC_SWAP | HWCAP_SPARC_MULDIV | \ 92 HWCAP_SPARC_V9) | \ 93 ((tlb_type == cheetah || tlb_type == cheetah_plus) ? \ 94 HWCAP_SPARC_ULTRA3 : 0)) 95 96/* This yields a string that ld.so will use to load implementation 97 specific libraries for optimization. This is more specific in 98 intent than poking at uname or /proc/cpuinfo. */ 99 100#define ELF_PLATFORM (NULL) 101 102#ifdef __KERNEL__ 103#define SET_PERSONALITY(ex, ibcs2) \ 104do { unsigned char flags = current->thread.flags; \ 105 if ((ex).e_ident[EI_CLASS] == ELFCLASS32) \ 106 flags |= SPARC_FLAG_32BIT; \ 107 else \ 108 flags &= ~SPARC_FLAG_32BIT; \ 109 if (flags != current->thread.flags) { \ 110 /* flush_thread will update pgd cache */\ 111 current->thread.flags |= SPARC_FLAG_ABI_PENDING; \ 112 } \ 113 \ 114 if (ibcs2) \ 115 set_personality(PER_SVR4); \ 116 else if (current->personality != PER_LINUX32) \ 117 set_personality(PER_LINUX); \ 118} while (0) 119#endif 120 121#endif /* !(__ASM_SPARC64_ELF_H) */ 122