1 /** @file
2   LZMA Decompress Library internal header file declares Lzma decompress interfaces.
3 
4   Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>
5   This program and the accompanying materials
6   are licensed and made available under the terms and conditions of the BSD License
7   which accompanies this distribution.  The full text of the license may be found at
8   http://opensource.org/licenses/bsd-license.php
9 
10   THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11   WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12 
13 **/
14 
15 #ifndef __LZMADECOMPRESSLIB_INTERNAL_H__
16 #define __LZMADECOMPRESSLIB_INTERNAL_H__
17 
18 #include <PiPei.h>
19 #include <Library/BaseLib.h>
20 #include <Library/BaseMemoryLib.h>
21 #include <Library/DebugLib.h>
22 #include <Library/ExtractGuidedSectionLib.h>
23 #include <Guid/LzmaDecompress.h>
24 
25 /**
26   Given a Lzma compressed source buffer, this function retrieves the size of
27   the uncompressed buffer and the size of the scratch buffer required
28   to decompress the compressed source buffer.
29 
30   Retrieves the size of the uncompressed buffer and the temporary scratch buffer
31   required to decompress the buffer specified by Source and SourceSize.
32   The size of the uncompressed buffer is returned in DestinationSize,
33   the size of the scratch buffer is returned in ScratchSize, and RETURN_SUCCESS is returned.
34   This function does not have scratch buffer available to perform a thorough
35   checking of the validity of the source data. It just retrieves the "Original Size"
36   field from the LZMA_HEADER_SIZE beginning bytes of the source data and output it as DestinationSize.
37   And ScratchSize is specific to the decompression implementation.
38 
39   If SourceSize is less than LZMA_HEADER_SIZE, then ASSERT().
40 
41   @param  Source          The source buffer containing the compressed data.
42   @param  SourceSize      The size, in bytes, of the source buffer.
43   @param  DestinationSize A pointer to the size, in bytes, of the uncompressed buffer
44                           that will be generated when the compressed buffer specified
45                           by Source and SourceSize is decompressed.
46   @param  ScratchSize     A pointer to the size, in bytes, of the scratch buffer that
47                           is required to decompress the compressed buffer specified
48                           by Source and SourceSize.
49 
50   @retval  RETURN_SUCCESS The size of the uncompressed data was returned
51                           in DestinationSize and the size of the scratch
52                           buffer was returned in ScratchSize.
53 
54 **/
55 RETURN_STATUS
56 EFIAPI
57 LzmaUefiDecompressGetInfo (
58   IN  CONST VOID  *Source,
59   IN  UINT32      SourceSize,
60   OUT UINT32      *DestinationSize,
61   OUT UINT32      *ScratchSize
62   );
63 
64 /**
65   Decompresses a Lzma compressed source buffer.
66 
67   Extracts decompressed data to its original form.
68   If the compressed source data specified by Source is successfully decompressed
69   into Destination, then RETURN_SUCCESS is returned.  If the compressed source data
70   specified by Source is not in a valid compressed data format,
71   then RETURN_INVALID_PARAMETER is returned.
72 
73   @param  Source      The source buffer containing the compressed data.
74   @param  SourceSize  The size of source buffer.
75   @param  Destination The destination buffer to store the decompressed data
76   @param  Scratch     A temporary scratch buffer that is used to perform the decompression.
77                       This is an optional parameter that may be NULL if the
78                       required scratch buffer size is 0.
79 
80   @retval  RETURN_SUCCESS Decompression completed successfully, and
81                           the uncompressed buffer is returned in Destination.
82   @retval  RETURN_INVALID_PARAMETER
83                           The source buffer specified by Source is corrupted
84                           (not in a valid compressed format).
85 **/
86 RETURN_STATUS
87 EFIAPI
88 LzmaUefiDecompress (
89   IN CONST VOID  *Source,
90   IN UINTN       SourceSize,
91   IN OUT VOID    *Destination,
92   IN OUT VOID    *Scratch
93   );
94 
95 #endif
96 
97