From 8f88247e04c71e1fe8079fe4a029c0556e88e314 Mon Sep 17 00:00:00 2001 From: Augustin Cavalier Date: Wed, 20 Nov 2024 14:11:51 -0500 Subject: [PATCH] kernel/device_manager: Add a io_scheduler_roster KDL command. This way, the list of I/O schedulers can actually be retrieved. --- .../device_manager/IOSchedulerRoster.cpp | 42 +++++++++++++++++++ .../kernel/device_manager/IOSchedulerRoster.h | 4 +- 2 files changed, 45 insertions(+), 1 deletion(-) diff --git a/src/system/kernel/device_manager/IOSchedulerRoster.cpp b/src/system/kernel/device_manager/IOSchedulerRoster.cpp index 751fe218c7..5d848cc864 100644 --- a/src/system/kernel/device_manager/IOSchedulerRoster.cpp +++ b/src/system/kernel/device_manager/IOSchedulerRoster.cpp @@ -86,6 +86,43 @@ IOSchedulerRoster::NextID() // #pragma mark - debug methods and initialization +void +IOSchedulerRoster::Dump() const +{ + kprintf("IOSchedulerRoster at %p\n", this); + kprintf(" mutex: %p\n", &fLock); + kprintf(" next ID: %" B_PRId32 "\n", fNextID); + + kprintf(" schedulers:"); + for (IOSchedulerList::ConstIterator it + = fSchedulers.GetIterator(); + IOScheduler* scheduler = it.Next();) { + kprintf(" %p", scheduler); + } + kprintf("\n"); +} + + +static int +dump_io_scheduler_roster(int argc, char** argv) +{ + IOSchedulerRoster* roster; + if (argc == 1) { + roster = IOSchedulerRoster::Default(); + } else if (argc == 2) { + roster = (IOSchedulerRoster*)parse_expression(argv[1]); + if (roster == NULL) + return -1; + } else { + print_debugger_command_usage(argv[0]); + return 0; + } + + roster->Dump(); + return 0; +} + + static int dump_io_scheduler(int argc, char** argv) { @@ -175,6 +212,11 @@ IOSchedulerRoster::Init() { new(&sDefaultInstance) IOSchedulerRoster; + add_debugger_command_etc("io_scheduler_roster", &dump_io_scheduler_roster, + "Dump an I/O scheduler roster", + "\n" + "Dumps I/O scheduler roster at address .\n" + "If unspecified, dump the default roster.\n", 0); add_debugger_command_etc("io_scheduler", &dump_io_scheduler, "Dump an I/O scheduler", "\n" diff --git a/src/system/kernel/device_manager/IOSchedulerRoster.h b/src/system/kernel/device_manager/IOSchedulerRoster.h index f43f9afc05..92eab12c09 100644 --- a/src/system/kernel/device_manager/IOSchedulerRoster.h +++ b/src/system/kernel/device_manager/IOSchedulerRoster.h @@ -25,7 +25,7 @@ typedef DoublyLinkedList IOSchedulerList; -class IOSchedulerRoster { +class IOSchedulerRoster final { public: static void Init(); static IOSchedulerRoster* Default() { return &sDefaultInstance; } @@ -48,6 +48,8 @@ public: int32 NextID(); + void Dump() const; + private: IOSchedulerRoster(); ~IOSchedulerRoster();