]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Bus/Pci/UhciDxe/UsbHcMem.h
Fix bug: The lower 2 bits of Width and stripped, Count will always be multiplied...
[mirror_edk2.git] / MdeModulePkg / Bus / Pci / UhciDxe / UsbHcMem.h
index 4df144be84451fa882adbf71715e0f928724e54b..c53d0b78f2399dc45f653f148d6847b06bea38f0 100644 (file)
@@ -1,7 +1,9 @@
 /** @file\r
 \r
-Copyright (c) 2007, Intel Corporation\r
-All rights reserved. This program and the accompanying materials\r
+  This file contains the definination for host controller memory management routines\r
+\r
+Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
 http://opensource.org/licenses/bsd-license.php\r
@@ -9,23 +11,11 @@ http://opensource.org/licenses/bsd-license.php
 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
 \r
-Module Name:\r
-\r
-  EhciMem.h\r
-\r
-Abstract:\r
-\r
-  This file contains the definination for host controller memory management routines\r
-\r
-Revision History\r
-\r
 **/\r
 \r
 #ifndef _EFI_EHCI_MEM_H_\r
 #define _EFI_EHCI_MEM_H_\r
 \r
-#include <IndustryStandard/Pci22.h>\r
-\r
 #define USB_HC_BIT(a)                  ((UINTN)(1 << (a)))\r
 \r
 #define USB_HC_BIT_IS_SET(Data, Bit)   \\r
@@ -34,8 +24,8 @@ Revision History
 #define USB_HC_HIGH_32BIT(Addr64)    \\r
           ((UINT32)(RShiftU64((UINTN)(Addr64), 32) & 0XFFFFFFFF))\r
 \r
-typedef struct _USBHC_MEM_BLOCK   USBHC_MEM_BLOCK;\r
 \r
+typedef struct _USBHC_MEM_BLOCK USBHC_MEM_BLOCK;\r
 struct _USBHC_MEM_BLOCK {\r
   UINT8                   *Bits;    // Bit array to record which unit is allocated\r
   UINTN                   BitsLen;\r
@@ -58,12 +48,13 @@ typedef struct _USBHC_MEM_POOL {
   USBHC_MEM_BLOCK         *Head;\r
 } USBHC_MEM_POOL;\r
 \r
-enum {\r
-  USBHC_MEM_UNIT           = 64,     // Memory allocation unit, must be 2^n, n>4\r
+//\r
+// Memory allocation unit, must be 2^n, n>4\r
+//\r
+#define USBHC_MEM_UNIT           64\r
 \r
-  USBHC_MEM_UNIT_MASK      = USBHC_MEM_UNIT - 1,\r
-  USBHC_MEM_DEFAULT_PAGES  = 16\r
-};\r
+#define USBHC_MEM_UNIT_MASK      (USBHC_MEM_UNIT - 1)\r
+#define USBHC_MEM_DEFAULT_PAGES  16\r
 \r
 #define USBHC_MEM_ROUND(Len)  (((Len) + USBHC_MEM_UNIT_MASK) & (~USBHC_MEM_UNIT_MASK))\r
 \r
@@ -80,51 +71,39 @@ enum {
           } while (0)\r
 \r
 \r
+/**\r
+  Initialize the memory management pool for the host controller.\r
+\r
+  @param  PciIo               The PciIo that can be used to access the host controller.\r
+  @param  Check4G             Whether the host controller requires allocated memory\r
+                              from one 4G address space.\r
+  @param  Which4G             The 4G memory area each memory allocated should be from.\r
+\r
+  @retval EFI_SUCCESS         The memory pool is initialized.\r
+  @retval EFI_OUT_OF_RESOURCE Fail to init the memory pool.\r
 \r
+**/\r
 USBHC_MEM_POOL *\r
 UsbHcInitMemPool (\r
   IN EFI_PCI_IO_PROTOCOL  *PciIo,\r
   IN BOOLEAN              Check4G,\r
   IN UINT32               Which4G\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Initialize the memory management pool for the host controller\r
-\r
-Arguments:\r
-\r
-  Pool    - The USB memory pool to initialize\r
-  PciIo   - The PciIo that can be used to access the host controller\r
-  Check4G - Whether the host controller requires allocated memory\r
-            from one 4G address space.\r
-  Which4G - The 4G memory area each memory allocated should be from\r
-\r
-Returns:\r
-\r
-  EFI_SUCCESS         : The memory pool is initialized\r
-  EFI_OUT_OF_RESOURCE : Fail to init the memory pool\r
-\r
---*/\r
-;\r
-\r
+  );\r
 \r
 \r
 /**\r
-  Release the memory management pool\r
+  Release the memory management pool.\r
 \r
-  @param  Pool  The USB memory pool to free\r
+  @param  Pool               The USB memory pool to free.\r
 \r
-  @return EFI_SUCCESS      : The memory pool is freed\r
-  @return EFI_DEVICE_ERROR : Failed to free the memory pool\r
+  @return EFI_SUCCESS        The memory pool is freed.\r
+  @return EFI_DEVICE_ERROR   Failed to free the memory pool.\r
 \r
 **/\r
 EFI_STATUS\r
 UsbHcFreeMemPool (\r
   IN USBHC_MEM_POOL       *Pool\r
-  )\r
-;\r
+  );\r
 \r
 \r
 \r
@@ -132,29 +111,28 @@ UsbHcFreeMemPool (
   Allocate some memory from the host controller's memory pool\r
   which can be used to communicate with host controller.\r
 \r
-  @param  Pool  The host controller's memory pool\r
-  @param  Size  Size of the memory to allocate\r
+  @param  Pool  The host controller's memory pool.\r
+  @param  Size  Size of the memory to allocate.\r
 \r
-  @return The allocated memory or NULL\r
+  @return The allocated memory or NULL.\r
 \r
 **/\r
 VOID *\r
 UsbHcAllocateMem (\r
   IN  USBHC_MEM_POOL      *Pool,\r
   IN  UINTN               Size\r
-  )\r
-;\r
+  );\r
 \r
 \r
 \r
 /**\r
-  Free the allocated memory back to the memory pool\r
+  Free the allocated memory back to the memory pool.\r
 \r
-  @param  Pool  The memory pool of the host controller\r
-  @param  Mem   The memory to free\r
-  @param  Size  The size of the memory to free\r
+  @param  Pool  The memory pool of the host controller.\r
+  @param  Mem   The memory to free.\r
+  @param  Size  The size of the memory to free.\r
 \r
-  @return VOID\r
+  @return None.\r
 \r
 **/\r
 VOID\r
@@ -162,6 +140,22 @@ UsbHcFreeMem (
   IN USBHC_MEM_POOL       *Pool,\r
   IN VOID                 *Mem,\r
   IN UINTN                Size\r
-  )\r
-;\r
+  );\r
+\r
+/**\r
+  Calculate the corresponding pci bus address according to the Mem parameter.\r
+\r
+  @param  Pool           The memory pool of the host controller.\r
+  @param  Mem            The pointer to host memory.\r
+  @param  Size           The size of the memory region.\r
+\r
+  @return the pci memory address\r
+**/\r
+EFI_PHYSICAL_ADDRESS\r
+UsbHcGetPciAddressForHostMem (\r
+  IN USBHC_MEM_POOL       *Pool,\r
+  IN VOID                 *Mem,\r
+  IN UINTN                Size\r
+  );\r
+\r
 #endif\r