Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys Implement mach_thread_get_state.
details: https://anonhg.NetBSD.org/src/rev/2abf5f7f165f
branches: trunk
changeset: 555211:2abf5f7f165f
user: manu <manu%NetBSD.org@localhost>
date: Tue Nov 11 17:31:59 2003 +0000
description:
Implement mach_thread_get_state.
While we are here, try to tag machine dependent functions in header files.
also transformed darwin_ppc_*_state into mach_ppc_*_state, as this is
what they really are (COMPAT_DARWIN is on the top of COMPAT_MACH, not the
other way around)
diffstat:
sys/arch/macppc/include/mach_machdep.h | 3 +
sys/arch/powerpc/include/darwin_machdep.h | 52 +++----------------
sys/arch/powerpc/include/mach_machdep.h | 81 +++++++++++++++++++++++++++++++
sys/arch/powerpc/powerpc/mach_machdep.c | 51 ++++++++++++++++++-
sys/compat/mach/mach_host.h | 8 +-
sys/compat/mach/mach_namemap.c | 5 +-
sys/compat/mach/mach_thread.c | 36 ++++++++++++-
sys/compat/mach/mach_thread.h | 26 +++++++++-
8 files changed, 208 insertions(+), 54 deletions(-)
diffs (truncated from 397 to 300 lines):
diff -r 18f27fb45973 -r 2abf5f7f165f sys/arch/macppc/include/mach_machdep.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/macppc/include/mach_machdep.h Tue Nov 11 17:31:59 2003 +0000
@@ -0,0 +1,3 @@
+/* $NetBSD: mach_machdep.h,v 1.1 2003/11/11 17:31:59 manu Exp $ */
+
+#include <powerpc/mach_machdep.h>
diff -r 18f27fb45973 -r 2abf5f7f165f sys/arch/powerpc/include/darwin_machdep.h
--- a/sys/arch/powerpc/include/darwin_machdep.h Tue Nov 11 17:27:13 2003 +0000
+++ b/sys/arch/powerpc/include/darwin_machdep.h Tue Nov 11 17:31:59 2003 +0000
@@ -1,7 +1,7 @@
-/* $NetBSD: darwin_machdep.h,v 1.3 2003/09/07 07:50:31 manu Exp $ */
+/* $NetBSD: darwin_machdep.h,v 1.4 2003/11/11 17:31:59 manu Exp $ */
/*-
- * Copyright (c) 2002 The NetBSD Foundation, Inc.
+ * Copyright (c) 2002-2003 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
@@ -40,56 +40,24 @@
#define _DARWIN_MACHDEP_H_
#include <compat/darwin/darwin_signal.h>
+#include <machine/mach_machdep.h>
void darwin_fork_child_return(void *);
-struct darwin_ppc_exception_state {
- unsigned long dar;
- unsigned long dsisr;
- unsigned long exception;
- unsigned long pad[5];
-};
-
-struct darwin_ppc_thread_state {
- unsigned int srr0;
- unsigned int srr1;
- unsigned int gpreg[32];
- unsigned int cr;
- unsigned int xer;
- unsigned int lr;
- unsigned int ctr;
- unsigned int mq;
- unsigned int vrsave;
-};
-
-struct darwin_ppc_float_state {
- double fpregs[32];
- unsigned int fpscr_pad;
- unsigned int fpscr;
-};
-
-struct darwin_ppc_vector_state {
- unsigned long vr[32][4];
- unsigned long vscr[4];
- unsigned int pad1[4];
- unsigned int vrvalid;
- unsigned int pad2[7];
-};
-
struct darwin_mcontext {
- struct darwin_ppc_exception_state es;
- struct darwin_ppc_thread_state ss;
- struct darwin_ppc_float_state fs;
- struct darwin_ppc_vector_state vs;
+ struct mach_ppc_exception_state es;
+ struct mach_ppc_thread_state ss;
+ struct mach_ppc_float_state fs;
+ struct mach_ppc_vector_state vs;
};
struct darwin_sigframe {
int nocopy1[30];
/* struct darwin_mcontext without the vs field */
struct darwin__mcontext {
- struct darwin_ppc_exception_state es;
- struct darwin_ppc_thread_state ss;
- struct darwin_ppc_float_state fs;
+ struct mach_ppc_exception_state es;
+ struct mach_ppc_thread_state ss;
+ struct mach_ppc_float_state fs;
} dmc;
int nocopy2[144];
/* struct darwin_ucontext with some padding */
diff -r 18f27fb45973 -r 2abf5f7f165f sys/arch/powerpc/include/mach_machdep.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/powerpc/include/mach_machdep.h Tue Nov 11 17:31:59 2003 +0000
@@ -0,0 +1,81 @@
+/* $NetBSD: mach_machdep.h,v 1.1 2003/11/11 17:31:59 manu Exp $ */
+
+/*-
+ * Copyright (c) 2003 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_MACHDEP_H_
+#define _MACH_MACHDEP_H_
+
+#define MACH_PPC_THREAD_STATE 1
+#define MACH_PPC_FLOAT_STATE 2
+#define MACH_PPC_EXCEPTION_STATE 3
+#define MACH_PPC_VECTOR_STATE 4
+#define MACH_THREAD_STATE_NONE 7
+
+struct mach_ppc_exception_state {
+ unsigned long dar;
+ unsigned long dsisr;
+ unsigned long exception;
+ unsigned long pad[5];
+};
+
+struct mach_ppc_thread_state {
+ unsigned int srr0;
+ unsigned int srr1;
+ unsigned int gpreg[32];
+ unsigned int cr;
+ unsigned int xer;
+ unsigned int lr;
+ unsigned int ctr;
+ unsigned int mq;
+ unsigned int vrsave;
+};
+
+struct mach_ppc_float_state {
+ double fpregs[32];
+ unsigned int fpscr_pad;
+ unsigned int fpscr;
+};
+
+struct mach_ppc_vector_state {
+ unsigned long vr[32][4];
+ unsigned long vscr[4];
+ unsigned int pad1[4];
+ unsigned int vrvalid;
+ unsigned int pad2[7];
+};
+
+#endif /* _MACH_MACHDEP_H_ */
diff -r 18f27fb45973 -r 2abf5f7f165f sys/arch/powerpc/powerpc/mach_machdep.c
--- a/sys/arch/powerpc/powerpc/mach_machdep.c Tue Nov 11 17:27:13 2003 +0000
+++ b/sys/arch/powerpc/powerpc/mach_machdep.c Tue Nov 11 17:31:59 2003 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: mach_machdep.c,v 1.15 2003/09/30 21:04:54 manu Exp $ */
+/* $NetBSD: mach_machdep.c,v 1.16 2003/11/11 17:31:59 manu Exp $ */
/*-
* Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: mach_machdep.c,v 1.15 2003/09/30 21:04:54 manu Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mach_machdep.c,v 1.16 2003/11/11 17:31:59 manu Exp $");
#include "opt_ppcarch.h"
#include <sys/param.h>
@@ -67,6 +67,7 @@
#include <machine/reg.h>
#include <machine/frame.h>
#include <machine/vmparam.h>
+#include <machine/mach_machdep.h>
#include <machine/macho_machdep.h>
#include <uvm/uvm_extern.h>
@@ -138,3 +139,49 @@
#endif
return;
}
+
+int
+mach_thread_state(l, flavor, state, size)
+ struct lwp *l;
+ int flavor;
+ void *state;
+ int *size;
+{
+ struct trapframe *tf;
+
+ tf = trapframe(l);
+
+ switch (flavor) {
+ case MACH_PPC_THREAD_STATE: {
+ struct mach_ppc_thread_state *mpts;
+
+ mpts = (struct mach_ppc_thread_state *)state;
+ mpts->srr0 = tf->srr0;
+ mpts->srr1 = tf->srr1;
+ memcpy(mpts, &tf->fixreg[0], sizeof(mpts->gpreg));
+ mpts->cr = tf->cr;
+ mpts->xer = tf->xer;
+ mpts->lr = tf->lr;
+ mpts->ctr = tf->ctr;
+ mpts->mq = 0; /* XXX */
+ mpts->vrsave = 0; /* XXX */
+
+ *size = sizeof(*mpts);
+ break;
+ }
+
+ case MACH_THREAD_STATE_NONE:
+ *size = 0;
+ break;
+
+ case MACH_PPC_FLOAT_STATE:
+ case MACH_PPC_EXCEPTION_STATE:
+ case MACH_PPC_VECTOR_STATE:
+ default:
+ printf("Unimplemented thread state flavor %d\n", flavor);
+ return EINVAL;
+ break;
+ }
+
+ return 0;
+}
diff -r 18f27fb45973 -r 2abf5f7f165f sys/compat/mach/mach_host.h
--- a/sys/compat/mach/mach_host.h Tue Nov 11 17:27:13 2003 +0000
+++ b/sys/compat/mach/mach_host.h Tue Nov 11 17:31:59 2003 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: mach_host.h,v 1.10 2003/02/02 19:07:17 manu Exp $ */
+/* $NetBSD: mach_host.h,v 1.11 2003/11/11 17:31:59 manu Exp $ */
/*-
* Copyright (c) 2002-2003 The NetBSD Foundation, Inc.
@@ -157,10 +157,12 @@
} mach_host_get_io_master_reply_t;
int mach_host_info(struct mach_trap_args *);
-void mach_host_basic_info(struct mach_host_basic_info *);
-void mach_host_priority_info(struct mach_host_priority_info *);
int mach_host_page_size(struct mach_trap_args *);
int mach_host_get_clock_service(struct mach_trap_args *);
int mach_host_get_io_master(struct mach_trap_args *);
+/* Theses are machine dependent functions */
+void mach_host_basic_info(struct mach_host_basic_info *);
+void mach_host_priority_info(struct mach_host_priority_info *);
+
#endif /* _MACH_HOST_H_ */
diff -r 18f27fb45973 -r 2abf5f7f165f sys/compat/mach/mach_namemap.c
--- a/sys/compat/mach/mach_namemap.c Tue Nov 11 17:27:13 2003 +0000
+++ b/sys/compat/mach/mach_namemap.c Tue Nov 11 17:31:59 2003 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: mach_namemap.c,v 1.33 2003/11/03 22:17:42 manu Exp $ */
+/* $NetBSD: mach_namemap.c,v 1.34 2003/11/11 17:31:59 manu Exp $ */
/*-
* Copyright (c) 2002-2003 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: mach_namemap.c,v 1.33 2003/11/03 22:17:42 manu Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mach_namemap.c,v 1.34 2003/11/11 17:31:59 manu Exp $");
#include <sys/types.h>
#include <sys/param.h>
@@ -133,6 +133,7 @@
{ 3414, mach_task_get_exception_ports, "task_get_exception_ports" },
{ 3418, mach_semaphore_create, "semaphore_create" },
{ 3419, mach_semaphore_destroy, "semaphore_destroy" },
+ { 3603, mach_thread_get_state, "thread_get_state" },
{ 3612, mach_thread_info, "thread_info" },
{ 3616, mach_thread_policy, "thread_policy" },
{ 3800, mach_vm_region, "vm_region" },
diff -r 18f27fb45973 -r 2abf5f7f165f sys/compat/mach/mach_thread.c
--- a/sys/compat/mach/mach_thread.c Tue Nov 11 17:27:13 2003 +0000
+++ b/sys/compat/mach/mach_thread.c Tue Nov 11 17:31:59 2003 +0000
@@ -1,7 +1,7 @@
Home |
Main Index |
Thread Index |
Old Index