1 /** @file 2 Private Header file for Usb Host Controller PEIM 3 4 Copyright (c) 2010, Intel Corporation. All rights reserved.<BR> 5 6 This program and the accompanying materials 7 are licensed and made available under the terms and conditions 8 of the BSD License which accompanies this distribution. The 9 full text of the license may be found at 10 http://opensource.org/licenses/bsd-license.php 11 12 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, 13 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. 14 15 **/ 16 17 #ifndef _EFI_EHCI_MEM_H_ 18 #define _EFI_EHCI_MEM_H_ 19 20 #include <Uefi.h> 21 #include <IndustryStandard/Pci22.h> 22 23 #define USB_HC_BIT(a) ((UINTN)(1 << (a))) 24 25 #define USB_HC_BIT_IS_SET(Data, Bit) \ 26 ((BOOLEAN)(((Data) & USB_HC_BIT(Bit)) == USB_HC_BIT(Bit))) 27 28 #define USB_HC_HIGH_32BIT(Addr64) \ 29 ((UINT32)(RShiftU64((UINTN)(Addr64), 32) & 0XFFFFFFFF)) 30 31 typedef struct _USBHC_MEM_BLOCK USBHC_MEM_BLOCK; 32 33 struct _USBHC_MEM_BLOCK { 34 UINT8 *Bits; // Bit array to record which unit is allocated 35 UINTN BitsLen; 36 UINT8 *Buf; 37 UINT8 *BufHost; 38 UINTN BufLen; // Memory size in bytes 39 VOID *Mapping; 40 USBHC_MEM_BLOCK *Next; 41 }; 42 43 // 44 // USBHC_MEM_POOL is used to manage the memory used by USB 45 // host controller. EHCI requires the control memory and transfer 46 // data to be on the same 4G memory. 47 // 48 typedef struct _USBHC_MEM_POOL { 49 BOOLEAN Check4G; 50 UINT32 Which4G; 51 USBHC_MEM_BLOCK *Head; 52 } USBHC_MEM_POOL; 53 54 // 55 // Memory allocation unit, must be 2^n, n>4 56 // 57 #define USBHC_MEM_UNIT 64 58 59 #define USBHC_MEM_UNIT_MASK (USBHC_MEM_UNIT - 1) 60 #define USBHC_MEM_DEFAULT_PAGES 16 61 62 #define USBHC_MEM_ROUND(Len) (((Len) + USBHC_MEM_UNIT_MASK) & (~USBHC_MEM_UNIT_MASK)) 63 64 // 65 // Advance the byte and bit to the next bit, adjust byte accordingly. 66 // 67 #define NEXT_BIT(Byte, Bit) \ 68 do { \ 69 (Bit)++; \ 70 if ((Bit) > 7) { \ 71 (Byte)++; \ 72 (Bit) = 0; \ 73 } \ 74 } while (0) 75 76 77 #endif 78