console.h

Go to the documentation of this file.
00001 #ifndef CONSOLE_H
00002 #define CONSOLE_H
00003 
00004 #include <gpxe/tables.h>
00005 
00006 /** @file
00007  *
00008  * User interaction.
00009  *
00010  * Various console devices can be selected via the build options
00011  * CONSOLE_FIRMWARE, CONSOLE_SERIAL etc.  The console functions
00012  * putchar(), getchar() and iskey() delegate to the individual console
00013  * drivers.
00014  *
00015  */
00016 
00017 FILE_LICENCE ( GPL2_OR_LATER );
00018 
00019 /**
00020  * A console driver
00021  *
00022  * Defines the functions that implement a particular console type.
00023  * Must be made part of the console drivers table by using
00024  * #__console_driver.
00025  *
00026  * @note Consoles that cannot be used before their initialisation
00027  * function has completed should set #disabled=1 initially.  This
00028  * allows other console devices to still be used to print out early
00029  * debugging messages.
00030  *
00031  */
00032 struct console_driver {
00033         /** Console is disabled.
00034          *
00035          * The console's putchar(), putline(), getchar() and iskey()
00036          * methods will not be called while #disabled==1. Typically
00037          * the console's initialisation functions will set #disabled=0
00038          * upon completion.
00039          *
00040          */
00041         int disabled;
00042 
00043         /** Write a character to the console.
00044          *
00045          * @v character         Character to be written
00046          * @ret None            -
00047          * @err None            -
00048          *
00049          */
00050         void ( *putchar ) ( int character );
00051 
00052         /** Write an entire line to the console.
00053          * This is intended to be used by line-oriented output media,
00054          * like system logging facilities or line printers.
00055          * Line output will not contain non-printable characters.
00056          *
00057          * @v linebuffer        Pointer to the \0-terminated line
00058          * @ret None            -
00059          * @err None            -
00060          */
00061         void ( * putline ) ( unsigned char * linebuffer );
00062 
00063         /** Read a character from the console.
00064          *
00065          * @v None              -
00066          * @ret character       Character read
00067          * @err None            -
00068          *
00069          * If no character is available to be read, this method will
00070          * block.  The character read should not be echoed back to the
00071          * console.
00072          *
00073          */
00074         int ( *getchar ) ( void );
00075 
00076         /** Check for available input.
00077          *
00078          * @v None              -
00079          * @ret True            Input is available
00080          * @ret False           Input is not available
00081          * @err None            -
00082          *
00083          * This should return True if a subsequent call to getchar()
00084          * will not block.
00085          *
00086          */
00087         int ( *iskey ) ( void );
00088 };
00089 
00090 /** Console driver table */
00091 #define CONSOLES __table ( struct console_driver, "consoles" )
00092 
00093 /**
00094  * Mark a <tt> struct console_driver </tt> as being part of the
00095  * console drivers table.
00096  *
00097  * Use as e.g.
00098  *
00099  * @code
00100  *
00101  *   struct console_driver my_console __console_driver = {
00102  *      .putchar = my_putchar,
00103  *      .getchar = my_getchar,
00104  *      .iskey = my_iskey,
00105  *   };
00106  *
00107  * @endcode
00108  *
00109  */
00110 #define __console_driver __table_entry ( CONSOLES, 01 )
00111 
00112 /* Function prototypes */
00113 
00114 extern void putchar ( int character );
00115 extern int getchar ( void );
00116 extern int iskey ( void );
00117 extern int getkey ( void );
00118 
00119 #endif /* CONSOLE_H */

Generated on Tue Apr 6 20:00:51 2010 for gPXE by  doxygen 1.5.7.1