- WindowServer wants io_master_port? Give it a port!

- introduce mach_port_destroy (badly emulated for now)
- on fork/exec, don't set l_private, as the process might be not mature
enough to survive a proc_representative_lwp call (-> kernel panic)

Once we give WindowServer the io_master_port, it sends a message to it:

   305 WindowServer MMSG  id 2804 [0x1310009 -> 0x131000e] -12016 bytes, flags 0
x1513
   0x0000  0x00001513 0xffffd110 0x0131000e 0x01310009   .........1...1..
   0x0010  0xffffcfd0 0x00000af4 0x00000000 0x00000000   ................
   0x0020  0xffffcf60 0x00000052 0x3c646963 0x74204944   ...`...R<dict ID
   0x0030  0x3d223022 0x3e3c6b65 0x793e494f 0x50726f76   ="0"><key>IOProv
   0x0040  0x69646572 0x436c6173 0x733c2f6b 0x65793e3c   iderClass</key><
   0x0050  0x73747269 0x6e672049 0x443d2231 0x223e494f   string ID="1">IO
   0x0060  0x48494453 0x79737465 0x6d3c2f73 0x7472696e   HIDSystem</strin
   0x0070  0x673e3c2f 0x64696374 0x3e0047cc              g></dict>.G.

Did you ever dreamt about system call arguments in XML?
This commit is contained in:
manu 2003-02-02 19:06:31 +00:00
parent 5442e1ce7f
commit 2cd19ab0b2
8 changed files with 83 additions and 26 deletions

View File

@ -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 <sys/cdefs.h>
__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 <sys/types.h>
#include <sys/systm.h>
@ -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;

View File

@ -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 <sys/cdefs.h>
__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 <sys/param.h>
#include <sys/systm.h>
@ -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;
}

View File

@ -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 *,

View File

@ -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 <sys/cdefs.h>
__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 <sys/types.h>
#include <sys/malloc.h>
@ -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);

View File

@ -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;

View File

@ -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 <sys/cdefs.h>
__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 <sys/types.h>
#include <sys/param.h>
@ -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" },

View File

@ -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 <sys/cdefs.h>
__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 <sys/types.h>
#include <sys/param.h>
@ -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;

View File

@ -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;