\r
\r
\r
-//\r
-// Assume all of memory has the same cache attributes, unless we do our magic\r
-//\r
-UINT64 gAttributes;\r
-\r
typedef struct {\r
EFI_PHYSICAL_ADDRESS Base;\r
VOID *Allocation;\r
EFI_MEMORY_TYPE MemoryType;\r
BOOLEAN Allocated;\r
LIST_ENTRY Link;\r
+ UINT64 Attributes;\r
} FREE_PAGE_NODE;\r
\r
STATIC LIST_ENTRY mPageList = INITIALIZE_LIST_HEAD_VARIABLE (mPageList);\r
}\r
\r
Status = gDS->GetMemorySpaceDescriptor (Memory, &Descriptor);\r
- if (!EFI_ERROR (Status)) {\r
- // We are making an assumption that all of memory has the same default attributes\r
- gAttributes = Descriptor.Attributes;\r
- } else {\r
+ if (EFI_ERROR (Status)) {\r
gBS->FreePages (Memory, Pages);\r
return Status;\r
}\r
NewNode->Pages = Pages;\r
NewNode->Allocated = TRUE;\r
NewNode->MemoryType = MemoryType;\r
+ NewNode->Attributes = Descriptor.Attributes;\r
\r
InsertTailList (&mPageList, &NewNode->Link);\r
\r
// We only free the non-allocated buffer\r
if (OldNode->Allocated == FALSE) {\r
gBS->FreePages ((EFI_PHYSICAL_ADDRESS)(UINTN)OldNode->Base, OldNode->Pages);\r
+\r
+ gDS->SetMemorySpaceAttributes ((EFI_PHYSICAL_ADDRESS)(UINTN)OldNode->Base,\r
+ EFI_PAGES_TO_SIZE (OldNode->Pages), OldNode->Attributes);\r
+\r
RemoveEntryList (&OldNode->Link);\r
FreePool (OldNode);\r
}\r