Update/correct copyright notices.
[deliverable/binutils-gdb.git] / gdb / config / ns32k / tm-merlin.h
1 /* Definitions to target GDB to a merlin under utek 2.1
2 Copyright 1986, 1987, 1989, 1991, 1993, 1994, 1998, 1999, 2000
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 #define TARGET_BYTE_ORDER LITTLE_ENDIAN
23
24 /* Offset from address of function to start of its code.
25 Zero on most machines. */
26
27 #define FUNCTION_START_OFFSET 0
28
29 /* Advance PC across any function entry prologue instructions
30 to reach some "real" code. */
31
32 extern CORE_ADDR merlin_skip_prologue (CORE_ADDR);
33 #define SKIP_PROLOGUE(pc) (merlin_skip_prologue (pc))
34
35 /* Immediately after a function call, return the saved pc.
36 Can't always go through the frames for this because on some machines
37 the new frame is not set up until the new function executes
38 some instructions. */
39
40 #define SAVED_PC_AFTER_CALL(frame) \
41 read_memory_integer (read_register (SP_REGNUM), 4)
42
43 /* Address of end of stack space. */
44
45 #define STACK_END_ADDR (0x800000)
46
47 /* Stack grows downward. */
48
49 #define INNER_THAN(lhs,rhs) ((lhs) < (rhs))
50
51 /* Sequence of bytes for breakpoint instruction. */
52
53 #define BREAKPOINT {0xf2}
54
55 /* Amount PC must be decremented by after a breakpoint.
56 This is often the number of bytes in BREAKPOINT
57 but not always. */
58
59 #define DECR_PC_AFTER_BREAK 0
60
61 /* Define this to say that the "svc" insn is followed by
62 codes in memory saying which kind of system call it is. */
63
64 #define NS32K_SVC_IMMED_OPERANDS
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
74 #define NUM_REGS 25
75
76 #define NUM_GENERAL_REGS 8
77
78 /* Initializer for an array of names of registers.
79 There should be NUM_REGS strings in this initializer. */
80
81 #define REGISTER_NAMES {"r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", \
82 "pc", "sp", "fp", "ps", \
83 "fsr", \
84 "f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7", \
85 "l0", "l1", "l2", "l3", "l4", \
86 }
87
88 /* Register numbers of various important registers.
89 Note that some of these values are "real" register numbers,
90 and correspond to the general registers of the machine,
91 and some are "phony" register numbers which are too large
92 to be actual register numbers as far as the user is concerned
93 but do serve to get the desired values when passed to read_register. */
94
95 #define AP_REGNUM FP_REGNUM
96 #define FP_REGNUM 10 /* Contains address of executing stack frame */
97 #define SP_REGNUM 9 /* Contains address of top of stack */
98 #define PC_REGNUM 8 /* Contains program counter */
99 #define PS_REGNUM 11 /* Contains processor status */
100 #define FPS_REGNUM 12 /* Floating point status register */
101 #define FP0_REGNUM 13 /* Floating point register 0 */
102 #define LP0_REGNUM 21 /* Double register 0 (same as FP0) */
103
104 /* Total amount of space needed to store our copies of the machine's
105 register state, the array `registers'. */
106 #define REGISTER_BYTES ((NUM_REGS - 4) * sizeof (int) + 4 * sizeof (double))
107
108 /* Index within `registers' of the first byte of the space for
109 register N. */
110
111 #define REGISTER_BYTE(N) ((N) >= LP0_REGNUM ? \
112 LP0_REGNUM * 4 + ((N) - LP0_REGNUM) * 8 : (N) * 4)
113
114 /* Number of bytes of storage in the actual machine representation
115 for register N. On the 32000, all regs are 4 bytes
116 except for the doubled floating registers. */
117
118 #define REGISTER_RAW_SIZE(N) ((N) >= LP0_REGNUM ? 8 : 4)
119
120 /* Number of bytes of storage in the program's representation
121 for register N. On the 32000, all regs are 4 bytes
122 except for the doubled floating registers. */
123
124 #define REGISTER_VIRTUAL_SIZE(N) ((N) >= LP0_REGNUM ? 8 : 4)
125
126 /* Largest value REGISTER_RAW_SIZE can have. */
127
128 #define MAX_REGISTER_RAW_SIZE 8
129
130 /* Largest value REGISTER_VIRTUAL_SIZE can have. */
131
132 #define MAX_REGISTER_VIRTUAL_SIZE 8
133
134 /* Return the GDB type object for the "standard" data type
135 of data in register N. */
136
137 #define REGISTER_VIRTUAL_TYPE(N) \
138 ((N) >= FP0_REGNUM ? \
139 ((N) >= LP0_REGNUM ? \
140 builtin_type_double \
141 : builtin_type_float) \
142 : builtin_type_int)
143
144 /* Store the address of the place in which to copy the structure the
145 subroutine will return. This is called from call_function.
146
147 On this machine this is a no-op, as gcc doesn't run on it yet.
148 This calling convention is not used. */
149
150 #define STORE_STRUCT_RETURN(ADDR, SP)
151
152 /* Extract from an array REGBUF containing the (raw) register state
153 a function return value of type TYPE, and copy that, in virtual format,
154 into VALBUF. */
155
156 #define EXTRACT_RETURN_VALUE(TYPE,REGBUF,VALBUF) \
157 memcpy (VALBUF, REGBUF, TYPE_LENGTH (TYPE))
158
159 /* Write into appropriate registers a function return value
160 of type TYPE, given in virtual format. */
161
162 #define STORE_RETURN_VALUE(TYPE,VALBUF) \
163 write_register_bytes (0, VALBUF, TYPE_LENGTH (TYPE))
164
165 /* Extract from an array REGBUF containing the (raw) register state
166 the address in which a function should return its structure value,
167 as a CORE_ADDR (or an expression that can be used as one). */
168
169 #define EXTRACT_STRUCT_VALUE_ADDRESS(REGBUF) (*(int *)(REGBUF))
170 \f
171 /* Describe the pointer in each stack frame to the previous stack frame
172 (its caller). */
173
174 /* FRAME_CHAIN takes a frame's nominal address
175 and produces the frame's chain-pointer. */
176
177 /* In the case of the Merlin, the frame's nominal address is the FP value,
178 and at that address is saved previous FP value as a 4-byte word. */
179
180 #define FRAME_CHAIN(thisframe) \
181 (!inside_entry_file ((thisframe)->pc) ? \
182 read_memory_integer ((thisframe)->frame, 4) :\
183 0)
184
185 /* Define other aspects of the stack frame. */
186
187 #define FRAME_SAVED_PC(FRAME) (read_memory_integer ((FRAME)->frame + 4, 4))
188
189 /* compute base of arguments */
190 #define FRAME_ARGS_ADDRESS(fi) ((fi)->frame)
191
192 #define FRAME_LOCALS_ADDRESS(fi) ((fi)->frame)
193
194 /* Return number of args passed to a frame.
195 Can return -1, meaning no way to tell. */
196
197 extern int merlin_frame_num_args (struct frame_info *fi);
198 #define FRAME_NUM_ARGS(fi) (merlin_frame_num_args ((fi)))
199
200 /* Return number of bytes at start of arglist that are not really args. */
201
202 #define FRAME_ARGS_SKIP 8
203
204 /* Put here the code to store, into a struct frame_saved_regs,
205 the addresses of the saved registers of frame described by FRAME_INFO.
206 This includes special registers such as pc and fp saved in special
207 ways in the stack frame. sp is even more special:
208 the address we return for it IS the sp for the next frame. */
209
210 #define FRAME_FIND_SAVED_REGS(frame_info, frame_saved_regs) \
211 { int regmask,regnum; \
212 int localcount; \
213 CORE_ADDR enter_addr; \
214 CORE_ADDR next_addr; \
215 \
216 enter_addr = get_pc_function_start ((frame_info)->pc); \
217 regmask = read_memory_integer (enter_addr+1, 1); \
218 localcount = ns32k_localcount (enter_addr); \
219 next_addr = (frame_info)->frame + localcount; \
220 for (regnum = 0; regnum < 8; regnum++, regmask >>= 1) \
221 (frame_saved_regs).regs[regnum] \
222 = (regmask & 1) ? (next_addr -= 4) : 0; \
223 (frame_saved_regs).regs[SP_REGNUM] = (frame_info)->frame + 4; \
224 (frame_saved_regs).regs[PC_REGNUM] = (frame_info)->frame + 4; \
225 (frame_saved_regs).regs[FP_REGNUM] \
226 = read_memory_integer ((frame_info)->frame, 4); }
227 \f
228
229 /* Things needed for making the inferior call functions. */
230
231 /* Push an empty stack frame, to record the current PC, etc. */
232
233 #define PUSH_DUMMY_FRAME \
234 { register CORE_ADDR sp = read_register (SP_REGNUM); \
235 register int regnum; \
236 sp = push_word (sp, read_register (PC_REGNUM)); \
237 sp = push_word (sp, read_register (FP_REGNUM)); \
238 write_register (FP_REGNUM, sp); \
239 for (regnum = 0; regnum < 8; regnum++) \
240 sp = push_word (sp, read_register (regnum)); \
241 write_register (SP_REGNUM, sp); \
242 }
243
244 /* Discard from the stack the innermost frame, restoring all registers. */
245
246 #define POP_FRAME \
247 { register struct frame_info *frame = get_current_frame (); \
248 register CORE_ADDR fp; \
249 register int regnum; \
250 struct frame_saved_regs fsr; \
251 struct frame_info *fi; \
252 fp = frame->frame; \
253 get_frame_saved_regs (frame, &fsr); \
254 for (regnum = 0; regnum < 8; regnum++) \
255 if (fsr.regs[regnum]) \
256 write_register (regnum, read_memory_integer (fsr.regs[regnum], 4)); \
257 write_register (FP_REGNUM, read_memory_integer (fp, 4)); \
258 write_register (PC_REGNUM, read_memory_integer (fp + 4, 4)); \
259 write_register (SP_REGNUM, fp + 8); \
260 flush_cached_frames (); \
261 }
262
263 /* This sequence of words is the instructions
264 enter 0xff,0 82 ff 00
265 jsr @0x00010203 7f ae c0 01 02 03
266 adjspd 0x69696969 7f a5 01 02 03 04
267 bpt f2
268 Note this is 16 bytes. */
269
270 #define CALL_DUMMY { 0x7f00ff82, 0x0201c0ae, 0x01a57f03, 0xf2040302 }
271
272 #define CALL_DUMMY_START_OFFSET 3
273 #define CALL_DUMMY_LENGTH 16
274 #define CALL_DUMMY_ADDR 5
275 #define CALL_DUMMY_NARGS 11
276
277 /* Insert the specified number of args and function address
278 into a call sequence of the above form stored at DUMMYNAME. */
279
280 #define FIX_CALL_DUMMY(dummyname, pc, fun, nargs, args, type, gcc_p) \
281 { int flipped = fun | 0xc0000000; \
282 flip_bytes (&flipped, 4); \
283 *((int *) (((char *) dummyname)+CALL_DUMMY_ADDR)) = flipped; \
284 flipped = - nargs * 4; \
285 flip_bytes (&flipped, 4); \
286 *((int *) (((char *) dummyname)+CALL_DUMMY_NARGS)) = flipped; \
287 }
This page took 0.035608 seconds and 4 git commands to generate.