mirror of
https://github.com/RGBCube/serenity
synced 2025-07-10 09:27:35 +00:00

Storage controllers are initialized during init and are never modified. NonnullRefPtr can be safely used instead of the NonnullLockRefPtr. This also fixes one of the UB issue that was there when using an NVMe device because of NonnullLockRefPtr. We can add proper locking when we need to modify the storage controllers after init.
36 lines
933 B
C++
36 lines
933 B
C++
/*
|
|
* Copyright (c) 2021, the SerenityOS developers.
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <AK/OwnPtr.h>
|
|
#include <AK/Types.h>
|
|
#include <Kernel/Library/LockRefPtr.h>
|
|
#include <Kernel/Storage/Ramdisk/Device.h>
|
|
#include <Kernel/Storage/StorageController.h>
|
|
#include <Kernel/Storage/StorageDevice.h>
|
|
|
|
namespace Kernel {
|
|
|
|
class AsyncBlockDeviceRequest;
|
|
|
|
class RamdiskController final : public StorageController {
|
|
public:
|
|
static NonnullRefPtr<RamdiskController> initialize();
|
|
virtual ~RamdiskController() override;
|
|
|
|
virtual LockRefPtr<StorageDevice> device(u32 index) const override;
|
|
virtual bool reset() override;
|
|
virtual bool shutdown() override;
|
|
virtual size_t devices_count() const override;
|
|
virtual void complete_current_request(AsyncDeviceRequest::RequestResult) override;
|
|
|
|
private:
|
|
RamdiskController();
|
|
|
|
Vector<NonnullLockRefPtr<RamdiskDevice>> m_devices;
|
|
};
|
|
}
|