e820.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681
  1. /*
  2. * Handle the memory map.
  3. * The functions here do the job until bootmem takes over.
  4. * $Id: e820.c,v 1.4 2002/09/19 19:25:32 ak Exp $
  5. *
  6. * Getting sanitize_e820_map() in sync with i386 version by applying change:
  7. * - Provisions for empty E820 memory regions (reported by certain BIOSes).
  8. * Alex Achenbach <xela@slit.de>, December 2002.
  9. * Venkatesh Pallipadi <venkatesh.pallipadi@intel.com>
  10. *
  11. */
  12. #include <linux/config.h>
  13. #include <linux/kernel.h>
  14. #include <linux/types.h>
  15. #include <linux/init.h>
  16. #include <linux/bootmem.h>
  17. #include <linux/ioport.h>
  18. #include <linux/string.h>
  19. #include <linux/kexec.h>
  20. #include <linux/module.h>
  21. #include <asm/page.h>
  22. #include <asm/e820.h>
  23. #include <asm/proto.h>
  24. #include <asm/bootsetup.h>
  25. #include <asm/sections.h>
  26. /*
  27. * PFN of last memory page.
  28. */
  29. unsigned long end_pfn;
  30. EXPORT_SYMBOL(end_pfn);
  31. /*
  32. * end_pfn only includes RAM, while end_pfn_map includes all e820 entries.
  33. * The direct mapping extends to end_pfn_map, so that we can directly access
  34. * apertures, ACPI and other tables without having to play with fixmaps.
  35. */
  36. unsigned long end_pfn_map;
  37. /*
  38. * Last pfn which the user wants to use.
  39. */
  40. unsigned long end_user_pfn = MAXMEM>>PAGE_SHIFT;
  41. extern struct resource code_resource, data_resource;
  42. /* Check for some hardcoded bad areas that early boot is not allowed to touch */
  43. static inline int bad_addr(unsigned long *addrp, unsigned long size)
  44. {
  45. unsigned long addr = *addrp, last = addr + size;
  46. /* various gunk below that needed for SMP startup */
  47. if (addr < 0x8000) {
  48. *addrp = 0x8000;
  49. return 1;
  50. }
  51. /* direct mapping tables of the kernel */
  52. if (last >= table_start<<PAGE_SHIFT && addr < table_end<<PAGE_SHIFT) {
  53. *addrp = table_end << PAGE_SHIFT;
  54. return 1;
  55. }
  56. /* initrd */
  57. #ifdef CONFIG_BLK_DEV_INITRD
  58. if (LOADER_TYPE && INITRD_START && last >= INITRD_START &&
  59. addr < INITRD_START+INITRD_SIZE) {
  60. *addrp = INITRD_START + INITRD_SIZE;
  61. return 1;
  62. }
  63. #endif
  64. /* kernel code + 640k memory hole (later should not be needed, but
  65. be paranoid for now) */
  66. if (last >= 640*1024 && addr < __pa_symbol(&_end)) {
  67. *addrp = __pa_symbol(&_end);
  68. return 1;
  69. }
  70. if (last >= ebda_addr && addr < ebda_addr + ebda_size) {
  71. *addrp = ebda_addr + ebda_size;
  72. return 1;
  73. }
  74. /* XXX ramdisk image here? */
  75. return 0;
  76. }
  77. /*
  78. * This function checks if any part of the range <start,end> is mapped
  79. * with type.
  80. */
  81. int __meminit
  82. e820_any_mapped(unsigned long start, unsigned long end, unsigned type)
  83. {
  84. int i;
  85. for (i = 0; i < e820.nr_map; i++) {
  86. struct e820entry *ei = &e820.map[i];
  87. if (type && ei->type != type)
  88. continue;
  89. if (ei->addr >= end || ei->addr + ei->size <= start)
  90. continue;
  91. return 1;
  92. }
  93. return 0;
  94. }
  95. /*
  96. * This function checks if the entire range <start,end> is mapped with type.
  97. *
  98. * Note: this function only works correct if the e820 table is sorted and
  99. * not-overlapping, which is the case
  100. */
  101. int __init e820_all_mapped(unsigned long start, unsigned long end, unsigned type)
  102. {
  103. int i;
  104. for (i = 0; i < e820.nr_map; i++) {
  105. struct e820entry *ei = &e820.map[i];
  106. if (type && ei->type != type)
  107. continue;
  108. /* is the region (part) in overlap with the current region ?*/
  109. if (ei->addr >= end || ei->addr + ei->size <= start)
  110. continue;
  111. /* if the region is at the beginning of <start,end> we move
  112. * start to the end of the region since it's ok until there
  113. */
  114. if (ei->addr <= start)
  115. start = ei->addr + ei->size;
  116. /* if start is now at or beyond end, we're done, full coverage */
  117. if (start >= end)
  118. return 1; /* we're done */
  119. }
  120. return 0;
  121. }
  122. /*
  123. * Find a free area in a specific range.
  124. */
  125. unsigned long __init find_e820_area(unsigned long start, unsigned long end, unsigned size)
  126. {
  127. int i;
  128. for (i = 0; i < e820.nr_map; i++) {
  129. struct e820entry *ei = &e820.map[i];
  130. unsigned long addr = ei->addr, last;
  131. if (ei->type != E820_RAM)
  132. continue;
  133. if (addr < start)
  134. addr = start;
  135. if (addr > ei->addr + ei->size)
  136. continue;
  137. while (bad_addr(&addr, size) && addr+size < ei->addr + ei->size)
  138. ;
  139. last = addr + size;
  140. if (last > ei->addr + ei->size)
  141. continue;
  142. if (last > end)
  143. continue;
  144. return addr;
  145. }
  146. return -1UL;
  147. }
  148. /*
  149. * Free bootmem based on the e820 table for a node.
  150. */
  151. void __init e820_bootmem_free(pg_data_t *pgdat, unsigned long start,unsigned long end)
  152. {
  153. int i;
  154. for (i = 0; i < e820.nr_map; i++) {
  155. struct e820entry *ei = &e820.map[i];
  156. unsigned long last, addr;
  157. if (ei->type != E820_RAM ||
  158. ei->addr+ei->size <= start ||
  159. ei->addr >= end)
  160. continue;
  161. addr = round_up(ei->addr, PAGE_SIZE);
  162. if (addr < start)
  163. addr = start;
  164. last = round_down(ei->addr + ei->size, PAGE_SIZE);
  165. if (last >= end)
  166. last = end;
  167. if (last > addr && last-addr >= PAGE_SIZE)
  168. free_bootmem_node(pgdat, addr, last-addr);
  169. }
  170. }
  171. /*
  172. * Find the highest page frame number we have available
  173. */
  174. unsigned long __init e820_end_of_ram(void)
  175. {
  176. int i;
  177. unsigned long end_pfn = 0;
  178. for (i = 0; i < e820.nr_map; i++) {
  179. struct e820entry *ei = &e820.map[i];
  180. unsigned long start, end;
  181. start = round_up(ei->addr, PAGE_SIZE);
  182. end = round_down(ei->addr + ei->size, PAGE_SIZE);
  183. if (start >= end)
  184. continue;
  185. if (ei->type == E820_RAM) {
  186. if (end > end_pfn<<PAGE_SHIFT)
  187. end_pfn = end>>PAGE_SHIFT;
  188. } else {
  189. if (end > end_pfn_map<<PAGE_SHIFT)
  190. end_pfn_map = end>>PAGE_SHIFT;
  191. }
  192. }
  193. if (end_pfn > end_pfn_map)
  194. end_pfn_map = end_pfn;
  195. if (end_pfn_map > MAXMEM>>PAGE_SHIFT)
  196. end_pfn_map = MAXMEM>>PAGE_SHIFT;
  197. if (end_pfn > end_user_pfn)
  198. end_pfn = end_user_pfn;
  199. if (end_pfn > end_pfn_map)
  200. end_pfn = end_pfn_map;
  201. return end_pfn;
  202. }
  203. /*
  204. * Compute how much memory is missing in a range.
  205. * Unlike the other functions in this file the arguments are in page numbers.
  206. */
  207. unsigned long __init
  208. e820_hole_size(unsigned long start_pfn, unsigned long end_pfn)
  209. {
  210. unsigned long ram = 0;
  211. unsigned long start = start_pfn << PAGE_SHIFT;
  212. unsigned long end = end_pfn << PAGE_SHIFT;
  213. int i;
  214. for (i = 0; i < e820.nr_map; i++) {
  215. struct e820entry *ei = &e820.map[i];
  216. unsigned long last, addr;
  217. if (ei->type != E820_RAM ||
  218. ei->addr+ei->size <= start ||
  219. ei->addr >= end)
  220. continue;
  221. addr = round_up(ei->addr, PAGE_SIZE);
  222. if (addr < start)
  223. addr = start;
  224. last = round_down(ei->addr + ei->size, PAGE_SIZE);
  225. if (last >= end)
  226. last = end;
  227. if (last > addr)
  228. ram += last - addr;
  229. }
  230. return ((end - start) - ram) >> PAGE_SHIFT;
  231. }
  232. /*
  233. * Mark e820 reserved areas as busy for the resource manager.
  234. */
  235. void __init e820_reserve_resources(void)
  236. {
  237. int i;
  238. for (i = 0; i < e820.nr_map; i++) {
  239. struct resource *res;
  240. res = alloc_bootmem_low(sizeof(struct resource));
  241. switch (e820.map[i].type) {
  242. case E820_RAM: res->name = "System RAM"; break;
  243. case E820_ACPI: res->name = "ACPI Tables"; break;
  244. case E820_NVS: res->name = "ACPI Non-volatile Storage"; break;
  245. default: res->name = "reserved";
  246. }
  247. res->start = e820.map[i].addr;
  248. res->end = res->start + e820.map[i].size - 1;
  249. res->flags = IORESOURCE_MEM | IORESOURCE_BUSY;
  250. request_resource(&iomem_resource, res);
  251. if (e820.map[i].type == E820_RAM) {
  252. /*
  253. * We don't know which RAM region contains kernel data,
  254. * so we try it repeatedly and let the resource manager
  255. * test it.
  256. */
  257. request_resource(res, &code_resource);
  258. request_resource(res, &data_resource);
  259. #ifdef CONFIG_KEXEC
  260. request_resource(res, &crashk_res);
  261. #endif
  262. }
  263. }
  264. }
  265. /*
  266. * Add a memory region to the kernel e820 map.
  267. */
  268. void __init add_memory_region(unsigned long start, unsigned long size, int type)
  269. {
  270. int x = e820.nr_map;
  271. if (x == E820MAX) {
  272. printk(KERN_ERR "Ooops! Too many entries in the memory map!\n");
  273. return;
  274. }
  275. e820.map[x].addr = start;
  276. e820.map[x].size = size;
  277. e820.map[x].type = type;
  278. e820.nr_map++;
  279. }
  280. void __init e820_print_map(char *who)
  281. {
  282. int i;
  283. for (i = 0; i < e820.nr_map; i++) {
  284. printk(" %s: %016Lx - %016Lx ", who,
  285. (unsigned long long) e820.map[i].addr,
  286. (unsigned long long) (e820.map[i].addr + e820.map[i].size));
  287. switch (e820.map[i].type) {
  288. case E820_RAM: printk("(usable)\n");
  289. break;
  290. case E820_RESERVED:
  291. printk("(reserved)\n");
  292. break;
  293. case E820_ACPI:
  294. printk("(ACPI data)\n");
  295. break;
  296. case E820_NVS:
  297. printk("(ACPI NVS)\n");
  298. break;
  299. default: printk("type %u\n", e820.map[i].type);
  300. break;
  301. }
  302. }
  303. }
  304. /*
  305. * Sanitize the BIOS e820 map.
  306. *
  307. * Some e820 responses include overlapping entries. The following
  308. * replaces the original e820 map with a new one, removing overlaps.
  309. *
  310. */
  311. static int __init sanitize_e820_map(struct e820entry * biosmap, char * pnr_map)
  312. {
  313. struct change_member {
  314. struct e820entry *pbios; /* pointer to original bios entry */
  315. unsigned long long addr; /* address for this change point */
  316. };
  317. static struct change_member change_point_list[2*E820MAX] __initdata;
  318. static struct change_member *change_point[2*E820MAX] __initdata;
  319. static struct e820entry *overlap_list[E820MAX] __initdata;
  320. static struct e820entry new_bios[E820MAX] __initdata;
  321. struct change_member *change_tmp;
  322. unsigned long current_type, last_type;
  323. unsigned long long last_addr;
  324. int chgidx, still_changing;
  325. int overlap_entries;
  326. int new_bios_entry;
  327. int old_nr, new_nr, chg_nr;
  328. int i;
  329. /*
  330. Visually we're performing the following (1,2,3,4 = memory types)...
  331. Sample memory map (w/overlaps):
  332. ____22__________________
  333. ______________________4_
  334. ____1111________________
  335. _44_____________________
  336. 11111111________________
  337. ____________________33__
  338. ___________44___________
  339. __________33333_________
  340. ______________22________
  341. ___________________2222_
  342. _________111111111______
  343. _____________________11_
  344. _________________4______
  345. Sanitized equivalent (no overlap):
  346. 1_______________________
  347. _44_____________________
  348. ___1____________________
  349. ____22__________________
  350. ______11________________
  351. _________1______________
  352. __________3_____________
  353. ___________44___________
  354. _____________33_________
  355. _______________2________
  356. ________________1_______
  357. _________________4______
  358. ___________________2____
  359. ____________________33__
  360. ______________________4_
  361. */
  362. /* if there's only one memory region, don't bother */
  363. if (*pnr_map < 2)
  364. return -1;
  365. old_nr = *pnr_map;
  366. /* bail out if we find any unreasonable addresses in bios map */
  367. for (i=0; i<old_nr; i++)
  368. if (biosmap[i].addr + biosmap[i].size < biosmap[i].addr)
  369. return -1;
  370. /* create pointers for initial change-point information (for sorting) */
  371. for (i=0; i < 2*old_nr; i++)
  372. change_point[i] = &change_point_list[i];
  373. /* record all known change-points (starting and ending addresses),
  374. omitting those that are for empty memory regions */
  375. chgidx = 0;
  376. for (i=0; i < old_nr; i++) {
  377. if (biosmap[i].size != 0) {
  378. change_point[chgidx]->addr = biosmap[i].addr;
  379. change_point[chgidx++]->pbios = &biosmap[i];
  380. change_point[chgidx]->addr = biosmap[i].addr + biosmap[i].size;
  381. change_point[chgidx++]->pbios = &biosmap[i];
  382. }
  383. }
  384. chg_nr = chgidx;
  385. /* sort change-point list by memory addresses (low -> high) */
  386. still_changing = 1;
  387. while (still_changing) {
  388. still_changing = 0;
  389. for (i=1; i < chg_nr; i++) {
  390. /* if <current_addr> > <last_addr>, swap */
  391. /* or, if current=<start_addr> & last=<end_addr>, swap */
  392. if ((change_point[i]->addr < change_point[i-1]->addr) ||
  393. ((change_point[i]->addr == change_point[i-1]->addr) &&
  394. (change_point[i]->addr == change_point[i]->pbios->addr) &&
  395. (change_point[i-1]->addr != change_point[i-1]->pbios->addr))
  396. )
  397. {
  398. change_tmp = change_point[i];
  399. change_point[i] = change_point[i-1];
  400. change_point[i-1] = change_tmp;
  401. still_changing=1;
  402. }
  403. }
  404. }
  405. /* create a new bios memory map, removing overlaps */
  406. overlap_entries=0; /* number of entries in the overlap table */
  407. new_bios_entry=0; /* index for creating new bios map entries */
  408. last_type = 0; /* start with undefined memory type */
  409. last_addr = 0; /* start with 0 as last starting address */
  410. /* loop through change-points, determining affect on the new bios map */
  411. for (chgidx=0; chgidx < chg_nr; chgidx++)
  412. {
  413. /* keep track of all overlapping bios entries */
  414. if (change_point[chgidx]->addr == change_point[chgidx]->pbios->addr)
  415. {
  416. /* add map entry to overlap list (> 1 entry implies an overlap) */
  417. overlap_list[overlap_entries++]=change_point[chgidx]->pbios;
  418. }
  419. else
  420. {
  421. /* remove entry from list (order independent, so swap with last) */
  422. for (i=0; i<overlap_entries; i++)
  423. {
  424. if (overlap_list[i] == change_point[chgidx]->pbios)
  425. overlap_list[i] = overlap_list[overlap_entries-1];
  426. }
  427. overlap_entries--;
  428. }
  429. /* if there are overlapping entries, decide which "type" to use */
  430. /* (larger value takes precedence -- 1=usable, 2,3,4,4+=unusable) */
  431. current_type = 0;
  432. for (i=0; i<overlap_entries; i++)
  433. if (overlap_list[i]->type > current_type)
  434. current_type = overlap_list[i]->type;
  435. /* continue building up new bios map based on this information */
  436. if (current_type != last_type) {
  437. if (last_type != 0) {
  438. new_bios[new_bios_entry].size =
  439. change_point[chgidx]->addr - last_addr;
  440. /* move forward only if the new size was non-zero */
  441. if (new_bios[new_bios_entry].size != 0)
  442. if (++new_bios_entry >= E820MAX)
  443. break; /* no more space left for new bios entries */
  444. }
  445. if (current_type != 0) {
  446. new_bios[new_bios_entry].addr = change_point[chgidx]->addr;
  447. new_bios[new_bios_entry].type = current_type;
  448. last_addr=change_point[chgidx]->addr;
  449. }
  450. last_type = current_type;
  451. }
  452. }
  453. new_nr = new_bios_entry; /* retain count for new bios entries */
  454. /* copy new bios mapping into original location */
  455. memcpy(biosmap, new_bios, new_nr*sizeof(struct e820entry));
  456. *pnr_map = new_nr;
  457. return 0;
  458. }
  459. /*
  460. * Copy the BIOS e820 map into a safe place.
  461. *
  462. * Sanity-check it while we're at it..
  463. *
  464. * If we're lucky and live on a modern system, the setup code
  465. * will have given us a memory map that we can use to properly
  466. * set up memory. If we aren't, we'll fake a memory map.
  467. *
  468. * We check to see that the memory map contains at least 2 elements
  469. * before we'll use it, because the detection code in setup.S may
  470. * not be perfect and most every PC known to man has two memory
  471. * regions: one from 0 to 640k, and one from 1mb up. (The IBM
  472. * thinkpad 560x, for example, does not cooperate with the memory
  473. * detection code.)
  474. */
  475. static int __init copy_e820_map(struct e820entry * biosmap, int nr_map)
  476. {
  477. /* Only one memory region (or negative)? Ignore it */
  478. if (nr_map < 2)
  479. return -1;
  480. do {
  481. unsigned long start = biosmap->addr;
  482. unsigned long size = biosmap->size;
  483. unsigned long end = start + size;
  484. unsigned long type = biosmap->type;
  485. /* Overflow in 64 bits? Ignore the memory map. */
  486. if (start > end)
  487. return -1;
  488. /*
  489. * Some BIOSes claim RAM in the 640k - 1M region.
  490. * Not right. Fix it up.
  491. *
  492. * This should be removed on Hammer which is supposed to not
  493. * have non e820 covered ISA mappings there, but I had some strange
  494. * problems so it stays for now. -AK
  495. */
  496. if (type == E820_RAM) {
  497. if (start < 0x100000ULL && end > 0xA0000ULL) {
  498. if (start < 0xA0000ULL)
  499. add_memory_region(start, 0xA0000ULL-start, type);
  500. if (end <= 0x100000ULL)
  501. continue;
  502. start = 0x100000ULL;
  503. size = end - start;
  504. }
  505. }
  506. add_memory_region(start, size, type);
  507. } while (biosmap++,--nr_map);
  508. return 0;
  509. }
  510. void __init setup_memory_region(void)
  511. {
  512. char *who = "BIOS-e820";
  513. /*
  514. * Try to copy the BIOS-supplied E820-map.
  515. *
  516. * Otherwise fake a memory map; one section from 0k->640k,
  517. * the next section from 1mb->appropriate_mem_k
  518. */
  519. sanitize_e820_map(E820_MAP, &E820_MAP_NR);
  520. if (copy_e820_map(E820_MAP, E820_MAP_NR) < 0) {
  521. unsigned long mem_size;
  522. /* compare results from other methods and take the greater */
  523. if (ALT_MEM_K < EXT_MEM_K) {
  524. mem_size = EXT_MEM_K;
  525. who = "BIOS-88";
  526. } else {
  527. mem_size = ALT_MEM_K;
  528. who = "BIOS-e801";
  529. }
  530. e820.nr_map = 0;
  531. add_memory_region(0, LOWMEMSIZE(), E820_RAM);
  532. add_memory_region(HIGH_MEMORY, mem_size << 10, E820_RAM);
  533. }
  534. printk(KERN_INFO "BIOS-provided physical RAM map:\n");
  535. e820_print_map(who);
  536. }
  537. void __init parse_memopt(char *p, char **from)
  538. {
  539. end_user_pfn = memparse(p, from);
  540. end_user_pfn >>= PAGE_SHIFT;
  541. }
  542. void __init parse_memmapopt(char *p, char **from)
  543. {
  544. unsigned long long start_at, mem_size;
  545. mem_size = memparse(p, from);
  546. p = *from;
  547. if (*p == '@') {
  548. start_at = memparse(p+1, from);
  549. add_memory_region(start_at, mem_size, E820_RAM);
  550. } else if (*p == '#') {
  551. start_at = memparse(p+1, from);
  552. add_memory_region(start_at, mem_size, E820_ACPI);
  553. } else if (*p == '$') {
  554. start_at = memparse(p+1, from);
  555. add_memory_region(start_at, mem_size, E820_RESERVED);
  556. } else {
  557. end_user_pfn = (mem_size >> PAGE_SHIFT);
  558. }
  559. p = *from;
  560. }
  561. unsigned long pci_mem_start = 0xaeedbabe;
  562. /*
  563. * Search for the biggest gap in the low 32 bits of the e820
  564. * memory space. We pass this space to PCI to assign MMIO resources
  565. * for hotplug or unconfigured devices in.
  566. * Hopefully the BIOS let enough space left.
  567. */
  568. __init void e820_setup_gap(void)
  569. {
  570. unsigned long gapstart, gapsize, round;
  571. unsigned long last;
  572. int i;
  573. int found = 0;
  574. last = 0x100000000ull;
  575. gapstart = 0x10000000;
  576. gapsize = 0x400000;
  577. i = e820.nr_map;
  578. while (--i >= 0) {
  579. unsigned long long start = e820.map[i].addr;
  580. unsigned long long end = start + e820.map[i].size;
  581. /*
  582. * Since "last" is at most 4GB, we know we'll
  583. * fit in 32 bits if this condition is true
  584. */
  585. if (last > end) {
  586. unsigned long gap = last - end;
  587. if (gap > gapsize) {
  588. gapsize = gap;
  589. gapstart = end;
  590. found = 1;
  591. }
  592. }
  593. if (start < last)
  594. last = start;
  595. }
  596. if (!found) {
  597. gapstart = (end_pfn << PAGE_SHIFT) + 1024*1024;
  598. printk(KERN_ERR "PCI: Warning: Cannot find a gap in the 32bit address range\n"
  599. KERN_ERR "PCI: Unassigned devices with 32bit resource registers may break!\n");
  600. }
  601. /*
  602. * See how much we want to round up: start off with
  603. * rounding to the next 1MB area.
  604. */
  605. round = 0x100000;
  606. while ((gapsize >> 4) > round)
  607. round += round;
  608. /* Fun with two's complement */
  609. pci_mem_start = (gapstart + round) & -round;
  610. printk(KERN_INFO "Allocating PCI resources starting at %lx (gap: %lx:%lx)\n",
  611. pci_mem_start, gapstart, gapsize);
  612. }