TianoCore EDK2 master
Loading...
Searching...
No Matches
UsbHcMem.h
Go to the documentation of this file.
1
10#ifndef _EFI_XHCI_MEM_H_
11#define _EFI_XHCI_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
19struct _USBHC_MEM_BLOCK {
20 UINT8 *Bits; // Bit array to record which unit is allocated
21 UINTN BitsLen;
22 UINT8 *Buf;
23 UINT8 *BufHost;
24 UINTN BufLen; // Memory size in bytes
25 VOID *Mapping;
26 USBHC_MEM_BLOCK *Next;
27};
28
29//
30// USBHC_MEM_POOL is used to manage the memory used by USB
31// host controller. XHCI requires the control memory and transfer
32// data to be on the same 4G memory.
33//
34typedef struct _USBHC_MEM_POOL {
36 BOOLEAN Check4G;
37 UINT32 Which4G;
38 USBHC_MEM_BLOCK *Head;
40
41//
42// Memory allocation unit, must be 2^n, n>4
43//
44#define USBHC_MEM_UNIT 64
45
46#define USBHC_MEM_UNIT_MASK (USBHC_MEM_UNIT - 1)
47#define USBHC_MEM_DEFAULT_PAGES 16
48
49#define USBHC_MEM_ROUND(Len) (((Len) + USBHC_MEM_UNIT_MASK) & (~USBHC_MEM_UNIT_MASK))
50
51#define USBHC_MEM_TRB_RINGS_BOUNDARY SIZE_64KB
52
53//
54// Advance the byte and bit to the next bit, adjust byte accordingly.
55//
56#define NEXT_BIT(Byte, Bit) \
57 do { \
58 (Bit)++; \
59 if ((Bit) > 7) { \
60 (Byte)++; \
61 (Bit) = 0; \
62 } \
63 } while (0)
64
77 );
78
90 IN USBHC_MEM_POOL *Pool
91 );
92
104VOID *
106 IN USBHC_MEM_POOL *Pool,
107 IN UINTN Size,
108 IN BOOLEAN AllocationForRing
109 );
110
119VOID
121 IN USBHC_MEM_POOL *Pool,
122 IN VOID *Mem,
123 IN UINTN Size
124 );
125
139 IN USBHC_MEM_POOL *Pool,
140 IN VOID *Mem,
141 IN UINTN Size,
142 IN BOOLEAN Alignment
143 );
144
158 IN USBHC_MEM_POOL *Pool,
159 IN VOID *Mem,
160 IN UINTN Size,
161 IN BOOLEAN Alignment
162 );
163
185 IN EFI_PCI_IO_PROTOCOL *PciIo,
186 IN UINTN Pages,
187 IN UINTN Alignment,
188 OUT VOID **HostAddress,
189 OUT EFI_PHYSICAL_ADDRESS *DeviceAddress,
190 OUT VOID **Mapping
191 );
192
202VOID
204 IN EFI_PCI_IO_PROTOCOL *PciIo,
205 IN VOID *HostAddress,
206 IN UINTN Pages,
207 VOID *Mapping
208 );
209
210#endif
UINT64 UINTN
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
#define OUT
Definition: Base.h:284
UINT64 EFI_PHYSICAL_ADDRESS
Definition: UefiBaseType.h:50
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29
EFI_PHYSICAL_ADDRESS UsbHcGetPciAddrForHostAddr(IN USBHC_MEM_POOL *Pool, IN VOID *Mem, IN UINTN Size, IN BOOLEAN Alignment)
Definition: UsbHcMem.c:235
EFI_STATUS UsbHcAllocateAlignedPages(IN EFI_PCI_IO_PROTOCOL *PciIo, IN UINTN Pages, IN UINTN Alignment, OUT VOID **HostAddress, OUT EFI_PHYSICAL_ADDRESS *DeviceAddress, OUT VOID **Mapping)
Definition: UsbHcMem.c:637
EFI_PHYSICAL_ADDRESS UsbHcGetHostAddrForPciAddr(IN USBHC_MEM_POOL *Pool, IN VOID *Mem, IN UINTN Size, IN BOOLEAN Alignment)
Definition: UsbHcMem.c:290
VOID UsbHcFreeAlignedPages(IN EFI_PCI_IO_PROTOCOL *PciIo, IN VOID *HostAddress, IN UINTN Pages, VOID *Mapping)
Definition: UsbHcMem.c:758