public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH 00/13] Add HiiImageEx implementation and demonstrate in Nt32
@ 2016-09-23  8:25 Ruiyu Ni
  2016-09-23  8:25 ` [PATCH 01/13] MdeModulePkg/HiiDatabase: Refine GetImageIdOrAddress Ruiyu Ni
                   ` (13 more replies)
  0 siblings, 14 replies; 15+ messages in thread
From: Ruiyu Ni @ 2016-09-23  8:25 UTC (permalink / raw)
  To: edk2-devel

The total 13 commits can be reviewed in following url:
https://github.com/niruiyu/edk2/commits/HiiImage

Ruiyu Ni (13):
  MdeModulePkg/HiiDatabase: Refine GetImageIdOrAddress
  MdeModulePkg/HiiDatabase: Move common code to LocatePackageList()
  MdeModulePkg/HiiDatabase: Refine HiiNewImage()
  MdeModulePkg/HiiDatabase: Refine HiiGetImage()
  MdeModulePkg/HiiDatabase: Refine HiiSetImage()
  MdeModulePkg/HiiDatabase: Refine HiiDrawImage()
  MdemodulePkg/HiiDatabase: Correct typo in comments.
  MdeModulePkg/HiiDatabase: Update HiiImage to support PNG/JPEG
  MdeModulePkg/HiiDatabase: Add HiiImageEx implementation.
  Nt32Pkg/PlatformBds: Do not call BootLogoEnableLogo
  MdeModulePkg/BootLogoLib&PlatformLogo: Use HII data types in
    parameters
  MdeModulePkg/Logo: Add LogoDxe module
  Nt32Pkg: Use the new LogoDxe driver

 MdeModulePkg/Include/Library/BootLogoLib.h         |  19 +-
 MdeModulePkg/Include/Protocol/PlatformLogo.h       |  18 +-
 MdeModulePkg/Library/BootLogoLib/BootLogoLib.c     | 204 +++----
 MdeModulePkg/Library/BootLogoLib/BootLogoLib.inf   |   6 +-
 MdeModulePkg/Logo/Logo.c                           | 156 ++++++
 MdeModulePkg/Logo/Logo.idf                         |  18 +
 MdeModulePkg/Logo/LogoDxe.inf                      |  60 ++
 MdeModulePkg/Logo/LogoDxe.uni                      |  21 +
 MdeModulePkg/Logo/LogoDxeExtra.uni                 |  19 +
 .../HiiDatabaseDxe/ConfigKeywordHandler.c          |  36 +-
 .../Universal/HiiDatabaseDxe/ConfigRouting.c       |  58 +-
 MdeModulePkg/Universal/HiiDatabaseDxe/Database.c   |  16 +-
 MdeModulePkg/Universal/HiiDatabaseDxe/Font.c       |  32 +-
 .../Universal/HiiDatabaseDxe/HiiDatabase.h         | 292 +++++++++-
 .../Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf    |   7 +-
 .../Universal/HiiDatabaseDxe/HiiDatabaseEntry.c    |  34 +-
 MdeModulePkg/Universal/HiiDatabaseDxe/Image.c      | 619 ++++++++++-----------
 MdeModulePkg/Universal/HiiDatabaseDxe/ImageEx.c    | 397 +++++++++++++
 .../PlatformBootManagerLib/PlatformBootManager.c   |   4 +-
 Nt32Pkg/Nt32Pkg.dsc                                |   7 +-
 Nt32Pkg/Nt32Pkg.fdf                                |   5 +-
 21 files changed, 1432 insertions(+), 596 deletions(-)
 create mode 100644 MdeModulePkg/Logo/Logo.c
 create mode 100644 MdeModulePkg/Logo/Logo.idf
 create mode 100644 MdeModulePkg/Logo/LogoDxe.inf
 create mode 100644 MdeModulePkg/Logo/LogoDxe.uni
 create mode 100644 MdeModulePkg/Logo/LogoDxeExtra.uni
 create mode 100644 MdeModulePkg/Universal/HiiDatabaseDxe/ImageEx.c

-- 
2.9.0.windows.1



^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH 01/13] MdeModulePkg/HiiDatabase: Refine GetImageIdOrAddress
  2016-09-23  8:25 [PATCH 00/13] Add HiiImageEx implementation and demonstrate in Nt32 Ruiyu Ni
@ 2016-09-23  8:25 ` Ruiyu Ni
  2016-09-23  8:25 ` [PATCH 02/13] MdeModulePkg/HiiDatabase: Move common code to LocatePackageList() Ruiyu Ni
                   ` (12 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: Ruiyu Ni @ 2016-09-23  8:25 UTC (permalink / raw)
  To: edk2-devel; +Cc: Liming Gao, Eric Dong, Dandan Bi

Contributed-under: TianoCore Contribution Agreement 1.0
Cc: Liming Gao <liming.gao@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Dandan Bi <dandan.bi@intel.com>
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
---
 MdeModulePkg/Universal/HiiDatabaseDxe/Database.c   |   2 +-
 .../Universal/HiiDatabaseDxe/HiiDatabase.h         |   2 +-
 MdeModulePkg/Universal/HiiDatabaseDxe/Image.c      | 135 ++++++++++-----------
 3 files changed, 63 insertions(+), 76 deletions(-)

diff --git a/MdeModulePkg/Universal/HiiDatabaseDxe/Database.c b/MdeModulePkg/Universal/HiiDatabaseDxe/Database.c
index d1eb881..984c5d2 100644
--- a/MdeModulePkg/Universal/HiiDatabaseDxe/Database.c
+++ b/MdeModulePkg/Universal/HiiDatabaseDxe/Database.c
@@ -1552,7 +1552,7 @@ InsertImagePackage (
   if (ImageInfoOffset != 0) {
     ImageSize = ImagePackage->ImagePkgHdr.Header.Length -
                 sizeof (EFI_HII_IMAGE_PACKAGE_HDR) - PaletteSize;
-    ImagePackage->ImageBlock = (UINT8 *) AllocateZeroPool (ImageSize);
+    ImagePackage->ImageBlock = AllocateZeroPool (ImageSize);
     if (ImagePackage->ImageBlock == NULL) {
       FreePool (ImagePackage->PaletteBlock);
       FreePool (ImagePackage);
diff --git a/MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabase.h b/MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabase.h
index 1b0f7f6..0ca2fba 100644
--- a/MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabase.h
+++ b/MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabase.h
@@ -223,7 +223,7 @@ typedef struct _HII_IMAGE_PACKAGE_INSTANCE {
   EFI_HII_IMAGE_PACKAGE_HDR             ImagePkgHdr;
   UINT32                                ImageBlockSize;
   UINT32                                PaletteInfoSize;
-  UINT8                                 *ImageBlock;
+  EFI_HII_IMAGE_BLOCK                   *ImageBlock;
   UINT8                                 *PaletteBlock;
 } HII_IMAGE_PACKAGE_INSTANCE;
 
diff --git a/MdeModulePkg/Universal/HiiDatabaseDxe/Image.c b/MdeModulePkg/Universal/HiiDatabaseDxe/Image.c
index 612d57a..5bdeacc 100644
--- a/MdeModulePkg/Universal/HiiDatabaseDxe/Image.c
+++ b/MdeModulePkg/Universal/HiiDatabaseDxe/Image.c
@@ -24,51 +24,44 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 
   This is a internal function.
 
-  @param ImageBlock      Points to the beginning of a series of image blocks stored in order.
+  @param ImageBlocks     Points to the beginning of a series of image blocks stored in order.
   @param ImageId         If input ImageId is 0, output the image id of the EFI_HII_IIBT_END_BLOCK;
                          else use this id to find its corresponding image block address.
 
   @return The image block address when input ImageId is not zero; otherwise return NULL.
 
 **/
-UINT8*
+EFI_HII_IMAGE_BLOCK *
 GetImageIdOrAddress (
-  IN  UINT8           *ImageBlock,
-  IN OUT EFI_IMAGE_ID *ImageId
+  IN EFI_HII_IMAGE_BLOCK *ImageBlocks,
+  IN OUT EFI_IMAGE_ID    *ImageId
   )
 {
   EFI_IMAGE_ID                   ImageIdCurrent;
-  UINT8                          *ImageBlockHdr;
-  UINT8                          Length8;
-  UINT16                         Length16;
-  UINT32                         Length32;
-  EFI_HII_IIBT_IMAGE_1BIT_BLOCK  Iibt1bit;
-  EFI_HII_IIBT_IMAGE_4BIT_BLOCK  Iibt4bit;
-  EFI_HII_IIBT_IMAGE_8BIT_BLOCK  Iibt8bit;
-  UINT16                         Width;
-  UINT16                         Height;
-
-  ASSERT (ImageBlock != NULL && ImageId != NULL);
-
-  ImageBlockHdr  = ImageBlock;
-  ImageIdCurrent = 1;
-
-  while (((EFI_HII_IMAGE_BLOCK *) ImageBlock)->BlockType != EFI_HII_IIBT_END) {
-    if (*ImageId > 0) {
+  EFI_HII_IMAGE_BLOCK            *CurrentImageBlock;
+  UINTN                          Length;
+
+  ASSERT (ImageBlocks != NULL && ImageId != NULL);
+  CurrentImageBlock = ImageBlocks;
+  ImageIdCurrent    = 1;
+
+  while (CurrentImageBlock->BlockType != EFI_HII_IIBT_END) {
+    if (*ImageId != 0) {
       if (*ImageId == ImageIdCurrent) {
         //
         // If the found image block is a duplicate block, update the ImageId to
         // find the previous defined image block.
         //
-        if (((EFI_HII_IMAGE_BLOCK *) ImageBlock)->BlockType == EFI_HII_IIBT_DUPLICATE) {
-          CopyMem (ImageId, ImageBlock + sizeof (EFI_HII_IMAGE_BLOCK), sizeof (EFI_IMAGE_ID));
+        if (CurrentImageBlock->BlockType == EFI_HII_IIBT_DUPLICATE) {
+          *ImageId = ReadUnaligned16 (&((EFI_HII_IIBT_DUPLICATE_BLOCK *) CurrentImageBlock)->ImageId);
           ASSERT (*ImageId != ImageIdCurrent);
-          ImageBlock = ImageBlockHdr;
+          ASSERT (*ImageId != 0);
+          CurrentImageBlock = ImageBlocks;
           ImageIdCurrent = 1;
           continue;
         }
 
-        return ImageBlock;
+        return CurrentImageBlock;
       }
       if (*ImageId < ImageIdCurrent) {
         //
@@ -77,86 +70,75 @@ GetImageIdOrAddress (
         return NULL;
       }
     }
-    switch (((EFI_HII_IMAGE_BLOCK *) ImageBlock)->BlockType) {
+    switch (CurrentImageBlock->BlockType) {
     case EFI_HII_IIBT_EXT1:
-      Length8 = *(UINT8*)((UINTN)ImageBlock + sizeof (EFI_HII_IMAGE_BLOCK) + sizeof (UINT8));
-      ImageBlock += Length8;
+      Length = ((EFI_HII_IIBT_EXT1_BLOCK *) CurrentImageBlock)->Length;
       break;
     case EFI_HII_IIBT_EXT2:
-      CopyMem (
-        &Length16,
-        (UINT8*)((UINTN)ImageBlock + sizeof (EFI_HII_IMAGE_BLOCK) + sizeof (UINT8)),
-        sizeof (UINT16)
-        );
-      ImageBlock += Length16;
+      Length = ReadUnaligned16 (&((EFI_HII_IIBT_EXT2_BLOCK *) CurrentImageBlock)->Length);
       break;
     case EFI_HII_IIBT_EXT4:
-      CopyMem (
-        &Length32,
-        (UINT8*)((UINTN)ImageBlock + sizeof (EFI_HII_IMAGE_BLOCK) + sizeof (UINT8)),
-        sizeof (UINT32)
-        );
-      ImageBlock += Length32;
+      Length = ReadUnaligned32 (&((EFI_HII_IIBT_EXT4_BLOCK *) CurrentImageBlock)->Length);
       break;
 
     case EFI_HII_IIBT_IMAGE_1BIT:
     case EFI_HII_IIBT_IMAGE_1BIT_TRANS:
-      CopyMem (&Iibt1bit, ImageBlock, sizeof (EFI_HII_IIBT_IMAGE_1BIT_BLOCK));
-      ImageBlock += sizeof (EFI_HII_IIBT_IMAGE_1BIT_BLOCK) - sizeof (UINT8) +
-                    BITMAP_LEN_1_BIT (Iibt1bit.Bitmap.Width, Iibt1bit.Bitmap.Height);
+      Length = sizeof (EFI_HII_IIBT_IMAGE_1BIT_BLOCK) - sizeof (UINT8) +
+               BITMAP_LEN_1_BIT (
+                 ReadUnaligned16 (&((EFI_HII_IIBT_IMAGE_1BIT_BLOCK *) CurrentImageBlock)->Bitmap.Width),
+                 ReadUnaligned16 (&((EFI_HII_IIBT_IMAGE_1BIT_BLOCK *) CurrentImageBlock)->Bitmap.Height)
+                 );
       ImageIdCurrent++;
       break;
 
     case EFI_HII_IIBT_IMAGE_4BIT:
     case EFI_HII_IIBT_IMAGE_4BIT_TRANS:
-      CopyMem (&Iibt4bit, ImageBlock, sizeof (EFI_HII_IIBT_IMAGE_4BIT_BLOCK));
-      ImageBlock += sizeof (EFI_HII_IIBT_IMAGE_4BIT_BLOCK) - sizeof (UINT8) +
-                    BITMAP_LEN_4_BIT (Iibt4bit.Bitmap.Width, Iibt4bit.Bitmap.Height);
+      Length = sizeof (EFI_HII_IIBT_IMAGE_4BIT_BLOCK) - sizeof (UINT8) +
+               BITMAP_LEN_4_BIT (
+                 ReadUnaligned16 (&((EFI_HII_IIBT_IMAGE_4BIT_BLOCK *) CurrentImageBlock)->Bitmap.Width),
+                 ReadUnaligned16 (&((EFI_HII_IIBT_IMAGE_4BIT_BLOCK *) CurrentImageBlock)->Bitmap.Height)
+                 );
       ImageIdCurrent++;
       break;
 
     case EFI_HII_IIBT_IMAGE_8BIT:
     case EFI_HII_IIBT_IMAGE_8BIT_TRANS:
-      CopyMem (&Iibt8bit, ImageBlock, sizeof (EFI_HII_IIBT_IMAGE_8BIT_BLOCK));
-      ImageBlock += sizeof (EFI_HII_IIBT_IMAGE_8BIT_BLOCK) - sizeof (UINT8) +
-                    BITMAP_LEN_8_BIT (Iibt8bit.Bitmap.Width, Iibt8bit.Bitmap.Height);
+      Length = sizeof (EFI_HII_IIBT_IMAGE_8BIT_BLOCK) - sizeof (UINT8) +
+               BITMAP_LEN_8_BIT (
+                 ReadUnaligned16 (&((EFI_HII_IIBT_IMAGE_8BIT_BLOCK *) CurrentImageBlock)->Bitmap.Width),
+                 ReadUnaligned16 (&((EFI_HII_IIBT_IMAGE_8BIT_BLOCK *) CurrentImageBlock)->Bitmap.Height)
+                 );
       ImageIdCurrent++;
       break;
 
     case EFI_HII_IIBT_IMAGE_24BIT:
     case EFI_HII_IIBT_IMAGE_24BIT_TRANS:
-      CopyMem (&Width, ImageBlock + sizeof (EFI_HII_IMAGE_BLOCK), sizeof (UINT16));
-      CopyMem (
-        &Height,
-        ImageBlock + sizeof (EFI_HII_IMAGE_BLOCK) + sizeof (UINT16),
-        sizeof (UINT16)
-        );
-      ImageBlock += sizeof (EFI_HII_IIBT_IMAGE_24BIT_BLOCK) - sizeof (EFI_HII_RGB_PIXEL) +
-                    BITMAP_LEN_24_BIT (Width, Height);
+      Length = sizeof (EFI_HII_IIBT_IMAGE_24BIT_BLOCK) - sizeof (EFI_HII_RGB_PIXEL) +
+               BITMAP_LEN_24_BIT (
+                 ReadUnaligned16 (&((EFI_HII_IIBT_IMAGE_24BIT_BLOCK *) CurrentImageBlock)->Bitmap.Width),
+                 ReadUnaligned16 (&((EFI_HII_IIBT_IMAGE_24BIT_BLOCK *) CurrentImageBlock)->Bitmap.Height)
+                 );
       ImageIdCurrent++;
       break;
 
     case EFI_HII_IIBT_DUPLICATE:
-      ImageBlock += sizeof (EFI_HII_IIBT_DUPLICATE_BLOCK);
+      Length = sizeof (EFI_HII_IIBT_DUPLICATE_BLOCK);
       ImageIdCurrent++;
       break;
 
     case EFI_HII_IIBT_IMAGE_JPEG:
-      CopyMem (&Length32, ImageBlock + sizeof (EFI_HII_IMAGE_BLOCK), sizeof (UINT32));
-      ImageBlock += Length32;
+      Length = ReadUnaligned32 (&((EFI_HII_IIBT_JPEG_BLOCK *) CurrentImageBlock)->Size);
       ImageIdCurrent++;
       break;
 
     case EFI_HII_IIBT_SKIP1:
-      Length8 = *(ImageBlock + sizeof (EFI_HII_IMAGE_BLOCK));
-      ImageBlock += sizeof (EFI_HII_IIBT_SKIP1_BLOCK);
-      ImageIdCurrent = (UINT16) (ImageIdCurrent + Length8);
+      Length = sizeof (EFI_HII_IIBT_SKIP1_BLOCK);
+      ImageIdCurrent += ((EFI_HII_IIBT_SKIP1_BLOCK *) CurrentImageBlock)->SkipCount;
       break;
 
     case EFI_HII_IIBT_SKIP2:
-      CopyMem (&Length16, ImageBlock + sizeof (EFI_HII_IMAGE_BLOCK), sizeof (UINT16));
-      ImageBlock += sizeof (EFI_HII_IIBT_SKIP2_BLOCK);
-      ImageIdCurrent = (UINT16) (ImageIdCurrent + Length16);
+      Length = sizeof (EFI_HII_IIBT_SKIP2_BLOCK);
+      ImageIdCurrent += ReadUnaligned16 (&((EFI_HII_IIBT_SKIP2_BLOCK *) CurrentImageBlock)->SkipCount);
       break;
 
     default:
@@ -164,7 +146,12 @@ GetImageIdOrAddress (
       // Unknown image blocks can not be skipped, processing halts.
       //
       ASSERT (FALSE);
+      Length = 0;
+      break;
     }
+
+    CurrentImageBlock = (EFI_HII_IMAGE_BLOCK *) ((UINT8 *) CurrentImageBlock + Length);
+
   }
 
   //
@@ -172,7 +159,7 @@ GetImageIdOrAddress (
   //
   if (*ImageId == 0) {
     *ImageId = ImageIdCurrent;
-    return ImageBlock;
+    return CurrentImageBlock;
   }
 
   return NULL;
@@ -689,7 +676,7 @@ HiiNewImage (
       ImagePackage->ImageBlockSize - sizeof (EFI_HII_IIBT_END_BLOCK)
       );
     FreePool (ImagePackage->ImageBlock);
-    ImagePackage->ImageBlock = ImageBlock;
+    ImagePackage->ImageBlock = (EFI_HII_IMAGE_BLOCK *) ImageBlock;
     ImageBlock += ImagePackage->ImageBlockSize - sizeof (EFI_HII_IIBT_END_BLOCK);
     //
     // Temp memory to store new block.
@@ -741,12 +728,12 @@ HiiNewImage (
     // Fill in image blocks.
     //
     ImagePackage->ImageBlockSize = (UINT32) BlockSize;
-    ImagePackage->ImageBlock = (UINT8 *) AllocateZeroPool (BlockSize);
+    ImagePackage->ImageBlock = AllocateZeroPool (BlockSize);
     if (ImagePackage->ImageBlock == NULL) {
       FreePool (ImagePackage);
       return EFI_OUT_OF_RESOURCES;
     }
-    ImageBlock = ImagePackage->ImageBlock;
+    ImageBlock = (UINT8 *) ImagePackage->ImageBlock;
 
     //
     // Temp memory to store new block.
@@ -885,7 +872,7 @@ HiiGetImage (
   // Find the image block specified by ImageId
   //
   LocalImageId = ImageId;
-  ImageBlock = GetImageIdOrAddress (ImagePackage->ImageBlock, &LocalImageId);
+  ImageBlock = (UINT8 *) GetImageIdOrAddress (ImagePackage->ImageBlock, &LocalImageId);
   if (ImageBlock == NULL) {
     return EFI_NOT_FOUND;
   }
@@ -1083,7 +1070,7 @@ HiiSetImage (
   // Find the image block specified by ImageId
   //
   LocalImageId = ImageId;
-  ImageBlock = GetImageIdOrAddress (ImagePackage->ImageBlock, &LocalImageId);
+  ImageBlock = (UINT8 *) GetImageIdOrAddress (ImagePackage->ImageBlock, &LocalImageId);
   if (ImageBlock == NULL) {
     return EFI_NOT_FOUND;
   }
@@ -1171,7 +1158,7 @@ HiiSetImage (
   }
 
   BlockPtr  = Block;
-  Part1Size = (UINT32) (ImageBlock - ImagePackage->ImageBlock);
+  Part1Size = (UINT32) (ImageBlock - (UINT8 *) ImagePackage->ImageBlock);
   Part2Size = ImagePackage->ImageBlockSize - Part1Size - OldBlockSize;
   CopyMem (BlockPtr, ImagePackage->ImageBlock, Part1Size);
   BlockPtr += Part1Size;
@@ -1181,7 +1168,7 @@ HiiSetImage (
 
   FreePool (ImagePackage->ImageBlock);
   FreePool (NewBlock);
-  ImagePackage->ImageBlock     = Block;
+  ImagePackage->ImageBlock     = (EFI_HII_IMAGE_BLOCK *) Block;
   ImagePackage->ImageBlockSize = BlockSize;
   ImagePackage->ImagePkgHdr.Header.Length += NewBlockSize - OldBlockSize;
   PackageListNode->PackageListHdr.PackageLength += NewBlockSize - OldBlockSize;
-- 
2.9.0.windows.1



^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 02/13] MdeModulePkg/HiiDatabase: Move common code to LocatePackageList()
  2016-09-23  8:25 [PATCH 00/13] Add HiiImageEx implementation and demonstrate in Nt32 Ruiyu Ni
  2016-09-23  8:25 ` [PATCH 01/13] MdeModulePkg/HiiDatabase: Refine GetImageIdOrAddress Ruiyu Ni
