Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * IA-32 ELF core dump support. |
| 3 | * |
| 4 | * Copyright (C) 2003 Arun Sharma <arun.sharma@intel.com> |
| 5 | * |
| 6 | * Derived from the x86_64 version |
| 7 | */ |
| 8 | #ifndef _ELFCORE32_H_ |
| 9 | #define _ELFCORE32_H_ |
| 10 | |
| 11 | #include <asm/intrinsics.h> |
| 12 | #include <asm/uaccess.h> |
| 13 | |
| 14 | #define USE_ELF_CORE_DUMP 1 |
| 15 | |
| 16 | /* Override elfcore.h */ |
| 17 | #define _LINUX_ELFCORE_H 1 |
| 18 | typedef unsigned int elf_greg_t; |
| 19 | |
| 20 | #define ELF_NGREG (sizeof (struct user_regs_struct32) / sizeof(elf_greg_t)) |
| 21 | typedef elf_greg_t elf_gregset_t[ELF_NGREG]; |
| 22 | |
| 23 | typedef struct ia32_user_i387_struct elf_fpregset_t; |
| 24 | typedef struct ia32_user_fxsr_struct elf_fpxregset_t; |
| 25 | |
| 26 | struct elf_siginfo |
| 27 | { |
| 28 | int si_signo; /* signal number */ |
| 29 | int si_code; /* extra code */ |
| 30 | int si_errno; /* errno */ |
| 31 | }; |
| 32 | |
| 33 | #define jiffies_to_timeval(a,b) do { (b)->tv_usec = 0; (b)->tv_sec = (a)/HZ; }while(0) |
| 34 | |
| 35 | struct elf_prstatus |
| 36 | { |
| 37 | struct elf_siginfo pr_info; /* Info associated with signal */ |
| 38 | short pr_cursig; /* Current signal */ |
| 39 | unsigned int pr_sigpend; /* Set of pending signals */ |
| 40 | unsigned int pr_sighold; /* Set of held signals */ |
| 41 | pid_t pr_pid; |
| 42 | pid_t pr_ppid; |
| 43 | pid_t pr_pgrp; |
| 44 | pid_t pr_sid; |
| 45 | struct compat_timeval pr_utime; /* User time */ |
| 46 | struct compat_timeval pr_stime; /* System time */ |
| 47 | struct compat_timeval pr_cutime; /* Cumulative user time */ |
| 48 | struct compat_timeval pr_cstime; /* Cumulative system time */ |
| 49 | elf_gregset_t pr_reg; /* GP registers */ |
| 50 | int pr_fpvalid; /* True if math co-processor being used. */ |
| 51 | }; |
| 52 | |
| 53 | #define ELF_PRARGSZ (80) /* Number of chars for args */ |
| 54 | |
| 55 | struct elf_prpsinfo |
| 56 | { |
| 57 | char pr_state; /* numeric process state */ |
| 58 | char pr_sname; /* char for pr_state */ |
| 59 | char pr_zomb; /* zombie */ |
| 60 | char pr_nice; /* nice val */ |
| 61 | unsigned int pr_flag; /* flags */ |
| 62 | __u16 pr_uid; |
| 63 | __u16 pr_gid; |
| 64 | pid_t pr_pid, pr_ppid, pr_pgrp, pr_sid; |
| 65 | /* Lots missing */ |
| 66 | char pr_fname[16]; /* filename of executable */ |
| 67 | char pr_psargs[ELF_PRARGSZ]; /* initial part of arg list */ |
| 68 | }; |
| 69 | |
| 70 | #define ELF_CORE_COPY_REGS(pr_reg, regs) \ |
| 71 | pr_reg[0] = regs->r11; \ |
| 72 | pr_reg[1] = regs->r9; \ |
| 73 | pr_reg[2] = regs->r10; \ |
| 74 | pr_reg[3] = regs->r14; \ |
| 75 | pr_reg[4] = regs->r15; \ |
| 76 | pr_reg[5] = regs->r13; \ |
| 77 | pr_reg[6] = regs->r8; \ |
| 78 | pr_reg[7] = regs->r16 & 0xffff; \ |
| 79 | pr_reg[8] = (regs->r16 >> 16) & 0xffff; \ |
| 80 | pr_reg[9] = (regs->r16 >> 32) & 0xffff; \ |
| 81 | pr_reg[10] = (regs->r16 >> 48) & 0xffff; \ |
| 82 | pr_reg[11] = regs->r1; \ |
| 83 | pr_reg[12] = regs->cr_iip; \ |
| 84 | pr_reg[13] = regs->r17 & 0xffff; \ |
| 85 | pr_reg[14] = ia64_getreg(_IA64_REG_AR_EFLAG); \ |
| 86 | pr_reg[15] = regs->r12; \ |
| 87 | pr_reg[16] = (regs->r17 >> 16) & 0xffff; |
| 88 | |
| 89 | static inline void elf_core_copy_regs(elf_gregset_t *elfregs, |
| 90 | struct pt_regs *regs) |
| 91 | { |
| 92 | ELF_CORE_COPY_REGS((*elfregs), regs) |
| 93 | } |
| 94 | |
| 95 | static inline int elf_core_copy_task_regs(struct task_struct *t, |
| 96 | elf_gregset_t* elfregs) |
| 97 | { |
Al Viro | 6450578 | 2006-01-12 01:06:06 -0800 | [diff] [blame] | 98 | ELF_CORE_COPY_REGS((*elfregs), task_pt_regs(t)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 99 | return 1; |
| 100 | } |
| 101 | |
| 102 | static inline int |
| 103 | elf_core_copy_task_fpregs(struct task_struct *tsk, struct pt_regs *regs, elf_fpregset_t *fpu) |
| 104 | { |
| 105 | struct ia32_user_i387_struct *fpstate = (void*)fpu; |
| 106 | mm_segment_t old_fs; |
| 107 | |
| 108 | if (!tsk_used_math(tsk)) |
| 109 | return 0; |
| 110 | |
| 111 | old_fs = get_fs(); |
| 112 | set_fs(KERNEL_DS); |
| 113 | save_ia32_fpstate(tsk, (struct ia32_user_i387_struct __user *) fpstate); |
| 114 | set_fs(old_fs); |
| 115 | |
| 116 | return 1; |
| 117 | } |
| 118 | |
| 119 | #define ELF_CORE_COPY_XFPREGS 1 |
| 120 | static inline int |
| 121 | elf_core_copy_task_xfpregs(struct task_struct *tsk, elf_fpxregset_t *xfpu) |
| 122 | { |
| 123 | struct ia32_user_fxsr_struct *fpxstate = (void*) xfpu; |
| 124 | mm_segment_t old_fs; |
| 125 | |
| 126 | if (!tsk_used_math(tsk)) |
| 127 | return 0; |
| 128 | |
| 129 | old_fs = get_fs(); |
| 130 | set_fs(KERNEL_DS); |
| 131 | save_ia32_fpxstate(tsk, (struct ia32_user_fxsr_struct __user *) fpxstate); |
| 132 | set_fs(old_fs); |
| 133 | |
| 134 | return 1; |
| 135 | } |
| 136 | |
| 137 | #endif /* _ELFCORE32_H_ */ |