tty: move the "tty" KDL command to the generic tty module.
Currently I'm trying to debug things using the generic tty module, and I can't use the command from the driver for that. I hope someday the driver and module will use the same structure for the ttys and can share the same command... Change-Id: I167dab600ac8567368604f9b6463f787857f4d20 Reviewed-on: https://review.haiku-os.org/c/haiku/+/4602 Reviewed-by: Jérôme Duval <[email protected]>
This commit is contained in:
committed by
Adrien Destugues
parent
e7a62c420f
commit
3e9824f9ef
@@ -40,98 +40,6 @@ struct mutex gTTYCookieLock;
|
||||
struct recursive_lock gTTYRequestLock;
|
||||
|
||||
|
||||
static void
|
||||
dump_tty_settings(struct tty_settings& settings)
|
||||
{
|
||||
kprintf(" pgrp_id: %" B_PRId32 "\n", settings.pgrp_id);
|
||||
kprintf(" session_id: %" B_PRId32 "\n", settings.session_id);
|
||||
|
||||
kprintf(" termios:\n");
|
||||
kprintf(" c_iflag: 0x%08" B_PRIx32 "\n", settings.termios.c_iflag);
|
||||
kprintf(" c_oflag: 0x%08" B_PRIx32 "\n", settings.termios.c_oflag);
|
||||
kprintf(" c_cflag: 0x%08" B_PRIx32 "\n", settings.termios.c_cflag);
|
||||
kprintf(" c_lflag: 0x%08" B_PRIx32 "\n", settings.termios.c_lflag);
|
||||
kprintf(" c_line: %d\n", settings.termios.c_line);
|
||||
kprintf(" c_ispeed: %u\n", settings.termios.c_ispeed);
|
||||
kprintf(" c_ospeed: %u\n", settings.termios.c_ospeed);
|
||||
for (int i = 0; i < NCCS; i++)
|
||||
kprintf(" c_cc[%02d]: %d\n", i, settings.termios.c_cc[i]);
|
||||
|
||||
kprintf(" wsize: %u x %u c, %u x %u pxl\n",
|
||||
settings.window_size.ws_row, settings.window_size.ws_col,
|
||||
settings.window_size.ws_xpixel, settings.window_size.ws_ypixel);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
dump_tty_struct(struct tty& tty)
|
||||
{
|
||||
kprintf(" tty @: %p\n", &tty);
|
||||
kprintf(" index: %" B_PRId32 "\n", tty.index);
|
||||
kprintf(" is_master: %s\n", tty.is_master ? "true" : "false");
|
||||
kprintf(" open_count: %" B_PRId32 "\n", tty.open_count);
|
||||
kprintf(" select_pool: %p\n", tty.select_pool);
|
||||
kprintf(" pending_eof: %" B_PRIu32 "\n", tty.pending_eof);
|
||||
kprintf(" lock: %p\n", tty.lock);
|
||||
|
||||
kprintf(" input_buffer:\n");
|
||||
kprintf(" first: %" B_PRId32 "\n", tty.input_buffer.first);
|
||||
kprintf(" in: %lu\n", tty.input_buffer.in);
|
||||
kprintf(" size: %lu\n", tty.input_buffer.size);
|
||||
kprintf(" buffer: %p\n", tty.input_buffer.buffer);
|
||||
|
||||
kprintf(" reader queue:\n");
|
||||
tty.reader_queue.Dump(" ");
|
||||
kprintf(" writer queue:\n");
|
||||
tty.writer_queue.Dump(" ");
|
||||
|
||||
kprintf(" cookies: ");
|
||||
TTYCookieList::Iterator it = tty.cookies.GetIterator();
|
||||
while (tty_cookie* cookie = it.Next())
|
||||
kprintf(" %p", cookie);
|
||||
kprintf("\n");
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
dump_tty(int argc, char** argv)
|
||||
{
|
||||
if (argc < 2) {
|
||||
kprintf("Usage: %s <tty index>\n", argv[0]);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32 index = atol(argv[1]);
|
||||
if (index < 0 || index >= (int32)kNumTTYs) {
|
||||
kprintf("Invalid tty index.\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
kprintf("master:\n");
|
||||
dump_tty_struct(gMasterTTYs[index]);
|
||||
kprintf("slave:\n");
|
||||
dump_tty_struct(gSlaveTTYs[index]);
|
||||
kprintf("settings:\n");
|
||||
dump_tty_settings(sTTYSettings[index]);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
tty_add_debugger_commands()
|
||||
{
|
||||
add_debugger_command("tty", &dump_tty, "Dump info on a tty");
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
tty_remove_debugger_commands()
|
||||
{
|
||||
remove_debugger_command("tty", &dump_tty);
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
init_hardware(void)
|
||||
{
|
||||
@@ -194,8 +102,6 @@ init_driver(void)
|
||||
gDeviceNames[2 * kNumTTYs] = (char *)"ptmx";
|
||||
gDeviceNames[2 * kNumTTYs + 1] = (char *)"tty";
|
||||
|
||||
tty_add_debugger_commands();
|
||||
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
@@ -205,8 +111,6 @@ uninit_driver(void)
|
||||
{
|
||||
TRACE((DRIVER_NAME ": uninit_driver()\n"));
|
||||
|
||||
tty_remove_debugger_commands();
|
||||
|
||||
for (int32 i = 0; i < (int32)kNumTTYs * 2; i++)
|
||||
free(gDeviceNames[i]);
|
||||
|
||||
|
||||
@@ -21,6 +21,95 @@ struct mutex gTTYCookieLock;
|
||||
struct recursive_lock gTTYRequestLock;
|
||||
|
||||
|
||||
static void
|
||||
dump_tty_settings(struct tty_settings& settings)
|
||||
{
|
||||
kprintf(" pgrp_id: %" B_PRId32 "\n", settings.pgrp_id);
|
||||
kprintf(" session_id: %" B_PRId32 "\n", settings.session_id);
|
||||
|
||||
kprintf(" termios:\n");
|
||||
kprintf(" c_iflag: 0x%08" B_PRIx32 "\n", settings.termios.c_iflag);
|
||||
kprintf(" c_oflag: 0x%08" B_PRIx32 "\n", settings.termios.c_oflag);
|
||||
kprintf(" c_cflag: 0x%08" B_PRIx32 "\n", settings.termios.c_cflag);
|
||||
kprintf(" c_lflag: 0x%08" B_PRIx32 "\n", settings.termios.c_lflag);
|
||||
kprintf(" c_line: %d\n", settings.termios.c_line);
|
||||
kprintf(" c_ispeed: %u\n", settings.termios.c_ispeed);
|
||||
kprintf(" c_ospeed: %u\n", settings.termios.c_ospeed);
|
||||
for (int i = 0; i < NCCS; i++)
|
||||
kprintf(" c_cc[%02d]: %d\n", i, settings.termios.c_cc[i]);
|
||||
|
||||
kprintf(" wsize: %u x %u c, %u x %u pxl\n",
|
||||
settings.window_size.ws_row, settings.window_size.ws_col,
|
||||
settings.window_size.ws_xpixel, settings.window_size.ws_ypixel);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
dump_tty_struct(struct tty& tty)
|
||||
{
|
||||
kprintf(" tty @: %p\n", &tty);
|
||||
kprintf(" is_master: %s\n", tty.is_master ? "true" : "false");
|
||||
kprintf(" open_count: %" B_PRId32 "\n", tty.open_count);
|
||||
kprintf(" select_pool: %p\n", tty.select_pool);
|
||||
kprintf(" pending_eof: %" B_PRIu32 "\n", tty.pending_eof);
|
||||
|
||||
kprintf(" input_buffer:\n");
|
||||
kprintf(" first: %" B_PRId32 "\n", tty.input_buffer.first);
|
||||
kprintf(" in: %lu\n", tty.input_buffer.in);
|
||||
kprintf(" size: %lu\n", tty.input_buffer.size);
|
||||
kprintf(" buffer: %p\n", tty.input_buffer.buffer);
|
||||
|
||||
kprintf(" reader queue:\n");
|
||||
tty.reader_queue.Dump(" ");
|
||||
kprintf(" writer queue:\n");
|
||||
tty.writer_queue.Dump(" ");
|
||||
|
||||
dump_tty_settings(tty.settings);
|
||||
|
||||
kprintf(" cookies: ");
|
||||
TTYCookieList::Iterator it = tty.cookies.GetIterator();
|
||||
while (tty_cookie* cookie = it.Next())
|
||||
kprintf(" %p", cookie);
|
||||
kprintf("\n");
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
dump_tty(int argc, char** argv)
|
||||
{
|
||||
if (argc < 2) {
|
||||
kprintf("Usage: %s <tty address>\n", argv[0]);
|
||||
return 0;
|
||||
}
|
||||
|
||||
char* endpointer;
|
||||
uintptr_t index = strtoul(argv[1], &endpointer, 0);
|
||||
if (*endpointer != '\0') {
|
||||
kprintf("Invalid tty index.\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct tty* tty = (struct tty*)index;
|
||||
dump_tty_struct(*tty);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
tty_add_debugger_commands()
|
||||
{
|
||||
add_debugger_command("tty", &dump_tty, "Dump info on a tty");
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
tty_remove_debugger_commands()
|
||||
{
|
||||
remove_debugger_command("tty", &dump_tty);
|
||||
}
|
||||
|
||||
|
||||
static status_t
|
||||
init_tty_module()
|
||||
{
|
||||
@@ -33,6 +122,8 @@ init_tty_module()
|
||||
// create the cookie mutex
|
||||
mutex_init(&gTTYCookieLock, "tty cookies");
|
||||
|
||||
tty_add_debugger_commands();
|
||||
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
@@ -40,6 +131,8 @@ init_tty_module()
|
||||
static void
|
||||
uninit_tty_module()
|
||||
{
|
||||
tty_remove_debugger_commands();
|
||||
|
||||
recursive_lock_destroy(&gTTYRequestLock);
|
||||
mutex_destroy(&gTTYCookieLock);
|
||||
mutex_destroy(&gGlobalTTYLock);
|
||||
|
||||
Reference in New Issue
Block a user