[S390] move crypto options and some cleanup.
[deliverable/linux.git] / arch / s390 / kernel / setup.c
CommitLineData
1da177e4
LT
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>
1da177e4
LT
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>
1e8e3383 38#include <linux/device.h>
585c3047 39#include <linux/notifier.h>
65912a84 40#include <linux/pfn.h>
2b67fc46 41#include <linux/reboot.h>
1da177e4
LT
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>
0b642ede
PO
50#include <asm/page.h>
51#include <asm/ptrace.h>
cc13ad62 52#include <asm/sections.h>
1da177e4 53
d02765d1
GS
54/*
55 * User copy operations.
56 */
57struct uaccess_ops uaccess;
58EXPORT_SYMBOL_GPL(uaccess);
59
1da177e4
LT
60/*
61 * Machine setup..
62 */
63unsigned int console_mode = 0;
64unsigned int console_devno = -1;
65unsigned int console_irq = -1;
1da177e4 66unsigned long machine_flags = 0;
36a2bd42 67
f4eb07c1 68struct mem_chunk __initdata memory_chunk[MEMORY_CHUNKS];
1da177e4 69volatile int __cpu_logical_map[NR_CPUS]; /* logical cpu to cpu address */
c9e37353 70static unsigned long __initdata memory_end;
1da177e4 71
1da177e4
LT
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
1da177e4
LT
80static struct resource code_resource = {
81 .name = "Kernel code",
82 .flags = IORESOURCE_BUSY | IORESOURCE_MEM,
83};
84
85static 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 */
93void __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 */
94c12cc7 100 asm volatile("stidp %0": "=m" (S390_lowcore.cpu_data.cpu_id));
1da177e4
LT
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 */
119char vmhalt_cmd[128] = "";
120char vmpoff_cmd[128] = "";
2b67fc46 121static char vmpanic_cmd[128] = "";
1da177e4
LT
122
123static 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
135static 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
144static 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
585c3047
PO
153static 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
164static struct notifier_block vmpanic_nb = {
165 .notifier_call = vmpanic_notify,
166 .priority = PANIC_PRI_VMPANIC
167};
168
169static 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
1da177e4
LT
185/*
186 * condev= and conmode= setup parameter.
187 */
188
189static 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
203static 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
222static void __init conmode_default(void)
223{
224 char query_buffer[1024];
225 char *ptr;
226
227 if (MACHINE_IS_VM) {
740b5706 228 cpcmd("QUERY CONSOLE", query_buffer, 1024, NULL);
1da177e4
LT
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);
740b5706 232 cpcmd("QUERY TERM", query_buffer, 1024, NULL);
1da177e4
LT
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 */
740b5706 241 cpcmd("TERM CONMODE 3215", NULL, 0, NULL);
1da177e4
LT
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
1da177e4
LT
279void (*_machine_restart)(char *command) = machine_restart_smp;
280void (*_machine_halt)(void) = machine_halt_smp;
281void (*_machine_power_off)(void) = machine_power_off_smp;
282#else
283/*
284 * Reboot, halt and power_off routines for non SMP.
285 */
1da177e4
LT
286static void do_machine_restart_nonsmp(char * __unused)
287{
ff6b8ea6 288 do_reipl();
1da177e4
LT
289}
290
291static void do_machine_halt_nonsmp(void)
292{
293 if (MACHINE_IS_VM && strlen(vmhalt_cmd) > 0)
740b5706 294 __cpcmd(vmhalt_cmd, NULL, 0, NULL);
1da177e4
LT
295 signal_processor(smp_processor_id(), sigp_stop_and_store_status);
296}
297
298static void do_machine_power_off_nonsmp(void)
299{
300 if (MACHINE_IS_VM && strlen(vmpoff_cmd) > 0)
740b5706 301 __cpcmd(vmpoff_cmd, NULL, 0, NULL);
1da177e4
LT
302 signal_processor(smp_processor_id(), sigp_stop_and_store_status);
303}
304
305void (*_machine_restart)(char *command) = do_machine_restart_nonsmp;
306void (*_machine_halt)(void) = do_machine_halt_nonsmp;
307void (*_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
315void machine_restart(char *command)
316{
06fa46a2
MS
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();
1da177e4
LT
323 _machine_restart(command);
324}
325
1da177e4
LT
326void machine_halt(void)
327{
06fa46a2
MS
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();
1da177e4
LT
334 _machine_halt();
335}
336
1da177e4
LT
337void machine_power_off(void)
338{
06fa46a2
MS
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();
1da177e4
LT
345 _machine_power_off();
346}
347
53df751c
MS
348/*
349 * Dummy power off function.
350 */
351void (*pm_power_off)(void) = machine_power_off;
352
59685296
HC
353static int __init early_parse_mem(char *p)
354{
355 memory_end = memparse(p, &p);
356 return 0;
357}
358early_param("mem", early_parse_mem);
359
360/*
361 * "ipldelay=XXX[sm]" sets ipl delay in seconds or minutes
362 */
363static int __init early_parse_ipldelay(char *p)
c9e37353 364{
c9e37353 365 unsigned long delay = 0;
1da177e4 366
59685296 367 delay = simple_strtoul(p, &p, 0);
1da177e4 368
59685296
HC
369 switch (*p) {
370 case 's':
371 case 'S':
372 delay *= 1000000;
373 break;
374 case 'm':
375 case 'M':
376 delay *= 60 * 1000000;
c9e37353 377 }
59685296
HC
378
379 /* now wait for the requested amount of time */
380 udelay(delay);
381
382 return 0;
c9e37353 383}
59685296 384early_param("ipldelay", early_parse_ipldelay);
c9e37353
HC
385
386static void __init
387setup_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);
0b642ede 399 lc->restart_psw.mask = PSW_BASE_BITS | PSW_DEFAULT_KEY;
c9e37353
HC
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;
77fa2245
HC
410 lc->mcck_new_psw.mask =
411 PSW_KERNEL_BITS & ~PSW_MASK_MCHECK & ~PSW_MASK_DAT;
c9e37353
HC
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;
c9e37353
HC
421 lc->panic_stack = (unsigned long)
422 __alloc_bootmem(PAGE_SIZE, PAGE_SIZE, 0) + PAGE_SIZE;
c9e37353
HC
423 lc->current_task = (unsigned long) init_thread_union.thread_info.task;
424 lc->thread_info = (unsigned long) &init_thread_union;
347a8dc3 425#ifndef CONFIG_64BIT
77fa2245
HC
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 */
c4972f33 430 __ctl_set_bit(14, 29);
77fa2245
HC
431 }
432#endif
c9e37353
HC
433 set_prefix((u32)(unsigned long) lc);
434}
435
436static void __init
437setup_resources(void)
438{
439 struct resource *res;
440 int i;
441
cc13ad62
HC
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
c9e37353
HC
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
8b62bc96
HC
469static 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;
de338a37 476 max_phys = VMALLOC_END_INIT - VMALLOC_MIN_SIZE;
8b62bc96
HC
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;
8b62bc96
HC
495}
496
c9e37353
HC
497static void __init
498setup_memory(void)
499{
500 unsigned long bootmap_size;
0b642ede 501 unsigned long start_pfn, end_pfn, init_pfn;
c9e37353 502 int i;
1da177e4
LT
503
504 /*
505 * partially used pages are not usable - thus
506 * we are rounding upwards:
507 */
65912a84
HC
508 start_pfn = PFN_UP(__pa(&_end));
509 end_pfn = max_pfn = PFN_DOWN(memory_end);
1da177e4 510
0b642ede
PO
511 /* Initialize storage key for kernel pages */
512 for (init_pfn = 0 ; init_pfn < start_pfn; init_pfn++)
513 page_set_storage_key(init_pfn << PAGE_SHIFT, PAGE_DEFAULT_KEY);
514
65912a84
HC
515#ifdef CONFIG_BLK_DEV_INITRD
516 /*
517 * Move the initrd in case the bitmap of the bootmem allocater
518 * would overwrite it.
519 */
520
521 if (INITRD_START && INITRD_SIZE) {
522 unsigned long bmap_size;
523 unsigned long start;
524
525 bmap_size = bootmem_bootmap_pages(end_pfn - start_pfn + 1);
526 bmap_size = PFN_PHYS(bmap_size);
527
528 if (PFN_PHYS(start_pfn) + bmap_size > INITRD_START) {
529 start = PFN_PHYS(start_pfn) + bmap_size + PAGE_SIZE;
530
531 if (start + INITRD_SIZE > memory_end) {
532 printk("initrd extends beyond end of memory "
533 "(0x%08lx > 0x%08lx)\n"
534 "disabling initrd\n",
535 start + INITRD_SIZE, memory_end);
536 INITRD_START = INITRD_SIZE = 0;
537 } else {
538 printk("Moving initrd (0x%08lx -> 0x%08lx, "
539 "size: %ld)\n",
540 INITRD_START, start, INITRD_SIZE);
541 memmove((void *) start, (void *) INITRD_START,
542 INITRD_SIZE);
543 INITRD_START = start;
544 }
545 }
546 }
547#endif
548
1da177e4 549 /*
7676bef9 550 * Initialize the boot-time allocator
1da177e4
LT
551 */
552 bootmap_size = init_bootmem(start_pfn, end_pfn);
553
554 /*
555 * Register RAM areas with the bootmem allocator.
556 */
c9e37353 557
0b642ede 558 for (i = 0; i < MEMORY_CHUNKS && memory_chunk[i].size > 0; i++) {
39b742f9 559 unsigned long start_chunk, end_chunk, pfn;
1da177e4
LT
560
561 if (memory_chunk[i].type != CHUNK_READ_WRITE)
562 continue;
39b742f9
HC
563 start_chunk = PFN_DOWN(memory_chunk[i].addr);
564 end_chunk = start_chunk + PFN_DOWN(memory_chunk[i].size) - 1;
565 end_chunk = min(end_chunk, end_pfn);
566 if (start_chunk >= end_chunk)
567 continue;
568 add_active_range(0, start_chunk, end_chunk);
569 pfn = max(start_chunk, start_pfn);
570 for (; pfn <= end_chunk; pfn++)
571 page_set_storage_key(PFN_PHYS(pfn), PAGE_DEFAULT_KEY);
1da177e4
LT
572 }
573
0b642ede
PO
574 psw_set_key(PAGE_DEFAULT_KEY);
575
39b742f9
HC
576 free_bootmem_with_active_regions(0, max_pfn);
577 reserve_bootmem(0, PFN_PHYS(start_pfn));
c9e37353
HC
578
579 /*
580 * Reserve the bootmem bitmap itself as well. We do this in two
581 * steps (first step was init_bootmem()) because this catches
582 * the (very unlikely) case of us accidentally initializing the
583 * bootmem allocator with an invalid RAM area.
584 */
585 reserve_bootmem(start_pfn << PAGE_SHIFT, bootmap_size);
1da177e4
LT
586
587#ifdef CONFIG_BLK_DEV_INITRD
65912a84 588 if (INITRD_START && INITRD_SIZE) {
1da177e4
LT
589 if (INITRD_START + INITRD_SIZE <= memory_end) {
590 reserve_bootmem(INITRD_START, INITRD_SIZE);
591 initrd_start = INITRD_START;
592 initrd_end = initrd_start + INITRD_SIZE;
593 } else {
c9e37353
HC
594 printk("initrd extends beyond end of memory "
595 "(0x%08lx > 0x%08lx)\ndisabling initrd\n",
596 initrd_start + INITRD_SIZE, memory_end);
597 initrd_start = initrd_end = 0;
1da177e4 598 }
c9e37353 599 }
1da177e4 600#endif
c9e37353 601}
1da177e4 602
c9e37353
HC
603/*
604 * Setup function called from init/main.c just after the banner
605 * was printed.
606 */
1da177e4 607
c9e37353
HC
608void __init
609setup_arch(char **cmdline_p)
610{
1da177e4 611 /*
c9e37353 612 * print what head.S has found out about the machine
1da177e4 613 */
347a8dc3 614#ifndef CONFIG_64BIT
c9e37353
HC
615 printk((MACHINE_IS_VM) ?
616 "We are running under VM (31 bit mode)\n" :
617 "We are running native (31 bit mode)\n");
618 printk((MACHINE_HAS_IEEE) ?
619 "This machine has an IEEE fpu\n" :
620 "This machine has no IEEE fpu\n");
347a8dc3 621#else /* CONFIG_64BIT */
c9e37353
HC
622 printk((MACHINE_IS_VM) ?
623 "We are running under VM (64 bit mode)\n" :
624 "We are running native (64 bit mode)\n");
347a8dc3 625#endif /* CONFIG_64BIT */
c9e37353 626
59685296
HC
627 /* Save unparsed command line copy for /proc/cmdline */
628 strlcpy(saved_command_line, COMMAND_LINE, COMMAND_LINE_SIZE);
629
630 *cmdline_p = COMMAND_LINE;
631 *(*cmdline_p + COMMAND_LINE_SIZE - 1) = '\0';
632
c9e37353 633 ROOT_DEV = Root_RAM0;
59685296
HC
634
635 init_mm.start_code = PAGE_OFFSET;
636 init_mm.end_code = (unsigned long) &_etext;
637 init_mm.end_data = (unsigned long) &_edata;
638 init_mm.brk = (unsigned long) &_end;
639
6c2a9e6d
GS
640 if (MACHINE_HAS_MVCOS)
641 memcpy(&uaccess, &uaccess_mvcos, sizeof(uaccess));
642 else
643 memcpy(&uaccess, &uaccess_std, sizeof(uaccess));
644
59685296
HC
645 parse_early_param();
646
8b62bc96 647 setup_memory_end();
c9e37353
HC
648 setup_memory();
649 setup_resources();
650 setup_lowcore();
651
1da177e4
LT
652 cpu_init();
653 __cpu_logical_map[0] = S390_lowcore.cpu_data.cpu_addr;
255acee7 654 smp_setup_cpu_possible_map();
1da177e4
LT
655
656 /*
657 * Create kernel page tables and switch to virtual addressing.
658 */
659 paging_init();
660
661 /* Setup default console */
662 conmode_default();
663}
664
665void print_cpu_info(struct cpuinfo_S390 *cpuinfo)
666{
667 printk("cpu %d "
668#ifdef CONFIG_SMP
669 "phys_idx=%d "
670#endif
671 "vers=%02X ident=%06X machine=%04X unused=%04X\n",
672 cpuinfo->cpu_nr,
673#ifdef CONFIG_SMP
674 cpuinfo->cpu_addr,
675#endif
676 cpuinfo->cpu_id.version,
677 cpuinfo->cpu_id.ident,
678 cpuinfo->cpu_id.machine,
679 cpuinfo->cpu_id.unused);
680}
681
682/*
683 * show_cpuinfo - Get information on one CPU for use by procfs.
684 */
685
686static int show_cpuinfo(struct seq_file *m, void *v)
687{
688 struct cpuinfo_S390 *cpuinfo;
689 unsigned long n = (unsigned long) v - 1;
690
b7ae9dd8 691 preempt_disable();
1da177e4
LT
692 if (!n) {
693 seq_printf(m, "vendor_id : IBM/S390\n"
694 "# processors : %i\n"
695 "bogomips per cpu: %lu.%02lu\n",
696 num_online_cpus(), loops_per_jiffy/(500000/HZ),
697 (loops_per_jiffy/(5000/HZ))%100);
698 }
699 if (cpu_online(n)) {
700#ifdef CONFIG_SMP
701 if (smp_processor_id() == n)
702 cpuinfo = &S390_lowcore.cpu_data;
703 else
704 cpuinfo = &lowcore_ptr[n]->cpu_data;
705#else
706 cpuinfo = &S390_lowcore.cpu_data;
707#endif
708 seq_printf(m, "processor %li: "
709 "version = %02X, "
710 "identification = %06X, "
711 "machine = %04X\n",
712 n, cpuinfo->cpu_id.version,
713 cpuinfo->cpu_id.ident,
714 cpuinfo->cpu_id.machine);
715 }
b7ae9dd8 716 preempt_enable();
1da177e4
LT
717 return 0;
718}
719
720static void *c_start(struct seq_file *m, loff_t *pos)
721{
722 return *pos < NR_CPUS ? (void *)((unsigned long) *pos + 1) : NULL;
723}
724static void *c_next(struct seq_file *m, void *v, loff_t *pos)
725{
726 ++*pos;
727 return c_start(m, pos);
728}
729static void c_stop(struct seq_file *m, void *v)
730{
731}
732struct seq_operations cpuinfo_op = {
733 .start = c_start,
734 .next = c_next,
735 .stop = c_stop,
736 .show = show_cpuinfo,
737};
738
This page took 0.242474 seconds and 5 git commands to generate.