1999-08-28 01:08:13 +00:00
|
|
|
# $FreeBSD$
|
1998-10-14 00:24:16 +00:00
|
|
|
|
|
|
|
PROG= boot2
|
|
|
|
NOMAN=
|
|
|
|
STRIP=
|
|
|
|
BINDIR?= /boot
|
|
|
|
BINMODE= 444
|
|
|
|
CLEANFILES+= boot1 boot1.out boot1.o \
|
2001-07-31 19:50:09 +00:00
|
|
|
boot2.ldr boot2.bin boot2.ld boot2.out boot2.o boot2.h \
|
2002-05-13 16:16:00 +00:00
|
|
|
boot2.s sio.o
|
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.
|
2000-06-26 22:57:16 +00:00
|
|
|
B1FLAGS= 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
|
|
|
|
|
1998-10-12 21:16:26 +00:00
|
|
|
.if exists(${.OBJDIR}/../btx)
|
|
|
|
BTX= ${.OBJDIR}/../btx
|
|
|
|
.else
|
|
|
|
BTX= ${.CURDIR}/../btx
|
|
|
|
.endif
|
|
|
|
|
|
|
|
ORG1= 0x7c00
|
|
|
|
ORG2= 0x1000
|
|
|
|
|
2002-05-10 04:05:42 +00:00
|
|
|
CFLAGS= -elf -ffreestanding -Os -fno-builtin \
|
2002-05-12 15:45:28 +00:00
|
|
|
-fno-guess-branch-probability \
|
2002-05-10 04:05:42 +00:00
|
|
|
-mrtd \
|
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 \
|
|
|
|
-Wpointer-arith -Wshadow -Wstrict-prototypes -Wwrite-strings
|
|
|
|
|
2002-10-07 08:09:20 +00:00
|
|
|
CFLAGS+= -DUFS1_ONLY
|
|
|
|
|
1998-10-12 21:16:26 +00:00
|
|
|
LDFLAGS=-nostdlib -static -N
|
|
|
|
|
|
|
|
all: boot1 boot2
|
|
|
|
|
|
|
|
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
|
|
|
|
|
2000-05-23 12:18:49 +00:00
|
|
|
boot1.o: boot1.s
|
2002-10-07 20:56:09 +00:00
|
|
|
${CPP} ${CFLAGS} ${.IMPSRC} | \
|
|
|
|
${AS} ${AFLAGS} --defsym FLAGS=${B1FLAGS} -o ${.TARGET}
|
1998-10-12 21:16:26 +00:00
|
|
|
|
2002-06-05 12:30:45 +00:00
|
|
|
boot2.o: boot2.c ${.CURDIR}/../../common/ufsread.c
|
2002-05-11 21:39:59 +00:00
|
|
|
${CC} ${CFLAGS} -S -o boot2.s.tmp ${.IMPSRC}
|
|
|
|
sed -e '/align/d' -e '/nop/d' < boot2.s.tmp > boot2.s
|
|
|
|
rm -f boot2.s.tmp
|
|
|
|
${AS} ${AFLAGS} -o boot2.o boot2.s
|
|
|
|
|
2001-07-31 19:50:09 +00:00
|
|
|
boot2.h: boot1.out
|
|
|
|
${NM} -t d ${.ALLSRC} | awk '/([0-9])+ T xread/ \
|
|
|
|
{ x = $$1 - ORG1; printf("#define XREADORG 0x7%x\n", x) }' \
|
|
|
|
ORG1=`printf "%d" ${ORG1}` > boot2.h
|
|
|
|
|
2000-04-11 14:49:13 +00:00
|
|
|
boot2: boot2.ldr boot2.bin ${BTX}/btx/btx
|
1998-10-12 21:16:26 +00:00
|
|
|
btxld -v -E ${ORG2} -f bin -b ${BTX}/btx/btx -l boot2.ldr \
|
1998-10-13 21:35:42 +00:00
|
|
|
-o boot2.ld -P 1 boot2.bin
|
|
|
|
@ls -l boot2.ld | awk '{ x = 7680 - $$5; \
|
|
|
|
print x " bytes available"; if (x < 0) exit 1 }'
|
|
|
|
dd if=boot2.ld of=${.TARGET} obs=7680 conv=osync 2>/dev/null
|
1998-10-12 21:16:26 +00:00
|
|
|
|
|
|
|
boot2.ldr:
|
|
|
|
dd if=/dev/zero of=${.TARGET} bs=512 count=1 2>/dev/null
|
|
|
|
|
|
|
|
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
|
|
|
|
1998-10-15 20:04:21 +00:00
|
|
|
boot2.out: boot2.o sio.o
|
1998-10-12 21:16:26 +00:00
|
|
|
${LD} ${LDFLAGS} -Ttext ${ORG2} -o ${.TARGET} \
|
2002-06-21 11:00:00 +00:00
|
|
|
${BTX}/lib/crt0.o boot2.o sio.o
|
1998-10-15 20:04:21 +00:00
|
|
|
|
2001-07-31 19:50:09 +00:00
|
|
|
boot2.o: boot2.h
|
|
|
|
|
1998-10-15 20:04:21 +00:00
|
|
|
sio.o: sio.s
|
2000-05-23 12:18:49 +00:00
|
|
|
${AS} ${AFLAGS} --defsym SIOPRT=${BOOT_COMCONSOLE_PORT} \
|
|
|
|
--defsym SIOFMT=${B2SIOFMT} \
|
|
|
|
--defsym SIOSPD=${BOOT_COMCONSOLE_SPEED} \
|
|
|
|
${.IMPSRC} -o ${.TARGET}
|
1998-10-12 21:16:26 +00:00
|
|
|
|
1998-10-14 00:24:16 +00:00
|
|
|
install:
|
2002-07-29 09:40:17 +00:00
|
|
|
${INSTALL} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
|
1998-10-14 00:24:16 +00:00
|
|
|
boot1 ${DESTDIR}${BINDIR}/boot1
|
2002-07-29 09:40:17 +00:00
|
|
|
${INSTALL} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
|
1998-10-14 00:24:16 +00:00
|
|
|
boot2 ${DESTDIR}${BINDIR}/boot2
|
|
|
|
|
|
|
|
.include <bsd.prog.mk>
|