summaryrefslogtreecommitdiff
path: root/payloads/libpayload/libc
diff options
context:
space:
mode:
authorJordan Crouse <jordan.crouse@amd.com>2008-04-08 23:21:33 +0000
committerUwe Hermann <uwe@hermann-uwe.de>2008-04-08 23:21:33 +0000
commit672d0ae15655aa8c28e2ac0e698e501628347b7c (patch)
treed8777af35f8dc2300aa953b0e463aa667a0a8394 /payloads/libpayload/libc
parent4eb5089821b014d84fac2ef432da0f7bbaba754e (diff)
downloadcoreboot-672d0ae15655aa8c28e2ac0e698e501628347b7c.tar.xz
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
Diffstat (limited to 'payloads/libpayload/libc')
-rw-r--r--payloads/libpayload/libc/console.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/payloads/libpayload/libc/console.c b/payloads/libpayload/libc/console.c
index b2b115b835..73e2644cd4 100644
--- a/payloads/libpayload/libc/console.c
+++ b/payloads/libpayload/libc/console.c
@@ -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;
+}