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