]>
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 | |
13314ba3 | 5 | Copyright (c) 2006 - 2010, 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 | |
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 | |
13314ba3 | 102 | Record->HeaderSize = (UINT16) sizeof (EFI_DATA_RECORD_HEADER);\r |
83f6d1a0 | 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 | |
83f6d1a0 | 289 | \r |
290 | Private = DATA_HUB_INSTANCE_FROM_THIS (This);\r | |
291 | \r | |
292 | FilterDriver = NULL;\r | |
83f6d1a0 | 293 | ClassFilter = EFI_DATA_RECORD_CLASS_DEBUG |\r |
294 | EFI_DATA_RECORD_CLASS_ERROR |\r | |
295 | EFI_DATA_RECORD_CLASS_DATA |\r | |
296 | EFI_DATA_RECORD_CLASS_PROGRESS_CODE;\r | |
297 | \r | |
d2720e0c | 298 | //\r |
299 | // If FilterDriverEvent is NULL, then return the next record\r | |
300 | //\r | |
301 | if (FilterDriverEvent == NULL) {\r | |
302 | *Record = GetNextDataRecord (&Private->DataListHead, ClassFilter, MonotonicCount);\r | |
303 | if (*Record == NULL) {\r | |
304 | return EFI_NOT_FOUND;\r | |
83f6d1a0 | 305 | }\r |
d2720e0c | 306 | return EFI_SUCCESS;\r |
307 | }\r | |
308 | \r | |
309 | //\r | |
310 | // For events the beginning is the last unread record. This info is\r | |
311 | // stored in the instance structure, so we must look up the event\r | |
312 | // to get the data.\r | |
313 | //\r | |
314 | FilterDriver = FindFilterDriverByEvent (\r | |
315 | &Private->FilterDriverListHead,\r | |
316 | *FilterDriverEvent\r | |
317 | );\r | |
318 | if (FilterDriver == NULL) {\r | |
319 | return EFI_INVALID_PARAMETER;\r | |
320 | }\r | |
321 | //\r | |
322 | // Use the Class filter the event was created with.\r | |
323 | //\r | |
324 | ClassFilter = FilterDriver->ClassFilter;\r | |
83f6d1a0 | 325 | \r |
d2720e0c | 326 | //\r |
327 | // Retrieve the next record or the first record.\r | |
328 | // \r | |
329 | if (*MonotonicCount != 0 || FilterDriver->GetNextMonotonicCount == 0) { \r | |
330 | *Record = GetNextDataRecord (&Private->DataListHead, ClassFilter, MonotonicCount);\r | |
331 | if (*Record == NULL) {\r | |
332 | return EFI_NOT_FOUND;\r | |
333 | }\r | |
334 | \r | |
335 | if (*MonotonicCount != 0) {\r | |
83f6d1a0 | 336 | //\r |
d2720e0c | 337 | // If this was not the last record then update the count associated with the filter \r |
83f6d1a0 | 338 | //\r |
d2720e0c | 339 | FilterDriver->GetNextMonotonicCount = *MonotonicCount;\r |
340 | } else {\r | |
2ebbe08c | 341 | //\r |
d2720e0c | 342 | // Save the MonotonicCount of the last record which has been read\r |
2ebbe08c | 343 | //\r |
d2720e0c | 344 | FilterDriver->GetNextMonotonicCount = (*Record)->LogMonotonicCount;\r |
83f6d1a0 | 345 | }\r |
d2720e0c | 346 | return EFI_SUCCESS;\r |
83f6d1a0 | 347 | }\r |
d2720e0c | 348 | \r |
349 | //\r | |
350 | // This is a request to read the first record that has not been read yet. \r | |
351 | // Set MonotoicCount to the last record successfuly read\r | |
352 | //\r | |
353 | *MonotonicCount = FilterDriver->GetNextMonotonicCount;\r | |
354 | \r | |
83f6d1a0 | 355 | //\r |
d2720e0c | 356 | // Retrieve the last record successfuly read again, but do not return it since\r |
357 | // it has already been returned before.\r | |
83f6d1a0 | 358 | //\r |
359 | *Record = GetNextDataRecord (&Private->DataListHead, ClassFilter, MonotonicCount);\r | |
360 | if (*Record == NULL) {\r | |
361 | return EFI_NOT_FOUND;\r | |
362 | }\r | |
d2720e0c | 363 | \r |
364 | if (*MonotonicCount != 0) {\r | |
83f6d1a0 | 365 | //\r |
d2720e0c | 366 | // Update the count associated with the filter \r |
83f6d1a0 | 367 | //\r |
d2720e0c | 368 | FilterDriver->GetNextMonotonicCount = *MonotonicCount;\r |
369 | \r | |
370 | //\r | |
371 | // Retrieve the record after the last record successfuly read \r | |
372 | // \r | |
373 | *Record = GetNextDataRecord (&Private->DataListHead, ClassFilter, MonotonicCount);\r | |
374 | if (*Record == NULL) {\r | |
375 | return EFI_NOT_FOUND;\r | |
83f6d1a0 | 376 | }\r |
377 | }\r | |
d2720e0c | 378 | \r |
83f6d1a0 | 379 | return EFI_SUCCESS;\r |
380 | }\r | |
381 | \r | |
a73d0c74 | 382 | /**\r |
83f6d1a0 | 383 | This function registers the data hub filter driver that is represented \r |
384 | by FilterEvent. Only one instance of each FilterEvent can be registered.\r | |
385 | After the FilterEvent is registered, it will be signaled so it can sync \r | |
386 | with data records that have been recorded prior to the FilterEvent being \r | |
387 | registered.\r | |
388 | \r | |
2ab23929 | 389 | @param This Pointer to The EFI_DATA_HUB_PROTOCOL instance.\r |
390 | @param FilterEvent The EFI_EVENT to signal whenever data that matches \r | |
391 | FilterClass is logged in the system.\r | |
392 | @param FilterTpl The maximum EFI_TPL at which FilterEvent can be \r | |
393 | signaled. It is strongly recommended that you use the \r | |
394 | lowest EFI_TPL possible.\r | |
395 | @param FilterClass FilterEvent will be signaled whenever a bit in \r | |
396 | EFI_DATA_RECORD_HEADER.DataRecordClass is also set in \r | |
397 | FilterClass. If FilterClass is zero, no class-based \r | |
398 | filtering will be performed.\r | |
399 | @param FilterDataRecordGuid FilterEvent will be signaled whenever FilterDataRecordGuid \r | |
400 | matches EFI_DATA_RECORD_HEADER.DataRecordGuid. If \r | |
401 | FilterDataRecordGuid is NULL, then no GUID-based filtering \r | |
402 | will be performed. \r | |
403 | \r | |
404 | @retval EFI_SUCCESS The filter driver event was registered.\r | |
405 | @retval EFI_ALREADY_STARTED FilterEvent was previously registered and cannot be \r | |
406 | registered again.\r | |
407 | @retval EFI_OUT_OF_RESOURCES The filter driver event was not registered due to lack of \r | |
408 | system resources.\r | |
83f6d1a0 | 409 | \r |
a73d0c74 | 410 | **/\r |
a73d0c74 | 411 | EFI_STATUS\r |
412 | EFIAPI\r | |
413 | DataHubRegisterFilterDriver (\r | |
414 | IN EFI_DATA_HUB_PROTOCOL * This,\r | |
415 | IN EFI_EVENT FilterEvent,\r | |
416 | IN EFI_TPL FilterTpl,\r | |
417 | IN UINT64 FilterClass,\r | |
418 | IN EFI_GUID * FilterDataRecordGuid OPTIONAL\r | |
419 | )\r | |
420 | \r | |
83f6d1a0 | 421 | {\r |
422 | DATA_HUB_INSTANCE *Private;\r | |
423 | DATA_HUB_FILTER_DRIVER *FilterDriver;\r | |
424 | \r | |
425 | Private = DATA_HUB_INSTANCE_FROM_THIS (This);\r | |
426 | \r | |
427 | FilterDriver = (DATA_HUB_FILTER_DRIVER *) AllocateZeroPool (sizeof (DATA_HUB_FILTER_DRIVER));\r | |
428 | if (FilterDriver == NULL) {\r | |
429 | return EFI_OUT_OF_RESOURCES;\r | |
430 | }\r | |
431 | //\r | |
432 | // Initialize filter driver info\r | |
433 | //\r | |
434 | FilterDriver->Signature = EFI_DATA_HUB_FILTER_DRIVER_SIGNATURE;\r | |
435 | FilterDriver->Event = FilterEvent;\r | |
436 | FilterDriver->Tpl = FilterTpl;\r | |
437 | FilterDriver->GetNextMonotonicCount = 0;\r | |
438 | if (FilterClass == 0) {\r | |
439 | FilterDriver->ClassFilter = EFI_DATA_RECORD_CLASS_DEBUG |\r | |
440 | EFI_DATA_RECORD_CLASS_ERROR |\r | |
441 | EFI_DATA_RECORD_CLASS_DATA |\r | |
442 | EFI_DATA_RECORD_CLASS_PROGRESS_CODE;\r | |
443 | } else {\r | |
444 | FilterDriver->ClassFilter = FilterClass;\r | |
445 | }\r | |
446 | \r | |
447 | if (FilterDataRecordGuid != NULL) {\r | |
448 | CopyMem (&FilterDriver->FilterDataRecordGuid, FilterDataRecordGuid, sizeof (EFI_GUID));\r | |
449 | }\r | |
450 | //\r | |
451 | // Search for duplicate entries\r | |
452 | //\r | |
453 | if (FindFilterDriverByEvent (&Private->FilterDriverListHead, FilterEvent) != NULL) {\r | |
454 | FreePool (FilterDriver);\r | |
455 | return EFI_ALREADY_STARTED;\r | |
456 | }\r | |
457 | //\r | |
458 | // Make insertion an atomic operation with the lock.\r | |
459 | //\r | |
460 | EfiAcquireLock (&Private->DataLock);\r | |
461 | InsertTailList (&Private->FilterDriverListHead, &FilterDriver->Link);\r | |
462 | EfiReleaseLock (&Private->DataLock);\r | |
463 | \r | |
464 | //\r | |
465 | // Signal the Filter driver we just loaded so they will recieve all the\r | |
466 | // previous history. If we did not signal here we would have to wait until\r | |
467 | // the next data was logged to get the history. In a case where no next\r | |
468 | // data was logged we would never get synced up.\r | |
469 | //\r | |
470 | gBS->SignalEvent (FilterEvent);\r | |
471 | \r | |
472 | return EFI_SUCCESS;\r | |
473 | }\r | |
474 | \r | |
a73d0c74 | 475 | /**\r |
83f6d1a0 | 476 | Remove a Filter Driver, so it no longer gets called when data \r |
477 | information is logged.\r | |
478 | \r | |
2ab23929 | 479 | @param This Protocol instance structure\r |
83f6d1a0 | 480 | \r |
2ab23929 | 481 | @param FilterEvent Event that represents a filter driver that is to be \r |
482 | Unregistered.\r | |
83f6d1a0 | 483 | \r |
2ab23929 | 484 | @retval EFI_SUCCESS If FilterEvent was unregistered\r |
485 | @retval EFI_NOT_FOUND If FilterEvent does not exist\r | |
a73d0c74 | 486 | **/\r |
a73d0c74 | 487 | EFI_STATUS\r |
488 | EFIAPI\r | |
489 | DataHubUnregisterFilterDriver (\r | |
490 | IN EFI_DATA_HUB_PROTOCOL *This,\r | |
491 | IN EFI_EVENT FilterEvent\r | |
492 | )\r | |
83f6d1a0 | 493 | {\r |
494 | DATA_HUB_INSTANCE *Private;\r | |
495 | DATA_HUB_FILTER_DRIVER *FilterDriver;\r | |
496 | \r | |
497 | Private = DATA_HUB_INSTANCE_FROM_THIS (This);\r | |
498 | \r | |
499 | //\r | |
500 | // Search for duplicate entries\r | |
501 | //\r | |
502 | FilterDriver = FindFilterDriverByEvent (\r | |
503 | &Private->FilterDriverListHead,\r | |
504 | FilterEvent\r | |
505 | );\r | |
506 | if (FilterDriver == NULL) {\r | |
507 | return EFI_NOT_FOUND;\r | |
508 | }\r | |
509 | //\r | |
510 | // Make removal an atomic operation with the lock\r | |
511 | //\r | |
512 | EfiAcquireLock (&Private->DataLock);\r | |
513 | RemoveEntryList (&FilterDriver->Link);\r | |
514 | EfiReleaseLock (&Private->DataLock);\r | |
515 | \r | |
516 | return EFI_SUCCESS;\r | |
517 | }\r | |
83f6d1a0 | 518 | \r |
83f6d1a0 | 519 | \r |
83f6d1a0 | 520 | \r |
a73d0c74 | 521 | /**\r |
2ab23929 | 522 | Driver's Entry point routine that install Driver to produce Data Hub protocol. \r |
83f6d1a0 | 523 | \r |
2ab23929 | 524 | @param ImageHandle Module's image handle\r |
525 | @param SystemTable Pointer of EFI_SYSTEM_TABLE\r | |
83f6d1a0 | 526 | \r |
2ab23929 | 527 | @retval EFI_SUCCESS Logging Hub protocol installed\r |
528 | @retval Other No protocol installed, unload driver.\r | |
83f6d1a0 | 529 | \r |
a73d0c74 | 530 | **/\r |
531 | EFI_STATUS\r | |
532 | EFIAPI\r | |
533 | DataHubInstall (\r | |
534 | IN EFI_HANDLE ImageHandle,\r | |
535 | IN EFI_SYSTEM_TABLE *SystemTable\r | |
536 | )\r | |
83f6d1a0 | 537 | {\r |
538 | EFI_STATUS Status;\r | |
539 | UINT32 HighMontonicCount;\r | |
540 | \r | |
541 | mPrivateData.Signature = DATA_HUB_INSTANCE_SIGNATURE;\r | |
542 | mPrivateData.DataHub.LogData = DataHubLogData;\r | |
543 | mPrivateData.DataHub.GetNextRecord = DataHubGetNextRecord;\r | |
544 | mPrivateData.DataHub.RegisterFilterDriver = DataHubRegisterFilterDriver;\r | |
545 | mPrivateData.DataHub.UnregisterFilterDriver = DataHubUnregisterFilterDriver;\r | |
546 | \r | |
547 | //\r | |
548 | // Initialize Private Data in CORE_LOGGING_HUB_INSTANCE that is\r | |
2ab23929 | 549 | // required by this protocol\r |
83f6d1a0 | 550 | //\r |
551 | InitializeListHead (&mPrivateData.DataListHead);\r | |
552 | InitializeListHead (&mPrivateData.FilterDriverListHead);\r | |
553 | \r | |
554 | EfiInitializeLock (&mPrivateData.DataLock, TPL_NOTIFY);\r | |
555 | \r | |
556 | //\r | |
557 | // Make sure we get a bigger MTC number on every boot!\r | |
558 | //\r | |
559 | Status = gRT->GetNextHighMonotonicCount (&HighMontonicCount);\r | |
560 | if (EFI_ERROR (Status)) {\r | |
561 | //\r | |
562 | // if system service fails pick a sane value.\r | |
563 | //\r | |
564 | mPrivateData.GlobalMonotonicCount = 0;\r | |
565 | } else {\r | |
566 | mPrivateData.GlobalMonotonicCount = LShiftU64 ((UINT64) HighMontonicCount, 32);\r | |
567 | }\r | |
568 | //\r | |
569 | // Make a new handle and install the protocol\r | |
570 | //\r | |
571 | mPrivateData.Handle = NULL;\r | |
572 | Status = gBS->InstallProtocolInterface (\r | |
573 | &mPrivateData.Handle,\r | |
574 | &gEfiDataHubProtocolGuid,\r | |
575 | EFI_NATIVE_INTERFACE,\r | |
576 | &mPrivateData.DataHub\r | |
577 | );\r | |
578 | return Status;\r | |
579 | }\r | |
a73d0c74 | 580 | \r |