Forráskód Böngészése

Kernel: Clarify IDEChannel function that switches current channel

Rename wait_until_not_busy() => select_device_and_wait_until_not_busy()
to make it more obvious what this thing is doing.
Andreas Kling 3 éve
szülő
commit
8177e7eb22

+ 5 - 4
Kernel/Storage/ATA/IDEChannel.cpp

@@ -62,12 +62,12 @@ UNMAP_AFTER_INIT void IDEChannel::initialize()
     IO::delay(30000);
     IO::delay(30000);
     m_io_group.control_base().out<u8>(device_control);
     m_io_group.control_base().out<u8>(device_control);
     // Wait up to 30 seconds before failing
     // Wait up to 30 seconds before failing
-    if (!wait_until_not_busy(false, 30000)) {
+    if (!select_device_and_wait_until_not_busy(DeviceType::Master, 30000)) {
         dbgln("IDEChannel: reset failed, busy flag on master stuck");
         dbgln("IDEChannel: reset failed, busy flag on master stuck");
         return;
         return;
     }
     }
     // Wait up to 30 seconds before failing
     // Wait up to 30 seconds before failing
-    if (!wait_until_not_busy(true, 30000)) {
+    if (!select_device_and_wait_until_not_busy(DeviceType::Slave, 30000)) {
         dbgln("IDEChannel: reset failed, busy flag on slave stuck");
         dbgln("IDEChannel: reset failed, busy flag on slave stuck");
         return;
         return;
     }
     }
@@ -261,10 +261,11 @@ static void io_delay()
         IO::in8(0x3f6);
         IO::in8(0x3f6);
 }
 }
 
 
-bool IDEChannel::wait_until_not_busy(bool slave, size_t milliseconds_timeout)
+bool IDEChannel::select_device_and_wait_until_not_busy(DeviceType device_type, size_t milliseconds_timeout)
 {
 {
     IO::delay(20);
     IO::delay(20);
-    m_io_group.io_base().offset(ATA_REG_HDDEVSEL).out<u8>(0xA0 | (slave << 4)); // First, we need to select the drive itself
+    u8 slave = device_type == DeviceType::Slave;
+    m_io_group.io_base().offset(ATA_REG_HDDEVSEL).out<u8>(0xA0 | (slave << 4));
     IO::delay(20);
     IO::delay(20);
     size_t time_elapsed = 0;
     size_t time_elapsed = 0;
     while (m_io_group.control_base().in<u8>() & ATA_SR_BSY && time_elapsed <= milliseconds_timeout) {
     while (m_io_group.control_base().in<u8>() & ATA_SR_BSY && time_elapsed <= milliseconds_timeout) {

+ 6 - 1
Kernel/Storage/ATA/IDEChannel.h

@@ -44,6 +44,11 @@ public:
         Secondary
         Secondary
     };
     };
 
 
+    enum class DeviceType : u8 {
+        Master,
+        Slave,
+    };
+
     struct IOAddressGroup {
     struct IOAddressGroup {
         IOAddressGroup(IOAddress io_base, IOAddress control_base, IOAddress bus_master_base)
         IOAddressGroup(IOAddress io_base, IOAddress control_base, IOAddress bus_master_base)
             : m_io_base(io_base)
             : m_io_base(io_base)
@@ -127,7 +132,7 @@ protected:
     StringView channel_type_string() const;
     StringView channel_type_string() const;
 
 
     void try_disambiguate_error();
     void try_disambiguate_error();
-    bool wait_until_not_busy(bool slave, size_t milliseconds_timeout);
+    bool select_device_and_wait_until_not_busy(DeviceType, size_t milliseconds_timeout);
     bool wait_until_not_busy(size_t milliseconds_timeout);
     bool wait_until_not_busy(size_t milliseconds_timeout);
 
 
     void start_request(AsyncBlockDeviceRequest&, bool, u16);
     void start_request(AsyncBlockDeviceRequest&, bool, u16);