kernel/device_manager: Add a io_scheduler_roster KDL command.

This way, the list of I/O schedulers can actually be retrieved.
This commit is contained in:
Augustin Cavalier 2024-11-20 14:11:51 -05:00
parent e19a3418cb
commit 8f88247e04
2 changed files with 45 additions and 1 deletions

View File

@ -86,6 +86,43 @@ IOSchedulerRoster::NextID()
// #pragma mark - debug methods and initialization // #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 static int
dump_io_scheduler(int argc, char** argv) dump_io_scheduler(int argc, char** argv)
{ {
@ -175,6 +212,11 @@ IOSchedulerRoster::Init()
{ {
new(&sDefaultInstance) IOSchedulerRoster; new(&sDefaultInstance) IOSchedulerRoster;
add_debugger_command_etc("io_scheduler_roster", &dump_io_scheduler_roster,
"Dump an I/O scheduler roster",
"<scheduler-roster>\n"
"Dumps I/O scheduler roster at address <scheduler-roster>.\n"
"If unspecified, dump the default roster.\n", 0);
add_debugger_command_etc("io_scheduler", &dump_io_scheduler, add_debugger_command_etc("io_scheduler", &dump_io_scheduler,
"Dump an I/O scheduler", "Dump an I/O scheduler",
"<scheduler>\n" "<scheduler>\n"

View File

@ -25,7 +25,7 @@
typedef DoublyLinkedList<IOScheduler> IOSchedulerList; typedef DoublyLinkedList<IOScheduler> IOSchedulerList;
class IOSchedulerRoster { class IOSchedulerRoster final {
public: public:
static void Init(); static void Init();
static IOSchedulerRoster* Default() { return &sDefaultInstance; } static IOSchedulerRoster* Default() { return &sDefaultInstance; }
@ -48,6 +48,8 @@ public:
int32 NextID(); int32 NextID();
void Dump() const;
private: private:
IOSchedulerRoster(); IOSchedulerRoster();
~IOSchedulerRoster(); ~IOSchedulerRoster();