klu2 | 6d3f772 | 2008-05-07 05:11:29 +0000 | [diff] [blame] | 1 | @REM
|
| 2 |
|
| 3 | @REM Set up environment at fisrt.
|
| 4 |
|
klu2 | 2a5ef1f | 2009-01-06 04:38:58 +0000 | [diff] [blame] | 5 | @set BASETOOLS_DIR=%WORKSPACE_TOOLS_PATH%\Bin\Win32
|
klu2 | 6d3f772 | 2008-05-07 05:11:29 +0000 | [diff] [blame] | 6 | @set BUILD_DIR=%WORKSPACE%\Build\DuetPkg\DEBUG_MYTOOLS
|
klu2 | e88f305 | 2009-06-22 03:01:53 +0000 | [diff] [blame] | 7 | @set BOOTSECTOR_BIN_DIR=%WORKSPACE%\DuetPkg\BootSector\bin
|
klu2 | 6d3f772 | 2008-05-07 05:11:29 +0000 | [diff] [blame] | 8 | @set DISK_LABEL=DUET
|
eric_tian | e843cdd | 2010-01-19 08:28:28 +0000 | [diff] [blame] | 9 | @set PROCESSOR=""
|
klu2 | 6d3f772 | 2008-05-07 05:11:29 +0000 | [diff] [blame] | 10 |
|
eric_tian | e843cdd | 2010-01-19 08:28:28 +0000 | [diff] [blame] | 11 | @echo on
|
klu2 | 6d3f772 | 2008-05-07 05:11:29 +0000 | [diff] [blame] | 12 |
|
| 13 | @if "%1"=="" goto Help
|
| 14 | @if "%2"=="" goto Help
|
| 15 | @if "%3"=="" goto Help
|
eric_tian | e843cdd | 2010-01-19 08:28:28 +0000 | [diff] [blame] | 16 | @if "%4"=="" goto NoArch
|
klu2 | 6d3f772 | 2008-05-07 05:11:29 +0000 | [diff] [blame] | 17 | @set EFI_BOOT_DISK=%2
|
eric_tian | e843cdd | 2010-01-19 08:28:28 +0000 | [diff] [blame] | 18 | @if "%4"=="IA32" set PROCESSOR=IA32
|
| 19 | @if "%4"=="X64" set PROCESSOR=X64
|
| 20 | @if %PROCESSOR%=="" goto WrongArch
|
klu2 | 6d3f772 | 2008-05-07 05:11:29 +0000 | [diff] [blame] | 21 | @if "%1"=="floppy" goto CreateFloppy
|
klu2 | e25803f | 2009-01-06 03:25:24 +0000 | [diff] [blame] | 22 | @if "%1"=="file" goto CreateFile
|
klu2 | 6d3f772 | 2008-05-07 05:11:29 +0000 | [diff] [blame] | 23 | @if "%1"=="usb" goto CreateUsb
|
| 24 | @if "%1"=="ide" goto CreateIde
|
eric_tian | e843cdd | 2010-01-19 08:28:28 +0000 | [diff] [blame] | 25 |
|
klu2 | 6d3f772 | 2008-05-07 05:11:29 +0000 | [diff] [blame] | 26 | goto 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
|
klu2 | e88f305 | 2009-06-22 03:01:53 +0000 | [diff] [blame] | 38 | %BASETOOLS_DIR%\Bootsectimage.exe -g FDBs.com %BOOTSECTOR_BIN_DIR%\Bootsect.com -f
|
klu2 | 6d3f772 | 2008-05-07 05:11:29 +0000 | [diff] [blame] | 39 | @REM @del FDBS.com
|
klu2 | e88f305 | 2009-06-22 03:01:53 +0000 | [diff] [blame] | 40 | %BASETOOLS_DIR%\Genbootsector.exe -o %EFI_BOOT_DISK% -i %BOOTSECTOR_BIN_DIR%\Bootsect.com
|
klu2 | 6d3f772 | 2008-05-07 05:11:29 +0000 | [diff] [blame] | 41 | @echo Done.
|
| 42 | copy %BUILD_DIR%\FV\EfiLdr %EFI_BOOT_DISK%
|
| 43 | mkdir %EFI_BOOT_DISK%\efi\boot
|
eric_tian | e843cdd | 2010-01-19 08:28:28 +0000 | [diff] [blame] | 44 | @if "%PROCESSOR%"=="IA32" goto CreateBootFileForIA32
|
| 45 | @if "%PROCESSOR%"=="X64" goto CreateBootFileForX64
|
klu2 | 6d3f772 | 2008-05-07 05:11:29 +0000 | [diff] [blame] | 46 | @goto end
|
| 47 |
|
klu2 | e25803f | 2009-01-06 03:25:24 +0000 | [diff] [blame] | 48 | :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
|
klu2 | e88f305 | 2009-06-22 03:01:53 +0000 | [diff] [blame] | 53 | %BASETOOLS_DIR%\Bootsectimage.exe -g FDBs.com %BOOTSECTOR_BIN_DIR%\Bootsect.com -f
|
klu2 | e25803f | 2009-01-06 03:25:24 +0000 | [diff] [blame] | 54 | @REM @del FDBS.com
|
klu2 | e88f305 | 2009-06-22 03:01:53 +0000 | [diff] [blame] | 55 | %BASETOOLS_DIR%\Genbootsector.exe -o %EFI_BOOT_DISK% -i %BOOTSECTOR_BIN_DIR%\Bootsect.com
|
klu2 | e25803f | 2009-01-06 03:25:24 +0000 | [diff] [blame] | 56 | @echo Done.
|
| 57 | @goto end
|
| 58 |
|
klu2 | 6d3f772 | 2008-05-07 05:11:29 +0000 | [diff] [blame] | 59 | :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_tian | e843cdd | 2010-01-19 08:28:28 +0000 | [diff] [blame] | 66 | @if "%5"=="step2" goto CreateUsb_FAT16_step2
|
klu2 | 6d3f772 | 2008-05-07 05:11:29 +0000 | [diff] [blame] | 67 | @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
|
klu2 | e88f305 | 2009-06-22 03:01:53 +0000 | [diff] [blame] | 73 | @%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
|
klu2 | e25803f | 2009-01-06 03:25:24 +0000 | [diff] [blame] | 76 | @echo Done.
|
| 77 | @echo PLEASE UNPLUG USB, THEN PLUG IT AGAIN!
|
| 78 | @goto end
|
| 79 |
|
| 80 | :CreateUsb_FAT16_step2
|
klu2 | 6d3f772 | 2008-05-07 05:11:29 +0000 | [diff] [blame] | 81 | @copy %BUILD_DIR%\FV\EfiLdr16 %EFI_BOOT_DISK%
|
| 82 | @mkdir %EFI_BOOT_DISK%\efi\boot
|
eric_tian | e843cdd | 2010-01-19 08:28:28 +0000 | [diff] [blame] | 83 | @if "%PROCESSOR%"=="IA32" goto CreateBootFileForIA32
|
| 84 | @if "%PROCESSOR%"=="X64" goto CreateBootFileForX64
|
klu2 | 6d3f772 | 2008-05-07 05:11:29 +0000 | [diff] [blame] | 85 | @goto end
|
| 86 |
|
| 87 | :CreateUsb_FAT32
|
eric_tian | e843cdd | 2010-01-19 08:28:28 +0000 | [diff] [blame] | 88 | @if "%5"=="step2" goto CreateUsb_FAT32_step2
|
klu2 | 6d3f772 | 2008-05-07 05:11:29 +0000 | [diff] [blame] | 89 | @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
|
klu2 | e88f305 | 2009-06-22 03:01:53 +0000 | [diff] [blame] | 95 | @%BASETOOLS_DIR%\Bootsectimage.exe -g UsbBs32.com %BOOTSECTOR_BIN_DIR%\Bs32.com -f
|
klu2 | 6d3f772 | 2008-05-07 05:11:29 +0000 | [diff] [blame] | 96 | @del UsbBs32.com
|
klu2 | e88f305 | 2009-06-22 03:01:53 +0000 | [diff] [blame] | 97 | @%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
|
klu2 | 6d3f772 | 2008-05-07 05:11:29 +0000 | [diff] [blame] | 99 | @echo Done.
|
| 100 | @echo PLEASE UNPLUG USB, THEN PLUG IT AGAIN!
|
| 101 | @goto end
|
| 102 |
|
klu2 | b0e441b | 2009-03-01 08:04:03 +0000 | [diff] [blame] | 103 | :CreateUsb_FAT32_step2
|
| 104 | @copy %BUILD_DIR%\FV\EfiLdr20 %EFI_BOOT_DISK%
|
| 105 | @mkdir %EFI_BOOT_DISK%\efi\boot
|
eric_tian | e843cdd | 2010-01-19 08:28:28 +0000 | [diff] [blame] | 106 | @if "%PROCESSOR%"=="IA32" goto CreateBootFileForIA32
|
| 107 | @if "%PROCESSOR%"=="X64" goto CreateBootFileForX64
|
klu2 | b0e441b | 2009-03-01 08:04:03 +0000 | [diff] [blame] | 108 | @goto end
|
| 109 |
|
klu2 | 6d3f772 | 2008-05-07 05:11:29 +0000 | [diff] [blame] | 110 | :CreateIde
|
| 111 | @goto end
|
| 112 |
|
eric_tian | e843cdd | 2010-01-19 08:28:28 +0000 | [diff] [blame] | 113 | :CreateBootFileForIA32
|
| 114 | copy %WORKSPACE%\EdkShellBinPkg\MinimumShell\IA32\Shell.efi %EFI_BOOT_DISK%\efi\boot\bootia32.efi /y
|
| 115 | @goto end
|
| 116 |
|
| 117 | :CreateBootFileForX64
|
| 118 | copy %WORKSPACE%\EdkShellBinPkg\MinimumShell\X64\Shell.efi %EFI_BOOT_DISK%\efi\boot\bootx64.efi /y
|
| 119 | @goto end
|
| 120 |
|
klu2 | 6d3f772 | 2008-05-07 05:11:29 +0000 | [diff] [blame] | 121 | :WrongFATType
|
| 122 | @echo Wrong FAT type %3 for %1
|
| 123 | @goto end
|
| 124 |
|
eric_tian | e843cdd | 2010-01-19 08:28:28 +0000 | [diff] [blame] | 125 | :NoArch
|
| 126 | @echo Error! Please specific the architecture.
|
| 127 | @goto Help
|
| 128 |
|
| 129 | :WrongArch
|
| 130 | @echo Error! Wrong architecture.
|
| 131 | @goto Help
|
| 132 |
|
klu2 | 6d3f772 | 2008-05-07 05:11:29 +0000 | [diff] [blame] | 133 | :Help
|
eric_tian | e843cdd | 2010-01-19 08:28:28 +0000 | [diff] [blame] | 134 | @echo "Usage: CreateBootDisk [usb|floppy|ide] DiskNumber [FAT12|FAT16|FAT32] [IA32|X64]"
|
klu2 | 6d3f772 | 2008-05-07 05:11:29 +0000 | [diff] [blame] | 135 | :end
|
| 136 | @echo on |