]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - tools/tools/nanobsd/embedded/common
Update llvm to trunk r290819 and resolve conflicts.
[FreeBSD/FreeBSD.git] / tools / tools / nanobsd / embedded / common
1 # $FreeBSD$
2
3 #-
4 # Copyright (c) 2015 Warner Losh. All Rights Reserved.
5 # Copyright (c) 2010-2011 iXsystems, Inc., All rights reserved.
6 #
7 # Redistribution and use in source and binary forms, with or without
8 # modification, are permitted provided that the following conditions
9 # are met:
10 # 1. Redistributions of source code must retain the above copyright
11 #    notice, this list of conditions and the following disclaimer.
12 # 2. Redistributions in binary form must reproduce the above copyright
13 #    notice, this list of conditions and the following disclaimer in the
14 #    documentation and/or other materials provided with the distribution.
15 #
16 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17 # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 # ARE DISCLAIMED.  IN NO EVENT SHALL iXsystems, Inc OR CONTRIBUTORS BE LIABLE
20 # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 # SUCH DAMAGE.
27 #
28 #
29 # This file is heavily derived from both Sam Leffler's Avilia config,
30 # as well as the BSDRP project's config file.  Neither of these have
31 # an explicit copyright/license statement, but are implicitly BSDL. This
32 # example has been taken from the FreeNAS project (an early version) and
33 # simplified to meet the needs of the example.
34 #
35
36 # NB: You want the other file as the command line arg :)
37
38 # Missing in base:
39 # o mkimg setting active partition
40 # o mkimg starting at arbitrary offset (needed for A10, et al)
41 # o mtools still needed because we have no makefs -t msdos
42 # o nanobsd doesn't record changes to WORLDTEMP in customization
43 #   scripts yet, so we have kludge to pick up all files
44 # o easy way for pkg to grab files from other repos and put that
45 #   data on the image
46 # o Need to have some way to create / resize the s4 slice to do ping
47 #   pong bouncing between s3 and s4 for an arbitrary image. we can resize
48 #   one slice, not two
49 # o hints in the uboot ports for how to create the image
50 #
51 # Missing here
52 # o documentation for how to run the qemu images
53 # o msdos mtools fallback
54 # o special boot for !x86 !arm platforms
55 # o qemu image for arm
56 # o qemu image for aarch64
57 # o qemu image for armv6/armv7
58 # o easy support for different image / vm formats
59 # o need to promote much of this to nanobsd.sh and friends
60 # o uses old kludge to build image w/o ownership being right
61 #   for many files. Should move to mtree-dedup.awk.
62 # o support for EFI images
63 # o support for GPT partitioning
64 #
65 # Long Term
66 # o common tooling for creating images for odd-ball platforms
67 # o support for boot loaders other than uboot in the image
68 #   or via special insturctions
69 # o No pony support. Sadly, you cannot have a pony.
70 #
71
72 if [ -z $NANO_NAME ]; then
73         echo "NANO_NAME not defined. Use foo.cfg instead."
74 fi
75
76 NANO_SLICE_FAT_SIZE=32m
77 NANO_SLICE_CFG_SIZE=32m
78
79 NANO_BOOT2CFG="-P -S115200"
80
81 NANO_RAM_ETCSIZE=8192
82 NANO_RAM_TMPVARSIZE=8192
83 NANO_IMAGES=2
84
85 NANO_PMAKE="make -j $(sysctl -n hw.ncpu)"
86
87 NANO_CFG_BASE=$(pwd)
88 NANO_CFG_BASE=$(realpath ${NANO_CFG_BASE}/..)
89 NANO_SRC=$(realpath ${NANO_CFG_BASE}/../../..)
90 #### XXX share obj 
91 if [ -z ${NANO_CPUTYPE} ]; then
92         NANO_OBJ=${NANO_SRC}/../embedded/obj
93 else
94         # Alas, I can't set OBJTREE to ${MACHINE}.${MACHINE_ARCH}.${CPUTYPE}
95         # so this will have to do until I can.
96         NANO_OBJ=${NANO_SRC}/../embedded/obj.${NANO_CPUTYPE}
97 fi
98 NANO_LOG=${NANO_OBJ}/../${NANO_NAME}
99 NANO_DISKIMGDIR=${NANO_OBJ}/../images
100 NANO_WORLDDIR=${NANO_LOG}/_.w
101 NANO_INIT_IMG2=0
102 NANO_NOPRIV_BUILD=t
103 unset MAKEOBJDIRPREFIX
104
105 mkdir -p ${NANO_OBJ}
106 NANO_OBJ=$(realpath ${NANO_OBJ})
107 mkdir -p ${NANO_LOG}
108 NANO_LOG=$(realpath ${NANO_LOG})
109 mkdir -p ${NANO_IMAGES}
110 NANO_IMAGES=$(realpath ${NANO_IMAGES})
111 mkdir -p ${NANO_WORLDDIR}
112 NANO_WORLDDIR=$(realpath ${NANO_WORLDDIR})
113 mkdir -p ${NANO_DISKIMGDIR}
114 NANO_DISKIMGDIR=$(realpath ${NANO_DISKIMGDIR})
115
116 NANO_FAT_DIR=${NANO_LOG}/_.fat
117
118 customize_cmd cust_allow_ssh_root
119
120 add_etc_make_conf ( ) (
121         touch ${NANO_WORLDDIR}/etc/make.conf
122 )
123 customize_cmd add_etc_make_conf
124
125 cust_install_machine_files ( ) (
126         echo "cd ${NANO_CFG_BASE}/Files"
127         cd ${NANO_CFG_BASE}/Files
128         find . -print | grep -Ev '/(CVS|\.svn|\.hg|\.git)' | cpio -dumpv ${NANO_WORLDDIR}
129 )
130 customize_cmd cust_install_files
131 customize_cmd cust_install_machine_files 
132
133 # NB: leave c++ enabled so devd can be built
134 CONF_BUILD="
135 WITHOUT_ACPI=true
136 WITHOUT_ATM=true
137 WITHOUT_AUDIT=true
138 WITHOUT_BIND_DNSSEC=true
139 WITHOUT_BIND_ETC=true
140 WITHOUT_BIND_LIBS_LWRES=true
141 WITHOUT_BLUETOOTH=true
142 WITHOUT_CALENDAR=true
143 WITHOUT_CVS=true
144 WITHOUT_DICT=true
145 WITHOUT_EXAMPLES=true
146 WITHOUT_FORTRAN=true
147 WITHOUT_GAMES=true
148 WITHOUT_GCOV=true
149 WITHOUT_GPIB=true
150 WITHOUT_HTML=true
151 WITHOUT_I4B=true
152 WITHOUT_IPFILTER=true
153 WITHOUT_IPX=true
154 WITHOUT_LIBKSE=true
155 WITHOUT_LOCALES=true
156 WITHOUT_LPR=true
157 WITHOUT_MAN=true
158 WITHOUT_NETCAT=true
159 WITHOUT_NIS=true
160 WITHOUT_NLS=true
161 WITHOUT_NS_CACHING=true
162 WITHOUT_OBJC=true
163 WITHOUT_PROFILE=true
164 WITHOUT_RCMDS=true
165 WITHOUT_SENDMAIL=true
166 WITHOUT_SHAREDOCS=true
167 WITHOUT_SYSCONS=true
168 WITHOUT_LIB32=true
169 WITHOUT_TESTS=true
170 WITHOUT_DEBUG_FILES=t
171 WITHOUT_KERNEL_SYMBOLS=t
172 "
173 CONF_INSTALL="$CONF_BUILD
174 INSTALL_NODEBUG=t
175 NOPORTDOCS=t
176 NO_INSTALL_MANPAGES=t
177 "
178 # The following would help...
179 # WITHOUT_TOOLCHAIN=true                can't build ports
180 # WITHOUT_INSTALLLIB=true               libgcc.a
181 #
182 # from the build
183 # WITHOUT_INFO=true                     makeinfo
184 # WITHOUT_RCS=true
185 PKG_ONLY_MAKE_CONF="
186 WITHOUT_TOOLCHAIN=true
187 WITHOUT_INSTALLLIB=true
188 WITHOUT_INFO=true
189 WITHOUT_RCS=true
190 "
191
192 NANO_PACKAGE_ONLY=1
193
194 # Creates images for all the formats that use MBR / GPT
195 # split later if the #ifdef soup gets too bad.
196 create_diskimage_gpt ( ) (
197         pprint 2 "build diskimage gpt ${NANO_NAME}"
198
199         create_diskimage_mbr $*
200 )
201
202 create_diskimage_mbr ( ) (
203
204         local fmt
205
206         [ -z ${NANO_DISKIMAGE_FORMAT} ] || fmt=".${NANO_DISKIMAGE_FORMAT}"
207
208         pprint 2 "build diskimage ${NANO_NAME}"
209         pprint 3 "log: ${NANO_LOG}/_.di"
210         pprint 3 "image in: ${NANO_DISKIMGDIR}/_.disk.image.${NANO_NAME}${fmt}"
211
212         (
213         local extra i sz fmt fmtarg bootmbr bootbsd skiparg
214         set -o xtrace
215         # Tell mtools not to be too picky
216         export MTOOLS_SKIP_CHECK=1
217
218         [ -z ${NANO_DISKIMAGE_FORMAT} ] || fmtarg="-f ${NANO_DISKIMAGE_FORMAT}"
219         [ -z ${NANO_DISKIMAGE_FORMAT} ] || fmt=".${NANO_DISKIMAGE_FORMAT}"
220         bootmbr=${NANO_BOOT_MBR:+-b ${NANO_BOOT_MBR}}
221         bootbsd=${NANO_BOOT_BSD:+-b ${NANO_BOOT_BSD}}
222         skiparg=${NANO_MBR_FIRST_SKIP:+-S ${NANO_MBR_FIRST_SKIP}}
223
224         for i in s1 s2 s3 s4 p1 p2 p3 p4 p5 empty; do
225                 rm -fr ${NANO_LOG}/_.${i}*
226         done
227
228         # Populate the FAT partition, if needed
229         if [ -n "${NANO_SLICE_FAT}" ]; then
230                 echo Creating MSDOS partition for kernel
231                 newfs_msdos -C ${NANO_SLICE_FAT_SIZE} -F 16 -L ${NANO_NAME} \
232                         ${NANO_LOG}/_.${NANO_SLICE_FAT}
233                 if [ -d ${NANO_FAT_DIR} ]; then
234                         # Need to copy files from ${NANO_FATDIR} with mtools, or use
235                         # makefs -t msdos once that's supported
236                         mcopy -i ${NANO_LOG}/_.${NANO_SLICE_FAT} ${NANO_FAT_DIR}/* ::
237                 fi
238         fi
239
240         # Populate the Powerpc boot image, if needed
241         if [ "${NANO_LAYOUT}" = powerpc64-ibm ]; then
242                 dd if=${NANO_WORLDDIR}/boot/boot1.elf of=${NANO_LOG}/_.s1 bs=800k count=1 conv=sync
243         fi
244
245         # Populate the / partition, and place it into a slice with a
246         # bsd label
247         [ -z ${NANO_NOPRIV_BUILD} ] || extra="-F ${NANO_METALOG}"
248         sz=${NANO_SLICE_ROOT_SIZE:+-s ${NANO_SLICE_ROOT_SIZE}}
249         eval "${NANO_MAKEFS_UFS}" ${extra} $sz "${NANO_LOG}/_.${NANO_ROOT}" \
250                 "${NANO_WORLDDIR}"
251         case ${NANO_DISK_SCHEME} in
252         mbr)
253                 mkimg -s bsd ${bootbsd} -p freebsd-ufs:=${NANO_LOG}/_.${NANO_ROOT} \
254                         -o ${NANO_LOG}/_.${NANO_SLICE_ROOT}
255                 eval $NANO_SLICE_CFG=freebsd
256                 eval $NANO_SLICE_ROOT=freebsd
257                 ;;
258         gpt)
259                 eval $NANO_SLICE_CFG=freebsd-ufs
260                 eval $NANO_SLICE_ROOT=freebsd-ufs
261                 ;;
262         esac
263
264         # Populate the /cfg partition, empty if none given
265         if [ -z "${NANO_CFGDIR}" ]; then
266                 echo "Faking cfg dir, it's empty"
267                 NANO_CFGDIR=${NANO_LOG}/_.empty
268                 mkdir -p ${NANO_CFGDIR}
269         fi
270         # XXX -F cfg-mtree
271         eval "${NANO_MAKEFS_UFS}" -s ${NANO_SLICE_CFG_SIZE} \
272                 "${NANO_LOG}/_.${NANO_SLICE_CFG}" "${NANO_CFGDIR}"
273
274         # data slice not supported since we need the part for FAT for 
275         # booting
276
277         # Now shuffle all the slices together into the proper layout
278         if [ -n "$NANO_SLICE_FAT" ]; then
279                 eval $NANO_SLICE_FAT=fat16b
280         fi
281
282         out=${NANO_DISKIMGDIR}/_.disk.image.${NANO_NAME}${fmt}
283         # below depends on https://reviews.freebsd.org/D4403 not yet in the tree
284         # but there's problems: it marks all partitions as active, so you have to
285         # boot off parittion 3 or 2 by hand if you're playing around with this WIP
286         case ${NANO_LAYOUT} in
287         std-embedded)
288                 mkimg -a 3 ${skiparg} ${fmtarg} ${bootmbr} -s mbr -p ${s1}:=${NANO_LOG}/_.s1 \
289                         -p ${s2}:=${NANO_LOG}/_.s2 \
290                         -p ${s3}:=${NANO_LOG}/_.s3 \
291                         -o ${out}
292                 ;;
293         std-x86)
294                 # s1 is cfg, s2 is /, not sure how to make that
295                 # boot (marked as active) with mkimg yet
296                 mkimg -a 2 ${fmtarg} ${bootmbr} -s mbr -p ${s1}:=${NANO_LOG}/_.s1 \
297                         -p ${s2}:=${NANO_LOG}/_.s2 \
298                         -o ${out}
299                 ;;
300         std-uefi)
301                 # s1 is boot, s2 is cfg, s3 is /, not sure how to make that
302                 # boot (marked as active) with mkimg yet
303                 mkimg -a 2 ${fmtarg} ${bootmbr} -s mbr \
304                         -p efi:=${NANO_WORLDDIR}/boot/boot1.efifat \
305                         -p ${s2}:=${NANO_LOG}/_.s2 \
306                         -p ${s3}:=${NANO_LOG}/_.s3 \
307                         -o ${out}
308                 ;;
309         std-uefi-bios)
310                 # p1 is boot for uefi, p2 is boot for gpt, p3 is cfg, p4 is /
311                 # and p5 is alt-root (after resize)
312                 mkimg -a 2 ${fmtarg} ${bootmbr} -s gpt \
313                         -p efi:=${NANO_WORLDDIR}/boot/boot1.efifat \
314                         -p freebsd-boot:=${NAANO_WORLDDIR}/boot/gptboot \
315                         -p ${p3}:=${NANO_LOG}/_.p3 \
316                         -p ${p4}:=${NANO_LOG}/_.p4 \
317                         -o ${out}
318                 ;;
319         powerpc64-ibm)
320                 # A lie to make the boot loader work, it boots the first BSD partition
321                 # it finds, regardless of the active flag.
322                 s2=fat16b
323                 # boot image is on a special partition, ala std-embedded, but that
324                 # partition isn't FAT with special files, but a copy of the boot
325                 # loader itself.
326                 mkimg -a 1 ${fmtarg} -s mbr -p prepboot:=${NANO_LOG}/_.s1 \
327                         -p ${s2}:=${NANO_LOG}/_.s2 \
328                         -p ${s3}:=${NANO_LOG}/_.s3a \
329                         -o ${out}
330                 ;;
331         esac
332         rm -f ${out}.xz
333         xz -9 --keep ${out}
334         ) > ${NANO_LOG}/_.di 2>&1
335 )
336
337 die( ) {
338         echo "$*"
339         exit 1
340 }
341
342 # Automatically include the packaging port here so it is always first so it
343 # builds the port and adds the package so we can add other packages.
344 #XXX Doesn't work for cross build, so punting until I can integreate qemu-static
345 #XXX or poudere, both of which require priv'd execution. Or qemu-system, which
346 #XXX is super, super slow.
347 #add_port ports-mgmt/pkg
348 #add_port security/sudo
349 #add_port ftp/curl
350
351 rp=$(realpath ${NANO_OBJ}/)
352 __a=`mount | grep ${rp} | awk '{print length($3), $3;}' | sort -rn | awk '{$1=""; print;}'`
353 if [ -n "$__a" ]; then
354     echo "unmounting $__a"
355     umount $__a
356 fi
357
358 if [ "$DEBUG" = 1 ]; then
359         DEBUG_BUILD="
360 DEBUG_FLAGS=            -g
361 "
362 else
363         DEBUG_INSTALL="
364 INSTALL_NODEBUG=        t
365 "
366 fi
367
368 CONF_INSTALL="$CONF_BUILD
369 ${DEBUG_BUILD}
370 "
371 CONF_INSTALL="$CONF_INSTALL
372 ${DEBUG_INSTALL}
373 "
374
375 if [ "${NANO_PACKAGE_ONLY}" -eq 1 ]; then
376         CONF_INSTALL="${CONF_INSTALL}
377 ${PKG_ONLY_MAKE_CONF}
378 "
379         echo "Automatically building a thin image with packages"
380 else
381         echo "Automatically building a * * F A T * * image so we can build ports"
382 fi
383
384 VARS="MASTER_SITE_BACKUP MASTER_SITE_OVERRIDE PACKAGEROOT PACKAGESITE"
385
386 for var in $VARS; do
387         val=$(eval echo "\$$var")
388         if [ -n "$val" ]; then
389                 CONF_INSTALL="${CONF_INSTALL}
390 $var=$val"
391         fi
392 done
393
394 typical_embedded ( ) (
395         # Need to create rc.conf before we copy over /etc to /conf/base/etc
396         # so now's a good time.
397
398         local rc=${NANO_WORLDDIR}/etc/rc.conf
399
400         echo "hostname=nanobsd-${NANO_NAME}" > $rc
401         echo "growfs_enable=YES" >> $rc
402         echo "growfs_type=nanobsd-pingpong" >> $rc
403         echo "ntpdate_enable=YES" >> $rc
404         echo "ifconfig_DEFAULT=DHCP" >> $rc
405         echo "ntpdate_hosts='0.freebsd.pool.ntp.org 1.freebsd.pool.ntp.org'" >> $rc
406         # Make sure that firstboot scripts run so growfs works.
407         # Note: still some issues remvoing this XXX
408         touch ${NANO_WORLDDIR}/firstboot
409 )
410 customize_cmd typical_embedded
411
412 fix_pkg ( ) (
413         chdir ${NANO_WORLDDIR}
414         mkdir -p pkg
415         mkdir -p pkg/db
416         mkdir -p pkg/cache
417         mkdir -p pkg/tmp                # Needed for pkg bootstrap
418         mkdir -p usr/local/etc          # Will get moved to local/etc
419         (
420         echo 'PKG_DBDIR = "/pkg/db"'
421         echo 'PKG_CACHEDIR = "/pkg/cache"'
422         echo 'DEFAULT_ALWAYS_YES = "yes"'
423         echo 'ASSUME_ALWAYS_YES = "yes"'
424         ) >> usr/local/etc/pkg.conf
425         [ -z ${NANO_NOPRIV_BUILD} ] || (
426         echo "./pkg type=dir uname=root gname=wheel mode=0755"
427         echo "./pkg/cache type=dir uname=root gname=wheel mode=0755"
428         echo "./pkg/db type=dir uname=root gname=wheel mode=0755"
429         echo "./pkg/tmp type=dir uname=root gname=wheel mode=0755"
430         ) >> ${NANO_METALOG}
431 )
432 customize_cmd fix_pkg
433
434 save_build ( ) (
435         VERSION_FILE=${NANO_WORLDDIR}/etc/version
436         if [ "${SVNREVISION}" = "${REVISION}" ]; then
437                 echo "${NANO_NAME}" > "${VERSION_FILE}"
438         else
439                 echo "${NANO_NAME} (${SVNREVISION})" > "${VERSION_FILE}"
440         fi
441 )
442 customize_cmd save_build
443
444 shrink_md_fbsize ( ) (
445         # We have a lot of little files on our memory disks. Let's decrease
446         # the block and frag size to fit more little files on them (this
447         # halves our space requirement by ~50% on /etc and /var on 8.x --
448         # and gives us more back on 9.x as the default block and frag size
449         # are 4 times larger).
450         sed -i '' -e 's,-S -i 4096,-S -i 4096 -b 4096 -f 512,' \
451                 ${NANO_WORLDDIR}/etc/rc.initdiskless
452 )
453 customize_cmd shrink_md_fbsize
454
455 customize_cmd cust_comconsole
456
457 dos_boot_part ( ) (
458         local d=/usr/local/share/u-boot/${NANO_BOOT_PKG}
459         local f=${NANO_FAT_DIR}
460
461         # For now, just copy all the files. However, for iMX6 and Allwinner,
462         # we'll need to put a special boot block at a fixed location
463         # on the disk as well.
464         rm -rf $f
465         mkdir $f
466         chdir $f
467         cp ${d}/* .
468
469         # Also copy ubldr. u-boot will load it and it will load the kernel
470         # from the ufs partition
471         cp ${NANO_WORLDDIR}/boot/ubldr .
472         cp ${NANO_WORLDDIR}/boot/ubldr.bin .
473
474         # We have to touch the saveenv file
475         touch uEnv.txt
476
477         # Now we need to copy over dtb files from the build.
478         cp ${NANO_WORLDDIR}/boot/dtb/*.dtb .
479 )
480
481 if [ -n "$NANO_BOOT_PKG" ]; then
482         if [ ! -d ${d} ]; then
483                 echo ${NANO_BOOT_PKG} not installed. Sadly, it must be.
484                 exit 1
485         fi
486         if [ ! -x /usr/local/bin/mcopy ]; then
487                 echo mtools not installed. Sadly, we gotta have it.
488                 exit 1
489         fi
490         customize_cmd dos_boot_part
491 fi
492
493 product_custom ( ) (
494         # not quie ready to tweak these in nopriv build
495         if [ -z ${NANO_NOPRIV_BUILD} ]; then
496                 # Last second tweaks -- generally not needed
497                 chown -R root:wheel ${NANO_WORLDDIR}/root
498                 chmod 0755 ${NANO_WORLDDIR}/root/*
499                 chmod 0755 ${NANO_WORLDDIR}/*
500                 chown -R root:wheel ${NANO_WORLDDIR}/etc
501                 chown -R root:wheel ${NANO_WORLDDIR}/boot
502                 chown root:wheel ${NANO_WORLDDIR}/
503                 chown root:wheel ${NANO_WORLDDIR}/usr
504         fi
505 )
506 late_customize_cmd product_custom
507
508 #
509 # Convenience routines to bring up many settings for standard environments
510 #
511
512 #
513 # For each architecture, we have a standard set of settings to the extent
514 # it makes sense. For architectures that don't have a standard environment
515 # cfg files need to either define a lot of settings, provide their own disk
516 # imaging, or set which of the variants we support. No subshells, since we
517 # set global variables
518 #
519
520 std_aarch64 ( ) {
521 }
522
523 std_amd64 ( ) {
524         std_i386
525 }
526
527 std_arm ( ) {
528 }
529
530 std_armeb ( ) {
531         NANO_ENDIAN=big
532 }
533
534 std_armv6 ( ) {
535 }
536
537 std_i386 ( ) {
538         # Default values, if not overridden in .cfg file
539         : ${NANO_KERNEL:=GENERIC}
540         : ${NANO_DRIVE:=ada0}
541         : ${NANO_LAYOUT:=std-x86}
542         : ${NANO_BOOT_MBR:=${NANO_WORLDDIR}/boot/boot0sio}
543         : ${NANO_BOOT_BSD:=${NANO_WORLDDIR}/boot/boot}
544 }
545
546 std_mips ( ) {
547         NANO_ENDIAN=big
548 }
549
550 std_mipsel ( ) {
551 }
552
553 std_mips64 ( ) {
554         NANO_ENDIAN=big
555 }
556
557 std_mips64el ( ) {
558 }
559
560 std_powerpc ( ) {
561         NANO_ENDIAN=big
562 }
563
564 std_powerpc64 ( ) {
565         NANO_LAYOUT=powerpc64-ibm
566         NANO_ENDIAN=big
567 }
568
569 std_sparc64 ( ) {
570         NANO_ENDIAN=big
571 }
572
573 #
574 # QEMU settings for the standard environments
575 #
576 qemu_env ( ) {
577
578         NANO_DISKIMAGE_FORMAT=qcow2
579 }
580
581 # other standard environments will go here
582
583 eval std_${NANO_ARCH}
584
585 # Slice 1: FAT for ROM loading bootstrap
586 # Slice 2: Config partition
587 # Slice 3: FreeBSD partition (sized exactly)
588 # Slice 4: FreeBSD partition (empty)
589 # on first boot, we resize slice 3 & 4 to be 1/2 of what's
590 # left over on the SD card after slice 1 and 2 are taken
591 # off the top. We also resize the 'a' partion on first boot
592 # to the size of the partition for the ping/pong upgrade.
593 # This feature needs support in the rc.d bootup script.
594 #
595 # Ideally, we'd not put BSD labels on the MBR disks.
596 # However, we can't boot off raw MBR disks. First,
597 # boot2 defaults to 'a' partition, and freaks out
598 # unless you tell it to use 'c'. But even if we
599 # hack that, then /boot/loader wants to load off
600 # of 'c' partition. If you fix that, then we'll
601 # try to mount root, but sanity checks prevent
602 # slices from working.
603 #
604
605 : ${NANO_ENDIAN:=little}        # make -V something to figure it out?
606 : ${NANO_LAYOUT:=std-embedded}
607 : ${NANO_MAKEFS_UFS:=makefs -t ffs -B ${NANO_ENDIAN}}
608 : ${NANO_DISK_SCHEME:=mbr}      # No others really supported ATM (well, gpt)
609 case ${NANO_LAYOUT} in
610 std-embedded)
611         NANO_SLICE_FAT=s1
612         NANO_SLICE_CFG=s2
613         NANO_SLICE_ROOT=s3
614         NANO_SLICE_ALTROOT=s4
615         ;;
616 std-x86)
617         NANO_SLICE_CFG=s1
618         NANO_SLICE_ROOT=s2
619         NANO_SLICE_ALTROOT=s3
620         ;;
621 powerpc64-ibm)
622         NANO_SLICE_PPCBOOT=s1
623         NANO_SLICE_CFG=s2
624         NANO_SLICE_ROOT=s3
625         NANO_SLICE_ALTROOT=s4
626         ;;
627 powerpc64-apple)
628         echo Not yet
629         exit 1
630         ;;
631 std-uefi)
632         NANO_SLICE_UEFI=s1
633         NANO_SLICE_CFG=s2
634         NANO_SLICE_ROOT=s3
635         NANO_SLICE_ALTROOT=s4
636         ;;
637 std-uefi-bios)
638         NANO_DISK_SCHEME=gpt
639         NANO_SLICE_UEFI=p1
640         NANO_SLICE_BOOT=p2
641         NANO_SLICE_CFG=p3
642         NANO_SLICE_ROOT=p4
643         NANO_SLICE_ALTROOT=p5
644         # override root name
645         NANO_ROOT=${NANO_SLICE_ROOT}
646         NANO_ALTROOT=${NANO_SLICE_ALTROOT}
647         ;;
648 *)
649         echo Unknown Layout ${NANO_LAYOUT}
650         exit 1
651         ;;
652 esac
653
654
655 NANO_SLICE_DATA=                # Not included
656
657 # Each major disk scheme has its own routine. Generally
658 # this is for mbr, gpt, etc. These are generally are widely
659 # shared, but some specialized formats won't be shared.
660 create_diskimage ( ) (
661         eval create_diskimage_${NANO_DISK_SCHEME}
662 )