[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

Hi:

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

 

Thanks

Elvin

 


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
[includes.common]
  .
  ..\Inc
  ..\Library
  $(EDK_SOURCE)\Foundation
  $(EDK_SOURCE)\Foundation\Include
  $(EDK_SOURCE)\Foundation\Include\IndustryStandard
  $(EDK_SOURCE)\Foundation\Efi
  $(EDK_SOURCE)\Foundation\Efi\Include
  $(EDK_SOURCE)\Foundation\FrameWork
  $(EDK_SOURCE)\Foundation\FrameWork\Include
  $(EDK_SOURCE)\Foundation\Core\Dxe
  $(DEST_DIR)\
  $(EDK_SOURCE)\Sample\Platform\DUET\Test\Shell\inc
  $(EDK_SOURCE)\Sample\Platform\DUET\Test\Shell\Library  
#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.
[libraries.common]  
  EfiShellLib
  EfiDriverLib
  EdkProtocolLib
  EdkFrameworkProtocolLib
  EfiProtocolLib
  EdkGuidLib
  EdkFrameworkGuidLib
  ArchProtocolLib

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;
//initial
EFI_SHELL_APP_INIT (ImageHandle, SystemTable);
Print(L"Test UGA and GOP\n");
UgaDraw = NULL;
Status = gBS->HandleProtocol (
                  gST->ConsoleOutHandle,
                  &gEfiGraphicsOutputProtocolGuid,
                  &GraphicsOutput );
  if (EFI_ERROR (Status)) {
    GraphicsOutput = NULL;
  Status = gBS->HandleProtocol (
                    gST->ConsoleOutHandle,
                    &gEfiUgaDrawProtocolGuid,
                    &UgaDraw);
   if (EFI_ERROR (Status)) {
      Print(L"error");
      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 (
                        UgaDraw,
                        &SizeOfX,
                        &SizeOfY,
                        &ColorDepth,
                        &RefreshRate );
    if (EFI_ERROR (Status)) {
      Print(L"error");
      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  
Color.Green=0;
Color.Blue=0;
Color.Red=255;
if (GraphicsOutput != NULL) {
      Status = GraphicsOutput->Blt (
                          GraphicsOutput,
                          &Color,
                          EfiBltVideoFill,
                          0,
                          0,
                          0,
                           PosY - GLYPH_HEIGHT - 1,
                          SizeOfX,
                          SizeOfY - (PosY - GLYPH_HEIGHT - 1),
                          SizeOfX * sizeof (EFI_UGA_PIXEL));
    } else {
      Status = UgaDraw->Blt (
                          UgaDraw,
                          (EFI_UGA_PIXEL *) &Color,
                          EfiUgaVideoFill,
                          0,
                          0,
                          0,
                          PosY - GLYPH_HEIGHT - 1,
                          SizeOfX,
                          SizeOfY - (PosY - GLYPH_HEIGHT - 1),
                          SizeOfX * sizeof (EFI_UGA_PIXEL)
                          );
    }
//show image until get a key
WaitForSingleEvent (gST->ConIn->WaitForKey, 0);
gST->ConIn->ReadKeyStroke(ST->ConIn,&key);
  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
1/18/2008