summaryrefslogtreecommitdiff
path: root/Kernel/Storage/NVMe/NVMeNameSpace.h
blob: 92081b7338a97a17576b9df8f6323f75b0394715 (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, Pankaj R <pankydev8@gmail.com>
 *
 * SPDX-License-Identifier: BSD-2-Clause
 */

#pragma once

#include <AK/OwnPtr.h>
#include <AK/Types.h>
#include <AK/kmalloc.h>
#include <Kernel/Library/LockRefPtr.h>
#include <Kernel/Library/NonnullLockRefPtr.h>
#include <Kernel/Locking/Spinlock.h>
#include <Kernel/Storage/NVMe/NVMeDefinitions.h>
#include <Kernel/Storage/NVMe/NVMeQueue.h>
#include <Kernel/Storage/StorageDevice.h>

namespace Kernel {

class NVMeController;
class NVMeNameSpace : public StorageDevice {
    friend class DeviceManagement;

public:
    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, Vector<NonnullLockRefPtr<NVMeQueue>> queues, size_t storage_size, size_t lba_size, u16 nsid);

    u16 m_nsid;
    Vector<NonnullLockRefPtr<NVMeQueue>> m_queues;
};

}