199767f8919635c4928607450d9e0abb932109ceToomas Soome# $FreeBSD$
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas SoomePROG?= boot0
199767f8919635c4928607450d9e0abb932109ceToomas SoomeSTRIP=
199767f8919635c4928607450d9e0abb932109ceToomas SoomeBINMODE=${NOBINMODE}
199767f8919635c4928607450d9e0abb932109ceToomas SoomeMAN=
199767f8919635c4928607450d9e0abb932109ceToomas SoomeSRCS= ${PROG}.S
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome# Additional options that you can specify with make OPTS="..."
199767f8919635c4928607450d9e0abb932109ceToomas Soome# (these only apply to boot0.S)
199767f8919635c4928607450d9e0abb932109ceToomas Soome#
199767f8919635c4928607450d9e0abb932109ceToomas Soome# -DVOLUME_SERIAL support volume serial number (NT, XP, Vista)
199767f8919635c4928607450d9e0abb932109ceToomas Soome# -DSIO do I/O using COM1:
199767f8919635c4928607450d9e0abb932109ceToomas Soome# -DPXE fallback to INT18/PXE with F6
199767f8919635c4928607450d9e0abb932109ceToomas Soome# -DCHECK_DRIVE enable checking drive number
199767f8919635c4928607450d9e0abb932109ceToomas Soome# -DONLY_F_KEYS accept only Fx keys in console
199767f8919635c4928607450d9e0abb932109ceToomas Soome# -DTEST print drive number on entry
199767f8919635c4928607450d9e0abb932109ceToomas Soome#
199767f8919635c4928607450d9e0abb932109ceToomas SoomeOPTS ?= -DVOLUME_SERIAL -DPXE
199767f8919635c4928607450d9e0abb932109ceToomas SoomeCFLAGS += ${OPTS}
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome# Flags used in the boot0.S code:
199767f8919635c4928607450d9e0abb932109ceToomas Soome# 0x0f all valid partitions enabled.
199767f8919635c4928607450d9e0abb932109ceToomas Soome# 0x80 'packet', use BIOS EDD (LBA) extensions instead of CHS
199767f8919635c4928607450d9e0abb932109ceToomas Soome# to read from disk. boot0.S does not check that the extensions
199767f8919635c4928607450d9e0abb932109ceToomas Soome# are supported, but all modern BIOSes should have them.
199767f8919635c4928607450d9e0abb932109ceToomas Soome# 0x40 'noupdate', disable writing boot0 back to disk so that
199767f8919635c4928607450d9e0abb932109ceToomas Soome# the current selection is not preserved across reboots.
199767f8919635c4928607450d9e0abb932109ceToomas Soome# 0x20 'setdrv', override the drive number supplied by the bios
199767f8919635c4928607450d9e0abb932109ceToomas Soome# with the one in the boot sector.
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome# Default boot flags:
199767f8919635c4928607450d9e0abb932109ceToomas SoomeBOOT_BOOT0_FLAGS?= 0x8f
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome# The number of timer ticks to wait for a keypress before assuming the default
199767f8919635c4928607450d9e0abb932109ceToomas Soome# selection. Since there are 18.2 ticks per second, the default value of
199767f8919635c4928607450d9e0abb932109ceToomas Soome# 0xb6 (182d) corresponds to 10 seconds.
199767f8919635c4928607450d9e0abb932109ceToomas SoomeBOOT_BOOT0_TICKS?= 0xb6
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome# The base address that we the boot0 code to to run it. Don't change this
199767f8919635c4928607450d9e0abb932109ceToomas Soome# unless you are glutton for punishment.
199767f8919635c4928607450d9e0abb932109ceToomas SoomeBOOT_BOOT0_ORG?= 0x600
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome# Comm settings for boot0sio.
199767f8919635c4928607450d9e0abb932109ceToomas Soome# Bit(s) Description
199767f8919635c4928607450d9e0abb932109ceToomas Soome# 7-5 data rate (110,150,300,600,1200,2400,4800,9600 bps)
199767f8919635c4928607450d9e0abb932109ceToomas Soome# 4-3 parity (00 or 10 = none, 01 = odd, 11 = even)
199767f8919635c4928607450d9e0abb932109ceToomas Soome# 2 stop bits (set = 2, clear = 1)
199767f8919635c4928607450d9e0abb932109ceToomas Soome# 1-0 data bits (00 = 5, 01 = 6, 10 = 7, 11 = 8)
199767f8919635c4928607450d9e0abb932109ceToomas Soome.if !defined(BOOT_BOOT0_COMCONSOLE_SPEED)
199767f8919635c4928607450d9e0abb932109ceToomas SoomeBOOT_COMCONSOLE_SPEED?= 9600
199767f8919635c4928607450d9e0abb932109ceToomas Soome.if ${BOOT_COMCONSOLE_SPEED} == 9600
199767f8919635c4928607450d9e0abb932109ceToomas SoomeBOOT_BOOT0_COMCONSOLE_SPEED= "7 << 5 + 3"
199767f8919635c4928607450d9e0abb932109ceToomas Soome.elif ${BOOT_COMCONSOLE_SPEED} == 4800
199767f8919635c4928607450d9e0abb932109ceToomas SoomeBOOT_BOOT0_COMCONSOLE_SPEED= "6 << 5 + 3"
199767f8919635c4928607450d9e0abb932109ceToomas Soome.elif ${BOOT_COMCONSOLE_SPEED} == 2400
199767f8919635c4928607450d9e0abb932109ceToomas SoomeBOOT_BOOT0_COMCONSOLE_SPEED= "5 << 5 + 3"
199767f8919635c4928607450d9e0abb932109ceToomas Soome.elif ${BOOT_COMCONSOLE_SPEED} == 1200
199767f8919635c4928607450d9e0abb932109ceToomas SoomeBOOT_BOOT0_COMCONSOLE_SPEED= "4 << 5 + 3"
199767f8919635c4928607450d9e0abb932109ceToomas Soome.elif ${BOOT_COMCONSOLE_SPEED} == 600
199767f8919635c4928607450d9e0abb932109ceToomas SoomeBOOT_BOOT0_COMCONSOLE_SPEED= "3 << 5 + 3"
199767f8919635c4928607450d9e0abb932109ceToomas Soome.elif ${BOOT_COMCONSOLE_SPEED} == 300
199767f8919635c4928607450d9e0abb932109ceToomas SoomeBOOT_BOOT0_COMCONSOLE_SPEED= "2 << 5 + 3"
199767f8919635c4928607450d9e0abb932109ceToomas Soome.elif ${BOOT_COMCONSOLE_SPEED} == 150
199767f8919635c4928607450d9e0abb932109ceToomas SoomeBOOT_BOOT0_COMCONSOLE_SPEED= "1 << 5 + 3"
199767f8919635c4928607450d9e0abb932109ceToomas Soome.elif ${BOOT_COMCONSOLE_SPEED} == 110
199767f8919635c4928607450d9e0abb932109ceToomas SoomeBOOT_BOOT0_COMCONSOLE_SPEED= "0 << 5 + 3"
199767f8919635c4928607450d9e0abb932109ceToomas Soome.else
199767f8919635c4928607450d9e0abb932109ceToomas SoomeBOOT_BOOT0_COMCONSOLE_SPEED= "7 << 5 + 3"
199767f8919635c4928607450d9e0abb932109ceToomas Soome.endif
199767f8919635c4928607450d9e0abb932109ceToomas Soome.endif
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas SoomeCFLAGS+=-DFLAGS=${BOOT_BOOT0_FLAGS} \
199767f8919635c4928607450d9e0abb932109ceToomas Soome -DTICKS=${BOOT_BOOT0_TICKS} \
199767f8919635c4928607450d9e0abb932109ceToomas Soome -DCOMSPEED=${BOOT_BOOT0_COMCONSOLE_SPEED}
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas SoomeLDFLAGS=-e start -Ttext ${BOOT_BOOT0_ORG} -Wl,-N,-S,--oformat,binary
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome.include <bsd.prog.mk>
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome# XXX: clang integrated-as doesn't grok .codeNN directives yet
199767f8919635c4928607450d9e0abb932109ceToomas SoomeCFLAGS.boot0.S= ${CLANG_NO_IAS}
199767f8919635c4928607450d9e0abb932109ceToomas SoomeCFLAGS+= ${CFLAGS.${.IMPSRC:T}}