blob: ba71bc17c1f1ea0b78c98e1c80b90671b2fbdc0e [file] [log] [blame]
klu2ab9cb4b2010-03-18 02:36:52 +00001#! /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##
gikidy5b7021e2009-03-03 06:27:07 +000016
17# Set up environment at fisrt.
klu2ab9cb4b2010-03-18 02:36:52 +000018
klu2df6434f2009-09-17 02:16:30 +000019export BASETOOLS_DIR=$WORKSPACE/Conf/BaseToolsSource/Source/C/bin
klu2e88f3052009-06-22 03:01:53 +000020export BOOTSECTOR_BIN_DIR=$WORKSPACE/DuetPkg/BootSector/bin
gikidy5b7021e2009-03-03 06:27:07 +000021export DISK_LABEL=DUET
gikidy6976b5c2009-03-31 06:38:37 +000022export PROCESS_MARK=TRUE
gikidy5b7021e2009-03-03 06:27:07 +000023
24if [ \
25 -z "$*" -o \
26 "$*" = "-?" -o \
27 "$*" = "-h" -o \
28 "$*" = "--help" \
29 ]
30then
eric_tiane843cdd2010-01-19 08:28:28 +000031 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"
gikidy6976b5c2009-03-31 06:38:37 +000033 PROCESS_MARK=FALSE
gikidy5b7021e2009-03-03 06:27:07 +000034fi
35
klu2ab9cb4b2010-03-18 02:36:52 +000036case "$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
46esac
47
48export BUILD_DIR=$WORKSPACE/Build/DuetPkg$PROCESSOR/DEBUG_UNIXGCC
49
50
gikidy536c5632009-03-24 09:23:21 +000051export EFI_BOOT_MEDIA=$2
52export EFI_BOOT_DEVICE=$3
gikidy5b7021e2009-03-03 06:27:07 +000053
gikidy6976b5c2009-03-31 06:38:37 +000054if [ "$PROCESS_MARK" = TRUE ]
55then
56 case "$1" in
57 floppy)
58 if [ "$4" = FAT12 ]
gikidy5b7021e2009-03-03 06:27:07 +000059 then
gikidy6976b5c2009-03-31 06:38:37 +000060 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
gikidy5b7021e2009-03-03 06:27:07 +000066 echo Create boot sector ...
gikidy6976b5c2009-03-31 06:38:37 +000067 ## Linux version of GenBootSector has not pass build yet.
68 $BASETOOLS_DIR/GnuGenBootSector -i $EFI_BOOT_DEVICE -o FDBs.com
klu2e88f3052009-06-22 03:01:53 +000069 $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
gikidy6976b5c2009-03-31 06:38:37 +000071
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_tiane843cdd2010-01-19 08:28:28 +000076 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
gikidy5b7021e2009-03-03 06:27:07 +000087 echo Done.
gikidy6976b5c2009-03-31 06:38:37 +000088 else
89 echo "Wrong FAT type $4 for floppy!"
gikidy5b7021e2009-03-03 06:27:07 +000090 fi
gikidy6976b5c2009-03-31 06:38:37 +000091 ;;
92
93 file) # CreateFile
94 if [ "$4" = FAT12 ]
95 then
96 echo "Start to create file boot disk ..."
97 echo Create boot sector ...
gikidy5b7021e2009-03-03 06:27:07 +000098
gikidy6976b5c2009-03-31 06:38:37 +000099 ## Linux version of GenBootSector has not pass build yet.
100 $BASETOOLS_DIR/GnuGenBootSector -i $EFI_BOOT_MEDIA -o FDBs.com
klu2e88f3052009-06-22 03:01:53 +0000101 $BASETOOLS_DIR/BootSectImage -g FDBs.com $BOOTSECTOR_BIN_DIR/bootsect.com -f
klu2df6434f2009-09-17 02:16:30 +0000102 $BASETOOLS_DIR/GnuGenBootSector -o $EFI_BOOT_MEDIA -i $BOOTSECTOR_BIN_DIR/bootsect.com
gikidy6976b5c2009-03-31 06:38:37 +0000103 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_tiane843cdd2010-01-19 08:28:28 +0000113 if [ "$6" = step2 ]
gikidy6976b5c2009-03-31 06:38:37 +0000114 then
115 cp $BUILD_DIR/FV/Efildr16 $EFI_BOOT_MEDIA
116 mkdir $EFI_BOOT_MEDIA/efi/boot
eric_tiane843cdd2010-01-19 08:28:28 +0000117 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
gikidy6976b5c2009-03-31 06:38:37 +0000128 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
klu2e88f3052009-06-22 03:01:53 +0000135 $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
gikidy6976b5c2009-03-31 06:38:37 +0000138 echo Done.
139 echo PLEASE UNPLUG USB, THEN PLUG IT AGAIN TO DO STEP2!
140 fi
141 elif [ "$4" = FAT32 ]
142 then
eric_tiane843cdd2010-01-19 08:28:28 +0000143 if [ "$6" = step2 ]
gikidy6976b5c2009-03-31 06:38:37 +0000144 then
145 cp $BUILD_DIR/FV/Efildr20 $EFI_BOOT_MEDIA
146 mkdir $EFI_BOOT_MEDIA/efi/boot
eric_tiane843cdd2010-01-19 08:28:28 +0000147 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
gikidy6976b5c2009-03-31 06:38:37 +0000158 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
klu2e88f3052009-06-22 03:01:53 +0000165 $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
gikidy6976b5c2009-03-31 06:38:37 +0000168 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!"
gikidy5b7021e2009-03-03 06:27:07 +0000179 ;;
gikidy6976b5c2009-03-31 06:38:37 +0000180 *)
181 echo "Arg1 should be [floppy | file | usb | ide] !"
gikidy5b7021e2009-03-03 06:27:07 +0000182
gikidy6976b5c2009-03-31 06:38:37 +0000183 esac
184fi