resource.c 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #include <linux/ioport.h>
  2. #include <asm/e820.h>
  3. static void resource_clip(struct resource *res, resource_size_t start,
  4. resource_size_t end)
  5. {
  6. resource_size_t low = 0, high = 0;
  7. if (res->end < start || res->start > end)
  8. return; /* no conflict */
  9. if (res->start < start)
  10. low = start - res->start;
  11. if (res->end > end)
  12. high = res->end - end;
  13. /* Keep the area above or below the conflict, whichever is larger */
  14. if (low > high)
  15. res->end = start - 1;
  16. else
  17. res->start = end + 1;
  18. }
  19. static void remove_e820_regions(struct resource *avail)
  20. {
  21. int i;
  22. struct e820entry *entry;
  23. for (i = 0; i < e820.nr_map; i++) {
  24. entry = &e820.map[i];
  25. resource_clip(avail, entry->addr,
  26. entry->addr + entry->size - 1);
  27. }
  28. }
  29. void arch_remove_reservations(struct resource *avail)
  30. {
  31. /*
  32. * Trim out BIOS area (high 2MB) and E820 regions. We do not remove
  33. * the low 1MB unconditionally, as this area is needed for some ISA
  34. * cards requiring a memory range, e.g. the i82365 PCMCIA controller.
  35. */
  36. if (avail->flags & IORESOURCE_MEM) {
  37. resource_clip(avail, BIOS_ROM_BASE, BIOS_ROM_END);
  38. remove_e820_regions(avail);
  39. }
  40. }