More mach traps:

mach_port_deallocate, task_get_special_port, mach_ports_lookup,
vm_deallocate, vm_map, host_get_clock_service.
This commit is contained in:
manu 2002-11-10 21:53:40 +00:00
parent 0d842ff28e
commit 556831bae9
13 changed files with 764 additions and 71 deletions

View File

@ -1,4 +1,4 @@
# $NetBSD: files.mach,v 1.3 2002/11/10 02:18:03 manu Exp $ # $NetBSD: files.mach,v 1.4 2002/11/10 21:53:40 manu Exp $
# #
# Config file description for machine-independent Mach compat code. # Config file description for machine-independent Mach compat code.
# Included by ports that need it. # Included by ports that need it.
@ -8,7 +8,10 @@
file compat/mach/mach_exec.c compat_mach file compat/mach/mach_exec.c compat_mach
file compat/mach/mach_host.c compat_mach file compat/mach/mach_host.c compat_mach
file compat/mach/mach_namemap.c compat_mach
file compat/mach/mach_misc.c compat_mach file compat/mach/mach_misc.c compat_mach
file compat/mach/mach_namemap.c compat_mach
file compat/mach/mach_port.c compat_mach
file compat/mach/mach_syscalls.c compat_mach file compat/mach/mach_syscalls.c compat_mach
file compat/mach/mach_sysent.c compat_mach file compat/mach/mach_sysent.c compat_mach
file compat/mach/mach_task.c compat_mach
file compat/mach/mach_vm.c compat_mach

View File

