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

console.h

Go to the documentation of this file.
00001 // console.h 00002 // Data structures to simulate the behavior of a terminal 00003 // I/O device. A terminal has two parts -- a keyboard input, 00004 // and a display output, each of which produces/accepts 00005 // characters sequentially. 00006 // 00007 // The console hardware device is asynchronous. When a character is 00008 // written to the device, the routine returns immediately, and an 00009 // interrupt handler is called later when the I/O completes. 00010 // For reads, an interrupt handler is called when a character arrives. 00011 // 00012 // The user of the device can specify the routines to be called when 00013 // the read/write interrupts occur. There is a separate interrupt 00014 // for read and write, and the device is "duplex" -- a character 00015 // can be outgoing and incoming at the same time. 00016 // 00017 // DO NOT CHANGE -- part of the machine emulation 00018 // 00019 // Copyright (c) 1992-1993 The Regents of the University of California. 00020 // All rights reserved. See copyright.h for copyright notice and limitation 00021 // of liability and disclaimer of warranty provisions. 00022 00023 #ifndef CONSOLE_H 00024 #define CONSOLE_H 00025 00026 #include "copyright.h" 00027 #include "utility.h" 00028 00029 // The following class defines a hardware console device. 00030 // Input and output to the device is simulated by reading 00031 // and writing to UNIX files ("readFile" and "writeFile"). 00032 // 00033 // Since the device is asynchronous, the interrupt handler "readAvail" 00034 // is called when a character has arrived, ready to be read in. 00035 // The interrupt handler "writeDone" is called when an output character 00036 // has been "put", so that the next character can be written. 00037 00038 class Console { 00039 public: 00040 Console(char *readFile, char *writeFile, VoidFunctionPtr readAvail, 00041 VoidFunctionPtr writeDone, int callArg); 00042 // initialize the hardware console device 00043 ~Console(); // clean up console emulation 00044 00045 // external interface -- Nachos kernel code can call these 00046 void PutChar(char ch); // Write "ch" to the console display, 00047 // and return immediately. "writeHandler" 00048 // is called when the I/O completes. 00049 00050 char GetChar(); // Poll the console input. If a char is 00051 // available, return it. Otherwise, return EOF. 00052 // "readHandler" is called whenever there is 00053 // a char to be gotten 00054 00055 // internal emulation routines -- DO NOT call these. 00056 void WriteDone(); // internal routines to signal I/O completion 00057 void CheckCharAvail(); 00058 00059 private: 00060 int readFileNo; // UNIX file emulating the keyboard 00061 int writeFileNo; // UNIX file emulating the display 00062 VoidFunctionPtr writeHandler; // Interrupt handler to call when 00063 // the PutChar I/O completes 00064 VoidFunctionPtr readHandler; // Interrupt handler to call when 00065 // a character arrives from the keyboard 00066 int handlerArg; // argument to be passed to the 00067 // interrupt handlers 00068 bool putBusy; // Is a PutChar operation in progress? 00069 // If so, you can't do another one! 00070 char incoming; // Contains the character to be read, 00071 // if there is one available. 00072 // Otherwise contains EOF. 00073 }; 00074 00075 #endif // CONSOLE_H

Generated on Thu Sep 16 12:33:44 2004 for NachOS by doxygen 1.3.8