]>
Commit | Line | Data |
---|---|---|
3cbfba02 DW |
1 | @REM @file\r |
2 | @REM Windows batch file to build BIOS ROM\r | |
3 | @REM\r | |
4 | @REM Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>\r | |
5 | @REM \r | |
9dc8036d | 6 | @REM SPDX-License-Identifier: BSD-2-Clause-Patent\r |
3cbfba02 DW |
7 | @REM\r |
8 | \r | |
9 | @echo off\r | |
10 | SetLocal EnableDelayedExpansion EnableExtensions\r | |
11 | \r | |
12 | :: Set script defaults\r | |
13 | set exitCode=0\r | |
14 | set BackupRom=1\r | |
15 | set UpdateVBios=1\r | |
83586b5d | 16 | set SpiLock=0\r |
3cbfba02 DW |
17 | set Stitch_Config=Stitch_Config.txt\r |
18 | copy /y nul Stitching.log >nul\r | |
19 | \r | |
20 | :: Set default Suffix as: YYYY_MM_DD_HHMM\r | |
21 | set hour=%time: =0%\r | |
22 | reg copy "HKCU\Control Panel\International" "HKCU\Control Panel\International_Temp" /f >nul\r | |
23 | reg add "HKCU\Control Panel\International" /v sShortDate /d "yyyy_MM_dd" /f >nul\r | |
24 | for /f "tokens=1" %%i in ("%date%") do set today=%%i\r | |
25 | reg copy "HKCU\Control Panel\International_Temp" "HKCU\Control Panel\International" /f >nul\r | |
26 | reg delete "HKCU\Control Panel\International_Temp" /f >nul\r | |
27 | set IFWI_Suffix=%today%_%hour:~0,2%%time:~3,2%\r | |
28 | \r | |
29 | :: Process input arguments\r | |
30 | if "%~1"=="?" goto Usage\r | |
31 | if "%~1"=="/?" goto Usage\r | |
32 | if /i "%~1"=="Help" goto Usage\r | |
33 | \r | |
34 | :OptLoop\r | |
35 | if /i "%~1"=="/nV" (\r | |
36 | set UpdateVBios=0\r | |
37 | shift\r | |
38 | goto OptLoop\r | |
39 | )\r | |
40 | if /i "%~1"=="/nB" (\r | |
41 | set BackupRom=0\r | |
42 | shift\r | |
43 | goto OptLoop\r | |
44 | )\r | |
83586b5d TH |
45 | if /i "%~1"=="/yL" (\r |
46 | set SpiLock=1\r | |
47 | shift\r | |
48 | goto OptLoop\r | |
49 | )\r | |
50 | \r | |
3cbfba02 DW |
51 | if /i "%~1"=="/B" (\r |
52 | if "%~2"=="" goto Usage\r | |
53 | if not exist %~2 echo BIOS not found. & goto Usage\r | |
54 | set BIOS_Names=%~2\r | |
55 | set BIOS_File_Name=%~n2\r | |
56 | shift & shift\r | |
57 | goto OptLoop\r | |
58 | )\r | |
59 | if /i "%~1"=="/C" (\r | |
60 | if "%~2"=="" goto Usage\r | |
61 | if not exist %~2 echo ConfigFile not found. & goto Usage\r | |
62 | set Stitch_Config=%~2\r | |
63 | shift & shift\r | |
64 | goto OptLoop\r | |
65 | )\r | |
66 | if /i "%~1"=="/S" (\r | |
67 | if "%~2"=="" goto Usage\r | |
68 | set IFWI_Suffix=%~2\r | |
69 | shift & shift\r | |
70 | goto OptLoop\r | |
71 | )\r | |
72 | \r | |
73 | if "%BIOS_File_Name:~0,4%"=="MNW2" (\r | |
74 | set Stitch_Config= MNW2_Stitch_Config.txt\r | |
75 | )\r | |
76 | if "%BIOS_File_Name:~3,4%"=="MNW2" (\r | |
77 | set Stitch_Config= MNW2_Stitch_Config.txt\r | |
78 | )\r | |
79 | \r | |
80 | :: if no rom specified by user, search in ./ for ROM files\r | |
81 | if "%BIOS_Names%"=="" (\r | |
82 | set "BIOS_Names= "\r | |
83 | for /f "tokens=*" %%i in ('dir /b *.rom') do set BIOS_Names=!BIOS_Names! %%i\r | |
84 | if "!BIOS_Names!"==" " (\r | |
85 | echo NO .ROM files found !!!\r | |
86 | goto Usage\r | |
87 | )\r | |
88 | )\r | |
89 | \r | |
90 | :: Parse the Stitch_Config File\r | |
91 | if not exist %Stitch_Config% (\r | |
92 | echo Stitch Configuration File %Stitch_Config% not found.\r | |
93 | goto ScriptFail\r | |
94 | )\r | |
95 | for /f "delims== tokens=1,2" %%i in (%Stitch_Config%) do (\r | |
96 | if /i "%%i"=="HEADER" set IFWI_HEADER=%%j\r | |
97 | if /i "%%i"=="SEC_VERSION" set SEC_VERSION=%%j\r | |
98 | if /i "%%i"=="Source" (\r | |
99 | if /i "%%j"=="ALPHA" set Source_Prefix=A_\r | |
100 | if /i "%%j"=="BF" set Source_Prefix=BF_\r | |
101 | if /i "%%j"=="BE" set Source_Prefix=BE_\r | |
102 | if /i "%%j"=="PV" set Source_Prefix=PV_\r | |
103 | if /i "%%j"=="PR1" set Source_Prefix=PR1_\r | |
104 | )\r | |
105 | )\r | |
106 | \r | |
83586b5d TH |
107 | if %SpiLock% EQU 1 (\r |
108 | set IFWI_HEADER_FILE=IFWIHeader\!IFWI_HEADER!_SPILOCK.bin\r | |
109 | ) else (\r | |
110 | set IFWI_HEADER_FILE=IFWIHeader\!IFWI_HEADER!.bin\r | |
111 | )\r | |
3cbfba02 DW |
112 | \r |
113 | :: **********************************************************************\r | |
114 | :: The Main Stitching Loop\r | |
115 | :: **********************************************************************\r | |
116 | echo %date% %time% >>Stitching.log 2>&1\r | |
117 | echo %date% %time%\r | |
118 | echo.\r | |
119 | for %%i in (%BIOS_Names%) do (\r | |
120 | \r | |
121 | REM ----- Do NOT use :: for comments Inside of code blocks() -------\r | |
122 | set BIOS_Rom=%%i\r | |
123 | set BIOS_Name=%%~ni\r | |
124 | set BIOS_Version=!BIOS_Name:~-7,7!\r | |
125 | \r | |
126 | REM extract PlatformType from BIOS filename\r | |
127 | set Platform_Type=!BIOS_Name:~0,4!\r | |
128 | \r | |
129 | REM Special treat for BayLake FFD8\r | |
130 | set Temp_Name=!BIOS_Name:~0,7!\r | |
131 | \r | |
132 | \r | |
133 | REM Capitalize and validate the Platform_Type\r | |
134 | if /i "!Platform_Type!"=="MNW2" (\r | |
135 | set Platform_Type=MNW2\r | |
136 | ) else (\r | |
137 | echo Error - Unsupported PlatformType: !Platform_Type!\r | |
138 | goto Usage\r | |
139 | )\r | |
140 | \r | |
141 | \r | |
142 | REM search BIOS_Name for Arch substring: either IA32 or X64\r | |
143 | if not "!BIOS_Name!"=="!BIOS_Name:_IA32_=!" (\r | |
144 | set Arch=IA32\r | |
145 | ) else if not "!BIOS_Name!"=="!BIOS_Name:_X64_=!" (\r | |
146 | set Arch=X64\r | |
147 | ) else (\r | |
148 | echo Error: Could not determine Architecture for !BIOS_Rom!\r | |
149 | goto Usage\r | |
150 | )\r | |
151 | set IFWI_Prefix=!Platform_Type!_IFWI_%Source_Prefix%!Arch!_!!BIOS_Version!\r | |
152 | \r | |
153 | REM search BIOS_Name for Build_Target substring: either R or D\r | |
154 | if not "!BIOS_Name!"=="!BIOS_Name:_R_=!" (\r | |
155 | set Build_Target=Release\r | |
156 | set IFWI_Prefix=!IFWI_Prefix!_R\r | |
157 | ) else if not "!BIOS_Name!"=="!BIOS_Name:_D_=!" (\r | |
158 | set Build_Target=Debug\r | |
159 | set IFWI_Prefix=!IFWI_Prefix!_D\r | |
160 | ) else (\r | |
161 | echo Error: Could not determine Build Target for !BIOS_Rom!\r | |
162 | goto Usage\r | |
163 | )\r | |
164 | \r | |
165 | REM Create a BIOS backup before Stitching\r | |
166 | if %BackupRom% EQU 1 (\r | |
167 | echo Creating backup of original BIOS rom.\r | |
168 | copy /y !BIOS_Rom! !BIOS_Rom!.orig >nul\r | |
169 | )\r | |
170 | \r | |
171 | echo. >>Stitching.log\r | |
172 | echo ********** Stitching !BIOS_Rom! ********** >>Stitching.log\r | |
173 | echo. >>Stitching.log\r | |
174 | echo.\r | |
175 | echo Stitching IFWI for !BIOS_Rom! ...\r | |
176 | echo ---------------------------------------------------------------------------\r | |
83586b5d | 177 | echo IFWI Header: !IFWI_HEADER_FILE!, SEC version: !SEC_VERSION!, \r |
3cbfba02 DW |
178 | echo BIOS Version: !BIOS_Version!\r |
179 | \r | |
180 | echo Platform Type: !Platform_Type!, IFWI Prefix: %BIOS_ID%\r | |
181 | echo ---------------------------------------------------------------------------\r | |
182 | \r | |
183 | echo -----------------------------\r | |
184 | echo.\r | |
185 | echo Generating IFWI... %BIOS_ID%.bin\r | |
186 | echo.\r | |
46002a4a | 187 | \r |
2cb2b6d6 | 188 | copy /b/y !IFWI_HEADER_FILE! + ..\..\..\silicon\Vlv2SocBinPkg\SEC\!SEC_VERSION!\VLV_SEC_REGION.bin + ..\..\..\silicon\Vlv2SocBinPkg\SEC\!SEC_VERSION!\Vacant.bin + !BIOS_Rom! %BIOS_ID%.bin\r |
3cbfba02 DW |
189 | echo.\r |
190 | echo ===========================================================================\r | |
191 | )\r | |
192 | @echo off\r | |
193 | \r | |
194 | ::**********************************************************************\r | |
195 | :: end of main loop\r | |
196 | ::**********************************************************************\r | |
197 | \r | |
198 | echo.\r | |
199 | echo -- All specified ROM files Stitched. --\r | |
200 | echo.\r | |
201 | goto Exit\r | |
202 | \r | |
203 | :Usage\r | |
204 | echo.\r | |
205 | echo **************************************************************************************************\r | |
206 | echo This Script is used to Stitch together BIOS, GOP Driver, Microcode Patch and TXE FW\r | |
207 | echo into a single Integrated Firmware Image (IFWI).\r | |
208 | echo.\r | |
209 | echo Usage: IFWIStitch.bat [flags] [/B BIOS.ROM] [/C Stitch_Config] [/S IFWI_Suffix]\r | |
210 | echo.\r | |
211 | echo This script has NO Required arguments, so that the user can just double click from the GUI.\r | |
212 | echo However, this requires that the BIOS.ROM file name is formatted correctly.\r | |
213 | echo.\r | |
214 | echo /nG Do NOT update the GOP driver. (applies to all ROM files for this run)\r | |
215 | echo /nV Do NOT update the VBIOS. (applies to all ROM files for this run)\r | |
216 | echo /nM Do NOT update the Microcode. (applies to all ROM files for this run)\r | |
217 | echo /nB Do NOT backup BIOS.ROMs. (Default will backup to BIOS.ROM.Orig)\r | |
218 | echo.\r | |
219 | echo BIOS.ROM: A single BIOS ROM file to use for stitching\r | |
220 | echo (DEFAULT: ALL .ROM files inside the current directory)\r | |
221 | echo Stitch_Config: Text file containing version info of each FW component\r | |
222 | echo (DEFAULT: Stitch_Config.txt)\r | |
223 | echo IFWI_Suffix: Suffix to append to the end of the IFWI filename\r | |
224 | echo (DEFAULT: YYYY_MM_DD_HHMM)\r | |
225 | echo.\r | |
226 | echo Examples:\r | |
227 | echo IFIWStitch.bat : Stitch all ROMs with defaults\r | |
228 | echo IFIWStitch.bat /B C:/MyRoms/testBIOS.rom : Stitch single ROM with defaults\r | |
229 | echo IFIWStitch.bat /B ../testBIOS.rom /S test123 : Stitch single ROM and add custom suffix\r | |
230 | echo IFIWStitch.bat /nM /nB /B testBIOS.rom /S test456 : Stitch single ROM, keep uCode from .rom,\r | |
231 | echo don't create backup, and add custom suffix.\r | |
232 | echo ****************************************************************************************************\r | |
233 | pause\r | |
234 | exit /b 1\r | |
235 | \r | |
236 | :ScriptFail\r | |
237 | set exitCode=1\r | |
238 | \r | |
239 | :Exit\r | |
240 | echo -- See Stitching.log for more info. --\r | |
241 | echo.\r | |
242 | echo %date% %time%\r | |
243 | echo.\r | |
244 | if "%Platform_Type%"=="MNW2" (\r | |
245 | echo .\r | |
246 | ) else (\r | |
247 | echo only support MNW2 for this project!\r | |
248 | pause\r | |
249 | )\r | |
250 | exit /b %exitCode%\r | |
251 | EndLocal\r |