]> git.proxmox.com Git - mirror_edk2.git/blobdiff - FatPkg/FatPei/FatLitePeim.h
FatPkg: Add GPT check in FatPei to support Capsule-on-Disk feature.
[mirror_edk2.git] / FatPkg / FatPei / FatLitePeim.h
index 69429fe03a17924d1da1342e5dcf246de90fdc2f..82ab045f2a8f11df8cb14ae82b635c70f379c1b1 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Data structures for FAT recovery PEIM\r
 \r
-Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.<BR>\r
 \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
@@ -20,12 +20,14 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 \r
 #include <Guid/RecoveryDevice.h>\r
 #include <Ppi/BlockIo.h>\r
+#include <Ppi/BlockIo2.h>\r
 #include <Ppi/DeviceRecoveryModule.h>\r
 \r
 #include <Library/DebugLib.h>\r
 #include <Library/BaseLib.h>\r
 #include <Library/PeimEntryPoint.h>\r
 #include <Library/BaseMemoryLib.h>\r
+#include <Library/MemoryAllocationLib.h>\r
 #include <Library/PcdLib.h>\r
 #include <Library/PeiServicesTablePointerLib.h>\r
 #include <Library/PeiServicesLib.h>\r
@@ -36,8 +38,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 //\r
 // Definitions\r
 //\r
-#define PEI_FAT_RECOVERY_CAPSULE_WITH_NT_EMULATOR     L"fv0001.fv"\r
-#define PEI_FAT_RECOVERY_CAPSULE_WITHOUT_NT_EMULATOR  L"fvmain.fv"\r
 \r
 #define PEI_FAT_CACHE_SIZE                            4\r
 #define PEI_FAT_MAX_BLOCK_SIZE                        8192\r
@@ -73,11 +73,13 @@ typedef struct {
   // Following fields only valid for physical device\r
   //\r
   EFI_PEI_BLOCK_DEVICE_TYPE     DevType;\r
+  UINT8                         InterfaceType;\r
   //\r
   // EFI_PEI_READ_BLOCKS         ReadFunc;\r
   //\r
-  EFI_PEI_RECOVERY_BLOCK_IO_PPI *BlockIo;\r
-  UINT8                         PhysicalDevNo;\r
+  EFI_PEI_RECOVERY_BLOCK_IO_PPI  *BlockIo;\r
+  EFI_PEI_RECOVERY_BLOCK_IO2_PPI *BlockIo2;\r
+  UINT8                          PhysicalDevNo;\r
 } PEI_FAT_BLOCK_DEVICE;\r
 \r
 //\r
