11da177e4SLinus Torvalds /* 21da177e4SLinus Torvalds * linux/arch/arm/kernel/setup.c 31da177e4SLinus Torvalds * 41da177e4SLinus Torvalds * Copyright (C) 1995-2001 Russell King 51da177e4SLinus Torvalds * 61da177e4SLinus Torvalds * This program is free software; you can redistribute it and/or modify 71da177e4SLinus Torvalds * it under the terms of the GNU General Public License version 2 as 81da177e4SLinus Torvalds * published by the Free Software Foundation. 91da177e4SLinus Torvalds */ 101da177e4SLinus Torvalds #include <linux/module.h> 111da177e4SLinus Torvalds #include <linux/kernel.h> 121da177e4SLinus Torvalds #include <linux/stddef.h> 131da177e4SLinus Torvalds #include <linux/ioport.h> 141da177e4SLinus Torvalds #include <linux/delay.h> 151da177e4SLinus Torvalds #include <linux/utsname.h> 161da177e4SLinus Torvalds #include <linux/initrd.h> 171da177e4SLinus Torvalds #include <linux/console.h> 181da177e4SLinus Torvalds #include <linux/bootmem.h> 191da177e4SLinus Torvalds #include <linux/seq_file.h> 20894673eeSJon Smirl #include <linux/screen_info.h> 211da177e4SLinus Torvalds #include <linux/init.h> 221da177e4SLinus Torvalds #include <linux/root_dev.h> 231da177e4SLinus Torvalds #include <linux/cpu.h> 241da177e4SLinus Torvalds #include <linux/interrupt.h> 257bbb7940SRussell King #include <linux/smp.h> 261da177e4SLinus Torvalds 271da177e4SLinus Torvalds #include <asm/cpu.h> 281da177e4SLinus Torvalds #include <asm/elf.h> 291da177e4SLinus Torvalds #include <asm/procinfo.h> 301da177e4SLinus Torvalds #include <asm/setup.h> 311da177e4SLinus Torvalds #include <asm/mach-types.h> 321da177e4SLinus Torvalds #include <asm/cacheflush.h> 331da177e4SLinus Torvalds #include <asm/tlbflush.h> 341da177e4SLinus Torvalds 351da177e4SLinus Torvalds #include <asm/mach/arch.h> 361da177e4SLinus Torvalds #include <asm/mach/irq.h> 371da177e4SLinus Torvalds #include <asm/mach/time.h> 381da177e4SLinus Torvalds 390fc1c832SBen Dooks #include "compat.h" 400fc1c832SBen Dooks 411da177e4SLinus Torvalds #ifndef MEM_SIZE 421da177e4SLinus Torvalds #define MEM_SIZE (16*1024*1024) 431da177e4SLinus Torvalds #endif 441da177e4SLinus Torvalds 451da177e4SLinus Torvalds #if defined(CONFIG_FPE_NWFPE) || defined(CONFIG_FPE_FASTFPE) 461da177e4SLinus Torvalds char fpe_type[8]; 471da177e4SLinus Torvalds 481da177e4SLinus Torvalds static int __init fpe_setup(char *line) 491da177e4SLinus Torvalds { 501da177e4SLinus Torvalds memcpy(fpe_type, line, 8); 511da177e4SLinus Torvalds return 1; 521da177e4SLinus Torvalds } 531da177e4SLinus Torvalds 541da177e4SLinus Torvalds __setup("fpe=", fpe_setup); 551da177e4SLinus Torvalds #endif 561da177e4SLinus Torvalds 571da177e4SLinus Torvalds extern void paging_init(struct meminfo *, struct machine_desc *desc); 581da177e4SLinus Torvalds extern void reboot_setup(char *str); 591da177e4SLinus Torvalds extern int root_mountflags; 601da177e4SLinus Torvalds extern void _stext, _text, _etext, __data_start, _edata, _end; 611da177e4SLinus Torvalds 621da177e4SLinus Torvalds unsigned int processor_id; 631da177e4SLinus Torvalds unsigned int __machine_arch_type; 641da177e4SLinus Torvalds EXPORT_SYMBOL(__machine_arch_type); 651da177e4SLinus Torvalds 661da177e4SLinus Torvalds unsigned int system_rev; 671da177e4SLinus Torvalds EXPORT_SYMBOL(system_rev); 681da177e4SLinus Torvalds 691da177e4SLinus Torvalds unsigned int system_serial_low; 701da177e4SLinus Torvalds EXPORT_SYMBOL(system_serial_low); 711da177e4SLinus Torvalds 721da177e4SLinus Torvalds unsigned int system_serial_high; 731da177e4SLinus Torvalds EXPORT_SYMBOL(system_serial_high); 741da177e4SLinus Torvalds 751da177e4SLinus Torvalds unsigned int elf_hwcap; 761da177e4SLinus Torvalds EXPORT_SYMBOL(elf_hwcap); 771da177e4SLinus Torvalds 781da177e4SLinus Torvalds 791da177e4SLinus Torvalds #ifdef MULTI_CPU 801da177e4SLinus Torvalds struct processor processor; 811da177e4SLinus Torvalds #endif 821da177e4SLinus Torvalds #ifdef MULTI_TLB 831da177e4SLinus Torvalds struct cpu_tlb_fns cpu_tlb; 841da177e4SLinus Torvalds #endif 851da177e4SLinus Torvalds #ifdef MULTI_USER 861da177e4SLinus Torvalds struct cpu_user_fns cpu_user; 871da177e4SLinus Torvalds #endif 881da177e4SLinus Torvalds #ifdef MULTI_CACHE 891da177e4SLinus Torvalds struct cpu_cache_fns cpu_cache; 901da177e4SLinus Torvalds #endif 911da177e4SLinus Torvalds 92ccea7a19SRussell King struct stack { 93ccea7a19SRussell King u32 irq[3]; 94ccea7a19SRussell King u32 abt[3]; 95ccea7a19SRussell King u32 und[3]; 96ccea7a19SRussell King } ____cacheline_aligned; 97ccea7a19SRussell King 98ccea7a19SRussell King static struct stack stacks[NR_CPUS]; 99ccea7a19SRussell King 1001da177e4SLinus Torvalds char elf_platform[ELF_PLATFORM_SIZE]; 1011da177e4SLinus Torvalds EXPORT_SYMBOL(elf_platform); 1021da177e4SLinus Torvalds 1031da177e4SLinus Torvalds unsigned long phys_initrd_start __initdata = 0; 1041da177e4SLinus Torvalds unsigned long phys_initrd_size __initdata = 0; 1051da177e4SLinus Torvalds 1061da177e4SLinus Torvalds static struct meminfo meminfo __initdata = { 0, }; 1071da177e4SLinus Torvalds static const char *cpu_name; 1081da177e4SLinus Torvalds static const char *machine_name; 109cd81899aSAlon Bar-Lev static char __initdata command_line[COMMAND_LINE_SIZE]; 1101da177e4SLinus Torvalds 1111da177e4SLinus Torvalds static char default_command_line[COMMAND_LINE_SIZE] __initdata = CONFIG_CMDLINE; 1121da177e4SLinus Torvalds static union { char c[4]; unsigned long l; } endian_test __initdata = { { 'l', '?', '?', 'b' } }; 1131da177e4SLinus Torvalds #define ENDIANNESS ((char)endian_test.l) 1141da177e4SLinus Torvalds 1151da177e4SLinus Torvalds DEFINE_PER_CPU(struct cpuinfo_arm, cpu_data); 1161da177e4SLinus Torvalds 1171da177e4SLinus Torvalds /* 1181da177e4SLinus Torvalds * Standard memory resources 1191da177e4SLinus Torvalds */ 1201da177e4SLinus Torvalds static struct resource mem_res[] = { 121740e518eSGreg Kroah-Hartman { 122740e518eSGreg Kroah-Hartman .name = "Video RAM", 123740e518eSGreg Kroah-Hartman .start = 0, 124740e518eSGreg Kroah-Hartman .end = 0, 125740e518eSGreg Kroah-Hartman .flags = IORESOURCE_MEM 126740e518eSGreg Kroah-Hartman }, 127740e518eSGreg Kroah-Hartman { 128740e518eSGreg Kroah-Hartman .name = "Kernel text", 129740e518eSGreg Kroah-Hartman .start = 0, 130740e518eSGreg Kroah-Hartman .end = 0, 131740e518eSGreg Kroah-Hartman .flags = IORESOURCE_MEM 132740e518eSGreg Kroah-Hartman }, 133740e518eSGreg Kroah-Hartman { 134740e518eSGreg Kroah-Hartman .name = "Kernel data", 135740e518eSGreg Kroah-Hartman .start = 0, 136740e518eSGreg Kroah-Hartman .end = 0, 137740e518eSGreg Kroah-Hartman .flags = IORESOURCE_MEM 138740e518eSGreg Kroah-Hartman } 1391da177e4SLinus Torvalds }; 1401da177e4SLinus Torvalds 1411da177e4SLinus Torvalds #define video_ram mem_res[0] 1421da177e4SLinus Torvalds #define kernel_code mem_res[1] 1431da177e4SLinus Torvalds #define kernel_data mem_res[2] 1441da177e4SLinus Torvalds 1451da177e4SLinus Torvalds static struct resource io_res[] = { 146740e518eSGreg Kroah-Hartman { 147740e518eSGreg Kroah-Hartman .name = "reserved", 148740e518eSGreg Kroah-Hartman .start = 0x3bc, 149740e518eSGreg Kroah-Hartman .end = 0x3be, 150740e518eSGreg Kroah-Hartman .flags = IORESOURCE_IO | IORESOURCE_BUSY 151740e518eSGreg Kroah-Hartman }, 152740e518eSGreg Kroah-Hartman { 153740e518eSGreg Kroah-Hartman .name = "reserved", 154740e518eSGreg Kroah-Hartman .start = 0x378, 155740e518eSGreg Kroah-Hartman .end = 0x37f, 156740e518eSGreg Kroah-Hartman .flags = IORESOURCE_IO | IORESOURCE_BUSY 157740e518eSGreg Kroah-Hartman }, 158740e518eSGreg Kroah-Hartman { 159740e518eSGreg Kroah-Hartman .name = "reserved", 160740e518eSGreg Kroah-Hartman .start = 0x278, 161740e518eSGreg Kroah-Hartman .end = 0x27f, 162740e518eSGreg Kroah-Hartman .flags = IORESOURCE_IO | IORESOURCE_BUSY 163740e518eSGreg Kroah-Hartman } 1641da177e4SLinus Torvalds }; 1651da177e4SLinus Torvalds 1661da177e4SLinus Torvalds #define lp0 io_res[0] 1671da177e4SLinus Torvalds #define lp1 io_res[1] 1681da177e4SLinus Torvalds #define lp2 io_res[2] 1691da177e4SLinus Torvalds 1701da177e4SLinus Torvalds static const char *cache_types[16] = { 1711da177e4SLinus Torvalds "write-through", 1721da177e4SLinus Torvalds "write-back", 1731da177e4SLinus Torvalds "write-back", 1741da177e4SLinus Torvalds "undefined 3", 1751da177e4SLinus Torvalds "undefined 4", 1761da177e4SLinus Torvalds "undefined 5", 1771da177e4SLinus Torvalds "write-back", 1781da177e4SLinus Torvalds "write-back", 1791da177e4SLinus Torvalds "undefined 8", 1801da177e4SLinus Torvalds "undefined 9", 1811da177e4SLinus Torvalds "undefined 10", 1821da177e4SLinus Torvalds "undefined 11", 1831da177e4SLinus Torvalds "undefined 12", 1841da177e4SLinus Torvalds "undefined 13", 1851da177e4SLinus Torvalds "write-back", 1861da177e4SLinus Torvalds "undefined 15", 1871da177e4SLinus Torvalds }; 1881da177e4SLinus Torvalds 1891da177e4SLinus Torvalds static const char *cache_clean[16] = { 1901da177e4SLinus Torvalds "not required", 1911da177e4SLinus Torvalds "read-block", 1921da177e4SLinus Torvalds "cp15 c7 ops", 1931da177e4SLinus Torvalds "undefined 3", 1941da177e4SLinus Torvalds "undefined 4", 1951da177e4SLinus Torvalds "undefined 5", 1961da177e4SLinus Torvalds "cp15 c7 ops", 1971da177e4SLinus Torvalds "cp15 c7 ops", 1981da177e4SLinus Torvalds "undefined 8", 1991da177e4SLinus Torvalds "undefined 9", 2001da177e4SLinus Torvalds "undefined 10", 2011da177e4SLinus Torvalds "undefined 11", 2021da177e4SLinus Torvalds "undefined 12", 2031da177e4SLinus Torvalds "undefined 13", 2041da177e4SLinus Torvalds "cp15 c7 ops", 2051da177e4SLinus Torvalds "undefined 15", 2061da177e4SLinus Torvalds }; 2071da177e4SLinus Torvalds 2081da177e4SLinus Torvalds static const char *cache_lockdown[16] = { 2091da177e4SLinus Torvalds "not supported", 2101da177e4SLinus Torvalds "not supported", 2111da177e4SLinus Torvalds "not supported", 2121da177e4SLinus Torvalds "undefined 3", 2131da177e4SLinus Torvalds "undefined 4", 2141da177e4SLinus Torvalds "undefined 5", 2151da177e4SLinus Torvalds "format A", 2161da177e4SLinus Torvalds "format B", 2171da177e4SLinus Torvalds "undefined 8", 2181da177e4SLinus Torvalds "undefined 9", 2191da177e4SLinus Torvalds "undefined 10", 2201da177e4SLinus Torvalds "undefined 11", 2211da177e4SLinus Torvalds "undefined 12", 2221da177e4SLinus Torvalds "undefined 13", 2231da177e4SLinus Torvalds "format C", 2241da177e4SLinus Torvalds "undefined 15", 2251da177e4SLinus Torvalds }; 2261da177e4SLinus Torvalds 2271da177e4SLinus Torvalds static const char *proc_arch[] = { 2281da177e4SLinus Torvalds "undefined/unknown", 2291da177e4SLinus Torvalds "3", 2301da177e4SLinus Torvalds "4", 2311da177e4SLinus Torvalds "4T", 2321da177e4SLinus Torvalds "5", 2331da177e4SLinus Torvalds "5T", 2341da177e4SLinus Torvalds "5TE", 2351da177e4SLinus Torvalds "5TEJ", 2361da177e4SLinus Torvalds "6TEJ", 2376b090a25SCatalin Marinas "7", 2381da177e4SLinus Torvalds "?(11)", 2391da177e4SLinus Torvalds "?(12)", 2401da177e4SLinus Torvalds "?(13)", 2411da177e4SLinus Torvalds "?(14)", 2421da177e4SLinus Torvalds "?(15)", 2431da177e4SLinus Torvalds "?(16)", 2441da177e4SLinus Torvalds "?(17)", 2451da177e4SLinus Torvalds }; 2461da177e4SLinus Torvalds 2471da177e4SLinus Torvalds #define CACHE_TYPE(x) (((x) >> 25) & 15) 2481da177e4SLinus Torvalds #define CACHE_S(x) ((x) & (1 << 24)) 2491da177e4SLinus Torvalds #define CACHE_DSIZE(x) (((x) >> 12) & 4095) /* only if S=1 */ 2501da177e4SLinus Torvalds #define CACHE_ISIZE(x) ((x) & 4095) 2511da177e4SLinus Torvalds 2521da177e4SLinus Torvalds #define CACHE_SIZE(y) (((y) >> 6) & 7) 2531da177e4SLinus Torvalds #define CACHE_ASSOC(y) (((y) >> 3) & 7) 2541da177e4SLinus Torvalds #define CACHE_M(y) ((y) & (1 << 2)) 2551da177e4SLinus Torvalds #define CACHE_LINE(y) ((y) & 3) 2561da177e4SLinus Torvalds 2571da177e4SLinus Torvalds static inline void dump_cache(const char *prefix, int cpu, unsigned int cache) 2581da177e4SLinus Torvalds { 2591da177e4SLinus Torvalds unsigned int mult = 2 + (CACHE_M(cache) ? 1 : 0); 2601da177e4SLinus Torvalds 2611da177e4SLinus Torvalds printk("CPU%u: %s: %d bytes, associativity %d, %d byte lines, %d sets\n", 2621da177e4SLinus Torvalds cpu, prefix, 2631da177e4SLinus Torvalds mult << (8 + CACHE_SIZE(cache)), 2641da177e4SLinus Torvalds (mult << CACHE_ASSOC(cache)) >> 1, 2651da177e4SLinus Torvalds 8 << CACHE_LINE(cache), 2661da177e4SLinus Torvalds 1 << (6 + CACHE_SIZE(cache) - CACHE_ASSOC(cache) - 2671da177e4SLinus Torvalds CACHE_LINE(cache))); 2681da177e4SLinus Torvalds } 2691da177e4SLinus Torvalds 2701da177e4SLinus Torvalds static void __init dump_cpu_info(int cpu) 2711da177e4SLinus Torvalds { 2721da177e4SLinus Torvalds unsigned int info = read_cpuid(CPUID_CACHETYPE); 2731da177e4SLinus Torvalds 2741da177e4SLinus Torvalds if (info != processor_id) { 2751da177e4SLinus Torvalds printk("CPU%u: D %s %s cache\n", cpu, cache_is_vivt() ? "VIVT" : "VIPT", 2761da177e4SLinus Torvalds cache_types[CACHE_TYPE(info)]); 2771da177e4SLinus Torvalds if (CACHE_S(info)) { 2781da177e4SLinus Torvalds dump_cache("I cache", cpu, CACHE_ISIZE(info)); 2791da177e4SLinus Torvalds dump_cache("D cache", cpu, CACHE_DSIZE(info)); 2801da177e4SLinus Torvalds } else { 2811da177e4SLinus Torvalds dump_cache("cache", cpu, CACHE_ISIZE(info)); 2821da177e4SLinus Torvalds } 2831da177e4SLinus Torvalds } 28423759dc6SLennert Buytenhek 28523759dc6SLennert Buytenhek if (arch_is_coherent()) 28623759dc6SLennert Buytenhek printk("Cache coherency enabled\n"); 2871da177e4SLinus Torvalds } 2881da177e4SLinus Torvalds 2891da177e4SLinus Torvalds int cpu_architecture(void) 2901da177e4SLinus Torvalds { 2911da177e4SLinus Torvalds int cpu_arch; 2921da177e4SLinus Torvalds 2936b090a25SCatalin Marinas if ((processor_id & 0x0008f000) == 0) { 2941da177e4SLinus Torvalds cpu_arch = CPU_ARCH_UNKNOWN; 2956b090a25SCatalin Marinas } else if ((processor_id & 0x0008f000) == 0x00007000) { 2961da177e4SLinus Torvalds cpu_arch = (processor_id & (1 << 23)) ? CPU_ARCH_ARMv4T : CPU_ARCH_ARMv3; 2976b090a25SCatalin Marinas } else if ((processor_id & 0x00080000) == 0x00000000) { 2981da177e4SLinus Torvalds cpu_arch = (processor_id >> 16) & 7; 2991da177e4SLinus Torvalds if (cpu_arch) 3001da177e4SLinus Torvalds cpu_arch += CPU_ARCH_ARMv3; 3016b090a25SCatalin Marinas } else { 3026b090a25SCatalin Marinas /* the revised CPUID */ 3036b090a25SCatalin Marinas cpu_arch = ((processor_id >> 12) & 0xf) - 0xb + CPU_ARCH_ARMv6; 3041da177e4SLinus Torvalds } 3051da177e4SLinus Torvalds 3061da177e4SLinus Torvalds return cpu_arch; 3071da177e4SLinus Torvalds } 3081da177e4SLinus Torvalds 3091da177e4SLinus Torvalds /* 3101da177e4SLinus Torvalds * These functions re-use the assembly code in head.S, which 3111da177e4SLinus Torvalds * already provide the required functionality. 3121da177e4SLinus Torvalds */ 3130f44ba1dSRussell King extern struct proc_info_list *lookup_processor_type(unsigned int); 3141da177e4SLinus Torvalds extern struct machine_desc *lookup_machine_type(unsigned int); 3151da177e4SLinus Torvalds 3161da177e4SLinus Torvalds static void __init setup_processor(void) 3171da177e4SLinus Torvalds { 3181da177e4SLinus Torvalds struct proc_info_list *list; 3191da177e4SLinus Torvalds 3201da177e4SLinus Torvalds /* 3211da177e4SLinus Torvalds * locate processor in the list of supported processor 3221da177e4SLinus Torvalds * types. The linker builds this table for us from the 3231da177e4SLinus Torvalds * entries in arch/arm/mm/proc-*.S 3241da177e4SLinus Torvalds */ 3250f44ba1dSRussell King list = lookup_processor_type(processor_id); 3261da177e4SLinus Torvalds if (!list) { 3271da177e4SLinus Torvalds printk("CPU configuration botched (ID %08x), unable " 3281da177e4SLinus Torvalds "to continue.\n", processor_id); 3291da177e4SLinus Torvalds while (1); 3301da177e4SLinus Torvalds } 3311da177e4SLinus Torvalds 3321da177e4SLinus Torvalds cpu_name = list->cpu_name; 3331da177e4SLinus Torvalds 3341da177e4SLinus Torvalds #ifdef MULTI_CPU 3351da177e4SLinus Torvalds processor = *list->proc; 3361da177e4SLinus Torvalds #endif 3371da177e4SLinus Torvalds #ifdef MULTI_TLB 3381da177e4SLinus Torvalds cpu_tlb = *list->tlb; 3391da177e4SLinus Torvalds #endif 3401da177e4SLinus Torvalds #ifdef MULTI_USER 3411da177e4SLinus Torvalds cpu_user = *list->user; 3421da177e4SLinus Torvalds #endif 3431da177e4SLinus Torvalds #ifdef MULTI_CACHE 3441da177e4SLinus Torvalds cpu_cache = *list->cache; 3451da177e4SLinus Torvalds #endif 3461da177e4SLinus Torvalds 3474e19025bSRussell King printk("CPU: %s [%08x] revision %d (ARMv%s), cr=%08lx\n", 3481da177e4SLinus Torvalds cpu_name, processor_id, (int)processor_id & 15, 349264edb35SRussell King proc_arch[cpu_architecture()], cr_alignment); 3501da177e4SLinus Torvalds 35196b644bdSSerge E. Hallyn sprintf(init_utsname()->machine, "%s%c", list->arch_name, ENDIANNESS); 3521da177e4SLinus Torvalds sprintf(elf_platform, "%s%c", list->elf_name, ENDIANNESS); 3531da177e4SLinus Torvalds elf_hwcap = list->elf_hwcap; 354adeff422SCatalin Marinas #ifndef CONFIG_ARM_THUMB 355adeff422SCatalin Marinas elf_hwcap &= ~HWCAP_THUMB; 356adeff422SCatalin Marinas #endif 3571da177e4SLinus Torvalds 3581da177e4SLinus Torvalds cpu_proc_init(); 3591da177e4SLinus Torvalds } 3601da177e4SLinus Torvalds 361ccea7a19SRussell King /* 362ccea7a19SRussell King * cpu_init - initialise one CPU. 363ccea7a19SRussell King * 364ccea7a19SRussell King * cpu_init dumps the cache information, initialises SMP specific 365ccea7a19SRussell King * information, and sets up the per-CPU stacks. 366ccea7a19SRussell King */ 36736c5ed23SRussell King void cpu_init(void) 368ccea7a19SRussell King { 369ccea7a19SRussell King unsigned int cpu = smp_processor_id(); 370ccea7a19SRussell King struct stack *stk = &stacks[cpu]; 371ccea7a19SRussell King 372ccea7a19SRussell King if (cpu >= NR_CPUS) { 373ccea7a19SRussell King printk(KERN_CRIT "CPU%u: bad primary CPU number\n", cpu); 374ccea7a19SRussell King BUG(); 375ccea7a19SRussell King } 376ccea7a19SRussell King 37732f8b97cSRussell King if (system_state == SYSTEM_BOOTING) 378ccea7a19SRussell King dump_cpu_info(cpu); 379ccea7a19SRussell King 380ccea7a19SRussell King /* 381ccea7a19SRussell King * setup stacks for re-entrant exception handlers 382ccea7a19SRussell King */ 383ccea7a19SRussell King __asm__ ( 384ccea7a19SRussell King "msr cpsr_c, %1\n\t" 385ccea7a19SRussell King "add sp, %0, %2\n\t" 386ccea7a19SRussell King "msr cpsr_c, %3\n\t" 387ccea7a19SRussell King "add sp, %0, %4\n\t" 388ccea7a19SRussell King "msr cpsr_c, %5\n\t" 389ccea7a19SRussell King "add sp, %0, %6\n\t" 390ccea7a19SRussell King "msr cpsr_c, %7" 391ccea7a19SRussell King : 392ccea7a19SRussell King : "r" (stk), 393ccea7a19SRussell King "I" (PSR_F_BIT | PSR_I_BIT | IRQ_MODE), 394ccea7a19SRussell King "I" (offsetof(struct stack, irq[0])), 395ccea7a19SRussell King "I" (PSR_F_BIT | PSR_I_BIT | ABT_MODE), 396ccea7a19SRussell King "I" (offsetof(struct stack, abt[0])), 397ccea7a19SRussell King "I" (PSR_F_BIT | PSR_I_BIT | UND_MODE), 398ccea7a19SRussell King "I" (offsetof(struct stack, und[0])), 399aaaa3f9eSCatalin Marinas "I" (PSR_F_BIT | PSR_I_BIT | SVC_MODE) 400aaaa3f9eSCatalin Marinas : "r14"); 401ccea7a19SRussell King } 402ccea7a19SRussell King 4031da177e4SLinus Torvalds static struct machine_desc * __init setup_machine(unsigned int nr) 4041da177e4SLinus Torvalds { 4051da177e4SLinus Torvalds struct machine_desc *list; 4061da177e4SLinus Torvalds 4071da177e4SLinus Torvalds /* 4081da177e4SLinus Torvalds * locate machine in the list of supported machines. 4091da177e4SLinus Torvalds */ 4101da177e4SLinus Torvalds list = lookup_machine_type(nr); 4111da177e4SLinus Torvalds if (!list) { 4121da177e4SLinus Torvalds printk("Machine configuration botched (nr %d), unable " 4131da177e4SLinus Torvalds "to continue.\n", nr); 4141da177e4SLinus Torvalds while (1); 4151da177e4SLinus Torvalds } 4161da177e4SLinus Torvalds 4171da177e4SLinus Torvalds printk("Machine: %s\n", list->name); 4181da177e4SLinus Torvalds 4191da177e4SLinus Torvalds return list; 4201da177e4SLinus Torvalds } 4211da177e4SLinus Torvalds 4221da177e4SLinus Torvalds static void __init early_initrd(char **p) 4231da177e4SLinus Torvalds { 4241da177e4SLinus Torvalds unsigned long start, size; 4251da177e4SLinus Torvalds 4261da177e4SLinus Torvalds start = memparse(*p, p); 4271da177e4SLinus Torvalds if (**p == ',') { 4281da177e4SLinus Torvalds size = memparse((*p) + 1, p); 4291da177e4SLinus Torvalds 4301da177e4SLinus Torvalds phys_initrd_start = start; 4311da177e4SLinus Torvalds phys_initrd_size = size; 4321da177e4SLinus Torvalds } 4331da177e4SLinus Torvalds } 4341da177e4SLinus Torvalds __early_param("initrd=", early_initrd); 4351da177e4SLinus Torvalds 4361c97b73eSAndrew Morton static void __init arm_add_memory(unsigned long start, unsigned long size) 4373a669411SRussell King { 43805f96ef1SRussell King struct membank *bank; 43905f96ef1SRussell King 4403a669411SRussell King /* 4413a669411SRussell King * Ensure that start/size are aligned to a page boundary. 4423a669411SRussell King * Size is appropriately rounded down, start is rounded up. 4433a669411SRussell King */ 4443a669411SRussell King size -= start & ~PAGE_MASK; 4453a669411SRussell King 44605f96ef1SRussell King bank = &meminfo.bank[meminfo.nr_banks++]; 44705f96ef1SRussell King 44805f96ef1SRussell King bank->start = PAGE_ALIGN(start); 44905f96ef1SRussell King bank->size = size & PAGE_MASK; 45005f96ef1SRussell King bank->node = PHYS_TO_NID(start); 4513a669411SRussell King } 4523a669411SRussell King 4531da177e4SLinus Torvalds /* 4541da177e4SLinus Torvalds * Pick out the memory size. We look for mem=size@start, 4551da177e4SLinus Torvalds * where start and size are "size[KkMm]" 4561da177e4SLinus Torvalds */ 4571da177e4SLinus Torvalds static void __init early_mem(char **p) 4581da177e4SLinus Torvalds { 4591da177e4SLinus Torvalds static int usermem __initdata = 0; 4601da177e4SLinus Torvalds unsigned long size, start; 4611da177e4SLinus Torvalds 4621da177e4SLinus Torvalds /* 4631da177e4SLinus Torvalds * If the user specifies memory size, we 4641da177e4SLinus Torvalds * blow away any automatically generated 4651da177e4SLinus Torvalds * size. 4661da177e4SLinus Torvalds */ 4671da177e4SLinus Torvalds if (usermem == 0) { 4681da177e4SLinus Torvalds usermem = 1; 4691da177e4SLinus Torvalds meminfo.nr_banks = 0; 4701da177e4SLinus Torvalds } 4711da177e4SLinus Torvalds 4721da177e4SLinus Torvalds start = PHYS_OFFSET; 4731da177e4SLinus Torvalds size = memparse(*p, p); 4741da177e4SLinus Torvalds if (**p == '@') 4751da177e4SLinus Torvalds start = memparse(*p + 1, p); 4761da177e4SLinus Torvalds 4771c97b73eSAndrew Morton arm_add_memory(start, size); 4781da177e4SLinus Torvalds } 4791da177e4SLinus Torvalds __early_param("mem=", early_mem); 4801da177e4SLinus Torvalds 4811da177e4SLinus Torvalds /* 4821da177e4SLinus Torvalds * Initial parsing of the command line. 4831da177e4SLinus Torvalds */ 4841da177e4SLinus Torvalds static void __init parse_cmdline(char **cmdline_p, char *from) 4851da177e4SLinus Torvalds { 4861da177e4SLinus Torvalds char c = ' ', *to = command_line; 4871da177e4SLinus Torvalds int len = 0; 4881da177e4SLinus Torvalds 4891da177e4SLinus Torvalds for (;;) { 4901da177e4SLinus Torvalds if (c == ' ') { 4911da177e4SLinus Torvalds extern struct early_params __early_begin, __early_end; 4921da177e4SLinus Torvalds struct early_params *p; 4931da177e4SLinus Torvalds 4941da177e4SLinus Torvalds for (p = &__early_begin; p < &__early_end; p++) { 4951da177e4SLinus Torvalds int len = strlen(p->arg); 4961da177e4SLinus Torvalds 4971da177e4SLinus Torvalds if (memcmp(from, p->arg, len) == 0) { 4981da177e4SLinus Torvalds if (to != command_line) 4991da177e4SLinus Torvalds to -= 1; 5001da177e4SLinus Torvalds from += len; 5011da177e4SLinus Torvalds p->fn(&from); 5021da177e4SLinus Torvalds 5031da177e4SLinus Torvalds while (*from != ' ' && *from != '\0') 5041da177e4SLinus Torvalds from++; 5051da177e4SLinus Torvalds break; 5061da177e4SLinus Torvalds } 5071da177e4SLinus Torvalds } 5081da177e4SLinus Torvalds } 5091da177e4SLinus Torvalds c = *from++; 5101da177e4SLinus Torvalds if (!c) 5111da177e4SLinus Torvalds break; 5121da177e4SLinus Torvalds if (COMMAND_LINE_SIZE <= ++len) 5131da177e4SLinus Torvalds break; 5141da177e4SLinus Torvalds *to++ = c; 5151da177e4SLinus Torvalds } 5161da177e4SLinus Torvalds *to = '\0'; 5171da177e4SLinus Torvalds *cmdline_p = command_line; 5181da177e4SLinus Torvalds } 5191da177e4SLinus Torvalds 5201da177e4SLinus Torvalds static void __init 5211da177e4SLinus Torvalds setup_ramdisk(int doload, int prompt, int image_start, unsigned int rd_sz) 5221da177e4SLinus Torvalds { 5231da177e4SLinus Torvalds #ifdef CONFIG_BLK_DEV_RAM 5241da177e4SLinus Torvalds extern int rd_size, rd_image_start, rd_prompt, rd_doload; 5251da177e4SLinus Torvalds 5261da177e4SLinus Torvalds rd_image_start = image_start; 5271da177e4SLinus Torvalds rd_prompt = prompt; 5281da177e4SLinus Torvalds rd_doload = doload; 5291da177e4SLinus Torvalds 5301da177e4SLinus Torvalds if (rd_sz) 5311da177e4SLinus Torvalds rd_size = rd_sz; 5321da177e4SLinus Torvalds #endif 5331da177e4SLinus Torvalds } 5341da177e4SLinus Torvalds 5351da177e4SLinus Torvalds static void __init 5361da177e4SLinus Torvalds request_standard_resources(struct meminfo *mi, struct machine_desc *mdesc) 5371da177e4SLinus Torvalds { 5381da177e4SLinus Torvalds struct resource *res; 5391da177e4SLinus Torvalds int i; 5401da177e4SLinus Torvalds 5411da177e4SLinus Torvalds kernel_code.start = virt_to_phys(&_text); 5421da177e4SLinus Torvalds kernel_code.end = virt_to_phys(&_etext - 1); 5431da177e4SLinus Torvalds kernel_data.start = virt_to_phys(&__data_start); 5441da177e4SLinus Torvalds kernel_data.end = virt_to_phys(&_end - 1); 5451da177e4SLinus Torvalds 5461da177e4SLinus Torvalds for (i = 0; i < mi->nr_banks; i++) { 5471da177e4SLinus Torvalds unsigned long virt_start, virt_end; 5481da177e4SLinus Torvalds 5491da177e4SLinus Torvalds if (mi->bank[i].size == 0) 5501da177e4SLinus Torvalds continue; 5511da177e4SLinus Torvalds 5521da177e4SLinus Torvalds virt_start = __phys_to_virt(mi->bank[i].start); 5531da177e4SLinus Torvalds virt_end = virt_start + mi->bank[i].size - 1; 5541da177e4SLinus Torvalds 5551da177e4SLinus Torvalds res = alloc_bootmem_low(sizeof(*res)); 5561da177e4SLinus Torvalds res->name = "System RAM"; 5571da177e4SLinus Torvalds res->start = __virt_to_phys(virt_start); 5581da177e4SLinus Torvalds res->end = __virt_to_phys(virt_end); 5591da177e4SLinus Torvalds res->flags = IORESOURCE_MEM | IORESOURCE_BUSY; 5601da177e4SLinus Torvalds 5611da177e4SLinus Torvalds request_resource(&iomem_resource, res); 5621da177e4SLinus Torvalds 5631da177e4SLinus Torvalds if (kernel_code.start >= res->start && 5641da177e4SLinus Torvalds kernel_code.end <= res->end) 5651da177e4SLinus Torvalds request_resource(res, &kernel_code); 5661da177e4SLinus Torvalds if (kernel_data.start >= res->start && 5671da177e4SLinus Torvalds kernel_data.end <= res->end) 5681da177e4SLinus Torvalds request_resource(res, &kernel_data); 5691da177e4SLinus Torvalds } 5701da177e4SLinus Torvalds 5711da177e4SLinus Torvalds if (mdesc->video_start) { 5721da177e4SLinus Torvalds video_ram.start = mdesc->video_start; 5731da177e4SLinus Torvalds video_ram.end = mdesc->video_end; 5741da177e4SLinus Torvalds request_resource(&iomem_resource, &video_ram); 5751da177e4SLinus Torvalds } 5761da177e4SLinus Torvalds 5771da177e4SLinus Torvalds /* 5781da177e4SLinus Torvalds * Some machines don't have the possibility of ever 5791da177e4SLinus Torvalds * possessing lp0, lp1 or lp2 5801da177e4SLinus Torvalds */ 5811da177e4SLinus Torvalds if (mdesc->reserve_lp0) 5821da177e4SLinus Torvalds request_resource(&ioport_resource, &lp0); 5831da177e4SLinus Torvalds if (mdesc->reserve_lp1) 5841da177e4SLinus Torvalds request_resource(&ioport_resource, &lp1); 5851da177e4SLinus Torvalds if (mdesc->reserve_lp2) 5861da177e4SLinus Torvalds request_resource(&ioport_resource, &lp2); 5871da177e4SLinus Torvalds } 5881da177e4SLinus Torvalds 5891da177e4SLinus Torvalds /* 5901da177e4SLinus Torvalds * Tag parsing. 5911da177e4SLinus Torvalds * 5921da177e4SLinus Torvalds * This is the new way of passing data to the kernel at boot time. Rather 5931da177e4SLinus Torvalds * than passing a fixed inflexible structure to the kernel, we pass a list 5941da177e4SLinus Torvalds * of variable-sized tags to the kernel. The first tag must be a ATAG_CORE 5951da177e4SLinus Torvalds * tag for the list to be recognised (to distinguish the tagged list from 5961da177e4SLinus Torvalds * a param_struct). The list is terminated with a zero-length tag (this tag 5971da177e4SLinus Torvalds * is not parsed in any way). 5981da177e4SLinus Torvalds */ 5991da177e4SLinus Torvalds static int __init parse_tag_core(const struct tag *tag) 6001da177e4SLinus Torvalds { 6011da177e4SLinus Torvalds if (tag->hdr.size > 2) { 6021da177e4SLinus Torvalds if ((tag->u.core.flags & 1) == 0) 6031da177e4SLinus Torvalds root_mountflags &= ~MS_RDONLY; 6041da177e4SLinus Torvalds ROOT_DEV = old_decode_dev(tag->u.core.rootdev); 6051da177e4SLinus Torvalds } 6061da177e4SLinus Torvalds return 0; 6071da177e4SLinus Torvalds } 6081da177e4SLinus Torvalds 6091da177e4SLinus Torvalds __tagtable(ATAG_CORE, parse_tag_core); 6101da177e4SLinus Torvalds 6111da177e4SLinus Torvalds static int __init parse_tag_mem32(const struct tag *tag) 6121da177e4SLinus Torvalds { 6131da177e4SLinus Torvalds if (meminfo.nr_banks >= NR_BANKS) { 6141da177e4SLinus Torvalds printk(KERN_WARNING 6151da177e4SLinus Torvalds "Ignoring memory bank 0x%08x size %dKB\n", 6161da177e4SLinus Torvalds tag->u.mem.start, tag->u.mem.size / 1024); 6171da177e4SLinus Torvalds return -EINVAL; 6181da177e4SLinus Torvalds } 6191c97b73eSAndrew Morton arm_add_memory(tag->u.mem.start, tag->u.mem.size); 6201da177e4SLinus Torvalds return 0; 6211da177e4SLinus Torvalds } 6221da177e4SLinus Torvalds 6231da177e4SLinus Torvalds __tagtable(ATAG_MEM, parse_tag_mem32); 6241da177e4SLinus Torvalds 6251da177e4SLinus Torvalds #if defined(CONFIG_VGA_CONSOLE) || defined(CONFIG_DUMMY_CONSOLE) 6261da177e4SLinus Torvalds struct screen_info screen_info = { 6271da177e4SLinus Torvalds .orig_video_lines = 30, 6281da177e4SLinus Torvalds .orig_video_cols = 80, 6291da177e4SLinus Torvalds .orig_video_mode = 0, 6301da177e4SLinus Torvalds .orig_video_ega_bx = 0, 6311da177e4SLinus Torvalds .orig_video_isVGA = 1, 6321da177e4SLinus Torvalds .orig_video_points = 8 6331da177e4SLinus Torvalds }; 6341da177e4SLinus Torvalds 6351da177e4SLinus Torvalds static int __init parse_tag_videotext(const struct tag *tag) 6361da177e4SLinus Torvalds { 6371da177e4SLinus Torvalds screen_info.orig_x = tag->u.videotext.x; 6381da177e4SLinus Torvalds screen_info.orig_y = tag->u.videotext.y; 6391da177e4SLinus Torvalds screen_info.orig_video_page = tag->u.videotext.video_page; 6401da177e4SLinus Torvalds screen_info.orig_video_mode = tag->u.videotext.video_mode; 6411da177e4SLinus Torvalds screen_info.orig_video_cols = tag->u.videotext.video_cols; 6421da177e4SLinus Torvalds screen_info.orig_video_ega_bx = tag->u.videotext.video_ega_bx; 6431da177e4SLinus Torvalds screen_info.orig_video_lines = tag->u.videotext.video_lines; 6441da177e4SLinus Torvalds screen_info.orig_video_isVGA = tag->u.videotext.video_isvga; 6451da177e4SLinus Torvalds screen_info.orig_video_points = tag->u.videotext.video_points; 6461da177e4SLinus Torvalds return 0; 6471da177e4SLinus Torvalds } 6481da177e4SLinus Torvalds 6491da177e4SLinus Torvalds __tagtable(ATAG_VIDEOTEXT, parse_tag_videotext); 6501da177e4SLinus Torvalds #endif 6511da177e4SLinus Torvalds 6521da177e4SLinus Torvalds static int __init parse_tag_ramdisk(const struct tag *tag) 6531da177e4SLinus Torvalds { 6541da177e4SLinus Torvalds setup_ramdisk((tag->u.ramdisk.flags & 1) == 0, 6551da177e4SLinus Torvalds (tag->u.ramdisk.flags & 2) == 0, 6561da177e4SLinus Torvalds tag->u.ramdisk.start, tag->u.ramdisk.size); 6571da177e4SLinus Torvalds return 0; 6581da177e4SLinus Torvalds } 6591da177e4SLinus Torvalds 6601da177e4SLinus Torvalds __tagtable(ATAG_RAMDISK, parse_tag_ramdisk); 6611da177e4SLinus Torvalds 6621da177e4SLinus Torvalds static int __init parse_tag_initrd(const struct tag *tag) 6631da177e4SLinus Torvalds { 6641da177e4SLinus Torvalds printk(KERN_WARNING "ATAG_INITRD is deprecated; " 6651da177e4SLinus Torvalds "please update your bootloader.\n"); 6661da177e4SLinus Torvalds phys_initrd_start = __virt_to_phys(tag->u.initrd.start); 6671da177e4SLinus Torvalds phys_initrd_size = tag->u.initrd.size; 6681da177e4SLinus Torvalds return 0; 6691da177e4SLinus Torvalds } 6701da177e4SLinus Torvalds 6711da177e4SLinus Torvalds __tagtable(ATAG_INITRD, parse_tag_initrd); 6721da177e4SLinus Torvalds 6731da177e4SLinus Torvalds static int __init parse_tag_initrd2(const struct tag *tag) 6741da177e4SLinus Torvalds { 6751da177e4SLinus Torvalds phys_initrd_start = tag->u.initrd.start; 6761da177e4SLinus Torvalds phys_initrd_size = tag->u.initrd.size; 6771da177e4SLinus Torvalds return 0; 6781da177e4SLinus Torvalds } 6791da177e4SLinus Torvalds 6801da177e4SLinus Torvalds __tagtable(ATAG_INITRD2, parse_tag_initrd2); 6811da177e4SLinus Torvalds 6821da177e4SLinus Torvalds static int __init parse_tag_serialnr(const struct tag *tag) 6831da177e4SLinus Torvalds { 6841da177e4SLinus Torvalds system_serial_low = tag->u.serialnr.low; 6851da177e4SLinus Torvalds system_serial_high = tag->u.serialnr.high; 6861da177e4SLinus Torvalds return 0; 6871da177e4SLinus Torvalds } 6881da177e4SLinus Torvalds 6891da177e4SLinus Torvalds __tagtable(ATAG_SERIAL, parse_tag_serialnr); 6901da177e4SLinus Torvalds 6911da177e4SLinus Torvalds static int __init parse_tag_revision(const struct tag *tag) 6921da177e4SLinus Torvalds { 6931da177e4SLinus Torvalds system_rev = tag->u.revision.rev; 6941da177e4SLinus Torvalds return 0; 6951da177e4SLinus Torvalds } 6961da177e4SLinus Torvalds 6971da177e4SLinus Torvalds __tagtable(ATAG_REVISION, parse_tag_revision); 6981da177e4SLinus Torvalds 6991da177e4SLinus Torvalds static int __init parse_tag_cmdline(const struct tag *tag) 7001da177e4SLinus Torvalds { 7011da177e4SLinus Torvalds strlcpy(default_command_line, tag->u.cmdline.cmdline, COMMAND_LINE_SIZE); 7021da177e4SLinus Torvalds return 0; 7031da177e4SLinus Torvalds } 7041da177e4SLinus Torvalds 7051da177e4SLinus Torvalds __tagtable(ATAG_CMDLINE, parse_tag_cmdline); 7061da177e4SLinus Torvalds 7071da177e4SLinus Torvalds /* 7081da177e4SLinus Torvalds * Scan the tag table for this tag, and call its parse function. 7091da177e4SLinus Torvalds * The tag table is built by the linker from all the __tagtable 7101da177e4SLinus Torvalds * declarations. 7111da177e4SLinus Torvalds */ 7121da177e4SLinus Torvalds static int __init parse_tag(const struct tag *tag) 7131da177e4SLinus Torvalds { 7141da177e4SLinus Torvalds extern struct tagtable __tagtable_begin, __tagtable_end; 7151da177e4SLinus Torvalds struct tagtable *t; 7161da177e4SLinus Torvalds 7171da177e4SLinus Torvalds for (t = &__tagtable_begin; t < &__tagtable_end; t++) 7181da177e4SLinus Torvalds if (tag->hdr.tag == t->tag) { 7191da177e4SLinus Torvalds t->parse(tag); 7201da177e4SLinus Torvalds break; 7211da177e4SLinus Torvalds } 7221da177e4SLinus Torvalds 7231da177e4SLinus Torvalds return t < &__tagtable_end; 7241da177e4SLinus Torvalds } 7251da177e4SLinus Torvalds 7261da177e4SLinus Torvalds /* 7271da177e4SLinus Torvalds * Parse all tags in the list, checking both the global and architecture 7281da177e4SLinus Torvalds * specific tag tables. 7291da177e4SLinus Torvalds */ 7301da177e4SLinus Torvalds static void __init parse_tags(const struct tag *t) 7311da177e4SLinus Torvalds { 7321da177e4SLinus Torvalds for (; t->hdr.size; t = tag_next(t)) 7331da177e4SLinus Torvalds if (!parse_tag(t)) 7341da177e4SLinus Torvalds printk(KERN_WARNING 7351da177e4SLinus Torvalds "Ignoring unrecognised tag 0x%08x\n", 7361da177e4SLinus Torvalds t->hdr.tag); 7371da177e4SLinus Torvalds } 7381da177e4SLinus Torvalds 7391da177e4SLinus Torvalds /* 7401da177e4SLinus Torvalds * This holds our defaults. 7411da177e4SLinus Torvalds */ 7421da177e4SLinus Torvalds static struct init_tags { 7431da177e4SLinus Torvalds struct tag_header hdr1; 7441da177e4SLinus Torvalds struct tag_core core; 7451da177e4SLinus Torvalds struct tag_header hdr2; 7461da177e4SLinus Torvalds struct tag_mem32 mem; 7471da177e4SLinus Torvalds struct tag_header hdr3; 7481da177e4SLinus Torvalds } init_tags __initdata = { 7491da177e4SLinus Torvalds { tag_size(tag_core), ATAG_CORE }, 7501da177e4SLinus Torvalds { 1, PAGE_SIZE, 0xff }, 7511da177e4SLinus Torvalds { tag_size(tag_mem32), ATAG_MEM }, 7521da177e4SLinus Torvalds { MEM_SIZE, PHYS_OFFSET }, 7531da177e4SLinus Torvalds { 0, ATAG_NONE } 7541da177e4SLinus Torvalds }; 7551da177e4SLinus Torvalds 7561da177e4SLinus Torvalds static void (*init_machine)(void) __initdata; 7571da177e4SLinus Torvalds 7581da177e4SLinus Torvalds static int __init customize_machine(void) 7591da177e4SLinus Torvalds { 7601da177e4SLinus Torvalds /* customizes platform devices, or adds new ones */ 7611da177e4SLinus Torvalds if (init_machine) 7621da177e4SLinus Torvalds init_machine(); 7631da177e4SLinus Torvalds return 0; 7641da177e4SLinus Torvalds } 7651da177e4SLinus Torvalds arch_initcall(customize_machine); 7661da177e4SLinus Torvalds 7671da177e4SLinus Torvalds void __init setup_arch(char **cmdline_p) 7681da177e4SLinus Torvalds { 7691da177e4SLinus Torvalds struct tag *tags = (struct tag *)&init_tags; 7701da177e4SLinus Torvalds struct machine_desc *mdesc; 7711da177e4SLinus Torvalds char *from = default_command_line; 7721da177e4SLinus Torvalds 7731da177e4SLinus Torvalds setup_processor(); 7741da177e4SLinus Torvalds mdesc = setup_machine(machine_arch_type); 7751da177e4SLinus Torvalds machine_name = mdesc->name; 7761da177e4SLinus Torvalds 7771da177e4SLinus Torvalds if (mdesc->soft_reboot) 7781da177e4SLinus Torvalds reboot_setup("s"); 7791da177e4SLinus Torvalds 780f9bd6ea4SRussell King if (mdesc->boot_params) 781f9bd6ea4SRussell King tags = phys_to_virt(mdesc->boot_params); 7821da177e4SLinus Torvalds 7831da177e4SLinus Torvalds /* 7841da177e4SLinus Torvalds * If we have the old style parameters, convert them to 7851da177e4SLinus Torvalds * a tag list. 7861da177e4SLinus Torvalds */ 7871da177e4SLinus Torvalds if (tags->hdr.tag != ATAG_CORE) 7881da177e4SLinus Torvalds convert_to_tag_list(tags); 7891da177e4SLinus Torvalds if (tags->hdr.tag != ATAG_CORE) 7901da177e4SLinus Torvalds tags = (struct tag *)&init_tags; 7911da177e4SLinus Torvalds 7921da177e4SLinus Torvalds if (mdesc->fixup) 7931da177e4SLinus Torvalds mdesc->fixup(mdesc, tags, &from, &meminfo); 7941da177e4SLinus Torvalds 7951da177e4SLinus Torvalds if (tags->hdr.tag == ATAG_CORE) { 7961da177e4SLinus Torvalds if (meminfo.nr_banks != 0) 7971da177e4SLinus Torvalds squash_mem_tags(tags); 7981da177e4SLinus Torvalds parse_tags(tags); 7991da177e4SLinus Torvalds } 8001da177e4SLinus Torvalds 8011da177e4SLinus Torvalds init_mm.start_code = (unsigned long) &_text; 8021da177e4SLinus Torvalds init_mm.end_code = (unsigned long) &_etext; 8031da177e4SLinus Torvalds init_mm.end_data = (unsigned long) &_edata; 8041da177e4SLinus Torvalds init_mm.brk = (unsigned long) &_end; 8051da177e4SLinus Torvalds 806cd81899aSAlon Bar-Lev memcpy(boot_command_line, from, COMMAND_LINE_SIZE); 807cd81899aSAlon Bar-Lev boot_command_line[COMMAND_LINE_SIZE-1] = '\0'; 8081da177e4SLinus Torvalds parse_cmdline(cmdline_p, from); 8091da177e4SLinus Torvalds paging_init(&meminfo, mdesc); 8101da177e4SLinus Torvalds request_standard_resources(&meminfo, mdesc); 8111da177e4SLinus Torvalds 8127bbb7940SRussell King #ifdef CONFIG_SMP 8137bbb7940SRussell King smp_init_cpus(); 8147bbb7940SRussell King #endif 8157bbb7940SRussell King 816ccea7a19SRussell King cpu_init(); 817ccea7a19SRussell King 8181da177e4SLinus Torvalds /* 8191da177e4SLinus Torvalds * Set up various architecture-specific pointers 8201da177e4SLinus Torvalds */ 8211da177e4SLinus Torvalds init_arch_irq = mdesc->init_irq; 8221da177e4SLinus Torvalds system_timer = mdesc->timer; 8231da177e4SLinus Torvalds init_machine = mdesc->init_machine; 8241da177e4SLinus Torvalds 8251da177e4SLinus Torvalds #ifdef CONFIG_VT 8261da177e4SLinus Torvalds #if defined(CONFIG_VGA_CONSOLE) 8271da177e4SLinus Torvalds conswitchp = &vga_con; 8281da177e4SLinus Torvalds #elif defined(CONFIG_DUMMY_CONSOLE) 8291da177e4SLinus Torvalds conswitchp = &dummy_con; 8301da177e4SLinus Torvalds #endif 8311da177e4SLinus Torvalds #endif 8321da177e4SLinus Torvalds } 8331da177e4SLinus Torvalds 8341da177e4SLinus Torvalds 8351da177e4SLinus Torvalds static int __init topology_init(void) 8361da177e4SLinus Torvalds { 8371da177e4SLinus Torvalds int cpu; 8381da177e4SLinus Torvalds 839036999d5SKAMEZAWA Hiroyuki for_each_possible_cpu(cpu) 84076b67ed9SKAMEZAWA Hiroyuki register_cpu(&per_cpu(cpu_data, cpu).cpu, cpu); 8411da177e4SLinus Torvalds 8421da177e4SLinus Torvalds return 0; 8431da177e4SLinus Torvalds } 8441da177e4SLinus Torvalds 8451da177e4SLinus Torvalds subsys_initcall(topology_init); 8461da177e4SLinus Torvalds 8471da177e4SLinus Torvalds static const char *hwcap_str[] = { 8481da177e4SLinus Torvalds "swp", 8491da177e4SLinus Torvalds "half", 8501da177e4SLinus Torvalds "thumb", 8511da177e4SLinus Torvalds "26bit", 8521da177e4SLinus Torvalds "fastmult", 8531da177e4SLinus Torvalds "fpa", 8541da177e4SLinus Torvalds "vfp", 8551da177e4SLinus Torvalds "edsp", 8561da177e4SLinus Torvalds "java", 8578f7f9435SPaul Gortmaker "iwmmxt", 85899e4a6ddSLennert Buytenhek "crunch", 8591da177e4SLinus Torvalds NULL 8601da177e4SLinus Torvalds }; 8611da177e4SLinus Torvalds 8621da177e4SLinus Torvalds static void 8631da177e4SLinus Torvalds c_show_cache(struct seq_file *m, const char *type, unsigned int cache) 8641da177e4SLinus Torvalds { 8651da177e4SLinus Torvalds unsigned int mult = 2 + (CACHE_M(cache) ? 1 : 0); 8661da177e4SLinus Torvalds 8671da177e4SLinus Torvalds seq_printf(m, "%s size\t\t: %d\n" 8681da177e4SLinus Torvalds "%s assoc\t\t: %d\n" 8691da177e4SLinus Torvalds "%s line length\t: %d\n" 8701da177e4SLinus Torvalds "%s sets\t\t: %d\n", 8711da177e4SLinus Torvalds type, mult << (8 + CACHE_SIZE(cache)), 8721da177e4SLinus Torvalds type, (mult << CACHE_ASSOC(cache)) >> 1, 8731da177e4SLinus Torvalds type, 8 << CACHE_LINE(cache), 8741da177e4SLinus Torvalds type, 1 << (6 + CACHE_SIZE(cache) - CACHE_ASSOC(cache) - 8751da177e4SLinus Torvalds CACHE_LINE(cache))); 8761da177e4SLinus Torvalds } 8771da177e4SLinus Torvalds 8781da177e4SLinus Torvalds static int c_show(struct seq_file *m, void *v) 8791da177e4SLinus Torvalds { 8801da177e4SLinus Torvalds int i; 8811da177e4SLinus Torvalds 8821da177e4SLinus Torvalds seq_printf(m, "Processor\t: %s rev %d (%s)\n", 8831da177e4SLinus Torvalds cpu_name, (int)processor_id & 15, elf_platform); 8841da177e4SLinus Torvalds 8851da177e4SLinus Torvalds #if defined(CONFIG_SMP) 8861da177e4SLinus Torvalds for_each_online_cpu(i) { 88715559722SRussell King /* 88815559722SRussell King * glibc reads /proc/cpuinfo to determine the number of 88915559722SRussell King * online processors, looking for lines beginning with 89015559722SRussell King * "processor". Give glibc what it expects. 89115559722SRussell King */ 89215559722SRussell King seq_printf(m, "processor\t: %d\n", i); 8931da177e4SLinus Torvalds seq_printf(m, "BogoMIPS\t: %lu.%02lu\n\n", 8941da177e4SLinus Torvalds per_cpu(cpu_data, i).loops_per_jiffy / (500000UL/HZ), 8951da177e4SLinus Torvalds (per_cpu(cpu_data, i).loops_per_jiffy / (5000UL/HZ)) % 100); 8961da177e4SLinus Torvalds } 8971da177e4SLinus Torvalds #else /* CONFIG_SMP */ 8981da177e4SLinus Torvalds seq_printf(m, "BogoMIPS\t: %lu.%02lu\n", 8991da177e4SLinus Torvalds loops_per_jiffy / (500000/HZ), 9001da177e4SLinus Torvalds (loops_per_jiffy / (5000/HZ)) % 100); 9011da177e4SLinus Torvalds #endif 9021da177e4SLinus Torvalds 9031da177e4SLinus Torvalds /* dump out the processor features */ 9041da177e4SLinus Torvalds seq_puts(m, "Features\t: "); 9051da177e4SLinus Torvalds 9061da177e4SLinus Torvalds for (i = 0; hwcap_str[i]; i++) 9071da177e4SLinus Torvalds if (elf_hwcap & (1 << i)) 9081da177e4SLinus Torvalds seq_printf(m, "%s ", hwcap_str[i]); 9091da177e4SLinus Torvalds 9101da177e4SLinus Torvalds seq_printf(m, "\nCPU implementer\t: 0x%02x\n", processor_id >> 24); 9111da177e4SLinus Torvalds seq_printf(m, "CPU architecture: %s\n", proc_arch[cpu_architecture()]); 9121da177e4SLinus Torvalds 9136b090a25SCatalin Marinas if ((processor_id & 0x0008f000) == 0x00000000) { 9141da177e4SLinus Torvalds /* pre-ARM7 */ 9151da177e4SLinus Torvalds seq_printf(m, "CPU part\t\t: %07x\n", processor_id >> 4); 9161da177e4SLinus Torvalds } else { 9176b090a25SCatalin Marinas if ((processor_id & 0x0008f000) == 0x00007000) { 9181da177e4SLinus Torvalds /* ARM7 */ 9191da177e4SLinus Torvalds seq_printf(m, "CPU variant\t: 0x%02x\n", 9201da177e4SLinus Torvalds (processor_id >> 16) & 127); 9211da177e4SLinus Torvalds } else { 9221da177e4SLinus Torvalds /* post-ARM7 */ 9231da177e4SLinus Torvalds seq_printf(m, "CPU variant\t: 0x%x\n", 9241da177e4SLinus Torvalds (processor_id >> 20) & 15); 9251da177e4SLinus Torvalds } 9261da177e4SLinus Torvalds seq_printf(m, "CPU part\t: 0x%03x\n", 9271da177e4SLinus Torvalds (processor_id >> 4) & 0xfff); 9281da177e4SLinus Torvalds } 9291da177e4SLinus Torvalds seq_printf(m, "CPU revision\t: %d\n", processor_id & 15); 9301da177e4SLinus Torvalds 9311da177e4SLinus Torvalds { 9321da177e4SLinus Torvalds unsigned int cache_info = read_cpuid(CPUID_CACHETYPE); 9331da177e4SLinus Torvalds if (cache_info != processor_id) { 9341da177e4SLinus Torvalds seq_printf(m, "Cache type\t: %s\n" 9351da177e4SLinus Torvalds "Cache clean\t: %s\n" 9361da177e4SLinus Torvalds "Cache lockdown\t: %s\n" 9371da177e4SLinus Torvalds "Cache format\t: %s\n", 9381da177e4SLinus Torvalds cache_types[CACHE_TYPE(cache_info)], 9391da177e4SLinus Torvalds cache_clean[CACHE_TYPE(cache_info)], 9401da177e4SLinus Torvalds cache_lockdown[CACHE_TYPE(cache_info)], 9411da177e4SLinus Torvalds CACHE_S(cache_info) ? "Harvard" : "Unified"); 9421da177e4SLinus Torvalds 9431da177e4SLinus Torvalds if (CACHE_S(cache_info)) { 9441da177e4SLinus Torvalds c_show_cache(m, "I", CACHE_ISIZE(cache_info)); 9451da177e4SLinus Torvalds c_show_cache(m, "D", CACHE_DSIZE(cache_info)); 9461da177e4SLinus Torvalds } else { 9471da177e4SLinus Torvalds c_show_cache(m, "Cache", CACHE_ISIZE(cache_info)); 9481da177e4SLinus Torvalds } 9491da177e4SLinus Torvalds } 9501da177e4SLinus Torvalds } 9511da177e4SLinus Torvalds 9521da177e4SLinus Torvalds seq_puts(m, "\n"); 9531da177e4SLinus Torvalds 9541da177e4SLinus Torvalds seq_printf(m, "Hardware\t: %s\n", machine_name); 9551da177e4SLinus Torvalds seq_printf(m, "Revision\t: %04x\n", system_rev); 9561da177e4SLinus Torvalds seq_printf(m, "Serial\t\t: %08x%08x\n", 9571da177e4SLinus Torvalds system_serial_high, system_serial_low); 9581da177e4SLinus Torvalds 9591da177e4SLinus Torvalds return 0; 9601da177e4SLinus Torvalds } 9611da177e4SLinus Torvalds 9621da177e4SLinus Torvalds static void *c_start(struct seq_file *m, loff_t *pos) 9631da177e4SLinus Torvalds { 9641da177e4SLinus Torvalds return *pos < 1 ? (void *)1 : NULL; 9651da177e4SLinus Torvalds } 9661da177e4SLinus Torvalds 9671da177e4SLinus Torvalds static void *c_next(struct seq_file *m, void *v, loff_t *pos) 9681da177e4SLinus Torvalds { 9691da177e4SLinus Torvalds ++*pos; 9701da177e4SLinus Torvalds return NULL; 9711da177e4SLinus Torvalds } 9721da177e4SLinus Torvalds 9731da177e4SLinus Torvalds static void c_stop(struct seq_file *m, void *v) 9741da177e4SLinus Torvalds { 9751da177e4SLinus Torvalds } 9761da177e4SLinus Torvalds 9771da177e4SLinus Torvalds struct seq_operations cpuinfo_op = { 9781da177e4SLinus Torvalds .start = c_start, 9791da177e4SLinus Torvalds .next = c_next, 9801da177e4SLinus Torvalds .stop = c_stop, 9811da177e4SLinus Torvalds .show = c_show 9821da177e4SLinus Torvalds }; 983