]>
Commit | Line | Data |
---|---|---|
5140562f JG |
1 | /* Parameters for execution on a Hewlett-Packard PA-RISC machine. |
2 | Copyright 1986, 1987, 1989, 1990, 1991, 1992 Free Software Foundation, Inc. | |
3 | ||
4 | Contributed by the Center for Software Science at the | |
5 | University of Utah ([email protected]). | |
6 | ||
7 | This file is part of GDB. | |
8 | ||
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. | |
13 | ||
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. | |
18 | ||
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., 675 Mass Ave, Cambridge, MA 02139, USA. */ | |
22 | ||
23 | /* Target system byte order. */ | |
24 | ||
25 | #define TARGET_BYTE_ORDER BIG_ENDIAN | |
26 | ||
27 | /* Get at various relevent fields of an instruction word. */ | |
28 | ||
29 | #define MASK_5 0x1f | |
30 | #define MASK_11 0x7ff | |
31 | #define MASK_14 0x3fff | |
32 | #define MASK_21 0x1fffff | |
33 | ||
34 | /* This macro gets bit fields using HP's numbering (MSB = 0) */ | |
35 | ||
36 | #define GET_FIELD(X, FROM, TO) \ | |
37 | ((X) >> 31 - (TO) & (1 << ((TO) - (FROM) + 1)) - 1) | |
38 | ||
39 | /* Watch out for NaNs */ | |
40 | ||
41 | #define IEEE_FLOAT | |
42 | ||
43 | /* Groan */ | |
44 | ||
45 | #define ARGS_GROW_DOWN | |
46 | ||
47 | /* Define this if the C compiler puts an underscore at the front | |
48 | of external names before giving them to the linker. */ | |
49 | ||
50 | /* #define NAMES_HAVE_UNDERSCORE */ | |
51 | ||
52 | /* Offset from address of function to start of its code. | |
53 | Zero on most machines. */ | |
54 | ||
55 | #define FUNCTION_START_OFFSET 0 | |
56 | ||
57 | /* Advance PC across any function entry prologue instructions | |
58 | to reach some "real" code. */ | |
59 | ||
60 | /* skip (stw rp, -20(0,sp)); copy 4,1; copy sp, 4; stwm 1,framesize(sp) | |
61 | for gcc, or (stw rp, -20(0,sp); stwm 1, framesize(sp) for hcc */ | |
62 | ||
63 | #define SKIP_PROLOGUE(pc) \ | |
64 | { if (read_memory_integer ((pc), 4) == 0x6BC23FD9) \ | |
65 | { if (read_memory_integer ((pc) + 4, 4) == 0x8040241) \ | |
66 | (pc) += 16; \ | |
67 | else if ((read_memory_integer (pc + 4, 4) & ~MASK_14) == 0x68810000) \ | |
68 | (pc) += 8;} \ | |
69 | else if (read_memory_integer ((pc), 4) == 0x8040241) \ | |
70 | (pc) += 12; \ | |
71 | else if ((read_memory_integer (pc, 4) & ~MASK_14) == 0x68810000) \ | |
72 | (pc) += 4;} | |
73 | ||
74 | /* Immediately after a function call, return the saved pc. | |
75 | Can't go through the frames for this because on some machines | |
76 | the new frame is not set up until the new function executes | |
77 | some instructions. */ | |
78 | ||
79 | #define SAVED_PC_AFTER_CALL(frame) (read_register (RP_REGNUM) & ~3) | |
80 | ||
81 | /* Address of end of stack space. Who knows. */ | |
82 | ||
83 | #define STACK_END_ADDR 0x80000000 | |
84 | ||
85 | /* Stack grows upward */ | |
86 | ||
87 | #define INNER_THAN > | |
88 | ||
89 | ||
90 | /* Sequence of bytes for breakpoint instruction. */ | |
91 | ||
92 | /*#define BREAKPOINT {0x00, 0x00, 0x00, 0x00}*/ | |
93 | #ifdef KERNELDEBUG /* XXX */ | |
94 | #define BREAKPOINT {0x00, 0x00, 0xa0, 0x00} | |
95 | #else | |
96 | #define BREAKPOINT {0x00, 0x01, 0x00, 0x04} | |
97 | #endif | |
98 | ||
99 | /* Amount PC must be decremented by after a breakpoint. | |
100 | This is often the number of bytes in BREAKPOINT | |
101 | but not always. | |
102 | ||
103 | Not on the PA-RISC */ | |
104 | ||
105 | #define DECR_PC_AFTER_BREAK 0 | |
106 | ||
107 | /* return instruction is bv r0(rp) */ | |
108 | ||
109 | #define ABOUT_TO_RETURN(pc) (read_memory_integer (pc, 4) == 0xE840C000) | |
110 | ||
111 | /* Return 1 if P points to an invalid floating point value. */ | |
112 | ||
113 | #define INVALID_FLOAT(p, len) 0 /* Just a first guess; not checked */ | |
114 | ||
115 | /* Largest integer type */ | |
116 | #define LONGEST long | |
117 | ||
118 | /* Name of the builtin type for the LONGEST type above. */ | |
119 | #define BUILTIN_TYPE_LONGEST builtin_type_long | |
120 | ||
121 | /* Say how long (ordinary) registers are. */ | |
122 | ||
123 | #define REGISTER_TYPE long | |
124 | ||
125 | /* Number of machine registers */ | |
126 | ||
127 | #define NUM_REGS 100 | |
128 | ||
129 | /* Initializer for an array of names of registers. | |
130 | There should be NUM_REGS strings in this initializer. */ | |
131 | ||
132 | #define REGISTER_NAMES \ | |
133 | {"flags", "r1", "rp", "r3", "r4", "r5", "r6", "r7", "r8", "r9", \ | |
134 | "r10", "r11", "r12", "r13", "r14", "r15", "r16", "r17", "r18", "r19", \ | |
135 | "r20", "r21", "r22", "arg3", "arg2", "arg1", "arg0", "dp", "ret0", "ret1", \ | |
136 | "sp", "r31", "sar", "pcoqh", "pcsqh", "pcoqt", "pcsqt", \ | |
137 | "eiem", "iir", "isr", "ior", "ipsw", "goto", "sr4", "sr0", "sr1", "sr2", \ | |
138 | "sr3", "sr5", "sr6", "sr7", "cr0", "cr8", "cr9", "ccr", "cr12", "cr13", \ | |
139 | "cr24", "cr25", "cr26", "mpsfu_high", "mpsfu_low", "mpsfu_ovflo", "pad", \ | |
140 | "fpsr", "fpe1", "fpe2", "fpe3", "fpe4", "fpe5", "fpe6", "fpe7", \ | |
141 | "fp4", "fp5", "fp6", "fp7", "fp8", \ | |
142 | "fp9", "fp10", "fp11", "fp12", "fp13", "fp14", "fp15", \ | |
143 | "fp16", "fp17", "fp18", "fp19", "fp20", "fp21", "fp22", "fp23", \ | |
144 | "fp24", "fp25", "fp26", "fp27", "fp28", "fp29", "fp30", "fp31"} | |
145 | ||
146 | /* Register numbers of various important registers. | |
147 | Note that some of these values are "real" register numbers, | |
148 | and correspond to the general registers of the machine, | |
149 | and some are "phony" register numbers which are too large | |
150 | to be actual register numbers as far as the user is concerned | |
151 | but do serve to get the desired values when passed to read_register. */ | |
152 | ||
153 | #define RP_REGNUM 2 /* return pointer */ | |
154 | #define FP_REGNUM 4 /* Contains address of executing stack */ | |
155 | /* frame */ | |
156 | #define SP_REGNUM 30 /* Contains address of top of stack */ | |
157 | #define SAR_REGNUM 32 /* shift amount register */ | |
158 | #define IPSW_REGNUM 41 /* processor status word. ? */ | |
159 | #define PCOQ_HEAD_REGNUM 33 /* instruction offset queue head */ | |
160 | #define PCSQ_HEAD_REGNUM 34 /* instruction space queue head */ | |
161 | #define PCOQ_TAIL_REGNUM 35 /* instruction offset queue tail */ | |
162 | #define PCSQ_TAIL_REGNUM 36 /* instruction space queue tail */ | |
163 | #define FP0_REGNUM 64 /* floating point reg. 0 */ | |
164 | #define FP4_REGNUM 72 | |
165 | ||
166 | /* compatibility with the rest of gdb. */ | |
167 | #define PC_REGNUM PCOQ_HEAD_REGNUM | |
168 | #define NPC_REGNUM PCOQ_TAIL_REGNUM | |
169 | ||
170 | /* Define DO_REGISTERS_INFO() to do machine-specific formatting | |
171 | of register dumps. */ | |
172 | ||
173 | #define DO_REGISTERS_INFO(_regnum, fp) pa_do_registers_info (_regnum, fp) | |
174 | ||
175 | /* PA specific macro to see if the current instruction is nullified. */ | |
176 | #define INSTRUCTION_NULLIFIED ((int)read_register (IPSW_REGNUM) & 0x00200000) | |
177 | ||
178 | /* Total amount of space needed to store our copies of the machine's | |
179 | register state, the array `registers'. */ | |
180 | #define REGISTER_BYTES (32 * 4 + 11 * 4 + 8 * 4 + 12 * 4 + 4 + 32 * 8) | |
181 | ||
182 | /* Index within `registers' of the first byte of the space for | |
183 | register N. */ | |
184 | ||
185 | #define REGISTER_BYTE(N) \ | |
186 | ((N) >= FP4_REGNUM ? ((N) - FP4_REGNUM) * 8 + 288 : (N) * 4) | |
187 | ||
188 | /* Number of bytes of storage in the actual machine representation | |
189 | for register N. On the PA-RISC, all regs are 4 bytes | |
190 | except the floating point regs which are 8 bytes. */ | |
191 | ||
192 | #define REGISTER_RAW_SIZE(N) ((N) < FP4_REGNUM ? 4 : 8) | |
193 | ||
194 | /* Number of bytes of storage in the program's representation | |
195 | for register N. */ | |
196 | ||
197 | #define REGISTER_VIRTUAL_SIZE(N) REGISTER_RAW_SIZE(N) | |
198 | ||
199 | /* Largest value REGISTER_RAW_SIZE can have. */ | |
200 | ||
201 | #define MAX_REGISTER_RAW_SIZE 8 | |
202 | ||
203 | /* Largest value REGISTER_VIRTUAL_SIZE can have. */ | |
204 | ||
205 | #define MAX_REGISTER_VIRTUAL_SIZE 8 | |
206 | ||
207 | /* Nonzero if register N requires conversion | |
208 | from raw format to virtual format. */ | |
209 | ||
210 | #define REGISTER_CONVERTIBLE(N) 0 | |
211 | ||
212 | /* Convert data from raw format for register REGNUM | |
213 | to virtual format for register REGNUM. */ | |
214 | ||
215 | #define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,FROM,TO) \ | |
216 | { bcopy ((FROM), (TO), (REGNUM) < FP4_REGNUM ? 4 : 8); } | |
217 | ||
218 | /* Convert data from virtual format for register REGNUM | |
219 | to raw format for register REGNUM. */ | |
220 | ||
221 | #define REGISTER_CONVERT_TO_RAW(REGNUM,FROM,TO) \ | |
222 | { bcopy ((FROM), (TO), (REGNUM) < FP4_REGNUM ? 4 : 8); } | |
223 | ||
224 | /* Return the GDB type object for the "standard" data type | |
225 | of data in register N. */ | |
226 | ||
227 | #define REGISTER_VIRTUAL_TYPE(N) \ | |
228 | ((N) < FP4_REGNUM ? builtin_type_int : builtin_type_double) | |
229 | ||
230 | /* Store the address of the place in which to copy the structure the | |
231 | subroutine will return. This is called from call_function. */ | |
232 | ||
233 | #define STORE_STRUCT_RETURN(ADDR, SP) {write_register (28, (ADDR)); } | |
234 | ||
235 | /* Extract from an array REGBUF containing the (raw) register state | |
236 | a function return value of type TYPE, and copy that, in virtual format, | |
237 | into VALBUF. */ | |
238 | ||
239 | #define EXTRACT_RETURN_VALUE(TYPE,REGBUF,VALBUF) \ | |
240 | bcopy ((REGBUF) + REGISTER_BYTE(TYPE_LENGTH(TYPE) > 4 ? \ | |
241 | FP4_REGNUM :28), VALBUF, TYPE_LENGTH (TYPE)) | |
242 | ||
243 | /* Write into appropriate registers a function return value | |
244 | of type TYPE, given in virtual format. */ | |
245 | ||
246 | #define STORE_RETURN_VALUE(TYPE,VALBUF) \ | |
247 | write_register_bytes (TYPE_LENGTH(TYPE) > 4 ? FP4_REGNUM :28, \ | |
248 | VALBUF, TYPE_LENGTH (TYPE)) | |
249 | ||
250 | /* Extract from an array REGBUF containing the (raw) register state | |
251 | the address in which a function should return its structure value, | |
252 | as a CORE_ADDR (or an expression that can be used as one). */ | |
253 | ||
254 | #define EXTRACT_STRUCT_VALUE_ADDRESS(REGBUF) (*(int *)((REGBUF) + 28)) | |
255 | ||
256 | /* This is a piece of magic that is given a register number REGNO | |
257 | and as BLOCKEND the address in the system of the end of the user structure | |
258 | and stores in ADDR the address in the kernel or core dump | |
259 | of that register. */ | |
260 | ||
261 | ||
262 | /* Describe the pointer in each stack frame to the previous stack frame | |
263 | (its caller). */ | |
264 | ||
265 | /* FRAME_CHAIN takes a frame's nominal address | |
266 | and produces the frame's chain-pointer. | |
267 | ||
268 | FRAME_CHAIN_COMBINE takes the chain pointer and the frame's nominal address | |
269 | and produces the nominal address of the caller frame. | |
270 | ||
271 | However, if FRAME_CHAIN_VALID returns zero, | |
272 | it means the given frame is the outermost one and has no caller. | |
273 | In that case, FRAME_CHAIN_COMBINE is not used. */ | |
274 | ||
275 | /* In the case of the PA-RISC, the frame's nominal address | |
276 | is the address of a 4-byte word containing the calling frame's | |
277 | address (previous FP). */ | |
278 | ||
279 | #define FRAME_CHAIN(thisframe) \ | |
280 | (inside_entry_file ((thisframe)->pc) ? \ | |
281 | read_memory_integer ((thisframe)->frame, 4) :\ | |
282 | 0) | |
283 | ||
284 | #define FRAME_CHAIN_VALID(chain, thisframe) \ | |
285 | frame_chain_valid (chain, thisframe) | |
286 | ||
287 | #define FRAME_CHAIN_COMBINE(chain, thisframe) (chain) | |
288 | ||
289 | /* Define other aspects of the stack frame. */ | |
290 | ||
291 | /* A macro that tells us whether the function invocation represented | |
292 | by FI does not have a frame on the stack associated with it. If it | |
293 | does not, FRAMELESS is set to 1, else 0. */ | |
294 | #define FRAMELESS_FUNCTION_INVOCATION(FI, FRAMELESS) \ | |
295 | (FRAMELESS) = frameless_look_for_prologue(FI) | |
296 | ||
297 | #define FRAME_SAVED_PC(FRAME) frame_saved_pc (FRAME) | |
298 | ||
299 | #define FRAME_ARGS_ADDRESS(fi) ((fi)->frame) | |
300 | ||
301 | #define FRAME_LOCALS_ADDRESS(fi) ((fi)->frame) | |
302 | /* Set VAL to the number of args passed to frame described by FI. | |
303 | Can set VAL to -1, meaning no way to tell. */ | |
304 | ||
305 | /* We can't tell how many args there are | |
306 | now that the C compiler delays popping them. */ | |
307 | #define FRAME_NUM_ARGS(val,fi) (val = -1) | |
308 | ||
309 | /* Return number of bytes at start of arglist that are not really args. */ | |
310 | ||
311 | #define FRAME_ARGS_SKIP 0 | |
312 | ||
313 | /* Put here the code to store, into a struct frame_saved_regs, | |
314 | the addresses of the saved registers of frame described by FRAME_INFO. | |
315 | This includes special registers such as pc and fp saved in special | |
316 | ways in the stack frame. sp is even more special: | |
317 | the address we return for it IS the sp for the next frame. */ | |
318 | ||
319 | /* Deal with dummy functions later. */ | |
320 | ||
321 | #define STW_P(INSN) (((INSN) & 0xfc000000) == 0x68000000) | |
322 | #define ADDIL_P(INSN) (((INSN) & 0xfc000000) == 0x28000000) | |
323 | #define LDO_P(INSN) (((INSN) & 0xfc00c000) == 0x34000000) | |
324 | ||
325 | ||
326 | #define FRAME_FIND_SAVED_REGS(frame_info, frame_saved_regs) \ | |
327 | { register int regnum; \ | |
328 | register CORE_ADDR next_addr; \ | |
329 | register CORE_ADDR pc; \ | |
330 | unsigned this_insn; \ | |
331 | unsigned address; \ | |
332 | \ | |
333 | bzero (&frame_saved_regs, sizeof frame_saved_regs); \ | |
334 | if ((frame_info)->pc <= ((frame_info)->frame - CALL_DUMMY_LENGTH - \ | |
335 | FP_REGNUM * 4 - 16 * 8) \ | |
336 | && (frame_info)->pc > (frame_info)->frame) \ | |
337 | find_dummy_frame_regs ((frame_info), &(frame_saved_regs)); \ | |
338 | else \ | |
339 | { pc = get_pc_function_start ((frame_info)->pc); \ | |
340 | if (read_memory_integer (pc, 4) == 0x6BC23FD9) \ | |
341 | { (frame_saved_regs).regs[RP_REGNUM] = (frame_info)->frame - 20;\ | |
342 | pc = pc + 4; \ | |
343 | } \ | |
344 | if (read_memory_integer (pc, 4) != 0x8040241) goto lose; \ | |
345 | pc += 8; /* skip "copy 4,1; copy 30, 4" */ \ | |
346 | /* skip either "stw 1,0(4);addil L'fsize,30;ldo R'fsize(1),30" \ | |
347 | or "stwm 1,fsize(30)" */ \ | |
348 | if ((read_memory_integer (pc, 4) & ~MASK_14) == 0x68810000) \ | |
349 | pc += 12; \ | |
350 | else \ | |
351 | pc += 4; \ | |
352 | while (1) \ | |
353 | { this_insn = read_memory_integer(pc, 4); \ | |
354 | if (STW_P (this_insn)) /* stw */ \ | |
355 | { regnum = GET_FIELD (this_insn, 11, 15); \ | |
356 | if (!regnum) goto lose; \ | |
357 | (frame_saved_regs).regs[regnum] = (frame_info)->frame + \ | |
358 | extract_14 (this_insn); \ | |
359 | pc += 4; \ | |
360 | } \ | |
361 | else if (ADDIL_P (this_insn)) /* addil */ \ | |
362 | { int next_insn; \ | |
363 | next_insn = read_memory_integer(pc + 4, 4); \ | |
364 | if (STW_P (next_insn)) /* stw */ \ | |
365 | { regnum = GET_FIELD (this_insn, 6, 10); \ | |
366 | if (!regnum) goto lose; \ | |
367 | (frame_saved_regs).regs[regnum] = (frame_info)->frame +\ | |
368 | (extract_21 (this_insn) << 11) + extract_14 (next_insn);\ | |
369 | pc += 8; \ | |
370 | } \ | |
371 | else \ | |
372 | break; \ | |
373 | } \ | |
374 | else \ | |
375 | { pc += 4; \ | |
376 | break; \ | |
377 | } \ | |
378 | } \ | |
379 | this_insn = read_memory_integer (pc, 4); \ | |
380 | if (LDO_P (this_insn)) \ | |
381 | { next_addr = (frame_info)->frame + extract_14 (this_insn); \ | |
382 | pc += 4; \ | |
383 | } \ | |
384 | else if (ADDIL_P (this_insn)) \ | |
385 | { next_addr = (frame_info)->frame + (extract_21 (this_insn) << 11)\ | |
386 | + extract_14 (read_memory_integer (pc + 4, 4)); \ | |
387 | pc += 8; \ | |
388 | } \ | |
389 | while (1) \ | |
390 | { this_insn = read_memory_integer (pc, 4); \ | |
391 | if ((this_insn & 0xfc001fe0) == 0x2c001220) /* fstds,ma */ \ | |
392 | { regnum = GET_FIELD (this_insn, 27, 31); \ | |
393 | (frame_saved_regs).regs[regnum + FP0_REGNUM] = next_addr; \ | |
394 | next_addr += 8; \ | |
395 | } \ | |
396 | else \ | |
397 | break; \ | |
398 | } \ | |
399 | lose: \ | |
400 | (frame_saved_regs).regs[FP_REGNUM] = (frame_info)->frame; \ | |
401 | (frame_saved_regs).regs[SP_REGNUM] = (frame_info)->frame -4; \ | |
402 | }} | |
403 | \f | |
404 | /* Things needed for making the inferior call functions. */ | |
405 | ||
406 | /* Push an empty stack frame, to record the current PC, etc. */ | |
407 | ||
408 | #define PUSH_DUMMY_FRAME \ | |
409 | { register CORE_ADDR sp = read_register (SP_REGNUM); \ | |
410 | register int regnum; \ | |
411 | int int_buffer; \ | |
412 | double freg_buffer; \ | |
413 | /* Space for "arguments"; the RP goes in here. */ \ | |
414 | sp += 48; \ | |
415 | int_buffer = read_register (RP_REGNUM) | 0x3; \ | |
416 | write_memory (sp - 20, &int_buffer, 4); \ | |
417 | int_buffer = read_register (FP_REGNUM); \ | |
418 | write_memory (sp, &int_buffer, 4); \ | |
419 | write_register (FP_REGNUM, sp); \ | |
420 | sp += 4; \ | |
421 | for (regnum = 1; regnum < 31; regnum++) \ | |
422 | if (regnum != RP_REGNUM && regnum != FP_REGNUM) \ | |
423 | sp = push_word (sp, read_register (regnum)); \ | |
424 | for (regnum = FP0_REGNUM; regnum < NUM_REGS; regnum++) \ | |
425 | { read_register_bytes (REGISTER_BYTE (regnum), &freg_buffer, 8); \ | |
426 | sp = push_bytes (sp, &freg_buffer, 8);} \ | |
427 | sp = push_word (sp, read_register (IPSW_REGNUM)); \ | |
428 | sp = push_word (sp, read_register (SAR_REGNUM)); \ | |
429 | sp = push_word (sp, read_register (PCOQ_TAIL_REGNUM)); \ | |
430 | sp = push_word (sp, read_register (PCSQ_TAIL_REGNUM)); \ | |
431 | write_register (SP_REGNUM, sp);} | |
432 | ||
433 | /* Discard from the stack the innermost frame, | |
434 | restoring all saved registers. */ | |
435 | #define POP_FRAME \ | |
436 | { register FRAME frame = get_current_frame (); \ | |
437 | register CORE_ADDR fp; \ | |
438 | register int regnum; \ | |
439 | struct frame_saved_regs fsr; \ | |
440 | struct frame_info *fi; \ | |
441 | double freg_buffer; \ | |
442 | fi = get_frame_info (frame); \ | |
443 | fp = fi->frame; \ | |
444 | get_frame_saved_regs (fi, &fsr); \ | |
445 | for (regnum = 31; regnum > 0; regnum--) \ | |
446 | if (fsr.regs[regnum]) \ | |
447 | write_register (regnum, read_memory_integer (fsr.regs[regnum], 4)); \ | |
448 | for (regnum = NUM_REGS - 1; regnum >= FP0_REGNUM ; regnum--) \ | |
449 | if (fsr.regs[regnum]) \ | |
450 | { read_memory (fsr.regs[regnum], &freg_buffer, 8); \ | |
451 | write_register_bytes (REGISTER_BYTE (regnum), &freg_buffer, 8); }\ | |
452 | if (fsr.regs[IPSW_REGNUM]) \ | |
453 | write_register (IPSW_REGNUM, \ | |
454 | read_memory_integer (fsr.regs[IPSW_REGNUM], 4)); \ | |
455 | if (fsr.regs[SAR_REGNUM]) \ | |
456 | write_register (SAR_REGNUM, \ | |
457 | read_memory_integer (fsr.regs[SAR_REGNUM], 4)); \ | |
458 | if (fsr.regs[PCOQ_TAIL_REGNUM]) \ | |
459 | write_register (PCOQ_TAIL_REGNUM, \ | |
460 | read_memory_integer (fsr.regs[PCOQ_TAIL_REGNUM], 4));\ | |
461 | if (fsr.regs[PCSQ_TAIL_REGNUM]) \ | |
462 | write_register (PCSQ_TAIL_REGNUM, \ | |
463 | read_memory_integer (fsr.regs[PCSQ_TAIL_REGNUM], 4));\ | |
464 | write_register (FP_REGNUM, read_memory_integer (fp, 4)); \ | |
465 | write_register (SP_REGNUM, fp + 8); \ | |
466 | flush_cached_frames (); \ | |
467 | set_current_frame (create_new_frame (read_register (FP_REGNUM),\ | |
468 | read_pc ())); } | |
469 | ||
470 | /* This sequence of words is the instructions | |
471 | ||
472 | ; Call stack frame has already been built by gdb. Since we could be calling | |
473 | ; a varargs function, and we do not have the benefit of a stub to put things in | |
474 | ; the right place, we load the first 4 word of arguments into both the general | |
475 | ; and fp registers. | |
476 | call_dummy | |
477 | ldw -36(sp), arg0 | |
478 | ldw -40(sp), arg1 | |
479 | ldw -44(sp), arg2 | |
480 | ldw -48(sp), arg3 | |
481 | ldo -36(sp), r1 | |
482 | fldws 0(0, r1), fr4 | |
483 | fldds -4(0, r1), fr5 | |
484 | fldws -8(0, r1), fr6 | |
485 | fldds -12(0, r1), fr7 | |
486 | ldil 0, r22 ; target will be placed here. | |
487 | ldo 0(r22), r22 | |
488 | ldsid (0,r22), r3 | |
489 | ldil 0, r1 ; _sr4export will be placed here. | |
490 | ldo 0(r1), r1 | |
491 | ldsid (0,r1), r4 | |
492 | combt,=,n r3, r4, text_space ; If target is in data space, do a | |
493 | ble 0(sr5, r22) ; "normal" procedure call | |
494 | copy r31, r2 | |
495 | break 4, 8 | |
496 | text_space ; Otherwise, go through _sr4export, | |
497 | ble (sr4, r1) ; which will return back here. | |
498 | stw 31,-24(r30) | |
499 | break 4, 8 | |
500 | ||
501 | The dummy decides if the target is in text space or data space. If | |
502 | it's in data space, there's no problem because the target can | |
503 | return back to the dummy. However, if the target is in text space, | |
504 | the dummy calls the secret, undocumented routine _sr4export, which | |
505 | calls a function in text space and can return to any space. Instead | |
506 | of including fake instructions to represent saved registers, we | |
507 | know that the frame is associated with the call dummy and treat it | |
508 | specially. */ | |
509 | ||
510 | #define CALL_DUMMY { 0x4bda3fb9, 0x4bd93fb1, 0x4bd83fa9, 0x4bd73fa1, \ | |
511 | 0x37c13fb9, 0x24201004, 0x2c391005, 0x24311006, \ | |
512 | 0x2c291007, 0x22c00000, 0x36d60000, 0x02c010a3, \ | |
513 | 0x20200000, 0x34210000, 0x002010a4, 0x80832012, \ | |
514 | 0xe6c06000, 0x081f0242, 0x00010004, 0xe4202000, \ | |
515 | 0x6bdf3fd1, 0x00010004} | |
516 | ||
517 | #define CALL_DUMMY_LENGTH 88 | |
518 | #define CALL_DUMMY_START_OFFSET 0 | |
519 | /* Insert the specified number of args and function address | |
520 | into a call sequence of the above form stored at DUMMYNAME. */ | |
521 | #define FIX_CALL_DUMMY(dummyname, pc, fun, nargs, args, type, gcc_p) \ | |
522 | { static CORE_ADDR sr4export_address = 0; \ | |
523 | \ | |
524 | if (!sr4export_address) \ | |
525 | { \ | |
526 | struct minimal_symbol *msymbol; \ | |
527 | msymbol = lookup_minimal_symbol ("_sr4export", (struct objfile *) NULL);\ | |
528 | if (msymbol = NULL) \ | |
529 | error ("Can't find an address for _sr4export trampoline"); \ | |
530 | else \ | |
531 | sr4export_address = msymbol -> address; \ | |
532 | } \ | |
533 | dummyname[9] = deposit_21 (fun >> 11, dummyname[9]); \ | |
534 | dummyname[10] = deposit_14 (fun & MASK_11, dummyname[10]); \ | |
535 | dummyname[12] = deposit_21 (sr4export_address >> 11, dummyname[12]); \ | |
536 | dummyname[13] = deposit_14 (sr4export_address & MASK_11, dummyname[13]);\ | |
537 | } | |
538 | ||
539 | /* Write the PC to a random value. | |
540 | On PA-RISC, we need to be sure that the PC space queue is correct. */ | |
541 | ||
542 | #define WRITE_PC(addr) \ | |
543 | { int space_reg, space = ((addr) >> 30); \ | |
544 | int space_val; \ | |
545 | if (space == 0) \ | |
546 | space_reg = 43; /* Space reg sr4 */ \ | |
547 | else if (space == 1) \ | |
548 | space_reg = 48; /* Space reg sr5*/ \ | |
549 | else \ | |
550 | error ("pc = %x is in illegal space.", addr); \ | |
551 | space_val = read_register (space_reg); \ | |
552 | write_register (PCOQ_HEAD_REGNUM, addr); \ | |
553 | write_register (PCSQ_HEAD_REGNUM, space_val); \ | |
554 | write_register (PCOQ_TAIL_REGNUM, addr); \ | |
555 | write_register (PCSQ_TAIL_REGNUM, space_val);} |