Kernel: Allow all named objects to fail cleanly if name exists

This commit is contained in:
Bananymous 2024-08-14 20:28:00 +03:00
parent 8a2a444f33
commit 17b7e9e772
7 changed files with 12 additions and 12 deletions

View File

@ -38,16 +38,16 @@ namespace Kernel::ACPI::AML
return ParseResult::Failure; return ParseResult::Failure;
auto source_object = AML::Namespace::root_namespace()->find_object(context.scope, source_string.value(), AML::Namespace::FindMode::Normal); auto source_object = AML::Namespace::root_namespace()->find_object(context.scope, source_string.value(), AML::Namespace::FindMode::Normal);
if (!source_object)
{
AML_ERROR("Alias target could not be found");
return ParseResult::Failure;
}
auto alias_string = AML::NameString::parse(context.aml_data); auto alias_string = AML::NameString::parse(context.aml_data);
if (!alias_string.has_value()) if (!alias_string.has_value())
return ParseResult::Failure; return ParseResult::Failure;
if (!source_object)
{
AML_PRINT("Alias target could not be found");
return ParseResult::Success;
}
auto alias = MUST(BAN::RefPtr<Alias>::create(alias_string.value().path.back(), source_object)); auto alias = MUST(BAN::RefPtr<Alias>::create(alias_string.value().path.back(), source_object));
if (!Namespace::root_namespace()->add_named_object(context, alias_string.value(), alias)) if (!Namespace::root_namespace()->add_named_object(context, alias_string.value(), alias))
return ParseResult::Success; return ParseResult::Success;

View File

@ -250,7 +250,7 @@ namespace Kernel::ACPI::AML
auto field = MUST(BAN::RefPtr<BufferField>::create(field_name->path.back(), buffer, field_bit_offset, field_bit_size)); auto field = MUST(BAN::RefPtr<BufferField>::create(field_name->path.back(), buffer, field_bit_offset, field_bit_size));
if (!Namespace::root_namespace()->add_named_object(context, field_name.value(), field)) if (!Namespace::root_namespace()->add_named_object(context, field_name.value(), field))
return ParseResult::Failure; return ParseResult::Success;
#if AML_DEBUG_LEVEL >= 2 #if AML_DEBUG_LEVEL >= 2
field->debug_print(0); field->debug_print(0);

View File

@ -31,7 +31,7 @@ namespace Kernel::ACPI::AML
auto device = MUST(BAN::RefPtr<Device>::create(name_string->path.back())); auto device = MUST(BAN::RefPtr<Device>::create(name_string->path.back()));
if (!Namespace::root_namespace()->add_named_object(context, name_string.value(), device)) if (!Namespace::root_namespace()->add_named_object(context, name_string.value(), device))
return ParseResult::Failure; return ParseResult::Success;
return device->enter_context_and_parse_term_list(context, name_string.value(), device_pkg.value()); return device->enter_context_and_parse_term_list(context, name_string.value(), device_pkg.value());
} }

View File

@ -71,7 +71,7 @@ namespace Kernel::ACPI::AML
auto mutex = MUST(BAN::RefPtr<Mutex>::create(name->path.back(), sync_level)); auto mutex = MUST(BAN::RefPtr<Mutex>::create(name->path.back(), sync_level));
if (!Namespace::root_namespace()->add_named_object(context, name.value(), mutex)) if (!Namespace::root_namespace()->add_named_object(context, name.value(), mutex))
return ParseResult::Failure; return ParseResult::Success;
#if AML_DEBUG_LEVEL >= 2 #if AML_DEBUG_LEVEL >= 2
mutex->debug_print(0); mutex->debug_print(0);

View File

@ -55,7 +55,7 @@ namespace Kernel::ACPI::AML
auto processor = MUST(BAN::RefPtr<Processor>::create(name->path.back(), id, pblk_addr, pblk_len)); auto processor = MUST(BAN::RefPtr<Processor>::create(name->path.back(), id, pblk_addr, pblk_len));
if (!Namespace::root_namespace()->add_named_object(context, name.value(), processor)) if (!Namespace::root_namespace()->add_named_object(context, name.value(), processor))
return ParseResult::Failure; return ParseResult::Success;
#if AML_DEBUG_LEVEL >= 2 #if AML_DEBUG_LEVEL >= 2
processor->debug_print(0); processor->debug_print(0);

View File

@ -68,7 +68,7 @@ namespace Kernel::ACPI::AML
)); ));
if (!Namespace::root_namespace()->add_named_object(context, name.value(), op_region)) if (!Namespace::root_namespace()->add_named_object(context, name.value(), op_region))
return ParseResult::Failure; return ParseResult::Success;
#if AML_DEBUG_LEVEL >= 2 #if AML_DEBUG_LEVEL >= 2
op_region->debug_print(0); op_region->debug_print(0);

View File

@ -33,7 +33,7 @@ namespace Kernel::ACPI::AML
auto thermal_zone = MUST(BAN::RefPtr<ThermalZone>::create(name->path.back())); auto thermal_zone = MUST(BAN::RefPtr<ThermalZone>::create(name->path.back()));
if (!Namespace::root_namespace()->add_named_object(context, name.value(), thermal_zone)) if (!Namespace::root_namespace()->add_named_object(context, name.value(), thermal_zone))
return ParseResult::Failure; return ParseResult::Success;
#if AML_DEBUG_LEVEL >= 2 #if AML_DEBUG_LEVEL >= 2
thermal_zone->debug_print(0); thermal_zone->debug_print(0);