build_board.py 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. # @ build_board.py
  2. # This adds additional functions to the build_bios.py
  3. #
  4. # Copyright (c) 2018, Intel Corporation. All rights reserved.<BR>
  5. # Copyright (c) 2021, American Megatrends International LLC.<BR>
  6. # SPDX-License-Identifier: BSD-2-Clause-Patent
  7. #
  8. """
  9. This module serves as an additional build steps for the Tioga Pass board
  10. """
  11. import os
  12. import sys
  13. def pre_build_ex(config, functions):
  14. """Additional Pre BIOS build function
  15. :param config: The environment variables to be used in the build process
  16. :type config: Dictionary
  17. :param functions: A dictionary of function pointers
  18. :type functions: Dictionary
  19. :returns: nothing
  20. """
  21. print("Info: re-generating PlatformOffset header files")
  22. execute_script = functions.get("execute_script")
  23. command = ["build", "-D", "MAX_SOCKET=" + config.get("MAX_SOCKET", "1"),
  24. "-m",
  25. os.path.join(config["PLATFORM_BOARD_PACKAGE"],
  26. "Acpi", "BoardAcpiDxe", "Dsdt.inf"),
  27. "-y",
  28. config.get("PRE_BUILD_REPORT",
  29. os.path.join(config["WORKSPACE"],
  30. "preBuildReport.txt")),
  31. "--log=" + config.get("PRE_BUILD_LOG",
  32. os.path.join(config["WORKSPACE"],
  33. "prebuild.log"))]
  34. _, _, _, code = execute_script(command, config)
  35. if code != 0:
  36. print(" ".join(command))
  37. print("Error re-generating PlatformOffset header files")
  38. sys.exit(1)
  39. config["AML_FILTER"] = "\"PSYS\" .MCTL\" .FIX[0-9,A-Z]\""
  40. print("AML_FILTER= ", config.get("AML_FILTER"))
  41. # build the command with arguments
  42. command = ["python",
  43. os.path.join(config["MIN_PACKAGE_TOOLS"],
  44. "AmlGenOffset",
  45. "AmlGenOffset.py"),
  46. "-d", "--aml_filter", config["AML_FILTER"],
  47. "-o", os.path.join(config["WORKSPACE_PLATFORM"],
  48. config["PLATFORM_BOARD_PACKAGE"],
  49. "Acpi", "BoardAcpiDxe",
  50. "AmlOffsetTable.c"),
  51. os.path.join(config["BUILD_X64"],
  52. "PurleyOpenBoardPkg",
  53. "Acpi",
  54. "BoardAcpiDxe",
  55. "DSDT",
  56. "OUTPUT",
  57. "Dsdt", "WFPPlatform.offset.h")]
  58. # execute the command
  59. _, _, _, code = execute_script(command, config)
  60. if code != 0:
  61. print(" ".join(command))
  62. print("Error re-generating PlatformOffset header files")
  63. sys.exit(1)
  64. print("GenOffset done")
  65. return config
  66. def build_ex(config, functions):
  67. """Additional BIOS build function
  68. :param config: The environment variables to be used in
  69. the build process
  70. :type config: Dictionary
  71. :param functions: A dictionary of function pointers
  72. :type functions: Dictionary
  73. :returns: config dictionary
  74. :rtype: Dictionary
  75. """
  76. print("build_ex")
  77. return None
  78. def post_build_ex(config, functions):
  79. """Additional Post BIOS build function
  80. :param config: The environment variables to be used in the post
  81. build process
  82. :type config: Dictionary
  83. :param functions: A dictionary of function pointers
  84. :type functions: Dictionary
  85. :returns: config dictionary
  86. :rtype: Dictionary
  87. """
  88. print("post_build_ex")
  89. execute_script = functions.get("execute_script")
  90. if not execute_script:
  91. print("post_build_ex Error")
  92. sys.exit(1)
  93. common_patch_command = [os.path.join(config["PYTHON_HOME"], "python"),
  94. os.path.join(config["MIN_PACKAGE_TOOLS"],
  95. "PatchFv", "PatchBinFv.py"),
  96. config["TARGET"],
  97. os.path.join(config["WORKSPACE_SILICON_BIN"],
  98. "PurleySiliconBinPkg", "FV"),
  99. os.path.join(config["WORKSPACE"],
  100. "BuildReport.log")]
  101. fvs_to_patch = ["FvTempMemorySilicon",
  102. "FvPreMemorySilicon",
  103. "FvPostMemorySilicon",
  104. "FvLateSilicon"]
  105. for fv in fvs_to_patch:
  106. patch_command = common_patch_command + [fv]
  107. _, _, _, code = execute_script(patch_command, config)
  108. if code != 0:
  109. print(" ".join(patch_command))
  110. print("Patch Error!")
  111. sys.exit(1)
  112. common_rebase_command = [os.path.join(config["PYTHON_HOME"], "python"),
  113. os.path.join(config["MIN_PACKAGE_TOOLS"],
  114. "PatchFv", "RebaseBinFv.py"),
  115. config["TARGET"],
  116. os.path.join(config["WORKSPACE_SILICON_BIN"],
  117. "PurleySiliconBinPkg", "FV"),
  118. os.path.join(config["WORKSPACE"],
  119. "BuildReport.log")]
  120. rebase_command = common_rebase_command +\
  121. ["FvPreMemorySilicon",
  122. "gMinPlatformPkgTokenSpaceGuid.PcdFlashFvFspMBase"]
  123. _, _, _, code = execute_script(rebase_command, config)
  124. if code != 0:
  125. print(" ".join(rebase_command))
  126. print("Patch Error!")
  127. sys.exit(1)
  128. rebase_command = common_rebase_command +\
  129. ["FvPostMemorySilicon",
  130. "gMinPlatformPkgTokenSpaceGuid.PcdFlashFvFspSBase"]
  131. _, _, _, code = execute_script(rebase_command, config)
  132. if code != 0:
  133. print(" ".join(rebase_command))
  134. print("Patch Error!")
  135. sys.exit(1)
  136. common_patchbfv_command = [os.path.join(config["PYTHON_HOME"], "python"),
  137. os.path.join(config["MIN_PACKAGE_TOOLS"],
  138. "PatchFv", "PatchBfv.py"),
  139. os.path.join(config["BUILD_DIR_PATH"],
  140. "FV", "PLATFORM.fd"),
  141. os.path.join(config["WORKSPACE"],
  142. "BuildReport.log")]
  143. patchbfv_command = common_patchbfv_command +\
  144. ["gMinPlatformPkgTokenSpaceGuid.PcdFlashFvPreMemoryBase"]
  145. _, _, _, code = execute_script(patchbfv_command, config)
  146. if code != 0:
  147. print(" ".join(patchbfv_command))
  148. print("Patch Error!")
  149. sys.exit(1)
  150. return None
  151. def clean_ex(config, functions):
  152. """Additional clean function
  153. :param config: The environment variables to be used in the build process
  154. :type config: Dictionary
  155. :param functions: A dictionary of function pointers
  156. :type functions: Dictionary
  157. :returns: config dictionary
  158. :rtype: Dictionary
  159. """
  160. print("clean_ex")
  161. return None