libpayload: Add a timeout function for getchar and getch

Implement a timeout option for getchar() to return after so many
milliseconds.  Also implement the same thing for curses using
the halfdelay() function.

Signed-off-by: Jordan Crouse <jordan.crouse@amd.com>
Acked-by: Uwe Hermann <uwe@hermann-uwe.de>



git-svn-id: svn://svn.coreboot.org/coreboot/trunk@3223 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
This commit is contained in:
Jordan Crouse
2008-04-08 23:21:33 +00:00
committed by Uwe Hermann
parent 4eb5089821
commit 672d0ae156
4 changed files with 48 additions and 4 deletions

View File

@ -101,3 +101,19 @@ int getchar(void)
#endif
}
}
int getchar_timeout(int *ms)
{
while (*ms > 0) {
if (havekey())
return getchar();
mdelay(100);
*ms -= 100;
}
if (*ms < 0)
*ms = 0;
return 0;
}