[POWERPC] coredump: Add SPU elf notes to coredump.
[safe/jmp/linux-2.6] / include / asm-powerpc / elf.h
index 36b9d5c..4545aa6 100644 (file)
@@ -1,11 +1,16 @@
 #ifndef _ASM_POWERPC_ELF_H
 #define _ASM_POWERPC_ELF_H
 
+#ifdef __KERNEL__
+#include <linux/sched.h>       /* for task_struct */
+#include <asm/page.h>
+#include <asm/string.h>
+#endif
+
 #include <asm/types.h>
 #include <asm/ptrace.h>
 #include <asm/cputable.h>
 #include <asm/auxvec.h>
-#include <asm/page.h>
 
 /* PowerPC relocations defined by the ABIs */
 #define R_PPC_NONE             0
@@ -87,7 +92,6 @@
  * as published by the Free Software Foundation; either version
  * 2 of the License, or (at your option) any later version.
  */
-#include <asm/ptrace.h>
 
 #define ELF_NGREG      48      /* includes nip, msr, lr, etc. */
 #define ELF_NFPREG     33      /* includes fpscr */
@@ -125,7 +129,7 @@ typedef elf_greg_t32 elf_gregset_t32[ELF_NGREG];
   /* Assumption: ELF_ARCH == EM_PPC and ELF_CLASS == ELFCLASS32 */
   typedef elf_greg_t32 elf_greg_t;
   typedef elf_gregset_t32 elf_gregset_t;
-# define elf_addr_t u32
+# define elf_addr_t __u32
 #endif /* ELF_ARCH */
 
 /* Floating point registers */
@@ -157,6 +161,7 @@ typedef elf_vrreg_t elf_vrregset_t[ELF_NVRREG];
 typedef elf_vrreg_t elf_vrregset_t32[ELF_NVRREG32];
 #endif
 
+#ifdef __KERNEL__
 /*
  * This is used to ensure we don't load something for the wrong architecture.
  */
@@ -172,24 +177,26 @@ typedef elf_vrreg_t elf_vrregset_t32[ELF_NVRREG32];
 
 #define ELF_ET_DYN_BASE         (0x08000000)
 
-#ifdef __KERNEL__
-
 /* Common routine for both 32-bit and 64-bit processes */
 static inline void ppc_elf_core_copy_regs(elf_gregset_t elf_regs,
                                            struct pt_regs *regs)
 {
-       int i;
-       int gprs = sizeof(struct pt_regs)/sizeof(ELF_GREG_TYPE);
-
-       if (gprs > ELF_NGREG)
-               gprs = ELF_NGREG;
+       int i, nregs;
 
-       for (i=0; i < gprs; i++)
-               elf_regs[i] = (elf_greg_t)((ELF_GREG_TYPE *)regs)[i];
+       memset((void *)elf_regs, 0, sizeof(elf_gregset_t));
 
-       memset((char *)(elf_regs) + sizeof(struct pt_regs), 0,          \
-              sizeof(elf_gregset_t) - sizeof(struct pt_regs));
+       /* Our registers are always unsigned longs, whether we're a 32 bit
+        * process or 64 bit, on either a 64 bit or 32 bit kernel.
+        * Don't use ELF_GREG_TYPE here. */
+       nregs = sizeof(struct pt_regs) / sizeof(unsigned long);
+       if (nregs > ELF_NGREG)
+               nregs = ELF_NGREG;
 
+       for (i = 0; i < nregs; i++) {
+               /* This will correctly truncate 64 bit registers to 32 bits
+                * for a 32 bit process on a 64 bit kernel. */
+               elf_regs[i] = (elf_greg_t)((ELF_GREG_TYPE *)regs)[i];
+       }
 }
 #define ELF_CORE_COPY_REGS(gregs, regs) ppc_elf_core_copy_regs(gregs, regs);
 