@@ -150,7 +152,7 @@ typedef struct {
   UINTN                               Signature;\r
   EFI_PEI_DEVICE_RECOVERY_MODULE_PPI  DeviceRecoveryPpi;\r
   EFI_PEI_PPI_DESCRIPTOR              PpiDescriptor;\r
-  EFI_PEI_NOTIFY_DESCRIPTOR           NotifyDescriptor;\r
+  EFI_PEI_NOTIFY_DESCRIPTOR           NotifyDescriptor[2];\r
 \r
   UINT8                               UnicodeCaseMap[0x300];\r
   CHAR8                               *EngUpperMap;\r
@@ -192,16 +194,16 @@ typedef struct {
   This function finds the the recovery file named FileName on a specified FAT volume and returns\r
   its FileHandle pointer.\r
 \r
-  @param  PrivateData             Global memory map for accessing global \r
-                                  variables. \r
-  @param  VolumeIndex             The index of the volume. \r
-  @param  FileName                The recovery file name to find. \r
-  @param  Handle                  The output file handle. \r
+  @param  PrivateData             Global memory map for accessing global\r
+                                  variables.\r
+  @param  VolumeIndex             The index of the volume.\r
+  @param  FileName                The recovery file name to find.\r
+  @param  Handle                  The output file handle.\r
 \r
-  @retval EFI_DEVICE_ERROR        Some error occured when operating the FAT \r
-                                  volume. \r
-  @retval EFI_NOT_FOUND           The recovery file was not found. \r
-  @retval EFI_SUCCESS             The recovery file was successfully found on the \r
+  @retval EFI_DEVICE_ERROR        Some error occured when operating the FAT\r
+                                  volume.\r
+  @retval EFI_NOT_FOUND           The recovery file was not found.\r
+  @retval EFI_SUCCESS             The recovery file was successfully found on the\r
                                   FAT volume.\r
 \r
 **/\r
@@ -220,14 +222,14 @@ FindRecoveryFile (
   returns the number and maximum size in bytes of the capsules discovered.Entry 1 is assumed to be\r
   the highest load priority and entry N is assumed to be the lowest priority.\r
 \r
-  @param  PeiServices             General-purpose services that are available to \r
-                                  every PEIM. \r
-  @param  This                    Indicates the \r
-                                  EFI_PEI_DEVICE_RECOVERY_MODULE_PPI instance. \r
-  @param  NumberRecoveryCapsules  Pointer to a caller-allocated UINTN.On output, \r
-                                  *NumberRecoveryCapsules contains the number of \r
-                                  recovery capsule images available for retrieval \r
-                                  from this PEIM instance. \r
+  @param  PeiServices             General-purpose services that are available to\r
+                                  every PEIM.\r
+  @param  This                    Indicates the\r
+                                  EFI_PEI_DEVICE_RECOVERY_MODULE_PPI instance.\r
+  @param  NumberRecoveryCapsules  Pointer to a caller-allocated UINTN.On output,\r
+                                  *NumberRecoveryCapsules contains the number of\r
+                                  recovery capsule images available for retrieval\r
+                                  from this PEIM instance.\r
 \r
   @retval EFI_SUCCESS             The function completed successfully.\r
 \r
@@ -245,26 +247,26 @@ GetNumberRecoveryCapsules (
   Returns the size and type of the requested recovery capsule.\r
   This function returns the size and type of the capsule specified by CapsuleInstance.\r
 \r
-  @param  PeiServices             General-purpose services that are available to \r
-                                  every PEIM. \r
-  @param  This                    Indicates the \r
-                                  EFI_PEI_DEVICE_RECOVERY_MODULE_PPI instance. \r
-  @param  CapsuleInstance         Specifies for which capsule instance to \r
-                                  retrieve the information.T his parameter must \r
-                                  be between one and the value returned by \r
-                                  GetNumberRecoveryCapsules() in \r
-                                  NumberRecoveryCapsules. \r
-  @param  Size                    A pointer to a caller-allocated UINTN in which \r
-                                  the size of the requested recovery module is \r
-                                  returned. \r
-  @param  CapsuleType             A pointer to a caller-allocated EFI_GUID in \r
-                                  which the type of the requested recovery \r
-                                  capsule is returned.T he semantic meaning of \r
-                                  the value returned is defined by the \r
-                                  implementation. \r
-\r
-  @retval EFI_SUCCESS             The capsule type and size were retrieved. \r
-  @retval EFI_INVALID_PARAMETER   The input CapsuleInstance does not match any \r
+  @param  PeiServices             General-purpose services that are available to\r
+                                  every PEIM.\r
+  @param  This                    Indicates the\r
+                                  EFI_PEI_DEVICE_RECOVERY_MODULE_PPI instance.\r
+  @param  CapsuleInstance         Specifies for which capsule instance to\r
+                                  retrieve the information.T his parameter must\r
+                                  be between one and the value returned by\r
+                                  GetNumberRecoveryCapsules() in\r
+                                  NumberRecoveryCapsules.\r
+  @param  Size                    A pointer to a caller-allocated UINTN in which\r
+                                  the size of the requested recovery module is\r
+                                  returned.\r
+  @param  CapsuleType             A pointer to a caller-allocated EFI_GUID in\r
+                                  which the type of the requested recovery\r
+                                  capsule is returned.T he semantic meaning of\r
+                                  the value returned is defined by the\r
+                                  implementation.\r
+\r
+  @retval EFI_SUCCESS             The capsule type and size were retrieved.\r
+  @retval EFI_INVALID_PARAMETER   The input CapsuleInstance does not match any\r
                                   discovered recovery capsule.\r
 \r
 **/\r
@@ -285,12 +287,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
@@ -315,11 +317,11 @@ LoadRecoveryCapsule (
   to a Null-terminated Unicode string.\r
   Here does not expand DBCS FAT chars.\r
 \r
-  @param  FatSize           The size of the string Fat in bytes. \r
-  @param  Fat               A pointer to a Null-terminated string that contains \r
-                            an 8.3 file name using an OEM character set. \r
-  @param  Str               A pointer to a Null-terminated Unicode string. The \r
-                            string must be allocated in advance to hold FatSize \r
+  @param  FatSize           The size of the string Fat in bytes.\r
+  @param  Fat               A pointer to a Null-terminated string that contains\r
+                            an 8.3 file name using an OEM character set.\r
+  @param  Str               A pointer to a Null-terminated Unicode string. The\r
+                            string must be allocated in advance to hold FatSize\r
                             Unicode characters\r
 \r
 **/\r
@@ -334,8 +336,8 @@ EngFatToStr (
 /**\r
   Performs a case-insensitive comparison of two Null-terminated Unicode strings.\r
 \r
-  @param  PrivateData       Global memory map for accessing global variables \r
-  @param  Str1              First string to perform case insensitive comparison. \r
+  @param  PrivateData       Global memory map for accessing global variables\r
+  @param  Str1              First string to perform case insensitive comparison.\r
   @param  Str2              Second string to perform case insensitive comparison.\r
 \r
 **/\r
@@ -351,15 +353,15 @@ EngStriColl (
   Reads a block of data from the block device by calling\r
   underlying Block I/O service.\r
 \r
-  @param  PrivateData       Global memory map for accessing global variables \r
-  @param  BlockDeviceNo     The index for the block device number. \r
-  @param  Lba               The logic block address to read data from. \r
-  @param  BufferSize        The size of data in byte to read. \r
-  @param  Buffer            The buffer of the \r
+  @param  PrivateData       Global memory map for accessing global variables\r
+  @param  BlockDeviceNo     The index for the block device number.\r
+  @param  Lba               The logic block address to read data from.\r
+  @param  BufferSize        The size of data in byte to read.\r
+  @param  Buffer            The buffer of the\r
 \r
-  @retval EFI_DEVICE_ERROR  The specified block device number exceeds the maximum \r
-                            device number. \r
-  @retval EFI_DEVICE_ERROR  The maximum address has exceeded the maximum address \r
+  @retval EFI_DEVICE_ERROR  The specified block device number exceeds the maximum\r
+                            device number.\r
+  @retval EFI_DEVICE_ERROR  The maximum address has exceeded the maximum address\r
                             of the block device.\r
 \r
 **/\r
@@ -379,16 +381,16 @@ FatReadBlock (
   volume structure. Note there should be a valid Block device number\r
   already set.\r
 \r
-  @param  PrivateData            Global memory map for accessing global \r
-                                 variables. \r
-  @param  Volume                 On input, the BlockDeviceNumber field of the \r
-                                 Volume  should be a valid value. On successful \r
-                                 output, all  fields except the VolumeNumber \r
-                                 field is initialized. \r
+  @param  PrivateData            Global memory map for accessing global\r
+                                 variables.\r
+  @param  Volume                 On input, the BlockDeviceNumber field of the\r
+                                 Volume  should be a valid value. On successful\r
+                                 output, all  fields except the VolumeNumber\r
+                                 field is initialized.\r
 \r
-  @retval EFI_SUCCESS            A FAT is found and the volume structure is \r
-                                 initialized. \r
-  @retval EFI_NOT_FOUND          There is no FAT on the corresponding device. \r
+  @retval EFI_SUCCESS            A FAT is found and the volume structure is\r
+                                 initialized.\r
+  @retval EFI_NOT_FOUND          There is no FAT on the corresponding device.\r
   @retval EFI_DEVICE_ERROR       There is something error while accessing device.\r
 \r
 **/\r
@@ -402,13 +404,13 @@ FatGetBpbInfo (
 /**\r
   Gets the next cluster in the cluster chain.\r
 \r
-  @param  PrivateData            Global memory map for accessing global variables \r
-  @param  Volume                 The volume \r
-  @param  Cluster                The cluster \r
-  @param  NextCluster            The cluster number of the next cluster \r
+  @param  PrivateData            Global memory map for accessing global variables\r
+  @param  Volume                 The volume\r
+  @param  Cluster                The cluster\r
+  @param  NextCluster            The cluster number of the next cluster\r
 \r
-  @retval EFI_SUCCESS            The address is got \r
-  @retval EFI_INVALID_PARAMETER  ClusterNo exceeds the MaxCluster of the volume. \r
+  @retval EFI_SUCCESS            The address is got\r
+  @retval EFI_INVALID_PARAMETER  ClusterNo exceeds the MaxCluster of the volume.\r
   @retval EFI_DEVICE_ERROR       Read disk error\r
 \r
 **/\r
@@ -424,11 +426,11 @@ FatGetNextCluster (
 /**\r
   Disk reading.\r
 \r
-  @param  PrivateData       the global memory map; \r
-  @param  BlockDeviceNo     the block device to read; \r
-  @param  StartingAddress   the starting address. \r
-  @param  Size              the amount of data to read. \r
-  @param  Buffer            the buffer holding the data \r
+  @param  PrivateData       the global memory map;\r
+  @param  BlockDeviceNo     the block device to read;\r
+  @param  StartingAddress   the starting address.\r
+  @param  Size              the amount of data to read.\r
+  @param  Buffer            the buffer holding the data\r
 \r
   @retval EFI_SUCCESS       The function completed successfully.\r
   @retval EFI_DEVICE_ERROR  Something error.\r
@@ -447,13 +449,13 @@ FatReadDisk (
 /**\r
   Set a file's CurrentPos and CurrentCluster, then compute StraightReadAmount.\r
 \r
-  @param  PrivateData            the global memory map \r
-  @param  File                   the file \r
-  @param  Pos                    the Position which is offset from the file's \r
-                                 CurrentPos \r
+  @param  PrivateData            the global memory map\r
+  @param  File                   the file\r
+  @param  Pos                    the Position which is offset from the file's\r
+                                 CurrentPos\r
 \r
-  @retval EFI_SUCCESS            Success. \r
-  @retval EFI_INVALID_PARAMETER  Pos is beyond file's size. \r
+  @retval EFI_SUCCESS            Success.\r
+  @retval EFI_INVALID_PARAMETER  Pos is beyond file's size.\r
   @retval EFI_DEVICE_ERROR       Something error while accessing media.\r
 \r
 **/\r
@@ -468,13 +470,13 @@ FatSetFilePos (
 /**\r
   Reads file data. Updates the file's CurrentPos.\r
 \r
-  @param  PrivateData            Global memory map for accessing global variables \r
-  @param  File                   The file. \r
-  @param  Size                   The amount of data to read. \r
-  @param  Buffer                 The buffer storing the data. \r
+  @param  PrivateData            Global memory map for accessing global variables\r
+  @param  File                   The file.\r
+  @param  Size                   The amount of data to read.\r
+  @param  Buffer                 The buffer storing the data.\r
 \r
-  @retval EFI_SUCCESS            The data is read. \r
-  @retval EFI_INVALID_PARAMETER  File is invalid. \r
+  @retval EFI_SUCCESS            The data is read.\r
+  @retval EFI_INVALID_PARAMETER  File is invalid.\r
   @retval EFI_DEVICE_ERROR       Something error while accessing media.\r
 \r
 **/\r
@@ -493,14 +495,14 @@ FatReadFile (
   The function updates the CurrentPos of the parent dir to after the item read.\r
   If no more items were found, the function returns EFI_NOT_FOUND.\r
 \r
-  @param  PrivateData            Global memory map for accessing global variables \r
-  @param  ParentDir              The parent directory. \r
-  @param  SubFile                The File structure containing the sub file that \r
-                                 is caught. \r
+  @param  PrivateData            Global memory map for accessing global variables\r
+  @param  ParentDir              The parent directory.\r
+  @param  SubFile                The File structure containing the sub file that\r
+                                 is caught.\r
 \r
-  @retval EFI_SUCCESS            The next sub file is obtained. \r
-  @retval EFI_INVALID_PARAMETER  The ParentDir is not a directory. \r
-  @retval EFI_NOT_FOUND          No more sub file exists. \r
+  @retval EFI_SUCCESS            The next sub file is obtained.\r
+  @retval EFI_INVALID_PARAMETER  The ParentDir is not a directory.\r
+  @retval EFI_NOT_FOUND          No more sub file exists.\r
   @retval EFI_DEVICE_ERROR       Something error while accessing media.\r
 \r
 **/\r