summaryrefslogtreecommitdiff
path: root/Kernel/Storage/RamdiskDevice.h
blob: e4cd63f1dc4de5a9c60aa6e091255c1bef0f93f4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/*
 * Copyright (c) 2021, the SerenityOS developers.
 *
 * SPDX-License-Identifier: BSD-2-Clause
 */

#pragma once

#include <Kernel/Locking/Mutex.h>
#include <Kernel/Storage/StorageDevice.h>

namespace Kernel {

class RamdiskController;

class RamdiskDevice final : public StorageDevice {
    friend class RamdiskController;
    friend class DeviceManagement;
    AK_MAKE_ETERNAL
public:
    static NonnullRefPtr<RamdiskDevice> create(const RamdiskController&, NonnullOwnPtr<Memory::Region>&& region, int major, int minor);
    virtual ~RamdiskDevice() override;

    // ^DiskDevice
    virtual StringView class_name() const override;

private:
    RamdiskDevice(const RamdiskController&, NonnullOwnPtr<Memory::Region>&&, int major, int minor, NonnullOwnPtr<KString> device_name);

    // ^BlockDevice
    virtual void start_request(AsyncBlockDeviceRequest&) override;

    Mutex m_lock { "RamdiskDevice" };

    NonnullOwnPtr<Memory::Region> m_region;
};

}