1 |
578 |
markom |
/* Target machine description for generic Motorola 88000, for GDB.
|
2 |
|
|
Copyright 1986, 1987, 1988, 1989, 1990, 1991, 1993, 1994, 1996, 1998,
|
3 |
|
|
1999, 2000
|
4 |
|
|
Free Software Foundation, Inc.
|
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., 59 Temple Place - Suite 330,
|
21 |
|
|
Boston, MA 02111-1307, USA. */
|
22 |
|
|
|
23 |
|
|
#include "regcache.h"
|
24 |
|
|
|
25 |
|
|
/* g++ support is not yet included. */
|
26 |
|
|
|
27 |
|
|
/* Define the bit, byte, and word ordering of the machine. */
|
28 |
|
|
#define TARGET_BYTE_ORDER BIG_ENDIAN
|
29 |
|
|
|
30 |
|
|
/* We cache information about saved registers in the frame structure,
|
31 |
|
|
to save us from having to re-scan function prologues every time
|
32 |
|
|
a register in a non-current frame is accessed. */
|
33 |
|
|
|
34 |
|
|
#define EXTRA_FRAME_INFO \
|
35 |
|
|
struct frame_saved_regs *fsr; \
|
36 |
|
|
CORE_ADDR locals_pointer; \
|
37 |
|
|
CORE_ADDR args_pointer;
|
38 |
|
|
|
39 |
|
|
/* Zero the frame_saved_regs pointer when the frame is initialized,
|
40 |
|
|
so that FRAME_FIND_SAVED_REGS () will know to allocate and
|
41 |
|
|
initialize a frame_saved_regs struct the first time it is called.
|
42 |
|
|
Set the arg_pointer to -1, which is not valid; 0 and other values
|
43 |
|
|
indicate real, cached values. */
|
44 |
|
|
|
45 |
|
|
#define INIT_EXTRA_FRAME_INFO(fromleaf, fi) \
|
46 |
|
|
init_extra_frame_info (fromleaf, fi)
|
47 |
|
|
extern void init_extra_frame_info ();
|
48 |
|
|
|
49 |
|
|
#define IEEE_FLOAT (1)
|
50 |
|
|
|
51 |
|
|
/* Offset from address of function to start of its code.
|
52 |
|
|
Zero on most machines. */
|
53 |
|
|
|
54 |
|
|
#define FUNCTION_START_OFFSET 0
|
55 |
|
|
|
56 |
|
|
/* Advance PC across any function entry prologue instructions
|
57 |
|
|
to reach some "real" code. */
|
58 |
|
|
|
59 |
|
|
extern CORE_ADDR m88k_skip_prologue (CORE_ADDR);
|
60 |
|
|
#define SKIP_PROLOGUE(frompc) (m88k_skip_prologue (frompc))
|
61 |
|
|
|
62 |
|
|
/* The m88k kernel aligns all instructions on 4-byte boundaries. The
|
63 |
|
|
kernel also uses the least significant two bits for its own hocus
|
64 |
|
|
pocus. When gdb receives an address from the kernel, it needs to
|
65 |
|
|
preserve those right-most two bits, but gdb also needs to be careful
|
66 |
|
|
to realize that those two bits are not really a part of the address
|
67 |
|
|
of an instruction. Shrug. */
|
68 |
|
|
|
69 |
|
|
extern CORE_ADDR m88k_addr_bits_remove (CORE_ADDR);
|
70 |
|
|
#define ADDR_BITS_REMOVE(addr) m88k_addr_bits_remove (addr)
|
71 |
|
|
|
72 |
|
|
/* Immediately after a function call, return the saved pc.
|
73 |
|
|
Can't always go through the frames for this because on some machines
|
74 |
|
|
the new frame is not set up until the new function executes
|
75 |
|
|
some instructions. */
|
76 |
|
|
|
77 |
|
|
#define SAVED_PC_AFTER_CALL(frame) \
|
78 |
|
|
(ADDR_BITS_REMOVE (read_register (SRP_REGNUM)))
|
79 |
|
|
|
80 |
|
|
/* Stack grows downward. */
|
81 |
|
|
|
82 |
|
|
#define INNER_THAN(lhs,rhs) ((lhs) < (rhs))
|
83 |
|
|
|
84 |
|
|
/* Sequence of bytes for breakpoint instruction. */
|
85 |
|
|
|
86 |
|
|
/* instruction 0xF000D1FF is 'tb0 0,r0,511'
|
87 |
|
|
If Bit bit 0 of r0 is clear (always true),
|
88 |
|
|
initiate exception processing (trap).
|
89 |
|
|
*/
|
90 |
|
|
#define BREAKPOINT {0xF0, 0x00, 0xD1, 0xFF}
|
91 |
|
|
|
92 |
|
|
/* Amount PC must be decremented by after a breakpoint.
|
93 |
|
|
This is often the number of bytes in BREAKPOINT
|
94 |
|
|
but not always. */
|
95 |
|
|
|
96 |
|
|
#define DECR_PC_AFTER_BREAK 0
|
97 |
|
|
|
98 |
|
|
/* Say how long (ordinary) registers are. This is a piece of bogosity
|
99 |
|
|
used in push_word and a few other places; REGISTER_RAW_SIZE is the
|
100 |
|
|
real way to know how big a register is. */
|
101 |
|
|
|
102 |
|
|
#define REGISTER_SIZE 4
|
103 |
|
|
|
104 |
|
|
/* Number of machine registers */
|
105 |
|
|
|
106 |
|
|
#define GP_REGS (38)
|
107 |
|
|
#define FP_REGS (32)
|
108 |
|
|
#define NUM_REGS (GP_REGS + FP_REGS)
|
109 |
|
|
|
110 |
|
|
/* Initializer for an array of names of registers.
|
111 |
|
|
There should be NUM_REGS strings in this initializer. */
|
112 |
|
|
|
113 |
|
|
#define REGISTER_NAMES {\
|
114 |
|
|
"r0",\
|
115 |
|
|
"r1",\
|
116 |
|
|
"r2",\
|
117 |
|
|
"r3",\
|
118 |
|
|
"r4",\
|
119 |
|
|
"r5",\
|
120 |
|
|
"r6",\
|
121 |
|
|
"r7",\
|
122 |
|
|
"r8",\
|
123 |
|
|
"r9",\
|
124 |
|
|
"r10",\
|
125 |
|
|
"r11",\
|
126 |
|
|
"r12",\
|
127 |
|
|
"r13",\
|
128 |
|
|
"r14",\
|
129 |
|
|
"r15",\
|
130 |
|
|
"r16",\
|
131 |
|
|
"r17",\
|
132 |
|
|
"r18",\
|
133 |
|
|
"r19",\
|
134 |
|
|
"r20",\
|
135 |
|
|
"r21",\
|
136 |
|
|
"r22",\
|
137 |
|
|
"r23",\
|
138 |
|
|
"r24",\
|
139 |
|
|
"r25",\
|
140 |
|
|
"r26",\
|
141 |
|
|
"r27",\
|
142 |
|
|
"r28",\
|
143 |
|
|
"r29",\
|
144 |
|
|
"r30",\
|
145 |
|
|
"r31",\
|
146 |
|
|
"psr",\
|
147 |
|
|
"fpsr",\
|
148 |
|
|
"fpcr",\
|
149 |
|
|
"sxip",\
|
150 |
|
|
"snip",\
|
151 |
|
|
"sfip",\
|
152 |
|
|
"x0",\
|
153 |
|
|
"x1",\
|
154 |
|
|
"x2",\
|
155 |
|
|
"x3",\
|
156 |
|
|
"x4",\
|
157 |
|
|
"x5",\
|
158 |
|
|
"x6",\
|
159 |
|
|
"x7",\
|
160 |
|
|
"x8",\
|
161 |
|
|
"x9",\
|
162 |
|
|
"x10",\
|
163 |
|
|
"x11",\
|
164 |
|
|
"x12",\
|
165 |
|
|
"x13",\
|
166 |
|
|
"x14",\
|
167 |
|
|
"x15",\
|
168 |
|
|
"x16",\
|
169 |
|
|
"x17",\
|
170 |
|
|
"x18",\
|
171 |
|
|
"x19",\
|
172 |
|
|
"x20",\
|
173 |
|
|
"x21",\
|
174 |
|
|
"x22",\
|
175 |
|
|
"x23",\
|
176 |
|
|
"x24",\
|
177 |
|
|
"x25",\
|
178 |
|
|
"x26",\
|
179 |
|
|
"x27",\
|
180 |
|
|
"x28",\
|
181 |
|
|
"x29",\
|
182 |
|
|
"x30",\
|
183 |
|
|
"x31",\
|
184 |
|
|
"vbr",\
|
185 |
|
|
"dmt0",\
|
186 |
|
|
"dmd0",\
|
187 |
|
|
"dma0",\
|
188 |
|
|
"dmt1",\
|
189 |
|
|
"dmd1",\
|
190 |
|
|
"dma1",\
|
191 |
|
|
"dmt2",\
|
192 |
|
|
"dmd2",\
|
193 |
|
|
"dma2",\
|
194 |
|
|
"sr0",\
|
195 |
|
|
"sr1",\
|
196 |
|
|
"sr2",\
|
197 |
|
|
"sr3",\
|
198 |
|
|
"fpecr",\
|
199 |
|
|
"fphs1",\
|
200 |
|
|
"fpls1",\
|
201 |
|
|
"fphs2",\
|
202 |
|
|
"fpls2",\
|
203 |
|
|
"fppt",\
|
204 |
|
|
"fprh",\
|
205 |
|
|
"fprl",\
|
206 |
|
|
"fpit",\
|
207 |
|
|
"fpsr",\
|
208 |
|
|
"fpcr",\
|
209 |
|
|
}
|
210 |
|
|
|
211 |
|
|
|
212 |
|
|
/* Register numbers of various important registers.
|
213 |
|
|
Note that some of these values are "real" register numbers,
|
214 |
|
|
and correspond to the general registers of the machine,
|
215 |
|
|
and some are "phony" register numbers which are too large
|
216 |
|
|
to be actual register numbers as far as the user is concerned
|
217 |
|
|
but do serve to get the desired values when passed to read_register. */
|
218 |
|
|
|
219 |
|
|
#define R0_REGNUM 0 /* Contains the constant zero */
|
220 |
|
|
#define SRP_REGNUM 1 /* Contains subroutine return pointer */
|
221 |
|
|
#define RV_REGNUM 2 /* Contains simple return values */
|
222 |
|
|
#define SRA_REGNUM 12 /* Contains address of struct return values */
|
223 |
|
|
#define SP_REGNUM 31 /* Contains address of top of stack */
|
224 |
|
|
|
225 |
|
|
/* Instruction pointer notes...
|
226 |
|
|
|
227 |
|
|
On the m88100:
|
228 |
|
|
|
229 |
|
|
* cr04 = sxip. On exception, contains the excepting pc (probably).
|
230 |
|
|
On rte, is ignored.
|
231 |
|
|
|
232 |
|
|
* cr05 = snip. On exception, contains the NPC (next pc). On rte,
|
233 |
|
|
pc is loaded from here.
|
234 |
|
|
|
235 |
|
|
* cr06 = sfip. On exception, contains the NNPC (next next pc). On
|
236 |
|
|
rte, the NPC is loaded from here.
|
237 |
|
|
|
238 |
|
|
* lower two bits of each are flag bits. Bit 1 is V means address
|
239 |
|
|
is valid. If address is not valid, bit 0 is ignored. Otherwise,
|
240 |
|
|
bit 0 is E and asks for an exception to be taken if this
|
241 |
|
|
instruction is executed.
|
242 |
|
|
|
243 |
|
|
On the m88110:
|
244 |
|
|
|
245 |
|
|
* cr04 = exip. On exception, contains the address of the excepting
|
246 |
|
|
pc (always). On rte, pc is loaded from here. Bit 0, aka the D
|
247 |
|
|
bit, is a flag saying that the offending instruction was in a
|
248 |
|
|
branch delay slot. If set, then cr05 contains the NPC.
|
249 |
|
|
|
250 |
|
|
* cr05 = enip. On exception, if the instruction pointed to by cr04
|
251 |
|
|
was in a delay slot as indicated by the bit 0 of cr04, aka the D
|
252 |
|
|
bit, the cr05 contains the NPC. Otherwise ignored.
|
253 |
|
|
|
254 |
|
|
* cr06 is invalid */
|
255 |
|
|
|
256 |
|
|
/* Note that the Harris Unix kernels emulate the m88100's behavior on
|
257 |
|
|
the m88110. */
|
258 |
|
|
|
259 |
|
|
#define SXIP_REGNUM 35 /* On m88100, Contains Shadow Execute
|
260 |
|
|
Instruction Pointer. */
|
261 |
|
|
#define SNIP_REGNUM 36 /* On m88100, Contains Shadow Next
|
262 |
|
|
Instruction Pointer. */
|
263 |
|
|
#define SFIP_REGNUM 37 /* On m88100, Contains Shadow Fetched
|
264 |
|
|
Intruction pointer. */
|
265 |
|
|
|
266 |
|
|
#define EXIP_REGNUM 35 /* On m88110, Contains Exception
|
267 |
|
|
Executing Instruction Pointer. */
|
268 |
|
|
#define ENIP_REGNUM 36 /* On m88110, Contains the Exception
|
269 |
|
|
Next Instruction Pointer. */
|
270 |
|
|
|
271 |
|
|
#define PC_REGNUM SXIP_REGNUM /* Program Counter */
|
272 |
|
|
#define NPC_REGNUM SNIP_REGNUM /* Next Program Counter */
|
273 |
|
|
#define NNPC_REGNUM SFIP_REGNUM /* Next Next Program Counter */
|
274 |
|
|
|
275 |
|
|
#define PSR_REGNUM 32 /* Processor Status Register */
|
276 |
|
|
#define FPSR_REGNUM 33 /* Floating Point Status Register */
|
277 |
|
|
#define FPCR_REGNUM 34 /* Floating Point Control Register */
|
278 |
|
|
#define XFP_REGNUM 38 /* First Extended Float Register */
|
279 |
|
|
#define X0_REGNUM XFP_REGNUM /* Which also contains the constant zero */
|
280 |
|
|
|
281 |
|
|
/* This is rather a confusing lie. Our m88k port using a stack pointer value
|
282 |
|
|
for the frame address. Hence, the frame address and the frame pointer are
|
283 |
|
|
only indirectly related. The value of this macro is the register number
|
284 |
|
|
fetched by the machine "independent" portions of gdb when they want to know
|
285 |
|
|
about a frame address. Thus, we lie here and claim that FP_REGNUM is
|
286 |
|
|
SP_REGNUM. */
|
287 |
|
|
#define FP_REGNUM SP_REGNUM /* Reg fetched to locate frame when pgm stops */
|
288 |
|
|
#define ACTUAL_FP_REGNUM 30
|
289 |
|
|
|
290 |
|
|
/* PSR status bit definitions. */
|
291 |
|
|
|
292 |
|
|
#define PSR_MODE 0x80000000
|
293 |
|
|
#define PSR_BYTE_ORDER 0x40000000
|
294 |
|
|
#define PSR_SERIAL_MODE 0x20000000
|
295 |
|
|
#define PSR_CARRY 0x10000000
|
296 |
|
|
#define PSR_SFU_DISABLE 0x000003f0
|
297 |
|
|
#define PSR_SFU1_DISABLE 0x00000008
|
298 |
|
|
#define PSR_MXM 0x00000004
|
299 |
|
|
#define PSR_IND 0x00000002
|
300 |
|
|
#define PSR_SFRZ 0x00000001
|
301 |
|
|
|
302 |
|
|
|
303 |
|
|
|
304 |
|
|
/* The following two comments come from the days prior to the m88110
|
305 |
|
|
port. The m88110 handles the instruction pointers differently. I
|
306 |
|
|
do not know what any m88110 kernels do as the m88110 port I'm
|
307 |
|
|
working with is for an embedded system. rich@cygnus.com
|
308 |
|
|
13-sept-93. */
|
309 |
|
|
|
310 |
|
|
/* BCS requires that the SXIP_REGNUM (or PC_REGNUM) contain the
|
311 |
|
|
address of the next instr to be executed when a breakpoint occurs.
|
312 |
|
|
Because the kernel gets the next instr (SNIP_REGNUM), the instr in
|
313 |
|
|
SNIP needs to be put back into SFIP, and the instr in SXIP should
|
314 |
|
|
be shifted to SNIP */
|
315 |
|
|
|
316 |
|
|
/* Are you sitting down? It turns out that the 88K BCS (binary
|
317 |
|
|
compatibility standard) folks originally felt that the debugger
|
318 |
|
|
should be responsible for backing up the IPs, not the kernel (as is
|
319 |
|
|
usually done). Well, they have reversed their decision, and in
|
320 |
|
|
future releases our kernel will be handling the backing up of the
|
321 |
|
|
IPs. So, eventually, we won't need to do the SHIFT_INST_REGS
|
322 |
|
|
stuff. But, for now, since there are 88K systems out there that do
|
323 |
|
|
need the debugger to do the IP shifting, and since there will be
|
324 |
|
|
systems where the kernel does the shifting, the code is a little
|
325 |
|
|
more complex than perhaps it needs to be (we still go inside
|
326 |
|
|
SHIFT_INST_REGS, and if the shifting hasn't occurred then gdb goes
|
327 |
|
|
ahead and shifts). */
|
328 |
|
|
|
329 |
|
|
extern int target_is_m88110;
|
330 |
|
|
#define SHIFT_INST_REGS() \
|
331 |
|
|
if (!target_is_m88110) \
|
332 |
|
|
{ \
|
333 |
|
|
CORE_ADDR pc = read_register (PC_REGNUM); \
|
334 |
|
|
CORE_ADDR npc = read_register (NPC_REGNUM); \
|
335 |
|
|
if (pc != npc) \
|
336 |
|
|
{ \
|
337 |
|
|
write_register (NNPC_REGNUM, npc); \
|
338 |
|
|
write_register (NPC_REGNUM, pc); \
|
339 |
|
|
} \
|
340 |
|
|
}
|
341 |
|
|
|
342 |
|
|
/* Storing the following registers is a no-op. */
|
343 |
|
|
#define CANNOT_STORE_REGISTER(regno) (((regno) == R0_REGNUM) \
|
344 |
|
|
|| ((regno) == X0_REGNUM))
|
345 |
|
|
|
346 |
|
|
/* Number of bytes of storage in the actual machine representation
|
347 |
|
|
for register N. On the m88k, the general purpose registers are 4
|
348 |
|
|
bytes and the 88110 extended registers are 10 bytes. */
|
349 |
|
|
|
350 |
|
|
#define REGISTER_RAW_SIZE(N) ((N) < XFP_REGNUM ? 4 : 10)
|
351 |
|
|
|
352 |
|
|
/* Total amount of space needed to store our copies of the machine's
|
353 |
|
|
register state, the array `registers'. */
|
354 |
|
|
|
355 |
|
|
#define REGISTER_BYTES ((GP_REGS * REGISTER_RAW_SIZE(0)) \
|
356 |
|
|
+ (FP_REGS * REGISTER_RAW_SIZE(XFP_REGNUM)))
|
357 |
|
|
|
358 |
|
|
/* Index within `registers' of the first byte of the space for
|
359 |
|
|
register N. */
|
360 |
|
|
|
361 |
|
|
#define REGISTER_BYTE(N) (((N) * REGISTER_RAW_SIZE(0)) \
|
362 |
|
|
+ ((N) >= XFP_REGNUM \
|
363 |
|
|
? (((N) - XFP_REGNUM) \
|
364 |
|
|
* REGISTER_RAW_SIZE(XFP_REGNUM)) \
|
365 |
|
|
: 0))
|
366 |
|
|
|
367 |
|
|
/* Number of bytes of storage in the program's representation for
|
368 |
|
|
register N. On the m88k, all registers are 4 bytes excepting the
|
369 |
|
|
m88110 extended registers which are 8 byte doubles. */
|
370 |
|
|
|
371 |
|
|
#define REGISTER_VIRTUAL_SIZE(N) ((N) < XFP_REGNUM ? 4 : 8)
|
372 |
|
|
|
373 |
|
|
/* Largest value REGISTER_RAW_SIZE can have. */
|
374 |
|
|
|
375 |
|
|
#define MAX_REGISTER_RAW_SIZE (REGISTER_RAW_SIZE(XFP_REGNUM))
|
376 |
|
|
|
377 |
|
|
/* Largest value REGISTER_VIRTUAL_SIZE can have.
|
378 |
|
|
Are FPS1, FPS2, FPR "virtual" regisers? */
|
379 |
|
|
|
380 |
|
|
#define MAX_REGISTER_VIRTUAL_SIZE (REGISTER_RAW_SIZE(XFP_REGNUM))
|
381 |
|
|
|
382 |
|
|
/* Nonzero if register N requires conversion
|
383 |
|
|
from raw format to virtual format. */
|
384 |
|
|
|
385 |
|
|
#define REGISTER_CONVERTIBLE(N) ((N) >= XFP_REGNUM)
|
386 |
|
|
|
387 |
|
|
#include "floatformat.h"
|
388 |
|
|
|
389 |
|
|
/* Convert data from raw format for register REGNUM in buffer FROM
|
390 |
|
|
to virtual format with type TYPE in buffer TO. */
|
391 |
|
|
|
392 |
|
|
#define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,TYPE,FROM,TO) \
|
393 |
|
|
{ \
|
394 |
|
|
double val; \
|
395 |
|
|
floatformat_to_double (&floatformat_m88110_ext, (FROM), &val); \
|
396 |
|
|
store_floating ((TO), TYPE_LENGTH (TYPE), val); \
|
397 |
|
|
}
|
398 |
|
|
|
399 |
|
|
/* Convert data from virtual format with type TYPE in buffer FROM
|
400 |
|
|
to raw format for register REGNUM in buffer TO. */
|
401 |
|
|
|
402 |
|
|
#define REGISTER_CONVERT_TO_RAW(TYPE,REGNUM,FROM,TO) \
|
403 |
|
|
{ \
|
404 |
|
|
double val = extract_floating ((FROM), TYPE_LENGTH (TYPE)); \
|
405 |
|
|
floatformat_from_double (&floatformat_m88110_ext, &val, (TO)); \
|
406 |
|
|
}
|
407 |
|
|
|
408 |
|
|
/* Return the GDB type object for the "standard" data type
|
409 |
|
|
of data in register N. */
|
410 |
|
|
|
411 |
|
|
#define REGISTER_VIRTUAL_TYPE(N) \
|
412 |
|
|
((N) >= XFP_REGNUM \
|
413 |
|
|
? builtin_type_double \
|
414 |
|
|
: ((N) == PC_REGNUM || (N) == FP_REGNUM || (N) == SP_REGNUM \
|
415 |
|
|
? lookup_pointer_type (builtin_type_void) : builtin_type_int))
|
416 |
|
|
|
417 |
|
|
/* The 88k call/return conventions call for "small" values to be returned
|
418 |
|
|
into consecutive registers starting from r2. */
|
419 |
|
|
|
420 |
|
|
#define EXTRACT_RETURN_VALUE(TYPE,REGBUF,VALBUF) \
|
421 |
|
|
memcpy ((VALBUF), &(((char *)REGBUF)[REGISTER_BYTE(RV_REGNUM)]), TYPE_LENGTH (TYPE))
|
422 |
|
|
|
423 |
|
|
#define EXTRACT_STRUCT_VALUE_ADDRESS(REGBUF) (*(int *)(REGBUF))
|
424 |
|
|
|
425 |
|
|
/* Write into appropriate registers a function return value
|
426 |
|
|
of type TYPE, given in virtual format. */
|
427 |
|
|
|
428 |
|
|
#define STORE_RETURN_VALUE(TYPE,VALBUF) \
|
429 |
|
|
write_register_bytes (2*REGISTER_RAW_SIZE(0), (VALBUF), TYPE_LENGTH (TYPE))
|
430 |
|
|
|
431 |
|
|
/* In COFF, if PCC says a parameter is a short or a char, do not
|
432 |
|
|
change it to int (it seems the convention is to change it). */
|
433 |
|
|
|
434 |
|
|
#define BELIEVE_PCC_PROMOTION 1
|
435 |
|
|
|
436 |
|
|
/* Describe the pointer in each stack frame to the previous stack frame
|
437 |
|
|
(its caller). */
|
438 |
|
|
|
439 |
|
|
/* FRAME_CHAIN takes a frame's nominal address
|
440 |
|
|
and produces the frame's chain-pointer.
|
441 |
|
|
|
442 |
|
|
However, if FRAME_CHAIN_VALID returns zero,
|
443 |
|
|
it means the given frame is the outermost one and has no caller. */
|
444 |
|
|
|
445 |
|
|
extern CORE_ADDR frame_chain ();
|
446 |
|
|
extern int frame_chain_valid ();
|
447 |
|
|
extern int frameless_function_invocation ();
|
448 |
|
|
|
449 |
|
|
#define FRAME_CHAIN(thisframe) \
|
450 |
|
|
frame_chain (thisframe)
|
451 |
|
|
|
452 |
|
|
#define FRAMELESS_FUNCTION_INVOCATION(frame) \
|
453 |
|
|
(frameless_function_invocation (frame))
|
454 |
|
|
|
455 |
|
|
/* Define other aspects of the stack frame. */
|
456 |
|
|
|
457 |
|
|
#define FRAME_SAVED_PC(FRAME) \
|
458 |
|
|
frame_saved_pc (FRAME)
|
459 |
|
|
extern CORE_ADDR frame_saved_pc ();
|
460 |
|
|
|
461 |
|
|
#define FRAME_ARGS_ADDRESS(fi) \
|
462 |
|
|
frame_args_address (fi)
|
463 |
|
|
extern CORE_ADDR frame_args_address ();
|
464 |
|
|
|
465 |
|
|
#define FRAME_LOCALS_ADDRESS(fi) \
|
466 |
|
|
frame_locals_address (fi)
|
467 |
|
|
extern CORE_ADDR frame_locals_address ();
|
468 |
|
|
|
469 |
|
|
/* Return number of args passed to a frame.
|
470 |
|
|
Can return -1, meaning no way to tell. */
|
471 |
|
|
|
472 |
|
|
#define FRAME_NUM_ARGS(fi) (-1)
|
473 |
|
|
|
474 |
|
|
/* Return number of bytes at start of arglist that are not really args. */
|
475 |
|
|
|
476 |
|
|
#define FRAME_ARGS_SKIP 0
|
477 |
|
|
|
478 |
|
|
/* Put here the code to store, into a struct frame_saved_regs,
|
479 |
|
|
the addresses of the saved registers of frame described by FRAME_INFO.
|
480 |
|
|
This includes special registers such as pc and fp saved in special
|
481 |
|
|
ways in the stack frame. sp is even more special:
|
482 |
|
|
the address we return for it IS the sp for the next frame. */
|
483 |
|
|
|
484 |
|
|
/* On the 88k, parameter registers get stored into the so called "homing"
|
485 |
|
|
area. This *always* happens when you compiled with GCC and use -g.
|
486 |
|
|
Also, (with GCC and -g) the saving of the parameter register values
|
487 |
|
|
always happens right within the function prologue code, so these register
|
488 |
|
|
values can generally be relied upon to be already copied into their
|
489 |
|
|
respective homing slots by the time you will normally try to look at
|
490 |
|
|
them (we hope).
|
491 |
|
|
|
492 |
|
|
Note that homing area stack slots are always at *positive* offsets from
|
493 |
|
|
the frame pointer. Thus, the homing area stack slots for the parameter
|
494 |
|
|
registers (passed values) for a given function are actually part of the
|
495 |
|
|
frame area of the caller. This is unusual, but it should not present
|
496 |
|
|
any special problems for GDB.
|
497 |
|
|
|
498 |
|
|
Note also that on the 88k, we are only interested in finding the
|
499 |
|
|
registers that might have been saved in memory. This is a subset of
|
500 |
|
|
the whole set of registers because the standard calling sequence allows
|
501 |
|
|
the called routine to clobber many registers.
|
502 |
|
|
|
503 |
|
|
We could manage to locate values for all of the so called "preserved"
|
504 |
|
|
registers (some of which may get saved within any particular frame) but
|
505 |
|
|
that would require decoding all of the tdesc information. That would be
|
506 |
|
|
nice information for GDB to have, but it is not strictly manditory if we
|
507 |
|
|
can live without the ability to look at values within (or backup to)
|
508 |
|
|
previous frames.
|
509 |
|
|
*/
|
510 |
|
|
|
511 |
|
|
struct frame_saved_regs;
|
512 |
|
|
struct frame_info;
|
513 |
|
|
|
514 |
|
|
void frame_find_saved_regs (struct frame_info *fi,
|
515 |
|
|
struct frame_saved_regs *fsr);
|
516 |
|
|
|
517 |
|
|
#define FRAME_FIND_SAVED_REGS(frame_info, frame_saved_regs) \
|
518 |
|
|
frame_find_saved_regs (frame_info, &frame_saved_regs)
|
519 |
|
|
|
520 |
|
|
|
521 |
|
|
#define POP_FRAME pop_frame ()
|
522 |
|
|
extern void pop_frame ();
|
523 |
|
|
|
524 |
|
|
/* Call function stuff contributed by Kevin Buettner of Motorola. */
|
525 |
|
|
|
526 |
|
|
#define CALL_DUMMY_LOCATION AFTER_TEXT_END
|
527 |
|
|
|
528 |
|
|
extern void m88k_push_dummy_frame ();
|
529 |
|
|
#define PUSH_DUMMY_FRAME m88k_push_dummy_frame()
|
530 |
|
|
|
531 |
|
|
#define CALL_DUMMY { \
|
532 |
|
|
0x67ff00c0, /* 0: subu #sp,#sp,0xc0 */ \
|
533 |
|
|
0x243f0004, /* 4: st #r1,#sp,0x4 */ \
|
534 |
|
|
0x245f0008, /* 8: st #r2,#sp,0x8 */ \
|
535 |
|
|
0x247f000c, /* c: st #r3,#sp,0xc */ \
|
536 |
|
|
0x249f0010, /* 10: st #r4,#sp,0x10 */ \
|
537 |
|
|
0x24bf0014, /* 14: st #r5,#sp,0x14 */ \
|
538 |
|
|
0x24df0018, /* 18: st #r6,#sp,0x18 */ \
|
539 |
|
|
0x24ff001c, /* 1c: st #r7,#sp,0x1c */ \
|
540 |
|
|
0x251f0020, /* 20: st #r8,#sp,0x20 */ \
|
541 |
|
|
0x253f0024, /* 24: st #r9,#sp,0x24 */ \
|
542 |
|
|
0x255f0028, /* 28: st #r10,#sp,0x28 */ \
|
543 |
|
|
0x257f002c, /* 2c: st #r11,#sp,0x2c */ \
|
544 |
|
|
0x259f0030, /* 30: st #r12,#sp,0x30 */ \
|
545 |
|
|
0x25bf0034, /* 34: st #r13,#sp,0x34 */ \
|
546 |
|
|
0x25df0038, /* 38: st #r14,#sp,0x38 */ \
|
547 |
|
|
0x25ff003c, /* 3c: st #r15,#sp,0x3c */ \
|
548 |
|
|
0x261f0040, /* 40: st #r16,#sp,0x40 */ \
|
549 |
|
|
0x263f0044, /* 44: st #r17,#sp,0x44 */ \
|
550 |
|
|
0x265f0048, /* 48: st #r18,#sp,0x48 */ \
|
551 |
|
|
0x267f004c, /* 4c: st #r19,#sp,0x4c */ \
|
552 |
|
|
0x269f0050, /* 50: st #r20,#sp,0x50 */ \
|
553 |
|
|
0x26bf0054, /* 54: st #r21,#sp,0x54 */ \
|
554 |
|
|
0x26df0058, /* 58: st #r22,#sp,0x58 */ \
|
555 |
|
|
0x26ff005c, /* 5c: st #r23,#sp,0x5c */ \
|
556 |
|
|
0x271f0060, /* 60: st #r24,#sp,0x60 */ \
|
557 |
|
|
0x273f0064, /* 64: st #r25,#sp,0x64 */ \
|
558 |
|
|
0x275f0068, /* 68: st #r26,#sp,0x68 */ \
|
559 |
|
|
0x277f006c, /* 6c: st #r27,#sp,0x6c */ \
|
560 |
|
|
0x279f0070, /* 70: st #r28,#sp,0x70 */ \
|
561 |
|
|
0x27bf0074, /* 74: st #r29,#sp,0x74 */ \
|
562 |
|
|
0x27df0078, /* 78: st #r30,#sp,0x78 */ \
|
563 |
|
|
0x63df0000, /* 7c: addu #r30,#sp,0x0 */ \
|
564 |
|
|
0x145f0000, /* 80: ld #r2,#sp,0x0 */ \
|
565 |
|
|
0x147f0004, /* 84: ld #r3,#sp,0x4 */ \
|
566 |
|
|
0x149f0008, /* 88: ld #r4,#sp,0x8 */ \
|
567 |
|
|
0x14bf000c, /* 8c: ld #r5,#sp,0xc */ \
|
568 |
|
|
0x14df0010, /* 90: ld #r6,#sp,0x10 */ \
|
569 |
|
|
0x14ff0014, /* 94: ld #r7,#sp,0x14 */ \
|
570 |
|
|
0x151f0018, /* 98: ld #r8,#sp,0x18 */ \
|
571 |
|
|
0x153f001c, /* 9c: ld #r9,#sp,0x1c */ \
|
572 |
|
|
0x5c200000, /* a0: or.u #r1,#r0,0x0 */ \
|
573 |
|
|
0x58210000, /* a4: or #r1,#r1,0x0 */ \
|
574 |
|
|
0xf400c801, /* a8: jsr #r1 */ \
|
575 |
|
|
0xf000d1ff /* ac: tb0 0x0,#r0,0x1ff */ \
|
576 |
|
|
}
|
577 |
|
|
|
578 |
|
|
#define CALL_DUMMY_START_OFFSET 0x80
|
579 |
|
|
#define CALL_DUMMY_LENGTH 0xb0
|
580 |
|
|
|
581 |
|
|
/* FIXME: byteswapping. */
|
582 |
|
|
#define FIX_CALL_DUMMY(dummy, pc, fun, nargs, args, type, gcc_p) \
|
583 |
|
|
{ \
|
584 |
|
|
*(unsigned long *)((char *) (dummy) + 0xa0) |= \
|
585 |
|
|
(((unsigned long) (fun)) >> 16); \
|
586 |
|
|
*(unsigned long *)((char *) (dummy) + 0xa4) |= \
|
587 |
|
|
(((unsigned long) (fun)) & 0xffff); \
|
588 |
|
|
}
|
589 |
|
|
|
590 |
|
|
/* Stack must be aligned on 64-bit boundaries when synthesizing
|
591 |
|
|
function calls. */
|
592 |
|
|
|
593 |
|
|
#define STACK_ALIGN(addr) (((addr) + 7) & -8)
|
594 |
|
|
|
595 |
|
|
#define STORE_STRUCT_RETURN(addr, sp) \
|
596 |
|
|
write_register (SRA_REGNUM, (addr))
|
597 |
|
|
|
598 |
|
|
#define NEED_TEXT_START_END 1
|
599 |
|
|
|
600 |
|
|
/* According to the MC88100 RISC Microprocessor User's Manual, section
|
601 |
|
|
6.4.3.1.2:
|
602 |
|
|
|
603 |
|
|
... can be made to return to a particular instruction by placing a
|
604 |
|
|
valid instruction address in the SNIP and the next sequential
|
605 |
|
|
instruction address in the SFIP (with V bits set and E bits clear).
|
606 |
|
|
The rte resumes execution at the instruction pointed to by the
|
607 |
|
|
SNIP, then the SFIP.
|
608 |
|
|
|
609 |
|
|
The E bit is the least significant bit (bit 0). The V (valid) bit is
|
610 |
|
|
bit 1. This is why we logical or 2 into the values we are writing
|
611 |
|
|
below. It turns out that SXIP plays no role when returning from an
|
612 |
|
|
exception so nothing special has to be done with it. We could even
|
613 |
|
|
(presumably) give it a totally bogus value.
|
614 |
|
|
|
615 |
|
|
-- Kevin Buettner
|
616 |
|
|
*/
|
617 |
|
|
|
618 |
|
|
#define TARGET_WRITE_PC(val, pid) { \
|
619 |
|
|
write_register_pid(SXIP_REGNUM, (long) val, pid); \
|
620 |
|
|
write_register_pid(SNIP_REGNUM, (long) val | 2, pid); \
|
621 |
|
|
write_register_pid(SFIP_REGNUM, ((long) val | 2) + 4, pid); \
|
622 |
|
|
}
|