5 FILES= boot boot1 boot2
9 # A value of 0x80 enables LBA support.
10 BOOT_BOOT1_FLAGS?= 0x80
12 BOOT_COMCONSOLE_PORT?= 0x3f8
13 BOOT_COMCONSOLE_SPEED?= 9600
20 # Decide level of UFS support.
21 BOOT2_UFS?= UFS1_AND_UFS2
22 #BOOT2_UFS?= UFS2_ONLY
23 #BOOT2_UFS?= UFS1_ONLY
26 -fomit-frame-pointer \
31 -DFLAGS=${BOOT_BOOT1_FLAGS} \
32 -DSIOPRT=${BOOT_COMCONSOLE_PORT} \
33 -DSIOFMT=${B2SIOFMT} \
34 -DSIOSPD=${BOOT_COMCONSOLE_SPEED} \
35 -I${.CURDIR}/../../common \
36 -I${.CURDIR}/../btx/lib -I. \
37 -Wall -Waggregate-return -Wbad-function-cast -Wcast-align \
38 -Wmissing-declarations -Wmissing-prototypes -Wnested-externs \
39 -Wpointer-arith -Wshadow -Wstrict-prototypes -Wwrite-strings \
43 CFLAGS.gcc+= -fno-guess-branch-probability \
45 --param max-inline-insns-single=100
46 .if ${COMPILER_TYPE} == "gcc" && ${COMPILER_VERSION} <= 40201
47 CFLAGS.gcc+= -mno-align-long-strings
50 LD_FLAGS=-static -N --gc-sections
52 # Pick up ../Makefile.inc early.
53 .include <bsd.init.mk>
58 cat boot1 boot2 > boot
60 CLEANFILES+= boot1 boot1.out boot1.o
63 ${OBJCOPY} -S -O binary boot1.out ${.TARGET}
66 ${LD} ${LD_FLAGS} -e start -Ttext ${ORG1} -o ${.TARGET} boot1.o
68 CLEANFILES+= boot2 boot2.ld boot2.ldr boot2.bin boot2.out boot2.o \
69 boot2.s boot2.s.tmp boot2.h sio.o
74 @set -- `ls -l ${.ALLSRC}`; x=$$((${BOOT2SIZE}-$$5)); \
75 echo "$$x bytes available"; test $$x -ge 0
76 ${DD} if=${.ALLSRC} of=${.TARGET} obs=${BOOT2SIZE} conv=osync
78 boot2.ld: boot2.ldr boot2.bin ${BTXKERN}
79 btxld -v -E ${ORG2} -f bin -b ${BTXKERN} -l boot2.ldr \
80 -o ${.TARGET} -P 1 boot2.bin
83 ${DD} if=/dev/zero of=${.TARGET} bs=512 count=1
86 ${OBJCOPY} -S -O binary boot2.out ${.TARGET}
88 boot2.out: ${BTXCRT} boot2.o sio.o
89 ${LD} ${LD_FLAGS} -Ttext ${ORG2} -o ${.TARGET} ${.ALLSRC}
92 ${CC} ${ACFLAGS} -c boot2.s
96 boot2.s: boot2.c boot2.h ${.CURDIR}/../../common/ufsread.c
97 ${CC} ${CFLAGS} -S -o boot2.s.tmp ${.CURDIR}/boot2.c
98 sed -e '/align/d' -e '/nop/d' < boot2.s.tmp > boot2.s
102 ${NM} -t d ${.ALLSRC} | awk '/([0-9])+ T xread/ \
104 printf("#define XREADORG %#x\n", REL1 + x) }' \
105 ORG1=`printf "%d" ${ORG1}` \
106 REL1=`printf "%d" ${REL1}` > ${.TARGET}
108 .if ${MACHINE_CPUARCH} == "amd64"
109 beforedepend boot2.s: machine
112 ln -sf ${.CURDIR}/../../../i386/include machine
115 .include <bsd.prog.mk>
117 # XXX: clang integrated-as doesn't grok .codeNN directives yet
118 CFLAGS.boot1.S= ${CLANG_NO_IAS}
119 CFLAGS+= ${CFLAGS.${.IMPSRC:T}}