Commit | Line | Data |
---|---|---|
386c036b MK |
1 | /* Native-dependent code for NetBSD/sparc64. |
2 | ||
3 | Copyright 2003, 2004 Free Software Foundation, Inc. | |
9ce5c36a JT |
4 | |
5 | This file is part of GDB. | |
6 | ||
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. | |
11 | ||
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. | |
16 | ||
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. */ | |
21 | ||
22 | #include "defs.h" | |
9ce5c36a | 23 | |
386c036b MK |
24 | #include "sparc64-tdep.h" |
25 | #include "sparc-nat.h" | |
9ce5c36a | 26 | |
386c036b MK |
27 | /* NetBSD is different from the other OSes that support both SPARC and |
28 | UltraSPARC in that the result of ptrace(2) depends on whether the | |
29 | traced process is 32-bit or 64-bit. */ | |
9ce5c36a | 30 | |
386c036b MK |
31 | static void |
32 | sparc64nbsd_supply_gregset (const struct sparc_gregset *gregset, | |
33 | struct regcache *regcache, | |
34 | int regnum, const void *gregs) | |
35 | { | |
36 | int sparc32 = (gdbarch_ptr_bit (current_gdbarch) == 32); | |
9ce5c36a | 37 | |
386c036b MK |
38 | if (sparc32) |
39 | sparc32_supply_gregset (&sparc32nbsd_gregset, regcache, regnum, gregs); | |
40 | else | |
41 | sparc64_supply_gregset (&sparc64nbsd_gregset, regcache, regnum, gregs); | |
42 | } | |
43 | ||
44 | static void | |
45 | sparc64nbsd_collect_gregset (const struct sparc_gregset *gregset, | |
46 | const struct regcache *regcache, | |
47 | int regnum, void *gregs) | |
48 | { | |
49 | int sparc32 = (gdbarch_ptr_bit (current_gdbarch) == 32); | |
50 | ||
51 | if (sparc32) | |
52 | sparc32_collect_gregset (&sparc32nbsd_gregset, regcache, regnum, gregs); | |
53 | else | |
54 | sparc64_collect_gregset (&sparc64nbsd_gregset, regcache, regnum, gregs); | |
55 | } | |
56 | ||
57 | static void | |
58 | sparc64nbsd_supply_fpregset (struct regcache *regcache, | |
59 | int regnum, const void *fpregs) | |
60 | { | |
61 | int sparc32 = (gdbarch_ptr_bit (current_gdbarch) == 32); | |
62 | ||
63 | if (sparc32) | |
64 | sparc32_supply_fpregset (regcache, regnum, fpregs); | |
65 | else | |
66 | sparc64_supply_fpregset (regcache, regnum, fpregs); | |
67 | } | |
68 | ||
69 | static void | |
70 | sparc64nbsd_collect_fpregset (const struct regcache *regcache, | |
71 | int regnum, void *fpregs) | |
9ce5c36a | 72 | { |
386c036b MK |
73 | int sparc32 = (gdbarch_ptr_bit (current_gdbarch) == 32); |
74 | ||
75 | if (sparc32) | |
76 | sparc32_collect_fpregset (regcache, regnum, fpregs); | |
77 | else | |
78 | sparc64_collect_fpregset (regcache, regnum, fpregs); | |
9ce5c36a JT |
79 | } |
80 | ||
386c036b MK |
81 | /* Determine whether `gregset_t' contains register REGNUM. */ |
82 | ||
9ce5c36a | 83 | static int |
386c036b | 84 | sparc64nbsd_gregset_supplies_p (int regnum) |
9ce5c36a | 85 | { |
386c036b MK |
86 | if (gdbarch_ptr_bit (current_gdbarch) == 32) |
87 | return sparc32_gregset_supplies_p (regnum); | |
88 | ||
89 | /* Integer registers. */ | |
90 | if ((regnum >= SPARC_G1_REGNUM && regnum <= SPARC_G7_REGNUM) | |
91 | || (regnum >= SPARC_O0_REGNUM && regnum <= SPARC_O7_REGNUM) | |
92 | || (regnum >= SPARC_L0_REGNUM && regnum <= SPARC_L7_REGNUM) | |
93 | || (regnum >= SPARC_I0_REGNUM && regnum <= SPARC_I7_REGNUM)) | |
94 | return 1; | |
95 | ||
96 | /* Control registers. */ | |
97 | if (regnum == SPARC64_PC_REGNUM | |
98 | || regnum == SPARC64_NPC_REGNUM | |
99 | || regnum == SPARC64_STATE_REGNUM | |
100 | || regnum == SPARC64_Y_REGNUM) | |
101 | return 1; | |
102 | ||
103 | return 0; | |
9ce5c36a JT |
104 | } |
105 | ||
386c036b MK |
106 | /* Determine whether `fpregset_t' contains register REGNUM. */ |
107 | ||
108 | static int | |
109 | sparc64nbsd_fpregset_supplies_p (int regnum) | |
9ce5c36a | 110 | { |
386c036b MK |
111 | if (gdbarch_ptr_bit (current_gdbarch) == 32) |
112 | return sparc32_fpregset_supplies_p (regnum); | |
113 | ||
114 | /* Floating-point registers. */ | |
115 | if ((regnum >= SPARC_F0_REGNUM && regnum <= SPARC_F31_REGNUM) | |
116 | || (regnum >= SPARC64_F32_REGNUM && regnum <= SPARC64_F62_REGNUM)) | |
117 | return 1; | |
118 | ||
119 | /* Control registers. */ | |
120 | if (regnum == SPARC64_FSR_REGNUM) | |
121 | return 1; | |
122 | ||
123 | return 0; | |
9ce5c36a JT |
124 | } |
125 | ||
386c036b MK |
126 | \f |
127 | /* Provide a prototype to silence -Wmissing-prototypes. */ | |
128 | void _initialize_sparcnbsd_nat (void); | |
129 | ||
9ce5c36a | 130 | void |
386c036b | 131 | _initialize_sparcnbsd_nat (void) |
9ce5c36a | 132 | { |
386c036b MK |
133 | sparc_supply_gregset = sparc64nbsd_supply_gregset; |
134 | sparc_collect_gregset = sparc64nbsd_collect_gregset; | |
135 | sparc_supply_fpregset = sparc64nbsd_supply_fpregset; | |
136 | sparc_collect_fpregset = sparc64nbsd_collect_fpregset; | |
137 | sparc_gregset_supplies_p = sparc64nbsd_gregset_supplies_p; | |
138 | sparc_fpregset_supplies_p = sparc64nbsd_fpregset_supplies_p; | |
9ce5c36a | 139 | } |