From 3742ae23a16b1f7abe052bf22275b2c97daad71a Mon Sep 17 00:00:00 2001 From: apio Date: Sat, 13 May 2023 18:12:34 +0200 Subject: [PATCH] kernel/ATA: Read the Busmaster base port and verify it --- kernel/src/arch/x86_64/disk/ATA.cpp | 8 ++++++++ kernel/src/arch/x86_64/disk/ATA.h | 1 + 2 files changed, 9 insertions(+) diff --git a/kernel/src/arch/x86_64/disk/ATA.cpp b/kernel/src/arch/x86_64/disk/ATA.cpp index 1fb852cf..dec6f2a5 100644 --- a/kernel/src/arch/x86_64/disk/ATA.cpp +++ b/kernel/src/arch/x86_64/disk/ATA.cpp @@ -187,6 +187,14 @@ namespace ATA m_io_base = io_base_address; m_control_base = control_port_base_address + 2; + auto io_busmaster = m_controller->device().getBAR(4); + if (!io_busmaster.is_iospace()) + { + kwarnln("ata: Channel %d's busmaster base BAR is not in IO space", m_channel_index); + return false; + } + m_busmaster_base = io_busmaster.port() + (u16)(m_channel_index * 8u); + if (m_is_pci_native_mode) m_interrupt_line = PCI::read8(m_controller->device().address, PCI::InterruptLine); else m_interrupt_line = m_channel_index ? 15 : 14; diff --git a/kernel/src/arch/x86_64/disk/ATA.h b/kernel/src/arch/x86_64/disk/ATA.h index c7f9a720..45770de4 100644 --- a/kernel/src/arch/x86_64/disk/ATA.h +++ b/kernel/src/arch/x86_64/disk/ATA.h @@ -120,6 +120,7 @@ namespace ATA u16 m_io_base; u16 m_control_base; + u16 m_busmaster_base; u8 m_current_drive = (u8)-1;