From b3b28b8b156b1cab2303ddeee4e966d791a12052 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Wed, 6 Feb 2019 10:29:35 +0100 Subject: [PATCH] Kernel: Add /proc/pci so we can see what's on the PCI bus. --- Kernel/ProcFS.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/Kernel/ProcFS.cpp b/Kernel/ProcFS.cpp index 1f17042154..e80b61a18d 100644 --- a/Kernel/ProcFS.cpp +++ b/Kernel/ProcFS.cpp @@ -8,6 +8,7 @@ #include "KSyms.h" #include "Console.h" #include "Scheduler.h" +#include #include #include @@ -33,6 +34,7 @@ enum ProcFileType { FI_Root_cpuinfo, FI_Root_inodes, FI_Root_dmesg, + FI_Root_pci, FI_Root_self, // symlink FI_Root_sys, // directory __FI_Root_End, @@ -204,9 +206,6 @@ ByteBuffer procfs$pid_fd_entry(InodeIdentifier identifier) ByteBuffer procfs$pid_vm(InodeIdentifier identifier) { -#ifdef PROCFS_DEBUG - dbgprintf("pid_vm: pid=%d\n", to_pid(identifier)); -#endif auto handle = ProcessInspectionHandle::from_pid(to_pid(identifier)); if (!handle) return { }; @@ -224,6 +223,15 @@ ByteBuffer procfs$pid_vm(InodeIdentifier identifier) return builder.to_byte_buffer(); } +ByteBuffer procfs$pci(InodeIdentifier) +{ + StringBuilder builder; + PCI::enumerate_all([&builder] (PCI::Address address, PCI::ID id) { + builder.appendf("%b:%b.%b %w:%w\n", address.bus(), address.slot(), address.function(), id.vendor_id, id.device_id); + }); + return builder.to_byte_buffer(); +} + ByteBuffer procfs$pid_vmo(InodeIdentifier identifier) { auto handle = ProcessInspectionHandle::from_pid(to_pid(identifier)); @@ -1009,6 +1017,7 @@ ProcFS::ProcFS() m_entries[FI_Root_inodes] = { "inodes", FI_Root_inodes, procfs$inodes }; m_entries[FI_Root_dmesg] = { "dmesg", FI_Root_dmesg, procfs$dmesg }; m_entries[FI_Root_self] = { "self", FI_Root_self, procfs$self }; + m_entries[FI_Root_pci] = { "pci", FI_Root_pci, procfs$pci }; m_entries[FI_Root_sys] = { "sys", FI_Root_sys }; m_entries[FI_PID_vm] = { "vm", FI_PID_vm, procfs$pid_vm };