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)
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 static int diag308_set_works
= 0;
100 static int reipl_capabilities
= IPL_TYPE_UNKNOWN
;
102 static enum ipl_type reipl_type
= IPL_TYPE_UNKNOWN
;
103 static enum ipl_method reipl_method
= IPL_METHOD_NONE
;
104 static struct ipl_parameter_block
*reipl_block_fcp
;
105 static struct ipl_parameter_block
*reipl_block_ccw
;
107 static char reipl_nss_name
[NSS_NAME_SIZE
+ 1];
109 static int dump_capabilities
= IPL_TYPE_NONE
;
110 static enum ipl_type dump_type
= IPL_TYPE_NONE
;
111 static enum ipl_method dump_method
= IPL_METHOD_NONE
;
112 static struct ipl_parameter_block
*dump_block_fcp
;
113 static struct ipl_parameter_block
*dump_block_ccw
;
115 static enum shutdown_action on_panic_action
= SHUTDOWN_STOP
;
117 int diag308(unsigned long subcode
, void *addr
)
119 register unsigned long _addr
asm("0") = (unsigned long) addr
;
120 register unsigned long _rc
asm("1") = 0;
123 " diag %0,%2,0x308\n"
126 : "+d" (_addr
), "+d" (_rc
)
127 : "d" (subcode
) : "cc", "memory");
133 #define DEFINE_IPL_ATTR_RO(_prefix, _name, _format, _value) \
134 static ssize_t sys_##_prefix##_##_name##_show(struct subsystem *subsys, \
137 return sprintf(page, _format, _value); \
139 static struct subsys_attribute sys_##_prefix##_##_name##_attr = \
140 __ATTR(_name, S_IRUGO, sys_##_prefix##_##_name##_show, NULL);
142 #define DEFINE_IPL_ATTR_RW(_prefix, _name, _fmt_out, _fmt_in, _value) \
143 static ssize_t sys_##_prefix##_##_name##_show(struct subsystem *subsys, \
146 return sprintf(page, _fmt_out, \
147 (unsigned long long) _value); \
149 static ssize_t sys_##_prefix##_##_name##_store(struct subsystem *subsys,\
150 const char *buf, size_t len) \
152 unsigned long long value; \
153 if (sscanf(buf, _fmt_in, &value) != 1) \
158 static struct subsys_attribute sys_##_prefix##_##_name##_attr = \
159 __ATTR(_name,(S_IRUGO | S_IWUSR), \
160 sys_##_prefix##_##_name##_show, \
161 sys_##_prefix##_##_name##_store);
163 #define DEFINE_IPL_ATTR_STR_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, _value); \
169 static ssize_t sys_##_prefix##_##_name##_store(struct subsystem *subsys,\
170 const char *buf, size_t len) \
172 if (sscanf(buf, _fmt_in, _value) != 1) \
176 static struct subsys_attribute sys_##_prefix##_##_name##_attr = \
177 __ATTR(_name,(S_IRUGO | S_IWUSR), \
178 sys_##_prefix##_##_name##_show, \
179 sys_##_prefix##_##_name##_store);
181 static void make_attrs_ro(struct attribute
**attrs
)
184 (*attrs
)->mode
= S_IRUGO
;
193 static enum ipl_type
ipl_get_type(void)
195 struct ipl_parameter_block
*ipl
= IPL_PARMBLOCK_START
;
197 if (ipl_flags
& IPL_NSS_VALID
)
199 if (!(ipl_flags
& IPL_DEVNO_VALID
))
200 return IPL_TYPE_UNKNOWN
;
201 if (!(ipl_flags
& IPL_PARMBLOCK_VALID
))
203 if (ipl
->hdr
.version
> IPL_MAX_SUPPORTED_VERSION
)
204 return IPL_TYPE_UNKNOWN
;
205 if (ipl
->hdr
.pbt
!= DIAG308_IPL_TYPE_FCP
)
206 return IPL_TYPE_UNKNOWN
;
210 static ssize_t
ipl_type_show(struct subsystem
*subsys
, char *page
)
212 return sprintf(page
, "%s\n", ipl_type_str(ipl_get_type()));
215 static struct subsys_attribute sys_ipl_type_attr
= __ATTR_RO(ipl_type
);
217 static ssize_t
sys_ipl_device_show(struct subsystem
*subsys
, char *page
)
219 struct ipl_parameter_block
*ipl
= IPL_PARMBLOCK_START
;
221 switch (ipl_get_type()) {
223 return sprintf(page
, "0.0.%04x\n", ipl_devno
);
225 return sprintf(page
, "0.0.%04x\n", ipl
->ipl_info
.fcp
.devno
);
231 static struct subsys_attribute sys_ipl_device_attr
=
232 __ATTR(device
, S_IRUGO
, sys_ipl_device_show
, NULL
);
234 static ssize_t
ipl_parameter_read(struct kobject
*kobj
, char *buf
, loff_t off
,
237 unsigned int size
= IPL_PARMBLOCK_SIZE
;
241 if (off
+ count
> size
)
243 memcpy(buf
, (void *)IPL_PARMBLOCK_START
+ off
, count
);
247 static struct bin_attribute ipl_parameter_attr
= {
249 .name
= "binary_parameter",
251 .owner
= THIS_MODULE
,
254 .read
= &ipl_parameter_read
,
257 static ssize_t
ipl_scp_data_read(struct kobject
*kobj
, char *buf
, loff_t off
,
260 unsigned int size
= IPL_PARMBLOCK_START
->ipl_info
.fcp
.scp_data_len
;
261 void *scp_data
= &IPL_PARMBLOCK_START
->ipl_info
.fcp
.scp_data
;
265 if (off
+ count
> size
)
267 memcpy(buf
, scp_data
+ off
, count
);
271 static struct bin_attribute ipl_scp_data_attr
= {
275 .owner
= THIS_MODULE
,
278 .read
= &ipl_scp_data_read
,
281 /* FCP ipl device attributes */
283 DEFINE_IPL_ATTR_RO(ipl_fcp
, wwpn
, "0x%016llx\n", (unsigned long long)
284 IPL_PARMBLOCK_START
->ipl_info
.fcp
.wwpn
);
285 DEFINE_IPL_ATTR_RO(ipl_fcp
, lun
, "0x%016llx\n", (unsigned long long)
286 IPL_PARMBLOCK_START
->ipl_info
.fcp
.lun
);
287 DEFINE_IPL_ATTR_RO(ipl_fcp
, bootprog
, "%lld\n", (unsigned long long)
288 IPL_PARMBLOCK_START
->ipl_info
.fcp
.bootprog
);
289 DEFINE_IPL_ATTR_RO(ipl_fcp
, br_lba
, "%lld\n", (unsigned long long)
290 IPL_PARMBLOCK_START
->ipl_info
.fcp
.br_lba
);
292 static struct attribute
*ipl_fcp_attrs
[] = {
293 &sys_ipl_type_attr
.attr
,
294 &sys_ipl_device_attr
.attr
,
295 &sys_ipl_fcp_wwpn_attr
.attr
,
296 &sys_ipl_fcp_lun_attr
.attr
,
297 &sys_ipl_fcp_bootprog_attr
.attr
,
298 &sys_ipl_fcp_br_lba_attr
.attr
,
302 static struct attribute_group ipl_fcp_attr_group
= {
303 .attrs
= ipl_fcp_attrs
,
306 /* CCW ipl device attributes */
308 static ssize_t
ipl_ccw_loadparm_show(struct subsystem
*subsys
, char *page
)
310 char loadparm
[LOADPARM_LEN
+ 1] = {};
313 return sprintf(page
, "#unknown#\n");
314 memcpy(loadparm
, SCCB_LOADPARM
, LOADPARM_LEN
);
315 EBCASC(loadparm
, LOADPARM_LEN
);
317 return sprintf(page
, "%s\n", loadparm
);
320 static struct subsys_attribute sys_ipl_ccw_loadparm_attr
=
321 __ATTR(loadparm
, 0444, ipl_ccw_loadparm_show
, NULL
);
323 static struct attribute
*ipl_ccw_attrs
[] = {
324 &sys_ipl_type_attr
.attr
,
325 &sys_ipl_device_attr
.attr
,
326 &sys_ipl_ccw_loadparm_attr
.attr
,
330 static struct attribute_group ipl_ccw_attr_group
= {
331 .attrs
= ipl_ccw_attrs
,
334 /* NSS ipl device attributes */
336 DEFINE_IPL_ATTR_RO(ipl_nss
, name
, "%s\n", kernel_nss_name
);
338 static struct attribute
*ipl_nss_attrs
[] = {
339 &sys_ipl_type_attr
.attr
,
340 &sys_ipl_nss_name_attr
.attr
,
344 static struct attribute_group ipl_nss_attr_group
= {
345 .attrs
= ipl_nss_attrs
,
348 /* UNKNOWN ipl device attributes */
350 static struct attribute
*ipl_unknown_attrs
[] = {
351 &sys_ipl_type_attr
.attr
,
355 static struct attribute_group ipl_unknown_attr_group
= {
356 .attrs
= ipl_unknown_attrs
,
359 static decl_subsys(ipl
, NULL
, NULL
);
365 /* FCP reipl device attributes */
367 DEFINE_IPL_ATTR_RW(reipl_fcp
, wwpn
, "0x%016llx\n", "%016llx\n",
368 reipl_block_fcp
->ipl_info
.fcp
.wwpn
);
369 DEFINE_IPL_ATTR_RW(reipl_fcp
, lun
, "0x%016llx\n", "%016llx\n",
370 reipl_block_fcp
->ipl_info
.fcp
.lun
);
371 DEFINE_IPL_ATTR_RW(reipl_fcp
, bootprog
, "%lld\n", "%lld\n",
372 reipl_block_fcp
->ipl_info
.fcp
.bootprog
);
373 DEFINE_IPL_ATTR_RW(reipl_fcp
, br_lba
, "%lld\n", "%lld\n",
374 reipl_block_fcp
->ipl_info
.fcp
.br_lba
);
375 DEFINE_IPL_ATTR_RW(reipl_fcp
, device
, "0.0.%04llx\n", "0.0.%llx\n",
376 reipl_block_fcp
->ipl_info
.fcp
.devno
);
378 static struct attribute
*reipl_fcp_attrs
[] = {
379 &sys_reipl_fcp_device_attr
.attr
,
380 &sys_reipl_fcp_wwpn_attr
.attr
,
381 &sys_reipl_fcp_lun_attr
.attr
,
382 &sys_reipl_fcp_bootprog_attr
.attr
,
383 &sys_reipl_fcp_br_lba_attr
.attr
,
387 static struct attribute_group reipl_fcp_attr_group
= {
389 .attrs
= reipl_fcp_attrs
,
392 /* CCW reipl device attributes */
394 DEFINE_IPL_ATTR_RW(reipl_ccw
, device
, "0.0.%04llx\n", "0.0.%llx\n",
395 reipl_block_ccw
->ipl_info
.ccw
.devno
);
397 static void reipl_get_ascii_loadparm(char *loadparm
)
399 memcpy(loadparm
, &reipl_block_ccw
->ipl_info
.ccw
.load_param
,
401 EBCASC(loadparm
, LOADPARM_LEN
);
402 loadparm
[LOADPARM_LEN
] = 0;
406 static ssize_t
reipl_ccw_loadparm_show(struct subsystem
*subsys
, char *page
)
408 char buf
[LOADPARM_LEN
+ 1];
410 reipl_get_ascii_loadparm(buf
);
411 return sprintf(page
, "%s\n", buf
);
414 static ssize_t
reipl_ccw_loadparm_store(struct subsystem
*subsys
,
415 const char *buf
, size_t len
)
419 /* ignore trailing newline */
421 if ((len
> 0) && (buf
[len
- 1] == '\n'))
423 /* loadparm can have max 8 characters and must not start with a blank */
424 if ((lp_len
> LOADPARM_LEN
) || ((lp_len
> 0) && (buf
[0] == ' ')))
426 /* loadparm can only contain "a-z,A-Z,0-9,SP,." */
427 for (i
= 0; i
< lp_len
; i
++) {
428 if (isalpha(buf
[i
]) || isdigit(buf
[i
]) || (buf
[i
] == ' ') ||
433 /* initialize loadparm with blanks */
434 memset(&reipl_block_ccw
->ipl_info
.ccw
.load_param
, ' ', LOADPARM_LEN
);
435 /* copy and convert to ebcdic */
436 memcpy(&reipl_block_ccw
->ipl_info
.ccw
.load_param
, buf
, lp_len
);
437 ASCEBC(reipl_block_ccw
->ipl_info
.ccw
.load_param
, LOADPARM_LEN
);
441 static struct subsys_attribute sys_reipl_ccw_loadparm_attr
=
442 __ATTR(loadparm
, 0644, reipl_ccw_loadparm_show
,
443 reipl_ccw_loadparm_store
);
445 static struct attribute
*reipl_ccw_attrs
[] = {
446 &sys_reipl_ccw_device_attr
.attr
,
447 &sys_reipl_ccw_loadparm_attr
.attr
,
451 static struct attribute_group reipl_ccw_attr_group
= {
453 .attrs
= reipl_ccw_attrs
,
457 /* NSS reipl device attributes */
459 DEFINE_IPL_ATTR_STR_RW(reipl_nss
, name
, "%s\n", "%s\n", reipl_nss_name
);
461 static struct attribute
*reipl_nss_attrs
[] = {
462 &sys_reipl_nss_name_attr
.attr
,
466 static struct attribute_group reipl_nss_attr_group
= {
468 .attrs
= reipl_nss_attrs
,
473 static int reipl_set_type(enum ipl_type type
)
475 if (!(reipl_capabilities
& type
))
481 reipl_method
= IPL_METHOD_CCW_VM
;
483 reipl_method
= IPL_METHOD_CCW_CIO
;
486 if (diag308_set_works
)
487 reipl_method
= IPL_METHOD_FCP_RW_DIAG
;
488 else if (MACHINE_IS_VM
)
489 reipl_method
= IPL_METHOD_FCP_RO_VM
;
491 reipl_method
= IPL_METHOD_FCP_RO_DIAG
;
494 reipl_method
= IPL_METHOD_NSS
;
497 reipl_method
= IPL_METHOD_NONE
;
503 static ssize_t
reipl_type_show(struct subsystem
*subsys
, char *page
)
505 return sprintf(page
, "%s\n", ipl_type_str(reipl_type
));
508 static ssize_t
reipl_type_store(struct subsystem
*subsys
, const char *buf
,
513 if (strncmp(buf
, IPL_CCW_STR
, strlen(IPL_CCW_STR
)) == 0)
514 rc
= reipl_set_type(IPL_TYPE_CCW
);
515 else if (strncmp(buf
, IPL_FCP_STR
, strlen(IPL_FCP_STR
)) == 0)
516 rc
= reipl_set_type(IPL_TYPE_FCP
);
517 else if (strncmp(buf
, IPL_NSS_STR
, strlen(IPL_NSS_STR
)) == 0)
518 rc
= reipl_set_type(IPL_TYPE_NSS
);
519 return (rc
!= 0) ? rc
: len
;
522 static struct subsys_attribute reipl_type_attr
=
523 __ATTR(reipl_type
, 0644, reipl_type_show
, reipl_type_store
);
525 static decl_subsys(reipl
, NULL
, NULL
);
531 /* FCP dump device attributes */
533 DEFINE_IPL_ATTR_RW(dump_fcp
, wwpn
, "0x%016llx\n", "%016llx\n",
534 dump_block_fcp
->ipl_info
.fcp
.wwpn
);
535 DEFINE_IPL_ATTR_RW(dump_fcp
, lun
, "0x%016llx\n", "%016llx\n",
536 dump_block_fcp
->ipl_info
.fcp
.lun
);
537 DEFINE_IPL_ATTR_RW(dump_fcp
, bootprog
, "%lld\n", "%lld\n",
538 dump_block_fcp
->ipl_info
.fcp
.bootprog
);
539 DEFINE_IPL_ATTR_RW(dump_fcp
, br_lba
, "%lld\n", "%lld\n",
540 dump_block_fcp
->ipl_info
.fcp
.br_lba
);
541 DEFINE_IPL_ATTR_RW(dump_fcp
, device
, "0.0.%04llx\n", "0.0.%llx\n",
542 dump_block_fcp
->ipl_info
.fcp
.devno
);
544 static struct attribute
*dump_fcp_attrs
[] = {
545 &sys_dump_fcp_device_attr
.attr
,
546 &sys_dump_fcp_wwpn_attr
.attr
,
547 &sys_dump_fcp_lun_attr
.attr
,
548 &sys_dump_fcp_bootprog_attr
.attr
,
549 &sys_dump_fcp_br_lba_attr
.attr
,
553 static struct attribute_group dump_fcp_attr_group
= {
555 .attrs
= dump_fcp_attrs
,
558 /* CCW dump device attributes */
560 DEFINE_IPL_ATTR_RW(dump_ccw
, device
, "0.0.%04llx\n", "0.0.%llx\n",
561 dump_block_ccw
->ipl_info
.ccw
.devno
);
563 static struct attribute
*dump_ccw_attrs
[] = {
564 &sys_dump_ccw_device_attr
.attr
,
568 static struct attribute_group dump_ccw_attr_group
= {
570 .attrs
= dump_ccw_attrs
,
575 static int dump_set_type(enum ipl_type type
)
577 if (!(dump_capabilities
& type
))
582 dump_method
= IPL_METHOD_CCW_VM
;
584 dump_method
= IPL_METHOD_CCW_CIO
;
587 dump_method
= IPL_METHOD_FCP_RW_DIAG
;
590 dump_method
= IPL_METHOD_NONE
;
596 static ssize_t
dump_type_show(struct subsystem
*subsys
, char *page
)
598 return sprintf(page
, "%s\n", ipl_type_str(dump_type
));
601 static ssize_t
dump_type_store(struct subsystem
*subsys
, const char *buf
,
606 if (strncmp(buf
, IPL_NONE_STR
, strlen(IPL_NONE_STR
)) == 0)
607 rc
= dump_set_type(IPL_TYPE_NONE
);
608 else if (strncmp(buf
, IPL_CCW_STR
, strlen(IPL_CCW_STR
)) == 0)
609 rc
= dump_set_type(IPL_TYPE_CCW
);
610 else if (strncmp(buf
, IPL_FCP_STR
, strlen(IPL_FCP_STR
)) == 0)
611 rc
= dump_set_type(IPL_TYPE_FCP
);
612 return (rc
!= 0) ? rc
: len
;
615 static struct subsys_attribute dump_type_attr
=
616 __ATTR(dump_type
, 0644, dump_type_show
, dump_type_store
);
618 static decl_subsys(dump
, NULL
, NULL
);
621 * Shutdown actions section
624 static decl_subsys(shutdown_actions
, NULL
, NULL
);
628 static ssize_t
on_panic_show(struct subsystem
*subsys
, char *page
)
630 return sprintf(page
, "%s\n", shutdown_action_str(on_panic_action
));
633 static ssize_t
on_panic_store(struct subsystem
*subsys
, const char *buf
,
636 if (strncmp(buf
, SHUTDOWN_REIPL_STR
, strlen(SHUTDOWN_REIPL_STR
)) == 0)
637 on_panic_action
= SHUTDOWN_REIPL
;
638 else if (strncmp(buf
, SHUTDOWN_DUMP_STR
,
639 strlen(SHUTDOWN_DUMP_STR
)) == 0)
640 on_panic_action
= SHUTDOWN_DUMP
;
641 else if (strncmp(buf
, SHUTDOWN_STOP_STR
,
642 strlen(SHUTDOWN_STOP_STR
)) == 0)
643 on_panic_action
= SHUTDOWN_STOP
;
650 static struct subsys_attribute on_panic_attr
=
651 __ATTR(on_panic
, 0644, on_panic_show
, on_panic_store
);
655 struct ccw_dev_id devid
;
656 static char buf
[100];
657 char loadparm
[LOADPARM_LEN
+ 1];
659 switch (reipl_method
) {
660 case IPL_METHOD_CCW_CIO
:
661 devid
.devno
= reipl_block_ccw
->ipl_info
.ccw
.devno
;
662 if (ipl_get_type() == IPL_TYPE_CCW
&& devid
.devno
== ipl_devno
)
663 diag308(DIAG308_IPL
, NULL
);
665 reipl_ccw_dev(&devid
);
667 case IPL_METHOD_CCW_VM
:
668 reipl_get_ascii_loadparm(loadparm
);
669 if (strlen(loadparm
) == 0)
670 sprintf(buf
, "IPL %X",
671 reipl_block_ccw
->ipl_info
.ccw
.devno
);
673 sprintf(buf
, "IPL %X LOADPARM '%s'",
674 reipl_block_ccw
->ipl_info
.ccw
.devno
, loadparm
);
675 __cpcmd(buf
, NULL
, 0, NULL
);
677 case IPL_METHOD_CCW_DIAG
:
678 diag308(DIAG308_SET
, reipl_block_ccw
);
679 diag308(DIAG308_IPL
, NULL
);
681 case IPL_METHOD_FCP_RW_DIAG
:
682 diag308(DIAG308_SET
, reipl_block_fcp
);
683 diag308(DIAG308_IPL
, NULL
);
685 case IPL_METHOD_FCP_RO_DIAG
:
686 diag308(DIAG308_IPL
, NULL
);
688 case IPL_METHOD_FCP_RO_VM
:
689 __cpcmd("IPL", NULL
, 0, NULL
);
692 sprintf(buf
, "IPL %s", reipl_nss_name
);
693 __cpcmd(buf
, NULL
, 0, NULL
);
695 case IPL_METHOD_NONE
:
698 __cpcmd("IPL", NULL
, 0, NULL
);
699 diag308(DIAG308_IPL
, NULL
);
702 signal_processor(smp_processor_id(), sigp_stop_and_store_status
);
705 static void do_dump(void)
707 struct ccw_dev_id devid
;
708 static char buf
[100];
710 switch (dump_method
) {
711 case IPL_METHOD_CCW_CIO
:
713 devid
.devno
= dump_block_ccw
->ipl_info
.ccw
.devno
;
715 reipl_ccw_dev(&devid
);
717 case IPL_METHOD_CCW_VM
:
719 sprintf(buf
, "STORE STATUS");
720 __cpcmd(buf
, NULL
, 0, NULL
);
721 sprintf(buf
, "IPL %X", dump_block_ccw
->ipl_info
.ccw
.devno
);
722 __cpcmd(buf
, NULL
, 0, NULL
);
724 case IPL_METHOD_CCW_DIAG
:
725 diag308(DIAG308_SET
, dump_block_ccw
);
726 diag308(DIAG308_DUMP
, NULL
);
728 case IPL_METHOD_FCP_RW_DIAG
:
729 diag308(DIAG308_SET
, dump_block_fcp
);
730 diag308(DIAG308_DUMP
, NULL
);
732 case IPL_METHOD_NONE
:
736 printk(KERN_EMERG
"Dump failed!\n");
741 static int __init
ipl_register_fcp_files(void)
745 rc
= sysfs_create_group(&ipl_subsys
.kset
.kobj
,
746 &ipl_fcp_attr_group
);
749 rc
= sysfs_create_bin_file(&ipl_subsys
.kset
.kobj
,
750 &ipl_parameter_attr
);
753 rc
= sysfs_create_bin_file(&ipl_subsys
.kset
.kobj
,
758 sysfs_remove_bin_file(&ipl_subsys
.kset
.kobj
, &ipl_parameter_attr
);
761 sysfs_remove_group(&ipl_subsys
.kset
.kobj
, &ipl_fcp_attr_group
);
766 static int __init
ipl_init(void)
770 rc
= firmware_register(&ipl_subsys
);
773 switch (ipl_get_type()) {
775 rc
= sysfs_create_group(&ipl_subsys
.kset
.kobj
,
776 &ipl_ccw_attr_group
);
779 rc
= ipl_register_fcp_files();
782 rc
= sysfs_create_group(&ipl_subsys
.kset
.kobj
,
783 &ipl_nss_attr_group
);
786 rc
= sysfs_create_group(&ipl_subsys
.kset
.kobj
,
787 &ipl_unknown_attr_group
);
791 firmware_unregister(&ipl_subsys
);
795 static void __init
reipl_probe(void)
799 buffer
= (void *) get_zeroed_page(GFP_KERNEL
);
802 if (diag308(DIAG308_STORE
, buffer
) == DIAG308_RC_OK
)
803 diag308_set_works
= 1;
804 free_page((unsigned long)buffer
);
807 static int __init
reipl_nss_init(void)
813 rc
= sysfs_create_group(&reipl_subsys
.kset
.kobj
, &reipl_nss_attr_group
);
816 strncpy(reipl_nss_name
, kernel_nss_name
, NSS_NAME_SIZE
+ 1);
817 reipl_capabilities
|= IPL_TYPE_NSS
;
821 static int __init
reipl_ccw_init(void)
825 reipl_block_ccw
= (void *) get_zeroed_page(GFP_KERNEL
);
826 if (!reipl_block_ccw
)
828 rc
= sysfs_create_group(&reipl_subsys
.kset
.kobj
, &reipl_ccw_attr_group
);
830 free_page((unsigned long)reipl_block_ccw
);
833 reipl_block_ccw
->hdr
.len
= IPL_PARM_BLK_CCW_LEN
;
834 reipl_block_ccw
->hdr
.version
= IPL_PARM_BLOCK_VERSION
;
835 reipl_block_ccw
->hdr
.blk0_len
= sizeof(reipl_block_ccw
->ipl_info
.ccw
);
836 reipl_block_ccw
->hdr
.pbt
= DIAG308_IPL_TYPE_CCW
;
837 /* check if read scp info worked and set loadparm */
839 memcpy(reipl_block_ccw
->ipl_info
.ccw
.load_param
,
840 SCCB_LOADPARM
, LOADPARM_LEN
);
842 /* read scp info failed: set empty loadparm (EBCDIC blanks) */
843 memset(reipl_block_ccw
->ipl_info
.ccw
.load_param
, 0x40,
845 /* FIXME: check for diag308_set_works when enabling diag ccw reipl */
847 sys_reipl_ccw_loadparm_attr
.attr
.mode
= S_IRUGO
;
848 if (ipl_get_type() == IPL_TYPE_CCW
)
849 reipl_block_ccw
->ipl_info
.ccw
.devno
= ipl_devno
;
850 reipl_capabilities
|= IPL_TYPE_CCW
;
854 static int __init
reipl_fcp_init(void)
858 if ((!diag308_set_works
) && (ipl_get_type() != IPL_TYPE_FCP
))
860 if ((!diag308_set_works
) && (ipl_get_type() == IPL_TYPE_FCP
))
861 make_attrs_ro(reipl_fcp_attrs
);
863 reipl_block_fcp
= (void *) get_zeroed_page(GFP_KERNEL
);
864 if (!reipl_block_fcp
)
866 rc
= sysfs_create_group(&reipl_subsys
.kset
.kobj
, &reipl_fcp_attr_group
);
868 free_page((unsigned long)reipl_block_fcp
);
871 if (ipl_get_type() == IPL_TYPE_FCP
) {
872 memcpy(reipl_block_fcp
, IPL_PARMBLOCK_START
, PAGE_SIZE
);
874 reipl_block_fcp
->hdr
.len
= IPL_PARM_BLK_FCP_LEN
;
875 reipl_block_fcp
->hdr
.version
= IPL_PARM_BLOCK_VERSION
;
876 reipl_block_fcp
->hdr
.blk0_len
=
877 sizeof(reipl_block_fcp
->ipl_info
.fcp
);
878 reipl_block_fcp
->hdr
.pbt
= DIAG308_IPL_TYPE_FCP
;
879 reipl_block_fcp
->ipl_info
.fcp
.opt
= DIAG308_IPL_OPT_IPL
;
881 reipl_capabilities
|= IPL_TYPE_FCP
;
885 static int __init
reipl_init(void)
889 rc
= firmware_register(&reipl_subsys
);
892 rc
= subsys_create_file(&reipl_subsys
, &reipl_type_attr
);
894 firmware_unregister(&reipl_subsys
);
897 rc
= reipl_ccw_init();
900 rc
= reipl_fcp_init();
903 rc
= reipl_nss_init();
906 rc
= reipl_set_type(ipl_get_type());
912 static int __init
dump_ccw_init(void)
916 dump_block_ccw
= (void *) get_zeroed_page(GFP_KERNEL
);
919 rc
= sysfs_create_group(&dump_subsys
.kset
.kobj
, &dump_ccw_attr_group
);
921 free_page((unsigned long)dump_block_ccw
);
924 dump_block_ccw
->hdr
.len
= IPL_PARM_BLK_CCW_LEN
;
925 dump_block_ccw
->hdr
.version
= IPL_PARM_BLOCK_VERSION
;
926 dump_block_ccw
->hdr
.blk0_len
= sizeof(reipl_block_ccw
->ipl_info
.ccw
);
927 dump_block_ccw
->hdr
.pbt
= DIAG308_IPL_TYPE_CCW
;
928 dump_capabilities
|= IPL_TYPE_CCW
;
932 static int __init
dump_fcp_init(void)
936 if(!(SCCB_FLAG
& 0x2) || !SCCB_VALID
)
937 return 0; /* LDIPL DUMP is not installed */
938 if (!diag308_set_works
)
940 dump_block_fcp
= (void *) get_zeroed_page(GFP_KERNEL
);
943 rc
= sysfs_create_group(&dump_subsys
.kset
.kobj
, &dump_fcp_attr_group
);
945 free_page((unsigned long)dump_block_fcp
);
948 dump_block_fcp
->hdr
.len
= IPL_PARM_BLK_FCP_LEN
;
949 dump_block_fcp
->hdr
.version
= IPL_PARM_BLOCK_VERSION
;
950 dump_block_fcp
->hdr
.blk0_len
= sizeof(dump_block_fcp
->ipl_info
.fcp
);
951 dump_block_fcp
->hdr
.pbt
= DIAG308_IPL_TYPE_FCP
;
952 dump_block_fcp
->ipl_info
.fcp
.opt
= DIAG308_IPL_OPT_DUMP
;
953 dump_capabilities
|= IPL_TYPE_FCP
;
957 #define SHUTDOWN_ON_PANIC_PRIO 0
959 static int shutdown_on_panic_notify(struct notifier_block
*self
,
960 unsigned long event
, void *data
)
962 if (on_panic_action
== SHUTDOWN_DUMP
)
964 else if (on_panic_action
== SHUTDOWN_REIPL
)
969 static struct notifier_block shutdown_on_panic_nb
= {
970 .notifier_call
= shutdown_on_panic_notify
,
971 .priority
= SHUTDOWN_ON_PANIC_PRIO
974 static int __init
dump_init(void)
978 rc
= firmware_register(&dump_subsys
);
981 rc
= subsys_create_file(&dump_subsys
, &dump_type_attr
);
983 firmware_unregister(&dump_subsys
);
986 rc
= dump_ccw_init();
989 rc
= dump_fcp_init();
992 dump_set_type(IPL_TYPE_NONE
);
996 static int __init
shutdown_actions_init(void)
1000 rc
= firmware_register(&shutdown_actions_subsys
);
1003 rc
= subsys_create_file(&shutdown_actions_subsys
, &on_panic_attr
);
1005 firmware_unregister(&shutdown_actions_subsys
);
1008 atomic_notifier_chain_register(&panic_notifier_list
,
1009 &shutdown_on_panic_nb
);
1013 static int __init
s390_ipl_init(void)
1027 rc
= shutdown_actions_init();
1033 __initcall(s390_ipl_init
);
1035 static LIST_HEAD(rcall
);
1036 static DEFINE_MUTEX(rcall_mutex
);
1038 void register_reset_call(struct reset_call
*reset
)
1040 mutex_lock(&rcall_mutex
);
1041 list_add(&reset
->list
, &rcall
);
1042 mutex_unlock(&rcall_mutex
);
1044 EXPORT_SYMBOL_GPL(register_reset_call
);
1046 void unregister_reset_call(struct reset_call
*reset
)
1048 mutex_lock(&rcall_mutex
);
1049 list_del(&reset
->list
);
1050 mutex_unlock(&rcall_mutex
);
1052 EXPORT_SYMBOL_GPL(unregister_reset_call
);
1054 static void do_reset_calls(void)
1056 struct reset_call
*reset
;
1058 list_for_each_entry(reset
, &rcall
, list
)
1062 extern __u32 dump_prefix_page
;
1064 void s390_reset_system(void)
1066 struct _lowcore
*lc
;
1068 lc
= (struct _lowcore
*)(unsigned long) store_prefix();
1070 /* Stack for interrupt/machine check handler */
1071 lc
->panic_stack
= S390_lowcore
.panic_stack
;
1073 /* Save prefix page address for dump case */
1074 dump_prefix_page
= (unsigned long) lc
;
1076 /* Disable prefixing */
1079 /* Disable lowcore protection */
1080 __ctl_clear_bit(0,28);
1082 /* Set new machine check handler */
1083 S390_lowcore
.mcck_new_psw
.mask
= psw_kernel_bits
& ~PSW_MASK_MCHECK
;
1084 S390_lowcore
.mcck_new_psw
.addr
=
1085 PSW_ADDR_AMODE
| (unsigned long) s390_base_mcck_handler
;
1087 /* Set new program check handler */
1088 S390_lowcore
.program_new_psw
.mask
= psw_kernel_bits
& ~PSW_MASK_MCHECK
;
1089 S390_lowcore
.program_new_psw
.addr
=
1090 PSW_ADDR_AMODE
| (unsigned long) s390_base_pgm_handler
;