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 | * |
| 5 | * Copyright (C) IBM Corp. 2005,2006 |
| 6 | * Author(s): Michael Holzheu <holzheu@de.ibm.com> |
| 7 | * Heiko Carstens <heiko.carstens@de.ibm.com> |
| 8 | * Volker Sameske <sameske@de.ibm.com> |
| 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> |
Michael Holzheu | 46b05d2 | 2007-02-21 10:55:21 +0100 | [diff] [blame] | 17 | #include <asm/ipl.h> |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 18 | #include <asm/smp.h> |
| 19 | #include <asm/setup.h> |
| 20 | #include <asm/cpcmd.h> |
| 21 | #include <asm/cio.h> |
Michael Holzheu | 03a4d20 | 2006-12-04 15:39:58 +0100 | [diff] [blame] | 22 | #include <asm/ebcdic.h> |
Heiko Carstens | 15e9b58 | 2006-12-04 15:40:26 +0100 | [diff] [blame] | 23 | #include <asm/reset.h> |
Heiko Carstens | ab14de6 | 2007-02-05 21:18:37 +0100 | [diff] [blame] | 24 | #include <asm/sclp.h> |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 25 | |
| 26 | #define IPL_PARM_BLOCK_VERSION 0 |
Michael Holzheu | 03a4d20 | 2006-12-04 15:39:58 +0100 | [diff] [blame] | 27 | |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 28 | #define IPL_UNKNOWN_STR "unknown" |
| 29 | #define IPL_CCW_STR "ccw" |
| 30 | #define IPL_FCP_STR "fcp" |
| 31 | #define IPL_FCP_DUMP_STR "fcp_dump" |
| 32 | #define IPL_NSS_STR "nss" |
Heiko Carstens | 615b04b | 2007-02-21 10:55:37 +0100 | [diff] [blame] | 33 | |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 34 | static char *ipl_type_str(enum ipl_type type) |
| 35 | { |
| 36 | switch (type) { |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 37 | case IPL_TYPE_CCW: |
| 38 | return IPL_CCW_STR; |
| 39 | case IPL_TYPE_FCP: |
| 40 | return IPL_FCP_STR; |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 41 | case IPL_TYPE_FCP_DUMP: |
| 42 | return IPL_FCP_DUMP_STR; |
Hongjie Yang | fe355b7 | 2007-02-05 21:18:24 +0100 | [diff] [blame] | 43 | case IPL_TYPE_NSS: |
| 44 | return IPL_NSS_STR; |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 45 | case IPL_TYPE_UNKNOWN: |
| 46 | default: |
| 47 | return IPL_UNKNOWN_STR; |
| 48 | } |
| 49 | } |
| 50 | |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 51 | enum dump_type { |
| 52 | DUMP_TYPE_NONE = 1, |
| 53 | DUMP_TYPE_CCW = 2, |
| 54 | DUMP_TYPE_FCP = 4, |
| 55 | }; |
| 56 | |
| 57 | #define DUMP_NONE_STR "none" |
| 58 | #define DUMP_CCW_STR "ccw" |
| 59 | #define DUMP_FCP_STR "fcp" |
| 60 | |
| 61 | static char *dump_type_str(enum dump_type type) |
| 62 | { |
| 63 | switch (type) { |
| 64 | case DUMP_TYPE_NONE: |
| 65 | return DUMP_NONE_STR; |
| 66 | case DUMP_TYPE_CCW: |
| 67 | return DUMP_CCW_STR; |
| 68 | case DUMP_TYPE_FCP: |
| 69 | return DUMP_FCP_STR; |
| 70 | default: |
| 71 | return NULL; |
| 72 | } |
| 73 | } |
| 74 | |
| 75 | /* |
| 76 | * Must be in data section since the bss section |
| 77 | * is not cleared when these are accessed. |
| 78 | */ |
| 79 | static u16 ipl_devno __attribute__((__section__(".data"))) = 0; |
| 80 | u32 ipl_flags __attribute__((__section__(".data"))) = 0; |
| 81 | |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 82 | enum ipl_method { |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 83 | REIPL_METHOD_CCW_CIO, |
| 84 | REIPL_METHOD_CCW_DIAG, |
| 85 | REIPL_METHOD_CCW_VM, |
| 86 | REIPL_METHOD_FCP_RO_DIAG, |
| 87 | REIPL_METHOD_FCP_RW_DIAG, |
| 88 | REIPL_METHOD_FCP_RO_VM, |
| 89 | REIPL_METHOD_FCP_DUMP, |
| 90 | REIPL_METHOD_NSS, |
| 91 | REIPL_METHOD_DEFAULT, |
| 92 | }; |
| 93 | |
| 94 | enum dump_method { |
| 95 | DUMP_METHOD_NONE, |
| 96 | DUMP_METHOD_CCW_CIO, |
| 97 | DUMP_METHOD_CCW_DIAG, |
| 98 | DUMP_METHOD_CCW_VM, |
| 99 | DUMP_METHOD_FCP_DIAG, |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 100 | }; |
| 101 | |
| 102 | enum shutdown_action { |
| 103 | SHUTDOWN_REIPL, |
| 104 | SHUTDOWN_DUMP, |
| 105 | SHUTDOWN_STOP, |
| 106 | }; |
| 107 | |
| 108 | #define SHUTDOWN_REIPL_STR "reipl" |
| 109 | #define SHUTDOWN_DUMP_STR "dump" |
| 110 | #define SHUTDOWN_STOP_STR "stop" |
| 111 | |
| 112 | static char *shutdown_action_str(enum shutdown_action action) |
| 113 | { |
| 114 | switch (action) { |
| 115 | case SHUTDOWN_REIPL: |
| 116 | return SHUTDOWN_REIPL_STR; |
| 117 | case SHUTDOWN_DUMP: |
| 118 | return SHUTDOWN_DUMP_STR; |
| 119 | case SHUTDOWN_STOP: |
| 120 | return SHUTDOWN_STOP_STR; |
| 121 | default: |
Michael Holzheu | 2b93293 | 2007-02-21 10:55:24 +0100 | [diff] [blame] | 122 | return NULL; |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 123 | } |
| 124 | } |
| 125 | |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 126 | static int diag308_set_works = 0; |
| 127 | |
| 128 | static int reipl_capabilities = IPL_TYPE_UNKNOWN; |
Hongjie Yang | fe355b7 | 2007-02-05 21:18:24 +0100 | [diff] [blame] | 129 | |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 130 | static enum ipl_type reipl_type = IPL_TYPE_UNKNOWN; |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 131 | static enum ipl_method reipl_method = REIPL_METHOD_DEFAULT; |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 132 | static struct ipl_parameter_block *reipl_block_fcp; |
| 133 | static struct ipl_parameter_block *reipl_block_ccw; |
| 134 | |
Hongjie Yang | fe355b7 | 2007-02-05 21:18:24 +0100 | [diff] [blame] | 135 | static char reipl_nss_name[NSS_NAME_SIZE + 1]; |
| 136 | |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 137 | static int dump_capabilities = DUMP_TYPE_NONE; |
| 138 | static enum dump_type dump_type = DUMP_TYPE_NONE; |
| 139 | static enum dump_method dump_method = DUMP_METHOD_NONE; |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 140 | static struct ipl_parameter_block *dump_block_fcp; |
| 141 | static struct ipl_parameter_block *dump_block_ccw; |
| 142 | |
| 143 | static enum shutdown_action on_panic_action = SHUTDOWN_STOP; |
| 144 | |
Heiko Carstens | 05dd253 | 2007-07-10 11:24:09 +0200 | [diff] [blame^] | 145 | static struct sclp_ipl_info sclp_ipl_info; |
| 146 | |
Michael Holzheu | 46b05d2 | 2007-02-21 10:55:21 +0100 | [diff] [blame] | 147 | int diag308(unsigned long subcode, void *addr) |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 148 | { |
Martin Schwidefsky | 94c12cc | 2006-09-28 16:56:43 +0200 | [diff] [blame] | 149 | register unsigned long _addr asm("0") = (unsigned long) addr; |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 150 | register unsigned long _rc asm("1") = 0; |
| 151 | |
Martin Schwidefsky | 94c12cc | 2006-09-28 16:56:43 +0200 | [diff] [blame] | 152 | asm volatile( |
| 153 | " diag %0,%2,0x308\n" |
| 154 | "0:\n" |
| 155 | EX_TABLE(0b,0b) |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 156 | : "+d" (_addr), "+d" (_rc) |
Martin Schwidefsky | 94c12cc | 2006-09-28 16:56:43 +0200 | [diff] [blame] | 157 | : "d" (subcode) : "cc", "memory"); |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 158 | return _rc; |
| 159 | } |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 160 | EXPORT_SYMBOL_GPL(diag308); |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 161 | |
| 162 | /* SYSFS */ |
| 163 | |
| 164 | #define DEFINE_IPL_ATTR_RO(_prefix, _name, _format, _value) \ |
Greg Kroah-Hartman | 823bccf | 2007-04-13 13:15:19 -0700 | [diff] [blame] | 165 | static ssize_t sys_##_prefix##_##_name##_show(struct kset *kset, \ |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 166 | char *page) \ |
| 167 | { \ |
| 168 | return sprintf(page, _format, _value); \ |
| 169 | } \ |
| 170 | static struct subsys_attribute sys_##_prefix##_##_name##_attr = \ |
| 171 | __ATTR(_name, S_IRUGO, sys_##_prefix##_##_name##_show, NULL); |
| 172 | |
| 173 | #define DEFINE_IPL_ATTR_RW(_prefix, _name, _fmt_out, _fmt_in, _value) \ |
Greg Kroah-Hartman | 823bccf | 2007-04-13 13:15:19 -0700 | [diff] [blame] | 174 | static ssize_t sys_##_prefix##_##_name##_show(struct kset *kset, \ |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 175 | char *page) \ |
| 176 | { \ |
| 177 | return sprintf(page, _fmt_out, \ |
| 178 | (unsigned long long) _value); \ |
| 179 | } \ |
Greg Kroah-Hartman | 823bccf | 2007-04-13 13:15:19 -0700 | [diff] [blame] | 180 | static ssize_t sys_##_prefix##_##_name##_store(struct kset *kset, \ |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 181 | const char *buf, size_t len) \ |
| 182 | { \ |
| 183 | unsigned long long value; \ |
| 184 | if (sscanf(buf, _fmt_in, &value) != 1) \ |
| 185 | return -EINVAL; \ |
| 186 | _value = value; \ |
| 187 | return len; \ |
| 188 | } \ |
| 189 | static struct subsys_attribute sys_##_prefix##_##_name##_attr = \ |
| 190 | __ATTR(_name,(S_IRUGO | S_IWUSR), \ |
| 191 | sys_##_prefix##_##_name##_show, \ |
| 192 | sys_##_prefix##_##_name##_store); |
| 193 | |
Hongjie Yang | fe355b7 | 2007-02-05 21:18:24 +0100 | [diff] [blame] | 194 | #define DEFINE_IPL_ATTR_STR_RW(_prefix, _name, _fmt_out, _fmt_in, _value)\ |
Greg Kroah-Hartman | 823bccf | 2007-04-13 13:15:19 -0700 | [diff] [blame] | 195 | static ssize_t sys_##_prefix##_##_name##_show(struct kset *kset, \ |
Hongjie Yang | fe355b7 | 2007-02-05 21:18:24 +0100 | [diff] [blame] | 196 | char *page) \ |
| 197 | { \ |
| 198 | return sprintf(page, _fmt_out, _value); \ |
| 199 | } \ |
Greg Kroah-Hartman | 823bccf | 2007-04-13 13:15:19 -0700 | [diff] [blame] | 200 | static ssize_t sys_##_prefix##_##_name##_store(struct kset *kset, \ |
Hongjie Yang | fe355b7 | 2007-02-05 21:18:24 +0100 | [diff] [blame] | 201 | const char *buf, size_t len) \ |
| 202 | { \ |
| 203 | if (sscanf(buf, _fmt_in, _value) != 1) \ |
| 204 | return -EINVAL; \ |
| 205 | return len; \ |
| 206 | } \ |
| 207 | static struct subsys_attribute sys_##_prefix##_##_name##_attr = \ |
| 208 | __ATTR(_name,(S_IRUGO | S_IWUSR), \ |
| 209 | sys_##_prefix##_##_name##_show, \ |
| 210 | sys_##_prefix##_##_name##_store); |
| 211 | |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 212 | static void make_attrs_ro(struct attribute **attrs) |
| 213 | { |
| 214 | while (*attrs) { |
| 215 | (*attrs)->mode = S_IRUGO; |
| 216 | attrs++; |
| 217 | } |
| 218 | } |
| 219 | |
| 220 | /* |
| 221 | * ipl section |
| 222 | */ |
| 223 | |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 224 | static __init enum ipl_type get_ipl_type(void) |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 225 | { |
| 226 | struct ipl_parameter_block *ipl = IPL_PARMBLOCK_START; |
| 227 | |
Hongjie Yang | fe355b7 | 2007-02-05 21:18:24 +0100 | [diff] [blame] | 228 | if (ipl_flags & IPL_NSS_VALID) |
| 229 | return IPL_TYPE_NSS; |
Heiko Carstens | e87bfe5 | 2006-09-20 15:59:15 +0200 | [diff] [blame] | 230 | if (!(ipl_flags & IPL_DEVNO_VALID)) |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 231 | return IPL_TYPE_UNKNOWN; |
Heiko Carstens | e87bfe5 | 2006-09-20 15:59:15 +0200 | [diff] [blame] | 232 | if (!(ipl_flags & IPL_PARMBLOCK_VALID)) |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 233 | return IPL_TYPE_CCW; |
| 234 | if (ipl->hdr.version > IPL_MAX_SUPPORTED_VERSION) |
| 235 | return IPL_TYPE_UNKNOWN; |
| 236 | if (ipl->hdr.pbt != DIAG308_IPL_TYPE_FCP) |
| 237 | return IPL_TYPE_UNKNOWN; |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 238 | if (ipl->ipl_info.fcp.opt == DIAG308_IPL_OPT_DUMP) |
| 239 | return IPL_TYPE_FCP_DUMP; |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 240 | return IPL_TYPE_FCP; |
| 241 | } |
| 242 | |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 243 | void __init setup_ipl_info(void) |
| 244 | { |
| 245 | ipl_info.type = get_ipl_type(); |
| 246 | switch (ipl_info.type) { |
| 247 | case IPL_TYPE_CCW: |
| 248 | ipl_info.data.ccw.dev_id.devno = ipl_devno; |
| 249 | ipl_info.data.ccw.dev_id.ssid = 0; |
| 250 | break; |
| 251 | case IPL_TYPE_FCP: |
| 252 | case IPL_TYPE_FCP_DUMP: |
| 253 | ipl_info.data.fcp.dev_id.devno = |
| 254 | IPL_PARMBLOCK_START->ipl_info.fcp.devno; |
| 255 | ipl_info.data.fcp.dev_id.ssid = 0; |
| 256 | ipl_info.data.fcp.wwpn = IPL_PARMBLOCK_START->ipl_info.fcp.wwpn; |
| 257 | ipl_info.data.fcp.lun = IPL_PARMBLOCK_START->ipl_info.fcp.lun; |
| 258 | break; |
| 259 | case IPL_TYPE_NSS: |
| 260 | strncpy(ipl_info.data.nss.name, kernel_nss_name, |
| 261 | sizeof(ipl_info.data.nss.name)); |
| 262 | break; |
| 263 | case IPL_TYPE_UNKNOWN: |
| 264 | default: |
| 265 | /* We have no info to copy */ |
| 266 | break; |
| 267 | } |
| 268 | } |
| 269 | |
| 270 | struct ipl_info ipl_info; |
| 271 | EXPORT_SYMBOL_GPL(ipl_info); |
| 272 | |
Greg Kroah-Hartman | 823bccf | 2007-04-13 13:15:19 -0700 | [diff] [blame] | 273 | static ssize_t ipl_type_show(struct kset *kset, char *page) |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 274 | { |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 275 | return sprintf(page, "%s\n", ipl_type_str(ipl_info.type)); |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 276 | } |
| 277 | |
| 278 | static struct subsys_attribute sys_ipl_type_attr = __ATTR_RO(ipl_type); |
| 279 | |
Greg Kroah-Hartman | 823bccf | 2007-04-13 13:15:19 -0700 | [diff] [blame] | 280 | static ssize_t sys_ipl_device_show(struct kset *kset, char *page) |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 281 | { |
| 282 | struct ipl_parameter_block *ipl = IPL_PARMBLOCK_START; |
| 283 | |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 284 | switch (ipl_info.type) { |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 285 | case IPL_TYPE_CCW: |
| 286 | return sprintf(page, "0.0.%04x\n", ipl_devno); |
| 287 | case IPL_TYPE_FCP: |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 288 | case IPL_TYPE_FCP_DUMP: |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 289 | return sprintf(page, "0.0.%04x\n", ipl->ipl_info.fcp.devno); |
| 290 | default: |
| 291 | return 0; |
| 292 | } |
| 293 | } |
| 294 | |
| 295 | static struct subsys_attribute sys_ipl_device_attr = |
| 296 | __ATTR(device, S_IRUGO, sys_ipl_device_show, NULL); |
| 297 | |
| 298 | static ssize_t ipl_parameter_read(struct kobject *kobj, char *buf, loff_t off, |
| 299 | size_t count) |
| 300 | { |
| 301 | unsigned int size = IPL_PARMBLOCK_SIZE; |
| 302 | |
| 303 | if (off > size) |
| 304 | return 0; |
| 305 | if (off + count > size) |
| 306 | count = size - off; |
| 307 | memcpy(buf, (void *)IPL_PARMBLOCK_START + off, count); |
| 308 | return count; |
| 309 | } |
| 310 | |
| 311 | static struct bin_attribute ipl_parameter_attr = { |
| 312 | .attr = { |
| 313 | .name = "binary_parameter", |
| 314 | .mode = S_IRUGO, |
| 315 | .owner = THIS_MODULE, |
| 316 | }, |
| 317 | .size = PAGE_SIZE, |
| 318 | .read = &ipl_parameter_read, |
| 319 | }; |
| 320 | |
| 321 | static ssize_t ipl_scp_data_read(struct kobject *kobj, char *buf, loff_t off, |
| 322 | size_t count) |
| 323 | { |
| 324 | unsigned int size = IPL_PARMBLOCK_START->ipl_info.fcp.scp_data_len; |
| 325 | void *scp_data = &IPL_PARMBLOCK_START->ipl_info.fcp.scp_data; |
| 326 | |
| 327 | if (off > size) |
| 328 | return 0; |
| 329 | if (off + count > size) |
| 330 | count = size - off; |
| 331 | memcpy(buf, scp_data + off, count); |
| 332 | return count; |
| 333 | } |
| 334 | |
| 335 | static struct bin_attribute ipl_scp_data_attr = { |
| 336 | .attr = { |
| 337 | .name = "scp_data", |
| 338 | .mode = S_IRUGO, |
| 339 | .owner = THIS_MODULE, |
| 340 | }, |
| 341 | .size = PAGE_SIZE, |
| 342 | .read = &ipl_scp_data_read, |
| 343 | }; |
| 344 | |
| 345 | /* FCP ipl device attributes */ |
| 346 | |
| 347 | DEFINE_IPL_ATTR_RO(ipl_fcp, wwpn, "0x%016llx\n", (unsigned long long) |
| 348 | IPL_PARMBLOCK_START->ipl_info.fcp.wwpn); |
| 349 | DEFINE_IPL_ATTR_RO(ipl_fcp, lun, "0x%016llx\n", (unsigned long long) |
| 350 | IPL_PARMBLOCK_START->ipl_info.fcp.lun); |
| 351 | DEFINE_IPL_ATTR_RO(ipl_fcp, bootprog, "%lld\n", (unsigned long long) |
| 352 | IPL_PARMBLOCK_START->ipl_info.fcp.bootprog); |
| 353 | DEFINE_IPL_ATTR_RO(ipl_fcp, br_lba, "%lld\n", (unsigned long long) |
| 354 | IPL_PARMBLOCK_START->ipl_info.fcp.br_lba); |
| 355 | |
| 356 | static struct attribute *ipl_fcp_attrs[] = { |
| 357 | &sys_ipl_type_attr.attr, |
| 358 | &sys_ipl_device_attr.attr, |
| 359 | &sys_ipl_fcp_wwpn_attr.attr, |
| 360 | &sys_ipl_fcp_lun_attr.attr, |
| 361 | &sys_ipl_fcp_bootprog_attr.attr, |
| 362 | &sys_ipl_fcp_br_lba_attr.attr, |
| 363 | NULL, |
| 364 | }; |
| 365 | |
| 366 | static struct attribute_group ipl_fcp_attr_group = { |
| 367 | .attrs = ipl_fcp_attrs, |
| 368 | }; |
| 369 | |
| 370 | /* CCW ipl device attributes */ |
| 371 | |
Greg Kroah-Hartman | 823bccf | 2007-04-13 13:15:19 -0700 | [diff] [blame] | 372 | static ssize_t ipl_ccw_loadparm_show(struct kset *kset, char *page) |
Michael Holzheu | 03a4d20 | 2006-12-04 15:39:58 +0100 | [diff] [blame] | 373 | { |
| 374 | char loadparm[LOADPARM_LEN + 1] = {}; |
| 375 | |
Heiko Carstens | 05dd253 | 2007-07-10 11:24:09 +0200 | [diff] [blame^] | 376 | if (!sclp_ipl_info.is_valid) |
Michael Holzheu | 03a4d20 | 2006-12-04 15:39:58 +0100 | [diff] [blame] | 377 | return sprintf(page, "#unknown#\n"); |
Heiko Carstens | 05dd253 | 2007-07-10 11:24:09 +0200 | [diff] [blame^] | 378 | memcpy(loadparm, &sclp_ipl_info.loadparm, LOADPARM_LEN); |
Michael Holzheu | 03a4d20 | 2006-12-04 15:39:58 +0100 | [diff] [blame] | 379 | EBCASC(loadparm, LOADPARM_LEN); |
| 380 | strstrip(loadparm); |
| 381 | return sprintf(page, "%s\n", loadparm); |
| 382 | } |
| 383 | |
| 384 | static struct subsys_attribute sys_ipl_ccw_loadparm_attr = |
| 385 | __ATTR(loadparm, 0444, ipl_ccw_loadparm_show, NULL); |
| 386 | |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 387 | static struct attribute *ipl_ccw_attrs[] = { |
| 388 | &sys_ipl_type_attr.attr, |
| 389 | &sys_ipl_device_attr.attr, |
Michael Holzheu | 03a4d20 | 2006-12-04 15:39:58 +0100 | [diff] [blame] | 390 | &sys_ipl_ccw_loadparm_attr.attr, |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 391 | NULL, |
| 392 | }; |
| 393 | |
| 394 | static struct attribute_group ipl_ccw_attr_group = { |
| 395 | .attrs = ipl_ccw_attrs, |
| 396 | }; |
| 397 | |
Hongjie Yang | fe355b7 | 2007-02-05 21:18:24 +0100 | [diff] [blame] | 398 | /* NSS ipl device attributes */ |
| 399 | |
| 400 | DEFINE_IPL_ATTR_RO(ipl_nss, name, "%s\n", kernel_nss_name); |
| 401 | |
| 402 | static struct attribute *ipl_nss_attrs[] = { |
| 403 | &sys_ipl_type_attr.attr, |
| 404 | &sys_ipl_nss_name_attr.attr, |
| 405 | NULL, |
| 406 | }; |
| 407 | |
| 408 | static struct attribute_group ipl_nss_attr_group = { |
| 409 | .attrs = ipl_nss_attrs, |
| 410 | }; |
| 411 | |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 412 | /* UNKNOWN ipl device attributes */ |
| 413 | |
| 414 | static struct attribute *ipl_unknown_attrs[] = { |
| 415 | &sys_ipl_type_attr.attr, |
| 416 | NULL, |
| 417 | }; |
| 418 | |
| 419 | static struct attribute_group ipl_unknown_attr_group = { |
| 420 | .attrs = ipl_unknown_attrs, |
| 421 | }; |
| 422 | |
| 423 | static decl_subsys(ipl, NULL, NULL); |
| 424 | |
| 425 | /* |
| 426 | * reipl section |
| 427 | */ |
| 428 | |
| 429 | /* FCP reipl device attributes */ |
| 430 | |
| 431 | DEFINE_IPL_ATTR_RW(reipl_fcp, wwpn, "0x%016llx\n", "%016llx\n", |
| 432 | reipl_block_fcp->ipl_info.fcp.wwpn); |
| 433 | DEFINE_IPL_ATTR_RW(reipl_fcp, lun, "0x%016llx\n", "%016llx\n", |
| 434 | reipl_block_fcp->ipl_info.fcp.lun); |
| 435 | DEFINE_IPL_ATTR_RW(reipl_fcp, bootprog, "%lld\n", "%lld\n", |
| 436 | reipl_block_fcp->ipl_info.fcp.bootprog); |
| 437 | DEFINE_IPL_ATTR_RW(reipl_fcp, br_lba, "%lld\n", "%lld\n", |
| 438 | reipl_block_fcp->ipl_info.fcp.br_lba); |
| 439 | DEFINE_IPL_ATTR_RW(reipl_fcp, device, "0.0.%04llx\n", "0.0.%llx\n", |
| 440 | reipl_block_fcp->ipl_info.fcp.devno); |
| 441 | |
| 442 | static struct attribute *reipl_fcp_attrs[] = { |
| 443 | &sys_reipl_fcp_device_attr.attr, |
| 444 | &sys_reipl_fcp_wwpn_attr.attr, |
| 445 | &sys_reipl_fcp_lun_attr.attr, |
| 446 | &sys_reipl_fcp_bootprog_attr.attr, |
| 447 | &sys_reipl_fcp_br_lba_attr.attr, |
| 448 | NULL, |
| 449 | }; |
| 450 | |
| 451 | static struct attribute_group reipl_fcp_attr_group = { |
| 452 | .name = IPL_FCP_STR, |
| 453 | .attrs = reipl_fcp_attrs, |
| 454 | }; |
| 455 | |
| 456 | /* CCW reipl device attributes */ |
| 457 | |
| 458 | DEFINE_IPL_ATTR_RW(reipl_ccw, device, "0.0.%04llx\n", "0.0.%llx\n", |
| 459 | reipl_block_ccw->ipl_info.ccw.devno); |
| 460 | |
Michael Holzheu | 03a4d20 | 2006-12-04 15:39:58 +0100 | [diff] [blame] | 461 | static void reipl_get_ascii_loadparm(char *loadparm) |
| 462 | { |
| 463 | memcpy(loadparm, &reipl_block_ccw->ipl_info.ccw.load_param, |
| 464 | LOADPARM_LEN); |
| 465 | EBCASC(loadparm, LOADPARM_LEN); |
| 466 | loadparm[LOADPARM_LEN] = 0; |
| 467 | strstrip(loadparm); |
| 468 | } |
| 469 | |
Greg Kroah-Hartman | 823bccf | 2007-04-13 13:15:19 -0700 | [diff] [blame] | 470 | static ssize_t reipl_ccw_loadparm_show(struct kset *kset, char *page) |
Michael Holzheu | 03a4d20 | 2006-12-04 15:39:58 +0100 | [diff] [blame] | 471 | { |
| 472 | char buf[LOADPARM_LEN + 1]; |
| 473 | |
| 474 | reipl_get_ascii_loadparm(buf); |
| 475 | return sprintf(page, "%s\n", buf); |
| 476 | } |
| 477 | |
Greg Kroah-Hartman | 823bccf | 2007-04-13 13:15:19 -0700 | [diff] [blame] | 478 | static ssize_t reipl_ccw_loadparm_store(struct kset *kset, |
Michael Holzheu | 03a4d20 | 2006-12-04 15:39:58 +0100 | [diff] [blame] | 479 | const char *buf, size_t len) |
| 480 | { |
| 481 | int i, lp_len; |
| 482 | |
| 483 | /* ignore trailing newline */ |
| 484 | lp_len = len; |
| 485 | if ((len > 0) && (buf[len - 1] == '\n')) |
| 486 | lp_len--; |
| 487 | /* loadparm can have max 8 characters and must not start with a blank */ |
| 488 | if ((lp_len > LOADPARM_LEN) || ((lp_len > 0) && (buf[0] == ' '))) |
| 489 | return -EINVAL; |
| 490 | /* loadparm can only contain "a-z,A-Z,0-9,SP,." */ |
| 491 | for (i = 0; i < lp_len; i++) { |
| 492 | if (isalpha(buf[i]) || isdigit(buf[i]) || (buf[i] == ' ') || |
| 493 | (buf[i] == '.')) |
| 494 | continue; |
| 495 | return -EINVAL; |
| 496 | } |
| 497 | /* initialize loadparm with blanks */ |
| 498 | memset(&reipl_block_ccw->ipl_info.ccw.load_param, ' ', LOADPARM_LEN); |
| 499 | /* copy and convert to ebcdic */ |
| 500 | memcpy(&reipl_block_ccw->ipl_info.ccw.load_param, buf, lp_len); |
| 501 | ASCEBC(reipl_block_ccw->ipl_info.ccw.load_param, LOADPARM_LEN); |
| 502 | return len; |
| 503 | } |
| 504 | |
| 505 | static struct subsys_attribute sys_reipl_ccw_loadparm_attr = |
| 506 | __ATTR(loadparm, 0644, reipl_ccw_loadparm_show, |
| 507 | reipl_ccw_loadparm_store); |
| 508 | |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 509 | static struct attribute *reipl_ccw_attrs[] = { |
| 510 | &sys_reipl_ccw_device_attr.attr, |
Michael Holzheu | 03a4d20 | 2006-12-04 15:39:58 +0100 | [diff] [blame] | 511 | &sys_reipl_ccw_loadparm_attr.attr, |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 512 | NULL, |
| 513 | }; |
| 514 | |
| 515 | static struct attribute_group reipl_ccw_attr_group = { |
| 516 | .name = IPL_CCW_STR, |
| 517 | .attrs = reipl_ccw_attrs, |
| 518 | }; |
| 519 | |
Hongjie Yang | fe355b7 | 2007-02-05 21:18:24 +0100 | [diff] [blame] | 520 | |
| 521 | /* NSS reipl device attributes */ |
| 522 | |
| 523 | DEFINE_IPL_ATTR_STR_RW(reipl_nss, name, "%s\n", "%s\n", reipl_nss_name); |
| 524 | |
| 525 | static struct attribute *reipl_nss_attrs[] = { |
| 526 | &sys_reipl_nss_name_attr.attr, |
| 527 | NULL, |
| 528 | }; |
| 529 | |
| 530 | static struct attribute_group reipl_nss_attr_group = { |
| 531 | .name = IPL_NSS_STR, |
| 532 | .attrs = reipl_nss_attrs, |
| 533 | }; |
| 534 | |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 535 | /* reipl type */ |
| 536 | |
| 537 | static int reipl_set_type(enum ipl_type type) |
| 538 | { |
| 539 | if (!(reipl_capabilities & type)) |
| 540 | return -EINVAL; |
| 541 | |
| 542 | switch(type) { |
| 543 | case IPL_TYPE_CCW: |
| 544 | if (MACHINE_IS_VM) |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 545 | reipl_method = REIPL_METHOD_CCW_VM; |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 546 | else |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 547 | reipl_method = REIPL_METHOD_CCW_CIO; |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 548 | break; |
| 549 | case IPL_TYPE_FCP: |
| 550 | if (diag308_set_works) |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 551 | reipl_method = REIPL_METHOD_FCP_RW_DIAG; |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 552 | else if (MACHINE_IS_VM) |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 553 | reipl_method = REIPL_METHOD_FCP_RO_VM; |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 554 | else |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 555 | reipl_method = REIPL_METHOD_FCP_RO_DIAG; |
| 556 | break; |
| 557 | case IPL_TYPE_FCP_DUMP: |
| 558 | reipl_method = REIPL_METHOD_FCP_DUMP; |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 559 | break; |
Hongjie Yang | fe355b7 | 2007-02-05 21:18:24 +0100 | [diff] [blame] | 560 | case IPL_TYPE_NSS: |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 561 | reipl_method = REIPL_METHOD_NSS; |
| 562 | break; |
| 563 | case IPL_TYPE_UNKNOWN: |
| 564 | reipl_method = REIPL_METHOD_DEFAULT; |
Hongjie Yang | fe355b7 | 2007-02-05 21:18:24 +0100 | [diff] [blame] | 565 | break; |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 566 | default: |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 567 | BUG(); |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 568 | } |
| 569 | reipl_type = type; |
| 570 | return 0; |
| 571 | } |
| 572 | |
Greg Kroah-Hartman | 823bccf | 2007-04-13 13:15:19 -0700 | [diff] [blame] | 573 | static ssize_t reipl_type_show(struct kset *kset, char *page) |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 574 | { |
| 575 | return sprintf(page, "%s\n", ipl_type_str(reipl_type)); |
| 576 | } |
| 577 | |
Greg Kroah-Hartman | 823bccf | 2007-04-13 13:15:19 -0700 | [diff] [blame] | 578 | static ssize_t reipl_type_store(struct kset *kset, const char *buf, |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 579 | size_t len) |
| 580 | { |
| 581 | int rc = -EINVAL; |
| 582 | |
| 583 | if (strncmp(buf, IPL_CCW_STR, strlen(IPL_CCW_STR)) == 0) |
| 584 | rc = reipl_set_type(IPL_TYPE_CCW); |
| 585 | else if (strncmp(buf, IPL_FCP_STR, strlen(IPL_FCP_STR)) == 0) |
| 586 | rc = reipl_set_type(IPL_TYPE_FCP); |
Hongjie Yang | fe355b7 | 2007-02-05 21:18:24 +0100 | [diff] [blame] | 587 | else if (strncmp(buf, IPL_NSS_STR, strlen(IPL_NSS_STR)) == 0) |
| 588 | rc = reipl_set_type(IPL_TYPE_NSS); |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 589 | return (rc != 0) ? rc : len; |
| 590 | } |
| 591 | |
| 592 | static struct subsys_attribute reipl_type_attr = |
| 593 | __ATTR(reipl_type, 0644, reipl_type_show, reipl_type_store); |
| 594 | |
| 595 | static decl_subsys(reipl, NULL, NULL); |
| 596 | |
| 597 | /* |
| 598 | * dump section |
| 599 | */ |
| 600 | |
| 601 | /* FCP dump device attributes */ |
| 602 | |
| 603 | DEFINE_IPL_ATTR_RW(dump_fcp, wwpn, "0x%016llx\n", "%016llx\n", |
| 604 | dump_block_fcp->ipl_info.fcp.wwpn); |
| 605 | DEFINE_IPL_ATTR_RW(dump_fcp, lun, "0x%016llx\n", "%016llx\n", |
| 606 | dump_block_fcp->ipl_info.fcp.lun); |
| 607 | DEFINE_IPL_ATTR_RW(dump_fcp, bootprog, "%lld\n", "%lld\n", |
| 608 | dump_block_fcp->ipl_info.fcp.bootprog); |
| 609 | DEFINE_IPL_ATTR_RW(dump_fcp, br_lba, "%lld\n", "%lld\n", |
| 610 | dump_block_fcp->ipl_info.fcp.br_lba); |
| 611 | DEFINE_IPL_ATTR_RW(dump_fcp, device, "0.0.%04llx\n", "0.0.%llx\n", |
| 612 | dump_block_fcp->ipl_info.fcp.devno); |
| 613 | |
| 614 | static struct attribute *dump_fcp_attrs[] = { |
| 615 | &sys_dump_fcp_device_attr.attr, |
| 616 | &sys_dump_fcp_wwpn_attr.attr, |
| 617 | &sys_dump_fcp_lun_attr.attr, |
| 618 | &sys_dump_fcp_bootprog_attr.attr, |
| 619 | &sys_dump_fcp_br_lba_attr.attr, |
| 620 | NULL, |
| 621 | }; |
| 622 | |
| 623 | static struct attribute_group dump_fcp_attr_group = { |
| 624 | .name = IPL_FCP_STR, |
| 625 | .attrs = dump_fcp_attrs, |
| 626 | }; |
| 627 | |
| 628 | /* CCW dump device attributes */ |
| 629 | |
| 630 | DEFINE_IPL_ATTR_RW(dump_ccw, device, "0.0.%04llx\n", "0.0.%llx\n", |
| 631 | dump_block_ccw->ipl_info.ccw.devno); |
| 632 | |
| 633 | static struct attribute *dump_ccw_attrs[] = { |
| 634 | &sys_dump_ccw_device_attr.attr, |
| 635 | NULL, |
| 636 | }; |
| 637 | |
| 638 | static struct attribute_group dump_ccw_attr_group = { |
| 639 | .name = IPL_CCW_STR, |
| 640 | .attrs = dump_ccw_attrs, |
| 641 | }; |
| 642 | |
| 643 | /* dump type */ |
| 644 | |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 645 | static int dump_set_type(enum dump_type type) |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 646 | { |
| 647 | if (!(dump_capabilities & type)) |
| 648 | return -EINVAL; |
| 649 | switch(type) { |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 650 | case DUMP_TYPE_CCW: |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 651 | if (MACHINE_IS_VM) |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 652 | dump_method = DUMP_METHOD_CCW_VM; |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 653 | else |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 654 | dump_method = DUMP_METHOD_CCW_CIO; |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 655 | break; |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 656 | case DUMP_TYPE_FCP: |
| 657 | dump_method = DUMP_METHOD_FCP_DIAG; |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 658 | break; |
| 659 | default: |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 660 | dump_method = DUMP_METHOD_NONE; |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 661 | } |
| 662 | dump_type = type; |
| 663 | return 0; |
| 664 | } |
| 665 | |
Greg Kroah-Hartman | 823bccf | 2007-04-13 13:15:19 -0700 | [diff] [blame] | 666 | static ssize_t dump_type_show(struct kset *kset, char *page) |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 667 | { |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 668 | return sprintf(page, "%s\n", dump_type_str(dump_type)); |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 669 | } |
| 670 | |
Greg Kroah-Hartman | 823bccf | 2007-04-13 13:15:19 -0700 | [diff] [blame] | 671 | static ssize_t dump_type_store(struct kset *kset, const char *buf, |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 672 | size_t len) |
| 673 | { |
| 674 | int rc = -EINVAL; |
| 675 | |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 676 | if (strncmp(buf, DUMP_NONE_STR, strlen(DUMP_NONE_STR)) == 0) |
| 677 | rc = dump_set_type(DUMP_TYPE_NONE); |
| 678 | else if (strncmp(buf, DUMP_CCW_STR, strlen(DUMP_CCW_STR)) == 0) |
| 679 | rc = dump_set_type(DUMP_TYPE_CCW); |
| 680 | else if (strncmp(buf, DUMP_FCP_STR, strlen(DUMP_FCP_STR)) == 0) |
| 681 | rc = dump_set_type(DUMP_TYPE_FCP); |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 682 | return (rc != 0) ? rc : len; |
| 683 | } |
| 684 | |
| 685 | static struct subsys_attribute dump_type_attr = |
| 686 | __ATTR(dump_type, 0644, dump_type_show, dump_type_store); |
| 687 | |
| 688 | static decl_subsys(dump, NULL, NULL); |
| 689 | |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 690 | /* |
| 691 | * Shutdown actions section |
| 692 | */ |
| 693 | |
| 694 | static decl_subsys(shutdown_actions, NULL, NULL); |
| 695 | |
| 696 | /* on panic */ |
| 697 | |
Greg Kroah-Hartman | 823bccf | 2007-04-13 13:15:19 -0700 | [diff] [blame] | 698 | static ssize_t on_panic_show(struct kset *kset, char *page) |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 699 | { |
| 700 | return sprintf(page, "%s\n", shutdown_action_str(on_panic_action)); |
| 701 | } |
| 702 | |
Greg Kroah-Hartman | 823bccf | 2007-04-13 13:15:19 -0700 | [diff] [blame] | 703 | static ssize_t on_panic_store(struct kset *kset, const char *buf, |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 704 | size_t len) |
| 705 | { |
| 706 | if (strncmp(buf, SHUTDOWN_REIPL_STR, strlen(SHUTDOWN_REIPL_STR)) == 0) |
| 707 | on_panic_action = SHUTDOWN_REIPL; |
| 708 | else if (strncmp(buf, SHUTDOWN_DUMP_STR, |
| 709 | strlen(SHUTDOWN_DUMP_STR)) == 0) |
| 710 | on_panic_action = SHUTDOWN_DUMP; |
| 711 | else if (strncmp(buf, SHUTDOWN_STOP_STR, |
| 712 | strlen(SHUTDOWN_STOP_STR)) == 0) |
| 713 | on_panic_action = SHUTDOWN_STOP; |
| 714 | else |
| 715 | return -EINVAL; |
| 716 | |
| 717 | return len; |
| 718 | } |
| 719 | |
| 720 | static struct subsys_attribute on_panic_attr = |
| 721 | __ATTR(on_panic, 0644, on_panic_show, on_panic_store); |
| 722 | |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 723 | void do_reipl(void) |
| 724 | { |
| 725 | struct ccw_dev_id devid; |
| 726 | static char buf[100]; |
Michael Holzheu | 03a4d20 | 2006-12-04 15:39:58 +0100 | [diff] [blame] | 727 | char loadparm[LOADPARM_LEN + 1]; |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 728 | |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 729 | switch (reipl_method) { |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 730 | case REIPL_METHOD_CCW_CIO: |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 731 | devid.devno = reipl_block_ccw->ipl_info.ccw.devno; |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 732 | if (ipl_info.type == IPL_TYPE_CCW && devid.devno == ipl_devno) |
Michael Holzheu | 5986b0e | 2006-12-04 15:40:13 +0100 | [diff] [blame] | 733 | diag308(DIAG308_IPL, NULL); |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 734 | devid.ssid = 0; |
| 735 | reipl_ccw_dev(&devid); |
| 736 | break; |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 737 | case REIPL_METHOD_CCW_VM: |
Michael Holzheu | 58be944 | 2006-12-15 17:18:25 +0100 | [diff] [blame] | 738 | reipl_get_ascii_loadparm(loadparm); |
Michael Holzheu | 03a4d20 | 2006-12-04 15:39:58 +0100 | [diff] [blame] | 739 | if (strlen(loadparm) == 0) |
| 740 | sprintf(buf, "IPL %X", |
| 741 | reipl_block_ccw->ipl_info.ccw.devno); |
| 742 | else |
| 743 | sprintf(buf, "IPL %X LOADPARM '%s'", |
| 744 | reipl_block_ccw->ipl_info.ccw.devno, loadparm); |
Heiko Carstens | 740b570 | 2006-12-04 15:40:30 +0100 | [diff] [blame] | 745 | __cpcmd(buf, NULL, 0, NULL); |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 746 | break; |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 747 | case REIPL_METHOD_CCW_DIAG: |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 748 | diag308(DIAG308_SET, reipl_block_ccw); |
| 749 | diag308(DIAG308_IPL, NULL); |
| 750 | break; |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 751 | case REIPL_METHOD_FCP_RW_DIAG: |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 752 | diag308(DIAG308_SET, reipl_block_fcp); |
| 753 | diag308(DIAG308_IPL, NULL); |
| 754 | break; |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 755 | case REIPL_METHOD_FCP_RO_DIAG: |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 756 | diag308(DIAG308_IPL, NULL); |
| 757 | break; |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 758 | case REIPL_METHOD_FCP_RO_VM: |
Heiko Carstens | 740b570 | 2006-12-04 15:40:30 +0100 | [diff] [blame] | 759 | __cpcmd("IPL", NULL, 0, NULL); |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 760 | break; |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 761 | case REIPL_METHOD_NSS: |
Hongjie Yang | fe355b7 | 2007-02-05 21:18:24 +0100 | [diff] [blame] | 762 | sprintf(buf, "IPL %s", reipl_nss_name); |
| 763 | __cpcmd(buf, NULL, 0, NULL); |
| 764 | break; |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 765 | case REIPL_METHOD_DEFAULT: |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 766 | if (MACHINE_IS_VM) |
Heiko Carstens | 740b570 | 2006-12-04 15:40:30 +0100 | [diff] [blame] | 767 | __cpcmd("IPL", NULL, 0, NULL); |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 768 | diag308(DIAG308_IPL, NULL); |
| 769 | break; |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 770 | case REIPL_METHOD_FCP_DUMP: |
| 771 | default: |
| 772 | break; |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 773 | } |
Michael Holzheu | 3902e47 | 2006-12-04 15:40:05 +0100 | [diff] [blame] | 774 | signal_processor(smp_processor_id(), sigp_stop_and_store_status); |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 775 | } |
| 776 | |
| 777 | static void do_dump(void) |
| 778 | { |
| 779 | struct ccw_dev_id devid; |
| 780 | static char buf[100]; |
| 781 | |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 782 | switch (dump_method) { |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 783 | case DUMP_METHOD_CCW_CIO: |
Heiko Carstens | c6b5b84 | 2006-12-04 15:40:33 +0100 | [diff] [blame] | 784 | smp_send_stop(); |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 785 | devid.devno = dump_block_ccw->ipl_info.ccw.devno; |
| 786 | devid.ssid = 0; |
| 787 | reipl_ccw_dev(&devid); |
| 788 | break; |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 789 | case DUMP_METHOD_CCW_VM: |
Heiko Carstens | c6b5b84 | 2006-12-04 15:40:33 +0100 | [diff] [blame] | 790 | smp_send_stop(); |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 791 | sprintf(buf, "STORE STATUS"); |
Heiko Carstens | 740b570 | 2006-12-04 15:40:30 +0100 | [diff] [blame] | 792 | __cpcmd(buf, NULL, 0, NULL); |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 793 | sprintf(buf, "IPL %X", dump_block_ccw->ipl_info.ccw.devno); |
Heiko Carstens | 740b570 | 2006-12-04 15:40:30 +0100 | [diff] [blame] | 794 | __cpcmd(buf, NULL, 0, NULL); |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 795 | break; |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 796 | case DUMP_METHOD_CCW_DIAG: |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 797 | diag308(DIAG308_SET, dump_block_ccw); |
| 798 | diag308(DIAG308_DUMP, NULL); |
| 799 | break; |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 800 | case DUMP_METHOD_FCP_DIAG: |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 801 | diag308(DIAG308_SET, dump_block_fcp); |
| 802 | diag308(DIAG308_DUMP, NULL); |
| 803 | break; |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 804 | case DUMP_METHOD_NONE: |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 805 | default: |
| 806 | return; |
| 807 | } |
| 808 | printk(KERN_EMERG "Dump failed!\n"); |
| 809 | } |
| 810 | |
| 811 | /* init functions */ |
| 812 | |
| 813 | static int __init ipl_register_fcp_files(void) |
| 814 | { |
| 815 | int rc; |
| 816 | |
Cornelia Huck | 0b0bb3c | 2007-05-10 15:45:41 +0200 | [diff] [blame] | 817 | rc = sysfs_create_group(&ipl_subsys.kobj, |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 818 | &ipl_fcp_attr_group); |
| 819 | if (rc) |
| 820 | goto out; |
Cornelia Huck | 0b0bb3c | 2007-05-10 15:45:41 +0200 | [diff] [blame] | 821 | rc = sysfs_create_bin_file(&ipl_subsys.kobj, |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 822 | &ipl_parameter_attr); |
| 823 | if (rc) |
| 824 | goto out_ipl_parm; |
Cornelia Huck | 0b0bb3c | 2007-05-10 15:45:41 +0200 | [diff] [blame] | 825 | rc = sysfs_create_bin_file(&ipl_subsys.kobj, |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 826 | &ipl_scp_data_attr); |
| 827 | if (!rc) |
| 828 | goto out; |
| 829 | |
Cornelia Huck | 0b0bb3c | 2007-05-10 15:45:41 +0200 | [diff] [blame] | 830 | sysfs_remove_bin_file(&ipl_subsys.kobj, &ipl_parameter_attr); |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 831 | |
| 832 | out_ipl_parm: |
Cornelia Huck | 0b0bb3c | 2007-05-10 15:45:41 +0200 | [diff] [blame] | 833 | sysfs_remove_group(&ipl_subsys.kobj, &ipl_fcp_attr_group); |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 834 | out: |
| 835 | return rc; |
| 836 | } |
| 837 | |
| 838 | static int __init ipl_init(void) |
| 839 | { |
| 840 | int rc; |
| 841 | |
| 842 | rc = firmware_register(&ipl_subsys); |
| 843 | if (rc) |
| 844 | return rc; |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 845 | switch (ipl_info.type) { |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 846 | case IPL_TYPE_CCW: |
Cornelia Huck | 0b0bb3c | 2007-05-10 15:45:41 +0200 | [diff] [blame] | 847 | rc = sysfs_create_group(&ipl_subsys.kobj, |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 848 | &ipl_ccw_attr_group); |
| 849 | break; |
| 850 | case IPL_TYPE_FCP: |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 851 | case IPL_TYPE_FCP_DUMP: |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 852 | rc = ipl_register_fcp_files(); |
| 853 | break; |
Hongjie Yang | fe355b7 | 2007-02-05 21:18:24 +0100 | [diff] [blame] | 854 | case IPL_TYPE_NSS: |
Cornelia Huck | 0b0bb3c | 2007-05-10 15:45:41 +0200 | [diff] [blame] | 855 | rc = sysfs_create_group(&ipl_subsys.kobj, |
Hongjie Yang | fe355b7 | 2007-02-05 21:18:24 +0100 | [diff] [blame] | 856 | &ipl_nss_attr_group); |
| 857 | break; |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 858 | default: |
Cornelia Huck | 0b0bb3c | 2007-05-10 15:45:41 +0200 | [diff] [blame] | 859 | rc = sysfs_create_group(&ipl_subsys.kobj, |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 860 | &ipl_unknown_attr_group); |
| 861 | break; |
| 862 | } |
| 863 | if (rc) |
| 864 | firmware_unregister(&ipl_subsys); |
| 865 | return rc; |
| 866 | } |
| 867 | |
| 868 | static void __init reipl_probe(void) |
| 869 | { |
| 870 | void *buffer; |
| 871 | |
| 872 | buffer = (void *) get_zeroed_page(GFP_KERNEL); |
| 873 | if (!buffer) |
| 874 | return; |
| 875 | if (diag308(DIAG308_STORE, buffer) == DIAG308_RC_OK) |
| 876 | diag308_set_works = 1; |
| 877 | free_page((unsigned long)buffer); |
| 878 | } |
| 879 | |
Hongjie Yang | fe355b7 | 2007-02-05 21:18:24 +0100 | [diff] [blame] | 880 | static int __init reipl_nss_init(void) |
| 881 | { |
| 882 | int rc; |
| 883 | |
| 884 | if (!MACHINE_IS_VM) |
| 885 | return 0; |
Cornelia Huck | 0b0bb3c | 2007-05-10 15:45:41 +0200 | [diff] [blame] | 886 | rc = sysfs_create_group(&reipl_subsys.kobj, &reipl_nss_attr_group); |
Hongjie Yang | fe355b7 | 2007-02-05 21:18:24 +0100 | [diff] [blame] | 887 | if (rc) |
| 888 | return rc; |
| 889 | strncpy(reipl_nss_name, kernel_nss_name, NSS_NAME_SIZE + 1); |
| 890 | reipl_capabilities |= IPL_TYPE_NSS; |
| 891 | return 0; |
| 892 | } |
| 893 | |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 894 | static int __init reipl_ccw_init(void) |
| 895 | { |
| 896 | int rc; |
| 897 | |
| 898 | reipl_block_ccw = (void *) get_zeroed_page(GFP_KERNEL); |
| 899 | if (!reipl_block_ccw) |
| 900 | return -ENOMEM; |
Cornelia Huck | 0b0bb3c | 2007-05-10 15:45:41 +0200 | [diff] [blame] | 901 | rc = sysfs_create_group(&reipl_subsys.kobj, &reipl_ccw_attr_group); |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 902 | if (rc) { |
| 903 | free_page((unsigned long)reipl_block_ccw); |
| 904 | return rc; |
| 905 | } |
| 906 | reipl_block_ccw->hdr.len = IPL_PARM_BLK_CCW_LEN; |
| 907 | reipl_block_ccw->hdr.version = IPL_PARM_BLOCK_VERSION; |
Michael Holzheu | fbb04f3 | 2007-03-19 13:19:03 +0100 | [diff] [blame] | 908 | reipl_block_ccw->hdr.blk0_len = IPL_PARM_BLK0_CCW_LEN; |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 909 | reipl_block_ccw->hdr.pbt = DIAG308_IPL_TYPE_CCW; |
Michael Holzheu | 03a4d20 | 2006-12-04 15:39:58 +0100 | [diff] [blame] | 910 | /* check if read scp info worked and set loadparm */ |
Heiko Carstens | 05dd253 | 2007-07-10 11:24:09 +0200 | [diff] [blame^] | 911 | if (sclp_ipl_info.is_valid) |
Michael Holzheu | 03a4d20 | 2006-12-04 15:39:58 +0100 | [diff] [blame] | 912 | memcpy(reipl_block_ccw->ipl_info.ccw.load_param, |
Heiko Carstens | 05dd253 | 2007-07-10 11:24:09 +0200 | [diff] [blame^] | 913 | &sclp_ipl_info.loadparm, LOADPARM_LEN); |
Michael Holzheu | 03a4d20 | 2006-12-04 15:39:58 +0100 | [diff] [blame] | 914 | else |
| 915 | /* read scp info failed: set empty loadparm (EBCDIC blanks) */ |
| 916 | memset(reipl_block_ccw->ipl_info.ccw.load_param, 0x40, |
| 917 | LOADPARM_LEN); |
| 918 | /* FIXME: check for diag308_set_works when enabling diag ccw reipl */ |
| 919 | if (!MACHINE_IS_VM) |
| 920 | sys_reipl_ccw_loadparm_attr.attr.mode = S_IRUGO; |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 921 | if (ipl_info.type == IPL_TYPE_CCW) |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 922 | reipl_block_ccw->ipl_info.ccw.devno = ipl_devno; |
| 923 | reipl_capabilities |= IPL_TYPE_CCW; |
| 924 | return 0; |
| 925 | } |
| 926 | |
| 927 | static int __init reipl_fcp_init(void) |
| 928 | { |
| 929 | int rc; |
| 930 | |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 931 | if ((!diag308_set_works) && (ipl_info.type != IPL_TYPE_FCP)) |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 932 | return 0; |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 933 | if ((!diag308_set_works) && (ipl_info.type == IPL_TYPE_FCP)) |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 934 | make_attrs_ro(reipl_fcp_attrs); |
| 935 | |
| 936 | reipl_block_fcp = (void *) get_zeroed_page(GFP_KERNEL); |
| 937 | if (!reipl_block_fcp) |
| 938 | return -ENOMEM; |
Cornelia Huck | 0b0bb3c | 2007-05-10 15:45:41 +0200 | [diff] [blame] | 939 | rc = sysfs_create_group(&reipl_subsys.kobj, &reipl_fcp_attr_group); |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 940 | if (rc) { |
| 941 | free_page((unsigned long)reipl_block_fcp); |
| 942 | return rc; |
| 943 | } |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 944 | if (ipl_info.type == IPL_TYPE_FCP) { |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 945 | memcpy(reipl_block_fcp, IPL_PARMBLOCK_START, PAGE_SIZE); |
| 946 | } else { |
| 947 | reipl_block_fcp->hdr.len = IPL_PARM_BLK_FCP_LEN; |
| 948 | reipl_block_fcp->hdr.version = IPL_PARM_BLOCK_VERSION; |
Michael Holzheu | fbb04f3 | 2007-03-19 13:19:03 +0100 | [diff] [blame] | 949 | reipl_block_fcp->hdr.blk0_len = IPL_PARM_BLK0_FCP_LEN; |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 950 | reipl_block_fcp->hdr.pbt = DIAG308_IPL_TYPE_FCP; |
| 951 | reipl_block_fcp->ipl_info.fcp.opt = DIAG308_IPL_OPT_IPL; |
| 952 | } |
| 953 | reipl_capabilities |= IPL_TYPE_FCP; |
| 954 | return 0; |
| 955 | } |
| 956 | |
| 957 | static int __init reipl_init(void) |
| 958 | { |
| 959 | int rc; |
| 960 | |
| 961 | rc = firmware_register(&reipl_subsys); |
| 962 | if (rc) |
| 963 | return rc; |
| 964 | rc = subsys_create_file(&reipl_subsys, &reipl_type_attr); |
| 965 | if (rc) { |
| 966 | firmware_unregister(&reipl_subsys); |
| 967 | return rc; |
| 968 | } |
| 969 | rc = reipl_ccw_init(); |
| 970 | if (rc) |
| 971 | return rc; |
| 972 | rc = reipl_fcp_init(); |
| 973 | if (rc) |
| 974 | return rc; |
Hongjie Yang | fe355b7 | 2007-02-05 21:18:24 +0100 | [diff] [blame] | 975 | rc = reipl_nss_init(); |
| 976 | if (rc) |
| 977 | return rc; |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 978 | rc = reipl_set_type(ipl_info.type); |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 979 | if (rc) |
| 980 | return rc; |
| 981 | return 0; |
| 982 | } |
| 983 | |
| 984 | static int __init dump_ccw_init(void) |
| 985 | { |
| 986 | int rc; |
| 987 | |
| 988 | dump_block_ccw = (void *) get_zeroed_page(GFP_KERNEL); |
| 989 | if (!dump_block_ccw) |
| 990 | return -ENOMEM; |
Cornelia Huck | 0b0bb3c | 2007-05-10 15:45:41 +0200 | [diff] [blame] | 991 | rc = sysfs_create_group(&dump_subsys.kobj, &dump_ccw_attr_group); |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 992 | if (rc) { |
| 993 | free_page((unsigned long)dump_block_ccw); |
| 994 | return rc; |
| 995 | } |
| 996 | dump_block_ccw->hdr.len = IPL_PARM_BLK_CCW_LEN; |
| 997 | dump_block_ccw->hdr.version = IPL_PARM_BLOCK_VERSION; |
Michael Holzheu | fbb04f3 | 2007-03-19 13:19:03 +0100 | [diff] [blame] | 998 | dump_block_ccw->hdr.blk0_len = IPL_PARM_BLK0_CCW_LEN; |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 999 | dump_block_ccw->hdr.pbt = DIAG308_IPL_TYPE_CCW; |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 1000 | dump_capabilities |= DUMP_TYPE_CCW; |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 1001 | return 0; |
| 1002 | } |
| 1003 | |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 1004 | static int __init dump_fcp_init(void) |
| 1005 | { |
| 1006 | int rc; |
| 1007 | |
Heiko Carstens | 05dd253 | 2007-07-10 11:24:09 +0200 | [diff] [blame^] | 1008 | if (!sclp_ipl_info.has_dump) |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 1009 | return 0; /* LDIPL DUMP is not installed */ |
| 1010 | if (!diag308_set_works) |
| 1011 | return 0; |
| 1012 | dump_block_fcp = (void *) get_zeroed_page(GFP_KERNEL); |
| 1013 | if (!dump_block_fcp) |
| 1014 | return -ENOMEM; |
Cornelia Huck | 0b0bb3c | 2007-05-10 15:45:41 +0200 | [diff] [blame] | 1015 | rc = sysfs_create_group(&dump_subsys.kobj, &dump_fcp_attr_group); |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 1016 | if (rc) { |
| 1017 | free_page((unsigned long)dump_block_fcp); |
| 1018 | return rc; |
| 1019 | } |
| 1020 | dump_block_fcp->hdr.len = IPL_PARM_BLK_FCP_LEN; |
| 1021 | dump_block_fcp->hdr.version = IPL_PARM_BLOCK_VERSION; |
Michael Holzheu | fbb04f3 | 2007-03-19 13:19:03 +0100 | [diff] [blame] | 1022 | dump_block_fcp->hdr.blk0_len = IPL_PARM_BLK0_FCP_LEN; |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 1023 | dump_block_fcp->hdr.pbt = DIAG308_IPL_TYPE_FCP; |
| 1024 | dump_block_fcp->ipl_info.fcp.opt = DIAG308_IPL_OPT_DUMP; |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 1025 | dump_capabilities |= DUMP_TYPE_FCP; |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 1026 | return 0; |
| 1027 | } |
| 1028 | |
| 1029 | #define SHUTDOWN_ON_PANIC_PRIO 0 |
| 1030 | |
| 1031 | static int shutdown_on_panic_notify(struct notifier_block *self, |
| 1032 | unsigned long event, void *data) |
| 1033 | { |
| 1034 | if (on_panic_action == SHUTDOWN_DUMP) |
| 1035 | do_dump(); |
| 1036 | else if (on_panic_action == SHUTDOWN_REIPL) |
| 1037 | do_reipl(); |
| 1038 | return NOTIFY_OK; |
| 1039 | } |
| 1040 | |
| 1041 | static struct notifier_block shutdown_on_panic_nb = { |
| 1042 | .notifier_call = shutdown_on_panic_notify, |
| 1043 | .priority = SHUTDOWN_ON_PANIC_PRIO |
| 1044 | }; |
| 1045 | |
| 1046 | static int __init dump_init(void) |
| 1047 | { |
| 1048 | int rc; |
| 1049 | |
| 1050 | rc = firmware_register(&dump_subsys); |
| 1051 | if (rc) |
| 1052 | return rc; |
| 1053 | rc = subsys_create_file(&dump_subsys, &dump_type_attr); |
| 1054 | if (rc) { |
| 1055 | firmware_unregister(&dump_subsys); |
| 1056 | return rc; |
| 1057 | } |
| 1058 | rc = dump_ccw_init(); |
| 1059 | if (rc) |
| 1060 | return rc; |
| 1061 | rc = dump_fcp_init(); |
| 1062 | if (rc) |
| 1063 | return rc; |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 1064 | dump_set_type(DUMP_TYPE_NONE); |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 1065 | return 0; |
| 1066 | } |
| 1067 | |
| 1068 | static int __init shutdown_actions_init(void) |
| 1069 | { |
| 1070 | int rc; |
| 1071 | |
| 1072 | rc = firmware_register(&shutdown_actions_subsys); |
| 1073 | if (rc) |
| 1074 | return rc; |
| 1075 | rc = subsys_create_file(&shutdown_actions_subsys, &on_panic_attr); |
| 1076 | if (rc) { |
| 1077 | firmware_unregister(&shutdown_actions_subsys); |
| 1078 | return rc; |
| 1079 | } |
| 1080 | atomic_notifier_chain_register(&panic_notifier_list, |
| 1081 | &shutdown_on_panic_nb); |
| 1082 | return 0; |
| 1083 | } |
| 1084 | |
| 1085 | static int __init s390_ipl_init(void) |
| 1086 | { |
| 1087 | int rc; |
| 1088 | |
Heiko Carstens | 05dd253 | 2007-07-10 11:24:09 +0200 | [diff] [blame^] | 1089 | sclp_get_ipl_info(&sclp_ipl_info); |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 1090 | reipl_probe(); |
| 1091 | rc = ipl_init(); |
| 1092 | if (rc) |
| 1093 | return rc; |
| 1094 | rc = reipl_init(); |
| 1095 | if (rc) |
| 1096 | return rc; |
| 1097 | rc = dump_init(); |
| 1098 | if (rc) |
| 1099 | return rc; |
| 1100 | rc = shutdown_actions_init(); |
| 1101 | if (rc) |
| 1102 | return rc; |
| 1103 | return 0; |
| 1104 | } |
| 1105 | |
| 1106 | __initcall(s390_ipl_init); |
Heiko Carstens | 15e9b58 | 2006-12-04 15:40:26 +0100 | [diff] [blame] | 1107 | |
Heiko Carstens | 6fc321f | 2007-04-27 16:01:25 +0200 | [diff] [blame] | 1108 | void __init ipl_save_parameters(void) |
| 1109 | { |
| 1110 | struct cio_iplinfo iplinfo; |
| 1111 | unsigned int *ipl_ptr; |
| 1112 | void *src, *dst; |
| 1113 | |
| 1114 | if (cio_get_iplinfo(&iplinfo)) |
| 1115 | return; |
| 1116 | |
| 1117 | ipl_devno = iplinfo.devno; |
| 1118 | ipl_flags |= IPL_DEVNO_VALID; |
| 1119 | if (!iplinfo.is_qdio) |
| 1120 | return; |
| 1121 | ipl_flags |= IPL_PARMBLOCK_VALID; |
| 1122 | ipl_ptr = (unsigned int *)__LC_IPL_PARMBLOCK_PTR; |
| 1123 | src = (void *)(unsigned long)*ipl_ptr; |
| 1124 | dst = (void *)IPL_PARMBLOCK_ORIGIN; |
| 1125 | memmove(dst, src, PAGE_SIZE); |
| 1126 | *ipl_ptr = IPL_PARMBLOCK_ORIGIN; |
| 1127 | } |
| 1128 | |
Heiko Carstens | 15e9b58 | 2006-12-04 15:40:26 +0100 | [diff] [blame] | 1129 | static LIST_HEAD(rcall); |
| 1130 | static DEFINE_MUTEX(rcall_mutex); |
| 1131 | |
| 1132 | void register_reset_call(struct reset_call *reset) |
| 1133 | { |
| 1134 | mutex_lock(&rcall_mutex); |
| 1135 | list_add(&reset->list, &rcall); |
| 1136 | mutex_unlock(&rcall_mutex); |
| 1137 | } |
| 1138 | EXPORT_SYMBOL_GPL(register_reset_call); |
| 1139 | |
| 1140 | void unregister_reset_call(struct reset_call *reset) |
| 1141 | { |
| 1142 | mutex_lock(&rcall_mutex); |
| 1143 | list_del(&reset->list); |
| 1144 | mutex_unlock(&rcall_mutex); |
| 1145 | } |
| 1146 | EXPORT_SYMBOL_GPL(unregister_reset_call); |
| 1147 | |
| 1148 | static void do_reset_calls(void) |
| 1149 | { |
| 1150 | struct reset_call *reset; |
| 1151 | |
| 1152 | list_for_each_entry(reset, &rcall, list) |
| 1153 | reset->fn(); |
| 1154 | } |
| 1155 | |
Heiko Carstens | c5dd858 | 2007-03-05 23:35:43 +0100 | [diff] [blame] | 1156 | u32 dump_prefix_page; |
Heiko Carstens | 15e9b58 | 2006-12-04 15:40:26 +0100 | [diff] [blame] | 1157 | |
| 1158 | void s390_reset_system(void) |
| 1159 | { |
| 1160 | struct _lowcore *lc; |
| 1161 | |
Heiko Carstens | 15e9b58 | 2006-12-04 15:40:26 +0100 | [diff] [blame] | 1162 | lc = (struct _lowcore *)(unsigned long) store_prefix(); |
Michael Holzheu | a45e141 | 2006-12-15 17:18:22 +0100 | [diff] [blame] | 1163 | |
| 1164 | /* Stack for interrupt/machine check handler */ |
Heiko Carstens | 15e9b58 | 2006-12-04 15:40:26 +0100 | [diff] [blame] | 1165 | lc->panic_stack = S390_lowcore.panic_stack; |
| 1166 | |
Michael Holzheu | da1cf23 | 2006-12-15 17:18:27 +0100 | [diff] [blame] | 1167 | /* Save prefix page address for dump case */ |
Heiko Carstens | c5dd858 | 2007-03-05 23:35:43 +0100 | [diff] [blame] | 1168 | dump_prefix_page = (u32)(unsigned long) lc; |
Michael Holzheu | da1cf23 | 2006-12-15 17:18:27 +0100 | [diff] [blame] | 1169 | |
Heiko Carstens | 15e9b58 | 2006-12-04 15:40:26 +0100 | [diff] [blame] | 1170 | /* Disable prefixing */ |
| 1171 | set_prefix(0); |
| 1172 | |
| 1173 | /* Disable lowcore protection */ |
| 1174 | __ctl_clear_bit(0,28); |
| 1175 | |
| 1176 | /* Set new machine check handler */ |
Gerald Schaefer | c1821c2 | 2007-02-05 21:18:17 +0100 | [diff] [blame] | 1177 | S390_lowcore.mcck_new_psw.mask = psw_kernel_bits & ~PSW_MASK_MCHECK; |
Heiko Carstens | 15e9b58 | 2006-12-04 15:40:26 +0100 | [diff] [blame] | 1178 | S390_lowcore.mcck_new_psw.addr = |
Heiko Carstens | ab14de6 | 2007-02-05 21:18:37 +0100 | [diff] [blame] | 1179 | PSW_ADDR_AMODE | (unsigned long) s390_base_mcck_handler; |
Michael Holzheu | a45e141 | 2006-12-15 17:18:22 +0100 | [diff] [blame] | 1180 | |
| 1181 | /* Set new program check handler */ |
Gerald Schaefer | c1821c2 | 2007-02-05 21:18:17 +0100 | [diff] [blame] | 1182 | S390_lowcore.program_new_psw.mask = psw_kernel_bits & ~PSW_MASK_MCHECK; |
Michael Holzheu | a45e141 | 2006-12-15 17:18:22 +0100 | [diff] [blame] | 1183 | S390_lowcore.program_new_psw.addr = |
Heiko Carstens | ab14de6 | 2007-02-05 21:18:37 +0100 | [diff] [blame] | 1184 | PSW_ADDR_AMODE | (unsigned long) s390_base_pgm_handler; |
Michael Holzheu | a45e141 | 2006-12-15 17:18:22 +0100 | [diff] [blame] | 1185 | |
Heiko Carstens | 15e9b58 | 2006-12-04 15:40:26 +0100 | [diff] [blame] | 1186 | do_reset_calls(); |
| 1187 | } |