• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 - 2008, Intel Corporation. All rights reserved.<BR>
10 This program and the accompanying materials
11 are licensed and made available under the terms and conditions of the BSD License
12 which accompanies this distribution.  The full text of the license may be found at
13 http://opensource.org/licenses/bsd-license.php
14 
15 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
16 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
17 
18 **/
19 
20 #ifndef __UEFI_DECPOMPRESS_LIB_H__
21 #define __UEFI_DECPOMPRESS_LIB_H__
22 
23 /**
24   Given a compressed source buffer, this function retrieves the size of
25   the uncompressed buffer and the size of the scratch buffer required
26   to decompress the compressed source buffer.
27 
28   Retrieves the size of the uncompressed buffer and the temporary scratch buffer
29   required to decompress the buffer specified by Source and SourceSize.
30   If the size of the uncompressed buffer or the size of the scratch buffer cannot
31   be determined from the compressed data specified by Source and SourceData,
32   then RETURN_INVALID_PARAMETER is returned.  Otherwise, the size of the uncompressed
33   buffer is returned in DestinationSize, the size of the scratch buffer is returned
34   in ScratchSize, and RETURN_SUCCESS is returned.
35   This function does not have scratch buffer available to perform a thorough
36   checking of the validity of the source data.  It just retrieves the "Original Size"
37   field from the beginning bytes of the source data and output it as DestinationSize.
38   And ScratchSize is specific to the decompression implementation.
39 
40   If Source is NULL, then ASSERT().
41   If DestinationSize is NULL, then ASSERT().
42   If ScratchSize is NULL, then ASSERT().
43 
44   @param  Source          The source buffer containing the compressed data.
45   @param  SourceSize      The size, in bytes, of the source buffer.
46   @param  DestinationSize A pointer to the size, in bytes, of the uncompressed buffer
47                           that will be generated when the compressed buffer specified
48                           by Source and SourceSize is decompressed.
49   @param  ScratchSize     A pointer to the size, in bytes, of the scratch buffer that
50                           is required to decompress the compressed buffer specified
51                           by Source and SourceSize.
52 
53   @retval  RETURN_SUCCESS The size of the uncompressed data was returned
54                           in DestinationSize and the size of the scratch
55                           buffer was returned in ScratchSize.
56   @retval  RETURN_INVALID_PARAMETER
57                           The size of the uncompressed data or the size of
58                           the scratch buffer cannot be determined from
59                           the compressed data specified by Source
60                           and SourceSize.
61 **/
62 RETURN_STATUS
63 EFIAPI
64 UefiDecompressGetInfo (
65   IN  CONST VOID  *Source,
66   IN  UINT32      SourceSize,
67   OUT UINT32      *DestinationSize,
68   OUT UINT32      *ScratchSize
69   );
70 
71 /**
72   Decompresses a compressed source buffer.
73 
74   Extracts decompressed data to its original form.
75   This function is designed so that the decompression algorithm can be implemented
76   without using any memory services.  As a result, this function is not allowed to
77   call any memory allocation services in its implementation.  It is the caller's
78   responsibility to allocate and free the Destination and Scratch buffers.
79   If the compressed source data specified by Source is successfully decompressed
80   into Destination, then RETURN_SUCCESS is returned.  If the compressed source data
81   specified by Source is not in a valid compressed data format,
82   then RETURN_INVALID_PARAMETER is returned.
83 
84   If Source is NULL, then ASSERT().
85   If Destination is NULL, then ASSERT().
86   If the required scratch buffer size > 0 and Scratch is NULL, then ASSERT().
87 
88   @param  Source      The source buffer containing the compressed data.
89   @param  Destination The destination buffer to store the decompressed data
90   @param  Scratch     A temporary scratch buffer that is used to perform the decompression.
91                       This is an optional parameter that may be NULL if the
92                       required scratch buffer size is 0.
93 
94   @retval  RETURN_SUCCESS Decompression completed successfully, and
95                           the uncompressed buffer is returned in Destination.
96   @retval  RETURN_INVALID_PARAMETER
97                           The source buffer specified by Source is corrupted
98                           (not in a valid compressed format).
99 **/
100 RETURN_STATUS
101 EFIAPI
102 UefiDecompress (
103   IN CONST VOID  *Source,
104   IN OUT VOID    *Destination,
105   IN OUT VOID    *Scratch  OPTIONAL
106   );
107 
108 #endif
109