Heiko Carstens | ab14de6 | 2007-02-05 21:18:37 +0100 | [diff] [blame] | 1 | /* |
| 2 | * arch/s390/kernel/early.c |
| 3 | * |
Hans-Joachim Picht | 155af2f | 2009-06-16 10:30:52 +0200 | [diff] [blame] | 4 | * Copyright IBM Corp. 2007, 2009 |
Heiko Carstens | ab14de6 | 2007-02-05 21:18:37 +0100 | [diff] [blame] | 5 | * Author(s): Hongjie Yang <hongjie@us.ibm.com>, |
| 6 | * Heiko Carstens <heiko.carstens@de.ibm.com> |
| 7 | */ |
| 8 | |
Christian Borntraeger | 92e6ecf | 2009-03-26 15:23:58 +0100 | [diff] [blame] | 9 | #include <linux/compiler.h> |
Heiko Carstens | ab14de6 | 2007-02-05 21:18:37 +0100 | [diff] [blame] | 10 | #include <linux/init.h> |
| 11 | #include <linux/errno.h> |
| 12 | #include <linux/string.h> |
| 13 | #include <linux/ctype.h> |
Heiko Carstens | dfd9f7a | 2009-06-12 10:26:44 +0200 | [diff] [blame] | 14 | #include <linux/ftrace.h> |
Heiko Carstens | ab14de6 | 2007-02-05 21:18:37 +0100 | [diff] [blame] | 15 | #include <linux/lockdep.h> |
| 16 | #include <linux/module.h> |
| 17 | #include <linux/pfn.h> |
| 18 | #include <linux/uaccess.h> |
Hendrik Brueckner | a0443fb | 2008-07-14 09:59:09 +0200 | [diff] [blame] | 19 | #include <asm/ebcdic.h> |
Michael Holzheu | 46b05d2 | 2007-02-21 10:55:21 +0100 | [diff] [blame] | 20 | #include <asm/ipl.h> |
Heiko Carstens | ab14de6 | 2007-02-05 21:18:37 +0100 | [diff] [blame] | 21 | #include <asm/lowcore.h> |
| 22 | #include <asm/processor.h> |
| 23 | #include <asm/sections.h> |
| 24 | #include <asm/setup.h> |
Christian Borntraeger | 92e6ecf | 2009-03-26 15:23:58 +0100 | [diff] [blame] | 25 | #include <asm/sysinfo.h> |
Heiko Carstens | ab14de6 | 2007-02-05 21:18:37 +0100 | [diff] [blame] | 26 | #include <asm/cpcmd.h> |
| 27 | #include <asm/sclp.h> |
Heiko Carstens | a806170 | 2008-04-17 07:46:26 +0200 | [diff] [blame] | 28 | #include "entry.h" |
Heiko Carstens | ab14de6 | 2007-02-05 21:18:37 +0100 | [diff] [blame] | 29 | |
| 30 | /* |
| 31 | * Create a Kernel NSS if the SAVESYS= parameter is defined |
| 32 | */ |
Hendrik Brueckner | a0443fb | 2008-07-14 09:59:09 +0200 | [diff] [blame] | 33 | #define DEFSYS_CMD_SIZE 128 |
Heiko Carstens | ab14de6 | 2007-02-05 21:18:37 +0100 | [diff] [blame] | 34 | #define SAVESYS_CMD_SIZE 32 |
| 35 | |
Heiko Carstens | ab14de6 | 2007-02-05 21:18:37 +0100 | [diff] [blame] | 36 | char kernel_nss_name[NSS_NAME_SIZE + 1]; |
| 37 | |
Hendrik Brueckner | a0443fb | 2008-07-14 09:59:09 +0200 | [diff] [blame] | 38 | static void __init setup_boot_command_line(void); |
| 39 | |
Martin Schwidefsky | b6112cc | 2009-04-14 15:36:28 +0200 | [diff] [blame] | 40 | /* |
| 41 | * Get the TOD clock running. |
| 42 | */ |
| 43 | static void __init reset_tod_clock(void) |
| 44 | { |
| 45 | u64 time; |
| 46 | |
| 47 | if (store_clock(&time) == 0) |
| 48 | return; |
| 49 | /* TOD clock not running. Set the clock to Unix Epoch. */ |
| 50 | if (set_clock(TOD_UNIX_EPOCH) != 0 || store_clock(&time) != 0) |
| 51 | disabled_wait(0); |
| 52 | |
| 53 | sched_clock_base_cc = TOD_UNIX_EPOCH; |
| 54 | } |
Hendrik Brueckner | a0443fb | 2008-07-14 09:59:09 +0200 | [diff] [blame] | 55 | |
Heiko Carstens | ab14de6 | 2007-02-05 21:18:37 +0100 | [diff] [blame] | 56 | #ifdef CONFIG_SHARED_KERNEL |
Hendrik Brueckner | a0443fb | 2008-07-14 09:59:09 +0200 | [diff] [blame] | 57 | int __init savesys_ipl_nss(char *cmd, const int cmdlen); |
| 58 | |
| 59 | asm( |
| 60 | " .section .init.text,\"ax\",@progbits\n" |
| 61 | " .align 4\n" |
| 62 | " .type savesys_ipl_nss, @function\n" |
| 63 | "savesys_ipl_nss:\n" |
| 64 | #ifdef CONFIG_64BIT |
| 65 | " stmg 6,15,48(15)\n" |
| 66 | " lgr 14,3\n" |
| 67 | " sam31\n" |
| 68 | " diag 2,14,0x8\n" |
| 69 | " sam64\n" |
| 70 | " lgr 2,14\n" |
| 71 | " lmg 6,15,48(15)\n" |
| 72 | #else |
| 73 | " stm 6,15,24(15)\n" |
| 74 | " lr 14,3\n" |
| 75 | " diag 2,14,0x8\n" |
| 76 | " lr 2,14\n" |
| 77 | " lm 6,15,24(15)\n" |
| 78 | #endif |
| 79 | " br 14\n" |
| 80 | " .size savesys_ipl_nss, .-savesys_ipl_nss\n"); |
| 81 | |
Hendrik Brueckner | 684d2fd | 2009-09-11 10:28:40 +0200 | [diff] [blame] | 82 | static __initdata char upper_command_line[COMMAND_LINE_SIZE]; |
| 83 | |
Heiko Carstens | ab14de6 | 2007-02-05 21:18:37 +0100 | [diff] [blame] | 84 | static noinline __init void create_kernel_nss(void) |
| 85 | { |
| 86 | unsigned int i, stext_pfn, eshared_pfn, end_pfn, min_size; |
| 87 | #ifdef CONFIG_BLK_DEV_INITRD |
| 88 | unsigned int sinitrd_pfn, einitrd_pfn; |
| 89 | #endif |
| 90 | int response; |
Hendrik Brueckner | a0443fb | 2008-07-14 09:59:09 +0200 | [diff] [blame] | 91 | size_t len; |
Heiko Carstens | ab14de6 | 2007-02-05 21:18:37 +0100 | [diff] [blame] | 92 | char *savesys_ptr; |
Heiko Carstens | ab14de6 | 2007-02-05 21:18:37 +0100 | [diff] [blame] | 93 | char defsys_cmd[DEFSYS_CMD_SIZE]; |
| 94 | char savesys_cmd[SAVESYS_CMD_SIZE]; |
| 95 | |
| 96 | /* Do nothing if we are not running under VM */ |
| 97 | if (!MACHINE_IS_VM) |
| 98 | return; |
| 99 | |
| 100 | /* Convert COMMAND_LINE to upper case */ |
Hendrik Brueckner | a0443fb | 2008-07-14 09:59:09 +0200 | [diff] [blame] | 101 | for (i = 0; i < strlen(boot_command_line); i++) |
| 102 | upper_command_line[i] = toupper(boot_command_line[i]); |
Heiko Carstens | ab14de6 | 2007-02-05 21:18:37 +0100 | [diff] [blame] | 103 | |
| 104 | savesys_ptr = strstr(upper_command_line, "SAVESYS="); |
| 105 | |
| 106 | if (!savesys_ptr) |
| 107 | return; |
| 108 | |
| 109 | savesys_ptr += 8; /* Point to the beginning of the NSS name */ |
| 110 | for (i = 0; i < NSS_NAME_SIZE; i++) { |
| 111 | if (savesys_ptr[i] == ' ' || savesys_ptr[i] == '\0') |
| 112 | break; |
| 113 | kernel_nss_name[i] = savesys_ptr[i]; |
| 114 | } |
| 115 | |
| 116 | stext_pfn = PFN_DOWN(__pa(&_stext)); |
| 117 | eshared_pfn = PFN_DOWN(__pa(&_eshared)); |
| 118 | end_pfn = PFN_UP(__pa(&_end)); |
| 119 | min_size = end_pfn << 2; |
| 120 | |
| 121 | sprintf(defsys_cmd, "DEFSYS %s 00000-%.5X EW %.5X-%.5X SR %.5X-%.5X", |
| 122 | kernel_nss_name, stext_pfn - 1, stext_pfn, eshared_pfn - 1, |
| 123 | eshared_pfn, end_pfn); |
| 124 | |
| 125 | #ifdef CONFIG_BLK_DEV_INITRD |
| 126 | if (INITRD_START && INITRD_SIZE) { |
| 127 | sinitrd_pfn = PFN_DOWN(__pa(INITRD_START)); |
| 128 | einitrd_pfn = PFN_UP(__pa(INITRD_START + INITRD_SIZE)); |
| 129 | min_size = einitrd_pfn << 2; |
| 130 | sprintf(defsys_cmd, "%s EW %.5X-%.5X", defsys_cmd, |
| 131 | sinitrd_pfn, einitrd_pfn); |
| 132 | } |
| 133 | #endif |
| 134 | |
Hendrik Brueckner | a0443fb | 2008-07-14 09:59:09 +0200 | [diff] [blame] | 135 | sprintf(defsys_cmd, "%s EW MINSIZE=%.7iK PARMREGS=0-13", |
| 136 | defsys_cmd, min_size); |
Heiko Carstens | ab14de6 | 2007-02-05 21:18:37 +0100 | [diff] [blame] | 137 | sprintf(savesys_cmd, "SAVESYS %s \n IPL %s", |
| 138 | kernel_nss_name, kernel_nss_name); |
| 139 | |
| 140 | __cpcmd(defsys_cmd, NULL, 0, &response); |
| 141 | |
Hongjie Yang | 583b33b | 2008-03-05 12:37:16 +0100 | [diff] [blame] | 142 | if (response != 0) { |
| 143 | kernel_nss_name[0] = '\0'; |
Heiko Carstens | ab14de6 | 2007-02-05 21:18:37 +0100 | [diff] [blame] | 144 | return; |
Hongjie Yang | 583b33b | 2008-03-05 12:37:16 +0100 | [diff] [blame] | 145 | } |
Heiko Carstens | ab14de6 | 2007-02-05 21:18:37 +0100 | [diff] [blame] | 146 | |
Hendrik Brueckner | a0443fb | 2008-07-14 09:59:09 +0200 | [diff] [blame] | 147 | len = strlen(savesys_cmd); |
| 148 | ASCEBC(savesys_cmd, len); |
| 149 | response = savesys_ipl_nss(savesys_cmd, len); |
Heiko Carstens | ab14de6 | 2007-02-05 21:18:37 +0100 | [diff] [blame] | 150 | |
Hendrik Brueckner | a0443fb | 2008-07-14 09:59:09 +0200 | [diff] [blame] | 151 | /* On success: response is equal to the command size, |
| 152 | * max SAVESYS_CMD_SIZE |
| 153 | * On error: response contains the numeric portion of cp error message. |
| 154 | * for SAVESYS it will be >= 263 |
| 155 | */ |
| 156 | if (response > SAVESYS_CMD_SIZE) { |
Hongjie Yang | 583b33b | 2008-03-05 12:37:16 +0100 | [diff] [blame] | 157 | kernel_nss_name[0] = '\0'; |
Heiko Carstens | ab14de6 | 2007-02-05 21:18:37 +0100 | [diff] [blame] | 158 | return; |
Hongjie Yang | 583b33b | 2008-03-05 12:37:16 +0100 | [diff] [blame] | 159 | } |
Heiko Carstens | ab14de6 | 2007-02-05 21:18:37 +0100 | [diff] [blame] | 160 | |
Hendrik Brueckner | a0443fb | 2008-07-14 09:59:09 +0200 | [diff] [blame] | 161 | /* re-setup boot command line with new ipl vm parms */ |
| 162 | ipl_update_parameters(); |
| 163 | setup_boot_command_line(); |
| 164 | |
Heiko Carstens | ab14de6 | 2007-02-05 21:18:37 +0100 | [diff] [blame] | 165 | ipl_flags = IPL_NSS_VALID; |
| 166 | } |
| 167 | |
| 168 | #else /* CONFIG_SHARED_KERNEL */ |
| 169 | |
| 170 | static inline void create_kernel_nss(void) { } |
| 171 | |
| 172 | #endif /* CONFIG_SHARED_KERNEL */ |
| 173 | |
| 174 | /* |
| 175 | * Clear bss memory |
| 176 | */ |
| 177 | static noinline __init void clear_bss_section(void) |
| 178 | { |
Heiko Carstens | 229d9c6 | 2007-02-21 10:55:29 +0100 | [diff] [blame] | 179 | memset(__bss_start, 0, __bss_stop - __bss_start); |
Heiko Carstens | ab14de6 | 2007-02-05 21:18:37 +0100 | [diff] [blame] | 180 | } |
| 181 | |
| 182 | /* |
| 183 | * Initialize storage key for kernel pages |
| 184 | */ |
| 185 | static noinline __init void init_kernel_storage_key(void) |
| 186 | { |
| 187 | unsigned long end_pfn, init_pfn; |
| 188 | |
| 189 | end_pfn = PFN_UP(__pa(&_end)); |
| 190 | |
| 191 | for (init_pfn = 0 ; init_pfn < end_pfn; init_pfn++) |
| 192 | page_set_storage_key(init_pfn << PAGE_SHIFT, PAGE_DEFAULT_KEY); |
| 193 | } |
| 194 | |
Christian Borntraeger | 92e6ecf | 2009-03-26 15:23:58 +0100 | [diff] [blame] | 195 | static __initdata struct sysinfo_3_2_2 vmms __aligned(PAGE_SIZE); |
| 196 | |
Heiko Carstens | ab14de6 | 2007-02-05 21:18:37 +0100 | [diff] [blame] | 197 | static noinline __init void detect_machine_type(void) |
| 198 | { |
Christian Borntraeger | 92e6ecf | 2009-03-26 15:23:58 +0100 | [diff] [blame] | 199 | /* No VM information? Looks like LPAR */ |
| 200 | if (stsi(&vmms, 3, 2, 2) == -ENOSYS) |
| 201 | return; |
| 202 | if (!vmms.count) |
| 203 | return; |
Heiko Carstens | ab14de6 | 2007-02-05 21:18:37 +0100 | [diff] [blame] | 204 | |
Christian Borntraeger | 92e6ecf | 2009-03-26 15:23:58 +0100 | [diff] [blame] | 205 | /* Running under KVM? If not we assume z/VM */ |
| 206 | if (!memcmp(vmms.vm[0].cpi, "\xd2\xe5\xd4", 3)) |
Heiko Carstens | d3135e0 | 2009-09-11 10:28:45 +0200 | [diff] [blame^] | 207 | S390_lowcore.machine_flags |= MACHINE_FLAG_KVM; |
Christian Borntraeger | 92e6ecf | 2009-03-26 15:23:58 +0100 | [diff] [blame] | 208 | else |
Heiko Carstens | d3135e0 | 2009-09-11 10:28:45 +0200 | [diff] [blame^] | 209 | S390_lowcore.machine_flags |= MACHINE_FLAG_VM; |
Heiko Carstens | ab14de6 | 2007-02-05 21:18:37 +0100 | [diff] [blame] | 210 | } |
| 211 | |
Heiko Carstens | 5f954c3 | 2009-07-24 12:39:49 +0200 | [diff] [blame] | 212 | static __init void early_pgm_check_handler(void) |
Heiko Carstens | ab14de6 | 2007-02-05 21:18:37 +0100 | [diff] [blame] | 213 | { |
| 214 | unsigned long addr; |
| 215 | const struct exception_table_entry *fixup; |
| 216 | |
| 217 | addr = S390_lowcore.program_old_psw.addr; |
| 218 | fixup = search_exception_tables(addr & PSW_ADDR_INSN); |
| 219 | if (!fixup) |
| 220 | disabled_wait(0); |
| 221 | S390_lowcore.program_old_psw.addr = fixup->fixup | PSW_ADDR_AMODE; |
| 222 | } |
| 223 | |
Heiko Carstens | 5f954c3 | 2009-07-24 12:39:49 +0200 | [diff] [blame] | 224 | static noinline __init void setup_lowcore_early(void) |
Heiko Carstens | ab14de6 | 2007-02-05 21:18:37 +0100 | [diff] [blame] | 225 | { |
| 226 | psw_t psw; |
| 227 | |
| 228 | psw.mask = PSW_BASE_BITS | PSW_DEFAULT_KEY; |
| 229 | psw.addr = PSW_ADDR_AMODE | (unsigned long) s390_base_ext_handler; |
| 230 | S390_lowcore.external_new_psw = psw; |
| 231 | psw.addr = PSW_ADDR_AMODE | (unsigned long) s390_base_pgm_handler; |
| 232 | S390_lowcore.program_new_psw = psw; |
| 233 | s390_base_pgm_handler_fn = early_pgm_check_handler; |
| 234 | } |
| 235 | |
Gerald Schaefer | 53492b1 | 2008-04-30 13:38:46 +0200 | [diff] [blame] | 236 | static noinline __init void setup_hpage(void) |
| 237 | { |
| 238 | #ifndef CONFIG_DEBUG_PAGEALLOC |
| 239 | unsigned int facilities; |
| 240 | |
| 241 | facilities = stfl(); |
| 242 | if (!(facilities & (1UL << 23)) || !(facilities & (1UL << 29))) |
| 243 | return; |
Heiko Carstens | d3135e0 | 2009-09-11 10:28:45 +0200 | [diff] [blame^] | 244 | S390_lowcore.machine_flags |= MACHINE_FLAG_HPAGE; |
Gerald Schaefer | 53492b1 | 2008-04-30 13:38:46 +0200 | [diff] [blame] | 245 | __ctl_set_bit(0, 23); |
| 246 | #endif |
| 247 | } |
| 248 | |
Heiko Carstens | 2e5061e | 2008-04-30 13:38:45 +0200 | [diff] [blame] | 249 | static __init void detect_mvpg(void) |
| 250 | { |
| 251 | #ifndef CONFIG_64BIT |
| 252 | int rc; |
| 253 | |
| 254 | asm volatile( |
| 255 | " la 0,0\n" |
| 256 | " mvpg %2,%2\n" |
| 257 | "0: la %0,0\n" |
| 258 | "1:\n" |
| 259 | EX_TABLE(0b,1b) |
| 260 | : "=d" (rc) : "0" (-EOPNOTSUPP), "a" (0) : "memory", "cc", "0"); |
| 261 | if (!rc) |
Heiko Carstens | d3135e0 | 2009-09-11 10:28:45 +0200 | [diff] [blame^] | 262 | S390_lowcore.machine_flags |= MACHINE_FLAG_MVPG; |
Heiko Carstens | 2e5061e | 2008-04-30 13:38:45 +0200 | [diff] [blame] | 263 | #endif |
| 264 | } |
| 265 | |
| 266 | static __init void detect_ieee(void) |
| 267 | { |
| 268 | #ifndef CONFIG_64BIT |
| 269 | int rc, tmp; |
| 270 | |
| 271 | asm volatile( |
| 272 | " efpc %1,0\n" |
| 273 | "0: la %0,0\n" |
| 274 | "1:\n" |
| 275 | EX_TABLE(0b,1b) |
| 276 | : "=d" (rc), "=d" (tmp): "0" (-EOPNOTSUPP) : "cc"); |
| 277 | if (!rc) |
Heiko Carstens | d3135e0 | 2009-09-11 10:28:45 +0200 | [diff] [blame^] | 278 | S390_lowcore.machine_flags |= MACHINE_FLAG_IEEE; |
Heiko Carstens | 2e5061e | 2008-04-30 13:38:45 +0200 | [diff] [blame] | 279 | #endif |
| 280 | } |
| 281 | |
| 282 | static __init void detect_csp(void) |
| 283 | { |
| 284 | #ifndef CONFIG_64BIT |
| 285 | int rc; |
| 286 | |
| 287 | asm volatile( |
| 288 | " la 0,0\n" |
| 289 | " la 1,0\n" |
| 290 | " la 2,4\n" |
| 291 | " csp 0,2\n" |
| 292 | "0: la %0,0\n" |
| 293 | "1:\n" |
| 294 | EX_TABLE(0b,1b) |
| 295 | : "=d" (rc) : "0" (-EOPNOTSUPP) : "cc", "0", "1", "2"); |
| 296 | if (!rc) |
Heiko Carstens | d3135e0 | 2009-09-11 10:28:45 +0200 | [diff] [blame^] | 297 | S390_lowcore.machine_flags |= MACHINE_FLAG_CSP; |
Heiko Carstens | 2e5061e | 2008-04-30 13:38:45 +0200 | [diff] [blame] | 298 | #endif |
| 299 | } |
| 300 | |
| 301 | static __init void detect_diag9c(void) |
| 302 | { |
| 303 | unsigned int cpu_address; |
| 304 | int rc; |
| 305 | |
| 306 | cpu_address = stap(); |
| 307 | asm volatile( |
| 308 | " diag %2,0,0x9c\n" |
| 309 | "0: la %0,0\n" |
| 310 | "1:\n" |
| 311 | EX_TABLE(0b,1b) |
| 312 | : "=d" (rc) : "0" (-EOPNOTSUPP), "d" (cpu_address) : "cc"); |
| 313 | if (!rc) |
Heiko Carstens | d3135e0 | 2009-09-11 10:28:45 +0200 | [diff] [blame^] | 314 | S390_lowcore.machine_flags |= MACHINE_FLAG_DIAG9C; |
Heiko Carstens | 2e5061e | 2008-04-30 13:38:45 +0200 | [diff] [blame] | 315 | } |
| 316 | |
| 317 | static __init void detect_diag44(void) |
| 318 | { |
| 319 | #ifdef CONFIG_64BIT |
| 320 | int rc; |
| 321 | |
| 322 | asm volatile( |
| 323 | " diag 0,0,0x44\n" |
| 324 | "0: la %0,0\n" |
| 325 | "1:\n" |
| 326 | EX_TABLE(0b,1b) |
| 327 | : "=d" (rc) : "0" (-EOPNOTSUPP) : "cc"); |
| 328 | if (!rc) |
Heiko Carstens | d3135e0 | 2009-09-11 10:28:45 +0200 | [diff] [blame^] | 329 | S390_lowcore.machine_flags |= MACHINE_FLAG_DIAG44; |
Heiko Carstens | 2e5061e | 2008-04-30 13:38:45 +0200 | [diff] [blame] | 330 | #endif |
| 331 | } |
| 332 | |
| 333 | static __init void detect_machine_facilities(void) |
| 334 | { |
| 335 | #ifdef CONFIG_64BIT |
| 336 | unsigned int facilities; |
| 337 | |
| 338 | facilities = stfl(); |
| 339 | if (facilities & (1 << 28)) |
Heiko Carstens | d3135e0 | 2009-09-11 10:28:45 +0200 | [diff] [blame^] | 340 | S390_lowcore.machine_flags |= MACHINE_FLAG_IDTE; |
Gerald Schaefer | 53492b1 | 2008-04-30 13:38:46 +0200 | [diff] [blame] | 341 | if (facilities & (1 << 23)) |
Heiko Carstens | d3135e0 | 2009-09-11 10:28:45 +0200 | [diff] [blame^] | 342 | S390_lowcore.machine_flags |= MACHINE_FLAG_PFMF; |
Heiko Carstens | 2e5061e | 2008-04-30 13:38:45 +0200 | [diff] [blame] | 343 | if (facilities & (1 << 4)) |
Heiko Carstens | d3135e0 | 2009-09-11 10:28:45 +0200 | [diff] [blame^] | 344 | S390_lowcore.machine_flags |= MACHINE_FLAG_MVCOS; |
Heiko Carstens | 2e5061e | 2008-04-30 13:38:45 +0200 | [diff] [blame] | 345 | #endif |
| 346 | } |
| 347 | |
Heiko Carstens | 761cdf6 | 2008-07-14 09:58:55 +0200 | [diff] [blame] | 348 | static __init void rescue_initrd(void) |
| 349 | { |
| 350 | #ifdef CONFIG_BLK_DEV_INITRD |
| 351 | /* |
| 352 | * Move the initrd right behind the bss section in case it starts |
| 353 | * within the bss section. So we don't overwrite it when the bss |
| 354 | * section gets cleared. |
| 355 | */ |
| 356 | if (!INITRD_START || !INITRD_SIZE) |
| 357 | return; |
| 358 | if (INITRD_START >= (unsigned long) __bss_stop) |
| 359 | return; |
| 360 | memmove(__bss_stop, (void *) INITRD_START, INITRD_SIZE); |
| 361 | INITRD_START = (unsigned long) __bss_stop; |
| 362 | #endif |
| 363 | } |
| 364 | |
Hendrik Brueckner | a0443fb | 2008-07-14 09:59:09 +0200 | [diff] [blame] | 365 | /* Set up boot command line */ |
Hendrik Brueckner | 684d2fd | 2009-09-11 10:28:40 +0200 | [diff] [blame] | 366 | static void __init append_to_cmdline(size_t (*ipl_data)(char *, size_t)) |
| 367 | { |
| 368 | char *parm, *delim; |
| 369 | size_t rc, len; |
| 370 | |
| 371 | len = strlen(boot_command_line); |
| 372 | |
| 373 | delim = boot_command_line + len; /* '\0' character position */ |
| 374 | parm = boot_command_line + len + 1; /* append right after '\0' */ |
| 375 | |
| 376 | rc = ipl_data(parm, COMMAND_LINE_SIZE - len - 1); |
| 377 | if (rc) { |
| 378 | if (*parm == '=') |
| 379 | memmove(boot_command_line, parm + 1, rc); |
| 380 | else |
| 381 | *delim = ' '; /* replace '\0' with space */ |
| 382 | } |
| 383 | } |
| 384 | |
Hendrik Brueckner | a0443fb | 2008-07-14 09:59:09 +0200 | [diff] [blame] | 385 | static void __init setup_boot_command_line(void) |
| 386 | { |
Hendrik Brueckner | a0443fb | 2008-07-14 09:59:09 +0200 | [diff] [blame] | 387 | /* copy arch command line */ |
| 388 | strlcpy(boot_command_line, COMMAND_LINE, ARCH_COMMAND_LINE_SIZE); |
Hendrik Brueckner | a0443fb | 2008-07-14 09:59:09 +0200 | [diff] [blame] | 389 | |
| 390 | /* append IPL PARM data to the boot command line */ |
Hendrik Brueckner | 684d2fd | 2009-09-11 10:28:40 +0200 | [diff] [blame] | 391 | if (MACHINE_IS_VM) |
| 392 | append_to_cmdline(append_ipl_vmparm); |
| 393 | |
| 394 | append_to_cmdline(append_ipl_scpdata); |
Hendrik Brueckner | a0443fb | 2008-07-14 09:59:09 +0200 | [diff] [blame] | 395 | } |
| 396 | |
| 397 | |
Heiko Carstens | ab14de6 | 2007-02-05 21:18:37 +0100 | [diff] [blame] | 398 | /* |
| 399 | * Save ipl parameters, clear bss memory, initialize storage keys |
| 400 | * and create a kernel NSS at startup if the SAVESYS= parm is defined |
| 401 | */ |
| 402 | void __init startup_init(void) |
| 403 | { |
Martin Schwidefsky | b6112cc | 2009-04-14 15:36:28 +0200 | [diff] [blame] | 404 | reset_tod_clock(); |
Heiko Carstens | ab14de6 | 2007-02-05 21:18:37 +0100 | [diff] [blame] | 405 | ipl_save_parameters(); |
Heiko Carstens | 761cdf6 | 2008-07-14 09:58:55 +0200 | [diff] [blame] | 406 | rescue_initrd(); |
Heiko Carstens | ab14de6 | 2007-02-05 21:18:37 +0100 | [diff] [blame] | 407 | clear_bss_section(); |
| 408 | init_kernel_storage_key(); |
| 409 | lockdep_init(); |
| 410 | lockdep_off(); |
Heiko Carstens | ab14de6 | 2007-02-05 21:18:37 +0100 | [diff] [blame] | 411 | sort_main_extable(); |
| 412 | setup_lowcore_early(); |
Hendrik Brueckner | a0443fb | 2008-07-14 09:59:09 +0200 | [diff] [blame] | 413 | detect_machine_type(); |
| 414 | ipl_update_parameters(); |
| 415 | setup_boot_command_line(); |
| 416 | create_kernel_nss(); |
Heiko Carstens | 2e5061e | 2008-04-30 13:38:45 +0200 | [diff] [blame] | 417 | detect_mvpg(); |
| 418 | detect_ieee(); |
| 419 | detect_csp(); |
| 420 | detect_diag9c(); |
| 421 | detect_diag44(); |
| 422 | detect_machine_facilities(); |
Gerald Schaefer | 53492b1 | 2008-04-30 13:38:46 +0200 | [diff] [blame] | 423 | setup_hpage(); |
Heiko Carstens | 83119ad | 2007-07-10 11:24:10 +0200 | [diff] [blame] | 424 | sclp_facilities_detect(); |
Heiko Carstens | 23d1742 | 2008-07-14 09:59:21 +0200 | [diff] [blame] | 425 | detect_memory_layout(memory_chunk); |
Heiko Carstens | dfd9f7a | 2009-06-12 10:26:44 +0200 | [diff] [blame] | 426 | #ifdef CONFIG_DYNAMIC_FTRACE |
| 427 | S390_lowcore.ftrace_func = (unsigned long)ftrace_caller; |
| 428 | #endif |
Heiko Carstens | ab14de6 | 2007-02-05 21:18:37 +0100 | [diff] [blame] | 429 | lockdep_on(); |
| 430 | } |