MdeModulePkg/TerminalDxe: Separate state machine start/stop logic

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Reviewed-by: Feng Tian <feng.tian@intel.com>
This commit is contained in:
Ruiyu Ni 2017-01-10 13:25:27 +08:00
parent 802c39b03b
commit b7cf1c0747

View File

@ -487,6 +487,63 @@ InitializeTerminalConsoleTextMode (
return TextModeData; return TextModeData;
} }
/**
Stop the terminal state machine.
@param TerminalDevice The terminal device.
**/
VOID
StopTerminalStateMachine (
TERMINAL_DEV *TerminalDevice
)
{
EFI_TPL OriginalTpl;
OriginalTpl = gBS->RaiseTPL (TPL_NOTIFY);
gBS->CloseEvent (TerminalDevice->TimerEvent);
gBS->CloseEvent (TerminalDevice->TwoSecondTimeOut);
gBS->RestoreTPL (OriginalTpl);
}
/**
Start the terminal state machine.
@param TerminalDevice The terminal device.
**/
VOID
StartTerminalStateMachine (
TERMINAL_DEV *TerminalDevice
)
{
EFI_STATUS Status;
Status = gBS->CreateEvent (
EVT_TIMER | EVT_NOTIFY_SIGNAL,
TPL_NOTIFY,
TerminalConInTimerHandler,
TerminalDevice,
&TerminalDevice->TimerEvent
);
ASSERT_EFI_ERROR (Status);
Status = gBS->SetTimer (
TerminalDevice->TimerEvent,
TimerPeriodic,
KEYBOARD_TIMER_INTERVAL
);
ASSERT_EFI_ERROR (Status);
Status = gBS->CreateEvent (
EVT_TIMER,
TPL_CALLBACK,
NULL,
NULL,
&TerminalDevice->TwoSecondTimeOut
);
ASSERT_EFI_ERROR (Status);
}
/** /**
Initialize the controller name table. Initialize the controller name table.
@ -893,30 +950,7 @@ TerminalDriverBindingStart (
goto ReportError; goto ReportError;
} }
Status = gBS->CreateEvent ( StartTerminalStateMachine (TerminalDevice);
EVT_TIMER | EVT_NOTIFY_SIGNAL,
TPL_NOTIFY,
TerminalConInTimerHandler,
TerminalDevice,
&TerminalDevice->TimerEvent
);
ASSERT_EFI_ERROR (Status);
Status = gBS->SetTimer (
TerminalDevice->TimerEvent,
TimerPeriodic,
KEYBOARD_TIMER_INTERVAL
);
ASSERT_EFI_ERROR (Status);
Status = gBS->CreateEvent (
EVT_TIMER,
TPL_CALLBACK,
NULL,
NULL,
&TerminalDevice->TwoSecondTimeOut
);
ASSERT_EFI_ERROR (Status);
Status = gBS->CreateEvent ( Status = gBS->CreateEvent (
EVT_NOTIFY_SIGNAL, EVT_NOTIFY_SIGNAL,
@ -1326,8 +1360,7 @@ TerminalDriverBindingStop (
FreeUnicodeStringTable (TerminalDevice->ControllerNameTable); FreeUnicodeStringTable (TerminalDevice->ControllerNameTable);
} }
gBS->CloseEvent (TerminalDevice->TimerEvent); StopTerminalStateMachine (TerminalDevice);
gBS->CloseEvent (TerminalDevice->TwoSecondTimeOut);
gBS->CloseEvent (TerminalDevice->SimpleInput.WaitForKey); gBS->CloseEvent (TerminalDevice->SimpleInput.WaitForKey);
gBS->CloseEvent (TerminalDevice->SimpleInputEx.WaitForKeyEx); gBS->CloseEvent (TerminalDevice->SimpleInputEx.WaitForKeyEx);
gBS->CloseEvent (TerminalDevice->KeyNotifyProcessEvent); gBS->CloseEvent (TerminalDevice->KeyNotifyProcessEvent);