1HAVE_ZFS= ${MK_LOADER_ZFS} 2 3LOADER_NET_SUPPORT?= yes 4LOADER_NFS_SUPPORT?= yes 5LOADER_TFTP_SUPPORT?= yes 6LOADER_CD9660_SUPPORT?= yes 7LOADER_EXT2FS_SUPPORT?= no 8LOADER_MSDOS_SUPPORT?= no 9LOADER_UFS_SUPPORT?= yes 10LOADER_GZIP_SUPPORT?= yes 11LOADER_BZIP2_SUPPORT?= yes 12LOADER_XZ_SUPPORT?= yes 13LOADER_MD_SUPPORT?= yes 14 15.include <bsd.init.mk> 16 17LOADER?= loader_${LOADER_INTERP} 18PROG= ${LOADER}.sym 19INTERNALPROG= 20NEWVERSWHAT?= "bootstrap loader" x86 21VERSION_FILE?= ${.CURDIR}/../loader/version 22# 23# There's 640k - 40k maximum space, less however much memory the BIOS uses. A 24# non-random survey suggests that 20k-25k is a good value for 'most' machines. 25# We also need to subtract maximum stack usage (20-25k). 26# 27# So 640k - 40k - 25k - 25k = 550k = 563,200 bytes, but use 560,000 below for 28# some extra buffer for more complex setups and/or wider BIOS lomem variation. 29# 30# Some systems use more stack or have BIOS reserve more RAM (or both), and will 31# need to set this lower in /etc/src.conf if the above buffer is too small. 32# 33# sudo dd if=/dev/mem bs=1 iseek=0x413 count=2 | hd -d 34# 35# will tell you how many kiB of lomem are available. 36# 37# We further reduce this to 505k, though, to give PXE an additional 64k of space 38# so pxeloader will fit. If you have special needs that do not include pxeboot, 39# you can safely set this as high as 560000 generally, or a bit higher if you 40# have tight control over the machines you are booting on. 41# 42LOADERSIZE?= 505000 # Largest known safe size for loader.bin 43 44.PATH: ${BOOTSRC}/i386/loader 45 46# architecture-specific loader code 47SRCS+= chain.c 48SRCS+= conf.c 49SRCS+= gfx_bios.c 50SRCS+= main.c 51SRCS+= vers.c 52 53.if ${MK_LOADER_BIOS_TEXTONLY} == "no" 54SRCS+= gfx_fb.c 55SRCS+= 8x16.c 56 57CFLAGS.gfx_fb.c += -I${.CURDIR}/../libi386 58CFLAGS.gfx_fb.c += -I$(SRCTOP)/sys/teken 59CFLAGS.gfx_fb.c += -I${SRCTOP}/sys/cddl/contrib/opensolaris/common/lz4 60CFLAGS.gfx_fb.c += -I${SRCTOP}/contrib/pnglite 61CFLAGS.gfx_fb.c += ${ZLIB_CFLAGS} 62CFLAGS.gfx_bios.c += -I$(SRCTOP)/sys/teken 63CFLAGS.gfx_bios.c += -I${SRCTOP}/contrib/pnglite 64.else 65CFLAGS.gfx_bios.c += -DBIOS_TEXT_ONLY 66CFLAGS.conf.c += -DBIOS_TEXT_ONLY 67.endif 68 69# Include bcache code. 70HAVE_BCACHE= yes 71 72# Enable PnP and ISA-PnP code. 73HAVE_PNP= yes 74HAVE_ISABUS= yes 75 76.if ${MK_LOADER_ZFS} == "yes" 77CFLAGS.main.c+= -I${SYSDIR}/contrib/openzfs/include 78CFLAGS.main.c+= -I${SYSDIR}/contrib/openzfs/include/os/freebsd/zfs 79.endif 80 81.if exists(${.CURDIR}/help.i386) 82HELP_FILES= ${.CURDIR}/help.i386 83.endif 84HELP_FILENAME= loader.help.bios 85 86# Always add MI sources 87.include "${BOOTSRC}/loader.mk" 88 89CLEANFILES+= ${LOADER} ${LOADER}.bin 8x16.c 90 91ORG= 0x0 92 93CFLAGS+= -Wall 94LDFLAGS+= -static ${LDFLAGS_ORG} -Wl,--gc-sections 95.if (${LINKER_TYPE} == "lld" && ${LINKER_VERSION} >= 130000) || \ 96 (${LINKER_TYPE} == "bfd" && ${LINKER_VERSION} >= 23700) 97# lld 13 and higher default to garbage collecting start/stop symbols, 98# completely ruining our linker sets. For now, work around it by 99# disabling this un-feature. 100LDFLAGS+= -Wl,-z,nostart-stop-gc 101.endif 102 103# i386 standalone support library 104LIBI386= ${BOOTOBJ}/i386/libi386/libi386.a 105CFLAGS+= -I${BOOTSRC}/i386 106 107# Debug me! 108#CFLAGS+= -g 109#LDFLAGS+= -g 110 1118x16.c: ${SRCTOP}/contrib/terminus/ter-u16b.bdf 112 vtfontcvt -f compressed-source -o ${.TARGET} ${.ALLSRC} 113 114 115${LOADER}: ${LOADER}.bin ${BTXLDR} ${BTXKERN} 116 btxld -v -f aout -e ${LOADER_ADDRESS} -o ${.TARGET} -l ${BTXLDR} \ 117 -b ${BTXKERN} ${LOADER}.bin 118 119${LOADER}.bin: ${LOADER}.sym 120 ${STRIPBIN} -R .comment -R .note -o ${.TARGET} ${.ALLSRC} 121 @set -- `ls -l ${.TARGET}` ; x=$$((${LOADERSIZE}-$$5)); \ 122 echo "$$x bytes available"; test $$x -ge 0 123 124.if ${MK_LOADER_ZFS} == "yes" && ${LOADER_INTERP} == ${LOADER_DEFAULT_INTERP} 125LINKS+= ${BINDIR}/${LOADER} ${BINDIR}/zfsloader 126.endif 127.if ${LOADER_INTERP} == ${LOADER_DEFAULT_INTERP} 128LINKS+= ${BINDIR}/${LOADER} ${BINDIR}/loader 129.endif 130FILES+= ${LOADER} 131FILESMODE_${LOADER}= ${BINMODE} -b 132 133# Note: crt0.o needs to be first for pxeboot(8) to work. It assumes that the 134# startup code is located at the start of the loader and will jump 135# there. Although btx is more flexible than this, the emulated boot2 environment 136# that pxeldr provides has none of that flexibility and assumes the entry point 137# is 0. Finally, both pxeldr and cdboot assume they are loading an a.out file. 138# 139# We must add it to the LDFLAGS instead of the OBJS because the former won't try 140# to clean it. When it is in OBJS, this cleaning can lead to races where 141# btxcrt.o is rebuilt, but boot2 isn't, leading to errors at installation time. 142# LDFLAGS does not have this baggage and will be included first in the list of 143# files. 144LDFLAGS+= ${BTXCRT} 145 146# Force the linker max page size to 4k so that we fit in the limited space even 147# if someone has set a larger default linker max page size via /etc/src.conf. 148LDFLAGS+= -Wl,-z,max-page-size=0x1000 149 150DPADD= ${LDR_INTERP32} ${LIBI386} ${LIBSA32} 151LDADD= ${LDR_INTERP32} ${LIBI386} ${LIBSA32} 152 153.if ${MACHINE_CPUARCH} == "amd64" 154CFLAGS+= -DLOADER_PREFER_AMD64 155.endif 156 157.include <bsd.prog.mk> 158