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.
This commit is contained in:
Tom 2022-01-02 16:21:12 -07:00 committed by Linus Groh
parent 84c6d6649e
commit e70aa690d2

View file

@ -163,11 +163,10 @@ Memory::MappedROM map_bios()
Memory::MappedROM map_ebda()
{
auto ebda_segment_ptr = Memory::map_typed<u16>(PhysicalAddress(0x40e));
auto ebda_length_ptr_b0 = Memory::map_typed<u8>(PhysicalAddress(0x413));
auto ebda_length_ptr_b1 = Memory::map_typed<u8>(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<u8>(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();