OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [insight/] [gdb/] [config/] [ns32k/] [tm-umax.h] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 578 markom
/* Definitions to make GDB run on an encore under umax 4.2
2
   Copyright 1987, 1989, 1991, 1993, 1994, 1998, 1999, 2000, 2001
3
   Free Software Foundation, Inc.
4
 
5
   This file is part of GDB.
6
 
7
   This program is free software; you can redistribute it and/or modify
8
   it under the terms of the GNU General Public License as published by
9
   the Free Software Foundation; either version 2 of the License, or
10
   (at your option) any later version.
11
 
12
   This program is distributed in the hope that it will be useful,
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
18
   along with this program; if not, write to the Free Software
19
   Foundation, Inc., 59 Temple Place - Suite 330,
20
   Boston, MA 02111-1307, USA.  */
21
 
22
#include "regcache.h"
23
 
24
/* This is also included by tm-ns32km3.h, as well as being used by umax.  */
25
 
26
#define TARGET_BYTE_ORDER LITTLE_ENDIAN
27
 
28
/* Need to get function ends by adding this to epilogue address from .bf
29
   record, not using x_fsize field.  */
30
#define FUNCTION_EPILOGUE_SIZE 4
31
 
32
/* Offset from address of function to start of its code.
33
   Zero on most machines.  */
34
 
35
#define FUNCTION_START_OFFSET 0
36
 
37
/* Advance PC across any function entry prologue instructions
38
   to reach some "real" code.  */
39
 
40
extern CORE_ADDR umax_skip_prologue (CORE_ADDR);
41
#define SKIP_PROLOGUE(pc) (umax_skip_prologue (pc))
42
 
43
/* Immediately after a function call, return the saved pc.
44
   Can't always go through the frames for this because on some machines
45
   the new frame is not set up until the new function executes
46
   some instructions.  */
47
 
48
#define SAVED_PC_AFTER_CALL(frame) \
49
        read_memory_integer (read_register (SP_REGNUM), 4)
50
 
51
/* Address of end of stack space.  */
52
 
53
#ifndef STACK_END_ADDR
54
#define STACK_END_ADDR (0xfffff000)
55
#endif
56
 
57
/* Stack grows downward.  */
58
 
59
#define INNER_THAN(lhs,rhs) ((lhs) < (rhs))
60
 
61
/* Sequence of bytes for breakpoint instruction.  */
62
 
63
#define BREAKPOINT {0xf2}
64
 
65
/* Amount PC must be decremented by after a breakpoint.
66
   This is often the number of bytes in BREAKPOINT
67
   but not always.  */
68
 
69
#define DECR_PC_AFTER_BREAK 0
70
 
71
#if 0                           /* Disable until fixed *correctly*.  */
72
#ifndef INVALID_FLOAT
73
#ifndef NaN
74
#include <nan.h>
75
#endif /* NaN */
76
 
77
/* Return 1 if P points to an invalid floating point value.  */
78
/* Surely wrong for cross-debugging.  */
79
#define INVALID_FLOAT(p, s) \
80
         ((s == sizeof (float))?        \
81
                NaF (*(float *) p) :    \
82
                NaD (*(double *) p))
83
#endif /* INVALID_FLOAT */
84
#endif
85
 
86
/* Say how long (ordinary) registers are.  This is a piece of bogosity
87
   used in push_word and a few other places; REGISTER_RAW_SIZE is the
88
   real way to know how big a register is.  */
89
 
90
#define REGISTER_SIZE 4
91
 
92
/* Number of machine registers */
93
 
94
#define NUM_REGS                25
95
 
96
#define NUM_GENERAL_REGS        8
97
 
98
/* Initializer for an array of names of registers.
99
   There should be NUM_REGS strings in this initializer.  */
100
 
101
#define REGISTER_NAMES {"r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", \
102
                        "f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7", \
103
                        "sp", "fp", "pc", "ps",                         \
104
                        "fsr",                                          \
