Add the DragonFly cvs id and perform general cleanups on cvs/rcs/sccs ids. Most
[dragonfly.git] / sys / boot / i386 / boot2 / sio.S
1 #
2 # Copyright (c) 1998 Robert Nordier
3 # All rights reserved.
4 #
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
8 # such forms.
9 #
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
13 # purpose.
14 #
15
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.2 2003/06/17 04:28:18 dillon Exp $
18
19                 .set SIO_PRT,SIOPRT             # Base port
20                 .set SIO_FMT,SIOFMT             # 8N1
21                 .set SIO_DIV,(115200/SIOSPD)    # 115200 / SPD
22
23                 .globl sio_init
24                 .globl sio_flush
25                 .globl sio_putc
26                 .globl sio_getc
27                 .globl sio_ischar
28
29 # void sio_init(void)
30
31 sio_init:       movw $SIO_PRT+0x3,%dx           # Data format reg
32                 movb $SIO_FMT|0x80,%al          # Set format
33                 outb %al,(%dx)                  #  and DLAB
34                 pushl %edx                      # Save
35                 subb $0x3,%dl                   # Divisor latch reg
36                 movw $SIO_DIV,%ax               # Set
37                 outw %ax,(%dx)                  #  BPS
38                 popl %edx                       # Restore
39                 movb $SIO_FMT,%al               # Clear
40                 outb %al,(%dx)                  #  DLAB
41                 incl %edx                       # Modem control reg
42                 movb $0x3,%al                   # Set RTS,
43                 outb %al,(%dx)                  #  DTR
44                 incl %edx                       # Line status reg
45
46 # void sio_flush(void)
47
48 sio_flush.0:    call sio_getc.1                 # Get character
49 sio_flush:      call sio_ischar                 # Check for character
50                 jnz sio_flush.0                 # Till none
51                 ret                             # To caller
52
53 # void sio_putc(int c)
54
55 sio_putc:       movw $SIO_PRT+0x5,%dx           # Line status reg
56                 xor %ecx,%ecx                   # Timeout
57                 movb $0x40,%ch                  #  counter
58 sio_putc.1:     inb (%dx),%al                   # Transmitter
59                 testb $0x20,%al                 #  buffer empty?
60                 loopz sio_putc.1                # No
61                 jz sio_putc.2                   # If timeout
62                 movb 0x4(%esp,1),%al            # Get character
63                 subb $0x5,%dl                   # Transmitter hold reg
64                 outb %al,(%dx)                  # Write character
65 sio_putc.2:     ret $0x4                        # To caller
66
67 # int sio_getc(void)
68
69 sio_getc:       call sio_ischar                 # Character available?
70                 jz sio_getc                     # No
71 sio_getc.1:     subb $0x5,%dl                   # Receiver buffer reg
72                 inb (%dx),%al                   # Read character
73                 ret                             # To caller
74
75 # int sio_ischar(void)
76
77 sio_ischar:     movw $SIO_PRT+0x5,%dx           # Line status register
78                 xorl %eax,%eax                  # Zero
79                 inb (%dx),%al                   # Received data
80                 andb $0x1,%al                   #  ready?
81                 ret                             # To caller