mirror of
https://github.com/SerenityOS/serenity.git
synced 2026-11-07 04:29:30 -10:00
Utilities: Add a simple utility to test out LibACPI
This is a simple program meant to load a AML table and dump out the root namespace afterwards. Co-authored-by: RatcheT2497 <[email protected]>
This commit is contained in:
1 parent
95ab8a7e1a
commit
d5710bef80
2 files changed
+51
No files matched your search
@@ -1,6 +1,7 @@
|
||||
set(CMD_SOURCES_CPP
|
||||
abench.cpp
|
||||
aconv.cpp
|
||||
acpi.cpp
|
||||
adjtime.cpp
|
||||
allocate.cpp
|
||||
animation.cpp
|
||||
@@ -300,6 +301,7 @@ install(CODE "file(CREATE_LINK /usr/lib/Loader.so ${CMAKE_INSTALL_PREFIX}/bin/ld
|
||||
|
||||
target_link_libraries(abench PRIVATE LibAudio LibFileSystem)
|
||||
target_link_libraries(aconv PRIVATE LibAudio LibFileSystem)
|
||||
target_link_libraries(acpi PRIVATE LibACPI LibFileSystem LibMain)
|
||||
target_link_libraries(animation PRIVATE LibGfx)
|
||||
target_link_libraries(aplay PRIVATE LibAudio LibFileSystem LibIPC)
|
||||
target_link_libraries(asctl PRIVATE LibAudio LibIPC)
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright (c) 2025, RatcheT2497 <[email protected]>
|
||||
* Copyright (c) 2026, Undefine <[email protected]>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <AK/MemoryStream.h>
|
||||
#include <LibACPI/Interpreter.h>
|
||||
#include <LibACPI/TableStream.h>
|
||||
#include <LibCore/ArgsParser.h>
|
||||
#include <LibCore/MappedFile.h>
|
||||
#include <LibCore/System.h>
|
||||
#include <LibFileSystem/FileSystem.h>
|
||||
#include <LibMain/Main.h>
|
||||
|
||||
ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
{
|
||||
Vector<StringView> input_files;
|
||||
|
||||
Core::ArgsParser args_parser;
|
||||
args_parser.set_general_help("ACPI management utility.");
|
||||
args_parser.add_positional_argument(input_files, "Files containing AML table bytecode to load.", "input");
|
||||
args_parser.parse(arguments);
|
||||
|
||||
if (input_files.is_empty())
|
||||
return Error::from_string_literal("Input file is required, use '-' to read from standard input");
|
||||
|
||||
TRY(Core::System::pledge("stdio rpath"sv));
|
||||
|
||||
for (auto input : input_files)
|
||||
TRY(Core::System::unveil(TRY(FileSystem::absolute_path(input)), "r"sv));
|
||||
TRY(Core::System::unveil(nullptr, nullptr));
|
||||
|
||||
auto interpreter = TRY(ACPI::AML::Interpreter::create());
|
||||
for (auto input : input_files) {
|
||||
auto maybe_input_file = Core::MappedFile::map(input);
|
||||
if (maybe_input_file.is_error()) {
|
||||
warnln("Failed to open {}: {}", input, maybe_input_file.release_error());
|
||||
return 1;
|
||||
}
|
||||
|
||||
auto input_file = maybe_input_file.release_value();
|
||||
TRY(interpreter->load(input_file->bytes()));
|
||||
}
|
||||
|
||||
TRY(interpreter->print_namespace());
|
||||
return 0;
|
||||
}
|
||||
Reference in new issue
Block a user