]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/Disk/CdExpressPei/PeiCdExpress.c
MdeModulePkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / MdeModulePkg / Universal / Disk / CdExpressPei / PeiCdExpress.c
index f78118a6a8b11e72dddc2c9fdc75c62354691bc5..b029c547292e07b4e982047cbad6649dd14192f4 100644 (file)
@@ -1,25 +1,20 @@
 /** @file\r
   Source file for CD recovery PEIM\r
 \r
-Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
 \r
-This program and the accompanying materials\r
-are licensed and made available under the terms and conditions\r
-of the BSD License which accompanies this distribution.  The\r
-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
+SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
 **/\r
 \r
 #include "PeiCdExpress.h"\r
 \r
 PEI_CD_EXPRESS_PRIVATE_DATA *mPrivateData = NULL;\r
+CHAR8 *mRecoveryFileName;\r
+UINTN mRecoveryFileNameSize;\r
 \r
 /**\r
-  Installs the Device Recovery Module PPI, Initialize BlockIo Ppi \r
+  Installs the Device Recovery Module PPI, Initialize BlockIo Ppi\r
   installation notification\r
 \r
   @param  FileHandle            The file handle of the image.\r
@@ -48,6 +43,16 @@ CdExpressPeimEntry (
     return EFI_OUT_OF_RESOURCES;\r
   }\r
 \r
+  mRecoveryFileNameSize = PcdGetSize(PcdRecoveryFileName) / sizeof(CHAR16);\r
+  mRecoveryFileName = AllocatePool(mRecoveryFileNameSize);\r
+  if (mRecoveryFileName == NULL) {\r
+    return EFI_OUT_OF_RESOURCES;\r
+  }\r
+  Status = UnicodeStrToAsciiStrS(PcdGetPtr(PcdRecoveryFileName), mRecoveryFileName, mRecoveryFileNameSize);\r
+  if (EFI_ERROR(Status)) {\r
+    return Status;\r
+  }\r
+\r
   //\r
   // Initialize Private Data (to zero, as is required by subsequent operations)\r
   //\r
@@ -106,8 +111,8 @@ CdExpressPeimEntry (
 }\r
 \r
 /**\r
-  BlockIo installation notification function. \r
-  \r
+  BlockIo installation notification function.\r
+\r
   This function finds out all the current Block IO PPIs in the system and add them\r
   into private data.\r
 \r
@@ -263,7 +268,7 @@ UpdateBlocksAndVolumes (
       if (EFI_ERROR (Status)) {\r
         continue;\r
       }\r
-  \r
+\r
       PrivateData->CapsuleCount++;\r
     }\r
 \r
@@ -399,7 +404,7 @@ FindRecoveryCapsules (
 \r
   @retval EFI_SUCCESS                   The recovery capsule is successfully found in the volume.\r
   @retval EFI_NOT_FOUND                 The recovery capsule is not found in the volume.\r
-  @retval Others                        \r
+  @retval Others\r
 \r
 **/\r
 EFI_STATUS\r
@@ -466,24 +471,25 @@ RetrieveCapsuleFileFromRoot (
       }\r
     }\r
 \r
