DecomprScratchEnd.fdf.inc 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. ## @file
  2. # This FDF include file computes the end of the scratch buffer used in
  3. # DecompressMemFvs() [SimicsX58Pkg/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. # Copyright (c) 2006 - 2019 Intel Corporation. All rights reserved. <BR>
  9. #
  10. # SPDX-License-Identifier: BSD-2-Clause-Patent
  11. #
  12. ##
  13. # The GUID EE4E5898-3914-4259-9D6E-DC7BD79403CF means "LzmaCustomDecompress".
  14. # The decompressed output will have the following structure (see the file
  15. # "9E21FD93-9C72-4c15-8C4B-E77F1DB2D792SEC1.guided.dummy" in the
  16. # Build/SimicsX58*/*/FV/Ffs/9E21FD93-9C72-4c15-8C4B-E77F1DB2D792/ directory):
  17. #
  18. # Size Contents
  19. # ------------------- --------------------------------------------------------
  20. # 4 EFI_COMMON_SECTION_HEADER, stating size 124 (0x7C) and
  21. # type 0x19 (EFI_SECTION_RAW). The purpose of this section
  22. # is to pad the start of PEIFV to 128 bytes.
  23. # 120 Zero bytes (padding).
  24. #
  25. # 4 EFI_COMMON_SECTION_HEADER, stating size
  26. # (PcdSimicsPeiMemFvSize + 4), and type 0x17
  27. # (EFI_SECTION_FIRMWARE_VOLUME_IMAGE).
  28. # PcdSimicsPeiMemFvSize PEIFV. Note that the above sizes pad the offset of this
  29. # object to 128 bytes. See also the "guided.dummy.txt"
  30. # file in the same directory.
  31. #
  32. # 4 EFI_COMMON_SECTION_HEADER, stating size 12 (0xC) and
  33. # type 0x19 (EFI_SECTION_RAW). The purpose of this section
  34. # is to pad the start of DXEFV to 16 bytes.
  35. # 8 Zero bytes (padding).
  36. #
  37. # 4 EFI_COMMON_SECTION_HEADER, stating size
  38. # (PcdSimicsDxeMemFvSize + 4), and type 0x17
  39. # (EFI_SECTION_FIRMWARE_VOLUME_IMAGE).
  40. # PcdSimicsDxeMemFvSize DXEFV. Note that the above sizes pad the offset of this
  41. # object to 16 bytes. See also the "guided.dummy.txt" file
  42. # in the same directory.
  43. #
  44. # The total size after decompression is (128 + PcdSimicsPeiMemFvSize + 16 +
  45. # PcdSimicsDxeMemFvSize).
  46. DEFINE OUTPUT_SIZE = (128 + gBoardModuleTokenSpaceGuid.PcdSimicsPeiMemFvSize + 16 + gBoardModuleTokenSpaceGuid.PcdSimicsDxeMemFvSize)
  47. # LzmaCustomDecompressLib uses a constant scratch buffer size of 64KB; see
  48. # SCRATCH_BUFFER_REQUEST_SIZE in
  49. # "MdeModulePkg/Library/LzmaCustomDecompressLib/LzmaDecompress.c".
  50. DEFINE DECOMP_SCRATCH_SIZE = 0x00010000
  51. # Note: when we use PcdSimicsDxeMemFvBase in this context, BaseTools have not yet
  52. # offset it with MEMFD's base address. For that reason we have to do it manually.
  53. #
  54. # The calculation below mirrors DecompressMemFvs() [SimicsX58Pkg/Sec/SecMain.c].
  55. DEFINE OUTPUT_BASE = ($(MEMFD_BASE_ADDRESS) + gBoardModuleTokenSpaceGuid.PcdSimicsDxeMemFvBase + 0x00100000)
  56. DEFINE DECOMP_SCRATCH_BASE_UNALIGNED = ($(OUTPUT_BASE) + $(OUTPUT_SIZE))
  57. DEFINE DECOMP_SCRATCH_BASE_ALIGNMENT = 0x000FFFFF
  58. DEFINE DECOMP_SCRATCH_BASE_MASK = 0xFFF00000
  59. DEFINE DECOMP_SCRATCH_BASE = (($(DECOMP_SCRATCH_BASE_UNALIGNED) + $(DECOMP_SCRATCH_BASE_ALIGNMENT)) & $(DECOMP_SCRATCH_BASE_MASK))
  60. SET gBoardModuleTokenSpaceGuid.PcdSimicsDecompressionScratchEnd = $(DECOMP_SCRATCH_BASE) + $(DECOMP_SCRATCH_SIZE)