Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/i386 new i386 files for macho and mach.
details: https://anonhg.NetBSD.org/src/rev/91e0db5644ad
branches: trunk
changeset: 512687:91e0db5644ad
user: christos <christos%NetBSD.org@localhost>
date: Sat Jul 14 02:04:25 2001 +0000
description:
new i386 files for macho and mach.
diffstat:
sys/arch/i386/i386/mach_machdep.c | 93 +++++++++++
sys/arch/i386/i386/mach_sigcode.s | 209 +++++++++++++++++++++++++
sys/arch/i386/i386/mach_syscall.c | 278 ++++++++++++++++++++++++++++++++++
sys/arch/i386/i386/macho_machdep.c | 128 +++++++++++++++
sys/arch/i386/include/macho_machdep.h | 95 +++++++++++
5 files changed, 803 insertions(+), 0 deletions(-)
diffs (truncated from 823 to 300 lines):
diff -r 25b12ecaafb7 -r 91e0db5644ad sys/arch/i386/i386/mach_machdep.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/i386/i386/mach_machdep.c Sat Jul 14 02:04:25 2001 +0000
@@ -0,0 +1,93 @@
+/* $NetBSD: mach_machdep.c,v 1.1 2001/07/14 02:04:25 christos Exp $ */
+
+/*-
+ * Copyright (c) 2000 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Christos Zoulas.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the NetBSD
+ * Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#if defined(_KERNEL_OPT)
+#include "opt_vm86.h"
+#include "opt_user_ldt.h"
+#endif
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/namei.h>
+#include <sys/proc.h>
+#include <sys/exec.h>
+#include <sys/user.h>
+#include <sys/filedesc.h>
+#include <sys/ioctl.h>
+#include <sys/kernel.h>
+#include <sys/signal.h>
+#include <sys/signalvar.h>
+#include <sys/malloc.h>
+#include <sys/mount.h>
+#include <sys/syscallargs.h>
+#include <sys/exec_elf.h>
+
+#include <compat/mach/mach_types.h>
+#include <compat/mach/mach_syscallargs.h>
+
+#include <machine/cpu.h>
+#include <machine/cpufunc.h>
+#include <machine/psl.h>
+#include <machine/reg.h>
+#include <machine/specialreg.h>
+#include <machine/sysarch.h>
+#include <machine/vm86.h>
+#include <machine/vmparam.h>
+
+void mach_trap __P((struct trapframe));
+
+/*
+ * Fast syscall gate trap...
+ */
+void
+mach_trap(frame)
+ struct trapframe frame;
+{
+ extern struct emul emul_mach;
+ struct proc *p = curproc;
+
+ p->p_md.md_regs = &frame;
+
+ if (p->p_emul != &emul_mach) {
+ DPRINTF(("mach trap %d on bad emulation\n", frame.tf_eax));
+ trapsignal(p, SIGBUS, 0);
+ return;
+ }
+
+ uprintf("unknown mach trap %d\n", frame.tf_eax);
+}
diff -r 25b12ecaafb7 -r 91e0db5644ad sys/arch/i386/i386/mach_sigcode.s
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/i386/i386/mach_sigcode.s Sat Jul 14 02:04:25 2001 +0000
@@ -0,0 +1,209 @@
+/* $NetBSD: mach_sigcode.s,v 1.1 2001/07/14 02:04:25 christos Exp $ */
+
+/*-
+ * Copyright (c) 1998 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Charles M. Hannum.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the NetBSD
+ * Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*-
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * William Jolitz.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)locore.s 7.3 (Berkeley) 5/13/91
+ */
+
+#if defined(_KERNEL_OPT)
+#include "opt_vm86.h"
+#endif
+
+#include "assym.h"
+
+#include <machine/psl.h>
+#include <machine/segments.h>
+#include <machine/trap.h>
+#include <compat/mach/mach_syscall.h>
+
+/*
+ * override user-land alignment before including asm.h
+ */
+#ifdef __ELF__
+#define ALIGN_DATA .align 4
+#define ALIGN_TEXT .align 4,0x90 /* 4-byte boundaries, NOP-filled */
+#define SUPERALIGN_TEXT .align 16,0x90 /* 16-byte boundaries better for 486 */
+#else
+#define ALIGN_DATA .align 2
+#define ALIGN_TEXT .align 2,0x90 /* 4-byte boundaries, NOP-filled */
+#define SUPERALIGN_TEXT .align 4,0x90 /* 16-byte boundaries better for 486 */
+#endif
+#define _ALIGN_TEXT ALIGN_TEXT
+#include <machine/asm.h>
+
+/*
+ * XXX traditional CPP's evaluation semantics make this necessary.
+ * XXX (__CONCAT() would be evaluated incorrectly)
+ */
+#ifdef __ELF__
+#define IDTVEC(name) ALIGN_TEXT; .globl X/**/name; X/**/name:
+#else
+#define IDTVEC(name) ALIGN_TEXT; .globl _X/**/name; _X/**/name:
+#endif
+
+/*
+ * These are used on interrupt or trap entry or exit.
+ */
+#define INTRENTRY \
+ pushl %eax ; \
+ pushl %ecx ; \
+ pushl %edx ; \
+ pushl %ebx ; \
+ movl $GSEL(GDATA_SEL, SEL_KPL),%eax ; \
+ pushl %ebp ; \
+ pushl %esi ; \
+ pushl %edi ; \
+ pushl %ds ; \
+ pushl %es ; \
+ movl %ax,%ds ; \
+ movl %ax,%es ; \
+ pushl %fs ; \
+ pushl %gs ; \
+ movl %ax,%fs ; \
+ movl %ax,%gs ; \
+
+#define INTRFASTEXIT \
+ popl %gs ; \
+ popl %fs ; \
+ popl %es ; \
+ popl %ds ; \
+ popl %edi ; \
+ popl %esi ; \
+ popl %ebp ; \
+ popl %ebx ; \
+ popl %edx ; \
+ popl %ecx ; \
+ popl %eax ; \
+ addl $8,%esp ; \
+ iret
+
+
+/*
+ * Signal trampoline; copied to top of user stack.
+ */
+/* LINTSTUB: Var: char mach_sigcode[1], mach_esigcode[1]; */
+NENTRY(mach_sigcode)
+/*
+ call MACH_SIGF_HANDLER(%esp)
+ leal MACH_SIGF_UC(%esp),%eax # ucp (the call may have clobbered the
+ # copy at SIGF_UCP(%esp))
+ pushl %eax
+ pushl $1 # setcontext(p) == syscontext(1, p)
+ pushl %eax # junk to fake return address
+ movl $MACH_SYS_context,%eax
+ int $0x80 # enter kernel with args on stack
+ movl $MACH_SYS_exit,%eax
+ int $0x80 # exit if sigreturn fails
+*/
+ .globl _C_LABEL(mach_esigcode)
+_C_LABEL(mach_esigcode):
+
+IDTVEC(mach_trap)
+ /* Set eflags in trap frame. */
+ pushfl
+ popl 8(%esp)
+ pushl $7 # size of instruction for restart
+ pushl $T_ASTFLT # trap # for doing ASTs
+ INTRENTRY
+ movl _C_LABEL(curproc),%edx # get pointer to curproc
+#ifdef DIAGNOSTIC
+ movl _C_LABEL(cpl),%ebx
+#endif /* DIAGNOSTIC */
+ movl %esp,P_MD_REGS(%edx) # save pointer to frame
+ call _C_LABEL(mach_trap)
+2: /* Check for ASTs on exit to user mode. */
+ cli
+ cmpb $0,_C_LABEL(astpending)
+ je 1f
+ /* Always returning to user mode here. */
+ movb $0,_C_LABEL(astpending)
+ sti
+ /* Pushed T_ASTFLT into tf_trapno on entry. */
+ call _C_LABEL(trap)
+ jmp 2b
+#ifndef DIAGNOSTIC
+1: INTRFASTEXIT
+#else /* DIAGNOSTIC */
+1: cmpl _C_LABEL(cpl),%ebx
+ jne 3f
+ INTRFASTEXIT
+3: sti
Home |
Main Index |
Thread Index |
Old Index