2 * arch/s390/kernel/setup.c
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)
9 * Derived from "arch/i386/kernel/setup.c"
10 * Copyright (C) 1995, Linus Torvalds
14 * This file handles the architecture-dependent parts of initialization
17 #include <linux/errno.h>
18 #include <linux/module.h>
19 #include <linux/sched.h>
20 #include <linux/kernel.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/ctype.h>
42 #include <linux/reboot.h>
44 #include <asm/uaccess.h>
45 #include <asm/system.h>
47 #include <asm/mmu_context.h>
48 #include <asm/cpcmd.h>
49 #include <asm/lowcore.h>
52 #include <asm/ptrace.h>
53 #include <asm/sections.h>
54 #include <asm/ebcdic.h>
55 #include <asm/compat.h>
57 long psw_kernel_bits
= (PSW_BASE_BITS
| PSW_MASK_DAT
| PSW_ASC_PRIMARY
|
58 PSW_MASK_MCHECK
| PSW_DEFAULT_KEY
);
59 long 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
);
64 * User copy operations.
66 struct uaccess_ops uaccess
;
67 EXPORT_SYMBOL_GPL(uaccess
);
72 unsigned int console_mode
= 0;
73 unsigned int console_devno
= -1;
74 unsigned int console_irq
= -1;
75 unsigned long machine_flags
= 0;
77 struct mem_chunk __initdata memory_chunk
[MEMORY_CHUNKS
];
78 volatile int __cpu_logical_map
[NR_CPUS
]; /* logical cpu to cpu address */
79 static unsigned long __initdata memory_end
;
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 ...
87 #include <asm/setup.h>
89 static struct resource code_resource
= {
90 .name
= "Kernel code",
91 .flags
= IORESOURCE_BUSY
| IORESOURCE_MEM
,
94 static struct resource data_resource
= {
95 .name
= "Kernel data",
96 .flags
= IORESOURCE_BUSY
| IORESOURCE_MEM
,
100 * cpu_init() initializes state that is per-CPU.
102 void __devinit
cpu_init (void)
104 int addr
= hard_smp_processor_id();
107 * Store processor id in lowcore (used e.g. in timer_interrupt)
109 asm volatile("stidp %0": "=m" (S390_lowcore
.cpu_data
.cpu_id
));
110 S390_lowcore
.cpu_data
.cpu_addr
= addr
;
113 * Force FPU initialization:
115 clear_thread_flag(TIF_USEDFPU
);
118 atomic_inc(&init_mm
.mm_count
);
119 current
->active_mm
= &init_mm
;
122 enter_lazy_tlb(&init_mm
, current
);
126 * VM halt and poweroff setup routines
128 char vmhalt_cmd
[128] = "";
129 char vmpoff_cmd
[128] = "";
130 static char vmpanic_cmd
[128] = "";
132 static inline void strncpy_skip_quote(char *dst
, char *src
, int n
)
137 for (sx
= 0; src
[sx
] != 0; sx
++) {
138 if (src
[sx
] == '"') continue;
144 static int __init
vmhalt_setup(char *str
)
146 strncpy_skip_quote(vmhalt_cmd
, str
, 127);
151 __setup("vmhalt=", vmhalt_setup
);
153 static int __init
vmpoff_setup(char *str
)
155 strncpy_skip_quote(vmpoff_cmd
, str
, 127);
160 __setup("vmpoff=", vmpoff_setup
);
162 static int vmpanic_notify(struct notifier_block
*self
, unsigned long event
,
165 if (MACHINE_IS_VM
&& strlen(vmpanic_cmd
) > 0)
166 cpcmd(vmpanic_cmd
, NULL
, 0, NULL
);
171 #define PANIC_PRI_VMPANIC 0
173 static struct notifier_block vmpanic_nb
= {
174 .notifier_call
= vmpanic_notify
,
175 .priority
= PANIC_PRI_VMPANIC
178 static int __init
vmpanic_setup(char *str
)
180 static int register_done __initdata
= 0;
182 strncpy_skip_quote(vmpanic_cmd
, str
, 127);
183 vmpanic_cmd
[127] = 0;
184 if (!register_done
) {
186 atomic_notifier_chain_register(&panic_notifier_list
,
192 __setup("vmpanic=", vmpanic_setup
);
195 * condev= and conmode= setup parameter.
198 static int __init
condev_setup(char *str
)
202 vdev
= simple_strtoul(str
, &str
, 0);
203 if (vdev
>= 0 && vdev
< 65536) {
204 console_devno
= vdev
;
210 __setup("condev=", condev_setup
);
212 static int __init
conmode_setup(char *str
)
214 #if defined(CONFIG_SCLP_CONSOLE)
215 if (strncmp(str
, "hwc", 4) == 0 || strncmp(str
, "sclp", 5) == 0)
218 #if defined(CONFIG_TN3215_CONSOLE)
219 if (strncmp(str
, "3215", 5) == 0)
222 #if defined(CONFIG_TN3270_CONSOLE)
223 if (strncmp(str
, "3270", 5) == 0)
229 __setup("conmode=", conmode_setup
);
231 static void __init
conmode_default(void)
233 char query_buffer
[1024];
237 cpcmd("QUERY CONSOLE", query_buffer
, 1024, NULL
);
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);
241 cpcmd("QUERY TERM", query_buffer
, 1024, NULL
);
242 ptr
= strstr(query_buffer
, "CONMODE");
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).
250 cpcmd("TERM CONMODE 3215", NULL
, 0, NULL
);
252 #if defined(CONFIG_SCLP_CONSOLE)
257 if (strncmp(ptr
+ 8, "3270", 4) == 0) {
258 #if defined(CONFIG_TN3270_CONSOLE)
260 #elif defined(CONFIG_TN3215_CONSOLE)
262 #elif defined(CONFIG_SCLP_CONSOLE)
265 } else if (strncmp(ptr
+ 8, "3215", 4) == 0) {
266 #if defined(CONFIG_TN3215_CONSOLE)
268 #elif defined(CONFIG_TN3270_CONSOLE)
270 #elif defined(CONFIG_SCLP_CONSOLE)
274 } else if (MACHINE_IS_P390
) {
275 #if defined(CONFIG_TN3215_CONSOLE)
277 #elif defined(CONFIG_TN3270_CONSOLE)
281 #if defined(CONFIG_SCLP_CONSOLE)
288 * Create a Kernel NSS if the SAVESYS= parameter is defined
290 #define DEFSYS_CMD_SIZE 96
291 #define SAVESYS_CMD_SIZE 32
294 char kernel_nss_name
[NSS_NAME_SIZE
+ 1];
296 #ifdef CONFIG_SHARED_KERNEL
297 static __init
void create_kernel_nss(void)
299 unsigned int i
, stext_pfn
, eshared_pfn
, end_pfn
, min_size
;
300 #ifdef CONFIG_BLK_DEV_INITRD
301 unsigned int sinitrd_pfn
, einitrd_pfn
;
305 char upper_command_line
[COMMAND_LINE_SIZE
];
306 char defsys_cmd
[DEFSYS_CMD_SIZE
];
307 char savesys_cmd
[SAVESYS_CMD_SIZE
];
309 /* Do nothing if we are not running under VM */
313 /* Convert COMMAND_LINE to upper case */
314 for (i
= 0; i
< strlen(COMMAND_LINE
); i
++)
315 upper_command_line
[i
] = toupper(COMMAND_LINE
[i
]);
317 savesys_ptr
= strstr(upper_command_line
, "SAVESYS=");
322 savesys_ptr
+= 8; /* Point to the beginning of the NSS name */
323 for (i
= 0; i
< NSS_NAME_SIZE
; i
++) {
324 if (savesys_ptr
[i
] == ' ' || savesys_ptr
[i
] == '\0')
326 kernel_nss_name
[i
] = savesys_ptr
[i
];
329 stext_pfn
= PFN_DOWN(__pa(&_stext
));
330 eshared_pfn
= PFN_DOWN(__pa(&_eshared
));
331 end_pfn
= PFN_UP(__pa(&_end
));
332 min_size
= end_pfn
<< 2;
334 sprintf(defsys_cmd
, "DEFSYS %s 00000-%.5X EW %.5X-%.5X SR %.5X-%.5X",
335 kernel_nss_name
, stext_pfn
- 1, stext_pfn
, eshared_pfn
- 1,
336 eshared_pfn
, end_pfn
);
338 #ifdef CONFIG_BLK_DEV_INITRD
339 if (INITRD_START
&& INITRD_SIZE
) {
340 sinitrd_pfn
= PFN_DOWN(__pa(INITRD_START
));
341 einitrd_pfn
= PFN_UP(__pa(INITRD_START
+ INITRD_SIZE
));
342 min_size
= einitrd_pfn
<< 2;
343 sprintf(defsys_cmd
, "%s EW %.5X-%.5X", defsys_cmd
,
344 sinitrd_pfn
, einitrd_pfn
);
348 sprintf(defsys_cmd
, "%s EW MINSIZE=%.7iK", defsys_cmd
, min_size
);
349 sprintf(savesys_cmd
, "SAVESYS %s \n IPL %s",
350 kernel_nss_name
, kernel_nss_name
);
352 __cpcmd(defsys_cmd
, NULL
, 0, &response
);
357 __cpcmd(savesys_cmd
, NULL
, 0, &response
);
359 if (response
!= strlen(savesys_cmd
))
362 ipl_flags
= IPL_NSS_VALID
;
365 #else /* CONFIG_SHARED_KERNEL */
367 static inline void create_kernel_nss(void) { }
369 #endif /* CONFIG_SHARED_KERNEL */
374 static __init
void clear_bss_section(void)
376 memset(__bss_start
, 0, _end
- __bss_start
);
380 * Initialize storage key for kernel pages
382 static __init
void init_kernel_storage_key(void)
384 unsigned long end_pfn
, init_pfn
;
386 end_pfn
= PFN_UP(__pa(&_end
));
388 for (init_pfn
= 0 ; init_pfn
< end_pfn
; init_pfn
++)
389 page_set_storage_key(init_pfn
<< PAGE_SHIFT
, PAGE_DEFAULT_KEY
);
392 static __init
void detect_machine_type(void)
394 struct cpuinfo_S390
*cpuinfo
= &S390_lowcore
.cpu_data
;
396 asm volatile("stidp %0" : "=m" (S390_lowcore
.cpu_data
.cpu_id
));
398 /* Running under z/VM ? */
399 if (cpuinfo
->cpu_id
.version
== 0xff)
402 /* Running on a P/390 ? */
403 if (cpuinfo
->cpu_id
.machine
== 0x7490)
408 * Save ipl parameters, clear bss memory, initialize storage keys
409 * and create a kernel NSS at startup if the SAVESYS= parm is defined
411 void __init
startup_init(void)
413 ipl_save_parameters();
415 init_kernel_storage_key();
417 detect_machine_type();
422 void (*_machine_restart
)(char *command
) = machine_restart_smp
;
423 void (*_machine_halt
)(void) = machine_halt_smp
;
424 void (*_machine_power_off
)(void) = machine_power_off_smp
;
427 * Reboot, halt and power_off routines for non SMP.
429 static void do_machine_restart_nonsmp(char * __unused
)
434 static void do_machine_halt_nonsmp(void)
436 if (MACHINE_IS_VM
&& strlen(vmhalt_cmd
) > 0)
437 __cpcmd(vmhalt_cmd
, NULL
, 0, NULL
);
438 signal_processor(smp_processor_id(), sigp_stop_and_store_status
);
441 static void do_machine_power_off_nonsmp(void)
443 if (MACHINE_IS_VM
&& strlen(vmpoff_cmd
) > 0)
444 __cpcmd(vmpoff_cmd
, NULL
, 0, NULL
);
445 signal_processor(smp_processor_id(), sigp_stop_and_store_status
);
448 void (*_machine_restart
)(char *command
) = do_machine_restart_nonsmp
;
449 void (*_machine_halt
)(void) = do_machine_halt_nonsmp
;
450 void (*_machine_power_off
)(void) = do_machine_power_off_nonsmp
;
454 * Reboot, halt and power_off stubs. They just call _machine_restart,
455 * _machine_halt or _machine_power_off.
458 void machine_restart(char *command
)
460 if (!in_interrupt() || oops_in_progress
)
462 * Only unblank the console if we are called in enabled
463 * context or a bust_spinlocks cleared the way for us.
466 _machine_restart(command
);
469 void machine_halt(void)
471 if (!in_interrupt() || oops_in_progress
)
473 * Only unblank the console if we are called in enabled
474 * context or a bust_spinlocks cleared the way for us.
480 void machine_power_off(void)
482 if (!in_interrupt() || oops_in_progress
)
484 * Only unblank the console if we are called in enabled
485 * context or a bust_spinlocks cleared the way for us.
488 _machine_power_off();
492 * Dummy power off function.
494 void (*pm_power_off
)(void) = machine_power_off
;
496 static int __init
early_parse_mem(char *p
)
498 memory_end
= memparse(p
, &p
);
501 early_param("mem", early_parse_mem
);
504 * "ipldelay=XXX[sm]" sets ipl delay in seconds or minutes
506 static int __init
early_parse_ipldelay(char *p
)
508 unsigned long delay
= 0;
510 delay
= simple_strtoul(p
, &p
, 0);
519 delay
*= 60 * 1000000;
522 /* now wait for the requested amount of time */
527 early_param("ipldelay", early_parse_ipldelay
);
529 #ifdef CONFIG_S390_SWITCH_AMODE
530 unsigned int switch_amode
= 0;
531 EXPORT_SYMBOL_GPL(switch_amode
);
533 static inline void set_amode_and_uaccess(unsigned long user_amode
,
534 unsigned long user32_amode
)
536 psw_user_bits
= PSW_BASE_BITS
| PSW_MASK_DAT
| user_amode
|
537 PSW_MASK_IO
| PSW_MASK_EXT
| PSW_MASK_MCHECK
|
538 PSW_MASK_PSTATE
| PSW_DEFAULT_KEY
;
540 psw_user32_bits
= PSW_BASE32_BITS
| PSW_MASK_DAT
| user_amode
|
541 PSW_MASK_IO
| PSW_MASK_EXT
| PSW_MASK_MCHECK
|
542 PSW_MASK_PSTATE
| PSW_DEFAULT_KEY
;
543 psw32_user_bits
= PSW32_BASE_BITS
| PSW32_MASK_DAT
| user32_amode
|
544 PSW32_MASK_IO
| PSW32_MASK_EXT
| PSW32_MASK_MCHECK
|
547 psw_kernel_bits
= PSW_BASE_BITS
| PSW_MASK_DAT
| PSW_ASC_HOME
|
548 PSW_MASK_MCHECK
| PSW_DEFAULT_KEY
;
550 if (MACHINE_HAS_MVCOS
) {
551 printk("mvcos available.\n");
552 memcpy(&uaccess
, &uaccess_mvcos_switch
, sizeof(uaccess
));
554 printk("mvcos not available.\n");
555 memcpy(&uaccess
, &uaccess_pt
, sizeof(uaccess
));
560 * Switch kernel/user addressing modes?
562 static int __init
early_parse_switch_amode(char *p
)
567 early_param("switch_amode", early_parse_switch_amode
);
569 #else /* CONFIG_S390_SWITCH_AMODE */
570 static inline void set_amode_and_uaccess(unsigned long user_amode
,
571 unsigned long user32_amode
)
574 #endif /* CONFIG_S390_SWITCH_AMODE */
576 #ifdef CONFIG_S390_EXEC_PROTECT
577 unsigned int s390_noexec
= 0;
578 EXPORT_SYMBOL_GPL(s390_noexec
);
581 * Enable execute protection?
583 static int __init
early_parse_noexec(char *p
)
585 if (!strncmp(p
, "off", 3))
591 early_param("noexec", early_parse_noexec
);
592 #endif /* CONFIG_S390_EXEC_PROTECT */
594 static void setup_addressing_mode(void)
597 printk("S390 execute protection active, ");
598 set_amode_and_uaccess(PSW_ASC_SECONDARY
, PSW32_ASC_SECONDARY
);
602 printk("S390 address spaces switched, ");
603 set_amode_and_uaccess(PSW_ASC_PRIMARY
, PSW32_ASC_PRIMARY
);
614 * Setup lowcore for boot cpu
616 lc_pages
= sizeof(void *) == 8 ? 2 : 1;
617 lc
= (struct _lowcore
*)
618 __alloc_bootmem(lc_pages
* PAGE_SIZE
, lc_pages
* PAGE_SIZE
, 0);
619 memset(lc
, 0, lc_pages
* PAGE_SIZE
);
620 lc
->restart_psw
.mask
= PSW_BASE_BITS
| PSW_DEFAULT_KEY
;
621 lc
->restart_psw
.addr
=
622 PSW_ADDR_AMODE
| (unsigned long) restart_int_handler
;
624 lc
->restart_psw
.mask
|= PSW_ASC_HOME
;
625 lc
->external_new_psw
.mask
= psw_kernel_bits
;
626 lc
->external_new_psw
.addr
=
627 PSW_ADDR_AMODE
| (unsigned long) ext_int_handler
;
628 lc
->svc_new_psw
.mask
= psw_kernel_bits
| PSW_MASK_IO
| PSW_MASK_EXT
;
629 lc
->svc_new_psw
.addr
= PSW_ADDR_AMODE
| (unsigned long) system_call
;
630 lc
->program_new_psw
.mask
= psw_kernel_bits
;
631 lc
->program_new_psw
.addr
=
632 PSW_ADDR_AMODE
| (unsigned long)pgm_check_handler
;
633 lc
->mcck_new_psw
.mask
=
634 psw_kernel_bits
& ~PSW_MASK_MCHECK
& ~PSW_MASK_DAT
;
635 lc
->mcck_new_psw
.addr
=
636 PSW_ADDR_AMODE
| (unsigned long) mcck_int_handler
;
637 lc
->io_new_psw
.mask
= psw_kernel_bits
;
638 lc
->io_new_psw
.addr
= PSW_ADDR_AMODE
| (unsigned long) io_int_handler
;
639 lc
->ipl_device
= S390_lowcore
.ipl_device
;
640 lc
->jiffy_timer
= -1LL;
641 lc
->kernel_stack
= ((unsigned long) &init_thread_union
) + THREAD_SIZE
;
642 lc
->async_stack
= (unsigned long)
643 __alloc_bootmem(ASYNC_SIZE
, ASYNC_SIZE
, 0) + ASYNC_SIZE
;
644 lc
->panic_stack
= (unsigned long)
645 __alloc_bootmem(PAGE_SIZE
, PAGE_SIZE
, 0) + PAGE_SIZE
;
646 lc
->current_task
= (unsigned long) init_thread_union
.thread_info
.task
;
647 lc
->thread_info
= (unsigned long) &init_thread_union
;
649 if (MACHINE_HAS_IEEE
) {
650 lc
->extended_save_area_addr
= (__u32
)
651 __alloc_bootmem(PAGE_SIZE
, PAGE_SIZE
, 0);
652 /* enable extended save area */
653 __ctl_set_bit(14, 29);
656 set_prefix((u32
)(unsigned long) lc
);
660 setup_resources(void)
662 struct resource
*res
, *sub_res
;
665 code_resource
.start
= (unsigned long) &_text
;
666 code_resource
.end
= (unsigned long) &_etext
- 1;
667 data_resource
.start
= (unsigned long) &_etext
;
668 data_resource
.end
= (unsigned long) &_edata
- 1;
670 for (i
= 0; i
< MEMORY_CHUNKS
&& memory_chunk
[i
].size
> 0; i
++) {
671 res
= alloc_bootmem_low(sizeof(struct resource
));
672 res
->flags
= IORESOURCE_BUSY
| IORESOURCE_MEM
;
673 switch (memory_chunk
[i
].type
) {
674 case CHUNK_READ_WRITE
:
675 res
->name
= "System RAM";
677 case CHUNK_READ_ONLY
:
678 res
->name
= "System ROM";
679 res
->flags
|= IORESOURCE_READONLY
;
682 res
->name
= "reserved";
684 res
->start
= memory_chunk
[i
].addr
;
685 res
->end
= memory_chunk
[i
].addr
+ memory_chunk
[i
].size
- 1;
686 request_resource(&iomem_resource
, res
);
688 if (code_resource
.start
>= res
->start
&&
689 code_resource
.start
<= res
->end
&&
690 code_resource
.end
> res
->end
) {
691 sub_res
= alloc_bootmem_low(sizeof(struct resource
));
692 memcpy(sub_res
, &code_resource
,
693 sizeof(struct resource
));
694 sub_res
->end
= res
->end
;
695 code_resource
.start
= res
->end
+ 1;
696 request_resource(res
, sub_res
);
699 if (code_resource
.start
>= res
->start
&&
700 code_resource
.start
<= res
->end
&&
701 code_resource
.end
<= res
->end
)
702 request_resource(res
, &code_resource
);
704 if (data_resource
.start
>= res
->start
&&
705 data_resource
.start
<= res
->end
&&
706 data_resource
.end
> res
->end
) {
707 sub_res
= alloc_bootmem_low(sizeof(struct resource
));
708 memcpy(sub_res
, &data_resource
,
709 sizeof(struct resource
));
710 sub_res
->end
= res
->end
;
711 data_resource
.start
= res
->end
+ 1;
712 request_resource(res
, sub_res
);
715 if (data_resource
.start
>= res
->start
&&
716 data_resource
.start
<= res
->end
&&
717 data_resource
.end
<= res
->end
)
718 request_resource(res
, &data_resource
);
722 static void __init
setup_memory_end(void)
724 unsigned long real_size
, memory_size
;
725 unsigned long max_mem
, max_phys
;
728 memory_size
= real_size
= 0;
729 max_phys
= VMALLOC_END_INIT
- VMALLOC_MIN_SIZE
;
730 memory_end
&= PAGE_MASK
;
732 max_mem
= memory_end
? min(max_phys
, memory_end
) : max_phys
;
734 for (i
= 0; i
< MEMORY_CHUNKS
; i
++) {
735 struct mem_chunk
*chunk
= &memory_chunk
[i
];
737 real_size
= max(real_size
, chunk
->addr
+ chunk
->size
);
738 if (chunk
->addr
>= max_mem
) {
739 memset(chunk
, 0, sizeof(*chunk
));
742 if (chunk
->addr
+ chunk
->size
> max_mem
)
743 chunk
->size
= max_mem
- chunk
->addr
;
744 memory_size
= max(memory_size
, chunk
->addr
+ chunk
->size
);
747 memory_end
= memory_size
;
753 unsigned long bootmap_size
;
754 unsigned long start_pfn
, end_pfn
;
758 * partially used pages are not usable - thus
759 * we are rounding upwards:
761 start_pfn
= PFN_UP(__pa(&_end
));
762 end_pfn
= max_pfn
= PFN_DOWN(memory_end
);
764 #ifdef CONFIG_BLK_DEV_INITRD
766 * Move the initrd in case the bitmap of the bootmem allocater
767 * would overwrite it.
770 if (INITRD_START
&& INITRD_SIZE
) {
771 unsigned long bmap_size
;
774 bmap_size
= bootmem_bootmap_pages(end_pfn
- start_pfn
+ 1);
775 bmap_size
= PFN_PHYS(bmap_size
);
777 if (PFN_PHYS(start_pfn
) + bmap_size
> INITRD_START
) {
778 start
= PFN_PHYS(start_pfn
) + bmap_size
+ PAGE_SIZE
;
780 if (start
+ INITRD_SIZE
> memory_end
) {
781 printk("initrd extends beyond end of memory "
782 "(0x%08lx > 0x%08lx)\n"
783 "disabling initrd\n",
784 start
+ INITRD_SIZE
, memory_end
);
785 INITRD_START
= INITRD_SIZE
= 0;
787 printk("Moving initrd (0x%08lx -> 0x%08lx, "
789 INITRD_START
, start
, INITRD_SIZE
);
790 memmove((void *) start
, (void *) INITRD_START
,
792 INITRD_START
= start
;
799 * Initialize the boot-time allocator
801 bootmap_size
= init_bootmem(start_pfn
, end_pfn
);
804 * Register RAM areas with the bootmem allocator.
807 for (i
= 0; i
< MEMORY_CHUNKS
&& memory_chunk
[i
].size
> 0; i
++) {
808 unsigned long start_chunk
, end_chunk
, pfn
;
810 if (memory_chunk
[i
].type
!= CHUNK_READ_WRITE
)
812 start_chunk
= PFN_DOWN(memory_chunk
[i
].addr
);
813 end_chunk
= start_chunk
+ PFN_DOWN(memory_chunk
[i
].size
) - 1;
814 end_chunk
= min(end_chunk
, end_pfn
);
815 if (start_chunk
>= end_chunk
)
817 add_active_range(0, start_chunk
, end_chunk
);
818 pfn
= max(start_chunk
, start_pfn
);
819 for (; pfn
<= end_chunk
; pfn
++)
820 page_set_storage_key(PFN_PHYS(pfn
), PAGE_DEFAULT_KEY
);
823 psw_set_key(PAGE_DEFAULT_KEY
);
825 free_bootmem_with_active_regions(0, max_pfn
);
826 reserve_bootmem(0, PFN_PHYS(start_pfn
));
829 * Reserve the bootmem bitmap itself as well. We do this in two
830 * steps (first step was init_bootmem()) because this catches
831 * the (very unlikely) case of us accidentally initializing the
832 * bootmem allocator with an invalid RAM area.
834 reserve_bootmem(start_pfn
<< PAGE_SHIFT
, bootmap_size
);
836 #ifdef CONFIG_BLK_DEV_INITRD
837 if (INITRD_START
&& INITRD_SIZE
) {
838 if (INITRD_START
+ INITRD_SIZE
<= memory_end
) {
839 reserve_bootmem(INITRD_START
, INITRD_SIZE
);
840 initrd_start
= INITRD_START
;
841 initrd_end
= initrd_start
+ INITRD_SIZE
;
843 printk("initrd extends beyond end of memory "
844 "(0x%08lx > 0x%08lx)\ndisabling initrd\n",
845 initrd_start
+ INITRD_SIZE
, memory_end
);
846 initrd_start
= initrd_end
= 0;
853 * Setup function called from init/main.c just after the banner
858 setup_arch(char **cmdline_p
)
861 * print what head.S has found out about the machine
864 printk((MACHINE_IS_VM
) ?
865 "We are running under VM (31 bit mode)\n" :
866 "We are running native (31 bit mode)\n");
867 printk((MACHINE_HAS_IEEE
) ?
868 "This machine has an IEEE fpu\n" :
869 "This machine has no IEEE fpu\n");
870 #else /* CONFIG_64BIT */
871 printk((MACHINE_IS_VM
) ?
872 "We are running under VM (64 bit mode)\n" :
873 "We are running native (64 bit mode)\n");
874 #endif /* CONFIG_64BIT */
876 /* Save unparsed command line copy for /proc/cmdline */
877 strlcpy(saved_command_line
, COMMAND_LINE
, COMMAND_LINE_SIZE
);
879 *cmdline_p
= COMMAND_LINE
;
880 *(*cmdline_p
+ COMMAND_LINE_SIZE
- 1) = '\0';
882 ROOT_DEV
= Root_RAM0
;
884 init_mm
.start_code
= PAGE_OFFSET
;
885 init_mm
.end_code
= (unsigned long) &_etext
;
886 init_mm
.end_data
= (unsigned long) &_edata
;
887 init_mm
.brk
= (unsigned long) &_end
;
889 if (MACHINE_HAS_MVCOS
)
890 memcpy(&uaccess
, &uaccess_mvcos
, sizeof(uaccess
));
892 memcpy(&uaccess
, &uaccess_std
, sizeof(uaccess
));
897 setup_addressing_mode();
903 __cpu_logical_map
[0] = S390_lowcore
.cpu_data
.cpu_addr
;
904 smp_setup_cpu_possible_map();
907 * Create kernel page tables and switch to virtual addressing.
911 /* Setup default console */
915 void print_cpu_info(struct cpuinfo_S390
*cpuinfo
)
921 "vers=%02X ident=%06X machine=%04X unused=%04X\n",
926 cpuinfo
->cpu_id
.version
,
927 cpuinfo
->cpu_id
.ident
,
928 cpuinfo
->cpu_id
.machine
,
929 cpuinfo
->cpu_id
.unused
);
933 * show_cpuinfo - Get information on one CPU for use by procfs.
936 static int show_cpuinfo(struct seq_file
*m
, void *v
)
938 struct cpuinfo_S390
*cpuinfo
;
939 unsigned long n
= (unsigned long) v
- 1;
943 seq_printf(m
, "vendor_id : IBM/S390\n"
944 "# processors : %i\n"
945 "bogomips per cpu: %lu.%02lu\n",
946 num_online_cpus(), loops_per_jiffy
/(500000/HZ
),
947 (loops_per_jiffy
/(5000/HZ
))%100);
951 if (smp_processor_id() == n
)
952 cpuinfo
= &S390_lowcore
.cpu_data
;
954 cpuinfo
= &lowcore_ptr
[n
]->cpu_data
;
956 cpuinfo
= &S390_lowcore
.cpu_data
;
958 seq_printf(m
, "processor %li: "
960 "identification = %06X, "
962 n
, cpuinfo
->cpu_id
.version
,
963 cpuinfo
->cpu_id
.ident
,
964 cpuinfo
->cpu_id
.machine
);
970 static void *c_start(struct seq_file
*m
, loff_t
*pos
)
972 return *pos
< NR_CPUS
? (void *)((unsigned long) *pos
+ 1) : NULL
;
974 static void *c_next(struct seq_file
*m
, void *v
, loff_t
*pos
)
977 return c_start(m
, pos
);
979 static void c_stop(struct seq_file
*m
, void *v
)
982 struct seq_operations cpuinfo_op
= {
986 .show
= show_cpuinfo
,