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