2 * arch/xtensa/kernel/setup.c
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>
20 #include <linux/proc_fs.h>
21 #include <linux/screen_info.h>
22 #include <linux/bootmem.h>
23 #include <linux/kernel.h>
25 #if defined(CONFIG_VGA_CONSOLE) || defined(CONFIG_DUMMY_CONSOLE)
26 # include <linux/console.h>
30 # include <linux/timex.h>
34 # include <linux/seq_file.h>
37 #include <asm/system.h>
38 #include <asm/bootparam.h>
39 #include <asm/pgtable.h>
40 #include <asm/processor.h>
41 #include <asm/timex.h>
42 #include <asm/platform.h>
44 #include <asm/setup.h>
45 #include <asm/param.h>
47 #include <platform/hardware.h>
49 #if defined(CONFIG_VGA_CONSOLE) || defined(CONFIG_DUMMY_CONSOLE)
50 struct screen_info screen_info
= { 0, 24, 0, 0, 0, 80, 0, 0, 0, 24, 1, 16};
53 #ifdef CONFIG_BLK_DEV_FD
54 extern struct fd_ops no_fd_ops
;
55 struct fd_ops
*fd_ops
;
58 extern struct rtc_ops no_rtc_ops
;
59 struct rtc_ops
*rtc_ops
;
61 #ifdef CONFIG_BLK_DEV_INITRD
62 extern void *initrd_start
;
63 extern void *initrd_end
;
64 extern void *__initrd_start
;
65 extern void *__initrd_end
;
66 int initrd_is_mapped
= 0;
67 extern int initrd_below_start_ok
;
70 unsigned char aux_device_present
;
71 extern unsigned long loops_per_jiffy
;
73 /* Command line specified as configuration option. */
75 static char __initdata command_line
[COMMAND_LINE_SIZE
];
77 #ifdef CONFIG_CMDLINE_BOOL
78 static char default_command_line
[COMMAND_LINE_SIZE
] __initdata
= CONFIG_CMDLINE
;
81 sysmem_info_t __initdata sysmem
;
83 #ifdef CONFIG_BLK_DEV_INITRD
87 extern void init_mmu(void);
90 * Boot parameter parsing.
92 * The Xtensa port uses a list of variable-sized tags to pass data to
93 * the kernel. The first tag must be a BP_TAG_FIRST tag for the list
94 * to be recognised. The list is terminated with a zero-sized
98 typedef struct tagtable
{
100 int (*parse
)(const bp_tag_t
*);
103 #define __tagtable(tag, fn) static tagtable_t __tagtable_##fn \
104 __attribute__((unused, __section__(".taglist"))) = { tag, fn }
106 /* parse current tag */
108 static int __init
parse_tag_mem(const bp_tag_t
*tag
)
110 meminfo_t
*mi
= (meminfo_t
*)(tag
->data
);
112 if (mi
->type
!= MEMORY_TYPE_CONVENTIONAL
)
115 if (sysmem
.nr_banks
>= SYSMEM_BANKS_MAX
) {
117 "Ignoring memory bank 0x%08lx size %ldKB\n",
118 (unsigned long)mi
->start
,
119 (unsigned long)mi
->end
- (unsigned long)mi
->start
);
122 sysmem
.bank
[sysmem
.nr_banks
].type
= mi
->type
;
123 sysmem
.bank
[sysmem
.nr_banks
].start
= PAGE_ALIGN(mi
->start
);
124 sysmem
.bank
[sysmem
.nr_banks
].end
= mi
->end
& PAGE_SIZE
;
130 __tagtable(BP_TAG_MEMORY
, parse_tag_mem
);
132 #ifdef CONFIG_BLK_DEV_INITRD
134 static int __init
parse_tag_initrd(const bp_tag_t
* tag
)
137 mi
= (meminfo_t
*)(tag
->data
);
138 initrd_start
= (void*)(mi
->start
);
139 initrd_end
= (void*)(mi
->end
);
144 __tagtable(BP_TAG_INITRD
, parse_tag_initrd
);
146 #endif /* CONFIG_BLK_DEV_INITRD */
148 static int __init
parse_tag_cmdline(const bp_tag_t
* tag
)
150 strncpy(command_line
, (char*)(tag
->data
), COMMAND_LINE_SIZE
);
151 command_line
[COMMAND_LINE_SIZE
- 1] = '\0';
155 __tagtable(BP_TAG_COMMAND_LINE
, parse_tag_cmdline
);
157 static int __init
parse_bootparam(const bp_tag_t
* tag
)
159 extern tagtable_t __tagtable_begin
, __tagtable_end
;
162 /* Boot parameters must start with a BP_TAG_FIRST tag. */
164 if (tag
->id
!= BP_TAG_FIRST
) {
165 printk(KERN_WARNING
"Invalid boot parameters!\n");
169 tag
= (bp_tag_t
*)((unsigned long)tag
+ sizeof(bp_tag_t
) + tag
->size
);
171 /* Parse all tags. */
173 while (tag
!= NULL
&& tag
->id
!= BP_TAG_LAST
) {
174 for (t
= &__tagtable_begin
; t
< &__tagtable_end
; t
++) {
175 if (tag
->id
== t
->tag
) {
180 if (t
== &__tagtable_end
)
181 printk(KERN_WARNING
"Ignoring tag "
182 "0x%08x\n", tag
->id
);
183 tag
= (bp_tag_t
*)((unsigned long)(tag
+ 1) + tag
->size
);
190 * Initialize architecture. (Early stage)
193 void __init
init_arch(bp_tag_t
*bp_start
)
196 #ifdef CONFIG_BLK_DEV_INITRD
197 initrd_start
= &__initrd_start
;
198 initrd_end
= &__initrd_end
;
203 #ifdef CONFIG_CMDLINE_BOOL
204 strcpy(command_line
, default_command_line
);
207 /* Parse boot parameters */
210 parse_bootparam(bp_start
);
212 if (sysmem
.nr_banks
== 0) {
214 sysmem
.bank
[0].start
= PLATFORM_DEFAULT_MEM_START
;
215 sysmem
.bank
[0].end
= PLATFORM_DEFAULT_MEM_START
216 + PLATFORM_DEFAULT_MEM_SIZE
;
219 /* Early hook for platforms */
221 platform_init(bp_start
);
223 /* Initialize MMU. */
229 * Initialize system. Setup memory and reserve regions.
234 extern char _WindowVectors_text_start
;
235 extern char _WindowVectors_text_end
;
236 extern char _DebugInterruptVector_literal_start
;
237 extern char _DebugInterruptVector_text_end
;
238 extern char _KernelExceptionVector_literal_start
;
239 extern char _KernelExceptionVector_text_end
;
240 extern char _UserExceptionVector_literal_start
;
241 extern char _UserExceptionVector_text_end
;
242 extern char _DoubleExceptionVector_literal_start
;
243 extern char _DoubleExceptionVector_text_end
;
245 void __init
setup_arch(char **cmdline_p
)
247 extern int mem_reserve(unsigned long, unsigned long, int);
248 extern void bootmem_init(void);
250 memcpy(boot_command_line
, command_line
, COMMAND_LINE_SIZE
);
251 boot_command_line
[COMMAND_LINE_SIZE
-1] = '\0';
252 *cmdline_p
= command_line
;
254 /* Reserve some memory regions */
256 #ifdef CONFIG_BLK_DEV_INITRD
257 if (initrd_start
< initrd_end
) {
258 initrd_is_mapped
= mem_reserve(__pa(initrd_start
),
259 __pa(initrd_end
), 0);
260 initrd_below_start_ok
= 1;
266 mem_reserve(__pa(&_stext
),__pa(&_end
), 1);
268 mem_reserve(__pa(&_WindowVectors_text_start
),
269 __pa(&_WindowVectors_text_end
), 0);
271 mem_reserve(__pa(&_DebugInterruptVector_literal_start
),
272 __pa(&_DebugInterruptVector_text_end
), 0);
274 mem_reserve(__pa(&_KernelExceptionVector_literal_start
),
275 __pa(&_KernelExceptionVector_text_end
), 0);
277 mem_reserve(__pa(&_UserExceptionVector_literal_start
),
278 __pa(&_UserExceptionVector_text_end
), 0);
280 mem_reserve(__pa(&_DoubleExceptionVector_literal_start
),
281 __pa(&_DoubleExceptionVector_text_end
), 0);
285 platform_setup(cmdline_p
);
291 # if defined(CONFIG_VGA_CONSOLE)
292 conswitchp
= &vga_con
;
293 # elif defined(CONFIG_DUMMY_CONSOLE)
294 conswitchp
= &dummy_con
;
299 platform_pcibios_init();
303 void machine_restart(char * cmd
)
308 void machine_halt(void)
314 void machine_power_off(void)
316 platform_power_off();
319 #ifdef CONFIG_PROC_FS
322 * Display some core information through /proc/cpuinfo.
326 c_show(struct seq_file
*f
, void *slot
)
328 /* high-level stuff */
329 seq_printf(f
,"processor\t: 0\n"
330 "vendor_id\t: Tensilica\n"
331 "model\t\t: Xtensa " XCHAL_HW_VERSION_NAME
"\n"
332 "core ID\t\t: " XCHAL_CORE_ID
"\n"
335 "cpu MHz\t\t: %lu.%02lu\n"
336 "bogomips\t: %lu.%02lu\n",
337 XCHAL_BUILD_UNIQUE_ID
,
338 XCHAL_HAVE_BE
? "big" : "little",
339 CCOUNT_PER_JIFFY
/(1000000/HZ
),
340 (CCOUNT_PER_JIFFY
/(10000/HZ
)) % 100,
341 loops_per_jiffy
/(500000/HZ
),
342 (loops_per_jiffy
/(5000/HZ
)) % 100);
344 seq_printf(f
,"flags\t\t: "
354 #if XCHAL_HAVE_DENSITY
357 #if XCHAL_HAVE_BOOLEANS
366 #if XCHAL_HAVE_MINMAX
372 #if XCHAL_HAVE_CLAMPS
384 #if XCHAL_HAVE_MUL32_HIGH
393 seq_printf(f
,"physical aregs\t: %d\n"
404 seq_printf(f
,"num ints\t: %d\n"
408 "debug level\t: %d\n",
409 XCHAL_NUM_INTERRUPTS
,
410 XCHAL_NUM_EXTINTERRUPTS
,
416 seq_printf(f
,"icache line size: %d\n"
417 "icache ways\t: %d\n"
418 "icache size\t: %d\n"
420 #if XCHAL_ICACHE_LINE_LOCKABLE
424 "dcache line size: %d\n"
425 "dcache ways\t: %d\n"
426 "dcache size\t: %d\n"
428 #if XCHAL_DCACHE_IS_WRITEBACK
431 #if XCHAL_DCACHE_LINE_LOCKABLE
435 XCHAL_ICACHE_LINESIZE
,
438 XCHAL_DCACHE_LINESIZE
,
446 * We show only CPU #0 info.
449 c_start(struct seq_file
*f
, loff_t
*pos
)
451 return (void *) ((*pos
== 0) ? (void *)1 : NULL
);
455 c_next(struct seq_file
*f
, void *v
, loff_t
*pos
)
461 c_stop(struct seq_file
*f
, void *v
)
465 const struct seq_operations cpuinfo_op
=
473 #endif /* CONFIG_PROC_FS */