home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 9 / FreshFishVol9-CD2.bin / bbs / gnu / gdb-4.14-src.lha / gdb-4.14 / gdb / remote-vx29k.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-01-17  |  5.4 KB  |  170 lines

  1. /* Am29k-dependent portions of the RPC protocol
  2.    used with a VxWorks target 
  3.  
  4. Contributed by Wind River Systems.
  5.  
  6. This file is part of GDB.
  7.  
  8. This program is free software; you can redistribute it and/or modify
  9. it under the terms of the GNU General Public License as published by
  10. the Free Software Foundation; either version 2 of the License, or
  11. (at your option) any later version.
  12.  
  13. This program is distributed in the hope that it will be useful,
  14. but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16. GNU General Public License for more details.
  17.  
  18. You should have received a copy of the GNU General Public License
  19. along with this program; if not, write to the Free Software
  20. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
  21.  
  22. #include <stdio.h>
  23. #include "defs.h"
  24.  
  25. #include "vx-share/regPacket.h"  
  26. #include "frame.h"
  27. #include "inferior.h"
  28. #include "wait.h"
  29. #include "target.h"
  30. #include "gdbcore.h"
  31. #include "command.h"
  32. #include "symtab.h"
  33. #include "symfile.h"        /* for struct complaint */
  34.  
  35. #include <string.h>
  36. #include <errno.h>
  37. #include <signal.h>
  38. #include <fcntl.h>
  39. #include <sys/types.h>
  40. #include <sys/time.h>
  41. #include <sys/socket.h>
  42.  
  43. #ifdef _AIX                     /* IBM claims "void *malloc()" not char * */
  44. #define malloc bogon_malloc
  45. #endif
  46.  
  47. #include <rpc/rpc.h>
  48. #include <sys/time.h>        /* UTek's <rpc/rpc.h> doesn't #incl this */
  49. #include <netdb.h>
  50. #include "vx-share/ptrace.h"
  51. #include "vx-share/xdr_ptrace.h"
  52. #include "vx-share/xdr_ld.h"
  53. #include "vx-share/xdr_rdb.h"
  54. #include "vx-share/dbgRpcLib.h"
  55.  
  56. /* get rid of value.h if possible */
  57. #include <value.h>
  58. #include <symtab.h>
  59.  
  60. /* Flag set if target has fpu */
  61.  
  62. extern int target_has_fp;
  63.  
  64. /* Generic register read/write routines in remote-vx.c.  */
  65.  
  66. extern void net_read_registers ();
  67. extern void net_write_registers ();
  68.  
  69. /* Read a register or registers from the VxWorks target.
  70.    REGNO is the register to read, or -1 for all; currently,
  71.    it is ignored.  FIXME look at regno to improve efficiency.  */
  72.  
  73. void
  74. vx_read_register (regno)
  75.      int regno;
  76. {
  77.   char am29k_greg_packet[AM29K_GREG_PLEN];
  78.   char am29k_fpreg_packet[AM29K_FPREG_PLEN];
  79.  
  80.   /* Get general-purpose registers.  When copying values into
  81.      registers [], don't assume that a location in registers []
  82.      is properly aligned for the target data type.  */
  83.  
  84.   net_read_registers (am29k_greg_packet, AM29K_GREG_PLEN, PTRACE_GETREGS);
  85.  
  86.   /* Now copy the register values into registers[].
  87.      Note that this code depends on the ordering of the REGNUMs
  88.      as defined in "tm-29k.h".  */
  89.  
  90.   bcopy (&am29k_greg_packet[AM29K_R_GR96],
  91.      ®isters[REGISTER_BYTE (GR96_REGNUM)], 160 * AM29K_GREG_SIZE);
  92.   bcopy (&am29k_greg_packet[AM29K_R_VAB],
  93.      ®isters[REGISTER_BYTE (VAB_REGNUM)], 15 * AM29K_GREG_SIZE);
  94.   registers[REGISTER_BYTE (INTE_REGNUM)] = am29k_greg_packet[AM29K_R_INTE];
  95.   bcopy (&am29k_greg_packet[AM29K_R_RSP],
  96.      ®isters[REGISTER_BYTE (GR1_REGNUM)], 5 * AM29K_GREG_SIZE);
  97.  
  98.   /* PAD For now, don't care about exop register */
  99.  
  100.   bzero (®isters[REGISTER_BYTE (EXO_REGNUM)], 1 * AM29K_GREG_SIZE);
  101.  
  102.   /* If the target has floating point registers, fetch them.
  103.      Otherwise, zero the floating point register values in
  104.      registers[] for good measure, even though we might not
  105.      need to.  */
  106.  
  107.   if (target_has_fp)
  108.     {
  109.       net_read_registers (am29k_fpreg_packet, AM29K_FPREG_PLEN,
  110.                           PTRACE_GETFPREGS);
  111.       registers[REGISTER_BYTE (FPE_REGNUM)] = am29k_fpreg_packet[AM29K_R_FPE];
  112.       registers[REGISTER_BYTE (FPS_REGNUM)] = am29k_fpreg_packet[AM29K_R_FPS];
  113.  
  114.       /* PAD For now, don't care about registers (?) AI0 to q */
  115.  
  116.       bzero (®isters[REGISTER_BYTE (161)], 21 * AM29K_FPREG_SIZE);
  117.     }
  118.   else
  119.     { 
  120.       bzero (®isters[REGISTER_BYTE (FPE_REGNUM)], 1 * AM29K_FPREG_SIZE);
  121.       bzero (®isters[REGISTER_BYTE (FPS_REGNUM)], 1 * AM29K_FPREG_SIZE);
  122.  
  123.       /* PAD For now, don't care about registers (?) AI0 to q */
  124.  
  125.       bzero (®isters[REGISTER_BYTE (161)], 21 * AM29K_FPREG_SIZE);
  126.     }
  127.  
  128.   /* Mark the register cache valid.  */
  129.  
  130.   registers_fetched ();
  131. }
  132.  
  133. /* Store a register or registers into the VxWorks target.
  134.    REGNO is the register to store, or -1 for all; currently,
  135.    it is ignored.  FIXME look at regno to improve efficiency.  */
  136.  
  137. void
  138. vx_write_register (regno)
  139.      int regno;
  140. {
  141.   char am29k_greg_packet[AM29K_GREG_PLEN];
  142.   char am29k_fpreg_packet[AM29K_FPREG_PLEN];
  143.  
  144.   /* Store general purpose registers.  When copying values from
  145.      registers [], don't assume that a location in registers []
  146.      is properly aligned for the target data type.  */
  147.  
  148.   bcopy (®isters[REGISTER_BYTE (GR96_REGNUM)],
  149.      &am29k_greg_packet[AM29K_R_GR96], 160 * AM29K_GREG_SIZE);
  150.   bcopy (®isters[REGISTER_BYTE (VAB_REGNUM)],
  151.      &am29k_greg_packet[AM29K_R_VAB], 15 * AM29K_GREG_SIZE);
  152.   am29k_greg_packet[AM29K_R_INTE] = registers[REGISTER_BYTE (INTE_REGNUM)];
  153.   bcopy (®isters[REGISTER_BYTE (GR1_REGNUM)],
  154.      &am29k_greg_packet[AM29K_R_RSP], 5 * AM29K_GREG_SIZE);
  155.  
  156.   net_write_registers (am29k_greg_packet, AM29K_GREG_PLEN, PTRACE_SETREGS);
  157.  
  158.   /* Store floating point registers if the target has them.  */
  159.  
  160.   if (target_has_fp)
  161.     {
  162.       am29k_fpreg_packet[AM29K_R_FPE] = registers[REGISTER_BYTE (FPE_REGNUM)];
  163.       am29k_fpreg_packet[AM29K_R_FPS] = registers[REGISTER_BYTE (FPS_REGNUM)];
  164.  
  165.       net_write_registers (am29k_fpreg_packet, AM29K_FPREG_PLEN,
  166.                            PTRACE_SETFPREGS);
  167.     }
  168. }
  169.  
  170.