setup.c 25 KB

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