1. Fixed bugs in DxeNetLib to meet consistence with network module DriverBinding...
authorvanjeff <vanjeff@6f19259b-4bc3-4df7-8a09-765794883524>
Thu, 17 Jan 2008 05:56:45 +0000 (05:56 +0000)
committervanjeff <vanjeff@6f19259b-4bc3-4df7-8a09-765794883524>
Thu, 17 Jan 2008 05:56:45 +0000 (05:56 +0000)
2. Sync bugs in console modules.
3. Sync bugs in PlatDriOverLib.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@4571 6f19259b-4bc3-4df7-8a09-765794883524

12 files changed:
MdeModulePkg/Include/Library/PlatDriOverLib.h
MdeModulePkg/Library/DxeNetLib/DxeNetLib.c
MdeModulePkg/Library/DxeNetLib/DxeNetLib.inf
MdeModulePkg/Library/DxePlatDriOverLib/PlatDriOverLib.c
MdeModulePkg/MdeModulePkg.dsc
MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitter.c
MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitterGraphics.c
MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsole.c
MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsole.h
MdeModulePkg/Universal/Console/TerminalDxe/Terminal.c
MdeModulePkg/Universal/Console/TerminalDxe/Terminal.h
MdeModulePkg/Universal/Console/TerminalDxe/TerminalConOut.c

index 8e6ab174d70fa5b1cd03fa37062ccd1cf2ef28c6..e6a6faf101ccecf03c5d033c1439b6615bdd0fc3 100644 (file)
@@ -24,6 +24,7 @@ Abstract:
 #include <PiDxe.h>
 #include <Protocol/PlatformDriverOverride.h>
 #include <Protocol/DevicePath.h>
+#include <Protocol/DriverBinding.h>
 #include <Library/BaseLib.h>
 
 #include <VariableFormat.h>
@@ -252,4 +253,19 @@ DeleteDriverImage (
   IN     LIST_ENTRY                                     *MappingDataBase
   );
 
+/**\r
+  Get the first Binding protocol which has the specific image handle\r
+\r
+  @param  Image          Image handle\r
+\r
+  @return Pointer into the Binding Protocol interface\r
+\r
+**/\r
+EFI_DRIVER_BINDING_PROTOCOL *\r
+EFIAPI\r
+GetBindingProtocolFromImageHandle (\r
+  IN  EFI_HANDLE   ImageHandle,\r
+  OUT EFI_HANDLE   *BindingHandle\r
+  );
+
 #endif
index f65489e7ed71b4c89ebaecfa06b1c2cc07629d60..ee8b6797e5dc4b11bd5abaafe986c0a1f656cac2 100644 (file)
@@ -25,6 +25,8 @@ Abstract:
 #include <Protocol/SimpleNetwork.h>\r
 #include <Protocol/LoadedImage.h>\r
 #include <Protocol/NicIp4Config.h>\r
+#include <Protocol/ComponentName.h>\r
+#include <Protocol/ComponentName2.h>\r
 \r
 #include <Library/NetLib.h>\r
 #include <Library/BaseLib.h>\r
@@ -842,8 +844,7 @@ NetLibDefaultUnload (
   UINTN                             Index;\r
   EFI_DRIVER_BINDING_PROTOCOL       *DriverBinding;\r
   EFI_COMPONENT_NAME_PROTOCOL       *ComponentName;\r
-  EFI_DRIVER_CONFIGURATION_PROTOCOL *DriverConfiguration;\r
-  EFI_DRIVER_DIAGNOSTICS_PROTOCOL   *DriverDiagnostics;\r
+  EFI_COMPONENT_NAME2_PROTOCOL      *ComponentName2;\r
 \r
   //\r
   // Get the list of all the handles in the handle database.\r
@@ -912,30 +913,15 @@ NetLibDefaultUnload (
 \r
     Status = gBS->HandleProtocol (\r
                     DeviceHandleBuffer[Index],\r
-                    &gEfiDriverConfigurationProtocolGuid,\r
-                    (VOID **) &DriverConfiguration\r
+                    &gEfiComponentName2ProtocolGuid,\r
+                    (VOID **) &ComponentName2\r
                     );\r
-\r
     if (!EFI_ERROR (Status)) {\r
       gBS->UninstallProtocolInterface (\r
-            ImageHandle,\r
-            &gEfiDriverConfigurationProtocolGuid,\r
-            DriverConfiguration\r
-            );\r
-    }\r
-\r
-    Status = gBS->HandleProtocol (\r
-                    DeviceHandleBuffer[Index],\r
-                    &gEfiDriverDiagnosticsProtocolGuid,\r
-                    (VOID **) &DriverDiagnostics\r
-                    );\r
-\r
-    if (!EFI_ERROR (Status)) {\r
-      gBS->UninstallProtocolInterface (\r
-            ImageHandle,\r
-            &gEfiDriverDiagnosticsProtocolGuid,\r
-            DriverDiagnostics\r
-            );\r
+             ImageHandle,\r
+             &gEfiComponentName2ProtocolGuid,\r
+             ComponentName2\r
+             );\r
     }\r
   }\r
 \r
index deb89499241b291579d96646c98f3a109ed322ce..3ce822d831a51dac73c6c1c5cc2b3221650ad42b 100644 (file)
 \r
 \r
 [LibraryClasses]\r
-   BaseLib\r
-   DebugLib\r
-   BaseMemoryLib\r
-   UefiBootServicesTableLib\r
-   UefiRuntimeServicesTableLib\r
-   UefiLib\r
-   MemoryAllocationLib\r
+  BaseLib\r
+  DebugLib\r
+  BaseMemoryLib\r
+  UefiBootServicesTableLib\r
+  UefiRuntimeServicesTableLib\r
+  UefiLib\r
+  MemoryAllocationLib\r
 \r
 [Protocols]\r
   gEfiSimpleNetworkProtocolGuid                 # PROTOCOL ALWAYS_CONSUMED\r
   gEfiNicIp4ConfigProtocolGuid                  # PROTOCOL ALWAYS_CONSUMED\r
   gEfiDpcProtocolGuid                           # PROTOCOL ALWAYS_CONSUMED\r
