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