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