TianoCore EDK2 master
Loading...
Searching...
No Matches
UsbHcMem.c File Reference
#include "XhcPeim.h"

Go to the source code of this file.

Functions

USBHC_MEM_BLOCKUsbHcAllocMemBlock (IN UINTN Pages)
 
VOID UsbHcFreeMemBlock (IN USBHC_MEM_POOL *Pool, IN USBHC_MEM_BLOCK *Block)
 
VOID * UsbHcAllocMemFromBlock (IN USBHC_MEM_BLOCK *Block, IN UINTN Units)
 
EFI_PHYSICAL_ADDRESS UsbHcGetPciAddrForHostAddr (IN USBHC_MEM_POOL *Pool, IN VOID *Mem, IN UINTN Size, IN BOOLEAN Alignment)
 
EFI_PHYSICAL_ADDRESS UsbHcGetHostAddrForPciAddr (IN USBHC_MEM_POOL *Pool, IN VOID *Mem, IN UINTN Size, IN BOOLEAN Alignment)
 
VOID UsbHcInsertMemBlockToPool (IN USBHC_MEM_BLOCK *Head, IN USBHC_MEM_BLOCK *Block)
 
BOOLEAN UsbHcIsMemBlockEmpty (IN USBHC_MEM_BLOCK *Block)
 
USBHC_MEM_POOLUsbHcInitMemPool (VOID)
 
VOID UsbHcUnlinkMemBlock (IN USBHC_MEM_BLOCK *Head, IN USBHC_MEM_BLOCK *BlockToUnlink)
 
VOID UsbHcFreeMemPool (IN USBHC_MEM_POOL *Pool)
 
VOID * UsbHcAllocateMem (IN USBHC_MEM_POOL *Pool, IN UINTN Size)
 
VOID UsbHcFreeMem (IN USBHC_MEM_POOL *Pool, IN VOID *Mem, IN UINTN Size)
 
EFI_STATUS UsbHcAllocateAlignedPages (IN UINTN Pages, IN UINTN Alignment, OUT VOID **HostAddress, OUT EFI_PHYSICAL_ADDRESS *DeviceAddress, OUT VOID **Mapping)
 
VOID UsbHcFreeAlignedPages (IN VOID *HostAddress, IN UINTN Pages, IN VOID *Mapping)
 

Detailed Description

PEIM to produce gPeiUsb2HostControllerPpiGuid based on gPeiUsbControllerPpiGuid which is used to enable recovery function from USB Drivers.

Copyright (c) 2014 - 2016, Intel Corporation. All rights reserved.
Copyright (C) 2022 Advanced Micro Devices, Inc. All rights reserved.

SPDX-License-Identifier: BSD-2-Clause-Patent

Definition in file UsbHcMem.c.

Function Documentation

◆ UsbHcAllocateAlignedPages()

EFI_STATUS UsbHcAllocateAlignedPages ( IN UINTN  Pages,
IN UINTN  Alignment,
OUT VOID **  HostAddress,
OUT EFI_PHYSICAL_ADDRESS DeviceAddress,
OUT VOID **  Mapping 
)

Allocates pages at a specified alignment.

If Alignment is not a power of two and Alignment is not zero, then ASSERT().

Parameters
PagesThe number of pages to allocate.
AlignmentThe requested alignment of the allocation. Must be a power of two.
HostAddressThe system memory address to map to the PCI controller.
DeviceAddressThe resulting map address for the bus master PCI controller to use to access the hosts HostAddress.
MappingA resulting value to pass to Unmap().
Return values
EFI_SUCCESSSuccess to allocate aligned pages.
EFI_INVALID_PARAMETERPages or Alignment is not valid.
EFI_OUT_OF_RESOURCESDo not have enough resources to allocate memory.

Definition at line 597 of file UsbHcMem.c.

◆ UsbHcAllocateMem()

VOID * UsbHcAllocateMem ( IN USBHC_MEM_POOL Pool,
IN UINTN  Size 
)

Allocate some memory from the host controller's memory pool which can be used to communicate with host controller.

Parameters
PoolThe host controller's memory pool.
SizeSize of the memory to allocate.
Returns
The allocated memory or NULL.

Definition at line 446 of file UsbHcMem.c.

◆ UsbHcAllocMemBlock()

USBHC_MEM_BLOCK * UsbHcAllocMemBlock ( IN UINTN  Pages)

Allocate a block of memory to be used by the buffer pool.

Parameters
PagesHow many pages to allocate.
Returns
Pointer to the allocated memory block or NULL if failed.

Definition at line 23 of file UsbHcMem.c.

◆ UsbHcAllocMemFromBlock()

