setup.c 25 KB

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