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])
40 #define IPL_NONE_STR "none"
41 #define IPL_UNKNOWN_STR "unknown"
42 #define IPL_CCW_STR "ccw"
43 #define IPL_FCP_STR "fcp"
44 #define IPL_NSS_STR "nss"
46 static char *ipl_type_str(enum ipl_type type)
57 case IPL_TYPE_UNKNOWN:
59 return IPL_UNKNOWN_STR;
68 IPL_METHOD_FCP_RO_DIAG,
69 IPL_METHOD_FCP_RW_DIAG,
74 enum shutdown_action {
80 #define SHUTDOWN_REIPL_STR "reipl"
81 #define SHUTDOWN_DUMP_STR "dump"
82 #define SHUTDOWN_STOP_STR "stop"
84 static char *shutdown_action_str(enum shutdown_action action)
88 return SHUTDOWN_REIPL_STR;
90 return SHUTDOWN_DUMP_STR;
92 return SHUTDOWN_STOP_STR;
98 enum diag308_subcode {
105 enum diag308_ipl_type {
106 DIAG308_IPL_TYPE_FCP = 0,
107 DIAG308_IPL_TYPE_CCW = 2,
111 DIAG308_IPL_OPT_IPL = 0x10,
112 DIAG308_IPL_OPT_DUMP = 0x20,
119 static int diag308_set_works = 0;
121 static int reipl_capabilities = IPL_TYPE_UNKNOWN;
123 static enum ipl_type reipl_type = IPL_TYPE_UNKNOWN;
124 static enum ipl_method reipl_method = IPL_METHOD_NONE;
125 static struct ipl_parameter_block *reipl_block_fcp;
126 static struct ipl_parameter_block *reipl_block_ccw;
128 static char reipl_nss_name[NSS_NAME_SIZE + 1];
130 static int dump_capabilities = IPL_TYPE_NONE;
131 static enum ipl_type dump_type = IPL_TYPE_NONE;
132 static enum ipl_method dump_method = IPL_METHOD_NONE;
133 static struct ipl_parameter_block *dump_block_fcp;
134 static struct ipl_parameter_block *dump_block_ccw;
136 static enum shutdown_action on_panic_action = SHUTDOWN_STOP;
138 static int diag308(unsigned long subcode, void *addr)
140 register unsigned long _addr asm("0") = (unsigned long) addr;
141 register unsigned long _rc asm("1") = 0;
144 " diag %0,%2,0x308\n"
147 : "+d" (_addr), "+d" (_rc)
148 : "d" (subcode) : "cc", "memory");
154 #define DEFINE_IPL_ATTR_RO(_prefix, _name, _format, _value) \
155 static ssize_t sys_##_prefix##_##_name##_show(struct subsystem *subsys, \
158 return sprintf(page, _format, _value); \
160 static struct subsys_attribute sys_##_prefix##_##_name##_attr = \
161 __ATTR(_name, S_IRUGO, sys_##_prefix##_##_name##_show, NULL);
163 #define DEFINE_IPL_ATTR_RW(_prefix, _name, _fmt_out, _fmt_in, _value) \
164 static ssize_t sys_##_prefix##_##_name##_show(struct subsystem *subsys, \
167 return sprintf(page, _fmt_out, \
168 (unsigned long long) _value); \
170 static ssize_t sys_##_prefix##_##_name##_store(struct subsystem *subsys,\
171 const char *buf, size_t len) \
173 unsigned long long value; \
174 if (sscanf(buf, _fmt_in, &value) != 1) \
179 static struct subsys_attribute sys_##_prefix##_##_name##_attr = \
180 __ATTR(_name,(S_IRUGO | S_IWUSR), \
181 sys_##_prefix##_##_name##_show, \
182 sys_##_prefix##_##_name##_store);
184 #define DEFINE_IPL_ATTR_STR_RW(_prefix, _name, _fmt_out, _fmt_in, _value)\
185 static ssize_t sys_##_prefix##_##_name##_show(struct subsystem *subsys, \
188 return sprintf(page, _fmt_out, _value); \
190 static ssize_t sys_##_prefix##_##_name##_store(struct subsystem *subsys,\
191 const char *buf, size_t len) \
193 if (sscanf(buf, _fmt_in, _value) != 1) \
197 static struct subsys_attribute sys_##_prefix##_##_name##_attr = \
198 __ATTR(_name,(S_IRUGO | S_IWUSR), \
199 sys_##_prefix##_##_name##_show, \
200 sys_##_prefix##_##_name##_store);
202 static void make_attrs_ro(struct attribute **attrs)
205 (*attrs)->mode = S_IRUGO;
214 static enum ipl_type ipl_get_type(void)
216 struct ipl_parameter_block *ipl = IPL_PARMBLOCK_START;
218 if (ipl_flags & IPL_NSS_VALID)
220 if (!(ipl_flags & IPL_DEVNO_VALID))
221 return IPL_TYPE_UNKNOWN;
222 if (!(ipl_flags & IPL_PARMBLOCK_VALID))
224 if (ipl->hdr.version > IPL_MAX_SUPPORTED_VERSION)
225 return IPL_TYPE_UNKNOWN;
226 if (ipl->hdr.pbt != DIAG308_IPL_TYPE_FCP)
227 return IPL_TYPE_UNKNOWN;
231 static ssize_t ipl_type_show(struct subsystem *subsys, char *page)
233 return sprintf(page, "%s\n", ipl_type_str(ipl_get_type()));
236 static struct subsys_attribute sys_ipl_type_attr = __ATTR_RO(ipl_type);
238 static ssize_t sys_ipl_device_show(struct subsystem *subsys, char *page)
240 struct ipl_parameter_block *ipl = IPL_PARMBLOCK_START;
242 switch (ipl_get_type()) {
244 return sprintf(page, "0.0.%04x\n", ipl_devno);
246 return sprintf(page, "0.0.%04x\n", ipl->ipl_info.fcp.devno);
252 static struct subsys_attribute sys_ipl_device_attr =
253 __ATTR(device, S_IRUGO, sys_ipl_device_show, NULL);
255 static ssize_t ipl_parameter_read(struct kobject *kobj, char *buf, loff_t off,
258 unsigned int size = IPL_PARMBLOCK_SIZE;
262 if (off + count > size)
264 memcpy(buf, (void *)IPL_PARMBLOCK_START + off, count);
268 static struct bin_attribute ipl_parameter_attr = {
270 .name = "binary_parameter",
272 .owner = THIS_MODULE,
275 .read = &ipl_parameter_read,
278 static ssize_t ipl_scp_data_read(struct kobject *kobj, char *buf, loff_t off,
281 unsigned int size = IPL_PARMBLOCK_START->ipl_info.fcp.scp_data_len;
282 void *scp_data = &IPL_PARMBLOCK_START->ipl_info.fcp.scp_data;
286 if (off + count > size)
288 memcpy(buf, scp_data + off, count);
292 static struct bin_attribute ipl_scp_data_attr = {
296 .owner = THIS_MODULE,
299 .read = &ipl_scp_data_read,
302 /* FCP ipl device attributes */
304 DEFINE_IPL_ATTR_RO(ipl_fcp, wwpn, "0x%016llx\n", (unsigned long long)
305 IPL_PARMBLOCK_START->ipl_info.fcp.wwpn);
306 DEFINE_IPL_ATTR_RO(ipl_fcp, lun, "0x%016llx\n", (unsigned long long)
307 IPL_PARMBLOCK_START->ipl_info.fcp.lun);
308 DEFINE_IPL_ATTR_RO(ipl_fcp, bootprog, "%lld\n", (unsigned long long)
309 IPL_PARMBLOCK_START->ipl_info.fcp.bootprog);
310 DEFINE_IPL_ATTR_RO(ipl_fcp, br_lba, "%lld\n", (unsigned long long)
311 IPL_PARMBLOCK_START->ipl_info.fcp.br_lba);
313 static struct attribute *ipl_fcp_attrs[] = {
314 &sys_ipl_type_attr.attr,
315 &sys_ipl_device_attr.attr,
316 &sys_ipl_fcp_wwpn_attr.attr,
317 &sys_ipl_fcp_lun_attr.attr,
318 &sys_ipl_fcp_bootprog_attr.attr,
319 &sys_ipl_fcp_br_lba_attr.attr,
323 static struct attribute_group ipl_fcp_attr_group = {
324 .attrs = ipl_fcp_attrs,
327 /* CCW ipl device attributes */
329 static ssize_t ipl_ccw_loadparm_show(struct subsystem *subsys, char *page)
331 char loadparm[LOADPARM_LEN + 1] = {};
334 return sprintf(page, "#unknown#\n");
335 memcpy(loadparm, SCCB_LOADPARM, LOADPARM_LEN);
336 EBCASC(loadparm, LOADPARM_LEN);
338 return sprintf(page, "%s\n", loadparm);
341 static struct subsys_attribute sys_ipl_ccw_loadparm_attr =
342 __ATTR(loadparm, 0444, ipl_ccw_loadparm_show, NULL);
344 static struct attribute *ipl_ccw_attrs[] = {
345 &sys_ipl_type_attr.attr,
346 &sys_ipl_device_attr.attr,
347 &sys_ipl_ccw_loadparm_attr.attr,
351 static struct attribute_group ipl_ccw_attr_group = {
352 .attrs = ipl_ccw_attrs,
355 /* NSS ipl device attributes */
357 DEFINE_IPL_ATTR_RO(ipl_nss, name, "%s\n", kernel_nss_name);
359 static struct attribute *ipl_nss_attrs[] = {
360 &sys_ipl_type_attr.attr,
361 &sys_ipl_nss_name_attr.attr,
365 static struct attribute_group ipl_nss_attr_group = {
366 .attrs = ipl_nss_attrs,
369 /* UNKNOWN ipl device attributes */
371 static struct attribute *ipl_unknown_attrs[] = {
372 &sys_ipl_type_attr.attr,
376 static struct attribute_group ipl_unknown_attr_group = {
377 .attrs = ipl_unknown_attrs,
380 static decl_subsys(ipl, NULL, NULL);
386 /* FCP reipl device attributes */
388 DEFINE_IPL_ATTR_RW(reipl_fcp, wwpn, "0x%016llx\n", "%016llx\n",
389 reipl_block_fcp->ipl_info.fcp.wwpn);
390 DEFINE_IPL_ATTR_RW(reipl_fcp, lun, "0x%016llx\n", "%016llx\n",
391 reipl_block_fcp->ipl_info.fcp.lun);
392 DEFINE_IPL_ATTR_RW(reipl_fcp, bootprog, "%lld\n", "%lld\n",
393 reipl_block_fcp->ipl_info.fcp.bootprog);
394 DEFINE_IPL_ATTR_RW(reipl_fcp, br_lba, "%lld\n", "%lld\n",
395 reipl_block_fcp->ipl_info.fcp.br_lba);
396 DEFINE_IPL_ATTR_RW(reipl_fcp, device, "0.0.%04llx\n", "0.0.%llx\n",
397 reipl_block_fcp->ipl_info.fcp.devno);
399 static struct attribute *reipl_fcp_attrs[] = {
400 &sys_reipl_fcp_device_attr.attr,
401 &sys_reipl_fcp_wwpn_attr.attr,
402 &sys_reipl_fcp_lun_attr.attr,
403 &sys_reipl_fcp_bootprog_attr.attr,
404 &sys_reipl_fcp_br_lba_attr.attr,
408 static struct attribute_group reipl_fcp_attr_group = {
410 .attrs = reipl_fcp_attrs,
413 /* CCW reipl device attributes */
415 DEFINE_IPL_ATTR_RW(reipl_ccw, device, "0.0.%04llx\n", "0.0.%llx\n",
416 reipl_block_ccw->ipl_info.ccw.devno);
418 static void reipl_get_ascii_loadparm(char *loadparm)
420 memcpy(loadparm, &reipl_block_ccw->ipl_info.ccw.load_param,
422 EBCASC(loadparm, LOADPARM_LEN);
423 loadparm[LOADPARM_LEN] = 0;
427 static ssize_t reipl_ccw_loadparm_show(struct subsystem *subsys, char *page)
429 char buf[LOADPARM_LEN + 1];
431 reipl_get_ascii_loadparm(buf);
432 return sprintf(page, "%s\n", buf);
435 static ssize_t reipl_ccw_loadparm_store(struct subsystem *subsys,
436 const char *buf, size_t len)
440 /* ignore trailing newline */
442 if ((len > 0) && (buf[len - 1] == '\n'))
444 /* loadparm can have max 8 characters and must not start with a blank */
445 if ((lp_len > LOADPARM_LEN) || ((lp_len > 0) && (buf[0] == ' ')))
447 /* loadparm can only contain "a-z,A-Z,0-9,SP,." */
448 for (i = 0; i < lp_len; i++) {
449 if (isalpha(buf[i]) || isdigit(buf[i]) || (buf[i] == ' ') ||
454 /* initialize loadparm with blanks */
455 memset(&reipl_block_ccw->ipl_info.ccw.load_param, ' ', LOADPARM_LEN);
456 /* copy and convert to ebcdic */
457 memcpy(&reipl_block_ccw->ipl_info.ccw.load_param, buf, lp_len);
458 ASCEBC(reipl_block_ccw->ipl_info.ccw.load_param, LOADPARM_LEN);
462 static struct subsys_attribute sys_reipl_ccw_loadparm_attr =
463 __ATTR(loadparm, 0644, reipl_ccw_loadparm_show,
464 reipl_ccw_loadparm_store);
466 static struct attribute *reipl_ccw_attrs[] = {
467 &sys_reipl_ccw_device_attr.attr,
468 &sys_reipl_ccw_loadparm_attr.attr,
472 static struct attribute_group reipl_ccw_attr_group = {
474 .attrs = reipl_ccw_attrs,
478 /* NSS reipl device attributes */
480 DEFINE_IPL_ATTR_STR_RW(reipl_nss, name, "%s\n", "%s\n", reipl_nss_name);
482 static struct attribute *reipl_nss_attrs[] = {
483 &sys_reipl_nss_name_attr.attr,
487 static struct attribute_group reipl_nss_attr_group = {
489 .attrs = reipl_nss_attrs,
494 static int reipl_set_type(enum ipl_type type)
496 if (!(reipl_capabilities & type))
502 reipl_method = IPL_METHOD_CCW_VM;
504 reipl_method = IPL_METHOD_CCW_CIO;
507 if (diag308_set_works)
508 reipl_method = IPL_METHOD_FCP_RW_DIAG;
509 else if (MACHINE_IS_VM)
510 reipl_method = IPL_METHOD_FCP_RO_VM;
512 reipl_method = IPL_METHOD_FCP_RO_DIAG;
515 reipl_method = IPL_METHOD_NSS;
518 reipl_method = IPL_METHOD_NONE;
524 static ssize_t reipl_type_show(struct subsystem *subsys, char *page)
526 return sprintf(page, "%s\n", ipl_type_str(reipl_type));
529 static ssize_t reipl_type_store(struct subsystem *subsys, const char *buf,
534 if (strncmp(buf, IPL_CCW_STR, strlen(IPL_CCW_STR)) == 0)
535 rc = reipl_set_type(IPL_TYPE_CCW);
536 else if (strncmp(buf, IPL_FCP_STR, strlen(IPL_FCP_STR)) == 0)
537 rc = reipl_set_type(IPL_TYPE_FCP);
538 else if (strncmp(buf, IPL_NSS_STR, strlen(IPL_NSS_STR)) == 0)
539 rc = reipl_set_type(IPL_TYPE_NSS);
540 return (rc != 0) ? rc : len;
543 static struct subsys_attribute reipl_type_attr =
544 __ATTR(reipl_type, 0644, reipl_type_show, reipl_type_store);
546 static decl_subsys(reipl, NULL, NULL);
552 /* FCP dump device attributes */
554 DEFINE_IPL_ATTR_RW(dump_fcp, wwpn, "0x%016llx\n", "%016llx\n",
555 dump_block_fcp->ipl_info.fcp.wwpn);
556 DEFINE_IPL_ATTR_RW(dump_fcp, lun, "0x%016llx\n", "%016llx\n",
557 dump_block_fcp->ipl_info.fcp.lun);
558 DEFINE_IPL_ATTR_RW(dump_fcp, bootprog, "%lld\n", "%lld\n",
559 dump_block_fcp->ipl_info.fcp.bootprog);
560 DEFINE_IPL_ATTR_RW(dump_fcp, br_lba, "%lld\n", "%lld\n",
561 dump_block_fcp->ipl_info.fcp.br_lba);
562 DEFINE_IPL_ATTR_RW(dump_fcp, device, "0.0.%04llx\n", "0.0.%llx\n",
563 dump_block_fcp->ipl_info.fcp.devno);
565 static struct attribute *dump_fcp_attrs[] = {
566 &sys_dump_fcp_device_attr.attr,
567 &sys_dump_fcp_wwpn_attr.attr,
568 &sys_dump_fcp_lun_attr.attr,
569 &sys_dump_fcp_bootprog_attr.attr,
570 &sys_dump_fcp_br_lba_attr.attr,
574 static struct attribute_group dump_fcp_attr_group = {
576 .attrs = dump_fcp_attrs,
579 /* CCW dump device attributes */
581 DEFINE_IPL_ATTR_RW(dump_ccw, device, "0.0.%04llx\n", "0.0.%llx\n",
582 dump_block_ccw->ipl_info.ccw.devno);
584 static struct attribute *dump_ccw_attrs[] = {
585 &sys_dump_ccw_device_attr.attr,
589 static struct attribute_group dump_ccw_attr_group = {
591 .attrs = dump_ccw_attrs,
596 static int dump_set_type(enum ipl_type type)
598 if (!(dump_capabilities & type))
603 dump_method = IPL_METHOD_CCW_VM;
605 dump_method = IPL_METHOD_CCW_CIO;
608 dump_method = IPL_METHOD_FCP_RW_DIAG;
611 dump_method = IPL_METHOD_NONE;
617 static ssize_t dump_type_show(struct subsystem *subsys, char *page)
619 return sprintf(page, "%s\n", ipl_type_str(dump_type));
622 static ssize_t dump_type_store(struct subsystem *subsys, const char *buf,
627 if (strncmp(buf, IPL_NONE_STR, strlen(IPL_NONE_STR)) == 0)
628 rc = dump_set_type(IPL_TYPE_NONE);
629 else if (strncmp(buf, IPL_CCW_STR, strlen(IPL_CCW_STR)) == 0)
630 rc = dump_set_type(IPL_TYPE_CCW);
631 else if (strncmp(buf, IPL_FCP_STR, strlen(IPL_FCP_STR)) == 0)
632 rc = dump_set_type(IPL_TYPE_FCP);
633 return (rc != 0) ? rc : len;
636 static struct subsys_attribute dump_type_attr =
637 __ATTR(dump_type, 0644, dump_type_show, dump_type_store);
639 static decl_subsys(dump, NULL, NULL);
642 * Shutdown actions section
645 static decl_subsys(shutdown_actions, NULL, NULL);
649 static ssize_t on_panic_show(struct subsystem *subsys, char *page)
651 return sprintf(page, "%s\n", shutdown_action_str(on_panic_action));
654 static ssize_t on_panic_store(struct subsystem *subsys, const char *buf,
657 if (strncmp(buf, SHUTDOWN_REIPL_STR, strlen(SHUTDOWN_REIPL_STR)) == 0)
658 on_panic_action = SHUTDOWN_REIPL;
659 else if (strncmp(buf, SHUTDOWN_DUMP_STR,
660 strlen(SHUTDOWN_DUMP_STR)) == 0)
661 on_panic_action = SHUTDOWN_DUMP;
662 else if (strncmp(buf, SHUTDOWN_STOP_STR,
663 strlen(SHUTDOWN_STOP_STR)) == 0)
664 on_panic_action = SHUTDOWN_STOP;
671 static struct subsys_attribute on_panic_attr =
672 __ATTR(on_panic, 0644, on_panic_show, on_panic_store);
676 struct ccw_dev_id devid;
677 static char buf[100];
678 char loadparm[LOADPARM_LEN + 1];
680 switch (reipl_method) {
681 case IPL_METHOD_CCW_CIO:
682 devid.devno = reipl_block_ccw->ipl_info.ccw.devno;
683 if (ipl_get_type() == IPL_TYPE_CCW && devid.devno == ipl_devno)
684 diag308(DIAG308_IPL, NULL);
686 reipl_ccw_dev(&devid);
688 case IPL_METHOD_CCW_VM:
689 reipl_get_ascii_loadparm(loadparm);
690 if (strlen(loadparm) == 0)
691 sprintf(buf, "IPL %X",
692 reipl_block_ccw->ipl_info.ccw.devno);
694 sprintf(buf, "IPL %X LOADPARM '%s'",
695 reipl_block_ccw->ipl_info.ccw.devno, loadparm);
696 __cpcmd(buf, NULL, 0, NULL);
698 case IPL_METHOD_CCW_DIAG:
699 diag308(DIAG308_SET, reipl_block_ccw);
700 diag308(DIAG308_IPL, NULL);
702 case IPL_METHOD_FCP_RW_DIAG:
703 diag308(DIAG308_SET, reipl_block_fcp);
704 diag308(DIAG308_IPL, NULL);
706 case IPL_METHOD_FCP_RO_DIAG:
707 diag308(DIAG308_IPL, NULL);
709 case IPL_METHOD_FCP_RO_VM:
710 __cpcmd("IPL", NULL, 0, NULL);
713 sprintf(buf, "IPL %s", reipl_nss_name);
714 __cpcmd(buf, NULL, 0, NULL);
716 case IPL_METHOD_NONE:
719 __cpcmd("IPL", NULL, 0, NULL);
720 diag308(DIAG308_IPL, NULL);
723 signal_processor(smp_processor_id(), sigp_stop_and_store_status);
726 static void do_dump(void)
728 struct ccw_dev_id devid;
729 static char buf[100];
731 switch (dump_method) {
732 case IPL_METHOD_CCW_CIO:
734 devid.devno = dump_block_ccw->ipl_info.ccw.devno;
736 reipl_ccw_dev(&devid);
738 case IPL_METHOD_CCW_VM:
740 sprintf(buf, "STORE STATUS");
741 __cpcmd(buf, NULL, 0, NULL);
742 sprintf(buf, "IPL %X", dump_block_ccw->ipl_info.ccw.devno);
743 __cpcmd(buf, NULL, 0, NULL);
745 case IPL_METHOD_CCW_DIAG:
746 diag308(DIAG308_SET, dump_block_ccw);
747 diag308(DIAG308_DUMP, NULL);
749 case IPL_METHOD_FCP_RW_DIAG:
750 diag308(DIAG308_SET, dump_block_fcp);
751 diag308(DIAG308_DUMP, NULL);
753 case IPL_METHOD_NONE:
757 printk(KERN_EMERG "Dump failed!\n");
762 static int __init ipl_register_fcp_files(void)
766 rc = sysfs_create_group(&ipl_subsys.kset.kobj,
767 &ipl_fcp_attr_group);
770 rc = sysfs_create_bin_file(&ipl_subsys.kset.kobj,
771 &ipl_parameter_attr);
774 rc = sysfs_create_bin_file(&ipl_subsys.kset.kobj,
779 sysfs_remove_bin_file(&ipl_subsys.kset.kobj, &ipl_parameter_attr);
782 sysfs_remove_group(&ipl_subsys.kset.kobj, &ipl_fcp_attr_group);
787 static int __init ipl_init(void)
791 rc = firmware_register(&ipl_subsys);
794 switch (ipl_get_type()) {
796 rc = sysfs_create_group(&ipl_subsys.kset.kobj,
797 &ipl_ccw_attr_group);
800 rc = ipl_register_fcp_files();
803 rc = sysfs_create_group(&ipl_subsys.kset.kobj,
804 &ipl_nss_attr_group);
807 rc = sysfs_create_group(&ipl_subsys.kset.kobj,
808 &ipl_unknown_attr_group);
812 firmware_unregister(&ipl_subsys);
816 static void __init reipl_probe(void)
820 buffer = (void *) get_zeroed_page(GFP_KERNEL);
823 if (diag308(DIAG308_STORE, buffer) == DIAG308_RC_OK)
824 diag308_set_works = 1;
825 free_page((unsigned long)buffer);
828 static int __init reipl_nss_init(void)
834 rc = sysfs_create_group(&reipl_subsys.kset.kobj, &reipl_nss_attr_group);
837 strncpy(reipl_nss_name, kernel_nss_name, NSS_NAME_SIZE + 1);
838 reipl_capabilities |= IPL_TYPE_NSS;
842 static int __init reipl_ccw_init(void)
846 reipl_block_ccw = (void *) get_zeroed_page(GFP_KERNEL);
847 if (!reipl_block_ccw)
849 rc = sysfs_create_group(&reipl_subsys.kset.kobj, &reipl_ccw_attr_group);
851 free_page((unsigned long)reipl_block_ccw);
854 reipl_block_ccw->hdr.len = IPL_PARM_BLK_CCW_LEN;
855 reipl_block_ccw->hdr.version = IPL_PARM_BLOCK_VERSION;
856 reipl_block_ccw->hdr.blk0_len = sizeof(reipl_block_ccw->ipl_info.ccw);
857 reipl_block_ccw->hdr.pbt = DIAG308_IPL_TYPE_CCW;
858 /* check if read scp info worked and set loadparm */
860 memcpy(reipl_block_ccw->ipl_info.ccw.load_param,
861 SCCB_LOADPARM, LOADPARM_LEN);
863 /* read scp info failed: set empty loadparm (EBCDIC blanks) */
864 memset(reipl_block_ccw->ipl_info.ccw.load_param, 0x40,
866 /* FIXME: check for diag308_set_works when enabling diag ccw reipl */
868 sys_reipl_ccw_loadparm_attr.attr.mode = S_IRUGO;
869 if (ipl_get_type() == IPL_TYPE_CCW)
870 reipl_block_ccw->ipl_info.ccw.devno = ipl_devno;
871 reipl_capabilities |= IPL_TYPE_CCW;
875 static int __init reipl_fcp_init(void)
879 if ((!diag308_set_works) && (ipl_get_type() != IPL_TYPE_FCP))
881 if ((!diag308_set_works) && (ipl_get_type() == IPL_TYPE_FCP))
882 make_attrs_ro(reipl_fcp_attrs);
884 reipl_block_fcp = (void *) get_zeroed_page(GFP_KERNEL);
885 if (!reipl_block_fcp)
887 rc = sysfs_create_group(&reipl_subsys.kset.kobj, &reipl_fcp_attr_group);
889 free_page((unsigned long)reipl_block_fcp);
892 if (ipl_get_type() == IPL_TYPE_FCP) {
893 memcpy(reipl_block_fcp, IPL_PARMBLOCK_START, PAGE_SIZE);
895 reipl_block_fcp->hdr.len = IPL_PARM_BLK_FCP_LEN;
896 reipl_block_fcp->hdr.version = IPL_PARM_BLOCK_VERSION;
897 reipl_block_fcp->hdr.blk0_len =
898 sizeof(reipl_block_fcp->ipl_info.fcp);
899 reipl_block_fcp->hdr.pbt = DIAG308_IPL_TYPE_FCP;
900 reipl_block_fcp->ipl_info.fcp.opt = DIAG308_IPL_OPT_IPL;
902 reipl_capabilities |= IPL_TYPE_FCP;
906 static int __init reipl_init(void)
910 rc = firmware_register(&reipl_subsys);
913 rc = subsys_create_file(&reipl_subsys, &reipl_type_attr);
915 firmware_unregister(&reipl_subsys);
918 rc = reipl_ccw_init();
921 rc = reipl_fcp_init();
924 rc = reipl_nss_init();
927 rc = reipl_set_type(ipl_get_type());
933 static int __init dump_ccw_init(void)
937 dump_block_ccw = (void *) get_zeroed_page(GFP_KERNEL);
940 rc = sysfs_create_group(&dump_subsys.kset.kobj, &dump_ccw_attr_group);
942 free_page((unsigned long)dump_block_ccw);
945 dump_block_ccw->hdr.len = IPL_PARM_BLK_CCW_LEN;
946 dump_block_ccw->hdr.version = IPL_PARM_BLOCK_VERSION;
947 dump_block_ccw->hdr.blk0_len = sizeof(reipl_block_ccw->ipl_info.ccw);
948 dump_block_ccw->hdr.pbt = DIAG308_IPL_TYPE_CCW;
949 dump_capabilities |= IPL_TYPE_CCW;
953 static int __init dump_fcp_init(void)
957 if(!(SCCB_FLAG & 0x2) || !SCCB_VALID)
958 return 0; /* LDIPL DUMP is not installed */
959 if (!diag308_set_works)
961 dump_block_fcp = (void *) get_zeroed_page(GFP_KERNEL);
964 rc = sysfs_create_group(&dump_subsys.kset.kobj, &dump_fcp_attr_group);
966 free_page((unsigned long)dump_block_fcp);
969 dump_block_fcp->hdr.len = IPL_PARM_BLK_FCP_LEN;
970 dump_block_fcp->hdr.version = IPL_PARM_BLOCK_VERSION;
971 dump_block_fcp->hdr.blk0_len = sizeof(dump_block_fcp->ipl_info.fcp);
972 dump_block_fcp->hdr.pbt = DIAG308_IPL_TYPE_FCP;
973 dump_block_fcp->ipl_info.fcp.opt = DIAG308_IPL_OPT_DUMP;
974 dump_capabilities |= IPL_TYPE_FCP;
978 #define SHUTDOWN_ON_PANIC_PRIO 0
980 static int shutdown_on_panic_notify(struct notifier_block *self,
981 unsigned long event, void *data)
983 if (on_panic_action == SHUTDOWN_DUMP)
985 else if (on_panic_action == SHUTDOWN_REIPL)
990 static struct notifier_block shutdown_on_panic_nb = {
991 .notifier_call = shutdown_on_panic_notify,
992 .priority = SHUTDOWN_ON_PANIC_PRIO
995 static int __init dump_init(void)
999 rc = firmware_register(&dump_subsys);
1002 rc = subsys_create_file(&dump_subsys, &dump_type_attr);
1004 firmware_unregister(&dump_subsys);
1007 rc = dump_ccw_init();
1010 rc = dump_fcp_init();
1013 dump_set_type(IPL_TYPE_NONE);
1017 static int __init shutdown_actions_init(void)
1021 rc = firmware_register(&shutdown_actions_subsys);
1024 rc = subsys_create_file(&shutdown_actions_subsys, &on_panic_attr);
1026 firmware_unregister(&shutdown_actions_subsys);
1029 atomic_notifier_chain_register(&panic_notifier_list,
1030 &shutdown_on_panic_nb);
1034 static int __init s390_ipl_init(void)
1048 rc = shutdown_actions_init();
1054 __initcall(s390_ipl_init);
1056 static LIST_HEAD(rcall);
1057 static DEFINE_MUTEX(rcall_mutex);
1059 void register_reset_call(struct reset_call *reset)
1061 mutex_lock(&rcall_mutex);
1062 list_add(&reset->list, &rcall);
1063 mutex_unlock(&rcall_mutex);
1065 EXPORT_SYMBOL_GPL(register_reset_call);
1067 void unregister_reset_call(struct reset_call *reset)
1069 mutex_lock(&rcall_mutex);
1070 list_del(&reset->list);
1071 mutex_unlock(&rcall_mutex);
1073 EXPORT_SYMBOL_GPL(unregister_reset_call);
1075 static void do_reset_calls(void)
1077 struct reset_call *reset;
1079 list_for_each_entry(reset, &rcall, list)
1083 extern void reset_mcck_handler(void);
1084 extern void reset_pgm_handler(void);
1085 extern __u32 dump_prefix_page;
1087 void s390_reset_system(void)
1089 struct _lowcore *lc;
1091 lc = (struct _lowcore *)(unsigned long) store_prefix();
1093 /* Stack for interrupt/machine check handler */
1094 lc->panic_stack = S390_lowcore.panic_stack;
1096 /* Save prefix page address for dump case */
1097 dump_prefix_page = (unsigned long) lc;
1099 /* Disable prefixing */
1102 /* Disable lowcore protection */
1103 __ctl_clear_bit(0,28);
1105 /* Set new machine check handler */
1106 S390_lowcore.mcck_new_psw.mask = psw_kernel_bits & ~PSW_MASK_MCHECK;
1107 S390_lowcore.mcck_new_psw.addr =
1108 PSW_ADDR_AMODE | (unsigned long) &reset_mcck_handler;
1110 /* Set new program check handler */
1111 S390_lowcore.program_new_psw.mask = psw_kernel_bits & ~PSW_MASK_MCHECK;
1112 S390_lowcore.program_new_psw.addr =
1113 PSW_ADDR_AMODE | (unsigned long) &reset_pgm_handler;