e820.c 18 KB

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