summaryrefslogtreecommitdiff
path: root/sys/src/boot
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@centraldogma>2011-11-10 04:41:32 +0100
committercinap_lenrek <cinap_lenrek@centraldogma>2011-11-10 04:41:32 +0100
commitd8f42424ae0b69be7cdc0ddb04c1509219de51ec (patch)
treeb08fe1b8f4233b46b044c473a88c6037f11ffd91 /sys/src/boot
parentf72373eaff6528535eef0f896158a3c7517a1158 (diff)
9boot: fix e820 scan
Diffstat (limited to 'sys/src/boot')
-rw-r--r--sys/src/boot/pc/e820.s14
-rw-r--r--sys/src/boot/pc/sub.c28
2 files changed, 30 insertions, 12 deletions
diff --git a/sys/src/boot/pc/e820.s b/sys/src/boot/pc/e820.s
index c830a64e6..71db6c53d 100644
--- a/sys/src/boot/pc/e820.s
+++ b/sys/src/boot/pc/e820.s
@@ -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
diff --git a/sys/src/boot/pc/sub.c b/sys/src/boot/pc/sub.c
index 8140508dc..fafe69ac0 100644
--- a/sys/src/boot/pc/sub.c
+++ b/sys/src/boot/pc/sub.c
@@ -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);