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