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