From d5dfcf76de2215803243f6fb806a00f260422e4a Mon Sep 17 00:00:00 2001 From: christos Date: Sun, 29 Jul 2001 19:30:56 +0000 Subject: [PATCH] a bit more mach glue. --- sys/compat/mach/mach_message.h | 74 ++++++++++++++++++++++++++++++ sys/compat/mach/mach_misc.c | 43 ++++++++++++++++- sys/compat/mach/mach_syscall.h | 6 +-- sys/compat/mach/mach_syscallargs.h | 16 ++++++- sys/compat/mach/mach_syscalls.c | 5 +- sys/compat/mach/mach_sysent.c | 7 +-- sys/compat/mach/mach_types.h | 3 +- sys/compat/mach/syscalls.master | 13 +++++- 8 files changed, 151 insertions(+), 16 deletions(-) create mode 100644 sys/compat/mach/mach_message.h diff --git a/sys/compat/mach/mach_message.h b/sys/compat/mach/mach_message.h new file mode 100644 index 000000000000..5c66c2c2f57c --- /dev/null +++ b/sys/compat/mach/mach_message.h @@ -0,0 +1,74 @@ +/* $NetBSD: mach_message.h,v 1.1 2001/07/29 19:30:56 christos Exp $ */ + +/*- + * Copyright (c) 2001 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Christos Zoulas. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the NetBSD + * Foundation, Inc. and its contributors. + * 4. Neither the name of The NetBSD Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _MACH_MESSAGE_H_ +#define _MACH_MESSAGE_H_ + +typedef u_int32_t mach_msg_bits_t; +typedef u_int32_t mach_msg_size_t; +typedef u_int32_t mach_msg_id_t; +typedef u_int32_t mach_msg_timeout_t; +typedef u_int32_t mach_msg_option_t; + +/* + * Options + */ +#define MACH_MSG_OPTION_NONE 0x00000000 +#define MACH_SEND_MSG 0x00000001 +#define MACH_RCV_MSG 0x00000002 +#define MACH_RCV_LARGE 0x00000004 +#define MACH_SEND_TIMEOUT 0x00000010 +#define MACH_SEND_INTERRUPT 0x00000040 +#define MACH_SEND_CANCEL 0x00000080 +#define MACH_RCV_TIMEOUT 0x00000100 +#define MACH_RCV_NOTIFY 0x00000200 +#define MACH_RCV_INTERRUPT 0x00000400 +#define MACH_RCV_OVERWRITE 0x00001000 +#define MACH_SEND_ALWAYS 0x00010000 +#define MACH_SEND_TRAILER 0x00020000 + +typedef struct { + mach_msg_bits_t msgh_bits; + mach_msg_size_t msgh_size; + mach_port_t msgh_remote_port; + mach_port_t msgh_local_port; + mach_msg_size_t msgh_reserved; + mach_msg_id_t msgh_id; +} mach_msg_header_t; + +#endif /* !_MACH_MESSAGE_H_ */ diff --git a/sys/compat/mach/mach_misc.c b/sys/compat/mach/mach_misc.c index fbe559ecf7ab..c0ac6310d599 100644 --- a/sys/compat/mach/mach_misc.c +++ b/sys/compat/mach/mach_misc.c @@ -1,4 +1,4 @@ -/* $NetBSD: mach_misc.c,v 1.1 2001/07/14 02:11:00 christos Exp $ */ +/* $NetBSD: mach_misc.c,v 1.2 2001/07/29 19:30:56 christos Exp $ */ /*- * Copyright (c) 2001 The NetBSD Foundation, Inc. @@ -78,8 +78,21 @@ #include #include +#include #include +#ifdef DEBUG_MACH +static void mach_print_msg_header_t(mach_msg_header_t *); + +static void +mach_print_msg_header_t(mach_msg_header_t *mh) { + uprintf("msgh { bits=0x%x, size=%d, remote_port=%d, local_port=%d," + "reserved=%d,id=%d }\n", + mh->msgh_bits, mh->msgh_size, mh->msgh_remote_port, + mh->msgh_local_port, mh->msgh_reserved, mh->msgh_id); +} +#endif /* DEBUG_MACH */ + int mach_sys_reply_port(struct proc *p, void *vv, register_t *r) { *r = 0; @@ -113,8 +126,34 @@ mach_sys_host_self_trap(struct proc *p, void *v, register_t *r) { int mach_sys_msg_overwrite_trap(struct proc *p, void *v, register_t *r) { + struct mach_sys_msg_overwrite_trap_args *ap = v; + int error; *r = 0; - DPRINTF(("mach_sys_msg_overwrite_trap();\n")); + + DPRINTF(("mach_sys_msg_overwrite_trap(%p, 0x%x," + " %d, %d, 0x%x, %d, 0x%x, %p, %d);\n", + SCARG(ap, msg), SCARG(ap, option), SCARG(ap, send_size), + SCARG(ap, rcv_size), SCARG(ap, rcv_name), SCARG(ap, timeout), + SCARG(ap, notify), SCARG(ap, rcv_msg), + SCARG(ap, scatter_list_size))); + + switch (SCARG(ap, option)) { + case MACH_SEND_MSG|MACH_RCV_MSG: + if (SCARG(ap, msg)) { + mach_msg_header_t mh; + if ((error = copyin(SCARG(ap, msg), &mh, + sizeof(mh))) != 0) + return error; +#ifdef DEBUG_MACH + mach_print_msg_header_t(&mh); +#endif /* DEBUG_MACH */ + } + break; + default: + uprintf("unhandled sys_msg_override_trap option %x\n", + SCARG(ap, option)); + break; + } return 0; } diff --git a/sys/compat/mach/mach_syscall.h b/sys/compat/mach/mach_syscall.h index 4a61823f9c1a..afd00fd26841 100644 --- a/sys/compat/mach/mach_syscall.h +++ b/sys/compat/mach/mach_syscall.h @@ -1,10 +1,10 @@ -/* $NetBSD: mach_syscall.h,v 1.1 2001/07/14 02:11:00 christos Exp $ */ +/* $NetBSD: mach_syscall.h,v 1.2 2001/07/29 19:30:56 christos Exp $ */ /* * System call numbers. * * DO NOT EDIT-- this file is automatically generated. - * created from NetBSD: syscalls.master,v 1.51 2001/05/30 11:37:32 mrg Exp + * created from NetBSD: syscalls.master,v 1.1 2001/07/14 02:11:02 christos Exp */ /* syscall: "reply_port" ret: "mach_port_name_t" args: */ @@ -19,7 +19,7 @@ /* syscall: "host_self_trap" ret: "mach_port_name_t" args: */ #define MACH_SYS_host_self_trap 29 -/* syscall: "msg_overwrite_trap" ret: "mach_kern_return_t" args: */ +/* syscall: "msg_overwrite_trap" ret: "mach_kern_return_t" args: "mach_msg_header_t *" "mach_msg_option_t" "mach_msg_size_t" "mach_msg_size_t" "mach_port_name_t" "mach_msg_timeout_t" "mach_port_name_t" "mach_msg_header_t *" "mach_msg_size_t" */ #define MACH_SYS_msg_overwrite_trap 32 /* syscall: "semaphore_signal_trap" ret: "mach_kern_return_t" args: "mach_port_name_t" */ diff --git a/sys/compat/mach/mach_syscallargs.h b/sys/compat/mach/mach_syscallargs.h index 8c1b35b3aee4..b692bd234b0c 100644 --- a/sys/compat/mach/mach_syscallargs.h +++ b/sys/compat/mach/mach_syscallargs.h @@ -1,10 +1,10 @@ -/* $NetBSD: mach_syscallargs.h,v 1.1 2001/07/14 02:11:01 christos Exp $ */ +/* $NetBSD: mach_syscallargs.h,v 1.2 2001/07/29 19:30:56 christos Exp $ */ /* * System call argument lists. * * DO NOT EDIT-- this file is automatically generated. - * created from NetBSD: syscalls.master,v 1.51 2001/05/30 11:37:32 mrg Exp + * created from NetBSD: syscalls.master,v 1.1 2001/07/14 02:11:02 christos Exp */ #ifndef _MACH_SYS__SYSCALLARGS_H_ @@ -26,6 +26,18 @@ } be; \ } +struct mach_sys_msg_overwrite_trap_args { + syscallarg(mach_msg_header_t *) msg; + syscallarg(mach_msg_option_t) option; + syscallarg(mach_msg_size_t) send_size; + syscallarg(mach_msg_size_t) rcv_size; + syscallarg(mach_port_name_t) rcv_name; + syscallarg(mach_msg_timeout_t) timeout; + syscallarg(mach_port_name_t) notify; + syscallarg(mach_msg_header_t *) rcv_msg; + syscallarg(mach_msg_size_t) scatter_list_size; +}; + struct mach_sys_semaphore_signal_trap_args { syscallarg(mach_port_name_t) signal_name; }; diff --git a/sys/compat/mach/mach_syscalls.c b/sys/compat/mach/mach_syscalls.c index 4e145dcee06f..a14d6145902a 100644 --- a/sys/compat/mach/mach_syscalls.c +++ b/sys/compat/mach/mach_syscalls.c @@ -1,10 +1,10 @@ -/* $NetBSD: mach_syscalls.c,v 1.1 2001/07/14 02:11:01 christos Exp $ */ +/* $NetBSD: mach_syscalls.c,v 1.2 2001/07/29 19:30:56 christos Exp $ */ /* * System call names. * * DO NOT EDIT-- this file is automatically generated. - * created from NetBSD: syscalls.master,v 1.51 2001/05/30 11:37:32 mrg Exp + * created from NetBSD: syscalls.master,v 1.1 2001/07/14 02:11:02 christos Exp */ #if defined(_KERNEL_OPT) @@ -19,6 +19,7 @@ #include #include #include +#include #include #endif /* _KERNEL_OPT */ diff --git a/sys/compat/mach/mach_sysent.c b/sys/compat/mach/mach_sysent.c index 515238e619e0..a8a83a8e5388 100644 --- a/sys/compat/mach/mach_sysent.c +++ b/sys/compat/mach/mach_sysent.c @@ -1,10 +1,10 @@ -/* $NetBSD: mach_sysent.c,v 1.1 2001/07/14 02:11:02 christos Exp $ */ +/* $NetBSD: mach_sysent.c,v 1.2 2001/07/29 19:30:57 christos Exp $ */ /* * System call switch table. * * DO NOT EDIT-- this file is automatically generated. - * created from NetBSD: syscalls.master,v 1.51 2001/05/30 11:37:32 mrg Exp + * created from NetBSD: syscalls.master,v 1.1 2001/07/14 02:11:02 christos Exp */ #if defined(_KERNEL_OPT) @@ -18,6 +18,7 @@ #include #include #include +#include #include #define s(type) sizeof(type) @@ -87,7 +88,7 @@ struct sysent mach_sysent[] = { sys_nosys }, /* 30 = unimplemented */ { 0, 0, 0, sys_nosys }, /* 31 = unimplemented */ - { 0, 0, 0, + { 9, s(struct mach_sys_msg_overwrite_trap_args), 0, mach_sys_msg_overwrite_trap }, /* 32 = msg_overwrite_trap */ { 1, s(struct mach_sys_semaphore_signal_trap_args), 0, mach_sys_semaphore_signal_trap }, /* 33 = semaphore_signal_trap */ diff --git a/sys/compat/mach/mach_types.h b/sys/compat/mach/mach_types.h index 7d35722c5cd8..62b93e2e22fa 100644 --- a/sys/compat/mach/mach_types.h +++ b/sys/compat/mach/mach_types.h @@ -1,4 +1,4 @@ -/* $NetBSD: mach_types.h,v 1.1 2001/07/14 02:11:02 christos Exp $ */ +/* $NetBSD: mach_types.h,v 1.2 2001/07/29 19:30:57 christos Exp $ */ /*- * Copyright (c) 2001 The NetBSD Foundation, Inc. @@ -44,7 +44,6 @@ typedef int mach_port_name_t; typedef int mach_kern_return_t; typedef int mach_clock_res_t; typedef int mach_boolean_t; -typedef int mach_msg_timeout_t; typedef int mach_sleep_type_t; typedef int mach_timespec_t; typedef int mach_absolute_time_t; diff --git a/sys/compat/mach/syscalls.master b/sys/compat/mach/syscalls.master index 4c2d09536340..590a6844c8e3 100644 --- a/sys/compat/mach/syscalls.master +++ b/sys/compat/mach/syscalls.master @@ -1,4 +1,4 @@ - $NetBSD: syscalls.master,v 1.1 2001/07/14 02:11:02 christos Exp $ + $NetBSD: syscalls.master,v 1.2 2001/07/29 19:30:57 christos Exp $ ; @(#)syscalls.master 8.1 (Berkeley) 7/19/93 @@ -45,6 +45,7 @@ #include #include +#include #include %% @@ -82,7 +83,15 @@ 30 UNIMPL 31 UNIMPL 32 STD { mach_kern_return_t mach_sys_msg_overwrite_trap( \ - void); } + mach_msg_header_t *msg, \ + mach_msg_option_t option, \ + mach_msg_size_t send_size, \ + mach_msg_size_t rcv_size, \ + mach_port_name_t rcv_name, \ + mach_msg_timeout_t timeout, \ + mach_port_name_t notify, \ + mach_msg_header_t *rcv_msg, \ + mach_msg_size_t scatter_list_size); } 33 STD { mach_kern_return_t \ mach_sys_semaphore_signal_trap( \ mach_port_name_t signal_name); }