setup.c 19 KB

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