[console] Avoid timer wraparound problems in getchar_timeout()
Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
parent
9e98e4b9b8
commit
2969a8567f
|
@ -39,9 +39,9 @@ FILE_LICENCE ( GPL2_OR_LATER );
|
||||||
* @ret character Character read from console
|
* @ret character Character read from console
|
||||||
*/
|
*/
|
||||||
int getchar_timeout ( unsigned long timeout ) {
|
int getchar_timeout ( unsigned long timeout ) {
|
||||||
unsigned long expiry = ( currticks() + timeout );
|
unsigned long start = currticks();
|
||||||
|
|
||||||
while ( currticks() < expiry ) {
|
while ( ( currticks() - start ) < timeout ) {
|
||||||
step();
|
step();
|
||||||
if ( iskey() )
|
if ( iskey() )
|
||||||
return getchar();
|
return getchar();
|
||||||
|
|
Reference in New Issue