9boot: fix e820 scan

This commit is contained in:
cinap_lenrek 2011-11-10 04:41:32 +01:00
parent f72373eaff
commit d8f42424ae
2 changed files with 30 additions and 12 deletions

View file

@ -4,17 +4,27 @@
TEXT e820(SB), $0
MOVL bx+4(SP), BX
MOVL p+8(SP), DI
MOVL $0xe820, AX
MOVL $0xE820, AX
MOVL $0x534D4150, DX
CALL rmode16(SB)
LWI(24, rCX)
BIOSCALL(0x15)
JC _bad
CALL16(pmode32(SB))
CMPB CL, $24
JZ _ret
MOVL $1, AX
MOVL AX, 20(DI)
_ret:
MOVL BX, AX
RET
_bad:
CALL16(pmode32(SB))
XORL AX, AX
MOVL AX, 0(DI)
MOVL AX, 4(DI)
MOVL AX, 8(DI)
MOVL AX, 12(DI)
MOVL AX, 16(DI)
MOVL AX, 20(DI)
RET

View file

@ -340,27 +340,35 @@ e820conf(void)
ulong bx;
char *s;
memset(&e, 0, sizeof(e));
if((bx = e820(0, &e)) == 0)
return;
bx=0;
s = confend;
memmove(confend, "e820=", 5);
confend += 5;
do{
if(e.typ == 1 && (e.ext & 1) == 0 && e.len){
e.base = 0;
e.len = 0;
e.typ = 0;
e.ext = 1;
bx = e820(bx, &e);
if(e.typ == 1 && e.len != 0 && (e.ext & 3) == 1){
if(confend == s){
/* single entry <= 1MB is useless */
if(bx == 0 && e.len <= 0x100000)
break;
memmove(confend, "e820=", 5);
confend += 5;
}
v = e.base;
addconfx("", 8, v>>32);
addconfx("", 8, v&0xffffffff);
v = e.base + e.len;
v += e.len;
addconfx(" ", 8, v>>32);
addconfx("", 8, v&0xffffffff);
*confend++ = ' ';
}
} while(bx);
memset(&e, 0, sizeof(e));
} while(bx = e820(bx, &e));
if(confend == s)
return;
*confend = 0;
print(s); print(crnl);