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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [gdb-5.0/] [gdb/] [config/] [ns32k/] [tm-merlin.h] - Blame information for rev 1774

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 106 markom
/* Definitions to target GDB to a merlin under utek 2.1
2
   Copyright 1986, 1987, 1989, 1991, 1993 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., 59 Temple Place - Suite 330,
19
   Boston, MA 02111-1307, USA.  */
20
 
21
#define TARGET_BYTE_ORDER LITTLE_ENDIAN
22
 
23
/* Offset from address of function to start of its code.
24
   Zero on most machines.  */
25
 
26
#define FUNCTION_START_OFFSET 0
27
 
28
/* Advance PC across any function entry prologue instructions
29
   to reach some "real" code.  */
30
 
31
extern CORE_ADDR merlin_skip_prologue PARAMS ((CORE_ADDR));
32
#define SKIP_PROLOGUE(pc) (merlin_skip_prologue (pc))
33
 
34
/* Immediately after a function call, return the saved pc.
35
   Can't always go through the frames for this because on some machines
36
   the new frame is not set up until the new function executes
37
   some instructions.  */
38
 
39
#define SAVED_PC_AFTER_CALL(frame) \
40
        read_memory_integer (read_register (SP_REGNUM), 4)
41
 
42
/* Address of end of stack space.  */
43
 
44
#define STACK_END_ADDR (0x800000)
45
 
46
/* Stack grows downward.  */
47
 
48
#define INNER_THAN(lhs,rhs) ((lhs) < (rhs))
49
 
50
/* Sequence of bytes for breakpoint instruction.  */
51
 
52
#define BREAKPOINT {0xf2}
53
 
54
/* Amount PC must be decremented by after a breakpoint.
55
   This is often the number of bytes in BREAKPOINT
56
   but not always.  */
57
 
58
#define DECR_PC_AFTER_BREAK 0
59
 
60
/* Define this to say that the "svc" insn is followed by
61
   codes in memory saying which kind of system call it is.  */
62
 
63
#define NS32K_SVC_IMMED_OPERANDS
64
 
65
/* Say how long (ordinary) registers are.  This is a piece of bogosity
66
   used in push_word and a few other places; REGISTER_RAW_SIZE is the
67
   real way to know how big a register is.  */
68
 
69
#define REGISTER_SIZE 4
70
 
71
/* Number of machine registers */
72
 
73
#define NUM_REGS                25
74
 
75
#define NUM_GENERAL_REGS        8
76
 
77
/* Initializer for an array of names of registers.
78
   There should be NUM_REGS strings in this initializer.  */
79
 
80
#define REGISTER_NAMES {"r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", \
81
                        "pc", "sp", "fp", "ps",                         \
82
                        "fsr",                                          \
83
                        "f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7", \
84
                        "l0", "l1", "l2", "l3", "l4",                   \
85
                        }
86
 
87
/* Register numbers of various important registers.
88
   Note that some of these values are "real" register numbers,
89
   and correspond to the general registers of the machine,
90
   and some are "phony" register numbers which are too large
91
   to be actual register numbers as far as the user is concerned
92
   but do serve to get the desired values when passed to read_register.  */
93
 
94
#define AP_REGNUM FP_REGNUM
95
#define FP_REGNUM 10            /* Contains address of executing stack frame */
96
#define SP_REGNUM 9             /* Contains address of top of stack */
97
#define PC_REGNUM 8             /* Contains program counter */
98
#define PS_REGNUM 11            /* Contains processor status */
99
#define FPS_REGNUM 12           /* Floating point status register */
100
#define FP0_REGNUM 13           /* Floating point register 0 */
101
#define LP0_REGNUM 21           /* Double register 0 (same as FP0) */
102
 
103
/* Total amount of space needed to store our copies of the machine's
104
   register state, the array `registers'.  */
105
#define REGISTER_BYTES ((NUM_REGS - 4) * sizeof (int) + 4 * sizeof (double))
106
 
107
/* Index within `registers' of the first byte of the space for
108
   register N.  */
109
 
110
#define REGISTER_BYTE(N) ((N) >= LP0_REGNUM ? \
111
        LP0_REGNUM * 4 + ((N) - LP0_REGNUM) * 8 : (N) * 4)
112
 
