1 /* Target machine description for generic Motorola 88000, for GDB.
2 Copyright 1986, 1987, 1988, 1989, 1990, 1991, 1993
3 Free Software Foundation, Inc.
5 This file is part of GDB.
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.
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.
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., 675 Mass Ave, Cambridge, MA 02139, USA. */
21 #include "ieee-float.h"
23 /* g++ support is not yet included. */
25 /* Define the bit, byte, and word ordering of the machine. */
26 #define TARGET_BYTE_ORDER BIG_ENDIAN
28 /* We cache information about saved registers in the frame structure,
29 to save us from having to re-scan function prologues every time
30 a register in a non-current frame is accessed. */
32 #define EXTRA_FRAME_INFO \
33 struct frame_saved_regs *fsr; \
34 CORE_ADDR locals_pointer; \
35 CORE_ADDR args_pointer;
37 /* Zero the frame_saved_regs pointer when the frame is initialized,
38 so that FRAME_FIND_SAVED_REGS () will know to allocate and
39 initialize a frame_saved_regs struct the first time it is called.
40 Set the arg_pointer to -1, which is not valid; 0 and other values
41 indicate real, cached values. */
43 #define INIT_EXTRA_FRAME_INFO(fromleaf, fi) \
44 init_extra_frame_info (fromleaf, fi)
45 extern void init_extra_frame_info ();
49 /* Offset from address of function to start of its code.
50 Zero on most machines. */
52 #define FUNCTION_START_OFFSET 0
54 /* Advance PC across any function entry prologue instructions
55 to reach some "real" code. */
57 #define SKIP_PROLOGUE(frompc) \
58 { (frompc) = skip_prologue (frompc); }
59 extern CORE_ADDR
skip_prologue ();
61 /* The m88k kernel aligns all instructions on 4-byte boundaries. The
62 kernel also uses the least significant two bits for its own hocus
63 pocus. When gdb receives an address from the kernel, it needs to
64 preserve those right-most two bits, but gdb also needs to be careful
65 to realize that those two bits are not really a part of the address
66 of an instruction. Shrug. */
68 #define ADDR_BITS_REMOVE(addr) ((addr) & ~3)
69 #define ADDR_BITS_SET(addr) (((addr) | 0x00000002) - 4)
71 /* Immediately after a function call, return the saved pc.
72 Can't always go through the frames for this because on some machines
73 the new frame is not set up until the new function executes
76 #define SAVED_PC_AFTER_CALL(frame) \
77 (ADDR_BITS_REMOVE (read_register (SRP_REGNUM)))
79 /* Stack grows downward. */
83 /* Sequence of bytes for breakpoint instruction. */
85 /* instruction 0xF000D1FF is 'tb0 0,r0,511'
86 If Bit bit 0 of r0 is clear (always true),
87 initiate exception processing (trap).
89 #define BREAKPOINT {0xF0, 0x00, 0xD1, 0xFF}
91 /* Amount PC must be decremented by after a breakpoint.
92 This is often the number of bytes in BREAKPOINT
95 #define DECR_PC_AFTER_BREAK 0
97 /* Nonzero if instruction at PC is a return instruction. */
98 /* 'jmp r1' or 'jmp.n r1' is used to return from a subroutine. */
100 #define ABOUT_TO_RETURN(pc) (read_memory_integer (pc, 2) == 0xF800)
102 /* This is taken care of in print_floating [IEEE_FLOAT]. */
104 #define INVALID_FLOAT(p,len) 0
106 /* Say how long (ordinary) registers are. */
108 #define REGISTER_TYPE long
110 /* Number of machine registers */
114 #define NUM_REGS (GP_REGS + FP_REGS)
116 /* Initializer for an array of names of registers.
117 There should be NUM_REGS strings in this initializer. */
119 #define REGISTER_NAMES {\
218 /* Register numbers of various important registers.
219 Note that some of these values are "real" register numbers,
220 and correspond to the general registers of the machine,
221 and some are "phony" register numbers which are too large
222 to be actual register numbers as far as the user is concerned
223 but do serve to get the desired values when passed to read_register. */
225 #define R0_REGNUM 0 /* Contains the constant zero */
226 #define SRP_REGNUM 1 /* Contains subroutine return pointer */
227 #define RV_REGNUM 2 /* Contains simple return values */
228 #define SRA_REGNUM 12 /* Contains address of struct return values */
229 #define SP_REGNUM 31 /* Contains address of top of stack */
231 /* Instruction pointer notes...
235 * cr04 = sxip. On exception, contains the excepting pc (probably).
238 * cr05 = snip. On exception, contains the NPC (next pc). On rte,
239 pc is loaded from here.
241 * cr06 = sfip. On exception, contains the NNPC (next next pc). On
242 rte, the NPC is loaded from here.
244 * lower two bits of each are flag bits. Bit 1 is V means address
245 is valid. If address is not valid, bit 0 is ignored. Otherwise,
246 bit 0 is E and asks for an exception to be taken if this
247 instruction is executed.
251 * cr04 = exip. On exception, contains the address of the excepting
252 pc (always). On rte, pc is loaded from here. Bit 0, aka the D
253 bit, is a flag saying that the offending instruction was in a
254 branch delay slot. If set, then cr05 contains the NPC.
256 * cr05 = enip. On exception, if the instruction pointed to by cr04
257 was in a delay slot as indicated by the bit 0 of cr04, aka the D
258 bit, the cr05 contains the NPC. Otherwise ignored.
262 #define SXIP_REGNUM 35 /* On m88100, Contains Shadow Execute
263 Instruction Pointer. */
264 #define SNIP_REGNUM 36 /* On m88100, Contains Shadow Next
265 Instruction Pointer. */
266 #define SFIP_REGNUM 37 /* On m88100, Contains Shadow Fetched
267 Intruction pointer. */
269 #define EXIP_REGNUM 35 /* On m88110, Contains Exception
270 Executing Instruction Pointer. */
271 #define ENIP_REGNUM 36 /* On m88110, Contains the Exception
272 Next Instruction Pointer. */
274 #define PC_REGNUM SXIP_REGNUM /* Program Counter */
275 #define NPC_REGNUM SNIP_REGNUM /* Next Program Counter */
276 #define NNPC_REGNUM SFIP_REGNUM /* Next Next Program Counter */
278 #define PSR_REGNUM 32 /* Processor Status Register */
279 #define FPSR_REGNUM 33 /* Floating Point Status Register */
280 #define FPCR_REGNUM 34 /* Floating Point Control Register */
281 #define XFP_REGNUM 38 /* First Extended Float Register */
282 #define X0_REGNUM XFP_REGNUM /* Which also contains the constant zero */
284 /* This is rather a confusing lie. Our m88k port using a stack pointer value
285 for the frame address. Hence, the frame address and the frame pointer are
286 only indirectly related. The value of this macro is the register number
287 fetched by the machine "independent" portions of gdb when they want to know
288 about a frame address. Thus, we lie here and claim that FP_REGNUM is
290 #define FP_REGNUM SP_REGNUM /* Reg fetched to locate frame when pgm stops */
291 #define ACTUAL_FP_REGNUM 30
293 /* PSR status bit definitions. */
295 #define PSR_MODE 0x80000000
296 #define PSR_BYTE_ORDER 0x40000000
297 #define PSR_SERIAL_MODE 0x20000000
298 #define PSR_CARRY 0x10000000
299 #define PSR_SFU_DISABLE 0x000003f0
300 #define PSR_SFU1_DISABLE 0x00000008
301 #define PSR_MXM 0x00000004
302 #define PSR_IND 0x00000002
303 #define PSR_SFRZ 0x00000001
307 /* The following two comments come from the days prior to the m88110
308 port. The m88110 handles the instruction pointers differently. I
309 do not know what any m88110 kernels do as the m88110 port I'm
310 working with is for an embedded system. rich@cygnus.com
313 /* BCS requires that the SXIP_REGNUM (or PC_REGNUM) contain the
314 address of the next instr to be executed when a breakpoint occurs.
315 Because the kernel gets the next instr (SNIP_REGNUM), the instr in
316 SNIP needs to be put back into SFIP, and the instr in SXIP should
317 be shifted to SNIP */
319 /* Are you sitting down? It turns out that the 88K BCS (binary
320 compatibility standard) folks originally felt that the debugger
321 should be responsible for backing up the IPs, not the kernel (as is
322 usually done). Well, they have reversed their decision, and in
323 future releases our kernel will be handling the backing up of the
324 IPs. So, eventually, we won't need to do the SHIFT_INST_REGS
325 stuff. But, for now, since there are 88K systems out there that do
326 need the debugger to do the IP shifting, and since there will be
327 systems where the kernel does the shifting, the code is a little
328 more complex than perhaps it needs to be (we still go inside
329 SHIFT_INST_REGS, and if the shifting hasn't occurred then gdb goes
330 ahead and shifts). */
332 extern int target_is_m88110
;
333 #define SHIFT_INST_REGS() \
334 if (!target_is_m88110) \
336 CORE_ADDR pc = read_register (PC_REGNUM); \
337 CORE_ADDR npc = read_register (NPC_REGNUM); \
340 write_register (NNPC_REGNUM, npc); \
341 write_register (NPC_REGNUM, pc); \
345 /* Storing the following registers is a no-op. */
346 #define CANNOT_STORE_REGISTER(regno) (((regno) == R0_REGNUM) \
347 || ((regno) == X0_REGNUM))
349 /* Number of bytes of storage in the actual machine representation
350 for register N. On the m88k, the general purpose registers are 4
351 bytes and the 88110 extended registers are 10 bytes. */
353 #define REGISTER_RAW_SIZE(N) ((N) < XFP_REGNUM ? 4 : 10)
355 /* Total amount of space needed to store our copies of the machine's
356 register state, the array `registers'. */
358 #define REGISTER_BYTES ((GP_REGS * REGISTER_RAW_SIZE(0)) \
359 + (FP_REGS * REGISTER_RAW_SIZE(XFP_REGNUM)))
361 /* Index within `registers' of the first byte of the space for
364 #define REGISTER_BYTE(N) (((N) * REGISTER_RAW_SIZE(0)) \
365 + ((N) >= XFP_REGNUM \
366 ? (((N) - XFP_REGNUM) \
367 * REGISTER_RAW_SIZE(XFP_REGNUM)) \
370 /* Number of bytes of storage in the program's representation for
371 register N. On the m88k, all registers are 4 bytes excepting the
372 m88110 extended registers which are 8 byte doubles. */
374 #define REGISTER_VIRTUAL_SIZE(N) ((N) < XFP_REGNUM ? 4 : 8)
376 /* Largest value REGISTER_RAW_SIZE can have. */
378 #define MAX_REGISTER_RAW_SIZE (REGISTER_RAW_SIZE(XFP_REGNUM))
380 /* Largest value REGISTER_VIRTUAL_SIZE can have.
381 Are FPS1, FPS2, FPR "virtual" regisers? */
383 #define MAX_REGISTER_VIRTUAL_SIZE (REGISTER_RAW_SIZE(XFP_REGNUM))
385 /* Nonzero if register N requires conversion
386 from raw format to virtual format. */
388 #define REGISTER_CONVERTIBLE(N) ((N) >= XFP_REGNUM)
390 /* Convert data from raw format for register REGNUM
391 to virtual format for register REGNUM. */
393 extern const struct ext_format ext_format_m88110
;
394 #define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,FROM,TO) \
396 if ((REGNUM) < XFP_REGNUM) \
397 memcpy ((TO), (FROM), REGISTER_RAW_SIZE (REGNUM)); \
398 else ieee_extended_to_double(&ext_format_m88110, \
399 (FROM), (double *)(TO)); \
402 /* Convert data from virtual format for register REGNUM
403 to raw format for register REGNUM. */
405 #define REGISTER_CONVERT_TO_RAW(REGNUM,FROM,TO) \
407 if ((REGNUM) < XFP_REGNUM) \
408 memcpy ((TO), (FROM), REGISTER_RAW_SIZE (REGNUM)); \
409 else double_to_ieee_extended (&ext_format_m88110, \
410 (double *)(FROM), (TO)); \
413 /* Return the GDB type object for the "standard" data type
414 of data in register N. */
416 #define REGISTER_VIRTUAL_TYPE(N) \
418 ? builtin_type_double \
419 : ((N) == PC_REGNUM || (N) == FP_REGNUM || (N) == SP_REGNUM \
420 ? lookup_pointer_type (builtin_type_void) : builtin_type_int))
422 /* The 88k call/return conventions call for "small" values to be returned
423 into consecutive registers starting from r2. */
425 #define EXTRACT_RETURN_VALUE(TYPE,REGBUF,VALBUF) \
426 memcpy ((VALBUF), &(((char *)REGBUF)[REGISTER_BYTE(RV_REGNUM)]), TYPE_LENGTH (TYPE))
428 #define EXTRACT_STRUCT_VALUE_ADDRESS(REGBUF) (*(int *)(REGBUF))
430 /* Write into appropriate registers a function return value
431 of type TYPE, given in virtual format. */
433 #define STORE_RETURN_VALUE(TYPE,VALBUF) \
434 write_register_bytes (2*REGISTER_RAW_SIZE(0), (VALBUF), TYPE_LENGTH (TYPE))
436 /* In COFF, if PCC says a parameter is a short or a char, do not
437 change it to int (it seems the convention is to change it). */
439 #define BELIEVE_PCC_PROMOTION 1
441 /* Describe the pointer in each stack frame to the previous stack frame
444 /* FRAME_CHAIN takes a frame's nominal address
445 and produces the frame's chain-pointer.
447 However, if FRAME_CHAIN_VALID returns zero,
448 it means the given frame is the outermost one and has no caller. */
450 extern CORE_ADDR
frame_chain ();
451 extern int frame_chain_valid ();
452 extern int frameless_function_invocation ();
454 #define FRAME_CHAIN(thisframe) \
455 frame_chain (thisframe)
457 #define FRAMELESS_FUNCTION_INVOCATION(frame, fromleaf) \
458 fromleaf = frameless_function_invocation (frame)
460 /* Define other aspects of the stack frame. */
462 #define FRAME_SAVED_PC(FRAME) \
463 frame_saved_pc (FRAME)
464 extern CORE_ADDR
frame_saved_pc ();
466 #define FRAME_ARGS_ADDRESS(fi) \
467 frame_args_address (fi)
468 extern CORE_ADDR
frame_args_address ();
470 #define FRAME_LOCALS_ADDRESS(fi) \
471 frame_locals_address (fi)
472 extern CORE_ADDR
frame_locals_address ();
474 /* Return number of args passed to a frame.
475 Can return -1, meaning no way to tell. */
477 #define FRAME_NUM_ARGS(numargs, fi) ((numargs) = -1)
479 /* Return number of bytes at start of arglist that are not really args. */
481 #define FRAME_ARGS_SKIP 0
483 /* Put here the code to store, into a struct frame_saved_regs,
484 the addresses of the saved registers of frame described by FRAME_INFO.
485 This includes special registers such as pc and fp saved in special
486 ways in the stack frame. sp is even more special:
487 the address we return for it IS the sp for the next frame. */
489 /* On the 88k, parameter registers get stored into the so called "homing"
490 area. This *always* happens when you compiled with GCC and use -g.
491 Also, (with GCC and -g) the saving of the parameter register values
492 always happens right within the function prologue code, so these register
493 values can generally be relied upon to be already copied into their
494 respective homing slots by the time you will normally try to look at
497 Note that homing area stack slots are always at *positive* offsets from
498 the frame pointer. Thus, the homing area stack slots for the parameter
499 registers (passed values) for a given function are actually part of the
500 frame area of the caller. This is unusual, but it should not present
501 any special problems for GDB.
503 Note also that on the 88k, we are only interested in finding the
504 registers that might have been saved in memory. This is a subset of
505 the whole set of registers because the standard calling sequence allows
506 the called routine to clobber many registers.
508 We could manage to locate values for all of the so called "preserved"
509 registers (some of which may get saved within any particular frame) but
510 that would require decoding all of the tdesc information. That would be
511 nice information for GDB to have, but it is not strictly manditory if we
512 can live without the ability to look at values within (or backup to)
516 struct frame_saved_regs
;
519 void frame_find_saved_regs
PARAMS((struct frame_info
*fi
,
520 struct frame_saved_regs
*fsr
));
522 #define FRAME_FIND_SAVED_REGS(frame_info, frame_saved_regs) \
523 frame_find_saved_regs (frame_info, &frame_saved_regs)
526 /* There is not currently a functioning way to call functions in the
529 /* But if there was this is where we'd put the call dummy. */
530 /* #define CALL_DUMMY_LOCATION AFTER_TEXT_END */
532 /* When popping a frame on the 88k (say when doing a return command), the
533 calling function only expects to have the "preserved" registers restored.
534 Thus, those are the only ones that we even try to restore here. */
536 #define POP_FRAME pop_frame ()
537 extern void pop_frame ();