Kernel/SysFS: Don't allocate ACPISysFS components in constructors

Instead defer it to a method to be called after the construction of
ACPISysFSDirectory.
This commit is contained in:
Liav A 2021-12-12 16:58:06 +02:00 committed by Andreas Kling
parent 381fdaa163
commit bbdb55126c
Notes: sideshowbarker 2024-07-17 22:47:37 +09:00
2 changed files with 14 additions and 8 deletions

View File

@ -67,14 +67,7 @@ UNMAP_AFTER_INIT ACPISysFSComponent::ACPISysFSComponent(NonnullOwnPtr<KString> t
{
}
UNMAP_AFTER_INIT NonnullRefPtr<ACPISysFSDirectory> ACPISysFSDirectory::must_create(FirmwareSysFSDirectory& firmware_directory)
{
auto acpi_directory = MUST(adopt_nonnull_ref_or_enomem(new (nothrow) ACPISysFSDirectory(firmware_directory)));
return acpi_directory;
}
UNMAP_AFTER_INIT ACPISysFSDirectory::ACPISysFSDirectory(FirmwareSysFSDirectory& firmware_directory)
: SysFSDirectory(firmware_directory)
UNMAP_AFTER_INIT void ACPISysFSDirectory::find_tables_and_register_them_as_components()
{
NonnullRefPtrVector<SysFSComponent> components;
size_t ssdt_count = 0;
@ -99,6 +92,18 @@ UNMAP_AFTER_INIT ACPISysFSDirectory::ACPISysFSDirectory(FirmwareSysFSDirectory&
}
}
UNMAP_AFTER_INIT NonnullRefPtr<ACPISysFSDirectory> ACPISysFSDirectory::must_create(FirmwareSysFSDirectory& firmware_directory)
{
auto acpi_directory = MUST(adopt_nonnull_ref_or_enomem(new (nothrow) ACPISysFSDirectory(firmware_directory)));
acpi_directory->find_tables_and_register_them_as_components();
return acpi_directory;
}
UNMAP_AFTER_INIT ACPISysFSDirectory::ACPISysFSDirectory(FirmwareSysFSDirectory& firmware_directory)
: SysFSDirectory(firmware_directory)
{
}
void Parser::enumerate_static_tables(Function<void(StringView, PhysicalAddress, size_t)> callback)
{
for (auto& p_table : m_sdt_pointers) {

View File

@ -26,6 +26,7 @@ public:
static NonnullRefPtr<ACPISysFSDirectory> must_create(FirmwareSysFSDirectory& firmware_directory);
private:
void find_tables_and_register_them_as_components();
explicit ACPISysFSDirectory(FirmwareSysFSDirectory& firmware_directory);
};