blob: 9a421d7ea7538edcbabc73aa4d725c129a3baa27 [file] [log] [blame]
klu2e4c00742010-03-10 01:23:13 +00001@REM ## @file
2@REM #
niruiyu7708d082011-07-01 04:48:45 +00003@REM # Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
klu2e4c00742010-03-10 01:23:13 +00004@REM #
5@REM # This program and the accompanying materials
6@REM # are licensed and made available under the terms and conditions of the BSD License
7@REM # which accompanies this distribution. The full text of the license may be found at
8@REM # http://opensource.org/licenses/bsd-license.php
9@REM # THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10@REM # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
11@REM #
12@REM #
13@REM ##
klu26d3f7722008-05-07 05:11:29 +000014
niruiyu7708d082011-07-01 04:48:45 +000015@REM Set up environment at first.
klu26d3f7722008-05-07 05:11:29 +000016
klu22a5ef1f2009-01-06 04:38:58 +000017@set BASETOOLS_DIR=%WORKSPACE_TOOLS_PATH%\Bin\Win32
klu2e88f3052009-06-22 03:01:53 +000018@set BOOTSECTOR_BIN_DIR=%WORKSPACE%\DuetPkg\BootSector\bin
klu26d3f7722008-05-07 05:11:29 +000019@set DISK_LABEL=DUET
eric_tiane843cdd2010-01-19 08:28:28 +000020@set PROCESSOR=""
niruiyu7708d082011-07-01 04:48:45 +000021@set STEP=1
22@call %WORKSPACE%\DuetPkg\GetVariables.bat
klu26d3f7722008-05-07 05:11:29 +000023
eric_tiane843cdd2010-01-19 08:28:28 +000024@echo on
klu26d3f7722008-05-07 05:11:29 +000025
26@if "%1"=="" goto Help
27@if "%2"=="" goto Help
28@if "%3"=="" goto Help
niruiyu7708d082011-07-01 04:48:45 +000029@if "%4"=="" goto Set_BootDisk
30@if "%4"=="step2" (@set STEP=2) else @set TARGET_ARCH=%4
31@if "%5"=="step2" @set STEP=2
32:Set_BootDisk
klu26d3f7722008-05-07 05:11:29 +000033@set EFI_BOOT_DISK=%2
niruiyu7708d082011-07-01 04:48:45 +000034@if "%TARGET_ARCH%"=="IA32" set PROCESSOR=IA32
35@if "%TARGET_ARCH%"=="X64" set PROCESSOR=X64
eric_tiane843cdd2010-01-19 08:28:28 +000036@if %PROCESSOR%=="" goto WrongArch
niruiyu7708d082011-07-01 04:48:45 +000037@set BUILD_DIR=%WORKSPACE%\Build\DuetPkg%PROCESSOR%\%TARGET%_%TOOL_CHAIN_TAG%
klu2ab9cb4b2010-03-18 02:36:52 +000038
klu26d3f7722008-05-07 05:11:29 +000039@if "%1"=="floppy" goto CreateFloppy
klu2e25803f2009-01-06 03:25:24 +000040@if "%1"=="file" goto CreateFile
klu26d3f7722008-05-07 05:11:29 +000041@if "%1"=="usb" goto CreateUsb
42@if "%1"=="ide" goto CreateIde
eric_tiane843cdd2010-01-19 08:28:28 +000043
klu26d3f7722008-05-07 05:11:29 +000044goto Help
45
46:CreateFloppy
47@if NOT "%3"=="FAT12" goto WrongFATType
48@echo Start to create floppy boot disk ...
49@echo Format %EFI_BOOT_DISK% ...
50@echo.> FormatCommandInput.txt
51@echo.n>> FormatCommandInput.txt
52@format /v:%DISK_LABEL% /q %EFI_BOOT_DISK% < FormatCommandInput.txt > NUL
53@del FormatCommandInput.txt
54@echo Create boot sector ...
55%BASETOOLS_DIR%\Genbootsector.exe -i %EFI_BOOT_DISK% -o FDBs.com
klu2e88f3052009-06-22 03:01:53 +000056%BASETOOLS_DIR%\Bootsectimage.exe -g FDBs.com %BOOTSECTOR_BIN_DIR%\Bootsect.com -f
klu26d3f7722008-05-07 05:11:29 +000057@REM @del FDBS.com
klu2e88f3052009-06-22 03:01:53 +000058%BASETOOLS_DIR%\Genbootsector.exe -o %EFI_BOOT_DISK% -i %BOOTSECTOR_BIN_DIR%\Bootsect.com
klu26d3f7722008-05-07 05:11:29 +000059@echo Done.
60copy %BUILD_DIR%\FV\EfiLdr %EFI_BOOT_DISK%
61mkdir %EFI_BOOT_DISK%\efi\boot
eric_tiane843cdd2010-01-19 08:28:28 +000062@if "%PROCESSOR%"=="IA32" goto CreateBootFileForIA32
63@if "%PROCESSOR%"=="X64" goto CreateBootFileForX64
klu26d3f7722008-05-07 05:11:29 +000064@goto end
65
klu2e25803f2009-01-06 03:25:24 +000066:CreateFile
67@if NOT "%3"=="FAT12" goto WrongFATType
68@echo Start to create file boot disk ...
69@echo Create boot sector ...
70%BASETOOLS_DIR%\Genbootsector.exe -i %EFI_BOOT_DISK% -o FDBs.com
klu2e88f3052009-06-22 03:01:53 +000071%BASETOOLS_DIR%\Bootsectimage.exe -g FDBs.com %BOOTSECTOR_BIN_DIR%\Bootsect.com -f
klu2e25803f2009-01-06 03:25:24 +000072@REM @del FDBS.com
klu2e88f3052009-06-22 03:01:53 +000073%BASETOOLS_DIR%\Genbootsector.exe -o %EFI_BOOT_DISK% -i %BOOTSECTOR_BIN_DIR%\Bootsect.com
klu2e25803f2009-01-06 03:25:24 +000074@echo Done.
75@goto end
76
klu26d3f7722008-05-07 05:11:29 +000077:CreateUsb
78@echo Start to create usb boot disk ...
79@if "%3"=="FAT16" goto CreateUsb_FAT16
80@if "%3"=="FAT32" goto CreateUsb_FAT32
81@if "%3"=="FAT12" goto WrongFATType
82
83:CreateUsb_FAT16
niruiyu7708d082011-07-01 04:48:45 +000084@if "%STEP%"=="2" goto CreateUsb_FAT16_step2
klu26d3f7722008-05-07 05:11:29 +000085@echo Format %EFI_BOOT_DISK% ...
86@echo.> FormatCommandInput.txt
87@format /FS:FAT /v:%DISK_LABEL% /q %EFI_BOOT_DISK% < FormatCommandInput.txt > NUL
88@del FormatCommandInput.txt
89@echo Create boot sector ...
90@%BASETOOLS_DIR%\Genbootsector.exe -i %EFI_BOOT_DISK% -o UsbBs16.com
klu2e88f3052009-06-22 03:01:53 +000091@%BASETOOLS_DIR%\Bootsectimage.exe -g UsbBs16.com %BOOTSECTOR_BIN_DIR%\Bs16.com -f
92@%BASETOOLS_DIR%\Genbootsector.exe -o %EFI_BOOT_DISK% -i %BOOTSECTOR_BIN_DIR%\Bs16.com
93@%BASETOOLS_DIR%\Genbootsector.exe -m -o %EFI_BOOT_DISK% -i %BOOTSECTOR_BIN_DIR%\Mbr.com
klu2e25803f2009-01-06 03:25:24 +000094@echo Done.
95@echo PLEASE UNPLUG USB, THEN PLUG IT AGAIN!
96@goto end
97
98:CreateUsb_FAT16_step2
klu26d3f7722008-05-07 05:11:29 +000099@copy %BUILD_DIR%\FV\EfiLdr16 %EFI_BOOT_DISK%
100@mkdir %EFI_BOOT_DISK%\efi\boot
eric_tiane843cdd2010-01-19 08:28:28 +0000101@if "%PROCESSOR%"=="IA32" goto CreateBootFileForIA32
102@if "%PROCESSOR%"=="X64" goto CreateBootFileForX64
klu26d3f7722008-05-07 05:11:29 +0000103@goto end
104
105:CreateUsb_FAT32
niruiyu7708d082011-07-01 04:48:45 +0000106@if "%STEP%"=="2" goto CreateUsb_FAT32_step2
klu26d3f7722008-05-07 05:11:29 +0000107@echo Format %EFI_BOOT_DISK% ...
108@echo.> FormatCommandInput.txt
109@format /FS:FAT32 /v:%DISK_LABEL% /q %EFI_BOOT_DISK% < FormatCommandInput.txt > NUL
110@del FormatCommandInput.txt
111@echo Create boot sector ...
112@%BASETOOLS_DIR%\Genbootsector.exe -i %EFI_BOOT_DISK% -o UsbBs32.com
klu2e88f3052009-06-22 03:01:53 +0000113@%BASETOOLS_DIR%\Bootsectimage.exe -g UsbBs32.com %BOOTSECTOR_BIN_DIR%\Bs32.com -f
klu26d3f7722008-05-07 05:11:29 +0000114@del UsbBs32.com
klu2e88f3052009-06-22 03:01:53 +0000115@%BASETOOLS_DIR%\Genbootsector.exe -o %EFI_BOOT_DISK% -i %BOOTSECTOR_BIN_DIR%\Bs32.com
116@%BASETOOLS_DIR%\Genbootsector.exe -m -o %EFI_BOOT_DISK% -i %BOOTSECTOR_BIN_DIR%\Mbr.com
klu26d3f7722008-05-07 05:11:29 +0000117@echo Done.
118@echo PLEASE UNPLUG USB, THEN PLUG IT AGAIN!
119@goto end
120
klu2b0e441b2009-03-01 08:04:03 +0000121:CreateUsb_FAT32_step2
122@copy %BUILD_DIR%\FV\EfiLdr20 %EFI_BOOT_DISK%
123@mkdir %EFI_BOOT_DISK%\efi\boot
eric_tiane843cdd2010-01-19 08:28:28 +0000124@if "%PROCESSOR%"=="IA32" goto CreateBootFileForIA32
125@if "%PROCESSOR%"=="X64" goto CreateBootFileForX64
klu2b0e441b2009-03-01 08:04:03 +0000126@goto end
127
klu26d3f7722008-05-07 05:11:29 +0000128:CreateIde
129@goto end
130
eric_tiane843cdd2010-01-19 08:28:28 +0000131:CreateBootFileForIA32
132copy %WORKSPACE%\EdkShellBinPkg\MinimumShell\IA32\Shell.efi %EFI_BOOT_DISK%\efi\boot\bootia32.efi /y
133@goto end
134
135:CreateBootFileForX64
136copy %WORKSPACE%\EdkShellBinPkg\MinimumShell\X64\Shell.efi %EFI_BOOT_DISK%\efi\boot\bootx64.efi /y
137@goto end
138
klu26d3f7722008-05-07 05:11:29 +0000139:WrongFATType
140@echo Wrong FAT type %3 for %1
141@goto end
142
eric_tiane843cdd2010-01-19 08:28:28 +0000143:WrongArch
144@echo Error! Wrong architecture.
145@goto Help
146
klu26d3f7722008-05-07 05:11:29 +0000147:Help
eric_tiane843cdd2010-01-19 08:28:28 +0000148@echo "Usage: CreateBootDisk [usb|floppy|ide] DiskNumber [FAT12|FAT16|FAT32] [IA32|X64]"
klu26d3f7722008-05-07 05:11:29 +0000149:end
150@echo on