setup.c 22 KB

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