18 "BootServicesCode (BS_code)",
19 "BootServicesData (BS_data)",
20 "RuntimeServicesCode (RT_code)",
21 "RuntimeServicesData (RT_Data)",
22 "ConventionalMemory (available)",
24 "ACPIReclaimMemory (ACPI_recl)",
25 "ACPIMemoryNVS (ACPI_NVS)",
27 "MemoryMappedIOPortSpace",
43 UINTN MemAttributesBuffSize,
46 gBS->SetMem(MemAttributesBuff, MemAttributesBuffSize, 0);
49 AsciiSPrint(MemAttributesBuff, MemAttributesBuffSize-1,
"%a EFI_MEMORY_UC |", MemAttributesBuff);
51 AsciiSPrint(MemAttributesBuff, MemAttributesBuffSize-1,
"%a EFI_MEMORY_WC |", MemAttributesBuff);
53 AsciiSPrint(MemAttributesBuff, MemAttributesBuffSize-1,
"%a EFI_MEMORY_WT |", MemAttributesBuff);
55 AsciiSPrint(MemAttributesBuff, MemAttributesBuffSize-1,
"%a EFI_MEMORY_WB |", MemAttributesBuff);
57 AsciiSPrint(MemAttributesBuff, MemAttributesBuffSize-1,
"%a EFI_MEMORY_UCE |", MemAttributesBuff);
59 AsciiSPrint(MemAttributesBuff, MemAttributesBuffSize-1,
"%a EFI_MEMORY_WP |", MemAttributesBuff);
61 AsciiSPrint(MemAttributesBuff, MemAttributesBuffSize-1,
"%a EFI_MEMORY_RP |", MemAttributesBuff);
63 AsciiSPrint(MemAttributesBuff, MemAttributesBuffSize-1,
"%a EFI_MEMORY_XP |", MemAttributesBuff);
65 AsciiSPrint(MemAttributesBuff, MemAttributesBuffSize-1,
"%a EFI_MEMORY_RUNTIME |", MemAttributesBuff);
75 #if USE_DXE_SERVICES == 1
77 EFI_GCD_MEMORY_SPACE_DESCRIPTOR GcdDescriptor;
79 Status = gDS->GetMemorySpaceDescriptor(BaseAddress, &GcdDescriptor);
81 if (EFI_ERROR(Status))
84 LogFullAscii(
"%a: error GetMemorySpaceDescriptor returned %08x\r\n",
85 __FUNCTION__, Status);
91 MemEntry->BaseAddress = GcdDescriptor.BaseAddress;
92 MemEntry->Capabilities = GcdDescriptor.Capabilities;
93 MemEntry->GcdMemoryType = GcdDescriptor.GcdMemoryType;
94 MemEntry->Length = GcdDescriptor.Length;
95 MemEntry->ImageHandle = GcdDescriptor.ImageHandle;
96 MemEntry->DeviceHandle = GcdDescriptor.DeviceHandle;
118 EFI_MEMORY_DESCRIPTOR *MemoryMap;
120 UINTN DescriptorSize;
121 UINT32 DescriptorVersion;
125 EFI_MEMORY_DESCRIPTOR *EfiMemoryMapEnd;
126 EFI_MEMORY_DESCRIPTOR *EfiEntry;
127 EFI_MEMORY_DESCRIPTOR *NextEfiEntry;
138 Status = gBS->GetMemoryMap(&MemoryMapSize,
144 if (Status == EFI_BUFFER_TOO_SMALL)
148 LogFullAscii(
"%a: Buffer to small, need = 0x%08x(%d) bytes\r\n",
149 __FUNCTION__, MemoryMapSize, MemoryMapSize);
153 Pages = EFI_SIZE_TO_PAGES(MemoryMapSize);
164 Status = gBS->GetMemoryMap(
172 if (EFI_ERROR(Status))
175 LogFullAscii(
"%a: GetMemoryMap returned unknown error (2nd time), status = %08d\r\n",
176 __FUNCTION__, Status);
184 LogFullAscii(
"%a: GetMemoryMap returned unknown error, status = %08x \n",
185 __FUNCTION__, Status);
193 LogFullAscii(
"%a: Memory map recevied, processing!\r\n", __FUNCTION__);
198 EfiEntry = MemoryMap;
199 NextEfiEntry = NEXT_MEMORY_DESCRIPTOR(EfiEntry, DescriptorSize);
200 EfiMemoryMapEnd = (EFI_MEMORY_DESCRIPTOR*)((UINT8*)MemoryMap + MemoryMapSize);
202 #define NUM_OF_MAP_ENTRIES ((MemoryMapSize / DescriptorSize)+1)
210 LogFullAscii(
"%a: unable to allocate memory for MemMap\r\n",
223 LogFullAscii(
"%a: unable to allocate memory for MemMapEntry\r\n",
237 MemMapEntry[i].
Type = EfiEntry->Type;
241 MemMapEntry[i].
Attributes = EfiEntry->Attribute;
244 EfiEntry = NEXT_MEMORY_DESCRIPTOR(EfiEntry, DescriptorSize);
253 #undef NUM_OF_MAP_ENTRIES
297 #if USE_DXE_SERVICES == 1
299 EFI_GCD_MEMORY_SPACE_DESCRIPTOR *MemSpaceMap;
300 UINTN i, NumOfDescriptors;
303 Status = gDS->GetMemorySpaceMap(&NumOfDescriptors, &MemSpaceMap);
305 if (EFI_ERROR(Status))
309 __FUNCTION__, Status);
316 for (i = 0; i < NumOfDescriptors; i++)
318 LogFullAscii(
"%08d: BaseAddr=%016lx Length=%016lx Attributes=%016lx\r\n",
319 i, MemSpaceMap[i].BaseAddress, MemSpaceMap[i].Length, MemSpaceMap[i].Attributes);
344 EFI_PHYSICAL_ADDRESS Address)
348 EFI_PHYSICAL_ADDRESS PhysEnd;
359 if ((Address >= MapEntry->
PhysicalStart) && (Address < PhysEnd))
386 CHAR8 Attributes[256];
387 CHAR16 DmpFilePath[512];
392 return EFI_NOT_FOUND;
403 LogFullAscii(
"%08d: PhysStart=%016lx PhysEnd=%016lx NumOfPages=%08llx VirtualStart=%016lx Attributes=%016lx (%a) Type=%08x (%a)\r\n",
415 #if USE_DXE_SERVICES == 1
416 LogFullAscii(
"%08d: GcdLength=%08llx GcdMemoryType=%08x GcdBaseAddr=%016lx ImageHandle=%08x\r\n",
419 MapEntry->GcdMemoryType,
420 MapEntry->BaseAddress,
421 MapEntry->ImageHandle);
428 UnicodeSPrint(DmpFilePath,
sizeof(DmpFilePath)-1, L
"mdump\\%p.dmp",
431 LogFullAscii(
"%a: dumping to: %s \r\n", __FUNCTION__, DmpFilePath);
434 if (SkipType && ((MapEntry->
Type == SkipType) || (MapEntry->
Type == 0)))
436 LogFullAscii(
"%a: not dumping this entry to disk (type skipped)\r\n",
452 #if USE_DXE_SERVICES == 1