Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/compat/mach Add thread_policy and clock_get_time mach tr...
details: https://anonhg.NetBSD.org/src/rev/b0097dc8b4a1
branches: trunk
changeset: 539787:b0097dc8b4a1
user: manu <manu%NetBSD.org@localhost>
date: Tue Nov 26 08:10:14 2002 +0000
description:
Add thread_policy and clock_get_time mach traps. Implement
mach_sys_clock_sleep_trap. This makes sleep(3) emulation working.
diffstat:
sys/compat/mach/files.mach | 4 +-
sys/compat/mach/mach_clock.c | 136 +++++++++++++++++++++++++++++++++++++
sys/compat/mach/mach_clock.h | 73 +++++++++++++++++++
sys/compat/mach/mach_misc.c | 19 +----
sys/compat/mach/mach_namemap.c | 8 +-
sys/compat/mach/mach_port.c | 5 +-
sys/compat/mach/mach_syscall.h | 4 +-
sys/compat/mach/mach_syscallargs.h | 4 +-
sys/compat/mach/mach_syscalls.c | 7 +-
sys/compat/mach/mach_sysent.c | 7 +-
sys/compat/mach/mach_task.c | 5 +-
sys/compat/mach/mach_thread.c | 79 +++++++++++++++++++++
sys/compat/mach/mach_thread.h | 71 +++++++++++++++++++
sys/compat/mach/mach_types.h | 3 +-
sys/compat/mach/mach_vm.c | 5 +-
sys/compat/mach/syscalls.master | 3 +-
16 files changed, 395 insertions(+), 38 deletions(-)
diffs (truncated from 689 to 300 lines):
diff -r 33a38ffde1d7 -r b0097dc8b4a1 sys/compat/mach/files.mach
--- a/sys/compat/mach/files.mach Tue Nov 26 06:22:22 2002 +0000
+++ b/sys/compat/mach/files.mach Tue Nov 26 08:10:14 2002 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: files.mach,v 1.6 2002/11/14 21:38:51 christos Exp $
+# $NetBSD: files.mach,v 1.7 2002/11/26 08:10:14 manu Exp $
#
# Config file description for machine-independent Mach compat code.
# Included by ports that need it.
@@ -6,6 +6,7 @@
# ports should define any machine-specific files they need in their
# own file lists.
+file compat/mach/mach_clock.c compat_mach | compat_darwin
file compat/mach/mach_errno.c compat_mach | compat_darwin
file compat/mach/mach_exec.c compat_mach | compat_darwin
file compat/mach/mach_host.c compat_mach | compat_darwin
@@ -15,4 +16,5 @@
file compat/mach/mach_syscalls.c compat_mach | compat_darwin
file compat/mach/mach_sysent.c compat_mach | compat_darwin
file compat/mach/mach_task.c compat_mach | compat_darwin
+file compat/mach/mach_thread.c compat_mach | compat_darwin
file compat/mach/mach_vm.c compat_mach | compat_darwin
diff -r 33a38ffde1d7 -r b0097dc8b4a1 sys/compat/mach/mach_clock.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/compat/mach/mach_clock.c Tue Nov 26 08:10:14 2002 +0000
@@ -0,0 +1,136 @@
+/* $NetBSD: mach_clock.c,v 1.1 2002/11/26 08:10:14 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_clock.c,v 1.1 2002/11/26 08:10:14 manu Exp $");
+
+#include <sys/types.h>
+#include <sys/param.h>
+#include <sys/kernel.h>
+#include <sys/systm.h>
+#include <sys/signal.h>
+#include <sys/proc.h>
+#include <sys/time.h>
+
+#include <compat/mach/mach_types.h>
+#include <compat/mach/mach_message.h>
+#include <compat/mach/mach_clock.h>
+#include <compat/mach/mach_syscallargs.h>
+
+
+int
+mach_sys_clock_sleep_trap(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct mach_sys_clock_sleep_trap_args /* {
+ syscallarg(mach_clock_port_t) clock_name;
+ syscallarg(mach_sleep_type_t) sleep_type;
+ syscallarg(int) sleep_sec;
+ syscallarg(int) sleep_nsec;
+ syscallarg(mach_timespec_t *) wakeup_time;
+ } */ *uap = v;
+ struct timespec mts, cts, tts;
+ struct timeval now;
+ mach_timespec_t mcts;
+ int dontcare;
+ int ticks;
+ int error;
+
+ mts.tv_sec = SCARG(uap, sleep_sec);
+ mts.tv_nsec = SCARG(uap, sleep_nsec);
+
+ if (SCARG(uap, sleep_type) == MACH_TIME_ABSOLUTE) {
+ microtime(&now);
+ TIMEVAL_TO_TIMESPEC(&now, &cts);
+ timespecsub(&mts, &cts, &tts);
+ } else {
+ tts.tv_sec = mts.tv_sec;
+ tts.tv_nsec = mts.tv_nsec;
+ }
+
+ ticks = tts.tv_sec * hz;
+ ticks += (tts.tv_nsec * hz) / 1000000000L;
+
+ tsleep(&dontcare, PZERO, "sleep", ticks);
+
+ if (SCARG(uap, wakeup_time) != NULL) {
+ microtime(&now);
+ TIMEVAL_TO_TIMESPEC(&now, &cts);
+ mcts.tv_sec = cts.tv_sec;
+ mcts.tv_nsec = cts.tv_nsec;
+ error = copyout(&mcts, SCARG(uap, wakeup_time), sizeof(mcts));
+ if (error != 0)
+ return error;
+ }
+
+ return 0;
+}
+
+int
+mach_clock_get_time(p, msgh)
+ struct proc *p;
+ mach_msg_header_t *msgh;
+{
+ mach_clock_get_time_request_t req;
+ mach_clock_get_time_reply_t rep;
+ struct timeval tv;
+ int error;
+
+ if ((error = copyin(msgh, &req, sizeof(req))) != 0)
+ return error;
+
+ microtime(&tv);
+
+ bzero(&rep, sizeof(rep));
+
+ 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_cur_time.tv_sec = tv.tv_sec;
+ rep.rep_cur_time.tv_nsec = tv.tv_usec * 1000;
+ rep.rep_trailer.msgh_trailer_size = 8;
+
+ if ((error = copyout(&rep, msgh, sizeof(rep))) != 0)
+ return error;
+ return 0;
+}
+
diff -r 33a38ffde1d7 -r b0097dc8b4a1 sys/compat/mach/mach_clock.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/compat/mach/mach_clock.h Tue Nov 26 08:10:14 2002 +0000
@@ -0,0 +1,73 @@
+/* $NetBSD: mach_clock.h,v 1.1 2002/11/26 08:10:15 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_CLOCK_H_
+#define _MACH_CLOCK_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_message.h>
+
+/* clock_get_time */
+#define MACH_TIME_ABSOLUTE 0x00
+#define MACH_TIME_RELATIVE 0x01
+
+typedef struct {
+ unsigned int tv_sec;
+ int tv_nsec;
+} mach_timespec_t;
+
+typedef struct {
+ mach_msg_header_t req_msgh;
+} mach_clock_get_time_request_t;
+
+typedef struct {
+ mach_msg_header_t rep_msgh;
+ mach_ndr_record_t rep_ndr;
+ mach_kern_return_t rep_retval;
+ mach_timespec_t rep_cur_time;
+ mach_msg_trailer_t rep_trailer;
+} mach_clock_get_time_reply_t;
+
+int mach_clock_get_time(struct proc *, mach_msg_header_t *);
+
+#endif /* _MACH_CLOCK_H_ */
diff -r 33a38ffde1d7 -r b0097dc8b4a1 sys/compat/mach/mach_misc.c
--- a/sys/compat/mach/mach_misc.c Tue Nov 26 06:22:22 2002 +0000
+++ b/sys/compat/mach/mach_misc.c Tue Nov 26 08:10:14 2002 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: mach_misc.c,v 1.11 2002/11/16 20:00:30 manu Exp $ */
+/* $NetBSD: mach_misc.c,v 1.12 2002/11/26 08:10:15 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.11 2002/11/16 20:00:30 manu Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mach_misc.c,v 1.12 2002/11/26 08:10:15 manu Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -82,6 +82,7 @@
#include <compat/mach/mach_types.h>
#include <compat/mach/mach_message.h>
+#include <compat/mach/mach_clock.h>
#include <compat/mach/mach_syscallargs.h>
#ifdef DEBUG_MACH
@@ -399,20 +400,6 @@
int
-mach_sys_clock_sleep_trap(struct proc *p, void *v, register_t *r) {
-#ifdef DEBUG_MACH
- struct mach_sys_clock_sleep_trap_args *ap = v;
-#endif
- *r = 0;
- DPRINTF(("mach_sys_sleep_trap(0x%x, %d, %d, %d, %p);\n",
- SCARG(ap, clock_name), SCARG(ap, sleep_type),
- SCARG(ap, sleep_sec), SCARG(ap, sleep_nsec),
- SCARG(ap, wakeup_time)));
- return 0;
-}
-
-
-int
mach_sys_timebase_info(struct proc *p, void *v, register_t *r) {
#ifdef DEBUG_MACH
struct mach_sys_timebase_info_args *ap = v;
diff -r 33a38ffde1d7 -r b0097dc8b4a1 sys/compat/mach/mach_namemap.c
--- a/sys/compat/mach/mach_namemap.c Tue Nov 26 06:22:22 2002 +0000
+++ b/sys/compat/mach/mach_namemap.c Tue Nov 26 08:10:14 2002 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: mach_namemap.c,v 1.5 2002/11/19 19:54:07 christos Exp $ */
+/* $NetBSD: mach_namemap.c,v 1.6 2002/11/26 08:10:16 manu Exp $ */
/*-
* Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -37,27 +37,31 @@
*/
#include <sys/cdefs.h>
Home |
Main Index |
Thread Index |
Old Index