DecomprScratchEnd.fdf.inc 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. ## @file
  2. # This FDF include file computes the end of the scratch buffer used in
  3. # DecompressMemFvs() [OvmfPkg/Sec/SecMain.c]. It is based on the decompressed
  4. # (ie. original) size of the LZMA-compressed section of the one FFS file in
  5. # the FVMAIN_COMPACT firmware volume.
  6. #
  7. # Copyright (C) 2015, Red Hat, Inc.
  8. #
  9. # This program and the accompanying materials are licensed and made available
  10. # under the terms and conditions of the BSD License which accompanies this
  11. # distribution. The full text of the license may be found at
  12. # http://opensource.org/licenses/bsd-license.php
  13. #
  14. # THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
  15. # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR
  16. # IMPLIED.
  17. ##
  18. # The GUID EE4E5898-3914-4259-9D6E-DC7BD79403CF means "LzmaCustomDecompress".
  19. # The decompressed output will have the following structure (see the file
  20. # "9E21FD93-9C72-4c15-8C4B-E77F1DB2D792SEC1.guided.dummy" in the
  21. # Build/Ovmf*/*/FV/Ffs/9E21FD93-9C72-4c15-8C4B-E77F1DB2D792/ directory):
  22. #
  23. # Size Contents
  24. # ------------------- --------------------------------------------------------
  25. # 4 EFI_COMMON_SECTION_HEADER, stating size 124 (0x7C) and
  26. # type 0x19 (EFI_SECTION_RAW). The purpose of this section
  27. # is to pad the start of PEIFV to 128 bytes.
  28. # 120 Zero bytes (padding).
  29. #
  30. # 4 EFI_COMMON_SECTION_HEADER, stating size
  31. # (PcdOvmfPeiMemFvSize + 4), and type 0x17
  32. # (EFI_SECTION_FIRMWARE_VOLUME_IMAGE).
  33. # PcdOvmfPeiMemFvSize PEIFV. Note that the above sizes pad the offset of this
  34. # object to 128 bytes. See also the "guided.dummy.txt"
  35. # file in the same directory.
  36. #
  37. # 4 EFI_COMMON_SECTION_HEADER, stating size 12 (0xC) and
  38. # type 0x19 (EFI_SECTION_RAW). The purpose of this section
  39. # is to pad the start of DXEFV to 16 bytes.
  40. # 8 Zero bytes (padding).
  41. #
  42. # 4 EFI_COMMON_SECTION_HEADER, stating size
  43. # (PcdOvmfDxeMemFvSize + 4), and type 0x17
  44. # (EFI_SECTION_FIRMWARE_VOLUME_IMAGE).
  45. # PcdOvmfDxeMemFvSize DXEFV. Note that the above sizes pad the offset of this
  46. # object to 16 bytes. See also the "guided.dummy.txt" file
  47. # in the same directory.
  48. #
  49. # The total size after decompression is (128 + PcdOvmfPeiMemFvSize + 16 +
  50. # PcdOvmfDxeMemFvSize).
  51. DEFINE OUTPUT_SIZE = (128 + gUefiOvmfPkgTokenSpaceGuid.PcdOvmfPeiMemFvSize + 16 + gUefiOvmfPkgTokenSpaceGuid.PcdOvmfDxeMemFvSize)
  52. # LzmaCustomDecompressLib uses a constant scratch buffer size of 64KB; see
  53. # SCRATCH_BUFFER_REQUEST_SIZE in
  54. # "MdeModulePkg/Library/LzmaCustomDecompressLib/LzmaDecompress.c".
  55. DEFINE DECOMP_SCRATCH_SIZE = 0x00010000
  56. # Note: when we use PcdOvmfDxeMemFvBase in this context, BaseTools have not yet
  57. # offset it with MEMFD's base address. For that reason we have to do it manually.
  58. #
  59. # The calculation below mirrors DecompressMemFvs() [OvmfPkg/Sec/SecMain.c].
  60. DEFINE OUTPUT_BASE = ($(MEMFD_BASE_ADDRESS) + gUefiOvmfPkgTokenSpaceGuid.PcdOvmfDxeMemFvBase + 0x00100000)
  61. DEFINE DECOMP_SCRATCH_BASE_UNALIGNED = ($(OUTPUT_BASE) + $(OUTPUT_SIZE))
  62. DEFINE DECOMP_SCRATCH_BASE_ALIGNMENT = 0x000FFFFF
  63. DEFINE DECOMP_SCRATCH_BASE_MASK = 0xFFF00000
  64. DEFINE DECOMP_SCRATCH_BASE = (($(DECOMP_SCRATCH_BASE_UNALIGNED) + $(DECOMP_SCRATCH_BASE_ALIGNMENT)) & $(DECOMP_SCRATCH_BASE_MASK))
  65. SET gUefiOvmfPkgTokenSpaceGuid.PcdOvmfDecompressionScratchEnd = $(DECOMP_SCRATCH_BASE) + $(DECOMP_SCRATCH_SIZE)