/arch/arm/kernel/setup.c

https://bitbucket.org/thekraven/iscream_thunderc-2.6.35 · C · 997 lines · 748 code · 148 blank · 101 comment · 97 complexity · fccf8b8e52a488adb304c8c9ac346dc8 MD5 · raw file

  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/root_dev.h>
  23. #include <linux/cpu.h>
  24. #include <linux/interrupt.h>
  25. #include <linux/smp.h>
  26. #include <linux/fs.h>
  27. #include <linux/proc_fs.h>
  28. #ifdef CONFIG_MEMORY_HOTPLUG
  29. #include <linux/memory_hotplug.h>
  30. #endif
  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. #include "compat.h"
  48. #include "atags.h"
  49. #include "tcm.h"
  50. #ifndef MEM_SIZE
  51. #define MEM_SIZE (16*1024*1024)
  52. #endif
  53. #if defined(CONFIG_FPE_NWFPE) || defined(CONFIG_FPE_FASTFPE)
  54. char fpe_type[8];
  55. static int __init fpe_setup(char *line)
  56. {
  57. memcpy(fpe_type, line, 8);
  58. return 1;
  59. }
  60. __setup("fpe=", fpe_setup);
  61. #endif
  62. extern void paging_init(struct machine_desc *desc);
  63. extern void reboot_setup(char *str);
  64. unsigned int processor_id;
  65. EXPORT_SYMBOL(processor_id);
  66. unsigned int __machine_arch_type;
  67. EXPORT_SYMBOL(__machine_arch_type);
  68. unsigned int cacheid;
  69. EXPORT_SYMBOL(cacheid);
  70. unsigned int __atags_pointer __initdata;
  71. unsigned int system_rev;
  72. EXPORT_SYMBOL(system_rev);
  73. unsigned int system_serial_low;
  74. EXPORT_SYMBOL(system_serial_low);
  75. unsigned int system_serial_high;
  76. EXPORT_SYMBOL(system_serial_high);
  77. unsigned int elf_hwcap;
  78. EXPORT_SYMBOL(elf_hwcap);
  79. unsigned int boot_reason;
  80. EXPORT_SYMBOL(boot_reason);
  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 setup_processor(void)
  242. {
  243. struct proc_info_list *list;
  244. /*
  245. * locate processor in the list of supported processor
  246. * types. The linker builds this table for us from the
  247. * entries in arch/arm/mm/proc-*.S
  248. */
  249. list = lookup_processor_type(read_cpuid_id());
  250. if (!list) {
  251. printk("CPU configuration botched (ID %08x), unable "
  252. "to continue.\n", read_cpuid_id());
  253. while (1);
  254. }
  255. cpu_name = list->cpu_name;
  256. #ifdef MULTI_CPU
  257. processor = *list->proc;
  258. #endif
  259. #ifdef MULTI_TLB
  260. cpu_tlb = *list->tlb;
  261. #endif
  262. #ifdef MULTI_USER
  263. cpu_user = *list->user;
  264. #endif
  265. #ifdef MULTI_CACHE
  266. cpu_cache = *list->cache;
  267. #endif
  268. printk("CPU: %s [%08x] revision %d (ARMv%s), cr=%08lx\n",
  269. cpu_name, read_cpuid_id(), read_cpuid_id() & 15,
  270. proc_arch[cpu_architecture()], cr_alignment);
  271. sprintf(init_utsname()->machine, "%s%c", list->arch_name, ENDIANNESS);
  272. sprintf(elf_platform, "%s%c", list->elf_name, ENDIANNESS);
  273. elf_hwcap = list->elf_hwcap;
  274. #ifndef CONFIG_ARM_THUMB
  275. elf_hwcap &= ~HWCAP_THUMB;
  276. #endif
  277. cacheid_init();
  278. cpu_proc_init();
  279. }
  280. /*
  281. * cpu_init - initialise one CPU.
  282. *
  283. * cpu_init sets up the per-CPU stacks.
  284. */
  285. void cpu_init(void)
  286. {
  287. unsigned int cpu = smp_processor_id();
  288. struct stack *stk = &stacks[cpu];
  289. if (cpu >= NR_CPUS) {
  290. printk(KERN_CRIT "CPU%u: bad primary CPU number\n", cpu);
  291. BUG();
  292. }
  293. /*
  294. * Define the placement constraint for the inline asm directive below.
  295. * In Thumb-2, msr with an immediate value is not allowed.
  296. */
  297. #ifdef CONFIG_THUMB2_KERNEL
  298. #define PLC "r"
  299. #else
  300. #define PLC "I"
  301. #endif
  302. /*
  303. * setup stacks for re-entrant exception handlers
  304. */
  305. __asm__ (
  306. "msr cpsr_c, %1\n\t"
  307. "add r14, %0, %2\n\t"
  308. "mov sp, r14\n\t"
  309. "msr cpsr_c, %3\n\t"
  310. "add r14, %0, %4\n\t"
  311. "mov sp, r14\n\t"
  312. "msr cpsr_c, %5\n\t"
  313. "add r14, %0, %6\n\t"
  314. "mov sp, r14\n\t"
  315. "msr cpsr_c, %7"
  316. :
  317. : "r" (stk),
  318. PLC (PSR_F_BIT | PSR_I_BIT | IRQ_MODE),
  319. "I" (offsetof(struct stack, irq[0])),
  320. PLC (PSR_F_BIT | PSR_I_BIT | ABT_MODE),
  321. "I" (offsetof(struct stack, abt[0])),
  322. PLC (PSR_F_BIT | PSR_I_BIT | UND_MODE),
  323. "I" (offsetof(struct stack, und[0])),
  324. PLC (PSR_F_BIT | PSR_I_BIT | SVC_MODE)
  325. : "r14");
  326. }
  327. static struct machine_desc * __init setup_machine(unsigned int nr)
  328. {
  329. struct machine_desc *list;
  330. /*
  331. * locate machine in the list of supported machines.
  332. */
  333. list = lookup_machine_type(nr);
  334. if (!list) {
  335. printk("Machine configuration botched (nr %d), unable "
  336. "to continue.\n", nr);
  337. while (1);
  338. }
  339. printk("Machine: %s\n", list->name);
  340. return list;
  341. }
  342. static int __init arm_add_memory(unsigned long start, unsigned long size)
  343. {
  344. struct membank *bank = &meminfo.bank[meminfo.nr_banks];
  345. if (meminfo.nr_banks >= NR_BANKS) {
  346. printk(KERN_CRIT "NR_BANKS too low, "
  347. "ignoring memory at %#lx\n", start);
  348. return -EINVAL;
  349. }
  350. /*
  351. * Ensure that start/size are aligned to a page boundary.
  352. * Size is appropriately rounded down, start is rounded up.
  353. */
  354. size -= start & ~PAGE_MASK;
  355. bank->start = PAGE_ALIGN(start);
  356. bank->size = size & PAGE_MASK;
  357. bank->node = PHYS_TO_NID(start);
  358. /*
  359. * Check whether this memory region has non-zero size or
  360. * invalid node number.
  361. */
  362. if (bank->size == 0 || bank->node >= MAX_NUMNODES)
  363. return -EINVAL;
  364. meminfo.nr_banks++;
  365. return 0;
  366. }
  367. /*
  368. * Pick out the memory size. We look for mem=size@start,
  369. * where start and size are "size[KkMm]"
  370. */
  371. static int __init early_mem(char *p)
  372. {
  373. static int usermem __initdata = 0;
  374. unsigned long size, start;
  375. char *endp;
  376. /*
  377. * If the user specifies memory size, we
  378. * blow away any automatically generated
  379. * size.
  380. */
  381. if (usermem == 0) {
  382. usermem = 1;
  383. meminfo.nr_banks = 0;
  384. }
  385. start = PHYS_OFFSET;
  386. size = memparse(p, &endp);
  387. if (*endp == '@')
  388. start = memparse(endp + 1, NULL);
  389. arm_add_memory(start, size);
  390. return 0;
  391. }
  392. early_param("mem", early_mem);
  393. #ifdef CONFIG_MEMORY_HOTPLUG
  394. static void __init early_mem_reserved(char **p)
  395. {
  396. unsigned int start;
  397. unsigned int size;
  398. unsigned int end;
  399. unsigned int h_end;
  400. start = PHYS_OFFSET;
  401. size = memparse(*p, p);
  402. if (**p == '@')
  403. start = memparse(*p + 1, p);
  404. if (movable_reserved_start) {
  405. end = start + size;
  406. h_end = movable_reserved_start + movable_reserved_size;
  407. end = max(end, h_end);
  408. movable_reserved_start = min(movable_reserved_start,
  409. (unsigned long)start);
  410. movable_reserved_size = end - movable_reserved_start;
  411. } else {
  412. movable_reserved_start = start;
  413. movable_reserved_size = size;
  414. }
  415. }
  416. __early_param("mem_reserved=", early_mem_reserved);
  417. static void __init early_mem_low_power(char **p)
  418. {
  419. unsigned int start;
  420. unsigned int size;
  421. unsigned int end;
  422. unsigned int h_end;
  423. start = PHYS_OFFSET;
  424. size = memparse(*p, p);
  425. if (**p == '@')
  426. start = memparse(*p + 1, p);
  427. if (low_power_memory_start) {
  428. end = start + size;
  429. h_end = low_power_memory_start + low_power_memory_size;
  430. end = max(end, h_end);
  431. low_power_memory_start = min(low_power_memory_start,
  432. (unsigned long)start);
  433. low_power_memory_size = end - low_power_memory_start;
  434. } else {
  435. low_power_memory_start = start;
  436. low_power_memory_size = size;
  437. }
  438. arm_add_memory(start, size);
  439. }
  440. __early_param("mem_low_power=", early_mem_low_power);
  441. #endif
  442. static void __init
  443. setup_ramdisk(int doload, int prompt, int image_start, unsigned int rd_sz)
  444. {
  445. #ifdef CONFIG_BLK_DEV_RAM
  446. extern int rd_size, rd_image_start, rd_prompt, rd_doload;
  447. rd_image_start = image_start;
  448. rd_prompt = prompt;
  449. rd_doload = doload;
  450. if (rd_sz)
  451. rd_size = rd_sz;
  452. #endif
  453. }
  454. static void __init
  455. request_standard_resources(struct meminfo *mi, struct machine_desc *mdesc)
  456. {
  457. struct resource *res;
  458. int i;
  459. kernel_code.start = virt_to_phys(_text);
  460. kernel_code.end = virt_to_phys(_etext - 1);
  461. kernel_data.start = virt_to_phys(_data);
  462. kernel_data.end = virt_to_phys(_end - 1);
  463. for (i = 0; i < mi->nr_banks; i++) {
  464. if (mi->bank[i].size == 0)
  465. continue;
  466. res = alloc_bootmem_low(sizeof(*res));
  467. res->name = "System RAM";
  468. res->start = mi->bank[i].start;
  469. res->end = mi->bank[i].start + mi->bank[i].size - 1;
  470. res->flags = IORESOURCE_MEM | IORESOURCE_BUSY;
  471. request_resource(&iomem_resource, res);
  472. if (kernel_code.start >= res->start &&
  473. kernel_code.end <= res->end)
  474. request_resource(res, &kernel_code);
  475. if (kernel_data.start >= res->start &&
  476. kernel_data.end <= res->end)
  477. request_resource(res, &kernel_data);
  478. }
  479. if (mdesc->video_start) {
  480. video_ram.start = mdesc->video_start;
  481. video_ram.end = mdesc->video_end;
  482. request_resource(&iomem_resource, &video_ram);
  483. }
  484. /*
  485. * Some machines don't have the possibility of ever
  486. * possessing lp0, lp1 or lp2
  487. */
  488. if (mdesc->reserve_lp0)
  489. request_resource(&ioport_resource, &lp0);
  490. if (mdesc->reserve_lp1)
  491. request_resource(&ioport_resource, &lp1);
  492. if (mdesc->reserve_lp2)
  493. request_resource(&ioport_resource, &lp2);
  494. }
  495. /*
  496. * Tag parsing.
  497. *
  498. * This is the new way of passing data to the kernel at boot time. Rather
  499. * than passing a fixed inflexible structure to the kernel, we pass a list
  500. * of variable-sized tags to the kernel. The first tag must be a ATAG_CORE
  501. * tag for the list to be recognised (to distinguish the tagged list from
  502. * a param_struct). The list is terminated with a zero-length tag (this tag
  503. * is not parsed in any way).
  504. */
  505. static int __init parse_tag_core(const struct tag *tag)
  506. {
  507. if (tag->hdr.size > 2) {
  508. if ((tag->u.core.flags & 1) == 0)
  509. root_mountflags &= ~MS_RDONLY;
  510. ROOT_DEV = old_decode_dev(tag->u.core.rootdev);
  511. }
  512. return 0;
  513. }
  514. __tagtable(ATAG_CORE, parse_tag_core);
  515. static int __init parse_tag_mem32(const struct tag *tag)
  516. {
  517. return arm_add_memory(tag->u.mem.start, tag->u.mem.size);
  518. }
  519. __tagtable(ATAG_MEM, parse_tag_mem32);
  520. #ifdef CONFIG_MEMORY_HOTPLUG
  521. static int __init parse_tag_mem32_reserved(const struct tag *tag)
  522. {
  523. unsigned int start;
  524. unsigned int size;
  525. unsigned int end;
  526. unsigned int h_end;
  527. start = tag->u.mem.start;
  528. size = tag->u.mem.size;
  529. if (movable_reserved_start) {
  530. end = start + size;
  531. h_end = movable_reserved_start + movable_reserved_size;
  532. end = max(end, h_end);
  533. movable_reserved_start = min(movable_reserved_start,
  534. (unsigned long)start);
  535. movable_reserved_size = end - movable_reserved_start;
  536. } else {
  537. movable_reserved_start = tag->u.mem.start;
  538. movable_reserved_size = tag->u.mem.size;
  539. }
  540. printk(KERN_ALERT "reserved %lx at %lx for hotplug\n",
  541. movable_reserved_size, movable_reserved_start);
  542. return 0;
  543. }
  544. __tagtable(ATAG_MEM_RESERVED, parse_tag_mem32_reserved);
  545. static int __init parse_tag_mem32_low_power(const struct tag *tag)
  546. {
  547. unsigned int start;
  548. unsigned int size;
  549. unsigned int end;
  550. unsigned int h_end;
  551. start = tag->u.mem.start;
  552. size = tag->u.mem.size;
  553. if (low_power_memory_start) {
  554. end = start + size;
  555. h_end = low_power_memory_start + low_power_memory_size;
  556. end = max(end, h_end);
  557. low_power_memory_start = min(low_power_memory_start,
  558. (unsigned long)start);
  559. low_power_memory_size = end - low_power_memory_start;
  560. } else {
  561. low_power_memory_start = tag->u.mem.start;
  562. low_power_memory_size = tag->u.mem.size;
  563. }
  564. printk(KERN_ALERT "low power memory %lx at %lx\n",
  565. low_power_memory_size, low_power_memory_start);
  566. return arm_add_memory(tag->u.mem.start, tag->u.mem.size);
  567. }
  568. __tagtable(ATAG_MEM_LOW_POWER, parse_tag_mem32_low_power);
  569. #endif
  570. #if defined(CONFIG_VGA_CONSOLE) || defined(CONFIG_DUMMY_CONSOLE)
  571. struct screen_info screen_info = {
  572. .orig_video_lines = 30,
  573. .orig_video_cols = 80,
  574. .orig_video_mode = 0,
  575. .orig_video_ega_bx = 0,
  576. .orig_video_isVGA = 1,
  577. .orig_video_points = 8
  578. };
  579. static int __init parse_tag_videotext(const struct tag *tag)
  580. {
  581. screen_info.orig_x = tag->u.videotext.x;
  582. screen_info.orig_y = tag->u.videotext.y;
  583. screen_info.orig_video_page = tag->u.videotext.video_page;
  584. screen_info.orig_video_mode = tag->u.videotext.video_mode;
  585. screen_info.orig_video_cols = tag->u.videotext.video_cols;
  586. screen_info.orig_video_ega_bx = tag->u.videotext.video_ega_bx;
  587. screen_info.orig_video_lines = tag->u.videotext.video_lines;
  588. screen_info.orig_video_isVGA = tag->u.videotext.video_isvga;
  589. screen_info.orig_video_points = tag->u.videotext.video_points;
  590. return 0;
  591. }
  592. __tagtable(ATAG_VIDEOTEXT, parse_tag_videotext);
  593. #endif
  594. static int __init parse_tag_ramdisk(const struct tag *tag)
  595. {
  596. setup_ramdisk((tag->u.ramdisk.flags & 1) == 0,
  597. (tag->u.ramdisk.flags & 2) == 0,
  598. tag->u.ramdisk.start, tag->u.ramdisk.size);
  599. return 0;
  600. }
  601. __tagtable(ATAG_RAMDISK, parse_tag_ramdisk);
  602. static int __init parse_tag_serialnr(const struct tag *tag)
  603. {
  604. system_serial_low = tag->u.serialnr.low;
  605. system_serial_high = tag->u.serialnr.high;
  606. return 0;
  607. }
  608. __tagtable(ATAG_SERIAL, parse_tag_serialnr);
  609. static int __init parse_tag_revision(const struct tag *tag)
  610. {
  611. system_rev = tag->u.revision.rev;
  612. return 0;
  613. }
  614. __tagtable(ATAG_REVISION, parse_tag_revision);
  615. #ifndef CONFIG_CMDLINE_FORCE
  616. static int __init parse_tag_cmdline(const struct tag *tag)
  617. {
  618. strlcpy(default_command_line, tag->u.cmdline.cmdline, COMMAND_LINE_SIZE);
  619. return 0;
  620. }
  621. __tagtable(ATAG_CMDLINE, parse_tag_cmdline);
  622. #endif /* CONFIG_CMDLINE_FORCE */
  623. /*
  624. * Scan the tag table for this tag, and call its parse function.
  625. * The tag table is built by the linker from all the __tagtable
  626. * declarations.
  627. */
  628. static int __init parse_tag(const struct tag *tag)
  629. {
  630. extern struct tagtable __tagtable_begin, __tagtable_end;
  631. struct tagtable *t;
  632. for (t = &__tagtable_begin; t < &__tagtable_end; t++)
  633. if (tag->hdr.tag == t->tag) {
  634. t->parse(tag);
  635. break;
  636. }
  637. return t < &__tagtable_end;
  638. }
  639. /*
  640. * Parse all tags in the list, checking both the global and architecture
  641. * specific tag tables.
  642. */
  643. static void __init parse_tags(const struct tag *t)
  644. {
  645. for (; t->hdr.size; t = tag_next(t))
  646. if (!parse_tag(t))
  647. printk(KERN_WARNING
  648. "Ignoring unrecognised tag 0x%08x\n",
  649. t->hdr.tag);
  650. }
  651. /*
  652. * This holds our defaults.
  653. */
  654. static struct init_tags {
  655. struct tag_header hdr1;
  656. struct tag_core core;
  657. struct tag_header hdr2;
  658. struct tag_mem32 mem;
  659. struct tag_header hdr3;
  660. } init_tags __initdata = {
  661. { tag_size(tag_core), ATAG_CORE },
  662. { 1, PAGE_SIZE, 0xff },
  663. { tag_size(tag_mem32), ATAG_MEM },
  664. { MEM_SIZE, PHYS_OFFSET },
  665. { 0, ATAG_NONE }
  666. };
  667. static void (*init_machine)(void) __initdata;
  668. static int __init customize_machine(void)
  669. {
  670. /* customizes platform devices, or adds new ones */
  671. if (init_machine)
  672. init_machine();
  673. return 0;
  674. }
  675. arch_initcall(customize_machine);
  676. void __init setup_arch(char **cmdline_p)
  677. {
  678. struct tag *tags = (struct tag *)&init_tags;
  679. struct machine_desc *mdesc;
  680. char *from = default_command_line;
  681. unwind_init();
  682. setup_processor();
  683. mdesc = setup_machine(machine_arch_type);
  684. machine_name = mdesc->name;
  685. if (mdesc->soft_reboot)
  686. reboot_setup("s");
  687. if (__atags_pointer)
  688. tags = phys_to_virt(__atags_pointer);
  689. else if (mdesc->boot_params)
  690. tags = phys_to_virt(mdesc->boot_params);
  691. /*
  692. * If we have the old style parameters, convert them to
  693. * a tag list.
  694. */
  695. if (tags->hdr.tag != ATAG_CORE)
  696. convert_to_tag_list(tags);
  697. if (tags->hdr.tag != ATAG_CORE)
  698. tags = (struct tag *)&init_tags;
  699. if (mdesc->fixup)
  700. mdesc->fixup(mdesc, tags, &from, &meminfo);
  701. if (tags->hdr.tag == ATAG_CORE) {
  702. if (meminfo.nr_banks != 0)
  703. squash_mem_tags(tags);
  704. save_atags(tags);
  705. parse_tags(tags);
  706. }
  707. init_mm.start_code = (unsigned long) _text;
  708. init_mm.end_code = (unsigned long) _etext;
  709. init_mm.end_data = (unsigned long) _edata;
  710. init_mm.brk = (unsigned long) _end;
  711. /* parse_early_param needs a boot_command_line */
  712. strlcpy(boot_command_line, from, COMMAND_LINE_SIZE);
  713. /* populate cmd_line too for later use, preserving boot_command_line */
  714. strlcpy(cmd_line, boot_command_line, COMMAND_LINE_SIZE);
  715. *cmdline_p = cmd_line;
  716. parse_early_param();
  717. paging_init(mdesc);
  718. request_standard_resources(&meminfo, mdesc);
  719. #ifdef CONFIG_SMP
  720. smp_init_cpus();
  721. #endif
  722. cpu_init();
  723. tcm_init();
  724. /*
  725. * Set up various architecture-specific pointers
  726. */
  727. init_arch_irq = mdesc->init_irq;
  728. system_timer = mdesc->timer;
  729. init_machine = mdesc->init_machine;
  730. #ifdef CONFIG_VT
  731. #if defined(CONFIG_VGA_CONSOLE)
  732. conswitchp = &vga_con;
  733. #elif defined(CONFIG_DUMMY_CONSOLE)
  734. conswitchp = &dummy_con;
  735. #endif
  736. #endif
  737. early_trap_init();
  738. }
  739. static int __init topology_init(void)
  740. {
  741. int cpu;
  742. for_each_possible_cpu(cpu) {
  743. struct cpuinfo_arm *cpuinfo = &per_cpu(cpu_data, cpu);
  744. cpuinfo->cpu.hotpluggable = 1;
  745. register_cpu(&cpuinfo->cpu, cpu);
  746. }
  747. return 0;
  748. }
  749. subsys_initcall(topology_init);
  750. #ifdef CONFIG_HAVE_PROC_CPU
  751. static int __init proc_cpu_init(void)
  752. {
  753. struct proc_dir_entry *res;
  754. res = proc_mkdir("cpu", NULL);
  755. if (!res)
  756. return -ENOMEM;
  757. return 0;
  758. }
  759. fs_initcall(proc_cpu_init);
  760. #endif
  761. static const char *hwcap_str[] = {
  762. "swp",
  763. "half",
  764. "thumb",
  765. "26bit",
  766. "fastmult",
  767. "fpa",
  768. "vfp",
  769. "edsp",
  770. "java",
  771. "iwmmxt",
  772. "crunch",
  773. "thumbee",
  774. "neon",
  775. "vfpv3",
  776. "vfpv3d16",
  777. NULL
  778. };
  779. static int c_show(struct seq_file *m, void *v)
  780. {
  781. int i;
  782. seq_printf(m, "Processor\t: %s rev %d (%s)\n",
  783. cpu_name, read_cpuid_id() & 15, elf_platform);
  784. #if defined(CONFIG_SMP)
  785. for_each_online_cpu(i) {
  786. /*
  787. * glibc reads /proc/cpuinfo to determine the number of
  788. * online processors, looking for lines beginning with
  789. * "processor". Give glibc what it expects.
  790. */
  791. seq_printf(m, "processor\t: %d\n", i);
  792. seq_printf(m, "BogoMIPS\t: %lu.%02lu\n\n",
  793. per_cpu(cpu_data, i).loops_per_jiffy / (500000UL/HZ),
  794. (per_cpu(cpu_data, i).loops_per_jiffy / (5000UL/HZ)) % 100);
  795. }
  796. #else /* CONFIG_SMP */
  797. seq_printf(m, "BogoMIPS\t: %lu.%02lu\n",
  798. loops_per_jiffy / (500000/HZ),
  799. (loops_per_jiffy / (5000/HZ)) % 100);
  800. #endif
  801. /* dump out the processor features */
  802. seq_puts(m, "Features\t: ");
  803. for (i = 0; hwcap_str[i]; i++)
  804. if (elf_hwcap & (1 << i))
  805. seq_printf(m, "%s ", hwcap_str[i]);
  806. seq_printf(m, "\nCPU implementer\t: 0x%02x\n", read_cpuid_id() >> 24);
  807. seq_printf(m, "CPU architecture: %s\n", proc_arch[cpu_architecture()]);
  808. if ((read_cpuid_id() & 0x0008f000) == 0x00000000) {
  809. /* pre-ARM7 */
  810. seq_printf(m, "CPU part\t: %07x\n", read_cpuid_id() >> 4);
  811. } else {
  812. if ((read_cpuid_id() & 0x0008f000) == 0x00007000) {
  813. /* ARM7 */
  814. seq_printf(m, "CPU variant\t: 0x%02x\n",
  815. (read_cpuid_id() >> 16) & 127);
  816. } else {
  817. /* post-ARM7 */
  818. seq_printf(m, "CPU variant\t: 0x%x\n",
  819. (read_cpuid_id() >> 20) & 15);
  820. }
  821. seq_printf(m, "CPU part\t: 0x%03x\n",
  822. (read_cpuid_id() >> 4) & 0xfff);
  823. }
  824. seq_printf(m, "CPU revision\t: %d\n", read_cpuid_id() & 15);
  825. seq_puts(m, "\n");
  826. seq_printf(m, "Hardware\t: %s\n", machine_name);
  827. seq_printf(m, "Revision\t: %04x\n", system_rev);
  828. seq_printf(m, "Serial\t\t: %08x%08x\n",
  829. system_serial_high, system_serial_low);
  830. return 0;
  831. }
  832. static void *c_start(struct seq_file *m, loff_t *pos)
  833. {
  834. return *pos < 1 ? (void *)1 : NULL;
  835. }
  836. static void *c_next(struct seq_file *m, void *v, loff_t *pos)
  837. {
  838. ++*pos;
  839. return NULL;
  840. }
  841. static void c_stop(struct seq_file *m, void *v)
  842. {
  843. }
  844. const struct seq_operations cpuinfo_op = {
  845. .start = c_start,
  846. .next = c_next,
  847. .stop = c_stop,
  848. .show = c_show
  849. };