Move most of the code involved into message header, trailer, and descriptor

construction to inline functions. This removes a lot of redundent code
from Mach services
This commit is contained in:
manu 2003-12-09 11:29:01 +00:00
parent 7b0cb03434
commit 99ee466dbb
16 changed files with 594 additions and 773 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: darwin_ioframebuffer.c,v 1.25 2003/12/07 10:25:38 manu Exp $ */
/* $NetBSD: darwin_ioframebuffer.c,v 1.26 2003/12/09 11:29:01 manu Exp $ */
/*-
* Copyright (c) 2003 The NetBSD Foundation, Inc.
@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: darwin_ioframebuffer.c,v 1.25 2003/12/07 10:25:38 manu Exp $");
__KERNEL_RCSID(0, "$NetBSD: darwin_ioframebuffer.c,v 1.26 2003/12/09 11:29:01 manu Exp $");
#include <sys/types.h>
#include <sys/param.h>
@ -133,13 +133,7 @@ darwin_ioframebuffer_connect_method_scalari_scalaro(args)
#ifdef DEBUG_DARWIN
printf("darwin_ioframebuffer_connect_method_scalari_scalaro()\n");
#endif
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_outcount = 0;
maxoutcount = req->req_in[req->req_incount];
switch (req->req_selector) {
@ -284,9 +278,9 @@ darwin_ioframebuffer_connect_method_scalari_scalaro(args)
break;
}
rep->rep_out[rep->rep_outcount + 1] = 8; /* XXX Trailer */
*msglen = sizeof(*rep) - ((16 - rep->rep_outcount) * sizeof(int));
rep->rep_msgh.msgh_size = *msglen - sizeof(rep->rep_trailer);
mach_set_header(rep, req, *msglen);
mach_set_trailer(rep, *msglen);
return 0;
}
@ -303,13 +297,7 @@ darwin_ioframebuffer_connect_method_scalari_structo(args)
#ifdef DEBUG_DARWIN
printf("darwin_ioframebuffer_connect_method_scalari_structo()\n");
#endif
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_outcount = 0;
maxoutcount = req->req_in[req->req_incount];
switch(req->req_selector) {
@ -408,9 +396,10 @@ darwin_ioframebuffer_connect_method_scalari_structo(args)
break;
}
rep->rep_out[rep->rep_outcount + 7] = 8; /* XXX Trailer */
*msglen = sizeof(*rep) - (4096 - rep->rep_outcount);
rep->rep_msgh.msgh_size = *msglen - sizeof(rep->rep_trailer);
mach_set_header(rep, req, *msglen);
mach_set_trailer(rep, *msglen);
return 0;
}
@ -425,17 +414,14 @@ darwin_ioframebuffer_connect_method_structi_structo(args)
#ifdef DEBUG_DARWIN
printf("darwin_ioframebuffer_connect_method_structi_structo()\n");
#endif
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_outcount = 1;
rep->rep_out[0] = 1;
rep->rep_out[rep->rep_outcount + 1] = 8; /* XXX Trailer */
*msglen = sizeof(*rep) - (4096 - rep->rep_outcount);
rep->rep_msgh.msgh_size = *msglen - sizeof(rep->rep_trailer);
mach_set_header(rep, req, *msglen);
mach_set_trailer(rep, *msglen);
return 0;
}
@ -573,17 +559,14 @@ darwin_ioframebuffer_connect_map_memory(args)
break;
}
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;
*msglen = sizeof(*rep);
mach_set_header(rep, req, *msglen);
rep->rep_retval = 0;
rep->rep_addr = pvaddr;
rep->rep_len = len;
rep->rep_trailer.msgh_trailer_size = 8;
*msglen = sizeof(*rep);
mach_set_trailer(rep, *msglen);
return 0;
}
@ -722,15 +705,12 @@ darwin_ioframebuffer_connect_method_scalari_structi(args)
break;
}
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_msgh.msgh_size = sizeof(*rep) - sizeof(rep->rep_trailer);
rep->rep_trailer.msgh_trailer_size = 8;
*msglen = sizeof(*rep);
mach_set_header(rep, req, *msglen);
rep->rep_retval = 0;
mach_set_trailer(rep, *msglen);
return 0;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: darwin_iohidsystem.c,v 1.23 2003/11/13 13:40:39 manu Exp $ */
/* $NetBSD: darwin_iohidsystem.c,v 1.24 2003/12/09 11:29:01 manu Exp $ */
/*-
* Copyright (c) 2003 The NetBSD Foundation, Inc.
@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: darwin_iohidsystem.c,v 1.23 2003/11/13 13:40:39 manu Exp $");
__KERNEL_RCSID(0, "$NetBSD: darwin_iohidsystem.c,v 1.24 2003/12/09 11:29:01 manu Exp $");
#include "ioconf.h"
#include "wsmux.h"
@ -171,13 +171,7 @@ darwin_iohidsystem_connect_method_scalari_scalaro(args)
#ifdef DEBUG_DARWIN
printf("darwin_iohidsystem_connect_method_scalari_scalaro()\n");
#endif
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_outcount = 0;
maxoutcount = req->req_in[req->req_incount];
switch (req->req_selector) {
@ -283,10 +277,10 @@ darwin_iohidsystem_connect_method_scalari_scalaro(args)
break;
}
rep->rep_out[rep->rep_outcount + 1] = 8; /* XXX Trailer */
*msglen = sizeof(*rep) - ((16 + rep->rep_outcount) * sizeof(int));
rep->rep_msgh.msgh_size = *msglen - sizeof(rep->rep_trailer);
mach_set_header(rep, req, *msglen);
mach_set_trailer(rep, *msglen);
return 0;
}
@ -304,13 +298,7 @@ darwin_iohidsystem_connect_method_structi_structo(args)
#ifdef DEBUG_DARWIN
printf("darwin_iohidsystem_connect_method_structi_structo()\n");
#endif
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_outcount = 0;
maxoutcount = req->req_in[req->req_incount];
switch (req->req_selector) {
@ -357,10 +345,11 @@ darwin_iohidsystem_connect_method_structi_structo(args)
break;
}
rep->rep_out[rep->rep_outcount + 1] = 8; /* XXX Trailer */
*msglen = sizeof(*rep) - (4096 - rep->rep_outcount);
rep->rep_msgh.msgh_size = *msglen - sizeof(rep->rep_trailer);
mach_set_header(rep, req, *msglen);
mach_set_trailer(rep, *msglen);
return 0;
}
@ -396,18 +385,15 @@ darwin_iohidsystem_connect_map_memory(args)
#ifdef DEBUG_DARWIN
printf("pvaddr = 0x%08lx\n", (long)pvaddr);
#endif
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;
*msglen = sizeof(*rep);
mach_set_header(rep, req, *msglen);
rep->rep_retval = 0;
rep->rep_addr = pvaddr;
rep->rep_len = sizeof(struct darwin_iohidsystem_shmem);
rep->rep_trailer.msgh_trailer_size = 8;
*msglen = sizeof(*rep);
mach_set_trailer(rep, *msglen);
return 0;
}
@ -714,7 +700,8 @@ mach_notify_iohidsystem(l, mr)
req->req_msgh.msgh_size = sizeof(*req) - sizeof(req->req_trailer);
req->req_msgh.msgh_local_port = mr->mr_name;
req->req_msgh.msgh_id = 0;
req->req_trailer.msgh_trailer_size = 8;
mach_set_trailer(req, sizeof(*req));
#ifdef KTRACE
ktruser(l->l_proc, "notify_iohidsystem", NULL, 0, 0);

View File

