mirror of
https://github.com/RGBCube/serenity
synced 2025-05-23 18:25:08 +00:00
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:
parent
b49af59b4a
commit
4744ccbff0
13 changed files with 76 additions and 15 deletions
|
@ -19,13 +19,13 @@
|
|||
#include <Kernel/Sections.h>
|
||||
|
||||
namespace Kernel {
|
||||
Atomic<u8> NVMeController::controller_id {};
|
||||
Atomic<u8> NVMeController::s_controller_id {};
|
||||
|
||||
UNMAP_AFTER_INIT ErrorOr<NonnullRefPtr<NVMeController>> NVMeController::try_initialize(Kernel::PCI::DeviceIdentifier const& device_identifier, bool is_queue_polled)
|
||||
{
|
||||
auto controller = TRY(adopt_nonnull_ref_or_enomem(new NVMeController(device_identifier)));
|
||||
TRY(controller->initialize(is_queue_polled));
|
||||
NVMeController::controller_id++;
|
||||
NVMeController::s_controller_id++;
|
||||
return controller;
|
||||
}
|
||||
|
||||
|
@ -207,7 +207,7 @@ UNMAP_AFTER_INIT ErrorOr<void> NVMeController::identify_and_init_namespaces()
|
|||
|
||||
dbgln_if(NVME_DEBUG, "NVMe: Block count is {} and Block size is {}", block_counts, block_size);
|
||||
|
||||
m_namespaces.append(TRY(NVMeNameSpace::try_create(m_queues, controller_id.load(), nsid, block_counts, block_size)));
|
||||
m_namespaces.append(TRY(NVMeNameSpace::try_create(*this, m_queues, s_controller_id.load(), nsid, block_counts, block_size)));
|
||||
m_device_count++;
|
||||
dbgln_if(NVME_DEBUG, "NVMe: Initialized namespace with NSID: {}", nsid);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue