Annotation of sys/arch/mips64/mips64/process_machdep.c, Revision 1.1
1.1 ! nbrk 1: /* $OpenBSD: process_machdep.c,v 1.7 2007/04/26 17:05:11 miod Exp $ */
! 2:
! 3: /*
! 4: * Copyright (c) 1994 Adam Glass
! 5: * Copyright (c) 1993 The Regents of the University of California.
! 6: * Copyright (c) 1993 Jan-Simon Pendry
! 7: * All rights reserved.
! 8: *
! 9: * This code is derived from software contributed to Berkeley by
! 10: * Jan-Simon Pendry.
! 11: *
! 12: * Redistribution and use in source and binary forms, with or without
! 13: * modification, are permitted provided that the following conditions
! 14: * are met:
! 15: * 1. Redistributions of source code must retain the above copyright
! 16: * notice, this list of conditions and the following disclaimer.
! 17: * 2. Redistributions in binary form must reproduce the above copyright
! 18: * notice, this list of conditions and the following disclaimer in the
! 19: * documentation and/or other materials provided with the distribution.
! 20: * 3. All advertising materials mentioning features or use of this software
! 21: * must display the following acknowledgement:
! 22: * This product includes software developed by the University of
! 23: * California, Berkeley and its contributors.
! 24: * 4. Neither the name of the University nor the names of its contributors
! 25: * may be used to endorse or promote products derived from this software
! 26: * without specific prior written permission.
! 27: *
! 28: * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
! 29: * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
! 30: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
! 31: * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
! 32: * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
! 33: * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
! 34: * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
! 35: * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
! 36: * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
! 37: * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
! 38: * SUCH DAMAGE.
! 39: *
! 40: * From:
! 41: * Id: procfs_i386.c,v 4.1 1993/12/17 10:47:45 jsp Rel
! 42: *
! 43: * $Id: process_machdep.c,v 1.7 2007/04/26 17:05:11 miod Exp $
! 44: */
! 45:
! 46: /*
! 47: * This file may seem a bit stylized, but that so that it's easier to port.
! 48: * Functions to be implemented here are:
! 49: *
! 50: * process_read_regs(proc, regs)
! 51: * Get the current user-visible register set from the process
! 52: * and copy it into the regs structure (<machine/reg.h>).
! 53: * The process is stopped at the time read_regs is called.
! 54: *
! 55: * process_write_regs(proc, regs)
! 56: * Update the current register set from the passed in regs
! 57: * structure. Take care to avoid clobbering special CPU
! 58: * registers or privileged bits in the PSL.
! 59: * The process is stopped at the time write_regs is called.
! 60: *
! 61: * process_sstep(proc)
! 62: * Arrange for the process to trap after executing a single instruction.
! 63: *
! 64: * process_set_pc(proc)
! 65: * Set the process's program counter.
! 66: */
! 67:
! 68: #include <sys/param.h>
! 69: #include <sys/systm.h>
! 70: #include <sys/time.h>
! 71: #include <sys/kernel.h>
! 72: #include <sys/proc.h>
! 73: #include <sys/user.h>
! 74: #include <sys/vnode.h>
! 75: #include <sys/ptrace.h>
! 76: #include <machine/pte.h>
! 77: #include <machine/psl.h>
! 78: #include <machine/frame.h>
! 79:
! 80: #define REGSIZE sizeof(struct trap_frame)
! 81:
! 82: extern void cpu_singlestep(struct proc *);
! 83:
! 84: int
! 85: process_read_regs(p, regs)
! 86: struct proc *p;
! 87: struct reg *regs;
! 88: {
! 89: extern struct proc *machFPCurProcPtr;
! 90:
! 91: if (p == machFPCurProcPtr) {
! 92: if (p->p_md.md_regs->sr & SR_FR_32)
! 93: MipsSaveCurFPState(p);
! 94: else
! 95: MipsSaveCurFPState16(p);
! 96: }
! 97: bcopy((caddr_t)p->p_md.md_regs, (caddr_t)regs, REGSIZE);
! 98: return (0);
! 99: }
! 100:
! 101: #ifdef PTRACE
! 102:
! 103: int
! 104: process_write_regs(p, regs)
! 105: struct proc *p;
! 106: struct reg *regs;
! 107: {
! 108: register_t sr;
! 109: extern struct proc *machFPCurProcPtr;
! 110:
! 111: if (p == machFPCurProcPtr) {
! 112: if (p->p_md.md_regs->sr & SR_FR_32)
! 113: MipsSaveCurFPState(p);
! 114: else
! 115: MipsSaveCurFPState16(p);
! 116: }
! 117: sr = p->p_md.md_regs->sr;
! 118: bcopy((caddr_t)regs, (caddr_t)p->p_md.md_regs, REGSIZE);
! 119: p->p_md.md_regs->sr = sr;
! 120: return (0);
! 121: }
! 122:
! 123: int
! 124: process_sstep(p, sstep)
! 125: struct proc *p;
! 126: {
! 127: if (sstep)
! 128: cpu_singlestep(p);
! 129: return (0);
! 130: }
! 131:
! 132: int
! 133: process_set_pc(p, addr)
! 134: struct proc *p;
! 135: caddr_t addr;
! 136: {
! 137: p->p_md.md_regs->pc = (register_t)addr;
! 138: return (0);
! 139: }
! 140:
! 141: #endif /* PTRACE */
CVSweb