summaryrefslogtreecommitdiff
path: root/Kernel/Storage/StorageDevice.cpp
diff options
context:
space:
mode:
authorLiav A <liavalb@gmail.com>2022-04-22 18:52:20 +0300
committerAndreas Kling <kling@serenityos.org>2022-07-15 12:29:23 +0200
commit4744ccbff0a165b05c2c4b6978cb1aa78aca80f7 (patch)
tree991558947b8e90a7804c853e6f2bb3b57f9a7954 /Kernel/Storage/StorageDevice.cpp
parentb49af59b4a3920b912ed6d06b2c8ba8c10492854 (diff)
downloadserenity-4744ccbff0a165b05c2c4b6978cb1aa78aca80f7.zip
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.
Diffstat (limited to 'Kernel/Storage/StorageDevice.cpp')
-rw-r--r--Kernel/Storage/StorageDevice.cpp3
1 files changed, 2 insertions, 1 deletions
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<KString> device_name)
+StorageDevice::StorageDevice(LUNAddress logical_unit_number_address, MajorNumber major, MinorNumber minor, size_t sector_size, u64 max_addressable_block, NonnullOwnPtr<KString> 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())
{