]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Bus/Pci/EhciPei/UsbHcMem.h
UefiCpuPkg: Move AsmRelocateApLoopStart from Mpfuncs.nasm to AmdSev.nasm
[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
9d510e61 6SPDX-License-Identifier: BSD-2-Clause-Patent\r
4b1bf81c 7\r
8**/\r
9\r
10#ifndef _EFI_EHCI_MEM_H_\r
11#define _EFI_EHCI_MEM_H_\r
12\r
13#include <Uefi.h>\r
14#include <IndustryStandard/Pci22.h>\r
15\r
1436aea4 16#define USB_HC_BIT(a) ((UINTN)(1 << (a)))\r
4b1bf81c 17\r
18#define USB_HC_BIT_IS_SET(Data, Bit) \\r
19 ((BOOLEAN)(((Data) & USB_HC_BIT(Bit)) == USB_HC_BIT(Bit)))\r
20\r
21#define USB_HC_HIGH_32BIT(Addr64) \\r
22 ((UINT32)(RShiftU64((UINTN)(Addr64), 32) & 0XFFFFFFFF))\r
23\r
24typedef struct _USBHC_MEM_BLOCK USBHC_MEM_BLOCK;\r
25\r
26struct _USBHC_MEM_BLOCK {\r
1436aea4
MK
27 UINT8 *Bits; // Bit array to record which unit is allocated\r
28 UINTN BitsLen;\r
29 UINT8 *Buf;\r
30 UINT8 *BufHost;\r
31 UINTN BufLen; // Memory size in bytes\r
32 VOID *Mapping;\r
33 USBHC_MEM_BLOCK *Next;\r
4b1bf81c 34};\r
35\r
36//\r
d1102dba 37// USBHC_MEM_POOL is used to manage the memory used by USB\r
4b1bf81c 38// host controller. EHCI requires the control memory and transfer\r
d1102dba 39// data to be on the same 4G memory.\r
4b1bf81c 40//\r
41typedef struct _USBHC_MEM_POOL {\r
1436aea4
MK
42 BOOLEAN Check4G;\r
43 UINT32 Which4G;\r
44 USBHC_MEM_BLOCK *Head;\r
4b1bf81c 45} USBHC_MEM_POOL;\r
46\r
47//\r
48// Memory allocation unit, must be 2^n, n>4\r
49//\r
1436aea4 50#define USBHC_MEM_UNIT 64\r
4b1bf81c 51\r
52#define USBHC_MEM_UNIT_MASK (USBHC_MEM_UNIT - 1)\r
53#define USBHC_MEM_DEFAULT_PAGES 16\r
54\r
55#define USBHC_MEM_ROUND(Len) (((Len) + USBHC_MEM_UNIT_MASK) & (~USBHC_MEM_UNIT_MASK))\r
56\r
57//\r
58// Advance the byte and bit to the next bit, adjust byte accordingly.\r
59//\r
60#define NEXT_BIT(Byte, Bit) \\r
61 do { \\r
62 (Bit)++; \\r
63 if ((Bit) > 7) { \\r
64 (Byte)++; \\r
65 (Bit) = 0; \\r
66 } \\r
d1102dba 67 } while (0)\r
4b1bf81c 68\r
2c656af0
SZ
69/**\r
70 Calculate the corresponding pci bus address according to the Mem parameter.\r
71\r
72 @param Pool The memory pool of the host controller.\r
73 @param Mem The pointer to host memory.\r
74 @param Size The size of the memory region.\r
75\r
76 @return the pci memory address\r
77**/\r
78EFI_PHYSICAL_ADDRESS\r
79UsbHcGetPciAddressForHostMem (\r
1436aea4
MK
80 IN USBHC_MEM_POOL *Pool,\r
81 IN VOID *Mem,\r
82 IN UINTN Size\r
2c656af0
SZ
83 );\r
84\r
4b1bf81c 85#endif\r