Kernel: Implement dummy AML NotifyOp

This commit is contained in:
Bananymous 2024-04-17 15:40:11 +03:00
parent da0c45b7ee
commit aefb33efff
2 changed files with 72 additions and 0 deletions

View File

@ -0,0 +1,66 @@
#pragma once
#include <kernel/ACPI/AML/Device.h>
#include <kernel/ACPI/AML/ParseContext.h>
#include <kernel/ACPI/AML/Processor.h>
#include <kernel/ACPI/AML/ThermalZone.h>
namespace Kernel::ACPI::AML
{
struct Notify
{
static ParseResult parse(ParseContext& context)
{
ASSERT(context.aml_data.size() >= 1);
ASSERT(static_cast<Byte>(context.aml_data[0]) == Byte::NotifyOp);
context.aml_data = context.aml_data.slice(1);
auto object_result = AML::parse_object(context);
if (!object_result.success())
return ParseResult::Failure;
auto object = object_result.node();
if (!object)
{
AML_ERROR("Notify object is null");
return ParseResult::Failure;
}
auto value_result = AML::parse_object(context);
if (!value_result.success())
return ParseResult::Failure;
auto value = value_result.node() ? value_result.node()->as_integer() : BAN::Optional<uint64_t>();
if (!value.has_value())
{
AML_ERROR("Notify value is not an integer");
return ParseResult::Failure;
}
BAN::StringView object_type_sv;
BAN::StringView object_name_sv;
switch (object->type)
{
case AML::Node::Type::Device:
object_type_sv = "Device"sv;
object_name_sv = static_cast<AML::Device*>(object.ptr())->name.sv();
break;
case AML::Node::Type::Processor:
object_type_sv = "Processor"sv;
object_name_sv = static_cast<AML::Processor*>(object.ptr())->name.sv();
break;
case AML::Node::Type::ThermalZone:
object_type_sv = "ThermalZone"sv;
object_name_sv = static_cast<AML::ThermalZone*>(object.ptr())->name.sv();
break;
default:
object_type_sv = "Unknown"sv;
object_name_sv = "????"sv;
break;
}
AML_TODO("Notify: {} {}: {2H}", object_type_sv, object_name_sv, value.value());
return ParseResult::Success;
}
};
}

View File

@ -10,6 +10,7 @@
#include <kernel/ACPI/AML/Mutex.h>
#include <kernel/ACPI/AML/Names.h>
#include <kernel/ACPI/AML/Node.h>
#include <kernel/ACPI/AML/Notify.h>
#include <kernel/ACPI/AML/Package.h>
#include <kernel/ACPI/AML/ParseContext.h>
#include <kernel/ACPI/AML/PowerResource.h>
@ -173,6 +174,11 @@ namespace Kernel::ACPI
return AML::Reference::parse(context);
case AML::Byte::IndexOp:
return AML::Index::parse(context);
case AML::Byte::NotifyOp:
return AML::Notify::parse(context);
case AML::Byte::NoopOp:
context.aml_data = context.aml_data.slice(1);
return ParseResult::Success;
case AML::Byte::ReturnOp:
{
context.aml_data = context.aml_data.slice(1);