Compare commits
5 Commits
19d16620a6
...
a07cbabcb3
Author | SHA1 | Date |
---|---|---|
Bananymous | a07cbabcb3 | |
Bananymous | 64a3893f6f | |
Bananymous | eabe759ebf | |
Bananymous | a4838386e6 | |
Bananymous | c65613901f |
|
@ -37,9 +37,7 @@ namespace Kernel
|
|||
|
||||
static constexpr inline uintptr_t uncanonicalize(uintptr_t addr)
|
||||
{
|
||||
if (addr & 0x0000800000000000)
|
||||
return addr & ~0xFFFF000000000000;
|
||||
return addr;
|
||||
return addr & 0x0000FFFFFFFFFFFF;
|
||||
}
|
||||
|
||||
static constexpr inline uintptr_t canonicalize(uintptr_t addr)
|
||||
|
|
|
@ -7,37 +7,8 @@
|
|||
namespace Kernel::ACPI::AML
|
||||
{
|
||||
|
||||
struct Alias final : public AML::NamedObject
|
||||
struct Alias
|
||||
{
|
||||
BAN::RefPtr<AML::Node> target;
|
||||
|
||||
Alias(NameSeg name, BAN::RefPtr<AML::Node> target)
|
||||
: NamedObject(Node::Type::Alias, name)
|
||||
, target(target)
|
||||
{}
|
||||
|
||||
BAN::RefPtr<AML::Node> to_underlying() override { return target; }
|
||||
|
||||
bool is_scope() const override { return target->is_scope(); }
|
||||
|
||||
BAN::RefPtr<AML::Node> convert(uint8_t mask) override
|
||||
{
|
||||
ASSERT(target);
|
||||
return target->convert(mask);
|
||||
}
|
||||
|
||||
BAN::RefPtr<Node> copy() override
|
||||
{
|
||||
ASSERT(target);
|
||||
return target->copy();
|
||||
}
|
||||
|
||||
BAN::RefPtr<AML::Node> store(BAN::RefPtr<AML::Node> node) override
|
||||
{
|
||||
ASSERT(target);
|
||||
return target->store(node);
|
||||
}
|
||||
|
||||
static ParseResult parse(ParseContext& context)
|
||||
{
|
||||
ASSERT(context.aml_data.size() >= 1);
|
||||
|
@ -59,27 +30,19 @@ namespace Kernel::ACPI::AML
|
|||
return ParseResult::Success;
|
||||
}
|
||||
|
||||
auto alias = MUST(BAN::RefPtr<Alias>::create(alias_string.value().path.back(), source_object->to_underlying()));
|
||||
if (!Namespace::root_namespace()->add_named_object(context, alias_string.value(), alias))
|
||||
if (!Namespace::root_namespace()->add_named_object(context, alias_string.value(), source_object))
|
||||
return ParseResult::Success;
|
||||
|
||||
#if AML_DEBUG_LEVEL >= 2
|
||||
alias->debug_print(0);
|
||||
AML_DEBUG_PRINT("Alias \"");
|
||||
alias_string->debug_print();
|
||||
AML_DEBUG_PRINT("\" => ");
|
||||
source_object->debug_print(0);
|
||||
AML_DEBUG_PRINTLN("");
|
||||
#endif
|
||||
|
||||
return ParseResult::Success;
|
||||
}
|
||||
|
||||
void debug_print(int indent) const override
|
||||
{
|
||||
AML_DEBUG_PRINT_INDENT(indent);
|
||||
AML_DEBUG_PRINTLN("Alias {} { ", name);
|
||||
target->debug_print(indent + 1);
|
||||
AML_DEBUG_PRINTLN("");
|
||||
AML_DEBUG_PRINT_INDENT(indent);
|
||||
AML_DEBUG_PRINT("}");
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -50,9 +50,6 @@ namespace Kernel::ACPI::AML
|
|||
|
||||
switch (destination->type)
|
||||
{
|
||||
case AML::Node::Type::Alias:
|
||||
static_cast<AML::Alias*>(destination.ptr())->target = source->copy();
|
||||
return source;
|
||||
case AML::Node::Type::Name:
|
||||
static_cast<AML::Name*>(destination.ptr())->object = source->copy();
|
||||
return source;
|
||||
|
|
|
@ -67,7 +67,12 @@ namespace Kernel::ACPI::AML
|
|||
return ParseResult::Failure;
|
||||
}
|
||||
auto package_element = package->elements[index];
|
||||
result = MUST(BAN::RefPtr<AML::Reference>::create(package_element->to_underlying()));
|
||||
if (!package_element)
|
||||
{
|
||||
AML_ERROR("IndexOp target is null package element");
|
||||
return ParseResult::Failure;
|
||||
}
|
||||
result = MUST(BAN::RefPtr<AML::Reference>::create(package_element));
|
||||
break;
|
||||
}
|
||||
case AML::Node::Type::String:
|
||||
|
|
|
@ -29,7 +29,6 @@ namespace Kernel::ACPI::AML
|
|||
enum class Type : uint8_t
|
||||
{
|
||||
None,
|
||||
Alias,
|
||||
BankFieldElement,
|
||||
Buffer,
|
||||
BufferField,
|
||||
|
|
|
@ -31,7 +31,6 @@ namespace Kernel::ACPI::AML
|
|||
switch (object->type)
|
||||
{
|
||||
case AML::Node::Type::None:
|
||||
case AML::Node::Type::Alias:
|
||||
case AML::Node::Type::Name:
|
||||
case AML::Node::Type::PackageElement:
|
||||
case AML::Node::Type::Reference:
|
||||
|
|
|
@ -84,7 +84,7 @@ namespace Kernel::ACPI::AML
|
|||
{
|
||||
if (!initialized)
|
||||
{
|
||||
AML_ERROR("Trying to store into uninitialized PackageElement");
|
||||
AML_ERROR("Trying to convert uninitialized PackageElement");
|
||||
return {};
|
||||
}
|
||||
if (!resolved && !resolve())
|
||||
|
@ -96,7 +96,7 @@ namespace Kernel::ACPI::AML
|
|||
{
|
||||
if (!initialized)
|
||||
{
|
||||
AML_ERROR("Trying to store into uninitialized PackageElement");
|
||||
AML_ERROR("Trying to read uninitialized PackageElement");
|
||||
return {};
|
||||
}
|
||||
if (!resolved && !resolve())
|
||||
|
@ -108,17 +108,17 @@ namespace Kernel::ACPI::AML
|
|||
{
|
||||
if (!initialized)
|
||||
{
|
||||
AML_ERROR("Trying to store into uninitialized PackageElement");
|
||||
return {};
|
||||
initialized = true;
|
||||
resolved = true;
|
||||
}
|
||||
if (!resolved && !resolve())
|
||||
return {};
|
||||
ASSERT(element->type != AML::Node::Type::Reference);
|
||||
ASSERT(!element || element->type != AML::Node::Type::Reference);
|
||||
if (node->type == AML::Node::Type::Reference)
|
||||
element = static_cast<AML::Reference*>(element.ptr())->node;
|
||||
element = static_cast<AML::Reference*>(node.ptr())->node;
|
||||
else
|
||||
element = element->copy();
|
||||
return element;
|
||||
element = node->copy();
|
||||
return node;
|
||||
}
|
||||
|
||||
static ParseResult parse(AML::ParseContext& context, BAN::RefPtr<AML::Package> package)
|
||||
|
|
|
@ -22,8 +22,8 @@ namespace Kernel::ACPI::AML
|
|||
if (!object_result.success())
|
||||
return ParseResult::Failure;
|
||||
auto object_node = object_result.node();
|
||||
if (object_node && object_node->type == AML::Node::Type::Register)
|
||||
object_node = static_cast<AML::Register*>(object_node.ptr())->value;
|
||||
if (object_node)
|
||||
object_node = object_node->to_underlying();
|
||||
if (!object_node)
|
||||
{
|
||||
AML_ERROR("SizeOf object is null");
|
||||
|
|
|
@ -495,25 +495,7 @@ acpi_release_global_lock:
|
|||
dwarnln("\\_S5 not found");
|
||||
return;
|
||||
}
|
||||
BAN::RefPtr<AML::Node> s5_evaluated = s5_object;
|
||||
while (true)
|
||||
{
|
||||
bool done = false;
|
||||
switch (s5_evaluated->type)
|
||||
{
|
||||
case AML::Node::Type::Alias:
|
||||
s5_evaluated = static_cast<AML::Alias*>(s5_evaluated.ptr())->target;
|
||||
break;
|
||||
case AML::Node::Type::Name:
|
||||
s5_evaluated = static_cast<AML::Name*>(s5_evaluated.ptr())->object;
|
||||
break;
|
||||
default:
|
||||
done = true;
|
||||
break;
|
||||
}
|
||||
if (done)
|
||||
break;
|
||||
}
|
||||
auto s5_evaluated = s5_object->to_underlying();
|
||||
if (!s5_evaluated)
|
||||
{
|
||||
dwarnln("Failed to evaluate \\_S5");
|
||||
|
|
|
@ -159,7 +159,6 @@ namespace Kernel::ACPI
|
|||
LockGuard _(m_object_mutex);
|
||||
|
||||
ASSERT(!object_path.path.empty());
|
||||
ASSERT(object_path.path.back() == object->name);
|
||||
|
||||
auto canonical_path = resolve_path(parse_context.scope, object_path, FindMode::ForceAbsolute, false);
|
||||
ASSERT(canonical_path.has_value());
|
||||
|
|
|
@ -93,6 +93,8 @@ namespace Kernel::ACPI
|
|||
auto result_integer = result.value()
|
||||
? result.value()->convert(AML::Node::ConvInteger)
|
||||
: BAN::RefPtr<AML::Node>();
|
||||
if (!result_integer)
|
||||
return {};
|
||||
return static_cast<AML::Integer*>(result_integer.ptr());
|
||||
}
|
||||
|
||||
|
|
|
@ -277,6 +277,7 @@ namespace Kernel
|
|||
memcpy(PageTable::fast_page_as_ptr(), g_ap_init_addr, PAGE_SIZE);
|
||||
});
|
||||
|
||||
uint8_t initialized_aps = 0;
|
||||
for (auto& processor : m_processors)
|
||||
{
|
||||
if (processor.apic_id == bsp_id)
|
||||
|
@ -339,15 +340,17 @@ namespace Kernel
|
|||
udelay(100);
|
||||
}
|
||||
});
|
||||
|
||||
initialized_aps++;
|
||||
}
|
||||
|
||||
__atomic_store_n(&g_ap_startup_done[0], 1, __ATOMIC_SEQ_CST);
|
||||
|
||||
const size_t timeout_ms = SystemTimer::get().ms_since_boot() + 500;
|
||||
while (__atomic_load_n(&g_ap_running_count[0], __ATOMIC_SEQ_CST) < m_processors.size() - 1)
|
||||
while (__atomic_load_n(&g_ap_running_count[0], __ATOMIC_SEQ_CST) < initialized_aps)
|
||||
{
|
||||
if (SystemTimer::get().ms_since_boot() >= timeout_ms)
|
||||
Kernel::panic("Could not start all processors");
|
||||
Kernel::panic("Could not start all APs ({}/{} started)", g_ap_running_count[0], initialized_aps);
|
||||
__builtin_ia32_pause();
|
||||
}
|
||||
|
||||
|
|
|
@ -37,6 +37,7 @@
|
|||
struct ParsedCommandLine
|
||||
{
|
||||
bool force_pic = false;
|
||||
bool disable_acpi = false;
|
||||
bool disable_serial = false;
|
||||
bool disable_smp = false;
|
||||
bool disable_usb = false;
|
||||
|
@ -82,6 +83,8 @@ static void parse_command_line()
|
|||
cmdline.disable_smp = true;
|
||||
else if (argument == "nousb")
|
||||
cmdline.disable_usb = true;
|
||||
else if (argument == "noacpi")
|
||||
cmdline.disable_acpi = true;
|
||||
else if (argument == "nodebug")
|
||||
g_disable_debug = true;
|
||||
else if (argument.starts_with("ps2="))
|
||||
|
@ -220,7 +223,7 @@ static void init2(void*)
|
|||
dprintln("USBManager initialized");
|
||||
}
|
||||
|
||||
if (ACPI::ACPI::get().enter_acpi_mode(InterruptController::get().is_using_apic()).is_error())
|
||||
if (!cmdline.disable_acpi && ACPI::ACPI::get().enter_acpi_mode(InterruptController::get().is_using_apic()).is_error())
|
||||
dprintln("Failed to enter ACPI mode");
|
||||
|
||||
DevFileSystem::get().initialize_device_updater();
|
||||
|
|
|
@ -13,6 +13,8 @@ setjmp:
|
|||
|
||||
ret
|
||||
|
||||
.size setjmp, . - setjmp
|
||||
|
||||
// void longjmp(jmp_buf env, int val)
|
||||
.global longjmp
|
||||
longjmp:
|
||||
|
@ -26,3 +28,5 @@ longjmp:
|
|||
movl 0(%edx), %esp
|
||||
movl 4(%edx), %ecx
|
||||
jmp *%ecx
|
||||
|
||||
.size longjmp, . - longjmp
|
||||
|
|
|
@ -10,6 +10,7 @@ setjmp:
|
|||
xorq %rax, %rax
|
||||
|
||||
ret
|
||||
.size setjmp, . - setjmp
|
||||
|
||||
// void longjmp(jmp_buf env, int val)
|
||||
.global longjmp
|
||||
|
@ -21,3 +22,4 @@ longjmp:
|
|||
movq 0(%rdi), %rsp
|
||||
movq 8(%rdi), %rcx
|
||||
jmp *%rcx
|
||||
.size longjmp, . - longjmp
|
||||
|
|
Loading…
Reference in New Issue