Kernel: Cleanup and fix AML Method calls
This commit is contained in:
parent
d9b3a4bf77
commit
eaf06d239c
|
@ -3,8 +3,10 @@
|
|||
#include <BAN/Function.h>
|
||||
#include <kernel/ACPI/AML/Bytes.h>
|
||||
#include <kernel/ACPI/AML/Namespace.h>
|
||||
#include <kernel/ACPI/AML/Namespace.h>
|
||||
#include <kernel/ACPI/AML/ParseContext.h>
|
||||
#include <kernel/ACPI/AML/Pkg.h>
|
||||
#include <kernel/ACPI/AML/Register.h>
|
||||
#include <kernel/ACPI/AML/Scope.h>
|
||||
|
||||
namespace Kernel::ACPI::AML
|
||||
|
@ -100,13 +102,13 @@ namespace Kernel::ACPI::AML
|
|||
ParseContext context;
|
||||
context.aml_data = term_list;
|
||||
context.scope = scope;
|
||||
context.method_args[0] = MUST(BAN::RefPtr<AML::Register>::create(arg0 && arg0->type == AML::Node::Type::Register ? static_cast<AML::Register*>(arg0.ptr())->value : arg0));
|
||||
context.method_args[1] = MUST(BAN::RefPtr<AML::Register>::create(arg1 && arg1->type == AML::Node::Type::Register ? static_cast<AML::Register*>(arg1.ptr())->value : arg1));
|
||||
context.method_args[2] = MUST(BAN::RefPtr<AML::Register>::create(arg2 && arg2->type == AML::Node::Type::Register ? static_cast<AML::Register*>(arg2.ptr())->value : arg2));
|
||||
context.method_args[3] = MUST(BAN::RefPtr<AML::Register>::create(arg3 && arg3->type == AML::Node::Type::Register ? static_cast<AML::Register*>(arg3.ptr())->value : arg3));
|
||||
context.method_args[4] = MUST(BAN::RefPtr<AML::Register>::create(arg4 && arg4->type == AML::Node::Type::Register ? static_cast<AML::Register*>(arg4.ptr())->value : arg4));
|
||||
context.method_args[5] = MUST(BAN::RefPtr<AML::Register>::create(arg5 && arg5->type == AML::Node::Type::Register ? static_cast<AML::Register*>(arg5.ptr())->value : arg5));
|
||||
context.method_args[6] = MUST(BAN::RefPtr<AML::Register>::create(arg6 && arg6->type == AML::Node::Type::Register ? static_cast<AML::Register*>(arg6.ptr())->value : arg6));
|
||||
context.method_args[0] = MUST(BAN::RefPtr<AML::Register>::create(arg0));
|
||||
context.method_args[1] = MUST(BAN::RefPtr<AML::Register>::create(arg1));
|
||||
context.method_args[2] = MUST(BAN::RefPtr<AML::Register>::create(arg2));
|
||||
context.method_args[3] = MUST(BAN::RefPtr<AML::Register>::create(arg3));
|
||||
context.method_args[4] = MUST(BAN::RefPtr<AML::Register>::create(arg4));
|
||||
context.method_args[5] = MUST(BAN::RefPtr<AML::Register>::create(arg5));
|
||||
context.method_args[6] = MUST(BAN::RefPtr<AML::Register>::create(arg6));
|
||||
context.sync_stack = BAN::move(current_sync_stack);
|
||||
for (auto& local : context.method_locals)
|
||||
local = MUST(BAN::RefPtr<AML::Register>::create());
|
||||
|
|
|
@ -219,45 +219,41 @@ namespace Kernel::ACPI
|
|||
AML_ERROR("NameString {} not found in namespace", name_string.value());
|
||||
return ParseResult::Failure;
|
||||
}
|
||||
if (aml_object->type == AML::Node::Type::Method)
|
||||
if (aml_object->type != AML::Node::Type::Method)
|
||||
return ParseResult(aml_object);
|
||||
|
||||
auto* method = static_cast<AML::Method*>(aml_object.ptr());
|
||||
|
||||
BAN::Array<BAN::RefPtr<AML::Node>, 7> args;
|
||||
for (uint8_t i = 0; i < method->arg_count; i++)
|
||||
{
|
||||
auto* method = static_cast<AML::Method*>(aml_object.ptr());
|
||||
|
||||
BAN::Array<BAN::RefPtr<AML::Node>, 7> args;
|
||||
for (uint8_t i = 0; i < method->arg_count; i++)
|
||||
auto arg_result = AML::parse_object(context);
|
||||
if (!arg_result.success() || !arg_result.node())
|
||||
{
|
||||
auto arg = AML::parse_object(context);
|
||||
if (!arg.success())
|
||||
{
|
||||
AML_ERROR("Failed to parse argument {} for method {}", i, name_string.value());
|
||||
return ParseResult::Failure;
|
||||
}
|
||||
args[i] = MUST(BAN::RefPtr<AML::Register>::create(arg.node()));
|
||||
}
|
||||
|
||||
auto result = method->invoke_with_sync_stack(
|
||||
context.sync_stack,
|
||||
args[0],
|
||||
args[1],
|
||||
args[2],
|
||||
args[3],
|
||||
args[4],
|
||||
args[5],
|
||||
args[6]
|
||||
);
|
||||
if (!result.has_value())
|
||||
{
|
||||
AML_ERROR("Failed to evaluate {}", name_string.value());
|
||||
AML_ERROR("Failed to parse argument {} for method {}", i, name_string.value());
|
||||
return ParseResult::Failure;
|
||||
}
|
||||
if (!result.value())
|
||||
return ParseResult::Success;
|
||||
return ParseResult(result.value());
|
||||
args[i] = arg_result.node();
|
||||
}
|
||||
|
||||
if (aml_object->type == AML::Node::Type::Name)
|
||||
return ParseResult(static_cast<AML::Name*>(aml_object.ptr())->object);
|
||||
return ParseResult(aml_object);
|
||||
auto result = method->invoke_with_sync_stack(
|
||||
context.sync_stack,
|
||||
args[0],
|
||||
args[1],
|
||||
args[2],
|
||||
args[3],
|
||||
args[4],
|
||||
args[5],
|
||||
args[6]
|
||||
);
|
||||
if (!result.has_value())
|
||||
{
|
||||
AML_ERROR("Failed to evaluate {}", name_string.value());
|
||||
return ParseResult::Failure;
|
||||
}
|
||||
if (!result.value())
|
||||
return ParseResult::Success;
|
||||
return ParseResult(result.value());
|
||||
}
|
||||
|
||||
AML_TODO("{2H}", context.aml_data[0]);
|
||||
|
|
Loading…
Reference in New Issue