1 /*	$NetBSD: svr4_machdep.c,v 1.71 2009/12/10 14:13:52 matt Exp $	 */
2 
3 /*-
4  * Copyright (c) 1994 The NetBSD Foundation, Inc.
5  * All rights reserved.
6  *
7  * This code is derived from software contributed to The NetBSD Foundation
8  * by Christos Zoulas.
9  *
10  * Redistribution and use in source and binary forms, with or without
11  * modification, are permitted provided that the following conditions
12  * are met:
13  * 1. Redistributions of source code must retain the above copyright
14  *    notice, this list of conditions and the following disclaimer.
15  * 2. Redistributions in binary form must reproduce the above copyright
16  *    notice, this list of conditions and the following disclaimer in the
17  *    documentation and/or other materials provided with the distribution.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29  * POSSIBILITY OF SUCH DAMAGE.
30  */
31 
32 #include <sys/cdefs.h>
33 __KERNEL_RCSID(0, "$NetBSD: svr4_machdep.c,v 1.71 2009/12/10 14:13:52 matt Exp $");
34 
35 #if defined(_KERNEL_OPT)
36 #include "opt_kgdb.h"
37 #endif
38 
39 #include <sys/param.h>
40 #include <sys/systm.h>
41 #include <sys/namei.h>
42 #include <sys/proc.h>
43 #include <sys/exec.h>
44 #include <sys/filedesc.h>
45 #include <sys/ioctl.h>
46 #include <sys/kernel.h>
47 #include <sys/signal.h>
48 #include <sys/signalvar.h>
49 #include <sys/malloc.h>
50 #include <sys/mount.h>
51 #include <sys/syscallargs.h>
52 #include <sys/exec_elf.h>
53 
54 #include <compat/svr4/svr4_types.h>
55 #include <compat/svr4/svr4_lwp.h>
56 #include <compat/svr4/svr4_ucontext.h>
57 #include <compat/svr4/svr4_syscallargs.h>
58 #include <compat/svr4/svr4_util.h>
59 #include <compat/svr4/svr4_exec.h>
60 
61 #include <machine/cpu.h>
62 #include <machine/psl.h>
63 #include <machine/reg.h>
64 #include <machine/trap.h>
65 #include <machine/vmparam.h>
66 #include <machine/svr4_machdep.h>
67 
68 static void svr4_getsiginfo(union svr4_siginfo *, int, u_long, void *);
69 
70 void
svr4_setregs(struct lwp * l,struct exec_package * epp,vaddr_t stack)71 svr4_setregs(struct lwp *l, struct exec_package *epp, vaddr_t stack)
72 {
73 
74 	setregs(l, epp, stack);
75 }
76 
77 #ifdef DEBUG
78 extern int sigdebug;
79 extern int sigpid;
80 #define SDB_FOLLOW	0x01	/* XXX: dup from machdep.c */
81 #define SDB_KSTACK	0x02
82 #define SDB_FPSTATE	0x04
83 #endif
84 
85 #ifdef DEBUG_SVR4
86 static void svr4_printmcontext(const char *, struct svr4_mcontext *);
87 
88 static void
svr4_printmcontext(const char * fun,struct svr4_mcontext * mc)89 svr4_printmcontext(const char *fun, struct svr4_mcontext *mc)
90 {
91 	svr4_greg_t *r = mc->greg;
92 
93 	printf("%s at %p\n", fun, mc);
94 
95 	printf("Regs: ");
96 	printf("PSR = 0x%x ", r[SVR4_SPARC_PSR]);
97 	printf("PC = 0x%x ",  r[SVR4_SPARC_PC]);
98 	printf("nPC = 0x%x ", r[SVR4_SPARC_nPC]);
99 	printf("Y = 0x%x ",   r[SVR4_SPARC_Y]);
100 	printf("G1 = 0x%x ",  r[SVR4_SPARC_G1]);
101 	printf("G2 = 0x%x ",  r[SVR4_SPARC_G2]);
102 	printf("G3 = 0x%x ",  r[SVR4_SPARC_G3]);
103 	printf("G4 = 0x%x ",  r[SVR4_SPARC_G4]);
104 	printf("G5 = 0x%x ",  r[SVR4_SPARC_G5]);
105 	printf("G6 = 0x%x ",  r[SVR4_SPARC_G6]);
106 	printf("G7 = 0x%x ",  r[SVR4_SPARC_G7]);
107 	printf("O0 = 0x%x ",  r[SVR4_SPARC_O0]);
108 	printf("O1 = 0x%x ",  r[SVR4_SPARC_O1]);
109 	printf("O2 = 0x%x ",  r[SVR4_SPARC_O2]);
110 	printf("O3 = 0x%x ",  r[SVR4_SPARC_O3]);
111 	printf("O4 = 0x%x ",  r[SVR4_SPARC_O4]);
112 	printf("O5 = 0x%x ",  r[SVR4_SPARC_O5]);
113 	printf("O6 = 0x%x ",  r[SVR4_SPARC_O6]);
114 	printf("O7 = 0x%x ",  r[SVR4_SPARC_O7]);
115 	printf("\n");
116 }
117 #endif
118 
119 void *
svr4_getmcontext(struct lwp * l,struct svr4_mcontext * mc,u_long * flags)120 svr4_getmcontext(struct lwp *l, struct svr4_mcontext *mc, u_long *flags)
121 {
122 	struct trapframe *tf = (struct trapframe *)l->l_md.md_tf;
123 	svr4_greg_t *r = mc->greg;
124 #ifdef FPU_CONTEXT
125 	svr4_fregset_t *f = &mc->freg;
126 	struct fpstate *fps = l->l_md.md_fpstate;
127 #endif
128 
129 	write_user_windows();
130 	if (rwindow_save(l)) {
131 		mutex_enter(l->l_proc->p_lock);
132 		sigexit(l, SIGILL);
133 	}
134 
135 	/*
136 	 * Get the general purpose registers
137 	 */
138 	r[SVR4_SPARC_PSR] = tf->tf_psr;
139 	r[SVR4_SPARC_PC] = tf->tf_pc;
140 	r[SVR4_SPARC_nPC] = tf->tf_npc;
141 	r[SVR4_SPARC_Y] = tf->tf_y;
142 	r[SVR4_SPARC_G1] = tf->tf_global[1];
143 	r[SVR4_SPARC_G2] = tf->tf_global[2];
144 	r[SVR4_SPARC_G3] = tf->tf_global[3];
145 	r[SVR4_SPARC_G4] = tf->tf_global[4];
146 	r[SVR4_SPARC_G5] = tf->tf_global[5];
147 	r[SVR4_SPARC_G6] = tf->tf_global[6];
148 	r[SVR4_SPARC_G7] = tf->tf_global[7];
149 	r[SVR4_SPARC_O0] = tf->tf_out[0];
150 	r[SVR4_SPARC_O1] = tf->tf_out[1];
151 	r[SVR4_SPARC_O2] = tf->tf_out[2];
152 	r[SVR4_SPARC_O3] = tf->tf_out[3];
153 	r[SVR4_SPARC_O4] = tf->tf_out[4];
154 	r[SVR4_SPARC_O5] = tf->tf_out[5];
155 	r[SVR4_SPARC_O6] = tf->tf_out[6];
156 	r[SVR4_SPARC_O7] = tf->tf_out[7];
157 
158 	*flags |= SVR4_UC_CPU;
159 
160 #ifdef FPU_CONTEXT
161 	/*
162 	 * Get the floating point registers
163 	 */
164 	memcpy(f->fpu_regs, fps->fs_regs, sizeof(fps->fs_regs));
165 	f->fp_nqsize = sizeof(struct fp_qentry);
166 	f->fp_nqel = fps->fs_qsize;
167 	f->fp_fsr = fps->fs_fsr;
168 	if (f->fp_q != NULL) {
169 		size_t sz = f->fp_nqel * f->fp_nqsize;
170 		if (sz > sizeof(fps->fs_queue)) {
171 #ifdef DIAGNOSTIC
172 			printf("getcontext: fp_queue too large\n");
173 #endif
174 			return;
175 		}
176 		if (copyout(fps->fs_queue, f->fp_q, sz) != 0) {
177 #ifdef DIAGNOSTIC
178 			printf("getcontext: copy of fp_queue failed %d\n",
179 			    error);
180 #endif
181 			return;
182 		}
183 	}
184 	f->fp_busy = 0;	/* XXX: How do we determine that? */
185 	*flags |= SVR4_UC_FPU;
186 #endif
187 
188 
189 #ifdef DEBUG_SVR4
190 	svr4_printmcontext("getmcontext", mc);
191 #endif
192 	return (void *)tf->tf_out[6];
193 }
194 
195 
196 /*
197  * Set to mcontext specified.
198  * Return to previous pc and psl as specified by
199  * context left by sendsig. Check carefully to
200  * make sure that the user has not modified the
201  * psl to gain improper privileges or to cause
202  * a machine fault.
203  * This is almost like sigreturn() and it shows.
204  */
205 int
svr4_setmcontext(struct lwp * l,struct svr4_mcontext * mc,u_long flags)206 svr4_setmcontext(struct lwp *l, struct svr4_mcontext *mc, u_long flags)
207 {
208 	register struct trapframe *tf;
209 	svr4_greg_t *r = mc->greg;
210 #ifdef FPU_CONTEXT
211 	svr4_fregset_t *f = &mc->freg;
212 	struct fpstate *fps = l->l_md.md_fpstate;
213 #endif
214 
215 #ifdef DEBUG_SVR4
216 	svr4_printmcontext("setmcontext", mc);
217 #endif
218 
219 	write_user_windows();
220 	if (rwindow_save(l)) {
221 		mutex_enter(l->l_proc->p_lock);
222 		sigexit(l, SIGILL);
223 	}
224 
225 #ifdef DEBUG
226 	if (sigdebug & SDB_FOLLOW)
227 		printf("svr4_setmcontext: %s[%d], svr4_mcontext %p\n",
228 		    l->l_proc->p_comm, l->l_proc->p_pid, mc);
229 #endif
230 
231 	if (flags & SVR4_UC_CPU) {
232 		/* Restore register context. */
233 		tf = (struct trapframe *)l->l_md.md_tf;
234 
235 		/*
236 		 * Only the icc bits in the psr are used, so it need not be
237 		 * verified.  pc and npc must be multiples of 4.  This is all
238 		 * that is required; if it holds, just do it.
239 		 */
240 		if (((r[SVR4_SPARC_PC] | r[SVR4_SPARC_nPC]) & 3) != 0) {
241 			printf("pc or npc are not multiples of 4!\n");
242 			return EINVAL;
243 		}
244 
245 		/* take only psr ICC field */
246 		tf->tf_psr = (tf->tf_psr & ~PSR_ICC) |
247 		    (r[SVR4_SPARC_PSR] & PSR_ICC);
248 		tf->tf_pc = r[SVR4_SPARC_PC];
249 		tf->tf_npc = r[SVR4_SPARC_nPC];
250 		tf->tf_y = r[SVR4_SPARC_Y];
251 
252 		/* Restore everything */
253 		tf->tf_global[1] = r[SVR4_SPARC_G1];
254 		tf->tf_global[2] = r[SVR4_SPARC_G2];
255 		tf->tf_global[3] = r[SVR4_SPARC_G3];
256 		tf->tf_global[4] = r[SVR4_SPARC_G4];
257 		tf->tf_global[5] = r[SVR4_SPARC_G5];
258 		tf->tf_global[6] = r[SVR4_SPARC_G6];
259 		tf->tf_global[7] = r[SVR4_SPARC_G7];
260 
261 		tf->tf_out[0] = r[SVR4_SPARC_O0];
262 		tf->tf_out[1] = r[SVR4_SPARC_O1];
263 		tf->tf_out[2] = r[SVR4_SPARC_O2];
264 		tf->tf_out[3] = r[SVR4_SPARC_O3];
265 		tf->tf_out[4] = r[SVR4_SPARC_O4];
266 		tf->tf_out[5] = r[SVR4_SPARC_O5];
267 		tf->tf_out[6] = r[SVR4_SPARC_O6];
268 		tf->tf_out[7] = r[SVR4_SPARC_O7];
269 	}
270 
271 
272 #ifdef FPU_CONTEXT
273 	if (flags & SVR4_UC_FPU) {
274 		/*
275 		 * Set the floating point registers
276 		 */
277 		int error;
278 		size_t sz = f->fp_nqel * f->fp_nqsize;
279 		if (sz > sizeof(fps->fs_queue)) {
280 #ifdef DIAGNOSTIC
281 			printf("setmcontext: fp_queue too large\n");
282 #endif
283 			return EINVAL;
284 		}
285 		memcpy(fps->fs_regs, f->fpu_regs, sizeof(fps->fs_regs));
286 		fps->fs_qsize = f->fp_nqel;
287 		fps->fs_fsr = f->fp_fsr;
288 		if (f->fp_q != NULL) {
289 			if ((error = copyin(f->fp_q, fps->fs_queue,
290 					    f->fp_nqel * f->fp_nqsize)) != 0) {
291 #ifdef DIAGNOSTIC
292 				printf("setmcontext: fp_queue copy failed\n");
293 #endif
294 				return error;
295 			}
296 		}
297 	}
298 #endif
299 
300 	return 0;
301 }
302 
303 /*
304  * map the trap code into the svr4 siginfo as best we can
305  */
306 static void
svr4_getsiginfo(union svr4_siginfo * si,int sig,u_long code,void * addr)307 svr4_getsiginfo(union svr4_siginfo *si, int sig, u_long code, void *addr)
308 {
309 
310 	si->si_signo = native_to_svr4_signo[sig];
311 	si->si_errno = 0;
312 	si->si_addr  = addr;
313 	/*
314 	 * we can do this direct map as they are the same as all sparc
315 	 * architectures.
316 	 */
317 	si->si_trap = code;
318 	switch (code) {
319 	case T_RESET:
320 		si->si_code = 0;
321 		break;
322 
323 	case T_TEXTFAULT:
324 		si->si_code = SVR4_BUS_ADRALN;
325 		break;
326 
327 	case T_ILLINST:
328 		si->si_code = SVR4_ILL_ILLOPC;
329 		break;
330 
331 	case T_PRIVINST:
332 		si->si_code = SVR4_ILL_PRVOPC;
333 		break;
334 
335 	case T_FPDISABLED:
336 		si->si_code = SVR4_FPE_FLTINV;
337 		break;
338 
339 	case T_ALIGN:
340 		si->si_code = SVR4_BUS_ADRALN;
341 		break;
342 
343 	case T_FPE:
344 		si->si_code = SVR4_FPE_FLTINV;
345 		break;
346 
347 	case T_DATAFAULT:
348 		si->si_code = SVR4_BUS_ADRALN;
349 		break;
350 
351 	case T_TAGOF:
352 		si->si_code = SVR4_EMT_TAGOVF;
353 		break;
354 
355 	case T_CPDISABLED:
356 		si->si_code = SVR4_FPE_FLTINV;
357 		break;
358 
359 	case T_CPEXCEPTION:
360 		si->si_code = SVR4_FPE_FLTINV;
361 		break;
362 
363 	case T_DIV0:
364 		si->si_code = SVR4_FPE_INTDIV;
365 		break;
366 
367 	case T_INTOF:
368 		si->si_code = SVR4_FPE_INTOVF;
369 		break;
370 
371 	case T_BREAKPOINT:
372 		si->si_code = SVR4_TRAP_BRKPT;
373 		break;
374 
375 	/*
376 	 * XXX - hardware traps with unknown code
377 	 */
378 	case T_WINOF:
379 	case T_WINUF:
380 	case T_L1INT:
381 	case T_L2INT:
382 	case T_L3INT:
383 	case T_L4INT:
384 	case T_L5INT:
385 	case T_L6INT:
386 	case T_L7INT:
387 	case T_L8INT:
388 	case T_L9INT:
389 	case T_L10INT:
390 	case T_L11INT:
391 	case T_L12INT:
392 	case T_L13INT:
393 	case T_L14INT:
394 	case T_L15INT:
395 		si->si_code = 0;
396 		break;
397 
398 	/*
399 	 * XXX - software traps with unknown code
400 	 */
401 	case T_SUN_SYSCALL:
402 	case T_FLUSHWIN:
403 	case T_CLEANWIN:
404 	case T_RANGECHECK:
405 	case T_FIXALIGN:
406 	case T_SVR4_SYSCALL:
407 	case T_BSD_SYSCALL:
408 	case T_KGDB_EXEC:
409 		si->si_code = 0;
410 		break;
411 
412 	default:
413 		si->si_code = 0;
414 #ifdef notyet
415 		/*
416 		 * XXX: in trap.c, code gets passed the address
417 		 * of the fault! not the trap code on SEGV!
418 		 */
419 #ifdef DIAGNOSTIC
420 		printf("sig %d code %ld\n", sig, code);
421 		panic("svr4_getsiginfo");
422 #endif
423 #endif
424 		break;
425 	}
426 }
427 
428 /*
429  * Send an interrupt to process.
430  *
431  * Stack is set up to allow sigcode stored
432  * in u. to call routine. After the handler is
433  * done svr4 will call setcontext for us
434  * with the user context we just set up, and we
435  * will return to the user pc, psl.
436  */
437 void
svr4_sendsig(const ksiginfo_t * ksi,const sigset_t * mask)438 svr4_sendsig(const ksiginfo_t *ksi, const sigset_t *mask)
439 {
440 	register struct lwp *l = curlwp;
441 	struct proc *p = l->l_proc;
442 	register struct trapframe *tf;
443 	struct svr4_sigframe *fp, frame;
444 	int onstack, oldsp, newsp, addr, error;
445 	int sig = ksi->ksi_signo;
446 	u_long code = ksi->ksi_code;
447 	sig_t catcher = SIGACTION(p, sig).sa_handler;
448 
449 	tf = (struct trapframe *)l->l_md.md_tf;
450 	oldsp = tf->tf_out[6];
451 
452 	/* Do we need to jump onto the signal stack? */
453 	onstack =
454 	    (l->l_sigstk.ss_flags & (SS_DISABLE | SS_ONSTACK)) == 0 &&
455 	    (SIGACTION(p, sig).sa_flags & SA_ONSTACK) != 0;
456 
457 	/*
458 	 * Allocate space for the signal handler context.
459 	 */
460 	if (onstack)
461 		fp = (struct svr4_sigframe *)((char *)l->l_sigstk.ss_sp +
462 						l->l_sigstk.ss_size);
463 	else
464 		fp = (struct svr4_sigframe *)oldsp;
465 	fp = (struct svr4_sigframe *) ((int) (fp - 1) & ~7);
466 
467 	/*
468 	 * Build the argument list for the signal handler.
469 	 */
470 	svr4_getcontext(l, &frame.sf_uc);
471 	svr4_getsiginfo(&frame.sf_si, sig, code, (void *) tf->tf_pc);
472 
473 	/* Build stack frame for signal trampoline. */
474 	frame.sf_signum = frame.sf_si.si_signo;
475 	frame.sf_sip = &fp->sf_si;
476 	frame.sf_ucp = &fp->sf_uc;
477 	frame.sf_handler = catcher;
478 
479 	DPRINTF(("svr4_sendsig signum=%d si = %p uc = %p handler = %p\n",
480 	         frame.sf_signum, frame.sf_sip,
481 		 frame.sf_ucp, frame.sf_handler));
482 	/*
483 	 * Modify the signal context to be used by sigreturn.
484 	 */
485 	sendsig_reset(l, sig);
486 	mutex_exit(p->p_lock);
487 	frame.sf_uc.uc_mcontext.greg[SVR4_SPARC_SP] = oldsp;
488 	newsp = (int)fp - sizeof(struct rwindow);
489 	write_user_windows();
490 	error = (rwindow_save(l) || copyout(&frame, fp, sizeof(frame)) != 0 ||
491 	    suword(&((struct rwindow *)newsp)->rw_in[6], oldsp));
492 	mutex_enter(p->p_lock);
493 
494 	if (error) {
495 		/*
496 		 * Process has trashed its stack; give it an illegal
497 		 * instruction to halt it in its tracks.
498 		 */
499 #ifdef DEBUG
500 		if ((sigdebug & SDB_KSTACK) && p->p_pid == sigpid)
501 			printf("svr4_sendsig: window save or copyout error\n");
502 #endif
503 		sigexit(l, SIGILL);
504 		/* NOTREACHED */
505 	}
506 
507 	/*
508 	 * Build context to run handler in.
509 	 */
510 	addr = (int)p->p_sigctx.ps_sigcode;
511 	tf->tf_pc = addr;
512 	tf->tf_npc = addr + 4;
513 	tf->tf_global[1] = (int)catcher;
514 	tf->tf_out[6] = newsp;
515 
516 	/* Remember that we're now on the signal stack. */
517 	if (onstack)
518 		l->l_sigstk.ss_flags |= SS_ONSTACK;
519 }
520 
521 
522 #define	ADVANCE (n = tf->tf_npc, tf->tf_pc = n, tf->tf_npc = n + 4)
523 
524 int
svr4_trap(int type,struct lwp * l)525 svr4_trap(int type, struct lwp *l)
526 {
527 	int n;
528 	struct trapframe *tf = l->l_md.md_tf;
529 	struct timespec ts;
530 	struct timeval tv;
531 	struct timeval rtime, stime;
532 	uint64_t tm;
533 
534 	if (l->l_proc->p_emul != &emul_svr4)
535 		return 0;
536 
537 	switch (type) {
538 	case T_SVR4_GETCC:
539 		uprintf("T_SVR4_GETCC\n");
540 		break;
541 
542 	case T_SVR4_SETCC:
543 		uprintf("T_SVR4_SETCC\n");
544 		break;
545 
546 	case T_SVR4_GETPSR:
547 		tf->tf_out[0] = tf->tf_psr;
548 		break;
549 
550 	case T_SVR4_SETPSR:
551 		/* Disable for now; it makes things worse */
552 #if 0
553 		/* I have no clue if this is right!  */
554 #define PRESERVE_PSR	(PSR_IMPL|PSR_VER|PSR_PIL|PSR_S|PSR_PS|PSR_ET|PSR_CWP)
555 		tf->tf_psr = (tf->tf_psr & ~PRESERVE_PSR) |
556 		    (tf->tf_out[0] & PRESERVE_PSR);
557 #endif
558 		break;
559 
560 	case T_SVR4_GETHRTIME:
561 		/*
562 		 * This is like gethrtime(3), returning the time expressed
563 		 * in nanoseconds since an arbitrary time in the past and
564 		 * guaranteed to be monotonically increasing, which we
565 		 * obtain from nanotime(9).
566 		 */
567 		nanouptime(&ts);
568 
569 		tm = ts.tv_nsec;
570 		tm += ts.tv_sec * (uint64_t)1000000000u;
571 		tf->tf_out[0] = (tm >> 32) & 0x00000000ffffffffUL;
572 		tf->tf_out[1] = tm & 0x00000000ffffffffUL;
573 		break;
574 
575 	case T_SVR4_GETHRVTIME:
576 		/*
577 		 * This is like gethrvtime(3). returning the LWP's (now:
578 		 * proc's) virtual time expressed in nanoseconds. It is
579 		 * supposedly guaranteed to be monotonically increasing, but
580 		 * for now using the process's real time augmented with its
581 		 * current runtime is the best we can do.
582 		 */
583 		microtime(&tv); /* XXX should move on to struct bintime */
584 		bintime2timeval(&l->l_rtime, &rtime);
585 		bintime2timeval(&l->l_stime, &stime);
586 
587 		tm = (rtime.tv_sec + tv.tv_sec - stime.tv_sec) * 1000000ull;
588 		tm += rtime.tv_usec + tv.tv_usec;
589 		tm -= stime.tv_usec;
590 		tm *= 1000u;
591 		tf->tf_out[0] = (tm >> 32) & 0x00000000ffffffffUL;
592 		tf->tf_out[1] = tm & 0x00000000ffffffffUL;
593 		break;
594 
595 	case T_SVR4_GETHRESTIME:
596 		/*
597 		 * This is used by gettimeofday(3), among other things.
598 		 */
599 		nanotime(&ts);
600 		tf->tf_out[0] = ts.tv_sec;
601 		tf->tf_out[1] = ts.tv_nsec;
602 		break;
603 
604 	default:
605 		return 0;
606 	}
607 
608 	ADVANCE;
609 	return 1;
610 }
611 
612 /*
613  */
614 int
svr4_sys_sysarch(struct lwp * l,const struct svr4_sys_sysarch_args * uap,register_t * retval)615 svr4_sys_sysarch(struct lwp *l, const struct svr4_sys_sysarch_args *uap, register_t *retval)
616 {
617 
618 	switch (SCARG(uap, op)) {
619 	default:
620 		printf("(sparc) svr4_sysarch(%d)\n", SCARG(uap, op));
621 		return EINVAL;
622 	}
623 }
624 
625 void
svr4_md_init(void)626 svr4_md_init(void)
627 {
628 
629 }
630 
631 void
svr4_md_fini(void)632 svr4_md_fini(void)
633 {
634 
635 }
636