Main Page | Alphabetical List | Class List | File List | Class Members | File Members

Console Class Reference

#include <console.h>

List of all members.

Public Member Functions

 Console (char *readFile, char *writeFile, VoidFunctionPtr readAvail, VoidFunctionPtr writeDone, int callArg)
 ~Console ()
void PutChar (char ch)
char GetChar ()
void WriteDone ()
void CheckCharAvail ()


Constructor & Destructor Documentation

Console::Console char *  readFile,
char *  writeFile,
VoidFunctionPtr  readAvail,
VoidFunctionPtr  writeDone,
int  callArg
 

Definition at line 39 of file console.cc.

References ConsoleReadInt, ConsoleTime, FALSE, interrupt, OpenForReadWrite(), OpenForWrite(), Interrupt::Schedule(), TRUE, and VoidFunctionPtr.

00041 { 00042 if (readFile == NULL) 00043 readFileNo = 0; // keyboard = stdin 00044 else 00045 readFileNo = OpenForReadWrite(readFile, TRUE); // should be read-only 00046 if (writeFile == NULL) 00047 writeFileNo = 1; // display = stdout 00048 else 00049 writeFileNo = OpenForWrite(writeFile); 00050 00051 // set up the stuff to emulate asynchronous interrupts 00052 writeHandler = writeDone; 00053 readHandler = readAvail; 00054 handlerArg = callArg; 00055 putBusy = FALSE; 00056 incoming = EOF; 00057 00058 // start polling for incoming packets 00059 interrupt->Schedule(ConsoleReadPoll, (int)this, ConsoleTime, ConsoleReadInt); 00060 }

Console::~Console  ) 
 

Definition at line 67 of file console.cc.

References Close().

00068 { 00069 if (readFileNo != 0) 00070 Close(readFileNo); 00071 if (writeFileNo != 1) 00072 Close(writeFileNo); 00073 }


Member Function Documentation

void Console::CheckCharAvail  ) 
 

Definition at line 87 of file console.cc.

References ConsoleReadInt, ConsoleTime, interrupt, Statistics::numConsoleCharsRead, PollFile(), Read(), Interrupt::Schedule(), and stats.

00088 { 00089 char c; 00090 00091 // schedule the next time to poll for a packet 00092 interrupt->Schedule(ConsoleReadPoll, (int)this, ConsoleTime, 00093 ConsoleReadInt); 00094 00095 // do nothing if character is already buffered, or none to be read 00096 if ((incoming != EOF) || !PollFile(readFileNo)) 00097 return; 00098 00099 // otherwise, read character and tell user about it 00100 Read(readFileNo, &c, sizeof(char)); 00101 incoming = c ; 00102 stats->numConsoleCharsRead++; 00103 (*readHandler)(handlerArg); 00104 }

char Console::GetChar  ) 
 

Definition at line 128 of file console.cc.

00129 { 00130 char ch = incoming; 00131 00132 incoming = EOF; 00133 return ch; 00134 }

void Console::PutChar char  ch  ) 
 

Definition at line 143 of file console.cc.

References ASSERT, ConsoleTime, ConsoleWriteInt, FALSE, interrupt, Interrupt::Schedule(), TRUE, and WriteFile().

00144 { 00145 ASSERT(putBusy == FALSE); 00146 WriteFile(writeFileNo, &ch, sizeof(char)); 00147 putBusy = TRUE; 00148 interrupt->Schedule(ConsoleWriteDone, (int)this, ConsoleTime, 00149 ConsoleWriteInt); 00150 }

void Console::WriteDone  ) 
 

Definition at line 114 of file console.cc.

References FALSE, Statistics::numConsoleCharsWritten, and stats.

00115 { 00116 putBusy = FALSE; 00117 stats->numConsoleCharsWritten++; 00118 (*writeHandler)(handlerArg); 00119 }


The documentation for this class was generated from the following files:
Generated on Thu Sep 16 12:33:48 2004 for NachOS by doxygen 1.3.8