kernel/device_manager: Move I/O scheduler debug dumpers into IOSchedulerRoster.

No behavioral change intended.
This commit is contained in:
Augustin Cavalier 2024-11-20 14:10:38 -05:00
parent 0edecdc00e
commit e19a3418cb
2 changed files with 114 additions and 110 deletions

View File

@ -1,5 +1,6 @@
/* /*
* Copyright 2009-2010, Ingo Weinhold, ingo_weinhold@gmx.de. * Copyright 2009-2010, Ingo Weinhold, ingo_weinhold@gmx.de.
* Copyright 2024, Haiku, Inc. All rights reserved.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
*/ */
@ -12,10 +13,20 @@
/*static*/ IOSchedulerRoster IOSchedulerRoster::sDefaultInstance; /*static*/ IOSchedulerRoster IOSchedulerRoster::sDefaultInstance;
/*static*/ void IOSchedulerRoster::IOSchedulerRoster()
IOSchedulerRoster::Init() :
fNextID(1),
fNotificationService("I/O")
{ {
new(&sDefaultInstance) IOSchedulerRoster; mutex_init(&fLock, "IOSchedulerRoster");
fNotificationService.Register();
}
IOSchedulerRoster::~IOSchedulerRoster()
{
mutex_destroy(&fLock);
fNotificationService.Unregister();
} }
@ -72,18 +83,109 @@ IOSchedulerRoster::NextID()
} }
IOSchedulerRoster::IOSchedulerRoster() // #pragma mark - debug methods and initialization
:
fNextID(1),
fNotificationService("I/O") static int
dump_io_scheduler(int argc, char** argv)
{ {
mutex_init(&fLock, "IOSchedulerRoster"); if (argc != 2) {
fNotificationService.Register(); print_debugger_command_usage(argv[0]);
return 0;
}
IOScheduler* scheduler = (IOScheduler*)parse_expression(argv[1]);
scheduler->Dump();
return 0;
} }
IOSchedulerRoster::~IOSchedulerRoster() static int
dump_io_request_owner(int argc, char** argv)
{ {
mutex_destroy(&fLock); if (argc != 2) {
fNotificationService.Unregister(); print_debugger_command_usage(argv[0]);
return 0;
}
IORequestOwner* owner = (IORequestOwner*)parse_expression(argv[1]);
owner->Dump();
return 0;
}
static int
dump_io_request(int argc, char** argv)
{
if (argc != 2 || !strcmp(argv[1], "--help")) {
kprintf("usage: %s <ptr-to-io-request>\n", argv[0]);
return 0;
}
IORequest* request = (IORequest*)parse_expression(argv[1]);
request->Dump();
return 0;
}
static int
dump_io_operation(int argc, char** argv)
{
if (argc != 2 || !strcmp(argv[1], "--help")) {
kprintf("usage: %s <ptr-to-io-operation>\n", argv[0]);
return 0;
}
IOOperation* operation = (IOOperation*)parse_expression(argv[1]);
operation->Dump();
return 0;
}
static int
dump_io_buffer(int argc, char** argv)
{
if (argc != 2 || !strcmp(argv[1], "--help")) {
kprintf("usage: %s <ptr-to-io-buffer>\n", argv[0]);
return 0;
}
IOBuffer* buffer = (IOBuffer*)parse_expression(argv[1]);
buffer->Dump();
return 0;
}
static int
dump_dma_buffer(int argc, char** argv)
{
if (argc != 2 || !strcmp(argv[1], "--help")) {
kprintf("usage: %s <ptr-to-dma-buffer>\n", argv[0]);
return 0;
}
DMABuffer* buffer = (DMABuffer*)parse_expression(argv[1]);
buffer->Dump();
return 0;
}
/*static*/ void
IOSchedulerRoster::Init()
{
new(&sDefaultInstance) IOSchedulerRoster;
add_debugger_command_etc("io_scheduler", &dump_io_scheduler,
"Dump an I/O scheduler",
"<scheduler>\n"
"Dumps I/O scheduler at address <scheduler>.\n", 0);
add_debugger_command_etc("io_request_owner", &dump_io_request_owner,
"Dump an I/O request owner",
"<owner>\n"
"Dumps I/O request owner at address <owner>.\n", 0);
add_debugger_command("io_request", &dump_io_request, "dump an I/O request");
add_debugger_command("io_operation", &dump_io_operation,
"dump an I/O operation");
add_debugger_command("io_buffer", &dump_io_buffer, "dump an I/O buffer");
add_debugger_command("dma_buffer", &dump_dma_buffer, "dump a DMA buffer");
} }

