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.
This commit is contained in:
Liav A 2022-08-05 13:36:10 +03:00 committed by Linus Groh
parent c85f81bc9d
commit c3eaa73113
Notes: sideshowbarker 2024-07-17 23:02:37 +09:00
8 changed files with 5 additions and 41 deletions

View File

@ -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<NonnullOwnPtr<KBuffer>> 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();
}

View File

@ -18,7 +18,6 @@ public:
EndLBA,
SectorSize,
CommandSet,
InterfaceType,
};
public:

View File

@ -29,7 +29,6 @@ UNMAP_AFTER_INIT NonnullRefPtr<StorageDeviceSysFSDirectory> 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;

View File

@ -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<KString>);
// ^DiskDevice

View File

@ -33,7 +33,6 @@ public:
private:
NVMeNameSpace(LUNAddress, NonnullRefPtrVector<NVMeQueue> queues, size_t storage_size, size_t lba_size, size_t major_number, size_t minor_number, u16 nsid, NonnullOwnPtr<KString> early_device_name);
virtual InterfaceType interface_type() const override { return InterfaceType::NVMe; }
u16 m_nsid;
NonnullRefPtrVector<NVMeQueue> m_queues;
};

View File

@ -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 };

View File

@ -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<size_t> StorageDevice::read(OpenFileDescription&, u64 offset, UserOrKernelBuffer& outbuf, size_t len)
{
u64 index = offset >> block_size_log();

View File

@ -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<StorageDevice, RefPtr<StorageDevice>> m_list_node;
NonnullRefPtrVector<DiskPartition> m_partitions;