]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/Console/TerminalDxe/Terminal.c
MdeModulePkg TerminalDxe: Execute key notify func at TPL_CALLBACK
[mirror_edk2.git] / MdeModulePkg / Universal / Console / TerminalDxe / Terminal.c
index babb097e57895428e7dada89a275c1f2ca56d43f..a209bf3cacf8e729432c9677af42f5030ee5de94 100644 (file)
@@ -2,7 +2,7 @@
   Produces Simple Text Input Protocol, Simple Text Input Extended Protocol and\r
   Simple Text Output Protocol upon Serial IO Protocol.\r
 \r
-Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
@@ -75,12 +75,19 @@ TERMINAL_DEV  mTerminalDevTemplate = {
   NULL, // RawFifo\r
   NULL, // UnicodeFiFo\r
   NULL, // EfiKeyFiFo\r
+  NULL, // EfiKeyFiFoForNotify\r
 \r
   NULL, // ControllerNameTable\r
   NULL, // TimerEvent\r
   NULL, // TwoSecondTimeOut\r
   INPUT_STATE_DEFAULT,\r
   RESET_STATE_DEFAULT,\r
+  {\r
+      0,\r
+      0,\r
+      0\r
+  },\r
+  0,\r
   FALSE,\r
   {   // SimpleTextInputEx\r
     TerminalConInResetEx,\r
@@ -93,7 +100,8 @@ TERMINAL_DEV  mTerminalDevTemplate = {
   {   // NotifyList\r
     NULL,\r
     NULL,\r
-  }\r
+  },\r
+  NULL // KeyNotifyProcessEvent\r
 };\r
 \r
 TERMINAL_CONSOLE_MODE_DATA mTerminalConsoleModeData[] = {\r
@@ -252,14 +260,13 @@ BuildTerminalDevpath  (
   EFI_STATUS                        Status;\r
 \r
   TerminalDevicePath = NULL;\r
-  TerminalType = PCANSITYPE;\r
 \r
   //\r
   // Use the RemainingDevicePath to determine the terminal type\r
   //\r
   Node = (VENDOR_DEVICE_PATH *) RemainingDevicePath;\r
   if (Node == NULL) {\r
-    TerminalType = PCANSITYPE;\r
+    TerminalType = PcdGet8 (PcdDefaultTerminalType);\r
 \r
   } else if (CompareGuid (&Node->Guid, &gEfiPcAnsiGuid)) {\r
 \r
@@ -539,7 +546,6 @@ TerminalDriverBindingStart (
   EFI_SERIAL_IO_PROTOCOL              *SerialIo;\r
   EFI_DEVICE_PATH_PROTOCOL            *ParentDevicePath;\r
   VENDOR_DEVICE_PATH                  *Node;\r
-  VENDOR_DEVICE_PATH                  *DefaultNode;\r
   EFI_SERIAL_IO_MODE                  *Mode;\r
   UINTN                               SerialInTimeOut;\r
   TERMINAL_DEV                        *TerminalDevice;\r
@@ -559,10 +565,9 @@ TerminalDriverBindingStart (
   UINTN                               ModeCount;\r
 \r
   TerminalDevice     = NULL;\r
-  DefaultNode        = NULL;\r
-  ConInSelected       = FALSE;\r
-  ConOutSelected      = FALSE;\r
-  NullRemaining      = TRUE;\r
+  ConInSelected      = FALSE;\r
+  ConOutSelected     = FALSE;\r
+  NullRemaining      = FALSE;\r
   SimTxtInInstalled  = FALSE;\r
   SimTxtOutInstalled = FALSE;\r
   FirstEnter         = FALSE;\r
@@ -675,7 +680,7 @@ TerminalDriverBindingStart (
   //\r
   if (FirstEnter) {\r
     //\r
-    // First enther the start funciton\r
+    // First enther the start function\r
     //\r
     FirstEnter = FALSE;\r
     //\r
@@ -703,23 +708,14 @@ TerminalDriverBindingStart (
     }\r
 \r
     //\r
-    // If RemainingDevicePath is NULL, then create default device path node\r
+    // If RemainingDevicePath is NULL, use default terminal type\r
     //\r
     if (RemainingDevicePath == NULL) {\r
-      DefaultNode = AllocateZeroPool (sizeof (VENDOR_DEVICE_PATH));\r
-      if (DefaultNode == NULL) {\r
-        Status = EFI_OUT_OF_RESOURCES;\r
-        goto Error;\r
-      }\r
-\r
       TerminalType = PcdGet8 (PcdDefaultTerminalType);\r
       //\r
       // Must be between PCANSITYPE (0) and TTYTERMTYPE (4)\r
       //\r
       ASSERT (TerminalType <= TTYTERMTYPE);\r
-\r
-      CopyMem (&DefaultNode->Guid, gTerminalType[TerminalType], sizeof (EFI_GUID));\r
-      RemainingDevicePath = (EFI_DEVICE_PATH_PROTOCOL *) DefaultNode;\r
     } else if (!IsDevicePathEnd (RemainingDevicePath)) {\r
       //\r
       // If RemainingDevicePath isn't the End of Device Path Node,\r
@@ -797,6 +793,10 @@ TerminalDriverBindingStart (
     if (TerminalDevice->EfiKeyFiFo == NULL) {\r
       goto Error;\r
     }\r
+    TerminalDevice->EfiKeyFiFoForNotify = AllocateZeroPool (sizeof (EFI_KEY_FIFO));\r
+    if (TerminalDevice->EfiKeyFiFoForNotify == NULL) {\r
+      goto Error;\r
+    }\r
 \r
     //\r
     // Set the timeout value of serial buffer for\r
@@ -1006,6 +1006,15 @@ TerminalDriverBindingStart (
                     );\r
     ASSERT_EFI_ERROR (Status);\r
 \r
+    Status = gBS->CreateEvent (\r
+                    EVT_NOTIFY_SIGNAL,\r
+                    TPL_CALLBACK,\r
+                    KeyNotifyProcessHandler,\r
+                    TerminalDevice,\r
+                    &TerminalDevice->KeyNotifyProcessEvent\r
+                    );\r
+    ASSERT_EFI_ERROR (Status);\r
+\r
     Status = gBS->InstallProtocolInterface (\r
                     &TerminalDevice->Handle,\r
                     &gEfiDevicePathProtocolGuid,\r
@@ -1177,9 +1186,6 @@ TerminalDriverBindingStart (
       goto Error;\r
     }\r
   }\r
-  if (DefaultNode != NULL) {\r
-    FreePool (DefaultNode);\r
-  }\r
 \r
   return EFI_SUCCESS;\r
 \r
@@ -1231,7 +1237,10 @@ Error:
       if (TerminalDevice->EfiKeyFiFo != NULL) {\r
         FreePool (TerminalDevice->EfiKeyFiFo);\r
       }\r
-\r
+      if (TerminalDevice->EfiKeyFiFoForNotify != NULL) {\r
+        FreePool (TerminalDevice->EfiKeyFiFoForNotify);\r
+      }\r
+  \r
       if (TerminalDevice->ControllerNameTable != NULL) {\r
         FreeUnicodeStringTable (TerminalDevice->ControllerNameTable);\r
       }\r
@@ -1248,10 +1257,6 @@ Error:
     }\r
   }\r
 \r
-  if (DefaultNode != NULL) {\r
-    FreePool (DefaultNode);\r
-  }\r
-\r
   This->Stop (This, Controller, 0, NULL);\r
 \r
   return Status;\r
@@ -1413,6 +1418,7 @@ TerminalDriverBindingStop (
         gBS->CloseEvent (TerminalDevice->TwoSecondTimeOut);\r
         gBS->CloseEvent (TerminalDevice->SimpleInput.WaitForKey);\r
         gBS->CloseEvent (TerminalDevice->SimpleInputEx.WaitForKeyEx);\r
+        gBS->CloseEvent (TerminalDevice->KeyNotifyProcessEvent);\r
         TerminalFreeNotifyList (&TerminalDevice->NotifyList);\r
         FreePool (TerminalDevice->DevicePath);\r
         if (TerminalDevice->TerminalConsoleModeData != NULL) {\r