1 | /** @file
|
---|
2 | Provides services to decompress a buffer using the UEFI Decompress algorithm.
|
---|
3 |
|
---|
4 | The UEFI Decompress Library enables the decompression of objects that
|
---|
5 | were compressed using the UEFI compression scheme. The UEFI Decompress
|
---|
6 | Library is independent of environment and requires the caller to allocate
|
---|
7 | all required memory buffers.
|
---|
8 |
|
---|
9 | Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
|
---|
10 | SPDX-License-Identifier: BSD-2-Clause-Patent
|
---|
11 |
|
---|
12 | **/
|
---|
13 |
|
---|
14 | #ifndef __UEFI_DECPOMPRESS_LIB_H__
|
---|
15 | #define __UEFI_DECPOMPRESS_LIB_H__
|
---|
16 |
|
---|
17 | /**
|
---|
18 | Given a compressed source buffer, this function retrieves the size of
|
---|
19 | the uncompressed buffer and the size of the scratch buffer required
|
---|
20 | to decompress the compressed source buffer.
|
---|
21 |
|
---|
22 | Retrieves the size of the uncompressed buffer and the temporary scratch buffer
|
---|
23 | required to decompress the buffer specified by Source and SourceSize.
|
---|
24 | If the size of the uncompressed buffer or the size of the scratch buffer cannot
|
---|
25 | be determined from the compressed data specified by Source and SourceData,
|
---|
26 | then RETURN_INVALID_PARAMETER is returned. Otherwise, the size of the uncompressed
|
---|
27 | buffer is returned in DestinationSize, the size of the scratch buffer is returned
|
---|
28 | 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 beginning bytes of the source data and output it as DestinationSize.
|
---|
32 | And ScratchSize is specific to the decompression implementation.
|
---|
33 |
|
---|
34 | If Source is NULL, then ASSERT().
|
---|
35 | If DestinationSize is NULL, then ASSERT().
|
---|
36 | If ScratchSize is NULL, then ASSERT().
|
---|
37 |
|
---|
38 | @param Source The source buffer containing the compressed data.
|
---|
39 | @param SourceSize The size, in bytes, of the source buffer.
|
---|
40 | @param DestinationSize A pointer to the size, in bytes, of the uncompressed buffer
|
---|
41 | that will be generated when the compressed buffer specified
|
---|
42 | by Source and SourceSize is decompressed.
|
---|
43 | @param ScratchSize A pointer to the size, in bytes, of the scratch buffer that
|
---|
44 | is required to decompress the compressed buffer specified
|
---|
45 | by Source and SourceSize.
|
---|
46 |
|
---|
47 | @retval RETURN_SUCCESS The size of the uncompressed data was returned
|
---|
48 | in DestinationSize and the size of the scratch
|
---|
49 | buffer was returned in ScratchSize.
|
---|
50 | @retval RETURN_INVALID_PARAMETER
|
---|
51 | The size of the uncompressed data or the size of
|
---|
52 | the scratch buffer cannot be determined from
|
---|
53 | the compressed data specified by Source
|
---|
54 | and SourceSize.
|
---|
55 | **/
|
---|
56 | RETURN_STATUS
|
---|
57 | EFIAPI
|
---|
58 | UefiDecompressGetInfo (
|
---|
59 | IN CONST VOID *Source,
|
---|
60 | IN UINT32 SourceSize,
|
---|
61 | OUT UINT32 *DestinationSize,
|
---|
62 | OUT UINT32 *ScratchSize
|
---|
63 | );
|
---|
64 |
|
---|
65 | /**
|
---|
66 | Decompresses a compressed source buffer.
|
---|
67 |
|
---|
68 | Extracts decompressed data to its original form.
|
---|
69 | This function is designed so that the decompression algorithm can be implemented
|
---|
70 | without using any memory services. As a result, this function is not allowed to
|
---|
71 | call any memory allocation services in its implementation. It is the caller's
|
---|
72 | responsibility to allocate and free the Destination and Scratch buffers.
|
---|
73 | If the compressed source data specified by Source is successfully decompressed
|
---|
74 | into Destination, then RETURN_SUCCESS is returned. If the compressed source data
|
---|
75 | specified by Source is not in a valid compressed data format,
|
---|
76 | then RETURN_INVALID_PARAMETER is returned.
|
---|
77 |
|
---|
78 | If Source is NULL, then ASSERT().
|
---|
79 | If Destination is NULL, then ASSERT().
|
---|
80 | If the required scratch buffer size > 0 and Scratch is NULL, then ASSERT().
|
---|
81 |
|
---|
82 | @param Source The source buffer containing the compressed data.
|
---|
83 | @param Destination The destination buffer to store the decompressed data
|
---|
84 | @param Scratch A temporary scratch buffer that is used to perform the decompression.
|
---|
85 | This is an optional parameter that may be NULL if the
|
---|
86 | required scratch buffer size is 0.
|
---|
87 |
|
---|
88 | @retval RETURN_SUCCESS Decompression completed successfully, and
|
---|
89 | the uncompressed buffer is returned in Destination.
|
---|
90 | @retval RETURN_INVALID_PARAMETER
|
---|
91 | The source buffer specified by Source is corrupted
|
---|
92 | (not in a valid compressed format).
|
---|
93 | **/
|
---|
94 | RETURN_STATUS
|
---|
95 | EFIAPI
|
---|
96 | UefiDecompress (
|
---|
97 | IN CONST VOID *Source,
|
---|
98 | IN OUT VOID *Destination,
|
---|
99 | IN OUT VOID *Scratch OPTIONAL
|
---|
100 | );
|
---|
101 |
|
---|
102 | #endif
|
---|