DragonFly submit List (threaded) for 2008-07
[
Date Prev][
Date Next]
[
Thread Prev][
Thread Next]
[
Date Index][
Thread Index]
bios0sio
Hi,
While trying to get DragonFly running on my pcengines router box (an AMD
geode Soekris-like box) I noticed that DragonFly's boot0 loader doesn't
support a COM console. The patch below adds support from FreeBSD.
If no one objects, I'd like to commit it.
Regards,
Michael
Index: boot0/Makefile
===================================================================
RCS file: /home/dcvs/src/sys/boot/pc32/boot0/Makefile,v
retrieving revision 1.5
diff -u -r1.5 Makefile
--- boot0/Makefile 19 Jul 2004 23:30:31 -0000 1.5
+++ boot0/Makefile 4 Jul 2008 19:39:23 -0000
@@ -1,7 +1,7 @@
# $FreeBSD: src/sys/boot/i386/boot0/Makefile,v 1.17 2002/09/17 01:48:54 peter Exp $
# $DragonFly: src/sys/boot/pc32/boot0/Makefile,v 1.5 2004/07/19 23:30:31 dillon Exp $
-PROG= boot0
+PROG?= boot0
NOMAN=
STRIP=
BINDIR?= /boot
@@ -12,7 +12,7 @@
# The default set of flags compiled into boot0. This enables update (writing
# the modified boot0 back to disk after running so that the selection made is
# saved), packet mode (detect and use the BIOS EDD extensions if we try to
-# boot past the 1024 cylinder liimt), and booting from all valid slices.
+# boot past the 1024 cylinder limit), and booting from all valid slices.
BOOT_BOOT0_FLAGS?= 0xf
# The number of timer ticks to wait for a keypress before assuming the default
@@ -20,17 +20,49 @@
# 0xb6 (182d) corresponds to 10 seconds.
BOOT_BOOT0_TICKS?= 0xb6
+# Comm settings for boot0sio.
+# Bit(s) Description
+# 7-5 data rate (110,150,300,600,1200,2400,4800,9600 bps)
+# 4-3 parity (00 or 10 = none, 01 = odd, 11 = even)
+# 2 stop bits (set = 2, clear = 1)
+# 1-0 data bits (00 = 5, 01 = 6, 10 = 7, 11 = 8)
+.if !defined(BOOT_BOOT0_COMCONSOLE_SPEED)
+BOOT_COMCONSOLE_SPEED?= 9600
+.if ${BOOT_COMCONSOLE_SPEED} == 9600
+BOOT_BOOT0_COMCONSOLE_SPEED= "7 << 5 + 3"
+.elif ${BOOT_COMCONSOLE_SPEED} == 4800
+BOOT_BOOT0_COMCONSOLE_SPEED= "6 << 5 + 3"
+.elif ${BOOT_COMCONSOLE_SPEED} == 2400
+BOOT_BOOT0_COMCONSOLE_SPEED= "5 << 5 + 3"
+.elif ${BOOT_COMCONSOLE_SPEED} == 1200
+BOOT_BOOT0_COMCONSOLE_SPEED= "4 << 5 + 3"
+.elif ${BOOT_COMCONSOLE_SPEED} == 600
+BOOT_BOOT0_COMCONSOLE_SPEED= "3 << 5 + 3"
+.elif ${BOOT_COMCONSOLE_SPEED} == 300
+BOOT_BOOT0_COMCONSOLE_SPEED= "2 << 5 + 3"
+.elif ${BOOT_COMCONSOLE_SPEED} == 150
+BOOT_BOOT0_COMCONSOLE_SPEED= "1 << 5 + 3"
+.elif ${BOOT_COMCONSOLE_SPEED} == 110
+BOOT_BOOT0_COMCONSOLE_SPEED= "0 << 5 + 3"
+.else
+BOOT_BOOT0_COMCONSOLE_SPEED= "7 << 5 + 3"
+.endif
+.endif
+
+CFLAGS+=-DFLAGS=${BOOT_BOOT0_FLAGS} \
+ -DTICKS=${BOOT_BOOT0_TICKS} \
+ -DCOMSPEED=${BOOT_BOOT0_COMCONSOLE_SPEED}
+
# pull BOOT0_ORIGIN out of bootasm.h
#
#
-boot0: boot0.o bootasmdef.nx
+${PROG}: boot0.o bootasmdef.nx
@echo "boot0 origin set to `${.OBJDIR}/bootasmdef.nx BOOT0_ORIGIN`"
${LD} -N -e start -Ttext `${.OBJDIR}/bootasmdef.nx BOOT0_ORIGIN` -o boot0.out boot0.o
objcopy -S -O binary boot0.out ${.TARGET}
boot0.o: boot0.S
- ${CC} -c -DFLAGS=${BOOT_BOOT0_FLAGS} -DTICKS=${BOOT_BOOT0_TICKS} \
- ${AFLAGS} ${.IMPSRC} -o ${.TARGET}
+ ${CC} -c ${CFLAGS} ${AFLAGS} ${.IMPSRC} -o ${.TARGET}
CLEANFILES+= boot0.out boot0.o bootasmdef.nx
Index: boot0/boot0.S
===================================================================
RCS file: /home/dcvs/src/sys/boot/pc32/boot0/boot0.S,v
retrieving revision 1.8
diff -u -r1.8 boot0.S
--- boot0/boot0.S 27 Jun 2006 20:32:39 -0000 1.8
+++ boot0/boot0.S 4 Jul 2008 19:26:12 -0000
@@ -51,6 +51,10 @@
#include "../bootasm.h"
+#ifdef SIO
+/* ... using a serial console on COM1. */
+#endif
+
/*
* A 512-byte boot manager.
*/
@@ -66,6 +70,9 @@
.set KEY_F1,0x3b # F1 key scan code
.set KEY_1,0x02 # #1 key scan code
+ .set ASCII_BEL,0x07 # ASCII code for <BEL>
+ .set ASCII_CR,0x0D # ASCII code for <CR>
+
/*
* Addresses in the sector of embedded data values. Accessed
* with negative offsets from the end of the relocated sector
@@ -127,15 +134,25 @@
pushw $main # Jump to relocated code
retw
+main:
+#if defined(SIO) && COMSPEED != 0
+ /*
+ * Initialize the serial port.
+ * bioscom preserves the driver number in DX.
+ */
+ movw $COMSPEED,%ax # defined by Makefile
+ callw bioscom
+#endif
/*
* Check what flags were loaded with us, specifically, Use a
* predefined Drive. If what the bios gives us is bad, use
* the '0' in the block instead, as well.
*/
-main: testb $0x20,_FLAGS(%bp) # Set number drive?
+ testb $0x20,_FLAGS(%bp) # Set number drive?
jnz main.1 # Yes
testb %dl,%dl # Drive number valid?
js main.2 # Possibly (0x80 set)
+
main.1: movb _SETDRV(%bp),%dl # Drive number to use
/*
@@ -253,9 +270,17 @@
* Busy loop, looking for keystrokes but
* keeping one eye on the time.
*/
-main.8: movb $0x1,%ah # BIOS: Check
+main.8:
+#ifndef SIO
+ movb $0x1,%ah # BIOS: Check
int $0x16 # for keypress
jnz main.11 # Have one
+#else /* SIO */
+ movb $0x03,%ah # BIOS: Read COM
+ call bioscom
+ testb $0x01,%ah # Check line status
+ jnz main.11 # (bit 1 indicates input)
+#endif /* SIO */
xorb %ah,%ah # BIOS: Get
int $0x1a # system time
cmpw %di,%dx # Timeout?
@@ -275,30 +300,44 @@
* until either the timeout occurs or the user hits a good
* key.
*/
-main.10: movb $0x7,%al # Signal
+main.10: movb $ASCII_BEL,%al # Signal
callw putchr # error
/*
* Get the keystroke.
*/
-main.11: xorb %ah,%ah # BIOS: Get
+main.11:
+#ifndef SIO
+ xorb %ah,%ah # BIOS: Get
int $0x16 # keypress
movb %ah,%al # Scan code
+#else
+ movb $0x02,%ah # BIOS: Receive
+ call bioscom
+#endif
/*
* If it's CR act as if timed out.
*/
+#ifndef SIO
cmpb $KEY_ENTER,%al # Enter pressed?
+#else
+ cmpb $ASCII_CR,%al # Enter pressed?
+#endif
je main.9 # Yes
/*
* Otherwise check if legal
* If not ask again.
*/
+#ifndef SIO
subb $KEY_F1,%al # Less F1 scan code
cmpb $0x4,%al # F1..F5?
jna main.12 # Yes
subb $(KEY_1 - KEY_F1),%al # Less #1 scan code
+#else
+ subb $'1',%al # Less '1' ascii character
+#endif
cmpb $0x4,%al # #1..#5?
ja main.10 # No
@@ -368,8 +407,11 @@
/*
* Display routines
*/
-putkey: movb $'F',%al # Display
+putkey:
+#ifndef SIO
+ movb $'F',%al # Display
callw putchr # 'F'
+#endif
movb $'1',%al # Prepare
addb %dl,%al # digit
jmp putstr.1 # Display the rest
@@ -394,12 +436,25 @@
jmp putstr # Continue
putstr.2: andb $~0x80,%al # Clear MSB
-putchr: pusha # Save
+#ifndef SIO
+putchr:
+ pusha # Save
movw $0x7,%bx # Page:attribute
movb $0xe,%ah # BIOS: Display
int $0x10 # character
popa # Restore
retw # To caller
+#else /* SIO */
+putchr:
+ movb $0x01,%ah # BIOS: Send
+bioscom:
+ pusha # Save
+ xorw %dx,%dx # Use COM1
+ int $0x14 # Character
+ popa # Restore
+ retw # To caller
+#endif
+
/*
* One-sector disk I/O routine
--- /dev/null 2008-07-04 18:33:36 +0000
+++ boot0sio/Makefile 2008-07-04 19:33:33 +0000
@@ -0,0 +1,9 @@
+# $FreeBSD: src/sys/boot/i386/boot0sio/Makefile,v 1.4 2004/04/28 21:31:20 ru Exp $
+# $DragonFly:$
+
+.PATH: ${.CURDIR}/../boot0
+
+PROG= boot0sio
+CFLAGS+= -DSIO
+
+.include "${.CURDIR}/../boot0/Makefile"
[
Date Prev][
Date Next]
[
Thread Prev][
Thread Next]
[
Date Index][
Thread Index]