]> git.proxmox.com Git - mirror_edk2.git/blob - DuetPkg/CreateBootDisk.sh
BaseTools\GenFds: remove extra content
[mirror_edk2.git] / DuetPkg / CreateBootDisk.sh
1 #! /bin/sh
2
3 ## @file
4 #
5 # Copyright (c) 2010 - 2014, 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 ##
16
17 # Set up environment at fisrt.
18
19 if [ -z "$EDK_TOOLS_PATH" ]
20 then
21 export BASETOOLS_DIR=$WORKSPACE/Conf/BaseToolsSource/Source/C/bin
22 else
23 export BASETOOLS_DIR=$EDK_TOOLS_PATH/Source/C/bin
24 fi
25
26 export BOOTSECTOR_BIN_DIR=$WORKSPACE/DuetPkg/BootSector/bin
27 export DISK_LABEL=DUET
28 export PROCESS_MARK=TRUE
29
30 if [ \
31 -z "$*" -o \
32 "$*" = "-?" -o \
33 "$*" = "-h" -o \
34 "$*" = "--help" \
35 ]
36 then
37 echo "Usage: CreateBootDisk [usb|floppy|ide|file] MediaPath DevicePath [FAT12|FAT16|FAT32] [IA32|X64]"
38 echo "e.g. : CreateBootDisk floppy /media/floppy0 /dev/fd0 FAT12 IA32"
39 PROCESS_MARK=FALSE
40 fi
41
42 case "$5" in
43 IA32)
44 export PROCESSOR=IA32
45 ;;
46 X64)
47 export PROCESSOR=X64
48 ;;
49 *)
50 echo Invalid Architecture string, should be only IA32 or X64
51 return 1
52 esac
53
54 . $WORKSPACE/DuetPkg/SetEnv_$PROCESSOR.sh
55 export BUILD_DIR=$WORKSPACE/Build/DuetPkg$PROCESSOR/DEBUG_$TOOLCHAIN
56
57
58 export EFI_BOOT_MEDIA=$2
59 export EFI_BOOT_DEVICE=$3
60
61 if [ "$PROCESS_MARK" = TRUE ]
62 then
63 case "$1" in
64 floppy)
65 if [ "$4" = FAT12 ]
66 then
67 echo Start to create floppy boot disk ...
68 echo Format $EFI_BOOT_MEDIA ...
69 ## Format floppy disk
70 umount $EFI_BOOT_MEDIA
71 mkfs.msdos $EFI_BOOT_DEVICE
72 mount $EFI_BOOT_DEVICE $EFI_BOOT_MEDIA
73 echo Create boot sector ...
74 ## Linux version of GenBootSector has not pass build yet.
75 $BASETOOLS_DIR/GnuGenBootSector -i $EFI_BOOT_DEVICE -o FDBs.com
76 cp $BOOTSECTOR_BIN_DIR/bootsect.com FDBs-1.com
77 $BASETOOLS_DIR/BootSectImage -g FDBs.com FDBs-1.com -f
78 $BASETOOLS_DIR/GnuGenBootSector -o $EFI_BOOT_DEVICE -i FDBs-1.com
79 rm FDBs-1.com
80 cp $BUILD_DIR/FV/Efildr $EFI_BOOT_MEDIA
81
82 mkdir -p $EFI_BOOT_MEDIA/efi
83 mkdir -p $EFI_BOOT_MEDIA/efi/boot
84 if [ "$5" = IA32 ]
85 then
86 cp $WORKSPACE/ShellBinPkg/UefiShell/Ia32/Shell.efi $EFI_BOOT_MEDIA/efi/boot/boot$5.efi
87 else
88 if [ "$5" = X64 ]
89 then
90 cp $WORKSPACE/ShellBinPkg/UefiShell/X64/Shell.efi $EFI_BOOT_MEDIA/efi/boot/boot$5.efi
91 else
92 echo Wrong Arch!
93 fi
94 fi
95 echo Done.
96 else
97 echo "Wrong FAT type $4 for floppy!"
98 fi
99 ;;
100
101 file) # CreateFile
102 if [ "$4" = FAT12 ]
103 then
104 echo "Start to create file boot disk ..."
105 dd bs=512 count=2880 if=/dev/zero of=$EFI_BOOT_MEDIA
106 mkfs.msdos -F 12 $EFI_BOOT_MEDIA
107
108 mcopy -i $EFI_BOOT_MEDIA $BUILD_DIR/FV/Efildr ::/Efildr
109 mmd -i $EFI_BOOT_MEDIA ::/efi ::/efi/boot
110 if [ "$5" = IA32 ]
111 then
112 mcopy -i $EFI_BOOT_MEDIA $WORKSPACE/ShellBinPkg/UefiShell/Ia32/Shell.efi ::/efi/boot/boot$5.efi
113 elif [ "$5" = X64 ]
114 then
115 mcopy -i $EFI_BOOT_MEDIA $WORKSPACE/ShellBinPkg/UefiShell/X64/Shell.efi ::/efi/boot/boot$5.efi
116 else
117 echo Wrong Arch!
118 fi
119 mdir -i $EFI_BOOT_MEDIA -s ::
120
121 ## Linux version of GenBootSector has not pass build yet.
122 $BASETOOLS_DIR/GnuGenBootSector -i $EFI_BOOT_MEDIA -o $EFI_BOOT_MEDIA.bs0
123 cp $BOOTSECTOR_BIN_DIR/bootsect.com $EFI_BOOT_MEDIA.bs1
124 $BASETOOLS_DIR/BootSectImage -g $EFI_BOOT_MEDIA.bs0 $EFI_BOOT_MEDIA.bs1
125 $BASETOOLS_DIR/GnuGenBootSector -o $EFI_BOOT_MEDIA -i $EFI_BOOT_MEDIA.bs1
126 rm $EFI_BOOT_MEDIA.bs[0-1]
127 echo Done.
128 else
129 echo "Wrong FAT type" $4 "for floppy!"
130 fi
131 ;;
132
133 usb) # CreateUsb
134
135 if [ "$4" = FAT16 ]
136 then
137 if [ "$6" = step2 ]
138 then
139 cp $BUILD_DIR/FV/Efildr16 $EFI_BOOT_MEDIA
140 mkdir $EFI_BOOT_MEDIA/efi/boot
141 if [ "$5" = IA32 ]
142 then
143 cp $WORKSPACE/ShellBinPkg/UefiShell/Ia32/Shell.efi $EFI_BOOT_MEDIA/efi/boot/boot$5.efi
144 else
145 if [ "$5" = X64 ]
146 then
147 cp $WORKSPACE/ShellBinPkg/UefiShell/X64/Shell.efi $EFI_BOOT_MEDIA/efi/boot/boot$5.efi
148 else
149 echo Wrong Arch!
150 fi
151 fi
152 echo "step2 Done!"
153 else
154 echo Format $EFI_BOOT_DEVICE ...
155 #Do format command.
156 echo Create boot sector ...
157 ## Linux version of GenBootSector & Bootsectimage has not pass build yet.
158 $BASETOOLS_DIR/GnuGenBootSector -i $EFI_BOOT_DEVICE -o UsbBs16.com
159 cp $BOOTSECTOR_BIN_DIR/bs16.com Bs16-1.com
160 $BASETOOLS_DIR/BootSectImage -g UsbBs16.com Bs16-1.com -f
161 $BASETOOLS_DIR/GnuGenBootSector -o $EFI_BOOT_DEVICE -i Bs16-1.com
162 rm Bs16-1.com
163 $BASETOOLS_DIR/GnuGenBootSector -m -o $EFI_BOOT_DEVICE -i $BOOTSECTOR_BIN_DIR/Mbr.com
164 echo Done.
165 echo PLEASE UNPLUG USB, THEN PLUG IT AGAIN TO DO STEP2!
166 fi
167 elif [ "$4" = FAT32 ]
168 then
169 if [ "$6" = step2 ]
170 then
171 cp $BUILD_DIR/FV/Efildr20 $EFI_BOOT_MEDIA
172 mkdir $EFI_BOOT_MEDIA/efi/boot
173 if [ "$5" = IA32 ]
174 then
175 cp $WORKSPACE/ShellBinPkg/UefiShell/Ia32/Shell.efi $EFI_BOOT_MEDIA/efi/boot/boot$5.efi
176 else
177 if [ "$5" = X64 ]
178 then
179 cp $WORKSPACE/ShellBinPkg/UefiShell/X64/Shell.efi $EFI_BOOT_MEDIA/efi/boot/boot$5.efi
180 else
181 echo Wrong Arch!
182 fi
183 fi
184 echo "step2 Done!"
185 else
186 echo Format $EFI_BOOT_DEVICE ...
187 #Do format command.
188 echo Create boot sector ...
189 ## Linux version of GenBootSector & Bootsectimage has not pass build yet.
190 $BASETOOLS_DIR/GnuGenBootSector -i $EFI_BOOT_DEVICE -o UsbBs32.com
191 cp $BOOTSECTOR_BIN_DIR/bs32.com Bs32-1.com
192 $BASETOOLS_DIR/BootSectImage -g UsbBs32.com Bs32-1.com -f
193 $BASETOOLS_DIR/GnuGenBootSector -o $EFI_BOOT_DEVICE -i Bs32-1.com
194 rm Bs32-1.com
195 $BASETOOLS_DIR/GnuGenBootSector -m -o $EFI_BOOT_DEVICE -i $BOOTSECTOR_BIN_DIR/Mbr.com
196 echo Done.
197 echo PLEASE UNPLUG USB, THEN PLUG IT AGAIN TO DO STEP2!
198 fi
199 else
200 echo "Wrong FAT type $1 for floppy!"
201 fi
202
203 ;;
204
205 ide) # CreateIde
206 echo "Not support yet!"
207 ;;
208 *)
209 echo "Arg1 should be [floppy | file | usb | ide] !"
210
211 esac
212 fi