]> git.proxmox.com Git - mirror_edk2.git/blobdiff - OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FwBlockService.c
OvmfPkg: QemuFlashFvbServicesRuntimeDxe: rewrap source code to 79 chars
[mirror_edk2.git] / OvmfPkg / QemuFlashFvbServicesRuntimeDxe / FwBlockService.c
index 075fac32a96db1bdce8a6c63afb90ae189e1f022..c542482c3aa189cc53d953e931ad717e11af74c6 100644 (file)
@@ -1,21 +1,22 @@
 /**@file\r
 \r
-Copyright (c) 2006 - 2014, 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
+  Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>\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
+  This program and the accompanying materials are licensed and made available\r
+  under the terms and conditions of the BSD License which accompanies this\r
+  distribution.  The full text of the license may be found at\r
+  http://opensource.org/licenses/bsd-license.php\r
 \r
-Module Name:\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
-  FWBlockService.c\r
+  Module Name:\r
 \r
-Abstract:\r
+    FWBlockService.c\r
 \r
-Revision History\r
+  Abstract:\r
+\r
+  Revision History\r
 \r
 **/\r
 \r
@@ -48,7 +49,8 @@ Revision History
 #include "FwBlockService.h"\r
 #include "QemuFlash.h"\r
 \r
-#define EFI_FVB2_STATUS (EFI_FVB2_READ_STATUS | EFI_FVB2_WRITE_STATUS | EFI_FVB2_LOCK_STATUS)\r
+#define EFI_FVB2_STATUS \\r
+          (EFI_FVB2_READ_STATUS | EFI_FVB2_WRITE_STATUS | EFI_FVB2_LOCK_STATUS)\r
 \r
 ESAL_FWB_GLOBAL         *mFvbModuleGlobal;\r
 \r
@@ -124,30 +126,32 @@ FvbVirtualddressChangeEvent (
   )\r
 /*++\r
 \r
-Routine Description:\r
+  Routine Description:\r
 \r
-  Fixup internal data so that EFI and SAL can be call in virtual mode.\r
-  Call the passed in Child Notify event and convert the mFvbModuleGlobal\r
-  date items to there virtual address.\r
+    Fixup internal data so that EFI and SAL can be call in virtual mode.\r
+    Call the passed in Child Notify event and convert the mFvbModuleGlobal\r
+    date items to there virtual address.\r
 \r
-  mFvbModuleGlobal->FvInstance[FVB_PHYSICAL]  - Physical copy of instance data\r
-  mFvbModuleGlobal->FvInstance[FVB_VIRTUAL]   - Virtual pointer to common\r
-                                                instance data.\r
+    mFvbModuleGlobal->FvInstance[FVB_PHYSICAL]  - Physical copy of instance\r
+                                                  data\r
+    mFvbModuleGlobal->FvInstance[FVB_VIRTUAL]   - Virtual pointer to common\r
+                                                  instance data.\r
 \r
-Arguments:\r
+  Arguments:\r
 \r
-  (Standard EFI notify event - EFI_EVENT_NOTIFY)\r
+    (Standard EFI notify event - EFI_EVENT_NOTIFY)\r
 \r
-Returns:\r
+  Returns:\r
 \r
-  None\r
+    None\r
 \r
 --*/\r
 {\r
   EFI_FW_VOL_INSTANCE *FwhInstance;\r
   UINTN               Index;\r
 \r
-  EfiConvertPointer (0x0, (VOID **) &mFvbModuleGlobal->FvInstance[FVB_VIRTUAL]);\r
+  EfiConvertPointer (0x0,\r
+    (VOID **) &mFvbModuleGlobal->FvInstance[FVB_VIRTUAL]);\r
 \r
   //\r
   // Convert the base address of all the instances\r
@@ -158,13 +162,15 @@ Returns:
     EfiConvertPointer (0x0, (VOID **) &FwhInstance->FvBase[FVB_VIRTUAL]);\r
     FwhInstance = (EFI_FW_VOL_INSTANCE *)\r
       (\r
-        (UINTN) ((UINT8 *) FwhInstance) + FwhInstance->VolumeHeader.HeaderLength +\r
-          (sizeof (EFI_FW_VOL_INSTANCE) - sizeof (EFI_FIRMWARE_VOLUME_HEADER))\r
+        (UINTN) ((UINT8 *) FwhInstance) +\r
+        FwhInstance->VolumeHeader.HeaderLength +\r
+        (sizeof (EFI_FW_VOL_INSTANCE) - sizeof (EFI_FIRMWARE_VOLUME_HEADER))\r
       );\r
     Index++;\r
   }\r
 \r
