Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/compat/mach Implment one command of the host_info mach t...
details: https://anonhg.NetBSD.org/src/rev/df13d54f6916
branches: trunk
changeset: 539166:df13d54f6916
user: manu <manu%NetBSD.org@localhost>
date: Sun Nov 10 02:18:03 2002 +0000
description:
Implment one command of the host_info mach trap, which check for mach_msg_trap
availability
diffstat:
sys/compat/mach/files.mach | 8 +-
sys/compat/mach/mach_host.c | 91 +++++++++++++++++++++++++++++++++++
sys/compat/mach/mach_host.h | 104 +++++++++++++++++++++++++++++++++++++++++
sys/compat/mach/mach_message.h | 16 +++++-
sys/compat/mach/mach_misc.c | 21 ++++++-
sys/compat/mach/mach_namemap.c | 54 +++++++++++++++++++++
sys/compat/mach/mach_types.h | 17 ++++++-
7 files changed, 301 insertions(+), 10 deletions(-)
diffs (truncated from 418 to 300 lines):
diff -r 7140b1cbc91e -r df13d54f6916 sys/compat/mach/files.mach
--- a/sys/compat/mach/files.mach Sat Nov 09 20:34:26 2002 +0000
+++ b/sys/compat/mach/files.mach Sun Nov 10 02:18:03 2002 +0000
@@ -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
diff -r 7140b1cbc91e -r df13d54f6916 sys/compat/mach/mach_host.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/compat/mach/mach_host.c Sun Nov 10 02:18:03 2002 +0000
@@ -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;
+}
+
diff -r 7140b1cbc91e -r df13d54f6916 sys/compat/mach/mach_host.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/compat/mach/mach_host.h Sun Nov 10 02:18:03 2002 +0000
@@ -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_ */
diff -r 7140b1cbc91e -r df13d54f6916 sys/compat/mach/mach_message.h
--- a/sys/compat/mach/mach_message.h Sat Nov 09 20:34:26 2002 +0000
+++ b/sys/compat/mach/mach_message.h Sun Nov 10 02:18:03 2002 +0000
@@ -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 @@
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_ */
diff -r 7140b1cbc91e -r df13d54f6916 sys/compat/mach/mach_misc.c
--- a/sys/compat/mach/mach_misc.c Sat Nov 09 20:34:26 2002 +0000
+++ b/sys/compat/mach/mach_misc.c Sun Nov 10 02:18:03 2002 +0000
@@ -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 @@
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 @@
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 @@
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 @@
Home |
Main Index |
Thread Index |
Old Index