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