[S390] Avoid excessive inlining.
[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>
fe355b7f 41#include <linux/ctype.h>
2b67fc46 42#include <linux/reboot.h>
1da177e4
LT
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>
0b642ede
PO
51#include <asm/page.h>
52#include <asm/ptrace.h>
cc13ad62 53#include <asm/sections.h>
fe355b7f 54#include <asm/ebcdic.h>
c1821c2e
GS
55#include <asm/compat.h>
56
57long psw_kernel_bits = (PSW_BASE_BITS | PSW_MASK_DAT | PSW_ASC_PRIMARY |
58 PSW_MASK_MCHECK | PSW_DEFAULT_KEY);
59long 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);
1da177e4 62
d02765d1
GS
63/*
64 * User copy operations.
65 */
66struct uaccess_ops uaccess;
67EXPORT_SYMBOL_GPL(uaccess);
68
1da177e4
LT
69/*
70 * Machine setup..
71 */
72unsigned int console_mode = 0;
73unsigned int console_devno = -1;
74unsigned int console_irq = -1;
1da177e4 75unsigned long machine_flags = 0;
36a2bd42 76
f4eb07c1 77struct mem_chunk __initdata memory_chunk[MEMORY_CHUNKS];
1da177e4 78volatile int __cpu_logical_map[NR_CPUS]; /* logical cpu to cpu address */
c9e37353 79static unsigned long __initdata memory_end;
1da177e4 80
1da177e4
LT
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
1da177e4
LT
89static struct resource code_resource = {
90 .name = "Kernel code",
91 .flags = IORESOURCE_BUSY | IORESOURCE_MEM,
92};
93
94static 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 */
102void __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 */
94c12cc7 109 asm volatile("stidp %0": "=m" (S390_lowcore.cpu_data.cpu_id));
1da177e4
LT
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 */
128char vmhalt_cmd[128] = "";
129char vmpoff_cmd[128] = "";
2b67fc46 130static char vmpanic_cmd[128] = "";
1da177e4 131
4d284cac 132static void strncpy_skip_quote(char *dst, char *src, int n)
1da177e4
LT
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
144static 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
153static 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
585c3047
PO
162static 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
173static struct notifier_block vmpanic_nb = {
174 .notifier_call = vmpanic_notify,
175 .priority = PANIC_PRI_VMPANIC
176};
177
178static 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
1da177e4
LT
194/*
195 * condev= and conmode= setup parameter.
196 */
197
198static 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
212static 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
231static void __init conmode_default(void)
232{
233 char query_buffer[1024];
234 char *ptr;
235
236 if (MACHINE_IS_VM) {
740b5706 237 cpcmd("QUERY CONSOLE", query_buffer, 1024, NULL);
1da177e4
LT
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);
740b5706 241 cpcmd("QUERY TERM", query_buffer, 1024, NULL);
1da177e4
LT
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 */
740b5706 250 cpcmd("TERM CONMODE 3215", NULL, 0, NULL);
1da177e4
LT
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
1da177e4
LT
288void (*_machine_restart)(char *command) = machine_restart_smp;
289void (*_machine_halt)(void) = machine_halt_smp;
290void (*_machine_power_off)(void) = machine_power_off_smp;
291#else
292/*
293 * Reboot, halt and power_off routines for non SMP.
294 */
1da177e4
LT
295static void do_machine_restart_nonsmp(char * __unused)
296{
ff6b8ea6 297 do_reipl();
1da177e4
LT
298}
299
300static void do_machine_halt_nonsmp(void)
301{
302 if (MACHINE_IS_VM && strlen(vmhalt_cmd) > 0)
740b5706 303 __cpcmd(vmhalt_cmd, NULL, 0, NULL);
1da177e4
LT
304 signal_processor(smp_processor_id(), sigp_stop_and_store_status);
305}
306
307static void do_machine_power_off_nonsmp(void)
308{
309 if (MACHINE_IS_VM && strlen(vmpoff_cmd) > 0)
740b5706 310 __cpcmd(vmpoff_cmd, NULL, 0, NULL);
1da177e4
LT
311 signal_processor(smp_processor_id(), sigp_stop_and_store_status);
312}
313
314void (*_machine_restart)(char *command) = do_machine_restart_nonsmp;
315void (*_machine_halt)(void) = do_machine_halt_nonsmp;
316void (*_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
324void machine_restart(char *command)
325{
06fa46a2
MS
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();
1da177e4
LT
332 _machine_restart(command);
333}
334
1da177e4
LT
335void machine_halt(void)
336{
06fa46a2
MS
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();
1da177e4
LT
343 _machine_halt();
344}
345
1da177e4
LT
346void machine_power_off(void)
347{
06fa46a2
MS
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();
1da177e4
LT
354 _machine_power_off();
355}
356
53df751c
MS
357/*
358 * Dummy power off function.
359 */
360void (*pm_power_off)(void) = machine_power_off;
361
59685296
HC
362static int __init early_parse_mem(char *p)
363{
364 memory_end = memparse(p, &p);
365 return 0;
366}
367early_param("mem", early_parse_mem);
368
369/*
370 * "ipldelay=XXX[sm]" sets ipl delay in seconds or minutes
371 */
372static int __init early_parse_ipldelay(char *p)
c9e37353 373{
c9e37353 374 unsigned long delay = 0;
1da177e4 375
59685296 376 delay = simple_strtoul(p, &p, 0);
1da177e4 377
59685296
HC
378 switch (*p) {
379 case 's':
380 case 'S':
381 delay *= 1000000;
382 break;
383 case 'm':
384 case 'M':
385 delay *= 60 * 1000000;
c9e37353 386 }
59685296
HC
387
388 /* now wait for the requested amount of time */
389 udelay(delay);
390
391 return 0;
c9e37353 392}
59685296 393early_param("ipldelay", early_parse_ipldelay);
c9e37353 394
c1821c2e
GS
395#ifdef CONFIG_S390_SWITCH_AMODE
396unsigned int switch_amode = 0;
397EXPORT_SYMBOL_GPL(switch_amode);
398
4d284cac
HC
399static void set_amode_and_uaccess(unsigned long user_amode,
400 unsigned long user32_amode)
c1821c2e
GS
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 */
428static int __init early_parse_switch_amode(char *p)
429{
430 switch_amode = 1;
431 return 0;
432}
433early_param("switch_amode", early_parse_switch_amode);
434
435#else /* CONFIG_S390_SWITCH_AMODE */
436static 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
443unsigned int s390_noexec = 0;
444EXPORT_SYMBOL_GPL(s390_noexec);
445
446/*
447 * Enable execute protection?
448 */
449static 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}
457early_param("noexec", early_parse_noexec);
458#endif /* CONFIG_S390_EXEC_PROTECT */
459
460static 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
c9e37353
HC
473static void __init
474setup_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);
0b642ede 486 lc->restart_psw.mask = PSW_BASE_BITS | PSW_DEFAULT_KEY;
c9e37353
HC
487 lc->restart_psw.addr =
488 PSW_ADDR_AMODE | (unsigned long) restart_int_handler;
c1821c2e
GS
489 if (switch_amode)
490 lc->restart_psw.mask |= PSW_ASC_HOME;
491 lc->external_new_psw.mask = psw_kernel_bits;
c9e37353
HC
492 lc->external_new_psw.addr =
493 PSW_ADDR_AMODE | (unsigned long) ext_int_handler;
c1821c2e 494 lc->svc_new_psw.mask = psw_kernel_bits | PSW_MASK_IO | PSW_MASK_EXT;
c9e37353 495 lc->svc_new_psw.addr = PSW_ADDR_AMODE | (unsigned long) system_call;
c1821c2e 496 lc->program_new_psw.mask = psw_kernel_bits;
c9e37353
HC
497 lc->program_new_psw.addr =
498 PSW_ADDR_AMODE | (unsigned long)pgm_check_handler;
77fa2245 499 lc->mcck_new_psw.mask =
c1821c2e 500 psw_kernel_bits & ~PSW_MASK_MCHECK & ~PSW_MASK_DAT;
c9e37353
HC
501 lc->mcck_new_psw.addr =
502 PSW_ADDR_AMODE | (unsigned long) mcck_int_handler;
c1821c2e 503 lc->io_new_psw.mask = psw_kernel_bits;
c9e37353
HC
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;
c9e37353
HC
510 lc->panic_stack = (unsigned long)
511 __alloc_bootmem(PAGE_SIZE, PAGE_SIZE, 0) + PAGE_SIZE;
c9e37353
HC
512 lc->current_task = (unsigned long) init_thread_union.thread_info.task;
513 lc->thread_info = (unsigned long) &init_thread_union;
347a8dc3 514#ifndef CONFIG_64BIT
77fa2245
HC
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 */
c4972f33 519 __ctl_set_bit(14, 29);
77fa2245
HC
520 }
521#endif
c9e37353
HC
522 set_prefix((u32)(unsigned long) lc);
523}
524
525static void __init
526setup_resources(void)
527{
fe355b7f 528 struct resource *res, *sub_res;
c9e37353
HC
529 int i;
530
cc13ad62
HC
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
c9e37353
HC
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);
fe355b7f
HY
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);
c9e37353
HC
585 }
586}
587
8b62bc96
HC
588static 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;
de338a37 595 max_phys = VMALLOC_END_INIT - VMALLOC_MIN_SIZE;
8b62bc96
HC
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;
8b62bc96
HC
614}
615
c9e37353
HC
616static void __init
617setup_memory(void)
618{
619 unsigned long bootmap_size;
fe355b7f 620 unsigned long start_pfn, end_pfn;
c9e37353 621 int i;
1da177e4
LT
622
623 /*
624 * partially used pages are not usable - thus
625 * we are rounding upwards:
626 */
65912a84
HC
627 start_pfn = PFN_UP(__pa(&_end));
628 end_pfn = max_pfn = PFN_DOWN(memory_end);
1da177e4 629
65912a84
HC
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
1da177e4 664 /*
7676bef9 665 * Initialize the boot-time allocator
1da177e4
LT
666 */
667 bootmap_size = init_bootmem(start_pfn, end_pfn);
668
669 /*
670 * Register RAM areas with the bootmem allocator.
671 */
c9e37353 672
0b642ede 673 for (i = 0; i < MEMORY_CHUNKS && memory_chunk[i].size > 0; i++) {
39b742f9 674 unsigned long start_chunk, end_chunk, pfn;
1da177e4
LT
675
676 if (memory_chunk[i].type != CHUNK_READ_WRITE)
677 continue;
39b742f9
HC
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);
1da177e4
LT
687 }
688
0b642ede
PO
689 psw_set_key(PAGE_DEFAULT_KEY);
690
39b742f9
HC
691 free_bootmem_with_active_regions(0, max_pfn);
692 reserve_bootmem(0, PFN_PHYS(start_pfn));
c9e37353
HC
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);
1da177e4
LT
701
702#ifdef CONFIG_BLK_DEV_INITRD
65912a84 703 if (INITRD_START && INITRD_SIZE) {
1da177e4
LT
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 {
c9e37353
HC
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;
1da177e4 713 }
c9e37353 714 }
1da177e4 715#endif
c9e37353 716}
1da177e4 717
c9e37353
HC
718/*
719 * Setup function called from init/main.c just after the banner
720 * was printed.
721 */
1da177e4 722
c9e37353
HC
723void __init
724setup_arch(char **cmdline_p)
725{
1da177e4 726 /*
c9e37353 727 * print what head.S has found out about the machine
1da177e4 728 */
347a8dc3 729#ifndef CONFIG_64BIT
c9e37353
HC
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");
347a8dc3 736#else /* CONFIG_64BIT */
c9e37353
HC
737 printk((MACHINE_IS_VM) ?
738 "We are running under VM (64 bit mode)\n" :
739 "We are running native (64 bit mode)\n");
347a8dc3 740#endif /* CONFIG_64BIT */
c9e37353 741
59685296
HC
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
c9e37353 748 ROOT_DEV = Root_RAM0;
59685296
HC
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
6c2a9e6d
GS
755 if (MACHINE_HAS_MVCOS)
756 memcpy(&uaccess, &uaccess_mvcos, sizeof(uaccess));
757 else
758 memcpy(&uaccess, &uaccess_std, sizeof(uaccess));
759
59685296
HC
760 parse_early_param();
761
8b62bc96 762 setup_memory_end();
c1821c2e 763 setup_addressing_mode();
c9e37353
HC
764 setup_memory();
765 setup_resources();
766 setup_lowcore();
767
1da177e4
LT
768 cpu_init();
769 __cpu_logical_map[0] = S390_lowcore.cpu_data.cpu_addr;
255acee7 770 smp_setup_cpu_possible_map();
1da177e4
LT
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
781void 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
802static int show_cpuinfo(struct seq_file *m, void *v)
803{
804 struct cpuinfo_S390 *cpuinfo;
805 unsigned long n = (unsigned long) v - 1;
806
31ee4b2f 807 s390_adjust_jiffies();
b7ae9dd8 808 preempt_disable();
1da177e4
LT
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 }
b7ae9dd8 833 preempt_enable();
1da177e4
LT
834 return 0;
835}
836
837static void *c_start(struct seq_file *m, loff_t *pos)
838{
839 return *pos < NR_CPUS ? (void *)((unsigned long) *pos + 1) : NULL;
840}
841static void *c_next(struct seq_file *m, void *v, loff_t *pos)
842{
843 ++*pos;
844 return c_start(m, pos);
845}
846static void c_stop(struct seq_file *m, void *v)
847{
848}
849struct seq_operations cpuinfo_op = {
850 .start = c_start,
851 .next = c_next,
852 .stop = c_stop,
853 .show = show_cpuinfo,
854};
855
This page took 0.226044 seconds and 5 git commands to generate.