]> git.proxmox.com Git - mirror_edk2.git/blob - UefiCpuPkg/ResetVector/Vtf0/Build.py
UefiCpuPkg: Move AsmRelocateApLoopStart from Mpfuncs.nasm to AmdSev.nasm
[mirror_edk2.git] / UefiCpuPkg / ResetVector / Vtf0 / Build.py
1 ## @file
2 # Automate the process of building the various reset vector types
3 #
4 # Copyright (c) 2009 - 2021, Intel Corporation. All rights reserved.<BR>
5 #
6 # SPDX-License-Identifier: BSD-2-Clause-Patent
7 #
8
9 import os
10 import subprocess
11 import sys
12
13 PAGE_TABLE_2M = 'PageTable2M'
14 PAGE_TABLE_1G = 'PageTable1G'
15 FILE_FORMAT = '.raw'
16 ALL_RAW_FORMAT = '*' + FILE_FORMAT
17 IA32 = 'IA32'
18 X64 = 'X64'
19
20 # Pre-Define a Macros for Page Table
21 PAGE_TABLES = {
22 PAGE_TABLE_2M : "PAGE_TABLE_2M",
23 PAGE_TABLE_1G : "PAGE_TABLE_1G"
24 }
25
26 def RunCommand(commandLine):
27 return subprocess.call(commandLine)
28
29 # Check for all raw binaries and delete them
30 for root, dirs, files in os.walk('Bin'):
31 for file in files:
32 if file.endswith(FILE_FORMAT):
33 os.remove(os.path.join(root, file))
34
35 for arch in ('ia32', 'x64'):
36 for debugType in (None, 'port80', 'serial'):
37 for pageTable in PAGE_TABLES.keys():
38 ret = True
39 if arch.lower() == X64.lower():
40 directory = os.path.join('Bin', X64, pageTable)
41 else:
42 directory = os.path.join('Bin', IA32)
43
44 # output raw binary name with arch type
45 fileName = 'ResetVector' + '.' + arch
46
47 if debugType is not None:
48 fileName += '.' + debugType
49 fileName += FILE_FORMAT
50
51 output = os.path.join(directory, fileName)
52
53 # if the directory not exists then create it
54 if not os.path.isdir(directory):
55 os.makedirs(directory)
56
57 # Prepare the command to execute the nasmb
58 commandLine = (
59 'nasm',
60 '-D', 'ARCH_%s' % arch.upper(),
61 '-D', 'DEBUG_%s' % str(debugType).upper(),
62 '-D', PAGE_TABLES[pageTable].upper(),
63 '-o', output,
64 'Vtf0.nasmb',
65 )
66
67 print(f"Command : {' '.join(commandLine)}")
68
69 try:
70 ret = RunCommand(commandLine)
71 except FileNotFoundError:
72 print("NASM not found")
73 except:
74 pass
75
76 if ret != 0:
77 print(f"something went wrong while executing {commandLine[-1]}")
78 sys.exit()
79 print('\tASM\t' + output)
80
81 commandLine = (
82 'python',
83 'Tools/FixupForRawSection.py',
84 output,
85 )
86 print('\tFIXUP\t' + output)
87 ret = RunCommand(commandLine)
88 if ret != 0: sys.exit(ret)
89