]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Code Scrub for Status Code Runtime Dxe driver.
authorxli24 <xli24@6f19259b-4bc3-4df7-8a09-765794883524>
Mon, 27 Apr 2009 06:14:50 +0000 (06:14 +0000)
committerxli24 <xli24@6f19259b-4bc3-4df7-8a09-765794883524>
Mon, 27 Apr 2009 06:14:50 +0000 (06:14 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@8178 6f19259b-4bc3-4df7-8a09-765794883524

IntelFrameworkModulePkg/Universal/StatusCode/Dxe/DataHubStatusCodeWorker.c
IntelFrameworkModulePkg/Universal/StatusCode/Dxe/DxeStatusCode.c
IntelFrameworkModulePkg/Universal/StatusCode/Dxe/DxeStatusCode.h
IntelFrameworkModulePkg/Universal/StatusCode/Dxe/DxeStatusCode.inf
IntelFrameworkModulePkg/Universal/StatusCode/Dxe/DxeStatusCodeCommon.c
IntelFrameworkModulePkg/Universal/StatusCode/Dxe/RtMemoryStatusCodeWorker.c
IntelFrameworkModulePkg/Universal/StatusCode/Dxe/SerialStatusCodeWorker.c

index 3cf5088fdfc561178f89e5a28f83dac885ece699..e55113cdbfbdaff2029c45f3a34158205ea90f5f 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
-  Data Hub status code worker in DXE.\r
+  Data Hub status code worker.\r
 \r
-  Copyright (c) 2006, Intel Corporation\r
+  Copyright (c) 2006 - 2009, Intel Corporation\r
   All rights reserved. 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
@@ -28,12 +28,14 @@ EFI_DATA_HUB_PROTOCOL     *mDataHubProtocol;
 \r
 \r
 /**\r
-  Return one DATAHUB_STATUSCODE_RECORD space.\r
-  The size of free record pool would be extend, if the pool is empty.\r
+  Retrieve one record of from free record buffer. This record is removed from\r
+  free record buffer.\r
 \r
+  This function retrieves one record from free record buffer.\r
+  If the pool has been exhausted, then new memory would be allocated for it.\r
 \r
-  @retval  NULL   Can not allocate free memeory for record.\r
-  @retval  !NULL  Point to buffer of record.\r
+  @return  Pointer to the free record.\r
+           NULL means failure to allocate new memeory for free record buffer.\r
 \r
 **/\r
 DATA_HUB_STATUS_CODE_DATA_RECORD *\r
@@ -49,6 +51,9 @@ AcquireRecordBuffer (
   CurrentTpl = gBS->RaiseTPL (TPL_HIGH_LEVEL);\r
 \r
   if (!IsListEmpty (&mRecordsBuffer)) {\r
+    //\r
+    // Strip one entry from free record buffer.\r
+    //\r
     Node = GetFirstNode (&mRecordsBuffer);\r
     RemoveEntryList (Node);\r
 \r
@@ -62,13 +67,20 @@ AcquireRecordBuffer (
       return NULL;\r
     }\r
 \r
+    //\r
+    // If free record buffer is exhausted, then allocate 16 new records for it.\r
+    //\r
     gBS->RestoreTPL (CurrentTpl);\r
     Record   = (DATAHUB_STATUSCODE_RECORD *) AllocateZeroPool (sizeof (DATAHUB_STATUSCODE_RECORD) * 16);\r
-    if (NULL == Record) {\r
+    if (Record == NULL) {\r
       return NULL;\r
     }\r
 \r
     CurrentTpl = gBS->RaiseTPL (TPL_HIGH_LEVEL);\r
+    //\r
+    // Here we only insert 15 new records to the free record buffer, for the first record\r
+    // will be returned immediately.\r
+    //\r
     for (Index = 1; Index < 16; Index++) {\r
       InsertTailList (&mRecordsBuffer, &Record[Index].Node);\r
     }\r
@@ -84,11 +96,10 @@ AcquireRecordBuffer (
 \r
 \r
 /**\r
-  Retrieve one record from Records FIFO. The record would be removed from FIFO and\r
-  release to free record buffer.\r
+  Retrieve one record from Records FIFO. The record would be removed from FIFO.\r
 \r
-  @return   !NULL   Point to record, which is ready to be logged.\r
-  @return   NULL    the FIFO of record is empty.\r
+  @return   Point to record, which is ready to be logged.\r
+            NULL means the FIFO of record is empty.\r
 \r
 **/\r
 DATA_HUB_STATUS_CODE_DATA_RECORD *\r
@@ -96,17 +107,19 @@ RetrieveRecord (
   VOID\r
   )\r
 {\r
-  DATA_HUB_STATUS_CODE_DATA_RECORD  *RecordData = NULL;\r
+  DATA_HUB_STATUS_CODE_DATA_RECORD  *RecordData;\r
   DATAHUB_STATUSCODE_RECORD         *Record;\r
   LIST_ENTRY                        *Node;\r
   EFI_TPL                           CurrentTpl;\r
 \r
+  RecordData = NULL;\r
+\r
   CurrentTpl = gBS->RaiseTPL (TPL_HIGH_LEVEL);\r
 \r
   if (!IsListEmpty (&mRecordsFifo)) {\r
     Node = GetFirstNode (&mRecordsFifo);\r
     Record = CR (Node, DATAHUB_STATUSCODE_RECORD, Node, DATAHUB_STATUS_CODE_SIGNATURE);\r
-    ASSERT (NULL != Record);\r
+    ASSERT (Record != NULL);\r
 \r
     RemoveEntryList (&Record->Node);\r
     RecordData = (DATA_HUB_STATUS_CODE_DATA_RECORD *) Record->Data;\r
@@ -118,10 +131,9 @@ RetrieveRecord (
 }\r
 \r
 /**\r
-  Release Records to FIFO.\r
+  Release given record and return it to free record buffer.\r
   \r
-  @param RecordData  Point to the record buffer allocated\r
-                     from AcquireRecordBuffer.\r
+  @param RecordData  Pointer to the record to release.\r
 \r
 **/\r
 VOID\r
@@ -133,7 +145,7 @@ ReleaseRecord (
   EFI_TPL                           CurrentTpl;\r
 \r
   Record = CR (RecordData, DATAHUB_STATUSCODE_RECORD, Data[0], DATAHUB_STATUS_CODE_SIGNATURE);\r
-  ASSERT (NULL != Record);\r
+  ASSERT (Record != NULL);\r
 \r
   CurrentTpl = gBS->RaiseTPL (TPL_HIGH_LEVEL);\r
 \r
@@ -143,36 +155,24 @@ ReleaseRecord (
   gBS->RestoreTPL (CurrentTpl);\r
 }\r
 \r
-\r
-\r
 /**\r
   Report status code into DataHub.\r
 \r
-  @param  CodeType      Indicates the type of status code being reported.  Type EFI_STATUS_CODE_TYPE is defined in "Related Definitions" below.\r
-\r
-  @param  Value         Describes the current status of a hardware or software entity.\r
-                        This included information about the class and subclass that is used to classify the entity\r
-                        as well as an operation.  For progress codes, the operation is the current activity.\r
-                        For error codes, it is the exception.  For debug codes, it is not defined at this time.\r
-                        Type EFI_STATUS_CODE_VALUE is defined in "Related Definitions" below.\r
-                        Specific values are discussed in the Intel? Platform Innovation Framework for EFI Status Code Specification.\r
-\r
-  @param  Instance      The enumeration of a hardware or software entity within the system.\r
-                        A system may contain multiple entities that match a class/subclass pairing.\r
-                        The instance differentiates between them.  An instance of 0 indicates that instance information is unavailable,\r
-                        not meaningful, or not relevant.  Valid instance numbers start with 1.\r
-\r
-\r
-  @param  CallerId      This optional parameter may be used to identify the caller.\r
-                        This parameter allows the status code driver to apply different rules to different callers.\r
-                        Type EFI_GUID is defined in InstallProtocolInterface() in the UEFI 2.0 Specification.\r
-\r
-\r
-  @param  Data          This optional parameter may be used to pass additional data\r
-\r
-  @retval EFI_OUT_OF_RESOURCES   Can not acquire record buffer.\r
-  @retval EFI_DEVICE_ERROR       EFI serial device can not work after ExitBootService() is called .\r
-  @retval EFI_SUCCESS            Success to cache status code and signal log data event.\r
+  @param  CodeType             Indicates the type of status code being reported.\r
+  @param  Value                Describes the current status of a hardware or software entity.\r
+                               This included information about the class and subclass that is used to\r
+                               classify the entity as well as an operation.\r
+  @param  Instance             The enumeration of a hardware or software entity within\r
+                               the system. Valid instance numbers start with 1.\r
+  @param  CallerId             This optional parameter may be used to identify the caller.\r
+                               This parameter allows the status code driver to apply different rules to\r
+                               different callers.\r
+  @param  Data                 This optional parameter may be used to pass additional data.\r
+\r
+  @retval EFI_SUCCESS          The function completed successfully.\r
+  @retval EFI_DEVICE_ERROR     Function is reentered.\r
+  @retval EFI_DEVICE_ERROR     Function is called at runtime.\r
+  @retval EFI_OUT_OF_RESOURCES Fail to allocate memory for free record buffer.\r
 \r
 **/\r
 EFI_STATUS\r
@@ -190,12 +190,11 @@ DataHubStatusCodeReportWorker (
   CHAR8                             *Format;\r
   UINTN                             CharCount;\r
 \r
-\r
   //\r
   // Use atom operation to avoid the reentant of report.\r
   // If current status is not zero, then the function is reentrancy.\r
   //\r
-  if (1 == InterlockedCompareExchange32 (&mLogDataHubStatus, 0, 0)) {\r
+  if (InterlockedCompareExchange32 (&mLogDataHubStatus, 0, 0) == 1) {\r
     return EFI_DEVICE_ERROR;\r
   }\r
 \r
@@ -234,7 +233,7 @@ DataHubStatusCodeReportWorker (
                     Marker\r
                     );\r
       //\r
-      // Change record data type from DebugType to String Type.\r
+      // Change record data type to DebugType.\r
       //\r
       CopyGuid (&Record->Data.Type, &gEfiStatusCodeDataTypeDebugGuid);\r
       Record->Data.HeaderSize = Data->HeaderSize;\r
@@ -281,7 +280,7 @@ LogDataHubEventCallBack (
   // Use atom operation to avoid the reentant of report.\r
   // If current status is not zero, then the function is reentrancy.\r
   //\r
-  if (1 == InterlockedCompareExchange32 (&mLogDataHubStatus, 0, 1)) {\r
+  if (InterlockedCompareExchange32 (&mLogDataHubStatus, 0, 1) == 1) {\r
     return;\r
   }\r
 \r
@@ -289,7 +288,10 @@ LogDataHubEventCallBack (
   // Log DataRecord in Data Hub.\r
   // Journal records fifo to find all record entry.\r
   //\r
-  while (1) {\r
+  while (TRUE) {\r
+    //\r
+    // Retrieve record from record FIFO until no more record can be retrieved.\r
+    //\r
     Record = RetrieveRecord ();\r
     if (Record == NULL) {\r
       break;\r
@@ -318,7 +320,6 @@ LogDataHubEventCallBack (
     //\r
     // Log DataRecord in Data Hub\r
     //\r
-\r
     mDataHubProtocol->LogData (\r
                         mDataHubProtocol,\r
                         &gEfiDataHubStatusCodeRecordGuid,\r
@@ -339,10 +340,10 @@ LogDataHubEventCallBack (
 \r
 \r
 /**\r
-  Initialize data hubstatus code.\r
-  Create a data hub listener.\r
+  Locate Data Hub Protocol and create event for logging data\r
+  as initialization for data hub status code worker.\r
 \r
-  @return  The function always return EFI_SUCCESS\r
+  @retval EFI_SUCCESS  Initialization is successful.\r
 \r
 **/\r
 EFI_STATUS\r
index 9f5ae55d0c593c7c6501b7c7143061591e4edd3e..55ae84a5388abcd0d6d7a981e5b0b26986cbde49 100644 (file)
@@ -13,7 +13,7 @@
   DXE       -> This driver\r
   RT        -> This driver\r
 \r
-  Copyright (c) 2006, Intel Corporation                                                         \r
+  Copyright (c) 2006 - 2009, Intel Corporation                                                         \r
   All rights reserved. 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
@@ -27,7 +27,6 @@
 #include "DxeStatusCode.h"\r
 \r
 /**\r
-  \r
   Dispatch initialization request to sub status code devices based on \r
   customized feature flags.\r
  \r
@@ -41,7 +40,7 @@ InitializationDispatcherWorker (
   EFI_STATUS                        Status;\r
   MEMORY_STATUSCODE_PACKET_HEADER   *PacketHeader;\r
   MEMORY_STATUSCODE_RECORD          *Record;\r
-  UINTN                             ExpectedPacketIndex = 0;\r
+  UINTN                             ExpectedPacketIndex;\r
   UINTN                             Index;\r
   VOID                              *HobStart;\r
 \r
@@ -55,6 +54,9 @@ InitializationDispatcherWorker (
     ASSERT_EFI_ERROR (Status);\r
   }\r
   if (FeaturePcdGet (PcdStatusCodeUseHardSerial)) {\r
+    //\r
+    // Call Serial Port Lib API to initialize serial port.\r
+    //\r
     Status = SerialPortInitialize ();\r
     ASSERT_EFI_ERROR (Status);\r
   }\r
@@ -67,18 +69,22 @@ InitializationDispatcherWorker (
     ASSERT_EFI_ERROR (Status);\r
   }\r
   if (FeaturePcdGet (PcdStatusCodeUseOEM)) {\r
+    //\r
+    // Call OEM hook status code library API to initialize OEM device for status code.\r
+    //\r
     Status = OemHookStatusCodeInitialize ();\r
     ASSERT_EFI_ERROR (Status);\r
   }\r
 \r
   //\r
-  // Replay Status code which saved in GUID'ed HOB to all supported device. \r
+  // Replay Status code which saved in GUID'ed HOB to all supported devices\r
   //\r
 \r
   // \r
   // 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
@@ -103,7 +109,6 @@ InitializationDispatcherWorker (
         if (FeaturePcdGet (PcdStatusCodeReplayInRuntimeMemory) &&\r
             FeaturePcdGet (PcdStatusCodeUseRuntimeMemory)) {\r
           RtMemoryStatusCodeReportWorker (\r
-            gDxeStatusCode.RtMemoryStatusCodeTable[PHYSICAL_MODE],\r
             Record[Index].CodeType,\r
             Record[Index].Value,\r
             Record[Index].Instance\r
@@ -121,6 +126,9 @@ InitializationDispatcherWorker (
         }\r
         if (FeaturePcdGet (PcdStatusCodeReplayInOEM) &&\r
             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
@@ -135,7 +143,7 @@ InitializationDispatcherWorker (
       //\r
       // See whether there is gap of packet or not\r
       //\r
-      if (NULL != HobStart) {\r
+      if (HobStart != NULL) {\r
         HobStart  = NULL;\r
         Hob.Raw   = HobStart;\r
         continue;\r
index 4004deb484c8386b36aeb4467675c699a0707d86..8fb5488a05f3cb3596f12d3af63481bebf38171d 100644 (file)
@@ -1,6 +1,7 @@
 /** @file\r
+  Internal include file of Status Code Runtime DXE Driver.\r
 \r
-  Copyright (c) 2006, Intel Corporation\r
+  Copyright (c) 2006 - 2009, Intel Corporation\r
   All rights reserved. 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
@@ -11,8 +12,8 @@
 \r
 **/\r
 \r
-#ifndef __DXE_STATUS_CODE_H__\r
-#define __DXE_STATUS_CODE_H__\r
+#ifndef __STATUS_CODE_RUNTIME_DXE_H__\r
+#define __STATUS_CODE_RUNTIME_DXE_H__\r
 \r
 \r
 #include <FrameworkDxe.h>\r
 //\r
 // Data hub worker definition\r
 //\r
-#define MAX_NUMBER_DATAHUB_RECORDS                1000\r
-#define DATAHUB_BYTES_PER_RECORD                  EFI_STATUS_CODE_DATA_MAX_SIZE\r
-#define EMPTY_RECORD_TAG                          0xFF\r
 #define DATAHUB_STATUS_CODE_SIGNATURE             SIGNATURE_32 ('B', 'D', 'H', 'S')\r
 \r
-//\r
-// Address type of pointer.\r
-// The point type always equal to PHYSICAL_MODE on IA32/X64/EBC architecture\r
-// Otherwise, VIRTUAL_MODE/PHYSICAL_MODE would be used on Ipf architecture,\r
-//\r
-typedef enum {\r
-  PHYSICAL_MODE,\r
-  VIRTUAL_MODE\r
-} PROCESSOR_MODE;\r
-\r
 typedef struct {\r
   UINTN       Signature;\r
   LIST_ENTRY  Node;\r
-\r
-  UINT8       Data[sizeof (DATA_HUB_STATUS_CODE_DATA_RECORD) + EFI_STATUS_CODE_DATA_MAX_SIZE];\r
+  UINT8       Data[sizeof(DATA_HUB_STATUS_CODE_DATA_RECORD) + EFI_STATUS_CODE_DATA_MAX_SIZE];\r
 } DATAHUB_STATUSCODE_RECORD;\r
 \r
 \r
@@ -76,25 +63,43 @@ typedef struct {
   UINT32   MaxRecordsNumber;\r
 } RUNTIME_MEMORY_STATUSCODE_HEADER;\r
 \r
+extern RUNTIME_MEMORY_STATUSCODE_HEADER  *mRtMemoryStatusCodeTable;\r
 \r
-typedef struct {\r
-  //\r
-  // Report operation nest status.\r
-  // If it is set, then the report operation has nested.\r
-  //\r
-  UINT32                            StatusCodeNestStatus;\r
-  //\r
-  // Runtime status code management header, the records buffer is following it.\r
-  //\r
-  RUNTIME_MEMORY_STATUSCODE_HEADER  *RtMemoryStatusCodeTable[2];\r
-} DXE_STATUS_CODE_CONTROLLER;\r
+/**\r
+  Report status code to all supported device.\r
 \r
+  This function implements EFI_STATUS_CODE_PROTOCOL.ReportStatusCode().\r
+  It calls into the workers which dispatches the platform specific listeners.\r
 \r
-/**\r
+  @param  Type             Indicates the type of status code being reported.\r
+  @param  Value            Describes the current status of a hardware or software entity.\r
+                           This included information about the class and subclass that is used to\r
+                           classify the entity as well as an operation.\r
+  @param  Instance         The enumeration of a hardware or software entity within\r
+                           the system. Valid instance numbers start with 1.\r
+  @param  CallerId         This optional parameter may be used to identify the caller.\r
+                           This parameter allows the status code driver to apply different rules to\r
+                           different callers.\r
+  @param  Data             This optional parameter may be used to pass additional data.\r
 \r
-  Dispatch initialization request to sub status code devices based on\r
-  customized feature flags.\r
+  @retval EFI_SUCCESS      The function completed successfully\r
+  @retval EFI_DEVICE_ERROR The function should not be completed due to a device error.\r
 \r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+ReportDispatcher (\r
+  IN EFI_STATUS_CODE_TYPE     CodeType,\r
+  IN EFI_STATUS_CODE_VALUE    Value,\r
+  IN UINT32                   Instance,\r
+  IN EFI_GUID                 *CallerId  OPTIONAL,\r
+  IN EFI_STATUS_CODE_DATA     *Data      OPTIONAL\r
+  );\r
+\r
+/**\r
+  Dispatch initialization request to sub status code devices based on \r
+  customized feature flags.\r
\r
 **/\r
 VOID\r
 InitializationDispatcherWorker (\r
@@ -103,9 +108,9 @@ InitializationDispatcherWorker (
 \r
 \r
 /**\r
-  Initialize serial status code worker.\r
-\r
-  @return  The function always return EFI_SUCCESS\r
+  Locates Serial I/O Protocol as initialization for serial status code worker.\r
\r
+  @retval EFI_SUCCESS  Serial I/O Protocol is successfully located.\r
 \r
 **/\r
 EFI_STATUS\r
@@ -116,31 +121,21 @@ EfiSerialStatusCodeInitializeWorker (
 \r
 /**\r
   Convert status code value and extended data to readable ASCII string, send string to serial I/O device.\r
-\r
-  @param  CodeType      Indicates the type of status code being reported.  Type EFI_STATUS_CODE_TYPE is defined in "Related Definitions" below.\r
-\r
-  @param  Value         Describes the current status of a hardware or software entity.\r
-                        This included information about the class and subclass that is used to classify the entity\r
-                        as well as an operation.  For progress codes, the operation is the current activity.\r
-                        For error codes, it is the exception.  For debug codes, it is not defined at this time.\r
-                        Type EFI_STATUS_CODE_VALUE is defined in "Related Definitions" below.\r
-                        Specific values are discussed in the Intel? Platform Innovation Framework for EFI Status Code Specification.\r
-\r
-  @param  Instance      The enumeration of a hardware or software entity within the system.\r
-                        A system may contain multiple entities that match a class/subclass pairing.\r
-                        The instance differentiates between them.  An instance of 0 indicates that instance information is unavailable,\r
-                        not meaningful, or not relevant.  Valid instance numbers start with 1.\r
-\r
-\r
-  @param  CallerId      This optional parameter may be used to identify the caller.\r
-                        This parameter allows the status code driver to apply different rules to different callers.\r
-                        Type EFI_GUID is defined in InstallProtocolInterface() in the UEFI 2.0 Specification.\r
-\r
-\r
-  @param  Data          This optional parameter may be used to pass additional data\r
-\r
-  @retval EFI_SUCCESS         Success to report status code to serial I/O.\r
-  @retval EFI_DEVICE_ERROR    EFI serial device can not work after ExitBootService() is called .\r
\r
+  @param  CodeType         Indicates the type of status code being reported.\r
+  @param  Value            Describes the current status of a hardware or software entity.\r
+                           This included information about the class and subclass that is used to\r
+                           classify the entity as well as an operation.\r
+  @param  Instance         The enumeration of a hardware or software entity within\r
+                           the system. Valid instance numbers start with 1.\r
+  @param  CallerId         This optional parameter may be used to identify the caller.\r
+                           This parameter allows the status code driver to apply different rules to\r
+                           different callers.\r
+  @param  Data             This optional parameter may be used to pass additional data.\r
+\r
+  @retval EFI_SUCCESS      Status code reported to serial I/O successfully.\r
+  @retval EFI_DEVICE_ERROR EFI serial device cannot work after ExitBootService() is called.\r
+  @retval EFI_DEVICE_ERROR EFI serial device cannot work with TPL higher than TPL_CALLBACK.\r
 \r
 **/\r
 EFI_STATUS\r
@@ -153,9 +148,9 @@ SerialStatusCodeReportWorker (
   );\r
 \r
 /**\r
-  Initialize runtime memory status code.\r
-\r
-  @return  The function always return EFI_SUCCESS\r
+  Initialize runtime memory status code table as initialization for runtime memory status code worker\r
\r
+  @retval EFI_SUCCESS  Runtime memory status code table successfully initialized.\r
 \r
 **/\r
 EFI_STATUS\r
@@ -164,42 +159,34 @@ RtMemoryStatusCodeInitializeWorker (
   );\r
 \r
 /**\r
-  Report status code into runtime memory. If the runtime pool is full, roll back to the\r
+  Report status code into runtime memory. If the runtime pool is full, roll back to the \r
   first record and overwrite it.\r
-\r
-  @param  RtMemoryStatusCodeTable\r
-                        Point to Runtime memory table header.\r
-\r
-  @param  CodeType      Indicates the type of status code being reported.  Type EFI_STATUS_CODE_TYPE is defined in "Related Definitions" below.\r
-\r
-  @param  Value         Describes the current status of a hardware or software entity.\r
-                        This included information about the class and subclass that is used to classify the entity\r
-                        as well as an operation.  For progress codes, the operation is the current activity.\r
-                        For error codes, it is the exception.  For debug codes, it is not defined at this time.\r
-                        Type EFI_STATUS_CODE_VALUE is defined in "Related Definitions" below.\r
-                        Specific values are discussed in the Intel? Platform Innovation Framework for EFI Status Code Specification.\r
-\r
-  @param  Instance      The enumeration of a hardware or software entity within the system.\r
-                        A system may contain multiple entities that match a class/subclass pairing.\r
-                        The instance differentiates between them.  An instance of 0 indicates that instance information is unavailable,\r
-                        not meaningful, or not relevant.  Valid instance numbers start with 1.\r
-\r
-  @return               The function always return EFI_SUCCESS.\r
\r
+  @param  CodeType                Indicates the type of status code being reported.\r
+  @param  Value                   Describes the current status of a hardware or software entity.\r
+                                  This included information about the class and subclass that is used to\r
+                                  classify the entity as well as an operation.\r
+  @param  Instance                The enumeration of a hardware or software entity within\r
+                                  the system. Valid instance numbers start with 1.\r
+  @param  CallerId                This optional parameter may be used to identify the caller.\r
+                                  This parameter allows the status code driver to apply different rules to\r
+                                  different callers.\r
\r
+  @retval EFI_SUCCESS             Status code successfully recorded in runtime memory status code table.\r
 \r
 **/\r
 EFI_STATUS\r
 RtMemoryStatusCodeReportWorker (\r
-  RUNTIME_MEMORY_STATUSCODE_HEADER      *RtMemoryStatusCodeTable,\r
   IN EFI_STATUS_CODE_TYPE               CodeType,\r
   IN EFI_STATUS_CODE_VALUE              Value,\r
   IN UINT32                             Instance\r
   );\r
 \r
 /**\r
-  Initialize data hubstatus code.\r
-  Create a data hub listener.\r
+  Locate Data Hub Protocol and create event for logging data\r
+  as initialization for data hub status code worker.\r
 \r
-  @return  The function always return EFI_SUCCESS\r
+  @retval EFI_SUCCESS  Initialization is successful.\r
 \r
 **/\r
 EFI_STATUS\r
@@ -211,31 +198,21 @@ DataHubStatusCodeInitializeWorker (
 /**\r
   Report status code into DataHub.\r
 \r
-  @param  CodeType      Indicates the type of status code being reported.  Type EFI_STATUS_CODE_TYPE is defined in "Related Definitions" below.\r
-\r
-  @param  Value         Describes the current status of a hardware or software entity.\r
-                        This included information about the class and subclass that is used to classify the entity\r
-                        as well as an operation.  For progress codes, the operation is the current activity.\r
-                        For error codes, it is the exception.  For debug codes, it is not defined at this time.\r
-                        Type EFI_STATUS_CODE_VALUE is defined in "Related Definitions" below.\r
-                        Specific values are discussed in the Intel? Platform Innovation Framework for EFI Status Code Specification.\r
-\r
-  @param  Instance      The enumeration of a hardware or software entity within the system.\r
-                        A system may contain multiple entities that match a class/subclass pairing.\r
-                        The instance differentiates between them.  An instance of 0 indicates that instance information is unavailable,\r
-                        not meaningful, or not relevant.  Valid instance numbers start with 1.\r
-\r
-\r
-  @param  CallerId      This optional parameter may be used to identify the caller.\r
-                        This parameter allows the status code driver to apply different rules to different callers.\r
-                        Type EFI_GUID is defined in InstallProtocolInterface() in the UEFI 2.0 Specification.\r
-\r
-\r
-  @param  Data          This optional parameter may be used to pass additional data\r
-\r
-  @retval EFI_OUT_OF_RESOURCES   Can not acquire record buffer.\r
-  @retval EFI_DEVICE_ERROR       EFI serial device can not work after ExitBootService() is called .\r
-  @retval EFI_SUCCESS            Success to cache status code and signal log data event.\r
+  @param  CodeType             Indicates the type of status code being reported.\r
+  @param  Value                Describes the current status of a hardware or software entity.\r
+                               This included information about the class and subclass that is used to\r
+                               classify the entity as well as an operation.\r
+  @param  Instance             The enumeration of a hardware or software entity within\r
+                               the system. Valid instance numbers start with 1.\r
+  @param  CallerId             This optional parameter may be used to identify the caller.\r
+                               This parameter allows the status code driver to apply different rules to\r
+                               different callers.\r
+  @param  Data                 This optional parameter may be used to pass additional data.\r
+\r
+  @retval EFI_SUCCESS          The function completed successfully.\r
+  @retval EFI_DEVICE_ERROR     Function is reentered.\r
+  @retval EFI_DEVICE_ERROR     Function is called at runtime.\r
+  @retval EFI_OUT_OF_RESOURCES Fail to allocate memory for free record buffer.\r
 \r
 **/\r
 EFI_STATUS\r
@@ -248,9 +225,15 @@ DataHubStatusCodeReportWorker (
   );\r
 \r
 \r
-//\r
-// Declaration for callback Event.\r
-//\r
+/**\r
+  Virtual address change notification call back. It converts global pointer\r
+  to virtual address.\r
+\r
+  @param  Event         Event whose notification function is being invoked.\r
+  @param  Context       Pointer to the notification function's context, which is\r
+                        always zero in current implementation.\r
+\r
+**/\r
 VOID\r
 EFIAPI\r
 VirtualAddressChangeCallBack (\r
@@ -258,18 +241,4 @@ VirtualAddressChangeCallBack (
   IN VOID       *Context\r
   );\r
 \r
-//\r
-// Declaration for original Entry Point.\r
-//\r
-EFI_STATUS\r
-EFIAPI\r
-DxeStatusCodeDriverEntry (\r
-  IN EFI_HANDLE           ImageHandle,\r
-  IN EFI_SYSTEM_TABLE     *SystemTable\r
-  );\r
-\r
-//\r
-// declaration of DXE status code controller.\r
-//\r
-extern DXE_STATUS_CODE_CONTROLLER gDxeStatusCode;\r
 #endif\r
index 1fece54af0c6f5b33a570348a02d59548fd14a56..3df517466804540a75148d3b03bddd20c3043dcd 100644 (file)
@@ -1,9 +1,7 @@
 #/** @file\r
-#  DXE status code driver.\r
+#  Status Code Runtime Dxe driver that supports multiple devices and produces\r
+#  Status Code Runtime Protocol.\r
 #\r
-#  Status Code Architectural Protocol implementation as defined in Tiano\r
-#  Architecture Specification. This driver has limited functionality\r
-#  at runtime and will not log to Data Hub at runtime.\r
 #  Copyright (c) 2006 - 2009, Intel Corporation.\r
 #\r
 #  All rights reserved. This program and the accompanying materials\r
 \r
 \r
 [Guids]\r
-  gEfiDataHubStatusCodeRecordGuid               # SOMETIMES_CONSUMED\r
-  gMemoryStatusCodeRecordGuid                   # SOMETIMES_CONSUMED\r
-  gEfiStatusCodeDataTypeDebugGuid               # PROTOCOL ALWAYS_CONSUMED\r
-  gEfiEventExitBootServicesGuid\r
+  gEfiDataHubStatusCodeRecordGuid               ## SOMETIMES_CONSUMES (Needed if Data Hub is supported for status code.)\r
+  gEfiStatusCodeDataTypeDebugGuid               ## SOMETIMES_CONSUMES (Needed if Data Hub is supported for status code.)\r
+  gMemoryStatusCodeRecordGuid                   ## CONSUMES ## HOB\r
+  gEfiEventVirtualAddressChangeGuid             ## CONSUMES ## Event\r
+\r
 \r
 [Protocols]\r
-  gEfiStatusCodeRuntimeProtocolGuid             # PROTOCOL ALWAYS_CONSUMED\r
-  gEfiDataHubProtocolGuid                       # PROTOCOL ALWAYS_CONSUMED\r
-  gEfiSerialIoProtocolGuid                      # PROTOCOL ALWAYS_CONSUMED\r
+  gEfiStatusCodeRuntimeProtocolGuid             ## PRODUCES\r
+  gEfiDataHubProtocolGuid                       ## SOMETIMES_CONSUMES (Needed if Data Hub is supported for status code.)\r
+  gEfiSerialIoProtocolGuid                      ## SOMETIMES_CONSUMES (Needed if Serial is supported for status code.)\r
 \r
 \r
 [FeaturePcd.common]\r
index 954e82740588f2537c27c5b4fa5549dc36abc71c..2a156a503d45b64f5de3d8ccb2d96656bc310468 100644 (file)
 \r
 #include "DxeStatusCode.h"\r
 \r
-//\r
-// Event for Exit Boot Services Callback\r
-//\r
-EFI_EVENT mExitBootServicesEvent = NULL;\r
-\r
-/**\r
-  Report status code to all supported device.\r
-  Calls into the workers which dispatches the platform specific\r
-  listeners.\r
-\r
-  @param  Type          Indicates the type of status code being reported.\r
-                        The type EFI_STATUS_CODE_TYPE is defined in "Related Definitions" below.\r
-  @param  Value         Describes the current status of a hardware or software entity.\r
-                        This includes information about the class and subclass that is used to classify the entity\r
-                        as well as an operation.  For progress codes, the operation is the current activity.\r
-                        For error codes, it is the exception.  For debug codes, it is not defined at this time.\r
-                        Type EFI_STATUS_CODE_VALUE is defined in "Related Definitions" below.\r
-                        Specific values are discussed in the Intel? Platform Innovation Framework for EFI Status Code Specification.\r
-  @param  Instance      The enumeration of a hardware or software entity within the system.\r
-                        A system may contain multiple entities that match a class/subclass pairing.\r
-                        The instance differentiates between them.  An instance of 0 indicates that instance\r
-                        information is unavailable, not meaningful, or not relevant.  Valid instance numbers start with 1.\r
-  @param  CallerId      This optional parameter may be used to identify the caller.\r
-                        This parameter allows the status code driver to apply different rules to different callers.\r
-  @param  Data          This optional parameter may be used to pass additional data.\r
-                        Type EFI_STATUS_CODE_DATA is defined in "Related Definitions" below.\r
-                        The contents of this data type may have additional GUID-specific data.  The standard GUIDs and\r
-                        their associated data structures are defined in the Intel? Platform Innovation Framework for EFI Status Codes Specification.\r
-\r
-  @return               Always return EFI_SUCCESS.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-ReportDispatcher (\r
-  IN EFI_STATUS_CODE_TYPE     Type,\r
-  IN EFI_STATUS_CODE_VALUE    Value,\r
-  IN UINT32                   Instance,\r
-  IN EFI_GUID                 *CallerId  OPTIONAL,\r
-  IN EFI_STATUS_CODE_DATA     *Data      OPTIONAL\r
-  );\r
+EFI_EVENT    mVirtualAddressChangeEvent = NULL;\r
+EFI_HANDLE   mHandle = NULL;\r
 \r
 //\r
 // Declaration of status code protocol.\r
@@ -64,24 +25,21 @@ EFI_STATUS_CODE_PROTOCOL  mEfiStatusCodeProtocol  = {
 };\r
 \r
 //\r
-// Delaration of DXE status code controller\r
+// Report operation nest status.\r
+// If it is set, then the report operation has nested.\r
 //\r
-DXE_STATUS_CODE_CONTROLLER gDxeStatusCode = {\r
-  //\r
-  // Initialize nest status as non nested.\r
-  //\r
-  0,\r
-  {NULL, NULL}\r
-};\r
+UINT32  mStatusCodeNestStatus = 0;\r
 \r
 /**\r
+  Entry point of DXE Status Code Driver.\r
 \r
-  Install the ReportStatusCode runtime service.\r
+  This function is the entry point of this DXE Status Code Driver.\r
+  It installs Status Code Runtime Protocol, and registers event for EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE.\r
 \r
-  @param ImageHandle     Image handle of the loaded driver\r
-  @param SystemTable     Pointer to the System Table\r
-\r
-  @return                The function always returns success.\r
+  @param  ImageHandle       The firmware allocated handle for the EFI image.\r
+  @param  SystemTable       A pointer to the EFI System Table.\r
+  \r
+  @retval EFI_SUCCESS       The entry point is executed successfully.\r
 \r
 **/\r
 EFI_STATUS\r
@@ -91,7 +49,6 @@ DxeStatusCodeDriverEntry (
   IN EFI_SYSTEM_TABLE   *SystemTable\r
   )\r
 {\r
-  EFI_HANDLE  Handle       = NULL;\r
   EFI_STATUS  Status;\r
 \r
   //\r
@@ -100,11 +57,10 @@ DxeStatusCodeDriverEntry (
   InitializationDispatcherWorker ();\r
 \r
   //\r
-  // Install Status Code Architectural Protocol implementation as defined in Tiano\r
-  // Architecture Specification.\r
+  // Install Status Code Runtime Protocol implementation as defined in PI Specification.\r
   //\r
   Status = gBS->InstallMultipleProtocolInterfaces (\r
-                  &Handle,\r
+                  &mHandle,\r
                   &gEfiStatusCodeRuntimeProtocolGuid,\r
                   &mEfiStatusCodeProtocol,\r
                   NULL\r
@@ -116,39 +72,33 @@ DxeStatusCodeDriverEntry (
                   TPL_NOTIFY,\r
                   VirtualAddressChangeCallBack,\r
                   NULL,\r
-                  &gEfiEventExitBootServicesGuid,\r
-                  &mExitBootServicesEvent\r
+                  &gEfiEventVirtualAddressChangeGuid,\r
+                  &mVirtualAddressChangeEvent\r
                   );\r
   ASSERT_EFI_ERROR (Status);\r
 \r
-  return Status;\r
+  return EFI_SUCCESS;\r
 }\r
 \r
 /**\r
   Report status code to all supported device.\r
-  Calls into the workers which dispatches the platform specific\r
-  listeners.\r
-\r
-  @param  CodeType      Indicates the type of status code being reported.\r
-                        The type EFI_STATUS_CODE_TYPE is defined in "Related Definitions" below.\r
-  @param  Value         Describes the current status of a hardware or software entity.\r
-                        This includes information about the class and subclass that is used to classify the entity\r
-                        as well as an operation.  For progress codes, the operation is the current activity.\r
-                        For error codes, it is the exception.  For debug codes, it is not defined at this time.\r
-                        Type EFI_STATUS_CODE_VALUE is defined in "Related Definitions" below.\r
-                        Specific values are discussed in the Intel? Platform Innovation Framework for EFI Status Code Specification.\r
-  @param  Instance      The enumeration of a hardware or software entity within the system.\r
-                        A system may contain multiple entities that match a class/subclass pairing.\r
-                        The instance differentiates between them.  An instance of 0 indicates that instance\r
-                        information is unavailable, not meaningful, or not relevant.  Valid instance numbers start with 1.\r
-  @param  CallerId      This optional parameter may be used to identify the caller.\r
-                        This parameter allows the status code driver to apply different rules to different callers.\r
-  @param  Data          This optional parameter may be used to pass additional data.\r
-                        Type EFI_STATUS_CODE_DATA is defined in "Related Definitions" below.\r
-                        The contents of this data type may have additional GUID-specific data.  The standard GUIDs and\r
-                        their associated data structures are defined in the Intel? Platform Innovation Framework for EFI Status Codes Specification.\r
-\r
-  @return               Always return EFI_SUCCESS.\r
+\r
+  This function implements EFI_STATUS_CODE_PROTOCOL.ReportStatusCode().\r
+  It calls into the workers which dispatches the platform specific listeners.\r
+\r
+  @param  Type             Indicates the type of status code being reported.\r
+  @param  Value            Describes the current status of a hardware or software entity.\r
+                           This included information about the class and subclass that is used to\r
+                           classify the entity as well as an operation.\r
+  @param  Instance         The enumeration of a hardware or software entity within\r
+                           the system. Valid instance numbers start with 1.\r
+  @param  CallerId         This optional parameter may be used to identify the caller.\r
+                           This parameter allows the status code driver to apply different rules to\r
+                           different callers.\r
+  @param  Data             This optional parameter may be used to pass additional data.\r
+\r
+  @retval EFI_SUCCESS      The function completed successfully\r
+  @retval EFI_DEVICE_ERROR The function should not be completed due to a device error.\r
 \r
 **/\r
 EFI_STATUS\r
@@ -165,7 +115,7 @@ ReportDispatcher (
   // Use atom operation to avoid the reentant of report.\r
   // If current status is not zero, then the function is reentrancy.\r
   //\r
-  if (1 == InterlockedCompareExchange32 (&gDxeStatusCode.StatusCodeNestStatus, 0, 1)) {\r
+  if (InterlockedCompareExchange32 (&mStatusCodeNestStatus, 0, 1) == 1) {\r
     return EFI_DEVICE_ERROR;\r
   }\r
 \r
@@ -180,7 +130,6 @@ ReportDispatcher (
   }\r
   if (FeaturePcdGet (PcdStatusCodeUseRuntimeMemory)) {\r
     RtMemoryStatusCodeReportWorker (\r
-      gDxeStatusCode.RtMemoryStatusCodeTable[PHYSICAL_MODE],\r
       CodeType,\r
       Value,\r
       Instance\r
@@ -196,6 +145,9 @@ ReportDispatcher (
       );\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
       CodeType,\r
       Value,\r
@@ -208,7 +160,7 @@ ReportDispatcher (
   //\r
   // Restore the nest status of report\r
   //\r
-  InterlockedCompareExchange32 (&gDxeStatusCode.StatusCodeNestStatus, 1, 0);\r
+  InterlockedCompareExchange32 (&mStatusCodeNestStatus, 1, 0);\r
 \r
   return EFI_SUCCESS;\r
 }\r
@@ -235,7 +187,7 @@ VirtualAddressChangeCallBack (
   //\r
   EfiConvertPointer (\r
     0,\r
-    (VOID **) &gDxeStatusCode.RtMemoryStatusCodeTable[PHYSICAL_MODE]\r
+    (VOID **) &mRtMemoryStatusCodeTable\r
     );\r
 }\r
 \r
index de2ccf380eba2a1b575a9deef19c8142b4cde858..3d0855f6f3e12821568c1d054f0e5b41920e0dd6 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
-  Runtime memory status code worker in DXE.\r
+  Runtime memory status code worker.\r
 \r
-  Copyright (c) 2006, Intel Corporation                                                         \r
+  Copyright (c) 2006 - 2009, Intel Corporation                                                         \r
   All rights reserved. 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
 \r
 #include "DxeStatusCode.h"\r
 \r
+RUNTIME_MEMORY_STATUSCODE_HEADER  *mRtMemoryStatusCodeTable;\r
+\r
 /**\r
-  Initialize runtime memory status code.\r
+  Initialize runtime memory status code table as initialization for runtime memory status code worker\r
  \r
-  @return  The function always return EFI_SUCCESS\r
+  @retval EFI_SUCCESS  Runtime memory status code table successfully initialized.\r
 \r
 **/\r
 EFI_STATUS\r
@@ -25,26 +27,21 @@ RtMemoryStatusCodeInitializeWorker (
   VOID\r
   )\r
 {\r
-  RUNTIME_MEMORY_STATUSCODE_HEADER  *RtMemoryStatusCodeTable;\r
-\r
   //\r
   // Allocate runtime memory status code pool.\r
   //\r
-  RtMemoryStatusCodeTable = \r
-    (RUNTIME_MEMORY_STATUSCODE_HEADER *) AllocateRuntimePool (\r
-                                           sizeof (RUNTIME_MEMORY_STATUSCODE_HEADER) +\r
-                                           PcdGet16 (PcdStatusCodeRuntimeMemorySize) *\r
-                                           1024\r
-                                           );\r
-\r
-  ASSERT (NULL != RtMemoryStatusCodeTable);\r
-\r
-  RtMemoryStatusCodeTable->RecordIndex                  = 0;\r
-  RtMemoryStatusCodeTable->NumberOfRecords              = 0;\r
-  RtMemoryStatusCodeTable->MaxRecordsNumber             = \r
+  mRtMemoryStatusCodeTable = AllocateRuntimePool (\r
+                               sizeof (RUNTIME_MEMORY_STATUSCODE_HEADER) +\r
+                               PcdGet16 (PcdStatusCodeRuntimeMemorySize) *\r
+                               1024\r
+                               );\r
+  ASSERT (mRtMemoryStatusCodeTable != NULL);\r
+\r
+  mRtMemoryStatusCodeTable->RecordIndex      = 0;\r
+  mRtMemoryStatusCodeTable->NumberOfRecords  = 0;\r
+  mRtMemoryStatusCodeTable->MaxRecordsNumber = \r
     (PcdGet16 (PcdStatusCodeRuntimeMemorySize) * 1024) / sizeof (MEMORY_STATUSCODE_RECORD);\r
 \r
-  gDxeStatusCode.RtMemoryStatusCodeTable[PHYSICAL_MODE] = RtMemoryStatusCodeTable;\r
   return EFI_SUCCESS;\r
 }\r
 \r
@@ -53,29 +50,21 @@ RtMemoryStatusCodeInitializeWorker (
   Report status code into runtime memory. If the runtime pool is full, roll back to the \r
   first record and overwrite it.\r
  \r
-  @param  RtMemoryStatusCodeTable      \r
-                        Point to Runtime memory table header.\r
-\r
-  @param  CodeType      Indicates the type of status code being reported.  Type EFI_STATUS_CODE_TYPE is defined in "Related Definitions" below.\r
\r
-  @param  Value         Describes the current status of a hardware or software entity.  \r
-                        This included information about the class and subclass that is used to classify the entity \r
-                        as well as an operation.  For progress codes, the operation is the current activity. \r
-                        For error codes, it is the exception.  For debug codes, it is not defined at this time. \r
-                        Type EFI_STATUS_CODE_VALUE is defined in "Related Definitions" below.  \r
-                        Specific values are discussed in the Intel? Platform Innovation Framework for EFI Status Code Specification.\r
+  @param  CodeType                Indicates the type of status code being reported.\r
+  @param  Value                   Describes the current status of a hardware or software entity.\r
+                                  This included information about the class and subclass that is used to\r
+                                  classify the entity as well as an operation.\r
+  @param  Instance                The enumeration of a hardware or software entity within\r
+                                  the system. Valid instance numbers start with 1.\r
+  @param  CallerId                This optional parameter may be used to identify the caller.\r
+                                  This parameter allows the status code driver to apply different rules to\r
+                                  different callers.\r
  \r
-  @param  Instance      The enumeration of a hardware or software entity within the system.  \r
-                        A system may contain multiple entities that match a class/subclass pairing. \r
-                        The instance differentiates between them.  An instance of 0 indicates that instance information is unavailable, \r
-                        not meaningful, or not relevant.  Valid instance numbers start with 1.\r
\r
-  @return               The function always return EFI_SUCCESS.\r
+  @retval EFI_SUCCESS             Status code successfully recorded in runtime memory status code table.\r
 \r
 **/\r
 EFI_STATUS\r
 RtMemoryStatusCodeReportWorker (\r
-  RUNTIME_MEMORY_STATUSCODE_HEADER      *RtMemoryStatusCodeTable,\r
   IN EFI_STATUS_CODE_TYPE               CodeType,\r
   IN EFI_STATUS_CODE_VALUE              Value,\r
   IN UINT32                             Instance\r
@@ -83,32 +72,33 @@ RtMemoryStatusCodeReportWorker (
 {\r
   MEMORY_STATUSCODE_RECORD              *Record;\r
 \r
-  ASSERT (NULL != RtMemoryStatusCodeTable);\r
-\r
   //\r
   // Locate current record buffer.\r
   //\r
-  Record                  = (MEMORY_STATUSCODE_RECORD *) (RtMemoryStatusCodeTable + 1);\r
-  Record                  = &Record[RtMemoryStatusCodeTable->RecordIndex++];\r
+  Record = (MEMORY_STATUSCODE_RECORD *) (mRtMemoryStatusCodeTable + 1);\r
+  Record = &Record[mRtMemoryStatusCodeTable->RecordIndex++];\r
 \r
   //\r
   // Save status code.\r
   //\r
-  Record->CodeType        = CodeType;\r
-  Record->Value           = Value;\r
-  Record->Instance        = Instance;\r
+  Record->CodeType = CodeType;\r
+  Record->Value    = Value;\r
+  Record->Instance = Instance;\r
 \r
   //\r
-  // Record total number of records, we compare the number with max records number,\r
-  // if it is bigger than the max number, then the roll back had happened, the record index points to \r
-  // the first record. if it is less then max number, then the zero index is the first record.\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
-  RtMemoryStatusCodeTable->NumberOfRecords++;\r
-  if (RtMemoryStatusCodeTable->RecordIndex == RtMemoryStatusCodeTable->MaxRecordsNumber) {\r
+  mRtMemoryStatusCodeTable->NumberOfRecords++;\r
+  if (mRtMemoryStatusCodeTable->RecordIndex == mRtMemoryStatusCodeTable->MaxRecordsNumber) {\r
     //\r
-    // Roll back record index.\r
+    // Wrap around record index.\r
     //\r
-    RtMemoryStatusCodeTable->RecordIndex = 0;\r
+    mRtMemoryStatusCodeTable->RecordIndex = 0;\r
   }\r
 \r
   return EFI_SUCCESS;\r
index 52817283d943aea2f33ddb1a754dd6618d6d078b..d9ec8c5ca3a08dcf224f47d0c73040c4ec06d056 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Serial I/O status code reporting worker.\r
 \r
-  Copyright (c) 2006, Intel Corporation                                                         \r
+  Copyright (c) 2006 - 2009, Intel Corporation                                                         \r
   All rights reserved. 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
@@ -17,9 +17,9 @@
 EFI_SERIAL_IO_PROTOCOL *mSerialIoProtocol;\r
 \r
 /**\r
-  Initialize serial status code worker.\r
+  Locates Serial I/O Protocol as initialization for serial status code worker.\r
  \r
-  @return  The function always return EFI_SUCCESS\r
+  @retval EFI_SUCCESS  Serial I/O Protocol is successfully located.\r
 \r
 **/\r
 EFI_STATUS\r
@@ -44,30 +44,20 @@ EfiSerialStatusCodeInitializeWorker (
 /**\r
   Convert status code value and extended data to readable ASCII string, send string to serial I/O device.\r
  \r
-  @param  CodeType      Indicates the type of status code being reported.  Type EFI_STATUS_CODE_TYPE is defined in "Related Definitions" below.\r
\r
-  @param  Value         Describes the current status of a hardware or software entity.  \r
-                        This included information about the class and subclass that is used to classify the entity \r
-                        as well as an operation.  For progress codes, the operation is the current activity. \r
-                        For error codes, it is the exception.  For debug codes, it is not defined at this time. \r
-                        Type EFI_STATUS_CODE_VALUE is defined in "Related Definitions" below.  \r
-                        Specific values are discussed in the Intel? Platform Innovation Framework for EFI Status Code Specification.\r
\r
-  @param  Instance      The enumeration of a hardware or software entity within the system.  \r
-                        A system may contain multiple entities that match a class/subclass pairing. \r
-                        The instance differentiates between them.  An instance of 0 indicates that instance information is unavailable, \r
-                        not meaningful, or not relevant.  Valid instance numbers start with 1.\r
-\r
-\r
-  @param  CallerId      This optional parameter may be used to identify the caller. \r
-                        This parameter allows the status code driver to apply different rules to different callers. \r
-                        Type EFI_GUID is defined in InstallProtocolInterface() in the UEFI 2.0 Specification.\r
-\r
-\r
-  @param  Data          This optional parameter may be used to pass additional data\r
\r
-  @retval EFI_SUCCESS         Success to report status code to serial I/O.\r
-  @retval EFI_DEVICE_ERROR    EFI serial device can not work after ExitBootService() is called .\r
+  @param  CodeType         Indicates the type of status code being reported.\r
+  @param  Value            Describes the current status of a hardware or software entity.\r
+                           This included information about the class and subclass that is used to\r
+                           classify the entity as well as an operation.\r
+  @param  Instance         The enumeration of a hardware or software entity within\r
+                           the system. Valid instance numbers start with 1.\r
+  @param  CallerId         This optional parameter may be used to identify the caller.\r
+                           This parameter allows the status code driver to apply different rules to\r
+                           different callers.\r
+  @param  Data             This optional parameter may be used to pass additional data.\r
+\r
+  @retval EFI_SUCCESS      Status code reported to serial I/O successfully.\r
+  @retval EFI_DEVICE_ERROR EFI serial device cannot work after ExitBootService() is called.\r
+  @retval EFI_DEVICE_ERROR EFI serial device cannot work with TPL higher than TPL_CALLBACK.\r
 \r
 **/\r
 EFI_STATUS\r
@@ -87,17 +77,12 @@ SerialStatusCodeReportWorker (
   UINT32          LineNumber;\r
   UINTN           CharCount;\r
   VA_LIST         Marker;\r
-  EFI_TPL         CurrentTpl;\r
-\r
 \r
   if (FeaturePcdGet (PcdStatusCodeUseEfiSerial)) {\r
     if (EfiAtRuntime ()) {\r
       return EFI_DEVICE_ERROR;\r
     }\r
-    CurrentTpl = gBS->RaiseTPL (TPL_HIGH_LEVEL);\r
-    gBS->RestoreTPL (CurrentTpl);\r
-\r
-    if (CurrentTpl > TPL_CALLBACK ) {\r
+    if (EfiGetCurrentTpl () > TPL_CALLBACK ) {\r
       return EFI_DEVICE_ERROR;\r
     }\r
   }\r
@@ -140,12 +125,7 @@ SerialStatusCodeReportWorker (
                   Value, \r
                   Instance\r
                   );\r
-\r
-    //\r
-    // Make sure we don't try to print values that weren't \r
-    // intended to be printed, especially NULL GUID pointers.\r
-    //\r
-    \r
+   \r
     if (CallerId != NULL) {\r
       CharCount += AsciiSPrint (\r
                      &Buffer[CharCount - 1],\r
@@ -170,6 +150,9 @@ SerialStatusCodeReportWorker (
                    "\n\r"\r
                    );\r
   } else if ((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_PROGRESS_CODE) {\r
+    //\r
+    // Print PROGRESS information into output buffer.\r
+    //\r
     CharCount = AsciiSPrint (\r
                   Buffer, \r
                   EFI_STATUS_CODE_DATA_MAX_SIZE, \r
@@ -178,6 +161,9 @@ SerialStatusCodeReportWorker (
                   Instance\r
                   );\r
   } else {\r
+    //\r
+    // Code type is not defined.\r
+    //\r
     CharCount = AsciiSPrint (\r
                   Buffer, \r
                   EFI_STATUS_CODE_DATA_MAX_SIZE, \r
@@ -191,7 +177,7 @@ SerialStatusCodeReportWorker (
 \r
   if (FeaturePcdGet (PcdStatusCodeUseHardSerial)) {\r
     //\r
-    // Callout to SerialPort Lib function to do print.\r
+    // Call SerialPort Lib function to do print.\r
     //\r
     SerialPortWrite ((UINT8 *) Buffer, CharCount);\r
   }\r