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