]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Add PcdVerifyNoteInList for judge whether do verification of node in list in debug...
authorklu2 <klu2@6f19259b-4bc3-4df7-8a09-765794883524>
Tue, 28 Jul 2009 02:38:30 +0000 (02:38 +0000)
committerklu2 <klu2@6f19259b-4bc3-4df7-8a09-765794883524>
Tue, 28 Jul 2009 02:38:30 +0000 (02:38 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@9016 6f19259b-4bc3-4df7-8a09-765794883524

MdePkg/Include/Library/BaseLib.h
MdePkg/Library/BaseLib/BaseLib.inf
MdePkg/Library/BaseLib/LinkedList.c
MdePkg/MdePkg.dec

index 25d61f1448db44fc0569e7b75d5eef5ccff06a32..202d2c3f55378d963cc4fd1839aedbb6e06ee54c 100644 (file)
@@ -1357,7 +1357,7 @@ GetFirstNode (
   InitializeListHead(), then ASSERT().\r
   If PcdMaximumLinkedListLenth is not zero, and List contains more than\r
   PcdMaximumLinkedListLenth nodes, then ASSERT().\r
-  If Node is not a node in List, then ASSERT().\r
+  If PcdVerifyNodeInList is TRUE and Node is not a node in List, then ASSERT().\r
 \r
   @param  List  A pointer to the head node of a doubly linked list.\r
   @param  Node  A pointer to a node in the doubly linked list.\r
@@ -1416,7 +1416,8 @@ IsListEmpty (
   If PcdMaximumLinkedListLenth is not zero, and the number of nodes\r
   in List, including the List node, is greater than or equal to\r
   PcdMaximumLinkedListLength, then ASSERT().\r
-  If Node is not a node in List and Node is not equal to List, then ASSERT().\r
+  If PcdVerifyNodeInList is TRUE and Node is not a node in List the and Node is not equal \r
+  to List, then ASSERT().\r
 \r
   @param  List  A pointer to the head node of a doubly linked list.\r
   @param  Node  A pointer to a node in the doubly linked list.\r
@@ -1447,7 +1448,7 @@ IsNull (
   If PcdMaximumLinkedListLenth is not zero, and the number of nodes\r
   in List, including the List node, is greater than or equal to\r
   PcdMaximumLinkedListLength, then ASSERT().\r
-  If Node is not a node in List, then ASSERT().\r
+  If PcdVerifyNodeInList is TRUE and Node is not a node in List, then ASSERT().\r
 \r
   @param  List  A pointer to the head node of a doubly linked list.\r
   @param  Node  A pointer to a node in the doubly linked list.\r
@@ -1477,7 +1478,8 @@ IsNodeAtEnd (
 \r
   If FirstEntry is NULL, then ASSERT().\r
   If SecondEntry is NULL, then ASSERT().\r
-  If SecondEntry and FirstEntry are not in the same linked list, then ASSERT().\r
+  If PcdVerifyNodeInList is TRUE and SecondEntry and FirstEntry are not in the \r
+  same linked list, then ASSERT().\r
   If PcdMaximumLinkedListLength is not zero, and the number of nodes in the\r
   linked list containing the FirstEntry and SecondEntry nodes, including\r
   the FirstEntry and SecondEntry nodes, is greater than or equal to\r
index e60b9b794b9db22d7c5d6a779eb3bbc5210a8d7c..1cadb67adf91117cff9f06b6d71e1e695b10582f 100644 (file)
   DebugLib\r
   BaseMemoryLib\r
 \r
-[Pcd.common]\r
+[Pcd]\r
   gEfiMdePkgTokenSpaceGuid.PcdMaximumLinkedListLength\r
   gEfiMdePkgTokenSpaceGuid.PcdMaximumAsciiStringLength\r
   gEfiMdePkgTokenSpaceGuid.PcdMaximumUnicodeStringLength\r
-\r
+  gEfiMdePkgTokenSpaceGuid.PcdVerifyNodeInList\r
index 62b6c364783afc137f21098c7808f8c978a49839..3ff582a978c706276d3c540ea560517a8c21bb7e 100644 (file)
   If List is NULL, then ASSERT().\r
   If List->ForwardLink is NULL, then ASSERT().\r
   If List->backLink is NULL, then ASSERT().\r
-  If Node is NULL, then ASSERT();\r
-  If PcdMaximumLinkedListLenth is not zero, and prior to insertion the number\r
-  of nodes in ListHead, including the ListHead node, is greater than or\r
-  equal to PcdMaximumLinkedListLength, then ASSERT().\r
+  If Node is NULL, then ASSERT().\r
+  If PcdVerifyNodeInList is TRUE and DoMembershipCheck is TRUE and Node \r
+  is in not a member of List, then return FALSE\r
+  If PcdMaximumLinkedListLenth is not zero, and List contains more than\r
+  PcdMaximumLinkedListLenth nodes, then ASSERT().\r
 \r
-  @param  List  A pointer to a node in a linked list.\r
-  @param  Node  A pointer to one nod.\r
+  @param  List              A pointer to a node in a linked list.\r
+  @param  Node              A pointer to a node in a linked list.\r
+  @param  VerifyNodeInList  TRUE if a check should be made to see if Node is a \r
+                            member of List.  FALSE if no membership test should \r
+                            be performed.\r
 \r
-  @retval TRUE   Node is in List\r
-  @retval FALSE  Node isn't in List, or List is invalid\r
+  @retval   TRUE if PcdVerifyNodeInList is FALSE\r
+  @retval   TRUE if DoMembershipCheck is FALSE\r
+  @retval   TRUE if PcdVerifyNodeInList is TRUE and DoMembershipCheck is TRUE \r
+            and Node is a member of List.\r
+  @retval   FALSE if PcdVerifyNodeInList is TRUE and DoMembershipCheck is TRUE \r
+            and Node is in not a member of List.\r
 \r
 **/\r
 BOOLEAN\r
 EFIAPI\r
 InternalBaseLibIsNodeInList (\r
-  IN      CONST LIST_ENTRY      *List,\r
-  IN      CONST LIST_ENTRY      *Node\r
+  IN CONST LIST_ENTRY  *List,\r
+  IN CONST LIST_ENTRY  *Node,\r
+  IN BOOLEAN           VerifyNodeInList\r
   )\r
 {\r
-  UINTN                         Count;\r
-  CONST LIST_ENTRY              *Ptr;\r
-  BOOLEAN                       Found;\r
+  UINTN             Count;\r
+  CONST LIST_ENTRY  *Ptr;\r
 \r
   //\r
   // Test the validity of List and Node\r
@@ -54,24 +62,54 @@ InternalBaseLibIsNodeInList (
   ASSERT (List->BackLink != NULL);\r
   ASSERT (Node != NULL);\r
 \r
-  Count = PcdGet32 (PcdMaximumLinkedListLength);\r
+  Count = 0;\r
+  Ptr   = List;\r
 \r
-  Ptr = List;\r
-  do {\r
-    Ptr = Ptr->ForwardLink;\r
-    Count--;\r
-  } while ((Ptr != List) && (Ptr != Node) && (Count > 0));\r
-  Found = (BOOLEAN)(Ptr == Node);\r
+  if (FeaturePcdGet (PcdVerifyNodeInList) && VerifyNodeInList) {\r
+    //\r
+    // Check to see if Node is a member of List.  \r
+    // Exit early if the number of nodes in List >= PcdMaximumLinkedListLength\r
+    //\r
+    do {\r
+      Ptr = Ptr->ForwardLink;\r
+      if (PcdGet32 (PcdMaximumLinkedListLength) > 0) {\r
+        Count++;\r
+        //\r
+        // ASSERT() if the linked list is too long\r
+        //\r
+        ASSERT (Count < PcdGet32 (PcdMaximumLinkedListLength));\r
+\r
+        //\r
+        // Return if the linked list is too long\r
+        //\r
+        if (Count >= PcdGet32 (PcdMaximumLinkedListLength)) {\r
+          return (BOOLEAN)(Ptr == Node);\r
+        }\r
+      }\r
+    } while ((Ptr != List) && (Ptr != Node)); \r
+\r
+    if (Ptr != Node) {\r
+      return FALSE;\r
+    }\r
+  }\r
 \r
   if (PcdGet32 (PcdMaximumLinkedListLength) > 0) {\r
-    while ((Count > 0) && (Ptr != List)) {\r
+    //\r
+    // Count the total number of nodes in List.\r
+    // Exit early if the number of nodes in List >= PcdMaximumLinkedListLength\r
+    //\r
+    do {\r
       Ptr = Ptr->ForwardLink;\r
-      Count--;\r
-    }\r
-    ASSERT (Count > 0);\r
+      Count++;\r
+    } while ((Ptr != List) && (Count < PcdGet32 (PcdMaximumLinkedListLength)));\r
+\r
+    //\r
+    // ASSERT() if the linked list is too long\r
+    //\r
+    ASSERT (Count < PcdGet32 (PcdMaximumLinkedListLength));\r
   }\r
 \r
-  return Found;\r
+  return TRUE;\r
 }\r
 \r
 /**\r
@@ -136,8 +174,8 @@ InsertHeadList (
   //\r
   // ASSERT List not too long and Entry is not one of the nodes of List\r
   //\r
-  ASSERT (!InternalBaseLibIsNodeInList (ListHead, Entry));\r
-\r
+  ASSERT (InternalBaseLibIsNodeInList (ListHead, Entry, FALSE));\r
+  \r
   Entry->ForwardLink = ListHead->ForwardLink;\r
   Entry->BackLink = ListHead;\r
   Entry->ForwardLink->BackLink = Entry;\r
@@ -177,8 +215,8 @@ InsertTailList (
   //\r
   // ASSERT List not too long and Entry is not one of the nodes of List\r
   //\r
-  ASSERT (!InternalBaseLibIsNodeInList (ListHead, Entry));\r
-\r
+  ASSERT (InternalBaseLibIsNodeInList (ListHead, Entry, FALSE));\r
+  \r
   Entry->ForwardLink = ListHead;\r
   Entry->BackLink = ListHead->BackLink;\r
   Entry->BackLink->ForwardLink = Entry;\r
@@ -215,7 +253,7 @@ GetFirstNode (
   //\r
   // ASSERT List not too long\r
   //\r
-  ASSERT (InternalBaseLibIsNodeInList (List, List));\r
+  ASSERT (InternalBaseLibIsNodeInList (List, List, FALSE));\r
 \r
   return List->ForwardLink;\r
 }\r
@@ -233,7 +271,7 @@ GetFirstNode (
   InitializeListHead(), then ASSERT().\r
   If PcdMaximumLinkedListLenth is not zero, and List contains more than\r
   PcdMaximumLinkedListLenth nodes, then ASSERT().\r
-  If Node is not a node in List, then ASSERT().\r
+  If PcdVerifyNodeInList is TRUE and Node is not a node in List, then ASSERT().\r
 \r
   @param  List  A pointer to the head node of a doubly linked list.\r
   @param  Node  A pointer to a node in the doubly linked list.\r
@@ -252,7 +290,7 @@ GetNextNode (
   //\r
   // ASSERT List not too long and Node is one of the nodes of List\r
   //\r
-  ASSERT (InternalBaseLibIsNodeInList (List, Node));\r
+  ASSERT (InternalBaseLibIsNodeInList (List, Node, TRUE));\r
 \r
   return Node->ForwardLink;\r
 }\r
@@ -285,8 +323,8 @@ IsListEmpty (
   //\r
   // ASSERT List not too long\r
   //\r
-  ASSERT (InternalBaseLibIsNodeInList (ListHead, ListHead));\r
-\r
+  ASSERT (InternalBaseLibIsNodeInList (ListHead, ListHead, FALSE));\r
+  \r
   return (BOOLEAN)(ListHead->ForwardLink == ListHead);\r
 }\r
 \r
@@ -306,7 +344,8 @@ IsListEmpty (
   If PcdMaximumLinkedListLenth is not zero, and the number of nodes\r
   in List, including the List node, is greater than or equal to\r
   PcdMaximumLinkedListLength, then ASSERT().\r
-  If Node is not a node in List and Node is not equal to List, then ASSERT().\r
+  If PcdVerifyNodeInList is TRUE and Node is not a node in List and Node is not \r
+  equal to List, then ASSERT().\r
 \r
   @param  List  A pointer to the head node of a doubly linked list.\r
   @param  Node  A pointer to a node in the doubly linked list.\r
@@ -325,8 +364,8 @@ IsNull (
   //\r
   // ASSERT List not too long and Node is one of the nodes of List\r
   //\r
-  ASSERT (InternalBaseLibIsNodeInList (List, Node));\r
-\r
+  ASSERT (InternalBaseLibIsNodeInList (List, Node, TRUE));\r
+  \r
   return (BOOLEAN)(Node == List);\r
 }\r
 \r
@@ -344,7 +383,7 @@ IsNull (
   If PcdMaximumLinkedListLenth is not zero, and the number of nodes\r
   in List, including the List node, is greater than or equal to\r
   PcdMaximumLinkedListLength, then ASSERT().\r
-  If Node is not a node in List, then ASSERT().\r
+  If PcdVerifyNodeInList is TRUE and Node is not a node in List, then ASSERT().\r
 \r
   @param  List  A pointer to the head node of a doubly linked list.\r
   @param  Node  A pointer to a node in the doubly linked list.\r
@@ -363,8 +402,8 @@ IsNodeAtEnd (
   //\r
   // ASSERT List not too long and Node is one of the nodes of List\r
   //\r
-  ASSERT (InternalBaseLibIsNodeInList (List, Node));\r
-\r
+  ASSERT (InternalBaseLibIsNodeInList (List, Node, TRUE));\r
+  \r
   return (BOOLEAN)(!IsNull (List, Node) && List->BackLink == Node);\r
 }\r
 \r
@@ -381,7 +420,8 @@ IsNodeAtEnd (
 \r
   If FirstEntry is NULL, then ASSERT().\r
   If SecondEntry is NULL, then ASSERT().\r
-  If SecondEntry and FirstEntry are not in the same linked list, then ASSERT().\r
+  If PcdVerifyNodeInList is TRUE and SecondEntry and FirstEntry are not in the \r
+  same linked list, then ASSERT().\r
   If PcdMaximumLinkedListLength is not zero, and the number of nodes in the\r
   linked list containing the FirstEntry and SecondEntry nodes, including\r
   the FirstEntry and SecondEntry nodes, is greater than or equal to\r
@@ -409,8 +449,8 @@ SwapListEntries (
   //\r
   // ASSERT Entry1 and Entry2 are in the same linked list\r
   //\r
-  ASSERT (InternalBaseLibIsNodeInList (FirstEntry, SecondEntry));\r
-\r
+  ASSERT (InternalBaseLibIsNodeInList (FirstEntry, SecondEntry, TRUE));\r
+  \r
   //\r
   // Ptr is the node pointed to by FirstEntry->ForwardLink\r
   //\r
@@ -468,7 +508,7 @@ RemoveEntryList (
   )\r
 {\r
   ASSERT (!IsListEmpty (Entry));\r
-\r
+  \r
   Entry->ForwardLink->BackLink = Entry->BackLink;\r
   Entry->BackLink->ForwardLink = Entry->ForwardLink;\r
   return Entry->ForwardLink;\r
index a143f9d3019f5ed4538ce3fa6b7dca14c13c1897..8c276322525391085394e491e0f6acd1185d2414 100644 (file)
   gEfiMdePkgTokenSpaceGuid.PcdUefiVariableDefaultLangDeprecate|FALSE|BOOLEAN|0x00000012\r
 \r
   ## If TRUE, UGA Draw Protocol is still consumed.\r
-  gEfiMdePkgTokenSpaceGuid.PcdUgaConsumeSupport|TRUE|BOOLEAN|0x00000013\r
+  gEfiMdePkgTokenSpaceGuid.PcdUgaConsumeSupport|TRUE|BOOLEAN|0x00000027\r
+\r
+  ## If TRUE, a check will be made to see if a specified node is a member of  linked list\r
+  #  in the following BaseLib fucntions: GetNextNode(), IsNull(), IsNodeAtEnd(), \r
+  #  SwapListEntries()\r
+  gEfiMdePkgTokenSpaceGuid.PcdVerifyNodeInList|FALSE|BOOLEAN|0x00000028\r
 \r
 [PcdsFixedAtBuild]\r
   ## Indicates the maximum length of unicode string\r