BSD 4_4 release
[unix-history] / usr / src / sys / vax / stand / prf.c
CommitLineData
55b4dbd0 1/*
0880b18e 2 * Copyright (c) 1982, 1986 Regents of the University of California.
55b4dbd0
KM
3 * All rights reserved. The Berkeley software License Agreement
4 * specifies the terms and conditions for redistribution.
5 *
ad787160 6 * @(#)prf.c 7.8 (Berkeley) 5/4/91
55b4dbd0 7 */
4d05cd07 8
b28b3a13 9#include "sys/param.h"
a031a31b 10
b28b3a13 11#include "../include/mtpr.h"
a031a31b 12#include "../vax/cons.h"
4d05cd07 13
4d05cd07
BJ
14/*
15 * Print a character on console.
4d05cd07
BJ
16 */
17putchar(c)
99fe9747 18 register c;
4d05cd07
BJ
19{
20 register s, timo;
f6322301 21#if VAX630 || VAX650
253bb020 22 extern (*v_putc)();
4d05cd07 23
253bb020
MT
24 if (v_putc) {
25 (*v_putc)(c);
26 if (c == '\n')
27 (*v_putc)('\r');
28 return;
29 }
30#endif
4d05cd07
BJ
31 timo = 30000;
32 /*
33 * Try waiting for the console tty to come ready,
34 * otherwise give up after a reasonable time.
35 */
36 while((mfpr(TXCS)&TXCS_RDY) == 0)
37 if(--timo == 0)
38 break;
39 if(c == 0)
40 return;
41 s = mfpr(TXCS);
42 mtpr(TXCS,0);
43 mtpr(TXDB, c&0xff);
44 if(c == '\n')
45 putchar('\r');
46 putchar(0);
47 mtpr(TXCS, s);
48}
49
7e197f83
KB
50scankbd()
51{}
52
4d05cd07
BJ
53getchar()
54{
55 register c;
f6322301 56#if VAX630 || VAX650
253bb020 57 extern (*v_getc)();
4d05cd07 58
253bb020
MT
59 if (v_getc) {
60 c = (*v_getc)();
61 } else {
62#endif
4d05cd07
BJ
63 while((mfpr(RXCS)&RXCS_DONE) == 0)
64 ;
65 c = mfpr(RXDB)&0177;
f6322301 66#if VAX630 || VAX650
253bb020
MT
67 }
68#endif
4d05cd07
BJ
69 if (c=='\r')
70 c = '\n';
a14fe297
MK
71 if (c != '\b' && c != '\177')
72 putchar(c);
4d05cd07
BJ
73 return(c);
74}