19313Ssos/* 68k-dependent portions of the RPC protocol 29313Ssos used with a VxWorks target 39313Ssos 49313Ssos Contributed by Wind River Systems. 59313Ssos 69313Ssos This file is part of GDB. 79313Ssos 89313Ssos This program is free software; you can redistribute it and/or modify 99313Ssos it under the terms of the GNU General Public License as published by 109313Ssos the Free Software Foundation; either version 2 of the License, or 119313Ssos (at your option) any later version. 129313Ssos 139313Ssos This program is distributed in the hope that it will be useful, 149313Ssos but WITHOUT ANY WARRANTY; without even the implied warranty of 159313Ssos MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 169313Ssos GNU General Public License for more details. 179313Ssos 189313Ssos You should have received a copy of the GNU General Public License 199313Ssos along with this program; if not, write to the Free Software 209313Ssos Foundation, Inc., 59 Temple Place - Suite 330, 219313Ssos Boston, MA 02111-1307, USA. */ 229313Ssos 239313Ssos#include <stdio.h> 249313Ssos#include "defs.h" 259313Ssos 269313Ssos#include "vx-share/regPacket.h" 279313Ssos#include "frame.h" 2812858Speter#include "inferior.h" 299313Ssos#include "target.h" 309313Ssos#include "gdbcore.h" 319313Ssos#include "command.h" 329313Ssos#include "symtab.h" 3312458Sbde#include "symfile.h" 349313Ssos#include "regcache.h" 359313Ssos 369313Ssos#include "gdb_string.h" 379313Ssos#include <errno.h> 389313Ssos#include <fcntl.h> 399313Ssos#include <sys/types.h> 4012458Sbde#include <sys/time.h> 419313Ssos#include <sys/socket.h> 429313Ssos 439313Ssos#ifdef _AIX /* IBM claims "void *malloc()" not char * */ 449313Ssos#define malloc bogon_malloc 459313Ssos#endif 469313Ssos 479313Ssos#include <rpc/rpc.h> 489313Ssos 499313Ssos#ifdef _AIX 509313Ssos#undef malloc 519313Ssos#endif 529313Ssos 539313Ssos#include <sys/time.h> /* UTek's <rpc/rpc.h> doesn't #incl this */ 549313Ssos#include <netdb.h> 559313Ssos#include "vx-share/ptrace.h" 569313Ssos#include "vx-share/xdr_ptrace.h" 579313Ssos#include "vx-share/xdr_ld.h" 589313Ssos#include "vx-share/xdr_rdb.h" 599313Ssos#include "vx-share/dbgRpcLib.h" 609313Ssos 619313Ssos/* get rid of value.h if possible */ 629313Ssos#include <value.h> 639313Ssos#include <symtab.h> 649313Ssos 659313Ssos/* Flag set if target has fpu */ 669313Ssos 679313Ssosextern int target_has_fp; 689313Ssos 699313Ssos/* Generic register read/write routines in remote-vx.c. */ 709313Ssos 719313Ssosextern void net_read_registers (); 729313Ssosextern void net_write_registers (); 739313Ssos 749313Ssos/* Read a register or registers from the VxWorks target. 759313Ssos REGNO is the register to read, or -1 for all; currently, 769313Ssos it is ignored. FIXME look at regno to improve efficiency. */ 7712858Speter 7812858Spetervoid 799313Ssosvx_read_register (int regno) 809313Ssos{ 8112858Speter char mc68k_greg_packet[MC68K_GREG_PLEN]; 829313Ssos char mc68k_fpreg_packet[MC68K_FPREG_PLEN]; 839313Ssos 849313Ssos /* Get general-purpose registers. */ 859313Ssos 869313Ssos net_read_registers (mc68k_greg_packet, MC68K_GREG_PLEN, PTRACE_GETREGS); 879313Ssos 889313Ssos bcopy (&mc68k_greg_packet[MC68K_R_D0], deprecated_registers, 899313Ssos 16 * MC68K_GREG_SIZE); 909313Ssos bcopy (&mc68k_greg_packet[MC68K_R_SR], 919313Ssos &deprecated_registers[DEPRECATED_REGISTER_BYTE (PS_REGNUM)], 929313Ssos MC68K_GREG_SIZE); 939313Ssos bcopy (&mc68k_greg_packet[MC68K_R_PC], 949313Ssos &deprecated_registers[DEPRECATED_REGISTER_BYTE (PC_REGNUM)], 959313Ssos MC68K_GREG_SIZE); 969313Ssos 979313Ssos /* Get floating-point registers, if the target system has them. 989313Ssos Otherwise, zero them. */ 999313Ssos 1009313Ssos if (target_has_fp) 1019313Ssos { 1029313Ssos net_read_registers (mc68k_fpreg_packet, MC68K_FPREG_PLEN, 1039313Ssos PTRACE_GETFPREGS); 1049313Ssos 1059313Ssos bcopy (&mc68k_fpreg_packet[MC68K_R_FP0], 10612858Speter &deprecated_registers[DEPRECATED_REGISTER_BYTE (FP0_REGNUM)], 1079313Ssos MC68K_FPREG_SIZE * 8); 1089313Ssos bcopy (&mc68k_fpreg_packet[MC68K_R_FPCR], 1099313Ssos &deprecated_registers[DEPRECATED_REGISTER_BYTE (FPC_REGNUM)], 1109313Ssos MC68K_FPREG_PLEN - (MC68K_FPREG_SIZE * 8)); 1119313Ssos } 1129313Ssos else 1139313Ssos { 1149313Ssos memset (&deprecated_registers[DEPRECATED_REGISTER_BYTE (FP0_REGNUM)], 1159313Ssos 0, MC68K_FPREG_SIZE * 8); 1169313Ssos memset (&deprecated_registers[DEPRECATED_REGISTER_BYTE (FPC_REGNUM)], 1179313Ssos 0, MC68K_FPREG_PLEN - (MC68K_FPREG_SIZE * 8)); 1189313Ssos } 1199313Ssos 1209313Ssos /* Mark the register cache valid. */ 1219313Ssos 1229313Ssos deprecated_registers_fetched (); 1239313Ssos} 1249313Ssos 1259313Ssos/* Store a register or registers into the VxWorks target. 1269313Ssos REGNO is the register to store, or -1 for all; currently, 1279313Ssos it is ignored. FIXME look at regno to improve efficiency. */ 1289313Ssos 1299313Ssosvoid 1309313Ssosvx_write_register (int regno) 1319313Ssos{ 1329313Ssos char mc68k_greg_packet[MC68K_GREG_PLEN]; 1339313Ssos char mc68k_fpreg_packet[MC68K_FPREG_PLEN]; 1349313Ssos 1359313Ssos /* Store general-purpose registers. */ 1369313Ssos 1379313Ssos bcopy (deprecated_registers, &mc68k_greg_packet[MC68K_R_D0], 1389313Ssos 16 * MC68K_GREG_SIZE); 1399313Ssos bcopy (&deprecated_registers[DEPRECATED_REGISTER_BYTE (PS_REGNUM)], 1409313Ssos &mc68k_greg_packet[MC68K_R_SR], MC68K_GREG_SIZE); 1419313Ssos bcopy (&deprecated_registers[DEPRECATED_REGISTER_BYTE (PC_REGNUM)], 1429313Ssos &mc68k_greg_packet[MC68K_R_PC], MC68K_GREG_SIZE); 1439313Ssos 1449313Ssos net_write_registers (mc68k_greg_packet, MC68K_GREG_PLEN, PTRACE_SETREGS); 1459313Ssos 1469313Ssos /* Store floating point registers if the target has them. */ 1479313Ssos 1489313Ssos if (target_has_fp) 1499313Ssos { 1509313Ssos bcopy (&deprecated_registers[DEPRECATED_REGISTER_BYTE (FP0_REGNUM)], 1519313Ssos &mc68k_fpreg_packet[MC68K_R_FP0], 1529313Ssos MC68K_FPREG_SIZE * 8); 1539313Ssos bcopy (&deprecated_registers[DEPRECATED_REGISTER_BYTE (FPC_REGNUM)], 1549313Ssos &mc68k_fpreg_packet[MC68K_R_FPCR], 1559313Ssos MC68K_FPREG_PLEN - (MC68K_FPREG_SIZE * 8)); 1569313Ssos 1579313Ssos net_write_registers (mc68k_fpreg_packet, MC68K_FPREG_PLEN, 1589313Ssos PTRACE_SETFPREGS); 1599313Ssos } 1609313Ssos} 1619313Ssos