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