* ns32k-tdep.c: Update copyright years.
[deliverable/binutils-gdb.git] / gdb / config / ns32k / tm-umax.h
1 /* Definitions to make GDB run on an encore under umax 4.2
2 Copyright 1987, 1989, 1991, 1993, 1994, 1998, 1999, 2000, 2001
3 Free Software Foundation, Inc.
4
5 This file is part of GDB.
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
21
22 #include "regcache.h"
23
24 /* Need to get function ends by adding this to epilogue address from .bf
25 record, not using x_fsize field. */
26 #define FUNCTION_EPILOGUE_SIZE 4
27
28 /* Offset from address of function to start of its code.
29 Zero on most machines. */
30
31 #define FUNCTION_START_OFFSET 0
32
33 /* Advance PC across any function entry prologue instructions
34 to reach some "real" code. */
35
36 extern CORE_ADDR umax_skip_prologue (CORE_ADDR);
37 #define SKIP_PROLOGUE(pc) (umax_skip_prologue (pc))
38
39 /* Immediately after a function call, return the saved pc.
40 Can't always go through the frames for this because on some machines
41 the new frame is not set up until the new function executes
42 some instructions. */
43
44 #define SAVED_PC_AFTER_CALL(frame) \
45 read_memory_integer (read_register (SP_REGNUM), 4)
46
47 /* Address of end of stack space. */
48
49 #ifndef STACK_END_ADDR
50 #define STACK_END_ADDR (0xfffff000)
51 #endif
52
53 /* Stack grows downward. */
54
55 #define INNER_THAN(lhs,rhs) ((lhs) < (rhs))
56
57 /* Sequence of bytes for breakpoint instruction. */
58
59 #define BREAKPOINT {0xf2}
60
61 /* Amount PC must be decremented by after a breakpoint.
62 This is often the number of bytes in BREAKPOINT
63 but not always. */
64
65 #define DECR_PC_AFTER_BREAK 0
66
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. */
70
71 #define REGISTER_SIZE 4
72
73 /* Number of machine registers */
74
75 #define NUM_REGS 25
76
77 #define NUM_GENERAL_REGS 8
78
79 extern char *ns32k_register_name_32082 (int);
80 extern char *ns32k_register_name_32382 (int);
81
82 #define REGISTER_NAME(REGNUM) ns32k_register_name_32082(REGNUM)
83
84 /* Register numbers of various important registers.
85 Note that some of these values are "real" register numbers,
86 and correspond to the general registers of the machine,
87 and some are "phony" register numbers which are too large
88 to be actual register numbers as far as the user is concerned
89 but do serve to get the desired values when passed to read_register. */
90
91 #define R0_REGNUM 0 /* General register 0 */
92 #define FP0_REGNUM 8 /* Floating point register 0 */
93 #define SP_REGNUM 16 /* Contains address of top of stack */
94 #define AP_REGNUM FP_REGNUM
95 #define FP_REGNUM 17 /* Contains address of executing stack frame */
96 #define PC_REGNUM 18 /* Contains program counter */
97 #define PS_REGNUM 19 /* Contains processor status */
98 #define FPS_REGNUM 20 /* Floating point status register */
99 #define LP0_REGNUM 21 /* Double register 0 (same as FP0) */
100
101 /* Total amount of space needed to store our copies of the machine's
102 register state, the array `registers'. */
103 #define REGISTER_BYTES \
104 ((NUM_REGS - 4) * REGISTER_RAW_SIZE(R0_REGNUM) \
105 + 4 * REGISTER_RAW_SIZE(LP0_REGNUM))
106
107 /* Index within `registers' of the first byte of the space for
108 register N. */
109
110 #define REGISTER_BYTE(N) ((N) >= LP0_REGNUM ? \
111 LP0_REGNUM * 4 + ((N) - LP0_REGNUM) * 8 : (N) * 4)
112
113 /* Number of bytes of storage in the actual machine representation
114 for register N. On the 32000, all regs are 4 bytes
115 except for the doubled floating registers. */
116
117 #define REGISTER_RAW_SIZE(N) ((N) >= LP0_REGNUM ? 8 : 4)
118
119 /* Number of bytes of storage in the program's representation
120 for register N. On the 32000, all regs are 4 bytes
121 except for the doubled floating registers. */
122
123 #define REGISTER_VIRTUAL_SIZE(N) ((N) >= LP0_REGNUM ? 8 : 4)
124
125 /* Largest value REGISTER_RAW_SIZE can have. */
126
127 #define MAX_REGISTER_RAW_SIZE 8
128
129 /* Largest value REGISTER_VIRTUAL_SIZE can have. */
130
131 #define MAX_REGISTER_VIRTUAL_SIZE 8
132
133 /* Return the GDB type object for the "standard" data type
134 of data in register N. */
135
136 #define REGISTER_VIRTUAL_TYPE(N) \
137 (((N) < FP0_REGNUM) ? \
138 builtin_type_int : \
139 ((N) < FP0_REGNUM + 8) ? \
140 builtin_type_float : \
141 ((N) < LP0_REGNUM) ? \
142 builtin_type_int : \
143 builtin_type_double)
144
145 /* Store the address of the place in which to copy the structure the
146 subroutine will return. This is called from call_function.
147
148 On this machine this is a no-op, because gcc isn't used on it
149 yet. So this calling convention is not used. */
150
151 #define STORE_STRUCT_RETURN(ADDR, SP)
152
153 /* Extract from an array REGBUF containing the (raw) register state
154 a function return value of type TYPE, and copy that, in virtual format,
155 into VALBUF. */
156
157 #define EXTRACT_RETURN_VALUE(TYPE,REGBUF,VALBUF) \
158 memcpy (VALBUF, REGBUF+REGISTER_BYTE (TYPE_CODE (TYPE) == TYPE_CODE_FLT ? FP0_REGNUM : 0), TYPE_LENGTH (TYPE))
159
160 /* Write into appropriate registers a function return value
161 of type TYPE, given in virtual format. */
162
163 #define STORE_RETURN_VALUE(TYPE,VALBUF) \
164 write_register_bytes (REGISTER_BYTE (TYPE_CODE (TYPE) == TYPE_CODE_FLT ? FP0_REGNUM : 0), VALBUF, TYPE_LENGTH (TYPE))
165
166 /* Extract from an array REGBUF containing the (raw) register state
167 the address in which a function should return its structure value,
168 as a CORE_ADDR (or an expression that can be used as one). */
169
170 #define EXTRACT_STRUCT_VALUE_ADDRESS(REGBUF) (*(int *)(REGBUF))
171 \f
172 /* Describe the pointer in each stack frame to the previous stack frame
173 (its caller). */
174
175 /* FRAME_CHAIN takes a frame's nominal address
176 and produces the frame's chain-pointer. */
177
178 /* In the case of the ns32000 series, the frame's nominal address is the FP
179 value, and at that address is saved previous FP value as a 4-byte word. */
180
181 #define FRAME_CHAIN(thisframe) \
182 (!inside_entry_file ((thisframe)->pc) ? \
183 read_memory_integer ((thisframe)->frame, 4) :\
184 0)
185
186 /* Define other aspects of the stack frame. */
187
188 #define FRAME_SAVED_PC(FRAME) (read_memory_integer ((FRAME)->frame + 4, 4))
189
190 /* Compute base of arguments. */
191
192 #define FRAME_ARGS_ADDRESS(fi) \
193 ((ns32k_get_enter_addr ((fi)->pc) > 1) ? \
194 ((fi)->frame) : (read_register (SP_REGNUM) - 4))
195
196 #define FRAME_LOCALS_ADDRESS(fi) ((fi)->frame)
197
198 /* Get the address of the enter opcode for this function, if it is active.
199 Returns positive address > 1 if pc is between enter/exit,
200 1 if pc before enter or after exit, 0 otherwise. */
201
202 extern CORE_ADDR ns32k_get_enter_addr ();
203
204 /* Return number of args passed to a frame.
205 Can return -1, meaning no way to tell. */
206
207 extern int umax_frame_num_args (struct frame_info *fi);
208 #define FRAME_NUM_ARGS(fi) (umax_frame_num_args ((fi)))
209
210 /* Return number of bytes at start of arglist that are not really args. */
211
212 #define FRAME_ARGS_SKIP 8
213
214 /* Put here the code to store, into a struct frame_saved_regs,
215 the addresses of the saved registers of frame described by FRAME_INFO.
216 This includes special registers such as pc and fp saved in special
217 ways in the stack frame. sp is even more special:
218 the address we return for it IS the sp for the next frame. */
219
220 extern int ns32k_localcount (CORE_ADDR enter_pc);
221
222 #define FRAME_FIND_SAVED_REGS(frame_info, frame_saved_regs) \
223 { \
224 register int regmask, regnum; \
225 int localcount; \
226 register CORE_ADDR enter_addr; \
227 register CORE_ADDR next_addr; \
228 \
229 memset (&(frame_saved_regs), '\0', sizeof (frame_saved_regs)); \
230 enter_addr = ns32k_get_enter_addr ((frame_info)->pc); \
231 if (enter_addr > 1) \
232 { \
233 regmask = read_memory_integer (enter_addr+1, 1) & 0xff; \
234 localcount = ns32k_localcount (enter_addr); \
235 next_addr = (frame_info)->frame + localcount; \
236 for (regnum = 0; regnum < 8; regnum++, regmask >>= 1) \
237 (frame_saved_regs).regs[regnum] = (regmask & 1) ? \
238 (next_addr -= 4) : 0; \
239 (frame_saved_regs).regs[SP_REGNUM] = (frame_info)->frame + 4;\
240 (frame_saved_regs).regs[PC_REGNUM] = (frame_info)->frame + 4;\
241 (frame_saved_regs).regs[FP_REGNUM] = \
242 (read_memory_integer ((frame_info)->frame, 4));\
243 } \
244 else if (enter_addr == 1) \
245 { \
246 CORE_ADDR sp = read_register (SP_REGNUM); \
247 (frame_saved_regs).regs[PC_REGNUM] = sp; \
248 (frame_saved_regs).regs[SP_REGNUM] = sp + 4; \
249 } \
250 }
251 \f
252 /* Things needed for making the inferior call functions. */
253
254 /* Push an empty stack frame, to record the current PC, etc. */
255
256 #define PUSH_DUMMY_FRAME \
257 { register CORE_ADDR sp = read_register (SP_REGNUM);\
258 register int regnum; \
259 sp = push_word (sp, read_register (PC_REGNUM)); \
260 sp = push_word (sp, read_register (FP_REGNUM)); \
261 write_register (FP_REGNUM, sp); \
262 for (regnum = 0; regnum < 8; regnum++) \
263 sp = push_word (sp, read_register (regnum)); \
264 write_register (SP_REGNUM, sp); \
265 }
266
267 /* Discard from the stack the innermost frame, restoring all registers. */
268
269 #define POP_FRAME \
270 { register struct frame_info *frame = get_current_frame (); \
271 register CORE_ADDR fp; \
272 register int regnum; \
273 struct frame_saved_regs fsr; \
274 struct frame_info *fi; \
275 fp = frame->frame; \
276 get_frame_saved_regs (frame, &fsr); \
277 for (regnum = 0; regnum < 8; regnum++) \
278 if (fsr.regs[regnum]) \
279 write_register (regnum, read_memory_integer (fsr.regs[regnum], 4)); \
280 write_register (FP_REGNUM, read_memory_integer (fp, 4)); \
281 write_register (PC_REGNUM, read_memory_integer (fp + 4, 4)); \
282 write_register (SP_REGNUM, fp + 8); \
283 flush_cached_frames (); \
284 }
285
286 /* This sequence of words is the instructions
287 enter 0xff,0 82 ff 00
288 jsr @0x00010203 7f ae c0 01 02 03
289 adjspd 0x69696969 7f a5 01 02 03 04
290 bpt f2
291 Note this is 16 bytes. */
292
293 #define CALL_DUMMY { 0x7f00ff82, 0x0201c0ae, 0x01a57f03, 0xf2040302 }
294
295 #define CALL_DUMMY_START_OFFSET 3
296 #define CALL_DUMMY_LENGTH 16
297 #define CALL_DUMMY_ADDR 5
298 #define CALL_DUMMY_NARGS 11
299
300 /* Insert the specified number of args and function address
301 into a call sequence of the above form stored at DUMMYNAME. */
302
303 void flip_bytes (void *ptr, int count);
304
305 #define FIX_CALL_DUMMY(dummyname, pc, fun, nargs, args, type, gcc_p) \
306 { \
307 int flipped; \
308 flipped = fun | 0xc0000000; \
309 flip_bytes (&flipped, 4); \
310 *((int *) (((char *) dummyname)+CALL_DUMMY_ADDR)) = flipped; \
311 flipped = - nargs * 4; \
312 flip_bytes (&flipped, 4); \
313 *((int *) (((char *) dummyname)+CALL_DUMMY_NARGS)) = flipped; \
314 }
This page took 0.040806 seconds and 4 git commands to generate.