@ -1,4 +1,4 @@
/* $NetBSD: mach_host.c,v 1.2 2002/11/10 09:41:45 manu Exp $ */ /* $NetBSD: mach_host.c,v 1.3 2002/11/10 21:53:40 manu Exp $ */
/*- /*-
* Copyright (c) 2002 The NetBSD Foundation, Inc. * Copyright (c) 2002 The NetBSD Foundation, Inc.
@ -37,12 +37,14 @@
*/ */
#include <sys/cdefs.h> #include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: mach_host.c,v 1.2 2002/11/10 09:41:45 manu Exp $"); __KERNEL_RCSID(0, "$NetBSD: mach_host.c,v 1.3 2002/11/10 21:53:40 manu Exp $");
#include <sys/types.h> #include <sys/types.h>
#include <sys/malloc.h> #include <sys/malloc.h>
#include <sys/param.h> #include <sys/param.h>
#include <sys/systm.h> #include <sys/systm.h>
#include <sys/signal.h>
#include <sys/proc.h>
#include <uvm/uvm_extern.h> #include <uvm/uvm_extern.h>
#include <uvm/uvm_param.h> #include <uvm/uvm_param.h>
@ -51,7 +53,8 @@ __KERNEL_RCSID(0, "$NetBSD: mach_host.c,v 1.2 2002/11/10 09:41:45 manu Exp $");
#include <compat/mach/mach_host.h> #include <compat/mach/mach_host.h>
int int
mach_host_info(msgh) mach_host_info(p, msgh)
struct proc *p;
mach_msg_header_t *msgh; mach_msg_header_t *msgh;
{ {
mach_host_info_request_t req; mach_host_info_request_t req;
@ -59,12 +62,29 @@ mach_host_info(msgh)
size_t msglen; size_t msglen;
int error; int error;
DPRINTF(("mach_host_info\n"));
if ((error = copyin(msgh, &req, sizeof(req))) != 0) if ((error = copyin(msgh, &req, sizeof(req))) != 0)
return error; return error;
switch(req.req_flavor) { switch(req.req_flavor) {
case MACH_HOST_BASIC_INFO: {
struct mach_host_basic_info *info;
msglen = sizeof(mach_host_info_reply_t);
rep = (mach_host_info_reply_t *)malloc(msglen,
M_TEMP, M_ZERO|M_WAITOK);
rep->rep_msgh.msgh_bits = 0x1200; /* XXX why? */
rep->rep_msgh.msgh_local_port = req.req_msgh.msgh_local_port;
rep->rep_msgh.msgh_id = 300; /* XXX why? */
info = (struct mach_host_basic_info *)&rep->rep_data[0];
info->max_cpus = 1; /* XXX fill this accurately */
info->avail_cpus = 1;
info->memory_size = uvmexp.active + uvmexp.inactive;
info->cpu_type = 0;
info->cpu_subtype = 0;
break;
}
case MACH_HOST_MACH_MSG_TRAP: case MACH_HOST_MACH_MSG_TRAP:
msglen = sizeof(mach_host_info_reply_t); msglen = sizeof(mach_host_info_reply_t);
rep = (mach_host_info_reply_t *)malloc(msglen, rep = (mach_host_info_reply_t *)malloc(msglen,
@ -74,7 +94,6 @@ mach_host_info(msgh)
rep->rep_msgh.msgh_id = 300; /* XXX why? */ rep->rep_msgh.msgh_id = 300; /* XXX why? */
break; break;
case MACH_HOST_BASIC_INFO:
case MACH_HOST_SCHED_INFO: case MACH_HOST_SCHED_INFO:
case MACH_HOST_RESOURCE_SIZES: case MACH_HOST_RESOURCE_SIZES:
case MACH_HOST_PRIORITY_INFO: case MACH_HOST_PRIORITY_INFO:
@ -94,24 +113,45 @@ mach_host_info(msgh)
int int
mach_host_page_size(msgh) mach_host_page_size(p, msgh)
struct proc *p;
mach_msg_header_t *msgh; mach_msg_header_t *msgh;
{ {
mach_host_page_size_request_t req; mach_host_page_size_request_t req;
mach_host_page_size_reply_t rep; mach_host_page_size_reply_t rep;
size_t msglen;
int error; int error;
DPRINTF(("mach_host_page_size\n"));
bzero(&rep, sizeof(rep)); bzero(&rep, sizeof(rep));
msglen = sizeof(mach_host_page_size_reply_t);
rep.rep_msgh.msgh_bits = 0x1200; /* XXX why? */ rep.rep_msgh.msgh_bits = 0x1200; /* XXX why? */
rep.rep_msgh.msgh_size = sizeof(rep); rep.rep_msgh.msgh_size = sizeof(rep);
rep.rep_msgh.msgh_local_port = req.req_msgh.msgh_local_port; rep.rep_msgh.msgh_local_port = req.req_msgh.msgh_local_port;
rep.rep_msgh.msgh_id = 302; /* XXX why? */ rep.rep_msgh.msgh_id = 302; /* XXX why? */
rep.rep_page_size = PAGE_SIZE; rep.rep_page_size = PAGE_SIZE;
if ((error = copyout(&rep, msgh, msglen)) != 0) if ((error = copyout(&rep, msgh, sizeof(rep))) != 0)
return error;
return 0;
}
int
mach_host_get_clock_service(p, msgh)
struct proc *p;
mach_msg_header_t *msgh;
{
mach_host_get_clock_service_request_t req;
mach_host_get_clock_service_reply_t rep;
int error;
bzero(&rep, sizeof(rep));
rep.rep_msgh.msgh_bits = 0x80001200; /* XXX why? */
rep.rep_msgh.msgh_size = sizeof(rep);
rep.rep_msgh.msgh_local_port = req.req_msgh.msgh_local_port;
rep.rep_msgh.msgh_id = 306; /* XXX why? */
rep.rep_body.msgh_descriptor_count = 1; /* XXX why? */
rep.rep_clock_serv.name = 0x60b; /* XXX */
rep.rep_clock_serv.disposition = 0x11; /* XXX */
if ((error = copyout(&rep, msgh, sizeof(rep))) != 0)
return error; return error;
return 0; return 0;
} }

View File

@ -1,4 +1,4 @@
/* $NetBSD: mach_host.h,v 1.2 2002/11/10 09:41:45 manu Exp $ */ /* $NetBSD: mach_host.h,v 1.3 2002/11/10 21:53:40 manu Exp $ */
/*- /*-
* Copyright (c) 2002 The NetBSD Foundation, Inc. * Copyright (c) 2002 The NetBSD Foundation, Inc.
@ -39,6 +39,11 @@
#ifndef _MACH_HOST_H_ #ifndef _MACH_HOST_H_
#define _MACH_HOST_H_ #define _MACH_HOST_H_
#include <sys/types.h>
#include <sys/param.h>
#include <sys/signal.h>
#include <sys/proc.h>
#include <compat/mach/mach_types.h> #include <compat/mach/mach_types.h>
#include <compat/mach/mach_message.h> #include <compat/mach/mach_message.h>
@ -114,7 +119,23 @@ typedef struct {
mach_vm_size_t rep_page_size; mach_vm_size_t rep_page_size;
} mach_host_page_size_reply_t; } mach_host_page_size_reply_t;
int mach_host_info __P((mach_msg_header_t *)); /* host_get_clock_service */
int mach_host_page_size __P((mach_msg_header_t *));
typedef struct {
mach_msg_header_t req_msgh;
mach_ndr_record_t req_ndr;
mach_clock_id_t req_clock_id;
} mach_host_get_clock_service_request_t;
typedef struct {
mach_msg_header_t rep_msgh;
mach_msg_body_t rep_body;
mach_msg_port_descriptor_t rep_clock_serv;
mach_msg_trailer_t req_trailer;
} mach_host_get_clock_service_reply_t;
int mach_host_info __P((struct proc *, mach_msg_header_t *));
int mach_host_page_size __P((struct proc *, mach_msg_header_t *));
int mach_host_get_clock_service __P((struct proc *, mach_msg_header_t *));
#endif /* _MACH_HOST_H_ */ #endif /* _MACH_HOST_H_ */

View File

@ -1,4 +1,4 @@
/* $NetBSD: mach_message.h,v 1.3 2002/11/10 02:18:03 manu Exp $ */ /* $NetBSD: mach_message.h,v 1.4 2002/11/10 21:53:40 manu Exp $ */
/*- /*-
* Copyright (c) 2001 The NetBSD Foundation, Inc. * Copyright (c) 2001 The NetBSD Foundation, Inc.
@ -39,11 +39,13 @@
#ifndef _MACH_MESSAGE_H_ #ifndef _MACH_MESSAGE_H_
#define _MACH_MESSAGE_H_ #define _MACH_MESSAGE_H_
typedef u_int32_t mach_msg_bits_t; typedef unsigned int mach_msg_bits_t;
typedef u_int32_t mach_msg_size_t; typedef unsigned int mach_msg_size_t;
typedef u_int32_t mach_msg_id_t; typedef unsigned int mach_msg_id_t;
typedef u_int32_t mach_msg_timeout_t; typedef unsigned int mach_msg_timeout_t;
typedef u_int32_t mach_msg_option_t; typedef unsigned int mach_msg_option_t;
typedef unsigned int mach_msg_type_name_t;
typedef unsigned int mach_msg_type_number_t;
/* /*
* Options * Options
@ -119,9 +121,37 @@ typedef struct {
mach_msg_trailer_size_t msgh_trailer_size; mach_msg_trailer_size_t msgh_trailer_size;
} mach_msg_trailer_t; } mach_msg_trailer_t;
typedef struct {
void* pad1;
mach_msg_size_t pad2;
unsigned int pad3 : 24;
mach_msg_descriptor_type_t type : 8;
} mach_msg_type_descriptor_t;
typedef struct {
mach_port_t name;
mach_msg_size_t pad1;
unsigned int pad2 : 16;
mach_msg_type_name_t disposition : 8;
mach_msg_descriptor_type_t type : 8;
} mach_msg_port_descriptor_t;
typedef struct {
void * address;
mach_msg_size_t count;
mach_boolean_t deallocate: 8;
mach_msg_copy_options_t copy: 8;
mach_msg_type_name_t disposition : 8;
mach_msg_descriptor_type_t type : 8;
} mach_msg_ool_ports_descriptor_t;
typedef struct {
mach_msg_size_t msgh_descriptor_count;
} mach_msg_body_t;
struct mach_subsystem_namemap { struct mach_subsystem_namemap {
int map_id; int map_id;
int (*map_handler) __P((mach_msg_header_t *)); int (*map_handler) __P((struct proc *, mach_msg_header_t *));
const char *map_name; const char *map_name;
}; };
extern struct mach_subsystem_namemap mach_namemap[]; extern struct mach_subsystem_namemap mach_namemap[];

View File

@ -1,4 +1,4 @@
/* $NetBSD: mach_misc.c,v 1.8 2002/11/10 09:41:45 manu Exp $ */ /* $NetBSD: mach_misc.c,v 1.9 2002/11/10 21:53:40 manu Exp $ */
/*- /*-
* Copyright (c) 2001 The NetBSD Foundation, Inc. * Copyright (c) 2001 The NetBSD Foundation, Inc.
@ -43,7 +43,7 @@
*/ */
#include <sys/cdefs.h> #include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: mach_misc.c,v 1.8 2002/11/10 09:41:45 manu Exp $"); __KERNEL_RCSID(0, "$NetBSD: mach_misc.c,v 1.9 2002/11/10 21:53:40 manu Exp $");
#include <sys/param.h> #include <sys/param.h>
#include <sys/systm.h> #include <sys/systm.h>
@ -127,38 +127,6 @@ mach_print_msg_header_t(mach_msg_header_t *mh) {
} }
#endif /* DEBUG_MACH */ #endif /* DEBUG_MACH */
int
mach_sys_reply_port(struct proc *p, void *vv, register_t *r) {
static int current_port = 0x80b;
*r = current_port++; /* XXX */
DPRINTF(("mach_sys_reply_port();\n"));
return 0;
}
int
mach_sys_thread_self_trap(struct proc *p, void *v, register_t *r) {
*r = 0;
DPRINTF(("mach_sys_thread_self();\n"));
return 0;
}
int
mach_sys_task_self_trap(struct proc *p, void *v, register_t *r) {
*r = 0xa07; /* XXX */
DPRINTF(("mach_sys_task_self();\n"));
return 0;
}
int
mach_sys_host_self_trap(struct proc *p, void *v, register_t *r) {
*r = 0x90b; /* XXX */
DPRINTF(("mach_sys_host_self();\n"));
return 0;
}
int int
mach_sys_msg_overwrite_trap(struct proc *p, void *v, register_t *r) { mach_sys_msg_overwrite_trap(struct proc *p, void *v, register_t *r) {
@ -192,10 +160,10 @@ mach_sys_msg_overwrite_trap(struct proc *p, void *v, register_t *r) {
namemap->map_id; namemap++) namemap->map_id; namemap++)
if (namemap->map_id == mh.msgh_id) if (namemap->map_id == mh.msgh_id)
break; break;
if (namemap->map_id) { if (namemap->map_handler == NULL)
DPRINTF(("mach_%s()\n", namemap->map_name)); break;
return (*namemap->map_handler)(SCARG(ap, msg)); DPRINTF(("mach_%s()\n", namemap->map_name));
} return (*namemap->map_handler)(p, SCARG(ap, msg));
} }
break; break;
default: default:
@ -227,10 +195,10 @@ mach_sys_msg_trap(struct proc *p, void *v, register_t *r) {
namemap->map_id; namemap++) namemap->map_id; namemap++)
if (namemap->map_id == mh.msgh_id) if (namemap->map_id == mh.msgh_id)
break; break;
if (namemap->map_id) { if (namemap->map_handler == NULL)
DPRINTF(("mach_%s()\n", namemap->map_name)); break;
return (*namemap->map_handler)(SCARG(ap, msg)); DPRINTF(("mach_%s()\n", namemap->map_name));
} return (*namemap->map_handler)(p, SCARG(ap, msg));
} }
break; break;
default: default:

View File

@ -1,4 +1,4 @@
/* $NetBSD: mach_namemap.c,v 1.2 2002/11/10 09:41:45 manu Exp $ */ /* $NetBSD: mach_namemap.c,v 1.3 2002/11/10 21:53:40 manu Exp $ */
/*- /*-
* Copyright (c) 2002 The NetBSD Foundation, Inc. * Copyright (c) 2002 The NetBSD Foundation, Inc.
@ -37,7 +37,7 @@
*/ */
#include <sys/cdefs.h> #include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: mach_namemap.c,v 1.2 2002/11/10 09:41:45 manu Exp $"); __KERNEL_RCSID(0, "$NetBSD: mach_namemap.c,v 1.3 2002/11/10 21:53:40 manu Exp $");
#include <sys/types.h> #include <sys/types.h>
#include <sys/param.h> #include <sys/param.h>
@ -45,10 +45,20 @@ __KERNEL_RCSID(0, "$NetBSD: mach_namemap.c,v 1.2 2002/11/10 09:41:45 manu Exp $"
#include <compat/mach/mach_types.h> #include <compat/mach/mach_types.h>
#include <compat/mach/mach_message.h> #include <compat/mach/mach_message.h>
#include <compat/mach/mach_host.h> #include <compat/mach/mach_host.h>
#include <compat/mach/mach_port.h>
#include <compat/mach/mach_task.h>
#include <compat/mach/mach_vm.h>
struct mach_subsystem_namemap mach_namemap[] = { struct mach_subsystem_namemap mach_namemap[] = {
{ 200, mach_host_info, "host_info" }, { 200, mach_host_info, "host_info" },
{ 202, mach_host_page_size," host_page_size" }, { 202, mach_host_page_size,"host_page_size" },
{ 206, mach_host_get_clock_service, "host_get_clock_service" },
{ 3204, mach_port_allocate, "port_allocate" },
{ 3206, mach_port_deallocate, "port_deallocate" },
{ 3404, mach_ports_lookup, "ports_lookup" },
{ 3409, mach_task_get_special_port, "task_get_special_port" },
{ 3802, mach_vm_deallocate, "vm_deallocate" },
{ 3812, mach_vm_map, "vm_map" },
{ 0, NULL, NULL }, { 0, NULL, NULL },
}; };

143
sys/compat/mach/mach_port.c Normal file
View File

@ -0,0 +1,143 @@
/* $NetBSD: mach_port.c,v 1.1 2002/11/10 21:53:40 manu Exp $ */
/*-
* Copyright (c) 2002 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Emmanuel Dreyfus
*
* 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.
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: mach_port.c,v 1.1 2002/11/10 21:53:40 manu Exp $");
#include <sys/types.h>
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/signal.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_syscallargs.h>
int
mach_sys_reply_port(p, v, retval)
struct proc *p;
void *v;
register_t *retval;
{
static int current_port = 0x80b;
*retval = current_port++; /* XXX */
return 0;
}
int
mach_sys_thread_self_trap(p, v, retval)
struct proc *p;
void *v;
register_t *retval;
{
*retval = 0; /* XXX */
return 0;
}
int
mach_sys_task_self_trap(p, v, retval)
struct proc *p;
void *v;
register_t *retval;
{
*retval = 0xa07; /* XXX */
return 0;
}
int
mach_sys_host_self_trap(p, v, retval)
struct proc *p;
void *v;
register_t *retval;
{
*retval = 0x90b; /* XXX */
return 0;
}
int
mach_port_deallocate(p, msgh)
struct proc *p;
mach_msg_header_t *msgh;
{
mach_port_deallocate_request_t req;
mach_port_deallocate_reply_t rep;
int error;
if ((error = copyin(msgh, &req, sizeof(req))) != 0)
return error;
bzero(&rep, sizeof(rep));
rep.rep_msgh.msgh_bits = 0x1200; /* XXX why? */
rep.rep_msgh.msgh_size = sizeof(rep);
rep.rep_msgh.msgh_local_port = req.req_msgh.msgh_local_port;
rep.rep_msgh.msgh_id = 3306; /* XXX why? */
if ((error = copyout(&rep, msgh, sizeof(rep))) != 0)
return error;
return 0;
}
int
mach_port_allocate(p, msgh)
struct proc *p;
mach_msg_header_t *msgh;
{
mach_port_allocate_request_t req;
mach_port_allocate_reply_t rep;
int error;
if ((error = copyin(msgh, &req, sizeof(req))) != 0)
return error;
bzero(&rep, sizeof(rep));
rep.rep_msgh.msgh_bits = 0x1200; /* XXX why? */
rep.rep_msgh.msgh_size = sizeof(rep);
rep.rep_msgh.msgh_local_port = req.req_msgh.msgh_local_port;
rep.rep_msgh.msgh_id = 3304; /* XXX why? */
rep.rep_trailer.msgh_trailer_size = 1811; /* XXX why? */
if ((error = copyout(&rep, msgh, sizeof(rep))) != 0)
return error;
return 0;
}

View File

@ -0,0 +1,76 @@
/* $NetBSD: mach_port.h,v 1.1 2002/11/10 21:53:41 manu Exp $ */
/*-
* Copyright (c) 2002 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Emmanuel Dreyfus
*
* 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_PORT_H_
#define _MACH_PORT_H_
/* port_deallocate */
typedef struct {
mach_msg_header_t req_msgh;
mach_ndr_record_t req_ndr;
mach_port_name_t req_name;
} mach_port_deallocate_request_t;
typedef struct {
mach_msg_header_t rep_msgh;
mach_ndr_record_t rep_ndr;
mach_kern_return_t rep_retval;
mach_msg_trailer_t rep_trailer;
} mach_port_deallocate_reply_t;
/* port_allocate */
typedef struct {
mach_msg_header_t req_msgh;
mach_ndr_record_t req_ndr;
mach_port_right_t req_right;
} mach_port_allocate_request_t;
typedef struct {
mach_msg_header_t rep_msgh;
mach_ndr_record_t rep_ndr;
mach_kern_return_t rep_retval;
mach_port_name_t rep_name;
mach_msg_trailer_t rep_trailer;
} mach_port_allocate_reply_t;
int mach_port_deallocate __P((struct proc *, mach_msg_header_t *));
int mach_port_allocate __P((struct proc *, mach_msg_header_t *));
#endif /* _MACH_PORT_H_ */

108
sys/compat/mach/mach_task.c Normal file
View File

@ -0,0 +1,108 @@
/* $NetBSD: mach_task.c,v 1.1 2002/11/10 21:53:41 manu Exp $ */
/*-
* Copyright (c) 2002 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Emmanuel Dreyfus
*
* 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.
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: mach_task.c,v 1.1 2002/11/10 21:53:41 manu Exp $");
#include <sys/types.h>
#include <sys/param.h>
#include <sys/systm.h>
#include <compat/mach/mach_types.h>
#include <compat/mach/mach_message.h>
#include <compat/mach/mach_task.h>
#include <compat/mach/mach_syscallargs.h>
int
mach_task_get_special_port(p, msgh)
struct proc *p;
mach_msg_header_t *msgh;
{
mach_task_get_special_port_request_t req;
mach_task_get_special_port_reply_t rep;
int error;
if ((error = copyin(msgh, &req, sizeof(req))) != 0)
return error;
bzero(&rep, sizeof(rep));
rep.rep_msgh.msgh_bits = 0x8001200; /* XXX why? */
rep.rep_msgh.msgh_size = sizeof(rep);
rep.rep_msgh.msgh_local_port = req.req_msgh.msgh_local_port;
rep.rep_msgh.msgh_id = 3509; /* XXX why? */
rep.rep_msgh_body.msgh_descriptor_count = 1; /* XXX why ? */
rep.rep_special_port.name = 0x90f; /* XXX why? */
rep.rep_special_port.disposition = 0x11; /* XXX why? */
rep.rep_trailer.msgh_trailer_size = 8; /* XXX why? */
if ((error = copyout(&rep, msgh, sizeof(rep))) != 0)
return error;
return 0;
}
int
mach_ports_lookup(p, msgh)
struct proc *p;
mach_msg_header_t *msgh;
{
mach_ports_lookup_request_t req;
mach_ports_lookup_reply_t rep;
int error;
if ((error = copyin(msgh, &req, sizeof(req))) != 0)
return error;
bzero(&rep, sizeof(rep));
rep.rep_msgh.msgh_bits = 0x8001200; /* XXX why? */
rep.rep_msgh.msgh_size = sizeof(rep);
rep.rep_msgh.msgh_local_port = req.req_msgh.msgh_local_port;
rep.rep_msgh.msgh_id = 3504; /* XXX why? */
rep.rep_msgh_body.msgh_descriptor_count = 1; /* XXX why ? */
rep.rep_init_port_set.address = (void *)0x8000; /* XXX why? */
rep.rep_init_port_set.count = 3; /* XXX why ? */
rep.rep_init_port_set.copy = 2; /* XXX why ? */
rep.rep_init_port_set.disposition = 0x11; /* XXX why? */
rep.rep_init_port_set.type = 2; /* XXX why? */
if ((error = copyout(&rep, msgh, sizeof(rep))) != 0)
return error;
return 0;
}

