]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/FirmwareVolume/FaultTolerantWriteDxe/FtwMisc.c
Clean up FaultTolerantWriteDxe for Doxygen comments requirement.
[mirror_edk2.git] / MdeModulePkg / Universal / FirmwareVolume / FaultTolerantWriteDxe / FtwMisc.c
index fccf889a3d057207535ee1c5e0e5e9d50875436f..eb487b737f2ba53cc1cf2947d58be60d6c9db8c6 100644 (file)
@@ -15,29 +15,24 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 \r
 #include <FtwLite.h>\r
 \r
-BOOLEAN\r
-IsErasedFlashBuffer (\r
-  IN BOOLEAN         Polarity,\r
-  IN UINT8           *Buffer,\r
-  IN UINTN           BufferSize\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
+/**\r
 \r
   Check whether a flash buffer is erased.\r
 \r
-Arguments:\r
-\r
-  Polarity    - All 1 or all 0\r
-  Buffer      - Buffer to check\r
-  BufferSize  - Size of the buffer\r
 \r
-Returns:\r
+  @param Polarity        All 1 or all 0\r
+  @param Buffer          Buffer to check\r
+  @param BufferSize      Size of the buffer\r
 \r
-  Erased or not.\r
+  @return A BOOLEAN value indicating erased or not.\r
 \r
---*/\r
+**/\r
+BOOLEAN\r
+IsErasedFlashBuffer (\r
+  IN BOOLEAN         Polarity,\r
+  IN UINT8           *Buffer,\r
+  IN UINTN           BufferSize\r
+  )\r
 {\r
   UINT8 ErasedValue;\r
   UINT8 *Ptr;\r
@@ -49,7 +44,7 @@ Returns:
   }\r
 \r
   Ptr = Buffer;\r
-  while (BufferSize--) {\r
+  while ((BufferSize--) != 0) {\r
     if (*Ptr++ != ErasedValue) {\r
       return FALSE;\r
     }\r
@@ -58,27 +53,24 @@ Returns:
   return TRUE;\r
 }\r
 \r
+/**\r
+  To Erase one block. The size is FTW_BLOCK_SIZE\r
+\r
+\r
+  @param FtwLiteDevice   Calling context\r
+  @param FvBlock         FVB Protocol interface\r
+  @param Lba             Lba of the firmware block\r
+\r
+  @retval  EFI_SUCCESS    Block LBA is Erased successfully\r
+  @retval  Others         Error occurs\r
+\r
+**/\r
 EFI_STATUS\r
 FtwEraseBlock (\r
   IN EFI_FTW_LITE_DEVICE              *FtwLiteDevice,\r
   EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL  *FvBlock,\r
   EFI_LBA                             Lba\r
   )\r
-/*++\r
-\r
-Routine Description:\r
-    To Erase one block. The size is FTW_BLOCK_SIZE\r
-\r
-Arguments:\r
-    FtwLiteDevice - Calling context\r
-    FvBlock       - FVB Protocol interface\r
-    Lba        - Lba of the firmware block\r
-\r
-Returns:\r
-    EFI_SUCCESS   - Block LBA is Erased successfully\r
-    Others        - Error occurs\r
-\r
---*/\r
 {\r
   return FvBlock->EraseBlocks (\r
                     FvBlock,\r
@@ -88,25 +80,32 @@ Returns:
                     );\r
 }\r
 \r
-EFI_STATUS\r
-FtwEraseSpareBlock (\r
-  IN EFI_FTW_LITE_DEVICE   *FtwLiteDevice\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
+/**\r
 \r
   Erase spare block.\r
 \r
-Arguments:\r
 \r
-  FtwLiteDevice - Calling context\r
+  @param FtwLiteDevice   Calling context\r
 \r
-Returns:\r
+  @retval EFI_SUCCESS The erase request was successfully\r
+                      completed.\r
+  \r
+  @retval EFI_ACCESS_DENIED   The firmware volume is in the\r
+                              WriteDisabled state.\r
+  @retval EFI_DEVICE_ERROR  The block device is not functioning\r
+                            correctly and could not be written.\r
+                            The firmware device may have been\r
+                            partially erased.\r
+  @retval EFI_INVALID_PARAMETER One or more of the LBAs listed\r
+                                in the variable argument list do\r
+                                not exist in the firmware volume.  \r
 \r
-  Status code\r
 \r
---*/\r
+**/\r
+EFI_STATUS\r
+FtwEraseSpareBlock (\r
+  IN EFI_FTW_LITE_DEVICE   *FtwLiteDevice\r
+  )\r
 {\r
   return FtwLiteDevice->FtwBackupFvb->EraseBlocks (\r
                                         FtwLiteDevice->FtwBackupFvb,\r
@@ -116,25 +115,23 @@ Returns:
                                         );\r
 }\r
 \r
+/**\r
+  Retrive the proper FVB protocol interface by HANDLE.\r
+\r
+\r
+  @param FvBlockHandle   The handle of FVB protocol that provides services for\r
+                         reading, writing, and erasing the target block.\r
+  @param FvBlock         The interface of FVB protocol\r
+\r
+  @retval  EFI_SUCCESS          The function completed successfully\r
+  @retval  EFI_ABORTED          The function could not complete successfully\r
+\r
+**/\r
 EFI_STATUS\r
 FtwGetFvbByHandle (\r
   IN EFI_HANDLE                           FvBlockHandle,\r
   OUT EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL  **FvBlock\r
   )\r
-/*++\r
-\r
-Routine Description:\r
-    Retrive the proper FVB protocol interface by HANDLE.\r
-\r
-Arguments:\r
-    FvBlockHandle       - The handle of FVB protocol that provides services for \r
-                          reading, writing, and erasing the target block.\r
-    FvBlock             - The interface of FVB protocol\r
-\r
-Returns:\r
-    EFI_SUCCESS         - The function completed successfully\r
-    EFI_ABORTED         - The function could not complete successfully\r
---*/\r
 {\r
   //\r
   // To get the FVB protocol interface on the handle\r
@@ -146,29 +143,23 @@ Returns:
                 );\r
 }\r
 \r
-EFI_STATUS\r
-GetFvbByAddress (\r
-  IN  EFI_PHYSICAL_ADDRESS               Address,\r
-  OUT EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL **FvBlock\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
+/**\r
 \r
   Get firmware block by address.\r
 \r
-Arguments:\r
-\r
-  Address - Address specified the block\r
-  FvBlock - The block caller wanted\r
 \r
-Returns:\r
+  @param Address         Address specified the block\r
+  @param FvBlock         The block caller wanted\r
 \r
-  Status code\r
+  @retval  EFI_SUCCESS    The protocol instance if found.\r
+  @retval  EFI_NOT_FOUND  Block not found\r
 \r
-  EFI_NOT_FOUND - Block not found\r
-\r
---*/\r
+**/\r
+EFI_STATUS\r
+GetFvbByAddress (\r
+  IN  EFI_PHYSICAL_ADDRESS               Address,\r
+  OUT EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL **FvBlock\r
+  )\r
 {\r
   EFI_STATUS                          Status;\r
   EFI_HANDLE                          *HandleBuffer;\r
@@ -225,29 +216,24 @@ Returns:
   return Status;\r
 }\r
 \r
-BOOLEAN\r
-IsInWorkingBlock (\r
-  EFI_FTW_LITE_DEVICE                 *FtwLiteDevice,\r
-  EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL  *FvBlock,\r
-  EFI_LBA                             Lba\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
+/**\r
 \r
   Is it in working block?\r
 \r
-Arguments:\r
 \r
-  FtwLiteDevice - Calling context\r
-  FvBlock       - Fvb protocol instance\r
-  Lba           - The block specified\r
+  @param FtwLiteDevice   Calling context\r
+  @param FvBlock         Fvb protocol instance\r
+  @param Lba             The block specified\r
 \r
-Returns:\r
+  @return A BOOLEAN value indicating in working block or not.\r
 \r
-  In working block or not\r
-\r
---*/\r
+**/\r
+BOOLEAN\r
+IsInWorkingBlock (\r
+  EFI_FTW_LITE_DEVICE                 *FtwLiteDevice,\r
+  EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL  *FvBlock,\r
+  EFI_LBA                             Lba\r
+  )\r
 {\r
   //\r
   // If matching the following condition, the target block is in working block.\r
@@ -262,32 +248,29 @@ Returns:
     );\r
 }\r
 \r
+/**\r
+  Copy the content of spare block to a target block. Size is FTW_BLOCK_SIZE.\r
+  Spare block is accessed by FTW backup FVB protocol interface. LBA is\r
+  FtwLiteDevice->FtwSpareLba.\r
+  Target block is accessed by FvBlock protocol interface. LBA is Lba.\r
+\r
+\r
+  @param FtwLiteDevice   The private data of FTW_LITE driver\r
+  @param FvBlock         FVB Protocol interface to access target block\r
+  @param Lba             Lba of the target block\r
+\r
+  @retval  EFI_SUCCESS               Spare block content is copied to target block\r
+  @retval  EFI_INVALID_PARAMETER     Input parameter error\r
+  @retval  EFI_OUT_OF_RESOURCES      Allocate memory error\r
+  @retval  EFI_ABORTED               The function could not complete successfully\r
+\r
+**/\r
 EFI_STATUS\r
 FlushSpareBlockToTargetBlock (\r
   EFI_FTW_LITE_DEVICE                 *FtwLiteDevice,\r
   EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL  *FvBlock,\r
   EFI_LBA                             Lba\r
   )\r
-/*++\r
-\r
-Routine Description:\r
-    Copy the content of spare block to a target block. Size is FTW_BLOCK_SIZE.\r
-    Spare block is accessed by FTW backup FVB protocol interface. LBA is \r
-    FtwLiteDevice->FtwSpareLba.\r
-    Target block is accessed by FvBlock protocol interface. LBA is Lba.\r
-\r
-Arguments:\r
-    FtwLiteDevice  - The private data of FTW_LITE driver\r
-    FvBlock        - FVB Protocol interface to access target block\r
-    Lba            - Lba of the target block\r
-\r
-Returns:\r
-    EFI_SUCCESS              - Spare block content is copied to target block\r
-    EFI_INVALID_PARAMETER    - Input parameter error\r
-    EFI_OUT_OF_RESOURCES     - Allocate memory error\r
-    EFI_ABORTED              - The function could not complete successfully\r
-\r
---*/\r
 {\r
   EFI_STATUS  Status;\r
   UINTN       Length;\r
@@ -356,33 +339,29 @@ Returns:
   return Status;\r
 }\r
 \r
-EFI_STATUS\r
-FlushSpareBlockToWorkingBlock (\r
-  EFI_FTW_LITE_DEVICE          *FtwLiteDevice\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-    Copy the content of spare block to working block. Size is FTW_BLOCK_SIZE.\r
-    Spare block is accessed by FTW backup FVB protocol interface. LBA is \r
-    FtwLiteDevice->FtwSpareLba.\r
-    Working block is accessed by FTW working FVB protocol interface. LBA is \r
-    FtwLiteDevice->FtwWorkBlockLba.\r
+/**\r
+  Copy the content of spare block to working block. Size is FTW_BLOCK_SIZE.\r
+  Spare block is accessed by FTW backup FVB protocol interface. LBA is\r
+  FtwLiteDevice->FtwSpareLba.\r
+  Working block is accessed by FTW working FVB protocol interface. LBA is\r
+  FtwLiteDevice->FtwWorkBlockLba.\r
 \r
-Arguments:\r
-    FtwLiteDevice  - The private data of FTW_LITE driver\r
 \r
-Returns:\r
-    EFI_SUCCESS              - Spare block content is copied to target block\r
-    EFI_OUT_OF_RESOURCES     - Allocate memory error\r
-    EFI_ABORTED              - The function could not complete successfully\r
+  @param FtwLiteDevice   The private data of FTW_LITE driver\r
 \r
-Notes:\r
-    Since the working block header is important when FTW initializes, the \r
-    state of the operation should be handled carefully. The Crc value is \r
-    calculated without STATE element. \r
+  @retval  EFI_SUCCESS               Spare block content is copied to target block\r
+  @retval  EFI_OUT_OF_RESOURCES      Allocate memory error\r
+  @retval  EFI_ABORTED               The function could not complete successfully\r
+                                     Notes:\r
+                                     Since the working block header is important when FTW initializes, the\r
+                                     state of the operation should be handled carefully. The Crc value is\r
+                                     calculated without STATE element.\r
 \r
---*/\r
+**/\r
+EFI_STATUS\r
+FlushSpareBlockToWorkingBlock (\r
+  EFI_FTW_LITE_DEVICE          *FtwLiteDevice\r
+  )\r
 {\r
   EFI_STATUS                              Status;\r
   UINTN                                   Length;\r