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