blob: e4e1369cd448c08585ddb623c5c411355fe25471 [file] [log] [blame]
klu26d3f7722008-05-07 05:11:29 +00001@REM
2
3@REM Set up environment at fisrt.
4
klu22a5ef1f2009-01-06 04:38:58 +00005@set BASETOOLS_DIR=%WORKSPACE_TOOLS_PATH%\Bin\Win32
klu26d3f7722008-05-07 05:11:29 +00006@set BUILD_DIR=%WORKSPACE%\Build\DuetPkg\DEBUG_MYTOOLS
klu2e88f3052009-06-22 03:01:53 +00007@set BOOTSECTOR_BIN_DIR=%WORKSPACE%\DuetPkg\BootSector\bin
klu26d3f7722008-05-07 05:11:29 +00008@set DISK_LABEL=DUET
eric_tiane843cdd2010-01-19 08:28:28 +00009@set PROCESSOR=""
klu26d3f7722008-05-07 05:11:29 +000010
eric_tiane843cdd2010-01-19 08:28:28 +000011@echo on
klu26d3f7722008-05-07 05:11:29 +000012
13@if "%1"=="" goto Help
14@if "%2"=="" goto Help
15@if "%3"=="" goto Help
eric_tiane843cdd2010-01-19 08:28:28 +000016@if "%4"=="" goto NoArch
klu26d3f7722008-05-07 05:11:29 +000017@set EFI_BOOT_DISK=%2
eric_tiane843cdd2010-01-19 08:28:28 +000018@if "%4"=="IA32" set PROCESSOR=IA32
19@if "%4"=="X64" set PROCESSOR=X64
20@if %PROCESSOR%=="" goto WrongArch
klu26d3f7722008-05-07 05:11:29 +000021@if "%1"=="floppy" goto CreateFloppy
klu2e25803f2009-01-06 03:25:24 +000022@if "%1"=="file" goto CreateFile
klu26d3f7722008-05-07 05:11:29 +000023@if "%1"=="usb" goto CreateUsb
24@if "%1"=="ide" goto CreateIde
eric_tiane843cdd2010-01-19 08:28:28 +000025
klu26d3f7722008-05-07 05:11:29 +000026goto Help
27
28:CreateFloppy
29@if NOT "%3"=="FAT12" goto WrongFATType
30@echo Start to create floppy boot disk ...
31@echo Format %EFI_BOOT_DISK% ...
32@echo.> FormatCommandInput.txt
33@echo.n>> FormatCommandInput.txt
34@format /v:%DISK_LABEL% /q %EFI_BOOT_DISK% < FormatCommandInput.txt > NUL
35@del FormatCommandInput.txt
36@echo Create boot sector ...
37%BASETOOLS_DIR%\Genbootsector.exe -i %EFI_BOOT_DISK% -o FDBs.com
klu2e88f3052009-06-22 03:01:53 +000038%BASETOOLS_DIR%\Bootsectimage.exe -g FDBs.com %BOOTSECTOR_BIN_DIR%\Bootsect.com -f
klu26d3f7722008-05-07 05:11:29 +000039@REM @del FDBS.com
klu2e88f3052009-06-22 03:01:53 +000040%BASETOOLS_DIR%\Genbootsector.exe -o %EFI_BOOT_DISK% -i %BOOTSECTOR_BIN_DIR%\Bootsect.com
klu26d3f7722008-05-07 05:11:29 +000041@echo Done.
42copy %BUILD_DIR%\FV\EfiLdr %EFI_BOOT_DISK%
43mkdir %EFI_BOOT_DISK%\efi\boot
eric_tiane843cdd2010-01-19 08:28:28 +000044@if "%PROCESSOR%"=="IA32" goto CreateBootFileForIA32
45@if "%PROCESSOR%"=="X64" goto CreateBootFileForX64
klu26d3f7722008-05-07 05:11:29 +000046@goto end
47
klu2e25803f2009-01-06 03:25:24 +000048:CreateFile
49@if NOT "%3"=="FAT12" goto WrongFATType
50@echo Start to create file boot disk ...
51@echo Create boot sector ...
52%BASETOOLS_DIR%\Genbootsector.exe -i %EFI_BOOT_DISK% -o FDBs.com
klu2e88f3052009-06-22 03:01:53 +000053%BASETOOLS_DIR%\Bootsectimage.exe -g FDBs.com %BOOTSECTOR_BIN_DIR%\Bootsect.com -f
klu2e25803f2009-01-06 03:25:24 +000054@REM @del FDBS.com
klu2e88f3052009-06-22 03:01:53 +000055%BASETOOLS_DIR%\Genbootsector.exe -o %EFI_BOOT_DISK% -i %BOOTSECTOR_BIN_DIR%\Bootsect.com
klu2e25803f2009-01-06 03:25:24 +000056@echo Done.
57@goto end
58
klu26d3f7722008-05-07 05:11:29 +000059:CreateUsb
60@echo Start to create usb boot disk ...
61@if "%3"=="FAT16" goto CreateUsb_FAT16
62@if "%3"=="FAT32" goto CreateUsb_FAT32
63@if "%3"=="FAT12" goto WrongFATType
64
65:CreateUsb_FAT16
eric_tiane843cdd2010-01-19 08:28:28 +000066@if "%5"=="step2" goto CreateUsb_FAT16_step2
klu26d3f7722008-05-07 05:11:29 +000067@echo Format %EFI_BOOT_DISK% ...
68@echo.> FormatCommandInput.txt
69@format /FS:FAT /v:%DISK_LABEL% /q %EFI_BOOT_DISK% < FormatCommandInput.txt > NUL
70@del FormatCommandInput.txt
71@echo Create boot sector ...
72@%BASETOOLS_DIR%\Genbootsector.exe -i %EFI_BOOT_DISK% -o UsbBs16.com
klu2e88f3052009-06-22 03:01:53 +000073@%BASETOOLS_DIR%\Bootsectimage.exe -g UsbBs16.com %BOOTSECTOR_BIN_DIR%\Bs16.com -f
74@%BASETOOLS_DIR%\Genbootsector.exe -o %EFI_BOOT_DISK% -i %BOOTSECTOR_BIN_DIR%\Bs16.com
75@%BASETOOLS_DIR%\Genbootsector.exe -m -o %EFI_BOOT_DISK% -i %BOOTSECTOR_BIN_DIR%\Mbr.com
klu2e25803f2009-01-06 03:25:24 +000076@echo Done.
77@echo PLEASE UNPLUG USB, THEN PLUG IT AGAIN!
78@goto end
79
80:CreateUsb_FAT16_step2
klu26d3f7722008-05-07 05:11:29 +000081@copy %BUILD_DIR%\FV\EfiLdr16 %EFI_BOOT_DISK%
82@mkdir %EFI_BOOT_DISK%\efi\boot
eric_tiane843cdd2010-01-19 08:28:28 +000083@if "%PROCESSOR%"=="IA32" goto CreateBootFileForIA32
84@if "%PROCESSOR%"=="X64" goto CreateBootFileForX64
klu26d3f7722008-05-07 05:11:29 +000085@goto end
86
87:CreateUsb_FAT32
eric_tiane843cdd2010-01-19 08:28:28 +000088@if "%5"=="step2" goto CreateUsb_FAT32_step2
klu26d3f7722008-05-07 05:11:29 +000089@echo Format %EFI_BOOT_DISK% ...
90@echo.> FormatCommandInput.txt
91@format /FS:FAT32 /v:%DISK_LABEL% /q %EFI_BOOT_DISK% < FormatCommandInput.txt > NUL
92@del FormatCommandInput.txt
93@echo Create boot sector ...
94@%BASETOOLS_DIR%\Genbootsector.exe -i %EFI_BOOT_DISK% -o UsbBs32.com
klu2e88f3052009-06-22 03:01:53 +000095@%BASETOOLS_DIR%\Bootsectimage.exe -g UsbBs32.com %BOOTSECTOR_BIN_DIR%\Bs32.com -f
klu26d3f7722008-05-07 05:11:29 +000096@del UsbBs32.com
klu2e88f3052009-06-22 03:01:53 +000097@%BASETOOLS_DIR%\Genbootsector.exe -o %EFI_BOOT_DISK% -i %BOOTSECTOR_BIN_DIR%\Bs32.com
98@%BASETOOLS_DIR%\Genbootsector.exe -m -o %EFI_BOOT_DISK% -i %BOOTSECTOR_BIN_DIR%\Mbr.com
klu26d3f7722008-05-07 05:11:29 +000099@echo Done.
100@echo PLEASE UNPLUG USB, THEN PLUG IT AGAIN!
101@goto end
102
klu2b0e441b2009-03-01 08:04:03 +0000103:CreateUsb_FAT32_step2
104@copy %BUILD_DIR%\FV\EfiLdr20 %EFI_BOOT_DISK%
105@mkdir %EFI_BOOT_DISK%\efi\boot
eric_tiane843cdd2010-01-19 08:28:28 +0000106@if "%PROCESSOR%"=="IA32" goto CreateBootFileForIA32
107@if "%PROCESSOR%"=="X64" goto CreateBootFileForX64
klu2b0e441b2009-03-01 08:04:03 +0000108@goto end
109
klu26d3f7722008-05-07 05:11:29 +0000110:CreateIde
111@goto end
112
eric_tiane843cdd2010-01-19 08:28:28 +0000113:CreateBootFileForIA32
114copy %WORKSPACE%\EdkShellBinPkg\MinimumShell\IA32\Shell.efi %EFI_BOOT_DISK%\efi\boot\bootia32.efi /y
115@goto end
116
117:CreateBootFileForX64
118copy %WORKSPACE%\EdkShellBinPkg\MinimumShell\X64\Shell.efi %EFI_BOOT_DISK%\efi\boot\bootx64.efi /y
119@goto end
120
klu26d3f7722008-05-07 05:11:29 +0000121:WrongFATType
122@echo Wrong FAT type %3 for %1
123@goto end
124
eric_tiane843cdd2010-01-19 08:28:28 +0000125:NoArch
126@echo Error! Please specific the architecture.
127@goto Help
128
129:WrongArch
130@echo Error! Wrong architecture.
131@goto Help
132
klu26d3f7722008-05-07 05:11:29 +0000133:Help
eric_tiane843cdd2010-01-19 08:28:28 +0000134@echo "Usage: CreateBootDisk [usb|floppy|ide] DiskNumber [FAT12|FAT16|FAT32] [IA32|X64]"
klu26d3f7722008-05-07 05:11:29 +0000135:end
136@echo on