public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH v1 1/7] MdePkg/BaseLib: Add linked list iteration macros
       [not found] <20200409200514.32796-1-michael.kubacki@outlook.com>
@ 2020-04-09 20:05 ` Michael Kubacki
  2020-04-10  1:45   ` [edk2-devel] " Guomin Jiang
  2020-04-09 20:05 ` [PATCH v1 2/7] MdeModulePkg/EhciDxe: Use BaseLib " Michael Kubacki
                   ` (5 subsequent siblings)
  6 siblings, 1 reply; 12+ messages in thread
From: Michael Kubacki @ 2020-04-09 20:05 UTC (permalink / raw)
  To: devel
  Cc: Dandan Bi, Hao A Wu, Jian J Wang, Liming Gao, Michael D Kinney,
	Sean Brogan

From: Michael Kubacki <michael.kubacki@microsoft.com>

REF:https://bugzilla.tianocore.org/show_bug.cgi?id=1959

The macros EFI_LIST_FOR_EACH and EFI_LIST_FOR_EACH_SAFE have been
duplicated across several drivers. These macros have proven useful and
established a commonly used pattern for linked list iteration.

This change defines the macros in BaseLib.h alongside other generic linked
list macros and functions.

Cc: Dandan Bi <dandan.bi@intel.com>
Cc: Hao A Wu <hao.a.wu@intel.com>
Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Sean Brogan <sean.brogan@microsoft.com>
Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
---
 MdePkg/Include/Library/BaseLib.h | 27 ++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/MdePkg/Include/Library/BaseLib.h b/MdePkg/Include/Library/BaseLib.h
index ecadff8b235e..d066f1be2495 100644
--- a/MdePkg/Include/Library/BaseLib.h
+++ b/MdePkg/Include/Library/BaseLib.h
@@ -4,6 +4,7 @@
 
 Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.<BR>
 Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
+Copyright (c) Microsoft Corporation.<BR>
 SPDX-License-Identifier: BSD-2-Clause-Patent
 
 **/
