-
Notifications
You must be signed in to change notification settings - Fork 70
/
_archdep_templ.c
180 lines (153 loc) · 8.23 KB
/
_archdep_templ.c
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
/* XXXXXXX.C (C) Copyright Your name or company, YYYY */
/* Short module description goes here */
/* */
/* Released under "The Q Public License Version 1" */
/* (http://www.hercules-390.org/herclic.html) as modifications to */
/* Hercules. */
#if 0 // ** REMOVE ME! ** REMOVE ME! ** REMOVE ME! ** REMOVE ME! **
/*-------------------------------------------------------------------*/
/* This is an example (sample) source module containing architecture */
/* dependent code. Copy it to whatever name you require, remove the */
/* #if 0 and #endif to activate it, and change it as needed. Replace */
/* the comments you are reading with a more detailed description of */
/* the purpose of your module and how it accomplishes its mission. */
/* Also mention reference manuals used during its development too. */
/*-------------------------------------------------------------------*/
/*-------------------------------------------------------------------*/
/* Additional credits: */
/* List here other people who helped or inspired you... */
/* List here other people who helped or inspired you... */
/*-------------------------------------------------------------------*/
#include "hstdinc.h" // (MUST ALWAYS BE FIRST!)
#define _XXXXXXX_C_ // (ALWAYS) (see hexterns.h)
#define _XXXXX_DLL_ // (ALWAYS) (usually _HENGINE_DLL_)
#include "hercules.h" // (ALWAYS) (needed by most modules)
//#include "xxxxxx.h" // (other needed includes go here)
//#include "xxxxxx.h" // (other needed includes go here)
//#include "xxxxxx.h" // (other needed includes go here)
#ifndef _WE_DID_THIS_ALREADY_
#define _WE_DID_THIS_ALREADY_
//-------------------------------------------------------------------
// code compiled only one time
//-------------------------------------------------------------------
// Place functions that are NEITHER *build* architecture dependent
// nor architectural FEATURE (nor _FEATURE) dependent here. These
// function get compiled ONE TIME and ONLY one time. Note: you must
// NOT use any build architecture dependent values in any of these
// functions since only the values for the FIRST build architecture
// have been #defined at this point (usually S370). These functions
// may be static or not, or DLL_EXPORT or not, it doesn't matter,
// but static helper functions used by the functions which follow
// are the type of functions which are usually placed here.
//-------------------------------------------------------------------
/*-------------------------------------------------------------------*/
/* Simple function description/purpose */
/*-------------------------------------------------------------------*/
static int foo()
{
}
/*-------------------------------------------------------------------*/
/* Simple function description/purpose */
/*-------------------------------------------------------------------*/
static int bar()
{
}
#endif /* _WE_DID_THIS_ALREADY_ */
//-------------------------------------------------------------------
// ARCH_DEP() code
//-------------------------------------------------------------------
// ARCH_DEP (build-architecture / FEATURE-dependent) functions here.
// All BUILD architecture dependent (ARCH_DEP) function are compiled
// multiple times (once for each defined build architecture) and each
// time they are compiled with a different set of FEATURE_XXX defines
// appropriate for that architecture. Use #ifdef FEATURE_XXX guards
// to check whether the current BUILD architecture has that given
// feature #defined for it or not. WARNING! Do NOT use _FEATURE_XXX!
// The underscore feature #defines mean something else entirely! Only
// test for FEATURE_XXX! (WITHOUT the underscore!) These functions
// may be static or not, or DLL_EXPORT or not, it doesn't matter.
//-------------------------------------------------------------------
/*-------------------------------------------------------------------*/
/* Advanced function description including purpose... */
/* */
/* Input: */
/* aaaaa Some input parameter */
/* bbbbb Another input parameter */
/* */
/* Output: */
/* ccccc Updated parameter */
/* */
/* Returns: */
/* Description of return code if any */
/* */
/* Detailed description of functionality... Detailed description */
/* of functionality... Detailed description of functionality... */
/* Detailed description of functionality... Detailed description */
/* of functionality... Detailed description of functionality... */
/*-------------------------------------------------------------------*/
int ARCH_DEP( foobar_func )( RADR *raddr, VADR vaddr, REGS *regs )
{
/* call non-archdep helper function */
int foobar = foo();
/* call another arch dep function */
ARCH_DEP( some_other_func )( vaddr, regs );
#if defined( FEATURE_XXX )
/* Code to handle this feature... */
#endif // defined( FEATURE_XXX )
return foobar;
} /* end function foobar_func */
/*-------------------------------------------------------------------*/
/* Compile ARCH_DEP() functions for other build architectures... */
/*-------------------------------------------------------------------*/
#if !defined(_GEN_ARCH) // (first time here?)
#if defined(_ARCHMODE2)
#define _GEN_ARCH _ARCHMODE2 // (set next build architecture)
#include "_archdep_templ.c" // (compile ourselves again)
#endif
#if defined(_ARCHMODE3)
#undef _GEN_ARCH
#define _GEN_ARCH _ARCHMODE3 // (set next build architecture)
#include "_archdep_templ.c" // (compile ourselves again)
#endif
//-------------------------------------------------------------------
// _FEATURE_XXX code
//-------------------------------------------------------------------
// Place any _FEATURE_XXX depdendent functions (WITH the underscore!)
// here. You may need to define such functions whenever one or more
// build architectures has a given FEATURE_XXX (WITHOUT underscore!)
// defined for it. The underscore means AT LEAST ONE of the build
// architectures #defined that feature. (See featchk.h) You must NOT
// use any #ifdef FEATURE_XXX here! Test for ONLY for _FEATURE_XXX!
// The functions in this area are compiled ONCE (only ONE time) and
// ONLY one time but are always compiled LAST after everything else.
// These functions may be static or not, or DLL_EXPORT or not, it
// doesn't matter.
//-------------------------------------------------------------------
#if defined( _FEATURE_XXX ) // (is FEATURE_XXX code needed?)
/*-------------------------------------------------------------------*/
/* This function is needed to support FEATURE_XXX. */
/* This is an example of a RUN-TIME-ARCHITECTURE dependent function */
/*-------------------------------------------------------------------*/
int feature_xxx_func()
{
//switch( sysblk.arch_mode ) // (switch based on RUN-TIME archmode)
switch( regs->arch_mode ) // (switch based on RUN-TIME archmode)
{
#if defined( _370 )
case ARCH_370:
return s370_foobar_func( ....arguments go here.... );
#endif
#if defined( _390 )
case ARCH_390:
return s390_foobar_func( ....arguments go here.... );
#endif
#if defined( _900 )
case ARCH_900:
return z900_foobar_func( ....arguments go here.... );
#endif
}
return 0;
}
#endif // _FEATURE_XXX
#endif // !defined(_GEN_ARCH)
#endif // ** REMOVE ME! ** REMOVE ME! ** REMOVE ME! ** REMOVE ME! **