ia64/xen-unstable

view linux-2.6-xen-sparse/arch/x86_64/kernel/e820-xen.c @ 13647:057c4c2991fa

32-on-64: Fix an one-off error in compat_addr_ok().
Signed-off-by: Jan Beulich <jbeulich@novell.com>
author kaf24@localhost.localdomain
date Fri Jan 26 13:36:52 2007 +0000 (2007-01-26)
parents 3adf00179a63
children beab19d957de
line source
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>
20 #include <asm/pgtable.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 #include <xen/interface/memory.h>
28 /*
29 * PFN of last memory page.
30 */
31 unsigned long end_pfn;
32 EXPORT_SYMBOL(end_pfn);
34 /*
35 * end_pfn only includes RAM, while end_pfn_map includes all e820 entries.
36 * The direct mapping extends to end_pfn_map, so that we can directly access
37 * apertures, ACPI and other tables without having to play with fixmaps.
38 */
39 unsigned long end_pfn_map;
41 /*
42 * Last pfn which the user wants to use.
43 */
44 unsigned long end_user_pfn = MAXMEM>>PAGE_SHIFT;
46 extern struct resource code_resource, data_resource;
48 /* Check for some hardcoded bad areas that early boot is not allowed to touch */
49 static inline int bad_addr(unsigned long *addrp, unsigned long size)
50 {
51 unsigned long addr = *addrp, last = addr + size;
53 #ifndef CONFIG_XEN
54 /* various gunk below that needed for SMP startup */
55 if (addr < 0x8000) {
56 *addrp = 0x8000;
57 return 1;
58 }
60 /* direct mapping tables of the kernel */
61 if (last >= table_start<<PAGE_SHIFT && addr < table_end<<PAGE_SHIFT) {
62 *addrp = table_end << PAGE_SHIFT;
63 return 1;
64 }
66 /* initrd */
67 #ifdef CONFIG_BLK_DEV_INITRD
68 if (LOADER_TYPE && INITRD_START && last >= INITRD_START &&
69 addr < INITRD_START+INITRD_SIZE) {
70 *addrp = INITRD_START + INITRD_SIZE;
71 return 1;
72 }
73 #endif
74 /* kernel code + 640k memory hole (later should not be needed, but
75 be paranoid for now) */
76 if (last >= 640*1024 && addr < 1024*1024) {
77 *addrp = 1024*1024;
78 return 1;
79 }
80 if (last >= __pa_symbol(&_text) && last < __pa_symbol(&_end)) {
81 *addrp = __pa_symbol(&_end);
82 return 1;
83 }
85 if (last >= ebda_addr && addr < ebda_addr + ebda_size) {
86 *addrp = ebda_addr + ebda_size;
87 return 1;
88 }
90 /* XXX ramdisk image here? */
91 #else
92 if (last < (table_end<<PAGE_SHIFT)) {
93 *addrp = table_end << PAGE_SHIFT;
94 return 1;
95 }
96 #endif
97 return 0;
98 }
100 #ifndef CONFIG_XEN
101 /*
102 * This function checks if any part of the range <start,end> is mapped
103 * with type.
104 */
105 int __meminit
106 e820_any_mapped(unsigned long start, unsigned long end, unsigned type)
107 {
108 int i;
109 for (i = 0; i < e820.nr_map; i++) {
110 struct e820entry *ei = &e820.map[i];
111 if (type && ei->type != type)
112 continue;
113 if (ei->addr >= end || ei->addr + ei->size <= start)
114 continue;
115 return 1;
116 }
117 return 0;
118 }
119 #endif
121 /*
122 * This function checks if the entire range <start,end> is mapped with type.
123 *
124 * Note: this function only works correct if the e820 table is sorted and
125 * not-overlapping, which is the case
126 */
127 int __init e820_all_mapped(unsigned long start, unsigned long end, unsigned type)
128 {
129 int i;
130 for (i = 0; i < e820.nr_map; i++) {
131 struct e820entry *ei = &e820.map[i];
132 if (type && ei->type != type)
133 continue;
134 /* is the region (part) in overlap with the current region ?*/
135 if (ei->addr >= end || ei->addr + ei->size <= start)
136 continue;
138 /* if the region is at the beginning of <start,end> we move
139 * start to the end of the region since it's ok until there
140 */
141 if (ei->addr <= start)
142 start = ei->addr + ei->size;
143 /* if start is now at or beyond end, we're done, full coverage */
144 if (start >= end)
145 return 1; /* we're done */
146 }
147 return 0;
148 }
150 /*
151 * Find a free area in a specific range.
152 */
153 unsigned long __init find_e820_area(unsigned long start, unsigned long end, unsigned size)
154 {
155 int i;
156 for (i = 0; i < e820.nr_map; i++) {
157 struct e820entry *ei = &e820.map[i];
158 unsigned long addr = ei->addr, last;
159 if (ei->type != E820_RAM)
160 continue;
161 if (addr < start)
162 addr = start;
163 if (addr > ei->addr + ei->size)
164 continue;
165 while (bad_addr(&addr, size) && addr+size <= ei->addr+ei->size)
166 ;
167 last = addr + size;
168 if (last > ei->addr + ei->size)
169 continue;
170 if (last > end)
171 continue;
172 return addr;
173 }
174 return -1UL;
175 }
177 /*
178 * Free bootmem based on the e820 table for a node.
179 */
180 void __init e820_bootmem_free(pg_data_t *pgdat, unsigned long start,unsigned long end)
181 {
182 int i;
183 for (i = 0; i < e820.nr_map; i++) {
184 struct e820entry *ei = &e820.map[i];
185 unsigned long last, addr;
187 if (ei->type != E820_RAM ||
188 ei->addr+ei->size <= start ||
189 ei->addr >= end)
190 continue;
192 addr = round_up(ei->addr, PAGE_SIZE);
193 if (addr < start)
194 addr = start;
196 last = round_down(ei->addr + ei->size, PAGE_SIZE);
197 if (last >= end)
198 last = end;
200 if (last > addr && last-addr >= PAGE_SIZE)
201 free_bootmem_node(pgdat, addr, last-addr);
202 }
203 }
205 /*
206 * Find the highest page frame number we have available
207 */
208 unsigned long __init e820_end_of_ram(void)
209 {
210 int i;
211 unsigned long end_pfn = 0;
213 for (i = 0; i < e820.nr_map; i++) {
214 struct e820entry *ei = &e820.map[i];
215 unsigned long start, end;
217 start = round_up(ei->addr, PAGE_SIZE);
218 end = round_down(ei->addr + ei->size, PAGE_SIZE);
219 if (start >= end)
220 continue;
221 if (ei->type == E820_RAM) {
222 if (end > end_pfn<<PAGE_SHIFT)
223 end_pfn = end>>PAGE_SHIFT;
224 } else {
225 if (end > end_pfn_map<<PAGE_SHIFT)
226 end_pfn_map = end>>PAGE_SHIFT;
227 }
228 }
230 if (end_pfn > end_pfn_map)
231 end_pfn_map = end_pfn;
232 if (end_pfn_map > MAXMEM>>PAGE_SHIFT)
233 end_pfn_map = MAXMEM>>PAGE_SHIFT;
234 if (end_pfn > end_user_pfn)
235 end_pfn = end_user_pfn;
236 if (end_pfn > end_pfn_map)
237 end_pfn = end_pfn_map;
239 return end_pfn;
240 }
242 /*
243 * Compute how much memory is missing in a range.
244 * Unlike the other functions in this file the arguments are in page numbers.
245 */
246 unsigned long __init
247 e820_hole_size(unsigned long start_pfn, unsigned long end_pfn)
248 {
249 unsigned long ram = 0;
250 unsigned long start = start_pfn << PAGE_SHIFT;
251 unsigned long end = end_pfn << PAGE_SHIFT;
252 int i;
253 for (i = 0; i < e820.nr_map; i++) {
254 struct e820entry *ei = &e820.map[i];
255 unsigned long last, addr;
257 if (ei->type != E820_RAM ||
258 ei->addr+ei->size <= start ||
259 ei->addr >= end)
260 continue;
262 addr = round_up(ei->addr, PAGE_SIZE);
263 if (addr < start)
264 addr = start;
266 last = round_down(ei->addr + ei->size, PAGE_SIZE);
267 if (last >= end)
268 last = end;
270 if (last > addr)
271 ram += last - addr;
272 }
273 return ((end - start) - ram) >> PAGE_SHIFT;
274 }
276 /*
277 * Mark e820 reserved areas as busy for the resource manager.
278 */
279 void __init e820_reserve_resources(struct e820entry *e820, int nr_map)
280 {
281 int i;
282 for (i = 0; i < nr_map; i++) {
283 struct resource *res;
284 res = alloc_bootmem_low(sizeof(struct resource));
285 switch (e820[i].type) {
286 case E820_RAM: res->name = "System RAM"; break;
287 case E820_ACPI: res->name = "ACPI Tables"; break;
288 case E820_NVS: res->name = "ACPI Non-volatile Storage"; break;
289 default: res->name = "reserved";
290 }
291 res->start = e820[i].addr;
292 res->end = res->start + e820[i].size - 1;
293 res->flags = IORESOURCE_MEM | IORESOURCE_BUSY;
294 request_resource(&iomem_resource, res);
295 if (e820[i].type == E820_RAM) {
296 /*
297 * We don't know which RAM region contains kernel data,
298 * so we try it repeatedly and let the resource manager
299 * test it.
300 */
301 #ifndef CONFIG_XEN
302 request_resource(res, &code_resource);
303 request_resource(res, &data_resource);
304 #endif
305 #ifdef CONFIG_KEXEC
306 if (crashk_res.start != crashk_res.end)
307 request_resource(res, &crashk_res);
308 #ifdef CONFIG_XEN
309 xen_machine_kexec_register_resources(res);
310 #endif
311 #endif
312 }
313 }
314 }
316 /*
317 * Add a memory region to the kernel e820 map.
318 */
319 void __init add_memory_region(unsigned long start, unsigned long size, int type)
320 {
321 int x = e820.nr_map;
323 if (x == E820MAX) {
324 printk(KERN_ERR "Ooops! Too many entries in the memory map!\n");
325 return;
326 }
328 e820.map[x].addr = start;
329 e820.map[x].size = size;
330 e820.map[x].type = type;
331 e820.nr_map++;
332 }
334 void __init e820_print_map(char *who)
335 {
336 int i;
338 for (i = 0; i < e820.nr_map; i++) {
339 printk(" %s: %016Lx - %016Lx ", who,
340 (unsigned long long) e820.map[i].addr,
341 (unsigned long long) (e820.map[i].addr + e820.map[i].size));
342 switch (e820.map[i].type) {
343 case E820_RAM: printk("(usable)\n");
344 break;
345 case E820_RESERVED:
346 printk("(reserved)\n");
347 break;
348 case E820_ACPI:
349 printk("(ACPI data)\n");
350 break;
351 case E820_NVS:
352 printk("(ACPI NVS)\n");
353 break;
354 default: printk("type %u\n", e820.map[i].type);
355 break;
356 }
357 }
358 }
360 /*
361 * Sanitize the BIOS e820 map.
362 *
363 * Some e820 responses include overlapping entries. The following
364 * replaces the original e820 map with a new one, removing overlaps.
365 *
366 */
367 static int __init sanitize_e820_map(struct e820entry * biosmap, char * pnr_map)
368 {
369 struct change_member {
370 struct e820entry *pbios; /* pointer to original bios entry */
371 unsigned long long addr; /* address for this change point */
372 };
373 static struct change_member change_point_list[2*E820MAX] __initdata;
374 static struct change_member *change_point[2*E820MAX] __initdata;
375 static struct e820entry *overlap_list[E820MAX] __initdata;
376 static struct e820entry new_bios[E820MAX] __initdata;
377 struct change_member *change_tmp;
378 unsigned long current_type, last_type;
379 unsigned long long last_addr;
380 int chgidx, still_changing;
381 int overlap_entries;
382 int new_bios_entry;
383 int old_nr, new_nr, chg_nr;
384 int i;
386 /*
387 Visually we're performing the following (1,2,3,4 = memory types)...
389 Sample memory map (w/overlaps):
390 ____22__________________
391 ______________________4_
392 ____1111________________
393 _44_____________________
394 11111111________________
395 ____________________33__
396 ___________44___________
397 __________33333_________
398 ______________22________
399 ___________________2222_
400 _________111111111______
401 _____________________11_
402 _________________4______
404 Sanitized equivalent (no overlap):
405 1_______________________
406 _44_____________________
407 ___1____________________
408 ____22__________________
409 ______11________________
410 _________1______________
411 __________3_____________
412 ___________44___________
413 _____________33_________
414 _______________2________
415 ________________1_______
416 _________________4______
417 ___________________2____
418 ____________________33__
419 ______________________4_
420 */
422 /* if there's only one memory region, don't bother */
423 if (*pnr_map < 2)
424 return -1;
426 old_nr = *pnr_map;
428 /* bail out if we find any unreasonable addresses in bios map */
429 for (i=0; i<old_nr; i++)
430 if (biosmap[i].addr + biosmap[i].size < biosmap[i].addr)
431 return -1;
433 /* create pointers for initial change-point information (for sorting) */
434 for (i=0; i < 2*old_nr; i++)
435 change_point[i] = &change_point_list[i];
437 /* record all known change-points (starting and ending addresses),
438 omitting those that are for empty memory regions */
439 chgidx = 0;
440 for (i=0; i < old_nr; i++) {
441 if (biosmap[i].size != 0) {
442 change_point[chgidx]->addr = biosmap[i].addr;
443 change_point[chgidx++]->pbios = &biosmap[i];
444 change_point[chgidx]->addr = biosmap[i].addr + biosmap[i].size;
445 change_point[chgidx++]->pbios = &biosmap[i];
446 }
447 }
448 chg_nr = chgidx;
450 /* sort change-point list by memory addresses (low -> high) */
451 still_changing = 1;
452 while (still_changing) {
453 still_changing = 0;
454 for (i=1; i < chg_nr; i++) {
455 /* if <current_addr> > <last_addr>, swap */
456 /* or, if current=<start_addr> & last=<end_addr>, swap */
457 if ((change_point[i]->addr < change_point[i-1]->addr) ||
458 ((change_point[i]->addr == change_point[i-1]->addr) &&
459 (change_point[i]->addr == change_point[i]->pbios->addr) &&
460 (change_point[i-1]->addr != change_point[i-1]->pbios->addr))
461 )
462 {
463 change_tmp = change_point[i];
464 change_point[i] = change_point[i-1];
465 change_point[i-1] = change_tmp;
466 still_changing=1;
467 }
468 }
469 }
471 /* create a new bios memory map, removing overlaps */
472 overlap_entries=0; /* number of entries in the overlap table */
473 new_bios_entry=0; /* index for creating new bios map entries */
474 last_type = 0; /* start with undefined memory type */
475 last_addr = 0; /* start with 0 as last starting address */
476 /* loop through change-points, determining affect on the new bios map */
477 for (chgidx=0; chgidx < chg_nr; chgidx++)
478 {
479 /* keep track of all overlapping bios entries */
480 if (change_point[chgidx]->addr == change_point[chgidx]->pbios->addr)
481 {
482 /* add map entry to overlap list (> 1 entry implies an overlap) */
483 overlap_list[overlap_entries++]=change_point[chgidx]->pbios;
484 }
485 else
486 {
487 /* remove entry from list (order independent, so swap with last) */
488 for (i=0; i<overlap_entries; i++)
489 {
490 if (overlap_list[i] == change_point[chgidx]->pbios)
491 overlap_list[i] = overlap_list[overlap_entries-1];
492 }
493 overlap_entries--;
494 }
495 /* if there are overlapping entries, decide which "type" to use */
496 /* (larger value takes precedence -- 1=usable, 2,3,4,4+=unusable) */
497 current_type = 0;
498 for (i=0; i<overlap_entries; i++)
499 if (overlap_list[i]->type > current_type)
500 current_type = overlap_list[i]->type;
501 /* continue building up new bios map based on this information */
502 if (current_type != last_type) {
503 if (last_type != 0) {
504 new_bios[new_bios_entry].size =
505 change_point[chgidx]->addr - last_addr;
506 /* move forward only if the new size was non-zero */
507 if (new_bios[new_bios_entry].size != 0)
508 if (++new_bios_entry >= E820MAX)
509 break; /* no more space left for new bios entries */
510 }
511 if (current_type != 0) {
512 new_bios[new_bios_entry].addr = change_point[chgidx]->addr;
513 new_bios[new_bios_entry].type = current_type;
514 last_addr=change_point[chgidx]->addr;
515 }
516 last_type = current_type;
517 }
518 }
519 new_nr = new_bios_entry; /* retain count for new bios entries */
521 /* copy new bios mapping into original location */
522 memcpy(biosmap, new_bios, new_nr*sizeof(struct e820entry));
523 *pnr_map = new_nr;
525 return 0;
526 }
528 /*
529 * Copy the BIOS e820 map into a safe place.
530 *
531 * Sanity-check it while we're at it..
532 *
533 * If we're lucky and live on a modern system, the setup code
534 * will have given us a memory map that we can use to properly
535 * set up memory. If we aren't, we'll fake a memory map.
536 *
537 * We check to see that the memory map contains at least 2 elements
538 * before we'll use it, because the detection code in setup.S may
539 * not be perfect and most every PC known to man has two memory
540 * regions: one from 0 to 640k, and one from 1mb up. (The IBM
541 * thinkpad 560x, for example, does not cooperate with the memory
542 * detection code.)
543 */
544 static int __init copy_e820_map(struct e820entry * biosmap, int nr_map)
545 {
546 #ifndef CONFIG_XEN
547 /* Only one memory region (or negative)? Ignore it */
548 if (nr_map < 2)
549 return -1;
550 #else
551 BUG_ON(nr_map < 1);
552 #endif
554 do {
555 unsigned long start = biosmap->addr;
556 unsigned long size = biosmap->size;
557 unsigned long end = start + size;
558 unsigned long type = biosmap->type;
560 /* Overflow in 64 bits? Ignore the memory map. */
561 if (start > end)
562 return -1;
564 #ifndef CONFIG_XEN
565 /*
566 * Some BIOSes claim RAM in the 640k - 1M region.
567 * Not right. Fix it up.
568 *
569 * This should be removed on Hammer which is supposed to not
570 * have non e820 covered ISA mappings there, but I had some strange
571 * problems so it stays for now. -AK
572 */
573 if (type == E820_RAM) {
574 if (start < 0x100000ULL && end > 0xA0000ULL) {
575 if (start < 0xA0000ULL)
576 add_memory_region(start, 0xA0000ULL-start, type);
577 if (end <= 0x100000ULL)
578 continue;
579 start = 0x100000ULL;
580 size = end - start;
581 }
582 }
583 #endif
585 add_memory_region(start, size, type);
586 } while (biosmap++,--nr_map);
587 return 0;
588 }
590 #ifndef CONFIG_XEN
591 void __init setup_memory_region(void)
592 {
593 char *who = "BIOS-e820";
595 /*
596 * Try to copy the BIOS-supplied E820-map.
597 *
598 * Otherwise fake a memory map; one section from 0k->640k,
599 * the next section from 1mb->appropriate_mem_k
600 */
601 sanitize_e820_map(E820_MAP, &E820_MAP_NR);
602 if (copy_e820_map(E820_MAP, E820_MAP_NR) < 0) {
603 unsigned long mem_size;
605 /* compare results from other methods and take the greater */
606 if (ALT_MEM_K < EXT_MEM_K) {
607 mem_size = EXT_MEM_K;
608 who = "BIOS-88";
609 } else {
610 mem_size = ALT_MEM_K;
611 who = "BIOS-e801";
612 }
614 e820.nr_map = 0;
615 add_memory_region(0, LOWMEMSIZE(), E820_RAM);
616 add_memory_region(HIGH_MEMORY, mem_size << 10, E820_RAM);
617 }
618 printk(KERN_INFO "BIOS-provided physical RAM map:\n");
619 e820_print_map(who);
620 }
622 #else /* CONFIG_XEN */
624 void __init setup_memory_region(void)
625 {
626 int rc;
627 struct xen_memory_map memmap;
628 /*
629 * This is rather large for a stack variable but this early in
630 * the boot process we know we have plenty slack space.
631 */
632 struct e820entry map[E820MAX];
634 memmap.nr_entries = E820MAX;
635 set_xen_guest_handle(memmap.buffer, map);
637 rc = HYPERVISOR_memory_op(XENMEM_memory_map, &memmap);
638 if ( rc == -ENOSYS ) {
639 memmap.nr_entries = 1;
640 map[0].addr = 0ULL;
641 map[0].size = xen_start_info->nr_pages << PAGE_SHIFT;
642 /* 8MB slack (to balance backend allocations). */
643 map[0].size += 8 << 20;
644 map[0].type = E820_RAM;
645 rc = 0;
646 }
647 BUG_ON(rc);
649 sanitize_e820_map(map, (char *)&memmap.nr_entries);
651 BUG_ON(copy_e820_map(map, (char)memmap.nr_entries) < 0);
653 printk(KERN_INFO "BIOS-provided physical RAM map:\n");
654 e820_print_map("Xen");
655 }
656 #endif
658 void __init parse_memopt(char *p, char **from)
659 {
660 int i;
661 unsigned long current_end;
662 unsigned long end;
664 end_user_pfn = memparse(p, from);
665 end_user_pfn >>= PAGE_SHIFT;
667 end = end_user_pfn<<PAGE_SHIFT;
668 i = e820.nr_map-1;
669 current_end = e820.map[i].addr + e820.map[i].size;
671 if (current_end < end) {
672 /*
673 * The e820 map ends before our requested size so
674 * extend the final entry to the requested address.
675 */
676 if (e820.map[i].type == E820_RAM)
677 e820.map[i].size = end - e820.map[i].addr;
678 else
679 add_memory_region(current_end, end - current_end, E820_RAM);
680 }
681 }
683 void __init parse_memmapopt(char *p, char **from)
684 {
685 unsigned long long start_at, mem_size;
687 mem_size = memparse(p, from);
688 p = *from;
689 if (*p == '@') {
690 start_at = memparse(p+1, from);
691 add_memory_region(start_at, mem_size, E820_RAM);
692 } else if (*p == '#') {
693 start_at = memparse(p+1, from);
694 add_memory_region(start_at, mem_size, E820_ACPI);
695 } else if (*p == '$') {
696 start_at = memparse(p+1, from);
697 add_memory_region(start_at, mem_size, E820_RESERVED);
698 } else {
699 end_user_pfn = (mem_size >> PAGE_SHIFT);
700 }
701 p = *from;
702 }
704 unsigned long pci_mem_start = 0xaeedbabe;
705 EXPORT_SYMBOL(pci_mem_start);
707 /*
708 * Search for the biggest gap in the low 32 bits of the e820
709 * memory space. We pass this space to PCI to assign MMIO resources
710 * for hotplug or unconfigured devices in.
711 * Hopefully the BIOS let enough space left.
712 */
713 __init void e820_setup_gap(struct e820entry *e820, int nr_map)
714 {
715 unsigned long gapstart, gapsize, round;
716 unsigned long last;
717 int i;
718 int found = 0;
720 last = 0x100000000ull;
721 gapstart = 0x10000000;
722 gapsize = 0x400000;
723 i = nr_map;
724 while (--i >= 0) {
725 unsigned long long start = e820[i].addr;
726 unsigned long long end = start + e820[i].size;
728 /*
729 * Since "last" is at most 4GB, we know we'll
730 * fit in 32 bits if this condition is true
731 */
732 if (last > end) {
733 unsigned long gap = last - end;
735 if (gap > gapsize) {
736 gapsize = gap;
737 gapstart = end;
738 found = 1;
739 }
740 }
741 if (start < last)
742 last = start;
743 }
745 if (!found) {
746 gapstart = (end_pfn << PAGE_SHIFT) + 1024*1024;
747 printk(KERN_ERR "PCI: Warning: Cannot find a gap in the 32bit address range\n"
748 KERN_ERR "PCI: Unassigned devices with 32bit resource registers may break!\n");
749 }
751 /*
752 * See how much we want to round up: start off with
753 * rounding to the next 1MB area.
754 */
755 round = 0x100000;
756 while ((gapsize >> 4) > round)
757 round += round;
758 /* Fun with two's complement */
759 pci_mem_start = (gapstart + round) & -round;
761 printk(KERN_INFO "Allocating PCI resources starting at %lx (gap: %lx:%lx)\n",
762 pci_mem_start, gapstart, gapsize);
763 }