setup.c 20 KB

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