1 /* LOADPARM.C (c) Copyright Jan Jaeger, 2004-2009 */
2 /* SCLP / MSSF loadparm */
3
4 /*-------------------------------------------------------------------*/
5 /* This module contains functions which set, copy, and retrieve the */
6 /* values of the LOADPARM and various other environmental parameters */
7 /*-------------------------------------------------------------------*/
8
9 #include "hstdinc.h"
10
11 #define _HENGINE_DLL_
12 #define _LOADPARM_C_
13
14 #include "hercules.h"
15
16
17 /*-------------------------------------------------------------------*/
18 /* SUBROUTINE TO COPY A STRINGZ TO A FIXED-LENGTH EBCDIC FIELD */
19 /*-------------------------------------------------------------------*/
copy_stringz_to_ebcdic(BYTE * fld,size_t len,char * name)20 static void copy_stringz_to_ebcdic(BYTE* fld, size_t len, char *name)
21 {
22 size_t i;
23
24 for(i = 0; name && i < strlen(name) && i < len; i++)
25 if(isprint(name[i]))
26 fld[i] = host_to_guest((int)(islower(name[i]) ? toupper(name[i]) : name[i]));
27 else
28 fld[i] = 0x40;
29 for(; i < len; i++)
30 fld[i] = 0x40;
31 }
32
33 /*-------------------------------------------------------------------*/
34 /* LOAD PARAMETER */
35 /* Set by: LOADPARM configuration statement or panel command */
36 /* Retrieved by: SERVC and MSSF_CALL instructions */
37 /*-------------------------------------------------------------------*/
38 static BYTE loadparm[8] = {0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40};
39
set_loadparm(char * name)40 void set_loadparm(char *name)
41 {
42 size_t i;
43
44 for(i = 0; name && i < strlen(name) && i < sizeof(loadparm); i++)
45 if(isprint(name[i]))
46 loadparm[i] = host_to_guest((int)(islower(name[i]) ? toupper(name[i]) : name[i]));
47 else
48 loadparm[i] = 0x40;
49 for(; i < sizeof(loadparm); i++)
50 loadparm[i] = 0x40;
51 }
52
53
get_loadparm(BYTE * dest)54 void get_loadparm(BYTE *dest)
55 {
56 memcpy(dest, loadparm, sizeof(loadparm));
57 }
58
59
str_loadparm()60 char *str_loadparm()
61 {
62 static char ret_loadparm[sizeof(loadparm)+1];
63 int i;
64
65 ret_loadparm[sizeof(loadparm)] = '\0';
66 for(i = sizeof(loadparm) - 1; i >= 0; i--)
67 {
68 ret_loadparm[i] = guest_to_host((int)loadparm[i]);
69
70 if(isspace(ret_loadparm[i]) && !ret_loadparm[i+1])
71 ret_loadparm[i] = '\0';
72 }
73
74 return ret_loadparm;
75 }
76
77
78 /*-------------------------------------------------------------------*/
79 /* LOGICAL PARTITION NAME */
80 /* Set by: LPARNAME configuration statement */
81 /* Retrieved by: STSI and MSSF_CALL instructions */
82 /*-------------------------------------------------------------------*/
83 static BYTE lparname[8] = {0xC8, 0xC5, 0xD9, 0xC3, 0xE4, 0xD3, 0xC5, 0xE2};
84 /* HERCULES */
85
set_lparname(char * name)86 void set_lparname(char *name)
87 {
88 size_t i;
89
90 for(i = 0; name && i < strlen(name) && i < sizeof(lparname); i++)
91 if(isprint(name[i]))
92 lparname[i] = host_to_guest((int)(islower(name[i]) ? toupper(name[i]) : name[i]));
93 else
94 lparname[i] = 0x40;
95 for(; i < sizeof(lparname); i++)
96 lparname[i] = 0x40;
97 }
98
99
get_lparname(BYTE * dest)100 void get_lparname(BYTE *dest)
101 {
102 memcpy(dest, lparname, sizeof(lparname));
103 }
104
105
106 LOADPARM_DLL_IMPORT
str_lparname()107 char *str_lparname()
108 {
109 static char ret_lparname[sizeof(lparname)+1];
110 int i;
111
112 ret_lparname[sizeof(lparname)] = '\0';
113 for(i = sizeof(lparname) - 1; i >= 0; i--)
114 {
115 ret_lparname[i] = guest_to_host((int)lparname[i]);
116
117 if(isspace(ret_lparname[i]) && !ret_lparname[i+1])
118 ret_lparname[i] = '\0';
119 }
120
121 return ret_lparname;
122 }
123
124
125 /*-------------------------------------------------------------------*/
126 /* MANUFACTURER NAME */
127 /* Set by: MANUFACTURER configuration statement */
128 /* Retrieved by: STSI instruction */
129 /*-------------------------------------------------------------------*/
130 /* "H R C" */
131 static BYTE manufact[16] = { 0xC8,0xD9,0xC3,0x40,0x40,0x40,0x40,0x40,
132 0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40 };
133
set_manufacturer(char * name)134 void set_manufacturer(char *name)
135 {
136 size_t i;
137
138 for(i = 0; name && i < strlen(name) && i < sizeof(manufact); i++)
139 if(isprint(name[i]))
140 manufact[i] = host_to_guest((int)(islower(name[i]) ? toupper(name[i]) : name[i]));
141 else
142 manufact[i] = 0x40;
143 for(; i < sizeof(manufact); i++)
144 manufact[i] = 0x40;
145 }
146
get_manufacturer(BYTE * dest)147 void get_manufacturer(BYTE *dest)
148 {
149 memcpy(dest, manufact, sizeof(manufact));
150 }
151
152
153 /*-------------------------------------------------------------------*/
154 /* MANUFACTURING PLANT NAME */
155 /* Set by: PLANT configuration statement */
156 /* Retrieved by: STSI instruction */
157 /*-------------------------------------------------------------------*/
158 /* "Z Z" */
159 static BYTE plant[4] = { 0xE9,0xE9,0x40,0x40 };
160
set_plant(char * name)161 void set_plant(char *name)
162 {
163 size_t i;
164
165 for(i = 0; name && i < strlen(name) && i < sizeof(plant); i++)
166 if(isprint(name[i]))
167 plant[i] = host_to_guest((int)(islower(name[i]) ? toupper(name[i]) : name[i]));
168 else
169 plant[i] = 0x40;
170 for(; i < sizeof(plant); i++)
171 plant[i] = 0x40;
172 }
173
get_plant(BYTE * dest)174 void get_plant(BYTE *dest)
175 {
176 memcpy(dest, plant, sizeof(plant));
177 }
178
179
180 /*-------------------------------------------------------------------*/
181 /* MODEL IDENTIFICATION */
182 /* Set by: MODEL configuration statement */
183 /* Retrieved by: STSI instruction */
184 /*-------------------------------------------------------------------*/
185 /* "E M U L A T O R" */
186 static BYTE model[16] = { 0xC5,0xD4,0xE4,0xD3,0xC1,0xE3,0xD6,0xD9,
187 0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40 };
188 static BYTE modelcapa[16] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 };
189 static BYTE modelperm[16] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 };
190 static BYTE modeltemp[16] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 };
191
set_model(int argc,char * m1,char * m2,char * m3,char * m4)192 void set_model(int argc, char *m1, char *m2, char *m3, char *m4)
193 {
194 if (argc > 1 && m1 != NULL)
195 copy_stringz_to_ebcdic(model, sizeof(model), m1);
196 if (argc > 2 && m2 != NULL)
197 copy_stringz_to_ebcdic(modelcapa, sizeof(modelcapa), m2);
198 if (argc > 3 && m3 != NULL)
199 copy_stringz_to_ebcdic(modelperm, sizeof(modelperm), m3);
200 if (argc > 4 && m4 != NULL)
201 copy_stringz_to_ebcdic(modeltemp, sizeof(modeltemp), m4);
202 }
203
get_model(BYTE * dest)204 void get_model(BYTE *dest)
205 {
206 memcpy(dest, model, sizeof(model));
207 }
208
get_modelcapa(BYTE * dest)209 void get_modelcapa(BYTE *dest)
210 {
211 memcpy(dest, modelcapa, sizeof(modelcapa));
212 }
213
get_modelperm(BYTE * dest)214 void get_modelperm(BYTE *dest)
215 {
216 memcpy(dest, modelperm, sizeof(modelperm));
217 }
218
get_modeltemp(BYTE * dest)219 void get_modeltemp(BYTE *dest)
220 {
221 memcpy(dest, modeltemp, sizeof(modeltemp));
222 }
223
224
225 /*-------------------------------------------------------------------*/
226 /* SYSTEM TYPE IDENTIFICATION */
227 /* Set by: SERVC instruction */
228 /* Retrieved by: DIAG204 instruction */
229 /*-------------------------------------------------------------------*/
230 static BYTE systype[8] = { 0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40 };
231
set_systype(BYTE * src)232 void set_systype(BYTE *src)
233 {
234 memcpy(systype, src, sizeof(systype));
235 }
236
get_systype(BYTE * dst)237 void get_systype(BYTE *dst)
238 {
239 memcpy(dst, systype, sizeof(systype));
240 }
241
242
243 /*-------------------------------------------------------------------*/
244 /* SYSTEM NAME */
245 /* Set by: SERVC instruction */
246 /* Retrieved by: DIAG204 instruction */
247 /*-------------------------------------------------------------------*/
248 static BYTE sysname[8] = { 0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40 };
249
set_sysname(BYTE * src)250 void set_sysname(BYTE *src)
251 {
252 memcpy(sysname, src, sizeof(sysname));
253 }
254
get_sysname(BYTE * dst)255 void get_sysname(BYTE *dst)
256 {
257 memcpy(dst, sysname, sizeof(sysname));
258 }
259
260
261 /*-------------------------------------------------------------------*/
262 /* SYSPLEX NAME */
263 /* Set by: SERVC instruction */
264 /* Retrieved by: DIAG204 instruction */
265 /*-------------------------------------------------------------------*/
266 static BYTE sysplex[8] = { 0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40 };
267
set_sysplex(BYTE * src)268 void set_sysplex(BYTE *src)
269 {
270 memcpy(sysplex, src, sizeof(sysplex));
271 }
272
get_sysplex(BYTE * dst)273 void get_sysplex(BYTE *dst)
274 {
275 memcpy(dst, sysplex, sizeof(sysplex));
276 }
277
278 /*-------------------------------------------------------------------*/
279 /* Retrieve Multiprocessing CPU-Capability Adjustment Factors */
280 /* */
281 /* This function retrieves the Multiprocessing CPU-Capability */
282 /* Adjustment Factor values for SYSIB (System Information Block) */
283 /* 1.2.2 as described in the Principles of Operations manual for */
284 /* the STORE SYSTEM INFORMATION instruction. */
285 /* */
286 /* Input: */
287 /* dest Address of where to store the information. */
288 /* Output: */
289 /* The requested MP Factor values at the address specified. */
290 /* Used by: */
291 /* B27D STSI Store System Information (Basic-machine All CPUs) */
292 /* B220 SERVC Service Call (read_scpinfo) */
293 /*-------------------------------------------------------------------*/
get_mpfactors(BYTE * dest)294 void get_mpfactors(BYTE *dest)
295 {
296 /*-------------------------------------------------------------------*/
297 /* The new z10 machine will use a denominator of 65535 for better */
298 /* granularity. But this will mess up old software. We will stick */
299 /* to the old value of 100. Bernard Feb 26, 2010. */
300 /*-------------------------------------------------------------------*/
301 #define MPFACTOR_DENOMINATOR 100
302 #define MPFACTOR_PERCENT 95
303
304 static U16 mpfactors[MAX_CPU_ENGINES-1] = {0};
305 static BYTE didthis = 0;
306
307 if (!didthis)
308 {
309 /* First time: initialize array... */
310 U32 mpfactor = MPFACTOR_DENOMINATOR;
311 size_t i;
312 for (i=0; i < arraysize( mpfactors ); i++)
313 {
314 /* Calculate the value of each subsequent entry
315 as percentage of the previous entry's value. */
316 mpfactor = (mpfactor * MPFACTOR_PERCENT) / 100;
317 STORE_HW( &mpfactors[i], (U16) mpfactor );
318 }
319 didthis = 1;
320 }
321
322 /* Return the requested information... */
323 memcpy( dest, &mpfactors[0], (MAX_CPU-1) * sizeof(U16) );
324 }
325