TianoCore EDK2 master
|
#include "Xhci.h"
Go to the source code of this file.
Routine procedures for memory allocate/free.
Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
Definition in file UsbHcMem.c.
EFI_STATUS UsbHcAllocateAlignedPages | ( | IN EFI_PCI_IO_PROTOCOL * | PciIo, |
IN UINTN | Pages, | ||
IN UINTN | Alignment, | ||
OUT VOID ** | HostAddress, | ||
OUT EFI_PHYSICAL_ADDRESS * | DeviceAddress, | ||
OUT VOID ** | Mapping | ||
) |
Allocates pages at a specified alignment that are suitable for an EfiPciIoOperationBusMasterCommonBuffer mapping.
If Alignment is not a power of two and Alignment is not zero, then ASSERT().
PciIo | The PciIo that can be used to access the host controller. |
Pages | The number of pages to allocate. |
Alignment | The requested alignment of the allocation. Must be a power of two. |
HostAddress | The system memory address to map to the PCI controller. |
DeviceAddress | The resulting map address for the bus master PCI controller to use to access the hosts HostAddress. |
Mapping | A resulting value to pass to Unmap(). |
EFI_SUCCESS | Success to allocate aligned pages. |
EFI_INVALID_PARAMETER | Pages or Alignment is not valid. |
EFI_OUT_OF_RESOURCES | Do not have enough resources to allocate memory. |
Definition at line 637 of file UsbHcMem.c.
VOID * UsbHcAllocateMem | ( | IN USBHC_MEM_POOL * | Pool, |
IN UINTN | Size, | ||
IN BOOLEAN | AllocationForRing | ||
) |
Allocate some memory from the host controller's memory pool which can be used to communicate with host controller.
Pool | The host controller's memory pool. |
Size | Size of the memory to allocate. |
AllocationForRing | The allocated memory is for Ring or not. |
Definition at line 480 of file UsbHcMem.c.
USBHC_MEM_BLOCK * UsbHcAllocMemBlock | ( | IN USBHC_MEM_POOL * | Pool, |
IN UINTN | Pages | ||
) |
Allocate a block of memory to be used by the buffer pool.
Pool | The buffer pool to allocate memory for. |
Pages | How many pages to allocate. |
Definition at line 22 of file UsbHcMem.c.
VOID * UsbHcAllocMemFromBlock | ( | IN USBHC_MEM_BLOCK * | Block, |
IN UINTN | Units, | ||
IN BOOLEAN | AllocationForRing | ||
) |
Alloc some memory from the block.
Block | The memory block to allocate memory from. |
Units | Number of memory units to allocate. |
AllocationForRing | The allocated memory is for Ring or not. |
Definition at line 144 of file UsbHcMem.c.
VOID UsbHcFreeAlignedPages | ( | IN EFI_PCI_IO_PROTOCOL * | PciIo, |
IN VOID * | HostAddress, | ||
IN UINTN | Pages, | ||
VOID * | Mapping | ||
) |
Frees memory that was allocated with UsbHcAllocateAlignedPages().
PciIo | The PciIo that can be used to access the host controller. |
HostAddress | The system memory address to map to the PCI controller. |
Pages | The number of 4 KB pages to free. |
Mapping | The mapping value returned from Map(). |
Definition at line 758 of file UsbHcMem.c.
VOID UsbHcFreeMem | ( | IN USBHC_MEM_POOL * | Pool, |
IN VOID * | Mem, | ||
IN UINTN | Size | ||
) |
Free the allocated memory back to the memory pool.
Pool | The memory pool of the host controller. |
Mem | The memory to free. |
Size | The size of the memory to free. |
Definition at line 555 of file UsbHcMem.c.
VOID UsbHcFreeMemBlock | ( | IN USBHC_MEM_POOL * | Pool, |
IN USBHC_MEM_BLOCK * | Block | ||
) |
Free the memory block from the memory pool.
Pool | The memory pool to free the block from. |
Block | The memory block to free. |
Definition at line 111 of file UsbHcMem.c.
EFI_STATUS UsbHcFreeMemPool | ( | IN USBHC_MEM_POOL * | Pool | ) |
Release the memory management pool.
Pool | The USB memory pool to free. |
EFI_SUCCESS | The memory pool is freed. |
EFI_DEVICE_ERROR | Failed to free the memory pool. |
Definition at line 445 of file UsbHcMem.c.
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.
Pool | The memory pool of the host controller. |
Mem | The pointer to pci memory. |
Size | The size of the memory region. |
Alignment | Alignment the size to USBHC_MEM_UNIT bytes. |
Definition at line 290 of file UsbHcMem.c.
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.
Pool | The memory pool of the host controller. |
Mem | The pointer to host memory. |
Size | The size of the memory region. |
Alignment | Alignment the size to USBHC_MEM_UNIT bytes. |
Definition at line 235 of file UsbHcMem.c.
USBHC_MEM_POOL * UsbHcInitMemPool | ( | IN EFI_PCI_IO_PROTOCOL * | PciIo | ) |
Initialize the memory management pool for the host controller.
PciIo | The PciIo that can be used to access the host controller. |
EFI_SUCCESS | The memory pool is initialized. |
EFI_OUT_OF_RESOURCE | Fail to init the memory pool. |
Definition at line 412 of file UsbHcMem.c.
VOID UsbHcInsertMemBlockToPool | ( | IN USBHC_MEM_BLOCK * | Head, |
IN USBHC_MEM_BLOCK * | Block | ||
) |
Insert the memory block to the pool's list of the blocks.
Head | The head of the memory pool's block list. |
Block | The memory block to insert. |
Definition at line 341 of file UsbHcMem.c.
BOOLEAN UsbHcIsMemBlockEmpty | ( | IN USBHC_MEM_BLOCK * | Block | ) |
Is the memory block empty?
Block | The memory block to check. |
TRUE | The memory block is empty. |
FALSE | The memory block isn't empty. |
Definition at line 361 of file UsbHcMem.c.
VOID UsbHcUnlinkMemBlock | ( | IN USBHC_MEM_BLOCK * | Head, |
IN USBHC_MEM_BLOCK * | BlockToUnlink | ||
) |
Unlink the memory block from the pool's list.
Head | The block list head of the memory's pool. |
BlockToUnlink | The memory block to unlink. |
Definition at line 384 of file UsbHcMem.c.