1ca987d46SWarner Losh.include <bsd.init.mk> 2ca987d46SWarner Losh 33830659eSToomas Soome.PATH: ${BOOTSRC}/i386/boot2 ${BOOTSRC}/i386/common ${BOOTSRC}/common 4ca987d46SWarner Losh 5ca987d46SWarner LoshFILES= zfsboot 6ca987d46SWarner LoshMAN= zfsboot.8 7ca987d46SWarner Losh 8ca987d46SWarner LoshBOOT_COMCONSOLE_PORT?= 0x3f8 9*4722ceb7SEd MasteBOOT_COMCONSOLE_SPEED?= 115200 10ca987d46SWarner LoshB2SIOFMT?= 0x3 11ca987d46SWarner Losh 12ca987d46SWarner LoshREL1= 0x700 13ca987d46SWarner LoshORG1= 0x7c00 14ca987d46SWarner LoshORG2= 0x2000 15ca987d46SWarner Losh 16ca987d46SWarner LoshCFLAGS+=-DBOOTPROG=\"zfsboot\" \ 17ca987d46SWarner Losh -O1 \ 183830659eSToomas Soome -DBOOT2 \ 193830659eSToomas Soome -DLOADER_GPT_SUPPORT \ 203830659eSToomas Soome -DLOADER_MBR_SUPPORT \ 213830659eSToomas Soome -DLOADER_ZFS_SUPPORT \ 223830659eSToomas Soome -DLOADER_UFS_SUPPORT \ 23ca987d46SWarner Losh -DSIOPRT=${BOOT_COMCONSOLE_PORT} \ 24ca987d46SWarner Losh -DSIOFMT=${B2SIOFMT} \ 25ca987d46SWarner Losh -DSIOSPD=${BOOT_COMCONSOLE_SPEED} \ 26ca987d46SWarner Losh -I${LDRSRC} \ 27ca987d46SWarner Losh -I${BOOTSRC}/i386/common \ 283830659eSToomas Soome -I${BOOTSRC}/i386/libi386 \ 29ca987d46SWarner Losh -I${ZFSSRC} \ 3092a2b890SWarner Losh -I${SYSDIR}/crypto/skein \ 31ca987d46SWarner Losh -I${SYSDIR}/cddl/boot/zfs \ 32e307eb94SToomas Soome -I${SYSDIR}/contrib/openzfs/include \ 33e307eb94SToomas Soome -I${SYSDIR}/contrib/openzfs/include/os/freebsd/spl \ 34e307eb94SToomas Soome -I${SYSDIR}/contrib/openzfs/include/os/freebsd/zfs \ 35e499793eSToomas Soome -I${SYSDIR}/cddl/contrib/opensolaris/common/lz4 \ 36ca987d46SWarner Losh -I${BOOTSRC}/i386/boot2 \ 37ca987d46SWarner Losh -Wall -Waggregate-return -Wbad-function-cast -Wno-cast-align \ 38ca987d46SWarner Losh -Wmissing-declarations -Wmissing-prototypes -Wnested-externs \ 39073193edSDimitry Andric -Wpointer-arith -Wshadow -Wstrict-prototypes -Wwrite-strings 40ca987d46SWarner Losh 413830659eSToomas SoomeCFLAGS.part.c+= -DHAVE_MEMCPY -I${SRCTOP}/sys/contrib/zlib 423830659eSToomas Soome 43ca987d46SWarner LoshCFLAGS.gcc+= --param max-inline-insns-single=100 44ca987d46SWarner Losh 45ca987d46SWarner LoshLD_FLAGS+=${LD_FLAGS_BIN} 46ca987d46SWarner Losh 47ca987d46SWarner LoshCLEANFILES+= zfsboot 48ca987d46SWarner Losh 49ca987d46SWarner Loshzfsboot: zfsboot1 zfsboot2 50ca987d46SWarner Losh cat zfsboot1 zfsboot2 > zfsboot 51ca987d46SWarner Losh 52ca987d46SWarner LoshCLEANFILES+= zfsboot1 zfsldr.out zfsldr.o 53ca987d46SWarner Losh 54ca987d46SWarner Loshzfsboot1: zfsldr.out 55ca987d46SWarner Losh ${OBJCOPY} -S -O binary zfsldr.out ${.TARGET} 56ca987d46SWarner Losh 57ca987d46SWarner Loshzfsldr.out: zfsldr.o 58a2037dbaSDimitry Andric ${LD} ${LD_FLAGS} -e start --defsym ORG=${ORG1} -T ${LDSCRIPT} -o ${.TARGET} zfsldr.o 59ca987d46SWarner Losh 60b4cb3fe0SToomas SoomeOBJS= zfsboot.o sio.o cons.o bcache.o devopen.o disk.o part.o zfs_cmd.o misc.o 61ca987d46SWarner LoshCLEANFILES+= zfsboot2 zfsboot.ld zfsboot.ldr zfsboot.bin zfsboot.out \ 623830659eSToomas Soome ${OBJS} 63ca987d46SWarner Losh 646f3d4ec8SAllan Jude# We currently allow 256k bytes for zfsboot - in practice it could be 65ca987d46SWarner Losh# any size up to 3.5Mb but keeping it fixed size simplifies zfsldr. 66ca987d46SWarner Losh# 676f3d4ec8SAllan JudeBOOT2SIZE= 262144 68ca987d46SWarner Losh 693830659eSToomas Soome# i386 standalone support library 703830659eSToomas SoomeLIBI386= ${BOOTOBJ}/i386/libi386/libi386.a 713830659eSToomas Soome 72ca987d46SWarner Loshzfsboot2: zfsboot.ld 73ca987d46SWarner Losh @set -- `ls -l ${.ALLSRC}`; x=$$((${BOOT2SIZE}-$$5)); \ 74ca987d46SWarner Losh echo "$$x bytes available"; test $$x -ge 0 7587c5e64cSAlex Richardson ${DD} if=${.ALLSRC} of=${.TARGET} bs=${BOOT2SIZE} conv=sync 76ca987d46SWarner Losh 77ca987d46SWarner Loshzfsboot.ld: zfsboot.ldr zfsboot.bin ${BTXKERN} 78ca987d46SWarner Losh btxld -v -E ${ORG2} -f bin -b ${BTXKERN} -l zfsboot.ldr \ 79ca987d46SWarner Losh -o ${.TARGET} -P 1 zfsboot.bin 80ca987d46SWarner Losh 81ca987d46SWarner Loshzfsboot.ldr: 82a5ebda46SWarner Losh :> ${.TARGET} 83ca987d46SWarner Losh 84ca987d46SWarner Loshzfsboot.bin: zfsboot.out 85ca987d46SWarner Losh ${OBJCOPY} -S -O binary zfsboot.out ${.TARGET} 86ca987d46SWarner Losh 873830659eSToomas Soomezfsboot.out: ${BTXCRT} ${OBJS} 883830659eSToomas Soome ${LD} ${LD_FLAGS} --defsym ORG=${ORG2} -T ${LDSCRIPT} -o ${.TARGET} ${.ALLSRC} ${LIBI386} ${LIBSA32} 89ca987d46SWarner Losh 90ca987d46SWarner LoshSRCS= zfsboot.c 91ca987d46SWarner Losh 92ca987d46SWarner Losh.include <bsd.prog.mk> 93