+ if( Port == gSerial_KernelDebugPort )
+ {
+ static tDebugHook info;
+ static int serial_debug_mode = 0;
+ // Kernel serial debug hooks.
+ if( serial_debug_mode == 2 )
+ {
+ // 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);
+ serial_debug_mode = 0;
+ }
+ else if( Ch == '~' ) {
+ // Enter latched mode
+ serial_debug_mode = 2;
+ }
+ else {
+ DebugHook_HandleInput(&info, 1, &Ch);
+ serial_debug_mode = 0;
+ }
+ return ;
+ }
+ else if( Ch == 'X'-'A'+1 )
+ {
+ serial_debug_mode = 1;
+ return ;
+ }
+ else
+ {
+ // Fall
+ }
+ }