2 # Copyright (c) 1998 Robert Nordier
5 # Redistribution and use in source and binary forms are freely
6 # permitted provided that the above copyright notice and this
7 # paragraph and the following disclaimer are duplicated in all
10 # This software is provided "AS IS" and without any express or
11 # implied warranties, including, without limitation, the implied
12 # warranties of merchantability and fitness for a particular
16 # $FreeBSD: src/sys/boot/i386/boot2/sio.s,v 1.4 1999/08/28 00:40:02 peter Exp $
17 # $DragonFly: src/sys/boot/i386/boot2/Attic/sio.s,v 1.5 2004/06/27 08:00:46 dillon Exp $
19 .set SIO_PRT,SIOPRT # Base port
20 .set SIO_FMT,SIOFMT # 8N1
21 .set SIO_DIV,(115200/SIOSPD) # 115200 / SPD
31 # returns non-zero if we couldn't init, which can happen if the
32 # serial port is unmapped and the inb's all return 0xFF (we fail
33 # to flush the input).
35 sio_init: movw $SIO_PRT+0x3,%dx # Data format reg
36 movb $SIO_FMT|0x80,%al # Set format and DLAB
37 outb %al,(%dx) # BASE+3
39 movw $SIO_DIV,%ax # divisor
40 outw %ax,(%dx) # BASE+0 (divisor w/ DLAB set)
42 movb $0x01,%al # Enable FIFO
43 # DISABLED - apparently many new laptops only implement
44 # 8250s, this might crash them? XXX
45 # outb %al,(%dx) # BASE+2
47 movb $SIO_FMT,%al # Clear DLAB
48 outb %al,(%dx) # BASE+3
50 movb $0x3,%al # RTS+DTR
51 outb %al,(%dx) # BASE+4
52 incl %edx # BASE+5 Line status reg
54 # fall through to io_flush
56 # sio_flush: flush pending data in the serial port,
57 # return non-zero if we were unable to flush (aka
58 # ischar always returned true)
60 sio_flush: movb $1,%ch # let %cl be garbage
66 # void sio_putc(int c)
68 sio_putc: movw $SIO_PRT+0x5,%dx # Line status reg
69 movb $0x40,%ch # Timeout counter. Allow %cl
71 sio_putc.1: inb (%dx),%al # Transmitter buffer empty?
74 jz sio_putc.2 # If timeout
75 movb 0x4(%esp,1),%al # Get character
76 subb $0x5,%dl # Transmitter hold reg
77 outb %al,(%dx) # Write character
82 sio_getc: call sio_ischar # Character available?
84 sio_getc.1: subb $0x5,%dl # Receiver buffer reg
85 inb (%dx),%al # Read character
88 # int sio_ischar(void)
90 sio_ischar: movw $SIO_PRT+0x5,%dx # Line status register
92 inb (%dx),%al # Received data ready?
97 inbser: movw $SIO_PRT+5,%dx