4 * This file is subject to the terms and conditions of the GNU General Public
5 * License. See the file "COPYING" in the main directory of this archive
8 * Copyright (C) 1995 Linus Torvalds
9 * Copyright (C) 2001 - 2005 Tensilica Inc.
11 * Chris Zankel <chris@zankel.net>
12 * Joe Taylor <joe@tensilica.com, joetylr@yahoo.com>
14 * Marc Gauthier<marc@tensilica.com> <marc@alumni.uwaterloo.ca>
17 #include <linux/errno.h>
18 #include <linux/init.h>
19 #include <linux/proc_fs.h>
20 #include <linux/tty.h>
21 #include <linux/bootmem.h>
22 #include <linux/kernel.h>
24 #if defined(CONFIG_VGA_CONSOLE) || defined(CONFIG_DUMMY_CONSOLE)
25 # include <linux/console.h>
29 # include <linux/timex.h>
33 # include <linux/seq_file.h>
36 #include <asm/system.h>
37 #include <asm/bootparam.h>
38 #include <asm/pgtable.h>
39 #include <asm/processor.h>
40 #include <asm/timex.h>
41 #include <asm/platform.h>
43 #include <asm/setup.h>
45 #include <xtensa/config/system.h>
47 #if defined(CONFIG_VGA_CONSOLE) || defined(CONFIG_DUMMY_CONSOLE)
48 struct screen_info screen_info = { 0, 24, 0, 0, 0, 80, 0, 0, 0, 24, 1, 16};
51 #ifdef CONFIG_BLK_DEV_FD
52 extern struct fd_ops no_fd_ops;
53 struct fd_ops *fd_ops;
56 #if defined(CONFIG_BLK_DEV_IDE) || defined(CONFIG_BLK_DEV_IDE_MODULE)
57 extern struct ide_ops no_ide_ops;
58 struct ide_ops *ide_ops;
61 extern struct rtc_ops no_rtc_ops;
62 struct rtc_ops *rtc_ops;
65 extern struct kbd_ops no_kbd_ops;
66 struct kbd_ops *kbd_ops;
69 #ifdef CONFIG_BLK_DEV_INITRD
70 extern void *initrd_start;
71 extern void *initrd_end;
72 extern void *__initrd_start;
73 extern void *__initrd_end;
74 int initrd_is_mapped = 0;
75 extern int initrd_below_start_ok;
78 unsigned char aux_device_present;
79 extern unsigned long loops_per_jiffy;
81 /* Command line specified as configuration option. */
83 static char command_line[COMMAND_LINE_SIZE];
85 #ifdef CONFIG_CMDLINE_BOOL
86 static char default_command_line[COMMAND_LINE_SIZE] __initdata = CONFIG_CMDLINE;
89 sysmem_info_t __initdata sysmem;
91 #ifdef CONFIG_BLK_DEV_INITRD
95 extern void init_mmu(void);
98 * Boot parameter parsing.
100 * The Xtensa port uses a list of variable-sized tags to pass data to
101 * the kernel. The first tag must be a BP_TAG_FIRST tag for the list
102 * to be recognised. The list is terminated with a zero-sized
106 typedef struct tagtable {
108 int (*parse)(const bp_tag_t*);
111 #define __tagtable(tag, fn) static tagtable_t __tagtable_##fn \
112 __attribute__((unused, __section__(".taglist"))) = { tag, fn }
114 /* parse current tag */
116 static int __init parse_tag_mem(const bp_tag_t *tag)
118 meminfo_t *mi = (meminfo_t*)(tag->data);
120 if (mi->type != MEMORY_TYPE_CONVENTIONAL)
123 if (sysmem.nr_banks >= SYSMEM_BANKS_MAX) {
125 "Ignoring memory bank 0x%08lx size %ldKB\n",
126 (unsigned long)mi->start,
127 (unsigned long)mi->end - (unsigned long)mi->start);
130 sysmem.bank[sysmem.nr_banks].type = mi->type;
131 sysmem.bank[sysmem.nr_banks].start = PAGE_ALIGN(mi->start);
132 sysmem.bank[sysmem.nr_banks].end = mi->end & PAGE_SIZE;
138 __tagtable(BP_TAG_MEMORY, parse_tag_mem);
140 #ifdef CONFIG_BLK_DEV_INITRD
142 static int __init parse_tag_initrd(const bp_tag_t* tag)
145 mi = (meminfo_t*)(tag->data);
146 initrd_start = (void*)(mi->start);
147 initrd_end = (void*)(mi->end);
152 __tagtable(BP_TAG_INITRD, parse_tag_initrd);
154 #endif /* CONFIG_BLK_DEV_INITRD */
156 static int __init parse_tag_cmdline(const bp_tag_t* tag)
158 strncpy(command_line, (char*)(tag->data), COMMAND_LINE_SIZE);
159 command_line[COMMAND_LINE_SIZE - 1] = '\0';
163 __tagtable(BP_TAG_COMMAND_LINE, parse_tag_cmdline);
165 static int __init parse_bootparam(const bp_tag_t* tag)
167 extern tagtable_t __tagtable_begin, __tagtable_end;
170 /* Boot parameters must start with a BP_TAG_FIRST tag. */
172 if (tag->id != BP_TAG_FIRST) {
173 printk(KERN_WARNING "Invalid boot parameters!\n");
177 tag = (bp_tag_t*)((unsigned long)tag + sizeof(bp_tag_t) + tag->size);
179 /* Parse all tags. */
181 while (tag != NULL && tag->id != BP_TAG_LAST) {
182 for (t = &__tagtable_begin; t < &__tagtable_end; t++) {
183 if (tag->id == t->tag) {
188 if (t == &__tagtable_end)
189 printk(KERN_WARNING "Ignoring tag "
190 "0x%08x\n", tag->id);
191 tag = (bp_tag_t*)((unsigned long)(tag + 1) + tag->size);
198 * Initialize architecture. (Early stage)
201 void __init init_arch(bp_tag_t *bp_start)
204 #ifdef CONFIG_BLK_DEV_INITRD
205 initrd_start = &__initrd_start;
206 initrd_end = &__initrd_end;
211 #ifdef CONFIG_CMDLINE_BOOL
212 strcpy(command_line, default_command_line);
215 /* Parse boot parameters */
218 parse_bootparam(bp_start);
220 if (sysmem.nr_banks == 0) {
222 sysmem.bank[0].start = PLATFORM_DEFAULT_MEM_START;
223 sysmem.bank[0].end = PLATFORM_DEFAULT_MEM_START
224 + PLATFORM_DEFAULT_MEM_SIZE;
227 /* Early hook for platforms */
229 platform_init(bp_start);
231 /* Initialize MMU. */
237 * Initialize system. Setup memory and reserve regions.
242 extern char _WindowVectors_text_start;
243 extern char _WindowVectors_text_end;
244 extern char _DebugInterruptVector_literal_start;
245 extern char _DebugInterruptVector_text_end;
246 extern char _KernelExceptionVector_literal_start;
247 extern char _KernelExceptionVector_text_end;
248 extern char _UserExceptionVector_literal_start;
249 extern char _UserExceptionVector_text_end;
250 extern char _DoubleExceptionVector_literal_start;
251 extern char _DoubleExceptionVector_text_end;
253 void __init setup_arch(char **cmdline_p)
255 extern int mem_reserve(unsigned long, unsigned long, int);
256 extern void bootmem_init(void);
258 memcpy(saved_command_line, command_line, COMMAND_LINE_SIZE);
259 saved_command_line[COMMAND_LINE_SIZE-1] = '\0';
260 *cmdline_p = command_line;
262 /* Reserve some memory regions */
264 #ifdef CONFIG_BLK_DEV_INITRD
265 if (initrd_start < initrd_end) {
266 initrd_is_mapped = mem_reserve(__pa(initrd_start),
267 __pa(initrd_end), 0);
268 initrd_below_start_ok = 1;
274 mem_reserve(__pa(&_stext),__pa(&_end), 1);
276 mem_reserve(__pa(&_WindowVectors_text_start),
277 __pa(&_WindowVectors_text_end), 0);
279 mem_reserve(__pa(&_DebugInterruptVector_literal_start),
280 __pa(&_DebugInterruptVector_text_end), 0);
282 mem_reserve(__pa(&_KernelExceptionVector_literal_start),
283 __pa(&_KernelExceptionVector_text_end), 0);
285 mem_reserve(__pa(&_UserExceptionVector_literal_start),
286 __pa(&_UserExceptionVector_text_end), 0);
288 mem_reserve(__pa(&_DoubleExceptionVector_literal_start),
289 __pa(&_DoubleExceptionVector_text_end), 0);
293 platform_setup(cmdline_p);
299 # if defined(CONFIG_VGA_CONSOLE)
300 conswitchp = &vga_con;
301 # elif defined(CONFIG_DUMMY_CONSOLE)
302 conswitchp = &dummy_con;
307 platform_pcibios_init();
311 void machine_restart(char * cmd)
316 void machine_halt(void)
322 void machine_power_off(void)
324 platform_power_off();
327 #ifdef CONFIG_PROC_FS
330 * Display some core information through /proc/cpuinfo.
334 c_show(struct seq_file *f, void *slot)
336 /* high-level stuff */
337 seq_printf(f,"processor\t: 0\n"
338 "vendor_id\t: Tensilica\n"
339 "model\t\t: Xtensa " XCHAL_HW_RELEASE_NAME "\n"
340 "core ID\t\t: " XCHAL_CORE_ID "\n"
343 "cpu MHz\t\t: %lu.%02lu\n"
344 "bogomips\t: %lu.%02lu\n",
345 XCHAL_BUILD_UNIQUE_ID,
346 XCHAL_HAVE_BE ? "big" : "little",
347 CCOUNT_PER_JIFFY/(1000000/HZ),
348 (CCOUNT_PER_JIFFY/(10000/HZ)) % 100,
349 loops_per_jiffy/(500000/HZ),
350 (loops_per_jiffy/(5000/HZ)) % 100);
352 seq_printf(f,"flags\t\t: "
362 #if XCHAL_HAVE_DENSITY
365 #if XCHAL_HAVE_BOOLEANS
374 #if XCHAL_HAVE_MINMAX
380 #if XCHAL_HAVE_CLAMPS
392 #if XCHAL_HAVE_MUL32_HIGH
401 seq_printf(f,"physical aregs\t: %d\n"
412 seq_printf(f,"num ints\t: %d\n"
416 "debug level\t: %d\n",
417 XCHAL_NUM_INTERRUPTS,
418 XCHAL_NUM_EXTINTERRUPTS,
425 seq_printf(f, "coprocessors\t: %d\n", XCHAL_CP_NUM);
427 seq_printf(f, "coprocessors\t: none\n");
430 /* {I,D}{RAM,ROM} and XLMI */
431 seq_printf(f,"inst ROMs\t: %d\n"
435 "XLMI ports\t: %d\n",
443 seq_printf(f,"icache line size: %d\n"
444 "icache ways\t: %d\n"
445 "icache size\t: %d\n"
447 #if XCHAL_ICACHE_LINE_LOCKABLE
451 "dcache line size: %d\n"
452 "dcache ways\t: %d\n"
453 "dcache size\t: %d\n"
455 #if XCHAL_DCACHE_IS_WRITEBACK
458 #if XCHAL_DCACHE_LINE_LOCKABLE
462 XCHAL_ICACHE_LINESIZE,
465 XCHAL_DCACHE_LINESIZE,
470 seq_printf(f,"ASID bits\t: %d\n"
471 "ASID invalid\t: %d\n"
472 "ASID kernel\t: %d\n"
475 "itlb AR ways\t: %d\n"
477 "dtlb AR ways\t: %d\n",
479 XCHAL_MMU_ASID_INVALID,
480 XCHAL_MMU_ASID_KERNEL,
485 XCHAL_DTLB_ARF_WAYS);
491 * We show only CPU #0 info.
494 c_start(struct seq_file *f, loff_t *pos)
496 return (void *) ((*pos == 0) ? (void *)1 : NULL);
500 c_next(struct seq_file *f, void *v, loff_t *pos)
506 c_stop(struct seq_file *f, void *v)
510 struct seq_operations cpuinfo_op =
518 #endif /* CONFIG_PROC_FS */