@@ -2972,6 +2973,32 @@ PathCleanUpDirectories(
 **/
 #define INITIALIZE_LIST_HEAD_VARIABLE(ListHead)  {&(ListHead), &(ListHead)}
 
+/**
+  Iterates over each node in a doubly linked list using each node's forward link.
+
+  @param  Entry     A pointer to a list node used as a loop cursor during iteration
+  @param  ListHead  The head node of the doubly linked list
+
+**/
+#define BASE_LIST_FOR_EACH(Entry, ListHead)    \
+  for(Entry = (ListHead)->ForwardLink; Entry != (ListHead); Entry = Entry->ForwardLink)
+
+/**
+  Iterates over each node in a doubly linked list using each node's forward link
+  with safety against node removal.
+
+  This macro uses NextEntry to temporarily store the next list node so the node
+  pointed to by Entry may be deleted in the current loop iteration step and
+  iteration can continue from the node pointed to by NextEntry.
+
+  @param  Entry     A pointer to a list node used as a loop cursor during iteration
+  @param  NextEntry A pointer to a list node used to temporarily store the next node
+  @param  ListHead  The head node of the doubly linked list
+
+**/
+#define BASE_LIST_FOR_EACH_SAFE(Entry, NextEntry, ListHead)            \
+  for(Entry = (ListHead)->ForwardLink, NextEntry = Entry->ForwardLink;\
+      Entry != (ListHead); Entry = NextEntry, NextEntry = Entry->ForwardLink)
 
 /**
   Checks whether FirstEntry and SecondEntry are part of the same doubly-linked
-- 
2.16.3.windows.1


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

* [PATCH v1 2/7] MdeModulePkg/EhciDxe: Use BaseLib linked list iteration macros
       [not found] <20200409200514.32796-1-michael.kubacki@outlook.com>
  2020-04-09 20:05 ` [PATCH v1 1/7] MdePkg/BaseLib: Add linked list iteration macros Michael Kubacki
@ 2020-04-09 20:05 ` Michael Kubacki
  2020-04-10  1:46   ` [edk2-devel] " Guomin Jiang
  2020-04-09 20:05 ` [PATCH v1 3/7] MdeModulePkg/EhciPei: " Michael Kubacki
                   ` (4 subsequent siblings)
  6 siblings, 1 reply; 12+ messages in thread
From: Michael Kubacki @ 2020-04-09 20:05 UTC (permalink / raw)
  To: devel; +Cc: Dandan Bi, Hao A Wu, Jian J Wang, Liming Gao, Ray Ni, Sean Brogan

From: Michael Kubacki <michael.kubacki@microsoft.com>

REF:https://bugzilla.tianocore.org/show_bug.cgi?id=1959

Replaces usage of the linked list iteration macros defined in Ehci.h
with the common definition in BaseLib.h.

Cc: Dandan Bi <dandan.bi@intel.com>
Cc: Hao A Wu <hao.a.wu@intel.com>
Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Sean Brogan <sean.brogan@microsoft.com>
Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
---
 MdeModulePkg/Bus/Pci/EhciDxe/EhciDebug.c |  3 ++-
 MdeModulePkg/Bus/Pci/EhciDxe/EhciSched.c | 11 ++++++-----
 MdeModulePkg/Bus/Pci/EhciDxe/EhciUrb.c   |  5 +++--
 MdeModulePkg/Bus/Pci/EhciDxe/Ehci.h      | 15 +--------------
 4 files changed, 12 insertions(+), 22 deletions(-)

diff --git a/MdeModulePkg/Bus/Pci/EhciDxe/EhciDebug.c b/MdeModulePkg/Bus/Pci/EhciDxe/EhciDebug.c
index e10f6bb357ab..db0e2c6d39c6 100644
--- a/MdeModulePkg/Bus/Pci/EhciDxe/EhciDebug.c
+++ b/MdeModulePkg/Bus/Pci/EhciDxe/EhciDebug.c
@@ -3,6 +3,7 @@
   This file provides the information dump support for EHCI when in debug mode.
 
 Copyright (c) 2007 - 2013, Intel Corporation. All rights reserved.<BR>
+Copyright (c) Microsoft Corporation.<BR>
 SPDX-License-Identifier: BSD-2-Clause-Patent
 
 **/
@@ -185,7 +186,7 @@ EhcDumpQh (
 
   DEBUG ((EFI_D_VERBOSE, "\n"));
 
-  EFI_LIST_FOR_EACH (Entry, &Qh->Qtds) {
+  BASE_LIST_FOR_EACH (Entry, &Qh->Qtds) {
     Qtd = EFI_LIST_CONTAINER (Entry, EHC_QTD, QtdList);
     EhcDumpQtd (Qtd, NULL);
 
diff --git a/MdeModulePkg/Bus/Pci/EhciDxe/EhciSched.c b/MdeModulePkg/Bus/Pci/EhciDxe/EhciSched.c
index 7db637aa2cb9..5fe7cf466939 100644
--- a/MdeModulePkg/Bus/Pci/EhciDxe/EhciSched.c
+++ b/MdeModulePkg/Bus/Pci/EhciDxe/EhciSched.c
@@ -3,6 +3,7 @@
   EHCI transfer scheduling routines.
 
 Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>
+Copyright (c) Microsoft Corporation.<BR>
 SPDX-License-Identifier: BSD-2-Clause-Patent
 
 **/
@@ -577,7 +578,7 @@ EhcCheckUrbResult (
     goto ON_EXIT;
   }
 
-  EFI_LIST_FOR_EACH (Entry, &Urb->Qh->Qtds) {
+  BASE_LIST_FOR_EACH (Entry, &Urb->Qh->Qtds) {
     Qtd   = EFI_LIST_CONTAINER (Entry, EHC_QTD, QtdList);
     QtdHw = &Qtd->QtdHw;
     State = (UINT8) QtdHw->Status;
@@ -757,7 +758,7 @@ EhciDelAsyncIntTransfer (
   Direction = (((EpNum & 0x80) != 0) ? EfiUsbDataIn : EfiUsbDataOut);
   EpNum    &= 0x0F;
 
-  EFI_LIST_FOR_EACH_SAFE (Entry, Next, &Ehc->AsyncIntTransfers) {
+  BASE_LIST_FOR_EACH_SAFE (Entry, Next, &Ehc->AsyncIntTransfers) {
     Urb = EFI_LIST_CONTAINER (Entry, URB, UrbList);
 
     if ((Urb->Ep.DevAddr == DevAddr) && (Urb->Ep.EpAddr == EpNum) &&
@@ -797,7 +798,7 @@ EhciDelAllAsyncIntTransfers (
   LIST_ENTRY              *Next;
   URB                     *Urb;
 
-  EFI_LIST_FOR_EACH_SAFE (Entry, Next, &Ehc->AsyncIntTransfers) {
+  BASE_LIST_FOR_EACH_SAFE (Entry, Next, &Ehc->AsyncIntTransfers) {
     Urb = EFI_LIST_CONTAINER (Entry, URB, UrbList);
 
     EhcUnlinkQhFromPeriod (Ehc, Urb->Qh);
@@ -965,7 +966,7 @@ EhcUpdateAsyncRequest (
   if (Urb->Result == EFI_USB_NOERROR) {
     FirstQtd = NULL;
 
-    EFI_LIST_FOR_EACH (Entry, &Urb->Qh->Qtds) {
+    BASE_LIST_FOR_EACH (Entry, &Urb->Qh->Qtds) {
       Qtd = EFI_LIST_CONTAINER (Entry, EHC_QTD, QtdList);
 
       if (FirstQtd == NULL) {
@@ -1049,7 +1050,7 @@ EhcMonitorAsyncRequests (
   OldTpl  = gBS->RaiseTPL (EHC_TPL);
   Ehc     = (USB2_HC_DEV *) Context;
 
-  EFI_LIST_FOR_EACH_SAFE (Entry, Next, &Ehc->AsyncIntTransfers) {
+  BASE_LIST_FOR_EACH_SAFE (Entry, Next, &Ehc->AsyncIntTransfers) {
     Urb = EFI_LIST_CONTAINER (Entry, URB, UrbList);
 
     //
diff --git a/MdeModulePkg/Bus/Pci/EhciDxe/EhciUrb.c b/MdeModulePkg/Bus/Pci/EhciDxe/EhciUrb.c
index ac5ddd259a83..37cef6d130f7 100644
--- a/MdeModulePkg/Bus/Pci/EhciDxe/EhciUrb.c
+++ b/MdeModulePkg/Bus/Pci/EhciDxe/EhciUrb.c
@@ -4,6 +4,7 @@
     URB (Usb Request Block).
 
 Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>
+Copyright (c) Microsoft Corporation.<BR>
 SPDX-License-Identifier: BSD-2-Clause-Patent
 
 **/
@@ -299,7 +300,7 @@ EhcFreeQtds (
   LIST_ENTRY              *Next;
   EHC_QTD                 *Qtd;
 
-  EFI_LIST_FOR_EACH_SAFE (Entry, Next, Qtds) {
+  BASE_LIST_FOR_EACH_SAFE (Entry, Next, Qtds) {
     Qtd = EFI_LIST_CONTAINER (Entry, EHC_QTD, QtdList);
 
     RemoveEntryList (&Qtd->QtdList);
@@ -482,7 +483,7 @@ EhcCreateQtds (
   //
   // OK, all the QTDs needed are created. Now, fix the NextQtd point
   //
-  EFI_LIST_FOR_EACH (Entry, &Qh->Qtds) {
+  BASE_LIST_FOR_EACH (Entry, &Qh->Qtds) {
     Qtd = EFI_LIST_CONTAINER (Entry, EHC_QTD, QtdList);
 
     //
diff --git a/MdeModulePkg/Bus/Pci/EhciDxe/Ehci.h b/MdeModulePkg/Bus/Pci/EhciDxe/Ehci.h
index 31fb171497a8..65933d94396e 100644
--- a/MdeModulePkg/Bus/Pci/EhciDxe/Ehci.h
+++ b/MdeModulePkg/Bus/Pci/EhciDxe/Ehci.h
@@ -3,6 +3,7 @@
   Provides some data struct used by EHCI controller driver.
 
 Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
+Copyright (c) Microsoft Corporation.<BR>
 SPDX-License-Identifier: BSD-2-Clause-Patent
 
 **/
@@ -80,20 +81,6 @@ typedef struct _USB2_HC_DEV  USB2_HC_DEV;
 //
 #define  EHC_TPL                     TPL_NOTIFY
 
-//
-//Iterate through the double linked list. NOT delete safe
-//
-#define EFI_LIST_FOR_EACH(Entry, ListHead)    \
-  for(Entry = (ListHead)->ForwardLink; Entry != (ListHead); Entry = Entry->ForwardLink)
-
-//
-//Iterate through the double linked list. This is delete-safe.
-//Don't touch NextEntry
-//
-#define EFI_LIST_FOR_EACH_SAFE(Entry, NextEntry, ListHead)            \
-  for(Entry = (ListHead)->ForwardLink, NextEntry = Entry->ForwardLink;\
-      Entry != (ListHead); Entry = NextEntry, NextEntry = Entry->ForwardLink)
-
 #define EFI_LIST_CONTAINER(Entry, Type, Field) BASE_CR(Entry, Type, Field)
 
 
-- 
2.16.3.windows.1


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

* [PATCH v1 3/7] MdeModulePkg/EhciPei: Use BaseLib linked list iteration macros
       [not found] <20200409200514.32796-1-michael.kubacki@outlook.com>
  2020-04-09 20:05 ` [PATCH v1 1/7] MdePkg/BaseLib: Add linked list iteration macros Michael Kubacki
  2020-04-09 20:05 ` [PATCH v1 2/7] MdeModulePkg/EhciDxe: Use BaseLib " Michael Kubacki
@ 2020-04-09 20:05 ` Michael Kubacki
  2020-04-10  1:47   ` [edk2-devel] " Guomin Jiang
  2020-04-09 20:05 ` [PATCH v1 4/7] MdeModulePkg/XhciDxe: " Michael Kubacki
                   ` (3 subsequent siblings)
  6 siblings, 1 reply; 12+ messages in thread
From: Michael Kubacki @ 2020-04-09 20:05 UTC (permalink / raw)
  To: devel; +Cc: Dandan Bi, Hao A Wu, Jian J Wang, Liming Gao, Ray Ni, Sean Brogan

From: Michael Kubacki <michael.kubacki@microsoft.com>

REF:https://bugzilla.tianocore.org/show_bug.cgi?id=1959

Replaces usage of the linked list iteration macros defined in EhcPeim.h
with the common definition in BaseLib.h.

Cc: Dandan Bi <dandan.bi@intel.com>
Cc: Hao A Wu <hao.a.wu@intel.com>
Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Sean Brogan <sean.brogan@microsoft.com>
Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
---
 MdeModulePkg/Bus/Pci/EhciPei/EhciSched.c |  3 ++-
 MdeModulePkg/Bus/Pci/EhciPei/EhciUrb.c   |  5 +++--
 MdeModulePkg/Bus/Pci/EhciPei/EhcPeim.h   | 15 +--------------
 3 files changed, 6 insertions(+), 17 deletions(-)

diff --git a/MdeModulePkg/Bus/Pci/EhciPei/EhciSched.c b/MdeModulePkg/Bus/Pci/EhciPei/EhciSched.c
index 8eb432dfc31d..311f50198062 100644
--- a/MdeModulePkg/Bus/Pci/EhciPei/EhciSched.c
+++ b/MdeModulePkg/Bus/Pci/EhciPei/EhciSched.c
@@ -3,6 +3,7 @@ PEIM to produce gPeiUsb2HostControllerPpiGuid based on gPeiUsbControllerPpiGuid
 which is used to enable recovery function from USB Drivers.
 
 Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved.<BR>
+Copyright (c) Microsoft Corporation.<BR>
 
 SPDX-License-Identifier: BSD-2-Clause-Patent
 
@@ -323,7 +324,7 @@ EhcCheckUrbResult (
     goto ON_EXIT;
   }
 
-  EFI_LIST_FOR_EACH (Entry, &Urb->Qh->Qtds) {
+  BASE_LIST_FOR_EACH (Entry, &Urb->Qh->Qtds) {
     Qtd   = EFI_LIST_CONTAINER (Entry, PEI_EHC_QTD, QtdList);
     QtdHw = &Qtd->QtdHw;
     State = (UINT8) QtdHw->Status;
diff --git a/MdeModulePkg/Bus/Pci/EhciPei/EhciUrb.c b/MdeModulePkg/Bus/Pci/EhciPei/EhciUrb.c
index 995ccd2463d2..df512ed6fa59 100644
--- a/MdeModulePkg/Bus/Pci/EhciPei/EhciUrb.c
+++ b/MdeModulePkg/Bus/Pci/EhciPei/EhciUrb.c
@@ -3,6 +3,7 @@ PEIM to produce gPeiUsb2HostControllerPpiGuid based on gPeiUsbControllerPpiGuid
 which is used to enable recovery function from USB Drivers.
 
 Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved.<BR>
+Copyright (c) Microsoft Corporation.<BR>
 
 SPDX-License-Identifier: BSD-2-Clause-Patent
 
@@ -290,7 +291,7 @@ EhcFreeQtds (
   EFI_LIST_ENTRY          *Next;
   PEI_EHC_QTD             *Qtd;
 
-  EFI_LIST_FOR_EACH_SAFE (Entry, Next, Qtds) {
+  BASE_LIST_FOR_EACH_SAFE (Entry, Next, Qtds) {
     Qtd = EFI_LIST_CONTAINER (Entry, PEI_EHC_QTD, QtdList);
 
     RemoveEntryList (&Qtd->QtdList);
@@ -461,7 +462,7 @@ EhcCreateQtds (
   //
   // OK, all the QTDs needed are created. Now, fix the NextQtd point
   //
-  EFI_LIST_FOR_EACH (Entry, &Qh->Qtds) {
+  BASE_LIST_FOR_EACH (Entry, &Qh->Qtds) {
     Qtd = EFI_LIST_CONTAINER (Entry, PEI_EHC_QTD, QtdList);
 
     //
diff --git a/MdeModulePkg/Bus/Pci/EhciPei/EhcPeim.h b/MdeModulePkg/Bus/Pci/EhciPei/EhcPeim.h
index 6b69f7a656ce..962cbc458986 100644
--- a/MdeModulePkg/Bus/Pci/EhciPei/EhcPeim.h
+++ b/MdeModulePkg/Bus/Pci/EhciPei/EhcPeim.h
@@ -2,6 +2,7 @@
 Private Header file for Usb Host Controller PEIM
 
 Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved.<BR>
+Copyright (c) Microsoft Corporation.<BR>
 
 SPDX-License-Identifier: BSD-2-Clause-Patent
 
@@ -60,20 +61,6 @@ typedef struct _PEI_USB2_HC_DEV PEI_USB2_HC_DEV;
 //
 #define EHC_SYNC_POLL_INTERVAL       (6 * EHC_1_MILLISECOND)
 
-//
-//Iterate through the double linked list. NOT delete safe
-//
-#define EFI_LIST_FOR_EACH(Entry, ListHead)    \
-  for(Entry = (ListHead)->ForwardLink; Entry != (ListHead); Entry = Entry->ForwardLink)
-
-//
-//Iterate through the double linked list. This is delete-safe.
-//Don't touch NextEntry
-//
-#define EFI_LIST_FOR_EACH_SAFE(Entry, NextEntry, ListHead)            \
-  for(Entry = (ListHead)->ForwardLink, NextEntry = Entry->ForwardLink;\
-      Entry != (ListHead); Entry = NextEntry, NextEntry = Entry->ForwardLink)
-
 #define EFI_LIST_CONTAINER(Entry, Type, Field) BASE_CR(Entry, Type, Field)
 
 
-- 
2.16.3.windows.1


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

* [PATCH v1 4/7] MdeModulePkg/XhciDxe: Use BaseLib linked list iteration macros
       [not found] <20200409200514.32796-1-michael.kubacki@outlook.com>
                   ` (2 preceding siblings ...)
  2020-04-09 20:05 ` [PATCH v1 3/7] MdeModulePkg/EhciPei: " Michael Kubacki
@ 2020-04-09 20:05 ` Michael Kubacki
  2020-04-10  1:47   ` [edk2-devel] " Guomin Jiang
  2020-04-09 20:05 ` [PATCH v1 5/7] MdeModulePkg/UfsPassThruDxe: " Michael Kubacki
                   ` (2 subsequent siblings)
  6 siblings, 1 reply; 12+ messages in thread
From: Michael Kubacki @ 2020-04-09 20:05 UTC (permalink / raw)
  To: devel; +Cc: Dandan Bi, Hao A Wu, Jian J Wang, Liming Gao, Ray Ni, Sean Brogan

From: Michael Kubacki <michael.kubacki@microsoft.com>

REF:https://bugzilla.tianocore.org/show_bug.cgi?id=1959

Replaces usage of the linked list iteration macros defined in Xhci.h
with the common definition in BaseLib.h.

Cc: Dandan Bi <dandan.bi@intel.com>
Cc: Hao A Wu <hao.a.wu@intel.com>
Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Sean Brogan <sean.brogan@microsoft.com>
Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
---
 MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.c | 9 +++++----
 MdeModulePkg/Bus/Pci/XhciDxe/Xhci.h      | 9 +--------
 2 files changed, 6 insertions(+), 12 deletions(-)

diff --git a/MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.c b/MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.c
index c0c374fc4758..ab8957c546ee 100644
--- a/MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.c
+++ b/MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.c
@@ -3,6 +3,7 @@
   XHCI transfer scheduling routines.
 
 Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>
+Copyright (c) Microsoft Corporation.<BR>
 SPDX-License-Identifier: BSD-2-Clause-Patent
 
 **/
@@ -1051,7 +1052,7 @@ IsAsyncIntTrb (
   LIST_ENTRY              *Next;
   URB                     *CheckedUrb;
 
-  EFI_LIST_FOR_EACH_SAFE (Entry, Next, &Xhc->AsyncIntTransfers) {
+  BASE_LIST_FOR_EACH_SAFE (Entry, Next, &Xhc->AsyncIntTransfers) {
     CheckedUrb = EFI_LIST_CONTAINER (Entry, URB, UrbList);
     if (IsTransferRingTrb (Xhc, Trb, CheckedUrb)) {
       *Urb = CheckedUrb;
@@ -1346,7 +1347,7 @@ XhciDelAsyncIntTransfer (
 
   Urb = NULL;
 
-  EFI_LIST_FOR_EACH_SAFE (Entry, Next, &Xhc->AsyncIntTransfers) {
+  BASE_LIST_FOR_EACH_SAFE (Entry, Next, &Xhc->AsyncIntTransfers) {
     Urb = EFI_LIST_CONTAINER (Entry, URB, UrbList);
     if ((Urb->Ep.BusAddr == BusAddr) &&
         (Urb->Ep.EpAddr == EpNum) &&
@@ -1386,7 +1387,7 @@ XhciDelAllAsyncIntTransfers (
   URB                     *Urb;
   EFI_STATUS              Status;
 
-  EFI_LIST_FOR_EACH_SAFE (Entry, Next, &Xhc->AsyncIntTransfers) {
+  BASE_LIST_FOR_EACH_SAFE (Entry, Next, &Xhc->AsyncIntTransfers) {
     Urb = EFI_LIST_CONTAINER (Entry, URB, UrbList);
 
     //
@@ -1578,7 +1579,7 @@ XhcMonitorAsyncRequests (
 
   Xhc    = (USB_XHCI_INSTANCE*) Context;
 
-  EFI_LIST_FOR_EACH_SAFE (Entry, Next, &Xhc->AsyncIntTransfers) {
+  BASE_LIST_FOR_EACH_SAFE (Entry, Next, &Xhc->AsyncIntTransfers) {
     Urb = EFI_LIST_CONTAINER (Entry, URB, UrbList);
 
     //
diff --git a/MdeModulePkg/Bus/Pci/XhciDxe/Xhci.h b/MdeModulePkg/Bus/Pci/XhciDxe/Xhci.h
index 72b4e084f14d..3285eb8798c0 100644
--- a/MdeModulePkg/Bus/Pci/XhciDxe/Xhci.h
+++ b/MdeModulePkg/Bus/Pci/XhciDxe/Xhci.h
@@ -3,6 +3,7 @@
   Provides some data structure definitions used by the XHCI host controller driver.
 
 Copyright (c) 2011 - 2017, Intel Corporation. All rights reserved.<BR>
+Copyright (c) Microsoft Corporation.<BR>
 SPDX-License-Identifier: BSD-2-Clause-Patent
 
 **/
@@ -82,14 +83,6 @@ typedef struct _USB_DEV_CONTEXT      USB_DEV_CONTEXT;
 #define INT_INTER                    3
 #define INT_INTER_ASYNC              4
 
-//
-// Iterate through the double linked list. This is delete-safe.
-// Don't touch NextEntry
-//
-#define EFI_LIST_FOR_EACH_SAFE(Entry, NextEntry, ListHead) \
-  for (Entry = (ListHead)->ForwardLink, NextEntry = Entry->ForwardLink;\
-      Entry != (ListHead); Entry = NextEntry, NextEntry = Entry->ForwardLink)
-
 #define EFI_LIST_CONTAINER(Entry, Type, Field) BASE_CR(Entry, Type, Field)
 
 #define XHC_LOW_32BIT(Addr64)          ((UINT32)(((UINTN)(Addr64)) & 0xFFFFFFFF))
-- 
2.16.3.windows.1


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

* [PATCH v1 5/7] MdeModulePkg/UfsPassThruDxe: Use BaseLib linked list iteration macros
       [not found] <20200409200514.32796-1-michael.kubacki@outlook.com>
                   ` (3 preceding siblings ...)
  2020-04-09 20:05 ` [PATCH v1 4/7] MdeModulePkg/XhciDxe: " Michael Kubacki
@ 2020-04-09 20:05 ` Michael Kubacki
  2020-04-09 20:05 ` [PATCH v1 6/7] MdeModulePkg/RamDiskDxe: " Michael Kubacki
  2020-04-09 20:05 ` [PATCH v1 7/7] SecurityPkg/HddPassword: " Michael Kubacki
  6 siblings, 0 replies; 12+ messages in thread
From: Michael Kubacki @ 2020-04-09 20:05 UTC (permalink / raw)
  To: devel; +Cc: Dandan Bi, Hao A Wu, Jian J Wang, Liming Gao, Ray Ni, Sean Brogan

From: Michael Kubacki <michael.kubacki@microsoft.com>

REF:https://bugzilla.tianocore.org/show_bug.cgi?id=1959

Replaces usage of the linked list iteration macros defined in UfsPassThru.h
with the common definition in BaseLib.h.

Cc: Dandan Bi <dandan.bi@intel.com>
Cc: Hao A Wu <hao.a.wu@intel.com>
Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Sean Brogan <sean.brogan@microsoft.com>
Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
---
 MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.c    | 3 ++-
 MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c | 3 ++-
 MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.h    | 9 +--------
 3 files changed, 5 insertions(+), 10 deletions(-)

diff --git a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.c b/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.c
index 26c5a8b85554..9768c2e6fb22 100644
--- a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.c
+++ b/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.c
@@ -1,6 +1,7 @@
 /** @file
 
   Copyright (c) 2014 - 2019, Intel Corporation. All rights reserved.<BR>
+  Copyright (c) Microsoft Corporation.<BR>
   SPDX-License-Identifier: BSD-2-Clause-Patent
 
 **/
@@ -1083,7 +1084,7 @@ UfsPassThruDriverBindingStop (
   // Cleanup the resources of I/O requests in the async I/O queue
   //
   if (!IsListEmpty(&Private->Queue)) {
-    EFI_LIST_FOR_EACH_SAFE (Entry, NextEntry, &Private->Queue) {
+    BASE_LIST_FOR_EACH_SAFE (Entry, NextEntry, &Private->Queue) {
       TransReq  = UFS_PASS_THRU_TRANS_REQ_FROM_THIS (Entry);
 
       //
diff --git a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c b/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c
index 93ac958f658f..0b1030ab4788 100644
--- a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c
+++ b/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c
@@ -3,6 +3,7 @@
   for upper layer application to execute UFS-supported SCSI cmds.
 
   Copyright (c) 2014 - 2019, Intel Corporation. All rights reserved.<BR>
+  Copyright (c) Microsoft Corporation.<BR>
   SPDX-License-Identifier: BSD-2-Clause-Patent
 
 **/
@@ -2285,7 +2286,7 @@ ProcessAsyncTaskList (
   // Check the entries in the async I/O queue are done or not.
   //
   if (!IsListEmpty(&Private->Queue)) {
-    EFI_LIST_FOR_EACH_SAFE (Entry, NextEntry, &Private->Queue) {
+    BASE_LIST_FOR_EACH_SAFE (Entry, NextEntry, &Private->Queue) {
       TransReq  = UFS_PASS_THRU_TRANS_REQ_FROM_THIS (Entry);
       Packet    = TransReq->Packet;
 
diff --git a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.h b/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.h
index cbc0c2126eee..ef33250c89d7 100644
--- a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.h
+++ b/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.h
@@ -1,6 +1,7 @@
 /** @file
 
   Copyright (c) 2014 - 2019, Intel Corporation. All rights reserved.<BR>
+  Copyright (c) Microsoft Corporation.<BR>
   SPDX-License-Identifier: BSD-2-Clause-Patent
 
 **/
@@ -46,14 +47,6 @@ typedef struct {
   UINT16   Rsvd:4;
 } UFS_EXPOSED_LUNS;
 
-//
-// Iterate through the double linked list. This is delete-safe.
-// Do not touch NextEntry
-//
-#define EFI_LIST_FOR_EACH_SAFE(Entry, NextEntry, ListHead)            \
-  for(Entry = (ListHead)->ForwardLink, NextEntry = Entry->ForwardLink;\
-      Entry != (ListHead); Entry = NextEntry, NextEntry = Entry->ForwardLink)
-
 typedef struct _UFS_PASS_THRU_PRIVATE_DATA {
   UINT32                              Signature;
   EFI_HANDLE                          Handle;
-- 
2.16.3.windows.1


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

* [PATCH v1 6/7] MdeModulePkg/RamDiskDxe: Use BaseLib linked list iteration macros
       [not found] <20200409200514.32796-1-michael.kubacki@outlook.com>
                   ` (4 preceding siblings ...)
  2020-04-09 20:05 ` [PATCH v1 5/7] MdeModulePkg/UfsPassThruDxe: " Michael Kubacki
@ 2020-04-09 20:05 ` Michael Kubacki
  2020-04-09 20:05 ` [PATCH v1 7/7] SecurityPkg/HddPassword: " Michael Kubacki
  6 siblings, 0 replies; 12+ messages in thread
From: Michael Kubacki @ 2020-04-09 20:05 UTC (permalink / raw)
  To: devel; +Cc: Dandan Bi, Hao A Wu, Jian J Wang, Liming Gao, Ray Ni, Sean Brogan

From: Michael Kubacki <michael.kubacki@microsoft.com>

REF:https://bugzilla.tianocore.org/show_bug.cgi?id=1959

Replaces usage of the linked list iteration macros defined in RamDiskImpl.h
with the common definition in BaseLib.h.

Cc: Dandan Bi <dandan.bi@intel.com>
Cc: Hao A Wu <hao.a.wu@intel.com>
Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Sean Brogan <sean.brogan@microsoft.com>
Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
---
 MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskDriver.c   |  3 ++-
 MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskImpl.c     |  9 +++++----
 MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskProtocol.c |  5 +++--
 MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskImpl.h     | 15 +--------------
 4 files changed, 11 insertions(+), 21 deletions(-)

diff --git a/MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskDriver.c b/MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskDriver.c
index a80ef271df9c..fcbf4f117dc6 100644
--- a/MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskDriver.c
+++ b/MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskDriver.c
@@ -2,6 +2,7 @@
   The driver entry point for RamDiskDxe driver.
 
   Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>
+  Copyright (c) Microsoft Corporation.<BR>
   SPDX-License-Identifier: BSD-2-Clause-Patent
 
 **/
@@ -92,7 +93,7 @@ RamDiskAcpiCheck (
     return;
   }
 
-  EFI_LIST_FOR_EACH (Entry, &RegisteredRamDisks) {
+  BASE_LIST_FOR_EACH (Entry, &RegisteredRamDisks) {
     PrivateData = RAM_DISK_PRIVATE_FROM_THIS (Entry);
     RamDiskPublishNfit (PrivateData);
   }
diff --git a/MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskImpl.c b/MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskImpl.c
index 96ea74a9a536..e35b8fa2296c 100644
--- a/MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskImpl.c
+++ b/MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskImpl.c
@@ -3,6 +3,7 @@
 
   Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>
   (C) Copyright 2016-2018 Hewlett Packard Enterprise Development LP<BR>
+  Copyright (c) Microsoft Corporation.<BR>
   SPDX-License-Identifier: BSD-2-Clause-Patent
 
 **/
@@ -165,7 +166,7 @@ UnregisterAllRamDisks (
   RAM_DISK_PRIVATE_DATA           *PrivateData;
 
   if (!IsListEmpty(&RegisteredRamDisks)) {
-    EFI_LIST_FOR_EACH_SAFE (Entry, NextEntry, &RegisteredRamDisks) {
+    BASE_LIST_FOR_EACH_SAFE (Entry, NextEntry, &RegisteredRamDisks) {
       PrivateData = RAM_DISK_PRIVATE_FROM_THIS (Entry);
 
       gBS->UninstallMultipleProtocolInterfaces (
@@ -507,7 +508,7 @@ UpdateMainForm (
   EndLabel->Number       = MAIN_LABEL_LIST_END;
 
   Index = 0;
-  EFI_LIST_FOR_EACH (Entry, &RegisteredRamDisks) {
+  BASE_LIST_FOR_EACH (Entry, &RegisteredRamDisks) {
     PrivateData                  = RAM_DISK_PRIVATE_FROM_THIS (Entry);
     PrivateData->CheckBoxId      = (EFI_QUESTION_ID)
                                    (MAIN_CHECKBOX_QUESTION_ID_START + Index);
@@ -689,7 +690,7 @@ RamDiskCallback (
       //
       // Remove the selected RAM disks
       //
-      EFI_LIST_FOR_EACH_SAFE (Entry, NextEntry, &RegisteredRamDisks) {
+      BASE_LIST_FOR_EACH_SAFE (Entry, NextEntry, &RegisteredRamDisks) {
         PrivateData = RAM_DISK_PRIVATE_FROM_THIS (Entry);
         if (PrivateData->CheckBoxChecked) {
           RamDiskUnregister (
@@ -742,7 +743,7 @@ RamDiskCallback (
       //
       if ((QuestionId >= MAIN_CHECKBOX_QUESTION_ID_START) &&
           (QuestionId < CREATE_RAW_RAM_DISK_FORM_ID)) {
-        EFI_LIST_FOR_EACH (Entry, &RegisteredRamDisks) {
+        BASE_LIST_FOR_EACH (Entry, &RegisteredRamDisks) {
           PrivateData = RAM_DISK_PRIVATE_FROM_THIS (Entry);
           if (PrivateData->CheckBoxId == QuestionId) {
             PrivateData->CheckBoxChecked = (BOOLEAN) (Value->u8 != 0);
diff --git a/MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskProtocol.c b/MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskProtocol.c
index 36d635e4bc31..4333e000539b 100644
--- a/MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskProtocol.c
+++ b/MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskProtocol.c
@@ -3,6 +3,7 @@
 
   Copyright (c) 2016 - 2019, Intel Corporation. All rights reserved.<BR>
   (C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>
+  Copyright (c) Microsoft Corporation.<BR>
   SPDX-License-Identifier: BSD-2-Clause-Patent
 
 **/
@@ -662,7 +663,7 @@ RamDiskRegister (
   if (!IsListEmpty(&RegisteredRamDisks)) {
     DevicePathSize = GetDevicePathSize (PrivateData->DevicePath);
 
-    EFI_LIST_FOR_EACH (Entry, &RegisteredRamDisks) {
+    BASE_LIST_FOR_EACH (Entry, &RegisteredRamDisks) {
       RegisteredPrivateData = RAM_DISK_PRIVATE_FROM_THIS (Entry);
       if (DevicePathSize == GetDevicePathSize (RegisteredPrivateData->DevicePath)) {
         //
@@ -797,7 +798,7 @@ RamDiskUnregister (
   EndingAddr     = ReadUnaligned64 ((UINT64 *) &(RamDiskDevNode->EndingAddr[0]));
 
   if (!IsListEmpty(&RegisteredRamDisks)) {
-    EFI_LIST_FOR_EACH_SAFE (Entry, NextEntry, &RegisteredRamDisks) {
+    BASE_LIST_FOR_EACH_SAFE (Entry, NextEntry, &RegisteredRamDisks) {
       PrivateData = RAM_DISK_PRIVATE_FROM_THIS (Entry);
 
       //
diff --git a/MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskImpl.h b/MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskImpl.h
index 25fec15c1882..ed80b47ccc33 100644
--- a/MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskImpl.h
+++ b/MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskImpl.h
@@ -2,6 +2,7 @@
   The header file of RamDiskDxe driver.
 
   Copyright (c) 2016 - 2019, Intel Corporation. All rights reserved.<BR>
+  Copyright (c) Microsoft Corporation.<BR>
   SPDX-License-Identifier: BSD-2-Clause-Patent
 
 **/
@@ -47,20 +48,6 @@
 //
 #define RAM_DISK_DEFAULT_BLOCK_SIZE 512
 
-//
-// Iterate through the double linked list. NOT delete safe
-//
-#define EFI_LIST_FOR_EACH(Entry, ListHead)    \
-  for(Entry = (ListHead)->ForwardLink; Entry != (ListHead); Entry = Entry->ForwardLink)
-
-//
-// Iterate through the double linked list. This is delete-safe.
-// Do not touch NextEntry
-//
-#define EFI_LIST_FOR_EACH_SAFE(Entry, NextEntry, ListHead)            \
-  for(Entry = (ListHead)->ForwardLink, NextEntry = Entry->ForwardLink;\
-      Entry != (ListHead); Entry = NextEntry, NextEntry = Entry->ForwardLink)
-
 //
 // RamDiskDxe driver maintains a list of registered RAM disks.
 //
-- 
2.16.3.windows.1


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

* [PATCH v1 7/7] SecurityPkg/HddPassword: Use BaseLib linked list iteration macros
       [not found] <20200409200514.32796-1-michael.kubacki@outlook.com>
                   ` (5 preceding siblings ...)
  2020-04-09 20:05 ` [PATCH v1 6/7] MdeModulePkg/RamDiskDxe: " Michael Kubacki
@ 2020-04-09 20:05 ` Michael Kubacki
  2020-04-09 23:10   ` Yao, Jiewen
  6 siblings, 1 reply; 12+ messages in thread
From: Michael Kubacki @ 2020-04-09 20:05 UTC (permalink / raw)
  To: devel; +Cc: Chao Zhang, Hao A Wu, Jian J Wang, Jiewen Yao, Sean Brogan

From: Michael Kubacki <michael.kubacki@microsoft.com>

REF:https://bugzilla.tianocore.org/show_bug.cgi?id=1959

Replaces usage of the linked list iteration macros defined in
HddPasswordDxe.h with the common definition in BaseLib.h.

Cc: Chao Zhang <chao.b.zhang@intel.com>
Cc: Hao A Wu <hao.a.wu@intel.com>
Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Sean Brogan <sean.brogan@microsoft.com>
Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
---
 SecurityPkg/HddPassword/HddPasswordDxe.c | 13 +++++++------
 SecurityPkg/HddPassword/HddPasswordDxe.h |  7 +------
 2 files changed, 8 insertions(+), 12 deletions(-)

diff --git a/SecurityPkg/HddPassword/HddPasswordDxe.c b/SecurityPkg/HddPassword/HddPasswordDxe.c
index a25b3471d073..32b55a6a8b72 100644
--- a/SecurityPkg/HddPassword/HddPasswordDxe.c
+++ b/SecurityPkg/HddPassword/HddPasswordDxe.c
@@ -2,6 +2,7 @@
   HDD password driver which is used to support HDD security feature.
 
   Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
+  Copyright (c) Microsoft Corporation.<BR>
 
   SPDX-License-Identifier: BSD-2-Clause-Patent
 
@@ -115,7 +116,7 @@ BuildHddPasswordDeviceInfo (
   // Build HDD password device info and save them to LockBox.
   //
   DevInfoLength = 0;
-  EFI_LIST_FOR_EACH (Entry, &mHddPasswordConfigFormList) {
+  BASE_LIST_FOR_EACH (Entry, &mHddPasswordConfigFormList) {
     ConfigFormEntry = BASE_CR (Entry, HDD_PASSWORD_CONFIG_FORM_ENTRY, Link);
 
     //
@@ -164,7 +165,7 @@ BuildHddPasswordDeviceInfo (
   ASSERT (DevInfo != NULL);
 
   TempDevInfo = DevInfo;
-  EFI_LIST_FOR_EACH (Entry, &mHddPasswordConfigFormList) {
+  BASE_LIST_FOR_EACH (Entry, &mHddPasswordConfigFormList) {
     ConfigFormEntry = BASE_CR (Entry, HDD_PASSWORD_CONFIG_FORM_ENTRY, Link);
 
     if ((!PasswordIsFullZero (ConfigFormEntry->Password)) ||
@@ -472,7 +473,7 @@ HddPasswordEndOfDxeEventNotify (
   //
   // Zero passsword and freeze lock device.
   //
-  EFI_LIST_FOR_EACH (Entry, &mHddPasswordConfigFormList) {
+  BASE_LIST_FOR_EACH (Entry, &mHddPasswordConfigFormList) {
     ConfigFormEntry = BASE_CR (Entry, HDD_PASSWORD_CONFIG_FORM_ENTRY, Link);
 
     ZeroMem (ConfigFormEntry->Password, HDD_PASSWORD_MAX_LENGTH);
@@ -2026,7 +2027,7 @@ HddPasswordGetConfigFormEntryByIndex (
   CurrentIndex    = 0;
   ConfigFormEntry = NULL;
 
-  EFI_LIST_FOR_EACH (Entry, &mHddPasswordConfigFormList) {
+  BASE_LIST_FOR_EACH (Entry, &mHddPasswordConfigFormList) {
     if (CurrentIndex == Index) {
       ConfigFormEntry = BASE_CR (Entry, HDD_PASSWORD_CONFIG_FORM_ENTRY, Link);
       break;
@@ -2408,7 +2409,7 @@ HddPasswordConfigUpdateForm (
   ConfigFormEntry = NULL;
   EntryExisted    = FALSE;
 
-  EFI_LIST_FOR_EACH (Entry, &mHddPasswordConfigFormList) {
+  BASE_LIST_FOR_EACH (Entry, &mHddPasswordConfigFormList) {
     ConfigFormEntry = BASE_CR (Entry, HDD_PASSWORD_CONFIG_FORM_ENTRY, Link);
 
     if ((ConfigFormEntry->Bus == Bus) &&
@@ -2503,7 +2504,7 @@ HddPasswordConfigUpdateForm (
     EndLabel->Number       = HDD_DEVICE_LABEL_END;
 
     mNumberOfHddDevices = 0;
-    EFI_LIST_FOR_EACH (Entry, &mHddPasswordConfigFormList) {
+    BASE_LIST_FOR_EACH (Entry, &mHddPasswordConfigFormList) {
       ConfigFormEntry = BASE_CR (Entry, HDD_PASSWORD_CONFIG_FORM_ENTRY, Link);
 
       HiiCreateGotoOpCode (
diff --git a/SecurityPkg/HddPassword/HddPasswordDxe.h b/SecurityPkg/HddPassword/HddPasswordDxe.h
index 87db587eb6f0..a6c87169dc59 100644
--- a/SecurityPkg/HddPassword/HddPasswordDxe.h
+++ b/SecurityPkg/HddPassword/HddPasswordDxe.h
@@ -1,6 +1,7 @@
 /** @file
 
   Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
+  Copyright (c) Microsoft Corporation.<BR>
 
   SPDX-License-Identifier: BSD-2-Clause-Patent
 
@@ -87,12 +88,6 @@ typedef struct _HDD_PASSWORD_DXE_PRIVATE_DATA {
 
 #define HDD_PASSWORD_DXE_PRIVATE_FROM_THIS(a)  CR (a, HDD_PASSWORD_DXE_PRIVATE_DATA, ConfigAccess, HDD_PASSWORD_DXE_PRIVATE_SIGNATURE)
 
-//
-//Iterate through the double linked list. NOT delete safe
-//
-#define EFI_LIST_FOR_EACH(Entry, ListHead)    \
-  for (Entry = (ListHead)->ForwardLink; Entry != (ListHead); Entry = Entry->ForwardLink)
-
 #define PASSWORD_SALT_SIZE                  32
 
 #define HDD_PASSWORD_REQUEST_VARIABLE_NAME  L"HddPasswordRequest"
-- 
2.16.3.windows.1


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

* Re: [PATCH v1 7/7] SecurityPkg/HddPassword: Use BaseLib linked list iteration macros
  2020-04-09 20:05 ` [PATCH v1 7/7] SecurityPkg/HddPassword: " Michael Kubacki
@ 2020-04-09 23:10   ` Yao, Jiewen
  0 siblings, 0 replies; 12+ messages in thread
From: Yao, Jiewen @ 2020-04-09 23:10 UTC (permalink / raw)
  To: michael.kubacki@outlook.com, devel@edk2.groups.io
  Cc: Zhang, Chao B, Wu, Hao A, Wang, Jian J, Sean Brogan

Reviewed-by: Jiewen.yao@intel.com

> -----Original Message-----
> From: michael.kubacki@outlook.com <michael.kubacki@outlook.com>
> Sent: Friday, April 10, 2020 4:05 AM
> To: devel@edk2.groups.io
> Cc: Zhang, Chao B <chao.b.zhang@intel.com>; Wu, Hao A
> <hao.a.wu@intel.com>; Wang, Jian J <jian.j.wang@intel.com>; Yao, Jiewen
> <jiewen.yao@intel.com>; Sean Brogan <sean.brogan@microsoft.com>
> Subject: [PATCH v1 7/7] SecurityPkg/HddPassword: Use BaseLib linked list
> iteration macros
> 
> From: Michael Kubacki <michael.kubacki@microsoft.com>
> 
> REF:https://bugzilla.tianocore.org/show_bug.cgi?id=1959
> 
> Replaces usage of the linked list iteration macros defined in
> HddPasswordDxe.h with the common definition in BaseLib.h.
> 
> Cc: Chao Zhang <chao.b.zhang@intel.com>
> Cc: Hao A Wu <hao.a.wu@intel.com>
> Cc: Jian J Wang <jian.j.wang@intel.com>
> Cc: Jiewen Yao <jiewen.yao@intel.com>
> Cc: Sean Brogan <sean.brogan@microsoft.com>
> Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
> ---
>  SecurityPkg/HddPassword/HddPasswordDxe.c | 13 +++++++------
>  SecurityPkg/HddPassword/HddPasswordDxe.h |  7 +------
>  2 files changed, 8 insertions(+), 12 deletions(-)
> 
> diff --git a/SecurityPkg/HddPassword/HddPasswordDxe.c
> b/SecurityPkg/HddPassword/HddPasswordDxe.c
> index a25b3471d073..32b55a6a8b72 100644
> --- a/SecurityPkg/HddPassword/HddPasswordDxe.c
> +++ b/SecurityPkg/HddPassword/HddPasswordDxe.c
> @@ -2,6 +2,7 @@
>    HDD password driver which is used to support HDD security feature.
> 
>    Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
> +  Copyright (c) Microsoft Corporation.<BR>
> 
>    SPDX-License-Identifier: BSD-2-Clause-Patent
> 
> @@ -115,7 +116,7 @@ BuildHddPasswordDeviceInfo (
>    // Build HDD password device info and save them to LockBox.
>    //
>    DevInfoLength = 0;
> -  EFI_LIST_FOR_EACH (Entry, &mHddPasswordConfigFormList) {
> +  BASE_LIST_FOR_EACH (Entry, &mHddPasswordConfigFormList) {
>      ConfigFormEntry = BASE_CR (Entry, HDD_PASSWORD_CONFIG_FORM_ENTRY,
> Link);
> 
>      //
> @@ -164,7 +165,7 @@ BuildHddPasswordDeviceInfo (
>    ASSERT (DevInfo != NULL);
> 
>    TempDevInfo = DevInfo;
> -  EFI_LIST_FOR_EACH (Entry, &mHddPasswordConfigFormList) {
> +  BASE_LIST_FOR_EACH (Entry, &mHddPasswordConfigFormList) {
>      ConfigFormEntry = BASE_CR (Entry, HDD_PASSWORD_CONFIG_FORM_ENTRY,
> Link);
> 
>      if ((!PasswordIsFullZero (ConfigFormEntry->Password)) ||
> @@ -472,7 +473,7 @@ HddPasswordEndOfDxeEventNotify (
>    //
>    // Zero passsword and freeze lock device.
>    //
> -  EFI_LIST_FOR_EACH (Entry, &mHddPasswordConfigFormList) {
> +  BASE_LIST_FOR_EACH (Entry, &mHddPasswordConfigFormList) {
>      ConfigFormEntry = BASE_CR (Entry, HDD_PASSWORD_CONFIG_FORM_ENTRY,
> Link);
> 
>      ZeroMem (ConfigFormEntry->Password, HDD_PASSWORD_MAX_LENGTH);
> @@ -2026,7 +2027,7 @@ HddPasswordGetConfigFormEntryByIndex (
>    CurrentIndex    = 0;
>    ConfigFormEntry = NULL;
> 
> -  EFI_LIST_FOR_EACH (Entry, &mHddPasswordConfigFormList) {
> +  BASE_LIST_FOR_EACH (Entry, &mHddPasswordConfigFormList) {
>      if (CurrentIndex == Index) {
>        ConfigFormEntry = BASE_CR (Entry,
> HDD_PASSWORD_CONFIG_FORM_ENTRY, Link);
>        break;
> @@ -2408,7 +2409,7 @@ HddPasswordConfigUpdateForm (
>    ConfigFormEntry = NULL;
>    EntryExisted    = FALSE;
> 
> -  EFI_LIST_FOR_EACH (Entry, &mHddPasswordConfigFormList) {
> +  BASE_LIST_FOR_EACH (Entry, &mHddPasswordConfigFormList) {
>      ConfigFormEntry = BASE_CR (Entry, HDD_PASSWORD_CONFIG_FORM_ENTRY,
> Link);
> 
>      if ((ConfigFormEntry->Bus == Bus) &&
> @@ -2503,7 +2504,7 @@ HddPasswordConfigUpdateForm (
>      EndLabel->Number       = HDD_DEVICE_LABEL_END;
> 
>      mNumberOfHddDevices = 0;
> -    EFI_LIST_FOR_EACH (Entry, &mHddPasswordConfigFormList) {
> +    BASE_LIST_FOR_EACH (Entry, &mHddPasswordConfigFormList) {
>        ConfigFormEntry = BASE_CR (Entry,
> HDD_PASSWORD_CONFIG_FORM_ENTRY, Link);
> 
>        HiiCreateGotoOpCode (
> diff --git a/SecurityPkg/HddPassword/HddPasswordDxe.h
> b/SecurityPkg/HddPassword/HddPasswordDxe.h
> index 87db587eb6f0..a6c87169dc59 100644
> --- a/SecurityPkg/HddPassword/HddPasswordDxe.h
> +++ b/SecurityPkg/HddPassword/HddPasswordDxe.h
> @@ -1,6 +1,7 @@
>  /** @file
> 
>    Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
> +  Copyright (c) Microsoft Corporation.<BR>
> 
>    SPDX-License-Identifier: BSD-2-Clause-Patent
> 
> @@ -87,12 +88,6 @@ typedef struct _HDD_PASSWORD_DXE_PRIVATE_DATA {
> 
>  #define HDD_PASSWORD_DXE_PRIVATE_FROM_THIS(a)  CR (a,
> HDD_PASSWORD_DXE_PRIVATE_DATA, ConfigAccess,
> HDD_PASSWORD_DXE_PRIVATE_SIGNATURE)
> 
> -//
> -//Iterate through the double linked list. NOT delete safe
> -//
> -#define EFI_LIST_FOR_EACH(Entry, ListHead)    \
> -  for (Entry = (ListHead)->ForwardLink; Entry != (ListHead); Entry = Entry-
> >ForwardLink)
> -
>  #define PASSWORD_SALT_SIZE                  32
> 
>  #define HDD_PASSWORD_REQUEST_VARIABLE_NAME
> L"HddPasswordRequest"
> --
> 2.16.3.windows.1


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

* Re: [edk2-devel] [PATCH v1 1/7] MdePkg/BaseLib: Add linked list iteration macros
  2020-04-09 20:05 ` [PATCH v1 1/7] MdePkg/BaseLib: Add linked list iteration macros Michael Kubacki
@ 2020-04-10  1:45   ` Guomin Jiang
  0 siblings, 0 replies; 12+ messages in thread
From: Guomin Jiang @ 2020-04-10  1:45 UTC (permalink / raw)
  To: devel@edk2.groups.io, michael.kubacki@outlook.com
  Cc: Bi, Dandan, Wu, Hao A, Wang, Jian J, Gao, Liming,
	Kinney, Michael D, Sean Brogan

Reviewed-by: Guomin Jiang <guomin.jiang@intel.com>

> -----Original Message-----
> From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Michael
> Kubacki
> Sent: Friday, April 10, 2020 4:05 AM
> To: devel@edk2.groups.io
> Cc: Bi, Dandan <dandan.bi@intel.com>; Wu, Hao A <hao.a.wu@intel.com>;
> Wang, Jian J <jian.j.wang@intel.com>; Gao, Liming <liming.gao@intel.com>;
> Kinney, Michael D <michael.d.kinney@intel.com>; Sean Brogan
> <sean.brogan@microsoft.com>
> Subject: [edk2-devel] [PATCH v1 1/7] MdePkg/BaseLib: Add linked list
> iteration macros
> 
> From: Michael Kubacki <michael.kubacki@microsoft.com>
> 
> REF:https://bugzilla.tianocore.org/show_bug.cgi?id=1959
> 
> The macros EFI_LIST_FOR_EACH and EFI_LIST_FOR_EACH_SAFE have been
> duplicated across several drivers. These macros have proven useful and
> established a commonly used pattern for linked list iteration.
> 
> This change defines the macros in BaseLib.h alongside other generic linked
> list macros and functions.
> 
> Cc: Dandan Bi <dandan.bi@intel.com>
> Cc: Hao A Wu <hao.a.wu@intel.com>
> Cc: Jian J Wang <jian.j.wang@intel.com>
> Cc: Liming Gao <liming.gao@intel.com>
> Cc: Michael D Kinney <michael.d.kinney@intel.com>
> Cc: Sean Brogan <sean.brogan@microsoft.com>
> Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
> ---
>  MdePkg/Include/Library/BaseLib.h | 27 ++++++++++++++++++++
>  1 file changed, 27 insertions(+)
> 
> diff --git a/MdePkg/Include/Library/BaseLib.h
> b/MdePkg/Include/Library/BaseLib.h
> index ecadff8b235e..d066f1be2495 100644
> --- a/MdePkg/Include/Library/BaseLib.h
> +++ b/MdePkg/Include/Library/BaseLib.h
> @@ -4,6 +4,7 @@
> 
>  Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.<BR>
> Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
> +Copyright (c) Microsoft Corporation.<BR>
>  SPDX-License-Identifier: BSD-2-Clause-Patent
> 
>  **/
> @@ -2972,6 +2973,32 @@ PathCleanUpDirectories(  **/  #define
> INITIALIZE_LIST_HEAD_VARIABLE(ListHead)  {&(ListHead), &(ListHead)}
> 
> +/**
> +  Iterates over each node in a doubly linked list using each node's forward
> link.
> +
> +  @param  Entry     A pointer to a list node used as a loop cursor during
> iteration
> +  @param  ListHead  The head node of the doubly linked list
> +
> +**/
> +#define BASE_LIST_FOR_EACH(Entry, ListHead)    \
> +  for(Entry = (ListHead)->ForwardLink; Entry != (ListHead); Entry =
> +Entry->ForwardLink)
> +
> +/**
> +  Iterates over each node in a doubly linked list using each node's
> +forward link
> +  with safety against node removal.
> +
> +  This macro uses NextEntry to temporarily store the next list node so
> + the node  pointed to by Entry may be deleted in the current loop
> + iteration step and  iteration can continue from the node pointed to by
> NextEntry.
> +
> +  @param  Entry     A pointer to a list node used as a loop cursor during
> iteration
> +  @param  NextEntry A pointer to a list node used to temporarily store
> + the next node  @param  ListHead  The head node of the doubly linked
> + list
> +
> +**/
> +#define BASE_LIST_FOR_EACH_SAFE(Entry, NextEntry, ListHead)            \
> +  for(Entry = (ListHead)->ForwardLink, NextEntry = Entry->ForwardLink;\
> +      Entry != (ListHead); Entry = NextEntry, NextEntry =
> +Entry->ForwardLink)
> 
>  /**
>    Checks whether FirstEntry and SecondEntry are part of the same doubly-
> linked
> --
> 2.16.3.windows.1
> 
> 
> 


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

* Re: [edk2-devel] [PATCH v1 2/7] MdeModulePkg/EhciDxe: Use BaseLib linked list iteration macros
  2020-04-09 20:05 ` [PATCH v1 2/7] MdeModulePkg/EhciDxe: Use BaseLib " Michael Kubacki
@ 2020-04-10  1:46   ` Guomin Jiang
  0 siblings, 0 replies; 12+ messages in thread
From: Guomin Jiang @ 2020-04-10  1:46 UTC (permalink / raw)
  To: devel@edk2.groups.io, michael.kubacki@outlook.com
  Cc: Bi, Dandan, Wu, Hao A, Wang, Jian J, Gao, Liming, Ni, Ray,
	Sean Brogan

Reviewed-by: Guomin Jiang <guomin.jiang@intel.com>

> -----Original Message-----
> From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Michael
> Kubacki
> Sent: Friday, April 10, 2020 4:05 AM
> To: devel@edk2.groups.io
> Cc: Bi, Dandan <dandan.bi@intel.com>; Wu, Hao A <hao.a.wu@intel.com>;
> Wang, Jian J <jian.j.wang@intel.com>; Gao, Liming <liming.gao@intel.com>;
> Ni, Ray <ray.ni@intel.com>; Sean Brogan <sean.brogan@microsoft.com>
> Subject: [edk2-devel] [PATCH v1 2/7] MdeModulePkg/EhciDxe: Use BaseLib
> linked list iteration macros
> 
> From: Michael Kubacki <michael.kubacki@microsoft.com>
> 
> REF:https://bugzilla.tianocore.org/show_bug.cgi?id=1959
> 
> Replaces usage of the linked list iteration macros defined in Ehci.h with the
> common definition in BaseLib.h.
> 
> Cc: Dandan Bi <dandan.bi@intel.com>
> Cc: Hao A Wu <hao.a.wu@intel.com>
> Cc: Jian J Wang <jian.j.wang@intel.com>
> Cc: Liming Gao <liming.gao@intel.com>
> Cc: Ray Ni <ray.ni@intel.com>
> Cc: Sean Brogan <sean.brogan@microsoft.com>
> Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
> ---
>  MdeModulePkg/Bus/Pci/EhciDxe/EhciDebug.c |  3 ++-
> MdeModulePkg/Bus/Pci/EhciDxe/EhciSched.c | 11 ++++++-----
>  MdeModulePkg/Bus/Pci/EhciDxe/EhciUrb.c   |  5 +++--
>  MdeModulePkg/Bus/Pci/EhciDxe/Ehci.h      | 15 +--------------
>  4 files changed, 12 insertions(+), 22 deletions(-)
> 
> diff --git a/MdeModulePkg/Bus/Pci/EhciDxe/EhciDebug.c
> b/MdeModulePkg/Bus/Pci/EhciDxe/EhciDebug.c
> index e10f6bb357ab..db0e2c6d39c6 100644
> --- a/MdeModulePkg/Bus/Pci/EhciDxe/EhciDebug.c
> +++ b/MdeModulePkg/Bus/Pci/EhciDxe/EhciDebug.c
> @@ -3,6 +3,7 @@
>    This file provides the information dump support for EHCI when in debug
> mode.
> 
>  Copyright (c) 2007 - 2013, Intel Corporation. All rights reserved.<BR>
> +Copyright (c) Microsoft Corporation.<BR>
>  SPDX-License-Identifier: BSD-2-Clause-Patent
> 
>  **/
> @@ -185,7 +186,7 @@ EhcDumpQh (
> 
>    DEBUG ((EFI_D_VERBOSE, "\n"));
> 
> -  EFI_LIST_FOR_EACH (Entry, &Qh->Qtds) {
> +  BASE_LIST_FOR_EACH (Entry, &Qh->Qtds) {
>      Qtd = EFI_LIST_CONTAINER (Entry, EHC_QTD, QtdList);
>      EhcDumpQtd (Qtd, NULL);
> 
> diff --git a/MdeModulePkg/Bus/Pci/EhciDxe/EhciSched.c
> b/MdeModulePkg/Bus/Pci/EhciDxe/EhciSched.c
> index 7db637aa2cb9..5fe7cf466939 100644
> --- a/MdeModulePkg/Bus/Pci/EhciDxe/EhciSched.c
> +++ b/MdeModulePkg/Bus/Pci/EhciDxe/EhciSched.c
> @@ -3,6 +3,7 @@
>    EHCI transfer scheduling routines.
> 
>  Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>
> +Copyright (c) Microsoft Corporation.<BR>
>  SPDX-License-Identifier: BSD-2-Clause-Patent
> 
>  **/
> @@ -577,7 +578,7 @@ EhcCheckUrbResult (
>      goto ON_EXIT;
>    }
> 
> -  EFI_LIST_FOR_EACH (Entry, &Urb->Qh->Qtds) {
> +  BASE_LIST_FOR_EACH (Entry, &Urb->Qh->Qtds) {
>      Qtd   = EFI_LIST_CONTAINER (Entry, EHC_QTD, QtdList);
>      QtdHw = &Qtd->QtdHw;
>      State = (UINT8) QtdHw->Status;
> @@ -757,7 +758,7 @@ EhciDelAsyncIntTransfer (
>    Direction = (((EpNum & 0x80) != 0) ? EfiUsbDataIn : EfiUsbDataOut);
>    EpNum    &= 0x0F;
> 
> -  EFI_LIST_FOR_EACH_SAFE (Entry, Next, &Ehc->AsyncIntTransfers) {
> +  BASE_LIST_FOR_EACH_SAFE (Entry, Next, &Ehc->AsyncIntTransfers) {
>      Urb = EFI_LIST_CONTAINER (Entry, URB, UrbList);
> 
>      if ((Urb->Ep.DevAddr == DevAddr) && (Urb->Ep.EpAddr == EpNum) &&
> @@ -797,7 +798,7 @@ EhciDelAllAsyncIntTransfers (
>    LIST_ENTRY              *Next;
>    URB                     *Urb;
> 
> -  EFI_LIST_FOR_EACH_SAFE (Entry, Next, &Ehc->AsyncIntTransfers) {
> +  BASE_LIST_FOR_EACH_SAFE (Entry, Next, &Ehc->AsyncIntTransfers) {
>      Urb = EFI_LIST_CONTAINER (Entry, URB, UrbList);
> 
>      EhcUnlinkQhFromPeriod (Ehc, Urb->Qh); @@ -965,7 +966,7 @@
> EhcUpdateAsyncRequest (
>    if (Urb->Result == EFI_USB_NOERROR) {
>      FirstQtd = NULL;
> 
> -    EFI_LIST_FOR_EACH (Entry, &Urb->Qh->Qtds) {
> +    BASE_LIST_FOR_EACH (Entry, &Urb->Qh->Qtds) {
>        Qtd = EFI_LIST_CONTAINER (Entry, EHC_QTD, QtdList);
> 
>        if (FirstQtd == NULL) {
> @@ -1049,7 +1050,7 @@ EhcMonitorAsyncRequests (
>    OldTpl  = gBS->RaiseTPL (EHC_TPL);
>    Ehc     = (USB2_HC_DEV *) Context;
> 
> -  EFI_LIST_FOR_EACH_SAFE (Entry, Next, &Ehc->AsyncIntTransfers) {
> +  BASE_LIST_FOR_EACH_SAFE (Entry, Next, &Ehc->AsyncIntTransfers) {
>      Urb = EFI_LIST_CONTAINER (Entry, URB, UrbList);
> 
>      //
> diff --git a/MdeModulePkg/Bus/Pci/EhciDxe/EhciUrb.c
> b/MdeModulePkg/Bus/Pci/EhciDxe/EhciUrb.c
> index ac5ddd259a83..37cef6d130f7 100644
> --- a/MdeModulePkg/Bus/Pci/EhciDxe/EhciUrb.c
> +++ b/MdeModulePkg/Bus/Pci/EhciDxe/EhciUrb.c
> @@ -4,6 +4,7 @@
>      URB (Usb Request Block).
> 
>  Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>
> +Copyright (c) Microsoft Corporation.<BR>
>  SPDX-License-Identifier: BSD-2-Clause-Patent
> 
>  **/
> @@ -299,7 +300,7 @@ EhcFreeQtds (
>    LIST_ENTRY              *Next;
>    EHC_QTD                 *Qtd;
> 
> -  EFI_LIST_FOR_EACH_SAFE (Entry, Next, Qtds) {
> +  BASE_LIST_FOR_EACH_SAFE (Entry, Next, Qtds) {
>      Qtd = EFI_LIST_CONTAINER (Entry, EHC_QTD, QtdList);
> 
>      RemoveEntryList (&Qtd->QtdList);
> @@ -482,7 +483,7 @@ EhcCreateQtds (
>    //
>    // OK, all the QTDs needed are created. Now, fix the NextQtd point
>    //
> -  EFI_LIST_FOR_EACH (Entry, &Qh->Qtds) {
> +  BASE_LIST_FOR_EACH (Entry, &Qh->Qtds) {
>      Qtd = EFI_LIST_CONTAINER (Entry, EHC_QTD, QtdList);
> 
>      //
> diff --git a/MdeModulePkg/Bus/Pci/EhciDxe/Ehci.h
> b/MdeModulePkg/Bus/Pci/EhciDxe/Ehci.h
> index 31fb171497a8..65933d94396e 100644
> --- a/MdeModulePkg/Bus/Pci/EhciDxe/Ehci.h
> +++ b/MdeModulePkg/Bus/Pci/EhciDxe/Ehci.h
> @@ -3,6 +3,7 @@
>    Provides some data struct used by EHCI controller driver.
> 
>  Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
> +Copyright (c) Microsoft Corporation.<BR>
>  SPDX-License-Identifier: BSD-2-Clause-Patent
> 
>  **/
> @@ -80,20 +81,6 @@ typedef struct _USB2_HC_DEV  USB2_HC_DEV;  //
>  #define  EHC_TPL                     TPL_NOTIFY
> 
> -//
> -//Iterate through the double linked list. NOT delete safe -//
> -#define EFI_LIST_FOR_EACH(Entry, ListHead)    \
> -  for(Entry = (ListHead)->ForwardLink; Entry != (ListHead); Entry = Entry-
> >ForwardLink)
> -
> -//
> -//Iterate through the double linked list. This is delete-safe.
> -//Don't touch NextEntry
> -//
> -#define EFI_LIST_FOR_EACH_SAFE(Entry, NextEntry, ListHead)            \
> -  for(Entry = (ListHead)->ForwardLink, NextEntry = Entry->ForwardLink;\
> -      Entry != (ListHead); Entry = NextEntry, NextEntry = Entry->ForwardLink)
> -
>  #define EFI_LIST_CONTAINER(Entry, Type, Field) BASE_CR(Entry, Type, Field)
> 
> 
> --
> 2.16.3.windows.1
> 
> 
> 


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

* Re: [edk2-devel] [PATCH v1 3/7] MdeModulePkg/EhciPei: Use BaseLib linked list iteration macros
  2020-04-09 20:05 ` [PATCH v1 3/7] MdeModulePkg/EhciPei: " Michael Kubacki
@ 2020-04-10  1:47   ` Guomin Jiang
  0 siblings, 0 replies; 12+ messages in thread
From: Guomin Jiang @ 2020-04-10  1:47 UTC (permalink / raw)
  To: devel@edk2.groups.io, michael.kubacki@outlook.com
  Cc: Bi, Dandan, Wu, Hao A, Wang, Jian J, Gao, Liming, Ni, Ray,
	Sean Brogan

Reviewed-by: Guomin Jiang <guomin.jiang@intel.com>

> -----Original Message-----
> From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Michael
> Kubacki
> Sent: Friday, April 10, 2020 4:05 AM
> To: devel@edk2.groups.io
> Cc: Bi, Dandan <dandan.bi@intel.com>; Wu, Hao A <hao.a.wu@intel.com>;
> Wang, Jian J <jian.j.wang@intel.com>; Gao, Liming <liming.gao@intel.com>;
> Ni, Ray <ray.ni@intel.com>; Sean Brogan <sean.brogan@microsoft.com>
> Subject: [edk2-devel] [PATCH v1 3/7] MdeModulePkg/EhciPei: Use BaseLib
> linked list iteration macros
> 
> From: Michael Kubacki <michael.kubacki@microsoft.com>
> 
> REF:https://bugzilla.tianocore.org/show_bug.cgi?id=1959
> 
> Replaces usage of the linked list iteration macros defined in EhcPeim.h with
> the common definition in BaseLib.h.
> 
> Cc: Dandan Bi <dandan.bi@intel.com>
> Cc: Hao A Wu <hao.a.wu@intel.com>
> Cc: Jian J Wang <jian.j.wang@intel.com>
> Cc: Liming Gao <liming.gao@intel.com>
> Cc: Ray Ni <ray.ni@intel.com>
> Cc: Sean Brogan <sean.brogan@microsoft.com>
> Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
> ---
>  MdeModulePkg/Bus/Pci/EhciPei/EhciSched.c |  3 ++-
>  MdeModulePkg/Bus/Pci/EhciPei/EhciUrb.c   |  5 +++--
>  MdeModulePkg/Bus/Pci/EhciPei/EhcPeim.h   | 15 +--------------
>  3 files changed, 6 insertions(+), 17 deletions(-)
> 
> diff --git a/MdeModulePkg/Bus/Pci/EhciPei/EhciSched.c
> b/MdeModulePkg/Bus/Pci/EhciPei/EhciSched.c
> index 8eb432dfc31d..311f50198062 100644
> --- a/MdeModulePkg/Bus/Pci/EhciPei/EhciSched.c
> +++ b/MdeModulePkg/Bus/Pci/EhciPei/EhciSched.c
> @@ -3,6 +3,7 @@ PEIM to produce gPeiUsb2HostControllerPpiGuid based
> on gPeiUsbControllerPpiGuid  which is used to enable recovery function from
> USB Drivers.
> 
>  Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved.<BR>
> +Copyright (c) Microsoft Corporation.<BR>
> 
>  SPDX-License-Identifier: BSD-2-Clause-Patent
> 
> @@ -323,7 +324,7 @@ EhcCheckUrbResult (
>      goto ON_EXIT;
>    }
> 
> -  EFI_LIST_FOR_EACH (Entry, &Urb->Qh->Qtds) {
> +  BASE_LIST_FOR_EACH (Entry, &Urb->Qh->Qtds) {
>      Qtd   = EFI_LIST_CONTAINER (Entry, PEI_EHC_QTD, QtdList);
>      QtdHw = &Qtd->QtdHw;
>      State = (UINT8) QtdHw->Status;
> diff --git a/MdeModulePkg/Bus/Pci/EhciPei/EhciUrb.c
> b/MdeModulePkg/Bus/Pci/EhciPei/EhciUrb.c
> index 995ccd2463d2..df512ed6fa59 100644
> --- a/MdeModulePkg/Bus/Pci/EhciPei/EhciUrb.c
> +++ b/MdeModulePkg/Bus/Pci/EhciPei/EhciUrb.c
> @@ -3,6 +3,7 @@ PEIM to produce gPeiUsb2HostControllerPpiGuid based
> on gPeiUsbControllerPpiGuid  which is used to enable recovery function from
> USB Drivers.
> 
>  Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved.<BR>
> +Copyright (c) Microsoft Corporation.<BR>
> 
>  SPDX-License-Identifier: BSD-2-Clause-Patent
> 
> @@ -290,7 +291,7 @@ EhcFreeQtds (
>    EFI_LIST_ENTRY          *Next;
>    PEI_EHC_QTD             *Qtd;
> 
> -  EFI_LIST_FOR_EACH_SAFE (Entry, Next, Qtds) {
> +  BASE_LIST_FOR_EACH_SAFE (Entry, Next, Qtds) {
>      Qtd = EFI_LIST_CONTAINER (Entry, PEI_EHC_QTD, QtdList);
> 
>      RemoveEntryList (&Qtd->QtdList);
> @@ -461,7 +462,7 @@ EhcCreateQtds (
>    //
>    // OK, all the QTDs needed are created. Now, fix the NextQtd point
>    //
> -  EFI_LIST_FOR_EACH (Entry, &Qh->Qtds) {
> +  BASE_LIST_FOR_EACH (Entry, &Qh->Qtds) {
>      Qtd = EFI_LIST_CONTAINER (Entry, PEI_EHC_QTD, QtdList);
> 
>      //
> diff --git a/MdeModulePkg/Bus/Pci/EhciPei/EhcPeim.h
> b/MdeModulePkg/Bus/Pci/EhciPei/EhcPeim.h
> index 6b69f7a656ce..962cbc458986 100644
> --- a/MdeModulePkg/Bus/Pci/EhciPei/EhcPeim.h
> +++ b/MdeModulePkg/Bus/Pci/EhciPei/EhcPeim.h
> @@ -2,6 +2,7 @@
>  Private Header file for Usb Host Controller PEIM
> 
>  Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved.<BR>
> +Copyright (c) Microsoft Corporation.<BR>
> 
>  SPDX-License-Identifier: BSD-2-Clause-Patent
> 
> @@ -60,20 +61,6 @@ typedef struct _PEI_USB2_HC_DEV PEI_USB2_HC_DEV;
> //
>  #define EHC_SYNC_POLL_INTERVAL       (6 * EHC_1_MILLISECOND)
> 
> -//
> -//Iterate through the double linked list. NOT delete safe -//
> -#define EFI_LIST_FOR_EACH(Entry, ListHead)    \
> -  for(Entry = (ListHead)->ForwardLink; Entry != (ListHead); Entry = Entry-
> >ForwardLink)
> -
> -//
> -//Iterate through the double linked list. This is delete-safe.
> -//Don't touch NextEntry
> -//
> -#define EFI_LIST_FOR_EACH_SAFE(Entry, NextEntry, ListHead)            \
> -  for(Entry = (ListHead)->ForwardLink, NextEntry = Entry->ForwardLink;\
> -      Entry != (ListHead); Entry = NextEntry, NextEntry = Entry->ForwardLink)
> -
>  #define EFI_LIST_CONTAINER(Entry, Type, Field) BASE_CR(Entry, Type, Field)
> 
> 
> --
> 2.16.3.windows.1
> 
> 
> 


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

* Re: [edk2-devel] [PATCH v1 4/7] MdeModulePkg/XhciDxe: Use BaseLib linked list iteration macros
  2020-04-09 20:05 ` [PATCH v1 4/7] MdeModulePkg/XhciDxe: " Michael Kubacki
@ 2020-04-10  1:47   ` Guomin Jiang
  0 siblings, 0 replies; 12+ messages in thread
From: Guomin Jiang @ 2020-04-10  1:47 UTC (permalink / raw)
  To: devel@edk2.groups.io, michael.kubacki@outlook.com
  Cc: Bi, Dandan, Wu, Hao A, Wang, Jian J, Gao, Liming, Ni, Ray,
	Sean Brogan

Reviewed-by: Guomin Jiang <guomin.jiang@intel.com>

> -----Original Message-----
> From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Michael
> Kubacki
> Sent: Friday, April 10, 2020 4:05 AM
> To: devel@edk2.groups.io
> Cc: Bi, Dandan <dandan.bi@intel.com>; Wu, Hao A <hao.a.wu@intel.com>;
> Wang, Jian J <jian.j.wang@intel.com>; Gao, Liming <liming.gao@intel.com>;
> Ni, Ray <ray.ni@intel.com>; Sean Brogan <sean.brogan@microsoft.com>
> Subject: [edk2-devel] [PATCH v1 4/7] MdeModulePkg/XhciDxe: Use BaseLib
> linked list iteration macros
> 
> From: Michael Kubacki <michael.kubacki@microsoft.com>
> 
> REF:https://bugzilla.tianocore.org/show_bug.cgi?id=1959
> 
> Replaces usage of the linked list iteration macros defined in Xhci.h with the
> common definition in BaseLib.h.
> 
> Cc: Dandan Bi <dandan.bi@intel.com>
> Cc: Hao A Wu <hao.a.wu@intel.com>
> Cc: Jian J Wang <jian.j.wang@intel.com>
> Cc: Liming Gao <liming.gao@intel.com>
> Cc: Ray Ni <ray.ni@intel.com>
> Cc: Sean Brogan <sean.brogan@microsoft.com>
> Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
> ---
>  MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.c | 9 +++++----
>  MdeModulePkg/Bus/Pci/XhciDxe/Xhci.h      | 9 +--------
>  2 files changed, 6 insertions(+), 12 deletions(-)
> 
> diff --git a/MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.c
> b/MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.c
> index c0c374fc4758..ab8957c546ee 100644
> --- a/MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.c
> +++ b/MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.c
> @@ -3,6 +3,7 @@
>    XHCI transfer scheduling routines.
> 
>  Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>
> +Copyright (c) Microsoft Corporation.<BR>
>  SPDX-License-Identifier: BSD-2-Clause-Patent
> 
>  **/
> @@ -1051,7 +1052,7 @@ IsAsyncIntTrb (
>    LIST_ENTRY              *Next;
>    URB                     *CheckedUrb;
> 
> -  EFI_LIST_FOR_EACH_SAFE (Entry, Next, &Xhc->AsyncIntTransfers) {
> +  BASE_LIST_FOR_EACH_SAFE (Entry, Next, &Xhc->AsyncIntTransfers) {
>      CheckedUrb = EFI_LIST_CONTAINER (Entry, URB, UrbList);
>      if (IsTransferRingTrb (Xhc, Trb, CheckedUrb)) {
>        *Urb = CheckedUrb;
> @@ -1346,7 +1347,7 @@ XhciDelAsyncIntTransfer (
> 
>    Urb = NULL;
> 
> -  EFI_LIST_FOR_EACH_SAFE (Entry, Next, &Xhc->AsyncIntTransfers) {
> +  BASE_LIST_FOR_EACH_SAFE (Entry, Next, &Xhc->AsyncIntTransfers) {
>      Urb = EFI_LIST_CONTAINER (Entry, URB, UrbList);
>      if ((Urb->Ep.BusAddr == BusAddr) &&
>          (Urb->Ep.EpAddr == EpNum) &&
> @@ -1386,7 +1387,7 @@ XhciDelAllAsyncIntTransfers (
>    URB                     *Urb;
>    EFI_STATUS              Status;
> 
> -  EFI_LIST_FOR_EACH_SAFE (Entry, Next, &Xhc->AsyncIntTransfers) {
> +  BASE_LIST_FOR_EACH_SAFE (Entry, Next, &Xhc->AsyncIntTransfers) {
>      Urb = EFI_LIST_CONTAINER (Entry, URB, UrbList);
> 
>      //
> @@ -1578,7 +1579,7 @@ XhcMonitorAsyncRequests (
> 
>    Xhc    = (USB_XHCI_INSTANCE*) Context;
> 
> -  EFI_LIST_FOR_EACH_SAFE (Entry, Next, &Xhc->AsyncIntTransfers) {
> +  BASE_LIST_FOR_EACH_SAFE (Entry, Next, &Xhc->AsyncIntTransfers) {
>      Urb = EFI_LIST_CONTAINER (Entry, URB, UrbList);
> 
>      //
> diff --git a/MdeModulePkg/Bus/Pci/XhciDxe/Xhci.h
> b/MdeModulePkg/Bus/Pci/XhciDxe/Xhci.h
> index 72b4e084f14d..3285eb8798c0 100644
> --- a/MdeModulePkg/Bus/Pci/XhciDxe/Xhci.h
> +++ b/MdeModulePkg/Bus/Pci/XhciDxe/Xhci.h
> @@ -3,6 +3,7 @@
>    Provides some data structure definitions used by the XHCI host controller
> driver.
> 
>  Copyright (c) 2011 - 2017, Intel Corporation. All rights reserved.<BR>
> +Copyright (c) Microsoft Corporation.<BR>
>  SPDX-License-Identifier: BSD-2-Clause-Patent
> 
>  **/
> @@ -82,14 +83,6 @@ typedef struct _USB_DEV_CONTEXT
> USB_DEV_CONTEXT;
>  #define INT_INTER                    3
>  #define INT_INTER_ASYNC              4
> 
> -//
> -// Iterate through the double linked list. This is delete-safe.
> -// Don't touch NextEntry
> -//
> -#define EFI_LIST_FOR_EACH_SAFE(Entry, NextEntry, ListHead) \
> -  for (Entry = (ListHead)->ForwardLink, NextEntry = Entry->ForwardLink;\
> -      Entry != (ListHead); Entry = NextEntry, NextEntry = Entry->ForwardLink)
> -
>  #define EFI_LIST_CONTAINER(Entry, Type, Field) BASE_CR(Entry, Type, Field)
> 
>  #define XHC_LOW_32BIT(Addr64)          ((UINT32)(((UINTN)(Addr64)) &
> 0xFFFFFFFF))
> --
> 2.16.3.windows.1
> 
> 
> 


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

end of thread, other threads:[~2020-04-10  1:47 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20200409200514.32796-1-michael.kubacki@outlook.com>
2020-04-09 20:05 ` [PATCH v1 1/7] MdePkg/BaseLib: Add linked list iteration macros Michael Kubacki
2020-04-10  1:45   ` [edk2-devel] " Guomin Jiang
2020-04-09 20:05 ` [PATCH v1 2/7] MdeModulePkg/EhciDxe: Use BaseLib " Michael Kubacki
2020-04-10  1:46   ` [edk2-devel] " Guomin Jiang
2020-04-09 20:05 ` [PATCH v1 3/7] MdeModulePkg/EhciPei: " Michael Kubacki
2020-04-10  1:47   ` [edk2-devel] " Guomin Jiang
2020-04-09 20:05 ` [PATCH v1 4/7] MdeModulePkg/XhciDxe: " Michael Kubacki
2020-04-10  1:47   ` [edk2-devel] " Guomin Jiang
2020-04-09 20:05 ` [PATCH v1 5/7] MdeModulePkg/UfsPassThruDxe: " Michael Kubacki
2020-04-09 20:05 ` [PATCH v1 6/7] MdeModulePkg/RamDiskDxe: " Michael Kubacki
2020-04-09 20:05 ` [PATCH v1 7/7] SecurityPkg/HddPassword: " Michael Kubacki
2020-04-09 23:10   ` Yao, Jiewen

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