+  gEfiComponentNameProtocolGuid                 # PROTOCOL ALWAYS_CONSUMED\r
+  gEfiComponentName2ProtocolGuid                # PROTOCOL ALWAYS_CONSUMED
\ No newline at end of file
index d32715bb40a84992b5eb7cfef9954706a246b975..0ba63fc5129c731b48106bb29aee42980ed4a6af 100644 (file)
@@ -63,7 +63,7 @@ InstallPlatformDriverOverrideProtocol (
   //\r
   if (!EFI_ERROR (Status)) {\r
     if (HandleBuffer != NULL) {\r
-      gBS->FreePool (HandleBuffer);\r
+      FreePool (HandleBuffer);\r
     }\r
     return EFI_ALREADY_STARTED;\r
   }\r
@@ -536,6 +536,92 @@ SaveOverridesMapping (
   return EFI_SUCCESS;\r
 }\r
 \r
+/**\r
+  Get the first Binding protocol which has the specific image handle\r
+\r
+  @param  Image          Image handle\r
+\r
+  @return Pointer into the Binding Protocol interface\r
+\r
+**/\r
+EFI_DRIVER_BINDING_PROTOCOL *\r
+EFIAPI\r
+GetBindingProtocolFromImageHandle (\r
+  IN  EFI_HANDLE   ImageHandle,\r
+  OUT EFI_HANDLE   *BindingHandle\r
+  )\r
+{\r
+  EFI_STATUS                        Status;\r
+  UINTN                             Index;\r
+  UINTN                             DriverBindingHandleCount;\r
+  EFI_HANDLE                        *DriverBindingHandleBuffer;\r
+  EFI_DRIVER_BINDING_PROTOCOL       *DriverBindingInterface;\r
+\r
+  if (BindingHandle == NULL || ImageHandle == NULL) {\r
+    return NULL;\r
+  }\r
+  //\r
+  // Get all driver which support binding protocol in second page\r
+  //\r
+  DriverBindingHandleCount  = 0;\r
+  Status = gBS->LocateHandleBuffer (\r
+                  ByProtocol,\r
+                  &gEfiDriverBindingProtocolGuid,\r
+                  NULL,\r
+                  &DriverBindingHandleCount,\r
+                  &DriverBindingHandleBuffer\r
+                  );\r
+  if (EFI_ERROR (Status) || (DriverBindingHandleCount == 0)) {\r
+    return NULL;\r
+  }\r
+\r
+  for (Index = 0; Index < DriverBindingHandleCount; Index++) {\r
+    DriverBindingInterface =NULL;\r
+    Status = gBS->OpenProtocol (\r
+                    DriverBindingHandleBuffer[Index],\r
+                    &gEfiDriverBindingProtocolGuid,\r
+                    (VOID **) &DriverBindingInterface,\r
+                    NULL,\r
+                    NULL,\r
+                    EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
+                    );\r
+    if (EFI_ERROR (Status)) {\r
+      continue;\r
+    }\r
+\r
+    if (DriverBindingInterface->ImageHandle == ImageHandle) {\r
+      *BindingHandle = DriverBindingHandleBuffer[Index];\r
+      FreePool (DriverBindingHandleBuffer);\r
+      return DriverBindingInterface;\r
+    }\r
+  }\r
+\r
+  FreePool (DriverBindingHandleBuffer);\r
+  *BindingHandle = NULL;\r
+  return NULL;\r
+}\r
+\r
+/**\r
+  return the current TPL, copied from the EDKII glue lib\r
+\r
+  @param  VOID\r
+\r
+  @return Current TPL\r
+\r
+**/\r
+EFI_TPL\r
+GetCurrentTpl (\r
+  VOID\r
+  )\r
+{\r
+  EFI_TPL                 Tpl;\r
+\r
+  Tpl = gBS->RaiseTPL (TPL_HIGH_LEVEL);\r
+  gBS->RestoreTPL (Tpl);\r
+\r
+  return Tpl;\r
+}\r
+\r
 \r
 /**\r
   Retrieves the image handle of the platform override driver for a controller in the system from the memory mapping database.\r
@@ -582,6 +668,7 @@ GetDriverFromMapping (
   UINTN                       Index;\r
   EFI_LOADED_IMAGE_PROTOCOL   *LoadedImage;\r
   EFI_DRIVER_BINDING_PROTOCOL *DriverBinding;\r
+  EFI_HANDLE                  DriverBindingHandle;\r
   BOOLEAN                     FoundLastReturned;\r
   PLATFORM_OVERRIDE_ITEM      *OverrideItem;\r
   DRIVER_IMAGE_INFO           *DriverImageInfo;\r
@@ -741,18 +828,27 @@ GetDriverFromMapping (
         }\r
 \r
         if (ImageFound) {\r
-          Status = gBS->HandleProtocol (\r
-                          ImageHandleBuffer[Index],\r
-                          &gEfiDriverBindingProtocolGuid,\r
-                          (VOID **) &DriverBinding\r
-                          );\r
-          ASSERT (!EFI_ERROR (Status));\r
+          //\r
+          // Find its related driver binding protocol\r
+          // Driver binding handle may be different with its driver's Image handle,\r
+          //\r
+          DriverBindingHandle = NULL;\r
+          DriverBinding = GetBindingProtocolFromImageHandle (\r
+                                      ImageHandleBuffer[Index],\r
+                                      &DriverBindingHandle\r
+                                      );\r
+          ASSERT (DriverBinding != NULL);\r
           DriverImageInfo->ImageHandle = ImageHandleBuffer[Index];\r
-        } else {\r
+        } else if (GetCurrentTpl() <= TPL_CALLBACK){\r
           //\r
           // The driver image has not been loaded and started, need try to load and start it now\r
           // Try to connect all device in the driver image path\r
           //\r
+          // Note: LoadImage() and  StartImage() should be called under CALLBACK TPL in theory, but\r
+          // since many device need to be connected in  CALLBACK level environment( e.g. Usb devices )\r
+          // and the Fat and Patition driver can endure executing in CALLBACK level in fact, so here permit\r
+          // to use LoadImage() and  StartImage() in CALLBACK TPL.\r
+          //\r
           Status = ConnectDevicePath (DriverImageInfo->DriverImagePath);\r
           //\r
           // check whether it points to a PCI Option Rom image, and try to use bus override protocol to get its first option rom image driver\r
@@ -774,12 +870,16 @@ GetDriverFromMapping (
                                                   &ImageHandle\r
                                                   );\r
             if (!EFI_ERROR (Status)) {\r
-              Status = gBS->HandleProtocol (\r
-                              ImageHandle,\r
-                              &gEfiDriverBindingProtocolGuid,\r
-                              (VOID **) &DriverBinding\r
-                              );\r
-              ASSERT (!EFI_ERROR (Status));\r
+              //\r
+              // Find its related driver binding protocol\r
+              // Driver binding handle may be different with its driver's Image handle\r
+              //\r
+              DriverBindingHandle = NULL;\r
+              DriverBinding = GetBindingProtocolFromImageHandle (\r
+                                          ImageHandle,\r
+                                          &DriverBindingHandle\r
+                                          );\r
+              ASSERT (DriverBinding != NULL);\r
               DriverImageInfo->ImageHandle = ImageHandle;\r
             }\r
           }\r
@@ -814,12 +914,16 @@ GetDriverFromMapping (
                 DriverImageInfo->UnStartable = TRUE;\r
                 DriverImageInfo->ImageHandle = NULL;\r
               } else {\r
-                Status = gBS->HandleProtocol (\r
-                                ImageHandle,\r
-                                &gEfiDriverBindingProtocolGuid,\r
-                                (VOID **) &DriverBinding\r
-                                );\r
-                ASSERT (!EFI_ERROR (Status));\r
+                //\r
+                // Find its related driver binding protocol\r
+                // Driver binding handle may be different with its driver's Image handle\r
+                //\r
+                DriverBindingHandle = NULL;\r
+                DriverBinding = GetBindingProtocolFromImageHandle (\r
+                                            ImageHandle,\r
+                                            &DriverBindingHandle\r
+                                            );\r
+                ASSERT (DriverBinding != NULL);\r
                 DriverImageInfo->ImageHandle = ImageHandle;\r
               }\r
             } else {\r
index 637cdfbe80b7e85b9a80ddd641e8bc2146067667..f77b58480bdeaca62480a4ec99fd6b1cb669b9d4 100644 (file)
 ################################################################################\r
 \r
 [Components.common]\r
-  MdeModulePkg/Core/Pei/PeiMain.inf\r
-  MdeModulePkg/Core/Dxe/DxeMain.inf {\r
-    <LibraryClasses>\r
-      NULL|MdeModulePkg/Library/DxeCrc32GuidedSectionExtractLib/DxeCrc32GuidedSectionExtractLib.inf\r
-  }\r
-\r
-  MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.inf\r
-  MdeModulePkg/Library/DxePerformanceLib/DxePerformanceLib.inf\r
-  MdeModulePkg/Library/PeiPerformanceLib/PeiPerformanceLib.inf\r
-  MdeModulePkg/Library/EdkDxePrintLib/EdkDxePrintLib.inf\r
-\r
-  MdeModulePkg/Library/DxeDpcLib/DxeDpcLib.inf\r
-  MdeModulePkg/Library/DxeNetLib/DxeNetLib.inf\r
-  MdeModulePkg/Library/DxeIpIoLib/DxeIpIoLib.inf\r
-  MdeModulePkg/Library/DxeUdpIoLib/DxeUdpIoLib.inf\r
-\r
-  MdeModulePkg/Library/DxePlatDriOverLib/DxePlatDriOverLib.inf\r
-\r
-  MdeModulePkg/Library/PeiS3LibNull/PeiS3LibNull.inf\r
-  MdeModulePkg/Library/PeiRecoveryLibNull/PeiRecoveryLibNull.inf\r
-\r
-  MdeModulePkg/Universal/iScsi/IScsi.inf\r
-\r
-  MdeModulePkg/Universal/Network/ArpDxe/ArpDxe.inf\r
-  MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Dxe.inf\r
-  MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4ConfigDxe.inf\r
-  MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Dxe.inf\r
-  MdeModulePkg/Universal/Network/MnpDxe/MnpDxe.inf\r
-  MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Dxe.inf\r
-  MdeModulePkg/Universal/Network/PxeBcDxe/PxeBcDxe.inf\r
-  MdeModulePkg/Universal/Network/UefiPxeBcDxe/UefiPxeBcDxe.inf\r
-  MdeModulePkg/Universal/Network/PxeDhcp4Dxe/PxeDhcp4Dxe.inf\r
-  MdeModulePkg/Universal/Network/SnpDxe/SnpDxe.inf\r
-  MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Dxe.inf\r
-  MdeModulePkg/Universal/Network/Udp4Dxe/Udp4Dxe.inf\r
-  MdeModulePkg/Universal/Network/DpcDxe/DpcDxe.inf\r
-\r
-  MdeModulePkg/Universal/PlatformDriOverrideDxe/PlatformDriOverrideDxe.inf\r
-\r
-  MdeModulePkg/Application/HelloWorld/HelloWorld.inf\r
-\r
-  MdeModulePkg/Bus/Scsi/ScsiBusDxe/ScsiBusDxe.inf\r
-  MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDiskDxe.inf\r
-\r
-  MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf\r
-  MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIoDxe.inf\r
-  MdeModulePkg/Universal/Disk/PartitionDxe/PartitionDxe.inf\r
-  MdeModulePkg/Universal/Disk/UnicodeCollation/EnglishDxe/EnglishDxe.inf\r
-  MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf\r
-\r
-  MdeModulePkg/Universal/FirmwareVolume/FaultTolerantWriteDxe/FtwLite.inf\r
-  MdeModulePkg/Universal/MemoryTest/NullMemoryTestDxe/NullMemoryTestDxe.inf\r
-  MdeModulePkg/Universal/MemoryTest/BaseMemoryTestPei/BaseMemoryTestPei.inf\r
-  MdeModulePkg/Core/RuntimeDxe/RuntimeDxe.inf\r
-\r
-  MdeModulePkg/Universal/WatchDogTimerDxe/WatchDogTimer.inf\r
-  MdeModulePkg/Universal/DebugPortDxe/DebugPortDxe.inf\r
-  MdeModulePkg/Universal/PCD/Dxe/Pcd.inf\r
-  MdeModulePkg/Universal/PCD/Pei/Pcd.inf\r
+#  MdeModulePkg/Core/Pei/PeiMain.inf\r
+#  MdeModulePkg/Core/Dxe/DxeMain.inf {\r
+#    <LibraryClasses>\r
+#      NULL|MdeModulePkg/Library/DxeCrc32GuidedSectionExtractLib/DxeCrc32GuidedSectionExtractLib.inf\r
+#  }\r
+#\r
+#  MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.inf\r
+#  MdeModulePkg/Library/DxePerformanceLib/DxePerformanceLib.inf\r
+#  MdeModulePkg/Library/PeiPerformanceLib/PeiPerformanceLib.inf\r
+#  MdeModulePkg/Library/EdkDxePrintLib/EdkDxePrintLib.inf\r
+#\r
+#  MdeModulePkg/Library/DxeDpcLib/DxeDpcLib.inf\r
+#  MdeModulePkg/Library/DxeNetLib/DxeNetLib.inf\r
+#  MdeModulePkg/Library/DxeIpIoLib/DxeIpIoLib.inf\r
+#  MdeModulePkg/Library/DxeUdpIoLib/DxeUdpIoLib.inf\r
+#\r
+#  MdeModulePkg/Library/DxePlatDriOverLib/DxePlatDriOverLib.inf\r
+#\r
+#  MdeModulePkg/Library/PeiS3LibNull/PeiS3LibNull.inf\r
+#  MdeModulePkg/Library/PeiRecoveryLibNull/PeiRecoveryLibNull.inf\r
+#\r
+#  MdeModulePkg/Universal/iScsi/IScsi.inf\r
+#\r
+#  MdeModulePkg/Universal/Network/ArpDxe/ArpDxe.inf\r
+#  MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Dxe.inf\r
+#  MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4ConfigDxe.inf\r
+#  MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Dxe.inf\r
+#  MdeModulePkg/Universal/Network/MnpDxe/MnpDxe.inf\r
+#  MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Dxe.inf\r
+#  MdeModulePkg/Universal/Network/PxeBcDxe/PxeBcDxe.inf\r
+#  MdeModulePkg/Universal/Network/UefiPxeBcDxe/UefiPxeBcDxe.inf\r
+#  MdeModulePkg/Universal/Network/PxeDhcp4Dxe/PxeDhcp4Dxe.inf\r
+#  MdeModulePkg/Universal/Network/SnpDxe/SnpDxe.inf\r
+#  MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Dxe.inf\r
+#  MdeModulePkg/Universal/Network/Udp4Dxe/Udp4Dxe.inf\r
+#  MdeModulePkg/Universal/Network/DpcDxe/DpcDxe.inf\r
+#\r
+#  MdeModulePkg/Universal/PlatformDriOverrideDxe/PlatformDriOverrideDxe.inf\r
+#\r
+#  MdeModulePkg/Application/HelloWorld/HelloWorld.inf\r
+#\r
+#  MdeModulePkg/Bus/Scsi/ScsiBusDxe/ScsiBusDxe.inf\r
+#  MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDiskDxe.inf\r
+#\r
+#  MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf\r
+#  MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIoDxe.inf\r
+#  MdeModulePkg/Universal/Disk/PartitionDxe/PartitionDxe.inf\r
+#  MdeModulePkg/Universal/Disk/UnicodeCollation/EnglishDxe/EnglishDxe.inf\r
+#  MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf\r
+#\r
+#  MdeModulePkg/Universal/FirmwareVolume/FaultTolerantWriteDxe/FtwLite.inf\r
+#  MdeModulePkg/Universal/MemoryTest/NullMemoryTestDxe/NullMemoryTestDxe.inf\r
+#  MdeModulePkg/Universal/MemoryTest/BaseMemoryTestPei/BaseMemoryTestPei.inf\r
+#  MdeModulePkg/Core/RuntimeDxe/RuntimeDxe.inf\r
+#\r
+#  MdeModulePkg/Universal/WatchDogTimerDxe/WatchDogTimer.inf\r
+#  MdeModulePkg/Universal/DebugPortDxe/DebugPortDxe.inf\r
+#  MdeModulePkg/Universal/PCD/Dxe/Pcd.inf\r
+#  MdeModulePkg/Universal/PCD/Pei/Pcd.inf\r
   MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatformDxe.inf\r
   MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitterDxe.inf\r
   MdeModulePkg/Universal/DevicePathDxe/DevicePathDxe.inf\r
   MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsoleDxe.inf\r
   MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf\r
   MdeModulePkg/Universal/PcatSingleSegmentPciCfg2Pei/PcatSingleSegmentPciCfg2Pei.inf\r
-  MdeModulePkg/Application/HelloWorld/HelloWorld.inf\r
-  MdeModulePkg/Bus/Pci/EhciDxe/EhciDxe.inf\r
-  MdeModulePkg/Bus/Pci/UhciDxe/UhciDxe.inf\r
-  MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBusDxe.inf\r
-  MdeModulePkg/Bus/Usb/UsbKbDxe/UsbKbDxe.inf\r
-  MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassStorageDxe.inf\r
-  MdeModulePkg/Bus/Usb/UsbMouseDxe/UsbMouseDxe.inf\r
-  MdeModulePkg/Bus/Usb/UsbMouseAbsolutePointerDxe/UsbMouseAbsolutePointerDxe.inf\r
-\r
-  MdeModulePkg/Universal/Variable/Pei/VariablePei.inf\r
-  MdeModulePkg/Universal/Variable/Application/VariableInfo.inf\r
-\r
-[Components.IA32]\r
-  MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf\r
-  MdeModulePkg/Universal/MonotonicCounterRuntimeDxe/MonotonicCounterRuntimeDxe.inf\r
-  MdeModulePkg/Universal/EbcDxe/EbcDxe.inf\r
-  MdeModulePkg/Universal/DebugSupportDxe/DebugSupportDxe.inf\r
-  MdeModulePkg/Universal/PcatRealTimeClockRuntimeDxe/PcatRealTimeClockRuntimeDxe.inf\r
-  MdeModulePkg/Bus/Pci/UndiRuntimeDxe/UndiRuntimeDxe.inf\r
-\r
-[Components.X64]\r
-  MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf\r
-  MdeModulePkg/Universal/MonotonicCounterRuntimeDxe/MonotonicCounterRuntimeDxe.inf\r
-  MdeModulePkg/Universal/EbcDxe/EbcDxe.inf\r
-  MdeModulePkg/Universal/DebugSupportDxe/DebugSupportDxe.inf\r
-  MdeModulePkg/Universal/PcatRealTimeClockRuntimeDxe/PcatRealTimeClockRuntimeDxe.inf\r
-  MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf\r
-  MdeModulePkg/Universal/Variable/EmuRuntimeDxe/EmuVariableRuntimeDxe.inf\r
-  MdeModulePkg/Bus/Pci/UndiRuntimeDxe/UndiRuntimeDxe.inf\r
-\r
-[Components.IPF]\r
-  MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf\r
-  MdeModulePkg/Universal/EbcDxe/EbcDxe.inf\r
-  MdeModulePkg/Universal/DebugSupportDxe/DebugSupportDxe.inf\r
-\r
-[Components.EBC]\r
-  #BugBug: Need DXE I/O library instance for EBC.\r
-  #MdeModulePkg/Universal/PcatRealTimeClockRuntimeDxe/PcatRealTimeClockRuntimeDxe.inf\r
-  MdeModulePkg/Bus/Pci/UndiRuntimeDxe/UndiRuntimeDxe.inf\r
-\r
+#  MdeModulePkg/Application/HelloWorld/HelloWorld.inf\r
+#  MdeModulePkg/Bus/Pci/EhciDxe/EhciDxe.inf\r
+#  MdeModulePkg/Bus/Pci/UhciDxe/UhciDxe.inf\r
+#  MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBusDxe.inf\r
+#  MdeModulePkg/Bus/Usb/UsbKbDxe/UsbKbDxe.inf\r
+#  MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassStorageDxe.inf\r
+#  MdeModulePkg/Bus/Usb/UsbMouseDxe/UsbMouseDxe.inf\r
+#  MdeModulePkg/Bus/Usb/UsbMouseAbsolutePointerDxe/UsbMouseAbsolutePointerDxe.inf\r
+#\r
+#  MdeModulePkg/Universal/Variable/Pei/VariablePei.inf\r
+#  MdeModulePkg/Universal/Variable/Application/VariableInfo.inf\r
+#\r
+#[Components.IA32]\r
+#  MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf\r
+#  MdeModulePkg/Universal/MonotonicCounterRuntimeDxe/MonotonicCounterRuntimeDxe.inf\r
+#  MdeModulePkg/Universal/EbcDxe/EbcDxe.inf\r
+#  MdeModulePkg/Universal/DebugSupportDxe/DebugSupportDxe.inf\r
+#  MdeModulePkg/Universal/PcatRealTimeClockRuntimeDxe/PcatRealTimeClockRuntimeDxe.inf\r
+#  MdeModulePkg/Bus/Pci/UndiRuntimeDxe/UndiRuntimeDxe.inf\r
+#\r
+#[Components.X64]\r
+#  MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf\r
+#  MdeModulePkg/Universal/MonotonicCounterRuntimeDxe/MonotonicCounterRuntimeDxe.inf\r
+#  MdeModulePkg/Universal/EbcDxe/EbcDxe.inf\r
+#  MdeModulePkg/Universal/DebugSupportDxe/DebugSupportDxe.inf\r
+#  MdeModulePkg/Universal/PcatRealTimeClockRuntimeDxe/PcatRealTimeClockRuntimeDxe.inf\r
+#  MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf\r
+#  MdeModulePkg/Universal/Variable/EmuRuntimeDxe/EmuVariableRuntimeDxe.inf\r
+#  MdeModulePkg/Bus/Pci/UndiRuntimeDxe/UndiRuntimeDxe.inf\r
+#\r
+#[Components.IPF]\r
+#  MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf\r
+#  MdeModulePkg/Universal/EbcDxe/EbcDxe.inf\r
+#  MdeModulePkg/Universal/DebugSupportDxe/DebugSupportDxe.inf\r
+#\r
+#[Components.EBC]\r
+#  #BugBug: Need DXE I/O library instance for EBC.\r
+#  #MdeModulePkg/Universal/PcatRealTimeClockRuntimeDxe/PcatRealTimeClockRuntimeDxe.inf\r
+#  MdeModulePkg/Bus/Pci/UndiRuntimeDxe/UndiRuntimeDxe.inf\r
+#\r
index 8e49c480972686426c5fd3ea1e4f7a729d48056d..63be0b1d8b467a139545e0a3db3a7f531611f387 100644 (file)
@@ -2243,6 +2243,7 @@ Returns:
   INT32                         Index;\r
   INT32                         *TextOutModeMap;\r
   INT32                         *MapTable;\r
+  INT32                         QueryMode;\r
   TEXT_OUT_SPLITTER_QUERY_DATA  *TextOutQueryData;\r
   UINTN                         Rows;\r
   UINTN                         Columns;\r
@@ -2263,13 +2264,15 @@ Returns:
   MapTable  = TextOutModeMap + Private->CurrentNumberOfConsoles;\r
   while (Mode < TextOut->Mode->MaxMode) {\r
     TextOut->QueryMode (TextOut, Mode, &Columns, &Rows);\r
+        MapTable[StepSize] = Mode;\r
 \r
     //\r
-    // Search the QueryData database to see if they intersects\r
+    // Search the intersection map and QueryData database to see if they intersects\r
     //\r
     Index = 0;\r
     while (Index < CurrentMaxMode) {\r
-      if ((TextOutQueryData[Index].Rows == Rows) && (TextOutQueryData[Index].Columns == Columns)) {\r
+      QueryMode = *(TextOutModeMap + Index * StepSize);\r
+      if ((TextOutQueryData[QueryMode].Rows == Rows) && (TextOutQueryData[QueryMode].Columns == Columns)) {\r
         MapTable[Index * StepSize] = Mode;\r
         break;\r
       }\r
@@ -2308,7 +2311,7 @@ Arguments:
 \r
 Returns:\r
 \r
-  None\r
+  EFI_SUCCESS\r
   EFI_OUT_OF_RESOURCES\r
 \r
 --*/\r
@@ -2319,10 +2322,14 @@ Returns:
   TEXT_OUT_AND_GOP_DATA         *StdErrTextOutList;\r
   UINTN                         Indexi;\r
   UINTN                         Indexj;\r
-  UINTN                         Rows;\r
-  UINTN                         Columns;\r
+  UINTN                         ConOutRows;\r
+  UINTN                         ConOutColumns;\r
+  UINTN                         StdErrRows;\r
+  UINTN                         StdErrColumns;\r
   INT32                         ConOutMaxMode;\r
   INT32                         StdErrMaxMode;\r
+  INT32                         ConOutMode;\r
+  INT32                         StdErrMode;\r
   INT32                         Mode;\r
   INT32                         Index;\r
   INT32                         *ConOutModeMap;\r
@@ -2331,6 +2338,8 @@ Returns:
   INT32                         *StdErrMapTable;\r
   TEXT_OUT_SPLITTER_QUERY_DATA  *ConOutQueryData;\r
   TEXT_OUT_SPLITTER_QUERY_DATA  *StdErrQueryData;\r
+  UINTN                         ConOutStepSize;\r
+  UINTN                         StdErrStepSize;\r
   BOOLEAN                       FoundTheSameTextOut;\r
   UINTN                         ConOutMapTableSize;\r
   UINTN                         StdErrMapTableSize;\r
@@ -2366,10 +2375,12 @@ Returns:
   //\r
   ConOutMaxMode     = mConOut.TextOutMode.MaxMode;\r
   ConOutModeMap     = mConOut.TextOutModeMap;\r
+  ConOutStepSize    = mConOut.TextOutListCount;\r
   ConOutQueryData   = mConOut.TextOutQueryData;\r
 \r
   StdErrMaxMode     = mStdErr.TextOutMode.MaxMode;\r
   StdErrModeMap     = mStdErr.TextOutModeMap;\r
+  StdErrStepSize    = mStdErr.TextOutListCount;\r
   StdErrQueryData   = mStdErr.TextOutQueryData;\r
 \r
   //\r
@@ -2398,13 +2409,17 @@ Returns:
   Mode = 0;\r
   while (Mode < ConOutMaxMode) {\r
     //\r
-    // Search the other's QueryData database to see if they intersect\r
+    // Search the intersection map and QueryData database to see if they intersect\r
     //\r
-    Index   = 0;\r
-    Rows    = ConOutQueryData[Mode].Rows;\r
-    Columns = ConOutQueryData[Mode].Columns;\r
+    Index = 0;\r
+    ConOutMode    = *(ConOutModeMap + Mode * ConOutStepSize);\r
+    ConOutRows    = ConOutQueryData[ConOutMode].Rows;\r
+    ConOutColumns = ConOutQueryData[ConOutMode].Columns;\r
     while (Index < StdErrMaxMode) {\r
-      if ((StdErrQueryData[Index].Rows == Rows) && (StdErrQueryData[Index].Columns == Columns)) {\r
+      StdErrMode    = *(StdErrModeMap + Index * StdErrStepSize);\r
+      StdErrRows    = StdErrQueryData[StdErrMode].Rows;\r
+      StdErrColumns = StdErrQueryData[StdErrMode].Columns;\r
+      if ((StdErrRows == ConOutRows) && (StdErrColumns == ConOutColumns)) {\r
         ConOutMapTable[Mode]  = 1;\r
         StdErrMapTable[Index] = 1;\r
         break;\r
@@ -2470,6 +2485,7 @@ Returns:
 {\r
   EFI_STATUS                           Status;\r
   UINTN                                Index;\r
+  UINTN                                CurrentIndex;\r
   EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *Mode;\r
   UINTN                                SizeOfInfo;\r
   EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *Info;\r
@@ -2479,6 +2495,10 @@ Returns:
   UINTN                                NumberIndex;\r
   BOOLEAN                              Match;\r
   BOOLEAN                              AlreadyExist;\r
+  UINT32                               UgaHorizontalResolution;\r
+  UINT32                               UgaVerticalResolution;\r
+  UINT32                               UgaColorDepth;\r
+  UINT32                               UgaRefreshRate;\r
 \r
   if ((GraphicsOutput == NULL) && (UgaDraw == NULL)) {\r
     return EFI_UNSUPPORTED;\r
@@ -2487,6 +2507,7 @@ Returns:
   CurrentGraphicsOutputMode = Private->GraphicsOutput.Mode;\r
 \r
   Index        = 0;\r
+  CurrentIndex = 0;\r
 \r
   if (Private->CurrentNumberOfUgaDraw != 0) {\r
     //\r
@@ -2606,34 +2627,49 @@ Returns:
     }\r
 \r
     //\r
-    // Select a prefered Display mode 800x600\r
+    // Graphics console driver can ensure the same mode for all GOP devices\r
     //\r
     for (Index = 0; Index < CurrentGraphicsOutputMode->MaxMode; Index++) {\r
       Mode = &Private->GraphicsOutputModeBuffer[Index];\r
-      if ((Mode->HorizontalResolution == 800) && (Mode->VerticalResolution == 600)) {\r
+      if ((Mode->HorizontalResolution == GraphicsOutput->Mode->Info->HorizontalResolution) &&\r
+         (Mode->VerticalResolution == GraphicsOutput->Mode->Info->VerticalResolution)) {\r
+        CurrentIndex = Index;\r
         break;\r
       }\r
     }\r
-    //\r
-    // Prefered mode is not found, set to mode 0\r
-    //\r
     if (Index >= CurrentGraphicsOutputMode->MaxMode) {\r
-      Index = 0;\r
+      //\r
+      // if user defined mode is not found, set to default mode 800x600\r
+      //\r
+      for (Index = 0; Index < CurrentGraphicsOutputMode->MaxMode; Index++) {\r
+        Mode = &Private->GraphicsOutputModeBuffer[Index];\r
+        if ((Mode->HorizontalResolution == 800) && (Mode->VerticalResolution == 600)) {\r
+          CurrentIndex = Index;\r
+          break;\r
+        }\r
+      }\r
     }\r
-\r
   }\r
   if (UgaDraw != NULL) {\r
     //\r
-    // For UGA device, it's inconvenient to retrieve all the supported display modes.\r
-    // To simplify the implementation, only add one resolution(800x600, 32bit color depth) as defined in UEFI spec\r
+    // Graphics console driver can ensure the same mode for all GOP devices\r
+    // so we can get the current mode from this video device\r
     //\r
+    UgaDraw->GetMode (\r
+               UgaDraw,\r
+               &UgaHorizontalResolution,\r
+               &UgaVerticalResolution,\r
+               &UgaColorDepth,\r
+               &UgaRefreshRate\r
+               );\r
+\r
     CurrentGraphicsOutputMode->MaxMode = 1;\r
     Info = CurrentGraphicsOutputMode->Info;\r
     Info->Version = 0;\r
-    Info->HorizontalResolution = 800;\r
-    Info->VerticalResolution = 600;\r
+    Info->HorizontalResolution = UgaHorizontalResolution;\r
+    Info->VerticalResolution = UgaVerticalResolution;\r
     Info->PixelFormat = PixelBltOnly;\r
-    Info->PixelsPerScanLine = 800;\r
+    Info->PixelsPerScanLine = UgaHorizontalResolution;\r
     CurrentGraphicsOutputMode->SizeOfInfo = sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION);\r
     CurrentGraphicsOutputMode->FrameBufferBase = (EFI_PHYSICAL_ADDRESS) NULL;\r
     CurrentGraphicsOutputMode->FrameBufferSize = 0;\r
@@ -2646,7 +2682,7 @@ Returns:
     //\r
     // Only mode 0 is available to be set\r
     //\r
-    Index = 0;\r
+    CurrentIndex = 0;\r
   }\r
 \r
 Done:\r
@@ -2666,7 +2702,20 @@ Done:
   //\r
   // Current mode number may need update now, so set it to an invalid mode number\r
   //\r
-  Status = Private->GraphicsOutput.SetMode (&Private->GraphicsOutput, (UINT32) Index);\r
+  CurrentGraphicsOutputMode->Mode = 0xffff;\r
+  //\r
+  // Graphics console can ensure all GOP devices have the same mode which can be taken as current mode.\r
+  //\r
+  Status = Private->GraphicsOutput.SetMode (&Private->GraphicsOutput, (UINT32) CurrentIndex);\r
+\r
+  //\r
+  // If user defined mode is not valid for UGA, set to the default mode 800x600.\r
+  //\r
+  if (EFI_ERROR(Status)) {\r
+    (Private->GraphicsOutputModeBuffer[0]).HorizontalResolution = 800;\r
+    (Private->GraphicsOutputModeBuffer[0]).VerticalResolution   = 600;\r
+    Status = Private->GraphicsOutput.SetMode (&Private->GraphicsOutput, 0);\r
+  }\r
 \r
   return Status;\r
 }\r
@@ -2694,6 +2743,10 @@ Returns:
   UINTN                 CurrentNumOfConsoles;\r
   INT32                 CurrentMode;\r
   INT32                 MaxMode;\r
+  UINT32                UgaHorizontalResolution;\r
+  UINT32                UgaVerticalResolution;\r
+  UINT32                UgaColorDepth;\r
+  UINT32                UgaRefreshRate;\r
   TEXT_OUT_AND_GOP_DATA *TextAndGop;\r
 \r
   Status                = EFI_SUCCESS;\r
@@ -2728,12 +2781,12 @@ Returns:
 \r
   if ((GraphicsOutput == NULL) && (UgaDraw == NULL)) {\r
     //\r
-    // If No UGA device then use the ConOut device\r
+    // If No GOP/UGA device then use the ConOut device\r
     //\r
     TextAndGop->TextOutEnabled = TRUE;\r
   } else {\r
     //\r
-    // If UGA device use ConOut device only used if UGA screen is in Text mode\r
+    // If GOP/UGA device use ConOut device only used if screen is in Text mode\r
     //\r
     TextAndGop->TextOutEnabled = (BOOLEAN) (Private->ConsoleOutputMode == EfiConsoleControlScreenText);\r
   }\r
@@ -2760,15 +2813,50 @@ Returns:
   MaxMode     = Private->TextOutMode.MaxMode;\r
   ASSERT (MaxMode >= 1);\r
 \r
+  //\r
+  // Update DevNull mode according to current video device\r
+  //\r
   if (FeaturePcdGet (PcdConOutGopSupport)) {\r
     if ((GraphicsOutput != NULL) || (UgaDraw != NULL)) {\r
       ConSplitterAddGraphicsOutputMode (Private, GraphicsOutput, UgaDraw);\r
     }\r
   }\r
+  if (FeaturePcdGet (PcdConOutUgaSupport)) {\r
+    if (UgaDraw != NULL) {\r
+      Status = UgaDraw->GetMode (\r
+                    UgaDraw,\r
+                    &UgaHorizontalResolution,\r
+                    &UgaVerticalResolution,\r
+                    &UgaColorDepth,\r
+                    &UgaRefreshRate\r
+                    );\r
+      if (!EFI_ERROR (Status)) {\r
+        Status = ConSpliterUgaDrawSetMode (\r
+                    &Private->UgaDraw,\r
+                    UgaHorizontalResolution,\r
+                    UgaVerticalResolution,\r
+                    UgaColorDepth,\r
+                    UgaRefreshRate\r
+                    );\r
+      }\r
+      //\r
+      // If GetMode/SetMode is failed, set to 800x600 mode\r
+      //\r
+      if(EFI_ERROR (Status)) {\r
+        Status = ConSpliterUgaDrawSetMode (\r
+                    &Private->UgaDraw,\r
+                    800,\r
+                    600,\r
+                    32,\r
+                    60\r
+                    );\r
+      }\r
+    }\r
+  }\r
 \r
   if (Private->ConsoleOutputMode == EfiConsoleControlScreenGraphics && GraphicsOutput != NULL) {\r
     //\r
-    // We just added a new UGA device in graphics mode\r
+    // We just added a new GOP or UGA device in graphics mode\r
     //\r
     if (FeaturePcdGet (PcdConOutGopSupport)) {\r
       DevNullGopSync (Private, TextAndGop->GraphicsOutput, TextAndGop->UgaDraw);\r
@@ -2823,14 +2911,12 @@ Returns:
     if (TextOutList->TextOut == TextOut) {\r
       CopyMem (TextOutList, TextOutList + 1, sizeof (TEXT_OUT_AND_GOP_DATA) * Index);\r
       CurrentNumOfConsoles--;\r
-    if (FeaturePcdGet (PcdConOutGopSupport)) {\r
       if (TextOutList->UgaDraw != NULL) {\r
         Private->CurrentNumberOfUgaDraw--;\r
       }\r
       if (TextOutList->GraphicsOutput != NULL) {\r
         Private->CurrentNumberOfGraphicsOutput--;\r
       }\r
-    }\r
       break;\r
     }\r
 \r
@@ -4300,6 +4386,8 @@ ConSplitterTextOutQueryMode (
 --*/\r
 {\r
   TEXT_OUT_SPLITTER_PRIVATE_DATA  *Private;\r
+  UINTN                           CurrentMode;\r
+  INT32                           *TextOutModeMap;\r
 \r
   Private = TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This);\r
 \r
@@ -4315,8 +4403,18 @@ ConSplitterTextOutQueryMode (
     return EFI_UNSUPPORTED;\r
   }\r
 \r
-  *Columns  = Private->TextOutQueryData[ModeNumber].Columns;\r
-  *Rows     = Private->TextOutQueryData[ModeNumber].Rows;\r
+  //\r
+  // We get the available mode from mode intersection map if it's available\r
+  //\r
+  if (Private->TextOutModeMap != NULL) {\r
+    TextOutModeMap = Private->TextOutModeMap + Private->TextOutListCount * ModeNumber;\r
+    CurrentMode    = (UINTN)(*TextOutModeMap);\r
+    *Columns       = Private->TextOutQueryData[CurrentMode].Columns;\r
+    *Rows          = Private->TextOutQueryData[CurrentMode].Rows;\r
+  } else {\r
+    *Columns  = Private->TextOutQueryData[ModeNumber].Columns;\r
+    *Rows     = Private->TextOutQueryData[ModeNumber].Rows;\r
+  }\r
 \r
   if (*Columns <= 0 && *Rows <= 0) {\r
     return EFI_UNSUPPORTED;\r
@@ -4386,8 +4484,8 @@ ConSplitterTextOutSetMode (
                                                       TextOutModeMap[Index]\r
                                                       );\r
       //\r
-      // If this console device is based on a UGA device, then sync up the bitmap from\r
-      // the UGA splitter and reclear the text portion of the display in the new mode.\r
+      // If this console device is based on a GOP or UGA device, then sync up the bitmap from\r
+      // the GOP/UGA splitter and reclear the text portion of the display in the new mode.\r
       //\r
       if ((Private->TextOutList[Index].GraphicsOutput != NULL) || (Private->TextOutList[Index].UgaDraw != NULL)) {\r
         Private->TextOutList[Index].TextOut->ClearScreen (Private->TextOutList[Index].TextOut);\r
@@ -4651,3 +4749,4 @@ ConSplitterTextOutEnableCursor (
 \r
   return ReturnStatus;\r
 }\r
+\r
index 3f720ac380aef0f4a94bd3cc6ace17932438a9b4..2c66a44ad04726bc4f54ece4ccc69a7f313e4de1 100644 (file)
@@ -1350,6 +1350,7 @@ DevNullTextOutSetMode (
 --*/\r
 {\r
   UINTN                         Size;\r
+  INT32                         CurrentMode;\r
   UINTN                         Row;\r
   UINTN                         Column;\r
   TEXT_OUT_SPLITTER_QUERY_DATA  *Mode;\r
@@ -1357,8 +1358,14 @@ DevNullTextOutSetMode (
   //\r
   // No extra check for ModeNumber here, as it has been checked in\r
   // ConSplitterTextOutSetMode. And mode 0 should always be supported.\r
+  // Row and Column should be fetched from intersection map.\r
   //\r
-  Mode    = &(Private->TextOutQueryData[ModeNumber]);\r
+  if (Private->TextOutModeMap != NULL) {\r
+    CurrentMode = *(Private->TextOutModeMap + Private->TextOutListCount * ModeNumber);\r
+  } else {\r
+    CurrentMode = (INT32)(ModeNumber);\r
+  }\r
+  Mode    = &(Private->TextOutQueryData[CurrentMode]);\r
   Row     = Mode->Rows;\r
   Column  = Mode->Columns;\r
 \r
index ee96eabdd6a0fea6e3596e39f09bf7cd0ab99c17..0f83803a3793c16213af4ca28dabc1b3f15d2e7d 100644 (file)
@@ -41,6 +41,14 @@ EraseCursor (
   IN  EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL  *This\r
   );\r
 \r
+EFI_STATUS\r
+CheckModeSupported (\r
+  EFI_GRAPHICS_OUTPUT_PROTOCOL  *GraphicsOutput,\r
+  IN  UINT32  HorizontalResolution,\r
+  IN  UINT32  VerticalResolution,\r
+  OUT UINT32  *CurrentModeNumber\r
+  );\r
+\r
 //\r
 // Globals\r
 //\r
@@ -70,8 +78,9 @@ GRAPHICS_CONSOLE_DEV        mGraphicsConsoleDevTemplate = {
   },\r
   {\r
     { 80, 25, 0, 0, 0, 0 },  // Mode 0\r
-    { 80, 50, 0, 0, 0, 0 },  // Mode 1 \r
-    {  0,  0, 0, 0, 0, 0 }   // Mode 2\r
+    { 80, 50, 0, 0, 0, 0 },  // Mode 1\r
+    { 100,31, 0, 0, 0, 0 },  // Mode 2\r
+    {  0,  0, 0, 0, 0, 0 }   // Mode 3\r
   },\r
   (EFI_GRAPHICS_OUTPUT_BLT_PIXEL *) NULL,\r
   (EFI_HII_HANDLE) 0\r
@@ -238,22 +247,20 @@ GraphicsConsoleControllerDriverStart (
 \r
 --*/\r
 {\r
-  EFI_STATUS            Status;\r
-  GRAPHICS_CONSOLE_DEV  *Private;\r
+  EFI_STATUS                           Status;\r
+  GRAPHICS_CONSOLE_DEV                 *Private;\r
   EFI_HII_PACKAGES      *Package;\r
   EFI_HII_FONT_PACK     *FontPack;\r
-  UINTN                 NarrowFontSize;\r
-  UINT32                HorizontalResolution;\r
-  UINT32                VerticalResolution;\r
-  UINT32                ColorDepth;\r
-  UINT32                RefreshRate;\r
-  UINTN                 MaxMode;\r
-  UINTN                 Columns;\r
-  UINTN                 Rows;\r
-  UINT8                 *Location;\r
+  UINTN                                NarrowFontSize;\r
+  UINT32                               HorizontalResolution;\r
+  UINT32                               VerticalResolution;\r
+  UINT32                               ColorDepth;\r
+  UINT32                               RefreshRate;\r
+  UINTN                                MaxMode;\r
+  UINTN                                Columns;\r
+  UINTN                                Rows;\r
+  UINT8                                *Location;\r
   UINT32                               ModeNumber;\r
-  UINTN                                SizeOfInfo;\r
-  EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *Info;\r
   \r
   ModeNumber = 0;\r
 \r
@@ -336,26 +343,32 @@ GraphicsConsoleControllerDriverStart (
 \r
   if (Private->GraphicsOutput != NULL) {\r
     //\r
-    // The console is build on top of Graphics Output Protocol, find the mode number for 800x600\r
+    // The console is build on top of Graphics Output Protocol, find the mode number \r
+    // for the user-defined mode; if there are multiple video devices,\r
+    // graphic console driver will set all the video devices to the same mode.\r
     //\r
-    for (ModeNumber = 0; ModeNumber < Private->GraphicsOutput->Mode->MaxMode; ModeNumber++) {\r
-      Status = Private->GraphicsOutput->QueryMode (\r
-                         Private->GraphicsOutput,\r
-                         ModeNumber,\r
-                         &SizeOfInfo,\r
-                         &Info\r
-                         );\r
-      if (!EFI_ERROR (Status)) {\r
-        if ((Info->HorizontalResolution == 800) &&\r
-            (Info->VerticalResolution == 600)) {\r
-          Status = Private->GraphicsOutput->SetMode (Private->GraphicsOutput, ModeNumber);\r
-          if (!EFI_ERROR (Status)) {\r
-            FreePool (Info);\r
-            break;\r
-          }\r
-        }\r
-        FreePool (Info);\r
-      }\r
+    Status = CheckModeSupported (\r
+                 Private->GraphicsOutput, \r
+                 CURRENT_HORIZONTAL_RESOLUTION, \r
+                 CURRENT_VERTICAL_RESOLUTION,\r
+                 &ModeNumber\r
+                 );\r
+    if (!EFI_ERROR(Status)) {\r
+      //\r
+      // Update default mode to current mode\r
+      //\r
+      HorizontalResolution = CURRENT_HORIZONTAL_RESOLUTION;\r
+      VerticalResolution   = CURRENT_VERTICAL_RESOLUTION;\r
+    } else {\r
+      //\r
+      // if not supporting current mode, try 800x600 which is required by UEFI/EFI spec\r
+      //\r
+      Status = CheckModeSupported (\r
+                   Private->GraphicsOutput, \r
+                   800, \r
+                   600, \r
+                   &ModeNumber\r
+                   );\r
     }\r
 \r
     if (EFI_ERROR (Status) || (ModeNumber == Private->GraphicsOutput->Mode->MaxMode)) {\r
@@ -368,30 +381,42 @@ GraphicsConsoleControllerDriverStart (
     }\r
   } else {\r
     //\r
-    // The console is build on top of UGA Draw Protocol\r
+    // At first try to set user-defined resolution\r
     //\r
     ColorDepth            = 32;\r
     RefreshRate           = 60;\r
     Status = Private->UgaDraw->SetMode (\r
                                 Private->UgaDraw,\r
-                                HorizontalResolution,\r
-                                VerticalResolution,\r
+                                CURRENT_HORIZONTAL_RESOLUTION,\r
+                                CURRENT_VERTICAL_RESOLUTION,\r
                                 ColorDepth,\r
                                 RefreshRate\r
                                 );\r
-    if (EFI_ERROR (Status)) {\r
+    if (!EFI_ERROR (Status)) {\r
+      HorizontalResolution = CURRENT_HORIZONTAL_RESOLUTION;\r
+      VerticalResolution   = CURRENT_VERTICAL_RESOLUTION;\r
+    } else {\r
       //\r
-      // Get the current mode information from the UGA Draw Protocol\r
+      // Try to set 800*600 which is required by UEFI/EFI spec\r
       //\r
-      Status = Private->UgaDraw->GetMode (\r
+      Status = Private->UgaDraw->SetMode (\r
                                   Private->UgaDraw,\r
-                                  &HorizontalResolution,\r
-                                  &VerticalResolution,\r
-                                  &ColorDepth,\r
-                                  &RefreshRate\r
+                                  HorizontalResolution,\r
+                                  VerticalResolution,\r
+                                  ColorDepth,\r
+                                  RefreshRate\r
                                   );\r
       if (EFI_ERROR (Status)) {\r
-        goto Error;\r
+        Status = Private->UgaDraw->GetMode (\r
+                                    Private->UgaDraw,\r
+                                    &HorizontalResolution,\r
+                                    &VerticalResolution,\r
+                                    &ColorDepth,\r
+                                    &RefreshRate\r
+                                    );\r
+        if (EFI_ERROR (Status)) {\r
+          goto Error;\r
+        }\r
       }\r
     }\r
   }\r
@@ -430,31 +455,47 @@ GraphicsConsoleControllerDriverStart (
     Private->ModeData[MaxMode].DeltaY     = (VerticalResolution - (50 * GLYPH_HEIGHT)) >> 1;\r
     MaxMode++;\r
   }\r
+\r
   //\r
-  // If the graphics mode is 800x600, than add a text mode that uses the entire display\r
+  // If it is not to support Mode #1 - 80x50, then skip it\r
   //\r
-  if (HorizontalResolution == 800 && VerticalResolution == 600) {\r
-\r
-    if (MaxMode < 2) {\r
-      Private->ModeData[MaxMode].Columns    = 0;\r
-      Private->ModeData[MaxMode].Rows       = 0;\r
-      Private->ModeData[MaxMode].GopWidth   = 800;\r
-      Private->ModeData[MaxMode].GopHeight  = 600;\r
-      Private->ModeData[MaxMode].GopModeNumber = ModeNumber;\r
-      Private->ModeData[MaxMode].DeltaX     = 0;\r
-      Private->ModeData[MaxMode].DeltaY     = 0;\r
-      MaxMode++;\r
-    }\r
+  if (MaxMode < 2) {\r
+    Private->ModeData[MaxMode].Columns    = 0;\r
+    Private->ModeData[MaxMode].Rows       = 0;\r
+    Private->ModeData[MaxMode].GopWidth   = HorizontalResolution;\r
+    Private->ModeData[MaxMode].GopHeight  = VerticalResolution;\r
+    Private->ModeData[MaxMode].GopModeNumber = ModeNumber;\r
+    Private->ModeData[MaxMode].DeltaX     = 0;\r
+    Private->ModeData[MaxMode].DeltaY     = 0;\r
+    MaxMode++;\r
+  }\r
+  \r
+  //\r
+  // Add Mode #2 that must be 100x31 (graphic mode >= 800x600)\r
+  //\r
+  if (Columns >= 100 && Rows >= 31) {  \r
+    Private->ModeData[MaxMode].GopWidth   = HorizontalResolution;\r
+    Private->ModeData[MaxMode].GopHeight  = VerticalResolution;\r
+    Private->ModeData[MaxMode].GopModeNumber = ModeNumber;\r
+    Private->ModeData[MaxMode].DeltaX     = (HorizontalResolution - (100 * GLYPH_WIDTH)) >> 1;\r
+    Private->ModeData[MaxMode].DeltaY     = (VerticalResolution - (31 * GLYPH_HEIGHT)) >> 1;\r
+    MaxMode++;\r
+  }\r
 \r
-    Private->ModeData[MaxMode].Columns    = 800 / GLYPH_WIDTH;\r
-    Private->ModeData[MaxMode].Rows       = 600 / GLYPH_HEIGHT;\r
-    Private->ModeData[MaxMode].GopWidth   = 800;\r
-    Private->ModeData[MaxMode].GopHeight  = 600;\r
+  //\r
+  // Add Mode #3 that uses the entire display for user-defined mode\r
+  //\r
+  if (HorizontalResolution > 800 && VerticalResolution > 600) {\r
+    Private->ModeData[MaxMode].Columns    = HorizontalResolution/GLYPH_WIDTH;\r
+    Private->ModeData[MaxMode].Rows       = VerticalResolution/GLYPH_HEIGHT;    \r
+    Private->ModeData[MaxMode].GopWidth   = HorizontalResolution;\r
+    Private->ModeData[MaxMode].GopHeight  = VerticalResolution;\r
     Private->ModeData[MaxMode].GopModeNumber = ModeNumber;\r
-    Private->ModeData[MaxMode].DeltaX     = (800 % GLYPH_WIDTH) >> 1;\r
-    Private->ModeData[MaxMode].DeltaY     = (600 % GLYPH_HEIGHT) >> 1;\r
+    Private->ModeData[MaxMode].DeltaX     = (HorizontalResolution % GLYPH_WIDTH) >> 1;\r
+    Private->ModeData[MaxMode].DeltaY     = (VerticalResolution % GLYPH_HEIGHT) >> 1;\r
     MaxMode++;\r
   }\r
+    \r
   //\r
   // Update the maximum number of modes\r
   //\r
@@ -587,6 +628,49 @@ GraphicsConsoleControllerDriverStop (
   return Status;\r
 }\r
 \r
+EFI_STATUS\r
+CheckModeSupported (\r
+  EFI_GRAPHICS_OUTPUT_PROTOCOL  *GraphicsOutput,\r
+  IN  UINT32  HorizontalResolution,\r
+  IN  UINT32  VerticalResolution,\r
+  OUT UINT32  *CurrentModeNumber\r
+  )\r
+{\r
+  UINT32     ModeNumber;\r
+  EFI_STATUS Status;\r
+  UINTN      SizeOfInfo;  \r
+  EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *Info;\r
+    \r
+  Status = EFI_SUCCESS;\r
+  \r
+  for (ModeNumber = 0; ModeNumber < GraphicsOutput->Mode->MaxMode; ModeNumber++) {\r
+    Status = GraphicsOutput->QueryMode (\r
+                       GraphicsOutput,\r
+                       ModeNumber,\r
+                       &SizeOfInfo,\r
+                       &Info\r
+                       );\r
+    if (!EFI_ERROR (Status)) {\r
+      if ((Info->HorizontalResolution == HorizontalResolution) &&\r
+          (Info->VerticalResolution == VerticalResolution)) {\r
+        Status = GraphicsOutput->SetMode (GraphicsOutput, ModeNumber);\r
+        if (!EFI_ERROR (Status)) {\r
+          gBS->FreePool (Info);\r
+          break;\r
+        }\r
+      }\r
+      gBS->FreePool (Info);\r
+    }\r
+  }\r
+  \r
+  if (ModeNumber == GraphicsOutput->Mode->MaxMode) {\r
+    Status = EFI_UNSUPPORTED;\r
+  }\r
+  \r
+  *CurrentModeNumber = ModeNumber;\r
+  return Status; \r
+}\r
+\r
 EFI_STATUS\r
 EfiLocateHiiProtocol (\r
   VOID\r
index 98780f704a2d41d114c0ccff18287998c5b8880c..f78c22c564dc02c155a18d95ed71720bd066f7b9 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2006, Intel Corporation                                                         \r
+Copyright (c) 2006 - 2008, Intel Corporation                                              \r
 All rights reserved. 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
@@ -177,6 +177,13 @@ GraphicsConsoleComponentNameGetControllerName (
 #define GLYPH_WIDTH   8\r
 #define GLYPH_HEIGHT  19\r
 \r
+//\r
+// User can define valid graphic resolution here\r
+// e.g. 640x480, 800x600, 1024x768...\r
+//\r
+#define CURRENT_HORIZONTAL_RESOLUTION  800\r
+#define CURRENT_VERTICAL_RESOLUTION    600\r
+\r
 typedef union {\r
   EFI_NARROW_GLYPH  NarrowGlyph;\r
   EFI_WIDE_GLYPH    WideGlyph;\r
@@ -200,7 +207,7 @@ typedef struct {
   UINT32  GopModeNumber;\r
 } GRAPHICS_CONSOLE_MODE_DATA;\r
 \r
-#define GRAPHICS_MAX_MODE 3\r
+#define GRAPHICS_MAX_MODE 4\r
 \r
 typedef struct {\r
   UINTN                            Signature;\r
index aaeca12100f488a632070dfd333caf62d9a150cf..8a38aa8026fcc443dd1ed8232ab7be6170ebf6b1 100644 (file)
@@ -489,8 +489,30 @@ TerminalDriverBindingStart (
   //\r
   // Simple Text Output Protocol\r
   //\r
+  TerminalDevice->SimpleTextOutput.Reset              = TerminalConOutReset;\r
+  TerminalDevice->SimpleTextOutput.OutputString       = TerminalConOutOutputString;\r
+  TerminalDevice->SimpleTextOutput.TestString         = TerminalConOutTestString;\r
+  TerminalDevice->SimpleTextOutput.QueryMode          = TerminalConOutQueryMode;\r
+  TerminalDevice->SimpleTextOutput.SetMode            = TerminalConOutSetMode;\r
+  TerminalDevice->SimpleTextOutput.SetAttribute       = TerminalConOutSetAttribute;\r
+  TerminalDevice->SimpleTextOutput.ClearScreen        = TerminalConOutClearScreen;\r
+  TerminalDevice->SimpleTextOutput.SetCursorPosition  = TerminalConOutSetCursorPosition;\r
+  TerminalDevice->SimpleTextOutput.EnableCursor       = TerminalConOutEnableCursor;\r
   TerminalDevice->SimpleTextOutput.Mode               = &TerminalDevice->SimpleTextOutputMode;\r
 \r
+  TerminalDevice->SimpleTextOutputMode.MaxMode        = 2;\r
+  //\r
+  // For terminal devices, cursor is always visible\r
+  //\r
+  TerminalDevice->SimpleTextOutputMode.CursorVisible  = TRUE;\r
+  Status = TerminalDevice->SimpleTextOutput.SetAttribute (\r
+                                                      &TerminalDevice->SimpleTextOutput,\r
+                                                      EFI_TEXT_ATTR (EFI_LIGHTGRAY, EFI_BLACK)\r
+                                                      );\r
+  if (EFI_ERROR (Status)) {\r
+    goto ReportError;\r
+  }\r
+\r
   Status = TerminalDevice->SimpleTextOutput.Reset (\r
                                               &TerminalDevice->SimpleTextOutput,\r
                                               FALSE\r
index b352c66991c4bd3b8e0455894e6bd4bdc3bf98e6..103adfbfee6127908094ac468722d655a78965a0 100644 (file)
@@ -143,6 +143,8 @@ typedef union {
 #define MODE0_COLUMN_COUNT        80\r
 #define MODE0_ROW_COUNT           25\r
 \r
+#define MODE1_COLUMN_COUNT        100\r
+#define MODE1_ROW_COUNT           31\r
 #define BACKSPACE                 8\r
 #define ESC                       27\r
 #define CSI                       0x9B\r
index 1931c2288638b1847ab8c1275ca3ffcd721618ef..74def9eb43e4dbb0fc368fad34c6ea4ea47e0455 100644 (file)
@@ -226,11 +226,11 @@ TerminalConOutOutputString (
   TerminalDevice = TERMINAL_CON_OUT_DEV_FROM_THIS (This);\r
 \r
   //\r
-  //  get current display mode\r
-  //  Terminal driver only support mode 0\r
+  //  Get current display mode\r
   //\r
   Mode = This->Mode;\r
-  if (Mode->Mode != 0) {\r
+  \r
+  if (Mode->Mode > 1) {\r
     return EFI_UNSUPPORTED;\r
   }\r
 \r
@@ -464,15 +464,17 @@ TerminalConOutQueryMode (
                 \r
 --*/\r
 {\r
-  if (This->Mode->MaxMode > 1) {\r
+  if (This->Mode->MaxMode > 2) {\r
     return EFI_DEVICE_ERROR;\r
   }\r
 \r
   if (ModeNumber == 0) {\r
-\r
     *Columns  = MODE0_COLUMN_COUNT;\r
     *Rows     = MODE0_ROW_COUNT;\r
-\r
+    return EFI_SUCCESS;\r
+  } else if (ModeNumber == 1) {  \r
+    *Columns  = MODE1_COLUMN_COUNT;\r
+    *Rows     = MODE1_ROW_COUNT;\r
     return EFI_SUCCESS;\r
   }\r
 \r
@@ -521,11 +523,14 @@ TerminalConOutSetMode (
   //\r
   TerminalDevice = TERMINAL_CON_OUT_DEV_FROM_THIS (This);\r
 \r
-  if (ModeNumber != 0) {\r
+  if (ModeNumber > 1) {\r
     return EFI_UNSUPPORTED;\r
   }\r
-\r
-  This->Mode->Mode = 0;\r
+  \r
+  //\r
+  // Set the current mode\r
+  //\r
+  This->Mode->Mode = (INT32) ModeNumber;\r
 \r
   This->ClearScreen (This);\r
 \r
@@ -537,7 +542,7 @@ TerminalConOutSetMode (
     return EFI_DEVICE_ERROR;\r
   }\r
 \r
-  This->Mode->Mode  = 0;\r
+  This->Mode->Mode  = (INT32) ModeNumber;\r
 \r
   Status            = This->ClearScreen (This);\r
   if (EFI_ERROR (Status)) {\r