/**
* Read character from console if available within timeout period
*
- * @v timeout Timeout period, in ticks
+ * @v timeout Timeout period, in ticks (0=indefinite)
* @ret character Character read from console
*/
-int getchar_timeout ( unsigned long timeout ) {
+static int getchar_timeout ( unsigned long timeout ) {
unsigned long start = currticks();
- while ( ( currticks() - start ) < timeout ) {
+ while ( ( timeout == 0 ) || ( ( currticks() - start ) < timeout ) ) {
step();
if ( iskey() )
return getchar();
/**
* Get single keypress
*
+ * @v timeout Timeout period, in ticks (0=indefinite)
* @ret key Key pressed
*
* The returned key will be an ASCII value or a KEY_XXX special
* will return "special" keys (e.g. cursor keys) as a series of
* characters forming an ANSI escape sequence.
*/
-int getkey ( void ) {
+int getkey ( unsigned long timeout ) {
int character;
unsigned int n = 0;
- character = getchar();
+ character = getchar_timeout ( timeout );
if ( character != ESC )
return character;
buf[0] = '\0';
while ( 1 ) {
- key = edit_string ( &string, getkey() );
+ key = edit_string ( &string, getkey ( 0 ) );
sync_console ( &string );
switch ( key ) {
case CR:
printf ( "\nPress Ctrl-B for the iPXE command line..." );
/* Wait for key */
- key = getchar_timeout ( ( BANNER_TIMEOUT * TICKS_PER_SEC ) / 10 );
+ key = getkey ( ( BANNER_TIMEOUT * TICKS_PER_SEC ) / 10 );
/* Clear the "Press Ctrl-B" line */
printf ( "\r \r" );
draw_editbox ( current_box );
- key = getkey();
+ key = getkey ( 0 );
switch ( key ) {
case KEY_DOWN:
current_box = &password_box;
draw_setting ( &widget );
color_set ( CPAIR_NORMAL, NULL );
- key = getkey();
+ key = getkey ( 0 );
if ( widget.editing ) {
key = edit_setting ( &widget, key );
switch ( key ) {
extern void putchar ( int character );
extern int getchar ( void );
-extern int getchar_timeout ( unsigned long timeout );
extern int iskey ( void );
-extern int getkey ( void );
+extern int getkey ( unsigned long timeout );
#endif /* CONSOLE_H */
#include <ipxe/dhcp.h>
#include <ipxe/keys.h>
#include <ipxe/timer.h>
-#include <ipxe/process.h>
#include <ipxe/uri.h>
#include <usr/dhcpmgmt.h>
#include <usr/autoboot.h>
pxe_menu_draw_item ( menu, menu->selection, 1 );
/* Wait for keyboard input */
- while ( ! iskey() )
- step();
- key = getkey();
+ key = getkey ( 0 );
/* Unhighlight currently selected item */
pxe_menu_draw_item ( menu, menu->selection, 0 );
if ( ! len )
len = printf ( " (%d)", menu->timeout );
if ( iskey() ) {
- key = getkey();
+ key = getkey ( 0 );
if ( key == KEY_F8 ) {
/* Display menu */
printf ( "\n" );