]> git.proxmox.com Git - mirror_edk2.git/blame - IntelFrameworkModulePkg/Universal/DataHubDxe/DataHub.c
Patch to remove STATIC modifier. This is on longer recommended by EFI Framework codin...
[mirror_edk2.git] / IntelFrameworkModulePkg / Universal / DataHubDxe / DataHub.c
CommitLineData
3db51098 1/**@file\r
83f6d1a0 2 This code produces the Data Hub protocol. It preloads the data hub\r
3 with status information copied in from PEI HOBs.\r
4 \r
5 Only code that implements the Data Hub protocol should go in this file!\r
6\r
7 The Term MTC stands for MonoTonicCounter. \r
8\r
9 For more information please look at DataHub.doc\r
10\r
11 NOTE: For extra security of the log GetNextDataRecord () could return a copy\r
12 of the data record.\r
3db51098 13 \r
14Copyright (c) 2006, Intel Corporation \r
15All rights reserved. This program and the accompanying materials \r
16are licensed and made available under the terms and conditions of the BSD License \r
17which accompanies this distribution. The full text of the license may be found at \r
18http://opensource.org/licenses/bsd-license.php \r
19 \r
20THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
21WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
22\r
23**/\r
83f6d1a0 24\r
25#include "DataHub.h"\r
26\r
27CONST EFI_GUID gZeroGuid = { 0, 0, 0, { 0, 0, 0, 0, 0, 0, 0, 0 } };\r
28\r
29//\r
30// Worker functions private to this file\r
31//\r
83f6d1a0 32DATA_HUB_FILTER_DRIVER *\r
33FindFilterDriverByEvent (\r
34 IN LIST_ENTRY *Head,\r
35 IN EFI_EVENT Event\r
36 );\r
37\r
83f6d1a0 38EFI_DATA_RECORD_HEADER *\r
39GetNextDataRecord (\r
40 IN LIST_ENTRY *Head,\r
41 IN UINT64 ClassFilter,\r
42 IN OUT UINT64 *PtrCurrentMTC\r
43 );\r
44\r
a73d0c74 45/**\r
46\r
47 Log data record into the data logging hub\r
48\r
49 @param This - Protocol instance structure\r
50 @param DataRecordGuid - GUID that defines record contents\r
51 @param ProducerName - GUID that defines the name of the producer of the data\r
52 @param DataRecordClass - Class that defines generic record type\r
53 @param RawData - Data Log record as defined by DataRecordGuid\r
54 @param RawDataSize - Size of Data Log data in bytes\r
55\r
56 @retval EFI_SUCCESS - If data was logged\r
57 @retval EFI_OUT_OF_RESOURCES - If data was not logged due to lack of system \r
58 resources.\r
59**/\r
83f6d1a0 60EFI_STATUS\r
61EFIAPI\r
62DataHubLogData (\r
63 IN EFI_DATA_HUB_PROTOCOL *This,\r
64 IN EFI_GUID *DataRecordGuid,\r
65 IN EFI_GUID *ProducerName,\r
66 IN UINT64 DataRecordClass,\r
67 IN VOID *RawData,\r
68 IN UINT32 RawDataSize\r
69 )\r
83f6d1a0 70{\r
71 EFI_STATUS Status;\r
72 DATA_HUB_INSTANCE *Private;\r
73 EFI_DATA_ENTRY *LogEntry;\r
74 UINT32 TotalSize;\r
75 UINT32 RecordSize;\r
76 EFI_DATA_RECORD_HEADER *Record;\r
77 VOID *Raw;\r
78 DATA_HUB_FILTER_DRIVER *FilterEntry;\r
79 LIST_ENTRY *Link;\r
80 LIST_ENTRY *Head;\r
81\r
82 Private = DATA_HUB_INSTANCE_FROM_THIS (This);\r
83\r
84 //\r
85 // Combine the storage for the internal structs and a copy of the log record.\r
86 // Record follows PrivateLogEntry. The consumer will be returned a pointer\r
87 // to Record so we don't what it to be the thing that was allocated from\r
88 // pool, so the consumer can't free an data record by mistake.\r
89 //\r
90 RecordSize = sizeof (EFI_DATA_RECORD_HEADER) + RawDataSize;\r
91 TotalSize = sizeof (EFI_DATA_ENTRY) + RecordSize;\r
92\r
93 //\r
94 // The Logging action is the critical section, so it is locked.\r
95 // The MTC asignment & update, time, and logging must be an\r
96 // atomic operation, so use the lock.\r
97 //\r
98 Status = EfiAcquireLockOrFail (&Private->DataLock);\r
99 if (EFI_ERROR (Status)) {\r
100 //\r
101 // Reentrancy detected so exit!\r
102 //\r
103 return Status;\r
104 }\r
105\r
106 LogEntry = AllocatePool (TotalSize);\r
107\r
108 if (LogEntry == NULL) {\r
109 EfiReleaseLock (&Private->DataLock);\r
110 return EFI_OUT_OF_RESOURCES;\r
111 }\r
112\r
113 ZeroMem (LogEntry, TotalSize);\r
114\r
115 Record = (EFI_DATA_RECORD_HEADER *) (LogEntry + 1);\r
116 Raw = (VOID *) (Record + 1);\r
117\r
118 //\r
119 // Build Standard Log Header\r
120 //\r
121 Record->Version = EFI_DATA_RECORD_HEADER_VERSION;\r
122 Record->HeaderSize = sizeof (EFI_DATA_RECORD_HEADER);\r
123 Record->RecordSize = RecordSize;\r
124 CopyMem (&Record->DataRecordGuid, DataRecordGuid, sizeof (EFI_GUID));\r
125 CopyMem (&Record->ProducerName, ProducerName, sizeof (EFI_GUID));\r
126 Record->DataRecordClass = DataRecordClass;\r
127\r
41e4912f 128 //\r
129 // Ensure LogMonotonicCount is not zero\r
130 //\r
131 Record->LogMonotonicCount = ++Private->GlobalMonotonicCount;\r
83f6d1a0 132\r
133 gRT->GetTime (&Record->LogTime, NULL);\r
134\r
135 //\r
136 // Insert log into the internal linked list.\r
137 //\r
138 LogEntry->Signature = EFI_DATA_ENTRY_SIGNATURE;\r
139 LogEntry->Record = Record;\r
140 LogEntry->RecordSize = sizeof (EFI_DATA_ENTRY) + RawDataSize;\r
141 InsertTailList (&Private->DataListHead, &LogEntry->Link);\r
142\r
143 CopyMem (Raw, RawData, RawDataSize);\r
144\r
145 EfiReleaseLock (&Private->DataLock);\r
146\r
147 //\r
148 // Send Signal to all the filter drivers which are interested\r
149 // in the record's class and guid.\r
150 //\r
151 Head = &Private->FilterDriverListHead;\r
152 for (Link = Head->ForwardLink; Link != Head; Link = Link->ForwardLink) {\r
153 FilterEntry = FILTER_ENTRY_FROM_LINK (Link);\r
154 if (((FilterEntry->ClassFilter & DataRecordClass) != 0) &&\r
155 (CompareGuid (&FilterEntry->FilterDataRecordGuid, &gZeroGuid) || \r
156 CompareGuid (&FilterEntry->FilterDataRecordGuid, DataRecordGuid))) {\r
157 gBS->SignalEvent (FilterEntry->Event);\r
158 }\r
159 }\r
160\r
161 return EFI_SUCCESS;\r
162}\r
163\r
a73d0c74 164/**\r
83f6d1a0 165\r
166 Get a previously logged data record and the MonotonicCount for the next\r
167 availible Record. This allows all records or all records later \r
168 than a give MonotonicCount to be returned. If an optional FilterDriverEvent\r
169 is passed in with a MonotonicCout of zero return the first record \r
170 not yet read by the filter driver. If FilterDriverEvent is NULL and \r
171 MonotonicCount is zero return the first data record.\r
172\r
a73d0c74 173 @param This The EFI_DATA_HUB_PROTOCOL instance.\r
174 @param MonotonicCount Specifies the Record to return. On input, zero means\r
175 return the first record. On output, contains the next\r
176 record to availible. Zero indicates no more records.\r
177 @param FilterDriverEvent If FilterDriverEvent is not passed in a MonotonicCount \r
178 of zero, it means to return the first data record. \r
179 If FilterDriverEvent is passed in, then a MonotonicCount \r
180 of zero means to return the first data not yet read by \r
181 FilterDriverEvent.\r
182 @param Record Returns a dynamically allocated memory buffer with a data \r
183 record that matches MonotonicCount.\r
184\r
185 @retval EFI_SUCCESS - Data was returned in Record.\r
186 @retval EFI_INVALID_PARAMETER - FilterDriverEvent was passed in but does not exist.\r
187 @retval EFI_NOT_FOUND - MonotonicCount does not match any data record in the\r
83f6d1a0 188 system. If a MonotonicCount of zero was passed in, then\r
189 no data records exist in the system.\r
a73d0c74 190 @retval EFI_OUT_OF_RESOURCES - Record was not returned due to lack of system resources.\r
83f6d1a0 191\r
a73d0c74 192**/\r
a73d0c74 193EFI_STATUS\r
194EFIAPI\r
195DataHubGetNextRecord (\r
196 IN EFI_DATA_HUB_PROTOCOL *This,\r
197 IN OUT UINT64 *MonotonicCount,\r
198 IN EFI_EVENT *FilterDriverEvent, OPTIONAL\r
199 OUT EFI_DATA_RECORD_HEADER **Record\r
200 )\r
83f6d1a0 201{\r
202 DATA_HUB_INSTANCE *Private;\r
203 DATA_HUB_FILTER_DRIVER *FilterDriver;\r
204 UINT64 ClassFilter;\r
205 UINT64 FilterMonotonicCount;\r
206\r
207 Private = DATA_HUB_INSTANCE_FROM_THIS (This);\r
208\r
209 FilterDriver = NULL;\r
210 FilterMonotonicCount = 0;\r
211 ClassFilter = EFI_DATA_RECORD_CLASS_DEBUG |\r
212 EFI_DATA_RECORD_CLASS_ERROR |\r
213 EFI_DATA_RECORD_CLASS_DATA |\r
214 EFI_DATA_RECORD_CLASS_PROGRESS_CODE;\r
215\r
216 if (FilterDriverEvent != NULL) {\r
217 //\r
218 // For events the beginning is the last unread record. This info is\r
219 // stored in the instance structure, so we must look up the event\r
220 // to get the data.\r
221 //\r
222 FilterDriver = FindFilterDriverByEvent (\r
223 &Private->FilterDriverListHead,\r
224 *FilterDriverEvent\r
225 );\r
226 if (FilterDriver == NULL) {\r
227 return EFI_INVALID_PARAMETER;\r
228 }\r
229 //\r
230 // Use the Class filter the event was created with.\r
231 //\r
232 ClassFilter = FilterDriver->ClassFilter;\r
233\r
234 if (*MonotonicCount == 0) {\r
235 //\r
236 // Use the MTC from the Filter Driver.\r
237 //\r
238 FilterMonotonicCount = FilterDriver->GetNextMonotonicCount;\r
239 if (FilterMonotonicCount != 0) {\r
240 //\r
241 // The GetNextMonotonicCount field remembers the last value from the previous time.\r
41e4912f 242 // But we already processed this vaule, so we need to find the next one.\r
83f6d1a0 243 //\r
244 *Record = GetNextDataRecord (&Private->DataListHead, ClassFilter, &FilterMonotonicCount);\r
245 *MonotonicCount = FilterMonotonicCount;\r
246 if (FilterMonotonicCount == 0) {\r
247 //\r
248 // If there is no new record to get exit now.\r
249 //\r
250 return EFI_NOT_FOUND;\r
251 }\r
252 }\r
253 }\r
254 }\r
255 //\r
256 // Return the record\r
257 //\r
258 *Record = GetNextDataRecord (&Private->DataListHead, ClassFilter, MonotonicCount);\r
259 if (*Record == NULL) {\r
260 return EFI_NOT_FOUND;\r
261 }\r
262\r
263 if (FilterDriver != NULL) {\r
264 //\r
265 // If we have a filter driver update the records that have been read.\r
266 // If MonotonicCount is zero No more reacords left.\r
267 //\r
268 if (*MonotonicCount == 0) {\r
41e4912f 269 //\r
270 // Save the current Record MonotonicCount.\r
271 //\r
272 FilterDriver->GetNextMonotonicCount = (*Record)->LogMonotonicCount;\r
83f6d1a0 273 } else {\r
274 //\r
275 // Point to next undread record\r
276 //\r
277 FilterDriver->GetNextMonotonicCount = *MonotonicCount;\r
278 }\r
279 }\r
280\r
281 return EFI_SUCCESS;\r
282}\r
283\r
a73d0c74 284/**\r
83f6d1a0 285 This function registers the data hub filter driver that is represented \r
286 by FilterEvent. Only one instance of each FilterEvent can be registered.\r
287 After the FilterEvent is registered, it will be signaled so it can sync \r
288 with data records that have been recorded prior to the FilterEvent being \r
289 registered.\r
290 \r
a73d0c74 291 @param This - The EFI_DATA_HUB_PROTOCOL instance.\r
292 @param FilterEvent - The EFI_EVENT to signal whenever data that matches \r
83f6d1a0 293 FilterClass is logged in the system.\r
a73d0c74 294 @param FilterTpl - The maximum EFI_TPL at which FilterEvent can be \r
83f6d1a0 295 signaled. It is strongly recommended that you use the \r
296 lowest EFI_TPL possible.\r
a73d0c74 297 @param FilterClass - FilterEvent will be signaled whenever a bit in \r
83f6d1a0 298 EFI_DATA_RECORD_HEADER.DataRecordClass is also set in \r
299 FilterClass. If FilterClass is zero, no class-based \r
300 filtering will be performed.\r
a73d0c74 301 @param FilterDataRecordGuid - FilterEvent will be signaled whenever FilterDataRecordGuid \r
83f6d1a0 302 matches EFI_DATA_RECORD_HEADER.DataRecordGuid. If \r
303 FilterDataRecordGuid is NULL, then no GUID-based filtering \r
304 will be performed. \r
83f6d1a0 305\r
a73d0c74 306 @retval EFI_SUCCESS - The filter driver event was registered.\r
307 @retval EFI_ALREADY_STARTED - FilterEvent was previously registered and cannot be \r
83f6d1a0 308 registered again.\r
a73d0c74 309 @retval EFI_OUT_OF_RESOURCES - The filter driver event was not registered due to lack of \r
83f6d1a0 310 system resources.\r
311\r
a73d0c74 312**/\r
a73d0c74 313EFI_STATUS\r
314EFIAPI\r
315DataHubRegisterFilterDriver (\r
316 IN EFI_DATA_HUB_PROTOCOL * This,\r
317 IN EFI_EVENT FilterEvent,\r
318 IN EFI_TPL FilterTpl,\r
319 IN UINT64 FilterClass,\r
320 IN EFI_GUID * FilterDataRecordGuid OPTIONAL\r
321 )\r
322\r
83f6d1a0 323{\r
324 DATA_HUB_INSTANCE *Private;\r
325 DATA_HUB_FILTER_DRIVER *FilterDriver;\r
326\r
327 Private = DATA_HUB_INSTANCE_FROM_THIS (This);\r
328\r
329 FilterDriver = (DATA_HUB_FILTER_DRIVER *) AllocateZeroPool (sizeof (DATA_HUB_FILTER_DRIVER));\r
330 if (FilterDriver == NULL) {\r
331 return EFI_OUT_OF_RESOURCES;\r
332 }\r
333 //\r
334 // Initialize filter driver info\r
335 //\r
336 FilterDriver->Signature = EFI_DATA_HUB_FILTER_DRIVER_SIGNATURE;\r
337 FilterDriver->Event = FilterEvent;\r
338 FilterDriver->Tpl = FilterTpl;\r
339 FilterDriver->GetNextMonotonicCount = 0;\r
340 if (FilterClass == 0) {\r
341 FilterDriver->ClassFilter = EFI_DATA_RECORD_CLASS_DEBUG |\r
342 EFI_DATA_RECORD_CLASS_ERROR |\r
343 EFI_DATA_RECORD_CLASS_DATA |\r
344 EFI_DATA_RECORD_CLASS_PROGRESS_CODE;\r
345 } else {\r
346 FilterDriver->ClassFilter = FilterClass;\r
347 }\r
348\r
349 if (FilterDataRecordGuid != NULL) {\r
350 CopyMem (&FilterDriver->FilterDataRecordGuid, FilterDataRecordGuid, sizeof (EFI_GUID));\r
351 }\r
352 //\r
353 // Search for duplicate entries\r
354 //\r
355 if (FindFilterDriverByEvent (&Private->FilterDriverListHead, FilterEvent) != NULL) {\r
356 FreePool (FilterDriver);\r
357 return EFI_ALREADY_STARTED;\r
358 }\r
359 //\r
360 // Make insertion an atomic operation with the lock.\r
361 //\r
362 EfiAcquireLock (&Private->DataLock);\r
363 InsertTailList (&Private->FilterDriverListHead, &FilterDriver->Link);\r
364 EfiReleaseLock (&Private->DataLock);\r
365\r
366 //\r
367 // Signal the Filter driver we just loaded so they will recieve all the\r
368 // previous history. If we did not signal here we would have to wait until\r
369 // the next data was logged to get the history. In a case where no next\r
370 // data was logged we would never get synced up.\r
371 //\r
372 gBS->SignalEvent (FilterEvent);\r
373\r
374 return EFI_SUCCESS;\r
375}\r
376\r
a73d0c74 377/**\r
83f6d1a0 378 Remove a Filter Driver, so it no longer gets called when data \r
379 information is logged.\r
380\r
a73d0c74 381 @param This - Protocol instance structure\r
83f6d1a0 382\r
a73d0c74 383 @param FilterEvent - Event that represents a filter driver that is to be \r
83f6d1a0 384 Unregistered.\r
385\r
a73d0c74 386 @retval EFI_SUCCESS - If FilterEvent was unregistered\r
83f6d1a0 387\r
a73d0c74 388 @retval EFI_NOT_FOUND - If FilterEvent does not exist\r
83f6d1a0 389\r
a73d0c74 390**/\r
a73d0c74 391EFI_STATUS\r
392EFIAPI\r
393DataHubUnregisterFilterDriver (\r
394 IN EFI_DATA_HUB_PROTOCOL *This,\r
395 IN EFI_EVENT FilterEvent\r
396 )\r
83f6d1a0 397{\r
398 DATA_HUB_INSTANCE *Private;\r
399 DATA_HUB_FILTER_DRIVER *FilterDriver;\r
400\r
401 Private = DATA_HUB_INSTANCE_FROM_THIS (This);\r
402\r
403 //\r
404 // Search for duplicate entries\r
405 //\r
406 FilterDriver = FindFilterDriverByEvent (\r
407 &Private->FilterDriverListHead,\r
408 FilterEvent\r
409 );\r
410 if (FilterDriver == NULL) {\r
411 return EFI_NOT_FOUND;\r
412 }\r
413 //\r
414 // Make removal an atomic operation with the lock\r
415 //\r
416 EfiAcquireLock (&Private->DataLock);\r
417 RemoveEntryList (&FilterDriver->Link);\r
418 EfiReleaseLock (&Private->DataLock);\r
419\r
420 return EFI_SUCCESS;\r
421}\r
83f6d1a0 422\r
a73d0c74 423/**\r
83f6d1a0 424 Search the Head list for a EFI_DATA_HUB_FILTER_DRIVER member that\r
425 represents Event and return it.\r
426\r
a73d0c74 427 @param Head - Head of dual linked list of EFI_DATA_HUB_FILTER_DRIVER\r
83f6d1a0 428 structures.\r
429\r
a73d0c74 430 @param Event - Event to be search for in the Head list.\r
83f6d1a0 431\r
a73d0c74 432 @retval EFI_DATA_HUB_FILTER_DRIVER - Returned if Event stored in the\r
83f6d1a0 433 Head doubly linked list.\r
434\r
a73d0c74 435 @retval NULL - If Event is not in the list\r
436\r
437**/\r
a73d0c74 438DATA_HUB_FILTER_DRIVER *\r
439FindFilterDriverByEvent (\r
440 IN LIST_ENTRY *Head,\r
441 IN EFI_EVENT Event\r
442 )\r
83f6d1a0 443\r
83f6d1a0 444{\r
445 DATA_HUB_FILTER_DRIVER *FilterEntry;\r
446 LIST_ENTRY *Link;\r
447\r
448 for (Link = Head->ForwardLink; Link != Head; Link = Link->ForwardLink) {\r
449 FilterEntry = FILTER_ENTRY_FROM_LINK (Link);\r
450 if (FilterEntry->Event == Event) {\r
451 return FilterEntry;\r
452 }\r
453 }\r
454\r
455 return NULL;\r
456}\r
457\r
a73d0c74 458/**\r
83f6d1a0 459 Search the Head doubly linked list for the passed in MTC. Return the \r
460 matching element in Head and the MTC on the next entry.\r
461\r
a73d0c74 462 @param Head - Head of Data Log linked list.\r
83f6d1a0 463\r
a73d0c74 464 @param ClassFilter - Only match the MTC if it is in the same Class as the\r
83f6d1a0 465 ClassFilter.\r
466\r
a73d0c74 467 @param PtrCurrentMTC - On IN contians MTC to search for. On OUT contians next\r
83f6d1a0 468 MTC in the data log list or zero if at end of the list.\r
469 \r
a73d0c74 470 @retval EFI_DATA_LOG_ENTRY - Return pointer to data log data from Head list.\r
83f6d1a0 471\r
a73d0c74 472 @retval NULL - If no data record exists.\r
83f6d1a0 473\r
a73d0c74 474**/\r
a73d0c74 475EFI_DATA_RECORD_HEADER *\r
476GetNextDataRecord (\r
477 IN LIST_ENTRY *Head,\r
478 IN UINT64 ClassFilter,\r
479 IN OUT UINT64 *PtrCurrentMTC\r
480 )\r
83f6d1a0 481\r
83f6d1a0 482{\r
483 EFI_DATA_ENTRY *LogEntry;\r
484 LIST_ENTRY *Link;\r
485 BOOLEAN ReturnFirstEntry;\r
486 EFI_DATA_RECORD_HEADER *Record;\r
487 EFI_DATA_ENTRY *NextLogEntry;\r
488\r
489 //\r
490 // If MonotonicCount == 0 just return the first one\r
491 //\r
492 ReturnFirstEntry = (BOOLEAN) (*PtrCurrentMTC == 0);\r
493\r
494 Record = NULL;\r
495 for (Link = Head->ForwardLink; Link != Head; Link = Link->ForwardLink) {\r
496 LogEntry = DATA_ENTRY_FROM_LINK (Link);\r
497 if ((LogEntry->Record->DataRecordClass & ClassFilter) == 0) {\r
498 //\r
499 // Skip any entry that does not have the correct ClassFilter\r
500 //\r
501 continue;\r
502 }\r
503\r
504 if ((LogEntry->Record->LogMonotonicCount == *PtrCurrentMTC) || ReturnFirstEntry) {\r
505 //\r
506 // Return record to the user\r
507 //\r
508 Record = LogEntry->Record;\r
509\r
510 //\r
511 // Calculate the next MTC value. If there is no next entry set\r
512 // MTC to zero.\r
513 //\r
514 *PtrCurrentMTC = 0;\r
515 for (Link = Link->ForwardLink; Link != Head; Link = Link->ForwardLink) {\r
516 NextLogEntry = DATA_ENTRY_FROM_LINK (Link);\r
517 if ((NextLogEntry->Record->DataRecordClass & ClassFilter) != 0) {\r
518 //\r
519 // Return the MTC of the next thing to search for if found\r
520 //\r
521 *PtrCurrentMTC = NextLogEntry->Record->LogMonotonicCount;\r
522 break;\r
523 }\r
524 }\r
525 //\r
526 // Record found exit loop and return\r
527 //\r
528 break;\r
529 }\r
530 }\r
531\r
532 return Record;\r
533}\r
534//\r
535// Module Global:\r
536// Since this driver will only ever produce one instance of the Logging Hub\r
537// protocol you are not required to dynamically allocate the PrivateData.\r
538//\r
539DATA_HUB_INSTANCE mPrivateData;\r
540\r
a73d0c74 541/**\r
83f6d1a0 542\r
83f6d1a0 543 Install Driver to produce Data Hub protocol. \r
544\r
a73d0c74 545 @param ImageHandle Module's image handle\r
546 @param SystemTable Pointer of EFI_SYSTEM_TABLE\r
83f6d1a0 547\r
83f6d1a0 548\r
a73d0c74 549 @retval EFI_SUCCESS - Logging Hub protocol installed\r
83f6d1a0 550\r
a73d0c74 551 @retval Other - No protocol installed, unload driver.\r
83f6d1a0 552\r
a73d0c74 553**/\r
554EFI_STATUS\r
555EFIAPI\r
556DataHubInstall (\r
557 IN EFI_HANDLE ImageHandle,\r
558 IN EFI_SYSTEM_TABLE *SystemTable\r
559 )\r
83f6d1a0 560{\r
561 EFI_STATUS Status;\r
562 UINT32 HighMontonicCount;\r
563\r
564 mPrivateData.Signature = DATA_HUB_INSTANCE_SIGNATURE;\r
565 mPrivateData.DataHub.LogData = DataHubLogData;\r
566 mPrivateData.DataHub.GetNextRecord = DataHubGetNextRecord;\r
567 mPrivateData.DataHub.RegisterFilterDriver = DataHubRegisterFilterDriver;\r
568 mPrivateData.DataHub.UnregisterFilterDriver = DataHubUnregisterFilterDriver;\r
569\r
570 //\r
571 // Initialize Private Data in CORE_LOGGING_HUB_INSTANCE that is\r
572 // required by this protocol\r
573 //\r
574 InitializeListHead (&mPrivateData.DataListHead);\r
575 InitializeListHead (&mPrivateData.FilterDriverListHead);\r
576\r
577 EfiInitializeLock (&mPrivateData.DataLock, TPL_NOTIFY);\r
578\r
579 //\r
580 // Make sure we get a bigger MTC number on every boot!\r
581 //\r
582 Status = gRT->GetNextHighMonotonicCount (&HighMontonicCount);\r
583 if (EFI_ERROR (Status)) {\r
584 //\r
585 // if system service fails pick a sane value.\r
586 //\r
587 mPrivateData.GlobalMonotonicCount = 0;\r
588 } else {\r
589 mPrivateData.GlobalMonotonicCount = LShiftU64 ((UINT64) HighMontonicCount, 32);\r
590 }\r
591 //\r
592 // Make a new handle and install the protocol\r
593 //\r
594 mPrivateData.Handle = NULL;\r
595 Status = gBS->InstallProtocolInterface (\r
596 &mPrivateData.Handle,\r
597 &gEfiDataHubProtocolGuid,\r
598 EFI_NATIVE_INTERFACE,\r
599 &mPrivateData.DataHub\r
600 );\r
601 return Status;\r
602}\r
a73d0c74 603\r