Remove PC98 and Alpha support.
[dragonfly.git] / sys / boot / pc98 / boot2 / serial_8251.S
1 /*
2  * Mach Operating System
3  * Copyright (c) 1992, 1991 Carnegie Mellon University
4  * All Rights Reserved.
5  * 
6  * Permission to use, copy, modify and distribute this software and its
7  * documentation is hereby granted, provided that both the copyright
8  * notice and this permission notice appear in all copies of the
9  * software, derivative works or modified versions, and any portions
10  * thereof, and that both notices appear in supporting documentation.
11  * 
12  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
13  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
14  * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
15  * 
16  * Carnegie Mellon requests users of this software to return to
17  * 
18  *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
19  *  School of Computer Science
20  *  Carnegie Mellon University
21  *  Pittsburgh PA 15213-3890
22  * 
23  * any improvements or extensions that they make and grant Carnegie Mellon
24  * the rights to redistribute these changes.
25  *
26  *      from: Mach, Revision 2.2  92/04/04  11:34:26  rpd
27  * $FreeBSD: src/sys/boot/pc98/boot2/serial_8251.S,v 1.1 2000/03/30 09:25:03 kato Exp $
28  * $DragonFly: src/sys/boot/pc98/boot2/Attic/serial_8251.S,v 1.4 2003/11/10 06:08:38 dillon Exp $
29  */
30
31 /*
32   Copyright 1988, 1989, 1990, 1991, 1992 
33    by Intel Corporation, Santa Clara, California.
34
35                 All Rights Reserved
36
37 Permission to use, copy, modify, and distribute this software and
38 its documentation for any purpose and without fee is hereby
39 granted, provided that the above copyright notice appears in all
40 copies and that both the copyright notice and this permission notice
41 appear in supporting documentation, and that the name of Intel
42 not be used in advertising or publicity pertaining to distribution
43 of the software without specific, written prior permission.
44
45 INTEL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE
46 INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,
47 IN NO EVENT SHALL INTEL BE LIABLE FOR ANY SPECIAL, INDIRECT, OR
48 CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
49 LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT,
50 NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
51 WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
52 */
53
54 /*
55  * Serial bootblock interface routines
56  * Copyright (c) 1994, J"org Wunsch
57  *
58  * Permission to use, copy, modify and distribute this software and its
59  * documentation is hereby granted, provided that both the copyright
60  * notice and this permission notice appear in all copies of the
61  * software, derivative works or modified versions, and any portions
62  * thereof, and that both notices appear in supporting documentation.
63  *
64  * THE AUTHOR ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
65  * CONDITION.  THE AUTHOR DISCLAIMS ANY LIABILITY OF ANY KIND FOR
66  * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
67  */ 
68
69 /*
70  * modified for PC-98 by KATO T. of Nagoya University
71  */
72
73         .file   "serial.S"
74
75 #include <isa/sioreg.h>
76 #include "asm.h"
77
78         .text
79
80 /*
81  * The serial port interface routines implement a simple polled i/o
82  * interface to a standard serial port.  Due to the space restrictions
83  * for the boot blocks, no BIOS support is used (since BIOS requires
84  * expensive real/protected mode switches), instead the rudimentary
85  * BIOS support is duplicated here.
86  *
87  * The base address for the i/o port is passed from the Makefile in
88  * the COMCONSOLE preprocessor macro.  Console parameters are currently
89  * hard-coded to 9600 Bd, 8 bit.  This can be changed in the
90  * init_serial() function.
91  */
92
93 /*
94  * void serial_putc(char ch)
95  *      send ch to serial port
96  *
97  */
98
99 ENTRY(serial_putc)
100         mov     $COMCONSOLE + 2, %edx   # line status reg
101 1:      inb     %dx, %al
102         testb   $0x01, %al
103         jz      1b              # TX buffer not empty
104
105         movb    0x4(%esp), %al
106
107         sub     $2, %edx        # TX output reg
108         outb    %al, %dx        # send this one
109
110         ret
111
112 /*
113  * int serial_getc(void)
114  *      read a character from serial port
115  */
116
117 ENTRY(serial_getc)
118         mov     $COMCONSOLE + 2, %edx   # line status reg
119 1:
120         inb     %dx, %al
121         testb   $0x02, %al
122         jz      1b              # no RX char available
123
124         xorb    %eax, %eax
125         subb    $2, %edx        # RX buffer reg
126         inb     %dx, %al        # fetch (first) character
127
128         cmp     $0x7F, %eax     # make DEL...
129         jne     2f
130         movb    $0x08, %eax     # look like BS
131 2:
132         ret
133
134 /*
135  * int serial_ischar(void)
136  *       if there is a character pending, return true; otherwise return 0
137  */
138 ENTRY(serial_ischar)
139         xorl    %eax, %eax
140         movl    $COMCONSOLE + 2, %edx   # line status reg
141         inb     %dx, %al
142         andb    $0x02, %al              # RX char available?
143
144         ret
145
146 /*
147  * void init_serial(void)
148  *      initialize the serial console port to 9600 Bd, 8 bpc
149  */
150 ENTRY(init_serial)
151         /* set 8253 */
152         movb    0xb6, %al
153         outb    %al, $0x77
154         movl    $COMCONSOLE_CLK, %eax
155         outb    %al, $0x75
156         inb     $0x5f, %al
157         movb    %ah, %al
158         outb    %al, $0x75
159
160         /* inhibit com int */
161         inb     $0x35, %al
162         andb    $0xf8, %al
163         movb    %al, %ah
164         inb     $0x5f, %al
165         movb    %ah, %al
166         outb    %al, $0x35
167
168         inb     $0x02, %al
169         orb     $0x10, %al
170         outb    %al, $0x02
171         
172         /* dummy command */
173         xorb    %al,%al
174         movl    $COMCONSOLE + 2, %edx
175         outb    %al, %dx
176         inb     $0x5f, %al
177         xorb    %al,%al
178         outb    %al, %dx
179         inb     $0x5f, %al
180         xorb    %al,%al
181         outb    %al, %dx
182         inb     $0x5f, %al
183
184         /* RESET 8251 */
185         movb    $0x40, %al
186         outb    %al, %dx
187
188         movb    $COMCONSOLE_MODE , %al
189         andb    $0xfc, %al
190         orb     $0x02, %al      /* factor = 1/16 */
191         outb    %al, %dx
192         inb     $0x5f, %al
193
194         /* start RS-232C */
195         movb    $0x37, %al
196         outb    %al, %dx
197
198         ret
199