VOID * UsbHcAllocMemFromBlock ( IN USBHC_MEM_BLOCK Block,
IN UINTN  Units 
)

Alloc some memory from the block.

Parameters
BlockThe memory block to allocate memory from.
UnitsNumber of memory units to allocate.
Returns
The pointer to the allocated memory. If couldn't allocate the needed memory, the return value is NULL.

Definition at line 126 of file UsbHcMem.c.

◆ UsbHcFreeAlignedPages()

VOID UsbHcFreeAlignedPages ( IN VOID *  HostAddress,
IN UINTN  Pages,
IN VOID *  Mapping 
)

Frees memory that was allocated with UsbHcAllocateAlignedPages().

Parameters
HostAddressThe system memory address to map to the PCI controller.
PagesThe number of pages to free.
MappingThe mapping value returned from Map().

Definition at line 663 of file UsbHcMem.c.

◆ UsbHcFreeMem()

VOID UsbHcFreeMem ( IN USBHC_MEM_POOL Pool,
IN VOID *  Mem,
IN UINTN  Size 
)

Free the allocated memory back to the memory pool.

Parameters
PoolThe memory pool of the host controller.
MemThe memory to free.
SizeThe size of the memory to free.

Definition at line 519 of file UsbHcMem.c.

◆ UsbHcFreeMemBlock()

VOID UsbHcFreeMemBlock ( IN USBHC_MEM_POOL Pool,
IN USBHC_MEM_BLOCK Block 
)

Free the memory block from the memory pool.

Parameters
PoolThe memory pool to free the block from.
BlockThe memory block to free.

Definition at line 101 of file UsbHcMem.c.

◆ UsbHcFreeMemPool()

VOID UsbHcFreeMemPool ( IN USBHC_MEM_POOL Pool)

Release the memory management pool.

Parameters
PoolThe USB memory pool to free.

Definition at line 414 of file UsbHcMem.c.

◆ UsbHcGetHostAddrForPciAddr()

EFI_PHYSICAL_ADDRESS UsbHcGetHostAddrForPciAddr ( IN USBHC_MEM_POOL Pool,
IN VOID *  Mem,
IN UINTN  Size,
IN BOOLEAN  Alignment 
)

Calculate the corresponding host address according to the pci address.

Parameters
PoolThe memory pool of the host controller.
MemThe pointer to pci memory.
SizeThe size of the memory region.
AlignmentAlignment the size to USBHC_MEM_UNIT bytes.
Returns
The host memory address

Definition at line 254 of file UsbHcMem.c.

◆ UsbHcGetPciAddrForHostAddr()

EFI_PHYSICAL_ADDRESS UsbHcGetPciAddrForHostAddr ( IN USBHC_MEM_POOL Pool,
IN VOID *  Mem,
IN UINTN  Size,
IN BOOLEAN  Alignment 
)

Calculate the corresponding pci bus address according to the Mem parameter.

Parameters
PoolThe memory pool of the host controller.
MemThe pointer to host memory.
SizeThe size of the memory region.
AlignmentAlignment the size to USBHC_MEM_UNIT bytes.
Returns
The pci memory address

Definition at line 199 of file UsbHcMem.c.

◆ UsbHcInitMemPool()

USBHC_MEM_POOL * UsbHcInitMemPool ( VOID  )

Initialize the memory management pool for the host controller.

Returns
Pointer to the allocated memory pool or NULL if failed.

Definition at line 347 of file UsbHcMem.c.

◆ UsbHcInsertMemBlockToPool()

VOID UsbHcInsertMemBlockToPool ( IN USBHC_MEM_BLOCK Head,
IN USBHC_MEM_BLOCK Block 
)

Insert the memory block to the pool's list of the blocks.

Parameters
HeadThe head of the memory pool's block list.
BlockThe memory block to insert.

Definition at line 305 of file UsbHcMem.c.

◆ UsbHcIsMemBlockEmpty()

BOOLEAN UsbHcIsMemBlockEmpty ( IN USBHC_MEM_BLOCK Block)

Is the memory block empty?

Parameters
BlockThe memory block to check.
Return values
TRUEThe memory block is empty.
FALSEThe memory block isn't empty.

Definition at line 325 of file UsbHcMem.c.

◆ UsbHcUnlinkMemBlock()

VOID UsbHcUnlinkMemBlock ( IN USBHC_MEM_BLOCK Head,
IN USBHC_MEM_BLOCK BlockToUnlink 
)

Unlink the memory block from the pool's list.

Parameters
HeadThe block list head of the memory's pool.
BlockToUnlinkThe memory block to unlink.

Definition at line 389 of file UsbHcMem.c.