]> git.proxmox.com Git - mirror_edk2.git/blobdiff - EdkNt32Pkg/RuntimeDxe/FvbServices/FWBlockService.c
Add PcdComponentName2Disable and PcdDriverDiagnostics2Disable.
[mirror_edk2.git] / EdkNt32Pkg / RuntimeDxe / FvbServices / FWBlockService.c
index 8824dc412afd89cd368cf70559c8d91e2fdf851a..e71fadaa1c44a4120988f02875a7008ad143aa6e 100644 (file)
@@ -1,18 +1,18 @@
 /*++\r
 \r
-Copyright (c) 2006, 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
-which accompanies this distribution.  The full text of the license may be found at        \r
-http://opensource.org/licenses/bsd-license.php                                            \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
+Copyright (c) 2006 - 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
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\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
   FWBlockService.c\r
-    \r
+\r
 Abstract:\r
 \r
 Revision History\r
@@ -81,14 +81,14 @@ Routine Description:
   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
+  mFvbModuleGlobal->FvInstance[FVB_VIRTUAL]   - Virtual pointer to common\r
                                                 instance data.\r
 \r
 Arguments:\r
 \r
   (Standard EFI notify event - EFI_EVENT_NOTIFY)\r
 \r
-Returns: \r
+Returns:\r
 \r
   None\r
 \r
@@ -138,7 +138,7 @@ Arguments:
   FwhInstance           - The EFI_FW_VOL_INSTANCE fimrware instance structure\r
   Virtual               - Whether CPU is in virtual or physical mode\r
 \r
-Returns: \r
+Returns:\r
   EFI_SUCCESS           - Successfully returns\r
   EFI_INVALID_PARAMETER - Instance not found\r
 \r
@@ -182,14 +182,14 @@ Routine Description:
 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
+  Address               - Pointer to a caller allocated EFI_PHYSICAL_ADDRESS\r
                           that on successful return, contains the base address\r
-                          of the firmware volume. \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
+Returns:\r
   EFI_SUCCESS           - Successfully returns\r
   EFI_INVALID_PARAMETER - Instance not found\r
 \r
@@ -222,14 +222,14 @@ Routine Description:
   resulting attributes in output parameter\r
 \r
 Arguments:\r
-  Instance              - The FV instance whose attributes is going to be \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
+Returns:\r
   EFI_SUCCESS           - Successfully returns\r
   EFI_INVALID_PARAMETER - Instance not found\r
 \r
@@ -266,7 +266,7 @@ Routine Description:
 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
+  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
@@ -277,7 +277,7 @@ Arguments:
                           instance data\r
   Virtual               - Whether CPU is in virtual or physical mode\r
 \r
-Returns: \r
+Returns:\r
   EFI_SUCCESS           - Successfully returns\r
   EFI_INVALID_PARAMETER - Instance not found\r
 \r
@@ -369,14 +369,14 @@ Arguments:
                           instance data\r
   Virtual               - Whether CPU is in virtual or physical mode\r
 \r
-Returns: \r
-  EFI_SUCCESS           - The firmware volume was read successfully and \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
+  EFI_DEVICE_ERROR      - The block device is not functioning correctly and\r
                           could not be read\r
   EFI_INVALID_PARAMETER - Instance not found, or NumBytes, Buffer are NULL\r
 \r
@@ -455,13 +455,13 @@ Arguments:
                           instance data\r
   Virtual               - Whether CPU is in virtual or physical mode\r
 \r
-Returns: \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
+  EFI_DEVICE_ERROR      - The block device is not functioning correctly and\r
                           could not be written\r
   EFI_INVALID_PARAMETER - Instance not found, or NumBytes, Buffer are NULL\r
 \r
@@ -533,10 +533,10 @@ Arguments:
                           instance data\r
   Virtual               - Whether CPU is in virtual or physical mode\r
 \r
-Returns: \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
+  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
   EFI_INVALID_PARAMETER - Instance not found\r
@@ -596,7 +596,7 @@ Routine Description:
 Arguments:\r
   Instance              - The FV instance to be erased\r
   StartLba              - The starting logical block index to be erased\r
-  OffsetStartLba        - Offset into the starting block at which to \r
+  OffsetStartLba        - Offset into the starting block at which to\r
                           begin erasing\r
   LastLba               - The last logical block index to be erased\r
   OffsetStartLba        - Offset into the last block at which to end erasing\r
@@ -604,10 +604,10 @@ Arguments:
                           instance data\r
   Virtual               - Whether CPU is in virtual or physical mode\r
 \r
-Returns: \r
+Returns:\r
   EFI_SUCCESS           - The firmware volume was erased successfully\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
+  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
   EFI_INVALID_PARAMETER - Instance not found\r
@@ -681,13 +681,13 @@ FvbSetVolumeAttributes (
 /*++\r
 \r
 Routine Description:\r
-  Modifies the current settings of the firmware volume according to the \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
+  Instance              - The FV instance whose attributes is going to be\r
                           modified\r
-  Attributes            - On input, it is a pointer to EFI_FVB_ATTRIBUTES \r
+  Attributes            - On input, it is a pointer to EFI_FVB_ATTRIBUTES\r
                           containing the desired firmware volume settings.\r
                           On successful return, it contains the new settings\r
                           of the firmware volume\r
@@ -695,7 +695,7 @@ Arguments:
                           instance data\r
   Virtual               - Whether CPU is in virtual or physical mode\r
 \r
-Returns: \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
@@ -801,7 +801,7 @@ Arguments:
 \r
 Returns:\r
 \r
-Returns: \r
+Returns:\r
   EFI_SUCCESS           - Successfully returns\r
 \r
 --*/\r
