Commit | Line | Data |
---|---|---|
e140f1da | 1 | /* Target machine description for generic Motorola 88000, for GDB. |
58dbaabd JG |
2 | Copyright 1986, 1987, 1988, 1989, 1990, 1991, 1993 |
3 | Free Software Foundation, Inc. | |
dd3b648e RP |
4 | |
5 | This file is part of GDB. | |
6 | ||
99a7de40 | 7 | This program is free software; you can redistribute it and/or modify |
dd3b648e | 8 | it under the terms of the GNU General Public License as published by |
99a7de40 JG |
9 | the Free Software Foundation; either version 2 of the License, or |
10 | (at your option) any later version. | |
dd3b648e | 11 | |
99a7de40 | 12 | This program is distributed in the hope that it will be useful, |
dd3b648e RP |
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 | |
99a7de40 JG |
18 | along with this program; if not, write to the Free Software |
19 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ | |
dd3b648e | 20 | |
dd3b648e RP |
21 | /* g++ support is not yet included. */ |
22 | ||
dd3b648e RP |
23 | #define TARGET_BYTE_ORDER BIG_ENDIAN |
24 | ||
e140f1da JG |
25 | /* We cache information about saved registers in the frame structure, |
26 | to save us from having to re-scan function prologues every time | |
27 | a register in a non-current frame is accessed. */ | |
dd3b648e | 28 | |
e140f1da JG |
29 | #define EXTRA_FRAME_INFO \ |
30 | struct frame_saved_regs *fsr; \ | |
31 | CORE_ADDR locals_pointer; \ | |
32 | CORE_ADDR args_pointer; | |
33 | ||
34 | /* Zero the frame_saved_regs pointer when the frame is initialized, | |
35 | so that FRAME_FIND_SAVED_REGS () will know to allocate and | |
36 | initialize a frame_saved_regs struct the first time it is called. | |
37 | Set the arg_pointer to -1, which is not valid; 0 and other values | |
38 | indicate real, cached values. */ | |
dd3b648e | 39 | |
e140f1da JG |
40 | #define INIT_EXTRA_FRAME_INFO(fromleaf, fi) \ |
41 | init_extra_frame_info (fromleaf, fi) | |
42 | extern void init_extra_frame_info (); | |
dd3b648e | 43 | |
e140f1da | 44 | #define IEEE_FLOAT |
dd3b648e | 45 | |
dd3b648e RP |
46 | /* Offset from address of function to start of its code. |
47 | Zero on most machines. */ | |
48 | ||
49 | #define FUNCTION_START_OFFSET 0 | |
50 | ||
51 | /* Advance PC across any function entry prologue instructions | |
52 | to reach some "real" code. */ | |
53 | ||
e140f1da JG |
54 | #define SKIP_PROLOGUE(frompc) \ |
55 | skip_prologue (frompc) | |
56 | extern CORE_ADDR skip_prologue (); | |
dd3b648e RP |
57 | |
58 | /* The m88k kernel aligns all instructions on 4-byte boundaries. The | |
59 | kernel also uses the least significant two bits for its own hocus | |
60 | pocus. When gdb receives an address from the kernel, it needs to | |
61 | preserve those right-most two bits, but gdb also needs to be careful | |
62 | to realize that those two bits are not really a part of the address | |
63 | of an instruction. Shrug. */ | |
64 | ||
65 | #define ADDR_BITS_REMOVE(addr) ((addr) & ~3) | |
66 | #define ADDR_BITS_SET(addr) (((addr) | 0x00000002) - 4) | |
67 | ||
68 | /* Immediately after a function call, return the saved pc. | |
69 | Can't always go through the frames for this because on some machines | |
70 | the new frame is not set up until the new function executes | |
71 | some instructions. */ | |
72 | ||
73 | #define SAVED_PC_AFTER_CALL(frame) \ | |
e140f1da | 74 | (ADDR_BITS_REMOVE (read_register (SRP_REGNUM))) |
dd3b648e RP |
75 | |
76 | /* Stack grows downward. */ | |
77 | ||
78 | #define INNER_THAN < | |
79 | ||
80 | /* Sequence of bytes for breakpoint instruction. */ | |
81 | ||
82 | /* instruction 0xF000D1FF is 'tb0 0,r0,511' | |
83 | If Bit bit 0 of r0 is clear (always true), | |
84 | initiate exception processing (trap). | |
85 | */ | |
86 | #define BREAKPOINT {0xF0, 0x00, 0xD1, 0xFF} | |
87 | ||
88 | /* Amount PC must be decremented by after a breakpoint. | |
89 | This is often the number of bytes in BREAKPOINT | |
90 | but not always. */ | |
91 | ||
92 | #define DECR_PC_AFTER_BREAK 0 | |
93 | ||
94 | /* Nonzero if instruction at PC is a return instruction. */ | |
95 | /* 'jmp r1' or 'jmp.n r1' is used to return from a subroutine. */ | |
96 | ||
97 | #define ABOUT_TO_RETURN(pc) (read_memory_integer (pc, 2) == 0xF800) | |
98 | ||
99 | /* Return 1 if P points to an invalid floating point value. | |
e140f1da | 100 | LEN is the length in bytes. */ |
dd3b648e RP |
101 | |
102 | #define INVALID_FLOAT(p, len) IEEE_isNAN(p,len) | |
103 | ||
104 | /* Say how long (ordinary) registers are. */ | |
105 | ||
106 | #define REGISTER_TYPE long | |
107 | ||
108 | /* Number of machine registers */ | |
109 | ||
110 | #define NUM_REGS 38 | |
111 | ||
112 | /* Initializer for an array of names of registers. | |
113 | There should be NUM_REGS strings in this initializer. */ | |
114 | ||
115 | #define REGISTER_NAMES {\ | |
116 | "r0",\ | |
117 | "r1",\ | |
118 | "r2",\ | |
119 | "r3",\ | |
120 | "r4",\ | |
121 | "r5",\ | |
122 | "r6",\ | |
123 | "r7",\ | |
124 | "r8",\ | |
125 | "r9",\ | |
126 | "r10",\ | |
127 | "r11",\ | |
128 | "r12",\ | |
129 | "r13",\ | |
130 | "r14",\ | |
131 | "r15",\ | |
132 | "r16",\ | |
133 | "r17",\ | |
134 | "r18",\ | |
135 | "r19",\ | |
136 | "r20",\ | |
137 | "r21",\ | |
138 | "r22",\ | |
139 | "r23",\ | |
140 | "r24",\ | |
141 | "r25",\ | |
142 | "r26",\ | |
143 | "r27",\ | |
144 | "r28",\ | |
145 | "r29",\ | |
146 | "r30",\ | |
147 | "r31",\ | |
148 | "psr",\ | |
149 | "fpsr",\ | |
150 | "fpcr",\ | |
151 | "sxip",\ | |
152 | "snip",\ | |
153 | "sfip",\ | |
154 | "vbr",\ | |
155 | "dmt0",\ | |
156 | "dmd0",\ | |
157 | "dma0",\ | |
158 | "dmt1",\ | |
159 | "dmd1",\ | |
160 | "dma1",\ | |
161 | "dmt2",\ | |
162 | "dmd2",\ | |
163 | "dma2",\ | |
164 | "sr0",\ | |
165 | "sr1",\ | |
166 | "sr2",\ | |
167 | "sr3",\ | |
168 | "fpecr",\ | |
169 | "fphs1",\ | |
170 | "fpls1",\ | |
171 | "fphs2",\ | |
172 | "fpls2",\ | |
173 | "fppt",\ | |
174 | "fprh",\ | |
175 | "fprl",\ | |
176 | "fpit",\ | |
177 | "fpsr",\ | |
178 | "fpcr",\ | |
1304f099 | 179 | } |
dd3b648e RP |
180 | |
181 | ||
182 | /* Register numbers of various important registers. | |
183 | Note that some of these values are "real" register numbers, | |
184 | and correspond to the general registers of the machine, | |
185 | and some are "phony" register numbers which are too large | |
186 | to be actual register numbers as far as the user is concerned | |
187 | but do serve to get the desired values when passed to read_register. */ | |
188 | ||
189 | #define SRP_REGNUM 1 /* Contains subroutine return pointer */ | |
190 | #define RV_REGNUM 2 /* Contains simple return values */ | |
191 | #define SRA_REGNUM 12 /* Contains address of struct return values */ | |
e140f1da | 192 | #define FP_REGNUM 31 /* Reg fetched to locate frame when pgm stops */ |
dd3b648e RP |
193 | #define SP_REGNUM 31 /* Contains address of top of stack */ |
194 | #define SXIP_REGNUM 35 /* Contains Shadow Execute Instruction Pointer */ | |
195 | #define SNIP_REGNUM 36 /* Contains Shadow Next Instruction Pointer */ | |
196 | #define PC_REGNUM SXIP_REGNUM /* Program Counter */ | |
197 | #define NPC_REGNUM SNIP_REGNUM /* Next Program Counter */ | |
198 | #define PSR_REGNUM 32 /* Processor Status Register */ | |
199 | #define FPSR_REGNUM 33 /* Floating Point Status Register */ | |
200 | #define FPCR_REGNUM 34 /* Floating Point Control Register */ | |
201 | #define SFIP_REGNUM 37 /* Contains Shadow Fetched Intruction pointer */ | |
202 | #define NNPC_REGNUM SFIP_REGNUM /* Next Next Program Counter */ | |
203 | ||
204 | /* PSR status bit definitions. */ | |
205 | ||
206 | #define PSR_MODE 0x80000000 | |
207 | #define PSR_BYTE_ORDER 0x40000000 | |
208 | #define PSR_SERIAL_MODE 0x20000000 | |
209 | #define PSR_CARRY 0x10000000 | |
210 | #define PSR_SFU_DISABLE 0x000003f0 | |
211 | #define PSR_SFU1_DISABLE 0x00000008 | |
212 | #define PSR_MXM 0x00000004 | |
213 | #define PSR_IND 0x00000002 | |
214 | #define PSR_SFRZ 0x00000001 | |
215 | ||
216 | /* BCS requires that the SXIP_REGNUM (or PC_REGNUM) contain the address | |
217 | of the next instr to be executed when a breakpoint occurs. Because | |
218 | the kernel gets the next instr (SNIP_REGNUM), the instr in SNIP needs | |
219 | to be put back into SFIP, and the instr in SXIP should be shifted | |
220 | to SNIP */ | |
221 | ||
222 | /* Are you sitting down? It turns out that the 88K BCS (binary compatibility | |
223 | standard) folks originally felt that the debugger should be responsible | |
224 | for backing up the IPs, not the kernel (as is usually done). Well, they | |
225 | have reversed their decision, and in future releases our kernel will be | |
226 | handling the backing up of the IPs. So, eventually, we won't need to | |
227 | do the SHIFT_INST_REGS stuff. But, for now, since there are 88K systems out | |
228 | there that do need the debugger to do the IP shifting, and since there | |
229 | will be systems where the kernel does the shifting, the code is a little | |
230 | more complex than perhaps it needs to be (we still go inside SHIFT_INST_REGS, | |
231 | and if the shifting hasn't occurred then gdb goes ahead and shifts). */ | |
232 | ||
233 | #define SHIFT_INST_REGS | |
234 | ||
6ad6ef42 JG |
235 | /* Number of bytes of storage in the actual machine representation |
236 | for register N. */ | |
237 | ||
238 | #define REGISTER_RAW_SIZE(N) 4 | |
239 | ||
dd3b648e RP |
240 | /* Total amount of space needed to store our copies of the machine's |
241 | register state, the array `registers'. */ | |
242 | ||
6ad6ef42 | 243 | #define REGISTER_BYTES (NUM_REGS * REGISTER_RAW_SIZE(0)) |
dd3b648e RP |
244 | |
245 | /* Index within `registers' of the first byte of the space for | |
246 | register N. */ | |
247 | ||
6ad6ef42 | 248 | #define REGISTER_BYTE(N) ((N)*REGISTER_RAW_SIZE(0)) |
dd3b648e RP |
249 | |
250 | /* Number of bytes of storage in the program's representation | |
251 | for register N. */ | |
252 | ||
6ad6ef42 | 253 | #define REGISTER_VIRTUAL_SIZE(N) (REGISTER_RAW_SIZE(N)) |
dd3b648e RP |
254 | |
255 | /* Largest value REGISTER_RAW_SIZE can have. */ | |
256 | ||
6ad6ef42 | 257 | #define MAX_REGISTER_RAW_SIZE (REGISTER_RAW_SIZE(0)) |
dd3b648e RP |
258 | |
259 | /* Largest value REGISTER_VIRTUAL_SIZE can have. | |
260 | /* Are FPS1, FPS2, FPR "virtual" regisers? */ | |
261 | ||
6ad6ef42 | 262 | #define MAX_REGISTER_VIRTUAL_SIZE (REGISTER_RAW_SIZE(0)) |
dd3b648e RP |
263 | |
264 | /* Nonzero if register N requires conversion | |
265 | from raw format to virtual format. */ | |
266 | ||
267 | #define REGISTER_CONVERTIBLE(N) (0) | |
268 | ||
269 | /* Convert data from raw format for register REGNUM | |
270 | to virtual format for register REGNUM. */ | |
271 | ||
6ad6ef42 JG |
272 | #define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,FROM,TO) \ |
273 | {bcopy ((FROM), (TO), REGISTER_RAW_SIZE (REGNUM));} | |
dd3b648e RP |
274 | |
275 | /* Convert data from virtual format for register REGNUM | |
276 | to raw format for register REGNUM. */ | |
277 | ||
2a770cac | 278 | #define REGISTER_CONVERT_TO_RAW(REGNUM,FROM,TO) \ |
6ad6ef42 | 279 | {bcopy ((FROM), (TO), REGISTER_RAW_SIZE (REGNUM));} |
dd3b648e RP |
280 | |
281 | /* Return the GDB type object for the "standard" data type | |
282 | of data in register N. */ | |
283 | ||
284 | #define REGISTER_VIRTUAL_TYPE(N) (builtin_type_int) | |
285 | ||
286 | /* The 88k call/return conventions call for "small" values to be returned | |
287 | into consecutive registers starting from r2. */ | |
288 | ||
289 | #define EXTRACT_RETURN_VALUE(TYPE,REGBUF,VALBUF) \ | |
8aa13b87 | 290 | bcopy (&(((char *)REGBUF)[REGISTER_BYTE(RV_REGNUM)]), (VALBUF), TYPE_LENGTH (TYPE)) |
dd3b648e RP |
291 | |
292 | #define EXTRACT_STRUCT_VALUE_ADDRESS(REGBUF) (*(int *)(REGBUF)) | |
293 | ||
294 | /* Write into appropriate registers a function return value | |
295 | of type TYPE, given in virtual format. */ | |
296 | ||
297 | #define STORE_RETURN_VALUE(TYPE,VALBUF) \ | |
6ad6ef42 | 298 | write_register_bytes (2*REGISTER_RAW_SIZE(0), (VALBUF), TYPE_LENGTH (TYPE)) |
dd3b648e RP |
299 | |
300 | /* In COFF, if PCC says a parameter is a short or a char, do not | |
301 | change it to int (it seems the convention is to change it). */ | |
302 | ||
303 | #define BELIEVE_PCC_PROMOTION 1 | |
304 | ||
305 | /* Describe the pointer in each stack frame to the previous stack frame | |
306 | (its caller). */ | |
307 | ||
308 | /* FRAME_CHAIN takes a frame's nominal address | |
309 | and produces the frame's chain-pointer. | |
310 | ||
dd3b648e | 311 | However, if FRAME_CHAIN_VALID returns zero, |
e140f1da | 312 | it means the given frame is the outermost one and has no caller. */ |
dd3b648e | 313 | |
e140f1da JG |
314 | extern CORE_ADDR frame_chain (); |
315 | extern int frame_chain_valid (); | |
316 | extern int frameless_function_invocation (); | |
dd3b648e | 317 | |
e140f1da JG |
318 | #define FRAME_CHAIN(thisframe) \ |
319 | frame_chain (thisframe) | |
dd3b648e | 320 | |
e140f1da JG |
321 | #define FRAME_CHAIN_VALID(chain, thisframe) \ |
322 | frame_chain_valid (chain, thisframe) | |
dd3b648e | 323 | |
e140f1da JG |
324 | #define FRAMELESS_FUNCTION_INVOCATION(frame, fromleaf) \ |
325 | fromleaf = frameless_function_invocation (frame) | |
dd3b648e RP |
326 | |
327 | /* Define other aspects of the stack frame. */ | |
328 | ||
e140f1da JG |
329 | #define FRAME_SAVED_PC(FRAME) \ |
330 | frame_saved_pc (FRAME) | |
331 | extern CORE_ADDR frame_saved_pc (); | |
dd3b648e | 332 | |
e140f1da JG |
333 | #define FRAME_ARGS_ADDRESS(fi) \ |
334 | frame_args_address (fi) | |
335 | extern CORE_ADDR frame_args_address (); | |
dd3b648e | 336 | |
e140f1da JG |
337 | #define FRAME_LOCALS_ADDRESS(fi) \ |
338 | frame_locals_address (fi) | |
339 | extern CORE_ADDR frame_locals_address (); | |
dd3b648e RP |
340 | |
341 | /* Return number of args passed to a frame. | |
342 | Can return -1, meaning no way to tell. */ | |
343 | ||
344 | #define FRAME_NUM_ARGS(numargs, fi) ((numargs) = -1) | |
345 | ||
346 | /* Return number of bytes at start of arglist that are not really args. */ | |
347 | ||
348 | #define FRAME_ARGS_SKIP 0 | |
349 | ||
350 | /* Put here the code to store, into a struct frame_saved_regs, | |
351 | the addresses of the saved registers of frame described by FRAME_INFO. | |
352 | This includes special registers such as pc and fp saved in special | |
353 | ways in the stack frame. sp is even more special: | |
354 | the address we return for it IS the sp for the next frame. */ | |
355 | ||
356 | /* On the 88k, parameter registers get stored into the so called "homing" | |
357 | area. This *always* happens when you compiled with GCC and use -g. | |
358 | Also, (with GCC and -g) the saving of the parameter register values | |
359 | always happens right within the function prologue code, so these register | |
360 | values can generally be relied upon to be already copied into their | |
361 | respective homing slots by the time you will normally try to look at | |
362 | them (we hope). | |
363 | ||
364 | Note that homing area stack slots are always at *positive* offsets from | |
365 | the frame pointer. Thus, the homing area stack slots for the parameter | |
366 | registers (passed values) for a given function are actually part of the | |
367 | frame area of the caller. This is unusual, but it should not present | |
368 | any special problems for GDB. | |
369 | ||
370 | Note also that on the 88k, we are only interested in finding the | |
371 | registers that might have been saved in memory. This is a subset of | |
372 | the whole set of registers because the standard calling sequence allows | |
373 | the called routine to clobber many registers. | |
374 | ||
375 | We could manage to locate values for all of the so called "preserved" | |
376 | registers (some of which may get saved within any particular frame) but | |
377 | that would require decoding all of the tdesc information. Tht would be | |
378 | nice information for GDB to have, but it is not strictly manditory if we | |
379 | can live without the ability to look at values within (or backup to) | |
380 | previous frames. | |
381 | */ | |
382 | ||
383 | #define FRAME_FIND_SAVED_REGS(frame_info, frame_saved_regs) \ | |
384 | frame_find_saved_regs (frame_info, &frame_saved_regs) | |
385 | ||
386 | \f | |
8aa13b87 JK |
387 | /* There is not currently a functioning way to call functions in the |
388 | inferior. */ | |
389 | ||
390 | /* But if there was this is where we'd put the call dummy. */ | |
391 | /* #define CALL_DUMMY_LOCATION AFTER_TEXT_END */ | |
392 | ||
dd3b648e RP |
393 | /* When popping a frame on the 88k (say when doing a return command), the |
394 | calling function only expects to have the "preserved" registers restored. | |
395 | Thus, those are the only ones that we even try to restore here. */ | |
396 | ||
dd3b648e | 397 | #define POP_FRAME pop_frame () |
e140f1da | 398 | extern void pop_frame (); |