TianoCore EDK2 master
Loading...
Searching...
No Matches
UsbHcMem.h
Go to the documentation of this file.
1
10#ifndef _EFI_EHCI_MEM_H_
11#define _EFI_EHCI_MEM_H_
12
13#define USB_HC_BIT(a) ((UINTN)(1 << (a)))
14
15#define USB_HC_BIT_IS_SET(Data, Bit) \
16 ((BOOLEAN)(((Data) & USB_HC_BIT(Bit)) == USB_HC_BIT(Bit)))
17
18#define USB_HC_HIGH_32BIT(Addr64) \
19 ((UINT32)(RShiftU64((UINTN)(Addr64), 32) & 0XFFFFFFFF))
20
23 UINT8 *Bits; // Bit array to record which unit is allocated
24 UINTN BitsLen;
25 UINT8 *Buf;
26 UINT8 *BufHost;
27 UINTN BufLen; // Memory size in bytes
28 VOID *Mapping;
29 USBHC_MEM_BLOCK *Next;
30};
31
32//
33// USBHC_MEM_POOL is used to manage the memory used by USB
34// host controller. EHCI requires the control memory and transfer
35// data to be on the same 4G memory.
36//
37typedef struct _USBHC_MEM_POOL {
39 BOOLEAN Check4G;
40 UINT32 Which4G;
41 USBHC_MEM_BLOCK *Head;
43
44//
45// Memory allocation unit, must be 2^n, n>4
46//
47#define USBHC_MEM_UNIT 64
48
49#define USBHC_MEM_UNIT_MASK (USBHC_MEM_UNIT - 1)
50#define USBHC_MEM_DEFAULT_PAGES 16
51
52#define USBHC_MEM_ROUND(Len) (((Len) + USBHC_MEM_UNIT_MASK) & (~USBHC_MEM_UNIT_MASK))
53
54//
55// Advance the byte and bit to the next bit, adjust byte accordingly.
56//
57#define NEXT_BIT(Byte, Bit) \
58 do { \
59 (Bit)++; \
60 if ((Bit) > 7) { \
61 (Byte)++; \
62 (Bit) = 0; \
63 } \
64 } while (0)
65
81 IN BOOLEAN Check4G,
82 IN UINT32 Which4G
83 );
84
96 IN USBHC_MEM_POOL *Pool
97 );
98
109VOID *
111 IN USBHC_MEM_POOL *Pool,
112 IN UINTN Size
113 );
114
123VOID
125 IN USBHC_MEM_POOL *Pool,
126 IN VOID *Mem,
127 IN UINTN Size
128 );
129
141 IN USBHC_MEM_POOL *Pool,
142 IN VOID *Mem,
143 IN UINTN Size
144 );
145
146#endif
UINT64 UINTN
EFI_PHYSICAL_ADDRESS UsbHcGetPciAddressForHostMem(IN USBHC_MEM_POOL *Pool, IN VOID *Mem, IN UINTN Size)
Definition: UsbHcMem.c:223
EFI_STATUS UsbHcFreeMemPool(IN USBHC_MEM_POOL *Pool)
Definition: UsbHcMem.c:385
VOID UsbHcFreeMem(IN USBHC_MEM_POOL *Pool, IN VOID *Mem, IN UINTN Size)
Definition: UsbHcMem.c:493
VOID * UsbHcAllocateMem(IN USBHC_MEM_POOL *Pool, IN UINTN Size)
Definition: UsbHcMem.c:419
USBHC_MEM_POOL * UsbHcInitMemPool(IN EFI_PCI_IO_PROTOCOL *PciIo, IN BOOLEAN Check4G, IN UINT32 Which4G)
Definition: UsbHcMem.c:348
#define IN
Definition: Base.h:279
UINT64 EFI_PHYSICAL_ADDRESS
Definition: UefiBaseType.h:50
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29