X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=KernelLand%2FKernel%2Fdrv%2Fserial.c;h=df13fc73e11b6f3e25572fa0d49df9f459922437;hb=5cab4c07bc13888dc7956194ef9595508072a4eb;hp=08fb6786ec96dddc46c6490b22f56b04db30fbdd;hpb=3fadd995d8e8c0d266f577c69999619445f0100c;p=tpg%2Facess2.git diff --git a/KernelLand/Kernel/drv/serial.c b/KernelLand/Kernel/drv/serial.c index 08fb6786..df13fc73 100644 --- a/KernelLand/Kernel/drv/serial.c +++ b/KernelLand/Kernel/drv/serial.c @@ -5,11 +5,15 @@ * drv/serial.c * - Common serial port code */ +#define DEBUG 0 #include #include #include #include #include +#include + +extern void Validate_VirtualMemoryUsage(void); // === TYPES === struct sSerialPort @@ -43,44 +47,56 @@ tSerialPort *Serial_CreatePort(tSerial_OutFcn output, void *handle) { tSerialPort *ret = malloc( sizeof(tSerialPort) ); // Automatically indexed - ret->PTY = PTY_Create("serial#", ret, Serial_int_PTYOutput, Serial_int_PTYSetDims, Serial_int_PTYSetArrib); - ret->OutputFcn = output; - ret->OutHandle = handle; - struct ptymode mode = { - .OutputMode = PTYBUFFMT_TEXT, - .InputMode = PTYIMODE_CANON|PTYIMODE_ECHO - }; struct ptydims dims = { .W = 80, .H = 25, .PW = 0, .PH = 0 }; - PTY_SetAttrib(ret->PTY, &dims, &mode, 0); + struct ptymode mode = { + .OutputMode = PTYBUFFMT_TEXT, + .InputMode = PTYIMODE_CANON|PTYIMODE_ECHO + }; + ret->PTY = PTY_Create("serial#", ret, + Serial_int_PTYOutput, Serial_int_PTYSetDims, Serial_int_PTYSetArrib, + &dims, &mode + ); + ret->OutputFcn = output; + ret->OutHandle = handle; return ret; } void Serial_ByteReceived(tSerialPort *Port, char Ch) { + LOG("Port=%p,Ch=%i", Port, Ch); if( !Port ) return ; if( Port == gSerial_KernelDebugPort ) { + static tDebugHook info; static int serial_debug_mode = 0; // Kernel serial debug hooks. - if( serial_debug_mode ) + if( serial_debug_mode == 2 ) { - switch(Ch) - { - case 'p': - Threads_Dump(); - break; - case 'h': - Heap_Dump(); - break; - case 'X'-'A'+1: + // Leave latched mode + if( Ch == '.' ) + serial_debug_mode = 0; + else + DebugHook_HandleInput(&info, 1, &Ch); + return ; + } + else if( serial_debug_mode ) + { + if( Ch == 'X'-'A'+1 ) { PTY_SendInput(Port->PTY, &Ch, 1); - break; + serial_debug_mode = 0; + } + else if( Ch == '~' ) { + // Enter latched mode + serial_debug_mode = 2; + } + else { + DebugHook_HandleInput(&info, 1, &Ch); + serial_debug_mode = 0; } - serial_debug_mode = 0; return ; } else if( Ch == 'X'-'A'+1 ) @@ -95,6 +111,7 @@ void Serial_ByteReceived(tSerialPort *Port, char Ch) } if( Ch == '\r' ) Ch = '\n'; + LOG("Dispatch to PTY"); PTY_SendInput(Port->PTY, &Ch, 1); }