setup.c 20 KB

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