@ -1,4 +1,4 @@
/* $NetBSD: mach_bootstrap.c,v 1.9 2003/11/13 13:40:39 manu Exp $ */
/* $NetBSD: mach_bootstrap.c,v 1.10 2003/12/09 11:29:01 manu Exp $ */
/*-
* Copyright (c) 2002-2003 The NetBSD Foundation, Inc.
@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: mach_bootstrap.c,v 1.9 2003/11/13 13:40:39 manu Exp $");
__KERNEL_RCSID(0, "$NetBSD: mach_bootstrap.c,v 1.10 2003/12/09 11:29:01 manu Exp $");
#include <sys/types.h>
#include <sys/param.h>
@ -75,18 +75,14 @@ mach_bootstrap_look_up(args)
mr = mach_right_get(NULL, l, MACH_PORT_TYPE_DEAD_NAME, 0);
rep->rep_msgh.msgh_bits =
MACH_MSGH_REPLY_LOCAL_BITS(MACH_MSG_TYPE_MOVE_SEND_ONCE) |
MACH_MSGH_BITS_COMPLEX;
rep->rep_msgh.msgh_size = *msglen - 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_count = 1; /* XXX Why? */
mach_set_header(rep, req, *msglen);
rep->rep_count = 1;
rep->rep_bootstrap_port = mr->mr_name;
strncpy((char *)rep->rep_service_name, service_name,
service_name_len);
/* XXX This is the trailer. We should find something better */
rep->rep_service_name[service_name_len + 7] = 8;
mach_set_trailer(rep, *msglen);
return 0;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: mach_clock.c,v 1.9 2003/11/13 13:40:39 manu Exp $ */
/* $NetBSD: mach_clock.c,v 1.10 2003/12/09 11:29:01 manu Exp $ */
/*-
* Copyright (c) 2002-2003 The NetBSD Foundation, Inc.
@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: mach_clock.c,v 1.9 2003/11/13 13:40:39 manu Exp $");
__KERNEL_RCSID(0, "$NetBSD: mach_clock.c,v 1.10 2003/12/09 11:29:01 manu Exp $");
#include <sys/types.h>
#include <sys/param.h>
@ -140,16 +140,13 @@ mach_clock_get_time(args)
microtime(&tv);
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;
*msglen = sizeof(*rep);
mach_set_header(rep, req, *msglen);
rep->rep_cur_time.tv_sec = tv.tv_sec;
rep->rep_cur_time.tv_nsec = tv.tv_usec * 1000;
rep->rep_trailer.msgh_trailer_size = 8;
*msglen = sizeof(*rep);
mach_set_trailer(rep, *msglen);
return 0;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: mach_errno.c,v 1.12 2003/02/09 22:13:46 manu Exp $ */
/* $NetBSD: mach_errno.c,v 1.13 2003/12/09 11:29:01 manu Exp $ */
/*-
* Copyright (c) 2002 The NetBSD Foundation, Inc.
@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: mach_errno.c,v 1.12 2003/02/09 22:13:46 manu Exp $");
__KERNEL_RCSID(0, "$NetBSD: mach_errno.c,v 1.13 2003/12/09 11:29:01 manu Exp $");
#include <sys/types.h>
#include <sys/systm.h>
@ -147,15 +147,12 @@ mach_msg_error(args, error)
mach_error_reply_t *rep = args->rmsg;
size_t *msglen = args->rsize;
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->msgh_local_port;
rep->rep_msgh.msgh_id = req->msgh_id + 100;
rep->rep_retval = native_to_mach_errno[error];
rep->rep_trailer.msgh_trailer_size = 8;
*msglen = sizeof(*rep);
mach_set_header(rep, req, *msglen);
rep->rep_retval = native_to_mach_errno[error];
mach_set_trailer(rep, *msglen);
#ifdef DEBUG_MACH
printf("failure in kernel handler for msg id %d\n", req->msgh_id);
@ -172,15 +169,12 @@ mach_iokit_error(args, error)
mach_error_reply_t *rep = args->rmsg;
size_t *msglen = args->rsize;
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->msgh_local_port;
rep->rep_msgh.msgh_id = req->msgh_id + 100;
rep->rep_retval = error;
rep->rep_trailer.msgh_trailer_size = 8;
*msglen = sizeof(*rep);
mach_set_header(rep, req, *msglen);
rep->rep_retval = error;
mach_set_trailer(rep, *msglen);
return 0;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: mach_host.c,v 1.25 2003/12/08 12:03:16 manu Exp $ */
/* $NetBSD: mach_host.c,v 1.26 2003/12/09 11:29:01 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.25 2003/12/08 12:03:16 manu Exp $");
__KERNEL_RCSID(0, "$NetBSD: mach_host.c,v 1.26 2003/12/09 11:29:01 manu Exp $");
#include <sys/types.h>
#include <sys/malloc.h>
@ -66,14 +66,8 @@ mach_host_info(args)
size_t *msglen = args->rsize;
mach_host_info_reply_simple_t *reps;
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);
mach_set_header(rep, req, *msglen);
switch(req->req_flavor) {
case MACH_HOST_BASIC_INFO: {
@ -84,11 +78,6 @@ mach_host_info(args)
- sizeof(rep->rep_trailer) + sizeof(*info);
rep->rep_count = sizeof(*info) / sizeof(mach_integer_t);
mach_host_basic_info(info);
/*
* XXX this is the trailer, the way it
* is filled should be improved
*/
rep->rep_data[rep->rep_count + 1] = 8;
break;
}
@ -100,11 +89,6 @@ mach_host_info(args)
- sizeof(rep->rep_trailer) + sizeof(*info);
rep->rep_count = sizeof(*info) / sizeof(mach_integer_t);
mach_host_priority_info(info);
/*
* XXX this is the trailer, the way it
* is filled should be improved
*/
rep->rep_data[rep->rep_count + 1] = 8;
break;
}
@ -113,7 +97,6 @@ mach_host_info(args)
reps = (mach_host_info_reply_simple_t *)rep;
reps->rep_msgh.msgh_size =
sizeof(*reps) - sizeof(reps->rep_trailer);
reps->rep_trailer.msgh_trailer_size = 8;
*msglen = sizeof(*reps);
break;
@ -128,7 +111,6 @@ mach_host_info(args)
info->min_timeout = 1000 / hz; /* XXX timout in ms */
info->min_quantum = 1000 / hz; /* quantum in ms */
rep->rep_data[rep->rep_count + 1] = 8; /* XXX trailer */
break;
}
@ -141,6 +123,8 @@ mach_host_info(args)
break;
}
mach_set_trailer(rep, *msglen);
return 0;
}
@ -153,15 +137,13 @@ mach_host_page_size(args)
mach_host_page_size_reply_t *rep = args->rmsg;
size_t *msglen = args->rsize;
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_page_size = PAGE_SIZE;
rep->rep_trailer.msgh_trailer_size = 8;
*msglen = sizeof(*rep);
mach_set_header(rep, req, *msglen);
rep->rep_page_size = PAGE_SIZE;
mach_set_trailer(rep, *msglen);
return 0;
}
@ -177,19 +159,11 @@ mach_host_get_clock_service(args)
mr = mach_right_get(mach_clock_port, l, MACH_PORT_TYPE_SEND, 0);
rep->rep_msgh.msgh_bits =
MACH_MSGH_REPLY_LOCAL_BITS(MACH_MSG_TYPE_MOVE_SEND_ONCE) |
MACH_MSGH_BITS_COMPLEX;
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;
rep->rep_clock_serv.name = (mach_port_t)mr->mr_name;
rep->rep_clock_serv.disposition = MACH_MSG_TYPE_MOVE_SEND;
rep->rep_clock_serv.type = MACH_MSG_PORT_DESCRIPTOR;
rep->rep_trailer.msgh_trailer_size = 8;
*msglen = sizeof(*rep);
mach_set_header(rep, req, *msglen);
mach_add_port_desc(rep, mr->mr_name);
mach_set_trailer(rep, *msglen);
return 0;
}
@ -222,18 +196,10 @@ mach_host_get_io_master(args)
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) |
MACH_MSGH_BITS_COMPLEX;
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;
rep->rep_iomaster.name = (mach_port_t)mr->mr_name;
rep->rep_iomaster.disposition = MACH_MSG_TYPE_MOVE_SEND;
rep->rep_iomaster.type = MACH_MSG_PORT_DESCRIPTOR;
rep->rep_trailer.msgh_trailer_size = 8;
*msglen = sizeof(*rep);
mach_set_header(rep, req, *msglen);
mach_add_port_desc(rep, mr->mr_name);
mach_set_trailer(rep, *msglen);
return 0;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: mach_iokit.c,v 1.28 2003/12/08 19:27:38 manu Exp $ */
/* $NetBSD: mach_iokit.c,v 1.29 2003/12/09 11:29:01 manu Exp $ */
/*-
* Copyright (c) 2003 The NetBSD Foundation, Inc.
@ -39,7 +39,7 @@
#include "opt_ktrace.h"
#include "opt_compat_darwin.h"
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: mach_iokit.c,v 1.28 2003/12/08 19:27:38 manu Exp $");
__KERNEL_RCSID(0, "$NetBSD: mach_iokit.c,v 1.29 2003/12/09 11:29:01 manu Exp $");
#include <sys/types.h>
#include <sys/param.h>
@ -136,19 +136,11 @@ mach_io_service_get_matching_services(args)
if (mp->mp_data == NULL)
return mach_iokit_error(args, MACH_IOKIT_ENOENT);
rep->rep_msgh.msgh_bits =
MACH_MSGH_REPLY_LOCAL_BITS(MACH_MSG_TYPE_MOVE_SEND_ONCE) |
MACH_MSGH_BITS_COMPLEX;
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;
rep->rep_match.name = (mach_port_t)mr->mr_name;
rep->rep_match.disposition = MACH_MSG_TYPE_MOVE_SEND;
rep->rep_match.type = MACH_MSG_PORT_DESCRIPTOR;
rep->rep_trailer.msgh_trailer_size = 8;
*msglen = sizeof(*rep);
mach_set_header(rep, req, *msglen);
mach_add_port_desc(rep, mr->mr_name);
mach_set_trailer(rep, *msglen);
return 0;
}
@ -185,19 +177,11 @@ mach_io_iterator_next(args)
mr = mach_right_get(mp, l, MACH_PORT_TYPE_SEND, 0);
rep->rep_msgh.msgh_bits =
MACH_MSGH_REPLY_LOCAL_BITS(MACH_MSG_TYPE_MOVE_SEND_ONCE) |
MACH_MSGH_BITS_COMPLEX;
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;
rep->rep_object.name = (mach_port_t)mr->mr_name;
rep->rep_object.disposition = MACH_MSG_TYPE_MOVE_SEND;
rep->rep_object.type = MACH_MSG_PORT_DESCRIPTOR;
rep->rep_trailer.msgh_trailer_size = 8;
*msglen = sizeof(*rep);
mach_set_header(rep, req, *msglen);
mach_add_port_desc(rep, mr->mr_name);
mach_set_trailer(rep, *msglen);
return 0;
}
@ -225,19 +209,11 @@ mach_io_service_open(args)
}
mr = mach_right_get(mp, l, MACH_PORT_TYPE_SEND, 0);
rep->rep_msgh.msgh_bits =
MACH_MSGH_REPLY_LOCAL_BITS(MACH_MSG_TYPE_MOVE_SEND_ONCE) |
MACH_MSGH_BITS_COMPLEX;
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;
rep->rep_connect.name = (mach_port_t)mr->mr_name;
rep->rep_connect.disposition = MACH_MSG_TYPE_MOVE_SEND;
rep->rep_connect.type = MACH_MSG_PORT_DESCRIPTOR;
rep->rep_trailer.msgh_trailer_size = 8;
*msglen = sizeof(*rep);
mach_set_header(rep, req, *msglen);
mach_add_port_desc(rep, mr->mr_name);
mach_set_trailer(rep, *msglen);
return 0;
}
@ -311,19 +287,11 @@ mach_io_connect_get_service(args)
*/
mr->mr_refcount++;
rep->rep_msgh.msgh_bits =
MACH_MSGH_REPLY_LOCAL_BITS(MACH_MSG_TYPE_MOVE_SEND_ONCE) |
MACH_MSGH_BITS_COMPLEX;
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;
rep->rep_service.name = (mach_port_t)mr->mr_name;
rep->rep_service.disposition = MACH_MSG_TYPE_MOVE_SEND;
rep->rep_service.type = MACH_MSG_PORT_DESCRIPTOR;
rep->rep_trailer.msgh_trailer_size = 8;
*msglen = sizeof(*rep);
mach_set_header(rep, req, *msglen);
mach_add_port_desc(rep, mr->mr_name);
mach_set_trailer(rep, *msglen);
return 0;
}
@ -395,19 +363,11 @@ mach_io_registry_entry_create_iterator(args)
printf("io_registry_entry_create_iterator\n");
#endif
rep->rep_msgh.msgh_bits =
MACH_MSGH_REPLY_LOCAL_BITS(MACH_MSG_TYPE_MOVE_SEND_ONCE) |
MACH_MSGH_BITS_COMPLEX;
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;
rep->rep_iterator.name = (mach_port_t)mr->mr_name;
rep->rep_iterator.disposition = MACH_MSG_TYPE_MOVE_SEND;
rep->rep_iterator.type = MACH_MSG_PORT_DESCRIPTOR;
rep->rep_trailer.msgh_trailer_size = 8;
*msglen = sizeof(*rep);
mach_set_header(rep, req, *msglen);
mach_add_port_desc(rep, mr->mr_name);
mach_set_trailer(rep, *msglen);
return 0;
}
@ -432,15 +392,13 @@ mach_io_object_conforms_to(args)
uprintf("Unimplemented mach_io_object_conforms_to\n");
#endif
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_conforms = 1; /* XXX */
rep->rep_trailer.msgh_trailer_size = 8;
*msglen = sizeof(*rep);
mach_set_header(rep, req, *msglen);
rep->rep_conforms = 1; /* XXX */
mach_set_trailer(rep, *msglen);
return 0;
}
@ -476,19 +434,11 @@ mach_io_service_add_interest_notification(args)
#ifdef DEBUG_DARWIN
uprintf("Unimplemented mach_io_service_add_interest_notification\n");
#endif
rep->rep_msgh.msgh_bits =
MACH_MSGH_REPLY_LOCAL_BITS(MACH_MSG_TYPE_MOVE_SEND_ONCE) |
MACH_MSGH_BITS_COMPLEX;
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;
rep->rep_notification.name = (mach_port_t)mr->mr_name;
rep->rep_notification.disposition = MACH_MSG_TYPE_MOVE_SEND;
rep->rep_notification.type = MACH_MSG_PORT_DESCRIPTOR;
rep->rep_trailer.msgh_trailer_size = 8;
*msglen = sizeof(*rep);
mach_set_header(rep, req, *msglen);
mach_add_port_desc(rep, mr->mr_name);
mach_set_trailer(rep, *msglen);
return 0;
}
@ -525,14 +475,13 @@ mach_io_connect_set_notification_port(args)
mid = (struct mach_iokit_devclass *)mr->mr_port->mp_data;
mid->mid_notify = mrn;
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);
mach_set_header(rep, req, *msglen);
rep->rep_retval = 0;
mach_set_trailer(rep, *msglen);
return 0;
}
@ -554,19 +503,11 @@ mach_io_registry_get_root_entry(args)
mr = mach_right_get(mp, l, MACH_PORT_TYPE_SEND, 0);
rep->rep_msgh.msgh_bits =
MACH_MSGH_REPLY_LOCAL_BITS(MACH_MSG_TYPE_MOVE_SEND_ONCE) |
MACH_MSGH_BITS_COMPLEX;
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;
rep->rep_root.name = (mach_port_t)mr->mr_name;
rep->rep_root.disposition = MACH_MSG_TYPE_MOVE_SEND;
rep->rep_root.type = MACH_MSG_PORT_DESCRIPTOR;
rep->rep_trailer.msgh_trailer_size = 8;
*msglen = sizeof(*rep);
mach_set_header(rep, req, *msglen);
mach_add_port_desc(rep, mr->mr_name);
mach_set_trailer(rep, *msglen);
return 0;
}
@ -616,19 +557,11 @@ mach_io_registry_entry_get_child_iterator(args)
mr = mach_right_get(mp, l, MACH_PORT_TYPE_SEND, 0);
rep->rep_msgh.msgh_bits =
MACH_MSGH_REPLY_LOCAL_BITS(MACH_MSG_TYPE_MOVE_SEND_ONCE) |
MACH_MSGH_BITS_COMPLEX;
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;
rep->rep_iterator.name = (mach_port_t)mr->mr_name;
rep->rep_iterator.disposition = MACH_MSG_TYPE_MOVE_SEND;
rep->rep_iterator.type = MACH_MSG_PORT_DESCRIPTOR;
rep->rep_trailer.msgh_trailer_size = 8;
*msglen = sizeof(*rep);
mach_set_header(rep, req, *msglen);
mach_add_port_desc(rep, mr->mr_name);
mach_set_trailer(rep, *msglen);
return 0;
}
@ -660,18 +593,16 @@ mach_io_registry_entry_get_name_in_plane(args)
return mach_iokit_error(args, MACH_IOKIT_EINVAL);
mid = mr->mr_port->mp_data;
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;
*msglen = sizeof(*rep);
mach_set_header(rep, req, *msglen);
rep->rep_namecount = strlen(mid->mid_name);
if (rep->rep_namecount >= 128)
rep->rep_namecount = 128;
memcpy(&rep->rep_name, mid->mid_name, rep->rep_namecount);
rep->rep_trailer.msgh_trailer_size = 8;
*msglen = sizeof(*rep);
mach_set_trailer(rep, *msglen);
return 0;
}
@ -684,19 +615,17 @@ mach_io_object_get_class(args)
size_t *msglen = args->rsize;
char classname[] = "unknownClass";
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;
*msglen = sizeof(*rep);
mach_set_header(rep, req, *msglen);
/* XXX Just return a dummy name for now */
rep->rep_namecount = strlen(classname);
if (rep->rep_namecount >= 128)
rep->rep_namecount = 128;
memcpy(&rep->rep_name, classname, rep->rep_namecount);
rep->rep_trailer.msgh_trailer_size = 8;
*msglen = sizeof(*rep);
mach_set_trailer(rep, *msglen);
return 0;
}
@ -719,17 +648,15 @@ mach_io_registry_entry_get_location_in_plane(args)
if (MACH_REQMSG_OVERFLOW(args, req->req_plane[end_offset]))
return mach_msg_error(args, EINVAL);
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;
*msglen = sizeof(*rep);
mach_set_header(rep, req, *msglen);
/* XXX Just return a dummy name for now */
rep->rep_locationcount = sizeof(location);
memcpy(&rep->rep_location, location, sizeof(location));
rep->rep_trailer.msgh_trailer_size = 8;
*msglen = sizeof(*rep);
mach_set_trailer(rep, *msglen);
return 0;
}
@ -768,22 +695,14 @@ mach_io_registry_entry_get_properties(args)
#endif
}
rep->rep_msgh.msgh_bits =
MACH_MSGH_REPLY_LOCAL_BITS(MACH_MSG_TYPE_MOVE_SEND_ONCE) |
MACH_MSGH_BITS_COMPLEX;
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;
rep->rep_properties.address = uaddr;
rep->rep_properties.size = size;
rep->rep_properties.deallocate = 0;
rep->rep_properties.copy = MACH_MSG_ALLOCATE;
rep->rep_properties.type = MACH_MSG_OOL_DESCRIPTOR;
rep->rep_count = size;
rep->rep_trailer.msgh_trailer_size = 8;
*msglen = sizeof(*rep);
mach_set_header(rep, req, *msglen);
mach_add_ool_desc(rep, uaddr, size);
rep->rep_count = size;
mach_set_trailer(rep, *msglen);
return 0;
}
@ -844,22 +763,14 @@ mach_io_registry_entry_get_property(args)
#endif
}
rep->rep_msgh.msgh_bits =
MACH_MSGH_REPLY_LOCAL_BITS(MACH_MSG_TYPE_MOVE_SEND_ONCE) |
MACH_MSGH_BITS_COMPLEX;
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;
rep->rep_properties.address = uaddr;
rep->rep_properties.size = size;
rep->rep_properties.deallocate = 0;
rep->rep_properties.copy = MACH_MSG_ALLOCATE;
rep->rep_properties.type = MACH_MSG_PORT_DESCRIPTOR; /* XXX was 0 */
rep->rep_properties_count = size;
rep->rep_trailer.msgh_trailer_size = 8;
*msglen = sizeof(*rep);
mach_set_header(rep, req, *msglen);
mach_add_ool_desc(rep, uaddr, size);
rep->rep_properties_count = size;
mach_set_trailer(rep, *msglen);
return 0;
}
@ -893,12 +804,9 @@ mach_io_registry_entry_get_path(args)
return mach_iokit_error(args, MACH_IOKIT_EINVAL);
plen = (len & ~0x3UL) + 4; /* Round to an int */
rep->rep_msgh.msgh_bits =
MACH_MSGH_REPLY_LOCAL_BITS(MACH_MSG_TYPE_MOVE_SEND_ONCE);
rep->rep_msgh.msgh_size = sizeof(*rep) +
(plen - 512) - 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;
*msglen = sizeof(*rep) + (plen - 512);
mach_set_header(rep, req, *msglen);
rep->rep_retval = 0;
rep->rep_count = len;
@ -909,9 +817,8 @@ mach_io_registry_entry_get_path(args)
cp += strlen(location);
*cp = '\0';
rep->rep_path[plen + 7] = 8; /* Trailer */
mach_set_trailer(rep, *msglen);
*msglen = sizeof(*rep) + (plen - 512);
return 0;
}
@ -963,15 +870,12 @@ mach_io_iterator_reset(args)
mdi = mr->mr_port->mp_data;
mdi->mdi_current = 0;
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_retval = 0;
rep->rep_trailer.msgh_trailer_size = 8;
*msglen = sizeof(*rep);
mach_set_header(rep, req, *msglen);
rep->rep_retval = 0;
mach_set_trailer(rep, *msglen);
return 0;
}
@ -1062,14 +966,11 @@ mach_io_connect_set_properties(args)
uprintf("Unimplemented mach_io_connect_set_properties\n");
#endif
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);
mach_set_header(rep, req, *msglen);
mach_set_trailer(rep, *msglen);
return 0;
}
@ -1085,15 +986,13 @@ mach_io_service_close(args)
uprintf("Unimplemented mach_io_service_close\n");
#endif
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_retval = 0;
rep->rep_trailer.msgh_trailer_size = 8;
*msglen = sizeof(*rep);
mach_set_header(rep, req, *msglen);
rep->rep_retval = 0;
mach_set_trailer(rep, *msglen);
return 0;
}
@ -1109,15 +1008,13 @@ mach_io_connect_add_client(args)
uprintf("Unimplemented mach_io_connect_add_client\n");
#endif
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_retval = 0;
rep->rep_trailer.msgh_trailer_size = 8;
*msglen = sizeof(*rep);
mach_set_header(rep, req, *msglen);
rep->rep_retval = 0;
mach_set_trailer(rep, *msglen);
return 0;
}
@ -1204,19 +1101,11 @@ mach_io_registry_entry_from_path(args)
}
}
rep->rep_msgh.msgh_bits =
MACH_MSGH_REPLY_LOCAL_BITS(MACH_MSG_TYPE_MOVE_SEND_ONCE) |
MACH_MSGH_BITS_COMPLEX;
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;
rep->rep_entry.name = (mach_port_t)mr->mr_name;
rep->rep_entry.disposition = MACH_MSG_TYPE_MOVE_SEND;
rep->rep_entry.type = MACH_MSG_PORT_DESCRIPTOR;
rep->rep_trailer.msgh_trailer_size = 8;
*msglen = sizeof(*rep);
mach_set_header(rep, req, *msglen);
mach_add_port_desc(rep, mr->mr_name);
mach_set_trailer(rep, *msglen);
return 0;
}
@ -1272,19 +1161,11 @@ mach_io_registry_entry_get_parent_iterator(args)
mr = mach_right_get(mp, l, MACH_PORT_TYPE_SEND, 0);
rep->rep_msgh.msgh_bits =
MACH_MSGH_REPLY_LOCAL_BITS(MACH_MSG_TYPE_MOVE_SEND_ONCE) |
MACH_MSGH_BITS_COMPLEX;
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;
rep->rep_iterator.name = (mach_port_t)mr->mr_name;
rep->rep_iterator.disposition = MACH_MSG_TYPE_MOVE_SEND;
rep->rep_iterator.type = MACH_MSG_PORT_DESCRIPTOR;
rep->rep_trailer.msgh_trailer_size = 8;
*msglen = sizeof(*rep);
mach_set_header(rep, req, *msglen);
mach_add_port_desc(rep, mr->mr_name);
mach_set_trailer(rep, *msglen);
return 0;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: mach_message.c,v 1.36 2003/12/08 19:27:38 manu Exp $ */
/* $NetBSD: mach_message.c,v 1.37 2003/12/09 11:29:01 manu Exp $ */
/*-
* Copyright (c) 2002-2003 The NetBSD Foundation, Inc.
@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: mach_message.c,v 1.36 2003/12/08 19:27:38 manu Exp $");
__KERNEL_RCSID(0, "$NetBSD: mach_message.c,v 1.37 2003/12/09 11:29:01 manu Exp $");
#include "opt_ktrace.h"
#include "opt_compat_mach.h" /* For COMPAT_MACH in <sys/ktrace.h> */
@ -586,8 +586,7 @@ mach_msg_recv(l, urm, option, recv_size, timeout, mn)
* whole message, so just copy the whole header.
*/
memcpy(&sr, mm->mm_msg, sizeof(mach_msg_header_t));
sr.sr_trailer.msgh_trailer_type = 0;
sr.sr_trailer.msgh_trailer_size = 8;
mach_set_trailer(&sr, sizeof(sr));
if ((error = copyout(&sr, urm, sizeof(sr))) != 0) {
ret = MACH_RCV_INVALID_DATA;
@ -1046,6 +1045,115 @@ out:
return error;
}
inline void
mach_set_trailer(msgh, size)
void *msgh;
size_t size;
{
mach_msg_trailer_t *trailer;
char *msg = (char *)msgh;
trailer = (mach_msg_trailer_t *)&msg[size - sizeof(*trailer)];
trailer->msgh_trailer_type = MACH_MSG_TRAILER_FORMAT_0;
trailer->msgh_trailer_size = sizeof(*trailer);
return;
}
inline void
mach_set_header(rep, req, size)
void *rep;
void *req;
size_t size;
{
mach_msg_header_t *rephdr = rep;
mach_msg_header_t *reqhdr = req;
rephdr->msgh_bits =
MACH_MSGH_REPLY_LOCAL_BITS(MACH_MSG_TYPE_MOVE_SEND_ONCE);
rephdr->msgh_size = size - sizeof(mach_msg_trailer_t);
rephdr->msgh_local_port = reqhdr->msgh_local_port;
rephdr->msgh_remote_port = 0;
rephdr->msgh_id = reqhdr->msgh_id + 100;
return;
}
inline void
mach_add_port_desc(msg, name)
void *msg;
mach_port_name_t name;
{
struct mach_complex_msg *mcm = msg;
int i;
if ((mcm->mcm_header.msgh_bits & MACH_MSGH_BITS_COMPLEX) == 0) {
mcm->mcm_header.msgh_bits |= MACH_MSGH_BITS_COMPLEX;
mcm->mcm_body.msgh_descriptor_count = 0;
}
i = mcm->mcm_body.msgh_descriptor_count;
mcm->mcm_port_desc[i].name = name;
mcm->mcm_port_desc[i].disposition = MACH_MSG_TYPE_MOVE_SEND;
mcm->mcm_port_desc[i].type = MACH_MSG_PORT_DESCRIPTOR;
mcm->mcm_body.msgh_descriptor_count++;
return;
}
inline void
mach_add_ool_ports_desc(msg, addr, count)
void *msg;
void *addr;
int count;
{
struct mach_complex_msg *mcm = msg;
int i;
if ((mcm->mcm_header.msgh_bits & MACH_MSGH_BITS_COMPLEX) == 0) {
mcm->mcm_header.msgh_bits |= MACH_MSGH_BITS_COMPLEX;
mcm->mcm_body.msgh_descriptor_count = 0;
}
i = mcm->mcm_body.msgh_descriptor_count;
mcm->mcm_ool_ports_desc[i].address = addr;
mcm->mcm_ool_ports_desc[i].count = count;
mcm->mcm_ool_ports_desc[i].copy = MACH_MSG_ALLOCATE;
mcm->mcm_ool_ports_desc[i].disposition = MACH_MSG_TYPE_MOVE_SEND;
mcm->mcm_ool_ports_desc[i].type = MACH_MSG_OOL_PORTS_DESCRIPTOR;
mcm->mcm_body.msgh_descriptor_count++;
return;
}
inline void mach_add_ool_desc(msg, addr, size)
void *msg;
void *addr;
size_t size;
{
struct mach_complex_msg *mcm = msg;
int i;
if ((mcm->mcm_header.msgh_bits & MACH_MSGH_BITS_COMPLEX) == 0) {
mcm->mcm_header.msgh_bits |= MACH_MSGH_BITS_COMPLEX;
mcm->mcm_body.msgh_descriptor_count = 0;
}
i = mcm->mcm_body.msgh_descriptor_count;
mcm->mcm_ool_desc[i].address = addr;
mcm->mcm_ool_desc[i].size = size;
mcm->mcm_ool_desc[i].deallocate = 0;
mcm->mcm_ool_desc[i].copy = MACH_MSG_ALLOCATE;
mcm->mcm_ool_desc[i].type = MACH_MSG_OOL_DESCRIPTOR;
mcm->mcm_body.msgh_descriptor_count++;
return;
}
void
mach_message_init(void)
{

View File

@ -1,4 +1,4 @@
/* $NetBSD: mach_message.h,v 1.22 2003/12/08 19:27:38 manu Exp $ */
/* $NetBSD: mach_message.h,v 1.23 2003/12/09 11:29:01 manu Exp $ */
/*-
* Copyright (c) 2001-2003 The NetBSD Foundation, Inc.
@ -163,6 +163,7 @@ typedef struct {
mach_msg_id_t msgh_id;
} mach_msg_header_t;
#define MACH_MSG_TRAILER_FORMAT_0 0
typedef u_int32_t mach_msg_trailer_type_t;
typedef u_int32_t mach_msg_trailer_size_t;
typedef struct {
@ -264,6 +265,11 @@ struct mach_message {
inline int mach_ool_copyin(struct proc *, const void *, void **, size_t, int);
inline int mach_ool_copyout(struct proc *, void *, void **, size_t, int);
inline void mach_set_trailer(void *, size_t);
inline void mach_set_header(void *, void *, size_t);
inline void mach_add_port_desc(void *, mach_port_name_t);
inline void mach_add_ool_ports_desc(void *, void *, int);
inline void mach_add_ool_desc(void *, void *, size_t);
void mach_message_init(void);
struct mach_message *mach_message_get(mach_msg_header_t *,
size_t, struct mach_port *, struct lwp *);

View File

@ -1,4 +1,4 @@
/* $NetBSD: mach_notify.c,v 1.12 2003/12/08 12:03:16 manu Exp $ */
/* $NetBSD: mach_notify.c,v 1.13 2003/12/09 11:29:01 manu Exp $ */
/*-
* Copyright (c) 2003 The NetBSD Foundation, Inc.
@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: mach_notify.c,v 1.12 2003/12/08 12:03:16 manu Exp $");
__KERNEL_RCSID(0, "$NetBSD: mach_notify.c,v 1.13 2003/12/09 11:29:01 manu Exp $");
#include "opt_ktrace.h"
#include "opt_compat_mach.h" /* For COMPAT_MACH in <sys/ktrace.h> */
@ -90,7 +90,8 @@ mach_notify_port_destroyed(l, mr)
req->req_msgh.msgh_id = MACH_NOTIFY_DESTROYED_MSGID;
req->req_body.msgh_descriptor_count = 1;
req->req_rights.name = mr->mr_name;
req->req_trailer.msgh_trailer_size = 8;
mach_set_trailer(req, sizeof(*req));
(void)mach_message_get((mach_msg_header_t *)req, sizeof(*req), mp, l);
#ifdef DEBUG_MACH_MSG
@ -135,7 +136,8 @@ mach_notify_port_no_senders(l, mr)
req->req_msgh.msgh_local_port = mr->mr_notify_no_senders->mr_name;
req->req_msgh.msgh_id = MACH_NOTIFY_NO_SENDERS_MSGID;
req->req_mscount = mr->mr_refcount;
req->req_trailer.msgh_trailer_size = 8;
mach_set_trailer(req, sizeof(*req));
(void)mach_message_get((mach_msg_header_t *)req, sizeof(*req), mp, l);
#ifdef DEBUG_MACH_MSG
@ -176,7 +178,8 @@ mach_notify_port_dead_name(l, mr)
req->req_msgh.msgh_local_port = mr->mr_notify_dead_name->mr_name;
req->req_msgh.msgh_id = MACH_NOTIFY_DEAD_NAME_MSGID;
req->req_name = mr->mr_name;
req->req_trailer.msgh_trailer_size = 8;
mach_set_trailer(req, sizeof(*req));
mr->mr_refcount++;
@ -346,7 +349,7 @@ mach_exception(l, exc, code)
msglen = sizeof(*req);
msgh = (mach_msg_header_t *)req;
req->req_msgh.msgh_bits = MACH_MSGH_BITS_COMPLEX |
req->req_msgh.msgh_bits =
MACH_MSGH_REPLY_LOCAL_BITS(MACH_MSG_TYPE_MOVE_SEND) |
MACH_MSGH_REMOTE_BITS(MACH_MSG_TYPE_MOVE_SEND_ONCE);
req->req_msgh.msgh_size =
@ -354,17 +357,14 @@ mach_exception(l, exc, code)
req->req_msgh.msgh_remote_port = kernel_mr->mr_name;
req->req_msgh.msgh_local_port = exc_mr->mr_name;
req->req_msgh.msgh_id = MACH_EXC_RAISE_MSGID;
req->req_body.msgh_descriptor_count = 2;
req->req_thread.name = thread->mr_name;
req->req_thread.disposition = MACH_MSG_TYPE_MOVE_SEND;
req->req_thread.type = MACH_MSG_PORT_DESCRIPTOR;
req->req_task.name = task->mr_name;
req->req_task.disposition = MACH_MSG_TYPE_MOVE_SEND;
req->req_task.type = MACH_MSG_PORT_DESCRIPTOR;
mach_add_port_desc(req, thread->mr_name);
mach_add_port_desc(req, task->mr_name);
req->req_exc = exc;
req->req_codecount = 2;
memcpy(&req->req_code[0], code, sizeof(req->req_code));
req->req_trailer.msgh_trailer_size = 8;
break;
}
@ -376,7 +376,7 @@ mach_exception(l, exc, code)
msglen = sizeof(*req);
msgh = (mach_msg_header_t *)req;
req->req_msgh.msgh_bits = MACH_MSGH_BITS_COMPLEX |
req->req_msgh.msgh_bits =
MACH_MSGH_REPLY_LOCAL_BITS(MACH_MSG_TYPE_MOVE_SEND) |
MACH_MSGH_REMOTE_BITS(MACH_MSG_TYPE_MOVE_SEND_ONCE);
req->req_msgh.msgh_size =
@ -389,12 +389,11 @@ mach_exception(l, exc, code)
memcpy(&req->req_code[0], code, sizeof(req->req_code));
req->req_flavor = flavor;
mach_thread_get_state_machdep(l, flavor, req->req_state, &dc);
/* Trailer */
req->req_state[(dc / sizeof(req->req_state[0])) + 1] = 8;
msglen = msglen -
sizeof(req->req_state) +
(dc * sizeof(req->req_state[0]));
break;
}
@ -406,7 +405,7 @@ mach_exception(l, exc, code)
msglen = sizeof(*req);
msgh = (mach_msg_header_t *)req;
req->req_msgh.msgh_bits = MACH_MSGH_BITS_COMPLEX |
req->req_msgh.msgh_bits =
MACH_MSGH_REPLY_LOCAL_BITS(MACH_MSG_TYPE_MOVE_SEND) |
MACH_MSGH_REMOTE_BITS(MACH_MSG_TYPE_MOVE_SEND_ONCE);
req->req_msgh.msgh_size =
@ -415,12 +414,10 @@ mach_exception(l, exc, code)
req->req_msgh.msgh_local_port = exc_mr->mr_name;
req->req_msgh.msgh_id = MACH_EXC_RAISE_STATE_IDENTITY_MSGID;
req->req_body.msgh_descriptor_count = 2;
req->req_thread.name = thread->mr_name;
req->req_thread.disposition = MACH_MSG_TYPE_MOVE_SEND;
req->req_thread.type = MACH_MSG_PORT_DESCRIPTOR;
req->req_task.name = task->mr_name;
req->req_task.disposition = MACH_MSG_TYPE_MOVE_SEND;
req->req_task.type = MACH_MSG_PORT_DESCRIPTOR;
mach_add_port_desc(req, thread->mr_name);
mach_add_port_desc(req, task->mr_name);
req->req_exc = exc;
req->req_codecount = 2;
memcpy(&req->req_code[0], code, sizeof(req->req_code));
@ -441,6 +438,8 @@ mach_exception(l, exc, code)
break;
}
mach_set_trailer(msgh, msglen);
(void)mach_message_get(msgh, msglen, exc_port, NULL);
wakeup(exc_port->mp_recv->mr_sethead);

