Implment one command of the host_info mach trap, which check for mach_msg_trap
availability
This commit is contained in:
parent
84ccc9c46e
commit
4855282dc6
|
@ -1,4 +1,4 @@
|
|||
# $NetBSD: files.mach,v 1.2 2002/10/27 21:41:51 manu Exp $
|
||||
# $NetBSD: files.mach,v 1.3 2002/11/10 02:18:03 manu Exp $
|
||||
#
|
||||
# Config file description for machine-independent Mach compat code.
|
||||
# Included by ports that need it.
|
||||
|
@ -6,7 +6,9 @@
|
|||
# ports should define any machine-specific files they need in their
|
||||
# own file lists.
|
||||
|
||||
file compat/mach/mach_exec.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_syscalls.c compat_mach
|
||||
file compat/mach/mach_sysent.c compat_mach
|
||||
file compat/mach/mach_misc.c compat_mach
|
||||
file compat/mach/mach_exec.c compat_mach
|
||||
|
|
|
@ -0,0 +1,91 @@
|
|||
/* $NetBSD: mach_host.c,v 1.1 2002/11/10 02:18:03 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_host.c,v 1.1 2002/11/10 02:18:03 manu Exp $");
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/malloc.h>
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
|
||||
#include <compat/mach/mach_types.h>
|
||||
#include <compat/mach/mach_host.h>
|
||||
|
||||
int
|
||||
mach_host_info(msgh)
|
||||
mach_msg_header_t *msgh;
|
||||
{
|
||||
mach_host_info_request_t req;
|
||||
mach_host_info_reply_t *rep = NULL;
|
||||
size_t msglen;
|
||||
int error;
|
||||
|
||||
DPRINTF(("mach_host_info\n"));
|
||||
|
||||
if ((error = copyin(msgh, &req, sizeof(req))) != 0)
|
||||
return error;
|
||||
|
||||
switch(req.req_flavor) {
|
||||
case MACH_HOST_MACH_MSG_TRAP:
|
||||
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? */
|
||||
break;
|
||||
|
||||
case MACH_HOST_BASIC_INFO:
|
||||
case MACH_HOST_SCHED_INFO:
|
||||
case MACH_HOST_RESOURCE_SIZES:
|
||||
case MACH_HOST_PRIORITY_INFO:
|
||||
case MACH_HOST_SEMAPHORE_TRAPS:
|
||||
DPRINTF(("unimplemented host_info flavor %d\n",
|
||||
req.req_flavor));
|
||||
default:
|
||||
return EINVAL;
|
||||
break;
|
||||
}
|
||||
|
||||
if (rep != NULL && (error = copyout(rep, msgh, msglen)) != 0)
|
||||
return error;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -0,0 +1,104 @@
|
|||
/* $NetBSD: mach_host.h,v 1.1 2002/11/10 02:18:03 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_HOST_H_
|
||||
#define _MACH_HOST_H_
|
||||
|
||||
#include <compat/mach/mach_types.h>
|
||||
#include <compat/mach/mach_message.h>
|
||||
|
||||
typedef mach_integer_t mach_host_flavor_t;
|
||||
|
||||
typedef struct {
|
||||
mach_msg_header_t req_msgh;
|
||||
mach_ndr_record_t req_ndr;
|
||||
mach_host_flavor_t req_flavor;
|
||||
mach_msg_type_number_t req_count;
|
||||
} mach_host_info_request_t;
|
||||
|
||||
typedef struct {
|
||||
mach_msg_header_t rep_msgh;
|
||||
mach_ndr_record_t rep_ndr;
|
||||
mach_kern_return_t rep_retval;
|
||||
mach_msg_type_number_t rep_count;
|
||||
mach_integer_t rep_data[12];
|
||||
mach_msg_trailer_t rep_trailer;
|
||||
} mach_host_info_reply_t;
|
||||
|
||||
#define MACH_HOST_BASIC_INFO 1
|
||||
#define MACH_HOST_SCHED_INFO 3
|
||||
#define MACH_HOST_RESOURCE_SIZES 4
|
||||
#define MACH_HOST_PRIORITY_INFO 5
|
||||
#define MACH_HOST_SEMAPHORE_TRAPS 7
|
||||
#define MACH_HOST_MACH_MSG_TRAP 8
|
||||
|
||||
struct mach_host_basic_info {
|
||||
mach_integer_t max_cpus;
|
||||
mach_integer_t avail_cpus;
|
||||
mach_vm_size_t memory_size;
|
||||
mach_cpu_type_t cpu_type;
|
||||
mach_cpu_subtype_t cpu_subtype;
|
||||
};
|
||||
|
||||
struct mach_host_sched_info {
|
||||
mach_integer_t min_timeout;
|
||||
mach_integer_t min_quantum;
|
||||
};
|
||||
|
||||
struct mach_kernel_resource_sizes {
|
||||
mach_vm_size_t task;
|
||||
mach_vm_size_t thread;
|
||||
mach_vm_size_t port;
|
||||
mach_vm_size_t memory_region;
|
||||
mach_vm_size_t memory_object;
|
||||
};
|
||||
|
||||
struct mach_host_priority_info {
|
||||
mach_integer_t kernel_priority;
|
||||
mach_integer_t system_priority;
|
||||
mach_integer_t server_priority;
|
||||
mach_integer_t user_priority;
|
||||
mach_integer_t depress_priority;
|
||||
mach_integer_t idle_priority;
|
||||
mach_integer_t minimum_priority;
|
||||
mach_integer_t maximum_priority;
|
||||
};
|
||||
|
||||
int mach_host_info __P((mach_msg_header_t *));
|
||||
|
||||
#endif /* _MACH_HOST_H_ */
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: mach_message.h,v 1.2 2002/10/30 15:04:17 christos Exp $ */
|
||||
/* $NetBSD: mach_message.h,v 1.3 2002/11/10 02:18:03 manu Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2001 The NetBSD Foundation, Inc.
|
||||
|
@ -112,4 +112,18 @@ typedef struct {
|
|||
mach_msg_id_t msgh_id;
|
||||
} mach_msg_header_t;
|
||||
|
||||
typedef u_int32_t mach_msg_trailer_type_t;
|
||||
typedef u_int32_t mach_msg_trailer_size_t;
|
||||
typedef struct {
|
||||
mach_msg_trailer_type_t msgh_trailer_type;
|
||||
mach_msg_trailer_size_t msgh_trailer_size;
|
||||
} mach_msg_trailer_t;
|
||||
|
||||
struct mach_subsystem_namemap {
|
||||
int map_id;
|
||||
int (*map_handler) __P((mach_msg_header_t *));
|
||||
const char *map_name;
|
||||
};
|
||||
extern struct mach_subsystem_namemap mach_namemap[];
|
||||
|
||||
#endif /* !_MACH_MESSAGE_H_ */
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: mach_misc.c,v 1.6 2002/11/01 20:04:40 jdolecek Exp $ */
|
||||
/* $NetBSD: mach_misc.c,v 1.7 2002/11/10 02:18:03 manu Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2001 The NetBSD Foundation, Inc.
|
||||
|
@ -43,7 +43,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: mach_misc.c,v 1.6 2002/11/01 20:04:40 jdolecek Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: mach_misc.c,v 1.7 2002/11/10 02:18:03 manu Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
|
@ -129,7 +129,9 @@ mach_print_msg_header_t(mach_msg_header_t *mh) {
|
|||
|
||||
int
|
||||
mach_sys_reply_port(struct proc *p, void *vv, register_t *r) {
|
||||
*r = 0;
|
||||
static int current_port = 0x80b;
|
||||
|
||||
*r = current_port++; /* XXX */
|
||||
DPRINTF(("mach_sys_reply_port();\n"));
|
||||
return 0;
|
||||
}
|
||||
|
@ -144,7 +146,7 @@ mach_sys_thread_self_trap(struct proc *p, void *v, register_t *r) {
|
|||
|
||||
int
|
||||
mach_sys_task_self_trap(struct proc *p, void *v, register_t *r) {
|
||||
*r = 0;
|
||||
*r = 0xa07; /* XXX */
|
||||
DPRINTF(("mach_sys_task_self();\n"));
|
||||
return 0;
|
||||
}
|
||||
|
@ -152,7 +154,7 @@ mach_sys_task_self_trap(struct proc *p, void *v, register_t *r) {
|
|||
|
||||
int
|
||||
mach_sys_host_self_trap(struct proc *p, void *v, register_t *r) {
|
||||
*r = 0;
|
||||
*r = 0x90b; /* XXX */
|
||||
DPRINTF(("mach_sys_host_self();\n"));
|
||||
return 0;
|
||||
}
|
||||
|
@ -162,6 +164,7 @@ 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;
|
||||
struct mach_subsystem_namemap *namemap;
|
||||
#ifdef DEBUG_MACH
|
||||
char buf[128];
|
||||
#endif
|
||||
|
@ -185,6 +188,14 @@ mach_sys_msg_overwrite_trap(struct proc *p, void *v, register_t *r) {
|
|||
#ifdef DEBUG_MACH
|
||||
mach_print_msg_header_t(&mh);
|
||||
#endif /* DEBUG_MACH */
|
||||
for (namemap = mach_namemap;
|
||||
namemap->map_id; namemap++)
|
||||
if (namemap->map_id == mh.msgh_id)
|
||||
break;
|
||||
if (namemap->map_id) {
|
||||
DPRINTF(("mach_%s()\n", namemap->map_name));
|
||||
return (*namemap->map_handler)(SCARG(ap, msg));
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
|
|
@ -0,0 +1,54 @@
|
|||
/* $NetBSD: mach_namemap.c,v 1.1 2002/11/10 02:18:03 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_namemap.c,v 1.1 2002/11/10 02:18:03 manu Exp $");
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/param.h>
|
||||
|
||||
#include <compat/mach/mach_types.h>
|
||||
#include <compat/mach/mach_message.h>
|
||||
#include <compat/mach/mach_host.h>
|
||||
|
||||
struct mach_subsystem_namemap mach_namemap[] = {
|
||||
{ 200, mach_host_info, "host_info" },
|
||||
{ 0, NULL, NULL },
|
||||
};
|
||||
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: mach_types.h,v 1.3 2002/11/03 23:17:19 manu Exp $ */
|
||||
/* $NetBSD: mach_types.h,v 1.4 2002/11/10 02:18:03 manu Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2001 The NetBSD Foundation, Inc.
|
||||
|
@ -47,6 +47,10 @@ typedef int mach_boolean_t;
|
|||
typedef int mach_sleep_type_t;
|
||||
typedef int mach_timespec_t;
|
||||
typedef int mach_absolute_time_t;
|
||||
typedef int mach_integer_t;
|
||||
typedef int mach_cpu_type_t;
|
||||
typedef int mach_cpu_subtype_t;
|
||||
typedef unsigned int mach_msg_type_number_t;
|
||||
typedef unsigned int mach_vm_size_t;
|
||||
typedef unsigned long mach_vm_offset_t;
|
||||
typedef void *mach_cproc_t; /* Unkown, see xnu/osfmk/ppc/hw_exception.s */
|
||||
|
@ -56,6 +60,17 @@ typedef struct {
|
|||
u_int32_t denom;
|
||||
} mach_timebase_info_t;
|
||||
|
||||
typedef struct {
|
||||
u_int8_t mig_vers;
|
||||
u_int8_t if_vers;
|
||||
u_int8_t reserved1;
|
||||
u_int8_t mig_encoding;
|
||||
u_int8_t int_rep;
|
||||
u_int8_t char_rep;
|
||||
u_int8_t float_rep;
|
||||
u_int8_t reserved2;
|
||||
} mach_ndr_record_t;
|
||||
|
||||
#ifdef DEBUG_MACH
|
||||
#define DPRINTF(a) uprintf a
|
||||
#else
|
||||
|
|
Loading…
Reference in New Issue