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