- if ((rp->end + 1) == pmap_memory_regions[bank].base) {
- rp->end = pmap_memory_regions[bank].end;
- } else {
- ++rp;
- ++num_regions;
- rp->base = pmap_memory_regions[bank].base;
- rp->end = pmap_memory_regions[bank].end;
- rp->alloc = 0;
- }
+ base = (ppnum_t) (mptr->PhysicalStart >> I386_PGSHIFT);
+ num = (ppnum_t) mptr->NumberOfPages;
+ if (!num)
+ continue;
+
+ switch (mptr->Type)
+ {
+ // any kind of dram
+ case kEfiLoaderCode:
+ case kEfiLoaderData:
+ case kEfiBootServicesCode:
+ case kEfiBootServicesData:
+ case kEfiConventionalMemory:
+ case kEfiACPIReclaimMemory:
+ case kEfiACPIMemoryNVS:
+ case kEfiPalCode:
+
+ if (!num_banks || (base != (1 + dram_ranges[num_banks - 1].last_page)))
+ {
+ num_banks++;
+ if (num_banks >= MAX_BANKS)
+ break;
+ dram_ranges[num_banks - 1].first_page = base;
+ }
+ dram_ranges[num_banks - 1].last_page = base + num - 1;
+ break;
+
+ // runtime services will be restarted, so no save
+ case kEfiRuntimeServicesCode:
+ case kEfiRuntimeServicesData:
+ // non dram
+ case kEfiReservedMemoryType:
+ case kEfiUnusableMemory:
+ case kEfiMemoryMappedIO:
+ case kEfiMemoryMappedIOPortSpace:
+ default:
+ break;
+ }