From e5071a9fef1de414c0dfe2f1b5fc42d069bf9b37 Mon Sep 17 00:00:00 2001 From: jwang36 Date: Mon, 28 Apr 2008 03:13:42 +0000 Subject: [PATCH] Added Extract interface for easier wrapping of decompressor in Python git-svn-id: https://buildtools.tianocore.org/svn/buildtools/trunk/BaseTools@1180 7335b38e-4728-0410-8992-fb3ffe349368 --- Source/C/Common/Decompress.c | 34 ++++++++++++++++++++++++++++++++++ Source/C/Common/Decompress.h | 10 ++++++++++ 2 files changed, 44 insertions(+) diff --git a/Source/C/Common/Decompress.c b/Source/C/Common/Decompress.c index a76dd25..8e54b5d 100644 --- a/Source/C/Common/Decompress.c +++ b/Source/C/Common/Decompress.c @@ -921,3 +921,37 @@ Returns: mPbit = MAXPBIT; return Decompress (Source, SrcSize, Destination, DstSize, Scratch, ScratchSize); } + +EFI_STATUS +Extract ( + IN VOID *Source, + IN UINT32 SrcSize, + IN OUT VOID *Destination, + IN UINT32 DstSize, + IN UINT Algorithm + ) +{ + SCRATCH_DATA Scratch; + EFI_STATUS Status; + + Status = EFI_SUCCESS; + switch (Algorithm) { + case 0: + if (SrcSize != DstSize) { + return EFI_INVALID_PARAMETER; + } + memcpy(Destination, Source, DstSize); + break; + case 1: + Status = EfiDecompress(Source, SrcSize, Destination, DstSize, &Scratch, sizeof(SCRATCH_DATA)); + break; + case 2: + Status = TianoDecompress(Source, SrcSize, Destination, DstSize, &Scratch, sizeof(SCRATCH_DATA)); + break; + default: + Status = EFI_INVALID_PARAMETER; + } + + return Status; +} + diff --git a/Source/C/Common/Decompress.h b/Source/C/Common/Decompress.h index fa7b202..8bcf504 100644 --- a/Source/C/Common/Decompress.h +++ b/Source/C/Common/Decompress.h @@ -159,4 +159,14 @@ EFI_STATUS IN OUT VOID *Scratch, IN UINT32 ScratchSize ); + +EFI_STATUS +Extract ( + IN VOID *Source, + IN UINT32 SrcSize, + IN OUT VOID *Destination, + IN UINT32 DstSize, + IN UINT Algorithm + ); + #endif -- 2.17.1