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