X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=src%2Fboot%2Fboot2.s;h=719f37e99549e7dbc249344f83170e4dc4a631f8;hb=77450ffb9190c6aa2a04bc23792a143b5886e459;hp=59096acd2b5ce7db337e718d5607b451dc730b9b;hpb=f03c64c0d3c22faa867aaad9243b679f5d1d7819;p=bootcensus diff --git a/src/boot/boot2.s b/src/boot/boot2.s index 59096ac..719f37e 100644 --- a/src/boot/boot2.s +++ b/src/boot/boot2.s @@ -15,6 +15,8 @@ # along with this program. If not, see . # this is the second-stage boot loader +# plus some other code that needs to run below 1mb (int86 implementation). + .code16 .section .boot2,"ax" @@ -613,16 +615,20 @@ e820_looptop: cmp $0x534d4150, %eax jnz e820_fail + # skip areas starting above 4GB as we won't be able to use them + cmpl $0, 4(%edi) + jnz e820_skip + + # only care for type 1 (usable ram), otherwise ignore + cmpl $1, 16(%edi) + jnz e820_skip + mov buffer, %eax mov $boot_mem_map, %esi mov boot_mem_map_size, %ebp # again, that's [ebp * 8 + esi] mov %eax, (%esi,%ebp,8) - # only care for type 1 (usable ram), otherwise ignore - cmpl $1, 16(%edi) - jnz e820_skip - # skip areas with 0 size (also clamp size to 4gb) # test high 32bits cmpl $0, 12(%edi) @@ -683,15 +689,21 @@ detect_mem_e801: movzx %cx, %eax # first size is in KB, convert to bytes shl $10, %eax - mov %eax, 4(%esi) - cmp $0, %dx + jnc 0f + # overflow means it's >4GB, clamp to 4GB + mov $0xffffffff, %eax +0: mov %eax, 4(%esi) incl boot_mem_map_size + cmp $0, %dx jz e801_done movl $0x1000000, 8(%esi) movzx %dx, %eax # second size is in 64kb blocks, convert to bytes shl $16, %eax - mov %eax, 12(%esi) + jnc 0f + # overflow means it's >4GB, clamp to 4GB + mov $0xffffffff, %eax +0: mov %eax, 12(%esi) incl boot_mem_map_size e801_done: clc