summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
dcd39e0)
Cc: Jiewen Yao <jiewen.yao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
/** @file\r
BmDma related function\r
\r
/** @file\r
BmDma related function\r
\r
- Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>\r
+ Copyright (c) 2017 - 2018, Intel Corporation. All rights reserved.<BR>\r
This program and the accompanying materials\r
are licensed and made available under the terms and conditions of the BSD License\r
which accompanies this distribution. The full text of the license may be found at\r
This program and the accompanying materials\r
are licensed and made available under the terms and conditions of the BSD License\r
which accompanies this distribution. The full text of the license may be found at\r
-#include <PiDxe.h>\r
-\r
-#include <Protocol/IoMmu.h>\r
-\r
-#include <Library/BaseLib.h>\r
-#include <Library/DebugLib.h>\r
-#include <Library/BaseMemoryLib.h>\r
-#include <Library/MemoryAllocationLib.h>\r
-#include <Library/UefiBootServicesTableLib.h>\r
+#include "DmaProtection.h"\r
\r
// TBD: May make it a policy\r
#define DMA_MEMORY_TOP MAX_UINTN\r
\r
// TBD: May make it a policy\r
#define DMA_MEMORY_TOP MAX_UINTN\r
MAP_INFO *MapInfo;\r
EFI_PHYSICAL_ADDRESS DmaMemoryTop;\r
BOOLEAN NeedRemap;\r
MAP_INFO *MapInfo;\r
EFI_PHYSICAL_ADDRESS DmaMemoryTop;\r
BOOLEAN NeedRemap;\r
\r
if (NumberOfBytes == NULL || DeviceAddress == NULL ||\r
Mapping == NULL) {\r
\r
if (NumberOfBytes == NULL || DeviceAddress == NULL ||\r
Mapping == NULL) {\r
MapInfo->DeviceAddress = MapInfo->HostAddress;\r
}\r
\r
MapInfo->DeviceAddress = MapInfo->HostAddress;\r
}\r
\r
+ OriginalTpl = gBS->RaiseTPL (VTD_TPL_LEVEL);\r
InsertTailList (&gMaps, &MapInfo->Link);\r
InsertTailList (&gMaps, &MapInfo->Link);\r
+ gBS->RestoreTPL (OriginalTpl);\r
\r
//\r
// The DeviceAddress is the address of the maped buffer below 4GB\r
\r
//\r
// The DeviceAddress is the address of the maped buffer below 4GB\r
{\r
MAP_INFO *MapInfo;\r
LIST_ENTRY *Link;\r
{\r
MAP_INFO *MapInfo;\r
LIST_ENTRY *Link;\r
\r
DEBUG ((DEBUG_VERBOSE, "IoMmuUnmap: 0x%08x\n", Mapping));\r
\r
\r
DEBUG ((DEBUG_VERBOSE, "IoMmuUnmap: 0x%08x\n", Mapping));\r
\r
return EFI_INVALID_PARAMETER;\r
}\r
\r
return EFI_INVALID_PARAMETER;\r
}\r
\r
+ OriginalTpl = gBS->RaiseTPL (VTD_TPL_LEVEL);\r
MapInfo = NULL;\r
for (Link = GetFirstNode (&gMaps)\r
; !IsNull (&gMaps, Link)\r
MapInfo = NULL;\r
for (Link = GetFirstNode (&gMaps)\r
; !IsNull (&gMaps, Link)\r
// Mapping is not a valid value returned by Map()\r
//\r
if (MapInfo != Mapping) {\r
// Mapping is not a valid value returned by Map()\r
//\r
if (MapInfo != Mapping) {\r
+ gBS->RestoreTPL (OriginalTpl);\r
DEBUG ((DEBUG_ERROR, "IoMmuUnmap: %r\n", EFI_INVALID_PARAMETER));\r
return EFI_INVALID_PARAMETER;\r
}\r
RemoveEntryList (&MapInfo->Link);\r
DEBUG ((DEBUG_ERROR, "IoMmuUnmap: %r\n", EFI_INVALID_PARAMETER));\r
return EFI_INVALID_PARAMETER;\r
}\r
RemoveEntryList (&MapInfo->Link);\r
+ gBS->RestoreTPL (OriginalTpl);\r
\r
if (MapInfo->DeviceAddress != MapInfo->HostAddress) {\r
//\r
\r
if (MapInfo->DeviceAddress != MapInfo->HostAddress) {\r
//\r
\r
Status = gBS->CreateEventEx (\r
EVT_NOTIFY_SIGNAL,\r
\r
Status = gBS->CreateEventEx (\r
EVT_NOTIFY_SIGNAL,\r
AcpiNotificationFunc,\r
NULL,\r
&gEfiAcpi10TableGuid,\r
AcpiNotificationFunc,\r
NULL,\r
&gEfiAcpi10TableGuid,\r
\r
Status = gBS->CreateEventEx (\r
EVT_NOTIFY_SIGNAL,\r
\r
Status = gBS->CreateEventEx (\r
EVT_NOTIFY_SIGNAL,\r
AcpiNotificationFunc,\r
NULL,\r
&gEfiAcpi20TableGuid,\r
AcpiNotificationFunc,\r
NULL,\r
&gEfiAcpi20TableGuid,\r
#define ALIGN_VALUE_UP(Value, Alignment) (((Value) + (Alignment) - 1) & (~((Alignment) - 1)))\r
#define ALIGN_VALUE_LOW(Value, Alignment) ((Value) & (~((Alignment) - 1)))\r
\r
#define ALIGN_VALUE_UP(Value, Alignment) (((Value) + (Alignment) - 1) & (~((Alignment) - 1)))\r
#define ALIGN_VALUE_LOW(Value, Alignment) ((Value) & (~((Alignment) - 1)))\r
\r
+#define VTD_TPL_LEVEL TPL_NOTIFY\r
+\r
//\r
// This is the initial max PCI DATA number.\r
// The number may be enlarged later.\r
//\r
// This is the initial max PCI DATA number.\r
// The number may be enlarged later.\r
-#include <PiDxe.h>\r
-\r
-#include <Protocol/IoMmu.h>\r
-#include <Protocol/PciIo.h>\r
-\r
-#include <Library/IoLib.h>\r
-#include <Library/BaseLib.h>\r
-#include <Library/DebugLib.h>\r
-#include <Library/UefiBootServicesTableLib.h>\r
-\r
#include "DmaProtection.h"\r
\r
/**\r
#include "DmaProtection.h"\r
\r
/**\r
EFI_STATUS Status;\r
EFI_PHYSICAL_ADDRESS DeviceAddress;\r
UINTN NumberOfPages;\r
EFI_STATUS Status;\r
EFI_PHYSICAL_ADDRESS DeviceAddress;\r
UINTN NumberOfPages;\r
+ EFI_TPL OriginalTpl;\r
+\r
+ OriginalTpl = gBS->RaiseTPL (VTD_TPL_LEVEL);\r
\r
Status = GetDeviceInfoFromMapping (Mapping, &DeviceAddress, &NumberOfPages);\r
\r
Status = GetDeviceInfoFromMapping (Mapping, &DeviceAddress, &NumberOfPages);\r
- if (EFI_ERROR(Status)) {\r
- return Status;\r
+ if (!EFI_ERROR(Status)) {\r
+ Status = VTdSetAttribute (\r
+ This,\r
+ DeviceHandle,\r
+ DeviceAddress,\r
+ EFI_PAGES_TO_SIZE(NumberOfPages),\r
+ IoMmuAccess\r
+ );\r
- Status = VTdSetAttribute (\r
- This,\r
- DeviceHandle,\r
- DeviceAddress,\r
- EFI_PAGES_TO_SIZE(NumberOfPages),\r
- IoMmuAccess\r
- );\r
+\r
+ gBS->RestoreTPL (OriginalTpl);\r