From e70aa690d2a073c3beb9043c17bb646241f57a60 Mon Sep 17 00:00:00 2001 From: Tom Date: Sun, 2 Jan 2022 16:21:12 -0700 Subject: [PATCH] Kernel: Fix determining EBDA size The first byte of the EBDA structure contains the size of the EBDA in 1 KiB units. We were incorrectly using the word at offset 0x413 of the BDA which specifies the number of KiB before the EBDA structure. --- Kernel/Firmware/BIOS.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/Kernel/Firmware/BIOS.cpp b/Kernel/Firmware/BIOS.cpp index 61f40edf22..3cb28bfe64 100644 --- a/Kernel/Firmware/BIOS.cpp +++ b/Kernel/Firmware/BIOS.cpp @@ -163,11 +163,10 @@ Memory::MappedROM map_bios() Memory::MappedROM map_ebda() { auto ebda_segment_ptr = Memory::map_typed(PhysicalAddress(0x40e)); - auto ebda_length_ptr_b0 = Memory::map_typed(PhysicalAddress(0x413)); - auto ebda_length_ptr_b1 = Memory::map_typed(PhysicalAddress(0x414)); - - PhysicalAddress ebda_paddr(*ebda_segment_ptr << 4); - size_t ebda_size = (*ebda_length_ptr_b1 << 8) | *ebda_length_ptr_b0; + PhysicalAddress ebda_paddr(PhysicalAddress(*ebda_segment_ptr).get() << 4); + // The EBDA size is stored in the first byte of the EBDA in 1K units + size_t ebda_size = *Memory::map_typed(ebda_paddr); + ebda_size *= 1024; Memory::MappedROM mapping; mapping.region = MM.allocate_kernel_region(ebda_paddr.page_base(), Memory::page_round_up(ebda_size).release_value_but_fixme_should_propagate_errors(), {}, Memory::Region::Access::Read).release_value();