2 * arch/s390/kernel/ipl.c
3 * ipl/reipl/dump support for Linux on s390.
5 * Copyright (C) IBM Corp. 2005,2006
6 * Author(s): Michael Holzheu <holzheu@de.ibm.com>
7 * Heiko Carstens <heiko.carstens@de.ibm.com>
8 * Volker Sameske <sameske@de.ibm.com>
11 #include <linux/types.h>
12 #include <linux/module.h>
13 #include <linux/device.h>
14 #include <linux/delay.h>
15 #include <linux/reboot.h>
16 #include <linux/ctype.h>
18 #include <asm/setup.h>
19 #include <asm/cpcmd.h>
21 #include <asm/ebcdic.h>
22 #include <asm/reset.h>
24 #define IPL_PARM_BLOCK_VERSION 0
25 #define LOADPARM_LEN 8
27 extern char s390_readinfo_sccb[];
28 #define SCCB_VALID (*((__u16*)&s390_readinfo_sccb[6]) == 0x0010)
29 #define SCCB_LOADPARM (&s390_readinfo_sccb[24])
30 #define SCCB_FLAG (s390_readinfo_sccb[91])
39 #define IPL_NONE_STR "none"
40 #define IPL_UNKNOWN_STR "unknown"
41 #define IPL_CCW_STR "ccw"
42 #define IPL_FCP_STR "fcp"
44 static char *ipl_type_str(enum ipl_type type)
53 case IPL_TYPE_UNKNOWN:
55 return IPL_UNKNOWN_STR;
64 IPL_METHOD_FCP_RO_DIAG,
65 IPL_METHOD_FCP_RW_DIAG,
69 enum shutdown_action {
75 #define SHUTDOWN_REIPL_STR "reipl"
76 #define SHUTDOWN_DUMP_STR "dump"
77 #define SHUTDOWN_STOP_STR "stop"
79 static char *shutdown_action_str(enum shutdown_action action)
83 return SHUTDOWN_REIPL_STR;
85 return SHUTDOWN_DUMP_STR;
87 return SHUTDOWN_STOP_STR;
93 enum diag308_subcode {
100 enum diag308_ipl_type {
101 DIAG308_IPL_TYPE_FCP = 0,
102 DIAG308_IPL_TYPE_CCW = 2,
106 DIAG308_IPL_OPT_IPL = 0x10,
107 DIAG308_IPL_OPT_DUMP = 0x20,
114 static int diag308_set_works = 0;
116 static int reipl_capabilities = IPL_TYPE_UNKNOWN;
117 static enum ipl_type reipl_type = IPL_TYPE_UNKNOWN;
118 static enum ipl_method reipl_method = IPL_METHOD_NONE;
119 static struct ipl_parameter_block *reipl_block_fcp;
120 static struct ipl_parameter_block *reipl_block_ccw;
122 static int dump_capabilities = IPL_TYPE_NONE;
123 static enum ipl_type dump_type = IPL_TYPE_NONE;
124 static enum ipl_method dump_method = IPL_METHOD_NONE;
125 static struct ipl_parameter_block *dump_block_fcp;
126 static struct ipl_parameter_block *dump_block_ccw;
128 static enum shutdown_action on_panic_action = SHUTDOWN_STOP;
130 static int diag308(unsigned long subcode, void *addr)
132 register unsigned long _addr asm("0") = (unsigned long) addr;
133 register unsigned long _rc asm("1") = 0;
136 " diag %0,%2,0x308\n"
139 : "+d" (_addr), "+d" (_rc)
140 : "d" (subcode) : "cc", "memory");
146 #define DEFINE_IPL_ATTR_RO(_prefix, _name, _format, _value) \
147 static ssize_t sys_##_prefix##_##_name##_show(struct subsystem *subsys, \
150 return sprintf(page, _format, _value); \
152 static struct subsys_attribute sys_##_prefix##_##_name##_attr = \
153 __ATTR(_name, S_IRUGO, sys_##_prefix##_##_name##_show, NULL);
155 #define DEFINE_IPL_ATTR_RW(_prefix, _name, _fmt_out, _fmt_in, _value) \
156 static ssize_t sys_##_prefix##_##_name##_show(struct subsystem *subsys, \
159 return sprintf(page, _fmt_out, \
160 (unsigned long long) _value); \
162 static ssize_t sys_##_prefix##_##_name##_store(struct subsystem *subsys,\
163 const char *buf, size_t len) \
165 unsigned long long value; \
166 if (sscanf(buf, _fmt_in, &value) != 1) \
171 static struct subsys_attribute sys_##_prefix##_##_name##_attr = \
172 __ATTR(_name,(S_IRUGO | S_IWUSR), \
173 sys_##_prefix##_##_name##_show, \
174 sys_##_prefix##_##_name##_store);
176 static void make_attrs_ro(struct attribute **attrs)
179 (*attrs)->mode = S_IRUGO;
188 static enum ipl_type ipl_get_type(void)
190 struct ipl_parameter_block *ipl = IPL_PARMBLOCK_START;
192 if (!(ipl_flags & IPL_DEVNO_VALID))
193 return IPL_TYPE_UNKNOWN;
194 if (!(ipl_flags & IPL_PARMBLOCK_VALID))
196 if (ipl->hdr.version > IPL_MAX_SUPPORTED_VERSION)
197 return IPL_TYPE_UNKNOWN;
198 if (ipl->hdr.pbt != DIAG308_IPL_TYPE_FCP)
199 return IPL_TYPE_UNKNOWN;
203 static ssize_t ipl_type_show(struct subsystem *subsys, char *page)
205 return sprintf(page, "%s\n", ipl_type_str(ipl_get_type()));
208 static struct subsys_attribute sys_ipl_type_attr = __ATTR_RO(ipl_type);
210 static ssize_t sys_ipl_device_show(struct subsystem *subsys, char *page)
212 struct ipl_parameter_block *ipl = IPL_PARMBLOCK_START;
214 switch (ipl_get_type()) {
216 return sprintf(page, "0.0.%04x\n", ipl_devno);
218 return sprintf(page, "0.0.%04x\n", ipl->ipl_info.fcp.devno);
224 static struct subsys_attribute sys_ipl_device_attr =
225 __ATTR(device, S_IRUGO, sys_ipl_device_show, NULL);
227 static ssize_t ipl_parameter_read(struct kobject *kobj, char *buf, loff_t off,
230 unsigned int size = IPL_PARMBLOCK_SIZE;
234 if (off + count > size)
236 memcpy(buf, (void *)IPL_PARMBLOCK_START + off, count);
240 static struct bin_attribute ipl_parameter_attr = {
242 .name = "binary_parameter",
244 .owner = THIS_MODULE,
247 .read = &ipl_parameter_read,
250 static ssize_t ipl_scp_data_read(struct kobject *kobj, char *buf, loff_t off,
253 unsigned int size = IPL_PARMBLOCK_START->ipl_info.fcp.scp_data_len;
254 void *scp_data = &IPL_PARMBLOCK_START->ipl_info.fcp.scp_data;
258 if (off + count > size)
260 memcpy(buf, scp_data + off, count);
264 static struct bin_attribute ipl_scp_data_attr = {
268 .owner = THIS_MODULE,
271 .read = &ipl_scp_data_read,
274 /* FCP ipl device attributes */
276 DEFINE_IPL_ATTR_RO(ipl_fcp, wwpn, "0x%016llx\n", (unsigned long long)
277 IPL_PARMBLOCK_START->ipl_info.fcp.wwpn);
278 DEFINE_IPL_ATTR_RO(ipl_fcp, lun, "0x%016llx\n", (unsigned long long)
279 IPL_PARMBLOCK_START->ipl_info.fcp.lun);
280 DEFINE_IPL_ATTR_RO(ipl_fcp, bootprog, "%lld\n", (unsigned long long)
281 IPL_PARMBLOCK_START->ipl_info.fcp.bootprog);
282 DEFINE_IPL_ATTR_RO(ipl_fcp, br_lba, "%lld\n", (unsigned long long)
283 IPL_PARMBLOCK_START->ipl_info.fcp.br_lba);
285 static struct attribute *ipl_fcp_attrs[] = {
286 &sys_ipl_type_attr.attr,
287 &sys_ipl_device_attr.attr,
288 &sys_ipl_fcp_wwpn_attr.attr,
289 &sys_ipl_fcp_lun_attr.attr,
290 &sys_ipl_fcp_bootprog_attr.attr,
291 &sys_ipl_fcp_br_lba_attr.attr,
295 static struct attribute_group ipl_fcp_attr_group = {
296 .attrs = ipl_fcp_attrs,
299 /* CCW ipl device attributes */
301 static ssize_t ipl_ccw_loadparm_show(struct subsystem *subsys, char *page)
303 char loadparm[LOADPARM_LEN + 1] = {};
306 return sprintf(page, "#unknown#\n");
307 memcpy(loadparm, SCCB_LOADPARM, LOADPARM_LEN);
308 EBCASC(loadparm, LOADPARM_LEN);
310 return sprintf(page, "%s\n", loadparm);
313 static struct subsys_attribute sys_ipl_ccw_loadparm_attr =
314 __ATTR(loadparm, 0444, ipl_ccw_loadparm_show, NULL);
316 static struct attribute *ipl_ccw_attrs[] = {
317 &sys_ipl_type_attr.attr,
318 &sys_ipl_device_attr.attr,
319 &sys_ipl_ccw_loadparm_attr.attr,
323 static struct attribute_group ipl_ccw_attr_group = {
324 .attrs = ipl_ccw_attrs,
327 /* UNKNOWN ipl device attributes */
329 static struct attribute *ipl_unknown_attrs[] = {
330 &sys_ipl_type_attr.attr,
334 static struct attribute_group ipl_unknown_attr_group = {
335 .attrs = ipl_unknown_attrs,
338 static decl_subsys(ipl, NULL, NULL);
344 /* FCP reipl device attributes */
346 DEFINE_IPL_ATTR_RW(reipl_fcp, wwpn, "0x%016llx\n", "%016llx\n",
347 reipl_block_fcp->ipl_info.fcp.wwpn);
348 DEFINE_IPL_ATTR_RW(reipl_fcp, lun, "0x%016llx\n", "%016llx\n",
349 reipl_block_fcp->ipl_info.fcp.lun);
350 DEFINE_IPL_ATTR_RW(reipl_fcp, bootprog, "%lld\n", "%lld\n",
351 reipl_block_fcp->ipl_info.fcp.bootprog);
352 DEFINE_IPL_ATTR_RW(reipl_fcp, br_lba, "%lld\n", "%lld\n",
353 reipl_block_fcp->ipl_info.fcp.br_lba);
354 DEFINE_IPL_ATTR_RW(reipl_fcp, device, "0.0.%04llx\n", "0.0.%llx\n",
355 reipl_block_fcp->ipl_info.fcp.devno);
357 static struct attribute *reipl_fcp_attrs[] = {
358 &sys_reipl_fcp_device_attr.attr,
359 &sys_reipl_fcp_wwpn_attr.attr,
360 &sys_reipl_fcp_lun_attr.attr,
361 &sys_reipl_fcp_bootprog_attr.attr,
362 &sys_reipl_fcp_br_lba_attr.attr,
366 static struct attribute_group reipl_fcp_attr_group = {
368 .attrs = reipl_fcp_attrs,
371 /* CCW reipl device attributes */
373 DEFINE_IPL_ATTR_RW(reipl_ccw, device, "0.0.%04llx\n", "0.0.%llx\n",
374 reipl_block_ccw->ipl_info.ccw.devno);
376 static void reipl_get_ascii_loadparm(char *loadparm)
378 memcpy(loadparm, &reipl_block_ccw->ipl_info.ccw.load_param,
380 EBCASC(loadparm, LOADPARM_LEN);
381 loadparm[LOADPARM_LEN] = 0;
385 static ssize_t reipl_ccw_loadparm_show(struct subsystem *subsys, char *page)
387 char buf[LOADPARM_LEN + 1];
389 reipl_get_ascii_loadparm(buf);
390 return sprintf(page, "%s\n", buf);
393 static ssize_t reipl_ccw_loadparm_store(struct subsystem *subsys,
394 const char *buf, size_t len)
398 /* ignore trailing newline */
400 if ((len > 0) && (buf[len - 1] == '\n'))
402 /* loadparm can have max 8 characters and must not start with a blank */
403 if ((lp_len > LOADPARM_LEN) || ((lp_len > 0) && (buf[0] == ' ')))
405 /* loadparm can only contain "a-z,A-Z,0-9,SP,." */
406 for (i = 0; i < lp_len; i++) {
407 if (isalpha(buf[i]) || isdigit(buf[i]) || (buf[i] == ' ') ||
412 /* initialize loadparm with blanks */
413 memset(&reipl_block_ccw->ipl_info.ccw.load_param, ' ', LOADPARM_LEN);
414 /* copy and convert to ebcdic */
415 memcpy(&reipl_block_ccw->ipl_info.ccw.load_param, buf, lp_len);
416 ASCEBC(reipl_block_ccw->ipl_info.ccw.load_param, LOADPARM_LEN);
420 static struct subsys_attribute sys_reipl_ccw_loadparm_attr =
421 __ATTR(loadparm, 0644, reipl_ccw_loadparm_show,
422 reipl_ccw_loadparm_store);
424 static struct attribute *reipl_ccw_attrs[] = {
425 &sys_reipl_ccw_device_attr.attr,
426 &sys_reipl_ccw_loadparm_attr.attr,
430 static struct attribute_group reipl_ccw_attr_group = {
432 .attrs = reipl_ccw_attrs,
437 static int reipl_set_type(enum ipl_type type)
439 if (!(reipl_capabilities & type))
445 reipl_method = IPL_METHOD_CCW_VM;
447 reipl_method = IPL_METHOD_CCW_CIO;
450 if (diag308_set_works)
451 reipl_method = IPL_METHOD_FCP_RW_DIAG;
452 else if (MACHINE_IS_VM)
453 reipl_method = IPL_METHOD_FCP_RO_VM;
455 reipl_method = IPL_METHOD_FCP_RO_DIAG;
458 reipl_method = IPL_METHOD_NONE;
464 static ssize_t reipl_type_show(struct subsystem *subsys, char *page)
466 return sprintf(page, "%s\n", ipl_type_str(reipl_type));
469 static ssize_t reipl_type_store(struct subsystem *subsys, const char *buf,
474 if (strncmp(buf, IPL_CCW_STR, strlen(IPL_CCW_STR)) == 0)
475 rc = reipl_set_type(IPL_TYPE_CCW);
476 else if (strncmp(buf, IPL_FCP_STR, strlen(IPL_FCP_STR)) == 0)
477 rc = reipl_set_type(IPL_TYPE_FCP);
478 return (rc != 0) ? rc : len;
481 static struct subsys_attribute reipl_type_attr =
482 __ATTR(reipl_type, 0644, reipl_type_show, reipl_type_store);
484 static decl_subsys(reipl, NULL, NULL);
490 /* FCP dump device attributes */
492 DEFINE_IPL_ATTR_RW(dump_fcp, wwpn, "0x%016llx\n", "%016llx\n",
493 dump_block_fcp->ipl_info.fcp.wwpn);
494 DEFINE_IPL_ATTR_RW(dump_fcp, lun, "0x%016llx\n", "%016llx\n",
495 dump_block_fcp->ipl_info.fcp.lun);
496 DEFINE_IPL_ATTR_RW(dump_fcp, bootprog, "%lld\n", "%lld\n",
497 dump_block_fcp->ipl_info.fcp.bootprog);
498 DEFINE_IPL_ATTR_RW(dump_fcp, br_lba, "%lld\n", "%lld\n",
499 dump_block_fcp->ipl_info.fcp.br_lba);
500 DEFINE_IPL_ATTR_RW(dump_fcp, device, "0.0.%04llx\n", "0.0.%llx\n",
501 dump_block_fcp->ipl_info.fcp.devno);
503 static struct attribute *dump_fcp_attrs[] = {
504 &sys_dump_fcp_device_attr.attr,
505 &sys_dump_fcp_wwpn_attr.attr,
506 &sys_dump_fcp_lun_attr.attr,
507 &sys_dump_fcp_bootprog_attr.attr,
508 &sys_dump_fcp_br_lba_attr.attr,
512 static struct attribute_group dump_fcp_attr_group = {
514 .attrs = dump_fcp_attrs,
517 /* CCW dump device attributes */
519 DEFINE_IPL_ATTR_RW(dump_ccw, device, "0.0.%04llx\n", "0.0.%llx\n",
520 dump_block_ccw->ipl_info.ccw.devno);
522 static struct attribute *dump_ccw_attrs[] = {
523 &sys_dump_ccw_device_attr.attr,
527 static struct attribute_group dump_ccw_attr_group = {
529 .attrs = dump_ccw_attrs,
534 static int dump_set_type(enum ipl_type type)
536 if (!(dump_capabilities & type))
541 dump_method = IPL_METHOD_CCW_VM;
543 dump_method = IPL_METHOD_CCW_CIO;
546 dump_method = IPL_METHOD_FCP_RW_DIAG;
549 dump_method = IPL_METHOD_NONE;
555 static ssize_t dump_type_show(struct subsystem *subsys, char *page)
557 return sprintf(page, "%s\n", ipl_type_str(dump_type));
560 static ssize_t dump_type_store(struct subsystem *subsys, const char *buf,
565 if (strncmp(buf, IPL_NONE_STR, strlen(IPL_NONE_STR)) == 0)
566 rc = dump_set_type(IPL_TYPE_NONE);
567 else if (strncmp(buf, IPL_CCW_STR, strlen(IPL_CCW_STR)) == 0)
568 rc = dump_set_type(IPL_TYPE_CCW);
569 else if (strncmp(buf, IPL_FCP_STR, strlen(IPL_FCP_STR)) == 0)
570 rc = dump_set_type(IPL_TYPE_FCP);
571 return (rc != 0) ? rc : len;
574 static struct subsys_attribute dump_type_attr =
575 __ATTR(dump_type, 0644, dump_type_show, dump_type_store);
577 static decl_subsys(dump, NULL, NULL);
580 * Shutdown actions section
583 static decl_subsys(shutdown_actions, NULL, NULL);
587 static ssize_t on_panic_show(struct subsystem *subsys, char *page)
589 return sprintf(page, "%s\n", shutdown_action_str(on_panic_action));
592 static ssize_t on_panic_store(struct subsystem *subsys, const char *buf,
595 if (strncmp(buf, SHUTDOWN_REIPL_STR, strlen(SHUTDOWN_REIPL_STR)) == 0)
596 on_panic_action = SHUTDOWN_REIPL;
597 else if (strncmp(buf, SHUTDOWN_DUMP_STR,
598 strlen(SHUTDOWN_DUMP_STR)) == 0)
599 on_panic_action = SHUTDOWN_DUMP;
600 else if (strncmp(buf, SHUTDOWN_STOP_STR,
601 strlen(SHUTDOWN_STOP_STR)) == 0)
602 on_panic_action = SHUTDOWN_STOP;
609 static struct subsys_attribute on_panic_attr =
610 __ATTR(on_panic, 0644, on_panic_show, on_panic_store);
612 static void print_fcp_block(struct ipl_parameter_block *fcp_block)
614 printk(KERN_EMERG "wwpn: %016llx\n",
615 (unsigned long long)fcp_block->ipl_info.fcp.wwpn);
616 printk(KERN_EMERG "lun: %016llx\n",
617 (unsigned long long)fcp_block->ipl_info.fcp.lun);
618 printk(KERN_EMERG "bootprog: %lld\n",
619 (unsigned long long)fcp_block->ipl_info.fcp.bootprog);
620 printk(KERN_EMERG "br_lba: %lld\n",
621 (unsigned long long)fcp_block->ipl_info.fcp.br_lba);
622 printk(KERN_EMERG "device: %llx\n",
623 (unsigned long long)fcp_block->ipl_info.fcp.devno);
624 printk(KERN_EMERG "opt: %x\n", fcp_block->ipl_info.fcp.opt);
629 struct ccw_dev_id devid;
630 static char buf[100];
631 char loadparm[LOADPARM_LEN + 1];
633 switch (reipl_type) {
635 reipl_get_ascii_loadparm(loadparm);
636 printk(KERN_EMERG "reboot on ccw device: 0.0.%04x\n",
637 reipl_block_ccw->ipl_info.ccw.devno);
638 printk(KERN_EMERG "loadparm = '%s'\n", loadparm);
641 printk(KERN_EMERG "reboot on fcp device:\n");
642 print_fcp_block(reipl_block_fcp);
648 switch (reipl_method) {
649 case IPL_METHOD_CCW_CIO:
650 devid.devno = reipl_block_ccw->ipl_info.ccw.devno;
651 if (ipl_get_type() == IPL_TYPE_CCW && devid.devno == ipl_devno)
652 diag308(DIAG308_IPL, NULL);
654 reipl_ccw_dev(&devid);
656 case IPL_METHOD_CCW_VM:
657 if (strlen(loadparm) == 0)
658 sprintf(buf, "IPL %X",
659 reipl_block_ccw->ipl_info.ccw.devno);
661 sprintf(buf, "IPL %X LOADPARM '%s'",
662 reipl_block_ccw->ipl_info.ccw.devno, loadparm);
663 __cpcmd(buf, NULL, 0, NULL);
665 case IPL_METHOD_CCW_DIAG:
666 diag308(DIAG308_SET, reipl_block_ccw);
667 diag308(DIAG308_IPL, NULL);
669 case IPL_METHOD_FCP_RW_DIAG:
670 diag308(DIAG308_SET, reipl_block_fcp);
671 diag308(DIAG308_IPL, NULL);
673 case IPL_METHOD_FCP_RO_DIAG:
674 diag308(DIAG308_IPL, NULL);
676 case IPL_METHOD_FCP_RO_VM:
677 __cpcmd("IPL", NULL, 0, NULL);
679 case IPL_METHOD_NONE:
682 __cpcmd("IPL", NULL, 0, NULL);
683 diag308(DIAG308_IPL, NULL);
686 printk(KERN_EMERG "reboot failed!\n");
687 signal_processor(smp_processor_id(), sigp_stop_and_store_status);
690 static void do_dump(void)
692 struct ccw_dev_id devid;
693 static char buf[100];
697 printk(KERN_EMERG "Automatic dump on ccw device: 0.0.%04x\n",
698 dump_block_ccw->ipl_info.ccw.devno);
701 printk(KERN_EMERG "Automatic dump on fcp device:\n");
702 print_fcp_block(dump_block_fcp);
708 switch (dump_method) {
709 case IPL_METHOD_CCW_CIO:
711 devid.devno = dump_block_ccw->ipl_info.ccw.devno;
713 reipl_ccw_dev(&devid);
715 case IPL_METHOD_CCW_VM:
717 sprintf(buf, "STORE STATUS");
718 __cpcmd(buf, NULL, 0, NULL);
719 sprintf(buf, "IPL %X", dump_block_ccw->ipl_info.ccw.devno);
720 __cpcmd(buf, NULL, 0, NULL);
722 case IPL_METHOD_CCW_DIAG:
723 diag308(DIAG308_SET, dump_block_ccw);
724 diag308(DIAG308_DUMP, NULL);
726 case IPL_METHOD_FCP_RW_DIAG:
727 diag308(DIAG308_SET, dump_block_fcp);
728 diag308(DIAG308_DUMP, NULL);
730 case IPL_METHOD_NONE:
734 printk(KERN_EMERG "Dump failed!\n");
739 static int __init ipl_register_fcp_files(void)
743 rc = sysfs_create_group(&ipl_subsys.kset.kobj,
744 &ipl_fcp_attr_group);
747 rc = sysfs_create_bin_file(&ipl_subsys.kset.kobj,
748 &ipl_parameter_attr);
751 rc = sysfs_create_bin_file(&ipl_subsys.kset.kobj,
756 sysfs_remove_bin_file(&ipl_subsys.kset.kobj, &ipl_parameter_attr);
759 sysfs_remove_group(&ipl_subsys.kset.kobj, &ipl_fcp_attr_group);
764 static int __init ipl_init(void)
768 rc = firmware_register(&ipl_subsys);
771 switch (ipl_get_type()) {
773 rc = sysfs_create_group(&ipl_subsys.kset.kobj,
774 &ipl_ccw_attr_group);
777 rc = ipl_register_fcp_files();
780 rc = sysfs_create_group(&ipl_subsys.kset.kobj,
781 &ipl_unknown_attr_group);
785 firmware_unregister(&ipl_subsys);
789 static void __init reipl_probe(void)
793 buffer = (void *) get_zeroed_page(GFP_KERNEL);
796 if (diag308(DIAG308_STORE, buffer) == DIAG308_RC_OK)
797 diag308_set_works = 1;
798 free_page((unsigned long)buffer);
801 static int __init reipl_ccw_init(void)
805 reipl_block_ccw = (void *) get_zeroed_page(GFP_KERNEL);
806 if (!reipl_block_ccw)
808 rc = sysfs_create_group(&reipl_subsys.kset.kobj, &reipl_ccw_attr_group);
810 free_page((unsigned long)reipl_block_ccw);
813 reipl_block_ccw->hdr.len = IPL_PARM_BLK_CCW_LEN;
814 reipl_block_ccw->hdr.version = IPL_PARM_BLOCK_VERSION;
815 reipl_block_ccw->hdr.blk0_len = sizeof(reipl_block_ccw->ipl_info.ccw);
816 reipl_block_ccw->hdr.pbt = DIAG308_IPL_TYPE_CCW;
817 /* check if read scp info worked and set loadparm */
819 memcpy(reipl_block_ccw->ipl_info.ccw.load_param,
820 SCCB_LOADPARM, LOADPARM_LEN);
822 /* read scp info failed: set empty loadparm (EBCDIC blanks) */
823 memset(reipl_block_ccw->ipl_info.ccw.load_param, 0x40,
825 /* FIXME: check for diag308_set_works when enabling diag ccw reipl */
827 sys_reipl_ccw_loadparm_attr.attr.mode = S_IRUGO;
828 if (ipl_get_type() == IPL_TYPE_CCW)
829 reipl_block_ccw->ipl_info.ccw.devno = ipl_devno;
830 reipl_capabilities |= IPL_TYPE_CCW;
834 static int __init reipl_fcp_init(void)
838 if ((!diag308_set_works) && (ipl_get_type() != IPL_TYPE_FCP))
840 if ((!diag308_set_works) && (ipl_get_type() == IPL_TYPE_FCP))
841 make_attrs_ro(reipl_fcp_attrs);
843 reipl_block_fcp = (void *) get_zeroed_page(GFP_KERNEL);
844 if (!reipl_block_fcp)
846 rc = sysfs_create_group(&reipl_subsys.kset.kobj, &reipl_fcp_attr_group);
848 free_page((unsigned long)reipl_block_fcp);
851 if (ipl_get_type() == IPL_TYPE_FCP) {
852 memcpy(reipl_block_fcp, IPL_PARMBLOCK_START, PAGE_SIZE);
854 reipl_block_fcp->hdr.len = IPL_PARM_BLK_FCP_LEN;
855 reipl_block_fcp->hdr.version = IPL_PARM_BLOCK_VERSION;
856 reipl_block_fcp->hdr.blk0_len =
857 sizeof(reipl_block_fcp->ipl_info.fcp);
858 reipl_block_fcp->hdr.pbt = DIAG308_IPL_TYPE_FCP;
859 reipl_block_fcp->ipl_info.fcp.opt = DIAG308_IPL_OPT_IPL;
861 reipl_capabilities |= IPL_TYPE_FCP;
865 static int __init reipl_init(void)
869 rc = firmware_register(&reipl_subsys);
872 rc = subsys_create_file(&reipl_subsys, &reipl_type_attr);
874 firmware_unregister(&reipl_subsys);
877 rc = reipl_ccw_init();
880 rc = reipl_fcp_init();
883 rc = reipl_set_type(ipl_get_type());
889 static int __init dump_ccw_init(void)
893 dump_block_ccw = (void *) get_zeroed_page(GFP_KERNEL);
896 rc = sysfs_create_group(&dump_subsys.kset.kobj, &dump_ccw_attr_group);
898 free_page((unsigned long)dump_block_ccw);
901 dump_block_ccw->hdr.len = IPL_PARM_BLK_CCW_LEN;
902 dump_block_ccw->hdr.version = IPL_PARM_BLOCK_VERSION;
903 dump_block_ccw->hdr.blk0_len = sizeof(reipl_block_ccw->ipl_info.ccw);
904 dump_block_ccw->hdr.pbt = DIAG308_IPL_TYPE_CCW;
905 dump_capabilities |= IPL_TYPE_CCW;
909 static int __init dump_fcp_init(void)
913 if(!(SCCB_FLAG & 0x2) || !SCCB_VALID)
914 return 0; /* LDIPL DUMP is not installed */
915 if (!diag308_set_works)
917 dump_block_fcp = (void *) get_zeroed_page(GFP_KERNEL);
920 rc = sysfs_create_group(&dump_subsys.kset.kobj, &dump_fcp_attr_group);
922 free_page((unsigned long)dump_block_fcp);
925 dump_block_fcp->hdr.len = IPL_PARM_BLK_FCP_LEN;
926 dump_block_fcp->hdr.version = IPL_PARM_BLOCK_VERSION;
927 dump_block_fcp->hdr.blk0_len = sizeof(dump_block_fcp->ipl_info.fcp);
928 dump_block_fcp->hdr.pbt = DIAG308_IPL_TYPE_FCP;
929 dump_block_fcp->ipl_info.fcp.opt = DIAG308_IPL_OPT_DUMP;
930 dump_capabilities |= IPL_TYPE_FCP;
934 #define SHUTDOWN_ON_PANIC_PRIO 0
936 static int shutdown_on_panic_notify(struct notifier_block *self,
937 unsigned long event, void *data)
939 if (on_panic_action == SHUTDOWN_DUMP)
941 else if (on_panic_action == SHUTDOWN_REIPL)
946 static struct notifier_block shutdown_on_panic_nb = {
947 .notifier_call = shutdown_on_panic_notify,
948 .priority = SHUTDOWN_ON_PANIC_PRIO
951 static int __init dump_init(void)
955 rc = firmware_register(&dump_subsys);
958 rc = subsys_create_file(&dump_subsys, &dump_type_attr);
960 firmware_unregister(&dump_subsys);
963 rc = dump_ccw_init();
966 rc = dump_fcp_init();
969 dump_set_type(IPL_TYPE_NONE);
973 static int __init shutdown_actions_init(void)
977 rc = firmware_register(&shutdown_actions_subsys);
980 rc = subsys_create_file(&shutdown_actions_subsys, &on_panic_attr);
982 firmware_unregister(&shutdown_actions_subsys);
985 atomic_notifier_chain_register(&panic_notifier_list,
986 &shutdown_on_panic_nb);
990 static int __init s390_ipl_init(void)
1004 rc = shutdown_actions_init();
1010 __initcall(s390_ipl_init);
1012 static LIST_HEAD(rcall);
1013 static DEFINE_MUTEX(rcall_mutex);
1015 void register_reset_call(struct reset_call *reset)
1017 mutex_lock(&rcall_mutex);
1018 list_add(&reset->list, &rcall);
1019 mutex_unlock(&rcall_mutex);
1021 EXPORT_SYMBOL_GPL(register_reset_call);
1023 void unregister_reset_call(struct reset_call *reset)
1025 mutex_lock(&rcall_mutex);
1026 list_del(&reset->list);
1027 mutex_unlock(&rcall_mutex);
1029 EXPORT_SYMBOL_GPL(unregister_reset_call);
1031 static void do_reset_calls(void)
1033 struct reset_call *reset;
1035 list_for_each_entry(reset, &rcall, list)
1039 extern void reset_mcck_handler(void);
1041 void s390_reset_system(void)
1043 struct _lowcore *lc;
1045 /* Stack for interrupt/machine check handler */
1046 lc = (struct _lowcore *)(unsigned long) store_prefix();
1047 lc->panic_stack = S390_lowcore.panic_stack;
1049 /* Disable prefixing */
1052 /* Disable lowcore protection */
1053 __ctl_clear_bit(0,28);
1055 /* Set new machine check handler */
1056 S390_lowcore.mcck_new_psw.mask = PSW_KERNEL_BITS & ~PSW_MASK_MCHECK;
1057 S390_lowcore.mcck_new_psw.addr =
1058 PSW_ADDR_AMODE | (unsigned long) &reset_mcck_handler;