TianoCore EDK2 master
|
#include <PiPei.h>
#include <Ppi/UsbController.h>
#include <Ppi/Usb2HostController.h>
#include <Ppi/IoMmu.h>
#include <Ppi/EndOfPeiPhase.h>
#include <Library/BaseLib.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 "UsbHcMem.h"
#include "EhciReg.h"
#include "EhciUrb.h"
#include "EhciSched.h"
Go to the source code of this file.
Data Structures | |
struct | _PEI_USB2_HC_DEV |
Macros | |
#define | EFI_LIST_ENTRY LIST_ENTRY |
#define | EFI_USB_SPEED_FULL 0x0000 |
#define | EFI_USB_SPEED_LOW 0x0001 |
#define | EFI_USB_SPEED_HIGH 0x0002 |
#define | PAGESIZE 4096 |
#define | EHC_1_MICROSECOND 1 |
#define | EHC_1_MILLISECOND (1000 * EHC_1_MICROSECOND) |
#define | EHC_1_SECOND (1000 * EHC_1_MILLISECOND) |
#define | EHC_RESET_TIMEOUT (1 * EHC_1_SECOND) |
#define | EHC_GENERIC_TIMEOUT (10 * EHC_1_MILLISECOND) |
#define | EHC_ROOT_PORT_RECOVERY_STALL (20 * EHC_1_MILLISECOND) |
#define | EHC_SYNC_POLL_INTERVAL (6 * EHC_1_MILLISECOND) |
#define | EFI_LIST_CONTAINER(Entry, Type, Field) BASE_CR(Entry, Type, Field) |
#define | EHC_LOW_32BIT(Addr64) ((UINT32)(((UINTN)(Addr64)) & 0XFFFFFFFF)) |
#define | EHC_HIGH_32BIT(Addr64) ((UINT32)(RShiftU64((UINTN)(Addr64), 32) & 0XFFFFFFFF)) |
#define | EHC_BIT_IS_SET(Data, Bit) ((BOOLEAN)(((Data) & (Bit)) == (Bit))) |
#define | EHC_REG_BIT_IS_SET(Ehc, Offset, Bit) (EHC_BIT_IS_SET(EhcReadOpReg ((Ehc), (Offset)), (Bit))) |
#define | USB2_HC_DEV_SIGNATURE SIGNATURE_32 ('e', 'h', 'c', 'i') |
#define | PEI_RECOVERY_USB_EHC_DEV_FROM_EHCI_THIS(a) CR (a, PEI_USB2_HC_DEV, Usb2HostControllerPpi, USB2_HC_DEV_SIGNATURE) |
#define | PEI_RECOVERY_USB_EHC_DEV_FROM_THIS_NOTIFY(a) CR (a, PEI_USB2_HC_DEV, EndOfPeiNotifyList, USB2_HC_DEV_SIGNATURE) |
Typedefs | |
typedef struct _PEI_USB2_HC_DEV | PEI_USB2_HC_DEV |
Functions | |
EFI_STATUS | InitializeUsbHC (IN PEI_USB2_HC_DEV *EhcDev) |
USBHC_MEM_POOL * | UsbHcInitMemPool (IN PEI_USB2_HC_DEV *Ehc, IN BOOLEAN Check4G, IN UINT32 Which4G) |
EFI_STATUS | UsbHcFreeMemPool (IN PEI_USB2_HC_DEV *Ehc, IN USBHC_MEM_POOL *Pool) |
VOID * | UsbHcAllocateMem (IN PEI_USB2_HC_DEV *Ehc, IN USBHC_MEM_POOL *Pool, IN UINTN Size) |
VOID | UsbHcFreeMem (IN PEI_USB2_HC_DEV *Ehc, IN USBHC_MEM_POOL *Pool, IN VOID *Mem, IN UINTN Size) |
EFI_STATUS | IoMmuMap (IN EDKII_IOMMU_PPI *IoMmu, IN EDKII_IOMMU_OPERATION Operation, IN VOID *HostAddress, IN OUT UINTN *NumberOfBytes, OUT EFI_PHYSICAL_ADDRESS *DeviceAddress, OUT VOID **Mapping) |
VOID | IoMmuUnmap (IN EDKII_IOMMU_PPI *IoMmu, IN VOID *Mapping) |
EFI_STATUS | IoMmuAllocateBuffer (IN EDKII_IOMMU_PPI *IoMmu, IN UINTN Pages, OUT VOID **HostAddress, OUT EFI_PHYSICAL_ADDRESS *DeviceAddress, OUT VOID **Mapping) |
VOID | IoMmuFreeBuffer (IN EDKII_IOMMU_PPI *IoMmu, IN UINTN Pages, IN VOID *HostAddress, IN VOID *Mapping) |
VOID | IoMmuInit (OUT EDKII_IOMMU_PPI **IoMmu) |
Private Header file for Usb Host Controller PEIM
Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved.
Copyright (c) Microsoft Corporation.
SPDX-License-Identifier: BSD-2-Clause-Patent
Definition in file EhcPeim.h.
#define EFI_LIST_CONTAINER | ( | Entry, | |
Type, | |||
Field | |||
) | BASE_CR(Entry, Type, Field) |
#define EFI_LIST_ENTRY LIST_ENTRY |
#define EHC_BIT_IS_SET | ( | Data, | |
Bit | |||
) | ((BOOLEAN)(((Data) & (Bit)) == (Bit))) |
#define EHC_LOW_32BIT | ( | Addr64 | ) | ((UINT32)(((UINTN)(Addr64)) & 0XFFFFFFFF)) |
#define EHC_REG_BIT_IS_SET | ( | Ehc, | |
Offset, | |||
Bit | |||
) | (EHC_BIT_IS_SET(EhcReadOpReg ((Ehc), (Offset)), (Bit))) |
#define EHC_ROOT_PORT_RECOVERY_STALL (20 * EHC_1_MILLISECOND) |
#define PEI_RECOVERY_USB_EHC_DEV_FROM_EHCI_THIS | ( | a | ) | CR (a, PEI_USB2_HC_DEV, Usb2HostControllerPpi, USB2_HC_DEV_SIGNATURE) |
#define PEI_RECOVERY_USB_EHC_DEV_FROM_THIS_NOTIFY | ( | a | ) | CR (a, PEI_USB2_HC_DEV, EndOfPeiNotifyList, USB2_HC_DEV_SIGNATURE) |
#define USB2_HC_DEV_SIGNATURE SIGNATURE_32 ('e', 'h', 'c', 'i') |
typedef struct _PEI_USB2_HC_DEV PEI_USB2_HC_DEV |
EFI_STATUS InitializeUsbHC | ( | IN PEI_USB2_HC_DEV * | EhcDev | ) |
EFI_STATUS IoMmuAllocateBuffer | ( | IN EDKII_IOMMU_PPI * | IoMmu, |
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.
IoMmu | Pointer to IOMMU PPI. |
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. |
VOID IoMmuInit | ( | OUT EDKII_IOMMU_PPI ** | IoMmu | ) |
EFI_STATUS IoMmuMap | ( | IN EDKII_IOMMU_PPI * | IoMmu, |
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.
IoMmu | Pointer to IOMMU PPI. |
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. |
VOID IoMmuUnmap | ( | IN EDKII_IOMMU_PPI * | IoMmu, |
IN VOID * | Mapping | ||
) |
VOID * UsbHcAllocateMem | ( | IN PEI_USB2_HC_DEV * | Ehc, |
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.
Ehc | The EHCI device. |
Pool | The host controller's memory pool. |
Size | Size of the memory to allocate. |
Definition at line 383 of file UsbHcMem.c.
VOID UsbHcFreeMem | ( | IN PEI_USB2_HC_DEV * | Ehc, |
IN USBHC_MEM_POOL * | Pool, | ||
IN VOID * | Mem, | ||
IN UINTN | Size | ||
) |
Free the allocated memory back to the memory pool.
Ehc | The EHCI device. |
Pool | The memory pool of the host controller. |
Mem | The memory to free. |
Size | The size of the memory to free. |
Definition at line 458 of file UsbHcMem.c.
EFI_STATUS UsbHcFreeMemPool | ( | IN PEI_USB2_HC_DEV * | Ehc, |
IN USBHC_MEM_POOL * | Pool | ||
) |
Release the memory management pool.
Ehc | The EHCI device. |
Pool | The USB memory pool to free. |
EFI_DEVICE_ERROR | Fail to free the memory pool. |
EFI_SUCCESS | The memory pool is freed. |
Definition at line 350 of file UsbHcMem.c.
USBHC_MEM_POOL * UsbHcInitMemPool | ( | IN PEI_USB2_HC_DEV * | Ehc, |
IN BOOLEAN | Check4G, | ||
IN UINT32 | Which4G | ||
) |
Initialize the memory management pool for the host controller.
Ehc | The EHCI device. |
Check4G | Whether the host controller requires allocated memory from one 4G address space. |
Which4G | The 4G memory area each memory allocated should be from. |
EFI_SUCCESS | The memory pool is initialized. |
EFI_OUT_OF_RESOURCE | Fail to init the memory pool. |
Initialize the memory management pool for the host controller.
Ehc | The EHCI device. |
Check4G | Whether the host controller requires allocated memory. from one 4G address space. |
Which4G | The 4G memory area each memory allocated should be from. |
EFI_SUCCESS | The memory pool is initialized. |
EFI_OUT_OF_RESOURCE | Fail to init the memory pool. |
Definition at line 302 of file UsbHcMem.c.