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