From ed34bfa8f1c97271c4546cd8312112da97d1df08 Mon Sep 17 00:00:00 2001 From: Warner Losh Date: Thu, 10 Feb 2011 23:36:39 +0000 Subject: [PATCH] Add 'generic' flash images. This is for projects producing generic images that are of a certain size. The geometery is bogus, but that doesn't matter since the new packet mode onviates the need to get the geometry right. --- tools/tools/nanobsd/FlashDevice.sub | 44 ++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/tools/tools/nanobsd/FlashDevice.sub b/tools/tools/nanobsd/FlashDevice.sub index ce9095097e8..90b3f6db364 100644 --- a/tools/tools/nanobsd/FlashDevice.sub +++ b/tools/tools/nanobsd/FlashDevice.sub @@ -203,10 +203,52 @@ sub_FlashDevice () { ;; esac ;; + # Generic flash media. It assumes that we're booting using packet + # mode so the HEADS and SECTS don't matter. The truncation of the + # size to a slightly lower number is intentional to be conservative + # (eg, 1 sector smaller than N GB is always smaller than any flash + # claiming to be N GB, but wastes a little space sometimes when 1GB + # really means 1GiB). This is intended to be used when producing + # generic images for anybody to boot. Media sizes are specified 'Xg' + # for X GB (10^9 bytes) flash or Xm for X MB (10^6 bytes) flash. + # Power of 2 variants can be specified with gi or mi for GiB and MiB + # sizeed flash and don't try to be conservative (use with caution). + generic) + case $a2 in + *.*) # Catch unsupported 1.5g case, since expr can't + # cope with floats. + echo "Unsupported generic size $a2" + exit 2 + ;; + *m) + NANO_HEADS=16 + NANO_SECTS=63 + NANO_MEDIASIZE=`expr -e ${a2%m} \* 1000000 / 512` + ;; + *g) + NANO_HEADS=16 + NANO_SECTS=63 + NANO_MEDIASIZE=`expr -e ${a2%g} \* 1000000000 / 512` + ;; + *mi) + NANO_HEADS=16 + NANO_SECTS=63 + NANO_MEDIASIZE=`expr -e ${a2%mi} \* 1024 \* 1024 / 512` + ;; + *gi) + NANO_HEADS=16 + NANO_SECTS=63 + NANO_MEDIASIZE=`expr -e ${a2%gi} \* 1024 \* 1024 \* 1024 / 512` + ;; + *) + echo "Unsupported generic size $a2" + exit 2 + ;; + esac + ;; *) echo "Unknown Flash manufacturer" exit 2 ;; esac } -