1# $FreeBSD$ 2 3.include <bsd.init.mk> 4 5FILES= boot boot1 boot2 6 7# A value of 0x80 enables LBA support. 8BOOT_BOOT1_FLAGS?= 0x80 9 10BOOT_COMCONSOLE_PORT?= 0x3f8 11BOOT_COMCONSOLE_SPEED?= 9600 12B2SIOFMT?= 0x3 13 14REL1= 0x700 15ORG1= 0x7c00 16ORG2= 0x2000 17 18# Decide level of UFS support. 19BOOT2_UFS?= UFS1_AND_UFS2 20#BOOT2_UFS?= UFS2_ONLY 21#BOOT2_UFS?= UFS1_ONLY 22 23CFLAGS+=-fomit-frame-pointer \ 24 -mrtd \ 25 -mregparm=3 \ 26 -D${BOOT2_UFS} \ 27 -DFLAGS=${BOOT_BOOT1_FLAGS} \ 28 -DSIOPRT=${BOOT_COMCONSOLE_PORT} \ 29 -DSIOFMT=${B2SIOFMT} \ 30 -DSIOSPD=${BOOT_COMCONSOLE_SPEED} \ 31 -I${LDRSRC} \ 32 -Wall -Waggregate-return -Wbad-function-cast -Wno-cast-align \ 33 -Wmissing-declarations -Wmissing-prototypes -Wnested-externs \ 34 -Wpointer-arith -Wshadow -Wstrict-prototypes -Wwrite-strings 35 36CFLAGS.gcc+= -Os \ 37 -fno-asynchronous-unwind-tables \ 38 --param max-inline-insns-single=100 39 40CFLAGS.clang+= -Oz ${CLANG_OPT_SMALL} 41 42LD_FLAGS+=${LD_FLAGS_BIN} 43 44CLEANFILES+= boot 45 46boot: boot1 boot2 47 cat boot1 boot2 > boot 48 49CLEANFILES+= boot1 boot1.out boot1.o 50 51boot1: boot1.out 52 ${OBJCOPY} -S -O binary boot1.out ${.TARGET} 53 54boot1.out: boot1.o 55 ${LD} ${LD_FLAGS} -e start --defsym ORG=${ORG1} -T ${LDSCRIPT} -o ${.TARGET} boot1.o 56 57CLEANFILES+= boot2 boot2.ld boot2.ldr boot2.bin boot2.out boot2.o \ 58 boot2.h sio.o 59 60BOOT2SIZE= 7680 61 62boot2: boot2.ld 63 @set -- `ls -l ${.ALLSRC}`; x=$$((${BOOT2SIZE}-$$5)); \ 64 echo "$$x bytes available"; test $$x -ge 0 65 ${DD} if=${.ALLSRC} of=${.TARGET} bs=${BOOT2SIZE} conv=sync 66 67boot2.ld: boot2.ldr boot2.bin ${BTXKERN} 68 btxld -v -E ${ORG2} -f bin -b ${BTXKERN} -l boot2.ldr \ 69 -o ${.TARGET} -P 1 boot2.bin 70 71boot2.ldr: 72 ${DD} if=/dev/zero of=${.TARGET} bs=512 count=1 73 74boot2.bin: boot2.out 75 ${OBJCOPY} -S -O binary boot2.out ${.TARGET} 76 77# For __ashldi3 78.PATH: ${SRCTOP}/contrib/llvm-project/compiler-rt/lib/builtins 79CFLAGS.ashldi3.c= -Wno-missing-prototypes -Wno-missing-declarations 80CLEANFILES+= ashldi3.o 81 82boot2.out: ${BTXCRT} boot2.o sio.o ashldi3.o 83 ${LD} ${LD_FLAGS} --defsym ORG=${ORG2} -T ${LDSCRIPT} -o ${.TARGET} ${.ALLSRC} 84 85SRCS= boot2.c boot2.h 86 87boot2.h: boot1.out 88 ${NM} -t d ${.ALLSRC} | awk '/([0-9])+ T xread/ \ 89 { x = $$1 - ORG1; \ 90 printf("#define XREADORG %#x\n", REL1 + x) }' \ 91 ORG1=`printf "%d" ${ORG1}` \ 92 REL1=`printf "%d" ${REL1}` > ${.TARGET} 93 94.include <bsd.prog.mk> 95