]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Bus/Ufs/UfsBlockIoPei/UfsHcMem.c
MdeModulePkg/UfsBlockIoPei: Support IoMmu
[mirror_edk2.git] / MdeModulePkg / Bus / Ufs / UfsBlockIoPei / UfsHcMem.c
index bf4079a4087457de637571d41bb3acbb097f52df..b9e3859b353e8de42c2226338e120477d10d5c33 100644 (file)
@@ -1,6 +1,6 @@
 /** @file\r
 \r
-Copyright (c) 2014 - 2016, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2014 - 2017, Intel Corporation. All rights reserved.<BR>\r
   \r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions\r
@@ -29,9 +29,11 @@ UfsPeimAllocMemBlock (
   )\r
 {\r
   UFS_PEIM_MEM_BLOCK           *Block;\r
+  VOID                         *BufHost;\r
+  VOID                         *Mapping;\r
+  EFI_PHYSICAL_ADDRESS         MappedAddr;\r
   EFI_STATUS                   Status;\r
   VOID                         *TempPtr;\r
-  EFI_PHYSICAL_ADDRESS         Address;\r
 \r
   TempPtr = NULL;\r
   Block   = NULL;\r
@@ -62,19 +64,22 @@ UfsPeimAllocMemBlock (
 \r
   Block->Bits = (UINT8*)(UINTN)TempPtr;\r
 \r
-  Status = PeiServicesAllocatePages (\r
-             EfiBootServicesCode,\r
+  Status = IoMmuAllocateBuffer (\r
              Pages,\r
-             &Address\r
+             &BufHost,\r
+             &MappedAddr,\r
+             &Mapping\r
              );\r
   if (EFI_ERROR (Status)) {\r
     return NULL;\r
   }\r
 \r
-  ZeroMem ((VOID*)(UINTN)Address, EFI_PAGES_TO_SIZE (Pages));\r
+  ZeroMem ((VOID*)(UINTN)BufHost, EFI_PAGES_TO_SIZE (Pages));\r
 \r
-  Block->Buf  = (UINT8*)((UINTN)Address);\r
-  Block->Next = NULL;\r
+  Block->BufHost = (UINT8 *) (UINTN) BufHost;\r
+  Block->Buf     = (UINT8 *) (UINTN) MappedAddr;\r
+  Block->Mapping = Mapping;\r
+  Block->Next    = NULL;\r
 \r
   return Block;\r
 }\r
@@ -93,6 +98,8 @@ UfsPeimFreeMemBlock (
   )\r
 {\r
   ASSERT ((Pool != NULL) && (Block != NULL));\r
+\r
+  IoMmuFreeBuffer (EFI_SIZE_TO_PAGES (Block->BufLen), Block->BufHost, Block->Mapping);\r
 }\r
 \r
 /**\r