+ * gdbarch.sh (DEPRECATED_EXTRACT_RETURN_VALUE): Rename
[deliverable/binutils-gdb.git] / gdb / config / i960 / tm-i960.h
CommitLineData
c906108c 1/* Parameters for target machine Intel 960, for GDB, the GNU debugger.
92e8c9ed
AC
2
3 Copyright 1990, 1991, 1993, 1994, 1996, 1998, 1999, 2000, 2002 Free
4 Software Foundation, Inc.
5
c906108c 6 Contributed by Intel Corporation.
c5aa993b 7 This file is part of GDB.
c906108c 8
c5aa993b
JM
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
c906108c 13
c5aa993b
JM
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
c906108c 18
c5aa993b
JM
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 59 Temple Place - Suite 330,
22 Boston, MA 02111-1307, USA. */
c906108c
SS
23
24/* Definitions to target GDB to any i960. */
25
26#ifndef I80960
27#define I80960
28#endif
29
d16aafd8
AC
30#include "doublest.h"
31
c906108c
SS
32/* Hook for the SYMBOL_CLASS of a parameter when decoding DBX symbol
33 information. In the i960, parameters can be stored as locals or as
34 args, depending on the type of the debug record.
35
36 From empirical observation, gcc960 uses N_LSYM to indicate
37 arguments passed in registers and then copied immediately
38 to the frame, and N_PSYM to indicate arguments passed in a
39 g14-relative argument block. */
40
41#define DBX_PARM_SYMBOL_CLASS(type) ((type == N_LSYM)? LOC_LOCAL_ARG: LOC_ARG)
42
c906108c
SS
43/* Offset from address of function to start of its code.
44 Zero on most machines. */
45
46#define FUNCTION_START_OFFSET 0
47
48/* Advance ip across any function entry prologue instructions
49 to reach some "real" code. */
50
b83266a0
SS
51#define SKIP_PROLOGUE(ip) (i960_skip_prologue (ip))
52extern CORE_ADDR i960_skip_prologue ();
c906108c
SS
53
54/* Immediately after a function call, return the saved ip.
55 Can't always go through the frames for this because on some machines
56 the new frame is not set up until the new function
57 executes some instructions. */
58
59#define SAVED_PC_AFTER_CALL(frame) (saved_pc_after_call (frame))
60extern CORE_ADDR saved_pc_after_call ();
61
62/* Stack grows upward */
63
64#define INNER_THAN(lhs,rhs) ((lhs) > (rhs))
65
66/* Say how long (ordinary) registers are. This is a piece of bogosity
67 used in push_word and a few other places; REGISTER_RAW_SIZE is the
68 real way to know how big a register is. */
69
70#define REGISTER_SIZE 4
71
72/* Number of machine registers */
73#define NUM_REGS 40
74
75/* Initializer for an array of names of registers.
76 There should be NUM_REGS strings in this initializer. */
77
78#define REGISTER_NAMES { \
79 /* 0 */ "pfp", "sp", "rip", "r3", "r4", "r5", "r6", "r7", \
80 /* 8 */ "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15",\
81 /* 16 */ "g0", "g1", "g2", "g3", "g4", "g5", "g6", "g7", \
82 /* 24 */ "g8", "g9", "g10", "g11", "g12", "g13", "g14", "fp", \
83 /* 32 */ "pcw", "ac", "tc", "ip", "fp0", "fp1", "fp2", "fp3",\
84}
85
86/* Register numbers of various important registers (used to index
87 into arrays of register names and register values). */
88
c5aa993b
JM
89#define R0_REGNUM 0 /* First local register */
90#define SP_REGNUM 1 /* Contains address of top of stack */
91#define RIP_REGNUM 2 /* Return instruction pointer (local r2) */
92#define R15_REGNUM 15 /* Last local register */
93#define G0_REGNUM 16 /* First global register */
94#define G13_REGNUM 29 /* g13 - holds struct return address */
95#define G14_REGNUM 30 /* g14 - ptr to arg block / leafproc return address */
96#define FP_REGNUM 31 /* Contains address of executing stack frame */
97#define PCW_REGNUM 32 /* process control word */
98#define ACW_REGNUM 33 /* arithmetic control word */
99#define TCW_REGNUM 34 /* trace control word */
100#define IP_REGNUM 35 /* instruction pointer */
101#define FP0_REGNUM 36 /* First floating point register */
c906108c
SS
102
103/* Some registers have more than one name */
104
105#define PC_REGNUM IP_REGNUM /* GDB refers to ip as the Program Counter */
c5aa993b 106#define PFP_REGNUM R0_REGNUM /* Previous frame pointer */
c906108c
SS
107
108/* Total amount of space needed to store our copies of the machine's
109 register state, the array `registers'. */
110#define REGISTER_BYTES ((36*4) + (4*10))
111
112/* Index within `registers' of the first byte of the space for register N. */
113
114#define REGISTER_BYTE(N) ( (N) < FP0_REGNUM ? \
115 (4*(N)) : ((10*(N)) - (6*FP0_REGNUM)) )
116
117/* The i960 has register windows, sort of. */
118
92e8c9ed
AC
119extern void i960_get_saved_register (char *raw_buffer,
120 int *optimized,
121 CORE_ADDR *addrp,
122 struct frame_info *frame,
123 int regnum,
124 enum lval_type *lval);
125
126#define GET_SAVED_REGISTER(raw_buffer, optimized, addrp, frame, regnum, lval) \
127 i960_get_saved_register(raw_buffer, optimized, addrp, frame, regnum, lval)
128
129
c906108c
SS
130/* Number of bytes of storage in the actual machine representation
131 for register N. On the i960, all regs are 4 bytes except for floating
132 point, which are 10. NINDY only sends us 8 byte values for these,
133 which is a pain, but VxWorks handles this correctly, so we must. */
134
135#define REGISTER_RAW_SIZE(N) ( (N) < FP0_REGNUM ? 4 : 10 )
136
137/* Number of bytes of storage in the program's representation for register N. */
138
139#define REGISTER_VIRTUAL_SIZE(N) ( (N) < FP0_REGNUM ? 4 : 8 )
140
141/* Largest value REGISTER_RAW_SIZE can have. */
142
143#define MAX_REGISTER_RAW_SIZE 10
144
145/* Largest value REGISTER_VIRTUAL_SIZE can have. */
146
147#define MAX_REGISTER_VIRTUAL_SIZE 8
148
c906108c
SS
149#include "floatformat.h"
150
151#define TARGET_LONG_DOUBLE_FORMAT &floatformat_i960_ext
152
c906108c
SS
153/* Return the GDB type object for the "standard" data type
154 of data in register N. */
155
0cb2e7c5
AC
156struct type *i960_register_type (int regnum);
157#define REGISTER_VIRTUAL_TYPE(N) i960_register_type (N)
c906108c
SS
158\f
159/* Macros for understanding function return values... */
160
161/* Does the specified function use the "struct returning" convention
162 or the "value returning" convention? The "value returning" convention
163 almost invariably returns the entire value in registers. The
164 "struct returning" convention often returns the entire value in
165 memory, and passes a pointer (out of or into the function) saying
166 where the value (is or should go).
167
168 Since this sometimes depends on whether it was compiled with GCC,
169 this is also an argument. This is used in call_function to build a
170 stack, and in value_being_returned to print return values.
171
172 On i960, a structure is returned in registers g0-g3, if it will fit.
173 If it's more than 16 bytes long, g13 pointed to it on entry. */
174
175extern use_struct_convention_fn i960_use_struct_convention;
176#define USE_STRUCT_CONVENTION(gcc_p, type) i960_use_struct_convention (gcc_p, type)
177
178/* Extract from an array REGBUF containing the (raw) register state
179 a function return value of type TYPE, and copy that, in virtual format,
180 into VALBUF. This is only called if USE_STRUCT_CONVENTION for this
181 type is 0.
182
183 On the i960 we just take as many bytes as we need from G0 through G3. */
184
26e9b323 185#define DEPRECATED_EXTRACT_RETURN_VALUE(TYPE,REGBUF,VALBUF) \
c906108c
SS
186 memcpy(VALBUF, REGBUF+REGISTER_BYTE(G0_REGNUM), TYPE_LENGTH (TYPE))
187
188/* If USE_STRUCT_CONVENTION produces a 1,
189 extract from an array REGBUF containing the (raw) register state
190 the address in which a function should return its structure value,
191 as a CORE_ADDR (or an expression that can be used as one).
192
193 Address of where to put structure was passed in in global
194 register g13 on entry. God knows what's in g13 now. The
195 (..., 0) below is to make it appear to return a value, though
196 actually all it does is call error(). */
197
26e9b323 198#define DEPRECATED_EXTRACT_STRUCT_VALUE_ADDRESS(REGBUF) \
c906108c
SS
199 (error("Don't know where large structure is returned on i960"), 0)
200
201/* Write into appropriate registers a function return value
202 of type TYPE, given in virtual format, for "value returning" functions.
c5aa993b 203
c906108c
SS
204 For 'return' command: not (yet) implemented for i960. */
205
206#define STORE_RETURN_VALUE(TYPE,VALBUF) \
207 error ("Returning values from functions is not implemented in i960 gdb")
208
209/* Store the address of the place in which to copy the structure the
210 subroutine will return. This is called from call_function. */
211
212#define STORE_STRUCT_RETURN(ADDR, SP) \
213 error ("Returning values from functions is not implemented in i960 gdb")
214\f
215/* Describe the pointer in each stack frame to the previous stack frame
216 (its caller). */
217
218/* FRAME_CHAIN takes a frame's nominal address
219 and produces the frame's chain-pointer.
220
221 However, if FRAME_CHAIN_VALID returns zero,
222 it means the given frame is the outermost one and has no caller. */
223
224/* We cache information about saved registers in the frame structure,
225 to save us from having to re-scan function prologues every time
226 a register in a non-current frame is accessed. */
227
228#define EXTRA_FRAME_INFO \
229 struct frame_saved_regs *fsr; \
230 CORE_ADDR arg_pointer;
231
232/* Zero the frame_saved_regs pointer when the frame is initialized,
233 so that FRAME_FIND_SAVED_REGS () will know to allocate and
234 initialize a frame_saved_regs struct the first time it is called.
235 Set the arg_pointer to -1, which is not valid; 0 and other values
236 indicate real, cached values. */
237
238#define INIT_EXTRA_FRAME_INFO(fromleaf, fi) \
239 ((fi)->fsr = 0, (fi)->arg_pointer = -1)
240
241/* On the i960, we get the chain pointer by reading the PFP saved
242 on the stack and clearing the status bits. */
243
244#define FRAME_CHAIN(thisframe) \
245 (read_memory_integer (FRAME_FP(thisframe), 4) & ~0xf)
246
247/* FRAME_CHAIN_VALID returns zero if the given frame is the outermost one
248 and has no caller.
249
250 On the i960, each various target system type must define FRAME_CHAIN_VALID,
251 since it differs between NINDY and VxWorks, the two currently supported
252 targets types. We leave it undefined here. */
253
254
255/* A macro that tells us whether the function invocation represented
256 by FI does not have a frame on the stack associated with it. If it
257 does not, FRAMELESS is set to 1, else 0. */
258
d4f3574e 259CORE_ADDR leafproc_return (CORE_ADDR ip);
392a587b
JM
260#define FRAMELESS_FUNCTION_INVOCATION(FI) \
261 (leafproc_return ((FI)->pc) != 0)
c906108c
SS
262
263/* Note that in the i960 architecture the return pointer is saved in the
264 *caller's* stack frame.
c5aa993b 265
c906108c
SS
266 Make sure to zero low-order bits because of bug in 960CA A-step part
267 (instruction addresses should always be word-aligned anyway). */
268
269#define FRAME_SAVED_PC(frame) \
270 ((read_memory_integer(FRAME_CHAIN(frame)+8,4)) & ~3)
271
272/* On the i960, FRAME_ARGS_ADDRESS should return the value of
273 g14 as passed into the frame, if known. We need a function for this.
274 We cache this value in the frame info if we've already looked it up. */
275
276#define FRAME_ARGS_ADDRESS(fi) \
277 (((fi)->arg_pointer != -1)? (fi)->arg_pointer: frame_args_address (fi, 0))
278extern CORE_ADDR frame_args_address (); /* i960-tdep.c */
279
280/* This is the same except it should return 0 when
281 it does not really know where the args are, rather than guessing.
282 This value is not cached since it is only used infrequently. */
283
284#define FRAME_ARGS_ADDRESS_CORRECT(fi) (frame_args_address (fi, 1))
285
286#define FRAME_LOCALS_ADDRESS(fi) (fi)->frame
287
288/* Set NUMARGS to the number of args passed to a frame.
289 Can return -1, meaning no way to tell. */
290
392a587b 291#define FRAME_NUM_ARGS(fi) (-1)
c906108c
SS
292
293/* Return number of bytes at start of arglist that are not really args. */
294
295#define FRAME_ARGS_SKIP 0
296
297/* Produce the positions of the saved registers in a stack frame. */
298
299#define FRAME_FIND_SAVED_REGS(frame_info_addr, sr) \
300 frame_find_saved_regs (frame_info_addr, &sr)
c5aa993b 301extern void frame_find_saved_regs (); /* See i960-tdep.c */
c906108c
SS
302\f
303/* Things needed for making calls to functions in the inferior process */
304
305/* Push an empty stack frame, to record the current ip, etc.
c5aa993b 306
c906108c
SS
307 Not (yet?) implemented for i960. */
308
309#define PUSH_DUMMY_FRAME \
310error("Function calls into the inferior process are not supported on the i960")
311
312/* Discard from the stack the innermost frame, restoring all registers. */
313
d4f3574e
SS
314
315void i960_pop_frame (void);
c906108c 316#define POP_FRAME \
d4f3574e 317 i960_pop_frame ()
c906108c
SS
318
319
320/* This sequence of words is the instructions
c5aa993b
JM
321
322 callx 0x00000000
323 fmark
c906108c
SS
324 */
325
326/* #define CALL_DUMMY { 0x86003000, 0x00000000, 0x66003e00 } */
327
c5aa993b 328 /* #define CALL_DUMMY_START_OFFSET 0 *//* Start execution at beginning of dummy */
c906108c
SS
329
330/* Indicate that we don't support calling inferior child functions. */
331
332#undef CALL_DUMMY
333
334/* Insert the specified number of args and function address
335 into a call sequence of the above form stored at 'dummyname'.
c5aa993b 336
c906108c
SS
337 Ignore arg count on i960. */
338
339/* #define FIX_CALL_DUMMY(dummyname, fun, nargs) *(((int *)dummyname)+1) = fun */
340
341#undef FIX_CALL_DUMMY
342
343
344/* Interface definitions for kernel debugger KDB */
345/* (Not relevant to i960.) */
This page took 0.210971 seconds and 4 git commands to generate.