#include <gpxe/tables.h>
Go to the source code of this file.
Data Structures | |
| struct | console_driver |
| A console driver. More... | |
Defines | |
| #define | CONSOLES __table ( struct console_driver, "consoles" ) |
| Console driver table. | |
| #define | __console_driver __table_entry ( CONSOLES, 01 ) |
Mark a struct console_driver as being part of the console drivers table. | |
Functions | |
| FILE_LICENCE (GPL2_OR_LATER) | |
| void | putchar (int character) |
| Write a single character to each console device. | |
| int | getchar (void) |
| Read a single character from any console. | |
| int | iskey (void) |
| Check for available input on any console. | |
| int | getkey (void) |
| Get single keypress. | |
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.
Definition in file console.h.
| #define CONSOLES __table ( struct console_driver, "consoles" ) |
Console driver table.
Definition at line 91 of file console.h.
Referenced by has_input(), and putchar().
struct console_driver serial_console __console_driver __table_entry ( CONSOLES, 01 ) [read] |
Mark a struct console_driver as being part of the console drivers table.
Use as e.g.
struct console_driver my_console __console_driver = { .putchar = my_putchar, .getchar = my_getchar, .iskey = my_iskey, };
| FILE_LICENCE | ( | GPL2_OR_LATER | ) |
| void putchar | ( | int | character | ) |
Write a single character to each console device.
| character | Character to be written |
| None | - |
| None | - |
Definition at line 21 of file console.c.
References CONSOLES, console_driver::disabled, for_each_table_entry, console_driver::putchar, and putchar().
Referenced by ansiscr_putc(), clrline(), eepro_poll(), epic100_open(), falcon_init_xmac(), get_eeprom_data(), int21(), print_user_string(), printf_putchar(), putchar(), readline(), and sync_console().
00021 { 00022 struct console_driver *console; 00023 00024 /* Automatic LF -> CR,LF translation */ 00025 if ( character == '\n' ) 00026 putchar ( '\r' ); 00027 00028 for_each_table_entry ( console, CONSOLES ) { 00029 if ( ( ! console->disabled ) && console->putchar ) 00030 console->putchar ( character ); 00031 } 00032 }
| int getchar | ( | void | ) |
Read a single character from any console.
| None | - |
| character | Character read from a console. |
| None | - |
The character read will not be echoed back to any console.
Definition at line 80 of file console.c.
References cpu_nap(), console_driver::getchar, has_input(), and step().
Referenced by ansiscr_getc(), getchar_timeout(), getkey(), iflinkwait(), int21(), monojob_wait(), more(), pause(), and shell_banner().
00080 { 00081 struct console_driver *console; 00082 int character; 00083 00084 while ( 1 ) { 00085 console = has_input(); 00086 if ( console && console->getchar ) { 00087 character = console->getchar (); 00088 break; 00089 } 00090 00091 /* Doze for a while (until the next interrupt). This works 00092 * fine, because the keyboard is interrupt-driven, and the 00093 * timer interrupt (approx. every 50msec) takes care of the 00094 * serial port, which is read by polling. This reduces the 00095 * power dissipation of a modern CPU considerably, and also 00096 * makes Etherboot waiting for user interaction waste a lot 00097 * less CPU time in a VMware session. 00098 */ 00099 cpu_nap(); 00100 00101 /* Keep processing background tasks while we wait for 00102 * input. 00103 */ 00104 step(); 00105 } 00106 00107 /* CR -> LF translation */ 00108 if ( character == '\r' ) 00109 character = '\n'; 00110 00111 return character; 00112 }
| int iskey | ( | void | ) |
Check for available input on any console.
| None | - |
| True | Input is available on a console | |
| False | Input is not available on any console |
| None | - |
Definition at line 128 of file console.c.
References has_input().
Referenced by ansiscr_peek(), getchar_timeout(), iflinkwait(), int21(), monojob_wait(), pxe_menu_prompt_and_select(), pxe_menu_select(), and shell_banner().
00128 { 00129 return has_input() ? 1 : 0; 00130 }
| int getkey | ( | void | ) |
Get single keypress.
| key | Key pressed |
Definition at line 63 of file getkey.c.
References ESC, getchar(), getchar_timeout(), GETKEY_TIMEOUT, isdigit, and KEY_ANSI.
Referenced by login_ui(), main_loop(), pxe_menu_prompt_and_select(), pxe_menu_select(), and readline().
00063 { 00064 int character; 00065 unsigned int n = 0; 00066 00067 character = getchar(); 00068 if ( character != ESC ) 00069 return character; 00070 00071 while ( ( character = getchar_timeout ( GETKEY_TIMEOUT ) ) >= 0 ) { 00072 if ( character == '[' ) 00073 continue; 00074 if ( isdigit ( character ) ) { 00075 n = ( ( n * 10 ) + ( character - '0' ) ); 00076 continue; 00077 } 00078 if ( character >= 0x40 ) 00079 return KEY_ANSI ( n, character ); 00080 } 00081 00082 return ESC; 00083 }
1.5.7.1