summaryrefslogtreecommitdiffstats
path: root/tools/cpu/hppa1.1/genoffsets.c
blob: 6563681f1118914913067eb5e19d3c18dae38f91 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
/*
 *      @(#)genoffsets.c        1.3 - 95/03/15
 *
 *
 *  genoffsets.c
 *
 *  This file generates the offsets.h for the HP PA-RISC port of RTEMS.
 *
 *  NOTE:  It only prints the offset for structures actually used
 *         by the assembly code.
 *
 *  COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994.
 *  On-Line Applications Research Corporation (OAR).
 *
 *  This material may be reproduced by or for the U.S. Government pursuant
 *  to the copyright license under the clause at DFARS 252.227-7013.  This
 *  notice must appear in all copies of this file and its derivatives.
 *
 *  $Id$
 *
 */

#include <stdio.h>

#include <rtems/system.h>

int main(
  int argc,
  char **argv
)
{
  unsigned int size;

  /*
   * Print the file header
   */

printf(
  "/*  offsets.h\n"
  " *\n"
  " *  This include file contains the offsets of elements in the\n"
  " *  C data structures used by the assembly language code for the\n"
  " *  HP PA-RISC 1.1 port of RTEMS.\n"
  " *\n"
  " *  NOTE:  THIS FILE IS AUTOMATICALLY GENERATED!!!!\n"
  " *         DO NOT EDIT THIS BY HAND!!!!\n"
  " *\n"
  " *  COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994.\n"
  " *  On-Line Applications Research Corporation (OAR).\n"
  " *  All rights assigned to U.S. Government, 1994.\n"
  " *\n"
  " *  This material may be reproduced by or for the U.S. Government pursuant\n"
  " *  to the copyright license under the clause at DFARS 252.227-7013.  This\n"
  " *  notice must appear in all copies of this file and its derivatives.\n"
  " */\n"
  "\n"
  "#ifndef __OFFSETS_h\n"
  "#define __OFFSETS_h\n"
  "\n"
);

/*
 *  Offsets of elements in the Context_control structure.
 */

#define PRINT_IT( STRING, TYPE, FIELD ) \
  printf( "#define\t%s\t0x%p\t\t/* %d */\n", \
          STRING, \
          &((TYPE)0)->FIELD, \
          (int) &((TYPE)0)->FIELD );

#define PRINT_SIZE( STRING, item ) \
  printf( "#define\t%s\t%d\t\t/* 0x%x */\n", \
          STRING, \
          sizeof(item), \
          sizeof(item) );

#define PRINT_COMMENT( STRING ) \
  printf(       \
    "\n"        \
    "/*\n"      \
    " * " STRING "\n" \
    " */\n"     \
    "\n"        \
  );

  PRINT_COMMENT("Context_Control information");

  PRINT_IT( "FLAGS_OFFSET", Context_Control *, flags );
  PRINT_IT( "R1_OFFSET", Context_Control *, gr1 );
  PRINT_IT( "R2_OFFSET", Context_Control *, gr2 );
  PRINT_IT( "R3_OFFSET", Context_Control *, gr3 );
  PRINT_IT( "R4_OFFSET", Context_Control *, gr4 );
  PRINT_IT( "R5_OFFSET", Context_Control *, gr5 );
  PRINT_IT( "R6_OFFSET", Context_Control *, gr6 );
  PRINT_IT( "R7_OFFSET", Context_Control *, gr7 );
  PRINT_IT( "R8_OFFSET", Context_Control *, gr8 );
  PRINT_IT( "R9_OFFSET", Context_Control *, gr9 );
  PRINT_IT( "R10_OFFSET", Context_Control *, gr10 );
  PRINT_IT( "R11_OFFSET", Context_Control *, gr11 );
  PRINT_IT( "R12_OFFSET", Context_Control *, gr12 );
  PRINT_IT( "R13_OFFSET", Context_Control *, gr13 );
  PRINT_IT( "R14_OFFSET", Context_Control *, gr14 );
  PRINT_IT( "R15_OFFSET", Context_Control *, gr15 );
  PRINT_IT( "R16_OFFSET", Context_Control *, gr16 );
  PRINT_IT( "R17_OFFSET", Context_Control *, gr17 );
  PRINT_IT( "R18_OFFSET", Context_Control *, gr18 );
  PRINT_IT( "R19_OFFSET", Context_Control *, gr19 );
  PRINT_IT( "R20_OFFSET", Context_Control *, gr20 );
  PRINT_IT( "R21_OFFSET", Context_Control *, gr21 );
  PRINT_IT( "R22_OFFSET", Context_Control *, gr22 );
  PRINT_IT( "R23_OFFSET", Context_Control *, gr23 );
  PRINT_IT( "R24_OFFSET", Context_Control *, gr24 );
  PRINT_IT( "R25_OFFSET", Context_Control *, gr25 );
  PRINT_IT( "R26_OFFSET", Context_Control *, gr26 );
  PRINT_IT( "R27_OFFSET", Context_Control *, gr27 );
  PRINT_IT( "R28_OFFSET", Context_Control *, gr28 );
  PRINT_IT( "R29_OFFSET", Context_Control *, gr29 );
  PRINT_IT( "R30_OFFSET", Context_Control *, sp );
  PRINT_IT( "R31_OFFSET", Context_Control *, gr31 );

  /*
   * And common aliases for the above
   */

  PRINT_COMMENT("Common aliases for above");

  PRINT_IT( "RP_OFFSET",   Context_Control *, gr2 );
  PRINT_IT( "ARG3_OFFSET", Context_Control *, gr23 );
  PRINT_IT( "ARG2_OFFSET", Context_Control *, gr24 );
  PRINT_IT( "ARG1_OFFSET", Context_Control *, gr25 );
  PRINT_IT( "ARG0_OFFSET", Context_Control *, gr26 );
  PRINT_IT( "SP_OFFSET",   Context_Control *, sp );
  PRINT_IT( "DP_OFFSET",   Context_Control *, gr27 );
  PRINT_IT( "RET0_OFFSET", Context_Control *, gr28 );
  PRINT_IT( "RET1_OFFSET", Context_Control *, gr29 );

  PRINT_SIZE("CPU_CONTEXT_SIZE", Context_Control);

  PRINT_COMMENT("Context_Control_fp information");

  PRINT_SIZE("CPU_CONTEXT_FP_SIZE", Context_Control_fp);

  /*
   *  And the control registers
   */

  PRINT_COMMENT("Control register portion of context");

  PRINT_IT( "SAR_OFFSET", Context_Control *, sar );
  PRINT_IT( "IPSW_OFFSET", Context_Control *, ipsw );
  PRINT_IT( "IIR_OFFSET", Context_Control *, iir );
  PRINT_IT( "IOR_OFFSET", Context_Control *, ior );
  PRINT_IT( "ISR_OFFSET", Context_Control *, isr );
  PRINT_IT( "PCOQFRONT_OFFSET", Context_Control *, pcoqfront );
  PRINT_IT( "PCOQBACK_OFFSET", Context_Control *, pcoqback );
  PRINT_IT( "PCSQFRONT_OFFSET", Context_Control *, pcsqfront );
  PRINT_IT( "PCSQBACK_OFFSET", Context_Control *, pcsqback );
  PRINT_IT( "ITIMER_OFFSET", Context_Control *, itimer );

  /*
   *  Full interrupt frame (integer + float)
   */
  PRINT_COMMENT("Interrupt frame information");

  PRINT_IT( "INTEGER_CONTEXT_OFFSET", CPU_Interrupt_frame *, Integer );
  PRINT_IT( "FP_CONTEXT_OFFSET", CPU_Interrupt_frame *, Floating_Point );
  size = sizeof( CPU_Interrupt_frame );

  if ( size % CPU_STACK_ALIGNMENT )
    size += CPU_STACK_ALIGNMENT - (size % CPU_STACK_ALIGNMENT);

  printf( "#define\tCPU_INTERRUPT_FRAME_SIZE\t%d\t\t/* 0x%x */\n", size, size );

#undef PRINT_IT
#undef PRINT_SIZE
#undef PRINT_COMMENT

  /*
   *  Print the end of file stuff
   */

   printf(
    "\n"
    "#endif    /* __OFFSETS_h  */\n"
    "\n"
    "/* end of include file */\n"
  );

  return 0;
}