setup.c 20 KB

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