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