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