105
                        "l0", "l1", "l2", "l3", "xx",                   \
106
                        }
107
 
108
/* Register numbers of various important registers.
109
   Note that some of these values are "real" register numbers,
110
   and correspond to the general registers of the machine,
111
   and some are "phony" register numbers which are too large
112
   to be actual register numbers as far as the user is concerned
113
   but do serve to get the desired values when passed to read_register.  */
114
 
115
#define R0_REGNUM 0             /* General register 0 */
116
#define FP0_REGNUM 8            /* Floating point register 0 */
117
#define SP_REGNUM 16            /* Contains address of top of stack */
118
#define AP_REGNUM FP_REGNUM
119
#define FP_REGNUM 17            /* Contains address of executing stack frame */
120
#define PC_REGNUM 18            /* Contains program counter */
121
#define PS_REGNUM 19            /* Contains processor status */
122
#define FPS_REGNUM 20           /* Floating point status register */
123
#define LP0_REGNUM 21           /* Double register 0 (same as FP0) */
124
 
125
/* Total amount of space needed to store our copies of the machine's
126
   register state, the array `registers'.  */
127
#define REGISTER_BYTES \
128
  ((NUM_REGS - 4) * REGISTER_RAW_SIZE(R0_REGNUM) \
129
   + 4            * REGISTER_RAW_SIZE(LP0_REGNUM))
130
 
131
/* Index within `registers' of the first byte of the space for
132
   register N.  */
133
 
134
#define REGISTER_BYTE(N) ((N) >= LP0_REGNUM ? \
135
        LP0_REGNUM * 4 + ((N) - LP0_REGNUM) * 8 : (N) * 4)
136
 
137
/* Number of bytes of storage in the actual machine representation
138
   for register N.  On the 32000, all regs are 4 bytes
139
   except for the doubled floating registers. */
140
 
141
#define REGISTER_RAW_SIZE(N) ((N) >= LP0_REGNUM ? 8 : 4)
142
 
143
/* Number of bytes of storage in the program's representation
144
   for register N.  On the 32000, all regs are 4 bytes
145
   except for the doubled floating registers. */
146
 
147
#define REGISTER_VIRTUAL_SIZE(N) ((N) >= LP0_REGNUM ? 8 : 4)
148
 
149
/* Largest value REGISTER_RAW_SIZE can have.  */
150
 
151
#define MAX_REGISTER_RAW_SIZE 8
152
 
153
/* Largest value REGISTER_VIRTUAL_SIZE can have.  */
154
 
155
#define MAX_REGISTER_VIRTUAL_SIZE 8
156
 
157
/* Return the GDB type object for the "standard" data type
158
   of data in register N.  */
159
 
160
#define REGISTER_VIRTUAL_TYPE(N) \
161
        (((N) < FP0_REGNUM) ?                           \
162
                builtin_type_int :                      \
163
                ((N) < FP0_REGNUM + 8) ?                \
164
                        builtin_type_float :            \
165
                        ((N) < LP0_REGNUM) ?            \
166
                                builtin_type_int :      \
167
                                builtin_type_double)
168
 
169
/* Store the address of the place in which to copy the structure the
170
   subroutine will return.  This is called from call_function.
171
 
172
   On this machine this is a no-op, because gcc isn't used on it
173
   yet.  So this calling convention is not used. */
174
 
175
#define STORE_STRUCT_RETURN(ADDR, SP)
176
 
177
/* Extract from an array REGBUF containing the (raw) register state
178
   a function return value of type TYPE, and copy that, in virtual format,
179
   into VALBUF.  */
180
 
181
#define EXTRACT_RETURN_VALUE(TYPE,REGBUF,VALBUF) \
182
  memcpy (VALBUF, REGBUF+REGISTER_BYTE (TYPE_CODE (TYPE) == TYPE_CODE_FLT ? FP0_REGNUM : 0), TYPE_LENGTH (TYPE))
183
 
184
/* Write into appropriate registers a function return value
185
   of type TYPE, given in virtual format.  */
