]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Fix the issues that StatusCode can't work when PcdStatusCodeUseMemory is set to TRUE...
authorlgao4 <lgao4@6f19259b-4bc3-4df7-8a09-765794883524>
Mon, 5 Jul 2010 09:01:39 +0000 (09:01 +0000)
committerlgao4 <lgao4@6f19259b-4bc3-4df7-8a09-765794883524>
Mon, 5 Jul 2010 09:01:39 +0000 (09:01 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@10631 6f19259b-4bc3-4df7-8a09-765794883524

IntelFrameworkModulePkg/Universal/StatusCode/Pei/MemoryStausCodeWorker.c
IntelFrameworkModulePkg/Universal/StatusCode/RuntimeDxe/DataHubStatusCodeWorker.c
IntelFrameworkModulePkg/Universal/StatusCode/RuntimeDxe/StatusCodeRuntimeDxe.c

index e767e6b147d2469890e4c2e9b818165542c3d561..f0b36f23a20ddfce066ff9916eb39a633554ea8f 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   PEI memory status code worker.\r
 \r
-  Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
   which accompanies this distribution.  The full text of the license may be found at\r
 #include "StatusCodePei.h"\r
 \r
 /**\r
-  Worker function to create one memory status code GUID'ed HOB,\r
-  using PacketIndex to identify the packet.\r
-\r
-  @param   PacketIndex    Index of records packet.\r
+  Create the first memory status code GUID'ed HOB as initialization for memory status code worker.\r
 \r
-  @return  Pointer to the memory status code packet.\r
+  @retval EFI_SUCCESS  The GUID'ed HOB is created successfully.\r
 \r
 **/\r
-MEMORY_STATUSCODE_PACKET_HEADER *\r
-CreateMemoryStatusCodePacket (\r
-  UINT16 PacketIndex\r
+EFI_STATUS\r
+MemoryStatusCodeInitializeWorker (\r
+  VOID\r
   )\r
 {\r
+  //\r
+  // Create memory status code GUID'ed HOB.\r
+  //\r
   MEMORY_STATUSCODE_PACKET_HEADER *PacketHeader;\r
 \r
   //\r
@@ -40,28 +40,9 @@ CreateMemoryStatusCodePacket (
   ASSERT (PacketHeader != NULL);\r
 \r
   PacketHeader->MaxRecordsNumber = (PcdGet16 (PcdStatusCodeMemorySize) * 1024) / sizeof (MEMORY_STATUSCODE_RECORD);\r
-  PacketHeader->PacketIndex      = PacketIndex;\r
+  PacketHeader->PacketIndex      = 0;\r
   PacketHeader->RecordIndex      = 0;\r
 \r
-  return PacketHeader;\r
-}\r
-\r
-/**\r
-  Create the first memory status code GUID'ed HOB as initialization for memory status code worker.\r
-\r
-  @retval EFI_SUCCESS  The GUID'ed HOB is created successfully.\r
-\r
-**/\r
-EFI_STATUS\r
-MemoryStatusCodeInitializeWorker (\r
-  VOID\r
-  )\r
-{\r
-  //\r
-  // Create first memory status code GUID'ed HOB.\r
-  //\r
-  CreateMemoryStatusCodePacket (0);\r
-\r
   return EFI_SUCCESS;\r
 }\r
 \r
@@ -98,49 +79,40 @@ MemoryStatusCodeReportWorker (
   EFI_PEI_HOB_POINTERS              Hob;\r
   MEMORY_STATUSCODE_PACKET_HEADER   *PacketHeader;\r
   MEMORY_STATUSCODE_RECORD          *Record;\r
-  UINT16                            PacketIndex;\r
-\r
-  Record      = NULL;\r
-  PacketIndex = 0;\r
 \r
   //\r
-  // Journal GUID'ed HOBs to find empty record entry. if found, then save status code in it.\r
-  // otherwise, create a new GUID'ed HOB.\r
+  // Find GUID'ed HOBs to locate current record buffer. \r
   //\r
   Hob.Raw = GetFirstGuidHob (&gMemoryStatusCodeRecordGuid);\r
-  while (Hob.Raw != NULL) {\r
-    PacketHeader = (MEMORY_STATUSCODE_PACKET_HEADER *) GET_GUID_HOB_DATA (Hob.Guid);\r
+  ASSERT (Hob.Raw != NULL);\r
 \r
-    //\r
-    // Check whether pccket is full or not.\r
-    //\r
-    if (PacketHeader->RecordIndex < PacketHeader->MaxRecordsNumber) {\r
-      Record = (MEMORY_STATUSCODE_RECORD *) (PacketHeader + 1);\r
-      Record = &Record[PacketHeader->RecordIndex++];\r
-      break;\r
-    }\r
-    //\r
-    // Cache number of found packet in PacketIndex.\r
-    //\r
-    PacketIndex++;\r
+  PacketHeader = (MEMORY_STATUSCODE_PACKET_HEADER *) GET_GUID_HOB_DATA (Hob.Guid);\r
+  Record = (MEMORY_STATUSCODE_RECORD *) (PacketHeader + 1);\r
+  Record = &Record[PacketHeader->RecordIndex++];\r
 \r
-    Hob.Raw = GetNextGuidHob (&gMemoryStatusCodeRecordGuid, Hob.Raw);\r
-  }\r
+  //\r
+  // Save status code.\r
+  //\r
+  Record->CodeType = CodeType;\r
+  Record->Instance = Instance;\r
+  Record->Value    = Value;\r
 \r
-  if (Record == NULL) {\r
+  //\r
+  // If record index equals to max record number, then wrap around record index to zero.\r
+  //\r
+  // The reader of status code should compare the number of records with max records number,\r
+  // If it is equal to or larger than the max number, then the wrap-around had happened,\r
+  // so the first record is pointed by record index.\r
+  // If it is less then max number, index of the first record is zero.\r
+  //\r
+  if (PacketHeader->RecordIndex == PacketHeader->MaxRecordsNumber) {\r
     //\r
-    // No available entry found, so create new packet.\r
+    // Wrap around record index.\r
     //\r
-    PacketHeader = CreateMemoryStatusCodePacket (PacketIndex);\r
-\r
-    Record = (MEMORY_STATUSCODE_RECORD *) (PacketHeader + 1);\r
-    Record = &Record[PacketHeader->RecordIndex++];\r
+    PacketHeader->RecordIndex = 0;\r
+    PacketHeader->PacketIndex ++;\r
   }\r
 \r
-  Record->CodeType = CodeType;\r
-  Record->Instance = Instance;\r
-  Record->Value    = Value;\r
-\r
   return EFI_SUCCESS;\r
 }\r
 \r
index 5c1616e14bf08cbd965506239dd11fdc4ffe02b2..ffee2f9c2acaafebf8c7ea690a940e94233e74c2 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Data Hub status code worker.\r
 \r
-  Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
   which accompanies this distribution.  The full text of the license may be found at\r
@@ -24,7 +24,7 @@ EFI_EVENT                 mLogDataHubEvent;
 //\r
 // Cache data hub protocol.\r
 //\r
-EFI_DATA_HUB_PROTOCOL     *mDataHubProtocol;\r
+EFI_DATA_HUB_PROTOCOL     *mDataHubProtocol = NULL;\r
 \r
 \r
 /**\r
@@ -189,6 +189,7 @@ DataHubStatusCodeReportWorker (
   BASE_LIST                         Marker;\r
   CHAR8                             *Format;\r
   UINTN                             CharCount;\r
+  EFI_STATUS                        Status;\r
 \r
   //\r
   // Use atom operation to avoid the reentant of report.\r
@@ -205,6 +206,13 @@ DataHubStatusCodeReportWorker (
     return EFI_DEVICE_ERROR;\r
   }\r
 \r
+  if (mDataHubProtocol == NULL) {\r
+    Status = DataHubStatusCodeInitializeWorker ();\r
+    if (EFI_ERROR (Status)) {\r
+      return Status;\r
+    }\r
+  }\r
+  \r
   Record = AcquireRecordBuffer ();\r
   if (Record == NULL) {\r
     //\r
@@ -358,7 +366,10 @@ DataHubStatusCodeInitializeWorker (
                   NULL, \r
                   (VOID **) &mDataHubProtocol\r
                   );\r
-  ASSERT_EFI_ERROR (Status);\r
+  if (EFI_ERROR (Status)) {\r
+    mDataHubProtocol = NULL;\r
+    return Status;\r
+  }\r
 \r
   //\r
   // Create a Notify Event to log data in Data Hub\r
index cb2c271124469dd2d45ad68e0fe0223eadcbe825..6435e1f727d0dcefd4e7ce7559436f26316ad6a9 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Status code driver for IA32/X64/EBC architecture.\r
 \r
-  Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
   which accompanies this distribution.  The full text of the license may be found at\r
@@ -205,9 +205,8 @@ InitializationDispatcherWorker (
   EFI_STATUS                        Status;\r
   MEMORY_STATUSCODE_PACKET_HEADER   *PacketHeader;\r
   MEMORY_STATUSCODE_RECORD          *Record;\r
-  UINTN                             ExpectedPacketIndex;\r
   UINTN                             Index;\r
-  VOID                              *HobStart;\r
+  UINTN                             MaxRecordNumber;\r
 \r
   //\r
   // If enable UseSerial, then initialize serial port.\r
@@ -226,8 +225,7 @@ InitializationDispatcherWorker (
     ASSERT_EFI_ERROR (Status);\r
   }\r
   if (FeaturePcdGet (PcdStatusCodeUseDataHub)) {\r
-    Status = DataHubStatusCodeInitializeWorker ();\r
-    ASSERT_EFI_ERROR (Status);\r
+    DataHubStatusCodeInitializeWorker ();\r
   }\r
   if (FeaturePcdGet (PcdStatusCodeUseOEM)) {\r
     //\r
@@ -245,73 +243,59 @@ InitializationDispatcherWorker (
     // Journal GUID'ed HOBs to find all record entry, if found, \r
     // then output record to support replay device.\r
     //\r
-    ExpectedPacketIndex = 0;\r
     Hob.Raw   = GetFirstGuidHob (&gMemoryStatusCodeRecordGuid);\r
-    HobStart  = Hob.Raw;\r
-    while (Hob.Raw != NULL) {\r
+    if (Hob.Raw != NULL) {\r
       PacketHeader = (MEMORY_STATUSCODE_PACKET_HEADER *) GET_GUID_HOB_DATA (Hob.Guid);\r
-      if (PacketHeader->PacketIndex == ExpectedPacketIndex) {\r
-        Record = (MEMORY_STATUSCODE_RECORD *) (PacketHeader + 1);\r
-        for (Index = 0; Index < PacketHeader->RecordIndex; Index++) {\r
-          //\r
-          // Dispatch records to devices based on feature flag.\r
-          //\r
-          if (FeaturePcdGet (PcdStatusCodeUseSerial)) {\r
-            SerialStatusCodeReportWorker (\r
-              Record[Index].CodeType,\r
-              Record[Index].Value,\r
-              Record[Index].Instance,\r
-              NULL,\r
-              NULL\r
-              );\r
-          }\r
-          if (FeaturePcdGet (PcdStatusCodeUseMemory)) {\r
-            RtMemoryStatusCodeReportWorker (\r
-              Record[Index].CodeType,\r
-              Record[Index].Value,\r
-              Record[Index].Instance\r
-              );\r
-          }\r
-          if (FeaturePcdGet (PcdStatusCodeUseDataHub)) {\r
-            DataHubStatusCodeReportWorker (\r
-              Record[Index].CodeType,\r
-              Record[Index].Value,\r
-              Record[Index].Instance,\r
-              NULL,\r
-              NULL\r
-              );\r
-          }\r
-          if (FeaturePcdGet (PcdStatusCodeUseOEM)) {\r
-            //\r
-            // Call OEM hook status code library API to report status code to OEM device\r
-            //\r
-            OemHookStatusCodeReport (\r
-              Record[Index].CodeType,\r
-              Record[Index].Value,\r
-              Record[Index].Instance,\r
-              NULL,\r
-              NULL\r
-              );\r
-          }\r
-        }\r
-        ExpectedPacketIndex++;\r
-  \r
+      Record = (MEMORY_STATUSCODE_RECORD *) (PacketHeader + 1);\r
+      MaxRecordNumber = (UINTN) PacketHeader->RecordIndex;\r
+      if (PacketHeader->PacketIndex > 0) {\r
         //\r
-        // See whether there is gap of packet or not\r
+        // Record has been wrapped around. So, record number has arrived at max number.\r
         //\r
-        if (HobStart != NULL) {\r
-          HobStart  = NULL;\r
-          Hob.Raw   = HobStart;\r
-          continue;\r
-        }\r
-      } else if (HobStart != NULL) {\r
+        MaxRecordNumber = (UINTN) PacketHeader->MaxRecordsNumber;\r
+      }\r
+      for (Index = 0; Index < MaxRecordNumber; Index++) {\r
         //\r
-        // Cache the found packet for improve the performance\r
+        // Dispatch records to devices based on feature flag.\r
         //\r
-        HobStart = Hob.Raw;\r
+        if (FeaturePcdGet (PcdStatusCodeUseSerial)) {\r
+          SerialStatusCodeReportWorker (\r
+            Record[Index].CodeType,\r
+            Record[Index].Value,\r
+            Record[Index].Instance,\r
+            NULL,\r
+            NULL\r
+            );\r
+        }\r
+        if (FeaturePcdGet (PcdStatusCodeUseMemory)) {\r
+          RtMemoryStatusCodeReportWorker (\r
+            Record[Index].CodeType,\r
+            Record[Index].Value,\r
+            Record[Index].Instance\r
+            );\r
+        }\r
+        if (FeaturePcdGet (PcdStatusCodeUseDataHub)) {\r
+          DataHubStatusCodeReportWorker (\r
+            Record[Index].CodeType,\r
+            Record[Index].Value,\r
+            Record[Index].Instance,\r
+            NULL,\r
+            NULL\r
+            );\r
+        }\r
+        if (FeaturePcdGet (PcdStatusCodeUseOEM)) {\r
+          //\r
+          // Call OEM hook status code library API to report status code to OEM device\r
+          //\r
+          OemHookStatusCodeReport (\r
+            Record[Index].CodeType,\r
+            Record[Index].Value,\r
+            Record[Index].Instance,\r
+            NULL,\r
+            NULL\r
+            );\r
+        }\r
       }\r
-  \r
-      Hob.Raw = GetNextGuidHob (&gMemoryStatusCodeRecordGuid, Hob.Raw);\r
     }\r
   }\r
 }\r