Compare commits
6 Commits
66905fcc08
...
cb07142832
Author | SHA1 | Date |
---|---|---|
Bananymous | cb07142832 | |
Bananymous | 60a05412c9 | |
Bananymous | 0179f5ea09 | |
Bananymous | f671ed7e3f | |
Bananymous | 2fccff5a35 | |
Bananymous | cd41d5f6dd |
|
@ -5,6 +5,7 @@
|
|||
#include <kernel/ACPI/AML/Node.h>
|
||||
#include <kernel/ACPI/AML/ParseContext.h>
|
||||
#include <kernel/ACPI/AML/Pkg.h>
|
||||
#include <kernel/ACPI/AML/String.h>
|
||||
|
||||
namespace Kernel::ACPI::AML
|
||||
{
|
||||
|
@ -67,11 +68,12 @@ namespace Kernel::ACPI::AML
|
|||
|
||||
struct BufferField : AML::NamedObject
|
||||
{
|
||||
BAN::RefPtr<Buffer> buffer;
|
||||
BAN::RefPtr<AML::Node> buffer;
|
||||
size_t field_bit_offset;
|
||||
size_t field_bit_size;
|
||||
|
||||
BufferField(AML::NameSeg name, BAN::RefPtr<Buffer> buffer, size_t field_bit_offset, size_t field_bit_size)
|
||||
template<typename T> requires BAN::is_same_v<T, AML::Buffer> || BAN::is_same_v<T, AML::String>
|
||||
BufferField(AML::NameSeg name, BAN::RefPtr<T> buffer, size_t field_bit_offset, size_t field_bit_size)
|
||||
: AML::NamedObject(Node::Type::BufferField, name)
|
||||
, buffer(buffer)
|
||||
, field_bit_offset(field_bit_offset)
|
||||
|
@ -81,7 +83,11 @@ namespace Kernel::ACPI::AML
|
|||
BAN::RefPtr<AML::Node> evaluate() override
|
||||
{
|
||||
ASSERT(buffer);
|
||||
ASSERT(field_bit_offset + field_bit_size <= buffer->buffer.size() * 8);
|
||||
ASSERT(buffer->type == AML::Node::Type::Buffer || buffer->type == AML::Node::Type::String);
|
||||
const auto& buffer = (this->buffer->type == AML::Node::Type::Buffer)
|
||||
? static_cast<AML::Buffer*>(this->buffer.ptr())->buffer
|
||||
: static_cast<AML::String*>(this->buffer.ptr())->string;
|
||||
ASSERT(field_bit_offset + field_bit_size <= buffer.size() * 8);
|
||||
|
||||
uint64_t value = 0;
|
||||
|
||||
|
@ -89,13 +95,13 @@ namespace Kernel::ACPI::AML
|
|||
const size_t bit_offset = field_bit_offset % 8;
|
||||
if (field_bit_size == 1)
|
||||
{
|
||||
value = (buffer->buffer[byte_offset] >> bit_offset) & 1;
|
||||
value = (buffer[byte_offset] >> bit_offset) & 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
ASSERT(bit_offset == 0);
|
||||
for (size_t byte = 0; byte < field_bit_size / 8; byte++)
|
||||
value |= buffer->buffer[byte_offset + byte] << byte;
|
||||
value |= buffer[byte_offset + byte] << byte;
|
||||
}
|
||||
|
||||
return MUST(BAN::RefPtr<AML::Integer>::create(value));
|
||||
|
@ -104,7 +110,11 @@ namespace Kernel::ACPI::AML
|
|||
bool store(BAN::RefPtr<AML::Node> node) override
|
||||
{
|
||||
ASSERT(buffer);
|
||||
ASSERT(field_bit_offset + field_bit_size <= buffer->buffer.size() * 8);
|
||||
ASSERT(buffer->type == AML::Node::Type::Buffer || buffer->type == AML::Node::Type::String);
|
||||
auto& buffer = (this->buffer->type == AML::Node::Type::Buffer)
|
||||
? static_cast<AML::Buffer*>(this->buffer.ptr())->buffer
|
||||
: static_cast<AML::String*>(this->buffer.ptr())->string;
|
||||
ASSERT(field_bit_offset + field_bit_size <= buffer.size() * 8);
|
||||
|
||||
auto value = node->as_integer();
|
||||
if (!value.has_value())
|
||||
|
@ -114,14 +124,14 @@ namespace Kernel::ACPI::AML
|
|||
const size_t bit_offset = field_bit_offset % 8;
|
||||
if (field_bit_size == 1)
|
||||
{
|
||||
buffer->buffer[byte_offset] &= ~(1 << bit_offset);
|
||||
buffer->buffer[byte_offset] |= (value.value() & 1) << bit_offset;
|
||||
buffer[byte_offset] &= ~(1 << bit_offset);
|
||||
buffer[byte_offset] |= (value.value() & 1) << bit_offset;
|
||||
}
|
||||
else
|
||||
{
|
||||
ASSERT(bit_offset == 0);
|
||||
for (size_t byte = 0; byte < field_bit_size / 8; byte++)
|
||||
buffer->buffer[byte_offset + byte] = (value.value() >> (byte * 8)) & 0xFF;
|
||||
buffer[byte_offset + byte] = (value.value() >> (byte * 8)) & 0xFF;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -163,7 +173,7 @@ namespace Kernel::ACPI::AML
|
|||
AML_ERROR("Buffer source does not evaluate to a Buffer");
|
||||
return ParseResult::Failure;
|
||||
}
|
||||
auto buffer = static_cast<Buffer*>(buffer_node.ptr());
|
||||
auto buffer = BAN::RefPtr<AML::Buffer>(static_cast<AML::Buffer*>(buffer_node.ptr()));
|
||||
|
||||
auto index_result = AML::parse_object(context);
|
||||
if (!index_result.success())
|
||||
|
|
|
@ -42,7 +42,7 @@ namespace Kernel::ACPI::AML
|
|||
{
|
||||
case AML::Node::Type::Buffer:
|
||||
{
|
||||
auto buffer = static_cast<AML::Buffer*>(source.ptr());
|
||||
auto buffer = BAN::RefPtr<AML::Buffer>(static_cast<AML::Buffer*>(source.ptr()));
|
||||
if (index.value() >= buffer->buffer.size())
|
||||
{
|
||||
AML_ERROR("IndexOp index is out of buffer bounds");
|
||||
|
@ -65,8 +65,17 @@ namespace Kernel::ACPI::AML
|
|||
break;
|
||||
}
|
||||
case AML::Node::Type::String:
|
||||
AML_TODO("IndexOp source String");
|
||||
{
|
||||
auto string = BAN::RefPtr<AML::String>(static_cast<AML::String*>(source.ptr()));
|
||||
if (index.value() >= string->string.size())
|
||||
{
|
||||
AML_ERROR("IndexOp index is out of string bounds");
|
||||
return ParseResult::Failure;
|
||||
}
|
||||
auto buffer_field = MUST(BAN::RefPtr<BufferField>::create(NameSeg(""_sv), string, index.value() * 8, 8));
|
||||
result = MUST(BAN::RefPtr<AML::Reference>::create(buffer_field));
|
||||
break;
|
||||
}
|
||||
default:
|
||||
AML_ERROR("IndexOp source is not a Buffer, Package, or String");
|
||||
return ParseResult::Failure;
|
||||
|
|
|
@ -30,6 +30,8 @@ namespace Kernel::ACPI::AML
|
|||
, constant(constant)
|
||||
{}
|
||||
|
||||
BAN::RefPtr<Node> copy() override { return MUST(BAN::RefPtr<Integer>::create(value)); }
|
||||
|
||||
BAN::RefPtr<AML::Node> evaluate() override
|
||||
{
|
||||
return this;
|
||||
|
|
|
@ -43,6 +43,8 @@ namespace Kernel::ACPI::AML
|
|||
|
||||
virtual bool is_scope() const { return false; }
|
||||
|
||||
virtual BAN::RefPtr<Node> copy() { return this; }
|
||||
|
||||
[[nodiscard]] BAN::Optional<uint64_t> as_integer();
|
||||
[[nodiscard]] virtual BAN::RefPtr<AML::Node> evaluate() { AML_TODO("evaluate, type {}", static_cast<uint8_t>(type)); return nullptr; }
|
||||
[[nodiscard]] virtual bool store(BAN::RefPtr<AML::Node>) { AML_TODO("store, type {}", static_cast<uint8_t>(type)); return false; }
|
||||
|
|
|
@ -32,7 +32,7 @@ namespace Kernel::ACPI::AML
|
|||
AML_ERROR("Failed to evaluate source for store");
|
||||
return false;
|
||||
}
|
||||
value = evaluated;
|
||||
value = evaluated->copy();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,54 @@
|
|||
#pragma once
|
||||
|
||||
|
||||
#include <kernel/ACPI/AML/Buffer.h>
|
||||
#include <kernel/ACPI/AML/Names.h>
|
||||
#include <kernel/ACPI/AML/Package.h>
|
||||
#include <kernel/ACPI/AML/ParseContext.h>
|
||||
#include <kernel/ACPI/AML/Reference.h>
|
||||
|
||||
namespace Kernel::ACPI::AML
|
||||
{
|
||||
|
||||
struct SizeOf
|
||||
{
|
||||
static ParseResult parse(ParseContext& context)
|
||||
{
|
||||
ASSERT(context.aml_data.size() >= 1);
|
||||
ASSERT(static_cast<Byte>(context.aml_data[0]) == Byte::SizeOfOp);
|
||||
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()->evaluate();
|
||||
if (object && object->type == AML::Node::Type::Reference)
|
||||
object = static_cast<AML::Reference*>(object.ptr())->node->evaluate();
|
||||
if (!object)
|
||||
{
|
||||
AML_ERROR("SizeOf object is null");
|
||||
return ParseResult::Failure;
|
||||
}
|
||||
|
||||
uint64_t size = 0;
|
||||
switch (object->type)
|
||||
{
|
||||
case AML::Node::Type::Buffer:
|
||||
size = static_cast<AML::Buffer*>(object.ptr())->buffer.size();
|
||||
break;
|
||||
case AML::Node::Type::String:
|
||||
size = static_cast<AML::String*>(object.ptr())->string.size();
|
||||
break;
|
||||
case AML::Node::Type::Package:
|
||||
size = static_cast<AML::Package*>(object.ptr())->elements.size();
|
||||
break;
|
||||
default:
|
||||
AML_ERROR("SizeOf object is not a buffer, string or package ({})", static_cast<uint8_t>(object->type));
|
||||
return ParseResult::Failure;
|
||||
}
|
||||
|
||||
return ParseResult(MUST(BAN::RefPtr<Integer>::create(size)));
|
||||
}
|
||||
};
|
||||
|
||||
}
|
|
@ -9,28 +9,40 @@ namespace Kernel::ACPI::AML
|
|||
|
||||
struct String : public AML::Node
|
||||
{
|
||||
BAN::String string;
|
||||
BAN::Vector<uint8_t> string;
|
||||
|
||||
String() : Node(Node::Type::String) {}
|
||||
String(BAN::StringView string)
|
||||
: Node(Node::Type::String)
|
||||
{
|
||||
MUST(this->string.resize(string.size()));
|
||||
for (size_t i = 0; i < string.size(); i++)
|
||||
this->string[i] = string[i];
|
||||
}
|
||||
|
||||
BAN::RefPtr<AML::Node> evaluate() override
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
BAN::StringView string_view() const
|
||||
{
|
||||
return BAN::StringView(reinterpret_cast<const char*>(string.data()), string.size());
|
||||
}
|
||||
|
||||
static ParseResult parse(ParseContext& context)
|
||||
{
|
||||
ASSERT(context.aml_data.size() >= 1);
|
||||
ASSERT(static_cast<AML::Byte>(context.aml_data[0]) == AML::Byte::StringPrefix);
|
||||
context.aml_data = context.aml_data.slice(1);
|
||||
|
||||
BAN::String string;
|
||||
BAN::Vector<uint8_t> string;
|
||||
|
||||
while (context.aml_data.size() > 0)
|
||||
{
|
||||
if (context.aml_data[0] == 0x00)
|
||||
break;
|
||||
MUST(string.push_back(static_cast<char>(context.aml_data[0])));
|
||||
MUST(string.push_back(context.aml_data[0]));
|
||||
context.aml_data = context.aml_data.slice(1);
|
||||
}
|
||||
|
||||
|
@ -49,7 +61,7 @@ namespace Kernel::ACPI::AML
|
|||
virtual void debug_print(int indent) const override
|
||||
{
|
||||
AML_DEBUG_PRINT_INDENT(indent);
|
||||
AML_DEBUG_PRINT("String \"{}\"", string);
|
||||
AML_DEBUG_PRINT("String \"{}\"", string_view());
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -506,9 +506,9 @@ acpi_release_global_lock:
|
|||
return;
|
||||
}
|
||||
auto* s5_package = static_cast<AML::Package*>(s5_evaluated.ptr());
|
||||
if (s5_package->elements.size() != 4)
|
||||
if (s5_package->elements.size() < 2)
|
||||
{
|
||||
dwarnln("\\_S5 package has {} elements, expected 4", s5_package->elements.size());
|
||||
dwarnln("\\_S5 package has {} elements, expected atleast 2", s5_package->elements.size());
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -222,10 +222,14 @@ namespace Kernel::ACPI
|
|||
return {};
|
||||
}
|
||||
auto string = static_cast<AML::String*>(arg.ptr());
|
||||
return string->string == "Linux" ? AML::Integer::Constants::Ones : AML::Integer::Constants::Zero;
|
||||
return string->string_view() == "Linux"_sv ? AML::Integer::Constants::Ones : AML::Integer::Constants::Zero;
|
||||
};
|
||||
ASSERT(s_root_namespace->add_named_object(context, AML::NameString("\\_OSI"), osi));
|
||||
|
||||
auto os_string = MUST(BAN::RefPtr<AML::String>::create("banan-os"_sv));
|
||||
auto os = MUST(BAN::RefPtr<AML::Name>::create("_OS"_sv, os_string));
|
||||
ASSERT(s_root_namespace->add_named_object(context, AML::NameString("\\_OS"), os));
|
||||
|
||||
return s_root_namespace;
|
||||
}
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#include <kernel/ACPI/AML/Processor.h>
|
||||
#include <kernel/ACPI/AML/Reference.h>
|
||||
#include <kernel/ACPI/AML/Region.h>
|
||||
#include <kernel/ACPI/AML/SizeOf.h>
|
||||
#include <kernel/ACPI/AML/Sleep.h>
|
||||
#include <kernel/ACPI/AML/Store.h>
|
||||
#include <kernel/ACPI/AML/String.h>
|
||||
|
@ -176,6 +177,8 @@ namespace Kernel::ACPI
|
|||
return AML::Index::parse(context);
|
||||
case AML::Byte::NotifyOp:
|
||||
return AML::Notify::parse(context);
|
||||
case AML::Byte::SizeOfOp:
|
||||
return AML::SizeOf::parse(context);
|
||||
case AML::Byte::NoopOp:
|
||||
context.aml_data = context.aml_data.slice(1);
|
||||
return ParseResult::Success;
|
||||
|
|
|
@ -10,8 +10,7 @@ if [ -z $BANAN_SYSROOT ]; then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
CURRENT_DIR=$(dirname $(realpath $0))
|
||||
pushd $CURRENT_DIR >/dev/null
|
||||
cd $(dirname $(realpath $0))
|
||||
|
||||
if [ ! -d "doomgeneric" ]; then
|
||||
git clone https://github.com/ozkl/doomgeneric.git
|
||||
|
@ -25,7 +24,10 @@ if [ ! -d "doomgeneric" ]; then
|
|||
grep -qxF doom ../installed || echo doom >> ../installed
|
||||
fi
|
||||
|
||||
if [ ! -f doom1.wad ]; then
|
||||
wget https://distro.ibiblio.org/slitaz/sources/packages/d/doom1.wad
|
||||
fi
|
||||
|
||||
make --directory doomgeneric/doomgeneric --file Makefile.banan_os
|
||||
cp "doomgeneric/doomgeneric/build-${BANAN_ARCH}/doomgeneric" "${BANAN_SYSROOT}/bin/doom"
|
||||
|
||||
popd >/dev/null
|
||||
cp doom1.wad $BANAN_SYSROOT/home/user/
|
||||
|
|
Loading…
Reference in New Issue