]> git.proxmox.com Git - mirror_edk2.git/blobdiff - IntelFrameworkModulePkg/Library/GenericBdsLib/BdsConsole.c
revert the change on BdsConsole. when doing minimal boot, the ConsoleIn variable...
[mirror_edk2.git] / IntelFrameworkModulePkg / Library / GenericBdsLib / BdsConsole.c
index 6f3addb2f25cf6e5f13cca48a4b0bcf8b54cb956..ab7879def1fd01205ff7a9c40c2904ce5884dd46 100644 (file)
@@ -18,7 +18,8 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 /**\r
   Check if we need to save the EFI variable with "ConVarName" as name\r
   as NV type\r
-\r
+  If ConVarName is NULL, then ASSERT().\r
+  \r
   @param ConVarName The name of the EFI variable.\r
 \r
   @retval TRUE    Set the EFI variable as NV type.\r
@@ -31,6 +32,8 @@ IsNvNeed (
 {\r
   CHAR16 *Ptr;\r
 \r
+  ASSERT (ConVarName != NULL);\r
+  \r
   Ptr = ConVarName;\r
 \r
   //\r
@@ -41,6 +44,10 @@ IsNvNeed (
     Ptr++;\r
   }\r
 \r
+  if (((INTN)((UINTN)Ptr - (UINTN)ConVarName) / sizeof (CHAR16)) <= 3) {\r
+    return TRUE;\r
+  }\r
+  \r
   if ((*(Ptr - 3) == 'D') && (*(Ptr - 2) == 'e') && (*(Ptr - 1) == 'v')) {\r
     return FALSE;\r
   } else {\r
@@ -363,12 +370,12 @@ BdsLibConnectConsoleVariable (
       //\r
       // Check the Usb console in Usb2.0 bus firstly, then Usb1.1 bus\r
       //\r
-      Status = BdsLibConnectUsbDevByShortFormDP (PCI_CLASSC_PI_EHCI, Instance);\r
+      Status = BdsLibConnectUsbDevByShortFormDP (PCI_IF_EHCI, Instance);\r
       if (!EFI_ERROR (Status)) {\r
         DeviceExist = TRUE;\r
       }\r
 \r
-      Status = BdsLibConnectUsbDevByShortFormDP (PCI_CLASSC_PI_UHCI, Instance);\r
+      Status = BdsLibConnectUsbDevByShortFormDP (PCI_IF_UHCI, Instance);\r
       if (!EFI_ERROR (Status)) {\r
         DeviceExist = TRUE;\r
       }\r
@@ -587,7 +594,7 @@ ConvertBmpToGopBlt (
   BMP_COLOR_MAP                 *BmpColorMap;\r
   EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltBuffer;\r
   EFI_GRAPHICS_OUTPUT_BLT_PIXEL *Blt;\r
-  UINT                        BltBufferSize;\r
+  UINT64                        BltBufferSize;\r
   UINTN                         Index;\r
   UINTN                         Height;\r
   UINTN                         Width;\r
@@ -622,13 +629,21 @@ ConvertBmpToGopBlt (
   //\r
   // Calculate the BltBuffer needed size.\r
   //\r
-  BltBufferSize = BmpHeader->PixelWidth * BmpHeader->PixelHeight * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL);\r
+  BltBufferSize = MultU64x32 ((UINT64) BmpHeader->PixelWidth, BmpHeader->PixelHeight);\r
+  //\r
+  // Ensure the BltBufferSize * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL) doesn't overflow\r
+  //\r
+  if (BltBufferSize > DivU64x32 ((UINTN) ~0, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL))) {\r
+      return EFI_UNSUPPORTED;\r
+   }\r
+  BltBufferSize = MultU64x32 (BltBufferSize, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL));\r
+\r
   IsAllocated   = FALSE;\r
   if (*GopBlt == NULL) {\r
     //\r
     // GopBlt is not allocated by caller.\r
     //\r
-    *GopBltSize = BltBufferSize;\r
+    *GopBltSize = (UINTN) BltBufferSize;\r
     *GopBlt     = AllocatePool (*GopBltSize);\r
     IsAllocated = TRUE;\r
     if (*GopBlt == NULL) {\r
@@ -638,8 +653,8 @@ ConvertBmpToGopBlt (
     //\r
     // GopBlt has been allocated by caller.\r
     //\r
-    if (*GopBltSize < BltBufferSize) {\r
-      *GopBltSize = BltBufferSize;\r
+    if (*GopBltSize < (UINTN) BltBufferSize) {\r
+      *GopBltSize = (UINTN) BltBufferSize;\r
       return EFI_BUFFER_TOO_SMALL;\r
     }\r
   }\r
@@ -733,32 +748,9 @@ ConvertBmpToGopBlt (
   return EFI_SUCCESS;\r
 }\r
 \r
-\r
-/**\r
-  Use Console Control Protocol to lock the Console In Spliter virtual handle.\r
-  This is the ConInHandle and ConIn handle in the EFI system table. All key\r
-  presses will be ignored until the Password is typed in. The only way to\r
-  disable the password is to type it in to a ConIn device.\r
-\r
-  @param  Password        Password used to lock ConIn device.\r
-\r
-  @retval EFI_SUCCESS     lock the Console In Spliter virtual handle successfully.\r
-  @retval EFI_UNSUPPORTED Password not found\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-LockKeyboards (\r
-  IN  CHAR16    *Password\r
-  )\r
-{\r
-    return EFI_UNSUPPORTED;\r
-}\r
-\r
-\r
 /**\r
-  Use Console Control to turn off UGA based Simple Text Out consoles from going\r
-  to the UGA device. Put up LogoFile on every UGA device that is a console\r
+  Use SystemTable Conout to stop video based Simple Text Out consoles from going\r
+  to the video device. Put up LogoFile on every video device that is a console.\r
 \r
   @param[in]  LogoFile   File name of logo to display on the center of the screen.\r
 \r
@@ -998,8 +990,8 @@ EnableQuietBoot (
 }\r
 \r
 /**\r
-  Use Console Control to turn on UGA based Simple Text Out consoles. The UGA\r
-  Simple Text Out screens will now be synced up with all non UGA output devices\r
+  Use SystemTable Conout to turn on video based Simple Text Out consoles. The \r
+  Simple Text Out screens will now be synced up with all non video output devices\r
 \r
   @retval EFI_SUCCESS     UGA devices are back in text mode and synced up.\r
 \r