summaryrefslogtreecommitdiffstats
path: root/MdeModulePkg
diff options
context:
space:
mode:
authorRuiyu Ni <ruiyu.ni@intel.com>2017-01-10 13:25:27 +0800
committerRuiyu Ni <ruiyu.ni@intel.com>2017-01-11 17:25:26 +0800
commitb7cf1c07479bbe5a3d5fd3c944b2ab76f740c072 (patch)
tree5ad62d855a875ab782c275d870cc3f2ad37871a6 /MdeModulePkg
parent802c39b03bdfddfea7c70545a9479d4418d5deaa (diff)
downloadedk2-b7cf1c07479bbe5a3d5fd3c944b2ab76f740c072.tar.gz
edk2-b7cf1c07479bbe5a3d5fd3c944b2ab76f740c072.tar.bz2
edk2-b7cf1c07479bbe5a3d5fd3c944b2ab76f740c072.zip
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>
Diffstat (limited to 'MdeModulePkg')
-rw-r--r--MdeModulePkg/Universal/Console/TerminalDxe/Terminal.c85
1 files changed, 59 insertions, 26 deletions
diff --git a/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.c b/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.c
index 129d7b3e60..b8dcf0c472 100644
--- a/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.c
+++ b/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.c
@@ -488,6 +488,63 @@ InitializeTerminalConsoleTextMode (
}
/**
+ 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.
@param TerminalType The terminal type.
@@ -893,30 +950,7 @@ TerminalDriverBindingStart (
goto ReportError;
}
- 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);
+ StartTerminalStateMachine (TerminalDevice);
Status = gBS->CreateEvent (
EVT_NOTIFY_SIGNAL,
@@ -1326,8 +1360,7 @@ TerminalDriverBindingStop (
FreeUnicodeStringTable (TerminalDevice->ControllerNameTable);
}
- gBS->CloseEvent (TerminalDevice->TimerEvent);
- gBS->CloseEvent (TerminalDevice->TwoSecondTimeOut);
+ StopTerminalStateMachine (TerminalDevice);
gBS->CloseEvent (TerminalDevice->SimpleInput.WaitForKey);
gBS->CloseEvent (TerminalDevice->SimpleInputEx.WaitForKeyEx);
gBS->CloseEvent (TerminalDevice->KeyNotifyProcessEvent);