1 /*ECPSVM.H      (c) Copyright Ivan Warren, 2003-2009                 */
2 /*              Hercules ECPS:VM Support                             */
3 
4 #ifndef __ECPSVM_H__
5 #define __ECPSVM_H__
6 
7 /* CR6 Definitions */
8 #define ECPSVM_CR6_VMASSIST 0x80000000         /* DO Privop Sim */
9 #define ECPSVM_CR6_VIRTPROB 0x40000000         /* Running user in Problem State */
10 #define ECPSVM_CR6_ISKINHIB 0x20000000         /* Inhibit ISK/SSK Sim */
11 #define ECPSVM_CR6_S360ONLY 0x10000000         /* Only S/360 Operations */
12 #define ECPSVM_CR6_SVCINHIB 0x08000000         /* No SVC sim */
13 #define ECPSVM_CR6_STVINHIB 0x04000000         /* No Shadow Table Validation */
14 #define ECPSVM_CR6_ECPSVM   0x02000000         /* ECPS:VM Enable */
15 #define ECPSVM_CR6_VIRTTIMR 0x01000000         /* Virtual Interval Timer update */
16 #define ECPSVM_CR6_MICBLOK  0x00FFFFF8         /* MICBLOK Address mask */
17 #define ECPSVM_CR6_VMMVSAS  0x00000004         /* VM Assists for MVS Enable (370E) */
18 
19 /* CR6 Definitions (VMBLOK style) */
20 #define VMMFE 0x80
21 #define VMMPROB 0x40
22 #define VMMNOSK 0x20
23 #define VMM360 0x10
24 #define VMMSVC 0x08
25 #define VMMSHADT 0x04
26 #define VMMCPAST 0x02
27 #define VMMVTMR 0x01
28 
29 /* MICBLOK */
30 typedef struct _ECPSVM_MICBLOK
31 {
32     U32 MICRSEG;
33     U32 MICCREG;
34     U32 MICVPSW;
35 #define MICVIP MICVPSW
36 #define MICPEND 0x80
37     U32 MICWORK;
38     U32 MICVTMR;
39     U32 MICACF;
40     U32 RESERVED1;
41     U32 RESERVED2;
42     U32 MICCREG0;
43     U32 RESERVED3;
44     /* Bits defined in MICEVMA */
45 #define MICLPSW 0x80    /* LPSW SIM */
46 #define MICPTLB 0x40    /* PTLB SIM */
47 #define MICSCSP 0x20    /* SCKC, SPT SIM */
48 #define MICSIO  0x10    /* SIO, SIOF SIM */
49 #define MICSTSM 0x08    /* SSM, STNSM, STOSM SIM */
50 #define MICSTPT 0x04    /* STPT SIM */
51 #define MICTCH  0x02    /* TCH SIM */
52 #define MICDIAG 0x01    /* DIAG SIM */
53     /* Hint : The following bits may be irrelevant for ECPS:VM Level 20 */
54     /* Bits defined in MICEVMA2 */
55     /* V=R Shadow Table Bypass assists */
56 #define MICSTBVR 0x80   /* V=R STBYPASS Assist active */
57 #define MICPTLB2 0x40   /* VRSTBYPASS PTLB Simulation */
58 #define MICIPTP2 0x20   /* VRSTBYPASS IPTE/TPRT Simulation */
59 #define MICVPFR2 0x10   /* Virtual Page Fault reflection Assists */
60 #define MICLRA2  0x08   /* VRSTBYPASS LRA Simulation */
61 #define MICSTSM2 0x02   /* VRSTBYPASS SSM/STxSM Sim */
62 #define MICLCTL2 0x01   /* VRSTBYPASS LCTL Sim */
63     /* Bits define in MICEVMA3 */
64 #define MICSKYMD 0x20   /* Unknown */
65 #define MICISKE  0x10   /* PTLB Sim */
66 #define MICRRBE  0x08   /* IPTE/TPRT Sim */
67 #define MICSSKE  0x04   /* V Page Fault Sim */
68     /* Bits defined in MICEVMA4 */
69 #define MICSVC4  0x40   /* SVC/LPSW/LCTL Assists Extentions */
70 #define MICSPT4  0x20   /* SPT Assist Extension */
71 #define MICIUCV  0x10   /* IUCV ASSIST */
72 } ECPSVM_MICBLOK;
73 
74 /* PSA Usefull Values */
75 #define IOOPSW   0x038
76 
77 #define QUANTUMR 0x04C  /* Usefull little unused space for MVCing NEW ITIMER */
78 #define INTTIMER 0x050
79 #define QUANTUM  0x054  /* Usefull little unused space for MVCing OLD ITIMER */
80 
81 /* PSA Displacements used by ECPS:VM */
82 /* PSA Entries used by DISPx Instructions */
83 #define CPSTATUS 0x348
84 /* PSA + 348 : CPSTATUS */
85 #define CPWAIT 0x80     /* CP IN WAIT STATE */
86 #define CPRUN  0x40     /* RUNUSER is use running */
87 #define CPEX   0x20     /* CPEXBLOK RUNNING */
88 #define CPSUPER 0x08    /* Supervisor State */
89 
90 /* PSA + 349 : SYSTEM EXTENDING FREE STORAGE BYTE */
91 /* Note : PSA+0X349 = 0xFF if storage extending */
92 #define XTENDLOCK 0x349
93 #define XTENDLOCKSET 0xff
94 
95 /* PSA + 34A : CPSTAT2 */
96 #define CPSTAT2 0x34A
97 #define CPMICAVL 0x80
98 #define CPMICON  0x40
99 #define CPSHRLK 0x20
100 #define CPASTAVL 0x08
101 #define CPASTON 0x04
102 
103 /* RUNPSW */
104 /* PSW used during dispatch */
105 #define RUNPSW 0x330
106 
107 /* RUNUSER PSA+338 */
108 #define RUNUSER 0x338
109 
110 /* RUNCR0, RUNCR1 */
111 /* CR0 & CR1 used during dispatch */
112 #define RUNCR0 0x340
113 #define RUNCR1 0x344
114 
115 /* ASYSVM : PSA+37C */
116 #define ASYSVM 0x37C
117 
118 /* PSA + X'3D4' - ASSISTS STUFF */
119 #define CPCREG0 0x3D4
120 #define CPCREG6 0x3D8
121 #define CPCREG8 0x3DC
122 #define TIMEDISP 0x3E0
123 #define ASVCLIST 0x3E4
124 #define AVMALIST 0x3E8
125 #define LASTUSER 0x3EC
126 
127 /* PSA + 328 : PROBTIME */
128 /* Total time spent in problem state (2's complement) */
129 #define PROBTIME 0x328
130 
131 /* PSA + 69B : APSTAT2 - Machine check recov & PTLB Required */
132 #define APSTAT2  0x69B
133 #define CPMCHLK  0x10
134 #define CPPTLBR  0x02
135 
136 /* PSA + 6A8 : PROBSTRT */
137 /* TOD Clock at Proble state entry */
138 #define PROBSTRT 0x6A8
139 
140 /* PSA + 6D0 : STACKVM - GPR11 Backup for dispatcher */
141 #define STACKVM 0x6D0
142 
143 /* CP ASSIST SVC (Not VM Assist SVC) LIST */
144 /* ASSISTS FOR CP LINK/RETURN SVCs */
145 /* DMKSVCNS */
146 /* Address found @ PSA+3E4 */
147 typedef struct _ECPSVM_SVCLIST
148 {
149     DW NEXTSAVE;        /* Pointer to next Save Area + 8 */
150     DW SLCADDR;         /* V=R Start */
151     DW DMKSVCHI;        /* DMKFREHI */
152     DW DMKSVCLO;        /* DMKFRELO + SAVEAREA LENGTH */
153 } ECPSVM_SVCLIST;
154 
155 /* VM ASSIST LISTS */
156 /* ENTRYPOINT TO VARIOUS PRIVOP SIM FASTPATH */
157 /* (DMKPRVMA) */
158 /* Address found @ PSA+3E8 */
159 
160 typedef struct _ECPSVM_VMALIST
161 {
162     DW VSIVS;   /* EP To DMKVSIVS (Fastpath SIO/SIOF) */
163     DW VSIEX;   /* Base addr for VSIVS */
164     DW DSPCH;   /* Scheduler - Fast path for LPSW/SSM/STNSM/STOSM */
165     DW TMRCC;   /* SCKC EP */
166     DW TMR;     /* Timer ops base */
167     DW TMRSP;   /* SPT EP */
168     DW VATAT;   /* ARCHITECT */
169     DW DSPB;    /* Slow Path Dispatcher - PSW Revalidate required */
170     DW PRVVS;   /* VSIVS COUNT */
171     DW PRVVL;   /* LPSW Count */
172     DW PRVVM;   /* SSM/STxSM COUNT */
173     DW PRVVC;   /* SCKC COUNT */
174     DW RESERVED;
175     DW PRVVP;   /* SPT COUNT */
176 } ECPSVM_VMALIST;
177 
178 /* VMBLOK Displacements */
179 #define VMQFPNT         0x000
180 #define VMQBPNT         0x004
181 #define VMPNT           0x008
182 #define VMECEXT         0x00C
183 #define VMVCR0 VMECEXT
184 #define VMSEG           0x010
185 #define VMSIZE          0x014
186 #define VMCHSTRT        0x018
187 #define VMCUSTRT        0x01C
188 #define VMDVSTRT        0x020
189 #define VMTERM          0x024
190 #define VMVTERM         0x028
191 #define VMTRMID         0x02A
192 #define VMTLEND         0x02C
193 #define VMTLDEL         0x02D
194 #define VMTCDEL         0x02E
195 #define VMTESCP         0x02F
196 #define VMCHCNT         0x030
197 #define VMCUCNT         0x032
198 #define VMDVCNT         0x034
199 #define VMIOACTV        0x036
200 #define VMCHTBL         0x038
201 #define VMRSTAT         0x058
202     /* Flags defined in VMRSTAT */
203 #define VMCFWAIT 0x80
204 #define VMPGWAIT 0x40
205 #define VMIOWAIT 0x20
206 #define VMPSWAIT 0x10
207 #define VMEXWAIT 0x08
208 #define VMLOGON  0x04
209 #define VMLOGOFF 0x02
210 #define VMIDLE   0x01
211 #define VMCPWAIT (VMCFWAIT|VMPGWAIT|VMIOWAIT|VMEXWAIT|VMLOGOFF|VMLOGON)
212 #define VMNORUN  (VMCPWAIT|VMPSWAIT)
213 #define VMLONGWT (VMCFWAIT|VMLOGON|VMLOGOFF|VMIDLE)
214 
215 #define VMDSTAT         0x059
216     /* Flags defined in VMDSTAT */
217 #define VMDSP   0x80
218 #define VMTSEND 0x40
219 #define VMQSEND 0x20
220 #define VMTIO   0x10
221 #define VMRUN   0x08
222 #define VMINQ   0x04
223 #define VMELIG  0x02
224 #define VMDSPCH 0x01
225 
226 #define VMOSTAT         0x05A
227     /* Flags defined in VMOSTAT */
228 #define VMSYSOP 0x80
229 #define VMSHR   0x40
230 #define VMSLEEP 0x20
231 #define VMDISC  0x10
232 #define VMCFRUN 0x08
233 #define VMVIRCF 0x04
234 #define VMCF    0x02
235 #define VMKILL  0x01
236 
237 #define VMQSTAT         0x05B
238     /* Flags defined in VMQSTAT */
239 #define VMPRIDSP 0x80
240 #define VMAUTOLOG 0x40
241 #define VMWSERNG 0x20
242 #define VMDLDRP 0x10
243 #define VMWSCHG 0x08
244 #define VMINHMIG 0x04
245 #define VMCFREAD 0x02
246 #define VMPA2APL 0x01
247 
248 #define VMPSTAT         0x05C
249     /* Flags defined in VMPSTAT */
250 #define VMISAM 0x80
251 #define VMV370R 0x40
252 #define VMRPAGE 0x20
253 #define VMREAL 0x10
254 #define VMNOTRAN 0x08
255 #define VMNSHR 0x04
256 #define VMACCOUN 0x02
257 #define VMPAGEX 0x01
258 
259 #define VMESTAT         0x05D
260     /* Flags defined in VMESTAT */
261 #define VMSHADT 0x80
262 #define VMPERCM 0x40
263 #define VMBADCR0 0x20
264 #define VMMICSVC 0x10
265 #define VMEXTCM 0x08
266 #define VMNEWCR0 0x04
267 #define VMINVSEG 0x02
268 #define VMINVPAG 0x01
269 #define VMECZAP ~VMMICSVC
270 
271 #define VMTRCTL         0x05E
272     /* Bits defined in VMTRCTL */
273 #define VMTRPER 0x80
274 #define VMTRSVC 0x40
275 #define VMTRPRG 0x20
276 #define VMTRIO  0x10
277 #define VMTREX  0x08
278 #define VMTRPRV 0x04
279 #define VMTRSIO 0x02
280 #define VMTRBRIN 0x01
281 #define VMTRINT (VMTRSVC|VMTRPRG|VMTRIO|VMTREX)
282 
283 #define VMMLEVEL        0x05F
284 #define VMQLEVEL        0x060
285     /* Bits defined in VMQLEVEL */
286 #define VMQ1    0x80
287 #define VMCOMP  0x40
288 #define VMHIPRI 0x20
289 #define VMLOPRI 0x10
290 #define VMAEX   0x08
291 #define VMAEXP  0x04
292 #define VMAQ3   0x02
293 #define VMDROP1 0x02
294 #define VMFS    0x01
295 
296 #define VM_RESERVED1    0x061
297 #define VMTLEVEL        0x062
298    /* Flags defined for VMTLEVEL */
299 #define VMTON   0x80
300 #define VMRON   0x40
301 #define VMCPUTMR 0x20
302 #define VMSTMPI 0x08
303 #define VMSTMPT 0x04
304 #define VMTMRINT 0x01
305 
306 #define VMPEND          0x063
307    /* Flags defined in VMPEND */
308 #define VMDEFSTK 0x80
309 #define VMPERPND 0x40
310 #define VMPRGPND 0x20
311 #define VMSVCPND 0x10
312 #define VMPGPND  0x08
313 #define VMIOPND  0x02
314 #define VMEXTPND 0x01
315 
316 #define VMLOCKER        0x064
317 #define VMFSTAT         0x068
318 #define VMMLVL2         0x069
319 #define VMIOINT         0x06A
320 #define VMTIMER         0x06C
321 #define VMVTIME         0x070
322 #define VMTMOUTQ        0x078
323 #define VMTTIME         0x080
324 #define VMTMINQ         0x088
325 #define VMTSOUTQ VMTMINQ
326 #define VMTODINQ        0x090
327 #define VMINST          0x098
328 #define VMUPRIOR        0x09E
329 #define VMPSWCT         0x09F
330 #define VMTREXT         0x0A0
331 #define VMADSTOP        0x0A4
332 #define VMPSW           0x0A8
333 #define VMGPRS          0x0B0
334 #define VMFPRS          0x0F0
335 #define VMUSER          0x110
336 #define VMACCNT         0x118
337 #define VMDIST          0x120
338 
339 
340 #define VMMICRO         0x17C
341 #define VMMCR6 VMMICRO
342 #define VMMADDR VMMICRO+1
343 
344 #define VMPXINT         0x184
345 
346 #define VMNOECPS        0x1A7
347 
348 #define VMSTKCNT        0x1CC
349 
350 
351 /* ECBLOK Specifics */
352 #define EXTSHCR0 0x40
353 #define EXTSHCR1 0x44
354 
355 typedef struct _ECPSVM_STAT
356 {
357     char *name;
358     U32   call;
359     U32   hit;
360     u_int support:1;
361     u_int enabled:1;
362     u_int debug:1;
363     u_int total:1;
364 } ECPSVM_STAT;
365 
366 /* THE FOLLOWING ARE C99 INITIALISATION OF THE ECPSVM INSTRUCTION STATE STRUCTURES */
367 /* SINCE MSVC SEEMS TO NOT LIKE THOSE, THEY ARE REPLACED FOR THE TIME BEING        */
368 #if 0
369 #define ECPSVM_STAT_DCL(_name) ECPSVM_STAT _name
370 #define ECPSVM_STAT_DEF(_name) ._name = { .name = ""#_name"" ,.call=0,.hit=0,.support=1,.total=0,.enabled=1,.debug=0}
371 #define ECPSVM_STAT_DEFU(_name) ._name = { .name = ""#_name"" ,.call=0,.hit=0,.support=0,.total=0,.enabled=1,.debug=0}
372 #define ECPSVM_STAT_DEFM(_name) ._name = { .name = ""#_name"" ,.call=0,.hit=0,.support=1,.total=1,.enabled=1,.debug=0}
373 #endif
374 
375 /* BELOW ARE NON C99 STRUCTURE INITIALIZERS KEEP THE ABOVE IN SYNC PLEASE */
376 #define ECPSVM_STAT_DCL(_name) ECPSVM_STAT _name
377 #define ECPSVM_STAT_DEF(_name) { ""#_name"" ,0,0,1,1,0,0}
378 #define ECPSVM_STAT_DEFU(_name) {""#_name"" ,0,0,0,1,0,0}
379 #define ECPSVM_STAT_DEFM(_name) {""#_name"" ,0,0,1,1,0,1}
380 
381 typedef struct _ECPSVM_CMDENT
382 {
383     char *name;
384     int  abbrev;
385     void (*fun)(int argc,char **av);
386     char *expl;
387     char *help;
388 } ECPSVM_CMDENT;
389 
390 #endif
391