* defs.h: Move definitions of TARGET_*_BIT after include of tm.h.
[deliverable/binutils-gdb.git] / gdb / config / h8300 / tm-h8300.h
1 /* Parameters for execution on a H8/300 series machine.
2 Copyright 1992, 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., 675 Mass Ave, Cambridge, MA 02139, USA. */
19
20 /* Contributed by Steve Chamberlain sac@cygnus.com */
21
22
23 /* 1 if debugging H8/300H application */
24 extern int h8300hmode;
25
26 /* Number of bytes in a word */
27
28 #define BINWORD (h8300hmode?4:2)
29
30 #define EXTRA_FRAME_INFO \
31 struct frame_saved_regs *fsr; \
32 CORE_ADDR from_pc; \
33 CORE_ADDR args_pointer;\
34 CORE_ADDR locals_pointer ;
35
36 /* Zero the frame_saved_regs pointer when the frame is initialized,
37 so that FRAME_FIND_SAVED_REGS () will know to allocate and
38 initialize a frame_saved_regs struct the first time it is called.
39 Set the arg_pointer to -1, which is not valid; 0 and other values
40 indicate real, cached values. */
41
42 #define INIT_EXTRA_FRAME_INFO(fromleaf, fi) \
43 init_extra_frame_info (fromleaf, fi)
44
45 extern void init_extra_frame_info ();
46
47 #define IEEE_FLOAT
48 /* Define the bit, byte, and word ordering of the machine. */
49 #define TARGET_BYTE_ORDER BIG_ENDIAN
50
51 #define TARGET_INT_BIT 16
52 #define TARGET_LONG_BIT 32
53 #define TARGET_PTR_BIT (h8300hmode ? 32:16)
54
55 /* Offset from address of function to start of its code.
56 Zero on most machines. */
57
58 #define FUNCTION_START_OFFSET 0
59
60 /* Advance PC across any function entry prologue instructions
61 to reach some "real" code. */
62
63 #define SKIP_PROLOGUE(ip) {(ip) = h8300_skip_prologue(ip);}
64 extern CORE_ADDR h8300_skip_prologue ();
65
66 /* Immediately after a function call, return the saved pc.
67 Can't always go through the frames for this because on some machines
68 the new frame is not set up until the new function executes
69 some instructions. */
70
71 #define SAVED_PC_AFTER_CALL(frame) \
72 read_memory_unsigned_integer (read_register (SP_REGNUM), BINWORD)
73
74 /* Stack grows downward. */
75
76 #define INNER_THAN <
77
78 /*#define BREAKPOINT {0x7A, 0xFF}*/
79 #define BREAKPOINT {0x01, 0x80} /* Sleep */
80
81 /* If your kernel resets the pc after the trap happens you may need to
82 define this before including this file. */
83
84 #define DECR_PC_AFTER_BREAK 0
85
86 /* Nonzero if instruction at PC is a return instruction. */
87 /* Allow any of the return instructions, including a trapv and a return
88 from interupt. */
89
90 #define ABOUT_TO_RETURN(pc) ((read_memory_unsigned_integer (pc, 2) & ~0x3) == 0x4e74)
91
92 /* Return 1 if P points to an invalid floating point value. */
93
94 #define INVALID_FLOAT(p, len) 0 /* Just a first guess; not checked */
95
96 /* Say how long registers are. */
97
98 #define REGISTER_TYPE unsigned short
99
100 #define NUM_REGS 13
101
102 #define REGISTER_BYTES (NUM_REGS * 4)
103
104 /* Index within `registers' of the first byte of the space for
105 register N. */
106
107 #define REGISTER_BYTE(N) ((N) * 4)
108
109 /* Number of bytes of storage in the actual machine representation
110 for register N. On the H8/300, all regs are 2 bytes. */
111
112 #define REGISTER_RAW_SIZE(N) (h8300hmode ? 4 : 2)
113
114 /* Number of bytes of storage in the program's representation
115 for register N. */
116
117 #define REGISTER_VIRTUAL_SIZE(N) (h8300hmode ? 4 : 2)
118
119 /* Largest value REGISTER_RAW_SIZE can have. */
120
121 #define MAX_REGISTER_RAW_SIZE 4
122
123 /* Largest value REGISTER_VIRTUAL_SIZE can have. */
124
125 #define MAX_REGISTER_VIRTUAL_SIZE 4
126
127 /* Return the GDB type object for the "standard" data type
128 of data in register N. */
129
130 #define REGISTER_VIRTUAL_TYPE(N) \
131 (h8300hmode ? builtin_type_unsigned_long : builtin_type_unsigned_short)
132
133 /* Initializer for an array of names of registers.
134 Entries beyond the first NUM_REGS are ignored. */
135
136 #define REGISTER_NAMES \
137 {"r0", "r1", "r2", "r3", "r4", "r5", "r6", "sp", "ccr","pc","cycles","tick","inst"}
138
139 /* Register numbers of various important registers.
140 Note that some of these values are "real" register numbers,
141 and correspond to the general registers of the machine,
142 and some are "phony" register numbers which are too large
143 to be actual register numbers as far as the user is concerned
144 but do serve to get the desired values when passed to read_register. */
145
146 #define FP_REGNUM 6 /* Contains address of executing stack frame */
147 #define SP_REGNUM 7 /* Contains address of top of stack */
148 #define CCR_REGNUM 8 /* Contains processor status */
149 #define PC_REGNUM 9 /* Contains program counter */
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 /* FIXME: Won't work with both h8/300's. */
156
157 #define EXTRACT_RETURN_VALUE(TYPE,REGBUF,VALBUF) \
158 memcpy (VALBUF, (char *)(REGBUF), TYPE_LENGTH(TYPE))
159
160 /* Write into appropriate registers a function return value
161 of type TYPE, given in virtual format. Assumes floats are passed
162 in d0/d1. */
163 /* FIXME: Won't work with both h8/300's. */
164
165 #define STORE_RETURN_VALUE(TYPE,VALBUF) \
166 write_register_bytes (0, VALBUF, TYPE_LENGTH (TYPE))
167
168 /* Extract from an array REGBUF containing the (raw) register state
169 the address in which a function should return its structure value,
170 as a CORE_ADDR (or an expression that can be used as one). */
171 /* FIXME: Won't work with both h8/300's. */
172
173 #define EXTRACT_STRUCT_VALUE_ADDRESS(REGBUF) (*(CORE_ADDR *)(REGBUF))
174 \f
175 /* Describe the pointer in each stack frame to the previous stack frame
176 (its caller). */
177
178 /* FRAME_CHAIN takes a frame's nominal address
179 and produces the frame's chain-pointer.
180
181 However, if FRAME_CHAIN_VALID returns zero,
182 it means the given frame is the outermost one and has no caller. */
183
184 /* In the case of the H8/300, the frame's nominal address
185 is the address of a 2-byte word containing the calling frame's address. */
186
187 /* Use the alternate method of avoiding running up off the end of
188 the frame chain or following frames back into the startup code.
189 See the comments in objfile.h */
190
191 #define FRAME_CHAIN_VALID_ALTERNATE
192
193 /* Define other aspects of the stack frame. */
194
195 /* A macro that tells us whether the function invocation represented
196 by FI does not have a frame on the stack associated with it. If it
197 does not, FRAMELESS is set to 1, else 0. */
198 #define FRAMELESS_FUNCTION_INVOCATION(FI, FRAMELESS) \
199 (FRAMELESS) = frameless_look_for_prologue(FI)
200
201 /* Any function with a frame looks like this
202 SECOND ARG
203 FIRST ARG
204 RET PC
205 SAVED R2
206 SAVED R3
207 SAVED FP <-FP POINTS HERE
208 LOCALS0
209 LOCALS1 <-SP POINTS HERE
210 */
211
212 #define FRAME_SAVED_PC(FRAME) frame_saved_pc(FRAME)
213
214 #define FRAME_ARGS_ADDRESS(fi) frame_args_address(fi)
215
216 #define FRAME_LOCALS_ADDRESS(fi) frame_locals_address(fi);
217
218 /* Set VAL to the number of args passed to frame described by FI.
219 Can set VAL to -1, meaning no way to tell. */
220
221 /* We can't tell how many args there are
222 now that the C compiler delays popping them. */
223
224 #define FRAME_NUM_ARGS(val,fi) (val = -1)
225
226 /* Return number of bytes at start of arglist that are not really args. */
227
228 #define FRAME_ARGS_SKIP 0
229
230 /* Put here the code to store, into a struct frame_saved_regs,
231 the addresses of the saved registers of frame described by FRAME_INFO.
232 This includes special registers such as pc and fp saved in special
233 ways in the stack frame. sp is even more special:
234 the address we return for it IS the sp for the next frame. */
235
236 #define FRAME_FIND_SAVED_REGS(frame_info, frame_saved_regs) \
237 frame_find_saved_regs(frame_info, &(frame_saved_regs))
238 \f
239
240 /* Push an empty stack frame, to record the current PC, etc. */
241
242 /*#define PUSH_DUMMY_FRAME { h8300_push_dummy_frame (); }*/
243
244 /* Discard from the stack the innermost frame, restoring all registers. */
245
246 #define POP_FRAME { h8300_pop_frame (); }
247
248 typedef unsigned short INSN_WORD;
249
250
251 #define PRINT_REGISTER_HOOK(regno) print_register_hook(regno)
252
253 #define GDB_TARGET_IS_H8300
254
255 #define NUM_REALREGS 10
256 #define NOP { 0x01, 0x80} /* A sleep insn */
This page took 0.079826 seconds and 5 git commands to generate.