2005-04-08 17:01:17 +02:00
|
|
|
#ifndef CONSOLE_H
|
|
|
|
#define CONSOLE_H
|
|
|
|
|
2010-04-19 21:16:01 +02:00
|
|
|
#include <ipxe/tables.h>
|
2005-04-08 17:01:17 +02:00
|
|
|
|
2005-05-20 12:24:11 +02:00
|
|
|
/** @file
|
|
|
|
*
|
|
|
|
* User interaction.
|
|
|
|
*
|
|
|
|
* Various console devices can be selected via the build options
|
|
|
|
* CONSOLE_FIRMWARE, CONSOLE_SERIAL etc. The console functions
|
|
|
|
* putchar(), getchar() and iskey() delegate to the individual console
|
|
|
|
* drivers.
|
|
|
|
*
|
2005-04-08 17:01:17 +02:00
|
|
|
*/
|
|
|
|
|
2009-05-01 16:41:06 +02:00
|
|
|
FILE_LICENCE ( GPL2_OR_LATER );
|
|
|
|
|
2005-05-20 12:24:11 +02:00
|
|
|
/**
|
|
|
|
* A console driver
|
|
|
|
*
|
|
|
|
* Defines the functions that implement a particular console type.
|
|
|
|
* Must be made part of the console drivers table by using
|
|
|
|
* #__console_driver.
|
|
|
|
*
|
2007-07-04 00:09:56 +02:00
|
|
|
* @note Consoles that cannot be used before their initialisation
|
|
|
|
* function has completed should set #disabled=1 initially. This
|
|
|
|
* allows other console devices to still be used to print out early
|
|
|
|
* debugging messages.
|
2005-05-20 12:24:11 +02:00
|
|
|
*
|
|
|
|
*/
|
2005-04-08 17:01:17 +02:00
|
|
|
struct console_driver {
|
2005-05-20 12:24:11 +02:00
|
|
|
/** Console is disabled.
|
|
|
|
*
|
2010-07-14 12:27:42 +02:00
|
|
|
* The console's putchar(), getchar() and iskey() methods will
|
|
|
|
* not be called while #disabled==1. Typically the console's
|
|
|
|
* initialisation functions will set #disabled=0 upon
|
|
|
|
* completion.
|
2005-05-20 12:24:11 +02:00
|
|
|
*
|
|
|
|
*/
|
2005-04-08 17:01:17 +02:00
|
|
|
int disabled;
|
2005-05-20 12:24:11 +02:00
|
|
|
|
|
|
|
/** Write a character to the console.
|
|
|
|
*
|
|
|
|
* @v character Character to be written
|
2005-05-24 02:11:25 +02:00
|
|
|
* @ret None -
|
|
|
|
* @err None -
|
2005-05-20 12:24:11 +02:00
|
|
|
*
|
|
|
|
*/
|
2005-04-08 17:01:17 +02:00
|
|
|
void ( *putchar ) ( int character );
|
2005-05-20 12:24:11 +02:00
|
|
|
|
|
|
|
/** Read a character from the console.
|
|
|
|
*
|
2005-05-24 02:11:25 +02:00
|
|
|
* @v None -
|
2005-05-20 12:24:11 +02:00
|
|
|
* @ret character Character read
|
2005-05-24 02:11:25 +02:00
|
|
|
* @err None -
|
2005-05-20 12:24:11 +02:00
|
|
|
*
|
|
|
|
* If no character is available to be read, this method will
|
|
|
|
* block. The character read should not be echoed back to the
|
|
|
|
* console.
|
|
|
|
*
|
|
|
|
*/
|
2005-04-08 17:01:17 +02:00
|
|
|
int ( *getchar ) ( void );
|
2005-05-20 12:24:11 +02:00
|
|
|
|
|
|
|
/** Check for available input.
|
|
|
|
*
|
2005-05-24 02:11:25 +02:00
|
|
|
* @v None -
|
2005-05-20 12:24:11 +02:00
|
|
|
* @ret True Input is available
|
|
|
|
* @ret False Input is not available
|
2005-05-24 02:11:25 +02:00
|
|
|
* @err None -
|
2005-05-20 12:24:11 +02:00
|
|
|
*
|
|
|
|
* This should return True if a subsequent call to getchar()
|
|
|
|
* will not block.
|
|
|
|
*
|
|
|
|
*/
|
2005-04-08 17:01:17 +02:00
|
|
|
int ( *iskey ) ( void );
|
|
|
|
};
|
|
|
|
|
2009-03-12 20:41:40 +01:00
|
|
|
/** Console driver table */
|
2009-03-13 01:13:38 +01:00
|
|
|
#define CONSOLES __table ( struct console_driver, "consoles" )
|
2009-03-12 20:41:40 +01:00
|
|
|
|
2005-05-20 12:24:11 +02:00
|
|
|
/**
|
|
|
|
* Mark a <tt> struct console_driver </tt> as being part of the
|
|
|
|
* console drivers table.
|
|
|
|
*
|
|
|
|
* Use as e.g.
|
|
|
|
*
|
|
|
|
* @code
|
|
|
|
*
|
|
|
|
* struct console_driver my_console __console_driver = {
|
|
|
|
* .putchar = my_putchar,
|
|
|
|
* .getchar = my_getchar,
|
|
|
|
* .iskey = my_iskey,
|
|
|
|
* };
|
|
|
|
*
|
|
|
|
* @endcode
|
|
|
|
*
|
|
|
|
*/
|
2009-03-13 01:13:38 +01:00
|
|
|
#define __console_driver __table_entry ( CONSOLES, 01 )
|
2005-04-08 17:01:17 +02:00
|
|
|
|
|
|
|
/* Function prototypes */
|
|
|
|
|
|
|
|
extern void putchar ( int character );
|
|
|
|
extern int getchar ( void );
|
2010-07-14 13:37:29 +02:00
|
|
|
extern int getchar_timeout ( unsigned long timeout );
|
2005-04-08 17:01:17 +02:00
|
|
|
extern int iskey ( void );
|
2006-12-20 22:56:50 +01:00
|
|
|
extern int getkey ( void );
|
2005-04-08 17:01:17 +02:00
|
|
|
|
|
|
|
#endif /* CONSOLE_H */
|