1 /* SR.C (c)Copyright Greg Smith, 2005-2009 */
2 /* Suspend/Resume a Hercules session */
3
4 #include "hstdinc.h"
5
6 #define _HERCULES_SR_C
7 #define _HENGINE_DLL_
8
9 #include "hercules.h"
10 #include "opcode.h"
11 #ifdef OPTION_FISHIO
12 #include "w32chan.h"
13 #endif
14 #include "sr.h"
15
16 /* subroutine to check for active devices */
sr_active_devices()17 DEVBLK *sr_active_devices()
18 {
19 DEVBLK *dev;
20
21 for (dev = sysblk.firstdev; dev; dev = dev->nextdev)
22 {
23 obtain_lock (&dev->lock);
24 if (dev->busy && !dev->suspended)
25 {
26 if (dev->devtype != 0x3088)
27 {
28 release_lock (&dev->lock);
29 return dev;
30 }
31 else
32 {
33 usleep(50000);
34 dev->busy = 0;
35 }
36 }
37 release_lock (&dev->lock);
38 }
39 return NULL;
40 }
41
suspend_cmd(int argc,char * argv[],char * cmdline)42 int suspend_cmd(int argc, char *argv[],char *cmdline)
43 {
44 char *fn = SR_DEFAULT_FILENAME;
45 SR_FILE file;
46 CPU_BITMAP started_mask;
47 struct timeval tv;
48 time_t tt;
49 int i, j, rc;
50 REGS *regs;
51 DEVBLK *dev;
52 IOINT *ioq;
53 BYTE psw[16];
54
55 UNREFERENCED(cmdline);
56
57 if (argc > 2)
58 {
59 logmsg( _("HHCSR101E Too many arguments\n"));
60 return -1;
61 }
62
63 if (argc == 2)
64 fn = argv[1];
65
66 file = SR_OPEN (fn, "wb");
67 if (file == NULL)
68 {
69 logmsg( _("HHCSR102E %s open error: %s\n"),fn,strerror(errno));
70 return -1;
71 }
72
73 /* Save CPU state and stop all CPU's */
74 OBTAIN_INTLOCK(NULL);
75 started_mask = sysblk.started_mask;
76 while (sysblk.started_mask)
77 {
78 for (i = 0; i < MAX_CPU_ENGINES; i++)
79 {
80 if (IS_CPU_ONLINE(i))
81 {
82 sysblk.regs[i]->cpustate = CPUSTATE_STOPPING;
83 ON_IC_INTERRUPT(sysblk.regs[i]);
84 signal_condition(&sysblk.regs[i]->intcond);
85 }
86 }
87 RELEASE_INTLOCK(NULL);
88 usleep (1000);
89 OBTAIN_INTLOCK(NULL);
90 }
91 RELEASE_INTLOCK(NULL);
92
93 /* Wait for I/O queue to clear out */
94 #ifdef OPTION_FISHIO
95 SLEEP (2);
96 #else
97 obtain_lock (&sysblk.ioqlock);
98 while (sysblk.ioq)
99 {
100 release_lock (&sysblk.ioqlock);
101 usleep (1000);
102 obtain_lock (&sysblk.ioqlock);
103 }
104 release_lock (&sysblk.ioqlock);
105 #endif
106
107 /* Wait for active I/Os to complete */
108 for (i = 1; i < 5000; i++)
109 {
110 dev = sr_active_devices();
111 if (dev == NULL) break;
112 if (i % 500 == 0)
113 logmsg( _("HHCSR103W Waiting for device %4.4X\n"),
114 dev->devnum);
115 usleep (10000);
116 }
117 if (dev != NULL)
118 logmsg( _("HHCSR104W Device %4.4X still busy, proceeding anyway\n"),
119 dev->devnum);
120
121 /* Write header */
122 SR_WRITE_STRING(file, SR_HDR_ID, SR_ID);
123 SR_WRITE_STRING(file, SR_HDR_VERSION, VERSION);
124 gettimeofday(&tv, NULL); tt = tv.tv_sec;
125 SR_WRITE_STRING(file, SR_HDR_DATE, ctime(&tt));
126
127 /* Write system data */
128 SR_WRITE_STRING(file,SR_SYS_ARCH_NAME,arch_name[sysblk.arch_mode]);
129 SR_WRITE_VALUE (file,SR_SYS_STARTED_MASK,started_mask,sizeof(started_mask));
130 SR_WRITE_VALUE (file,SR_SYS_MAINSIZE,sysblk.mainsize,sizeof(sysblk.mainsize));
131 SR_WRITE_BUF (file,SR_SYS_MAINSTOR,sysblk.mainstor,sysblk.mainsize);
132 SR_WRITE_VALUE (file,SR_SYS_SKEYSIZE,sysblk.mainsize/STORAGE_KEY_UNITSIZE,sizeof(int));
133 SR_WRITE_BUF (file,SR_SYS_STORKEYS,sysblk.storkeys,sysblk.mainsize/STORAGE_KEY_UNITSIZE);
134 SR_WRITE_VALUE (file,SR_SYS_XPNDSIZE,sysblk.xpndsize,sizeof(sysblk.xpndsize));
135 SR_WRITE_BUF (file,SR_SYS_XPNDSTOR,sysblk.xpndstor,sysblk.xpndsize);
136 SR_WRITE_VALUE (file,SR_SYS_CPUID,sysblk.cpuid,sizeof(sysblk.cpuid));
137 SR_WRITE_VALUE (file,SR_SYS_IPLDEV,sysblk.ipldev,sizeof(sysblk.ipldev));
138 SR_WRITE_VALUE (file,SR_SYS_IPLCPU,sysblk.iplcpu,sizeof(sysblk.iplcpu));
139 SR_WRITE_VALUE (file,SR_SYS_MBO,sysblk.mbo,sizeof(sysblk.mbo));
140 SR_WRITE_VALUE (file,SR_SYS_MBK,sysblk.mbk,sizeof(sysblk.mbk));
141 SR_WRITE_VALUE (file,SR_SYS_MBM,sysblk.mbm,sizeof(sysblk.mbm));
142 SR_WRITE_VALUE (file,SR_SYS_MBD,sysblk.mbd,sizeof(sysblk.mbd));
143
144 for (ioq = sysblk.iointq; ioq; ioq = ioq->next)
145 if (ioq->pcipending)
146 {
147 SR_WRITE_VALUE(file,SR_SYS_PCIPENDING_LCSS, SSID_TO_LCSS(ioq->dev->ssid),sizeof(U16));
148 SR_WRITE_VALUE(file,SR_SYS_PCIPENDING, ioq->dev->devnum,sizeof(ioq->dev->devnum));
149 }
150 else if (ioq->attnpending)
151 {
152 SR_WRITE_VALUE(file,SR_SYS_ATTNPENDING_LCSS, SSID_TO_LCSS(ioq->dev->ssid),sizeof(U16));
153 SR_WRITE_VALUE(file,SR_SYS_ATTNPENDING, ioq->dev->devnum,sizeof(ioq->dev->devnum));
154 }
155 else
156 {
157 SR_WRITE_VALUE(file,SR_SYS_IOPENDING_LCSS, SSID_TO_LCSS(ioq->dev->ssid),sizeof(U16));
158 SR_WRITE_VALUE(file,SR_SYS_IOPENDING, ioq->dev->devnum,sizeof(ioq->dev->devnum));
159 }
160
161 for (i = 0; i < 8; i++)
162 SR_WRITE_VALUE(file,SR_SYS_CHP_RESET+i,sysblk.chp_reset[i],sizeof(sysblk.chp_reset[0]));
163
164 SR_WRITE_VALUE (file,SR_SYS_SERVPARM,sysblk.servparm,sizeof(sysblk.servparm));
165 SR_WRITE_VALUE (file,SR_SYS_SIGINTREQ,sysblk.sigintreq,1);
166 SR_WRITE_STRING(file,SR_SYS_LOADPARM,str_loadparm());
167 SR_WRITE_VALUE (file,SR_SYS_INTS_STATE,sysblk.ints_state,sizeof(sysblk.ints_state));
168 SR_WRITE_HDR(file, SR_DELIMITER, 0);
169
170 /* Save service console state */
171 SR_WRITE_HDR(file, SR_SYS_SERVC, 0);
172 servc_hsuspend(file);
173 SR_WRITE_HDR(file, SR_DELIMITER, 0);
174
175 /* Save clock state */
176 SR_WRITE_HDR(file, SR_SYS_CLOCK, 0);
177 clock_hsuspend(file);
178 SR_WRITE_HDR(file, SR_DELIMITER, 0);
179
180 /* Write CPU data */
181 for (i = 0; i < MAX_CPU_ENGINES; i++)
182 {
183 if (!IS_CPU_ONLINE(i)) continue;
184 regs = sysblk.regs[i];
185 SR_WRITE_VALUE(file, SR_CPU, i, sizeof(i));
186 SR_WRITE_VALUE(file, SR_CPU_ARCHMODE, regs->arch_mode,sizeof(regs->arch_mode));
187 SR_WRITE_VALUE(file, SR_CPU_PX, regs->PX_G,sizeof(regs->PX_G));
188 copy_psw (regs, psw);
189 SR_WRITE_BUF(file, SR_CPU_PSW, psw, 16);
190 for (j = 0; j < 16; j++)
191 SR_WRITE_VALUE(file, SR_CPU_GR+j, regs->GR_G(j),sizeof(regs->GR_G(0)));
192 for (j = 0; j < 16; j++)
193 SR_WRITE_VALUE(file, SR_CPU_CR+j, regs->CR_G(j),sizeof(regs->CR_G(0)));
194 for (j = 0; j < 16; j++)
195 SR_WRITE_VALUE(file, SR_CPU_AR+j, regs->ar[j],sizeof(regs->ar[0]));
196 for (j = 0; j < 32; j++)
197 SR_WRITE_VALUE(file, SR_CPU_FPR+j, regs->fpr[j],sizeof(regs->fpr[0]));
198 SR_WRITE_VALUE(file, SR_CPU_FPC, regs->fpc, sizeof(regs->fpc));
199 SR_WRITE_VALUE(file, SR_CPU_DXC, regs->dxc, sizeof(regs->dxc));
200 SR_WRITE_VALUE(file, SR_CPU_MC, regs->MC_G, sizeof(regs->MC_G));
201 SR_WRITE_VALUE(file, SR_CPU_EA, regs->EA_G, sizeof(regs->EA_G));
202 SR_WRITE_VALUE(file, SR_CPU_PTIMER, cpu_timer(regs), sizeof(S64));
203 SR_WRITE_VALUE(file, SR_CPU_CLKC, regs->clkc, sizeof(regs->clkc));
204 SR_WRITE_VALUE(file, SR_CPU_CHANSET, regs->chanset, sizeof(regs->chanset));
205 SR_WRITE_VALUE(file, SR_CPU_TODPR, regs->todpr, sizeof(regs->todpr));
206 SR_WRITE_VALUE(file, SR_CPU_MONCLASS, regs->monclass, sizeof(regs->monclass));
207 SR_WRITE_VALUE(file, SR_CPU_EXCARID, regs->excarid, sizeof(regs->excarid));
208 SR_WRITE_VALUE(file, SR_CPU_BEAR, regs->bear, sizeof(regs->bear));
209 SR_WRITE_VALUE(file, SR_CPU_OPNDRID, regs->opndrid, sizeof(regs->opndrid));
210 SR_WRITE_VALUE(file, SR_CPU_CHECKSTOP, regs->checkstop, 1);
211 SR_WRITE_VALUE(file, SR_CPU_HOSTINT, regs->hostint, 1);
212 SR_WRITE_VALUE(file, SR_CPU_EXECFLAG, regs->execflag, 1);
213 // SR_WRITE_VALUE(file, SR_CPU_INSTVALID, regs->instvalid, 1);
214 SR_WRITE_VALUE(file, SR_CPU_PERMODE, regs->permode, 1);
215 SR_WRITE_VALUE(file, SR_CPU_LOADSTATE, regs->loadstate, 1);
216 SR_WRITE_VALUE(file, SR_CPU_INVALIDATE, regs->invalidate, 1);
217 SR_WRITE_VALUE(file, SR_CPU_SIGPRESET, regs->sigpreset, 1);
218 SR_WRITE_VALUE(file, SR_CPU_SIGPIRESET, regs->sigpireset, 1);
219 SR_WRITE_VALUE(file, SR_CPU_INTS_STATE, regs->ints_state, sizeof(regs->ints_state));
220 SR_WRITE_VALUE(file, SR_CPU_INTS_MASK, regs->ints_mask, sizeof(regs->ints_mask));
221 for (j = 0; j < MAX_CPU_ENGINES; j++)
222 SR_WRITE_VALUE(file, SR_CPU_MALFCPU+j, regs->malfcpu[j], sizeof(regs->malfcpu[0]));
223 for (j = 0; j < MAX_CPU_ENGINES; j++)
224 SR_WRITE_VALUE(file, SR_CPU_EMERCPU+j, regs->emercpu[j], sizeof(regs->emercpu[0]));
225 SR_WRITE_VALUE(file, SR_CPU_EXTCCPU, regs->extccpu, sizeof(regs->extccpu));
226 SR_WRITE_HDR(file, SR_DELIMITER, 0);
227 }
228
229 /* Write Device data */
230 for (dev = sysblk.firstdev; dev; dev = dev->nextdev)
231 {
232 if (!(dev->pmcw.flag5 & PMCW5_V)) continue;
233
234 /* These fields must come first so the device could be attached */
235 SR_WRITE_VALUE(file, SR_DEV, dev->devnum, sizeof(dev->devnum));
236 SR_WRITE_VALUE(file, SR_DEV_LCSS, SSID_TO_LCSS(dev->ssid), sizeof(U16));
237 SR_WRITE_VALUE(file, SR_DEV_ARGC, dev->argc, sizeof(dev->argc));
238 for (i = 0; i < dev->argc; i++)
239 if (dev->argv[i])
240 {
241 SR_WRITE_STRING(file, SR_DEV_ARGV, dev->argv[i]);
242 }
243 else
244 {
245 SR_WRITE_STRING(file, SR_DEV_ARGV, "");
246 }
247 SR_WRITE_STRING(file, SR_DEV_TYPNAME, dev->typname);
248
249 /* Common device fields */
250 SR_WRITE_BUF (file, SR_DEV_ORB, &dev->orb, sizeof(ORB));
251 SR_WRITE_BUF (file, SR_DEV_PMCW, &dev->pmcw, sizeof(PMCW));
252 SR_WRITE_BUF (file, SR_DEV_SCSW, &dev->scsw, sizeof(SCSW));
253 SR_WRITE_BUF (file, SR_DEV_PCISCSW, &dev->pciscsw, sizeof(SCSW));
254 SR_WRITE_BUF (file, SR_DEV_ATTNSCSW, &dev->attnscsw, sizeof(SCSW));
255 SR_WRITE_BUF (file, SR_DEV_CSW, dev->csw, 8);
256 SR_WRITE_BUF (file, SR_DEV_PCICSW, dev->pcicsw, 8);
257 SR_WRITE_BUF (file, SR_DEV_ATTNCSW, dev->attncsw, 8);
258 SR_WRITE_BUF (file, SR_DEV_ESW, &dev->esw, sizeof(ESW));
259 SR_WRITE_BUF (file, SR_DEV_ECW, dev->ecw, 32);
260 SR_WRITE_BUF (file, SR_DEV_SENSE, dev->sense, 32);
261 SR_WRITE_VALUE(file, SR_DEV_PGSTAT, dev->pgstat, sizeof(dev->pgstat));
262 SR_WRITE_BUF (file, SR_DEV_PGID, dev->pgid, 11);
263 /* By Adrian - SR_DEV_DRVPWD */
264 SR_WRITE_BUF (file, SR_DEV_DRVPWD, dev->drvpwd, 11);
265
266 SR_WRITE_VALUE(file, SR_DEV_BUSY, dev->busy, 1);
267 SR_WRITE_VALUE(file, SR_DEV_RESERVED, dev->reserved, 1);
268 SR_WRITE_VALUE(file, SR_DEV_SUSPENDED, dev->suspended, 1);
269 SR_WRITE_VALUE(file, SR_DEV_PCIPENDING, dev->pcipending, 1);
270 SR_WRITE_VALUE(file, SR_DEV_ATTNPENDING, dev->attnpending, 1);
271 SR_WRITE_VALUE(file, SR_DEV_PENDING, dev->pending, 1);
272 SR_WRITE_VALUE(file, SR_DEV_STARTPENDING, dev->startpending, 1);
273 SR_WRITE_VALUE(file, SR_DEV_CRWPENDING, dev->crwpending, 1);
274 SR_WRITE_VALUE(file, SR_DEV_CCWADDR, dev->ccwaddr, sizeof(dev->ccwaddr));
275 SR_WRITE_VALUE(file, SR_DEV_IDAPMASK, dev->idapmask, sizeof(dev->idapmask));
276 SR_WRITE_VALUE(file, SR_DEV_IDAWFMT, dev->idawfmt, sizeof(dev->idawfmt));
277 SR_WRITE_VALUE(file, SR_DEV_CCWFMT, dev->ccwfmt, sizeof(dev->ccwfmt));
278 SR_WRITE_VALUE(file, SR_DEV_CCWKEY, dev->ccwkey, sizeof(dev->ccwkey));
279
280 /* Device type specific data */
281 SR_WRITE_VALUE(file, SR_DEV_DEVTYPE, dev->devtype, sizeof(dev->devtype));
282 if (dev->hnd->hsuspend)
283 {
284 rc = (dev->hnd->hsuspend) (dev, file);
285 if (rc < 0) goto sr_error_exit;
286 }
287 SR_WRITE_HDR(file, SR_DELIMITER, 0);
288 }
289
290 SR_WRITE_HDR(file, SR_EOF, 0);
291 SR_CLOSE (file);
292
293 /* Shutdown */
294 do_shutdown();
295
296 return 0;
297
298 sr_write_error:
299 logmsg(_("HHCSR010E write error: %s\n"), strerror(errno));
300 goto sr_error_exit;
301 sr_value_error:
302 logmsg(_("HHCSR013E value error, incorrect length\n"));
303 goto sr_error_exit;
304 sr_string_error:
305 logmsg(_("HHCSR014E string error, incorrect length\n"));
306 goto sr_error_exit;
307 sr_error_exit:
308 logmsg(_("HHCSR015E error processing file %s\n"),fn);
309 SR_CLOSE (file);
310 return -1;
311 }
312
resume_cmd(int argc,char * argv[],char * cmdline)313 int resume_cmd(int argc, char *argv[],char *cmdline)
314 {
315 char *fn = SR_DEFAULT_FILENAME;
316 SR_FILE file;
317 U32 key = 0, len = 0;
318 CPU_BITMAP started_mask = 0;
319 int i, rc;
320 REGS *regs = NULL;
321 U16 devnum=0;
322 U16 lcss=0;
323 U16 hw;
324 int devargc=0;
325 char *devargv[16];
326 int devargx=0;
327 DEVBLK *dev = NULL;
328 IOINT *ioq = NULL;
329 char buf[SR_MAX_STRING_LENGTH+1];
330 char zeros[16];
331 S64 dreg;
332
333 UNREFERENCED(cmdline);
334
335 if (argc > 2)
336 {
337 logmsg( _("HHCSR101E Too many arguments\n"));
338 return -1;
339 }
340
341 if (argc == 2)
342 fn = argv[1];
343
344 memset (zeros, 0, sizeof(zeros));
345
346 /* Make sure all CPUs are deconfigured or stopped */
347 OBTAIN_INTLOCK(NULL);
348 for (i = 0; i < MAX_CPU_ENGINES; i++)
349 if (IS_CPU_ONLINE(i)
350 && CPUSTATE_STOPPED != sysblk.regs[i]->cpustate)
351 {
352 RELEASE_INTLOCK(NULL);
353 logmsg( _("HHCSR103E All CPU's must be stopped to resume\n") );
354 return -1;
355 }
356 RELEASE_INTLOCK(NULL);
357
358 file = SR_OPEN (fn, "rb");
359 if (file == NULL)
360 {
361 logmsg( _("HHCSR102E %s open error: %s\n"),fn,strerror(errno));
362 return -1;
363 }
364
365 /* First key must be SR_HDR_ID and string must match SR_ID */
366 SR_READ_HDR(file, key, len);
367 if (key == SR_HDR_ID) SR_READ_STRING(file, buf, len);
368 if (key != SR_HDR_ID || strcmp(buf, SR_ID))
369 {
370 logmsg( _("HHCSR104E File identifier error\n"));
371 goto sr_error_exit;
372 }
373
374 /* Deconfigure all CPUs */
375 OBTAIN_INTLOCK(NULL);
376 for (i = 0; i < MAX_CPU_ENGINES; i++)
377 if (IS_CPU_ONLINE(i))
378 deconfigure_cpu(i);
379 RELEASE_INTLOCK(NULL);
380
381 while (key != SR_EOF)
382 {
383 SR_READ_HDR(file, key, len);
384 switch (key) {
385
386 case SR_HDR_DATE:
387 SR_READ_STRING(file, buf, len);
388 logmsg( _("HHCSR001I Resuming suspended file created %s"), buf);
389 break;
390
391 case SR_SYS_STARTED_MASK:
392 SR_READ_VALUE(file, len, &started_mask, sizeof(started_mask));
393 break;
394
395 case SR_SYS_ARCH_NAME:
396 SR_READ_STRING(file, buf, len);
397 i = -1;
398 #if defined (_370)
399 if (strcasecmp (buf, arch_name[ARCH_370]) == 0)
400 {
401 i = ARCH_370;
402 sysblk.maxcpu = sysblk.numcpu;
403 }
404 #endif
405 #if defined (_390)
406 if (strcasecmp (buf, arch_name[ARCH_390]) == 0)
407 {
408 i = ARCH_390;
409 #if defined(_FEATURE_CPU_RECONFIG)
410 sysblk.maxcpu = MAX_CPU_ENGINES;
411 #else
412 sysblk.maxcpu = sysblk.numcpu;
413 #endif
414 }
415 #endif
416 #if defined (_900)
417 if (0
418 || strcasecmp (buf, arch_name[ARCH_900]) == 0
419 || strcasecmp (buf, "ESAME") == 0
420 )
421 {
422 i = ARCH_900;
423 #if defined(_FEATURE_CPU_RECONFIG)
424 sysblk.maxcpu = MAX_CPU_ENGINES;
425 #else
426 sysblk.maxcpu = sysblk.numcpu;
427 #endif
428 }
429 #endif
430 if (i < 0)
431 {
432 logmsg( _("HHCSR105E Archmode %s not supported\n"), buf);
433 goto sr_error_exit;
434 }
435 sysblk.arch_mode = i;
436 #if defined (_900)
437 sysblk.arch_z900 = sysblk.arch_mode != ARCH_390;
438 #endif
439 sysblk.pcpu = 0;
440 sysblk.dummyregs.arch_mode = sysblk.arch_mode;
441 #if defined(OPTION_FISHIO)
442 ios_arch_mode = sysblk.arch_mode;
443 #endif
444 break;
445
446 case SR_SYS_MAINSIZE:
447 SR_READ_VALUE(file, len, &len, sizeof(len));
448 if (len > sysblk.mainsize)
449 {
450 logmsg( _("HHCSR106E Mainsize mismatch: %d" "M expected %d" "M\n"),
451 len / (1024*1024), sysblk.mainsize / (1024*1024));
452 goto sr_error_exit;
453 }
454 break;
455
456 case SR_SYS_MAINSTOR:
457 if (len > sysblk.mainsize)
458 {
459 logmsg( _("HHCSR107E Mainsize mismatch: %d" "M expected %d" "M\n"),
460 len / (1024*1024), sysblk.mainsize / (1024*1024));
461 goto sr_error_exit;
462 }
463 SR_READ_BUF(file, sysblk.mainstor, len);
464 break;
465
466 case SR_SYS_SKEYSIZE:
467 SR_READ_VALUE(file, len, &len, sizeof(len));
468 if (len > sysblk.mainsize/STORAGE_KEY_UNITSIZE)
469 {
470 logmsg( _("HHCSR108E Storkey size mismatch: %d expected %d\n"),
471 len, sysblk.mainsize/STORAGE_KEY_UNITSIZE);
472 goto sr_error_exit;
473 }
474 break;
475
476 case SR_SYS_STORKEYS:
477 if (len > sysblk.mainsize/STORAGE_KEY_UNITSIZE)
478 {
479 logmsg( _("HHCSR109E Storkey size mismatch: %d expected %d\n"),
480 len, sysblk.mainsize/STORAGE_KEY_UNITSIZE);
481 goto sr_error_exit;
482 }
483 SR_READ_BUF(file, sysblk.storkeys, len);
484 break;
485
486 case SR_SYS_XPNDSIZE:
487 SR_READ_VALUE(file, len, &len, sizeof(len));
488 if (len > sysblk.xpndsize)
489 {
490 logmsg( _("HHCSR110E Xpndsize mismatch: %d" "M expected %d" "M\n"),
491 len / (1024*1024), sysblk.xpndsize / (1024*1024));
492 goto sr_error_exit;
493 }
494 break;
495
496 case SR_SYS_XPNDSTOR:
497 if (len > sysblk.xpndsize)
498 {
499 logmsg( _("HHCSR111E Xpndsize mismatch: %d" "M expected %d" "M\n"),
500 len / (1024*1024), sysblk.xpndsize / (1024*1024));
501 goto sr_error_exit;
502 }
503 SR_READ_BUF(file, sysblk.xpndstor, len);
504 break;
505
506 case SR_SYS_IPLDEV:
507 SR_READ_VALUE(file, len, &sysblk.ipldev, sizeof(sysblk.ipldev));
508 break;
509
510 case SR_SYS_IPLCPU:
511 SR_READ_VALUE(file, len, &sysblk.iplcpu, sizeof(sysblk.iplcpu));
512 break;
513
514 case SR_SYS_MBO:
515 SR_READ_VALUE(file, len, &sysblk.mbo, sizeof(sysblk.mbo));
516 break;
517
518 case SR_SYS_MBK:
519 SR_READ_VALUE(file, len, &sysblk.mbk, sizeof(sysblk.mbk));
520 break;
521
522 case SR_SYS_MBM:
523 SR_READ_VALUE(file, len, &sysblk.mbm, sizeof(sysblk.mbm));
524 break;
525
526 case SR_SYS_MBD:
527 SR_READ_VALUE(file, len, &sysblk.mbd, sizeof(sysblk.mbd));
528 break;
529
530 case SR_SYS_IOPENDING_LCSS:
531 SR_READ_VALUE(file,len,&lcss,sizeof(lcss));
532 break;
533
534 case SR_SYS_IOPENDING:
535 SR_READ_VALUE(file, len, &hw, sizeof(hw));
536 dev = find_device_by_devnum(lcss,hw);
537 if (dev == NULL) break;
538 if (ioq == NULL)
539 sysblk.iointq = &dev->ioint;
540 else
541 ioq->next = &dev->ioint;
542 ioq = &dev->ioint;
543 dev = NULL;
544 lcss = 0;
545 break;
546
547 case SR_SYS_PCIPENDING_LCSS:
548 SR_READ_VALUE(file,len,&lcss,sizeof(lcss));
549 break;
550
551 case SR_SYS_PCIPENDING:
552 SR_READ_VALUE(file, len, &hw, sizeof(hw));
553 dev = find_device_by_devnum(lcss,hw);
554 if (dev == NULL) break;
555 if (ioq == NULL)
556 sysblk.iointq = &dev->pciioint;
557 else
558 ioq->next = &dev->pciioint;
559 ioq = &dev->pciioint;
560 dev = NULL;
561 lcss = 0;
562 break;
563
564 case SR_SYS_ATTNPENDING_LCSS:
565 SR_READ_VALUE(file,len,&lcss,sizeof(lcss));
566 break;
567
568 case SR_SYS_ATTNPENDING:
569 SR_READ_VALUE(file, len, &hw, sizeof(hw));
570 dev = find_device_by_devnum(lcss,hw);
571 if (dev == NULL) break;
572 if (ioq == NULL)
573 sysblk.iointq = &dev->attnioint;
574 else
575 ioq->next = &dev->attnioint;
576 ioq = &dev->attnioint;
577 dev = NULL;
578 lcss = 0;
579 break;
580
581 case SR_SYS_CHP_RESET_0:
582 case SR_SYS_CHP_RESET_1:
583 case SR_SYS_CHP_RESET_2:
584 case SR_SYS_CHP_RESET_3:
585 case SR_SYS_CHP_RESET_4:
586 case SR_SYS_CHP_RESET_5:
587 case SR_SYS_CHP_RESET_6:
588 case SR_SYS_CHP_RESET_7:
589 i = key - SR_SYS_CHP_RESET;
590 SR_READ_VALUE(file, len, &sysblk.chp_reset[i], sizeof(sysblk.chp_reset[0]));
591 break;
592
593 case SR_SYS_SERVPARM:
594 SR_READ_VALUE(file, len, &sysblk.servparm, sizeof(sysblk.servparm));
595 break;
596
597 case SR_SYS_SIGINTREQ:
598 SR_READ_VALUE(file, len, &rc, sizeof(rc));
599 sysblk.sigintreq = rc;
600 break;
601
602 case SR_SYS_LOADPARM:
603 SR_READ_STRING(file, buf, len);
604 set_loadparm ((char *)buf);
605 break;
606
607 case SR_SYS_SERVC:
608 rc = servc_hresume(file);
609 if (rc < 0) goto sr_error_exit;
610 break;
611
612 case SR_SYS_CLOCK:
613 rc = clock_hresume(file);
614 if (rc < 0) goto sr_error_exit;
615 break;
616
617 case SR_CPU:
618 SR_READ_VALUE(file, len, &i, sizeof(i));
619 if (i >= MAX_CPU_ENGINES)
620 {
621 logmsg( _("HHCSR113E CPU%4.4d exceeds max allowed cpu (%d)\n"),
622 i, MAX_CPU_ENGINES-1);
623 goto sr_error_exit;
624 }
625 OBTAIN_INTLOCK(NULL);
626 if (IS_CPU_ONLINE(i))
627 {
628 RELEASE_INTLOCK(NULL);
629 logmsg( _("HHCSR114E CPU%4.4d already configured\n"), i);
630 goto sr_error_exit;
631 }
632 rc = configure_cpu(i);
633 RELEASE_INTLOCK(NULL);
634 if (rc < 0)
635 {
636 logmsg( _("HHCSR115E CPU%4.4d unable to configure online\n"), i);
637 goto sr_error_exit;
638 }
639 regs = sysblk.regs[i];
640 break;
641
642 case SR_CPU_PX:
643 if (regs == NULL) goto sr_null_regs_exit;
644 SR_READ_VALUE(file, len, ®s->px, sizeof(regs->px));
645 break;
646
647 case SR_CPU_PSW:
648 if (regs == NULL) goto sr_null_regs_exit;
649 if (len != 8 && len != 16)
650 {
651 logmsg( _("HHCSR116E CPU%4.4d invalid psw length (%d)\n"),
652 regs->cpuad, len);
653 goto sr_error_exit;
654 }
655 memset(buf, 0, 16);
656 SR_READ_BUF(file, buf, len);
657 switch (regs->arch_mode) {
658 #if defined (_370)
659 case ARCH_370:
660 len = 8;
661 rc = s370_load_psw(regs, (BYTE *)&buf);
662 break;
663 #endif
664 #if defined (_390)
665 case ARCH_390:
666 len = 8;
667 rc = s390_load_psw(regs, (BYTE *)&buf);
668 break;
669 #endif
670 #if defined (_900)
671 case ARCH_900:
672 len = 16;
673 rc = z900_load_psw(regs, (BYTE *)&buf);
674 break;
675 #endif
676 default: /* regs->arch_mode not valid (should not occur) */
677 rc = 99;
678 } /* switch (regs->arch_mode) */
679 if (rc != 0 && memcmp(buf, zeros, len))
680 {
681 logmsg( _("HHCSR117E CPU%4.4d error loading psw (%d)\n"),
682 regs->cpuad, rc);
683 goto sr_error_exit;
684 }
685 break;
686
687 case SR_CPU_GR_0:
688 case SR_CPU_GR_1:
689 case SR_CPU_GR_2:
690 case SR_CPU_GR_3:
691 case SR_CPU_GR_4:
692 case SR_CPU_GR_5:
693 case SR_CPU_GR_6:
694 case SR_CPU_GR_7:
695 case SR_CPU_GR_8:
696 case SR_CPU_GR_9:
697 case SR_CPU_GR_10:
698 case SR_CPU_GR_11:
699 case SR_CPU_GR_12:
700 case SR_CPU_GR_13:
701 case SR_CPU_GR_14:
702 case SR_CPU_GR_15:
703 if (regs == NULL) goto sr_null_regs_exit;
704 i = key - SR_CPU_GR;
705 SR_READ_VALUE(file, len, ®s->gr[i], sizeof(regs->gr[0]));
706 break;
707
708 case SR_CPU_CR_0:
709 case SR_CPU_CR_1:
710 case SR_CPU_CR_2:
711 case SR_CPU_CR_3:
712 case SR_CPU_CR_4:
713 case SR_CPU_CR_5:
714 case SR_CPU_CR_6:
715 case SR_CPU_CR_7:
716 case SR_CPU_CR_8:
717 case SR_CPU_CR_9:
718 case SR_CPU_CR_10:
719 case SR_CPU_CR_11:
720 case SR_CPU_CR_12:
721 case SR_CPU_CR_13:
722 case SR_CPU_CR_14:
723 case SR_CPU_CR_15:
724 if (regs == NULL) goto sr_null_regs_exit;
725 i = key - SR_CPU_CR;
726 SR_READ_VALUE(file, len, ®s->cr[i], sizeof(regs->cr[0]));
727 break;
728
729 case SR_CPU_AR_0:
730 case SR_CPU_AR_1:
731 case SR_CPU_AR_2:
732 case SR_CPU_AR_3:
733 case SR_CPU_AR_4:
734 case SR_CPU_AR_5:
735 case SR_CPU_AR_6:
736 case SR_CPU_AR_7:
737 case SR_CPU_AR_8:
738 case SR_CPU_AR_9:
739 case SR_CPU_AR_10:
740 case SR_CPU_AR_11:
741 case SR_CPU_AR_12:
742 case SR_CPU_AR_13:
743 case SR_CPU_AR_14:
744 case SR_CPU_AR_15:
745 if (regs == NULL) goto sr_null_regs_exit;
746 i = key - SR_CPU_AR;
747 SR_READ_VALUE(file, len, ®s->ar[i], sizeof(regs->ar[0]));
748 break;
749
750 case SR_CPU_FPR_0:
751 case SR_CPU_FPR_1:
752 case SR_CPU_FPR_2:
753 case SR_CPU_FPR_3:
754 case SR_CPU_FPR_4:
755 case SR_CPU_FPR_5:
756 case SR_CPU_FPR_6:
757 case SR_CPU_FPR_7:
758 case SR_CPU_FPR_8:
759 case SR_CPU_FPR_9:
760 case SR_CPU_FPR_10:
761 case SR_CPU_FPR_11:
762 case SR_CPU_FPR_12:
763 case SR_CPU_FPR_13:
764 case SR_CPU_FPR_14:
765 case SR_CPU_FPR_15:
766 case SR_CPU_FPR_16:
767 case SR_CPU_FPR_17:
768 case SR_CPU_FPR_18:
769 case SR_CPU_FPR_19:
770 case SR_CPU_FPR_20:
771 case SR_CPU_FPR_21:
772 case SR_CPU_FPR_22:
773 case SR_CPU_FPR_23:
774 case SR_CPU_FPR_24:
775 case SR_CPU_FPR_25:
776 case SR_CPU_FPR_26:
777 case SR_CPU_FPR_27:
778 case SR_CPU_FPR_28:
779 case SR_CPU_FPR_29:
780 case SR_CPU_FPR_30:
781 case SR_CPU_FPR_31:
782 if (regs == NULL) goto sr_null_regs_exit;
783 i = key - SR_CPU_FPR;
784 SR_READ_VALUE(file, len, ®s->fpr[i], sizeof(regs->fpr[0]));
785 break;
786
787 case SR_CPU_FPC:
788 if (regs == NULL) goto sr_null_regs_exit;
789 SR_READ_VALUE(file, len, ®s->fpc, sizeof(regs->fpc));
790 break;
791
792 case SR_CPU_DXC:
793 if (regs == NULL) goto sr_null_regs_exit;
794 SR_READ_VALUE(file, len, ®s->dxc, sizeof(regs->dxc));
795 break;
796
797 case SR_CPU_MC:
798 if (regs == NULL) goto sr_null_regs_exit;
799 SR_READ_VALUE(file, len, ®s->mc, sizeof(regs->mc));
800 break;
801
802 case SR_CPU_EA:
803 if (regs == NULL) goto sr_null_regs_exit;
804 SR_READ_VALUE(file, len, ®s->ea, sizeof(regs->ea));
805 break;
806
807 case SR_CPU_PTIMER:
808 if (regs == NULL) goto sr_null_regs_exit;
809 SR_READ_VALUE(file, len, &dreg, sizeof(S64));
810 set_cpu_timer(regs, dreg);
811 break;
812
813 case SR_CPU_CLKC:
814 if (regs == NULL) goto sr_null_regs_exit;
815 SR_READ_VALUE(file, len, ®s->clkc, sizeof(regs->clkc));
816 break;
817
818 case SR_CPU_CHANSET:
819 if (regs == NULL) goto sr_null_regs_exit;
820 SR_READ_VALUE(file, len, ®s->chanset, sizeof(regs->chanset));
821 break;
822
823 case SR_CPU_TODPR:
824 if (regs == NULL) goto sr_null_regs_exit;
825 SR_READ_VALUE(file, len, ®s->todpr, sizeof(regs->todpr));
826 break;
827
828 case SR_CPU_MONCLASS:
829 if (regs == NULL) goto sr_null_regs_exit;
830 SR_READ_VALUE(file, len, ®s->monclass, sizeof(regs->monclass));
831 break;
832
833 case SR_CPU_EXCARID:
834 if (regs == NULL) goto sr_null_regs_exit;
835 SR_READ_VALUE(file, len, ®s->excarid, sizeof(regs->excarid));
836 break;
837
838 case SR_CPU_BEAR:
839 if (regs == NULL) goto sr_null_regs_exit;
840 SR_READ_VALUE(file, len, ®s->bear, sizeof(regs->bear));
841 break;
842
843 case SR_CPU_OPNDRID:
844 if (regs == NULL) goto sr_null_regs_exit;
845 SR_READ_VALUE(file, len, ®s->opndrid, sizeof(regs->opndrid));
846 break;
847
848 case SR_CPU_CHECKSTOP:
849 if (regs == NULL) goto sr_null_regs_exit;
850 SR_READ_VALUE(file, len, &rc, sizeof(rc));
851 regs->checkstop = rc;
852 break;
853
854 case SR_CPU_HOSTINT:
855 if (regs == NULL) goto sr_null_regs_exit;
856 SR_READ_VALUE(file, len, &rc, sizeof(rc));
857 regs->hostint = rc;
858 break;
859
860 case SR_CPU_LOADSTATE:
861 if (regs == NULL) goto sr_null_regs_exit;
862 SR_READ_VALUE(file, len, &rc, sizeof(rc));
863 regs->loadstate = rc;
864 break;
865
866 case SR_CPU_INVALIDATE:
867 if (regs == NULL) goto sr_null_regs_exit;
868 SR_READ_VALUE(file, len, &rc, sizeof(rc));
869 regs->invalidate = rc;
870 break;
871
872 case SR_CPU_SIGPRESET:
873 if (regs == NULL) goto sr_null_regs_exit;
874 SR_READ_VALUE(file, len, &rc, sizeof(rc));
875 regs->sigpreset = rc;
876 break;
877
878 case SR_CPU_SIGPIRESET:
879 if (regs == NULL) goto sr_null_regs_exit;
880 SR_READ_VALUE(file, len, &rc, sizeof(rc));
881 regs->sigpireset = rc;
882 break;
883
884 case SR_CPU_INTS_STATE:
885 if (regs == NULL) goto sr_null_regs_exit;
886 SR_READ_VALUE(file, len, ®s->ints_state, sizeof(regs->ints_state));
887 /* Force CPU to examine the interrupt state */
888 ON_IC_INTERRUPT(regs);
889 break;
890
891 case SR_CPU_INTS_MASK:
892 if (regs == NULL) goto sr_null_regs_exit;
893 SR_READ_VALUE(file, len, ®s->ints_mask, sizeof(regs->ints_mask));
894 break;
895
896 case SR_CPU_MALFCPU_0:
897 case SR_CPU_MALFCPU_1:
898 case SR_CPU_MALFCPU_2:
899 case SR_CPU_MALFCPU_3:
900 case SR_CPU_MALFCPU_4:
901 case SR_CPU_MALFCPU_5:
902 case SR_CPU_MALFCPU_6:
903 case SR_CPU_MALFCPU_7:
904 case SR_CPU_MALFCPU_8:
905 case SR_CPU_MALFCPU_9:
906 case SR_CPU_MALFCPU_10:
907 case SR_CPU_MALFCPU_11:
908 case SR_CPU_MALFCPU_12:
909 case SR_CPU_MALFCPU_13:
910 case SR_CPU_MALFCPU_14:
911 case SR_CPU_MALFCPU_15:
912 case SR_CPU_MALFCPU_16:
913 case SR_CPU_MALFCPU_17:
914 case SR_CPU_MALFCPU_18:
915 case SR_CPU_MALFCPU_19:
916 case SR_CPU_MALFCPU_20:
917 case SR_CPU_MALFCPU_21:
918 case SR_CPU_MALFCPU_22:
919 case SR_CPU_MALFCPU_23:
920 case SR_CPU_MALFCPU_24:
921 case SR_CPU_MALFCPU_25:
922 case SR_CPU_MALFCPU_26:
923 case SR_CPU_MALFCPU_27:
924 case SR_CPU_MALFCPU_28:
925 case SR_CPU_MALFCPU_29:
926 case SR_CPU_MALFCPU_30:
927 case SR_CPU_MALFCPU_31:
928 if (regs == NULL) goto sr_null_regs_exit;
929 i = key - SR_CPU_MALFCPU;
930 if (i < MAX_CPU_ENGINES)
931 SR_READ_VALUE(file, len, ®s->malfcpu[i], sizeof(regs->malfcpu[0]));
932 break;
933
934 case SR_CPU_EMERCPU_0:
935 case SR_CPU_EMERCPU_1:
936 case SR_CPU_EMERCPU_2:
937 case SR_CPU_EMERCPU_3:
938 case SR_CPU_EMERCPU_4:
939 case SR_CPU_EMERCPU_5:
940 case SR_CPU_EMERCPU_6:
941 case SR_CPU_EMERCPU_7:
942 case SR_CPU_EMERCPU_8:
943 case SR_CPU_EMERCPU_9:
944 case SR_CPU_EMERCPU_10:
945 case SR_CPU_EMERCPU_11:
946 case SR_CPU_EMERCPU_12:
947 case SR_CPU_EMERCPU_13:
948 case SR_CPU_EMERCPU_14:
949 case SR_CPU_EMERCPU_15:
950 case SR_CPU_EMERCPU_16:
951 case SR_CPU_EMERCPU_17:
952 case SR_CPU_EMERCPU_18:
953 case SR_CPU_EMERCPU_19:
954 case SR_CPU_EMERCPU_20:
955 case SR_CPU_EMERCPU_21:
956 case SR_CPU_EMERCPU_22:
957 case SR_CPU_EMERCPU_23:
958 case SR_CPU_EMERCPU_24:
959 case SR_CPU_EMERCPU_25:
960 case SR_CPU_EMERCPU_26:
961 case SR_CPU_EMERCPU_27:
962 case SR_CPU_EMERCPU_28:
963 case SR_CPU_EMERCPU_29:
964 case SR_CPU_EMERCPU_30:
965 case SR_CPU_EMERCPU_31:
966 if (regs == NULL) goto sr_null_regs_exit;
967 i = key - SR_CPU_EMERCPU;
968 if (i < MAX_CPU_ENGINES)
969 SR_READ_VALUE(file, len, ®s->emercpu[i], sizeof(regs->emercpu[0]));
970 break;
971
972 case SR_DEV:
973 SR_READ_VALUE(file, len, &devnum, sizeof(devnum));
974 lcss=0;
975 break;
976
977 case SR_DEV_LCSS:
978 SR_READ_VALUE(file, len, &lcss, sizeof(U16));
979 break;
980
981 case SR_DEV_ARGC:
982 SR_READ_VALUE(file, len, &devargc, sizeof(devargc));
983 if (devargc > 16) devargc = 16;
984 for (i = 0; i < devargc; i++) devargv[i] = NULL;
985 devargx = 0;
986 break;
987
988 case SR_DEV_ARGV:
989 SR_READ_STRING(file, buf, len);
990 if (devargx < devargc) devargv[devargx++] = strdup(buf);
991 break;
992
993 case SR_DEV_TYPNAME:
994 SR_READ_STRING(file, buf, len);
995 dev = find_device_by_devnum(lcss,devnum);
996 if (dev == NULL)
997 {
998 if (attach_device (lcss, devnum, buf, devargc, devargv))
999 {
1000 logmsg( _("HHCSR118W Device %4.4X initialization failed\n"),
1001 devnum);
1002 }
1003 }
1004 else if (strcmp(dev->typname, buf))
1005 {
1006 logmsg( _("HHCSR119W Device %4.4X type mismatch; %s expected %s\n"),
1007 devnum, buf, dev->typname);
1008 dev = NULL;
1009 }
1010 for (i = 0; i < devargx; i++)
1011 {
1012 if (devargv[i]) free(devargv[i]);
1013 devargv[i] = NULL;
1014 }
1015 devnum = devargc = devargx = 0;
1016 break;
1017
1018 case SR_DEV_ORB:
1019 SR_SKIP_NULL_DEV(dev, file, len);
1020 if (len != sizeof(ORB))
1021 {
1022 logmsg( _("HHCSR120E Device %4.4X ORB size mismatch: %d expected %d\n"),
1023 dev->devnum, len, sizeof(ORB));
1024 goto sr_error_exit;
1025 }
1026 SR_READ_BUF(file, &dev->orb, len);
1027 break;
1028
1029 case SR_DEV_PMCW:
1030 SR_SKIP_NULL_DEV(dev, file, len);
1031 if (len != sizeof(PMCW))
1032 {
1033 logmsg( _("HHCSR121E Device %4.4X PMCW size mismatch: %d expected %d\n"),
1034 dev->devnum, len, sizeof(PMCW));
1035 goto sr_error_exit;
1036 }
1037 SR_READ_BUF(file, &dev->pmcw, len);
1038 break;
1039
1040 case SR_DEV_SCSW:
1041 SR_SKIP_NULL_DEV(dev, file, len);
1042 if (len != sizeof(SCSW))
1043 {
1044 logmsg( _("HHCSR122E Device %4.4X SCSW size mismatch: %d expected %d\n"),
1045 dev->devnum, len, sizeof(SCSW));
1046 goto sr_error_exit;
1047 }
1048 SR_READ_BUF(file, &dev->scsw, len);
1049 break;
1050
1051 case SR_DEV_PCISCSW:
1052 SR_SKIP_NULL_DEV(dev, file, len);
1053 if (len != sizeof(SCSW))
1054 {
1055 logmsg( _("HHCSR123E Device %4.4X PCI SCSW size mismatch: %d expected %d\n"),
1056 dev->devnum, len, sizeof(SCSW));
1057 goto sr_error_exit;
1058 }
1059 SR_READ_BUF(file, &dev->pciscsw, len);
1060 break;
1061
1062 case SR_DEV_ATTNSCSW:
1063 SR_SKIP_NULL_DEV(dev, file, len);
1064 if (len != sizeof(SCSW))
1065 {
1066 logmsg( _("HHCSR124E Device %4.4X Attn SCSW size mismatch: %d expected %d\n"),
1067 dev->devnum, len, sizeof(SCSW));
1068 goto sr_error_exit;
1069 }
1070 SR_READ_BUF(file, &dev->attnscsw, len);
1071 break;
1072
1073 case SR_DEV_CSW:
1074 SR_SKIP_NULL_DEV(dev, file, len);
1075 if (len != 8)
1076 {
1077 logmsg( _("HHCSR125E Device %4.4X CSW size mismatch: %d expected %d\n"),
1078 dev->devnum, len, 8);
1079 goto sr_error_exit;
1080 }
1081 SR_READ_BUF(file, &dev->csw, len);
1082 break;
1083
1084 case SR_DEV_PCICSW:
1085 SR_SKIP_NULL_DEV(dev, file, len);
1086 if (len != 8)
1087 {
1088 logmsg( _("HHCSR126E Device %4.4X PCI CSW size mismatch: %d expected %d\n"),
1089 dev->devnum, len, 8);
1090 goto sr_error_exit;
1091 }
1092 SR_READ_BUF(file, &dev->pcicsw, len);
1093 break;
1094
1095 case SR_DEV_ATTNCSW:
1096 SR_SKIP_NULL_DEV(dev, file, len);
1097 if (len != 8)
1098 {
1099 logmsg( _("HHCSR127E Device %4.4X Attn CSW size mismatch: %d expected %d\n"),
1100 dev->devnum, len, 8);
1101 goto sr_error_exit;
1102 }
1103 SR_READ_BUF(file, &dev->attncsw, len);
1104 break;
1105
1106 case SR_DEV_ESW:
1107 SR_SKIP_NULL_DEV(dev, file, len);
1108 if (len != sizeof(ESW))
1109 {
1110 logmsg( _("HHCSR128E Device %4.4X ESW size mismatch: %d expected %d\n"),
1111 dev->devnum, len, sizeof(ESW));
1112 goto sr_error_exit;
1113 }
1114 SR_READ_BUF(file, &dev->esw, len);
1115 break;
1116
1117 case SR_DEV_ECW:
1118 SR_SKIP_NULL_DEV(dev, file, len);
1119 if (len != 32)
1120 {
1121 logmsg( _("HHCSR129E Device %4.4X ECW size mismatch: %d expected %d\n"),
1122 dev->devnum, len, 32);
1123 goto sr_error_exit;
1124 }
1125 SR_READ_BUF(file, &dev->ecw, len);
1126 break;
1127
1128 case SR_DEV_SENSE:
1129 SR_SKIP_NULL_DEV(dev, file, len);
1130 if (len != 32)
1131 {
1132 logmsg( _("HHCSR130E Device %4.4X Sense size mismatch: %d expected %d\n"),
1133 dev->devnum, len, 32);
1134 goto sr_error_exit;
1135 }
1136 SR_READ_BUF(file, &dev->ecw, len);
1137 break;
1138
1139 case SR_DEV_PGSTAT:
1140 SR_SKIP_NULL_DEV(dev, file, len);
1141 SR_READ_VALUE(file, len, &dev->pgstat, sizeof(dev->pgstat));
1142 break;
1143
1144 case SR_DEV_PGID:
1145 SR_SKIP_NULL_DEV(dev, file, len);
1146 if (len != 11)
1147 {
1148 logmsg( _("HHCSR131E Device %4.4X PGID size mismatch: %d expected %d\n"),
1149 dev->devnum, len, 11);
1150 goto sr_error_exit;
1151 }
1152 SR_READ_BUF(file, &dev->pgid, len);
1153 break;
1154
1155 /* By Adrian - SR_DEV_DRVPWD */
1156 case SR_DEV_DRVPWD:
1157 SR_SKIP_NULL_DEV(dev, file, len);
1158 if (len != 11)
1159 {
1160 logmsg( _("HHCSR134E Device %4.4X DRVPWD size mismatch: %d expected %d\n"),
1161 dev->devnum, len, 11);
1162 goto sr_error_exit;
1163 }
1164 SR_READ_BUF(file, &dev->drvpwd, len);
1165 break;
1166
1167
1168
1169 case SR_DEV_BUSY:
1170 SR_SKIP_NULL_DEV(dev, file, len);
1171 SR_READ_VALUE(file, len, &rc, sizeof(rc));
1172 dev->busy = rc;
1173 break;
1174
1175 case SR_DEV_RESERVED:
1176 SR_SKIP_NULL_DEV(dev, file, len);
1177 SR_READ_VALUE(file, len, &rc, sizeof(rc));
1178 dev->reserved = rc;
1179 break;
1180
1181 case SR_DEV_SUSPENDED:
1182 SR_SKIP_NULL_DEV(dev, file, len);
1183 SR_READ_VALUE(file, len, &rc, sizeof(rc));
1184 dev->suspended = rc;
1185 break;
1186
1187 case SR_DEV_PENDING:
1188 SR_SKIP_NULL_DEV(dev, file, len);
1189 SR_READ_VALUE(file, len, &rc, sizeof(rc));
1190 dev->pending = rc;
1191 QUEUE_IO_INTERRUPT(&dev->ioint);
1192 break;
1193
1194 case SR_DEV_PCIPENDING:
1195 SR_SKIP_NULL_DEV(dev, file, len);
1196 SR_READ_VALUE(file, len, &rc, sizeof(rc));
1197 dev->pcipending = rc;
1198 QUEUE_IO_INTERRUPT(&dev->pciioint);
1199 break;
1200
1201 case SR_DEV_ATTNPENDING:
1202 SR_SKIP_NULL_DEV(dev, file, len);
1203 SR_READ_VALUE(file, len, &rc, sizeof(rc));
1204 dev->attnpending = rc;
1205 QUEUE_IO_INTERRUPT(&dev->attnioint);
1206 break;
1207
1208 case SR_DEV_STARTPENDING:
1209 SR_SKIP_NULL_DEV(dev, file, len);
1210 SR_READ_VALUE(file, len, &rc, sizeof(rc));
1211 dev->startpending = rc;
1212 break;
1213
1214 case SR_DEV_CRWPENDING:
1215 SR_SKIP_NULL_DEV(dev, file, len);
1216 SR_READ_VALUE(file, len, &rc, sizeof(rc));
1217 dev->crwpending = rc;
1218 break;
1219
1220 case SR_DEV_CCWADDR:
1221 SR_SKIP_NULL_DEV(dev, file, len);
1222 SR_READ_VALUE(file, len, &dev->ccwaddr, sizeof(dev->ccwaddr));
1223 break;
1224
1225 case SR_DEV_IDAPMASK:
1226 SR_SKIP_NULL_DEV(dev, file, len);
1227 SR_READ_VALUE(file, len, &dev->idapmask, sizeof(dev->idapmask));
1228 break;
1229
1230 case SR_DEV_IDAWFMT:
1231 SR_SKIP_NULL_DEV(dev, file, len);
1232 SR_READ_VALUE(file, len, &dev->idawfmt, sizeof(dev->idawfmt));
1233 break;
1234
1235 case SR_DEV_CCWFMT:
1236 SR_SKIP_NULL_DEV(dev, file, len);
1237 SR_READ_VALUE(file, len, &dev->ccwfmt, sizeof(dev->ccwfmt));
1238 break;
1239
1240 case SR_DEV_CCWKEY:
1241 SR_SKIP_NULL_DEV(dev, file, len);
1242 SR_READ_VALUE(file, len, &dev->ccwkey, sizeof(dev->ccwkey));
1243 break;
1244
1245 /* This is the trigger to call the device dependent resume routine */
1246 case SR_DEV_DEVTYPE:
1247 SR_SKIP_NULL_DEV(dev, file, len);
1248 SR_READ_VALUE(file, len, &hw, sizeof(hw));
1249 if (hw != dev->devtype)
1250 {
1251 logmsg( _("HHCSR132E Device %4.4X type mismatch: %4.4x expected %4.4x\n"),
1252 dev->devnum, hw, dev->devtype);
1253 goto sr_error_exit;
1254 }
1255 if (dev->hnd->hresume)
1256 {
1257 rc = (dev->hnd->hresume) (dev, file);
1258 if (rc < 0) goto sr_error_exit;
1259 }
1260 break;
1261
1262 default:
1263 if ((key & SR_KEY_ID_MASK) != SR_KEY_ID)
1264 {
1265 logmsg( _("HHCSR999E Invalid key %8.8x\n"), key);
1266 goto sr_error_exit;
1267 }
1268 SR_READ_SKIP(file, len);
1269 break;
1270
1271 } /* switch (key) */
1272
1273 } /* while (key != SR_EOF) */
1274
1275 /* For all suspended devices, resume the `suspended' state */
1276 for (dev = sysblk.firstdev; dev; dev = dev->nextdev)
1277 {
1278 if (dev->suspended && (dev->pmcw.flag5 & PMCW5_V))
1279 {
1280 dev->resumesuspended=1;
1281 switch (sysblk.arch_mode) {
1282 #if defined(_370)
1283 case ARCH_370:
1284 rc = create_thread (&dev->tid, DETACHED,
1285 s370_execute_ccw_chain, dev, "device thread");
1286 break;
1287 #endif
1288 #if defined(_390)
1289 case ARCH_390:
1290 rc = create_thread (&dev->tid, DETACHED,
1291 s390_execute_ccw_chain, dev, "device thread");
1292 break;
1293 #endif
1294 #if defined(_900)
1295 case ARCH_900:
1296 rc = create_thread (&dev->tid, DETACHED,
1297 z900_execute_ccw_chain, dev, "device thread");
1298 break;
1299 #endif
1300 default: /* sysblk.arch_mode not valid (should not occur) */
1301 rc = 99;
1302 } /* switch (sysblk.arch_mode) */
1303 if (rc != 0)
1304 {
1305 logmsg( _("HHCSR133E %4.4X Unable to resume suspended device: %s\n"),
1306 dev->devnum, strerror(errno));
1307 goto sr_error_exit;
1308 }
1309 } /* If suspended device */
1310 } /* For each device */
1311
1312 /* Indicate crw pending for any new devices */
1313 #if defined(_370)
1314 if (sysblk.arch_mode != ARCH_370)
1315 #endif
1316 machine_check_crwpend();
1317
1318 /* Start the CPUs */
1319 OBTAIN_INTLOCK(NULL);
1320 ON_IC_IOPENDING;
1321 for (i = 0; i < MAX_CPU_ENGINES; i++)
1322 if (IS_CPU_ONLINE(i) && (started_mask & CPU_BIT(i)))
1323 {
1324 sysblk.regs[i]->opinterv = 0;
1325 sysblk.regs[i]->cpustate = CPUSTATE_STARTED;
1326 sysblk.regs[i]->checkstop = 0;
1327 WAKEUP_CPU(sysblk.regs[i]);
1328 }
1329 RELEASE_INTLOCK(NULL);
1330
1331 return 0;
1332
1333 sr_read_error:
1334 logmsg(_("HHCSR011E read error: %s\n"), strerror(errno));
1335 goto sr_error_exit;
1336 /*
1337 sr_seek_error:
1338 logmsg(_("HHCSR012E seek error: %s\n"), strerror(errno));
1339 goto sr_error_exit;
1340 */
1341 sr_string_error:
1342 logmsg(_("HHCSR014E string error, incorrect length\n"));
1343 goto sr_error_exit;
1344 sr_value_error:
1345 logmsg(_("HHCSR001E value error, incorrect length\n"), fn);
1346 goto sr_error_exit;
1347 sr_null_regs_exit:
1348 logmsg(_("HHCSR016E CPU key %8.8x found but no active CPU\n"), key);
1349 goto sr_error_exit;
1350 sr_error_exit:
1351 logmsg(_("HHCSR015E Error processing file %s\n"), fn);
1352 SR_CLOSE (file);
1353 return -1;
1354 }
1355