Commit | Line | Data |
---|---|---|
cb1bf9dc | 1 | /* SPARC-specific portions of the RPC protocol for VxWorks. |
c906108c | 2 | |
c5aa993b | 3 | Contributed by Wind River Systems. |
c906108c | 4 | |
c5aa993b | 5 | This file is part of GDB. |
c906108c | 6 | |
c5aa993b JM |
7 | This program is free software; you can redistribute it and/or modify |
8 | it under the terms of the GNU General Public License as published by | |
9 | the Free Software Foundation; either version 2 of the License, or | |
10 | (at your option) any later version. | |
c906108c | 11 | |
c5aa993b JM |
12 | This program is distributed in the hope that it will be useful, |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | GNU General Public License for more details. | |
c906108c | 16 | |
c5aa993b JM |
17 | You should have received a copy of the GNU General Public License |
18 | along with this program; if not, write to the Free Software | |
19 | Foundation, Inc., 59 Temple Place - Suite 330, | |
20 | Boston, MA 02111-1307, USA. */ | |
c906108c | 21 | |
c906108c | 22 | #include "defs.h" |
4e052eda | 23 | #include "regcache.h" |
c906108c SS |
24 | |
25 | #include "gdb_string.h" | |
c906108c | 26 | |
cb1bf9dc | 27 | #include "sparc-tdep.h" |
c906108c | 28 | |
cb1bf9dc MK |
29 | #include "vx-share/ptrace.h" |
30 | #include "vx-share/regPacket.h" | |
c906108c | 31 | |
cb1bf9dc | 32 | #define SPARC_R_G1 (SPARC_R_G0 + SPARC_GREG_SIZE) |
c906108c | 33 | |
cb1bf9dc MK |
34 | const struct sparc_gregset vxsparc_gregset = |
35 | { | |
36 | SPARC_R_PSR, /* %psr */ | |
37 | SPARC_R_PC, /* %pc */ | |
38 | SPARC_R_NPC, /* %npc */ | |
39 | SPARC_R_Y, /* %y */ | |
40 | SPARC_R_WIM, /* %wim */ | |
41 | SPARC_R_TBR, /* %tbr */ | |
42 | SPARC_R_G1, /* %g1 */ | |
43 | SPARC_R_I0 /* %l0 */ | |
44 | }; | |
45 | ||
46 | /* Flag set if target has an FPU. */ | |
c906108c | 47 | |
cb1bf9dc | 48 | extern int target_has_fp; |
c906108c SS |
49 | |
50 | /* Generic register read/write routines in remote-vx.c. */ | |
51 | ||
52 | extern void net_read_registers (); | |
53 | extern void net_write_registers (); | |
54 | ||
cb1bf9dc MK |
55 | /* Read a register or registers from the VxWorks target. REGNUM is |
56 | the register to read, or -1 for all; currently, it is ignored. | |
57 | FIXME: Look at REGNUM to improve efficiency. */ | |
c906108c SS |
58 | |
59 | void | |
cb1bf9dc | 60 | vx_read_register (int regnum) |
c906108c | 61 | { |
cb1bf9dc MK |
62 | struct regcache *regcache = current_regcache; |
63 | char gregs[SPARC_GREG_PLEN]; | |
64 | char fpregs[SPARC_FPREG_PLEN]; | |
c906108c SS |
65 | CORE_ADDR sp; |
66 | ||
cb1bf9dc MK |
67 | /* Get the general-purpose registers. */ |
68 | net_read_registers (gregs, SPARC_GREG_PLEN, PTRACE_GETREGS); | |
69 | sparc32_supply_gregset (&vxsparc_gregset, regcache, -1, gregs); | |
c906108c | 70 | |
cb1bf9dc MK |
71 | /* If the target has floating-point registers, fetch them. |
72 | Otherwise, zero the floating-point register values in GDB's | |
73 | register cache for good measure, even though we might not need | |
74 | to. */ | |
c906108c | 75 | if (target_has_fp) |
cb1bf9dc | 76 | net_read_registers (fpregs, SPARC_FPREG_PLEN, PTRACE_GETFPREGS); |
c906108c | 77 | else |
cb1bf9dc MK |
78 | memset (fpregs, 0, SPARC_FPREG_PLEN); |
79 | sparc32_supply_fpregset (regcache, -1, fpregs); | |
c906108c SS |
80 | } |
81 | ||
cb1bf9dc MK |
82 | /* Store a register or registers into the VxWorks target. REGNUM is |
83 | the register to store, or -1 for all; currently, it is ignored. | |
84 | FIXME: Look at REGNUM to improve efficiency. */ | |
c906108c SS |
85 | |
86 | void | |
cb1bf9dc | 87 | vx_write_register (int regnum) |
c906108c | 88 | { |
cb1bf9dc MK |
89 | struct regcache *regcache = current_regcache; |
90 | char gregs[SPARC_GREG_PLEN]; | |
91 | char fpregs[SPARC_FPREG_PLEN]; | |
92 | int gregs_p = 1; | |
93 | int fpregs_p = 1; | |
c906108c SS |
94 | CORE_ADDR sp; |
95 | ||
cb1bf9dc | 96 | if (regnum != -1) |
c906108c | 97 | { |
cb1bf9dc MK |
98 | if ((SPARC_G0_REGNUM <= regnum && regnum <= SPARC_I7_REGNUM) |
99 | || (SPARC32_Y_REGNUM <= regnum && regnum <= SPARC32_NPC_REGNUM)) | |
100 | fpregs_p = 0; | |
c906108c | 101 | else |
cb1bf9dc | 102 | gregs_p = 0; |
c906108c | 103 | } |
c906108c | 104 | |
cb1bf9dc MK |
105 | /* Store the general-purpose registers. */ |
106 | if (gregs_p) | |
107 | { | |
108 | sparc32_collect_gregset (&vxsparc_gregset, regcache, -1, gregs); | |
109 | net_write_registers (gregs, SPARC_GREG_PLEN, PTRACE_SETREGS); | |
c906108c | 110 | |
cb1bf9dc MK |
111 | /* Deal with the stack regs. */ |
112 | if (regnum == -1 || regnum == SPARC_SP_REGNUM | |
113 | || (regnum >= SPARC_L0_REGNUM && regnum <= SPARC_I7_REGNUM)) | |
c5aa993b | 114 | { |
cb1bf9dc MK |
115 | ULONGEST sp; |
116 | ||
117 | regcache_cooked_read_unsigned (regcache, SPARC_SP_REGNUM, &sp); | |
118 | sparc_collect_rwindow (regcache, sp, regnum); | |
c906108c SS |
119 | } |
120 | } | |
121 | ||
cb1bf9dc MK |
122 | /* Store the floating-point registers if the target has them. */ |
123 | if (fpregs_p && target_has_fp) | |
c906108c | 124 | { |
cb1bf9dc MK |
125 | sparc32_collect_fpregset (regcache, -1, fpregs); |
126 | net_write_registers (fpregs, SPARC_FPREG_PLEN, PTRACE_SETFPREGS); | |
c906108c SS |
127 | } |
128 | } |