From 5648d53cdbccdf9fd2f4eb0290f75e3ba23c0de8 Mon Sep 17 00:00:00 2001 From: cinap_lenrek Date: Sun, 15 May 2011 12:16:01 +0000 Subject: 9boot: use 500 ms timeout --- sys/src/boot/pc/fns.h | 1 + sys/src/boot/pc/l.s | 11 +++++++++++ sys/src/boot/pc/sub.c | 20 +++++++++++++++++--- 3 files changed, 29 insertions(+), 3 deletions(-) (limited to 'sys/src') diff --git a/sys/src/boot/pc/fns.h b/sys/src/boot/pc/fns.h index 11176f07f..8a36ce04b 100644 --- a/sys/src/boot/pc/fns.h +++ b/sys/src/boot/pc/fns.h @@ -9,6 +9,7 @@ void start(void *sp); int getc(void); int gotc(void); void putc(int c); +void usleep(int t); void halt(void); void jump(void *pc); diff --git a/sys/src/boot/pc/l.s b/sys/src/boot/pc/l.s index e8fa45954..8e47c4bf9 100644 --- a/sys/src/boot/pc/l.s +++ b/sys/src/boot/pc/l.s @@ -171,6 +171,17 @@ _pret32: ANDL $0xFFFF, AX RET +TEXT usleep(SB), $0 + MOVL t+4(SP), AX + PUSHL AX + CALL rmode16(SB) + CALL16(spllo(SB)) + POPR(rDX) + POPR(rCX) + MOVB $0x86, AH + BIOSCALL(0x15) + JMP _pret32 + #ifdef PXE TEXT pxeinit(SB), $0 diff --git a/sys/src/boot/pc/sub.c b/sys/src/boot/pc/sub.c index 981d3f61a..428bc8cf5 100644 --- a/sys/src/boot/pc/sub.c +++ b/sys/src/boot/pc/sub.c @@ -129,6 +129,18 @@ readline(void *f, char buf[64]) return p - buf; } +static int +timeout(int ms) +{ + while(ms > 0){ + if(gotc()) + return 1; + usleep(100000); + ms -= 100; + } + return 0; +} + #define BOOTLINE ((char*)CONFADDR) #define BOOTLINELEN 64 #define BOOTARGS ((char*)(CONFADDR+BOOTLINELEN)) @@ -176,17 +188,19 @@ Loop: print(line); print(crnl); } *confend = 0; + if(f){ close(f); f = 0; + + if(kern && timeout(500)) + goto Loop; } + if(!kern){ print("no bootfile\r\n"); goto Loop; } - for(n=0; n<10000; n++) - if(gotc()) - goto Loop; if(p = strrchr(kern, '!')) kern = p+1; -- cgit v1.2.3