tac0S
Template Affectional Command Operating System
Public Member Functions | List of all members
Console Class Reference

The following class defines a hardware console device. Input and output to the device is simulated by reading and writing to UNIX files ("readFile" and "writeFile"). More...

#include <console.h>

Public Member Functions

 Console (char *readFile, char *writeFile, VoidFunctionPtr readAvail, VoidFunctionPtr writeDone, int callArg)
 Console::Console Initialize the simulation of a hardware console device. More...
 
 ~Console ()
 Console::~Console Clean up console emulation.
 
void PutChar (char ch)
 Console::PutChar() Write a character to the simulated display, schedule an interrupt to occur in the future, and return. More...
 
char GetChar ()
 Console::GetChar() Read a character from the input buffer, if there is any there. Either return the character, or EOF if none buffered. More...
 
void WriteDone ()
 Console::WriteDone() Internal routine called when it is time to invoke the interrupt handler to tell the Nachos kernel that the output character has completed.
 
void CheckCharAvail ()
 Console::CheckCharAvail() Periodically called to check if a character is available for input from the simulated keyboard (eg, has it been typed?). More...
 
bool Feof ()
 Console::Feof Initialize the simulation of a hardware console device. More...
 

Detailed Description

The following class defines a hardware console device. Input and output to the device is simulated by reading and writing to UNIX files ("readFile" and "writeFile").

Since the device is asynchronous, the interrupt handler "readAvail" is called when a character has arrived, ready to be read in. The interrupt handler "writeDone" is called when an output character has been "put", so that the next character can be written.

Constructor & Destructor Documentation

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

Console::Console Initialize the simulation of a hardware console device.

Parameters
readFile– UNIX file simulating the keyboard (NULL -> use stdin)
writeFile– UNIX file simulating the display (NULL -> use stdout)
readAvailis the interrupt handler called when a character arrives from the keyboard
writeDoneis the interrupt handler called when a character has been output, so that it is ok to request the next char be output

Member Function Documentation

void Console::CheckCharAvail ( )

Console::CheckCharAvail() Periodically called to check if a character is available for input from the simulated keyboard (eg, has it been typed?).

Only read it in if there is buffer space for it (if the previous character has been grabbed out of the buffer by the Nachos kernel). Invoke the "read" interrupt handler, once the character has been put into the buffer.

bool Console::Feof ( )

Console::Feof Initialize the simulation of a hardware console device.

Returns
bool : Return a bololean that indicate wether there is something more to read or not
char Console::GetChar ( )

Console::GetChar() Read a character from the input buffer, if there is any there. Either return the character, or EOF if none buffered.

Returns
char The caracter available in the current FD
void Console::PutChar ( char  ch)

Console::PutChar() Write a character to the simulated display, schedule an interrupt to occur in the future, and return.

Parameters
ch: The caracter you wanted to be Put

The documentation for this class was generated from the following files: