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
|
|
|
*/
|
|
|
|
|
2020-08-25 01:35:19 +00:00
|
|
|
#include <AK/Singleton.h>
|
2021-06-22 15:40:16 +00:00
|
|
|
#include <Kernel/Devices/NullDevice.h>
|
|
|
|
#include <Kernel/Sections.h>
|
2018-10-14 00:59:22 +00:00
|
|
|
|
2020-02-16 00:27:42 +00:00
|
|
|
namespace Kernel {
|
|
|
|
|
2021-08-07 19:34:11 +00:00
|
|
|
static Singleton<NullDevice> s_the;
|
2020-08-25 01:35:19 +00:00
|
|
|
|
2021-02-19 23:00:19 +00:00
|
|
|
UNMAP_AFTER_INIT void NullDevice::initialize()
|
2020-08-25 01:35:19 +00:00
|
|
|
{
|
|
|
|
s_the.ensure_instance();
|
|
|
|
}
|
2019-02-12 10:25:25 +00:00
|
|
|
|
|
|
|
NullDevice& NullDevice::the()
|
|
|
|
{
|
|
|
|
return *s_the;
|
|
|
|
}
|
|
|
|
|
2021-02-19 17:41:50 +00:00
|
|
|
UNMAP_AFTER_INIT NullDevice::NullDevice()
|
2018-10-30 12:59:29 +00:00
|
|
|
: CharacterDevice(1, 3)
|
2018-10-14 00:59:22 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2021-02-19 17:41:50 +00:00
|
|
|
UNMAP_AFTER_INIT NullDevice::~NullDevice()
|
2018-10-14 00:59:22 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2020-04-10 09:44:42 +00:00
|
|
|
bool NullDevice::can_read(const FileDescription&, size_t) const
|
2018-10-25 11:07:59 +00:00
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2021-03-17 12:18:51 +00:00
|
|
|
KResultOr<size_t> NullDevice::read(FileDescription&, u64, UserOrKernelBuffer&, size_t)
|
2018-10-14 00:59:22 +00:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2021-03-17 12:18:51 +00:00
|
|
|
KResultOr<size_t> NullDevice::write(FileDescription&, u64, const UserOrKernelBuffer&, size_t buffer_size)
|
2018-10-14 00:59:22 +00:00
|
|
|
{
|
2021-05-27 07:13:49 +00:00
|
|
|
return buffer_size;
|
2018-10-14 00:59:22 +00:00
|
|
|
}
|
2020-02-16 00:27:42 +00:00
|
|
|
|
|
|
|
}
|