build_board.py 6.1 KB

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