summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sys/arch/powerpc/include/pcb.h6
-rw-r--r--sys/arch/powerpc/include/ptrace.h4
-rw-r--r--sys/arch/powerpc/include/reg.h21
-rw-r--r--sys/arch/powerpc/powerpc/process_machdep.c46
-rw-r--r--sys/arch/powerpc/powerpc/trap.c36
-rw-r--r--sys/arch/powerpc/powerpc/vm_machdep.c11
6 files changed, 108 insertions, 16 deletions
diff --git a/sys/arch/powerpc/include/pcb.h b/sys/arch/powerpc/include/pcb.h
index ab02043c45f..ea32d4bbcab 100644
--- a/sys/arch/powerpc/include/pcb.h
+++ b/sys/arch/powerpc/include/pcb.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: pcb.h,v 1.2 1996/12/28 06:25:18 rahnds Exp $ */
+/* $OpenBSD: pcb.h,v 1.3 1998/08/07 02:22:03 rahnds Exp $ */
/* $NetBSD: pcb.h,v 1.1 1996/09/30 16:34:29 ws Exp $ */
/*-
@@ -34,6 +34,7 @@
#ifndef _MACHINE_PCB_H_
#define _MACHINE_PCB_H_
+#include <machine/reg.h>
typedef int faultbuf[24];
struct pcb {
@@ -51,8 +52,7 @@ struct pcb {
};
struct md_coredump {
- struct trapframe frame;
- /* Need to add FPU regs here */
+ struct reg regs;
};
#ifdef _KERNEL
diff --git a/sys/arch/powerpc/include/ptrace.h b/sys/arch/powerpc/include/ptrace.h
index 321320297e6..7190d31d4a2 100644
--- a/sys/arch/powerpc/include/ptrace.h
+++ b/sys/arch/powerpc/include/ptrace.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ptrace.h,v 1.1 1996/12/28 06:09:22 rahnds Exp $ */
+/* $OpenBSD: ptrace.h,v 1.2 1998/08/07 02:22:05 rahnds Exp $ */
/* $NetBSD: ptrace.h,v 1.7 1995/01/26 19:47:10 mycroft Exp $ */
/*
@@ -37,10 +37,10 @@
* powerpc-dependent ptrace definitions
*/
#define PT_STEP (PT_FIRSTMACH + 0)
-#if NOT_SUPPORTED
#define PT_GETREGS (PT_FIRSTMACH + 1)
#define PT_SETREGS (PT_FIRSTMACH + 2)
+#if NOT_SUPPORTED
#define PT_GETFPREGS (PT_FIRSTMACH + 3)
#define PT_SETFPREGS (PT_FIRSTMACH + 4)
#endif
diff --git a/sys/arch/powerpc/include/reg.h b/sys/arch/powerpc/include/reg.h
index b0c31944803..ba2ab6413a9 100644
--- a/sys/arch/powerpc/include/reg.h
+++ b/sys/arch/powerpc/include/reg.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: reg.h,v 1.1 1997/01/02 02:55:47 rahnds Exp $ */
+/* $OpenBSD: reg.h,v 1.2 1998/08/07 02:22:06 rahnds Exp $ */
/*-
* Copyright (c) 1990 The Regents of the University of California.
@@ -41,5 +41,22 @@
#ifndef _POWERPC_REG_H_
#define _POWERPC_REG_H_
-/* not supported yet */
+/*
+ * Struct reg, used for procfs and in signal contexts
+ * Note that in signal contexts, it's represented as an array.
+ * That array has to look exactly like 'struct reg' though.
+ */
+
+/* this table is set up to match what gdb expects */
+struct reg {
+ u_int32_t gpr[32];
+ u_int64_t fpr[32];
+ u_int32_t pc;
+ u_int32_t ps;
+ u_int32_t cnd;
+ u_int32_t lr;
+ u_int32_t cnt;
+ u_int32_t xer;
+ u_int32_t mq;
+};
#endif /* !_POWERPC_REG_H_ */
diff --git a/sys/arch/powerpc/powerpc/process_machdep.c b/sys/arch/powerpc/powerpc/process_machdep.c
index 1bb3b9ebb60..99ade0ecc9f 100644
--- a/sys/arch/powerpc/powerpc/process_machdep.c
+++ b/sys/arch/powerpc/powerpc/process_machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: process_machdep.c,v 1.2 1996/12/28 06:22:16 rahnds Exp $ */
+/* $OpenBSD: process_machdep.c,v 1.3 1998/08/07 02:22:08 rahnds Exp $ */
/* $NetBSD: process_machdep.c,v 1.1 1996/09/30 16:34:53 ws Exp $ */
/*
@@ -33,6 +33,7 @@
*/
#include <sys/param.h>
#include <sys/proc.h>
+#include <machine/reg.h>
/*
* Set the process's program counter.
@@ -61,3 +62,46 @@ process_sstep(p, sstep)
tf->srr1 &= ~PSL_SE;
return 0;
}
+int
+process_read_regs(p, regs)
+ struct proc *p;
+ struct reg *regs;
+{
+ struct trapframe *tf = trapframe(p);
+
+ bcopy(&(tf->fixreg[0]), &(regs->gpr[0]), sizeof(regs->gpr));
+ bzero(&(regs->fpr[0]), sizeof(regs->fpr));
+ /*
+ * need to do floating point here
+ */
+ regs->pc = tf->srr0;
+ regs->ps = tf->srr1; /* is this the correct value for this ? */
+ regs->cnd = tf->cr;
+ regs->lr = tf->lr;
+ regs->cnt = tf->ctr;
+ regs->xer = tf->xer;
+ regs->mq = 0; /* what should this really be? */
+
+ return (0);
+}
+int
+process_write_regs(p, regs)
+ struct proc *p;
+ struct reg *regs;
+{
+ struct trapframe *tf = trapframe(p);
+
+ bcopy(&(regs->gpr[0]), &(tf->fixreg[0]), sizeof(regs->gpr));
+ /*
+ * need to do floating point here
+ */
+ tf->srr0 = regs->pc;
+ tf->srr1 = regs->ps; /* is this the correct value for this ? */
+ tf->cr = regs->cnd;
+ tf->lr = regs->lr;
+ tf->ctr = regs->cnt;
+ tf->xer = regs->xer;
+ /* regs->mq = 0; what should this really be? */
+
+ return (0);
+}
diff --git a/sys/arch/powerpc/powerpc/trap.c b/sys/arch/powerpc/powerpc/trap.c
index e95f96b49e9..c88c18ac34b 100644
--- a/sys/arch/powerpc/powerpc/trap.c
+++ b/sys/arch/powerpc/powerpc/trap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: trap.c,v 1.8 1998/05/29 04:15:41 rahnds Exp $ */
+/* $OpenBSD: trap.c,v 1.9 1998/08/07 02:22:09 rahnds Exp $ */
/* $NetBSD: trap.c,v 1.3 1996/10/13 03:31:37 christos Exp $ */
/*
@@ -56,6 +56,34 @@
volatile int want_resched;
+#ifdef PPC_WANT_BACKTRACE
+void dumpframe (u_int32_t pframe)
+{
+ u_int32_t nextframe;
+ u_int32_t lr;
+ int error;
+ if (error = copyin ((void *)pframe, &nextframe , 4) ){
+ printf("unable to read next frame @%x\n", pframe);
+ return;
+ }
+ if (error = copyin ((void *)(pframe+4), &lr , 4) ){
+ printf("unable to read lr @%x\n", pframe+4);
+ return;
+ }
+ printf("lr %x fp %x nfp %x\n", lr, pframe, nextframe);
+
+ if (nextframe != 0) {
+ dumpframe(nextframe);
+ }
+ return;
+}
+void
+ppc_dumpbt(struct trapframe *frame)
+{
+ dumpframe(frame->fixreg[1]);
+ return;
+}
+#endif
void
trap(frame)
struct trapframe *frame;
@@ -123,7 +151,11 @@ printf("kern dsi on addr %x iar %x\n", frame->dar, frame->srr0);
trunc_page(frame->dar), ftype, FALSE)
== KERN_SUCCESS)
break;
-printf("dsi on addr %x iar %x\n", frame->dar, frame->srr0);
+printf("dsi on addr %x iar %x lr %x\n", frame->dar, frame->srr0,frame->lr);
+/*
+ * keep this for later in case we want it later.
+ppc_dumpbt(frame);
+*/
sv.sival_int = frame->dar;
trapsignal(p, SIGSEGV, vftype, SEGV_MAPERR, sv);
}
diff --git a/sys/arch/powerpc/powerpc/vm_machdep.c b/sys/arch/powerpc/powerpc/vm_machdep.c
index b9ca7a1690b..5739a2295db 100644
--- a/sys/arch/powerpc/powerpc/vm_machdep.c
+++ b/sys/arch/powerpc/powerpc/vm_machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vm_machdep.c,v 1.3 1997/10/13 13:43:02 pefo Exp $ */
+/* $OpenBSD: vm_machdep.c,v 1.4 1998/08/07 02:22:10 rahnds Exp $ */
/* $NetBSD: vm_machdep.c,v 1.1 1996/09/30 16:34:57 ws Exp $ */
/*
@@ -180,16 +180,15 @@ cpu_coredump(p, vp, cred, chdr)
struct trapframe *tf;
int error;
-#if 0
- CORE_SETMAGIC(*chdr, COREMAGIC, MID_POWERPC, 0);
+#if 1
+ CORE_SETMAGIC(*chdr, COREMAGIC, MID_ZERO, 0);
chdr->c_hdrsize = ALIGN(sizeof *chdr);
chdr->c_seghdrsize = ALIGN(sizeof cseg);
chdr->c_cpusize = sizeof md_core;
- tf = trapframe(p);
- bcopy(tf, &md_core.frame, sizeof md_core.frame);
+ process_read_regs(p, &md_core);
- CORE_SETMAGIC(cseg, CORESEGMAGIC, MID_POWERPC, CORE_CPU);
+ CORE_SETMAGIC(cseg, CORESEGMAGIC, MID_ZERO, CORE_CPU);
cseg.c_addr = 0;
cseg.c_size = chdr->c_cpusize;