source: rtems/c/src/exec/score/tools/hppa1.1/genoffsets.c @ a5f56a43

4.104.114.84.95
Last change on this file since a5f56a43 was 8389628, checked in by Joel Sherrill <joel.sherrill@…>, on 04/22/96 at 16:53:46

updates from Tony Bennett

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