setup.c 22 KB

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