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