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