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.
This commit is contained in:
Liav A 2022-04-22 18:52:20 +03:00 committed by Andreas Kling
parent b49af59b4a
commit 4744ccbff0
Notes: sideshowbarker 2024-07-17 08:56:21 +09:00
13 changed files with 76 additions and 15 deletions

View file

@ -0,0 +1,17 @@
/*
* Copyright (c) 2022, Liav A. <liavalb@hotmail.co.il>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <Kernel/Storage/StorageController.h>
#include <Kernel/Storage/StorageManagement.h>
namespace Kernel {
StorageController::StorageController()
: m_controller_id(StorageManagement::generate_controller_id())
{
}
}