1 | /* |
---|
2 | * @(#)genoffsets.c 1.7 - 95/09/25 |
---|
3 | * |
---|
4 | * |
---|
5 | * genoffsets.c |
---|
6 | * |
---|
7 | * This file generates the offsets.h for the HP PA-RISC port of RTEMS. |
---|
8 | * |
---|
9 | * NOTE: It only prints the offset for structures actually used |
---|
10 | * by the assembly code. |
---|
11 | * |
---|
12 | * COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994. |
---|
13 | * On-Line Applications Research Corporation (OAR). |
---|
14 | * |
---|
15 | * This material may be reproduced by or for the U.S. Government pursuant |
---|
16 | * to the copyright license under the clause at DFARS 252.227-7013. This |
---|
17 | * notice must appear in all copies of this file and its derivatives. |
---|
18 | * |
---|
19 | * $Id$ |
---|
20 | * |
---|
21 | */ |
---|
22 | |
---|
23 | #include <stdio.h> |
---|
24 | |
---|
25 | #include <rtems/system.h> |
---|
26 | |
---|
27 | void print_information( void ); |
---|
28 | |
---|
29 | int main( |
---|
30 | int argc, |
---|
31 | char **argv |
---|
32 | ) |
---|
33 | { |
---|
34 | unsigned int size = 0; |
---|
35 | |
---|
36 | /* |
---|
37 | * Print the file header |
---|
38 | */ |
---|
39 | |
---|
40 | printf( |
---|
41 | "/* offsets.h\n" |
---|
42 | " *\n" |
---|
43 | " * This include file contains the offsets of elements in the\n" |
---|
44 | " * C data structures used by the assembly language code for the\n" |
---|
45 | " * HP PA-RISC 1.1 port of RTEMS.\n" |
---|
46 | " *\n" |
---|
47 | " * NOTE: THIS FILE IS AUTOMATICALLY GENERATED!!!!\n" |
---|
48 | " * DO NOT EDIT THIS BY HAND!!!!\n" |
---|
49 | " *\n" |
---|
50 | " * COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994.\n" |
---|
51 | " * On-Line Applications Research Corporation (OAR).\n" |
---|
52 | " * All rights assigned to U.S. Government, 1994.\n" |
---|
53 | " *\n" |
---|
54 | " * This material may be reproduced by or for the U.S. Government pursuant\n" |
---|
55 | " * to the copyright license under the clause at DFARS 252.227-7013. This\n" |
---|
56 | " * notice must appear in all copies of this file and its derivatives.\n" |
---|
57 | " */\n" |
---|
58 | "\n" |
---|
59 | "#ifndef __OFFSETS_h\n" |
---|
60 | "#define __OFFSETS_h\n" |
---|
61 | "\n" |
---|
62 | ); |
---|
63 | |
---|
64 | #define PRINT_IT( STRING, TYPE, FIELD ) \ |
---|
65 | printf( "#define\t%s\t0x%p\t\t/* %d */\n", \ |
---|
66 | STRING, \ |
---|
67 | &((TYPE)0)->FIELD, \ |
---|
68 | (int) &((TYPE)0)->FIELD ); |
---|
69 | |
---|
70 | #define PRINT_SIZE( STRING, item ) \ |
---|
71 | printf( "#define\t%s\t%d\t\t/* 0x%x */\n", \ |
---|
72 | STRING, \ |
---|
73 | sizeof(item), \ |
---|
74 | sizeof(item) ); |
---|
75 | |
---|
76 | #define PRINT_COMMENT( STRING ) \ |
---|
77 | printf( \ |
---|
78 | "\n" \ |
---|
79 | "/*\n" \ |
---|
80 | " * " STRING "\n" \ |
---|
81 | " */\n" \ |
---|
82 | "\n" \ |
---|
83 | ); |
---|
84 | |
---|
85 | #if defined(__hpux__) && defined(__hppa__) |
---|
86 | |
---|
87 | /* |
---|
88 | * Offsets of elements in the Context_control structure. |
---|
89 | */ |
---|
90 | |
---|
91 | PRINT_COMMENT("Context_Control information"); |
---|
92 | |
---|
93 | PRINT_IT( "FLAGS_OFFSET", Context_Control *, flags ); |
---|
94 | PRINT_IT( "R1_OFFSET", Context_Control *, gr1 ); |
---|
95 | PRINT_IT( "R2_OFFSET", Context_Control *, gr2 ); |
---|
96 | PRINT_IT( "R3_OFFSET", Context_Control *, gr3 ); |
---|
97 | PRINT_IT( "R4_OFFSET", Context_Control *, gr4 ); |
---|
98 | PRINT_IT( "R5_OFFSET", Context_Control *, gr5 ); |
---|
99 | PRINT_IT( "R6_OFFSET", Context_Control *, gr6 ); |
---|
100 | PRINT_IT( "R7_OFFSET", Context_Control *, gr7 ); |
---|
101 | PRINT_IT( "R8_OFFSET", Context_Control *, gr8 ); |
---|
102 | PRINT_IT( "R9_OFFSET", Context_Control *, gr9 ); |
---|
103 | PRINT_IT( "R10_OFFSET", Context_Control *, gr10 ); |
---|
104 | PRINT_IT( "R11_OFFSET", Context_Control *, gr11 ); |
---|
105 | PRINT_IT( "R12_OFFSET", Context_Control *, gr12 ); |
---|
106 | PRINT_IT( "R13_OFFSET", Context_Control *, gr13 ); |
---|
107 | PRINT_IT( "R14_OFFSET", Context_Control *, gr14 ); |
---|
108 | PRINT_IT( "R15_OFFSET", Context_Control *, gr15 ); |
---|
109 | PRINT_IT( "R16_OFFSET", Context_Control *, gr16 ); |
---|
110 | PRINT_IT( "R17_OFFSET", Context_Control *, gr17 ); |
---|
111 | PRINT_IT( "R18_OFFSET", Context_Control *, gr18 ); |
---|
112 | PRINT_IT( "R19_OFFSET", Context_Control *, gr19 ); |
---|
113 | PRINT_IT( "R20_OFFSET", Context_Control *, gr20 ); |
---|
114 | PRINT_IT( "R21_OFFSET", Context_Control *, gr21 ); |
---|
115 | PRINT_IT( "R22_OFFSET", Context_Control *, gr22 ); |
---|
116 | PRINT_IT( "R23_OFFSET", Context_Control *, gr23 ); |
---|
117 | PRINT_IT( "R24_OFFSET", Context_Control *, gr24 ); |
---|
118 | PRINT_IT( "R25_OFFSET", Context_Control *, gr25 ); |
---|
119 | PRINT_IT( "R26_OFFSET", Context_Control *, gr26 ); |
---|
120 | PRINT_IT( "R27_OFFSET", Context_Control *, gr27 ); |
---|
121 | PRINT_IT( "R28_OFFSET", Context_Control *, gr28 ); |
---|
122 | PRINT_IT( "R29_OFFSET", Context_Control *, gr29 ); |
---|
123 | PRINT_IT( "R30_OFFSET", Context_Control *, sp ); |
---|
124 | PRINT_IT( "R31_OFFSET", Context_Control *, gr31 ); |
---|
125 | |
---|
126 | /* |
---|
127 | * And common aliases for the above |
---|
128 | */ |
---|
129 | |
---|
130 | PRINT_COMMENT("Common aliases for above"); |
---|
131 | |
---|
132 | PRINT_IT( "RP_OFFSET", Context_Control *, gr2 ); |
---|
133 | PRINT_IT( "ARG3_OFFSET", Context_Control *, gr23 ); |
---|
134 | PRINT_IT( "ARG2_OFFSET", Context_Control *, gr24 ); |
---|
135 | PRINT_IT( "ARG1_OFFSET", Context_Control *, gr25 ); |
---|
136 | PRINT_IT( "ARG0_OFFSET", Context_Control *, gr26 ); |
---|
137 | PRINT_IT( "SP_OFFSET", Context_Control *, sp ); |
---|
138 | PRINT_IT( "DP_OFFSET", Context_Control *, gr27 ); |
---|
139 | PRINT_IT( "RET0_OFFSET", Context_Control *, gr28 ); |
---|
140 | PRINT_IT( "RET1_OFFSET", Context_Control *, gr29 ); |
---|
141 | |
---|
142 | PRINT_SIZE("CPU_CONTEXT_SIZE", Context_Control); |
---|
143 | |
---|
144 | PRINT_COMMENT("Context_Control_fp information"); |
---|
145 | |
---|
146 | PRINT_SIZE("CPU_CONTEXT_FP_SIZE", Context_Control_fp); |
---|
147 | |
---|
148 | /* |
---|
149 | * And the control registers |
---|
150 | */ |
---|
151 | |
---|
152 | PRINT_COMMENT("Control register portion of context"); |
---|
153 | |
---|
154 | PRINT_IT( "SAR_OFFSET", Context_Control *, sar ); |
---|
155 | PRINT_IT( "IPSW_OFFSET", Context_Control *, ipsw ); |
---|
156 | PRINT_IT( "IIR_OFFSET", Context_Control *, iir ); |
---|
157 | PRINT_IT( "IOR_OFFSET", Context_Control *, ior ); |
---|
158 | PRINT_IT( "ISR_OFFSET", Context_Control *, isr ); |
---|
159 | PRINT_IT( "PCOQFRONT_OFFSET", Context_Control *, pcoqfront ); |
---|
160 | PRINT_IT( "PCOQBACK_OFFSET", Context_Control *, pcoqback ); |
---|
161 | PRINT_IT( "PCSQFRONT_OFFSET", Context_Control *, pcsqfront ); |
---|
162 | PRINT_IT( "PCSQBACK_OFFSET", Context_Control *, pcsqback ); |
---|
163 | PRINT_IT( "ITIMER_OFFSET", Context_Control *, itimer ); |
---|
164 | |
---|
165 | /* |
---|
166 | * Full interrupt frame (integer + float) |
---|
167 | */ |
---|
168 | PRINT_COMMENT("Interrupt frame information"); |
---|
169 | |
---|
170 | PRINT_IT( "INTEGER_CONTEXT_OFFSET", CPU_Interrupt_frame *, Integer ); |
---|
171 | PRINT_IT( "FP_CONTEXT_OFFSET", CPU_Interrupt_frame *, Floating_Point ); |
---|
172 | size = sizeof( CPU_Interrupt_frame ); |
---|
173 | |
---|
174 | if ( size % CPU_STACK_ALIGNMENT ) |
---|
175 | size += CPU_STACK_ALIGNMENT - (size % CPU_STACK_ALIGNMENT); |
---|
176 | |
---|
177 | printf( "#define\tCPU_INTERRUPT_FRAME_SIZE\t%d\t\t/* 0x%x */\n", size, size ); |
---|
178 | |
---|
179 | #else |
---|
180 | |
---|
181 | print_information(); |
---|
182 | |
---|
183 | #endif |
---|
184 | |
---|
185 | #undef PRINT_IT |
---|
186 | #undef PRINT_SIZE |
---|
187 | #undef PRINT_COMMENT |
---|
188 | |
---|
189 | /* |
---|
190 | * Print the end of file stuff |
---|
191 | */ |
---|
192 | |
---|
193 | printf( |
---|
194 | "\n" |
---|
195 | "#endif /* __OFFSETS_h */\n" |
---|
196 | "\n" |
---|
197 | "/* end of include file */\n" |
---|
198 | ); |
---|
199 | |
---|
200 | return 0; |
---|
201 | } |
---|
202 | |
---|
203 | void print_information( void ) |
---|
204 | { |
---|
205 | |
---|
206 | #define PRINT_IT( STRING, NUMBER ) \ |
---|
207 | printf( "#define\t%s\t0x%x\t\t/* %d */\n", \ |
---|
208 | STRING, \ |
---|
209 | NUMBER, \ |
---|
210 | NUMBER ); |
---|
211 | |
---|
212 | #define PRINT_SIZE( STRING, NUMBER ) \ |
---|
213 | printf( "#define\t%s\t0x%x\t\t/* %d */\n", \ |
---|
214 | STRING, \ |
---|
215 | NUMBER, \ |
---|
216 | NUMBER ); |
---|
217 | |
---|
218 | #define PRINT_COMMENT( STRING ) \ |
---|
219 | printf( \ |
---|
220 | "\n" \ |
---|
221 | "/*\n" \ |
---|
222 | " * " STRING "\n" \ |
---|
223 | " */\n" \ |
---|
224 | "\n" \ |
---|
225 | ); |
---|
226 | |
---|
227 | /* |
---|
228 | * Offsets of elements in the Context_control structure. |
---|
229 | */ |
---|
230 | |
---|
231 | PRINT_COMMENT("Context_Control information"); |
---|
232 | |
---|
233 | PRINT_IT( "FLAGS_OFFSET", 0x00 ); |
---|
234 | PRINT_IT( "R1_OFFSET", 0x04 ); |
---|
235 | PRINT_IT( "R2_OFFSET", 0x08 ); |
---|
236 | PRINT_IT( "R3_OFFSET", 0x0c ); |
---|
237 | PRINT_IT( "R4_OFFSET", 0x00 ); |
---|
238 | PRINT_IT( "R5_OFFSET", 0x14 ); |
---|
239 | PRINT_IT( "R6_OFFSET", 0x18 ); |
---|
240 | PRINT_IT( "R7_OFFSET", 0x1c ); |
---|
241 | PRINT_IT( "R8_OFFSET", 0x20 ); |
---|
242 | PRINT_IT( "R9_OFFSET", 0x24 ); |
---|
243 | PRINT_IT( "R10_OFFSET", 0x28 ); |
---|
244 | PRINT_IT( "R11_OFFSET", 0x2c ); |
---|
245 | PRINT_IT( "R12_OFFSET", 0x30 ); |
---|
246 | PRINT_IT( "R13_OFFSET", 0x34 ); |
---|
247 | PRINT_IT( "R14_OFFSET", 0x38 ); |
---|
248 | PRINT_IT( "R15_OFFSET", 0x3c ); |
---|
249 | PRINT_IT( "R16_OFFSET", 0x40 ); |
---|
250 | PRINT_IT( "R17_OFFSET", 0x44 ); |
---|
251 | PRINT_IT( "R18_OFFSET", 0x48 ); |
---|
252 | PRINT_IT( "R19_OFFSET", 0x4c ); |
---|
253 | PRINT_IT( "R20_OFFSET", 0x50 ); |
---|
254 | PRINT_IT( "R21_OFFSET", 0x54 ); |
---|
255 | PRINT_IT( "R22_OFFSET", 0x58 ); |
---|
256 | PRINT_IT( "R23_OFFSET", 0x5c ); |
---|
257 | PRINT_IT( "R24_OFFSET", 0x60 ); |
---|
258 | PRINT_IT( "R25_OFFSET", 0x64 ); |
---|
259 | PRINT_IT( "R26_OFFSET", 0x68 ); |
---|
260 | PRINT_IT( "R27_OFFSET", 0x6c ); |
---|
261 | PRINT_IT( "R28_OFFSET", 0x70 ); |
---|
262 | PRINT_IT( "R29_OFFSET", 0x74 ); |
---|
263 | PRINT_IT( "R30_OFFSET", 0x78 ); |
---|
264 | PRINT_IT( "R31_OFFSET", 0x7c ); |
---|
265 | |
---|
266 | /* |
---|
267 | * And common aliases for the above |
---|
268 | */ |
---|
269 | |
---|
270 | PRINT_COMMENT("Common aliases for above"); |
---|
271 | |
---|
272 | PRINT_IT( "RP_OFFSET", 0x08 ); |
---|
273 | PRINT_IT( "ARG3_OFFSET", 0x5c ); |
---|
274 | PRINT_IT( "ARG2_OFFSET", 0x60 ); |
---|
275 | PRINT_IT( "ARG1_OFFSET", 0x64 ); |
---|
276 | PRINT_IT( "ARG0_OFFSET", 0x68 ); |
---|
277 | PRINT_IT( "SP_OFFSET", 0x78 ); |
---|
278 | PRINT_IT( "DP_OFFSET", 0x6c ); |
---|
279 | PRINT_IT( "RET0_OFFSET", 0x74 ); |
---|
280 | PRINT_IT( "RET1_OFFSET", 0x74 ); |
---|
281 | |
---|
282 | PRINT_SIZE("CPU_CONTEXT_SIZE", 168 ); |
---|
283 | |
---|
284 | PRINT_COMMENT("Context_Control_fp information"); |
---|
285 | |
---|
286 | PRINT_SIZE("CPU_CONTEXT_FP_SIZE", 256); |
---|
287 | |
---|
288 | /* |
---|
289 | * And the control registers |
---|
290 | */ |
---|
291 | |
---|
292 | PRINT_COMMENT("Control register portion of context"); |
---|
293 | |
---|
294 | PRINT_IT( "SAR_OFFSET", 0x80 ); |
---|
295 | PRINT_IT( "IPSW_OFFSET", 0x84 ); |
---|
296 | PRINT_IT( "IIR_OFFSET", 0x88 ); |
---|
297 | PRINT_IT( "IOR_OFFSET", 0x8c ); |
---|
298 | PRINT_IT( "ISR_OFFSET", 0x90 ); |
---|
299 | PRINT_IT( "PCOQFRONT_OFFSET", 0x94 ); |
---|
300 | PRINT_IT( "PCOQBACK_OFFSET", 0x98 ); |
---|
301 | PRINT_IT( "PCSQFRONT_OFFSET", 0x9c ); |
---|
302 | PRINT_IT( "PCSQBACK_OFFSET", 0xa0 ); |
---|
303 | PRINT_IT( "ITIMER_OFFSET", 0xa4 ); |
---|
304 | |
---|
305 | /* |
---|
306 | * Full interrupt frame (integer + float) |
---|
307 | */ |
---|
308 | |
---|
309 | PRINT_COMMENT("Interrupt frame information"); |
---|
310 | |
---|
311 | PRINT_IT( "INTEGER_CONTEXT_OFFSET", 0x00 ); |
---|
312 | PRINT_IT( "FP_CONTEXT_OFFSET", 0xa8 ); |
---|
313 | PRINT_SIZE( "CPU_INTERRUPT_FRAME_SIZE", 448 ); |
---|
314 | |
---|
315 | } |
---|