diff options
| author | Liming Gao <gaoliming@byosoft.com.cn> | 2026-01-25 13:45:01 +0800 |
|---|---|---|
| committer | Liming Gao <gaoliming@byosoft.com.cn> | 2026-01-25 13:45:01 +0800 |
| commit | ab336fdef2776bdedf57a9849e66e3514233133f (patch) | |
| tree | 609504a09e2de337a7ee4083d852ab68c11072b6 | |
| parent | 229fbfde14a32435f1c0854e90312325b0f2aba5 (diff) | |
| download | edk2_master.tar.gz edk2_master.zip | |
MdeModulePkg HelloWorld: Add the display information for GOP resolutionedk2_master
Signed-off-by: Liming Gao <gaoliming@byosoft.com.cn>
| -rw-r--r-- | MdeModulePkg/Application/HelloWorld/HelloWorld.c | 41 |
1 files changed, 40 insertions, 1 deletions
diff --git a/MdeModulePkg/Application/HelloWorld/HelloWorld.c b/MdeModulePkg/Application/HelloWorld/HelloWorld.c index ab581c040c..763fce31e0 100644 --- a/MdeModulePkg/Application/HelloWorld/HelloWorld.c +++ b/MdeModulePkg/Application/HelloWorld/HelloWorld.c @@ -11,6 +11,8 @@ #include <Library/PcdLib.h>
#include <Library/UefiLib.h>
#include <Library/UefiApplicationEntryPoint.h>
+#include <Library/UefiBootServicesTableLib.h>
+#include <Protocol/GraphicsOutput.h>
//
// String token ID of help message text.
@@ -40,7 +42,11 @@ UefiMain ( IN EFI_SYSTEM_TABLE *SystemTable
)
{
- UINT32 Index;
+ UINT32 Index;
+ EFI_STATUS Status;
+ EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;
+ EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *ModeInfo;
+ UINTN SizeOfInfo;
Index = 0;
@@ -56,5 +62,38 @@ UefiMain ( }
}
+ //
+ // Get current screen resolution
+ //
+ Status = gBS->LocateProtocol(
+ &gEfiGraphicsOutputProtocolGuid,
+ NULL,
+ (VOID **)&GraphicsOutput
+ );
+
+ if (EFI_ERROR(Status)) {
+ Print(L"Failed to locate Graphics Output Protocol: %r\n", Status);
+ } else {
+ // Get current mode information
+ Status = GraphicsOutput->QueryMode(
+ GraphicsOutput,
+ GraphicsOutput->Mode->Mode,
+ &SizeOfInfo,
+ &ModeInfo
+ );
+
+ if (EFI_ERROR(Status)) {
+ Print(L"Failed to query current mode: %r\n", Status);
+ } else {
+ // Print current screen resolution
+ Print(L"Current Screen Resolution: %dx%d\n",
+ ModeInfo->HorizontalResolution,
+ ModeInfo->VerticalResolution);
+
+ // Free the buffer allocated by QueryMode
+ gBS->FreePool(ModeInfo);
+ }
+ }
+
return EFI_SUCCESS;
}
|