113
/* Number of bytes of storage in the actual machine representation
114
   for register N.  On the 32000, all regs are 4 bytes
115
   except for the doubled floating registers. */
116
 
117
#define REGISTER_RAW_SIZE(N) ((N) >= LP0_REGNUM ? 8 : 4)
118
 
119
/* Number of bytes of storage in the program's representation
120
   for register N.  On the 32000, all regs are 4 bytes
121
   except for the doubled floating registers. */
122
 
123
#define REGISTER_VIRTUAL_SIZE(N) ((N) >= LP0_REGNUM ? 8 : 4)
124
 
125
/* Largest value REGISTER_RAW_SIZE can have.  */
126
 
127
#define MAX_REGISTER_RAW_SIZE 8
128
 
129
/* Largest value REGISTER_VIRTUAL_SIZE can have.  */
130
 
131
#define MAX_REGISTER_VIRTUAL_SIZE 8
132
 
133
/* Return the GDB type object for the "standard" data type
134
   of data in register N.  */
135
 
136
#define REGISTER_VIRTUAL_TYPE(N) \
137
  ((N) >= FP0_REGNUM ?          \
138
    ((N) >= LP0_REGNUM ?        \
139
     builtin_type_double        \
140
     : builtin_type_float)      \
141
   : builtin_type_int)
142
 
143
/* Store the address of the place in which to copy the structure the
144
   subroutine will return.  This is called from call_function.
145
 
146
   On this machine this is a no-op, as gcc doesn't run on it yet.
147
   This calling convention is not used. */
148
 
149
#define STORE_STRUCT_RETURN(ADDR, SP)
150
 
151
/* Extract from an array REGBUF containing the (raw) register state
152
   a function return value of type TYPE, and copy that, in virtual format,
153
   into VALBUF.  */
154
 
155
#define EXTRACT_RETURN_VALUE(TYPE,REGBUF,VALBUF) \
156
  memcpy (VALBUF, REGBUF, TYPE_LENGTH (TYPE))
157
 
158
/* Write into appropriate registers a function return value
159
   of type TYPE, given in virtual format.  */
160
 
161
#define STORE_RETURN_VALUE(TYPE,VALBUF) \
162
  write_register_bytes (0, VALBUF, TYPE_LENGTH (TYPE))
163
 
164
/* Extract from an array REGBUF containing the (raw) register state
165
   the address in which a function should return its structure value,
166
   as a CORE_ADDR (or an expression that can be used as one).  */
167
 
168
#define EXTRACT_STRUCT_VALUE_ADDRESS(REGBUF) (*(int *)(REGBUF))
169
 
170
/* Describe the pointer in each stack frame to the previous stack frame
171
   (its caller).  */
172
 
173
/* FRAME_CHAIN takes a frame's nominal address
174
   and produces the frame's chain-pointer. */
175
 
176
/* In the case of the Merlin, the frame's nominal address is the FP value,
177
   and at that address is saved previous FP value as a 4-byte word.  */
178
 
179
#define FRAME_CHAIN(thisframe)  \
180
  (!inside_entry_file ((thisframe)->pc) ? \
181
   read_memory_integer ((thisframe)->frame, 4) :\
182
   0)
183
 
184
/* Define other aspects of the stack frame.  */
185
 
186
#define FRAME_SAVED_PC(FRAME) (read_memory_integer ((FRAME)->frame + 4, 4))
187
 
188
/* compute base of arguments */
189
#define FRAME_ARGS_ADDRESS(fi) ((fi)->frame)
190
 
191
#define FRAME_LOCALS_ADDRESS(fi) ((fi)->frame)
192
 
193
/* Return number of args passed to a frame.
194
   Can return -1, meaning no way to tell.  */
195
 
196
extern int merlin_frame_num_args PARAMS ((struct frame_info * fi));
197
#define FRAME_NUM_ARGS(fi) (merlin_frame_num_args ((fi)))
198
 
199
/* Return number of bytes at start of arglist that are not really args.  */
200
 
201
#define FRAME_ARGS_SKIP 8
202
 
203
/* Put here the code to store, into a struct frame_saved_regs,
204
   the addresses of the saved registers of frame described by FRAME_INFO.
205
   This includes special registers such as pc and fp saved in special
206
   ways in the stack frame.  sp is even more special:
207
   the address we return for it IS the sp for the next frame.  */
208
 
