PEIM to produce gPeiUsb2HostControllerPpiGuid based on gPeiUsbControllerPpiGuid\r
which is used to enable recovery function from USB Drivers.\r
\r
-Copyright (c) 2014 - 2015, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2014 - 2016, 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
)\r
{\r
USBHC_MEM_BLOCK *Block;\r
+ VOID *BufHost;\r
+ VOID *Mapping;\r
+ EFI_PHYSICAL_ADDRESS MappedAddr;\r
EFI_STATUS Status;\r
UINTN PageNumber;\r
EFI_PHYSICAL_ADDRESS TempPtr;\r
\r
Block->Bits = (UINT8 *) (UINTN) TempPtr;\r
\r
- Status = PeiServicesAllocatePages (\r
- EfiBootServicesData,\r
+ Status = IoMmuAllocateBuffer (\r
Pages,\r
- &TempPtr\r
+ &BufHost,\r
+ &MappedAddr,\r
+ &Mapping\r
);\r
if (EFI_ERROR (Status)) {\r
return NULL;\r
}\r
- ZeroMem ((VOID *) (UINTN) TempPtr, EFI_PAGES_TO_SIZE (Pages));\r
+ ZeroMem ((VOID *) (UINTN) BufHost, EFI_PAGES_TO_SIZE (Pages));\r
\r
- Block->BufHost = (UINT8 *) (UINTN) TempPtr;;\r
- Block->Buf = (UINT8 *) (UINTN) TempPtr;\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
{\r
ASSERT ((Pool != NULL) && (Block != NULL));\r
+\r
+ IoMmuFreeBuffer (EFI_SIZE_TO_PAGES (Block->BufLen), Block->BufHost, Block->Mapping);\r
+\r
//\r
// No free memory in PEI.\r
//\r
return TRUE;\r
}\r
\r
-/**\r
- Unlink the memory block from the pool's list.\r
-\r
- @param Head The block list head of the memory's pool.\r
- @param BlockToUnlink The memory block to unlink.\r
\r
-**/\r
-VOID\r
-UsbHcUnlinkMemBlock (\r
- IN USBHC_MEM_BLOCK *Head,\r
- IN USBHC_MEM_BLOCK *BlockToUnlink\r
- )\r
-{\r
- USBHC_MEM_BLOCK *Block;\r
-\r
- ASSERT ((Head != NULL) && (BlockToUnlink != NULL));\r
-\r
- for (Block = Head; Block != NULL; Block = Block->Next) {\r
- if (Block->Next == BlockToUnlink) {\r
- Block->Next = BlockToUnlink->Next;\r
- BlockToUnlink->Next = NULL;\r
- break;\r
- }\r
- }\r
-}\r
\r
/**\r
Initialize the memory management pool for the host controller.\r
Bit = ((ToFree - Block->BufHost) / USBHC_MEM_UNIT) % 8;\r
\r
//\r
- // reset associated bits in bit arry\r
+ // reset associated bits in bit array\r
//\r
for (Count = 0; Count < (AllocSize / USBHC_MEM_UNIT); Count++) {\r
ASSERT (USB_HC_BIT_IS_SET (Block->Bits[Byte], Bit));\r
@param HostAddress The system memory address to map to the PCI controller.\r
@param DeviceAddress The resulting map address for the bus master PCI controller to\r
use to access the hosts HostAddress.\r
+ @param Mapping A resulting value to pass to Unmap().\r
\r
@retval EFI_SUCCESS Success to allocate aligned pages.\r
@retval EFI_INVALID_PARAMETER Pages or Alignment is not valid.\r
IN UINTN Pages,\r
IN UINTN Alignment,\r
OUT VOID **HostAddress,\r
- OUT EFI_PHYSICAL_ADDRESS *DeviceAddress\r
+ OUT EFI_PHYSICAL_ADDRESS *DeviceAddress,\r
+ OUT VOID **Mapping\r
)\r
{\r
EFI_STATUS Status;\r
- EFI_PHYSICAL_ADDRESS Memory;\r
+ VOID *Memory;\r
UINTN AlignedMemory;\r
UINTN AlignmentMask;\r
+ EFI_PHYSICAL_ADDRESS DeviceMemory;\r
+ UINTN AlignedDeviceMemory;\r
UINTN RealPages;\r
\r
//\r
//\r
ASSERT (RealPages > Pages);\r
\r
- Status = PeiServicesAllocatePages (\r
- EfiBootServicesData,\r
+ Status = IoMmuAllocateBuffer (\r
Pages,\r
- &Memory\r
+ &Memory,\r
+ &DeviceMemory,\r
+ Mapping\r
);\r
if (EFI_ERROR (Status)) {\r
return EFI_OUT_OF_RESOURCES;\r
}\r
AlignedMemory = ((UINTN) Memory + AlignmentMask) & ~AlignmentMask;\r
+ AlignedDeviceMemory = ((UINTN) DeviceMemory + AlignmentMask) & ~AlignmentMask;\r
} else {\r
//\r
// Do not over-allocate pages in this case.\r
//\r
- Status = PeiServicesAllocatePages (\r
- EfiBootServicesData,\r
+ Status = IoMmuAllocateBuffer (\r
Pages,\r
- &Memory\r
+ &Memory,\r
+ &DeviceMemory,\r
+ Mapping\r
);\r
if (EFI_ERROR (Status)) {\r
return EFI_OUT_OF_RESOURCES;\r
}\r
AlignedMemory = (UINTN) Memory;\r
+ AlignedDeviceMemory = (UINTN) DeviceMemory;\r
}\r
\r
*HostAddress = (VOID *) AlignedMemory;\r
- *DeviceAddress = (EFI_PHYSICAL_ADDRESS) AlignedMemory;\r
+ *DeviceAddress = (EFI_PHYSICAL_ADDRESS) AlignedDeviceMemory;\r
\r
return EFI_SUCCESS;\r
}\r
\r
@param HostAddress The system memory address to map to the PCI controller.\r
@param Pages The number of pages to free.\r
+ @param Mapping The mapping value returned from Map().\r
\r
**/\r
VOID\r
UsbHcFreeAlignedPages (\r
IN VOID *HostAddress,\r
- IN UINTN Pages\r
+ IN UINTN Pages,\r
+ IN VOID *Mapping\r
)\r
{\r
ASSERT (Pages != 0);\r
- //\r
- // No free memory in PEI.\r
- //\r
+\r
+ IoMmuFreeBuffer (Pages, HostAddress, Mapping);\r
}\r
\r