Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * linux/arch/arm/kernel/setup.c |
| 3 | * |
| 4 | * Copyright (C) 1995-2001 Russell King |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License version 2 as |
| 8 | * published by the Free Software Foundation. |
| 9 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 10 | #include <linux/module.h> |
| 11 | #include <linux/kernel.h> |
| 12 | #include <linux/stddef.h> |
| 13 | #include <linux/ioport.h> |
| 14 | #include <linux/delay.h> |
| 15 | #include <linux/utsname.h> |
| 16 | #include <linux/initrd.h> |
| 17 | #include <linux/console.h> |
| 18 | #include <linux/bootmem.h> |
| 19 | #include <linux/seq_file.h> |
Jon Smirl | 894673e | 2006-07-10 04:44:13 -0700 | [diff] [blame] | 20 | #include <linux/screen_info.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 21 | #include <linux/init.h> |
Mika Westerberg | 3c57fb4 | 2010-05-10 09:20:22 +0100 | [diff] [blame^] | 22 | #include <linux/kexec.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 23 | #include <linux/root_dev.h> |
| 24 | #include <linux/cpu.h> |
| 25 | #include <linux/interrupt.h> |
Russell King | 7bbb794 | 2006-02-16 11:08:09 +0000 | [diff] [blame] | 26 | #include <linux/smp.h> |
Alexey Dobriyan | 4e950f6 | 2007-07-30 02:36:13 +0400 | [diff] [blame] | 27 | #include <linux/fs.h> |
Russell King | e119bff | 2010-01-10 17:23:29 +0000 | [diff] [blame] | 28 | #include <linux/proc_fs.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 29 | |
Catalin Marinas | b86040a | 2009-07-24 12:32:54 +0100 | [diff] [blame] | 30 | #include <asm/unified.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 31 | #include <asm/cpu.h> |
Russell King | 0ba8b9b | 2008-08-10 18:08:10 +0100 | [diff] [blame] | 32 | #include <asm/cputype.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 33 | #include <asm/elf.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 34 | #include <asm/procinfo.h> |
Russell King | 37efe64 | 2008-12-01 11:53:07 +0000 | [diff] [blame] | 35 | #include <asm/sections.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 36 | #include <asm/setup.h> |
| 37 | #include <asm/mach-types.h> |
| 38 | #include <asm/cacheflush.h> |
Russell King | 46097c7 | 2008-08-10 18:10:19 +0100 | [diff] [blame] | 39 | #include <asm/cachetype.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 40 | #include <asm/tlbflush.h> |
| 41 | |
| 42 | #include <asm/mach/arch.h> |
| 43 | #include <asm/mach/irq.h> |
| 44 | #include <asm/mach/time.h> |
Jason Wessel | 5cbad0e | 2008-02-20 13:33:40 -0600 | [diff] [blame] | 45 | #include <asm/traps.h> |
Catalin Marinas | bff595c | 2009-02-16 11:41:36 +0100 | [diff] [blame] | 46 | #include <asm/unwind.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 47 | |
Ben Dooks | 0fc1c83 | 2006-03-15 23:17:30 +0000 | [diff] [blame] | 48 | #include "compat.h" |
Richard Purdie | 4cd9d6f | 2008-01-02 00:56:46 +0100 | [diff] [blame] | 49 | #include "atags.h" |
Linus Walleij | bc58177 | 2009-09-15 17:30:37 +0100 | [diff] [blame] | 50 | #include "tcm.h" |
Ben Dooks | 0fc1c83 | 2006-03-15 23:17:30 +0000 | [diff] [blame] | 51 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 52 | #ifndef MEM_SIZE |
| 53 | #define MEM_SIZE (16*1024*1024) |
| 54 | #endif |
| 55 | |
| 56 | #if defined(CONFIG_FPE_NWFPE) || defined(CONFIG_FPE_FASTFPE) |
| 57 | char fpe_type[8]; |
| 58 | |
| 59 | static int __init fpe_setup(char *line) |
| 60 | { |
| 61 | memcpy(fpe_type, line, 8); |
| 62 | return 1; |
| 63 | } |
| 64 | |
| 65 | __setup("fpe=", fpe_setup); |
| 66 | #endif |
| 67 | |
Nicolas Pitre | 4b5f32c | 2008-10-06 13:24:40 -0400 | [diff] [blame] | 68 | extern void paging_init(struct machine_desc *desc); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 69 | extern void reboot_setup(char *str); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 70 | |
| 71 | unsigned int processor_id; |
Krzysztof Halasa | c18f658 | 2007-12-18 03:53:27 +0100 | [diff] [blame] | 72 | EXPORT_SYMBOL(processor_id); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 73 | unsigned int __machine_arch_type; |
| 74 | EXPORT_SYMBOL(__machine_arch_type); |
Russell King | c0e9587 | 2008-09-25 15:35:28 +0100 | [diff] [blame] | 75 | unsigned int cacheid; |
| 76 | EXPORT_SYMBOL(cacheid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 77 | |
Bill Gatliff | 9d20fdd | 2007-05-31 22:02:22 +0100 | [diff] [blame] | 78 | unsigned int __atags_pointer __initdata; |
| 79 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 80 | unsigned int system_rev; |
| 81 | EXPORT_SYMBOL(system_rev); |
| 82 | |
| 83 | unsigned int system_serial_low; |
| 84 | EXPORT_SYMBOL(system_serial_low); |
| 85 | |
| 86 | unsigned int system_serial_high; |
| 87 | EXPORT_SYMBOL(system_serial_high); |
| 88 | |
| 89 | unsigned int elf_hwcap; |
| 90 | EXPORT_SYMBOL(elf_hwcap); |
| 91 | |
| 92 | |
| 93 | #ifdef MULTI_CPU |
| 94 | struct processor processor; |
| 95 | #endif |
| 96 | #ifdef MULTI_TLB |
| 97 | struct cpu_tlb_fns cpu_tlb; |
| 98 | #endif |
| 99 | #ifdef MULTI_USER |
| 100 | struct cpu_user_fns cpu_user; |
| 101 | #endif |
| 102 | #ifdef MULTI_CACHE |
| 103 | struct cpu_cache_fns cpu_cache; |
| 104 | #endif |
Catalin Marinas | 953233d | 2007-02-05 14:48:08 +0100 | [diff] [blame] | 105 | #ifdef CONFIG_OUTER_CACHE |
| 106 | struct outer_cache_fns outer_cache; |
Santosh Shilimkar | 6c09f09 | 2010-02-16 07:57:43 +0100 | [diff] [blame] | 107 | EXPORT_SYMBOL(outer_cache); |
Catalin Marinas | 953233d | 2007-02-05 14:48:08 +0100 | [diff] [blame] | 108 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 109 | |
Russell King | ccea7a1 | 2005-05-31 22:22:32 +0100 | [diff] [blame] | 110 | struct stack { |
| 111 | u32 irq[3]; |
| 112 | u32 abt[3]; |
| 113 | u32 und[3]; |
| 114 | } ____cacheline_aligned; |
| 115 | |
| 116 | static struct stack stacks[NR_CPUS]; |
| 117 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 118 | char elf_platform[ELF_PLATFORM_SIZE]; |
| 119 | EXPORT_SYMBOL(elf_platform); |
| 120 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 121 | static const char *cpu_name; |
| 122 | static const char *machine_name; |
Jeremy Kerr | 48ab7e0 | 2010-01-27 01:13:31 +0100 | [diff] [blame] | 123 | static char __initdata cmd_line[COMMAND_LINE_SIZE]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 124 | |
| 125 | static char default_command_line[COMMAND_LINE_SIZE] __initdata = CONFIG_CMDLINE; |
| 126 | static union { char c[4]; unsigned long l; } endian_test __initdata = { { 'l', '?', '?', 'b' } }; |
| 127 | #define ENDIANNESS ((char)endian_test.l) |
| 128 | |
| 129 | DEFINE_PER_CPU(struct cpuinfo_arm, cpu_data); |
| 130 | |
| 131 | /* |
| 132 | * Standard memory resources |
| 133 | */ |
| 134 | static struct resource mem_res[] = { |
Greg Kroah-Hartman | 740e518 | 2006-06-12 14:47:06 -0700 | [diff] [blame] | 135 | { |
| 136 | .name = "Video RAM", |
| 137 | .start = 0, |
| 138 | .end = 0, |
| 139 | .flags = IORESOURCE_MEM |
| 140 | }, |
| 141 | { |
| 142 | .name = "Kernel text", |
| 143 | .start = 0, |
| 144 | .end = 0, |
| 145 | .flags = IORESOURCE_MEM |
| 146 | }, |
| 147 | { |
| 148 | .name = "Kernel data", |
| 149 | .start = 0, |
| 150 | .end = 0, |
| 151 | .flags = IORESOURCE_MEM |
| 152 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 153 | }; |
| 154 | |
| 155 | #define video_ram mem_res[0] |
| 156 | #define kernel_code mem_res[1] |
| 157 | #define kernel_data mem_res[2] |
| 158 | |
| 159 | static struct resource io_res[] = { |
Greg Kroah-Hartman | 740e518 | 2006-06-12 14:47:06 -0700 | [diff] [blame] | 160 | { |
| 161 | .name = "reserved", |
| 162 | .start = 0x3bc, |
| 163 | .end = 0x3be, |
| 164 | .flags = IORESOURCE_IO | IORESOURCE_BUSY |
| 165 | }, |
| 166 | { |
| 167 | .name = "reserved", |
| 168 | .start = 0x378, |
| 169 | .end = 0x37f, |
| 170 | .flags = IORESOURCE_IO | IORESOURCE_BUSY |
| 171 | }, |
| 172 | { |
| 173 | .name = "reserved", |
| 174 | .start = 0x278, |
| 175 | .end = 0x27f, |
| 176 | .flags = IORESOURCE_IO | IORESOURCE_BUSY |
| 177 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 178 | }; |
| 179 | |
| 180 | #define lp0 io_res[0] |
| 181 | #define lp1 io_res[1] |
| 182 | #define lp2 io_res[2] |
| 183 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 184 | static const char *proc_arch[] = { |
| 185 | "undefined/unknown", |
| 186 | "3", |
| 187 | "4", |
| 188 | "4T", |
| 189 | "5", |
| 190 | "5T", |
| 191 | "5TE", |
| 192 | "5TEJ", |
| 193 | "6TEJ", |
Catalin Marinas | 6b090a2 | 2006-01-12 16:28:16 +0000 | [diff] [blame] | 194 | "7", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 195 | "?(11)", |
| 196 | "?(12)", |
| 197 | "?(13)", |
| 198 | "?(14)", |
| 199 | "?(15)", |
| 200 | "?(16)", |
| 201 | "?(17)", |
| 202 | }; |
| 203 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 204 | int cpu_architecture(void) |
| 205 | { |
| 206 | int cpu_arch; |
| 207 | |
Russell King | 0ba8b9b | 2008-08-10 18:08:10 +0100 | [diff] [blame] | 208 | if ((read_cpuid_id() & 0x0008f000) == 0) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 209 | cpu_arch = CPU_ARCH_UNKNOWN; |
Russell King | 0ba8b9b | 2008-08-10 18:08:10 +0100 | [diff] [blame] | 210 | } else if ((read_cpuid_id() & 0x0008f000) == 0x00007000) { |
| 211 | cpu_arch = (read_cpuid_id() & (1 << 23)) ? CPU_ARCH_ARMv4T : CPU_ARCH_ARMv3; |
| 212 | } else if ((read_cpuid_id() & 0x00080000) == 0x00000000) { |
| 213 | cpu_arch = (read_cpuid_id() >> 16) & 7; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 214 | if (cpu_arch) |
| 215 | cpu_arch += CPU_ARCH_ARMv3; |
Russell King | 0ba8b9b | 2008-08-10 18:08:10 +0100 | [diff] [blame] | 216 | } else if ((read_cpuid_id() & 0x000f0000) == 0x000f0000) { |
Catalin Marinas | 180005c | 2007-09-25 16:49:45 +0100 | [diff] [blame] | 217 | unsigned int mmfr0; |
| 218 | |
| 219 | /* Revised CPUID format. Read the Memory Model Feature |
| 220 | * Register 0 and check for VMSAv7 or PMSAv7 */ |
| 221 | asm("mrc p15, 0, %0, c0, c1, 4" |
| 222 | : "=r" (mmfr0)); |
| 223 | if ((mmfr0 & 0x0000000f) == 0x00000003 || |
| 224 | (mmfr0 & 0x000000f0) == 0x00000030) |
| 225 | cpu_arch = CPU_ARCH_ARMv7; |
| 226 | else if ((mmfr0 & 0x0000000f) == 0x00000002 || |
| 227 | (mmfr0 & 0x000000f0) == 0x00000020) |
| 228 | cpu_arch = CPU_ARCH_ARMv6; |
| 229 | else |
| 230 | cpu_arch = CPU_ARCH_UNKNOWN; |
| 231 | } else |
| 232 | cpu_arch = CPU_ARCH_UNKNOWN; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 233 | |
| 234 | return cpu_arch; |
| 235 | } |
| 236 | |
Russell King | c0e9587 | 2008-09-25 15:35:28 +0100 | [diff] [blame] | 237 | static void __init cacheid_init(void) |
| 238 | { |
| 239 | unsigned int cachetype = read_cpuid_cachetype(); |
| 240 | unsigned int arch = cpu_architecture(); |
| 241 | |
Catalin Marinas | b57ee99 | 2009-03-03 11:44:12 +0100 | [diff] [blame] | 242 | if (arch >= CPU_ARCH_ARMv6) { |
| 243 | if ((cachetype & (7 << 29)) == 4 << 29) { |
| 244 | /* ARMv7 register format */ |
| 245 | cacheid = CACHEID_VIPT_NONALIASING; |
| 246 | if ((cachetype & (3 << 14)) == 1 << 14) |
| 247 | cacheid |= CACHEID_ASID_TAGGED; |
| 248 | } else if (cachetype & (1 << 23)) |
Russell King | c0e9587 | 2008-09-25 15:35:28 +0100 | [diff] [blame] | 249 | cacheid = CACHEID_VIPT_ALIASING; |
| 250 | else |
| 251 | cacheid = CACHEID_VIPT_NONALIASING; |
| 252 | } else { |
| 253 | cacheid = CACHEID_VIVT; |
| 254 | } |
Russell King | 2b4ae1f | 2008-09-25 15:39:20 +0100 | [diff] [blame] | 255 | |
| 256 | printk("CPU: %s data cache, %s instruction cache\n", |
| 257 | cache_is_vivt() ? "VIVT" : |
| 258 | cache_is_vipt_aliasing() ? "VIPT aliasing" : |
| 259 | cache_is_vipt_nonaliasing() ? "VIPT nonaliasing" : "unknown", |
| 260 | cache_is_vivt() ? "VIVT" : |
| 261 | icache_is_vivt_asid_tagged() ? "VIVT ASID tagged" : |
| 262 | cache_is_vipt_aliasing() ? "VIPT aliasing" : |
| 263 | cache_is_vipt_nonaliasing() ? "VIPT nonaliasing" : "unknown"); |
Russell King | c0e9587 | 2008-09-25 15:35:28 +0100 | [diff] [blame] | 264 | } |
| 265 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 266 | /* |
| 267 | * These functions re-use the assembly code in head.S, which |
| 268 | * already provide the required functionality. |
| 269 | */ |
Russell King | 0f44ba1 | 2006-02-24 21:04:56 +0000 | [diff] [blame] | 270 | extern struct proc_info_list *lookup_processor_type(unsigned int); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 271 | extern struct machine_desc *lookup_machine_type(unsigned int); |
| 272 | |
Tony Lindgren | f159f4e | 2010-07-05 14:53:10 +0100 | [diff] [blame] | 273 | static void __init feat_v6_fixup(void) |
| 274 | { |
| 275 | int id = read_cpuid_id(); |
| 276 | |
| 277 | if ((id & 0xff0f0000) != 0x41070000) |
| 278 | return; |
| 279 | |
| 280 | /* |
| 281 | * HWCAP_TLS is available only on 1136 r1p0 and later, |
| 282 | * see also kuser_get_tls_init. |
| 283 | */ |
| 284 | if ((((id >> 4) & 0xfff) == 0xb36) && (((id >> 20) & 3) == 0)) |
| 285 | elf_hwcap &= ~HWCAP_TLS; |
| 286 | } |
| 287 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 288 | static void __init setup_processor(void) |
| 289 | { |
| 290 | struct proc_info_list *list; |
| 291 | |
| 292 | /* |
| 293 | * locate processor in the list of supported processor |
| 294 | * types. The linker builds this table for us from the |
| 295 | * entries in arch/arm/mm/proc-*.S |
| 296 | */ |
Russell King | 0ba8b9b | 2008-08-10 18:08:10 +0100 | [diff] [blame] | 297 | list = lookup_processor_type(read_cpuid_id()); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 298 | if (!list) { |
| 299 | printk("CPU configuration botched (ID %08x), unable " |
Russell King | 0ba8b9b | 2008-08-10 18:08:10 +0100 | [diff] [blame] | 300 | "to continue.\n", read_cpuid_id()); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 301 | while (1); |
| 302 | } |
| 303 | |
| 304 | cpu_name = list->cpu_name; |
| 305 | |
| 306 | #ifdef MULTI_CPU |
| 307 | processor = *list->proc; |
| 308 | #endif |
| 309 | #ifdef MULTI_TLB |
| 310 | cpu_tlb = *list->tlb; |
| 311 | #endif |
| 312 | #ifdef MULTI_USER |
| 313 | cpu_user = *list->user; |
| 314 | #endif |
| 315 | #ifdef MULTI_CACHE |
| 316 | cpu_cache = *list->cache; |
| 317 | #endif |
| 318 | |
Russell King | 4e19025 | 2006-07-03 13:29:38 +0100 | [diff] [blame] | 319 | printk("CPU: %s [%08x] revision %d (ARMv%s), cr=%08lx\n", |
Russell King | 0ba8b9b | 2008-08-10 18:08:10 +0100 | [diff] [blame] | 320 | cpu_name, read_cpuid_id(), read_cpuid_id() & 15, |
Russell King | 264edb3 | 2006-06-29 15:03:09 +0100 | [diff] [blame] | 321 | proc_arch[cpu_architecture()], cr_alignment); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 322 | |
Serge E. Hallyn | 96b644b | 2006-10-02 02:18:13 -0700 | [diff] [blame] | 323 | sprintf(init_utsname()->machine, "%s%c", list->arch_name, ENDIANNESS); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 324 | sprintf(elf_platform, "%s%c", list->elf_name, ENDIANNESS); |
| 325 | elf_hwcap = list->elf_hwcap; |
Catalin Marinas | adeff42 | 2006-04-10 21:32:35 +0100 | [diff] [blame] | 326 | #ifndef CONFIG_ARM_THUMB |
| 327 | elf_hwcap &= ~HWCAP_THUMB; |
| 328 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 329 | |
Tony Lindgren | f159f4e | 2010-07-05 14:53:10 +0100 | [diff] [blame] | 330 | feat_v6_fixup(); |
| 331 | |
Russell King | c0e9587 | 2008-09-25 15:35:28 +0100 | [diff] [blame] | 332 | cacheid_init(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 333 | cpu_proc_init(); |
| 334 | } |
| 335 | |
Russell King | ccea7a1 | 2005-05-31 22:22:32 +0100 | [diff] [blame] | 336 | /* |
| 337 | * cpu_init - initialise one CPU. |
| 338 | * |
Russell King | 90f1e08 | 2008-09-25 14:45:02 +0100 | [diff] [blame] | 339 | * cpu_init sets up the per-CPU stacks. |
Russell King | ccea7a1 | 2005-05-31 22:22:32 +0100 | [diff] [blame] | 340 | */ |
Russell King | 36c5ed2 | 2005-06-19 18:39:33 +0100 | [diff] [blame] | 341 | void cpu_init(void) |
Russell King | ccea7a1 | 2005-05-31 22:22:32 +0100 | [diff] [blame] | 342 | { |
| 343 | unsigned int cpu = smp_processor_id(); |
| 344 | struct stack *stk = &stacks[cpu]; |
| 345 | |
| 346 | if (cpu >= NR_CPUS) { |
| 347 | printk(KERN_CRIT "CPU%u: bad primary CPU number\n", cpu); |
| 348 | BUG(); |
| 349 | } |
| 350 | |
Russell King | ccea7a1 | 2005-05-31 22:22:32 +0100 | [diff] [blame] | 351 | /* |
Catalin Marinas | b86040a | 2009-07-24 12:32:54 +0100 | [diff] [blame] | 352 | * Define the placement constraint for the inline asm directive below. |
| 353 | * In Thumb-2, msr with an immediate value is not allowed. |
| 354 | */ |
| 355 | #ifdef CONFIG_THUMB2_KERNEL |
| 356 | #define PLC "r" |
| 357 | #else |
| 358 | #define PLC "I" |
| 359 | #endif |
| 360 | |
| 361 | /* |
Russell King | ccea7a1 | 2005-05-31 22:22:32 +0100 | [diff] [blame] | 362 | * setup stacks for re-entrant exception handlers |
| 363 | */ |
| 364 | __asm__ ( |
| 365 | "msr cpsr_c, %1\n\t" |
Catalin Marinas | b86040a | 2009-07-24 12:32:54 +0100 | [diff] [blame] | 366 | "add r14, %0, %2\n\t" |
| 367 | "mov sp, r14\n\t" |
Russell King | ccea7a1 | 2005-05-31 22:22:32 +0100 | [diff] [blame] | 368 | "msr cpsr_c, %3\n\t" |
Catalin Marinas | b86040a | 2009-07-24 12:32:54 +0100 | [diff] [blame] | 369 | "add r14, %0, %4\n\t" |
| 370 | "mov sp, r14\n\t" |
Russell King | ccea7a1 | 2005-05-31 22:22:32 +0100 | [diff] [blame] | 371 | "msr cpsr_c, %5\n\t" |
Catalin Marinas | b86040a | 2009-07-24 12:32:54 +0100 | [diff] [blame] | 372 | "add r14, %0, %6\n\t" |
| 373 | "mov sp, r14\n\t" |
Russell King | ccea7a1 | 2005-05-31 22:22:32 +0100 | [diff] [blame] | 374 | "msr cpsr_c, %7" |
| 375 | : |
| 376 | : "r" (stk), |
Catalin Marinas | b86040a | 2009-07-24 12:32:54 +0100 | [diff] [blame] | 377 | PLC (PSR_F_BIT | PSR_I_BIT | IRQ_MODE), |
Russell King | ccea7a1 | 2005-05-31 22:22:32 +0100 | [diff] [blame] | 378 | "I" (offsetof(struct stack, irq[0])), |
Catalin Marinas | b86040a | 2009-07-24 12:32:54 +0100 | [diff] [blame] | 379 | PLC (PSR_F_BIT | PSR_I_BIT | ABT_MODE), |
Russell King | ccea7a1 | 2005-05-31 22:22:32 +0100 | [diff] [blame] | 380 | "I" (offsetof(struct stack, abt[0])), |
Catalin Marinas | b86040a | 2009-07-24 12:32:54 +0100 | [diff] [blame] | 381 | PLC (PSR_F_BIT | PSR_I_BIT | UND_MODE), |
Russell King | ccea7a1 | 2005-05-31 22:22:32 +0100 | [diff] [blame] | 382 | "I" (offsetof(struct stack, und[0])), |
Catalin Marinas | b86040a | 2009-07-24 12:32:54 +0100 | [diff] [blame] | 383 | PLC (PSR_F_BIT | PSR_I_BIT | SVC_MODE) |
Catalin Marinas | aaaa3f9 | 2005-06-29 15:34:39 +0100 | [diff] [blame] | 384 | : "r14"); |
Russell King | ccea7a1 | 2005-05-31 22:22:32 +0100 | [diff] [blame] | 385 | } |
| 386 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 387 | static struct machine_desc * __init setup_machine(unsigned int nr) |
| 388 | { |
| 389 | struct machine_desc *list; |
| 390 | |
| 391 | /* |
| 392 | * locate machine in the list of supported machines. |
| 393 | */ |
| 394 | list = lookup_machine_type(nr); |
| 395 | if (!list) { |
| 396 | printk("Machine configuration botched (nr %d), unable " |
| 397 | "to continue.\n", nr); |
| 398 | while (1); |
| 399 | } |
| 400 | |
| 401 | printk("Machine: %s\n", list->name); |
| 402 | |
| 403 | return list; |
| 404 | } |
| 405 | |
Nicolas Pitre | 4b5f32c | 2008-10-06 13:24:40 -0400 | [diff] [blame] | 406 | static int __init arm_add_memory(unsigned long start, unsigned long size) |
Russell King | 3a66941 | 2005-06-22 21:43:10 +0100 | [diff] [blame] | 407 | { |
Nicolas Pitre | 4b5f32c | 2008-10-06 13:24:40 -0400 | [diff] [blame] | 408 | struct membank *bank = &meminfo.bank[meminfo.nr_banks]; |
| 409 | |
| 410 | if (meminfo.nr_banks >= NR_BANKS) { |
| 411 | printk(KERN_CRIT "NR_BANKS too low, " |
| 412 | "ignoring memory at %#lx\n", start); |
| 413 | return -EINVAL; |
| 414 | } |
Russell King | 05f96ef | 2006-11-30 20:44:49 +0000 | [diff] [blame] | 415 | |
Russell King | 3a66941 | 2005-06-22 21:43:10 +0100 | [diff] [blame] | 416 | /* |
| 417 | * Ensure that start/size are aligned to a page boundary. |
| 418 | * Size is appropriately rounded down, start is rounded up. |
| 419 | */ |
| 420 | size -= start & ~PAGE_MASK; |
Russell King | 05f96ef | 2006-11-30 20:44:49 +0000 | [diff] [blame] | 421 | bank->start = PAGE_ALIGN(start); |
| 422 | bank->size = size & PAGE_MASK; |
| 423 | bank->node = PHYS_TO_NID(start); |
Nicolas Pitre | 4b5f32c | 2008-10-06 13:24:40 -0400 | [diff] [blame] | 424 | |
| 425 | /* |
| 426 | * Check whether this memory region has non-zero size or |
| 427 | * invalid node number. |
| 428 | */ |
| 429 | if (bank->size == 0 || bank->node >= MAX_NUMNODES) |
| 430 | return -EINVAL; |
| 431 | |
| 432 | meminfo.nr_banks++; |
| 433 | return 0; |
Russell King | 3a66941 | 2005-06-22 21:43:10 +0100 | [diff] [blame] | 434 | } |
| 435 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 436 | /* |
| 437 | * Pick out the memory size. We look for mem=size@start, |
| 438 | * where start and size are "size[KkMm]" |
| 439 | */ |
Jeremy Kerr | 2b0d8c2 | 2010-01-11 23:17:34 +0100 | [diff] [blame] | 440 | static int __init early_mem(char *p) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 441 | { |
| 442 | static int usermem __initdata = 0; |
| 443 | unsigned long size, start; |
Jeremy Kerr | 2b0d8c2 | 2010-01-11 23:17:34 +0100 | [diff] [blame] | 444 | char *endp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 445 | |
| 446 | /* |
| 447 | * If the user specifies memory size, we |
| 448 | * blow away any automatically generated |
| 449 | * size. |
| 450 | */ |
| 451 | if (usermem == 0) { |
| 452 | usermem = 1; |
| 453 | meminfo.nr_banks = 0; |
| 454 | } |
| 455 | |
| 456 | start = PHYS_OFFSET; |
Jeremy Kerr | 2b0d8c2 | 2010-01-11 23:17:34 +0100 | [diff] [blame] | 457 | size = memparse(p, &endp); |
| 458 | if (*endp == '@') |
| 459 | start = memparse(endp + 1, NULL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 460 | |
Andrew Morton | 1c97b73 | 2006-04-20 21:41:18 +0100 | [diff] [blame] | 461 | arm_add_memory(start, size); |
Jeremy Kerr | 2b0d8c2 | 2010-01-11 23:17:34 +0100 | [diff] [blame] | 462 | |
| 463 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 464 | } |
Jeremy Kerr | 2b0d8c2 | 2010-01-11 23:17:34 +0100 | [diff] [blame] | 465 | early_param("mem", early_mem); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 466 | |
| 467 | static void __init |
| 468 | setup_ramdisk(int doload, int prompt, int image_start, unsigned int rd_sz) |
| 469 | { |
| 470 | #ifdef CONFIG_BLK_DEV_RAM |
| 471 | extern int rd_size, rd_image_start, rd_prompt, rd_doload; |
| 472 | |
| 473 | rd_image_start = image_start; |
| 474 | rd_prompt = prompt; |
| 475 | rd_doload = doload; |
| 476 | |
| 477 | if (rd_sz) |
| 478 | rd_size = rd_sz; |
| 479 | #endif |
| 480 | } |
| 481 | |
| 482 | static void __init |
| 483 | request_standard_resources(struct meminfo *mi, struct machine_desc *mdesc) |
| 484 | { |
| 485 | struct resource *res; |
| 486 | int i; |
| 487 | |
Russell King | 37efe64 | 2008-12-01 11:53:07 +0000 | [diff] [blame] | 488 | kernel_code.start = virt_to_phys(_text); |
| 489 | kernel_code.end = virt_to_phys(_etext - 1); |
| 490 | kernel_data.start = virt_to_phys(_data); |
| 491 | kernel_data.end = virt_to_phys(_end - 1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 492 | |
| 493 | for (i = 0; i < mi->nr_banks; i++) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 494 | if (mi->bank[i].size == 0) |
| 495 | continue; |
| 496 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 497 | res = alloc_bootmem_low(sizeof(*res)); |
| 498 | res->name = "System RAM"; |
Nicolas Pitre | 3319f5e | 2008-10-02 03:29:22 +0100 | [diff] [blame] | 499 | res->start = mi->bank[i].start; |
| 500 | res->end = mi->bank[i].start + mi->bank[i].size - 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 501 | res->flags = IORESOURCE_MEM | IORESOURCE_BUSY; |
| 502 | |
| 503 | request_resource(&iomem_resource, res); |
| 504 | |
| 505 | if (kernel_code.start >= res->start && |
| 506 | kernel_code.end <= res->end) |
| 507 | request_resource(res, &kernel_code); |
| 508 | if (kernel_data.start >= res->start && |
| 509 | kernel_data.end <= res->end) |
| 510 | request_resource(res, &kernel_data); |
| 511 | } |
| 512 | |
| 513 | if (mdesc->video_start) { |
| 514 | video_ram.start = mdesc->video_start; |
| 515 | video_ram.end = mdesc->video_end; |
| 516 | request_resource(&iomem_resource, &video_ram); |
| 517 | } |
| 518 | |
| 519 | /* |
| 520 | * Some machines don't have the possibility of ever |
| 521 | * possessing lp0, lp1 or lp2 |
| 522 | */ |
| 523 | if (mdesc->reserve_lp0) |
| 524 | request_resource(&ioport_resource, &lp0); |
| 525 | if (mdesc->reserve_lp1) |
| 526 | request_resource(&ioport_resource, &lp1); |
| 527 | if (mdesc->reserve_lp2) |
| 528 | request_resource(&ioport_resource, &lp2); |
| 529 | } |
| 530 | |
| 531 | /* |
| 532 | * Tag parsing. |
| 533 | * |
| 534 | * This is the new way of passing data to the kernel at boot time. Rather |
| 535 | * than passing a fixed inflexible structure to the kernel, we pass a list |
| 536 | * of variable-sized tags to the kernel. The first tag must be a ATAG_CORE |
| 537 | * tag for the list to be recognised (to distinguish the tagged list from |
| 538 | * a param_struct). The list is terminated with a zero-length tag (this tag |
| 539 | * is not parsed in any way). |
| 540 | */ |
| 541 | static int __init parse_tag_core(const struct tag *tag) |
| 542 | { |
| 543 | if (tag->hdr.size > 2) { |
| 544 | if ((tag->u.core.flags & 1) == 0) |
| 545 | root_mountflags &= ~MS_RDONLY; |
| 546 | ROOT_DEV = old_decode_dev(tag->u.core.rootdev); |
| 547 | } |
| 548 | return 0; |
| 549 | } |
| 550 | |
| 551 | __tagtable(ATAG_CORE, parse_tag_core); |
| 552 | |
| 553 | static int __init parse_tag_mem32(const struct tag *tag) |
| 554 | { |
Nicolas Pitre | 4b5f32c | 2008-10-06 13:24:40 -0400 | [diff] [blame] | 555 | return arm_add_memory(tag->u.mem.start, tag->u.mem.size); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 556 | } |
| 557 | |
| 558 | __tagtable(ATAG_MEM, parse_tag_mem32); |
| 559 | |
| 560 | #if defined(CONFIG_VGA_CONSOLE) || defined(CONFIG_DUMMY_CONSOLE) |
| 561 | struct screen_info screen_info = { |
| 562 | .orig_video_lines = 30, |
| 563 | .orig_video_cols = 80, |
| 564 | .orig_video_mode = 0, |
| 565 | .orig_video_ega_bx = 0, |
| 566 | .orig_video_isVGA = 1, |
| 567 | .orig_video_points = 8 |
| 568 | }; |
| 569 | |
| 570 | static int __init parse_tag_videotext(const struct tag *tag) |
| 571 | { |
| 572 | screen_info.orig_x = tag->u.videotext.x; |
| 573 | screen_info.orig_y = tag->u.videotext.y; |
| 574 | screen_info.orig_video_page = tag->u.videotext.video_page; |
| 575 | screen_info.orig_video_mode = tag->u.videotext.video_mode; |
| 576 | screen_info.orig_video_cols = tag->u.videotext.video_cols; |
| 577 | screen_info.orig_video_ega_bx = tag->u.videotext.video_ega_bx; |
| 578 | screen_info.orig_video_lines = tag->u.videotext.video_lines; |
| 579 | screen_info.orig_video_isVGA = tag->u.videotext.video_isvga; |
| 580 | screen_info.orig_video_points = tag->u.videotext.video_points; |
| 581 | return 0; |
| 582 | } |
| 583 | |
| 584 | __tagtable(ATAG_VIDEOTEXT, parse_tag_videotext); |
| 585 | #endif |
| 586 | |
| 587 | static int __init parse_tag_ramdisk(const struct tag *tag) |
| 588 | { |
| 589 | setup_ramdisk((tag->u.ramdisk.flags & 1) == 0, |
| 590 | (tag->u.ramdisk.flags & 2) == 0, |
| 591 | tag->u.ramdisk.start, tag->u.ramdisk.size); |
| 592 | return 0; |
| 593 | } |
| 594 | |
| 595 | __tagtable(ATAG_RAMDISK, parse_tag_ramdisk); |
| 596 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 597 | static int __init parse_tag_serialnr(const struct tag *tag) |
| 598 | { |
| 599 | system_serial_low = tag->u.serialnr.low; |
| 600 | system_serial_high = tag->u.serialnr.high; |
| 601 | return 0; |
| 602 | } |
| 603 | |
| 604 | __tagtable(ATAG_SERIAL, parse_tag_serialnr); |
| 605 | |
| 606 | static int __init parse_tag_revision(const struct tag *tag) |
| 607 | { |
| 608 | system_rev = tag->u.revision.rev; |
| 609 | return 0; |
| 610 | } |
| 611 | |
| 612 | __tagtable(ATAG_REVISION, parse_tag_revision); |
| 613 | |
Alexander Holler | 92d2040 | 2010-02-16 19:04:53 +0100 | [diff] [blame] | 614 | #ifndef CONFIG_CMDLINE_FORCE |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 615 | static int __init parse_tag_cmdline(const struct tag *tag) |
| 616 | { |
| 617 | strlcpy(default_command_line, tag->u.cmdline.cmdline, COMMAND_LINE_SIZE); |
| 618 | return 0; |
| 619 | } |
| 620 | |
| 621 | __tagtable(ATAG_CMDLINE, parse_tag_cmdline); |
Alexander Holler | 92d2040 | 2010-02-16 19:04:53 +0100 | [diff] [blame] | 622 | #endif /* CONFIG_CMDLINE_FORCE */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 623 | |
| 624 | /* |
| 625 | * Scan the tag table for this tag, and call its parse function. |
| 626 | * The tag table is built by the linker from all the __tagtable |
| 627 | * declarations. |
| 628 | */ |
| 629 | static int __init parse_tag(const struct tag *tag) |
| 630 | { |
| 631 | extern struct tagtable __tagtable_begin, __tagtable_end; |
| 632 | struct tagtable *t; |
| 633 | |
| 634 | for (t = &__tagtable_begin; t < &__tagtable_end; t++) |
| 635 | if (tag->hdr.tag == t->tag) { |
| 636 | t->parse(tag); |
| 637 | break; |
| 638 | } |
| 639 | |
| 640 | return t < &__tagtable_end; |
| 641 | } |
| 642 | |
| 643 | /* |
| 644 | * Parse all tags in the list, checking both the global and architecture |
| 645 | * specific tag tables. |
| 646 | */ |
| 647 | static void __init parse_tags(const struct tag *t) |
| 648 | { |
| 649 | for (; t->hdr.size; t = tag_next(t)) |
| 650 | if (!parse_tag(t)) |
| 651 | printk(KERN_WARNING |
| 652 | "Ignoring unrecognised tag 0x%08x\n", |
| 653 | t->hdr.tag); |
| 654 | } |
| 655 | |
| 656 | /* |
| 657 | * This holds our defaults. |
| 658 | */ |
| 659 | static struct init_tags { |
| 660 | struct tag_header hdr1; |
| 661 | struct tag_core core; |
| 662 | struct tag_header hdr2; |
| 663 | struct tag_mem32 mem; |
| 664 | struct tag_header hdr3; |
| 665 | } init_tags __initdata = { |
| 666 | { tag_size(tag_core), ATAG_CORE }, |
| 667 | { 1, PAGE_SIZE, 0xff }, |
| 668 | { tag_size(tag_mem32), ATAG_MEM }, |
| 669 | { MEM_SIZE, PHYS_OFFSET }, |
| 670 | { 0, ATAG_NONE } |
| 671 | }; |
| 672 | |
| 673 | static void (*init_machine)(void) __initdata; |
| 674 | |
| 675 | static int __init customize_machine(void) |
| 676 | { |
| 677 | /* customizes platform devices, or adds new ones */ |
| 678 | if (init_machine) |
| 679 | init_machine(); |
| 680 | return 0; |
| 681 | } |
| 682 | arch_initcall(customize_machine); |
| 683 | |
Mika Westerberg | 3c57fb4 | 2010-05-10 09:20:22 +0100 | [diff] [blame^] | 684 | #ifdef CONFIG_KEXEC |
| 685 | static inline unsigned long long get_total_mem(void) |
| 686 | { |
| 687 | unsigned long total; |
| 688 | |
| 689 | total = max_low_pfn - min_low_pfn; |
| 690 | return total << PAGE_SHIFT; |
| 691 | } |
| 692 | |
| 693 | /** |
| 694 | * reserve_crashkernel() - reserves memory are for crash kernel |
| 695 | * |
| 696 | * This function reserves memory area given in "crashkernel=" kernel command |
| 697 | * line parameter. The memory reserved is used by a dump capture kernel when |
| 698 | * primary kernel is crashing. |
| 699 | */ |
| 700 | static void __init reserve_crashkernel(void) |
| 701 | { |
| 702 | unsigned long long crash_size, crash_base; |
| 703 | unsigned long long total_mem; |
| 704 | int ret; |
| 705 | |
| 706 | total_mem = get_total_mem(); |
| 707 | ret = parse_crashkernel(boot_command_line, total_mem, |
| 708 | &crash_size, &crash_base); |
| 709 | if (ret) |
| 710 | return; |
| 711 | |
| 712 | ret = reserve_bootmem(crash_base, crash_size, BOOTMEM_EXCLUSIVE); |
| 713 | if (ret < 0) { |
| 714 | printk(KERN_WARNING "crashkernel reservation failed - " |
| 715 | "memory is in use (0x%lx)\n", (unsigned long)crash_base); |
| 716 | return; |
| 717 | } |
| 718 | |
| 719 | printk(KERN_INFO "Reserving %ldMB of memory at %ldMB " |
| 720 | "for crashkernel (System RAM: %ldMB)\n", |
| 721 | (unsigned long)(crash_size >> 20), |
| 722 | (unsigned long)(crash_base >> 20), |
| 723 | (unsigned long)(total_mem >> 20)); |
| 724 | |
| 725 | crashk_res.start = crash_base; |
| 726 | crashk_res.end = crash_base + crash_size - 1; |
| 727 | insert_resource(&iomem_resource, &crashk_res); |
| 728 | } |
| 729 | #else |
| 730 | static inline void reserve_crashkernel(void) {} |
| 731 | #endif /* CONFIG_KEXEC */ |
| 732 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 733 | void __init setup_arch(char **cmdline_p) |
| 734 | { |
| 735 | struct tag *tags = (struct tag *)&init_tags; |
| 736 | struct machine_desc *mdesc; |
| 737 | char *from = default_command_line; |
| 738 | |
Catalin Marinas | bff595c | 2009-02-16 11:41:36 +0100 | [diff] [blame] | 739 | unwind_init(); |
| 740 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 741 | setup_processor(); |
| 742 | mdesc = setup_machine(machine_arch_type); |
| 743 | machine_name = mdesc->name; |
| 744 | |
| 745 | if (mdesc->soft_reboot) |
| 746 | reboot_setup("s"); |
| 747 | |
Bill Gatliff | 9d20fdd | 2007-05-31 22:02:22 +0100 | [diff] [blame] | 748 | if (__atags_pointer) |
| 749 | tags = phys_to_virt(__atags_pointer); |
| 750 | else if (mdesc->boot_params) |
Russell King | f9bd6ea | 2005-07-04 10:43:36 +0100 | [diff] [blame] | 751 | tags = phys_to_virt(mdesc->boot_params); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 752 | |
| 753 | /* |
| 754 | * If we have the old style parameters, convert them to |
| 755 | * a tag list. |
| 756 | */ |
| 757 | if (tags->hdr.tag != ATAG_CORE) |
| 758 | convert_to_tag_list(tags); |
| 759 | if (tags->hdr.tag != ATAG_CORE) |
| 760 | tags = (struct tag *)&init_tags; |
| 761 | |
| 762 | if (mdesc->fixup) |
| 763 | mdesc->fixup(mdesc, tags, &from, &meminfo); |
| 764 | |
| 765 | if (tags->hdr.tag == ATAG_CORE) { |
| 766 | if (meminfo.nr_banks != 0) |
| 767 | squash_mem_tags(tags); |
Richard Purdie | 4cd9d6f | 2008-01-02 00:56:46 +0100 | [diff] [blame] | 768 | save_atags(tags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 769 | parse_tags(tags); |
| 770 | } |
| 771 | |
Russell King | 37efe64 | 2008-12-01 11:53:07 +0000 | [diff] [blame] | 772 | init_mm.start_code = (unsigned long) _text; |
| 773 | init_mm.end_code = (unsigned long) _etext; |
| 774 | init_mm.end_data = (unsigned long) _edata; |
| 775 | init_mm.brk = (unsigned long) _end; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 776 | |
Jeremy Kerr | 2b0d8c2 | 2010-01-11 23:17:34 +0100 | [diff] [blame] | 777 | /* parse_early_param needs a boot_command_line */ |
| 778 | strlcpy(boot_command_line, from, COMMAND_LINE_SIZE); |
| 779 | |
Jeremy Kerr | 48ab7e0 | 2010-01-27 01:13:31 +0100 | [diff] [blame] | 780 | /* populate cmd_line too for later use, preserving boot_command_line */ |
| 781 | strlcpy(cmd_line, boot_command_line, COMMAND_LINE_SIZE); |
| 782 | *cmdline_p = cmd_line; |
Jeremy Kerr | 2b0d8c2 | 2010-01-11 23:17:34 +0100 | [diff] [blame] | 783 | |
| 784 | parse_early_param(); |
| 785 | |
Nicolas Pitre | 4b5f32c | 2008-10-06 13:24:40 -0400 | [diff] [blame] | 786 | paging_init(mdesc); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 787 | request_standard_resources(&meminfo, mdesc); |
| 788 | |
Russell King | 7bbb794 | 2006-02-16 11:08:09 +0000 | [diff] [blame] | 789 | #ifdef CONFIG_SMP |
| 790 | smp_init_cpus(); |
| 791 | #endif |
Mika Westerberg | 3c57fb4 | 2010-05-10 09:20:22 +0100 | [diff] [blame^] | 792 | reserve_crashkernel(); |
Russell King | 7bbb794 | 2006-02-16 11:08:09 +0000 | [diff] [blame] | 793 | |
Russell King | ccea7a1 | 2005-05-31 22:22:32 +0100 | [diff] [blame] | 794 | cpu_init(); |
Linus Walleij | bc58177 | 2009-09-15 17:30:37 +0100 | [diff] [blame] | 795 | tcm_init(); |
Russell King | ccea7a1 | 2005-05-31 22:22:32 +0100 | [diff] [blame] | 796 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 797 | /* |
| 798 | * Set up various architecture-specific pointers |
| 799 | */ |
eric miao | 354e6f7 | 2010-06-25 09:46:09 +0100 | [diff] [blame] | 800 | arch_nr_irqs = mdesc->nr_irqs; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 801 | init_arch_irq = mdesc->init_irq; |
| 802 | system_timer = mdesc->timer; |
| 803 | init_machine = mdesc->init_machine; |
| 804 | |
| 805 | #ifdef CONFIG_VT |
| 806 | #if defined(CONFIG_VGA_CONSOLE) |
| 807 | conswitchp = &vga_con; |
| 808 | #elif defined(CONFIG_DUMMY_CONSOLE) |
| 809 | conswitchp = &dummy_con; |
| 810 | #endif |
| 811 | #endif |
Jason Wessel | 5cbad0e | 2008-02-20 13:33:40 -0600 | [diff] [blame] | 812 | early_trap_init(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 813 | } |
| 814 | |
| 815 | |
| 816 | static int __init topology_init(void) |
| 817 | { |
| 818 | int cpu; |
| 819 | |
Russell King | 66fb8bd | 2007-03-13 09:54:21 +0000 | [diff] [blame] | 820 | for_each_possible_cpu(cpu) { |
| 821 | struct cpuinfo_arm *cpuinfo = &per_cpu(cpu_data, cpu); |
| 822 | cpuinfo->cpu.hotpluggable = 1; |
| 823 | register_cpu(&cpuinfo->cpu, cpu); |
| 824 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 825 | |
| 826 | return 0; |
| 827 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 828 | subsys_initcall(topology_init); |
| 829 | |
Russell King | e119bff | 2010-01-10 17:23:29 +0000 | [diff] [blame] | 830 | #ifdef CONFIG_HAVE_PROC_CPU |
| 831 | static int __init proc_cpu_init(void) |
| 832 | { |
| 833 | struct proc_dir_entry *res; |
| 834 | |
| 835 | res = proc_mkdir("cpu", NULL); |
| 836 | if (!res) |
| 837 | return -ENOMEM; |
| 838 | return 0; |
| 839 | } |
| 840 | fs_initcall(proc_cpu_init); |
| 841 | #endif |
| 842 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 843 | static const char *hwcap_str[] = { |
| 844 | "swp", |
| 845 | "half", |
| 846 | "thumb", |
| 847 | "26bit", |
| 848 | "fastmult", |
| 849 | "fpa", |
| 850 | "vfp", |
| 851 | "edsp", |
| 852 | "java", |
Paul Gortmaker | 8f7f943 | 2006-10-27 05:13:19 +0100 | [diff] [blame] | 853 | "iwmmxt", |
Lennert Buytenhek | 99e4a6d | 2006-12-18 00:59:10 +0100 | [diff] [blame] | 854 | "crunch", |
Catalin Marinas | 4369ae1 | 2008-11-06 13:23:06 +0000 | [diff] [blame] | 855 | "thumbee", |
Catalin Marinas | 2bedbdf | 2008-11-06 13:23:07 +0000 | [diff] [blame] | 856 | "neon", |
Catalin Marinas | 7279dc3 | 2009-02-11 13:13:56 +0100 | [diff] [blame] | 857 | "vfpv3", |
| 858 | "vfpv3d16", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 859 | NULL |
| 860 | }; |
| 861 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 862 | static int c_show(struct seq_file *m, void *v) |
| 863 | { |
| 864 | int i; |
| 865 | |
| 866 | seq_printf(m, "Processor\t: %s rev %d (%s)\n", |
Russell King | 0ba8b9b | 2008-08-10 18:08:10 +0100 | [diff] [blame] | 867 | cpu_name, read_cpuid_id() & 15, elf_platform); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 868 | |
| 869 | #if defined(CONFIG_SMP) |
| 870 | for_each_online_cpu(i) { |
Russell King | 1555972 | 2005-11-06 21:41:08 +0000 | [diff] [blame] | 871 | /* |
| 872 | * glibc reads /proc/cpuinfo to determine the number of |
| 873 | * online processors, looking for lines beginning with |
| 874 | * "processor". Give glibc what it expects. |
| 875 | */ |
| 876 | seq_printf(m, "processor\t: %d\n", i); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 877 | seq_printf(m, "BogoMIPS\t: %lu.%02lu\n\n", |
| 878 | per_cpu(cpu_data, i).loops_per_jiffy / (500000UL/HZ), |
| 879 | (per_cpu(cpu_data, i).loops_per_jiffy / (5000UL/HZ)) % 100); |
| 880 | } |
| 881 | #else /* CONFIG_SMP */ |
| 882 | seq_printf(m, "BogoMIPS\t: %lu.%02lu\n", |
| 883 | loops_per_jiffy / (500000/HZ), |
| 884 | (loops_per_jiffy / (5000/HZ)) % 100); |
| 885 | #endif |
| 886 | |
| 887 | /* dump out the processor features */ |
| 888 | seq_puts(m, "Features\t: "); |
| 889 | |
| 890 | for (i = 0; hwcap_str[i]; i++) |
| 891 | if (elf_hwcap & (1 << i)) |
| 892 | seq_printf(m, "%s ", hwcap_str[i]); |
| 893 | |
Russell King | 0ba8b9b | 2008-08-10 18:08:10 +0100 | [diff] [blame] | 894 | seq_printf(m, "\nCPU implementer\t: 0x%02x\n", read_cpuid_id() >> 24); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 895 | seq_printf(m, "CPU architecture: %s\n", proc_arch[cpu_architecture()]); |
| 896 | |
Russell King | 0ba8b9b | 2008-08-10 18:08:10 +0100 | [diff] [blame] | 897 | if ((read_cpuid_id() & 0x0008f000) == 0x00000000) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 898 | /* pre-ARM7 */ |
Russell King | 0ba8b9b | 2008-08-10 18:08:10 +0100 | [diff] [blame] | 899 | seq_printf(m, "CPU part\t: %07x\n", read_cpuid_id() >> 4); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 900 | } else { |
Russell King | 0ba8b9b | 2008-08-10 18:08:10 +0100 | [diff] [blame] | 901 | if ((read_cpuid_id() & 0x0008f000) == 0x00007000) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 902 | /* ARM7 */ |
| 903 | seq_printf(m, "CPU variant\t: 0x%02x\n", |
Russell King | 0ba8b9b | 2008-08-10 18:08:10 +0100 | [diff] [blame] | 904 | (read_cpuid_id() >> 16) & 127); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 905 | } else { |
| 906 | /* post-ARM7 */ |
| 907 | seq_printf(m, "CPU variant\t: 0x%x\n", |
Russell King | 0ba8b9b | 2008-08-10 18:08:10 +0100 | [diff] [blame] | 908 | (read_cpuid_id() >> 20) & 15); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 909 | } |
| 910 | seq_printf(m, "CPU part\t: 0x%03x\n", |
Russell King | 0ba8b9b | 2008-08-10 18:08:10 +0100 | [diff] [blame] | 911 | (read_cpuid_id() >> 4) & 0xfff); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 912 | } |
Russell King | 0ba8b9b | 2008-08-10 18:08:10 +0100 | [diff] [blame] | 913 | seq_printf(m, "CPU revision\t: %d\n", read_cpuid_id() & 15); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 914 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 915 | seq_puts(m, "\n"); |
| 916 | |
| 917 | seq_printf(m, "Hardware\t: %s\n", machine_name); |
| 918 | seq_printf(m, "Revision\t: %04x\n", system_rev); |
| 919 | seq_printf(m, "Serial\t\t: %08x%08x\n", |
| 920 | system_serial_high, system_serial_low); |
| 921 | |
| 922 | return 0; |
| 923 | } |
| 924 | |
| 925 | static void *c_start(struct seq_file *m, loff_t *pos) |
| 926 | { |
| 927 | return *pos < 1 ? (void *)1 : NULL; |
| 928 | } |
| 929 | |
| 930 | static void *c_next(struct seq_file *m, void *v, loff_t *pos) |
| 931 | { |
| 932 | ++*pos; |
| 933 | return NULL; |
| 934 | } |
| 935 | |
| 936 | static void c_stop(struct seq_file *m, void *v) |
| 937 | { |
| 938 | } |
| 939 | |
Jan Engelhardt | 2ffd6e1 | 2008-01-22 20:41:07 +0100 | [diff] [blame] | 940 | const struct seq_operations cpuinfo_op = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 941 | .start = c_start, |
| 942 | .next = c_next, |
| 943 | .stop = c_stop, |
| 944 | .show = c_show |
| 945 | }; |