klu2 | ab9cb4b | 2010-03-18 02:36:52 +0000 | [diff] [blame^] | 1 | #! /bin/sh |
| 2 | |
| 3 | ## @file |
| 4 | # |
| 5 | # Copyright (c) 2010 Intel Corporation. All rights reserved.<BR> |
| 6 | # |
| 7 | # This program and the accompanying materials |
| 8 | # are licensed and made available under the terms and conditions of the BSD License |
| 9 | # which accompanies this distribution. The full text of the license may be found at |
| 10 | # http://opensource.org/licenses/bsd-license.php |
| 11 | # THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, |
| 12 | # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. |
| 13 | # |
| 14 | # |
| 15 | ## |
gikidy | 5b7021e | 2009-03-03 06:27:07 +0000 | [diff] [blame] | 16 | |
| 17 | # Set up environment at fisrt. |
klu2 | ab9cb4b | 2010-03-18 02:36:52 +0000 | [diff] [blame^] | 18 | |
klu2 | df6434f | 2009-09-17 02:16:30 +0000 | [diff] [blame] | 19 | export BASETOOLS_DIR=$WORKSPACE/Conf/BaseToolsSource/Source/C/bin |
klu2 | e88f305 | 2009-06-22 03:01:53 +0000 | [diff] [blame] | 20 | export BOOTSECTOR_BIN_DIR=$WORKSPACE/DuetPkg/BootSector/bin |
gikidy | 5b7021e | 2009-03-03 06:27:07 +0000 | [diff] [blame] | 21 | export DISK_LABEL=DUET |
gikidy | 6976b5c | 2009-03-31 06:38:37 +0000 | [diff] [blame] | 22 | export PROCESS_MARK=TRUE |
gikidy | 5b7021e | 2009-03-03 06:27:07 +0000 | [diff] [blame] | 23 | |
| 24 | if [ \ |
| 25 | -z "$*" -o \ |
| 26 | "$*" = "-?" -o \ |
| 27 | "$*" = "-h" -o \ |
| 28 | "$*" = "--help" \ |
| 29 | ] |
| 30 | then |
eric_tian | e843cdd | 2010-01-19 08:28:28 +0000 | [diff] [blame] | 31 | echo "Usage: CreateBootDisk [usb|floppy|ide] MediaPath DevicePath [FAT12|FAT16|FAT32] [IA32|X64]" |
| 32 | echo "e.g. : CreateBootDisk floppy /media/floppy0 /dev/fd0 FAT12 IA32" |
gikidy | 6976b5c | 2009-03-31 06:38:37 +0000 | [diff] [blame] | 33 | PROCESS_MARK=FALSE |
gikidy | 5b7021e | 2009-03-03 06:27:07 +0000 | [diff] [blame] | 34 | fi |
| 35 | |
klu2 | ab9cb4b | 2010-03-18 02:36:52 +0000 | [diff] [blame^] | 36 | case "$5" in |
| 37 | IA32) |
| 38 | export PROCESSOR=IA32 |
| 39 | ;; |
| 40 | X64) |
| 41 | export PROCESSOR=X64 |
| 42 | ;; |
| 43 | *) |
| 44 | echo Invalid Architecture string, should be only IA32 or X64 |
| 45 | return 1 |
| 46 | esac |
| 47 | |
| 48 | export BUILD_DIR=$WORKSPACE/Build/DuetPkg$PROCESSOR/DEBUG_UNIXGCC |
| 49 | |
| 50 | |
gikidy | 536c563 | 2009-03-24 09:23:21 +0000 | [diff] [blame] | 51 | export EFI_BOOT_MEDIA=$2 |
| 52 | export EFI_BOOT_DEVICE=$3 |
gikidy | 5b7021e | 2009-03-03 06:27:07 +0000 | [diff] [blame] | 53 | |
gikidy | 6976b5c | 2009-03-31 06:38:37 +0000 | [diff] [blame] | 54 | if [ "$PROCESS_MARK" = TRUE ] |
| 55 | then |
| 56 | case "$1" in |
| 57 | floppy) |
| 58 | if [ "$4" = FAT12 ] |
gikidy | 5b7021e | 2009-03-03 06:27:07 +0000 | [diff] [blame] | 59 | then |
gikidy | 6976b5c | 2009-03-31 06:38:37 +0000 | [diff] [blame] | 60 | echo Start to create floppy boot disk ... |
| 61 | echo Format $EFI_BOOT_MEDIA ... |
| 62 | ## Format floppy disk |
| 63 | umount $EFI_BOOT_MEDIA |
| 64 | mkfs.msdos $EFI_BOOT_DEVICE |
| 65 | mount $EFI_BOOT_DEVICE $EFI_BOOT_MEDIA |
gikidy | 5b7021e | 2009-03-03 06:27:07 +0000 | [diff] [blame] | 66 | echo Create boot sector ... |
gikidy | 6976b5c | 2009-03-31 06:38:37 +0000 | [diff] [blame] | 67 | ## Linux version of GenBootSector has not pass build yet. |
| 68 | $BASETOOLS_DIR/GnuGenBootSector -i $EFI_BOOT_DEVICE -o FDBs.com |
klu2 | e88f305 | 2009-06-22 03:01:53 +0000 | [diff] [blame] | 69 | $BASETOOLS_DIR/BootSectImage -g FDBs.com $BOOTSECTOR_BIN_DIR/bootsect.com -f |
| 70 | $BASETOOLS_DIR/GnuGenBootSector -o $EFI_BOOT_DEVICE -i $BOOTSECTOR_BIN_DIR/bootsect.com |
gikidy | 6976b5c | 2009-03-31 06:38:37 +0000 | [diff] [blame] | 71 | |
| 72 | cp $BUILD_DIR/FV/Efildr $EFI_BOOT_MEDIA |
| 73 | |
| 74 | mkdir -p $EFI_BOOT_MEDIA/efi |
| 75 | mkdir -p $EFI_BOOT_MEDIA/efi/boot |
eric_tian | e843cdd | 2010-01-19 08:28:28 +0000 | [diff] [blame] | 76 | if [ "$5" = IA32 ] |
| 77 | then |
| 78 | cp $WORKSPACE/EdkShellBinPkg/MinimumShell/Ia32/Shell.efi $EFI_BOOT_MEDIA/efi/boot/bootia32.efi |
| 79 | else |
| 80 | if [ "$5" = X64 ] |
| 81 | then |
| 82 | cp $WORKSPACE/EdkShellBinPkg/MinimumShell/X64/Shell.efi $EFI_BOOT_MEDIA/efi/boot/bootx64.efi |
| 83 | else |
| 84 | echo Wrong Arch! |
| 85 | fi |
| 86 | fi |
gikidy | 5b7021e | 2009-03-03 06:27:07 +0000 | [diff] [blame] | 87 | echo Done. |
gikidy | 6976b5c | 2009-03-31 06:38:37 +0000 | [diff] [blame] | 88 | else |
| 89 | echo "Wrong FAT type $4 for floppy!" |
gikidy | 5b7021e | 2009-03-03 06:27:07 +0000 | [diff] [blame] | 90 | fi |
gikidy | 6976b5c | 2009-03-31 06:38:37 +0000 | [diff] [blame] | 91 | ;; |
| 92 | |
| 93 | file) # CreateFile |
| 94 | if [ "$4" = FAT12 ] |
| 95 | then |
| 96 | echo "Start to create file boot disk ..." |
| 97 | echo Create boot sector ... |
gikidy | 5b7021e | 2009-03-03 06:27:07 +0000 | [diff] [blame] | 98 | |
gikidy | 6976b5c | 2009-03-31 06:38:37 +0000 | [diff] [blame] | 99 | ## Linux version of GenBootSector has not pass build yet. |
| 100 | $BASETOOLS_DIR/GnuGenBootSector -i $EFI_BOOT_MEDIA -o FDBs.com |
klu2 | e88f305 | 2009-06-22 03:01:53 +0000 | [diff] [blame] | 101 | $BASETOOLS_DIR/BootSectImage -g FDBs.com $BOOTSECTOR_BIN_DIR/bootsect.com -f |
klu2 | df6434f | 2009-09-17 02:16:30 +0000 | [diff] [blame] | 102 | $BASETOOLS_DIR/GnuGenBootSector -o $EFI_BOOT_MEDIA -i $BOOTSECTOR_BIN_DIR/bootsect.com |
gikidy | 6976b5c | 2009-03-31 06:38:37 +0000 | [diff] [blame] | 103 | echo Done. |
| 104 | else |
| 105 | echo "Wrong FAT type" $4 "for floppy!" |
| 106 | fi |
| 107 | ;; |
| 108 | |
| 109 | usb) # CreateUsb |
| 110 | |
| 111 | if [ "$4" = FAT16 ] |
| 112 | then |
eric_tian | e843cdd | 2010-01-19 08:28:28 +0000 | [diff] [blame] | 113 | if [ "$6" = step2 ] |
gikidy | 6976b5c | 2009-03-31 06:38:37 +0000 | [diff] [blame] | 114 | then |
| 115 | cp $BUILD_DIR/FV/Efildr16 $EFI_BOOT_MEDIA |
| 116 | mkdir $EFI_BOOT_MEDIA/efi/boot |
eric_tian | e843cdd | 2010-01-19 08:28:28 +0000 | [diff] [blame] | 117 | if [ "$5" = IA32 ] |
| 118 | then |
| 119 | cp $WORKSPACE/EdkShellBinPkg/MinimumShell/Ia32/Shell.efi $EFI_BOOT_MEDIA/efi/boot/bootia32.efi |
| 120 | else |
| 121 | if [ "$5" = X64 ] |
| 122 | then |
| 123 | cp $WORKSPACE/EdkShellBinPkg/MinimumShell/X64/Shell.efi $EFI_BOOT_MEDIA/efi/boot/bootx64.efi |
| 124 | else |
| 125 | echo Wrong Arch! |
| 126 | fi |
| 127 | fi |
gikidy | 6976b5c | 2009-03-31 06:38:37 +0000 | [diff] [blame] | 128 | echo "step2 Done!" |
| 129 | else |
| 130 | echo Format $EFI_BOOT_DEVICE ... |
| 131 | #Do format command. |
| 132 | echo Create boot sector ... |
| 133 | ## Linux version of GenBootSector & Bootsectimage has not pass build yet. |
| 134 | $BASETOOLS_DIR/GnuGenBootSector -i $EFI_BOOT_DEVICE -o UsbBs16.com |
klu2 | e88f305 | 2009-06-22 03:01:53 +0000 | [diff] [blame] | 135 | $BASETOOLS_DIR/BootSectImage -g UsbBs16.com $BOOTSECTOR_BIN_DIR/bs16.com -f |
| 136 | $BASETOOLS_DIR/GnuGenBootSector -o $EFI_BOOT_DEVICE -i $BOOTSECTOR_BIN_DIR/bs16.com |
| 137 | $BASETOOLS_DIR/GnuGenBootSector -m -o $EFI_BOOT_DEVICE -i $BOOTSECTOR_BIN_DIR/Mbr.com |
gikidy | 6976b5c | 2009-03-31 06:38:37 +0000 | [diff] [blame] | 138 | echo Done. |
| 139 | echo PLEASE UNPLUG USB, THEN PLUG IT AGAIN TO DO STEP2! |
| 140 | fi |
| 141 | elif [ "$4" = FAT32 ] |
| 142 | then |
eric_tian | e843cdd | 2010-01-19 08:28:28 +0000 | [diff] [blame] | 143 | if [ "$6" = step2 ] |
gikidy | 6976b5c | 2009-03-31 06:38:37 +0000 | [diff] [blame] | 144 | then |
| 145 | cp $BUILD_DIR/FV/Efildr20 $EFI_BOOT_MEDIA |
| 146 | mkdir $EFI_BOOT_MEDIA/efi/boot |
eric_tian | e843cdd | 2010-01-19 08:28:28 +0000 | [diff] [blame] | 147 | if [ "$5" = IA32 ] |
| 148 | then |
| 149 | cp $WORKSPACE/EdkShellBinPkg/MinimumShell/Ia32/Shell.efi $EFI_BOOT_MEDIA/efi/boot/bootia32.efi |
| 150 | else |
| 151 | if [ "$5" = X64 ] |
| 152 | then |
| 153 | cp $WORKSPACE/EdkShellBinPkg/MinimumShell/X64/Shell.efi $EFI_BOOT_MEDIA/efi/boot/bootx64.efi |
| 154 | else |
| 155 | echo Wrong Arch! |
| 156 | fi |
| 157 | fi |
gikidy | 6976b5c | 2009-03-31 06:38:37 +0000 | [diff] [blame] | 158 | echo "step2 Done!" |
| 159 | else |
| 160 | echo Format $EFI_BOOT_DEVICE ... |
| 161 | #Do format command. |
| 162 | echo Create boot sector ... |
| 163 | ## Linux version of GenBootSector & Bootsectimage has not pass build yet. |
| 164 | $BASETOOLS_DIR/GnuGenBootSector -i $EFI_BOOT_DEVICE -o UsbBs32.com |
klu2 | e88f305 | 2009-06-22 03:01:53 +0000 | [diff] [blame] | 165 | $BASETOOLS_DIR/BootSectImage -g UsbBs32.com $BOOTSECTOR_BIN_DIR/bs32.com -f |
| 166 | $BASETOOLS_DIR/GnuGenBootSector -o $EFI_BOOT_DEVICE -i $BOOTSECTOR_BIN_DIR/bs32.com |
| 167 | $BASETOOLS_DIR/GnuGenBootSector -m -o $EFI_BOOT_DEVICE -i $BOOTSECTOR_BIN_DIR/Mbr.com |
gikidy | 6976b5c | 2009-03-31 06:38:37 +0000 | [diff] [blame] | 168 | echo Done. |
| 169 | echo PLEASE UNPLUG USB, THEN PLUG IT AGAIN TO DO STEP2! |
| 170 | fi |
| 171 | else |
| 172 | echo "Wrong FAT type $1 for floppy!" |
| 173 | fi |
| 174 | |
| 175 | ;; |
| 176 | |
| 177 | ide) # CreateIde |
| 178 | echo "Not support yet!" |
gikidy | 5b7021e | 2009-03-03 06:27:07 +0000 | [diff] [blame] | 179 | ;; |
gikidy | 6976b5c | 2009-03-31 06:38:37 +0000 | [diff] [blame] | 180 | *) |
| 181 | echo "Arg1 should be [floppy | file | usb | ide] !" |
gikidy | 5b7021e | 2009-03-03 06:27:07 +0000 | [diff] [blame] | 182 | |
gikidy | 6976b5c | 2009-03-31 06:38:37 +0000 | [diff] [blame] | 183 | esac |
| 184 | fi |