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