summaryrefslogtreecommitdiff
path: root/Kernel/Storage
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2023-03-06 17:56:28 +0100
committerAndreas Kling <kling@serenityos.org>2023-03-06 23:46:36 +0100
commit7369d0ab5f93b3b083e030bef64486b02cafb3d5 (patch)
tree2b82fc7c6825248d15d0a36c09d2518fe6f8d2cc /Kernel/Storage
parent21db2b7b903d8c35151174fb18f947db5227eab7 (diff)
downloadserenity-7369d0ab5f93b3b083e030bef64486b02cafb3d5.zip
Kernel: Stop using NonnullLockRefPtrVector
Diffstat (limited to 'Kernel/Storage')
-rw-r--r--Kernel/Storage/ATA/AHCI/Controller.cpp2
-rw-r--r--Kernel/Storage/ATA/ATAPort.h2
-rw-r--r--Kernel/Storage/ATA/GenericIDE/Controller.cpp14
-rw-r--r--Kernel/Storage/ATA/GenericIDE/Controller.h2
-rw-r--r--Kernel/Storage/NVMe/NVMeController.h5
-rw-r--r--Kernel/Storage/NVMe/NVMeNameSpace.cpp8
-rw-r--r--Kernel/Storage/NVMe/NVMeNameSpace.h7
-rw-r--r--Kernel/Storage/NVMe/NVMeQueue.h1
-rw-r--r--Kernel/Storage/Ramdisk/Controller.h2
-rw-r--r--Kernel/Storage/StorageDevice.h4
-rw-r--r--Kernel/Storage/StorageManagement.cpp10
-rw-r--r--Kernel/Storage/StorageManagement.h3
12 files changed, 28 insertions, 32 deletions
diff --git a/Kernel/Storage/ATA/AHCI/Controller.cpp b/Kernel/Storage/ATA/AHCI/Controller.cpp
index 13f8ef066c..23105ba65d 100644
--- a/Kernel/Storage/ATA/AHCI/Controller.cpp
+++ b/Kernel/Storage/ATA/AHCI/Controller.cpp
@@ -205,7 +205,7 @@ LockRefPtr<StorageDevice> AHCIController::device_by_port(u32 port_index) const
LockRefPtr<StorageDevice> AHCIController::device(u32 index) const
{
- NonnullLockRefPtrVector<StorageDevice> connected_devices;
+ Vector<NonnullLockRefPtr<StorageDevice>> connected_devices;
u32 pi = hba().control_regs.pi;
u32 bit = bit_scan_forward(pi);
while (bit) {
diff --git a/Kernel/Storage/ATA/ATAPort.h b/Kernel/Storage/ATA/ATAPort.h
index bb876cad7f..ef6942d1af 100644
--- a/Kernel/Storage/ATA/ATAPort.h
+++ b/Kernel/Storage/ATA/ATAPort.h
@@ -149,7 +149,7 @@ protected:
RefPtr<Memory::PhysicalPage> m_dma_buffer_page;
const u8 m_port_index;
- NonnullLockRefPtrVector<ATADevice> m_ata_devices;
+ Vector<NonnullLockRefPtr<ATADevice>> m_ata_devices;
NonnullOwnPtr<KBuffer> m_ata_identify_data_buffer;
NonnullLockRefPtr<ATAController> m_parent_ata_controller;
};
diff --git a/Kernel/Storage/ATA/GenericIDE/Controller.cpp b/Kernel/Storage/ATA/GenericIDE/Controller.cpp
index 1f1aea0e8e..b4458d8bb6 100644
--- a/Kernel/Storage/ATA/GenericIDE/Controller.cpp
+++ b/Kernel/Storage/ATA/GenericIDE/Controller.cpp
@@ -46,13 +46,13 @@ void IDEController::start_request(ATADevice const& device, AsyncBlockDeviceReque
VERIFY(address.subport < 2);
switch (address.port) {
case 0: {
- auto result = m_channels[0].start_request(device, request);
+ auto result = m_channels[0]->start_request(device, request);
// FIXME: Propagate errors properly
VERIFY(!result.is_error());
return;
}
case 1: {
- auto result = m_channels[1].start_request(device, request);
+ auto result = m_channels[1]->start_request(device, request);
// FIXME: Propagate errors properly
VERIFY(!result.is_error());
return;
@@ -73,20 +73,20 @@ LockRefPtr<StorageDevice> IDEController::device_by_channel_and_position(u32 inde
{
switch (index) {
case 0:
- return m_channels[0].connected_device(0);
+ return m_channels[0]->connected_device(0);
case 1:
- return m_channels[0].connected_device(1);
+ return m_channels[0]->connected_device(1);
case 2:
- return m_channels[1].connected_device(0);
+ return m_channels[1]->connected_device(0);
case 3:
- return m_channels[1].connected_device(1);
+ return m_channels[1]->connected_device(1);
}
VERIFY_NOT_REACHED();
}
LockRefPtr<StorageDevice> IDEController::device(u32 index) const
{
- NonnullLockRefPtrVector<StorageDevice> connected_devices;
+ Vector<NonnullLockRefPtr<StorageDevice>> connected_devices;
for (size_t index = 0; index < 4; index++) {
auto checked_device = device_by_channel_and_position(index);
if (checked_device.is_null())
diff --git a/Kernel/Storage/ATA/GenericIDE/Controller.h b/Kernel/Storage/ATA/GenericIDE/Controller.h
index 406bcad5d4..75f8907018 100644
--- a/Kernel/Storage/ATA/GenericIDE/Controller.h
+++ b/Kernel/Storage/ATA/GenericIDE/Controller.h
@@ -32,6 +32,6 @@ protected:
IDEController();
LockRefPtr<StorageDevice> device_by_channel_and_position(u32 index) const;
- NonnullLockRefPtrVector<IDEChannel> m_channels;
+ Vector<NonnullLockRefPtr<IDEChannel>> m_channels;
};
}
diff --git a/Kernel/Storage/NVMe/NVMeController.h b/Kernel/Storage/NVMe/NVMeController.h
index 8c51bf438d..e07d447acf 100644
--- a/Kernel/Storage/NVMe/NVMeController.h
+++ b/Kernel/Storage/NVMe/NVMeController.h
@@ -13,7 +13,6 @@
#include <Kernel/Bus/PCI/Device.h>
#include <Kernel/Library/LockRefPtr.h>
#include <Kernel/Library/NonnullLockRefPtr.h>
-#include <Kernel/Library/NonnullLockRefPtrVector.h>
#include <Kernel/Locking/Spinlock.h>
#include <Kernel/Memory/TypedMapping.h>
#include <Kernel/Storage/NVMe/NVMeDefinitions.h>
@@ -70,8 +69,8 @@ private:
private:
LockRefPtr<NVMeQueue> m_admin_queue;
- NonnullLockRefPtrVector<NVMeQueue> m_queues;
- NonnullLockRefPtrVector<NVMeNameSpace> m_namespaces;
+ Vector<NonnullLockRefPtr<NVMeQueue>> m_queues;
+ Vector<NonnullLockRefPtr<NVMeNameSpace>> m_namespaces;
Memory::TypedMapping<ControllerRegister volatile> m_controller_regs;
bool m_admin_queue_ready { false };
size_t m_device_count { 0 };
diff --git a/Kernel/Storage/NVMe/NVMeNameSpace.cpp b/Kernel/Storage/NVMe/NVMeNameSpace.cpp
index f126f8c10f..48e5d2551a 100644
--- a/Kernel/Storage/NVMe/NVMeNameSpace.cpp
+++ b/Kernel/Storage/NVMe/NVMeNameSpace.cpp
@@ -12,13 +12,13 @@
namespace Kernel {
-UNMAP_AFTER_INIT ErrorOr<NonnullLockRefPtr<NVMeNameSpace>> NVMeNameSpace::try_create(NVMeController const& controller, NonnullLockRefPtrVector<NVMeQueue> queues, u16 nsid, size_t storage_size, size_t lba_size)
+UNMAP_AFTER_INIT ErrorOr<NonnullLockRefPtr<NVMeNameSpace>> NVMeNameSpace::try_create(NVMeController const& controller, Vector<NonnullLockRefPtr<NVMeQueue>> queues, u16 nsid, size_t storage_size, size_t lba_size)
{
auto device = TRY(DeviceManagement::try_create_device<NVMeNameSpace>(StorageDevice::LUNAddress { controller.controller_id(), nsid, 0 }, controller.hardware_relative_controller_id(), move(queues), storage_size, lba_size, nsid));
return device;
}
-UNMAP_AFTER_INIT NVMeNameSpace::NVMeNameSpace(LUNAddress logical_unit_number_address, u32 hardware_relative_controller_id, NonnullLockRefPtrVector<NVMeQueue> queues, size_t max_addresable_block, size_t lba_size, u16 nsid)
+UNMAP_AFTER_INIT NVMeNameSpace::NVMeNameSpace(LUNAddress logical_unit_number_address, u32 hardware_relative_controller_id, Vector<NonnullLockRefPtr<NVMeQueue>> queues, size_t max_addresable_block, size_t lba_size, u16 nsid)
: StorageDevice(logical_unit_number_address, hardware_relative_controller_id, lba_size, max_addresable_block)
, m_nsid(nsid)
, m_queues(move(queues))
@@ -34,9 +34,9 @@ void NVMeNameSpace::start_request(AsyncBlockDeviceRequest& request)
VERIFY(request.block_count() <= (PAGE_SIZE / block_size()));
if (request.request_type() == AsyncBlockDeviceRequest::Read) {
- queue.read(request, m_nsid, request.block_index(), request.block_count());
+ queue->read(request, m_nsid, request.block_index(), request.block_count());
} else {
- queue.write(request, m_nsid, request.block_index(), request.block_count());
+ queue->write(request, m_nsid, request.block_index(), request.block_count());
}
}
}
diff --git a/Kernel/Storage/NVMe/NVMeNameSpace.h b/Kernel/Storage/NVMe/NVMeNameSpace.h
index f7c5a1225f..92081b7338 100644
--- a/Kernel/Storage/NVMe/NVMeNameSpace.h
+++ b/Kernel/Storage/NVMe/NVMeNameSpace.h
@@ -11,7 +11,6 @@
#include <AK/kmalloc.h>
#include <Kernel/Library/LockRefPtr.h>
#include <Kernel/Library/NonnullLockRefPtr.h>
-#include <Kernel/Library/NonnullLockRefPtrVector.h>
#include <Kernel/Locking/Spinlock.h>
#include <Kernel/Storage/NVMe/NVMeDefinitions.h>
#include <Kernel/Storage/NVMe/NVMeQueue.h>
@@ -24,16 +23,16 @@ class NVMeNameSpace : public StorageDevice {
friend class DeviceManagement;
public:
- static ErrorOr<NonnullLockRefPtr<NVMeNameSpace>> try_create(NVMeController const&, NonnullLockRefPtrVector<NVMeQueue> queues, u16 nsid, size_t storage_size, size_t lba_size);
+ static ErrorOr<NonnullLockRefPtr<NVMeNameSpace>> try_create(NVMeController const&, Vector<NonnullLockRefPtr<NVMeQueue>> queues, u16 nsid, size_t storage_size, size_t lba_size);
CommandSet command_set() const override { return CommandSet::NVMe; };
void start_request(AsyncBlockDeviceRequest& request) override;
private:
- NVMeNameSpace(LUNAddress, u32 hardware_relative_controller_id, NonnullLockRefPtrVector<NVMeQueue> queues, size_t storage_size, size_t lba_size, u16 nsid);
+ NVMeNameSpace(LUNAddress, u32 hardware_relative_controller_id, Vector<NonnullLockRefPtr<NVMeQueue>> queues, size_t storage_size, size_t lba_size, u16 nsid);
u16 m_nsid;
- NonnullLockRefPtrVector<NVMeQueue> m_queues;
+ Vector<NonnullLockRefPtr<NVMeQueue>> m_queues;
};
}
diff --git a/Kernel/Storage/NVMe/NVMeQueue.h b/Kernel/Storage/NVMe/NVMeQueue.h
index be0b864f4e..46f386c726 100644
--- a/Kernel/Storage/NVMe/NVMeQueue.h
+++ b/Kernel/Storage/NVMe/NVMeQueue.h
@@ -13,7 +13,6 @@
#include <Kernel/Interrupts/IRQHandler.h>
#include <Kernel/Library/LockRefPtr.h>
#include <Kernel/Library/NonnullLockRefPtr.h>
-#include <Kernel/Library/NonnullLockRefPtrVector.h>
#include <Kernel/Locking/Spinlock.h>
#include <Kernel/Memory/MemoryManager.h>
#include <Kernel/Memory/TypedMapping.h>
diff --git a/Kernel/Storage/Ramdisk/Controller.h b/Kernel/Storage/Ramdisk/Controller.h
index 56c31a0c03..64661663b2 100644
--- a/Kernel/Storage/Ramdisk/Controller.h
+++ b/Kernel/Storage/Ramdisk/Controller.h
@@ -31,6 +31,6 @@ public:
private:
RamdiskController();
- NonnullLockRefPtrVector<RamdiskDevice> m_devices;
+ Vector<NonnullLockRefPtr<RamdiskDevice>> m_devices;
};
}
diff --git a/Kernel/Storage/StorageDevice.h b/Kernel/Storage/StorageDevice.h
index 7497e9637f..b66a94f062 100644
--- a/Kernel/Storage/StorageDevice.h
+++ b/Kernel/Storage/StorageDevice.h
@@ -63,7 +63,7 @@ public:
virtual bool can_write(OpenFileDescription const&, u64) const override;
virtual void prepare_for_unplug() { m_partitions.clear(); }
- NonnullLockRefPtrVector<DiskPartition> const& partitions() const { return m_partitions; }
+ Vector<NonnullLockRefPtr<DiskPartition>> const& partitions() const { return m_partitions; }
void add_partition(NonnullLockRefPtr<DiskPartition> disk_partition) { MUST(m_partitions.try_append(disk_partition)); }
@@ -93,7 +93,7 @@ private:
virtual void will_be_destroyed() override;
mutable IntrusiveListNode<StorageDevice, LockRefPtr<StorageDevice>> m_list_node;
- NonnullLockRefPtrVector<DiskPartition> m_partitions;
+ Vector<NonnullLockRefPtr<DiskPartition>> m_partitions;
LUNAddress const m_logical_unit_number_address;
diff --git a/Kernel/Storage/StorageManagement.cpp b/Kernel/Storage/StorageManagement.cpp
index 62ec69ed62..7fa774d8d2 100644
--- a/Kernel/Storage/StorageManagement.cpp
+++ b/Kernel/Storage/StorageManagement.cpp
@@ -129,8 +129,8 @@ UNMAP_AFTER_INIT void StorageManagement::enumerate_storage_devices()
{
VERIFY(!m_controllers.is_empty());
for (auto& controller : m_controllers) {
- for (size_t device_index = 0; device_index < controller.devices_count(); device_index++) {
- auto device = controller.device(device_index);
+ for (size_t device_index = 0; device_index < controller->devices_count(); device_index++) {
+ auto device = controller->device(device_index);
if (device.is_null())
continue;
m_storage_devices.append(device.release_nonnull());
@@ -149,7 +149,7 @@ UNMAP_AFTER_INIT void StorageManagement::dump_storage_devices_and_partitions() c
dbgln(" Device: block{}:{} ({} partitions)", storage_device.major(), storage_device.minor(), partitions.size());
unsigned partition_number = 1;
for (auto const& partition : partitions) {
- dbgln(" Partition: {}, block{}:{} (UUID {})", partition_number, partition.major(), partition.minor(), partition.metadata().unique_guid().to_string());
+ dbgln(" Partition: {}, block{}:{} (UUID {})", partition_number, partition->major(), partition->minor(), partition->metadata().unique_guid().to_string());
partition_number++;
}
}
@@ -375,9 +375,9 @@ UNMAP_AFTER_INIT void StorageManagement::determine_boot_device_with_partition_uu
for (auto& storage_device : m_storage_devices) {
for (auto& partition : storage_device.partitions()) {
- if (partition.metadata().unique_guid().is_zero())
+ if (partition->metadata().unique_guid().is_zero())
continue;
- if (partition.metadata().unique_guid() == partition_uuid) {
+ if (partition->metadata().unique_guid() == partition_uuid) {
m_boot_block_device = partition;
break;
}
diff --git a/Kernel/Storage/StorageManagement.h b/Kernel/Storage/StorageManagement.h
index f8512ba13f..bdc30935ed 100644
--- a/Kernel/Storage/StorageManagement.h
+++ b/Kernel/Storage/StorageManagement.h
@@ -10,7 +10,6 @@
#include <AK/Types.h>
#include <Kernel/FileSystem/FileSystem.h>
#include <Kernel/Library/NonnullLockRefPtr.h>
-#include <Kernel/Library/NonnullLockRefPtrVector.h>
#include <Kernel/Storage/DiskPartition.h>
#include <Kernel/Storage/StorageController.h>
#include <Kernel/Storage/StorageDevice.h>
@@ -67,7 +66,7 @@ private:
StringView m_boot_argument;
LockWeakPtr<BlockDevice> m_boot_block_device;
- NonnullLockRefPtrVector<StorageController> m_controllers;
+ Vector<NonnullLockRefPtr<StorageController>> m_controllers;
IntrusiveList<&StorageDevice::m_list_node> m_storage_devices;
};