1999-08-28 01:08:13 +00:00
|
|
|
# $FreeBSD$
|
1998-10-14 00:24:16 +00:00
|
|
|
|
2010-08-21 15:01:59 +00:00
|
|
|
.include <bsd.own.mk>
|
|
|
|
|
2004-02-06 21:58:32 +00:00
|
|
|
FILES= boot boot1 boot2
|
1998-10-12 21:16:26 +00:00
|
|
|
|
2001-07-31 19:50:09 +00:00
|
|
|
NM?= nm
|
|
|
|
|
1999-07-20 01:19:23 +00:00
|
|
|
# A value of 0x80 enables LBA support.
|
2004-08-27 15:01:56 +00:00
|
|
|
BOOT_BOOT1_FLAGS?= 0x80
|
1999-07-20 01:19:23 +00:00
|
|
|
|
1999-01-10 14:48:05 +00:00
|
|
|
BOOT_COMCONSOLE_PORT?= 0x3f8
|
|
|
|
BOOT_COMCONSOLE_SPEED?= 9600
|
1998-10-20 20:20:48 +00:00
|
|
|
B2SIOFMT?= 0x3
|
|
|
|
|
2002-10-08 12:09:16 +00:00
|
|
|
REL1= 0x700
|
1998-10-12 21:16:26 +00:00
|
|
|
ORG1= 0x7c00
|
2002-10-08 18:19:02 +00:00
|
|
|
ORG2= 0x2000
|
1998-10-12 21:16:26 +00:00
|
|
|
|
2004-02-06 21:58:32 +00:00
|
|
|
# Decide level of UFS support.
|
2002-12-17 21:10:34 +00:00
|
|
|
BOOT2_UFS?= UFS1_AND_UFS2
|
2004-02-06 21:58:32 +00:00
|
|
|
#BOOT2_UFS?= UFS2_ONLY
|
|
|
|
#BOOT2_UFS?= UFS1_ONLY
|
|
|
|
|
2004-02-07 14:32:06 +00:00
|
|
|
CFLAGS= -Os \
|
2004-07-30 04:27:20 +00:00
|
|
|
-fno-guess-branch-probability \
|
|
|
|
-fomit-frame-pointer \
|
|
|
|
-fno-unit-at-a-time \
|
2002-12-21 02:03:31 +00:00
|
|
|
-mno-align-long-strings \
|
2002-05-10 04:05:42 +00:00
|
|
|
-mrtd \
|
2011-04-04 18:23:55 +00:00
|
|
|
-mregparm=3 \
|
2011-04-28 17:44:24 +00:00
|
|
|
-DUSE_XREAD \
|
2002-12-14 19:44:13 +00:00
|
|
|
-D${BOOT2_UFS} \
|
2004-08-27 15:01:56 +00:00
|
|
|
-DFLAGS=${BOOT_BOOT1_FLAGS} \
|
2004-02-17 07:13:04 +00:00
|
|
|
-DSIOPRT=${BOOT_COMCONSOLE_PORT} \
|
|
|
|
-DSIOFMT=${B2SIOFMT} \
|
|
|
|
-DSIOSPD=${BOOT_COMCONSOLE_SPEED} \
|
2002-06-05 11:10:38 +00:00
|
|
|
-I${.CURDIR}/../../common \
|
2002-05-10 00:53:45 +00:00
|
|
|
-I${.CURDIR}/../btx/lib -I. \
|
1998-10-12 21:16:26 +00:00
|
|
|
-Wall -Waggregate-return -Wbad-function-cast -Wcast-align \
|
|
|
|
-Wmissing-declarations -Wmissing-prototypes -Wnested-externs \
|
2007-05-19 05:07:47 +00:00
|
|
|
-Wpointer-arith -Wshadow -Wstrict-prototypes -Wwrite-strings \
|
2012-02-28 18:30:18 +00:00
|
|
|
-Winline --param max-inline-insns-single=100 \
|
|
|
|
${CLANG_OPT_SMALL}
|
2011-05-02 21:13:08 +00:00
|
|
|
|
2004-02-09 14:11:58 +00:00
|
|
|
LDFLAGS=-static -N --gc-sections
|
1998-10-12 21:16:26 +00:00
|
|
|
|
2004-02-06 21:58:32 +00:00
|
|
|
# Pick up ../Makefile.inc early.
|
|
|
|
.include <bsd.init.mk>
|
|
|
|
|
|
|
|
CLEANFILES= boot
|
2003-01-26 13:33:57 +00:00
|
|
|
|
|
|
|
boot: boot1 boot2
|
|
|
|
cat boot1 boot2 > boot
|
1998-10-12 21:16:26 +00:00
|
|
|
|
2004-02-06 21:58:32 +00:00
|
|
|
CLEANFILES+= boot1 boot1.out boot1.o
|
|
|
|
|
1998-10-12 21:16:26 +00:00
|
|
|
boot1: boot1.out
|
1998-10-13 18:29:18 +00:00
|
|
|
objcopy -S -O binary boot1.out ${.TARGET}
|
1998-10-12 21:16:26 +00:00
|
|
|
|
|
|
|
boot1.out: boot1.o
|
|
|
|
${LD} ${LDFLAGS} -e start -Ttext ${ORG1} -o ${.TARGET} boot1.o
|
|
|
|
|
2004-02-06 21:58:32 +00:00
|
|
|
CLEANFILES+= boot2 boot2.ld boot2.ldr boot2.bin boot2.out boot2.o \
|
|
|
|
boot2.s boot2.s.tmp boot2.h sio.o
|
2002-05-11 21:39:59 +00:00
|
|
|
|
2004-02-06 21:58:32 +00:00
|
|
|
boot2: boot2.ld
|
|
|
|
@set -- `ls -l boot2.ld`; x=$$((7680-$$5)); \
|
|
|
|
echo "$$x bytes available"; test $$x -ge 0
|
|
|
|
dd if=boot2.ld of=${.TARGET} obs=7680 conv=osync
|
|
|
|
|
|
|
|
boot2.ld: boot2.ldr boot2.bin ${BTXKERN}
|
|
|
|
btxld -v -E ${ORG2} -f bin -b ${BTXKERN} -l boot2.ldr \
|
|
|
|
-o ${.TARGET} -P 1 boot2.bin
|
1998-10-12 21:16:26 +00:00
|
|
|
|
|
|
|
boot2.ldr:
|
2009-03-07 22:05:58 +00:00
|
|
|
dd if=/dev/zero of=${.TARGET} bs=512 count=1
|
1998-10-12 21:16:26 +00:00
|
|
|
|
|
|
|
boot2.bin: boot2.out
|
1998-10-13 18:29:18 +00:00
|
|
|
objcopy -S -O binary boot2.out ${.TARGET}
|
1998-10-12 21:16:26 +00:00
|
|
|
|
2004-02-06 21:58:32 +00:00
|
|
|
boot2.out: ${BTXCRT} boot2.o sio.o
|
|
|
|
${LD} ${LDFLAGS} -Ttext ${ORG2} -o ${.TARGET} ${.ALLSRC}
|
2001-07-31 19:50:09 +00:00
|
|
|
|
2004-02-06 21:58:32 +00:00
|
|
|
boot2.o: boot2.s
|
2011-07-17 13:50:21 +00:00
|
|
|
${CC} ${ACFLAGS} -c boot2.s
|
1998-10-12 21:16:26 +00:00
|
|
|
|
2004-02-07 13:38:47 +00:00
|
|
|
SRCS= boot2.c boot2.h
|
|
|
|
|
2004-02-06 21:58:32 +00:00
|
|
|
boot2.s: boot2.c boot2.h ${.CURDIR}/../../common/ufsread.c
|
|
|
|
${CC} ${CFLAGS} -S -o boot2.s.tmp ${.CURDIR}/boot2.c
|
|
|
|
sed -e '/align/d' -e '/nop/d' < boot2.s.tmp > boot2.s
|
|
|
|
rm -f boot2.s.tmp
|
1998-10-14 00:24:16 +00:00
|
|
|
|
2004-02-06 21:58:32 +00:00
|
|
|
boot2.h: boot1.out
|
|
|
|
${NM} -t d ${.ALLSRC} | awk '/([0-9])+ T xread/ \
|
|
|
|
{ x = $$1 - ORG1; \
|
|
|
|
printf("#define XREADORG %#x\n", REL1 + x) }' \
|
|
|
|
ORG1=`printf "%d" ${ORG1}` \
|
|
|
|
REL1=`printf "%d" ${REL1}` > ${.TARGET}
|
2003-06-26 03:51:57 +00:00
|
|
|
|
2010-08-23 01:42:09 +00:00
|
|
|
.if ${MACHINE_CPUARCH} == "amd64"
|
2004-02-07 23:30:45 +00:00
|
|
|
beforedepend boot2.s: machine
|
2004-02-07 08:10:07 +00:00
|
|
|
CLEANFILES+= machine
|
2003-06-26 03:51:57 +00:00
|
|
|
machine:
|
|
|
|
ln -sf ${.CURDIR}/../../../i386/include machine
|
|
|
|
.endif
|
|
|
|
|
2004-02-06 21:58:32 +00:00
|
|
|
.include <bsd.prog.mk>
|
2012-02-28 18:30:18 +00:00
|
|
|
|
|
|
|
# XXX: clang integrated-as doesn't grok .codeNN directives yet
|
|
|
|
CFLAGS.boot1.S= ${CLANG_NO_IAS}
|
|
|
|
CFLAGS+= ${CFLAGS.${.IMPSRC:T}}
|