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 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# 35# We further reduce this to 500k, though, to give PXE an additional 64k of space 36# so pxeloader will fit. If you have special needs that do not include pxeboot, 37# you can safely set this as high as 560000 generally, or a bit higher if you 38# have tight control over the machines you are booting on. 39# 40LOADERSIZE?= 500000 # Largest known safe size for loader.bin 41 42.PATH: ${BOOTSRC}/i386/loader 43 44# architecture-specific loader code 45SRCS+= chain.c 46SRCS+= conf.c 47SRCS+= gfx_bios.c 48SRCS+= main.c 49SRCS+= vers.c 50 51.if ${MK_LOADER_BIOS_TEXTONLY} == "no" 52SRCS+= gfx_fb.c 53SRCS+= 8x16.c 54 55CFLAGS.gfx_fb.c += -I${.CURDIR}/../libi386 56CFLAGS.gfx_fb.c += -I$(SRCTOP)/sys/teken 57CFLAGS.gfx_fb.c += -I${SRCTOP}/sys/cddl/contrib/opensolaris/common/lz4 58CFLAGS.gfx_fb.c += -I${SRCTOP}/contrib/pnglite 59CFLAGS.gfx_fb.c += -DHAVE_MEMCPY -I${SRCTOP}/sys/contrib/zlib 60CFLAGS.gfx_bios.c += -I$(SRCTOP)/sys/teken 61CFLAGS.gfx_bios.c += -I${SRCTOP}/contrib/pnglite 62.else 63CFLAGS.gfx_bios.c += -DBIOS_TEXT_ONLY 64CFLAGS.conf.c += -DBIOS_TEXT_ONLY 65.endif 66 67# Include bcache code. 68HAVE_BCACHE= yes 69 70# Enable PnP and ISA-PnP code. 71HAVE_PNP= yes 72HAVE_ISABUS= yes 73 74.if ${MK_LOADER_ZFS} == "yes" 75CFLAGS.main.c+= -I${SYSDIR}/contrib/openzfs/include 76CFLAGS.main.c+= -I${SYSDIR}/contrib/openzfs/include/os/freebsd/zfs 77.endif 78 79.if exists(${.CURDIR}/help.i386) 80HELP_FILES= ${.CURDIR}/help.i386 81.endif 82HELP_FILENAME= loader.help.bios 83 84# Always add MI sources 85.include "${BOOTSRC}/loader.mk" 86 87CLEANFILES+= ${LOADER} ${LOADER}.bin 8x16.c 88 89ORG= 0x0 90 91CFLAGS+= -Wall 92LDFLAGS+= -static ${LDFLAGS_ORG} -Wl,--gc-sections 93.if ${LINKER_TYPE} == "lld" && ${LINKER_VERSION} >= 130000 94# lld 13 and higher default to garbage collecting start/stop symbols, 95# completely ruining our linker sets. For now, work around it by 96# disabling this un-feature. 97LDFLAGS+= -Wl,-z,nostart-stop-gc 98.endif 99 100# i386 standalone support library 101LIBI386= ${BOOTOBJ}/i386/libi386/libi386.a 102CFLAGS+= -I${BOOTSRC}/i386 103 104# Debug me! 105#CFLAGS+= -g 106#LDFLAGS+= -g 107 1088x16.c: ${SRCTOP}/contrib/terminus/ter-u16b.bdf 109 vtfontcvt -f compressed-source -o ${.TARGET} ${.ALLSRC} 110 111 112${LOADER}: ${LOADER}.bin ${BTXLDR} ${BTXKERN} 113 btxld -v -f aout -e ${LOADER_ADDRESS} -o ${.TARGET} -l ${BTXLDR} \ 114 -b ${BTXKERN} ${LOADER}.bin 115 116${LOADER}.bin: ${LOADER}.sym 117 ${STRIPBIN} -R .comment -R .note -o ${.TARGET} ${.ALLSRC} 118 @set -- `ls -l ${.TARGET}` ; x=$$((${LOADERSIZE}-$$5)); \ 119 echo "$$x bytes available"; test $$x -ge 0 120 121.if ${MK_LOADER_ZFS} == "yes" && ${LOADER_INTERP} == ${LOADER_DEFAULT_INTERP} 122LINKS+= ${BINDIR}/${LOADER} ${BINDIR}/zfsloader 123.endif 124.if ${LOADER_INTERP} == ${LOADER_DEFAULT_INTERP} 125LINKS+= ${BINDIR}/${LOADER} ${BINDIR}/loader 126.endif 127FILES+= ${LOADER} 128FILESMODE_${LOADER}= ${BINMODE} -b 129 130# Note: crt0.o needs to be first for pxeboot(8) to work. It assumes that the 131# startup code is located at the start of the loader and will jump 132# there. Although btx is more flexible than this, the emulated boot2 environment 133# that pxeldr provides has none of that flexibility and assumes the entry point 134# is 0. Finally, both pxeldr and cdboot assume they are loading an a.out file. 135# 136# We must add it to the LDFLAGS instead of the OBJS because the former won't try 137# to clean it. When it is in OBJS, this cleaning can lead to races where 138# btxcrt.o is rebuilt, but boot2 isn't, leading to errors at installation time. 139# LDFLAGS does not have this baggage and will be included first in the list of 140# files. 141LDFLAGS+= ${BTXCRT} 142 143DPADD= ${LDR_INTERP32} ${LIBI386} ${LIBSA32} 144LDADD= ${LDR_INTERP32} ${LIBI386} ${LIBSA32} 145 146.if ${MACHINE_CPUARCH} == "amd64" 147CFLAGS+= -DLOADER_PREFER_AMD64 148.endif 149 150.include <bsd.prog.mk> 151