setup.c 23 KB

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