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"
47 * Must be in data section since the bss section
48 * is not cleared when these are accessed.
50 u16 ipl_devno
__attribute__((__section__(".data"))) = 0;
51 u32 ipl_flags
__attribute__((__section__(".data"))) = 0;
53 static char *ipl_type_str(enum ipl_type type
)
64 case IPL_TYPE_UNKNOWN
:
66 return IPL_UNKNOWN_STR
;
75 IPL_METHOD_FCP_RO_DIAG
,
76 IPL_METHOD_FCP_RW_DIAG
,
81 enum shutdown_action
{
87 #define SHUTDOWN_REIPL_STR "reipl"
88 #define SHUTDOWN_DUMP_STR "dump"
89 #define SHUTDOWN_STOP_STR "stop"
91 static char *shutdown_action_str(enum shutdown_action action
)
95 return SHUTDOWN_REIPL_STR
;
97 return SHUTDOWN_DUMP_STR
;
99 return SHUTDOWN_STOP_STR
;
105 static int diag308_set_works
= 0;
107 static int reipl_capabilities
= IPL_TYPE_UNKNOWN
;
109 static enum ipl_type reipl_type
= IPL_TYPE_UNKNOWN
;
110 static enum ipl_method reipl_method
= IPL_METHOD_NONE
;
111 static struct ipl_parameter_block
*reipl_block_fcp
;
112 static struct ipl_parameter_block
*reipl_block_ccw
;
114 static char reipl_nss_name
[NSS_NAME_SIZE
+ 1];
116 static int dump_capabilities
= IPL_TYPE_NONE
;
117 static enum ipl_type dump_type
= IPL_TYPE_NONE
;
118 static enum ipl_method dump_method
= IPL_METHOD_NONE
;
119 static struct ipl_parameter_block
*dump_block_fcp
;
120 static struct ipl_parameter_block
*dump_block_ccw
;
122 static enum shutdown_action on_panic_action
= SHUTDOWN_STOP
;
124 int diag308(unsigned long subcode
, void *addr
)
126 register unsigned long _addr
asm("0") = (unsigned long) addr
;
127 register unsigned long _rc
asm("1") = 0;
130 " diag %0,%2,0x308\n"
133 : "+d" (_addr
), "+d" (_rc
)
134 : "d" (subcode
) : "cc", "memory");
140 #define DEFINE_IPL_ATTR_RO(_prefix, _name, _format, _value) \
141 static ssize_t sys_##_prefix##_##_name##_show(struct subsystem *subsys, \
144 return sprintf(page, _format, _value); \
146 static struct subsys_attribute sys_##_prefix##_##_name##_attr = \
147 __ATTR(_name, S_IRUGO, sys_##_prefix##_##_name##_show, NULL);
149 #define DEFINE_IPL_ATTR_RW(_prefix, _name, _fmt_out, _fmt_in, _value) \
150 static ssize_t sys_##_prefix##_##_name##_show(struct subsystem *subsys, \
153 return sprintf(page, _fmt_out, \
154 (unsigned long long) _value); \
156 static ssize_t sys_##_prefix##_##_name##_store(struct subsystem *subsys,\
157 const char *buf, size_t len) \
159 unsigned long long value; \
160 if (sscanf(buf, _fmt_in, &value) != 1) \
165 static struct subsys_attribute sys_##_prefix##_##_name##_attr = \
166 __ATTR(_name,(S_IRUGO | S_IWUSR), \
167 sys_##_prefix##_##_name##_show, \
168 sys_##_prefix##_##_name##_store);
170 #define DEFINE_IPL_ATTR_STR_RW(_prefix, _name, _fmt_out, _fmt_in, _value)\
171 static ssize_t sys_##_prefix##_##_name##_show(struct subsystem *subsys, \
174 return sprintf(page, _fmt_out, _value); \
176 static ssize_t sys_##_prefix##_##_name##_store(struct subsystem *subsys,\
177 const char *buf, size_t len) \
179 if (sscanf(buf, _fmt_in, _value) != 1) \
183 static struct subsys_attribute sys_##_prefix##_##_name##_attr = \
184 __ATTR(_name,(S_IRUGO | S_IWUSR), \
185 sys_##_prefix##_##_name##_show, \
186 sys_##_prefix##_##_name##_store);
188 static void make_attrs_ro(struct attribute
**attrs
)
191 (*attrs
)->mode
= S_IRUGO
;
200 static enum ipl_type
ipl_get_type(void)
202 struct ipl_parameter_block
*ipl
= IPL_PARMBLOCK_START
;
204 if (ipl_flags
& IPL_NSS_VALID
)
206 if (!(ipl_flags
& IPL_DEVNO_VALID
))
207 return IPL_TYPE_UNKNOWN
;
208 if (!(ipl_flags
& IPL_PARMBLOCK_VALID
))
210 if (ipl
->hdr
.version
> IPL_MAX_SUPPORTED_VERSION
)
211 return IPL_TYPE_UNKNOWN
;
212 if (ipl
->hdr
.pbt
!= DIAG308_IPL_TYPE_FCP
)
213 return IPL_TYPE_UNKNOWN
;
217 static ssize_t
ipl_type_show(struct subsystem
*subsys
, char *page
)
219 return sprintf(page
, "%s\n", ipl_type_str(ipl_get_type()));
222 static struct subsys_attribute sys_ipl_type_attr
= __ATTR_RO(ipl_type
);
224 static ssize_t
sys_ipl_device_show(struct subsystem
*subsys
, char *page
)
226 struct ipl_parameter_block
*ipl
= IPL_PARMBLOCK_START
;
228 switch (ipl_get_type()) {
230 return sprintf(page
, "0.0.%04x\n", ipl_devno
);
232 return sprintf(page
, "0.0.%04x\n", ipl
->ipl_info
.fcp
.devno
);
238 static struct subsys_attribute sys_ipl_device_attr
=
239 __ATTR(device
, S_IRUGO
, sys_ipl_device_show
, NULL
);
241 static ssize_t
ipl_parameter_read(struct kobject
*kobj
, char *buf
, loff_t off
,
244 unsigned int size
= IPL_PARMBLOCK_SIZE
;
248 if (off
+ count
> size
)
250 memcpy(buf
, (void *)IPL_PARMBLOCK_START
+ off
, count
);
254 static struct bin_attribute ipl_parameter_attr
= {
256 .name
= "binary_parameter",
258 .owner
= THIS_MODULE
,
261 .read
= &ipl_parameter_read
,
264 static ssize_t
ipl_scp_data_read(struct kobject
*kobj
, char *buf
, loff_t off
,
267 unsigned int size
= IPL_PARMBLOCK_START
->ipl_info
.fcp
.scp_data_len
;
268 void *scp_data
= &IPL_PARMBLOCK_START
->ipl_info
.fcp
.scp_data
;
272 if (off
+ count
> size
)
274 memcpy(buf
, scp_data
+ off
, count
);
278 static struct bin_attribute ipl_scp_data_attr
= {
282 .owner
= THIS_MODULE
,
285 .read
= &ipl_scp_data_read
,
288 /* FCP ipl device attributes */
290 DEFINE_IPL_ATTR_RO(ipl_fcp
, wwpn
, "0x%016llx\n", (unsigned long long)
291 IPL_PARMBLOCK_START
->ipl_info
.fcp
.wwpn
);
292 DEFINE_IPL_ATTR_RO(ipl_fcp
, lun
, "0x%016llx\n", (unsigned long long)
293 IPL_PARMBLOCK_START
->ipl_info
.fcp
.lun
);
294 DEFINE_IPL_ATTR_RO(ipl_fcp
, bootprog
, "%lld\n", (unsigned long long)
295 IPL_PARMBLOCK_START
->ipl_info
.fcp
.bootprog
);
296 DEFINE_IPL_ATTR_RO(ipl_fcp
, br_lba
, "%lld\n", (unsigned long long)
297 IPL_PARMBLOCK_START
->ipl_info
.fcp
.br_lba
);
299 static struct attribute
*ipl_fcp_attrs
[] = {
300 &sys_ipl_type_attr
.attr
,
301 &sys_ipl_device_attr
.attr
,
302 &sys_ipl_fcp_wwpn_attr
.attr
,
303 &sys_ipl_fcp_lun_attr
.attr
,
304 &sys_ipl_fcp_bootprog_attr
.attr
,
305 &sys_ipl_fcp_br_lba_attr
.attr
,
309 static struct attribute_group ipl_fcp_attr_group
= {
310 .attrs
= ipl_fcp_attrs
,
313 /* CCW ipl device attributes */
315 static ssize_t
ipl_ccw_loadparm_show(struct subsystem
*subsys
, char *page
)
317 char loadparm
[LOADPARM_LEN
+ 1] = {};
320 return sprintf(page
, "#unknown#\n");
321 memcpy(loadparm
, SCCB_LOADPARM
, LOADPARM_LEN
);
322 EBCASC(loadparm
, LOADPARM_LEN
);
324 return sprintf(page
, "%s\n", loadparm
);
327 static struct subsys_attribute sys_ipl_ccw_loadparm_attr
=
328 __ATTR(loadparm
, 0444, ipl_ccw_loadparm_show
, NULL
);
330 static struct attribute
*ipl_ccw_attrs
[] = {
331 &sys_ipl_type_attr
.attr
,
332 &sys_ipl_device_attr
.attr
,
333 &sys_ipl_ccw_loadparm_attr
.attr
,
337 static struct attribute_group ipl_ccw_attr_group
= {
338 .attrs
= ipl_ccw_attrs
,
341 /* NSS ipl device attributes */
343 DEFINE_IPL_ATTR_RO(ipl_nss
, name
, "%s\n", kernel_nss_name
);
345 static struct attribute
*ipl_nss_attrs
[] = {
346 &sys_ipl_type_attr
.attr
,
347 &sys_ipl_nss_name_attr
.attr
,
351 static struct attribute_group ipl_nss_attr_group
= {
352 .attrs
= ipl_nss_attrs
,
355 /* UNKNOWN ipl device attributes */
357 static struct attribute
*ipl_unknown_attrs
[] = {
358 &sys_ipl_type_attr
.attr
,
362 static struct attribute_group ipl_unknown_attr_group
= {
363 .attrs
= ipl_unknown_attrs
,
366 static decl_subsys(ipl
, NULL
, NULL
);
372 /* FCP reipl device attributes */
374 DEFINE_IPL_ATTR_RW(reipl_fcp
, wwpn
, "0x%016llx\n", "%016llx\n",
375 reipl_block_fcp
->ipl_info
.fcp
.wwpn
);
376 DEFINE_IPL_ATTR_RW(reipl_fcp
, lun
, "0x%016llx\n", "%016llx\n",
377 reipl_block_fcp
->ipl_info
.fcp
.lun
);
378 DEFINE_IPL_ATTR_RW(reipl_fcp
, bootprog
, "%lld\n", "%lld\n",
379 reipl_block_fcp
->ipl_info
.fcp
.bootprog
);
380 DEFINE_IPL_ATTR_RW(reipl_fcp
, br_lba
, "%lld\n", "%lld\n",
381 reipl_block_fcp
->ipl_info
.fcp
.br_lba
);
382 DEFINE_IPL_ATTR_RW(reipl_fcp
, device
, "0.0.%04llx\n", "0.0.%llx\n",
383 reipl_block_fcp
->ipl_info
.fcp
.devno
);
385 static struct attribute
*reipl_fcp_attrs
[] = {
386 &sys_reipl_fcp_device_attr
.attr
,
387 &sys_reipl_fcp_wwpn_attr
.attr
,
388 &sys_reipl_fcp_lun_attr
.attr
,
389 &sys_reipl_fcp_bootprog_attr
.attr
,
390 &sys_reipl_fcp_br_lba_attr
.attr
,
394 static struct attribute_group reipl_fcp_attr_group
= {
396 .attrs
= reipl_fcp_attrs
,
399 /* CCW reipl device attributes */
401 DEFINE_IPL_ATTR_RW(reipl_ccw
, device
, "0.0.%04llx\n", "0.0.%llx\n",
402 reipl_block_ccw
->ipl_info
.ccw
.devno
);
404 static void reipl_get_ascii_loadparm(char *loadparm
)
406 memcpy(loadparm
, &reipl_block_ccw
->ipl_info
.ccw
.load_param
,
408 EBCASC(loadparm
, LOADPARM_LEN
);
409 loadparm
[LOADPARM_LEN
] = 0;
413 static ssize_t
reipl_ccw_loadparm_show(struct subsystem
*subsys
, char *page
)
415 char buf
[LOADPARM_LEN
+ 1];
417 reipl_get_ascii_loadparm(buf
);
418 return sprintf(page
, "%s\n", buf
);
421 static ssize_t
reipl_ccw_loadparm_store(struct subsystem
*subsys
,
422 const char *buf
, size_t len
)
426 /* ignore trailing newline */
428 if ((len
> 0) && (buf
[len
- 1] == '\n'))
430 /* loadparm can have max 8 characters and must not start with a blank */
431 if ((lp_len
> LOADPARM_LEN
) || ((lp_len
> 0) && (buf
[0] == ' ')))
433 /* loadparm can only contain "a-z,A-Z,0-9,SP,." */
434 for (i
= 0; i
< lp_len
; i
++) {
435 if (isalpha(buf
[i
]) || isdigit(buf
[i
]) || (buf
[i
] == ' ') ||
440 /* initialize loadparm with blanks */
441 memset(&reipl_block_ccw
->ipl_info
.ccw
.load_param
, ' ', LOADPARM_LEN
);
442 /* copy and convert to ebcdic */
443 memcpy(&reipl_block_ccw
->ipl_info
.ccw
.load_param
, buf
, lp_len
);
444 ASCEBC(reipl_block_ccw
->ipl_info
.ccw
.load_param
, LOADPARM_LEN
);
448 static struct subsys_attribute sys_reipl_ccw_loadparm_attr
=
449 __ATTR(loadparm
, 0644, reipl_ccw_loadparm_show
,
450 reipl_ccw_loadparm_store
);
452 static struct attribute
*reipl_ccw_attrs
[] = {
453 &sys_reipl_ccw_device_attr
.attr
,
454 &sys_reipl_ccw_loadparm_attr
.attr
,
458 static struct attribute_group reipl_ccw_attr_group
= {
460 .attrs
= reipl_ccw_attrs
,
464 /* NSS reipl device attributes */
466 DEFINE_IPL_ATTR_STR_RW(reipl_nss
, name
, "%s\n", "%s\n", reipl_nss_name
);
468 static struct attribute
*reipl_nss_attrs
[] = {
469 &sys_reipl_nss_name_attr
.attr
,
473 static struct attribute_group reipl_nss_attr_group
= {
475 .attrs
= reipl_nss_attrs
,
480 static int reipl_set_type(enum ipl_type type
)
482 if (!(reipl_capabilities
& type
))
488 reipl_method
= IPL_METHOD_CCW_VM
;
490 reipl_method
= IPL_METHOD_CCW_CIO
;
493 if (diag308_set_works
)
494 reipl_method
= IPL_METHOD_FCP_RW_DIAG
;
495 else if (MACHINE_IS_VM
)
496 reipl_method
= IPL_METHOD_FCP_RO_VM
;
498 reipl_method
= IPL_METHOD_FCP_RO_DIAG
;
501 reipl_method
= IPL_METHOD_NSS
;
504 reipl_method
= IPL_METHOD_NONE
;
510 static ssize_t
reipl_type_show(struct subsystem
*subsys
, char *page
)
512 return sprintf(page
, "%s\n", ipl_type_str(reipl_type
));
515 static ssize_t
reipl_type_store(struct subsystem
*subsys
, const char *buf
,
520 if (strncmp(buf
, IPL_CCW_STR
, strlen(IPL_CCW_STR
)) == 0)
521 rc
= reipl_set_type(IPL_TYPE_CCW
);
522 else if (strncmp(buf
, IPL_FCP_STR
, strlen(IPL_FCP_STR
)) == 0)
523 rc
= reipl_set_type(IPL_TYPE_FCP
);
524 else if (strncmp(buf
, IPL_NSS_STR
, strlen(IPL_NSS_STR
)) == 0)
525 rc
= reipl_set_type(IPL_TYPE_NSS
);
526 return (rc
!= 0) ? rc
: len
;
529 static struct subsys_attribute reipl_type_attr
=
530 __ATTR(reipl_type
, 0644, reipl_type_show
, reipl_type_store
);
532 static decl_subsys(reipl
, NULL
, NULL
);
538 /* FCP dump device attributes */
540 DEFINE_IPL_ATTR_RW(dump_fcp
, wwpn
, "0x%016llx\n", "%016llx\n",
541 dump_block_fcp
->ipl_info
.fcp
.wwpn
);
542 DEFINE_IPL_ATTR_RW(dump_fcp
, lun
, "0x%016llx\n", "%016llx\n",
543 dump_block_fcp
->ipl_info
.fcp
.lun
);
544 DEFINE_IPL_ATTR_RW(dump_fcp
, bootprog
, "%lld\n", "%lld\n",
545 dump_block_fcp
->ipl_info
.fcp
.bootprog
);
546 DEFINE_IPL_ATTR_RW(dump_fcp
, br_lba
, "%lld\n", "%lld\n",
547 dump_block_fcp
->ipl_info
.fcp
.br_lba
);
548 DEFINE_IPL_ATTR_RW(dump_fcp
, device
, "0.0.%04llx\n", "0.0.%llx\n",
549 dump_block_fcp
->ipl_info
.fcp
.devno
);
551 static struct attribute
*dump_fcp_attrs
[] = {
552 &sys_dump_fcp_device_attr
.attr
,
553 &sys_dump_fcp_wwpn_attr
.attr
,
554 &sys_dump_fcp_lun_attr
.attr
,
555 &sys_dump_fcp_bootprog_attr
.attr
,
556 &sys_dump_fcp_br_lba_attr
.attr
,
560 static struct attribute_group dump_fcp_attr_group
= {
562 .attrs
= dump_fcp_attrs
,
565 /* CCW dump device attributes */
567 DEFINE_IPL_ATTR_RW(dump_ccw
, device
, "0.0.%04llx\n", "0.0.%llx\n",
568 dump_block_ccw
->ipl_info
.ccw
.devno
);
570 static struct attribute
*dump_ccw_attrs
[] = {
571 &sys_dump_ccw_device_attr
.attr
,
575 static struct attribute_group dump_ccw_attr_group
= {
577 .attrs
= dump_ccw_attrs
,
582 static int dump_set_type(enum ipl_type type
)
584 if (!(dump_capabilities
& type
))
589 dump_method
= IPL_METHOD_CCW_VM
;
591 dump_method
= IPL_METHOD_CCW_CIO
;
594 dump_method
= IPL_METHOD_FCP_RW_DIAG
;
597 dump_method
= IPL_METHOD_NONE
;
603 static ssize_t
dump_type_show(struct subsystem
*subsys
, char *page
)
605 return sprintf(page
, "%s\n", ipl_type_str(dump_type
));
608 static ssize_t
dump_type_store(struct subsystem
*subsys
, const char *buf
,
613 if (strncmp(buf
, IPL_NONE_STR
, strlen(IPL_NONE_STR
)) == 0)
614 rc
= dump_set_type(IPL_TYPE_NONE
);
615 else if (strncmp(buf
, IPL_CCW_STR
, strlen(IPL_CCW_STR
)) == 0)
616 rc
= dump_set_type(IPL_TYPE_CCW
);
617 else if (strncmp(buf
, IPL_FCP_STR
, strlen(IPL_FCP_STR
)) == 0)
618 rc
= dump_set_type(IPL_TYPE_FCP
);
619 return (rc
!= 0) ? rc
: len
;
622 static struct subsys_attribute dump_type_attr
=
623 __ATTR(dump_type
, 0644, dump_type_show
, dump_type_store
);
625 static decl_subsys(dump
, NULL
, NULL
);
628 * Shutdown actions section
631 static decl_subsys(shutdown_actions
, NULL
, NULL
);
635 static ssize_t
on_panic_show(struct subsystem
*subsys
, char *page
)
637 return sprintf(page
, "%s\n", shutdown_action_str(on_panic_action
));
640 static ssize_t
on_panic_store(struct subsystem
*subsys
, const char *buf
,
643 if (strncmp(buf
, SHUTDOWN_REIPL_STR
, strlen(SHUTDOWN_REIPL_STR
)) == 0)
644 on_panic_action
= SHUTDOWN_REIPL
;
645 else if (strncmp(buf
, SHUTDOWN_DUMP_STR
,
646 strlen(SHUTDOWN_DUMP_STR
)) == 0)
647 on_panic_action
= SHUTDOWN_DUMP
;
648 else if (strncmp(buf
, SHUTDOWN_STOP_STR
,
649 strlen(SHUTDOWN_STOP_STR
)) == 0)
650 on_panic_action
= SHUTDOWN_STOP
;
657 static struct subsys_attribute on_panic_attr
=
658 __ATTR(on_panic
, 0644, on_panic_show
, on_panic_store
);
662 struct ccw_dev_id devid
;
663 static char buf
[100];
664 char loadparm
[LOADPARM_LEN
+ 1];
666 switch (reipl_method
) {
667 case IPL_METHOD_CCW_CIO
:
668 devid
.devno
= reipl_block_ccw
->ipl_info
.ccw
.devno
;
669 if (ipl_get_type() == IPL_TYPE_CCW
&& devid
.devno
== ipl_devno
)
670 diag308(DIAG308_IPL
, NULL
);
672 reipl_ccw_dev(&devid
);
674 case IPL_METHOD_CCW_VM
:
675 reipl_get_ascii_loadparm(loadparm
);
676 if (strlen(loadparm
) == 0)
677 sprintf(buf
, "IPL %X",
678 reipl_block_ccw
->ipl_info
.ccw
.devno
);
680 sprintf(buf
, "IPL %X LOADPARM '%s'",
681 reipl_block_ccw
->ipl_info
.ccw
.devno
, loadparm
);
682 __cpcmd(buf
, NULL
, 0, NULL
);
684 case IPL_METHOD_CCW_DIAG
:
685 diag308(DIAG308_SET
, reipl_block_ccw
);
686 diag308(DIAG308_IPL
, NULL
);
688 case IPL_METHOD_FCP_RW_DIAG
:
689 diag308(DIAG308_SET
, reipl_block_fcp
);
690 diag308(DIAG308_IPL
, NULL
);
692 case IPL_METHOD_FCP_RO_DIAG
:
693 diag308(DIAG308_IPL
, NULL
);
695 case IPL_METHOD_FCP_RO_VM
:
696 __cpcmd("IPL", NULL
, 0, NULL
);
699 sprintf(buf
, "IPL %s", reipl_nss_name
);
700 __cpcmd(buf
, NULL
, 0, NULL
);
702 case IPL_METHOD_NONE
:
705 __cpcmd("IPL", NULL
, 0, NULL
);
706 diag308(DIAG308_IPL
, NULL
);
709 signal_processor(smp_processor_id(), sigp_stop_and_store_status
);
712 static void do_dump(void)
714 struct ccw_dev_id devid
;
715 static char buf
[100];
717 switch (dump_method
) {
718 case IPL_METHOD_CCW_CIO
:
720 devid
.devno
= dump_block_ccw
->ipl_info
.ccw
.devno
;
722 reipl_ccw_dev(&devid
);
724 case IPL_METHOD_CCW_VM
:
726 sprintf(buf
, "STORE STATUS");
727 __cpcmd(buf
, NULL
, 0, NULL
);
728 sprintf(buf
, "IPL %X", dump_block_ccw
->ipl_info
.ccw
.devno
);
729 __cpcmd(buf
, NULL
, 0, NULL
);
731 case IPL_METHOD_CCW_DIAG
:
732 diag308(DIAG308_SET
, dump_block_ccw
);
733 diag308(DIAG308_DUMP
, NULL
);
735 case IPL_METHOD_FCP_RW_DIAG
:
736 diag308(DIAG308_SET
, dump_block_fcp
);
737 diag308(DIAG308_DUMP
, NULL
);
739 case IPL_METHOD_NONE
:
743 printk(KERN_EMERG
"Dump failed!\n");
748 static int __init
ipl_register_fcp_files(void)
752 rc
= sysfs_create_group(&ipl_subsys
.kset
.kobj
,
753 &ipl_fcp_attr_group
);
756 rc
= sysfs_create_bin_file(&ipl_subsys
.kset
.kobj
,
757 &ipl_parameter_attr
);
760 rc
= sysfs_create_bin_file(&ipl_subsys
.kset
.kobj
,
765 sysfs_remove_bin_file(&ipl_subsys
.kset
.kobj
, &ipl_parameter_attr
);
768 sysfs_remove_group(&ipl_subsys
.kset
.kobj
, &ipl_fcp_attr_group
);
773 static int __init
ipl_init(void)
777 rc
= firmware_register(&ipl_subsys
);
780 switch (ipl_get_type()) {
782 rc
= sysfs_create_group(&ipl_subsys
.kset
.kobj
,
783 &ipl_ccw_attr_group
);
786 rc
= ipl_register_fcp_files();
789 rc
= sysfs_create_group(&ipl_subsys
.kset
.kobj
,
790 &ipl_nss_attr_group
);
793 rc
= sysfs_create_group(&ipl_subsys
.kset
.kobj
,
794 &ipl_unknown_attr_group
);
798 firmware_unregister(&ipl_subsys
);
802 static void __init
reipl_probe(void)
806 buffer
= (void *) get_zeroed_page(GFP_KERNEL
);
809 if (diag308(DIAG308_STORE
, buffer
) == DIAG308_RC_OK
)
810 diag308_set_works
= 1;
811 free_page((unsigned long)buffer
);
814 static int __init
reipl_nss_init(void)
820 rc
= sysfs_create_group(&reipl_subsys
.kset
.kobj
, &reipl_nss_attr_group
);
823 strncpy(reipl_nss_name
, kernel_nss_name
, NSS_NAME_SIZE
+ 1);
824 reipl_capabilities
|= IPL_TYPE_NSS
;
828 static int __init
reipl_ccw_init(void)
832 reipl_block_ccw
= (void *) get_zeroed_page(GFP_KERNEL
);
833 if (!reipl_block_ccw
)
835 rc
= sysfs_create_group(&reipl_subsys
.kset
.kobj
, &reipl_ccw_attr_group
);
837 free_page((unsigned long)reipl_block_ccw
);
840 reipl_block_ccw
->hdr
.len
= IPL_PARM_BLK_CCW_LEN
;
841 reipl_block_ccw
->hdr
.version
= IPL_PARM_BLOCK_VERSION
;
842 reipl_block_ccw
->hdr
.blk0_len
= sizeof(reipl_block_ccw
->ipl_info
.ccw
);
843 reipl_block_ccw
->hdr
.pbt
= DIAG308_IPL_TYPE_CCW
;
844 /* check if read scp info worked and set loadparm */
846 memcpy(reipl_block_ccw
->ipl_info
.ccw
.load_param
,
847 SCCB_LOADPARM
, LOADPARM_LEN
);
849 /* read scp info failed: set empty loadparm (EBCDIC blanks) */
850 memset(reipl_block_ccw
->ipl_info
.ccw
.load_param
, 0x40,
852 /* FIXME: check for diag308_set_works when enabling diag ccw reipl */
854 sys_reipl_ccw_loadparm_attr
.attr
.mode
= S_IRUGO
;
855 if (ipl_get_type() == IPL_TYPE_CCW
)
856 reipl_block_ccw
->ipl_info
.ccw
.devno
= ipl_devno
;
857 reipl_capabilities
|= IPL_TYPE_CCW
;
861 static int __init
reipl_fcp_init(void)
865 if ((!diag308_set_works
) && (ipl_get_type() != IPL_TYPE_FCP
))
867 if ((!diag308_set_works
) && (ipl_get_type() == IPL_TYPE_FCP
))
868 make_attrs_ro(reipl_fcp_attrs
);
870 reipl_block_fcp
= (void *) get_zeroed_page(GFP_KERNEL
);
871 if (!reipl_block_fcp
)
873 rc
= sysfs_create_group(&reipl_subsys
.kset
.kobj
, &reipl_fcp_attr_group
);
875 free_page((unsigned long)reipl_block_fcp
);
878 if (ipl_get_type() == IPL_TYPE_FCP
) {
879 memcpy(reipl_block_fcp
, IPL_PARMBLOCK_START
, PAGE_SIZE
);
881 reipl_block_fcp
->hdr
.len
= IPL_PARM_BLK_FCP_LEN
;
882 reipl_block_fcp
->hdr
.version
= IPL_PARM_BLOCK_VERSION
;
883 reipl_block_fcp
->hdr
.blk0_len
=
884 sizeof(reipl_block_fcp
->ipl_info
.fcp
);
885 reipl_block_fcp
->hdr
.pbt
= DIAG308_IPL_TYPE_FCP
;
886 reipl_block_fcp
->ipl_info
.fcp
.opt
= DIAG308_IPL_OPT_IPL
;
888 reipl_capabilities
|= IPL_TYPE_FCP
;
892 static int __init
reipl_init(void)
896 rc
= firmware_register(&reipl_subsys
);
899 rc
= subsys_create_file(&reipl_subsys
, &reipl_type_attr
);
901 firmware_unregister(&reipl_subsys
);
904 rc
= reipl_ccw_init();
907 rc
= reipl_fcp_init();
910 rc
= reipl_nss_init();
913 rc
= reipl_set_type(ipl_get_type());
919 static int __init
dump_ccw_init(void)
923 dump_block_ccw
= (void *) get_zeroed_page(GFP_KERNEL
);
926 rc
= sysfs_create_group(&dump_subsys
.kset
.kobj
, &dump_ccw_attr_group
);
928 free_page((unsigned long)dump_block_ccw
);
931 dump_block_ccw
->hdr
.len
= IPL_PARM_BLK_CCW_LEN
;
932 dump_block_ccw
->hdr
.version
= IPL_PARM_BLOCK_VERSION
;
933 dump_block_ccw
->hdr
.blk0_len
= sizeof(reipl_block_ccw
->ipl_info
.ccw
);
934 dump_block_ccw
->hdr
.pbt
= DIAG308_IPL_TYPE_CCW
;
935 dump_capabilities
|= IPL_TYPE_CCW
;
939 static int __init
dump_fcp_init(void)
943 if(!(SCCB_FLAG
& 0x2) || !SCCB_VALID
)
944 return 0; /* LDIPL DUMP is not installed */
945 if (!diag308_set_works
)
947 dump_block_fcp
= (void *) get_zeroed_page(GFP_KERNEL
);
950 rc
= sysfs_create_group(&dump_subsys
.kset
.kobj
, &dump_fcp_attr_group
);
952 free_page((unsigned long)dump_block_fcp
);
955 dump_block_fcp
->hdr
.len
= IPL_PARM_BLK_FCP_LEN
;
956 dump_block_fcp
->hdr
.version
= IPL_PARM_BLOCK_VERSION
;
957 dump_block_fcp
->hdr
.blk0_len
= sizeof(dump_block_fcp
->ipl_info
.fcp
);
958 dump_block_fcp
->hdr
.pbt
= DIAG308_IPL_TYPE_FCP
;
959 dump_block_fcp
->ipl_info
.fcp
.opt
= DIAG308_IPL_OPT_DUMP
;
960 dump_capabilities
|= IPL_TYPE_FCP
;
964 #define SHUTDOWN_ON_PANIC_PRIO 0
966 static int shutdown_on_panic_notify(struct notifier_block
*self
,
967 unsigned long event
, void *data
)
969 if (on_panic_action
== SHUTDOWN_DUMP
)
971 else if (on_panic_action
== SHUTDOWN_REIPL
)
976 static struct notifier_block shutdown_on_panic_nb
= {
977 .notifier_call
= shutdown_on_panic_notify
,
978 .priority
= SHUTDOWN_ON_PANIC_PRIO
981 static int __init
dump_init(void)
985 rc
= firmware_register(&dump_subsys
);
988 rc
= subsys_create_file(&dump_subsys
, &dump_type_attr
);
990 firmware_unregister(&dump_subsys
);
993 rc
= dump_ccw_init();
996 rc
= dump_fcp_init();
999 dump_set_type(IPL_TYPE_NONE
);
1003 static int __init
shutdown_actions_init(void)
1007 rc
= firmware_register(&shutdown_actions_subsys
);
1010 rc
= subsys_create_file(&shutdown_actions_subsys
, &on_panic_attr
);
1012 firmware_unregister(&shutdown_actions_subsys
);
1015 atomic_notifier_chain_register(&panic_notifier_list
,
1016 &shutdown_on_panic_nb
);
1020 static int __init
s390_ipl_init(void)
1034 rc
= shutdown_actions_init();
1040 __initcall(s390_ipl_init
);
1042 static LIST_HEAD(rcall
);
1043 static DEFINE_MUTEX(rcall_mutex
);
1045 void register_reset_call(struct reset_call
*reset
)
1047 mutex_lock(&rcall_mutex
);
1048 list_add(&reset
->list
, &rcall
);
1049 mutex_unlock(&rcall_mutex
);
1051 EXPORT_SYMBOL_GPL(register_reset_call
);
1053 void unregister_reset_call(struct reset_call
*reset
)
1055 mutex_lock(&rcall_mutex
);
1056 list_del(&reset
->list
);
1057 mutex_unlock(&rcall_mutex
);
1059 EXPORT_SYMBOL_GPL(unregister_reset_call
);
1061 static void do_reset_calls(void)
1063 struct reset_call
*reset
;
1065 list_for_each_entry(reset
, &rcall
, list
)
1069 extern __u32 dump_prefix_page
;
1071 void s390_reset_system(void)
1073 struct _lowcore
*lc
;
1075 lc
= (struct _lowcore
*)(unsigned long) store_prefix();
1077 /* Stack for interrupt/machine check handler */
1078 lc
->panic_stack
= S390_lowcore
.panic_stack
;
1080 /* Save prefix page address for dump case */
1081 dump_prefix_page
= (unsigned long) lc
;
1083 /* Disable prefixing */
1086 /* Disable lowcore protection */
1087 __ctl_clear_bit(0,28);
1089 /* Set new machine check handler */
1090 S390_lowcore
.mcck_new_psw
.mask
= psw_kernel_bits
& ~PSW_MASK_MCHECK
;
1091 S390_lowcore
.mcck_new_psw
.addr
=
1092 PSW_ADDR_AMODE
| (unsigned long) s390_base_mcck_handler
;
1094 /* Set new program check handler */
1095 S390_lowcore
.program_new_psw
.mask
= psw_kernel_bits
& ~PSW_MASK_MCHECK
;
1096 S390_lowcore
.program_new_psw
.addr
=
1097 PSW_ADDR_AMODE
| (unsigned long) s390_base_pgm_handler
;