From c3eaa73113b423df3acc2578023fc1b3b8f8c53c Mon Sep 17 00:00:00 2001 From: Liav A Date: Fri, 5 Aug 2022 13:36:10 +0300 Subject: Kernel/Storage: Remove InterfaceType enum This enum was created to help put distinction between the commandset and the interface type, as ATAPI devices are simply ATA devices utilizing the SCSI commandset. Because we don't support ATAPI, putting such type of distinction is pointless, so let's remove this for now. --- .../Subsystems/Devices/Storage/DeviceAttribute.cpp | 5 ----- .../Subsystems/Devices/Storage/DeviceAttribute.h | 1 - .../Subsystems/Devices/Storage/DeviceDirectory.cpp | 1 - Kernel/Storage/ATA/ATADiskDevice.h | 1 - Kernel/Storage/NVMe/NVMeNameSpace.h | 1 - Kernel/Storage/Ramdisk/Device.h | 1 - Kernel/Storage/StorageDevice.cpp | 17 ----------------- Kernel/Storage/StorageDevice.h | 19 +++++-------------- 8 files changed, 5 insertions(+), 41 deletions(-) diff --git a/Kernel/FileSystem/SysFS/Subsystems/Devices/Storage/DeviceAttribute.cpp b/Kernel/FileSystem/SysFS/Subsystems/Devices/Storage/DeviceAttribute.cpp index c76ea273f6..d21ba3ba95 100644 --- a/Kernel/FileSystem/SysFS/Subsystems/Devices/Storage/DeviceAttribute.cpp +++ b/Kernel/FileSystem/SysFS/Subsystems/Devices/Storage/DeviceAttribute.cpp @@ -21,8 +21,6 @@ StringView StorageDeviceAttributeSysFSComponent::name() const return "sector_size"sv; case Type::CommandSet: return "command_set"sv; - case Type::InterfaceType: - return "interface_type"sv; default: VERIFY_NOT_REACHED(); } @@ -65,9 +63,6 @@ ErrorOr> StorageDeviceAttributeSysFSComponent::try_to_gen case Type::CommandSet: value = TRY(KString::formatted("{}", m_device->command_set_to_string_view())); break; - case Type::InterfaceType: - value = TRY(KString::formatted("{}", m_device->interface_type_to_string_view())); - break; default: VERIFY_NOT_REACHED(); } diff --git a/Kernel/FileSystem/SysFS/Subsystems/Devices/Storage/DeviceAttribute.h b/Kernel/FileSystem/SysFS/Subsystems/Devices/Storage/DeviceAttribute.h index f9c769e224..9682fb0172 100644 --- a/Kernel/FileSystem/SysFS/Subsystems/Devices/Storage/DeviceAttribute.h +++ b/Kernel/FileSystem/SysFS/Subsystems/Devices/Storage/DeviceAttribute.h @@ -18,7 +18,6 @@ public: EndLBA, SectorSize, CommandSet, - InterfaceType, }; public: diff --git a/Kernel/FileSystem/SysFS/Subsystems/Devices/Storage/DeviceDirectory.cpp b/Kernel/FileSystem/SysFS/Subsystems/Devices/Storage/DeviceDirectory.cpp index 87e0efa6ef..1e0bf34f74 100644 --- a/Kernel/FileSystem/SysFS/Subsystems/Devices/Storage/DeviceDirectory.cpp +++ b/Kernel/FileSystem/SysFS/Subsystems/Devices/Storage/DeviceDirectory.cpp @@ -29,7 +29,6 @@ UNMAP_AFTER_INIT NonnullRefPtr StorageDeviceSysFSDi list.append(StorageDeviceAttributeSysFSComponent::must_create(*directory, StorageDeviceAttributeSysFSComponent::Type::EndLBA)); list.append(StorageDeviceAttributeSysFSComponent::must_create(*directory, StorageDeviceAttributeSysFSComponent::Type::SectorSize)); list.append(StorageDeviceAttributeSysFSComponent::must_create(*directory, StorageDeviceAttributeSysFSComponent::Type::CommandSet)); - list.append(StorageDeviceAttributeSysFSComponent::must_create(*directory, StorageDeviceAttributeSysFSComponent::Type::InterfaceType)); return {}; })); return directory; diff --git a/Kernel/Storage/ATA/ATADiskDevice.h b/Kernel/Storage/ATA/ATADiskDevice.h index 53fd22199b..595ebe2e8a 100644 --- a/Kernel/Storage/ATA/ATADiskDevice.h +++ b/Kernel/Storage/ATA/ATADiskDevice.h @@ -25,7 +25,6 @@ public: virtual CommandSet command_set() const override { return CommandSet::ATA; } private: - virtual InterfaceType interface_type() const override { return InterfaceType::ATA; } ATADiskDevice(ATAController const&, Address, MinorNumber, u16, u16, u64, NonnullOwnPtr); // ^DiskDevice diff --git a/Kernel/Storage/NVMe/NVMeNameSpace.h b/Kernel/Storage/NVMe/NVMeNameSpace.h index 6a1a1b10aa..e96c6f9805 100644 --- a/Kernel/Storage/NVMe/NVMeNameSpace.h +++ b/Kernel/Storage/NVMe/NVMeNameSpace.h @@ -33,7 +33,6 @@ public: private: NVMeNameSpace(LUNAddress, NonnullRefPtrVector queues, size_t storage_size, size_t lba_size, size_t major_number, size_t minor_number, u16 nsid, NonnullOwnPtr early_device_name); - virtual InterfaceType interface_type() const override { return InterfaceType::NVMe; } u16 m_nsid; NonnullRefPtrVector m_queues; }; diff --git a/Kernel/Storage/Ramdisk/Device.h b/Kernel/Storage/Ramdisk/Device.h index dc398281a8..0e4ef6cca9 100644 --- a/Kernel/Storage/Ramdisk/Device.h +++ b/Kernel/Storage/Ramdisk/Device.h @@ -32,7 +32,6 @@ private: // ^StorageDevice virtual CommandSet command_set() const override { return CommandSet::PlainMemory; } - virtual InterfaceType interface_type() const override { return InterfaceType::PlainMemory; } Mutex m_lock { "RamdiskDevice"sv }; diff --git a/Kernel/Storage/StorageDevice.cpp b/Kernel/Storage/StorageDevice.cpp index 40bc8484aa..5407a939f6 100644 --- a/Kernel/Storage/StorageDevice.cpp +++ b/Kernel/Storage/StorageDevice.cpp @@ -71,23 +71,6 @@ StringView StorageDevice::command_set_to_string_view() const VERIFY_NOT_REACHED(); } -StringView StorageDevice::interface_type_to_string_view() const -{ - switch (interface_type()) { - case InterfaceType::PlainMemory: - return "memory"sv; - case InterfaceType::SCSI: - return "scsi"sv; - case InterfaceType::ATA: - return "ata"sv; - case InterfaceType::NVMe: - return "nvme"sv; - default: - break; - } - VERIFY_NOT_REACHED(); -} - ErrorOr StorageDevice::read(OpenFileDescription&, u64 offset, UserOrKernelBuffer& outbuf, size_t len) { u64 index = offset >> block_size_log(); diff --git a/Kernel/Storage/StorageDevice.h b/Kernel/Storage/StorageDevice.h index a8f0b583d0..8a070612f2 100644 --- a/Kernel/Storage/StorageDevice.h +++ b/Kernel/Storage/StorageDevice.h @@ -27,6 +27,11 @@ public: // The IDE controller code being aware of the possibility of ATAPI devices attached // to the ATA bus, will check whether the Command set is ATA or SCSI and will act // accordingly. + // Note: For now, there's simply no distinction between the interface type and the commandset. + // As mentioned above, ATAPI devices use the ATA interface with actual SCSI packets so + // the commandset is SCSI while the interface type is ATA. We simply don't support SCSI over ATA (ATAPI) + // and ATAPI is the exception to no-distinction rule. If we ever put SCSI support in the kernel, + // we can create another enum class to put the distinction. enum class CommandSet { PlainMemory, SCSI, @@ -34,18 +39,6 @@ public: NVMe, }; - // Note: this attribute describes the interface type of a Storage device. - // For example, an ordinary harddrive utilizes the ATA command set, while - // an ATAPI device (e.g. Optical drive) that is connected to the ATA bus, - // is actually using SCSI commands (packets) encapsulated inside an ATA command. - // Therefore, an ATAPI device is still using the ATA interface. - enum class InterfaceType { - PlainMemory, - SCSI, - ATA, - NVMe, - }; - // Note: The most reliable way to address this device from userspace interfaces, // such as SysFS, is to have one way to enumerate everything in the eyes of userspace. // Therefore, SCSI LUN (logical unit number) addressing seem to be the most generic way to do this. @@ -81,7 +74,6 @@ public: virtual CommandSet command_set() const = 0; - StringView interface_type_to_string_view() const; StringView command_set_to_string_view() const; // ^File @@ -96,7 +88,6 @@ private: virtual void after_inserting() override; virtual void will_be_destroyed() override; - virtual InterfaceType interface_type() const = 0; mutable IntrusiveListNode> m_list_node; NonnullRefPtrVector m_partitions; -- cgit v1.2.3