]> git.proxmox.com Git - mirror_edk2.git/blobdiff - IntelFrameworkModulePkg/Library/BaseUefiTianoCustomDecompressLib/BaseUefiTianoCustomDecompressLib.c
Correct parameter UINTN to UINT32. Fix UINTN conver to UINT32
[mirror_edk2.git] / IntelFrameworkModulePkg / Library / BaseUefiTianoCustomDecompressLib / BaseUefiTianoCustomDecompressLib.c
index acde4d503e3eb8f4619975bfcda72364643374cc..061222dae00b683e3108338ef99caaa04aaa65d8 100644 (file)
@@ -12,6 +12,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 \r
 **/\r
 \r
+#include <Guid/CustomDecompress.h>\r
 #include "BaseUefiTianoCustomDecompressLibInternals.h"\r
 \r
 VOID\r
@@ -775,6 +776,7 @@ Returns:
 RETURN_STATUS\r
 EFIAPI\r
 CustomDecompressGetInfo (\r
+  IN  CONST GUID *DecompressGuid,\r
   IN  CONST VOID  *Source,\r
   IN  UINT32      SourceSize,\r
   OUT UINT32      *DestinationSize,\r
@@ -787,7 +789,7 @@ Routine Description:
   The internal implementation of *_DECOMPRESS_PROTOCOL.GetInfo().\r
 \r
 Arguments:\r
-\r
+  DecompressGuid    The guid matches this decompress method.\r
   Source          - The source buffer containing the compressed data.\r
   SourceSize      - The size of source buffer\r
   DestinationSize - The size of destination buffer.\r
@@ -797,15 +799,21 @@ Returns:
 \r
   RETURN_SUCCESS           - The size of destination buffer and the size of scratch buffer are successull retrieved.\r
   RETURN_INVALID_PARAMETER - The source data is corrupted\r
+  RETURN_UNSUPPORTED       - Decompress method is not supported.\r
 \r
 --*/\r
 {\r
-  return UefiDecompressGetInfo (Source, SourceSize, DestinationSize, ScratchSize);\r
+  if (CompareGuid (DecompressGuid, &gTianoCustomDecompressGuid)) {\r
+    return UefiDecompressGetInfo (Source, SourceSize, DestinationSize, ScratchSize);\r
+  } else {\r
+    return RETURN_UNSUPPORTED;\r
+  }\r
 }\r
 \r
 RETURN_STATUS\r
 EFIAPI\r
 CustomDecompress (\r
+  IN  CONST GUID *DecompressGuid,\r
   IN CONST VOID  *Source,\r
   IN OUT VOID    *Destination,\r
   IN OUT VOID    *Scratch\r
@@ -817,7 +825,7 @@ Routine Description:
   The internal implementation of *_DECOMPRESS_PROTOCOL.Decompress().\r
 \r
 Arguments:\r
-\r
+  DecompressGuid    The guid matches this decompress method.\r
   Source          - The source buffer containing the compressed data.\r
   Destination     - The destination buffer to store the decompressed data\r
   Scratch         - The buffer used internally by the decompress routine. This  buffer is needed to store intermediate data.\r
@@ -826,8 +834,50 @@ Returns:
 \r
   RETURN_SUCCESS           - Decompression is successfull\r
   RETURN_INVALID_PARAMETER - The source data is corrupted\r
+  RETURN_UNSUPPORTED       - Decompress method is not supported.\r
 \r
 --*/\r
 {\r
-  return UefiTianoDecompress (Source, Destination, Scratch, 2);\r
+  if (CompareGuid (DecompressGuid, &gTianoCustomDecompressGuid)) {\r
+    return UefiTianoDecompress (Source, Destination, Scratch, 2);\r
+  } else {\r
+    return RETURN_UNSUPPORTED;\r
+  }\r
 }\r
+\r
+/**
+  Get decompress method guid list.\r
+\r
+  @param[in, out]  AlgorithmGuidTable   The decompress method guid list.
+  @param[in, out]  NumberOfAlgorithms   The number of decompress methods.
+
+  @retval  RETURN_SUCCESS            Get all algorithmes list successfully.
+  @retval  RETURN_INVALID_PARAMETER  Input paramter error.\r
+  @retval  RETURN_OUT_OF_RESOURCES   Source is not enough.\r
+\r
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+CustomDecompressGetAlgorithms (\r
+   IN OUT  GUID    **AlgorithmGuidTable,\r
+   IN OUT  UINT32  *NumberOfAlgorithms\r
+  )\r
+{\r
+  if (NumberOfAlgorithms == NULL) {\r
+    return RETURN_INVALID_PARAMETER;\r
+  }\r
+  \r
+  if (*NumberOfAlgorithms < 1) {\r
+    *NumberOfAlgorithms = 1;\r
+    return RETURN_OUT_OF_RESOURCES;\r
+  }\r
+  \r
+  if (AlgorithmGuidTable == NULL) {\r
+    return RETURN_INVALID_PARAMETER;\r
+  }\r
+\r
+  AlgorithmGuidTable [0] = &gTianoCustomDecompressGuid;\r
+  *NumberOfAlgorithms = 1;\r
+  \r
+  return RETURN_SUCCESS;  \r
+}
\ No newline at end of file