Path: blob/main/sys/contrib/edk2/Include/Protocol/Decompress.h
96339 views
/** @file1The Decompress Protocol Interface as defined in UEFI spec23Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>4SPDX-License-Identifier: BSD-2-Clause-Patent56**/78#ifndef __DECOMPRESS_H__9#define __DECOMPRESS_H__1011#define EFI_DECOMPRESS_PROTOCOL_GUID \12{ \130xd8117cfe, 0x94a6, 0x11d4, {0x9a, 0x3a, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d } \14}1516typedef struct _EFI_DECOMPRESS_PROTOCOL EFI_DECOMPRESS_PROTOCOL;1718/**19The GetInfo() function retrieves the size of the uncompressed buffer20and the temporary scratch buffer required to decompress the buffer21specified by Source and SourceSize. If the size of the uncompressed22buffer or the size of the scratch buffer cannot be determined from23the compressed data specified by Source and SourceData, then24EFI_INVALID_PARAMETER is returned. Otherwise, the size of the uncompressed25buffer is returned in DestinationSize, the size of the scratch buffer is26returned in ScratchSize, and EFI_SUCCESS is returned.2728The GetInfo() function does not have a scratch buffer available to perform29a thorough checking of the validity of the source data. It just retrieves30the 'Original Size' field from the beginning bytes of the source data and31output it as DestinationSize. And ScratchSize is specific to the decompression32implementation.3334@param This A pointer to the EFI_DECOMPRESS_PROTOCOL instance.35@param Source The source buffer containing the compressed data.36@param SourceSize The size, in bytes, of source buffer.37@param DestinationSize A pointer to the size, in bytes, of the uncompressed buffer38that will be generated when the compressed buffer specified39by Source and SourceSize is decompressed.40@param ScratchSize A pointer to the size, in bytes, of the scratch buffer that41is required to decompress the compressed buffer specified by42Source and SourceSize.4344@retval EFI_SUCCESS The size of the uncompressed data was returned in DestinationSize45and the size of the scratch buffer was returned in ScratchSize.46@retval EFI_INVALID_PARAMETER The size of the uncompressed data or the size of the scratch47buffer cannot be determined from the compressed data specified by48Source and SourceData.4950**/51typedef52EFI_STATUS53(EFIAPI *EFI_DECOMPRESS_GET_INFO)(54IN EFI_DECOMPRESS_PROTOCOL *This,55IN VOID *Source,56IN UINT32 SourceSize,57OUT UINT32 *DestinationSize,58OUT UINT32 *ScratchSize59);6061/**62The Decompress() function extracts decompressed data to its original form.6364This protocol is designed so that the decompression algorithm can be65implemented without using any memory services. As a result, the66Decompress() function is not allowed to call AllocatePool() or67AllocatePages() in its implementation. It is the caller's responsibility68to allocate and free the Destination and Scratch buffers.6970If the compressed source data specified by Source and SourceSize is71successfully decompressed into Destination, then EFI_SUCCESS is returned.72If the compressed source data specified by Source and SourceSize is not in73a valid compressed data format, then EFI_INVALID_PARAMETER is returned.7475@param This A pointer to the EFI_DECOMPRESS_PROTOCOL instance.76@param Source The source buffer containing the compressed data.77@param SourceSize The size of source data.78@param Destination On output, the destination buffer that contains79the uncompressed data.80@param DestinationSize The size of destination buffer. The size of destination81buffer needed is obtained from GetInfo().82@param Scratch A temporary scratch buffer that is used to perform the83decompression.84@param ScratchSize The size of scratch buffer. The size of scratch buffer needed85is obtained from GetInfo().8687@retval EFI_SUCCESS Decompression completed successfully, and the uncompressed88buffer is returned in Destination.89@retval EFI_INVALID_PARAMETER The source buffer specified by Source and SourceSize is90corrupted (not in a valid compressed format).9192**/93typedef94EFI_STATUS95(EFIAPI *EFI_DECOMPRESS_DECOMPRESS)(96IN EFI_DECOMPRESS_PROTOCOL *This,97IN VOID *Source,98IN UINT32 SourceSize,99IN OUT VOID *Destination,100IN UINT32 DestinationSize,101IN OUT VOID *Scratch,102IN UINT32 ScratchSize103);104105///106/// Provides a decompression service.107///108struct _EFI_DECOMPRESS_PROTOCOL {109EFI_DECOMPRESS_GET_INFO GetInfo;110EFI_DECOMPRESS_DECOMPRESS Decompress;111};112113extern EFI_GUID gEfiDecompressProtocolGuid;114115#endif116117118