1 /* Parameters for target machine of AMD 29000, for GDB, the GNU debugger.
2 Copyright 1990, 1991 Free Software Foundation, Inc.
3 Contributed by Cygnus Support. Written by Jim Kingdon.
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 /* Parameters for an EB29K (a board which plugs into a PC and is
22 accessed through EBMON software running on the PC, which we
23 use as we'd use a remote stub (see remote-eb.c).
25 If gdb is ported to other 29k machines/systems, the
26 machine/system-specific parts should be removed from this file (a
29 /* Byte order is configurable, but this machine runs big-endian. */
30 #define TARGET_BYTE_ORDER BIG_ENDIAN
32 /* Floating point uses IEEE representations. */
35 /* Recognize our magic number. */
36 #define BADMAG(x) ((x).f_magic != 0572)
38 /* Define this if the C compiler puts an underscore at the front
39 of external names before giving them to the linker. */
41 #define NAMES_HAVE_UNDERSCORE
43 /* Offset from address of function to start of its code.
44 Zero on most machines. */
46 #define FUNCTION_START_OFFSET 0
48 /* Advance PC across any function entry prologue instructions
49 to reach some "real" code. */
51 #define SKIP_PROLOGUE(pc) \
52 { pc = skip_prologue (pc); }
53 CORE_ADDR
skip_prologue ();
55 /* Immediately after a function call, return the saved pc.
56 Can't go through the frames for this because on some machines
57 the new frame is not set up until the new function executes
60 #define SAVED_PC_AFTER_CALL(frame) (read_register (LR0_REGNUM))
62 /* I'm not sure about the exact value of this, but based on looking
63 at the stack pointer when we get to main this seems to be right.
65 This is the register stack; We call it "CONTROL" in GDB for consistency
67 #define CONTROL_END_ADDR 0x80200000
69 /* Memory stack. This is for the default register stack size, which is
70 only 0x800 bytes. Perhaps we should let the user specify stack sizes
71 (and tell EBMON with the "ZS" command). */
72 #define STACK_END_ADDR 0x801ff800
74 /* Stack grows downward. */
78 /* Stack must be aligned on 32-bit word boundaries. */
79 #define STACK_ALIGN(ADDR) (((ADDR) + 3) & ~3)
81 /* Sequence of bytes for breakpoint instruction. */
82 /* ASNEQ 0x50, gr1, gr1
83 The trap number 0x50 is chosen arbitrarily. */
84 #if TARGET_BYTE_ORDER == BIG_ENDIAN
85 #define BREAKPOINT {0x72, 0x50, 0x01, 0x01}
86 #else /* Target is little-endian. */
87 #define BREAKPOINT {0x01, 0x01, 0x50, 0x72}
88 #endif /* Target is little-endian. */
90 /* Amount PC must be decremented by after a breakpoint.
91 This is often the number of bytes in BREAKPOINT
94 #define DECR_PC_AFTER_BREAK 0
96 /* Nonzero if instruction at PC is a return instruction.
97 On the 29k, this is a "jmpi l0" instruction. */
99 #define ABOUT_TO_RETURN(pc) \
100 ((read_memory_integer (pc, 4) & 0xff0000ff) == 0xc0000080)
102 /* Return 1 if P points to an invalid floating point value. */
104 #define INVALID_FLOAT(p, len) 0 /* Just a first guess; not checked */
106 /* Say how long (ordinary) registers are. */
108 #define REGISTER_TYPE long
110 /* Allow the register declarations here to be overridden for remote
112 #if !defined (REGISTER_NAMES)
114 /* Number of machine registers */
118 /* Initializer for an array of names of registers.
119 There should be NUM_REGS strings in this initializer.
121 FIXME, add floating point registers and support here.
123 Also note that this list does not attempt to deal with kernel
124 debugging (in which the first 32 registers are gr64-gr95). */
126 #define REGISTER_NAMES \
127 {"gr96", "gr97", "gr98", "gr99", "gr100", "gr101", "gr102", "gr103", "gr104", \
128 "gr105", "gr106", "gr107", "gr108", "gr109", "gr110", "gr111", "gr112", \
129 "gr113", "gr114", "gr115", "gr116", "gr117", "gr118", "gr119", "gr120", \
130 "gr121", "gr122", "gr123", "gr124", "gr125", "gr126", "gr127", \
131 "lr0", "lr1", "lr2", "lr3", "lr4", "lr5", "lr6", "lr7", "lr8", "lr9", \
132 "lr10", "lr11", "lr12", "lr13", "lr14", "lr15", "lr16", "lr17", "lr18", \
133 "lr19", "lr20", "lr21", "lr22", "lr23", "lr24", "lr25", "lr26", "lr27", \
134 "lr28", "lr29", "lr30", "lr31", "lr32", "lr33", "lr34", "lr35", "lr36", \
135 "lr37", "lr38", "lr39", "lr40", "lr41", "lr42", "lr43", "lr44", "lr45", \
136 "lr46", "lr47", "lr48", "lr49", "lr50", "lr51", "lr52", "lr53", "lr54", \
137 "lr55", "lr56", "lr57", "lr58", "lr59", "lr60", "lr61", "lr62", "lr63", \
138 "lr64", "lr65", "lr66", "lr67", "lr68", "lr69", "lr70", "lr71", "lr72", \
139 "lr73", "lr74", "lr75", "lr76", "lr77", "lr78", "lr79", "lr80", "lr81", \
140 "lr82", "lr83", "lr84", "lr85", "lr86", "lr87", "lr88", "lr89", "lr90", \
141 "lr91", "lr92", "lr93", "lr94", "lr95", "lr96", "lr97", "lr98", "lr99", \
142 "lr100", "lr101", "lr102", "lr103", "lr104", "lr105", "lr106", "lr107", \
143 "lr108", "lr109", "lr110", "lr111", "lr112", "lr113", "lr114", "lr115", \
144 "lr116", "lr117", "lr118", "lr119", "lr120", "lr121", "lr122", "lr123", \
145 "lr124", "lr125", "lr126", "lr127", \
146 "AI0", "AI1", "AI2", "AI3", "AI4", "AI5", "AI6", "AI7", "AI8", "AI9", \
147 "AI10", "AI11", "AI12", "AI13", "AI14", "AI15", "FP", \
148 "bp", "fc", "cr", "q", \
149 "vab", "ops", "cps", "cfg", "cha", "chd", "chc", "rbp", "tmc", "tmr", \
150 "pc0", "pc1", "pc2", "mmu", "lru", "fpe", "inte", "fps", "exo", "gr1", \
151 "alu", "ipc", "ipa", "ipb" }
154 * Converts an sdb register number to an internal gdb register number.
155 * Currently under epi, gr96->0...gr127->31...lr0->32...lr127->159, or...
156 * gr64->0...gr95->31, lr0->32...lr127->159.
158 #define SDB_REG_TO_REGNUM(value) \
159 (((value) >= 96 && (value) <= 127) ? ((value) - 96) : \
160 ((value) >= 128 && (value) <= 255) ? ((value) - 128 + LR0_REGNUM) : \
164 * Provide the processor register numbers of some registers that are
165 * expected/written in instructions that might change under different
166 * register sets. Namely, gcc can compile (-mkernel-registers) so that
167 * it uses gr64-gr95 in stead of gr96-gr127.
169 #define MSP_HW_REGNUM 125 /* gr125 */
170 #define RAB_HW_REGNUM 126 /* gr126 */
172 /* Convert Processor Special register #x to REGISTER_NAMES register # */
173 #define SR_REGNUM(x) \
174 ((x) < 15 ? VAB_REGNUM + (x) \
175 : (x) >= 128 && (x) < 131 ? IPC_REGNUM + (x) - 128 \
176 : (x) == 131 ? Q_REGNUM \
177 : (x) == 132 ? ALU_REGNUM \
178 : (x) >= 133 && (x) < 136 ? BP_REGNUM + (x) - 133 \
179 : (x) >= 160 && (x) < 163 ? FPE_REGNUM + (x) - 160 \
180 : (x) == 164 ? EXO_REGNUM \
181 : (error ("Internal error in SR_REGNUM"), 0))
182 #define GR96_REGNUM 0
183 /* Define the return register separately, so it can be overridden for
184 kernel procedure calling conventions. */
185 #define RETURN_REGNUM GR96_REGNUM
186 #define GR1_REGNUM 200
187 /* This needs to be the memory stack pointer, not the register stack pointer,
188 to make call_function work right. */
189 #define SP_REGNUM MSP_REGNUM
190 #define FP_REGNUM 33 /* lr1 */
191 /* Large Return Pointer (gr123). */
192 #define LRP_REGNUM (123 - 96 + GR96_REGNUM)
193 /* Static link pointer (gr124). */
194 #define SLP_REGNUM (124 - 96 + GR96_REGNUM)
195 /* Memory Stack Pointer (gr125). */
196 #define MSP_REGNUM (125 - 96 + GR96_REGNUM)
197 /* Register allocate bound (gr126). */
198 #define RAB_REGNUM (126 - 96 + GR96_REGNUM)
199 /* Register Free Bound (gr127). */
200 #define RFB_REGNUM (127 - 96 + GR96_REGNUM)
201 /* Register Stack Pointer. */
202 #define RSP_REGNUM GR1_REGNUM
203 #define LR0_REGNUM 32
204 #define BP_REGNUM 177
205 #define FC_REGNUM 178
206 #define CR_REGNUM 179
208 #define VAB_REGNUM 181
209 #define OPS_REGNUM (VAB_REGNUM + 1)
210 #define CPS_REGNUM (VAB_REGNUM + 2)
211 #define CFG_REGNUM (VAB_REGNUM + 3)
212 #define CHA_REGNUM (VAB_REGNUM + 4)
213 #define CHD_REGNUM (VAB_REGNUM + 5)
214 #define CHC_REGNUM (VAB_REGNUM + 6)
215 #define RBP_REGNUM (VAB_REGNUM + 7)
216 #define TMC_REGNUM (VAB_REGNUM + 8)
217 #define TMR_REGNUM (VAB_REGNUM + 9)
218 #define NPC_REGNUM (VAB_REGNUM + 10) /* pc0 */
219 #define PC_REGNUM (VAB_REGNUM + 11) /* pc1 */
220 #define PC2_REGNUM (VAB_REGNUM + 12)
221 #define MMU_REGNUM (VAB_REGNUM + 13)
222 #define LRU_REGNUM (VAB_REGNUM + 14)
223 #define FPE_REGNUM (VAB_REGNUM + 15)
224 #define INTE_REGNUM (VAB_REGNUM + 16)
225 #define FPS_REGNUM (VAB_REGNUM + 17)
226 #define EXO_REGNUM (VAB_REGNUM + 18)
227 /* gr1 is defined above as 200 = VAB_REGNUM + 19 */
228 #define ALU_REGNUM (VAB_REGNUM + 20)
229 #define PS_REGNUM ALU_REGNUM
230 #define IPC_REGNUM (VAB_REGNUM + 21)
231 #define IPA_REGNUM (VAB_REGNUM + 22)
232 #define IPB_REGNUM (VAB_REGNUM + 23)
234 #endif /* !defined(REGISTER_NAMES) */
236 /* Total amount of space needed to store our copies of the machine's
237 register state, the array `registers'. */
238 #define REGISTER_BYTES (NUM_REGS * 4)
240 /* Index within `registers' of the first byte of the space for
242 #define REGISTER_BYTE(N) ((N)*4)
244 /* Number of bytes of storage in the actual machine representation
247 /* All regs are 4 bytes. */
249 #define REGISTER_RAW_SIZE(N) (4)
251 /* Number of bytes of storage in the program's representation
254 /* All regs are 4 bytes. */
256 #define REGISTER_VIRTUAL_SIZE(N) (4)
258 /* Largest value REGISTER_RAW_SIZE can have. */
260 #define MAX_REGISTER_RAW_SIZE (4)
262 /* Largest value REGISTER_VIRTUAL_SIZE can have. */
264 #define MAX_REGISTER_VIRTUAL_SIZE (4)
266 /* Nonzero if register N requires conversion
267 from raw format to virtual format. */
269 #define REGISTER_CONVERTIBLE(N) (0)
271 /* Convert data from raw format for register REGNUM
272 to virtual format for register REGNUM. */
274 #define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,FROM,TO) \
275 { bcopy ((FROM), (TO), 4); }
277 /* Convert data from virtual format for register REGNUM
278 to raw format for register REGNUM. */
280 #define REGISTER_CONVERT_TO_RAW(REGNUM,FROM,TO) \
281 { bcopy ((FROM), (TO), 4); }
283 /* Return the GDB type object for the "standard" data type
284 of data in register N. */
286 #define REGISTER_VIRTUAL_TYPE(N) \
287 (((N) == PC_REGNUM || (N) == LRP_REGNUM || (N) == SLP_REGNUM \
288 || (N) == MSP_REGNUM || (N) == RAB_REGNUM || (N) == RFB_REGNUM \
289 || (N) == GR1_REGNUM || (N) == FP_REGNUM || (N) == LR0_REGNUM \
290 || (N) == NPC_REGNUM || (N) == PC2_REGNUM) \
291 ? lookup_pointer_type (builtin_type_void) : builtin_type_int)
293 /* Store the address of the place in which to copy the structure the
294 subroutine will return. This is called from call_function. */
295 /* On the 29k the LRP points to the part of the structure beyond the first
297 #define STORE_STRUCT_RETURN(ADDR, SP) \
298 write_register (LRP_REGNUM, (ADDR) + 16 * 4);
300 /* Should call_function allocate stack space for a struct return? */
301 /* On the 29k objects over 16 words require the caller to allocate space. */
302 #define USE_STRUCT_CONVENTION(gcc_p, type) (TYPE_LENGTH (type) > 16 * 4)
304 /* Extract from an array REGBUF containing the (raw) register state
305 a function return value of type TYPE, and copy that, in virtual format,
308 #define EXTRACT_RETURN_VALUE(TYPE,REGBUF,VALBUF) \
310 int reg_length = TYPE_LENGTH (TYPE); \
311 if (reg_length > 16 * 4) \
313 reg_length = 16 * 4; \
314 read_memory (*((int *)(REGBUF) + LRP_REGNUM), (VALBUF) + 16 * 4, \
315 TYPE_LENGTH (TYPE) - 16 * 4); \
317 bcopy (((int *)(REGBUF))+RETURN_REGNUM, (VALBUF), reg_length); \
320 /* Write into appropriate registers a function return value
321 of type TYPE, given in virtual format. */
323 #define STORE_RETURN_VALUE(TYPE,VALBUF) \
325 int reg_length = TYPE_LENGTH (TYPE); \
326 if (reg_length > 16 * 4) \
328 reg_length = 16 * 4; \
329 write_memory (read_register (LRP_REGNUM), \
330 (char *)(VALBUF) + 16 * 4, \
331 TYPE_LENGTH (TYPE) - 16 * 4); \
333 write_register_bytes (REGISTER_BYTE (RETURN_REGNUM), (char *)(VALBUF), \
334 TYPE_LENGTH (TYPE)); \
337 /* The am29k user's guide documents well what the stacks look like.
338 But what isn't so clear there is how this interracts with the
339 symbols, or with GDB.
340 In the following saved_msp, saved memory stack pointer (which functions
341 as a memory frame pointer), means either
342 a register containing the memory frame pointer or, in the case of
343 functions with fixed size memory frames (i.e. those who don't use
344 alloca()), the result of the calculation msp + msize.
346 LOC_ARG, LOC_LOCAL - For GCC, these are relative to saved_msp.
347 For high C, these are relative to msp (making alloca impossible).
348 LOC_REGISTER, LOC_REGPARM - The register number is the number at the
349 time the function is running (after the prologue), or in the case
350 of LOC_REGPARM, may be a register number in the range 160-175.
352 The compilers do things like store an argument into memory, and then put out
353 a LOC_ARG for it, or put it into global registers and put out a
354 LOC_REGPARM. Thus is it important to execute the first line of
355 code (i.e. the line of the open brace, i.e. the prologue) of a function
356 before trying to print arguments or anything.
358 The following diagram attempts to depict what is going on in memory
359 (see also the _am29k user's guide_) and also how that interacts with
360 GDB frames. We arbitrarily pick fci->frame to point the same place
361 as the register stack pointer; since we set it ourself in
362 INIT_EXTRA_FRAME_INFO, and access it only through the FRAME_*
363 macros, it doesn't really matter exactly how we
364 do it. However, note that FRAME_FP is used in two ways in GDB:
365 (1) as a "magic cookie" which uniquely identifies frames (even over
366 calls to the inferior), (2) (in PC_IN_CALL_DUMMY [ON_STACK])
367 as the value of SP_REGNUM before the dummy frame was pushed. These
368 two meanings would be incompatible for the 29k if we defined
369 CALL_DUMMY_LOCATION == ON_STACK (but we don't, so don't worry about it).
370 Also note that "lr1" below, while called a frame pointer
371 in the user's guide, has only one function: To determine whether
372 registers need to be filled in the function epilogue.
377 bar: sub gr1,gr1,rsize_b
384 foo: sub gr1,gr1,rsize_f
389 loc3: < suppose the inferior stops here >
391 memory stack register stack
394 +------->|___________| | | ^
395 | | ^ | | locals_b | |
396 | | | | |____________| |
397 | | | | | | | rsize_b
398 | | | msize_b | | args_to_f | |
399 | | | | |____________| |
400 | | | | |____lr1_____| V
401 | | V | |____loc2____|<----------------+
402 | +--->|___________|<---------mfp | ^ |
403 | | | ^ | | locals_f | | |
404 | | | | msize_f | |____________| | |
405 | | | | | | | | rsize_f |
406 | | | V | | args | | |
407 | | |___________|<msp |____________| | |
408 | | |_____lr1____| V |
409 | | |___garbage__| <- gr1 <----+ |
416 | | |_________________| | |
417 | | |rsize=rsize_b | | |
418 | | |msize=msize_b | | |
419 +---|--------saved_msp | | |
420 | |frame------------------------------------|---+
422 | |_________________| |
425 +--------saved_msp | |
426 |frame------------------------------------+
430 So, is that sufficiently confusing? Welcome to the 29000.
432 * The frame for foo uses a memory frame pointer but the frame for
433 bar does not. In the latter case the saved_msp is
434 computed by adding msize to the saved_msp of the
436 * msize is in the frame cache only for high C's sake. */
438 void read_register_stack ();
439 long read_register_stack_integer ();
441 #define EXTRA_FRAME_INFO \
442 CORE_ADDR saved_msp; \
443 unsigned int rsize; \
444 unsigned int msize; \
447 /* Bits for flags in EXTRA_FRAME_INFO */
448 #define TRANSPARENT 0x1 /* This is a transparent frame */
449 #define MFP_USED 0x2 /* A memory frame pointer is used */
451 /* Because INIT_FRAME_PC gets passed fromleaf, that's where we init
452 not only ->pc and ->frame, but all the extra stuff, when called from
453 get_prev_frame_info, that is. */
454 #define INIT_EXTRA_FRAME_INFO(fromleaf, fci) init_extra_frame_info(fci)
455 void init_extra_frame_info ();
457 #define INIT_FRAME_PC(fromleaf, fci) init_frame_pc(fromleaf, fci)
458 void init_frame_pc ();
461 /* FRAME_CHAIN takes a FRAME
462 and produces the frame's chain-pointer.
464 However, if FRAME_CHAIN_VALID returns zero,
465 it means the given frame is the outermost one and has no caller. */
467 /* On the 29k, the nominal address of a frame is the address on the
468 register stack of the return address (the one next to the incoming
469 arguments, not down at the bottom so nominal address == stack pointer).
471 GDB expects "nominal address" to equal contents of FP_REGNUM,
472 at least when it comes time to create the innermost frame.
473 However, that doesn't work for us, so when creating the innermost
474 frame we set ->frame ourselves in INIT_EXTRA_FRAME_INFO. */
476 /* These are mostly dummies for the 29k because INIT_FRAME_PC
477 sets prev->frame instead. */
478 #define FRAME_CHAIN(thisframe) ((thisframe)->frame + (thisframe)->rsize)
480 /* Determine if the frame has a 'previous' and back-traceable frame. */
481 #define FRAME_IS_UNCHAINED(frame) ((frame)->flags & TRANSPARENT)
483 /* Find the previous frame of a transparent routine.
484 * For now lets not try and trace through a transparent routine (we might
485 * have to assume that all transparent routines are traps).
487 #define FIND_PREV_UNCHAINED_FRAME(frame) 0
489 /* Define other aspects of the stack frame. */
491 /* A macro that tells us whether the function invocation represented
492 by FI does not have a frame on the stack associated with it. If it
493 does not, FRAMELESS is set to 1, else 0. */
494 #define FRAMELESS_FUNCTION_INVOCATION(FI, FRAMELESS) \
495 (FRAMELESS) = frameless_look_for_prologue(FI)
497 /* Saved pc (i.e. return address). */
498 #define FRAME_SAVED_PC(fraim) \
499 (read_register_stack_integer ((fraim)->frame + (fraim)->rsize, 4))
501 /* Local variables (i.e. LOC_LOCAL) are on the memory stack, with their
502 offsets being relative to the memory stack pointer (high C) or
505 #define FRAME_LOCALS_ADDRESS(fi) frame_locals_address (fi)
506 extern CORE_ADDR
frame_locals_address ();
508 /* Return number of args passed to a frame.
509 Can return -1, meaning no way to tell. */
510 /* While we could go the effort of finding the tags word and getting
511 the argcount field from it,
512 (1) It only counts arguments in registers, i.e. the first 16 words
514 (2) It gives the number of arguments the function was declared with
515 not how many it was called with (or some variation, like all 16
516 words for varadic functions). This makes argcount pretty much
517 redundant with -g info, even for varadic functions.
519 #define FRAME_NUM_ARGS(numargs, fi) ((numargs) = -1)
521 #define FRAME_ARGS_ADDRESS(fi) FRAME_LOCALS_ADDRESS (fi)
523 /* Return number of bytes at start of arglist that are not really args. */
525 #define FRAME_ARGS_SKIP 0
527 /* Provide our own get_saved_register. HAVE_REGISTER_WINDOWS is insufficient
528 because registers get renumbered on the 29k without getting saved. */
530 #define GET_SAVED_REGISTER
532 /* Call function stuff. */
534 /* The dummy frame looks like this (see also the general frame picture
539 | | frame for function
540 | locals_sproc | executing at time
541 |________________| of call_function.
542 | | We must not disturb
543 | args_out_sproc | it.
544 memory stack |________________|
545 |____lr1_sproc___|<-+
546 | | |__retaddr_sproc_| | <-- gr1 (at start)
547 |____________|<-msp 0 <-----------mfp_dummy_____| |
548 | | (at start) | save regs | |
549 | arg_slop | | pc0,pc1 | |
550 | (16 words) | | gr96-gr124 | |
551 |____________|<-msp 1--after | sr160-sr162 | |
552 | | PUSH_DUMMY_FRAME| sr128-sr135 | |
553 | struct ret | |________________| |
555 |____________|<- lrp | args_out_dummy | |
556 | struct ret | | (16 words) | |
557 | 16 | |________________| |
558 | (16 words) | |____lr1_dummy___|--+
559 |____________|<- msp 2--after |_retaddr_dummy__|<- gr1 after
560 | | struct ret | | PUSH_DUMMY_FRAME
561 | margs17+ | area allocated | locals_inf |
562 | | |________________| called
563 |____________|<- msp 4--when | | function's
564 | | inf called | args_out_inf | frame (set up
565 | margs16 | |________________| by called
566 | (16 words) | |_____lr1_inf____| function).
567 |____________|<- msp 3--after | . |
568 | | args pushed | . |
572 arg_slop: This area is so that when the call dummy adds 16 words to
573 the msp, it won't end up larger than mfp_dummy (it is needed in the
574 case where margs and struct_ret do not add up to at least 16 words).
575 struct ret: This area is allocated by GDB if the return value is more
576 than 16 words. struct ret_16 is not used on the 29k.
577 margs: Pushed by GDB. The call dummy copies the first 16 words to
579 retaddr_sproc: Contains the PC at the time we call the function.
580 set by PUSH_DUMMY_FRAME and read by POP_FRAME.
581 retaddr_dummy: This points to a breakpoint instruction in the dummy. */
583 /* Rsize for dummy frame, in bytes. */
585 /* Bytes for outgoing args, lr1, and retaddr. */
586 #define DUMMY_ARG (2 * 4 + 16 * 4)
588 /* Number of special registers (sr128-) to save. */
589 #define DUMMY_SAVE_SR128 8
590 /* Number of special registers (sr160-) to save. */
591 #define DUMMY_SAVE_SR160 3
592 /* Number of general (gr96- or gr64-) registers to save. */
593 #define DUMMY_SAVE_GREGS 29
595 #define DUMMY_FRAME_RSIZE \
597 + 2 * 4 /* pc0, pc1 */ \
598 + DUMMY_SAVE_GREGS * 4 \
599 + DUMMY_SAVE_SR160 * 4 \
600 + DUMMY_SAVE_SR128 * 4 \
604 /* Push an empty stack frame, to record the current PC, etc. */
606 #define PUSH_DUMMY_FRAME push_dummy_frame()
607 extern void push_dummy_frame ();
609 /* Discard from the stack the innermost frame,
610 restoring all saved registers. */
612 #define POP_FRAME pop_frame()
613 extern void pop_frame ();
615 /* This sequence of words is the instructions
617 loadm 0, 0, lr2, msp ; load first 16 words of arguments into registers
618 add msp, msp, 16 * 4 ; point to the remaining arguments
623 aseq 0x40,gr1,gr1 ; nop
624 asneq 0x50,gr1,gr1 ; breakpoint
627 /* Position of the "const" instruction within CALL_DUMMY in bytes. */
628 #define CONST_INSN (3 * 4)
629 #if TARGET_BYTE_ORDER == HOST_BYTE_ORDER
630 #define CALL_DUMMY {0x0400870f,\
631 0x36008200|(MSP_HW_REGNUM), \
632 0x15000040|(MSP_HW_REGNUM<<8)|(MSP_HW_REGNUM<<16), \
633 0x03ff80ff, 0x02ff80ff, 0xc8008080, 0x70400101, 0x72500101}
634 #else /* Byte order differs. */
636 #endif /* Byte order differs. */
637 #define CALL_DUMMY_LENGTH (8 * 4)
639 #define CALL_DUMMY_START_OFFSET 0 /* Start execution at beginning of dummy */
641 /* Helper macro for FIX_CALL_DUMMY. WORDP is a long * which points to a
642 word in target byte order; bits 0-7 and 16-23 of *WORDP are replaced with
643 bits 0-7 and 8-15 of DATA (which is in host byte order). */
645 #if TARGET_BYTE_ORDER == BIG_ENDIAN
646 #define STUFF_I16(WORDP, DATA) \
648 *((char *)(WORDP) + 3) = ((DATA) & 0xff);\
649 *((char *)(WORDP) + 1) = (((DATA) >> 8) & 0xff);\
651 #else /* Target is little endian. */
652 #define STUFF_I16(WORDP, DATA) \
654 *(char *)(WORDP
) = ((DATA
) & 0xff);
655 *((char *)(WORDP
) + 2) = (((DATA
) >> 8) & 0xff);
657 #endif /* Target is little endian. */
659 /* Insert the specified number of args and function address
660 into a call sequence of the above form stored at DUMMYNAME. */
662 /* Currently this stuffs in the address of the function that we are calling.
663 If different 29k systems use different breakpoint instructions, it
664 could also stuff BREAKPOINT in the right place (to avoid having to
665 duplicate CALL_DUMMY in each tm-*.h file). */
667 #define FIX_CALL_DUMMY(dummyname, pc, fun, nargs, args, type, gcc_p) \
669 STUFF_I16((char *)dummyname + CONST_INSN, fun);\
670 STUFF_I16((char *)dummyname + CONST_INSN + 4, fun >> 16);\
673 /* 29k architecture has separate data & instruction memories -- wired to
674 different pins on the chip -- and can't execute the data memory.
675 Also, there should be space after text_end;
676 we won't get a SIGSEGV or scribble on data space. */
678 #define CALL_DUMMY_LOCATION AFTER_TEXT_END
680 /* Because of this, we need (as a kludge) to know the addresses of the
683 #define NEED_TEXT_START_END
685 /* How to translate register numbers in the .stab's into gdb's internal register
686 numbers. We don't translate them, but we warn if an invalid register
687 number is seen. Note that FIXME, we use the value "sym" as an implicit
688 argument in printing the error message. It happens to be available where
689 this macro is used. (This macro definition appeared in a late revision
690 of gdb-3.91.6 and is not well tested. Also, it should be a "complaint".) */
692 #define STAB_REG_TO_REGNUM(num) \
693 (((num) > LR0_REGNUM + 127) \
695 "Invalid register number %d in symbol table entry for %s\n", \
696 (num), SYMBOL_NAME (sym)), (num) \