1204174Srrs/*********************************************************************** 2204174SrrsCopyright 2003-2006 Raza Microelectronics, Inc.(RMI). 3204174SrrsThis is a derived work from software originally provided by the external 4204174Srrsentity identified below. The licensing terms and warranties specified in 5204174Srrsthe header of the original work apply to this derived work. 6204174SrrsContribution by RMI: 7204174Srrs*****************************#RMI_1#**********************************/ 8204174Srrs/* Native-dependent code for MIPS systems running NetBSD. 9204174Srrs Copyright 2000, 2001, 2002 Free Software Foundation, Inc. 10204174Srrs 11204174Srrs This file is part of GDB. 12204174Srrs 13204174Srrs This program is free software; you can redistribute it and/or modify 14204174Srrs it under the terms of the GNU General Public License as published by 15204174Srrs the Free Software Foundation; either version 2 of the License, or 16204174Srrs (at your option) any later version. 17204174Srrs 18204174Srrs This program is distributed in the hope that it will be useful, 19204174Srrs but WITHOUT ANY WARRANTY; without even the implied warranty of 20204174Srrs MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 21204174Srrs GNU General Public License for more details. 22204174Srrs 23204174Srrs You should have received a copy of the GNU General Public License 24204174Srrs along with this program; if not, write to the Free Software 25204174Srrs Foundation, Inc., 59 Temple Place - Suite 330, 26204174Srrs Boston, MA 02111-1307, USA. */ 27204174Srrs 28204174Srrs#include "defs.h" 29204174Srrs#include "inferior.h" 30204174Srrs#include "regcache.h" 31204174Srrs 32204174Srrs#include "mipsfbsd-tdep.h" 33204174Srrs 34204174Srrs#include <sys/types.h> 35204174Srrs#include <sys/ptrace.h> 36204174Srrs#include <machine/reg.h> 37204174Srrs 38204174Srrs/* Determine if PT_GETREGS fetches this register. */ 39204174Srrsstatic int 40204174Srrsgetregs_supplies (int regno) 41204174Srrs{ 42204174Srrs return ((regno) >= ZERO_REGNUM && (regno) <= PC_REGNUM); 43204174Srrs} 44204174Srrs 45204174Srrsvoid 46204174Srrsfetch_inferior_registers (int regno) 47204174Srrs{ 48204174Srrs if (regno == -1 || getregs_supplies (regno)) 49204174Srrs { 50204174Srrs struct reg regs; 51204174Srrs 52204174Srrs if (ptrace (PT_GETREGS, PIDGET (inferior_ptid), 53204174Srrs (PTRACE_ARG3_TYPE) ®s, 0) == -1) 54204174Srrs perror_with_name ("Couldn't get registers"); 55204174Srrs 56204174Srrs mipsfbsd_supply_reg ((char *) ®s, regno); 57204174Srrs if (regno != -1) 58204174Srrs return; 59204174Srrs } 60204174Srrs 61204174Srrs if (regno == -1 || regno >= FP0_REGNUM) 62204174Srrs { 63204174Srrs struct fpreg fpregs; 64204174Srrs 65204174Srrs if (ptrace (PT_GETFPREGS, PIDGET (inferior_ptid), 66204174Srrs (PTRACE_ARG3_TYPE) &fpregs, 0) == -1) 67204174Srrs perror_with_name ("Couldn't get floating point status"); 68204174Srrs 69204174Srrs mipsfbsd_supply_fpreg ((char *) &fpregs, regno); 70204174Srrs } 71204174Srrs} 72204174Srrs 73204174Srrsvoid 74204174Srrsstore_inferior_registers (int regno) 75204174Srrs{ 76204174Srrs if (regno == -1 || getregs_supplies (regno)) 77204174Srrs { 78204174Srrs struct reg regs; 79204174Srrs 80204174Srrs if (ptrace (PT_GETREGS, PIDGET (inferior_ptid), 81204174Srrs (PTRACE_ARG3_TYPE) ®s, 0) == -1) 82204174Srrs perror_with_name ("Couldn't get registers"); 83204174Srrs 84204174Srrs mipsfbsd_fill_reg ((char *) ®s, regno); 85204174Srrs 86204174Srrs if (ptrace (PT_SETREGS, PIDGET (inferior_ptid), 87204174Srrs (PTRACE_ARG3_TYPE) ®s, 0) == -1) 88204174Srrs perror_with_name ("Couldn't write registers"); 89204174Srrs 90204174Srrs if (regno != -1) 91204174Srrs return; 92204174Srrs } 93204174Srrs 94204174Srrs if (regno == -1 || regno >= FP0_REGNUM) 95204174Srrs { 96204174Srrs struct fpreg fpregs; 97204174Srrs 98204174Srrs if (ptrace (PT_GETFPREGS, PIDGET (inferior_ptid), 99204174Srrs (PTRACE_ARG3_TYPE) &fpregs, 0) == -1) 100204174Srrs perror_with_name ("Couldn't get floating point status"); 101204174Srrs 102204174Srrs mipsfbsd_fill_fpreg ((char *) &fpregs, regno); 103204174Srrs 104204174Srrs if (ptrace (PT_SETFPREGS, PIDGET (inferior_ptid), 105204174Srrs (PTRACE_ARG3_TYPE) &fpregs, 0) == -1) 106204174Srrs perror_with_name ("Couldn't write floating point status"); 107204174Srrs } 108204174Srrs} 109