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 00:59:22 +00:00
|
|
|
#pragma once
|
|
|
|
|
2021-07-11 19:02:15 +00:00
|
|
|
#include <Kernel/Devices/CharacterDevice.h>
|
2018-10-14 00:59:22 +00:00
|
|
|
|
2020-02-16 00:27:42 +00:00
|
|
|
namespace Kernel {
|
|
|
|
|
2018-10-14 00:59:22 +00:00
|
|
|
class ZeroDevice final : public CharacterDevice {
|
2021-09-11 06:19:20 +00:00
|
|
|
friend class DeviceManagement;
|
|
|
|
|
2018-10-14 00:59:22 +00:00
|
|
|
public:
|
2021-06-18 08:37:26 +00:00
|
|
|
static NonnullRefPtr<ZeroDevice> must_create();
|
2018-10-25 11:07:59 +00:00
|
|
|
virtual ~ZeroDevice() override;
|
2018-10-14 00:59:22 +00:00
|
|
|
|
2021-09-11 06:19:20 +00:00
|
|
|
private:
|
2021-06-18 08:37:26 +00:00
|
|
|
ZeroDevice();
|
2021-09-10 11:44:46 +00:00
|
|
|
|
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;
|
|
|
|
virtual ErrorOr<size_t> write(OpenFileDescription&, u64, const UserOrKernelBuffer&, size_t) override;
|
2022-01-25 18:17:49 +00:00
|
|
|
virtual bool can_read(const OpenFileDescription&, u64) const override;
|
2022-01-25 18:19:35 +00:00
|
|
|
virtual bool can_write(const OpenFileDescription&, u64) const override { return true; }
|
2021-10-02 22:24:00 +00:00
|
|
|
virtual StringView class_name() const override { return "ZeroDevice"sv; }
|
2018-10-14 00:59:22 +00:00
|
|
|
};
|
2020-02-16 00:27:42 +00:00
|
|
|
|
|
|
|
}
|