+ * gdbarch.sh (DEPRECATED_EXTRACT_RETURN_VALUE): Rename
[deliverable/binutils-gdb.git] / gdb / config / d30v / tm-d30v.h
CommitLineData
c906108c 1/* Target-specific definition for the Mitsubishi D30V
b6ba6518 2 Copyright 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
c906108c 3
c5aa993b 4 This file is part of GDB.
c906108c 5
c5aa993b
JM
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
c906108c 10
c5aa993b
JM
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
c906108c 15
c5aa993b
JM
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. */
c906108c
SS
20
21#ifndef TM_D30V_H
22#define TM_D30V_H
23
f88e2c52
AC
24#include "regcache.h"
25
c906108c
SS
26/* Offset from address of function to start of its code.
27 Zero on most machines. */
28
29#define FUNCTION_START_OFFSET 0
30
31/* these are the addresses the D30V-EVA board maps data */
32/* and instruction memory to. */
33
34#define DMEM_START 0x20000000
c5aa993b 35#define IMEM_START 0x00000000 /* was 0x10000000 */
c906108c
SS
36#define STACK_START 0x20007ffe
37
104c1213 38/* Forward decls for prototypes */
c906108c 39struct frame_info;
c5aa993b 40struct frame_saved_regs;
c906108c
SS
41struct type;
42struct value;
c906108c
SS
43
44/* Advance PC across any function entry prologue instructions
45 to reach some "real" code. */
46
a14ed312 47extern CORE_ADDR d30v_skip_prologue (CORE_ADDR);
b83266a0 48#define SKIP_PROLOGUE(ip) (d30v_skip_prologue (ip))
c906108c
SS
49
50
51/* Stack grows downward. */
52#define INNER_THAN(lhs,rhs) ((lhs) < (rhs))
53
54/* for a breakpoint, use "dbt || nop" */
55#define BREAKPOINT {0x00, 0xb0, 0x00, 0x00,\
56 0x00, 0xf0, 0x00, 0x00}
57
58/* If your kernel resets the pc after the trap happens you may need to
59 define this before including this file. */
60#define DECR_PC_AFTER_BREAK 0
61
62#define REGISTER_NAMES \
63{ "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", \
64 "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15", \
65 "r16", "r17", "r18", "r19", "r20", "r21", "r22", "r23", \
66 "r24", "r25", "r26", "r27", "r28", "r29", "r30", "r31", \
67 "r32", "r33", "r34", "r35", "r36", "r37", "r38", "r39", \
68 "r40", "r41", "r42", "r43", "r44", "r45", "r46", "r47", \
69 "r48", "r49", "r50", "r51", "r52", "r53", "r54", "r55", \
70 "r56", "r57", "r58", "r59", "r60", "r61", "r62", "r63", \
71 "spi", "spu", \
72 "psw", "bpsw", "pc", "bpc", "dpsw", "dpc", "cr6", "rpt_c", \
73 "rpt_s", "rpt_e", "mod_s", "mod_e", "cr12", "cr13", "iba", "eit_vb",\
74 "int_s", "int_m", "a0", "a1" \
75 }
76
77#define NUM_REGS 86
78
79/* Register numbers of various important registers.
80 Note that some of these values are "real" register numbers,
81 and correspond to the general registers of the machine,
82 and some are "phony" register numbers which are too large
83 to be actual register numbers as far as the user is concerned
84 but do serve to get the desired values when passed to read_register. */
85
86#define R0_REGNUM 0
87#define FP_REGNUM 61
88#define LR_REGNUM 62
89#define SP_REGNUM 63
90#define SPI_REGNUM 64 /* Interrupt stack pointer */
91#define SPU_REGNUM 65 /* User stack pointer */
92#define CREGS_START 66
93
c5aa993b 94#define PSW_REGNUM (CREGS_START + 0) /* psw, bpsw, or dpsw??? */
c906108c 95#define PSW_SM (((unsigned long)0x80000000) >> 0) /* Stack mode: 0/SPI */
c5aa993b 96 /* 1/SPU */
c906108c
SS
97#define PSW_EA (((unsigned long)0x80000000) >> 2) /* Execution status */
98#define PSW_DB (((unsigned long)0x80000000) >> 3) /* Debug mode */
99#define PSW_DS (((unsigned long)0x80000000) >> 4) /* Debug EIT status */
100#define PSW_IE (((unsigned long)0x80000000) >> 5) /* Interrupt enable */
101#define PSW_RP (((unsigned long)0x80000000) >> 6) /* Repeat enable */
102#define PSW_MD (((unsigned long)0x80000000) >> 7) /* Modulo enable */
103#define PSW_F0 (((unsigned long)0x80000000) >> 17) /* F0 flag */
104#define PSW_F1 (((unsigned long)0x80000000) >> 19) /* F1 flag */
105#define PSW_F2 (((unsigned long)0x80000000) >> 21) /* F2 flag */
106#define PSW_F3 (((unsigned long)0x80000000) >> 23) /* F3 flag */
107#define PSW_S (((unsigned long)0x80000000) >> 25) /* Saturation flag */
108#define PSW_V (((unsigned long)0x80000000) >> 27) /* Overflow flag */
109#define PSW_VA (((unsigned long)0x80000000) >> 29) /* Accum. overflow */
110#define PSW_C (((unsigned long)0x80000000) >> 31) /* Carry/Borrow flag */
111
c5aa993b
JM
112#define BPSW_REGNUM (CREGS_START + 1) /* Backup PSW (on interrupt) */
113#define PC_REGNUM (CREGS_START + 2) /* pc, bpc, or dpc??? */
114#define BPC_REGNUM (CREGS_START + 3) /* Backup PC (on interrupt) */
115#define DPSW_REGNUM (CREGS_START + 4) /* Backup PSW (on debug trap) */
116#define DPC_REGNUM (CREGS_START + 5) /* Backup PC (on debug trap) */
117#define RPT_C_REGNUM (CREGS_START + 7) /* Loop count */
118#define RPT_S_REGNUM (CREGS_START + 8) /* Loop start address */
119#define RPT_E_REGNUM (CREGS_START + 9) /* Loop end address */
c906108c
SS
120#define MOD_S_REGNUM (CREGS_START + 10)
121#define MOD_E_REGNUM (CREGS_START + 11)
c5aa993b
JM
122#define IBA_REGNUM (CREGS_START + 14) /* Instruction break address */
123#define EIT_VB_REGNUM (CREGS_START + 15) /* Vector base address */
124#define INT_S_REGNUM (CREGS_START + 16) /* Interrupt status */
125#define INT_M_REGNUM (CREGS_START + 17) /* Interrupt mask */
c906108c
SS
126#define A0_REGNUM 84
127#define A1_REGNUM 85
128
129/* Say how much memory is needed to store a copy of the register set */
c5aa993b 130#define REGISTER_BYTES ((NUM_REGS - 2) * 4 + 2 * 8)
c906108c
SS
131
132/* Index within `registers' of the first byte of the space for
133 register N. */
134
135#define REGISTER_BYTE(N) \
136( ((N) >= A0_REGNUM) ? ( ((N) - A0_REGNUM) * 8 + A0_REGNUM * 4 ) : ((N) * 4) )
137
138/* Number of bytes of storage in the actual machine representation
139 for register N. */
140
141#define REGISTER_RAW_SIZE(N) ( ((N) >= A0_REGNUM) ? 8 : 4 )
142
143/* Number of bytes of storage in the program's representation
c5aa993b 144 for register N. */
c906108c
SS
145#define REGISTER_VIRTUAL_SIZE(N) REGISTER_RAW_SIZE(N)
146
147/* Largest value REGISTER_RAW_SIZE can have. */
148
149#define MAX_REGISTER_RAW_SIZE 8
150
151/* Largest value REGISTER_VIRTUAL_SIZE can have. */
152
153#define MAX_REGISTER_VIRTUAL_SIZE 8
154
155/* Return the GDB type object for the "standard" data type
156 of data in register N. */
157
158#define REGISTER_VIRTUAL_TYPE(N) \
159( ((N) < A0_REGNUM ) ? builtin_type_long : builtin_type_long_long)
160
161/* Writing to r0 is a noop (not an error or exception or anything like
162 that, however). */
163
164#define CANNOT_STORE_REGISTER(regno) ((regno) == R0_REGNUM)
165
a14ed312 166void d30v_do_registers_info (int regnum, int fpregs);
c906108c
SS
167
168#define DO_REGISTERS_INFO d30v_do_registers_info
169
170/* Store the address of the place in which to copy the structure the
171 subroutine will return. This is called from call_function.
172
173 We store structs through a pointer passed in R2 */
174
175#define STORE_STRUCT_RETURN(ADDR, SP) \
176 { write_register (2, (ADDR)); }
177
178
179/* Write into appropriate registers a function return value
180 of type TYPE, given in virtual format.
181
182 Things always get returned in R2/R3 */
183
184#define STORE_RETURN_VALUE(TYPE,VALBUF) \
185 write_register_bytes (REGISTER_BYTE(2), VALBUF, TYPE_LENGTH (TYPE))
186
187
188/* Extract from an array REGBUF containing the (raw) register state
189 the address in which a function should return its structure value,
190 as a CORE_ADDR (or an expression that can be used as one). */
26e9b323 191#define DEPRECATED_EXTRACT_STRUCT_VALUE_ADDRESS(REGBUF) (((CORE_ADDR *)(REGBUF))[2])
c906108c
SS
192\f
193
194/* Define other aspects of the stack frame.
195 we keep a copy of the worked out return pc lying around, since it
196 is a useful bit of info */
197
198#define EXTRA_FRAME_INFO \
199 CORE_ADDR return_pc; \
200 CORE_ADDR dummy; \
201 int frameless; \
202 int size;
203
204#define INIT_EXTRA_FRAME_INFO(fromleaf, fi) \
c5aa993b 205 d30v_init_extra_frame_info(fromleaf, fi)
c906108c 206
a14ed312 207extern void d30v_init_extra_frame_info (int fromleaf, struct frame_info *fi);
c906108c
SS
208
209/* A macro that tells us whether the function invocation represented
210 by FI does not have a frame on the stack associated with it. If it
211 does not, FRAMELESS is set to 1, else 0. */
212
392a587b
JM
213#define FRAMELESS_FUNCTION_INVOCATION(FI) \
214 (frameless_look_for_prologue (FI))
c906108c 215
d4f3574e 216CORE_ADDR d30v_frame_chain (struct frame_info *frame);
c906108c 217#define FRAME_CHAIN(FRAME) d30v_frame_chain(FRAME)
a14ed312 218extern int d30v_frame_chain_valid (CORE_ADDR, struct frame_info *);
c906108c 219#define FRAME_CHAIN_VALID(chain, thisframe) d30v_frame_chain_valid (chain, thisframe)
c5aa993b 220#define FRAME_SAVED_PC(FRAME) ((FRAME)->return_pc)
c906108c
SS
221#define FRAME_ARGS_ADDRESS(fi) (fi)->frame
222#define FRAME_LOCALS_ADDRESS(fi) (fi)->frame
223
d4f3574e 224void d30v_init_frame_pc (int fromleaf, struct frame_info *prev);
c906108c
SS
225#define INIT_FRAME_PC_FIRST(fromleaf, prev) d30v_init_frame_pc(fromleaf, prev)
226#define INIT_FRAME_PC(fromleaf, prev) /* nada */
227
228/* Immediately after a function call, return the saved pc. We can't */
229/* use frame->return_pc beause that is determined by reading R62 off the */
230/* stack and that may not be written yet. */
231
232#define SAVED_PC_AFTER_CALL(frame) (read_register(LR_REGNUM))
c5aa993b 233
c906108c
SS
234/* Set VAL to the number of args passed to frame described by FI.
235 Can set VAL to -1, meaning no way to tell. */
236/* We can't tell how many args there are */
237
392a587b 238#define FRAME_NUM_ARGS(fi) (-1)
c906108c
SS
239
240/* Return number of bytes at start of arglist that are not really args. */
241
242#define FRAME_ARGS_SKIP 0
243
244
245/* Put here the code to store, into a struct frame_saved_regs,
246 the addresses of the saved registers of frame described by FRAME_INFO.
247 This includes special registers such as pc and fp saved in special
248 ways in the stack frame. sp is even more special:
249 the address we return for it IS the sp for the next frame. */
250
251#define FRAME_FIND_SAVED_REGS(frame_info, frame_saved_regs) \
252 d30v_frame_find_saved_regs(frame_info, &(frame_saved_regs))
253
a14ed312
KB
254extern void d30v_frame_find_saved_regs (struct frame_info *,
255 struct frame_saved_regs *);
c906108c 256
c906108c
SS
257/* DUMMY FRAMES. Need these to support inferior function calls.
258 They work like this on D30V:
259 First we set a breakpoint at 0 or __start.
260 Then we push all the registers onto the stack.
261 Then put the function arguments in the proper registers and set r13
262 to our breakpoint address.
263 Finally call the function directly.
264 When it hits the breakpoint, clear the break point and pop the old
265 register contents off the stack. */
266
c5aa993b 267#define CALL_DUMMY { 0 }
c906108c 268#define PUSH_DUMMY_FRAME
c5aa993b 269#define CALL_DUMMY_START_OFFSET 0
c906108c
SS
270#define CALL_DUMMY_LOCATION AT_ENTRY_POINT
271#define CALL_DUMMY_BREAKPOINT_OFFSET (0)
272
a14ed312 273extern CORE_ADDR d30v_call_dummy_address (void);
c906108c
SS
274#define CALL_DUMMY_ADDRESS() d30v_call_dummy_address()
275
276#define FIX_CALL_DUMMY(dummyname, pc, fun, nargs, args, type, gcc_p) \
277sp = d30v_fix_call_dummy (dummyname, pc, fun, nargs, args, type, gcc_p)
278
279#define PC_IN_CALL_DUMMY(pc, sp, frame_address) ( pc == IMEM_START + 4 )
280
a14ed312
KB
281extern CORE_ADDR d30v_fix_call_dummy (char *, CORE_ADDR, CORE_ADDR,
282 int, struct value **,
283 struct type *, int);
c906108c 284#define PUSH_ARGUMENTS(nargs, args, sp, struct_return, struct_addr) \
392a587b 285 (d30v_push_arguments((nargs), (args), (sp), (struct_return), (struct_addr)))
a14ed312
KB
286extern CORE_ADDR d30v_push_arguments (int, struct value **, CORE_ADDR, int,
287 CORE_ADDR);
c906108c
SS
288
289
290/* Extract from an array REGBUF containing the (raw) register state
291 a function return value of type TYPE, and copy that, in virtual format,
292 into VALBUF. */
293
26e9b323 294#define DEPRECATED_EXTRACT_RETURN_VALUE(TYPE,REGBUF,VALBUF) \
c906108c 295d30v_extract_return_value(TYPE, REGBUF, VALBUF)
a14ed312 296extern void d30v_extract_return_value (struct type *, char *, char *);
c906108c
SS
297
298
299/* Discard from the stack the innermost frame,
300 restoring all saved registers. */
301#define POP_FRAME d30v_pop_frame();
a14ed312 302extern void d30v_pop_frame (void);
c906108c
SS
303
304#define REGISTER_SIZE 4
305
306/* Need to handle SP special, as we need to select between spu and spi. */
307#if 0 /* XXX until the simulator is fixed */
308#define TARGET_READ_SP() ((read_register (PSW_REGNUM) & PSW_SM) \
309 ? read_register (SPU_REGNUM) \
310 : read_register (SPI_REGNUM))
311
312#define TARGET_WRITE_SP(val) ((read_register (PSW_REGNUM) & PSW_SM) \
313 ? write_register (SPU_REGNUM, (val)) \
314 : write_register (SPI_REGNUM, (val)))
315#endif
316
317#define STACK_ALIGN(len) (((len) + 7 ) & ~7)
318
319/* Turn this on to cause remote-sim.c to use sim_set/clear_breakpoint. */
320
321#define SIM_HAS_BREAKPOINTS
322
323#endif /* TM_D30V_H */
This page took 0.173198 seconds and 4 git commands to generate.