View File

@ -1,4 +1,4 @@
/* $NetBSD: mach_port.c,v 1.45 2003/12/03 18:18:43 manu Exp $ */
/* $NetBSD: mach_port.c,v 1.46 2003/12/09 11:29:01 manu Exp $ */
/*-
* Copyright (c) 2002-2003 The NetBSD Foundation, Inc.
@ -38,7 +38,7 @@
#include "opt_compat_darwin.h"
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: mach_port.c,v 1.45 2003/12/03 18:18:43 manu Exp $");
__KERNEL_RCSID(0, "$NetBSD: mach_port.c,v 1.46 2003/12/09 11:29:01 manu Exp $");
#include <sys/types.h>
#include <sys/param.h>
@ -156,14 +156,13 @@ mach_port_deallocate(args)
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);
mach_set_header(rep, req, *msglen);
rep->rep_retval = 0;
mach_set_trailer(rep, *msglen);
return 0;
}
@ -188,14 +187,13 @@ mach_port_destroy(args)
mach_right_put(mr, MACH_PORT_TYPE_ALL_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);
mach_set_header(rep, req, *msglen);
rep->rep_retval = 0;
mach_set_trailer(rep, *msglen);
return 0;
}
@ -231,15 +229,14 @@ mach_port_allocate(args)
break;
}
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_name = (mach_port_name_t)mr->mr_name;
rep->rep_trailer.msgh_trailer_size = 8;
*msglen = sizeof(*rep);
mach_set_header(rep, req, *msglen);
rep->rep_retval = 0;
rep->rep_name = (mach_port_name_t)mr->mr_name;
mach_set_trailer(rep, *msglen);
return 0;
}
@ -289,14 +286,13 @@ mach_port_insert_right(args)
break;
}
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);
mach_set_header(rep, req, *msglen);
rep->rep_retval = 0;
mach_set_trailer(rep, *msglen);
return 0;
}
@ -315,16 +311,14 @@ mach_port_type(args)
if ((mr = mach_right_check(mn, l, MACH_PORT_TYPE_ALL_RIGHTS)) == NULL)
return mach_msg_error(args, EPERM);
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;
*msglen = sizeof(*rep);
mach_set_header(rep, req, *msglen);
rep->rep_retval = 0;
rep->rep_ptype = mr->mr_type;
rep->rep_trailer.msgh_trailer_size = 8;
*msglen = sizeof(*rep);
mach_set_trailer(rep, *msglen);
return 0;
}
@ -353,14 +347,13 @@ mach_port_set_attributes(args)
break;
}
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);
mach_set_header(rep, req, *msglen);
rep->rep_retval = 0;
mach_set_trailer(rep, *msglen);
return 0;
}
@ -440,14 +433,11 @@ mach_port_get_attributes(args)
};
*msglen = sizeof(*rep) - 10 + rep->rep_count;
mach_set_header(rep, req, *msglen);
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_retval = 0;
rep->rep_info[rep->rep_count + 1] = 8;
mach_set_trailer(rep, *msglen);
return 0;
}
@ -463,14 +453,13 @@ mach_port_insert_member(args)
uprintf("Unimplemented mach_port_insert_member\n");
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);
mach_set_header(rep, req, *msglen);
rep->rep_retval = 0;
mach_set_trailer(rep, *msglen);
return 0;
}
@ -508,14 +497,13 @@ mach_port_move_member(args)
lockmgr(&med->med_rightlock, LK_RELEASE, NULL);
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);
mach_set_header(rep, req, *msglen);
rep->rep_retval = 0;
mach_set_trailer(rep, *msglen);
return 0;
}
@ -595,17 +583,11 @@ mach_port_request_notification(args)
oldmn = (mach_port_t)MACH_PORT_NULL;
}
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_body.msgh_descriptor_count = 1;
rep->rep_previous.name = oldmn;
rep->rep_previous.disposition = MACH_MSG_TYPE_MOVE_SEND_ONCE;
rep->rep_trailer.msgh_trailer_size = 8;
*msglen = sizeof(*rep);
mach_set_header(rep, req, *msglen);
mach_add_port_desc(rep, oldmn);
mach_set_trailer(rep, *msglen);
return 0;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: mach_port.h,v 1.30 2003/11/17 01:52:14 manu Exp $ */
/* $NetBSD: mach_port.h,v 1.31 2003/12/09 11:29:01 manu Exp $ */
/*-
* Copyright (c) 2002-2003 The NetBSD Foundation, Inc.
@ -316,6 +316,7 @@ struct mach_port {
#define MACH_MP_NOTIFY_SYNC 0x5 /* int */
#define MACH_MP_MEMORY_ENTRY 0x6 /* (struct mach_memory_entry *) */
#define MACH_MP_EXC_FLAGS 0x7 /* Two shorts: behavior, flavor */
#define MACH_MP_SEMAPHORE 0x8 /* (struct mach_semaphore *) */
void mach_port_init(void);
struct mach_port *mach_port_get(void);

