Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * arch/s390/kernel/setup.c |
| 3 | * |
| 4 | * S390 version |
| 5 | * Copyright (C) 1999,2000 IBM Deutschland Entwicklung GmbH, IBM Corporation |
| 6 | * Author(s): Hartmut Penner (hp@de.ibm.com), |
| 7 | * Martin Schwidefsky (schwidefsky@de.ibm.com) |
| 8 | * |
| 9 | * Derived from "arch/i386/kernel/setup.c" |
| 10 | * Copyright (C) 1995, Linus Torvalds |
| 11 | */ |
| 12 | |
| 13 | /* |
| 14 | * This file handles the architecture-dependent parts of initialization |
| 15 | */ |
| 16 | |
| 17 | #include <linux/errno.h> |
| 18 | #include <linux/module.h> |
| 19 | #include <linux/sched.h> |
| 20 | #include <linux/kernel.h> |
| 21 | #include <linux/mm.h> |
| 22 | #include <linux/stddef.h> |
| 23 | #include <linux/unistd.h> |
| 24 | #include <linux/ptrace.h> |
| 25 | #include <linux/slab.h> |
| 26 | #include <linux/user.h> |
| 27 | #include <linux/a.out.h> |
| 28 | #include <linux/tty.h> |
| 29 | #include <linux/ioport.h> |
| 30 | #include <linux/delay.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 31 | #include <linux/init.h> |
| 32 | #include <linux/initrd.h> |
| 33 | #include <linux/bootmem.h> |
| 34 | #include <linux/root_dev.h> |
| 35 | #include <linux/console.h> |
| 36 | #include <linux/seq_file.h> |
| 37 | #include <linux/kernel_stat.h> |
Heiko Carstens | 1e8e338 | 2005-10-30 15:00:11 -0800 | [diff] [blame] | 38 | #include <linux/device.h> |
Peter Oberparleiter | 585c304 | 2006-06-29 15:08:25 +0200 | [diff] [blame] | 39 | #include <linux/notifier.h> |
Heiko Carstens | 65912a8 | 2006-09-20 15:58:41 +0200 | [diff] [blame] | 40 | #include <linux/pfn.h> |
Hongjie Yang | fe355b7 | 2007-02-05 21:18:24 +0100 | [diff] [blame] | 41 | #include <linux/ctype.h> |
Heiko Carstens | 2b67fc4 | 2007-02-05 21:16:47 +0100 | [diff] [blame] | 42 | #include <linux/reboot.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 43 | |
Michael Holzheu | 46b05d2 | 2007-02-21 10:55:21 +0100 | [diff] [blame] | 44 | #include <asm/ipl.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 45 | #include <asm/uaccess.h> |
| 46 | #include <asm/system.h> |
| 47 | #include <asm/smp.h> |
| 48 | #include <asm/mmu_context.h> |
| 49 | #include <asm/cpcmd.h> |
| 50 | #include <asm/lowcore.h> |
| 51 | #include <asm/irq.h> |
Peter Oberparleiter | 0b642ed | 2005-05-01 08:58:58 -0700 | [diff] [blame] | 52 | #include <asm/page.h> |
| 53 | #include <asm/ptrace.h> |
Heiko Carstens | cc13ad6 | 2006-06-25 05:49:30 -0700 | [diff] [blame] | 54 | #include <asm/sections.h> |
Hongjie Yang | fe355b7 | 2007-02-05 21:18:24 +0100 | [diff] [blame] | 55 | #include <asm/ebcdic.h> |
Gerald Schaefer | c1821c2 | 2007-02-05 21:18:17 +0100 | [diff] [blame] | 56 | #include <asm/compat.h> |
| 57 | |
| 58 | long psw_kernel_bits = (PSW_BASE_BITS | PSW_MASK_DAT | PSW_ASC_PRIMARY | |
| 59 | PSW_MASK_MCHECK | PSW_DEFAULT_KEY); |
| 60 | long psw_user_bits = (PSW_BASE_BITS | PSW_MASK_DAT | PSW_ASC_HOME | |
| 61 | PSW_MASK_IO | PSW_MASK_EXT | PSW_MASK_MCHECK | |
| 62 | PSW_MASK_PSTATE | PSW_DEFAULT_KEY); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 63 | |
| 64 | /* |
Gerald Schaefer | d02765d | 2006-09-20 15:59:42 +0200 | [diff] [blame] | 65 | * User copy operations. |
| 66 | */ |
| 67 | struct uaccess_ops uaccess; |
| 68 | EXPORT_SYMBOL_GPL(uaccess); |
| 69 | |
| 70 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 71 | * Machine setup.. |
| 72 | */ |
| 73 | unsigned int console_mode = 0; |
| 74 | unsigned int console_devno = -1; |
| 75 | unsigned int console_irq = -1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 76 | unsigned long machine_flags = 0; |
Heiko Carstens | 36a2bd4 | 2006-12-04 15:40:38 +0100 | [diff] [blame] | 77 | |
Heiko Carstens | f4eb07c | 2006-12-08 15:56:07 +0100 | [diff] [blame] | 78 | struct mem_chunk __initdata memory_chunk[MEMORY_CHUNKS]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 79 | volatile int __cpu_logical_map[NR_CPUS]; /* logical cpu to cpu address */ |
Heiko Carstens | c9e3735 | 2005-05-01 08:58:57 -0700 | [diff] [blame] | 80 | static unsigned long __initdata memory_end; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 81 | |
| 82 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 83 | * This is set up by the setup-routine at boot-time |
| 84 | * for S390 need to find out, what we have to setup |
| 85 | * using address 0x10400 ... |
| 86 | */ |
| 87 | |
| 88 | #include <asm/setup.h> |
| 89 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 90 | static struct resource code_resource = { |
| 91 | .name = "Kernel code", |
| 92 | .flags = IORESOURCE_BUSY | IORESOURCE_MEM, |
| 93 | }; |
| 94 | |
| 95 | static struct resource data_resource = { |
| 96 | .name = "Kernel data", |
| 97 | .flags = IORESOURCE_BUSY | IORESOURCE_MEM, |
| 98 | }; |
| 99 | |
| 100 | /* |
| 101 | * cpu_init() initializes state that is per-CPU. |
| 102 | */ |
| 103 | void __devinit cpu_init (void) |
| 104 | { |
| 105 | int addr = hard_smp_processor_id(); |
| 106 | |
| 107 | /* |
| 108 | * Store processor id in lowcore (used e.g. in timer_interrupt) |
| 109 | */ |
Michael Holzheu | 72960a0 | 2007-02-21 10:55:18 +0100 | [diff] [blame] | 110 | get_cpu_id(&S390_lowcore.cpu_data.cpu_id); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 111 | S390_lowcore.cpu_data.cpu_addr = addr; |
| 112 | |
| 113 | /* |
| 114 | * Force FPU initialization: |
| 115 | */ |
| 116 | clear_thread_flag(TIF_USEDFPU); |
| 117 | clear_used_math(); |
| 118 | |
| 119 | atomic_inc(&init_mm.mm_count); |
| 120 | current->active_mm = &init_mm; |
| 121 | if (current->mm) |
| 122 | BUG(); |
| 123 | enter_lazy_tlb(&init_mm, current); |
| 124 | } |
| 125 | |
| 126 | /* |
| 127 | * VM halt and poweroff setup routines |
| 128 | */ |
| 129 | char vmhalt_cmd[128] = ""; |
| 130 | char vmpoff_cmd[128] = ""; |
Heiko Carstens | 2b67fc4 | 2007-02-05 21:16:47 +0100 | [diff] [blame] | 131 | static char vmpanic_cmd[128] = ""; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 132 | |
Heiko Carstens | 4d284ca | 2007-02-05 21:18:53 +0100 | [diff] [blame] | 133 | static void strncpy_skip_quote(char *dst, char *src, int n) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 134 | { |
| 135 | int sx, dx; |
| 136 | |
| 137 | dx = 0; |
| 138 | for (sx = 0; src[sx] != 0; sx++) { |
| 139 | if (src[sx] == '"') continue; |
| 140 | dst[dx++] = src[sx]; |
| 141 | if (dx >= n) break; |
| 142 | } |
| 143 | } |
| 144 | |
| 145 | static int __init vmhalt_setup(char *str) |
| 146 | { |
| 147 | strncpy_skip_quote(vmhalt_cmd, str, 127); |
| 148 | vmhalt_cmd[127] = 0; |
| 149 | return 1; |
| 150 | } |
| 151 | |
| 152 | __setup("vmhalt=", vmhalt_setup); |
| 153 | |
| 154 | static int __init vmpoff_setup(char *str) |
| 155 | { |
| 156 | strncpy_skip_quote(vmpoff_cmd, str, 127); |
| 157 | vmpoff_cmd[127] = 0; |
| 158 | return 1; |
| 159 | } |
| 160 | |
| 161 | __setup("vmpoff=", vmpoff_setup); |
| 162 | |
Peter Oberparleiter | 585c304 | 2006-06-29 15:08:25 +0200 | [diff] [blame] | 163 | static int vmpanic_notify(struct notifier_block *self, unsigned long event, |
| 164 | void *data) |
| 165 | { |
| 166 | if (MACHINE_IS_VM && strlen(vmpanic_cmd) > 0) |
| 167 | cpcmd(vmpanic_cmd, NULL, 0, NULL); |
| 168 | |
| 169 | return NOTIFY_OK; |
| 170 | } |
| 171 | |
| 172 | #define PANIC_PRI_VMPANIC 0 |
| 173 | |
| 174 | static struct notifier_block vmpanic_nb = { |
| 175 | .notifier_call = vmpanic_notify, |
| 176 | .priority = PANIC_PRI_VMPANIC |
| 177 | }; |
| 178 | |
| 179 | static int __init vmpanic_setup(char *str) |
| 180 | { |
| 181 | static int register_done __initdata = 0; |
| 182 | |
| 183 | strncpy_skip_quote(vmpanic_cmd, str, 127); |
| 184 | vmpanic_cmd[127] = 0; |
| 185 | if (!register_done) { |
| 186 | register_done = 1; |
| 187 | atomic_notifier_chain_register(&panic_notifier_list, |
| 188 | &vmpanic_nb); |
| 189 | } |
| 190 | return 1; |
| 191 | } |
| 192 | |
| 193 | __setup("vmpanic=", vmpanic_setup); |
| 194 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 195 | /* |
| 196 | * condev= and conmode= setup parameter. |
| 197 | */ |
| 198 | |
| 199 | static int __init condev_setup(char *str) |
| 200 | { |
| 201 | int vdev; |
| 202 | |
| 203 | vdev = simple_strtoul(str, &str, 0); |
| 204 | if (vdev >= 0 && vdev < 65536) { |
| 205 | console_devno = vdev; |
| 206 | console_irq = -1; |
| 207 | } |
| 208 | return 1; |
| 209 | } |
| 210 | |
| 211 | __setup("condev=", condev_setup); |
| 212 | |
| 213 | static int __init conmode_setup(char *str) |
| 214 | { |
| 215 | #if defined(CONFIG_SCLP_CONSOLE) |
| 216 | if (strncmp(str, "hwc", 4) == 0 || strncmp(str, "sclp", 5) == 0) |
| 217 | SET_CONSOLE_SCLP; |
| 218 | #endif |
| 219 | #if defined(CONFIG_TN3215_CONSOLE) |
| 220 | if (strncmp(str, "3215", 5) == 0) |
| 221 | SET_CONSOLE_3215; |
| 222 | #endif |
| 223 | #if defined(CONFIG_TN3270_CONSOLE) |
| 224 | if (strncmp(str, "3270", 5) == 0) |
| 225 | SET_CONSOLE_3270; |
| 226 | #endif |
| 227 | return 1; |
| 228 | } |
| 229 | |
| 230 | __setup("conmode=", conmode_setup); |
| 231 | |
| 232 | static void __init conmode_default(void) |
| 233 | { |
| 234 | char query_buffer[1024]; |
| 235 | char *ptr; |
| 236 | |
| 237 | if (MACHINE_IS_VM) { |
Heiko Carstens | 740b570 | 2006-12-04 15:40:30 +0100 | [diff] [blame] | 238 | cpcmd("QUERY CONSOLE", query_buffer, 1024, NULL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 239 | console_devno = simple_strtoul(query_buffer + 5, NULL, 16); |
| 240 | ptr = strstr(query_buffer, "SUBCHANNEL ="); |
| 241 | console_irq = simple_strtoul(ptr + 13, NULL, 16); |
Heiko Carstens | 740b570 | 2006-12-04 15:40:30 +0100 | [diff] [blame] | 242 | cpcmd("QUERY TERM", query_buffer, 1024, NULL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 243 | ptr = strstr(query_buffer, "CONMODE"); |
| 244 | /* |
| 245 | * Set the conmode to 3215 so that the device recognition |
| 246 | * will set the cu_type of the console to 3215. If the |
| 247 | * conmode is 3270 and we don't set it back then both |
| 248 | * 3215 and the 3270 driver will try to access the console |
| 249 | * device (3215 as console and 3270 as normal tty). |
| 250 | */ |
Heiko Carstens | 740b570 | 2006-12-04 15:40:30 +0100 | [diff] [blame] | 251 | cpcmd("TERM CONMODE 3215", NULL, 0, NULL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 252 | if (ptr == NULL) { |
| 253 | #if defined(CONFIG_SCLP_CONSOLE) |
| 254 | SET_CONSOLE_SCLP; |
| 255 | #endif |
| 256 | return; |
| 257 | } |
| 258 | if (strncmp(ptr + 8, "3270", 4) == 0) { |
| 259 | #if defined(CONFIG_TN3270_CONSOLE) |
| 260 | SET_CONSOLE_3270; |
| 261 | #elif defined(CONFIG_TN3215_CONSOLE) |
| 262 | SET_CONSOLE_3215; |
| 263 | #elif defined(CONFIG_SCLP_CONSOLE) |
| 264 | SET_CONSOLE_SCLP; |
| 265 | #endif |
| 266 | } else if (strncmp(ptr + 8, "3215", 4) == 0) { |
| 267 | #if defined(CONFIG_TN3215_CONSOLE) |
| 268 | SET_CONSOLE_3215; |
| 269 | #elif defined(CONFIG_TN3270_CONSOLE) |
| 270 | SET_CONSOLE_3270; |
| 271 | #elif defined(CONFIG_SCLP_CONSOLE) |
| 272 | SET_CONSOLE_SCLP; |
| 273 | #endif |
| 274 | } |
| 275 | } else if (MACHINE_IS_P390) { |
| 276 | #if defined(CONFIG_TN3215_CONSOLE) |
| 277 | SET_CONSOLE_3215; |
| 278 | #elif defined(CONFIG_TN3270_CONSOLE) |
| 279 | SET_CONSOLE_3270; |
| 280 | #endif |
| 281 | } else { |
| 282 | #if defined(CONFIG_SCLP_CONSOLE) |
| 283 | SET_CONSOLE_SCLP; |
| 284 | #endif |
| 285 | } |
| 286 | } |
| 287 | |
| 288 | #ifdef CONFIG_SMP |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 289 | void (*_machine_restart)(char *command) = machine_restart_smp; |
| 290 | void (*_machine_halt)(void) = machine_halt_smp; |
| 291 | void (*_machine_power_off)(void) = machine_power_off_smp; |
| 292 | #else |
| 293 | /* |
| 294 | * Reboot, halt and power_off routines for non SMP. |
| 295 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 296 | static void do_machine_restart_nonsmp(char * __unused) |
| 297 | { |
Michael Holzheu | ff6b8ea | 2006-09-20 15:58:49 +0200 | [diff] [blame] | 298 | do_reipl(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 299 | } |
| 300 | |
| 301 | static void do_machine_halt_nonsmp(void) |
| 302 | { |
| 303 | if (MACHINE_IS_VM && strlen(vmhalt_cmd) > 0) |
Heiko Carstens | 740b570 | 2006-12-04 15:40:30 +0100 | [diff] [blame] | 304 | __cpcmd(vmhalt_cmd, NULL, 0, NULL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 305 | signal_processor(smp_processor_id(), sigp_stop_and_store_status); |
| 306 | } |
| 307 | |
| 308 | static void do_machine_power_off_nonsmp(void) |
| 309 | { |
| 310 | if (MACHINE_IS_VM && strlen(vmpoff_cmd) > 0) |
Heiko Carstens | 740b570 | 2006-12-04 15:40:30 +0100 | [diff] [blame] | 311 | __cpcmd(vmpoff_cmd, NULL, 0, NULL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 312 | signal_processor(smp_processor_id(), sigp_stop_and_store_status); |
| 313 | } |
| 314 | |
| 315 | void (*_machine_restart)(char *command) = do_machine_restart_nonsmp; |
| 316 | void (*_machine_halt)(void) = do_machine_halt_nonsmp; |
| 317 | void (*_machine_power_off)(void) = do_machine_power_off_nonsmp; |
| 318 | #endif |
| 319 | |
| 320 | /* |
| 321 | * Reboot, halt and power_off stubs. They just call _machine_restart, |
| 322 | * _machine_halt or _machine_power_off. |
| 323 | */ |
| 324 | |
| 325 | void machine_restart(char *command) |
| 326 | { |
Martin Schwidefsky | 06fa46a | 2006-06-29 14:57:32 +0200 | [diff] [blame] | 327 | if (!in_interrupt() || oops_in_progress) |
| 328 | /* |
| 329 | * Only unblank the console if we are called in enabled |
| 330 | * context or a bust_spinlocks cleared the way for us. |
| 331 | */ |
| 332 | console_unblank(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 333 | _machine_restart(command); |
| 334 | } |
| 335 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 336 | void machine_halt(void) |
| 337 | { |
Martin Schwidefsky | 06fa46a | 2006-06-29 14:57:32 +0200 | [diff] [blame] | 338 | if (!in_interrupt() || oops_in_progress) |
| 339 | /* |
| 340 | * Only unblank the console if we are called in enabled |
| 341 | * context or a bust_spinlocks cleared the way for us. |
| 342 | */ |
| 343 | console_unblank(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 344 | _machine_halt(); |
| 345 | } |
| 346 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 347 | void machine_power_off(void) |
| 348 | { |
Martin Schwidefsky | 06fa46a | 2006-06-29 14:57:32 +0200 | [diff] [blame] | 349 | if (!in_interrupt() || oops_in_progress) |
| 350 | /* |
| 351 | * Only unblank the console if we are called in enabled |
| 352 | * context or a bust_spinlocks cleared the way for us. |
| 353 | */ |
| 354 | console_unblank(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 355 | _machine_power_off(); |
| 356 | } |
| 357 | |
Martin Schwidefsky | 53df751 | 2006-01-14 13:21:01 -0800 | [diff] [blame] | 358 | /* |
| 359 | * Dummy power off function. |
| 360 | */ |
| 361 | void (*pm_power_off)(void) = machine_power_off; |
| 362 | |
Heiko Carstens | 5968529 | 2006-03-24 03:15:15 -0800 | [diff] [blame] | 363 | static int __init early_parse_mem(char *p) |
Heiko Carstens | c9e3735 | 2005-05-01 08:58:57 -0700 | [diff] [blame] | 364 | { |
Heiko Carstens | 5968529 | 2006-03-24 03:15:15 -0800 | [diff] [blame] | 365 | memory_end = memparse(p, &p); |
| 366 | return 0; |
| 367 | } |
| 368 | early_param("mem", early_parse_mem); |
| 369 | |
| 370 | /* |
| 371 | * "ipldelay=XXX[sm]" sets ipl delay in seconds or minutes |
| 372 | */ |
| 373 | static int __init early_parse_ipldelay(char *p) |
| 374 | { |
Heiko Carstens | c9e3735 | 2005-05-01 08:58:57 -0700 | [diff] [blame] | 375 | unsigned long delay = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 376 | |
Heiko Carstens | 5968529 | 2006-03-24 03:15:15 -0800 | [diff] [blame] | 377 | delay = simple_strtoul(p, &p, 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 378 | |
Heiko Carstens | 5968529 | 2006-03-24 03:15:15 -0800 | [diff] [blame] | 379 | switch (*p) { |
| 380 | case 's': |
| 381 | case 'S': |
| 382 | delay *= 1000000; |
| 383 | break; |
| 384 | case 'm': |
| 385 | case 'M': |
| 386 | delay *= 60 * 1000000; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 387 | } |
Heiko Carstens | 5968529 | 2006-03-24 03:15:15 -0800 | [diff] [blame] | 388 | |
| 389 | /* now wait for the requested amount of time */ |
| 390 | udelay(delay); |
| 391 | |
| 392 | return 0; |
Heiko Carstens | c9e3735 | 2005-05-01 08:58:57 -0700 | [diff] [blame] | 393 | } |
Heiko Carstens | 5968529 | 2006-03-24 03:15:15 -0800 | [diff] [blame] | 394 | early_param("ipldelay", early_parse_ipldelay); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 395 | |
Gerald Schaefer | c1821c2 | 2007-02-05 21:18:17 +0100 | [diff] [blame] | 396 | #ifdef CONFIG_S390_SWITCH_AMODE |
| 397 | unsigned int switch_amode = 0; |
| 398 | EXPORT_SYMBOL_GPL(switch_amode); |
| 399 | |
Heiko Carstens | 4d284ca | 2007-02-05 21:18:53 +0100 | [diff] [blame] | 400 | static void set_amode_and_uaccess(unsigned long user_amode, |
| 401 | unsigned long user32_amode) |
Gerald Schaefer | c1821c2 | 2007-02-05 21:18:17 +0100 | [diff] [blame] | 402 | { |
| 403 | psw_user_bits = PSW_BASE_BITS | PSW_MASK_DAT | user_amode | |
| 404 | PSW_MASK_IO | PSW_MASK_EXT | PSW_MASK_MCHECK | |
| 405 | PSW_MASK_PSTATE | PSW_DEFAULT_KEY; |
| 406 | #ifdef CONFIG_COMPAT |
| 407 | psw_user32_bits = PSW_BASE32_BITS | PSW_MASK_DAT | user_amode | |
| 408 | PSW_MASK_IO | PSW_MASK_EXT | PSW_MASK_MCHECK | |
| 409 | PSW_MASK_PSTATE | PSW_DEFAULT_KEY; |
| 410 | psw32_user_bits = PSW32_BASE_BITS | PSW32_MASK_DAT | user32_amode | |
| 411 | PSW32_MASK_IO | PSW32_MASK_EXT | PSW32_MASK_MCHECK | |
| 412 | PSW32_MASK_PSTATE; |
| 413 | #endif |
| 414 | psw_kernel_bits = PSW_BASE_BITS | PSW_MASK_DAT | PSW_ASC_HOME | |
| 415 | PSW_MASK_MCHECK | PSW_DEFAULT_KEY; |
| 416 | |
| 417 | if (MACHINE_HAS_MVCOS) { |
| 418 | printk("mvcos available.\n"); |
| 419 | memcpy(&uaccess, &uaccess_mvcos_switch, sizeof(uaccess)); |
| 420 | } else { |
| 421 | printk("mvcos not available.\n"); |
| 422 | memcpy(&uaccess, &uaccess_pt, sizeof(uaccess)); |
| 423 | } |
| 424 | } |
| 425 | |
| 426 | /* |
| 427 | * Switch kernel/user addressing modes? |
| 428 | */ |
| 429 | static int __init early_parse_switch_amode(char *p) |
| 430 | { |
| 431 | switch_amode = 1; |
| 432 | return 0; |
| 433 | } |
| 434 | early_param("switch_amode", early_parse_switch_amode); |
| 435 | |
| 436 | #else /* CONFIG_S390_SWITCH_AMODE */ |
| 437 | static inline void set_amode_and_uaccess(unsigned long user_amode, |
| 438 | unsigned long user32_amode) |
| 439 | { |
| 440 | } |
| 441 | #endif /* CONFIG_S390_SWITCH_AMODE */ |
| 442 | |
| 443 | #ifdef CONFIG_S390_EXEC_PROTECT |
| 444 | unsigned int s390_noexec = 0; |
| 445 | EXPORT_SYMBOL_GPL(s390_noexec); |
| 446 | |
| 447 | /* |
| 448 | * Enable execute protection? |
| 449 | */ |
| 450 | static int __init early_parse_noexec(char *p) |
| 451 | { |
| 452 | if (!strncmp(p, "off", 3)) |
| 453 | return 0; |
| 454 | switch_amode = 1; |
| 455 | s390_noexec = 1; |
| 456 | return 0; |
| 457 | } |
| 458 | early_param("noexec", early_parse_noexec); |
| 459 | #endif /* CONFIG_S390_EXEC_PROTECT */ |
| 460 | |
| 461 | static void setup_addressing_mode(void) |
| 462 | { |
| 463 | if (s390_noexec) { |
| 464 | printk("S390 execute protection active, "); |
| 465 | set_amode_and_uaccess(PSW_ASC_SECONDARY, PSW32_ASC_SECONDARY); |
| 466 | return; |
| 467 | } |
| 468 | if (switch_amode) { |
| 469 | printk("S390 address spaces switched, "); |
| 470 | set_amode_and_uaccess(PSW_ASC_PRIMARY, PSW32_ASC_PRIMARY); |
| 471 | } |
| 472 | } |
| 473 | |
Heiko Carstens | c9e3735 | 2005-05-01 08:58:57 -0700 | [diff] [blame] | 474 | static void __init |
| 475 | setup_lowcore(void) |
| 476 | { |
| 477 | struct _lowcore *lc; |
| 478 | int lc_pages; |
| 479 | |
| 480 | /* |
| 481 | * Setup lowcore for boot cpu |
| 482 | */ |
| 483 | lc_pages = sizeof(void *) == 8 ? 2 : 1; |
| 484 | lc = (struct _lowcore *) |
| 485 | __alloc_bootmem(lc_pages * PAGE_SIZE, lc_pages * PAGE_SIZE, 0); |
| 486 | memset(lc, 0, lc_pages * PAGE_SIZE); |
Peter Oberparleiter | 0b642ed | 2005-05-01 08:58:58 -0700 | [diff] [blame] | 487 | lc->restart_psw.mask = PSW_BASE_BITS | PSW_DEFAULT_KEY; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 488 | lc->restart_psw.addr = |
| 489 | PSW_ADDR_AMODE | (unsigned long) restart_int_handler; |
Gerald Schaefer | c1821c2 | 2007-02-05 21:18:17 +0100 | [diff] [blame] | 490 | if (switch_amode) |
| 491 | lc->restart_psw.mask |= PSW_ASC_HOME; |
| 492 | lc->external_new_psw.mask = psw_kernel_bits; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 493 | lc->external_new_psw.addr = |
| 494 | PSW_ADDR_AMODE | (unsigned long) ext_int_handler; |
Gerald Schaefer | c1821c2 | 2007-02-05 21:18:17 +0100 | [diff] [blame] | 495 | lc->svc_new_psw.mask = psw_kernel_bits | PSW_MASK_IO | PSW_MASK_EXT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 496 | lc->svc_new_psw.addr = PSW_ADDR_AMODE | (unsigned long) system_call; |
Gerald Schaefer | c1821c2 | 2007-02-05 21:18:17 +0100 | [diff] [blame] | 497 | lc->program_new_psw.mask = psw_kernel_bits; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 498 | lc->program_new_psw.addr = |
| 499 | PSW_ADDR_AMODE | (unsigned long)pgm_check_handler; |
Heiko Carstens | 77fa224 | 2005-06-25 14:55:30 -0700 | [diff] [blame] | 500 | lc->mcck_new_psw.mask = |
Gerald Schaefer | c1821c2 | 2007-02-05 21:18:17 +0100 | [diff] [blame] | 501 | psw_kernel_bits & ~PSW_MASK_MCHECK & ~PSW_MASK_DAT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 502 | lc->mcck_new_psw.addr = |
| 503 | PSW_ADDR_AMODE | (unsigned long) mcck_int_handler; |
Gerald Schaefer | c1821c2 | 2007-02-05 21:18:17 +0100 | [diff] [blame] | 504 | lc->io_new_psw.mask = psw_kernel_bits; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 505 | lc->io_new_psw.addr = PSW_ADDR_AMODE | (unsigned long) io_int_handler; |
| 506 | lc->ipl_device = S390_lowcore.ipl_device; |
| 507 | lc->jiffy_timer = -1LL; |
| 508 | lc->kernel_stack = ((unsigned long) &init_thread_union) + THREAD_SIZE; |
| 509 | lc->async_stack = (unsigned long) |
| 510 | __alloc_bootmem(ASYNC_SIZE, ASYNC_SIZE, 0) + ASYNC_SIZE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 511 | lc->panic_stack = (unsigned long) |
| 512 | __alloc_bootmem(PAGE_SIZE, PAGE_SIZE, 0) + PAGE_SIZE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 513 | lc->current_task = (unsigned long) init_thread_union.thread_info.task; |
| 514 | lc->thread_info = (unsigned long) &init_thread_union; |
Martin Schwidefsky | 347a8dc | 2006-01-06 00:19:28 -0800 | [diff] [blame] | 515 | #ifndef CONFIG_64BIT |
Heiko Carstens | 77fa224 | 2005-06-25 14:55:30 -0700 | [diff] [blame] | 516 | if (MACHINE_HAS_IEEE) { |
| 517 | lc->extended_save_area_addr = (__u32) |
| 518 | __alloc_bootmem(PAGE_SIZE, PAGE_SIZE, 0); |
| 519 | /* enable extended save area */ |
Heiko Carstens | c4972f3 | 2006-11-06 10:49:02 +0100 | [diff] [blame] | 520 | __ctl_set_bit(14, 29); |
Heiko Carstens | 77fa224 | 2005-06-25 14:55:30 -0700 | [diff] [blame] | 521 | } |
| 522 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 523 | set_prefix((u32)(unsigned long) lc); |
Heiko Carstens | c9e3735 | 2005-05-01 08:58:57 -0700 | [diff] [blame] | 524 | } |
| 525 | |
| 526 | static void __init |
| 527 | setup_resources(void) |
| 528 | { |
Hongjie Yang | fe355b7 | 2007-02-05 21:18:24 +0100 | [diff] [blame] | 529 | struct resource *res, *sub_res; |
Heiko Carstens | c9e3735 | 2005-05-01 08:58:57 -0700 | [diff] [blame] | 530 | int i; |
| 531 | |
Heiko Carstens | cc13ad6 | 2006-06-25 05:49:30 -0700 | [diff] [blame] | 532 | code_resource.start = (unsigned long) &_text; |
| 533 | code_resource.end = (unsigned long) &_etext - 1; |
| 534 | data_resource.start = (unsigned long) &_etext; |
| 535 | data_resource.end = (unsigned long) &_edata - 1; |
| 536 | |
Heiko Carstens | c9e3735 | 2005-05-01 08:58:57 -0700 | [diff] [blame] | 537 | for (i = 0; i < MEMORY_CHUNKS && memory_chunk[i].size > 0; i++) { |
| 538 | res = alloc_bootmem_low(sizeof(struct resource)); |
| 539 | res->flags = IORESOURCE_BUSY | IORESOURCE_MEM; |
| 540 | switch (memory_chunk[i].type) { |
| 541 | case CHUNK_READ_WRITE: |
| 542 | res->name = "System RAM"; |
| 543 | break; |
| 544 | case CHUNK_READ_ONLY: |
| 545 | res->name = "System ROM"; |
| 546 | res->flags |= IORESOURCE_READONLY; |
| 547 | break; |
| 548 | default: |
| 549 | res->name = "reserved"; |
| 550 | } |
| 551 | res->start = memory_chunk[i].addr; |
| 552 | res->end = memory_chunk[i].addr + memory_chunk[i].size - 1; |
| 553 | request_resource(&iomem_resource, res); |
Hongjie Yang | fe355b7 | 2007-02-05 21:18:24 +0100 | [diff] [blame] | 554 | |
| 555 | if (code_resource.start >= res->start && |
| 556 | code_resource.start <= res->end && |
| 557 | code_resource.end > res->end) { |
| 558 | sub_res = alloc_bootmem_low(sizeof(struct resource)); |
| 559 | memcpy(sub_res, &code_resource, |
| 560 | sizeof(struct resource)); |
| 561 | sub_res->end = res->end; |
| 562 | code_resource.start = res->end + 1; |
| 563 | request_resource(res, sub_res); |
| 564 | } |
| 565 | |
| 566 | if (code_resource.start >= res->start && |
| 567 | code_resource.start <= res->end && |
| 568 | code_resource.end <= res->end) |
| 569 | request_resource(res, &code_resource); |
| 570 | |
| 571 | if (data_resource.start >= res->start && |
| 572 | data_resource.start <= res->end && |
| 573 | data_resource.end > res->end) { |
| 574 | sub_res = alloc_bootmem_low(sizeof(struct resource)); |
| 575 | memcpy(sub_res, &data_resource, |
| 576 | sizeof(struct resource)); |
| 577 | sub_res->end = res->end; |
| 578 | data_resource.start = res->end + 1; |
| 579 | request_resource(res, sub_res); |
| 580 | } |
| 581 | |
| 582 | if (data_resource.start >= res->start && |
| 583 | data_resource.start <= res->end && |
| 584 | data_resource.end <= res->end) |
| 585 | request_resource(res, &data_resource); |
Heiko Carstens | c9e3735 | 2005-05-01 08:58:57 -0700 | [diff] [blame] | 586 | } |
| 587 | } |
| 588 | |
Heiko Carstens | 8b62bc9 | 2006-12-04 15:40:56 +0100 | [diff] [blame] | 589 | static void __init setup_memory_end(void) |
| 590 | { |
| 591 | unsigned long real_size, memory_size; |
| 592 | unsigned long max_mem, max_phys; |
| 593 | int i; |
| 594 | |
| 595 | memory_size = real_size = 0; |
Heiko Carstens | de338a3 | 2007-01-09 10:18:47 +0100 | [diff] [blame] | 596 | max_phys = VMALLOC_END_INIT - VMALLOC_MIN_SIZE; |
Heiko Carstens | 8b62bc9 | 2006-12-04 15:40:56 +0100 | [diff] [blame] | 597 | memory_end &= PAGE_MASK; |
| 598 | |
| 599 | max_mem = memory_end ? min(max_phys, memory_end) : max_phys; |
| 600 | |
| 601 | for (i = 0; i < MEMORY_CHUNKS; i++) { |
| 602 | struct mem_chunk *chunk = &memory_chunk[i]; |
| 603 | |
| 604 | real_size = max(real_size, chunk->addr + chunk->size); |
| 605 | if (chunk->addr >= max_mem) { |
| 606 | memset(chunk, 0, sizeof(*chunk)); |
| 607 | continue; |
| 608 | } |
| 609 | if (chunk->addr + chunk->size > max_mem) |
| 610 | chunk->size = max_mem - chunk->addr; |
| 611 | memory_size = max(memory_size, chunk->addr + chunk->size); |
| 612 | } |
| 613 | if (!memory_end) |
| 614 | memory_end = memory_size; |
Heiko Carstens | 8b62bc9 | 2006-12-04 15:40:56 +0100 | [diff] [blame] | 615 | } |
| 616 | |
Heiko Carstens | c9e3735 | 2005-05-01 08:58:57 -0700 | [diff] [blame] | 617 | static void __init |
| 618 | setup_memory(void) |
| 619 | { |
| 620 | unsigned long bootmap_size; |
Hongjie Yang | fe355b7 | 2007-02-05 21:18:24 +0100 | [diff] [blame] | 621 | unsigned long start_pfn, end_pfn; |
Heiko Carstens | c9e3735 | 2005-05-01 08:58:57 -0700 | [diff] [blame] | 622 | int i; |
| 623 | |
| 624 | /* |
| 625 | * partially used pages are not usable - thus |
| 626 | * we are rounding upwards: |
| 627 | */ |
Heiko Carstens | 65912a8 | 2006-09-20 15:58:41 +0200 | [diff] [blame] | 628 | start_pfn = PFN_UP(__pa(&_end)); |
| 629 | end_pfn = max_pfn = PFN_DOWN(memory_end); |
Heiko Carstens | c9e3735 | 2005-05-01 08:58:57 -0700 | [diff] [blame] | 630 | |
Heiko Carstens | 65912a8 | 2006-09-20 15:58:41 +0200 | [diff] [blame] | 631 | #ifdef CONFIG_BLK_DEV_INITRD |
| 632 | /* |
| 633 | * Move the initrd in case the bitmap of the bootmem allocater |
| 634 | * would overwrite it. |
| 635 | */ |
| 636 | |
| 637 | if (INITRD_START && INITRD_SIZE) { |
| 638 | unsigned long bmap_size; |
| 639 | unsigned long start; |
| 640 | |
| 641 | bmap_size = bootmem_bootmap_pages(end_pfn - start_pfn + 1); |
| 642 | bmap_size = PFN_PHYS(bmap_size); |
| 643 | |
| 644 | if (PFN_PHYS(start_pfn) + bmap_size > INITRD_START) { |
| 645 | start = PFN_PHYS(start_pfn) + bmap_size + PAGE_SIZE; |
| 646 | |
| 647 | if (start + INITRD_SIZE > memory_end) { |
| 648 | printk("initrd extends beyond end of memory " |
| 649 | "(0x%08lx > 0x%08lx)\n" |
| 650 | "disabling initrd\n", |
| 651 | start + INITRD_SIZE, memory_end); |
| 652 | INITRD_START = INITRD_SIZE = 0; |
| 653 | } else { |
| 654 | printk("Moving initrd (0x%08lx -> 0x%08lx, " |
| 655 | "size: %ld)\n", |
| 656 | INITRD_START, start, INITRD_SIZE); |
| 657 | memmove((void *) start, (void *) INITRD_START, |
| 658 | INITRD_SIZE); |
| 659 | INITRD_START = start; |
| 660 | } |
| 661 | } |
| 662 | } |
| 663 | #endif |
| 664 | |
Heiko Carstens | c9e3735 | 2005-05-01 08:58:57 -0700 | [diff] [blame] | 665 | /* |
Heiko Carstens | 7676bef | 2006-10-04 20:02:19 +0200 | [diff] [blame] | 666 | * Initialize the boot-time allocator |
Heiko Carstens | c9e3735 | 2005-05-01 08:58:57 -0700 | [diff] [blame] | 667 | */ |
| 668 | bootmap_size = init_bootmem(start_pfn, end_pfn); |
| 669 | |
| 670 | /* |
| 671 | * Register RAM areas with the bootmem allocator. |
| 672 | */ |
Heiko Carstens | c9e3735 | 2005-05-01 08:58:57 -0700 | [diff] [blame] | 673 | |
Peter Oberparleiter | 0b642ed | 2005-05-01 08:58:58 -0700 | [diff] [blame] | 674 | for (i = 0; i < MEMORY_CHUNKS && memory_chunk[i].size > 0; i++) { |
Heiko Carstens | 39b742f | 2006-12-08 15:56:10 +0100 | [diff] [blame] | 675 | unsigned long start_chunk, end_chunk, pfn; |
Heiko Carstens | c9e3735 | 2005-05-01 08:58:57 -0700 | [diff] [blame] | 676 | |
| 677 | if (memory_chunk[i].type != CHUNK_READ_WRITE) |
| 678 | continue; |
Heiko Carstens | 39b742f | 2006-12-08 15:56:10 +0100 | [diff] [blame] | 679 | start_chunk = PFN_DOWN(memory_chunk[i].addr); |
| 680 | end_chunk = start_chunk + PFN_DOWN(memory_chunk[i].size) - 1; |
| 681 | end_chunk = min(end_chunk, end_pfn); |
| 682 | if (start_chunk >= end_chunk) |
| 683 | continue; |
| 684 | add_active_range(0, start_chunk, end_chunk); |
| 685 | pfn = max(start_chunk, start_pfn); |
| 686 | for (; pfn <= end_chunk; pfn++) |
| 687 | page_set_storage_key(PFN_PHYS(pfn), PAGE_DEFAULT_KEY); |
Heiko Carstens | c9e3735 | 2005-05-01 08:58:57 -0700 | [diff] [blame] | 688 | } |
| 689 | |
Peter Oberparleiter | 0b642ed | 2005-05-01 08:58:58 -0700 | [diff] [blame] | 690 | psw_set_key(PAGE_DEFAULT_KEY); |
| 691 | |
Heiko Carstens | 39b742f | 2006-12-08 15:56:10 +0100 | [diff] [blame] | 692 | free_bootmem_with_active_regions(0, max_pfn); |
Heiko Carstens | c9e3735 | 2005-05-01 08:58:57 -0700 | [diff] [blame] | 693 | |
| 694 | /* |
Heiko Carstens | 615b04b | 2007-02-21 10:55:37 +0100 | [diff] [blame^] | 695 | * Reserve memory used for lowcore/command line/kernel image. |
| 696 | */ |
| 697 | reserve_bootmem(0, (unsigned long)_ehead); |
| 698 | reserve_bootmem((unsigned long)_stext, |
| 699 | PFN_PHYS(start_pfn) - (unsigned long)_stext); |
| 700 | /* |
Heiko Carstens | c9e3735 | 2005-05-01 08:58:57 -0700 | [diff] [blame] | 701 | * Reserve the bootmem bitmap itself as well. We do this in two |
| 702 | * steps (first step was init_bootmem()) because this catches |
| 703 | * the (very unlikely) case of us accidentally initializing the |
| 704 | * bootmem allocator with an invalid RAM area. |
| 705 | */ |
| 706 | reserve_bootmem(start_pfn << PAGE_SHIFT, bootmap_size); |
| 707 | |
| 708 | #ifdef CONFIG_BLK_DEV_INITRD |
Heiko Carstens | 65912a8 | 2006-09-20 15:58:41 +0200 | [diff] [blame] | 709 | if (INITRD_START && INITRD_SIZE) { |
Heiko Carstens | c9e3735 | 2005-05-01 08:58:57 -0700 | [diff] [blame] | 710 | if (INITRD_START + INITRD_SIZE <= memory_end) { |
| 711 | reserve_bootmem(INITRD_START, INITRD_SIZE); |
| 712 | initrd_start = INITRD_START; |
| 713 | initrd_end = initrd_start + INITRD_SIZE; |
| 714 | } else { |
| 715 | printk("initrd extends beyond end of memory " |
| 716 | "(0x%08lx > 0x%08lx)\ndisabling initrd\n", |
| 717 | initrd_start + INITRD_SIZE, memory_end); |
| 718 | initrd_start = initrd_end = 0; |
| 719 | } |
| 720 | } |
| 721 | #endif |
| 722 | } |
| 723 | |
| 724 | /* |
| 725 | * Setup function called from init/main.c just after the banner |
| 726 | * was printed. |
| 727 | */ |
| 728 | |
| 729 | void __init |
| 730 | setup_arch(char **cmdline_p) |
| 731 | { |
| 732 | /* |
| 733 | * print what head.S has found out about the machine |
| 734 | */ |
Martin Schwidefsky | 347a8dc | 2006-01-06 00:19:28 -0800 | [diff] [blame] | 735 | #ifndef CONFIG_64BIT |
Heiko Carstens | c9e3735 | 2005-05-01 08:58:57 -0700 | [diff] [blame] | 736 | printk((MACHINE_IS_VM) ? |
| 737 | "We are running under VM (31 bit mode)\n" : |
| 738 | "We are running native (31 bit mode)\n"); |
| 739 | printk((MACHINE_HAS_IEEE) ? |
| 740 | "This machine has an IEEE fpu\n" : |
| 741 | "This machine has no IEEE fpu\n"); |
Martin Schwidefsky | 347a8dc | 2006-01-06 00:19:28 -0800 | [diff] [blame] | 742 | #else /* CONFIG_64BIT */ |
Heiko Carstens | c9e3735 | 2005-05-01 08:58:57 -0700 | [diff] [blame] | 743 | printk((MACHINE_IS_VM) ? |
| 744 | "We are running under VM (64 bit mode)\n" : |
| 745 | "We are running native (64 bit mode)\n"); |
Martin Schwidefsky | 347a8dc | 2006-01-06 00:19:28 -0800 | [diff] [blame] | 746 | #endif /* CONFIG_64BIT */ |
Heiko Carstens | c9e3735 | 2005-05-01 08:58:57 -0700 | [diff] [blame] | 747 | |
Heiko Carstens | 5968529 | 2006-03-24 03:15:15 -0800 | [diff] [blame] | 748 | /* Save unparsed command line copy for /proc/cmdline */ |
Alon Bar-Lev | e06b1a3 | 2007-02-12 00:54:19 -0800 | [diff] [blame] | 749 | strlcpy(boot_command_line, COMMAND_LINE, COMMAND_LINE_SIZE); |
Heiko Carstens | 5968529 | 2006-03-24 03:15:15 -0800 | [diff] [blame] | 750 | |
| 751 | *cmdline_p = COMMAND_LINE; |
| 752 | *(*cmdline_p + COMMAND_LINE_SIZE - 1) = '\0'; |
| 753 | |
Heiko Carstens | c9e3735 | 2005-05-01 08:58:57 -0700 | [diff] [blame] | 754 | ROOT_DEV = Root_RAM0; |
Heiko Carstens | 5968529 | 2006-03-24 03:15:15 -0800 | [diff] [blame] | 755 | |
| 756 | init_mm.start_code = PAGE_OFFSET; |
| 757 | init_mm.end_code = (unsigned long) &_etext; |
| 758 | init_mm.end_data = (unsigned long) &_edata; |
| 759 | init_mm.brk = (unsigned long) &_end; |
| 760 | |
Gerald Schaefer | 6c2a9e6 | 2006-09-20 15:59:44 +0200 | [diff] [blame] | 761 | if (MACHINE_HAS_MVCOS) |
| 762 | memcpy(&uaccess, &uaccess_mvcos, sizeof(uaccess)); |
| 763 | else |
| 764 | memcpy(&uaccess, &uaccess_std, sizeof(uaccess)); |
| 765 | |
Heiko Carstens | 5968529 | 2006-03-24 03:15:15 -0800 | [diff] [blame] | 766 | parse_early_param(); |
| 767 | |
Heiko Carstens | 8b62bc9 | 2006-12-04 15:40:56 +0100 | [diff] [blame] | 768 | setup_memory_end(); |
Gerald Schaefer | c1821c2 | 2007-02-05 21:18:17 +0100 | [diff] [blame] | 769 | setup_addressing_mode(); |
Heiko Carstens | c9e3735 | 2005-05-01 08:58:57 -0700 | [diff] [blame] | 770 | setup_memory(); |
| 771 | setup_resources(); |
| 772 | setup_lowcore(); |
| 773 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 774 | cpu_init(); |
| 775 | __cpu_logical_map[0] = S390_lowcore.cpu_data.cpu_addr; |
Heiko Carstens | 255acee | 2006-02-17 13:52:46 -0800 | [diff] [blame] | 776 | smp_setup_cpu_possible_map(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 777 | |
| 778 | /* |
| 779 | * Create kernel page tables and switch to virtual addressing. |
| 780 | */ |
| 781 | paging_init(); |
| 782 | |
| 783 | /* Setup default console */ |
| 784 | conmode_default(); |
| 785 | } |
| 786 | |
| 787 | void print_cpu_info(struct cpuinfo_S390 *cpuinfo) |
| 788 | { |
| 789 | printk("cpu %d " |
| 790 | #ifdef CONFIG_SMP |
| 791 | "phys_idx=%d " |
| 792 | #endif |
| 793 | "vers=%02X ident=%06X machine=%04X unused=%04X\n", |
| 794 | cpuinfo->cpu_nr, |
| 795 | #ifdef CONFIG_SMP |
| 796 | cpuinfo->cpu_addr, |
| 797 | #endif |
| 798 | cpuinfo->cpu_id.version, |
| 799 | cpuinfo->cpu_id.ident, |
| 800 | cpuinfo->cpu_id.machine, |
| 801 | cpuinfo->cpu_id.unused); |
| 802 | } |
| 803 | |
| 804 | /* |
| 805 | * show_cpuinfo - Get information on one CPU for use by procfs. |
| 806 | */ |
| 807 | |
| 808 | static int show_cpuinfo(struct seq_file *m, void *v) |
| 809 | { |
| 810 | struct cpuinfo_S390 *cpuinfo; |
| 811 | unsigned long n = (unsigned long) v - 1; |
| 812 | |
Martin Schwidefsky | 31ee4b2 | 2007-02-05 21:18:31 +0100 | [diff] [blame] | 813 | s390_adjust_jiffies(); |
Heiko Carstens | b7ae9dd | 2005-09-16 19:27:34 -0700 | [diff] [blame] | 814 | preempt_disable(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 815 | if (!n) { |
| 816 | seq_printf(m, "vendor_id : IBM/S390\n" |
| 817 | "# processors : %i\n" |
| 818 | "bogomips per cpu: %lu.%02lu\n", |
| 819 | num_online_cpus(), loops_per_jiffy/(500000/HZ), |
| 820 | (loops_per_jiffy/(5000/HZ))%100); |
| 821 | } |
| 822 | if (cpu_online(n)) { |
| 823 | #ifdef CONFIG_SMP |
| 824 | if (smp_processor_id() == n) |
| 825 | cpuinfo = &S390_lowcore.cpu_data; |
| 826 | else |
| 827 | cpuinfo = &lowcore_ptr[n]->cpu_data; |
| 828 | #else |
| 829 | cpuinfo = &S390_lowcore.cpu_data; |
| 830 | #endif |
| 831 | seq_printf(m, "processor %li: " |
| 832 | "version = %02X, " |
| 833 | "identification = %06X, " |
| 834 | "machine = %04X\n", |
| 835 | n, cpuinfo->cpu_id.version, |
| 836 | cpuinfo->cpu_id.ident, |
| 837 | cpuinfo->cpu_id.machine); |
| 838 | } |
Heiko Carstens | b7ae9dd | 2005-09-16 19:27:34 -0700 | [diff] [blame] | 839 | preempt_enable(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 840 | return 0; |
| 841 | } |
| 842 | |
| 843 | static void *c_start(struct seq_file *m, loff_t *pos) |
| 844 | { |
| 845 | return *pos < NR_CPUS ? (void *)((unsigned long) *pos + 1) : NULL; |
| 846 | } |
| 847 | static void *c_next(struct seq_file *m, void *v, loff_t *pos) |
| 848 | { |
| 849 | ++*pos; |
| 850 | return c_start(m, pos); |
| 851 | } |
| 852 | static void c_stop(struct seq_file *m, void *v) |
| 853 | { |
| 854 | } |
| 855 | struct seq_operations cpuinfo_op = { |
| 856 | .start = c_start, |
| 857 | .next = c_next, |
| 858 | .stop = c_stop, |
| 859 | .show = show_cpuinfo, |
| 860 | }; |
| 861 | |