xref: /original-bsd/sys/vax/stand/prf.c (revision e21485a6)
1 /*
2  * Copyright (c) 1982, 1986 Regents of the University of California.
3  * All rights reserved.  The Berkeley software License Agreement
4  * specifies the terms and conditions for redistribution.
5  *
6  *	@(#)prf.c	7.8 (Berkeley) 05/04/91
7  */
8 
9 #include "sys/param.h"
10 
11 #include "../include/mtpr.h"
12 #include "../vax/cons.h"
13 
14 /*
15  * Print a character on console.
16  */
17 putchar(c)
18 	register c;
19 {
20 	register s, timo;
21 #if VAX630 || VAX650
22 	extern (*v_putc)();
23 
24 	if (v_putc) {
25 		(*v_putc)(c);
26 		if (c == '\n')
27 			(*v_putc)('\r');
28 		return;
29 	}
30 #endif
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 
50 scankbd()
51 {}
52 
53 getchar()
54 {
55 	register c;
56 #if VAX630 || VAX650
57 	extern (*v_getc)();
58 
59 	if (v_getc) {
60 		c = (*v_getc)();
61 	} else {
62 #endif
63 	while((mfpr(RXCS)&RXCS_DONE) == 0)
64 		;
65 	c = mfpr(RXDB)&0177;
66 #if VAX630 || VAX650
67 	}
68 #endif
69 	if (c=='\r')
70 		c = '\n';
71 	if (c != '\b' && c != '\177')
72 		putchar(c);
73 	return(c);
74 }
75