]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Bus/Pci/UhciDxe/UsbHcMem.c
Remove some useless EDK_RELEASE_VERSION, EFI_SPECIFICATION_VERSION ,and review VALID_...
[mirror_edk2.git] / MdeModulePkg / Bus / Pci / UhciDxe / UsbHcMem.c
index 7c598e2bbbcf42116107bb92b0709b6e0ab5b749..7cc99ba5276ed15371a0e640346d407a7ac076e6 100644 (file)
@@ -1,5 +1,7 @@
 /** @file\r
 \r
 /** @file\r
 \r
+  The routine procedure for uhci memory allocate/free.\r
+\r
 Copyright (c) 2007, Intel Corporation\r
 All rights reserved. This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 Copyright (c) 2007, Intel Corporation\r
 All rights reserved. This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
@@ -9,33 +11,20 @@ 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
 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.c\r
-\r
-Abstract:\r
-\r
-\r
-Revision History\r
-\r
 **/\r
 \r
 #include "Uhci.h"\r
 \r
 \r
 **/\r
 \r
 #include "Uhci.h"\r
 \r
 \r
-UINTN mUsbHcDebugLevel = DEBUG_INFO;\r
-\r
-\r
 /**\r
 /**\r
-  Allocate a block of memory to be used by the buffer pool\r
+  Allocate a block of memory to be used by the buffer pool.\r
 \r
 \r
-  @param  Pool           The buffer pool to allocate memory for\r
-  @param  Pages          How many pages to allocate\r
+  @param  Pool           The buffer pool to allocate memory for.\r
+  @param  Pages          How many pages to allocate.\r
 \r
 \r
-  @return The allocated memory block or NULL if failed\r
+  @return The allocated memory block or NULL if failed.\r
 \r
 **/\r
 \r
 **/\r
