]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/config/a29k/tm-a29k.h
import gdb-1999-05-25 snapshot
[thirdparty/binutils-gdb.git] / gdb / config / a29k / tm-a29k.h
1 /* Parameters for target machine AMD 29000, for GDB, the GNU debugger.
2 Copyright 1990, 1991, 1993, 1994 Free Software Foundation, Inc.
3 Contributed by Cygnus Support. Written by Jim Kingdon.
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, Boston, MA 02111-1307, USA. */
20
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).
24
25 If gdb is ported to other a29k machines/systems, the
26 machine/system-specific parts should be removed from this file (a
27 la tm-m68k.h). */
28
29 /* Byte order is configurable, but this machine runs big-endian. */
30 #define TARGET_BYTE_ORDER BIG_ENDIAN
31
32 /* Floating point uses IEEE representations. */
33 #define IEEE_FLOAT
34
35 /* Recognize our magic number. */
36 #define BADMAG(x) ((x).f_magic != 0572)
37
38 /* Offset from address of function to start of its code.
39 Zero on most machines. */
40
41 #define FUNCTION_START_OFFSET 0
42
43 /* Advance PC across any function entry prologue instructions
44 to reach some "real" code. */
45
46 #define SKIP_PROLOGUE(pc) (a29k_skip_prologue (pc))
47 CORE_ADDR a29k_skip_prologue ();
48
49 /* Immediately after a function call, return the saved pc.
50 Can't go through the frames for this because on some machines
51 the new frame is not set up until the new function executes
52 some instructions. */
53
54 #define SAVED_PC_AFTER_CALL(frame) ((frame->flags & TRANSPARENT_FRAME) \
55 ? read_register (TPC_REGNUM) \
56 : read_register (LR0_REGNUM))
57
58 /* Stack grows downward. */
59
60 #define INNER_THAN(lhs,rhs) ((lhs) < (rhs))
61
62 /* Stack must be aligned on 32-bit boundaries when synthesizing
63 function calls. */
64
65 #define STACK_ALIGN(ADDR) (((ADDR) + 3) & ~3)
66
67 /* Sequence of bytes for breakpoint instruction. */
68 /* ASNEQ 0x50, gr1, gr1
69 The trap number 0x50 is chosen arbitrarily.
70 We let the command line (or previously included files) override this
71 setting. */
72 #ifndef BREAKPOINT
73 #if TARGET_BYTE_ORDER == BIG_ENDIAN
74 #define BREAKPOINT {0x72, 0x50, 0x01, 0x01}
75 #else /* Target is little-endian. */
76 #define BREAKPOINT {0x01, 0x01, 0x50, 0x72}
77 #endif /* Target is little-endian. */
78 #endif /* BREAKPOINT */
79
80 /* Amount PC must be decremented by after a breakpoint.
81 This is often the number of bytes in BREAKPOINT
82 but not always. */
83
84 #define DECR_PC_AFTER_BREAK 0
85
86 /* Say how long (ordinary) registers are. This is a piece of bogosity
87 used in push_word and a few other places; REGISTER_RAW_SIZE is the
88 real way to know how big a register is. */
89
90 #define REGISTER_SIZE 4
91
92 /* Allow the register declarations here to be overridden for remote
93 kernel debugging. */
94 #if !defined (REGISTER_NAMES)
95
96 /* Number of machine registers */
97
98 #define NUM_REGS 205
99
100 /* Initializer for an array of names of registers.
101 There should be NUM_REGS strings in this initializer.
102
103 FIXME, add floating point registers and support here.
104
105 Also note that this list does not attempt to deal with kernel
106 debugging (in which the first 32 registers are gr64-gr95). */
107
108 #define REGISTER_NAMES \
109 {"gr96", "gr97", "gr98", "gr99", "gr100", "gr101", "gr102", "gr103", "gr104", \
110 "gr105", "gr106", "gr107", "gr108", "gr109", "gr110", "gr111", "gr112", \
111 "gr113", "gr114", "gr115", "gr116", "gr117", "gr118", "gr119", "gr120", \
112 "gr121", "gr122", "gr123", "gr124", "gr125", "gr126", "gr127", \
113 "lr0", "lr1", "lr2", "lr3", "lr4", "lr5", "lr6", "lr7", "lr8", "lr9", \
114 "lr10", "lr11", "lr12", "lr13", "lr14", "lr15", "lr16", "lr17", "lr18", \
115 "lr19", "lr20", "lr21", "lr22", "lr23", "lr24", "lr25", "lr26", "lr27", \
116 "lr28", "lr29", "lr30", "lr31", "lr32", "lr33", "lr34", "lr35", "lr36", \
117 "lr37", "lr38", "lr39", "lr40", "lr41", "lr42", "lr43", "lr44", "lr45", \
118 "lr46", "lr47", "lr48", "lr49", "lr50", "lr51", "lr52", "lr53", "lr54", \
119 "lr55", "lr56", "lr57", "lr58", "lr59", "lr60", "lr61", "lr62", "lr63", \
120 "lr64", "lr65", "lr66", "lr67", "lr68", "lr69", "lr70", "lr71", "lr72", \
121 "lr73", "lr74", "lr75", "lr76", "lr77", "lr78", "lr79", "lr80", "lr81", \
122 "lr82", "lr83", "lr84", "lr85", "lr86", "lr87", "lr88", "lr89", "lr90", \
123 "lr91", "lr92", "lr93", "lr94", "lr95", "lr96", "lr97", "lr98", "lr99", \
124 "lr100", "lr101", "lr102", "lr103", "lr104", "lr105", "lr106", "lr107", \
125 "lr108", "lr109", "lr110", "lr111", "lr112", "lr113", "lr114", "lr115", \
126 "lr116", "lr117", "lr118", "lr119", "lr120", "lr121", "lr122", "lr123", \
127 "lr124", "lr125", "lr126", "lr127", \
128 "AI0", "AI1", "AI2", "AI3", "AI4", "AI5", "AI6", "AI7", "AI8", "AI9", \
129 "AI10", "AI11", "AI12", "AI13", "AI14", "AI15", "FP", \
130 "bp", "fc", "cr", "q", \
131 "vab", "ops", "cps", "cfg", "cha", "chd", "chc", "rbp", "tmc", "tmr", \
132 "pc0", "pc1", "pc2", "mmu", "lru", "fpe", "inte", "fps", "exo", "gr1", \
133 "alu", "ipc", "ipa", "ipb" }
134
135 /*
136 * Converts an sdb register number to an internal gdb register number.
137 * Currently under epi, gr96->0...gr127->31...lr0->32...lr127->159, or...
138 * gr64->0...gr95->31, lr0->32...lr127->159.
139 */
140 #define SDB_REG_TO_REGNUM(value) \
141 (((value) >= 96 && (value) <= 127) ? ((value) - 96) : \
142 ((value) >= 128 && (value) <= 255) ? ((value) - 128 + LR0_REGNUM) : \
143 (value))
144
145 /*
146 * Provide the processor register numbers of some registers that are
147 * expected/written in instructions that might change under different
148 * register sets. Namely, gcc can compile (-mkernel-registers) so that
149 * it uses gr64-gr95 in stead of gr96-gr127.
150 */
151 #define MSP_HW_REGNUM 125 /* gr125 */
152 #define RAB_HW_REGNUM 126 /* gr126 */
153
154 /* Convert Processor Special register #x to REGISTER_NAMES register # */
155 #define SR_REGNUM(x) \
156 ((x) < 15 ? VAB_REGNUM + (x) \
157 : (x) >= 128 && (x) < 131 ? IPC_REGNUM + (x) - 128 \
158 : (x) == 131 ? Q_REGNUM \
159 : (x) == 132 ? ALU_REGNUM \
160 : (x) >= 133 && (x) < 136 ? BP_REGNUM + (x) - 133 \
161 : (x) >= 160 && (x) < 163 ? FPE_REGNUM + (x) - 160 \
162 : (x) == 164 ? EXO_REGNUM \
163 : (error ("Internal error in SR_REGNUM"), 0))
164 #define GR96_REGNUM 0
165
166 /* Define the return register separately, so it can be overridden for
167 kernel procedure calling conventions. */
168 #define RETURN_REGNUM GR96_REGNUM
169 #define GR1_REGNUM 200
170 /* This needs to be the memory stack pointer, not the register stack pointer,
171 to make call_function work right. */
172 #define SP_REGNUM MSP_REGNUM
173 #define FP_REGNUM 33 /* lr1 */
174
175 /* Return register for transparent calling convention (gr122). */
176 #define TPC_REGNUM (122 - 96 + GR96_REGNUM)
177
178 /* Large Return Pointer (gr123). */
179 #define LRP_REGNUM (123 - 96 + GR96_REGNUM)
180
181 /* Static link pointer (gr124). */
182 #define SLP_REGNUM (124 - 96 + GR96_REGNUM)
183
184 /* Memory Stack Pointer (gr125). */
185 #define MSP_REGNUM (125 - 96 + GR96_REGNUM)
186
187 /* Register allocate bound (gr126). */
188 #define RAB_REGNUM (126 - 96 + GR96_REGNUM)
189
190 /* Register Free Bound (gr127). */
191 #define RFB_REGNUM (127 - 96 + GR96_REGNUM)
192
193 /* Register Stack Pointer. */
194 #define RSP_REGNUM GR1_REGNUM
195 #define LR0_REGNUM 32
196 #define BP_REGNUM 177
197 #define FC_REGNUM 178
198 #define CR_REGNUM 179
199 #define Q_REGNUM 180
200 #define VAB_REGNUM 181
201 #define OPS_REGNUM (VAB_REGNUM + 1)
202 #define CPS_REGNUM (VAB_REGNUM + 2)
203 #define CFG_REGNUM (VAB_REGNUM + 3)
204 #define CHA_REGNUM (VAB_REGNUM + 4)
205 #define CHD_REGNUM (VAB_REGNUM + 5)
206 #define CHC_REGNUM (VAB_REGNUM + 6)
207 #define RBP_REGNUM (VAB_REGNUM + 7)
208 #define TMC_REGNUM (VAB_REGNUM + 8)
209 #define TMR_REGNUM (VAB_REGNUM + 9)
210 #define NPC_REGNUM (VAB_REGNUM + 10) /* pc0 */
211 #define PC_REGNUM (VAB_REGNUM + 11) /* pc1 */
212 #define PC2_REGNUM (VAB_REGNUM + 12)
213 #define MMU_REGNUM (VAB_REGNUM + 13)
214 #define LRU_REGNUM (VAB_REGNUM + 14)
215 #define FPE_REGNUM (VAB_REGNUM + 15)
216 #define INTE_REGNUM (VAB_REGNUM + 16)
217 #define FPS_REGNUM (VAB_REGNUM + 17)
218 #define EXO_REGNUM (VAB_REGNUM + 18)
219 /* gr1 is defined above as 200 = VAB_REGNUM + 19 */
220 #define ALU_REGNUM (VAB_REGNUM + 20)
221 #define PS_REGNUM ALU_REGNUM
222 #define IPC_REGNUM (VAB_REGNUM + 21)
223 #define IPA_REGNUM (VAB_REGNUM + 22)
224 #define IPB_REGNUM (VAB_REGNUM + 23)
225
226 #endif /* !defined(REGISTER_NAMES) */
227
228 /* Total amount of space needed to store our copies of the machine's
229 register state, the array `registers'. */
230 #define REGISTER_BYTES (NUM_REGS * 4)
231
232 /* Index within `registers' of the first byte of the space for
233 register N. */
234 #define REGISTER_BYTE(N) ((N)*4)
235
236 /* Number of bytes of storage in the actual machine representation
237 for register N. */
238
239 /* All regs are 4 bytes. */
240
241 #define REGISTER_RAW_SIZE(N) (4)
242
243 /* Number of bytes of storage in the program's representation
244 for register N. */
245
246 /* All regs are 4 bytes. */
247
248 #define REGISTER_VIRTUAL_SIZE(N) (4)
249
250 /* Largest value REGISTER_RAW_SIZE can have. */
251
252 #define MAX_REGISTER_RAW_SIZE (4)
253
254 /* Largest value REGISTER_VIRTUAL_SIZE can have. */
255
256 #define MAX_REGISTER_VIRTUAL_SIZE (4)
257
258 /* Return the GDB type object for the "standard" data type
259 of data in register N. */
260
261 #define REGISTER_VIRTUAL_TYPE(N) \
262 (((N) == PC_REGNUM || (N) == LRP_REGNUM || (N) == SLP_REGNUM \
263 || (N) == MSP_REGNUM || (N) == RAB_REGNUM || (N) == RFB_REGNUM \
264 || (N) == GR1_REGNUM || (N) == FP_REGNUM || (N) == LR0_REGNUM \
265 || (N) == NPC_REGNUM || (N) == PC2_REGNUM) \
266 ? lookup_pointer_type (builtin_type_void) : builtin_type_int)
267 \f
268 /* Store the address of the place in which to copy the structure the
269 subroutine will return. This is called from call_function. */
270 /* On the a29k the LRP points to the part of the structure beyond the first
271 16 words. */
272 #define STORE_STRUCT_RETURN(ADDR, SP) \
273 write_register (LRP_REGNUM, (ADDR) + 16 * 4);
274
275 /* Should call_function allocate stack space for a struct return? */
276 /* On the a29k objects over 16 words require the caller to allocate space. */
277 extern use_struct_convention_fn a29k_use_struct_convention;
278 #define USE_STRUCT_CONVENTION(gcc_p, type) a29k_use_struct_convention (gcc_p, type)
279
280 /* Extract from an array REGBUF containing the (raw) register state
281 a function return value of type TYPE, and copy that, in virtual format,
282 into VALBUF. */
283
284 #define EXTRACT_RETURN_VALUE(TYPE,REGBUF,VALBUF) \
285 { \
286 int reg_length = TYPE_LENGTH (TYPE); \
287 if (reg_length > 16 * 4) \
288 { \
289 reg_length = 16 * 4; \
290 read_memory (*((int *)(REGBUF) + LRP_REGNUM), (VALBUF) + 16 * 4, \
291 TYPE_LENGTH (TYPE) - 16 * 4); \
292 } \
293 memcpy ((VALBUF), ((int *)(REGBUF))+RETURN_REGNUM, reg_length); \
294 }
295
296 /* Write into appropriate registers a function return value
297 of type TYPE, given in virtual format. */
298
299 #define STORE_RETURN_VALUE(TYPE,VALBUF) \
300 { \
301 int reg_length = TYPE_LENGTH (TYPE); \
302 if (reg_length > 16 * 4) \
303 { \
304 reg_length = 16 * 4; \
305 write_memory (read_register (LRP_REGNUM), \
306 (char *)(VALBUF) + 16 * 4, \
307 TYPE_LENGTH (TYPE) - 16 * 4); \
308 } \
309 write_register_bytes (REGISTER_BYTE (RETURN_REGNUM), (char *)(VALBUF), \
310 TYPE_LENGTH (TYPE)); \
311 }
312 \f
313 /* The a29k user's guide documents well what the stacks look like.
314 But what isn't so clear there is how this interracts with the
315 symbols, or with GDB.
316 In the following saved_msp, saved memory stack pointer (which functions
317 as a memory frame pointer), means either
318 a register containing the memory frame pointer or, in the case of
319 functions with fixed size memory frames (i.e. those who don't use
320 alloca()), the result of the calculation msp + msize.
321
322 LOC_ARG, LOC_LOCAL - For GCC, these are relative to saved_msp.
323 For high C, these are relative to msp (making alloca impossible).
324 LOC_REGISTER, LOC_REGPARM - The register number is the number at the
325 time the function is running (after the prologue), or in the case
326 of LOC_REGPARM, may be a register number in the range 160-175.
327
328 The compilers do things like store an argument into memory, and then put out
329 a LOC_ARG for it, or put it into global registers and put out a
330 LOC_REGPARM. Thus is it important to execute the first line of
331 code (i.e. the line of the open brace, i.e. the prologue) of a function
332 before trying to print arguments or anything.
333
334 The following diagram attempts to depict what is going on in memory
335 (see also the _a29k user's guide_) and also how that interacts with
336 GDB frames. We arbitrarily pick fci->frame to point the same place
337 as the register stack pointer; since we set it ourself in
338 INIT_EXTRA_FRAME_INFO, and access it only through the FRAME_*
339 macros, it doesn't really matter exactly how we
340 do it. However, note that FRAME_FP is used in two ways in GDB:
341 (1) as a "magic cookie" which uniquely identifies frames (even over
342 calls to the inferior), (2) (in PC_IN_CALL_DUMMY [ON_STACK])
343 as the value of SP_REGNUM before the dummy frame was pushed. These
344 two meanings would be incompatible for the a29k if we defined
345 CALL_DUMMY_LOCATION == ON_STACK (but we don't, so don't worry about it).
346 Also note that "lr1" below, while called a frame pointer
347 in the user's guide, has only one function: To determine whether
348 registers need to be filled in the function epilogue.
349
350 Consider the code:
351 < call bar>
352 loc1: . . .
353 bar: sub gr1,gr1,rsize_b
354 . . .
355 add mfp,msp,0
356 sub msp,msp,msize_b
357 . . .
358 < call foo >
359 loc2: . . .
360 foo: sub gr1,gr1,rsize_f
361 . . .
362 add mfp,msp,0
363 sub msp,msp,msize_f
364 . . .
365 loc3: < suppose the inferior stops here >
366
367 memory stack register stack
368 | | |____________|
369 | | |____loc1____|
370 +------->|___________| | | ^
371 | | ^ | | locals_b | |
372 | | | | |____________| |
373 | | | | | | | rsize_b
374 | | | msize_b | | args_to_f | |
375 | | | | |____________| |
376 | | | | |____lr1_____| V
377 | | V | |____loc2____|<----------------+
378 | +--->|___________|<---------mfp | ^ |
379 | | | ^ | | locals_f | | |
380 | | | | msize_f | |____________| | |
381 | | | | | | | | rsize_f |
382 | | | V | | args | | |
383 | | |___________|<msp |____________| | |
384 | | |_____lr1____| V |
385 | | |___garbage__| <- gr1 <----+ |
386 | | | |
387 | | | |
388 | | pc=loc3 | |
389 | | | |
390 | | | |
391 | | frame cache | |
392 | | |_________________| | |
393 | | |rsize=rsize_b | | |
394 | | |msize=msize_b | | |
395 +---|--------saved_msp | | |
396 | |frame------------------------------------|---+
397 | |pc=loc2 | |
398 | |_________________| |
399 | |rsize=rsize_f | |
400 | |msize=msize_f | |
401 +--------saved_msp | |
402 |frame------------------------------------+
403 |pc=loc3 |
404 |_________________|
405
406 So, is that sufficiently confusing? Welcome to the 29000.
407 Notes:
408 * The frame for foo uses a memory frame pointer but the frame for
409 bar does not. In the latter case the saved_msp is
410 computed by adding msize to the saved_msp of the
411 next frame.
412 * msize is in the frame cache only for high C's sake. */
413
414 void read_register_stack ();
415 long read_register_stack_integer ();
416 \f
417 #define FRAME_INIT_SAVED_REGS(fi) /*no-op*/
418
419 #define EXTRA_FRAME_INFO \
420 CORE_ADDR saved_msp; \
421 unsigned int rsize; \
422 unsigned int msize; \
423 unsigned char flags;
424
425 /* Bits for flags in EXTRA_FRAME_INFO */
426 #define TRANSPARENT_FRAME 0x1 /* This is a transparent frame */
427 #define MFP_USED 0x2 /* A memory frame pointer is used */
428
429 /* Because INIT_FRAME_PC gets passed fromleaf, that's where we init
430 not only ->pc and ->frame, but all the extra stuff, when called from
431 get_prev_frame, that is. */
432 #define INIT_EXTRA_FRAME_INFO(fromleaf, fci) init_extra_frame_info(fci)
433 void init_extra_frame_info ();
434
435 #define INIT_FRAME_PC(fromleaf, fci) init_frame_pc(fromleaf, fci)
436 void init_frame_pc ();
437
438 \f
439 /* FRAME_CHAIN takes a FRAME
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 /* On the a29k, the nominal address of a frame is the address on the
446 register stack of the return address (the one next to the incoming
447 arguments, not down at the bottom so nominal address == stack pointer).
448
449 GDB expects "nominal address" to equal contents of FP_REGNUM,
450 at least when it comes time to create the innermost frame.
451 However, that doesn't work for us, so when creating the innermost
452 frame we set ->frame ourselves in INIT_EXTRA_FRAME_INFO. */
453
454 /* These are mostly dummies for the a29k because INIT_FRAME_PC
455 sets prev->frame instead. */
456 /* If rsize is zero, we must be at end of stack (or otherwise hosed).
457 If we don't check rsize, we loop forever if we see rsize == 0. */
458 #define FRAME_CHAIN(thisframe) \
459 ((thisframe)->rsize == 0 \
460 ? 0 \
461 : (thisframe)->frame + (thisframe)->rsize)
462
463 /* Determine if the frame has a 'previous' and back-traceable frame. */
464 #define FRAME_IS_UNCHAINED(frame) ((frame)->flags & TRANSPARENT_FRAME)
465
466 /* Find the previous frame of a transparent routine.
467 * For now lets not try and trace through a transparent routine (we might
468 * have to assume that all transparent routines are traps).
469 */
470 #define FIND_PREV_UNCHAINED_FRAME(frame) 0
471
472 /* Define other aspects of the stack frame. */
473
474 /* An expression that tells us whether the function invocation represented
475 by FI does not have a frame on the stack associated with it. */
476 #define FRAMELESS_FUNCTION_INVOCATION(FI) \
477 (frameless_look_for_prologue (FI))
478
479 /* Saved pc (i.e. return address). */
480 #define FRAME_SAVED_PC(fraim) \
481 (read_register_stack_integer ((fraim)->frame + (fraim)->rsize, 4))
482
483 /* Local variables (i.e. LOC_LOCAL) are on the memory stack, with their
484 offsets being relative to the memory stack pointer (high C) or
485 saved_msp (gcc). */
486
487 #define FRAME_LOCALS_ADDRESS(fi) frame_locals_address (fi)
488 extern CORE_ADDR frame_locals_address ();
489
490 /* Return number of args passed to a frame.
491 Can return -1, meaning no way to tell. */
492 /* We tried going to the effort of finding the tags word and getting
493 the argcount field from it, to support debugging assembler code.
494 Problem was, the "argcount" field never did hold the argument
495 count. */
496 #define FRAME_NUM_ARGS(fi) (-1)
497
498 #define FRAME_ARGS_ADDRESS(fi) FRAME_LOCALS_ADDRESS (fi)
499
500 /* Return number of bytes at start of arglist that are not really args. */
501
502 #define FRAME_ARGS_SKIP 0
503
504 /* Provide our own get_saved_register. HAVE_REGISTER_WINDOWS is insufficient
505 because registers get renumbered on the a29k without getting saved. */
506
507 #ifdef __STDC__
508 enum lval_type;
509 struct frame_info;
510 #endif
511 void a29k_get_saved_register PARAMS ((char *raw_buffer, int *optimized, CORE_ADDR *addrp, struct frame_info *frame, int regnum, enum lval_type *lvalp));
512 #define GET_SAVED_REGISTER(raw_buffer, optimized, addrp, frame, regnum, lval) \
513 a29k_get_saved_register (raw_buffer, optimized, addrp, frame, regnum, lval)
514 \f
515 /* Call function stuff. */
516
517 /* The dummy frame looks like this (see also the general frame picture
518 above):
519
520 register stack
521
522 | | frame for function
523 | locals_sproc | executing at time
524 |________________| of call_function.
525 | | We must not disturb
526 | args_out_sproc | it.
527 memory stack |________________|
528 |____lr1_sproc___|<-+
529 | | |__retaddr_sproc_| | <-- gr1 (at start)
530 |____________|<-msp 0 <-----------mfp_dummy_____| |
531 | | (at start) | save regs | |
532 | arg_slop | | pc0,pc1 | |
533 | | | pc2,lr0 sproc | |
534 | (16 words) | | gr96-gr124 | |
535 |____________|<-msp 1--after | sr160-sr162 | |
536 | | PUSH_DUMMY_FRAME| sr128-sr135 | |
537 | struct ret | |________________| |
538 | 17+ | | | |
539 |____________|<- lrp | args_out_dummy | |
540 | struct ret | | (16 words) | |
541 | 16 | |________________| |
542 | (16 words) | |____lr1_dummy___|--+
543 |____________|<- msp 2--after |_retaddr_dummy__|<- gr1 after
544 | | struct ret | | PUSH_DUMMY_FRAME
545 | margs17+ | area allocated | locals_inf |
546 | | |________________| called
547 |____________|<- msp 4--when | | function's
548 | | inf called | args_out_inf | frame (set up
549 | margs16 | |________________| by called
550 | (16 words) | |_____lr1_inf____| function).
551 |____________|<- msp 3--after | . |
552 | | args pushed | . |
553 | | | . |
554 | |
555
556 arg_slop: This area is so that when the call dummy adds 16 words to
557 the msp, it won't end up larger than mfp_dummy (it is needed in the
558 case where margs and struct_ret do not add up to at least 16 words).
559 struct ret: This area is allocated by GDB if the return value is more
560 than 16 words. struct ret_16 is not used on the a29k.
561 margs: Pushed by GDB. The call dummy copies the first 16 words to
562 args_out_dummy.
563 retaddr_sproc: Contains the PC at the time we call the function.
564 set by PUSH_DUMMY_FRAME and read by POP_FRAME.
565 retaddr_dummy: This points to a breakpoint instruction in the dummy. */
566 \f
567 /* Rsize for dummy frame, in bytes. */
568
569 /* Bytes for outgoing args, lr1, and retaddr. */
570 #define DUMMY_ARG (2 * 4 + 16 * 4)
571
572 /* Number of special registers (sr128-) to save. */
573 #define DUMMY_SAVE_SR128 8
574 /* Number of special registers (sr160-) to save. */
575 #define DUMMY_SAVE_SR160 3
576 /* Number of general (gr96- or gr64-) registers to save. */
577 #define DUMMY_SAVE_GREGS 29
578
579 #define DUMMY_FRAME_RSIZE \
580 (4 /* mfp_dummy */ \
581 + 4 * 4 /* pc0, pc1, pc2, lr0 */ \
582 + DUMMY_SAVE_GREGS * 4 \
583 + DUMMY_SAVE_SR160 * 4 \
584 + DUMMY_SAVE_SR128 * 4 \
585 + DUMMY_ARG \
586 + 4 /* pad to doubleword */ )
587
588 /* Push an empty stack frame, to record the current PC, etc. */
589
590 #define PUSH_DUMMY_FRAME push_dummy_frame()
591 extern void push_dummy_frame ();
592
593 /* Discard from the stack the innermost frame,
594 restoring all saved registers. */
595
596 #define POP_FRAME pop_frame()
597 extern void pop_frame ();
598
599 /* This sequence of words is the instructions
600 mtsrim cr, 15
601 loadm 0, 0, lr2, msp ; load first 16 words of arguments into registers
602 add msp, msp, 16 * 4 ; point to the remaining arguments
603 CONST_INSN:
604 const lr0,inf ; (replaced by half of target addr)
605 consth lr0,inf ; (replaced by other half of target addr)
606 calli lr0, lr0
607 aseq 0x40,gr1,gr1 ; nop
608 BREAKPT_INSN:
609 asneq 0x50,gr1,gr1 ; breakpoint (replaced by local breakpoint insn)
610 */
611
612 #if TARGET_BYTE_ORDER == HOST_BYTE_ORDER
613 #define BS(const) const
614 #else
615 #define BS(const) (((const) & 0xff) << 24) | \
616 (((const) & 0xff00) << 8) | \
617 (((const) & 0xff0000) >> 8) | \
618 (((const) & 0xff000000) >> 24)
619 #endif
620
621 /* Position of the "const" and blkt instructions within CALL_DUMMY in bytes. */
622 #define CONST_INSN (3 * 4)
623 #define BREAKPT_INSN (7 * 4)
624 #define CALL_DUMMY { \
625 BS(0x0400870f),\
626 BS(0x36008200|(MSP_HW_REGNUM)), \
627 BS(0x15000040|(MSP_HW_REGNUM<<8)|(MSP_HW_REGNUM<<16)), \
628 BS(0x03ff80ff), \
629 BS(0x02ff80ff), \
630 BS(0xc8008080), \
631 BS(0x70400101), \
632 BS(0x72500101)}
633 #define CALL_DUMMY_LENGTH (8 * 4)
634
635 #define CALL_DUMMY_START_OFFSET 0 /* Start execution at beginning of dummy */
636
637 /* Helper macro for FIX_CALL_DUMMY. WORDP is a long * which points to a
638 word in target byte order; bits 0-7 and 16-23 of *WORDP are replaced with
639 bits 0-7 and 8-15 of DATA (which is in host byte order). */
640
641 #if TARGET_BYTE_ORDER == BIG_ENDIAN
642 #define STUFF_I16(WORDP, DATA) \
643 { \
644 *((char *)(WORDP) + 3) = ((DATA) & 0xff);\
645 *((char *)(WORDP) + 1) = (((DATA) >> 8) & 0xff);\
646 }
647 #else /* Target is little endian. */
648 #define STUFF_I16(WORDP, DATA) \
649 {
650 *(char *)(WORDP) = ((DATA) & 0xff);
651 *((char *)(WORDP) + 2) = (((DATA) >> 8) & 0xff);
652 }
653 #endif /* Target is little endian. */
654
655 /* Insert the specified number of args and function address
656 into a call sequence of the above form stored at DUMMYNAME. */
657
658 /* Currently this stuffs in the address of the function that we are calling.
659 Since different a29k systems use different breakpoint instructions, it
660 also stuffs BREAKPOINT in the right place (to avoid having to
661 duplicate CALL_DUMMY in each tm-*.h file). */
662
663 #define FIX_CALL_DUMMY(dummyname, pc, fun, nargs, args, type, gcc_p) \
664 {\
665 STUFF_I16((char *)dummyname + CONST_INSN, fun); \
666 STUFF_I16((char *)dummyname + CONST_INSN + 4, fun >> 16); \
667 /* FIXME memcpy ((char *)(dummyname) + BREAKPT_INSN, break_insn, 4); */ \
668 }
669
670 /* a29k architecture has separate data & instruction memories -- wired to
671 different pins on the chip -- and can't execute the data memory.
672 Also, there should be space after text_end;
673 we won't get a SIGSEGV or scribble on data space. */
674
675 #define CALL_DUMMY_LOCATION AFTER_TEXT_END
676
677 /* Because of this, we need (as a kludge) to know the addresses of the
678 text section. */
679
680 #define NEED_TEXT_START_END 1
681
682 /* How to translate register numbers in the .stab's into gdb's internal register
683 numbers. We don't translate them, but we warn if an invalid register
684 number is seen. Note that FIXME, we use the value "sym" as an implicit
685 argument in printing the error message. It happens to be available where
686 this macro is used. (This macro definition appeared in a late revision
687 of gdb-3.91.6 and is not well tested. Also, it should be a "complaint".) */
688
689 #define STAB_REG_TO_REGNUM(num) \
690 (((num) > LR0_REGNUM + 127) \
691 ? fprintf(stderr, \
692 "Invalid register number %d in symbol table entry for %s\n", \
693 (num), SYMBOL_SOURCE_NAME (sym)), (num) \
694 : (num))
695
696 extern enum a29k_processor_types {
697 a29k_unknown,
698
699 /* Bit 0x400 of the CPS does *not* identify freeze mode, i.e. 29000,
700 29030, etc. */
701 a29k_no_freeze_mode,
702
703 /* Bit 0x400 of the CPS does identify freeze mode, i.e. 29050. */
704 a29k_freeze_mode
705 } processor_type;
706
707 /* We need three arguments for a general frame specification for the
708 "frame" or "info frame" command. */
709
710 #define SETUP_ARBITRARY_FRAME(argc, argv) setup_arbitrary_frame (argc, argv)
711 extern struct frame_info *setup_arbitrary_frame PARAMS ((int, CORE_ADDR *));