View File

@ -0,0 +1,75 @@
/* $NetBSD: mach_task.h,v 1.1 2002/11/10 21:53:41 manu Exp $ */
/*-
* Copyright (c) 2002 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Emmanuel Dreyfus
*
* 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_TASK_H_
#define _MACH_TASK_H_
/* task_get_special_port */
typedef struct {
mach_msg_header_t req_msgh;
mach_ndr_record_t req_ndr;
int req_which_port;
} mach_task_get_special_port_request_t;
typedef struct {
mach_msg_header_t rep_msgh;
mach_msg_body_t rep_msgh_body;
mach_msg_port_descriptor_t rep_special_port;
mach_msg_trailer_t rep_trailer;
} mach_task_get_special_port_reply_t;
/* mach_ports_lookup */
typedef struct {
mach_msg_header_t req_msgh;
} mach_ports_lookup_request_t;
typedef struct {
mach_msg_header_t rep_msgh;
mach_msg_body_t rep_msgh_body;
mach_msg_ool_ports_descriptor_t rep_init_port_set;
mach_ndr_record_t rep_ndr;
mach_msg_type_number_t rep_init_port_set_count;
mach_msg_trailer_t rep_trailer;
} mach_ports_lookup_reply_t;
int mach_task_get_special_port __P((struct proc *, mach_msg_header_t *));
int mach_ports_lookup __P((struct proc *, mach_msg_header_t *));
#endif /* _MACH_TASK_H_ */

