Kernel: Fix bug which made bochs unbootable

We could not boot if ATABus did not have valid primary device.
This commit is contained in:
Bananymous 2023-07-13 15:53:09 +03:00
parent 6c1ada8d0a
commit 650e1b4fc5
1 changed files with 5 additions and 2 deletions

View File

@ -247,8 +247,11 @@ namespace Kernel
uint8_t ATABus::device_index(const ATADevice& device) const
{
ASSERT(&device == m_devices[0].ptr() || &device == m_devices[1].ptr());
return (&device == m_devices[0].ptr()) ? 0 : 1;
if (m_devices[0] && m_devices[0].ptr() == &device)
return 0;
if (m_devices[1] && m_devices[1].ptr() == &device)
return 1;
ASSERT_NOT_REACHED();
}
BAN::ErrorOr<void> ATABus::read(ATADevice& device, uint64_t lba, uint8_t sector_count, uint8_t* buffer)