setup.c 23 KB

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