public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: Ruiyu Ni <ruiyu.ni@intel.com>
To: edk2-devel@lists.01.org
Cc: Liming Gao <liming.gao@intel.com>,
	Eric Dong <eric.dong@intel.com>, Dandan Bi <dandan.bi@intel.com>
Subject: [PATCH v2 02/19] MdeModulePkg/HiiDatabase: Move common code to LocatePackageList()
Date: Mon, 26 Sep 2016 17:30:18 +0800	[thread overview]
Message-ID: <20160926093035.350612-3-ruiyu.ni@intel.com> (raw)
In-Reply-To: <20160926093035.350612-1-ruiyu.ni@intel.com>

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 0a908ec..6ff397d 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



  parent reply	other threads:[~2016-09-26  9:30 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-26  9:30 [PATCH v2 00/19] Add HiiImageEx implementations Ruiyu Ni
2016-09-26  9:30 ` [PATCH v2 01/19] MdeModulePkg/HiiDatabase: Refine GetImageIdOrAddress Ruiyu Ni
2016-09-26  9:30 ` Ruiyu Ni [this message]
2016-09-26  9:30 ` [PATCH v2 03/19] MdeModulePkg/HiiDatabase: Refine HiiNewImage() Ruiyu Ni
2016-09-26  9:30 ` [PATCH v2 04/19] MdeModulePkg/HiiDatabase: Refine HiiGetImage() Ruiyu Ni
2016-09-26  9:30 ` [PATCH v2 05/19] MdeModulePkg/HiiDatabase: Refine HiiSetImage() Ruiyu Ni
2016-09-26  9:30 ` [PATCH v2 06/19] MdeModulePkg/HiiDatabase: Refine HiiDrawImage() Ruiyu Ni
2016-09-26  9:30 ` [PATCH v2 07/19] MdemodulePkg/HiiDatabase: Correct typo in comments Ruiyu Ni
2016-09-26  9:30 ` [PATCH v2 08/19] MdePkg/HiiImage.h: Include GraphicsOutput.h Ruiyu Ni
2016-09-26  9:30 ` [PATCH v2 09/19] MdeModulePkg/HiiDatabase: Update HiiImage to support PNG/JPEG Ruiyu Ni
2016-09-26  9:30 ` [PATCH v2 10/19] MdePkg/HiiImageDecoder.h: Add HiiImageDecoder protocol header file Ruiyu Ni
2016-09-26  9:30 ` [PATCH v2 11/19] MdeModulePkg/HiiDatabase: Add HiiImageEx implementation Ruiyu Ni
2016-09-26  9:30 ` [PATCH v2 12/19] Nt32Pkg/PlatformBds: Do not call BootLogoEnableLogo Ruiyu Ni
2016-09-26  9:30 ` [PATCH v2 13/19] ArmVirtPkg/PlatformBds: " Ruiyu Ni
2016-09-26 10:06   ` Laszlo Ersek
2016-09-26 12:56     ` Ard Biesheuvel
2016-09-26  9:30 ` [PATCH v2 14/19] OvmfPkg/PlatformBds: " Ruiyu Ni
2016-09-26 10:06   ` Laszlo Ersek
2016-09-26  9:30 ` [PATCH v2 15/19] MdeModulePkg/BootLogoLib&PlatformLogo: Use HII data types in parameters Ruiyu Ni
2016-09-26  9:30 ` [PATCH v2 16/19] MdeModulePkg/Logo: Add LogoDxe module Ruiyu Ni
2016-09-26  9:30 ` [PATCH v2 17/19] Nt32Pkg: Use the new LogoDxe driver Ruiyu Ni
2016-09-26  9:30 ` [PATCH v2 18/19] ArmVirtPkg: " Ruiyu Ni
2016-09-26 10:06   ` Laszlo Ersek
2016-09-26 12:56     ` Ard Biesheuvel
2016-09-26  9:30 ` [PATCH v2 19/19] OvmfPkg: " Ruiyu Ni
2016-09-26 10:06   ` Laszlo Ersek
2016-09-28  8:12 ` [PATCH v2 00/19] Add HiiImageEx implementations Gao, Liming

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160926093035.350612-3-ruiyu.ni@intel.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox