tac0S
Template Affectional Command Operating System
console.h
Go to the documentation of this file.
1 
25 #ifndef CONSOLE_H
26 #define CONSOLE_H
27 
28 #include "copyright.h"
29 #include "utility.h"
30 
39 
40 class Console {
41  public:
42  Console(char *readFile, char *writeFile, VoidFunctionPtr readAvail,
43  VoidFunctionPtr writeDone, int callArg);
44  // initialize the hardware console device
45  ~Console(); // clean up console emulation
46 
47 // external interface -- Nachos kernel code can call these
48  void PutChar(char ch); // Write "ch" to the console display,
49  // and return immediately. "writeHandler"
50  // is called when the I/O completes.
51 
52  char GetChar(); // Poll the console input. If a char is
53  // available, return it. Otherwise, return EOF.
54  // "readHandler" is called whenever there is
55  // a char to be gotten
56 
57 // internal emulation routines -- DO NOT call these.
58  void WriteDone(); // internal routines to signal I/O completion
59  void CheckCharAvail();
60  // Retrurn true if EndOfFile(nothing to read there)
61  bool Feof();
62 
63  private:
64  int readFileNo; // UNIX file emulating the keyboard
65  int writeFileNo; // UNIX file emulating the display
66  VoidFunctionPtr writeHandler; // Interrupt handler to call when
67  // the PutChar I/O completes
68  VoidFunctionPtr readHandler; // Interrupt handler to call when
69  // a character arrives from the keyboard
70  int handlerArg; // argument to be passed to the
71  // interrupt handlers
72  bool putBusy; // Is a PutChar operation in progress?
73  // If so, you can't do another one!
74  char incoming; // Contains the character to be read,
75  // if there is one available.
76  // Otherwise contains EOF.
77 
78 
79 };
80 
81 #endif // CONSOLE_H
bool Feof()
Console::Feof Initialize the simulation of a hardware console device.
Definition: console.cc:161
void PutChar(char ch)
Console::PutChar() Write a character to the simulated display, schedule an interrupt to occur in the ...
Definition: console.cc:146
void CheckCharAvail()
Console::CheckCharAvail() Periodically called to check if a character is available for input from the...
Definition: console.cc:89
~Console()
Console::~Console Clean up console emulation.
Definition: console.cc:69
Console(char *readFile, char *writeFile, VoidFunctionPtr readAvail, VoidFunctionPtr writeDone, int callArg)
Console::Console Initialize the simulation of a hardware console device.
Definition: console.cc:41
char GetChar()
Console::GetChar() Read a character from the input buffer, if there is any there. Either return the c...
Definition: console.cc:131
The following class defines a hardware console device. Input and output to the device is simulated by...
Definition: console.h:40
Miscellaneous useful definitions, including debugging routines.
void WriteDone()
Console::WriteDone() Internal routine called when it is time to invoke the interrupt handler to tell ...
Definition: console.cc:117