2 * linux/arch/arm/kernel/setup.c
4 * Copyright (C) 1995-2001 Russell King
5 * Copyright (C) 2003 Ian Molton
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
11 #include <linux/config.h>
12 #include <linux/kernel.h>
13 #include <linux/stddef.h>
14 #include <linux/ioport.h>
15 #include <linux/delay.h>
16 #include <linux/utsname.h>
17 #include <linux/blkdev.h>
18 #include <linux/console.h>
19 #include <linux/bootmem.h>
20 #include <linux/seq_file.h>
21 #include <linux/tty.h>
22 #include <linux/init.h>
23 #include <linux/root_dev.h>
26 #include <asm/hardware.h>
28 #include <asm/procinfo.h>
29 #include <asm/setup.h>
30 #include <asm/mach-types.h>
31 #include <asm/tlbflush.h>
33 #include <asm/irqchip.h>
36 #define MEM_SIZE (16*1024*1024)
40 spinlock_t kernel_flag = SPIN_LOCK_UNLOCKED;
43 #if defined(CONFIG_FPE_NWFPE)
46 static int __init fpe_setup(char *line)
48 memcpy(fpe_type, line, 8);
52 __setup("fpe=", fpe_setup);
55 extern void paging_init(struct meminfo *);
56 extern void convert_to_tag_list(struct tag *tags);
57 extern void squash_mem_tags(struct tag *tag);
58 extern void bootmem_init(struct meminfo *);
59 extern int root_mountflags;
60 extern int _stext, _text, _etext, _edata, _end;
61 #ifdef CONFIG_XIP_KERNEL
62 extern int _endtext, _sdata;
66 unsigned int processor_id;
67 unsigned int __machine_arch_type;
68 unsigned int system_rev;
69 unsigned int system_serial_low;
70 unsigned int system_serial_high;
71 unsigned int elf_hwcap;
72 unsigned int memc_ctrl_reg;
73 unsigned int number_mfm_drives;
75 struct processor processor;
77 unsigned char aux_device_present;
78 char elf_platform[ELF_PLATFORM_SIZE];
80 unsigned long phys_initrd_start __initdata = 0;
81 unsigned long phys_initrd_size __initdata = 0;
82 static struct meminfo meminfo __initdata = { 0, };
83 static struct proc_info_item proc_info;
84 static const char *machine_name;
85 static char command_line[COMMAND_LINE_SIZE];
87 static char default_command_line[COMMAND_LINE_SIZE] __initdata = CONFIG_CMDLINE;
90 * Standard memory resources
92 static struct resource mem_res[] = {
93 { "Video RAM", 0, 0, IORESOURCE_MEM },
94 { "Kernel code", 0, 0, IORESOURCE_MEM },
95 { "Kernel data", 0, 0, IORESOURCE_MEM }
98 #define video_ram mem_res[0]
99 #define kernel_code mem_res[1]
100 #define kernel_data mem_res[2]
102 static struct resource io_res[] = {
103 { "reserved", 0x3bc, 0x3be, IORESOURCE_IO | IORESOURCE_BUSY },
104 { "reserved", 0x378, 0x37f, IORESOURCE_IO | IORESOURCE_BUSY },
105 { "reserved", 0x278, 0x27f, IORESOURCE_IO | IORESOURCE_BUSY }
108 #define lp0 io_res[0]
109 #define lp1 io_res[1]
110 #define lp2 io_res[2]
112 #define dump_cpu_info() do { } while (0)
114 static void __init setup_processor(void)
116 extern struct proc_info_list __proc_info_begin, __proc_info_end;
117 struct proc_info_list *list;
120 * locate processor in the list of supported processor
121 * types. The linker builds this table for us from the
122 * entries in arch/arm/mm/proc-*.S
124 for (list = &__proc_info_begin; list < &__proc_info_end ; list++)
125 if ((processor_id & list->cpu_mask) == list->cpu_val)
129 * If processor type is unrecognised, then we
132 if (list >= &__proc_info_end) {
133 printk("CPU configuration botched (ID %08x), unable "
134 "to continue.\n", processor_id);
138 proc_info = *list->info;
139 processor = *list->proc;
142 printk("CPU: %s %s revision %d\n",
143 proc_info.manufacturer, proc_info.cpu_name,
144 (int)processor_id & 15);
148 sprintf(system_utsname.machine, "%s", list->arch_name);
149 sprintf(elf_platform, "%s", list->elf_name);
150 elf_hwcap = list->elf_hwcap;
156 * Initial parsing of the command line. We need to pick out the
157 * memory size. We look for mem=size@start, where start and size
161 parse_cmdline(struct meminfo *mi, char **cmdline_p, char *from)
163 char c = ' ', *to = command_line;
164 int usermem = 0, len = 0;
167 if (c == ' ' && !memcmp(from, "mem=", 4)) {
168 unsigned long size, start;
170 if (to != command_line)
174 * If the user specifies memory size, we
175 * blow away any automatically generated
184 size = memparse(from + 4, &from);
186 start = memparse(from + 1, &from);
188 mi->bank[mi->nr_banks].start = start;
189 mi->bank[mi->nr_banks].size = size;
190 mi->bank[mi->nr_banks].node = PHYS_TO_NID(start);
196 if (COMMAND_LINE_SIZE <= ++len)
201 *cmdline_p = command_line;
205 setup_ramdisk(int doload, int prompt, int image_start, unsigned int rd_sz)
207 #ifdef CONFIG_BLK_DEV_RAM
208 extern int rd_size, rd_image_start, rd_prompt, rd_doload;
210 rd_image_start = image_start;
220 request_standard_resources(struct meminfo *mi)
222 struct resource *res;
225 kernel_code.start = init_mm.start_code;
226 kernel_code.end = init_mm.end_code - 1;
227 #ifdef CONFIG_XIP_KERNEL
228 kernel_data.start = init_mm.start_data;
230 kernel_data.start = init_mm.end_code;
232 kernel_data.end = init_mm.brk - 1;
234 for (i = 0; i < mi->nr_banks; i++) {
235 unsigned long virt_start, virt_end;
237 if (mi->bank[i].size == 0)
240 virt_start = mi->bank[i].start;
241 virt_end = virt_start + mi->bank[i].size - 1;
243 res = alloc_bootmem_low(sizeof(*res));
244 res->name = "System RAM";
245 res->start = virt_start;
247 res->flags = IORESOURCE_MEM | IORESOURCE_BUSY;
249 request_resource(&iomem_resource, res);
251 if (kernel_code.start >= res->start &&
252 kernel_code.end <= res->end)
253 request_resource(res, &kernel_code);
254 if (kernel_data.start >= res->start &&
255 kernel_data.end <= res->end)
256 request_resource(res, &kernel_data);
259 /* FIXME - needed? if (mdesc->video_start) {
260 video_ram.start = mdesc->video_start;
261 video_ram.end = mdesc->video_end;
262 request_resource(&iomem_resource, &video_ram);
266 * Some machines don't have the possibility of ever
267 * possessing lp1 or lp2
269 if (0) /* FIXME - need to do this for A5k at least */
270 request_resource(&ioport_resource, &lp0);
276 * This is the new way of passing data to the kernel at boot time. Rather
277 * than passing a fixed inflexible structure to the kernel, we pass a list
278 * of variable-sized tags to the kernel. The first tag must be a ATAG_CORE
279 * tag for the list to be recognised (to distinguish the tagged list from
280 * a param_struct). The list is terminated with a zero-length tag (this tag
281 * is not parsed in any way).
283 static int __init parse_tag_core(const struct tag *tag)
285 if (tag->hdr.size > 2) {
286 if ((tag->u.core.flags & 1) == 0)
287 root_mountflags &= ~MS_RDONLY;
288 ROOT_DEV = old_decode_dev(tag->u.core.rootdev);
293 __tagtable(ATAG_CORE, parse_tag_core);
295 static int __init parse_tag_mem32(const struct tag *tag)
297 if (meminfo.nr_banks >= NR_BANKS) {
299 "Ignoring memory bank 0x%08x size %dKB\n",
300 tag->u.mem.start, tag->u.mem.size / 1024);
303 meminfo.bank[meminfo.nr_banks].start = tag->u.mem.start;
304 meminfo.bank[meminfo.nr_banks].size = tag->u.mem.size;
305 meminfo.bank[meminfo.nr_banks].node = PHYS_TO_NID(tag->u.mem.start);
306 meminfo.nr_banks += 1;
311 __tagtable(ATAG_MEM, parse_tag_mem32);
313 #if defined(CONFIG_DUMMY_CONSOLE)
314 struct screen_info screen_info = {
315 .orig_video_lines = 30,
316 .orig_video_cols = 80,
317 .orig_video_mode = 0,
318 .orig_video_ega_bx = 0,
319 .orig_video_isVGA = 1,
320 .orig_video_points = 8
323 static int __init parse_tag_videotext(const struct tag *tag)
325 screen_info.orig_x = tag->u.videotext.x;
326 screen_info.orig_y = tag->u.videotext.y;
327 screen_info.orig_video_page = tag->u.videotext.video_page;
328 screen_info.orig_video_mode = tag->u.videotext.video_mode;
329 screen_info.orig_video_cols = tag->u.videotext.video_cols;
330 screen_info.orig_video_ega_bx = tag->u.videotext.video_ega_bx;
331 screen_info.orig_video_lines = tag->u.videotext.video_lines;
332 screen_info.orig_video_isVGA = tag->u.videotext.video_isvga;
333 screen_info.orig_video_points = tag->u.videotext.video_points;
337 __tagtable(ATAG_VIDEOTEXT, parse_tag_videotext);
340 static int __init parse_tag_acorn(const struct tag *tag)
342 memc_ctrl_reg = tag->u.acorn.memc_control_reg;
343 number_mfm_drives = tag->u.acorn.adfsdrives;
347 __tagtable(ATAG_ACORN, parse_tag_acorn);
349 static int __init parse_tag_ramdisk(const struct tag *tag)
351 setup_ramdisk((tag->u.ramdisk.flags & 1) == 0,
352 (tag->u.ramdisk.flags & 2) == 0,
353 tag->u.ramdisk.start, tag->u.ramdisk.size);
357 __tagtable(ATAG_RAMDISK, parse_tag_ramdisk);
359 static int __init parse_tag_initrd(const struct tag *tag)
361 printk(KERN_WARNING "ATAG_INITRD is deprecated; please update your bootloader. \n");
362 phys_initrd_start = (unsigned long)tag->u.initrd.start;
363 phys_initrd_size = (unsigned long)tag->u.initrd.size;
367 __tagtable(ATAG_INITRD, parse_tag_initrd);
369 static int __init parse_tag_initrd2(const struct tag *tag)
371 printk(KERN_WARNING "ATAG_INITRD is deprecated; please update your bootloader. \n");
372 phys_initrd_start = (unsigned long)tag->u.initrd.start;
373 phys_initrd_size = (unsigned long)tag->u.initrd.size;
377 __tagtable(ATAG_INITRD2, parse_tag_initrd2);
379 static int __init parse_tag_serialnr(const struct tag *tag)
381 system_serial_low = tag->u.serialnr.low;
382 system_serial_high = tag->u.serialnr.high;
386 __tagtable(ATAG_SERIAL, parse_tag_serialnr);
388 static int __init parse_tag_revision(const struct tag *tag)
390 system_rev = tag->u.revision.rev;
394 __tagtable(ATAG_REVISION, parse_tag_revision);
396 static int __init parse_tag_cmdline(const struct tag *tag)
398 strncpy(default_command_line, tag->u.cmdline.cmdline, COMMAND_LINE_SIZE);
399 default_command_line[COMMAND_LINE_SIZE - 1] = '\0';
403 __tagtable(ATAG_CMDLINE, parse_tag_cmdline);
406 * Scan the tag table for this tag, and call its parse function.
407 * The tag table is built by the linker from all the __tagtable
410 static int __init parse_tag(const struct tag *tag)
412 extern struct tagtable __tagtable_begin, __tagtable_end;
415 for (t = &__tagtable_begin; t < &__tagtable_end; t++)
416 if (tag->hdr.tag == t->tag) {
421 return t < &__tagtable_end;
425 * Parse all tags in the list, checking both the global and architecture
426 * specific tag tables.
428 static void __init parse_tags(const struct tag *t)
430 for (; t->hdr.size; t = tag_next(t))
433 "Ignoring unrecognised tag 0x%08x\n",
438 * This holds our defaults.
440 static struct init_tags {
441 struct tag_header hdr1;
442 struct tag_core core;
443 struct tag_header hdr2;
444 struct tag_mem32 mem;
445 struct tag_header hdr3;
446 } init_tags __initdata = {
447 { tag_size(tag_core), ATAG_CORE },
448 { 1, PAGE_SIZE, 0xff },
449 { tag_size(tag_mem32), ATAG_MEM },
450 { MEM_SIZE, PHYS_OFFSET },
454 void __init setup_arch(char **cmdline_p)
456 struct tag *tags = (struct tag *)&init_tags;
457 char *from = default_command_line;
460 if(machine_arch_type == MACH_TYPE_A5K)
461 machine_name = "A5000";
462 else if(machine_arch_type == MACH_TYPE_ARCHIMEDES)
463 machine_name = "Archimedes";
465 machine_name = "UNKNOWN";
467 //FIXME - the tag struct is always copied here but this is a block
468 // of RAM that is accidentally reserved along with video RAM. perhaps
469 // it would be a good idea to explicitly reserve this?
471 tags = (struct tag *)0x0207c000;
474 * If we have the old style parameters, convert them to
477 if (tags->hdr.tag != ATAG_CORE)
478 convert_to_tag_list(tags);
479 if (tags->hdr.tag != ATAG_CORE)
480 tags = (struct tag *)&init_tags;
481 if (tags->hdr.tag == ATAG_CORE) {
482 if (meminfo.nr_banks != 0)
483 squash_mem_tags(tags);
487 init_mm.start_code = (unsigned long) &_text;
488 #ifndef CONFIG_XIP_KERNEL
489 init_mm.end_code = (unsigned long) &_etext;
491 init_mm.end_code = (unsigned long) &_endtext;
492 init_mm.start_data = (unsigned long) &_sdata;
494 init_mm.end_data = (unsigned long) &_edata;
495 init_mm.brk = (unsigned long) &_end;
497 memcpy(saved_command_line, from, COMMAND_LINE_SIZE);
498 saved_command_line[COMMAND_LINE_SIZE-1] = '\0';
499 parse_cmdline(&meminfo, cmdline_p, from);
500 bootmem_init(&meminfo);
501 paging_init(&meminfo);
502 request_standard_resources(&meminfo);
505 #if defined(CONFIG_DUMMY_CONSOLE)
506 conswitchp = &dummy_con;
511 static const char *hwcap_str[] = {
523 static int c_show(struct seq_file *m, void *v)
527 seq_printf(m, "Processor\t: %s %s rev %d (%s)\n",
528 proc_info.manufacturer, proc_info.cpu_name,
529 (int)processor_id & 15, elf_platform);
531 seq_printf(m, "BogoMIPS\t: %lu.%02lu\n",
532 loops_per_jiffy / (500000/HZ),
533 (loops_per_jiffy / (5000/HZ)) % 100);
535 /* dump out the processor features */
536 seq_puts(m, "Features\t: ");
538 for (i = 0; hwcap_str[i]; i++)
539 if (elf_hwcap & (1 << i))
540 seq_printf(m, "%s ", hwcap_str[i]);
544 seq_printf(m, "CPU part\t\t: %07x\n", processor_id >> 4);
545 seq_printf(m, "CPU revision\t: %d\n\n", processor_id & 15);
546 seq_printf(m, "Hardware\t: %s\n", machine_name);
547 seq_printf(m, "Revision\t: %04x\n", system_rev);
548 seq_printf(m, "Serial\t\t: %08x%08x\n",
549 system_serial_high, system_serial_low);
554 static void *c_start(struct seq_file *m, loff_t *pos)
556 return *pos < 1 ? (void *)1 : NULL;
559 static void *c_next(struct seq_file *m, void *v, loff_t *pos)
565 static void c_stop(struct seq_file *m, void *v)
569 struct seq_operations cpuinfo_op = {