9boot: use 500 ms timeout

This commit is contained in:
cinap_lenrek 2011-05-15 12:16:01 +00:00
parent a67e921c7f
commit 5648d53cdb
3 changed files with 29 additions and 3 deletions

View file

@ -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);

View file

@ -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

View file

@ -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;