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