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 IPL_UNKNOWN_STR "unknown"
29 #define IPL_CCW_STR "ccw"
30 #define IPL_FCP_STR "fcp"
31 #define IPL_FCP_DUMP_STR "fcp_dump"
32 #define IPL_NSS_STR "nss"
34 static char *ipl_type_str(enum ipl_type type
)
41 case IPL_TYPE_FCP_DUMP
:
42 return IPL_FCP_DUMP_STR
;
45 case IPL_TYPE_UNKNOWN
:
47 return IPL_UNKNOWN_STR
;
57 #define DUMP_NONE_STR "none"
58 #define DUMP_CCW_STR "ccw"
59 #define DUMP_FCP_STR "fcp"
61 static char *dump_type_str(enum dump_type type
)
76 * Must be in data section since the bss section
77 * is not cleared when these are accessed.
79 static u16 ipl_devno
__attribute__((__section__(".data"))) = 0;
80 u32 ipl_flags
__attribute__((__section__(".data"))) = 0;
84 REIPL_METHOD_CCW_DIAG
,
86 REIPL_METHOD_FCP_RO_DIAG
,
87 REIPL_METHOD_FCP_RW_DIAG
,
88 REIPL_METHOD_FCP_RO_VM
,
89 REIPL_METHOD_FCP_DUMP
,
102 enum shutdown_action
{
108 #define SHUTDOWN_REIPL_STR "reipl"
109 #define SHUTDOWN_DUMP_STR "dump"
110 #define SHUTDOWN_STOP_STR "stop"
112 static char *shutdown_action_str(enum shutdown_action action
)
116 return SHUTDOWN_REIPL_STR
;
118 return SHUTDOWN_DUMP_STR
;
120 return SHUTDOWN_STOP_STR
;
126 static int diag308_set_works
= 0;
128 static int reipl_capabilities
= IPL_TYPE_UNKNOWN
;
130 static enum ipl_type reipl_type
= IPL_TYPE_UNKNOWN
;
131 static enum ipl_method reipl_method
= REIPL_METHOD_DEFAULT
;
132 static struct ipl_parameter_block
*reipl_block_fcp
;
133 static struct ipl_parameter_block
*reipl_block_ccw
;
135 static char reipl_nss_name
[NSS_NAME_SIZE
+ 1];
137 static int dump_capabilities
= DUMP_TYPE_NONE
;
138 static enum dump_type dump_type
= DUMP_TYPE_NONE
;
139 static enum dump_method dump_method
= DUMP_METHOD_NONE
;
140 static struct ipl_parameter_block
*dump_block_fcp
;
141 static struct ipl_parameter_block
*dump_block_ccw
;
143 static enum shutdown_action on_panic_action
= SHUTDOWN_STOP
;
145 static struct sclp_ipl_info sclp_ipl_info
;
147 int diag308(unsigned long subcode
, void *addr
)
149 register unsigned long _addr
asm("0") = (unsigned long) addr
;
150 register unsigned long _rc
asm("1") = 0;
153 " diag %0,%2,0x308\n"
156 : "+d" (_addr
), "+d" (_rc
)
157 : "d" (subcode
) : "cc", "memory");
160 EXPORT_SYMBOL_GPL(diag308
);
164 #define DEFINE_IPL_ATTR_RO(_prefix, _name, _format, _value) \
165 static ssize_t sys_##_prefix##_##_name##_show(struct kset *kset, \
168 return sprintf(page, _format, _value); \
170 static struct subsys_attribute sys_##_prefix##_##_name##_attr = \
171 __ATTR(_name, S_IRUGO, sys_##_prefix##_##_name##_show, NULL);
173 #define DEFINE_IPL_ATTR_RW(_prefix, _name, _fmt_out, _fmt_in, _value) \
174 static ssize_t sys_##_prefix##_##_name##_show(struct kset *kset, \
177 return sprintf(page, _fmt_out, \
178 (unsigned long long) _value); \
180 static ssize_t sys_##_prefix##_##_name##_store(struct kset *kset, \
181 const char *buf, size_t len) \
183 unsigned long long value; \
184 if (sscanf(buf, _fmt_in, &value) != 1) \
189 static struct subsys_attribute sys_##_prefix##_##_name##_attr = \
190 __ATTR(_name,(S_IRUGO | S_IWUSR), \
191 sys_##_prefix##_##_name##_show, \
192 sys_##_prefix##_##_name##_store);
194 #define DEFINE_IPL_ATTR_STR_RW(_prefix, _name, _fmt_out, _fmt_in, _value)\
195 static ssize_t sys_##_prefix##_##_name##_show(struct kset *kset, \
198 return sprintf(page, _fmt_out, _value); \
200 static ssize_t sys_##_prefix##_##_name##_store(struct kset *kset, \
201 const char *buf, size_t len) \
203 if (sscanf(buf, _fmt_in, _value) != 1) \
207 static struct subsys_attribute sys_##_prefix##_##_name##_attr = \
208 __ATTR(_name,(S_IRUGO | S_IWUSR), \
209 sys_##_prefix##_##_name##_show, \
210 sys_##_prefix##_##_name##_store);
212 static void make_attrs_ro(struct attribute
**attrs
)
215 (*attrs
)->mode
= S_IRUGO
;
224 static __init
enum ipl_type
get_ipl_type(void)
226 struct ipl_parameter_block
*ipl
= IPL_PARMBLOCK_START
;
228 if (ipl_flags
& IPL_NSS_VALID
)
230 if (!(ipl_flags
& IPL_DEVNO_VALID
))
231 return IPL_TYPE_UNKNOWN
;
232 if (!(ipl_flags
& IPL_PARMBLOCK_VALID
))
234 if (ipl
->hdr
.version
> IPL_MAX_SUPPORTED_VERSION
)
235 return IPL_TYPE_UNKNOWN
;
236 if (ipl
->hdr
.pbt
!= DIAG308_IPL_TYPE_FCP
)
237 return IPL_TYPE_UNKNOWN
;
238 if (ipl
->ipl_info
.fcp
.opt
== DIAG308_IPL_OPT_DUMP
)
239 return IPL_TYPE_FCP_DUMP
;
243 void __init
setup_ipl_info(void)
245 ipl_info
.type
= get_ipl_type();
246 switch (ipl_info
.type
) {
248 ipl_info
.data
.ccw
.dev_id
.devno
= ipl_devno
;
249 ipl_info
.data
.ccw
.dev_id
.ssid
= 0;
252 case IPL_TYPE_FCP_DUMP
:
253 ipl_info
.data
.fcp
.dev_id
.devno
=
254 IPL_PARMBLOCK_START
->ipl_info
.fcp
.devno
;
255 ipl_info
.data
.fcp
.dev_id
.ssid
= 0;
256 ipl_info
.data
.fcp
.wwpn
= IPL_PARMBLOCK_START
->ipl_info
.fcp
.wwpn
;
257 ipl_info
.data
.fcp
.lun
= IPL_PARMBLOCK_START
->ipl_info
.fcp
.lun
;
260 strncpy(ipl_info
.data
.nss
.name
, kernel_nss_name
,
261 sizeof(ipl_info
.data
.nss
.name
));
263 case IPL_TYPE_UNKNOWN
:
265 /* We have no info to copy */
270 struct ipl_info ipl_info
;
271 EXPORT_SYMBOL_GPL(ipl_info
);
273 static ssize_t
ipl_type_show(struct kset
*kset
, char *page
)
275 return sprintf(page
, "%s\n", ipl_type_str(ipl_info
.type
));
278 static struct subsys_attribute sys_ipl_type_attr
= __ATTR_RO(ipl_type
);
280 static ssize_t
sys_ipl_device_show(struct kset
*kset
, char *page
)
282 struct ipl_parameter_block
*ipl
= IPL_PARMBLOCK_START
;
284 switch (ipl_info
.type
) {
286 return sprintf(page
, "0.0.%04x\n", ipl_devno
);
288 case IPL_TYPE_FCP_DUMP
:
289 return sprintf(page
, "0.0.%04x\n", ipl
->ipl_info
.fcp
.devno
);
295 static struct subsys_attribute sys_ipl_device_attr
=
296 __ATTR(device
, S_IRUGO
, sys_ipl_device_show
, NULL
);
298 static ssize_t
ipl_parameter_read(struct kobject
*kobj
, struct bin_attribute
*attr
,
299 char *buf
, loff_t off
, size_t count
)
301 unsigned int size
= IPL_PARMBLOCK_SIZE
;
305 if (off
+ count
> size
)
307 memcpy(buf
, (void *)IPL_PARMBLOCK_START
+ off
, count
);
311 static struct bin_attribute ipl_parameter_attr
= {
313 .name
= "binary_parameter",
317 .read
= &ipl_parameter_read
,
320 static ssize_t
ipl_scp_data_read(struct kobject
*kobj
, struct bin_attribute
*attr
,
321 char *buf
, loff_t off
, size_t count
)
323 unsigned int size
= IPL_PARMBLOCK_START
->ipl_info
.fcp
.scp_data_len
;
324 void *scp_data
= &IPL_PARMBLOCK_START
->ipl_info
.fcp
.scp_data
;
328 if (off
+ count
> size
)
330 memcpy(buf
, scp_data
+ off
, count
);
334 static struct bin_attribute ipl_scp_data_attr
= {
340 .read
= ipl_scp_data_read
,
343 /* FCP ipl device attributes */
345 DEFINE_IPL_ATTR_RO(ipl_fcp
, wwpn
, "0x%016llx\n", (unsigned long long)
346 IPL_PARMBLOCK_START
->ipl_info
.fcp
.wwpn
);
347 DEFINE_IPL_ATTR_RO(ipl_fcp
, lun
, "0x%016llx\n", (unsigned long long)
348 IPL_PARMBLOCK_START
->ipl_info
.fcp
.lun
);
349 DEFINE_IPL_ATTR_RO(ipl_fcp
, bootprog
, "%lld\n", (unsigned long long)
350 IPL_PARMBLOCK_START
->ipl_info
.fcp
.bootprog
);
351 DEFINE_IPL_ATTR_RO(ipl_fcp
, br_lba
, "%lld\n", (unsigned long long)
352 IPL_PARMBLOCK_START
->ipl_info
.fcp
.br_lba
);
354 static struct attribute
*ipl_fcp_attrs
[] = {
355 &sys_ipl_type_attr
.attr
,
356 &sys_ipl_device_attr
.attr
,
357 &sys_ipl_fcp_wwpn_attr
.attr
,
358 &sys_ipl_fcp_lun_attr
.attr
,
359 &sys_ipl_fcp_bootprog_attr
.attr
,
360 &sys_ipl_fcp_br_lba_attr
.attr
,
364 static struct attribute_group ipl_fcp_attr_group
= {
365 .attrs
= ipl_fcp_attrs
,
368 /* CCW ipl device attributes */
370 static ssize_t
ipl_ccw_loadparm_show(struct kset
*kset
, char *page
)
372 char loadparm
[LOADPARM_LEN
+ 1] = {};
374 if (!sclp_ipl_info
.is_valid
)
375 return sprintf(page
, "#unknown#\n");
376 memcpy(loadparm
, &sclp_ipl_info
.loadparm
, LOADPARM_LEN
);
377 EBCASC(loadparm
, LOADPARM_LEN
);
379 return sprintf(page
, "%s\n", loadparm
);
382 static struct subsys_attribute sys_ipl_ccw_loadparm_attr
=
383 __ATTR(loadparm
, 0444, ipl_ccw_loadparm_show
, NULL
);
385 static struct attribute
*ipl_ccw_attrs
[] = {
386 &sys_ipl_type_attr
.attr
,
387 &sys_ipl_device_attr
.attr
,
388 &sys_ipl_ccw_loadparm_attr
.attr
,
392 static struct attribute_group ipl_ccw_attr_group
= {
393 .attrs
= ipl_ccw_attrs
,
396 /* NSS ipl device attributes */
398 DEFINE_IPL_ATTR_RO(ipl_nss
, name
, "%s\n", kernel_nss_name
);
400 static struct attribute
*ipl_nss_attrs
[] = {
401 &sys_ipl_type_attr
.attr
,
402 &sys_ipl_nss_name_attr
.attr
,
406 static struct attribute_group ipl_nss_attr_group
= {
407 .attrs
= ipl_nss_attrs
,
410 /* UNKNOWN ipl device attributes */
412 static struct attribute
*ipl_unknown_attrs
[] = {
413 &sys_ipl_type_attr
.attr
,
417 static struct attribute_group ipl_unknown_attr_group
= {
418 .attrs
= ipl_unknown_attrs
,
421 static decl_subsys(ipl
, NULL
, NULL
);
427 /* FCP reipl device attributes */
429 DEFINE_IPL_ATTR_RW(reipl_fcp
, wwpn
, "0x%016llx\n", "%016llx\n",
430 reipl_block_fcp
->ipl_info
.fcp
.wwpn
);
431 DEFINE_IPL_ATTR_RW(reipl_fcp
, lun
, "0x%016llx\n", "%016llx\n",
432 reipl_block_fcp
->ipl_info
.fcp
.lun
);
433 DEFINE_IPL_ATTR_RW(reipl_fcp
, bootprog
, "%lld\n", "%lld\n",
434 reipl_block_fcp
->ipl_info
.fcp
.bootprog
);
435 DEFINE_IPL_ATTR_RW(reipl_fcp
, br_lba
, "%lld\n", "%lld\n",
436 reipl_block_fcp
->ipl_info
.fcp
.br_lba
);
437 DEFINE_IPL_ATTR_RW(reipl_fcp
, device
, "0.0.%04llx\n", "0.0.%llx\n",
438 reipl_block_fcp
->ipl_info
.fcp
.devno
);
440 static struct attribute
*reipl_fcp_attrs
[] = {
441 &sys_reipl_fcp_device_attr
.attr
,
442 &sys_reipl_fcp_wwpn_attr
.attr
,
443 &sys_reipl_fcp_lun_attr
.attr
,
444 &sys_reipl_fcp_bootprog_attr
.attr
,
445 &sys_reipl_fcp_br_lba_attr
.attr
,
449 static struct attribute_group reipl_fcp_attr_group
= {
451 .attrs
= reipl_fcp_attrs
,
454 /* CCW reipl device attributes */
456 DEFINE_IPL_ATTR_RW(reipl_ccw
, device
, "0.0.%04llx\n", "0.0.%llx\n",
457 reipl_block_ccw
->ipl_info
.ccw
.devno
);
459 static void reipl_get_ascii_loadparm(char *loadparm
)
461 memcpy(loadparm
, &reipl_block_ccw
->ipl_info
.ccw
.load_param
,
463 EBCASC(loadparm
, LOADPARM_LEN
);
464 loadparm
[LOADPARM_LEN
] = 0;
468 static ssize_t
reipl_ccw_loadparm_show(struct kset
*kset
, char *page
)
470 char buf
[LOADPARM_LEN
+ 1];
472 reipl_get_ascii_loadparm(buf
);
473 return sprintf(page
, "%s\n", buf
);
476 static ssize_t
reipl_ccw_loadparm_store(struct kset
*kset
,
477 const char *buf
, size_t len
)
481 /* ignore trailing newline */
483 if ((len
> 0) && (buf
[len
- 1] == '\n'))
485 /* loadparm can have max 8 characters and must not start with a blank */
486 if ((lp_len
> LOADPARM_LEN
) || ((lp_len
> 0) && (buf
[0] == ' ')))
488 /* loadparm can only contain "a-z,A-Z,0-9,SP,." */
489 for (i
= 0; i
< lp_len
; i
++) {
490 if (isalpha(buf
[i
]) || isdigit(buf
[i
]) || (buf
[i
] == ' ') ||
495 /* initialize loadparm with blanks */
496 memset(&reipl_block_ccw
->ipl_info
.ccw
.load_param
, ' ', LOADPARM_LEN
);
497 /* copy and convert to ebcdic */
498 memcpy(&reipl_block_ccw
->ipl_info
.ccw
.load_param
, buf
, lp_len
);
499 ASCEBC(reipl_block_ccw
->ipl_info
.ccw
.load_param
, LOADPARM_LEN
);
503 static struct subsys_attribute sys_reipl_ccw_loadparm_attr
=
504 __ATTR(loadparm
, 0644, reipl_ccw_loadparm_show
,
505 reipl_ccw_loadparm_store
);
507 static struct attribute
*reipl_ccw_attrs
[] = {
508 &sys_reipl_ccw_device_attr
.attr
,
509 &sys_reipl_ccw_loadparm_attr
.attr
,
513 static struct attribute_group reipl_ccw_attr_group
= {
515 .attrs
= reipl_ccw_attrs
,
519 /* NSS reipl device attributes */
521 DEFINE_IPL_ATTR_STR_RW(reipl_nss
, name
, "%s\n", "%s\n", reipl_nss_name
);
523 static struct attribute
*reipl_nss_attrs
[] = {
524 &sys_reipl_nss_name_attr
.attr
,
528 static struct attribute_group reipl_nss_attr_group
= {
530 .attrs
= reipl_nss_attrs
,
535 static int reipl_set_type(enum ipl_type type
)
537 if (!(reipl_capabilities
& type
))
543 reipl_method
= REIPL_METHOD_CCW_VM
;
545 reipl_method
= REIPL_METHOD_CCW_CIO
;
548 if (diag308_set_works
)
549 reipl_method
= REIPL_METHOD_FCP_RW_DIAG
;
550 else if (MACHINE_IS_VM
)
551 reipl_method
= REIPL_METHOD_FCP_RO_VM
;
553 reipl_method
= REIPL_METHOD_FCP_RO_DIAG
;
555 case IPL_TYPE_FCP_DUMP
:
556 reipl_method
= REIPL_METHOD_FCP_DUMP
;
559 reipl_method
= REIPL_METHOD_NSS
;
561 case IPL_TYPE_UNKNOWN
:
562 reipl_method
= REIPL_METHOD_DEFAULT
;
571 static ssize_t
reipl_type_show(struct kset
*kset
, char *page
)
573 return sprintf(page
, "%s\n", ipl_type_str(reipl_type
));
576 static ssize_t
reipl_type_store(struct kset
*kset
, const char *buf
,
581 if (strncmp(buf
, IPL_CCW_STR
, strlen(IPL_CCW_STR
)) == 0)
582 rc
= reipl_set_type(IPL_TYPE_CCW
);
583 else if (strncmp(buf
, IPL_FCP_STR
, strlen(IPL_FCP_STR
)) == 0)
584 rc
= reipl_set_type(IPL_TYPE_FCP
);
585 else if (strncmp(buf
, IPL_NSS_STR
, strlen(IPL_NSS_STR
)) == 0)
586 rc
= reipl_set_type(IPL_TYPE_NSS
);
587 return (rc
!= 0) ? rc
: len
;
590 static struct subsys_attribute reipl_type_attr
=
591 __ATTR(reipl_type
, 0644, reipl_type_show
, reipl_type_store
);
593 static decl_subsys(reipl
, NULL
, NULL
);
599 /* FCP dump device attributes */
601 DEFINE_IPL_ATTR_RW(dump_fcp
, wwpn
, "0x%016llx\n", "%016llx\n",
602 dump_block_fcp
->ipl_info
.fcp
.wwpn
);
603 DEFINE_IPL_ATTR_RW(dump_fcp
, lun
, "0x%016llx\n", "%016llx\n",
604 dump_block_fcp
->ipl_info
.fcp
.lun
);
605 DEFINE_IPL_ATTR_RW(dump_fcp
, bootprog
, "%lld\n", "%lld\n",
606 dump_block_fcp
->ipl_info
.fcp
.bootprog
);
607 DEFINE_IPL_ATTR_RW(dump_fcp
, br_lba
, "%lld\n", "%lld\n",
608 dump_block_fcp
->ipl_info
.fcp
.br_lba
);
609 DEFINE_IPL_ATTR_RW(dump_fcp
, device
, "0.0.%04llx\n", "0.0.%llx\n",
610 dump_block_fcp
->ipl_info
.fcp
.devno
);
612 static struct attribute
*dump_fcp_attrs
[] = {
613 &sys_dump_fcp_device_attr
.attr
,
614 &sys_dump_fcp_wwpn_attr
.attr
,
615 &sys_dump_fcp_lun_attr
.attr
,
616 &sys_dump_fcp_bootprog_attr
.attr
,
617 &sys_dump_fcp_br_lba_attr
.attr
,
621 static struct attribute_group dump_fcp_attr_group
= {
623 .attrs
= dump_fcp_attrs
,
626 /* CCW dump device attributes */
628 DEFINE_IPL_ATTR_RW(dump_ccw
, device
, "0.0.%04llx\n", "0.0.%llx\n",
629 dump_block_ccw
->ipl_info
.ccw
.devno
);
631 static struct attribute
*dump_ccw_attrs
[] = {
632 &sys_dump_ccw_device_attr
.attr
,
636 static struct attribute_group dump_ccw_attr_group
= {
638 .attrs
= dump_ccw_attrs
,
643 static int dump_set_type(enum dump_type type
)
645 if (!(dump_capabilities
& type
))
650 dump_method
= DUMP_METHOD_CCW_VM
;
652 dump_method
= DUMP_METHOD_CCW_CIO
;
655 dump_method
= DUMP_METHOD_FCP_DIAG
;
658 dump_method
= DUMP_METHOD_NONE
;
664 static ssize_t
dump_type_show(struct kset
*kset
, char *page
)
666 return sprintf(page
, "%s\n", dump_type_str(dump_type
));
669 static ssize_t
dump_type_store(struct kset
*kset
, const char *buf
,
674 if (strncmp(buf
, DUMP_NONE_STR
, strlen(DUMP_NONE_STR
)) == 0)
675 rc
= dump_set_type(DUMP_TYPE_NONE
);
676 else if (strncmp(buf
, DUMP_CCW_STR
, strlen(DUMP_CCW_STR
)) == 0)
677 rc
= dump_set_type(DUMP_TYPE_CCW
);
678 else if (strncmp(buf
, DUMP_FCP_STR
, strlen(DUMP_FCP_STR
)) == 0)
679 rc
= dump_set_type(DUMP_TYPE_FCP
);
680 return (rc
!= 0) ? rc
: len
;
683 static struct subsys_attribute dump_type_attr
=
684 __ATTR(dump_type
, 0644, dump_type_show
, dump_type_store
);
686 static decl_subsys(dump
, NULL
, NULL
);
689 * Shutdown actions section
692 static decl_subsys(shutdown_actions
, NULL
, NULL
);
696 static ssize_t
on_panic_show(struct kset
*kset
, char *page
)
698 return sprintf(page
, "%s\n", shutdown_action_str(on_panic_action
));
701 static ssize_t
on_panic_store(struct kset
*kset
, const char *buf
,
704 if (strncmp(buf
, SHUTDOWN_REIPL_STR
, strlen(SHUTDOWN_REIPL_STR
)) == 0)
705 on_panic_action
= SHUTDOWN_REIPL
;
706 else if (strncmp(buf
, SHUTDOWN_DUMP_STR
,
707 strlen(SHUTDOWN_DUMP_STR
)) == 0)
708 on_panic_action
= SHUTDOWN_DUMP
;
709 else if (strncmp(buf
, SHUTDOWN_STOP_STR
,
710 strlen(SHUTDOWN_STOP_STR
)) == 0)
711 on_panic_action
= SHUTDOWN_STOP
;
718 static struct subsys_attribute on_panic_attr
=
719 __ATTR(on_panic
, 0644, on_panic_show
, on_panic_store
);
723 struct ccw_dev_id devid
;
724 static char buf
[100];
725 char loadparm
[LOADPARM_LEN
+ 1];
727 switch (reipl_method
) {
728 case REIPL_METHOD_CCW_CIO
:
729 devid
.devno
= reipl_block_ccw
->ipl_info
.ccw
.devno
;
730 if (ipl_info
.type
== IPL_TYPE_CCW
&& devid
.devno
== ipl_devno
)
731 diag308(DIAG308_IPL
, NULL
);
733 reipl_ccw_dev(&devid
);
735 case REIPL_METHOD_CCW_VM
:
736 reipl_get_ascii_loadparm(loadparm
);
737 if (strlen(loadparm
) == 0)
738 sprintf(buf
, "IPL %X CLEAR",
739 reipl_block_ccw
->ipl_info
.ccw
.devno
);
741 sprintf(buf
, "IPL %X CLEAR LOADPARM '%s'",
742 reipl_block_ccw
->ipl_info
.ccw
.devno
, loadparm
);
743 __cpcmd(buf
, NULL
, 0, NULL
);
745 case REIPL_METHOD_CCW_DIAG
:
746 diag308(DIAG308_SET
, reipl_block_ccw
);
747 diag308(DIAG308_IPL
, NULL
);
749 case REIPL_METHOD_FCP_RW_DIAG
:
750 diag308(DIAG308_SET
, reipl_block_fcp
);
751 diag308(DIAG308_IPL
, NULL
);
753 case REIPL_METHOD_FCP_RO_DIAG
:
754 diag308(DIAG308_IPL
, NULL
);
756 case REIPL_METHOD_FCP_RO_VM
:
757 __cpcmd("IPL", NULL
, 0, NULL
);
759 case REIPL_METHOD_NSS
:
760 sprintf(buf
, "IPL %s", reipl_nss_name
);
761 __cpcmd(buf
, NULL
, 0, NULL
);
763 case REIPL_METHOD_DEFAULT
:
765 __cpcmd("IPL", NULL
, 0, NULL
);
766 diag308(DIAG308_IPL
, NULL
);
768 case REIPL_METHOD_FCP_DUMP
:
772 signal_processor(smp_processor_id(), sigp_stop_and_store_status
);
775 static void do_dump(void)
777 struct ccw_dev_id devid
;
778 static char buf
[100];
780 switch (dump_method
) {
781 case DUMP_METHOD_CCW_CIO
:
783 devid
.devno
= dump_block_ccw
->ipl_info
.ccw
.devno
;
785 reipl_ccw_dev(&devid
);
787 case DUMP_METHOD_CCW_VM
:
789 sprintf(buf
, "STORE STATUS");
790 __cpcmd(buf
, NULL
, 0, NULL
);
791 sprintf(buf
, "IPL %X", dump_block_ccw
->ipl_info
.ccw
.devno
);
792 __cpcmd(buf
, NULL
, 0, NULL
);
794 case DUMP_METHOD_CCW_DIAG
:
795 diag308(DIAG308_SET
, dump_block_ccw
);
796 diag308(DIAG308_DUMP
, NULL
);
798 case DUMP_METHOD_FCP_DIAG
:
799 diag308(DIAG308_SET
, dump_block_fcp
);
800 diag308(DIAG308_DUMP
, NULL
);
802 case DUMP_METHOD_NONE
:
806 printk(KERN_EMERG
"Dump failed!\n");
811 static int __init
ipl_register_fcp_files(void)
815 rc
= sysfs_create_group(&ipl_subsys
.kobj
,
816 &ipl_fcp_attr_group
);
819 rc
= sysfs_create_bin_file(&ipl_subsys
.kobj
,
820 &ipl_parameter_attr
);
823 rc
= sysfs_create_bin_file(&ipl_subsys
.kobj
,
828 sysfs_remove_bin_file(&ipl_subsys
.kobj
, &ipl_parameter_attr
);
831 sysfs_remove_group(&ipl_subsys
.kobj
, &ipl_fcp_attr_group
);
836 static int __init
ipl_init(void)
840 rc
= firmware_register(&ipl_subsys
);
843 switch (ipl_info
.type
) {
845 rc
= sysfs_create_group(&ipl_subsys
.kobj
,
846 &ipl_ccw_attr_group
);
849 case IPL_TYPE_FCP_DUMP
:
850 rc
= ipl_register_fcp_files();
853 rc
= sysfs_create_group(&ipl_subsys
.kobj
,
854 &ipl_nss_attr_group
);
857 rc
= sysfs_create_group(&ipl_subsys
.kobj
,
858 &ipl_unknown_attr_group
);
862 firmware_unregister(&ipl_subsys
);
866 static void __init
reipl_probe(void)
870 buffer
= (void *) get_zeroed_page(GFP_KERNEL
);
873 if (diag308(DIAG308_STORE
, buffer
) == DIAG308_RC_OK
)
874 diag308_set_works
= 1;
875 free_page((unsigned long)buffer
);
878 static int __init
reipl_nss_init(void)
884 rc
= sysfs_create_group(&reipl_subsys
.kobj
, &reipl_nss_attr_group
);
887 strncpy(reipl_nss_name
, kernel_nss_name
, NSS_NAME_SIZE
+ 1);
888 reipl_capabilities
|= IPL_TYPE_NSS
;
892 static int __init
reipl_ccw_init(void)
896 reipl_block_ccw
= (void *) get_zeroed_page(GFP_KERNEL
);
897 if (!reipl_block_ccw
)
899 rc
= sysfs_create_group(&reipl_subsys
.kobj
, &reipl_ccw_attr_group
);
901 free_page((unsigned long)reipl_block_ccw
);
904 reipl_block_ccw
->hdr
.len
= IPL_PARM_BLK_CCW_LEN
;
905 reipl_block_ccw
->hdr
.version
= IPL_PARM_BLOCK_VERSION
;
906 reipl_block_ccw
->hdr
.blk0_len
= IPL_PARM_BLK0_CCW_LEN
;
907 reipl_block_ccw
->hdr
.pbt
= DIAG308_IPL_TYPE_CCW
;
908 /* check if read scp info worked and set loadparm */
909 if (sclp_ipl_info
.is_valid
)
910 memcpy(reipl_block_ccw
->ipl_info
.ccw
.load_param
,
911 &sclp_ipl_info
.loadparm
, LOADPARM_LEN
);
913 /* read scp info failed: set empty loadparm (EBCDIC blanks) */
914 memset(reipl_block_ccw
->ipl_info
.ccw
.load_param
, 0x40,
916 /* FIXME: check for diag308_set_works when enabling diag ccw reipl */
918 sys_reipl_ccw_loadparm_attr
.attr
.mode
= S_IRUGO
;
919 if (ipl_info
.type
== IPL_TYPE_CCW
)
920 reipl_block_ccw
->ipl_info
.ccw
.devno
= ipl_devno
;
921 reipl_capabilities
|= IPL_TYPE_CCW
;
925 static int __init
reipl_fcp_init(void)
929 if ((!diag308_set_works
) && (ipl_info
.type
!= IPL_TYPE_FCP
))
931 if ((!diag308_set_works
) && (ipl_info
.type
== IPL_TYPE_FCP
))
932 make_attrs_ro(reipl_fcp_attrs
);
934 reipl_block_fcp
= (void *) get_zeroed_page(GFP_KERNEL
);
935 if (!reipl_block_fcp
)
937 rc
= sysfs_create_group(&reipl_subsys
.kobj
, &reipl_fcp_attr_group
);
939 free_page((unsigned long)reipl_block_fcp
);
942 if (ipl_info
.type
== IPL_TYPE_FCP
) {
943 memcpy(reipl_block_fcp
, IPL_PARMBLOCK_START
, PAGE_SIZE
);
945 reipl_block_fcp
->hdr
.len
= IPL_PARM_BLK_FCP_LEN
;
946 reipl_block_fcp
->hdr
.version
= IPL_PARM_BLOCK_VERSION
;
947 reipl_block_fcp
->hdr
.blk0_len
= IPL_PARM_BLK0_FCP_LEN
;
948 reipl_block_fcp
->hdr
.pbt
= DIAG308_IPL_TYPE_FCP
;
949 reipl_block_fcp
->ipl_info
.fcp
.opt
= DIAG308_IPL_OPT_IPL
;
951 reipl_capabilities
|= IPL_TYPE_FCP
;
955 static int __init
reipl_init(void)
959 rc
= firmware_register(&reipl_subsys
);
962 rc
= subsys_create_file(&reipl_subsys
, &reipl_type_attr
);
964 firmware_unregister(&reipl_subsys
);
967 rc
= reipl_ccw_init();
970 rc
= reipl_fcp_init();
973 rc
= reipl_nss_init();
976 rc
= reipl_set_type(ipl_info
.type
);
982 static int __init
dump_ccw_init(void)
986 dump_block_ccw
= (void *) get_zeroed_page(GFP_KERNEL
);
989 rc
= sysfs_create_group(&dump_subsys
.kobj
, &dump_ccw_attr_group
);
991 free_page((unsigned long)dump_block_ccw
);
994 dump_block_ccw
->hdr
.len
= IPL_PARM_BLK_CCW_LEN
;
995 dump_block_ccw
->hdr
.version
= IPL_PARM_BLOCK_VERSION
;
996 dump_block_ccw
->hdr
.blk0_len
= IPL_PARM_BLK0_CCW_LEN
;
997 dump_block_ccw
->hdr
.pbt
= DIAG308_IPL_TYPE_CCW
;
998 dump_capabilities
|= DUMP_TYPE_CCW
;
1002 static int __init
dump_fcp_init(void)
1006 if (!sclp_ipl_info
.has_dump
)
1007 return 0; /* LDIPL DUMP is not installed */
1008 if (!diag308_set_works
)
1010 dump_block_fcp
= (void *) get_zeroed_page(GFP_KERNEL
);
1011 if (!dump_block_fcp
)
1013 rc
= sysfs_create_group(&dump_subsys
.kobj
, &dump_fcp_attr_group
);
1015 free_page((unsigned long)dump_block_fcp
);
1018 dump_block_fcp
->hdr
.len
= IPL_PARM_BLK_FCP_LEN
;
1019 dump_block_fcp
->hdr
.version
= IPL_PARM_BLOCK_VERSION
;
1020 dump_block_fcp
->hdr
.blk0_len
= IPL_PARM_BLK0_FCP_LEN
;
1021 dump_block_fcp
->hdr
.pbt
= DIAG308_IPL_TYPE_FCP
;
1022 dump_block_fcp
->ipl_info
.fcp
.opt
= DIAG308_IPL_OPT_DUMP
;
1023 dump_capabilities
|= DUMP_TYPE_FCP
;
1027 #define SHUTDOWN_ON_PANIC_PRIO 0
1029 static int shutdown_on_panic_notify(struct notifier_block
*self
,
1030 unsigned long event
, void *data
)
1032 if (on_panic_action
== SHUTDOWN_DUMP
)
1034 else if (on_panic_action
== SHUTDOWN_REIPL
)
1039 static struct notifier_block shutdown_on_panic_nb
= {
1040 .notifier_call
= shutdown_on_panic_notify
,
1041 .priority
= SHUTDOWN_ON_PANIC_PRIO
1044 static int __init
dump_init(void)
1048 rc
= firmware_register(&dump_subsys
);
1051 rc
= subsys_create_file(&dump_subsys
, &dump_type_attr
);
1053 firmware_unregister(&dump_subsys
);
1056 rc
= dump_ccw_init();
1059 rc
= dump_fcp_init();
1062 dump_set_type(DUMP_TYPE_NONE
);
1066 static int __init
shutdown_actions_init(void)
1070 rc
= firmware_register(&shutdown_actions_subsys
);
1073 rc
= subsys_create_file(&shutdown_actions_subsys
, &on_panic_attr
);
1075 firmware_unregister(&shutdown_actions_subsys
);
1078 atomic_notifier_chain_register(&panic_notifier_list
,
1079 &shutdown_on_panic_nb
);
1083 static int __init
s390_ipl_init(void)
1087 sclp_get_ipl_info(&sclp_ipl_info
);
1098 rc
= shutdown_actions_init();
1104 __initcall(s390_ipl_init
);
1106 void __init
ipl_save_parameters(void)
1108 struct cio_iplinfo iplinfo
;
1109 unsigned int *ipl_ptr
;
1112 if (cio_get_iplinfo(&iplinfo
))
1115 ipl_devno
= iplinfo
.devno
;
1116 ipl_flags
|= IPL_DEVNO_VALID
;
1117 if (!iplinfo
.is_qdio
)
1119 ipl_flags
|= IPL_PARMBLOCK_VALID
;
1120 ipl_ptr
= (unsigned int *)__LC_IPL_PARMBLOCK_PTR
;
1121 src
= (void *)(unsigned long)*ipl_ptr
;
1122 dst
= (void *)IPL_PARMBLOCK_ORIGIN
;
1123 memmove(dst
, src
, PAGE_SIZE
);
1124 *ipl_ptr
= IPL_PARMBLOCK_ORIGIN
;
1127 static LIST_HEAD(rcall
);
1128 static DEFINE_MUTEX(rcall_mutex
);
1130 void register_reset_call(struct reset_call
*reset
)
1132 mutex_lock(&rcall_mutex
);
1133 list_add(&reset
->list
, &rcall
);
1134 mutex_unlock(&rcall_mutex
);
1136 EXPORT_SYMBOL_GPL(register_reset_call
);
1138 void unregister_reset_call(struct reset_call
*reset
)
1140 mutex_lock(&rcall_mutex
);
1141 list_del(&reset
->list
);
1142 mutex_unlock(&rcall_mutex
);
1144 EXPORT_SYMBOL_GPL(unregister_reset_call
);
1146 static void do_reset_calls(void)
1148 struct reset_call
*reset
;
1150 list_for_each_entry(reset
, &rcall
, list
)
1154 u32 dump_prefix_page
;
1156 void s390_reset_system(void)
1158 struct _lowcore
*lc
;
1160 lc
= (struct _lowcore
*)(unsigned long) store_prefix();
1162 /* Stack for interrupt/machine check handler */
1163 lc
->panic_stack
= S390_lowcore
.panic_stack
;
1165 /* Save prefix page address for dump case */
1166 dump_prefix_page
= (u32
)(unsigned long) lc
;
1168 /* Disable prefixing */
1171 /* Disable lowcore protection */
1172 __ctl_clear_bit(0,28);
1174 /* Set new machine check handler */
1175 S390_lowcore
.mcck_new_psw
.mask
= psw_kernel_bits
& ~PSW_MASK_MCHECK
;
1176 S390_lowcore
.mcck_new_psw
.addr
=
1177 PSW_ADDR_AMODE
| (unsigned long) s390_base_mcck_handler
;
1179 /* Set new program check handler */
1180 S390_lowcore
.program_new_psw
.mask
= psw_kernel_bits
& ~PSW_MASK_MCHECK
;
1181 S390_lowcore
.program_new_psw
.addr
=
1182 PSW_ADDR_AMODE
| (unsigned long) s390_base_pgm_handler
;