X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=UefiCpuPkg%2FResetVector%2FVtf0%2FBuild.py;fp=UefiCpuPkg%2FResetVector%2FVtf0%2FBuild.py;h=3f1d5cd2c83ba216c2490a39860b2fb3ab13258b;hb=60d8bb9f28f663e6ca58bc87c042fdd82f5607bd;hp=b791d32762791ca04d4c2f337424fa8b1c30a597;hpb=89f7ed8b29f6a88a8fb78d6fb2c92b4f7edf42d2;p=mirror_edk2.git diff --git a/UefiCpuPkg/ResetVector/Vtf0/Build.py b/UefiCpuPkg/ResetVector/Vtf0/Build.py index b791d32762..3f1d5cd2c8 100644 --- a/UefiCpuPkg/ResetVector/Vtf0/Build.py +++ b/UefiCpuPkg/ResetVector/Vtf0/Build.py @@ -6,45 +6,84 @@ # SPDX-License-Identifier: BSD-2-Clause-Patent # -import glob import os import subprocess import sys +PAGE_TABLE_2M = 'PageTable2M' +PAGE_TABLE_1G = 'PageTable1G' +FILE_FORMAT = '.raw' +ALL_RAW_FORMAT = '*' + FILE_FORMAT +IA32 = 'IA32' +X64 = 'X64' + +# Pre-Define a Macros for Page Table +PAGE_TABLES = { + PAGE_TABLE_2M : "PAGE_TABLE_2M", + PAGE_TABLE_1G : "PAGE_TABLE_1G" +} + def RunCommand(commandLine): - #print ' '.join(commandLine) return subprocess.call(commandLine) -for filename in glob.glob(os.path.join('Bin', '*.raw')): - os.remove(filename) +# Check for all raw binaries and delete them +for root, dirs, files in os.walk('Bin'): + for file in files: + if file.endswith(FILE_FORMAT): + os.remove(os.path.join(root, file)) for arch in ('ia32', 'x64'): for debugType in (None, 'port80', 'serial'): - output = os.path.join('Bin', 'ResetVector') - output += '.' + arch - if debugType is not None: - output += '.' + debugType - output += '.raw' - commandLine = ( - 'nasm', - '-D', 'ARCH_%s' % arch.upper(), - '-D', 'DEBUG_%s' % str(debugType).upper(), - '-o', output, - 'Vtf0.nasmb', - ) - print(f"Command : {' '.join(commandLine)}") - ret = RunCommand(commandLine) - if ret != 0: - print(f"something went wrong while executing {commandLine[-1]}") - sys.exit() - print('\tASM\t' + output) - - commandLine = ( - 'python', - 'Tools/FixupForRawSection.py', - output, - ) - print('\tFIXUP\t' + output) - ret = RunCommand(commandLine) - if ret != 0: sys.exit(ret) + for pageTable in PAGE_TABLES.keys(): + ret = True + if arch.lower() == X64.lower(): + directory = os.path.join('Bin', X64, pageTable) + else: + directory = os.path.join('Bin', IA32) + + # output raw binary name with arch type + fileName = 'ResetVector' + '.' + arch + + if debugType is not None: + fileName += '.' + debugType + fileName += FILE_FORMAT + + output = os.path.join(directory, fileName) + + # if the directory not exists then create it + if not os.path.isdir(directory): + os.makedirs(directory) + + # Prepare the command to execute the nasmb + commandLine = ( + 'nasm', + '-D', 'ARCH_%s' % arch.upper(), + '-D', 'DEBUG_%s' % str(debugType).upper(), + '-D', PAGE_TABLES[pageTable].upper(), + '-o', output, + 'Vtf0.nasmb', + ) + + print(f"Command : {' '.join(commandLine)}") + + try: + ret = RunCommand(commandLine) + except FileNotFoundError: + print("NASM not found") + except: + pass + + if ret != 0: + print(f"something went wrong while executing {commandLine[-1]}") + sys.exit() + print('\tASM\t' + output) + + commandLine = ( + 'python', + 'Tools/FixupForRawSection.py', + output, + ) + print('\tFIXUP\t' + output) + ret = RunCommand(commandLine) + if ret != 0: sys.exit(ret)