setup.c 20 KB

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