nfsd4: typo logical vs bitwise negate for want_mask
[linux-btrfs-devel.git] / arch / s390 / kernel / ipl.c
blob04361d5a42794524419bd1898ac78ef755491449
1 /*
2 * arch/s390/kernel/ipl.c
3 * ipl/reipl/dump support for Linux on s390.
5 * Copyright IBM Corp. 2005,2007
6 * Author(s): Michael Holzheu <holzheu@de.ibm.com>
7 * Heiko Carstens <heiko.carstens@de.ibm.com>
8 * Volker Sameske <sameske@de.ibm.com>
9 */
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>
17 #include <linux/fs.h>
18 #include <linux/gfp.h>
19 #include <asm/ipl.h>
20 #include <asm/smp.h>
21 #include <asm/setup.h>
22 #include <asm/cpcmd.h>
23 #include <asm/cio.h>
24 #include <asm/ebcdic.h>
25 #include <asm/reset.h>
26 #include <asm/sclp.h>
27 #include <asm/sigp.h>
28 #include <asm/checksum.h>
30 #define IPL_PARM_BLOCK_VERSION 0
32 #define IPL_UNKNOWN_STR "unknown"
33 #define IPL_CCW_STR "ccw"
34 #define IPL_FCP_STR "fcp"
35 #define IPL_FCP_DUMP_STR "fcp_dump"
36 #define IPL_NSS_STR "nss"
38 #define DUMP_CCW_STR "ccw"
39 #define DUMP_FCP_STR "fcp"
40 #define DUMP_NONE_STR "none"
43 * Four shutdown trigger types are supported:
44 * - panic
45 * - halt
46 * - power off
47 * - reipl
48 * - restart
50 #define ON_PANIC_STR "on_panic"
51 #define ON_HALT_STR "on_halt"
52 #define ON_POFF_STR "on_poff"
53 #define ON_REIPL_STR "on_reboot"
54 #define ON_RESTART_STR "on_restart"
56 struct shutdown_action;
57 struct shutdown_trigger {
58 char *name;
59 struct shutdown_action *action;
63 * The following shutdown action types are supported:
65 #define SHUTDOWN_ACTION_IPL_STR "ipl"
66 #define SHUTDOWN_ACTION_REIPL_STR "reipl"
67 #define SHUTDOWN_ACTION_DUMP_STR "dump"
68 #define SHUTDOWN_ACTION_VMCMD_STR "vmcmd"
69 #define SHUTDOWN_ACTION_STOP_STR "stop"
70 #define SHUTDOWN_ACTION_DUMP_REIPL_STR "dump_reipl"
72 struct shutdown_action {
73 char *name;
74 void (*fn) (struct shutdown_trigger *trigger);
75 int (*init) (void);
76 int init_rc;
79 static char *ipl_type_str(enum ipl_type type)
81 switch (type) {
82 case IPL_TYPE_CCW:
83 return IPL_CCW_STR;
84 case IPL_TYPE_FCP:
85 return IPL_FCP_STR;
86 case IPL_TYPE_FCP_DUMP:
87 return IPL_FCP_DUMP_STR;
88 case IPL_TYPE_NSS:
89 return IPL_NSS_STR;
90 case IPL_TYPE_UNKNOWN:
91 default:
92 return IPL_UNKNOWN_STR;
96 enum dump_type {
97 DUMP_TYPE_NONE = 1,
98 DUMP_TYPE_CCW = 2,
99 DUMP_TYPE_FCP = 4,
102 static char *dump_type_str(enum dump_type type)
104 switch (type) {
105 case DUMP_TYPE_NONE:
106 return DUMP_NONE_STR;
107 case DUMP_TYPE_CCW:
108 return DUMP_CCW_STR;
109 case DUMP_TYPE_FCP:
110 return DUMP_FCP_STR;
111 default:
112 return NULL;
117 * Must be in data section since the bss section
118 * is not cleared when these are accessed.
120 static u16 ipl_devno __attribute__((__section__(".data"))) = 0;
121 u32 ipl_flags __attribute__((__section__(".data"))) = 0;
123 enum ipl_method {
124 REIPL_METHOD_CCW_CIO,
125 REIPL_METHOD_CCW_DIAG,
126 REIPL_METHOD_CCW_VM,
127 REIPL_METHOD_FCP_RO_DIAG,
128 REIPL_METHOD_FCP_RW_DIAG,
129 REIPL_METHOD_FCP_RO_VM,
130 REIPL_METHOD_FCP_DUMP,
131 REIPL_METHOD_NSS,
132 REIPL_METHOD_NSS_DIAG,
133 REIPL_METHOD_DEFAULT,
136 enum dump_method {
137 DUMP_METHOD_NONE,
138 DUMP_METHOD_CCW_CIO,
139 DUMP_METHOD_CCW_DIAG,
140 DUMP_METHOD_CCW_VM,
141 DUMP_METHOD_FCP_DIAG,
144 static int diag308_set_works = 0;
146 static struct ipl_parameter_block ipl_block;
148 static int reipl_capabilities = IPL_TYPE_UNKNOWN;
150 static enum ipl_type reipl_type = IPL_TYPE_UNKNOWN;
151 static enum ipl_method reipl_method = REIPL_METHOD_DEFAULT;
152 static struct ipl_parameter_block *reipl_block_fcp;
153 static struct ipl_parameter_block *reipl_block_ccw;
154 static struct ipl_parameter_block *reipl_block_nss;
155 static struct ipl_parameter_block *reipl_block_actual;
157 static int dump_capabilities = DUMP_TYPE_NONE;
158 static enum dump_type dump_type = DUMP_TYPE_NONE;
159 static enum dump_method dump_method = DUMP_METHOD_NONE;
160 static struct ipl_parameter_block *dump_block_fcp;
161 static struct ipl_parameter_block *dump_block_ccw;
163 static struct sclp_ipl_info sclp_ipl_info;
165 int diag308(unsigned long subcode, void *addr)
167 register unsigned long _addr asm("0") = (unsigned long) addr;
168 register unsigned long _rc asm("1") = 0;
170 asm volatile(
171 " diag %0,%2,0x308\n"
172 "0:\n"
173 EX_TABLE(0b,0b)
174 : "+d" (_addr), "+d" (_rc)
175 : "d" (subcode) : "cc", "memory");
176 return _rc;
178 EXPORT_SYMBOL_GPL(diag308);
180 /* SYSFS */
182 #define DEFINE_IPL_ATTR_RO(_prefix, _name, _format, _value) \
183 static ssize_t sys_##_prefix##_##_name##_show(struct kobject *kobj, \
184 struct kobj_attribute *attr, \
185 char *page) \
187 return sprintf(page, _format, _value); \
189 static struct kobj_attribute sys_##_prefix##_##_name##_attr = \
190 __ATTR(_name, S_IRUGO, sys_##_prefix##_##_name##_show, NULL);
192 #define DEFINE_IPL_ATTR_RW(_prefix, _name, _fmt_out, _fmt_in, _value) \
193 static ssize_t sys_##_prefix##_##_name##_show(struct kobject *kobj, \
194 struct kobj_attribute *attr, \
195 char *page) \
197 return sprintf(page, _fmt_out, \
198 (unsigned long long) _value); \
200 static ssize_t sys_##_prefix##_##_name##_store(struct kobject *kobj, \
201 struct kobj_attribute *attr, \
202 const char *buf, size_t len) \
204 unsigned long long value; \
205 if (sscanf(buf, _fmt_in, &value) != 1) \
206 return -EINVAL; \
207 _value = value; \
208 return len; \
210 static struct kobj_attribute sys_##_prefix##_##_name##_attr = \
211 __ATTR(_name,(S_IRUGO | S_IWUSR), \
212 sys_##_prefix##_##_name##_show, \
213 sys_##_prefix##_##_name##_store);
215 #define DEFINE_IPL_ATTR_STR_RW(_prefix, _name, _fmt_out, _fmt_in, _value)\
216 static ssize_t sys_##_prefix##_##_name##_show(struct kobject *kobj, \
217 struct kobj_attribute *attr, \
218 char *page) \
220 return sprintf(page, _fmt_out, _value); \
222 static ssize_t sys_##_prefix##_##_name##_store(struct kobject *kobj, \
223 struct kobj_attribute *attr, \
224 const char *buf, size_t len) \
226 strncpy(_value, buf, sizeof(_value) - 1); \
227 strim(_value); \
228 return len; \
230 static struct kobj_attribute sys_##_prefix##_##_name##_attr = \
231 __ATTR(_name,(S_IRUGO | S_IWUSR), \
232 sys_##_prefix##_##_name##_show, \
233 sys_##_prefix##_##_name##_store);
235 static void make_attrs_ro(struct attribute **attrs)
237 while (*attrs) {
238 (*attrs)->mode = S_IRUGO;
239 attrs++;
244 * ipl section
247 static __init enum ipl_type get_ipl_type(void)
249 struct ipl_parameter_block *ipl = IPL_PARMBLOCK_START;
251 if (ipl_flags & IPL_NSS_VALID)
252 return IPL_TYPE_NSS;
253 if (!(ipl_flags & IPL_DEVNO_VALID))
254 return IPL_TYPE_UNKNOWN;
255 if (!(ipl_flags & IPL_PARMBLOCK_VALID))
256 return IPL_TYPE_CCW;
257 if (ipl->hdr.version > IPL_MAX_SUPPORTED_VERSION)
258 return IPL_TYPE_UNKNOWN;
259 if (ipl->hdr.pbt != DIAG308_IPL_TYPE_FCP)
260 return IPL_TYPE_UNKNOWN;
261 if (ipl->ipl_info.fcp.opt == DIAG308_IPL_OPT_DUMP)
262 return IPL_TYPE_FCP_DUMP;
263 return IPL_TYPE_FCP;
266 struct ipl_info ipl_info;
267 EXPORT_SYMBOL_GPL(ipl_info);
269 static ssize_t ipl_type_show(struct kobject *kobj, struct kobj_attribute *attr,
270 char *page)
272 return sprintf(page, "%s\n", ipl_type_str(ipl_info.type));
275 static struct kobj_attribute sys_ipl_type_attr = __ATTR_RO(ipl_type);
277 /* VM IPL PARM routines */
278 size_t reipl_get_ascii_vmparm(char *dest, size_t size,
279 const struct ipl_parameter_block *ipb)
281 int i;
282 size_t len;
283 char has_lowercase = 0;
285 len = 0;
286 if ((ipb->ipl_info.ccw.vm_flags & DIAG308_VM_FLAGS_VP_VALID) &&
287 (ipb->ipl_info.ccw.vm_parm_len > 0)) {
289 len = min_t(size_t, size - 1, ipb->ipl_info.ccw.vm_parm_len);
290 memcpy(dest, ipb->ipl_info.ccw.vm_parm, len);
291 /* If at least one character is lowercase, we assume mixed
292 * case; otherwise we convert everything to lowercase.
294 for (i = 0; i < len; i++)
295 if ((dest[i] > 0x80 && dest[i] < 0x8a) || /* a-i */
296 (dest[i] > 0x90 && dest[i] < 0x9a) || /* j-r */
297 (dest[i] > 0xa1 && dest[i] < 0xaa)) { /* s-z */
298 has_lowercase = 1;
299 break;
301 if (!has_lowercase)
302 EBC_TOLOWER(dest, len);
303 EBCASC(dest, len);
305 dest[len] = 0;
307 return len;
310 size_t append_ipl_vmparm(char *dest, size_t size)
312 size_t rc;
314 rc = 0;
315 if (diag308_set_works && (ipl_block.hdr.pbt == DIAG308_IPL_TYPE_CCW))
316 rc = reipl_get_ascii_vmparm(dest, size, &ipl_block);
317 else
318 dest[0] = 0;
319 return rc;
322 static ssize_t ipl_vm_parm_show(struct kobject *kobj,
323 struct kobj_attribute *attr, char *page)
325 char parm[DIAG308_VMPARM_SIZE + 1] = {};
327 append_ipl_vmparm(parm, sizeof(parm));
328 return sprintf(page, "%s\n", parm);
331 static size_t scpdata_length(const char* buf, size_t count)
333 while (count) {
334 if (buf[count - 1] != '\0' && buf[count - 1] != ' ')
335 break;
336 count--;
338 return count;
341 size_t reipl_append_ascii_scpdata(char *dest, size_t size,
342 const struct ipl_parameter_block *ipb)
344 size_t count;
345 size_t i;
346 int has_lowercase;
348 count = min(size - 1, scpdata_length(ipb->ipl_info.fcp.scp_data,
349 ipb->ipl_info.fcp.scp_data_len));
350 if (!count)
351 goto out;
353 has_lowercase = 0;
354 for (i = 0; i < count; i++) {
355 if (!isascii(ipb->ipl_info.fcp.scp_data[i])) {
356 count = 0;
357 goto out;
359 if (!has_lowercase && islower(ipb->ipl_info.fcp.scp_data[i]))
360 has_lowercase = 1;
363 if (has_lowercase)
364 memcpy(dest, ipb->ipl_info.fcp.scp_data, count);
365 else
366 for (i = 0; i < count; i++)
367 dest[i] = tolower(ipb->ipl_info.fcp.scp_data[i]);
368 out:
369 dest[count] = '\0';
370 return count;
373 size_t append_ipl_scpdata(char *dest, size_t len)
375 size_t rc;
377 rc = 0;
378 if (ipl_block.hdr.pbt == DIAG308_IPL_TYPE_FCP)
379 rc = reipl_append_ascii_scpdata(dest, len, &ipl_block);
380 else
381 dest[0] = 0;
382 return rc;
386 static struct kobj_attribute sys_ipl_vm_parm_attr =
387 __ATTR(parm, S_IRUGO, ipl_vm_parm_show, NULL);
389 static ssize_t sys_ipl_device_show(struct kobject *kobj,
390 struct kobj_attribute *attr, char *page)
392 struct ipl_parameter_block *ipl = IPL_PARMBLOCK_START;
394 switch (ipl_info.type) {
395 case IPL_TYPE_CCW:
396 return sprintf(page, "0.0.%04x\n", ipl_devno);
397 case IPL_TYPE_FCP:
398 case IPL_TYPE_FCP_DUMP:
399 return sprintf(page, "0.0.%04x\n", ipl->ipl_info.fcp.devno);
400 default:
401 return 0;
405 static struct kobj_attribute sys_ipl_device_attr =
406 __ATTR(device, S_IRUGO, sys_ipl_device_show, NULL);
408 static ssize_t ipl_parameter_read(struct file *filp, struct kobject *kobj,
409 struct bin_attribute *attr, char *buf,
410 loff_t off, size_t count)
412 return memory_read_from_buffer(buf, count, &off, IPL_PARMBLOCK_START,
413 IPL_PARMBLOCK_SIZE);
416 static struct bin_attribute ipl_parameter_attr = {
417 .attr = {
418 .name = "binary_parameter",
419 .mode = S_IRUGO,
421 .size = PAGE_SIZE,
422 .read = &ipl_parameter_read,
425 static ssize_t ipl_scp_data_read(struct file *filp, struct kobject *kobj,
426 struct bin_attribute *attr, char *buf,
427 loff_t off, size_t count)
429 unsigned int size = IPL_PARMBLOCK_START->ipl_info.fcp.scp_data_len;
430 void *scp_data = &IPL_PARMBLOCK_START->ipl_info.fcp.scp_data;
432 return memory_read_from_buffer(buf, count, &off, scp_data, size);
435 static struct bin_attribute ipl_scp_data_attr = {
436 .attr = {
437 .name = "scp_data",
438 .mode = S_IRUGO,
440 .size = PAGE_SIZE,
441 .read = ipl_scp_data_read,
444 /* FCP ipl device attributes */
446 DEFINE_IPL_ATTR_RO(ipl_fcp, wwpn, "0x%016llx\n", (unsigned long long)
447 IPL_PARMBLOCK_START->ipl_info.fcp.wwpn);
448 DEFINE_IPL_ATTR_RO(ipl_fcp, lun, "0x%016llx\n", (unsigned long long)
449 IPL_PARMBLOCK_START->ipl_info.fcp.lun);
450 DEFINE_IPL_ATTR_RO(ipl_fcp, bootprog, "%lld\n", (unsigned long long)
451 IPL_PARMBLOCK_START->ipl_info.fcp.bootprog);
452 DEFINE_IPL_ATTR_RO(ipl_fcp, br_lba, "%lld\n", (unsigned long long)
453 IPL_PARMBLOCK_START->ipl_info.fcp.br_lba);
455 static struct attribute *ipl_fcp_attrs[] = {
456 &sys_ipl_type_attr.attr,
457 &sys_ipl_device_attr.attr,
458 &sys_ipl_fcp_wwpn_attr.attr,
459 &sys_ipl_fcp_lun_attr.attr,
460 &sys_ipl_fcp_bootprog_attr.attr,
461 &sys_ipl_fcp_br_lba_attr.attr,
462 NULL,
465 static struct attribute_group ipl_fcp_attr_group = {
466 .attrs = ipl_fcp_attrs,
469 /* CCW ipl device attributes */
471 static ssize_t ipl_ccw_loadparm_show(struct kobject *kobj,
472 struct kobj_attribute *attr, char *page)
474 char loadparm[LOADPARM_LEN + 1] = {};
476 if (!sclp_ipl_info.is_valid)
477 return sprintf(page, "#unknown#\n");
478 memcpy(loadparm, &sclp_ipl_info.loadparm, LOADPARM_LEN);
479 EBCASC(loadparm, LOADPARM_LEN);
480 strim(loadparm);
481 return sprintf(page, "%s\n", loadparm);
484 static struct kobj_attribute sys_ipl_ccw_loadparm_attr =
485 __ATTR(loadparm, 0444, ipl_ccw_loadparm_show, NULL);
487 static struct attribute *ipl_ccw_attrs_vm[] = {
488 &sys_ipl_type_attr.attr,
489 &sys_ipl_device_attr.attr,
490 &sys_ipl_ccw_loadparm_attr.attr,
491 &sys_ipl_vm_parm_attr.attr,
492 NULL,
495 static struct attribute *ipl_ccw_attrs_lpar[] = {
496 &sys_ipl_type_attr.attr,
497 &sys_ipl_device_attr.attr,
498 &sys_ipl_ccw_loadparm_attr.attr,
499 NULL,
502 static struct attribute_group ipl_ccw_attr_group_vm = {
503 .attrs = ipl_ccw_attrs_vm,
506 static struct attribute_group ipl_ccw_attr_group_lpar = {
507 .attrs = ipl_ccw_attrs_lpar
510 /* NSS ipl device attributes */
512 DEFINE_IPL_ATTR_RO(ipl_nss, name, "%s\n", kernel_nss_name);
514 static struct attribute *ipl_nss_attrs[] = {
515 &sys_ipl_type_attr.attr,
516 &sys_ipl_nss_name_attr.attr,
517 &sys_ipl_ccw_loadparm_attr.attr,
518 &sys_ipl_vm_parm_attr.attr,
519 NULL,
522 static struct attribute_group ipl_nss_attr_group = {
523 .attrs = ipl_nss_attrs,
526 /* UNKNOWN ipl device attributes */
528 static struct attribute *ipl_unknown_attrs[] = {
529 &sys_ipl_type_attr.attr,
530 NULL,
533 static struct attribute_group ipl_unknown_attr_group = {
534 .attrs = ipl_unknown_attrs,
537 static struct kset *ipl_kset;
539 static int __init ipl_register_fcp_files(void)
541 int rc;
543 rc = sysfs_create_group(&ipl_kset->kobj, &ipl_fcp_attr_group);
544 if (rc)
545 goto out;
546 rc = sysfs_create_bin_file(&ipl_kset->kobj, &ipl_parameter_attr);
547 if (rc)
548 goto out_ipl_parm;
549 rc = sysfs_create_bin_file(&ipl_kset->kobj, &ipl_scp_data_attr);
550 if (!rc)
551 goto out;
553 sysfs_remove_bin_file(&ipl_kset->kobj, &ipl_parameter_attr);
555 out_ipl_parm:
556 sysfs_remove_group(&ipl_kset->kobj, &ipl_fcp_attr_group);
557 out:
558 return rc;
561 static void __ipl_run(void *unused)
563 diag308(DIAG308_IPL, NULL);
564 if (MACHINE_IS_VM)
565 __cpcmd("IPL", NULL, 0, NULL);
566 else if (ipl_info.type == IPL_TYPE_CCW)
567 reipl_ccw_dev(&ipl_info.data.ccw.dev_id);
570 static void ipl_run(struct shutdown_trigger *trigger)
572 smp_switch_to_ipl_cpu(__ipl_run, NULL);
575 static int __init ipl_init(void)
577 int rc;
579 ipl_kset = kset_create_and_add("ipl", NULL, firmware_kobj);
580 if (!ipl_kset) {
581 rc = -ENOMEM;
582 goto out;
584 switch (ipl_info.type) {
585 case IPL_TYPE_CCW:
586 if (MACHINE_IS_VM)
587 rc = sysfs_create_group(&ipl_kset->kobj,
588 &ipl_ccw_attr_group_vm);
589 else
590 rc = sysfs_create_group(&ipl_kset->kobj,
591 &ipl_ccw_attr_group_lpar);
592 break;
593 case IPL_TYPE_FCP:
594 case IPL_TYPE_FCP_DUMP:
595 rc = ipl_register_fcp_files();
596 break;
597 case IPL_TYPE_NSS:
598 rc = sysfs_create_group(&ipl_kset->kobj, &ipl_nss_attr_group);
599 break;
600 default:
601 rc = sysfs_create_group(&ipl_kset->kobj,
602 &ipl_unknown_attr_group);
603 break;
605 out:
606 if (rc)
607 panic("ipl_init failed: rc = %i\n", rc);
609 return 0;
612 static struct shutdown_action __refdata ipl_action = {
613 .name = SHUTDOWN_ACTION_IPL_STR,
614 .fn = ipl_run,
615 .init = ipl_init,
619 * reipl shutdown action: Reboot Linux on shutdown.
622 /* VM IPL PARM attributes */
623 static ssize_t reipl_generic_vmparm_show(struct ipl_parameter_block *ipb,
624 char *page)
626 char vmparm[DIAG308_VMPARM_SIZE + 1] = {};
628 reipl_get_ascii_vmparm(vmparm, sizeof(vmparm), ipb);
629 return sprintf(page, "%s\n", vmparm);
632 static ssize_t reipl_generic_vmparm_store(struct ipl_parameter_block *ipb,
633 size_t vmparm_max,
634 const char *buf, size_t len)
636 int i, ip_len;
638 /* ignore trailing newline */
639 ip_len = len;
640 if ((len > 0) && (buf[len - 1] == '\n'))
641 ip_len--;
643 if (ip_len > vmparm_max)
644 return -EINVAL;
646 /* parm is used to store kernel options, check for common chars */
647 for (i = 0; i < ip_len; i++)
648 if (!(isalnum(buf[i]) || isascii(buf[i]) || isprint(buf[i])))
649 return -EINVAL;
651 memset(ipb->ipl_info.ccw.vm_parm, 0, DIAG308_VMPARM_SIZE);
652 ipb->ipl_info.ccw.vm_parm_len = ip_len;
653 if (ip_len > 0) {
654 ipb->ipl_info.ccw.vm_flags |= DIAG308_VM_FLAGS_VP_VALID;
655 memcpy(ipb->ipl_info.ccw.vm_parm, buf, ip_len);
656 ASCEBC(ipb->ipl_info.ccw.vm_parm, ip_len);
657 } else {
658 ipb->ipl_info.ccw.vm_flags &= ~DIAG308_VM_FLAGS_VP_VALID;
661 return len;
664 /* NSS wrapper */
665 static ssize_t reipl_nss_vmparm_show(struct kobject *kobj,
666 struct kobj_attribute *attr, char *page)
668 return reipl_generic_vmparm_show(reipl_block_nss, page);
671 static ssize_t reipl_nss_vmparm_store(struct kobject *kobj,
672 struct kobj_attribute *attr,
673 const char *buf, size_t len)
675 return reipl_generic_vmparm_store(reipl_block_nss, 56, buf, len);
678 /* CCW wrapper */
679 static ssize_t reipl_ccw_vmparm_show(struct kobject *kobj,
680 struct kobj_attribute *attr, char *page)
682 return reipl_generic_vmparm_show(reipl_block_ccw, page);
685 static ssize_t reipl_ccw_vmparm_store(struct kobject *kobj,
686 struct kobj_attribute *attr,
687 const char *buf, size_t len)
689 return reipl_generic_vmparm_store(reipl_block_ccw, 64, buf, len);
692 static struct kobj_attribute sys_reipl_nss_vmparm_attr =
693 __ATTR(parm, S_IRUGO | S_IWUSR, reipl_nss_vmparm_show,
694 reipl_nss_vmparm_store);
695 static struct kobj_attribute sys_reipl_ccw_vmparm_attr =
696 __ATTR(parm, S_IRUGO | S_IWUSR, reipl_ccw_vmparm_show,
697 reipl_ccw_vmparm_store);
699 /* FCP reipl device attributes */
701 static ssize_t reipl_fcp_scpdata_read(struct file *filp, struct kobject *kobj,
702 struct bin_attribute *attr,
703 char *buf, loff_t off, size_t count)
705 size_t size = reipl_block_fcp->ipl_info.fcp.scp_data_len;
706 void *scp_data = reipl_block_fcp->ipl_info.fcp.scp_data;
708 return memory_read_from_buffer(buf, count, &off, scp_data, size);
711 static ssize_t reipl_fcp_scpdata_write(struct file *filp, struct kobject *kobj,
712 struct bin_attribute *attr,
713 char *buf, loff_t off, size_t count)
715 size_t padding;
716 size_t scpdata_len;
718 if (off < 0)
719 return -EINVAL;
721 if (off >= DIAG308_SCPDATA_SIZE)
722 return -ENOSPC;
724 if (count > DIAG308_SCPDATA_SIZE - off)
725 count = DIAG308_SCPDATA_SIZE - off;
727 memcpy(reipl_block_fcp->ipl_info.fcp.scp_data, buf + off, count);
728 scpdata_len = off + count;
730 if (scpdata_len % 8) {
731 padding = 8 - (scpdata_len % 8);
732 memset(reipl_block_fcp->ipl_info.fcp.scp_data + scpdata_len,
733 0, padding);
734 scpdata_len += padding;
737 reipl_block_fcp->ipl_info.fcp.scp_data_len = scpdata_len;
738 reipl_block_fcp->hdr.len = IPL_PARM_BLK_FCP_LEN + scpdata_len;
739 reipl_block_fcp->hdr.blk0_len = IPL_PARM_BLK0_FCP_LEN + scpdata_len;
741 return count;
744 static struct bin_attribute sys_reipl_fcp_scp_data_attr = {
745 .attr = {
746 .name = "scp_data",
747 .mode = S_IRUGO | S_IWUSR,
749 .size = PAGE_SIZE,
750 .read = reipl_fcp_scpdata_read,
751 .write = reipl_fcp_scpdata_write,
754 DEFINE_IPL_ATTR_RW(reipl_fcp, wwpn, "0x%016llx\n", "%016llx\n",
755 reipl_block_fcp->ipl_info.fcp.wwpn);
756 DEFINE_IPL_ATTR_RW(reipl_fcp, lun, "0x%016llx\n", "%016llx\n",
757 reipl_block_fcp->ipl_info.fcp.lun);
758 DEFINE_IPL_ATTR_RW(reipl_fcp, bootprog, "%lld\n", "%lld\n",
759 reipl_block_fcp->ipl_info.fcp.bootprog);
760 DEFINE_IPL_ATTR_RW(reipl_fcp, br_lba, "%lld\n", "%lld\n",
761 reipl_block_fcp->ipl_info.fcp.br_lba);
762 DEFINE_IPL_ATTR_RW(reipl_fcp, device, "0.0.%04llx\n", "0.0.%llx\n",
763 reipl_block_fcp->ipl_info.fcp.devno);
765 static struct attribute *reipl_fcp_attrs[] = {
766 &sys_reipl_fcp_device_attr.attr,
767 &sys_reipl_fcp_wwpn_attr.attr,
768 &sys_reipl_fcp_lun_attr.attr,
769 &sys_reipl_fcp_bootprog_attr.attr,
770 &sys_reipl_fcp_br_lba_attr.attr,
771 NULL,
774 static struct attribute_group reipl_fcp_attr_group = {
775 .attrs = reipl_fcp_attrs,
778 /* CCW reipl device attributes */
780 DEFINE_IPL_ATTR_RW(reipl_ccw, device, "0.0.%04llx\n", "0.0.%llx\n",
781 reipl_block_ccw->ipl_info.ccw.devno);
783 static void reipl_get_ascii_loadparm(char *loadparm,
784 struct ipl_parameter_block *ibp)
786 memcpy(loadparm, ibp->ipl_info.ccw.load_parm, LOADPARM_LEN);
787 EBCASC(loadparm, LOADPARM_LEN);
788 loadparm[LOADPARM_LEN] = 0;
789 strim(loadparm);
792 static ssize_t reipl_generic_loadparm_show(struct ipl_parameter_block *ipb,
793 char *page)
795 char buf[LOADPARM_LEN + 1];
797 reipl_get_ascii_loadparm(buf, ipb);
798 return sprintf(page, "%s\n", buf);
801 static ssize_t reipl_generic_loadparm_store(struct ipl_parameter_block *ipb,
802 const char *buf, size_t len)
804 int i, lp_len;
806 /* ignore trailing newline */
807 lp_len = len;
808 if ((len > 0) && (buf[len - 1] == '\n'))
809 lp_len--;
810 /* loadparm can have max 8 characters and must not start with a blank */
811 if ((lp_len > LOADPARM_LEN) || ((lp_len > 0) && (buf[0] == ' ')))
812 return -EINVAL;
813 /* loadparm can only contain "a-z,A-Z,0-9,SP,." */
814 for (i = 0; i < lp_len; i++) {
815 if (isalpha(buf[i]) || isdigit(buf[i]) || (buf[i] == ' ') ||
816 (buf[i] == '.'))
817 continue;
818 return -EINVAL;
820 /* initialize loadparm with blanks */
821 memset(ipb->ipl_info.ccw.load_parm, ' ', LOADPARM_LEN);
822 /* copy and convert to ebcdic */
823 memcpy(ipb->ipl_info.ccw.load_parm, buf, lp_len);
824 ASCEBC(ipb->ipl_info.ccw.load_parm, LOADPARM_LEN);
825 return len;
828 /* NSS wrapper */
829 static ssize_t reipl_nss_loadparm_show(struct kobject *kobj,
830 struct kobj_attribute *attr, char *page)
832 return reipl_generic_loadparm_show(reipl_block_nss, page);
835 static ssize_t reipl_nss_loadparm_store(struct kobject *kobj,
836 struct kobj_attribute *attr,
837 const char *buf, size_t len)
839 return reipl_generic_loadparm_store(reipl_block_nss, buf, len);
842 /* CCW wrapper */
843 static ssize_t reipl_ccw_loadparm_show(struct kobject *kobj,
844 struct kobj_attribute *attr, char *page)
846 return reipl_generic_loadparm_show(reipl_block_ccw, page);
849 static ssize_t reipl_ccw_loadparm_store(struct kobject *kobj,
850 struct kobj_attribute *attr,
851 const char *buf, size_t len)
853 return reipl_generic_loadparm_store(reipl_block_ccw, buf, len);
856 static struct kobj_attribute sys_reipl_ccw_loadparm_attr =
857 __ATTR(loadparm, S_IRUGO | S_IWUSR, reipl_ccw_loadparm_show,
858 reipl_ccw_loadparm_store);
860 static struct attribute *reipl_ccw_attrs_vm[] = {
861 &sys_reipl_ccw_device_attr.attr,
862 &sys_reipl_ccw_loadparm_attr.attr,
863 &sys_reipl_ccw_vmparm_attr.attr,
864 NULL,
867 static struct attribute *reipl_ccw_attrs_lpar[] = {
868 &sys_reipl_ccw_device_attr.attr,
869 &sys_reipl_ccw_loadparm_attr.attr,
870 NULL,
873 static struct attribute_group reipl_ccw_attr_group_vm = {
874 .name = IPL_CCW_STR,
875 .attrs = reipl_ccw_attrs_vm,
878 static struct attribute_group reipl_ccw_attr_group_lpar = {
879 .name = IPL_CCW_STR,
880 .attrs = reipl_ccw_attrs_lpar,
884 /* NSS reipl device attributes */
885 static void reipl_get_ascii_nss_name(char *dst,
886 struct ipl_parameter_block *ipb)
888 memcpy(dst, ipb->ipl_info.ccw.nss_name, NSS_NAME_SIZE);
889 EBCASC(dst, NSS_NAME_SIZE);
890 dst[NSS_NAME_SIZE] = 0;
893 static ssize_t reipl_nss_name_show(struct kobject *kobj,
894 struct kobj_attribute *attr, char *page)
896 char nss_name[NSS_NAME_SIZE + 1] = {};
898 reipl_get_ascii_nss_name(nss_name, reipl_block_nss);
899 return sprintf(page, "%s\n", nss_name);
902 static ssize_t reipl_nss_name_store(struct kobject *kobj,
903 struct kobj_attribute *attr,
904 const char *buf, size_t len)
906 int nss_len;
908 /* ignore trailing newline */
909 nss_len = len;
910 if ((len > 0) && (buf[len - 1] == '\n'))
911 nss_len--;
913 if (nss_len > NSS_NAME_SIZE)
914 return -EINVAL;
916 memset(reipl_block_nss->ipl_info.ccw.nss_name, 0x40, NSS_NAME_SIZE);
917 if (nss_len > 0) {
918 reipl_block_nss->ipl_info.ccw.vm_flags |=
919 DIAG308_VM_FLAGS_NSS_VALID;
920 memcpy(reipl_block_nss->ipl_info.ccw.nss_name, buf, nss_len);
921 ASCEBC(reipl_block_nss->ipl_info.ccw.nss_name, nss_len);
922 EBC_TOUPPER(reipl_block_nss->ipl_info.ccw.nss_name, nss_len);
923 } else {
924 reipl_block_nss->ipl_info.ccw.vm_flags &=
925 ~DIAG308_VM_FLAGS_NSS_VALID;
928 return len;
931 static struct kobj_attribute sys_reipl_nss_name_attr =
932 __ATTR(name, S_IRUGO | S_IWUSR, reipl_nss_name_show,
933 reipl_nss_name_store);
935 static struct kobj_attribute sys_reipl_nss_loadparm_attr =
936 __ATTR(loadparm, S_IRUGO | S_IWUSR, reipl_nss_loadparm_show,
937 reipl_nss_loadparm_store);
939 static struct attribute *reipl_nss_attrs[] = {
940 &sys_reipl_nss_name_attr.attr,
941 &sys_reipl_nss_loadparm_attr.attr,
942 &sys_reipl_nss_vmparm_attr.attr,
943 NULL,
946 static struct attribute_group reipl_nss_attr_group = {
947 .name = IPL_NSS_STR,
948 .attrs = reipl_nss_attrs,
951 /* reipl type */
953 static int reipl_set_type(enum ipl_type type)
955 if (!(reipl_capabilities & type))
956 return -EINVAL;
958 switch(type) {
959 case IPL_TYPE_CCW:
960 if (diag308_set_works)
961 reipl_method = REIPL_METHOD_CCW_DIAG;
962 else if (MACHINE_IS_VM)
963 reipl_method = REIPL_METHOD_CCW_VM;
964 else
965 reipl_method = REIPL_METHOD_CCW_CIO;
966 reipl_block_actual = reipl_block_ccw;
967 break;
968 case IPL_TYPE_FCP:
969 if (diag308_set_works)
970 reipl_method = REIPL_METHOD_FCP_RW_DIAG;
971 else if (MACHINE_IS_VM)
972 reipl_method = REIPL_METHOD_FCP_RO_VM;
973 else
974 reipl_method = REIPL_METHOD_FCP_RO_DIAG;
975 reipl_block_actual = reipl_block_fcp;
976 break;
977 case IPL_TYPE_FCP_DUMP:
978 reipl_method = REIPL_METHOD_FCP_DUMP;
979 break;
980 case IPL_TYPE_NSS:
981 if (diag308_set_works)
982 reipl_method = REIPL_METHOD_NSS_DIAG;
983 else
984 reipl_method = REIPL_METHOD_NSS;
985 reipl_block_actual = reipl_block_nss;
986 break;
987 case IPL_TYPE_UNKNOWN:
988 reipl_method = REIPL_METHOD_DEFAULT;
989 break;
990 default:
991 BUG();
993 reipl_type = type;
994 return 0;
997 static ssize_t reipl_type_show(struct kobject *kobj,
998 struct kobj_attribute *attr, char *page)
1000 return sprintf(page, "%s\n", ipl_type_str(reipl_type));
1003 static ssize_t reipl_type_store(struct kobject *kobj,
1004 struct kobj_attribute *attr,
1005 const char *buf, size_t len)
1007 int rc = -EINVAL;
1009 if (strncmp(buf, IPL_CCW_STR, strlen(IPL_CCW_STR)) == 0)
1010 rc = reipl_set_type(IPL_TYPE_CCW);
1011 else if (strncmp(buf, IPL_FCP_STR, strlen(IPL_FCP_STR)) == 0)
1012 rc = reipl_set_type(IPL_TYPE_FCP);
1013 else if (strncmp(buf, IPL_NSS_STR, strlen(IPL_NSS_STR)) == 0)
1014 rc = reipl_set_type(IPL_TYPE_NSS);
1015 return (rc != 0) ? rc : len;
1018 static struct kobj_attribute reipl_type_attr =
1019 __ATTR(reipl_type, 0644, reipl_type_show, reipl_type_store);
1021 static struct kset *reipl_kset;
1022 static struct kset *reipl_fcp_kset;
1024 static void get_ipl_string(char *dst, struct ipl_parameter_block *ipb,
1025 const enum ipl_method m)
1027 char loadparm[LOADPARM_LEN + 1] = {};
1028 char vmparm[DIAG308_VMPARM_SIZE + 1] = {};
1029 char nss_name[NSS_NAME_SIZE + 1] = {};
1030 size_t pos = 0;
1032 reipl_get_ascii_loadparm(loadparm, ipb);
1033 reipl_get_ascii_nss_name(nss_name, ipb);
1034 reipl_get_ascii_vmparm(vmparm, sizeof(vmparm), ipb);
1036 switch (m) {
1037 case REIPL_METHOD_CCW_VM:
1038 pos = sprintf(dst, "IPL %X CLEAR", ipb->ipl_info.ccw.devno);
1039 break;
1040 case REIPL_METHOD_NSS:
1041 pos = sprintf(dst, "IPL %s", nss_name);
1042 break;
1043 default:
1044 break;
1046 if (strlen(loadparm) > 0)
1047 pos += sprintf(dst + pos, " LOADPARM '%s'", loadparm);
1048 if (strlen(vmparm) > 0)
1049 sprintf(dst + pos, " PARM %s", vmparm);
1052 static void __reipl_run(void *unused)
1054 struct ccw_dev_id devid;
1055 static char buf[128];
1057 switch (reipl_method) {
1058 case REIPL_METHOD_CCW_CIO:
1059 devid.devno = reipl_block_ccw->ipl_info.ccw.devno;
1060 devid.ssid = 0;
1061 reipl_ccw_dev(&devid);
1062 break;
1063 case REIPL_METHOD_CCW_VM:
1064 get_ipl_string(buf, reipl_block_ccw, REIPL_METHOD_CCW_VM);
1065 __cpcmd(buf, NULL, 0, NULL);
1066 break;
1067 case REIPL_METHOD_CCW_DIAG:
1068 diag308(DIAG308_SET, reipl_block_ccw);
1069 diag308(DIAG308_IPL, NULL);
1070 break;
1071 case REIPL_METHOD_FCP_RW_DIAG:
1072 diag308(DIAG308_SET, reipl_block_fcp);
1073 diag308(DIAG308_IPL, NULL);
1074 break;
1075 case REIPL_METHOD_FCP_RO_DIAG:
1076 diag308(DIAG308_IPL, NULL);
1077 break;
1078 case REIPL_METHOD_FCP_RO_VM:
1079 __cpcmd("IPL", NULL, 0, NULL);
1080 break;
1081 case REIPL_METHOD_NSS_DIAG:
1082 diag308(DIAG308_SET, reipl_block_nss);
1083 diag308(DIAG308_IPL, NULL);
1084 break;
1085 case REIPL_METHOD_NSS:
1086 get_ipl_string(buf, reipl_block_nss, REIPL_METHOD_NSS);
1087 __cpcmd(buf, NULL, 0, NULL);
1088 break;
1089 case REIPL_METHOD_DEFAULT:
1090 if (MACHINE_IS_VM)
1091 __cpcmd("IPL", NULL, 0, NULL);
1092 diag308(DIAG308_IPL, NULL);
1093 break;
1094 case REIPL_METHOD_FCP_DUMP:
1095 break;
1097 disabled_wait((unsigned long) __builtin_return_address(0));
1100 static void reipl_run(struct shutdown_trigger *trigger)
1102 smp_switch_to_ipl_cpu(__reipl_run, NULL);
1105 static void reipl_block_ccw_init(struct ipl_parameter_block *ipb)
1107 ipb->hdr.len = IPL_PARM_BLK_CCW_LEN;
1108 ipb->hdr.version = IPL_PARM_BLOCK_VERSION;
1109 ipb->hdr.blk0_len = IPL_PARM_BLK0_CCW_LEN;
1110 ipb->hdr.pbt = DIAG308_IPL_TYPE_CCW;
1113 static void reipl_block_ccw_fill_parms(struct ipl_parameter_block *ipb)
1115 /* LOADPARM */
1116 /* check if read scp info worked and set loadparm */
1117 if (sclp_ipl_info.is_valid)
1118 memcpy(ipb->ipl_info.ccw.load_parm,
1119 &sclp_ipl_info.loadparm, LOADPARM_LEN);
1120 else
1121 /* read scp info failed: set empty loadparm (EBCDIC blanks) */
1122 memset(ipb->ipl_info.ccw.load_parm, 0x40, LOADPARM_LEN);
1123 ipb->hdr.flags = DIAG308_FLAGS_LP_VALID;
1125 /* VM PARM */
1126 if (MACHINE_IS_VM && diag308_set_works &&
1127 (ipl_block.ipl_info.ccw.vm_flags & DIAG308_VM_FLAGS_VP_VALID)) {
1129 ipb->ipl_info.ccw.vm_flags |= DIAG308_VM_FLAGS_VP_VALID;
1130 ipb->ipl_info.ccw.vm_parm_len =
1131 ipl_block.ipl_info.ccw.vm_parm_len;
1132 memcpy(ipb->ipl_info.ccw.vm_parm,
1133 ipl_block.ipl_info.ccw.vm_parm, DIAG308_VMPARM_SIZE);
1137 static int __init reipl_nss_init(void)
1139 int rc;
1141 if (!MACHINE_IS_VM)
1142 return 0;
1144 reipl_block_nss = (void *) get_zeroed_page(GFP_KERNEL);
1145 if (!reipl_block_nss)
1146 return -ENOMEM;
1148 if (!diag308_set_works)
1149 sys_reipl_nss_vmparm_attr.attr.mode = S_IRUGO;
1151 rc = sysfs_create_group(&reipl_kset->kobj, &reipl_nss_attr_group);
1152 if (rc)
1153 return rc;
1155 reipl_block_ccw_init(reipl_block_nss);
1156 if (ipl_info.type == IPL_TYPE_NSS) {
1157 memset(reipl_block_nss->ipl_info.ccw.nss_name,
1158 ' ', NSS_NAME_SIZE);
1159 memcpy(reipl_block_nss->ipl_info.ccw.nss_name,
1160 kernel_nss_name, strlen(kernel_nss_name));
1161 ASCEBC(reipl_block_nss->ipl_info.ccw.nss_name, NSS_NAME_SIZE);
1162 reipl_block_nss->ipl_info.ccw.vm_flags |=
1163 DIAG308_VM_FLAGS_NSS_VALID;
1165 reipl_block_ccw_fill_parms(reipl_block_nss);
1168 reipl_capabilities |= IPL_TYPE_NSS;
1169 return 0;
1172 static int __init reipl_ccw_init(void)
1174 int rc;
1176 reipl_block_ccw = (void *) get_zeroed_page(GFP_KERNEL);
1177 if (!reipl_block_ccw)
1178 return -ENOMEM;
1180 if (MACHINE_IS_VM) {
1181 if (!diag308_set_works)
1182 sys_reipl_ccw_vmparm_attr.attr.mode = S_IRUGO;
1183 rc = sysfs_create_group(&reipl_kset->kobj,
1184 &reipl_ccw_attr_group_vm);
1185 } else {
1186 if(!diag308_set_works)
1187 sys_reipl_ccw_loadparm_attr.attr.mode = S_IRUGO;
1188 rc = sysfs_create_group(&reipl_kset->kobj,
1189 &reipl_ccw_attr_group_lpar);
1191 if (rc)
1192 return rc;
1194 reipl_block_ccw_init(reipl_block_ccw);
1195 if (ipl_info.type == IPL_TYPE_CCW) {
1196 reipl_block_ccw->ipl_info.ccw.devno = ipl_devno;
1197 reipl_block_ccw_fill_parms(reipl_block_ccw);
1200 reipl_capabilities |= IPL_TYPE_CCW;
1201 return 0;
1204 static int __init reipl_fcp_init(void)
1206 int rc;
1208 if (!diag308_set_works) {
1209 if (ipl_info.type == IPL_TYPE_FCP) {
1210 make_attrs_ro(reipl_fcp_attrs);
1211 sys_reipl_fcp_scp_data_attr.attr.mode = S_IRUGO;
1212 } else
1213 return 0;
1216 reipl_block_fcp = (void *) get_zeroed_page(GFP_KERNEL);
1217 if (!reipl_block_fcp)
1218 return -ENOMEM;
1220 /* sysfs: create fcp kset for mixing attr group and bin attrs */
1221 reipl_fcp_kset = kset_create_and_add(IPL_FCP_STR, NULL,
1222 &reipl_kset->kobj);
1223 if (!reipl_kset) {
1224 free_page((unsigned long) reipl_block_fcp);
1225 return -ENOMEM;
1228 rc = sysfs_create_group(&reipl_fcp_kset->kobj, &reipl_fcp_attr_group);
1229 if (rc) {
1230 kset_unregister(reipl_fcp_kset);
1231 free_page((unsigned long) reipl_block_fcp);
1232 return rc;
1235 rc = sysfs_create_bin_file(&reipl_fcp_kset->kobj,
1236 &sys_reipl_fcp_scp_data_attr);
1237 if (rc) {
1238 sysfs_remove_group(&reipl_fcp_kset->kobj, &reipl_fcp_attr_group);
1239 kset_unregister(reipl_fcp_kset);
1240 free_page((unsigned long) reipl_block_fcp);
1241 return rc;
1244 if (ipl_info.type == IPL_TYPE_FCP)
1245 memcpy(reipl_block_fcp, IPL_PARMBLOCK_START, PAGE_SIZE);
1246 else {
1247 reipl_block_fcp->hdr.len = IPL_PARM_BLK_FCP_LEN;
1248 reipl_block_fcp->hdr.version = IPL_PARM_BLOCK_VERSION;
1249 reipl_block_fcp->hdr.blk0_len = IPL_PARM_BLK0_FCP_LEN;
1250 reipl_block_fcp->hdr.pbt = DIAG308_IPL_TYPE_FCP;
1251 reipl_block_fcp->ipl_info.fcp.opt = DIAG308_IPL_OPT_IPL;
1253 reipl_capabilities |= IPL_TYPE_FCP;
1254 return 0;
1257 static int __init reipl_init(void)
1259 int rc;
1261 reipl_kset = kset_create_and_add("reipl", NULL, firmware_kobj);
1262 if (!reipl_kset)
1263 return -ENOMEM;
1264 rc = sysfs_create_file(&reipl_kset->kobj, &reipl_type_attr.attr);
1265 if (rc) {
1266 kset_unregister(reipl_kset);
1267 return rc;
1269 rc = reipl_ccw_init();
1270 if (rc)
1271 return rc;
1272 rc = reipl_fcp_init();
1273 if (rc)
1274 return rc;
1275 rc = reipl_nss_init();
1276 if (rc)
1277 return rc;
1278 rc = reipl_set_type(ipl_info.type);
1279 if (rc)
1280 return rc;
1281 return 0;
1284 static struct shutdown_action __refdata reipl_action = {
1285 .name = SHUTDOWN_ACTION_REIPL_STR,
1286 .fn = reipl_run,
1287 .init = reipl_init,
1291 * dump shutdown action: Dump Linux on shutdown.
1294 /* FCP dump device attributes */
1296 DEFINE_IPL_ATTR_RW(dump_fcp, wwpn, "0x%016llx\n", "%016llx\n",
1297 dump_block_fcp->ipl_info.fcp.wwpn);
1298 DEFINE_IPL_ATTR_RW(dump_fcp, lun, "0x%016llx\n", "%016llx\n",
1299 dump_block_fcp->ipl_info.fcp.lun);
1300 DEFINE_IPL_ATTR_RW(dump_fcp, bootprog, "%lld\n", "%lld\n",
1301 dump_block_fcp->ipl_info.fcp.bootprog);
1302 DEFINE_IPL_ATTR_RW(dump_fcp, br_lba, "%lld\n", "%lld\n",
1303 dump_block_fcp->ipl_info.fcp.br_lba);
1304 DEFINE_IPL_ATTR_RW(dump_fcp, device, "0.0.%04llx\n", "0.0.%llx\n",
1305 dump_block_fcp->ipl_info.fcp.devno);
1307 static struct attribute *dump_fcp_attrs[] = {
1308 &sys_dump_fcp_device_attr.attr,
1309 &sys_dump_fcp_wwpn_attr.attr,
1310 &sys_dump_fcp_lun_attr.attr,
1311 &sys_dump_fcp_bootprog_attr.attr,
1312 &sys_dump_fcp_br_lba_attr.attr,
1313 NULL,
1316 static struct attribute_group dump_fcp_attr_group = {
1317 .name = IPL_FCP_STR,
1318 .attrs = dump_fcp_attrs,
1321 /* CCW dump device attributes */
1323 DEFINE_IPL_ATTR_RW(dump_ccw, device, "0.0.%04llx\n", "0.0.%llx\n",
1324 dump_block_ccw->ipl_info.ccw.devno);
1326 static struct attribute *dump_ccw_attrs[] = {
1327 &sys_dump_ccw_device_attr.attr,
1328 NULL,
1331 static struct attribute_group dump_ccw_attr_group = {
1332 .name = IPL_CCW_STR,
1333 .attrs = dump_ccw_attrs,
1336 /* dump type */
1338 static int dump_set_type(enum dump_type type)
1340 if (!(dump_capabilities & type))
1341 return -EINVAL;
1342 switch (type) {
1343 case DUMP_TYPE_CCW:
1344 if (diag308_set_works)
1345 dump_method = DUMP_METHOD_CCW_DIAG;
1346 else if (MACHINE_IS_VM)
1347 dump_method = DUMP_METHOD_CCW_VM;
1348 else
1349 dump_method = DUMP_METHOD_CCW_CIO;
1350 break;
1351 case DUMP_TYPE_FCP:
1352 dump_method = DUMP_METHOD_FCP_DIAG;
1353 break;
1354 default:
1355 dump_method = DUMP_METHOD_NONE;
1357 dump_type = type;
1358 return 0;
1361 static ssize_t dump_type_show(struct kobject *kobj,
1362 struct kobj_attribute *attr, char *page)
1364 return sprintf(page, "%s\n", dump_type_str(dump_type));
1367 static ssize_t dump_type_store(struct kobject *kobj,
1368 struct kobj_attribute *attr,
1369 const char *buf, size_t len)
1371 int rc = -EINVAL;
1373 if (strncmp(buf, DUMP_NONE_STR, strlen(DUMP_NONE_STR)) == 0)
1374 rc = dump_set_type(DUMP_TYPE_NONE);
1375 else if (strncmp(buf, DUMP_CCW_STR, strlen(DUMP_CCW_STR)) == 0)
1376 rc = dump_set_type(DUMP_TYPE_CCW);
1377 else if (strncmp(buf, DUMP_FCP_STR, strlen(DUMP_FCP_STR)) == 0)
1378 rc = dump_set_type(DUMP_TYPE_FCP);
1379 return (rc != 0) ? rc : len;
1382 static struct kobj_attribute dump_type_attr =
1383 __ATTR(dump_type, 0644, dump_type_show, dump_type_store);
1385 static struct kset *dump_kset;
1387 static void __dump_run(void *unused)
1389 struct ccw_dev_id devid;
1390 static char buf[100];
1392 switch (dump_method) {
1393 case DUMP_METHOD_CCW_CIO:
1394 devid.devno = dump_block_ccw->ipl_info.ccw.devno;
1395 devid.ssid = 0;
1396 reipl_ccw_dev(&devid);
1397 break;
1398 case DUMP_METHOD_CCW_VM:
1399 sprintf(buf, "STORE STATUS");
1400 __cpcmd(buf, NULL, 0, NULL);
1401 sprintf(buf, "IPL %X", dump_block_ccw->ipl_info.ccw.devno);
1402 __cpcmd(buf, NULL, 0, NULL);
1403 break;
1404 case DUMP_METHOD_CCW_DIAG:
1405 diag308(DIAG308_SET, dump_block_ccw);
1406 diag308(DIAG308_DUMP, NULL);
1407 break;
1408 case DUMP_METHOD_FCP_DIAG:
1409 diag308(DIAG308_SET, dump_block_fcp);
1410 diag308(DIAG308_DUMP, NULL);
1411 break;
1412 default:
1413 break;
1417 static void dump_run(struct shutdown_trigger *trigger)
1419 if (dump_method == DUMP_METHOD_NONE)
1420 return;
1421 smp_send_stop();
1422 smp_switch_to_ipl_cpu(__dump_run, NULL);
1425 static int __init dump_ccw_init(void)
1427 int rc;
1429 dump_block_ccw = (void *) get_zeroed_page(GFP_KERNEL);
1430 if (!dump_block_ccw)
1431 return -ENOMEM;
1432 rc = sysfs_create_group(&dump_kset->kobj, &dump_ccw_attr_group);
1433 if (rc) {
1434 free_page((unsigned long)dump_block_ccw);
1435 return rc;
1437 dump_block_ccw->hdr.len = IPL_PARM_BLK_CCW_LEN;
1438 dump_block_ccw->hdr.version = IPL_PARM_BLOCK_VERSION;
1439 dump_block_ccw->hdr.blk0_len = IPL_PARM_BLK0_CCW_LEN;
1440 dump_block_ccw->hdr.pbt = DIAG308_IPL_TYPE_CCW;
1441 dump_capabilities |= DUMP_TYPE_CCW;
1442 return 0;
1445 static int __init dump_fcp_init(void)
1447 int rc;
1449 if (!sclp_ipl_info.has_dump)
1450 return 0; /* LDIPL DUMP is not installed */
1451 if (!diag308_set_works)
1452 return 0;
1453 dump_block_fcp = (void *) get_zeroed_page(GFP_KERNEL);
1454 if (!dump_block_fcp)
1455 return -ENOMEM;
1456 rc = sysfs_create_group(&dump_kset->kobj, &dump_fcp_attr_group);
1457 if (rc) {
1458 free_page((unsigned long)dump_block_fcp);
1459 return rc;
1461 dump_block_fcp->hdr.len = IPL_PARM_BLK_FCP_LEN;
1462 dump_block_fcp->hdr.version = IPL_PARM_BLOCK_VERSION;
1463 dump_block_fcp->hdr.blk0_len = IPL_PARM_BLK0_FCP_LEN;
1464 dump_block_fcp->hdr.pbt = DIAG308_IPL_TYPE_FCP;
1465 dump_block_fcp->ipl_info.fcp.opt = DIAG308_IPL_OPT_DUMP;
1466 dump_capabilities |= DUMP_TYPE_FCP;
1467 return 0;
1470 static int __init dump_init(void)
1472 int rc;
1474 dump_kset = kset_create_and_add("dump", NULL, firmware_kobj);
1475 if (!dump_kset)
1476 return -ENOMEM;
1477 rc = sysfs_create_file(&dump_kset->kobj, &dump_type_attr.attr);
1478 if (rc) {
1479 kset_unregister(dump_kset);
1480 return rc;
1482 rc = dump_ccw_init();
1483 if (rc)
1484 return rc;
1485 rc = dump_fcp_init();
1486 if (rc)
1487 return rc;
1488 dump_set_type(DUMP_TYPE_NONE);
1489 return 0;
1492 static struct shutdown_action __refdata dump_action = {
1493 .name = SHUTDOWN_ACTION_DUMP_STR,
1494 .fn = dump_run,
1495 .init = dump_init,
1498 static void dump_reipl_run(struct shutdown_trigger *trigger)
1500 preempt_disable();
1502 * Bypass dynamic address translation (DAT) when storing IPL parameter
1503 * information block address and checksum into the prefix area
1504 * (corresponding to absolute addresses 0-8191).
1505 * When enhanced DAT applies and the STE format control in one,
1506 * the absolute address is formed without prefixing. In this case a
1507 * normal store (stg/st) into the prefix area would no more match to
1508 * absolute addresses 0-8191.
1510 #ifdef CONFIG_64BIT
1511 asm volatile("sturg %0,%1"
1512 :: "a" ((unsigned long) reipl_block_actual),
1513 "a" (&lowcore_ptr[smp_processor_id()]->ipib));
1514 #else
1515 asm volatile("stura %0,%1"
1516 :: "a" ((unsigned long) reipl_block_actual),
1517 "a" (&lowcore_ptr[smp_processor_id()]->ipib));
1518 #endif
1519 asm volatile("stura %0,%1"
1520 :: "a" (csum_partial(reipl_block_actual,
1521 reipl_block_actual->hdr.len, 0)),
1522 "a" (&lowcore_ptr[smp_processor_id()]->ipib_checksum));
1523 preempt_enable();
1524 dump_run(trigger);
1527 static int __init dump_reipl_init(void)
1529 if (!diag308_set_works)
1530 return -EOPNOTSUPP;
1531 else
1532 return 0;
1535 static struct shutdown_action __refdata dump_reipl_action = {
1536 .name = SHUTDOWN_ACTION_DUMP_REIPL_STR,
1537 .fn = dump_reipl_run,
1538 .init = dump_reipl_init,
1542 * vmcmd shutdown action: Trigger vm command on shutdown.
1545 static char vmcmd_on_reboot[128];
1546 static char vmcmd_on_panic[128];
1547 static char vmcmd_on_halt[128];
1548 static char vmcmd_on_poff[128];
1549 static char vmcmd_on_restart[128];
1551 DEFINE_IPL_ATTR_STR_RW(vmcmd, on_reboot, "%s\n", "%s\n", vmcmd_on_reboot);
1552 DEFINE_IPL_ATTR_STR_RW(vmcmd, on_panic, "%s\n", "%s\n", vmcmd_on_panic);
1553 DEFINE_IPL_ATTR_STR_RW(vmcmd, on_halt, "%s\n", "%s\n", vmcmd_on_halt);
1554 DEFINE_IPL_ATTR_STR_RW(vmcmd, on_poff, "%s\n", "%s\n", vmcmd_on_poff);
1555 DEFINE_IPL_ATTR_STR_RW(vmcmd, on_restart, "%s\n", "%s\n", vmcmd_on_restart);
1557 static struct attribute *vmcmd_attrs[] = {
1558 &sys_vmcmd_on_reboot_attr.attr,
1559 &sys_vmcmd_on_panic_attr.attr,
1560 &sys_vmcmd_on_halt_attr.attr,
1561 &sys_vmcmd_on_poff_attr.attr,
1562 &sys_vmcmd_on_restart_attr.attr,
1563 NULL,
1566 static struct attribute_group vmcmd_attr_group = {
1567 .attrs = vmcmd_attrs,
1570 static struct kset *vmcmd_kset;
1572 static void vmcmd_run(struct shutdown_trigger *trigger)
1574 char *cmd, *next_cmd;
1576 if (strcmp(trigger->name, ON_REIPL_STR) == 0)
1577 cmd = vmcmd_on_reboot;
1578 else if (strcmp(trigger->name, ON_PANIC_STR) == 0)
1579 cmd = vmcmd_on_panic;
1580 else if (strcmp(trigger->name, ON_HALT_STR) == 0)
1581 cmd = vmcmd_on_halt;
1582 else if (strcmp(trigger->name, ON_POFF_STR) == 0)
1583 cmd = vmcmd_on_poff;
1584 else if (strcmp(trigger->name, ON_RESTART_STR) == 0)
1585 cmd = vmcmd_on_restart;
1586 else
1587 return;
1589 if (strlen(cmd) == 0)
1590 return;
1591 do {
1592 next_cmd = strchr(cmd, '\n');
1593 if (next_cmd) {
1594 next_cmd[0] = 0;
1595 next_cmd += 1;
1597 __cpcmd(cmd, NULL, 0, NULL);
1598 cmd = next_cmd;
1599 } while (cmd != NULL);
1602 static int vmcmd_init(void)
1604 if (!MACHINE_IS_VM)
1605 return -EOPNOTSUPP;
1606 vmcmd_kset = kset_create_and_add("vmcmd", NULL, firmware_kobj);
1607 if (!vmcmd_kset)
1608 return -ENOMEM;
1609 return sysfs_create_group(&vmcmd_kset->kobj, &vmcmd_attr_group);
1612 static struct shutdown_action vmcmd_action = {SHUTDOWN_ACTION_VMCMD_STR,
1613 vmcmd_run, vmcmd_init};
1616 * stop shutdown action: Stop Linux on shutdown.
1619 static void stop_run(struct shutdown_trigger *trigger)
1621 if (strcmp(trigger->name, ON_PANIC_STR) == 0)
1622 disabled_wait((unsigned long) __builtin_return_address(0));
1623 while (sigp(smp_processor_id(), sigp_stop) == sigp_busy)
1624 cpu_relax();
1625 for (;;);
1628 static struct shutdown_action stop_action = {SHUTDOWN_ACTION_STOP_STR,
1629 stop_run, NULL};
1631 /* action list */
1633 static struct shutdown_action *shutdown_actions_list[] = {
1634 &ipl_action, &reipl_action, &dump_reipl_action, &dump_action,
1635 &vmcmd_action, &stop_action};
1636 #define SHUTDOWN_ACTIONS_COUNT (sizeof(shutdown_actions_list) / sizeof(void *))
1639 * Trigger section
1642 static struct kset *shutdown_actions_kset;
1644 static int set_trigger(const char *buf, struct shutdown_trigger *trigger,
1645 size_t len)
1647 int i;
1649 for (i = 0; i < SHUTDOWN_ACTIONS_COUNT; i++) {
1650 if (sysfs_streq(buf, shutdown_actions_list[i]->name)) {
1651 if (shutdown_actions_list[i]->init_rc) {
1652 return shutdown_actions_list[i]->init_rc;
1653 } else {
1654 trigger->action = shutdown_actions_list[i];
1655 return len;
1659 return -EINVAL;
1662 /* on reipl */
1664 static struct shutdown_trigger on_reboot_trigger = {ON_REIPL_STR,
1665 &reipl_action};
1667 static ssize_t on_reboot_show(struct kobject *kobj,
1668 struct kobj_attribute *attr, char *page)
1670 return sprintf(page, "%s\n", on_reboot_trigger.action->name);
1673 static ssize_t on_reboot_store(struct kobject *kobj,
1674 struct kobj_attribute *attr,
1675 const char *buf, size_t len)
1677 return set_trigger(buf, &on_reboot_trigger, len);
1680 static struct kobj_attribute on_reboot_attr =
1681 __ATTR(on_reboot, 0644, on_reboot_show, on_reboot_store);
1683 static void do_machine_restart(char *__unused)
1685 smp_send_stop();
1686 on_reboot_trigger.action->fn(&on_reboot_trigger);
1687 reipl_run(NULL);
1689 void (*_machine_restart)(char *command) = do_machine_restart;
1691 /* on panic */
1693 static struct shutdown_trigger on_panic_trigger = {ON_PANIC_STR, &stop_action};
1695 static ssize_t on_panic_show(struct kobject *kobj,
1696 struct kobj_attribute *attr, char *page)
1698 return sprintf(page, "%s\n", on_panic_trigger.action->name);
1701 static ssize_t on_panic_store(struct kobject *kobj,
1702 struct kobj_attribute *attr,
1703 const char *buf, size_t len)
1705 return set_trigger(buf, &on_panic_trigger, len);
1708 static struct kobj_attribute on_panic_attr =
1709 __ATTR(on_panic, 0644, on_panic_show, on_panic_store);
1711 static void do_panic(void)
1713 on_panic_trigger.action->fn(&on_panic_trigger);
1714 stop_run(&on_panic_trigger);
1717 /* on restart */
1719 static struct shutdown_trigger on_restart_trigger = {ON_RESTART_STR,
1720 &reipl_action};
1722 static ssize_t on_restart_show(struct kobject *kobj,
1723 struct kobj_attribute *attr, char *page)
1725 return sprintf(page, "%s\n", on_restart_trigger.action->name);
1728 static ssize_t on_restart_store(struct kobject *kobj,
1729 struct kobj_attribute *attr,
1730 const char *buf, size_t len)
1732 return set_trigger(buf, &on_restart_trigger, len);
1735 static struct kobj_attribute on_restart_attr =
1736 __ATTR(on_restart, 0644, on_restart_show, on_restart_store);
1738 void do_restart(void)
1740 smp_send_stop();
1741 on_restart_trigger.action->fn(&on_restart_trigger);
1742 stop_run(&on_restart_trigger);
1745 /* on halt */
1747 static struct shutdown_trigger on_halt_trigger = {ON_HALT_STR, &stop_action};
1749 static ssize_t on_halt_show(struct kobject *kobj,
1750 struct kobj_attribute *attr, char *page)
1752 return sprintf(page, "%s\n", on_halt_trigger.action->name);
1755 static ssize_t on_halt_store(struct kobject *kobj,
1756 struct kobj_attribute *attr,
1757 const char *buf, size_t len)
1759 return set_trigger(buf, &on_halt_trigger, len);
1762 static struct kobj_attribute on_halt_attr =
1763 __ATTR(on_halt, 0644, on_halt_show, on_halt_store);
1766 static void do_machine_halt(void)
1768 smp_send_stop();
1769 on_halt_trigger.action->fn(&on_halt_trigger);
1770 stop_run(&on_halt_trigger);
1772 void (*_machine_halt)(void) = do_machine_halt;
1774 /* on power off */
1776 static struct shutdown_trigger on_poff_trigger = {ON_POFF_STR, &stop_action};
1778 static ssize_t on_poff_show(struct kobject *kobj,
1779 struct kobj_attribute *attr, char *page)
1781 return sprintf(page, "%s\n", on_poff_trigger.action->name);
1784 static ssize_t on_poff_store(struct kobject *kobj,
1785 struct kobj_attribute *attr,
1786 const char *buf, size_t len)
1788 return set_trigger(buf, &on_poff_trigger, len);
1791 static struct kobj_attribute on_poff_attr =
1792 __ATTR(on_poff, 0644, on_poff_show, on_poff_store);
1795 static void do_machine_power_off(void)
1797 smp_send_stop();
1798 on_poff_trigger.action->fn(&on_poff_trigger);
1799 stop_run(&on_poff_trigger);
1801 void (*_machine_power_off)(void) = do_machine_power_off;
1803 static void __init shutdown_triggers_init(void)
1805 shutdown_actions_kset = kset_create_and_add("shutdown_actions", NULL,
1806 firmware_kobj);
1807 if (!shutdown_actions_kset)
1808 goto fail;
1809 if (sysfs_create_file(&shutdown_actions_kset->kobj,
1810 &on_reboot_attr.attr))
1811 goto fail;
1812 if (sysfs_create_file(&shutdown_actions_kset->kobj,
1813 &on_panic_attr.attr))
1814 goto fail;
1815 if (sysfs_create_file(&shutdown_actions_kset->kobj,
1816 &on_halt_attr.attr))
1817 goto fail;
1818 if (sysfs_create_file(&shutdown_actions_kset->kobj,
1819 &on_poff_attr.attr))
1820 goto fail;
1821 if (sysfs_create_file(&shutdown_actions_kset->kobj,
1822 &on_restart_attr.attr))
1823 goto fail;
1824 return;
1825 fail:
1826 panic("shutdown_triggers_init failed\n");
1829 static void __init shutdown_actions_init(void)
1831 int i;
1833 for (i = 0; i < SHUTDOWN_ACTIONS_COUNT; i++) {
1834 if (!shutdown_actions_list[i]->init)
1835 continue;
1836 shutdown_actions_list[i]->init_rc =
1837 shutdown_actions_list[i]->init();
1841 static int __init s390_ipl_init(void)
1843 sclp_get_ipl_info(&sclp_ipl_info);
1844 shutdown_actions_init();
1845 shutdown_triggers_init();
1846 return 0;
1849 __initcall(s390_ipl_init);
1851 static void __init strncpy_skip_quote(char *dst, char *src, int n)
1853 int sx, dx;
1855 dx = 0;
1856 for (sx = 0; src[sx] != 0; sx++) {
1857 if (src[sx] == '"')
1858 continue;
1859 dst[dx++] = src[sx];
1860 if (dx >= n)
1861 break;
1865 static int __init vmcmd_on_reboot_setup(char *str)
1867 if (!MACHINE_IS_VM)
1868 return 1;
1869 strncpy_skip_quote(vmcmd_on_reboot, str, 127);
1870 vmcmd_on_reboot[127] = 0;
1871 on_reboot_trigger.action = &vmcmd_action;
1872 return 1;
1874 __setup("vmreboot=", vmcmd_on_reboot_setup);
1876 static int __init vmcmd_on_panic_setup(char *str)
1878 if (!MACHINE_IS_VM)
1879 return 1;
1880 strncpy_skip_quote(vmcmd_on_panic, str, 127);
1881 vmcmd_on_panic[127] = 0;
1882 on_panic_trigger.action = &vmcmd_action;
1883 return 1;
1885 __setup("vmpanic=", vmcmd_on_panic_setup);
1887 static int __init vmcmd_on_halt_setup(char *str)
1889 if (!MACHINE_IS_VM)
1890 return 1;
1891 strncpy_skip_quote(vmcmd_on_halt, str, 127);
1892 vmcmd_on_halt[127] = 0;
1893 on_halt_trigger.action = &vmcmd_action;
1894 return 1;
1896 __setup("vmhalt=", vmcmd_on_halt_setup);
1898 static int __init vmcmd_on_poff_setup(char *str)
1900 if (!MACHINE_IS_VM)
1901 return 1;
1902 strncpy_skip_quote(vmcmd_on_poff, str, 127);
1903 vmcmd_on_poff[127] = 0;
1904 on_poff_trigger.action = &vmcmd_action;
1905 return 1;
1907 __setup("vmpoff=", vmcmd_on_poff_setup);
1909 static int on_panic_notify(struct notifier_block *self,
1910 unsigned long event, void *data)
1912 do_panic();
1913 return NOTIFY_OK;
1916 static struct notifier_block on_panic_nb = {
1917 .notifier_call = on_panic_notify,
1918 .priority = INT_MIN,
1921 void __init setup_ipl(void)
1923 ipl_info.type = get_ipl_type();
1924 switch (ipl_info.type) {
1925 case IPL_TYPE_CCW:
1926 ipl_info.data.ccw.dev_id.devno = ipl_devno;
1927 ipl_info.data.ccw.dev_id.ssid = 0;
1928 break;
1929 case IPL_TYPE_FCP:
1930 case IPL_TYPE_FCP_DUMP:
1931 ipl_info.data.fcp.dev_id.devno =
1932 IPL_PARMBLOCK_START->ipl_info.fcp.devno;
1933 ipl_info.data.fcp.dev_id.ssid = 0;
1934 ipl_info.data.fcp.wwpn = IPL_PARMBLOCK_START->ipl_info.fcp.wwpn;
1935 ipl_info.data.fcp.lun = IPL_PARMBLOCK_START->ipl_info.fcp.lun;
1936 break;
1937 case IPL_TYPE_NSS:
1938 strncpy(ipl_info.data.nss.name, kernel_nss_name,
1939 sizeof(ipl_info.data.nss.name));
1940 break;
1941 case IPL_TYPE_UNKNOWN:
1942 /* We have no info to copy */
1943 break;
1945 atomic_notifier_chain_register(&panic_notifier_list, &on_panic_nb);
1948 void __init ipl_update_parameters(void)
1950 int rc;
1952 rc = diag308(DIAG308_STORE, &ipl_block);
1953 if ((rc == DIAG308_RC_OK) || (rc == DIAG308_RC_NOCONFIG))
1954 diag308_set_works = 1;
1957 void __init ipl_save_parameters(void)
1959 struct cio_iplinfo iplinfo;
1960 void *src, *dst;
1962 if (cio_get_iplinfo(&iplinfo))
1963 return;
1965 ipl_devno = iplinfo.devno;
1966 ipl_flags |= IPL_DEVNO_VALID;
1967 if (!iplinfo.is_qdio)
1968 return;
1969 ipl_flags |= IPL_PARMBLOCK_VALID;
1970 src = (void *)(unsigned long)S390_lowcore.ipl_parmblock_ptr;
1971 dst = (void *)IPL_PARMBLOCK_ORIGIN;
1972 memmove(dst, src, PAGE_SIZE);
1973 S390_lowcore.ipl_parmblock_ptr = IPL_PARMBLOCK_ORIGIN;
1976 static LIST_HEAD(rcall);
1977 static DEFINE_MUTEX(rcall_mutex);
1979 void register_reset_call(struct reset_call *reset)
1981 mutex_lock(&rcall_mutex);
1982 list_add(&reset->list, &rcall);
1983 mutex_unlock(&rcall_mutex);
1985 EXPORT_SYMBOL_GPL(register_reset_call);
1987 void unregister_reset_call(struct reset_call *reset)
1989 mutex_lock(&rcall_mutex);
1990 list_del(&reset->list);
1991 mutex_unlock(&rcall_mutex);
1993 EXPORT_SYMBOL_GPL(unregister_reset_call);
1995 static void do_reset_calls(void)
1997 struct reset_call *reset;
1999 #ifdef CONFIG_64BIT
2000 if (diag308_set_works) {
2001 diag308_reset();
2002 return;
2004 #endif
2005 list_for_each_entry(reset, &rcall, list)
2006 reset->fn();
2009 u32 dump_prefix_page;
2011 void s390_reset_system(void)
2013 struct _lowcore *lc;
2015 lc = (struct _lowcore *)(unsigned long) store_prefix();
2017 /* Stack for interrupt/machine check handler */
2018 lc->panic_stack = S390_lowcore.panic_stack;
2020 /* Save prefix page address for dump case */
2021 dump_prefix_page = (u32)(unsigned long) lc;
2023 /* Disable prefixing */
2024 set_prefix(0);
2026 /* Disable lowcore protection */
2027 __ctl_clear_bit(0,28);
2029 /* Set new machine check handler */
2030 S390_lowcore.mcck_new_psw.mask = psw_kernel_bits & ~PSW_MASK_MCHECK;
2031 S390_lowcore.mcck_new_psw.addr =
2032 PSW_ADDR_AMODE | (unsigned long) s390_base_mcck_handler;
2034 /* Set new program check handler */
2035 S390_lowcore.program_new_psw.mask = psw_kernel_bits & ~PSW_MASK_MCHECK;
2036 S390_lowcore.program_new_psw.addr =
2037 PSW_ADDR_AMODE | (unsigned long) s390_base_pgm_handler;
2039 do_reset_calls();