source: rtems/tools/cpu/hppa1.1/genoffsets.c @ 76b6fd0c

4.104.114.84.95
Last change on this file since 76b6fd0c was 76b6fd0c, checked in by Joel Sherrill <joel.sherrill@…>, on 12/05/95 at 15:28:21

minor changes so it would compile in a cross environment

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