View File

@ -1,4 +1,4 @@
/* $NetBSD: mach_types.h,v 1.4 2002/11/10 02:18:03 manu Exp $ */ /* $NetBSD: mach_types.h,v 1.5 2002/11/10 21:53:41 manu Exp $ */
/*- /*-
* Copyright (c) 2001 The NetBSD Foundation, Inc. * Copyright (c) 2001 The NetBSD Foundation, Inc.
@ -43,6 +43,7 @@ typedef int mach_port_t;
typedef int mach_port_name_t; typedef int mach_port_name_t;
typedef int mach_kern_return_t; typedef int mach_kern_return_t;
typedef int mach_clock_res_t; typedef int mach_clock_res_t;
typedef int mach_clock_id_t;
typedef int mach_boolean_t; typedef int mach_boolean_t;
typedef int mach_sleep_type_t; typedef int mach_sleep_type_t;
typedef int mach_timespec_t; typedef int mach_timespec_t;
@ -50,7 +51,11 @@ typedef int mach_absolute_time_t;
typedef int mach_integer_t; typedef int mach_integer_t;
typedef int mach_cpu_type_t; typedef int mach_cpu_type_t;
typedef int mach_cpu_subtype_t; typedef int mach_cpu_subtype_t;
typedef unsigned int mach_msg_type_number_t; typedef int mach_port_right_t;
typedef int mach_vm_address_t;
typedef int mach_vm_inherit_t;
typedef int mach_vm_prot_t;
typedef unsigned int mach_natural_t;
typedef unsigned int mach_vm_size_t; typedef unsigned int mach_vm_size_t;
typedef unsigned long mach_vm_offset_t; typedef unsigned long mach_vm_offset_t;
typedef void *mach_cproc_t; /* Unkown, see xnu/osfmk/ppc/hw_exception.s */ typedef void *mach_cproc_t; /* Unkown, see xnu/osfmk/ppc/hw_exception.s */

