setup.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769
  1. /*
  2. * This file is subject to the terms and conditions of the GNU General Public
  3. * License. See the file "COPYING" in the main directory of this archive
  4. * for more details.
  5. *
  6. * Copyright (C) 1995 Linus Torvalds
  7. * Copyright (C) 1995 Waldorf Electronics
  8. * Copyright (C) 1994, 95, 96, 97, 98, 99, 2000, 01, 02, 03 Ralf Baechle
  9. * Copyright (C) 1996 Stoned Elipot
  10. * Copyright (C) 1999 Silicon Graphics, Inc.
  11. * Copyright (C) 2000, 2001, 2002, 2007 Maciej W. Rozycki
  12. */
  13. #include <linux/init.h>
  14. #include <linux/ioport.h>
  15. #include <linux/export.h>
  16. #include <linux/screen_info.h>
  17. #include <linux/memblock.h>
  18. #include <linux/bootmem.h>
  19. #include <linux/initrd.h>
  20. #include <linux/root_dev.h>
  21. #include <linux/highmem.h>
  22. #include <linux/console.h>
  23. #include <linux/pfn.h>
  24. #include <linux/debugfs.h>
  25. #include <linux/kexec.h>
  26. #include <linux/sizes.h>
  27. #include <asm/addrspace.h>
  28. #include <asm/bootinfo.h>
  29. #include <asm/bugs.h>
  30. #include <asm/cache.h>
  31. #include <asm/cpu.h>
  32. #include <asm/sections.h>
  33. #include <asm/setup.h>
  34. #include <asm/smp-ops.h>
  35. #include <asm/prom.h>
  36. struct cpuinfo_mips cpu_data[NR_CPUS] __read_mostly;
  37. EXPORT_SYMBOL(cpu_data);
  38. #ifdef CONFIG_VT
  39. struct screen_info screen_info;
  40. #endif
  41. /*
  42. * Despite it's name this variable is even if we don't have PCI
  43. */
  44. unsigned int PCI_DMA_BUS_IS_PHYS;
  45. EXPORT_SYMBOL(PCI_DMA_BUS_IS_PHYS);
  46. /*
  47. * Setup information
  48. *
  49. * These are initialized so they are in the .data section
  50. */
  51. unsigned long mips_machtype __read_mostly = MACH_UNKNOWN;
  52. EXPORT_SYMBOL(mips_machtype);
  53. struct boot_mem_map boot_mem_map;
  54. static char __initdata command_line[COMMAND_LINE_SIZE];
  55. char __initdata arcs_cmdline[COMMAND_LINE_SIZE];
  56. #ifdef CONFIG_CMDLINE_BOOL
  57. static char __initdata builtin_cmdline[COMMAND_LINE_SIZE] = CONFIG_CMDLINE;
  58. #endif
  59. /*
  60. * mips_io_port_base is the begin of the address space to which x86 style
  61. * I/O ports are mapped.
  62. */
  63. const unsigned long mips_io_port_base = -1;
  64. EXPORT_SYMBOL(mips_io_port_base);
  65. static struct resource code_resource = { .name = "Kernel code", };
  66. static struct resource data_resource = { .name = "Kernel data", };
  67. static void *detect_magic __initdata = detect_memory_region;
  68. void __init add_memory_region(phys_t start, phys_t size, long type)
  69. {
  70. int x = boot_mem_map.nr_map;
  71. int i;
  72. /* Sanity check */
  73. if (start + size < start) {
  74. pr_warning("Trying to add an invalid memory region, skipped\n");
  75. return;
  76. }
  77. /*
  78. * Try to merge with existing entry, if any.
  79. */
  80. for (i = 0; i < boot_mem_map.nr_map; i++) {
  81. struct boot_mem_map_entry *entry = boot_mem_map.map + i;
  82. unsigned long top;
  83. if (entry->type != type)
  84. continue;
  85. if (start + size < entry->addr)
  86. continue; /* no overlap */
  87. if (entry->addr + entry->size < start)
  88. continue; /* no overlap */
  89. top = max(entry->addr + entry->size, start + size);
  90. entry->addr = min(entry->addr, start);
  91. entry->size = top - entry->addr;
  92. return;
  93. }
  94. if (boot_mem_map.nr_map == BOOT_MEM_MAP_MAX) {
  95. pr_err("Ooops! Too many entries in the memory map!\n");
  96. return;
  97. }
  98. boot_mem_map.map[x].addr = start;
  99. boot_mem_map.map[x].size = size;
  100. boot_mem_map.map[x].type = type;
  101. boot_mem_map.nr_map++;
  102. }
  103. void __init detect_memory_region(phys_t start, phys_t sz_min, phys_t sz_max)
  104. {
  105. void *dm = &detect_magic;
  106. phys_t size;
  107. for (size = sz_min; size < sz_max; size <<= 1) {
  108. if (!memcmp(dm, dm + size, sizeof(detect_magic)))
  109. break;
  110. }
  111. pr_debug("Memory: %lluMB of RAM detected at 0x%llx (min: %lluMB, max: %lluMB)\n",
  112. ((unsigned long long) size) / SZ_1M,
  113. (unsigned long long) start,
  114. ((unsigned long long) sz_min) / SZ_1M,
  115. ((unsigned long long) sz_max) / SZ_1M);
  116. add_memory_region(start, size, BOOT_MEM_RAM);
  117. }
  118. static void __init print_memory_map(void)
  119. {
  120. int i;
  121. const int field = 2 * sizeof(unsigned long);
  122. for (i = 0; i < boot_mem_map.nr_map; i++) {
  123. printk(KERN_INFO " memory: %0*Lx @ %0*Lx ",
  124. field, (unsigned long long) boot_mem_map.map[i].size,
  125. field, (unsigned long long) boot_mem_map.map[i].addr);
  126. switch (boot_mem_map.map[i].type) {
  127. case BOOT_MEM_RAM:
  128. printk(KERN_CONT "(usable)\n");
  129. break;
  130. case BOOT_MEM_INIT_RAM:
  131. printk(KERN_CONT "(usable after init)\n");
  132. break;
  133. case BOOT_MEM_ROM_DATA:
  134. printk(KERN_CONT "(ROM data)\n");
  135. break;
  136. case BOOT_MEM_RESERVED:
  137. printk(KERN_CONT "(reserved)\n");
  138. break;
  139. default:
  140. printk(KERN_CONT "type %lu\n", boot_mem_map.map[i].type);
  141. break;
  142. }
  143. }
  144. }
  145. /*
  146. * Manage initrd
  147. */
  148. #ifdef CONFIG_BLK_DEV_INITRD
  149. static int __init rd_start_early(char *p)
  150. {
  151. unsigned long start = memparse(p, &p);
  152. #ifdef CONFIG_64BIT
  153. /* Guess if the sign extension was forgotten by bootloader */
  154. if (start < XKPHYS)
  155. start = (int)start;
  156. #endif
  157. initrd_start = start;
  158. initrd_end += start;
  159. return 0;
  160. }
  161. early_param("rd_start", rd_start_early);
  162. static int __init rd_size_early(char *p)
  163. {
  164. initrd_end += memparse(p, &p);
  165. return 0;
  166. }
  167. early_param("rd_size", rd_size_early);
  168. /* it returns the next free pfn after initrd */
  169. static unsigned long __init init_initrd(void)
  170. {
  171. unsigned long end;
  172. /*
  173. * Board specific code or command line parser should have
  174. * already set up initrd_start and initrd_end. In these cases
  175. * perfom sanity checks and use them if all looks good.
  176. */
  177. if (!initrd_start || initrd_end <= initrd_start)
  178. goto disable;
  179. if (initrd_start & ~PAGE_MASK) {
  180. pr_err("initrd start must be page aligned\n");
  181. goto disable;
  182. }
  183. if (initrd_start < PAGE_OFFSET) {
  184. pr_err("initrd start < PAGE_OFFSET\n");
  185. goto disable;
  186. }
  187. /*
  188. * Sanitize initrd addresses. For example firmware
  189. * can't guess if they need to pass them through
  190. * 64-bits values if the kernel has been built in pure
  191. * 32-bit. We need also to switch from KSEG0 to XKPHYS
  192. * addresses now, so the code can now safely use __pa().
  193. */
  194. end = __pa(initrd_end);
  195. initrd_end = (unsigned long)__va(end);
  196. initrd_start = (unsigned long)__va(__pa(initrd_start));
  197. ROOT_DEV = Root_RAM0;
  198. return PFN_UP(end);
  199. disable:
  200. initrd_start = 0;
  201. initrd_end = 0;
  202. return 0;
  203. }
  204. static void __init finalize_initrd(void)
  205. {
  206. unsigned long size = initrd_end - initrd_start;
  207. if (size == 0) {
  208. printk(KERN_INFO "Initrd not found or empty");
  209. goto disable;
  210. }
  211. if (__pa(initrd_end) > PFN_PHYS(max_low_pfn)) {
  212. printk(KERN_ERR "Initrd extends beyond end of memory");
  213. goto disable;
  214. }
  215. reserve_bootmem(__pa(initrd_start), size, BOOTMEM_DEFAULT);
  216. initrd_below_start_ok = 1;
  217. pr_info("Initial ramdisk at: 0x%lx (%lu bytes)\n",
  218. initrd_start, size);
  219. return;
  220. disable:
  221. printk(KERN_CONT " - disabling initrd\n");
  222. initrd_start = 0;
  223. initrd_end = 0;
  224. }
  225. #else /* !CONFIG_BLK_DEV_INITRD */
  226. static unsigned long __init init_initrd(void)
  227. {
  228. return 0;
  229. }
  230. #define finalize_initrd() do {} while (0)
  231. #endif
  232. /*
  233. * Initialize the bootmem allocator. It also setup initrd related data
  234. * if needed.
  235. */
  236. #ifdef CONFIG_SGI_IP27
  237. static void __init bootmem_init(void)
  238. {
  239. init_initrd();
  240. finalize_initrd();
  241. }
  242. #else /* !CONFIG_SGI_IP27 */
  243. static void __init bootmem_init(void)
  244. {
  245. unsigned long reserved_end;
  246. unsigned long mapstart = ~0UL;
  247. unsigned long bootmap_size;
  248. int i;
  249. /*
  250. * Init any data related to initrd. It's a nop if INITRD is
  251. * not selected. Once that done we can determine the low bound
  252. * of usable memory.
  253. */
  254. reserved_end = max(init_initrd(),
  255. (unsigned long) PFN_UP(__pa_symbol(&_end)));
  256. /*
  257. * max_low_pfn is not a number of pages. The number of pages
  258. * of the system is given by 'max_low_pfn - min_low_pfn'.
  259. */
  260. min_low_pfn = ~0UL;
  261. max_low_pfn = 0;
  262. /*
  263. * Find the highest page frame number we have available.
  264. */
  265. for (i = 0; i < boot_mem_map.nr_map; i++) {
  266. unsigned long start, end;
  267. if (boot_mem_map.map[i].type != BOOT_MEM_RAM)
  268. continue;
  269. start = PFN_UP(boot_mem_map.map[i].addr);
  270. end = PFN_DOWN(boot_mem_map.map[i].addr
  271. + boot_mem_map.map[i].size);
  272. if (end > max_low_pfn)
  273. max_low_pfn = end;
  274. if (start < min_low_pfn)
  275. min_low_pfn = start;
  276. if (end <= reserved_end)
  277. continue;
  278. if (start >= mapstart)
  279. continue;
  280. mapstart = max(reserved_end, start);
  281. }
  282. if (min_low_pfn >= max_low_pfn)
  283. panic("Incorrect memory mapping !!!");
  284. if (min_low_pfn > ARCH_PFN_OFFSET) {
  285. pr_info("Wasting %lu bytes for tracking %lu unused pages\n",
  286. (min_low_pfn - ARCH_PFN_OFFSET) * sizeof(struct page),
  287. min_low_pfn - ARCH_PFN_OFFSET);
  288. } else if (min_low_pfn < ARCH_PFN_OFFSET) {
  289. pr_info("%lu free pages won't be used\n",
  290. ARCH_PFN_OFFSET - min_low_pfn);
  291. }
  292. min_low_pfn = ARCH_PFN_OFFSET;
  293. /*
  294. * Determine low and high memory ranges
  295. */
  296. max_pfn = max_low_pfn;
  297. if (max_low_pfn > PFN_DOWN(HIGHMEM_START)) {
  298. #ifdef CONFIG_HIGHMEM
  299. highstart_pfn = PFN_DOWN(HIGHMEM_START);
  300. highend_pfn = max_low_pfn;
  301. #endif
  302. max_low_pfn = PFN_DOWN(HIGHMEM_START);
  303. }
  304. /*
  305. * Initialize the boot-time allocator with low memory only.
  306. */
  307. bootmap_size = init_bootmem_node(NODE_DATA(0), mapstart,
  308. min_low_pfn, max_low_pfn);
  309. for (i = 0; i < boot_mem_map.nr_map; i++) {
  310. unsigned long start, end;
  311. start = PFN_UP(boot_mem_map.map[i].addr);
  312. end = PFN_DOWN(boot_mem_map.map[i].addr
  313. + boot_mem_map.map[i].size);
  314. if (start <= min_low_pfn)
  315. start = min_low_pfn;
  316. if (start >= end)
  317. continue;
  318. #ifndef CONFIG_HIGHMEM
  319. if (end > max_low_pfn)
  320. end = max_low_pfn;
  321. /*
  322. * ... finally, is the area going away?
  323. */
  324. if (end <= start)
  325. continue;
  326. #endif
  327. memblock_add_node(PFN_PHYS(start), PFN_PHYS(end - start), 0);
  328. }
  329. /*
  330. * Register fully available low RAM pages with the bootmem allocator.
  331. */
  332. for (i = 0; i < boot_mem_map.nr_map; i++) {
  333. unsigned long start, end, size;
  334. start = PFN_UP(boot_mem_map.map[i].addr);
  335. end = PFN_DOWN(boot_mem_map.map[i].addr
  336. + boot_mem_map.map[i].size);
  337. /*
  338. * Reserve usable memory.
  339. */
  340. switch (boot_mem_map.map[i].type) {
  341. case BOOT_MEM_RAM:
  342. break;
  343. case BOOT_MEM_INIT_RAM:
  344. memory_present(0, start, end);
  345. continue;
  346. default:
  347. /* Not usable memory */
  348. continue;
  349. }
  350. /*
  351. * We are rounding up the start address of usable memory
  352. * and at the end of the usable range downwards.
  353. */
  354. if (start >= max_low_pfn)
  355. continue;
  356. if (start < reserved_end)
  357. start = reserved_end;
  358. if (end > max_low_pfn)
  359. end = max_low_pfn;
  360. /*
  361. * ... finally, is the area going away?
  362. */
  363. if (end <= start)
  364. continue;
  365. size = end - start;
  366. /* Register lowmem ranges */
  367. free_bootmem(PFN_PHYS(start), size << PAGE_SHIFT);
  368. memory_present(0, start, end);
  369. }
  370. /*
  371. * Reserve the bootmap memory.
  372. */
  373. reserve_bootmem(PFN_PHYS(mapstart), bootmap_size, BOOTMEM_DEFAULT);
  374. /*
  375. * Reserve initrd memory if needed.
  376. */
  377. finalize_initrd();
  378. }
  379. #endif /* CONFIG_SGI_IP27 */
  380. /*
  381. * arch_mem_init - initialize memory management subsystem
  382. *
  383. * o plat_mem_setup() detects the memory configuration and will record detected
  384. * memory areas using add_memory_region.
  385. *
  386. * At this stage the memory configuration of the system is known to the
  387. * kernel but generic memory management system is still entirely uninitialized.
  388. *
  389. * o bootmem_init()
  390. * o sparse_init()
  391. * o paging_init()
  392. *
  393. * At this stage the bootmem allocator is ready to use.
  394. *
  395. * NOTE: historically plat_mem_setup did the entire platform initialization.
  396. * This was rather impractical because it meant plat_mem_setup had to
  397. * get away without any kind of memory allocator. To keep old code from
  398. * breaking plat_setup was just renamed to plat_setup and a second platform
  399. * initialization hook for anything else was introduced.
  400. */
  401. static int usermem __initdata;
  402. static int __init early_parse_mem(char *p)
  403. {
  404. unsigned long start, size;
  405. /*
  406. * If a user specifies memory size, we
  407. * blow away any automatically generated
  408. * size.
  409. */
  410. if (usermem == 0) {
  411. boot_mem_map.nr_map = 0;
  412. usermem = 1;
  413. }
  414. start = 0;
  415. size = memparse(p, &p);
  416. if (*p == '@')
  417. start = memparse(p + 1, &p);
  418. add_memory_region(start, size, BOOT_MEM_RAM);
  419. return 0;
  420. }
  421. early_param("mem", early_parse_mem);
  422. #ifdef CONFIG_PROC_VMCORE
  423. unsigned long setup_elfcorehdr, setup_elfcorehdr_size;
  424. static int __init early_parse_elfcorehdr(char *p)
  425. {
  426. int i;
  427. setup_elfcorehdr = memparse(p, &p);
  428. for (i = 0; i < boot_mem_map.nr_map; i++) {
  429. unsigned long start = boot_mem_map.map[i].addr;
  430. unsigned long end = (boot_mem_map.map[i].addr +
  431. boot_mem_map.map[i].size);
  432. if (setup_elfcorehdr >= start && setup_elfcorehdr < end) {
  433. /*
  434. * Reserve from the elf core header to the end of
  435. * the memory segment, that should all be kdump
  436. * reserved memory.
  437. */
  438. setup_elfcorehdr_size = end - setup_elfcorehdr;
  439. break;
  440. }
  441. }
  442. /*
  443. * If we don't find it in the memory map, then we shouldn't
  444. * have to worry about it, as the new kernel won't use it.
  445. */
  446. return 0;
  447. }
  448. early_param("elfcorehdr", early_parse_elfcorehdr);
  449. #endif
  450. static void __init arch_mem_addpart(phys_t mem, phys_t end, int type)
  451. {
  452. phys_t size;
  453. int i;
  454. size = end - mem;
  455. if (!size)
  456. return;
  457. /* Make sure it is in the boot_mem_map */
  458. for (i = 0; i < boot_mem_map.nr_map; i++) {
  459. if (mem >= boot_mem_map.map[i].addr &&
  460. mem < (boot_mem_map.map[i].addr +
  461. boot_mem_map.map[i].size))
  462. return;
  463. }
  464. add_memory_region(mem, size, type);
  465. }
  466. static void __init arch_mem_init(char **cmdline_p)
  467. {
  468. extern void plat_mem_setup(void);
  469. /* call board setup routine */
  470. plat_mem_setup();
  471. /*
  472. * Make sure all kernel memory is in the maps. The "UP" and
  473. * "DOWN" are opposite for initdata since if it crosses over
  474. * into another memory section you don't want that to be
  475. * freed when the initdata is freed.
  476. */
  477. arch_mem_addpart(PFN_DOWN(__pa_symbol(&_text)) << PAGE_SHIFT,
  478. PFN_UP(__pa_symbol(&_edata)) << PAGE_SHIFT,
  479. BOOT_MEM_RAM);
  480. arch_mem_addpart(PFN_UP(__pa_symbol(&__init_begin)) << PAGE_SHIFT,
  481. PFN_DOWN(__pa_symbol(&__init_end)) << PAGE_SHIFT,
  482. BOOT_MEM_INIT_RAM);
  483. pr_info("Determined physical RAM map:\n");
  484. print_memory_map();
  485. #ifdef CONFIG_CMDLINE_BOOL
  486. #ifdef CONFIG_CMDLINE_OVERRIDE
  487. strlcpy(boot_command_line, builtin_cmdline, COMMAND_LINE_SIZE);
  488. #else
  489. if (builtin_cmdline[0]) {
  490. strlcat(arcs_cmdline, " ", COMMAND_LINE_SIZE);
  491. strlcat(arcs_cmdline, builtin_cmdline, COMMAND_LINE_SIZE);
  492. }
  493. strlcpy(boot_command_line, arcs_cmdline, COMMAND_LINE_SIZE);
  494. #endif
  495. #else
  496. strlcpy(boot_command_line, arcs_cmdline, COMMAND_LINE_SIZE);
  497. #endif
  498. strlcpy(command_line, boot_command_line, COMMAND_LINE_SIZE);
  499. *cmdline_p = command_line;
  500. parse_early_param();
  501. if (usermem) {
  502. pr_info("User-defined physical RAM map:\n");
  503. print_memory_map();
  504. }
  505. bootmem_init();
  506. #ifdef CONFIG_PROC_VMCORE
  507. if (setup_elfcorehdr && setup_elfcorehdr_size) {
  508. printk(KERN_INFO "kdump reserved memory at %lx-%lx\n",
  509. setup_elfcorehdr, setup_elfcorehdr_size);
  510. reserve_bootmem(setup_elfcorehdr, setup_elfcorehdr_size,
  511. BOOTMEM_DEFAULT);
  512. }
  513. #endif
  514. #ifdef CONFIG_KEXEC
  515. if (crashk_res.start != crashk_res.end)
  516. reserve_bootmem(crashk_res.start,
  517. crashk_res.end - crashk_res.start + 1,
  518. BOOTMEM_DEFAULT);
  519. #endif
  520. device_tree_init();
  521. sparse_init();
  522. plat_swiotlb_setup();
  523. paging_init();
  524. }
  525. #ifdef CONFIG_KEXEC
  526. static inline unsigned long long get_total_mem(void)
  527. {
  528. unsigned long long total;
  529. total = max_pfn - min_low_pfn;
  530. return total << PAGE_SHIFT;
  531. }
  532. static void __init mips_parse_crashkernel(void)
  533. {
  534. unsigned long long total_mem;
  535. unsigned long long crash_size, crash_base;
  536. int ret;
  537. total_mem = get_total_mem();
  538. ret = parse_crashkernel(boot_command_line, total_mem,
  539. &crash_size, &crash_base);
  540. if (ret != 0 || crash_size <= 0)
  541. return;
  542. crashk_res.start = crash_base;
  543. crashk_res.end = crash_base + crash_size - 1;
  544. }
  545. static void __init request_crashkernel(struct resource *res)
  546. {
  547. int ret;
  548. ret = request_resource(res, &crashk_res);
  549. if (!ret)
  550. pr_info("Reserving %ldMB of memory at %ldMB for crashkernel\n",
  551. (unsigned long)((crashk_res.end -
  552. crashk_res.start + 1) >> 20),
  553. (unsigned long)(crashk_res.start >> 20));
  554. }
  555. #else /* !defined(CONFIG_KEXEC) */
  556. static void __init mips_parse_crashkernel(void)
  557. {
  558. }
  559. static void __init request_crashkernel(struct resource *res)
  560. {
  561. }
  562. #endif /* !defined(CONFIG_KEXEC) */
  563. static void __init resource_init(void)
  564. {
  565. int i;
  566. if (UNCAC_BASE != IO_BASE)
  567. return;
  568. code_resource.start = __pa_symbol(&_text);
  569. code_resource.end = __pa_symbol(&_etext) - 1;
  570. data_resource.start = __pa_symbol(&_etext);
  571. data_resource.end = __pa_symbol(&_edata) - 1;
  572. /*
  573. * Request address space for all standard RAM.
  574. */
  575. mips_parse_crashkernel();
  576. for (i = 0; i < boot_mem_map.nr_map; i++) {
  577. struct resource *res;
  578. unsigned long start, end;
  579. start = boot_mem_map.map[i].addr;
  580. end = boot_mem_map.map[i].addr + boot_mem_map.map[i].size - 1;
  581. if (start >= HIGHMEM_START)
  582. continue;
  583. if (end >= HIGHMEM_START)
  584. end = HIGHMEM_START - 1;
  585. res = alloc_bootmem(sizeof(struct resource));
  586. switch (boot_mem_map.map[i].type) {
  587. case BOOT_MEM_RAM:
  588. case BOOT_MEM_INIT_RAM:
  589. case BOOT_MEM_ROM_DATA:
  590. res->name = "System RAM";
  591. break;
  592. case BOOT_MEM_RESERVED:
  593. default:
  594. res->name = "reserved";
  595. }
  596. res->start = start;
  597. res->end = end;
  598. res->flags = IORESOURCE_MEM | IORESOURCE_BUSY;
  599. request_resource(&iomem_resource, res);
  600. /*
  601. * We don't know which RAM region contains kernel data,
  602. * so we try it repeatedly and let the resource manager
  603. * test it.
  604. */
  605. request_resource(res, &code_resource);
  606. request_resource(res, &data_resource);
  607. request_crashkernel(res);
  608. }
  609. }
  610. void __init setup_arch(char **cmdline_p)
  611. {
  612. cpu_probe();
  613. prom_init();
  614. #ifdef CONFIG_EARLY_PRINTK
  615. setup_early_printk();
  616. #endif
  617. cpu_report();
  618. check_bugs_early();
  619. #if defined(CONFIG_VT)
  620. #if defined(CONFIG_VGA_CONSOLE)
  621. conswitchp = &vga_con;
  622. #elif defined(CONFIG_DUMMY_CONSOLE)
  623. conswitchp = &dummy_con;
  624. #endif
  625. #endif
  626. arch_mem_init(cmdline_p);
  627. resource_init();
  628. plat_smp_setup();
  629. cpu_cache_init();
  630. }
  631. unsigned long kernelsp[NR_CPUS];
  632. unsigned long fw_arg0, fw_arg1, fw_arg2, fw_arg3;
  633. #ifdef CONFIG_DEBUG_FS
  634. struct dentry *mips_debugfs_dir;
  635. static int __init debugfs_mips(void)
  636. {
  637. struct dentry *d;
  638. d = debugfs_create_dir("mips", NULL);
  639. if (!d)
  640. return -ENOMEM;
  641. mips_debugfs_dir = d;
  642. return 0;
  643. }
  644. arch_initcall(debugfs_mips);
  645. #endif