blob: 4c5f2ce87f1dbc71cfb24fdffaec751e2c76e40d [file] [log] [blame]
klu2e4c00742010-03-10 01:23:13 +00001@REM ## @file
2@REM #
klu2c4ae2792010-03-10 02:36:05 +00003@REM # Copyright (c) 2010 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
15@REM Set up environment at fisrt.
16
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=""
klu26d3f7722008-05-07 05:11:29 +000021
eric_tiane843cdd2010-01-19 08:28:28 +000022@echo on
klu26d3f7722008-05-07 05:11:29 +000023
24@if "%1"=="" goto Help
25@if "%2"=="" goto Help
26@if "%3"=="" goto Help
eric_tiane843cdd2010-01-19 08:28:28 +000027@if "%4"=="" goto NoArch
klu26d3f7722008-05-07 05:11:29 +000028@set EFI_BOOT_DISK=%2
eric_tiane843cdd2010-01-19 08:28:28 +000029@if "%4"=="IA32" set PROCESSOR=IA32
30@if "%4"=="X64" set PROCESSOR=X64
31@if %PROCESSOR%=="" goto WrongArch
klu2ab9cb4b2010-03-18 02:36:52 +000032@set BUILD_DIR=%WORKSPACE%\Build\DuetPkg%PROCESSOR%\DEBUG_MYTOOLS
33
klu26d3f7722008-05-07 05:11:29 +000034@if "%1"=="floppy" goto CreateFloppy
klu2e25803f2009-01-06 03:25:24 +000035@if "%1"=="file" goto CreateFile
klu26d3f7722008-05-07 05:11:29 +000036@if "%1"=="usb" goto CreateUsb
37@if "%1"=="ide" goto CreateIde
eric_tiane843cdd2010-01-19 08:28:28 +000038
klu26d3f7722008-05-07 05:11:29 +000039goto Help
40
41:CreateFloppy
42@if NOT "%3"=="FAT12" goto WrongFATType
43@echo Start to create floppy boot disk ...
44@echo Format %EFI_BOOT_DISK% ...
45@echo.> FormatCommandInput.txt
46@echo.n>> FormatCommandInput.txt
47@format /v:%DISK_LABEL% /q %EFI_BOOT_DISK% < FormatCommandInput.txt > NUL
48@del FormatCommandInput.txt
49@echo Create boot sector ...
50%BASETOOLS_DIR%\Genbootsector.exe -i %EFI_BOOT_DISK% -o FDBs.com
klu2e88f3052009-06-22 03:01:53 +000051%BASETOOLS_DIR%\Bootsectimage.exe -g FDBs.com %BOOTSECTOR_BIN_DIR%\Bootsect.com -f
klu26d3f7722008-05-07 05:11:29 +000052@REM @del FDBS.com
klu2e88f3052009-06-22 03:01:53 +000053%BASETOOLS_DIR%\Genbootsector.exe -o %EFI_BOOT_DISK% -i %BOOTSECTOR_BIN_DIR%\Bootsect.com
klu26d3f7722008-05-07 05:11:29 +000054@echo Done.
55copy %BUILD_DIR%\FV\EfiLdr %EFI_BOOT_DISK%
56mkdir %EFI_BOOT_DISK%\efi\boot
eric_tiane843cdd2010-01-19 08:28:28 +000057@if "%PROCESSOR%"=="IA32" goto CreateBootFileForIA32
58@if "%PROCESSOR%"=="X64" goto CreateBootFileForX64
klu26d3f7722008-05-07 05:11:29 +000059@goto end
60
klu2e25803f2009-01-06 03:25:24 +000061:CreateFile
62@if NOT "%3"=="FAT12" goto WrongFATType
63@echo Start to create file boot disk ...
64@echo Create boot sector ...
65%BASETOOLS_DIR%\Genbootsector.exe -i %EFI_BOOT_DISK% -o FDBs.com
klu2e88f3052009-06-22 03:01:53 +000066%BASETOOLS_DIR%\Bootsectimage.exe -g FDBs.com %BOOTSECTOR_BIN_DIR%\Bootsect.com -f
klu2e25803f2009-01-06 03:25:24 +000067@REM @del FDBS.com
klu2e88f3052009-06-22 03:01:53 +000068%BASETOOLS_DIR%\Genbootsector.exe -o %EFI_BOOT_DISK% -i %BOOTSECTOR_BIN_DIR%\Bootsect.com
klu2e25803f2009-01-06 03:25:24 +000069@echo Done.
70@goto end
71
klu26d3f7722008-05-07 05:11:29 +000072:CreateUsb
73@echo Start to create usb boot disk ...
74@if "%3"=="FAT16" goto CreateUsb_FAT16
75@if "%3"=="FAT32" goto CreateUsb_FAT32
76@if "%3"=="FAT12" goto WrongFATType
77
78:CreateUsb_FAT16
eric_tiane843cdd2010-01-19 08:28:28 +000079@if "%5"=="step2" goto CreateUsb_FAT16_step2
klu26d3f7722008-05-07 05:11:29 +000080@echo Format %EFI_BOOT_DISK% ...
81@echo.> FormatCommandInput.txt
82@format /FS:FAT /v:%DISK_LABEL% /q %EFI_BOOT_DISK% < FormatCommandInput.txt > NUL
83@del FormatCommandInput.txt
84@echo Create boot sector ...
85@%BASETOOLS_DIR%\Genbootsector.exe -i %EFI_BOOT_DISK% -o UsbBs16.com
klu2e88f3052009-06-22 03:01:53 +000086@%BASETOOLS_DIR%\Bootsectimage.exe -g UsbBs16.com %BOOTSECTOR_BIN_DIR%\Bs16.com -f
87@%BASETOOLS_DIR%\Genbootsector.exe -o %EFI_BOOT_DISK% -i %BOOTSECTOR_BIN_DIR%\Bs16.com
88@%BASETOOLS_DIR%\Genbootsector.exe -m -o %EFI_BOOT_DISK% -i %BOOTSECTOR_BIN_DIR%\Mbr.com
klu2e25803f2009-01-06 03:25:24 +000089@echo Done.
90@echo PLEASE UNPLUG USB, THEN PLUG IT AGAIN!
91@goto end
92
93:CreateUsb_FAT16_step2
klu26d3f7722008-05-07 05:11:29 +000094@copy %BUILD_DIR%\FV\EfiLdr16 %EFI_BOOT_DISK%
95@mkdir %EFI_BOOT_DISK%\efi\boot
eric_tiane843cdd2010-01-19 08:28:28 +000096@if "%PROCESSOR%"=="IA32" goto CreateBootFileForIA32
97@if "%PROCESSOR%"=="X64" goto CreateBootFileForX64
klu26d3f7722008-05-07 05:11:29 +000098@goto end
99
100:CreateUsb_FAT32
eric_tiane843cdd2010-01-19 08:28:28 +0000101@if "%5"=="step2" goto CreateUsb_FAT32_step2
klu26d3f7722008-05-07 05:11:29 +0000102@echo Format %EFI_BOOT_DISK% ...
103@echo.> FormatCommandInput.txt
104@format /FS:FAT32 /v:%DISK_LABEL% /q %EFI_BOOT_DISK% < FormatCommandInput.txt > NUL
105@del FormatCommandInput.txt
106@echo Create boot sector ...
107@%BASETOOLS_DIR%\Genbootsector.exe -i %EFI_BOOT_DISK% -o UsbBs32.com
klu2e88f3052009-06-22 03:01:53 +0000108@%BASETOOLS_DIR%\Bootsectimage.exe -g UsbBs32.com %BOOTSECTOR_BIN_DIR%\Bs32.com -f
klu26d3f7722008-05-07 05:11:29 +0000109@del UsbBs32.com
klu2e88f3052009-06-22 03:01:53 +0000110@%BASETOOLS_DIR%\Genbootsector.exe -o %EFI_BOOT_DISK% -i %BOOTSECTOR_BIN_DIR%\Bs32.com
111@%BASETOOLS_DIR%\Genbootsector.exe -m -o %EFI_BOOT_DISK% -i %BOOTSECTOR_BIN_DIR%\Mbr.com
klu26d3f7722008-05-07 05:11:29 +0000112@echo Done.
113@echo PLEASE UNPLUG USB, THEN PLUG IT AGAIN!
114@goto end
115
klu2b0e441b2009-03-01 08:04:03 +0000116:CreateUsb_FAT32_step2
117@copy %BUILD_DIR%\FV\EfiLdr20 %EFI_BOOT_DISK%
118@mkdir %EFI_BOOT_DISK%\efi\boot
eric_tiane843cdd2010-01-19 08:28:28 +0000119@if "%PROCESSOR%"=="IA32" goto CreateBootFileForIA32
120@if "%PROCESSOR%"=="X64" goto CreateBootFileForX64
klu2b0e441b2009-03-01 08:04:03 +0000121@goto end
122
klu26d3f7722008-05-07 05:11:29 +0000123:CreateIde
124@goto end
125
eric_tiane843cdd2010-01-19 08:28:28 +0000126:CreateBootFileForIA32
127copy %WORKSPACE%\EdkShellBinPkg\MinimumShell\IA32\Shell.efi %EFI_BOOT_DISK%\efi\boot\bootia32.efi /y
128@goto end
129
130:CreateBootFileForX64
131copy %WORKSPACE%\EdkShellBinPkg\MinimumShell\X64\Shell.efi %EFI_BOOT_DISK%\efi\boot\bootx64.efi /y
132@goto end
133
klu26d3f7722008-05-07 05:11:29 +0000134:WrongFATType
135@echo Wrong FAT type %3 for %1
136@goto end
137
eric_tiane843cdd2010-01-19 08:28:28 +0000138:NoArch
139@echo Error! Please specific the architecture.
140@goto Help
141
142:WrongArch
143@echo Error! Wrong architecture.
144@goto Help
145
klu26d3f7722008-05-07 05:11:29 +0000146:Help
eric_tiane843cdd2010-01-19 08:28:28 +0000147@echo "Usage: CreateBootDisk [usb|floppy|ide] DiskNumber [FAT12|FAT16|FAT32] [IA32|X64]"
klu26d3f7722008-05-07 05:11:29 +0000148:end
149@echo on