]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Add DataHub & DataHubStdErr modules
authorqhuang8 <qhuang8@6f19259b-4bc3-4df7-8a09-765794883524>
Thu, 28 Jun 2007 14:01:00 +0000 (14:01 +0000)
committerqhuang8 <qhuang8@6f19259b-4bc3-4df7-8a09-765794883524>
Thu, 28 Jun 2007 14:01:00 +0000 (14:01 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@2851 6f19259b-4bc3-4df7-8a09-765794883524

IntelFrameworkModulePkg/Universal/DataHub/DataHub/Dxe/DataHub.c [new file with mode: 0644]
IntelFrameworkModulePkg/Universal/DataHub/DataHub/Dxe/DataHub.dxs [new file with mode: 0644]
IntelFrameworkModulePkg/Universal/DataHub/DataHub/Dxe/DataHub.h [new file with mode: 0644]
IntelFrameworkModulePkg/Universal/DataHub/DataHub/Dxe/DataHub.inf [new file with mode: 0644]
IntelFrameworkModulePkg/Universal/DataHub/DataHub/Dxe/DataHub.msa [new file with mode: 0644]
IntelFrameworkModulePkg/Universal/DataHub/DataHubStdErr/Dxe/DataHubStdErr.c [new file with mode: 0644]
IntelFrameworkModulePkg/Universal/DataHub/DataHubStdErr/Dxe/DataHubStdErr.dxs [new file with mode: 0644]
IntelFrameworkModulePkg/Universal/DataHub/DataHubStdErr/Dxe/DataHubStdErr.inf [new file with mode: 0644]
IntelFrameworkModulePkg/Universal/DataHub/DataHubStdErr/Dxe/DataHubStdErr.msa [new file with mode: 0644]

diff --git a/IntelFrameworkModulePkg/Universal/DataHub/DataHub/Dxe/DataHub.c b/IntelFrameworkModulePkg/Universal/DataHub/DataHub/Dxe/DataHub.c
new file mode 100644 (file)
index 0000000..aa0cced
--- /dev/null
@@ -0,0 +1,660 @@
+/*++\r
+\r
+Copyright (c) 2006, 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
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  DataHub.c\r
+\r
+Abstract:\r
+\r
+  This code produces the Data Hub protocol. It preloads the data hub\r
+  with status information copied in from PEI HOBs.\r
+  \r
+  Only code that implements the Data Hub protocol should go in this file!\r
+\r
+  The Term MTC stands for MonoTonicCounter. \r
+\r
+  For more information please look at DataHub.doc\r
+\r
+  NOTE: For extra security of the log GetNextDataRecord () could return a copy\r
+        of the data record.\r
+--*/\r
+\r
+#include "DataHub.h"\r
+\r
+CONST EFI_GUID gZeroGuid  = { 0, 0, 0, { 0, 0, 0, 0, 0, 0, 0, 0 } };\r
+\r
+//\r
+// Worker functions private to this file\r
+//\r
+STATIC\r
+DATA_HUB_FILTER_DRIVER  *\r
+FindFilterDriverByEvent (\r
+  IN  LIST_ENTRY      *Head,\r
+  IN  EFI_EVENT       Event\r
+  );\r
+\r
+STATIC\r
+EFI_DATA_RECORD_HEADER  *\r
+GetNextDataRecord (\r
+  IN  LIST_ENTRY          *Head,\r
+  IN  UINT64              ClassFilter,\r
+  IN OUT  UINT64          *PtrCurrentMTC\r
+  );\r
+\r
+STATIC\r
+EFI_STATUS\r
+EFIAPI\r
+DataHubLogData (\r
+  IN  EFI_DATA_HUB_PROTOCOL   *This,\r
+  IN  EFI_GUID                *DataRecordGuid,\r
+  IN  EFI_GUID                *ProducerName,\r
+  IN  UINT64                  DataRecordClass,\r
+  IN  VOID                    *RawData,\r
+  IN  UINT32                  RawDataSize\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Log data record into the data logging hub\r
+\r
+Arguments:\r
+\r
+  This                - Protocol instance structure\r
+\r
+  DataRecordGuid      - GUID that defines record contents\r
+\r
+  ProducerName        - GUID that defines the name of the producer of the data\r
+\r
+  DataRecordClass     - Class that defines generic record type\r
+\r
+  RawData             - Data Log record as defined by DataRecordGuid\r
+  \r
+  RawDataSize         - Size of Data Log data in bytes\r
+\r
+Returns: \r
+\r
+  EFI_SUCCESS           - If data was logged\r
+\r
+  EFI_OUT_OF_RESOURCES  - If data was not logged due to lack of system \r
+                           resources.\r
+--*/\r
+{\r
+  EFI_STATUS              Status;\r
+  DATA_HUB_INSTANCE       *Private;\r
+  EFI_DATA_ENTRY          *LogEntry;\r
+  UINT32                  TotalSize;\r
+  UINT32                  RecordSize;\r
+  EFI_DATA_RECORD_HEADER  *Record;\r
+  VOID                    *Raw;\r
+  DATA_HUB_FILTER_DRIVER  *FilterEntry;\r
+  LIST_ENTRY              *Link;\r
+  LIST_ENTRY              *Head;\r
+\r
+  Private = DATA_HUB_INSTANCE_FROM_THIS (This);\r
+\r
+  //\r
+  // Combine the storage for the internal structs and a copy of the log record.\r
+  //  Record follows PrivateLogEntry. The consumer will be returned a pointer\r
+  //  to Record so we don't what it to be the thing that was allocated from\r
+  //  pool, so the consumer can't free an data record by mistake.\r
+  //\r
+  RecordSize  = sizeof (EFI_DATA_RECORD_HEADER) + RawDataSize;\r
+  TotalSize   = sizeof (EFI_DATA_ENTRY) + RecordSize;\r
+\r
+  //\r
+  // The Logging action is the critical section, so it is locked.\r
+  //  The MTC asignment & update, time, and logging must be an\r
+  //  atomic operation, so use the lock.\r
+  //\r
+  Status = EfiAcquireLockOrFail (&Private->DataLock);\r
+  if (EFI_ERROR (Status)) {\r
+    //\r
+    // Reentrancy detected so exit!\r
+    //\r
+    return Status;\r
+  }\r
+\r
+  LogEntry = AllocatePool (TotalSize);\r
+\r
+  if (LogEntry == NULL) {\r
+    EfiReleaseLock (&Private->DataLock);\r
+    return EFI_OUT_OF_RESOURCES;\r
+  }\r
+\r
+  ZeroMem (LogEntry, TotalSize);\r
+\r
+  Record  = (EFI_DATA_RECORD_HEADER *) (LogEntry + 1);\r
+  Raw     = (VOID *) (Record + 1);\r
+\r
+  //\r
+  // Build Standard Log Header\r
+  //\r
+  Record->Version     = EFI_DATA_RECORD_HEADER_VERSION;\r
+  Record->HeaderSize  = sizeof (EFI_DATA_RECORD_HEADER);\r
+  Record->RecordSize  = RecordSize;\r
+  CopyMem (&Record->DataRecordGuid, DataRecordGuid, sizeof (EFI_GUID));\r
+  CopyMem (&Record->ProducerName, ProducerName, sizeof (EFI_GUID));\r
+  Record->DataRecordClass   = DataRecordClass;\r
+\r
+  Record->LogMonotonicCount = Private->GlobalMonotonicCount++;\r
+\r
+  gRT->GetTime (&Record->LogTime, NULL);\r
+\r
+  //\r
+  // Insert log into the internal linked list.\r
+  //\r
+  LogEntry->Signature   = EFI_DATA_ENTRY_SIGNATURE;\r
+  LogEntry->Record      = Record;\r
+  LogEntry->RecordSize  = sizeof (EFI_DATA_ENTRY) + RawDataSize;\r
+  InsertTailList (&Private->DataListHead, &LogEntry->Link);\r
+\r
+  CopyMem (Raw, RawData, RawDataSize);\r
+\r
+  EfiReleaseLock (&Private->DataLock);\r
+\r
+  //\r
+  // Send Signal to all the filter drivers which are interested\r
+  //  in the record's class and guid.\r
+  //\r
+  Head = &Private->FilterDriverListHead;\r
+  for (Link = Head->ForwardLink; Link != Head; Link = Link->ForwardLink) {\r
+    FilterEntry = FILTER_ENTRY_FROM_LINK (Link);\r
+    if (((FilterEntry->ClassFilter & DataRecordClass) != 0) &&\r
+        (CompareGuid (&FilterEntry->FilterDataRecordGuid, &gZeroGuid) || \r
+         CompareGuid (&FilterEntry->FilterDataRecordGuid, DataRecordGuid))) {\r
+      gBS->SignalEvent (FilterEntry->Event);\r
+    }\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+STATIC\r
+EFI_STATUS\r
+EFIAPI\r
+DataHubGetNextRecord (\r
+  IN EFI_DATA_HUB_PROTOCOL            *This,\r
+  IN OUT UINT64                       *MonotonicCount,\r
+  IN EFI_EVENT                        *FilterDriverEvent, OPTIONAL\r
+  OUT EFI_DATA_RECORD_HEADER          **Record\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Get a previously logged data record and the MonotonicCount for the next\r
+  availible Record. This allows all records or all records later \r
+  than a give MonotonicCount to be returned. If an optional FilterDriverEvent\r
+  is passed in with a MonotonicCout of zero return the first record \r
+  not yet read by the filter driver. If FilterDriverEvent is NULL and \r
+  MonotonicCount is zero return the first data record.\r
+\r
+Arguments:\r
+\r
+  This              - The EFI_DATA_HUB_PROTOCOL instance.\r
+  MonotonicCount    - Specifies the Record to return. On input, zero means\r
+                      return the first record. On output, contains the next\r
+                      record to availible. Zero indicates no more records.\r
+  FilterDriverEvent - If FilterDriverEvent is not passed in a MonotonicCount \r
+                      of zero, it means to return the first data record. \r
+                      If FilterDriverEvent is passed in, then a MonotonicCount \r
+                      of zero means to return the first data not yet read by \r
+                      FilterDriverEvent.\r
+  Record            - Returns a dynamically allocated memory buffer with a data \r
+                      record that matches MonotonicCount.\r
+\r
+Returns: \r
+\r
+  EFI_SUCCESS             - Data was returned in Record.\r
+  EFI_INVALID_PARAMETER   - FilterDriverEvent was passed in but does not exist.\r
+  EFI_NOT_FOUND           - MonotonicCount does not match any data record in the\r
+                            system. If a MonotonicCount of zero was passed in, then\r
+                            no data records exist in the system.\r
+  EFI_OUT_OF_RESOURCES    - Record was not returned due to lack of system resources.\r
+\r
+--*/\r
+{\r
+  DATA_HUB_INSTANCE       *Private;\r
+  DATA_HUB_FILTER_DRIVER  *FilterDriver;\r
+  UINT64                  ClassFilter;\r
+  UINT64                  FilterMonotonicCount;\r
+\r
+  Private               = DATA_HUB_INSTANCE_FROM_THIS (This);\r
+\r
+  FilterDriver          = NULL;\r
+  FilterMonotonicCount  = 0;\r
+  ClassFilter = EFI_DATA_RECORD_CLASS_DEBUG |\r
+    EFI_DATA_RECORD_CLASS_ERROR |\r
+    EFI_DATA_RECORD_CLASS_DATA |\r
+    EFI_DATA_RECORD_CLASS_PROGRESS_CODE;\r
+\r
+  if (FilterDriverEvent != NULL) {\r
+    //\r
+    // For events the beginning is the last unread record. This info is\r
+    // stored in the instance structure, so we must look up the event\r
+    // to get the data.\r
+    //\r
+    FilterDriver = FindFilterDriverByEvent (\r
+                    &Private->FilterDriverListHead,\r
+                    *FilterDriverEvent\r
+                    );\r
+    if (FilterDriver == NULL) {\r
+      return EFI_INVALID_PARAMETER;\r
+    }\r
+    //\r
+    // Use the Class filter the event was created with.\r
+    //\r
+    ClassFilter = FilterDriver->ClassFilter;\r
+\r
+    if (*MonotonicCount == 0) {\r
+      //\r
+      // Use the MTC from the Filter Driver.\r
+      //\r
+      FilterMonotonicCount = FilterDriver->GetNextMonotonicCount;\r
+      if (FilterMonotonicCount != 0) {\r
+        //\r
+        // The GetNextMonotonicCount field remembers the last value from the previous time.\r
+        // But we already processed this vaule, so we need to find the next one. So if\r
+        // It is not the first time get the new record entry.\r
+        //\r
+        *Record         = GetNextDataRecord (&Private->DataListHead, ClassFilter, &FilterMonotonicCount);\r
+        *MonotonicCount = FilterMonotonicCount;\r
+        if (FilterMonotonicCount == 0) {\r
+          //\r
+          // If there is no new record to get exit now.\r
+          //\r
+          return EFI_NOT_FOUND;\r
+        }\r
+      }\r
+    }\r
+  }\r
+  //\r
+  // Return the record\r
+  //\r
+  *Record = GetNextDataRecord (&Private->DataListHead, ClassFilter, MonotonicCount);\r
+  if (*Record == NULL) {\r
+    return EFI_NOT_FOUND;\r
+  }\r
+\r
+  if (FilterDriver != NULL) {\r
+    //\r
+    // If we have a filter driver update the records that have been read.\r
+    // If MonotonicCount is zero No more reacords left.\r
+    //\r
+    if (*MonotonicCount == 0) {\r
+      if (FilterMonotonicCount != 0) {\r
+        //\r
+        // Return the result of our extra GetNextDataRecord.\r
+        //\r
+        FilterDriver->GetNextMonotonicCount = FilterMonotonicCount;\r
+      }\r
+    } else {\r
+      //\r
+      // Point to next undread record\r
+      //\r
+      FilterDriver->GetNextMonotonicCount = *MonotonicCount;\r
+    }\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+STATIC\r
+EFI_STATUS\r
+EFIAPI\r
+DataHubRegisterFilterDriver (\r
+  IN EFI_DATA_HUB_PROTOCOL    * This,\r
+  IN EFI_EVENT                FilterEvent,\r
+  IN EFI_TPL                  FilterTpl,\r
+  IN UINT64                   FilterClass,\r
+  IN EFI_GUID                 * FilterDataRecordGuid OPTIONAL\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This function registers the data hub filter driver that is represented \r
+  by FilterEvent. Only one instance of each FilterEvent can be registered.\r
+  After the FilterEvent is registered, it will be signaled so it can sync \r
+  with data records that have been recorded prior to the FilterEvent being \r
+  registered.\r
+    \r
+Arguments:\r
+\r
+  This                  - The EFI_DATA_HUB_PROTOCOL instance.\r
+  FilterEvent           - The EFI_EVENT to signal whenever data that matches \r
+                          FilterClass is logged in the system.\r
+  FilterTpl             - The maximum EFI_TPL at which FilterEvent can be \r
+                          signaled. It is strongly recommended that you use the \r
+                          lowest EFI_TPL possible.\r
+  FilterClass           - FilterEvent will be signaled whenever a bit in \r
+                          EFI_DATA_RECORD_HEADER.DataRecordClass is also set in \r
+                          FilterClass. If FilterClass is zero, no class-based \r
+                          filtering will be performed.\r
+  FilterDataRecordGuid  - FilterEvent will be signaled whenever FilterDataRecordGuid \r
+                          matches EFI_DATA_RECORD_HEADER.DataRecordGuid. If \r
+                          FilterDataRecordGuid is NULL, then no GUID-based filtering \r
+                          will be performed.              \r
+Returns: \r
+\r
+  EFI_SUCCESS             - The filter driver event was registered.\r
+  EFI_ALREADY_STARTED     - FilterEvent was previously registered and cannot be \r
+                            registered again.\r
+  EFI_OUT_OF_RESOURCES    - The filter driver event was not registered due to lack of \r
+                            system resources.\r
+\r
+--*/\r
+{\r
+  DATA_HUB_INSTANCE       *Private;\r
+  DATA_HUB_FILTER_DRIVER  *FilterDriver;\r
+\r
+  Private       = DATA_HUB_INSTANCE_FROM_THIS (This);\r
+\r
+  FilterDriver  = (DATA_HUB_FILTER_DRIVER *) AllocateZeroPool (sizeof (DATA_HUB_FILTER_DRIVER));\r
+  if (FilterDriver == NULL) {\r
+    return EFI_OUT_OF_RESOURCES;\r
+  }\r
+  //\r
+  // Initialize filter driver info\r
+  //\r
+  FilterDriver->Signature             = EFI_DATA_HUB_FILTER_DRIVER_SIGNATURE;\r
+  FilterDriver->Event                 = FilterEvent;\r
+  FilterDriver->Tpl                   = FilterTpl;\r
+  FilterDriver->GetNextMonotonicCount = 0;\r
+  if (FilterClass == 0) {\r
+    FilterDriver->ClassFilter = EFI_DATA_RECORD_CLASS_DEBUG |\r
+      EFI_DATA_RECORD_CLASS_ERROR |\r
+      EFI_DATA_RECORD_CLASS_DATA |\r
+      EFI_DATA_RECORD_CLASS_PROGRESS_CODE;\r
+  } else {\r
+    FilterDriver->ClassFilter = FilterClass;\r
+  }\r
+\r
+  if (FilterDataRecordGuid != NULL) {\r
+    CopyMem (&FilterDriver->FilterDataRecordGuid, FilterDataRecordGuid, sizeof (EFI_GUID));\r
+  }\r
+  //\r
+  // Search for duplicate entries\r
+  //\r
+  if (FindFilterDriverByEvent (&Private->FilterDriverListHead, FilterEvent) != NULL) {\r
+    FreePool (FilterDriver);\r
+    return EFI_ALREADY_STARTED;\r
+  }\r
+  //\r
+  // Make insertion an atomic operation with the lock.\r
+  //\r
+  EfiAcquireLock (&Private->DataLock);\r
+  InsertTailList (&Private->FilterDriverListHead, &FilterDriver->Link);\r
+  EfiReleaseLock (&Private->DataLock);\r
+\r
+  //\r
+  // Signal the Filter driver we just loaded so they will recieve all the\r
+  // previous history. If we did not signal here we would have to wait until\r
+  // the next data was logged to get the history. In a case where no next\r
+  // data was logged we would never get synced up.\r
+  //\r
+  gBS->SignalEvent (FilterEvent);\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+STATIC\r
+EFI_STATUS\r
+EFIAPI\r
+DataHubUnregisterFilterDriver (\r
+  IN EFI_DATA_HUB_PROTOCOL    *This,\r
+  IN EFI_EVENT                FilterEvent\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Remove a Filter Driver, so it no longer gets called when data \r
+   information is logged.\r
+\r
+Arguments:\r
+\r
+  This        - Protocol instance structure\r
+\r
+  FilterEvent - Event that represents a filter driver that is to be \r
+                 Unregistered.\r
+\r
+Returns: \r
+\r
+  EFI_SUCCESS   - If FilterEvent was unregistered\r
+\r
+  EFI_NOT_FOUND - If FilterEvent does not exist\r
+\r
+--*/\r
+{\r
+  DATA_HUB_INSTANCE       *Private;\r
+  DATA_HUB_FILTER_DRIVER  *FilterDriver;\r
+\r
+  Private = DATA_HUB_INSTANCE_FROM_THIS (This);\r
+\r
+  //\r
+  // Search for duplicate entries\r
+  //\r
+  FilterDriver = FindFilterDriverByEvent (\r
+                  &Private->FilterDriverListHead,\r
+                  FilterEvent\r
+                  );\r
+  if (FilterDriver == NULL) {\r
+    return EFI_NOT_FOUND;\r
+  }\r
+  //\r
+  // Make removal an atomic operation with the lock\r
+  //\r
+  EfiAcquireLock (&Private->DataLock);\r
+  RemoveEntryList (&FilterDriver->Link);\r
+  EfiReleaseLock (&Private->DataLock);\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+//\r
+// STATIC Worker fucntions follow\r
+//\r
+STATIC\r
+DATA_HUB_FILTER_DRIVER *\r
+FindFilterDriverByEvent (\r
+  IN  LIST_ENTRY      *Head,\r
+  IN  EFI_EVENT       Event\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Search the Head list for a EFI_DATA_HUB_FILTER_DRIVER member that\r
+   represents Event and return it.\r
+\r
+Arguments:\r
+\r
+  Head  - Head of dual linked list of EFI_DATA_HUB_FILTER_DRIVER\r
+           structures.\r
+\r
+  Event - Event to be search for in the Head list.\r
+\r
+Returns: \r
+\r
+  EFI_DATA_HUB_FILTER_DRIVER - Returned if Event stored in the\r
+                               Head doubly linked list.\r
+\r
+  NULL - If Event is not in the list\r
+\r
+--*/\r
+{\r
+  DATA_HUB_FILTER_DRIVER  *FilterEntry;\r
+  LIST_ENTRY              *Link;\r
+\r
+  for (Link = Head->ForwardLink; Link != Head; Link = Link->ForwardLink) {\r
+    FilterEntry = FILTER_ENTRY_FROM_LINK (Link);\r
+    if (FilterEntry->Event == Event) {\r
+      return FilterEntry;\r
+    }\r
+  }\r
+\r
+  return NULL;\r
+}\r
+\r
+STATIC\r
+EFI_DATA_RECORD_HEADER *\r
+GetNextDataRecord (\r
+  IN  LIST_ENTRY          *Head,\r
+  IN  UINT64              ClassFilter,\r
+  IN OUT  UINT64          *PtrCurrentMTC\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Search the Head doubly linked list for the passed in MTC. Return the \r
+   matching element in Head and the MTC on the next entry.\r
+\r
+Arguments:\r
+\r
+  Head          - Head of Data Log linked list.\r
+\r
+  ClassFilter   - Only match the MTC if it is in the same Class as the\r
+                  ClassFilter.\r
+\r
+  PtrCurrentMTC - On IN contians MTC to search for. On OUT contians next\r
+                   MTC in the data log list or zero if at end of the list.\r
+  \r
+Returns:\r
+\r
+  EFI_DATA_LOG_ENTRY - Return pointer to data log data from Head list.\r
+\r
+  NULL - If no data record exists.\r
+\r
+--*/\r
+{\r
+  EFI_DATA_ENTRY          *LogEntry;\r
+  LIST_ENTRY              *Link;\r
+  BOOLEAN                 ReturnFirstEntry;\r
+  EFI_DATA_RECORD_HEADER  *Record;\r
+  EFI_DATA_ENTRY          *NextLogEntry;\r
+\r
+  //\r
+  // If MonotonicCount == 0 just return the first one\r
+  //\r
+  ReturnFirstEntry  = (BOOLEAN) (*PtrCurrentMTC == 0);\r
+\r
+  Record            = NULL;\r
+  for (Link = Head->ForwardLink; Link != Head; Link = Link->ForwardLink) {\r
+    LogEntry = DATA_ENTRY_FROM_LINK (Link);\r
+    if ((LogEntry->Record->DataRecordClass & ClassFilter) == 0) {\r
+      //\r
+      // Skip any entry that does not have the correct ClassFilter\r
+      //\r
+      continue;\r
+    }\r
+\r
+    if ((LogEntry->Record->LogMonotonicCount == *PtrCurrentMTC) || ReturnFirstEntry) {\r
+      //\r
+      // Return record to the user\r
+      //\r
+      Record = LogEntry->Record;\r
+\r
+      //\r
+      // Calculate the next MTC value. If there is no next entry set\r
+      // MTC to zero.\r
+      //\r
+      *PtrCurrentMTC = 0;\r
+      for (Link = Link->ForwardLink; Link != Head; Link = Link->ForwardLink) {\r
+        NextLogEntry = DATA_ENTRY_FROM_LINK (Link);\r
+        if ((NextLogEntry->Record->DataRecordClass & ClassFilter) != 0) {\r
+          //\r
+          // Return the MTC of the next thing to search for if found\r
+          //\r
+          *PtrCurrentMTC = NextLogEntry->Record->LogMonotonicCount;\r
+          break;\r
+        }\r
+      }\r
+      //\r
+      // Record found exit loop and return\r
+      //\r
+      break;\r
+    }\r
+  }\r
+\r
+  return Record;\r
+}\r
+//\r
+// Module Global:\r
+//  Since this driver will only ever produce one instance of the Logging Hub\r
+//  protocol you are not required to dynamically allocate the PrivateData.\r
+//\r
+DATA_HUB_INSTANCE mPrivateData;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+DataHubInstall (\r
+  IN EFI_HANDLE           ImageHandle,\r
+  IN EFI_SYSTEM_TABLE     *SystemTable\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Install Driver to produce Data Hub protocol. \r
+\r
+Arguments:\r
+  (Standard EFI Image entry - EFI_IMAGE_ENTRY_POINT)\r
+\r
+Returns: \r
+\r
+  EFI_SUCCESS - Logging Hub protocol installed\r
+\r
+  Other       - No protocol installed, unload driver.\r
+\r
+--*/\r
+{\r
+  EFI_STATUS  Status;\r
+  UINT32      HighMontonicCount;\r
+\r
+  mPrivateData.Signature                      = DATA_HUB_INSTANCE_SIGNATURE;\r
+  mPrivateData.DataHub.LogData                = DataHubLogData;\r
+  mPrivateData.DataHub.GetNextRecord          = DataHubGetNextRecord;\r
+  mPrivateData.DataHub.RegisterFilterDriver   = DataHubRegisterFilterDriver;\r
+  mPrivateData.DataHub.UnregisterFilterDriver = DataHubUnregisterFilterDriver;\r
+\r
+  //\r
+  // Initialize Private Data in CORE_LOGGING_HUB_INSTANCE that is\r
+  //  required by this protocol\r
+  //\r
+  InitializeListHead (&mPrivateData.DataListHead);\r
+  InitializeListHead (&mPrivateData.FilterDriverListHead);\r
+\r
+  EfiInitializeLock (&mPrivateData.DataLock, TPL_NOTIFY);\r
+\r
+  //\r
+  // Make sure we get a bigger MTC number on every boot!\r
+  //\r
+  Status = gRT->GetNextHighMonotonicCount (&HighMontonicCount);\r
+  if (EFI_ERROR (Status)) {\r
+    //\r
+    // if system service fails pick a sane value.\r
+    //\r
+    mPrivateData.GlobalMonotonicCount = 0;\r
+  } else {\r
+    mPrivateData.GlobalMonotonicCount = LShiftU64 ((UINT64) HighMontonicCount, 32);\r
+  }\r
+  //\r
+  // Make a new handle and install the protocol\r
+  //\r
+  mPrivateData.Handle = NULL;\r
+  Status = gBS->InstallProtocolInterface (\r
+                  &mPrivateData.Handle,\r
+                  &gEfiDataHubProtocolGuid,\r
+                  EFI_NATIVE_INTERFACE,\r
+                  &mPrivateData.DataHub\r
+                  );\r
+  return Status;\r
+}\r
diff --git a/IntelFrameworkModulePkg/Universal/DataHub/DataHub/Dxe/DataHub.dxs b/IntelFrameworkModulePkg/Universal/DataHub/DataHub/Dxe/DataHub.dxs
new file mode 100644 (file)
index 0000000..226acc5
--- /dev/null
@@ -0,0 +1,25 @@
+/*++\r
+\r
+Copyright (c) 2006, 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
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  DataHub.dxs\r
+\r
+Abstract:\r
+\r
+  Dependency expression source file.\r
+  \r
+--*/  \r
+#include <DxeDepex.h>\r
+\r
+DEPENDENCY_START\r
+  TRUE\r
+DEPENDENCY_END\r
diff --git a/IntelFrameworkModulePkg/Universal/DataHub/DataHub/Dxe/DataHub.h b/IntelFrameworkModulePkg/Universal/DataHub/DataHub/Dxe/DataHub.h
new file mode 100644 (file)
index 0000000..8f90e99
--- /dev/null
@@ -0,0 +1,141 @@
+/*++\r
+\r
+Copyright (c) 2006, 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
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  DataHub.h\r
+\r
+Abstract:\r
+  This code supports a the private implementation \r
+  of the Data Hub protocol\r
+\r
+--*/\r
+\r
+#ifndef _DATA_HUB_H_\r
+#define _DATA_HUB_H_\r
+\r
+//\r
+// The package level header files this module uses\r
+//\r
+#include <PiDxe.h>\r
+//\r
+// The protocols, PPI and GUID defintions for this module\r
+//\r
+#include <Protocol/DataHub.h>\r
+//\r
+// The Library classes this module consumes\r
+//\r
+#include <Library/DebugLib.h>\r
+#include <Library/UefiDriverEntryPoint.h>\r
+#include <Library/UefiLib.h>\r
+#include <Library/BaseLib.h>\r
+#include <Library/BaseMemoryLib.h>\r
+#include <Library/MemoryAllocationLib.h>\r
+#include <Library/UefiBootServicesTableLib.h>\r
+#include <Library/UefiRuntimeServicesTableLib.h>\r
+\r
+#define DATA_HUB_INSTANCE_SIGNATURE EFI_SIGNATURE_32 ('D', 'H', 'u', 'b')\r
+typedef struct {\r
+  UINT32                Signature;\r
+\r
+  EFI_HANDLE            Handle;\r
+\r
+  //\r
+  // Produced protocol(s)\r
+  //\r
+  EFI_DATA_HUB_PROTOCOL DataHub;\r
+\r
+  //\r
+  // Private Data\r
+  //\r
+  //\r
+  // Updates to GlobalMonotonicCount, LogListHead, and FilterDriverListHead\r
+  //  must be locked.\r
+  //\r
+  EFI_LOCK              DataLock;\r
+\r
+  //\r
+  // Runing Monotonic Count to use for each error record.\r
+  //  Increment AFTER use in an error record.\r
+  //\r
+  UINT64                GlobalMonotonicCount;\r
+\r
+  //\r
+  // List of EFI_DATA_ENTRY structures. This is the data log! The list\r
+  //  must be in assending order of LogMonotonicCount.\r
+  //\r
+  LIST_ENTRY            DataListHead;\r
+\r
+  //\r
+  // List of EFI_DATA_HUB_FILTER_DRIVER structures. Represents all\r
+  //  the registered filter drivers.\r
+  //\r
+  LIST_ENTRY            FilterDriverListHead;\r
+\r
+} DATA_HUB_INSTANCE;\r
+\r
+#define DATA_HUB_INSTANCE_FROM_THIS(this) CR (this, DATA_HUB_INSTANCE, DataHub, DATA_HUB_INSTANCE_SIGNATURE)\r
+\r
+//\r
+// Private data structure to contain the data log. One record per\r
+//  structure. Head pointer to the list is the Log member of\r
+//  EFI_DATA_ENTRY. Record is a copy of the data passed in.\r
+//\r
+#define EFI_DATA_ENTRY_SIGNATURE  EFI_SIGNATURE_32 ('D', 'r', 'e', 'c')\r
+typedef struct {\r
+  UINT32                  Signature;\r
+  LIST_ENTRY              Link;\r
+\r
+  EFI_DATA_RECORD_HEADER  *Record;\r
+\r
+  UINTN                   RecordSize;\r
+\r
+} EFI_DATA_ENTRY;\r
+\r
+#define DATA_ENTRY_FROM_LINK(link)  CR (link, EFI_DATA_ENTRY, Link, EFI_DATA_ENTRY_SIGNATURE)\r
+\r
+//\r
+// Private data to contain the filter driver Event and it's\r
+//  associated EFI_TPL.\r
+//\r
+#define EFI_DATA_HUB_FILTER_DRIVER_SIGNATURE  EFI_SIGNATURE_32 ('D', 'h', 'F', 'd')\r
+\r
+typedef struct {\r
+  UINT32          Signature;\r
+  LIST_ENTRY      Link;\r
+\r
+  //\r
+  // Store Filter Driver Event and Tpl level it can be Signaled at.\r
+  //\r
+  EFI_EVENT       Event;\r
+  EFI_TPL         Tpl;\r
+\r
+  //\r
+  // Monotonic count on the get next operation for Event.\r
+  //  Zero indicates get next has not been called for this event yet.\r
+  //\r
+  UINT64          GetNextMonotonicCount;\r
+\r
+  //\r
+  // Filter driver will register what class filter should be used.\r
+  //\r
+  UINT64          ClassFilter;\r
+\r
+  //\r
+  // Filter driver will register what record guid filter should be used.\r
+  //\r
+  EFI_GUID        FilterDataRecordGuid;\r
+\r
+} DATA_HUB_FILTER_DRIVER;\r
+\r
+#define FILTER_ENTRY_FROM_LINK(link)  CR (link, DATA_HUB_FILTER_DRIVER, Link, EFI_DATA_HUB_FILTER_DRIVER_SIGNATURE)\r
+\r
+#endif\r
diff --git a/IntelFrameworkModulePkg/Universal/DataHub/DataHub/Dxe/DataHub.inf b/IntelFrameworkModulePkg/Universal/DataHub/DataHub/Dxe/DataHub.inf
new file mode 100644 (file)
index 0000000..279bb7b
--- /dev/null
@@ -0,0 +1,100 @@
+#/** @file\r
+# Component description file for DataHub module.\r
+#\r
+# This driver initializes and installs the Data Hub protocol.\r
+# Copyright (c) 2006 - 2007, Intel Corporation\r
+#\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
+#  http://opensource.org/licenses/bsd-license.php\r
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+#\r
+#\r
+#**/\r
+\r
+################################################################################\r
+#\r
+# Defines Section - statements that will be processed to create a Makefile.\r
+#\r
+################################################################################\r
+[Defines]\r
+  INF_VERSION                    = 0x00010005\r
+  BASE_NAME                      = DataHub\r
+  FILE_GUID                      = 53BCC14F-C24F-434C-B294-8ED2D4CC1860\r
+  MODULE_TYPE                    = DXE_DRIVER\r
+  VERSION_STRING                 = 1.0\r
+  EDK_RELEASE_VERSION            = 0x00020000\r
+  EFI_SPECIFICATION_VERSION      = 0x00020000\r
+\r
+  ENTRY_POINT                    = DataHubInstall\r
+\r
+#\r
+# The following information is for reference only and not required by the build tools.\r
+#\r
+#  VALID_ARCHITECTURES           = IA32 X64 IPF EBC\r
+#\r
+\r
+################################################################################\r
+#\r
+# Sources Section - list of files that are required for the build to succeed.\r
+#\r
+################################################################################\r
+\r
+[Sources.common]\r
+  DataHub.h\r
+  DataHub.c\r
+\r
+\r
+################################################################################\r
+#\r
+# Package Dependency Section - list of Package files that are required for\r
+#                              this module.\r
+#\r
+################################################################################\r
+\r
+[Packages]\r
+  IntelFrameworkPkg/IntelFrameworkPkg.dec\r
+  MdePkg/MdePkg.dec\r
+\r
+\r
+################################################################################\r
+#\r
+# Library Class Section - list of Library Classes that are required for\r
+#                         this module.\r
+#\r
+################################################################################\r
+\r
+[LibraryClasses]\r
+  UefiRuntimeServicesTableLib\r
+  UefiBootServicesTableLib\r
+  MemoryAllocationLib\r
+  BaseMemoryLib\r
+  BaseLib\r
+  UefiLib\r
+  UefiDriverEntryPoint\r
+  DebugLib\r
+\r
+\r
+################################################################################\r
+#\r
+# Protocol C Name Section - list of Protocol and Protocol Notify C Names\r
+#                           that this module uses or produces.\r
+#\r
+################################################################################\r
+\r
+[Protocols]\r
+  gEfiDataHubProtocolGuid                       # PROTOCOL ALWAYS_PRODUCED\r
+\r
+\r
+################################################################################\r
+#\r
+# Dependency Expression Section - list of Dependency expressions that are required for\r
+#                              this module.\r
+#\r
+################################################################################\r
+\r
+[Depex]\r
+  TRUE\r
+\r
diff --git a/IntelFrameworkModulePkg/Universal/DataHub/DataHub/Dxe/DataHub.msa b/IntelFrameworkModulePkg/Universal/DataHub/DataHub/Dxe/DataHub.msa
new file mode 100644 (file)
index 0000000..d51f606
--- /dev/null
@@ -0,0 +1,71 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<ModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">\r
+  <MsaHeader>\r
+    <ModuleName>DataHub</ModuleName>\r
+    <ModuleType>DXE_DRIVER</ModuleType>\r
+    <GuidValue>53BCC14F-C24F-434C-B294-8ED2D4CC1860</GuidValue>\r
+    <Version>1.0</Version>\r
+    <Abstract>Component description file for DataHub module.</Abstract>\r
+    <Description>This driver initializes and installs the Data Hub protocol.</Description>\r
+    <Copyright>Copyright (c) 2006 - 2007, Intel Corporation</Copyright>\r
+    <License>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
+      http://opensource.org/licenses/bsd-license.php\r
+      THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+      WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.</License>\r
+    <Specification>FRAMEWORK_BUILD_PACKAGING_SPECIFICATION   0x00000052</Specification>\r
+  </MsaHeader>\r
+  <ModuleDefinitions>\r
+    <SupportedArchitectures>IA32 X64 IPF EBC</SupportedArchitectures>\r
+    <BinaryModule>false</BinaryModule>\r
+    <OutputFileBasename>DataHub</OutputFileBasename>\r
+  </ModuleDefinitions>\r
+  <LibraryClassDefinitions>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>DebugLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>UefiDriverEntryPoint</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>UefiLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>BaseLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>BaseMemoryLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>MemoryAllocationLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>UefiBootServicesTableLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>UefiRuntimeServicesTableLib</Keyword>\r
+    </LibraryClass>\r
+  </LibraryClassDefinitions>\r
+  <SourceFiles>\r
+    <Filename>DataHub.c</Filename>\r
+    <Filename>DataHub.h</Filename>\r
+    <Filename>DataHub.dxs</Filename>\r
+  </SourceFiles>\r
+  <PackageDependencies>\r
+    <Package PackageGuid="1E73767F-8F52-4603-AEB4-F29B510B6766"/>\r
+    <Package PackageGuid="2759ded5-bb57-4b06-af4f-c398fa552719"/>\r
+  </PackageDependencies>\r
+  <Protocols>\r
+    <Protocol Usage="ALWAYS_PRODUCED">\r
+      <ProtocolCName>gEfiDataHubProtocolGuid</ProtocolCName>\r
+    </Protocol>\r
+  </Protocols>\r
+  <Externs>\r
+    <Specification>EFI_SPECIFICATION_VERSION 0x00020000</Specification>\r
+    <Specification>EDK_RELEASE_VERSION 0x00020000</Specification>\r
+    <Extern>\r
+      <ModuleEntryPoint>DataHubInstall</ModuleEntryPoint>\r
+    </Extern>\r
+  </Externs>\r
+</ModuleSurfaceArea>\r
diff --git a/IntelFrameworkModulePkg/Universal/DataHub/DataHubStdErr/Dxe/DataHubStdErr.c b/IntelFrameworkModulePkg/Universal/DataHub/DataHubStdErr/Dxe/DataHubStdErr.c
new file mode 100644 (file)
index 0000000..50e40c0
--- /dev/null
@@ -0,0 +1,181 @@
+/*++\r
+\r
+Copyright (c) 2006, 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
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+Module Name:\r
+\r
+  DataHubStdErr.c\r
+\r
+Abstract:\r
+\r
+  Data Hub filter driver that takes DEBUG () info from Data Hub and writes it\r
+  to StdErr if it exists.\r
+\r
+--*/\r
+\r
+//\r
+// The package level header files this module uses\r
+//\r
+#include <PiDxe.h>\r
+#include <Common/FrameworkStatusCode.h>\r
+//\r
+// The protocols, PPI and GUID defintions for this module\r
+//\r
+#include <Guid/StatusCode.h>\r
+#include <Guid/StatusCodeDataTypeId.h>\r
+#include <Protocol/DataHub.h>\r
+#include <Protocol/SimpleTextOut.h>\r
+//\r
+// The Library classes this module consumes\r
+//\r
+#include <Library/DebugLib.h>\r
+#include <Library/UefiDriverEntryPoint.h>\r
+#include <Library/BaseMemoryLib.h>\r
+#include <Library/UefiBootServicesTableLib.h>\r
+\r
+EFI_DATA_HUB_PROTOCOL *mDataHub = NULL;\r
+\r
+EFI_EVENT             mDataHubStdErrEvent;\r
+\r
+STATIC\r
+VOID\r
+EFIAPI\r
+DataHubStdErrEventHandler (\r
+  IN EFI_EVENT Event,\r
+  IN VOID      *Context\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Event handler registered with the Data Hub to parse EFI_DEBUG_CODE. This\r
+  handler reads the Data Hub and sends any DEBUG info to StdErr.\r
+\r
+Arguments:\r
+  Event    - The event that occured, not used\r
+  Context  - DataHub Protocol Pointer\r
+\r
+Returns:\r
+  None.\r
+\r
+--*/\r
+{\r
+  EFI_STATUS                           Status;\r
+  EFI_DATA_HUB_PROTOCOL                *DataHub;\r
+  EFI_DATA_RECORD_HEADER               *Record;\r
+  DATA_HUB_STATUS_CODE_DATA_RECORD     *DataRecord;\r
+  UINT64                               Mtc;\r
+  EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL      *Sto;\r
+  INT32                                OldAttribute;\r
+\r
+  DataHub = (EFI_DATA_HUB_PROTOCOL *) Context;\r
+\r
+  //\r
+  // If StdErr is not yet initialized just return a DEBUG print in the BDS\r
+  // after consoles are connect will make sure data gets flushed properly\r
+  // when StdErr is availible.\r
+  //\r
+  if (gST == NULL) {\r
+    return ;\r
+  }\r
+\r
+  if (gST->StdErr == NULL) {\r
+    return ;\r
+  }\r
+  //\r
+  // Mtc of zero means return the next record that has not been read by the\r
+  // event handler.\r
+  //\r
+  Mtc = 0;\r
+  do {\r
+    Status = DataHub->GetNextRecord (DataHub, &Mtc, &mDataHubStdErrEvent, &Record);\r
+    if (!EFI_ERROR (Status)) {\r
+      if (CompareGuid (&Record->DataRecordGuid, &gEfiStatusCodeGuid)) {\r
+        DataRecord = (DATA_HUB_STATUS_CODE_DATA_RECORD *) (((CHAR8 *) Record) + Record->HeaderSize);\r
+\r
+        if (DataRecord->Data.HeaderSize > 0) {\r
+          if (CompareGuid (&DataRecord->Data.Type, &gEfiStatusCodeDataTypeDebugGuid)) {\r
+            //\r
+            // If the Data record is from a DEBUG () then send it to Standard Error\r
+            //\r
+            Sto           = gST->StdErr;\r
+            OldAttribute  = Sto->Mode->Attribute;\r
+            Sto->SetAttribute (Sto, EFI_TEXT_ATTR (EFI_MAGENTA, EFI_BLACK));\r
+            Sto->OutputString (Sto, (CHAR16 *) (DataRecord + 1));\r
+            Sto->SetAttribute (Sto, OldAttribute);\r
+          }\r
+        }\r
+      }\r
+    }\r
+  } while ((Mtc != 0) && !EFI_ERROR (Status));\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+DataHubStdErrInitialize (\r
+  IN EFI_HANDLE         ImageHandle,\r
+  IN EFI_SYSTEM_TABLE   *SystemTable\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Register an event handler with the Data Hub to parse EFI_DEBUG_CODE. This\r
+  handler reads the Data Hub and sends any DEBUG info to StdErr.\r
+\r
+Arguments:\r
+\r
+  ImageHandle - Image handle of this driver.\r
+  SystemTable - Pointer to EFI system table.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS             - The event handler was registered.\r
+  EFI_OUT_OF_RESOURCES    - The event hadler was not registered due to lack of\r
+                            system resources.\r
+\r
+--*/\r
+{\r
+  EFI_STATUS  Status;\r
+  UINT64      DataClass;\r
+\r
+  gBS->LocateProtocol (&gEfiDataHubProtocolGuid, NULL, (VOID **) &mDataHub);\r
+  //\r
+  // Should never fail due to Depex grammer.\r
+  //\r
+  ASSERT (mDataHub != NULL);\r
+\r
+  //\r
+  // Create an event and register it with the filter driver\r
+  //\r
+  Status = gBS->CreateEvent (\r
+                  EVT_NOTIFY_SIGNAL,\r
+                  TPL_CALLBACK,\r
+                  DataHubStdErrEventHandler,\r
+                  mDataHub,\r
+                  &mDataHubStdErrEvent\r
+                  );\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  DataClass = EFI_DATA_RECORD_CLASS_DEBUG | EFI_DATA_RECORD_CLASS_ERROR;\r
+  Status = mDataHub->RegisterFilterDriver (\r
+                      mDataHub,\r
+                      mDataHubStdErrEvent,\r
+                      TPL_CALLBACK,\r
+                      DataClass,\r
+                      NULL\r
+                      );\r
+  if (EFI_ERROR (Status)) {\r
+    gBS->CloseEvent (mDataHubStdErrEvent);\r
+  }\r
+\r
+  return Status;\r
+}\r
diff --git a/IntelFrameworkModulePkg/Universal/DataHub/DataHubStdErr/Dxe/DataHubStdErr.dxs b/IntelFrameworkModulePkg/Universal/DataHub/DataHubStdErr/Dxe/DataHubStdErr.dxs
new file mode 100644 (file)
index 0000000..9603a3e
--- /dev/null
@@ -0,0 +1,26 @@
+/*++\r
+\r
+Copyright (c) 2006, 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
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+  \r
+    DataHubStdErr.dxs\r
+\r
+Abstract:\r
+\r
+  Dependency expression source file.\r
+  \r
+--*/  \r
+#include <DxeDepex.h>\r
+\r
+\r
+DEPENDENCY_START\r
+  EFI_DATA_HUB_PROTOCOL_GUID \r
+DEPENDENCY_END\r
diff --git a/IntelFrameworkModulePkg/Universal/DataHub/DataHubStdErr/Dxe/DataHubStdErr.inf b/IntelFrameworkModulePkg/Universal/DataHub/DataHubStdErr/Dxe/DataHubStdErr.inf
new file mode 100644 (file)
index 0000000..728e634
--- /dev/null
@@ -0,0 +1,111 @@
+#/** @file\r
+# Component description file for Data Hub filter driver.\r
+#\r
+# This driver takes DEBUG () info from Data Hub and writes it to StdErr if it exists.\r
+# Copyright (c) 2006 - 2007, Intel Corporation\r
+#\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
+#  http://opensource.org/licenses/bsd-license.php\r
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+#\r
+#\r
+#**/\r
+\r
+################################################################################\r
+#\r
+# Defines Section - statements that will be processed to create a Makefile.\r
+#\r
+################################################################################\r
+[Defines]\r
+  INF_VERSION                    = 0x00010005\r
+  BASE_NAME                      = DataHubStdErr\r
+  FILE_GUID                      = CA515306-00CE-4032-874E-11B755FF6866\r
+  MODULE_TYPE                    = DXE_DRIVER\r
+  VERSION_STRING                 = 1.0\r
+  EDK_RELEASE_VERSION            = 0x00020000\r
+  EFI_SPECIFICATION_VERSION      = 0x00020000\r
+\r
+  ENTRY_POINT                    = DataHubStdErrInitialize\r
+\r
+#\r
+# The following information is for reference only and not required by the build tools.\r
+#\r
+#  VALID_ARCHITECTURES           = IA32 X64 IPF EBC\r
+#\r
+\r
+################################################################################\r
+#\r
+# Sources Section - list of files that are required for the build to succeed.\r
+#\r
+################################################################################\r
+\r
+[Sources.common]\r
+  DataHubStdErr.c\r
+\r
+[Includes]\r
+  IntelFrameworkModulePkg/Include\r
+\r
+################################################################################\r
+#\r
+# Package Dependency Section - list of Package files that are required for\r
+#                              this module.\r
+#\r
+################################################################################\r
+\r
+[Packages]\r
+  MdePkg/MdePkg.dec\r
+  IntelFrameworkPkg/IntelFrameworkPkg.dec\r
+  IntelFrameworkModulePkg/IntelFrameworkModulePkg.dec\r
+\r
+\r
+\r
+\r
+################################################################################\r
+#\r
+# Library Class Section - list of Library Classes that are required for\r
+#                         this module.\r
+#\r
+################################################################################\r
+\r
+[LibraryClasses]\r
+  UefiBootServicesTableLib\r
+  BaseMemoryLib\r
+  UefiDriverEntryPoint\r
+  DebugLib\r
+\r
+\r
+################################################################################\r
+#\r
+# Guid C Name Section - list of Guids that this module uses or produces.\r
+#\r
+################################################################################\r
+\r
+[Guids]\r
+  gEfiStatusCodeDataTypeDebugGuid               # SOMETIMES_CONSUMED\r
+  gEfiStatusCodeGuid                            # SOMETIMES_CONSUMED\r
+\r
+\r
+################################################################################\r
+#\r
+# Protocol C Name Section - list of Protocol and Protocol Notify C Names\r
+#                           that this module uses or produces.\r
+#\r
+################################################################################\r
+\r
+[Protocols]\r
+  gEfiDataHubProtocolGuid                       # PROTOCOL ALWAYS_CONSUMED\r
+\r
+\r
+################################################################################\r
+#\r
+# Dependency Expression Section - list of Dependency expressions that are required for\r
+#                              this module.\r
+#\r
+################################################################################\r
+\r
+[Depex]\r
+  gEfiDataHubProtocolGuid\r
+\r
diff --git a/IntelFrameworkModulePkg/Universal/DataHub/DataHubStdErr/Dxe/DataHubStdErr.msa b/IntelFrameworkModulePkg/Universal/DataHub/DataHubStdErr/Dxe/DataHubStdErr.msa
new file mode 100644 (file)
index 0000000..b1d4c61
--- /dev/null
@@ -0,0 +1,73 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<ModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">\r
+  <MsaHeader>\r
+    <ModuleName>DataHubStdErr</ModuleName>\r
+    <ModuleType>DXE_DRIVER</ModuleType>\r
+    <GuidValue>CA515306-00CE-4032-874E-11B755FF6866</GuidValue>\r
+    <Version>1.0</Version>\r
+    <Abstract>Component description file for Data Hub filter driver.</Abstract>\r
+    <Description>This driver takes DEBUG () info from Data Hub and writes it to StdErr if it exists.</Description>\r
+    <Copyright>Copyright (c) 2006 - 2007, Intel Corporation</Copyright>\r
+    <License>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
+      http://opensource.org/licenses/bsd-license.php\r
+      THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+      WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.</License>\r
+    <Specification>FRAMEWORK_BUILD_PACKAGING_SPECIFICATION   0x00000052</Specification>\r
+  </MsaHeader>\r
+  <ModuleDefinitions>\r
+    <SupportedArchitectures>IA32 X64 IPF EBC</SupportedArchitectures>\r
+    <BinaryModule>false</BinaryModule>\r
+    <OutputFileBasename>DataHubStdErr</OutputFileBasename>\r
+  </ModuleDefinitions>\r
+  <LibraryClassDefinitions>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>DebugLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>UefiDriverEntryPoint</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>BaseMemoryLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>UefiBootServicesTableLib</Keyword>\r
+    </LibraryClass>\r
+  </LibraryClassDefinitions>\r
+  <SourceFiles>\r
+    <Filename>DataHubStdErr.c</Filename>\r
+    <Filename>DataHubStdErr.dxs</Filename>\r
+  </SourceFiles>\r
+  <PackageDependencies>\r
+    <Package PackageGuid="1E73767F-8F52-4603-AEB4-F29B510B6766"/>\r
+    <Package PackageGuid="2759ded5-bb57-4b06-af4f-c398fa552719"/>\r
+    <Package PackageGuid="88894582-7553-4822-B484-624E24B6DECF"/>\r
+  </PackageDependencies>\r
+  <Protocols>\r
+    <Protocol Usage="ALWAYS_CONSUMED">\r
+      <ProtocolCName>gEfiDataHubProtocolGuid</ProtocolCName>\r
+    </Protocol>\r
+  </Protocols>\r
+  <DataHubs>\r
+    <DataHubRecord Usage="SOMETIMES_CONSUMED">\r
+      <DataHubCName>DATA_HUB_STATUS_CODE_DATA_RECORD</DataHubCName>\r
+      <HelpText>DEBUG() data that is recorded in status code data hub will be sent to Standard Error.</HelpText>\r
+    </DataHubRecord>\r
+  </DataHubs>\r
+  <Guids>\r
+    <GuidCNames Usage="SOMETIMES_CONSUMED">\r
+      <GuidCName>gEfiStatusCodeGuid</GuidCName>\r
+    </GuidCNames>\r
+    <GuidCNames Usage="SOMETIMES_CONSUMED">\r
+      <GuidCName>gEfiStatusCodeDataTypeDebugGuid</GuidCName>\r
+    </GuidCNames>\r
+  </Guids>\r
+  <Externs>\r
+    <Specification>EFI_SPECIFICATION_VERSION 0x00020000</Specification>\r
+    <Specification>EDK_RELEASE_VERSION 0x00020000</Specification>\r
+    <Extern>\r
+      <ModuleEntryPoint>DataHubStdErrInitialize</ModuleEntryPoint>\r
+    </Extern>\r
+  </Externs>\r
+</ModuleSurfaceArea>\r