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