This patch includes:

1) Update and refine functions/header files comments
2) Try to use LinkedList library instance produced by BaseLib but not access linked list via pointer directly.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@8641 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
klu2 2009-06-24 05:49:49 +00:00
parent b4b6c8de1e
commit 2ab239290d
2 changed files with 97 additions and 102 deletions

View File

@ -2,16 +2,7 @@
This code produces the Data Hub protocol. It preloads the data hub This code produces the Data Hub protocol. It preloads the data hub
with status information copied in from PEI HOBs. with status information copied in from PEI HOBs.
Only code that implements the Data Hub protocol should go in this file! Copyright (c) 2006 - 2009, Intel Corporation
The Term MTC stands for MonoTonicCounter.
For more information please look at DataHub.doc
NOTE: For extra security of the log GetNextDataRecord () could return a copy
of the data record.
Copyright (c) 2006, Intel Corporation
All rights reserved. This program and the accompanying materials All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at which accompanies this distribution. The full text of the license may be found at
@ -27,7 +18,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
CONST EFI_GUID gZeroGuid = { 0, 0, 0, { 0, 0, 0, 0, 0, 0, 0, 0 } }; CONST EFI_GUID gZeroGuid = { 0, 0, 0, { 0, 0, 0, 0, 0, 0, 0, 0 } };
// //
// Module Global:
// Since this driver will only ever produce one instance of the Logging Hub // Since this driver will only ever produce one instance of the Logging Hub
// protocol you are not required to dynamically allocate the PrivateData. // protocol you are not required to dynamically allocate the PrivateData.
// //
@ -50,18 +40,17 @@ GetNextDataRecord (
); );
/** /**
Log data record into the data logging hub Log data record into the data logging hub
@param This - Protocol instance structure @param This Protocol instance structure
@param DataRecordGuid - GUID that defines record contents @param DataRecordGuid GUID that defines record contents
@param ProducerName - GUID that defines the name of the producer of the data @param ProducerName GUID that defines the name of the producer of the data
@param DataRecordClass - Class that defines generic record type @param DataRecordClass Class that defines generic record type
@param RawData - Data Log record as defined by DataRecordGuid @param RawData Data Log record as defined by DataRecordGuid
@param RawDataSize - Size of Data Log data in bytes @param RawDataSize Size of Data Log data in bytes
@retval EFI_SUCCESS - If data was logged @retval EFI_SUCCESS If data was logged
@retval EFI_OUT_OF_RESOURCES - If data was not logged due to lack of system @retval EFI_OUT_OF_RESOURCES If data was not logged due to lack of system
resources. resources.
**/ **/
EFI_STATUS EFI_STATUS
@ -156,7 +145,7 @@ DataHubLogData (
// in the record's class and guid. // in the record's class and guid.
// //
Head = &Private->FilterDriverListHead; Head = &Private->FilterDriverListHead;
for (Link = Head->ForwardLink; Link != Head; Link = Link->ForwardLink) { for (Link = GetFirstNode(Head); Link != Head; Link = GetNextNode(Head, Link)) {
FilterEntry = FILTER_ENTRY_FROM_LINK (Link); FilterEntry = FILTER_ENTRY_FROM_LINK (Link);
if (((FilterEntry->ClassFilter & DataRecordClass) != 0) && if (((FilterEntry->ClassFilter & DataRecordClass) != 0) &&
(CompareGuid (&FilterEntry->FilterDataRecordGuid, &gZeroGuid) || (CompareGuid (&FilterEntry->FilterDataRecordGuid, &gZeroGuid) ||
@ -177,7 +166,7 @@ DataHubLogData (
not yet read by the filter driver. If FilterDriverEvent is NULL and not yet read by the filter driver. If FilterDriverEvent is NULL and
MonotonicCount is zero return the first data record. MonotonicCount is zero return the first data record.
@param This The EFI_DATA_HUB_PROTOCOL instance. @param This Pointer to the EFI_DATA_HUB_PROTOCOL instance.
@param MonotonicCount Specifies the Record to return. On input, zero means @param MonotonicCount Specifies the Record to return. On input, zero means
return the first record. On output, contains the next return the first record. On output, contains the next
record to availible. Zero indicates no more records. record to availible. Zero indicates no more records.
@ -189,12 +178,12 @@ DataHubLogData (
@param Record Returns a dynamically allocated memory buffer with a data @param Record Returns a dynamically allocated memory buffer with a data
record that matches MonotonicCount. record that matches MonotonicCount.
@retval EFI_SUCCESS - Data was returned in Record. @retval EFI_SUCCESS Data was returned in Record.
@retval EFI_INVALID_PARAMETER - FilterDriverEvent was passed in but does not exist. @retval EFI_INVALID_PARAMETER FilterDriverEvent was passed in but does not exist.
@retval EFI_NOT_FOUND - MonotonicCount does not match any data record in the @retval EFI_NOT_FOUND MonotonicCount does not match any data record in the
system. If a MonotonicCount of zero was passed in, then system. If a MonotonicCount of zero was passed in, then
no data records exist in the system. no data records exist in the system.
@retval EFI_OUT_OF_RESOURCES - Record was not returned due to lack of system resources. @retval EFI_OUT_OF_RESOURCES Record was not returned due to lack of system resources.
**/ **/
EFI_STATUS EFI_STATUS
@ -298,25 +287,25 @@ DataHubGetNextRecord (
with data records that have been recorded prior to the FilterEvent being with data records that have been recorded prior to the FilterEvent being
registered. registered.
@param This - The EFI_DATA_HUB_PROTOCOL instance. @param This Pointer to The EFI_DATA_HUB_PROTOCOL instance.
@param FilterEvent - The EFI_EVENT to signal whenever data that matches @param FilterEvent The EFI_EVENT to signal whenever data that matches
FilterClass is logged in the system. FilterClass is logged in the system.
@param FilterTpl - The maximum EFI_TPL at which FilterEvent can be @param FilterTpl The maximum EFI_TPL at which FilterEvent can be
signaled. It is strongly recommended that you use the signaled. It is strongly recommended that you use the
lowest EFI_TPL possible. lowest EFI_TPL possible.
@param FilterClass - FilterEvent will be signaled whenever a bit in @param FilterClass FilterEvent will be signaled whenever a bit in
EFI_DATA_RECORD_HEADER.DataRecordClass is also set in EFI_DATA_RECORD_HEADER.DataRecordClass is also set in
FilterClass. If FilterClass is zero, no class-based FilterClass. If FilterClass is zero, no class-based
filtering will be performed. filtering will be performed.
@param FilterDataRecordGuid - FilterEvent will be signaled whenever FilterDataRecordGuid @param FilterDataRecordGuid FilterEvent will be signaled whenever FilterDataRecordGuid
matches EFI_DATA_RECORD_HEADER.DataRecordGuid. If matches EFI_DATA_RECORD_HEADER.DataRecordGuid. If
FilterDataRecordGuid is NULL, then no GUID-based filtering FilterDataRecordGuid is NULL, then no GUID-based filtering
will be performed. will be performed.
@retval EFI_SUCCESS - The filter driver event was registered. @retval EFI_SUCCESS The filter driver event was registered.
@retval EFI_ALREADY_STARTED - FilterEvent was previously registered and cannot be @retval EFI_ALREADY_STARTED FilterEvent was previously registered and cannot be
registered again. registered again.
@retval EFI_OUT_OF_RESOURCES - The filter driver event was not registered due to lack of @retval EFI_OUT_OF_RESOURCES The filter driver event was not registered due to lack of
system resources. system resources.
**/ **/
@ -388,15 +377,13 @@ DataHubRegisterFilterDriver (
Remove a Filter Driver, so it no longer gets called when data Remove a Filter Driver, so it no longer gets called when data
information is logged. information is logged.
@param This - Protocol instance structure @param This Protocol instance structure
@param FilterEvent - Event that represents a filter driver that is to be @param FilterEvent Event that represents a filter driver that is to be
Unregistered. Unregistered.
@retval EFI_SUCCESS - If FilterEvent was unregistered @retval EFI_SUCCESS If FilterEvent was unregistered
@retval EFI_NOT_FOUND If FilterEvent does not exist
@retval EFI_NOT_FOUND - If FilterEvent does not exist
**/ **/
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
@ -434,15 +421,11 @@ DataHubUnregisterFilterDriver (
Search the Head list for a EFI_DATA_HUB_FILTER_DRIVER member that Search the Head list for a EFI_DATA_HUB_FILTER_DRIVER member that
represents Event and return it. represents Event and return it.
@param Head - Head of dual linked list of EFI_DATA_HUB_FILTER_DRIVER @param Head Pointer to head of dual linked list of EFI_DATA_HUB_FILTER_DRIVER structures.
structures. @param Event Event to be search for in the Head list.
@param Event - Event to be search for in the Head list. @retval EFI_DATA_HUB_FILTER_DRIVER Returned if Event stored in the Head doubly linked list.
@retval NULL If Event is not in the list
@retval EFI_DATA_HUB_FILTER_DRIVER - Returned if Event stored in the
Head doubly linked list.
@retval NULL - If Event is not in the list
**/ **/
DATA_HUB_FILTER_DRIVER * DATA_HUB_FILTER_DRIVER *
@ -450,12 +433,11 @@ FindFilterDriverByEvent (
IN LIST_ENTRY *Head, IN LIST_ENTRY *Head,
IN EFI_EVENT Event IN EFI_EVENT Event
) )
{ {
DATA_HUB_FILTER_DRIVER *FilterEntry; DATA_HUB_FILTER_DRIVER *FilterEntry;
LIST_ENTRY *Link; LIST_ENTRY *Link;
for (Link = Head->ForwardLink; Link != Head; Link = Link->ForwardLink) { for (Link = GetFirstNode(Head); Link != Head; Link = GetNextNode(Head, Link)) {
FilterEntry = FILTER_ENTRY_FROM_LINK (Link); FilterEntry = FILTER_ENTRY_FROM_LINK (Link);
if (FilterEntry->Event == Event) { if (FilterEntry->Event == Event) {
return FilterEntry; return FilterEntry;
@ -469,17 +451,14 @@ FindFilterDriverByEvent (
Search the Head doubly linked list for the passed in MTC. Return the Search the Head doubly linked list for the passed in MTC. Return the
matching element in Head and the MTC on the next entry. matching element in Head and the MTC on the next entry.
@param Head - Head of Data Log linked list. @param Head Head of Data Log linked list.
@param ClassFilter Only match the MTC if it is in the same Class as the
@param ClassFilter - Only match the MTC if it is in the same Class as the
ClassFilter. ClassFilter.
@param PtrCurrentMTC On IN contians MTC to search for. On OUT contians next
@param PtrCurrentMTC - On IN contians MTC to search for. On OUT contians next
MTC in the data log list or zero if at end of the list. MTC in the data log list or zero if at end of the list.
@retval EFI_DATA_LOG_ENTRY - Return pointer to data log data from Head list. @retval EFI_DATA_LOG_ENTRY Return pointer to data log data from Head list.
@retval NULL If no data record exists.
@retval NULL - If no data record exists.
**/ **/
EFI_DATA_RECORD_HEADER * EFI_DATA_RECORD_HEADER *
@ -502,7 +481,7 @@ GetNextDataRecord (
ReturnFirstEntry = (BOOLEAN) (*PtrCurrentMTC == 0); ReturnFirstEntry = (BOOLEAN) (*PtrCurrentMTC == 0);
Record = NULL; Record = NULL;
for (Link = Head->ForwardLink; Link != Head; Link = Link->ForwardLink) { for (Link = GetFirstNode(Head); Link != Head; Link = GetNextNode(Head, Link)) {
LogEntry = DATA_ENTRY_FROM_LINK (Link); LogEntry = DATA_ENTRY_FROM_LINK (Link);
if ((LogEntry->Record->DataRecordClass & ClassFilter) == 0) { if ((LogEntry->Record->DataRecordClass & ClassFilter) == 0) {
// //
@ -522,7 +501,7 @@ GetNextDataRecord (
// MTC to zero. // MTC to zero.
// //
*PtrCurrentMTC = 0; *PtrCurrentMTC = 0;
for (Link = Link->ForwardLink; Link != Head; Link = Link->ForwardLink) { for (Link = GetNextNode(Head, Link); Link != Head; Link = GetNextNode(Head, Link)) {
NextLogEntry = DATA_ENTRY_FROM_LINK (Link); NextLogEntry = DATA_ENTRY_FROM_LINK (Link);
if ((NextLogEntry->Record->DataRecordClass & ClassFilter) != 0) { if ((NextLogEntry->Record->DataRecordClass & ClassFilter) != 0) {
// //
@ -543,16 +522,13 @@ GetNextDataRecord (
} }
/** /**
Driver's Entry point routine that install Driver to produce Data Hub protocol.
Install Driver to produce Data Hub protocol.
@param ImageHandle Module's image handle @param ImageHandle Module's image handle
@param SystemTable Pointer of EFI_SYSTEM_TABLE @param SystemTable Pointer of EFI_SYSTEM_TABLE
@retval EFI_SUCCESS Logging Hub protocol installed
@retval EFI_SUCCESS - Logging Hub protocol installed @retval Other No protocol installed, unload driver.
@retval Other - No protocol installed, unload driver.
**/ **/
EFI_STATUS EFI_STATUS

View File

@ -1,7 +1,26 @@
#/** @file #/** @file
# Component description file for DataHub module.
#
# This driver initializes and installs the Data Hub protocol. # This driver initializes and installs the Data Hub protocol.
#
# The data hub is a volatile database that is intended as the major focus for the accumulation of
# manageability data.T he hub is fed by "producers" with chunks of data in a defined format.
# Consumers may then extract the data in temporal "log" order.As an example, progress codes might
# be recorded in the data hub for future processing.Ot her data contributed to the data hub might
# include, for example, statistics on enumerated items such as memory, add-in buses, and add-in
# cards and data on errors encountered during boot (for example, the system did not boot off the
# network because the cable was not plugged in).
# Some classes of data have defined formats.For example, the amount of memory in the system is
# reported in a standard format so that consumers can be written to extract the data.O ther data is
# system specific.For example, additional detail on errors might be specific to the driver that
# discovered the error.The consumer might be a driver that tabularizes data from the data hub,
# providing a mechanism for the raw data to be made available to the OS for post-processing by
# OS-based applications.
# The intent of the data hub is for drivers that enumerate and configure parts of the system to report
# their discoveries to the data hub.This data can then be extracted by other drivers that report those
# discoveries using standard manageability interfaces such as SMBIOS and Intelligent Platform
# Management Interface (IPMI).The alternative to a data-hub-like architecture is to require all
# drivers to be aware of all reporting formats.
# For more information, please ref http://www.intel.com/technology/framework/
#
# Copyright (c) 2006 - 2009, Intel Corporation # Copyright (c) 2006 - 2009, Intel Corporation
# #
# All rights reserved. This program and the accompanying materials # All rights reserved. This program and the accompanying materials
@ -51,7 +70,7 @@
[Protocols] [Protocols]
gEfiDataHubProtocolGuid # PROTOCOL ALWAYS_PRODUCED gEfiDataHubProtocolGuid # PROTOCOL PRODUCED
[Depex] [Depex]