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