setup.c 31 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171
  1. /*
  2. * arch/blackfin/kernel/setup.c
  3. *
  4. * Copyright 2004-2006 Analog Devices Inc.
  5. *
  6. * Enter bugs at http://blackfin.uclinux.org/
  7. *
  8. * Licensed under the GPL-2 or later.
  9. */
  10. #include <linux/delay.h>
  11. #include <linux/console.h>
  12. #include <linux/bootmem.h>
  13. #include <linux/seq_file.h>
  14. #include <linux/cpu.h>
  15. #include <linux/module.h>
  16. #include <linux/tty.h>
  17. #include <linux/pfn.h>
  18. #include <linux/ext2_fs.h>
  19. #include <linux/cramfs_fs.h>
  20. #include <linux/romfs_fs.h>
  21. #include <asm/cplb.h>
  22. #include <asm/cacheflush.h>
  23. #include <asm/blackfin.h>
  24. #include <asm/cplbinit.h>
  25. #include <asm/div64.h>
  26. #include <asm/fixed_code.h>
  27. #include <asm/early_printk.h>
  28. static DEFINE_PER_CPU(struct cpu, cpu_devices);
  29. u16 _bfin_swrst;
  30. EXPORT_SYMBOL(_bfin_swrst);
  31. unsigned long memory_start, memory_end, physical_mem_end;
  32. unsigned long _rambase, _ramstart, _ramend;
  33. unsigned long reserved_mem_dcache_on;
  34. unsigned long reserved_mem_icache_on;
  35. EXPORT_SYMBOL(memory_start);
  36. EXPORT_SYMBOL(memory_end);
  37. EXPORT_SYMBOL(physical_mem_end);
  38. EXPORT_SYMBOL(_ramend);
  39. #ifdef CONFIG_MTD_UCLINUX
  40. unsigned long memory_mtd_end, memory_mtd_start, mtd_size;
  41. unsigned long _ebss;
  42. EXPORT_SYMBOL(memory_mtd_end);
  43. EXPORT_SYMBOL(memory_mtd_start);
  44. EXPORT_SYMBOL(mtd_size);
  45. #endif
  46. char __initdata command_line[COMMAND_LINE_SIZE];
  47. void __initdata *init_retx, *init_saved_retx, *init_saved_seqstat,
  48. *init_saved_icplb_fault_addr, *init_saved_dcplb_fault_addr;
  49. /* boot memmap, for parsing "memmap=" */
  50. #define BFIN_MEMMAP_MAX 128 /* number of entries in bfin_memmap */
  51. #define BFIN_MEMMAP_RAM 1
  52. #define BFIN_MEMMAP_RESERVED 2
  53. struct bfin_memmap {
  54. int nr_map;
  55. struct bfin_memmap_entry {
  56. unsigned long long addr; /* start of memory segment */
  57. unsigned long long size;
  58. unsigned long type;
  59. } map[BFIN_MEMMAP_MAX];
  60. } bfin_memmap __initdata;
  61. /* for memmap sanitization */
  62. struct change_member {
  63. struct bfin_memmap_entry *pentry; /* pointer to original entry */
  64. unsigned long long addr; /* address for this change point */
  65. };
  66. static struct change_member change_point_list[2*BFIN_MEMMAP_MAX] __initdata;
  67. static struct change_member *change_point[2*BFIN_MEMMAP_MAX] __initdata;
  68. static struct bfin_memmap_entry *overlap_list[BFIN_MEMMAP_MAX] __initdata;
  69. static struct bfin_memmap_entry new_map[BFIN_MEMMAP_MAX] __initdata;
  70. void __init bfin_cache_init(void)
  71. {
  72. #if defined(CONFIG_BFIN_DCACHE) || defined(CONFIG_BFIN_ICACHE)
  73. generate_cplb_tables();
  74. #endif
  75. #ifdef CONFIG_BFIN_ICACHE
  76. bfin_icache_init();
  77. printk(KERN_INFO "Instruction Cache Enabled\n");
  78. #endif
  79. #ifdef CONFIG_BFIN_DCACHE
  80. bfin_dcache_init();
  81. printk(KERN_INFO "Data Cache Enabled"
  82. # if defined CONFIG_BFIN_WB
  83. " (write-back)"
  84. # elif defined CONFIG_BFIN_WT
  85. " (write-through)"
  86. # endif
  87. "\n");
  88. #endif
  89. }
  90. void __init bfin_relocate_l1_mem(void)
  91. {
  92. unsigned long l1_code_length;
  93. unsigned long l1_data_a_length;
  94. unsigned long l1_data_b_length;
  95. unsigned long l2_length;
  96. l1_code_length = _etext_l1 - _stext_l1;
  97. if (l1_code_length > L1_CODE_LENGTH)
  98. panic("L1 Instruction SRAM Overflow\n");
  99. /* cannot complain as printk is not available as yet.
  100. * But we can continue booting and complain later!
  101. */
  102. /* Copy _stext_l1 to _etext_l1 to L1 instruction SRAM */
  103. dma_memcpy(_stext_l1, _l1_lma_start, l1_code_length);
  104. l1_data_a_length = _ebss_l1 - _sdata_l1;
  105. if (l1_data_a_length > L1_DATA_A_LENGTH)
  106. panic("L1 Data SRAM Bank A Overflow\n");
  107. /* Copy _sdata_l1 to _ebss_l1 to L1 data bank A SRAM */
  108. dma_memcpy(_sdata_l1, _l1_lma_start + l1_code_length, l1_data_a_length);
  109. l1_data_b_length = _ebss_b_l1 - _sdata_b_l1;
  110. if (l1_data_b_length > L1_DATA_B_LENGTH)
  111. panic("L1 Data SRAM Bank B Overflow\n");
  112. /* Copy _sdata_b_l1 to _ebss_b_l1 to L1 data bank B SRAM */
  113. dma_memcpy(_sdata_b_l1, _l1_lma_start + l1_code_length +
  114. l1_data_a_length, l1_data_b_length);
  115. if (L2_LENGTH != 0) {
  116. l2_length = _ebss_l2 - _stext_l2;
  117. if (l2_length > L2_LENGTH)
  118. panic("L2 SRAM Overflow\n");
  119. /* Copy _stext_l2 to _edata_l2 to L2 SRAM */
  120. dma_memcpy(_stext_l2, _l2_lma_start, l2_length);
  121. }
  122. }
  123. /* add_memory_region to memmap */
  124. static void __init add_memory_region(unsigned long long start,
  125. unsigned long long size, int type)
  126. {
  127. int i;
  128. i = bfin_memmap.nr_map;
  129. if (i == BFIN_MEMMAP_MAX) {
  130. printk(KERN_ERR "Ooops! Too many entries in the memory map!\n");
  131. return;
  132. }
  133. bfin_memmap.map[i].addr = start;
  134. bfin_memmap.map[i].size = size;
  135. bfin_memmap.map[i].type = type;
  136. bfin_memmap.nr_map++;
  137. }
  138. /*
  139. * Sanitize the boot memmap, removing overlaps.
  140. */
  141. static int __init sanitize_memmap(struct bfin_memmap_entry *map, int *pnr_map)
  142. {
  143. struct change_member *change_tmp;
  144. unsigned long current_type, last_type;
  145. unsigned long long last_addr;
  146. int chgidx, still_changing;
  147. int overlap_entries;
  148. int new_entry;
  149. int old_nr, new_nr, chg_nr;
  150. int i;
  151. /*
  152. Visually we're performing the following (1,2,3,4 = memory types)
  153. Sample memory map (w/overlaps):
  154. ____22__________________
  155. ______________________4_
  156. ____1111________________
  157. _44_____________________
  158. 11111111________________
  159. ____________________33__
  160. ___________44___________
  161. __________33333_________
  162. ______________22________
  163. ___________________2222_
  164. _________111111111______
  165. _____________________11_
  166. _________________4______
  167. Sanitized equivalent (no overlap):
  168. 1_______________________
  169. _44_____________________
  170. ___1____________________
  171. ____22__________________
  172. ______11________________
  173. _________1______________
  174. __________3_____________
  175. ___________44___________
  176. _____________33_________
  177. _______________2________
  178. ________________1_______
  179. _________________4______
  180. ___________________2____
  181. ____________________33__
  182. ______________________4_
  183. */
  184. /* if there's only one memory region, don't bother */
  185. if (*pnr_map < 2)
  186. return -1;
  187. old_nr = *pnr_map;
  188. /* bail out if we find any unreasonable addresses in memmap */
  189. for (i = 0; i < old_nr; i++)
  190. if (map[i].addr + map[i].size < map[i].addr)
  191. return -1;
  192. /* create pointers for initial change-point information (for sorting) */
  193. for (i = 0; i < 2*old_nr; i++)
  194. change_point[i] = &change_point_list[i];
  195. /* record all known change-points (starting and ending addresses),
  196. omitting those that are for empty memory regions */
  197. chgidx = 0;
  198. for (i = 0; i < old_nr; i++) {
  199. if (map[i].size != 0) {
  200. change_point[chgidx]->addr = map[i].addr;
  201. change_point[chgidx++]->pentry = &map[i];
  202. change_point[chgidx]->addr = map[i].addr + map[i].size;
  203. change_point[chgidx++]->pentry = &map[i];
  204. }
  205. }
  206. chg_nr = chgidx; /* true number of change-points */
  207. /* sort change-point list by memory addresses (low -> high) */
  208. still_changing = 1;
  209. while (still_changing) {
  210. still_changing = 0;
  211. for (i = 1; i < chg_nr; i++) {
  212. /* if <current_addr> > <last_addr>, swap */
  213. /* or, if current=<start_addr> & last=<end_addr>, swap */
  214. if ((change_point[i]->addr < change_point[i-1]->addr) ||
  215. ((change_point[i]->addr == change_point[i-1]->addr) &&
  216. (change_point[i]->addr == change_point[i]->pentry->addr) &&
  217. (change_point[i-1]->addr != change_point[i-1]->pentry->addr))
  218. ) {
  219. change_tmp = change_point[i];
  220. change_point[i] = change_point[i-1];
  221. change_point[i-1] = change_tmp;
  222. still_changing = 1;
  223. }
  224. }
  225. }
  226. /* create a new memmap, removing overlaps */
  227. overlap_entries = 0; /* number of entries in the overlap table */
  228. new_entry = 0; /* index for creating new memmap entries */
  229. last_type = 0; /* start with undefined memory type */
  230. last_addr = 0; /* start with 0 as last starting address */
  231. /* loop through change-points, determining affect on the new memmap */
  232. for (chgidx = 0; chgidx < chg_nr; chgidx++) {
  233. /* keep track of all overlapping memmap entries */
  234. if (change_point[chgidx]->addr == change_point[chgidx]->pentry->addr) {
  235. /* add map entry to overlap list (> 1 entry implies an overlap) */
  236. overlap_list[overlap_entries++] = change_point[chgidx]->pentry;
  237. } else {
  238. /* remove entry from list (order independent, so swap with last) */
  239. for (i = 0; i < overlap_entries; i++) {
  240. if (overlap_list[i] == change_point[chgidx]->pentry)
  241. overlap_list[i] = overlap_list[overlap_entries-1];
  242. }
  243. overlap_entries--;
  244. }
  245. /* if there are overlapping entries, decide which "type" to use */
  246. /* (larger value takes precedence -- 1=usable, 2,3,4,4+=unusable) */
  247. current_type = 0;
  248. for (i = 0; i < overlap_entries; i++)
  249. if (overlap_list[i]->type > current_type)
  250. current_type = overlap_list[i]->type;
  251. /* continue building up new memmap based on this information */
  252. if (current_type != last_type) {
  253. if (last_type != 0) {
  254. new_map[new_entry].size =
  255. change_point[chgidx]->addr - last_addr;
  256. /* move forward only if the new size was non-zero */
  257. if (new_map[new_entry].size != 0)
  258. if (++new_entry >= BFIN_MEMMAP_MAX)
  259. break; /* no more space left for new entries */
  260. }
  261. if (current_type != 0) {
  262. new_map[new_entry].addr = change_point[chgidx]->addr;
  263. new_map[new_entry].type = current_type;
  264. last_addr = change_point[chgidx]->addr;
  265. }
  266. last_type = current_type;
  267. }
  268. }
  269. new_nr = new_entry; /* retain count for new entries */
  270. /* copy new mapping into original location */
  271. memcpy(map, new_map, new_nr*sizeof(struct bfin_memmap_entry));
  272. *pnr_map = new_nr;
  273. return 0;
  274. }
  275. static void __init print_memory_map(char *who)
  276. {
  277. int i;
  278. for (i = 0; i < bfin_memmap.nr_map; i++) {
  279. printk(KERN_DEBUG " %s: %016Lx - %016Lx ", who,
  280. bfin_memmap.map[i].addr,
  281. bfin_memmap.map[i].addr + bfin_memmap.map[i].size);
  282. switch (bfin_memmap.map[i].type) {
  283. case BFIN_MEMMAP_RAM:
  284. printk("(usable)\n");
  285. break;
  286. case BFIN_MEMMAP_RESERVED:
  287. printk("(reserved)\n");
  288. break;
  289. default: printk("type %lu\n", bfin_memmap.map[i].type);
  290. break;
  291. }
  292. }
  293. }
  294. static __init int parse_memmap(char *arg)
  295. {
  296. unsigned long long start_at, mem_size;
  297. if (!arg)
  298. return -EINVAL;
  299. mem_size = memparse(arg, &arg);
  300. if (*arg == '@') {
  301. start_at = memparse(arg+1, &arg);
  302. add_memory_region(start_at, mem_size, BFIN_MEMMAP_RAM);
  303. } else if (*arg == '$') {
  304. start_at = memparse(arg+1, &arg);
  305. add_memory_region(start_at, mem_size, BFIN_MEMMAP_RESERVED);
  306. }
  307. return 0;
  308. }
  309. /*
  310. * Initial parsing of the command line. Currently, we support:
  311. * - Controlling the linux memory size: mem=xxx[KMG]
  312. * - Controlling the physical memory size: max_mem=xxx[KMG][$][#]
  313. * $ -> reserved memory is dcacheable
  314. * # -> reserved memory is icacheable
  315. * - "memmap=XXX[KkmM][@][$]XXX[KkmM]" defines a memory region
  316. * @ from <start> to <start>+<mem>, type RAM
  317. * $ from <start> to <start>+<mem>, type RESERVED
  318. *
  319. */
  320. static __init void parse_cmdline_early(char *cmdline_p)
  321. {
  322. char c = ' ', *to = cmdline_p;
  323. unsigned int memsize;
  324. for (;;) {
  325. if (c == ' ') {
  326. if (!memcmp(to, "mem=", 4)) {
  327. to += 4;
  328. memsize = memparse(to, &to);
  329. if (memsize)
  330. _ramend = memsize;
  331. } else if (!memcmp(to, "max_mem=", 8)) {
  332. to += 8;
  333. memsize = memparse(to, &to);
  334. if (memsize) {
  335. physical_mem_end = memsize;
  336. if (*to != ' ') {
  337. if (*to == '$'
  338. || *(to + 1) == '$')
  339. reserved_mem_dcache_on =
  340. 1;
  341. if (*to == '#'
  342. || *(to + 1) == '#')
  343. reserved_mem_icache_on =
  344. 1;
  345. }
  346. }
  347. } else if (!memcmp(to, "earlyprintk=", 12)) {
  348. to += 12;
  349. setup_early_printk(to);
  350. } else if (!memcmp(to, "memmap=", 7)) {
  351. to += 7;
  352. parse_memmap(to);
  353. }
  354. }
  355. c = *(to++);
  356. if (!c)
  357. break;
  358. }
  359. }
  360. /*
  361. * Setup memory defaults from user config.
  362. * The physical memory layout looks like:
  363. *
  364. * [_rambase, _ramstart]: kernel image
  365. * [memory_start, memory_end]: dynamic memory managed by kernel
  366. * [memory_end, _ramend]: reserved memory
  367. * [meory_mtd_start(memory_end),
  368. * memory_mtd_start + mtd_size]: rootfs (if any)
  369. * [_ramend - DMA_UNCACHED_REGION,
  370. * _ramend]: uncached DMA region
  371. * [_ramend, physical_mem_end]: memory not managed by kernel
  372. *
  373. */
  374. static __init void memory_setup(void)
  375. {
  376. #ifdef CONFIG_MTD_UCLINUX
  377. unsigned long mtd_phys = 0;
  378. #endif
  379. _rambase = (unsigned long)_stext;
  380. _ramstart = (unsigned long)_end;
  381. if (DMA_UNCACHED_REGION > (_ramend - _ramstart)) {
  382. console_init();
  383. panic("DMA region exceeds memory limit: %lu.\n",
  384. _ramend - _ramstart);
  385. }
  386. memory_end = _ramend - DMA_UNCACHED_REGION;
  387. #ifdef CONFIG_MPU
  388. /* Round up to multiple of 4MB. */
  389. memory_start = (_ramstart + 0x3fffff) & ~0x3fffff;
  390. #else
  391. memory_start = PAGE_ALIGN(_ramstart);
  392. #endif
  393. #if defined(CONFIG_MTD_UCLINUX)
  394. /* generic memory mapped MTD driver */
  395. memory_mtd_end = memory_end;
  396. mtd_phys = _ramstart;
  397. mtd_size = PAGE_ALIGN(*((unsigned long *)(mtd_phys + 8)));
  398. # if defined(CONFIG_EXT2_FS) || defined(CONFIG_EXT3_FS)
  399. if (*((unsigned short *)(mtd_phys + 0x438)) == EXT2_SUPER_MAGIC)
  400. mtd_size =
  401. PAGE_ALIGN(*((unsigned long *)(mtd_phys + 0x404)) << 10);
  402. # endif
  403. # if defined(CONFIG_CRAMFS)
  404. if (*((unsigned long *)(mtd_phys)) == CRAMFS_MAGIC)
  405. mtd_size = PAGE_ALIGN(*((unsigned long *)(mtd_phys + 0x4)));
  406. # endif
  407. # if defined(CONFIG_ROMFS_FS)
  408. if (((unsigned long *)mtd_phys)[0] == ROMSB_WORD0
  409. && ((unsigned long *)mtd_phys)[1] == ROMSB_WORD1)
  410. mtd_size =
  411. PAGE_ALIGN(be32_to_cpu(((unsigned long *)mtd_phys)[2]));
  412. # if (defined(CONFIG_BFIN_ICACHE) && ANOMALY_05000263)
  413. /* Due to a Hardware Anomaly we need to limit the size of usable
  414. * instruction memory to max 60MB, 56 if HUNT_FOR_ZERO is on
  415. * 05000263 - Hardware loop corrupted when taking an ICPLB exception
  416. */
  417. # if (defined(CONFIG_DEBUG_HUNT_FOR_ZERO))
  418. if (memory_end >= 56 * 1024 * 1024)
  419. memory_end = 56 * 1024 * 1024;
  420. # else
  421. if (memory_end >= 60 * 1024 * 1024)
  422. memory_end = 60 * 1024 * 1024;
  423. # endif /* CONFIG_DEBUG_HUNT_FOR_ZERO */
  424. # endif /* ANOMALY_05000263 */
  425. # endif /* CONFIG_ROMFS_FS */
  426. memory_end -= mtd_size;
  427. if (mtd_size == 0) {
  428. console_init();
  429. panic("Don't boot kernel without rootfs attached.\n");
  430. }
  431. /* Relocate MTD image to the top of memory after the uncached memory area */
  432. dma_memcpy((char *)memory_end, _end, mtd_size);
  433. memory_mtd_start = memory_end;
  434. _ebss = memory_mtd_start; /* define _ebss for compatible */
  435. #endif /* CONFIG_MTD_UCLINUX */
  436. #if (defined(CONFIG_BFIN_ICACHE) && ANOMALY_05000263)
  437. /* Due to a Hardware Anomaly we need to limit the size of usable
  438. * instruction memory to max 60MB, 56 if HUNT_FOR_ZERO is on
  439. * 05000263 - Hardware loop corrupted when taking an ICPLB exception
  440. */
  441. #if (defined(CONFIG_DEBUG_HUNT_FOR_ZERO))
  442. if (memory_end >= 56 * 1024 * 1024)
  443. memory_end = 56 * 1024 * 1024;
  444. #else
  445. if (memory_end >= 60 * 1024 * 1024)
  446. memory_end = 60 * 1024 * 1024;
  447. #endif /* CONFIG_DEBUG_HUNT_FOR_ZERO */
  448. printk(KERN_NOTICE "Warning: limiting memory to %liMB due to hardware anomaly 05000263\n", memory_end >> 20);
  449. #endif /* ANOMALY_05000263 */
  450. #ifdef CONFIG_MPU
  451. page_mask_nelts = ((_ramend >> PAGE_SHIFT) + 31) / 32;
  452. page_mask_order = get_order(3 * page_mask_nelts * sizeof(long));
  453. #endif
  454. #if !defined(CONFIG_MTD_UCLINUX)
  455. /*In case there is no valid CPLB behind memory_end make sure we don't get to close*/
  456. memory_end -= SIZE_4K;
  457. #endif
  458. init_mm.start_code = (unsigned long)_stext;
  459. init_mm.end_code = (unsigned long)_etext;
  460. init_mm.end_data = (unsigned long)_edata;
  461. init_mm.brk = (unsigned long)0;
  462. printk(KERN_INFO "Board Memory: %ldMB\n", physical_mem_end >> 20);
  463. printk(KERN_INFO "Kernel Managed Memory: %ldMB\n", _ramend >> 20);
  464. printk(KERN_INFO "Memory map:\n"
  465. KERN_INFO " fixedcode = 0x%p-0x%p\n"
  466. KERN_INFO " text = 0x%p-0x%p\n"
  467. KERN_INFO " rodata = 0x%p-0x%p\n"
  468. KERN_INFO " bss = 0x%p-0x%p\n"
  469. KERN_INFO " data = 0x%p-0x%p\n"
  470. KERN_INFO " stack = 0x%p-0x%p\n"
  471. KERN_INFO " init = 0x%p-0x%p\n"
  472. KERN_INFO " available = 0x%p-0x%p\n"
  473. #ifdef CONFIG_MTD_UCLINUX
  474. KERN_INFO " rootfs = 0x%p-0x%p\n"
  475. #endif
  476. #if DMA_UNCACHED_REGION > 0
  477. KERN_INFO " DMA Zone = 0x%p-0x%p\n"
  478. #endif
  479. , (void *)FIXED_CODE_START, (void *)FIXED_CODE_END,
  480. _stext, _etext,
  481. __start_rodata, __end_rodata,
  482. __bss_start, __bss_stop,
  483. _sdata, _edata,
  484. (void *)&init_thread_union,
  485. (void *)((int)(&init_thread_union) + 0x2000),
  486. __init_begin, __init_end,
  487. (void *)_ramstart, (void *)memory_end
  488. #ifdef CONFIG_MTD_UCLINUX
  489. , (void *)memory_mtd_start, (void *)(memory_mtd_start + mtd_size)
  490. #endif
  491. #if DMA_UNCACHED_REGION > 0
  492. , (void *)(_ramend - DMA_UNCACHED_REGION), (void *)(_ramend)
  493. #endif
  494. );
  495. }
  496. /*
  497. * Find the lowest, highest page frame number we have available
  498. */
  499. void __init find_min_max_pfn(void)
  500. {
  501. int i;
  502. max_pfn = 0;
  503. min_low_pfn = memory_end;
  504. for (i = 0; i < bfin_memmap.nr_map; i++) {
  505. unsigned long start, end;
  506. /* RAM? */
  507. if (bfin_memmap.map[i].type != BFIN_MEMMAP_RAM)
  508. continue;
  509. start = PFN_UP(bfin_memmap.map[i].addr);
  510. end = PFN_DOWN(bfin_memmap.map[i].addr +
  511. bfin_memmap.map[i].size);
  512. if (start >= end)
  513. continue;
  514. if (end > max_pfn)
  515. max_pfn = end;
  516. if (start < min_low_pfn)
  517. min_low_pfn = start;
  518. }
  519. }
  520. static __init void setup_bootmem_allocator(void)
  521. {
  522. int bootmap_size;
  523. int i;
  524. unsigned long start_pfn, end_pfn;
  525. unsigned long curr_pfn, last_pfn, size;
  526. /* mark memory between memory_start and memory_end usable */
  527. add_memory_region(memory_start,
  528. memory_end - memory_start, BFIN_MEMMAP_RAM);
  529. /* sanity check for overlap */
  530. sanitize_memmap(bfin_memmap.map, &bfin_memmap.nr_map);
  531. print_memory_map("boot memmap");
  532. /* intialize globals in linux/bootmem.h */
  533. find_min_max_pfn();
  534. /* pfn of the last usable page frame */
  535. if (max_pfn > memory_end >> PAGE_SHIFT)
  536. max_pfn = memory_end >> PAGE_SHIFT;
  537. /* pfn of last page frame directly mapped by kernel */
  538. max_low_pfn = max_pfn;
  539. /* pfn of the first usable page frame after kernel image*/
  540. if (min_low_pfn < memory_start >> PAGE_SHIFT)
  541. min_low_pfn = memory_start >> PAGE_SHIFT;
  542. start_pfn = PAGE_OFFSET >> PAGE_SHIFT;
  543. end_pfn = memory_end >> PAGE_SHIFT;
  544. /*
  545. * give all the memory to the bootmap allocator, tell it to put the
  546. * boot mem_map at the start of memory.
  547. */
  548. bootmap_size = init_bootmem_node(NODE_DATA(0),
  549. memory_start >> PAGE_SHIFT, /* map goes here */
  550. start_pfn, end_pfn);
  551. /* register the memmap regions with the bootmem allocator */
  552. for (i = 0; i < bfin_memmap.nr_map; i++) {
  553. /*
  554. * Reserve usable memory
  555. */
  556. if (bfin_memmap.map[i].type != BFIN_MEMMAP_RAM)
  557. continue;
  558. /*
  559. * We are rounding up the start address of usable memory:
  560. */
  561. curr_pfn = PFN_UP(bfin_memmap.map[i].addr);
  562. if (curr_pfn >= end_pfn)
  563. continue;
  564. /*
  565. * ... and at the end of the usable range downwards:
  566. */
  567. last_pfn = PFN_DOWN(bfin_memmap.map[i].addr +
  568. bfin_memmap.map[i].size);
  569. if (last_pfn > end_pfn)
  570. last_pfn = end_pfn;
  571. /*
  572. * .. finally, did all the rounding and playing
  573. * around just make the area go away?
  574. */
  575. if (last_pfn <= curr_pfn)
  576. continue;
  577. size = last_pfn - curr_pfn;
  578. free_bootmem(PFN_PHYS(curr_pfn), PFN_PHYS(size));
  579. }
  580. /* reserve memory before memory_start, including bootmap */
  581. reserve_bootmem(PAGE_OFFSET,
  582. memory_start + bootmap_size + PAGE_SIZE - 1 - PAGE_OFFSET,
  583. BOOTMEM_DEFAULT);
  584. }
  585. #define EBSZ_TO_MEG(ebsz) \
  586. ({ \
  587. int meg = 0; \
  588. switch (ebsz & 0xf) { \
  589. case 0x1: meg = 16; break; \
  590. case 0x3: meg = 32; break; \
  591. case 0x5: meg = 64; break; \
  592. case 0x7: meg = 128; break; \
  593. case 0x9: meg = 256; break; \
  594. case 0xb: meg = 512; break; \
  595. } \
  596. meg; \
  597. })
  598. static inline int __init get_mem_size(void)
  599. {
  600. #if defined(EBIU_SDBCTL)
  601. # if defined(BF561_FAMILY)
  602. int ret = 0;
  603. u32 sdbctl = bfin_read_EBIU_SDBCTL();
  604. ret += EBSZ_TO_MEG(sdbctl >> 0);
  605. ret += EBSZ_TO_MEG(sdbctl >> 8);
  606. ret += EBSZ_TO_MEG(sdbctl >> 16);
  607. ret += EBSZ_TO_MEG(sdbctl >> 24);
  608. return ret;
  609. # else
  610. return EBSZ_TO_MEG(bfin_read_EBIU_SDBCTL());
  611. # endif
  612. #elif defined(EBIU_DDRCTL1)
  613. u32 ddrctl = bfin_read_EBIU_DDRCTL1();
  614. int ret = 0;
  615. switch (ddrctl & 0xc0000) {
  616. case DEVSZ_64: ret = 64 / 8;
  617. case DEVSZ_128: ret = 128 / 8;
  618. case DEVSZ_256: ret = 256 / 8;
  619. case DEVSZ_512: ret = 512 / 8;
  620. }
  621. switch (ddrctl & 0x30000) {
  622. case DEVWD_4: ret *= 2;
  623. case DEVWD_8: ret *= 2;
  624. case DEVWD_16: break;
  625. }
  626. if ((ddrctl & 0xc000) == 0x4000)
  627. ret *= 2;
  628. return ret;
  629. #endif
  630. BUG();
  631. }
  632. void __init setup_arch(char **cmdline_p)
  633. {
  634. unsigned long sclk, cclk;
  635. #ifdef CONFIG_DUMMY_CONSOLE
  636. conswitchp = &dummy_con;
  637. #endif
  638. #if defined(CONFIG_CMDLINE_BOOL)
  639. strncpy(&command_line[0], CONFIG_CMDLINE, sizeof(command_line));
  640. command_line[sizeof(command_line) - 1] = 0;
  641. #endif
  642. /* Keep a copy of command line */
  643. *cmdline_p = &command_line[0];
  644. memcpy(boot_command_line, command_line, COMMAND_LINE_SIZE);
  645. boot_command_line[COMMAND_LINE_SIZE - 1] = '\0';
  646. /* setup memory defaults from the user config */
  647. physical_mem_end = 0;
  648. _ramend = get_mem_size() * 1024 * 1024;
  649. memset(&bfin_memmap, 0, sizeof(bfin_memmap));
  650. parse_cmdline_early(&command_line[0]);
  651. if (physical_mem_end == 0)
  652. physical_mem_end = _ramend;
  653. memory_setup();
  654. /* Initialize Async memory banks */
  655. bfin_write_EBIU_AMBCTL0(AMBCTL0VAL);
  656. bfin_write_EBIU_AMBCTL1(AMBCTL1VAL);
  657. bfin_write_EBIU_AMGCTL(AMGCTLVAL);
  658. #ifdef CONFIG_EBIU_MBSCTLVAL
  659. bfin_write_EBIU_MBSCTL(CONFIG_EBIU_MBSCTLVAL);
  660. bfin_write_EBIU_MODE(CONFIG_EBIU_MODEVAL);
  661. bfin_write_EBIU_FCTL(CONFIG_EBIU_FCTLVAL);
  662. #endif
  663. cclk = get_cclk();
  664. sclk = get_sclk();
  665. #if !defined(CONFIG_BFIN_KERNEL_CLOCK)
  666. if (ANOMALY_05000273 && cclk == sclk)
  667. panic("ANOMALY 05000273, SCLK can not be same as CCLK");
  668. #endif
  669. #ifdef BF561_FAMILY
  670. if (ANOMALY_05000266) {
  671. bfin_read_IMDMA_D0_IRQ_STATUS();
  672. bfin_read_IMDMA_D1_IRQ_STATUS();
  673. }
  674. #endif
  675. printk(KERN_INFO "Hardware Trace ");
  676. if (bfin_read_TBUFCTL() & 0x1)
  677. printk("Active ");
  678. else
  679. printk("Off ");
  680. if (bfin_read_TBUFCTL() & 0x2)
  681. printk("and Enabled\n");
  682. else
  683. printk("and Disabled\n");
  684. #if defined(CONFIG_CHR_DEV_FLASH) || defined(CONFIG_BLK_DEV_FLASH)
  685. /* we need to initialize the Flashrom device here since we might
  686. * do things with flash early on in the boot
  687. */
  688. flash_probe();
  689. #endif
  690. _bfin_swrst = bfin_read_SWRST();
  691. #ifdef CONFIG_DEBUG_DOUBLEFAULT_PRINT
  692. bfin_write_SWRST(_bfin_swrst & ~DOUBLE_FAULT);
  693. #endif
  694. #ifdef CONFIG_DEBUG_DOUBLEFAULT_RESET
  695. bfin_write_SWRST(_bfin_swrst | DOUBLE_FAULT);
  696. #endif
  697. if (_bfin_swrst & RESET_DOUBLE) {
  698. printk(KERN_EMERG "Recovering from DOUBLE FAULT event\n");
  699. #ifdef CONFIG_DEBUG_DOUBLEFAULT
  700. /* We assume the crashing kernel, and the current symbol table match */
  701. printk(KERN_EMERG " While handling exception (EXCAUSE = 0x%x) at %pF\n",
  702. (int)init_saved_seqstat & SEQSTAT_EXCAUSE, init_saved_retx);
  703. printk(KERN_NOTICE " DCPLB_FAULT_ADDR: %pF\n", init_saved_dcplb_fault_addr);
  704. printk(KERN_NOTICE " ICPLB_FAULT_ADDR: %pF\n", init_saved_icplb_fault_addr);
  705. #endif
  706. printk(KERN_NOTICE " The instruction at %pF caused a double exception\n",
  707. init_retx);
  708. } else if (_bfin_swrst & RESET_WDOG)
  709. printk(KERN_INFO "Recovering from Watchdog event\n");
  710. else if (_bfin_swrst & RESET_SOFTWARE)
  711. printk(KERN_NOTICE "Reset caused by Software reset\n");
  712. printk(KERN_INFO "Blackfin support (C) 2004-2008 Analog Devices, Inc.\n");
  713. if (bfin_compiled_revid() == 0xffff)
  714. printk(KERN_INFO "Compiled for ADSP-%s Rev any\n", CPU);
  715. else if (bfin_compiled_revid() == -1)
  716. printk(KERN_INFO "Compiled for ADSP-%s Rev none\n", CPU);
  717. else
  718. printk(KERN_INFO "Compiled for ADSP-%s Rev 0.%d\n", CPU, bfin_compiled_revid());
  719. if (bfin_revid() != bfin_compiled_revid()) {
  720. if (bfin_compiled_revid() == -1)
  721. printk(KERN_ERR "Warning: Compiled for Rev none, but running on Rev %d\n",
  722. bfin_revid());
  723. else if (bfin_compiled_revid() != 0xffff)
  724. printk(KERN_ERR "Warning: Compiled for Rev %d, but running on Rev %d\n",
  725. bfin_compiled_revid(), bfin_revid());
  726. }
  727. if (bfin_revid() <= CONFIG_BF_REV_MIN || bfin_revid() > CONFIG_BF_REV_MAX)
  728. printk(KERN_ERR "Warning: Unsupported Chip Revision ADSP-%s Rev 0.%d detected\n",
  729. CPU, bfin_revid());
  730. printk(KERN_INFO "Blackfin Linux support by http://blackfin.uclinux.org/\n");
  731. printk(KERN_INFO "Processor Speed: %lu MHz core clock and %lu MHz System Clock\n",
  732. cclk / 1000000, sclk / 1000000);
  733. if (ANOMALY_05000273 && (cclk >> 1) <= sclk)
  734. printk("\n\n\nANOMALY_05000273: CCLK must be >= 2*SCLK !!!\n\n\n");
  735. setup_bootmem_allocator();
  736. paging_init();
  737. /* Copy atomic sequences to their fixed location, and sanity check that
  738. these locations are the ones that we advertise to userspace. */
  739. memcpy((void *)FIXED_CODE_START, &fixed_code_start,
  740. FIXED_CODE_END - FIXED_CODE_START);
  741. BUG_ON((char *)&sigreturn_stub - (char *)&fixed_code_start
  742. != SIGRETURN_STUB - FIXED_CODE_START);
  743. BUG_ON((char *)&atomic_xchg32 - (char *)&fixed_code_start
  744. != ATOMIC_XCHG32 - FIXED_CODE_START);
  745. BUG_ON((char *)&atomic_cas32 - (char *)&fixed_code_start
  746. != ATOMIC_CAS32 - FIXED_CODE_START);
  747. BUG_ON((char *)&atomic_add32 - (char *)&fixed_code_start
  748. != ATOMIC_ADD32 - FIXED_CODE_START);
  749. BUG_ON((char *)&atomic_sub32 - (char *)&fixed_code_start
  750. != ATOMIC_SUB32 - FIXED_CODE_START);
  751. BUG_ON((char *)&atomic_ior32 - (char *)&fixed_code_start
  752. != ATOMIC_IOR32 - FIXED_CODE_START);
  753. BUG_ON((char *)&atomic_and32 - (char *)&fixed_code_start
  754. != ATOMIC_AND32 - FIXED_CODE_START);
  755. BUG_ON((char *)&atomic_xor32 - (char *)&fixed_code_start
  756. != ATOMIC_XOR32 - FIXED_CODE_START);
  757. BUG_ON((char *)&safe_user_instruction - (char *)&fixed_code_start
  758. != SAFE_USER_INSTRUCTION - FIXED_CODE_START);
  759. init_exception_vectors();
  760. bfin_cache_init();
  761. }
  762. static int __init topology_init(void)
  763. {
  764. int cpu;
  765. for_each_possible_cpu(cpu) {
  766. struct cpu *c = &per_cpu(cpu_devices, cpu);
  767. register_cpu(c, cpu);
  768. }
  769. return 0;
  770. }
  771. subsys_initcall(topology_init);
  772. /* Get the voltage input multiplier */
  773. static u_long cached_vco_pll_ctl, cached_vco;
  774. static u_long get_vco(void)
  775. {
  776. u_long msel;
  777. u_long pll_ctl = bfin_read_PLL_CTL();
  778. if (pll_ctl == cached_vco_pll_ctl)
  779. return cached_vco;
  780. else
  781. cached_vco_pll_ctl = pll_ctl;
  782. msel = (pll_ctl >> 9) & 0x3F;
  783. if (0 == msel)
  784. msel = 64;
  785. cached_vco = CONFIG_CLKIN_HZ;
  786. cached_vco >>= (1 & pll_ctl); /* DF bit */
  787. cached_vco *= msel;
  788. return cached_vco;
  789. }
  790. /* Get the Core clock */
  791. static u_long cached_cclk_pll_div, cached_cclk;
  792. u_long get_cclk(void)
  793. {
  794. u_long csel, ssel;
  795. if (bfin_read_PLL_STAT() & 0x1)
  796. return CONFIG_CLKIN_HZ;
  797. ssel = bfin_read_PLL_DIV();
  798. if (ssel == cached_cclk_pll_div)
  799. return cached_cclk;
  800. else
  801. cached_cclk_pll_div = ssel;
  802. csel = ((ssel >> 4) & 0x03);
  803. ssel &= 0xf;
  804. if (ssel && ssel < (1 << csel)) /* SCLK > CCLK */
  805. cached_cclk = get_vco() / ssel;
  806. else
  807. cached_cclk = get_vco() >> csel;
  808. return cached_cclk;
  809. }
  810. EXPORT_SYMBOL(get_cclk);
  811. /* Get the System clock */
  812. static u_long cached_sclk_pll_div, cached_sclk;
  813. u_long get_sclk(void)
  814. {
  815. u_long ssel;
  816. if (bfin_read_PLL_STAT() & 0x1)
  817. return CONFIG_CLKIN_HZ;
  818. ssel = bfin_read_PLL_DIV();
  819. if (ssel == cached_sclk_pll_div)
  820. return cached_sclk;
  821. else
  822. cached_sclk_pll_div = ssel;
  823. ssel &= 0xf;
  824. if (0 == ssel) {
  825. printk(KERN_WARNING "Invalid System Clock\n");
  826. ssel = 1;
  827. }
  828. cached_sclk = get_vco() / ssel;
  829. return cached_sclk;
  830. }
  831. EXPORT_SYMBOL(get_sclk);
  832. unsigned long sclk_to_usecs(unsigned long sclk)
  833. {
  834. u64 tmp = USEC_PER_SEC * (u64)sclk;
  835. do_div(tmp, get_sclk());
  836. return tmp;
  837. }
  838. EXPORT_SYMBOL(sclk_to_usecs);
  839. unsigned long usecs_to_sclk(unsigned long usecs)
  840. {
  841. u64 tmp = get_sclk() * (u64)usecs;
  842. do_div(tmp, USEC_PER_SEC);
  843. return tmp;
  844. }
  845. EXPORT_SYMBOL(usecs_to_sclk);
  846. /*
  847. * Get CPU information for use by the procfs.
  848. */
  849. static int show_cpuinfo(struct seq_file *m, void *v)
  850. {
  851. char *cpu, *mmu, *fpu, *vendor, *cache;
  852. uint32_t revid;
  853. u_long cclk = 0, sclk = 0;
  854. u_int icache_size = BFIN_ICACHESIZE / 1024, dcache_size = 0, dsup_banks = 0;
  855. cpu = CPU;
  856. mmu = "none";
  857. fpu = "none";
  858. revid = bfin_revid();
  859. cclk = get_cclk();
  860. sclk = get_sclk();
  861. switch (bfin_read_CHIPID() & CHIPID_MANUFACTURE) {
  862. case 0xca:
  863. vendor = "Analog Devices";
  864. break;
  865. default:
  866. vendor = "unknown";
  867. break;
  868. }
  869. seq_printf(m, "processor\t: %d\n"
  870. "vendor_id\t: %s\n"
  871. "cpu family\t: 0x%x\n"
  872. "model name\t: ADSP-%s %lu(MHz CCLK) %lu(MHz SCLK) (%s)\n"
  873. "stepping\t: %d\n",
  874. *(unsigned int *)v,
  875. vendor,
  876. (bfin_read_CHIPID() & CHIPID_FAMILY),
  877. cpu, cclk/1000000, sclk/1000000,
  878. #ifdef CONFIG_MPU
  879. "mpu on",
  880. #else
  881. "mpu off",
  882. #endif
  883. revid);
  884. seq_printf(m, "cpu MHz\t\t: %lu.%03lu/%lu.%03lu\n",
  885. cclk/1000000, cclk%1000000,
  886. sclk/1000000, sclk%1000000);
  887. seq_printf(m, "bogomips\t: %lu.%02lu\n"
  888. "Calibration\t: %lu loops\n",
  889. (loops_per_jiffy * HZ) / 500000,
  890. ((loops_per_jiffy * HZ) / 5000) % 100,
  891. (loops_per_jiffy * HZ));
  892. /* Check Cache configutation */
  893. switch (bfin_read_DMEM_CONTROL() & (1 << DMC0_P | 1 << DMC1_P)) {
  894. case ACACHE_BSRAM:
  895. cache = "dbank-A/B\t: cache/sram";
  896. dcache_size = 16;
  897. dsup_banks = 1;
  898. break;
  899. case ACACHE_BCACHE:
  900. cache = "dbank-A/B\t: cache/cache";
  901. dcache_size = 32;
  902. dsup_banks = 2;
  903. break;
  904. case ASRAM_BSRAM:
  905. cache = "dbank-A/B\t: sram/sram";
  906. dcache_size = 0;
  907. dsup_banks = 0;
  908. break;
  909. default:
  910. cache = "unknown";
  911. dcache_size = 0;
  912. dsup_banks = 0;
  913. break;
  914. }
  915. /* Is it turned on? */
  916. if ((bfin_read_DMEM_CONTROL() & (ENDCPLB | DMC_ENABLE)) != (ENDCPLB | DMC_ENABLE))
  917. dcache_size = 0;
  918. if ((bfin_read_IMEM_CONTROL() & (IMC | ENICPLB)) != (IMC | ENICPLB))
  919. icache_size = 0;
  920. seq_printf(m, "cache size\t: %d KB(L1 icache) "
  921. "%d KB(L1 dcache-%s) %d KB(L2 cache)\n",
  922. icache_size, dcache_size,
  923. #if defined CONFIG_BFIN_WB
  924. "wb"
  925. #elif defined CONFIG_BFIN_WT
  926. "wt"
  927. #endif
  928. "", 0);
  929. seq_printf(m, "%s\n", cache);
  930. if (icache_size)
  931. seq_printf(m, "icache setup\t: %d Sub-banks/%d Ways, %d Lines/Way\n",
  932. BFIN_ISUBBANKS, BFIN_IWAYS, BFIN_ILINES);
  933. else
  934. seq_printf(m, "icache setup\t: off\n");
  935. seq_printf(m,
  936. "dcache setup\t: %d Super-banks/%d Sub-banks/%d Ways, %d Lines/Way\n",
  937. dsup_banks, BFIN_DSUBBANKS, BFIN_DWAYS,
  938. BFIN_DLINES);
  939. #ifdef CONFIG_BFIN_ICACHE_LOCK
  940. switch ((bfin_read_IMEM_CONTROL() >> 3) & WAYALL_L) {
  941. case WAY0_L:
  942. seq_printf(m, "Way0 Locked-Down\n");
  943. break;
  944. case WAY1_L:
  945. seq_printf(m, "Way1 Locked-Down\n");
  946. break;
  947. case WAY01_L:
  948. seq_printf(m, "Way0,Way1 Locked-Down\n");
  949. break;
  950. case WAY2_L:
  951. seq_printf(m, "Way2 Locked-Down\n");
  952. break;
  953. case WAY02_L:
  954. seq_printf(m, "Way0,Way2 Locked-Down\n");
  955. break;
  956. case WAY12_L:
  957. seq_printf(m, "Way1,Way2 Locked-Down\n");
  958. break;
  959. case WAY012_L:
  960. seq_printf(m, "Way0,Way1 & Way2 Locked-Down\n");
  961. break;
  962. case WAY3_L:
  963. seq_printf(m, "Way3 Locked-Down\n");
  964. break;
  965. case WAY03_L:
  966. seq_printf(m, "Way0,Way3 Locked-Down\n");
  967. break;
  968. case WAY13_L:
  969. seq_printf(m, "Way1,Way3 Locked-Down\n");
  970. break;
  971. case WAY013_L:
  972. seq_printf(m, "Way 0,Way1,Way3 Locked-Down\n");
  973. break;
  974. case WAY32_L:
  975. seq_printf(m, "Way3,Way2 Locked-Down\n");
  976. break;
  977. case WAY320_L:
  978. seq_printf(m, "Way3,Way2,Way0 Locked-Down\n");
  979. break;
  980. case WAY321_L:
  981. seq_printf(m, "Way3,Way2,Way1 Locked-Down\n");
  982. break;
  983. case WAYALL_L:
  984. seq_printf(m, "All Ways are locked\n");
  985. break;
  986. default:
  987. seq_printf(m, "No Ways are locked\n");
  988. }
  989. #endif
  990. seq_printf(m, "board name\t: %s\n", bfin_board_name);
  991. seq_printf(m, "board memory\t: %ld kB (0x%p -> 0x%p)\n",
  992. physical_mem_end >> 10, (void *)0, (void *)physical_mem_end);
  993. seq_printf(m, "kernel memory\t: %d kB (0x%p -> 0x%p)\n",
  994. ((int)memory_end - (int)_stext) >> 10,
  995. _stext,
  996. (void *)memory_end);
  997. return 0;
  998. }
  999. static void *c_start(struct seq_file *m, loff_t *pos)
  1000. {
  1001. if (*pos == 0)
  1002. *pos = first_cpu(cpu_online_map);
  1003. if (*pos >= num_online_cpus())
  1004. return NULL;
  1005. return pos;
  1006. }
  1007. static void *c_next(struct seq_file *m, void *v, loff_t *pos)
  1008. {
  1009. *pos = next_cpu(*pos, cpu_online_map);
  1010. return c_start(m, pos);
  1011. }
  1012. static void c_stop(struct seq_file *m, void *v)
  1013. {
  1014. }
  1015. const struct seq_operations cpuinfo_op = {
  1016. .start = c_start,
  1017. .next = c_next,
  1018. .stop = c_stop,
  1019. .show = show_cpuinfo,
  1020. };
  1021. void __init cmdline_init(const char *r0)
  1022. {
  1023. if (r0)
  1024. strncpy(command_line, r0, COMMAND_LINE_SIZE);
  1025. }