setup.c 20 KB

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