-  EfiConvertPointer (0x0, (VOID **) &mFvbModuleGlobal->FvbScratchSpace[FVB_VIRTUAL]);\r
+  EfiConvertPointer (0x0,\r
+    (VOID **) &mFvbModuleGlobal->FvbScratchSpace[FVB_VIRTUAL]);\r
   EfiConvertPointer (0x0, (VOID **) &mFvbModuleGlobal);\r
   QemuFlashConvertPointers ();\r
 }\r
@@ -178,20 +184,20 @@ GetFvbInstance (
   )\r
 /*++\r
 \r
-Routine Description:\r
-  Retrieves the physical address of a memory mapped FV\r
+  Routine Description:\r
+    Retrieves the physical address of a memory mapped FV\r
 \r
-Arguments:\r
-  Instance              - The FV instance whose base address is going to be\r
-                          returned\r
-  Global                - Pointer to ESAL_FWB_GLOBAL that contains all\r
-                          instance data\r
-  FwhInstance           - The EFI_FW_VOL_INSTANCE fimrware instance structure\r
-  Virtual               - Whether CPU is in virtual or physical mode\r
+  Arguments:\r
+    Instance              - The FV instance whose base address is going to be\r
+                            returned\r
+    Global                - Pointer to ESAL_FWB_GLOBAL that contains all\r
+                            instance data\r
+    FwhInstance           - The EFI_FW_VOL_INSTANCE fimrware instance structure\r
+    Virtual               - Whether CPU is in virtual or physical mode\r
 \r
-Returns:\r
-  EFI_SUCCESS           - Successfully returns\r
-  EFI_INVALID_PARAMETER - Instance not found\r
+  Returns:\r
+    EFI_SUCCESS           - Successfully returns\r
+    EFI_INVALID_PARAMETER - Instance not found\r
 \r
 --*/\r
 {\r
@@ -228,22 +234,22 @@ FvbGetPhysicalAddress (
   )\r
 /*++\r
 \r
-Routine Description:\r
-  Retrieves the physical address of a memory mapped FV\r
+  Routine Description:\r
+    Retrieves the physical address of a memory mapped FV\r
 \r
-Arguments:\r
-  Instance              - The FV instance whose base address is going to be\r
-                          returned\r
-  Address               - Pointer to a caller allocated EFI_PHYSICAL_ADDRESS\r
-                          that on successful return, contains the base address\r
-                          of the firmware volume.\r
-  Global                - Pointer to ESAL_FWB_GLOBAL that contains all\r
-                          instance data\r
-  Virtual               - Whether CPU is in virtual or physical mode\r
+  Arguments:\r
+    Instance              - The FV instance whose base address is going to be\r
+                            returned\r
+    Address               - Pointer to a caller allocated EFI_PHYSICAL_ADDRESS\r
+                            that on successful return, contains the base\r
+                            address of the firmware volume.\r
+    Global                - Pointer to ESAL_FWB_GLOBAL that contains all\r
+                            instance data\r
+    Virtual               - Whether CPU is in virtual or physical mode\r
 \r
-Returns:\r
-  EFI_SUCCESS           - Successfully returns\r
-  EFI_INVALID_PARAMETER - Instance not found\r
+  Returns:\r
+    EFI_SUCCESS           - Successfully returns\r
+    EFI_INVALID_PARAMETER - Instance not found\r
 \r
 --*/\r
 {\r
@@ -269,21 +275,21 @@ FvbGetVolumeAttributes (
   )\r
 /*++\r
 \r
-Routine Description:\r
-  Retrieves attributes, insures positive polarity of attribute bits, returns\r
-  resulting attributes in output parameter\r
+  Routine Description:\r
+    Retrieves attributes, insures positive polarity of attribute bits, returns\r
+    resulting attributes in output parameter\r
 \r
-Arguments:\r
-  Instance              - The FV instance whose attributes is going to be\r
-                          returned\r
-  Attributes            - Output buffer which contains attributes\r
-  Global                - Pointer to ESAL_FWB_GLOBAL that contains all\r
-                          instance data\r
-  Virtual               - Whether CPU is in virtual or physical mode\r
+  Arguments:\r
+    Instance              - The FV instance whose attributes is going to be\r
+                            returned\r
+    Attributes            - Output buffer which contains attributes\r
+    Global                - Pointer to ESAL_FWB_GLOBAL that contains all\r
+                            instance data\r
+    Virtual               - Whether CPU is in virtual or physical mode\r
 \r
-Returns:\r
-  EFI_SUCCESS           - Successfully returns\r
-  EFI_INVALID_PARAMETER - Instance not found\r
+  Returns:\r
+    EFI_SUCCESS           - Successfully returns\r
+    EFI_INVALID_PARAMETER - Instance not found\r
 \r
 --*/\r
 {\r
@@ -312,26 +318,26 @@ FvbGetLbaAddress (
   )\r
 /*++\r
 \r
-Routine Description:\r
-  Retrieves the starting address of an LBA in an FV\r
-\r
-Arguments:\r
-  Instance              - The FV instance which the Lba belongs to\r
-  Lba                   - The logical block address\r
-  LbaAddress            - On output, contains the physical starting address\r
-                          of the Lba\r
-  LbaLength             - On output, contains the length of the block\r
-  NumOfBlocks           - A pointer to a caller allocated UINTN in which the\r
-                          number of consecutive blocks starting with Lba is\r
-                          returned. All blocks in this range have a size of\r
-                          BlockSize\r
-  Global                - Pointer to ESAL_FWB_GLOBAL that contains all\r
-                          instance data\r
-  Virtual               - Whether CPU is in virtual or physical mode\r
-\r
-Returns:\r
-  EFI_SUCCESS           - Successfully returns\r
-  EFI_INVALID_PARAMETER - Instance not found\r
+  Routine Description:\r
+    Retrieves the starting address of an LBA in an FV\r
+\r
+  Arguments:\r
+    Instance              - The FV instance which the Lba belongs to\r
+    Lba                   - The logical block address\r
+    LbaAddress            - On output, contains the physical starting address\r
+                            of the Lba\r
+    LbaLength             - On output, contains the length of the block\r
+    NumOfBlocks           - A pointer to a caller allocated UINTN in which the\r
+                            number of consecutive blocks starting with Lba is\r
+                            returned. All blocks in this range have a size of\r
+                            BlockSize\r
+    Global                - Pointer to ESAL_FWB_GLOBAL that contains all\r
+                            instance data\r
+    Virtual               - Whether CPU is in virtual or physical mode\r
+\r
+  Returns:\r
+    EFI_SUCCESS           - Successfully returns\r
+    EFI_INVALID_PARAMETER - Instance not found\r
 \r
 --*/\r
 {\r
@@ -402,27 +408,27 @@ FvbSetVolumeAttributes (
   )\r
 /*++\r
 \r
-Routine Description:\r
-  Modifies the current settings of the firmware volume according to the\r
-  input parameter, and returns the new setting of the volume\r
-\r
-Arguments:\r
-  Instance              - The FV instance whose attributes is going to be\r
-                          modified\r
-  Attributes            - On input, it is a pointer to EFI_FVB_ATTRIBUTES_2\r
-                          containing the desired firmware volume settings.\r
-                          On successful return, it contains the new settings\r
-                          of the firmware volume\r
-  Global                - Pointer to ESAL_FWB_GLOBAL that contains all\r
-                          instance data\r
-  Virtual               - Whether CPU is in virtual or physical mode\r
-\r
-Returns:\r
-  EFI_SUCCESS           - Successfully returns\r
-  EFI_ACCESS_DENIED     - The volume setting is locked and cannot be modified\r
-  EFI_INVALID_PARAMETER - Instance not found, or The attributes requested are\r
-                          in conflict with the capabilities as declared in the\r
-                          firmware volume header\r
+  Routine Description:\r
+    Modifies the current settings of the firmware volume according to the\r
+    input parameter, and returns the new setting of the volume\r
+\r
+  Arguments:\r
+    Instance              - The FV instance whose attributes is going to be\r
+                            modified\r
+    Attributes            - On input, it is a pointer to EFI_FVB_ATTRIBUTES_2\r
+                            containing the desired firmware volume settings.\r
+                            On successful return, it contains the new settings\r
+                            of the firmware volume\r
+    Global                - Pointer to ESAL_FWB_GLOBAL that contains all\r
+                            instance data\r
+    Virtual               - Whether CPU is in virtual or physical mode\r
+\r
+  Returns:\r
+    EFI_SUCCESS           - Successfully returns\r
+    EFI_ACCESS_DENIED     - The volume setting is locked and cannot be modified\r
+    EFI_INVALID_PARAMETER - Instance not found, or The attributes requested are\r
+                            in conflict with the capabilities as declared in\r
+                            the firmware volume header\r
 \r
 --*/\r
 {\r
@@ -441,7 +447,8 @@ Returns:
   Status = GetFvbInstance (Instance, Global, &FwhInstance, Virtual);\r
   ASSERT_EFI_ERROR (Status);\r
 \r
-  AttribPtr     = (EFI_FVB_ATTRIBUTES_2 *) &(FwhInstance->VolumeHeader.Attributes);\r
+  AttribPtr     =\r
+    (EFI_FVB_ATTRIBUTES_2 *) &(FwhInstance->VolumeHeader.Attributes);\r
   OldAttributes = *AttribPtr;\r
   Capabilities  = OldAttributes & (EFI_FVB2_READ_DISABLED_CAP | \\r
                                    EFI_FVB2_READ_ENABLED_CAP | \\r
@@ -467,7 +474,8 @@ Returns:
   //\r
   // Some attributes of FV is read only can *not* be set\r
   //\r
-  if ((OldAttributes & UnchangedAttributes) ^ (*Attributes & UnchangedAttributes)) {\r
+  if ((OldAttributes & UnchangedAttributes) ^\r
+      (*Attributes & UnchangedAttributes)) {\r
     return EFI_INVALID_PARAMETER;\r
   }\r
   //\r
@@ -537,19 +545,17 @@ FvbProtocolGetPhysicalAddress (
   )\r
 /*++\r
 \r
-Routine Description:\r
-\r
-  Retrieves the physical address of the device.\r
+  Routine Description:\r
 \r
-Arguments:\r
+    Retrieves the physical address of the device.\r
 \r
-  This                  - Calling context\r
-  Address               - Output buffer containing the address.\r
+  Arguments:\r
 \r
-Returns:\r
+    This                  - Calling context\r
+    Address               - Output buffer containing the address.\r
 \r
-Returns:\r
-  EFI_SUCCESS           - Successfully returns\r
+  Returns:\r
+    EFI_SUCCESS           - Successfully returns\r
 \r
 --*/\r
 {\r
@@ -557,7 +563,8 @@ Returns:
 \r
   FvbDevice = FVB_DEVICE_FROM_THIS (This);\r
 \r
-  return FvbGetPhysicalAddress (FvbDevice->Instance, Address, mFvbModuleGlobal, EfiGoneVirtual ());\r
+  return FvbGetPhysicalAddress (FvbDevice->Instance, Address,\r
+           mFvbModuleGlobal, EfiGoneVirtual ());\r
 }\r
 \r
 EFI_STATUS\r
@@ -570,22 +577,22 @@ FvbProtocolGetBlockSize (
   )\r
 /*++\r
 \r
-Routine Description:\r
-  Retrieve the size of a logical block\r
+  Routine Description:\r
+    Retrieve the size of a logical block\r
 \r
-Arguments:\r
-  This                  - Calling context\r
-  Lba                   - Indicates which block to return the size for.\r
-  BlockSize             - A pointer to a caller allocated UINTN in which\r
-                          the size of the block is returned\r
-  NumOfBlocks           - a pointer to a caller allocated UINTN in which the\r
-                          number of consecutive blocks starting with Lba is\r
-                          returned. All blocks in this range have a size of\r
-                          BlockSize\r
+  Arguments:\r
+    This                  - Calling context\r
+    Lba                   - Indicates which block to return the size for.\r
+    BlockSize             - A pointer to a caller allocated UINTN in which\r
+                            the size of the block is returned\r
+    NumOfBlocks           - a pointer to a caller allocated UINTN in which the\r
+                            number of consecutive blocks starting with Lba is\r
+                            returned. All blocks in this range have a size of\r
+                            BlockSize\r
 \r
-Returns:\r
-  EFI_SUCCESS           - The firmware volume was read successfully and\r
-                          contents are in Buffer\r
+  Returns:\r
+    EFI_SUCCESS           - The firmware volume was read successfully and\r
+                            contents are in Buffer\r
 \r
 --*/\r
 {\r
@@ -612,15 +619,15 @@ FvbProtocolGetAttributes (
   )\r
 /*++\r
 \r
-Routine Description:\r
-    Retrieves Volume attributes.  No polarity translations are done.\r
+  Routine Description:\r
+      Retrieves Volume attributes.  No polarity translations are done.\r
 \r
-Arguments:\r
-    This                - Calling context\r
-    Attributes          - output buffer which contains attributes\r
+  Arguments:\r
+      This                - Calling context\r
+      Attributes          - output buffer which contains attributes\r
 \r
-Returns:\r
-  EFI_SUCCESS           - Successfully returns\r
+  Returns:\r
+    EFI_SUCCESS           - Successfully returns\r
 \r
 --*/\r
 {\r
@@ -628,7 +635,8 @@ Returns:
 \r
   FvbDevice = FVB_DEVICE_FROM_THIS (This);\r
 \r
-  return FvbGetVolumeAttributes (FvbDevice->Instance, Attributes, mFvbModuleGlobal, EfiGoneVirtual ());\r
+  return FvbGetVolumeAttributes (FvbDevice->Instance, Attributes,\r
+           mFvbModuleGlobal, EfiGoneVirtual ());\r
 }\r
 \r
 EFI_STATUS\r
@@ -639,15 +647,15 @@ FvbProtocolSetAttributes (
   )\r
 /*++\r
 \r
-Routine Description:\r
-  Sets Volume attributes. No polarity translations are done.\r
+  Routine Description:\r
+    Sets Volume attributes. No polarity translations are done.\r
 \r
-Arguments:\r
-  This                  - Calling context\r
-  Attributes            - output buffer which contains attributes\r
+  Arguments:\r
+    This                  - Calling context\r
+    Attributes            - output buffer which contains attributes\r
 \r
-Returns:\r
-  EFI_SUCCESS           - Successfully returns\r
+  Returns:\r
+    EFI_SUCCESS           - Successfully returns\r
 \r
 --*/\r
 {\r
@@ -655,7 +663,8 @@ Returns:
 \r
   FvbDevice = FVB_DEVICE_FROM_THIS (This);\r
 \r
-  return FvbSetVolumeAttributes (FvbDevice->Instance, Attributes, mFvbModuleGlobal, EfiGoneVirtual ());\r
+  return FvbSetVolumeAttributes (FvbDevice->Instance, Attributes,\r
+           mFvbModuleGlobal, EfiGoneVirtual ());\r
 }\r
 \r
 EFI_STATUS\r
@@ -666,26 +675,27 @@ FvbProtocolEraseBlocks (
   )\r
 /*++\r
 \r
-Routine Description:\r
+  Routine Description:\r
 \r
-  The EraseBlock() function erases one or more blocks as denoted by the\r
-  variable argument list. The entire parameter list of blocks must be verified\r
-  prior to erasing any blocks.  If a block is requested that does not exist\r
-  within the associated firmware volume (it has a larger index than the last\r
-  block of the firmware volume), the EraseBlock() function must return\r
-  EFI_INVALID_PARAMETER without modifying the contents of the firmware volume.\r
+    The EraseBlock() function erases one or more blocks as denoted by the\r
+    variable argument list. The entire parameter list of blocks must be\r
+    verified prior to erasing any blocks.  If a block is requested that does\r
+    not exist within the associated firmware volume (it has a larger index than\r
+    the last block of the firmware volume), the EraseBlock() function must\r
+    return EFI_INVALID_PARAMETER without modifying the contents of the firmware\r
+    volume.\r
 \r
-Arguments:\r
-  This                  - Calling context\r
-  ...                   - Starting LBA followed by Number of Lba to erase.\r
-                          a -1 to terminate the list.\r
+  Arguments:\r
+    This                  - Calling context\r
+    ...                   - Starting LBA followed by Number of Lba to erase.\r
+                            a -1 to terminate the list.\r
 \r
-Returns:\r
-  EFI_SUCCESS           - The erase request was successfully completed\r
-  EFI_ACCESS_DENIED     - The firmware volume is in the WriteDisabled state\r
-  EFI_DEVICE_ERROR      - The block device is not functioning correctly and\r
-                          could not be written. Firmware device may have been\r
-                          partially erased\r
+  Returns:\r
+    EFI_SUCCESS           - The erase request was successfully completed\r
+    EFI_ACCESS_DENIED     - The firmware volume is in the WriteDisabled state\r
+    EFI_DEVICE_ERROR      - The block device is not functioning correctly and\r
+                            could not be written. Firmware device may have been\r
+                            partially erased\r
 \r
 --*/\r
 {\r
@@ -699,7 +709,8 @@ Returns:
 \r
   FvbDevice = FVB_DEVICE_FROM_THIS (This);\r
 \r
-  Status    = GetFvbInstance (FvbDevice->Instance, mFvbModuleGlobal, &FwhInstance, EfiGoneVirtual ());\r
+  Status    = GetFvbInstance (FvbDevice->Instance, mFvbModuleGlobal,\r
+                &FwhInstance, EfiGoneVirtual ());\r
   ASSERT_EFI_ERROR (Status);\r
 \r
   NumOfBlocks = FwhInstance->NumOfBlocks;\r
@@ -763,36 +774,38 @@ FvbProtocolWrite (
   )\r
 /*++\r
 \r
-Routine Description:\r
-\r
-  Writes data beginning at Lba:Offset from FV. The write terminates either\r
-  when *NumBytes of data have been written, or when a block boundary is\r
-  reached.  *NumBytes is updated to reflect the actual number of bytes\r
-  written. The write opertion does not include erase. This routine will\r
-  attempt to write only the specified bytes. If the writes do not stick,\r
-  it will return an error.\r
-\r
-Arguments:\r
-  This                  - Calling context\r
-  Lba                   - Block in which to begin write\r
-  Offset                - Offset in the block at which to begin write\r
-  NumBytes              - On input, indicates the requested write size. On\r
-                          output, indicates the actual number of bytes written\r
-  Buffer                - Buffer containing source data for the write.\r
-\r
-Returns:\r
-  EFI_SUCCESS           - The firmware volume was written successfully\r
-  EFI_BAD_BUFFER_SIZE   - Write attempted across a LBA boundary. On output,\r
-                          NumBytes contains the total number of bytes\r
-                          actually written\r
-  EFI_ACCESS_DENIED     - The firmware volume is in the WriteDisabled state\r
-  EFI_DEVICE_ERROR      - The block device is not functioning correctly and\r
-                          could not be written\r
-  EFI_INVALID_PARAMETER - NumBytes or Buffer are NULL\r
+  Routine Description:\r
+\r
+    Writes data beginning at Lba:Offset from FV. The write terminates either\r
+    when *NumBytes of data have been written, or when a block boundary is\r
+    reached.  *NumBytes is updated to reflect the actual number of bytes\r
+    written. The write opertion does not include erase. This routine will\r
+    attempt to write only the specified bytes. If the writes do not stick,\r
+    it will return an error.\r
+\r
+  Arguments:\r
+    This                  - Calling context\r
+    Lba                   - Block in which to begin write\r
+    Offset                - Offset in the block at which to begin write\r
+    NumBytes              - On input, indicates the requested write size. On\r
+                            output, indicates the actual number of bytes\r
+                            written\r
+    Buffer                - Buffer containing source data for the write.\r
+\r
+  Returns:\r
+    EFI_SUCCESS           - The firmware volume was written successfully\r
+    EFI_BAD_BUFFER_SIZE   - Write attempted across a LBA boundary. On output,\r
+                            NumBytes contains the total number of bytes\r
+                            actually written\r
+    EFI_ACCESS_DENIED     - The firmware volume is in the WriteDisabled state\r
+    EFI_DEVICE_ERROR      - The block device is not functioning correctly and\r
+                            could not be written\r
+    EFI_INVALID_PARAMETER - NumBytes or Buffer are NULL\r
 \r
 --*/\r
 {\r
-  return QemuFlashWrite ((EFI_LBA)Lba, (UINTN)Offset, NumBytes, (UINT8 *)Buffer);\r
+  return QemuFlashWrite ((EFI_LBA)Lba, (UINTN)Offset, NumBytes,\r
+           (UINT8 *)Buffer);\r
 }\r
 \r
 EFI_STATUS\r
@@ -806,37 +819,38 @@ FvbProtocolRead (
   )\r
 /*++\r
 \r
-Routine Description:\r
-\r
-  Reads data beginning at Lba:Offset from FV. The Read terminates either\r
-  when *NumBytes of data have been read, or when a block boundary is\r
-  reached.  *NumBytes is updated to reflect the actual number of bytes\r
-  written. The write opertion does not include erase. This routine will\r
-  attempt to write only the specified bytes. If the writes do not stick,\r
-  it will return an error.\r
-\r
-Arguments:\r
-  This                  - Calling context\r
-  Lba                   - Block in which to begin Read\r
-  Offset                - Offset in the block at which to begin Read\r
-  NumBytes              - On input, indicates the requested write size. On\r
-                          output, indicates the actual number of bytes Read\r
-  Buffer                - Buffer containing source data for the Read.\r
-\r
-Returns:\r
-  EFI_SUCCESS           - The firmware volume was read successfully and\r
-                          contents are in Buffer\r
-  EFI_BAD_BUFFER_SIZE   - Read attempted across a LBA boundary. On output,\r
-                          NumBytes contains the total number of bytes returned\r
-                          in Buffer\r
-  EFI_ACCESS_DENIED     - The firmware volume is in the ReadDisabled state\r
-  EFI_DEVICE_ERROR      - The block device is not functioning correctly and\r
-                          could not be read\r
-  EFI_INVALID_PARAMETER - NumBytes or Buffer are NULL\r
+  Routine Description:\r
+\r
+    Reads data beginning at Lba:Offset from FV. The Read terminates either\r
+    when *NumBytes of data have been read, or when a block boundary is\r
+    reached.  *NumBytes is updated to reflect the actual number of bytes\r
+    written. The write opertion does not include erase. This routine will\r
+    attempt to write only the specified bytes. If the writes do not stick,\r
+    it will return an error.\r
+\r
+  Arguments:\r
+    This                  - Calling context\r
+    Lba                   - Block in which to begin Read\r
+    Offset                - Offset in the block at which to begin Read\r
+    NumBytes              - On input, indicates the requested write size. On\r
+                            output, indicates the actual number of bytes Read\r
+    Buffer                - Buffer containing source data for the Read.\r
+\r
+  Returns:\r
+    EFI_SUCCESS           - The firmware volume was read successfully and\r
+                            contents are in Buffer\r
+    EFI_BAD_BUFFER_SIZE   - Read attempted across a LBA boundary. On output,\r
+                            NumBytes contains the total number of bytes\r
+                            returned in Buffer\r
+    EFI_ACCESS_DENIED     - The firmware volume is in the ReadDisabled state\r
+    EFI_DEVICE_ERROR      - The block device is not functioning correctly and\r
+                            could not be read\r
+    EFI_INVALID_PARAMETER - NumBytes or Buffer are NULL\r
 \r
 --*/\r
 {\r
-  return QemuFlashRead ((EFI_LBA)Lba, (UINTN)Offset, NumBytes, (UINT8 *)Buffer);\r
+  return QemuFlashRead ((EFI_LBA)Lba, (UINTN)Offset, NumBytes,\r
+           (UINT8 *)Buffer);\r
 }\r
 \r
 EFI_STATUS\r
@@ -845,15 +859,16 @@ ValidateFvHeader (
   )\r
 /*++\r
 \r
-Routine Description:\r
-  Check the integrity of firmware volume header\r
+  Routine Description:\r
+    Check the integrity of firmware volume header\r
 \r
-Arguments:\r
-  FwVolHeader           - A pointer to a firmware volume header\r
+  Arguments:\r
+    FwVolHeader           - A pointer to a firmware volume header\r
 \r
-Returns:\r
-  EFI_SUCCESS           - The firmware volume is consistent\r
-  EFI_NOT_FOUND         - The firmware volume has corrupted. So it is not an FV\r
+  Returns:\r
+    EFI_SUCCESS           - The firmware volume is consistent\r
+    EFI_NOT_FOUND         - The firmware volume has corrupted. So it is not an\r
+                            FV\r
 \r
 --*/\r
 {\r
@@ -876,7 +891,8 @@ Returns:
   // Verify the header checksum\r
   //\r
 \r
-  Checksum = CalculateSum16 ((UINT16 *) FwVolHeader, FwVolHeader->HeaderLength);\r
+  Checksum = CalculateSum16 ((UINT16 *) FwVolHeader,\r
+               FwVolHeader->HeaderLength);\r
   if (Checksum != 0) {\r
     UINT16 Expected;\r
 \r
@@ -963,7 +979,8 @@ InitializeVariableFvHeader (
     UINTN   Offset;\r
     UINTN   Start;\r
 \r
-    DEBUG ((EFI_D_INFO, "Variable FV header is not valid. It will be reinitialized.\n"));\r
+    DEBUG ((EFI_D_INFO,\r
+      "Variable FV header is not valid. It will be reinitialized.\n"));\r
 \r
     //\r
     // Get FvbInfo to provide in FwhInstance.\r
@@ -1007,12 +1024,12 @@ FvbInitialize (
   )\r
 /*++\r
 \r
-Routine Description:\r
-  This function does common initialization for FVB services\r
+  Routine Description:\r
+    This function does common initialization for FVB services\r
 \r
-Arguments:\r
+  Arguments:\r
 \r
-Returns:\r
+  Returns:\r
 \r
 --*/\r
 {\r
@@ -1034,7 +1051,8 @@ Returns:
     //\r
     // Return an error so image will be unloaded\r
     //\r
-    DEBUG ((EFI_D_INFO, "QEMU flash was not detected. Writable FVB is not being installed.\n"));\r
+    DEBUG ((EFI_D_INFO,\r
+      "QEMU flash was not detected. Writable FVB is not being installed.\n"));\r
     return EFI_WRITE_PROTECTED;\r
   }\r
 \r
@@ -1050,7 +1068,8 @@ Returns:
 \r
   Status = InitializeVariableFvHeader ();\r
   if (EFI_ERROR (Status)) {\r
-    DEBUG ((EFI_D_INFO, "QEMU Flash: Unable to initialize variable FV header\n"));\r
+    DEBUG ((EFI_D_INFO,\r
+      "QEMU Flash: Unable to initialize variable FV header\n"));\r
     return EFI_WRITE_PROTECTED;\r
   }\r
 \r
@@ -1067,14 +1086,18 @@ Returns:
     }\r
   }\r
 \r
-  BufferSize = (sizeof (EFI_FW_VOL_INSTANCE) + FwVolHeader->HeaderLength - sizeof (EFI_FIRMWARE_VOLUME_HEADER));\r
+  BufferSize = (sizeof (EFI_FW_VOL_INSTANCE) +\r
+                FwVolHeader->HeaderLength -\r
+                sizeof (EFI_FIRMWARE_VOLUME_HEADER)\r
+                );\r
 \r
   //\r
   // Only need to allocate once. There is only one copy of physical memory for\r
   // the private data of each FV instance. But in virtual mode or in physical\r
   // mode, the address of the the physical memory may be different.\r
   //\r
-  mFvbModuleGlobal->FvInstance[FVB_PHYSICAL] = AllocateRuntimePool (BufferSize);\r
+  mFvbModuleGlobal->FvInstance[FVB_PHYSICAL] = AllocateRuntimePool (\r
+                                                 BufferSize);\r
   ASSERT (mFvbModuleGlobal->FvInstance[FVB_PHYSICAL] != NULL);\r
 \r
   //\r
@@ -1093,13 +1116,16 @@ Returns:
   FwhInstance->FvBase[FVB_PHYSICAL] = (UINTN) BaseAddress;\r
   FwhInstance->FvBase[FVB_VIRTUAL]  = (UINTN) BaseAddress;\r
 \r
-  CopyMem ((UINTN *) &(FwhInstance->VolumeHeader), (UINTN *) FwVolHeader, FwVolHeader->HeaderLength);\r
+  CopyMem ((UINTN *) &(FwhInstance->VolumeHeader), (UINTN *) FwVolHeader,\r
+    FwVolHeader->HeaderLength);\r
   FwVolHeader = &(FwhInstance->VolumeHeader);\r
   EfiInitializeLock (&(FwhInstance->FvbDevLock), TPL_HIGH_LEVEL);\r
 \r
   NumOfBlocks = 0;\r
 \r
-  for (PtrBlockMapEntry = FwVolHeader->BlockMap; PtrBlockMapEntry->NumBlocks != 0; PtrBlockMapEntry++) {\r
+  for (PtrBlockMapEntry = FwVolHeader->BlockMap;\r
+       PtrBlockMapEntry->NumBlocks != 0;\r
+       PtrBlockMapEntry++) {\r
     //\r
     // Get the maximum size of a block.\r
     //\r
@@ -1130,24 +1156,35 @@ Returns:
   // Set up the devicepath\r
   //\r
   if (FwVolHeader->ExtHeaderOffset == 0) {\r
+    FV_MEMMAP_DEVICE_PATH *FvMemmapDevicePath;\r
+\r
     //\r
     // FV does not contains extension header, then produce MEMMAP_DEVICE_PATH\r
     //\r
-    FvbDevice->DevicePath = (EFI_DEVICE_PATH_PROTOCOL *) AllocateCopyPool (sizeof (FV_MEMMAP_DEVICE_PATH), &mFvMemmapDevicePathTemplate);\r
-    ((FV_MEMMAP_DEVICE_PATH *) FvbDevice->DevicePath)->MemMapDevPath.StartingAddress = BaseAddress;\r
-    ((FV_MEMMAP_DEVICE_PATH *) FvbDevice->DevicePath)->MemMapDevPath.EndingAddress   = BaseAddress + FwVolHeader->FvLength - 1;\r
+    FvMemmapDevicePath = AllocateCopyPool (sizeof (FV_MEMMAP_DEVICE_PATH),\r
+                           &mFvMemmapDevicePathTemplate);\r
+    FvMemmapDevicePath->MemMapDevPath.StartingAddress = BaseAddress;\r
+    FvMemmapDevicePath->MemMapDevPath.EndingAddress   =\r
+      BaseAddress + FwVolHeader->FvLength - 1;\r
+    FvbDevice->DevicePath = (EFI_DEVICE_PATH_PROTOCOL *)FvMemmapDevicePath;\r
   } else {\r
-    FvbDevice->DevicePath = (EFI_DEVICE_PATH_PROTOCOL *) AllocateCopyPool (sizeof (FV_PIWG_DEVICE_PATH), &mFvPIWGDevicePathTemplate);\r
+    FV_PIWG_DEVICE_PATH *FvPiwgDevicePath;\r
+\r
+    FvPiwgDevicePath = AllocateCopyPool (sizeof (FV_PIWG_DEVICE_PATH),\r
+                         &mFvPIWGDevicePathTemplate);\r
     CopyGuid (\r
-      &((FV_PIWG_DEVICE_PATH *)FvbDevice->DevicePath)->FvDevPath.FvName,\r
+      &FvPiwgDevicePath->FvDevPath.FvName,\r
       (GUID *)(UINTN)(BaseAddress + FwVolHeader->ExtHeaderOffset)\r
       );\r
+    FvbDevice->DevicePath = (EFI_DEVICE_PATH_PROTOCOL *)FvPiwgDevicePath;\r
   }\r
 \r
   //\r
-  // Find a handle with a matching device path that has supports FW Block protocol\r
+  // Find a handle with a matching device path that has supports FW Block\r
+  // protocol\r
   //\r
-  Status = gBS->LocateDevicePath (&gEfiFirmwareVolumeBlockProtocolGuid, &FvbDevice->DevicePath, &FwbHandle);\r
+  Status = gBS->LocateDevicePath (&gEfiFirmwareVolumeBlockProtocolGuid,\r
+                  &FvbDevice->DevicePath, &FwbHandle);\r
   if (EFI_ERROR (Status)) {\r
     //\r
     // LocateDevicePath fails so install a new interface and device path\r