mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 16:18:12 +00:00
Kernel/SysFS: Mark SysFSDirectory traverse and lookup methods as final
This enforces us to remove duplicated code across the SysFS code. This results in great simplification of how the SysFS works now, because we enforce one way to treat SysFSDirectory objects.
This commit is contained in:
parent
6733f19b3c
commit
70afa0b171
18 changed files with 114 additions and 178 deletions
|
@ -70,28 +70,31 @@ UNMAP_AFTER_INIT ACPISysFSComponent::ACPISysFSComponent(NonnullOwnPtr<KString> t
|
|||
|
||||
UNMAP_AFTER_INIT void ACPISysFSDirectory::find_tables_and_register_them_as_components()
|
||||
{
|
||||
NonnullRefPtrVector<SysFSComponent> components;
|
||||
size_t ssdt_count = 0;
|
||||
ACPI::Parser::the()->enumerate_static_tables([&](StringView signature, PhysicalAddress p_table, size_t length) {
|
||||
if (signature == "SSDT") {
|
||||
auto component_name = KString::formatted("{:4s}{}", signature.characters_without_null_termination(), ssdt_count).release_value_but_fixme_should_propagate_errors();
|
||||
components.append(ACPISysFSComponent::create(component_name->view(), p_table, length));
|
||||
ssdt_count++;
|
||||
return;
|
||||
MUST(m_child_components.with([&](auto& list) -> ErrorOr<void> {
|
||||
ACPI::Parser::the()->enumerate_static_tables([&](StringView signature, PhysicalAddress p_table, size_t length) {
|
||||
if (signature == "SSDT") {
|
||||
auto component_name = KString::formatted("{:4s}{}", signature.characters_without_null_termination(), ssdt_count).release_value_but_fixme_should_propagate_errors();
|
||||
list.append(ACPISysFSComponent::create(component_name->view(), p_table, length));
|
||||
ssdt_count++;
|
||||
return;
|
||||
}
|
||||
list.append(ACPISysFSComponent::create(signature, p_table, length));
|
||||
});
|
||||
return {};
|
||||
}));
|
||||
|
||||
MUST(m_child_components.with([&](auto& list) -> ErrorOr<void> {
|
||||
auto rsdp = Memory::map_typed<Structures::RSDPDescriptor20>(ACPI::Parser::the()->rsdp()).release_value_but_fixme_should_propagate_errors();
|
||||
list.append(ACPISysFSComponent::create("RSDP"sv, ACPI::Parser::the()->rsdp(), rsdp->base.revision == 0 ? sizeof(Structures::RSDPDescriptor) : rsdp->length));
|
||||
auto main_system_description_table = Memory::map_typed<Structures::SDTHeader>(ACPI::Parser::the()->main_system_description_table()).release_value_but_fixme_should_propagate_errors();
|
||||
if (ACPI::Parser::the()->is_xsdt_supported()) {
|
||||
list.append(ACPISysFSComponent::create("XSDT"sv, ACPI::Parser::the()->main_system_description_table(), main_system_description_table->length));
|
||||
} else {
|
||||
list.append(ACPISysFSComponent::create("RSDT"sv, ACPI::Parser::the()->main_system_description_table(), main_system_description_table->length));
|
||||
}
|
||||
components.append(ACPISysFSComponent::create(signature, p_table, length));
|
||||
});
|
||||
m_components = components;
|
||||
|
||||
auto rsdp = Memory::map_typed<Structures::RSDPDescriptor20>(ACPI::Parser::the()->rsdp()).release_value_but_fixme_should_propagate_errors();
|
||||
m_components.append(ACPISysFSComponent::create("RSDP"sv, ACPI::Parser::the()->rsdp(), rsdp->base.revision == 0 ? sizeof(Structures::RSDPDescriptor) : rsdp->length));
|
||||
|
||||
auto main_system_description_table = Memory::map_typed<Structures::SDTHeader>(ACPI::Parser::the()->main_system_description_table()).release_value_but_fixme_should_propagate_errors();
|
||||
if (ACPI::Parser::the()->is_xsdt_supported()) {
|
||||
m_components.append(ACPISysFSComponent::create("XSDT"sv, ACPI::Parser::the()->main_system_description_table(), main_system_description_table->length));
|
||||
} else {
|
||||
m_components.append(ACPISysFSComponent::create("RSDT"sv, ACPI::Parser::the()->main_system_description_table(), main_system_description_table->length));
|
||||
}
|
||||
return {};
|
||||
}));
|
||||
}
|
||||
|
||||
UNMAP_AFTER_INIT NonnullRefPtr<ACPISysFSDirectory> ACPISysFSDirectory::must_create(FirmwareSysFSDirectory& firmware_directory)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue