FIrst attempt at mach ports and rights, which are needed if we ever want
to implement messages between kernel and userland. While we are there, cleanup some debug messages.
This commit is contained in:
parent
a2e85e2b1c
commit
b8a9df5e21
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: mach_errno.c,v 1.7 2002/12/09 21:53:28 manu Exp $ */
|
||||
/* $NetBSD: mach_errno.c,v 1.8 2002/12/15 00:40:24 manu Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2002 The NetBSD Foundation, Inc.
|
||||
@ -37,11 +37,12 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: mach_errno.c,v 1.7 2002/12/09 21:53:28 manu Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: mach_errno.c,v 1.8 2002/12/15 00:40:24 manu Exp $");
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/null.h>
|
||||
#include <sys/queue.h>
|
||||
#include <sys/errno.h>
|
||||
|
||||
#include <compat/mach/mach_types.h>
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: mach_exec.c,v 1.14 2002/12/12 23:18:20 manu Exp $ */
|
||||
/* $NetBSD: mach_exec.c,v 1.15 2002/12/15 00:40:25 manu Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2001 The NetBSD Foundation, Inc.
|
||||
@ -37,7 +37,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: mach_exec.c,v 1.14 2002/12/12 23:18:20 manu Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: mach_exec.c,v 1.15 2002/12/15 00:40:25 manu Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
@ -54,12 +54,16 @@ __KERNEL_RCSID(0, "$NetBSD: mach_exec.c,v 1.14 2002/12/12 23:18:20 manu Exp $");
|
||||
|
||||
#include <compat/mach/mach_types.h>
|
||||
#include <compat/mach/mach_message.h>
|
||||
#include <compat/mach/mach_port.h>
|
||||
#include <compat/mach/mach_semaphore.h>
|
||||
#include <compat/mach/mach_exec.h>
|
||||
|
||||
static int mach_cold = 1; /* Have we initialized COMPAT_MACH structures? */
|
||||
|
||||
static void mach_e_proc_exec(struct proc *, struct exec_package *);
|
||||
static void mach_e_proc_fork(struct proc *, struct proc *);
|
||||
static void mach_e_proc_exit(struct proc *);
|
||||
static void mach_init(void);
|
||||
|
||||
extern char sigcode[], esigcode[];
|
||||
extern struct sysent sysent[];
|
||||
@ -220,6 +224,13 @@ mach_e_proc_init(p, vmspace)
|
||||
{
|
||||
struct mach_emuldata *med;
|
||||
|
||||
/*
|
||||
* Initialize various things if needed.
|
||||
* XXX Not the best place for that.
|
||||
*/
|
||||
if (mach_cold == 1)
|
||||
mach_init();
|
||||
|
||||
if (!p->p_emuldata)
|
||||
p->p_emuldata = malloc(sizeof(struct mach_emuldata),
|
||||
M_EMULDATA, M_WAITOK | M_ZERO);
|
||||
@ -227,9 +238,21 @@ mach_e_proc_init(p, vmspace)
|
||||
med = (struct mach_emuldata *)p->p_emuldata;
|
||||
med->med_p = 0;
|
||||
|
||||
/* Initialize semaphores if needed. Not the best place for that... */
|
||||
if (mach_semaphore_cold == 1)
|
||||
mach_semaphore_init();
|
||||
LIST_INIT(&med->med_recv);
|
||||
LIST_INIT(&med->med_send);
|
||||
LIST_INIT(&med->med_sendonce);
|
||||
lockinit(&med->med_rlock, PZERO|PCATCH, "mach_port", 0, 0);
|
||||
lockinit(&med->med_slock, PZERO|PCATCH, "mach_port", 0, 0);
|
||||
lockinit(&med->med_solock, PZERO|PCATCH, "mach_port", 0, 0);
|
||||
|
||||
med->med_bootstrap = mach_port_get(NULL);
|
||||
med->med_kernel = mach_port_get(NULL);
|
||||
med->med_host = mach_port_get(NULL);
|
||||
|
||||
/* Make sure they will not be deallocated */
|
||||
med->med_bootstrap->mp_refcount++;
|
||||
med->med_kernel->mp_refcount++;
|
||||
med->med_host->mp_refcount++;
|
||||
|
||||
return;
|
||||
}
|
||||
@ -245,3 +268,15 @@ mach_e_proc_exit(p)
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static void
|
||||
mach_init(void)
|
||||
{
|
||||
mach_semaphore_init();
|
||||
mach_message_init();
|
||||
mach_port_init();
|
||||
|
||||
mach_cold = 0;
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: mach_exec.h,v 1.7 2002/12/12 23:18:20 manu Exp $ */
|
||||
/* $NetBSD: mach_exec.h,v 1.8 2002/12/15 00:40:25 manu Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2001 The NetBSD Foundation, Inc.
|
||||
@ -44,8 +44,20 @@
|
||||
#include <compat/mach/mach_types.h>
|
||||
|
||||
struct mach_emuldata {
|
||||
mach_cproc_t med_p;
|
||||
int med_thpri;
|
||||
mach_cproc_t med_p; /* Thread id */
|
||||
int med_thpri; /* Saved priority */
|
||||
LIST_HEAD(med_recv, /* List of receive rights */
|
||||
mach_right) med_recv;
|
||||
LIST_HEAD(med_send, /* List of send rights */
|
||||
mach_right) med_send;
|
||||
LIST_HEAD(med_sendonce, /* List of send once rights */
|
||||
mach_right) med_sendonce;
|
||||
struct lock med_rlock; /* Lock on recv rights list */
|
||||
struct lock med_slock; /* Lock on send rights list */
|
||||
struct lock med_solock; /* Lock on send once rights list */
|
||||
struct mach_port *med_bootstrap;/* task bootstrap port */
|
||||
struct mach_port *med_kernel; /* task kernel port */
|
||||
struct mach_port *med_host; /* task host port */
|
||||
};
|
||||
|
||||
int exec_mach_copyargs(struct proc *, struct exec_package *,
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: mach_host.c,v 1.14 2002/12/09 21:29:24 manu Exp $ */
|
||||
/* $NetBSD: mach_host.c,v 1.15 2002/12/15 00:40:25 manu Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2002 The NetBSD Foundation, Inc.
|
||||
@ -37,7 +37,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: mach_host.c,v 1.14 2002/12/09 21:29:24 manu Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: mach_host.c,v 1.15 2002/12/15 00:40:25 manu Exp $");
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/malloc.h>
|
||||
@ -85,7 +85,6 @@ mach_host_info(p, msgh, maxlen, dst)
|
||||
struct mach_host_basic_info *info
|
||||
= (struct mach_host_basic_info *)&rep.rep_data[0];
|
||||
|
||||
DPRINTF(("mach_host_info(BASIC_INFO);\n"));
|
||||
rep.rep_msgh.msgh_size = sizeof(*reps)
|
||||
- sizeof(rep.rep_trailer) + sizeof(*info);
|
||||
rep.rep_count = sizeof(*info) / sizeof(mach_integer_t);
|
||||
@ -102,7 +101,6 @@ mach_host_info(p, msgh, maxlen, dst)
|
||||
struct mach_host_priority_info *info
|
||||
= (struct mach_host_priority_info *)&rep.rep_data[0];
|
||||
|
||||
DPRINTF(("mach_host_info(PRIORITY_INFO);\n"));
|
||||
rep.rep_msgh.msgh_size = sizeof(*reps)
|
||||
- sizeof(rep.rep_trailer) + sizeof(*info);
|
||||
rep.rep_count = sizeof(*info) / sizeof(mach_integer_t);
|
||||
@ -117,9 +115,6 @@ mach_host_info(p, msgh, maxlen, dst)
|
||||
|
||||
case MACH_HOST_SEMAPHORE_TRAPS:
|
||||
case MACH_HOST_MACH_MSG_TRAP:
|
||||
DPRINTF(("mach_host_info(%s);\n",
|
||||
req.req_flavor == MACH_HOST_SEMAPHORE_TRAPS ?
|
||||
"SEMAPHORE_TRAPS" : "MACH_MSG_TRAP"));
|
||||
reps = (mach_host_info_reply_simple_t *)&rep;
|
||||
reps->rep_msgh.msgh_size =
|
||||
sizeof(*reps) - sizeof(reps->rep_trailer);
|
||||
@ -129,8 +124,8 @@ mach_host_info(p, msgh, maxlen, dst)
|
||||
|
||||
case MACH_HOST_SCHED_INFO:
|
||||
case MACH_HOST_RESOURCE_SIZES:
|
||||
DPRINTF(("Unimplemented host_info flavor %d\n",
|
||||
req.req_flavor));
|
||||
uprintf("mach_host_info() Unimplemented host_info flavor %d\n",
|
||||
req.req_flavor);
|
||||
default:
|
||||
uprintf("Unknown host_info flavor %d\n", req.req_flavor);
|
||||
rep.rep_retval = native_to_mach_errno[EINVAL];
|
||||
@ -155,8 +150,6 @@ mach_host_page_size(p, msgh, maxlen, dst)
|
||||
if ((error = copyin(msgh, &req, sizeof(req))) != 0)
|
||||
return error;
|
||||
|
||||
DPRINTF(("mach_host_page_size();\n"));
|
||||
|
||||
bzero(&rep, sizeof(rep));
|
||||
|
||||
rep.rep_msgh.msgh_bits =
|
||||
@ -184,8 +177,6 @@ mach_host_get_clock_service(p, msgh, maxlen, dst)
|
||||
if ((error = copyin(msgh, &req, sizeof(req))) != 0)
|
||||
return error;
|
||||
|
||||
DPRINTF(("mach_host_get_clock_service();\n"));
|
||||
|
||||
bzero(&rep, sizeof(rep));
|
||||
|
||||
rep.rep_msgh.msgh_bits =
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: mach_message.c,v 1.2 2002/12/09 21:29:24 manu Exp $ */
|
||||
/* $NetBSD: mach_message.c,v 1.3 2002/12/15 00:40:25 manu Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2002 The NetBSD Foundation, Inc.
|
||||
@ -37,7 +37,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: mach_message.c,v 1.2 2002/12/09 21:29:24 manu Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: mach_message.c,v 1.3 2002/12/15 00:40:25 manu Exp $");
|
||||
|
||||
#include "opt_ktrace.h"
|
||||
#include "opt_compat_mach.h" /* For COMPAT_MACH in <sys/ktrace.h> */
|
||||
@ -47,6 +47,9 @@ __KERNEL_RCSID(0, "$NetBSD: mach_message.c,v 1.2 2002/12/09 21:29:24 manu Exp $"
|
||||
#include <sys/systm.h>
|
||||
#include <sys/signal.h>
|
||||
#include <sys/proc.h>
|
||||
#include <sys/queue.h>
|
||||
#include <sys/malloc.h>
|
||||
#include <sys/pool.h>
|
||||
#ifdef KTRACE
|
||||
#include <sys/ktrace.h>
|
||||
#endif
|
||||
@ -57,6 +60,9 @@ __KERNEL_RCSID(0, "$NetBSD: mach_message.c,v 1.2 2002/12/09 21:29:24 manu Exp $"
|
||||
#include <compat/mach/mach_clock.h>
|
||||
#include <compat/mach/mach_syscallargs.h>
|
||||
|
||||
/* Mach message pool */
|
||||
static struct pool mach_message_pool;
|
||||
|
||||
#ifdef DEBUG_MACH
|
||||
static void mach_print_msg_header_t(mach_msg_header_t *);
|
||||
static char *mach_print_msg_bits_t(mach_msg_bits_t, char *, size_t);
|
||||
@ -244,3 +250,30 @@ mach_msg_return(p, rep, msgh, msglen, maxlen, dst)
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
mach_message_init(void)
|
||||
{
|
||||
pool_init(&mach_message_pool, sizeof (struct mach_message),
|
||||
0, 0, 128, "mach_message_pool", NULL);
|
||||
return;
|
||||
}
|
||||
|
||||
struct mach_message *
|
||||
mach_message_get(void)
|
||||
{
|
||||
struct mach_message *mm;
|
||||
|
||||
mm = (struct mach_message *)pool_get(&mach_message_pool, M_WAITOK);
|
||||
|
||||
return mm;
|
||||
}
|
||||
|
||||
void
|
||||
mach_message_put(mm)
|
||||
struct mach_message *mm;
|
||||
{
|
||||
pool_put(&mach_message_pool, mm);
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: mach_message.h,v 1.7 2002/12/09 21:29:24 manu Exp $ */
|
||||
/* $NetBSD: mach_message.h,v 1.8 2002/12/15 00:40:25 manu Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2001 The NetBSD Foundation, Inc.
|
||||
@ -166,4 +166,18 @@ extern struct mach_subsystem_namemap mach_namemap[];
|
||||
int mach_msg_return(struct proc *, mach_msg_header_t *, mach_msg_header_t *,
|
||||
size_t, size_t, mach_msg_header_t *);
|
||||
|
||||
|
||||
|
||||
/* In-kernel Mach messages description */
|
||||
struct mach_message {
|
||||
mach_msg_header_t *mm_msg; /* In-kernel copy of the message */
|
||||
size_t mm_size; /* Message size */
|
||||
TAILQ_ENTRY(mach_message) mm_list;
|
||||
/* List of pending messages */
|
||||
};
|
||||
|
||||
void mach_message_init(void);
|
||||
struct mach_message *mach_message_get(void);
|
||||
void mach_message_put(struct mach_message *);
|
||||
|
||||
#endif /* !_MACH_MESSAGE_H_ */
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: mach_port.c,v 1.14 2002/12/12 00:29:24 manu Exp $ */
|
||||
/* $NetBSD: mach_port.c,v 1.15 2002/12/15 00:40:25 manu Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2002 The NetBSD Foundation, Inc.
|
||||
@ -37,29 +37,43 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: mach_port.c,v 1.14 2002/12/12 00:29:24 manu Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: mach_port.c,v 1.15 2002/12/15 00:40:25 manu Exp $");
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/signal.h>
|
||||
#include <sys/pool.h>
|
||||
#include <sys/queue.h>
|
||||
#include <sys/malloc.h>
|
||||
#include <sys/proc.h>
|
||||
|
||||
#include <compat/mach/mach_types.h>
|
||||
#include <compat/mach/mach_message.h>
|
||||
#include <compat/mach/mach_port.h>
|
||||
#include <compat/mach/mach_clock.h>
|
||||
#include <compat/mach/mach_exec.h>
|
||||
#include <compat/mach/mach_errno.h>
|
||||
#include <compat/mach/mach_syscallargs.h>
|
||||
|
||||
/* Port list, lock, pool */
|
||||
static LIST_HEAD(mach_port_list, mach_port) mach_port_list;
|
||||
static struct lock mach_port_list_lock;
|
||||
static struct pool mach_port_pool;
|
||||
/* Rights pool */
|
||||
static struct pool mach_right_pool;
|
||||
|
||||
int
|
||||
mach_sys_reply_port(p, v, retval)
|
||||
struct proc *p;
|
||||
void *v;
|
||||
register_t *retval;
|
||||
{
|
||||
static int current_port = 0x80b;
|
||||
struct mach_right *mr;
|
||||
|
||||
mr = mach_right_get(mach_port_get(p), p, MACH_PORT_RIGHT_RECEIVE);
|
||||
*retval = (register_t)mr;
|
||||
|
||||
*retval = current_port; /* XXX */
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -69,7 +83,17 @@ mach_sys_thread_self_trap(p, v, retval)
|
||||
void *v;
|
||||
register_t *retval;
|
||||
{
|
||||
*retval = 0; /* XXX */
|
||||
struct mach_emuldata *med;
|
||||
struct mach_right *mr;
|
||||
|
||||
/*
|
||||
* XXX for now thread kernel port and task kernel port are the same
|
||||
* awaiting for struct lwp ...
|
||||
*/
|
||||
med = (struct mach_emuldata *)p->p_emuldata;
|
||||
mr = mach_right_get(med->med_kernel, p, MACH_PORT_RIGHT_SEND);
|
||||
*retval = (register_t)mr;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -80,7 +104,13 @@ mach_sys_task_self_trap(p, v, retval)
|
||||
void *v;
|
||||
register_t *retval;
|
||||
{
|
||||
*retval = 0xa07; /* XXX */
|
||||
struct mach_emuldata *med;
|
||||
struct mach_right *mr;
|
||||
|
||||
med = (struct mach_emuldata *)p->p_emuldata;
|
||||
mr = mach_right_get(med->med_kernel, p, MACH_PORT_RIGHT_SEND);
|
||||
*retval = (register_t)mr;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -91,7 +121,13 @@ mach_sys_host_self_trap(p, v, retval)
|
||||
void *v;
|
||||
register_t *retval;
|
||||
{
|
||||
*retval = 0x90b; /* XXX */
|
||||
struct mach_emuldata *med;
|
||||
struct mach_right *mr;
|
||||
|
||||
med = (struct mach_emuldata *)p->p_emuldata;
|
||||
mr = mach_right_get(med->med_host, p, MACH_PORT_RIGHT_SEND);
|
||||
*retval = (register_t)mr;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -104,10 +140,18 @@ mach_port_deallocate(p, msgh, maxlen, dst)
|
||||
{
|
||||
mach_port_deallocate_request_t req;
|
||||
mach_port_deallocate_reply_t rep;
|
||||
struct mach_right *mr;
|
||||
int error;
|
||||
|
||||
if ((error = copyin(msgh, &req, sizeof(req))) != 0)
|
||||
return error;
|
||||
|
||||
mr = (struct mach_right *)req.req_name;
|
||||
if (mach_right_check(mr, p, MACH_PORT_TYPE_PORT_RIGHTS) != 0)
|
||||
mach_right_put(mr);
|
||||
else
|
||||
return MACH_MSG_ERROR(p, msgh,
|
||||
&req, &rep, EINVAL, maxlen, dst);
|
||||
|
||||
bzero(&rep, sizeof(rep));
|
||||
|
||||
@ -130,11 +174,31 @@ mach_port_allocate(p, msgh, maxlen, dst)
|
||||
{
|
||||
mach_port_allocate_request_t req;
|
||||
mach_port_allocate_reply_t rep;
|
||||
struct mach_right *mr;
|
||||
int error;
|
||||
|
||||
if ((error = copyin(msgh, &req, sizeof(req))) != 0)
|
||||
return error;
|
||||
|
||||
switch (req.req_right) {
|
||||
case MACH_PORT_RIGHT_RECEIVE:
|
||||
mr = mach_right_get(mach_port_get(p), p, req.req_right);
|
||||
break;
|
||||
|
||||
case MACH_PORT_RIGHT_DEAD_NAME:
|
||||
mr = mach_right_get(mach_port_get(NULL), p, req.req_right);
|
||||
break;
|
||||
|
||||
case MACH_PORT_RIGHT_PORT_SET:
|
||||
mr = mach_right_get(mach_port_get(NULL), p, req.req_right);
|
||||
break;
|
||||
|
||||
default:
|
||||
uprintf("mach_port_allocate: unknown right %d\n",
|
||||
req.req_right);
|
||||
break;
|
||||
}
|
||||
|
||||
bzero(&rep, sizeof(rep));
|
||||
|
||||
rep.rep_msgh.msgh_bits =
|
||||
@ -142,6 +206,7 @@ mach_port_allocate(p, msgh, maxlen, dst)
|
||||
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_name = (mach_port_name_t)mr;
|
||||
rep.rep_trailer.msgh_trailer_size = 8;
|
||||
|
||||
return MACH_MSG_RETURN(p, &rep, msgh, sizeof(rep), maxlen, dst);
|
||||
@ -156,11 +221,65 @@ mach_port_insert_right(p, msgh, maxlen, dst)
|
||||
{
|
||||
mach_port_insert_right_request_t req;
|
||||
mach_port_insert_right_reply_t rep;
|
||||
struct mach_right *mr;
|
||||
struct mach_right *tmr;
|
||||
struct mach_right *nmr;
|
||||
struct proc *tp;
|
||||
int error;
|
||||
|
||||
if ((error = copyin(msgh, &req, sizeof(req))) != 0)
|
||||
return error;
|
||||
|
||||
mr = (struct mach_right *)req.req_name;
|
||||
tmr = (struct mach_right *)req.req_msgh.msgh_local_port;
|
||||
nmr = NULL;
|
||||
|
||||
tp = tmr->mr_p; /* The target process */
|
||||
|
||||
switch (req.req_poly.name) {
|
||||
case MACH_MSG_TYPE_MAKE_SEND:
|
||||
case MACH_MSG_TYPE_MOVE_SEND:
|
||||
case MACH_MSG_TYPE_COPY_SEND:
|
||||
/*
|
||||
* XXX We require that requester has send right.
|
||||
* Not sure this is right
|
||||
*/
|
||||
if (mach_right_check(mr, p, MACH_PORT_TYPE_SEND) == 0)
|
||||
return MACH_MSG_ERROR(p, msgh, &req, &rep,
|
||||
EPERM, maxlen, dst);
|
||||
nmr = mach_right_get(mr->mr_port, tp, MACH_PORT_RIGHT_SEND);
|
||||
break;
|
||||
|
||||
case MACH_MSG_TYPE_MAKE_SEND_ONCE:
|
||||
case MACH_MSG_TYPE_MOVE_SEND_ONCE:
|
||||
/*
|
||||
* XXX We require that requester has send right.
|
||||
* Not sure this is right
|
||||
*/
|
||||
if (mach_right_check(mr, p, MACH_PORT_TYPE_SEND_ONCE) == 0)
|
||||
return MACH_MSG_ERROR(p, msgh, &req, &rep,
|
||||
EPERM, maxlen, dst);
|
||||
nmr = mach_right_get(mr->mr_port,
|
||||
tp, MACH_PORT_RIGHT_SEND_ONCE);
|
||||
break;
|
||||
|
||||
case MACH_MSG_TYPE_MOVE_RECEIVE:
|
||||
/*
|
||||
* XXX We require that requester has any right.
|
||||
* Not sure this is right
|
||||
*/
|
||||
if (mach_right_check(mr, p, MACH_PORT_TYPE_PORT_RIGHTS) == 0)
|
||||
return MACH_MSG_ERROR(p, msgh, &req, &rep,
|
||||
EPERM, maxlen, dst);
|
||||
nmr = mach_right_get(mr->mr_port, tp, MACH_PORT_RIGHT_RECEIVE);
|
||||
break;
|
||||
|
||||
default:
|
||||
uprintf("mach_port_insert_right: unknown right %d\n",
|
||||
req.req_poly.name);
|
||||
break;
|
||||
}
|
||||
|
||||
bzero(&rep, sizeof(rep));
|
||||
|
||||
rep.rep_msgh.msgh_bits =
|
||||
@ -182,11 +301,16 @@ mach_port_type(p, msgh, maxlen, dst)
|
||||
{
|
||||
mach_port_type_request_t req;
|
||||
mach_port_type_reply_t rep;
|
||||
struct mach_right *mr;
|
||||
int error;
|
||||
|
||||
if ((error = copyin(msgh, &req, sizeof(req))) != 0)
|
||||
return error;
|
||||
|
||||
mr = (struct mach_right *)req.req_name;
|
||||
if (mach_right_check(mr, p, MACH_PORT_TYPE_PORT_RIGHTS) == 0)
|
||||
return MACH_MSG_ERROR(p, msgh, &req, &rep, EPERM, maxlen, dst);
|
||||
|
||||
bzero(&rep, sizeof(rep));
|
||||
|
||||
rep.rep_msgh.msgh_bits =
|
||||
@ -195,7 +319,7 @@ mach_port_type(p, msgh, maxlen, dst)
|
||||
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_retval = 0;
|
||||
rep.rep_ptype = 0;
|
||||
rep.rep_ptype = mr->mr_type;
|
||||
rep.rep_trailer.msgh_trailer_size = 8;
|
||||
|
||||
return MACH_MSG_RETURN(p, &rep, msgh, sizeof(rep), maxlen, dst);
|
||||
@ -238,6 +362,7 @@ mach_port_set_attributes(p, msgh, maxlen, dst)
|
||||
return MACH_MSG_RETURN(p, &rep, msgh, sizeof(rep), maxlen, dst);
|
||||
}
|
||||
|
||||
/* XXX need to implement port sets before doing that */
|
||||
int
|
||||
mach_port_insert_member(p, msgh, maxlen, dst)
|
||||
struct proc *p;
|
||||
@ -264,6 +389,7 @@ mach_port_insert_member(p, msgh, maxlen, dst)
|
||||
return MACH_MSG_RETURN(p, &rep, msgh, sizeof(rep), maxlen, dst);
|
||||
}
|
||||
|
||||
/* XXX need to implement port sets before doing that */
|
||||
int
|
||||
mach_port_move_member(p, msgh, maxlen, dst)
|
||||
struct proc *p;
|
||||
@ -290,3 +416,258 @@ mach_port_move_member(p, msgh, maxlen, dst)
|
||||
return MACH_MSG_RETURN(p, &rep, msgh, sizeof(rep), maxlen, dst);
|
||||
}
|
||||
|
||||
void
|
||||
mach_port_init(void)
|
||||
{
|
||||
LIST_INIT(&mach_port_list);
|
||||
lockinit(&mach_port_list_lock, PZERO|PCATCH, "mach_port", 0, 0);
|
||||
pool_init(&mach_port_pool, sizeof (struct mach_port),
|
||||
0, 0, 128, "mach_port_pool", NULL);
|
||||
pool_init(&mach_right_pool, sizeof (struct mach_right),
|
||||
0, 0, 128, "mach_right_pool", NULL);
|
||||
return;
|
||||
}
|
||||
|
||||
struct mach_port *
|
||||
mach_port_get(p)
|
||||
struct proc *p;
|
||||
{
|
||||
struct mach_port *mp;
|
||||
|
||||
mp = (struct mach_port *)pool_get(&mach_port_pool, M_WAITOK);
|
||||
mp->mp_recv = p;
|
||||
mp->mp_count = 0;
|
||||
TAILQ_INIT(&mp->mp_msglist);
|
||||
lockinit(&mp->mp_msglock, PZERO|PCATCH, "mach_port", 0, 0);
|
||||
|
||||
lockmgr(&mach_port_list_lock, LK_EXCLUSIVE, NULL);
|
||||
LIST_INSERT_HEAD(&mach_port_list, mp, mp_alllist);
|
||||
lockmgr(&mach_port_list_lock, LK_RELEASE, NULL);
|
||||
|
||||
return mp;
|
||||
}
|
||||
|
||||
void
|
||||
mach_port_put(mp)
|
||||
struct mach_port *mp;
|
||||
{
|
||||
struct mach_message *mm;
|
||||
|
||||
if (mp->mp_refcount != 0)
|
||||
uprintf("mach_port_put: attempt to free a referenced port\n");
|
||||
|
||||
lockmgr(&mp->mp_msglock, LK_EXCLUSIVE, NULL);
|
||||
while ((mm = TAILQ_FIRST(&mp->mp_msglist)) != NULL)
|
||||
mach_message_put(mm);
|
||||
lockmgr(&mp->mp_msglock, LK_RELEASE, NULL);
|
||||
lockmgr(&mp->mp_msglock, LK_DRAIN, NULL);
|
||||
|
||||
lockmgr(&mach_port_list_lock, LK_EXCLUSIVE, NULL);
|
||||
LIST_REMOVE(mp, mp_alllist);
|
||||
lockmgr(&mach_port_list_lock, LK_RELEASE, NULL);
|
||||
|
||||
pool_put(&mach_port_pool, mp);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
struct mach_right *
|
||||
mach_right_get(mp, p, type)
|
||||
struct mach_port *mp;
|
||||
struct proc *p;
|
||||
int type;
|
||||
{
|
||||
struct mach_right *mr;
|
||||
struct mach_right *omr;
|
||||
struct mach_emuldata *med;
|
||||
|
||||
mr = pool_get(&mach_right_pool, M_WAITOK);
|
||||
|
||||
mr->mr_port = mp;
|
||||
mr->mr_p = p;
|
||||
mr->mr_type = type;
|
||||
|
||||
mr->mr_port->mp_refcount++;
|
||||
|
||||
/* Insert the right in one of the process right lists */
|
||||
med = (struct mach_emuldata *)p->p_emuldata;
|
||||
switch (type) {
|
||||
case MACH_PORT_RIGHT_SEND:
|
||||
lockmgr(&med->med_slock, LK_EXCLUSIVE, NULL);
|
||||
LIST_INSERT_HEAD(&med->med_send, mr, mr_list);
|
||||
lockmgr(&med->med_slock, LK_RELEASE, NULL);
|
||||
break;
|
||||
|
||||
case MACH_PORT_RIGHT_SEND_ONCE:
|
||||
lockmgr(&med->med_solock, LK_EXCLUSIVE, NULL);
|
||||
LIST_INSERT_HEAD(&med->med_sendonce, mr, mr_list);
|
||||
lockmgr(&med->med_solock, LK_RELEASE, NULL);
|
||||
break;
|
||||
|
||||
case MACH_PORT_RIGHT_RECEIVE:
|
||||
lockmgr(&med->med_rlock, LK_EXCLUSIVE, NULL);
|
||||
LIST_INSERT_HEAD(&med->med_recv, mr, mr_list);
|
||||
lockmgr(&med->med_rlock, LK_RELEASE, NULL);
|
||||
|
||||
/*
|
||||
* The process that owned the receive right on that
|
||||
* port should now drop it.
|
||||
*/
|
||||
if (mr->mr_port->mp_recv != NULL) {
|
||||
med = (struct mach_emuldata *)
|
||||
mr->mr_port->mp_recv->p_emuldata;
|
||||
|
||||
/* XXX lock it shared... */
|
||||
LIST_FOREACH(omr, &med->med_recv, mr_list)
|
||||
if ((omr->mr_port == mr->mr_port) &&
|
||||
(omr != mr) &&
|
||||
(omr->mr_type == MACH_PORT_RIGHT_RECEIVE))
|
||||
mach_right_put(omr);
|
||||
}
|
||||
|
||||
/*
|
||||
* Requester now is the receiver
|
||||
*/
|
||||
mr->mr_port->mp_recv = p;
|
||||
break;
|
||||
|
||||
default:
|
||||
uprintf("mach_right_get: unknown right %d\n", type);
|
||||
break;
|
||||
}
|
||||
return mr;
|
||||
}
|
||||
|
||||
void
|
||||
mach_right_put(mr)
|
||||
struct mach_right *mr;
|
||||
{
|
||||
struct mach_emuldata *med;
|
||||
|
||||
/* Remove the right from one of the process right lists */
|
||||
med = (struct mach_emuldata *)mr->mr_p->p_emuldata;
|
||||
switch(mr->mr_type) {
|
||||
case MACH_PORT_RIGHT_SEND:
|
||||
lockmgr(&med->med_slock, LK_EXCLUSIVE, NULL);
|
||||
LIST_REMOVE(mr, mr_list);
|
||||
lockmgr(&med->med_slock, LK_RELEASE, NULL);
|
||||
break;
|
||||
|
||||
case MACH_PORT_RIGHT_SEND_ONCE:
|
||||
lockmgr(&med->med_solock, LK_EXCLUSIVE, NULL);
|
||||
LIST_REMOVE(mr, mr_list);
|
||||
lockmgr(&med->med_solock, LK_RELEASE, NULL);
|
||||
break;
|
||||
|
||||
case MACH_PORT_RIGHT_RECEIVE:
|
||||
lockmgr(&med->med_rlock, LK_EXCLUSIVE, NULL);
|
||||
LIST_REMOVE(mr, mr_list);
|
||||
lockmgr(&med->med_rlock, LK_RELEASE, NULL);
|
||||
break;
|
||||
|
||||
default:
|
||||
uprintf("mach_right_put: unknown right %d\n", mr->mr_type);
|
||||
break;
|
||||
}
|
||||
|
||||
mr->mr_port->mp_refcount--;
|
||||
if (mr->mr_port->mp_refcount <= 0)
|
||||
mach_port_put(mr->mr_port);
|
||||
|
||||
pool_put(&mach_right_pool, mr);
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* Check that a process do have a given right. Beware that type is
|
||||
* MACH_PORT_TYPE_*, and not MACH_PORT_RIGHT_*
|
||||
*/
|
||||
int
|
||||
mach_right_check(mr, p, type)
|
||||
struct mach_right *mr;
|
||||
struct proc *p;
|
||||
int type;
|
||||
{
|
||||
struct mach_right *cmr;
|
||||
struct mach_emuldata *med;
|
||||
int found;
|
||||
|
||||
med = (struct mach_emuldata *)p->p_emuldata;
|
||||
found = 0;
|
||||
|
||||
if (type & MACH_PORT_TYPE_RECEIVE) {
|
||||
lockmgr(&med->med_rlock, LK_SHARED, NULL);
|
||||
LIST_FOREACH(cmr, &med->med_recv, mr_list)
|
||||
if ((mr == cmr) &&
|
||||
(cmr->mr_type == MACH_PORT_RIGHT_RECEIVE))
|
||||
found = 1;
|
||||
lockmgr(&med->med_rlock, LK_RELEASE, NULL);
|
||||
}
|
||||
|
||||
if (type & MACH_PORT_TYPE_SEND) {
|
||||
lockmgr(&med->med_slock, LK_SHARED, NULL);
|
||||
LIST_FOREACH(cmr, &med->med_send, mr_list)
|
||||
if ((mr == cmr) &&
|
||||
(cmr->mr_type == MACH_PORT_RIGHT_SEND))
|
||||
found = 1;
|
||||
lockmgr(&med->med_slock, LK_RELEASE, NULL);
|
||||
}
|
||||
|
||||
if (type & MACH_PORT_TYPE_SEND_ONCE) {
|
||||
lockmgr(&med->med_solock, LK_SHARED, NULL);
|
||||
LIST_FOREACH(cmr, &med->med_sendonce, mr_list)
|
||||
if ((mr == cmr) &&
|
||||
(cmr->mr_type == MACH_PORT_RIGHT_SEND_ONCE))
|
||||
found = 1;
|
||||
lockmgr(&med->med_solock, LK_RELEASE, NULL);
|
||||
}
|
||||
|
||||
return found;
|
||||
}
|
||||
|
||||
#ifdef DEBUG_MACH
|
||||
void
|
||||
mach_debug_port(p)
|
||||
struct proc *p;
|
||||
{
|
||||
struct mach_emuldata *med;
|
||||
struct mach_right *mr;
|
||||
|
||||
printf("mach_debug_port(%p)\n", p);
|
||||
|
||||
med = (struct mach_emuldata *)p->p_emuldata;
|
||||
|
||||
printf("receive rights:\n");
|
||||
LIST_FOREACH(mr, &med->med_recv, mr_list) {
|
||||
printf(" port = %p\n", mr->mr_port);
|
||||
printf(" recv = %p\n", mr->mr_port->mp_recv);
|
||||
printf(" count = %d\n", mr->mr_port->mp_count);
|
||||
printf(" refcount = %d\n", mr->mr_port->mp_refcount);
|
||||
printf(" proc = %p\n", mr->mr_p);
|
||||
printf(" type = %d\n", mr->mr_type);
|
||||
}
|
||||
|
||||
printf("send rights:\n");
|
||||
LIST_FOREACH(mr, &med->med_send, mr_list) {
|
||||
printf(" port = %p\n", mr->mr_port);
|
||||
printf(" recv = %p\n", mr->mr_port->mp_recv);
|
||||
printf(" count = %d\n", mr->mr_port->mp_count);
|
||||
printf(" refcount = %d\n", mr->mr_port->mp_refcount);
|
||||
printf(" proc = %p\n", mr->mr_p);
|
||||
printf(" type = %d\n", mr->mr_type);
|
||||
}
|
||||
|
||||
printf("send once rights:\n");
|
||||
LIST_FOREACH(mr, &med->med_sendonce, mr_list) {
|
||||
printf(" port = %p\n", mr->mr_port);
|
||||
printf(" recv = %p\n", mr->mr_port->mp_recv);
|
||||
printf(" count = %d\n", mr->mr_port->mp_count);
|
||||
printf(" refcount = %d\n", mr->mr_port->mp_refcount);
|
||||
printf(" proc = %p\n", mr->mr_p);
|
||||
printf(" type = %d\n", mr->mr_type);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: mach_port.h,v 1.6 2002/12/12 00:29:24 manu Exp $ */
|
||||
/* $NetBSD: mach_port.h,v 1.7 2002/12/15 00:40:25 manu Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2002 The NetBSD Foundation, Inc.
|
||||
@ -39,6 +39,19 @@
|
||||
#ifndef _MACH_PORT_H_
|
||||
#define _MACH_PORT_H_
|
||||
|
||||
#define MACH_PORT_RIGHT_SEND 0
|
||||
#define MACH_PORT_RIGHT_RECEIVE 1
|
||||
#define MACH_PORT_RIGHT_SEND_ONCE 2
|
||||
#define MACH_PORT_RIGHT_PORT_SET 3
|
||||
#define MACH_PORT_RIGHT_DEAD_NAME 4
|
||||
#define MACH_PORT_RIGHT_NUMBER 5
|
||||
|
||||
#define MACH_PORT_TYPE_SEND (MACH_PORT_RIGHT_SEND << 16)
|
||||
#define MACH_PORT_TYPE_RECEIVE (MACH_PORT_RIGHT_RECEIVE << 16)
|
||||
#define MACH_PORT_TYPE_SEND_ONCE (MACH_PORT_RIGHT_SEND_ONCE << 16)
|
||||
#define MACH_PORT_TYPE_PORT_RIGHTS \
|
||||
(MACH_PORT_TYPE_SEND | MACH_PORT_TYPE_RECEIVE | MACH_PORT_TYPE_SEND_ONCE)
|
||||
|
||||
/* port_deallocate */
|
||||
|
||||
typedef struct {
|
||||
@ -192,4 +205,39 @@ int mach_port_insert_member(struct proc *, mach_msg_header_t *,
|
||||
int mach_port_move_member(struct proc *, mach_msg_header_t *,
|
||||
size_t, mach_msg_header_t *);
|
||||
|
||||
|
||||
/* In-kernel Mach port right description */
|
||||
struct mach_right {
|
||||
struct mach_port *mr_port; /* Port we have the right on */
|
||||
struct proc *mr_p; /* points back to struct proc */
|
||||
int mr_type; /* right type (recv, send, sendonce) */
|
||||
LIST_ENTRY(mach_right) mr_list;
|
||||
};
|
||||
|
||||
struct mach_right *mach_right_get(struct mach_port *, struct proc *, int);
|
||||
void mach_right_put(struct mach_right *);
|
||||
int mach_right_check(struct mach_right *, struct proc *, int);
|
||||
|
||||
/* In-kernel Mach port description */
|
||||
struct mach_port {
|
||||
struct proc *mp_recv; /* Receiving process (holding recv. right) */
|
||||
int mp_count; /* Count of queued messages */
|
||||
TAILQ_HEAD(mp_msglist, /* Queue of messages pending delivery */
|
||||
mach_message) mp_msglist;
|
||||
struct lock mp_msglock; /* Lock for the queue */
|
||||
LIST_ENTRY(mach_port) /* List of all ports */
|
||||
mp_alllist;
|
||||
int mp_refcount; /* Reference count (amount of rights) */
|
||||
};
|
||||
|
||||
void mach_port_init(void);
|
||||
struct mach_port *mach_port_get(struct proc *);
|
||||
void mach_port_put(struct mach_port *);
|
||||
void mach_remove_recvport(struct mach_port *);
|
||||
void mach_add_recvport(struct mach_port *, struct proc *);
|
||||
int mach_port_check(struct mach_port *);
|
||||
#ifdef DEBUG_MACH
|
||||
void mach_debug_port(struct proc *);
|
||||
#endif
|
||||
|
||||
#endif /* _MACH_PORT_H_ */
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: mach_semaphore.c,v 1.1 2002/12/12 23:18:21 manu Exp $ */
|
||||
/* $NetBSD: mach_semaphore.c,v 1.2 2002/12/15 00:40:25 manu Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2002 The NetBSD Foundation, Inc.
|
||||
@ -37,7 +37,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: mach_semaphore.c,v 1.1 2002/12/12 23:18:21 manu Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: mach_semaphore.c,v 1.2 2002/12/15 00:40:25 manu Exp $");
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/param.h>
|
||||
@ -54,12 +54,11 @@ __KERNEL_RCSID(0, "$NetBSD: mach_semaphore.c,v 1.1 2002/12/12 23:18:21 manu Exp
|
||||
#include <compat/mach/mach_clock.h>
|
||||
#include <compat/mach/mach_syscallargs.h>
|
||||
|
||||
/* Semaphore list, lock, pools and inited flag */
|
||||
/* Semaphore list, lock, pools */
|
||||
static LIST_HEAD(mach_semaphore_list, mach_semaphore) mach_semaphore_list;
|
||||
static struct lock mach_semaphore_list_lock;
|
||||
static struct pool mach_semaphore_list_pool;
|
||||
static struct pool mach_waiting_proc_pool;
|
||||
int mach_semaphore_cold = 1;
|
||||
|
||||
/* Function to manipulate them */
|
||||
static struct mach_semaphore *mach_semaphore_get(int, int);
|
||||
@ -198,7 +197,6 @@ mach_semaphore_init(void)
|
||||
0, 0, 128, "mach_sem_pool", NULL);
|
||||
pool_init(&mach_waiting_proc_pool, sizeof (struct mach_waiting_proc),
|
||||
0, 0, 128, "mach_waitp_pool", NULL);
|
||||
mach_semaphore_cold = 0;
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: mach_task.c,v 1.10 2002/12/12 00:29:24 manu Exp $ */
|
||||
/* $NetBSD: mach_task.c,v 1.11 2002/12/15 00:40:25 manu Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2002 The NetBSD Foundation, Inc.
|
||||
@ -37,7 +37,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: mach_task.c,v 1.10 2002/12/12 00:29:24 manu Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: mach_task.c,v 1.11 2002/12/15 00:40:25 manu Exp $");
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/param.h>
|
||||
@ -51,6 +51,8 @@ __KERNEL_RCSID(0, "$NetBSD: mach_task.c,v 1.10 2002/12/12 00:29:24 manu Exp $");
|
||||
#include <compat/mach/mach_message.h>
|
||||
#include <compat/mach/mach_clock.h>
|
||||
#include <compat/mach/mach_errno.h>
|
||||
#include <compat/mach/mach_exec.h>
|
||||
#include <compat/mach/mach_port.h>
|
||||
#include <compat/mach/mach_task.h>
|
||||
#include <compat/mach/mach_syscallargs.h>
|
||||
|
||||
@ -64,10 +66,37 @@ mach_task_get_special_port(p, msgh, maxlen, dst)
|
||||
{
|
||||
mach_task_get_special_port_request_t req;
|
||||
mach_task_get_special_port_reply_t rep;
|
||||
struct mach_emuldata *med;
|
||||
struct mach_right *mr;
|
||||
int error;
|
||||
|
||||
if ((error = copyin(msgh, &req, sizeof(req))) != 0)
|
||||
return error;
|
||||
|
||||
med = (struct mach_emuldata *)p->p_emuldata;
|
||||
|
||||
switch (req.req_which_port) {
|
||||
case MACH_TASK_KERNEL_PORT:
|
||||
mr = mach_right_get(med->med_kernel, p, MACH_PORT_RIGHT_SEND);
|
||||
break;
|
||||
|
||||
case MACH_TASK_HOST_PORT:
|
||||
mr = mach_right_get(med->med_host, p, MACH_PORT_RIGHT_SEND);
|
||||
break;
|
||||
|
||||
case MACH_TASK_BOOTSTRAP_PORT:
|
||||
mr = mach_right_get(med->med_bootstrap,
|
||||
p, MACH_PORT_RIGHT_SEND);
|
||||
break;
|
||||
|
||||
case MACH_TASK_WIRED_LEDGER_PORT:
|
||||
case MACH_TASK_PAGED_LEDGER_PORT:
|
||||
default:
|
||||
uprintf("mach_task_get_special_port(): unimpl. port %d\n",
|
||||
req.req_which_port);
|
||||
return MACH_MSG_ERROR(p, msgh, &req, &rep, error, maxlen, dst);
|
||||
break;
|
||||
}
|
||||
|
||||
bzero(&rep, sizeof(rep));
|
||||
|
||||
@ -77,8 +106,8 @@ mach_task_get_special_port(p, msgh, maxlen, dst)
|
||||
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_msgh_body.msgh_descriptor_count = 1; /* XXX why ? */
|
||||
rep.rep_special_port.name = 0x90f; /* XXX why? */
|
||||
rep.rep_msgh_body.msgh_descriptor_count = 1;
|
||||
rep.rep_special_port.name = (mach_port_t)mr;
|
||||
rep.rep_special_port.disposition = 0x11; /* XXX why? */
|
||||
rep.rep_trailer.msgh_trailer_size = 8;
|
||||
|
||||
@ -100,6 +129,12 @@ mach_ports_lookup(p, msgh, maxlen, dst)
|
||||
if ((error = copyin(msgh, &req, sizeof(req))) != 0)
|
||||
return error;
|
||||
|
||||
/*
|
||||
* This is some out of band data sent with the reply. In the
|
||||
* encoutered situation the out of band data has laways been
|
||||
* null. We have to see more of his in order to fully understand
|
||||
* How this trap works.
|
||||
*/
|
||||
bzero(&evc, sizeof(evc));
|
||||
evc.ev_addr = 0x00008000;
|
||||
evc.ev_len = PAGE_SIZE;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: mach_task.h,v 1.3 2002/12/12 00:29:24 manu Exp $ */
|
||||
/* $NetBSD: mach_task.h,v 1.4 2002/12/15 00:40:25 manu Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2002 The NetBSD Foundation, Inc.
|
||||
@ -41,6 +41,12 @@
|
||||
|
||||
/* task_get_special_port */
|
||||
|
||||
#define MACH_TASK_KERNEL_PORT 1
|
||||
#define MACH_TASK_HOST_PORT 2
|
||||
#define MACH_TASK_BOOTSTRAP_PORT 4
|
||||
#define MACH_TASK_WIRED_LEDGER_PORT 5
|
||||
#define MACH_TASK_PAGED_LEDGER_PORT 6
|
||||
|
||||
typedef struct {
|
||||
mach_msg_header_t req_msgh;
|
||||
mach_ndr_record_t req_ndr;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: mach_vm.c,v 1.19 2002/12/11 21:23:37 manu Exp $ */
|
||||
/* $NetBSD: mach_vm.c,v 1.20 2002/12/15 00:40:25 manu Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2002 The NetBSD Foundation, Inc.
|
||||
@ -37,7 +37,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: mach_vm.c,v 1.19 2002/12/11 21:23:37 manu Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: mach_vm.c,v 1.20 2002/12/15 00:40:25 manu Exp $");
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/param.h>
|
||||
@ -53,6 +53,9 @@ __KERNEL_RCSID(0, "$NetBSD: mach_vm.c,v 1.19 2002/12/11 21:23:37 manu Exp $");
|
||||
|
||||
#include <uvm/uvm_prot.h>
|
||||
#include <uvm/uvm_map.h>
|
||||
|
||||
/* Too much debug output from here, but we might need it later... */
|
||||
#undef DEBUG_MACH
|
||||
|
||||
#include <compat/mach/mach_types.h>
|
||||
#include <compat/mach/mach_message.h>
|
||||
|
Loading…
Reference in New Issue
Block a user