setup.c 22 KB

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