TianoCore EDK2 master
Loading...
Searching...
No Matches
EhcPeim.h File Reference
#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_POOLUsbHcInitMemPool (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)
 

Detailed Description

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.

Macro Definition Documentation

◆ EFI_LIST_CONTAINER

#define EFI_LIST_CONTAINER (   Entry,
  Type,
  Field 
)    BASE_CR(Entry, Type, Field)

Definition at line 64 of file EhcPeim.h.

◆ EFI_LIST_ENTRY

#define EFI_LIST_ENTRY   LIST_ENTRY

Definition at line 31 of file EhcPeim.h.

◆ EFI_USB_SPEED_FULL

#define EFI_USB_SPEED_FULL   0x0000

Definition at line 38 of file EhcPeim.h.

◆ EFI_USB_SPEED_HIGH

#define EFI_USB_SPEED_HIGH   0x0002

Definition at line 40 of file EhcPeim.h.

◆ EFI_USB_SPEED_LOW

#define EFI_USB_SPEED_LOW   0x0001

Definition at line 39 of file EhcPeim.h.

◆ EHC_1_MICROSECOND

#define EHC_1_MICROSECOND   1

Definition at line 44 of file EhcPeim.h.

◆ EHC_1_MILLISECOND

#define EHC_1_MILLISECOND   (1000 * EHC_1_MICROSECOND)

Definition at line 45 of file EhcPeim.h.

◆ EHC_1_SECOND

#define EHC_1_SECOND   (1000 * EHC_1_MILLISECOND)

Definition at line 46 of file EhcPeim.h.

◆ EHC_BIT_IS_SET

#define EHC_BIT_IS_SET (   Data,
  Bit 
)    ((BOOLEAN)(((Data) & (Bit)) == (Bit)))

Definition at line 68 of file EhcPeim.h.

◆ EHC_GENERIC_TIMEOUT

#define EHC_GENERIC_TIMEOUT   (10 * EHC_1_MILLISECOND)

Definition at line 52 of file EhcPeim.h.

◆ EHC_HIGH_32BIT

#define EHC_HIGH_32BIT (   Addr64)    ((UINT32)(RShiftU64((UINTN)(Addr64), 32) & 0XFFFFFFFF))

Definition at line 67 of file EhcPeim.h.

◆ EHC_LOW_32BIT

#define EHC_LOW_32BIT (   Addr64)    ((UINT32)(((UINTN)(Addr64)) & 0XFFFFFFFF))

Definition at line 66 of file EhcPeim.h.

◆ EHC_REG_BIT_IS_SET

#define EHC_REG_BIT_IS_SET (   Ehc,
  Offset,
  Bit 
)     (EHC_BIT_IS_SET(EhcReadOpReg ((Ehc), (Offset)), (Bit)))

Definition at line 70 of file EhcPeim.h.

◆ EHC_RESET_TIMEOUT

#define EHC_RESET_TIMEOUT   (1 * EHC_1_SECOND)

Definition at line 51 of file EhcPeim.h.

◆ EHC_ROOT_PORT_RECOVERY_STALL

#define EHC_ROOT_PORT_RECOVERY_STALL   (20 * EHC_1_MILLISECOND)

Definition at line 57 of file EhcPeim.h.

◆ EHC_SYNC_POLL_INTERVAL

#define EHC_SYNC_POLL_INTERVAL   (6 * EHC_1_MILLISECOND)

Definition at line 62 of file EhcPeim.h.

◆ PAGESIZE

#define PAGESIZE   4096

Definition at line 42 of file EhcPeim.h.

◆ PEI_RECOVERY_USB_EHC_DEV_FROM_EHCI_THIS

#define PEI_RECOVERY_USB_EHC_DEV_FROM_EHCI_THIS (   a)    CR (a, PEI_USB2_HC_DEV, Usb2HostControllerPpi, USB2_HC_DEV_SIGNATURE)

Definition at line 126 of file EhcPeim.h.

◆ PEI_RECOVERY_USB_EHC_DEV_FROM_THIS_NOTIFY

#define PEI_RECOVERY_USB_EHC_DEV_FROM_THIS_NOTIFY (   a)    CR (a, PEI_USB2_HC_DEV, EndOfPeiNotifyList, USB2_HC_DEV_SIGNATURE)

Definition at line 127 of file EhcPeim.h.

◆ USB2_HC_DEV_SIGNATURE

#define USB2_HC_DEV_SIGNATURE   SIGNATURE_32 ('e', 'h', 'c', 'i')

