150477Speter# $FreeBSD: releng/11.0/sys/boot/i386/boot2/Makefile 297283 2016-03-26 03:46:12Z bdrewery $ 240269Srnordier 3211571Srpaulo.include <bsd.own.mk> 4211571Srpaulo 5125537SruFILES= boot boot1 boot2 640326Srnordier 780751SjhbNM?= nm 880751Sjhb 948919Srnordier# A value of 0x80 enables LBA support. 10134382SyarBOOT_BOOT1_FLAGS?= 0x80 1148919Srnordier 1242480SrnordierBOOT_COMCONSOLE_PORT?= 0x3f8 1342480SrnordierBOOT_COMCONSOLE_SPEED?= 9600 1440541SrnordierB2SIOFMT?= 0x3 1540541Srnordier 16104673SgreenREL1= 0x700 1740269SrnordierORG1= 0x7c00 18104683SjhbORG2= 0x2000 1940269Srnordier 20125537Sru# Decide level of UFS support. 21108000SimpBOOT2_UFS?= UFS1_AND_UFS2 22125537Sru#BOOT2_UFS?= UFS2_ONLY 23125537Sru#BOOT2_UFS?= UFS1_ONLY 24104635Sphk 25276479SdimCFLAGS= -fomit-frame-pointer \ 2696327Sjhb -mrtd \ 27220337Srdivacky -mregparm=3 \ 28221177Sjhb -DUSE_XREAD \ 29107879Sphk -D${BOOT2_UFS} \ 30134382Syar -DFLAGS=${BOOT_BOOT1_FLAGS} \ 31125932Sru -DSIOPRT=${BOOT_COMCONSOLE_PORT} \ 32125932Sru -DSIOFMT=${B2SIOFMT} \ 33125932Sru -DSIOSPD=${BOOT_COMCONSOLE_SPEED} \ 3497860Sphk -I${.CURDIR}/../../common \ 3596306Sobrien -I${.CURDIR}/../btx/lib -I. \ 3640269Srnordier -Wall -Waggregate-return -Wbad-function-cast -Wcast-align \ 3740269Srnordier -Wmissing-declarations -Wmissing-prototypes -Wnested-externs \ 38169732Skan -Wpointer-arith -Wshadow -Wstrict-prototypes -Wwrite-strings \ 39272249Snyan -Winline 4040269Srnordier 41276479SdimCFLAGS.gcc+= -Os \ 42276479Sdim -fno-guess-branch-probability \ 43259913Sdim -fno-unit-at-a-time \ 44260334Sdim --param max-inline-insns-single=100 45279598Sdim.if ${COMPILER_TYPE} == "gcc" && ${COMPILER_VERSION} <= 40201 46279598SdimCFLAGS.gcc+= -mno-align-long-strings 47279598Sdim.endif 48259913Sdim 49276479SdimCFLAGS.clang+= -Oz ${CLANG_OPT_SMALL} 50265400Simp 51260095SdimLD_FLAGS=-static -N --gc-sections 5240269Srnordier 53125537Sru# Pick up ../Makefile.inc early. 54125537Sru.include <bsd.init.mk> 5540269Srnordier 56125537SruCLEANFILES= boot 57125537Sru 58109886Sphkboot: boot1 boot2 59109886Sphk cat boot1 boot2 > boot 60109886Sphk 61125537SruCLEANFILES+= boot1 boot1.out boot1.o 62125537Sru 6340269Srnordierboot1: boot1.out 64280980Sdim ${OBJCOPY} -S -O binary boot1.out ${.TARGET} 6540269Srnordier 6640269Srnordierboot1.out: boot1.o 67260095Sdim ${LD} ${LD_FLAGS} -e start -Ttext ${ORG1} -o ${.TARGET} boot1.o 6840269Srnordier 69125537SruCLEANFILES+= boot2 boot2.ld boot2.ldr boot2.bin boot2.out boot2.o \ 70125537Sru boot2.s boot2.s.tmp boot2.h sio.o 7196424Speter 72125537Sruboot2: boot2.ld 73125537Sru @set -- `ls -l boot2.ld`; x=$$((7680-$$5)); \ 74125537Sru echo "$$x bytes available"; test $$x -ge 0 75295757Semaste dd if=boot2.ld of=${.TARGET} obs=7680 conv=osync status=none 7680751Sjhb 77125537Sruboot2.ld: boot2.ldr boot2.bin ${BTXKERN} 78125537Sru btxld -v -E ${ORG2} -f bin -b ${BTXKERN} -l boot2.ldr \ 79125537Sru -o ${.TARGET} -P 1 boot2.bin 8040269Srnordier 8140269Srnordierboot2.ldr: 82295757Semaste dd if=/dev/zero of=${.TARGET} bs=512 count=1 status=none 8340269Srnordier 8440269Srnordierboot2.bin: boot2.out 85280980Sdim ${OBJCOPY} -S -O binary boot2.out ${.TARGET} 8640269Srnordier 87125537Sruboot2.out: ${BTXCRT} boot2.o sio.o 88260095Sdim ${LD} ${LD_FLAGS} -Ttext ${ORG2} -o ${.TARGET} ${.ALLSRC} 8940269Srnordier 90125537Sruboot2.o: boot2.s 91224131Sdim ${CC} ${ACFLAGS} -c boot2.s 9280751Sjhb 93125564SruSRCS= boot2.c boot2.h 94125564Sru 95125537Sruboot2.s: boot2.c boot2.h ${.CURDIR}/../../common/ufsread.c 96125537Sru ${CC} ${CFLAGS} -S -o boot2.s.tmp ${.CURDIR}/boot2.c 97125537Sru sed -e '/align/d' -e '/nop/d' < boot2.s.tmp > boot2.s 98125537Sru rm -f boot2.s.tmp 9940404Srnordier 100125537Sruboot2.h: boot1.out 101125537Sru ${NM} -t d ${.ALLSRC} | awk '/([0-9])+ T xread/ \ 102125537Sru { x = $$1 - ORG1; \ 103125537Sru printf("#define XREADORG %#x\n", REL1 + x) }' \ 104125537Sru ORG1=`printf "%d" ${ORG1}` \ 105125537Sru REL1=`printf "%d" ${REL1}` > ${.TARGET} 10640326Srnordier 107211677Simp.if ${MACHINE_CPUARCH} == "amd64" 108125581Srubeforedepend boot2.s: machine 109125556SruCLEANFILES+= machine 110291320Sbdrewerymachine: ${.CURDIR}/../../../i386/include .NOMETA 111291320Sbdrewery ln -sf ${.ALLSRC} ${.TARGET} 112116864Speter.endif 113116864Speter 114125537Sru.include <bsd.prog.mk> 115232263Sdim 116232263Sdim# XXX: clang integrated-as doesn't grok .codeNN directives yet 117232263SdimCFLAGS.boot1.S= ${CLANG_NO_IAS} 118