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