> On Nov 5, 2014, at 8:08 AM, jim_dai...@dell.com wrote:
> 
> I'm building an EFI utility under Windows. I want to compress some data and 
> append
> it to the utility. Later, when the utility is executed in the EFI shell, I 
> want to
> have the utility decompress the data.
>  
> I tried using BaseTools\Bin\Win32\LzmaCompress.exe to compress the data and 
> found
> that it doesn't place the compressed and uncompressed sizes of the data at the
> beginning of the compressed data.  So, I tried 
> BaseTools\Bin\Win32\TianoCompress.exe.
>  
> That utility does seem to create an output that the EFI_DECOMPRESS_PROTOCOL's
> GetInfo() function likes.  However, that protocol's Decompress() function 
> does not
> like the compressed data's format (returns Invalid Parameter).
>  
> I also tried using the UefiDecompressLib functions to decompress the data, but
> that fails similarly.
>  
> So, is there some Win32 utility that compresses data in the format that the
> EFI_DECOMPRESS_PROTOCOL expects?  If so, what/where is it?
>  

Interesting question. Looks like the tools have code that does the compression.
https://svn.code.sf.net/p/edk2/code/trunk/edk2/BaseTools/Source/C/Common/EfiCompress.c

The stand alone tools are used for GUID’ed compression schemes. These map to an 
EFI_SECTION_GUID_DEFINED in the FV FFS file section, while the 
EFI_SECTION_COMPRESSION is used for the EFI compression type. I think this is 
only reason stand alone tools exist is for the other forms of compression. 

A hack would be to use the GenSec tool.

GenSec -s EFI_SECTION_COMPRESSION -o compressedFileSection RawFile

I think it would generate the compressed data that starts with a 
EFI_COMPRESSION_SECTION structure. So if you just point pass the the 
EFI_COMPRESSION_SECTION the decompress should “just work”?

https://svn.code.sf.net/p/edk2/code/trunk/edk2/MdePkg/Include/Pi/PiFirmwareFile.h
///
/// An encapsulation section type in which the
/// section data is compressed.
///
typedef struct {
  ///
  /// Usual common section header. CommonHeader.Type = EFI_SECTION_COMPRESSION.
  ///
  EFI_COMMON_SECTION_HEADER   CommonHeader;
  ///
  /// The UINT32 that indicates the size of the section data after 
decompression.
  ///
  UINT32                      UncompressedLength;
  ///
  /// Indicates which compression algorithm is used.
  ///
  UINT8                       CompressionType;
} EFI_COMPRESSION_SECTION;

If the file is to big to fit in a EFI_COMPRESSION_SECTION it will end up in a 
EFI_COMPRESSION_SECTION2.

typedef struct {
  ///
  /// Usual common section header. CommonHeader.Type = EFI_SECTION_COMPRESSION.
  ///
  EFI_COMMON_SECTION_HEADER2    CommonHeader;
  ///
  /// UINT32 that indicates the size of the section data after decompression.
  ///
  UINT32                        UncompressedLength;
  ///
  /// Indicates which compression algorithm is used.
  ///
  UINT8                         CompressionType;
} EFI_COMPRESSION_SECTION2;
typedef struct {
  ///
  /// A 24-bit unsigned integer that contains the total size of the section in 
bytes,
  /// including the EFI_COMMON_SECTION_HEADER.
  ///
  UINT8             Size[3];

  EFI_SECTION_TYPE  Type;

  ///
  /// If Size is 0xFFFFFF, then ExtendedSize contains the size of the section. 
If
  /// Size is not equal to 0xFFFFFF, then this field does not exist.
  ///
  UINT32            ExtendedSize;
} EFI_COMMON_SECTION_HEADER2;


Thanks,

Andrew Fish


> Thanks,
> Jim
> ------------------------------------------------------------------------------
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.sourceforge.net <mailto:edk2-devel@lists.sourceforge.net>
> https://lists.sourceforge.net/lists/listinfo/edk2-devel 
> <https://lists.sourceforge.net/lists/listinfo/edk2-devel>
------------------------------------------------------------------------------
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/edk2-devel

Reply via email to