TianoCore EDK2 master
|
#include <PiPei.h>
#include <Ppi/UsbController.h>
#include <Ppi/Usb2HostController.h>
#include <Ppi/IoMmu.h>
#include <Ppi/EndOfPeiPhase.h>
#include <Library/DebugLib.h>
#include <Library/PeimEntryPoint.h>
#include <Library/PeiServicesLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/TimerLib.h>
#include <Library/IoLib.h>
#include <Library/MemoryAllocationLib.h>
#include "UsbHcMem.h"
#include "XhciReg.h"
#include "XhciSched.h"
Go to the source code of this file.
Data Structures | |
struct | _USB_DEV_CONTEXT |
struct | _PEI_XHC_DEV |
Macros | |
#define | CMD_RING_TRB_NUMBER 0x100 |
#define | TR_RING_TRB_NUMBER 0x100 |
#define | ERST_NUMBER 0x01 |
#define | EVENT_RING_TRB_NUMBER 0x200 |
#define | XHC_1_MICROSECOND 1 |
#define | XHC_1_MILLISECOND (1000 * XHC_1_MICROSECOND) |
#define | XHC_1_SECOND (1000 * XHC_1_MILLISECOND) |
#define | XHC_RESET_TIMEOUT (1000) |
#define | XHC_RESET_RECOVERY_DELAY (10 * 1000) |
#define | XHC_ROOT_PORT_STATE_STABLE (200 * XHC_1_MILLISECOND) |
#define | XHC_GENERIC_TIMEOUT (10 * 1000) |
#define | XHC_LOW_32BIT(Addr64) ((UINT32)(((UINTN)(Addr64)) & 0XFFFFFFFF)) |
#define | XHC_HIGH_32BIT(Addr64) ((UINT32)(RShiftU64((UINTN)(Addr64), 32) & 0XFFFFFFFF)) |
#define | XHC_BIT_IS_SET(Data, Bit) ((BOOLEAN)(((Data) & (Bit)) == (Bit))) |
#define | XHC_REG_BIT_IS_SET(XHC, Offset, Bit) (XHC_BIT_IS_SET(XhcPeiReadOpReg ((XHC), (Offset)), (Bit))) |
#define | USB_DESC_TYPE_HUB 0x29 |
#define | USB_DESC_TYPE_HUB_SUPER_SPEED 0x2a |
#define | USB_REQUEST_TYPE(Dir, Type, Target) ((UINT8)((((Dir) == EfiUsbDataIn ? 0x01 : 0) << 7) | (Type) | (Target))) |
#define | USB_XHC_DEV_SIGNATURE SIGNATURE_32 ('x', 'h', 'c', 'i') |
#define | PEI_RECOVERY_USB_XHC_DEV_FROM_THIS(a) CR (a, PEI_XHC_DEV, Usb2HostControllerPpi, USB_XHC_DEV_SIGNATURE) |
#define | PEI_RECOVERY_USB_XHC_DEV_FROM_THIS_NOTIFY(a) CR (a, PEI_XHC_DEV, EndOfPeiNotifyList, USB_XHC_DEV_SIGNATURE) |
Typedefs | |
typedef struct _PEI_XHC_DEV | PEI_XHC_DEV |
typedef struct _USB_DEV_CONTEXT | USB_DEV_CONTEXT |
Functions | |
USBHC_MEM_POOL * | UsbHcInitMemPool (VOID) |
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) |
VOID | IoMmuInit (VOID) |
EFI_STATUS | IoMmuMap (IN EDKII_IOMMU_OPERATION Operation, IN VOID *HostAddress, IN OUT UINTN *NumberOfBytes, OUT EFI_PHYSICAL_ADDRESS *DeviceAddress, OUT VOID **Mapping) |
EFI_STATUS | IoMmuUnmap (IN VOID *Mapping) |
EFI_STATUS | IoMmuAllocateBuffer (IN UINTN Pages, OUT VOID **HostAddress, OUT EFI_PHYSICAL_ADDRESS *DeviceAddress, OUT VOID **Mapping) |
EFI_STATUS | IoMmuFreeBuffer (IN UINTN Pages, IN VOID *HostAddress, IN VOID *Mapping) |
EFI_STATUS | IoMmuAllocateAlignedBuffer (IN UINTN Pages, IN UINTN Alignment, OUT VOID **HostAddress, OUT EFI_PHYSICAL_ADDRESS *DeviceAddress, OUT VOID **Mapping) |
Private Header file for Usb Host Controller PEIM
Copyright (c) 2014 - 2016, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
Definition in file XhcPeim.h.
#define PEI_RECOVERY_USB_XHC_DEV_FROM_THIS | ( | a | ) | CR (a, PEI_XHC_DEV, Usb2HostControllerPpi, USB_XHC_DEV_SIGNATURE) |
#define PEI_RECOVERY_USB_XHC_DEV_FROM_THIS_NOTIFY | ( | a | ) | CR (a, PEI_XHC_DEV, EndOfPeiNotifyList, USB_XHC_DEV_SIGNATURE) |
#define USB_REQUEST_TYPE | ( | Dir, | |
Type, | |||
Target | |||
) | ((UINT8)((((Dir) == EfiUsbDataIn ? 0x01 : 0) << 7) | (Type) | (Target))) |
#define USB_XHC_DEV_SIGNATURE SIGNATURE_32 ('x', 'h', 'c', 'i') |
#define XHC_BIT_IS_SET | ( | Data, | |
Bit | |||
) | ((BOOLEAN)(((Data) & (Bit)) == (Bit))) |
#define XHC_LOW_32BIT | ( | Addr64 | ) | ((UINT32)(((UINTN)(Addr64)) & 0XFFFFFFFF)) |
#define XHC_REG_BIT_IS_SET | ( | XHC, | |
Offset, | |||
Bit | |||
) | (XHC_BIT_IS_SET(XhcPeiReadOpReg ((XHC), (Offset)), (Bit))) |
#define XHC_ROOT_PORT_STATE_STABLE (200 * XHC_1_MILLISECOND) |
typedef struct _PEI_XHC_DEV PEI_XHC_DEV |
typedef struct _USB_DEV_CONTEXT USB_DEV_CONTEXT |
EFI_STATUS IoMmuAllocateAlignedBuffer | ( | IN UINTN | Pages, |
IN UINTN | Alignment, | ||
OUT VOID ** | HostAddress, | ||
OUT EFI_PHYSICAL_ADDRESS * | DeviceAddress, | ||
OUT VOID ** | Mapping | ||
) |
Allocates aligned pages that are suitable for an OperationBusMasterCommonBuffer or OperationBusMasterCommonBuffer64 mapping.
Pages | The number of pages to allocate. |
Alignment | The requested alignment of the allocation. Must be a power of two. |
HostAddress | A pointer to store the base system memory address of the allocated range. |
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 | The requested memory pages were allocated. |
EFI_UNSUPPORTED | Attributes is unsupported. The only legal attribute bits are MEMORY_WRITE_COMBINE and MEMORY_CACHED. |
EFI_INVALID_PARAMETER | One or more parameters are invalid. |
EFI_OUT_OF_RESOURCES | The memory pages could not be allocated. |
EFI_STATUS IoMmuAllocateBuffer | ( | IN UINTN | Pages, |
OUT VOID ** | HostAddress, | ||
OUT EFI_PHYSICAL_ADDRESS * | DeviceAddress, | ||
OUT VOID ** | Mapping | ||
) |
Allocates pages that are suitable for an OperationBusMasterCommonBuffer or OperationBusMasterCommonBuffer64 mapping.
Pages | The number of pages to allocate. |
HostAddress | A pointer to store the base system memory address of the allocated range. |
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 | The requested memory pages were allocated. |
EFI_UNSUPPORTED | Attributes is unsupported. The only legal attribute bits are MEMORY_WRITE_COMBINE and MEMORY_CACHED. |
EFI_INVALID_PARAMETER | One or more parameters are invalid. |
EFI_OUT_OF_RESOURCES | The memory pages could not be allocated. |
EFI_STATUS IoMmuFreeBuffer | ( | IN UINTN | Pages, |
IN VOID * | HostAddress, | ||
IN VOID * | Mapping | ||
) |
Frees memory that was allocated with AllocateBuffer().
Pages | The number of pages to free. |
HostAddress | The base system memory address of the allocated range. |
Mapping | The mapping value returned from Map(). |
EFI_SUCCESS | The requested memory pages were freed. |
EFI_INVALID_PARAMETER | The memory range specified by HostAddress and Pages was not allocated with AllocateBuffer(). |
EFI_STATUS IoMmuMap | ( | IN EDKII_IOMMU_OPERATION | Operation, |
IN VOID * | HostAddress, | ||
IN OUT UINTN * | NumberOfBytes, | ||
OUT EFI_PHYSICAL_ADDRESS * | DeviceAddress, | ||
OUT VOID ** | Mapping | ||
) |
Provides the controller-specific addresses required to access system memory from a DMA bus master.
Operation | Indicates if the bus master is going to read or write to system memory. |
HostAddress | The system memory address to map to the PCI controller. |
NumberOfBytes | On input the number of bytes to map. On output the number of bytes that were mapped. |
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 | The range was mapped for the returned NumberOfBytes. |
EFI_UNSUPPORTED | The HostAddress cannot be mapped as a common buffer. |
EFI_INVALID_PARAMETER | One or more parameters are invalid. |
EFI_OUT_OF_RESOURCES | The request could not be completed due to a lack of resources. |
EFI_DEVICE_ERROR | The system hardware could not map the requested address. |
EFI_STATUS IoMmuUnmap | ( | IN VOID * | Mapping | ) |
Completes the Map() operation and releases any corresponding resources.
Mapping | The mapping value returned from Map(). |
EFI_SUCCESS | The range was unmapped. |
EFI_INVALID_PARAMETER | Mapping is not a value that was returned by Map(). |
EFI_DEVICE_ERROR | The data was not committed to the target system memory. |
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.
Pool | The host controller's memory pool. |
Size | Size of the memory to allocate. |
Definition at line 419 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 493 of file UsbHcMem.c.
VOID UsbHcFreeMemPool | ( | IN USBHC_MEM_POOL * | Pool | ) |
Release the memory management pool.
Pool | The USB memory pool to free. |
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. |
Release the memory management pool.
Pool | The USB memory pool to free. |
Definition at line 385 of file UsbHcMem.c.
USBHC_MEM_POOL * UsbHcInitMemPool | ( | VOID | ) |
Initialize the memory management pool for the host controller.
Definition at line 347 of file UsbHcMem.c.