2020-01-18 08:38:21 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
|
|
|
*
|
2021-04-22 08:24:48 +00:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-01-18 08:38:21 +00:00
|
|
|
*/
|
|
|
|
|
2018-10-14 22:44:54 +00:00
|
|
|
#pragma once
|
|
|
|
|
2021-07-11 19:02:15 +00:00
|
|
|
#include <Kernel/Devices/CharacterDevice.h>
|
2018-10-14 22:44:54 +00:00
|
|
|
|
2020-02-16 00:27:42 +00:00
|
|
|
namespace Kernel {
|
|
|
|
|
2018-10-14 22:44:54 +00:00
|
|
|
class RandomDevice final : public CharacterDevice {
|
2021-09-11 06:19:20 +00:00
|
|
|
friend class DeviceManagement;
|
|
|
|
|
2018-10-14 22:44:54 +00:00
|
|
|
public:
|
2022-08-19 18:53:40 +00:00
|
|
|
static NonnullLockRefPtr<RandomDevice> must_create();
|
2018-10-25 11:07:59 +00:00
|
|
|
virtual ~RandomDevice() override;
|
2018-10-14 22:44:54 +00:00
|
|
|
|
2021-09-11 06:19:20 +00:00
|
|
|
private:
|
2021-06-18 08:37:26 +00:00
|
|
|
RandomDevice();
|
|
|
|
|
2019-01-21 01:33:01 +00:00
|
|
|
// ^CharacterDevice
|
2021-11-07 23:51:39 +00:00
|
|
|
virtual ErrorOr<size_t> read(OpenFileDescription&, u64, UserOrKernelBuffer&, size_t) override;
|
2022-04-01 17:58:27 +00:00
|
|
|
virtual ErrorOr<size_t> write(OpenFileDescription&, u64, UserOrKernelBuffer const&, size_t) override;
|
|
|
|
virtual bool can_read(OpenFileDescription const&, u64) const override;
|
|
|
|
virtual bool can_write(OpenFileDescription const&, u64) const override { return true; }
|
2021-10-02 22:24:00 +00:00
|
|
|
virtual StringView class_name() const override { return "RandomDevice"sv; }
|
2018-10-14 22:44:54 +00:00
|
|
|
};
|
2020-02-16 00:27:42 +00:00
|
|
|
|
|
|
|
}
|