Import 2.3.12pre2
[davej-history.git] / arch / arm / kernel / setup.c
blob1555278fd5c77d49f5d705b85a58cf4ad14571aa
1 /*
2 * linux/arch/arm/kernel/setup.c
4 * Copyright (C) 1995-1998 Russell King
5 */
7 /*
8 * This file obtains various parameters about the system that the kernel
9 * is running on.
12 #include <linux/config.h>
13 #include <linux/errno.h>
14 #include <linux/sched.h>
15 #include <linux/kernel.h>
16 #include <linux/mm.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>
32 #include <asm/elf.h>
33 #include <asm/hardware.h>
34 #include <asm/io.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
46 #else
47 #define SUPPORT_CPU_SA110
48 #endif
49 #ifdef CONFIG_CPU_ARM6
50 #define SUPPORT_CPU_ARM6
51 #endif
52 #ifdef CONFIG_CPU_ARM7
53 #define SUPPORT_CPU_ARM7
54 #endif
55 #ifdef CONFIG_CPU_SA110
56 #define SUPPORT_CPU_SA110
57 #endif
59 #define MEM_SIZE (16*1024*1024)
60 #define COMMAND_LINE_SIZE 256
62 #ifndef CONFIG_CMDLINE
63 #define CONFIG_CMDLINE ""
64 #endif
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 = {
72 orig_video_lines: 30,
73 orig_video_cols: 80,
74 orig_video_mode: 0,
75 orig_video_ega_bx: 0,
76 orig_video_isVGA: 1,
77 orig_video_points: 8
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)
95 /* ARM2 fake ident */
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
106 /* ARM6 */
107 { 0x41560600, 0xfffffff0, "ARM/VLSI", "arm6" , "armv3" , "v3", HWCAP_SWP,
108 &arm6_processor_functions },
109 /* ARM610 */
110 { 0x41560610, 0xfffffff0, "ARM/VLSI", "arm610" , "armv3" , "v3", HWCAP_SWP,
111 &arm6_processor_functions },
112 #endif
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 },
120 #endif
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 },
126 #else
127 { 0x4401a100, 0xfffffff0, "Intel", "sa110" , "armv4" , "v4", HWCAP_SWP|HWCAP_HALF,
128 &sa110_processor_functions },
129 #endif
130 #endif
131 #endif
132 { 0x00000000, 0x00000000, "***", "unknown", "unknown", "**", 0, NULL }
136 * From head-armv.S
138 unsigned int processor_id;
139 unsigned int __machine_arch_type;
140 int armidindex;
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.
152 * initial ram disk
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);
162 initrd_start = 0;
166 #else
167 #define check_initrd(ms,me)
168 #endif
170 __initfunc(void
171 setup_processor(void))
173 armidindex = 0;
175 while ((armidlist[armidindex].id ^ processor_id) &
176 armidlist[armidindex].mask)
177 armidindex += 1;
179 if (armidlist[armidindex].id == 0)
180 while (1);
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;
194 int len = 0;
196 *mem_start = (unsigned long)&_end;
198 for (;;) {
199 if (c == ' ') {
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);
205 switch(*cmd_line) {
206 case 'M':
207 case 'm':
208 *mem_sz <<= 10;
209 case 'K':
210 case 'k':
211 *mem_sz <<= 10;
212 cmd_line++;
215 /* if there are two spaces, remove one */
216 if (*cmd_line == ' ') {
217 cmd_line++;
218 continue;
221 c = *cmd_line++;
222 if (!c)
223 break;
224 if (COMMAND_LINE_SIZE <= ++len)
225 break;
226 *to++ = c;
229 *to = '\0';
231 /* remove trailing spaces */
232 while (*--to == ' ' && to != command_line)
233 *to = '\0';
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;
245 rd_prompt = prompt;
246 rd_doload = doload;
247 #endif
251 * initial ram disk
253 __initfunc(static void
254 setup_initrd(unsigned int start, unsigned int size))
256 #ifdef CONFIG_BLK_DEV_INITRD
257 if (start) {
258 initrd_start = start;
259 initrd_end = start + size;
260 } else {
261 initrd_start = 0;
262 initrd_end = 0;
264 #endif
267 #ifdef CONFIG_ARCH_ACORN
268 int memc_ctrl_reg;
269 int number_mfm_drives;
270 unsigned int vram_size;
271 #endif
273 #ifndef PARAMS_BASE
274 #define PARAMS_BASE NULL
275 #endif
277 static union { char c[4]; unsigned long l; } endian_test __initdata = { { 'l', '?', '?', 'b' } };
278 #define ENDIANNESS ((char)endian_test.l)
280 __initfunc(void
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;
286 char *from = NULL;
288 if (smptrap == 1)
289 return;
290 smptrap = 1;
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;
296 #endif
298 setup_processor();
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' */
311 disable_hlt();
312 if (params && params->u1.s.page_size != 4096)
313 params = NULL;
314 break;
316 case MACH_TYPE_EBSA285:
317 if (params) {
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;
323 break;
325 case MACH_TYPE_CO285:
327 #if 0
328 extern unsigned long boot_memory_end;
329 extern char boot_command_line[];
331 from = boot_command_line;
332 memory_end = boot_memory_end;
333 #endif
334 params = NULL;
336 break;
338 case MACH_TYPE_CATS:
339 /* CATS must use soft-reboot */
340 reboot_setup("s", NULL);
341 break;
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;
366 } else {
367 printk("Warning: no NeTTrom parameter page detected, using "
368 "compiled-in settings\n");
369 params = NULL;
371 break;
373 default:
374 break;
377 if (params) {
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);
399 #endif
401 memc_ctrl_reg = params->u1.s.memc_control_reg;
402 number_mfm_drives = (params->u1.s.adfsdrives >> 3) & 3;
403 vram_size = 0;
405 switch (params->u1.s.pages_in_vram) {
406 case 512:
407 vram_size += PAGE_SIZE * 256;
408 case 256:
409 vram_size += PAGE_SIZE * 256;
410 default:
411 break;
414 memory_end -= vram_size;
415 #endif
417 from = params->commandline;
418 } else {
419 ROOT_DEV = 0x00ff;
421 setup_ram(1, 1, 0);
422 setup_initrd(0, 0);
425 if (!memory_end)
426 memory_end = MEM_SIZE;
428 if (!from)
429 from = default_command_line;
431 #ifdef CONFIG_NWFPE
432 fpe_init();
433 #endif
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);
448 #ifdef CONFIG_VT
449 #if defined(CONFIG_VGA_CONSOLE)
450 conswitchp = &vga_con;
451 #elif defined(CONFIG_DUMMY_CONSOLE)
452 conswitchp = &dummy_con;
453 #endif
454 #endif
456 *cmdline_p = command_line;
457 *memory_end_p = memory_end;
460 static const char *machine_desc[] = {
461 "EBSA110",
462 "Acorn-RiscPC",
463 "unknown",
464 "Nexus-FTV/PCI",
465 "EBSA285",
466 "Corel-NetWinder",
467 "Chalice-CATS",
468 "unknown-TBOX",
469 "co-EBSA285",
470 "CL-PS7110",
471 "Acorn-Archimedes",
472 "Acorn-A5000"
475 int get_cpuinfo(char * buffer)
477 int len;
479 len = sprintf(buffer,
480 "Processor\t: %s %s rev %d\n"
481 "BogoMips\t: %lu.%02lu\n"
482 "Hardware\t: %s\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]);
489 return len;