From 17b7e9e77236e076560bed1e6860af65b6600bc6 Mon Sep 17 00:00:00 2001 From: Bananymous Date: Wed, 14 Aug 2024 20:28:00 +0300 Subject: [PATCH] Kernel: Allow all named objects to fail cleanly if name exists --- kernel/include/kernel/ACPI/AML/Alias.h | 12 ++++++------ kernel/include/kernel/ACPI/AML/Buffer.h | 2 +- kernel/include/kernel/ACPI/AML/Device.h | 2 +- kernel/include/kernel/ACPI/AML/Mutex.h | 2 +- kernel/include/kernel/ACPI/AML/Processor.h | 2 +- kernel/include/kernel/ACPI/AML/Region.h | 2 +- kernel/include/kernel/ACPI/AML/ThermalZone.h | 2 +- 7 files changed, 12 insertions(+), 12 deletions(-) diff --git a/kernel/include/kernel/ACPI/AML/Alias.h b/kernel/include/kernel/ACPI/AML/Alias.h index 615203432c..315cb04127 100644 --- a/kernel/include/kernel/ACPI/AML/Alias.h +++ b/kernel/include/kernel/ACPI/AML/Alias.h @@ -38,16 +38,16 @@ namespace Kernel::ACPI::AML return ParseResult::Failure; 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); if (!alias_string.has_value()) return ParseResult::Failure; + if (!source_object) + { + AML_PRINT("Alias target could not be found"); + return ParseResult::Success; + } + auto alias = MUST(BAN::RefPtr::create(alias_string.value().path.back(), source_object)); if (!Namespace::root_namespace()->add_named_object(context, alias_string.value(), alias)) return ParseResult::Success; diff --git a/kernel/include/kernel/ACPI/AML/Buffer.h b/kernel/include/kernel/ACPI/AML/Buffer.h index b1fd791189..49d244b53c 100644 --- a/kernel/include/kernel/ACPI/AML/Buffer.h +++ b/kernel/include/kernel/ACPI/AML/Buffer.h @@ -250,7 +250,7 @@ namespace Kernel::ACPI::AML auto field = MUST(BAN::RefPtr::create(field_name->path.back(), buffer, field_bit_offset, field_bit_size)); if (!Namespace::root_namespace()->add_named_object(context, field_name.value(), field)) - return ParseResult::Failure; + return ParseResult::Success; #if AML_DEBUG_LEVEL >= 2 field->debug_print(0); diff --git a/kernel/include/kernel/ACPI/AML/Device.h b/kernel/include/kernel/ACPI/AML/Device.h index 8fa687381a..0349290b78 100644 --- a/kernel/include/kernel/ACPI/AML/Device.h +++ b/kernel/include/kernel/ACPI/AML/Device.h @@ -31,7 +31,7 @@ namespace Kernel::ACPI::AML auto device = MUST(BAN::RefPtr::create(name_string->path.back())); 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()); } diff --git a/kernel/include/kernel/ACPI/AML/Mutex.h b/kernel/include/kernel/ACPI/AML/Mutex.h index 4fa9ee94f4..7aa23327c1 100644 --- a/kernel/include/kernel/ACPI/AML/Mutex.h +++ b/kernel/include/kernel/ACPI/AML/Mutex.h @@ -71,7 +71,7 @@ namespace Kernel::ACPI::AML auto mutex = MUST(BAN::RefPtr::create(name->path.back(), sync_level)); if (!Namespace::root_namespace()->add_named_object(context, name.value(), mutex)) - return ParseResult::Failure; + return ParseResult::Success; #if AML_DEBUG_LEVEL >= 2 mutex->debug_print(0); diff --git a/kernel/include/kernel/ACPI/AML/Processor.h b/kernel/include/kernel/ACPI/AML/Processor.h index 382d682906..3402e3453c 100644 --- a/kernel/include/kernel/ACPI/AML/Processor.h +++ b/kernel/include/kernel/ACPI/AML/Processor.h @@ -55,7 +55,7 @@ namespace Kernel::ACPI::AML auto processor = MUST(BAN::RefPtr::create(name->path.back(), id, pblk_addr, pblk_len)); if (!Namespace::root_namespace()->add_named_object(context, name.value(), processor)) - return ParseResult::Failure; + return ParseResult::Success; #if AML_DEBUG_LEVEL >= 2 processor->debug_print(0); diff --git a/kernel/include/kernel/ACPI/AML/Region.h b/kernel/include/kernel/ACPI/AML/Region.h index 805734476f..ad599b8cd3 100644 --- a/kernel/include/kernel/ACPI/AML/Region.h +++ b/kernel/include/kernel/ACPI/AML/Region.h @@ -68,7 +68,7 @@ namespace Kernel::ACPI::AML )); if (!Namespace::root_namespace()->add_named_object(context, name.value(), op_region)) - return ParseResult::Failure; + return ParseResult::Success; #if AML_DEBUG_LEVEL >= 2 op_region->debug_print(0); diff --git a/kernel/include/kernel/ACPI/AML/ThermalZone.h b/kernel/include/kernel/ACPI/AML/ThermalZone.h index 69e379eb9a..675c35522a 100644 --- a/kernel/include/kernel/ACPI/AML/ThermalZone.h +++ b/kernel/include/kernel/ACPI/AML/ThermalZone.h @@ -33,7 +33,7 @@ namespace Kernel::ACPI::AML auto thermal_zone = MUST(BAN::RefPtr::create(name->path.back())); if (!Namespace::root_namespace()->add_named_object(context, name.value(), thermal_zone)) - return ParseResult::Failure; + return ParseResult::Success; #if AML_DEBUG_LEVEL >= 2 thermal_zone->debug_print(0);