lsirq.cpp 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. /*
  2. * Copyright (c) 2020, Liav A. <liavalb@hotmail.co.il>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #include <AK/JsonArray.h>
  7. #include <AK/JsonObject.h>
  8. #include <LibCore/File.h>
  9. #include <LibCore/System.h>
  10. #include <LibMain/Main.h>
  11. ErrorOr<int> serenity_main(Main::Arguments)
  12. {
  13. TRY(Core::System::pledge("stdio rpath"));
  14. TRY(Core::System::unveil("/sys/kernel/interrupts", "r"));
  15. TRY(Core::System::unveil(nullptr, nullptr));
  16. auto proc_interrupts = TRY(Core::File::open("/sys/kernel/interrupts", Core::OpenMode::ReadOnly));
  17. TRY(Core::System::pledge("stdio"));
  18. outln(" CPU0");
  19. auto file_contents = proc_interrupts->read_all();
  20. auto json = TRY(JsonValue::from_string(file_contents));
  21. json.as_array().for_each([](auto& value) {
  22. auto& handler = value.as_object();
  23. auto purpose = handler.get("purpose"sv).to_string();
  24. auto interrupt = handler.get("interrupt_line"sv).to_string();
  25. auto controller = handler.get("controller"sv).to_string();
  26. auto call_count = handler.get("call_count"sv).to_string();
  27. outln("{:>4}: {:10} {:10} {:30}", interrupt, call_count, controller, purpose);
  28. });
  29. return 0;
  30. }