| 1 | /* Parameters for target machine Intel 960, for GDB, the GNU debugger. |
| 2 | Copyright (C) 1990-1991 Free Software Foundation, Inc. |
| 3 | Contributed by Intel Corporation. |
| 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 | /* Definitions to target GDB to any i960. */ |
| 21 | |
| 22 | #ifndef I80960 |
| 23 | #define I80960 |
| 24 | #endif |
| 25 | |
| 26 | /* Hook for the SYMBOL_CLASS of a parameter when decoding DBX symbol |
| 27 | information. In the i960, parameters can be stored as locals or as |
| 28 | args, depending on the type of the debug record. |
| 29 | |
| 30 | From empirical observation, gcc960 uses N_LSYM to indicate |
| 31 | arguments passed in registers and then copied immediately |
| 32 | to the frame, and N_PSYM to indicate arguments passed in a |
| 33 | g14-relative argument block. */ |
| 34 | |
| 35 | #define DBX_PARM_SYMBOL_CLASS(type) ((type == N_LSYM)? LOC_LOCAL_ARG: LOC_ARG) |
| 36 | |
| 37 | /* Byte order is configurable, but this machine runs little-endian. */ |
| 38 | #define TARGET_BYTE_ORDER LITTLE_ENDIAN |
| 39 | |
| 40 | /* We have IEEE floating point, if we have any float at all. */ |
| 41 | |
| 42 | #define IEEE_FLOAT |
| 43 | |
| 44 | /* Define this if the C compiler puts an underscore at the front |
| 45 | of external names before giving them to the linker. */ |
| 46 | |
| 47 | #define NAMES_HAVE_UNDERSCORE |
| 48 | |
| 49 | |
| 50 | /* Offset from address of function to start of its code. |
| 51 | Zero on most machines. */ |
| 52 | |
| 53 | #define FUNCTION_START_OFFSET 0 |
| 54 | |
| 55 | /* Advance ip across any function entry prologue instructions |
| 56 | to reach some "real" code. */ |
| 57 | |
| 58 | #define SKIP_PROLOGUE(ip) { ip = skip_prologue (ip); } |
| 59 | extern CORE_ADDR skip_prologue (); |
| 60 | |
| 61 | /* Immediately after a function call, return the saved ip. |
| 62 | Can't always go through the frames for this because on some machines |
| 63 | the new frame is not set up until the new function |
| 64 | executes some instructions. */ |
| 65 | |
| 66 | #define SAVED_PC_AFTER_CALL(frame) (saved_pc_after_call (frame)) |
| 67 | extern CORE_ADDR saved_pc_after_call (); |
| 68 | |
| 69 | /* Stack grows upward */ |
| 70 | |
| 71 | #define INNER_THAN > |
| 72 | |
| 73 | /* Nonzero if instruction at ip is a return instruction. */ |
| 74 | |
| 75 | #define ABOUT_TO_RETURN(ip) (read_memory_integer(ip,4) == 0x0a000000) |
| 76 | |
| 77 | /* Return 1 if P points to an invalid floating point value. |
| 78 | LEN is the length in bytes. */ |
| 79 | |
| 80 | #define INVALID_FLOAT(p, len) (0) |
| 81 | |
| 82 | /* How long (ordinary) registers are */ |
| 83 | |
| 84 | #define REGISTER_TYPE long |
| 85 | |
| 86 | /* Number of machine registers */ |
| 87 | #define NUM_REGS 40 |
| 88 | |
| 89 | /* Initializer for an array of names of registers. |
| 90 | There should be NUM_REGS strings in this initializer. */ |
| 91 | |
| 92 | #define REGISTER_NAMES { \ |
| 93 | /* 0 */ "pfp", "sp", "rip", "r3", "r4", "r5", "r6", "r7", \ |
| 94 | /* 8 */ "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15",\ |
| 95 | /* 16 */ "g0", "g1", "g2", "g3", "g4", "g5", "g6", "g7", \ |
| 96 | /* 24 */ "g8", "g9", "g10", "g11", "g12", "g13", "g14", "fp", \ |
| 97 | /* 32 */ "pc", "ac", "ip", "tc", "fp0", "fp1", "fp2", "fp3", \ |
| 98 | } |
| 99 | |
| 100 | /* Register numbers of various important registers (used to index |
| 101 | into arrays of register names and register values). */ |
| 102 | |
| 103 | #define R0_REGNUM 0 /* First local register */ |
| 104 | #define SP_REGNUM 1 /* Contains address of top of stack */ |
| 105 | #define RIP_REGNUM 2 /* Return instruction pointer (local r2) */ |
| 106 | #define R15_REGNUM 15 /* Last local register */ |
| 107 | #define G0_REGNUM 16 /* First global register */ |
| 108 | #define G13_REGNUM 29 /* g13 - holds struct return address */ |
| 109 | #define G14_REGNUM 30 /* g14 - ptr to arg block / leafproc return address */ |
| 110 | #define FP_REGNUM 31 /* Contains address of executing stack frame */ |
| 111 | #define PCW_REGNUM 32 /* process control word */ |
| 112 | #define ACW_REGNUM 33 /* arithmetic control word */ |
| 113 | #define IP_REGNUM 34 /* instruction pointer */ |
| 114 | #define TCW_REGNUM 35 /* trace control word */ |
| 115 | #define FP0_REGNUM 36 /* First floating point register */ |
| 116 | |
| 117 | /* Some registers have more than one name */ |
| 118 | |
| 119 | #define PC_REGNUM IP_REGNUM /* GDB refers to ip as the Program Counter */ |
| 120 | #define PFP_REGNUM R0_REGNUM /* Previous frame pointer */ |
| 121 | |
| 122 | /* Total amount of space needed to store our copies of the machine's |
| 123 | register state, the array `registers'. */ |
| 124 | #define REGISTER_BYTES ((36*4) + (4*10)) |
| 125 | |
| 126 | /* Index within `registers' of the first byte of the space for register N. */ |
| 127 | |
| 128 | #define REGISTER_BYTE(N) ( (N) < FP0_REGNUM ? \ |
| 129 | (4*(N)) : ((10*(N)) - (6*FP0_REGNUM)) ) |
| 130 | |
| 131 | /* The i960 has register windows, sort of. */ |
| 132 | |
| 133 | #define HAVE_REGISTER_WINDOWS |
| 134 | |
| 135 | /* Is this register part of the register window system? A yes answer |
| 136 | implies that 1) The name of this register will not be the same in |
| 137 | other frames, and 2) This register is automatically "saved" upon |
| 138 | subroutine calls and thus there is no need to search more than one |
| 139 | stack frame for it. |
| 140 | |
| 141 | On the i960, in fact, the name of this register in another frame is |
| 142 | "mud" -- there is no overlap between the windows. Each window is |
| 143 | simply saved into the stack (true for our purposes, after having been |
| 144 | flushed; normally they reside on-chip and are restored from on-chip |
| 145 | without ever going to memory). */ |
| 146 | |
| 147 | #define REGISTER_IN_WINDOW_P(regnum) ((regnum) <= R15_REGNUM) |
| 148 | |
| 149 | /* Number of bytes of storage in the actual machine representation |
| 150 | for register N. On the i960, all regs are 4 bytes except for floating |
| 151 | point, which are 10. NINDY only sends us 8 byte values for these, |
| 152 | which is a pain, but VxWorks handles this correctly, so we must. */ |
| 153 | |
| 154 | #define REGISTER_RAW_SIZE(N) ( (N) < FP0_REGNUM ? 4 : 10 ) |
| 155 | |
| 156 | /* Number of bytes of storage in the program's representation for register N. */ |
| 157 | |
| 158 | #define REGISTER_VIRTUAL_SIZE(N) ( (N) < FP0_REGNUM ? 4 : 8 ) |
| 159 | |
| 160 | /* Largest value REGISTER_RAW_SIZE can have. */ |
| 161 | |
| 162 | #define MAX_REGISTER_RAW_SIZE 10 |
| 163 | |
| 164 | /* Largest value REGISTER_VIRTUAL_SIZE can have. */ |
| 165 | |
| 166 | #define MAX_REGISTER_VIRTUAL_SIZE 8 |
| 167 | |
| 168 | /* Nonzero if register N requires conversion from raw format to virtual |
| 169 | format. */ |
| 170 | |
| 171 | #define REGISTER_CONVERTIBLE(N) ((N) >= FP0_REGNUM) |
| 172 | |
| 173 | /* Convert data from raw format for register REGNUM |
| 174 | to virtual format for register REGNUM. */ |
| 175 | |
| 176 | #define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,FROM,TO) \ |
| 177 | { \ |
| 178 | extern struct ext_format ext_format_i960; \ |
| 179 | \ |
| 180 | if ((REGNUM) >= FP0_REGNUM) \ |
| 181 | ieee_extended_to_double (&ext_format_i960, (FROM), (double *)(TO)); \ |
| 182 | else \ |
| 183 | bcopy ((FROM), (TO), 4); \ |
| 184 | } |
| 185 | |
| 186 | /* Convert data from virtual format for register REGNUM |
| 187 | to raw format for register REGNUM. */ |
| 188 | |
| 189 | #define REGISTER_CONVERT_TO_RAW(REGNUM,FROM,TO) \ |
| 190 | { \ |
| 191 | extern struct ext_format ext_format_i960; \ |
| 192 | \ |
| 193 | if ((REGNUM) >= FP0_REGNUM) \ |
| 194 | double_to_ieee_extended (&ext_format_i960, (double *)(FROM), (TO)); \ |
| 195 | else \ |
| 196 | bcopy ((FROM), (TO), 4); \ |
| 197 | } |
| 198 | |
| 199 | |
| 200 | /* Return the GDB type object for the "standard" data type |
| 201 | of data in register N. */ |
| 202 | |
| 203 | #define REGISTER_VIRTUAL_TYPE(N) ((N) < FP0_REGNUM ? \ |
| 204 | builtin_type_int : builtin_type_double) |
| 205 | \f |
| 206 | /* Macros for understanding function return values... */ |
| 207 | |
| 208 | /* Does the specified function use the "struct returning" convention |
| 209 | or the "value returning" convention? The "value returning" convention |
| 210 | almost invariably returns the entire value in registers. The |
| 211 | "struct returning" convention often returns the entire value in |
| 212 | memory, and passes a pointer (out of or into the function) saying |
| 213 | where the value (is or should go). |
| 214 | |
| 215 | Since this sometimes depends on whether it was compiled with GCC, |
| 216 | this is also an argument. This is used in call_function to build a |
| 217 | stack, and in value_being_returned to print return values. |
| 218 | |
| 219 | On i960, a structure is returned in registers g0-g3, if it will fit. |
| 220 | If it's more than 16 bytes long, g13 pointed to it on entry. */ |
| 221 | |
| 222 | #define USE_STRUCT_CONVENTION(gcc_p, type) (TYPE_LENGTH (type) > 16) |
| 223 | |
| 224 | /* Extract from an array REGBUF containing the (raw) register state |
| 225 | a function return value of type TYPE, and copy that, in virtual format, |
| 226 | into VALBUF. This is only called if USE_STRUCT_CONVENTION for this |
| 227 | type is 0. |
| 228 | |
| 229 | On the i960 we just take as many bytes as we need from G0 through G3. */ |
| 230 | |
| 231 | #define EXTRACT_RETURN_VALUE(TYPE,REGBUF,VALBUF) \ |
| 232 | bcopy(REGBUF+REGISTER_BYTE(G0_REGNUM), VALBUF, TYPE_LENGTH (TYPE)) |
| 233 | |
| 234 | /* If USE_STRUCT_CONVENTION produces a 1, |
| 235 | extract from an array REGBUF containing the (raw) register state |
| 236 | the address in which a function should return its structure value, |
| 237 | as a CORE_ADDR (or an expression that can be used as one). |
| 238 | |
| 239 | Address of where to put structure was passed in in global |
| 240 | register g13 on entry. God knows what's in g13 now. The |
| 241 | (..., 0) below is to make it appear to return a value, though |
| 242 | actually all it does is call error(). */ |
| 243 | |
| 244 | #define EXTRACT_STRUCT_VALUE_ADDRESS(REGBUF) \ |
| 245 | (error("Don't know where large structure is returned on i960"), 0) |
| 246 | |
| 247 | /* Write into appropriate registers a function return value |
| 248 | of type TYPE, given in virtual format, for "value returning" functions. |
| 249 | |
| 250 | For 'return' command: not (yet) implemented for i960. */ |
| 251 | |
| 252 | #define STORE_RETURN_VALUE(TYPE,VALBUF) \ |
| 253 | error ("Returning values from functions is not implemented in i960 gdb") |
| 254 | |
| 255 | /* Store the address of the place in which to copy the structure the |
| 256 | subroutine will return. This is called from call_function. */ |
| 257 | |
| 258 | #define STORE_STRUCT_RETURN(ADDR, SP) \ |
| 259 | error ("Returning values from functions is not implemented in i960 gdb") |
| 260 | \f |
| 261 | /* Describe the pointer in each stack frame to the previous stack frame |
| 262 | (its caller). */ |
| 263 | |
| 264 | /* FRAME_CHAIN takes a frame's nominal address |
| 265 | and produces the frame's chain-pointer. |
| 266 | |
| 267 | FRAME_CHAIN_COMBINE takes the chain pointer and the frame's nominal address |
| 268 | and produces the nominal address of the caller frame. |
| 269 | |
| 270 | However, if FRAME_CHAIN_VALID returns zero, |
| 271 | it means the given frame is the outermost one and has no caller. |
| 272 | In that case, FRAME_CHAIN_COMBINE is not used. */ |
| 273 | |
| 274 | /* We cache information about saved registers in the frame structure, |
| 275 | to save us from having to re-scan function prologues every time |
| 276 | a register in a non-current frame is accessed. */ |
| 277 | |
| 278 | #define EXTRA_FRAME_INFO \ |
| 279 | struct frame_saved_regs *fsr; \ |
| 280 | CORE_ADDR arg_pointer; |
| 281 | |
| 282 | /* Zero the frame_saved_regs pointer when the frame is initialized, |
| 283 | so that FRAME_FIND_SAVED_REGS () will know to allocate and |
| 284 | initialize a frame_saved_regs struct the first time it is called. |
| 285 | Set the arg_pointer to -1, which is not valid; 0 and other values |
| 286 | indicate real, cached values. */ |
| 287 | |
| 288 | #define INIT_EXTRA_FRAME_INFO(fi) ((fi)->fsr = 0, (fi)->arg_pointer = -1) |
| 289 | |
| 290 | /* On the i960, we get the chain pointer by reading the PFP saved |
| 291 | on the stack and clearing the status bits. */ |
| 292 | |
| 293 | #define FRAME_CHAIN(thisframe) \ |
| 294 | (read_memory_integer (FRAME_FP(thisframe), 4) & ~0xf) |
| 295 | |
| 296 | #define FRAME_CHAIN_COMBINE(chain, thisframe) (chain) |
| 297 | |
| 298 | /* FRAME_CHAIN_VALID returns zero if the given frame is the outermost one |
| 299 | and has no caller. In that case, FRAME_CHAIN_COMBINE is not used. |
| 300 | |
| 301 | On the i960, each various target system type must define FRAME_CHAIN_VALID, |
| 302 | since it differs between NINDY and VxWorks, the two currently supported |
| 303 | targets types. We leave it undefined here. */ |
| 304 | |
| 305 | |
| 306 | /* A macro that tells us whether the function invocation represented |
| 307 | by FI does not have a frame on the stack associated with it. If it |
| 308 | does not, FRAMELESS is set to 1, else 0. */ |
| 309 | |
| 310 | #define FRAMELESS_FUNCTION_INVOCATION(FI, FRAMELESS) \ |
| 311 | { (FRAMELESS) = (leafproc_return ((FI)->pc) != 0); } |
| 312 | |
| 313 | /* Note that in the i960 architecture the return pointer is saved in the |
| 314 | *caller's* stack frame. |
| 315 | |
| 316 | Make sure to zero low-order bits because of bug in 960CA A-step part |
| 317 | (instruction addresses should always be word-aligned anyway). */ |
| 318 | |
| 319 | #define FRAME_SAVED_PC(frame) \ |
| 320 | ((read_memory_integer(FRAME_CHAIN(frame)+8,4)) & ~3) |
| 321 | |
| 322 | /* On the i960, FRAME_ARGS_ADDRESS should return the value of |
| 323 | g14 as passed into the frame, if known. We need a function for this. |
| 324 | We cache this value in the frame info if we've already looked it up. */ |
| 325 | |
| 326 | #define FRAME_ARGS_ADDRESS(fi) \ |
| 327 | (((fi)->arg_pointer != -1)? (fi)->arg_pointer: frame_args_address (fi, 0)) |
| 328 | extern CORE_ADDR frame_args_address (); /* i960-tdep.c */ |
| 329 | |
| 330 | /* This is the same except it should return 0 when |
| 331 | it does not really know where the args are, rather than guessing. |
| 332 | This value is not cached since it is only used infrequently. */ |
| 333 | |
| 334 | #define FRAME_ARGS_ADDRESS_CORRECT(fi) (frame_args_address (fi, 1)) |
| 335 | |
| 336 | #define FRAME_LOCALS_ADDRESS(fi) (fi)->frame |
| 337 | |
| 338 | /* Set NUMARGS to the number of args passed to a frame. |
| 339 | Can return -1, meaning no way to tell. */ |
| 340 | |
| 341 | #define FRAME_NUM_ARGS(numargs, fi) (numargs = -1) |
| 342 | |
| 343 | /* Return number of bytes at start of arglist that are not really args. */ |
| 344 | |
| 345 | #define FRAME_ARGS_SKIP 0 |
| 346 | |
| 347 | /* Produce the positions of the saved registers in a stack frame. */ |
| 348 | |
| 349 | #define FRAME_FIND_SAVED_REGS(frame_info_addr, sr) \ |
| 350 | frame_find_saved_regs (frame_info_addr, &sr) |
| 351 | extern void frame_find_saved_regs(); /* See i960-tdep.c */ |
| 352 | |
| 353 | |
| 354 | /* Print status when we get a random unexpected signal. We have more |
| 355 | kinds of signals than Unix does... */ |
| 356 | |
| 357 | #define PRINT_RANDOM_SIGNAL(stop_signal) print_fault (stop_signal) |
| 358 | \f |
| 359 | /* Things needed for making calls to functions in the inferior process */ |
| 360 | |
| 361 | /* Push an empty stack frame, to record the current ip, etc. |
| 362 | |
| 363 | Not (yet?) implemented for i960. */ |
| 364 | |
| 365 | #define PUSH_DUMMY_FRAME \ |
| 366 | error("Function calls into the inferior process are not supported on the i960") |
| 367 | |
| 368 | /* Discard from the stack the innermost frame, restoring all registers. */ |
| 369 | |
| 370 | #define POP_FRAME \ |
| 371 | pop_frame () |
| 372 | |
| 373 | |
| 374 | /* This sequence of words is the instructions |
| 375 | |
| 376 | callx 0x00000000 |
| 377 | fmark |
| 378 | */ |
| 379 | |
| 380 | /* #define CALL_DUMMY { 0x86003000, 0x00000000, 0x66003e00 } */ |
| 381 | |
| 382 | /* #define CALL_DUMMY_START_OFFSET 0 *//* Start execution at beginning of dummy */ |
| 383 | |
| 384 | /* Indicate that we don't support calling inferior child functions. */ |
| 385 | |
| 386 | #undef CALL_DUMMY |
| 387 | |
| 388 | /* Insert the specified number of args and function address |
| 389 | into a call sequence of the above form stored at 'dummyname'. |
| 390 | |
| 391 | Ignore arg count on i960. */ |
| 392 | |
| 393 | /* #define FIX_CALL_DUMMY(dummyname, fun, nargs) *(((int *)dummyname)+1) = fun */ |
| 394 | |
| 395 | #undef FIX_CALL_DUMMY |
| 396 | |
| 397 | |
| 398 | /* Interface definitions for kernel debugger KDB */ |
| 399 | /* (Not relevant to i960.) */ |