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