This source file includes following definitions.
- exec_hpux_makecmds
- exec_hpux_som_nmagic
- exec_hpux_som_zmagic
- exec_hpux_som_omagic
- hpux_sys_execv
- hpux_sys_execve
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38 #include <sys/param.h>
39 #include <sys/systm.h>
40 #include <sys/kernel.h>
41 #include <sys/proc.h>
42 #include <sys/malloc.h>
43 #include <sys/mount.h>
44 #include <sys/namei.h>
45 #include <sys/user.h>
46 #include <sys/vnode.h>
47 #include <sys/mman.h>
48 #include <sys/stat.h>
49
50 #include <uvm/uvm_extern.h>
51
52 #include <machine/cpu.h>
53 #include <machine/reg.h>
54
55 #include <sys/syscallargs.h>
56
57 #include <compat/hpux/hpux.h>
58 #include <compat/hpux/hpux_util.h>
59 #include <compat/hpux/hppa/hpux_syscall.h>
60 #include <compat/hpux/hppa/hpux_syscallargs.h>
61
62 #include <machine/hpux_machdep.h>
63
64 const char hpux_emul_path[] = "/emul/hpux";
65 extern char hpux_sigcode[], hpux_esigcode[];
66 extern struct sysent hpux_sysent[];
67 #ifdef SYSCALL_DEBUG
68 extern char *hpux_syscallnames[];
69 #endif
70 extern int bsdtohpuxerrnomap[];
71
72 int exec_hpux_som_nmagic(struct proc *, struct exec_package *);
73 int exec_hpux_som_zmagic(struct proc *, struct exec_package *);
74 int exec_hpux_som_omagic(struct proc *, struct exec_package *);
75
76 struct emul emul_hpux = {
77 "hpux",
78 bsdtohpuxerrnomap,
79 hpux_sendsig,
80 HPUX_SYS_syscall,
81 HPUX_SYS_MAXSYSCALL,
82 hpux_sysent,
83 #ifdef SYSCALL_DEBUG
84 hpux_syscallnames,
85 #else
86 NULL,
87 #endif
88 0,
89 copyargs,
90 hpux_setregs,
91 NULL,
92 hpux_sigcode,
93 hpux_esigcode,
94 };
95
96 int
97 exec_hpux_makecmds(p, epp)
98 struct proc *p;
99 struct exec_package *epp;
100 {
101 struct som_exec *som_ep = epp->ep_hdr;
102 short sysid, magic;
103 int error = ENOEXEC;
104
105 sysid = HPUX_SYSID(som_ep);
106 if (sysid != MID_HPUX800 && sysid != MID_HPPA11 && sysid != MID_HPPA20)
107 return (error);
108
109
110 if (sysid != MID_HPUX && (!(som_ep->som_version == HPUX_SOM_V0 ||
111 som_ep->som_version == HPUX_SOM_V1) ||
112 som_ep->som_auxhdr + sizeof(struct som_aux) > epp->ep_hdrvalid)) {
113 return (error);
114 }
115
116
117
118
119
120 if (PAGE_SIZE != HPUX_LDPGSZ)
121 return (error);
122
123 magic = HPUX_MAGIC(som_ep);
124 switch (magic) {
125 case OMAGIC:
126 error = exec_hpux_som_omagic(p, epp);
127 break;
128
129 case NMAGIC:
130 error = exec_hpux_som_nmagic(p, epp);
131 break;
132
133 case ZMAGIC:
134 error = exec_hpux_som_zmagic(p, epp);
135 break;
136 }
137
138 if (error == 0) {
139
140 epp->ep_emul = &emul_hpux;
141 } else
142 kill_vmcmds(&epp->ep_vmcmds);
143
144 return (error);
145 }
146
147 int
148 exec_hpux_som_nmagic(struct proc *p, struct exec_package *epp)
149 {
150 struct som_exec *execp = epp->ep_hdr;
151 struct som_aux *auxp = epp->ep_hdr + execp->som_auxhdr;
152
153 epp->ep_taddr = auxp->som_tmem;
154 epp->ep_tsize = auxp->som_tsize;
155 epp->ep_daddr = auxp->som_dmem;
156 epp->ep_dsize = auxp->som_dsize + auxp->som_bsize;
157 epp->ep_entry = auxp->som_entry;
158
159
160 NEW_VMCMD(&epp->ep_vmcmds, vmcmd_map_readvn, epp->ep_tsize,
161 epp->ep_taddr, epp->ep_vp, auxp->som_tfile,
162 VM_PROT_READ|VM_PROT_EXECUTE);
163
164
165 NEW_VMCMD(&epp->ep_vmcmds, vmcmd_map_readvn, auxp->som_dsize,
166 epp->ep_daddr, epp->ep_vp, auxp->som_dfile,
167 VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE);
168
169
170 if (auxp->som_bsize > 0)
171 NEW_VMCMD(&epp->ep_vmcmds, vmcmd_map_zero, auxp->som_bsize,
172 epp->ep_daddr + auxp->som_dsize,
173 NULLVP, 0, VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE);
174
175 return (exec_setup_stack(p, epp));
176 }
177
178 int
179 exec_hpux_som_zmagic(struct proc *p, struct exec_package *epp)
180 {
181
182 return (exec_setup_stack(p, epp));
183 }
184
185 int
186 exec_hpux_som_omagic(struct proc *p, struct exec_package *epp)
187 {
188
189 return (exec_setup_stack(p, epp));
190 }
191
192
193
194
195
196
197
198 int
199 hpux_sys_execv(p, v, retval)
200 struct proc *p;
201 void *v;
202 register_t *retval;
203 {
204 struct hpux_sys_execv_args
205
206
207 *uap = v;
208 struct sys_execve_args ap;
209 caddr_t sg;
210
211 sg = stackgap_init(p->p_emul);
212 HPUX_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
213
214 SCARG(&ap, path) = SCARG(uap, path);
215 SCARG(&ap, argp) = SCARG(uap, argp);
216 SCARG(&ap, envp) = NULL;
217
218 return sys_execve(p, &ap, retval);
219 }
220
221 int
222 hpux_sys_execve(p, v, retval)
223 struct proc *p;
224 void *v;
225 register_t *retval;
226 {
227 struct hpux_sys_execve_args
228
229
230
231 *uap = v;
232 struct sys_execve_args ap;
233 caddr_t sg;
234
235 sg = stackgap_init(p->p_emul);
236 HPUX_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
237
238 SCARG(&ap, path) = SCARG(uap, path);
239 SCARG(&ap, argp) = SCARG(uap, argp);
240 SCARG(&ap, envp) = SCARG(uap, envp);
241
242 return (sys_execve(p, &ap, retval));
243 }