@@ -836,8 +836,8 @@ Arguments:
                           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
+Returns:\r
+  EFI_SUCCESS           - The firmware volume was read successfully and\r
                           contents are in Buffer\r
 \r
 --*/\r
@@ -872,7 +872,7 @@ Arguments:
     This                - Calling context\r
     Attributes          - output buffer which contains attributes\r
 \r
-Returns: \r
+Returns:\r
   EFI_SUCCESS           - Successfully returns\r
 \r
 --*/\r
@@ -899,7 +899,7 @@ Arguments:
   This                  - Calling context\r
   Attributes            - output buffer which contains attributes\r
 \r
-Returns: \r
+Returns:\r
   EFI_SUCCESS           - Successfully returns\r
 \r
 --*/\r
@@ -915,28 +915,28 @@ EFI_STATUS
 EFIAPI\r
 FvbProtocolEraseBlocks (\r
   IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL    *This,\r
-  ...  \r
+  ...\r
   )\r
 /*++\r
 \r
 Routine Description:\r
 \r
-  The EraseBlock() function erases one or more blocks as denoted by the \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
+  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
 \r
 Arguments:\r
   This                  - Calling context\r
-  ...                   - Starting LBA followed by Number of Lba to erase. \r
+  ...                   - Starting LBA followed by Number of Lba to erase.\r
                           a -1 to terminate the list.\r
 \r
-Returns: \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
+  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
@@ -1037,13 +1037,13 @@ Arguments:
                           output, indicates the actual number of bytes written\r
   Buffer                - Buffer containing source data for the write.\r
 \r
-Returns: \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
+  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
@@ -1085,14 +1085,14 @@ Arguments:
                           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
+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
+  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
@@ -1125,15 +1125,15 @@ Routine Description:
 Arguments:\r
   This                  - Calling context\r
   StartLba              - The starting logical block index to be erased\r
-  OffsetStartLba        - Offset into the starting block at which to \r
+  OffsetStartLba        - Offset into the starting block at which to\r
                           begin erasing\r
   LastLba               - The last logical block index to be erased\r
   OffsetStartLba        - Offset into the last block at which to end erasing\r
 \r
-Returns: \r
+Returns:\r
   EFI_SUCCESS           - The firmware volume was erased successfully\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
+  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
@@ -1167,7 +1167,7 @@ Routine Description:
 Arguments:\r
   FwVolHeader           - A pointer to a firmware volume header\r
 \r
-Returns: \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
 \r
@@ -1252,12 +1252,8 @@ Returns:
   // Allocate runtime services data for global variable, which contains\r
   // the private data of all firmware volume block instances\r
   //\r
-  Status = gBS->AllocatePool (\r
-                  EfiRuntimeServicesData,\r
-                  sizeof (ESAL_FWB_GLOBAL),\r
-                  &mFvbModuleGlobal\r
-                  );\r
-  ASSERT_EFI_ERROR (Status);\r
+  mFvbModuleGlobal = AllocateRuntimePool (sizeof (ESAL_FWB_GLOBAL));\r
+  ASSERT (mFvbModuleGlobal != NULL);\r
 \r
   //\r
   // Calculate the total size for all firmware volume block instances\r
@@ -1306,12 +1302,8 @@ Returns:
   // 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
-  Status = gBS->AllocatePool (\r
-                  EfiRuntimeServicesData,\r
-                  BufferSize,\r
-                  &mFvbModuleGlobal->FvInstance[FVB_PHYSICAL]\r
-                  );\r
-  ASSERT_EFI_ERROR (Status);\r
+  mFvbModuleGlobal->FvInstance[FVB_PHYSICAL] = AllocateRuntimePool (BufferSize);\r
+  ASSERT (mFvbModuleGlobal->FvInstance[FVB_PHYSICAL] != NULL);\r
 \r
   //\r
   // Make a virtual copy of the FvInstance pointer.\r
@@ -1392,12 +1384,8 @@ Returns:
     //\r
     // Add a FVB Protocol Instance\r
     //\r
-    Status = gBS->AllocatePool (\r
-                    EfiRuntimeServicesData,\r
-                    sizeof (EFI_FW_VOL_BLOCK_DEVICE),\r
-                    &FvbDevice\r
-                    );\r
-    ASSERT_EFI_ERROR (Status);\r
+    FvbDevice = AllocateRuntimePool (sizeof (EFI_FW_VOL_BLOCK_DEVICE));\r
+    ASSERT (FvbDevice != NULL);\r
 \r
     CopyMem (FvbDevice, &mFvbDeviceTemplate, sizeof (EFI_FW_VOL_BLOCK_DEVICE));\r
 \r
@@ -1481,12 +1469,8 @@ Returns:
   //\r
   // Allocate for scratch space, an intermediate buffer for FVB extention\r
   //\r
-  Status = gBS->AllocatePool (\r
-                  EfiRuntimeServicesData,\r
-                  MaxLbaSize,\r
-                  &mFvbModuleGlobal->FvbScratchSpace[FVB_PHYSICAL]\r
-                  );\r
-  ASSERT_EFI_ERROR (Status);\r
+  mFvbModuleGlobal->FvbScratchSpace[FVB_PHYSICAL] = AllocateRuntimePool (MaxLbaSize);\r
+  ASSERT (mFvbModuleGlobal->FvbScratchSpace[FVB_PHYSICAL] != NULL);\r
 \r
   mFvbModuleGlobal->FvbScratchSpace[FVB_VIRTUAL] = mFvbModuleGlobal->FvbScratchSpace[FVB_PHYSICAL];\r
 \r