1*49097Sbostic /*- 2*49097Sbostic * Copyright (c) 1991 The Regents of the University of California. 3*49097Sbostic * All rights reserved. 4*49097Sbostic * 5*49097Sbostic * This code is derived from software contributed to Berkeley by 6*49097Sbostic * Computer Consoles Inc. 7*49097Sbostic * 8*49097Sbostic * %sccs.include.redist.c% 9*49097Sbostic * 10*49097Sbostic * @(#)prf.c 7.1 (Berkeley) 05/04/91 11*49097Sbostic */ 1225870Ssam 1343457Sroot #include "sys/param.h" 1445796Sbostic #include "../tahoe/cp.h" 15*49097Sbostic #include "../include/mtpr.h" 1625870Ssam 1725870Ssam /* 1825870Ssam * Print a character on console. 1925870Ssam */ 2025870Ssam struct cpdcb_o cpout; 2125870Ssam struct cpdcb_i cpin; 2225870Ssam 2325870Ssam /* console requires even parity */ 2425870Ssam #define EVENP 2529979Skarels putchar(c)2625870Ssamputchar(c) 2729979Skarels char c; 2825870Ssam { 2925870Ssam int time; 3025870Ssam #ifdef EVENP 3125870Ssam register mask, par; 3225870Ssam 3329979Skarels for (par = 0, mask = 1; mask != 0200; mask <<= 1, par <<= 1) 3425870Ssam par ^= c&mask; 3525870Ssam c |= par; 36*49097Sbostic #endif /* EVENP */ 37*49097Sbostic cpout.cp_hdr.cp_unit = CPCONS; /* Resets done bit */ 3825870Ssam cpout.cp_hdr.cp_comm = CPWRITE; 3925870Ssam cpout.cp_hdr.cp_count = 1; 4025870Ssam cpout.cp_buf[0] = c; 4125870Ssam mtpr(CPMDCB, &cpout); 4225870Ssam time = 100000; /* Delay loop */ 4325870Ssam while (time--) { 4429979Skarels uncache(&cpout.cp_hdr.cp_unit); 4529979Skarels if (cpout.cp_hdr.cp_unit & CPDONE) 4629979Skarels break; 4725870Ssam } 4829979Skarels if (c == '\n') 4929979Skarels putchar ('\r'); 5025870Ssam } 5125870Ssam scankbd()52*49097Sbosticscankbd() 53*49097Sbostic {} 54*49097Sbostic getchar()5525870Ssamgetchar() 5625870Ssam { 5729979Skarels char c; 5825870Ssam 59*49097Sbostic cpin.cp_hdr.cp_unit = CPCONS; /* Resets done bit */ 6025870Ssam cpin.cp_hdr.cp_comm = CPREAD; 6125870Ssam cpin.cp_hdr.cp_count = 1; 6225870Ssam mtpr(CPMDCB, &cpin); 6325870Ssam while ((cpin.cp_hdr.cp_unit & CPDONE) == 0) 6429979Skarels uncache(&cpin.cp_hdr.cp_unit); 6529979Skarels uncache(&cpin.cpi_buf[0]); 6625870Ssam c = cpin.cpi_buf[0] & 0x7f; 6729979Skarels if (c == '\r') 6829979Skarels c = '\n'; 6929979Skarels if (c != '\b' && c != '\177') 7029979Skarels putchar(c); 7129979Skarels return (c); 7225870Ssam } 7333638Sbostic trap(ps)7433638Sbostictrap(ps) 7533638Sbostic int ps; 7633638Sbostic { 7733638Sbostic printf("Trap %o\n", ps); 7833638Sbostic for (;;) 7933638Sbostic ; 8033638Sbostic } 8133638Sbostic uncache(addr)8233638Sbosticuncache (addr) 8333638Sbostic char *addr; 8433638Sbostic { 8533638Sbostic /* Return *(addr-0x4000); DIRTY assumes this address is valid */ 8633638Sbostic mtpr(PDCS, addr); 8733638Sbostic } 88