2 * binfmt_elf32.c: Support 32-bit Sparc ELF binaries on Ultra.
4 * Copyright (C) 1995, 1996, 1997, 1998 David S. Miller (davem@redhat.com)
5 * Copyright (C) 1995, 1996, 1997, 1998 Jakub Jelinek (jj@ultra.linux.cz)
8 #define ELF_ARCH EM_SPARC
9 #define ELF_CLASS ELFCLASS32
10 #define ELF_DATA ELFDATA2MSB;
12 /* For the most part we present code dumps in the format
15 typedef unsigned int elf_greg_t;
17 typedef elf_greg_t elf_gregset_t[ELF_NGREG];
24 * PSR, PC, nPC, Y, WIM, TBR
26 #include <asm/psrcompat.h>
27 #define ELF_CORE_COPY_REGS(__elf_regs, __pt_regs) \
28 do { unsigned int *dest = &(__elf_regs[0]); \
29 struct pt_regs *src = (__pt_regs); \
30 unsigned int __user *sp; \
32 for(i = 0; i < 16; i++) \
33 dest[i] = (unsigned int) src->u_regs[i];\
34 /* Don't try this at home kids... */ \
35 sp = (unsigned int __user *) (src->u_regs[14] & \
36 0x00000000fffffffc); \
37 for(i = 0; i < 16; i++) \
38 __get_user(dest[i+16], &sp[i]); \
39 dest[32] = tstate_to_psr(src->tstate); \
40 dest[33] = (unsigned int) src->tpc; \
41 dest[34] = (unsigned int) src->tnpc; \
43 dest[36] = dest[37] = 0; /* XXX */ \
48 unsigned int pr_regs[32];
49 unsigned long pr_dregs[16];
51 unsigned int __unused;
53 unsigned char pr_qcnt;
54 unsigned char pr_q_entrysize;
56 unsigned int pr_q[64];
59 /* UltraSparc extensions. Still unused, but will be eventually. */
62 unsigned int pr_align;
66 unsigned int pr_regs[32];
67 unsigned long pr_dregs[16];
68 long double pr_qregs[8];
73 unsigned int pr_xg[8];
74 unsigned int pr_xo[8];
75 unsigned long pr_tstate;
76 unsigned int pr_filler[8];
80 #define elf_check_arch(x) (((x)->e_machine == EM_SPARC) || ((x)->e_machine == EM_SPARC32PLUS))
82 #define ELF_ET_DYN_BASE 0x70000000
85 #include <asm/processor.h>
86 #include <linux/module.h>
87 #include <linux/elfcore.h>
88 #include <linux/compat.h>
90 #define elf_prstatus elf_prstatus32
93 struct elf_siginfo pr_info; /* Info associated with signal */
94 short pr_cursig; /* Current signal */
95 unsigned int pr_sigpend; /* Set of pending signals */
96 unsigned int pr_sighold; /* Set of held signals */
101 struct compat_timeval pr_utime; /* User time */
102 struct compat_timeval pr_stime; /* System time */
103 struct compat_timeval pr_cutime; /* Cumulative user time */
104 struct compat_timeval pr_cstime; /* Cumulative system time */
105 elf_gregset_t pr_reg; /* GP registers */
106 int pr_fpvalid; /* True if math co-processor being used. */
109 #define elf_prpsinfo elf_prpsinfo32
110 struct elf_prpsinfo32
112 char pr_state; /* numeric process state */
113 char pr_sname; /* char for pr_state */
114 char pr_zomb; /* zombie */
115 char pr_nice; /* nice val */
116 unsigned int pr_flag; /* flags */
119 pid_t pr_pid, pr_ppid, pr_pgrp, pr_sid;
121 char pr_fname[16]; /* filename of executable */
122 char pr_psargs[ELF_PRARGSZ]; /* initial part of arg list */
125 #include <linux/highuid.h>
127 #undef NEW_TO_OLD_UID
128 #undef NEW_TO_OLD_GID
129 #define NEW_TO_OLD_UID(uid) ((uid) > 65535) ? (u16)overflowuid : (u16)(uid)
130 #define NEW_TO_OLD_GID(gid) ((gid) > 65535) ? (u16)overflowgid : (u16)(gid)
132 #include <linux/time.h>
134 #undef cputime_to_timeval
135 #define cputime_to_timeval cputime_to_compat_timeval
136 static __inline__ void
137 cputime_to_compat_timeval(const cputime_t cputime, struct compat_timeval *value)
139 unsigned long jiffies = cputime_to_jiffies(cputime);
140 value->tv_usec = (jiffies % HZ) * (1000000L / HZ);
141 value->tv_sec = jiffies / HZ;
144 #define elf_addr_t u32
146 #define start_thread start_thread32
147 #define init_elf_binfmt init_elf32_binfmt
149 MODULE_DESCRIPTION("Binary format loader for compatibility with 32bit SparcLinux binaries on the Ultra");
150 MODULE_AUTHOR("Eric Youngdale, David S. Miller, Jakub Jelinek");
152 #undef MODULE_DESCRIPTION
155 #include <asm/a.out.h>
158 #define TASK_SIZE STACK_TOP32
160 #include "../../../fs/binfmt_elf.c"