Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch Shared ARM ptrace(2) implementation. Mostly the sa...



details:   https://anonhg.NetBSD.org/src/rev/230949459e03
branches:  trunk
changeset: 503690:230949459e03
user:      bjh21 <bjh21%NetBSD.org@localhost>
date:      Sun Feb 11 17:03:04 2001 +0000

description:
Shared ARM ptrace(2) implementation.  Mostly the same as the arm32
version, but with some #ifdefs for arm26.

Also, don't define PT_STEP, since we don't implement it.  This should
reduce code size a little.

diffstat:

 sys/arch/arm/arm/process_machdep.c     |  185 +++++++++++++++++++++++++++++++++
 sys/arch/arm/conf/files.arm            |    3 +-
 sys/arch/arm/include/Makefile          |    6 +-
 sys/arch/arm/include/ptrace.h          |   41 +++++++
 sys/arch/arm26/arm26/process_machdep.c |  115 --------------------
 sys/arch/arm26/conf/files.arm26        |    3 +-
 sys/arch/arm26/include/ptrace.h        |   42 +-------
 sys/arch/arm32/arm32/process_machdep.c |  174 -------------------------------
 sys/arch/arm32/conf/files.arm32        |    3 +-
 sys/arch/arm32/include/ptrace.h        |   42 +-------
 10 files changed, 237 insertions(+), 377 deletions(-)

diffs (truncated from 692 to 300 lines):

diff -r 2b6dfb4b7834 -r 230949459e03 sys/arch/arm/arm/process_machdep.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/arm/arm/process_machdep.c        Sun Feb 11 17:03:04 2001 +0000
@@ -0,0 +1,185 @@
+/*     $NetBSD: process_machdep.c,v 1.1 2001/02/11 17:03:04 bjh21 Exp $        */
+
+/*
+ * Copyright (c) 1995 Frank Lancaster.  All rights reserved.
+ * Copyright (c) 1995 Tools GmbH.  All rights reserved.
+ * Copyright (c) 1995 Charles M. Hannum.  All rights reserved.
+ * Copyright (c) 1993 The Regents of the University of California.
+ * Copyright (c) 1993 Jan-Simon Pendry
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Jan-Simon Pendry.
+ *
+ * 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 University of
+ *     California, Berkeley and its contributors.
+ * 4. Neither the name of the University 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 REGENTS 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 REGENTS 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.
+ *
+ * From:
+ *     Id: procfs_i386.c,v 4.1 1993/12/17 10:47:45 jsp Rel
+ */
+
+/*
+ * This file may seem a bit stylized, but that so that it's easier to port.
+ * Functions to be implemented here are:
+ *
+ * process_read_regs(proc, regs)
+ *     Get the current user-visible register set from the process
+ *     and copy it into the regs structure (<machine/reg.h>).
+ *     The process is stopped at the time read_regs is called.
+ *
+ * process_write_regs(proc, regs)
+ *     Update the current register set from the passed in regs
+ *     structure.  Take care to avoid clobbering special CPU
+ *     registers or privileged bits in the PSL.
+ *     The process is stopped at the time write_regs is called.
+ *
+ * process_sstep(proc, sstep)
+ *     Arrange for the process to trap or not trap depending on sstep
+ *     after executing a single instruction.
+ *
+ * process_set_pc(proc)
+ *     Set the process's program counter.
+ */
+
+#ifdef arm32
+#include "opt_armfpe.h"
+#endif
+
+#include <sys/param.h>
+
+__KERNEL_RCSID(0, "$NetBSD: process_machdep.c,v 1.1 2001/02/11 17:03:04 bjh21 Exp $");
+
+#include <sys/proc.h>
+#include <sys/ptrace.h>
+#include <sys/systm.h>
+#include <sys/user.h>
+
+#include <machine/frame.h>
+#include <machine/pcb.h>
+#include <machine/reg.h>
+
+#ifndef arm32
+#include <arm/armreg.h>
+#endif
+
+#ifdef ARMFPE
+#include <machine/cpus.h>
+#include <arm32/fpe-arm/armfpe.h>
+#endif /* ARMFPE */
+
+static __inline struct trapframe *
+process_frame(struct proc *p)
+{
+
+#ifdef arm32
+       return (p->p_md.md_regs);
+#else /* arm26 */
+       return p->p_addr->u_pcb.pcb_tf;
+#endif
+}
+
+int
+process_read_regs(struct proc *p, struct reg *regs)
+{
+       struct trapframe *tf = process_frame(p);
+
+       KASSERT(tf != NULL);
+       bcopy((caddr_t)&tf->tf_r0, (caddr_t)regs->r, sizeof(regs->r));
+       regs->r_sp = tf->tf_usr_sp;
+       regs->r_lr = tf->tf_usr_lr;
+       regs->r_pc = tf->tf_pc;
+       regs->r_cpsr = tf->tf_spsr;
+
+       return(0);
+}
+
+int
+process_read_fpregs(struct proc *p, struct fpreg *regs)
+{
+#ifdef ARMFPE
+       arm_fpe_getcontext(p, regs);
+       return(0);
+#else  /* ARMFPE */
+       /* No hardware FP support */
+       memset(regs, 0, sizeof(struct fpreg));
+       return(0);
+#endif /* ARMFPE */
+}
+
+int
+process_write_regs(struct proc *p, struct reg *regs)
+{
+       struct trapframe *tf = process_frame(p);
+
+       KASSERT(tf != NULL);
+       bcopy((caddr_t)regs->r, (caddr_t)&tf->tf_r0, sizeof(regs->r));
+       tf->tf_usr_sp = regs->r_sp;
+       tf->tf_usr_lr = regs->r_lr;
+#ifdef arm32
+       tf->tf_pc = regs->r_pc;
+       tf->tf_spsr &=  ~PSR_FLAGS;
+       tf->tf_spsr |= regs->r_cpsr & PSR_FLAGS;
+#else /* arm26 */
+       if ((regs->r_pc & (R15_MODE | R15_IRQ_DISABLE | R15_FIQ_DISABLE)) != 0)
+               return EPERM;
+
+       tf->tf_r15 = regs->r_pc;
+#endif
+
+       return(0);
+}
+
+int
+process_write_fpregs(struct proc *p,  struct fpreg *regs)
+{
+#ifdef ARMFPE
+       arm_fpe_setcontext(p, regs);
+       return(0);
+#else  /* ARMFPE */
+       /* No hardware FP support */
+       return(0);
+#endif /* ARMFPE */
+}
+
+int
+process_set_pc(struct proc *p, caddr_t addr)
+{
+       struct trapframe *tf = process_frame(p);
+
+       KASSERT(tf != NULL);
+#ifdef arm32
+       tf->tf_pc = (int)addr;
+#else /* arm26 */
+       /* Only set the PC, not the PSR */
+       if (((register_t)addr & R15_PC) != (register_t)addr)
+               return EINVAL;
+       tf->tf_r15 = (tf->tf_r15 & ~R15_PC) | (register_t)addr;
+#endif
+
+       return (0);
+}
diff -r 2b6dfb4b7834 -r 230949459e03 sys/arch/arm/conf/files.arm
--- a/sys/arch/arm/conf/files.arm       Sun Feb 11 16:16:58 2001 +0000
+++ b/sys/arch/arm/conf/files.arm       Sun Feb 11 17:03:04 2001 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: files.arm,v 1.5 2001/01/13 00:06:50 bjh21 Exp $
+#      $NetBSD: files.arm,v 1.6 2001/02/11 17:03:05 bjh21 Exp $
 
 file   arch/arm/arm/in_cksum_arm.c             inet
 file   netinet/in4_cksum.c                     inet
