Commit | Line | Data |
---|---|---|
e49d4fa6 SS |
1 | /* Parameters for execution on a TI TMS320C80 (MVP) processor. |
2 | Copyright 1997 | |
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, Boston, MA 02111-1307, USA. */ | |
20 | ||
21 | #ifndef TM_TIC80_H | |
22 | #define TM_TIC80_H | |
23 | ||
24 | #ifdef __STDC__ /* Forward declare structs used in prototypes */ | |
25 | struct frame_info; | |
26 | struct type; | |
27 | struct value; | |
28 | struct symbol; | |
29 | struct frame_saved_regs; | |
30 | #endif | |
31 | ||
32 | #define TARGET_BYTE_ORDER LITTLE_ENDIAN | |
33 | ||
34 | /* Define this if the C compiler puts an underscore at the front | |
35 | of external names before giving them to the linker. */ | |
36 | ||
37 | #define NAMES_HAVE_UNDERSCORE | |
38 | ||
39 | #define NUM_REGS 38 | |
40 | ||
41 | #define REGISTER_NAMES \ | |
42 | { "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", \ | |
43 | "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15", \ | |
44 | "r16", "r17", "r18", "r19", "r20", "r21", "r22", "r23", \ | |
45 | "r24", "r25", "r26", "r27", "r28", "r29", "r30", "r31", \ | |
46 | "pc", "npc", \ | |
47 | "a0", "a1", "a2", "a3", \ | |
48 | } | |
49 | ||
50 | /* Various dedicated register numbers | |
51 | FIXME: Shadow updates in sim/tic80/sim-calls.c */ | |
52 | ||
53 | #define SP_REGNUM 1 /* Contains address of top of stack */ | |
54 | #define ARG0_REGNUM 2 /* Contains argument 1 (r3 has high word) */ | |
55 | #define RET_REGNUM 2 /* Contains function return value */ | |
56 | #define ARGLAST_REGNUM 12 /* Contains argument 6 (r13 has high word) */ | |
57 | #define FP_REGNUM 30 /* Contains address of executing stack frame */ | |
58 | #define LR_REGNUM 31 /* Contains address of caller (link register) */ | |
59 | #define PC_REGNUM 32 /* Contains program counter (FIXME?) */ | |
60 | #define NPC_REGNUM 33 /* Contains the next program counter (FIXME?) */ | |
61 | #define A0_REGNUM 34 /* Accumulator register 0 */ | |
62 | #define A3_REGNUM 37 /* Accumulator register 1 */ | |
63 | ||
64 | #define R0_REGNUM 0 /* General Purpose Register 0 - for sim */ | |
65 | #define Rn_REGNUM 31 /* Last General Purpose Register - for sim */ | |
66 | #define An_REGNUM A3_REGNUM /* Last Accumulator register - for sim */ | |
67 | ||
68 | /* Total amount of space needed to store our copies of the machine's | |
69 | register state, the array `registers'. */ | |
70 | ||
71 | #define REGISTER_BYTES (((NUM_REGS - 4) * 4) + (4 * 8)) | |
72 | ||
73 | /* Index within `registers' of the first byte of the space for | |
74 | register N. */ | |
75 | ||
76 | #define REGISTER_BYTE(N) \ | |
77 | (((N) >= A0_REGNUM) ? (((N) - A0_REGNUM) * 8 + A0_REGNUM * 4) : ((N) * 4)) | |
78 | ||
79 | /* Most registers are 4 bytes */ | |
80 | ||
81 | #define REGISTER_SIZE 4 | |
82 | ||
83 | /* Some registers are 8 bytes. */ | |
84 | ||
85 | #define REGISTER_RAW_SIZE(N) \ | |
86 | (((N) >= A0_REGNUM) ? 8 : 4) | |
87 | ||
88 | /* Largest value REGISTER_RAW_SIZE can have. */ | |
89 | ||
90 | #define MAX_REGISTER_RAW_SIZE (8) | |
91 | ||
92 | /* All regs are 4 bytes. */ | |
93 | ||
94 | #define REGISTER_VIRTUAL_SIZE(N) (REGISTER_RAW_SIZE(N)) | |
95 | ||
96 | /* Largest value REGISTER_VIRTUAL_SIZE can have. */ | |
97 | ||
98 | #define MAX_REGISTER_VIRTUAL_SIZE (MAX_REGISTER_RAW_SIZE) | |
99 | ||
100 | /* Return the GDB type object for the "standard" data type | |
101 | of data in register N. */ | |
102 | ||
103 | #define REGISTER_VIRTUAL_TYPE(N) /* FIXME? */ \ | |
104 | (((N) >= A0_REGNUM) ? builtin_type_float : builtin_type_int) | |
105 | ||
106 | /* Offset from address of function to start of its code. | |
107 | Zero on most machines. */ | |
108 | ||
109 | #define FUNCTION_START_OFFSET 0 | |
110 | ||
111 | /* Stack grows downward. */ | |
112 | ||
113 | #define INNER_THAN(lhs,rhs) ((lhs) < (rhs)) | |
114 | ||
115 | /* Sequence of bytes for breakpoint instruction. | |
116 | This is padded out to the size of a machine word. */ | |
117 | ||
118 | #define BREAKPOINT {0x49, 0x80, 0x00, 0x00} /* FIXME! */ | |
119 | ||
120 | /* Amount PC must be decremented by after a breakpoint. | |
121 | This is often the number of bytes in BREAKPOINT | |
122 | but not always. */ | |
123 | ||
124 | #define DECR_PC_AFTER_BREAK 0 /* FIXME! */ | |
125 | ||
126 | /* Discard from the stack the innermost frame, restoring all registers. */ | |
127 | ||
128 | #define POP_FRAME tic80_pop_frame(get_current_frame ()) | |
129 | extern struct frame_info *tic80_pop_frame PARAMS ((struct frame_info *frame)); | |
130 | ||
131 | /* Return number of bytes at start of arglist that are not really args. */ | |
132 | ||
133 | #define FRAME_ARGS_SKIP 0 | |
134 | ||
135 | /* Set VAL to the number of args passed to frame described by FI. | |
136 | Can set VAL to -1, meaning no way to tell. */ | |
137 | /* We can't tell how many args there are */ | |
138 | ||
392a587b | 139 | #define FRAME_NUM_ARGS(fi) (-1) |
e49d4fa6 SS |
140 | |
141 | #define FRAME_ARGS_SKIP 0 | |
142 | #define FRAME_ARGS_ADDRESS(fi) (fi)->frame | |
143 | #define FRAME_LOCALS_ADDRESS(fi) (fi)->frame | |
144 | ||
145 | /* Define other aspects of the stack frame. | |
146 | We keep the offsets of all saved registers, 'cause we need 'em a lot! | |
147 | We also keep the current size of the stack frame, and the offset of | |
148 | the frame pointer from the stack pointer (for frameless functions, and | |
149 | when we're still in the prologue of a function with a frame) */ | |
150 | ||
151 | #define EXTRA_FRAME_INFO \ | |
152 | struct frame_saved_regs fsr; \ | |
153 | int framesize; \ | |
154 | int frameoffset; \ | |
155 | int framereg; | |
156 | ||
157 | extern void tic80_init_extra_frame_info PARAMS ((struct frame_info *fi)); | |
158 | #define INIT_EXTRA_FRAME_INFO(fromleaf, fi) tic80_init_extra_frame_info (fi) | |
159 | #define INIT_FRAME_PC /* Not necessary */ | |
160 | ||
161 | /* Put here the code to store, into a struct frame_saved_regs, | |
162 | the addresses of the saved registers of frame described by FRAME_INFO. | |
163 | This includes special registers such as pc and fp saved in special | |
164 | ways in the stack frame. sp is even more special: | |
165 | the address we return for it IS the sp for the next frame. */ | |
166 | ||
167 | #define FRAME_FIND_SAVED_REGS(frame_info, frame_saved_regs) \ | |
168 | tic80_frame_find_saved_regs(frame_info, &(frame_saved_regs)) | |
169 | extern void tic80_frame_find_saved_regs PARAMS ((struct frame_info *, struct frame_saved_regs *)); | |
170 | ||
171 | /* Advance PC across any function entry prologue instructions | |
172 | to reach some "real" code. */ | |
173 | ||
b83266a0 | 174 | #define SKIP_PROLOGUE(pc) (tic80_skip_prologue (pc)) |
e49d4fa6 SS |
175 | extern CORE_ADDR tic80_skip_prologue PARAMS ((CORE_ADDR pc)); |
176 | ||
177 | /* Immediately after a function call, return the saved pc. | |
178 | Can't always go through the frames for this because on some machines | |
179 | the new frame is not set up until the new function executes | |
180 | some instructions. */ | |
181 | ||
182 | #define SAVED_PC_AFTER_CALL(frame) read_register (LR_REGNUM) | |
183 | ||
184 | /* Describe the pointer in each stack frame to the previous stack frame | |
185 | (its caller). */ | |
186 | ||
187 | /* FRAME_CHAIN takes a frame's nominal address | |
188 | and produces the frame's chain-pointer. */ | |
189 | ||
190 | #define FRAME_CHAIN(thisframe) (CORE_ADDR) tic80_frame_chain (thisframe) | |
191 | extern CORE_ADDR tic80_frame_chain PARAMS ((struct frame_info *)); | |
192 | ||
193 | #define FRAME_SAVED_PC(FRAME) tic80_frame_saved_pc (FRAME) | |
194 | extern CORE_ADDR tic80_frame_saved_pc PARAMS ((struct frame_info *)); | |
195 | ||
196 | /* Store the address of the place in which to copy the structure the | |
197 | subroutine will return. This is called from call_function. | |
198 | ||
199 | We store structs through a pointer passed in R2 */ | |
200 | ||
201 | #define STORE_STRUCT_RETURN(STRUCT_ADDR, SP) \ | |
202 | write_register (ARG0_REGNUM, STRUCT_ADDR) | |
203 | ||
204 | /* Extract from an array REGBUF containing the (raw) register state | |
205 | a function return value of type TYPE, and copy that, in virtual format, | |
206 | into VALBUF. */ | |
207 | ||
208 | #define EXTRACT_RETURN_VALUE(TYPE,REGBUF,VALBUF) \ | |
209 | memcpy ((VALBUF), \ | |
210 | (char *)(REGBUF) + REGISTER_BYTE (RET_REGNUM) + \ | |
211 | ((TYPE_LENGTH (TYPE) > 4 ? 8 : 4) - TYPE_LENGTH (TYPE)), \ | |
212 | TYPE_LENGTH (TYPE)) | |
213 | ||
214 | /* Write into appropriate registers a function return value | |
215 | of type TYPE, given in virtual format. */ | |
216 | ||
217 | #define STORE_RETURN_VALUE(TYPE,VALBUF) \ | |
218 | write_register_bytes(REGISTER_BYTE (RET_REGNUM) + \ | |
219 | ((TYPE_LENGTH (TYPE) > 4 ? 8:4) - TYPE_LENGTH (TYPE)),\ | |
220 | (VALBUF), TYPE_LENGTH (TYPE)); | |
221 | ||
222 | ||
223 | ||
224 | /* PUSH_ARGUMENTS */ | |
225 | extern CORE_ADDR tic80_push_arguments PARAMS ((int nargs, | |
226 | struct value **args, | |
227 | CORE_ADDR sp, | |
228 | unsigned char struct_return, | |
229 | CORE_ADDR struct_addr)); | |
230 | ||
231 | #define PUSH_ARGUMENTS(NARGS, ARGS, SP, STRUCT_RETURN, STRUCT_ADDR) \ | |
392a587b | 232 | (tic80_push_arguments (NARGS, ARGS, SP, STRUCT_RETURN, STRUCT_ADDR)) |
e49d4fa6 SS |
233 | |
234 | /* PUSH_RETURN_ADDRESS */ | |
235 | extern CORE_ADDR tic80_push_return_address PARAMS ((CORE_ADDR, CORE_ADDR)); | |
236 | #define PUSH_RETURN_ADDRESS(PC, SP) tic80_push_return_address (PC, SP) | |
237 | ||
238 | /* override the standard get_saved_register function with | |
239 | one that takes account of generic CALL_DUMMY frames */ | |
240 | #define GET_SAVED_REGISTER(raw_buffer, optimized, addrp, frame, regnum, lval) \ | |
241 | generic_get_saved_register (raw_buffer, optimized, addrp, frame, regnum, lval) | |
242 | ||
243 | #define USE_GENERIC_DUMMY_FRAMES 1 | |
244 | #define CALL_DUMMY {0} | |
245 | #define CALL_DUMMY_LENGTH (0) | |
246 | #define CALL_DUMMY_START_OFFSET (0) | |
247 | #define CALL_DUMMY_BREAKPOINT_OFFSET (0) | |
248 | #define FIX_CALL_DUMMY(DUMMY1, STARTADDR, FUNADDR, NARGS, ARGS, TYPE, GCCP) | |
249 | #define CALL_DUMMY_LOCATION AT_ENTRY_POINT | |
250 | #define CALL_DUMMY_ADDRESS() entry_point_address () | |
251 | ||
252 | /* generic dummy frame stuff */ | |
253 | ||
254 | #define PUSH_DUMMY_FRAME generic_push_dummy_frame () | |
255 | #define PC_IN_CALL_DUMMY(PC, SP, FP) generic_pc_in_call_dummy (PC, SP, FP) | |
256 | ||
257 | #endif /* TM_TIC80_H */ |