diff options
author | Andreas Kling <awesomekling@gmail.com> | 2019-05-19 15:54:33 +0200 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-05-19 15:54:33 +0200 |
commit | 5f26f83451ea046f76d1bb019510548714408de6 (patch) | |
tree | 8024ca2d605cbdaef033fe9f12305712919accb9 | |
parent | 29863d38150bc67d676bc8bd390e648207ac75ae (diff) | |
download | serenity-5f26f83451ea046f76d1bb019510548714408de6.zip |
IDEDiskDevice: Add sysctl variable for turning DMA on/off.
-rw-r--r-- | Kernel/Devices/IDEDiskDevice.cpp | 7 | ||||
-rw-r--r-- | Kernel/Devices/IDEDiskDevice.h | 1 |
2 files changed, 6 insertions, 2 deletions
diff --git a/Kernel/Devices/IDEDiskDevice.cpp b/Kernel/Devices/IDEDiskDevice.cpp index 10e928b9bf..67d42f6a55 100644 --- a/Kernel/Devices/IDEDiskDevice.cpp +++ b/Kernel/Devices/IDEDiskDevice.cpp @@ -7,6 +7,7 @@ #include "PIC.h" #include <Kernel/Lock.h> #include <Kernel/VM/MemoryManager.h> +#include <Kernel/FileSystem/ProcFS.h> //#define DISK_DEBUG @@ -110,6 +111,8 @@ Retained<IDEDiskDevice> IDEDiskDevice::create() IDEDiskDevice::IDEDiskDevice() : IRQHandler(IRQ_FIXED_DISK) { + m_dma_enabled.resource() = true; + ProcFS::the().add_sys_bool("ide_dma", m_dma_enabled); initialize(); } @@ -129,14 +132,14 @@ unsigned IDEDiskDevice::block_size() const bool IDEDiskDevice::read_blocks(unsigned index, word count, byte* out) { - if (m_bus_master_base) + if (m_bus_master_base && m_dma_enabled.resource()) return read_sectors_with_dma(index, count, out); return read_sectors(index, count, out); } bool IDEDiskDevice::read_block(unsigned index, byte* out) const { - if (m_bus_master_base) + if (m_bus_master_base && const_cast<IDEDiskDevice*>(this)->m_dma_enabled.resource()) return const_cast<IDEDiskDevice&>(*this).read_sectors_with_dma(index, 1, out); return const_cast<IDEDiskDevice&>(*this).read_sectors(index, 1, out); } diff --git a/Kernel/Devices/IDEDiskDevice.h b/Kernel/Devices/IDEDiskDevice.h index 4a8e497926..5bec3a9acc 100644 --- a/Kernel/Devices/IDEDiskDevice.h +++ b/Kernel/Devices/IDEDiskDevice.h @@ -53,5 +53,6 @@ private: PhysicalRegionDescriptor m_prdt; RetainPtr<PhysicalPage> m_dma_buffer_page; word m_bus_master_base { 0 }; + Lockable<bool> m_dma_enabled; }; |