-    if (Index != (sizeof (PEI_RECOVERY_FILE_NAME) - 1)) {\r
+    if (Index != mRecoveryFileNameSize - 1) {\r
       Buffer += FileRecord->Length;\r
       continue;\r
     }\r
 \r
-    if (!StringCmp (FileRecord->FileID, (UINT8 *) PEI_RECOVERY_FILE_NAME, sizeof (PEI_RECOVERY_FILE_NAME) - 1, FALSE)) {\r
+    if (!StringCmp (FileRecord->FileID, (UINT8 *)mRecoveryFileName, mRecoveryFileNameSize - 1, FALSE)) {\r
       Buffer += FileRecord->Length;\r
       continue;\r
     }\r
 \r
     PrivateData->CapsuleData[PrivateData->CapsuleCount].CapsuleStartLBA = FileRecord->LocationOfExtent[0];\r
-    PrivateData->CapsuleData[PrivateData->CapsuleCount].CapsuleSize =\r
+    PrivateData->CapsuleData[PrivateData->CapsuleCount].CapsuleBlockAlignedSize =\r
       (\r
         FileRecord->DataLength[0] /\r
         PEI_CD_BLOCK_SIZE +\r
         1\r
       ) *\r
       PEI_CD_BLOCK_SIZE;\r
+    PrivateData->CapsuleData[PrivateData->CapsuleCount].CapsuleSize = FileRecord->DataLength[0];\r
 \r
     return EFI_SUCCESS;\r
   }\r
@@ -495,18 +501,18 @@ RetrieveCapsuleFileFromRoot (
   Returns the number of DXE capsules residing on the device.\r
 \r
   This function searches for DXE capsules from the associated device and returns\r
-  the number and maximum size in bytes of the capsules discovered. Entry 1 is \r
-  assumed to be the highest load priority and entry N is assumed to be the lowest \r
+  the number and maximum size in bytes of the capsules discovered. Entry 1 is\r
+  assumed to be the highest load priority and entry N is assumed to be the lowest\r
   priority.\r
 \r
-  @param[in]  PeiServices              General-purpose services that are available \r
+  @param[in]  PeiServices              General-purpose services that are available\r
                                        to every PEIM\r
   @param[in]  This                     Indicates the EFI_PEI_DEVICE_RECOVERY_MODULE_PPI\r
                                        instance.\r
-  @param[out] NumberRecoveryCapsules   Pointer to a caller-allocated UINTN. On \r
-                                       output, *NumberRecoveryCapsules contains \r
-                                       the number of recovery capsule images \r
-                                       available for retrieval from this PEIM \r
+  @param[out] NumberRecoveryCapsules   Pointer to a caller-allocated UINTN. On\r
+                                       output, *NumberRecoveryCapsules contains\r
+                                       the number of recovery capsule images\r
+                                       available for retrieval from this PEIM\r
                                        instance.\r
 \r
   @retval EFI_SUCCESS        One or more capsules were discovered.\r
@@ -542,18 +548,18 @@ GetNumberRecoveryCapsules (
   This function gets the size and type of the capsule specified by CapsuleInstance.\r
 \r
   @param[in]  PeiServices       General-purpose services that are available to every PEIM\r
-  @param[in]  This              Indicates the EFI_PEI_DEVICE_RECOVERY_MODULE_PPI \r
+  @param[in]  This              Indicates the EFI_PEI_DEVICE_RECOVERY_MODULE_PPI\r
                                 instance.\r
-  @param[in]  CapsuleInstance   Specifies for which capsule instance to retrieve \r
-                                the information.  This parameter must be between \r
-                                one and the value returned by GetNumberRecoveryCapsules() \r
+  @param[in]  CapsuleInstance   Specifies for which capsule instance to retrieve\r
+                                the information.  This parameter must be between\r
+                                one and the value returned by GetNumberRecoveryCapsules()\r
                                 in NumberRecoveryCapsules.\r
-  @param[out] Size              A pointer to a caller-allocated UINTN in which \r
-                                the size of the requested recovery module is \r
+  @param[out] Size              A pointer to a caller-allocated UINTN in which\r
+                                the size of the requested recovery module is\r
                                 returned.\r
-  @param[out] CapsuleType       A pointer to a caller-allocated EFI_GUID in which \r
-                                the type of the requested recovery capsule is \r
-                                returned.  The semantic meaning of the value \r
+  @param[out] CapsuleType       A pointer to a caller-allocated EFI_GUID in which\r
+                                the type of the requested recovery capsule is\r
+                                returned.  The semantic meaning of the value\r
                                 returned is defined by the implementation.\r
 \r
   @retval EFI_SUCCESS        One or more capsules were discovered.\r
@@ -607,12 +613,12 @@ GetRecoveryCapsuleInfo (
   This function, by whatever mechanism, retrieves a DXE capsule from some device\r
   and loads it into memory. Note that the published interface is device neutral.\r
 \r
-  @param[in]     PeiServices       General-purpose services that are available \r
+  @param[in]     PeiServices       General-purpose services that are available\r
                                    to every PEIM\r
   @param[in]     This              Indicates the EFI_PEI_DEVICE_RECOVERY_MODULE_PPI\r
                                    instance.\r
   @param[in]     CapsuleInstance   Specifies which capsule instance to retrieve.\r
-  @param[out]    Buffer            Specifies a caller-allocated buffer in which \r
+  @param[out]    Buffer            Specifies a caller-allocated buffer in which\r
                                    the requested recovery capsule will be returned.\r
 \r
   @retval EFI_SUCCESS        The capsule was loaded correctly.\r
@@ -659,7 +665,7 @@ LoadRecoveryCapsule (
                           BlockIo2Ppi,\r
                           PrivateData->CapsuleData[CapsuleInstance - 1].IndexBlock,\r
                           PrivateData->CapsuleData[CapsuleInstance - 1].CapsuleStartLBA,\r
-                          PrivateData->CapsuleData[CapsuleInstance - 1].CapsuleSize,\r
+                          PrivateData->CapsuleData[CapsuleInstance - 1].CapsuleBlockAlignedSize,\r
                           Buffer\r
                           );\r
   } else {\r
@@ -668,7 +674,7 @@ LoadRecoveryCapsule (
                           BlockIoPpi,\r
                           PrivateData->CapsuleData[CapsuleInstance - 1].IndexBlock,\r
                           PrivateData->CapsuleData[CapsuleInstance - 1].CapsuleStartLBA,\r
-                          PrivateData->CapsuleData[CapsuleInstance - 1].CapsuleSize,\r
+                          PrivateData->CapsuleData[CapsuleInstance - 1].CapsuleBlockAlignedSize,\r
                           Buffer\r
                           );\r
   }\r