186
 
187
#define STORE_RETURN_VALUE(TYPE,VALBUF) \
188
  write_register_bytes (REGISTER_BYTE (TYPE_CODE (TYPE) == TYPE_CODE_FLT ? FP0_REGNUM : 0), VALBUF, TYPE_LENGTH (TYPE))
189
 
190
/* Extract from an array REGBUF containing the (raw) register state
191
   the address in which a function should return its structure value,
192
   as a CORE_ADDR (or an expression that can be used as one).  */
193
 
194
#define EXTRACT_STRUCT_VALUE_ADDRESS(REGBUF) (*(int *)(REGBUF))
195
 
196
/* Describe the pointer in each stack frame to the previous stack frame
197
   (its caller).  */
198
 
199
/* FRAME_CHAIN takes a frame's nominal address
200
   and produces the frame's chain-pointer. */
201
 
202
/* In the case of the ns32000 series, the frame's nominal address is the FP
203
   value, and at that address is saved previous FP value as a 4-byte word.  */
204
 
205
#define FRAME_CHAIN(thisframe)  \
206
  (!inside_entry_file ((thisframe)->pc) ? \
207
   read_memory_integer ((thisframe)->frame, 4) :\
208
   0)
209
 
210
/* Define other aspects of the stack frame.  */
211
 
212
#define FRAME_SAVED_PC(FRAME) (read_memory_integer ((FRAME)->frame + 4, 4))
213
 
214
/* Compute base of arguments. */
215
 
216
#define FRAME_ARGS_ADDRESS(fi)  \
217
  ((ns32k_get_enter_addr ((fi)->pc) > 1) ? \
218
        ((fi)->frame) : (read_register (SP_REGNUM) - 4))
219
 
220
#define FRAME_LOCALS_ADDRESS(fi) ((fi)->frame)
221
 
222
/* Get the address of the enter opcode for this function, if it is active.
223
   Returns positive address > 1 if pc is between enter/exit,
224
   1 if pc before enter or after exit, 0 otherwise. */
225
 
226
extern CORE_ADDR ns32k_get_enter_addr ();
227
 
228
/* Return number of args passed to a frame.
229
   Can return -1, meaning no way to tell.  */
230
 
231
extern int umax_frame_num_args (struct frame_info *fi);
232
#define FRAME_NUM_ARGS(fi) (umax_frame_num_args ((fi)))
233
 
234
/* Return number of bytes at start of arglist that are not really args.  */
235
 
236
#define FRAME_ARGS_SKIP 8
237
 
238
/* Put here the code to store, into a struct frame_saved_regs,
239
   the addresses of the saved registers of frame described by FRAME_INFO.
240
   This includes special registers such as pc and fp saved in special
241
   ways in the stack frame.  sp is even more special:
242
   the address we return for it IS the sp for the next frame.  */
243
 
244
extern int ns32k_localcount (CORE_ADDR enter_pc);
245
 
246
#define FRAME_FIND_SAVED_REGS(frame_info, frame_saved_regs)     \
247
{                                                               \
248
  register int  regmask, regnum;                                \
249
  int           localcount;                                     \
250
  register CORE_ADDR    enter_addr;                             \
251
  register CORE_ADDR    next_addr;                              \
252
                                                                \
253
  memset (&(frame_saved_regs), '\0', sizeof (frame_saved_regs));        \
254
  enter_addr = ns32k_get_enter_addr ((frame_info)->pc);         \
255
  if (enter_addr > 1)                                           \
256
    {                                                           \
257
      regmask = read_memory_integer (enter_addr+1, 1) & 0xff;   \
258
      localcount = ns32k_localcount (enter_addr);               \
259
      next_addr = (frame_info)->frame + localcount;             \
260
      for (regnum = 0; regnum < 8; regnum++, regmask >>= 1)      \
261
        (frame_saved_regs).regs[regnum] = (regmask & 1) ?       \
262
                                          (next_addr -= 4) : 0;  \
263
      (frame_saved_regs).regs[SP_REGNUM] = (frame_info)->frame + 4;\
264
      (frame_saved_regs).regs[PC_REGNUM] = (frame_info)->frame + 4;\
265
      (frame_saved_regs).regs[FP_REGNUM] =                      \
266
                  (read_memory_integer ((frame_info)->frame, 4));\
267
    }                                                           \
268
  else if (enter_addr == 1)                                     \
269
    {                                                           \
270
      CORE_ADDR sp = read_register (SP_REGNUM);                 \
271
      (frame_saved_regs).regs[PC_REGNUM] = sp;                  \
272
      (frame_saved_regs).regs[SP_REGNUM] = sp + 4;              \
273
    }                                                           \
274
}
275
 
