From fddf44c0bf12d0cd38d2baa205fee3dada7da015 Mon Sep 17 00:00:00 2001 From: manu Date: Wed, 30 Oct 2002 06:41:45 +0000 Subject: [PATCH] Add COMPAT_MACH and EXEC_MACHO support on the PowerPC --- sys/arch/powerpc/conf/files.powerpc | 9 +- sys/arch/powerpc/include/Makefile | 4 +- sys/arch/powerpc/include/macho_machdep.h | 185 +++++++++++++++++++++++ sys/arch/powerpc/powerpc/mach_machdep.c | 94 ++++++++++++ sys/arch/powerpc/powerpc/mach_sigcode.S | 88 +++++++++++ sys/arch/powerpc/powerpc/mach_syscall.c | 53 +++++++ sys/arch/powerpc/powerpc/macho_machdep.c | 64 ++++++++ sys/arch/powerpc/powerpc/syscall.c | 30 +++- 8 files changed, 521 insertions(+), 6 deletions(-) create mode 100644 sys/arch/powerpc/include/macho_machdep.h create mode 100644 sys/arch/powerpc/powerpc/mach_machdep.c create mode 100644 sys/arch/powerpc/powerpc/mach_sigcode.S create mode 100644 sys/arch/powerpc/powerpc/mach_syscall.c create mode 100644 sys/arch/powerpc/powerpc/macho_machdep.c diff --git a/sys/arch/powerpc/conf/files.powerpc b/sys/arch/powerpc/conf/files.powerpc index 070b9d8c7a0c..cd0c81dcac33 100644 --- a/sys/arch/powerpc/conf/files.powerpc +++ b/sys/arch/powerpc/conf/files.powerpc @@ -1,4 +1,4 @@ -# $NetBSD: files.powerpc,v 1.37 2002/10/30 06:37:37 manu Exp $ +# $NetBSD: files.powerpc,v 1.38 2002/10/30 06:41:46 manu Exp $ defflag opt_altivec.h ALTIVEC K_ALTIVEC defflag opt_openpic.h OPENPIC OPENPIC_SERIAL_MODE @@ -53,6 +53,13 @@ file arch/powerpc/powerpc/trap.c ppc_mpc6xx # Binary compatibility with previous NetBSD releases (COMPAT_XX) file arch/powerpc/powerpc/compat_13_machdep.c compat_13 +# MACH binary compatibility (COMPAT_MACH) +include "compat/mach/files.mach" +file arch/powerpc/powerpc/mach_machdep.c compat_mach +file arch/powerpc/powerpc/mach_sigcode.S compat_mach +file arch/powerpc/powerpc/mach_syscall.c compat_mach +file arch/powerpc/powerpc/macho_machdep.c exec_macho + # OSS audio driver compatibility include "compat/ossaudio/files.ossaudio" diff --git a/sys/arch/powerpc/include/Makefile b/sys/arch/powerpc/include/Makefile index 6f0597492db7..678c3a5a187e 100644 --- a/sys/arch/powerpc/include/Makefile +++ b/sys/arch/powerpc/include/Makefile @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.25 2002/08/07 05:15:53 briggs Exp $ +# $NetBSD: Makefile,v 1.26 2002/10/30 06:41:45 manu Exp $ KDIR= /sys/arch/powerpc/include INCSDIR= /usr/include/powerpc @@ -14,7 +14,7 @@ INCS= ansi.h aout_machdep.h asm.h atomic.h \ ipkdb.h \ kcore.h \ limits.h lock.h \ - math.h \ + macho_machdep.h math.h \ param.h pcb.h pio.h pmap.h pmc.h proc.h profile.h psl.h pte.h ptrace.h \ reg.h reloc.h \ setjmp.h signal.h stdarg.h \ diff --git a/sys/arch/powerpc/include/macho_machdep.h b/sys/arch/powerpc/include/macho_machdep.h new file mode 100644 index 000000000000..6f51281e97ce --- /dev/null +++ b/sys/arch/powerpc/include/macho_machdep.h @@ -0,0 +1,185 @@ +/* $NetBSD: macho_machdep.h,v 1.1 2002/10/30 06:41:45 manu Exp $ */ + +/*- + * Copyright (c) 2002 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Emmanuel Dreyfus. + * + * 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. + */ + +#ifndef _POWERPC_MACHO_MACHDEP_H_ +#define _POWERPC_MACHO_MACHDEP_H_ + +/* From Darwin's xnu/osfmk/mach/ppc/thread_status.h (s/ppc/powerpc/) */ +#define MACHO_POWERPC_THREAD_STATE 1 + +struct exec_macho_powerpc_thread_state { + unsigned int srr0; + unsigned int srr1; + unsigned int r0; + unsigned int r1; + unsigned int r2; + unsigned int r3; + unsigned int r4; + unsigned int r5; + unsigned int r6; + unsigned int r7; + unsigned int r8; + unsigned int r9; + unsigned int r10; + unsigned int r11; + unsigned int r12; + unsigned int r13; + unsigned int r14; + unsigned int r15; + unsigned int r16; + unsigned int r17; + unsigned int r18; + unsigned int r19; + unsigned int r20; + unsigned int r21; + unsigned int r22; + unsigned int r23; + unsigned int r24; + unsigned int r25; + unsigned int r26; + unsigned int r27; + unsigned int r28; + unsigned int r29; + unsigned int r30; + unsigned int r31; + unsigned int cr; + unsigned int xer; + unsigned int lr; + unsigned int ctr; + unsigned int mq; + unsigned int vrsave; +}; + +#define MACHO_POWERPC_NEW_THREAD_STATE 1 + +/* + * From Darwin's xnu/osfmk/ppc/savearea.h + * struct exec_macho_powerpc_saved_state is called struct savearea there. + */ +struct exec_macho_powerpc_saved_state { + struct exec_macho_powerpc_savearea_comm { + struct exec_macho_powerpc_saved_state *save_prev; + unsigned int *sac_next; + unsigned int *sac_prev; + unsigned int save_flags; + unsigned int save_level; + unsigned int save_time[2]; + struct thread_activation *save_act; + unsigned int sac_vrswap; + unsigned int sac_alloc; + unsigned int sac_flags; + unsigned int save_misc0; + unsigned int save_misc1; + unsigned int save_misc2; + unsigned int save_misc3; + unsigned int save_misc4; + unsigned int save_040[8]; + } save_hdr; + unsigned int save_060[8]; + unsigned int save_r0; + unsigned int save_r1; + unsigned int save_r2; + unsigned int save_r3; + unsigned int save_r4; + unsigned int save_r5; + unsigned int save_r6; + unsigned int save_r7; + unsigned int save_r8; + unsigned int save_r9; + unsigned int save_r10; + unsigned int save_r11; + unsigned int save_r12; + unsigned int save_r13; + unsigned int save_r14; + unsigned int save_r15; + unsigned int save_r16; + unsigned int save_r17; + unsigned int save_r18; + unsigned int save_r19; + unsigned int save_r20; + unsigned int save_r21; + unsigned int save_r22; + unsigned int save_r23; + unsigned int save_r24; + unsigned int save_r25; + unsigned int save_r26; + unsigned int save_r27; + unsigned int save_r28; + unsigned int save_r29; + unsigned int save_r30; + unsigned int save_r31; + unsigned int save_srr0; + unsigned int save_srr1; + unsigned int save_cr; + unsigned int save_xer; + unsigned int save_lr; + unsigned int save_ctr; + unsigned int save_dar; + unsigned int save_dsisr; + unsigned int save_vscr[4]; + unsigned int save_fpscrpad; + unsigned int save_fpscr; + unsigned int save_exception; + unsigned int save_vrsave; + unsigned int save_sr0; + unsigned int save_sr1; + unsigned int save_sr2; + unsigned int save_sr3; + unsigned int save_sr4; + unsigned int save_sr5; + unsigned int save_sr6; + unsigned int save_sr7; + unsigned int save_sr8; + unsigned int save_sr9; + unsigned int save_sr10; + unsigned int save_sr11; + unsigned int save_sr12; + unsigned int save_sr13; + unsigned int save_sr14; + unsigned int save_sr15; + unsigned int save_180[8]; + unsigned int save_1A0[8]; + unsigned int save_1C0[8]; + unsigned int save_1E0[8]; + unsigned int save_200[8]; + unsigned int save_220[8]; + unsigned int save_240[8]; + unsigned int save_260[8]; +}; + +#endif /* !_POWERPC_MACHO_MACHDEP_H_ */ diff --git a/sys/arch/powerpc/powerpc/mach_machdep.c b/sys/arch/powerpc/powerpc/mach_machdep.c new file mode 100644 index 000000000000..cd6c9bd086d0 --- /dev/null +++ b/sys/arch/powerpc/powerpc/mach_machdep.c @@ -0,0 +1,94 @@ +/* $NetBSD: mach_machdep.c,v 1.1 2002/10/30 06:41:45 manu Exp $ */ + +/*- + * Copyright (c) 2002 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Christos Zoulas and Emmanuel Dreyfus. + * + * 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. + */ + +#include +__KERNEL_RCSID(0, "$NetBSD: mach_machdep.c,v 1.1 2002/10/30 06:41:45 manu Exp $"); + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include +#include + +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; + + if (p->p_emul != &emul_mach) { + DPRINTF(("mach trap %d on bad emulation\n", frame->exc)); + trapsignal(p, SIGBUS, 0); + return; + } + + switch (frame->exc) { + case 0: + DPRINTF(("mach_pthread_self();\n")); + break; + case 1: + DPRINTF(("mach_pthread_set_self();\n")); + break; + default: + uprintf("unknown mach trap %d\n", frame->exc); + break; + } +} diff --git a/sys/arch/powerpc/powerpc/mach_sigcode.S b/sys/arch/powerpc/powerpc/mach_sigcode.S new file mode 100644 index 000000000000..1201cf56448c --- /dev/null +++ b/sys/arch/powerpc/powerpc/mach_sigcode.S @@ -0,0 +1,88 @@ +/* $NetBSD: mach_sigcode.S,v 1.1 2002/10/30 06:41:45 manu Exp $ */ + +/*- + * Copyright (c) 2002 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Charles M. Hannum and Emmanuel Dreyfus. + * + * 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 + */ + +#include "assym.h" + +#include +#include +#include + +#include + + .globl _C_LABEL(mach_sigcode),_C_LABEL(mach_esigcode) +_C_LABEL(mach_sigcode): +_C_LABEL(mach_esigcode): + diff --git a/sys/arch/powerpc/powerpc/mach_syscall.c b/sys/arch/powerpc/powerpc/mach_syscall.c new file mode 100644 index 000000000000..85e2215f8ed1 --- /dev/null +++ b/sys/arch/powerpc/powerpc/mach_syscall.c @@ -0,0 +1,53 @@ +/* $NetBSD: mach_syscall.c,v 1.1 2002/10/30 06:41:45 manu Exp $ */ + +/*- + * Copyright (c) 2002 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Emmanuel Dreyfus + * + * 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. + */ + +#include + +__KERNEL_RCSID(0, "$NetBSD: mach_syscall.c,v 1.1 2002/10/30 06:41:45 manu Exp $"); + +#include +#include +#include +#include + +void mach_syscall_intern __P((struct proc *)); + +#define EMULNAME(x) __CONCAT(mach_,x) +#define MACH_SYSCALL + +#include "syscall.c" diff --git a/sys/arch/powerpc/powerpc/macho_machdep.c b/sys/arch/powerpc/powerpc/macho_machdep.c new file mode 100644 index 000000000000..7706fe839215 --- /dev/null +++ b/sys/arch/powerpc/powerpc/macho_machdep.c @@ -0,0 +1,64 @@ +/* $NetBSD: macho_machdep.c,v 1.1 2002/10/30 06:41:45 manu Exp $ */ + +/*- + * Copyright (c) 2002 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Emmanuel Dreyfus + * + * 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. + */ + +#include +__KERNEL_RCSID(0, "$NetBSD: macho_machdep.c,v 1.1 2002/10/30 06:41:45 manu Exp $"); + +#include +#include +#include + +u_int32_t exec_macho_supported_cpu[] = { MACHO_CPU_TYPE_POWERPC, 0 }; + +u_long +exec_macho_thread_entry(struct exec_macho_thread_command *tc) { + switch (tc->flavor) { + case MACHO_POWERPC_THREAD_STATE: { + struct exec_macho_powerpc_thread_state *ts = + (struct exec_macho_powerpc_thread_state *) + (void *)((char *)tc + sizeof(*tc)); + return ts->srr0; + } + + default: +#ifdef DEBUG_MACHO + printf("Unknown thread flavor %ld\n", tc->flavor); +#endif + return 0; + } +} diff --git a/sys/arch/powerpc/powerpc/syscall.c b/sys/arch/powerpc/powerpc/syscall.c index 6eede5112391..068e2385adf9 100644 --- a/sys/arch/powerpc/powerpc/syscall.c +++ b/sys/arch/powerpc/powerpc/syscall.c @@ -1,4 +1,4 @@ -/* $NetBSD: syscall.c,v 1.5 2002/10/30 06:37:38 manu Exp $ */ +/* $NetBSD: syscall.c,v 1.6 2002/10/30 06:41:45 manu Exp $ */ /* * Copyright (C) 2002 Matt Thomas @@ -36,6 +36,7 @@ #include "opt_ktrace.h" #include "opt_systrace.h" #include "opt_compat_linux.h" +#include "opt_compat_mach.h" #include "opt_multiprocessor.h" #include @@ -67,6 +68,11 @@ #include #endif +#ifdef COMPAT_MACH +#include +extern struct sysent mach_sysent[]; +#endif + #define FIRSTARG 3 /* first argument is in reg 3 */ #define NARGREG 8 /* 8 args are in registers */ #define MOREARGS(sp) ((caddr_t)((uintptr_t)(sp) + 8)) /* more args go here */ @@ -94,7 +100,16 @@ EMULNAME(syscall_plain)(struct trapframe *frame) code = frame->fixreg[0]; - callp = p->p_emul->e_sysent; +#if MACH_SYSCALL + if (code < 0) { +#ifdef DEBUG_MACH + printf("->mach(%d)\n", code); +#endif /* DEBUG_MACH */ + code = -code; + callp = mach_sysent; + } else +#endif /* MACH_SYSCALL */ + callp = p->p_emul->e_sysent; params = frame->fixreg + FIRSTARG; n = NARGREG; @@ -187,7 +202,16 @@ EMULNAME(syscall_fancy)(struct trapframe *frame) curcpu()->ci_ev_scalls.ev_count++; code = frame->fixreg[0]; - callp = p->p_emul->e_sysent; +#ifdef MACH_SYSCALL + if (code < 0) { +#ifdef DEBUG_MACH + printf("->mach(%d)\n", code); +#endif /* DEBUG_MACH */ + code = -code; + callp = mach_sysent; + } else +#endif /* MACH_SYSCALL */ + callp = p->p_emul->e_sysent; params = frame->fixreg + FIRSTARG; n = NARGREG;