Definition at line 73 of file EhcPeim.h.

Typedef Documentation

◆ PEI_USB2_HC_DEV

Definition at line 29 of file EhcPeim.h.

Function Documentation

◆ InitializeUsbHC()

EFI_STATUS InitializeUsbHC ( IN PEI_USB2_HC_DEV EhcDev)
Parameters
EhcDevEHCI Device.
Return values
EFI_SUCCESSEHCI successfully initialized.
EFI_ABORTEDEHCI was failed to be initialized.

Definition at line 1301 of file EhcPeim.c.

◆ IoMmuAllocateBuffer()

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.

Parameters
IoMmuPointer to IOMMU PPI.
PagesThe number of pages to allocate.
HostAddressA pointer to store the base system memory address of the allocated range.
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_SUCCESSThe requested memory pages were allocated.
EFI_UNSUPPORTEDAttributes is unsupported. The only legal attribute bits are MEMORY_WRITE_COMBINE and MEMORY_CACHED.
EFI_INVALID_PARAMETEROne or more parameters are invalid.
EFI_OUT_OF_RESOURCESThe memory pages could not be allocated.

Definition at line 134 of file DmaMem.c.

◆ IoMmuFreeBuffer()

VOID IoMmuFreeBuffer ( IN EDKII_IOMMU_PPI IoMmu,
IN UINTN  Pages,
IN VOID *  HostAddress,
IN VOID *  Mapping 
)

Frees memory that was allocated with AllocateBuffer().

Parameters
IoMmuPointer to IOMMU PPI.
PagesThe number of pages to free.
HostAddressThe base system memory address of the allocated range.
MappingThe mapping value returned from Map().

Definition at line 217 of file DmaMem.c.

◆ IoMmuInit()

VOID IoMmuInit ( OUT EDKII_IOMMU_PPI **  IoMmu)

Initialize IOMMU.

Parameters
IoMmuPointer to pointer to IOMMU PPI.

Definition at line 238 of file DmaMem.c.

◆ IoMmuMap()

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.

Parameters
IoMmuPointer to IOMMU PPI.
OperationIndicates if the bus master is going to read or write to system memory.
HostAddressThe system memory address to map to the PCI controller.
NumberOfBytesOn input the number of bytes to map. On output the number of bytes that were mapped.
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_SUCCESSThe range was mapped for the returned NumberOfBytes.
EFI_UNSUPPORTEDThe HostAddress cannot be mapped as a common buffer.
EFI_INVALID_PARAMETEROne or more parameters are invalid.
EFI_OUT_OF_RESOURCESThe request could not be completed due to a lack of resources.
EFI_DEVICE_ERRORThe system hardware could not map the requested address.

Definition at line 33 of file DmaMem.c.

◆ IoMmuUnmap()

VOID IoMmuUnmap ( IN EDKII_IOMMU_PPI IoMmu,
IN VOID *  Mapping 
)

Completes the Map() operation and releases any corresponding resources.

Parameters
IoMmuPointer to IOMMU PPI.
MappingThe mapping value returned from Map().

Definition at line 103 of file DmaMem.c.

◆ UsbHcAllocateMem()

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.

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

Definition at line 383 of file UsbHcMem.c.

◆ UsbHcFreeMem()

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.

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

Definition at line 458 of file UsbHcMem.c.

◆ UsbHcFreeMemPool()

EFI_STATUS UsbHcFreeMemPool ( IN PEI_USB2_HC_DEV Ehc,
IN USBHC_MEM_POOL Pool 
)

Release the memory management pool.

Parameters
EhcThe EHCI device.
PoolThe USB memory pool to free.
Return values
EFI_DEVICE_ERRORFail to free the memory pool.
EFI_SUCCESSThe memory pool is freed.

Definition at line 350 of file UsbHcMem.c.

◆ UsbHcInitMemPool()

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.

Parameters
EhcThe EHCI device.
Check4GWhether the host controller requires allocated memory from one 4G address space.
Which4GThe 4G memory area each memory allocated should be from.
Return values
EFI_SUCCESSThe memory pool is initialized.
EFI_OUT_OF_RESOURCEFail to init the memory pool.

Initialize the memory management pool for the host controller.

Parameters
EhcThe EHCI device.
Check4GWhether the host controller requires allocated memory. from one 4G address space.
Which4GThe 4G memory area each memory allocated should be from.
Return values
EFI_SUCCESSThe memory pool is initialized.
EFI_OUT_OF_RESOURCEFail to init the memory pool.

Definition at line 302 of file UsbHcMem.c.