From 50a1695ff528f3e625c1139664b912a71b8e44ff Mon Sep 17 00:00:00 2001 From: Matthew Dillon Date: Sat, 26 Jun 2004 23:41:09 +0000 Subject: [PATCH] Do a bit of cleanup and enable the SIO FIFO (1655x) to reduce latencies generated by the disk twiddle (the \ | / - \ | twirly that occurs on the screen). --- sys/boot/i386/boot2/boot2.c | 15 +++++----- sys/boot/i386/boot2/sio.S | 48 ++++++++++++++++-------------- sys/boot/i386/boot2/sio.s | 48 ++++++++++++++++-------------- sys/boot/i386/libi386/comconsole.c | 8 ++++- sys/boot/pc32/boot2/boot2.c | 15 +++++----- sys/boot/pc32/boot2/sio.S | 48 ++++++++++++++++-------------- sys/boot/pc32/libi386/comconsole.c | 8 ++++- 7 files changed, 105 insertions(+), 85 deletions(-) diff --git a/sys/boot/i386/boot2/boot2.c b/sys/boot/i386/boot2/boot2.c index 40ca14db8c..4cf48f4977 100644 --- a/sys/boot/i386/boot2/boot2.c +++ b/sys/boot/i386/boot2/boot2.c @@ -13,7 +13,7 @@ * purpose. * * $FreeBSD: src/sys/boot/i386/boot2/boot2.c,v 1.64 2003/08/25 23:28:31 obrien Exp $ - * $DragonFly: src/sys/boot/i386/boot2/Attic/boot2.c,v 1.8 2004/06/26 22:37:09 dillon Exp $ + * $DragonFly: src/sys/boot/i386/boot2/Attic/boot2.c,v 1.9 2004/06/26 23:41:06 dillon Exp $ */ #include #include @@ -53,7 +53,7 @@ #define RBF_SERIAL (1 << RBX_SERIAL) #define RBF_VIDEO (1 << RBX_VIDEO) -/* pass: -a, -s, -r, -d, -c, -v, -h, -C, -g, -m, -p, -D */ +/* pass: -a, -s, -r, -d, -c, -v, -h, -C, -g, -m, -p, -V */ #define RBX_MASK 0x2005ffff #define PATH_CONFIG "/boot.config" @@ -122,7 +122,7 @@ static void putchar(int); static uint32_t memsize(void); static int drvread(void *, unsigned, unsigned); static int keyhit(unsigned); -static int xputc(int); +static void xputc(int); static int xgetc(int); static int getc(int); @@ -587,9 +587,11 @@ putchar(int c) static int drvread(void *buf, unsigned lba, unsigned nblk) { - static unsigned c = 0x2d5c7c2f; + static unsigned c = 0x2d5c7c2f; /* twiddle */ - printf("%c\b", c = c << 8 | c >> 24); + c = (c << 8) | (c >> 24); + xputc(c); + xputc('\b'); v86.ctl = V86_ADDR | V86_CALLF | V86_FLAGS; v86.addr = XREADORG; /* call to xread in boot1 */ v86.es = VTOPSEG(buf); @@ -625,14 +627,13 @@ keyhit(unsigned ticks) } } -static int +static void xputc(int c) { if (opts & RBF_VIDEO) putc(c); if (opts & RBF_SERIAL) sio_putc(c); - return c; } static int diff --git a/sys/boot/i386/boot2/sio.S b/sys/boot/i386/boot2/sio.S index cad515920b..c1cdc5b2ee 100644 --- a/sys/boot/i386/boot2/sio.S +++ b/sys/boot/i386/boot2/sio.S @@ -14,7 +14,7 @@ # # $FreeBSD: src/sys/boot/i386/boot2/sio.s,v 1.4 1999/08/28 00:40:02 peter Exp $ -# $DragonFly: src/sys/boot/i386/boot2/Attic/sio.S,v 1.3 2003/11/10 06:08:35 dillon Exp $ +# $DragonFly: src/sys/boot/i386/boot2/Attic/sio.S,v 1.4 2004/06/26 23:41:06 dillon Exp $ .set SIO_PRT,SIOPRT # Base port .set SIO_FMT,SIOFMT # 8N1 @@ -29,18 +29,20 @@ # void sio_init(void) sio_init: movw $SIO_PRT+0x3,%dx # Data format reg - movb $SIO_FMT|0x80,%al # Set format - outb %al,(%dx) # and DLAB - pushl %edx # Save - subb $0x3,%dl # Divisor latch reg - movw $SIO_DIV,%ax # Set - outw %ax,(%dx) # BPS - popl %edx # Restore - movb $SIO_FMT,%al # Clear - outb %al,(%dx) # DLAB - incl %edx # Modem control reg - movb $0x3,%al # Set RTS, - outb %al,(%dx) # DTR + movb $SIO_FMT|0x80,%al # Set format and DLAB + outb %al,(%dx) # BASE+3 + subb $0x3,%dl + movw $SIO_DIV,%ax # divisor + outw %ax,(%dx) # BASE+0 (divisor w/ DLAB set) + movw $SIO_PRT+0x2,%dx + movb $0x01,%al # Enable FIFO + outb %al,(%dx) # BASE+2 + incl %edx + movb $SIO_FMT,%al # Clear DLAB + outb %al,(%dx) # BASE+3 + incl %edx + movb $0x3,%al # RTS+DTR + outb %al,(%dx) # BASE+4 incl %edx # Line status reg # void sio_flush(void) @@ -48,21 +50,21 @@ sio_init: movw $SIO_PRT+0x3,%dx # Data format reg sio_flush.0: call sio_getc.1 # Get character sio_flush: call sio_ischar # Check for character jnz sio_flush.0 # Till none - ret # To caller + ret # void sio_putc(int c) sio_putc: movw $SIO_PRT+0x5,%dx # Line status reg - xor %ecx,%ecx # Timeout - movb $0x40,%ch # counter -sio_putc.1: inb (%dx),%al # Transmitter - testb $0x20,%al # buffer empty? + movb $0x40,%ch # Timeout counter. Allow %cl + # to contain garbage. +sio_putc.1: inb (%dx),%al # Transmitter buffer empty? + testb $0x20,%al loopz sio_putc.1 # No jz sio_putc.2 # If timeout movb 0x4(%esp,1),%al # Get character subb $0x5,%dl # Transmitter hold reg outb %al,(%dx) # Write character -sio_putc.2: ret $0x4 # To caller +sio_putc.2: ret $0x4 # int sio_getc(void) @@ -70,12 +72,12 @@ sio_getc: call sio_ischar # Character available? jz sio_getc # No sio_getc.1: subb $0x5,%dl # Receiver buffer reg inb (%dx),%al # Read character - ret # To caller + ret # int sio_ischar(void) sio_ischar: movw $SIO_PRT+0x5,%dx # Line status register xorl %eax,%eax # Zero - inb (%dx),%al # Received data - andb $0x1,%al # ready? - ret # To caller + inb (%dx),%al # Received data ready? + andb $0x1,%al + ret diff --git a/sys/boot/i386/boot2/sio.s b/sys/boot/i386/boot2/sio.s index b601f163e7..0d178cc583 100644 --- a/sys/boot/i386/boot2/sio.s +++ b/sys/boot/i386/boot2/sio.s @@ -14,7 +14,7 @@ # # $FreeBSD: src/sys/boot/i386/boot2/sio.s,v 1.4 1999/08/28 00:40:02 peter Exp $ -# $DragonFly: src/sys/boot/i386/boot2/Attic/sio.s,v 1.3 2003/11/10 06:08:35 dillon Exp $ +# $DragonFly: src/sys/boot/i386/boot2/Attic/sio.s,v 1.4 2004/06/26 23:41:06 dillon Exp $ .set SIO_PRT,SIOPRT # Base port .set SIO_FMT,SIOFMT # 8N1 @@ -29,18 +29,20 @@ # void sio_init(void) sio_init: movw $SIO_PRT+0x3,%dx # Data format reg - movb $SIO_FMT|0x80,%al # Set format - outb %al,(%dx) # and DLAB - pushl %edx # Save - subb $0x3,%dl # Divisor latch reg - movw $SIO_DIV,%ax # Set - outw %ax,(%dx) # BPS - popl %edx # Restore - movb $SIO_FMT,%al # Clear - outb %al,(%dx) # DLAB - incl %edx # Modem control reg - movb $0x3,%al # Set RTS, - outb %al,(%dx) # DTR + movb $SIO_FMT|0x80,%al # Set format and DLAB + outb %al,(%dx) # BASE+3 + subb $0x3,%dl + movw $SIO_DIV,%ax # divisor + outw %ax,(%dx) # BASE+0 (divisor w/ DLAB set) + movw $SIO_PRT+0x2,%dx + movb $0x01,%al # Enable FIFO + outb %al,(%dx) # BASE+2 + incl %edx + movb $SIO_FMT,%al # Clear DLAB + outb %al,(%dx) # BASE+3 + incl %edx + movb $0x3,%al # RTS+DTR + outb %al,(%dx) # BASE+4 incl %edx # Line status reg # void sio_flush(void) @@ -48,21 +50,21 @@ sio_init: movw $SIO_PRT+0x3,%dx # Data format reg sio_flush.0: call sio_getc.1 # Get character sio_flush: call sio_ischar # Check for character jnz sio_flush.0 # Till none - ret # To caller + ret # void sio_putc(int c) sio_putc: movw $SIO_PRT+0x5,%dx # Line status reg - xor %ecx,%ecx # Timeout - movb $0x40,%ch # counter -sio_putc.1: inb (%dx),%al # Transmitter - testb $0x20,%al # buffer empty? + movb $0x40,%ch # Timeout counter. Allow %cl + # to contain garbage. +sio_putc.1: inb (%dx),%al # Transmitter buffer empty? + testb $0x20,%al loopz sio_putc.1 # No jz sio_putc.2 # If timeout movb 0x4(%esp,1),%al # Get character subb $0x5,%dl # Transmitter hold reg outb %al,(%dx) # Write character -sio_putc.2: ret $0x4 # To caller +sio_putc.2: ret $0x4 # int sio_getc(void) @@ -70,12 +72,12 @@ sio_getc: call sio_ischar # Character available? jz sio_getc # No sio_getc.1: subb $0x5,%dl # Receiver buffer reg inb (%dx),%al # Read character - ret # To caller + ret # int sio_ischar(void) sio_ischar: movw $SIO_PRT+0x5,%dx # Line status register xorl %eax,%eax # Zero - inb (%dx),%al # Received data - andb $0x1,%al # ready? - ret # To caller + inb (%dx),%al # Received data ready? + andb $0x1,%al + ret diff --git a/sys/boot/i386/libi386/comconsole.c b/sys/boot/i386/libi386/comconsole.c index d95df190f2..452bdbe19d 100644 --- a/sys/boot/i386/libi386/comconsole.c +++ b/sys/boot/i386/libi386/comconsole.c @@ -23,7 +23,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/boot/i386/libi386/comconsole.c,v 1.10 2003/09/16 11:24:23 bde Exp $ - * $DragonFly: src/sys/boot/i386/libi386/Attic/comconsole.c,v 1.5 2004/06/26 22:37:10 dillon Exp $ + * $DragonFly: src/sys/boot/i386/libi386/Attic/comconsole.c,v 1.6 2004/06/26 23:41:09 dillon Exp $ */ #include @@ -82,6 +82,12 @@ comc_init(int arg) outb(COMPORT + com_cfcr, COMC_FMT); outb(COMPORT + com_mcr, MCR_RTS | MCR_DTR); + /* + * Enable the FIFO so the serial port output in dual console mode doesn't + * interfere so much with the disk twiddle. + */ + outb(COMPORT + com_fifo, FIFO_ENABLE); + /* * Give the serial port a little time to settle after asserting RTS and * DTR, then drain any pending garbage. diff --git a/sys/boot/pc32/boot2/boot2.c b/sys/boot/pc32/boot2/boot2.c index c36cd7b8b1..ee3c19f197 100644 --- a/sys/boot/pc32/boot2/boot2.c +++ b/sys/boot/pc32/boot2/boot2.c @@ -13,7 +13,7 @@ * purpose. * * $FreeBSD: src/sys/boot/i386/boot2/boot2.c,v 1.64 2003/08/25 23:28:31 obrien Exp $ - * $DragonFly: src/sys/boot/pc32/boot2/boot2.c,v 1.8 2004/06/26 22:37:09 dillon Exp $ + * $DragonFly: src/sys/boot/pc32/boot2/boot2.c,v 1.9 2004/06/26 23:41:06 dillon Exp $ */ #include #include @@ -53,7 +53,7 @@ #define RBF_SERIAL (1 << RBX_SERIAL) #define RBF_VIDEO (1 << RBX_VIDEO) -/* pass: -a, -s, -r, -d, -c, -v, -h, -C, -g, -m, -p, -D */ +/* pass: -a, -s, -r, -d, -c, -v, -h, -C, -g, -m, -p, -V */ #define RBX_MASK 0x2005ffff #define PATH_CONFIG "/boot.config" @@ -122,7 +122,7 @@ static void putchar(int); static uint32_t memsize(void); static int drvread(void *, unsigned, unsigned); static int keyhit(unsigned); -static int xputc(int); +static void xputc(int); static int xgetc(int); static int getc(int); @@ -587,9 +587,11 @@ putchar(int c) static int drvread(void *buf, unsigned lba, unsigned nblk) { - static unsigned c = 0x2d5c7c2f; + static unsigned c = 0x2d5c7c2f; /* twiddle */ - printf("%c\b", c = c << 8 | c >> 24); + c = (c << 8) | (c >> 24); + xputc(c); + xputc('\b'); v86.ctl = V86_ADDR | V86_CALLF | V86_FLAGS; v86.addr = XREADORG; /* call to xread in boot1 */ v86.es = VTOPSEG(buf); @@ -625,14 +627,13 @@ keyhit(unsigned ticks) } } -static int +static void xputc(int c) { if (opts & RBF_VIDEO) putc(c); if (opts & RBF_SERIAL) sio_putc(c); - return c; } static int diff --git a/sys/boot/pc32/boot2/sio.S b/sys/boot/pc32/boot2/sio.S index 2d87cfbc34..99e37364ba 100644 --- a/sys/boot/pc32/boot2/sio.S +++ b/sys/boot/pc32/boot2/sio.S @@ -14,7 +14,7 @@ # # $FreeBSD: src/sys/boot/i386/boot2/sio.s,v 1.4 1999/08/28 00:40:02 peter Exp $ -# $DragonFly: src/sys/boot/pc32/boot2/sio.S,v 1.3 2003/11/10 06:08:35 dillon Exp $ +# $DragonFly: src/sys/boot/pc32/boot2/sio.S,v 1.4 2004/06/26 23:41:06 dillon Exp $ .set SIO_PRT,SIOPRT # Base port .set SIO_FMT,SIOFMT # 8N1 @@ -29,18 +29,20 @@ # void sio_init(void) sio_init: movw $SIO_PRT+0x3,%dx # Data format reg - movb $SIO_FMT|0x80,%al # Set format - outb %al,(%dx) # and DLAB - pushl %edx # Save - subb $0x3,%dl # Divisor latch reg - movw $SIO_DIV,%ax # Set - outw %ax,(%dx) # BPS - popl %edx # Restore - movb $SIO_FMT,%al # Clear - outb %al,(%dx) # DLAB - incl %edx # Modem control reg - movb $0x3,%al # Set RTS, - outb %al,(%dx) # DTR + movb $SIO_FMT|0x80,%al # Set format and DLAB + outb %al,(%dx) # BASE+3 + subb $0x3,%dl + movw $SIO_DIV,%ax # divisor + outw %ax,(%dx) # BASE+0 (divisor w/ DLAB set) + movw $SIO_PRT+0x2,%dx + movb $0x01,%al # Enable FIFO + outb %al,(%dx) # BASE+2 + incl %edx + movb $SIO_FMT,%al # Clear DLAB + outb %al,(%dx) # BASE+3 + incl %edx + movb $0x3,%al # RTS+DTR + outb %al,(%dx) # BASE+4 incl %edx # Line status reg # void sio_flush(void) @@ -48,21 +50,21 @@ sio_init: movw $SIO_PRT+0x3,%dx # Data format reg sio_flush.0: call sio_getc.1 # Get character sio_flush: call sio_ischar # Check for character jnz sio_flush.0 # Till none - ret # To caller + ret # void sio_putc(int c) sio_putc: movw $SIO_PRT+0x5,%dx # Line status reg - xor %ecx,%ecx # Timeout - movb $0x40,%ch # counter -sio_putc.1: inb (%dx),%al # Transmitter - testb $0x20,%al # buffer empty? + movb $0x40,%ch # Timeout counter. Allow %cl + # to contain garbage. +sio_putc.1: inb (%dx),%al # Transmitter buffer empty? + testb $0x20,%al loopz sio_putc.1 # No jz sio_putc.2 # If timeout movb 0x4(%esp,1),%al # Get character subb $0x5,%dl # Transmitter hold reg outb %al,(%dx) # Write character -sio_putc.2: ret $0x4 # To caller +sio_putc.2: ret $0x4 # int sio_getc(void) @@ -70,12 +72,12 @@ sio_getc: call sio_ischar # Character available? jz sio_getc # No sio_getc.1: subb $0x5,%dl # Receiver buffer reg inb (%dx),%al # Read character - ret # To caller + ret # int sio_ischar(void) sio_ischar: movw $SIO_PRT+0x5,%dx # Line status register xorl %eax,%eax # Zero - inb (%dx),%al # Received data - andb $0x1,%al # ready? - ret # To caller + inb (%dx),%al # Received data ready? + andb $0x1,%al + ret diff --git a/sys/boot/pc32/libi386/comconsole.c b/sys/boot/pc32/libi386/comconsole.c index 3cf6c39eed..f2bcab9fb5 100644 --- a/sys/boot/pc32/libi386/comconsole.c +++ b/sys/boot/pc32/libi386/comconsole.c @@ -23,7 +23,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/boot/i386/libi386/comconsole.c,v 1.10 2003/09/16 11:24:23 bde Exp $ - * $DragonFly: src/sys/boot/pc32/libi386/comconsole.c,v 1.5 2004/06/26 22:37:10 dillon Exp $ + * $DragonFly: src/sys/boot/pc32/libi386/comconsole.c,v 1.6 2004/06/26 23:41:09 dillon Exp $ */ #include @@ -82,6 +82,12 @@ comc_init(int arg) outb(COMPORT + com_cfcr, COMC_FMT); outb(COMPORT + com_mcr, MCR_RTS | MCR_DTR); + /* + * Enable the FIFO so the serial port output in dual console mode doesn't + * interfere so much with the disk twiddle. + */ + outb(COMPORT + com_fifo, FIFO_ENABLE); + /* * Give the serial port a little time to settle after asserting RTS and * DTR, then drain any pending garbage. -- 2.41.0