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