diff options
author | Liav A <liavalb@gmail.com> | 2020-02-22 20:51:50 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-02-24 11:27:03 +0100 |
commit | 80eea6cd8b7e37596ff09a888186e332270a4b80 (patch) | |
tree | 0ec49dbdfe30c105ebf3a21f6d20ce135161605f | |
parent | e3b24d0478eb300081d3c8c80000f329ca207f6a (diff) | |
download | serenity-80eea6cd8b7e37596ff09a888186e332270a4b80.zip |
Kernel: Create an entry for viewing interrupts in ProcFS
-rw-r--r-- | Kernel/FileSystem/ProcFS.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/Kernel/FileSystem/ProcFS.cpp b/Kernel/FileSystem/ProcFS.cpp index 5cc71e654c..2bade10fb3 100644 --- a/Kernel/FileSystem/ProcFS.cpp +++ b/Kernel/FileSystem/ProcFS.cpp @@ -39,6 +39,8 @@ #include <Kernel/FileSystem/FileDescription.h> #include <Kernel/FileSystem/VirtualFileSystem.h> #include <Kernel/Heap/kmalloc.h> +#include <Kernel/Interrupts/GenericInterruptHandler.h> +#include <Kernel/Interrupts/InterruptManagement.h> #include <Kernel/KBufferBuilder.h> #include <Kernel/KParams.h> #include <Kernel/Module.h> @@ -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<KBuffer> procfs$pci(InodeIdentifier) return builder.build(); } +Optional<KBuffer> 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<KBuffer> 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 }; |