e820.c 18 KB

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