-STATIC\r
 USBHC_MEM_BLOCK *\r
 UsbHcAllocMemBlock (\r
   IN  USBHC_MEM_POOL      *Pool,\r
 USBHC_MEM_BLOCK *\r
 UsbHcAllocMemBlock (\r
   IN  USBHC_MEM_POOL      *Pool,\r
@@ -116,9 +105,6 @@ UsbHcAllocMemBlock (
   Block->Buf      = (UINT8 *) ((UINTN) MappedAddr);\r
   Block->Mapping  = Mapping;\r
 \r
   Block->Buf      = (UINT8 *) ((UINTN) MappedAddr);\r
   Block->Mapping  = Mapping;\r
 \r
-  DEBUG ((mUsbHcDebugLevel, "UsbHcAllocMemBlock: block %x created with buffer %x\n",\r
-                          Block, Block->Buf));\r
-\r
   return Block;\r
 \r
 FREE_BUFFER:\r
   return Block;\r
 \r
 FREE_BUFFER:\r
@@ -132,15 +118,14 @@ FREE_BITARRAY:
 \r
 \r
 /**\r
 \r
 \r
 /**\r
-  Free the memory block from the memory pool\r
+  Free the memory block from the memory pool.\r
 \r
 \r
-  @param  Pool           The memory pool to free the block from\r
-  @param  Block          The memory block to free\r
+  @param  Pool           The memory pool to free the block from.\r
+  @param  Block          The memory block to free.\r
 \r
 \r
-  @return VOID\r
+  @return None.\r
 \r
 **/\r
 \r
 **/\r
-STATIC\r
 VOID\r
 UsbHcFreeMemBlock (\r
   IN USBHC_MEM_POOL       *Pool,\r
 VOID\r
 UsbHcFreeMemBlock (\r
   IN USBHC_MEM_POOL       *Pool,\r
@@ -165,17 +150,15 @@ UsbHcFreeMemBlock (
 \r
 \r
 /**\r
 \r
 \r
 /**\r
-  Alloc some memory from the block\r
+  Alloc some memory from the block.\r
 \r
 \r
-  @param  Block          The memory block to allocate memory from\r
-  @param  Mem            The variable to store the memory allocated\r
-  @param  Units          Number of memory units to allocate\r
+  @param  Block           The memory block to allocate memory from.\r
+  @param  Units           Number of memory units to allocate.\r
 \r
 \r
-  @return EFI_SUCCESS   : The needed memory is allocated\r
-  @return EFI_NOT_FOUND : Can't find the free memory\r
+  @return EFI_SUCCESS     The needed memory is allocated.\r
+  @return EFI_NOT_FOUND   Can't find the free memory.\r
 \r
 **/\r
 \r
 **/\r
-STATIC\r
 VOID *\r
 UsbHcAllocMemFromBlock (\r
   IN  USBHC_MEM_BLOCK     *Block,\r
 VOID *\r
 UsbHcAllocMemFromBlock (\r
   IN  USBHC_MEM_BLOCK     *Block,\r
@@ -232,7 +215,7 @@ UsbHcAllocMemFromBlock (
   for (Count = 0; Count < Units; Count++) {\r
     ASSERT (!USB_HC_BIT_IS_SET (Block->Bits[Byte], Bit));\r
 \r
   for (Count = 0; Count < Units; Count++) {\r
     ASSERT (!USB_HC_BIT_IS_SET (Block->Bits[Byte], Bit));\r
 \r
-    Block->Bits[Byte] |= USB_HC_BIT (Bit);\r
+    Block->Bits[Byte] = (UINT8) (Block->Bits[Byte] | (UINT8) USB_HC_BIT (Bit));\r
     NEXT_BIT (Byte, Bit);\r
   }\r
 \r
     NEXT_BIT (Byte, Bit);\r
   }\r
 \r
@@ -241,15 +224,14 @@ UsbHcAllocMemFromBlock (
 \r
 \r
 /**\r
 \r
 \r
 /**\r
-  Insert the memory block to the pool's list of the blocks\r
+  Insert the memory block to the pool's list of the blocks.\r
 \r
 \r
-  @param  Head           The head of the memory pool's block list\r
-  @param  Block          The memory block to insert\r
+  @param  Head           The head of the memory pool's block list.\r
+  @param  Block          The memory block to insert.\r
 \r
 \r
-  @return VOID\r
+  @return None.\r
 \r
 **/\r
 \r
 **/\r
-STATIC\r
 VOID\r
 UsbHcInsertMemBlockToPool (\r
   IN USBHC_MEM_BLOCK      *Head,\r
 VOID\r
 UsbHcInsertMemBlockToPool (\r
   IN USBHC_MEM_BLOCK      *Head,\r
@@ -265,13 +247,12 @@ UsbHcInsertMemBlockToPool (
 /**\r
   Is the memory block empty?\r
 \r
 /**\r
   Is the memory block empty?\r
 \r
-  @param  Block          The memory block to check\r
+  @param  Block     The memory block to check.\r
 \r
 \r
-  @return TRUE  : The memory block is empty\r
-  @return FALSE : The memory block isn't empty\r
+  @return TRUE      The memory block is empty.\r
+  @return FALSE     The memory block isn't empty.\r
 \r
 **/\r
 \r
 **/\r
-STATIC\r
 BOOLEAN\r
 UsbHcIsMemBlockEmpty (\r
   IN USBHC_MEM_BLOCK     *Block\r
 BOOLEAN\r
 UsbHcIsMemBlockEmpty (\r
   IN USBHC_MEM_BLOCK     *Block\r
@@ -290,15 +271,14 @@ UsbHcIsMemBlockEmpty (
 \r
 \r
 /**\r
 \r
 \r
 /**\r
-  Unlink the memory block from the pool's list\r
+  Unlink the memory block from the pool's list.\r
 \r
 \r
-  @param  Head           The block list head of the memory's pool\r
+  @param  Head           The block list head of the memory's pool.\r
   @param  BlockToUnlink  The memory block to unlink.\r
 \r
   @param  BlockToUnlink  The memory block to unlink.\r
 \r
-  @return VOID\r
+  @return None.\r
 \r
 **/\r
 \r
 **/\r
-STATIC\r
 VOID\r
 UsbHcUnlinkMemBlock (\r
   IN USBHC_MEM_BLOCK      *Head,\r
 VOID\r
 UsbHcUnlinkMemBlock (\r
   IN USBHC_MEM_BLOCK      *Head,\r
@@ -320,16 +300,15 @@ UsbHcUnlinkMemBlock (
 \r
 \r
 /**\r
 \r
 \r
 /**\r
-  Initialize the memory management pool for the host controller\r
+  Initialize the memory management pool for the host controller.\r
 \r
 \r
-  @param  Pool           The USB memory pool to initialize\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
+  @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
 \r
-  @return EFI_SUCCESS         : The memory pool is initialized\r
-  @return EFI_OUT_OF_RESOURCE : Fail to init the memory pool\r
+  @return EFI_SUCCESS           The memory pool is initialized.\r
+  @return EFI_OUT_OF_RESOURCE   Fail to init the memory pool.\r
 \r
 **/\r
 USBHC_MEM_POOL *\r
 \r
 **/\r
 USBHC_MEM_POOL *\r
@@ -362,12 +341,12 @@ UsbHcInitMemPool (
 \r
 \r
 /**\r
 \r
 \r
 /**\r
-  Release the memory management pool\r
+  Release the memory management pool.\r
 \r
 \r
-  @param  Pool           The USB memory pool to free\r
+  @param  Pool               The USB memory pool to free.\r
 \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
 \r
 **/\r
 EFI_STATUS\r
@@ -399,10 +378,10 @@ UsbHcFreeMemPool (
   Allocate some memory from the host controller's memory pool\r
   which can be used to communicate with host controller.\r
 \r
   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
 \r
-  @return The allocated memory or NULL\r
+  @return The allocated memory or NULL.\r
 \r
 **/\r
 VOID *\r
 \r
 **/\r
 VOID *\r
@@ -454,7 +433,7 @@ UsbHcAllocateMem (
   NewBlock = UsbHcAllocMemBlock (Pool, Pages);\r
 \r
   if (NewBlock == NULL) {\r
   NewBlock = UsbHcAllocMemBlock (Pool, Pages);\r
 \r
   if (NewBlock == NULL) {\r
-    DEBUG ((mUsbHcDebugLevel, "UsbHcAllocateMem: failed to allocate block\n"));\r
+    DEBUG ((EFI_D_INFO, "UsbHcAllocateMem: failed to allocate block\n"));\r
     return NULL;\r
   }\r
 \r
     return NULL;\r
   }\r
 \r
@@ -473,13 +452,13 @@ UsbHcAllocateMem (
 \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
 \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
 \r
-  @return VOID\r
+  @return None.\r
 \r
 **/\r
 VOID\r
 \r
 **/\r
 VOID\r
@@ -538,8 +517,6 @@ UsbHcFreeMem (
   // Release the current memory block if it is empty and not the head\r
   //\r
   if ((Block != Head) && UsbHcIsMemBlockEmpty (Block)) {\r
   // Release the current memory block if it is empty and not the head\r
   //\r
   if ((Block != Head) && UsbHcIsMemBlockEmpty (Block)) {\r
-    DEBUG ((mUsbHcDebugLevel, "UsbHcFreeMem: block %x is empty, recycle\n", Block));\r
-\r
     UsbHcUnlinkMemBlock (Head, Block);\r
     UsbHcFreeMemBlock (Pool, Block);\r
   }\r
     UsbHcUnlinkMemBlock (Head, Block);\r
     UsbHcFreeMemBlock (Pool, Block);\r
   }\r