klu2 | e4c0074 | 2010-03-10 01:23:13 +0000 | [diff] [blame] | 1 | @REM ## @file
|
| 2 | @REM #
|
Ruiyu Ni | 2790926 | 2014-11-25 08:53:33 +0000 | [diff] [blame] | 3 | @REM # Copyright (c) 2010 - 2014, Intel Corporation. All rights reserved.<BR>
|
klu2 | e4c0074 | 2010-03-10 01:23:13 +0000 | [diff] [blame] | 4 | @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 ##
|
klu2 | 6d3f772 | 2008-05-07 05:11:29 +0000 | [diff] [blame] | 14 |
|
niruiyu | 7708d08 | 2011-07-01 04:48:45 +0000 | [diff] [blame] | 15 | @REM Set up environment at first.
|
klu2 | 6d3f772 | 2008-05-07 05:11:29 +0000 | [diff] [blame] | 16 |
|
klu2 | 2a5ef1f | 2009-01-06 04:38:58 +0000 | [diff] [blame] | 17 | @set BASETOOLS_DIR=%WORKSPACE_TOOLS_PATH%\Bin\Win32
|
klu2 | e88f305 | 2009-06-22 03:01:53 +0000 | [diff] [blame] | 18 | @set BOOTSECTOR_BIN_DIR=%WORKSPACE%\DuetPkg\BootSector\bin
|
klu2 | 6d3f772 | 2008-05-07 05:11:29 +0000 | [diff] [blame] | 19 | @set DISK_LABEL=DUET
|
eric_tian | e843cdd | 2010-01-19 08:28:28 +0000 | [diff] [blame] | 20 | @set PROCESSOR=""
|
niruiyu | 7708d08 | 2011-07-01 04:48:45 +0000 | [diff] [blame] | 21 | @set STEP=1
|
| 22 | @call %WORKSPACE%\DuetPkg\GetVariables.bat
|
klu2 | 6d3f772 | 2008-05-07 05:11:29 +0000 | [diff] [blame] | 23 |
|
eric_tian | e843cdd | 2010-01-19 08:28:28 +0000 | [diff] [blame] | 24 | @echo on
|
klu2 | 6d3f772 | 2008-05-07 05:11:29 +0000 | [diff] [blame] | 25 |
|
| 26 | @if "%1"=="" goto Help
|
| 27 | @if "%2"=="" goto Help
|
| 28 | @if "%3"=="" goto Help
|
niruiyu | 7708d08 | 2011-07-01 04:48:45 +0000 | [diff] [blame] | 29 | @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
|
klu2 | 6d3f772 | 2008-05-07 05:11:29 +0000 | [diff] [blame] | 33 | @set EFI_BOOT_DISK=%2
|
niruiyu | 7708d08 | 2011-07-01 04:48:45 +0000 | [diff] [blame] | 34 | @if "%TARGET_ARCH%"=="IA32" set PROCESSOR=IA32
|
| 35 | @if "%TARGET_ARCH%"=="X64" set PROCESSOR=X64
|
eric_tian | e843cdd | 2010-01-19 08:28:28 +0000 | [diff] [blame] | 36 | @if %PROCESSOR%=="" goto WrongArch
|
niruiyu | 7708d08 | 2011-07-01 04:48:45 +0000 | [diff] [blame] | 37 | @set BUILD_DIR=%WORKSPACE%\Build\DuetPkg%PROCESSOR%\%TARGET%_%TOOL_CHAIN_TAG%
|
klu2 | ab9cb4b | 2010-03-18 02:36:52 +0000 | [diff] [blame] | 38 |
|
klu2 | 6d3f772 | 2008-05-07 05:11:29 +0000 | [diff] [blame] | 39 | @if "%1"=="floppy" goto CreateFloppy
|
klu2 | e25803f | 2009-01-06 03:25:24 +0000 | [diff] [blame] | 40 | @if "%1"=="file" goto CreateFile
|
klu2 | 6d3f772 | 2008-05-07 05:11:29 +0000 | [diff] [blame] | 41 | @if "%1"=="usb" goto CreateUsb
|
| 42 | @if "%1"=="ide" goto CreateIde
|
eric_tian | e843cdd | 2010-01-19 08:28:28 +0000 | [diff] [blame] | 43 |
|
klu2 | 6d3f772 | 2008-05-07 05:11:29 +0000 | [diff] [blame] | 44 | goto 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 ...
|
Ruiyu Ni | 2790926 | 2014-11-25 08:53:33 +0000 | [diff] [blame] | 55 | @%BASETOOLS_DIR%\Genbootsector.exe -i %EFI_BOOT_DISK% -o FDBs.com
|
Eric Dong | bffaa26 | 2014-07-09 08:28:05 +0000 | [diff] [blame] | 56 | @copy %BOOTSECTOR_BIN_DIR%\Bootsect.com FDBs-1.com
|
Ruiyu Ni | 2790926 | 2014-11-25 08:53:33 +0000 | [diff] [blame] | 57 | @%BASETOOLS_DIR%\Bootsectimage.exe -g FDBs.com FDBs-1.com -f
|
klu2 | 6d3f772 | 2008-05-07 05:11:29 +0000 | [diff] [blame] | 58 | @REM @del FDBS.com
|
Ruiyu Ni | 2790926 | 2014-11-25 08:53:33 +0000 | [diff] [blame] | 59 | @%BASETOOLS_DIR%\Genbootsector.exe -o %EFI_BOOT_DISK% -i FDBs-1.com
|
Eric Dong | bffaa26 | 2014-07-09 08:28:05 +0000 | [diff] [blame] | 60 | @del FDBs-1.com
|
klu2 | 6d3f772 | 2008-05-07 05:11:29 +0000 | [diff] [blame] | 61 | @echo Done.
|
Ruiyu Ni | 2790926 | 2014-11-25 08:53:33 +0000 | [diff] [blame] | 62 | @copy %BUILD_DIR%\FV\EfiLdr %EFI_BOOT_DISK%
|
| 63 | @goto CreateBootFile
|
klu2 | 6d3f772 | 2008-05-07 05:11:29 +0000 | [diff] [blame] | 64 |
|
klu2 | e25803f | 2009-01-06 03:25:24 +0000 | [diff] [blame] | 65 | :CreateFile
|
| 66 | @if NOT "%3"=="FAT12" goto WrongFATType
|
| 67 | @echo Start to create file boot disk ...
|
| 68 | @echo Create boot sector ...
|
| 69 | %BASETOOLS_DIR%\Genbootsector.exe -i %EFI_BOOT_DISK% -o FDBs.com
|
Ruiyu Ni | 2790926 | 2014-11-25 08:53:33 +0000 | [diff] [blame] | 70 | @copy %BOOTSECTOR_BIN_DIR%\Bootsect.com FDBs-1.com
|
| 71 | @%BASETOOLS_DIR%\Bootsectimage.exe -g FDBs.com FDBs-1.com -f
|
klu2 | e25803f | 2009-01-06 03:25:24 +0000 | [diff] [blame] | 72 | @REM @del FDBS.com
|
Ruiyu Ni | 2790926 | 2014-11-25 08:53:33 +0000 | [diff] [blame] | 73 | @%BASETOOLS_DIR%\Genbootsector.exe -o %EFI_BOOT_DISK% -i FDBs-1.com
|
Eric Dong | bffaa26 | 2014-07-09 08:28:05 +0000 | [diff] [blame] | 74 | @del FDBs-1.com
|
klu2 | e25803f | 2009-01-06 03:25:24 +0000 | [diff] [blame] | 75 | @echo Done.
|
| 76 | @goto end
|
| 77 |
|
klu2 | 6d3f772 | 2008-05-07 05:11:29 +0000 | [diff] [blame] | 78 | :CreateUsb
|
| 79 | @echo Start to create usb boot disk ...
|
| 80 | @if "%3"=="FAT16" goto CreateUsb_FAT16
|
| 81 | @if "%3"=="FAT32" goto CreateUsb_FAT32
|
| 82 | @if "%3"=="FAT12" goto WrongFATType
|
| 83 |
|
| 84 | :CreateUsb_FAT16
|
niruiyu | 7708d08 | 2011-07-01 04:48:45 +0000 | [diff] [blame] | 85 | @if "%STEP%"=="2" goto CreateUsb_FAT16_step2
|
klu2 | 6d3f772 | 2008-05-07 05:11:29 +0000 | [diff] [blame] | 86 | @echo Format %EFI_BOOT_DISK% ...
|
| 87 | @echo.> FormatCommandInput.txt
|
| 88 | @format /FS:FAT /v:%DISK_LABEL% /q %EFI_BOOT_DISK% < FormatCommandInput.txt > NUL
|
| 89 | @del FormatCommandInput.txt
|
| 90 | @echo Create boot sector ...
|
| 91 | @%BASETOOLS_DIR%\Genbootsector.exe -i %EFI_BOOT_DISK% -o UsbBs16.com
|
Eric Dong | bffaa26 | 2014-07-09 08:28:05 +0000 | [diff] [blame] | 92 | @copy %BOOTSECTOR_BIN_DIR%\Bs16.com Bs16-1.com
|
| 93 | @%BASETOOLS_DIR%\Bootsectimage.exe -g UsbBs16.com Bs16-1.com -f
|
| 94 | @%BASETOOLS_DIR%\Genbootsector.exe -o %EFI_BOOT_DISK% -i Bs16-1.com
|
| 95 | @del Bs16-1.com
|
klu2 | e88f305 | 2009-06-22 03:01:53 +0000 | [diff] [blame] | 96 | @%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] | 97 | @echo Done.
|
| 98 | @echo PLEASE UNPLUG USB, THEN PLUG IT AGAIN!
|
| 99 | @goto end
|
| 100 |
|
| 101 | :CreateUsb_FAT16_step2
|
klu2 | 6d3f772 | 2008-05-07 05:11:29 +0000 | [diff] [blame] | 102 | @copy %BUILD_DIR%\FV\EfiLdr16 %EFI_BOOT_DISK%
|
Ruiyu Ni | 2790926 | 2014-11-25 08:53:33 +0000 | [diff] [blame] | 103 | @goto CreateBootFile
|
klu2 | 6d3f772 | 2008-05-07 05:11:29 +0000 | [diff] [blame] | 104 |
|
| 105 | :CreateUsb_FAT32
|
niruiyu | 7708d08 | 2011-07-01 04:48:45 +0000 | [diff] [blame] | 106 | @if "%STEP%"=="2" goto CreateUsb_FAT32_step2
|
klu2 | 6d3f772 | 2008-05-07 05:11:29 +0000 | [diff] [blame] | 107 | @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
|
Eric Dong | bffaa26 | 2014-07-09 08:28:05 +0000 | [diff] [blame] | 113 | @copy %BOOTSECTOR_BIN_DIR%\Bs32.com Bs32-1.com
|
| 114 | @%BASETOOLS_DIR%\Bootsectimage.exe -g UsbBs32.com Bs32-1.com -f
|
klu2 | 6d3f772 | 2008-05-07 05:11:29 +0000 | [diff] [blame] | 115 | @del UsbBs32.com
|
Eric Dong | bffaa26 | 2014-07-09 08:28:05 +0000 | [diff] [blame] | 116 | @%BASETOOLS_DIR%\Genbootsector.exe -o %EFI_BOOT_DISK% -i Bs32-1.com
|
| 117 | @del Bs32-1.com
|
klu2 | e88f305 | 2009-06-22 03:01:53 +0000 | [diff] [blame] | 118 | @%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] | 119 | @echo Done.
|
| 120 | @echo PLEASE UNPLUG USB, THEN PLUG IT AGAIN!
|
| 121 | @goto end
|
| 122 |
|
klu2 | b0e441b | 2009-03-01 08:04:03 +0000 | [diff] [blame] | 123 | :CreateUsb_FAT32_step2
|
| 124 | @copy %BUILD_DIR%\FV\EfiLdr20 %EFI_BOOT_DISK%
|
Ruiyu Ni | 2790926 | 2014-11-25 08:53:33 +0000 | [diff] [blame] | 125 | @goto CreateBootFile
|
klu2 | b0e441b | 2009-03-01 08:04:03 +0000 | [diff] [blame] | 126 |
|
klu2 | 6d3f772 | 2008-05-07 05:11:29 +0000 | [diff] [blame] | 127 | :CreateIde
|
| 128 | @goto end
|
| 129 |
|
Ruiyu Ni | 2790926 | 2014-11-25 08:53:33 +0000 | [diff] [blame] | 130 | :CreateBootFile
|
| 131 | @mkdir %EFI_BOOT_DISK%\efi\boot
|
| 132 | copy %WORKSPACE%\ShellBinPkg\UefiShell\%PROCESSOR%\Shell.efi %EFI_BOOT_DISK%\efi\boot\boot%PROCESSOR%.efi /y
|
eric_tian | e843cdd | 2010-01-19 08:28:28 +0000 | [diff] [blame] | 133 | @goto end
|
| 134 |
|
klu2 | 6d3f772 | 2008-05-07 05:11:29 +0000 | [diff] [blame] | 135 | :WrongFATType
|
| 136 | @echo Wrong FAT type %3 for %1
|
| 137 | @goto end
|
| 138 |
|
eric_tian | e843cdd | 2010-01-19 08:28:28 +0000 | [diff] [blame] | 139 | :WrongArch
|
| 140 | @echo Error! Wrong architecture.
|
| 141 | @goto Help
|
| 142 |
|
klu2 | 6d3f772 | 2008-05-07 05:11:29 +0000 | [diff] [blame] | 143 | :Help
|
eric_tian | e843cdd | 2010-01-19 08:28:28 +0000 | [diff] [blame] | 144 | @echo "Usage: CreateBootDisk [usb|floppy|ide] DiskNumber [FAT12|FAT16|FAT32] [IA32|X64]"
|
klu2 | 6d3f772 | 2008-05-07 05:11:29 +0000 | [diff] [blame] | 145 | :end
|
Ruiyu Ni | 2790926 | 2014-11-25 08:53:33 +0000 | [diff] [blame] | 146 | @echo on
|