e820.c 18 KB

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