Replacing a bogus file with a semi-bogus one (sharing through devo).
[external/binutils.git] / gdb / config / fr30 / tm-fr30.h
1 /* Parameters for execution on a Fujitsu FR30 processor.
2
3 This file is part of GDB.
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
18
19 #define FR30_GENREGS            16
20 #define FR30_DEDICATEDREGS      8
21 #define FR30_REGSIZE            4       /* bytes */
22
23 #define NUM_REGS (FR30_GENREGS + FR30_DEDICATEDREGS)
24 #define REGISTER_BYTES ((FR30_GENREGS + FR30_DEDICATEDREGS)*FR30_REGSIZE)
25
26 /* Index within `registers' of the first byte of the space for
27    register N.  */
28 #define REGISTER_BYTE(N) ((N) * FR30_REGSIZE)
29
30 /* Initializer for an array of names of registers.
31    There should be NUM_REGS strings in this initializer.  */
32 #define REGISTER_NAMES \
33 { "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", "r8", \
34   "r9", "r10", "r11", "r12", "r13", "r14", "r15", \
35   "pc", "ps", "tbr", "rp", "ssp", "usp", "mdh", "mdl" }
36
37 /* Offset from address of function to start of its code.
38    Zero on most machines.  */
39 #define FUNCTION_START_OFFSET 0
40
41 /* Amount PC must be decremented by after a breakpoint.
42    This is often the number of bytes in BREAKPOINT
43    but not always.  */
44
45 #define DECR_PC_AFTER_BREAK 0
46
47 /* Stack grows downward.  */
48
49 #define INNER_THAN <
50
51 #define TARGET_BYTE_ORDER BIG_ENDIAN
52
53 #define R4_REGNUM  4
54 #define R7_REGNUM  7
55 #define FP_REGNUM 14            /* Frame pointer */
56 #define SP_REGNUM 15            /* Stack pointer */
57 #define PC_REGNUM 16            /* Program counter */
58 #define RP_REGNUM 19            /* Return pointer */
59
60 #define FIRST_ARGREG    R4_REGNUM       /* first arg (or struct ret val addr) */
61 #define LAST_ARGREG     R7_REGNUM       /* fourth (or third arg) */
62 #define RETVAL_REG      R4_REGNUM       /* return vaue */
63
64 /* Say how long (ordinary) registers are.  This is a piece of bogosity
65    used in push_word and a few other places; REGISTER_RAW_SIZE is the
66    real way to know how big a register is.  */
67 #define REGISTER_SIZE FR30_REGSIZE
68
69 /* Number of bytes of storage in the actual machine representation
70    for register N.  */
71 #define REGISTER_RAW_SIZE(N) FR30_REGSIZE
72
73 /* Largest value REGISTER_RAW_SIZE can have.  */
74 #define MAX_REGISTER_RAW_SIZE FR30_REGSIZE 
75
76 /* Number of bytes of storage in the program's representation
77    for register N.  */
78 #define REGISTER_VIRTUAL_SIZE(N) REGISTER_RAW_SIZE(N)
79
80 /* Largest value REGISTER_VIRTUAL_SIZE can have.  */
81 #define MAX_REGISTER_VIRTUAL_SIZE FR30_REGSIZE
82
83 extern void fr30_pop_frame PARAMS ((void));
84 /* XXX do we need the parameter ? */
85 #define POP_FRAME fr30_pop_frame()
86
87 /* Number of bytes at start of arglist that are not really args.  */
88 #define FRAME_ARGS_SKIP 0
89
90 /* Return the GDB type object for the "standard" data type
91    of data in register N.  */
92 #define REGISTER_VIRTUAL_TYPE(REG) builtin_type_int
93
94 /* Extract from an array REGBUF containing the (raw) register state
95    a function return value of type TYPE, and copy that, in virtual format,
96    into VALBUF.  */
97 #define EXTRACT_RETURN_VALUE(TYPE,REGBUF,VALBUF) \
98     memcpy (VALBUF, REGBUF + REGISTER_BYTE(RETVAL_REG), TYPE_LENGTH (TYPE))
99
100 /* Extract from an array REGBUF containing the (raw) register state
101    the address in which a function should return its structure value,
102    as a CORE_ADDR (or an expression that can be used as one).  */
103 #define EXTRACT_STRUCT_VALUE_ADDRESS(REGBUF) \
104   extract_address (REGBUF + REGISTER_BYTE (RETVAL_REG), \
105                    REGISTER_RAW_SIZE (RETVAL_REG))
106
107
108 #define FRAME_ARGS_ADDRESS(fi) (fi->frame)
109 #define FRAME_LOCALS_ADDRESS(fi) ((fi)->frame)
110
111 /* Return number of args passed to a frame.
112    Can return -1, meaning no way to tell.  */
113 #define FRAME_NUM_ARGS(numargs, fi) (numargs = -1)
114
115 #ifdef __STDC__         /* Forward decls for prototypes */
116 struct frame_info;
117 struct frame_saved_regs;
118 struct type;
119 struct value;
120 #endif
121
122 #define EXTRA_FRAME_INFO struct frame_saved_regs fsr;
123
124 extern CORE_ADDR fr30_frame_chain PARAMS ((struct frame_info *fi));
125 #define FRAME_CHAIN(fi) fr30_frame_chain (fi)
126
127 extern CORE_ADDR fr30_frame_saved_pc   PARAMS ((struct frame_info *));
128 #define FRAME_SAVED_PC(fi) (fr30_frame_saved_pc (fi))
129
130 #define SAVED_PC_AFTER_CALL(fi) read_register (RP_REGNUM)
131
132 extern CORE_ADDR fr30_skip_prologue PARAMS ((CORE_ADDR pc));
133 #define SKIP_PROLOGUE(pc) pc = fr30_skip_prologue (pc)
134
135 /* Write into appropriate registers a function return value
136    of type TYPE, given in virtual format.  */
137
138 #define STORE_RETURN_VALUE(TYPE,VALBUF) \
139     write_register_bytes (0, VALBUF, TYPE_LENGTH (TYPE))
140
141 /* Put here the code to store, into a struct frame_saved_regs,
142    the addresses of the saved registers of frame described by FRAME_INFO.
143    This includes special registers such as pc and fp saved in special
144    ways in the stack frame.  sp is even more special:
145    the address we return for it IS the sp for the next frame.  */
146 #define FRAME_FIND_SAVED_REGS(fi, regaddr) regaddr = fi->fsr
147
148 /* Use INT #BREAKPOINT_INTNUM instruction for breakpoint */
149 #define FR30_BREAKOP    0x1f    /* opcode, type D instruction */
150 #define BREAKPOINT_INTNUM 9     /* one of the reserved traps */
151 #define BREAKPOINT {FR30_BREAKOP, BREAKPOINT_INTNUM}
152
153
154  
155
156
157
158
159
160 #if(0) /* Z.R. */
161
162 ARM example 
163
164 #ifdef __STDC__         /* Forward decls for prototypes */
165 struct type;
166 struct value;
167 #endif
168
169 #define TARGET_BYTE_ORDER_SELECTABLE
170
171 /* IEEE format floating point */
172
173 #define IEEE_FLOAT
174
175 /* FIXME: may need a floatformat_ieee_double_bigbyte_littleword format for
176    BIG_ENDIAN use. -fnf */
177
178 #define TARGET_DOUBLE_FORMAT (target_byte_order == BIG_ENDIAN \
179                               ? &floatformat_ieee_double_big \
180                               : &floatformat_ieee_double_littlebyte_bigword)
181
182 /* When reading symbols, we need to zap the low bit of the address, which
183    may be set to 1 for Thumb functions.  */
184
185 #define SMASH_TEXT_ADDRESS(addr) ((addr) &= ~0x1)
186
187 /* Remove useless bits from addresses in a running program.  */
188
189 CORE_ADDR arm_addr_bits_remove PARAMS ((CORE_ADDR));
190
191 #define ADDR_BITS_REMOVE(val) (arm_addr_bits_remove (val))
192
193 /* Offset from address of function to start of its code.
194    Zero on most machines.  */
195
196 #define FUNCTION_START_OFFSET 0
197
198 /* Advance PC across any function entry prologue instructions
199    to reach some "real" code.  */
200
201 extern CORE_ADDR arm_skip_prologue PARAMS ((CORE_ADDR pc));
202
203 #define SKIP_PROLOGUE(pc) { pc = arm_skip_prologue (pc); }
204
205 /* Immediately after a function call, return the saved pc.
206    Can't always go through the frames for this because on some machines
207    the new frame is not set up until the new function executes
208    some instructions.  */
209
210 #define SAVED_PC_AFTER_CALL(frame) arm_saved_pc_after_call (frame)
211 struct frame_info;
212 extern CORE_ADDR arm_saved_pc_after_call PARAMS ((struct frame_info *));
213
214 /* I don't know the real values for these.  */
215 #define TARGET_UPAGES UPAGES
216 #define TARGET_NBPG NBPG
217
218 /* Address of end of stack space.  */
219
220 #define STACK_END_ADDR (0x01000000 - (TARGET_UPAGES * TARGET_NBPG))
221
222 /* Stack grows downward.  */
223
224 #define INNER_THAN <
225
226 /* Sequence of bytes for breakpoint instruction.  */
227
228 /* !!!! if we're using RDP, then we're inserting breakpoints and storing
229    their handles instread of what was in memory.  It is nice that
230    this is the same size as a handle - otherwise remote-rdp will
231    have to change. */
232
233 #define ARM_LE_BREAKPOINT {0x00,0x00,0x18,0xef} /* BKPT_SWI from <sys/ptrace.h> */
234 #define ARM_BE_BREAKPOINT {0xef,0x18,0x00,0x00} /* BKPT_SWI from <sys/ptrace.h> */
235 #define THUMB_LE_BREAKPOINT {0x18,0xdf}       /* swi 24 */
236 #define THUMB_BE_BREAKPOINT {0xdf,0x18}       /* swi 24 */
237
238 /* The following has been superseded by BREAKPOINT_FOR_PC, but
239    is defined merely to keep mem-break.c happy.  */
240 #define LITTLE_BREAKPOINT ARM_LE_BREAKPOINT
241 #define BIG_BREAKPOINT    ARM_BE_BREAKPOINT
242
243 /* BREAKPOINT_FROM_PC uses the program counter value to determine whether a
244    16- or 32-bit breakpoint should be used.  It returns a pointer
245    to a string of bytes that encode a breakpoint instruction, stores
246    the length of the string to *lenptr, and adjusts the pc (if necessary) to
247    point to the actual memory location where the breakpoint should be
248    inserted.  */
249
250 unsigned char * arm_breakpoint_from_pc PARAMS ((CORE_ADDR * pcptr, int * lenptr));
251 #define BREAKPOINT_FROM_PC(pcptr, lenptr) arm_breakpoint_from_pc (pcptr, lenptr)
252
253 /* Amount PC must be decremented by after a breakpoint.
254    This is often the number of bytes in BREAKPOINT
255    but not always.  */
256
257 #define DECR_PC_AFTER_BREAK 0
258
259 /* Nonzero if instruction at PC is a return instruction.  */
260
261 #define ABOUT_TO_RETURN(pc) \
262       ((read_memory_integer(pc, 4) & 0x0fffffff == 0x01b0f00e) || \
263        (read_memory_integer(pc, 4) & 0x0ffff800 == 0x09eba800))
264
265 /* code to execute to print interesting information about the
266  * floating point processor (if any)
267  * No need to define if there is nothing to do.
268  */
269 #define FLOAT_INFO { arm_float_info (); }
270
271 /* Say how long (ordinary) registers are.  This is a piece of bogosity
272    used in push_word and a few other places; REGISTER_RAW_SIZE is the
273    real way to know how big a register is.  */
274
275 #define REGISTER_SIZE 4
276
277 /* Number of machine registers */
278
279 /* Note: I make a fake copy of the pc in register 25 (calling it ps) so
280    that I can clear the status bits from pc (register 15) */
281
282 #define NUM_REGS 26
283
284 /* Initializer for an array of names of registers.
285    There should be NUM_REGS strings in this initializer.  */
286
287 #define ORIGINAL_REGISTER_NAMES \
288 { "a1", "a2", "a3", "a4", /*  0  1  2  3 */ \
289   "v1", "v2", "v3", "v4", /*  4  5  6  7 */ \
290   "v5", "v6", "sl", "fp", /*  8  9 10 11 */ \
291   "ip", "sp", "lr", "pc", /* 12 13 14 15 */ \
292   "f0", "f1", "f2", "f3", /* 16 17 18 19 */ \
293   "f4", "f5", "f6", "f7", /* 20 21 22 23 */ \
294   "fps","ps" }            /* 24 25       */
295
296 /* These names are the ones which gcc emits, and 
297    I find them less confusing.  Toggle between them
298    using the `othernames' command. */
299
300 #define ADDITIONAL_REGISTER_NAMES \
301 { "r0", "r1", "r2", "r3", /*  0  1  2  3 */ \
302   "r4", "r5", "r6", "r7", /*  4  5  6  7 */ \
303   "r8", "r9", "sl", "fp", /*  8  9 10 11 */ \
304   "ip", "sp", "lr", "pc", /* 12 13 14 15 */ \
305   "f0", "f1", "f2", "f3", /* 16 17 18 19 */ \
306   "f4", "f5", "f6", "f7", /* 20 21 22 23 */ \
307   "fps","ps" }            /* 24 25       */
308
309 #define REGISTER_NAMES ADDITIONAL_REGISTER_NAMES
310 #ifndef REGISTER_NAMES
311 #define REGISTER_NAMES ORIGINAL_REGISTER_NAMES
312 #endif
313
314 /* Register numbers of various important registers.
315    Note that some of these values are "real" register numbers,
316    and correspond to the general registers of the machine,
317    and some are "phony" register numbers which are too large
318    to be actual register numbers as far as the user is concerned
319    but do serve to get the desired values when passed to read_register.  */
320
321 #define A1_REGNUM 0             /* first integer-like argument */
322 #define A4_REGNUM 3             /* last integer-like argument */
323 #define AP_REGNUM 11
324 #define FP_REGNUM 11            /* Contains address of executing stack frame */
325 #define SP_REGNUM 13            /* Contains address of top of stack */
326 #define LR_REGNUM 14            /* address to return to from a function call */
327 #define PC_REGNUM 15            /* Contains program counter */
328 #define F0_REGNUM 16            /* first floating point register */
329 #define F3_REGNUM 19            /* last floating point argument register */
330 #define F7_REGNUM 23            /* last floating point register */
331 #define FPS_REGNUM 24           /* floating point status register */
332 #define PS_REGNUM 25            /* Contains processor status */
333
334 #define THUMB_FP_REGNUM 7       /* R7 is frame register on Thumb */
335
336 #define ARM_NUM_ARG_REGS        4
337 #define ARM_LAST_ARG_REGNUM     A4_REGNUM
338 #define ARM_NUM_FP_ARG_REGS     4
339 #define ARM_LAST_FP_ARG_REGNUM  F3_REGNUM
340
341 /* Instruction condition field values.  */
342 #define INST_EQ         0x0
343 #define INST_NE         0x1
344 #define INST_CS         0x2
345 #define INST_CC         0x3
346 #define INST_MI         0x4
347 #define INST_PL         0x5
348 #define INST_VS         0x6
349 #define INST_VC         0x7
350 #define INST_HI         0x8
351 #define INST_LS         0x9
352 #define INST_GE         0xa
353 #define INST_LT         0xb
354 #define INST_GT         0xc
355 #define INST_LE         0xd
356 #define INST_AL         0xe
357 #define INST_NV         0xf
358
359 #define FLAG_N          0x80000000
360 #define FLAG_Z          0x40000000
361 #define FLAG_C          0x20000000
362 #define FLAG_V          0x10000000
363
364
365
366 /* Total amount of space needed to store our copies of the machine's
367    register state, the array `registers'.  */
368 #define REGISTER_BYTES (16*4 + 12*8 + 4 + 4)
369
370 /* Index within `registers' of the first byte of the space for
371    register N.  */
372
373 #define REGISTER_BYTE(N) (((N) < F0_REGNUM) ? (N)*4 : \
374                           (((N) < PS_REGNUM) ? 16*4 + ((N) - 16)*12 : \
375                            16*4 + 8*12 + ((N) - FPS_REGNUM) * 4))
376
377 /* Number of bytes of storage in the actual machine representation
378    for register N.  On the vax, all regs are 4 bytes.  */
379
380 #define REGISTER_RAW_SIZE(N) (((N) < F0_REGNUM || (N) >= FPS_REGNUM) ? 4 : 12)
381
382 /* Number of bytes of storage in the program's representation
383    for register N.  On the vax, all regs are 4 bytes.  */
384
385 #define REGISTER_VIRTUAL_SIZE(N) (((N) < F0_REGNUM || (N) >= FPS_REGNUM) ? 4 : 8)
386
387 /* Largest value REGISTER_RAW_SIZE can have.  */
388
389 #define MAX_REGISTER_RAW_SIZE 12 
390
391 /* Largest value REGISTER_VIRTUAL_SIZE can have.  */
392
393 #define MAX_REGISTER_VIRTUAL_SIZE 8
394
395 /* Nonzero if register N requires conversion
396    from raw format to virtual format.  */
397 #define REGISTER_CONVERTIBLE(N) ((unsigned)(N) - F0_REGNUM < 8)
398
399 /* Convert data from raw format for register REGNUM in buffer FROM
400    to virtual format with type TYPE in buffer TO.  */
401
402 #define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,TYPE,FROM,TO) \
403 { \
404   double val; \
405   convert_from_extended ((FROM), & val); \
406   store_floating ((TO), TYPE_LENGTH (TYPE), val); \
407 }
408
409 /* Convert data from virtual format with type TYPE in buffer FROM
410    to raw format for register REGNUM in buffer TO.  */
411
412 #define REGISTER_CONVERT_TO_RAW(TYPE,REGNUM,FROM,TO)    \
413 { \
414   double val = extract_floating ((FROM), TYPE_LENGTH (TYPE)); \
415   convert_to_extended (&val, (TO)); \
416 }
417 /* Return the GDB type object for the "standard" data type
418    of data in register N.  */
419
420 #define REGISTER_VIRTUAL_TYPE(N) \
421  (((unsigned)(N) - F0_REGNUM) < 8 ? builtin_type_double : builtin_type_int)
422 \f
423 /* The system C compiler uses a similar structure return convention to gcc */
424
425 #define USE_STRUCT_CONVENTION(gcc_p, type) (TYPE_LENGTH (type) > 4)
426
427 /* Store the address of the place in which to copy the structure the
428    subroutine will return.  This is called from call_function. */
429
430 #define STORE_STRUCT_RETURN(ADDR, SP) \
431   { write_register (0, (ADDR)); }
432
433 /* Extract from an array REGBUF containing the (raw) register state
434    a function return value of type TYPE, and copy that, in virtual format,
435    into VALBUF.  */
436
437 #define EXTRACT_RETURN_VALUE(TYPE,REGBUF,VALBUF) \
438   if (TYPE_CODE (TYPE) == TYPE_CODE_FLT)                                \
439     convert_from_extended (REGBUF + REGISTER_BYTE (F0_REGNUM), VALBUF); \
440   else                                                                  \
441     memcpy (VALBUF, REGBUF, TYPE_LENGTH (TYPE))
442
443 /* Write into appropriate registers a function return value
444    of type TYPE, given in virtual format.  */
445
446 #define STORE_RETURN_VALUE(TYPE,VALBUF) \
447   if (TYPE_CODE (TYPE) == TYPE_CODE_FLT) {                              \
448     char _buf[MAX_REGISTER_RAW_SIZE];                                   \
449     convert_to_extended (VALBUF, _buf);                                         \
450     write_register_bytes (REGISTER_BYTE (F0_REGNUM), _buf, MAX_REGISTER_RAW_SIZE); \
451   } else                                                                \
452     write_register_bytes (0, VALBUF, TYPE_LENGTH (TYPE))
453
454 /* Extract from an array REGBUF containing the (raw) register state
455    the address in which a function should return its structure value,
456    as a CORE_ADDR (or an expression that can be used as one).  */
457
458 #define EXTRACT_STRUCT_VALUE_ADDRESS(REGBUF) (*(int *)(REGBUF))
459
460 /* Specify that for the native compiler variables for a particular
461    lexical context are listed after the beginning LBRAC instead of
462    before in the executables list of symbols.  */
463 #define VARIABLES_INSIDE_BLOCK(desc, gcc_p) (!(gcc_p))
464
465 \f
466 /* Define other aspects of the stack frame. 
467    We keep the offsets of all saved registers, 'cause we need 'em a lot!
468    We also keep the current size of the stack frame, and the offset of
469    the frame pointer from the stack pointer (for frameless functions, and
470    when we're still in the prologue of a function with a frame) */
471
472 #define EXTRA_FRAME_INFO        \
473   struct frame_saved_regs fsr;  \
474   int framesize;                \
475   int frameoffset;              \
476   int framereg;
477
478 extern void arm_init_extra_frame_info PARAMS ((struct frame_info *fi));
479 #define INIT_EXTRA_FRAME_INFO(fromleaf, fi) arm_init_extra_frame_info (fi)
480
481 /* Return the frame address.  On ARM, it is R11; on Thumb it is R7.  */
482 CORE_ADDR arm_target_read_fp PARAMS ((void));
483 #define TARGET_READ_FP() arm_target_read_fp ()
484
485 /* Describe the pointer in each stack frame to the previous stack frame
486    (its caller).  */
487
488 /* FRAME_CHAIN takes a frame's nominal address
489    and produces the frame's chain-pointer.
490
491    However, if FRAME_CHAIN_VALID returns zero,
492    it means the given frame is the outermost one and has no caller.  */
493
494 #define FRAME_CHAIN(thisframe) (CORE_ADDR) arm_frame_chain (thisframe)
495 extern CORE_ADDR arm_frame_chain PARAMS ((struct frame_info *));
496
497 #define LOWEST_PC 0x20  /* the first 0x20 bytes are the trap vectors. */
498
499 #define FRAME_CHAIN_VALID(chain, thisframe) \
500   (chain != 0 && (FRAME_SAVED_PC (thisframe) >= LOWEST_PC))
501
502 /* Define other aspects of the stack frame.  */
503
504 /* A macro that tells us whether the function invocation represented
505    by FI does not have a frame on the stack associated with it.  If it
506    does not, FRAMELESS is set to 1, else 0.  */
507 #define FRAMELESS_FUNCTION_INVOCATION(FI, FRAMELESS) \
508 {                                                       \
509   CORE_ADDR func_start, after_prologue;                 \
510   func_start = (get_pc_function_start ((FI)->pc) +      \
511                 FUNCTION_START_OFFSET);                 \
512   after_prologue = func_start;                          \
513   SKIP_PROLOGUE (after_prologue);                       \
514   (FRAMELESS) = (after_prologue == func_start);         \
515 }
516
517 /* Saved Pc.  */
518
519 #define FRAME_SAVED_PC(FRAME)   arm_frame_saved_pc (FRAME)
520 extern CORE_ADDR arm_frame_saved_pc PARAMS ((struct frame_info *));
521
522 #define FRAME_ARGS_ADDRESS(fi) (fi->frame)
523
524 #define FRAME_LOCALS_ADDRESS(fi) ((fi)->frame)
525
526 /* Return number of args passed to a frame.
527    Can return -1, meaning no way to tell.  */
528
529 #define FRAME_NUM_ARGS(numargs, fi) (numargs = -1)
530
531 /* Return number of bytes at start of arglist that are not really args.  */
532
533 #define FRAME_ARGS_SKIP 0
534
535 /* Put here the code to store, into a struct frame_saved_regs,
536    the addresses of the saved registers of frame described by FRAME_INFO.
537    This includes special registers such as pc and fp saved in special
538    ways in the stack frame.  sp is even more special:
539    the address we return for it IS the sp for the next frame.  */
540
541 struct frame_saved_regs;
542 struct frame_info;
543 void frame_find_saved_regs PARAMS((struct frame_info *fi,
544                                    struct frame_saved_regs *fsr));
545
546 #define FRAME_FIND_SAVED_REGS(frame_info, frame_saved_regs) \
547  arm_frame_find_saved_regs (frame_info, &(frame_saved_regs));
548
549 \f
550 /* Things needed for making the inferior call functions.  */
551
552 #define PUSH_ARGUMENTS(nargs, args, sp, struct_return, struct_addr) \
553     sp = arm_push_arguments ((nargs), (args), (sp), (struct_return), (struct_addr))
554 extern CORE_ADDR
555 arm_push_arguments PARAMS ((int, struct value **, CORE_ADDR, int, CORE_ADDR));
556
557 /* Push an empty stack frame, to record the current PC, etc.  */
558
559 void arm_push_dummy_frame PARAMS ((void));
560
561 #define PUSH_DUMMY_FRAME arm_push_dummy_frame ()
562
563 /* Discard from the stack the innermost frame, restoring all registers.  */
564
565 void arm_pop_frame PARAMS ((void));
566
567 #define POP_FRAME arm_pop_frame ()
568
569 /* This sequence of words is the instructions
570
571      mov        lr,pc
572      mov        pc,r4
573      swi        bkpt_swi
574
575    Note this is 12 bytes.  */
576
577 #define CALL_DUMMY {0xe1a0e00f, 0xe1a0f004, 0xef180000}
578
579 #define CALL_DUMMY_START_OFFSET 0  /* Start execution at beginning of dummy */
580
581 #define CALL_DUMMY_BREAKPOINT_OFFSET arm_call_dummy_breakpoint_offset()
582 extern int arm_call_dummy_breakpoint_offset PARAMS ((void));
583
584 /* Insert the specified number of args and function address
585    into a call sequence of the above form stored at DUMMYNAME.  */
586
587 #define FIX_CALL_DUMMY(dummyname, pc, fun, nargs, args, type, gcc_p) \
588    arm_fix_call_dummy (dummyname, pc, fun, nargs, args, type, gcc_p)
589
590 void arm_fix_call_dummy PARAMS ((char *dummy, CORE_ADDR pc, CORE_ADDR fun,
591                                  int nargs, struct value **args,
592                                  struct type *type, int gcc_p));
593
594 CORE_ADDR arm_get_next_pc PARAMS ((CORE_ADDR));
595
596 /* Functions for dealing with Thumb call thunks.  */
597 #define IN_SOLIB_CALL_TRAMPOLINE(pc, name)      arm_in_call_stub (pc, name)
598 #define SKIP_TRAMPOLINE_CODE(pc)                arm_skip_stub (pc)
599 extern int arm_in_call_stub PARAMS ((CORE_ADDR pc,  char *name));
600 extern CORE_ADDR arm_skip_stub PARAMS ((CORE_ADDR pc));
601
602 /* Function to determine whether MEMADDR is in a Thumb function.  */
603 extern int arm_pc_is_thumb PARAMS ((bfd_vma memaddr));
604
605 /* Function to determine whether MEMADDR is in a call dummy called from
606    a Thumb function.  */
607 extern int arm_pc_is_thumb_dummy PARAMS ((bfd_vma memaddr));
608
609 /* Macros for setting and testing a bit in a minimal symbol that
610    marks it as Thumb function.  The MSB of the minimal symbol's
611    "info" field is used for this purpose. This field is already
612    being used to store the symbol size, so the assumption is
613    that the symbol size cannot exceed 2^31.
614  
615    COFF_MAKE_MSYMBOL_SPECIAL
616    ELF_MAKE_MSYMBOL_SPECIAL     tests whether the COFF or ELF symbol corresponds 
617                         to a thumb function, and sets a "special" bit in a
618                         minimal symbol to indicate that it does
619    MSYMBOL_SET_SPECIAL  actually sets the "special" bit
620    MSYMBOL_IS_SPECIAL   tests the "special" bit in a minimal symbol
621    MSYMBOL_SIZE         returns the size of the minimal symbol, i.e.
622                         the "info" field with the "special" bit masked out
623 */
624  
625 extern int coff_sym_is_thumb(int val);
626 #define MSYMBOL_SET_SPECIAL(msym) \
627     MSYMBOL_INFO (msym) = (char *) (((long) MSYMBOL_INFO (msym)) | 0x80000000)
628 #define MSYMBOL_IS_SPECIAL(msym) \
629   (((long) MSYMBOL_INFO (msym) & 0x80000000) != 0)
630 #define MSYMBOL_SIZE(msym) \
631   ((long) MSYMBOL_INFO (msym) & 0x7fffffff)
632
633 /* Thumb symbol are of type STT_LOPROC, (synonymous with STT_ARM_TFUNC) */
634 #define ELF_MAKE_MSYMBOL_SPECIAL(sym,msym) \
635  { if(ELF_ST_TYPE(((elf_symbol_type *)(sym))->internal_elf_sym.st_info) == STT_LOPROC) \
636         MSYMBOL_SET_SPECIAL(msym); }
637   
638 #define COFF_MAKE_MSYMBOL_SPECIAL(val,msym) \
639  { if(coff_sym_is_thumb(val)) MSYMBOL_SET_SPECIAL(msym); }
640
641
642 V850 example
643
644
645 #define TARGET_BYTE_ORDER BIG_ENDIAN
646
647 #define NUM_REGS 66
648
649 #define REGISTER_NAMES \
650 { "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", \
651   "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15", \
652   "r16", "r17", "r18", "r19", "r20", "r21", "r22", "r23", \
653   "r24", "r25", "r26", "r27", "r28", "r29", "r30", "r31", \
654     \
655   "eipc", "eipsw", "fepc", "fepsw", "ecr", "psw", "sr6", "sr7", \
656   "sr8", "sr9", "sr10", "sr11", "sr12", "sr13", "sr14", "sr15", \
657   "sr16", "sr17", "sr18", "sr19", "sr20", "sr21", "sr22", "sr23", \
658   "sr24", "sr25", "sr26", "sr27", "sr28", "sr29", "sr30", "sr31", \
659     \
660   "pc", "fp" }
661
662 #define REGISTER_BYTES (NUM_REGS * 4)
663
664 #define REGISTER_SIZE 4
665 #define MAX_REGISTER_RAW_SIZE 4
666
667 #define R0_REGNUM 0
668 #define R1_REGNUM 1
669 #define SAVE1_START_REGNUM 2
670 #define SAVE1_END_REGNUM 2
671 #define SP_REGNUM 3
672 #define ARG0_REGNUM 6
673 #define ARGLAST_REGNUM 9
674 #define V0_REGNUM 10
675 #define V1_REGNUM 11
676 #define R12_REGNUM 12
677 #define SAVE2_START_REGNUM 20
678 #define SAVE2_END_REGNUM 29
679 #define EP_REGNUM 30
680 #define SAVE3_START_REGNUM 31
681 #define SAVE3_END_REGNUM 31
682 #define RP_REGNUM 31
683 #define PS_REGNUM 37
684 #define PC_REGNUM 64
685 #define FP_REGNUM 65
686 #define FP_RAW_REGNUM 29
687
688 #define TARGET_READ_FP() read_register (FP_RAW_REGNUM)
689 #define TARGET_WRITE_FP(VAL) write_register (FP_REGNUM, (VAL))
690
691 #define REGISTER_VIRTUAL_TYPE(REG) builtin_type_int
692
693 #define REGISTER_BYTE(REG) ((REG) * 4)
694 #define REGISTER_VIRTUAL_SIZE(REG) 4
695 #define REGISTER_RAW_SIZE(REG) 4
696
697 #define MAX_REGISTER_VIRTUAL_SIZE 4
698
699 #define BREAKPOINT {0x40, 0xF8} /* little-ended */
700
701 #define FUNCTION_START_OFFSET 0
702
703 #define DECR_PC_AFTER_BREAK 0
704
705 #define INNER_THAN <
706
707 #define SAVED_PC_AFTER_CALL(fi) read_register (RP_REGNUM)
708
709 #ifdef __STDC__
710 struct frame_info;
711 struct frame_saved_regs;
712 struct type;
713 struct value;
714 #endif
715
716 #define EXTRA_FRAME_INFO struct frame_saved_regs fsr;
717
718 extern void fr30_init_extra_frame_info PARAMS ((struct frame_info *fi));
719 #define INIT_EXTRA_FRAME_INFO(fromleaf, fi) fr30_init_extra_frame_info (fi)
720 #define INIT_FRAME_PC           /* Not necessary */
721
722 extern void fr30_frame_find_saved_regs PARAMS ((struct frame_info *fi, struct frame_saved_regs *regaddr));
723 #define FRAME_FIND_SAVED_REGS(fi, regaddr) regaddr = fi->fsr
724
725 extern CORE_ADDR fr30_frame_chain PARAMS ((struct frame_info *fi));
726 #define FRAME_CHAIN(fi) fr30_frame_chain (fi)
727 #define FRAME_CHAIN_VALID(FP, FI)       generic_frame_chain_valid (FP, FI)
728
729 extern CORE_ADDR fr30_find_callers_reg PARAMS ((struct frame_info *fi, int regnum));
730 extern CORE_ADDR fr30_frame_saved_pc   PARAMS ((struct frame_info *));
731 #define FRAME_SAVED_PC(FI) (fr30_frame_saved_pc (FI))
732
733 #define EXTRACT_RETURN_VALUE(TYPE, REGBUF, VALBUF) \
734   memcpy (VALBUF, REGBUF + REGISTER_BYTE (V0_REGNUM), TYPE_LENGTH (TYPE))
735
736 #define EXTRACT_STRUCT_VALUE_ADDRESS(REGBUF) \
737   extract_address (REGBUF + REGISTER_BYTE (V0_REGNUM), \
738                    REGISTER_RAW_SIZE (V0_REGNUM))
739
740 #define STORE_RETURN_VALUE(TYPE, VALBUF) \
741   write_register_bytes(REGISTER_BYTE (V0_REGNUM), VALBUF, TYPE_LENGTH (TYPE));
742
743 extern CORE_ADDR fr30_skip_prologue PARAMS ((CORE_ADDR pc));
744 #define SKIP_PROLOGUE(pc) pc = fr30_skip_prologue (pc)
745
746 #define FRAME_ARGS_SKIP 0
747
748 #define FRAME_ARGS_ADDRESS(fi) ((fi)->frame)
749 #define FRAME_LOCALS_ADDRESS(fi) ((fi)->frame)
750 #define FRAME_NUM_ARGS(val, fi) ((val) = -1)
751
752 extern void fr30_pop_frame PARAMS ((void));
753 #define POP_FRAME fr30_pop_frame()
754
755 #define USE_GENERIC_DUMMY_FRAMES
756 #define CALL_DUMMY                   {0}
757 #define CALL_DUMMY_START_OFFSET      (0)
758 #define CALL_DUMMY_BREAKPOINT_OFFSET (0)
759 #define CALL_DUMMY_LOCATION          AT_ENTRY_POINT
760 #define FIX_CALL_DUMMY(DUMMY, START, FUNADDR, NARGS, ARGS, TYPE, GCCP)
761 #define CALL_DUMMY_ADDRESS()         entry_point_address ()
762 extern CORE_ADDR fr30_push_return_address PARAMS ((CORE_ADDR, CORE_ADDR));
763 #define PUSH_RETURN_ADDRESS(PC, SP)  fr30_push_return_address (PC, SP)
764
765
766 #define PUSH_DUMMY_FRAME        generic_push_dummy_frame ()
767
768 extern CORE_ADDR
769 fr30_push_arguments PARAMS ((int nargs, struct value **args, CORE_ADDR sp,
770                              unsigned char struct_return,
771                              CORE_ADDR struct_addr));
772 #define PUSH_ARGUMENTS(NARGS, ARGS, SP, STRUCT_RETURN, STRUCT_ADDR) \
773   (SP) = fr30_push_arguments (NARGS, ARGS, SP, STRUCT_RETURN, STRUCT_ADDR)
774
775 #define STORE_STRUCT_RETURN(STRUCT_ADDR, SP)
776
777
778 #define PC_IN_CALL_DUMMY(PC, SP, FP) generic_pc_in_call_dummy (PC, SP)
779
780 #define USE_STRUCT_CONVENTION(GCC_P, TYPE) \
781         (TYPE_NFIELDS (TYPE) > 1 || TYPE_LENGTH (TYPE) > 4)
782
783 /* override the default get_saved_register function with
784    one that takes account of generic CALL_DUMMY frames */
785 #define GET_SAVED_REGISTER
786
787 /* Define this for Wingdb */
788
789 #define TARGET_FR30
790
791 #endif /* Z.R. */