]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitter.c
Update consplitter driver to use dynamic PCD to set console output mode instead of...
[mirror_edk2.git] / MdeModulePkg / Universal / Console / ConSplitterDxe / ConSplitter.c
index 8c4395c3a77d6939aeff4f7e02f82c3e7a00bb1f..e189b7d5c98146f1880b4b3ddbb395fcea4aa321 100644 (file)
@@ -2686,9 +2686,13 @@ ConSplitterAddGraphicsOutputMode (
         //\r
         // This is the first Graphics Output device added\r
         //\r
-        CopyMem (CurrentGraphicsOutputMode, GraphicsOutput->Mode, sizeof (EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE));\r
+        CurrentGraphicsOutputMode->MaxMode = GraphicsOutput->Mode->MaxMode;\r
+        CurrentGraphicsOutputMode->Mode = GraphicsOutput->Mode->Mode;\r
         CopyMem (CurrentGraphicsOutputMode->Info, GraphicsOutput->Mode->Info, GraphicsOutput->Mode->SizeOfInfo);\r
-\r
+        CurrentGraphicsOutputMode->SizeOfInfo = GraphicsOutput->Mode->SizeOfInfo;\r
+        CurrentGraphicsOutputMode->FrameBufferBase = GraphicsOutput->Mode->FrameBufferBase;\r
+        CurrentGraphicsOutputMode->FrameBufferSize = GraphicsOutput->Mode->FrameBufferSize;\r
+  \r
         //\r
         // Allocate resource for the private mode buffer\r
         //\r
@@ -2914,7 +2918,6 @@ ConsplitterSetConsoleOutMode (
   UINTN                            MaxMode;\r
   EFI_STATUS                       Status;\r
   CONSOLE_OUT_MODE                 ModeInfo;\r
-  UINTN                            ModeInfoSize;\r
   EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL  *TextOut;\r
 \r
   PreferMode   = 0xFF;\r
@@ -2922,31 +2925,8 @@ ConsplitterSetConsoleOutMode (
   TextOut      = &Private->TextOut;\r
   MaxMode      = (UINTN) (TextOut->Mode->MaxMode);\r
 \r
-  ModeInfoSize = sizeof (CONSOLE_OUT_MODE);\r
-  Status = gRT->GetVariable (\r
-                   VARCONOUTMODE,\r
-                   &gEfiGenericPlatformVariableGuid,\r
-                   NULL,\r
-                   &ModeInfoSize,\r
-                   &ModeInfo\r
-                   );\r
-\r
-  if (EFI_ERROR(Status)) {\r
-    //\r
-    // If fail to get variable, set variable to the default mode 80 x 25\r
-    // required by UEFI spec;\r
-    //\r
-    ModeInfo.Column = 80;\r
-    ModeInfo.Row    = 25;\r
-\r
-    gRT->SetVariable (\r
-           VARCONOUTMODE,\r
-           &gEfiGenericPlatformVariableGuid,\r
-           EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_NON_VOLATILE,\r
-           sizeof (CONSOLE_OUT_MODE),\r
-           &ModeInfo\r
-           );\r
-  }\r
+  ModeInfo.Column = PcdGet32 (PcdConOutColumn);\r
+  ModeInfo.Row    = PcdGet32 (PcdConOutRow);\r
 \r
   //\r
   // To find the prefer mode and basic mode from Text Out mode list\r
@@ -2964,7 +2944,7 @@ ConsplitterSetConsoleOutMode (
   }\r
 \r
   //\r
-  // Set perfer mode to Text Out devices.\r
+  // Set prefer mode to Text Out devices.\r
   //\r
   Status = TextOut->SetMode (TextOut, PreferMode);\r
   if (EFI_ERROR(Status)) {\r
@@ -2973,20 +2953,9 @@ ConsplitterSetConsoleOutMode (
     //\r
     Status = TextOut->SetMode (TextOut, BaseMode);\r
     ASSERT(!EFI_ERROR(Status));\r
-\r
-    ModeInfo.Column = 80;\r
-    ModeInfo.Row    = 25;\r
-\r
-    //\r
-    // Update ConOutMode variable\r
-    //\r
-    gRT->SetVariable (\r
-           VARCONOUTMODE,\r
-           &gEfiGenericPlatformVariableGuid,\r
-           EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_NON_VOLATILE,\r
-           sizeof (CONSOLE_OUT_MODE),\r
-           &ModeInfo\r
-           );\r
+    \r
+    PcdSet32 (PcdConOutColumn, 80);\r
+    PcdSet32 (PcdConOutRow, 25);\r
   }\r
 \r
   return ;\r
@@ -3389,10 +3358,12 @@ ConSpliterConssoleControlStdInLocked (
 \r
 \r
 /**\r
-  This timer event will fire when StdIn is locked. It will check the key\r
-  sequence on StdIn to see if it matches the password. Any error in the\r
-  password will cause the check to reset. As long a mConIn.PasswordEnabled is\r
-  TRUE the StdIn splitter will not report any input.\r
+  Record and check key sequence on StdIn.\r
+\r
+  This timer event will fire when StdIn is locked. It will record the key sequence\r
+  on StdIn and also check to see if it matches the password. Any error in the\r
+  password will cause the check to reset. As long as a mConIn.PasswordEnabled is\r
+  TRUE, the StdIn splitter will not report any input.\r
 \r
   @param  Event                  The Event this notify function registered to.\r
   @param  Context                Pointer to the context data registerd to the\r
@@ -3414,11 +3385,14 @@ ConSpliterConsoleControlLockStdInEvent (
     Status = ConSplitterTextInPrivateReadKeyStroke (&mConIn, &Key);\r
     if (!EFI_ERROR (Status)) {\r
       //\r
-      // if it's an ENTER, match password\r
+      // If key read successfully\r
       //\r
       if ((Key.UnicodeChar == CHAR_CARRIAGE_RETURN) && (Key.ScanCode == SCAN_NULL)) {\r
+        //\r
+        // If it's an ENTER, match password\r
+        //\r
         mConIn.PwdAttempt[mConIn.PwdIndex] = CHAR_NULL;\r
-        if (StrCmp (mConIn.Password, mConIn.PwdAttempt)) {\r
+        if (StrCmp (mConIn.Password, mConIn.PwdAttempt) != 0) {\r
           //\r
           // Password not match\r
           //\r
@@ -3451,7 +3425,8 @@ ConSpliterConsoleControlLockStdInEvent (
         }\r
       } else if ((Key.ScanCode == SCAN_NULL) && (Key.UnicodeChar >= 32)) {\r
         //\r
-        // If it's not an ENTER, neigher a function key, nor a CTRL-X or ALT-X, record the input\r
+        // If it's not an ENTER, neigher a function key, nor a CTRL-X or ALT-X, record the input,\r
+        // value 32 stands for a Blank Space key.\r
         //\r
         if (mConIn.PwdIndex < (MAX_STD_IN_PASSWORD - 1)) {\r
           if (mConIn.PwdIndex == 0) {\r
@@ -3475,9 +3450,9 @@ ConSpliterConsoleControlLockStdInEvent (
   @param  This                     Console Control protocol pointer.\r
   @param  Password                 The password input.\r
 \r
-  @retval EFI_SUCCESS              Lock the StdIn device\r
-  @retval EFI_INVALID_PARAMETER    Password is NULL\r
-  @retval EFI_OUT_OF_RESOURCES     Buffer allocation to store the password fails\r
+  @retval EFI_SUCCESS              Lock the StdIn device.\r
+  @retval EFI_INVALID_PARAMETER    Password is NULL.\r
+  @retval EFI_OUT_OF_RESOURCES     Buffer allocation to store the password fails.\r
 \r
 **/\r
 EFI_STATUS\r
@@ -3503,7 +3478,10 @@ ConSpliterConsoleControlLockStdIn (
   StrCpy (mConIn.Password, Password);\r
   mConIn.PasswordEnabled  = TRUE;\r
   mConIn.PwdIndex         = 0;\r
-  gBS->SetTimer (mConIn.LockEvent, TimerPeriodic, (10000 * 25));\r
+  //\r
+  // Lock Timer Periodic is 25ms.\r
+  //\r
+  gBS->SetTimer (mConIn.LockEvent, TimerPeriodic, 10000 * 25);\r
 \r
   return EFI_SUCCESS;\r
 }\r
@@ -3547,7 +3525,8 @@ ConSplitterTextInReadKeyStroke (
 \r
 \r
 /**\r
-  This event agregates all the events of the ConIn devices in the spliter.\r
+  This event aggregates all the events of the ConIn devices in the spliter.\r
+\r
   If the ConIn is password locked then return.\r
   If any events of physical ConIn devices are signaled, signal the ConIn\r
   spliter event. This will cause the calling code to call\r
@@ -3569,6 +3548,7 @@ ConSplitterTextInWaitForKey (
   UINTN                         Index;\r
 \r
   Private = (TEXT_IN_SPLITTER_PRIVATE_DATA *) Context;\r
+\r
   if (Private->PasswordEnabled) {\r
     //\r
     // If StdIn Locked return not ready\r
@@ -3576,15 +3556,16 @@ ConSplitterTextInWaitForKey (
     return ;\r
   }\r
 \r
-  //\r
-  // if KeyEventSignalState is flagged before, and not cleared by Reset() or ReadKeyStroke()\r
-  //\r
   if (Private->KeyEventSignalState) {\r
+    //\r
+    // If KeyEventSignalState is flagged before, and not cleared by Reset() or ReadKeyStroke()\r
+    //\r
     gBS->SignalEvent (Event);\r
     return ;\r
   }\r
+\r
   //\r
-  // if any physical console input device has key input, signal the event.\r
+  // If any physical console input device has key input, signal the event.\r
   //\r
   for (Index = 0; Index < Private->CurrentNumberOfConsoles; Index++) {\r
     Status = gBS->CheckEvent (Private->TextInList[Index]->WaitForKey);\r
@@ -3819,7 +3800,7 @@ ConSplitterTextInSetState (
                                    successfully.\r
   @retval EFI_OUT_OF_RESOURCES     Unable to allocate resources for necesssary data\r
                                    structures.\r
-  @retval EFI_INVALID_PARAMETER    KeyData or NotifyHandle is NULL.\r
+  @retval EFI_INVALID_PARAMETER    KeyData or KeyNotificationFunction or NotifyHandle is NULL.\r
 \r
 **/\r
 EFI_STATUS\r
@@ -3846,7 +3827,7 @@ ConSplitterTextInRegisterKeyNotify (
   Private = TEXT_IN_EX_SPLITTER_PRIVATE_DATA_FROM_THIS (This);\r
 \r
   //\r
-  // if no physical console input device exists,\r
+  // If no physical console input device exists,\r
   // return EFI_SUCCESS directly.\r
   //\r
   if (Private->CurrentNumberOfExConsoles <= 0) {\r