120
sys/compat/mach/mach_vm.c Normal file
View File

@ -0,0 +1,120 @@
/* $NetBSD: mach_vm.c,v 1.1 2002/11/10 21:53:41 manu Exp $ */
/*-
* Copyright (c) 2002 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Emmanuel Dreyfus
*
* 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.
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: mach_vm.c,v 1.1 2002/11/10 21:53:41 manu Exp $");
#include <sys/types.h>
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/mount.h>
#include <sys/proc.h>
#include <sys/syscallargs.h>
#include <compat/mach/mach_types.h>
#include <compat/mach/mach_message.h>
#include <compat/mach/mach_vm.h>
#include <compat/mach/mach_syscallargs.h>
int
mach_vm_map(p, msgh)
struct proc *p;
mach_msg_header_t *msgh;
{
mach_vm_map_request_t req;
mach_vm_map_reply_t rep;
struct sys_mmap_args cup;
int error;
if ((error = copyin(msgh, &req, sizeof(req))) != 0)
return error;
bzero(&rep, sizeof(rep));
SCARG(&cup, addr) = (void *)req.req_address;
SCARG(&cup, len) = req.req_size;
SCARG(&cup, prot) = req.req_cur_protection; /* XXX */
SCARG(&cup, flags) = req.req_flags; /* XXX */
SCARG(&cup, fd) = 0; /* XXX */
SCARG(&cup, pos) = (off_t)req.req_offset;
if ((error = sys_mmap(p, &cup, &rep.rep_retval)) != 0)
return error;
rep.rep_msgh.msgh_bits = 0x1200; /* XXX why? */
rep.rep_msgh.msgh_size = sizeof(rep);
rep.rep_msgh.msgh_local_port = req.req_msgh.msgh_local_port;
rep.rep_msgh.msgh_id = 3912; /* XXX why? */
rep.rep_trailer.msgh_trailer_type = 0x80001513; /* XXX why? */
rep.rep_trailer.msgh_trailer_size = 0x00000713; /* XXX why? */
if ((error = copyout(&rep, msgh, sizeof(rep))) != 0)
return error;
return 0;
}
int
mach_vm_deallocate(p, msgh)
struct proc *p;
mach_msg_header_t *msgh;
{
mach_vm_deallocate_request_t req;
mach_vm_deallocate_reply_t rep;
struct sys_munmap_args cup;
int error;
if ((error = copyin(msgh, &req, sizeof(req))) != 0)
return error;
bzero(&rep, sizeof(rep));
SCARG(&cup, addr) = (caddr_t)req.req_address;
SCARG(&cup, len) = req.req_size;
if ((error = sys_munmap(p, &cup, &rep.rep_retval)) != 0)
return error;
rep.rep_msgh.msgh_bits = 0x1200; /* XXX why? */
rep.rep_msgh.msgh_size = sizeof(rep);
rep.rep_msgh.msgh_local_port = req.req_msgh.msgh_local_port;
rep.rep_msgh.msgh_id = 3902; /* XXX why? */
if ((error = copyout(&rep, msgh, sizeof(rep))) != 0)
return error;
return 0;
}