View File

@ -1,4 +1,4 @@
/* $NetBSD: mach_semaphore.c,v 1.6 2003/11/13 13:40:39 manu Exp $ */
/* $NetBSD: mach_semaphore.c,v 1.7 2003/12/09 11:29:01 manu Exp $ */
/*-
* Copyright (c) 2002-2003 The NetBSD Foundation, Inc.
@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: mach_semaphore.c,v 1.6 2003/11/13 13:40:39 manu Exp $");
__KERNEL_RCSID(0, "$NetBSD: mach_semaphore.c,v 1.7 2003/12/09 11:29:01 manu Exp $");
#include <sys/types.h>
#include <sys/param.h>
@ -52,6 +52,8 @@ __KERNEL_RCSID(0, "$NetBSD: mach_semaphore.c,v 1.6 2003/11/13 13:40:39 manu Exp
#include <compat/mach/mach_message.h>
#include <compat/mach/mach_semaphore.h>
#include <compat/mach/mach_clock.h>
#include <compat/mach/mach_errno.h>
#include <compat/mach/mach_port.h>
#include <compat/mach/mach_services.h>
#include <compat/mach/mach_syscallargs.h>
@ -80,9 +82,18 @@ mach_sys_semaphore_wait_trap(l, v, retval)
} */ *uap = v;
struct mach_semaphore *ms;
struct mach_waiting_proc *mwp;
struct mach_right *mr;
mach_port_t mn;
int blocked = 0;
ms = (struct mach_semaphore *)SCARG(uap, wait_name);
mn = SCARG(uap, wait_name);
if ((mr = mach_right_check(mn, l, MACH_PORT_TYPE_ALL_RIGHTS)) == 0)
return EPERM;
if (mr->mr_port->mp_datatype != MACH_MP_SEMAPHORE)
return EINVAL;
ms = (struct mach_semaphore *)mr->mr_port->mp_data;
lockmgr(&ms->ms_lock, LK_EXCLUSIVE, NULL);
ms->ms_value--;
@ -110,9 +121,18 @@ mach_sys_semaphore_signal_trap(l, v, retval)
} */ *uap = v;
struct mach_semaphore *ms;
struct mach_waiting_proc *mwp;
struct mach_right *mr;
mach_port_t mn;
int unblocked = 0;
ms = (struct mach_semaphore *)SCARG(uap, signal_name);
mn = SCARG(uap, signal_name);
if ((mr = mach_right_check(mn, l, MACH_PORT_TYPE_ALL_RIGHTS)) == 0)
return EPERM;
if (mr->mr_port->mp_datatype != MACH_MP_SEMAPHORE)
return EINVAL;
ms = (struct mach_semaphore *)mr->mr_port->mp_datatype;
lockmgr(&ms->ms_lock, LK_EXCLUSIVE, NULL);
ms->ms_value++;
@ -136,19 +156,24 @@ mach_semaphore_create(args)
mach_semaphore_create_request_t *req = args->smsg;
mach_semaphore_create_reply_t *rep = args->rmsg;
size_t *msglen = args->rsize;
struct lwp *l = args->l;
struct mach_semaphore *ms;
struct mach_port *mp;
struct mach_right *mr;
ms = mach_semaphore_get(req->req_value, req->req_policy);
mp = mach_port_get();
mp->mp_datatype = MACH_MP_SEMAPHORE;
mp->mp_data = (void *)ms;
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_sem.name = (mach_port_t)ms; /* Waiting for better */
rep->rep_trailer.msgh_trailer_size = 8;
mr = mach_right_get(mp, l, MACH_PORT_TYPE_SEND, 0);
*msglen = sizeof(*rep);
mach_set_header(rep, req, *msglen);
mach_add_port_desc(rep, mr->mr_name);
mach_set_trailer(rep, *msglen);
return 0;
}
@ -158,20 +183,30 @@ mach_semaphore_destroy(args)
{
mach_semaphore_destroy_request_t *req = args->smsg;
mach_semaphore_destroy_reply_t *rep = args->rmsg;
struct lwp *l = args->l;
size_t *msglen = args->rsize;
struct mach_semaphore *ms;
struct mach_right *mr;
mach_port_t mn;
ms = (struct mach_semaphore *)req->req_sem.name;
mn = req->req_sem.name;
if ((mr = mach_right_check(mn, l, MACH_PORT_TYPE_ALL_RIGHTS)) == 0)
return mach_msg_error(args, EPERM);
if (mr->mr_port->mp_datatype != MACH_MP_SEMAPHORE)
return mach_msg_error(args, EINVAL);
ms = (struct mach_semaphore *)mr->mr_port->mp_data;
mach_semaphore_put(ms);
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);
mach_set_header(rep, req, *msglen);
rep->rep_retval = 0;
mach_set_trailer(rep, *msglen);
return 0;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: mach_task.c,v 1.48 2003/12/08 19:27:38 manu Exp $ */
/* $NetBSD: mach_task.c,v 1.49 2003/12/09 11:29:01 manu Exp $ */
/*-
* Copyright (c) 2002-2003 The NetBSD Foundation, Inc.
@ -40,7 +40,7 @@
#include "opt_compat_darwin.h"
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: mach_task.c,v 1.48 2003/12/08 19:27:38 manu Exp $");
__KERNEL_RCSID(0, "$NetBSD: mach_task.c,v 1.49 2003/12/09 11:29:01 manu Exp $");
#include <sys/types.h>
#include <sys/param.h>
@ -114,19 +114,11 @@ mach_task_get_special_port(args)
break;
}
rep->rep_msgh.msgh_bits =
MACH_MSGH_REPLY_LOCAL_BITS(MACH_MSG_TYPE_MOVE_SEND_ONCE) |
MACH_MSGH_BITS_COMPLEX;
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;
rep->rep_special_port.name = (mach_port_t)mr->mr_name;
rep->rep_special_port.disposition = MACH_MSG_TYPE_MOVE_SEND;
rep->rep_special_port.type = MACH_MSG_PORT_DESCRIPTOR;
rep->rep_trailer.msgh_trailer_size = 8;
*msglen = sizeof(*rep);
mach_set_header(rep, req, *msglen);
mach_add_port_desc(rep, mr->mr_name);
mach_set_trailer(rep, *msglen);
return 0;
}
@ -145,6 +137,7 @@ mach_ports_lookup(args)
mach_port_name_t mnp[7];
void *uaddr;
int error;
int count;
/*
* This is some out of band data sent with the reply. In the
@ -173,22 +166,16 @@ mach_ports_lookup(args)
&uaddr, sizeof(mnp), MACH_OOL_TRACE)) != 0)
return mach_msg_error(args, error);
rep->rep_msgh.msgh_bits =
MACH_MSGH_REPLY_LOCAL_BITS(MACH_MSG_TYPE_MOVE_SEND_ONCE) |
MACH_MSGH_BITS_COMPLEX;
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;
rep->rep_init_port_set.address = uaddr;
rep->rep_init_port_set.count = 3; /* XXX should be 7? */
rep->rep_init_port_set.copy = MACH_MSG_ALLOCATE;
rep->rep_init_port_set.disposition = MACH_MSG_TYPE_MOVE_SEND;
rep->rep_init_port_set.type = MACH_MSG_OOL_PORTS_DESCRIPTOR;
rep->rep_init_port_set_count = 3;
rep->rep_trailer.msgh_trailer_size = 8;
count = 3; /* XXX Shouldn't this be 7? */
*msglen = sizeof(*rep);
mach_set_header(rep, req, *msglen);
mach_add_ool_ports_desc(rep, uaddr, count);
rep->rep_init_port_set_count = count;
mach_set_trailer(rep, *msglen);
return 0;
}
@ -271,14 +258,13 @@ mach_task_set_special_port(args)
req->req_which_port);
}
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);
mach_set_header(rep, req, *msglen);
rep->rep_retval = 0;
mach_set_trailer(rep, *msglen);
return 0;
}
@ -316,22 +302,14 @@ mach_task_threads(args)
size, MACH_OOL_TRACE|MACH_OOL_FREE)) != 0)
return mach_msg_error(args, error);
rep->rep_msgh.msgh_bits =
MACH_MSGH_REPLY_LOCAL_BITS(MACH_MSG_TYPE_MOVE_SEND_ONCE) |
MACH_MSGH_BITS_COMPLEX;
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;
rep->rep_list.address = uaddr;
rep->rep_list.count = tp->p_nlwps;
rep->rep_list.copy = MACH_MSG_ALLOCATE;
rep->rep_list.disposition = MACH_MSG_TYPE_MOVE_SEND;
rep->rep_list.type = MACH_MSG_OOL_PORTS_DESCRIPTOR;
rep->rep_count = tp->p_nlwps;
rep->rep_trailer.msgh_trailer_size = 8;
*msglen = sizeof(*rep);
mach_set_header(rep, req, *msglen);
mach_add_ool_ports_desc(rep, uaddr, tp->p_nlwps);
rep->rep_count = tp->p_nlwps;
mach_set_trailer(rep, *msglen);
return 0;
}
@ -353,13 +331,8 @@ mach_task_get_exception_ports(args)
/* It always return an array of 32 ports even if only 9 can be used */
count = sizeof(rep->rep_old_handler) / sizeof(rep->rep_old_handler[0]);
rep->rep_msgh.msgh_bits =
MACH_MSGH_REPLY_LOCAL_BITS(MACH_MSG_TYPE_MOVE_SEND_ONCE) |
MACH_MSGH_BITS_COMPLEX;
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 = count;
mach_set_header(rep, req, *msglen);
rep->rep_masks_count = count;
j = 0;
@ -369,9 +342,8 @@ mach_task_get_exception_ports(args)
mr = mach_right_get(med->med_exc[i], l, MACH_PORT_TYPE_SEND, 0);
rep->rep_old_handler[j].name = mr->mr_name;
rep->rep_old_handler[j].disposition = MACH_MSG_TYPE_MOVE_SEND;
rep->rep_old_handler[j].type = MACH_MSG_PORT_DESCRIPTOR;
mach_add_port_desc(rep, mr->mr_name);
rep->rep_masks[j] = 1 << i;
rep->rep_old_behaviors[j] = (int)mr->mr_port->mp_data >> 16;
rep->rep_old_flavors[j] = (int)mr->mr_port->mp_data & 0xffff;
@ -379,9 +351,8 @@ mach_task_get_exception_ports(args)
j++;
}
rep->rep_trailer.msgh_trailer_size = 8;
*msglen = sizeof(*rep);
mach_set_trailer(rep, *msglen);
return 0;
}
@ -458,14 +429,12 @@ mach_task_set_exception_ports(args)
"not supported (mask %x)\n", req->req_mask);
#endif
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);
mach_set_header(rep, req, *msglen);
rep->rep_retval = 0;
mach_set_trailer(rep, *msglen);
return 0;
}
@ -558,13 +527,11 @@ mach_task_info(args)
return mach_msg_error(args, EINVAL);
};
rep->rep_msgh.msgh_bits =
MACH_MSGH_REPLY_LOCAL_BITS(MACH_MSG_TYPE_MOVE_SEND_ONCE);
rep->rep_msgh.msgh_size = *msglen - 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;
mach_set_header(rep, req, *msglen);
rep->rep_count = count;
rep->rep_info[count + 1] = 8; /* Trailer */
mach_set_trailer(rep, *msglen);
return 0;
}
@ -600,14 +567,12 @@ mach_task_suspend(args)
}
proc_stop(tp, 0);
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);
mach_set_header(rep, req, *msglen);
rep->rep_retval = 0;
mach_set_trailer(rep, *msglen);
return 0;
}
@ -636,16 +601,12 @@ mach_task_resume(args)
#endif
(void)proc_unstop(tp);
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;
proc_unstop(tl->l_proc);
rep->rep_retval = 0;
rep->rep_trailer.msgh_trailer_size = 8;
*msglen = sizeof(*rep);
mach_set_header(rep, req, *msglen);
rep->rep_retval = 0;
mach_set_trailer(rep, *msglen);
return 0;
}
@ -666,15 +627,12 @@ mach_task_terminate(args)
SCARG(&cup, rval) = 0;
error = sys_exit(tl, &cup, &retval);
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_retval = native_to_mach_errno[error];
rep->rep_trailer.msgh_trailer_size = 8;
*msglen = sizeof(*rep);
mach_set_header(rep, req, *msglen);
rep->rep_retval = native_to_mach_errno[error];
mach_set_trailer(rep, *msglen);
return 0;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: mach_thread.c,v 1.28 2003/12/03 22:25:46 manu Exp $ */
/* $NetBSD: mach_thread.c,v 1.29 2003/12/09 11:29:01 manu Exp $ */
/*-
* Copyright (c) 2002-2003 The NetBSD Foundation, Inc.
@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: mach_thread.c,v 1.28 2003/12/03 22:25:46 manu Exp $");
__KERNEL_RCSID(0, "$NetBSD: mach_thread.c,v 1.29 2003/12/09 11:29:01 manu Exp $");
#include <sys/types.h>
#include <sys/param.h>
@ -173,14 +173,13 @@ mach_thread_policy(args)
uprintf("Unimplemented mach_thread_policy\n");
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);
mach_set_header(rep, req, *msglen);
rep->rep_retval = 0;
mach_set_trailer(rep, *msglen);
return 0;
}
@ -246,15 +245,13 @@ mach_thread_create_running(args)
(void)tsleep(&mctc.mctc_child_done,
PZERO|PCATCH, "mach_thread", 0);
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;
/* XXX do something for rep->rep_child_act */
rep->rep_trailer.msgh_trailer_size = 8;
*msglen = sizeof(*rep);
mach_set_header(rep, req, *msglen);
/* XXX do something for rep->rep_child_act */
mach_set_trailer(rep, *msglen);
return 0;
}
@ -273,11 +270,10 @@ mach_thread_info(args)
if (req->req_count > 12)
return mach_msg_error(args, EINVAL);
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_count = req->req_count;
*msglen = sizeof(*rep) + ((req->req_count - 12) * sizeof(int));
mach_set_header(rep, req, *msglen);
switch (req->req_flavor) {
case MACH_THREAD_BASIC_INFO: {
@ -347,10 +343,7 @@ mach_thread_info(args)
break;
}
rep->rep_count = req->req_count;
rep->rep_out[rep->rep_count + 1] = 8; /* This is the trailer */
*msglen = sizeof(*rep) + ((req->req_count - 12) * sizeof(int));
mach_set_trailer(rep, *msglen);
return 0;
}
@ -374,15 +367,10 @@ mach_thread_get_state(args)
req->req_flavor, &rep->rep_state, &size)) != 0)
return mach_msg_error(args, error);
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_count = size / sizeof(int);
rep->rep_state[rep->rep_count + 1] = 8; /* This is the trailer */
*msglen = sizeof(*rep) + ((req->req_count - 144) * sizeof(int));
mach_set_header(rep, req, *msglen);
mach_set_trailer(rep, *msglen);
return 0;
}
@ -407,14 +395,12 @@ mach_thread_set_state(args)
req->req_flavor, &req->req_state)) != 0)
return mach_msg_error(args, error);
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);
mach_set_header(rep, req, *msglen);
rep->rep_retval = 0;
mach_set_trailer(rep, *msglen);
return 0;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: mach_vm.c,v 1.43 2003/12/08 12:03:16 manu Exp $ */
/* $NetBSD: mach_vm.c,v 1.44 2003/12/09 11:29:01 manu Exp $ */
/*-
* Copyright (c) 2002-2003 The NetBSD Foundation, Inc.
@ -39,7 +39,7 @@
#include "opt_ktrace.h"
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: mach_vm.c,v 1.43 2003/12/08 12:03:16 manu Exp $");
__KERNEL_RCSID(0, "$NetBSD: mach_vm.c,v 1.44 2003/12/09 11:29:01 manu Exp $");
#include <sys/types.h>
#include <sys/param.h>
@ -151,14 +151,10 @@ mach_vm_map(args)
if ((error = sys_mmap(tl, &cup, &rep->rep_retval)) != 0)
return mach_msg_error(args, error);
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);
mach_set_header(rep, req, *msglen);
mach_set_trailer(rep, *msglen);
return 0;
}
@ -227,14 +223,13 @@ mach_vm_allocate(args)
#endif
out:
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);
mach_set_header(rep, req, *msglen);
rep->rep_retval = 0;
mach_set_trailer(rep, *msglen);
return 0;
}
@ -260,14 +255,10 @@ mach_vm_deallocate(args)
if ((error = sys_munmap(tl, &cup, &rep->rep_retval)) != 0)
return mach_msg_error(args, error);
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);
mach_set_header(rep, req, *msglen);
mach_set_trailer(rep, *msglen);
return 0;
}
@ -322,14 +313,10 @@ mach_vm_wire(args)
req->req_access, 0)) != 0)
return mach_msg_error(args, error);
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);
mach_set_header(rep, req, *msglen);
mach_set_trailer(rep, *msglen);
return 0;
}
#endif
@ -353,14 +340,10 @@ mach_vm_protect(args)
if ((error = sys_mprotect(tl, &cup, &retval)) != 0)
return mach_msg_error(args, error);
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);
mach_set_header(rep, req, *msglen);
mach_set_trailer(rep, *msglen);
return 0;
}
@ -504,14 +487,10 @@ mach_vm_inherit(args)
if ((error = sys_minherit(tl, &cup, &retval)) != 0)
return mach_msg_error(args, error);
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);
mach_set_header(rep, req, *msglen);
mach_set_trailer(rep, *msglen);
return 0;
}
@ -543,19 +522,14 @@ mach_make_memory_entry_64(args)
mr = mach_right_get(mp, l, MACH_PORT_TYPE_SEND, 0);
rep->rep_msgh.msgh_bits =
MACH_MSGH_REPLY_LOCAL_BITS(MACH_MSG_TYPE_MOVE_SEND_ONCE) |
MACH_MSGH_BITS_COMPLEX;
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_obj_handle.name = (mach_port_t)mr->mr_name;
rep->rep_obj_handle.disposition = MACH_MSG_TYPE_MOVE_SEND;
rep->rep_obj_handle.type = MACH_MSG_PORT_DESCRIPTOR;
rep->rep_size = req->req_size;
rep->rep_trailer.msgh_trailer_size = 8;
*msglen = sizeof(*rep);
mach_set_header(rep, req, *msglen);
mach_add_port_desc(rep, mr->mr_name);
rep->rep_size = req->req_size;
mach_set_trailer(rep, *msglen);
return 0;
}
@ -595,16 +569,9 @@ mach_vm_region(args)
if (error == 0)
return mach_msg_error(args, ENOMEM);
rep->rep_msgh.msgh_bits =
MACH_MSGH_REPLY_LOCAL_BITS(MACH_MSG_TYPE_MOVE_SEND_ONCE) |
MACH_MSGH_BITS_COMPLEX;
rep->rep_msgh.msgh_size = *msglen - 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;
rep->rep_obj.name = 0;
rep->rep_obj.disposition = MACH_MSG_TYPE_MOVE_SEND;
rep->rep_obj.type = MACH_MSG_PORT_DESCRIPTOR;
mach_set_header(rep, req, *msglen);
mach_add_port_desc(rep, 0); /* XXX Why this null name */
rep->rep_addr = vme->start;
rep->rep_size = vme->end - vme->start;
rep->rep_count = req->req_count;
@ -620,7 +587,7 @@ mach_vm_region(args)
/* XXX Why this? */
*(short *)((u_long)&rbi->user_wired_count + sizeof(short)) = 1;
rep->rep_info[rep->rep_count + 1] = 8; /* This is the trailer */
mach_set_trailer(rep, *msglen);
return 0;
}
@ -661,16 +628,9 @@ mach_vm_region_64(args)
if (error == 0)
return mach_msg_error(args, ENOMEM);
rep->rep_msgh.msgh_bits =
MACH_MSGH_REPLY_LOCAL_BITS(MACH_MSG_TYPE_MOVE_SEND_ONCE) |
MACH_MSGH_BITS_COMPLEX;
rep->rep_msgh.msgh_size = *msglen - 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;
rep->rep_obj.name = 0;
rep->rep_obj.disposition = MACH_MSG_TYPE_MOVE_SEND;
rep->rep_obj.type = MACH_MSG_PORT_DESCRIPTOR;
mach_set_header(rep, req, *msglen);
mach_add_port_desc(rep, 0); /* XXX null port ? */
rep->rep_size = PAGE_SIZE; /* XXX Why? */
rep->rep_count = req->req_count;
@ -685,7 +645,7 @@ mach_vm_region_64(args)
/* XXX Why this? */
*(short *)((u_long)&rbi->user_wired_count + sizeof(short)) = 1;
rep->rep_info[rep->rep_count + 1] = 8; /* This is the trailer */
mach_set_trailer(rep, *msglen);
return 0;
}
@ -714,15 +674,13 @@ mach_vm_msync(args)
error = sys___msync13(tl, &cup, &dontcare);
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_retval = error;
rep->rep_trailer.msgh_trailer_size = 8;
*msglen = sizeof(*rep);
mach_set_header(rep, req, *msglen);
rep->rep_retval = native_to_mach_errno[error];
mach_set_trailer(rep, *msglen);
return 0;
}
@ -763,15 +721,13 @@ mach_vm_copy(args)
req->req_size -= PAGE_SIZE;
} while (req->req_size != 0);
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_retval = 0;
rep->rep_trailer.msgh_trailer_size = 8;
*msglen = sizeof(*rep);
mach_set_header(rep, req, *msglen);
rep->rep_retval = 0;
mach_set_trailer(rep, *msglen);
return 0;
}
@ -827,22 +783,14 @@ mach_vm_read(args)
free(buf, M_WAITOK);
rep->rep_msgh.msgh_bits =
MACH_MSGH_REPLY_LOCAL_BITS(MACH_MSG_TYPE_MOVE_SEND_ONCE) |
MACH_MSGH_BITS_COMPLEX;
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;
rep->rep_data.address = (void *)va;
rep->rep_data.size = size;
rep->rep_data.deallocate = 0;
rep->rep_data.copy = MACH_MSG_ALLOCATE;
rep->rep_data.type = MACH_MSG_OOL_DESCRIPTOR;
rep->rep_count = size;
rep->rep_trailer.msgh_trailer_size = 8;
*msglen = sizeof(*rep);
mach_set_header(rep, req, *msglen);
mach_add_ool_desc(rep, (void *)va, size);
rep->rep_count = size;
mach_set_trailer(rep, *msglen);
return 0;
}
@ -893,14 +841,13 @@ mach_vm_write(args)
free(buf, M_WAITOK);
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);
mach_set_header(rep, req, *msglen);
rep->rep_retval = 0;
mach_set_trailer(rep, *msglen);
return 0;
}
@ -947,16 +894,14 @@ mach_vm_machine_attribute(args)
break;
}
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_retval = error;
*msglen = sizeof(*rep);
mach_set_header(rep, req, *msglen);
rep->rep_retval = native_to_mach_errno[error];
if (error != 0)
rep->rep_value = value;
rep->rep_trailer.msgh_trailer_size = 8;
*msglen = sizeof(*rep);
mach_set_trailer(rep, *msglen);
return 0;
}