@ 2016-09-23  8:25 ` Ruiyu Ni
  2016-09-23  8:25 ` [PATCH 03/13] MdeModulePkg/HiiDatabase: Refine HiiNewImage() Ruiyu Ni
                   ` (11 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: Ruiyu Ni @ 2016-09-23  8:25 UTC (permalink / raw)
  To: edk2-devel; +Cc: Liming Gao, Eric Dong, Dandan Bi

Contributed-under: TianoCore Contribution Agreement 1.0
Cc: Liming Gao <liming.gao@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Dandan Bi <dandan.bi@intel.com>
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
---
 MdeModulePkg/Universal/HiiDatabaseDxe/Image.c | 88 +++++++++++----------------
 1 file changed, 34 insertions(+), 54 deletions(-)

diff --git a/MdeModulePkg/Universal/HiiDatabaseDxe/Image.c b/MdeModulePkg/Universal/HiiDatabaseDxe/Image.c
index 5bdeacc..b72d556 100644
--- a/MdeModulePkg/Universal/HiiDatabaseDxe/Image.c
+++ b/MdeModulePkg/Universal/HiiDatabaseDxe/Image.c
@@ -569,6 +569,37 @@ ImageToBlt (
   return EFI_SUCCESS;
 }
 
+/**
+  Return the HII package list identified by PackageList HII handle.
+
+  @param Database    Pointer to HII database list header.
+  @param PackageList HII handle of the package list to locate.
+
+  @retval The HII package list instance.
+**/
+HII_DATABASE_PACKAGE_LIST_INSTANCE *
+LocatePackageList (  
+  IN  LIST_ENTRY                     *Database,
+  IN  EFI_HII_HANDLE                 PackageList
+  )
+{
+  LIST_ENTRY                         *Link;
+  HII_DATABASE_RECORD                *Record;
+
+  //
+  // Get the specified package list and image package.
+  //
+  for (Link = GetFirstNode (Database);
+       !IsNull (Database, Link);
+       Link = GetNextNode (Database, Link)
+      ) {
+    Record = CR (Link, HII_DATABASE_RECORD, DatabaseEntry, HII_DATABASE_RECORD_SIGNATURE);
+    if (Record->Handle == PackageList) {
+      return Record->PackageList;
+    }
+  }
+  return NULL;
+}
 
 /**
   This function adds the image Image to the group of images owned by PackageList, and returns
@@ -598,8 +629,6 @@ HiiNewImage (
   )
 {
   HII_DATABASE_PRIVATE_DATA           *Private;
-  LIST_ENTRY                          *Link;
-  HII_DATABASE_RECORD                 *DatabaseRecord;
   HII_DATABASE_PACKAGE_LIST_INSTANCE  *PackageListNode;
   HII_IMAGE_PACKAGE_INSTANCE          *ImagePackage;
   UINT8                               *ImageBlock;
@@ -618,24 +647,7 @@ HiiNewImage (
   }
 
   Private = HII_IMAGE_DATABASE_PRIVATE_DATA_FROM_THIS (This);
-
-  //
-  // Get the specified package list
-  //
-
-  PackageListNode = NULL;
-
-  for (Link = Private->DatabaseList.ForwardLink;
-       Link != &Private->DatabaseList;
-       Link = Link->ForwardLink
-      ) {
-    DatabaseRecord = CR (Link, HII_DATABASE_RECORD, DatabaseEntry, HII_DATABASE_RECORD_SIGNATURE);
-    if (DatabaseRecord->Handle == PackageList) {
-      PackageListNode = DatabaseRecord->PackageList;
-      break;
-    }
-  }
-
+  PackageListNode = LocatePackageList (&Private->DatabaseList, PackageList);
   if (PackageListNode == NULL) {
     return EFI_NOT_FOUND;
   }
@@ -820,8 +832,6 @@ HiiGetImage (
   )
 {
   HII_DATABASE_PRIVATE_DATA           *Private;
-  LIST_ENTRY                          *Link;
-  HII_DATABASE_RECORD                 *DatabaseRecord;
   HII_DATABASE_PACKAGE_LIST_INSTANCE  *PackageListNode;
   HII_IMAGE_PACKAGE_INSTANCE          *ImagePackage;
   UINT8                               *ImageBlock;
@@ -845,21 +855,7 @@ HiiGetImage (
   }
 
   Private = HII_IMAGE_DATABASE_PRIVATE_DATA_FROM_THIS (This);
-
-  //
-  // Get the specified package list and image package.
-  //
-  PackageListNode = NULL;
-  for (Link = Private->DatabaseList.ForwardLink;
-       Link != &Private->DatabaseList;
-       Link = Link->ForwardLink
-      ) {
-    DatabaseRecord = CR (Link, HII_DATABASE_RECORD, DatabaseEntry, HII_DATABASE_RECORD_SIGNATURE);
-    if (DatabaseRecord->Handle == PackageList) {
-      PackageListNode = DatabaseRecord->PackageList;
-      break;
-    }
-  }
+  PackageListNode = LocatePackageList (&Private->DatabaseList, PackageList);
   if (PackageListNode == NULL) {
     return EFI_NOT_FOUND;
   }
@@ -1011,8 +1007,6 @@ HiiSetImage (
   )
 {
   HII_DATABASE_PRIVATE_DATA           *Private;
-  LIST_ENTRY                          *Link;
-  HII_DATABASE_RECORD                 *DatabaseRecord;
   HII_DATABASE_PACKAGE_LIST_INSTANCE  *PackageListNode;
   HII_IMAGE_PACKAGE_INSTANCE          *ImagePackage;
   UINT8                               *ImageBlock;
@@ -1043,21 +1037,7 @@ HiiSetImage (
   }
 
   Private = HII_IMAGE_DATABASE_PRIVATE_DATA_FROM_THIS (This);
-
-  //
-  // Get the specified package list and image package.
-  //
-  PackageListNode = NULL;
-  for (Link = Private->DatabaseList.ForwardLink;
-       Link != &Private->DatabaseList;
-       Link = Link->ForwardLink
-      ) {
-    DatabaseRecord = CR (Link, HII_DATABASE_RECORD, DatabaseEntry, HII_DATABASE_RECORD_SIGNATURE);
-    if (DatabaseRecord->Handle == PackageList) {
-      PackageListNode = DatabaseRecord->PackageList;
-      break;
-    }
-  }
+  PackageListNode = LocatePackageList (&Private->DatabaseList, PackageList);
   if (PackageListNode == NULL) {
     return EFI_NOT_FOUND;
   }
-- 
2.9.0.windows.1



^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 03/13] MdeModulePkg/HiiDatabase: Refine HiiNewImage()
  2016-09-23  8:25 [PATCH 00/13] Add HiiImageEx implementation and demonstrate in Nt32 Ruiyu Ni
  2016-09-23  8:25 ` [PATCH 01/13] MdeModulePkg/HiiDatabase: Refine GetImageIdOrAddress Ruiyu Ni
  2016-09-23  8:25 ` [PATCH 02/13] MdeModulePkg/HiiDatabase: Move common code to LocatePackageList() Ruiyu Ni
@ 2016-09-23  8:25 ` Ruiyu Ni
  2016-09-23  8:25 ` [PATCH 04/13] MdeModulePkg/HiiDatabase: Refine HiiGetImage() Ruiyu Ni
                   ` (10 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: Ruiyu Ni @ 2016-09-23  8:25 UTC (permalink / raw)
  To: edk2-devel; +Cc: Liming Gao, Eric Dong, Dandan Bi

Contributed-under: TianoCore Contribution Agreement 1.0
Cc: Liming Gao <liming.gao@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Dandan Bi <dandan.bi@intel.com>
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
---
 MdeModulePkg/Universal/HiiDatabaseDxe/Image.c | 83 +++++++++------------------
 1 file changed, 27 insertions(+), 56 deletions(-)

diff --git a/MdeModulePkg/Universal/HiiDatabaseDxe/Image.c b/MdeModulePkg/Universal/HiiDatabaseDxe/Image.c
index b72d556..9175ec9 100644
--- a/MdeModulePkg/Universal/HiiDatabaseDxe/Image.c
+++ b/MdeModulePkg/Universal/HiiDatabaseDxe/Image.c
@@ -631,12 +631,8 @@ HiiNewImage (
   HII_DATABASE_PRIVATE_DATA           *Private;
   HII_DATABASE_PACKAGE_LIST_INSTANCE  *PackageListNode;
   HII_IMAGE_PACKAGE_INSTANCE          *ImagePackage;
-  UINT8                               *ImageBlock;
-  UINTN                               BlockSize;
-  UINT8                               *NewBlock;
-  UINT8                               *NewBlockPtr;
-  UINTN                               NewBlockSize;
-  EFI_IMAGE_INPUT                     *ImageIn;
+  EFI_HII_IMAGE_BLOCK                 *ImageBlocks;
+  UINT32                              NewBlockSize;
 
   if (This == NULL || ImageId == NULL || Image == NULL || Image->Bitmap == NULL) {
     return EFI_INVALID_PARAMETER;
@@ -652,10 +648,8 @@ HiiNewImage (
     return EFI_NOT_FOUND;
   }
 
-  ImageIn = (EFI_IMAGE_INPUT *) Image;
-
   NewBlockSize = sizeof (EFI_HII_IIBT_IMAGE_24BIT_BLOCK) - sizeof (EFI_HII_RGB_PIXEL) +
-                 BITMAP_LEN_24_BIT (ImageIn->Width, ImageIn->Height);
+                 BITMAP_LEN_24_BIT (Image->Width, Image->Height);
 
   //
   // Get the image package in the package list,
@@ -674,38 +668,33 @@ HiiNewImage (
     //
     // Update the package's image block by appending the new block to the end.
     //
-    BlockSize  = ImagePackage->ImageBlockSize + NewBlockSize;
-    ImageBlock = (UINT8 *) AllocateZeroPool (BlockSize);
-    if (ImageBlock == NULL) {
+    ImageBlocks = AllocatePool (ImagePackage->ImageBlockSize + NewBlockSize);
+    if (ImageBlocks == NULL) {
       return EFI_OUT_OF_RESOURCES;
     }
     //
     // Copy the original content.
     //
     CopyMem (
-      ImageBlock,
+      ImageBlocks,
       ImagePackage->ImageBlock,
       ImagePackage->ImageBlockSize - sizeof (EFI_HII_IIBT_END_BLOCK)
       );
     FreePool (ImagePackage->ImageBlock);
-    ImagePackage->ImageBlock = (EFI_HII_IMAGE_BLOCK *) ImageBlock;
-    ImageBlock += ImagePackage->ImageBlockSize - sizeof (EFI_HII_IIBT_END_BLOCK);
+    ImagePackage->ImageBlock = ImageBlocks;
+
     //
-    // Temp memory to store new block.
+    // Point to the very last block.
     //
-    NewBlock = AllocateZeroPool (NewBlockSize);
-    if (NewBlock == NULL) {
-      FreePool (ImagePackage->ImageBlock);
-      return EFI_OUT_OF_RESOURCES;
-    }
-    NewBlockPtr = NewBlock;
-
+    ImageBlocks = (EFI_HII_IMAGE_BLOCK *) (
+                    (UINT8 *) ImageBlocks + ImagePackage->ImageBlockSize - sizeof (EFI_HII_IIBT_END_BLOCK)
+                    );
     //
     // Update the length record.
     //
-    ImagePackage->ImageBlockSize = (UINT32) BlockSize;
-    ImagePackage->ImagePkgHdr.Header.Length += (UINT32) NewBlockSize;
-    PackageListNode->PackageListHdr.PackageLength += (UINT32) NewBlockSize;
+    ImagePackage->ImageBlockSize                  += NewBlockSize;
+    ImagePackage->ImagePkgHdr.Header.Length       += NewBlockSize;
+    PackageListNode->PackageListHdr.PackageLength += NewBlockSize;
 
   } else {
     //
@@ -721,11 +710,10 @@ HiiNewImage (
     // first image block so that id is initially to one.
     //
     *ImageId = 1;
-    BlockSize    = sizeof (EFI_HII_IIBT_END_BLOCK) + NewBlockSize;
     //
     // Fill in image package header.
     //
-    ImagePackage->ImagePkgHdr.Header.Length     = (UINT32) BlockSize + sizeof (EFI_HII_IMAGE_PACKAGE_HDR);
+    ImagePackage->ImagePkgHdr.Header.Length     = sizeof (EFI_HII_IMAGE_PACKAGE_HDR) + NewBlockSize + sizeof (EFI_HII_IIBT_END_BLOCK);
     ImagePackage->ImagePkgHdr.Header.Type       = EFI_HII_PACKAGE_IMAGES;
     ImagePackage->ImagePkgHdr.ImageInfoOffset   = sizeof (EFI_HII_IMAGE_PACKAGE_HDR);
     ImagePackage->ImagePkgHdr.PaletteInfoOffset = 0;
@@ -739,24 +727,13 @@ HiiNewImage (
     //
     // Fill in image blocks.
     //
-    ImagePackage->ImageBlockSize = (UINT32) BlockSize;
-    ImagePackage->ImageBlock = AllocateZeroPool (BlockSize);
+    ImagePackage->ImageBlockSize = NewBlockSize + sizeof (EFI_HII_IIBT_END_BLOCK);
+    ImagePackage->ImageBlock = AllocateZeroPool (NewBlockSize + sizeof (EFI_HII_IIBT_END_BLOCK));
     if (ImagePackage->ImageBlock == NULL) {
       FreePool (ImagePackage);
       return EFI_OUT_OF_RESOURCES;
     }
-    ImageBlock = (UINT8 *) ImagePackage->ImageBlock;
-
-    //
-    // Temp memory to store new block.
-    //
-    NewBlock = AllocateZeroPool (NewBlockSize);
-    if (NewBlock == NULL) {
-      FreePool (ImagePackage->ImageBlock);
-      FreePool (ImagePackage);
-      return EFI_OUT_OF_RESOURCES;
-    }
-    NewBlockPtr = NewBlock;
+    ImageBlocks = ImagePackage->ImageBlock;
 
     //
     // Insert this image package.
@@ -768,26 +745,20 @@ HiiNewImage (
   //
   // Append the new block here
   //
-  if (ImageIn->Flags == EFI_IMAGE_TRANSPARENT) {
-    *NewBlock = EFI_HII_IIBT_IMAGE_24BIT_TRANS;
+  if (Image->Flags == EFI_IMAGE_TRANSPARENT) {
+    ImageBlocks->BlockType = EFI_HII_IIBT_IMAGE_24BIT_TRANS;
   } else {
-    *NewBlock = EFI_HII_IIBT_IMAGE_24BIT;
+    ImageBlocks->BlockType = EFI_HII_IIBT_IMAGE_24BIT;
   }
-  NewBlock++;
-  CopyMem (NewBlock, &ImageIn->Width, sizeof (UINT16));
-  NewBlock += sizeof (UINT16);
-  CopyMem (NewBlock, &ImageIn->Height, sizeof (UINT16));
-  NewBlock += sizeof (UINT16);
-  CopyGopToRgbPixel ((EFI_HII_RGB_PIXEL *) NewBlock, ImageIn->Bitmap, ImageIn->Width * ImageIn->Height);
-
-  CopyMem (ImageBlock, NewBlockPtr, NewBlockSize);
-  FreePool (NewBlockPtr);
+  WriteUnaligned16 (&((EFI_HII_IIBT_IMAGE_24BIT_BLOCK *) ImageBlocks)->Bitmap.Width, Image->Width);
+  WriteUnaligned16 (&((EFI_HII_IIBT_IMAGE_24BIT_BLOCK *) ImageBlocks)->Bitmap.Height, Image->Height);
+  CopyGopToRgbPixel (((EFI_HII_IIBT_IMAGE_24BIT_BLOCK *) ImageBlocks)->Bitmap.Bitmap, Image->Bitmap, Image->Width * Image->Height);
 
   //
   // Append the block end
   //
-  ImageBlock += NewBlockSize;
-  ((EFI_HII_IIBT_END_BLOCK *) (ImageBlock))->Header.BlockType = EFI_HII_IIBT_END;
+  ImageBlocks = (EFI_HII_IMAGE_BLOCK *) ((UINT8 *) ImageBlocks + NewBlockSize);
+  ImageBlocks->BlockType = EFI_HII_IIBT_END;
 
   //
   // Check whether need to get the contents of HiiDataBase.
-- 
2.9.0.windows.1



^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 04/13] MdeModulePkg/HiiDatabase: Refine HiiGetImage()
  2016-09-23  8:25 [PATCH 00/13] Add HiiImageEx implementation and demonstrate in Nt32 Ruiyu Ni
                   ` (2 preceding siblings ...)
  2016-09-23  8:25 ` [PATCH 03/13] MdeModulePkg/HiiDatabase: Refine HiiNewImage() Ruiyu Ni
@ 2016-09-23  8:25 ` Ruiyu Ni
  2016-09-23  8:25 ` [PATCH 05/13] MdeModulePkg/HiiDatabase: Refine HiiSetImage() Ruiyu Ni
                   ` (9 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: Ruiyu Ni @ 2016-09-23  8:25 UTC (permalink / raw)
  To: edk2-devel; +Cc: Liming Gao, Eric Dong, Dandan Bi

Contributed-under: TianoCore Contribution Agreement 1.0
Cc: Liming Gao <liming.gao@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Dandan Bi <dandan.bi@intel.com>
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
---
 MdeModulePkg/Universal/HiiDatabaseDxe/Image.c | 55 ++++++++++-----------------
 1 file changed, 20 insertions(+), 35 deletions(-)

diff --git a/MdeModulePkg/Universal/HiiDatabaseDxe/Image.c b/MdeModulePkg/Universal/HiiDatabaseDxe/Image.c
index 9175ec9..9b7e3af 100644
--- a/MdeModulePkg/Universal/HiiDatabaseDxe/Image.c
+++ b/MdeModulePkg/Universal/HiiDatabaseDxe/Image.c
@@ -805,19 +805,16 @@ HiiGetImage (
   HII_DATABASE_PRIVATE_DATA           *Private;
   HII_DATABASE_PACKAGE_LIST_INSTANCE  *PackageListNode;
   HII_IMAGE_PACKAGE_INSTANCE          *ImagePackage;
-  UINT8                               *ImageBlock;
-  EFI_IMAGE_ID                        LocalImageId;
-  UINT8                               BlockType;
+  EFI_HII_IMAGE_BLOCK                 *CurrentImageBlock;
   EFI_HII_IIBT_IMAGE_1BIT_BLOCK       Iibt1bit;
   UINT16                              Width;
   UINT16                              Height;
   UINTN                               ImageLength;
-  BOOLEAN                             Flag;
   UINT8                               *PaletteInfo;
   UINT8                               PaletteIndex;
   UINT16                              PaletteSize;
 
-  if (This == NULL || Image == NULL || ImageId < 1) {
+  if (This == NULL || Image == NULL || ImageId == 0) {
     return EFI_INVALID_PARAMETER;
   }
 
@@ -838,16 +835,12 @@ HiiGetImage (
   //
   // Find the image block specified by ImageId
   //
-  LocalImageId = ImageId;
-  ImageBlock = (UINT8 *) GetImageIdOrAddress (ImagePackage->ImageBlock, &LocalImageId);
-  if (ImageBlock == NULL) {
+  CurrentImageBlock = GetImageIdOrAddress (ImagePackage->ImageBlock, &ImageId);
+  if (CurrentImageBlock == NULL) {
     return EFI_NOT_FOUND;
   }
 
-  Flag      = FALSE;
-  BlockType = *ImageBlock;
-
-  switch (BlockType) {
+  switch (CurrentImageBlock->BlockType) {
   case EFI_HII_IIBT_IMAGE_JPEG:
     //
     // BUGBUG: need to be supported as soon as image tool is designed.
@@ -857,7 +850,7 @@ HiiGetImage (
   case EFI_HII_IIBT_IMAGE_1BIT_TRANS:
   case EFI_HII_IIBT_IMAGE_4BIT_TRANS:
   case EFI_HII_IIBT_IMAGE_8BIT_TRANS:
-    Flag = TRUE;
+    Image->Flags = EFI_IMAGE_TRANSPARENT;
     //
     // fall through
     //
@@ -867,7 +860,7 @@ HiiGetImage (
     //
     // Use the common block code since the definition of these structures is the same.
     //
-    CopyMem (&Iibt1bit, ImageBlock, sizeof (EFI_HII_IIBT_IMAGE_1BIT_BLOCK));
+    CopyMem (&Iibt1bit, CurrentImageBlock, sizeof (EFI_HII_IIBT_IMAGE_1BIT_BLOCK));
     ImageLength = sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL) *
                   (Iibt1bit.Bitmap.Width * Iibt1bit.Bitmap.Height);
     Image->Bitmap = (EFI_GRAPHICS_OUTPUT_BLT_PIXEL *) AllocateZeroPool (ImageLength);
@@ -875,9 +868,6 @@ HiiGetImage (
       return EFI_OUT_OF_RESOURCES;
     }
 
-    if (Flag) {
-      Image->Flags = EFI_IMAGE_TRANSPARENT;
-    }
     Image->Width  = Iibt1bit.Bitmap.Width;
     Image->Height = Iibt1bit.Bitmap.Height;
 
@@ -891,22 +881,24 @@ HiiGetImage (
     //
     // Output bitmap data
     //
-    if (BlockType == EFI_HII_IIBT_IMAGE_1BIT || BlockType == EFI_HII_IIBT_IMAGE_1BIT_TRANS) {
+    if (CurrentImageBlock->BlockType == EFI_HII_IIBT_IMAGE_1BIT ||
+        CurrentImageBlock->BlockType == EFI_HII_IIBT_IMAGE_1BIT_TRANS) {
       Output1bitPixel (
         Image,
-        (UINT8 *) ((UINTN)ImageBlock + sizeof (EFI_HII_IIBT_IMAGE_1BIT_BLOCK) - sizeof (UINT8)),
+        ((EFI_HII_IIBT_IMAGE_1BIT_BLOCK *) CurrentImageBlock)->Bitmap.Data,
         (EFI_HII_IMAGE_PALETTE_INFO *) PaletteInfo
         );
-    } else if (BlockType == EFI_HII_IIBT_IMAGE_4BIT || BlockType == EFI_HII_IIBT_IMAGE_4BIT_TRANS) {
+    } else if (CurrentImageBlock->BlockType == EFI_HII_IIBT_IMAGE_4BIT ||
+               CurrentImageBlock->BlockType == EFI_HII_IIBT_IMAGE_4BIT_TRANS) {
       Output4bitPixel (
         Image,
-        (UINT8 *) ((UINTN)ImageBlock + sizeof (EFI_HII_IIBT_IMAGE_4BIT_BLOCK) - sizeof (UINT8)),
+        ((EFI_HII_IIBT_IMAGE_4BIT_BLOCK *) CurrentImageBlock)->Bitmap.Data,
         (EFI_HII_IMAGE_PALETTE_INFO *) PaletteInfo
         );
     } else {
       Output8bitPixel (
         Image,
-        (UINT8 *) ((UINTN)ImageBlock + sizeof (EFI_HII_IIBT_IMAGE_8BIT_BLOCK) - sizeof (UINT8)),
+        ((EFI_HII_IIBT_IMAGE_8BIT_BLOCK *) CurrentImageBlock)->Bitmap.Data,
         (EFI_HII_IMAGE_PALETTE_INFO *) PaletteInfo
         );
     }
@@ -914,35 +906,28 @@ HiiGetImage (
     return EFI_SUCCESS;
 
   case EFI_HII_IIBT_IMAGE_24BIT_TRANS:
-    Flag = TRUE;
+    Image->Flags = EFI_IMAGE_TRANSPARENT;
     //
     // fall through
     //
   case EFI_HII_IIBT_IMAGE_24BIT:
-    CopyMem (&Width, ImageBlock + sizeof (EFI_HII_IMAGE_BLOCK), sizeof (UINT16));
-    CopyMem (
-      &Height,
-      ImageBlock + sizeof (EFI_HII_IMAGE_BLOCK) + sizeof (UINT16),
-      sizeof (UINT16)
-      );
+    Width = ReadUnaligned16 (&((EFI_HII_IIBT_IMAGE_24BIT_BLOCK *) CurrentImageBlock)->Bitmap.Width);
+    Height = ReadUnaligned16 (&((EFI_HII_IIBT_IMAGE_24BIT_BLOCK *) CurrentImageBlock)->Bitmap.Height);
     ImageLength = sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL) * (Width * Height);
-    Image->Bitmap = (EFI_GRAPHICS_OUTPUT_BLT_PIXEL *) AllocateZeroPool (ImageLength);
+    Image->Bitmap = AllocateZeroPool (ImageLength);
     if (Image->Bitmap == NULL) {
       return EFI_OUT_OF_RESOURCES;
     }
 
-    if (Flag) {
-      Image->Flags = EFI_IMAGE_TRANSPARENT;
-    }
     Image->Width  = Width;
     Image->Height = Height;
 
     //
-    // Output the bimap data directly.
+    // Output the bitmap data directly.
     //
     Output24bitPixel (
       Image,
-      (EFI_HII_RGB_PIXEL *) (ImageBlock + sizeof (EFI_HII_IIBT_IMAGE_24BIT_BLOCK) - sizeof (EFI_HII_RGB_PIXEL))
+      ((EFI_HII_IIBT_IMAGE_24BIT_BLOCK *) CurrentImageBlock)->Bitmap.Bitmap
       );
     return EFI_SUCCESS;
 
-- 
2.9.0.windows.1



^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 05/13] MdeModulePkg/HiiDatabase: Refine HiiSetImage()
  2016-09-23  8:25 [PATCH 00/13] Add HiiImageEx implementation and demonstrate in Nt32 Ruiyu Ni
                   ` (3 preceding siblings ...)
  2016-09-23  8:25 ` [PATCH 04/13] MdeModulePkg/HiiDatabase: Refine HiiGetImage() Ruiyu Ni
@ 2016-09-23  8:25 ` Ruiyu Ni
  2016-09-23  8:25 ` [PATCH 06/13] MdeModulePkg/HiiDatabase: Refine HiiDrawImage() Ruiyu Ni
                   ` (8 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: Ruiyu Ni @ 2016-09-23  8:25 UTC (permalink / raw)
  To: edk2-devel; +Cc: Liming Gao, Eric Dong, Dandan Bi

Contributed-under: TianoCore Contribution Agreement 1.0
Cc: Liming Gao <liming.gao@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Dandan Bi <dandan.bi@intel.com>
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
---
 MdeModulePkg/Universal/HiiDatabaseDxe/Image.c | 116 ++++++++++----------------
 1 file changed, 46 insertions(+), 70 deletions(-)

diff --git a/MdeModulePkg/Universal/HiiDatabaseDxe/Image.c b/MdeModulePkg/Universal/HiiDatabaseDxe/Image.c
index 9b7e3af..1562767 100644
--- a/MdeModulePkg/Universal/HiiDatabaseDxe/Image.c
+++ b/MdeModulePkg/Universal/HiiDatabaseDxe/Image.c
@@ -965,26 +965,15 @@ HiiSetImage (
   HII_DATABASE_PRIVATE_DATA           *Private;
   HII_DATABASE_PACKAGE_LIST_INSTANCE  *PackageListNode;
   HII_IMAGE_PACKAGE_INSTANCE          *ImagePackage;
-  UINT8                               *ImageBlock;
-  EFI_IMAGE_ID                        LocalImageId;
-  UINT8                               BlockType;
-  EFI_HII_IIBT_IMAGE_1BIT_BLOCK       Iibt1bit;
-  EFI_HII_IIBT_IMAGE_4BIT_BLOCK       Iibt4bit;
-  EFI_HII_IIBT_IMAGE_8BIT_BLOCK       Iibt8bit;
-  UINT16                              Width;
-  UINT16                              Height;
-  UINT32                              BlockSize;
+  EFI_HII_IMAGE_BLOCK                 *CurrentImageBlock;
+  EFI_HII_IMAGE_BLOCK                 *ImageBlocks;
+  EFI_HII_IMAGE_BLOCK                 *NewImageBlock;
   UINT32                              NewBlockSize;
   UINT32                              OldBlockSize;
-  EFI_IMAGE_INPUT                     *ImageIn;
-  UINT8                               *NewBlock;
-  UINT8                               *NewBlockPtr;
-  UINT8                               *Block;
-  UINT8                               *BlockPtr;
   UINT32                               Part1Size;
   UINT32                               Part2Size;
 
-  if (This == NULL || Image == NULL || ImageId < 1 || Image->Bitmap == NULL) {
+  if (This == NULL || Image == NULL || ImageId == 0 || Image->Bitmap == NULL) {
     return EFI_INVALID_PARAMETER;
   }
 
@@ -1005,19 +994,16 @@ HiiSetImage (
   //
   // Find the image block specified by ImageId
   //
-  LocalImageId = ImageId;
-  ImageBlock = (UINT8 *) GetImageIdOrAddress (ImagePackage->ImageBlock, &LocalImageId);
-  if (ImageBlock == NULL) {
+  CurrentImageBlock = GetImageIdOrAddress (ImagePackage->ImageBlock, &ImageId);
+  if (CurrentImageBlock == NULL) {
     return EFI_NOT_FOUND;
   }
 
-  BlockType = *ImageBlock;
-
   //
   // Get the size of original image block. Use some common block code here
   // since the definition of some structures is the same.
   //
-  switch (BlockType) {
+  switch (CurrentImageBlock->BlockType) {
   case EFI_HII_IIBT_IMAGE_JPEG:
     //
     // BUGBUG: need to be supported as soon as image tool is designed.
@@ -1026,32 +1012,35 @@ HiiSetImage (
 
   case EFI_HII_IIBT_IMAGE_1BIT:
   case EFI_HII_IIBT_IMAGE_1BIT_TRANS:
-    CopyMem (&Iibt1bit, ImageBlock, sizeof (EFI_HII_IIBT_IMAGE_1BIT_BLOCK));
     OldBlockSize = sizeof (EFI_HII_IIBT_IMAGE_1BIT_BLOCK) - sizeof (UINT8) +
-                   BITMAP_LEN_1_BIT (Iibt1bit.Bitmap.Width, Iibt1bit.Bitmap.Height);
+                   BITMAP_LEN_1_BIT (
+                     ReadUnaligned16 (&((EFI_HII_IIBT_IMAGE_1BIT_BLOCK *) CurrentImageBlock)->Bitmap.Width),
+                     ReadUnaligned16 (&((EFI_HII_IIBT_IMAGE_1BIT_BLOCK *) CurrentImageBlock)->Bitmap.Height)
+                     );
     break;
   case EFI_HII_IIBT_IMAGE_4BIT:
   case EFI_HII_IIBT_IMAGE_4BIT_TRANS:
-    CopyMem (&Iibt4bit, ImageBlock, sizeof (EFI_HII_IIBT_IMAGE_4BIT_BLOCK));
     OldBlockSize = sizeof (EFI_HII_IIBT_IMAGE_4BIT_BLOCK) - sizeof (UINT8) +
-                   BITMAP_LEN_4_BIT (Iibt4bit.Bitmap.Width, Iibt4bit.Bitmap.Height);
+                   BITMAP_LEN_4_BIT (
+                     ReadUnaligned16 (&((EFI_HII_IIBT_IMAGE_4BIT_BLOCK *) CurrentImageBlock)->Bitmap.Width),
+                     ReadUnaligned16 (&((EFI_HII_IIBT_IMAGE_4BIT_BLOCK *) CurrentImageBlock)->Bitmap.Height)
+                     );
     break;
   case EFI_HII_IIBT_IMAGE_8BIT:
   case EFI_HII_IIBT_IMAGE_8BIT_TRANS:
-    CopyMem (&Iibt8bit, ImageBlock, sizeof (EFI_HII_IIBT_IMAGE_8BIT_BLOCK));
     OldBlockSize = sizeof (EFI_HII_IIBT_IMAGE_8BIT_BLOCK) - sizeof (UINT8) +
-                   BITMAP_LEN_8_BIT (Iibt8bit.Bitmap.Width, Iibt8bit.Bitmap.Height);
+                   BITMAP_LEN_8_BIT (
+                     ReadUnaligned16 (&((EFI_HII_IIBT_IMAGE_8BIT_BLOCK *) CurrentImageBlock)->Bitmap.Width),
+                     ReadUnaligned16 (&((EFI_HII_IIBT_IMAGE_8BIT_BLOCK *) CurrentImageBlock)->Bitmap.Height)
+                     );
     break;
   case EFI_HII_IIBT_IMAGE_24BIT:
   case EFI_HII_IIBT_IMAGE_24BIT_TRANS:
-    CopyMem (&Width, ImageBlock + sizeof (EFI_HII_IMAGE_BLOCK), sizeof (UINT16));
-    CopyMem (
-      &Height,
-      ImageBlock + sizeof (EFI_HII_IMAGE_BLOCK) + sizeof (UINT16),
-      sizeof (UINT16)
-      );
     OldBlockSize = sizeof (EFI_HII_IIBT_IMAGE_24BIT_BLOCK) - sizeof (EFI_HII_RGB_PIXEL) +
-                   BITMAP_LEN_24_BIT (Width , Height);
+                   BITMAP_LEN_24_BIT (
+                     ReadUnaligned16 (&((EFI_HII_IIBT_IMAGE_24BIT_BLOCK *) CurrentImageBlock)->Bitmap.Width),
+                     ReadUnaligned16 (&((EFI_HII_IIBT_IMAGE_24BIT_BLOCK *) CurrentImageBlock)->Bitmap.Height)
+                     );
     break;
   default:
     return EFI_NOT_FOUND;
@@ -1060,53 +1049,40 @@ HiiSetImage (
   //
   // Create the new image block according to input image.
   //
-  ImageIn = (EFI_IMAGE_INPUT *) Image;
   NewBlockSize = sizeof (EFI_HII_IIBT_IMAGE_24BIT_BLOCK) - sizeof (EFI_HII_RGB_PIXEL) +
-                 BITMAP_LEN_24_BIT (ImageIn->Width, ImageIn->Height);
-  NewBlock = (UINT8 *) AllocateZeroPool (NewBlockSize);
-  if (NewBlock == NULL) {
+                 BITMAP_LEN_24_BIT (Image->Width, Image->Height);
+  //
+  // Adjust the image package to remove the original block firstly then add the new block.
+  //
+  ImageBlocks = AllocateZeroPool (ImagePackage->ImageBlockSize + NewBlockSize - OldBlockSize);
+  if (ImageBlocks == NULL) {
     return EFI_OUT_OF_RESOURCES;
   }
 
-  NewBlockPtr = NewBlock;
-  if ((ImageIn->Flags & EFI_IMAGE_TRANSPARENT) == EFI_IMAGE_TRANSPARENT) {
-    *NewBlockPtr = EFI_HII_IIBT_IMAGE_24BIT_TRANS;
-  } else {
-    *NewBlockPtr = EFI_HII_IIBT_IMAGE_24BIT;
-  }
-  NewBlockPtr++;
-
-  CopyMem (NewBlockPtr, &ImageIn->Width, sizeof (UINT16));
-  NewBlockPtr += sizeof (UINT16);
-  CopyMem (NewBlockPtr, &ImageIn->Height, sizeof (UINT16));
-  NewBlockPtr += sizeof (UINT16);
-
-  CopyGopToRgbPixel ((EFI_HII_RGB_PIXEL *) NewBlockPtr, ImageIn->Bitmap, ImageIn->Width * ImageIn->Height);
+  Part1Size = (UINT32) (UINTN) ((UINT8 *) CurrentImageBlock - (UINT8 *) ImagePackage->ImageBlock);
+  Part2Size = ImagePackage->ImageBlockSize - Part1Size - OldBlockSize;
+  CopyMem (ImageBlocks, ImagePackage->ImageBlock, Part1Size);
 
   //
-  // Adjust the image package to remove the original block firstly then add the new block.
+  // Set the new image block
   //
-  BlockSize = ImagePackage->ImageBlockSize + NewBlockSize - OldBlockSize;
-  Block = (UINT8 *) AllocateZeroPool (BlockSize);
-  if (Block == NULL) {
-    FreePool (NewBlock);
-    return EFI_OUT_OF_RESOURCES;
+  NewImageBlock = (EFI_HII_IMAGE_BLOCK *) ((UINT8 *) ImageBlocks + Part1Size);
+  if ((Image->Flags & EFI_IMAGE_TRANSPARENT) == EFI_IMAGE_TRANSPARENT) {
+    NewImageBlock->BlockType= EFI_HII_IIBT_IMAGE_24BIT_TRANS;
+  } else {
+    NewImageBlock->BlockType = EFI_HII_IIBT_IMAGE_24BIT;
   }
+  WriteUnaligned16 (&((EFI_HII_IIBT_IMAGE_24BIT_BLOCK *) NewImageBlock)->Bitmap.Width, Image->Width);
+  WriteUnaligned16 (&((EFI_HII_IIBT_IMAGE_24BIT_BLOCK *) NewImageBlock)->Bitmap.Height, Image->Height);
+  CopyGopToRgbPixel (((EFI_HII_IIBT_IMAGE_24BIT_BLOCK *) NewImageBlock)->Bitmap.Bitmap,
+                       Image->Bitmap, Image->Width * Image->Height);
 
-  BlockPtr  = Block;
-  Part1Size = (UINT32) (ImageBlock - (UINT8 *) ImagePackage->ImageBlock);
-  Part2Size = ImagePackage->ImageBlockSize - Part1Size - OldBlockSize;
-  CopyMem (BlockPtr, ImagePackage->ImageBlock, Part1Size);
-  BlockPtr += Part1Size;
-  CopyMem (BlockPtr, NewBlock, NewBlockSize);
-  BlockPtr += NewBlockSize;
-  CopyMem (BlockPtr, ImageBlock + OldBlockSize, Part2Size);
+  CopyMem ((UINT8 *) NewImageBlock + NewBlockSize, (UINT8 *) CurrentImageBlock + OldBlockSize, Part2Size);
 
   FreePool (ImagePackage->ImageBlock);
-  FreePool (NewBlock);
-  ImagePackage->ImageBlock     = (EFI_HII_IMAGE_BLOCK *) Block;
-  ImagePackage->ImageBlockSize = BlockSize;
-  ImagePackage->ImagePkgHdr.Header.Length += NewBlockSize - OldBlockSize;
+  ImagePackage->ImageBlock                       = ImageBlocks;
+  ImagePackage->ImageBlockSize                  += NewBlockSize - OldBlockSize;
+  ImagePackage->ImagePkgHdr.Header.Length       += NewBlockSize - OldBlockSize;
   PackageListNode->PackageListHdr.PackageLength += NewBlockSize - OldBlockSize;
 
   //
-- 
2.9.0.windows.1



^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 06/13] MdeModulePkg/HiiDatabase: Refine HiiDrawImage()
  2016-09-23  8:25 [PATCH 00/13] Add HiiImageEx implementation and demonstrate in Nt32 Ruiyu Ni
                   ` (4 preceding siblings ...)
  2016-09-23  8:25 ` [PATCH 05/13] MdeModulePkg/HiiDatabase: Refine HiiSetImage() Ruiyu Ni
@ 2016-09-23  8:25 ` Ruiyu Ni
  2016-09-23  8:25 ` [PATCH 07/13] MdemodulePkg/HiiDatabase: Correct typo in comments Ruiyu Ni
                   ` (7 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: Ruiyu Ni @ 2016-09-23  8:25 UTC (permalink / raw)
  To: edk2-devel; +Cc: Liming Gao, Eric Dong, Dandan Bi

Contributed-under: TianoCore Contribution Agreement 1.0
Cc: Liming Gao <liming.gao@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Dandan Bi <dandan.bi@intel.com>
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
---
 MdeModulePkg/Universal/HiiDatabaseDxe/Image.c | 26 ++++++++++++--------------
 1 file changed, 12 insertions(+), 14 deletions(-)

diff --git a/MdeModulePkg/Universal/HiiDatabaseDxe/Image.c b/MdeModulePkg/Universal/HiiDatabaseDxe/Image.c
index 1562767..8335252 100644
--- a/MdeModulePkg/Universal/HiiDatabaseDxe/Image.c
+++ b/MdeModulePkg/Universal/HiiDatabaseDxe/Image.c
@@ -1139,7 +1139,6 @@ HiiDrawImage (
   EFI_STATUS                          Status;
   HII_DATABASE_PRIVATE_DATA           *Private;
   BOOLEAN                             Transparent;
-  EFI_IMAGE_INPUT                     *ImageIn;
   EFI_IMAGE_OUTPUT                    *ImageOut;
   EFI_GRAPHICS_OUTPUT_BLT_PIXEL       *BltBuffer;
   UINTN                               BufferLen;
@@ -1165,7 +1164,6 @@ HiiDrawImage (
   }
 
   FontInfo = NULL;
-  ImageIn = (EFI_IMAGE_INPUT *) Image;
 
   //
   // Check whether the image will be drawn transparently or opaquely.
@@ -1180,7 +1178,7 @@ HiiDrawImage (
     // Now EFI_HII_DRAW_FLAG_DEFAULT is set, whether image will be drawn depending
     // on the image's transparency setting.
     //
-    if ((ImageIn->Flags & EFI_IMAGE_TRANSPARENT) == EFI_IMAGE_TRANSPARENT) {
+    if ((Image->Flags & EFI_IMAGE_TRANSPARENT) == EFI_IMAGE_TRANSPARENT) {
       Transparent = TRUE;
     }
   }
@@ -1209,8 +1207,8 @@ HiiDrawImage (
     // Clip the image by (Width, Height)
     //
 
-    Width  = ImageIn->Width;
-    Height = ImageIn->Height;
+    Width  = Image->Width;
+    Height = Image->Height;
 
     if (Width > (*Blt)->Width - BltX) {
       Width = (*Blt)->Width - BltX;
@@ -1225,14 +1223,14 @@ HiiDrawImage (
       return EFI_OUT_OF_RESOURCES;
     }
 
-    if (Width == ImageIn->Width && Height == ImageIn->Height) {
-      CopyMem (BltBuffer, ImageIn->Bitmap, BufferLen);
+    if (Width == Image->Width && Height == Image->Height) {
+      CopyMem (BltBuffer, Image->Bitmap, BufferLen);
     } else {
       for (Ypos = 0; Ypos < Height; Ypos++) {
-        OffsetY1 = ImageIn->Width * Ypos;
+        OffsetY1 = Image->Width * Ypos;
         OffsetY2 = Width * Ypos;
         for (Xpos = 0; Xpos < Width; Xpos++) {
-          BltBuffer[OffsetY2 + Xpos] = ImageIn->Bitmap[OffsetY1 + Xpos];
+          BltBuffer[OffsetY2 + Xpos] = Image->Bitmap[OffsetY1 + Xpos];
         }
       }
     }
@@ -1283,8 +1281,8 @@ HiiDrawImage (
     //
     // Allocate a new bitmap to hold the incoming image.
     //
-    Width  = ImageIn->Width  + BltX;
-    Height = ImageIn->Height + BltY;
+    Width  = Image->Width  + BltX;
+    Height = Image->Height + BltY;
 
     BufferLen = Width * Height * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL);
     BltBuffer = (EFI_GRAPHICS_OUTPUT_BLT_PIXEL *) AllocateZeroPool (BufferLen);
@@ -1322,11 +1320,11 @@ HiiDrawImage (
     //
     *Blt = ImageOut;
     return ImageToBlt (
-             ImageIn->Bitmap,
+             Image->Bitmap,
              BltX,
              BltY,
-             ImageIn->Width,
-             ImageIn->Height,
+             Image->Width,
+             Image->Height,
              Transparent,
              Blt
              );
-- 
2.9.0.windows.1



^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 07/13] MdemodulePkg/HiiDatabase: Correct typo in comments.
  2016-09-23  8:25 [PATCH 00/13] Add HiiImageEx implementation and demonstrate in Nt32 Ruiyu Ni
                   ` (5 preceding siblings ...)
  2016-09-23  8:25 ` [PATCH 06/13] MdeModulePkg/HiiDatabase: Refine HiiDrawImage() Ruiyu Ni
@ 2016-09-23  8:25 ` Ruiyu Ni
  2016-09-23  8:25 ` [PATCH 08/13] MdeModulePkg/HiiDatabase: Update HiiImage to support PNG/JPEG Ruiyu Ni
                   ` (6 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: Ruiyu Ni @ 2016-09-23  8:25 UTC (permalink / raw)
  To: edk2-devel; +Cc: Liming Gao, Eric Dong, Dandan Bi

Contributed-under: TianoCore Contribution Agreement 1.0
Cc: Liming Gao <liming.gao@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Dandan Bi <dandan.bi@intel.com>
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
---
 .../HiiDatabaseDxe/ConfigKeywordHandler.c          | 36 +++++++-------
 .../Universal/HiiDatabaseDxe/ConfigRouting.c       | 58 +++++++++++-----------
 MdeModulePkg/Universal/HiiDatabaseDxe/Database.c   | 14 +++---
 MdeModulePkg/Universal/HiiDatabaseDxe/Font.c       | 32 ++++++------
 .../Universal/HiiDatabaseDxe/HiiDatabaseEntry.c    |  2 +-
 5 files changed, 71 insertions(+), 71 deletions(-)

diff --git a/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigKeywordHandler.c b/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigKeywordHandler.c
index 10a901f..ae5cff2 100644
--- a/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigKeywordHandler.c
+++ b/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigKeywordHandler.c
@@ -28,7 +28,7 @@ extern HII_DATABASE_PRIVATE_DATA mPrivate;
   @param  NextString             string follow the possible PathHdr string.
 
   @retval EFI_INVALID_PARAMETER  The device path is not valid or the incoming parameter is invalid.
-  @retval EFI_OUT_OF_RESOURCES   Lake of resources to store neccesary structures.
+  @retval EFI_OUT_OF_RESOURCES   Lake of resources to store necessary structures.
   @retval EFI_SUCCESS            The device path is retrieved and translated to binary format.
                                  The Input string not include PathHdr section.
 
@@ -240,10 +240,10 @@ ExtractNameSpace (
 
   @param  String                 KeywordRequestformat string.
   @param  Keyword                return the extract keyword string.
-  @param  NextString             return the next string follow this keyword sectin.
+  @param  NextString             return the next string follow this keyword section.
 
   @retval EFI_SUCCESS            Success to get the keyword string.
-  @retval EFI_INVALID_PARAMETER  Parsr the input string return error.
+  @retval EFI_INVALID_PARAMETER  Parse the input string return error.
 
 **/
 EFI_STATUS
@@ -306,10 +306,10 @@ ExtractKeyword (
 
   @param  String                 KeywordRequestformat string.
   @param  Value                  return the extract value string.
-  @param  NextString             return the next string follow this keyword sectin.
+  @param  NextString             return the next string follow this keyword section.
 
   @retval EFI_SUCCESS            Success to get the keyword string.
-  @retval EFI_INVALID_PARAMETER  Parsr the input string return error.
+  @retval EFI_INVALID_PARAMETER  Parse the input string return error.
 
 **/
 EFI_STATUS
@@ -361,10 +361,10 @@ ExtractValue (
 
   @param  String                 KeywordRequestformat string.
   @param  FilterFlags            return the filter condition.
-  @param  NextString             return the next string follow this keyword sectin.
+  @param  NextString             return the next string follow this keyword section.
 
   @retval EFI_SUCCESS            Success to get the keyword string.
-  @retval EFI_INVALID_PARAMETER  Parsr the input string return error.
+  @retval EFI_INVALID_PARAMETER  Parse the input string return error.
 
 **/
 BOOLEAN
@@ -477,7 +477,7 @@ ExtractFilter (
         String = KeywordPtr;
       } else {
         //
-        // Only has paltform defined filter section, just skip it.
+        // Only has platform defined filter section, just skip it.
         //
         String += StrLen (String);
       }
@@ -520,9 +520,9 @@ ExtractReadOnlyFromOpCode (
 
   This is a internal function.
 
-  @param  OpCodeData             The questin binary ifr data.
+  @param  OpCodeData             The question binary ifr data.
   @param  KeywordRequest         KeywordRequestformat string.
-  @param  NextString             return the next string follow this keyword sectin.
+  @param  NextString             return the next string follow this keyword section.
   @param  ReadOnly               Return whether this question is read only.
 
   @retval KEYWORD_HANDLER_NO_ERROR                     Success validate.
@@ -711,7 +711,7 @@ GetRecordFromDevicePath (
   @param  BufferSize             Length of the buffer.
   @param  StringDest             Buffer to store the string text. 
 
-  @retval EFI_SUCCESS            The string text was outputed successfully.
+  @retval EFI_SUCCESS            The string text was outputted successfully.
   @retval EFI_OUT_OF_RESOURCES   Out of resource.
 
 **/
@@ -1310,7 +1310,7 @@ GetNextStringId (
   @param  KeywordValue                   Keyword value.
   @param  StringId                       String Id for this keyword.
 
-  @retval KEYWORD_HANDLER_NO_ERROR                     Get String id succes.
+  @retval KEYWORD_HANDLER_NO_ERROR                     Get String id successfully.
   @retval KEYWORD_HANDLER_KEYWORD_NOT_FOUND            Not found the string id in the string package.
   @retval KEYWORD_HANDLER_NAMESPACE_ID_NOT_FOUND       Not found the string package for this namespace.
   @retval KEYWORD_HANDLER_UNDEFINED_PROCESSING_ERROR   Out of resource error.
@@ -1609,7 +1609,7 @@ GetWidth (
 }
 
 /**
-  Converts all hex dtring characters in range ['A'..'F'] to ['a'..'f'] for 
+  Converts all hex string characters in range ['A'..'F'] to ['a'..'f'] for 
   hex digits that appear between a '=' and a '&' in a config string.
 
   If ConfigString is NULL, then ASSERT().
@@ -1657,7 +1657,7 @@ InternalLowerConfigString (
   @param[in]  DriverHandle  The driver handle which supports a Device Path Protocol
                             that is the routing information PATH.  Each byte of
                             the Device Path associated with DriverHandle is converted
-                            to a 2 Unicode character hexidecimal string.
+                            to a 2 Unicode character hexadecimal string.
 
   @retval NULL   DriverHandle does not support the Device Path Protocol.
   @retval Other  A pointer to the Null-terminate Unicode <ConfigHdr> string
@@ -2356,7 +2356,7 @@ GetStringIdFromDatabase (
 }
 
 /**
-  Genereate the KeywordResp String.
+  Generate the KeywordResp String.
 
   <KeywordResp> ::= <NameSpaceId><PathHdr>'&'<Keyword>'&VALUE='<Number>['&READONLY']
 
@@ -2419,7 +2419,7 @@ GenerateKeywordResp (
   RespStrLen += StrLen (PathHdr);
 
   //
-  // 1.3 Keyword setion.
+  // 1.3 Keyword section.
   // 'KEYWORD='<String>[':'<DecCh>(1/4)]
   //
   RespStrLen += 8 + StrLen (KeywordData);
@@ -2709,7 +2709,7 @@ Error:
   }
 
   //
-  // return the already get MultiKeywordString even error occured.
+  // return the already get MultiKeywordString even error occurred.
   //
   if (MultiKeywordResp == NULL) {
     Status = EFI_NOT_FOUND;
@@ -3071,7 +3071,7 @@ Done:
   @retval EFI_SUCCESS             The specified action was completed successfully.
   
   @retval EFI_INVALID_PARAMETER   One or more of the following are TRUE:
-                                  1.Progress, ProgressErr, or Resuts is NULL.
+                                  1.Progress, ProgressErr, or Results is NULL.
                                   2.Parsing of the KeywordString resulted in an error. See
                                     Progress and ProgressErr for more data.
   
diff --git a/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c b/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c
index 9f036a5..b3fdc26 100644
--- a/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c
+++ b/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c
@@ -65,7 +65,7 @@ CalculateConfigStringLen (
 
   @retval EFI_NOT_FOUND          The device path is not invalid.
   @retval EFI_INVALID_PARAMETER  Any incoming parameter is invalid.
-  @retval EFI_OUT_OF_RESOURCES   Lake of resources to store neccesary structures.
+  @retval EFI_OUT_OF_RESOURCES   Lake of resources to store necessary structures.
   @retval EFI_SUCCESS            The device path is retrieved and translated to
                                  binary format.
 
@@ -436,7 +436,7 @@ AppendToMultiString (
                                  to free memory.
   @param  Len                    Length of the <Number>, in characters.
 
-  @retval EFI_OUT_OF_RESOURCES   Insufficient resources to store neccessary
+  @retval EFI_OUT_OF_RESOURCES   Insufficient resources to store necessary
                                  structures.
   @retval EFI_SUCCESS            Value of <Number> is outputted in Number
                                  successfully.
@@ -518,7 +518,7 @@ Exit:
   @param  Found                  The Block whether has been found.
   @param  BufferLen              The length of the buffer.
 
-  @retval EFI_OUT_OF_RESOURCES   Insufficient resources to store neccessary structures.
+  @retval EFI_OUT_OF_RESOURCES   Insufficient resources to store necessary structures.
   @retval EFI_SUCCESS            The function finishes successfully.
 
 **/
@@ -574,7 +574,7 @@ FindSameBlockElement(
   @param  AltConfigHdr           Pointer to a Unicode string in <AltConfigHdr> format.
   @param  ConfigAltRespChanged   Whether the ConfigAltResp has been changed.
 
-  @retval EFI_OUT_OF_RESOURCES   Insufficient resources to store neccessary structures.
+  @retval EFI_OUT_OF_RESOURCES   Insufficient resources to store necessary structures.
   @retval EFI_SUCCESS            The function finishes  successfully.
 
 **/
@@ -715,7 +715,7 @@ Exit:
   @param  AltConfigHdr           Pointer to a Unicode string in <AltConfigHdr> format.
   @param  ConfigAltRespChanged   Whether the ConfigAltResp has been changed.
 
-  @retval EFI_OUT_OF_RESOURCES   Insufficient resources to store neccessary structures.
+  @retval EFI_OUT_OF_RESOURCES   Insufficient resources to store necessary structures.
   @retval EFI_SUCCESS            The function finishes  successfully.
 
 **/
@@ -845,7 +845,7 @@ Exit:
                                  string for the different varstore buffer.
   @param  AltConfigHdr           Pointer to a Unicode string in <AltConfigHdr> format.
 
-  @retval EFI_OUT_OF_RESOURCES   Insufficient resources to store neccessary
+  @retval EFI_OUT_OF_RESOURCES   Insufficient resources to store necessary
                                  structures.
   @retval EFI_SUCCESS            The function finishes  successfully.
 
@@ -1021,7 +1021,7 @@ MergeDefaultString (
   }
   
   //
-  // Get the requestr ConfigHdr
+  // Get the request ConfigHdr
   //
   SizeAltCfgResp  = 0;
   StringPtr       = *AltCfgResp;
@@ -1249,9 +1249,9 @@ InsertBlockData (
   @param[in]  HiiHandle  A handle that was previously registered in the HII Database.
 
   @retval NULL   HiiHandle is not registered in the HII database
-  @retval NULL   There are not enough resources available to retrieve the suported 
+  @retval NULL   There are not enough resources available to retrieve the supported 
                  languages.
-  @retval NULL   The list of suported languages could not be retrieved.
+  @retval NULL   The list of supported languages could not be retrieved.
   @retval Other  A pointer to the Null-terminated ASCII string of supported languages.
 
 **/
@@ -1697,7 +1697,7 @@ GetVarStoreType (
       } 
         
       //
-      // Free alllocated temp string.
+      // Free allocated temp string.
       //
       FreePool (VarStoreName);
       FreePool (GuidStr);
@@ -1755,8 +1755,8 @@ GetElementsFromRequest (
   @param  Name              Varstore name.
   @param  ConfigHdr         Current configRequest info.
 
-  @retval  TRUE              This varstore is the requst one.
-  @retval  FALSE             This varstore is not the requst one.
+  @retval  TRUE              This varstore is the request one.
+  @retval  FALSE             This varstore is not the request one.
                                  
 **/
 BOOLEAN
@@ -1825,8 +1825,8 @@ Done:
   @param  DataBaseRecord        The DataBaseRecord instance contains the found Hii handle and package.
   @param  ConfigHdr             Request string ConfigHdr. If it is NULL,
                                 the first found varstore will be as ConfigHdr.
-  @retval  TRUE                 This hii package is the reqeust one.
-  @retval  FALSE                This hii package is not the reqeust one.
+  @retval  TRUE                 This hii package is the request one.
+  @retval  FALSE                This hii package is not the request one.
 **/                                
 BOOLEAN
 IsThisPackageList (
@@ -1955,7 +1955,7 @@ Done:
 
   @param  RequestBlockArray      The array includes all the request info or NULL.
   @param  HiiHandle              The hii handle for this form package.
-  @param  VarStorageData         The varstore data strucure.
+  @param  VarStorageData         The varstore data structure.
   @param  IfrOpHdr               Ifr opcode header for this opcode.
   @param  VarWidth               The buffer width for this opcode.
   @param  ReturnData             The data block added for this opcode.
@@ -2048,7 +2048,7 @@ IsThisOpcodeRequired (
 
   @param  HiiHandle             Hii Handle for this hii package.
   @param  Package               Pointer to the form package data.
-  @param  PackageLength         Length of the pacakge.
+  @param  PackageLength         Length of the package.
   @param  ConfigHdr             Request string ConfigHdr. If it is NULL,
                                 the first found varstore will be as ConfigHdr.
   @param  RequestBlockArray     The block array is retrieved from the request string.
@@ -2056,7 +2056,7 @@ IsThisOpcodeRequired (
   @param  DefaultIdArray        Point to the got default id and default name array.
 
   @retval EFI_SUCCESS           The block array and the default value array are got.
-  @retval EFI_INVALID_PARAMETER The varstore defintion in the differnt form pacakges
+  @retval EFI_INVALID_PARAMETER The varstore definition in the different form packages
                                 are conflicted. 
   @retval EFI_OUT_OF_RESOURCES  No enough memory.
 **/
@@ -2493,7 +2493,7 @@ ParseIfrData (
       DefaultData.DefaultId   = VarDefaultId;
       if ((IfrCheckBox->Flags & EFI_IFR_CHECKBOX_DEFAULT) == EFI_IFR_CHECKBOX_DEFAULT) {
         //
-        // When flag is set, defautl value is TRUE.
+        // When flag is set, default value is TRUE.
         //
         DefaultData.Type    = DefaultValueFromFlag;
         DefaultData.Value.b = TRUE;
@@ -2518,7 +2518,7 @@ ParseIfrData (
       DefaultData.DefaultId   = VarDefaultId;
       if ((IfrCheckBox->Flags & EFI_IFR_CHECKBOX_DEFAULT_MFG) == EFI_IFR_CHECKBOX_DEFAULT_MFG) {
         //
-        // When flag is set, defautl value is TRUE.
+        // When flag is set, default value is TRUE.
         //
         DefaultData.Type    = DefaultValueFromFlag;
         DefaultData.Value.b = TRUE;
@@ -2534,7 +2534,7 @@ ParseIfrData (
       }
       if (SmallestIdFromFlag) {
         //
-        // When smallest default Id is given by the  flag of CheckBox, set defaut value with TRUE for other default Id in the DefaultId list.
+        // When smallest default Id is given by the  flag of CheckBox, set default value with TRUE for other default Id in the DefaultId list.
         //
         DefaultData.Type    = DefaultValueFromOtherDefault;
         DefaultData.Value.b = TRUE;
@@ -2548,7 +2548,7 @@ ParseIfrData (
         }
       } else {
         //
-        // When flag is not set, defautl value is FASLE.
+        // When flag is not set, default value is FASLE.
         //
         DefaultData.Type    = DefaultValueFromDefault;
         DefaultData.Value.b = FALSE;
@@ -2943,7 +2943,7 @@ ParseIfrData (
 
       //
       // After insert the default value, reset the cleaned value for next 
-      // time used. If not set here, need to set the value before everytime 
+      // time used. If not set here, need to set the value before every time 
       // use it.
       //
       DefaultData.Cleaned     = FALSE;
@@ -3743,7 +3743,7 @@ GenerateAltConfigResp (
                                  When Request points to NULL, the default value string 
                                  for each varstore in form package will be merged into 
                                  a <MultiConfigAltResp> format string and return.
-  @param  PointerProgress        Optional parameter, it can be be NULL. 
+  @param  PointerProgress        Optional parameter, it can be NULL. 
                                  When it is not NULL, if Request is NULL, it returns NULL. 
                                  On return, points to a character in the Request
                                  string. Points to the string's null terminator if
@@ -3807,7 +3807,7 @@ GetFullStringFromHiiFormPackages (
   }
 
   //
-  // 1. Get the request block array by Request String when Request string containts the block array.
+  // 1. Get the request block array by Request String when Request string contains the block array.
   //
   StringPtr = NULL;
   if (*Request != NULL) {
@@ -3890,7 +3890,7 @@ GetFullStringFromHiiFormPackages (
   //
 
   //
-  // Parse the opcode in form pacakge to get the default setting.
+  // Parse the opcode in form package to get the default setting.
   //
   Status = ParseIfrData (DataBaseRecord->Handle,
                          HiiFormPackage,
@@ -3936,7 +3936,7 @@ GetFullStringFromHiiFormPackages (
   }
 
   //
-  // 5. Merge string into the input AltCfgResp if the iput *AltCfgResp is not NULL.
+  // 5. Merge string into the input AltCfgResp if the input *AltCfgResp is not NULL.
   //
   if (*AltCfgResp != NULL && DefaultAltCfgResp != NULL) {
     Status = MergeDefaultString (AltCfgResp, DefaultAltCfgResp);
@@ -4009,7 +4009,7 @@ Done:
   }
 
   //
-  // Free Pacakge data
+  // Free Package data
   //
   if (HiiFormPackage != NULL) {
     FreePool (HiiFormPackage);
@@ -4675,7 +4675,7 @@ HiiConfigRoutingExtractConfig (
 
     //
     // Attach this <ConfigAltResp> to a <MultiConfigAltResp>. There is a '&'
-    // which seperates the first <ConfigAltResp> and the following ones.
+    // which separates the first <ConfigAltResp> and the following ones.
     //
     ASSERT (*AccessProgress == 0);
 
@@ -4928,7 +4928,7 @@ HiiConfigRoutingExportConfig (
       
       //
       // Attach this <ConfigAltResp> to a <MultiConfigAltResp>. There is a '&'
-      // which seperates the first <ConfigAltResp> and the following ones.      
+      // which separates the first <ConfigAltResp> and the following ones.      
       //
       if (!FirstElement) {
         Status = AppendToMultiString (Results, L"&");
diff --git a/MdeModulePkg/Universal/HiiDatabaseDxe/Database.c b/MdeModulePkg/Universal/HiiDatabaseDxe/Database.c
index 984c5d2..4fd83f8 100644
--- a/MdeModulePkg/Universal/HiiDatabaseDxe/Database.c
+++ b/MdeModulePkg/Universal/HiiDatabaseDxe/Database.c
@@ -356,7 +356,7 @@ InvokeRegisteredFunction (
   @param  NotifyType             The type of change concerning the database.
   @param  PackageList            Pointer to a package list which will be inserted
                                  to.
-  @param  Package                Created GUID pacakge
+  @param  Package                Created GUID package
 
   @retval EFI_SUCCESS            Guid Package is inserted successfully.
   @retval EFI_OUT_OF_RESOURCES   Unable to allocate necessary resources for the new
@@ -903,7 +903,7 @@ Error:
  @param  PackageList        Pointer to a package list which will be adjusted.
 
  @retval EFI_SUCCESS  Adjust all string packages successfully.
- @retval others       Can't adjust string packges.
+ @retval others       Can't adjust string packages.
 
 **/
 EFI_STATUS
@@ -3041,7 +3041,7 @@ HiiNewPackageList (
 
 
 /**
-  This function removes the package list that is associated with a handle Handle
+  This function removes the package list that is associated with Handle
   from the HII database. Before removing the package, any registered functions
   with the notification type REMOVE_PACK and the same package type will be called.
 
@@ -3052,7 +3052,7 @@ HiiNewPackageList (
 
   @retval EFI_SUCCESS            The data associated with the Handle was removed
                                  from  the HII database.
-  @retval EFI_NOT_FOUND          The specified andle is not in database.
+  @retval EFI_NOT_FOUND          The specified handle is not in database.
   @retval EFI_INVALID_PARAMETER  The Handle was not valid.
 
 **/
@@ -3294,7 +3294,7 @@ HiiUpdatePackageList (
                                  buffer that is required for the handles found.
   @param  Handle                 An array of EFI_HII_HANDLE instances returned.
 
-  @retval EFI_SUCCESS            The matching handles are outputed successfully.
+  @retval EFI_SUCCESS            The matching handles are outputted successfully.
                                  HandleBufferLength is updated with the actual length.
   @retval EFI_BUFFER_TO_SMALL    The HandleBufferLength parameter indicates that
                                  Handle is too small to support the number of
@@ -3400,7 +3400,7 @@ HiiListPackageLists (
         }
         break;
         //
-        // Pesudo-type EFI_HII_PACKAGE_TYPE_ALL will cause all package handles
+        // Pseudo-type EFI_HII_PACKAGE_TYPE_ALL will cause all package handles
         // to be listed.
         //
       case EFI_HII_PACKAGE_TYPE_ALL:
@@ -3457,7 +3457,7 @@ HiiListPackageLists (
                                  Handle is too small to support the number of
                                  handles.      HandleBufferLength is updated with a
                                  value that will enable the data to fit.
-  @retval EFI_NOT_FOUND          The specifiecd Handle could not be found in the
+  @retval EFI_NOT_FOUND          The specified Handle could not be found in the
                                  current database.
   @retval EFI_INVALID_PARAMETER  BufferSize was NULL.
   @retval EFI_INVALID_PARAMETER  The value referenced by BufferSize was not zero 
diff --git a/MdeModulePkg/Universal/HiiDatabaseDxe/Font.c b/MdeModulePkg/Universal/HiiDatabaseDxe/Font.c
index 7e5d3bd..348c428 100644
--- a/MdeModulePkg/Universal/HiiDatabaseDxe/Font.c
+++ b/MdeModulePkg/Universal/HiiDatabaseDxe/Font.c
@@ -275,7 +275,7 @@ GetGlyphBuffer (
   @param  RowWidth       The width of the text on the line, in pixels.
   @param  RowHeight      The height of the line, in pixels.
   @param  Transparent    If TRUE, the Background color is ignored and all
-                         "off" pixels in the character's drawn wil use the
+                         "off" pixels in the character's drawn will use the
                          pixel value from BltBuffer.
   @param  Origin         On input, points to the origin of the to be
                          displayed character, on output, points to the
@@ -351,7 +351,7 @@ NarrowGlyphToBlt (
   @param  RowWidth                The width of the text on the line, in pixels.
   @param  RowHeight               The height of the line, in pixels.
   @param  Transparent             If TRUE, the Background color is ignored and all
-                                  "off" pixels in the character's drawn wil use the
+                                  "off" pixels in the character's drawn will use the
                                   pixel value from BltBuffer.
   @param  Cell                    Points to EFI_HII_GLYPH_INFO structure.
   @param  Attributes              The attribute of incoming glyph in GlyphBuffer.
@@ -467,7 +467,7 @@ GlyphToBlt (
   @param  RowWidth                The width of the text on the line, in pixels.
   @param  RowHeight               The height of the line, in pixels.
   @param  Transparent             If TRUE, the Background color is ignored and all
-                                  "off" pixels in the character's drawn wil use the
+                                  "off" pixels in the character's drawn will use the
                                   pixel value from BltBuffer.
   @param  Cell                    Points to EFI_HII_GLYPH_INFO structure.
   @param  Attributes              The attribute of incoming glyph in GlyphBuffer.
@@ -593,7 +593,7 @@ GlyphToImage (
   @param  InputCell               Buffer which stores cell information of the
                                   encoded bitmap.
   @param  GlyphBuffer             Output the corresponding bitmap data of the found
-                                  block. It is the caller's responsiblity to free
+                                  block. It is the caller's responsibility to free
                                   this buffer.
   @param  Cell                    Output cell information of the encoded bitmap.
   @param  GlyphBufferLen          If not NULL, output the length of GlyphBuffer.
@@ -647,7 +647,7 @@ WriteOutputParam (
   @param  CharValue               Unicode character value, which identifies a glyph
                                   block.
   @param  GlyphBuffer             Output the corresponding bitmap data of the found
-                                  block. It is the caller's responsiblity to free
+                                  block. It is the caller's responsibility to free
                                   this buffer.
   @param  Cell                    Output cell information of the encoded bitmap.
   @param  GlyphBufferLen          If not NULL, output the length of GlyphBuffer.
@@ -1143,7 +1143,7 @@ Exit:
   @param  FontHandle              On entry, Points to the font handle returned by a
                                   previous  call to GetFontInfo() or NULL to start
                                   with the first font.
-  @param  GlobalFontInfo          If not NULL, output the corresponding globa font
+  @param  GlobalFontInfo          If not NULL, output the corresponding global font
                                   info.
 
   @retval TRUE                    Existed
@@ -1172,7 +1172,7 @@ IsFontInfoExisted (
   ASSERT (FontInfo != NULL);
 
   //
-  // Matched flag represents an exactly match; VagueMatched1 repensents a RESIZE
+  // Matched flag represents an exactly match; VagueMatched1 represents a RESIZE
   // or RESTYLE match; VagueMatched2 represents a RESIZE | RESTYLE match.
   //
   Matched           = FALSE;
@@ -1248,7 +1248,7 @@ IsFontInfoExisted (
         }
         break;
       //
-      // If EFI_FONT_INFO_RESIZE is specified, then the sytem may attempt to
+      // If EFI_FONT_INFO_RESIZE is specified, then the system may attempt to
       // stretch or shrink a font to meet the size requested.
       //
       case EFI_FONT_INFO_ANY_FONT | EFI_FONT_INFO_RESIZE:
@@ -1747,8 +1747,8 @@ HiiStringToImage (
   }
   
   //
-  // Use the maxinum height of font as the base line.
-  // And, use the maxinum height as line height.
+  // Use the maximum height of font as the base line.
+  // And, use the maximum height as line height.
   //
   LineHeight     = Height;
   LastLineHeight = Height;
@@ -1783,7 +1783,7 @@ HiiStringToImage (
   }
   //
   // If EFI_HII_IGNORE_IF_NO_GLYPH is set, then characters which have no glyphs
-  // are not drawn. Otherwise they are replaced wth Unicode character 0xFFFD.
+  // are not drawn. Otherwise they are replaced with Unicode character 0xFFFD.
   //
   StringIn2  = AllocateZeroPool (StrSize (StringPtr));
   if (StringIn2 == NULL) {
@@ -2074,7 +2074,7 @@ HiiStringToImage (
       for (Index1 = RowInfo[RowIndex].StartIndex; Index1 <= RowInfo[RowIndex].EndIndex; Index1++) {
         if (RowInfo[RowIndex].LineWidth > 0 && RowInfo[RowIndex].LineWidth > LineOffset) {
           //
-          // Only BLT these character which have corrsponding glyph in font basebase.
+          // Only BLT these character which have corresponding glyph in font database.
           //
           GlyphToImage (
             GlyphBuf[Index1],
@@ -2124,7 +2124,7 @@ HiiStringToImage (
       }
     } else {
       //
-      // Save the starting position for calculate the starting postition of next row. 
+      // Save the starting position for calculate the starting position of next row. 
       //
       RowBufferPtr = BufferPtr;
       //
@@ -2134,7 +2134,7 @@ HiiStringToImage (
       for (Index1 = RowInfo[RowIndex].StartIndex; Index1 <= RowInfo[RowIndex].EndIndex; Index1++) {
         if (RowInfo[RowIndex].LineWidth > 0 && RowInfo[RowIndex].LineWidth > LineOffset) {
           //
-          // Only BLT these character which have corrsponding glyph in font basebase.
+          // Only BLT these character which have corresponding glyph in font database.
           //
           GlyphToImage (
             GlyphBuf[Index1],
@@ -2304,8 +2304,8 @@ Exit:
                                   RowInfoArray or Blt.
   @retval EFI_INVALID_PARAMETER  The Blt or PackageList was NULL.
   @retval EFI_INVALID_PARAMETER  Flags were invalid combination.
-  @retval EFI_NOT_FOUND         The specified PackageList is not in the Database or the stringid is not 
-                          in the specified PackageList. 
+  @retval EFI_NOT_FOUND          The specified PackageList is not in the Database or the string id is not 
+                                  in the specified PackageList. 
 
 **/
 EFI_STATUS
diff --git a/MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseEntry.c b/MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseEntry.c
index 03a4184..b48254f 100644
--- a/MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseEntry.c
+++ b/MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseEntry.c
@@ -160,7 +160,7 @@ OnReadyToBoot (
   @retval EFI_SUCCESS    The Hii database is setup correctly.
   @return Other value if failed to create the default event for
           gHiiKeyboardLayoutChanged. Check gBS->CreateEventEx for
-          details. Or failed to insatll the protocols.
+          details. Or failed to install the protocols.
           Check gBS->InstallMultipleProtocolInterfaces for details.
           Or failed to create Ready To Boot Event.
           Check EfiCreateEventReadyToBootEx for details.
-- 
2.9.0.windows.1



^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 08/13] MdeModulePkg/HiiDatabase: Update HiiImage to support PNG/JPEG
  2016-09-23  8:25 [PATCH 00/13] Add HiiImageEx implementation and demonstrate in Nt32 Ruiyu Ni
                   ` (6 preceding siblings ...)
  2016-09-23  8:25 ` [PATCH 07/13] MdemodulePkg/HiiDatabase: Correct typo in comments Ruiyu Ni
@ 2016-09-23  8:25 ` Ruiyu Ni
  2016-09-23  8:25 ` [PATCH 09/13] MdeModulePkg/HiiDatabase: Add HiiImageEx implementation Ruiyu Ni
                   ` (5 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: Ruiyu Ni @ 2016-09-23  8:25 UTC (permalink / raw)
  To: edk2-devel; +Cc: Liming Gao, Eric Dong, Dandan Bi

1. Update GetImageIdOrAddress() to recognize PNG/JPEG image block.
   A offset calculation bug was fixed.
2. Update HiiGetImage() comments to say PNG/JPEG support is provided
   by HiiImageEx
3. Update HiiSetImage() to support replacing a PNG/JPEG image block
   with a new image

Contributed-under: TianoCore Contribution Agreement 1.0
Cc: Liming Gao <liming.gao@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Dandan Bi <dandan.bi@intel.com>
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
---
 MdeModulePkg/Universal/HiiDatabaseDxe/Image.c | 21 ++++++++++++++-------
 1 file changed, 14 insertions(+), 7 deletions(-)

diff --git a/MdeModulePkg/Universal/HiiDatabaseDxe/Image.c b/MdeModulePkg/Universal/HiiDatabaseDxe/Image.c
index 8335252..6d70193 100644
--- a/MdeModulePkg/Universal/HiiDatabaseDxe/Image.c
+++ b/MdeModulePkg/Universal/HiiDatabaseDxe/Image.c
@@ -127,7 +127,12 @@ GetImageIdOrAddress (
       break;
 
     case EFI_HII_IIBT_IMAGE_JPEG:
-      Length = ReadUnaligned32 (&((EFI_HII_IIBT_JPEG_BLOCK *) CurrentImageBlock)->Size);
+      Length = OFFSET_OF (EFI_HII_IIBT_JPEG_BLOCK, Data) + ReadUnaligned32 (&((EFI_HII_IIBT_JPEG_BLOCK *) CurrentImageBlock)->Size);
+      ImageIdCurrent++;
+      break;
+
+    case EFI_HII_IIBT_IMAGE_PNG:
+      Length = OFFSET_OF (EFI_HII_IIBT_PNG_BLOCK, Data) + ReadUnaligned32 (&((EFI_HII_IIBT_PNG_BLOCK *) CurrentImageBlock)->Size);
       ImageIdCurrent++;
       break;
 
@@ -842,8 +847,10 @@ HiiGetImage (
 
   switch (CurrentImageBlock->BlockType) {
   case EFI_HII_IIBT_IMAGE_JPEG:
+  case EFI_HII_IIBT_IMAGE_PNG:
     //
-    // BUGBUG: need to be supported as soon as image tool is designed.
+    // HiiImage protocol doesn't support return JPEG/PNG.
+    // Use HiiImageEx instead.
     //
     return EFI_UNSUPPORTED;
 
@@ -1005,11 +1012,11 @@ HiiSetImage (
   //
   switch (CurrentImageBlock->BlockType) {
   case EFI_HII_IIBT_IMAGE_JPEG:
-    //
-    // BUGBUG: need to be supported as soon as image tool is designed.
-    //
-    return EFI_UNSUPPORTED;
-
+    OldBlockSize = ReadUnaligned32 (&((EFI_HII_IIBT_JPEG_BLOCK *) CurrentImageBlock)->Size);
+    break;
+  case EFI_HII_IIBT_IMAGE_PNG:
+    OldBlockSize = ReadUnaligned32 (&((EFI_HII_IIBT_PNG_BLOCK *) CurrentImageBlock)->Size);
+    break;
   case EFI_HII_IIBT_IMAGE_1BIT:
   case EFI_HII_IIBT_IMAGE_1BIT_TRANS:
     OldBlockSize = sizeof (EFI_HII_IIBT_IMAGE_1BIT_BLOCK) - sizeof (UINT8) +
-- 
2.9.0.windows.1



^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 09/13] MdeModulePkg/HiiDatabase: Add HiiImageEx implementation.
  2016-09-23  8:25 [PATCH 00/13] Add HiiImageEx implementation and demonstrate in Nt32 Ruiyu Ni
                   ` (7 preceding siblings ...)
  2016-09-23  8:25 ` [PATCH 08/13] MdeModulePkg/HiiDatabase: Update HiiImage to support PNG/JPEG Ruiyu Ni
@ 2016-09-23  8:25 ` Ruiyu Ni
  2016-09-23  8:25 ` [PATCH 10/13] Nt32Pkg/PlatformBds: Do not call BootLogoEnableLogo Ruiyu Ni
                   ` (4 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: Ruiyu Ni @ 2016-09-23  8:25 UTC (permalink / raw)
  To: edk2-devel; +Cc: Liming Gao, Eric Dong, Dandan Bi

According to UEFI spec, NewImageEx()/SetImageEx()/DrawImageEx()
/DrawImageIdEx() implicitly call the non-Ex version interface
of HiiImage protocol.
GetImageEx() is the enhanced version of
GetImage(), which can support decoding JPEG/PNG through the
help of HiiImageDecoder protocol.

Contributed-under: TianoCore Contribution Agreement 1.0
Cc: Liming Gao <liming.gao@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Dandan Bi <dandan.bi@intel.com>
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
---
 .../Universal/HiiDatabaseDxe/HiiDatabase.h         | 290 ++++++++++++++-
 .../Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf    |   7 +-
 .../Universal/HiiDatabaseDxe/HiiDatabaseEntry.c    |  32 +-
 MdeModulePkg/Universal/HiiDatabaseDxe/Image.c      | 119 ++++--
 MdeModulePkg/Universal/HiiDatabaseDxe/ImageEx.c    | 397 +++++++++++++++++++++
 5 files changed, 792 insertions(+), 53 deletions(-)
 create mode 100644 MdeModulePkg/Universal/HiiDatabaseDxe/ImageEx.c

diff --git a/MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabase.h b/MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabase.h
index 0ca2fba..bfce4d1 100644
--- a/MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabase.h
+++ b/MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabase.h
@@ -20,6 +20,8 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #include <Protocol/DevicePath.h>
 #include <Protocol/HiiFont.h>
 #include <Protocol/HiiImage.h>
+#include <Protocol/HiiImageEx.h>
+#include <Protocol/HiiImageDecoder.h>
 #include <Protocol/HiiString.h>
 #include <Protocol/HiiDatabase.h>
 #include <Protocol/HiiConfigRouting.h>
@@ -301,6 +303,7 @@ typedef struct _HII_DATABASE_PRIVATE_DATA {
   LIST_ENTRY                            DatabaseNotifyList;
   EFI_HII_FONT_PROTOCOL                 HiiFont;
   EFI_HII_IMAGE_PROTOCOL                HiiImage;
+  EFI_HII_IMAGE_EX_PROTOCOL             HiiImageEx;
   EFI_HII_STRING_PROTOCOL               HiiString;
   EFI_HII_DATABASE_PROTOCOL             HiiDatabase;
   EFI_HII_CONFIG_ROUTING_PROTOCOL       ConfigRouting;
@@ -327,6 +330,13 @@ typedef struct _HII_DATABASE_PRIVATE_DATA {
       HII_DATABASE_PRIVATE_DATA_SIGNATURE \
       )
 
+#define HII_IMAGE_EX_DATABASE_PRIVATE_DATA_FROM_THIS(a) \
+  CR (a, \
+      HII_DATABASE_PRIVATE_DATA, \
+      HiiImageEx, \
+      HII_DATABASE_PRIVATE_DATA_SIGNATURE \
+      )
+
 #define HII_STRING_DATABASE_PRIVATE_DATA_FROM_THIS(a) \
   CR (a, \
       HII_DATABASE_PRIVATE_DATA, \
@@ -813,6 +823,82 @@ HiiGetFontInfo (
 // EFI_HII_IMAGE_PROTOCOL interfaces
 //
 
+/**
+  Get the image id of last image block: EFI_HII_IIBT_END_BLOCK when input
+  ImageId is zero, otherwise return the address of the
+  corresponding image block with identifier specified by ImageId.
+
+  This is a internal function.
+
+  @param ImageBlocks     Points to the beginning of a series of image blocks stored in order.
+  @param ImageId         If input ImageId is 0, output the image id of the EFI_HII_IIBT_END_BLOCK;
+                         else use this id to find its corresponding image block address.
+
+  @return The image block address when input ImageId is not zero; otherwise return NULL.
+
+**/
+EFI_HII_IMAGE_BLOCK *
+GetImageIdOrAddress (
+  IN EFI_HII_IMAGE_BLOCK *ImageBlocks,
+  IN OUT EFI_IMAGE_ID    *ImageId
+  );
+
+/**
+  Return the HII package list identified by PackageList HII handle.
+
+  @param Database    Pointer to HII database list header.
+  @param PackageList HII handle of the package list to locate.
+
+  @retval The HII package list instance.
+**/
+HII_DATABASE_PACKAGE_LIST_INSTANCE *
+LocatePackageList (  
+  IN  LIST_ENTRY                     *Database,
+  IN  EFI_HII_HANDLE                 PackageList
+  );
+
+/**
+  This function retrieves the image specified by ImageId which is associated with
+  the specified PackageList and copies it into the buffer specified by Image.
+
+  @param  Database               A pointer to the database list header.
+  @param  PackageList            Handle of the package list where this image will
+                                 be searched.
+  @param  ImageId                The image's id,, which is unique within
+                                 PackageList.
+  @param  Image                  Points to the image.
+  @param  BitmapOnly             TRUE to only return the bitmap type image.
+                                 FALSE to locate image decoder instance to decode image.
+
+  @retval EFI_SUCCESS            The new image was returned successfully.
+  @retval EFI_NOT_FOUND          The image specified by ImageId is not in the
+                                 database. The specified PackageList is not in the database.
+  @retval EFI_BUFFER_TOO_SMALL   The buffer specified by ImageSize is too small to
+                                 hold the image.
+  @retval EFI_INVALID_PARAMETER  The Image or ImageSize was NULL.
+  @retval EFI_OUT_OF_RESOURCES   The bitmap could not be retrieved because there was not
+                                 enough memory.
+**/
+EFI_STATUS
+IGetImage (
+  IN  LIST_ENTRY                     *Database,
+  IN  EFI_HII_HANDLE                 PackageList,
+  IN  EFI_IMAGE_ID                   ImageId,
+  OUT EFI_IMAGE_INPUT                *Image,
+  IN  BOOLEAN                        BitmapOnly
+  );
+
+/**
+  Return the first HII image decoder instance which supports the DecoderName.
+
+  @param BlockType  The image block type.
+
+  @retval Pointer to the HII image decoder instance.
+**/
+EFI_HII_IMAGE_DECODER_PROTOCOL *
+LocateHiiImageDecoder (
+  UINT8                          BlockType
+  );
 
 /**
   This function adds the image Image to the group of images owned by PackageList, and returns
@@ -984,10 +1070,210 @@ HiiDrawImageId (
   IN OUT EFI_IMAGE_OUTPUT            **Blt,
   IN UINTN                           BltX,
   IN UINTN                           BltY
-  )
+  );
 
-;
+/**
+  The prototype of this extension function is the same with EFI_HII_IMAGE_PROTOCOL.NewImage().
+  This protocol invokes EFI_HII_IMAGE_PROTOCOL.NewImage() implicitly.
+
+  @param  This                   A pointer to the EFI_HII_IMAGE_EX_PROTOCOL instance.
+  @param  PackageList            Handle of the package list where this image will
+                                 be added.
+  @param  ImageId                On return, contains the new image id, which is
+                                 unique within PackageList.
+  @param  Image                  Points to the image.
+
+  @retval EFI_SUCCESS            The new image was added successfully.
+  @retval EFI_NOT_FOUND          The PackageList could not be found.
+  @retval EFI_OUT_OF_RESOURCES   Could not add the image due to lack of resources.
+  @retval EFI_INVALID_PARAMETER  Image is NULL or ImageId is NULL.
+**/
+EFI_STATUS
+EFIAPI
+HiiNewImageEx (
+  IN  CONST EFI_HII_IMAGE_EX_PROTOCOL *This,
+  IN  EFI_HII_HANDLE                  PackageList,
+  OUT EFI_IMAGE_ID                    *ImageId,
+  IN  CONST EFI_IMAGE_INPUT           *Image
+  );
+
+/**
+  Return the information about the image, associated with the package list.
+  The prototype of this extension function is the same with EFI_HII_IMAGE_PROTOCOL.GetImage().
+
+  This function is similar to EFI_HII_IMAGE_PROTOCOL.GetImage().The difference is that
+  this function will locate all EFI_HII_IMAGE_DECODER_PROTOCOL instances installed in the
+  system if the decoder of the certain image type is not supported by the
+  EFI_HII_IMAGE_EX_PROTOCOL. The function will attempt to decode the image to the
+  EFI_IMAGE_INPUT using the first EFI_HII_IMAGE_DECODER_PROTOCOL instance that
+  supports the requested image type.
+
+  @param  This                   A pointer to the EFI_HII_IMAGE_EX_PROTOCOL instance.
+  @param  PackageList            The package list in the HII database to search for the
+                                 specified image.
+  @param  ImageId                The image's id, which is unique within PackageList.
+  @param  Image                  Points to the image.
+
+  @retval EFI_SUCCESS            The new image was returned successfully.
+  @retval EFI_NOT_FOUND          The image specified by ImageId is not available. The specified
+                                 PackageList is not in the Database.
+  @retval EFI_INVALID_PARAMETER  Image was NULL or ImageId was 0.
+  @retval EFI_OUT_OF_RESOURCES   The bitmap could not be retrieved because there
+                                 was not enough memory.
+
+**/
+EFI_STATUS
+EFIAPI
+HiiGetImageEx (
+  IN  CONST EFI_HII_IMAGE_EX_PROTOCOL *This,
+  IN  EFI_HII_HANDLE                  PackageList,
+  IN  EFI_IMAGE_ID                    ImageId,
+  OUT EFI_IMAGE_INPUT                 *Image
+  );
+
+/**
+  Change the information about the image.
+
+  Same with EFI_HII_IMAGE_PROTOCOL.SetImage(),this protocol invokes
+  EFI_HII_IMAGE_PROTOCOL.SetImage()implicitly.
+
+  @param  This                   A pointer to the EFI_HII_IMAGE_EX_PROTOCOL instance.
+  @param  PackageList            The package list containing the images.
+  @param  ImageId                The image's id, which is unique within PackageList.
+  @param  Image                  Points to the image.
+
+  @retval EFI_SUCCESS            The new image was successfully updated.
+  @retval EFI_NOT_FOUND          The image specified by ImageId is not in the
+                                 database. The specified PackageList is not in
+                                 the database.
+  @retval EFI_INVALID_PARAMETER  The Image was NULL, the ImageId was 0 or
+                                 the Image->Bitmap was NULL.
+
+**/
+EFI_STATUS
+EFIAPI
+HiiSetImageEx (
+  IN CONST EFI_HII_IMAGE_EX_PROTOCOL *This,
+  IN EFI_HII_HANDLE                  PackageList,
+  IN EFI_IMAGE_ID                    ImageId,
+  IN CONST EFI_IMAGE_INPUT           *Image
+  );
 
+/**
+  Renders an image to a bitmap or to the display.
+
+  The prototype of this extension function is the same with
+  EFI_HII_IMAGE_PROTOCOL.DrawImage(). This protocol invokes
+  EFI_HII_IMAGE_PROTOCOL.DrawImage() implicitly.
+
+  @param  This                   A pointer to the EFI_HII_IMAGE_EX_PROTOCOL instance.
+  @param  Flags                  Describes how the image is to be drawn.
+  @param  Image                  Points to the image to be displayed.
+  @param  Blt                    If this points to a non-NULL on entry, this points
+                                 to the image, which is Width pixels wide and
+                                 Height pixels high.  The image will be drawn onto
+                                 this image and  EFI_HII_DRAW_FLAG_CLIP is implied.
+                                 If this points to a NULL on entry, then a buffer
+                                 will be allocated to hold the generated image and
+                                 the pointer updated on exit. It is the caller's
+                                 responsibility to free this buffer.
+  @param  BltX                   Specifies the offset from the left and top edge of
+                                 the output image of the first pixel in the image.
+  @param  BltY                   Specifies the offset from the left and top edge of
+                                 the output image of the first pixel in the image.
+
+  @retval EFI_SUCCESS            The image was successfully drawn.
+  @retval EFI_OUT_OF_RESOURCES   Unable to allocate an output buffer for Blt.
+  @retval EFI_INVALID_PARAMETER  The Image or Blt was NULL.
+
+**/
+EFI_STATUS
+EFIAPI
+HiiDrawImageEx (
+  IN CONST EFI_HII_IMAGE_EX_PROTOCOL *This,
+  IN EFI_HII_DRAW_FLAGS              Flags,
+  IN CONST EFI_IMAGE_INPUT           *Image,
+  IN OUT EFI_IMAGE_OUTPUT            **Blt,
+  IN UINTN                           BltX,
+  IN UINTN                           BltY
+  );
+
+/**
+  Renders an image to a bitmap or the screen containing the contents of the specified
+  image.
+  
+  The prototype of this extension function is the same with
+  EFI_HII_IMAGE_PROTOCOL.DrawImageId(). This protocol invokes
+  EFI_HII_IMAGE_PROTOCOL.DrawImageId() implicitly.
+
+  @param  This                   A pointer to the EFI_HII_IMAGE_EX_PROTOCOL instance.
+  @param  Flags                  Describes how the image is to be drawn.
+  @param  PackageList            The package list in the HII database to search for
+                                 the  specified image.
+  @param  ImageId                The image's id, which is unique within PackageList.
+  @param  Blt                    If this points to a non-NULL on entry, this points
+                                 to the image, which is Width pixels wide and
+                                 Height pixels high. The image will be drawn onto
+                                 this image and EFI_HII_DRAW_FLAG_CLIP is implied.
+                                 If this points to a NULL on entry, then a buffer
+                                 will be allocated to hold  the generated image
+                                 and the pointer updated on exit. It is the caller's
+                                 responsibility to free this buffer.
+  @param  BltX                   Specifies the offset from the left and top edge of
+                                 the output image of the first pixel in the image.
+  @param  BltY                   Specifies the offset from the left and top edge of
+                                 the output image of the first pixel in the image.
+
+  @retval EFI_SUCCESS            The image was successfully drawn.
+  @retval EFI_OUT_OF_RESOURCES   Unable to allocate an output buffer for Blt.
+  @retval EFI_INVALID_PARAMETER  The Blt was NULL or ImageId was 0.
+  @retval EFI_NOT_FOUND          The image specified by ImageId is not in the database.
+                                 The specified PackageList is not in the database.
+
+**/
+EFI_STATUS
+EFIAPI
+HiiDrawImageIdEx (
+  IN CONST EFI_HII_IMAGE_EX_PROTOCOL *This,
+  IN EFI_HII_DRAW_FLAGS              Flags,
+  IN EFI_HII_HANDLE                  PackageList,
+  IN EFI_IMAGE_ID                    ImageId,
+  IN OUT EFI_IMAGE_OUTPUT            **Blt,
+  IN UINTN                           BltX,
+  IN UINTN                           BltY
+  );
+
+/**
+  This function returns the image information to EFI_IMAGE_OUTPUT. Only the width
+  and height are returned to the EFI_IMAGE_OUTPUT instead of decoding the image
+  to the buffer. This function is used to get the geometry of the image. This function
+  will try to locate all of the EFI_HII_IMAGE_DECODER_PROTOCOL installed on the
+  system if the decoder of image type is not supported by the EFI_HII_IMAGE_EX_PROTOCOL.
+
+  @param  This                   A pointer to the EFI_HII_IMAGE_EX_PROTOCOL instance.
+  @param  PackageList            Handle of the package list where this image will
+                                 be searched.
+  @param  ImageId                The image's id, which is unique within PackageList.
+  @param  Image                  Points to the image.
+
+  @retval EFI_SUCCESS            The new image was returned successfully.
+  @retval EFI_NOT_FOUND          The image specified by ImageId is not in the
+                                 database. The specified PackageList is not in the database.
+  @retval EFI_BUFFER_TOO_SMALL   The buffer specified by ImageSize is too small to
+                                 hold the image.
+  @retval EFI_INVALID_PARAMETER  The Image was NULL or the ImageId was 0.
+  @retval EFI_OUT_OF_RESOURCES   The bitmap could not be retrieved because there
+                                 was not enough memory.
+
+**/
+EFI_STATUS
+EFIAPI
+HiiGetImageInfo (
+  IN CONST  EFI_HII_IMAGE_EX_PROTOCOL       *This,
+  IN        EFI_HII_HANDLE                  PackageList,
+  IN        EFI_IMAGE_ID                    ImageId,
+  OUT       EFI_IMAGE_OUTPUT                *Image
+  );
 //
 // EFI_HII_STRING_PROTOCOL
 //
diff --git a/MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf b/MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf
index 2fb619e..f82a1f4 100644
--- a/MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf
+++ b/MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf
@@ -35,6 +35,7 @@ [Defines]
 [Sources]
   HiiDatabaseEntry.c
   Image.c
+  ImageEx.c
   HiiDatabase.h
   ConfigRouting.c
   String.c
@@ -63,7 +64,9 @@ [LibraryClasses]
 [Protocols]
   gEfiDevicePathProtocolGuid                                            ## SOMETIMES_CONSUMES
   gEfiHiiStringProtocolGuid                                             ## PRODUCES
-  gEfiHiiImageProtocolGuid |gEfiMdeModulePkgTokenSpaceGuid.PcdSupportHiiImageProtocol  ## SOMETIMES_PRODUCES
+  gEfiHiiImageProtocolGuid        |gEfiMdeModulePkgTokenSpaceGuid.PcdSupportHiiImageProtocol  ## SOMETIMES_PRODUCES
+  gEfiHiiImageExProtocolGuid      |gEfiMdeModulePkgTokenSpaceGuid.PcdSupportHiiImageProtocol  ## SOMETIMES_PRODUCES
+  gEfiHiiImageDecoderProtocolGuid |gEfiMdeModulePkgTokenSpaceGuid.PcdSupportHiiImageProtocol  ## SOMETIMES_CONSUMES
   gEfiHiiConfigRoutingProtocolGuid                                      ## PRODUCES
   gEfiHiiDatabaseProtocolGuid                                           ## PRODUCES
   gEfiHiiFontProtocolGuid                                               ## PRODUCES
@@ -85,6 +88,8 @@ [Guids]
   ## CONSUMES  ## Event
   ## PRODUCES  ## Event
   gEfiHiiKeyBoardLayoutGuid
+  gEfiHiiImageDecoderNameJpegGuid |gEfiMdeModulePkgTokenSpaceGuid.PcdSupportHiiImageProtocol  ## SOMETIMES_CONSUMES
+  gEfiHiiImageDecoderNamePngGuid  |gEfiMdeModulePkgTokenSpaceGuid.PcdSupportHiiImageProtocol  ## SOMETIMES_CONSUMES
 
 [Depex]
   TRUE
diff --git a/MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseEntry.c b/MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseEntry.c
index b48254f..9d09c60 100644
--- a/MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseEntry.c
+++ b/MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseEntry.c
@@ -39,11 +39,19 @@ HII_DATABASE_PRIVATE_DATA mPrivate = {
     HiiGetFontInfo
   },
   {
-    NULL,
-    NULL,
-    NULL,
-    NULL,
-    NULL
+    HiiNewImage,
+    HiiGetImage,
+    HiiSetImage,
+    HiiDrawImage,
+    HiiDrawImageId
+  },
+  {
+    HiiNewImageEx,
+    HiiGetImageEx,
+    HiiSetImageEx,
+    HiiDrawImageEx,
+    HiiDrawImageIdEx,
+    HiiGetImageInfo
   },
   {
     HiiNewString,
@@ -96,14 +104,6 @@ HII_DATABASE_PRIVATE_DATA mPrivate = {
   NULL
 };
 
-GLOBAL_REMOVE_IF_UNREFERENCED CONST EFI_HII_IMAGE_PROTOCOL mImageProtocol = {
-  HiiNewImage,
-  HiiGetImage,
-  HiiSetImage,
-  HiiDrawImage,
-  HiiDrawImageId
-};
-
 /**
   The default event handler for gHiiKeyboardLayoutChanged
   event group.
@@ -230,12 +230,10 @@ InitializeHiiDatabase (
   }
 
   if (FeaturePcdGet (PcdSupportHiiImageProtocol)) {
-    CopyMem (&mPrivate.HiiImage, &mImageProtocol, sizeof (mImageProtocol));
-
     Status = gBS->InstallMultipleProtocolInterfaces (
                     &Handle,
-                    &gEfiHiiImageProtocolGuid,
-                    &mPrivate.HiiImage,
+                    &gEfiHiiImageProtocolGuid, &mPrivate.HiiImage,
+                    &gEfiHiiImageExProtocolGuid, &mPrivate.HiiImageEx,
                     NULL
                     );
 
diff --git a/MdeModulePkg/Universal/HiiDatabaseDxe/Image.c b/MdeModulePkg/Universal/HiiDatabaseDxe/Image.c
index 6d70193..1c183cb 100644
--- a/MdeModulePkg/Universal/HiiDatabaseDxe/Image.c
+++ b/MdeModulePkg/Universal/HiiDatabaseDxe/Image.c
@@ -643,10 +643,6 @@ HiiNewImage (
     return EFI_INVALID_PARAMETER;
   }
 
-  if (!IsHiiHandleValid (PackageList)) {
-    return EFI_NOT_FOUND;
-  }
-
   Private = HII_IMAGE_DATABASE_PRIVATE_DATA_FROM_THIS (This);
   PackageListNode = LocatePackageList (&Private->DatabaseList, PackageList);
   if (PackageListNode == NULL) {
@@ -781,33 +777,34 @@ HiiNewImage (
   This function retrieves the image specified by ImageId which is associated with
   the specified PackageList and copies it into the buffer specified by Image.
 
-  @param  This                   A pointer to the EFI_HII_IMAGE_PROTOCOL instance.
+  @param  Database               A pointer to the database list header.
   @param  PackageList            Handle of the package list where this image will
                                  be searched.
   @param  ImageId                The image's id,, which is unique within
                                  PackageList.
   @param  Image                  Points to the image.
+  @param  BitmapOnly             TRUE to only return the bitmap type image.
+                                 FALSE to locate image decoder instance to decode image.
 
   @retval EFI_SUCCESS            The new image was returned successfully.
-  @retval EFI_NOT_FOUND           The image specified by ImageId is not in the
-                                                database. The specified PackageList is not in the database.
+  @retval EFI_NOT_FOUND          The image specified by ImageId is not in the
+                                 database. The specified PackageList is not in the database.
   @retval EFI_BUFFER_TOO_SMALL   The buffer specified by ImageSize is too small to
                                  hold the image.
   @retval EFI_INVALID_PARAMETER  The Image or ImageSize was NULL.
   @retval EFI_OUT_OF_RESOURCES   The bitmap could not be retrieved because there was not
-                                                     enough memory.
-
+                                 enough memory.
 **/
 EFI_STATUS
-EFIAPI
-HiiGetImage (
-  IN  CONST EFI_HII_IMAGE_PROTOCOL   *This,
+IGetImage (
+  IN  LIST_ENTRY                     *Database,
   IN  EFI_HII_HANDLE                 PackageList,
   IN  EFI_IMAGE_ID                   ImageId,
-  OUT EFI_IMAGE_INPUT                *Image
+  OUT EFI_IMAGE_INPUT                *Image,
+  IN  BOOLEAN                        BitmapOnly
   )
 {
-  HII_DATABASE_PRIVATE_DATA           *Private;
+  EFI_STATUS                          Status;
   HII_DATABASE_PACKAGE_LIST_INSTANCE  *PackageListNode;
   HII_IMAGE_PACKAGE_INSTANCE          *ImagePackage;
   EFI_HII_IMAGE_BLOCK                 *CurrentImageBlock;
@@ -818,17 +815,14 @@ HiiGetImage (
   UINT8                               *PaletteInfo;
   UINT8                               PaletteIndex;
   UINT16                              PaletteSize;
+  EFI_HII_IMAGE_DECODER_PROTOCOL      *Decoder;
+  EFI_IMAGE_OUTPUT                    *ImageOut;
 
-  if (This == NULL || Image == NULL || ImageId == 0) {
+  if (Image == NULL || ImageId == 0) {
     return EFI_INVALID_PARAMETER;
   }
 
-  if (!IsHiiHandleValid (PackageList)) {
-    return EFI_NOT_FOUND;
-  }
-
-  Private = HII_IMAGE_DATABASE_PRIVATE_DATA_FROM_THIS (This);
-  PackageListNode = LocatePackageList (&Private->DatabaseList, PackageList);
+  PackageListNode = LocatePackageList (Database, PackageList);
   if (PackageListNode == NULL) {
     return EFI_NOT_FOUND;
   }
@@ -845,14 +839,46 @@ HiiGetImage (
     return EFI_NOT_FOUND;
   }
 
+  Image->Flags = 0;
   switch (CurrentImageBlock->BlockType) {
   case EFI_HII_IIBT_IMAGE_JPEG:
   case EFI_HII_IIBT_IMAGE_PNG:
+    if (BitmapOnly) {
+      return EFI_UNSUPPORTED;
+    }
+
+    ImageOut = NULL;
+    Decoder = LocateHiiImageDecoder (CurrentImageBlock->BlockType);
+    if (Decoder == NULL) {
+      return EFI_UNSUPPORTED;
+    }
     //
-    // HiiImage protocol doesn't support return JPEG/PNG.
-    // Use HiiImageEx instead.
+    // Use the common block code since the definition of two structures is the same.
     //
-    return EFI_UNSUPPORTED;
+    ASSERT (OFFSET_OF (EFI_HII_IIBT_JPEG_BLOCK, Data) == OFFSET_OF (EFI_HII_IIBT_PNG_BLOCK, Data));
+    ASSERT (sizeof (((EFI_HII_IIBT_JPEG_BLOCK *) CurrentImageBlock)->Data) ==
+            sizeof (((EFI_HII_IIBT_PNG_BLOCK *) CurrentImageBlock)->Data));
+    ASSERT (OFFSET_OF (EFI_HII_IIBT_JPEG_BLOCK, Size) == OFFSET_OF (EFI_HII_IIBT_PNG_BLOCK, Size));
+    ASSERT (sizeof (((EFI_HII_IIBT_JPEG_BLOCK *) CurrentImageBlock)->Size) ==
+            sizeof (((EFI_HII_IIBT_PNG_BLOCK *) CurrentImageBlock)->Size));
+    Status = Decoder->DecodeImage (
+      Decoder,
+      ((EFI_HII_IIBT_JPEG_BLOCK *) CurrentImageBlock)->Data,
+      ((EFI_HII_IIBT_JPEG_BLOCK *) CurrentImageBlock)->Size,
+      &ImageOut,
+      FALSE
+    );
+
+    //
+    // Spec requires to use the first capable image decoder instance.
+    // The first image decoder instance may fail to decode the image.
+    //
+    if (!EFI_ERROR (Status)) {
+      Image->Bitmap = ImageOut->Image.Bitmap;
+      Image->Height = ImageOut->Height;
+      Image->Width = ImageOut->Width;
+    }
+    return Status;
 
   case EFI_HII_IIBT_IMAGE_1BIT_TRANS:
   case EFI_HII_IIBT_IMAGE_4BIT_TRANS:
@@ -870,7 +896,7 @@ HiiGetImage (
     CopyMem (&Iibt1bit, CurrentImageBlock, sizeof (EFI_HII_IIBT_IMAGE_1BIT_BLOCK));
     ImageLength = sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL) *
                   (Iibt1bit.Bitmap.Width * Iibt1bit.Bitmap.Height);
-    Image->Bitmap = (EFI_GRAPHICS_OUTPUT_BLT_PIXEL *) AllocateZeroPool (ImageLength);
+    Image->Bitmap = AllocateZeroPool (ImageLength);
     if (Image->Bitmap == NULL) {
       return EFI_OUT_OF_RESOURCES;
     }
@@ -943,6 +969,41 @@ HiiGetImage (
   }
 }
 
+/**
+  This function retrieves the image specified by ImageId which is associated with
+  the specified PackageList and copies it into the buffer specified by Image.
+
+  @param  This                   A pointer to the EFI_HII_IMAGE_PROTOCOL instance.
+  @param  PackageList            Handle of the package list where this image will
+                                 be searched.
+  @param  ImageId                The image's id,, which is unique within
+                                 PackageList.
+  @param  Image                  Points to the image.
+
+  @retval EFI_SUCCESS            The new image was returned successfully.
+  @retval EFI_NOT_FOUND           The image specified by ImageId is not in the
+                                                database. The specified PackageList is not in the database.
+  @retval EFI_BUFFER_TOO_SMALL   The buffer specified by ImageSize is too small to
+                                 hold the image.
+  @retval EFI_INVALID_PARAMETER  The Image or ImageSize was NULL.
+  @retval EFI_OUT_OF_RESOURCES   The bitmap could not be retrieved because there was not
+                                 enough memory.
+
+**/
+EFI_STATUS
+EFIAPI
+HiiGetImage (
+  IN  CONST EFI_HII_IMAGE_PROTOCOL   *This,
+  IN  EFI_HII_HANDLE                 PackageList,
+  IN  EFI_IMAGE_ID                   ImageId,
+  OUT EFI_IMAGE_INPUT                *Image
+  )
+{
+  HII_DATABASE_PRIVATE_DATA           *Private;
+  Private = HII_IMAGE_DATABASE_PRIVATE_DATA_FROM_THIS (This);
+  return IGetImage (&Private->DatabaseList, PackageList, ImageId, Image, TRUE);
+}
+
 
 /**
   This function updates the image specified by ImageId in the specified PackageListHandle to
@@ -984,10 +1045,6 @@ HiiSetImage (
     return EFI_INVALID_PARAMETER;
   }
 
-  if (!IsHiiHandleValid (PackageList)) {
-    return EFI_NOT_FOUND;
-  }
-
   Private = HII_IMAGE_DATABASE_PRIVATE_DATA_FROM_THIS (This);
   PackageListNode = LocatePackageList (&Private->DatabaseList, PackageList);
   if (PackageListNode == NULL) {
@@ -1394,10 +1451,6 @@ HiiDrawImageId (
     return EFI_INVALID_PARAMETER;
   }
 
-  if (!IsHiiHandleValid (PackageList)) {
-    return EFI_NOT_FOUND;
-  }
-
   //
   // Get the specified Image.
   //
diff --git a/MdeModulePkg/Universal/HiiDatabaseDxe/ImageEx.c b/MdeModulePkg/Universal/HiiDatabaseDxe/ImageEx.c
new file mode 100644
index 0000000..2d9c86b
--- /dev/null
+++ b/MdeModulePkg/Universal/HiiDatabaseDxe/ImageEx.c
@@ -0,0 +1,397 @@
+/** @file
+Implementation for EFI_HII_IMAGE_EX_PROTOCOL.
+
+
+Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>
+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
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+
+#include "HiiDatabase.h"
+
+/**
+  The prototype of this extension function is the same with EFI_HII_IMAGE_PROTOCOL.NewImage().
+  This protocol invokes EFI_HII_IMAGE_PROTOCOL.NewImage() implicitly.
+
+  @param  This                   A pointer to the EFI_HII_IMAGE_EX_PROTOCOL instance.
+  @param  PackageList            Handle of the package list where this image will
+                                 be added.
+  @param  ImageId                On return, contains the new image id, which is
+                                 unique within PackageList.
+  @param  Image                  Points to the image.
+
+  @retval EFI_SUCCESS            The new image was added successfully.
+  @retval EFI_NOT_FOUND          The PackageList could not be found.
+  @retval EFI_OUT_OF_RESOURCES   Could not add the image due to lack of resources.
+  @retval EFI_INVALID_PARAMETER  Image is NULL or ImageId is NULL.
+**/
+EFI_STATUS
+EFIAPI
+HiiNewImageEx (
+  IN  CONST EFI_HII_IMAGE_EX_PROTOCOL *This,
+  IN  EFI_HII_HANDLE                  PackageList,
+  OUT EFI_IMAGE_ID                    *ImageId,
+  IN  CONST EFI_IMAGE_INPUT           *Image
+  )
+{
+  HII_DATABASE_PRIVATE_DATA           *Private;
+
+  Private = HII_IMAGE_EX_DATABASE_PRIVATE_DATA_FROM_THIS (This);
+  return HiiNewImage (&Private->HiiImage, PackageList, ImageId, Image);
+}
+
+/**
+  Return the information about the image, associated with the package list.
+  The prototype of this extension function is the same with EFI_HII_IMAGE_PROTOCOL.GetImage().
+
+  This function is similar to EFI_HII_IMAGE_PROTOCOL.GetImage().The difference is that
+  this function will locate all EFI_HII_IMAGE_DECODER_PROTOCOL instances installed in the
+  system if the decoder of the certain image type is not supported by the
+  EFI_HII_IMAGE_EX_PROTOCOL. The function will attempt to decode the image to the
+  EFI_IMAGE_INPUT using the first EFI_HII_IMAGE_DECODER_PROTOCOL instance that
+  supports the requested image type.
+
+  @param  This                   A pointer to the EFI_HII_IMAGE_EX_PROTOCOL instance.
+  @param  PackageList            The package list in the HII database to search for the
+                                 specified image.
+  @param  ImageId                The image's id, which is unique within PackageList.
+  @param  Image                  Points to the image.
+
+  @retval EFI_SUCCESS            The new image was returned successfully.
+  @retval EFI_NOT_FOUND          The image specified by ImageId is not available. The specified
+                                 PackageList is not in the Database.
+  @retval EFI_INVALID_PARAMETER  Image was NULL or ImageId was 0.
+  @retval EFI_OUT_OF_RESOURCES   The bitmap could not be retrieved because there
+                                 was not enough memory.
+
+**/
+EFI_STATUS
+EFIAPI
+HiiGetImageEx (
+  IN  CONST EFI_HII_IMAGE_EX_PROTOCOL *This,
+  IN  EFI_HII_HANDLE                  PackageList,
+  IN  EFI_IMAGE_ID                    ImageId,
+  OUT EFI_IMAGE_INPUT                 *Image
+  )
+{
+  HII_DATABASE_PRIVATE_DATA           *Private;
+
+  Private = HII_IMAGE_EX_DATABASE_PRIVATE_DATA_FROM_THIS (This);
+  return IGetImage (&Private->DatabaseList, PackageList, ImageId, Image, FALSE);
+}
+
+
+/**
+  Change the information about the image.
+
+  Same with EFI_HII_IMAGE_PROTOCOL.SetImage(),this protocol invokes
+  EFI_HII_IMAGE_PROTOCOL.SetImage()implicitly.
+
+  @param  This                   A pointer to the EFI_HII_IMAGE_EX_PROTOCOL instance.
+  @param  PackageList            The package list containing the images.
+  @param  ImageId                The image's id, which is unique within PackageList.
+  @param  Image                  Points to the image.
+
+  @retval EFI_SUCCESS            The new image was successfully updated.
+  @retval EFI_NOT_FOUND          The image specified by ImageId is not in the
+                                 database. The specified PackageList is not in
+                                 the database.
+  @retval EFI_INVALID_PARAMETER  The Image was NULL, the ImageId was 0 or
+                                 the Image->Bitmap was NULL.
+
+**/
+EFI_STATUS
+EFIAPI
+HiiSetImageEx (
+  IN CONST EFI_HII_IMAGE_EX_PROTOCOL *This,
+  IN EFI_HII_HANDLE                  PackageList,
+  IN EFI_IMAGE_ID                    ImageId,
+  IN CONST EFI_IMAGE_INPUT           *Image
+  )
+{
+  HII_DATABASE_PRIVATE_DATA           *Private;
+  Private = HII_IMAGE_EX_DATABASE_PRIVATE_DATA_FROM_THIS (This);
+  return HiiSetImage (&Private->HiiImage, PackageList, ImageId, Image);
+}
+
+
+/**
+  Renders an image to a bitmap or to the display.
+
+  The prototype of this extension function is the same with
+  EFI_HII_IMAGE_PROTOCOL.DrawImage(). This protocol invokes
+  EFI_HII_IMAGE_PROTOCOL.DrawImage() implicitly.
+
+  @param  This                   A pointer to the EFI_HII_IMAGE_EX_PROTOCOL instance.
+  @param  Flags                  Describes how the image is to be drawn.
+  @param  Image                  Points to the image to be displayed.
+  @param  Blt                    If this points to a non-NULL on entry, this points
+                                 to the image, which is Width pixels wide and
+                                 Height pixels high.  The image will be drawn onto
+                                 this image and  EFI_HII_DRAW_FLAG_CLIP is implied.
+                                 If this points to a NULL on entry, then a buffer
+                                 will be allocated to hold the generated image and
+                                 the pointer updated on exit. It is the caller's
+                                 responsibility to free this buffer.
+  @param  BltX                   Specifies the offset from the left and top edge of
+                                 the output image of the first pixel in the image.
+  @param  BltY                   Specifies the offset from the left and top edge of
+                                 the output image of the first pixel in the image.
+
+  @retval EFI_SUCCESS            The image was successfully drawn.
+  @retval EFI_OUT_OF_RESOURCES   Unable to allocate an output buffer for Blt.
+  @retval EFI_INVALID_PARAMETER  The Image or Blt was NULL.
+
+**/
+EFI_STATUS
+EFIAPI
+HiiDrawImageEx (
+  IN CONST EFI_HII_IMAGE_EX_PROTOCOL *This,
+  IN EFI_HII_DRAW_FLAGS              Flags,
+  IN CONST EFI_IMAGE_INPUT           *Image,
+  IN OUT EFI_IMAGE_OUTPUT            **Blt,
+  IN UINTN                           BltX,
+  IN UINTN                           BltY
+  )
+{
+  HII_DATABASE_PRIVATE_DATA           *Private;
+  Private = HII_IMAGE_EX_DATABASE_PRIVATE_DATA_FROM_THIS (This);
+  return HiiDrawImage (&Private->HiiImage, Flags, Image, Blt, BltX, BltY);
+}
+
+
+/**
+  Renders an image to a bitmap or the screen containing the contents of the specified
+  image.
+  
+  The prototype of this extension function is the same with
+  EFI_HII_IMAGE_PROTOCOL.DrawImageId(). This protocol invokes
+  EFI_HII_IMAGE_PROTOCOL.DrawImageId() implicitly.
+
+  @param  This                   A pointer to the EFI_HII_IMAGE_EX_PROTOCOL instance.
+  @param  Flags                  Describes how the image is to be drawn.
+  @param  PackageList            The package list in the HII database to search for
+                                 the  specified image.
+  @param  ImageId                The image's id, which is unique within PackageList.
+  @param  Blt                    If this points to a non-NULL on entry, this points
+                                 to the image, which is Width pixels wide and
+                                 Height pixels high. The image will be drawn onto
+                                 this image and EFI_HII_DRAW_FLAG_CLIP is implied.
+                                 If this points to a NULL on entry, then a buffer
+                                 will be allocated to hold  the generated image
+                                 and the pointer updated on exit. It is the caller's
+                                 responsibility to free this buffer.
+  @param  BltX                   Specifies the offset from the left and top edge of
+                                 the output image of the first pixel in the image.
+  @param  BltY                   Specifies the offset from the left and top edge of
+                                 the output image of the first pixel in the image.
+
+  @retval EFI_SUCCESS            The image was successfully drawn.
+  @retval EFI_OUT_OF_RESOURCES   Unable to allocate an output buffer for Blt.
+  @retval EFI_INVALID_PARAMETER  The Blt was NULL or ImageId was 0.
+  @retval EFI_NOT_FOUND          The image specified by ImageId is not in the database.
+                                 The specified PackageList is not in the database.
+
+**/
+EFI_STATUS
+EFIAPI
+HiiDrawImageIdEx (
+  IN CONST EFI_HII_IMAGE_EX_PROTOCOL *This,
+  IN EFI_HII_DRAW_FLAGS              Flags,
+  IN EFI_HII_HANDLE                  PackageList,
+  IN EFI_IMAGE_ID                    ImageId,
+  IN OUT EFI_IMAGE_OUTPUT            **Blt,
+  IN UINTN                           BltX,
+  IN UINTN                           BltY
+  )
+{
+  HII_DATABASE_PRIVATE_DATA           *Private;
+  Private = HII_IMAGE_EX_DATABASE_PRIVATE_DATA_FROM_THIS (This);
+  return HiiDrawImageId (&Private->HiiImage, Flags, PackageList, ImageId, Blt, BltX, BltY);
+}
+
+/**
+  Return the first HII image decoder instance which supports the DecoderName.
+
+  @param BlockType  The image block type.
+
+  @retval Pointer to the HII image decoder instance.
+**/
+EFI_HII_IMAGE_DECODER_PROTOCOL *
+LocateHiiImageDecoder (
+  UINT8                          BlockType
+  )
+{
+  EFI_STATUS                     Status;
+  EFI_HII_IMAGE_DECODER_PROTOCOL *Decoder;
+  EFI_HANDLE                     *Handles;
+  UINTN                          HandleNum;
+  UINTN                          Index;
+  EFI_GUID                       *DecoderNames;
+  UINT16                         NumberOfDecoderName;
+  UINT16                         DecoderNameIndex;
+  EFI_GUID                       *DecoderName;
+
+  switch (BlockType) {
+  case EFI_HII_IIBT_IMAGE_JPEG:
+    DecoderName = &gEfiHiiImageDecoderNameJpegGuid;
+    break;
+
+  case EFI_HII_IIBT_IMAGE_PNG:
+    DecoderName = &gEfiHiiImageDecoderNamePngGuid;
+    break;
+ 
+  default:
+    ASSERT (FALSE);
+    return NULL;
+  }
+
+  Status = gBS->LocateHandleBuffer (ByProtocol, &gEfiHiiImageDecoderProtocolGuid, NULL, &HandleNum, &Handles);
+  if (EFI_ERROR (Status)) {
+    return NULL;
+  }
+  for (Index = 0; Index < HandleNum; Index++) {
+    Status = gBS->HandleProtocol (Handles[Index], &gEfiHiiImageDecoderProtocolGuid, (VOID **) &Decoder);
+    if (EFI_ERROR (Status)) {
+      continue;
+    }
+
+    Status = Decoder->GetImageDecoderName (Decoder, &DecoderNames, &NumberOfDecoderName);
+    if (EFI_ERROR (Status)) {
+      continue;
+    }
+    for (DecoderNameIndex = 0; DecoderNameIndex < NumberOfDecoderName; DecoderNameIndex++) {
+      if (CompareGuid (DecoderName, &DecoderNames[DecoderNameIndex])) {
+        return Decoder;
+      }
+    }
+  }
+
+  return NULL;
+}
+
+/**
+  This function returns the image information to EFI_IMAGE_OUTPUT. Only the width
+  and height are returned to the EFI_IMAGE_OUTPUT instead of decoding the image
+  to the buffer. This function is used to get the geometry of the image. This function
+  will try to locate all of the EFI_HII_IMAGE_DECODER_PROTOCOL installed on the
+  system if the decoder of image type is not supported by the EFI_HII_IMAGE_EX_PROTOCOL.
+
+  @param  This                   A pointer to the EFI_HII_IMAGE_EX_PROTOCOL instance.
+  @param  PackageList            Handle of the package list where this image will
+                                 be searched.
+  @param  ImageId                The image's id, which is unique within PackageList.
+  @param  Image                  Points to the image.
+
+  @retval EFI_SUCCESS            The new image was returned successfully.
+  @retval EFI_NOT_FOUND          The image specified by ImageId is not in the
+                                 database. The specified PackageList is not in the database.
+  @retval EFI_BUFFER_TOO_SMALL   The buffer specified by ImageSize is too small to
+                                 hold the image.
+  @retval EFI_INVALID_PARAMETER  The Image was NULL or the ImageId was 0.
+  @retval EFI_OUT_OF_RESOURCES   The bitmap could not be retrieved because there
+                                 was not enough memory.
+
+**/
+EFI_STATUS
+EFIAPI
+HiiGetImageInfo (
+  IN CONST  EFI_HII_IMAGE_EX_PROTOCOL       *This,
+  IN        EFI_HII_HANDLE                  PackageList,
+  IN        EFI_IMAGE_ID                    ImageId,
+  OUT       EFI_IMAGE_OUTPUT                *Image
+  )
+{
+  EFI_STATUS                              Status;
+  HII_DATABASE_PRIVATE_DATA               *Private;
+  HII_DATABASE_PACKAGE_LIST_INSTANCE      *PackageListNode;
+  HII_IMAGE_PACKAGE_INSTANCE              *ImagePackage;
+  EFI_HII_IMAGE_BLOCK                     *CurrentImageBlock;
+  EFI_HII_IMAGE_DECODER_PROTOCOL          *Decoder;
+  EFI_HII_IMAGE_DECODER_IMAGE_INFO_HEADER *ImageInfo;
+
+  if (Image == NULL || ImageId == 0) {
+    return EFI_INVALID_PARAMETER;
+  }
+
+  Private = HII_IMAGE_EX_DATABASE_PRIVATE_DATA_FROM_THIS (This);
+  PackageListNode = LocatePackageList (&Private->DatabaseList, PackageList);
+  if (PackageListNode == NULL) {
+    return EFI_NOT_FOUND;
+  }
+  ImagePackage = PackageListNode->ImagePkg;
+  if (ImagePackage == NULL) {
+    return EFI_NOT_FOUND;
+  }
+
+  //
+  // Find the image block specified by ImageId
+  //
+  CurrentImageBlock = GetImageIdOrAddress (ImagePackage->ImageBlock, &ImageId);
+  switch (CurrentImageBlock->BlockType) {
+  case EFI_HII_IIBT_IMAGE_JPEG:
+  case EFI_HII_IIBT_IMAGE_PNG:
+    Decoder = LocateHiiImageDecoder (CurrentImageBlock->BlockType);
+    if (Decoder == NULL) {
+      return EFI_UNSUPPORTED;
+    }
+    //
+    // Use the common block code since the definition of two structures is the same.
+    //
+    ASSERT (OFFSET_OF (EFI_HII_IIBT_JPEG_BLOCK, Data) == OFFSET_OF (EFI_HII_IIBT_PNG_BLOCK, Data));
+    ASSERT (sizeof (((EFI_HII_IIBT_JPEG_BLOCK *) CurrentImageBlock)->Data) ==
+            sizeof (((EFI_HII_IIBT_PNG_BLOCK *) CurrentImageBlock)->Data));
+    ASSERT (OFFSET_OF (EFI_HII_IIBT_JPEG_BLOCK, Size) == OFFSET_OF (EFI_HII_IIBT_PNG_BLOCK, Size));
+    ASSERT (sizeof (((EFI_HII_IIBT_JPEG_BLOCK *) CurrentImageBlock)->Size) ==
+            sizeof (((EFI_HII_IIBT_PNG_BLOCK *) CurrentImageBlock)->Size));
+    Status = Decoder->GetImageInfo (
+      Decoder,
+      ((EFI_HII_IIBT_JPEG_BLOCK *) CurrentImageBlock)->Data,
+      ((EFI_HII_IIBT_JPEG_BLOCK *) CurrentImageBlock)->Size,
+      &ImageInfo
+    );
+
+    //
+    // Spec requires to use the first capable image decoder instance.
+    // The first image decoder instance may fail to decode the image.
+    //
+    if (!EFI_ERROR (Status)) {
+      Image->Height = ImageInfo->ImageHeight;
+      Image->Width = ImageInfo->ImageWidth;
+      Image->Image.Bitmap = NULL;
+      FreePool (ImageInfo);
+    }
+    return Status;
+
+  case EFI_HII_IIBT_IMAGE_1BIT_TRANS:
+  case EFI_HII_IIBT_IMAGE_4BIT_TRANS:
+  case EFI_HII_IIBT_IMAGE_8BIT_TRANS:
+  case EFI_HII_IIBT_IMAGE_1BIT:
+  case EFI_HII_IIBT_IMAGE_4BIT:
+  case EFI_HII_IIBT_IMAGE_8BIT:
+    //
+    // Use the common block code since the definition of these structures is the same.
+    //
+    Image->Width = ReadUnaligned16 (&((EFI_HII_IIBT_IMAGE_1BIT_BLOCK *) CurrentImageBlock)->Bitmap.Width);
+    Image->Height = ReadUnaligned16 (&((EFI_HII_IIBT_IMAGE_1BIT_BLOCK *) CurrentImageBlock)->Bitmap.Height);
+    Image->Image.Bitmap = NULL;
+    return EFI_SUCCESS;
+
+  case EFI_HII_IIBT_IMAGE_24BIT_TRANS:
+  case EFI_HII_IIBT_IMAGE_24BIT:
+    Image->Width = ReadUnaligned16 (&((EFI_HII_IIBT_IMAGE_24BIT_BLOCK *) CurrentImageBlock)->Bitmap.Width);
+    Image->Height = ReadUnaligned16 (&((EFI_HII_IIBT_IMAGE_24BIT_BLOCK *) CurrentImageBlock)->Bitmap.Height);
+    Image->Image.Bitmap = NULL;
+    return EFI_SUCCESS;
+
+  default:
+    return EFI_NOT_FOUND;
+  }
+}
\ No newline at end of file
-- 
2.9.0.windows.1



^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 10/13] Nt32Pkg/PlatformBds: Do not call BootLogoEnableLogo
  2016-09-23  8:25 [PATCH 00/13] Add HiiImageEx implementation and demonstrate in Nt32 Ruiyu Ni
                   ` (8 preceding siblings ...)
  2016-09-23  8:25 ` [PATCH 09/13] MdeModulePkg/HiiDatabase: Add HiiImageEx implementation Ruiyu Ni
@ 2016-09-23  8:25 ` Ruiyu Ni
  2016-09-23  8:25 ` [PATCH 11/13] MdeModulePkg/BootLogoLib&PlatformLogo: Use HII data types in parameters Ruiyu Ni
                   ` (3 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: Ruiyu Ni @ 2016-09-23  8:25 UTC (permalink / raw)
  To: edk2-devel; +Cc: Liming Gao, Eric Dong, Dandan Bi

Prototype of BootLogoEnableLogo will change in following patches, so
do not call BootLogoEnableLogo to avoid build failure.

Contributed-under: TianoCore Contribution Agreement 1.0
Cc: Liming Gao <liming.gao@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Dandan Bi <dandan.bi@intel.com>
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
---
 Nt32Pkg/Library/PlatformBootManagerLib/PlatformBootManager.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/Nt32Pkg/Library/PlatformBootManagerLib/PlatformBootManager.c b/Nt32Pkg/Library/PlatformBootManagerLib/PlatformBootManager.c
index 76d926b..373442e 100644
--- a/Nt32Pkg/Library/PlatformBootManagerLib/PlatformBootManager.c
+++ b/Nt32Pkg/Library/PlatformBootManagerLib/PlatformBootManager.c
@@ -2,7 +2,7 @@
   This file include all platform action which can be customized
   by IBV/OEM.
 
-Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.<BR>
 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
@@ -42,7 +42,7 @@ PlatformBootManagerDiagnostics (
   // from the graphic lib
   //
   if (QuietBoot) {
-    BootLogoEnableLogo (ImageFormatBmp, PcdGetPtr(PcdLogoFile), EdkiiPlatformLogoDisplayAttributeCenter, 0, 0);
+    // BootLogoEnableLogo (ImageFormatBmp, PcdGetPtr(PcdLogoFile), EdkiiPlatformLogoDisplayAttributeCenter, 0, 0);
 
     //
     // Perform system diagnostic
-- 
2.9.0.windows.1



^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 11/13] MdeModulePkg/BootLogoLib&PlatformLogo: Use HII data types in parameters
  2016-09-23  8:25 [PATCH 00/13] Add HiiImageEx implementation and demonstrate in Nt32 Ruiyu Ni
                   ` (9 preceding siblings ...)
  2016-09-23  8:25 ` [PATCH 10/13] Nt32Pkg/PlatformBds: Do not call BootLogoEnableLogo Ruiyu Ni
@ 2016-09-23  8:25 ` Ruiyu Ni
  2016-09-23  8:25 ` [PATCH 12/13] MdeModulePkg/Logo: Add LogoDxe module Ruiyu Ni
                   ` (2 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: Ruiyu Ni @ 2016-09-23  8:25 UTC (permalink / raw)
  To: edk2-devel; +Cc: Liming Gao, Eric Dong, Dandan Bi

1. Change PlatformLogo protocol to return EFI_IMAGE_INPUT instead of
   RAW image data. PlatformLogo implementation can use HiiImageEx to
   decode the image if it's JPEG or PNG format.
2. Change BootLogoLib to consume the new PlatformLogo protocol.
3. Change BootLogoEnableLogo() to only use images returned from
   PlatformLogo protocol.

Contributed-under: TianoCore Contribution Agreement 1.0
Cc: Liming Gao <liming.gao@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Dandan Bi <dandan.bi@intel.com>
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
---
 MdeModulePkg/Include/Library/BootLogoLib.h       |  19 +--
 MdeModulePkg/Include/Protocol/PlatformLogo.h     |  18 +-
 MdeModulePkg/Library/BootLogoLib/BootLogoLib.c   | 204 +++++++++--------------
 MdeModulePkg/Library/BootLogoLib/BootLogoLib.inf |   6 +-
 4 files changed, 86 insertions(+), 161 deletions(-)

diff --git a/MdeModulePkg/Include/Library/BootLogoLib.h b/MdeModulePkg/Include/Library/BootLogoLib.h
index 55fe4b1..cacdd29 100644
--- a/MdeModulePkg/Include/Library/BootLogoLib.h
+++ b/MdeModulePkg/Include/Library/BootLogoLib.h
@@ -2,7 +2,7 @@
   This library is only intended to be used by PlatformBootManagerLib
   to show progress bar and LOGO.
 
-Copyright (c) 2011 - 2015, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2011 - 2016, Intel Corporation. All rights reserved.<BR>
 This program and the accompanying materials are licensed and made available under
 the terms and conditions of the BSD License that accompanies this distribution.
 The full text of the license may be found at
@@ -20,25 +20,12 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #include <Protocol/GraphicsOutput.h>
 
 /**
-  Show LOGO on all consoles.
-
-  @param[in]  ImageFormat Format of the image file.
-  @param[in]  LogoFile    The file name of logo to display.
-  @param[in]  Attribute   The display attributes of the image returned.
-  @param[in]  OffsetX     The X offset of the image regarding the Attribute.
-  @param[in]  OffsetY     The Y offset of the image regarding the Attribute.
-
-  @retval EFI_SUCCESS     Logo was displayed.
-  @retval EFI_UNSUPPORTED Logo was not found or cannot be displayed.
+  Show LOGO returned from Edkii Platform Logo protocol on all consoles.
 **/
 EFI_STATUS
 EFIAPI
 BootLogoEnableLogo (
-  IN  IMAGE_FORMAT                          ImageFormat,
-  IN  EFI_GUID                              *Logo,
-  IN  EDKII_PLATFORM_LOGO_DISPLAY_ATTRIBUTE Attribute,
-  IN  INTN                                  OffsetX,
-  IN  INTN                                  OffsetY
+  VOID
   );
 
 
diff --git a/MdeModulePkg/Include/Protocol/PlatformLogo.h b/MdeModulePkg/Include/Protocol/PlatformLogo.h
index 8c1d3ca..bb98c56 100644
--- a/MdeModulePkg/Include/Protocol/PlatformLogo.h
+++ b/MdeModulePkg/Include/Protocol/PlatformLogo.h
@@ -2,7 +2,7 @@
   The Platform Logo Protocol defines the interface to get the Platform logo
   image with the display attribute.
 
-Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.<BR>
 This program and the accompanying materials are licensed and made available under 
 the terms and conditions of the BSD License that accompanies this distribution.  
 The full text of the license may be found at
@@ -16,6 +16,8 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #ifndef __PLATFORM_LOGO_H__
 #define __PLATFORM_LOGO_H__
 
+#include <Protocol/HiiImage.h>
+
 //
 // GUID for EDKII Platform Logo Protocol
 //
@@ -25,14 +27,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 typedef struct _EDKII_PLATFORM_LOGO_PROTOCOL EDKII_PLATFORM_LOGO_PROTOCOL;
 
 typedef enum {
-  ImageFormatUnknown,
-  ImageFormatBmp,
-  ImageFormatJpeg,
-  ImageFormatTiff,
-  ImageFormatGif
-} IMAGE_FORMAT;
-
-typedef enum {
   EdkiiPlatformLogoDisplayAttributeLeftTop,
   EdkiiPlatformLogoDisplayAttributeCenterTop,
   EdkiiPlatformLogoDisplayAttributeRightTop,
@@ -67,13 +61,11 @@ EFI_STATUS
 (EFIAPI *EDKII_PLATFORM_LOGO_GET_IMAGE)(
   IN     EDKII_PLATFORM_LOGO_PROTOCOL          *This,
   IN OUT UINT32                                *Instance,
-     OUT IMAGE_FORMAT                          *Format,
-     OUT UINT8                                 **ImageData,
-     OUT UINTN                                 *ImageSize,
+     OUT EFI_IMAGE_INPUT                       *Image,
      OUT EDKII_PLATFORM_LOGO_DISPLAY_ATTRIBUTE *Attribute,
      OUT INTN                                  *OffsetX,
      OUT INTN                                  *OffsetY
-);
+  );
 
 
 struct _EDKII_PLATFORM_LOGO_PROTOCOL {
diff --git a/MdeModulePkg/Library/BootLogoLib/BootLogoLib.c b/MdeModulePkg/Library/BootLogoLib/BootLogoLib.c
index 7cb3bcb..2c1e8ea 100644
--- a/MdeModulePkg/Library/BootLogoLib/BootLogoLib.c
+++ b/MdeModulePkg/Library/BootLogoLib/BootLogoLib.c
@@ -2,7 +2,7 @@
   This library is only intended to be used by PlatformBootManagerLib
   to show progress bar and LOGO.
 
-Copyright (c) 2011 - 2015, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2011 - 2016, Intel Corporation. All rights reserved.<BR>
 This program and the accompanying materials are licensed and made available under
 the terms and conditions of the BSD License that accompanies this distribution.
 The full text of the license may be found at
@@ -13,30 +13,22 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 
 **/
 
-#include <PiDxe.h>
+#include <Uefi.h>
+#include <Protocol/GraphicsOutput.h>
 #include <Protocol/SimpleTextOut.h>
 #include <Protocol/PlatformLogo.h>
-#include <Protocol/GraphicsOutput.h>
 #include <Protocol/UgaDraw.h>
 #include <Protocol/BootLogo.h>
 #include <Library/BaseLib.h>
 #include <Library/UefiLib.h>
 #include <Library/BaseMemoryLib.h>
 #include <Library/UefiBootServicesTableLib.h>
-#include <Library/DxeServicesLib.h>
 #include <Library/PcdLib.h>
 #include <Library/MemoryAllocationLib.h>
 #include <Library/DebugLib.h>
-#include <Library/ImageDecoderLib.h>
 
 /**
-  Show LOGO on all consoles.
-
-  @param[in]  ImageFormat Format of the image file.
-  @param[in]  LogoFile    The file name of logo to display.
-  @param[in]  Attribute   The display attributes of the image returned.
-  @param[in]  OffsetX     The X offset of the image regarding the Attribute.
-  @param[in]  OffsetY     The Y offset of the image regarding the Attribute.
+  Show LOGO returned from Edkii Platform Logo protocol on all consoles.
 
   @retval EFI_SUCCESS     Logo was displayed.
   @retval EFI_UNSUPPORTED Logo was not found or cannot be displayed.
@@ -44,42 +36,40 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 EFI_STATUS
 EFIAPI
 BootLogoEnableLogo (
-  IN  IMAGE_FORMAT                          ImageFormat,
-  IN  EFI_GUID                              *Logo,
-  IN  EDKII_PLATFORM_LOGO_DISPLAY_ATTRIBUTE Attribute,
-  IN  INTN                                  OffsetX,
-  IN  INTN                                  OffsetY
+  VOID
   )
 {
-  EFI_STATUS                    Status;
-  EDKII_PLATFORM_LOGO_PROTOCOL  *PlatformLogo;
-  UINT32                        SizeOfX;
-  UINT32                        SizeOfY;
-  INTN                          DestX;
-  INTN                          DestY;
-  UINT8                         *ImageData;
-  UINTN                         ImageSize;
-  UINTN                         BltSize;
-  UINT32                        Instance;
-  UINTN                         Height;
-  UINTN                         Width;
-  EFI_GRAPHICS_OUTPUT_BLT_PIXEL *Blt;
-  EFI_UGA_DRAW_PROTOCOL         *UgaDraw;
-  UINT32                        ColorDepth;
-  UINT32                        RefreshRate;
-  EFI_GRAPHICS_OUTPUT_PROTOCOL  *GraphicsOutput;
-  EFI_BOOT_LOGO_PROTOCOL        *BootLogo;
-  UINTN                         NumberOfLogos;
-  EFI_GRAPHICS_OUTPUT_BLT_PIXEL *LogoBlt;
-  UINTN                         LogoDestX;
-  UINTN                         LogoDestY;
-  UINTN                         LogoHeight;
-  UINTN                         LogoWidth;
-  UINTN                         NewDestX;
-  UINTN                         NewDestY;
-  UINTN                         NewHeight;
-  UINTN                         NewWidth;
-  UINTN                         BufferSize;
+  EFI_STATUS                            Status;
+  EDKII_PLATFORM_LOGO_PROTOCOL          *PlatformLogo;
+  EDKII_PLATFORM_LOGO_DISPLAY_ATTRIBUTE Attribute;
+  INTN                                  OffsetX;
+  INTN                                  OffsetY;
+  UINT32                                SizeOfX;
+  UINT32                                SizeOfY;
+  INTN                                  DestX;
+  INTN                                  DestY;
+  UINT32                                Instance;
+  EFI_IMAGE_INPUT                       Image;
+  EFI_GRAPHICS_OUTPUT_BLT_PIXEL         *Blt;
+  EFI_UGA_DRAW_PROTOCOL                 *UgaDraw;
+  UINT32                                ColorDepth;
+  UINT32                                RefreshRate;
+  EFI_GRAPHICS_OUTPUT_PROTOCOL          *GraphicsOutput;
+  EFI_BOOT_LOGO_PROTOCOL                *BootLogo;
+  UINTN                                 NumberOfLogos;
+  EFI_GRAPHICS_OUTPUT_BLT_PIXEL         *LogoBlt;
+  UINTN                                 LogoDestX;
+  UINTN                                 LogoDestY;
+  UINTN                                 LogoHeight;
+  UINTN                                 LogoWidth;
+  UINTN                                 NewDestX;
+  UINTN                                 NewDestY;
+  UINTN                                 BufferSize;
+
+  Status  = gBS->LocateProtocol (&gEdkiiPlatformLogoProtocolGuid, NULL, (VOID **) &PlatformLogo);
+  if (EFI_ERROR (Status)) {
+    return EFI_UNSUPPORTED;
+  }
 
   UgaDraw = NULL;
   //
@@ -100,15 +90,6 @@ BootLogoEnableLogo (
     return EFI_UNSUPPORTED;
   }
 
-  Status  = gBS->LocateProtocol (&gEdkiiPlatformLogoProtocolGuid, NULL, (VOID **) &PlatformLogo);
-  if (EFI_ERROR (Status)) {
-    PlatformLogo = NULL;
-  }
-
-  if ((Logo == NULL) && (PlatformLogo == NULL)) {
-    return EFI_UNSUPPORTED;
-  }
-
   //
   // Try to open Boot Logo Protocol.
   //
@@ -142,59 +123,33 @@ BootLogoEnableLogo (
   LogoWidth = 0;
   NewDestX = 0;
   NewDestY = 0;
-  NewHeight = 0;
-  NewWidth = 0;
   Instance = 0;
   DestX = 0;
   DestY = 0;
   while (TRUE) {
-    ImageData = NULL;
-    ImageSize = 0;
-
-    if (PlatformLogo != NULL) {
-      //
-      // Get image from OEMBadging protocol.
-      //
-      Status = PlatformLogo->GetImage (
-                               PlatformLogo,
-                               &Instance,
-                               &ImageFormat,
-                               &ImageData,
-                               &ImageSize,
-                               &Attribute,
-                               &OffsetX,
-                               &OffsetY
-                               );
-      if (EFI_ERROR (Status)) {
-        break;
-      }
+    //
+    // Get image from PlatformLogo protocol.
+    //
+    Status = PlatformLogo->GetImage (
+                             PlatformLogo,
+                             &Instance,
+                             &Image,
+                             &Attribute,
+                             &OffsetX,
+                             &OffsetY
+                             );
+    if (EFI_ERROR (Status)) {
+      break;
+    }
 
-    } else {
-      //
-      // Get the specified image from FV.
-      //
-      Status = GetSectionFromAnyFv (Logo, EFI_SECTION_RAW, 0, (VOID **) &ImageData, &ImageSize);
-      if (EFI_ERROR (Status)) {
-        return EFI_UNSUPPORTED;
-      }
+    if (EFI_ERROR (Status)) {
+      continue;
     }
 
     if (Blt != NULL) {
       FreePool (Blt);
     }
-
-    Status = DecodeImage (ImageFormat, ImageData, ImageSize, &Blt, &BltSize, &Width, &Height);
-    FreePool (ImageData);
-    if (EFI_ERROR (Status)) {
-      if (Logo != NULL) {
-        //
-        // Directly return failure for single LOGO
-        //
-        return Status;
-      } else {
-        continue;
-      }
-    }
+    Blt = Image.Bitmap;
 
     //
     // Calculate the display position according to Attribute.
@@ -205,42 +160,43 @@ BootLogoEnableLogo (
       DestY = 0;
       break;
     case EdkiiPlatformLogoDisplayAttributeCenterTop:
-      DestX = (SizeOfX - Width) / 2;
+      DestX = (SizeOfX - Image.Width) / 2;
       DestY = 0;
       break;
     case EdkiiPlatformLogoDisplayAttributeRightTop:
-      DestX = SizeOfX - Width;
+      DestX = SizeOfX - Image.Width;
       DestY = 0;
       break;
 
     case EdkiiPlatformLogoDisplayAttributeCenterLeft:
       DestX = 0;
-      DestY = (SizeOfY - Height) / 2;
+      DestY = (SizeOfY - Image.Height) / 2;
       break;
     case EdkiiPlatformLogoDisplayAttributeCenter:
-      DestX = (SizeOfX - Width) / 2;
-      DestY = (SizeOfY - Height) / 2;
+      DestX = (SizeOfX - Image.Width) / 2;
+      DestY = (SizeOfY - Image.Height) / 2;
       break;
     case EdkiiPlatformLogoDisplayAttributeCenterRight:
-      DestX = SizeOfX - Width;
-      DestY = (SizeOfY - Height) / 2;
+      DestX = SizeOfX - Image.Width;
+      DestY = (SizeOfY - Image.Height) / 2;
       break;
 
     case EdkiiPlatformLogoDisplayAttributeLeftBottom:
       DestX = 0;
-      DestY = SizeOfY - Height;
+      DestY = SizeOfY - Image.Height;
       break;
     case EdkiiPlatformLogoDisplayAttributeCenterBottom:
-      DestX = (SizeOfX - Width) / 2;
-      DestY = SizeOfY - Height;
+      DestX = (SizeOfX - Image.Width) / 2;
+      DestY = SizeOfY - Image.Height;
       break;
     case EdkiiPlatformLogoDisplayAttributeRightBottom:
-      DestX = SizeOfX - Width;
-      DestY = SizeOfY - Height;
+      DestX = SizeOfX - Image.Width;
+      DestY = SizeOfY - Image.Height;
       break;
 
     default:
       ASSERT (FALSE);
+      continue;
       break;
     }
 
@@ -257,9 +213,9 @@ BootLogoEnableLogo (
                                    0,
                                    (UINTN) DestX,
                                    (UINTN) DestY,
-                                   Width,
-                                   Height,
-                                   Width * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL)
+                                   Image.Width,
+                                   Image.Height,
+                                   Image.Width * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL)
                                    );
       } else {
         ASSERT (UgaDraw != NULL);
@@ -271,9 +227,9 @@ BootLogoEnableLogo (
                             0,
                             (UINTN) DestX,
                             (UINTN) DestY,
-                            Width,
-                            Height,
-                            Width * sizeof (EFI_UGA_PIXEL)
+                            Image.Width,
+                            Image.Height,
+                            Image.Width * sizeof (EFI_UGA_PIXEL)
                             );
       }
 
@@ -283,34 +239,28 @@ BootLogoEnableLogo (
       if (!EFI_ERROR (Status)) {
         NumberOfLogos++;
 
-        if (LogoWidth == 0) {
+        if (NumberOfLogos == 1) {
           //
           // The first Logo.
           //
           LogoDestX = (UINTN) DestX;
           LogoDestY = (UINTN) DestY;
-          LogoWidth = Width;
-          LogoHeight = Height;
+          LogoWidth = Image.Width;
+          LogoHeight = Image.Height;
         } else {
           //
           // Merge new logo with old one.
           //
           NewDestX = MIN ((UINTN) DestX, LogoDestX);
           NewDestY = MIN ((UINTN) DestY, LogoDestY);
-          NewWidth = MAX ((UINTN) DestX + Width, LogoDestX + LogoWidth) - NewDestX;
-          NewHeight = MAX ((UINTN) DestY + Height, LogoDestY + LogoHeight) - NewDestY;
+          LogoWidth = MAX ((UINTN) DestX + Image.Width, LogoDestX + LogoWidth) - NewDestX;
+          LogoHeight = MAX ((UINTN) DestY + Image.Height, LogoDestY + LogoHeight) - NewDestY;
 
           LogoDestX = NewDestX;
           LogoDestY = NewDestY;
-          LogoWidth = NewWidth;
-          LogoHeight = NewHeight;
         }
       }
     }
-
-    if (PlatformLogo == NULL) {
-      break;
-    }
   }
 
   if (BootLogo == NULL || NumberOfLogos == 0) {
diff --git a/MdeModulePkg/Library/BootLogoLib/BootLogoLib.inf b/MdeModulePkg/Library/BootLogoLib/BootLogoLib.inf
index 8698f26..8fa0b46 100644
--- a/MdeModulePkg/Library/BootLogoLib/BootLogoLib.inf
+++ b/MdeModulePkg/Library/BootLogoLib/BootLogoLib.inf
@@ -2,7 +2,7 @@
 #  This library is only intended to be used by PlatformBootManagerLib
 #  to show progress bar and logo.
 #  
-#  Copyright (c) 2011 - 2015, Intel Corporation. All rights reserved.<BR>
+#  Copyright (c) 2011 - 2016, Intel Corporation. All rights reserved.<BR>
 #  This program and the accompanying materials are licensed and made available under
 #  the terms and conditions of the BSD License that accompanies this distribution.
 #  The full text of the license may be found at
@@ -44,10 +44,6 @@ [LibraryClasses]
   DebugLib
   PrintLib
   PcdLib
-  DxeServicesLib
-  ImageDecoderLib
-
-[Guids]
 
 [Protocols]
   gEfiGraphicsOutputProtocolGuid                ## SOMETIMES_CONSUMES
-- 
2.9.0.windows.1



^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 12/13] MdeModulePkg/Logo: Add LogoDxe module
  2016-09-23  8:25 [PATCH 00/13] Add HiiImageEx implementation and demonstrate in Nt32 Ruiyu Ni
                   ` (10 preceding siblings ...)
  2016-09-23  8:25 ` [PATCH 11/13] MdeModulePkg/BootLogoLib&PlatformLogo: Use HII data types in parameters Ruiyu Ni
@ 2016-09-23  8:25 ` Ruiyu Ni
  2016-09-23  8:25 ` [PATCH 13/13] Nt32Pkg: Use the new LogoDxe driver Ruiyu Ni
  2016-09-26  2:55 ` [PATCH 00/13] Add HiiImageEx implementation and demonstrate in Nt32 Gao, Liming
  13 siblings, 0 replies; 15+ messages in thread
From: Ruiyu Ni @ 2016-09-23  8:25 UTC (permalink / raw)
  To: edk2-devel; +Cc: Liming Gao, Eric Dong, Dandan Bi

LogoDxe embeds the image resource in the PE resource section, then
it produces Platform Logo protocol which can return the images
in pixel format.
HiiImageEx protocol is responsible to decode the JPEG/PNG images
to pixel format. LogoDxe driver uses HiiImageEx protocol.

Contributed-under: TianoCore Contribution Agreement 1.0
Cc: Liming Gao <liming.gao@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Dandan Bi <dandan.bi@intel.com>
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
---
 MdeModulePkg/Logo/Logo.c           | 156 +++++++++++++++++++++++++++++++++++++
 MdeModulePkg/Logo/Logo.idf         |  18 +++++
 MdeModulePkg/Logo/LogoDxe.inf      |  60 ++++++++++++++
 MdeModulePkg/Logo/LogoDxe.uni      |  21 +++++
 MdeModulePkg/Logo/LogoDxeExtra.uni |  19 +++++
 5 files changed, 274 insertions(+)
 create mode 100644 MdeModulePkg/Logo/Logo.c
 create mode 100644 MdeModulePkg/Logo/Logo.idf
 create mode 100644 MdeModulePkg/Logo/LogoDxe.inf
 create mode 100644 MdeModulePkg/Logo/LogoDxe.uni
 create mode 100644 MdeModulePkg/Logo/LogoDxeExtra.uni

diff --git a/MdeModulePkg/Logo/Logo.c b/MdeModulePkg/Logo/Logo.c
new file mode 100644
index 0000000..f0792ad
--- /dev/null
+++ b/MdeModulePkg/Logo/Logo.c
@@ -0,0 +1,156 @@
+/** @file
+  Logo DXE Driver, install Edkii Platform Logo protocol.
+
+Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>
+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
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+#include <Uefi.h>
+#include <Protocol/HiiDatabase.h>
+#include <Protocol/GraphicsOutput.h>
+#include <Protocol/HiiImageEx.h>
+#include <Protocol/PlatformLogo.h>
+#include <Protocol/HiiPackageList.h>
+#include <Library/UefiBootServicesTableLib.h>
+#include <Library/DebugLib.h>
+
+typedef struct {
+  EFI_IMAGE_ID                          ImageId;
+  EDKII_PLATFORM_LOGO_DISPLAY_ATTRIBUTE Attribute;
+  INTN                                  OffsetX;
+  INTN                                  OffsetY;
+} LOGO_ENTRY;
+
+EFI_HII_IMAGE_EX_PROTOCOL *mHiiImageEx;
+EFI_HII_HANDLE            mHiiHandle;
+LOGO_ENTRY                mLogos[] = {
+  {
+    IMAGE_TOKEN (IMG_LOGO),
+    EdkiiPlatformLogoDisplayAttributeCenter,
+    0,
+    0
+  }
+};
+
+/**
+  Load a platform logo image and return its data and attributes.
+
+  @param This              The pointer to this protocol instance.
+  @param Instance          The visible image instance is found.
+  @param Image             Points to the image.
+  @param Attribute         The display attributes of the image returned.
+  @param OffsetX           The X offset of the image regarding the Attribute.
+  @param OffsetY           The Y offset of the image regarding the Attribute.
+
+  @retval EFI_SUCCESS      The image was fetched successfully.
+  @retval EFI_NOT_FOUND    The specified image could not be found.
+**/
+EFI_STATUS
+EFIAPI
+GetImage (
+  IN     EDKII_PLATFORM_LOGO_PROTOCOL          *This,
+  IN OUT UINT32                                *Instance,
+     OUT EFI_IMAGE_INPUT                       *Image,
+     OUT EDKII_PLATFORM_LOGO_DISPLAY_ATTRIBUTE *Attribute,
+     OUT INTN                                  *OffsetX,
+     OUT INTN                                  *OffsetY
+  )
+{
+  UINT32 Current;
+  if (Instance == NULL || Image == NULL ||
+      Attribute == NULL || OffsetX == NULL || OffsetY == NULL) {
+    return EFI_INVALID_PARAMETER;
+  }
+
+  Current = *Instance;
+  if (Current >= sizeof (mLogos) / sizeof (mLogos[0])) {
+    return EFI_NOT_FOUND;
+  }
+
+  (*Instance)++;
+  *Attribute = mLogos[Current].Attribute;
+  *OffsetX   = mLogos[Current].OffsetX;
+  *OffsetY   = mLogos[Current].OffsetY;
+  return mHiiImageEx->GetImageEx (mHiiImageEx, mHiiHandle, mLogos[Current].ImageId, Image);
+}
+
+EDKII_PLATFORM_LOGO_PROTOCOL mPlatformLogo = {
+  GetImage
+};
+
+/**
+  Entrypoint of this module.
+
+  This function is the entrypoint of this module. It installs the Edkii
+  Platform Logo protocol.
+
+  @param  ImageHandle       The firmware allocated handle for the EFI image.
+  @param  SystemTable       A pointer to the EFI System Table.
+
+  @retval EFI_SUCCESS       The entry point is executed successfully.
+
+**/
+EFI_STATUS
+EFIAPI
+InitializeLogo (
+  IN EFI_HANDLE               ImageHandle,
+  IN EFI_SYSTEM_TABLE         *SystemTable
+  )
+{
+  EFI_STATUS                  Status;
+  EFI_HII_PACKAGE_LIST_HEADER *PackageList;
+  EFI_HII_DATABASE_PROTOCOL   *HiiDatabase;
+  EFI_HANDLE                  Handle;
+
+  Status = gBS->LocateProtocol (
+                  &gEfiHiiDatabaseProtocolGuid,
+                  NULL,
+                  (VOID **) &HiiDatabase
+                  );
+  ASSERT_EFI_ERROR (Status);
+
+  Status = gBS->LocateProtocol (
+                  &gEfiHiiImageExProtocolGuid,
+                  NULL,
+                  (VOID **) &mHiiImageEx
+                  );
+  ASSERT_EFI_ERROR (Status);
+
+  //
+  // Retrieve HII package list from ImageHandle
+  //
+  Status = gBS->OpenProtocol (
+                  ImageHandle,
+                  &gEfiHiiPackageListProtocolGuid,
+                  (VOID **) &PackageList,
+                  ImageHandle,
+                  NULL,
+                  EFI_OPEN_PROTOCOL_GET_PROTOCOL
+                  );
+  ASSERT_EFI_ERROR (Status);
+
+  //
+  // Publish HII package list to HII Database.
+  //
+  Status = HiiDatabase->NewPackageList (
+                          HiiDatabase,
+                          PackageList,
+                          NULL,
+                          &mHiiHandle
+                          );
+  if (!EFI_ERROR (Status)) {
+    Handle = NULL;
+    Status = gBS->InstallMultipleProtocolInterfaces (
+                    &Handle,
+                    &gEdkiiPlatformLogoProtocolGuid, &mPlatformLogo,
+                    NULL
+                    );
+  }
+  return Status;
+}
diff --git a/MdeModulePkg/Logo/Logo.idf b/MdeModulePkg/Logo/Logo.idf
new file mode 100644
index 0000000..f4c39b7
--- /dev/null
+++ b/MdeModulePkg/Logo/Logo.idf
@@ -0,0 +1,18 @@
+// /** @file
+// Platform Logo image definition file.
+//
+// Console Platfrom DXE Driver that specifies whether device can be used as console
+// input/output device or error output device and update global variables accordingly.
+//
+// Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>
+//
+// 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
+// http://opensource.org/licenses/bsd-license.php
+// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+//
+// **/
+
+#image IMG_LOGO Logo.bmp
diff --git a/MdeModulePkg/Logo/LogoDxe.inf b/MdeModulePkg/Logo/LogoDxe.inf
new file mode 100644
index 0000000..3ffc64b
--- /dev/null
+++ b/MdeModulePkg/Logo/LogoDxe.inf
@@ -0,0 +1,60 @@
+## @file
+#  The default logo bitmap picture shown on setup screen.
+#
+#  Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>
+#
+#  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
+#  http://opensource.org/licenses/bsd-license.php
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+#
+##
+
+[Defines]
+  INF_VERSION                    = 0x00010005
+  BASE_NAME                      = LogoDxe
+  MODULE_UNI_FILE                = LogoDxe.uni
+  FILE_GUID                      = F74D20EE-37E7-48FC-97F7-9B1047749C69
+  MODULE_TYPE                    = DXE_DRIVER
+  VERSION_STRING                 = 1.0
+
+  ENTRY_POINT                    = InitializeLogo
+#
+#  This flag specifies whether HII resource section is generated into PE image.
+#
+  UEFI_HII_RESOURCE_SECTION      = TRUE
+
+#
+# The following information is for reference only and not required by the build tools.
+#
+#  VALID_ARCHITECTURES           = IA32 X64
+#
+
+[Sources]
+  Logo.bmp
+  Logo.c
+  Logo.idf
+
+[Packages]
+  MdeModulePkg/MdeModulePkg.dec
+  MdePkg/MdePkg.dec
+
+[LibraryClasses]
+  UefiBootServicesTableLib
+  UefiDriverEntryPoint
+  DebugLib
+
+[Protocols]
+  gEfiHiiDatabaseProtocolGuid        ## CONSUMES
+  gEfiHiiImageExProtocolGuid         ## CONSUMES
+  gEfiHiiPackageListProtocolGuid     ## PRODUCES CONSUMES
+  gEdkiiPlatformLogoProtocolGuid     ## PRODUCES
+
+[Depex]
+  gEfiHiiDatabaseProtocolGuid
+
+[UserExtensions.TianoCore."ExtraFiles"]
+  LogoDxeExtra.uni
diff --git a/MdeModulePkg/Logo/LogoDxe.uni b/MdeModulePkg/Logo/LogoDxe.uni
new file mode 100644
index 0000000..698776d
--- /dev/null
+++ b/MdeModulePkg/Logo/LogoDxe.uni
@@ -0,0 +1,21 @@
+// /** @file
+// The default logo bitmap picture shown on setup screen.
+//
+// This module provides the default logo bitmap picture shown on setup screen, through EDKII Platform Logo protocol.
+//
+// Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>
+//
+// 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
+// http://opensource.org/licenses/bsd-license.php
+// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+//
+// **/
+
+
+#string STR_MODULE_ABSTRACT             #language en-US "Provides the default logo bitmap picture shown on setup screen."
+
+#string STR_MODULE_DESCRIPTION          #language en-US "This module provides the default logo bitmap picture shown on setup screen, through EDKII Platform Logo protocol."
+
diff --git a/MdeModulePkg/Logo/LogoDxeExtra.uni b/MdeModulePkg/Logo/LogoDxeExtra.uni
new file mode 100644
index 0000000..fe9e2ba
--- /dev/null
+++ b/MdeModulePkg/Logo/LogoDxeExtra.uni
@@ -0,0 +1,19 @@
+// /** @file
+// Logo Localized Strings and Content
+//
+// Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>
+//
+// 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
+// http://opensource.org/licenses/bsd-license.php
+// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+//
+// **/
+
+#string STR_PROPERTIES_MODULE_NAME 
+#language en-US 
+"Logo Image File"
+
+
-- 
2.9.0.windows.1



^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 13/13] Nt32Pkg: Use the new LogoDxe driver
  2016-09-23  8:25 [PATCH 00/13] Add HiiImageEx implementation and demonstrate in Nt32 Ruiyu Ni
                   ` (11 preceding siblings ...)
  2016-09-23  8:25 ` [PATCH 12/13] MdeModulePkg/Logo: Add LogoDxe module Ruiyu Ni
@ 2016-09-23  8:25 ` Ruiyu Ni
  2016-09-26  2:55 ` [PATCH 00/13] Add HiiImageEx implementation and demonstrate in Nt32 Gao, Liming
  13 siblings, 0 replies; 15+ messages in thread
From: Ruiyu Ni @ 2016-09-23  8:25 UTC (permalink / raw)
  To: edk2-devel; +Cc: Liming Gao, Eric Dong, Dandan Bi

Contributed-under: TianoCore Contribution Agreement 1.0
Cc: Liming Gao <liming.gao@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Dandan Bi <dandan.bi@intel.com>
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
---
 Nt32Pkg/Library/PlatformBootManagerLib/PlatformBootManager.c | 2 +-
 Nt32Pkg/Nt32Pkg.dsc                                          | 7 ++-----
 Nt32Pkg/Nt32Pkg.fdf                                          | 5 +----
 3 files changed, 4 insertions(+), 10 deletions(-)

diff --git a/Nt32Pkg/Library/PlatformBootManagerLib/PlatformBootManager.c b/Nt32Pkg/Library/PlatformBootManagerLib/PlatformBootManager.c
index 373442e..07068f9 100644
--- a/Nt32Pkg/Library/PlatformBootManagerLib/PlatformBootManager.c
+++ b/Nt32Pkg/Library/PlatformBootManagerLib/PlatformBootManager.c
@@ -42,7 +42,7 @@ PlatformBootManagerDiagnostics (
   // from the graphic lib
   //
   if (QuietBoot) {
-    // BootLogoEnableLogo (ImageFormatBmp, PcdGetPtr(PcdLogoFile), EdkiiPlatformLogoDisplayAttributeCenter, 0, 0);
+    BootLogoEnableLogo ();
 
     //
     // Perform system diagnostic
diff --git a/Nt32Pkg/Nt32Pkg.dsc b/Nt32Pkg/Nt32Pkg.dsc
index 408cc51..4458c02 100644
--- a/Nt32Pkg/Nt32Pkg.dsc
+++ b/Nt32Pkg/Nt32Pkg.dsc
@@ -119,7 +119,6 @@ [LibraryClasses]
   TimerLib|MdePkg/Library/BaseTimerLibNullTemplate/BaseTimerLibNullTemplate.inf
   SerialPortLib|MdePkg/Library/BaseSerialPortLibNull/BaseSerialPortLibNull.inf
   CapsuleLib|MdeModulePkg/Library/DxeCapsuleLibNull/DxeCapsuleLibNull.inf
-  ImageDecoderLib|MdeModulePkg/Library/ImageDecoderLib/ImageDecoderLib.inf
   BootLogoLib|MdeModulePkg/Library/BootLogoLib/BootLogoLib.inf
   #
   # Platform
@@ -447,10 +446,7 @@ [Components]
   NetworkPkg/HttpDxe/HttpDxe.inf
   NetworkPkg/HttpUtilitiesDxe/HttpUtilitiesDxe.inf
 
-  MdeModulePkg/Universal/BdsDxe/BdsDxe.inf {
-    <LibraryClasses>
-      NULL|MdeModulePkg/Library/BmpImageDecoderLib/BmpImageDecoderLib.inf
-  }
+  MdeModulePkg/Universal/BdsDxe/BdsDxe.inf
   MdeModulePkg/Application/UiApp/UiApp.inf{
     <LibraryClasses>
       NULL|MdeModulePkg/Library/DeviceManagerUiLib/DeviceManagerUiLib.inf
@@ -474,6 +470,7 @@ [Components]
     <LibraryClasses>
       NULL|IntelFrameworkModulePkg/Library/LegacyBootManagerLib/LegacyBootManagerLib.inf
   }
+  MdeModulePkg/Logo/LogoDxe.inf
 
 ###################################################################################################
 #
diff --git a/Nt32Pkg/Nt32Pkg.fdf b/Nt32Pkg/Nt32Pkg.fdf
index bd9eeca..cf00a13 100644
--- a/Nt32Pkg/Nt32Pkg.fdf
+++ b/Nt32Pkg/Nt32Pkg.fdf
@@ -279,10 +279,7 @@ [FV.FvRecovery]
 
 INF FatPkg/EnhancedFatDxe/Fat.inf
 
-FILE FREEFORM = PCD(gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdLogoFile) {
-    SECTION RAW = MdeModulePkg/Logo/Logo.bmp
-  }
-
+INF MdeModulePkg/Logo/LogoDxe.inf
 INF MdeModulePkg/Universal/LoadFileOnFv2/LoadFileOnFv2.inf
 ################################################################################
 #
-- 
2.9.0.windows.1



^ permalink raw reply related	[flat|nested] 15+ messages in thread

* Re: [PATCH 00/13] Add HiiImageEx implementation and demonstrate in Nt32
  2016-09-23  8:25 [PATCH 00/13] Add HiiImageEx implementation and demonstrate in Nt32 Ruiyu Ni
                   ` (12 preceding siblings ...)
  2016-09-23  8:25 ` [PATCH 13/13] Nt32Pkg: Use the new LogoDxe driver Ruiyu Ni
@ 2016-09-26  2:55 ` Gao, Liming
  13 siblings, 0 replies; 15+ messages in thread
From: Gao, Liming @ 2016-09-26  2:55 UTC (permalink / raw)
  To: Ni, Ruiyu, edk2-devel@lists.01.org

Ray:
  I have some comments. 
1) This is the incompatible change in BootLogoLib. It also impacts OvmfPkg and ArmVirtPkg. Please highlight this change in cover letter, and update OvmfPkg and ArmVirtPkg both.
2) HiiDrawImageIdEx() directly calls HiiDrawImageId(). But, HiiDrawImageId() doesn't support JPEG and PNG. This is a functional issue in HiiDrawImageIdEx(). 
3) IGetImage() will call Decoder protocol to get the output ImageOut. Per UEFI spec, ImageOut is allocated by Decoder protocol, and free by the caller. Please free it in IGetImage()

Thanks
Liming
> -----Original Message-----
> From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of
> Ruiyu Ni
> Sent: Friday, September 23, 2016 4:25 PM
> To: edk2-devel@lists.01.org
> Subject: [edk2] [PATCH 00/13] Add HiiImageEx implementation and
> demonstrate in Nt32
> 
> The total 13 commits can be reviewed in following url:
> https://github.com/niruiyu/edk2/commits/HiiImage
> 
> Ruiyu Ni (13):
>   MdeModulePkg/HiiDatabase: Refine GetImageIdOrAddress
>   MdeModulePkg/HiiDatabase: Move common code to LocatePackageList()
>   MdeModulePkg/HiiDatabase: Refine HiiNewImage()
>   MdeModulePkg/HiiDatabase: Refine HiiGetImage()
>   MdeModulePkg/HiiDatabase: Refine HiiSetImage()
>   MdeModulePkg/HiiDatabase: Refine HiiDrawImage()
>   MdemodulePkg/HiiDatabase: Correct typo in comments.
>   MdeModulePkg/HiiDatabase: Update HiiImage to support PNG/JPEG
>   MdeModulePkg/HiiDatabase: Add HiiImageEx implementation.
>   Nt32Pkg/PlatformBds: Do not call BootLogoEnableLogo
>   MdeModulePkg/BootLogoLib&PlatformLogo: Use HII data types in
>     parameters
>   MdeModulePkg/Logo: Add LogoDxe module
>   Nt32Pkg: Use the new LogoDxe driver
> 
>  MdeModulePkg/Include/Library/BootLogoLib.h         |  19 +-
>  MdeModulePkg/Include/Protocol/PlatformLogo.h       |  18 +-
>  MdeModulePkg/Library/BootLogoLib/BootLogoLib.c     | 204 +++----
>  MdeModulePkg/Library/BootLogoLib/BootLogoLib.inf   |   6 +-
>  MdeModulePkg/Logo/Logo.c                           | 156 ++++++
>  MdeModulePkg/Logo/Logo.idf                         |  18 +
>  MdeModulePkg/Logo/LogoDxe.inf                      |  60 ++
>  MdeModulePkg/Logo/LogoDxe.uni                      |  21 +
>  MdeModulePkg/Logo/LogoDxeExtra.uni                 |  19 +
>  .../HiiDatabaseDxe/ConfigKeywordHandler.c          |  36 +-
>  .../Universal/HiiDatabaseDxe/ConfigRouting.c       |  58 +-
>  MdeModulePkg/Universal/HiiDatabaseDxe/Database.c   |  16 +-
>  MdeModulePkg/Universal/HiiDatabaseDxe/Font.c       |  32 +-
>  .../Universal/HiiDatabaseDxe/HiiDatabase.h         | 292 +++++++++-
>  .../Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf    |   7 +-
>  .../Universal/HiiDatabaseDxe/HiiDatabaseEntry.c    |  34 +-
>  MdeModulePkg/Universal/HiiDatabaseDxe/Image.c      | 619 ++++++++++---
> --------
>  MdeModulePkg/Universal/HiiDatabaseDxe/ImageEx.c    | 397
> +++++++++++++
>  .../PlatformBootManagerLib/PlatformBootManager.c   |   4 +-
>  Nt32Pkg/Nt32Pkg.dsc                                |   7 +-
>  Nt32Pkg/Nt32Pkg.fdf                                |   5 +-
>  21 files changed, 1432 insertions(+), 596 deletions(-)
>  create mode 100644 MdeModulePkg/Logo/Logo.c
>  create mode 100644 MdeModulePkg/Logo/Logo.idf
>  create mode 100644 MdeModulePkg/Logo/LogoDxe.inf
>  create mode 100644 MdeModulePkg/Logo/LogoDxe.uni
>  create mode 100644 MdeModulePkg/Logo/LogoDxeExtra.uni
>  create mode 100644 MdeModulePkg/Universal/HiiDatabaseDxe/ImageEx.c
> 
> --
> 2.9.0.windows.1
> 
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel


^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2016-09-26  2:55 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-09-23  8:25 [PATCH 00/13] Add HiiImageEx implementation and demonstrate in Nt32 Ruiyu Ni
2016-09-23  8:25 ` [PATCH 01/13] MdeModulePkg/HiiDatabase: Refine GetImageIdOrAddress Ruiyu Ni
2016-09-23  8:25 ` [PATCH 02/13] MdeModulePkg/HiiDatabase: Move common code to LocatePackageList() Ruiyu Ni
2016-09-23  8:25 ` [PATCH 03/13] MdeModulePkg/HiiDatabase: Refine HiiNewImage() Ruiyu Ni
2016-09-23  8:25 ` [PATCH 04/13] MdeModulePkg/HiiDatabase: Refine HiiGetImage() Ruiyu Ni
2016-09-23  8:25 ` [PATCH 05/13] MdeModulePkg/HiiDatabase: Refine HiiSetImage() Ruiyu Ni
2016-09-23  8:25 ` [PATCH 06/13] MdeModulePkg/HiiDatabase: Refine HiiDrawImage() Ruiyu Ni
2016-09-23  8:25 ` [PATCH 07/13] MdemodulePkg/HiiDatabase: Correct typo in comments Ruiyu Ni
2016-09-23  8:25 ` [PATCH 08/13] MdeModulePkg/HiiDatabase: Update HiiImage to support PNG/JPEG Ruiyu Ni
2016-09-23  8:25 ` [PATCH 09/13] MdeModulePkg/HiiDatabase: Add HiiImageEx implementation Ruiyu Ni
2016-09-23  8:25 ` [PATCH 10/13] Nt32Pkg/PlatformBds: Do not call BootLogoEnableLogo Ruiyu Ni
2016-09-23  8:25 ` [PATCH 11/13] MdeModulePkg/BootLogoLib&PlatformLogo: Use HII data types in parameters Ruiyu Ni
2016-09-23  8:25 ` [PATCH 12/13] MdeModulePkg/Logo: Add LogoDxe module Ruiyu Ni
2016-09-23  8:25 ` [PATCH 13/13] Nt32Pkg: Use the new LogoDxe driver Ruiyu Ni
2016-09-26  2:55 ` [PATCH 00/13] Add HiiImageEx implementation and demonstrate in Nt32 Gao, Liming

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox