2020-01-18 11:38:21 +03:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
|
|
|
*
|
2021-04-22 11:24:48 +03:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-01-18 11:38:21 +03:00
|
|
|
*/
|
|
|
|
|
2018-10-15 01:44:54 +03:00
|
|
|
#pragma once
|
|
|
|
|
2021-07-11 22:02:15 +03:00
|
|
|
#include <Kernel/Devices/CharacterDevice.h>
|
2018-10-15 01:44:54 +03:00
|
|
|
|
2020-02-16 03:27:42 +03:00
|
|
|
namespace Kernel {
|
|
|
|
|
2018-10-15 01:44:54 +03:00
|
|
|
class RandomDevice final : public CharacterDevice {
|
2018-11-01 01:19:15 +03:00
|
|
|
AK_MAKE_ETERNAL
|
2018-10-15 01:44:54 +03:00
|
|
|
public:
|
2021-06-18 11:37:26 +03:00
|
|
|
static NonnullRefPtr<RandomDevice> must_create();
|
2018-10-25 14:07:59 +03:00
|
|
|
virtual ~RandomDevice() override;
|
2018-10-15 01:44:54 +03:00
|
|
|
|
2020-12-25 20:01:19 +03:00
|
|
|
// ^Device
|
|
|
|
virtual mode_t required_mode() const override { return 0666; }
|
2021-01-21 20:49:56 +03:00
|
|
|
virtual String device_name() const override { return "random"; }
|
2020-12-25 20:01:19 +03:00
|
|
|
|
2019-01-21 04:33:01 +03:00
|
|
|
private:
|
2021-06-18 11:37:26 +03:00
|
|
|
RandomDevice();
|
|
|
|
|
2019-01-21 04:33:01 +03:00
|
|
|
// ^CharacterDevice
|
2021-03-17 15:18:51 +03:00
|
|
|
virtual KResultOr<size_t> read(FileDescription&, u64, UserOrKernelBuffer&, size_t) override;
|
|
|
|
virtual KResultOr<size_t> write(FileDescription&, u64, const UserOrKernelBuffer&, size_t) override;
|
2020-04-10 12:44:42 +03:00
|
|
|
virtual bool can_read(const FileDescription&, size_t) const override;
|
|
|
|
virtual bool can_write(const FileDescription&, size_t) const override { return true; }
|
2021-07-11 02:46:09 +03:00
|
|
|
virtual StringView class_name() const override { return "RandomDevice"; }
|
2018-10-15 01:44:54 +03:00
|
|
|
};
|
2020-02-16 03:27:42 +03:00
|
|
|
|
|
|
|
}
|