tac0S
Template Affectional Command Operating System
|
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... | |
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.
Console::Console | ( | char * | readFile, |
char * | writeFile, | ||
VoidFunctionPtr | readAvail, | ||
VoidFunctionPtr | writeDone, | ||
int | callArg | ||
) |
Console::Console Initialize the simulation of a hardware console device.
readFile | – UNIX file simulating the keyboard (NULL -> use stdin) |
writeFile | – UNIX file simulating the display (NULL -> use stdout) |
readAvail | is the interrupt handler called when a character arrives from the keyboard |
writeDone | is the interrupt handler called when a character has been output, so that it is ok to request the next char be output |
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.
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.
void Console::PutChar | ( | char | ch | ) |
Console::PutChar() Write a character to the simulated display, schedule an interrupt to occur in the future, and return.
ch | : The caracter you wanted to be Put |