1999-08-27 21:08:13 -04:00
|
|
|
# $FreeBSD$
|
1998-10-13 20:24:16 -04:00
|
|
|
|
2004-02-06 16:58:32 -05:00
|
|
|
FILES= boot boot1 boot2
|
1998-10-12 17:16:26 -04:00
|
|
|
|
2001-07-31 15:50:09 -04:00
|
|
|
NM?= nm
|
|
|
|
|
|
1999-07-19 21:19:23 -04:00
|
|
|
# A value of 0x80 enables LBA support.
|
2000-06-26 18:57:16 -04:00
|
|
|
B1FLAGS= 0x80
|
1999-07-19 21:19:23 -04:00
|
|
|
|
1999-01-10 09:48:05 -05:00
|
|
|
BOOT_COMCONSOLE_PORT?= 0x3f8
|
|
|
|
|
BOOT_COMCONSOLE_SPEED?= 9600
|
1998-10-20 16:20:48 -04:00
|
|
|
B2SIOFMT?= 0x3
|
|
|
|
|
|
2002-10-08 08:09:16 -04:00
|
|
|
REL1= 0x700
|
1998-10-12 17:16:26 -04:00
|
|
|
ORG1= 0x7c00
|
2002-10-08 14:19:02 -04:00
|
|
|
ORG2= 0x2000
|
1998-10-12 17:16:26 -04:00
|
|
|
|
2004-02-06 16:58:32 -05:00
|
|
|
# Decide level of UFS support.
|
2002-12-17 16:10:34 -05:00
|
|
|
BOOT2_UFS?= UFS1_AND_UFS2
|
2004-02-06 16:58:32 -05:00
|
|
|
#BOOT2_UFS?= UFS2_ONLY
|
|
|
|
|
#BOOT2_UFS?= UFS1_ONLY
|
|
|
|
|
|
2004-02-07 09:32:06 -05:00
|
|
|
CFLAGS= -Os \
|
2002-12-17 16:10:34 -05:00
|
|
|
-fno-guess-branch-probability -fomit-frame-pointer\
|
2002-12-20 21:03:31 -05:00
|
|
|
-mno-align-long-strings \
|
2002-05-10 00:05:42 -04:00
|
|
|
-mrtd \
|
2002-12-14 14:44:13 -05:00
|
|
|
-D${BOOT2_UFS} \
|
2004-02-17 02:13:04 -05:00
|
|
|
-DFLAGS=${B1FLAGS} \
|
|
|
|
|
-DSIOPRT=${BOOT_COMCONSOLE_PORT} \
|
|
|
|
|
-DSIOFMT=${B2SIOFMT} \
|
|
|
|
|
-DSIOSPD=${BOOT_COMCONSOLE_SPEED} \
|
2002-06-05 07:10:38 -04:00
|
|
|
-I${.CURDIR}/../../common \
|
2002-05-09 20:53:45 -04:00
|
|
|
-I${.CURDIR}/../btx/lib -I. \
|
1998-10-12 17:16:26 -04:00
|
|
|
-Wall -Waggregate-return -Wbad-function-cast -Wcast-align \
|
|
|
|
|
-Wmissing-declarations -Wmissing-prototypes -Wnested-externs \
|
|
|
|
|
-Wpointer-arith -Wshadow -Wstrict-prototypes -Wwrite-strings
|
|
|
|
|
|
2004-02-09 09:11:58 -05:00
|
|
|
LDFLAGS=-static -N --gc-sections
|
1998-10-12 17:16:26 -04:00
|
|
|
|
2004-02-06 16:58:32 -05:00
|
|
|
# Pick up ../Makefile.inc early.
|
|
|
|
|
.include <bsd.init.mk>
|
|
|
|
|
|
|
|
|
|
CLEANFILES= boot
|
2003-01-26 08:33:57 -05:00
|
|
|
|
|
|
|
|
boot: boot1 boot2
|
|
|
|
|
cat boot1 boot2 > boot
|
1998-10-12 17:16:26 -04:00
|
|
|
|
2004-02-06 16:58:32 -05:00
|
|
|
CLEANFILES+= boot1 boot1.out boot1.o
|
|
|
|
|
|
1998-10-12 17:16:26 -04:00
|
|
|
boot1: boot1.out
|
1998-10-13 14:29:18 -04:00
|
|
|
objcopy -S -O binary boot1.out ${.TARGET}
|
1998-10-12 17:16:26 -04:00
|
|
|
|
|
|
|
|
boot1.out: boot1.o
|
|
|
|
|
${LD} ${LDFLAGS} -e start -Ttext ${ORG1} -o ${.TARGET} boot1.o
|
|
|
|
|
|
2004-02-06 16:58:32 -05: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 17:39:59 -04:00
|
|
|
|
2004-02-06 16:58:32 -05: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 17:16:26 -04:00
|
|
|
|
|
|
|
|
boot2.ldr:
|
2004-02-06 16:58:32 -05:00
|
|
|
dd if=/dev/zero of=${.TARGET} bs=276 count=1
|
1998-10-12 17:16:26 -04:00
|
|
|
|
|
|
|
|
boot2.bin: boot2.out
|
1998-10-13 14:29:18 -04:00
|
|
|
objcopy -S -O binary boot2.out ${.TARGET}
|
1998-10-12 17:16:26 -04:00
|
|
|
|
2004-02-06 16:58:32 -05:00
|
|
|
boot2.out: ${BTXCRT} boot2.o sio.o
|
|
|
|
|
${LD} ${LDFLAGS} -Ttext ${ORG2} -o ${.TARGET} ${.ALLSRC}
|
2001-07-31 15:50:09 -04:00
|
|
|
|
2004-02-06 16:58:32 -05:00
|
|
|
boot2.o: boot2.s
|
1998-10-12 17:16:26 -04:00
|
|
|
|
2004-02-07 08:38:47 -05:00
|
|
|
SRCS= boot2.c boot2.h
|
|
|
|
|
|
2004-02-06 16:58:32 -05: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-13 20:24:16 -04:00
|
|
|
|
2004-02-06 16:58:32 -05: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-25 23:51:57 -04:00
|
|
|
|
2004-02-07 03:10:07 -05:00
|
|
|
.if ${MACHINE_ARCH} == "amd64"
|
2004-02-07 18:30:45 -05:00
|
|
|
beforedepend boot2.s: machine
|
2004-02-07 03:10:07 -05:00
|
|
|
CLEANFILES+= machine
|
2003-06-25 23:51:57 -04:00
|
|
|
machine:
|
|
|
|
|
ln -sf ${.CURDIR}/../../../i386/include machine
|
|
|
|
|
.endif
|
|
|
|
|
|
2004-02-06 16:58:32 -05:00
|
|
|
.include <bsd.prog.mk>
|