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