added a lot of printk output to ease writing of emulator
[linux-2.4.21-pre4.git] / include / asm-ppc64 / elf.h
1 #ifndef __PPC64_ELF_H
2 #define __PPC64_ELF_H
3
4 /*
5  * ELF register definitions..
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version
10  * 2 of the License, or (at your option) any later version.
11  */
12 #include <asm/ptrace.h>
13
14 #define ELF_NGREG       48      /* includes nip, msr, lr, etc. */
15 #define ELF_NFPREG      33      /* includes fpscr */
16 #define ELF_NVRREG      33      /* includes vscr */
17
18 typedef unsigned long elf_greg_t64;
19 typedef elf_greg_t64 elf_gregset_t64[ELF_NGREG];
20
21 typedef unsigned int elf_greg_t32;
22 typedef elf_greg_t32 elf_gregset_t32[ELF_NGREG];
23
24 /*
25  * These are used to set parameters in the core dumps.
26  */
27 #ifndef ELF_ARCH
28 # define ELF_ARCH       EM_PPC64
29 # define ELF_CLASS      ELFCLASS64
30 # define ELF_DATA       ELFDATA2MSB
31   typedef elf_greg_t64 elf_greg_t;
32   typedef elf_gregset_t64 elf_gregset_t;
33 # define elf_addr_t unsigned long
34 # define elf_caddr_t char *
35 #else
36   /* Assumption: ELF_ARCH == EM_PPC and ELF_CLASS == ELFCLASS32 */
37   typedef elf_greg_t32 elf_greg_t;
38   typedef elf_gregset_t32 elf_gregset_t;
39 # define elf_addr_t u32
40 # define elf_caddr_t u32
41 #endif
42
43 typedef double elf_fpreg_t;
44 typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
45
46 #ifdef __KERNEL__
47
48 /*
49  * This is used to ensure we don't load something for the wrong architecture.
50  */
51 #define elf_check_arch(x) ((x)->e_machine == ELF_ARCH)
52
53 #define USE_ELF_CORE_DUMP
54 #define ELF_EXEC_PAGESIZE       4096
55
56 /* This is the location that an ET_DYN program is loaded if exec'ed.  Typical
57    use of this is to invoke "./ld.so someprog" to test out a new version of
58    the loader.  We need to make sure that it is out of the way of the program
59    that it will "exec", and that there is sufficient room for the brk.  */
60
61 #define ELF_ET_DYN_BASE         (0x08000000)
62
63 /* Common routine for both 32-bit and 64-bit processes */
64 #define ELF_CORE_COPY_REGS(gregs, regs) elf_core_copy_regs(gregs, regs);
65 static inline void
66 elf_core_copy_regs(elf_gregset_t dstRegs, struct pt_regs* srcRegs)
67 {
68         int i;
69
70         int numGPRS = ((sizeof(struct pt_regs)/sizeof(elf_greg_t64)) < ELF_NGREG) ? (sizeof(struct pt_regs)/sizeof(elf_greg_t64)) : ELF_NGREG;
71
72         for (i=0; i < numGPRS; i++)
73                 dstRegs[i] = (elf_greg_t)((elf_greg_t64 *)srcRegs)[i];
74 }
75
76 /* This yields a mask that user programs can use to figure out what
77    instruction set this cpu supports.  This could be done in userspace,
78    but it's not easy, and we've already done it here.  */
79
80 #define ELF_HWCAP       (0)
81
82 /* This yields a string that ld.so will use to load implementation
83    specific libraries for optimization.  This is more specific in
84    intent than poking at uname or /proc/cpuinfo.
85
86    For the moment, we have only optimizations for the Intel generations,
87    but that could change... */
88
89 #define ELF_PLATFORM    (NULL)
90
91
92 #define ELF_PLAT_INIT(_r, interp_load_addr)     do { \
93         memset(_r->gpr, 0, sizeof(_r->gpr)); \
94         _r->ctr = _r->link = _r->xer = _r->ccr = 0; \
95         _r->gpr[2] = interp_load_addr; \
96 } while (0)
97
98
99
100 #define SET_PERSONALITY(ex, ibcs2)                              \
101 do {    if ((ex).e_ident[EI_CLASS] == ELFCLASS32)               \
102                 current->thread.flags |= PPC_FLAG_32BIT;        \
103         else                                                    \
104                 current->thread.flags &= ~PPC_FLAG_32BIT;       \
105         if (ibcs2)                                              \
106                 set_personality(PER_SVR4);                      \
107         else if (current->personality != PER_LINUX32)           \
108                 set_personality(PER_LINUX);                     \
109 } while (0)
110
111 /*
112  * We need to put in some extra aux table entries to tell glibc what
113  * the cache block size is, so it can use the dcbz instruction safely.
114  */
115 #define AT_DCACHEBSIZE          19
116 #define AT_ICACHEBSIZE          20
117 #define AT_UCACHEBSIZE          21
118 /* A special ignored type value for PPC, for glibc compatibility.  */
119 #define AT_IGNOREPPC            22
120
121 extern int dcache_bsize;
122 extern int icache_bsize;
123 extern int ucache_bsize;
124
125 /*
126  * The requirements here are:
127  * - keep the final alignment of sp (sp & 0xf)
128  * - make sure the 32-bit value at the first 16 byte aligned position of
129  *   AUXV is greater than 16 for glibc compatibility.
130  *   AT_IGNOREPPC is used for that.
131  * - for compatibility with glibc ARCH_DLINFO must always be defined on PPC,
132  *   even if DLINFO_ARCH_ITEMS goes to zero or is undefined.
133  */
134 #define DLINFO_ARCH_ITEMS       3
135 #define ARCH_DLINFO                                                     \
136 do {                                                                    \
137         sp -= DLINFO_ARCH_ITEMS * 2;                                    \
138         NEW_AUX_ENT(0, AT_DCACHEBSIZE, dcache_bsize);                   \
139         NEW_AUX_ENT(1, AT_ICACHEBSIZE, icache_bsize);                   \
140         NEW_AUX_ENT(2, AT_UCACHEBSIZE, ucache_bsize);                   \
141         /*                                                              \
142          * Now handle glibc compatibility.                              \
143          */                                                             \
144         sp -= 2*2;                                                      \
145         NEW_AUX_ENT(0, AT_IGNOREPPC, AT_IGNOREPPC);                     \
146         NEW_AUX_ENT(1, AT_IGNOREPPC, AT_IGNOREPPC);                     \
147  } while (0)
148
149 #endif /* __KERNEL__ */
150 #endif /* __PPC64_ELF_H */