94
sys/compat/mach/mach_vm.h Normal file
View File

@ -0,0 +1,94 @@
/* $NetBSD: mach_vm.h,v 1.1 2002/11/10 21:53:41 manu Exp $ */
/*-
* Copyright (c) 2002 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Emmanuel Dreyfus
*
* 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_VM_H_
#define _MACH_VM_H_
#include <sys/types.h>
#include <sys/param.h>
#include <compat/mach/mach_types.h>
#include <compat/mach/mach_message.h>
/* vm_map */
typedef struct {
mach_msg_header_t req_msgh;
mach_msg_body_t req_body;
mach_msg_port_descriptor_t req_object;
mach_ndr_record_t req_ndr;
mach_vm_address_t req_address;
mach_vm_size_t req_size;
mach_vm_address_t req_mask;
int req_flags;
mach_vm_offset_t req_offset;
mach_boolean_t req_copy;
mach_vm_prot_t req_cur_protection;
mach_vm_prot_t req_max_protection;
mach_vm_inherit_t req_inherance;
} mach_vm_map_request_t;
typedef struct {
mach_msg_header_t rep_msgh;
mach_ndr_record_t rep_ndr;
mach_kern_return_t rep_retval;
mach_vm_address_t rep_address;
mach_msg_trailer_t rep_trailer;
} mach_vm_map_reply_t;
/* vm_deallocate */
typedef struct {
mach_msg_header_t req_msgh;
mach_ndr_record_t req_ndr;
mach_vm_address_t req_address;
mach_vm_size_t req_size;
} mach_vm_deallocate_request_t;
typedef struct {
mach_msg_header_t rep_msgh;
mach_ndr_record_t rep_ndr;
mach_kern_return_t rep_retval;
mach_msg_trailer_t rep_trailer;
} mach_vm_deallocate_reply_t;
int mach_vm_map __P((struct proc *, mach_msg_header_t *));
int mach_vm_deallocate __P((struct proc *, mach_msg_header_t *));
#endif /* _MACH_VM_H_ */