From 80eea6cd8b7e37596ff09a888186e332270a4b80 Mon Sep 17 00:00:00 2001 From: Liav A Date: Sat, 22 Feb 2020 20:51:50 +0200 Subject: [PATCH] Kernel: Create an entry for viewing interrupts in ProcFS --- Kernel/FileSystem/ProcFS.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/Kernel/FileSystem/ProcFS.cpp b/Kernel/FileSystem/ProcFS.cpp index 5cc71e654cf..2bade10fb34 100644 --- a/Kernel/FileSystem/ProcFS.cpp +++ b/Kernel/FileSystem/ProcFS.cpp @@ -39,6 +39,8 @@ #include #include #include +#include +#include #include #include #include @@ -81,6 +83,7 @@ enum ProcFileType { FI_Root_cpuinfo, FI_Root_inodes, FI_Root_dmesg, + FI_Root_interrupts, FI_Root_pci, FI_Root_devices, FI_Root_uptime, @@ -339,6 +342,22 @@ Optional procfs$pci(InodeIdentifier) return builder.build(); } +Optional procfs$interrupts(InodeIdentifier) +{ + KBufferBuilder builder; + JsonArraySerializer array { builder }; + InterruptManagement::the().enumerate_interrupt_handlers([&array](GenericInterruptHandler& handler) { + auto obj = array.add_object(); + obj.add("purpose", "Interrupt Handler"); // FIXME: Determine the right description for each interrupt handler. + obj.add("interrupt_line", handler.interrupt_number()); + obj.add("cpu_handler", 0); // FIXME: Determine the responsible CPU for each interrupt handler. + obj.add("device_sharing", (unsigned)handler.get_sharing_devices_count()); + obj.add("call_count", (unsigned)handler.get_invoking_count()); + }); + array.finish(); + return builder.build(); +} + Optional procfs$devices(InodeIdentifier) { KBufferBuilder builder; @@ -1590,6 +1609,7 @@ ProcFS::ProcFS() m_entries[FI_Root_dmesg] = { "dmesg", FI_Root_dmesg, true, procfs$dmesg }; m_entries[FI_Root_self] = { "self", FI_Root_self, false, procfs$self }; m_entries[FI_Root_pci] = { "pci", FI_Root_pci, false, procfs$pci }; + m_entries[FI_Root_interrupts] = { "interrupts", FI_Root_interrupts, false, procfs$interrupts }; m_entries[FI_Root_devices] = { "devices", FI_Root_devices, false, procfs$devices }; m_entries[FI_Root_uptime] = { "uptime", FI_Root_uptime, false, procfs$uptime }; m_entries[FI_Root_cmdline] = { "cmdline", FI_Root_cmdline, true, procfs$cmdline };