2 * linux/arch/arm/kernel/setup.c
4 * Copyright (C) 1995-1998 Russell King
8 * This file obtains various parameters about the system that the kernel
12 #include <linux/config.h>
13 #include <linux/errno.h>
14 #include <linux/sched.h>
15 #include <linux/kernel.h>
17 #include <linux/stddef.h>
18 #include <linux/unistd.h>
19 #include <linux/ptrace.h>
20 #include <linux/malloc.h>
21 #include <linux/user.h>
22 #include <linux/a.out.h>
23 #include <linux/tty.h>
24 #include <linux/ioport.h>
25 #include <linux/delay.h>
26 #include <linux/major.h>
27 #include <linux/utsname.h>
28 #include <linux/blk.h>
29 #include <linux/init.h>
30 #include <linux/console.h>
33 #include <asm/hardware.h>
35 #include <asm/pgtable.h>
36 #include <asm/procinfo.h>
37 #include <asm/segment.h>
38 #include <asm/setup.h>
39 #include <asm/system.h>
41 /* Work out which CPUs to support */
42 #ifdef CONFIG_ARCH_ACORN
43 #define SUPPORT_CPU_ARM6
44 #define SUPPORT_CPU_ARM7
45 #define SUPPORT_CPU_SA110
47 #define SUPPORT_CPU_SA110
49 #ifdef CONFIG_CPU_ARM6
50 #define SUPPORT_CPU_ARM6
52 #ifdef CONFIG_CPU_ARM7
53 #define SUPPORT_CPU_ARM7
55 #ifdef CONFIG_CPU_SA110
56 #define SUPPORT_CPU_SA110
59 #define MEM_SIZE (16*1024*1024)
60 #define COMMAND_LINE_SIZE 256
62 #ifndef CONFIG_CMDLINE
63 #define CONFIG_CMDLINE ""
66 extern void reboot_setup(char *str
, int *ints
);
67 extern void fpe_init(void);
68 extern void disable_hlt(void);
70 struct drive_info_struct
{ char dummy
[32]; } drive_info
;
71 struct screen_info screen_info
= {
79 struct processor processor
;
80 unsigned char aux_device_present
;
82 extern const struct processor arm2_processor_functions
;
83 extern const struct processor arm250_processor_functions
;
84 extern const struct processor arm3_processor_functions
;
85 extern const struct processor arm6_processor_functions
;
86 extern const struct processor arm7_processor_functions
;
87 extern const struct processor sa110_processor_functions
;
89 char elf_platform
[ELF_PLATFORM_SIZE
];
91 const struct armversions armidlist
[] = {
92 /*-- Match -- --- Mask -- -- Manu -- Processor uname -m --- ELF STUFF ---
93 --- processor asm funcs --- */
94 #if defined(CONFIG_CPU_26)
96 { 0x41560200, 0xfffffff0, "ARM/VLSI", "arm2" , "armv1" , "v1", 0,
97 &arm2_processor_functions
},
98 /* ARM250 fake ident */
99 { 0x41560250, 0xfffffff0, "ARM/VLSI", "arm250" , "armv2" , "v2", HWCAP_SWP
,
100 &arm250_processor_functions
},
101 /* ARM3 processors */
102 { 0x41560300, 0xfffffff0, "ARM/VLSI", "arm3" , "armv2" , "v2", HWCAP_SWP
,
103 &arm3_processor_functions
},
104 #elif defined(CONFIG_CPU_32)
105 #ifdef SUPPORT_CPU_ARM6
107 { 0x41560600, 0xfffffff0, "ARM/VLSI", "arm6" , "armv3" , "v3", HWCAP_SWP
,
108 &arm6_processor_functions
},
110 { 0x41560610, 0xfffffff0, "ARM/VLSI", "arm610" , "armv3" , "v3", HWCAP_SWP
,
111 &arm6_processor_functions
},
113 #ifdef SUPPORT_CPU_ARM7
114 /* ARM7's have a strange numbering */
115 { 0x41007000, 0xffffff00, "ARM/VLSI", "arm7" , "armv3" , "v3", HWCAP_SWP
,
116 &arm7_processor_functions
},
117 /* ARM710 IDs are non-standard */
118 { 0x41007100, 0xfff8ff00, "ARM/VLSI", "arm710" , "armv3" , "v3", HWCAP_SWP
,
119 &arm7_processor_functions
},
121 #ifdef SUPPORT_CPU_SA110
122 #ifdef CONFIG_ARCH_RPC
123 /* Acorn RiscPC's can't handle ARMv4 half-word instructions */
124 { 0x4401a100, 0xfffffff0, "Intel", "sa110" , "armv4" , "v4", HWCAP_SWP
,
125 &sa110_processor_functions
},
127 { 0x4401a100, 0xfffffff0, "Intel", "sa110" , "armv4" , "v4", HWCAP_SWP
|HWCAP_HALF
,
128 &sa110_processor_functions
},
132 { 0x00000000, 0x00000000, "***", "unknown", "unknown", "**", 0, NULL
}
138 unsigned int processor_id
;
139 unsigned int __machine_arch_type
;
142 extern int root_mountflags
;
143 extern int _etext
, _edata
, _end
;
145 /*-------------------------------------------------------------------------
146 * Early initialisation routines for various configurable items in the
147 * kernel. Each one either supplies a setup_ function, or defines this
148 * symbol to be empty if not configured.
154 #ifdef CONFIG_BLK_DEV_INITRD
155 __initfunc(static void
156 check_initrd(unsigned long mem_start
, unsigned long mem_end
))
158 if (initrd_end
> mem_end
) {
159 printk ("initrd extends beyond end of memory "
160 "(0x%08lx > 0x%08lx) - disabling initrd\n",
161 initrd_end
, mem_end
);
167 #define check_initrd(ms,me)
171 setup_processor(void))
175 while ((armidlist
[armidindex
].id
^ processor_id
) &
176 armidlist
[armidindex
].mask
)
179 if (armidlist
[armidindex
].id
== 0)
182 processor
= *armidlist
[armidindex
].proc
;
183 processor
._proc_init();
186 static char default_command_line
[COMMAND_LINE_SIZE
] __initdata
= CONFIG_CMDLINE
;
187 static char command_line
[COMMAND_LINE_SIZE
] = { 0, };
188 char saved_command_line
[COMMAND_LINE_SIZE
];
190 __initfunc(static void
191 setup_mem(char *cmd_line
, unsigned long *mem_start
, unsigned long *mem_sz
))
193 char c
= ' ', *to
= command_line
;
196 *mem_start
= (unsigned long)&_end
;
200 if (cmd_line
[0] == 'm' &&
201 cmd_line
[1] == 'e' &&
202 cmd_line
[2] == 'm' &&
203 cmd_line
[3] == '=') {
204 *mem_sz
= simple_strtoul(cmd_line
+4, &cmd_line
, 0);
215 /* if there are two spaces, remove one */
216 if (*cmd_line
== ' ') {
224 if (COMMAND_LINE_SIZE
<= ++len
)
231 /* remove trailing spaces */
232 while (*--to
== ' ' && to
!= command_line
)
236 __initfunc(static void
237 setup_ram(int doload
, int prompt
, int image_start
))
239 #ifdef CONFIG_BLK_DEV_RAM
240 extern int rd_doload
;
241 extern int rd_prompt
;
242 extern int rd_image_start
;
244 rd_image_start
= image_start
;
253 __initfunc(static void
254 setup_initrd(unsigned int start
, unsigned int size
))
256 #ifdef CONFIG_BLK_DEV_INITRD
258 initrd_start
= start
;
259 initrd_end
= start
+ size
;
267 #ifdef CONFIG_ARCH_ACORN
269 int number_mfm_drives
;
270 unsigned int vram_size
;
274 #define PARAMS_BASE NULL
277 static union { char c
[4]; unsigned long l
; } endian_test __initdata
= { { 'l', '?', '?', 'b' } };
278 #define ENDIANNESS ((char)endian_test.l)
281 setup_arch(char **cmdline_p
, unsigned long * memory_start_p
, unsigned long * memory_end_p
))
283 struct param_struct
*params
= (struct param_struct
*)PARAMS_BASE
;
284 static unsigned char smptrap
;
285 unsigned long memory_end
= 0;
292 #if defined(CONFIG_ARCH_ARC)
293 __machine_arch_type
= MACH_TYPE_ARCHIMEDES
;
294 #elif defined(CONFIG_ARCH_A5K)
295 __machine_arch_type
= MACH_TYPE_A5K
;
300 init_mm
.start_code
= TASK_SIZE
;
301 init_mm
.end_code
= TASK_SIZE
+ (unsigned long) &_etext
;
302 init_mm
.end_data
= TASK_SIZE
+ (unsigned long) &_edata
;
303 init_mm
.brk
= TASK_SIZE
+ (unsigned long) &_end
;
306 * Add your machine dependencies here
308 switch (machine_arch_type
) {
309 case MACH_TYPE_EBSA110
:
310 /* EBSA110 locks if we execute 'wait for interrupt' */
312 if (params
&& params
->u1
.s
.page_size
!= 4096)
316 case MACH_TYPE_EBSA285
:
318 ORIG_X
= params
->u1
.s
.video_x
;
319 ORIG_Y
= params
->u1
.s
.video_y
;
320 ORIG_VIDEO_COLS
= params
->u1
.s
.video_num_cols
;
321 ORIG_VIDEO_LINES
= params
->u1
.s
.video_num_rows
;
325 case MACH_TYPE_CO285
:
328 extern unsigned long boot_memory_end
;
329 extern char boot_command_line
[];
331 from
= boot_command_line
;
332 memory_end
= boot_memory_end
;
339 /* CATS must use soft-reboot */
340 reboot_setup("s", NULL
);
343 case MACH_TYPE_NETWINDER
:
345 * to be fixed in a future NeTTrom
347 if (params
->u1
.s
.page_size
== 4096) {
348 if (params
->u1
.s
.nr_pages
!= 0x2000 &&
349 params
->u1
.s
.nr_pages
!= 0x4000) {
350 printk("Warning: bad NeTTrom parameters detected, using defaults\n");
352 * This stuff doesn't appear to be initialised
353 * properly by NeTTrom 2.0.6 and 2.0.7
355 params
->u1
.s
.nr_pages
= 0x2000; /* 32MB */
356 params
->u1
.s
.ramdisk_size
= 0;
357 params
->u1
.s
.flags
= FLAG_READONLY
;
358 params
->u1
.s
.initrd_start
= 0;
359 params
->u1
.s
.initrd_size
= 0;
360 params
->u1
.s
.rd_start
= 0;
361 params
->u1
.s
.video_x
= 0;
362 params
->u1
.s
.video_y
= 0;
363 params
->u1
.s
.video_num_cols
= 80;
364 params
->u1
.s
.video_num_rows
= 30;
367 printk("Warning: no NeTTrom parameter page detected, using "
368 "compiled-in settings\n");
378 memory_end
= params
->u1
.s
.page_size
*
379 params
->u1
.s
.nr_pages
;
381 ROOT_DEV
= to_kdev_t(params
->u1
.s
.rootdev
);
383 setup_ram((params
->u1
.s
.flags
& FLAG_RDLOAD
) == 0,
384 (params
->u1
.s
.flags
& FLAG_RDPROMPT
) == 0,
385 params
->u1
.s
.rd_start
);
387 setup_initrd(params
->u1
.s
.initrd_start
,
388 params
->u1
.s
.initrd_size
);
390 if (!(params
->u1
.s
.flags
& FLAG_READONLY
))
391 root_mountflags
&= ~MS_RDONLY
;
393 #ifdef CONFIG_ARCH_ACORN
394 #ifdef CONFIG_ARCH_RPC
396 extern void init_dram_banks(struct param_struct
*);
397 init_dram_banks(params
);
401 memc_ctrl_reg
= params
->u1
.s
.memc_control_reg
;
402 number_mfm_drives
= (params
->u1
.s
.adfsdrives
>> 3) & 3;
405 switch (params
->u1
.s
.pages_in_vram
) {
407 vram_size
+= PAGE_SIZE
* 256;
409 vram_size
+= PAGE_SIZE
* 256;
414 memory_end
-= vram_size
;
417 from
= params
->commandline
;
426 memory_end
= MEM_SIZE
;
429 from
= default_command_line
;
435 /* Save unparsed command line copy for /proc/cmdline */
436 memcpy(saved_command_line
, from
, COMMAND_LINE_SIZE
);
437 saved_command_line
[COMMAND_LINE_SIZE
-1] = '\0';
439 setup_mem(from
, memory_start_p
, &memory_end
);
441 memory_end
+= PAGE_OFFSET
;
443 check_initrd(*memory_start_p
, memory_end
);
445 sprintf(system_utsname
.machine
, "%s%c", armidlist
[armidindex
].arch_vsn
, ENDIANNESS
);
446 sprintf(elf_platform
, "%s%c", armidlist
[armidindex
].elf_vsn
, ENDIANNESS
);
449 #if defined(CONFIG_VGA_CONSOLE)
450 conswitchp
= &vga_con
;
451 #elif defined(CONFIG_DUMMY_CONSOLE)
452 conswitchp
= &dummy_con
;
456 *cmdline_p
= command_line
;
457 *memory_end_p
= memory_end
;
460 static const char *machine_desc
[] = {
475 int get_cpuinfo(char * buffer
)
479 len
= sprintf(buffer
,
480 "Processor\t: %s %s rev %d\n"
481 "BogoMips\t: %lu.%02lu\n"
483 armidlist
[armidindex
].manu
,
484 armidlist
[armidindex
].name
,
485 (int)processor_id
& 15,
486 (loops_per_sec
+2500) / 500000,
487 ((loops_per_sec
+2500) / 5000) % 100,
488 machine_desc
[machine_arch_type
]);