|
|
1.1.1.2 ! root 1: /* kprintf.c - kprintf, kputc--slightly edited from original Xinu */ 1.1 root 2: 3: #include <conf.h> 4: #include <kernel.h> 5: #include <io.h> 6: #include <tty.h> 1.1.1.2 ! root 7: ! 8: /* set up macros for appropriate SLU as spec. by SLUCHIP: ! 9: if SLUCHIP==6850, #include slu6850.h, #define TTYWRITE ttywrite6850, etc. ! 10: if SLUCHIP==7201, #include slu7201.h, #define TTYWRITE ttywrite7201, etc. ! 11: if SLUCHIP undef.,#include slu.h, #define TTYWRITE ttywrite (orig. case) ! 12: similarly sluaccess.h, other TTY fns */ ! 13: #include <sluinclude.h> ! 14: #ifdef ATT7300 ! 15: int slowtime = 500; ! 16: /* Xinu console is the serial port on the back, assumed already ! 17: initialized by the downloading support */ ! 18: #else ! 19: int slowtime = 200; ! 20: /* MECB console is the console MC6850, init'd by TUTOR */ ! 21: #endif 1.1 root 22: 23: /*------------------------------------------------------------------------ 24: * kprintf -- kernel printf: formatted, unbuffered output to CONSOLE 25: *------------------------------------------------------------------------ 26: */ 1.1.1.2 ! root 27: ! 28: /* kprintf is the routine to use for polling output, even in the case that */ ! 29: /* the calling program also uses SLU interrupts. It shuts out interrupts */ ! 30: /* by going high-CPU-priority, saving the old CPU priority locally and */ ! 31: /* reestablishing it on return. It varies from the original Vol I. Xinu */ ! 32: /* sources by not changing the device control register, but rather just */ ! 33: /* relying on high CPU priority to hold the console (did the original SLU */ ! 34: /* fail to post a transmit ready bit with interrupts enabled??) */ ! 35: 1.1 root 36: kprintf(fmt, args) /* Derived by Bob Brown, Purdue U. */ 1.1.1.2 ! root 37: char *fmt; 1.1 root 38: { 1.1.1.2 ! root 39: static unsigned short savesr; ! 40: int kputc(); ! 41: ! 42: _disable(&savesr); /* orig. Xinu had "savestate()" */ ! 43: _doprnt(fmt, &args, kputc, CONSOLE); ! 44: _restore(&savesr); /* orig. Xinu had "rststate()" */ ! 45: return(OK); 1.1 root 46: } 47: 48: /*------------------------------------------------------------------------ 1.1.1.2 ! root 49: * kputc -- write a character on the console (or other SLU) ! 50: * using polled I/O 1.1 root 51: *------------------------------------------------------------------------ 52: */ 1.1.1.2 ! root 53: kputc(device,c) ! 54: int device; ! 55: register char c; /* character to print from _doprnt */ 1.1 root 56: { 1.1.1.2 ! root 57: struct csr *csrptr; ! 58: /*T*/ int slowdown; /* added to delay output because host */ ! 59: /*T*/ /* can't take it at 9600 baud */ ! 60: if ( c == 0 ) 1.1 root 61: return; 62: if ( c == NEWLINE ) 1.1.1.2 ! root 63: kputc(device, RETURN ); ! 64: csrptr = (struct csr *)devtab[device].dvcsr; ! 65: while ( (csrptr->cstat & SLUTRANSREADY) == 0 ) ; /* poll for idle*/ ! 66: csrptr->cbuf = c; ! 67: /*T*/ for(slowdown=0;slowdown<slowtime;slowdown++) ; ! 68: while ( (csrptr->cstat & SLUTRANSREADY) == 0 ) ; /* poll for idle*/ 1.1 root 69: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.