@@ -10,4 +10,5 @@
 # files related to debugging
 file   arch/arm/arm/disassem.c
 
+file   arch/arm/arm/process_machdep.c
 file   arch/arm/arm/sigcode.S
diff -r 2b6dfb4b7834 -r 230949459e03 sys/arch/arm/include/Makefile
--- a/sys/arch/arm/include/Makefile     Sun Feb 11 16:16:58 2001 +0000
+++ b/sys/arch/arm/include/Makefile     Sun Feb 11 17:03:04 2001 +0000
@@ -1,11 +1,11 @@
-#      $NetBSD: Makefile,v 1.7 2001/02/11 14:51:55 bjh21 Exp $
+#      $NetBSD: Makefile,v 1.8 2001/02/11 17:03:05 bjh21 Exp $
 
 KDIR=  /sys/arch/arm/include
 INCSDIR= /usr/include/arm
 
 INCS=  ansi.h aout_machdep.h armreg.h asm.h bswap.h cdefs.h disklabel.h \
        disklabel_acorn.h elf_machdep.h float.h fp.h frame.h ieee.h ieeefp.h \
-       int_types.h limits.h lock.h math.h reg.h signal.h setjmp.h stdarg.h \
-       trap.h varargs.h
+       int_types.h limits.h lock.h math.h ptrace reg.h signal.h setjmp.h \
+       stdarg.h trap.h varargs.h
 
 .include <bsd.kinc.mk>
diff -r 2b6dfb4b7834 -r 230949459e03 sys/arch/arm/include/ptrace.h
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/arm/include/ptrace.h     Sun Feb 11 17:03:04 2001 +0000
@@ -0,0 +1,41 @@
+/*     $NetBSD: ptrace.h,v 1.1 2001/02/11 17:03:05 bjh21 Exp $ */
+
+/*
+ * Copyright (c) 1995 Frank Lancaster
+ * Copyright (c) 1995 Tools GmbH
+ * All rights reserved.
+ *
+ * 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 Christopher G. Demetriou.
+ * 4. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission
+ *
+ * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``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 TOOLS GMBH 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.
+ */
+
+/*
+ * arm-dependent ptrace definitions
+ */
+/* #define PT_STEP     (PT_FIRSTMACH + 0) Not implemented */
+#define        PT_GETREGS      (PT_FIRSTMACH + 1)
+#define        PT_SETREGS      (PT_FIRSTMACH + 2)
+#define        PT_GETFPREGS    (PT_FIRSTMACH + 3)
+#define        PT_SETFPREGS    (PT_FIRSTMACH + 4)
diff -r 2b6dfb4b7834 -r 230949459e03 sys/arch/arm26/arm26/process_machdep.c
--- a/sys/arch/arm26/arm26/process_machdep.c    Sun Feb 11 16:16:58 2001 +0000
+++ /dev/null   Thu Jan 01 00:00:00 1970 +0000
@@ -1,115 +0,0 @@
-/* $NetBSD: process_machdep.c,v 1.4 2001/02/11 14:51:56 bjh21 Exp $ */
-/*-
- * Copyright (c) 2000 Ben Harris
- * All rights reserved.
- *
- * 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. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission.
- * 
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
- */
-/* This file is part of NetBSD/arm26 -- a port of NetBSD to ARM2/3 machines. */
-/*



Home | Main Index | Thread Index | Old Index