diff --git a/src/system/kernel/device_manager/IOSchedulerRoster.cpp b/src/system/kernel/device_manager/IOSchedulerRoster.cpp index 5724aa17b6..751fe218c7 100644 --- a/src/system/kernel/device_manager/IOSchedulerRoster.cpp +++ b/src/system/kernel/device_manager/IOSchedulerRoster.cpp @@ -1,5 +1,6 @@ /* * Copyright 2009-2010, Ingo Weinhold, ingo_weinhold@gmx.de. + * Copyright 2024, Haiku, Inc. All rights reserved. * Distributed under the terms of the MIT License. */ @@ -12,10 +13,20 @@ /*static*/ IOSchedulerRoster IOSchedulerRoster::sDefaultInstance; -/*static*/ void -IOSchedulerRoster::Init() +IOSchedulerRoster::IOSchedulerRoster() + : + 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() - : - fNextID(1), - fNotificationService("I/O") +// #pragma mark - debug methods and initialization + + +static int +dump_io_scheduler(int argc, char** argv) { - mutex_init(&fLock, "IOSchedulerRoster"); - fNotificationService.Register(); + if (argc != 2) { + 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); - fNotificationService.Unregister(); + 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 \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 \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 \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 \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", + "\n" + "Dumps I/O scheduler at address .\n", 0); + add_debugger_command_etc("io_request_owner", &dump_io_request_owner, + "Dump an I/O request owner", + "\n" + "Dumps I/O request owner at address .\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"); } diff --git a/src/system/kernel/device_manager/device_manager.cpp b/src/system/kernel/device_manager/device_manager.cpp index 3a577abeb8..72a855517d 100644 --- a/src/system/kernel/device_manager/device_manager.cpp +++ b/src/system/kernel/device_manager/device_manager.cpp @@ -30,7 +30,6 @@ #include "AbstractModuleDevice.h" #include "devfs_private.h" #include "id_generator.h" -#include "IORequest.h" #include "io_resources.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 \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 \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 \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 \n", argv[0]); - return 0; - } - - DMABuffer* buffer = (DMABuffer*)parse_expression(argv[1]); - buffer->Dump(); - return 0; -} - - static int 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, "dump device node tree"); - add_debugger_command_etc("io_scheduler", &dump_io_scheduler, - "Dump an I/O scheduler", - "\n" - "Dumps I/O scheduler at address .\n", 0); - add_debugger_command_etc("io_request_owner", &dump_io_request_owner, - "Dump an I/O request owner", - "\n" - "Dumps I/O request owner at address .\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();