2 Private Header file for Usb Host Controller PEIM
4 Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved.<BR>
6 SPDX-License-Identifier: BSD-2-Clause-Patent
10 #ifndef _EFI_EHCI_MEM_H_
11 #define _EFI_EHCI_MEM_H_
14 #include <IndustryStandard/Pci22.h>
16 #define USB_HC_BIT(a) ((UINTN)(1 << (a)))
18 #define USB_HC_BIT_IS_SET(Data, Bit) \
19 ((BOOLEAN)(((Data) & USB_HC_BIT(Bit)) == USB_HC_BIT(Bit)))
21 #define USB_HC_HIGH_32BIT(Addr64) \
22 ((UINT32)(RShiftU64((UINTN)(Addr64), 32) & 0XFFFFFFFF))
24 typedef struct _USBHC_MEM_BLOCK USBHC_MEM_BLOCK
;
26 struct _USBHC_MEM_BLOCK
{
27 UINT8
*Bits
; // Bit array to record which unit is allocated
31 UINTN BufLen
; // Memory size in bytes
33 USBHC_MEM_BLOCK
*Next
;
37 // USBHC_MEM_POOL is used to manage the memory used by USB
38 // host controller. EHCI requires the control memory and transfer
39 // data to be on the same 4G memory.
41 typedef struct _USBHC_MEM_POOL
{
44 USBHC_MEM_BLOCK
*Head
;
48 // Memory allocation unit, must be 2^n, n>4
50 #define USBHC_MEM_UNIT 64
52 #define USBHC_MEM_UNIT_MASK (USBHC_MEM_UNIT - 1)
53 #define USBHC_MEM_DEFAULT_PAGES 16
55 #define USBHC_MEM_ROUND(Len) (((Len) + USBHC_MEM_UNIT_MASK) & (~USBHC_MEM_UNIT_MASK))
58 // Advance the byte and bit to the next bit, adjust byte accordingly.
60 #define NEXT_BIT(Byte, Bit) \
70 Calculate the corresponding pci bus address according to the Mem parameter.
72 @param Pool The memory pool of the host controller.
73 @param Mem The pointer to host memory.
74 @param Size The size of the memory region.
76 @return the pci memory address
79 UsbHcGetPciAddressForHostMem (
80 IN USBHC_MEM_POOL
*Pool
,