2005-04-08 17:01:17 +02:00
|
|
|
#ifndef CONSOLE_H
|
|
|
|
#define CONSOLE_H
|
|
|
|
|
|
|
|
#include "stdint.h"
|
2005-04-17 12:44:26 +02:00
|
|
|
#include "vsprintf.h"
|
2006-04-24 17:42:49 +02:00
|
|
|
#include <gpxe/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
|
|
|
*/
|
|
|
|
|
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.
|
|
|
|
*
|
|
|
|
* @note Consoles that cannot be used before their INIT_FN() has
|
|
|
|
* completed should set #disabled=1 initially. This allows other
|
|
|
|
* console devices to still be used to print out early debugging
|
|
|
|
* messages.
|
|
|
|
*
|
|
|
|
*/
|
2005-04-08 17:01:17 +02:00
|
|
|
struct console_driver {
|
2005-05-20 12:24:11 +02:00
|
|
|
/** Console is disabled.
|
|
|
|
*
|
|
|
|
* The console's putchar(), getchar() and iskey() methods will
|
|
|
|
* not be called while #disabled==1. Typically the
|
|
|
|
* console's initialisation functions (called via INIT_FN())
|
|
|
|
* will set #disabled=0 upon completion.
|
|
|
|
*
|
|
|
|
*/
|
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 );
|
|
|
|
};
|
|
|
|
|
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
|
|
|
|
*
|
|
|
|
*/
|
2005-05-17 14:16:28 +02:00
|
|
|
#define __console_driver __table ( console, 01 )
|
2005-04-08 17:01:17 +02:00
|
|
|
|
|
|
|
/* Function prototypes */
|
|
|
|
|
|
|
|
extern void putchar ( int character );
|
|
|
|
extern int getchar ( void );
|
|
|
|
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 */
|