]> Git Repo - binutils.git/blob - gdb/tm-pn.h
ansi name abuse changes
[binutils.git] / gdb / tm-pn.h
1 /* Parameters for targe of a Gould Powernode, for GDB, the GNU debugger.
2    Copyright (C) 1986, 1987, 1989, 1991 Free Software Foundation, Inc.
3
4 This file is part of GDB.
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
19
20 #define GOULD_PN
21
22 #define TARGET_BYTE_ORDER BIG_ENDIAN
23
24 /* This code appears in libraries on Gould machines.  Ignore it. */
25 #define IGNORE_SYMBOL(type) (type == N_ENTRY)
26
27 /* We don't want the extra gnu symbols on the machine;
28    they will interfere with the shared segment symbols.  */
29 #define NO_GNU_STABS
30
31 /* Macro for text-offset and data info (in PN a.out format).  */
32 #define TEXTINFO                                                \
33         text_offset = N_TXTOFF (exec_coffhdr);                  \
34         exec_data_offset = N_TXTOFF (exec_coffhdr)              \
35                 + exec_aouthdr.a_text
36
37 /* Macro for number of symbol table entries */
38 #define END_OF_TEXT_DEFAULT                                     \
39         (0xffffff)
40
41 /* Macro for number of symbol table entries */
42 #define NUMBER_OF_SYMBOLS                                       \
43         (coffhdr.f_nsyms)
44
45 /* Macro for file-offset of symbol table (in usual a.out format).  */
46 #define SYMBOL_TABLE_OFFSET                                     \
47         N_SYMOFF (coffhdr)
48
49 /* Macro for file-offset of string table (in usual a.out format).  */
50 #define STRING_TABLE_OFFSET                                     \
51         (N_STROFF (coffhdr) + sizeof(int))
52
53 /* Macro to store the length of the string table data in INTO.  */
54 #define READ_STRING_TABLE_SIZE(INTO)                            \
55         { INTO = hdr.a_stsize; }
56
57 /* Macro to declare variables to hold the file's header data.  */
58 #define DECLARE_FILE_HEADERS  struct old_exec hdr;              \
59                               FILHDR coffhdr
60
61 /* Macro to read the header data from descriptor DESC and validate it.
62    NAME is the file name, for error messages.  */
63 #define READ_FILE_HEADERS(DESC, NAME)                           \
64 { val = myread (DESC, &coffhdr, sizeof coffhdr);                \
65   if (val < 0)                                                  \
66     perror_with_name (NAME);                                    \
67   val = myread (DESC, &hdr, sizeof hdr);                        \
68   if (val < 0)                                                  \
69     perror_with_name (NAME);                                    \
70   if (coffhdr.f_magic != GNP1MAGIC)                             \
71     error ("File \"%s\" not in coff executable format.", NAME); \
72   if (N_BADMAG (hdr))                                           \
73     error ("File \"%s\" not in executable format.", NAME); }
74
75 /* Define COFF and other symbolic names needed on NP1 */
76 #define NS32GMAGIC      GDPMAGIC
77 #define NS32SMAGIC      PN_MAGIC
78 /* Define this if the C compiler puts an underscore at the front
79    of external names before giving them to the linker.  */
80 #define NAMES_HAVE_UNDERSCORE
81
82 /* Offset from address of function to start of its code.
83    Zero on most machines.  */
84 #define FUNCTION_START_OFFSET   4
85
86 /* Advance PC across any function entry prologue instructions
87    to reach some "real" code.  One PN we can have one or two startup
88    sequences depending on the size of the local stack:
89
90    Either:
91       "suabr b2, #"
92    of
93       "lil r4, #", "suabr b2, #(r4)"
94
95    "lwbr b6, #", "stw r1, 8(b2)"
96    Optional "stwbr b3, c(b2)"
97    Optional "trr r2,r7"      (Gould first argument register passing)
98      or
99    Optional "stw r2,8(b3)"   (Gould first argument register passing)
100  */
101 #define SKIP_PROLOGUE(pc) {                                             \
102         register int op = read_memory_integer ((pc), 4);                \
103         if ((op & 0xffff0000) == 0x580B0000) {                          \
104             pc += 4;                                                    \
105             op = read_memory_integer ((pc), 4);                         \
106             if ((op & 0xffff0000) == 0x59400000) {                      \
107                 pc += 4;                                                \
108                 op = read_memory_integer ((pc), 4);                     \
109                 if ((op & 0xffff0000) == 0x5F000000) {                  \
110                     pc += 4;                                            \
111                     op = read_memory_integer ((pc), 4);                 \
112                     if (op == 0xD4820008) {                             \
113                         pc += 4;                                        \
114                         op = read_memory_integer ((pc), 4);             \
115                         if (op == 0x5582000C) {                         \
116                             pc += 4;                                    \
117                             op = read_memory_integer ((pc), 2);         \
118                             if (op == 0x2fa0) {                         \
119                                 pc += 2;                                \
120                             } else {                                    \
121                                 op = read_memory_integer ((pc), 4);     \
122                                 if (op == 0xd5030008) {                 \
123                                     pc += 4;                            \
124                                 }                                       \
125                             }                                           \
126                         } else {                                        \
127                             op = read_memory_integer ((pc), 2);         \
128                             if (op == 0x2fa0) {                         \
129                                 pc += 2;                                \
130                             }                                           \
131                         }                                               \
132                     }                                                   \
133                 }                                                       \
134             }                                                           \
135         }                                                               \
136         if ((op & 0xffff0000) == 0x59000000) {                          \
137             pc += 4;                                                    \
138             op = read_memory_integer ((pc), 4);                         \
139             if ((op & 0xffff0000) == 0x5F000000) {                      \
140                 pc += 4;                                                \
141                 op = read_memory_integer ((pc), 4);                     \
142                 if (op == 0xD4820008) {                                 \
143                     pc += 4;                                            \
144                     op = read_memory_integer ((pc), 4);                 \
145                     if (op == 0x5582000C) {                             \
146                         pc += 4;                                        \
147                         op = read_memory_integer ((pc), 2);             \
148                         if (op == 0x2fa0) {                             \
149                             pc += 2;                                    \
150                         } else {                                        \
151                             op = read_memory_integer ((pc), 4);         \
152                             if (op == 0xd5030008) {                     \
153                                 pc += 4;                                \
154                             }                                           \
155                         }                                               \
156                     } else {                                            \
157                         op = read_memory_integer ((pc), 2);             \
158                         if (op == 0x2fa0) {                             \
159                             pc += 2;                                    \
160                         }                                               \
161                     }                                                   \
162                 }                                                       \
163             }                                                           \
164         }                                                               \
165 }
166
167 /* Immediately after a function call, return the saved pc.
168    Can't go through the frames for this because on some machines
169    the new frame is not set up until the new function executes
170    some instructions.  True on PN!  Return address is in R1.
171    Note: true return location is 4 bytes past R1! */
172 #define SAVED_PC_AFTER_CALL(frame) \
173         (read_register(R1_REGNUM) + 4)
174
175 /* Address of end of stack space.  */
176 #define STACK_END_ADDR          0x480000
177
178 /* Stack grows downward.  */
179 #define INNER_THAN              <
180
181 /* Sequence of bytes for breakpoint instruction.  */
182 #define BREAKPOINT              {0x28, 0x09}
183
184 /* Amount PC must be decremented by after a breakpoint.
185    This is often the number of bytes in BREAKPOINT
186    but not always.  */
187 #define DECR_PC_AFTER_BREAK     2
188
189 /* Nonzero if instruction at PC is a return instruction. "bu 4(r1)" */
190 #define ABOUT_TO_RETURN(pc)     (read_memory_integer (pc, 4) == 0xEC100004)
191
192 /* Return 1 if P points to an invalid floating point value.  */
193 #define INVALID_FLOAT(p, len)   ((*(short *)p & 0xff80) == 0x8000)
194
195 /* Say how long (ordinary) registers are.  */
196 #define REGISTER_TYPE           long
197
198 /* Number of machine registers */
199 #define NUM_REGS                19
200 #define NUM_GEN_REGS            16
201 #define NUM_CPU_REGS            3
202
203 /* Initializer for an array of names of registers.
204    There should be NUM_REGS strings in this initializer.  */
205 #define REGISTER_NAMES { \
206   "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", \
207   "b0", "b1", "b2", "b3", "b4", "b5", "b6", "b7", \
208   "sp", "ps", "pc", \
209 }
210
211 /* Register numbers of various important registers.
212    Note that some of these values are "real" register numbers,
213    and correspond to the general registers of the machine,
214    and some are "phony" register numbers which are too large
215    to be actual register numbers as far as the user is concerned
216    but do serve to get the desired values when passed to read_register.  */
217 #define R1_REGNUM       1       /* Gr1 => return address of caller */
218 #define R4_REGNUM       4       /* Gr4 => register save area */
219 #define R5_REGNUM       5       /* Gr5 => register save area */
220 #define R6_REGNUM       6       /* Gr6 => register save area */
221 #define R7_REGNUM       7       /* Gr7 => register save area */
222 #define B1_REGNUM       9       /* Br1 => start of this code routine */
223 #define FP_REGNUM       10      /* Br2 == (sp) */
224 #define AP_REGNUM       11      /* Br3 == (ap) */
225 #define SP_REGNUM       16      /* A copy of Br2 saved in trap */
226 #define PS_REGNUM       17      /* Contains processor status */
227 #define PC_REGNUM       18      /* Contains program counter */
228
229 /* Total amount of space needed to store our copies of the machine's
230    register state, the array `registers'.  */
231 #define REGISTER_BYTES                  (NUM_GEN_REGS*4 + NUM_CPU_REGS*4)
232
233 /* Index within `registers' of the first byte of the space for
234    register N.  */
235 #define REGISTER_BYTE(N)                ((N) * 4)
236
237 /* Number of bytes of storage in the actual machine representation
238    for register N.  On the PN, all normal regs are 4 bytes. */
239 #define REGISTER_RAW_SIZE(N)            (4)
240
241 /* Number of bytes of storage in the program's representation
242    for register N.  On the PN, all regs are 4 bytes. */
243 #define REGISTER_VIRTUAL_SIZE(N)        (4)
244
245 /* Largest value REGISTER_RAW_SIZE can have.  */
246 #define MAX_REGISTER_RAW_SIZE           (4)
247
248 /* Largest value REGISTER_VIRTUAL_SIZE can have.  */
249 #define MAX_REGISTER_VIRTUAL_SIZE       (4)
250
251 /* Nonzero if register N requires conversion
252    from raw format to virtual format.  */
253 #define REGISTER_CONVERTIBLE(N)         (0)
254
255 /* Convert data from raw format for register REGNUM
256    to virtual format for register REGNUM.  */
257 #define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,FROM,TO)     \
258         bcopy ((FROM), (TO), REGISTER_RAW_SIZE(REGNUM));
259
260 /* Convert data from virtual format for register REGNUM
261    to raw format for register REGNUM.  */
262 #define REGISTER_CONVERT_TO_RAW(REGNUM,FROM,TO) \
263         bcopy ((FROM), (TO), REGISTER_VIRTUAL_SIZE(REGNUM));
264
265 /* Return the GDB type object for the "standard" data type
266    of data in register N.  */
267 #define REGISTER_VIRTUAL_TYPE(N)        (builtin_type_int)
268
269 /* Store the address of the place in which to copy the structure the
270    subroutine will return.  This is called from call_function.
271
272    On this machine this is a no-op, because gcc isn't used on it
273    yet.  So this calling convention is not used. */
274
275 #define STORE_STRUCT_RETURN(ADDR, SP)
276
277 /* Extract from an arrary REGBUF containing the (raw) register state
278    a function return value of type TYPE, and copy that, in virtual format,
279    into VALBUF. */
280
281 #define EXTRACT_RETURN_VALUE(TYPE,REGBUF,VALBUF) \
282         bcopy (REGBUF, VALBUF, TYPE_LENGTH (TYPE))
283
284 /* Write into appropriate registers a function return value
285    of type TYPE, given in virtual format.  */
286
287 #define STORE_RETURN_VALUE(TYPE,VALBUF) \
288         write_register_bytes (0, VALBUF, TYPE_LENGTH (TYPE))
289
290 /* Extract from an array REGBUF containing the (raw) register state
291    the address in which a function should return its structure value,
292    as a CORE_ADDR (or an expression that can be used as one).  */
293
294 #define EXTRACT_STRUCT_VALUE_ADDRESS(REGBUF) (*(int *)(REGBUF))
295
296 \f
297 /* Describe the pointer in each stack frame to the previous stack frame
298    (its caller).  */
299
300 /* FRAME_CHAIN takes a frame's nominal address
301    and produces the frame's chain-pointer.
302
303    FRAME_CHAIN_COMBINE takes the chain pointer and the frame's nominal address
304    and produces the nominal address of the caller frame.
305
306    However, if FRAME_CHAIN_VALID returns zero,
307    it means the given frame is the outermost one and has no caller.
308    In that case, FRAME_CHAIN_COMBINE is not used.  */
309
310 /* In the case of the NPL, the frame's norminal address is Br2 and the 
311    previous routines frame is up the stack X bytes, where X is the
312    value stored in the code function header xA(Br1). */
313 #define FRAME_CHAIN(thisframe)          (findframe(thisframe))
314
315 #define FRAME_CHAIN_VALID(chain, thisframe) \
316         (chain != 0 && chain != (thisframe)->frame)
317
318 #define FRAME_CHAIN_COMBINE(chain, thisframe) \
319         (chain)
320
321 /* Define other aspects of the stack frame on NPL.  */
322 #define FRAME_SAVED_PC(frame) \
323         (read_memory_integer ((frame)->frame + 8, 4))
324
325 #define FRAME_ARGS_ADDRESS(fi) \
326         ((fi)->next_frame ? \
327          read_memory_integer ((fi)->frame + 12, 4) : \
328          read_register (AP_REGNUM))
329
330 #define FRAME_LOCALS_ADDRESS(fi)        ((fi)->frame + 80)
331
332 /* Set VAL to the number of args passed to frame described by FI.
333    Can set VAL to -1, meaning no way to tell.  */
334
335 /* We can check the stab info to see how
336    many arg we have.  No info in stack will tell us */
337 #define FRAME_NUM_ARGS(val,fi)          (val = findarg(fi))
338
339 /* Return number of bytes at start of arglist that are not really args.  */
340 #define FRAME_ARGS_SKIP                 8
341
342 /* Put here the code to store, into a struct frame_saved_regs,
343    the addresses of the saved registers of frame described by FRAME_INFO.
344    This includes special registers such as pc and fp saved in special
345    ways in the stack frame.  sp is even more special:
346    the address we return for it IS the sp for the next frame.  */
347
348 #define FRAME_FIND_SAVED_REGS(frame_info, frame_saved_regs)             \
349 {                                                                       \
350   bzero (&frame_saved_regs, sizeof frame_saved_regs);                   \
351   (frame_saved_regs).regs[PC_REGNUM] = (frame_info)->frame + 8;         \
352   (frame_saved_regs).regs[R4_REGNUM] = (frame_info)->frame + 0x30;      \
353   (frame_saved_regs).regs[R5_REGNUM] = (frame_info)->frame + 0x34;      \
354   (frame_saved_regs).regs[R6_REGNUM] = (frame_info)->frame + 0x38;      \
355   (frame_saved_regs).regs[R7_REGNUM] = (frame_info)->frame + 0x3C;      \
356 }
357 \f
358 /* Things needed for making the inferior call functions.  */
359
360 /* Push an empty stack frame, to record the current PC, etc.  */
361
362 #define PUSH_DUMMY_FRAME \
363 { register CORE_ADDR sp = read_register (SP_REGNUM);                    \
364   register int regnum;                                                  \
365   sp = push_word (sp, read_register (PC_REGNUM));                       \
366   sp = push_word (sp, read_register (FP_REGNUM));                       \
367   write_register (FP_REGNUM, sp);                                       \
368   for (regnum = FP_REGNUM - 1; regnum >= 0; regnum--)                   \
369     sp = push_word (sp, read_register (regnum));                        \
370   sp = push_word (sp, read_register (PS_REGNUM));                       \
371   write_register (SP_REGNUM, sp);  }
372
373 /* Discard from the stack the innermost frame, 
374    restoring all saved registers.  */
375
376 #define POP_FRAME  \
377 { register FRAME frame = get_current_frame ();                   \
378   register CORE_ADDR fp;                                         \
379   register int regnum;                                           \
380   struct frame_saved_regs fsr;                                   \
381   struct frame_info *fi;                                         \
382   fi = get_frame_info (frame);                                   \
383   fp = fi->frame;                                                \
384   get_frame_saved_regs (fi, &fsr);                               \
385   for (regnum = FP_REGNUM - 1; regnum >= 0; regnum--)            \
386     if (fsr.regs[regnum])                                        \
387       write_register (regnum, read_memory_integer (fsr.regs[regnum], 4)); \
388   if (fsr.regs[PS_REGNUM])                                       \
389     write_register (PS_REGNUM, read_memory_integer (fsr.regs[PS_REGNUM], 4)); \
390   write_register (FP_REGNUM, read_memory_integer (fp, 4));       \
391   write_register (PC_REGNUM, read_memory_integer (fp + 4, 4));   \
392   write_register (SP_REGNUM, fp + 8);                            \
393   flush_cached_frames ();                                        \
394   set_current_frame ( create_new_frame (read_register (FP_REGNUM),\
395                                         read_pc ())); }
396
397 /* This sequence of words is the instructions:
398      halt
399      halt
400      halt
401      halt
402      suabr      b2, #<stacksize>
403      lwbr       b6, #con
404      stw        r1, 8(b2)       - save caller address, do we care?
405      lw         r2, 60(b2)      - arg1
406      labr       b3, 50(b2)
407      std        r4, 30(b2)      - save r4-r7
408      std        r6, 38(b2)
409      lwbr       b1, #<func>     - load function call address
410      brlnk      r1, 8(b1)       - call function
411      halt
412      halt
413      ld         r4, 30(b2)      - restore r4-r7
414      ld         r6, 38(b2)
415
416    Setup our stack frame, load argumemts, call and then restore registers.
417 */
418
419 /* FIXME:  The below defines an m68k CALL_DUMMY, which looks nothing like what
420    is documented above. */
421
422 #define CALL_DUMMY {0xf227e0ff, 0x48e7fffc, 0x426742e7, 0x4eb93232, 0x3232dffc, 0x69696969, 0x4e4f4e71}
423
424 #define CALL_DUMMY_LENGTH 28
425
426 #define CALL_DUMMY_START_OFFSET 12
427
428 /* Insert the specified number of args and function address
429    into a call sequence of the above form stored at DUMMYNAME.  */
430
431 #define FIX_CALL_DUMMY(dummyname, pc, fun, nargs, args, type, gcc_p)     \
432 { *(int *)((char *) dummyname + 20) = nargs * 4;  \
433   *(int *)((char *) dummyname + 14) = fun; }
This page took 0.051043 seconds and 4 git commands to generate.