2020-02-22 20:52:54 +02:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2020, Liav A. <liavalb@hotmail.co.il>
|
|
|
|
*
|
2021-04-22 01:24:48 -07:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-02-22 20:52:54 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <AK/JsonArray.h>
|
|
|
|
#include <AK/JsonObject.h>
|
|
|
|
#include <LibCore/File.h>
|
2022-01-20 15:42:33 +01:00
|
|
|
#include <LibCore/System.h>
|
|
|
|
#include <LibMain/Main.h>
|
2020-02-22 20:52:54 +02:00
|
|
|
|
2022-01-20 15:42:33 +01:00
|
|
|
ErrorOr<int> serenity_main(Main::Arguments)
|
2020-02-22 20:52:54 +02:00
|
|
|
{
|
2022-01-20 15:42:33 +01:00
|
|
|
TRY(Core::System::pledge("stdio rpath"));
|
2022-10-14 21:56:19 +03:00
|
|
|
TRY(Core::System::unveil("/sys/kernel/interrupts", "r"));
|
2022-01-20 15:42:33 +01:00
|
|
|
TRY(Core::System::unveil(nullptr, nullptr));
|
2020-02-22 20:52:54 +02:00
|
|
|
|
2022-10-14 21:56:19 +03:00
|
|
|
auto proc_interrupts = TRY(Core::File::open("/sys/kernel/interrupts", Core::OpenMode::ReadOnly));
|
2020-02-22 20:52:54 +02:00
|
|
|
|
2022-01-20 15:42:33 +01:00
|
|
|
TRY(Core::System::pledge("stdio"));
|
2020-02-22 20:52:54 +02:00
|
|
|
|
2021-05-31 15:43:25 +01:00
|
|
|
outln(" CPU0");
|
2020-02-22 20:52:54 +02:00
|
|
|
auto file_contents = proc_interrupts->read_all();
|
2022-01-20 15:42:33 +01:00
|
|
|
auto json = TRY(JsonValue::from_string(file_contents));
|
2021-11-15 01:46:51 +01:00
|
|
|
json.as_array().for_each([](auto& value) {
|
2021-05-31 17:59:02 +01:00
|
|
|
auto& handler = value.as_object();
|
2022-07-11 17:32:29 +00:00
|
|
|
auto purpose = handler.get("purpose"sv).to_string();
|
|
|
|
auto interrupt = handler.get("interrupt_line"sv).to_string();
|
|
|
|
auto controller = handler.get("controller"sv).to_string();
|
|
|
|
auto call_count = handler.get("call_count"sv).to_string();
|
2020-02-22 20:52:54 +02:00
|
|
|
|
2021-05-31 15:43:25 +01:00
|
|
|
outln("{:>4}: {:10} {:10} {:30}", interrupt, call_count, controller, purpose);
|
2020-02-22 20:52:54 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|