summaryrefslogtreecommitdiff
path: root/Kernel/Bus/VirtIO/RNG.h
blob: ea4e8c775d07da38abb1c3f95b8fe7bd555092fb (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
/*
 * Copyright (c) 2021, the SerenityOS developers.
 *
 * SPDX-License-Identifier: BSD-2-Clause
 */

#pragma once

#include <AK/RefCounted.h>
#include <Kernel/Bus/VirtIO/Device.h>
#include <Kernel/Devices/CharacterDevice.h>
#include <Kernel/Random.h>

namespace Kernel::VirtIO {

#define REQUESTQ 0

class RNG final
    : public RefCounted<RNG>
    , public VirtIO::Device {
public:
    virtual StringView purpose() const override { return class_name(); }

    RNG(PCI::Address);
    virtual ~RNG() override;

private:
    virtual StringView class_name() const override { return "VirtIOConsole"; }
    virtual bool handle_device_config_change() override;
    virtual void handle_queue_update(u16 queue_index) override;
    void request_entropy_from_host();

    OwnPtr<Memory::Region> m_entropy_buffer;
    EntropySource m_entropy_source;
};

}