1
2PROG?=	boot0
3STRIP=
4BINMODE=${NOBINMODE}
5SRCS=	${PROG}.S
6
7# Additional options that you can specify with make OPTS="..."
8# (these only apply to boot0.S)
9#
10#	-DVOLUME_SERIAL	support volume serial number (NT, XP, Vista)
11#	-DSIO		do I/O using COM1:
12#	-DPXE		fallback to INT18/PXE with F6
13#	-DCHECK_DRIVE	enable checking drive number
14#	-DONLY_F_KEYS	accept only Fx keys in console
15#	-DTEST		print drive number on entry
16#
17OPTS ?= -DVOLUME_SERIAL -DPXE
18CFLAGS += ${OPTS}
19
20# Flags used in the boot0.S code:
21#   0x0f	all valid partitions enabled.
22#   0x80	'packet', use BIOS EDD (LBA) extensions instead of CHS
23#		to read from disk. boot0.S does not check that the extensions
24#		are supported, but all modern BIOSes should have them.
25#   0x40	'noupdate', disable writing boot0 back to disk so that
26#		the current selection is not preserved across reboots.
27#   0x20	'setdrv', override the drive number supplied by the bios
28#		with the one in the boot sector.
29
30# Default boot flags:
31BOOT_BOOT0_FLAGS?=	0x8f
32
33# The number of timer ticks to wait for a keypress before assuming the default
34# selection.  Since there are 18.2 ticks per second, the default value of
35# 0xb6 (182d) corresponds to 10 seconds.
36BOOT_BOOT0_TICKS?=	0xb6
37
38# The BIOS loads boot0 to the hardcoded address 0x7c00.  boot0 copies
39# itself to this alternate base address before continuing execution so
40# that next level boot blocks can be loaded at the 0x7c00 address they
41# expect.
42ORG=	0x600
43
44# Comm settings for boot0sio.
45#
46# boot0sio uses BIOS INT $0x14 for serial ports, we can only support these
47# baudrates due to INT14's limited interface. In addition, if
48# BOOT_BOOT0_COMCONSOLE_SPEED=0, then the baud rate and frame format will remain
49# unchanged. Some BIOSes initialize the serial ports to 115200, and this may
50# allow boot0sio access at that rate if so.
51#
52# Bit(s) Description
53# 7-5    data rate (110,150,300,600,1200,2400,4800,9600 bps)
54# 4-3    parity (00 or 10 = none, 01 = odd, 11 = even)
55# 2      stop bits (set = 2, clear = 1)
56# 1-0    data bits (00 = 5, 01 = 6, 10 = 7, 11 = 8)
57.if !defined(BOOT_BOOT0_COMCONSOLE_SPEED)
58BOOT_COMCONSOLE_SPEED?=	9600	# BIOS interfaces do not support higher rates.
59.if ${BOOT_COMCONSOLE_SPEED} == 9600
60BOOT_BOOT0_COMCONSOLE_SPEED=	"7 << 5 + 3"
61.elif ${BOOT_COMCONSOLE_SPEED} == 4800
62BOOT_BOOT0_COMCONSOLE_SPEED=	"6 << 5 + 3"
63.elif ${BOOT_COMCONSOLE_SPEED} == 2400
64BOOT_BOOT0_COMCONSOLE_SPEED=	"5 << 5 + 3"
65.elif ${BOOT_COMCONSOLE_SPEED} == 1200
66BOOT_BOOT0_COMCONSOLE_SPEED=	"4 << 5 + 3"
67.elif ${BOOT_COMCONSOLE_SPEED} == 600
68BOOT_BOOT0_COMCONSOLE_SPEED=	"3 << 5 + 3"
69.elif ${BOOT_COMCONSOLE_SPEED} == 300
70BOOT_BOOT0_COMCONSOLE_SPEED=	"2 << 5 + 3"
71.elif ${BOOT_COMCONSOLE_SPEED} == 150
72BOOT_BOOT0_COMCONSOLE_SPEED=	"1 << 5 + 3"
73.elif ${BOOT_COMCONSOLE_SPEED} == 110
74BOOT_BOOT0_COMCONSOLE_SPEED=	"0 << 5 + 3"
75.else
76BOOT_BOOT0_COMCONSOLE_SPEED=	"7 << 5 + 3"
77.endif
78.endif
79
80CFLAGS+=-DFLAGS=${BOOT_BOOT0_FLAGS} \
81	-DTICKS=${BOOT_BOOT0_TICKS} \
82	-DCOMSPEED=${BOOT_BOOT0_COMCONSOLE_SPEED}
83
84LDFLAGS+=${LDFLAGS_BIN}
85
86.include <bsd.prog.mk>
87