mirror of
https://github.com/SerenityOS/serenity
synced 2026-05-12 18:06:56 +02:00
We used to allocate major numbers quite randomly, with no common place to look them up if needed. This commit is changing that by placing all major number allocations under a new C++ namespace, in the API/MajorNumberAllocation.h file. We also add the foundations of what is needed before we can publish this information (allocated numbers for block and char devices) to userspace.
33 lines
1014 B
C++
33 lines
1014 B
C++
/*
|
|
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <Kernel/API/MajorNumberAllocation.h>
|
|
#include <Kernel/Devices/Device.h>
|
|
|
|
namespace Kernel {
|
|
|
|
class CharacterDevice : public Device {
|
|
public:
|
|
virtual ~CharacterDevice() override;
|
|
|
|
protected:
|
|
CharacterDevice(MajorAllocation::CharacterDeviceFamily character_device_family, MinorNumber minor);
|
|
|
|
virtual void after_inserting_add_symlink_to_device_identifier_directory() override final;
|
|
virtual void before_will_be_destroyed_remove_symlink_from_device_identifier_directory() override final;
|
|
|
|
private:
|
|
virtual bool is_character_device() const final { return true; }
|
|
|
|
// FIXME: These methods will be eventually removed after all nodes in /sys/dev/char/ are symlinks
|
|
virtual void after_inserting_add_to_device_identifier_directory() override final;
|
|
virtual void before_will_be_destroyed_remove_from_device_identifier_directory() override final;
|
|
};
|
|
|
|
}
|