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