View File

@ -30,7 +30,6 @@
#include "AbstractModuleDevice.h" #include "AbstractModuleDevice.h"
#include "devfs_private.h" #include "devfs_private.h"
#include "id_generator.h" #include "id_generator.h"
#include "IORequest.h"
#include "io_resources.h" #include "io_resources.h"
#include "IOSchedulerRoster.h" #include "IOSchedulerRoster.h"
@ -290,90 +289,6 @@ dump_attribute(device_attr* attr, int32 level)
} }
static int
dump_io_scheduler(int argc, char** argv)
{
if (argc != 2) {
print_debugger_command_usage(argv[0]);
return 0;
}
IOScheduler* scheduler = (IOScheduler*)parse_expression(argv[1]);
scheduler->Dump();
return 0;
}
static int
dump_io_request_owner(int argc, char** argv)
{
if (argc != 2) {
print_debugger_command_usage(argv[0]);
return 0;
}
IORequestOwner* owner = (IORequestOwner*)parse_expression(argv[1]);
owner->Dump();
return 0;
}
static int
dump_io_request(int argc, char** argv)
{
if (argc != 2 || !strcmp(argv[1], "--help")) {
kprintf("usage: %s <ptr-to-io-request>\n", argv[0]);
return 0;
}
IORequest* request = (IORequest*)parse_expression(argv[1]);
request->Dump();
return 0;
}
static int
dump_io_operation(int argc, char** argv)
{
if (argc != 2 || !strcmp(argv[1], "--help")) {
kprintf("usage: %s <ptr-to-io-operation>\n", argv[0]);
return 0;
}
IOOperation* operation = (IOOperation*)parse_expression(argv[1]);
operation->Dump();
return 0;
}
static int
dump_io_buffer(int argc, char** argv)
{
if (argc != 2 || !strcmp(argv[1], "--help")) {
kprintf("usage: %s <ptr-to-io-buffer>\n", argv[0]);
return 0;
}
IOBuffer* buffer = (IOBuffer*)parse_expression(argv[1]);
buffer->Dump();
return 0;
}
static int
dump_dma_buffer(int argc, char** argv)
{
if (argc != 2 || !strcmp(argv[1], "--help")) {
kprintf("usage: %s <ptr-to-dma-buffer>\n", argv[0]);
return 0;
}
DMABuffer* buffer = (DMABuffer*)parse_expression(argv[1]);
buffer->Dump();
return 0;
}
static int static int
dump_device_nodes(int argc, char** argv) dump_device_nodes(int argc, char** argv)
{ {
@ -2466,19 +2381,6 @@ device_manager_init(struct kernel_args* args)
add_debugger_command("dm_tree", &dump_device_nodes, add_debugger_command("dm_tree", &dump_device_nodes,
"dump device node tree"); "dump device node tree");
add_debugger_command_etc("io_scheduler", &dump_io_scheduler,
"Dump an I/O scheduler",
"<scheduler>\n"
"Dumps I/O scheduler at address <scheduler>.\n", 0);
add_debugger_command_etc("io_request_owner", &dump_io_request_owner,
"Dump an I/O request owner",
"<owner>\n"
"Dumps I/O request owner at address <owner>.\n", 0);
add_debugger_command("io_request", &dump_io_request, "dump an I/O request");
add_debugger_command("io_operation", &dump_io_operation,
"dump an I/O operation");
add_debugger_command("io_buffer", &dump_io_buffer, "dump an I/O buffer");
add_debugger_command("dma_buffer", &dump_dma_buffer, "dump a DMA buffer");
init_node_tree(); init_node_tree();