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> |
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> |
Hendrik Brueckner | a0443fb | 2008-07-14 09:59:09 +0200 | [diff] [blame^] | 25 | #include <asm/setup.h> |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 26 | |
| 27 | #define IPL_PARM_BLOCK_VERSION 0 |
Michael Holzheu | 03a4d20 | 2006-12-04 15:39:58 +0100 | [diff] [blame] | 28 | |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 29 | #define IPL_UNKNOWN_STR "unknown" |
| 30 | #define IPL_CCW_STR "ccw" |
| 31 | #define IPL_FCP_STR "fcp" |
| 32 | #define IPL_FCP_DUMP_STR "fcp_dump" |
| 33 | #define IPL_NSS_STR "nss" |
Heiko Carstens | 615b04b | 2007-02-21 10:55:37 +0100 | [diff] [blame] | 34 | |
Michael Holzheu | 99ca4e5 | 2008-01-26 14:11:11 +0100 | [diff] [blame] | 35 | #define DUMP_CCW_STR "ccw" |
| 36 | #define DUMP_FCP_STR "fcp" |
| 37 | #define DUMP_NONE_STR "none" |
| 38 | |
| 39 | /* |
| 40 | * Four shutdown trigger types are supported: |
| 41 | * - panic |
| 42 | * - halt |
| 43 | * - power off |
| 44 | * - reipl |
| 45 | */ |
| 46 | #define ON_PANIC_STR "on_panic" |
| 47 | #define ON_HALT_STR "on_halt" |
| 48 | #define ON_POFF_STR "on_poff" |
| 49 | #define ON_REIPL_STR "on_reboot" |
| 50 | |
| 51 | struct shutdown_action; |
| 52 | struct shutdown_trigger { |
| 53 | char *name; |
| 54 | struct shutdown_action *action; |
| 55 | }; |
| 56 | |
| 57 | /* |
| 58 | * Five shutdown action types are supported: |
| 59 | */ |
| 60 | #define SHUTDOWN_ACTION_IPL_STR "ipl" |
| 61 | #define SHUTDOWN_ACTION_REIPL_STR "reipl" |
| 62 | #define SHUTDOWN_ACTION_DUMP_STR "dump" |
| 63 | #define SHUTDOWN_ACTION_VMCMD_STR "vmcmd" |
| 64 | #define SHUTDOWN_ACTION_STOP_STR "stop" |
| 65 | |
| 66 | struct shutdown_action { |
| 67 | char *name; |
| 68 | void (*fn) (struct shutdown_trigger *trigger); |
| 69 | int (*init) (void); |
| 70 | }; |
| 71 | |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 72 | static char *ipl_type_str(enum ipl_type type) |
| 73 | { |
| 74 | switch (type) { |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 75 | case IPL_TYPE_CCW: |
| 76 | return IPL_CCW_STR; |
| 77 | case IPL_TYPE_FCP: |
| 78 | return IPL_FCP_STR; |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 79 | case IPL_TYPE_FCP_DUMP: |
| 80 | return IPL_FCP_DUMP_STR; |
Hongjie Yang | fe355b7 | 2007-02-05 21:18:24 +0100 | [diff] [blame] | 81 | case IPL_TYPE_NSS: |
| 82 | return IPL_NSS_STR; |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 83 | case IPL_TYPE_UNKNOWN: |
| 84 | default: |
| 85 | return IPL_UNKNOWN_STR; |
| 86 | } |
| 87 | } |
| 88 | |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 89 | enum dump_type { |
| 90 | DUMP_TYPE_NONE = 1, |
| 91 | DUMP_TYPE_CCW = 2, |
| 92 | DUMP_TYPE_FCP = 4, |
| 93 | }; |
| 94 | |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 95 | static char *dump_type_str(enum dump_type type) |
| 96 | { |
| 97 | switch (type) { |
| 98 | case DUMP_TYPE_NONE: |
| 99 | return DUMP_NONE_STR; |
| 100 | case DUMP_TYPE_CCW: |
| 101 | return DUMP_CCW_STR; |
| 102 | case DUMP_TYPE_FCP: |
| 103 | return DUMP_FCP_STR; |
| 104 | default: |
| 105 | return NULL; |
| 106 | } |
| 107 | } |
| 108 | |
| 109 | /* |
| 110 | * Must be in data section since the bss section |
| 111 | * is not cleared when these are accessed. |
| 112 | */ |
| 113 | static u16 ipl_devno __attribute__((__section__(".data"))) = 0; |
| 114 | u32 ipl_flags __attribute__((__section__(".data"))) = 0; |
| 115 | |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 116 | enum ipl_method { |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 117 | REIPL_METHOD_CCW_CIO, |
| 118 | REIPL_METHOD_CCW_DIAG, |
| 119 | REIPL_METHOD_CCW_VM, |
| 120 | REIPL_METHOD_FCP_RO_DIAG, |
| 121 | REIPL_METHOD_FCP_RW_DIAG, |
| 122 | REIPL_METHOD_FCP_RO_VM, |
| 123 | REIPL_METHOD_FCP_DUMP, |
| 124 | REIPL_METHOD_NSS, |
Hendrik Brueckner | a0443fb | 2008-07-14 09:59:09 +0200 | [diff] [blame^] | 125 | REIPL_METHOD_NSS_DIAG, |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 126 | REIPL_METHOD_DEFAULT, |
| 127 | }; |
| 128 | |
| 129 | enum dump_method { |
| 130 | DUMP_METHOD_NONE, |
| 131 | DUMP_METHOD_CCW_CIO, |
| 132 | DUMP_METHOD_CCW_DIAG, |
| 133 | DUMP_METHOD_CCW_VM, |
| 134 | DUMP_METHOD_FCP_DIAG, |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 135 | }; |
| 136 | |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 137 | static int diag308_set_works = 0; |
| 138 | |
Hendrik Brueckner | a0443fb | 2008-07-14 09:59:09 +0200 | [diff] [blame^] | 139 | static struct ipl_parameter_block ipl_block; |
| 140 | |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 141 | static int reipl_capabilities = IPL_TYPE_UNKNOWN; |
Hongjie Yang | fe355b7 | 2007-02-05 21:18:24 +0100 | [diff] [blame] | 142 | |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 143 | static enum ipl_type reipl_type = IPL_TYPE_UNKNOWN; |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 144 | static enum ipl_method reipl_method = REIPL_METHOD_DEFAULT; |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 145 | static struct ipl_parameter_block *reipl_block_fcp; |
| 146 | static struct ipl_parameter_block *reipl_block_ccw; |
Hendrik Brueckner | a0443fb | 2008-07-14 09:59:09 +0200 | [diff] [blame^] | 147 | static struct ipl_parameter_block *reipl_block_nss; |
Hongjie Yang | fe355b7 | 2007-02-05 21:18:24 +0100 | [diff] [blame] | 148 | |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 149 | static int dump_capabilities = DUMP_TYPE_NONE; |
| 150 | static enum dump_type dump_type = DUMP_TYPE_NONE; |
| 151 | static enum dump_method dump_method = DUMP_METHOD_NONE; |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 152 | static struct ipl_parameter_block *dump_block_fcp; |
| 153 | static struct ipl_parameter_block *dump_block_ccw; |
| 154 | |
Heiko Carstens | 05dd253 | 2007-07-10 11:24:09 +0200 | [diff] [blame] | 155 | static struct sclp_ipl_info sclp_ipl_info; |
| 156 | |
Michael Holzheu | 46b05d2 | 2007-02-21 10:55:21 +0100 | [diff] [blame] | 157 | int diag308(unsigned long subcode, void *addr) |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 158 | { |
Martin Schwidefsky | 94c12cc | 2006-09-28 16:56:43 +0200 | [diff] [blame] | 159 | register unsigned long _addr asm("0") = (unsigned long) addr; |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 160 | register unsigned long _rc asm("1") = 0; |
| 161 | |
Martin Schwidefsky | 94c12cc | 2006-09-28 16:56:43 +0200 | [diff] [blame] | 162 | asm volatile( |
| 163 | " diag %0,%2,0x308\n" |
| 164 | "0:\n" |
| 165 | EX_TABLE(0b,0b) |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 166 | : "+d" (_addr), "+d" (_rc) |
Martin Schwidefsky | 94c12cc | 2006-09-28 16:56:43 +0200 | [diff] [blame] | 167 | : "d" (subcode) : "cc", "memory"); |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 168 | return _rc; |
| 169 | } |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 170 | EXPORT_SYMBOL_GPL(diag308); |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 171 | |
| 172 | /* SYSFS */ |
| 173 | |
| 174 | #define DEFINE_IPL_ATTR_RO(_prefix, _name, _format, _value) \ |
Greg Kroah-Hartman | 9b94916 | 2007-11-02 17:17:00 -0400 | [diff] [blame] | 175 | static ssize_t sys_##_prefix##_##_name##_show(struct kobject *kobj, \ |
| 176 | struct kobj_attribute *attr, \ |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 177 | char *page) \ |
| 178 | { \ |
| 179 | return sprintf(page, _format, _value); \ |
| 180 | } \ |
Greg Kroah-Hartman | 9b94916 | 2007-11-02 17:17:00 -0400 | [diff] [blame] | 181 | static struct kobj_attribute sys_##_prefix##_##_name##_attr = \ |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 182 | __ATTR(_name, S_IRUGO, sys_##_prefix##_##_name##_show, NULL); |
| 183 | |
| 184 | #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] | 185 | static ssize_t sys_##_prefix##_##_name##_show(struct kobject *kobj, \ |
| 186 | struct kobj_attribute *attr, \ |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 187 | char *page) \ |
| 188 | { \ |
| 189 | return sprintf(page, _fmt_out, \ |
| 190 | (unsigned long long) _value); \ |
| 191 | } \ |
Greg Kroah-Hartman | 9b94916 | 2007-11-02 17:17:00 -0400 | [diff] [blame] | 192 | static ssize_t sys_##_prefix##_##_name##_store(struct kobject *kobj, \ |
| 193 | struct kobj_attribute *attr, \ |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 194 | const char *buf, size_t len) \ |
| 195 | { \ |
| 196 | unsigned long long value; \ |
| 197 | if (sscanf(buf, _fmt_in, &value) != 1) \ |
| 198 | return -EINVAL; \ |
| 199 | _value = value; \ |
| 200 | return len; \ |
| 201 | } \ |
Greg Kroah-Hartman | 9b94916 | 2007-11-02 17:17:00 -0400 | [diff] [blame] | 202 | static struct kobj_attribute sys_##_prefix##_##_name##_attr = \ |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 203 | __ATTR(_name,(S_IRUGO | S_IWUSR), \ |
| 204 | sys_##_prefix##_##_name##_show, \ |
| 205 | sys_##_prefix##_##_name##_store); |
| 206 | |
Hongjie Yang | fe355b7 | 2007-02-05 21:18:24 +0100 | [diff] [blame] | 207 | #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] | 208 | static ssize_t sys_##_prefix##_##_name##_show(struct kobject *kobj, \ |
| 209 | struct kobj_attribute *attr, \ |
Hongjie Yang | fe355b7 | 2007-02-05 21:18:24 +0100 | [diff] [blame] | 210 | char *page) \ |
| 211 | { \ |
| 212 | return sprintf(page, _fmt_out, _value); \ |
| 213 | } \ |
Greg Kroah-Hartman | 9b94916 | 2007-11-02 17:17:00 -0400 | [diff] [blame] | 214 | static ssize_t sys_##_prefix##_##_name##_store(struct kobject *kobj, \ |
| 215 | struct kobj_attribute *attr, \ |
Hongjie Yang | fe355b7 | 2007-02-05 21:18:24 +0100 | [diff] [blame] | 216 | const char *buf, size_t len) \ |
| 217 | { \ |
Michael Holzheu | 99ca4e5 | 2008-01-26 14:11:11 +0100 | [diff] [blame] | 218 | strncpy(_value, buf, sizeof(_value) - 1); \ |
| 219 | strstrip(_value); \ |
Hongjie Yang | fe355b7 | 2007-02-05 21:18:24 +0100 | [diff] [blame] | 220 | return len; \ |
| 221 | } \ |
Greg Kroah-Hartman | 9b94916 | 2007-11-02 17:17:00 -0400 | [diff] [blame] | 222 | static struct kobj_attribute sys_##_prefix##_##_name##_attr = \ |
Hongjie Yang | fe355b7 | 2007-02-05 21:18:24 +0100 | [diff] [blame] | 223 | __ATTR(_name,(S_IRUGO | S_IWUSR), \ |
| 224 | sys_##_prefix##_##_name##_show, \ |
| 225 | sys_##_prefix##_##_name##_store); |
| 226 | |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 227 | static void make_attrs_ro(struct attribute **attrs) |
| 228 | { |
| 229 | while (*attrs) { |
| 230 | (*attrs)->mode = S_IRUGO; |
| 231 | attrs++; |
| 232 | } |
| 233 | } |
| 234 | |
| 235 | /* |
| 236 | * ipl section |
| 237 | */ |
| 238 | |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 239 | static __init enum ipl_type get_ipl_type(void) |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 240 | { |
| 241 | struct ipl_parameter_block *ipl = IPL_PARMBLOCK_START; |
| 242 | |
Hongjie Yang | fe355b7 | 2007-02-05 21:18:24 +0100 | [diff] [blame] | 243 | if (ipl_flags & IPL_NSS_VALID) |
| 244 | return IPL_TYPE_NSS; |
Heiko Carstens | e87bfe5 | 2006-09-20 15:59:15 +0200 | [diff] [blame] | 245 | if (!(ipl_flags & IPL_DEVNO_VALID)) |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 246 | return IPL_TYPE_UNKNOWN; |
Heiko Carstens | e87bfe5 | 2006-09-20 15:59:15 +0200 | [diff] [blame] | 247 | if (!(ipl_flags & IPL_PARMBLOCK_VALID)) |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 248 | return IPL_TYPE_CCW; |
| 249 | if (ipl->hdr.version > IPL_MAX_SUPPORTED_VERSION) |
| 250 | return IPL_TYPE_UNKNOWN; |
| 251 | if (ipl->hdr.pbt != DIAG308_IPL_TYPE_FCP) |
| 252 | return IPL_TYPE_UNKNOWN; |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 253 | if (ipl->ipl_info.fcp.opt == DIAG308_IPL_OPT_DUMP) |
| 254 | return IPL_TYPE_FCP_DUMP; |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 255 | return IPL_TYPE_FCP; |
| 256 | } |
| 257 | |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 258 | struct ipl_info ipl_info; |
| 259 | EXPORT_SYMBOL_GPL(ipl_info); |
| 260 | |
Greg Kroah-Hartman | 9b94916 | 2007-11-02 17:17:00 -0400 | [diff] [blame] | 261 | static ssize_t ipl_type_show(struct kobject *kobj, struct kobj_attribute *attr, |
| 262 | char *page) |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 263 | { |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 264 | return sprintf(page, "%s\n", ipl_type_str(ipl_info.type)); |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 265 | } |
| 266 | |
Greg Kroah-Hartman | 9b94916 | 2007-11-02 17:17:00 -0400 | [diff] [blame] | 267 | static struct kobj_attribute sys_ipl_type_attr = __ATTR_RO(ipl_type); |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 268 | |
Hendrik Brueckner | a0443fb | 2008-07-14 09:59:09 +0200 | [diff] [blame^] | 269 | /* VM IPL PARM routines */ |
| 270 | static void reipl_get_ascii_vmparm(char *dest, |
| 271 | const struct ipl_parameter_block *ipb) |
| 272 | { |
| 273 | int i; |
| 274 | int len = 0; |
| 275 | char has_lowercase = 0; |
| 276 | |
| 277 | if ((ipb->ipl_info.ccw.vm_flags & DIAG308_VM_FLAGS_VP_VALID) && |
| 278 | (ipb->ipl_info.ccw.vm_parm_len > 0)) { |
| 279 | |
| 280 | len = ipb->ipl_info.ccw.vm_parm_len; |
| 281 | memcpy(dest, ipb->ipl_info.ccw.vm_parm, len); |
| 282 | /* If at least one character is lowercase, we assume mixed |
| 283 | * case; otherwise we convert everything to lowercase. |
| 284 | */ |
| 285 | for (i = 0; i < len; i++) |
| 286 | if ((dest[i] > 0x80 && dest[i] < 0x8a) || /* a-i */ |
| 287 | (dest[i] > 0x90 && dest[i] < 0x9a) || /* j-r */ |
| 288 | (dest[i] > 0xa1 && dest[i] < 0xaa)) { /* s-z */ |
| 289 | has_lowercase = 1; |
| 290 | break; |
| 291 | } |
| 292 | if (!has_lowercase) |
| 293 | EBC_TOLOWER(dest, len); |
| 294 | EBCASC(dest, len); |
| 295 | } |
| 296 | dest[len] = 0; |
| 297 | } |
| 298 | |
| 299 | void get_ipl_vmparm(char *dest) |
| 300 | { |
| 301 | if (diag308_set_works && (ipl_block.hdr.pbt == DIAG308_IPL_TYPE_CCW)) |
| 302 | reipl_get_ascii_vmparm(dest, &ipl_block); |
| 303 | else |
| 304 | dest[0] = 0; |
| 305 | } |
| 306 | |
| 307 | static ssize_t ipl_vm_parm_show(struct kobject *kobj, |
| 308 | struct kobj_attribute *attr, char *page) |
| 309 | { |
| 310 | char parm[DIAG308_VMPARM_SIZE + 1] = {}; |
| 311 | |
| 312 | get_ipl_vmparm(parm); |
| 313 | return sprintf(page, "%s\n", parm); |
| 314 | } |
| 315 | |
| 316 | static struct kobj_attribute sys_ipl_vm_parm_attr = |
| 317 | __ATTR(parm, S_IRUGO, ipl_vm_parm_show, NULL); |
| 318 | |
Greg Kroah-Hartman | 9b94916 | 2007-11-02 17:17:00 -0400 | [diff] [blame] | 319 | static ssize_t sys_ipl_device_show(struct kobject *kobj, |
| 320 | struct kobj_attribute *attr, char *page) |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 321 | { |
| 322 | struct ipl_parameter_block *ipl = IPL_PARMBLOCK_START; |
| 323 | |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 324 | switch (ipl_info.type) { |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 325 | case IPL_TYPE_CCW: |
| 326 | return sprintf(page, "0.0.%04x\n", ipl_devno); |
| 327 | case IPL_TYPE_FCP: |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 328 | case IPL_TYPE_FCP_DUMP: |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 329 | return sprintf(page, "0.0.%04x\n", ipl->ipl_info.fcp.devno); |
| 330 | default: |
| 331 | return 0; |
| 332 | } |
| 333 | } |
| 334 | |
Greg Kroah-Hartman | 9b94916 | 2007-11-02 17:17:00 -0400 | [diff] [blame] | 335 | static struct kobj_attribute sys_ipl_device_attr = |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 336 | __ATTR(device, S_IRUGO, sys_ipl_device_show, NULL); |
| 337 | |
Al Viro | 05bd711 | 2007-07-15 21:01:22 +0100 | [diff] [blame] | 338 | static ssize_t ipl_parameter_read(struct kobject *kobj, struct bin_attribute *attr, |
| 339 | char *buf, loff_t off, size_t count) |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 340 | { |
| 341 | unsigned int size = IPL_PARMBLOCK_SIZE; |
| 342 | |
| 343 | if (off > size) |
| 344 | return 0; |
| 345 | if (off + count > size) |
| 346 | count = size - off; |
| 347 | memcpy(buf, (void *)IPL_PARMBLOCK_START + off, count); |
| 348 | return count; |
| 349 | } |
| 350 | |
| 351 | static struct bin_attribute ipl_parameter_attr = { |
| 352 | .attr = { |
| 353 | .name = "binary_parameter", |
| 354 | .mode = S_IRUGO, |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 355 | }, |
| 356 | .size = PAGE_SIZE, |
| 357 | .read = &ipl_parameter_read, |
| 358 | }; |
| 359 | |
Al Viro | 05bd711 | 2007-07-15 21:01:22 +0100 | [diff] [blame] | 360 | static ssize_t ipl_scp_data_read(struct kobject *kobj, struct bin_attribute *attr, |
| 361 | char *buf, loff_t off, size_t count) |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 362 | { |
| 363 | unsigned int size = IPL_PARMBLOCK_START->ipl_info.fcp.scp_data_len; |
| 364 | void *scp_data = &IPL_PARMBLOCK_START->ipl_info.fcp.scp_data; |
| 365 | |
| 366 | if (off > size) |
| 367 | return 0; |
| 368 | if (off + count > size) |
| 369 | count = size - off; |
| 370 | memcpy(buf, scp_data + off, count); |
| 371 | return count; |
| 372 | } |
| 373 | |
| 374 | static struct bin_attribute ipl_scp_data_attr = { |
| 375 | .attr = { |
| 376 | .name = "scp_data", |
| 377 | .mode = S_IRUGO, |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 378 | }, |
| 379 | .size = PAGE_SIZE, |
Al Viro | 05bd711 | 2007-07-15 21:01:22 +0100 | [diff] [blame] | 380 | .read = ipl_scp_data_read, |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 381 | }; |
| 382 | |
| 383 | /* FCP ipl device attributes */ |
| 384 | |
| 385 | DEFINE_IPL_ATTR_RO(ipl_fcp, wwpn, "0x%016llx\n", (unsigned long long) |
| 386 | IPL_PARMBLOCK_START->ipl_info.fcp.wwpn); |
| 387 | DEFINE_IPL_ATTR_RO(ipl_fcp, lun, "0x%016llx\n", (unsigned long long) |
| 388 | IPL_PARMBLOCK_START->ipl_info.fcp.lun); |
| 389 | DEFINE_IPL_ATTR_RO(ipl_fcp, bootprog, "%lld\n", (unsigned long long) |
| 390 | IPL_PARMBLOCK_START->ipl_info.fcp.bootprog); |
| 391 | DEFINE_IPL_ATTR_RO(ipl_fcp, br_lba, "%lld\n", (unsigned long long) |
| 392 | IPL_PARMBLOCK_START->ipl_info.fcp.br_lba); |
| 393 | |
| 394 | static struct attribute *ipl_fcp_attrs[] = { |
| 395 | &sys_ipl_type_attr.attr, |
| 396 | &sys_ipl_device_attr.attr, |
| 397 | &sys_ipl_fcp_wwpn_attr.attr, |
| 398 | &sys_ipl_fcp_lun_attr.attr, |
| 399 | &sys_ipl_fcp_bootprog_attr.attr, |
| 400 | &sys_ipl_fcp_br_lba_attr.attr, |
| 401 | NULL, |
| 402 | }; |
| 403 | |
| 404 | static struct attribute_group ipl_fcp_attr_group = { |
| 405 | .attrs = ipl_fcp_attrs, |
| 406 | }; |
| 407 | |
| 408 | /* CCW ipl device attributes */ |
| 409 | |
Greg Kroah-Hartman | 9b94916 | 2007-11-02 17:17:00 -0400 | [diff] [blame] | 410 | static ssize_t ipl_ccw_loadparm_show(struct kobject *kobj, |
| 411 | struct kobj_attribute *attr, char *page) |
Michael Holzheu | 03a4d20 | 2006-12-04 15:39:58 +0100 | [diff] [blame] | 412 | { |
| 413 | char loadparm[LOADPARM_LEN + 1] = {}; |
| 414 | |
Heiko Carstens | 05dd253 | 2007-07-10 11:24:09 +0200 | [diff] [blame] | 415 | if (!sclp_ipl_info.is_valid) |
Michael Holzheu | 03a4d20 | 2006-12-04 15:39:58 +0100 | [diff] [blame] | 416 | return sprintf(page, "#unknown#\n"); |
Heiko Carstens | 05dd253 | 2007-07-10 11:24:09 +0200 | [diff] [blame] | 417 | memcpy(loadparm, &sclp_ipl_info.loadparm, LOADPARM_LEN); |
Michael Holzheu | 03a4d20 | 2006-12-04 15:39:58 +0100 | [diff] [blame] | 418 | EBCASC(loadparm, LOADPARM_LEN); |
| 419 | strstrip(loadparm); |
| 420 | return sprintf(page, "%s\n", loadparm); |
| 421 | } |
| 422 | |
Greg Kroah-Hartman | 9b94916 | 2007-11-02 17:17:00 -0400 | [diff] [blame] | 423 | static struct kobj_attribute sys_ipl_ccw_loadparm_attr = |
Michael Holzheu | 03a4d20 | 2006-12-04 15:39:58 +0100 | [diff] [blame] | 424 | __ATTR(loadparm, 0444, ipl_ccw_loadparm_show, NULL); |
| 425 | |
Hendrik Brueckner | a0443fb | 2008-07-14 09:59:09 +0200 | [diff] [blame^] | 426 | static struct attribute *ipl_ccw_attrs_vm[] = { |
| 427 | &sys_ipl_type_attr.attr, |
| 428 | &sys_ipl_device_attr.attr, |
| 429 | &sys_ipl_ccw_loadparm_attr.attr, |
| 430 | &sys_ipl_vm_parm_attr.attr, |
| 431 | NULL, |
| 432 | }; |
| 433 | |
| 434 | static struct attribute *ipl_ccw_attrs_lpar[] = { |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 435 | &sys_ipl_type_attr.attr, |
| 436 | &sys_ipl_device_attr.attr, |
Michael Holzheu | 03a4d20 | 2006-12-04 15:39:58 +0100 | [diff] [blame] | 437 | &sys_ipl_ccw_loadparm_attr.attr, |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 438 | NULL, |
| 439 | }; |
| 440 | |
Hendrik Brueckner | a0443fb | 2008-07-14 09:59:09 +0200 | [diff] [blame^] | 441 | static struct attribute_group ipl_ccw_attr_group_vm = { |
| 442 | .attrs = ipl_ccw_attrs_vm, |
| 443 | }; |
| 444 | |
| 445 | static struct attribute_group ipl_ccw_attr_group_lpar = { |
| 446 | .attrs = ipl_ccw_attrs_lpar |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 447 | }; |
| 448 | |
Hongjie Yang | fe355b7 | 2007-02-05 21:18:24 +0100 | [diff] [blame] | 449 | /* NSS ipl device attributes */ |
| 450 | |
| 451 | DEFINE_IPL_ATTR_RO(ipl_nss, name, "%s\n", kernel_nss_name); |
| 452 | |
| 453 | static struct attribute *ipl_nss_attrs[] = { |
| 454 | &sys_ipl_type_attr.attr, |
| 455 | &sys_ipl_nss_name_attr.attr, |
Hendrik Brueckner | a0443fb | 2008-07-14 09:59:09 +0200 | [diff] [blame^] | 456 | &sys_ipl_ccw_loadparm_attr.attr, |
| 457 | &sys_ipl_vm_parm_attr.attr, |
Hongjie Yang | fe355b7 | 2007-02-05 21:18:24 +0100 | [diff] [blame] | 458 | NULL, |
| 459 | }; |
| 460 | |
| 461 | static struct attribute_group ipl_nss_attr_group = { |
| 462 | .attrs = ipl_nss_attrs, |
| 463 | }; |
| 464 | |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 465 | /* UNKNOWN ipl device attributes */ |
| 466 | |
| 467 | static struct attribute *ipl_unknown_attrs[] = { |
| 468 | &sys_ipl_type_attr.attr, |
| 469 | NULL, |
| 470 | }; |
| 471 | |
| 472 | static struct attribute_group ipl_unknown_attr_group = { |
| 473 | .attrs = ipl_unknown_attrs, |
| 474 | }; |
| 475 | |
Greg Kroah-Hartman | d91885b | 2007-11-02 17:17:00 -0400 | [diff] [blame] | 476 | static struct kset *ipl_kset; |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 477 | |
Michael Holzheu | 99ca4e5 | 2008-01-26 14:11:11 +0100 | [diff] [blame] | 478 | static int __init ipl_register_fcp_files(void) |
| 479 | { |
| 480 | int rc; |
| 481 | |
| 482 | rc = sysfs_create_group(&ipl_kset->kobj, &ipl_fcp_attr_group); |
| 483 | if (rc) |
| 484 | goto out; |
| 485 | rc = sysfs_create_bin_file(&ipl_kset->kobj, &ipl_parameter_attr); |
| 486 | if (rc) |
| 487 | goto out_ipl_parm; |
| 488 | rc = sysfs_create_bin_file(&ipl_kset->kobj, &ipl_scp_data_attr); |
| 489 | if (!rc) |
| 490 | goto out; |
| 491 | |
| 492 | sysfs_remove_bin_file(&ipl_kset->kobj, &ipl_parameter_attr); |
| 493 | |
| 494 | out_ipl_parm: |
| 495 | sysfs_remove_group(&ipl_kset->kobj, &ipl_fcp_attr_group); |
| 496 | out: |
| 497 | return rc; |
| 498 | } |
| 499 | |
| 500 | static void ipl_run(struct shutdown_trigger *trigger) |
| 501 | { |
| 502 | diag308(DIAG308_IPL, NULL); |
| 503 | if (MACHINE_IS_VM) |
| 504 | __cpcmd("IPL", NULL, 0, NULL); |
| 505 | else if (ipl_info.type == IPL_TYPE_CCW) |
| 506 | reipl_ccw_dev(&ipl_info.data.ccw.dev_id); |
| 507 | } |
| 508 | |
Heiko Carstens | 2bc89b5 | 2008-02-05 16:50:40 +0100 | [diff] [blame] | 509 | static int __init ipl_init(void) |
Michael Holzheu | 99ca4e5 | 2008-01-26 14:11:11 +0100 | [diff] [blame] | 510 | { |
| 511 | int rc; |
| 512 | |
| 513 | ipl_kset = kset_create_and_add("ipl", NULL, firmware_kobj); |
| 514 | if (!ipl_kset) { |
| 515 | rc = -ENOMEM; |
| 516 | goto out; |
| 517 | } |
| 518 | switch (ipl_info.type) { |
| 519 | case IPL_TYPE_CCW: |
Hendrik Brueckner | a0443fb | 2008-07-14 09:59:09 +0200 | [diff] [blame^] | 520 | if (MACHINE_IS_VM) |
| 521 | rc = sysfs_create_group(&ipl_kset->kobj, |
| 522 | &ipl_ccw_attr_group_vm); |
| 523 | else |
| 524 | rc = sysfs_create_group(&ipl_kset->kobj, |
| 525 | &ipl_ccw_attr_group_lpar); |
Michael Holzheu | 99ca4e5 | 2008-01-26 14:11:11 +0100 | [diff] [blame] | 526 | break; |
| 527 | case IPL_TYPE_FCP: |
| 528 | case IPL_TYPE_FCP_DUMP: |
| 529 | rc = ipl_register_fcp_files(); |
| 530 | break; |
| 531 | case IPL_TYPE_NSS: |
| 532 | rc = sysfs_create_group(&ipl_kset->kobj, &ipl_nss_attr_group); |
| 533 | break; |
| 534 | default: |
| 535 | rc = sysfs_create_group(&ipl_kset->kobj, |
| 536 | &ipl_unknown_attr_group); |
| 537 | break; |
| 538 | } |
| 539 | out: |
| 540 | if (rc) |
| 541 | panic("ipl_init failed: rc = %i\n", rc); |
| 542 | |
| 543 | return 0; |
| 544 | } |
| 545 | |
Heiko Carstens | 2bc89b5 | 2008-02-05 16:50:40 +0100 | [diff] [blame] | 546 | static struct shutdown_action __refdata ipl_action = { |
| 547 | .name = SHUTDOWN_ACTION_IPL_STR, |
| 548 | .fn = ipl_run, |
| 549 | .init = ipl_init, |
| 550 | }; |
Michael Holzheu | 99ca4e5 | 2008-01-26 14:11:11 +0100 | [diff] [blame] | 551 | |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 552 | /* |
Michael Holzheu | 99ca4e5 | 2008-01-26 14:11:11 +0100 | [diff] [blame] | 553 | * reipl shutdown action: Reboot Linux on shutdown. |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 554 | */ |
| 555 | |
Hendrik Brueckner | a0443fb | 2008-07-14 09:59:09 +0200 | [diff] [blame^] | 556 | /* VM IPL PARM attributes */ |
| 557 | static ssize_t reipl_generic_vmparm_show(struct ipl_parameter_block *ipb, |
| 558 | char *page) |
| 559 | { |
| 560 | char vmparm[DIAG308_VMPARM_SIZE + 1] = {}; |
| 561 | |
| 562 | reipl_get_ascii_vmparm(vmparm, ipb); |
| 563 | return sprintf(page, "%s\n", vmparm); |
| 564 | } |
| 565 | |
| 566 | static ssize_t reipl_generic_vmparm_store(struct ipl_parameter_block *ipb, |
| 567 | size_t vmparm_max, |
| 568 | const char *buf, size_t len) |
| 569 | { |
| 570 | int i, ip_len; |
| 571 | |
| 572 | /* ignore trailing newline */ |
| 573 | ip_len = len; |
| 574 | if ((len > 0) && (buf[len - 1] == '\n')) |
| 575 | ip_len--; |
| 576 | |
| 577 | if (ip_len > vmparm_max) |
| 578 | return -EINVAL; |
| 579 | |
| 580 | /* parm is used to store kernel options, check for common chars */ |
| 581 | for (i = 0; i < ip_len; i++) |
| 582 | if (!(isalnum(buf[i]) || isascii(buf[i]) || isprint(buf[i]))) |
| 583 | return -EINVAL; |
| 584 | |
| 585 | memset(ipb->ipl_info.ccw.vm_parm, 0, DIAG308_VMPARM_SIZE); |
| 586 | ipb->ipl_info.ccw.vm_parm_len = ip_len; |
| 587 | if (ip_len > 0) { |
| 588 | ipb->ipl_info.ccw.vm_flags |= DIAG308_VM_FLAGS_VP_VALID; |
| 589 | memcpy(ipb->ipl_info.ccw.vm_parm, buf, ip_len); |
| 590 | ASCEBC(ipb->ipl_info.ccw.vm_parm, ip_len); |
| 591 | } else { |
| 592 | ipb->ipl_info.ccw.vm_flags &= ~DIAG308_VM_FLAGS_VP_VALID; |
| 593 | } |
| 594 | |
| 595 | return len; |
| 596 | } |
| 597 | |
| 598 | /* NSS wrapper */ |
| 599 | static ssize_t reipl_nss_vmparm_show(struct kobject *kobj, |
| 600 | struct kobj_attribute *attr, char *page) |
| 601 | { |
| 602 | return reipl_generic_vmparm_show(reipl_block_nss, page); |
| 603 | } |
| 604 | |
| 605 | static ssize_t reipl_nss_vmparm_store(struct kobject *kobj, |
| 606 | struct kobj_attribute *attr, |
| 607 | const char *buf, size_t len) |
| 608 | { |
| 609 | return reipl_generic_vmparm_store(reipl_block_nss, 56, buf, len); |
| 610 | } |
| 611 | |
| 612 | /* CCW wrapper */ |
| 613 | static ssize_t reipl_ccw_vmparm_show(struct kobject *kobj, |
| 614 | struct kobj_attribute *attr, char *page) |
| 615 | { |
| 616 | return reipl_generic_vmparm_show(reipl_block_ccw, page); |
| 617 | } |
| 618 | |
| 619 | static ssize_t reipl_ccw_vmparm_store(struct kobject *kobj, |
| 620 | struct kobj_attribute *attr, |
| 621 | const char *buf, size_t len) |
| 622 | { |
| 623 | return reipl_generic_vmparm_store(reipl_block_ccw, 64, buf, len); |
| 624 | } |
| 625 | |
| 626 | static struct kobj_attribute sys_reipl_nss_vmparm_attr = |
| 627 | __ATTR(parm, S_IRUGO | S_IWUSR, reipl_nss_vmparm_show, |
| 628 | reipl_nss_vmparm_store); |
| 629 | static struct kobj_attribute sys_reipl_ccw_vmparm_attr = |
| 630 | __ATTR(parm, S_IRUGO | S_IWUSR, reipl_ccw_vmparm_show, |
| 631 | reipl_ccw_vmparm_store); |
| 632 | |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 633 | /* FCP reipl device attributes */ |
| 634 | |
| 635 | DEFINE_IPL_ATTR_RW(reipl_fcp, wwpn, "0x%016llx\n", "%016llx\n", |
| 636 | reipl_block_fcp->ipl_info.fcp.wwpn); |
| 637 | DEFINE_IPL_ATTR_RW(reipl_fcp, lun, "0x%016llx\n", "%016llx\n", |
| 638 | reipl_block_fcp->ipl_info.fcp.lun); |
| 639 | DEFINE_IPL_ATTR_RW(reipl_fcp, bootprog, "%lld\n", "%lld\n", |
| 640 | reipl_block_fcp->ipl_info.fcp.bootprog); |
| 641 | DEFINE_IPL_ATTR_RW(reipl_fcp, br_lba, "%lld\n", "%lld\n", |
| 642 | reipl_block_fcp->ipl_info.fcp.br_lba); |
| 643 | DEFINE_IPL_ATTR_RW(reipl_fcp, device, "0.0.%04llx\n", "0.0.%llx\n", |
| 644 | reipl_block_fcp->ipl_info.fcp.devno); |
| 645 | |
| 646 | static struct attribute *reipl_fcp_attrs[] = { |
| 647 | &sys_reipl_fcp_device_attr.attr, |
| 648 | &sys_reipl_fcp_wwpn_attr.attr, |
| 649 | &sys_reipl_fcp_lun_attr.attr, |
| 650 | &sys_reipl_fcp_bootprog_attr.attr, |
| 651 | &sys_reipl_fcp_br_lba_attr.attr, |
| 652 | NULL, |
| 653 | }; |
| 654 | |
| 655 | static struct attribute_group reipl_fcp_attr_group = { |
| 656 | .name = IPL_FCP_STR, |
| 657 | .attrs = reipl_fcp_attrs, |
| 658 | }; |
| 659 | |
| 660 | /* CCW reipl device attributes */ |
| 661 | |
| 662 | DEFINE_IPL_ATTR_RW(reipl_ccw, device, "0.0.%04llx\n", "0.0.%llx\n", |
| 663 | reipl_block_ccw->ipl_info.ccw.devno); |
| 664 | |
Hendrik Brueckner | a0443fb | 2008-07-14 09:59:09 +0200 | [diff] [blame^] | 665 | static void reipl_get_ascii_loadparm(char *loadparm, |
| 666 | struct ipl_parameter_block *ibp) |
Michael Holzheu | 03a4d20 | 2006-12-04 15:39:58 +0100 | [diff] [blame] | 667 | { |
Hendrik Brueckner | a0443fb | 2008-07-14 09:59:09 +0200 | [diff] [blame^] | 668 | memcpy(loadparm, ibp->ipl_info.ccw.load_parm, LOADPARM_LEN); |
Michael Holzheu | 03a4d20 | 2006-12-04 15:39:58 +0100 | [diff] [blame] | 669 | EBCASC(loadparm, LOADPARM_LEN); |
| 670 | loadparm[LOADPARM_LEN] = 0; |
| 671 | strstrip(loadparm); |
| 672 | } |
| 673 | |
Hendrik Brueckner | a0443fb | 2008-07-14 09:59:09 +0200 | [diff] [blame^] | 674 | static ssize_t reipl_generic_loadparm_show(struct ipl_parameter_block *ipb, |
| 675 | char *page) |
Michael Holzheu | 03a4d20 | 2006-12-04 15:39:58 +0100 | [diff] [blame] | 676 | { |
| 677 | char buf[LOADPARM_LEN + 1]; |
| 678 | |
Hendrik Brueckner | a0443fb | 2008-07-14 09:59:09 +0200 | [diff] [blame^] | 679 | reipl_get_ascii_loadparm(buf, ipb); |
Michael Holzheu | 03a4d20 | 2006-12-04 15:39:58 +0100 | [diff] [blame] | 680 | return sprintf(page, "%s\n", buf); |
| 681 | } |
| 682 | |
Hendrik Brueckner | a0443fb | 2008-07-14 09:59:09 +0200 | [diff] [blame^] | 683 | static ssize_t reipl_generic_loadparm_store(struct ipl_parameter_block *ipb, |
| 684 | const char *buf, size_t len) |
Michael Holzheu | 03a4d20 | 2006-12-04 15:39:58 +0100 | [diff] [blame] | 685 | { |
| 686 | int i, lp_len; |
| 687 | |
| 688 | /* ignore trailing newline */ |
| 689 | lp_len = len; |
| 690 | if ((len > 0) && (buf[len - 1] == '\n')) |
| 691 | lp_len--; |
| 692 | /* loadparm can have max 8 characters and must not start with a blank */ |
| 693 | if ((lp_len > LOADPARM_LEN) || ((lp_len > 0) && (buf[0] == ' '))) |
| 694 | return -EINVAL; |
| 695 | /* loadparm can only contain "a-z,A-Z,0-9,SP,." */ |
| 696 | for (i = 0; i < lp_len; i++) { |
| 697 | if (isalpha(buf[i]) || isdigit(buf[i]) || (buf[i] == ' ') || |
| 698 | (buf[i] == '.')) |
| 699 | continue; |
| 700 | return -EINVAL; |
| 701 | } |
| 702 | /* initialize loadparm with blanks */ |
Hendrik Brueckner | a0443fb | 2008-07-14 09:59:09 +0200 | [diff] [blame^] | 703 | memset(ipb->ipl_info.ccw.load_parm, ' ', LOADPARM_LEN); |
Michael Holzheu | 03a4d20 | 2006-12-04 15:39:58 +0100 | [diff] [blame] | 704 | /* copy and convert to ebcdic */ |
Hendrik Brueckner | a0443fb | 2008-07-14 09:59:09 +0200 | [diff] [blame^] | 705 | memcpy(ipb->ipl_info.ccw.load_parm, buf, lp_len); |
| 706 | ASCEBC(ipb->ipl_info.ccw.load_parm, LOADPARM_LEN); |
Michael Holzheu | 03a4d20 | 2006-12-04 15:39:58 +0100 | [diff] [blame] | 707 | return len; |
| 708 | } |
| 709 | |
Hendrik Brueckner | a0443fb | 2008-07-14 09:59:09 +0200 | [diff] [blame^] | 710 | /* NSS wrapper */ |
| 711 | static ssize_t reipl_nss_loadparm_show(struct kobject *kobj, |
| 712 | struct kobj_attribute *attr, char *page) |
| 713 | { |
| 714 | return reipl_generic_loadparm_show(reipl_block_nss, page); |
| 715 | } |
Michael Holzheu | 03a4d20 | 2006-12-04 15:39:58 +0100 | [diff] [blame] | 716 | |
Hendrik Brueckner | a0443fb | 2008-07-14 09:59:09 +0200 | [diff] [blame^] | 717 | static ssize_t reipl_nss_loadparm_store(struct kobject *kobj, |
| 718 | struct kobj_attribute *attr, |
| 719 | const char *buf, size_t len) |
| 720 | { |
| 721 | return reipl_generic_loadparm_store(reipl_block_nss, buf, len); |
| 722 | } |
| 723 | |
| 724 | /* CCW wrapper */ |
| 725 | static ssize_t reipl_ccw_loadparm_show(struct kobject *kobj, |
| 726 | struct kobj_attribute *attr, char *page) |
| 727 | { |
| 728 | return reipl_generic_loadparm_show(reipl_block_ccw, page); |
| 729 | } |
| 730 | |
| 731 | static ssize_t reipl_ccw_loadparm_store(struct kobject *kobj, |
| 732 | struct kobj_attribute *attr, |
| 733 | const char *buf, size_t len) |
| 734 | { |
| 735 | return reipl_generic_loadparm_store(reipl_block_ccw, buf, len); |
| 736 | } |
| 737 | |
| 738 | static struct kobj_attribute sys_reipl_ccw_loadparm_attr = |
| 739 | __ATTR(loadparm, S_IRUGO | S_IWUSR, reipl_ccw_loadparm_show, |
| 740 | reipl_ccw_loadparm_store); |
| 741 | |
| 742 | static struct attribute *reipl_ccw_attrs_vm[] = { |
| 743 | &sys_reipl_ccw_device_attr.attr, |
| 744 | &sys_reipl_ccw_loadparm_attr.attr, |
| 745 | &sys_reipl_ccw_vmparm_attr.attr, |
| 746 | NULL, |
| 747 | }; |
| 748 | |
| 749 | static struct attribute *reipl_ccw_attrs_lpar[] = { |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 750 | &sys_reipl_ccw_device_attr.attr, |
Michael Holzheu | 03a4d20 | 2006-12-04 15:39:58 +0100 | [diff] [blame] | 751 | &sys_reipl_ccw_loadparm_attr.attr, |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 752 | NULL, |
| 753 | }; |
| 754 | |
Hendrik Brueckner | a0443fb | 2008-07-14 09:59:09 +0200 | [diff] [blame^] | 755 | static struct attribute_group reipl_ccw_attr_group_vm = { |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 756 | .name = IPL_CCW_STR, |
Hendrik Brueckner | a0443fb | 2008-07-14 09:59:09 +0200 | [diff] [blame^] | 757 | .attrs = reipl_ccw_attrs_vm, |
| 758 | }; |
| 759 | |
| 760 | static struct attribute_group reipl_ccw_attr_group_lpar = { |
| 761 | .name = IPL_CCW_STR, |
| 762 | .attrs = reipl_ccw_attrs_lpar, |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 763 | }; |
| 764 | |
Hongjie Yang | fe355b7 | 2007-02-05 21:18:24 +0100 | [diff] [blame] | 765 | |
| 766 | /* NSS reipl device attributes */ |
Hendrik Brueckner | a0443fb | 2008-07-14 09:59:09 +0200 | [diff] [blame^] | 767 | static void reipl_get_ascii_nss_name(char *dst, |
| 768 | struct ipl_parameter_block *ipb) |
| 769 | { |
| 770 | memcpy(dst, ipb->ipl_info.ccw.nss_name, NSS_NAME_SIZE); |
| 771 | EBCASC(dst, NSS_NAME_SIZE); |
| 772 | dst[NSS_NAME_SIZE] = 0; |
| 773 | } |
Hongjie Yang | fe355b7 | 2007-02-05 21:18:24 +0100 | [diff] [blame] | 774 | |
Hendrik Brueckner | a0443fb | 2008-07-14 09:59:09 +0200 | [diff] [blame^] | 775 | static ssize_t reipl_nss_name_show(struct kobject *kobj, |
| 776 | struct kobj_attribute *attr, char *page) |
| 777 | { |
| 778 | char nss_name[NSS_NAME_SIZE + 1] = {}; |
| 779 | |
| 780 | reipl_get_ascii_nss_name(nss_name, reipl_block_nss); |
| 781 | return sprintf(page, "%s\n", nss_name); |
| 782 | } |
| 783 | |
| 784 | static ssize_t reipl_nss_name_store(struct kobject *kobj, |
| 785 | struct kobj_attribute *attr, |
| 786 | const char *buf, size_t len) |
| 787 | { |
| 788 | int nss_len; |
| 789 | |
| 790 | /* ignore trailing newline */ |
| 791 | nss_len = len; |
| 792 | if ((len > 0) && (buf[len - 1] == '\n')) |
| 793 | nss_len--; |
| 794 | |
| 795 | if (nss_len > NSS_NAME_SIZE) |
| 796 | return -EINVAL; |
| 797 | |
| 798 | memset(reipl_block_nss->ipl_info.ccw.nss_name, 0x40, NSS_NAME_SIZE); |
| 799 | if (nss_len > 0) { |
| 800 | reipl_block_nss->ipl_info.ccw.vm_flags |= |
| 801 | DIAG308_VM_FLAGS_NSS_VALID; |
| 802 | memcpy(reipl_block_nss->ipl_info.ccw.nss_name, buf, nss_len); |
| 803 | ASCEBC(reipl_block_nss->ipl_info.ccw.nss_name, nss_len); |
| 804 | EBC_TOUPPER(reipl_block_nss->ipl_info.ccw.nss_name, nss_len); |
| 805 | } else { |
| 806 | reipl_block_nss->ipl_info.ccw.vm_flags &= |
| 807 | ~DIAG308_VM_FLAGS_NSS_VALID; |
| 808 | } |
| 809 | |
| 810 | return len; |
| 811 | } |
| 812 | |
| 813 | static struct kobj_attribute sys_reipl_nss_name_attr = |
| 814 | __ATTR(name, S_IRUGO | S_IWUSR, reipl_nss_name_show, |
| 815 | reipl_nss_name_store); |
| 816 | |
| 817 | static struct kobj_attribute sys_reipl_nss_loadparm_attr = |
| 818 | __ATTR(loadparm, S_IRUGO | S_IWUSR, reipl_nss_loadparm_show, |
| 819 | reipl_nss_loadparm_store); |
Hongjie Yang | fe355b7 | 2007-02-05 21:18:24 +0100 | [diff] [blame] | 820 | |
| 821 | static struct attribute *reipl_nss_attrs[] = { |
| 822 | &sys_reipl_nss_name_attr.attr, |
Hendrik Brueckner | a0443fb | 2008-07-14 09:59:09 +0200 | [diff] [blame^] | 823 | &sys_reipl_nss_loadparm_attr.attr, |
| 824 | &sys_reipl_nss_vmparm_attr.attr, |
Hongjie Yang | fe355b7 | 2007-02-05 21:18:24 +0100 | [diff] [blame] | 825 | NULL, |
| 826 | }; |
| 827 | |
| 828 | static struct attribute_group reipl_nss_attr_group = { |
| 829 | .name = IPL_NSS_STR, |
| 830 | .attrs = reipl_nss_attrs, |
| 831 | }; |
| 832 | |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 833 | /* reipl type */ |
| 834 | |
| 835 | static int reipl_set_type(enum ipl_type type) |
| 836 | { |
| 837 | if (!(reipl_capabilities & type)) |
| 838 | return -EINVAL; |
| 839 | |
| 840 | switch(type) { |
| 841 | case IPL_TYPE_CCW: |
Michael Holzheu | 48657d2 | 2008-01-26 14:11:17 +0100 | [diff] [blame] | 842 | if (diag308_set_works) |
| 843 | reipl_method = REIPL_METHOD_CCW_DIAG; |
| 844 | else if (MACHINE_IS_VM) |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 845 | reipl_method = REIPL_METHOD_CCW_VM; |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 846 | else |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 847 | reipl_method = REIPL_METHOD_CCW_CIO; |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 848 | break; |
| 849 | case IPL_TYPE_FCP: |
| 850 | if (diag308_set_works) |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 851 | reipl_method = REIPL_METHOD_FCP_RW_DIAG; |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 852 | else if (MACHINE_IS_VM) |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 853 | reipl_method = REIPL_METHOD_FCP_RO_VM; |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 854 | else |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 855 | reipl_method = REIPL_METHOD_FCP_RO_DIAG; |
| 856 | break; |
| 857 | case IPL_TYPE_FCP_DUMP: |
| 858 | reipl_method = REIPL_METHOD_FCP_DUMP; |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 859 | break; |
Hongjie Yang | fe355b7 | 2007-02-05 21:18:24 +0100 | [diff] [blame] | 860 | case IPL_TYPE_NSS: |
Hendrik Brueckner | a0443fb | 2008-07-14 09:59:09 +0200 | [diff] [blame^] | 861 | if (diag308_set_works) |
| 862 | reipl_method = REIPL_METHOD_NSS_DIAG; |
| 863 | else |
| 864 | reipl_method = REIPL_METHOD_NSS; |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 865 | break; |
| 866 | case IPL_TYPE_UNKNOWN: |
| 867 | reipl_method = REIPL_METHOD_DEFAULT; |
Hongjie Yang | fe355b7 | 2007-02-05 21:18:24 +0100 | [diff] [blame] | 868 | break; |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 869 | default: |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 870 | BUG(); |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 871 | } |
| 872 | reipl_type = type; |
| 873 | return 0; |
| 874 | } |
| 875 | |
Greg Kroah-Hartman | 9b94916 | 2007-11-02 17:17:00 -0400 | [diff] [blame] | 876 | static ssize_t reipl_type_show(struct kobject *kobj, |
| 877 | struct kobj_attribute *attr, char *page) |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 878 | { |
| 879 | return sprintf(page, "%s\n", ipl_type_str(reipl_type)); |
| 880 | } |
| 881 | |
Greg Kroah-Hartman | 9b94916 | 2007-11-02 17:17:00 -0400 | [diff] [blame] | 882 | static ssize_t reipl_type_store(struct kobject *kobj, |
| 883 | struct kobj_attribute *attr, |
| 884 | const char *buf, size_t len) |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 885 | { |
| 886 | int rc = -EINVAL; |
| 887 | |
| 888 | if (strncmp(buf, IPL_CCW_STR, strlen(IPL_CCW_STR)) == 0) |
| 889 | rc = reipl_set_type(IPL_TYPE_CCW); |
| 890 | else if (strncmp(buf, IPL_FCP_STR, strlen(IPL_FCP_STR)) == 0) |
| 891 | rc = reipl_set_type(IPL_TYPE_FCP); |
Hongjie Yang | fe355b7 | 2007-02-05 21:18:24 +0100 | [diff] [blame] | 892 | else if (strncmp(buf, IPL_NSS_STR, strlen(IPL_NSS_STR)) == 0) |
| 893 | rc = reipl_set_type(IPL_TYPE_NSS); |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 894 | return (rc != 0) ? rc : len; |
| 895 | } |
| 896 | |
Greg Kroah-Hartman | 9b94916 | 2007-11-02 17:17:00 -0400 | [diff] [blame] | 897 | static struct kobj_attribute reipl_type_attr = |
Michael Holzheu | 99ca4e5 | 2008-01-26 14:11:11 +0100 | [diff] [blame] | 898 | __ATTR(reipl_type, 0644, reipl_type_show, reipl_type_store); |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 899 | |
Greg Kroah-Hartman | d91885b | 2007-11-02 17:17:00 -0400 | [diff] [blame] | 900 | static struct kset *reipl_kset; |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 901 | |
Hendrik Brueckner | a0443fb | 2008-07-14 09:59:09 +0200 | [diff] [blame^] | 902 | static void get_ipl_string(char *dst, struct ipl_parameter_block *ipb, |
| 903 | const enum ipl_method m) |
| 904 | { |
| 905 | char loadparm[LOADPARM_LEN + 1] = {}; |
| 906 | char vmparm[DIAG308_VMPARM_SIZE + 1] = {}; |
| 907 | char nss_name[NSS_NAME_SIZE + 1] = {}; |
| 908 | size_t pos = 0; |
| 909 | |
| 910 | reipl_get_ascii_loadparm(loadparm, ipb); |
| 911 | reipl_get_ascii_nss_name(nss_name, ipb); |
| 912 | reipl_get_ascii_vmparm(vmparm, ipb); |
| 913 | |
| 914 | switch (m) { |
| 915 | case REIPL_METHOD_CCW_VM: |
| 916 | pos = sprintf(dst, "IPL %X CLEAR", ipb->ipl_info.ccw.devno); |
| 917 | break; |
| 918 | case REIPL_METHOD_NSS: |
| 919 | pos = sprintf(dst, "IPL %s", nss_name); |
| 920 | break; |
| 921 | default: |
| 922 | break; |
| 923 | } |
| 924 | if (strlen(loadparm) > 0) |
| 925 | pos += sprintf(dst + pos, " LOADPARM '%s'", loadparm); |
| 926 | if (strlen(vmparm) > 0) |
| 927 | sprintf(dst + pos, " PARM %s", vmparm); |
| 928 | } |
| 929 | |
Heiko Carstens | a806170 | 2008-04-17 07:46:26 +0200 | [diff] [blame] | 930 | static void reipl_run(struct shutdown_trigger *trigger) |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 931 | { |
| 932 | struct ccw_dev_id devid; |
Hendrik Brueckner | a0443fb | 2008-07-14 09:59:09 +0200 | [diff] [blame^] | 933 | static char buf[128]; |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 934 | |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 935 | switch (reipl_method) { |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 936 | case REIPL_METHOD_CCW_CIO: |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 937 | devid.devno = reipl_block_ccw->ipl_info.ccw.devno; |
| 938 | devid.ssid = 0; |
| 939 | reipl_ccw_dev(&devid); |
| 940 | break; |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 941 | case REIPL_METHOD_CCW_VM: |
Hendrik Brueckner | a0443fb | 2008-07-14 09:59:09 +0200 | [diff] [blame^] | 942 | get_ipl_string(buf, reipl_block_ccw, REIPL_METHOD_CCW_VM); |
Heiko Carstens | 740b570 | 2006-12-04 15:40:30 +0100 | [diff] [blame] | 943 | __cpcmd(buf, NULL, 0, NULL); |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 944 | break; |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 945 | case REIPL_METHOD_CCW_DIAG: |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 946 | diag308(DIAG308_SET, reipl_block_ccw); |
| 947 | diag308(DIAG308_IPL, NULL); |
| 948 | break; |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 949 | case REIPL_METHOD_FCP_RW_DIAG: |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 950 | diag308(DIAG308_SET, reipl_block_fcp); |
| 951 | diag308(DIAG308_IPL, NULL); |
| 952 | break; |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 953 | case REIPL_METHOD_FCP_RO_DIAG: |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 954 | diag308(DIAG308_IPL, NULL); |
| 955 | break; |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 956 | case REIPL_METHOD_FCP_RO_VM: |
Heiko Carstens | 740b570 | 2006-12-04 15:40:30 +0100 | [diff] [blame] | 957 | __cpcmd("IPL", NULL, 0, NULL); |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 958 | break; |
Hendrik Brueckner | a0443fb | 2008-07-14 09:59:09 +0200 | [diff] [blame^] | 959 | case REIPL_METHOD_NSS_DIAG: |
| 960 | diag308(DIAG308_SET, reipl_block_nss); |
| 961 | diag308(DIAG308_IPL, NULL); |
| 962 | break; |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 963 | case REIPL_METHOD_NSS: |
Hendrik Brueckner | a0443fb | 2008-07-14 09:59:09 +0200 | [diff] [blame^] | 964 | get_ipl_string(buf, reipl_block_nss, REIPL_METHOD_NSS); |
Hongjie Yang | fe355b7 | 2007-02-05 21:18:24 +0100 | [diff] [blame] | 965 | __cpcmd(buf, NULL, 0, NULL); |
| 966 | break; |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 967 | case REIPL_METHOD_DEFAULT: |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 968 | if (MACHINE_IS_VM) |
Heiko Carstens | 740b570 | 2006-12-04 15:40:30 +0100 | [diff] [blame] | 969 | __cpcmd("IPL", NULL, 0, NULL); |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 970 | diag308(DIAG308_IPL, NULL); |
| 971 | break; |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 972 | case REIPL_METHOD_FCP_DUMP: |
| 973 | default: |
| 974 | break; |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 975 | } |
Michael Holzheu | 208e559 | 2008-03-05 12:37:15 +0100 | [diff] [blame] | 976 | disabled_wait((unsigned long) __builtin_return_address(0)); |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 977 | } |
| 978 | |
Hendrik Brueckner | a0443fb | 2008-07-14 09:59:09 +0200 | [diff] [blame^] | 979 | static void reipl_block_ccw_init(struct ipl_parameter_block *ipb) |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 980 | { |
Hendrik Brueckner | a0443fb | 2008-07-14 09:59:09 +0200 | [diff] [blame^] | 981 | ipb->hdr.len = IPL_PARM_BLK_CCW_LEN; |
| 982 | ipb->hdr.version = IPL_PARM_BLOCK_VERSION; |
| 983 | ipb->hdr.blk0_len = IPL_PARM_BLK0_CCW_LEN; |
| 984 | ipb->hdr.pbt = DIAG308_IPL_TYPE_CCW; |
| 985 | } |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 986 | |
Hendrik Brueckner | a0443fb | 2008-07-14 09:59:09 +0200 | [diff] [blame^] | 987 | static void reipl_block_ccw_fill_parms(struct ipl_parameter_block *ipb) |
| 988 | { |
| 989 | /* LOADPARM */ |
| 990 | /* check if read scp info worked and set loadparm */ |
| 991 | if (sclp_ipl_info.is_valid) |
| 992 | memcpy(ipb->ipl_info.ccw.load_parm, |
| 993 | &sclp_ipl_info.loadparm, LOADPARM_LEN); |
| 994 | else |
| 995 | /* read scp info failed: set empty loadparm (EBCDIC blanks) */ |
| 996 | memset(ipb->ipl_info.ccw.load_parm, 0x40, LOADPARM_LEN); |
| 997 | ipb->hdr.flags = DIAG308_FLAGS_LP_VALID; |
| 998 | |
| 999 | /* VM PARM */ |
| 1000 | if (MACHINE_IS_VM && diag308_set_works && |
| 1001 | (ipl_block.ipl_info.ccw.vm_flags & DIAG308_VM_FLAGS_VP_VALID)) { |
| 1002 | |
| 1003 | ipb->ipl_info.ccw.vm_flags |= DIAG308_VM_FLAGS_VP_VALID; |
| 1004 | ipb->ipl_info.ccw.vm_parm_len = |
| 1005 | ipl_block.ipl_info.ccw.vm_parm_len; |
| 1006 | memcpy(ipb->ipl_info.ccw.vm_parm, |
| 1007 | ipl_block.ipl_info.ccw.vm_parm, DIAG308_VMPARM_SIZE); |
| 1008 | } |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 1009 | } |
| 1010 | |
Hongjie Yang | fe355b7 | 2007-02-05 21:18:24 +0100 | [diff] [blame] | 1011 | static int __init reipl_nss_init(void) |
| 1012 | { |
| 1013 | int rc; |
| 1014 | |
| 1015 | if (!MACHINE_IS_VM) |
| 1016 | return 0; |
Hendrik Brueckner | a0443fb | 2008-07-14 09:59:09 +0200 | [diff] [blame^] | 1017 | |
| 1018 | reipl_block_nss = (void *) get_zeroed_page(GFP_KERNEL); |
| 1019 | if (!reipl_block_nss) |
| 1020 | return -ENOMEM; |
| 1021 | |
| 1022 | if (!diag308_set_works) |
| 1023 | sys_reipl_nss_vmparm_attr.attr.mode = S_IRUGO; |
| 1024 | |
Greg Kroah-Hartman | d91885b | 2007-11-02 17:17:00 -0400 | [diff] [blame] | 1025 | rc = sysfs_create_group(&reipl_kset->kobj, &reipl_nss_attr_group); |
Hongjie Yang | fe355b7 | 2007-02-05 21:18:24 +0100 | [diff] [blame] | 1026 | if (rc) |
| 1027 | return rc; |
Hendrik Brueckner | a0443fb | 2008-07-14 09:59:09 +0200 | [diff] [blame^] | 1028 | |
| 1029 | reipl_block_ccw_init(reipl_block_nss); |
| 1030 | if (ipl_info.type == IPL_TYPE_NSS) { |
| 1031 | memset(reipl_block_nss->ipl_info.ccw.nss_name, |
| 1032 | ' ', NSS_NAME_SIZE); |
| 1033 | memcpy(reipl_block_nss->ipl_info.ccw.nss_name, |
| 1034 | kernel_nss_name, strlen(kernel_nss_name)); |
| 1035 | ASCEBC(reipl_block_nss->ipl_info.ccw.nss_name, NSS_NAME_SIZE); |
| 1036 | reipl_block_nss->ipl_info.ccw.vm_flags |= |
| 1037 | DIAG308_VM_FLAGS_NSS_VALID; |
| 1038 | |
| 1039 | reipl_block_ccw_fill_parms(reipl_block_nss); |
| 1040 | } |
| 1041 | |
Hongjie Yang | fe355b7 | 2007-02-05 21:18:24 +0100 | [diff] [blame] | 1042 | reipl_capabilities |= IPL_TYPE_NSS; |
| 1043 | return 0; |
| 1044 | } |
| 1045 | |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 1046 | static int __init reipl_ccw_init(void) |
| 1047 | { |
| 1048 | int rc; |
| 1049 | |
| 1050 | reipl_block_ccw = (void *) get_zeroed_page(GFP_KERNEL); |
| 1051 | if (!reipl_block_ccw) |
| 1052 | return -ENOMEM; |
Hendrik Brueckner | a0443fb | 2008-07-14 09:59:09 +0200 | [diff] [blame^] | 1053 | |
| 1054 | if (MACHINE_IS_VM) { |
| 1055 | if (!diag308_set_works) |
| 1056 | sys_reipl_ccw_vmparm_attr.attr.mode = S_IRUGO; |
| 1057 | rc = sysfs_create_group(&reipl_kset->kobj, |
| 1058 | &reipl_ccw_attr_group_vm); |
| 1059 | } else { |
| 1060 | if(!diag308_set_works) |
| 1061 | sys_reipl_ccw_loadparm_attr.attr.mode = S_IRUGO; |
| 1062 | rc = sysfs_create_group(&reipl_kset->kobj, |
| 1063 | &reipl_ccw_attr_group_lpar); |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 1064 | } |
Hendrik Brueckner | a0443fb | 2008-07-14 09:59:09 +0200 | [diff] [blame^] | 1065 | if (rc) |
| 1066 | return rc; |
| 1067 | |
| 1068 | reipl_block_ccw_init(reipl_block_ccw); |
| 1069 | if (ipl_info.type == IPL_TYPE_CCW) { |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 1070 | reipl_block_ccw->ipl_info.ccw.devno = ipl_devno; |
Hendrik Brueckner | a0443fb | 2008-07-14 09:59:09 +0200 | [diff] [blame^] | 1071 | reipl_block_ccw_fill_parms(reipl_block_ccw); |
| 1072 | } |
| 1073 | |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 1074 | reipl_capabilities |= IPL_TYPE_CCW; |
| 1075 | return 0; |
| 1076 | } |
| 1077 | |
| 1078 | static int __init reipl_fcp_init(void) |
| 1079 | { |
| 1080 | int rc; |
| 1081 | |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 1082 | if ((!diag308_set_works) && (ipl_info.type != IPL_TYPE_FCP)) |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 1083 | return 0; |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 1084 | if ((!diag308_set_works) && (ipl_info.type == IPL_TYPE_FCP)) |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 1085 | make_attrs_ro(reipl_fcp_attrs); |
| 1086 | |
| 1087 | reipl_block_fcp = (void *) get_zeroed_page(GFP_KERNEL); |
| 1088 | if (!reipl_block_fcp) |
| 1089 | return -ENOMEM; |
Greg Kroah-Hartman | d91885b | 2007-11-02 17:17:00 -0400 | [diff] [blame] | 1090 | rc = sysfs_create_group(&reipl_kset->kobj, &reipl_fcp_attr_group); |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 1091 | if (rc) { |
| 1092 | free_page((unsigned long)reipl_block_fcp); |
| 1093 | return rc; |
| 1094 | } |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 1095 | if (ipl_info.type == IPL_TYPE_FCP) { |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 1096 | memcpy(reipl_block_fcp, IPL_PARMBLOCK_START, PAGE_SIZE); |
| 1097 | } else { |
| 1098 | reipl_block_fcp->hdr.len = IPL_PARM_BLK_FCP_LEN; |
| 1099 | reipl_block_fcp->hdr.version = IPL_PARM_BLOCK_VERSION; |
Michael Holzheu | fbb04f3 | 2007-03-19 13:19:03 +0100 | [diff] [blame] | 1100 | reipl_block_fcp->hdr.blk0_len = IPL_PARM_BLK0_FCP_LEN; |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 1101 | reipl_block_fcp->hdr.pbt = DIAG308_IPL_TYPE_FCP; |
| 1102 | reipl_block_fcp->ipl_info.fcp.opt = DIAG308_IPL_OPT_IPL; |
| 1103 | } |
| 1104 | reipl_capabilities |= IPL_TYPE_FCP; |
| 1105 | return 0; |
| 1106 | } |
| 1107 | |
Heiko Carstens | 2bc89b5 | 2008-02-05 16:50:40 +0100 | [diff] [blame] | 1108 | static int __init reipl_init(void) |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 1109 | { |
| 1110 | int rc; |
| 1111 | |
Greg Kroah-Hartman | f62ed9e | 2007-11-05 13:16:15 -0800 | [diff] [blame] | 1112 | reipl_kset = kset_create_and_add("reipl", NULL, firmware_kobj); |
Greg Kroah-Hartman | d91885b | 2007-11-02 17:17:00 -0400 | [diff] [blame] | 1113 | if (!reipl_kset) |
| 1114 | return -ENOMEM; |
| 1115 | rc = sysfs_create_file(&reipl_kset->kobj, &reipl_type_attr.attr); |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 1116 | if (rc) { |
Greg Kroah-Hartman | d91885b | 2007-11-02 17:17:00 -0400 | [diff] [blame] | 1117 | kset_unregister(reipl_kset); |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 1118 | return rc; |
| 1119 | } |
| 1120 | rc = reipl_ccw_init(); |
| 1121 | if (rc) |
| 1122 | return rc; |
| 1123 | rc = reipl_fcp_init(); |
| 1124 | if (rc) |
| 1125 | return rc; |
Hongjie Yang | fe355b7 | 2007-02-05 21:18:24 +0100 | [diff] [blame] | 1126 | rc = reipl_nss_init(); |
| 1127 | if (rc) |
| 1128 | return rc; |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 1129 | rc = reipl_set_type(ipl_info.type); |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 1130 | if (rc) |
| 1131 | return rc; |
| 1132 | return 0; |
| 1133 | } |
| 1134 | |
Heiko Carstens | 2bc89b5 | 2008-02-05 16:50:40 +0100 | [diff] [blame] | 1135 | static struct shutdown_action __refdata reipl_action = { |
| 1136 | .name = SHUTDOWN_ACTION_REIPL_STR, |
| 1137 | .fn = reipl_run, |
| 1138 | .init = reipl_init, |
| 1139 | }; |
Michael Holzheu | 99ca4e5 | 2008-01-26 14:11:11 +0100 | [diff] [blame] | 1140 | |
| 1141 | /* |
| 1142 | * dump shutdown action: Dump Linux on shutdown. |
| 1143 | */ |
| 1144 | |
| 1145 | /* FCP dump device attributes */ |
| 1146 | |
| 1147 | DEFINE_IPL_ATTR_RW(dump_fcp, wwpn, "0x%016llx\n", "%016llx\n", |
| 1148 | dump_block_fcp->ipl_info.fcp.wwpn); |
| 1149 | DEFINE_IPL_ATTR_RW(dump_fcp, lun, "0x%016llx\n", "%016llx\n", |
| 1150 | dump_block_fcp->ipl_info.fcp.lun); |
| 1151 | DEFINE_IPL_ATTR_RW(dump_fcp, bootprog, "%lld\n", "%lld\n", |
| 1152 | dump_block_fcp->ipl_info.fcp.bootprog); |
| 1153 | DEFINE_IPL_ATTR_RW(dump_fcp, br_lba, "%lld\n", "%lld\n", |
| 1154 | dump_block_fcp->ipl_info.fcp.br_lba); |
| 1155 | DEFINE_IPL_ATTR_RW(dump_fcp, device, "0.0.%04llx\n", "0.0.%llx\n", |
| 1156 | dump_block_fcp->ipl_info.fcp.devno); |
| 1157 | |
| 1158 | static struct attribute *dump_fcp_attrs[] = { |
| 1159 | &sys_dump_fcp_device_attr.attr, |
| 1160 | &sys_dump_fcp_wwpn_attr.attr, |
| 1161 | &sys_dump_fcp_lun_attr.attr, |
| 1162 | &sys_dump_fcp_bootprog_attr.attr, |
| 1163 | &sys_dump_fcp_br_lba_attr.attr, |
| 1164 | NULL, |
| 1165 | }; |
| 1166 | |
| 1167 | static struct attribute_group dump_fcp_attr_group = { |
| 1168 | .name = IPL_FCP_STR, |
| 1169 | .attrs = dump_fcp_attrs, |
| 1170 | }; |
| 1171 | |
| 1172 | /* CCW dump device attributes */ |
| 1173 | |
| 1174 | DEFINE_IPL_ATTR_RW(dump_ccw, device, "0.0.%04llx\n", "0.0.%llx\n", |
| 1175 | dump_block_ccw->ipl_info.ccw.devno); |
| 1176 | |
| 1177 | static struct attribute *dump_ccw_attrs[] = { |
| 1178 | &sys_dump_ccw_device_attr.attr, |
| 1179 | NULL, |
| 1180 | }; |
| 1181 | |
| 1182 | static struct attribute_group dump_ccw_attr_group = { |
| 1183 | .name = IPL_CCW_STR, |
| 1184 | .attrs = dump_ccw_attrs, |
| 1185 | }; |
| 1186 | |
| 1187 | /* dump type */ |
| 1188 | |
| 1189 | static int dump_set_type(enum dump_type type) |
| 1190 | { |
| 1191 | if (!(dump_capabilities & type)) |
| 1192 | return -EINVAL; |
| 1193 | switch (type) { |
| 1194 | case DUMP_TYPE_CCW: |
Michael Holzheu | 48657d2 | 2008-01-26 14:11:17 +0100 | [diff] [blame] | 1195 | if (diag308_set_works) |
| 1196 | dump_method = DUMP_METHOD_CCW_DIAG; |
| 1197 | else if (MACHINE_IS_VM) |
Michael Holzheu | 99ca4e5 | 2008-01-26 14:11:11 +0100 | [diff] [blame] | 1198 | dump_method = DUMP_METHOD_CCW_VM; |
| 1199 | else |
| 1200 | dump_method = DUMP_METHOD_CCW_CIO; |
| 1201 | break; |
| 1202 | case DUMP_TYPE_FCP: |
| 1203 | dump_method = DUMP_METHOD_FCP_DIAG; |
| 1204 | break; |
| 1205 | default: |
| 1206 | dump_method = DUMP_METHOD_NONE; |
| 1207 | } |
| 1208 | dump_type = type; |
| 1209 | return 0; |
| 1210 | } |
| 1211 | |
| 1212 | static ssize_t dump_type_show(struct kobject *kobj, |
| 1213 | struct kobj_attribute *attr, char *page) |
| 1214 | { |
| 1215 | return sprintf(page, "%s\n", dump_type_str(dump_type)); |
| 1216 | } |
| 1217 | |
| 1218 | static ssize_t dump_type_store(struct kobject *kobj, |
| 1219 | struct kobj_attribute *attr, |
| 1220 | const char *buf, size_t len) |
| 1221 | { |
| 1222 | int rc = -EINVAL; |
| 1223 | |
| 1224 | if (strncmp(buf, DUMP_NONE_STR, strlen(DUMP_NONE_STR)) == 0) |
| 1225 | rc = dump_set_type(DUMP_TYPE_NONE); |
| 1226 | else if (strncmp(buf, DUMP_CCW_STR, strlen(DUMP_CCW_STR)) == 0) |
| 1227 | rc = dump_set_type(DUMP_TYPE_CCW); |
| 1228 | else if (strncmp(buf, DUMP_FCP_STR, strlen(DUMP_FCP_STR)) == 0) |
| 1229 | rc = dump_set_type(DUMP_TYPE_FCP); |
| 1230 | return (rc != 0) ? rc : len; |
| 1231 | } |
| 1232 | |
| 1233 | static struct kobj_attribute dump_type_attr = |
| 1234 | __ATTR(dump_type, 0644, dump_type_show, dump_type_store); |
| 1235 | |
| 1236 | static struct kset *dump_kset; |
| 1237 | |
| 1238 | static void dump_run(struct shutdown_trigger *trigger) |
| 1239 | { |
| 1240 | struct ccw_dev_id devid; |
| 1241 | static char buf[100]; |
| 1242 | |
| 1243 | switch (dump_method) { |
| 1244 | case DUMP_METHOD_CCW_CIO: |
| 1245 | smp_send_stop(); |
| 1246 | devid.devno = dump_block_ccw->ipl_info.ccw.devno; |
| 1247 | devid.ssid = 0; |
| 1248 | reipl_ccw_dev(&devid); |
| 1249 | break; |
| 1250 | case DUMP_METHOD_CCW_VM: |
| 1251 | smp_send_stop(); |
| 1252 | sprintf(buf, "STORE STATUS"); |
| 1253 | __cpcmd(buf, NULL, 0, NULL); |
| 1254 | sprintf(buf, "IPL %X", dump_block_ccw->ipl_info.ccw.devno); |
| 1255 | __cpcmd(buf, NULL, 0, NULL); |
| 1256 | break; |
| 1257 | case DUMP_METHOD_CCW_DIAG: |
| 1258 | diag308(DIAG308_SET, dump_block_ccw); |
| 1259 | diag308(DIAG308_DUMP, NULL); |
| 1260 | break; |
| 1261 | case DUMP_METHOD_FCP_DIAG: |
| 1262 | diag308(DIAG308_SET, dump_block_fcp); |
| 1263 | diag308(DIAG308_DUMP, NULL); |
| 1264 | break; |
| 1265 | case DUMP_METHOD_NONE: |
| 1266 | default: |
| 1267 | return; |
| 1268 | } |
| 1269 | printk(KERN_EMERG "Dump failed!\n"); |
| 1270 | } |
| 1271 | |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 1272 | static int __init dump_ccw_init(void) |
| 1273 | { |
| 1274 | int rc; |
| 1275 | |
| 1276 | dump_block_ccw = (void *) get_zeroed_page(GFP_KERNEL); |
| 1277 | if (!dump_block_ccw) |
| 1278 | return -ENOMEM; |
Greg Kroah-Hartman | d91885b | 2007-11-02 17:17:00 -0400 | [diff] [blame] | 1279 | rc = sysfs_create_group(&dump_kset->kobj, &dump_ccw_attr_group); |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 1280 | if (rc) { |
| 1281 | free_page((unsigned long)dump_block_ccw); |
| 1282 | return rc; |
| 1283 | } |
| 1284 | dump_block_ccw->hdr.len = IPL_PARM_BLK_CCW_LEN; |
| 1285 | dump_block_ccw->hdr.version = IPL_PARM_BLOCK_VERSION; |
Michael Holzheu | fbb04f3 | 2007-03-19 13:19:03 +0100 | [diff] [blame] | 1286 | dump_block_ccw->hdr.blk0_len = IPL_PARM_BLK0_CCW_LEN; |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 1287 | dump_block_ccw->hdr.pbt = DIAG308_IPL_TYPE_CCW; |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 1288 | dump_capabilities |= DUMP_TYPE_CCW; |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 1289 | return 0; |
| 1290 | } |
| 1291 | |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 1292 | static int __init dump_fcp_init(void) |
| 1293 | { |
| 1294 | int rc; |
| 1295 | |
Heiko Carstens | 05dd253 | 2007-07-10 11:24:09 +0200 | [diff] [blame] | 1296 | if (!sclp_ipl_info.has_dump) |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 1297 | return 0; /* LDIPL DUMP is not installed */ |
| 1298 | if (!diag308_set_works) |
| 1299 | return 0; |
| 1300 | dump_block_fcp = (void *) get_zeroed_page(GFP_KERNEL); |
| 1301 | if (!dump_block_fcp) |
| 1302 | return -ENOMEM; |
Greg Kroah-Hartman | d91885b | 2007-11-02 17:17:00 -0400 | [diff] [blame] | 1303 | rc = sysfs_create_group(&dump_kset->kobj, &dump_fcp_attr_group); |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 1304 | if (rc) { |
| 1305 | free_page((unsigned long)dump_block_fcp); |
| 1306 | return rc; |
| 1307 | } |
| 1308 | dump_block_fcp->hdr.len = IPL_PARM_BLK_FCP_LEN; |
| 1309 | dump_block_fcp->hdr.version = IPL_PARM_BLOCK_VERSION; |
Michael Holzheu | fbb04f3 | 2007-03-19 13:19:03 +0100 | [diff] [blame] | 1310 | dump_block_fcp->hdr.blk0_len = IPL_PARM_BLK0_FCP_LEN; |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 1311 | dump_block_fcp->hdr.pbt = DIAG308_IPL_TYPE_FCP; |
| 1312 | dump_block_fcp->ipl_info.fcp.opt = DIAG308_IPL_OPT_DUMP; |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 1313 | dump_capabilities |= DUMP_TYPE_FCP; |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 1314 | return 0; |
| 1315 | } |
| 1316 | |
Heiko Carstens | 2bc89b5 | 2008-02-05 16:50:40 +0100 | [diff] [blame] | 1317 | static int __init dump_init(void) |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 1318 | { |
| 1319 | int rc; |
| 1320 | |
Greg Kroah-Hartman | f62ed9e | 2007-11-05 13:16:15 -0800 | [diff] [blame] | 1321 | dump_kset = kset_create_and_add("dump", NULL, firmware_kobj); |
Greg Kroah-Hartman | d91885b | 2007-11-02 17:17:00 -0400 | [diff] [blame] | 1322 | if (!dump_kset) |
| 1323 | return -ENOMEM; |
Michael Holzheu | 99ca4e5 | 2008-01-26 14:11:11 +0100 | [diff] [blame] | 1324 | rc = sysfs_create_file(&dump_kset->kobj, &dump_type_attr.attr); |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 1325 | if (rc) { |
Greg Kroah-Hartman | d91885b | 2007-11-02 17:17:00 -0400 | [diff] [blame] | 1326 | kset_unregister(dump_kset); |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 1327 | return rc; |
| 1328 | } |
| 1329 | rc = dump_ccw_init(); |
| 1330 | if (rc) |
| 1331 | return rc; |
| 1332 | rc = dump_fcp_init(); |
| 1333 | if (rc) |
| 1334 | return rc; |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 1335 | dump_set_type(DUMP_TYPE_NONE); |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 1336 | return 0; |
| 1337 | } |
| 1338 | |
Heiko Carstens | 2bc89b5 | 2008-02-05 16:50:40 +0100 | [diff] [blame] | 1339 | static struct shutdown_action __refdata dump_action = { |
| 1340 | .name = SHUTDOWN_ACTION_DUMP_STR, |
| 1341 | .fn = dump_run, |
| 1342 | .init = dump_init, |
| 1343 | }; |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 1344 | |
Michael Holzheu | 99ca4e5 | 2008-01-26 14:11:11 +0100 | [diff] [blame] | 1345 | /* |
| 1346 | * vmcmd shutdown action: Trigger vm command on shutdown. |
| 1347 | */ |
| 1348 | |
| 1349 | static char vmcmd_on_reboot[128]; |
| 1350 | static char vmcmd_on_panic[128]; |
| 1351 | static char vmcmd_on_halt[128]; |
| 1352 | static char vmcmd_on_poff[128]; |
| 1353 | |
| 1354 | DEFINE_IPL_ATTR_STR_RW(vmcmd, on_reboot, "%s\n", "%s\n", vmcmd_on_reboot); |
| 1355 | DEFINE_IPL_ATTR_STR_RW(vmcmd, on_panic, "%s\n", "%s\n", vmcmd_on_panic); |
| 1356 | DEFINE_IPL_ATTR_STR_RW(vmcmd, on_halt, "%s\n", "%s\n", vmcmd_on_halt); |
| 1357 | DEFINE_IPL_ATTR_STR_RW(vmcmd, on_poff, "%s\n", "%s\n", vmcmd_on_poff); |
| 1358 | |
| 1359 | static struct attribute *vmcmd_attrs[] = { |
| 1360 | &sys_vmcmd_on_reboot_attr.attr, |
| 1361 | &sys_vmcmd_on_panic_attr.attr, |
| 1362 | &sys_vmcmd_on_halt_attr.attr, |
| 1363 | &sys_vmcmd_on_poff_attr.attr, |
| 1364 | NULL, |
| 1365 | }; |
| 1366 | |
| 1367 | static struct attribute_group vmcmd_attr_group = { |
| 1368 | .attrs = vmcmd_attrs, |
| 1369 | }; |
| 1370 | |
| 1371 | static struct kset *vmcmd_kset; |
| 1372 | |
| 1373 | static void vmcmd_run(struct shutdown_trigger *trigger) |
| 1374 | { |
| 1375 | char *cmd, *next_cmd; |
| 1376 | |
| 1377 | if (strcmp(trigger->name, ON_REIPL_STR) == 0) |
| 1378 | cmd = vmcmd_on_reboot; |
| 1379 | else if (strcmp(trigger->name, ON_PANIC_STR) == 0) |
| 1380 | cmd = vmcmd_on_panic; |
| 1381 | else if (strcmp(trigger->name, ON_HALT_STR) == 0) |
| 1382 | cmd = vmcmd_on_halt; |
| 1383 | else if (strcmp(trigger->name, ON_POFF_STR) == 0) |
| 1384 | cmd = vmcmd_on_poff; |
| 1385 | else |
| 1386 | return; |
| 1387 | |
| 1388 | if (strlen(cmd) == 0) |
| 1389 | return; |
| 1390 | do { |
| 1391 | next_cmd = strchr(cmd, '\n'); |
| 1392 | if (next_cmd) { |
| 1393 | next_cmd[0] = 0; |
| 1394 | next_cmd += 1; |
| 1395 | } |
| 1396 | __cpcmd(cmd, NULL, 0, NULL); |
| 1397 | cmd = next_cmd; |
| 1398 | } while (cmd != NULL); |
| 1399 | } |
| 1400 | |
| 1401 | static int vmcmd_init(void) |
| 1402 | { |
| 1403 | if (!MACHINE_IS_VM) |
| 1404 | return -ENOTSUPP; |
| 1405 | vmcmd_kset = kset_create_and_add("vmcmd", NULL, firmware_kobj); |
| 1406 | if (!vmcmd_kset) |
| 1407 | return -ENOMEM; |
| 1408 | return sysfs_create_group(&vmcmd_kset->kobj, &vmcmd_attr_group); |
| 1409 | } |
| 1410 | |
| 1411 | static struct shutdown_action vmcmd_action = {SHUTDOWN_ACTION_VMCMD_STR, |
| 1412 | vmcmd_run, vmcmd_init}; |
| 1413 | |
| 1414 | /* |
| 1415 | * stop shutdown action: Stop Linux on shutdown. |
| 1416 | */ |
| 1417 | |
| 1418 | static void stop_run(struct shutdown_trigger *trigger) |
| 1419 | { |
Michael Holzheu | c654749 | 2008-01-26 14:11:12 +0100 | [diff] [blame] | 1420 | if (strcmp(trigger->name, ON_PANIC_STR) == 0) |
| 1421 | disabled_wait((unsigned long) __builtin_return_address(0)); |
| 1422 | else { |
| 1423 | signal_processor(smp_processor_id(), sigp_stop); |
| 1424 | for (;;); |
| 1425 | } |
Michael Holzheu | 99ca4e5 | 2008-01-26 14:11:11 +0100 | [diff] [blame] | 1426 | } |
| 1427 | |
| 1428 | static struct shutdown_action stop_action = {SHUTDOWN_ACTION_STOP_STR, |
| 1429 | stop_run, NULL}; |
| 1430 | |
| 1431 | /* action list */ |
| 1432 | |
| 1433 | static struct shutdown_action *shutdown_actions_list[] = { |
| 1434 | &ipl_action, &reipl_action, &dump_action, &vmcmd_action, &stop_action}; |
| 1435 | #define SHUTDOWN_ACTIONS_COUNT (sizeof(shutdown_actions_list) / sizeof(void *)) |
| 1436 | |
| 1437 | /* |
| 1438 | * Trigger section |
| 1439 | */ |
| 1440 | |
| 1441 | static struct kset *shutdown_actions_kset; |
| 1442 | |
| 1443 | static int set_trigger(const char *buf, struct shutdown_trigger *trigger, |
| 1444 | size_t len) |
| 1445 | { |
| 1446 | int i; |
| 1447 | for (i = 0; i < SHUTDOWN_ACTIONS_COUNT; i++) { |
| 1448 | if (!shutdown_actions_list[i]) |
| 1449 | continue; |
| 1450 | if (strncmp(buf, shutdown_actions_list[i]->name, |
| 1451 | strlen(shutdown_actions_list[i]->name)) == 0) { |
| 1452 | trigger->action = shutdown_actions_list[i]; |
| 1453 | return len; |
| 1454 | } |
| 1455 | } |
| 1456 | return -EINVAL; |
| 1457 | } |
| 1458 | |
| 1459 | /* on reipl */ |
| 1460 | |
| 1461 | static struct shutdown_trigger on_reboot_trigger = {ON_REIPL_STR, |
| 1462 | &reipl_action}; |
| 1463 | |
| 1464 | static ssize_t on_reboot_show(struct kobject *kobj, |
| 1465 | struct kobj_attribute *attr, char *page) |
| 1466 | { |
| 1467 | return sprintf(page, "%s\n", on_reboot_trigger.action->name); |
| 1468 | } |
| 1469 | |
| 1470 | static ssize_t on_reboot_store(struct kobject *kobj, |
| 1471 | struct kobj_attribute *attr, |
| 1472 | const char *buf, size_t len) |
| 1473 | { |
| 1474 | return set_trigger(buf, &on_reboot_trigger, len); |
| 1475 | } |
| 1476 | |
| 1477 | static struct kobj_attribute on_reboot_attr = |
| 1478 | __ATTR(on_reboot, 0644, on_reboot_show, on_reboot_store); |
| 1479 | |
| 1480 | static void do_machine_restart(char *__unused) |
| 1481 | { |
| 1482 | smp_send_stop(); |
| 1483 | on_reboot_trigger.action->fn(&on_reboot_trigger); |
| 1484 | reipl_run(NULL); |
| 1485 | } |
| 1486 | void (*_machine_restart)(char *command) = do_machine_restart; |
| 1487 | |
| 1488 | /* on panic */ |
| 1489 | |
| 1490 | static struct shutdown_trigger on_panic_trigger = {ON_PANIC_STR, &stop_action}; |
| 1491 | |
| 1492 | static ssize_t on_panic_show(struct kobject *kobj, |
| 1493 | struct kobj_attribute *attr, char *page) |
| 1494 | { |
| 1495 | return sprintf(page, "%s\n", on_panic_trigger.action->name); |
| 1496 | } |
| 1497 | |
| 1498 | static ssize_t on_panic_store(struct kobject *kobj, |
| 1499 | struct kobj_attribute *attr, |
| 1500 | const char *buf, size_t len) |
| 1501 | { |
| 1502 | return set_trigger(buf, &on_panic_trigger, len); |
| 1503 | } |
| 1504 | |
| 1505 | static struct kobj_attribute on_panic_attr = |
| 1506 | __ATTR(on_panic, 0644, on_panic_show, on_panic_store); |
| 1507 | |
| 1508 | static void do_panic(void) |
| 1509 | { |
| 1510 | on_panic_trigger.action->fn(&on_panic_trigger); |
| 1511 | stop_run(&on_panic_trigger); |
| 1512 | } |
| 1513 | |
| 1514 | /* on halt */ |
| 1515 | |
| 1516 | static struct shutdown_trigger on_halt_trigger = {ON_HALT_STR, &stop_action}; |
| 1517 | |
| 1518 | static ssize_t on_halt_show(struct kobject *kobj, |
| 1519 | struct kobj_attribute *attr, char *page) |
| 1520 | { |
| 1521 | return sprintf(page, "%s\n", on_halt_trigger.action->name); |
| 1522 | } |
| 1523 | |
| 1524 | static ssize_t on_halt_store(struct kobject *kobj, |
| 1525 | struct kobj_attribute *attr, |
| 1526 | const char *buf, size_t len) |
| 1527 | { |
| 1528 | return set_trigger(buf, &on_halt_trigger, len); |
| 1529 | } |
| 1530 | |
| 1531 | static struct kobj_attribute on_halt_attr = |
| 1532 | __ATTR(on_halt, 0644, on_halt_show, on_halt_store); |
| 1533 | |
| 1534 | |
| 1535 | static void do_machine_halt(void) |
| 1536 | { |
| 1537 | smp_send_stop(); |
| 1538 | on_halt_trigger.action->fn(&on_halt_trigger); |
| 1539 | stop_run(&on_halt_trigger); |
| 1540 | } |
| 1541 | void (*_machine_halt)(void) = do_machine_halt; |
| 1542 | |
| 1543 | /* on power off */ |
| 1544 | |
| 1545 | static struct shutdown_trigger on_poff_trigger = {ON_POFF_STR, &stop_action}; |
| 1546 | |
| 1547 | static ssize_t on_poff_show(struct kobject *kobj, |
| 1548 | struct kobj_attribute *attr, char *page) |
| 1549 | { |
| 1550 | return sprintf(page, "%s\n", on_poff_trigger.action->name); |
| 1551 | } |
| 1552 | |
| 1553 | static ssize_t on_poff_store(struct kobject *kobj, |
| 1554 | struct kobj_attribute *attr, |
| 1555 | const char *buf, size_t len) |
| 1556 | { |
| 1557 | return set_trigger(buf, &on_poff_trigger, len); |
| 1558 | } |
| 1559 | |
| 1560 | static struct kobj_attribute on_poff_attr = |
| 1561 | __ATTR(on_poff, 0644, on_poff_show, on_poff_store); |
| 1562 | |
| 1563 | |
| 1564 | static void do_machine_power_off(void) |
| 1565 | { |
| 1566 | smp_send_stop(); |
| 1567 | on_poff_trigger.action->fn(&on_poff_trigger); |
| 1568 | stop_run(&on_poff_trigger); |
| 1569 | } |
| 1570 | void (*_machine_power_off)(void) = do_machine_power_off; |
| 1571 | |
| 1572 | static void __init shutdown_triggers_init(void) |
| 1573 | { |
Greg Kroah-Hartman | d91885b | 2007-11-02 17:17:00 -0400 | [diff] [blame] | 1574 | shutdown_actions_kset = kset_create_and_add("shutdown_actions", NULL, |
Greg Kroah-Hartman | f62ed9e | 2007-11-05 13:16:15 -0800 | [diff] [blame] | 1575 | firmware_kobj); |
Greg Kroah-Hartman | d91885b | 2007-11-02 17:17:00 -0400 | [diff] [blame] | 1576 | if (!shutdown_actions_kset) |
Michael Holzheu | 99ca4e5 | 2008-01-26 14:11:11 +0100 | [diff] [blame] | 1577 | goto fail; |
| 1578 | if (sysfs_create_file(&shutdown_actions_kset->kobj, |
| 1579 | &on_reboot_attr.attr)) |
| 1580 | goto fail; |
| 1581 | if (sysfs_create_file(&shutdown_actions_kset->kobj, |
| 1582 | &on_panic_attr.attr)) |
| 1583 | goto fail; |
| 1584 | if (sysfs_create_file(&shutdown_actions_kset->kobj, |
| 1585 | &on_halt_attr.attr)) |
| 1586 | goto fail; |
| 1587 | if (sysfs_create_file(&shutdown_actions_kset->kobj, |
| 1588 | &on_poff_attr.attr)) |
| 1589 | goto fail; |
| 1590 | |
| 1591 | return; |
| 1592 | fail: |
| 1593 | panic("shutdown_triggers_init failed\n"); |
| 1594 | } |
| 1595 | |
| 1596 | static void __init shutdown_actions_init(void) |
| 1597 | { |
| 1598 | int i; |
| 1599 | |
| 1600 | for (i = 0; i < SHUTDOWN_ACTIONS_COUNT; i++) { |
| 1601 | if (!shutdown_actions_list[i]->init) |
| 1602 | continue; |
| 1603 | if (shutdown_actions_list[i]->init()) |
| 1604 | shutdown_actions_list[i] = NULL; |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 1605 | } |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 1606 | } |
| 1607 | |
| 1608 | static int __init s390_ipl_init(void) |
| 1609 | { |
Michael Holzheu | d09293a | 2008-01-26 14:11:15 +0100 | [diff] [blame] | 1610 | sclp_get_ipl_info(&sclp_ipl_info); |
Michael Holzheu | 99ca4e5 | 2008-01-26 14:11:11 +0100 | [diff] [blame] | 1611 | shutdown_actions_init(); |
| 1612 | shutdown_triggers_init(); |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 1613 | return 0; |
| 1614 | } |
| 1615 | |
| 1616 | __initcall(s390_ipl_init); |
Heiko Carstens | 15e9b58 | 2006-12-04 15:40:26 +0100 | [diff] [blame] | 1617 | |
Michael Holzheu | 99ca4e5 | 2008-01-26 14:11:11 +0100 | [diff] [blame] | 1618 | static void __init strncpy_skip_quote(char *dst, char *src, int n) |
| 1619 | { |
| 1620 | int sx, dx; |
| 1621 | |
| 1622 | dx = 0; |
| 1623 | for (sx = 0; src[sx] != 0; sx++) { |
| 1624 | if (src[sx] == '"') |
| 1625 | continue; |
| 1626 | dst[dx++] = src[sx]; |
| 1627 | if (dx >= n) |
| 1628 | break; |
| 1629 | } |
| 1630 | } |
| 1631 | |
| 1632 | static int __init vmcmd_on_reboot_setup(char *str) |
| 1633 | { |
| 1634 | if (!MACHINE_IS_VM) |
| 1635 | return 1; |
| 1636 | strncpy_skip_quote(vmcmd_on_reboot, str, 127); |
| 1637 | vmcmd_on_reboot[127] = 0; |
| 1638 | on_reboot_trigger.action = &vmcmd_action; |
| 1639 | return 1; |
| 1640 | } |
| 1641 | __setup("vmreboot=", vmcmd_on_reboot_setup); |
| 1642 | |
| 1643 | static int __init vmcmd_on_panic_setup(char *str) |
| 1644 | { |
| 1645 | if (!MACHINE_IS_VM) |
| 1646 | return 1; |
| 1647 | strncpy_skip_quote(vmcmd_on_panic, str, 127); |
| 1648 | vmcmd_on_panic[127] = 0; |
| 1649 | on_panic_trigger.action = &vmcmd_action; |
| 1650 | return 1; |
| 1651 | } |
| 1652 | __setup("vmpanic=", vmcmd_on_panic_setup); |
| 1653 | |
| 1654 | static int __init vmcmd_on_halt_setup(char *str) |
| 1655 | { |
| 1656 | if (!MACHINE_IS_VM) |
| 1657 | return 1; |
| 1658 | strncpy_skip_quote(vmcmd_on_halt, str, 127); |
| 1659 | vmcmd_on_halt[127] = 0; |
| 1660 | on_halt_trigger.action = &vmcmd_action; |
| 1661 | return 1; |
| 1662 | } |
| 1663 | __setup("vmhalt=", vmcmd_on_halt_setup); |
| 1664 | |
| 1665 | static int __init vmcmd_on_poff_setup(char *str) |
| 1666 | { |
| 1667 | if (!MACHINE_IS_VM) |
| 1668 | return 1; |
| 1669 | strncpy_skip_quote(vmcmd_on_poff, str, 127); |
| 1670 | vmcmd_on_poff[127] = 0; |
| 1671 | on_poff_trigger.action = &vmcmd_action; |
| 1672 | return 1; |
| 1673 | } |
| 1674 | __setup("vmpoff=", vmcmd_on_poff_setup); |
| 1675 | |
| 1676 | static int on_panic_notify(struct notifier_block *self, |
| 1677 | unsigned long event, void *data) |
| 1678 | { |
| 1679 | do_panic(); |
| 1680 | return NOTIFY_OK; |
| 1681 | } |
| 1682 | |
| 1683 | static struct notifier_block on_panic_nb = { |
| 1684 | .notifier_call = on_panic_notify, |
| 1685 | .priority = 0, |
| 1686 | }; |
| 1687 | |
| 1688 | void __init setup_ipl(void) |
| 1689 | { |
| 1690 | ipl_info.type = get_ipl_type(); |
| 1691 | switch (ipl_info.type) { |
| 1692 | case IPL_TYPE_CCW: |
| 1693 | ipl_info.data.ccw.dev_id.devno = ipl_devno; |
| 1694 | ipl_info.data.ccw.dev_id.ssid = 0; |
| 1695 | break; |
| 1696 | case IPL_TYPE_FCP: |
| 1697 | case IPL_TYPE_FCP_DUMP: |
| 1698 | ipl_info.data.fcp.dev_id.devno = |
| 1699 | IPL_PARMBLOCK_START->ipl_info.fcp.devno; |
| 1700 | ipl_info.data.fcp.dev_id.ssid = 0; |
| 1701 | ipl_info.data.fcp.wwpn = IPL_PARMBLOCK_START->ipl_info.fcp.wwpn; |
| 1702 | ipl_info.data.fcp.lun = IPL_PARMBLOCK_START->ipl_info.fcp.lun; |
| 1703 | break; |
| 1704 | case IPL_TYPE_NSS: |
| 1705 | strncpy(ipl_info.data.nss.name, kernel_nss_name, |
| 1706 | sizeof(ipl_info.data.nss.name)); |
| 1707 | break; |
| 1708 | case IPL_TYPE_UNKNOWN: |
| 1709 | default: |
| 1710 | /* We have no info to copy */ |
| 1711 | break; |
| 1712 | } |
| 1713 | atomic_notifier_chain_register(&panic_notifier_list, &on_panic_nb); |
| 1714 | } |
| 1715 | |
Hendrik Brueckner | a0443fb | 2008-07-14 09:59:09 +0200 | [diff] [blame^] | 1716 | void __init ipl_update_parameters(void) |
| 1717 | { |
| 1718 | if (diag308(DIAG308_STORE, &ipl_block) == DIAG308_RC_OK) |
| 1719 | diag308_set_works = 1; |
| 1720 | } |
| 1721 | |
Heiko Carstens | 6fc321f | 2007-04-27 16:01:25 +0200 | [diff] [blame] | 1722 | void __init ipl_save_parameters(void) |
| 1723 | { |
| 1724 | struct cio_iplinfo iplinfo; |
| 1725 | unsigned int *ipl_ptr; |
| 1726 | void *src, *dst; |
| 1727 | |
| 1728 | if (cio_get_iplinfo(&iplinfo)) |
| 1729 | return; |
| 1730 | |
| 1731 | ipl_devno = iplinfo.devno; |
| 1732 | ipl_flags |= IPL_DEVNO_VALID; |
| 1733 | if (!iplinfo.is_qdio) |
| 1734 | return; |
| 1735 | ipl_flags |= IPL_PARMBLOCK_VALID; |
| 1736 | ipl_ptr = (unsigned int *)__LC_IPL_PARMBLOCK_PTR; |
| 1737 | src = (void *)(unsigned long)*ipl_ptr; |
| 1738 | dst = (void *)IPL_PARMBLOCK_ORIGIN; |
| 1739 | memmove(dst, src, PAGE_SIZE); |
| 1740 | *ipl_ptr = IPL_PARMBLOCK_ORIGIN; |
| 1741 | } |
| 1742 | |
Heiko Carstens | 15e9b58 | 2006-12-04 15:40:26 +0100 | [diff] [blame] | 1743 | static LIST_HEAD(rcall); |
| 1744 | static DEFINE_MUTEX(rcall_mutex); |
| 1745 | |
| 1746 | void register_reset_call(struct reset_call *reset) |
| 1747 | { |
| 1748 | mutex_lock(&rcall_mutex); |
| 1749 | list_add(&reset->list, &rcall); |
| 1750 | mutex_unlock(&rcall_mutex); |
| 1751 | } |
| 1752 | EXPORT_SYMBOL_GPL(register_reset_call); |
| 1753 | |
| 1754 | void unregister_reset_call(struct reset_call *reset) |
| 1755 | { |
| 1756 | mutex_lock(&rcall_mutex); |
| 1757 | list_del(&reset->list); |
| 1758 | mutex_unlock(&rcall_mutex); |
| 1759 | } |
| 1760 | EXPORT_SYMBOL_GPL(unregister_reset_call); |
| 1761 | |
| 1762 | static void do_reset_calls(void) |
| 1763 | { |
| 1764 | struct reset_call *reset; |
| 1765 | |
| 1766 | list_for_each_entry(reset, &rcall, list) |
| 1767 | reset->fn(); |
| 1768 | } |
| 1769 | |
Heiko Carstens | c5dd858 | 2007-03-05 23:35:43 +0100 | [diff] [blame] | 1770 | u32 dump_prefix_page; |
Heiko Carstens | 15e9b58 | 2006-12-04 15:40:26 +0100 | [diff] [blame] | 1771 | |
| 1772 | void s390_reset_system(void) |
| 1773 | { |
| 1774 | struct _lowcore *lc; |
| 1775 | |
Heiko Carstens | 15e9b58 | 2006-12-04 15:40:26 +0100 | [diff] [blame] | 1776 | lc = (struct _lowcore *)(unsigned long) store_prefix(); |
Michael Holzheu | a45e141 | 2006-12-15 17:18:22 +0100 | [diff] [blame] | 1777 | |
| 1778 | /* Stack for interrupt/machine check handler */ |
Heiko Carstens | 15e9b58 | 2006-12-04 15:40:26 +0100 | [diff] [blame] | 1779 | lc->panic_stack = S390_lowcore.panic_stack; |
| 1780 | |
Michael Holzheu | da1cf23 | 2006-12-15 17:18:27 +0100 | [diff] [blame] | 1781 | /* Save prefix page address for dump case */ |
Heiko Carstens | c5dd858 | 2007-03-05 23:35:43 +0100 | [diff] [blame] | 1782 | dump_prefix_page = (u32)(unsigned long) lc; |
Michael Holzheu | da1cf23 | 2006-12-15 17:18:27 +0100 | [diff] [blame] | 1783 | |
Heiko Carstens | 15e9b58 | 2006-12-04 15:40:26 +0100 | [diff] [blame] | 1784 | /* Disable prefixing */ |
| 1785 | set_prefix(0); |
| 1786 | |
| 1787 | /* Disable lowcore protection */ |
| 1788 | __ctl_clear_bit(0,28); |
| 1789 | |
| 1790 | /* Set new machine check handler */ |
Gerald Schaefer | c1821c2 | 2007-02-05 21:18:17 +0100 | [diff] [blame] | 1791 | S390_lowcore.mcck_new_psw.mask = psw_kernel_bits & ~PSW_MASK_MCHECK; |
Heiko Carstens | 15e9b58 | 2006-12-04 15:40:26 +0100 | [diff] [blame] | 1792 | S390_lowcore.mcck_new_psw.addr = |
Heiko Carstens | ab14de6 | 2007-02-05 21:18:37 +0100 | [diff] [blame] | 1793 | PSW_ADDR_AMODE | (unsigned long) s390_base_mcck_handler; |
Michael Holzheu | a45e141 | 2006-12-15 17:18:22 +0100 | [diff] [blame] | 1794 | |
| 1795 | /* Set new program check handler */ |
Gerald Schaefer | c1821c2 | 2007-02-05 21:18:17 +0100 | [diff] [blame] | 1796 | S390_lowcore.program_new_psw.mask = psw_kernel_bits & ~PSW_MASK_MCHECK; |
Michael Holzheu | a45e141 | 2006-12-15 17:18:22 +0100 | [diff] [blame] | 1797 | S390_lowcore.program_new_psw.addr = |
Heiko Carstens | ab14de6 | 2007-02-05 21:18:37 +0100 | [diff] [blame] | 1798 | PSW_ADDR_AMODE | (unsigned long) s390_base_pgm_handler; |
Michael Holzheu | a45e141 | 2006-12-15 17:18:22 +0100 | [diff] [blame] | 1799 | |
Heiko Carstens | 15e9b58 | 2006-12-04 15:40:26 +0100 | [diff] [blame] | 1800 | do_reset_calls(); |
| 1801 | } |
Michael Holzheu | 99ca4e5 | 2008-01-26 14:11:11 +0100 | [diff] [blame] | 1802 | |