diff --git a/sys/compat/mach/arch/powerpc/fasttraps/mach_fasttraps_thread.c b/sys/compat/mach/arch/powerpc/fasttraps/mach_fasttraps_thread.c index 79b059eed555..6129d8b32d85 100644 --- a/sys/compat/mach/arch/powerpc/fasttraps/mach_fasttraps_thread.c +++ b/sys/compat/mach/arch/powerpc/fasttraps/mach_fasttraps_thread.c @@ -1,4 +1,4 @@ -/* $NetBSD: mach_fasttraps_thread.c,v 1.5 2003/01/30 19:14:20 manu Exp $ */ +/* $NetBSD: mach_fasttraps_thread.c,v 1.6 2003/02/02 19:06:31 manu Exp $ */ /*- * Copyright (c) 2002 The NetBSD Foundation, Inc. @@ -37,7 +37,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: mach_fasttraps_thread.c,v 1.5 2003/01/30 19:14:20 manu Exp $"); +__KERNEL_RCSID(0, "$NetBSD: mach_fasttraps_thread.c,v 1.6 2003/02/02 19:06:31 manu Exp $"); #include #include @@ -72,6 +72,19 @@ mach_sys_cthread_self(l, v, retval) void *v; register_t *retval; { + struct mach_emuldata *med; + + /* + * After a fork or exec, l_private is not initialized. + * We have no way of setting it before, so we keep track + * of it being uninitialized with med_dirty_thid. + * XXX This is probably not the most efficient way + */ + med = l->l_proc->p_emuldata; + if (med->med_dirty_thid != 0) { + l->l_private = NULL; + med->med_dirty_thid = 0; + } *retval = (register_t)l->l_private; return 0; diff --git a/sys/compat/mach/mach_exec.c b/sys/compat/mach/mach_exec.c index 06babecec827..812dd26db8da 100644 --- a/sys/compat/mach/mach_exec.c +++ b/sys/compat/mach/mach_exec.c @@ -1,4 +1,4 @@ -/* $NetBSD: mach_exec.c,v 1.25 2003/01/30 19:14:19 manu Exp $ */ +/* $NetBSD: mach_exec.c,v 1.26 2003/02/02 19:07:17 manu Exp $ */ /*- * Copyright (c) 2001-2003 The NetBSD Foundation, Inc. @@ -37,7 +37,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: mach_exec.c,v 1.25 2003/01/30 19:14:19 manu Exp $"); +__KERNEL_RCSID(0, "$NetBSD: mach_exec.c,v 1.26 2003/02/02 19:07:17 manu Exp $"); #include #include @@ -214,7 +214,6 @@ mach_e_proc_init(p, vmspace) struct vmspace *vmspace; { struct mach_emuldata *med; - struct lwp *l; /* * Initialize various things if needed. @@ -251,9 +250,7 @@ mach_e_proc_init(p, vmspace) med->med_bootstrap = mach_bootstrap_port; med->med_bootstrap->mp_refcount++; - l = proc_representative_lwp(p); - l->l_private = (void *)0; - + med->med_dirty_thid = 1; return; } diff --git a/sys/compat/mach/mach_exec.h b/sys/compat/mach/mach_exec.h index ea649bed6ce3..1d60afaf7a05 100644 --- a/sys/compat/mach/mach_exec.h +++ b/sys/compat/mach/mach_exec.h @@ -1,4 +1,4 @@ -/* $NetBSD: mach_exec.h,v 1.14 2003/01/30 19:14:19 manu Exp $ */ +/* $NetBSD: mach_exec.h,v 1.15 2003/02/02 19:07:17 manu Exp $ */ /*- * Copyright (c) 2001 The NetBSD Foundation, Inc. @@ -53,6 +53,8 @@ struct mach_emuldata { struct mach_port *med_kernel; /* task kernel port */ struct mach_port *med_host; /* task host port */ struct mach_port *med_exception;/* task exception port */ + + int med_dirty_thid; /* Thread id not yet initialized */ }; int exec_mach_copyargs(struct proc *, struct exec_package *, diff --git a/sys/compat/mach/mach_host.c b/sys/compat/mach/mach_host.c index 58a8a9b553d4..db301156e61a 100644 --- a/sys/compat/mach/mach_host.c +++ b/sys/compat/mach/mach_host.c @@ -1,4 +1,4 @@ -/* $NetBSD: mach_host.c,v 1.21 2003/01/21 04:06:07 matt Exp $ */ +/* $NetBSD: mach_host.c,v 1.22 2003/02/02 19:07:17 manu Exp $ */ /*- * Copyright (c) 2002-2003 The NetBSD Foundation, Inc. @@ -37,7 +37,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: mach_host.c,v 1.21 2003/01/21 04:06:07 matt Exp $"); +__KERNEL_RCSID(0, "$NetBSD: mach_host.c,v 1.22 2003/02/02 19:07:17 manu Exp $"); #include #include @@ -197,17 +197,13 @@ int mach_host_get_io_master(args) struct mach_trap_args *args; { - mach_host_get_clock_service_request_t *req = args->smsg; - mach_host_get_clock_service_reply_t *rep = args->rmsg; + mach_host_get_io_master_request_t *req = args->smsg; + mach_host_get_io_master_reply_t *rep = args->rmsg; size_t *msglen = args->rsize; struct lwp *l = args->l; + struct mach_right *mr; - /* - * XXX Find out what this is supposed - * to do and implement it - */ - printf("pid %d.%d: unimplemented mach_host_get_io_master\n", - l->l_proc->p_pid, l->l_lid); + mr = mach_right_get(mach_io_master_port, l, MACH_PORT_TYPE_SEND, 0); rep->rep_msgh.msgh_bits = MACH_MSGH_REPLY_LOCAL_BITS(MACH_MSG_TYPE_MOVE_SEND_ONCE) | @@ -215,6 +211,9 @@ mach_host_get_io_master(args) rep->rep_msgh.msgh_size = sizeof(*rep) - sizeof(rep->rep_trailer); rep->rep_msgh.msgh_local_port = req->req_msgh.msgh_local_port; rep->rep_msgh.msgh_id = req->req_msgh.msgh_id + 100; + rep->rep_body.msgh_descriptor_count = 1; /* XXX why? */ + rep->rep_iomaster.name = (mach_port_t)mr->mr_name; + rep->rep_iomaster.disposition = 0x11; /* XXX */ rep->rep_trailer.msgh_trailer_size = 8; *msglen = sizeof(*rep); diff --git a/sys/compat/mach/mach_host.h b/sys/compat/mach/mach_host.h index cd0eb3a55107..073036cfef17 100644 --- a/sys/compat/mach/mach_host.h +++ b/sys/compat/mach/mach_host.h @@ -1,4 +1,4 @@ -/* $NetBSD: mach_host.h,v 1.9 2003/01/04 15:15:01 manu Exp $ */ +/* $NetBSD: mach_host.h,v 1.10 2003/02/02 19:07:17 manu Exp $ */ /*- * Copyright (c) 2002-2003 The NetBSD Foundation, Inc. @@ -147,7 +147,7 @@ typedef struct { typedef struct { mach_msg_header_t req_msgh; -} mach_host_get_io_master_repquest_t; +} mach_host_get_io_master_request_t; typedef struct { mach_msg_header_t rep_msgh; diff --git a/sys/compat/mach/mach_namemap.c b/sys/compat/mach/mach_namemap.c index 14fe7870c42c..0dc60fa0cf4b 100644 --- a/sys/compat/mach/mach_namemap.c +++ b/sys/compat/mach/mach_namemap.c @@ -1,4 +1,4 @@ -/* $NetBSD: mach_namemap.c,v 1.12 2003/01/04 15:15:01 manu Exp $ */ +/* $NetBSD: mach_namemap.c,v 1.13 2003/02/02 19:07:18 manu Exp $ */ /*- * Copyright (c) 2002-2003 The NetBSD Foundation, Inc. @@ -37,7 +37,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: mach_namemap.c,v 1.12 2003/01/04 15:15:01 manu Exp $"); +__KERNEL_RCSID(0, "$NetBSD: mach_namemap.c,v 1.13 2003/02/02 19:07:18 manu Exp $"); #include #include @@ -63,6 +63,7 @@ struct mach_subsystem_namemap mach_namemap[] = { { 1000, mach_clock_get_time, "clock_get_time" }, { 3201, mach_port_type, "port_type" }, { 3204, mach_port_allocate, "port_allocate" }, + { 3205, mach_port_destroy, "port_destroy" }, { 3206, mach_port_deallocate, "port_deallocate" }, { 3212, mach_port_move_member, "port_move_member" }, { 3214, mach_port_insert_right, "port_insert_right" }, diff --git a/sys/compat/mach/mach_port.c b/sys/compat/mach/mach_port.c index cc0dfd3095cc..9019ef5e6bfe 100644 --- a/sys/compat/mach/mach_port.c +++ b/sys/compat/mach/mach_port.c @@ -1,4 +1,4 @@ -/* $NetBSD: mach_port.c,v 1.32 2003/01/24 21:37:03 manu Exp $ */ +/* $NetBSD: mach_port.c,v 1.33 2003/02/02 19:07:18 manu Exp $ */ /*- * Copyright (c) 2002-2003 The NetBSD Foundation, Inc. @@ -39,7 +39,7 @@ #include "opt_compat_darwin.h" #include -__KERNEL_RCSID(0, "$NetBSD: mach_port.c,v 1.32 2003/01/24 21:37:03 manu Exp $"); +__KERNEL_RCSID(0, "$NetBSD: mach_port.c,v 1.33 2003/02/02 19:07:18 manu Exp $"); #include #include @@ -68,6 +68,7 @@ static struct pool mach_right_pool; struct mach_port *mach_bootstrap_port; struct mach_port *mach_clock_port; +struct mach_port *mach_io_master_port; struct mach_port *mach_saved_bootstrap_port; int @@ -164,6 +165,32 @@ mach_port_deallocate(args) return 0; } +int +mach_port_destroy(args) + struct mach_trap_args *args; +{ + mach_port_destroy_request_t *req = args->smsg; + mach_port_destroy_reply_t *rep = args->rmsg; + size_t *msglen = args->rsize; + struct lwp *l = args->l; + mach_port_t mn; + struct mach_right *mr; + + mn = req->req_name; + if ((mr = mach_right_check(mn, l, MACH_PORT_TYPE_REF_RIGHTS)) != NULL) + mach_right_put(mr, MACH_PORT_TYPE_REF_RIGHTS); + + rep->rep_msgh.msgh_bits = + MACH_MSGH_REPLY_LOCAL_BITS(MACH_MSG_TYPE_MOVE_SEND_ONCE); + rep->rep_msgh.msgh_size = sizeof(*rep) - sizeof(rep->rep_trailer); + rep->rep_msgh.msgh_local_port = req->req_msgh.msgh_local_port; + rep->rep_msgh.msgh_id = req->req_msgh.msgh_id + 100; + rep->rep_trailer.msgh_trailer_size = 8; + + *msglen = sizeof(*rep); + return 0; +} + int mach_port_allocate(args) struct mach_trap_args *args; @@ -397,6 +424,7 @@ mach_port_init(void) mach_bootstrap_port = mach_port_get(); mach_clock_port = mach_port_get(); + mach_io_master_port = mach_port_get(); mach_saved_bootstrap_port = mach_bootstrap_port; return; diff --git a/sys/compat/mach/mach_port.h b/sys/compat/mach/mach_port.h index 5c6a459e23d6..fbfd7847f69d 100644 --- a/sys/compat/mach/mach_port.h +++ b/sys/compat/mach/mach_port.h @@ -1,4 +1,4 @@ -/* $NetBSD: mach_port.h,v 1.17 2003/01/21 04:06:08 matt Exp $ */ +/* $NetBSD: mach_port.h,v 1.18 2003/02/02 19:07:18 manu Exp $ */ /*- * Copyright (c) 2002-2003 The NetBSD Foundation, Inc. @@ -202,6 +202,21 @@ typedef struct { mach_msg_trailer_t rep_trailer; } mach_port_move_member_reply_t; +/* port_destroy */ + +typedef struct { + mach_msg_header_t req_msgh; + mach_ndr_record_t req_ndr; + mach_port_name_t req_name; +} mach_port_destroy_request_t; + +typedef struct { + mach_msg_header_t rep_msgh; + mach_ndr_record_t rep_ndr; + mach_kern_return_t rep_retval; + mach_msg_trailer_t rep_trailer; +} mach_port_destroy_reply_t; + int mach_port_deallocate(struct mach_trap_args *); int mach_port_allocate(struct mach_trap_args *); int mach_port_insert_right(struct mach_trap_args *); @@ -209,8 +224,10 @@ int mach_port_type(struct mach_trap_args *); int mach_port_set_attributes(struct mach_trap_args *); int mach_port_insert_member(struct mach_trap_args *); int mach_port_move_member(struct mach_trap_args *); +int mach_port_destroy(struct mach_trap_args *); extern struct mach_port *mach_clock_port; +extern struct mach_port *mach_io_master_port; extern struct mach_port *mach_bootstrap_port; extern struct mach_port *mach_saved_bootstrap_port;