mirror of
https://github.com/SerenityOS/serenity.git
synced 2025-01-24 02:12:09 -05:00
Kernel: Simplify force_pio logic in PATA driver (#923)
This commit is contained in:
parent
95034fdfbd
commit
0b3a868729
3 changed files with 17 additions and 14 deletions
|
@ -118,19 +118,23 @@ void PATAChannel::initialize(bool force_pio)
|
|||
kprintf("PATAChannel: PATA Controller found! id=%w:%w\n", id.vendor_id, id.device_id);
|
||||
}
|
||||
});
|
||||
m_force_pio.resource() = false;
|
||||
if (!m_pci_address.is_null()) {
|
||||
// Let's try to set up DMA transfers.
|
||||
PCI::enable_bus_mastering(m_pci_address);
|
||||
m_prdt.end_of_table = 0x8000;
|
||||
m_bus_master_base = PCI::get_BAR4(m_pci_address) & 0xfffc;
|
||||
m_dma_buffer_page = MM.allocate_supervisor_physical_page();
|
||||
kprintf("PATAChannel: Bus master IDE: I/O @ %x\n", m_bus_master_base);
|
||||
if (force_pio) {
|
||||
m_force_pio.resource() = true;
|
||||
kprintf("PATAChannel: Requested to force PIO mode!\n");
|
||||
}
|
||||
|
||||
if (m_pci_address.is_null()) {
|
||||
kprintf("PATAChannel: PCI address was null; can not set up DMA\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (force_pio) {
|
||||
kprintf("PATAChannel: Requested to force PIO mode; not setting up DMA\n");
|
||||
return;
|
||||
}
|
||||
|
||||
// Let's try to set up DMA transfers.
|
||||
PCI::enable_bus_mastering(m_pci_address);
|
||||
m_prdt.end_of_table = 0x8000;
|
||||
m_bus_master_base = PCI::get_BAR4(m_pci_address) & 0xfffc;
|
||||
m_dma_buffer_page = MM.allocate_supervisor_physical_page();
|
||||
kprintf("PATAChannel: Bus master IDE: I/O @ %x\n", m_bus_master_base);
|
||||
}
|
||||
|
||||
static void print_ide_status(u8 status)
|
||||
|
|
|
@ -69,7 +69,6 @@ private:
|
|||
RefPtr<PhysicalPage> m_dma_buffer_page;
|
||||
u16 m_bus_master_base { 0 };
|
||||
Lockable<bool> m_dma_enabled;
|
||||
Lockable<bool> m_force_pio;
|
||||
|
||||
RefPtr<PATADiskDevice> m_master;
|
||||
RefPtr<PATADiskDevice> m_slave;
|
||||
|
|
|
@ -24,7 +24,7 @@ const char* PATADiskDevice::class_name() const
|
|||
|
||||
bool PATADiskDevice::read_blocks(unsigned index, u16 count, u8* out)
|
||||
{
|
||||
if (m_channel.m_bus_master_base && m_channel.m_dma_enabled.resource() && !m_channel.m_force_pio.resource())
|
||||
if (m_channel.m_bus_master_base && m_channel.m_dma_enabled.resource())
|
||||
return read_sectors_with_dma(index, count, out);
|
||||
return read_sectors(index, count, out);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue