1 /*- 2 * Copyright (c) 1991 The Regents of the University of California. 3 * All rights reserved. 4 * 5 * This code is derived from software contributed to Berkeley by 6 * Computer Consoles Inc. 7 * 8 * %sccs.include.redist.c% 9 * 10 * @(#)prf.c 7.1 (Berkeley) 05/04/91 11 */ 12 13 #include "sys/param.h" 14 #include "../tahoe/cp.h" 15 #include "../include/mtpr.h" 16 17 /* 18 * Print a character on console. 19 */ 20 struct cpdcb_o cpout; 21 struct cpdcb_i cpin; 22 23 /* console requires even parity */ 24 #define EVENP 25 26 putchar(c) 27 char c; 28 { 29 int time; 30 #ifdef EVENP 31 register mask, par; 32 33 for (par = 0, mask = 1; mask != 0200; mask <<= 1, par <<= 1) 34 par ^= c&mask; 35 c |= par; 36 #endif /* EVENP */ 37 cpout.cp_hdr.cp_unit = CPCONS; /* Resets done bit */ 38 cpout.cp_hdr.cp_comm = CPWRITE; 39 cpout.cp_hdr.cp_count = 1; 40 cpout.cp_buf[0] = c; 41 mtpr(CPMDCB, &cpout); 42 time = 100000; /* Delay loop */ 43 while (time--) { 44 uncache(&cpout.cp_hdr.cp_unit); 45 if (cpout.cp_hdr.cp_unit & CPDONE) 46 break; 47 } 48 if (c == '\n') 49 putchar ('\r'); 50 } 51 52 scankbd() 53 {} 54 55 getchar() 56 { 57 char c; 58 59 cpin.cp_hdr.cp_unit = CPCONS; /* Resets done bit */ 60 cpin.cp_hdr.cp_comm = CPREAD; 61 cpin.cp_hdr.cp_count = 1; 62 mtpr(CPMDCB, &cpin); 63 while ((cpin.cp_hdr.cp_unit & CPDONE) == 0) 64 uncache(&cpin.cp_hdr.cp_unit); 65 uncache(&cpin.cpi_buf[0]); 66 c = cpin.cpi_buf[0] & 0x7f; 67 if (c == '\r') 68 c = '\n'; 69 if (c != '\b' && c != '\177') 70 putchar(c); 71 return (c); 72 } 73 74 trap(ps) 75 int ps; 76 { 77 printf("Trap %o\n", ps); 78 for (;;) 79 ; 80 } 81 82 uncache (addr) 83 char *addr; 84 { 85 /* Return *(addr-0x4000); DIRTY assumes this address is valid */ 86 mtpr(PDCS, addr); 87 } 88