Author: kevans Date: Sun Feb 11 20:58:00 2018 New Revision: 329140 URL: https://svnweb.freebsd.org/changeset/base/329140
Log: MFC Loader Fixes 2017q4p6: r324649,r324650,r324651,r324652,r324653,r324654, r324700,r324702,r324709,r324717,r324719,r324841,r324842,r324843,r324845, r324850,r324876,r324877,r324878,r324879,r324880,r324881,r324883,r324980, r324981,r324982,r324995,r325014,r325093,r325094,r325114,r325170,r325171, r325172,r325173,r325174,r325175,r325176,r325248,r325286,r325310,r325332, r325338,r325339,r325376,r325377,r325379,r325380,r325382,r325478,r325479, r325480,r325482,r325483,r325484,r325485,r325556,r325641,r325681,r325685, r325686,r325687,r325688,r325689,r325690,r325691,r325692,r325693,r325694, r325743,r325744,r325748,r325775,r325779,r325780 r324649: Move common/Makefile.inc to sys/boot/loader.mk. r324650: tweak style r324651: create defs.mk for common definitions r324652: Move all the ficl common code into ficl.mk r324653: LOADER_foo_SUPPORTED r324654: Explicitly inlcude SYSDIR in the include path r324700: loader: initialize dv_cleanup in md.c to eliminate clang warning r324702: We need to include disk.o in libuboot.a when we're building with support for disk access. r324709: Revert "Unify boot1 with loader" change r324646 r324717: libsa/ip.c: misplaced comment, ip_v is half char, not ip_p r324719: libsa/ip: stop read loop on bad fragments r324841: Use BOOTDIR more consistently in defs.mk rather than repeat sys/boot. r324842: Introduce BOOTOBJ: The top level object directory for the boot tree r324843: Stopgap fix to the mistmatch between LOADER_GELI_SUPPORT and LOADER_NO_GELI_SUPPORT. r324845: Use BOOTOBJ and BOOTDIR to find geli includes and libraries. r324850: Define LIBSA32 to LIBSA on i386 to fix build. r324876: Move fdt and uboot defines into common uboot.mk. r324877: End source directories with SRC rather than a hodgepodge of names r324878: Make at91 boot loader compile again. r324879: Prefer SRCTOP paths for bits we're grabbing from libc. r324880: Use BOOTSRC here. r324881: Use SYSDIR instead of ${.CURDIR}/../..<etc>/sys. r324883: Use preferred defined paths, rather than relative paths in fdt. r324980: Use BOOTDIR consistently. r324981: Move BINDIR definition to defs.mk, and override where it isn't /boot r324982: Remove sys/boot/arm/at91 and ixp425 r324995: loader.efi: Make framebuffer commands available for arm64 r325014: Add a 'place holder' arm struct efi_fb until a real one comes r325093: Define new EFI variables r325094: Cleanup non-arch Makefiles r325114: Use defs.mk defins in most MD code r325170: Use defs.mk values for userboot r325171: Use defs.mk name and prefer bsd.init.mk r325172: Remove the -nostdlib stuff I added. Instead, fix LDFLAGS to be honored correctly with the new Makefile.inc include order. r325173: We don't need to build a special ficl for userboot. r325174: Minor cleanup r325175: For amd64, compile both zfs and zfs32 libraries. r325176: Actually add zfs32/Makefile r325248: loader ptblread() is broken with >512B sectors r325286: efipart_strategy is using wrong offset with >512B sectors r325310: zfs.c:vdev_read() needs to be careful about large sectors r325332: loader: re-enable gzip support for x86 r325338: loader: fix BOOTSRC -> BOOTOBJ in a library path r325339: This used to have bzip2 support too. r325376: WIP: centralize machine links r325377: mostly libsa r325379: Revert "mostly libsa" r325380: Revert "WIP: centralize machine links" r325382: Cleanup stray libstand names to be libsa names. r325478: Powerpc is a 32-bit boot loader. r325479: Define LIBFICL32 to be libficl.a on i386 and libficl32.a on amd64. r325480: Use DO32 for all the places that we need to flag we're building a 32-bit version of a library. r325482: Move machine and other link creation to defs.mk r325483: MACHINE can never be powerpc64, so cleanup code that thinks it can. r325484: Prefer bsd.init.mk to src.opts.mk r325485: Centralize all 32-bit builds on 64-bit platform stuff. r325556: loader: set options before including bsd.init.mk r325641: loader.efi: efi_devpath_is_prefix should return bool r325681: boot1: avoid using NULL device path r325685: libsa32 isn't needed for i386. It's already a 32-bit platform. r325686: Simplify this if to a direct assignment. r325687: Remove all the empty help files from the powerpc build. r325688: FDT support doesn't make sense for ps3, remove it. r325689: Remove LOADER_FDT_SUPPORT as a Makefile variable. r325690: Remove LOADER_ZFS_SUPPORT as a Makefile variable r325691: Remove useless PNP define here. r325692: Replace LOADER_FIREWIRE_SUPPORT variable r325693: Move LOADER_{NO,}_GELI_SUPPORT to MK_LOADER_GELI r325694: Install the 4th files in sys/boot/forth instead of each loader r325743: Make sure the proper loader.rc gets installed. r325744: boot1: also check for NULL device r325748: Use proper include file. r325775: Add loader.conf to the list of files that are MD. r325779: Add /boot/dts to the list of default modules. r325780: Don't add /boot/dt*s* but /boot/dt*b*. Stupid think-o. Added: stable/11/sys/boot/arm/loader/ - copied from r325775, head/sys/boot/arm/loader/ stable/11/sys/boot/defs.mk - copied, changed from r324654, head/sys/boot/defs.mk stable/11/sys/boot/efi/boot1/boot_module.h - copied unchanged from r324709, head/sys/boot/efi/boot1/boot_module.h stable/11/sys/boot/efi/boot1/ufs_module.c - copied unchanged from r324709, head/sys/boot/efi/boot1/ufs_module.c stable/11/sys/boot/efi/boot1/zfs_module.c - copied unchanged from r324709, head/sys/boot/efi/boot1/zfs_module.c stable/11/sys/boot/efi/loader/efi_main.c - copied unchanged from r324709, head/sys/boot/efi/loader/efi_main.c stable/11/sys/boot/efi/loader/framebuffer.c - copied unchanged from r324995, head/sys/boot/efi/loader/framebuffer.c stable/11/sys/boot/efi/loader/framebuffer.h - copied unchanged from r324995, head/sys/boot/efi/loader/framebuffer.h stable/11/sys/boot/fdt.mk - copied unchanged from r325689, head/sys/boot/fdt.mk stable/11/sys/boot/loader.mk - copied, changed from r329139, stable/11/sys/boot/common/Makefile.inc stable/11/sys/boot/uboot.mk - copied, changed from r324881, head/sys/boot/uboot.mk stable/11/sys/boot/zfs32/ - copied from r325176, head/sys/boot/zfs32/ stable/11/tools/build/options/WITHOUT_LOADER_GEIL - copied unchanged from r325693, head/tools/build/options/WITHOUT_LOADER_GEIL stable/11/tools/build/options/WITH_LOADER_FIREWIRE - copied unchanged from r325692, head/tools/build/options/WITH_LOADER_FIREWIRE Replaced: stable/11/sys/boot/arm/loader/loader.conf - copied unchanged from r329139, stable/11/sys/boot/arm/uboot/loader.conf Deleted: stable/11/sys/boot/arm/at91/Makefile stable/11/sys/boot/arm/at91/Makefile.inc stable/11/sys/boot/arm/at91/boot0/Makefile stable/11/sys/boot/arm/at91/boot0/README stable/11/sys/boot/arm/at91/boot0/linker.cfg stable/11/sys/boot/arm/at91/boot0/main.c stable/11/sys/boot/arm/at91/boot0iic/Makefile stable/11/sys/boot/arm/at91/boot0iic/main.c stable/11/sys/boot/arm/at91/boot0spi/Makefile stable/11/sys/boot/arm/at91/boot0spi/main.c stable/11/sys/boot/arm/at91/boot2/Makefile stable/11/sys/boot/arm/at91/boot2/board.h stable/11/sys/boot/arm/at91/boot2/boot2.c stable/11/sys/boot/arm/at91/boot2/bwct_board.c stable/11/sys/boot/arm/at91/boot2/centipad_board.c stable/11/sys/boot/arm/at91/boot2/kb920x_board.c stable/11/sys/boot/arm/at91/bootiic/Makefile stable/11/sys/boot/arm/at91/bootiic/README stable/11/sys/boot/arm/at91/bootiic/env_vars.c stable/11/sys/boot/arm/at91/bootiic/env_vars.h stable/11/sys/boot/arm/at91/bootiic/loader_prompt.c stable/11/sys/boot/arm/at91/bootiic/loader_prompt.h stable/11/sys/boot/arm/at91/bootiic/main.c stable/11/sys/boot/arm/at91/bootspi/Makefile stable/11/sys/boot/arm/at91/bootspi/README stable/11/sys/boot/arm/at91/bootspi/ee.c stable/11/sys/boot/arm/at91/bootspi/ee.h stable/11/sys/boot/arm/at91/bootspi/env_vars.c stable/11/sys/boot/arm/at91/bootspi/env_vars.h stable/11/sys/boot/arm/at91/bootspi/loader_prompt.c stable/11/sys/boot/arm/at91/bootspi/loader_prompt.h stable/11/sys/boot/arm/at91/bootspi/main.c stable/11/sys/boot/arm/at91/libat91/Makefile stable/11/sys/boot/arm/at91/libat91/arm_init.S stable/11/sys/boot/arm/at91/libat91/at91rm9200.h stable/11/sys/boot/arm/at91/libat91/at91rm9200_lowlevel.c stable/11/sys/boot/arm/at91/libat91/at91rm9200_lowlevel.h stable/11/sys/boot/arm/at91/libat91/delay.c stable/11/sys/boot/arm/at91/libat91/eeprom.c stable/11/sys/boot/arm/at91/libat91/emac.c stable/11/sys/boot/arm/at91/libat91/emac.h stable/11/sys/boot/arm/at91/libat91/emac_init.c stable/11/sys/boot/arm/at91/libat91/getc.c stable/11/sys/boot/arm/at91/libat91/lib.h stable/11/sys/boot/arm/at91/libat91/lib_AT91RM9200.h stable/11/sys/boot/arm/at91/libat91/mci_device.h stable/11/sys/boot/arm/at91/libat91/memcmp.c stable/11/sys/boot/arm/at91/libat91/memcpy.c stable/11/sys/boot/arm/at91/libat91/memset.c stable/11/sys/boot/arm/at91/libat91/p_string.c stable/11/sys/boot/arm/at91/libat91/printf.c stable/11/sys/boot/arm/at91/libat91/putchar.c stable/11/sys/boot/arm/at91/libat91/reset.c stable/11/sys/boot/arm/at91/libat91/sd-card.c stable/11/sys/boot/arm/at91/libat91/sd-card.h stable/11/sys/boot/arm/at91/libat91/spi_flash.c stable/11/sys/boot/arm/at91/libat91/spi_flash.h stable/11/sys/boot/arm/at91/libat91/strcmp.c stable/11/sys/boot/arm/at91/libat91/strcpy.c stable/11/sys/boot/arm/at91/libat91/strcvt.c stable/11/sys/boot/arm/at91/libat91/strlen.c stable/11/sys/boot/arm/at91/libat91/tag_list.c stable/11/sys/boot/arm/at91/libat91/tag_list.h stable/11/sys/boot/arm/at91/libat91/xmodem.c stable/11/sys/boot/arm/at91/linker.cfg stable/11/sys/boot/arm/ixp425/Makefile.inc stable/11/sys/boot/arm/ixp425/boot2/Makefile stable/11/sys/boot/arm/ixp425/boot2/arm_init.S stable/11/sys/boot/arm/ixp425/boot2/boot2.c stable/11/sys/boot/arm/ixp425/boot2/cf_ata.h stable/11/sys/boot/arm/ixp425/boot2/ixp425_board.c stable/11/sys/boot/arm/ixp425/boot2/lib.h stable/11/sys/boot/arm/uboot/loader.conf stable/11/sys/boot/common/Makefile.inc stable/11/sys/boot/efi/libefi/efi_main.c stable/11/sys/boot/efi/loader/arch/amd64/framebuffer.c stable/11/sys/boot/efi/loader/arch/amd64/framebuffer.h stable/11/sys/boot/forth/Makefile.inc stable/11/sys/boot/powerpc/kboot/help.kboot stable/11/sys/boot/powerpc/ofw/help.ofw stable/11/sys/boot/powerpc/ps3/help.ps3 stable/11/sys/boot/powerpc/uboot/help.uboot stable/11/sys/boot/uboot/common/Makefile.inc stable/11/sys/boot/userboot/ficl/Makefile stable/11/sys/boot/userboot/ficl/Makefile.depend stable/11/sys/boot/userboot/zfs/Makefile stable/11/sys/boot/userboot/zfs/Makefile.depend Modified: stable/11/UPDATING stable/11/share/mk/src.opts.mk stable/11/sys/arm/include/metadata.h stable/11/sys/arm64/include/metadata.h stable/11/sys/boot/Makefile stable/11/sys/boot/Makefile.amd64 stable/11/sys/boot/Makefile.arm stable/11/sys/boot/Makefile.arm64 stable/11/sys/boot/Makefile.i386 stable/11/sys/boot/Makefile.inc stable/11/sys/boot/Makefile.powerpc stable/11/sys/boot/Makefile.sparc64 stable/11/sys/boot/arm/uboot/Makefile stable/11/sys/boot/common/disk.c stable/11/sys/boot/common/md.c stable/11/sys/boot/efi/Makefile stable/11/sys/boot/efi/Makefile.inc stable/11/sys/boot/efi/boot1/Makefile stable/11/sys/boot/efi/boot1/boot1.c stable/11/sys/boot/efi/fdt/Makefile stable/11/sys/boot/efi/include/efilib.h stable/11/sys/boot/efi/libefi/Makefile stable/11/sys/boot/efi/libefi/devpath.c stable/11/sys/boot/efi/libefi/efipart.c stable/11/sys/boot/efi/loader/Makefile stable/11/sys/boot/efi/loader/arch/amd64/Makefile.inc stable/11/sys/boot/efi/loader/arch/arm/Makefile.inc stable/11/sys/boot/efi/loader/arch/arm64/Makefile.inc stable/11/sys/boot/efi/loader/arch/i386/Makefile.inc stable/11/sys/boot/efi/loader/bootinfo.c stable/11/sys/boot/fdt/Makefile stable/11/sys/boot/ficl.mk stable/11/sys/boot/ficl/Makefile stable/11/sys/boot/ficl32/Makefile stable/11/sys/boot/forth/Makefile stable/11/sys/boot/forth/loader.conf stable/11/sys/boot/geli/Makefile stable/11/sys/boot/i386/Makefile stable/11/sys/boot/i386/Makefile.inc stable/11/sys/boot/i386/boot0/Makefile stable/11/sys/boot/i386/boot2/Makefile stable/11/sys/boot/i386/btx/btx/Makefile stable/11/sys/boot/i386/btx/btxldr/Makefile stable/11/sys/boot/i386/btx/lib/Makefile stable/11/sys/boot/i386/cdboot/Makefile stable/11/sys/boot/i386/gptboot/Makefile stable/11/sys/boot/i386/gptzfsboot/Makefile stable/11/sys/boot/i386/kgzldr/Makefile stable/11/sys/boot/i386/libfirewire/Makefile stable/11/sys/boot/i386/libi386/Makefile stable/11/sys/boot/i386/loader/Makefile stable/11/sys/boot/i386/mbr/Makefile stable/11/sys/boot/i386/pmbr/Makefile stable/11/sys/boot/i386/pxeldr/Makefile stable/11/sys/boot/i386/zfsboot/Makefile stable/11/sys/boot/i386/zfsloader/Makefile stable/11/sys/boot/libsa/Makefile stable/11/sys/boot/libsa/ip.c stable/11/sys/boot/libsa32/Makefile stable/11/sys/boot/man/Makefile stable/11/sys/boot/mips/beri/Makefile.inc stable/11/sys/boot/mips/beri/boot2/Makefile stable/11/sys/boot/mips/beri/loader/Makefile stable/11/sys/boot/mips/uboot/Makefile stable/11/sys/boot/ofw/Makefile.inc stable/11/sys/boot/ofw/libofw/Makefile stable/11/sys/boot/powerpc/Makefile stable/11/sys/boot/powerpc/Makefile.inc stable/11/sys/boot/powerpc/boot1.chrp/Makefile stable/11/sys/boot/powerpc/kboot/Makefile stable/11/sys/boot/powerpc/ofw/Makefile stable/11/sys/boot/powerpc/ps3/Makefile stable/11/sys/boot/powerpc/uboot/Makefile stable/11/sys/boot/sparc64/Makefile stable/11/sys/boot/sparc64/Makefile.inc stable/11/sys/boot/sparc64/boot1/Makefile stable/11/sys/boot/sparc64/loader/Makefile stable/11/sys/boot/sparc64/zfsloader/Makefile stable/11/sys/boot/uboot/Makefile stable/11/sys/boot/uboot/Makefile.inc stable/11/sys/boot/uboot/fdt/Makefile stable/11/sys/boot/uboot/lib/Makefile stable/11/sys/boot/userboot/Makefile stable/11/sys/boot/userboot/test/Makefile stable/11/sys/boot/userboot/test/test.c stable/11/sys/boot/userboot/userboot/Makefile stable/11/sys/boot/zfs/Makefile stable/11/sys/boot/zfs/zfs.c stable/11/sys/boot/zfs32/Makefile stable/11/tools/boot/universe.sh Directory Properties: stable/11/ (props changed) Modified: stable/11/UPDATING ============================================================================== --- stable/11/UPDATING Sun Feb 11 20:47:38 2018 (r329139) +++ stable/11/UPDATING Sun Feb 11 20:58:00 2018 (r329140) @@ -16,6 +16,11 @@ from older versions of FreeBSD, try WITHOUT_CLANG and the tip of head, and then rebuild without this option. The bootstrap process from older version of current across the gcc/clang cutover is a bit fragile. +20180211: + The LOADER_FIREWIRE_SUPPORT build variable as been renamed to + WITH/OUT_LOADER_FIREWIRE. LOADER_{NO_,}GELI_SUPPORT has been renamed + to WITH/OUT_LOADER_GELI. + 20180210: The geli password typed at boot is now hidden. To restore the previous behavior, see geli(8) for configuration options. Modified: stable/11/share/mk/src.opts.mk ============================================================================== --- stable/11/share/mk/src.opts.mk Sun Feb 11 20:47:38 2018 (r329139) +++ stable/11/share/mk/src.opts.mk Sun Feb 11 20:58:00 2018 (r329140) @@ -123,6 +123,7 @@ __DEFAULT_YES_OPTIONS = \ LIB32 \ LIBPTHREAD \ LIBTHR \ + LOADER_GELI \ LOCALES \ LOCATE \ LPR \ @@ -188,6 +189,7 @@ __DEFAULT_NO_OPTIONS = \ HESIOD \ LIBSOFT \ LINT \ + LOADER_FIREWIRE \ LOADER_FORCE_LE \ NAND \ OFED \ Modified: stable/11/sys/arm/include/metadata.h ============================================================================== --- stable/11/sys/arm/include/metadata.h Sun Feb 11 20:47:38 2018 (r329139) +++ stable/11/sys/arm/include/metadata.h Sun Feb 11 20:58:00 2018 (r329140) @@ -39,4 +39,19 @@ struct efi_map_header { uint32_t descriptor_version; }; +/* + * Placeholder for now + */ +struct efi_fb { + uint64_t fb_addr; + uint64_t fb_size; + uint32_t fb_height; + uint32_t fb_width; + uint32_t fb_stride; + uint32_t fb_mask_red; + uint32_t fb_mask_green; + uint32_t fb_mask_blue; + uint32_t fb_mask_reserved; +}; + #endif /* !_MACHINE_METADATA_H_ */ Modified: stable/11/sys/arm64/include/metadata.h ============================================================================== --- stable/11/sys/arm64/include/metadata.h Sun Feb 11 20:47:38 2018 (r329139) +++ stable/11/sys/arm64/include/metadata.h Sun Feb 11 20:58:00 2018 (r329140) @@ -31,11 +31,24 @@ #define MODINFOMD_EFI_MAP 0x1001 #define MODINFOMD_DTBP 0x1002 +#define MODINFOMD_EFI_FB 0x1003 struct efi_map_header { size_t memory_size; size_t descriptor_size; uint32_t descriptor_version; +}; + +struct efi_fb { + uint64_t fb_addr; + uint64_t fb_size; + uint32_t fb_height; + uint32_t fb_width; + uint32_t fb_stride; + uint32_t fb_mask_red; + uint32_t fb_mask_green; + uint32_t fb_mask_blue; + uint32_t fb_mask_reserved; }; #endif /* !_MACHINE_METADATA_H_ */ Modified: stable/11/sys/boot/Makefile ============================================================================== --- stable/11/sys/boot/Makefile Sun Feb 11 20:47:38 2018 (r329139) +++ stable/11/sys/boot/Makefile Sun Feb 11 20:58:00 2018 (r329140) @@ -13,10 +13,8 @@ SUBDIR+= man .include <bsd.arch.inc.mk> -# Pick the machine-dependent subdir based on the target architecture. -ADIR= ${MACHINE:S/powerpc64/powerpc/} -.if exists(${.CURDIR}/${ADIR}/.) -SUBDIR+= ${ADIR} +.if exists(${.CURDIR}/${MACHINE}/.) +SUBDIR+= ${MACHINE} .endif .include <bsd.subdir.mk> Modified: stable/11/sys/boot/Makefile.amd64 ============================================================================== --- stable/11/sys/boot/Makefile.amd64 Sun Feb 11 20:47:38 2018 (r329139) +++ stable/11/sys/boot/Makefile.amd64 Sun Feb 11 20:58:00 2018 (r329140) @@ -1,16 +1,18 @@ # $FreeBSD$ -SUBDIR+= efi SUBDIR+= libsa32 -SUBDIR+= zfs -SUBDIR+= userboot - -.if !defined(LOADER_NO_GELI_SUPPORT) -SUBDIR+= geli +.if ${MK_ZFS} != "no" +SUBDIR+= zfs zfs32 .endif - .if ${MK_FORTH} != "no" SUBDIR+= ficl32 +.endif + +SUBDIR+= efi +SUBDIR+= userboot + +.if ${LOADER_GELI_SUPPORT:Uyes} == "yes" +SUBDIR+= geli .endif SUBDIR+= i386 Modified: stable/11/sys/boot/Makefile.arm ============================================================================== --- stable/11/sys/boot/Makefile.arm Sun Feb 11 20:47:38 2018 (r329139) +++ stable/11/sys/boot/Makefile.arm Sun Feb 11 20:58:00 2018 (r329140) @@ -3,5 +3,8 @@ .if ${MK_FDT} != "no" SUBDIR+= fdt .endif +.if ${MK_ZFS} != "no" +SUBDIR+= zfs +.endif SUBDIR+= efi uboot Modified: stable/11/sys/boot/Makefile.arm64 ============================================================================== --- stable/11/sys/boot/Makefile.arm64 Sun Feb 11 20:47:38 2018 (r329139) +++ stable/11/sys/boot/Makefile.arm64 Sun Feb 11 20:58:00 2018 (r329140) @@ -3,5 +3,8 @@ .if ${MK_FDT} != "no" SUBDIR+= fdt .endif +.if ${MK_ZFS} != "no" +SUBDIR+= zfs +.endif SUBDIR+= efi Modified: stable/11/sys/boot/Makefile.i386 ============================================================================== --- stable/11/sys/boot/Makefile.i386 Sun Feb 11 20:47:38 2018 (r329139) +++ stable/11/sys/boot/Makefile.i386 Sun Feb 11 20:58:00 2018 (r329140) @@ -1,9 +1,10 @@ # $FreeBSD$ -SUBDIR+= efi -SUBDIR+= libsa32 -SUBDIR+= zfs - -.if !defined(LOADER_NO_GELI_SUPPORT) +.if ${LOADER_GELI_SUPPORT:Uyes} == "yes" SUBDIR+= geli .endif +.if ${MK_ZFS} != "no" +SUBDIR+= zfs +.endif + +SUBDIR+= efi Modified: stable/11/sys/boot/Makefile.inc ============================================================================== --- stable/11/sys/boot/Makefile.inc Sun Feb 11 20:47:38 2018 (r329139) +++ stable/11/sys/boot/Makefile.inc Sun Feb 11 20:58:00 2018 (r329140) @@ -1,15 +1,9 @@ # $FreeBSD$ -.include <src.opts.mk> +.include "defs.mk" .if !defined(__BOOT_MAKEFILE_INC__) __BOOT_MAKEFILE_INC__=${MFILE} - -SASRC=${SRCTOP}/sys/boot/libsa -# Normal Standalone library -LIBSA=${OBJTOP}/sys/boot/libsa/libsa.a -# Standalone library compiled for 32-bit version of the processor -LIBSA32=${OBJTOP}/sys/boot/libsa32/libsa32.a CFLAGS+=-I${SASRC} Modified: stable/11/sys/boot/Makefile.powerpc ============================================================================== --- stable/11/sys/boot/Makefile.powerpc Sun Feb 11 20:47:38 2018 (r329139) +++ stable/11/sys/boot/Makefile.powerpc Sun Feb 11 20:58:00 2018 (r329140) @@ -4,6 +4,5 @@ SUBDIR+= fdt .endif -SUBDIR+= libsa32 SUBDIR+= ofw SUBDIR+= uboot Modified: stable/11/sys/boot/Makefile.sparc64 ============================================================================== --- stable/11/sys/boot/Makefile.sparc64 Sun Feb 11 20:47:38 2018 (r329139) +++ stable/11/sys/boot/Makefile.sparc64 Sun Feb 11 20:58:00 2018 (r329140) @@ -1,4 +1,6 @@ # $FreeBSD$ SUBDIR+= ofw +.if ${MK_ZFS} != "no" SUBDIR+= zfs +.endif Copied: stable/11/sys/boot/arm/loader/loader.conf (from r329139, stable/11/sys/boot/arm/uboot/loader.conf) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/11/sys/boot/arm/loader/loader.conf Sun Feb 11 20:58:00 2018 (r329140, copy of r329139, stable/11/sys/boot/arm/uboot/loader.conf) @@ -0,0 +1,13 @@ +# This is defaults/loader.conf for ARM, containing defaults for loader(8). +# Do not modify the contents of this file, instead put your customizations +# into /boot/loader.conf or /boot/loader.conf.local +# $FreeBSD$ + +autoboot_delay=10 +bootfile="kernel" # Kernel name (possibly absolute path) +kernel="kernel" # /boot sub-directory containing kernel and modules +loader_conf_files="/boot/loader.conf /boot/loader.conf.local" +module_path="/boot/kernel;/boot/modules;/boot/dtb;/boot/overlays" +nextboot_conf="/boot/nextboot.conf" +nextboot_enable="NO" +verbose_loading="NO" Modified: stable/11/sys/boot/arm/uboot/Makefile ============================================================================== --- stable/11/sys/boot/arm/uboot/Makefile Sun Feb 11 20:47:38 2018 (r329139) +++ stable/11/sys/boot/arm/uboot/Makefile Sun Feb 11 20:58:00 2018 (r329140) @@ -1,11 +1,20 @@ # $FreeBSD$ -.include <src.opts.mk> +LOADER_UFS_SUPPORT?= yes +LOADER_CD9660_SUPPORT?= no +LOADER_MSDOS_SUPPORT?= no +LOADER_EXT2FS_SUPPORT?= no +LOADER_NET_SUPPORT?= yes +LOADER_NFS_SUPPORT?= yes +LOADER_TFTP_SUPPORT?= no +LOADER_GZIP_SUPPORT?= no +LOADER_BZIP2_SUPPORT?= no -FILES= ubldr ubldr.bin +.include <bsd.init.mk> +FILES+= ubldr ubldr.bin + NEWVERSWHAT= "U-Boot loader" ${MACHINE_ARCH} -BINDIR?= /boot INSTALLFLAGS= -b WARNS?= 1 # Address at which ubldr will be loaded. @@ -19,113 +28,26 @@ SRCS= start.S conf.c self_reloc.c vers.c CWARNFLAGS.self_reloc.c+= -Wno-error=maybe-uninitialized .endif -.if !defined(LOADER_NO_DISK_SUPPORT) -LOADER_DISK_SUPPORT?= yes -.else -LOADER_DISK_SUPPORT= no -.endif -LOADER_UFS_SUPPORT?= yes -LOADER_CD9660_SUPPORT?= no -LOADER_EXT2FS_SUPPORT?= no -.if ${MK_NAND} != "no" -LOADER_NANDFS_SUPPORT?= yes -.else -LOADER_NANDFS_SUPPORT?= no -.endif -LOADER_NET_SUPPORT?= yes -LOADER_NFS_SUPPORT?= yes -LOADER_TFTP_SUPPORT?= no -LOADER_GZIP_SUPPORT?= no -LOADER_BZIP2_SUPPORT?= no -.if ${MK_FDT} != "no" -LOADER_FDT_SUPPORT= yes -.else -LOADER_FDT_SUPPORT= no -.endif +HELP_FILES+= help.uboot ${BOOTSRC}/fdt/help.fdt -.if ${LOADER_DISK_SUPPORT} == "yes" -CFLAGS+= -DLOADER_DISK_SUPPORT -.endif -.if ${LOADER_UFS_SUPPORT} == "yes" -CFLAGS+= -DLOADER_UFS_SUPPORT -.endif -.if ${LOADER_CD9660_SUPPORT} == "yes" -CFLAGS+= -DLOADER_CD9660_SUPPORT -.endif -.if ${LOADER_EXT2FS_SUPPORT} == "yes" -CFLAGS+= -DLOADER_EXT2FS_SUPPORT -.endif -.if ${LOADER_NANDFS_SUPPORT} == "yes" -CFLAGS+= -DLOADER_NANDFS_SUPPORT -.endif -.if ${LOADER_GZIP_SUPPORT} == "yes" -CFLAGS+= -DLOADER_GZIP_SUPPORT -.endif -.if ${LOADER_BZIP2_SUPPORT} == "yes" -CFLAGS+= -DLOADER_BZIP2_SUPPORT -.endif -.if ${LOADER_NET_SUPPORT} == "yes" -CFLAGS+= -DLOADER_NET_SUPPORT -.endif -.if ${LOADER_NFS_SUPPORT} == "yes" -CFLAGS+= -DLOADER_NFS_SUPPORT -.endif -.if ${LOADER_TFTP_SUPPORT} == "yes" -CFLAGS+= -DLOADER_TFTP_SUPPORT -.endif -.if ${LOADER_FDT_SUPPORT} == "yes" -CFLAGS+= -I${.CURDIR}/../../fdt -CFLAGS+= -I${.OBJDIR}/../../fdt -CFLAGS+= -DLOADER_FDT_SUPPORT -LIBUBOOT_FDT= ${.OBJDIR}/../../uboot/fdt/libuboot_fdt.a -LIBFDT= ${.OBJDIR}/../../fdt/libfdt.a -.endif - -.if ${MK_FORTH} != "no" -# Enable BootForth -BOOT_FORTH= yes -CFLAGS+= -DBOOT_FORTH -I${.CURDIR}/../../ficl -CFLAGS+= -I${.CURDIR}/../../ficl/arm -LIBFICL= ${.OBJDIR}/../../ficl/libficl.a -.endif - # Always add MI sources -.PATH: ${.CURDIR}/../../common -.include "${.CURDIR}/../../common/Makefile.inc" -CFLAGS+= -I${.CURDIR}/../../common -CFLAGS+= -I. +.include "${BOOTSRC}/loader.mk" -CLEANFILES+= loader.help - CFLAGS+= -ffreestanding -msoft-float LDFLAGS= -nostdlib -static -T ${.CURDIR}/ldscript.${MACHINE_CPUARCH} LDFLAGS+= -Wl,-znotext # Pull in common loader code -.PATH: ${.CURDIR}/../../uboot/common -.include "${.CURDIR}/../../uboot/common/Makefile.inc" -CFLAGS+= -I${.CURDIR}/../../uboot/common +.include "${BOOTSRC}/uboot.mk" -# U-Boot standalone support library -LIBUBOOT= ${.OBJDIR}/../../uboot/lib/libuboot.a -CFLAGS+= -I${.CURDIR}/../../uboot/lib -CFLAGS+= -I${.OBJDIR}/../../uboot/lib - CFLAGS+= -fPIC -# clang doesn't understand %D as a specifier to printf -NO_WERROR.clang= - DPADD= ${LIBFICL} ${LIBUBOOT} ${LIBFDT} ${LIBUBOOT_FDT} ${LIBSA} LDADD= ${LIBFICL} ${LIBUBOOT} ${LIBFDT} ${LIBUBOOT_FDT} ${LIBSA} OBJS+= ${SRCS:N*.h:R:S/$/.o/g} -loader.help: help.common help.uboot ${.CURDIR}/../../fdt/help.fdt - cat ${.ALLSRC} | \ - awk -f ${.CURDIR}/../../common/merge_help.awk > ${.TARGET} - ldscript.abs: echo "UBLDR_LOADADDR = ${UBLDR_LOADADDR};" >${.TARGET} @@ -144,16 +66,5 @@ ubldr.bin: ubldr.pie ${OBJCOPY} -S -O binary ubldr.pie ${.TARGET} CLEANFILES+= ldscript.abs ldscript.pie ubldr ubldr.pie ubldr.bin - -.if !defined(LOADER_ONLY) -.PATH: ${.CURDIR}/../../forth -.include "${.CURDIR}/../../forth/Makefile.inc" - -# Install loader.rc. -FILES+= loader.rc -# Put sample menu.rc on disk but don't enable it by default. -FILES+= menu.rc -FILESNAME_menu.rc= menu.rc.sample -.endif .include <bsd.prog.mk> Modified: stable/11/sys/boot/common/disk.c ============================================================================== --- stable/11/sys/boot/common/disk.c Sun Feb 11 20:47:38 2018 (r329139) +++ stable/11/sys/boot/common/disk.c Sun Feb 11 20:58:00 2018 (r329140) @@ -89,6 +89,12 @@ ptblread(void *d, void *buf, size_t blocks, uint64_t o od = (struct open_disk *)dev->d_opendata; /* + * The strategy function assumes the offset is in units of 512 byte + * sectors. For larger sector sizes, we need to adjust the offset to + * match the actual sector size. + */ + offset *= (od->sectorsize / 512); + /* * As the GPT backup partition is located at the end of the disk, * to avoid reading past disk end, flag bcache not to use RA. */ Modified: stable/11/sys/boot/common/md.c ============================================================================== --- stable/11/sys/boot/common/md.c Sun Feb 11 20:47:38 2018 (r329139) +++ stable/11/sys/boot/common/md.c Sun Feb 11 20:58:00 2018 (r329140) @@ -73,7 +73,8 @@ struct devsw md_dev = { md_open, md_close, noioctl, - md_print + md_print, + NULL }; static int Copied and modified: stable/11/sys/boot/defs.mk (from r324654, head/sys/boot/defs.mk) ============================================================================== --- head/sys/boot/defs.mk Mon Oct 16 03:59:58 2017 (r324654, copy source) +++ stable/11/sys/boot/defs.mk Sun Feb 11 20:58:00 2018 (r329140) @@ -5,19 +5,38 @@ .if !defined(__BOOT_DEFS_MK__) __BOOT_DEFS_MK__=${MFILE} -BOOTDIR= ${SRCTOP}/sys/boot -FICLDIR= ${SRCTOP}/sys/boot/ficl -LDR_MI= ${BOOTDIR}/common -SASRC= ${SRCTOP}/sys/boot/libsa +BOOTSRC= ${SRCTOP}/sys/boot +EFISRC= ${BOOTSRC}/efi +EFIINC= ${EFISRC}/include +EFIINCMD= ${EFIINC}/${MACHINE} +FDTSRC= ${BOOTSRC}/fdt +FICLSRC= ${BOOTSRC}/ficl +LDRSRC= ${BOOTSRC}/common +SASRC= ${BOOTSRC}/libsa SYSDIR= ${SRCTOP}/sys +UBOOTSRC= ${BOOTSRC}/uboot +ZFSSRC= ${BOOTSRC}/zfs +BOOTOBJ= ${OBJTOP}/sys/boot + +# BINDIR is where we install +BINDIR?= /boot + # NB: The makefiles depend on these being empty when we don't build forth. .if ${MK_FORTH} != "no" -LIBFICL= ${OBJTOP}/sys/boot/ficl/libficl.a -LIBFICL32= ${OBJTOP}/sys/boot/ficl32/libficl.a +LIBFICL= ${BOOTOBJ}/ficl/libficl.a +.if ${MACHINE} == "i386" +LIBFICL32= ${LIBFICL} +.else +LIBFICL32= ${BOOTOBJ}/ficl32/libficl.a .endif -LIBSA= ${OBJTOP}/sys/boot/libsa/libsa.a -LIBSA32= ${OBJTOP}/sys/boot/libsa32/libsa32.a +.endif +LIBSA= ${BOOTOBJ}/libsa/libsa.a +.if ${MACHINE} == "i386" +LIBSA32= ${LIBSA} +.else +LIBSA32= ${BOOTOBJ}/libsa32/libsa32.a +.endif # Standard options: @@ -66,9 +85,87 @@ CFLAGS+= -DLOADER_GPT_SUPPORT .if ${LOADER_MBR_SUPPORT:Uyes} == "yes" CFLAGS+= -DLOADER_MBR_SUPPORT .endif -.if ${LOADER_GELI_SUPPORT:Uyes} == "yes" -CFLAGS+= -DLOADER_GELI_SUPPORT + +# GELI Support, with backward compat hooks +.if defined(HAVE_GELI) +.if defined(LOADER_NO_GELI_SUPPORT) +MK_LOADER_GELI=no +.warning "Please move from LOADER_NO_GELI_SUPPORT to WITHOUT_LOADER_GELI" .endif +.if defined(LOADER_GELI_SUPPORT) +MK_LOADER_GELI=yes +.warning "Please move from LOADER_GELI_SUPPORT to WITH_LOADER_GELI" .endif +.if ${MK_LOADER_GELI} == "yes" +CFLAGS+= -DLOADER_GELI_SUPPORT +CFLAGS+= -I${BOOTSRC}/geli +LIBGELIBOOT= ${BOOTOBJ}/geli/libgeliboot.a +.endif +.endif +.endif + +CFLAGS+= -I${SYSDIR} + +# All PowerPC builds are 32 bit. We have no 64-bit loaders on powerpc +# or powerpc64. +.if ${MACHINE_ARCH} == "powerpc64" +CFLAGS+= -m32 -mcpu=powerpc +.endif + +# For amd64, there's a bit of mixed bag. Some of the tree (i386, lib*32) is +# build 32-bit and some 64-bit (lib*, efi). Centralize all the 32-bit magic here +# and activate it when DO32 is explicitly defined to be 1. +.if ${MACHINE_ARCH} == "amd64" && ${DO32:U0} == 1 +CFLAGS+= -m32 -mcpu=i386 +# LD_FLAGS is passed directly to ${LD}, not via ${CC}: +LD_FLAGS+= -m elf_i386_fbsd +AFLAGS+= --32 +.endif + +# Make sure we use the machine link we're about to create +CFLAGS+=-I. + +_ILINKS=machine +.if ${MACHINE} != ${MACHINE_CPUARCH} && ${MACHINE} != "arm64" +_ILINKS+=${MACHINE_CPUARCH} +.endif +.if ${MACHINE_CPUARCH} == "i386" || ${MACHINE_CPUARCH} == "amd64" +_ILINKS+=x86 +.endif +CLEANFILES+=${_ILINKS} + +all: ${PROG} + +beforedepend: ${_ILINKS} +beforebuild: ${_ILINKS} + +# Ensure that the links exist without depending on it when it exists which +# causes all the modules to be rebuilt when the directory pointed to changes. +.for _link in ${_ILINKS} +.if !exists(${.OBJDIR}/${_link}) +${OBJS}: ${_link} +.endif +.endfor + +.NOPATH: ${_ILINKS} + +${_ILINKS}: + @case ${.TARGET} in \ + machine) \ + if [ ${DO32:U0} -eq 0 ]; then \ + path=${SYSDIR}/${MACHINE}/include ; \ + else \ + path=${SYSDIR}/${MACHINE:C/amd64/i386/}/include ; \ + fi ;; \ + *) \ + path=${SYSDIR}/${.TARGET:T}/include ;; \ + esac ; \ + path=`(cd $$path && /bin/pwd)` ; \ + ${ECHO} ${.TARGET:T} "->" $$path ; \ + ln -fhs $$path ${.TARGET:T} + +# For loader implementations, we generate a loader.help file. This can be suppressed by +# setting HELP_FILES to nothing. +HELP_FILES= ${LDRSRC}/help.common .endif # __BOOT_DEFS_MK__ Modified: stable/11/sys/boot/efi/Makefile ============================================================================== --- stable/11/sys/boot/efi/Makefile Sun Feb 11 20:47:38 2018 (r329139) +++ stable/11/sys/boot/efi/Makefile Sun Feb 11 20:58:00 2018 (r329140) @@ -1,6 +1,6 @@ # $FreeBSD$ -.include <src.opts.mk> +.include <bsd.init.mk> # In-tree GCC does not support __attribute__((ms_abi)), but gcc newer # than 4.5 supports it. Modified: stable/11/sys/boot/efi/Makefile.inc ============================================================================== --- stable/11/sys/boot/efi/Makefile.inc Sun Feb 11 20:47:38 2018 (r329139) +++ stable/11/sys/boot/efi/Makefile.inc Sun Feb 11 20:58:00 2018 (r329140) @@ -1,7 +1,5 @@ # $FreeBSD$ -BINDIR?= /boot - .if ${MACHINE_CPUARCH} == "i386" CFLAGS+= -march=i386 CFLAGS+= -mno-aes Modified: stable/11/sys/boot/efi/boot1/Makefile ============================================================================== --- stable/11/sys/boot/efi/boot1/Makefile Sun Feb 11 20:47:38 2018 (r329139) +++ stable/11/sys/boot/efi/boot1/Makefile Sun Feb 11 20:58:00 2018 (r329140) @@ -2,17 +2,15 @@ MAN= -.include "../Makefile.inc" +.include <bsd.init.mk> MK_SSP= no +MK_FORTH= no PROG= boot1.sym INTERNALPROG= -WARNS?= 3 +WARNS?= 6 -# Include bcache code. -HAVE_BCACHE= yes - # We implement a slightly non-standard %S in that it always takes a # CHAR16 that's common in UEFI-land instead of a wchar_t. This only # seems to matter on arm64 where wchar_t defaults to an int instead @@ -21,71 +19,46 @@ HAVE_BCACHE= yes CWARNFLAGS.boot1.c+= -Wno-format # Disable warnings that are currently incompatible with the zfs boot code -CWARNFLAGS.zfs.c += -Wno-incompatible-pointer-types-discards-qualifiers -CWARNFLAGS.zfs.c += -Wno-missing-variable-declarations -CWARNFLAGS.zfs.c += -Wno-array-bounds -CWARNFLAGS.zfs.c += -Wno-cast-align -CWARNFLAGS.zfs.c += -Wno-cast-qual -CWARNFLAGS.zfs.c += -Wno-missing-prototypes -CWARNFLAGS.zfs.c += -Wno-sign-compare -CWARNFLAGS.zfs.c += -Wno-unused-parameter -CWARNFLAGS.zfs.c += -Wno-unused-function -CWARNFLAGS.skein.c += -Wno-cast-align -.if ${COMPILER_TYPE} == "clang" -CWARNFLAGS.skein.c += -Wno-missing-variable-declarations -.else if ${COMPILER_TYPE} == "gcc" -CWARNFLAGS.skein.c += -Wno-missing-declarations -.endif +CWARNFLAGS.zfs_module.c += -Wno-array-bounds +CWARNFLAGS.zfs_module.c += -Wno-cast-align +CWARNFLAGS.zfs_module.c += -Wno-cast-qual +CWARNFLAGS.zfs_module.c += -Wno-missing-prototypes +CWARNFLAGS.zfs_module.c += -Wno-sign-compare +CWARNFLAGS.zfs_module.c += -Wno-unused-parameter +CWARNFLAGS.zfs_module.c += -Wno-unused-function # architecture-specific loader code -SRCS= boot1.c self_reloc.c start.S +SRCS= boot1.c self_reloc.c start.S ufs_module.c .if ${MK_ZFS} != "no" -.PATH: ${.CURDIR}/../../../crypto/skein -SRCS+= skein.c skein_block.c -# Do not unroll skein loops, reduce code size -CFLAGS+= -DSKEIN_LOOP=111 -.PATH: ${.CURDIR}/../../zfs -SRCS+= zfs.c +SRCS+= zfs_module.c +CFLAGS+= -I${ZFSSRC} +CFLAGS+= -I${SYSDIR}/cddl/boot/zfs +CFLAGS+= -DEFI_ZFS_BOOT +LIBZFSBOOT= ${BOOTOBJ}/zfs/libzfsboot.a .endif .if ${COMPILER_TYPE} == "gcc" && ${COMPILER_VERSION} > 40201 CWARNFLAGS.self_reloc.c+= -Wno-error=maybe-uninitialized .endif -# Always add MI sources -.PATH: ${.CURDIR}/../../common -.include "${.CURDIR}/../../common/Makefile.inc" -CFLAGS+= -I${.CURDIR}/../../common - -.PATH: ${.CURDIR}/arch/${MACHINE} - -CFLAGS+= -I. -CFLAGS+= -I${.CURDIR}/../include -CFLAGS+= -I${.CURDIR}/../include/${MACHINE} -CFLAGS+= -I${.CURDIR}/../../../contrib/dev/acpica/include -CFLAGS+= -I${.CURDIR}/../../.. +CFLAGS+= -I${EFIINC} +CFLAGS+= -I${EFIINCMD} +CFLAGS+= -I${SYSDIR}/contrib/dev/acpica/include CFLAGS+= -DEFI_UFS_BOOT .ifdef(EFI_DEBUG) CFLAGS+= -DEFI_DEBUG .endif -.if ${MK_ZFS} != "no" -CFLAGS+= -I${.CURDIR}/../../zfs/ -CFLAGS+= -I${.CURDIR}/../../../cddl/boot/zfs/ -CFLAGS+= -I${.CURDIR}/../../../crypto/skein -CFLAGS+= -DEFI_ZFS_BOOT -.endif - # Always add MI sources and REGULAR efi loader bits -.PATH: ${.CURDIR}/../loader/arch/${MACHINE} -.PATH: ${.CURDIR}/../loader -.PATH: ${.CURDIR}/../../common -CFLAGS+= -I${.CURDIR}/../../common +.PATH: ${EFISRC}/loader/arch/${MACHINE} +.PATH: ${EFISRC}/loader +.PATH: ${LDRSRC} +CFLAGS+= -I${LDRSRC} FILES= boot1.efi boot1.efifat FILESMODE_boot1.efi= ${BINMODE} -LDSCRIPT= ${.CURDIR}/../loader/arch/${MACHINE}/ldscript.${MACHINE} +LDSCRIPT= ${EFISRC}/loader/arch/${MACHINE}/ldscript.${MACHINE} LDFLAGS+= -Wl,-T${LDSCRIPT},-Bsymbolic,-znotext -shared .if ${MACHINE_CPUARCH} == "aarch64" @@ -96,15 +69,15 @@ CFLAGS+= -fPIC LDFLAGS+= -Wl,-znocombreloc .endif -LIBEFI= ${.OBJDIR}/../libefi/libefi.a +LIBEFI= ${BOOTOBJ}/efi/libefi/libefi.a # # Add libstand for the runtime functions used by the compiler - for example # __aeabi_* (arm) or __divdi3 (i386). # as well as required string and memory functions for all platforms. # -DPADD+= ${LIBEFI} ${LIBSA} -LDADD+= ${LIBEFI} ${LIBSA} +DPADD+= ${LIBEFI} ${LIBZFSBOOT} ${LIBSA} +LDADD+= ${LIBEFI} ${LIBZFSBOOT} ${LIBSA} DPADD+= ${LDSCRIPT} @@ -130,7 +103,7 @@ boot1.efi: ${PROG} SOURCE_DATE_EPOCH=${SOURCE_DATE_EPOCH} \ ${OBJCOPY} -j .peheader -j .text -j .sdata -j .data \ -j .dynamic -j .dynsym -j .rel.dyn \ - -j .rela.dyn -j .reloc -j .eh_frame -j set_Xcommand_set \ + -j .rela.dyn -j .reloc -j .eh_frame \ --output-target=${EFI_TARGET} ${.ALLSRC} ${.TARGET} boot1.o: ${SASRC}/ufsread.c @@ -151,21 +124,6 @@ boot1.efifat: boot1.efi xz -d -c ${.CURDIR}/fat-${MACHINE}.tmpl.xz > ${.TARGET} ${DD} if=${.ALLSRC} of=${.TARGET} seek=${BOOT1_OFFSET} conv=notrunc -CLEANFILES= boot1.efi boot1.efifat +CLEANFILES+= boot1.efi boot1.efifat .include <bsd.prog.mk> - -beforedepend ${OBJS}: machine - -CLEANFILES+= machine - -machine: .NOMETA - ln -sf ${.CURDIR}/../../../${MACHINE}/include machine - -.if ${MACHINE_CPUARCH} == "amd64" || ${MACHINE_CPUARCH} == "i386" -beforedepend ${OBJS}: x86 -CLEANFILES+= x86 - -x86: .NOMETA - ln -sf ${.CURDIR}/../../../x86/include x86 -.endif Modified: stable/11/sys/boot/efi/boot1/boot1.c ============================================================================== --- stable/11/sys/boot/efi/boot1/boot1.c Sun Feb 11 20:47:38 2018 (r329139) +++ stable/11/sys/boot/efi/boot1/boot1.c Sun Feb 11 20:58:00 2018 (r329140) @@ -23,179 +23,61 @@ __FBSDID("$FreeBSD$"); #include <sys/param.h> -#include <sys/disk.h> #include <machine/elf.h> #include <machine/stdarg.h> #include <stand.h> -#include <disk.h> #include <efi.h> -#include <efilib.h> -#include <efiprot.h> #include <eficonsctl.h> -#ifdef EFI_ZFS_BOOT -#include <libzfs.h> -#endif typedef CHAR16 efi_char; #include <efichar.h> -#include <bootstrap.h> - -#include "efi_drivers.h" -#include "efizfs.h" +#include "boot_module.h" #include "paths.h" static void efi_panic(EFI_STATUS s, const char *fmt, ...) __dead2 __printflike(2, 3); -#ifdef EFI_DEBUG -#define DPRINTF(fmt, args...) printf(fmt, ##args) -#define DSTALL(d) BS->Stall(d) -#else -#define DPRINTF(fmt, ...) {} -#define DSTALL(d) {} -#endif -struct arch_switch archsw; /* MI/MD interface boundary */ - -static const efi_driver_t *efi_drivers[] = { - NULL -}; - -extern struct console efi_console; -#if defined(__amd64__) || defined(__i386__) -extern struct console comconsole; -extern struct console nullconsole; -#endif - +static const boot_module_t *boot_modules[] = +{ #ifdef EFI_ZFS_BOOT -uint64_t pool_guid; + &zfs_module, #endif - -struct fs_ops *file_system[] = { -#ifdef EFI_ZFS_BOOT - &zfs_fsops, -#endif - &dosfs_fsops, #ifdef EFI_UFS_BOOT - &ufs_fsops, + &ufs_module #endif - &cd9660_fsops, - &nfs_fsops, - &gzipfs_fsops, - &bzipfs_fsops, - NULL }; -struct devsw *devsw[] = { - &efipart_hddev, - &efipart_fddev, - &efipart_cddev, -#ifdef EFI_ZFS_BOOT - &zfs_dev, -#endif - NULL -}; - -struct console *consoles[] = { - &efi_console, - NULL -}; - -static EFI_LOADED_IMAGE *boot_image; -static EFI_DEVICE_PATH *imgpath; -static EFI_DEVICE_PATH *imgprefix; - -/* Definitions we don't actually need for boot, but we need to define - * to make the linker happy. - */ -struct file_format *file_formats[] = { NULL }; - -struct netif_driver *netif_drivers[] = { NULL }; - -static int -efi_autoload(void) -{ - printf("******** Boot block should not call autoload\n"); - return (-1); -} - -static ssize_t -efi_copyin(const void *src __unused, vm_offset_t dest __unused, - const size_t len __unused) -{ - printf("******** Boot block should not call copyin\n"); - return (-1); -} - -static ssize_t -efi_copyout(vm_offset_t src __unused, void *dest __unused, - const size_t len __unused) -{ - printf("******** Boot block should not call copyout\n"); - return (-1); -} - -static ssize_t -efi_readin(int fd __unused, vm_offset_t dest __unused, - const size_t len __unused) -{ - printf("******** Boot block should not call readin\n"); - return (-1); -} - +#define NUM_BOOT_MODULES nitems(boot_modules) /* The initial number of handles used to query EFI for partitions. */ #define NUM_HANDLES_INIT 24 +static EFI_GUID BlockIoProtocolGUID = BLOCK_IO_PROTOCOL; static EFI_GUID DevicePathGUID = DEVICE_PATH_PROTOCOL; static EFI_GUID LoadedImageGUID = LOADED_IMAGE_PROTOCOL; +static EFI_GUID ConsoleControlGUID = EFI_CONSOLE_CONTROL_PROTOCOL_GUID; static EFI_GUID FreeBSDBootVarGUID = FREEBSD_BOOT_VAR_GUID; -static EFI_STATUS -do_load(const char *filepath, void **bufp, size_t *bufsize) +/* + * Provide Malloc / Free backed by EFIs AllocatePool / FreePool which ensures + * memory is correctly aligned avoiding EFI_INVALID_PARAMETER returns from + * EFI methods. + */ +void * +Malloc(size_t len, const char *file __unused, int line __unused) { - struct stat st; - void *buf = NULL; - int fd, err; - size_t fsize, remaining; - ssize_t readsize; + void *out; - if ((fd = open(filepath, O_RDONLY)) < 0) { - return (ENOTSUP); - } + if (BS->AllocatePool(EfiLoaderData, len, &out) == EFI_SUCCESS) + return (out); - if ((err = fstat(fd, &st)) != 0) { - goto close_file; - } + return (NULL); +} - fsize = st.st_size; - - if ((buf = malloc(fsize)) == NULL) { - err = ENOMEM; - goto close_file; - } - - remaining = fsize; - - do { - if ((readsize = read(fd, buf, fsize)) < 0) { - err = (-readsize); - goto free_buf; - } - - remaining -= readsize; - } while(remaining != 0); - - close(fd); - *bufsize = st.st_size; - *bufp = buf; - - close_file: - close(fd); - - return errno_to_efi_status(err); - - free_buf: - free(buf); - goto close_file; +void +Free(void *buf, const char *file __unused, int line __unused) +{ + if (buf != NULL) + (void)BS->FreePool(buf); } static EFI_STATUS @@ -215,275 +97,98 @@ efi_setenv_freebsd_wcs(const char *varname, CHAR16 *va return (rv); } -static int -probe_fs(const char *filepath) +/* + * nodes_match returns TRUE if the imgpath isn't NULL and the nodes match, + * FALSE otherwise. + */ +static BOOLEAN +nodes_match(EFI_DEVICE_PATH *imgpath, EFI_DEVICE_PATH *devpath) { - int fd; + size_t len; - if ((fd = open(filepath, O_RDONLY)) < 0) { - return (ENOTSUP); - } + if (imgpath == NULL || imgpath->Type != devpath->Type || + imgpath->SubType != devpath->SubType) + return (FALSE); - close(fd); + len = DevicePathNodeLength(imgpath); + if (len != DevicePathNodeLength(devpath)) + return (FALSE); - return (0); + return (memcmp(imgpath, devpath, (size_t)len) == 0); } -static int -probe_dev(struct devsw *dev, int unit, const char *filepath) +/* + * device_paths_match returns TRUE if the imgpath isn't NULL and all nodes + * in imgpath and devpath match up to their respective occurrences of a + * media node, FALSE otherwise. + */ +static BOOLEAN +device_paths_match(EFI_DEVICE_PATH *imgpath, EFI_DEVICE_PATH *devpath) { - struct devdesc currdev; - char *devname; - int err; - currdev.d_dev = dev; - currdev.d_type = currdev.d_dev->dv_type; - currdev.d_unit = unit; - currdev.d_opendata = NULL; - devname = efi_fmtdev(&currdev); + if (imgpath == NULL) + return (FALSE); - env_setenv("currdev", EV_VOLATILE, devname, efi_setcurrdev, - env_nounset); + while (!IsDevicePathEnd(imgpath) && !IsDevicePathEnd(devpath)) { + if (IsDevicePathType(imgpath, MEDIA_DEVICE_PATH) && + IsDevicePathType(devpath, MEDIA_DEVICE_PATH)) + return (TRUE); - err = probe_fs(filepath); + if (!nodes_match(imgpath, devpath)) *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** _______________________________________________ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"