1) Enable GraphicsConsole module to support a legacy platform which only produce...
authorqwang12 <qwang12@de2fecce-e211-0410-80a6-f3fac2684e05>
Wed, 20 Feb 2008 10:50:15 +0000 (10:50 +0000)
committerqwang12 <qwang12@de2fecce-e211-0410-80a6-f3fac2684e05>
Wed, 20 Feb 2008 10:50:15 +0000 (10:50 +0000)
2) Remove all references to EFI_SPECIFICATION_VERSION in *.c file as module in MdeModulePkg only support UEFI 2.1.

git-svn-id: https://edk2.tianocore.org/svn/edk2/trunk@4739 de2fecce-e211-0410-80a6-f3fac2684e05

edk2/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsole.c
edk2/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsoleDxe.inf

index 11d1c76..6a624af 100644 (file)
@@ -86,17 +86,12 @@ GRAPHICS_CONSOLE_DEV        mGraphicsConsoleDevTemplate = {
   (EFI_HII_HANDLE ) 0\r
 };\r
 \r
-#if (EFI_SPECIFICATION_VERSION >= 0x0002000A)\r
 EFI_HII_DATABASE_PROTOCOL   *mHiiDatabase;\r
 EFI_HII_FONT_PROTOCOL       *mHiiFont;\r
 BOOLEAN                     mFirstAccessFlag = TRUE;\r
 \r
 STATIC EFI_GUID             mFontPackageListGuid = {0xf5f219d3, 0x7006, 0x4648, 0xac, 0x8d, 0xd6, 0x1d, 0xfb, 0x7b, 0xc6, 0xad};\r
 \r
