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>
19 #include <asm/setup.h>
20 #include <asm/cpcmd.h>
22 #include <asm/ebcdic.h>
23 #include <asm/reset.h>
26 #define IPL_PARM_BLOCK_VERSION 0
28 #define SCCB_VALID (s390_readinfo_sccb.header.response_code == 0x10)
29 #define SCCB_LOADPARM (&s390_readinfo_sccb.loadparm)
30 #define SCCB_FLAG (s390_readinfo_sccb.flags)
32 #define IPL_UNKNOWN_STR "unknown"
33 #define IPL_CCW_STR "ccw"
34 #define IPL_FCP_STR "fcp"
35 #define IPL_FCP_DUMP_STR "fcp_dump"
36 #define IPL_NSS_STR "nss"
38 static char *ipl_type_str(enum ipl_type type)
45 case IPL_TYPE_FCP_DUMP:
46 return IPL_FCP_DUMP_STR;
49 case IPL_TYPE_UNKNOWN:
51 return IPL_UNKNOWN_STR;
61 #define DUMP_NONE_STR "none"
62 #define DUMP_CCW_STR "ccw"
63 #define DUMP_FCP_STR "fcp"
65 static char *dump_type_str(enum dump_type type)
80 * Must be in data section since the bss section
81 * is not cleared when these are accessed.
83 static u16 ipl_devno __attribute__((__section__(".data"))) = 0;
84 u32 ipl_flags __attribute__((__section__(".data"))) = 0;
88 REIPL_METHOD_CCW_DIAG,
90 REIPL_METHOD_FCP_RO_DIAG,
91 REIPL_METHOD_FCP_RW_DIAG,
92 REIPL_METHOD_FCP_RO_VM,
93 REIPL_METHOD_FCP_DUMP,
101 DUMP_METHOD_CCW_DIAG,
103 DUMP_METHOD_FCP_DIAG,
106 enum shutdown_action {
112 #define SHUTDOWN_REIPL_STR "reipl"
113 #define SHUTDOWN_DUMP_STR "dump"
114 #define SHUTDOWN_STOP_STR "stop"
116 static char *shutdown_action_str(enum shutdown_action action)
120 return SHUTDOWN_REIPL_STR;
122 return SHUTDOWN_DUMP_STR;
124 return SHUTDOWN_STOP_STR;
130 static int diag308_set_works = 0;
132 static int reipl_capabilities = IPL_TYPE_UNKNOWN;
134 static enum ipl_type reipl_type = IPL_TYPE_UNKNOWN;
135 static enum ipl_method reipl_method = REIPL_METHOD_DEFAULT;
136 static struct ipl_parameter_block *reipl_block_fcp;
137 static struct ipl_parameter_block *reipl_block_ccw;
139 static char reipl_nss_name[NSS_NAME_SIZE + 1];
141 static int dump_capabilities = DUMP_TYPE_NONE;
142 static enum dump_type dump_type = DUMP_TYPE_NONE;
143 static enum dump_method dump_method = DUMP_METHOD_NONE;
144 static struct ipl_parameter_block *dump_block_fcp;
145 static struct ipl_parameter_block *dump_block_ccw;
147 static enum shutdown_action on_panic_action = SHUTDOWN_STOP;
149 int diag308(unsigned long subcode, void *addr)
151 register unsigned long _addr asm("0") = (unsigned long) addr;
152 register unsigned long _rc asm("1") = 0;
155 " diag %0,%2,0x308\n"
158 : "+d" (_addr), "+d" (_rc)
159 : "d" (subcode) : "cc", "memory");
162 EXPORT_SYMBOL_GPL(diag308);
166 #define DEFINE_IPL_ATTR_RO(_prefix, _name, _format, _value) \
167 static ssize_t sys_##_prefix##_##_name##_show(struct kset *kset, \
170 return sprintf(page, _format, _value); \
172 static struct subsys_attribute sys_##_prefix##_##_name##_attr = \
173 __ATTR(_name, S_IRUGO, sys_##_prefix##_##_name##_show, NULL);
175 #define DEFINE_IPL_ATTR_RW(_prefix, _name, _fmt_out, _fmt_in, _value) \
176 static ssize_t sys_##_prefix##_##_name##_show(struct kset *kset, \
179 return sprintf(page, _fmt_out, \
180 (unsigned long long) _value); \
182 static ssize_t sys_##_prefix##_##_name##_store(struct kset *kset, \
183 const char *buf, size_t len) \
185 unsigned long long value; \
186 if (sscanf(buf, _fmt_in, &value) != 1) \
191 static struct subsys_attribute sys_##_prefix##_##_name##_attr = \
192 __ATTR(_name,(S_IRUGO | S_IWUSR), \
193 sys_##_prefix##_##_name##_show, \
194 sys_##_prefix##_##_name##_store);
196 #define DEFINE_IPL_ATTR_STR_RW(_prefix, _name, _fmt_out, _fmt_in, _value)\
197 static ssize_t sys_##_prefix##_##_name##_show(struct kset *kset, \
200 return sprintf(page, _fmt_out, _value); \
202 static ssize_t sys_##_prefix##_##_name##_store(struct kset *kset, \
203 const char *buf, size_t len) \
205 if (sscanf(buf, _fmt_in, _value) != 1) \
209 static struct subsys_attribute sys_##_prefix##_##_name##_attr = \
210 __ATTR(_name,(S_IRUGO | S_IWUSR), \
211 sys_##_prefix##_##_name##_show, \
212 sys_##_prefix##_##_name##_store);
214 static void make_attrs_ro(struct attribute **attrs)
217 (*attrs)->mode = S_IRUGO;
226 static __init enum ipl_type get_ipl_type(void)
228 struct ipl_parameter_block *ipl = IPL_PARMBLOCK_START;
230 if (ipl_flags & IPL_NSS_VALID)
232 if (!(ipl_flags & IPL_DEVNO_VALID))
233 return IPL_TYPE_UNKNOWN;
234 if (!(ipl_flags & IPL_PARMBLOCK_VALID))
236 if (ipl->hdr.version > IPL_MAX_SUPPORTED_VERSION)
237 return IPL_TYPE_UNKNOWN;
238 if (ipl->hdr.pbt != DIAG308_IPL_TYPE_FCP)
239 return IPL_TYPE_UNKNOWN;
240 if (ipl->ipl_info.fcp.opt == DIAG308_IPL_OPT_DUMP)
241 return IPL_TYPE_FCP_DUMP;
245 void __init setup_ipl_info(void)
247 ipl_info.type = get_ipl_type();
248 switch (ipl_info.type) {
250 ipl_info.data.ccw.dev_id.devno = ipl_devno;
251 ipl_info.data.ccw.dev_id.ssid = 0;
254 case IPL_TYPE_FCP_DUMP:
255 ipl_info.data.fcp.dev_id.devno =
256 IPL_PARMBLOCK_START->ipl_info.fcp.devno;
257 ipl_info.data.fcp.dev_id.ssid = 0;
258 ipl_info.data.fcp.wwpn = IPL_PARMBLOCK_START->ipl_info.fcp.wwpn;
259 ipl_info.data.fcp.lun = IPL_PARMBLOCK_START->ipl_info.fcp.lun;
262 strncpy(ipl_info.data.nss.name, kernel_nss_name,
263 sizeof(ipl_info.data.nss.name));
265 case IPL_TYPE_UNKNOWN:
267 /* We have no info to copy */
272 struct ipl_info ipl_info;
273 EXPORT_SYMBOL_GPL(ipl_info);
275 static ssize_t ipl_type_show(struct kset *kset, char *page)
277 return sprintf(page, "%s\n", ipl_type_str(ipl_info.type));
280 static struct subsys_attribute sys_ipl_type_attr = __ATTR_RO(ipl_type);
282 static ssize_t sys_ipl_device_show(struct kset *kset, char *page)
284 struct ipl_parameter_block *ipl = IPL_PARMBLOCK_START;
286 switch (ipl_info.type) {
288 return sprintf(page, "0.0.%04x\n", ipl_devno);
290 case IPL_TYPE_FCP_DUMP:
291 return sprintf(page, "0.0.%04x\n", ipl->ipl_info.fcp.devno);
297 static struct subsys_attribute sys_ipl_device_attr =
298 __ATTR(device, S_IRUGO, sys_ipl_device_show, NULL);
300 static ssize_t ipl_parameter_read(struct kobject *kobj, char *buf, loff_t off,
303 unsigned int size = IPL_PARMBLOCK_SIZE;
307 if (off + count > size)
309 memcpy(buf, (void *)IPL_PARMBLOCK_START + off, count);
313 static struct bin_attribute ipl_parameter_attr = {
315 .name = "binary_parameter",
317 .owner = THIS_MODULE,
320 .read = &ipl_parameter_read,
323 static ssize_t ipl_scp_data_read(struct kobject *kobj, char *buf, loff_t off,
326 unsigned int size = IPL_PARMBLOCK_START->ipl_info.fcp.scp_data_len;
327 void *scp_data = &IPL_PARMBLOCK_START->ipl_info.fcp.scp_data;
331 if (off + count > size)
333 memcpy(buf, scp_data + off, count);
337 static struct bin_attribute ipl_scp_data_attr = {
341 .owner = THIS_MODULE,
344 .read = &ipl_scp_data_read,
347 /* FCP ipl device attributes */
349 DEFINE_IPL_ATTR_RO(ipl_fcp, wwpn, "0x%016llx\n", (unsigned long long)
350 IPL_PARMBLOCK_START->ipl_info.fcp.wwpn);
351 DEFINE_IPL_ATTR_RO(ipl_fcp, lun, "0x%016llx\n", (unsigned long long)
352 IPL_PARMBLOCK_START->ipl_info.fcp.lun);
353 DEFINE_IPL_ATTR_RO(ipl_fcp, bootprog, "%lld\n", (unsigned long long)
354 IPL_PARMBLOCK_START->ipl_info.fcp.bootprog);
355 DEFINE_IPL_ATTR_RO(ipl_fcp, br_lba, "%lld\n", (unsigned long long)
356 IPL_PARMBLOCK_START->ipl_info.fcp.br_lba);
358 static struct attribute *ipl_fcp_attrs[] = {
359 &sys_ipl_type_attr.attr,
360 &sys_ipl_device_attr.attr,
361 &sys_ipl_fcp_wwpn_attr.attr,
362 &sys_ipl_fcp_lun_attr.attr,
363 &sys_ipl_fcp_bootprog_attr.attr,
364 &sys_ipl_fcp_br_lba_attr.attr,
368 static struct attribute_group ipl_fcp_attr_group = {
369 .attrs = ipl_fcp_attrs,
372 /* CCW ipl device attributes */
374 static ssize_t ipl_ccw_loadparm_show(struct kset *kset, char *page)
376 char loadparm[LOADPARM_LEN + 1] = {};
379 return sprintf(page, "#unknown#\n");
380 memcpy(loadparm, SCCB_LOADPARM, LOADPARM_LEN);
381 EBCASC(loadparm, LOADPARM_LEN);
383 return sprintf(page, "%s\n", loadparm);
386 static struct subsys_attribute sys_ipl_ccw_loadparm_attr =
387 __ATTR(loadparm, 0444, ipl_ccw_loadparm_show, NULL);
389 static struct attribute *ipl_ccw_attrs[] = {
390 &sys_ipl_type_attr.attr,
391 &sys_ipl_device_attr.attr,
392 &sys_ipl_ccw_loadparm_attr.attr,
396 static struct attribute_group ipl_ccw_attr_group = {
397 .attrs = ipl_ccw_attrs,
400 /* NSS ipl device attributes */
402 DEFINE_IPL_ATTR_RO(ipl_nss, name, "%s\n", kernel_nss_name);
404 static struct attribute *ipl_nss_attrs[] = {
405 &sys_ipl_type_attr.attr,
406 &sys_ipl_nss_name_attr.attr,
410 static struct attribute_group ipl_nss_attr_group = {
411 .attrs = ipl_nss_attrs,
414 /* UNKNOWN ipl device attributes */
416 static struct attribute *ipl_unknown_attrs[] = {
417 &sys_ipl_type_attr.attr,
421 static struct attribute_group ipl_unknown_attr_group = {
422 .attrs = ipl_unknown_attrs,
425 static decl_subsys(ipl, NULL, NULL);
431 /* FCP reipl device attributes */
433 DEFINE_IPL_ATTR_RW(reipl_fcp, wwpn, "0x%016llx\n", "%016llx\n",
434 reipl_block_fcp->ipl_info.fcp.wwpn);
435 DEFINE_IPL_ATTR_RW(reipl_fcp, lun, "0x%016llx\n", "%016llx\n",
436 reipl_block_fcp->ipl_info.fcp.lun);
437 DEFINE_IPL_ATTR_RW(reipl_fcp, bootprog, "%lld\n", "%lld\n",
438 reipl_block_fcp->ipl_info.fcp.bootprog);
439 DEFINE_IPL_ATTR_RW(reipl_fcp, br_lba, "%lld\n", "%lld\n",
440 reipl_block_fcp->ipl_info.fcp.br_lba);
441 DEFINE_IPL_ATTR_RW(reipl_fcp, device, "0.0.%04llx\n", "0.0.%llx\n",
442 reipl_block_fcp->ipl_info.fcp.devno);
444 static struct attribute *reipl_fcp_attrs[] = {
445 &sys_reipl_fcp_device_attr.attr,
446 &sys_reipl_fcp_wwpn_attr.attr,
447 &sys_reipl_fcp_lun_attr.attr,
448 &sys_reipl_fcp_bootprog_attr.attr,
449 &sys_reipl_fcp_br_lba_attr.attr,
453 static struct attribute_group reipl_fcp_attr_group = {
455 .attrs = reipl_fcp_attrs,
458 /* CCW reipl device attributes */
460 DEFINE_IPL_ATTR_RW(reipl_ccw, device, "0.0.%04llx\n", "0.0.%llx\n",
461 reipl_block_ccw->ipl_info.ccw.devno);
463 static void reipl_get_ascii_loadparm(char *loadparm)
465 memcpy(loadparm, &reipl_block_ccw->ipl_info.ccw.load_param,
467 EBCASC(loadparm, LOADPARM_LEN);
468 loadparm[LOADPARM_LEN] = 0;
472 static ssize_t reipl_ccw_loadparm_show(struct kset *kset, char *page)
474 char buf[LOADPARM_LEN + 1];
476 reipl_get_ascii_loadparm(buf);
477 return sprintf(page, "%s\n", buf);
480 static ssize_t reipl_ccw_loadparm_store(struct kset *kset,
481 const char *buf, size_t len)
485 /* ignore trailing newline */
487 if ((len > 0) && (buf[len - 1] == '\n'))
489 /* loadparm can have max 8 characters and must not start with a blank */
490 if ((lp_len > LOADPARM_LEN) || ((lp_len > 0) && (buf[0] == ' ')))
492 /* loadparm can only contain "a-z,A-Z,0-9,SP,." */
493 for (i = 0; i < lp_len; i++) {
494 if (isalpha(buf[i]) || isdigit(buf[i]) || (buf[i] == ' ') ||
499 /* initialize loadparm with blanks */
500 memset(&reipl_block_ccw->ipl_info.ccw.load_param, ' ', LOADPARM_LEN);
501 /* copy and convert to ebcdic */
502 memcpy(&reipl_block_ccw->ipl_info.ccw.load_param, buf, lp_len);
503 ASCEBC(reipl_block_ccw->ipl_info.ccw.load_param, LOADPARM_LEN);
507 static struct subsys_attribute sys_reipl_ccw_loadparm_attr =
508 __ATTR(loadparm, 0644, reipl_ccw_loadparm_show,
509 reipl_ccw_loadparm_store);
511 static struct attribute *reipl_ccw_attrs[] = {
512 &sys_reipl_ccw_device_attr.attr,
513 &sys_reipl_ccw_loadparm_attr.attr,
517 static struct attribute_group reipl_ccw_attr_group = {
519 .attrs = reipl_ccw_attrs,
523 /* NSS reipl device attributes */
525 DEFINE_IPL_ATTR_STR_RW(reipl_nss, name, "%s\n", "%s\n", reipl_nss_name);
527 static struct attribute *reipl_nss_attrs[] = {
528 &sys_reipl_nss_name_attr.attr,
532 static struct attribute_group reipl_nss_attr_group = {
534 .attrs = reipl_nss_attrs,
539 static int reipl_set_type(enum ipl_type type)
541 if (!(reipl_capabilities & type))
547 reipl_method = REIPL_METHOD_CCW_VM;
549 reipl_method = REIPL_METHOD_CCW_CIO;
552 if (diag308_set_works)
553 reipl_method = REIPL_METHOD_FCP_RW_DIAG;
554 else if (MACHINE_IS_VM)
555 reipl_method = REIPL_METHOD_FCP_RO_VM;
557 reipl_method = REIPL_METHOD_FCP_RO_DIAG;
559 case IPL_TYPE_FCP_DUMP:
560 reipl_method = REIPL_METHOD_FCP_DUMP;
563 reipl_method = REIPL_METHOD_NSS;
565 case IPL_TYPE_UNKNOWN:
566 reipl_method = REIPL_METHOD_DEFAULT;
575 static ssize_t reipl_type_show(struct kset *kset, char *page)
577 return sprintf(page, "%s\n", ipl_type_str(reipl_type));
580 static ssize_t reipl_type_store(struct kset *kset, const char *buf,
585 if (strncmp(buf, IPL_CCW_STR, strlen(IPL_CCW_STR)) == 0)
586 rc = reipl_set_type(IPL_TYPE_CCW);
587 else if (strncmp(buf, IPL_FCP_STR, strlen(IPL_FCP_STR)) == 0)
588 rc = reipl_set_type(IPL_TYPE_FCP);
589 else if (strncmp(buf, IPL_NSS_STR, strlen(IPL_NSS_STR)) == 0)
590 rc = reipl_set_type(IPL_TYPE_NSS);
591 return (rc != 0) ? rc : len;
594 static struct subsys_attribute reipl_type_attr =
595 __ATTR(reipl_type, 0644, reipl_type_show, reipl_type_store);
597 static decl_subsys(reipl, NULL, NULL);
603 /* FCP dump device attributes */
605 DEFINE_IPL_ATTR_RW(dump_fcp, wwpn, "0x%016llx\n", "%016llx\n",
606 dump_block_fcp->ipl_info.fcp.wwpn);
607 DEFINE_IPL_ATTR_RW(dump_fcp, lun, "0x%016llx\n", "%016llx\n",
608 dump_block_fcp->ipl_info.fcp.lun);
609 DEFINE_IPL_ATTR_RW(dump_fcp, bootprog, "%lld\n", "%lld\n",
610 dump_block_fcp->ipl_info.fcp.bootprog);
611 DEFINE_IPL_ATTR_RW(dump_fcp, br_lba, "%lld\n", "%lld\n",
612 dump_block_fcp->ipl_info.fcp.br_lba);
613 DEFINE_IPL_ATTR_RW(dump_fcp, device, "0.0.%04llx\n", "0.0.%llx\n",
614 dump_block_fcp->ipl_info.fcp.devno);
616 static struct attribute *dump_fcp_attrs[] = {
617 &sys_dump_fcp_device_attr.attr,
618 &sys_dump_fcp_wwpn_attr.attr,
619 &sys_dump_fcp_lun_attr.attr,
620 &sys_dump_fcp_bootprog_attr.attr,
621 &sys_dump_fcp_br_lba_attr.attr,
625 static struct attribute_group dump_fcp_attr_group = {
627 .attrs = dump_fcp_attrs,
630 /* CCW dump device attributes */
632 DEFINE_IPL_ATTR_RW(dump_ccw, device, "0.0.%04llx\n", "0.0.%llx\n",
633 dump_block_ccw->ipl_info.ccw.devno);
635 static struct attribute *dump_ccw_attrs[] = {
636 &sys_dump_ccw_device_attr.attr,
640 static struct attribute_group dump_ccw_attr_group = {
642 .attrs = dump_ccw_attrs,
647 static int dump_set_type(enum dump_type type)
649 if (!(dump_capabilities & type))
654 dump_method = DUMP_METHOD_CCW_VM;
656 dump_method = DUMP_METHOD_CCW_CIO;
659 dump_method = DUMP_METHOD_FCP_DIAG;
662 dump_method = DUMP_METHOD_NONE;
668 static ssize_t dump_type_show(struct kset *kset, char *page)
670 return sprintf(page, "%s\n", dump_type_str(dump_type));
673 static ssize_t dump_type_store(struct kset *kset, const char *buf,
678 if (strncmp(buf, DUMP_NONE_STR, strlen(DUMP_NONE_STR)) == 0)
679 rc = dump_set_type(DUMP_TYPE_NONE);
680 else if (strncmp(buf, DUMP_CCW_STR, strlen(DUMP_CCW_STR)) == 0)
681 rc = dump_set_type(DUMP_TYPE_CCW);
682 else if (strncmp(buf, DUMP_FCP_STR, strlen(DUMP_FCP_STR)) == 0)
683 rc = dump_set_type(DUMP_TYPE_FCP);
684 return (rc != 0) ? rc : len;
687 static struct subsys_attribute dump_type_attr =
688 __ATTR(dump_type, 0644, dump_type_show, dump_type_store);
690 static decl_subsys(dump, NULL, NULL);
693 * Shutdown actions section
696 static decl_subsys(shutdown_actions, NULL, NULL);
700 static ssize_t on_panic_show(struct kset *kset, char *page)
702 return sprintf(page, "%s\n", shutdown_action_str(on_panic_action));
705 static ssize_t on_panic_store(struct kset *kset, const char *buf,
708 if (strncmp(buf, SHUTDOWN_REIPL_STR, strlen(SHUTDOWN_REIPL_STR)) == 0)
709 on_panic_action = SHUTDOWN_REIPL;
710 else if (strncmp(buf, SHUTDOWN_DUMP_STR,
711 strlen(SHUTDOWN_DUMP_STR)) == 0)
712 on_panic_action = SHUTDOWN_DUMP;
713 else if (strncmp(buf, SHUTDOWN_STOP_STR,
714 strlen(SHUTDOWN_STOP_STR)) == 0)
715 on_panic_action = SHUTDOWN_STOP;
722 static struct subsys_attribute on_panic_attr =
723 __ATTR(on_panic, 0644, on_panic_show, on_panic_store);
727 struct ccw_dev_id devid;
728 static char buf[100];
729 char loadparm[LOADPARM_LEN + 1];
731 switch (reipl_method) {
732 case REIPL_METHOD_CCW_CIO:
733 devid.devno = reipl_block_ccw->ipl_info.ccw.devno;
734 if (ipl_info.type == IPL_TYPE_CCW && devid.devno == ipl_devno)
735 diag308(DIAG308_IPL, NULL);
737 reipl_ccw_dev(&devid);
739 case REIPL_METHOD_CCW_VM:
740 reipl_get_ascii_loadparm(loadparm);
741 if (strlen(loadparm) == 0)
742 sprintf(buf, "IPL %X",
743 reipl_block_ccw->ipl_info.ccw.devno);
745 sprintf(buf, "IPL %X LOADPARM '%s'",
746 reipl_block_ccw->ipl_info.ccw.devno, loadparm);
747 __cpcmd(buf, NULL, 0, NULL);
749 case REIPL_METHOD_CCW_DIAG:
750 diag308(DIAG308_SET, reipl_block_ccw);
751 diag308(DIAG308_IPL, NULL);
753 case REIPL_METHOD_FCP_RW_DIAG:
754 diag308(DIAG308_SET, reipl_block_fcp);
755 diag308(DIAG308_IPL, NULL);
757 case REIPL_METHOD_FCP_RO_DIAG:
758 diag308(DIAG308_IPL, NULL);
760 case REIPL_METHOD_FCP_RO_VM:
761 __cpcmd("IPL", NULL, 0, NULL);
763 case REIPL_METHOD_NSS:
764 sprintf(buf, "IPL %s", reipl_nss_name);
765 __cpcmd(buf, NULL, 0, NULL);
767 case REIPL_METHOD_DEFAULT:
769 __cpcmd("IPL", NULL, 0, NULL);
770 diag308(DIAG308_IPL, NULL);
772 case REIPL_METHOD_FCP_DUMP:
776 signal_processor(smp_processor_id(), sigp_stop_and_store_status);
779 static void do_dump(void)
781 struct ccw_dev_id devid;
782 static char buf[100];
784 switch (dump_method) {
785 case DUMP_METHOD_CCW_CIO:
787 devid.devno = dump_block_ccw->ipl_info.ccw.devno;
789 reipl_ccw_dev(&devid);
791 case DUMP_METHOD_CCW_VM:
793 sprintf(buf, "STORE STATUS");
794 __cpcmd(buf, NULL, 0, NULL);
795 sprintf(buf, "IPL %X", dump_block_ccw->ipl_info.ccw.devno);
796 __cpcmd(buf, NULL, 0, NULL);
798 case DUMP_METHOD_CCW_DIAG:
799 diag308(DIAG308_SET, dump_block_ccw);
800 diag308(DIAG308_DUMP, NULL);
802 case DUMP_METHOD_FCP_DIAG:
803 diag308(DIAG308_SET, dump_block_fcp);
804 diag308(DIAG308_DUMP, NULL);
806 case DUMP_METHOD_NONE:
810 printk(KERN_EMERG "Dump failed!\n");
815 static int __init ipl_register_fcp_files(void)
819 rc = sysfs_create_group(&ipl_subsys.kset.kobj,
820 &ipl_fcp_attr_group);
823 rc = sysfs_create_bin_file(&ipl_subsys.kset.kobj,
824 &ipl_parameter_attr);
827 rc = sysfs_create_bin_file(&ipl_subsys.kset.kobj,
832 sysfs_remove_bin_file(&ipl_subsys.kset.kobj, &ipl_parameter_attr);
835 sysfs_remove_group(&ipl_subsys.kset.kobj, &ipl_fcp_attr_group);
840 static int __init ipl_init(void)
844 rc = firmware_register(&ipl_subsys);
847 switch (ipl_info.type) {
849 rc = sysfs_create_group(&ipl_subsys.kset.kobj,
850 &ipl_ccw_attr_group);
853 case IPL_TYPE_FCP_DUMP:
854 rc = ipl_register_fcp_files();
857 rc = sysfs_create_group(&ipl_subsys.kset.kobj,
858 &ipl_nss_attr_group);
861 rc = sysfs_create_group(&ipl_subsys.kset.kobj,
862 &ipl_unknown_attr_group);
866 firmware_unregister(&ipl_subsys);
870 static void __init reipl_probe(void)
874 buffer = (void *) get_zeroed_page(GFP_KERNEL);
877 if (diag308(DIAG308_STORE, buffer) == DIAG308_RC_OK)
878 diag308_set_works = 1;
879 free_page((unsigned long)buffer);
882 static int __init reipl_nss_init(void)
888 rc = sysfs_create_group(&reipl_subsys.kset.kobj, &reipl_nss_attr_group);
891 strncpy(reipl_nss_name, kernel_nss_name, NSS_NAME_SIZE + 1);
892 reipl_capabilities |= IPL_TYPE_NSS;
896 static int __init reipl_ccw_init(void)
900 reipl_block_ccw = (void *) get_zeroed_page(GFP_KERNEL);
901 if (!reipl_block_ccw)
903 rc = sysfs_create_group(&reipl_subsys.kset.kobj, &reipl_ccw_attr_group);
905 free_page((unsigned long)reipl_block_ccw);
908 reipl_block_ccw->hdr.len = IPL_PARM_BLK_CCW_LEN;
909 reipl_block_ccw->hdr.version = IPL_PARM_BLOCK_VERSION;
910 reipl_block_ccw->hdr.blk0_len = IPL_PARM_BLK0_CCW_LEN;
911 reipl_block_ccw->hdr.pbt = DIAG308_IPL_TYPE_CCW;
912 /* check if read scp info worked and set loadparm */
914 memcpy(reipl_block_ccw->ipl_info.ccw.load_param,
915 SCCB_LOADPARM, LOADPARM_LEN);
917 /* read scp info failed: set empty loadparm (EBCDIC blanks) */
918 memset(reipl_block_ccw->ipl_info.ccw.load_param, 0x40,
920 /* FIXME: check for diag308_set_works when enabling diag ccw reipl */
922 sys_reipl_ccw_loadparm_attr.attr.mode = S_IRUGO;
923 if (ipl_info.type == IPL_TYPE_CCW)
924 reipl_block_ccw->ipl_info.ccw.devno = ipl_devno;
925 reipl_capabilities |= IPL_TYPE_CCW;
929 static int __init reipl_fcp_init(void)
933 if ((!diag308_set_works) && (ipl_info.type != IPL_TYPE_FCP))
935 if ((!diag308_set_works) && (ipl_info.type == IPL_TYPE_FCP))
936 make_attrs_ro(reipl_fcp_attrs);
938 reipl_block_fcp = (void *) get_zeroed_page(GFP_KERNEL);
939 if (!reipl_block_fcp)
941 rc = sysfs_create_group(&reipl_subsys.kset.kobj, &reipl_fcp_attr_group);
943 free_page((unsigned long)reipl_block_fcp);
946 if (ipl_info.type == IPL_TYPE_FCP) {
947 memcpy(reipl_block_fcp, IPL_PARMBLOCK_START, PAGE_SIZE);
949 reipl_block_fcp->hdr.len = IPL_PARM_BLK_FCP_LEN;
950 reipl_block_fcp->hdr.version = IPL_PARM_BLOCK_VERSION;
951 reipl_block_fcp->hdr.blk0_len = IPL_PARM_BLK0_FCP_LEN;
952 reipl_block_fcp->hdr.pbt = DIAG308_IPL_TYPE_FCP;
953 reipl_block_fcp->ipl_info.fcp.opt = DIAG308_IPL_OPT_IPL;
955 reipl_capabilities |= IPL_TYPE_FCP;
959 static int __init reipl_init(void)
963 rc = firmware_register(&reipl_subsys);
966 rc = subsys_create_file(&reipl_subsys, &reipl_type_attr);
968 firmware_unregister(&reipl_subsys);
971 rc = reipl_ccw_init();
974 rc = reipl_fcp_init();
977 rc = reipl_nss_init();
980 rc = reipl_set_type(ipl_info.type);
986 static int __init dump_ccw_init(void)
990 dump_block_ccw = (void *) get_zeroed_page(GFP_KERNEL);
993 rc = sysfs_create_group(&dump_subsys.kset.kobj, &dump_ccw_attr_group);
995 free_page((unsigned long)dump_block_ccw);
998 dump_block_ccw->hdr.len = IPL_PARM_BLK_CCW_LEN;
999 dump_block_ccw->hdr.version = IPL_PARM_BLOCK_VERSION;
1000 dump_block_ccw->hdr.blk0_len = IPL_PARM_BLK0_CCW_LEN;
1001 dump_block_ccw->hdr.pbt = DIAG308_IPL_TYPE_CCW;
1002 dump_capabilities |= DUMP_TYPE_CCW;
1006 static int __init dump_fcp_init(void)
1010 if(!(SCCB_FLAG & 0x2) || !SCCB_VALID)
1011 return 0; /* LDIPL DUMP is not installed */
1012 if (!diag308_set_works)
1014 dump_block_fcp = (void *) get_zeroed_page(GFP_KERNEL);
1015 if (!dump_block_fcp)
1017 rc = sysfs_create_group(&dump_subsys.kset.kobj, &dump_fcp_attr_group);
1019 free_page((unsigned long)dump_block_fcp);
1022 dump_block_fcp->hdr.len = IPL_PARM_BLK_FCP_LEN;
1023 dump_block_fcp->hdr.version = IPL_PARM_BLOCK_VERSION;
1024 dump_block_fcp->hdr.blk0_len = IPL_PARM_BLK0_FCP_LEN;
1025 dump_block_fcp->hdr.pbt = DIAG308_IPL_TYPE_FCP;
1026 dump_block_fcp->ipl_info.fcp.opt = DIAG308_IPL_OPT_DUMP;
1027 dump_capabilities |= DUMP_TYPE_FCP;
1031 #define SHUTDOWN_ON_PANIC_PRIO 0
1033 static int shutdown_on_panic_notify(struct notifier_block *self,
1034 unsigned long event, void *data)
1036 if (on_panic_action == SHUTDOWN_DUMP)
1038 else if (on_panic_action == SHUTDOWN_REIPL)
1043 static struct notifier_block shutdown_on_panic_nb = {
1044 .notifier_call = shutdown_on_panic_notify,
1045 .priority = SHUTDOWN_ON_PANIC_PRIO
1048 static int __init dump_init(void)
1052 rc = firmware_register(&dump_subsys);
1055 rc = subsys_create_file(&dump_subsys, &dump_type_attr);
1057 firmware_unregister(&dump_subsys);
1060 rc = dump_ccw_init();
1063 rc = dump_fcp_init();
1066 dump_set_type(DUMP_TYPE_NONE);
1070 static int __init shutdown_actions_init(void)
1074 rc = firmware_register(&shutdown_actions_subsys);
1077 rc = subsys_create_file(&shutdown_actions_subsys, &on_panic_attr);
1079 firmware_unregister(&shutdown_actions_subsys);
1082 atomic_notifier_chain_register(&panic_notifier_list,
1083 &shutdown_on_panic_nb);
1087 static int __init s390_ipl_init(void)
1101 rc = shutdown_actions_init();
1107 __initcall(s390_ipl_init);
1109 void __init ipl_save_parameters(void)
1111 struct cio_iplinfo iplinfo;
1112 unsigned int *ipl_ptr;
1115 if (cio_get_iplinfo(&iplinfo))
1118 ipl_devno = iplinfo.devno;
1119 ipl_flags |= IPL_DEVNO_VALID;
1120 if (!iplinfo.is_qdio)
1122 ipl_flags |= IPL_PARMBLOCK_VALID;
1123 ipl_ptr = (unsigned int *)__LC_IPL_PARMBLOCK_PTR;
1124 src = (void *)(unsigned long)*ipl_ptr;
1125 dst = (void *)IPL_PARMBLOCK_ORIGIN;
1126 memmove(dst, src, PAGE_SIZE);
1127 *ipl_ptr = IPL_PARMBLOCK_ORIGIN;
1130 static LIST_HEAD(rcall);
1131 static DEFINE_MUTEX(rcall_mutex);
1133 void register_reset_call(struct reset_call *reset)
1135 mutex_lock(&rcall_mutex);
1136 list_add(&reset->list, &rcall);
1137 mutex_unlock(&rcall_mutex);
1139 EXPORT_SYMBOL_GPL(register_reset_call);
1141 void unregister_reset_call(struct reset_call *reset)
1143 mutex_lock(&rcall_mutex);
1144 list_del(&reset->list);
1145 mutex_unlock(&rcall_mutex);
1147 EXPORT_SYMBOL_GPL(unregister_reset_call);
1149 static void do_reset_calls(void)
1151 struct reset_call *reset;
1153 list_for_each_entry(reset, &rcall, list)
1157 u32 dump_prefix_page;
1159 void s390_reset_system(void)
1161 struct _lowcore *lc;
1163 lc = (struct _lowcore *)(unsigned long) store_prefix();
1165 /* Stack for interrupt/machine check handler */
1166 lc->panic_stack = S390_lowcore.panic_stack;
1168 /* Save prefix page address for dump case */
1169 dump_prefix_page = (u32)(unsigned long) lc;
1171 /* Disable prefixing */
1174 /* Disable lowcore protection */
1175 __ctl_clear_bit(0,28);
1177 /* Set new machine check handler */
1178 S390_lowcore.mcck_new_psw.mask = psw_kernel_bits & ~PSW_MASK_MCHECK;
1179 S390_lowcore.mcck_new_psw.addr =
1180 PSW_ADDR_AMODE | (unsigned long) s390_base_mcck_handler;
1182 /* Set new program check handler */
1183 S390_lowcore.program_new_psw.mask = psw_kernel_bits & ~PSW_MASK_MCHECK;
1184 S390_lowcore.program_new_psw.addr =
1185 PSW_ADDR_AMODE | (unsigned long) s390_base_pgm_handler;