TianoCore EDK2 master
Loading...
Searching...
No Matches
UsbHcMem.h File Reference

Go to the source code of this file.

Data Structures

struct  _USBHC_MEM_BLOCK
 
struct  _USBHC_MEM_POOL
 

Macros

#define USB_HC_BIT(a)   ((UINTN)(1 << (a)))
 
#define USB_HC_BIT_IS_SET(Data, Bit)    ((BOOLEAN)(((Data) & USB_HC_BIT(Bit)) == USB_HC_BIT(Bit)))
 
#define USBHC_MEM_UNIT   64
 
#define USBHC_MEM_UNIT_MASK   (USBHC_MEM_UNIT - 1)
 
#define USBHC_MEM_DEFAULT_PAGES   16
 
#define USBHC_MEM_ROUND(Len)   (((Len) + USBHC_MEM_UNIT_MASK) & (~USBHC_MEM_UNIT_MASK))
 
#define USBHC_MEM_TRB_RINGS_BOUNDARY   SIZE_64KB
 
#define NEXT_BIT(Byte, Bit)
 

Typedefs

typedef struct _USBHC_MEM_BLOCK USBHC_MEM_BLOCK
 
typedef struct _USBHC_MEM_POOL USBHC_MEM_POOL
 

Functions

USBHC_MEM_POOLUsbHcInitMemPool (IN EFI_PCI_IO_PROTOCOL *PciIo)
 
EFI_STATUS UsbHcFreeMemPool (IN USBHC_MEM_POOL *Pool)
 
VOID * UsbHcAllocateMem (IN USBHC_MEM_POOL *Pool, IN UINTN Size, IN BOOLEAN AllocationForRing)
 
VOID UsbHcFreeMem (IN USBHC_MEM_POOL *Pool, IN VOID *Mem, IN UINTN Size)
 
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)
 
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)
 
VOID UsbHcFreeAlignedPages (IN EFI_PCI_IO_PROTOCOL *PciIo, IN VOID *HostAddress, IN UINTN Pages, VOID *Mapping)
 

Detailed Description

This file contains the definination for host controller memory management routines.

Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent

Definition in file UsbHcMem.h.

Macro Definition Documentation

◆ NEXT_BIT

#define NEXT_BIT (   Byte,
  Bit 
)
Value:
do { \
(Bit)++; \
if ((Bit) > 7) { \
(Byte)++; \
(Bit) = 0; \
} \
} while (0)

Definition at line 56 of file UsbHcMem.h.

◆ USB_HC_BIT

#define USB_HC_BIT (   a)    ((UINTN)(1 << (a)))

Definition at line 13 of file UsbHcMem.h.

◆ USB_HC_BIT_IS_SET

#define USB_HC_BIT_IS_SET (   Data,
  Bit 
)     ((BOOLEAN)(((Data) & USB_HC_BIT(Bit)) == USB_HC_BIT(Bit)))

Definition at line 15 of file UsbHcMem.h.

◆ USBHC_MEM_DEFAULT_PAGES

#define USBHC_MEM_DEFAULT_PAGES   16

Definition at line 47 of file UsbHcMem.h.

◆ USBHC_MEM_ROUND

#define USBHC_MEM_ROUND (   Len)    (((Len) + USBHC_MEM_UNIT_MASK) & (~USBHC_MEM_UNIT_MASK))

Definition at line 49 of file UsbHcMem.h.

◆ USBHC_MEM_TRB_RINGS_BOUNDARY

#define USBHC_MEM_TRB_RINGS_BOUNDARY   SIZE_64KB

Definition at line 51 of file UsbHcMem.h.

◆ USBHC_MEM_UNIT

#define USBHC_MEM_UNIT   64

Definition at line 44 of file UsbHcMem.h.

◆ USBHC_MEM_UNIT_MASK

#define USBHC_MEM_UNIT_MASK   (USBHC_MEM_UNIT - 1)

Definition at line 46 of file UsbHcMem.h.

Typedef Documentation

◆ USBHC_MEM_BLOCK

Definition at line 18 of file UsbHcMem.h.

Function Documentation

◆ UsbHcAllocateAlignedPages()

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().

Parameters
PciIoThe PciIo that can be used to access the host controller.
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 637 of file UsbHcMem.c.

◆ UsbHcAllocateMem()

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.

Parameters
PoolThe host controller's memory pool.
SizeSize of the memory to allocate.
AllocationForRingThe allocated memory is for Ring or not.
Returns
The allocated memory or NULL.

Definition at line 480 of file UsbHcMem.c.

◆ UsbHcFreeAlignedPages()

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

Frees memory that was allocated with UsbHcAllocateAlignedPages().

Parameters
PciIoThe PciIo that can be used to access the host controller.
HostAddressThe system memory address to map to the PCI controller.
PagesThe number of pages to free.
MappingThe mapping value returned from Map().

Frees memory that was allocated with UsbHcAllocateAlignedPages().

Parameters
PciIoThe PciIo that can be used to access the host controller.
HostAddressThe system memory address to map to the PCI controller.
PagesThe number of 4 KB pages to free.
MappingThe mapping value returned from Map().

Definition at line 758 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 493 of file UsbHcMem.c.

◆ UsbHcFreeMemPool()

EFI_STATUS UsbHcFreeMemPool ( IN USBHC_MEM_POOL Pool)

Release the memory management pool.

Parameters
PoolThe USB memory pool to free.
Return values
EFI_SUCCESSThe memory pool is freed.
EFI_DEVICE_ERRORFailed to free the memory pool.

Release the memory management pool.

Parameters
PoolThe USB memory pool to free.
Returns
EFI_SUCCESS The memory pool is freed.
EFI_DEVICE_ERROR Failed to free the memory pool.

Release the memory management pool.

Parameters
PoolThe USB memory pool to free.

Definition at line 385 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 290 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 235 of file UsbHcMem.c.

◆ UsbHcInitMemPool()

USBHC_MEM_POOL * UsbHcInitMemPool ( IN EFI_PCI_IO_PROTOCOL PciIo)

Initialize the memory management pool for the host controller.

Parameters
PciIoThe PciIo that can be used to access the host controller.
Return values
EFI_SUCCESSThe memory pool is initialized.
EFI_OUT_OF_RESOURCEFail to init the memory pool.

Definition at line 412 of file UsbHcMem.c.