-#else\r
-EFI_HII_PROTOCOL            *mHii;\r
-#endif\r
-\r
 static CHAR16               mCrLfString[3] = { CHAR_CARRIAGE_RETURN, CHAR_LINEFEED, CHAR_NULL };\r
 \r
 static EFI_GRAPHICS_OUTPUT_BLT_PIXEL        mEfiColors[16] = {\r
@@ -697,8 +692,6 @@ EfiLocateHiiProtocol (
   UINTN       Size;\r
   EFI_STATUS  Status;\r
 \r
-#if (EFI_SPECIFICATION_VERSION >= 0x0002000A)\r
-\r
   //\r
   // There should only be one - so buffer size is this\r
   //\r
@@ -732,33 +725,6 @@ EfiLocateHiiProtocol (
                   (VOID **) &mHiiFont\r
                   );\r
   return Status;\r
-#else\r
-\r
-  //\r
-  // There should only be one - so buffer size is this\r
-  //\r
-  Size = sizeof (EFI_HANDLE);\r
-\r
-  Status = gBS->LocateHandle (\r
-                  ByProtocol,\r
-                  &gEfiHiiProtocolGuid,\r
-                  NULL,\r
-                  &Size,\r
-                  &Handle\r
-                  );\r
-\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  Status = gBS->HandleProtocol (\r
-                  Handle,\r
-                  &gEfiHiiProtocolGuid,\r
-                  &mHii\r
-                  );\r
-\r
-  return Status;\r
-#endif\r
 }\r
 \r
 //\r
@@ -1138,18 +1104,11 @@ GraphicsConsoleConOutTestString (
   EFI_STATUS            Status;\r
   UINT16                Count;\r
 \r
-#if (EFI_SPECIFICATION_VERSION >= 0x0002000A)\r
   EFI_IMAGE_OUTPUT      *Blt = NULL;\r
-#else\r
-  UINT16                GlyphWidth;\r
-  UINT32                GlyphStatus = 0;\r
-  GLYPH_UNION           *Glyph;  \r
-#endif\r
 \r
   Count = 0;\r
 \r
   while (WString[Count] != 0) {\r
-#if (EFI_SPECIFICATION_VERSION >= 0x0002000A)\r
     Status = mHiiFont->GetGlyph (\r
                          mHiiFont,\r
                          WString[Count],\r
@@ -1160,16 +1119,7 @@ GraphicsConsoleConOutTestString (
     SafeFreePool (Blt);\r
     Blt = NULL;\r
     Count++;\r
-#else\r
-    Status = mHii->GetGlyph (\r
-                    mHii,\r
-                    WString,\r
-                    &Count,\r
-                    (UINT8 **) &Glyph,\r
-                    &GlyphWidth,\r
-                    &GlyphStatus\r
-                    );\r
-#endif\r
+\r
     if (EFI_ERROR (Status)) {\r
       return EFI_UNSUPPORTED;\r
     }\r
@@ -1716,7 +1666,6 @@ GetTextColors (
   return EFI_SUCCESS;\r
 }\r
 \r
-#if (EFI_SPECIFICATION_VERSION >= 0x0002000A)\r
 EFI_STATUS\r
 DrawUnicodeWeightAtCursorN (\r
   IN  EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL  *This,\r
@@ -1729,13 +1678,11 @@ DrawUnicodeWeightAtCursorN (
   EFI_IMAGE_OUTPUT                  *Blt;\r
   EFI_STRING                        String;\r
   EFI_FONT_DISPLAY_INFO             *FontInfo;\r
+  EFI_UGA_DRAW_PROTOCOL             *UgaDraw;\r
+  EFI_HII_ROW_INFO                  *RowInfoArray;\r
+  UINTN                             RowInfoArraySize;\r
 \r
   Private = GRAPHICS_CONSOLE_CON_OUT_DEV_FROM_THIS (This);\r
-  //\r
-  // GOP protocol is required in UEFI mode.\r
-  //\r
-  ASSERT (Private->GraphicsOutput != NULL);\r
-\r
   Blt = (EFI_IMAGE_OUTPUT *) AllocateZeroPool (sizeof (EFI_IMAGE_OUTPUT));\r
   if (Blt == NULL) {\r
     return EFI_OUT_OF_RESOURCES;\r
@@ -1743,7 +1690,6 @@ DrawUnicodeWeightAtCursorN (
 \r
   Blt->Width        = (UINT16) (Private->ModeData[This->Mode->Mode].GopWidth);\r
   Blt->Height       = (UINT16) (Private->ModeData[This->Mode->Mode].GopHeight);\r
-  Blt->Image.Screen = Private->GraphicsOutput;\r
 \r
   String = AllocateCopyPool ((Count + 1) * sizeof (CHAR16), UnicodeWeight);\r
   if (String == NULL) {\r
@@ -1760,166 +1706,83 @@ DrawUnicodeWeightAtCursorN (
   }\r
   GetTextColors (This, &FontInfo->ForegroundColor, &FontInfo->BackgroundColor);\r
 \r
-  Status = mHiiFont->StringToImage (\r
-                       mHiiFont,\r
-                       EFI_HII_IGNORE_IF_NO_GLYPH | EFI_HII_DIRECT_TO_SCREEN,\r
-                       String,\r
-                       FontInfo,\r
-                       &Blt,\r
-                       This->Mode->CursorColumn * GLYPH_WIDTH + Private->ModeData[This->Mode->Mode].DeltaX,\r
-                       This->Mode->CursorRow * GLYPH_HEIGHT + Private->ModeData[This->Mode->Mode].DeltaY,\r
-                       NULL,\r
-                       NULL,\r
-                       NULL\r
-                       );\r
-\r
-  SafeFreePool (Blt);\r
-  SafeFreePool (String);\r
-  SafeFreePool (FontInfo);\r
-  return Status;\r
-}\r
-#else\r
-STATIC\r
-EFI_STATUS\r
-DrawUnicodeWeightAtCursorN (\r
-  IN  EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL  *This,\r
-  IN  CHAR16                           *UnicodeWeight,\r
-  IN  UINTN                            Count\r
-  )\r
-{\r
-  GRAPHICS_CONSOLE_DEV  *Private;\r
-  EFI_STATUS            Status;\r
-  EFI_STATUS            ReturnStatus;\r
-  GLYPH_UNION           *Glyph;\r
-  GLYPH_UNION           GlyphData;\r
-  INTN                  GlyphX;\r
-  INTN                  GlyphY;\r
-  EFI_GRAPHICS_OUTPUT_PROTOCOL  *GraphicsOutput;\r
-  EFI_UGA_DRAW_PROTOCOL *UgaDraw;\r
-  EFI_GRAPHICS_OUTPUT_BLT_PIXEL Foreground;\r
-  EFI_GRAPHICS_OUTPUT_BLT_PIXEL Background;\r
-  UINTN                 Index;\r
-  UINTN                 ArrayIndex;\r
-  UINTN                 Counts;\r
-  UINT16                GlyphWidth;\r
-  UINT32                GlyphStatus;\r
-\r
-  Private       = GRAPHICS_CONSOLE_CON_OUT_DEV_FROM_THIS (This);\r
+  if (Private->GraphicsOutput != NULL) {\r
+    Blt->Image.Screen = Private->GraphicsOutput;\r
 \r
-  ReturnStatus  = EFI_SUCCESS;\r
-  GlyphStatus   = 0;\r
-  GlyphWidth    = 0x08;\r
+    Status = mHiiFont->StringToImage (\r
+                         mHiiFont,\r
+                         EFI_HII_IGNORE_IF_NO_GLYPH | EFI_HII_DIRECT_TO_SCREEN,\r
+                         String,\r
+                         FontInfo,\r
+                         &Blt,\r
+                         This->Mode->CursorColumn * GLYPH_WIDTH + Private->ModeData[This->Mode->Mode].DeltaX,\r
+                         This->Mode->CursorRow * GLYPH_HEIGHT + Private->ModeData[This->Mode->Mode].DeltaY,\r
+                         NULL,\r
+                         NULL,\r
+                         NULL\r
+                         );\r
 \r
-  GetTextColors (This, &Foreground, &Background);\r
+  } else {\r
+    ASSERT (Private->UgaDraw!= NULL);\r
 \r
-  Index       = 0;\r
-  ArrayIndex  = 0;\r
-  while (Index < Count) {\r
-    if (This->Mode->Attribute & EFI_WIDE_ATTRIBUTE) {\r
-      GlyphStatus = WIDE_CHAR;\r
-    } else {\r
-      GlyphStatus = NARROW_CHAR;\r
-    }\r
+    UgaDraw = Private->UgaDraw;\r
 \r
-    Status = mHii->GetGlyph (\r
-                    mHii,\r
-                    UnicodeWeight,\r
-                    (UINT16 *) &Index,\r
-                    (UINT8 **) &Glyph,\r
-                    &GlyphWidth,\r
-                    &GlyphStatus\r
-                    );\r
-    if (EFI_ERROR (Status)) {\r
-      ReturnStatus = Status;\r
+    Blt->Image.Bitmap = AllocateZeroPool (Blt->Width * Blt->Height * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL));\r
+    if (Blt->Image.Bitmap == NULL) {\r
+      SafeFreePool (Blt);\r
+      SafeFreePool (String);\r
+      return EFI_OUT_OF_RESOURCES;\r
     }\r
 \r
-    Counts = 0;\r
-\r
-    CopyMem (&GlyphData, Glyph, sizeof (GLYPH_UNION));\r
+    RowInfoArray = NULL;\r
+    //\r
+    //  StringToImage only support blt'ing image to device using GOP protocol. If GOP is not supported in this platform,\r
+    //  we ask StringToImage to print the string to blt buffer, then blt to device using UgaDraw.\r
+    //\r
+    Status = mHiiFont->StringToImage (\r
+                          mHiiFont,\r
+                          EFI_HII_IGNORE_IF_NO_GLYPH,\r
+                          String,\r
+                          FontInfo,\r
+                          &Blt,\r
+                          This->Mode->CursorColumn * GLYPH_WIDTH + Private->ModeData[This->Mode->Mode].DeltaX,\r
+                          This->Mode->CursorRow * GLYPH_HEIGHT + Private->ModeData[This->Mode->Mode].DeltaY,\r
+                          &RowInfoArray,\r
+                          &RowInfoArraySize,\r
+                          NULL\r
+                          );\r
 \r
-    do {\r
+    if (!EFI_ERROR (Status)) {\r
       //\r
-      // We are creating the second half of the wide character's BLT buffer\r
+      // Line breaks are handled by caller of DrawUnicodeWeightAtCursorN, so the updated parameter RowInfoArraySize by StringToImage will\r
+      // always be 1. ASSERT here to make sure.\r
       //\r
-      if (GlyphWidth == 0x10 && Counts == 1) {\r
-        CopyMem (&GlyphData.NarrowGlyph.GlyphCol1, &Glyph->WideGlyph.GlyphCol2, sizeof (Glyph->WideGlyph.GlyphCol2));\r
-      }\r
-\r
-      Counts++;\r
-\r
-      if (GlyphWidth == 0x10) {\r
-        mHii->GlyphToBlt (\r
-                mHii,\r
-                (UINT8 *) &GlyphData,\r
-                Foreground,\r
-                Background,\r
-                Count * 2,\r
-                GLYPH_WIDTH,\r
-                GLYPH_HEIGHT,\r
-                &Private->LineBuffer[ArrayIndex * GLYPH_WIDTH]\r
-                );\r
-      } else {\r
-        mHii->GlyphToBlt (\r
-                mHii,\r
-                (UINT8 *) &GlyphData,\r
-                Foreground,\r
-                Background,\r
-                Count,\r
-                GLYPH_WIDTH,\r
-                GLYPH_HEIGHT,\r
-                &Private->LineBuffer[ArrayIndex * GLYPH_WIDTH]\r
-                );\r
-      }\r
-\r
-      ArrayIndex++;\r
-\r
-    } while (Counts < 2 && GlyphWidth == 0x10);\r
+      ASSERT (RowInfoArraySize == 1);\r
+      \r
+      Status = UgaDraw->Blt (\r
+                          UgaDraw,\r
+                          (EFI_UGA_PIXEL *) Blt->Image.Bitmap,\r
+                          EfiUgaBltBufferToVideo,\r
+                          This->Mode->CursorColumn * GLYPH_WIDTH  + Private->ModeData[This->Mode->Mode].DeltaX,\r
+                          (This->Mode->CursorRow) * GLYPH_HEIGHT + Private->ModeData[This->Mode->Mode].DeltaY,\r
+                          This->Mode->CursorColumn * GLYPH_WIDTH  + Private->ModeData[This->Mode->Mode].DeltaX,\r
+                          (This->Mode->CursorRow) * GLYPH_HEIGHT + Private->ModeData[This->Mode->Mode].DeltaY,\r
+                          RowInfoArray[0].LineWidth,\r
+                          RowInfoArray[0].LineHeight,\r
+                          Blt->Width * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL)\r
+                          );\r
+    }\r
 \r
-  }\r
-  //\r
-  // If we are printing Wide characters, treat the BLT as if it is twice as many characters\r
-  //\r
-  if (GlyphWidth == 0x10) {\r
-    Count = Count * 2;\r
-  }\r
-  //\r
-  // Blt a character to the screen\r
-  //\r
-  GlyphX  = This->Mode->CursorColumn * GLYPH_WIDTH;\r
-  GlyphY  = This->Mode->CursorRow * GLYPH_HEIGHT;\r
-  GraphicsOutput = Private->GraphicsOutput;\r
-  UgaDraw = Private->UgaDraw;\r
-  if (GraphicsOutput != NULL) {\r
-    GraphicsOutput->Blt (\r
-              GraphicsOutput,\r
-              Private->LineBuffer,\r
-              EfiBltBufferToVideo,\r
-              0,\r
-              0,\r
-              GlyphX + Private->ModeData[This->Mode->Mode].DeltaX,\r
-              GlyphY + Private->ModeData[This->Mode->Mode].DeltaY,\r
-              GLYPH_WIDTH * Count,\r
-              GLYPH_HEIGHT,\r
-              GLYPH_WIDTH * Count * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL)\r
-              );\r
-  } else {\r
-    UgaDraw->Blt (\r
-              UgaDraw,\r
-              (EFI_UGA_PIXEL *) (UINTN) Private->LineBuffer,\r
-              EfiUgaBltBufferToVideo,\r
-              0,\r
-              0,\r
-              GlyphX + Private->ModeData[This->Mode->Mode].DeltaX,\r
-              GlyphY + Private->ModeData[This->Mode->Mode].DeltaY,\r
-              GLYPH_WIDTH * Count,\r
-              GLYPH_HEIGHT,\r
-              GLYPH_WIDTH * Count * sizeof (EFI_UGA_PIXEL)\r
-              );\r
+    SafeFreePool (RowInfoArray);\r
+    SafeFreePool (Blt->Image.Bitmap);\r
   }\r
 \r
-  return ReturnStatus;\r
+  SafeFreePool (Blt);\r
+  SafeFreePool (String);\r
+  SafeFreePool (FontInfo);\r
+  return Status;\r
 }\r
-#endif\r
+\r
 \r
 STATIC\r
 EFI_STATUS\r
@@ -2065,3 +1928,4 @@ InitializeGraphicsConsole (
   return Status;\r
 }\r
 \r
+\r
index 4ccfe21..4a07393 100644 (file)
@@ -44,7 +44,6 @@
   MdePkg/MdePkg.dec\r
   # currently use Hii for glyph lookup, need to change to UEFI scheme\r
   MdeModulePkg/MdeModulePkg.dec\r
-  IntelFrameworkPkg/IntelFrameworkPkg.dec\r
 \r
 [LibraryClasses]\r
   UefiBootServicesTableLib\r
@@ -62,4 +61,4 @@
   gEfiUgaDrawProtocolGuid                       # PROTOCOL TO_START\r
   gEfiHiiFontProtocolGuid\r
   gEfiHiiDatabaseProtocolGuid\r
-\r
+  
\ No newline at end of file