[if !mso]>

RE: [EDK DEV] Problems in showing image in EFI shell

Subject: RE: [EDK DEV] Problems in showing image in EFI shell

From: "Li, Elvin" <elvin.li@intel.com>

To: <dev@edk.tianocore.org>

Date: 2008-01-19 02:55:39


      Did you use Console->SetMode (Console, EfiConsoleControlScreenGraphics); to change the console mode to graphics mode before using GOP?





From: [mailto:wilson100hong@gmail.com]
Sent: 2008
118 18:41
To: dev@edk.tianocore.org
Subject: [EDK DEV] Problems in showing image in EFI shell


Hello EDK developers,

     I come up with problems when dealing with graphics application in EFI. I have surveyed the related articles in mailing list but still cannt solve the problems. First I beiefly describe my development environment.

1. I use EDK-Dev snapshot20071112 with VC++ and WinDDK(build3790) to compile the application. The application is following the form in EDK_DG..My  application is running under EFI DUET shell, X64 platform.

2. I also included EFIshellLib functions and added necessary(I hope) information to the application's .inf file
#I added last 2 line because the linker cannot find correct directory of efishelllib.inf and related headerfiles if I put #shelllib too far away from current directory.

3. I use EFI_GRAPHICS_OUTPUT_PROTOCOL by following the sample code in <EDK>\Sample\Platform\Generic\Dxe\PlatformBds.c
   My test program is just to show a Red big retangle on the screen.  Here is my code(the variable declaration is ommited)
//-------------code begin-------------------//
//assign global
gST = SystemTable;
gBS = gST->BootServices;
gRT = gST->RuntimeServices;
EFI_SHELL_APP_INIT (ImageHandle, SystemTable);
Print(L"Test UGA and GOP\n");
UgaDraw = NULL;
Status = gBS->HandleProtocol (
                  &GraphicsOutput );
  if (EFI_ERROR (Status)) {
    GraphicsOutput = NULL;
  Status = gBS->HandleProtocol (
   if (EFI_ERROR (Status)) {
      return EFI_UNSUPPORTED;
if (GraphicsOutput != NULL) {
    SizeOfX = GraphicsOutput->Mode->Info->HorizontalResolution;
    SizeOfY = GraphicsOutput->Mode->Info->VerticalResolution;
    Print(L"SizeOfX:%d\n", SizeOfX);
    Print(L"SizeOfY:%d\n", SizeOfY);
  } else {
    Status = UgaDraw->GetMode (
                        &RefreshRate );
    if (EFI_ERROR (Status)) {
      return EFI_UNSUPPORTED;
  BlockWidth  = SizeOfX / 100;
  BlockHeight = SizeOfY / 50;
  PosX        = 0;
  PosY        = SizeOfY * 48 / 50;
   gBS->SetMem (&Color, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL), 0xff);
// I want a RED rectangle  
if (GraphicsOutput != NULL) {
      Status = GraphicsOutput->Blt (
                           PosY - GLYPH_HEIGHT - 1,
                          SizeOfY - (PosY - GLYPH_HEIGHT - 1),
                          SizeOfX * sizeof (EFI_UGA_PIXEL));
    } else {
      Status = UgaDraw->Blt (
                          (EFI_UGA_PIXEL *) &Color,
                          PosY - GLYPH_HEIGHT - 1,
                          SizeOfY - (PosY - GLYPH_HEIGHT - 1),
                          SizeOfX * sizeof (EFI_UGA_PIXEL)
//show image until get a key
WaitForSingleEvent (gST->ConIn->WaitForKey, 0);
  return Status;
//-------------code end-------------------//
4.Result: I expected to see some red color when I execute the application. But the only result showing on the screen is the string"Test UGA and GOP" and value SizeOfX=800, SizeOfY=600  and the program is waitng me to stroke a key. There is no red even a pixel on the screen. I had tried to unlock logo.inf in DUET.dsc, but no logo shows on screen, too. There is no error message output by EFI function. Anyway , the program seems just neglect my "Blt" function.

    If you can point out flaws in my procedures, give me hints with some executable samples, or remind me some  initializations before using GOP, that's a huge help on me. Thanks.

Wilson Hong