@@ -72,29 +72,29 @@ usage() {
7272 echo " -C: console device (default: ${DEFAULT_CONSOLE} )"
7373 echo " -d: virtio diskdev file (default: ${DEFAULT_VIRTIO_DISK} )"
7474 echo " -e: set FreeBSD loader environment variable"
75- echo " -E: Use UEFI mode"
76- echo " -f: Use a specific UEFI firmware"
75+ echo " -E: Use UEFI mode (amd64 only) "
76+ echo " -f: Use a specific boot firmware (e.g., EDK2, U-Boot) "
7777 echo " -F: Use a custom UEFI GOP framebuffer size" \
78- " (default: ${DEFAULT_VNCSIZE} )"
78+ " (default: ${DEFAULT_VNCSIZE} ) (amd64 only) "
7979 echo " -G: bind the GDB stub to the specified address"
8080 echo " -H: host filesystem to export to the loader"
8181 echo " -i: force boot of the Installation CDROM image"
8282 echo " -I: Installation CDROM image location" \
8383 " (default: ${DEFAULT_ISOFILE} )"
84- echo " -l: the OS loader to use (default: /boot/userboot.so)"
84+ echo " -l: the OS loader to use (default: /boot/userboot.so) (amd64 only) "
8585 echo " -L: IP address for UEFI GOP VNC server" \
8686 " (default: ${DEFAULT_VNCHOST} )"
8787 echo " -m: memory size (default: ${DEFAULT_MEMSIZE} )"
8888 echo " -n: network adapter emulation type" \
8989 " (default: ${DEFAULT_NIC} )"
9090 echo " -p: pass-through a host PCI device (e.g ppt0 or" \
91- " bus/slot/func)"
91+ " bus/slot/func) (amd64 only) "
9292 echo " -P: UEFI GOP VNC port (default: ${DEFAULT_VNCPORT} )"
9393 echo " -t: tap device for virtio-net (default: $DEFAULT_TAPDEV )"
94- echo " -T: Enable tablet device (for UEFI GOP)"
94+ echo " -T: Enable tablet device (for UEFI GOP) (amd64 only) "
9595 echo " -u: RTC keeps UTC time"
9696 echo " -v: Wait for VNC client connection before booting VM"
97- echo " -w: ignore unimplemented MSRs"
97+ echo " -w: ignore unimplemented MSRs (amd64 only) "
9898 echo " "
9999 [ -n " $msg " ] && errmsg " $msg "
100100 exit 1
@@ -111,6 +111,12 @@ if [ $? -ne 0 ]; then
111111 exit 1
112112fi
113113
114+ platform=$( uname -m)
115+ if [ " ${platform} " != amd64 -a " ${platform} " != arm64 ]; then
116+ errmsg " This script is only supported on amd64 and arm64 platforms"
117+ exit 1
118+ fi
119+
114120force_install=0
115121isofile=${DEFAULT_ISOFILE}
116122memsize=${DEFAULT_MEMSIZE}
@@ -121,7 +127,6 @@ tap_total=0
121127disk_total=0
122128disk_emulation=${DEFAULT_DISK}
123129loader_opt=" "
124- bhyverun_opt=" -H -P"
125130pass_total=0
126131
127132# EFI-specific options
@@ -133,7 +138,21 @@ vncport=${DEFAULT_VNCPORT}
133138vncsize=${DEFAULT_VNCSIZE}
134139tablet=" "
135140
136- while getopts aAc:C:d:e:Ef:F:G:hH:iI:l:L:m:n:p:P:t:Tuvw c ; do
141+ # arm64 only
142+ uboot_firmware=" /usr/local/share/u-boot/u-boot-bhyve-arm64/u-boot.bin"
143+
144+ case ${platform} in
145+ amd64)
146+ bhyverun_opt=" -H -P"
147+ opts=" aAc:C:d:e:Ef:F:G:hH:iI:l:L:m:n:p:P:t:Tuvw"
148+ ;;
149+ arm64)
150+ bhyverun_opt=" "
151+ opts=" aAc:C:d:e:f:F:G:hH:iI:L:m:n:P:t:uv"
152+ ;;
153+ esac
154+
155+ while getopts $opts c ; do
137156 case $c in
138157 a)
139158 bhyverun_opt=" ${bhyverun_opt} -a"
@@ -161,7 +180,7 @@ while getopts aAc:C:d:e:Ef:F:G:hH:iI:l:L:m:n:p:P:t:Tuvw c ; do
161180 efi_mode=1
162181 ;;
163182 f)
164- efi_firmware =" ${OPTARG} "
183+ firmware =" ${OPTARG} "
165184 ;;
166185 F)
167186 vncsize=" ${OPTARG} "
@@ -246,12 +265,25 @@ if [ ${pass_total} -gt 0 ]; then
246265 bhyverun_opt=" ${bhyverun_opt} -S"
247266fi
248267
249- if [ ${efi_mode} -gt 0 ]; then
250- if [ ! -f ${efi_firmware} ]; then
251- echo " Error: EFI Firmware ${efi_firmware} doesn't exist." \
252- " Try: pkg install edk2-bhyve"
253- exit 1
268+ if [ -z " $firmware " ]; then
269+ case ${platform} in
270+ amd64)
271+ firmware=" ${efi_firmware} "
272+ firmware_pkg=" edk2-bhyve"
273+ ;;
274+ arm64)
275+ firmware=" ${uboot_firmware} "
276+ firmware_pkg=" u-boot-bhyve-arm64"
277+ ;;
278+ esac
279+ fi
280+
281+ if [ -n " ${firmware} " -a ! -f " ${firmware} " ]; then
282+ echo " Error: Firmware file ${firmware} doesn't exist."
283+ if [ -n " ${firmware_pkg} " ]; then
284+ echo " Try: pkg install ${firmware_pkg} "
254285 fi
286+ exit 1
255287fi
256288
257289make_and_check_diskdev ()
@@ -317,7 +349,7 @@ while [ 1 ]; do
317349 installer_opt=" "
318350 fi
319351
320- if [ ${efi_mode} -eq 0 ]; then
352+ if [ ${platform} = amd64 -a ${ efi_mode} -eq 0 ]; then
321353 ${LOADER} -c ${console} -m ${memsize} ${BOOTDISKS} \
322354 ${loader_opt} ${vmname}
323355 bhyve_exit=$?
@@ -329,15 +361,19 @@ while [ 1 ]; do
329361 #
330362 # Build up args for additional tap and disk devices now.
331363 #
332- nextslot=2 # slot 0 is hostbridge, slot 1 is lpc
333- devargs=" " # accumulate disk/tap args here
334- i=0
335- while [ $i -lt $tap_total ] ; do
336- eval " tapname=\$ tap_dev${i} "
337- devargs=" $devargs -s $nextslot :0,${nic} ,${tapname} "
338- nextslot=$(( $nextslot + 1 ))
339- i=$(( $i + 1 ))
340- done
364+ devargs=" -s 0:0,hostbridge" # accumulate disk/tap args here
365+ case ${platform} in
366+ amd64)
367+ console_opt=" -l com1,${console} "
368+ devargs=" $devargs -s 1:0,lpc "
369+ nextslot=2 # slot 0 is hostbridge, slot 1 is lpc
370+ ;;
371+ arm64)
372+ console_opt=" -o console=${console} "
373+ devargs=" $devargs -o bootrom=${firmware} "
374+ nextslot=1 # slot 0 is hostbridge
375+ ;;
376+ esac
341377
342378 i=0
343379 while [ $i -lt $disk_total ] ; do
@@ -349,6 +385,14 @@ while [ 1 ]; do
349385 i=$(( $i + 1 ))
350386 done
351387
388+ i=0
389+ while [ $i -lt $tap_total ] ; do
390+ eval " tapname=\$ tap_dev${i} "
391+ devargs=" $devargs -s $nextslot :0,${nic} ,${tapname} "
392+ nextslot=$(( $nextslot + 1 ))
393+ i=$(( $i + 1 ))
394+ done
395+
352396 i=0
353397 while [ $i -lt $pass_total ] ; do
354398 eval " pass=\$ pass_dev${i} "
@@ -372,16 +416,14 @@ while [ 1 ]; do
372416 if [ ${efi_mode} -gt 0 ]; then
373417 efiargs=" -s 29,fbuf,tcp=${vnchost} :${vncport} ,"
374418 efiargs=" ${efiargs}${vncsize}${vncwait} "
375- efiargs=" ${efiargs} -l bootrom,${efi_firmware } "
419+ efiargs=" ${efiargs} -l bootrom,${firmware } "
376420 efiargs=" ${efiargs} ${tablet} "
377421 fi
378422
379423 ${FBSDRUN} -c ${cpus} -m ${memsize} ${bhyverun_opt} \
380- -s 0:0,hostbridge \
381- -s 1:0,lpc \
382424 ${efiargs} \
383425 ${devargs} \
384- -l com1, ${console} \
426+ ${console_opt} \
385427 ${installer_opt} \
386428 ${vmname}
387429
0 commit comments