} MAP_INFO;\r
\r
//\r
-// List of MAP_INFO structures recycled by Unmap().\r
+// List of the MAP_INFO structures that have been set up by IoMmuMap() and not\r
+// yet torn down by IoMmuUnmap(). The list represents the full set of mappings\r
+// currently in effect.\r
//\r
-// Recycled MAP_INFO structures are equally good for future recycling and\r
-// freeing.\r
-//\r
-STATIC LIST_ENTRY mRecycledMapInfos = INITIALIZE_LIST_HEAD_VARIABLE (\r
- mRecycledMapInfos\r
- );\r
+STATIC LIST_ENTRY mMapInfos = INITIALIZE_LIST_HEAD_VARIABLE (mMapInfos);\r
\r
#define COMMON_BUFFER_SIG SIGNATURE_64 ('C', 'M', 'N', 'B', 'U', 'F', 'F', 'R')\r
\r
)\r
{\r
EFI_STATUS Status;\r
- LIST_ENTRY *RecycledMapInfo;\r
MAP_INFO *MapInfo;\r
EFI_ALLOCATE_TYPE AllocateType;\r
COMMON_BUFFER_HEADER *CommonBufferHeader;\r
// Allocate a MAP_INFO structure to remember the mapping when Unmap() is\r
// called later.\r
//\r
- RecycledMapInfo = GetFirstNode (&mRecycledMapInfos);\r
- if (RecycledMapInfo == &mRecycledMapInfos) {\r
- //\r
- // No recycled MAP_INFO structure, allocate a new one.\r
- //\r
- MapInfo = AllocatePool (sizeof (MAP_INFO));\r
- if (MapInfo == NULL) {\r
- Status = EFI_OUT_OF_RESOURCES;\r
- goto Failed;\r
- }\r
- } else {\r
- MapInfo = CR (RecycledMapInfo, MAP_INFO, Link, MAP_INFO_SIG);\r
- RemoveEntryList (RecycledMapInfo);\r
+ MapInfo = AllocatePool (sizeof (MAP_INFO));\r
+ if (MapInfo == NULL) {\r
+ Status = EFI_OUT_OF_RESOURCES;\r
+ goto Failed;\r
}\r
\r
//\r
);\r
}\r
\r
+ //\r
+ // Track all MAP_INFO structures.\r
+ //\r
+ InsertHeadList (&mMapInfos, &MapInfo->Link);\r
//\r
// Populate output parameters.\r
//\r
CommonBufferHeader->StashBuffer,\r
MapInfo->NumberOfBytes\r
);\r
-\r
- //\r
- // Recycle the MAP_INFO structure.\r
- //\r
- InsertTailList (&mRecycledMapInfos, &MapInfo->Link);\r
} else {\r
ZeroMem (\r
(VOID *)(UINTN)MapInfo->PlainTextAddress,\r
EFI_PAGES_TO_SIZE (MapInfo->NumberOfPages)\r
);\r
gBS->FreePages (MapInfo->PlainTextAddress, MapInfo->NumberOfPages);\r
-\r
- //\r
- // Free the MAP_INFO structure.\r
- //\r
- FreePool (MapInfo);\r
}\r
\r
+ //\r
+ // Forget and free the MAP_INFO structure.\r
+ //\r
+ RemoveEntryList (&MapInfo->Link);\r
+ FreePool (MapInfo);\r
+\r
return EFI_SUCCESS;\r
}\r
\r