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