Main Page   Class Hierarchy   Compound List   File List   Compound Members   File Members  

ConsoleInput Class Reference

The following class defines the input side of a hardware console device. Input to the device is simulated by reading to the UNIX file "readFile". Since input to the device is asynchronous, the interrupt handler "callWhenAvail" is called when a character has arrived to be read in.In practice, usually a single hardware thing that does serial input. More...

#include <console.h>

Inheritance diagram for ConsoleInput::

CallBackObj List of all members.

Public Methods

 ConsoleInput (char *readFile, CallBackObj *toCall)
 initialize hardware console input. More...

 ~ConsoleInput ()
 clean up console emulation. More...

char GetChar ()
 Poll the console input. If a char is available, return it. Otherwise, return EOF. "callWhenAvail" is called whenever there is a char to be gotten. More...

void CallBack ()
 Invoked when a character arrives from the keyboard. More...


Private Attributes

int readFileNo
 UNIX file emulating the keyboard. More...

CallBackObjcallWhenAvail
 Interrupt handler to call when there is a char to be read. More...

char incoming
 Contains the character to be read, if there is one available. Otherwise contains EOF. More...


Detailed Description

The following class defines the input side of a hardware console device. Input to the device is simulated by reading to the UNIX file "readFile". Since input to the device is asynchronous, the interrupt handler "callWhenAvail" is called when a character has arrived to be read in.In practice, usually a single hardware thing that does serial input.

Definition at line 43 of file console.h.


Constructor & Destructor Documentation

ConsoleInput::ConsoleInput ( char * readFile,
CallBackObj * toCall )
 

initialize hardware console input.

ConsoleInput::ConsoleInput Initialize the simulation of the input for a hardware console device.

"readFile" -- UNIX file simulating the keyboard (NULL -> use stdin) "toCall" is the interrupt handler to call when a character arrives from the keyboard

Definition at line 28 of file console.cc.

ConsoleInput::~ConsoleInput ( )
 

clean up console emulation.

ConsoleInput::~ConsoleInput Clean up console input emulation

Definition at line 48 of file console.cc.


Member Function Documentation

void ConsoleInput::CallBack ( ) [virtual]
 

Invoked when a character arrives from the keyboard.

ConsoleInput::CallBack() Simulator calls this when a character may be available to be read in from the simulated keyboard (eg, the user typed something).

First check to make sure character is available. Then invoke the "callBack" registered by whoever wants the character.

Reimplemented from CallBackObj.

Definition at line 65 of file console.cc.

char ConsoleInput::GetChar ( )
 

Poll the console input. If a char is available, return it. Otherwise, return EOF. "callWhenAvail" is called whenever there is a char to be gotten.

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

Definition at line 89 of file console.cc.

Referenced by SynchConsoleInput::GetChar().


Member Data Documentation

CallBackObj * ConsoleInput::callWhenAvail [private]
 

Interrupt handler to call when there is a char to be read.

Definition at line 59 of file console.h.

char ConsoleInput::incoming [private]
 

Contains the character to be read, if there is one available. Otherwise contains EOF.

Definition at line 61 of file console.h.

int ConsoleInput::readFileNo [private]
 

UNIX file emulating the keyboard.

Definition at line 58 of file console.h.


The documentation for this class was generated from the following files:
Generated at Wed Jul 4 11:32:23 2001 for Nachos by doxygen1.2.8.1 written by Dimitri van Heesch, © 1997-2001