]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Include/Protocol/Decompress.h
MdePkg: Clean up source files
[mirror_edk2.git] / MdePkg / Include / Protocol / Decompress.h
1 /** @file
2 The Decompress Protocol Interface as defined in UEFI spec
3
4 Copyright (c) 2006 - 2018, 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 __DECOMPRESS_H__
16 #define __DECOMPRESS_H__
17
18 #define EFI_DECOMPRESS_PROTOCOL_GUID \
19 { \
20 0xd8117cfe, 0x94a6, 0x11d4, {0x9a, 0x3a, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d } \
21 }
22
23 typedef struct _EFI_DECOMPRESS_PROTOCOL EFI_DECOMPRESS_PROTOCOL;
24
25 /**
26 The GetInfo() function retrieves the size of the uncompressed buffer
27 and the temporary scratch buffer required to decompress the buffer
28 specified by Source and SourceSize. If the size of the uncompressed
29 buffer or the size of the scratch buffer cannot be determined from
30 the compressed data specified by Source and SourceData, then
31 EFI_INVALID_PARAMETER is returned. Otherwise, the size of the uncompressed
32 buffer is returned in DestinationSize, the size of the scratch buffer is
33 returned in ScratchSize, and EFI_SUCCESS is returned.
34
35 The GetInfo() function does not have a scratch buffer available to perform
36 a thorough checking of the validity of the source data. It just retrieves
37 the 'Original Size' field from the beginning bytes of the source data and
38 output it as DestinationSize. And ScratchSize is specific to the decompression
39 implementation.
40
41 @param This A pointer to the EFI_DECOMPRESS_PROTOCOL instance.
42 @param Source The source buffer containing the compressed data.
43 @param SourceSize The size, in bytes, of source buffer.
44 @param DestinationSize A pointer to the size, in bytes, of the uncompressed buffer
45 that will be generated when the compressed buffer specified
46 by Source and SourceSize is decompressed.
47 @param ScratchSize A pointer to the size, in bytes, of the scratch buffer that
48 is required to decompress the compressed buffer specified by
49 Source and SourceSize.
50
51 @retval EFI_SUCCESS The size of the uncompressed data was returned in DestinationSize
52 and the size of the scratch buffer was returned in ScratchSize.
53 @retval EFI_INVALID_PARAMETER The size of the uncompressed data or the size of the scratch
54 buffer cannot be determined from the compressed data specified by
55 Source and SourceData.
56
57 **/
58 typedef
59 EFI_STATUS
60 (EFIAPI *EFI_DECOMPRESS_GET_INFO)(
61 IN EFI_DECOMPRESS_PROTOCOL *This,
62 IN VOID *Source,
63 IN UINT32 SourceSize,
64 OUT UINT32 *DestinationSize,
65 OUT UINT32 *ScratchSize
66 );
67
68 /**
69 The Decompress() function extracts decompressed data to its original form.
70
71 This protocol is designed so that the decompression algorithm can be
72 implemented without using any memory services. As a result, the
73 Decompress() function is not allowed to call AllocatePool() or
74 AllocatePages() in its implementation. It is the caller's responsibility
75 to allocate and free the Destination and Scratch buffers.
76
77 If the compressed source data specified by Source and SourceSize is
78 successfully decompressed into Destination, then EFI_SUCCESS is returned.
79 If the compressed source data specified by Source and SourceSize is not in
80 a valid compressed data format, then EFI_INVALID_PARAMETER is returned.
81
82 @param This A pointer to the EFI_DECOMPRESS_PROTOCOL instance.
83 @param Source The source buffer containing the compressed data.
84 @param SourceSize The size of source data.
85 @param Destination On output, the destination buffer that contains
86 the uncompressed data.
87 @param DestinationSize The size of destination buffer. The size of destination
88 buffer needed is obtained from GetInfo().
89 @param Scratch A temporary scratch buffer that is used to perform the
90 decompression.
91 @param ScratchSize The size of scratch buffer. The size of scratch buffer needed
92 is obtained from GetInfo().
93
94 @retval EFI_SUCCESS Decompression completed successfully, and the uncompressed
95 buffer is returned in Destination.
96 @retval EFI_INVALID_PARAMETER The source buffer specified by Source and SourceSize is
97 corrupted (not in a valid compressed format).
98
99 **/
100 typedef
101 EFI_STATUS
102 (EFIAPI *EFI_DECOMPRESS_DECOMPRESS)(
103 IN EFI_DECOMPRESS_PROTOCOL *This,
104 IN VOID *Source,
105 IN UINT32 SourceSize,
106 IN OUT VOID *Destination,
107 IN UINT32 DestinationSize,
108 IN OUT VOID *Scratch,
109 IN UINT32 ScratchSize
110 );
111
112 ///
113 /// Provides a decompression service.
114 ///
115 struct _EFI_DECOMPRESS_PROTOCOL {
116 EFI_DECOMPRESS_GET_INFO GetInfo;
117 EFI_DECOMPRESS_DECOMPRESS Decompress;
118 };
119
120 extern EFI_GUID gEfiDecompressProtocolGuid;
121
122 #endif