From 4744ccbff0a165b05c2c4b6978cb1aa78aca80f7 Mon Sep 17 00:00:00 2001 From: Liav A Date: Fri, 22 Apr 2022 18:52:20 +0300 Subject: Kernel/Storage: Add LUN address to each StorageDevice LUN address is essentially how people used to address SCSI devices back in the day we had these devices more in use. However, SCSI was taken as an abstraction layer for many Unix and Unix-like systems, so it still common to see LUN addresses in use. In Serenity, we don't really provide such abstraction layer, and therefore until now, we didn't use LUNs too. However (again), this changes, as we want to let users to address their devices under SysFS easily. LUNs make sense in that regard, because they can be easily adapted to different interfaces besides SCSI. For example, for legacy ATA hard drive being connected to the first IDE controller which was enumerated on the PCI bus, and then to the primary channel as slave device, the LUN address would be 0:0:1. To make this happen, we add unique ID number to each StorageController, which increments by 1 for each new instance of StorageController. Then, we adapt the ATA and NVMe devices to use these numbers and generate LUN in the construction time. --- Kernel/Storage/StorageDevice.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'Kernel/Storage/StorageDevice.cpp') diff --git a/Kernel/Storage/StorageDevice.cpp b/Kernel/Storage/StorageDevice.cpp index 6c8cc784cb..8ca455ea81 100644 --- a/Kernel/Storage/StorageDevice.cpp +++ b/Kernel/Storage/StorageDevice.cpp @@ -14,9 +14,10 @@ namespace Kernel { -StorageDevice::StorageDevice(MajorNumber major, MinorNumber minor, size_t sector_size, u64 max_addressable_block, NonnullOwnPtr device_name) +StorageDevice::StorageDevice(LUNAddress logical_unit_number_address, MajorNumber major, MinorNumber minor, size_t sector_size, u64 max_addressable_block, NonnullOwnPtr device_name) : BlockDevice(major, minor, sector_size) , m_early_storage_device_name(move(device_name)) + , m_logical_unit_number_address(logical_unit_number_address) , m_max_addressable_block(max_addressable_block) , m_blocks_per_page(PAGE_SIZE / block_size()) { -- cgit v1.2.3