Annotation of sys/arch/m68k/m68k/m68k_machdep.c, Revision 1.1.1.1
1.1 nbrk 1: /* $OpenBSD: m68k_machdep.c,v 1.11 2007/05/15 13:46:22 martin Exp $ */
2: /* $NetBSD: m68k_machdep.c,v 1.3 1997/06/12 09:57:04 veego Exp $ */
3:
4: /*-
5: * Copyright (c) 1997 The NetBSD Foundation, Inc.
6: * All rights reserved.
7: *
8: * This code is derived from software contributed to The NetBSD Foundation
9: * by Bernd Ernesti.
10: *
11: * Redistribution and use in source and binary forms, with or without
12: * modification, are permitted provided that the following conditions
13: * are met:
14: * 1. Redistributions of source code must retain the above copyright
15: * notice, this list of conditions and the following disclaimer.
16: * 2. Redistributions in binary form must reproduce the above copyright
17: * notice, this list of conditions and the following disclaimer in the
18: * documentation and/or other materials provided with the distribution.
19: * 3. All advertising materials mentioning features or use of this software
20: * must display the following acknowledgement:
21: * This product includes software developed by the NetBSD
22: * Foundation, Inc. and its contributors.
23: * 4. Neither the name of The NetBSD Foundation nor the names of its
24: * contributors may be used to endorse or promote products derived
25: * from this software without specific prior written permission.
26: *
27: * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
28: * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
29: * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
30: * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
31: * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
32: * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
33: * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
34: * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
35: * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
36: * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
37: * POSSIBILITY OF SUCH DAMAGE.
38: */
39:
40: #include <sys/param.h>
41: #include <sys/systm.h>
42: #include <sys/exec.h>
43: #include <sys/proc.h>
44: #include <sys/syscall.h>
45: #include <sys/ktrace.h>
46: #include <sys/user.h>
47:
48: #include <machine/cpu.h>
49: #include <machine/frame.h>
50: #include <machine/reg.h>
51:
52: struct cpu_info cpu_info_store;
53:
54: /*
55: * Set registers on exec.
56: */
57: void
58: setregs(p, pack, stack, retval)
59: struct proc *p;
60: struct exec_package *pack;
61: u_long stack;
62: register_t *retval;
63: {
64: #ifdef COMPAT_SUNOS
65: extern struct emul emul_sunos;
66: #endif
67: struct frame *frame = (struct frame *)p->p_md.md_regs;
68:
69: frame->f_sr = PSL_USERSET;
70: frame->f_pc = pack->ep_entry & ~1;
71: bzero(frame->f_regs, 15 * sizeof(register_t));
72: frame->f_regs[A2] = (int)PS_STRINGS;
73: frame->f_regs[SP] = stack;
74:
75: /* restore a null state frame */
76: p->p_addr->u_pcb.pcb_fpregs.fpf_null = 0;
77: if (fputype != FPU_NONE) {
78: m68881_restore(&p->p_addr->u_pcb.pcb_fpregs);
79: }
80:
81: #ifdef COMPAT_SUNOS
82: /*
83: * SunOS' ld.so does self-modifying code without knowing
84: * about the 040's cache purging needs. So we need to uncache
85: * writeable executable pages.
86: */
87: if (p->p_emul == &emul_sunos)
88: p->p_md.md_flags |= MDP_UNCACHE_WX;
89: else
90: p->p_md.md_flags &= ~MDP_UNCACHE_WX;
91: #endif
92:
93: retval[1] = 0;
94: }
95:
96: /*
97: * Process the tail end of a fork() for the child
98: */
99: void
100: child_return(arg)
101: void *arg;
102: {
103: struct proc *p = (struct proc *)arg;
104: struct frame *f = (struct frame *)p->p_md.md_regs;
105:
106: f->f_regs[D0] = 0;
107: f->f_sr &= ~PSL_C; /* carry bit */
108: f->f_format = FMT0;
109:
110: userret(p);
111: #ifdef KTRACE
112: if (KTRPOINT(p, KTR_SYSRET))
113: ktrsysret(p,
114: (p->p_flag & P_PPWAIT) ? SYS_vfork : SYS_fork, 0, 0);
115: #endif
116: }
117:
118: #ifdef DIAGNOSTIC
119: void
120: splassert_check(int wantipl, const char *func)
121: {
122: int oldipl;
123:
124: __asm __volatile ("movew sr,%0" : "=&d" (oldipl));
125:
126: oldipl = PSLTOIPL(oldipl);
127:
128: if (oldipl < wantipl) {
129: splassert_fail(wantipl, oldipl, func);
130: /*
131: * If the splassert_ctl is set to not panic, raise the ipl
132: * in a feeble attempt to reduce damage.
133: */
134: _spl(PSL_S | IPLTOPSL(wantipl));
135: }
136: }
137: #endif
CVSweb