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 * $FreeBSD: head/sys/boot/i386/boot2/sio.S 241301 2012-10-06 20:08:29Z avg $
16 */
17
18 .set SIO_PRT,SIOPRT # Base port
19 .set SIO_FMT,SIOFMT # 8N1
20
21 .globl sio_init
22 .globl sio_flush
23 .globl sio_putc
24 .globl sio_getc
25 .globl sio_ischar
26
27/* int sio_init(int div) */
28
29sio_init: pushl %eax
30 movw $SIO_PRT+0x3,%dx # Data format reg
31 movb $SIO_FMT|0x80,%al # Set format
32 outb %al,(%dx) # and DLAB
33 subb $0x3,%dl # Divisor latch reg
34 popl %eax
35 outw %ax,(%dx) # BPS
36 movw $SIO_PRT+0x3,%dx # Data format reg
37 movb $SIO_FMT,%al # Clear
38 outb %al,(%dx) # DLAB
39 incl %edx # Modem control reg
40 movb $0x3,%al # Set RTS,
41 outb %al,(%dx) # DTR
42 incl %edx # Line status reg
43 call sio_flush
44 ret
45
46/* int sio_flush(void) */
47
48sio_flush: xorl %eax,%eax # Return value
49 xorl %ecx,%ecx # Timeout
50 movb $0x80,%ch # counter
51sio_flush.1: call sio_ischar # Check for character
52 jz sio_flush.2 # Till none
53 loop sio_flush.1 # or counter is zero
54 movb $1, %al # Exhausted all tries
55sio_flush.2: ret # To caller
56
57/* void sio_putc(int c) */
58
59sio_putc: pushl %eax
60 movw $SIO_PRT+0x5,%dx # Line status reg
61 xor %ecx,%ecx # Timeout
62 movb $0x40,%ch # counter
63sio_putc.1: inb (%dx),%al # Transmitter
--- 23 unchanged lines hidden ---
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 * $FreeBSD: head/sys/boot/i386/boot2/sio.S 241301 2012-10-06 20:08:29Z avg $
16 */
17
18 .set SIO_PRT,SIOPRT # Base port
19 .set SIO_FMT,SIOFMT # 8N1
20
21 .globl sio_init
22 .globl sio_flush
23 .globl sio_putc
24 .globl sio_getc
25 .globl sio_ischar
26
27/* int sio_init(int div) */
28
29sio_init: pushl %eax
30 movw $SIO_PRT+0x3,%dx # Data format reg
31 movb $SIO_FMT|0x80,%al # Set format
32 outb %al,(%dx) # and DLAB
33 subb $0x3,%dl # Divisor latch reg
34 popl %eax
35 outw %ax,(%dx) # BPS
36 movw $SIO_PRT+0x3,%dx # Data format reg
37 movb $SIO_FMT,%al # Clear
38 outb %al,(%dx) # DLAB
39 incl %edx # Modem control reg
40 movb $0x3,%al # Set RTS,
41 outb %al,(%dx) # DTR
42 incl %edx # Line status reg
43 call sio_flush
44 ret
45
46/* int sio_flush(void) */
47
48sio_flush: xorl %eax,%eax # Return value
49 xorl %ecx,%ecx # Timeout
50 movb $0x80,%ch # counter
51sio_flush.1: call sio_ischar # Check for character
52 jz sio_flush.2 # Till none
53 loop sio_flush.1 # or counter is zero
54 movb $1, %al # Exhausted all tries
55sio_flush.2: ret # To caller
56
57/* void sio_putc(int c) */
58
59sio_putc: pushl %eax
60 movw $SIO_PRT+0x5,%dx # Line status reg
61 xor %ecx,%ecx # Timeout
62 movb $0x40,%ch # counter
63sio_putc.1: inb (%dx),%al # Transmitter
--- 23 unchanged lines hidden ---