Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 1 | /* |
| 2 | * arch/s390/kernel/ipl.c |
| 3 | * ipl/reipl/dump support for Linux on s390. |
| 4 | * |
Michael Holzheu | 99ca4e5 | 2008-01-26 14:11:11 +0100 | [diff] [blame] | 5 | * Copyright IBM Corp. 2005,2007 |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 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 | */ |
| 10 | |
| 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> |
Michael Holzheu | 03a4d20 | 2006-12-04 15:39:58 +0100 | [diff] [blame] | 16 | #include <linux/ctype.h> |
Akinobu Mita | 0788fea | 2008-07-14 09:59:17 +0200 | [diff] [blame] | 17 | #include <linux/fs.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 18 | #include <linux/gfp.h> |
Michael Holzheu | 46b05d2 | 2007-02-21 10:55:21 +0100 | [diff] [blame] | 19 | #include <asm/ipl.h> |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 20 | #include <asm/smp.h> |
| 21 | #include <asm/setup.h> |
| 22 | #include <asm/cpcmd.h> |
| 23 | #include <asm/cio.h> |
Michael Holzheu | 03a4d20 | 2006-12-04 15:39:58 +0100 | [diff] [blame] | 24 | #include <asm/ebcdic.h> |
Heiko Carstens | 15e9b58 | 2006-12-04 15:40:26 +0100 | [diff] [blame] | 25 | #include <asm/reset.h> |
Heiko Carstens | ab14de6 | 2007-02-05 21:18:37 +0100 | [diff] [blame] | 26 | #include <asm/sclp.h> |
Heiko Carstens | 3bd5f3e | 2009-04-23 13:58:06 +0200 | [diff] [blame] | 27 | #include <asm/sigp.h> |
Frank Munzert | 159d1ff | 2009-03-26 15:24:45 +0100 | [diff] [blame] | 28 | #include <asm/checksum.h> |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 29 | |
| 30 | #define IPL_PARM_BLOCK_VERSION 0 |
Michael Holzheu | 03a4d20 | 2006-12-04 15:39:58 +0100 | [diff] [blame] | 31 | |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 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" |
Heiko Carstens | 615b04b | 2007-02-21 10:55:37 +0100 | [diff] [blame] | 37 | |
Michael Holzheu | 99ca4e5 | 2008-01-26 14:11:11 +0100 | [diff] [blame] | 38 | #define DUMP_CCW_STR "ccw" |
| 39 | #define DUMP_FCP_STR "fcp" |
| 40 | #define DUMP_NONE_STR "none" |
| 41 | |
| 42 | /* |
| 43 | * Four shutdown trigger types are supported: |
| 44 | * - panic |
| 45 | * - halt |
| 46 | * - power off |
| 47 | * - reipl |
Michael Holzheu | 7dd6b33 | 2011-08-03 16:44:19 +0200 | [diff] [blame] | 48 | * - restart |
Michael Holzheu | 99ca4e5 | 2008-01-26 14:11:11 +0100 | [diff] [blame] | 49 | */ |
| 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" |
Michael Holzheu | 7dd6b33 | 2011-08-03 16:44:19 +0200 | [diff] [blame] | 54 | #define ON_RESTART_STR "on_restart" |
Michael Holzheu | 99ca4e5 | 2008-01-26 14:11:11 +0100 | [diff] [blame] | 55 | |
| 56 | struct shutdown_action; |
| 57 | struct shutdown_trigger { |
| 58 | char *name; |
| 59 | struct shutdown_action *action; |
| 60 | }; |
| 61 | |
| 62 | /* |
Frank Munzert | 099b765 | 2009-03-26 15:23:43 +0100 | [diff] [blame] | 63 | * The following shutdown action types are supported: |
Michael Holzheu | 99ca4e5 | 2008-01-26 14:11:11 +0100 | [diff] [blame] | 64 | */ |
| 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" |
Frank Munzert | 099b765 | 2009-03-26 15:23:43 +0100 | [diff] [blame] | 70 | #define SHUTDOWN_ACTION_DUMP_REIPL_STR "dump_reipl" |
Michael Holzheu | 99ca4e5 | 2008-01-26 14:11:11 +0100 | [diff] [blame] | 71 | |
| 72 | struct shutdown_action { |
| 73 | char *name; |
| 74 | void (*fn) (struct shutdown_trigger *trigger); |
| 75 | int (*init) (void); |
Frank Munzert | 8108881 | 2009-07-07 16:37:07 +0200 | [diff] [blame] | 76 | int init_rc; |
Michael Holzheu | 99ca4e5 | 2008-01-26 14:11:11 +0100 | [diff] [blame] | 77 | }; |
| 78 | |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 79 | static char *ipl_type_str(enum ipl_type type) |
| 80 | { |
| 81 | switch (type) { |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 82 | case IPL_TYPE_CCW: |
| 83 | return IPL_CCW_STR; |
| 84 | case IPL_TYPE_FCP: |
| 85 | return IPL_FCP_STR; |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 86 | case IPL_TYPE_FCP_DUMP: |
| 87 | return IPL_FCP_DUMP_STR; |
Hongjie Yang | fe355b7 | 2007-02-05 21:18:24 +0100 | [diff] [blame] | 88 | case IPL_TYPE_NSS: |
| 89 | return IPL_NSS_STR; |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 90 | case IPL_TYPE_UNKNOWN: |
| 91 | default: |
| 92 | return IPL_UNKNOWN_STR; |
| 93 | } |
| 94 | } |
| 95 | |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 96 | enum dump_type { |
| 97 | DUMP_TYPE_NONE = 1, |
| 98 | DUMP_TYPE_CCW = 2, |
| 99 | DUMP_TYPE_FCP = 4, |
| 100 | }; |
| 101 | |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 102 | static char *dump_type_str(enum dump_type type) |
| 103 | { |
| 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; |
| 113 | } |
| 114 | } |
| 115 | |
| 116 | /* |
| 117 | * Must be in data section since the bss section |
| 118 | * is not cleared when these are accessed. |
| 119 | */ |
| 120 | static u16 ipl_devno __attribute__((__section__(".data"))) = 0; |
| 121 | u32 ipl_flags __attribute__((__section__(".data"))) = 0; |
| 122 | |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 123 | enum ipl_method { |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 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, |
Hendrik Brueckner | a0443fb | 2008-07-14 09:59:09 +0200 | [diff] [blame] | 132 | REIPL_METHOD_NSS_DIAG, |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 133 | REIPL_METHOD_DEFAULT, |
| 134 | }; |
| 135 | |
| 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, |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 142 | }; |
| 143 | |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 144 | static int diag308_set_works = 0; |
| 145 | |
Hendrik Brueckner | a0443fb | 2008-07-14 09:59:09 +0200 | [diff] [blame] | 146 | static struct ipl_parameter_block ipl_block; |
| 147 | |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 148 | static int reipl_capabilities = IPL_TYPE_UNKNOWN; |
Hongjie Yang | fe355b7 | 2007-02-05 21:18:24 +0100 | [diff] [blame] | 149 | |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 150 | static enum ipl_type reipl_type = IPL_TYPE_UNKNOWN; |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 151 | static enum ipl_method reipl_method = REIPL_METHOD_DEFAULT; |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 152 | static struct ipl_parameter_block *reipl_block_fcp; |
| 153 | static struct ipl_parameter_block *reipl_block_ccw; |
Hendrik Brueckner | a0443fb | 2008-07-14 09:59:09 +0200 | [diff] [blame] | 154 | static struct ipl_parameter_block *reipl_block_nss; |
Frank Munzert | 099b765 | 2009-03-26 15:23:43 +0100 | [diff] [blame] | 155 | static struct ipl_parameter_block *reipl_block_actual; |
Hongjie Yang | fe355b7 | 2007-02-05 21:18:24 +0100 | [diff] [blame] | 156 | |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 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; |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 160 | static struct ipl_parameter_block *dump_block_fcp; |
| 161 | static struct ipl_parameter_block *dump_block_ccw; |
| 162 | |
Heiko Carstens | 05dd253 | 2007-07-10 11:24:09 +0200 | [diff] [blame] | 163 | static struct sclp_ipl_info sclp_ipl_info; |
| 164 | |
Michael Holzheu | 46b05d2 | 2007-02-21 10:55:21 +0100 | [diff] [blame] | 165 | int diag308(unsigned long subcode, void *addr) |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 166 | { |
Martin Schwidefsky | 94c12cc | 2006-09-28 16:56:43 +0200 | [diff] [blame] | 167 | register unsigned long _addr asm("0") = (unsigned long) addr; |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 168 | register unsigned long _rc asm("1") = 0; |
| 169 | |
Martin Schwidefsky | 94c12cc | 2006-09-28 16:56:43 +0200 | [diff] [blame] | 170 | asm volatile( |
| 171 | " diag %0,%2,0x308\n" |
| 172 | "0:\n" |
| 173 | EX_TABLE(0b,0b) |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 174 | : "+d" (_addr), "+d" (_rc) |
Martin Schwidefsky | 94c12cc | 2006-09-28 16:56:43 +0200 | [diff] [blame] | 175 | : "d" (subcode) : "cc", "memory"); |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 176 | return _rc; |
| 177 | } |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 178 | EXPORT_SYMBOL_GPL(diag308); |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 179 | |
| 180 | /* SYSFS */ |
| 181 | |
| 182 | #define DEFINE_IPL_ATTR_RO(_prefix, _name, _format, _value) \ |
Greg Kroah-Hartman | 9b94916 | 2007-11-02 17:17:00 -0400 | [diff] [blame] | 183 | static ssize_t sys_##_prefix##_##_name##_show(struct kobject *kobj, \ |
| 184 | struct kobj_attribute *attr, \ |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 185 | char *page) \ |
| 186 | { \ |
| 187 | return sprintf(page, _format, _value); \ |
| 188 | } \ |
Greg Kroah-Hartman | 9b94916 | 2007-11-02 17:17:00 -0400 | [diff] [blame] | 189 | static struct kobj_attribute sys_##_prefix##_##_name##_attr = \ |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 190 | __ATTR(_name, S_IRUGO, sys_##_prefix##_##_name##_show, NULL); |
| 191 | |
| 192 | #define DEFINE_IPL_ATTR_RW(_prefix, _name, _fmt_out, _fmt_in, _value) \ |
Greg Kroah-Hartman | 9b94916 | 2007-11-02 17:17:00 -0400 | [diff] [blame] | 193 | static ssize_t sys_##_prefix##_##_name##_show(struct kobject *kobj, \ |
| 194 | struct kobj_attribute *attr, \ |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 195 | char *page) \ |
| 196 | { \ |
| 197 | return sprintf(page, _fmt_out, \ |
| 198 | (unsigned long long) _value); \ |
| 199 | } \ |
Greg Kroah-Hartman | 9b94916 | 2007-11-02 17:17:00 -0400 | [diff] [blame] | 200 | static ssize_t sys_##_prefix##_##_name##_store(struct kobject *kobj, \ |
| 201 | struct kobj_attribute *attr, \ |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 202 | const char *buf, size_t len) \ |
| 203 | { \ |
| 204 | unsigned long long value; \ |
| 205 | if (sscanf(buf, _fmt_in, &value) != 1) \ |
| 206 | return -EINVAL; \ |
| 207 | _value = value; \ |
| 208 | return len; \ |
| 209 | } \ |
Greg Kroah-Hartman | 9b94916 | 2007-11-02 17:17:00 -0400 | [diff] [blame] | 210 | static struct kobj_attribute sys_##_prefix##_##_name##_attr = \ |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 211 | __ATTR(_name,(S_IRUGO | S_IWUSR), \ |
| 212 | sys_##_prefix##_##_name##_show, \ |
| 213 | sys_##_prefix##_##_name##_store); |
| 214 | |
Hongjie Yang | fe355b7 | 2007-02-05 21:18:24 +0100 | [diff] [blame] | 215 | #define DEFINE_IPL_ATTR_STR_RW(_prefix, _name, _fmt_out, _fmt_in, _value)\ |
Greg Kroah-Hartman | 9b94916 | 2007-11-02 17:17:00 -0400 | [diff] [blame] | 216 | static ssize_t sys_##_prefix##_##_name##_show(struct kobject *kobj, \ |
| 217 | struct kobj_attribute *attr, \ |
Hongjie Yang | fe355b7 | 2007-02-05 21:18:24 +0100 | [diff] [blame] | 218 | char *page) \ |
| 219 | { \ |
| 220 | return sprintf(page, _fmt_out, _value); \ |
| 221 | } \ |
Greg Kroah-Hartman | 9b94916 | 2007-11-02 17:17:00 -0400 | [diff] [blame] | 222 | static ssize_t sys_##_prefix##_##_name##_store(struct kobject *kobj, \ |
| 223 | struct kobj_attribute *attr, \ |
Hongjie Yang | fe355b7 | 2007-02-05 21:18:24 +0100 | [diff] [blame] | 224 | const char *buf, size_t len) \ |
| 225 | { \ |
Michael Holzheu | 99ca4e5 | 2008-01-26 14:11:11 +0100 | [diff] [blame] | 226 | strncpy(_value, buf, sizeof(_value) - 1); \ |
Heiko Carstens | 1d802e2 | 2009-12-18 17:43:27 +0100 | [diff] [blame] | 227 | strim(_value); \ |
Hongjie Yang | fe355b7 | 2007-02-05 21:18:24 +0100 | [diff] [blame] | 228 | return len; \ |
| 229 | } \ |
Greg Kroah-Hartman | 9b94916 | 2007-11-02 17:17:00 -0400 | [diff] [blame] | 230 | static struct kobj_attribute sys_##_prefix##_##_name##_attr = \ |
Hongjie Yang | fe355b7 | 2007-02-05 21:18:24 +0100 | [diff] [blame] | 231 | __ATTR(_name,(S_IRUGO | S_IWUSR), \ |
| 232 | sys_##_prefix##_##_name##_show, \ |
| 233 | sys_##_prefix##_##_name##_store); |
| 234 | |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 235 | static void make_attrs_ro(struct attribute **attrs) |
| 236 | { |
| 237 | while (*attrs) { |
| 238 | (*attrs)->mode = S_IRUGO; |
| 239 | attrs++; |
| 240 | } |
| 241 | } |
| 242 | |
| 243 | /* |
| 244 | * ipl section |
| 245 | */ |
| 246 | |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 247 | static __init enum ipl_type get_ipl_type(void) |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 248 | { |
| 249 | struct ipl_parameter_block *ipl = IPL_PARMBLOCK_START; |
| 250 | |
Hongjie Yang | fe355b7 | 2007-02-05 21:18:24 +0100 | [diff] [blame] | 251 | if (ipl_flags & IPL_NSS_VALID) |
| 252 | return IPL_TYPE_NSS; |
Heiko Carstens | e87bfe5 | 2006-09-20 15:59:15 +0200 | [diff] [blame] | 253 | if (!(ipl_flags & IPL_DEVNO_VALID)) |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 254 | return IPL_TYPE_UNKNOWN; |
Heiko Carstens | e87bfe5 | 2006-09-20 15:59:15 +0200 | [diff] [blame] | 255 | if (!(ipl_flags & IPL_PARMBLOCK_VALID)) |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 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; |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 261 | if (ipl->ipl_info.fcp.opt == DIAG308_IPL_OPT_DUMP) |
| 262 | return IPL_TYPE_FCP_DUMP; |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 263 | return IPL_TYPE_FCP; |
| 264 | } |
| 265 | |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 266 | struct ipl_info ipl_info; |
| 267 | EXPORT_SYMBOL_GPL(ipl_info); |
| 268 | |
Greg Kroah-Hartman | 9b94916 | 2007-11-02 17:17:00 -0400 | [diff] [blame] | 269 | static ssize_t ipl_type_show(struct kobject *kobj, struct kobj_attribute *attr, |
| 270 | char *page) |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 271 | { |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 272 | return sprintf(page, "%s\n", ipl_type_str(ipl_info.type)); |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 273 | } |
| 274 | |
Greg Kroah-Hartman | 9b94916 | 2007-11-02 17:17:00 -0400 | [diff] [blame] | 275 | static struct kobj_attribute sys_ipl_type_attr = __ATTR_RO(ipl_type); |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 276 | |
Hendrik Brueckner | a0443fb | 2008-07-14 09:59:09 +0200 | [diff] [blame] | 277 | /* VM IPL PARM routines */ |
Hendrik Brueckner | 684d2fd | 2009-09-11 10:28:40 +0200 | [diff] [blame] | 278 | size_t reipl_get_ascii_vmparm(char *dest, size_t size, |
Hendrik Brueckner | a0443fb | 2008-07-14 09:59:09 +0200 | [diff] [blame] | 279 | const struct ipl_parameter_block *ipb) |
| 280 | { |
| 281 | int i; |
Hendrik Brueckner | 684d2fd | 2009-09-11 10:28:40 +0200 | [diff] [blame] | 282 | size_t len; |
Hendrik Brueckner | a0443fb | 2008-07-14 09:59:09 +0200 | [diff] [blame] | 283 | char has_lowercase = 0; |
| 284 | |
Hendrik Brueckner | 684d2fd | 2009-09-11 10:28:40 +0200 | [diff] [blame] | 285 | len = 0; |
Hendrik Brueckner | a0443fb | 2008-07-14 09:59:09 +0200 | [diff] [blame] | 286 | if ((ipb->ipl_info.ccw.vm_flags & DIAG308_VM_FLAGS_VP_VALID) && |
| 287 | (ipb->ipl_info.ccw.vm_parm_len > 0)) { |
| 288 | |
Hendrik Brueckner | 684d2fd | 2009-09-11 10:28:40 +0200 | [diff] [blame] | 289 | len = min_t(size_t, size - 1, ipb->ipl_info.ccw.vm_parm_len); |
Hendrik Brueckner | a0443fb | 2008-07-14 09:59:09 +0200 | [diff] [blame] | 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. |
| 293 | */ |
| 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; |
| 300 | } |
| 301 | if (!has_lowercase) |
| 302 | EBC_TOLOWER(dest, len); |
| 303 | EBCASC(dest, len); |
| 304 | } |
| 305 | dest[len] = 0; |
Hendrik Brueckner | 684d2fd | 2009-09-11 10:28:40 +0200 | [diff] [blame] | 306 | |
| 307 | return len; |
Hendrik Brueckner | a0443fb | 2008-07-14 09:59:09 +0200 | [diff] [blame] | 308 | } |
| 309 | |
Hendrik Brueckner | 684d2fd | 2009-09-11 10:28:40 +0200 | [diff] [blame] | 310 | size_t append_ipl_vmparm(char *dest, size_t size) |
Hendrik Brueckner | a0443fb | 2008-07-14 09:59:09 +0200 | [diff] [blame] | 311 | { |
Hendrik Brueckner | 684d2fd | 2009-09-11 10:28:40 +0200 | [diff] [blame] | 312 | size_t rc; |
| 313 | |
| 314 | rc = 0; |
Hendrik Brueckner | a0443fb | 2008-07-14 09:59:09 +0200 | [diff] [blame] | 315 | if (diag308_set_works && (ipl_block.hdr.pbt == DIAG308_IPL_TYPE_CCW)) |
Hendrik Brueckner | 684d2fd | 2009-09-11 10:28:40 +0200 | [diff] [blame] | 316 | rc = reipl_get_ascii_vmparm(dest, size, &ipl_block); |
Hendrik Brueckner | a0443fb | 2008-07-14 09:59:09 +0200 | [diff] [blame] | 317 | else |
| 318 | dest[0] = 0; |
Hendrik Brueckner | 684d2fd | 2009-09-11 10:28:40 +0200 | [diff] [blame] | 319 | return rc; |
Hendrik Brueckner | a0443fb | 2008-07-14 09:59:09 +0200 | [diff] [blame] | 320 | } |
| 321 | |
| 322 | static ssize_t ipl_vm_parm_show(struct kobject *kobj, |
| 323 | struct kobj_attribute *attr, char *page) |
| 324 | { |
| 325 | char parm[DIAG308_VMPARM_SIZE + 1] = {}; |
| 326 | |
Hendrik Brueckner | 684d2fd | 2009-09-11 10:28:40 +0200 | [diff] [blame] | 327 | append_ipl_vmparm(parm, sizeof(parm)); |
Hendrik Brueckner | a0443fb | 2008-07-14 09:59:09 +0200 | [diff] [blame] | 328 | return sprintf(page, "%s\n", parm); |
| 329 | } |
| 330 | |
Hendrik Brueckner | 684d2fd | 2009-09-11 10:28:40 +0200 | [diff] [blame] | 331 | static size_t scpdata_length(const char* buf, size_t count) |
| 332 | { |
| 333 | while (count) { |
| 334 | if (buf[count - 1] != '\0' && buf[count - 1] != ' ') |
| 335 | break; |
| 336 | count--; |
| 337 | } |
| 338 | return count; |
| 339 | } |
| 340 | |
| 341 | size_t reipl_append_ascii_scpdata(char *dest, size_t size, |
| 342 | const struct ipl_parameter_block *ipb) |
| 343 | { |
| 344 | size_t count; |
| 345 | size_t i; |
Hendrik Brueckner | 18d00ac | 2009-09-11 10:28:41 +0200 | [diff] [blame] | 346 | int has_lowercase; |
Hendrik Brueckner | 684d2fd | 2009-09-11 10:28:40 +0200 | [diff] [blame] | 347 | |
| 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; |
| 352 | |
Hendrik Brueckner | 18d00ac | 2009-09-11 10:28:41 +0200 | [diff] [blame] | 353 | has_lowercase = 0; |
| 354 | for (i = 0; i < count; i++) { |
Hendrik Brueckner | 684d2fd | 2009-09-11 10:28:40 +0200 | [diff] [blame] | 355 | if (!isascii(ipb->ipl_info.fcp.scp_data[i])) { |
| 356 | count = 0; |
| 357 | goto out; |
| 358 | } |
Hendrik Brueckner | 18d00ac | 2009-09-11 10:28:41 +0200 | [diff] [blame] | 359 | if (!has_lowercase && islower(ipb->ipl_info.fcp.scp_data[i])) |
| 360 | has_lowercase = 1; |
| 361 | } |
Hendrik Brueckner | 684d2fd | 2009-09-11 10:28:40 +0200 | [diff] [blame] | 362 | |
Hendrik Brueckner | 18d00ac | 2009-09-11 10:28:41 +0200 | [diff] [blame] | 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]); |
Hendrik Brueckner | 684d2fd | 2009-09-11 10:28:40 +0200 | [diff] [blame] | 368 | out: |
| 369 | dest[count] = '\0'; |
| 370 | return count; |
| 371 | } |
| 372 | |
| 373 | size_t append_ipl_scpdata(char *dest, size_t len) |
| 374 | { |
| 375 | size_t rc; |
| 376 | |
| 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; |
| 383 | } |
| 384 | |
| 385 | |
Hendrik Brueckner | a0443fb | 2008-07-14 09:59:09 +0200 | [diff] [blame] | 386 | static struct kobj_attribute sys_ipl_vm_parm_attr = |
| 387 | __ATTR(parm, S_IRUGO, ipl_vm_parm_show, NULL); |
| 388 | |
Greg Kroah-Hartman | 9b94916 | 2007-11-02 17:17:00 -0400 | [diff] [blame] | 389 | static ssize_t sys_ipl_device_show(struct kobject *kobj, |
| 390 | struct kobj_attribute *attr, char *page) |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 391 | { |
| 392 | struct ipl_parameter_block *ipl = IPL_PARMBLOCK_START; |
| 393 | |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 394 | switch (ipl_info.type) { |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 395 | case IPL_TYPE_CCW: |
| 396 | return sprintf(page, "0.0.%04x\n", ipl_devno); |
| 397 | case IPL_TYPE_FCP: |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 398 | case IPL_TYPE_FCP_DUMP: |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 399 | return sprintf(page, "0.0.%04x\n", ipl->ipl_info.fcp.devno); |
| 400 | default: |
| 401 | return 0; |
| 402 | } |
| 403 | } |
| 404 | |
Greg Kroah-Hartman | 9b94916 | 2007-11-02 17:17:00 -0400 | [diff] [blame] | 405 | static struct kobj_attribute sys_ipl_device_attr = |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 406 | __ATTR(device, S_IRUGO, sys_ipl_device_show, NULL); |
| 407 | |
Chris Wright | 2c3c8be | 2010-05-12 18:28:57 -0700 | [diff] [blame] | 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) |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 411 | { |
Akinobu Mita | 0788fea | 2008-07-14 09:59:17 +0200 | [diff] [blame] | 412 | return memory_read_from_buffer(buf, count, &off, IPL_PARMBLOCK_START, |
| 413 | IPL_PARMBLOCK_SIZE); |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 414 | } |
| 415 | |
| 416 | static struct bin_attribute ipl_parameter_attr = { |
| 417 | .attr = { |
| 418 | .name = "binary_parameter", |
| 419 | .mode = S_IRUGO, |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 420 | }, |
| 421 | .size = PAGE_SIZE, |
| 422 | .read = &ipl_parameter_read, |
| 423 | }; |
| 424 | |
Chris Wright | 2c3c8be | 2010-05-12 18:28:57 -0700 | [diff] [blame] | 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) |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 428 | { |
| 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; |
| 431 | |
Akinobu Mita | 0788fea | 2008-07-14 09:59:17 +0200 | [diff] [blame] | 432 | return memory_read_from_buffer(buf, count, &off, scp_data, size); |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 433 | } |
| 434 | |
| 435 | static struct bin_attribute ipl_scp_data_attr = { |
| 436 | .attr = { |
| 437 | .name = "scp_data", |
| 438 | .mode = S_IRUGO, |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 439 | }, |
| 440 | .size = PAGE_SIZE, |
Al Viro | 05bd711 | 2007-07-15 21:01:22 +0100 | [diff] [blame] | 441 | .read = ipl_scp_data_read, |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 442 | }; |
| 443 | |
| 444 | /* FCP ipl device attributes */ |
| 445 | |
| 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); |
| 454 | |
| 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, |
| 463 | }; |
| 464 | |
| 465 | static struct attribute_group ipl_fcp_attr_group = { |
| 466 | .attrs = ipl_fcp_attrs, |
| 467 | }; |
| 468 | |
| 469 | /* CCW ipl device attributes */ |
| 470 | |
Greg Kroah-Hartman | 9b94916 | 2007-11-02 17:17:00 -0400 | [diff] [blame] | 471 | static ssize_t ipl_ccw_loadparm_show(struct kobject *kobj, |
| 472 | struct kobj_attribute *attr, char *page) |
Michael Holzheu | 03a4d20 | 2006-12-04 15:39:58 +0100 | [diff] [blame] | 473 | { |
| 474 | char loadparm[LOADPARM_LEN + 1] = {}; |
| 475 | |
Heiko Carstens | 05dd253 | 2007-07-10 11:24:09 +0200 | [diff] [blame] | 476 | if (!sclp_ipl_info.is_valid) |
Michael Holzheu | 03a4d20 | 2006-12-04 15:39:58 +0100 | [diff] [blame] | 477 | return sprintf(page, "#unknown#\n"); |
Heiko Carstens | 05dd253 | 2007-07-10 11:24:09 +0200 | [diff] [blame] | 478 | memcpy(loadparm, &sclp_ipl_info.loadparm, LOADPARM_LEN); |
Michael Holzheu | 03a4d20 | 2006-12-04 15:39:58 +0100 | [diff] [blame] | 479 | EBCASC(loadparm, LOADPARM_LEN); |
Heiko Carstens | 1d802e2 | 2009-12-18 17:43:27 +0100 | [diff] [blame] | 480 | strim(loadparm); |
Michael Holzheu | 03a4d20 | 2006-12-04 15:39:58 +0100 | [diff] [blame] | 481 | return sprintf(page, "%s\n", loadparm); |
| 482 | } |
| 483 | |
Greg Kroah-Hartman | 9b94916 | 2007-11-02 17:17:00 -0400 | [diff] [blame] | 484 | static struct kobj_attribute sys_ipl_ccw_loadparm_attr = |
Michael Holzheu | 03a4d20 | 2006-12-04 15:39:58 +0100 | [diff] [blame] | 485 | __ATTR(loadparm, 0444, ipl_ccw_loadparm_show, NULL); |
| 486 | |
Hendrik Brueckner | a0443fb | 2008-07-14 09:59:09 +0200 | [diff] [blame] | 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, |
| 493 | }; |
| 494 | |
| 495 | static struct attribute *ipl_ccw_attrs_lpar[] = { |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 496 | &sys_ipl_type_attr.attr, |
| 497 | &sys_ipl_device_attr.attr, |
Michael Holzheu | 03a4d20 | 2006-12-04 15:39:58 +0100 | [diff] [blame] | 498 | &sys_ipl_ccw_loadparm_attr.attr, |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 499 | NULL, |
| 500 | }; |
| 501 | |
Hendrik Brueckner | a0443fb | 2008-07-14 09:59:09 +0200 | [diff] [blame] | 502 | static struct attribute_group ipl_ccw_attr_group_vm = { |
| 503 | .attrs = ipl_ccw_attrs_vm, |
| 504 | }; |
| 505 | |
| 506 | static struct attribute_group ipl_ccw_attr_group_lpar = { |
| 507 | .attrs = ipl_ccw_attrs_lpar |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 508 | }; |
| 509 | |
Hongjie Yang | fe355b7 | 2007-02-05 21:18:24 +0100 | [diff] [blame] | 510 | /* NSS ipl device attributes */ |
| 511 | |
| 512 | DEFINE_IPL_ATTR_RO(ipl_nss, name, "%s\n", kernel_nss_name); |
| 513 | |
| 514 | static struct attribute *ipl_nss_attrs[] = { |
| 515 | &sys_ipl_type_attr.attr, |
| 516 | &sys_ipl_nss_name_attr.attr, |
Hendrik Brueckner | a0443fb | 2008-07-14 09:59:09 +0200 | [diff] [blame] | 517 | &sys_ipl_ccw_loadparm_attr.attr, |
| 518 | &sys_ipl_vm_parm_attr.attr, |
Hongjie Yang | fe355b7 | 2007-02-05 21:18:24 +0100 | [diff] [blame] | 519 | NULL, |
| 520 | }; |
| 521 | |
| 522 | static struct attribute_group ipl_nss_attr_group = { |
| 523 | .attrs = ipl_nss_attrs, |
| 524 | }; |
| 525 | |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 526 | /* UNKNOWN ipl device attributes */ |
| 527 | |
| 528 | static struct attribute *ipl_unknown_attrs[] = { |
| 529 | &sys_ipl_type_attr.attr, |
| 530 | NULL, |
| 531 | }; |
| 532 | |
| 533 | static struct attribute_group ipl_unknown_attr_group = { |
| 534 | .attrs = ipl_unknown_attrs, |
| 535 | }; |
| 536 | |
Greg Kroah-Hartman | d91885b | 2007-11-02 17:17:00 -0400 | [diff] [blame] | 537 | static struct kset *ipl_kset; |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 538 | |
Michael Holzheu | 99ca4e5 | 2008-01-26 14:11:11 +0100 | [diff] [blame] | 539 | static int __init ipl_register_fcp_files(void) |
| 540 | { |
| 541 | int rc; |
| 542 | |
| 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; |
| 552 | |
| 553 | sysfs_remove_bin_file(&ipl_kset->kobj, &ipl_parameter_attr); |
| 554 | |
| 555 | out_ipl_parm: |
| 556 | sysfs_remove_group(&ipl_kset->kobj, &ipl_fcp_attr_group); |
| 557 | out: |
| 558 | return rc; |
| 559 | } |
| 560 | |
Heiko Carstens | 2c2df11 | 2010-02-26 22:37:34 +0100 | [diff] [blame] | 561 | static void __ipl_run(void *unused) |
Michael Holzheu | 99ca4e5 | 2008-01-26 14:11:11 +0100 | [diff] [blame] | 562 | { |
| 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); |
| 568 | } |
| 569 | |
Heiko Carstens | 2c2df11 | 2010-02-26 22:37:34 +0100 | [diff] [blame] | 570 | static void ipl_run(struct shutdown_trigger *trigger) |
| 571 | { |
| 572 | smp_switch_to_ipl_cpu(__ipl_run, NULL); |
| 573 | } |
| 574 | |
Heiko Carstens | 2bc89b5 | 2008-02-05 16:50:40 +0100 | [diff] [blame] | 575 | static int __init ipl_init(void) |
Michael Holzheu | 99ca4e5 | 2008-01-26 14:11:11 +0100 | [diff] [blame] | 576 | { |
| 577 | int rc; |
| 578 | |
| 579 | ipl_kset = kset_create_and_add("ipl", NULL, firmware_kobj); |
| 580 | if (!ipl_kset) { |
| 581 | rc = -ENOMEM; |
| 582 | goto out; |
| 583 | } |
| 584 | switch (ipl_info.type) { |
| 585 | case IPL_TYPE_CCW: |
Hendrik Brueckner | a0443fb | 2008-07-14 09:59:09 +0200 | [diff] [blame] | 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); |
Michael Holzheu | 99ca4e5 | 2008-01-26 14:11:11 +0100 | [diff] [blame] | 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; |
| 604 | } |
| 605 | out: |
| 606 | if (rc) |
| 607 | panic("ipl_init failed: rc = %i\n", rc); |
| 608 | |
| 609 | return 0; |
| 610 | } |
| 611 | |
Heiko Carstens | 2bc89b5 | 2008-02-05 16:50:40 +0100 | [diff] [blame] | 612 | static struct shutdown_action __refdata ipl_action = { |
| 613 | .name = SHUTDOWN_ACTION_IPL_STR, |
| 614 | .fn = ipl_run, |
| 615 | .init = ipl_init, |
| 616 | }; |
Michael Holzheu | 99ca4e5 | 2008-01-26 14:11:11 +0100 | [diff] [blame] | 617 | |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 618 | /* |
Michael Holzheu | 99ca4e5 | 2008-01-26 14:11:11 +0100 | [diff] [blame] | 619 | * reipl shutdown action: Reboot Linux on shutdown. |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 620 | */ |
| 621 | |
Hendrik Brueckner | a0443fb | 2008-07-14 09:59:09 +0200 | [diff] [blame] | 622 | /* VM IPL PARM attributes */ |
| 623 | static ssize_t reipl_generic_vmparm_show(struct ipl_parameter_block *ipb, |
| 624 | char *page) |
| 625 | { |
| 626 | char vmparm[DIAG308_VMPARM_SIZE + 1] = {}; |
| 627 | |
Hendrik Brueckner | 684d2fd | 2009-09-11 10:28:40 +0200 | [diff] [blame] | 628 | reipl_get_ascii_vmparm(vmparm, sizeof(vmparm), ipb); |
Hendrik Brueckner | a0443fb | 2008-07-14 09:59:09 +0200 | [diff] [blame] | 629 | return sprintf(page, "%s\n", vmparm); |
| 630 | } |
| 631 | |
| 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) |
| 635 | { |
| 636 | int i, ip_len; |
| 637 | |
| 638 | /* ignore trailing newline */ |
| 639 | ip_len = len; |
| 640 | if ((len > 0) && (buf[len - 1] == '\n')) |
| 641 | ip_len--; |
| 642 | |
| 643 | if (ip_len > vmparm_max) |
| 644 | return -EINVAL; |
| 645 | |
| 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; |
| 650 | |
| 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; |
| 659 | } |
| 660 | |
| 661 | return len; |
| 662 | } |
| 663 | |
| 664 | /* NSS wrapper */ |
| 665 | static ssize_t reipl_nss_vmparm_show(struct kobject *kobj, |
| 666 | struct kobj_attribute *attr, char *page) |
| 667 | { |
| 668 | return reipl_generic_vmparm_show(reipl_block_nss, page); |
| 669 | } |
| 670 | |
| 671 | static ssize_t reipl_nss_vmparm_store(struct kobject *kobj, |
| 672 | struct kobj_attribute *attr, |
| 673 | const char *buf, size_t len) |
| 674 | { |
| 675 | return reipl_generic_vmparm_store(reipl_block_nss, 56, buf, len); |
| 676 | } |
| 677 | |
| 678 | /* CCW wrapper */ |
| 679 | static ssize_t reipl_ccw_vmparm_show(struct kobject *kobj, |
| 680 | struct kobj_attribute *attr, char *page) |
| 681 | { |
| 682 | return reipl_generic_vmparm_show(reipl_block_ccw, page); |
| 683 | } |
| 684 | |
| 685 | static ssize_t reipl_ccw_vmparm_store(struct kobject *kobj, |
| 686 | struct kobj_attribute *attr, |
| 687 | const char *buf, size_t len) |
| 688 | { |
| 689 | return reipl_generic_vmparm_store(reipl_block_ccw, 64, buf, len); |
| 690 | } |
| 691 | |
| 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); |
| 698 | |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 699 | /* FCP reipl device attributes */ |
| 700 | |
Chris Wright | 2c3c8be | 2010-05-12 18:28:57 -0700 | [diff] [blame] | 701 | static ssize_t reipl_fcp_scpdata_read(struct file *filp, struct kobject *kobj, |
Hendrik Brueckner | 684d2fd | 2009-09-11 10:28:40 +0200 | [diff] [blame] | 702 | struct bin_attribute *attr, |
| 703 | char *buf, loff_t off, size_t count) |
| 704 | { |
| 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; |
| 707 | |
| 708 | return memory_read_from_buffer(buf, count, &off, scp_data, size); |
| 709 | } |
| 710 | |
Chris Wright | 2c3c8be | 2010-05-12 18:28:57 -0700 | [diff] [blame] | 711 | static ssize_t reipl_fcp_scpdata_write(struct file *filp, struct kobject *kobj, |
Hendrik Brueckner | 684d2fd | 2009-09-11 10:28:40 +0200 | [diff] [blame] | 712 | struct bin_attribute *attr, |
| 713 | char *buf, loff_t off, size_t count) |
| 714 | { |
| 715 | size_t padding; |
| 716 | size_t scpdata_len; |
| 717 | |
| 718 | if (off < 0) |
| 719 | return -EINVAL; |
| 720 | |
| 721 | if (off >= DIAG308_SCPDATA_SIZE) |
| 722 | return -ENOSPC; |
| 723 | |
| 724 | if (count > DIAG308_SCPDATA_SIZE - off) |
| 725 | count = DIAG308_SCPDATA_SIZE - off; |
| 726 | |
| 727 | memcpy(reipl_block_fcp->ipl_info.fcp.scp_data, buf + off, count); |
| 728 | scpdata_len = off + count; |
| 729 | |
| 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; |
| 735 | } |
| 736 | |
| 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; |
| 740 | |
| 741 | return count; |
| 742 | } |
| 743 | |
| 744 | static struct bin_attribute sys_reipl_fcp_scp_data_attr = { |
| 745 | .attr = { |
| 746 | .name = "scp_data", |
| 747 | .mode = S_IRUGO | S_IWUSR, |
| 748 | }, |
| 749 | .size = PAGE_SIZE, |
| 750 | .read = reipl_fcp_scpdata_read, |
| 751 | .write = reipl_fcp_scpdata_write, |
| 752 | }; |
| 753 | |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 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); |
| 764 | |
| 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, |
| 772 | }; |
| 773 | |
| 774 | static struct attribute_group reipl_fcp_attr_group = { |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 775 | .attrs = reipl_fcp_attrs, |
| 776 | }; |
| 777 | |
| 778 | /* CCW reipl device attributes */ |
| 779 | |
| 780 | DEFINE_IPL_ATTR_RW(reipl_ccw, device, "0.0.%04llx\n", "0.0.%llx\n", |
| 781 | reipl_block_ccw->ipl_info.ccw.devno); |
| 782 | |
Hendrik Brueckner | a0443fb | 2008-07-14 09:59:09 +0200 | [diff] [blame] | 783 | static void reipl_get_ascii_loadparm(char *loadparm, |
| 784 | struct ipl_parameter_block *ibp) |
Michael Holzheu | 03a4d20 | 2006-12-04 15:39:58 +0100 | [diff] [blame] | 785 | { |
Hendrik Brueckner | a0443fb | 2008-07-14 09:59:09 +0200 | [diff] [blame] | 786 | memcpy(loadparm, ibp->ipl_info.ccw.load_parm, LOADPARM_LEN); |
Michael Holzheu | 03a4d20 | 2006-12-04 15:39:58 +0100 | [diff] [blame] | 787 | EBCASC(loadparm, LOADPARM_LEN); |
| 788 | loadparm[LOADPARM_LEN] = 0; |
Heiko Carstens | 1d802e2 | 2009-12-18 17:43:27 +0100 | [diff] [blame] | 789 | strim(loadparm); |
Michael Holzheu | 03a4d20 | 2006-12-04 15:39:58 +0100 | [diff] [blame] | 790 | } |
| 791 | |
Hendrik Brueckner | a0443fb | 2008-07-14 09:59:09 +0200 | [diff] [blame] | 792 | static ssize_t reipl_generic_loadparm_show(struct ipl_parameter_block *ipb, |
| 793 | char *page) |
Michael Holzheu | 03a4d20 | 2006-12-04 15:39:58 +0100 | [diff] [blame] | 794 | { |
| 795 | char buf[LOADPARM_LEN + 1]; |
| 796 | |
Hendrik Brueckner | a0443fb | 2008-07-14 09:59:09 +0200 | [diff] [blame] | 797 | reipl_get_ascii_loadparm(buf, ipb); |
Michael Holzheu | 03a4d20 | 2006-12-04 15:39:58 +0100 | [diff] [blame] | 798 | return sprintf(page, "%s\n", buf); |
| 799 | } |
| 800 | |
Hendrik Brueckner | a0443fb | 2008-07-14 09:59:09 +0200 | [diff] [blame] | 801 | static ssize_t reipl_generic_loadparm_store(struct ipl_parameter_block *ipb, |
| 802 | const char *buf, size_t len) |
Michael Holzheu | 03a4d20 | 2006-12-04 15:39:58 +0100 | [diff] [blame] | 803 | { |
| 804 | int i, lp_len; |
| 805 | |
| 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; |
| 819 | } |
| 820 | /* initialize loadparm with blanks */ |
Hendrik Brueckner | a0443fb | 2008-07-14 09:59:09 +0200 | [diff] [blame] | 821 | memset(ipb->ipl_info.ccw.load_parm, ' ', LOADPARM_LEN); |
Michael Holzheu | 03a4d20 | 2006-12-04 15:39:58 +0100 | [diff] [blame] | 822 | /* copy and convert to ebcdic */ |
Hendrik Brueckner | a0443fb | 2008-07-14 09:59:09 +0200 | [diff] [blame] | 823 | memcpy(ipb->ipl_info.ccw.load_parm, buf, lp_len); |
| 824 | ASCEBC(ipb->ipl_info.ccw.load_parm, LOADPARM_LEN); |
Michael Holzheu | 03a4d20 | 2006-12-04 15:39:58 +0100 | [diff] [blame] | 825 | return len; |
| 826 | } |
| 827 | |
Hendrik Brueckner | a0443fb | 2008-07-14 09:59:09 +0200 | [diff] [blame] | 828 | /* NSS wrapper */ |
| 829 | static ssize_t reipl_nss_loadparm_show(struct kobject *kobj, |
| 830 | struct kobj_attribute *attr, char *page) |
| 831 | { |
| 832 | return reipl_generic_loadparm_show(reipl_block_nss, page); |
| 833 | } |
Michael Holzheu | 03a4d20 | 2006-12-04 15:39:58 +0100 | [diff] [blame] | 834 | |
Hendrik Brueckner | a0443fb | 2008-07-14 09:59:09 +0200 | [diff] [blame] | 835 | static ssize_t reipl_nss_loadparm_store(struct kobject *kobj, |
| 836 | struct kobj_attribute *attr, |
| 837 | const char *buf, size_t len) |
| 838 | { |
| 839 | return reipl_generic_loadparm_store(reipl_block_nss, buf, len); |
| 840 | } |
| 841 | |
| 842 | /* CCW wrapper */ |
| 843 | static ssize_t reipl_ccw_loadparm_show(struct kobject *kobj, |
| 844 | struct kobj_attribute *attr, char *page) |
| 845 | { |
| 846 | return reipl_generic_loadparm_show(reipl_block_ccw, page); |
| 847 | } |
| 848 | |
| 849 | static ssize_t reipl_ccw_loadparm_store(struct kobject *kobj, |
| 850 | struct kobj_attribute *attr, |
| 851 | const char *buf, size_t len) |
| 852 | { |
| 853 | return reipl_generic_loadparm_store(reipl_block_ccw, buf, len); |
| 854 | } |
| 855 | |
| 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); |
| 859 | |
| 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, |
| 865 | }; |
| 866 | |
| 867 | static struct attribute *reipl_ccw_attrs_lpar[] = { |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 868 | &sys_reipl_ccw_device_attr.attr, |
Michael Holzheu | 03a4d20 | 2006-12-04 15:39:58 +0100 | [diff] [blame] | 869 | &sys_reipl_ccw_loadparm_attr.attr, |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 870 | NULL, |
| 871 | }; |
| 872 | |
Hendrik Brueckner | a0443fb | 2008-07-14 09:59:09 +0200 | [diff] [blame] | 873 | static struct attribute_group reipl_ccw_attr_group_vm = { |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 874 | .name = IPL_CCW_STR, |
Hendrik Brueckner | a0443fb | 2008-07-14 09:59:09 +0200 | [diff] [blame] | 875 | .attrs = reipl_ccw_attrs_vm, |
| 876 | }; |
| 877 | |
| 878 | static struct attribute_group reipl_ccw_attr_group_lpar = { |
| 879 | .name = IPL_CCW_STR, |
| 880 | .attrs = reipl_ccw_attrs_lpar, |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 881 | }; |
| 882 | |
Hongjie Yang | fe355b7 | 2007-02-05 21:18:24 +0100 | [diff] [blame] | 883 | |
| 884 | /* NSS reipl device attributes */ |
Hendrik Brueckner | a0443fb | 2008-07-14 09:59:09 +0200 | [diff] [blame] | 885 | static void reipl_get_ascii_nss_name(char *dst, |
| 886 | struct ipl_parameter_block *ipb) |
| 887 | { |
| 888 | memcpy(dst, ipb->ipl_info.ccw.nss_name, NSS_NAME_SIZE); |
| 889 | EBCASC(dst, NSS_NAME_SIZE); |
| 890 | dst[NSS_NAME_SIZE] = 0; |
| 891 | } |
Hongjie Yang | fe355b7 | 2007-02-05 21:18:24 +0100 | [diff] [blame] | 892 | |
Hendrik Brueckner | a0443fb | 2008-07-14 09:59:09 +0200 | [diff] [blame] | 893 | static ssize_t reipl_nss_name_show(struct kobject *kobj, |
| 894 | struct kobj_attribute *attr, char *page) |
| 895 | { |
| 896 | char nss_name[NSS_NAME_SIZE + 1] = {}; |
| 897 | |
| 898 | reipl_get_ascii_nss_name(nss_name, reipl_block_nss); |
| 899 | return sprintf(page, "%s\n", nss_name); |
| 900 | } |
| 901 | |
| 902 | static ssize_t reipl_nss_name_store(struct kobject *kobj, |
| 903 | struct kobj_attribute *attr, |
| 904 | const char *buf, size_t len) |
| 905 | { |
| 906 | int nss_len; |
| 907 | |
| 908 | /* ignore trailing newline */ |
| 909 | nss_len = len; |
| 910 | if ((len > 0) && (buf[len - 1] == '\n')) |
| 911 | nss_len--; |
| 912 | |
| 913 | if (nss_len > NSS_NAME_SIZE) |
| 914 | return -EINVAL; |
| 915 | |
| 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; |
| 926 | } |
| 927 | |
| 928 | return len; |
| 929 | } |
| 930 | |
| 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); |
| 934 | |
| 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); |
Hongjie Yang | fe355b7 | 2007-02-05 21:18:24 +0100 | [diff] [blame] | 938 | |
| 939 | static struct attribute *reipl_nss_attrs[] = { |
| 940 | &sys_reipl_nss_name_attr.attr, |
Hendrik Brueckner | a0443fb | 2008-07-14 09:59:09 +0200 | [diff] [blame] | 941 | &sys_reipl_nss_loadparm_attr.attr, |
| 942 | &sys_reipl_nss_vmparm_attr.attr, |
Hongjie Yang | fe355b7 | 2007-02-05 21:18:24 +0100 | [diff] [blame] | 943 | NULL, |
| 944 | }; |
| 945 | |
| 946 | static struct attribute_group reipl_nss_attr_group = { |
| 947 | .name = IPL_NSS_STR, |
| 948 | .attrs = reipl_nss_attrs, |
| 949 | }; |
| 950 | |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 951 | /* reipl type */ |
| 952 | |
| 953 | static int reipl_set_type(enum ipl_type type) |
| 954 | { |
| 955 | if (!(reipl_capabilities & type)) |
| 956 | return -EINVAL; |
| 957 | |
| 958 | switch(type) { |
| 959 | case IPL_TYPE_CCW: |
Michael Holzheu | 48657d2 | 2008-01-26 14:11:17 +0100 | [diff] [blame] | 960 | if (diag308_set_works) |
| 961 | reipl_method = REIPL_METHOD_CCW_DIAG; |
| 962 | else if (MACHINE_IS_VM) |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 963 | reipl_method = REIPL_METHOD_CCW_VM; |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 964 | else |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 965 | reipl_method = REIPL_METHOD_CCW_CIO; |
Frank Munzert | 099b765 | 2009-03-26 15:23:43 +0100 | [diff] [blame] | 966 | reipl_block_actual = reipl_block_ccw; |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 967 | break; |
| 968 | case IPL_TYPE_FCP: |
| 969 | if (diag308_set_works) |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 970 | reipl_method = REIPL_METHOD_FCP_RW_DIAG; |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 971 | else if (MACHINE_IS_VM) |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 972 | reipl_method = REIPL_METHOD_FCP_RO_VM; |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 973 | else |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 974 | reipl_method = REIPL_METHOD_FCP_RO_DIAG; |
Frank Munzert | 099b765 | 2009-03-26 15:23:43 +0100 | [diff] [blame] | 975 | reipl_block_actual = reipl_block_fcp; |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 976 | break; |
| 977 | case IPL_TYPE_FCP_DUMP: |
| 978 | reipl_method = REIPL_METHOD_FCP_DUMP; |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 979 | break; |
Hongjie Yang | fe355b7 | 2007-02-05 21:18:24 +0100 | [diff] [blame] | 980 | case IPL_TYPE_NSS: |
Hendrik Brueckner | a0443fb | 2008-07-14 09:59:09 +0200 | [diff] [blame] | 981 | if (diag308_set_works) |
| 982 | reipl_method = REIPL_METHOD_NSS_DIAG; |
| 983 | else |
| 984 | reipl_method = REIPL_METHOD_NSS; |
Frank Munzert | 099b765 | 2009-03-26 15:23:43 +0100 | [diff] [blame] | 985 | reipl_block_actual = reipl_block_nss; |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 986 | break; |
| 987 | case IPL_TYPE_UNKNOWN: |
| 988 | reipl_method = REIPL_METHOD_DEFAULT; |
Hongjie Yang | fe355b7 | 2007-02-05 21:18:24 +0100 | [diff] [blame] | 989 | break; |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 990 | default: |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 991 | BUG(); |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 992 | } |
| 993 | reipl_type = type; |
| 994 | return 0; |
| 995 | } |
| 996 | |
Greg Kroah-Hartman | 9b94916 | 2007-11-02 17:17:00 -0400 | [diff] [blame] | 997 | static ssize_t reipl_type_show(struct kobject *kobj, |
| 998 | struct kobj_attribute *attr, char *page) |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 999 | { |
| 1000 | return sprintf(page, "%s\n", ipl_type_str(reipl_type)); |
| 1001 | } |
| 1002 | |
Greg Kroah-Hartman | 9b94916 | 2007-11-02 17:17:00 -0400 | [diff] [blame] | 1003 | static ssize_t reipl_type_store(struct kobject *kobj, |
| 1004 | struct kobj_attribute *attr, |
| 1005 | const char *buf, size_t len) |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 1006 | { |
| 1007 | int rc = -EINVAL; |
| 1008 | |
| 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); |
Hongjie Yang | fe355b7 | 2007-02-05 21:18:24 +0100 | [diff] [blame] | 1013 | else if (strncmp(buf, IPL_NSS_STR, strlen(IPL_NSS_STR)) == 0) |
| 1014 | rc = reipl_set_type(IPL_TYPE_NSS); |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 1015 | return (rc != 0) ? rc : len; |
| 1016 | } |
| 1017 | |
Greg Kroah-Hartman | 9b94916 | 2007-11-02 17:17:00 -0400 | [diff] [blame] | 1018 | static struct kobj_attribute reipl_type_attr = |
Michael Holzheu | 99ca4e5 | 2008-01-26 14:11:11 +0100 | [diff] [blame] | 1019 | __ATTR(reipl_type, 0644, reipl_type_show, reipl_type_store); |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 1020 | |
Greg Kroah-Hartman | d91885b | 2007-11-02 17:17:00 -0400 | [diff] [blame] | 1021 | static struct kset *reipl_kset; |
Hendrik Brueckner | 684d2fd | 2009-09-11 10:28:40 +0200 | [diff] [blame] | 1022 | static struct kset *reipl_fcp_kset; |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 1023 | |
Hendrik Brueckner | a0443fb | 2008-07-14 09:59:09 +0200 | [diff] [blame] | 1024 | static void get_ipl_string(char *dst, struct ipl_parameter_block *ipb, |
| 1025 | const enum ipl_method m) |
| 1026 | { |
| 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; |
| 1031 | |
| 1032 | reipl_get_ascii_loadparm(loadparm, ipb); |
| 1033 | reipl_get_ascii_nss_name(nss_name, ipb); |
Hendrik Brueckner | 684d2fd | 2009-09-11 10:28:40 +0200 | [diff] [blame] | 1034 | reipl_get_ascii_vmparm(vmparm, sizeof(vmparm), ipb); |
Hendrik Brueckner | a0443fb | 2008-07-14 09:59:09 +0200 | [diff] [blame] | 1035 | |
| 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; |
| 1045 | } |
| 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); |
| 1050 | } |
| 1051 | |
Heiko Carstens | 2c2df11 | 2010-02-26 22:37:34 +0100 | [diff] [blame] | 1052 | static void __reipl_run(void *unused) |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 1053 | { |
| 1054 | struct ccw_dev_id devid; |
Hendrik Brueckner | a0443fb | 2008-07-14 09:59:09 +0200 | [diff] [blame] | 1055 | static char buf[128]; |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 1056 | |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 1057 | switch (reipl_method) { |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 1058 | case REIPL_METHOD_CCW_CIO: |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 1059 | devid.devno = reipl_block_ccw->ipl_info.ccw.devno; |
| 1060 | devid.ssid = 0; |
| 1061 | reipl_ccw_dev(&devid); |
| 1062 | break; |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 1063 | case REIPL_METHOD_CCW_VM: |
Hendrik Brueckner | a0443fb | 2008-07-14 09:59:09 +0200 | [diff] [blame] | 1064 | get_ipl_string(buf, reipl_block_ccw, REIPL_METHOD_CCW_VM); |
Heiko Carstens | 740b570 | 2006-12-04 15:40:30 +0100 | [diff] [blame] | 1065 | __cpcmd(buf, NULL, 0, NULL); |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 1066 | break; |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 1067 | case REIPL_METHOD_CCW_DIAG: |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 1068 | diag308(DIAG308_SET, reipl_block_ccw); |
| 1069 | diag308(DIAG308_IPL, NULL); |
| 1070 | break; |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 1071 | case REIPL_METHOD_FCP_RW_DIAG: |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 1072 | diag308(DIAG308_SET, reipl_block_fcp); |
| 1073 | diag308(DIAG308_IPL, NULL); |
| 1074 | break; |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 1075 | case REIPL_METHOD_FCP_RO_DIAG: |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 1076 | diag308(DIAG308_IPL, NULL); |
| 1077 | break; |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 1078 | case REIPL_METHOD_FCP_RO_VM: |
Heiko Carstens | 740b570 | 2006-12-04 15:40:30 +0100 | [diff] [blame] | 1079 | __cpcmd("IPL", NULL, 0, NULL); |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 1080 | break; |
Hendrik Brueckner | a0443fb | 2008-07-14 09:59:09 +0200 | [diff] [blame] | 1081 | case REIPL_METHOD_NSS_DIAG: |
| 1082 | diag308(DIAG308_SET, reipl_block_nss); |
| 1083 | diag308(DIAG308_IPL, NULL); |
| 1084 | break; |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 1085 | case REIPL_METHOD_NSS: |
Hendrik Brueckner | a0443fb | 2008-07-14 09:59:09 +0200 | [diff] [blame] | 1086 | get_ipl_string(buf, reipl_block_nss, REIPL_METHOD_NSS); |
Hongjie Yang | fe355b7 | 2007-02-05 21:18:24 +0100 | [diff] [blame] | 1087 | __cpcmd(buf, NULL, 0, NULL); |
| 1088 | break; |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 1089 | case REIPL_METHOD_DEFAULT: |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 1090 | if (MACHINE_IS_VM) |
Heiko Carstens | 740b570 | 2006-12-04 15:40:30 +0100 | [diff] [blame] | 1091 | __cpcmd("IPL", NULL, 0, NULL); |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 1092 | diag308(DIAG308_IPL, NULL); |
| 1093 | break; |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 1094 | case REIPL_METHOD_FCP_DUMP: |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 1095 | break; |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 1096 | } |
Michael Holzheu | 208e559 | 2008-03-05 12:37:15 +0100 | [diff] [blame] | 1097 | disabled_wait((unsigned long) __builtin_return_address(0)); |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 1098 | } |
| 1099 | |
Heiko Carstens | 2c2df11 | 2010-02-26 22:37:34 +0100 | [diff] [blame] | 1100 | static void reipl_run(struct shutdown_trigger *trigger) |
| 1101 | { |
| 1102 | smp_switch_to_ipl_cpu(__reipl_run, NULL); |
| 1103 | } |
| 1104 | |
Hendrik Brueckner | a0443fb | 2008-07-14 09:59:09 +0200 | [diff] [blame] | 1105 | static void reipl_block_ccw_init(struct ipl_parameter_block *ipb) |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 1106 | { |
Hendrik Brueckner | a0443fb | 2008-07-14 09:59:09 +0200 | [diff] [blame] | 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; |
| 1111 | } |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 1112 | |
Hendrik Brueckner | a0443fb | 2008-07-14 09:59:09 +0200 | [diff] [blame] | 1113 | static void reipl_block_ccw_fill_parms(struct ipl_parameter_block *ipb) |
| 1114 | { |
| 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; |
| 1124 | |
| 1125 | /* VM PARM */ |
| 1126 | if (MACHINE_IS_VM && diag308_set_works && |
| 1127 | (ipl_block.ipl_info.ccw.vm_flags & DIAG308_VM_FLAGS_VP_VALID)) { |
| 1128 | |
| 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); |
| 1134 | } |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 1135 | } |
| 1136 | |
Hongjie Yang | fe355b7 | 2007-02-05 21:18:24 +0100 | [diff] [blame] | 1137 | static int __init reipl_nss_init(void) |
| 1138 | { |
| 1139 | int rc; |
| 1140 | |
| 1141 | if (!MACHINE_IS_VM) |
| 1142 | return 0; |
Hendrik Brueckner | a0443fb | 2008-07-14 09:59:09 +0200 | [diff] [blame] | 1143 | |
| 1144 | reipl_block_nss = (void *) get_zeroed_page(GFP_KERNEL); |
| 1145 | if (!reipl_block_nss) |
| 1146 | return -ENOMEM; |
| 1147 | |
| 1148 | if (!diag308_set_works) |
| 1149 | sys_reipl_nss_vmparm_attr.attr.mode = S_IRUGO; |
| 1150 | |
Greg Kroah-Hartman | d91885b | 2007-11-02 17:17:00 -0400 | [diff] [blame] | 1151 | rc = sysfs_create_group(&reipl_kset->kobj, &reipl_nss_attr_group); |
Hongjie Yang | fe355b7 | 2007-02-05 21:18:24 +0100 | [diff] [blame] | 1152 | if (rc) |
| 1153 | return rc; |
Hendrik Brueckner | a0443fb | 2008-07-14 09:59:09 +0200 | [diff] [blame] | 1154 | |
| 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; |
| 1164 | |
| 1165 | reipl_block_ccw_fill_parms(reipl_block_nss); |
| 1166 | } |
| 1167 | |
Hongjie Yang | fe355b7 | 2007-02-05 21:18:24 +0100 | [diff] [blame] | 1168 | reipl_capabilities |= IPL_TYPE_NSS; |
| 1169 | return 0; |
| 1170 | } |
| 1171 | |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 1172 | static int __init reipl_ccw_init(void) |
| 1173 | { |
| 1174 | int rc; |
| 1175 | |
| 1176 | reipl_block_ccw = (void *) get_zeroed_page(GFP_KERNEL); |
| 1177 | if (!reipl_block_ccw) |
| 1178 | return -ENOMEM; |
Hendrik Brueckner | a0443fb | 2008-07-14 09:59:09 +0200 | [diff] [blame] | 1179 | |
| 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); |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 1190 | } |
Hendrik Brueckner | a0443fb | 2008-07-14 09:59:09 +0200 | [diff] [blame] | 1191 | if (rc) |
| 1192 | return rc; |
| 1193 | |
| 1194 | reipl_block_ccw_init(reipl_block_ccw); |
| 1195 | if (ipl_info.type == IPL_TYPE_CCW) { |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 1196 | reipl_block_ccw->ipl_info.ccw.devno = ipl_devno; |
Hendrik Brueckner | a0443fb | 2008-07-14 09:59:09 +0200 | [diff] [blame] | 1197 | reipl_block_ccw_fill_parms(reipl_block_ccw); |
| 1198 | } |
| 1199 | |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 1200 | reipl_capabilities |= IPL_TYPE_CCW; |
| 1201 | return 0; |
| 1202 | } |
| 1203 | |
| 1204 | static int __init reipl_fcp_init(void) |
| 1205 | { |
| 1206 | int rc; |
| 1207 | |
Michael Holzheu | 008d2d1 | 2009-03-26 15:24:51 +0100 | [diff] [blame] | 1208 | if (!diag308_set_works) { |
Hendrik Brueckner | 684d2fd | 2009-09-11 10:28:40 +0200 | [diff] [blame] | 1209 | if (ipl_info.type == IPL_TYPE_FCP) { |
Michael Holzheu | 008d2d1 | 2009-03-26 15:24:51 +0100 | [diff] [blame] | 1210 | make_attrs_ro(reipl_fcp_attrs); |
Hendrik Brueckner | 684d2fd | 2009-09-11 10:28:40 +0200 | [diff] [blame] | 1211 | sys_reipl_fcp_scp_data_attr.attr.mode = S_IRUGO; |
| 1212 | } else |
Michael Holzheu | 008d2d1 | 2009-03-26 15:24:51 +0100 | [diff] [blame] | 1213 | return 0; |
| 1214 | } |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 1215 | |
| 1216 | reipl_block_fcp = (void *) get_zeroed_page(GFP_KERNEL); |
| 1217 | if (!reipl_block_fcp) |
| 1218 | return -ENOMEM; |
Hendrik Brueckner | 684d2fd | 2009-09-11 10:28:40 +0200 | [diff] [blame] | 1219 | |
| 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; |
| 1226 | } |
| 1227 | |
| 1228 | rc = sysfs_create_group(&reipl_fcp_kset->kobj, &reipl_fcp_attr_group); |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 1229 | if (rc) { |
Hendrik Brueckner | 684d2fd | 2009-09-11 10:28:40 +0200 | [diff] [blame] | 1230 | kset_unregister(reipl_fcp_kset); |
| 1231 | free_page((unsigned long) reipl_block_fcp); |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 1232 | return rc; |
| 1233 | } |
Hendrik Brueckner | 684d2fd | 2009-09-11 10:28:40 +0200 | [diff] [blame] | 1234 | |
| 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; |
| 1242 | } |
| 1243 | |
| 1244 | if (ipl_info.type == IPL_TYPE_FCP) |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 1245 | memcpy(reipl_block_fcp, IPL_PARMBLOCK_START, PAGE_SIZE); |
Hendrik Brueckner | 684d2fd | 2009-09-11 10:28:40 +0200 | [diff] [blame] | 1246 | else { |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 1247 | reipl_block_fcp->hdr.len = IPL_PARM_BLK_FCP_LEN; |
| 1248 | reipl_block_fcp->hdr.version = IPL_PARM_BLOCK_VERSION; |
Michael Holzheu | fbb04f3 | 2007-03-19 13:19:03 +0100 | [diff] [blame] | 1249 | reipl_block_fcp->hdr.blk0_len = IPL_PARM_BLK0_FCP_LEN; |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 1250 | reipl_block_fcp->hdr.pbt = DIAG308_IPL_TYPE_FCP; |
| 1251 | reipl_block_fcp->ipl_info.fcp.opt = DIAG308_IPL_OPT_IPL; |
| 1252 | } |
| 1253 | reipl_capabilities |= IPL_TYPE_FCP; |
| 1254 | return 0; |
| 1255 | } |
| 1256 | |
Heiko Carstens | 2bc89b5 | 2008-02-05 16:50:40 +0100 | [diff] [blame] | 1257 | static int __init reipl_init(void) |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 1258 | { |
| 1259 | int rc; |
| 1260 | |
Greg Kroah-Hartman | f62ed9e | 2007-11-05 13:16:15 -0800 | [diff] [blame] | 1261 | reipl_kset = kset_create_and_add("reipl", NULL, firmware_kobj); |
Greg Kroah-Hartman | d91885b | 2007-11-02 17:17:00 -0400 | [diff] [blame] | 1262 | if (!reipl_kset) |
| 1263 | return -ENOMEM; |
| 1264 | rc = sysfs_create_file(&reipl_kset->kobj, &reipl_type_attr.attr); |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 1265 | if (rc) { |
Greg Kroah-Hartman | d91885b | 2007-11-02 17:17:00 -0400 | [diff] [blame] | 1266 | kset_unregister(reipl_kset); |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 1267 | return rc; |
| 1268 | } |
| 1269 | rc = reipl_ccw_init(); |
| 1270 | if (rc) |
| 1271 | return rc; |
| 1272 | rc = reipl_fcp_init(); |
| 1273 | if (rc) |
| 1274 | return rc; |
Hongjie Yang | fe355b7 | 2007-02-05 21:18:24 +0100 | [diff] [blame] | 1275 | rc = reipl_nss_init(); |
| 1276 | if (rc) |
| 1277 | return rc; |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 1278 | rc = reipl_set_type(ipl_info.type); |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 1279 | if (rc) |
| 1280 | return rc; |
| 1281 | return 0; |
| 1282 | } |
| 1283 | |
Heiko Carstens | 2bc89b5 | 2008-02-05 16:50:40 +0100 | [diff] [blame] | 1284 | static struct shutdown_action __refdata reipl_action = { |
| 1285 | .name = SHUTDOWN_ACTION_REIPL_STR, |
| 1286 | .fn = reipl_run, |
| 1287 | .init = reipl_init, |
| 1288 | }; |
Michael Holzheu | 99ca4e5 | 2008-01-26 14:11:11 +0100 | [diff] [blame] | 1289 | |
| 1290 | /* |
| 1291 | * dump shutdown action: Dump Linux on shutdown. |
| 1292 | */ |
| 1293 | |
| 1294 | /* FCP dump device attributes */ |
| 1295 | |
| 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); |
| 1306 | |
| 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, |
| 1314 | }; |
| 1315 | |
| 1316 | static struct attribute_group dump_fcp_attr_group = { |
| 1317 | .name = IPL_FCP_STR, |
| 1318 | .attrs = dump_fcp_attrs, |
| 1319 | }; |
| 1320 | |
| 1321 | /* CCW dump device attributes */ |
| 1322 | |
| 1323 | DEFINE_IPL_ATTR_RW(dump_ccw, device, "0.0.%04llx\n", "0.0.%llx\n", |
| 1324 | dump_block_ccw->ipl_info.ccw.devno); |
| 1325 | |
| 1326 | static struct attribute *dump_ccw_attrs[] = { |
| 1327 | &sys_dump_ccw_device_attr.attr, |
| 1328 | NULL, |
| 1329 | }; |
| 1330 | |
| 1331 | static struct attribute_group dump_ccw_attr_group = { |
| 1332 | .name = IPL_CCW_STR, |
| 1333 | .attrs = dump_ccw_attrs, |
| 1334 | }; |
| 1335 | |
| 1336 | /* dump type */ |
| 1337 | |
| 1338 | static int dump_set_type(enum dump_type type) |
| 1339 | { |
| 1340 | if (!(dump_capabilities & type)) |
| 1341 | return -EINVAL; |
| 1342 | switch (type) { |
| 1343 | case DUMP_TYPE_CCW: |
Michael Holzheu | 48657d2 | 2008-01-26 14:11:17 +0100 | [diff] [blame] | 1344 | if (diag308_set_works) |
| 1345 | dump_method = DUMP_METHOD_CCW_DIAG; |
| 1346 | else if (MACHINE_IS_VM) |
Michael Holzheu | 99ca4e5 | 2008-01-26 14:11:11 +0100 | [diff] [blame] | 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; |
| 1356 | } |
| 1357 | dump_type = type; |
| 1358 | return 0; |
| 1359 | } |
| 1360 | |
| 1361 | static ssize_t dump_type_show(struct kobject *kobj, |
| 1362 | struct kobj_attribute *attr, char *page) |
| 1363 | { |
| 1364 | return sprintf(page, "%s\n", dump_type_str(dump_type)); |
| 1365 | } |
| 1366 | |
| 1367 | static ssize_t dump_type_store(struct kobject *kobj, |
| 1368 | struct kobj_attribute *attr, |
| 1369 | const char *buf, size_t len) |
| 1370 | { |
| 1371 | int rc = -EINVAL; |
| 1372 | |
| 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; |
| 1380 | } |
| 1381 | |
| 1382 | static struct kobj_attribute dump_type_attr = |
| 1383 | __ATTR(dump_type, 0644, dump_type_show, dump_type_store); |
| 1384 | |
| 1385 | static struct kset *dump_kset; |
| 1386 | |
Heiko Carstens | 2c2df11 | 2010-02-26 22:37:34 +0100 | [diff] [blame] | 1387 | static void __dump_run(void *unused) |
Michael Holzheu | 99ca4e5 | 2008-01-26 14:11:11 +0100 | [diff] [blame] | 1388 | { |
| 1389 | struct ccw_dev_id devid; |
| 1390 | static char buf[100]; |
| 1391 | |
| 1392 | switch (dump_method) { |
| 1393 | case DUMP_METHOD_CCW_CIO: |
Michael Holzheu | 99ca4e5 | 2008-01-26 14:11:11 +0100 | [diff] [blame] | 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: |
Michael Holzheu | 99ca4e5 | 2008-01-26 14:11:11 +0100 | [diff] [blame] | 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; |
Heiko Carstens | 2c2df11 | 2010-02-26 22:37:34 +0100 | [diff] [blame] | 1412 | default: |
| 1413 | break; |
Michael Holzheu | 99ca4e5 | 2008-01-26 14:11:11 +0100 | [diff] [blame] | 1414 | } |
Heiko Carstens | 2c2df11 | 2010-02-26 22:37:34 +0100 | [diff] [blame] | 1415 | } |
| 1416 | |
| 1417 | static void dump_run(struct shutdown_trigger *trigger) |
| 1418 | { |
| 1419 | if (dump_method == DUMP_METHOD_NONE) |
| 1420 | return; |
| 1421 | smp_send_stop(); |
| 1422 | smp_switch_to_ipl_cpu(__dump_run, NULL); |
Michael Holzheu | 99ca4e5 | 2008-01-26 14:11:11 +0100 | [diff] [blame] | 1423 | } |
| 1424 | |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 1425 | static int __init dump_ccw_init(void) |
| 1426 | { |
| 1427 | int rc; |
| 1428 | |
| 1429 | dump_block_ccw = (void *) get_zeroed_page(GFP_KERNEL); |
| 1430 | if (!dump_block_ccw) |
| 1431 | return -ENOMEM; |
Greg Kroah-Hartman | d91885b | 2007-11-02 17:17:00 -0400 | [diff] [blame] | 1432 | rc = sysfs_create_group(&dump_kset->kobj, &dump_ccw_attr_group); |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 1433 | if (rc) { |
| 1434 | free_page((unsigned long)dump_block_ccw); |
| 1435 | return rc; |
| 1436 | } |
| 1437 | dump_block_ccw->hdr.len = IPL_PARM_BLK_CCW_LEN; |
| 1438 | dump_block_ccw->hdr.version = IPL_PARM_BLOCK_VERSION; |
Michael Holzheu | fbb04f3 | 2007-03-19 13:19:03 +0100 | [diff] [blame] | 1439 | dump_block_ccw->hdr.blk0_len = IPL_PARM_BLK0_CCW_LEN; |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 1440 | dump_block_ccw->hdr.pbt = DIAG308_IPL_TYPE_CCW; |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 1441 | dump_capabilities |= DUMP_TYPE_CCW; |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 1442 | return 0; |
| 1443 | } |
| 1444 | |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 1445 | static int __init dump_fcp_init(void) |
| 1446 | { |
| 1447 | int rc; |
| 1448 | |
Heiko Carstens | 05dd253 | 2007-07-10 11:24:09 +0200 | [diff] [blame] | 1449 | if (!sclp_ipl_info.has_dump) |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 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; |
Greg Kroah-Hartman | d91885b | 2007-11-02 17:17:00 -0400 | [diff] [blame] | 1456 | rc = sysfs_create_group(&dump_kset->kobj, &dump_fcp_attr_group); |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 1457 | if (rc) { |
| 1458 | free_page((unsigned long)dump_block_fcp); |
| 1459 | return rc; |
| 1460 | } |
| 1461 | dump_block_fcp->hdr.len = IPL_PARM_BLK_FCP_LEN; |
| 1462 | dump_block_fcp->hdr.version = IPL_PARM_BLOCK_VERSION; |
Michael Holzheu | fbb04f3 | 2007-03-19 13:19:03 +0100 | [diff] [blame] | 1463 | dump_block_fcp->hdr.blk0_len = IPL_PARM_BLK0_FCP_LEN; |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 1464 | dump_block_fcp->hdr.pbt = DIAG308_IPL_TYPE_FCP; |
| 1465 | dump_block_fcp->ipl_info.fcp.opt = DIAG308_IPL_OPT_DUMP; |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 1466 | dump_capabilities |= DUMP_TYPE_FCP; |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 1467 | return 0; |
| 1468 | } |
| 1469 | |
Heiko Carstens | 2bc89b5 | 2008-02-05 16:50:40 +0100 | [diff] [blame] | 1470 | static int __init dump_init(void) |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 1471 | { |
| 1472 | int rc; |
| 1473 | |
Greg Kroah-Hartman | f62ed9e | 2007-11-05 13:16:15 -0800 | [diff] [blame] | 1474 | dump_kset = kset_create_and_add("dump", NULL, firmware_kobj); |
Greg Kroah-Hartman | d91885b | 2007-11-02 17:17:00 -0400 | [diff] [blame] | 1475 | if (!dump_kset) |
| 1476 | return -ENOMEM; |
Michael Holzheu | 99ca4e5 | 2008-01-26 14:11:11 +0100 | [diff] [blame] | 1477 | rc = sysfs_create_file(&dump_kset->kobj, &dump_type_attr.attr); |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 1478 | if (rc) { |
Greg Kroah-Hartman | d91885b | 2007-11-02 17:17:00 -0400 | [diff] [blame] | 1479 | kset_unregister(dump_kset); |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 1480 | return rc; |
| 1481 | } |
| 1482 | rc = dump_ccw_init(); |
| 1483 | if (rc) |
| 1484 | return rc; |
| 1485 | rc = dump_fcp_init(); |
| 1486 | if (rc) |
| 1487 | return rc; |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 1488 | dump_set_type(DUMP_TYPE_NONE); |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 1489 | return 0; |
| 1490 | } |
| 1491 | |
Heiko Carstens | 2bc89b5 | 2008-02-05 16:50:40 +0100 | [diff] [blame] | 1492 | static struct shutdown_action __refdata dump_action = { |
| 1493 | .name = SHUTDOWN_ACTION_DUMP_STR, |
| 1494 | .fn = dump_run, |
| 1495 | .init = dump_init, |
| 1496 | }; |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 1497 | |
Frank Munzert | 099b765 | 2009-03-26 15:23:43 +0100 | [diff] [blame] | 1498 | static void dump_reipl_run(struct shutdown_trigger *trigger) |
| 1499 | { |
| 1500 | preempt_disable(); |
| 1501 | /* |
| 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. |
| 1509 | */ |
| 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" |
Frank Munzert | 159d1ff | 2009-03-26 15:24:45 +0100 | [diff] [blame] | 1520 | :: "a" (csum_partial(reipl_block_actual, |
| 1521 | reipl_block_actual->hdr.len, 0)), |
Frank Munzert | 099b765 | 2009-03-26 15:23:43 +0100 | [diff] [blame] | 1522 | "a" (&lowcore_ptr[smp_processor_id()]->ipib_checksum)); |
| 1523 | preempt_enable(); |
| 1524 | dump_run(trigger); |
| 1525 | } |
| 1526 | |
| 1527 | static int __init dump_reipl_init(void) |
| 1528 | { |
| 1529 | if (!diag308_set_works) |
| 1530 | return -EOPNOTSUPP; |
| 1531 | else |
| 1532 | return 0; |
| 1533 | } |
| 1534 | |
| 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, |
| 1539 | }; |
| 1540 | |
Michael Holzheu | 99ca4e5 | 2008-01-26 14:11:11 +0100 | [diff] [blame] | 1541 | /* |
| 1542 | * vmcmd shutdown action: Trigger vm command on shutdown. |
| 1543 | */ |
| 1544 | |
| 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]; |
Michael Holzheu | 7dd6b33 | 2011-08-03 16:44:19 +0200 | [diff] [blame] | 1549 | static char vmcmd_on_restart[128]; |
Michael Holzheu | 99ca4e5 | 2008-01-26 14:11:11 +0100 | [diff] [blame] | 1550 | |
| 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); |
Michael Holzheu | 7dd6b33 | 2011-08-03 16:44:19 +0200 | [diff] [blame] | 1555 | DEFINE_IPL_ATTR_STR_RW(vmcmd, on_restart, "%s\n", "%s\n", vmcmd_on_restart); |
Michael Holzheu | 99ca4e5 | 2008-01-26 14:11:11 +0100 | [diff] [blame] | 1556 | |
| 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, |
Michael Holzheu | 7dd6b33 | 2011-08-03 16:44:19 +0200 | [diff] [blame] | 1562 | &sys_vmcmd_on_restart_attr.attr, |
Michael Holzheu | 99ca4e5 | 2008-01-26 14:11:11 +0100 | [diff] [blame] | 1563 | NULL, |
| 1564 | }; |
| 1565 | |
| 1566 | static struct attribute_group vmcmd_attr_group = { |
| 1567 | .attrs = vmcmd_attrs, |
| 1568 | }; |
| 1569 | |
| 1570 | static struct kset *vmcmd_kset; |
| 1571 | |
| 1572 | static void vmcmd_run(struct shutdown_trigger *trigger) |
| 1573 | { |
| 1574 | char *cmd, *next_cmd; |
| 1575 | |
| 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; |
Michael Holzheu | 7dd6b33 | 2011-08-03 16:44:19 +0200 | [diff] [blame] | 1584 | else if (strcmp(trigger->name, ON_RESTART_STR) == 0) |
| 1585 | cmd = vmcmd_on_restart; |
Michael Holzheu | 99ca4e5 | 2008-01-26 14:11:11 +0100 | [diff] [blame] | 1586 | else |
| 1587 | return; |
| 1588 | |
| 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; |
| 1596 | } |
| 1597 | __cpcmd(cmd, NULL, 0, NULL); |
| 1598 | cmd = next_cmd; |
| 1599 | } while (cmd != NULL); |
| 1600 | } |
| 1601 | |
| 1602 | static int vmcmd_init(void) |
| 1603 | { |
| 1604 | if (!MACHINE_IS_VM) |
Heiko Carstens | b8e660b | 2010-02-26 22:37:41 +0100 | [diff] [blame] | 1605 | return -EOPNOTSUPP; |
Michael Holzheu | 99ca4e5 | 2008-01-26 14:11:11 +0100 | [diff] [blame] | 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); |
| 1610 | } |
| 1611 | |
| 1612 | static struct shutdown_action vmcmd_action = {SHUTDOWN_ACTION_VMCMD_STR, |
| 1613 | vmcmd_run, vmcmd_init}; |
| 1614 | |
| 1615 | /* |
| 1616 | * stop shutdown action: Stop Linux on shutdown. |
| 1617 | */ |
| 1618 | |
| 1619 | static void stop_run(struct shutdown_trigger *trigger) |
| 1620 | { |
Michael Holzheu | c654749 | 2008-01-26 14:11:12 +0100 | [diff] [blame] | 1621 | if (strcmp(trigger->name, ON_PANIC_STR) == 0) |
| 1622 | disabled_wait((unsigned long) __builtin_return_address(0)); |
Heiko Carstens | a93b8ec | 2010-02-26 22:37:35 +0100 | [diff] [blame] | 1623 | while (sigp(smp_processor_id(), sigp_stop) == sigp_busy) |
Heiko Carstens | f8501ba | 2009-10-29 15:04:13 +0100 | [diff] [blame] | 1624 | cpu_relax(); |
| 1625 | for (;;); |
Michael Holzheu | 99ca4e5 | 2008-01-26 14:11:11 +0100 | [diff] [blame] | 1626 | } |
| 1627 | |
| 1628 | static struct shutdown_action stop_action = {SHUTDOWN_ACTION_STOP_STR, |
| 1629 | stop_run, NULL}; |
| 1630 | |
| 1631 | /* action list */ |
| 1632 | |
| 1633 | static struct shutdown_action *shutdown_actions_list[] = { |
Frank Munzert | 099b765 | 2009-03-26 15:23:43 +0100 | [diff] [blame] | 1634 | &ipl_action, &reipl_action, &dump_reipl_action, &dump_action, |
| 1635 | &vmcmd_action, &stop_action}; |
Michael Holzheu | 99ca4e5 | 2008-01-26 14:11:11 +0100 | [diff] [blame] | 1636 | #define SHUTDOWN_ACTIONS_COUNT (sizeof(shutdown_actions_list) / sizeof(void *)) |
| 1637 | |
| 1638 | /* |
| 1639 | * Trigger section |
| 1640 | */ |
| 1641 | |
| 1642 | static struct kset *shutdown_actions_kset; |
| 1643 | |
| 1644 | static int set_trigger(const char *buf, struct shutdown_trigger *trigger, |
| 1645 | size_t len) |
| 1646 | { |
| 1647 | int i; |
Frank Munzert | 099b765 | 2009-03-26 15:23:43 +0100 | [diff] [blame] | 1648 | |
Michael Holzheu | 99ca4e5 | 2008-01-26 14:11:11 +0100 | [diff] [blame] | 1649 | for (i = 0; i < SHUTDOWN_ACTIONS_COUNT; i++) { |
Frank Munzert | 099b765 | 2009-03-26 15:23:43 +0100 | [diff] [blame] | 1650 | if (sysfs_streq(buf, shutdown_actions_list[i]->name)) { |
Frank Munzert | 8108881 | 2009-07-07 16:37:07 +0200 | [diff] [blame] | 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; |
| 1656 | } |
Michael Holzheu | 99ca4e5 | 2008-01-26 14:11:11 +0100 | [diff] [blame] | 1657 | } |
| 1658 | } |
| 1659 | return -EINVAL; |
| 1660 | } |
| 1661 | |
| 1662 | /* on reipl */ |
| 1663 | |
| 1664 | static struct shutdown_trigger on_reboot_trigger = {ON_REIPL_STR, |
| 1665 | &reipl_action}; |
| 1666 | |
| 1667 | static ssize_t on_reboot_show(struct kobject *kobj, |
| 1668 | struct kobj_attribute *attr, char *page) |
| 1669 | { |
| 1670 | return sprintf(page, "%s\n", on_reboot_trigger.action->name); |
| 1671 | } |
| 1672 | |
| 1673 | static ssize_t on_reboot_store(struct kobject *kobj, |
| 1674 | struct kobj_attribute *attr, |
| 1675 | const char *buf, size_t len) |
| 1676 | { |
| 1677 | return set_trigger(buf, &on_reboot_trigger, len); |
| 1678 | } |
| 1679 | |
| 1680 | static struct kobj_attribute on_reboot_attr = |
| 1681 | __ATTR(on_reboot, 0644, on_reboot_show, on_reboot_store); |
| 1682 | |
| 1683 | static void do_machine_restart(char *__unused) |
| 1684 | { |
| 1685 | smp_send_stop(); |
| 1686 | on_reboot_trigger.action->fn(&on_reboot_trigger); |
| 1687 | reipl_run(NULL); |
| 1688 | } |
| 1689 | void (*_machine_restart)(char *command) = do_machine_restart; |
| 1690 | |
| 1691 | /* on panic */ |
| 1692 | |
| 1693 | static struct shutdown_trigger on_panic_trigger = {ON_PANIC_STR, &stop_action}; |
| 1694 | |
| 1695 | static ssize_t on_panic_show(struct kobject *kobj, |
| 1696 | struct kobj_attribute *attr, char *page) |
| 1697 | { |
| 1698 | return sprintf(page, "%s\n", on_panic_trigger.action->name); |
| 1699 | } |
| 1700 | |
| 1701 | static ssize_t on_panic_store(struct kobject *kobj, |
| 1702 | struct kobj_attribute *attr, |
| 1703 | const char *buf, size_t len) |
| 1704 | { |
| 1705 | return set_trigger(buf, &on_panic_trigger, len); |
| 1706 | } |
| 1707 | |
| 1708 | static struct kobj_attribute on_panic_attr = |
| 1709 | __ATTR(on_panic, 0644, on_panic_show, on_panic_store); |
| 1710 | |
| 1711 | static void do_panic(void) |
| 1712 | { |
| 1713 | on_panic_trigger.action->fn(&on_panic_trigger); |
| 1714 | stop_run(&on_panic_trigger); |
| 1715 | } |
| 1716 | |
Michael Holzheu | 7dd6b33 | 2011-08-03 16:44:19 +0200 | [diff] [blame] | 1717 | /* on restart */ |
| 1718 | |
| 1719 | static struct shutdown_trigger on_restart_trigger = {ON_RESTART_STR, |
| 1720 | &reipl_action}; |
| 1721 | |
| 1722 | static ssize_t on_restart_show(struct kobject *kobj, |
| 1723 | struct kobj_attribute *attr, char *page) |
| 1724 | { |
| 1725 | return sprintf(page, "%s\n", on_restart_trigger.action->name); |
| 1726 | } |
| 1727 | |
| 1728 | static ssize_t on_restart_store(struct kobject *kobj, |
| 1729 | struct kobj_attribute *attr, |
| 1730 | const char *buf, size_t len) |
| 1731 | { |
| 1732 | return set_trigger(buf, &on_restart_trigger, len); |
| 1733 | } |
| 1734 | |
| 1735 | static struct kobj_attribute on_restart_attr = |
| 1736 | __ATTR(on_restart, 0644, on_restart_show, on_restart_store); |
| 1737 | |
| 1738 | void do_restart(void) |
| 1739 | { |
| 1740 | smp_send_stop(); |
| 1741 | on_restart_trigger.action->fn(&on_restart_trigger); |
| 1742 | stop_run(&on_restart_trigger); |
| 1743 | } |
| 1744 | |
Michael Holzheu | 99ca4e5 | 2008-01-26 14:11:11 +0100 | [diff] [blame] | 1745 | /* on halt */ |
| 1746 | |
| 1747 | static struct shutdown_trigger on_halt_trigger = {ON_HALT_STR, &stop_action}; |
| 1748 | |
| 1749 | static ssize_t on_halt_show(struct kobject *kobj, |
| 1750 | struct kobj_attribute *attr, char *page) |
| 1751 | { |
| 1752 | return sprintf(page, "%s\n", on_halt_trigger.action->name); |
| 1753 | } |
| 1754 | |
| 1755 | static ssize_t on_halt_store(struct kobject *kobj, |
| 1756 | struct kobj_attribute *attr, |
| 1757 | const char *buf, size_t len) |
| 1758 | { |
| 1759 | return set_trigger(buf, &on_halt_trigger, len); |
| 1760 | } |
| 1761 | |
| 1762 | static struct kobj_attribute on_halt_attr = |
| 1763 | __ATTR(on_halt, 0644, on_halt_show, on_halt_store); |
| 1764 | |
| 1765 | |
| 1766 | static void do_machine_halt(void) |
| 1767 | { |
| 1768 | smp_send_stop(); |
| 1769 | on_halt_trigger.action->fn(&on_halt_trigger); |
| 1770 | stop_run(&on_halt_trigger); |
| 1771 | } |
| 1772 | void (*_machine_halt)(void) = do_machine_halt; |
| 1773 | |
| 1774 | /* on power off */ |
| 1775 | |
| 1776 | static struct shutdown_trigger on_poff_trigger = {ON_POFF_STR, &stop_action}; |
| 1777 | |
| 1778 | static ssize_t on_poff_show(struct kobject *kobj, |
| 1779 | struct kobj_attribute *attr, char *page) |
| 1780 | { |
| 1781 | return sprintf(page, "%s\n", on_poff_trigger.action->name); |
| 1782 | } |
| 1783 | |
| 1784 | static ssize_t on_poff_store(struct kobject *kobj, |
| 1785 | struct kobj_attribute *attr, |
| 1786 | const char *buf, size_t len) |
| 1787 | { |
| 1788 | return set_trigger(buf, &on_poff_trigger, len); |
| 1789 | } |
| 1790 | |
| 1791 | static struct kobj_attribute on_poff_attr = |
| 1792 | __ATTR(on_poff, 0644, on_poff_show, on_poff_store); |
| 1793 | |
| 1794 | |
| 1795 | static void do_machine_power_off(void) |
| 1796 | { |
| 1797 | smp_send_stop(); |
| 1798 | on_poff_trigger.action->fn(&on_poff_trigger); |
| 1799 | stop_run(&on_poff_trigger); |
| 1800 | } |
| 1801 | void (*_machine_power_off)(void) = do_machine_power_off; |
| 1802 | |
| 1803 | static void __init shutdown_triggers_init(void) |
| 1804 | { |
Greg Kroah-Hartman | d91885b | 2007-11-02 17:17:00 -0400 | [diff] [blame] | 1805 | shutdown_actions_kset = kset_create_and_add("shutdown_actions", NULL, |
Greg Kroah-Hartman | f62ed9e | 2007-11-05 13:16:15 -0800 | [diff] [blame] | 1806 | firmware_kobj); |
Greg Kroah-Hartman | d91885b | 2007-11-02 17:17:00 -0400 | [diff] [blame] | 1807 | if (!shutdown_actions_kset) |
Michael Holzheu | 99ca4e5 | 2008-01-26 14:11:11 +0100 | [diff] [blame] | 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; |
Michael Holzheu | 7dd6b33 | 2011-08-03 16:44:19 +0200 | [diff] [blame] | 1821 | if (sysfs_create_file(&shutdown_actions_kset->kobj, |
| 1822 | &on_restart_attr.attr)) |
| 1823 | goto fail; |
Michael Holzheu | 99ca4e5 | 2008-01-26 14:11:11 +0100 | [diff] [blame] | 1824 | return; |
| 1825 | fail: |
| 1826 | panic("shutdown_triggers_init failed\n"); |
| 1827 | } |
| 1828 | |
| 1829 | static void __init shutdown_actions_init(void) |
| 1830 | { |
| 1831 | int i; |
| 1832 | |
| 1833 | for (i = 0; i < SHUTDOWN_ACTIONS_COUNT; i++) { |
| 1834 | if (!shutdown_actions_list[i]->init) |
| 1835 | continue; |
Frank Munzert | 8108881 | 2009-07-07 16:37:07 +0200 | [diff] [blame] | 1836 | shutdown_actions_list[i]->init_rc = |
| 1837 | shutdown_actions_list[i]->init(); |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 1838 | } |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 1839 | } |
| 1840 | |
| 1841 | static int __init s390_ipl_init(void) |
| 1842 | { |
Michael Holzheu | d09293a | 2008-01-26 14:11:15 +0100 | [diff] [blame] | 1843 | sclp_get_ipl_info(&sclp_ipl_info); |
Michael Holzheu | 99ca4e5 | 2008-01-26 14:11:11 +0100 | [diff] [blame] | 1844 | shutdown_actions_init(); |
| 1845 | shutdown_triggers_init(); |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 1846 | return 0; |
| 1847 | } |
| 1848 | |
| 1849 | __initcall(s390_ipl_init); |
Heiko Carstens | 15e9b58 | 2006-12-04 15:40:26 +0100 | [diff] [blame] | 1850 | |
Michael Holzheu | 99ca4e5 | 2008-01-26 14:11:11 +0100 | [diff] [blame] | 1851 | static void __init strncpy_skip_quote(char *dst, char *src, int n) |
| 1852 | { |
| 1853 | int sx, dx; |
| 1854 | |
| 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; |
| 1862 | } |
| 1863 | } |
| 1864 | |
| 1865 | static int __init vmcmd_on_reboot_setup(char *str) |
| 1866 | { |
| 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; |
| 1873 | } |
| 1874 | __setup("vmreboot=", vmcmd_on_reboot_setup); |
| 1875 | |
| 1876 | static int __init vmcmd_on_panic_setup(char *str) |
| 1877 | { |
| 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; |
| 1884 | } |
| 1885 | __setup("vmpanic=", vmcmd_on_panic_setup); |
| 1886 | |
| 1887 | static int __init vmcmd_on_halt_setup(char *str) |
| 1888 | { |
| 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; |
| 1895 | } |
| 1896 | __setup("vmhalt=", vmcmd_on_halt_setup); |
| 1897 | |
| 1898 | static int __init vmcmd_on_poff_setup(char *str) |
| 1899 | { |
| 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; |
| 1906 | } |
| 1907 | __setup("vmpoff=", vmcmd_on_poff_setup); |
| 1908 | |
| 1909 | static int on_panic_notify(struct notifier_block *self, |
| 1910 | unsigned long event, void *data) |
| 1911 | { |
| 1912 | do_panic(); |
| 1913 | return NOTIFY_OK; |
| 1914 | } |
| 1915 | |
| 1916 | static struct notifier_block on_panic_nb = { |
| 1917 | .notifier_call = on_panic_notify, |
Michael Holzheu | 7e9b580 | 2009-03-26 15:24:55 +0100 | [diff] [blame] | 1918 | .priority = INT_MIN, |
Michael Holzheu | 99ca4e5 | 2008-01-26 14:11:11 +0100 | [diff] [blame] | 1919 | }; |
| 1920 | |
| 1921 | void __init setup_ipl(void) |
| 1922 | { |
| 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: |
Michael Holzheu | 99ca4e5 | 2008-01-26 14:11:11 +0100 | [diff] [blame] | 1942 | /* We have no info to copy */ |
| 1943 | break; |
| 1944 | } |
| 1945 | atomic_notifier_chain_register(&panic_notifier_list, &on_panic_nb); |
| 1946 | } |
| 1947 | |
Hendrik Brueckner | a0443fb | 2008-07-14 09:59:09 +0200 | [diff] [blame] | 1948 | void __init ipl_update_parameters(void) |
| 1949 | { |
Michael Holzheu | 3a95e8e | 2008-08-01 16:39:10 +0200 | [diff] [blame] | 1950 | int rc; |
| 1951 | |
| 1952 | rc = diag308(DIAG308_STORE, &ipl_block); |
| 1953 | if ((rc == DIAG308_RC_OK) || (rc == DIAG308_RC_NOCONFIG)) |
Hendrik Brueckner | a0443fb | 2008-07-14 09:59:09 +0200 | [diff] [blame] | 1954 | diag308_set_works = 1; |
| 1955 | } |
| 1956 | |
Heiko Carstens | 6fc321f | 2007-04-27 16:01:25 +0200 | [diff] [blame] | 1957 | void __init ipl_save_parameters(void) |
| 1958 | { |
| 1959 | struct cio_iplinfo iplinfo; |
Heiko Carstens | 6fc321f | 2007-04-27 16:01:25 +0200 | [diff] [blame] | 1960 | void *src, *dst; |
| 1961 | |
| 1962 | if (cio_get_iplinfo(&iplinfo)) |
| 1963 | return; |
| 1964 | |
| 1965 | ipl_devno = iplinfo.devno; |
| 1966 | ipl_flags |= IPL_DEVNO_VALID; |
| 1967 | if (!iplinfo.is_qdio) |
| 1968 | return; |
| 1969 | ipl_flags |= IPL_PARMBLOCK_VALID; |
Heiko Carstens | cbb870c | 2010-02-26 22:37:43 +0100 | [diff] [blame] | 1970 | src = (void *)(unsigned long)S390_lowcore.ipl_parmblock_ptr; |
Heiko Carstens | 6fc321f | 2007-04-27 16:01:25 +0200 | [diff] [blame] | 1971 | dst = (void *)IPL_PARMBLOCK_ORIGIN; |
| 1972 | memmove(dst, src, PAGE_SIZE); |
Heiko Carstens | cbb870c | 2010-02-26 22:37:43 +0100 | [diff] [blame] | 1973 | S390_lowcore.ipl_parmblock_ptr = IPL_PARMBLOCK_ORIGIN; |
Heiko Carstens | 6fc321f | 2007-04-27 16:01:25 +0200 | [diff] [blame] | 1974 | } |
| 1975 | |
Heiko Carstens | 15e9b58 | 2006-12-04 15:40:26 +0100 | [diff] [blame] | 1976 | static LIST_HEAD(rcall); |
| 1977 | static DEFINE_MUTEX(rcall_mutex); |
| 1978 | |
| 1979 | void register_reset_call(struct reset_call *reset) |
| 1980 | { |
| 1981 | mutex_lock(&rcall_mutex); |
| 1982 | list_add(&reset->list, &rcall); |
| 1983 | mutex_unlock(&rcall_mutex); |
| 1984 | } |
| 1985 | EXPORT_SYMBOL_GPL(register_reset_call); |
| 1986 | |
| 1987 | void unregister_reset_call(struct reset_call *reset) |
| 1988 | { |
| 1989 | mutex_lock(&rcall_mutex); |
| 1990 | list_del(&reset->list); |
| 1991 | mutex_unlock(&rcall_mutex); |
| 1992 | } |
| 1993 | EXPORT_SYMBOL_GPL(unregister_reset_call); |
| 1994 | |
| 1995 | static void do_reset_calls(void) |
| 1996 | { |
| 1997 | struct reset_call *reset; |
| 1998 | |
Michael Holzheu | 9dc7356 | 2011-08-03 16:44:22 +0200 | [diff] [blame] | 1999 | #ifdef CONFIG_64BIT |
| 2000 | if (diag308_set_works) { |
| 2001 | diag308_reset(); |
| 2002 | return; |
| 2003 | } |
| 2004 | #endif |
Heiko Carstens | 15e9b58 | 2006-12-04 15:40:26 +0100 | [diff] [blame] | 2005 | list_for_each_entry(reset, &rcall, list) |
| 2006 | reset->fn(); |
| 2007 | } |
| 2008 | |
Heiko Carstens | c5dd858 | 2007-03-05 23:35:43 +0100 | [diff] [blame] | 2009 | u32 dump_prefix_page; |
Heiko Carstens | 15e9b58 | 2006-12-04 15:40:26 +0100 | [diff] [blame] | 2010 | |
| 2011 | void s390_reset_system(void) |
| 2012 | { |
| 2013 | struct _lowcore *lc; |
| 2014 | |
Heiko Carstens | 15e9b58 | 2006-12-04 15:40:26 +0100 | [diff] [blame] | 2015 | lc = (struct _lowcore *)(unsigned long) store_prefix(); |
Michael Holzheu | a45e141 | 2006-12-15 17:18:22 +0100 | [diff] [blame] | 2016 | |
| 2017 | /* Stack for interrupt/machine check handler */ |
Heiko Carstens | 15e9b58 | 2006-12-04 15:40:26 +0100 | [diff] [blame] | 2018 | lc->panic_stack = S390_lowcore.panic_stack; |
| 2019 | |
Michael Holzheu | da1cf23 | 2006-12-15 17:18:27 +0100 | [diff] [blame] | 2020 | /* Save prefix page address for dump case */ |
Heiko Carstens | c5dd858 | 2007-03-05 23:35:43 +0100 | [diff] [blame] | 2021 | dump_prefix_page = (u32)(unsigned long) lc; |
Michael Holzheu | da1cf23 | 2006-12-15 17:18:27 +0100 | [diff] [blame] | 2022 | |
Heiko Carstens | 15e9b58 | 2006-12-04 15:40:26 +0100 | [diff] [blame] | 2023 | /* Disable prefixing */ |
| 2024 | set_prefix(0); |
| 2025 | |
| 2026 | /* Disable lowcore protection */ |
| 2027 | __ctl_clear_bit(0,28); |
| 2028 | |
| 2029 | /* Set new machine check handler */ |
Gerald Schaefer | c1821c2 | 2007-02-05 21:18:17 +0100 | [diff] [blame] | 2030 | S390_lowcore.mcck_new_psw.mask = psw_kernel_bits & ~PSW_MASK_MCHECK; |
Heiko Carstens | 15e9b58 | 2006-12-04 15:40:26 +0100 | [diff] [blame] | 2031 | S390_lowcore.mcck_new_psw.addr = |
Heiko Carstens | ab14de6 | 2007-02-05 21:18:37 +0100 | [diff] [blame] | 2032 | PSW_ADDR_AMODE | (unsigned long) s390_base_mcck_handler; |
Michael Holzheu | a45e141 | 2006-12-15 17:18:22 +0100 | [diff] [blame] | 2033 | |
| 2034 | /* Set new program check handler */ |
Gerald Schaefer | c1821c2 | 2007-02-05 21:18:17 +0100 | [diff] [blame] | 2035 | S390_lowcore.program_new_psw.mask = psw_kernel_bits & ~PSW_MASK_MCHECK; |
Michael Holzheu | a45e141 | 2006-12-15 17:18:22 +0100 | [diff] [blame] | 2036 | S390_lowcore.program_new_psw.addr = |
Heiko Carstens | ab14de6 | 2007-02-05 21:18:37 +0100 | [diff] [blame] | 2037 | PSW_ADDR_AMODE | (unsigned long) s390_base_pgm_handler; |
Michael Holzheu | a45e141 | 2006-12-15 17:18:22 +0100 | [diff] [blame] | 2038 | |
Heiko Carstens | 15e9b58 | 2006-12-04 15:40:26 +0100 | [diff] [blame] | 2039 | do_reset_calls(); |
| 2040 | } |
Michael Holzheu | 99ca4e5 | 2008-01-26 14:11:11 +0100 | [diff] [blame] | 2041 | |