276
/* Things needed for making the inferior call functions.  */
277
 
278
/* Push an empty stack frame, to record the current PC, etc.  */
279
 
280
#define PUSH_DUMMY_FRAME \
281
{ register CORE_ADDR sp = read_register (SP_REGNUM);\
282
  register int regnum;                              \
283
  sp = push_word (sp, read_register (PC_REGNUM));   \
284
  sp = push_word (sp, read_register (FP_REGNUM));   \
285
  write_register (FP_REGNUM, sp);                   \
286
  for (regnum = 0; regnum < 8; regnum++)  \
287
    sp = push_word (sp, read_register (regnum));    \
288
  write_register (SP_REGNUM, sp);                       \
289
}
290
 
291
/* Discard from the stack the innermost frame, restoring all registers.  */
292
 
293
#define POP_FRAME  \
294
{ register struct frame_info *frame = get_current_frame ();      \
295
  register CORE_ADDR fp;                                         \
296
  register int regnum;                                           \
297
  struct frame_saved_regs fsr;                                   \
298
  struct frame_info *fi;                                                 \
299
  fp = frame->frame;                                             \
300
  get_frame_saved_regs (frame, &fsr);                            \
301
  for (regnum = 0; regnum < 8; regnum++)                  \
302
    if (fsr.regs[regnum])                                        \
303
      write_register (regnum, read_memory_integer (fsr.regs[regnum], 4)); \
304
  write_register (FP_REGNUM, read_memory_integer (fp, 4));       \
305
  write_register (PC_REGNUM, read_memory_integer (fp + 4, 4));   \
306
  write_register (SP_REGNUM, fp + 8);                            \
307
  flush_cached_frames ();                                        \
308
}
309
 
310
/* This sequence of words is the instructions
311
   enter        0xff,0          82 ff 00
312
   jsr  @0x00010203     7f ae c0 01 02 03
313
   adjspd       0x69696969      7f a5 01 02 03 04
314
   bpt                  f2
315
   Note this is 16 bytes.  */
316
 
317
#define CALL_DUMMY { 0x7f00ff82, 0x0201c0ae, 0x01a57f03, 0xf2040302 }
318
 
319
#define CALL_DUMMY_START_OFFSET 3
320
#define CALL_DUMMY_LENGTH       16
321
#define CALL_DUMMY_ADDR         5
322
#define CALL_DUMMY_NARGS        11
323
 
324
/* Insert the specified number of args and function address
325
   into a call sequence of the above form stored at DUMMYNAME.  */
326
 
327
void flip_bytes (void *ptr, int count);
328
 
329
#define FIX_CALL_DUMMY(dummyname, pc, fun, nargs, args, type, gcc_p)            \
330
{                                                               \
331
        int     flipped;                                        \
332
        flipped = fun | 0xc0000000;                             \
333
        flip_bytes (&flipped, 4);                               \
334
        *((int *) (((char *) dummyname)+CALL_DUMMY_ADDR)) = flipped;    \
335
        flipped = - nargs * 4;                                  \
336
        flip_bytes (&flipped, 4);                               \
337
        *((int *) (((char *) dummyname)+CALL_DUMMY_NARGS)) = flipped;   \
338
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.