1 /* $NetBSD: console.c,v 1.5 2000/07/24 18:40:01 jdolecek Exp $ */
5 * Copyright (c) 1995 Charles D. Cranor and Seth Widoff
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. All advertising materials mentioning features or use of this software
17 * must display the following acknowledgement:
18 * This product includes software developed by Charles D. Cranor
20 * 4. The name of the author may not be used to endorse or promote products
21 * derived from this software without specific prior written permission.
23 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
24 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
25 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
26 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
27 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
28 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
32 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
49 struct zs_hw
*zs
= (struct zs_hw
*)CONS_ZS_ADDR
;
52 * consinit: init console
61 if (time() > mark
+ 5) break;
62 zs
->ctl
= 1; rr1
= zs
->ctl
;
64 if ((rr1
& 0x1) == 1 && (zs
->ctl
& 0x4) == 4)
65 break; /* zs_drain! */
68 zs
->ctl
= 0x00; /* clear interrupt */
70 zs
->ctl
= 0x44; /* 16x clk, 1 stop bit */
72 zs
->ctl
= 0xea; /* DTR on, 8 bit xmit, xmit on, RTS on */
74 zs
->ctl
= 0xc1; /* 8 bit recv, auto cd_cts, recv on */
76 zs
->ctl
= 0x00; /* no intrs */
78 zs
->ctl
= 0x00; /* no vector */
82 zs
->ctl
= 0x50; /* clocking options */
84 zs
->ctl
= 0x0e; /* 9600 baud, part 1 */
86 zs
->ctl
= 0x00; /* 9600 baud, part 2 */
88 zs
->ctl
= 0x03; /* more clocking options */
90 zs
->ctl
= 0x00; /* clear intrs */
94 * putchar: put char to console
100 putchar('\r'); /* avoid the need for \r\n in printf */
102 while ((zs
->ctl
& 0x04) == 0) {
110 * cngetc: get 1 char from console
117 while ((zs
->ctl
& 0x1) == 0) {
125 * puts: put string to console
132 while (*str
!= '\0') {
139 * ngets: get string from console
143 ngets(char *str
, int size
)
147 while ((i
< size
- 1) && (str
[i
] = cngetc()) != '\r') {
148 if (str
[i
] == '\b' || str
[i
] == 0x7F) {