mirror of
https://github.com/SerenityOS/serenity.git
synced 2025-01-24 02:12:09 -05:00
54 lines
1.3 KiB
C++
54 lines
1.3 KiB
C++
/*
|
|
* Copyright (c) 2022, Liav A. <liavalb@hotmail.co.il>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#include <AK/Singleton.h>
|
|
#include <AK/StringView.h>
|
|
#include <Kernel/FileSystem/SysFS/Registry.h>
|
|
#include <Kernel/Sections.h>
|
|
|
|
namespace Kernel {
|
|
|
|
static Singleton<SysFSComponentRegistry> s_the;
|
|
|
|
SysFSComponentRegistry& SysFSComponentRegistry::the()
|
|
{
|
|
return *s_the;
|
|
}
|
|
|
|
UNMAP_AFTER_INIT void SysFSComponentRegistry::initialize()
|
|
{
|
|
VERIFY(!s_the.is_initialized());
|
|
s_the.ensure_instance();
|
|
}
|
|
|
|
UNMAP_AFTER_INIT SysFSComponentRegistry::SysFSComponentRegistry()
|
|
: m_root_directory(SysFSRootDirectory::create())
|
|
{
|
|
}
|
|
|
|
UNMAP_AFTER_INIT void SysFSComponentRegistry::register_new_component(SysFSComponent& component)
|
|
{
|
|
MutexLocker locker(m_lock);
|
|
m_root_directory->m_components.append(component);
|
|
}
|
|
|
|
SysFSComponentRegistry::DevicesList& SysFSComponentRegistry::devices_list()
|
|
{
|
|
return m_devices_list;
|
|
}
|
|
|
|
SysFSBusDirectory& SysFSComponentRegistry::buses_directory()
|
|
{
|
|
return *m_root_directory->m_buses_directory;
|
|
}
|
|
|
|
void SysFSComponentRegistry::register_new_bus_directory(SysFSDirectory& new_bus_directory)
|
|
{
|
|
VERIFY(!m_root_directory->m_buses_directory.is_null());
|
|
m_root_directory->m_buses_directory->m_components.append(new_bus_directory);
|
|
}
|
|
|
|
}
|