@@ -212,25 +219,19 @@ extern int dump_task_fpu(struct task_struct *, elf_fpregset_t *);
 /* ELF_HWCAP yields a mask that user programs can use to figure out what
    instruction set this cpu supports.  This could be done in userspace,
    but it's not easy, and we've already done it here.  */
-#ifdef __powerpc64__
 # define ELF_HWCAP     (cur_cpu_spec->cpu_user_features)
-# define ELF_PLAT_INIT(_r, load_addr)  do { \
-       memset(_r->gpr, 0, sizeof(_r->gpr)); \
-       _r->ctr = _r->link = _r->xer = _r->ccr = 0; \
-       _r->gpr[2] = load_addr; \
-} while (0)
-#else
-# define ELF_HWCAP     (cur_cpu_spec[0]->cpu_user_features)
-#endif /* __powerpc64__ */
 
 /* This yields a string that ld.so will use to load implementation
    specific libraries for optimization.  This is more specific in
-   intent than poking at uname or /proc/cpuinfo.
+   intent than poking at uname or /proc/cpuinfo.  */
 
-   For the moment, we have only optimizations for the Intel generations,
-   but that could change... */
+#define ELF_PLATFORM   (cur_cpu_spec->platform)
 
-#define ELF_PLATFORM   (NULL)
+#ifdef __powerpc64__
+# define ELF_PLAT_INIT(_r, load_addr)  do {    \
+       _r->gpr[2] = load_addr;                 \
+} while (0)
+#endif /* __powerpc64__ */
 
 #ifdef __KERNEL__
 
@@ -267,14 +268,12 @@ extern int dcache_bsize;
 extern int icache_bsize;
 extern int ucache_bsize;
 
-#ifdef __powerpc64__
+/* vDSO has arch_setup_additional_pages */
+#define ARCH_HAS_SETUP_ADDITIONAL_PAGES
 struct linux_binprm;
-#define ARCH_HAS_SETUP_ADDITIONAL_PAGES        /* vDSO has arch_setup_additional_pages */
-extern int arch_setup_additional_pages(struct linux_binprm *bprm, int executable_stack);
+extern int arch_setup_additional_pages(struct linux_binprm *bprm,
+                                      int executable_stack);
 #define VDSO_AUX_ENT(a,b) NEW_AUX_ENT(a,b);
-#else
-#define VDSO_AUX_ENT(a,b)
-#endif /* __powerpc64__ */
 
 /*
  * The requirements here are:
@@ -294,7 +293,7 @@ do {                                                                        \
        NEW_AUX_ENT(AT_DCACHEBSIZE, dcache_bsize);                      \
        NEW_AUX_ENT(AT_ICACHEBSIZE, icache_bsize);                      \
        NEW_AUX_ENT(AT_UCACHEBSIZE, ucache_bsize);                      \
-       VDSO_AUX_ENT(AT_SYSINFO_EHDR, current->thread.vdso_base)        \
+       VDSO_AUX_ENT(AT_SYSINFO_EHDR, current->mm->context.vdso_base)   \
 } while (0)
 
 /* PowerPC64 relocations defined by the ABIs */
@@ -412,4 +411,17 @@ do {                                                                       \
 /* Keep this the last entry.  */
 #define R_PPC64_NUM            107
 
+#ifdef CONFIG_PPC_CELL
+/* Notes used in ET_CORE. Note name is "SPU/<fd>/<filename>". */
+#define NT_SPU         1
+
+extern int arch_notes_size(void);
+extern void arch_write_notes(struct file *file);
+
+#define ELF_CORE_EXTRA_NOTES_SIZE arch_notes_size()
+#define ELF_CORE_WRITE_EXTRA_NOTES arch_write_notes(file)
+
+#define ARCH_HAVE_EXTRA_ELF_NOTES
+#endif /* CONFIG_PPC_CELL */
+
 #endif /* _ASM_POWERPC_ELF_H */