209
#define FRAME_FIND_SAVED_REGS(frame_info, frame_saved_regs) \
210
{ int regmask,regnum;                                           \
211
  int localcount;                                               \
212
  CORE_ADDR enter_addr;                                         \
213
  CORE_ADDR next_addr;                                          \
214
                                                                \
215
  enter_addr = get_pc_function_start ((frame_info)->pc);        \
216
  regmask = read_memory_integer (enter_addr+1, 1);              \
217
  localcount = ns32k_localcount (enter_addr);                   \
218
  next_addr = (frame_info)->frame + localcount;                 \
219
  for (regnum = 0; regnum < 8; regnum++, regmask >>= 1)          \
220
    (frame_saved_regs).regs[regnum]                             \
221
      = (regmask & 1) ? (next_addr -= 4) : 0;                    \
222
  (frame_saved_regs).regs[SP_REGNUM] = (frame_info)->frame + 4; \
223
  (frame_saved_regs).regs[PC_REGNUM] = (frame_info)->frame + 4; \
224
  (frame_saved_regs).regs[FP_REGNUM]                            \
225
     = read_memory_integer ((frame_info)->frame, 4); }
226
 
227
 
228
/* Things needed for making the inferior call functions.  */
229
 
230
/* Push an empty stack frame, to record the current PC, etc.  */
231
 
232
#define PUSH_DUMMY_FRAME \
233
{ register CORE_ADDR sp = read_register (SP_REGNUM);    \
234
  register int regnum;                                  \
235
  sp = push_word (sp, read_register (PC_REGNUM));       \
236
  sp = push_word (sp, read_register (FP_REGNUM));       \
237
  write_register (FP_REGNUM, sp);                       \
238
  for (regnum = 0; regnum < 8; regnum++)                 \
239
    sp = push_word (sp, read_register (regnum));        \
240
  write_register (SP_REGNUM, sp);                       \
241
}
242
 
243
/* Discard from the stack the innermost frame, restoring all registers.  */
244
 
245
#define POP_FRAME  \
246
{ register struct frame_info *frame = get_current_frame ();      \
247
  register CORE_ADDR fp;                                         \
248
  register int regnum;                                           \
249
  struct frame_saved_regs fsr;                                   \
250
  struct frame_info *fi;                                                 \
251
  fp = frame->frame;                                             \
252
  get_frame_saved_regs (frame, &fsr);                            \
253
  for (regnum = 0; regnum < 8; regnum++)                  \
254
    if (fsr.regs[regnum])                                        \
255
      write_register (regnum, read_memory_integer (fsr.regs[regnum], 4)); \
256
  write_register (FP_REGNUM, read_memory_integer (fp, 4));       \
257
  write_register (PC_REGNUM, read_memory_integer (fp + 4, 4));   \
258
  write_register (SP_REGNUM, fp + 8);                            \
259
  flush_cached_frames ();                                        \
260
}
261
 
262
/* This sequence of words is the instructions
263
   enter        0xff,0          82 ff 00
264
   jsr  @0x00010203     7f ae c0 01 02 03
265
   adjspd       0x69696969      7f a5 01 02 03 04
266
   bpt                  f2
267
   Note this is 16 bytes.  */
268
 
269
#define CALL_DUMMY { 0x7f00ff82, 0x0201c0ae, 0x01a57f03, 0xf2040302 }
270
 
271
#define CALL_DUMMY_START_OFFSET 3
272
#define CALL_DUMMY_LENGTH       16
273
#define CALL_DUMMY_ADDR         5
274
#define CALL_DUMMY_NARGS        11
275
 
276
/* Insert the specified number of args and function address
277
   into a call sequence of the above form stored at DUMMYNAME.  */
278
 
279
#define FIX_CALL_DUMMY(dummyname, pc, fun, nargs, args, type, gcc_p)            \
280
{ int flipped = fun | 0xc0000000;                               \
281
  flip_bytes (&flipped, 4);                                     \
282
  *((int *) (((char *) dummyname)+CALL_DUMMY_ADDR)) = flipped;  \
283
  flipped = - nargs * 4;                                        \
284
  flip_bytes (&flipped, 4);                                     \
285
  *((int *) (((char *) dummyname)+CALL_DUMMY_NARGS)) = flipped; \
286
}

powered by: WebSVN 2.1.0

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