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