TianoCore EDK2 master
Loading...
Searching...
No Matches
DxeCorePerformanceLib.c
Go to the documentation of this file.
1
20
21//
22// Data for FPDT performance records.
23//
24#define SMM_BOOT_RECORD_COMM_SIZE (OFFSET_OF (EFI_SMM_COMMUNICATE_HEADER, Data) + sizeof(SMM_BOOT_RECORD_COMMUNICATE))
25#define STRING_SIZE (FPDT_STRING_EVENT_RECORD_NAME_LENGTH * sizeof (CHAR8))
26#define FIRMWARE_RECORD_BUFFER 0x10000
27#define CACHE_HANDLE_GUID_COUNT 0x800
28
29BOOT_PERFORMANCE_TABLE *mAcpiBootPerformanceTable = NULL;
30BOOT_PERFORMANCE_TABLE mBootPerformanceTableTemplate = {
31 {
34 },
35 {
36 {
37 EFI_ACPI_5_0_FPDT_RUNTIME_RECORD_TYPE_FIRMWARE_BASIC_BOOT, // Type
39 EFI_ACPI_5_0_FPDT_RUNTIME_RECORD_REVISION_FIRMWARE_BASIC_BOOT // Revision
40 },
41 0, // Reserved
42 //
43 // These values will be updated at runtime.
44 //
45 0, // ResetEnd
46 0, // OsLoaderLoadImageStart
47 0, // OsLoaderStartImageStart
48 0, // ExitBootServicesEntry
49 0 // ExitBootServicesExit
50 }
51};
52
53typedef struct {
54 EFI_HANDLE Handle;
55 CHAR8 NameString[FPDT_STRING_EVENT_RECORD_NAME_LENGTH];
56 EFI_GUID ModuleGuid;
58
59HANDLE_GUID_MAP mCacheHandleGuidTable[CACHE_HANDLE_GUID_COUNT];
60UINTN mCachePairCount = 0;
61
62UINT32 mLoadImageCount = 0;
63UINT32 mPerformanceLength = 0;
64UINT32 mMaxPerformanceLength = 0;
65UINT32 mBootRecordSize = 0;
66UINTN mBootRecordMaxSize = 0;
67UINT32 mCachedLength = 0;
68
69BOOLEAN mFpdtBufferIsReported = FALSE;
70BOOLEAN mLackSpaceIsReported = FALSE;
71CHAR8 *mPlatformLanguage = NULL;
72UINT8 *mPerformancePointer = NULL;
73UINT8 *mBootRecordBuffer = NULL;
74BOOLEAN mLockInsertRecord = FALSE;
75CHAR8 *mDevicePathString = NULL;
76UINTN mSmmBootRecordOffset = 0;
77
78EFI_DEVICE_PATH_TO_TEXT_PROTOCOL *mDevicePathToText = NULL;
79
80//
81// Interfaces for PerformanceMeasurement Protocol.
82//
83EDKII_PERFORMANCE_MEASUREMENT_PROTOCOL mPerformanceMeasurementInterface = {
85};
86
87PERFORMANCE_PROPERTY mPerformanceProperty;
88
100 IN UINT8 RecordSize,
101 IN OUT FPDT_RECORD_PTR *FpdtRecordPtr
102 )
103{
104 if (mFpdtBufferIsReported) {
105 //
106 // Append Boot records to the boot performance table.
107 //
108 if (mBootRecordSize + RecordSize > mBootRecordMaxSize) {
109 if (!mLackSpaceIsReported) {
110 DEBUG ((DEBUG_INFO, "DxeCorePerformanceLib: No enough space to save boot records\n"));
111 mLackSpaceIsReported = TRUE;
112 }
113
114 return EFI_OUT_OF_RESOURCES;
115 } else {
116 //
117 // Save boot record into BootPerformance table
118 //
119 FpdtRecordPtr->RecordHeader = (EFI_ACPI_5_0_FPDT_PERFORMANCE_RECORD_HEADER *)(mBootRecordBuffer + mBootRecordSize);
120 }
121 } else {
122 //
123 // Check if pre-allocated buffer is full
124 //
125 if (mPerformanceLength + RecordSize > mMaxPerformanceLength) {
126 mPerformancePointer = ReallocatePool (
127 mPerformanceLength,
128 mPerformanceLength + RecordSize + FIRMWARE_RECORD_BUFFER,
129 mPerformancePointer
130 );
131 if (mPerformancePointer == NULL) {
132 return EFI_OUT_OF_RESOURCES;
133 }
134
135 mMaxPerformanceLength = mPerformanceLength + RecordSize + FIRMWARE_RECORD_BUFFER;
136 }
137
138 //
139 // Covert buffer to FPDT Ptr Union type.
140 //
141 FpdtRecordPtr->RecordHeader = (EFI_ACPI_5_0_FPDT_PERFORMANCE_RECORD_HEADER *)(mPerformancePointer + mPerformanceLength);
142 }
143
144 return EFI_SUCCESS;
145}
146
156BOOLEAN
158 IN CONST CHAR8 *Token
159 )
160{
161 if (Token == NULL) {
162 return FALSE;
163 }
164
165 if ((AsciiStrCmp (Token, SEC_TOK) == 0) ||
166 (AsciiStrCmp (Token, PEI_TOK) == 0) ||
167 (AsciiStrCmp (Token, DXE_TOK) == 0) ||
168 (AsciiStrCmp (Token, BDS_TOK) == 0) ||
169 (AsciiStrCmp (Token, DRIVERBINDING_START_TOK) == 0) ||
170 (AsciiStrCmp (Token, DRIVERBINDING_SUPPORT_TOK) == 0) ||
171 (AsciiStrCmp (Token, DRIVERBINDING_STOP_TOK) == 0) ||
172 (AsciiStrCmp (Token, LOAD_IMAGE_TOK) == 0) ||
173 (AsciiStrCmp (Token, START_IMAGE_TOK) == 0) ||
174 (AsciiStrCmp (Token, PEIM_TOK) == 0))
175 {
176 return TRUE;
177 } else {
178 return FALSE;
179 }
180}
181
191BOOLEAN
193 IN UINT32 Identifier
194 )
195{
196 if ((Identifier == MODULE_START_ID) ||
197 (Identifier == MODULE_END_ID) ||
198 (Identifier == MODULE_LOADIMAGE_START_ID) ||
199 (Identifier == MODULE_LOADIMAGE_END_ID) ||
200 (Identifier == MODULE_DB_START_ID) ||
201 (Identifier == MODULE_DB_END_ID) ||
202 (Identifier == MODULE_DB_SUPPORT_START_ID) ||
203 (Identifier == MODULE_DB_SUPPORT_END_ID) ||
204 (Identifier == MODULE_DB_STOP_START_ID) ||
205 (Identifier == MODULE_DB_STOP_END_ID))
206 {
207 return TRUE;
208 } else {
209 return FALSE;
210 }
211}
212
221VOID
223 OUT VOID **SmmPerfData,
224 OUT UINTN *SmmPerfDataSize,
225 IN BOOLEAN SkipGetPerfData
226 )
227{
228 EFI_STATUS Status;
229 UINT8 *SmmBootRecordCommBuffer;
230 EFI_SMM_COMMUNICATE_HEADER *SmmCommBufferHeader;
231 SMM_BOOT_RECORD_COMMUNICATE *SmmCommData;
232 UINTN CommSize;
233 EFI_SMM_COMMUNICATION_PROTOCOL *Communication;
234 EDKII_PI_SMM_COMMUNICATION_REGION_TABLE *SmmCommRegionTable;
235 EFI_MEMORY_DESCRIPTOR *SmmCommMemRegion;
236 UINTN Index;
237 VOID *SmmBootRecordData;
238 UINTN SmmBootRecordDataSize;
239 UINTN ReservedMemSize;
240 UINTN SmmBootRecordDataRetrieved;
241
242 //
243 // Collect boot records from SMM drivers.
244 //
245 SmmBootRecordCommBuffer = NULL;
246 SmmCommData = NULL;
247 SmmBootRecordData = NULL;
248 ReservedMemSize = 0;
249 Status = gBS->LocateProtocol (&gEfiSmmCommunicationProtocolGuid, NULL, (VOID **)&Communication);
250 if (!EFI_ERROR (Status)) {
251 //
252 // Initialize communicate buffer
253 // Get the prepared Reserved Memory Range
254 //
256 &gEdkiiPiSmmCommunicationRegionTableGuid,
257 (VOID **)&SmmCommRegionTable
258 );
259 if (!EFI_ERROR (Status)) {
260 ASSERT (SmmCommRegionTable != NULL);
261 SmmCommMemRegion = (EFI_MEMORY_DESCRIPTOR *)(SmmCommRegionTable + 1);
262 for (Index = 0; Index < SmmCommRegionTable->NumberOfEntries; Index++) {
263 if (SmmCommMemRegion->Type == EfiConventionalMemory) {
264 break;
265 }
266
267 SmmCommMemRegion = (EFI_MEMORY_DESCRIPTOR *)((UINT8 *)SmmCommMemRegion + SmmCommRegionTable->DescriptorSize);
268 }
269
270 ASSERT (Index < SmmCommRegionTable->NumberOfEntries);
271 ASSERT (SmmCommMemRegion->PhysicalStart > 0);
272 ASSERT (SmmCommMemRegion->NumberOfPages > 0);
273 ReservedMemSize = (UINTN)SmmCommMemRegion->NumberOfPages * EFI_PAGE_SIZE;
274
275 //
276 // Check enough reserved memory space
277 //
278 if (ReservedMemSize > SMM_BOOT_RECORD_COMM_SIZE) {
279 SmmBootRecordCommBuffer = (VOID *)(UINTN)SmmCommMemRegion->PhysicalStart;
280 SmmCommBufferHeader = (EFI_SMM_COMMUNICATE_HEADER *)SmmBootRecordCommBuffer;
281 SmmCommData = (SMM_BOOT_RECORD_COMMUNICATE *)SmmCommBufferHeader->Data;
282 ZeroMem ((UINT8 *)SmmCommData, sizeof (SMM_BOOT_RECORD_COMMUNICATE));
283
284 CopyGuid (&SmmCommBufferHeader->HeaderGuid, &gEfiFirmwarePerformanceGuid);
285 SmmCommBufferHeader->MessageLength = sizeof (SMM_BOOT_RECORD_COMMUNICATE);
286 CommSize = SMM_BOOT_RECORD_COMM_SIZE;
287
288 //
289 // Get the size of boot records.
290 //
291 SmmCommData->Function = SMM_FPDT_FUNCTION_GET_BOOT_RECORD_SIZE;
292 SmmCommData->BootRecordData = NULL;
293 Status = Communication->Communicate (Communication, SmmBootRecordCommBuffer, &CommSize);
294
295 if (!EFI_ERROR (Status) && !EFI_ERROR (SmmCommData->ReturnStatus) && (SmmCommData->BootRecordSize != 0)) {
296 if (SkipGetPerfData) {
297 *SmmPerfDataSize = SmmCommData->BootRecordSize;
298 return;
299 }
300
301 //
302 // Get boot records starting from mSmmBootRecordOffset
303 //
304 SmmCommData->Function = SMM_FPDT_FUNCTION_GET_BOOT_RECORD_DATA_BY_OFFSET;
305 SmmCommData->BootRecordOffset = mSmmBootRecordOffset;
306 SmmBootRecordDataSize = SmmCommData->BootRecordSize - mSmmBootRecordOffset;
307 SmmBootRecordData = AllocateZeroPool (SmmBootRecordDataSize);
308 SmmBootRecordDataRetrieved = 0;
309 ASSERT (SmmBootRecordData != NULL);
310 SmmCommData->BootRecordData = (VOID *)((UINTN)SmmCommMemRegion->PhysicalStart + SMM_BOOT_RECORD_COMM_SIZE);
311 SmmCommData->BootRecordSize = ReservedMemSize - SMM_BOOT_RECORD_COMM_SIZE;
312 while (SmmBootRecordDataRetrieved < SmmBootRecordDataSize) {
313 Status = Communication->Communicate (Communication, SmmBootRecordCommBuffer, &CommSize);
314 ASSERT_EFI_ERROR (Status);
315 ASSERT_EFI_ERROR (SmmCommData->ReturnStatus);
316 if (SmmBootRecordDataRetrieved + SmmCommData->BootRecordSize > SmmBootRecordDataSize) {
317 CopyMem ((UINT8 *)SmmBootRecordData + SmmBootRecordDataRetrieved, SmmCommData->BootRecordData, SmmBootRecordDataSize - SmmBootRecordDataRetrieved);
318 } else {
319 CopyMem ((UINT8 *)SmmBootRecordData + SmmBootRecordDataRetrieved, SmmCommData->BootRecordData, SmmCommData->BootRecordSize);
320 }
321
322 SmmBootRecordDataRetrieved += SmmCommData->BootRecordSize;
323 SmmCommData->BootRecordOffset += SmmCommData->BootRecordSize;
324 }
325
326 mSmmBootRecordOffset = SmmCommData->BootRecordOffset;
327
328 *SmmPerfData = SmmBootRecordData;
329 *SmmPerfDataSize = SmmBootRecordDataSize;
330 }
331 }
332 }
333 }
334}
335
344 VOID
345 )
346{
347 EFI_STATUS Status;
348 UINTN Size;
349 UINTN BootPerformanceDataSize;
350 UINT8 *BootPerformanceData;
351 FIRMWARE_PERFORMANCE_VARIABLE PerformanceVariable;
352 UINTN SmmBootRecordDataSize;
353
354 SmmBootRecordDataSize = 0;
355
356 //
357 // Get SMM performance data size at the point of EndOfDxe in order to allocate the boot performance table.
358 // Will Get all the data at ReadyToBoot.
359 //
360 InternalGetSmmPerfData (NULL, &SmmBootRecordDataSize, TRUE);
361
362 //
363 // Prepare memory for Boot Performance table.
364 // Boot Performance table includes BasicBoot record, and one or more appended Boot Records.
365 //
366 BootPerformanceDataSize = sizeof (BOOT_PERFORMANCE_TABLE) + mPerformanceLength + SmmBootRecordDataSize + PcdGet32 (PcdExtFpdtBootRecordPadSize);
367
368 //
369 // Try to allocate the same runtime buffer as last time boot.
370 //
371 ZeroMem (&PerformanceVariable, sizeof (PerformanceVariable));
372 Size = sizeof (PerformanceVariable);
373 Status = gRT->GetVariable (
374 EFI_FIRMWARE_PERFORMANCE_VARIABLE_NAME,
375 &gEfiFirmwarePerformanceGuid,
376 NULL,
377 &Size,
378 &PerformanceVariable
379 );
380 if (!EFI_ERROR (Status)) {
381 Status = gBS->AllocatePages (
384 EFI_SIZE_TO_PAGES (BootPerformanceDataSize),
385 &PerformanceVariable.BootPerformanceTablePointer
386 );
387 if (!EFI_ERROR (Status)) {
388 mAcpiBootPerformanceTable = (BOOT_PERFORMANCE_TABLE *)(UINTN)PerformanceVariable.BootPerformanceTablePointer;
389 }
390 }
391
392 if (mAcpiBootPerformanceTable == NULL) {
393 //
394 // Fail to allocate at specified address, continue to allocate at any address.
395 //
396 mAcpiBootPerformanceTable = (BOOT_PERFORMANCE_TABLE *)AllocatePeiAccessiblePages (
398 EFI_SIZE_TO_PAGES (BootPerformanceDataSize)
399 );
400 if (mAcpiBootPerformanceTable != NULL) {
401 ZeroMem (mAcpiBootPerformanceTable, BootPerformanceDataSize);
402 }
403 }
404
405 DEBUG ((DEBUG_INFO, "DxeCorePerformanceLib: ACPI Boot Performance Table address = 0x%x\n", mAcpiBootPerformanceTable));
406
407 if (mAcpiBootPerformanceTable == NULL) {
408 return EFI_OUT_OF_RESOURCES;
409 }
410
411 //
412 // Prepare Boot Performance Table.
413 //
414 BootPerformanceData = (UINT8 *)mAcpiBootPerformanceTable;
415 //
416 // Fill Basic Boot record to Boot Performance Table.
417 //
418 CopyMem (mAcpiBootPerformanceTable, &mBootPerformanceTableTemplate, sizeof (mBootPerformanceTableTemplate));
419 BootPerformanceData = BootPerformanceData + mAcpiBootPerformanceTable->Header.Length;
420 //
421 // Fill Boot records from boot drivers.
422 //
423 if (mPerformancePointer != NULL) {
424 CopyMem (BootPerformanceData, mPerformancePointer, mPerformanceLength);
425 mAcpiBootPerformanceTable->Header.Length += mPerformanceLength;
426 BootPerformanceData = BootPerformanceData + mPerformanceLength;
427 FreePool (mPerformancePointer);
428 mPerformancePointer = NULL;
429 mPerformanceLength = 0;
430 mMaxPerformanceLength = 0;
431 }
432
433 mBootRecordBuffer = (UINT8 *)mAcpiBootPerformanceTable;
434 mBootRecordSize = mAcpiBootPerformanceTable->Header.Length;
435 mBootRecordMaxSize = BootPerformanceDataSize;
436
437 return EFI_SUCCESS;
438}
439
456 IN EFI_HANDLE Handle,
457 OUT CHAR8 *NameString,
458 IN UINTN BufferSize,
459 OUT EFI_GUID *ModuleGuid OPTIONAL
460 )
461{
462 EFI_STATUS Status;
463 EFI_LOADED_IMAGE_PROTOCOL *LoadedImage;
464 EFI_DRIVER_BINDING_PROTOCOL *DriverBinding;
465 CHAR8 *PdbFileName;
466 EFI_GUID *TempGuid;
467 UINTN StartIndex;
468 UINTN Index;
469 INTN Count;
470 BOOLEAN ModuleGuidIsGet;
471 UINTN StringSize;
472 CHAR16 *StringPtr;
473 EFI_COMPONENT_NAME2_PROTOCOL *ComponentName2;
475
476 if ((NameString == NULL) || (BufferSize == 0)) {
477 return EFI_INVALID_PARAMETER;
478 }
479
480 //
481 // Try to get the ModuleGuid and name string form the caached array.
482 //
483 if (mCachePairCount > 0) {
484 for (Count = mCachePairCount -1; Count >= 0; Count--) {
485 if (Handle == mCacheHandleGuidTable[Count].Handle) {
486 CopyGuid (ModuleGuid, &mCacheHandleGuidTable[Count].ModuleGuid);
487 AsciiStrCpyS (NameString, FPDT_STRING_EVENT_RECORD_NAME_LENGTH, mCacheHandleGuidTable[Count].NameString);
488 return EFI_SUCCESS;
489 }
490 }
491 }
492
493 Status = EFI_INVALID_PARAMETER;
494 LoadedImage = NULL;
495 ModuleGuidIsGet = FALSE;
496
497 //
498 // Initialize GUID as zero value.
499 //
500 TempGuid = &gZeroGuid;
501 //
502 // Initialize it as "" string.
503 //
504 NameString[0] = 0;
505
506 if (Handle != NULL) {
507 //
508 // Try Handle as ImageHandle.
509 //
510 Status = gBS->HandleProtocol (
511 Handle,
512 &gEfiLoadedImageProtocolGuid,
513 (VOID **)&LoadedImage
514 );
515
516 if (EFI_ERROR (Status)) {
517 //
518 // Try Handle as Controller Handle
519 //
520 Status = gBS->OpenProtocol (
521 Handle,
522 &gEfiDriverBindingProtocolGuid,
523 (VOID **)&DriverBinding,
524 NULL,
525 NULL,
526 EFI_OPEN_PROTOCOL_GET_PROTOCOL
527 );
528 if (!EFI_ERROR (Status)) {
529 //
530 // Get Image protocol from ImageHandle
531 //
532 Status = gBS->HandleProtocol (
533 DriverBinding->ImageHandle,
534 &gEfiLoadedImageProtocolGuid,
535 (VOID **)&LoadedImage
536 );
537 }
538 }
539 }
540
541 if (!EFI_ERROR (Status) && (LoadedImage != NULL)) {
542 //
543 // Get Module Guid from DevicePath.
544 //
545 if ((LoadedImage->FilePath != NULL) &&
546 (LoadedImage->FilePath->Type == MEDIA_DEVICE_PATH) &&
547 (LoadedImage->FilePath->SubType == MEDIA_PIWG_FW_FILE_DP)
548 )
549 {
550 //
551 // Determine GUID associated with module logging performance
552 //
553 ModuleGuidIsGet = TRUE;
554 FvFilePath = (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *)LoadedImage->FilePath;
555 TempGuid = &FvFilePath->FvFileName;
556 }
557
558 //
559 // Method 1 Get Module Name from PDB string.
560 //
561 PdbFileName = PeCoffLoaderGetPdbPointer (LoadedImage->ImageBase);
562 if ((PdbFileName != NULL) && (BufferSize > 0)) {
563 StartIndex = 0;
564 for (Index = 0; PdbFileName[Index] != 0; Index++) {
565 if ((PdbFileName[Index] == '\\') || (PdbFileName[Index] == '/')) {
566 StartIndex = Index + 1;
567 }
568 }
569
570 //
571 // Copy the PDB file name to our temporary string.
572 // If the length is bigger than BufferSize, trim the redudant characters to avoid overflow in array boundary.
573 //
574 for (Index = 0; Index < BufferSize - 1; Index++) {
575 NameString[Index] = PdbFileName[Index + StartIndex];
576 if ((NameString[Index] == 0) || (NameString[Index] == '.')) {
577 NameString[Index] = 0;
578 break;
579 }
580 }
581
582 if (Index == BufferSize - 1) {
583 NameString[Index] = 0;
584 }
585
586 //
587 // Module Name is got.
588 //
589 goto Done;
590 }
591 }
592
593 //
594 // Method 2: Get the name string from ComponentName2 protocol
595 //
596 Status = gBS->HandleProtocol (
597 Handle,
598 &gEfiComponentName2ProtocolGuid,
599 (VOID **)&ComponentName2
600 );
601 if (!EFI_ERROR (Status)) {
602 //
603 // Get the current platform language setting
604 //
605 if (mPlatformLanguage == NULL) {
606 GetEfiGlobalVariable2 (L"PlatformLang", (VOID **)&mPlatformLanguage, NULL);
607 }
608
609 if (mPlatformLanguage != NULL) {
610 Status = ComponentName2->GetDriverName (
611 ComponentName2,
612 mPlatformLanguage != NULL ? mPlatformLanguage : "en-US",
613 &StringPtr
614 );
615 if (!EFI_ERROR (Status)) {
616 for (Index = 0; Index < BufferSize - 1 && StringPtr[Index] != 0; Index++) {
617 NameString[Index] = (CHAR8)StringPtr[Index];
618 }
619
620 NameString[Index] = 0;
621 //
622 // Module Name is got.
623 //
624 goto Done;
625 }
626 }
627 }
628
629 if (ModuleGuidIsGet) {
630 //
631 // Method 3 Try to get the image's FFS UI section by image GUID
632 //
633 StringPtr = NULL;
634 StringSize = 0;
635 Status = GetSectionFromAnyFv (
636 TempGuid,
637 EFI_SECTION_USER_INTERFACE,
638 0,
639 (VOID **)&StringPtr,
640 &StringSize
641 );
642
643 if (!EFI_ERROR (Status)) {
644 //
645 // Method 3. Get the name string from FFS UI section
646 //
647 for (Index = 0; Index < BufferSize - 1 && StringPtr[Index] != 0; Index++) {
648 NameString[Index] = (CHAR8)StringPtr[Index];
649 }
650
651 NameString[Index] = 0;
652 FreePool (StringPtr);
653 }
654 }
655
656Done:
657 //
658 // Copy Module Guid
659 //
660 if (ModuleGuid != NULL) {
661 CopyGuid (ModuleGuid, TempGuid);
662 if (IsZeroGuid (TempGuid) && (Handle != NULL) && !ModuleGuidIsGet) {
663 // Handle is GUID
664 CopyGuid (ModuleGuid, (EFI_GUID *)Handle);
665 }
666 }
667
668 //
669 // Cache the Handle and Guid pairs.
670 //
671 if (mCachePairCount < CACHE_HANDLE_GUID_COUNT) {
672 mCacheHandleGuidTable[mCachePairCount].Handle = Handle;
673 CopyGuid (&mCacheHandleGuidTable[mCachePairCount].ModuleGuid, ModuleGuid);
674 AsciiStrCpyS (mCacheHandleGuidTable[mCachePairCount].NameString, FPDT_STRING_EVENT_RECORD_NAME_LENGTH, NameString);
675 mCachePairCount++;
676 }
677
678 return Status;
679}
680
697 IN PERF_MEASUREMENT_ATTRIBUTE Attribute,
698 IN CONST VOID *Handle,
699 IN CONST CHAR8 *String,
700 OUT UINT16 *ProgressID
701 )
702{
703 //
704 // Token to PerfId.
705 //
706 if (String != NULL) {
707 if (AsciiStrCmp (String, START_IMAGE_TOK) == 0) {
708 // "StartImage:"
709 if (Attribute == PerfStartEntry) {
710 *ProgressID = MODULE_START_ID;
711 } else {
712 *ProgressID = MODULE_END_ID;
713 }
714 } else if (AsciiStrCmp (String, LOAD_IMAGE_TOK) == 0) {
715 // "LoadImage:"
716 if (Attribute == PerfStartEntry) {
717 *ProgressID = MODULE_LOADIMAGE_START_ID;
718 } else {
719 *ProgressID = MODULE_LOADIMAGE_END_ID;
720 }
721 } else if (AsciiStrCmp (String, DRIVERBINDING_START_TOK) == 0) {
722 // "DB:Start:"
723 if (Attribute == PerfStartEntry) {
724 *ProgressID = MODULE_DB_START_ID;
725 } else {
726 *ProgressID = MODULE_DB_END_ID;
727 }
728 } else if (AsciiStrCmp (String, DRIVERBINDING_SUPPORT_TOK) == 0) {
729 // "DB:Support:"
730 if (PcdGetBool (PcdEdkiiFpdtStringRecordEnableOnly)) {
731 return RETURN_UNSUPPORTED;
732 }
733
734 if (Attribute == PerfStartEntry) {
735 *ProgressID = MODULE_DB_SUPPORT_START_ID;
736 } else {
737 *ProgressID = MODULE_DB_SUPPORT_END_ID;
738 }
739 } else if (AsciiStrCmp (String, DRIVERBINDING_STOP_TOK) == 0) {
740 // "DB:Stop:"
741 if (PcdGetBool (PcdEdkiiFpdtStringRecordEnableOnly)) {
742 return RETURN_UNSUPPORTED;
743 }
744
745 if (Attribute == PerfStartEntry) {
746 *ProgressID = MODULE_DB_STOP_START_ID;
747 } else {
748 *ProgressID = MODULE_DB_STOP_END_ID;
749 }
750 } else if ((AsciiStrCmp (String, PEI_TOK) == 0) || // "PEI"
751 (AsciiStrCmp (String, DXE_TOK) == 0) || // "DXE"
752 (AsciiStrCmp (String, BDS_TOK) == 0)) // "BDS"
753 {
754 if (Attribute == PerfStartEntry) {
755 *ProgressID = PERF_CROSSMODULE_START_ID;
756 } else {
757 *ProgressID = PERF_CROSSMODULE_END_ID;
758 }
759 } else {
760 // Pref used in Modules.
761 if (Attribute == PerfStartEntry) {
762 *ProgressID = PERF_INMODULE_START_ID;
763 } else {
764 *ProgressID = PERF_INMODULE_END_ID;
765 }
766 }
767 } else if (Handle != NULL) {
768 // Pref used in Modules.
769 if (Attribute == PerfStartEntry) {
770 *ProgressID = PERF_INMODULE_START_ID;
771 } else {
772 *ProgressID = PERF_INMODULE_END_ID;
773 }
774 } else {
775 return EFI_INVALID_PARAMETER;
776 }
777
778 return EFI_SUCCESS;
779}
780
790VOID
792 IN OUT CHAR8 *Destination,
793 IN CONST CHAR8 *Source,
794 IN OUT UINT8 *Length
795 )
796{
797 UINTN StringLen;
798 UINTN DestMax;
799
800 ASSERT (Source != NULL);
801
802 if (PcdGetBool (PcdEdkiiFpdtStringRecordEnableOnly)) {
803 DestMax = STRING_SIZE;
804 } else {
805 DestMax = AsciiStrSize (Source);
806 if (DestMax > STRING_SIZE) {
807 DestMax = STRING_SIZE;
808 }
809 }
810
811 StringLen = AsciiStrLen (Source);
812 if (StringLen >= DestMax) {
813 StringLen = DestMax -1;
814 }
815
816 AsciiStrnCpyS (Destination, DestMax, Source, StringLen);
817 *Length += (UINT8)DestMax;
818
819 return;
820}
821
838 IN CONST VOID *Handle,
839 IN EFI_HANDLE ControllerHandle,
840 OUT CHAR8 *ComponentNameString,
841 IN OUT UINT8 *Length
842 )
843{
844 EFI_DEVICE_PATH_PROTOCOL *DevicePathProtocol;
845 EFI_COMPONENT_NAME2_PROTOCOL *ComponentName2;
846 EFI_STATUS Status;
847 CHAR16 *StringPtr;
848 CHAR8 *AsciiStringPtr;
849 UINTN ControllerNameStringSize;
850 UINTN DevicePathStringSize;
851
852 ControllerNameStringSize = 0;
853
854 Status = gBS->HandleProtocol (
855 (EFI_HANDLE)Handle,
856 &gEfiComponentName2ProtocolGuid,
857 (VOID **)&ComponentName2
858 );
859
860 if (!EFI_ERROR (Status)) {
861 //
862 // Get the current platform language setting
863 //
864 if (mPlatformLanguage == NULL) {
865 GetEfiGlobalVariable2 (L"PlatformLang", (VOID **)&mPlatformLanguage, NULL);
866 }
867
868 Status = ComponentName2->GetControllerName (
869 ComponentName2,
870 ControllerHandle,
871 NULL,
872 mPlatformLanguage != NULL ? mPlatformLanguage : "en-US",
873 &StringPtr
874 );
875 }
876
877 if (!EFI_ERROR (Status)) {
878 //
879 // This will produce the size of the unicode string, which is twice as large as the ASCII one
880 // This must be an even number, so ok to divide by 2
881 //
882 ControllerNameStringSize = StrSize (StringPtr) / 2;
883
884 //
885 // The + 1 is because we want to add a space between the ControllerName and the device path
886 //
887 if ((ControllerNameStringSize + (*Length) + 1) > FPDT_MAX_PERF_RECORD_SIZE) {
888 //
889 // Only copy enough to fill FPDT_MAX_PERF_RECORD_SIZE worth of the record
890 //
891 ControllerNameStringSize = FPDT_MAX_PERF_RECORD_SIZE - (*Length) - 1;
892 }
893
894 UnicodeStrnToAsciiStrS (StringPtr, ControllerNameStringSize - 1, ComponentNameString, ControllerNameStringSize, &ControllerNameStringSize);
895
896 //
897 // Add a space in the end of the ControllerName
898 //
899 AsciiStringPtr = ComponentNameString + ControllerNameStringSize - 1;
900 *AsciiStringPtr = 0x20;
901 AsciiStringPtr++;
902 *AsciiStringPtr = 0;
903 ControllerNameStringSize++;
904
905 *Length += (UINT8)ControllerNameStringSize;
906 }
907
908 //
909 // This function returns the device path protocol from the handle specified by Handle. If Handle is
910 // NULL or Handle does not contain a device path protocol, then NULL is returned.
911 //
912 DevicePathProtocol = DevicePathFromHandle (ControllerHandle);
913
914 if (DevicePathProtocol != NULL) {
915 StringPtr = ConvertDevicePathToText (DevicePathProtocol, TRUE, FALSE);
916 if (StringPtr != NULL) {
917 //
918 // This will produce the size of the unicode string, which is twice as large as the ASCII one
919 // This must be an even number, so ok to divide by 2
920 //
921 DevicePathStringSize = StrSize (StringPtr) / 2;
922
923 if ((DevicePathStringSize + (*Length)) > FPDT_MAX_PERF_RECORD_SIZE) {
924 //
925 // Only copy enough to fill FPDT_MAX_PERF_RECORD_SIZE worth of the record
926 //
927 DevicePathStringSize = FPDT_MAX_PERF_RECORD_SIZE - (*Length);
928 }
929
930 if (ControllerNameStringSize != 0) {
931 AsciiStringPtr = ComponentNameString + ControllerNameStringSize - 1;
932 } else {
933 AsciiStringPtr = ComponentNameString;
934 }
935
936 UnicodeStrnToAsciiStrS (StringPtr, DevicePathStringSize - 1, AsciiStringPtr, DevicePathStringSize, &DevicePathStringSize);
937 *Length += (UINT8)DevicePathStringSize;
938 return EFI_SUCCESS;
939 }
940 }
941
942 return EFI_UNSUPPORTED;
943}
944
971 IN CONST VOID *CallerIdentifier OPTIONAL,
972 IN CONST VOID *Guid OPTIONAL,
973 IN CONST CHAR8 *String OPTIONAL,
974 IN UINT64 Ticker,
975 IN UINT64 Address OPTIONAL,
976 IN UINT16 PerfId,
977 IN PERF_MEASUREMENT_ATTRIBUTE Attribute
978 )
979{
980 EFI_GUID ModuleGuid;
981 CHAR8 ModuleName[FPDT_STRING_EVENT_RECORD_NAME_LENGTH];
982 FPDT_RECORD_PTR FpdtRecordPtr;
983 FPDT_RECORD_PTR CachedFpdtRecordPtr;
984 UINT64 TimeStamp;
985 CONST CHAR8 *StringPtr;
986 UINTN DestMax;
987 UINTN StringLen;
988 EFI_STATUS Status;
989 UINT16 ProgressId;
990
991 StringPtr = NULL;
992 ProgressId = 0;
993 ZeroMem (ModuleName, sizeof (ModuleName));
994
995 //
996 // 1. Get the Perf Id for records from PERF_START/PERF_END, PERF_START_EX/PERF_END_EX.
997 // notes: For other Perf macros (Attribute == PerfEntry), their Id is known.
998 //
999 if (Attribute != PerfEntry) {
1000 //
1001 // If PERF_START_EX()/PERF_END_EX() have specified the ProgressID,it has high priority.
1002 // !!! Note: If the Perf is not the known Token used in the core but have same
1003 // ID with the core Token, this case will not be supported.
1004 // And in currtnt usage mode, for the unkown ID, there is a general rule:
1005 // If it is start pref: the lower 4 bits of the ID should be 0.
1006 // If it is end pref: the lower 4 bits of the ID should not be 0.
1007 // If input ID doesn't follow the rule, we will adjust it.
1008 //
1009 if ((PerfId != 0) && (IsKnownID (PerfId)) && (!IsKnownTokens (String))) {
1010 return EFI_INVALID_PARAMETER;
1011 } else if ((PerfId != 0) && (!IsKnownID (PerfId)) && (!IsKnownTokens (String))) {
1012 if ((Attribute == PerfStartEntry) && ((PerfId & 0x000F) != 0)) {
1013 PerfId &= 0xFFF0;
1014 } else if ((Attribute == PerfEndEntry) && ((PerfId & 0x000F) == 0)) {
1015 PerfId += 1;
1016 }
1017 } else if (PerfId == 0) {
1018 //
1019 // Get ProgressID form the String Token.
1020 //
1021 Status = GetFpdtRecordId (Attribute, CallerIdentifier, String, &ProgressId);
1022 if (EFI_ERROR (Status)) {
1023 return Status;
1024 }
1025
1026 PerfId = ProgressId;
1027 }
1028 }
1029
1030 //
1031 // 2. Get the buffer to store the FPDT record.
1032 //
1033 Status = GetFpdtRecordPtr (FPDT_MAX_PERF_RECORD_SIZE, &FpdtRecordPtr);
1034 if (EFI_ERROR (Status)) {
1035 return Status;
1036 }
1037
1038 //
1039 // 3. Get the TimeStamp.
1040 //
1041 if (Ticker == 0) {
1042 Ticker = GetPerformanceCounter ();
1043 TimeStamp = GetTimeInNanoSecond (Ticker);
1044 } else if (Ticker == 1) {
1045 TimeStamp = 0;
1046 } else {
1047 TimeStamp = GetTimeInNanoSecond (Ticker);
1048 }
1049
1050 //
1051 // 4. Fill in the FPDT record according to different Performance Identifier.
1052 //
1053 switch (PerfId) {
1054 case MODULE_START_ID:
1055 case MODULE_END_ID:
1056 GetModuleInfoFromHandle ((EFI_HANDLE)CallerIdentifier, ModuleName, sizeof (ModuleName), &ModuleGuid);
1057 StringPtr = ModuleName;
1058 //
1059 // Cache the offset of start image start record and use to update the start image end record if needed.
1060 //
1061 if ((Attribute == PerfEntry) && (PerfId == MODULE_START_ID)) {
1062 if (mFpdtBufferIsReported) {
1063 mCachedLength = mBootRecordSize;
1064 } else {
1065 mCachedLength = mPerformanceLength;
1066 }
1067 }
1068
1069 if (!PcdGetBool (PcdEdkiiFpdtStringRecordEnableOnly)) {
1070 FpdtRecordPtr.GuidEvent->Header.Type = FPDT_GUID_EVENT_TYPE;
1071 FpdtRecordPtr.GuidEvent->Header.Length = sizeof (FPDT_GUID_EVENT_RECORD);
1072 FpdtRecordPtr.GuidEvent->Header.Revision = FPDT_RECORD_REVISION_1;
1073 FpdtRecordPtr.GuidEvent->ProgressID = PerfId;
1074 FpdtRecordPtr.GuidEvent->Timestamp = TimeStamp;
1075 CopyMem (&FpdtRecordPtr.GuidEvent->Guid, &ModuleGuid, sizeof (FpdtRecordPtr.GuidEvent->Guid));
1076 if ((CallerIdentifier == NULL) && (PerfId == MODULE_END_ID) && (mCachedLength != 0)) {
1077 if (mFpdtBufferIsReported) {
1078 CachedFpdtRecordPtr.RecordHeader = (EFI_ACPI_5_0_FPDT_PERFORMANCE_RECORD_HEADER *)(mBootRecordBuffer + mCachedLength);
1079 } else {
1080 CachedFpdtRecordPtr.RecordHeader = (EFI_ACPI_5_0_FPDT_PERFORMANCE_RECORD_HEADER *)(mPerformancePointer + mCachedLength);
1081 }
1082
1083 CopyMem (&FpdtRecordPtr.GuidEvent->Guid, &CachedFpdtRecordPtr.GuidEvent->Guid, sizeof (FpdtRecordPtr.GuidEvent->Guid));
1084 mCachedLength = 0;
1085 }
1086 }
1087
1088 break;
1089
1090 case MODULE_LOADIMAGE_START_ID:
1091 case MODULE_LOADIMAGE_END_ID:
1092 GetModuleInfoFromHandle ((EFI_HANDLE)CallerIdentifier, ModuleName, sizeof (ModuleName), &ModuleGuid);
1093 StringPtr = ModuleName;
1094 if (PerfId == MODULE_LOADIMAGE_START_ID) {
1095 mLoadImageCount++;
1096 //
1097 // Cache the offset of load image start record and use to be updated by the load image end record if needed.
1098 //
1099 if ((CallerIdentifier == NULL) && (Attribute == PerfEntry)) {
1100 if (mFpdtBufferIsReported) {
1101 mCachedLength = mBootRecordSize;
1102 } else {
1103 mCachedLength = mPerformanceLength;
1104 }
1105 }
1106 }
1107
1108 if (!PcdGetBool (PcdEdkiiFpdtStringRecordEnableOnly)) {
1109 FpdtRecordPtr.GuidQwordEvent->Header.Type = FPDT_GUID_QWORD_EVENT_TYPE;
1110 FpdtRecordPtr.GuidQwordEvent->Header.Length = sizeof (FPDT_GUID_QWORD_EVENT_RECORD);
1111 FpdtRecordPtr.GuidQwordEvent->Header.Revision = FPDT_RECORD_REVISION_1;
1112 FpdtRecordPtr.GuidQwordEvent->ProgressID = PerfId;
1113 FpdtRecordPtr.GuidQwordEvent->Timestamp = TimeStamp;
1114 FpdtRecordPtr.GuidQwordEvent->Qword = mLoadImageCount;
1115 CopyMem (&FpdtRecordPtr.GuidQwordEvent->Guid, &ModuleGuid, sizeof (FpdtRecordPtr.GuidQwordEvent->Guid));
1116 if ((PerfId == MODULE_LOADIMAGE_END_ID) && (mCachedLength != 0)) {
1117 if (mFpdtBufferIsReported) {
1118 CachedFpdtRecordPtr.RecordHeader = (EFI_ACPI_5_0_FPDT_PERFORMANCE_RECORD_HEADER *)(mBootRecordBuffer + mCachedLength);
1119 } else {
1120 CachedFpdtRecordPtr.RecordHeader = (EFI_ACPI_5_0_FPDT_PERFORMANCE_RECORD_HEADER *)(mPerformancePointer + mCachedLength);
1121 }
1122
1123 CopyMem (&CachedFpdtRecordPtr.GuidQwordEvent->Guid, &ModuleGuid, sizeof (CachedFpdtRecordPtr.GuidQwordEvent->Guid));
1124 mCachedLength = 0;
1125 }
1126 }
1127
1128 break;
1129
1130 case MODULE_DB_START_ID:
1131 case MODULE_DB_SUPPORT_START_ID:
1132 case MODULE_DB_SUPPORT_END_ID:
1133 case MODULE_DB_STOP_START_ID:
1134 case MODULE_DB_STOP_END_ID:
1135 GetModuleInfoFromHandle ((EFI_HANDLE)CallerIdentifier, ModuleName, sizeof (ModuleName), &ModuleGuid);
1136 StringPtr = ModuleName;
1137 if (!PcdGetBool (PcdEdkiiFpdtStringRecordEnableOnly)) {
1138 FpdtRecordPtr.GuidQwordEvent->Header.Type = FPDT_GUID_QWORD_EVENT_TYPE;
1139 FpdtRecordPtr.GuidQwordEvent->Header.Length = sizeof (FPDT_GUID_QWORD_EVENT_RECORD);
1140 FpdtRecordPtr.GuidQwordEvent->Header.Revision = FPDT_RECORD_REVISION_1;
1141 FpdtRecordPtr.GuidQwordEvent->ProgressID = PerfId;
1142 FpdtRecordPtr.GuidQwordEvent->Timestamp = TimeStamp;
1143 FpdtRecordPtr.GuidQwordEvent->Qword = Address;
1144 CopyMem (&FpdtRecordPtr.GuidQwordEvent->Guid, &ModuleGuid, sizeof (FpdtRecordPtr.GuidQwordEvent->Guid));
1145 }
1146
1147 break;
1148
1149 case MODULE_DB_END_ID:
1150 GetModuleInfoFromHandle ((EFI_HANDLE)CallerIdentifier, ModuleName, sizeof (ModuleName), &ModuleGuid);
1151 StringPtr = ModuleName;
1152 if (!PcdGetBool (PcdEdkiiFpdtStringRecordEnableOnly)) {
1153 FpdtRecordPtr.GuidQwordStringEvent->Header.Type = FPDT_GUID_QWORD_STRING_EVENT_TYPE;
1154 FpdtRecordPtr.GuidQwordStringEvent->Header.Length = sizeof (FPDT_GUID_QWORD_STRING_EVENT_RECORD);
1155 FpdtRecordPtr.GuidQwordStringEvent->Header.Revision = FPDT_RECORD_REVISION_1;
1156 FpdtRecordPtr.GuidQwordStringEvent->ProgressID = PerfId;
1157 FpdtRecordPtr.GuidQwordStringEvent->Timestamp = TimeStamp;
1158 FpdtRecordPtr.GuidQwordStringEvent->Qword = Address;
1159 CopyMem (&FpdtRecordPtr.GuidQwordStringEvent->Guid, &ModuleGuid, sizeof (FpdtRecordPtr.GuidQwordStringEvent->Guid));
1160 if (Address != 0) {
1161 GetDeviceInfoFromHandleAndUpdateLength (CallerIdentifier, (EFI_HANDLE)(UINTN)Address, FpdtRecordPtr.GuidQwordStringEvent->String, &FpdtRecordPtr.GuidQwordStringEvent->Header.Length);
1162 }
1163 }
1164
1165 break;
1166
1167 case PERF_EVENTSIGNAL_START_ID:
1168 case PERF_EVENTSIGNAL_END_ID:
1169 case PERF_CALLBACK_START_ID:
1170 case PERF_CALLBACK_END_ID:
1171 if ((String == NULL) || (Guid == NULL)) {
1172 return EFI_INVALID_PARAMETER;
1173 }
1174
1175 StringPtr = String;
1176 if (AsciiStrLen (String) == 0) {
1177 StringPtr = "unknown name";
1178 }
1179
1180 if (!PcdGetBool (PcdEdkiiFpdtStringRecordEnableOnly)) {
1181 FpdtRecordPtr.DualGuidStringEvent->Header.Type = FPDT_DUAL_GUID_STRING_EVENT_TYPE;
1182 FpdtRecordPtr.DualGuidStringEvent->Header.Length = sizeof (FPDT_DUAL_GUID_STRING_EVENT_RECORD);
1183 FpdtRecordPtr.DualGuidStringEvent->Header.Revision = FPDT_RECORD_REVISION_1;
1184 FpdtRecordPtr.DualGuidStringEvent->ProgressID = PerfId;
1185 FpdtRecordPtr.DualGuidStringEvent->Timestamp = TimeStamp;
1186 CopyMem (&FpdtRecordPtr.DualGuidStringEvent->Guid1, CallerIdentifier, sizeof (FpdtRecordPtr.DualGuidStringEvent->Guid1));
1187 CopyMem (&FpdtRecordPtr.DualGuidStringEvent->Guid2, Guid, sizeof (FpdtRecordPtr.DualGuidStringEvent->Guid2));
1188 CopyStringIntoPerfRecordAndUpdateLength (FpdtRecordPtr.DualGuidStringEvent->String, StringPtr, &FpdtRecordPtr.DualGuidStringEvent->Header.Length);
1189 }
1190
1191 break;
1192
1193 case PERF_EVENT_ID:
1194 case PERF_FUNCTION_START_ID:
1195 case PERF_FUNCTION_END_ID:
1196 case PERF_INMODULE_START_ID:
1197 case PERF_INMODULE_END_ID:
1198 case PERF_CROSSMODULE_START_ID:
1199 case PERF_CROSSMODULE_END_ID:
1200 GetModuleInfoFromHandle ((EFI_HANDLE)CallerIdentifier, ModuleName, sizeof (ModuleName), &ModuleGuid);
1201 if (String != NULL) {
1202 StringPtr = String;
1203 } else {
1204 StringPtr = ModuleName;
1205 }
1206
1207 if (AsciiStrLen (StringPtr) == 0) {
1208 StringPtr = "unknown name";
1209 }
1210
1211 if (!PcdGetBool (PcdEdkiiFpdtStringRecordEnableOnly)) {
1212 FpdtRecordPtr.DynamicStringEvent->Header.Type = FPDT_DYNAMIC_STRING_EVENT_TYPE;
1213 FpdtRecordPtr.DynamicStringEvent->Header.Length = sizeof (FPDT_DYNAMIC_STRING_EVENT_RECORD);
1214 FpdtRecordPtr.DynamicStringEvent->Header.Revision = FPDT_RECORD_REVISION_1;
1215 FpdtRecordPtr.DynamicStringEvent->ProgressID = PerfId;
1216 FpdtRecordPtr.DynamicStringEvent->Timestamp = TimeStamp;
1217 CopyMem (&FpdtRecordPtr.DynamicStringEvent->Guid, &ModuleGuid, sizeof (FpdtRecordPtr.DynamicStringEvent->Guid));
1218 CopyStringIntoPerfRecordAndUpdateLength (FpdtRecordPtr.DynamicStringEvent->String, StringPtr, &FpdtRecordPtr.DynamicStringEvent->Header.Length);
1219 }
1220
1221 break;
1222
1223 default:
1224 if (Attribute != PerfEntry) {
1225 GetModuleInfoFromHandle ((EFI_HANDLE)CallerIdentifier, ModuleName, sizeof (ModuleName), &ModuleGuid);
1226 if (String != NULL) {
1227 StringPtr = String;
1228 } else {
1229 StringPtr = ModuleName;
1230 }
1231
1232 if (AsciiStrLen (StringPtr) == 0) {
1233 StringPtr = "unknown name";
1234 }
1235
1236 if (!PcdGetBool (PcdEdkiiFpdtStringRecordEnableOnly)) {
1237 FpdtRecordPtr.DynamicStringEvent->Header.Type = FPDT_DYNAMIC_STRING_EVENT_TYPE;
1238 FpdtRecordPtr.DynamicStringEvent->Header.Length = sizeof (FPDT_DYNAMIC_STRING_EVENT_RECORD);
1239 FpdtRecordPtr.DynamicStringEvent->Header.Revision = FPDT_RECORD_REVISION_1;
1240 FpdtRecordPtr.DynamicStringEvent->ProgressID = PerfId;
1241 FpdtRecordPtr.DynamicStringEvent->Timestamp = TimeStamp;
1242 CopyMem (&FpdtRecordPtr.DynamicStringEvent->Guid, &ModuleGuid, sizeof (FpdtRecordPtr.DynamicStringEvent->Guid));
1243 CopyStringIntoPerfRecordAndUpdateLength (FpdtRecordPtr.DynamicStringEvent->String, StringPtr, &FpdtRecordPtr.DynamicStringEvent->Header.Length);
1244 }
1245 } else {
1246 return EFI_INVALID_PARAMETER;
1247 }
1248
1249 break;
1250 }
1251
1252 //
1253 // 4.2 When PcdEdkiiFpdtStringRecordEnableOnly==TRUE, create string record for all Perf entries.
1254 //
1255 if (PcdGetBool (PcdEdkiiFpdtStringRecordEnableOnly)) {
1256 if ((StringPtr == NULL) || (PerfId == MODULE_DB_SUPPORT_START_ID) || (PerfId == MODULE_DB_SUPPORT_END_ID)) {
1257 return EFI_INVALID_PARAMETER;
1258 }
1259
1260 FpdtRecordPtr.DynamicStringEvent->Header.Type = FPDT_DYNAMIC_STRING_EVENT_TYPE;
1261 FpdtRecordPtr.DynamicStringEvent->Header.Length = sizeof (FPDT_DYNAMIC_STRING_EVENT_RECORD);
1262 FpdtRecordPtr.DynamicStringEvent->Header.Revision = FPDT_RECORD_REVISION_1;
1263 FpdtRecordPtr.DynamicStringEvent->ProgressID = PerfId;
1264 FpdtRecordPtr.DynamicStringEvent->Timestamp = TimeStamp;
1265 if (Guid != NULL) {
1266 //
1267 // Cache the event guid in string event record.
1268 //
1269 CopyMem (&FpdtRecordPtr.DynamicStringEvent->Guid, Guid, sizeof (FpdtRecordPtr.DynamicStringEvent->Guid));
1270 } else {
1271 CopyMem (&FpdtRecordPtr.DynamicStringEvent->Guid, &ModuleGuid, sizeof (FpdtRecordPtr.DynamicStringEvent->Guid));
1272 }
1273
1274 if (AsciiStrLen (StringPtr) == 0) {
1275 StringPtr = "unknown name";
1276 }
1277
1278 CopyStringIntoPerfRecordAndUpdateLength (FpdtRecordPtr.DynamicStringEvent->String, StringPtr, &FpdtRecordPtr.DynamicStringEvent->Header.Length);
1279
1280 if ((PerfId == MODULE_LOADIMAGE_START_ID) || (PerfId == MODULE_END_ID)) {
1281 FpdtRecordPtr.DynamicStringEvent->Header.Length = (UINT8)(sizeof (FPDT_DYNAMIC_STRING_EVENT_RECORD)+ STRING_SIZE);
1282 }
1283
1284 if (((PerfId == MODULE_LOADIMAGE_END_ID) || (PerfId == MODULE_END_ID)) && (mCachedLength != 0)) {
1285 if (mFpdtBufferIsReported) {
1286 CachedFpdtRecordPtr.RecordHeader = (EFI_ACPI_5_0_FPDT_PERFORMANCE_RECORD_HEADER *)(mBootRecordBuffer + mCachedLength);
1287 } else {
1288 CachedFpdtRecordPtr.RecordHeader = (EFI_ACPI_5_0_FPDT_PERFORMANCE_RECORD_HEADER *)(mPerformancePointer + mCachedLength);
1289 }
1290
1291 if (PerfId == MODULE_LOADIMAGE_END_ID) {
1292 DestMax = CachedFpdtRecordPtr.DynamicStringEvent->Header.Length - sizeof (FPDT_DYNAMIC_STRING_EVENT_RECORD);
1293 StringLen = AsciiStrLen (StringPtr);
1294 if (StringLen >= DestMax) {
1295 StringLen = DestMax -1;
1296 }
1297
1298 CopyMem (&CachedFpdtRecordPtr.DynamicStringEvent->Guid, &ModuleGuid, sizeof (CachedFpdtRecordPtr.DynamicStringEvent->Guid));
1299 AsciiStrnCpyS (CachedFpdtRecordPtr.DynamicStringEvent->String, DestMax, StringPtr, StringLen);
1300 } else if (PerfId == MODULE_END_ID) {
1301 DestMax = FpdtRecordPtr.DynamicStringEvent->Header.Length - sizeof (FPDT_DYNAMIC_STRING_EVENT_RECORD);
1302 StringLen = AsciiStrLen (CachedFpdtRecordPtr.DynamicStringEvent->String);
1303 if (StringLen >= DestMax) {
1304 StringLen = DestMax -1;
1305 }
1306
1307 CopyMem (&FpdtRecordPtr.DynamicStringEvent->Guid, &CachedFpdtRecordPtr.DynamicStringEvent->Guid, sizeof (CachedFpdtRecordPtr.DynamicStringEvent->Guid));
1308 AsciiStrnCpyS (FpdtRecordPtr.DynamicStringEvent->String, DestMax, CachedFpdtRecordPtr.DynamicStringEvent->String, StringLen);
1309 }
1310
1311 mCachedLength = 0;
1312 }
1313 }
1314
1315 //
1316 // 5. Update the length of the used buffer after fill in the record.
1317 //
1318 if (mFpdtBufferIsReported) {
1319 mBootRecordSize += FpdtRecordPtr.RecordHeader->Length;
1320 mAcpiBootPerformanceTable->Header.Length += FpdtRecordPtr.RecordHeader->Length;
1321 } else {
1322 mPerformanceLength += FpdtRecordPtr.RecordHeader->Length;
1323 }
1324
1325 return EFI_SUCCESS;
1326}
1327
1338VOID
1340 VOID *HobStart
1341 )
1342{
1343 UINT8 *FirmwarePerformanceHob;
1344 FPDT_PEI_EXT_PERF_HEADER *PeiPerformanceLogHeader;
1345 UINT8 *EventRec;
1346 EFI_HOB_GUID_TYPE *GuidHob;
1347
1348 GuidHob = GetNextGuidHob (&gEdkiiFpdtExtendedFirmwarePerformanceGuid, HobStart);
1349 while (GuidHob != NULL) {
1350 FirmwarePerformanceHob = GET_GUID_HOB_DATA (GuidHob);
1351 PeiPerformanceLogHeader = (FPDT_PEI_EXT_PERF_HEADER *)FirmwarePerformanceHob;
1352
1353 if (mPerformanceLength + PeiPerformanceLogHeader->SizeOfAllEntries > mMaxPerformanceLength) {
1354 mPerformancePointer = ReallocatePool (
1355 mPerformanceLength,
1356 mPerformanceLength +
1357 (UINTN)PeiPerformanceLogHeader->SizeOfAllEntries +
1358 FIRMWARE_RECORD_BUFFER,
1359 mPerformancePointer
1360 );
1361 ASSERT (mPerformancePointer != NULL);
1362 mMaxPerformanceLength = mPerformanceLength +
1363 (UINTN)(PeiPerformanceLogHeader->SizeOfAllEntries) +
1364 FIRMWARE_RECORD_BUFFER;
1365 }
1366
1367 EventRec = mPerformancePointer + mPerformanceLength;
1368 CopyMem (EventRec, FirmwarePerformanceHob + sizeof (FPDT_PEI_EXT_PERF_HEADER), (UINTN)(PeiPerformanceLogHeader->SizeOfAllEntries));
1369 //
1370 // Update the used buffer size.
1371 //
1372 mPerformanceLength += (UINTN)(PeiPerformanceLogHeader->SizeOfAllEntries);
1373 mLoadImageCount += PeiPerformanceLogHeader->LoadImageCount;
1374
1375 //
1376 // Get next performance guid hob
1377 //
1378 GuidHob = GetNextGuidHob (&gEdkiiFpdtExtendedFirmwarePerformanceGuid, GET_NEXT_HOB (GuidHob));
1379 }
1380}
1381
1389VOID
1390EFIAPI
1392 IN EFI_EVENT Event,
1393 IN VOID *Context
1394 )
1395{
1396 EFI_STATUS Status;
1397 UINT64 BPDTAddr;
1398
1399 if (!mFpdtBufferIsReported) {
1400 Status = AllocateBootPerformanceTable ();
1401 if (!EFI_ERROR (Status)) {
1402 BPDTAddr = (UINT64)(UINTN)mAcpiBootPerformanceTable;
1405 EFI_SOFTWARE_DXE_BS_DRIVER,
1406 0,
1407 NULL,
1408 &gEdkiiFpdtExtendedFirmwarePerformanceGuid,
1409 &BPDTAddr,
1410 sizeof (UINT64)
1411 );
1412 Status = gBS->InstallConfigurationTable (&gEdkiiFpdtExtendedFirmwarePerformanceGuid, (VOID *)(UINTN)BPDTAddr);
1413 ASSERT_EFI_ERROR (Status);
1414 }
1415
1416 //
1417 // Set FPDT report state to TRUE.
1418 //
1419 mFpdtBufferIsReported = TRUE;
1420 }
1421}
1422
1430VOID
1431EFIAPI
1433 IN EFI_EVENT Event,
1434 IN VOID *Context
1435 )
1436{
1437 VOID *SmmBootRecordData;
1438 UINTN SmmBootRecordDataSize;
1439 UINTN AppendSize;
1440 UINT8 *FirmwarePerformanceTablePtr;
1441
1442 SmmBootRecordDataSize = 0;
1443
1444 //
1445 // Get SMM performance data.
1446 //
1447 SmmBootRecordData = NULL;
1448 InternalGetSmmPerfData (&SmmBootRecordData, &SmmBootRecordDataSize, FALSE);
1449
1450 FirmwarePerformanceTablePtr = (UINT8 *)mAcpiBootPerformanceTable + mAcpiBootPerformanceTable->Header.Length;
1451
1452 if (mAcpiBootPerformanceTable->Header.Length + SmmBootRecordDataSize > mBootRecordMaxSize) {
1453 DEBUG ((DEBUG_INFO, "DxeCorePerformanceLib: No enough space to save all SMM boot performance data\n"));
1454 AppendSize = mBootRecordMaxSize - mAcpiBootPerformanceTable->Header.Length;
1455 } else {
1456 AppendSize = SmmBootRecordDataSize;
1457 }
1458
1459 if (SmmBootRecordData != NULL) {
1460 CopyMem (FirmwarePerformanceTablePtr, SmmBootRecordData, AppendSize);
1461 mAcpiBootPerformanceTable->Header.Length += (UINT32)AppendSize;
1462 mBootRecordSize += (UINT32)AppendSize;
1463 FreePool (SmmBootRecordData);
1464 }
1465}
1466
1481EFIAPI
1483 IN EFI_HANDLE ImageHandle,
1484 IN EFI_SYSTEM_TABLE *SystemTable
1485 )
1486{
1487 EFI_STATUS Status;
1488 EFI_HANDLE Handle;
1489 EFI_EVENT EndOfDxeEvent;
1490 EFI_EVENT ReadyToBootEvent;
1491 PERFORMANCE_PROPERTY *PerformanceProperty;
1492
1494 //
1495 // Do not initialize performance infrastructure if not required.
1496 //
1497 return EFI_SUCCESS;
1498 }
1499
1500 //
1501 // Dump normal PEI performance records
1502 //
1504
1505 //
1506 // Install the protocol interfaces for DXE performance library instance.
1507 //
1508 Handle = NULL;
1509 Status = gBS->InstallMultipleProtocolInterfaces (
1510 &Handle,
1511 &gEdkiiPerformanceMeasurementProtocolGuid,
1512 &mPerformanceMeasurementInterface,
1513 NULL
1514 );
1515 ASSERT_EFI_ERROR (Status);
1516
1517 //
1518 // Register EndOfDxe event to allocate the boot performance table and report the table address through status code.
1519 //
1520 Status = gBS->CreateEventEx (
1521 EVT_NOTIFY_SIGNAL,
1522 TPL_NOTIFY,
1524 NULL,
1525 &gEfiEndOfDxeEventGroupGuid,
1526 &EndOfDxeEvent
1527 );
1528
1529 //
1530 // Register ReadyToBoot event to update the boot performance table for SMM performance data.
1531 //
1532 Status = gBS->CreateEventEx (
1533 EVT_NOTIFY_SIGNAL,
1534 TPL_CALLBACK,
1536 NULL,
1537 &gEfiEventReadyToBootGuid,
1538 &ReadyToBootEvent
1539 );
1540
1541 ASSERT_EFI_ERROR (Status);
1542
1543 Status = EfiGetSystemConfigurationTable (&gPerformanceProtocolGuid, (VOID **)&PerformanceProperty);
1544 if (EFI_ERROR (Status)) {
1545 //
1546 // Install configuration table for performance property.
1547 //
1548 mPerformanceProperty.Revision = PERFORMANCE_PROPERTY_REVISION;
1549 mPerformanceProperty.Reserved = 0;
1550 mPerformanceProperty.Frequency = GetPerformanceCounterProperties (
1551 &mPerformanceProperty.TimerStartValue,
1552 &mPerformanceProperty.TimerEndValue
1553 );
1554 Status = gBS->InstallConfigurationTable (&gPerformanceProtocolGuid, &mPerformanceProperty);
1555 ASSERT_EFI_ERROR (Status);
1556 }
1557
1558 return EFI_SUCCESS;
1559}
1560
1580EFIAPI
1582 IN CONST VOID *CallerIdentifier,
1583 IN CONST VOID *Guid OPTIONAL,
1584 IN CONST CHAR8 *String OPTIONAL,
1585 IN UINT64 TimeStamp,
1586 IN UINT64 Address OPTIONAL,
1587 IN UINT32 Identifier,
1588 IN PERF_MEASUREMENT_ATTRIBUTE Attribute
1589 )
1590{
1591 EFI_STATUS Status;
1592
1593 Status = EFI_SUCCESS;
1594
1595 if (mLockInsertRecord) {
1596 return EFI_INVALID_PARAMETER;
1597 }
1598
1599 mLockInsertRecord = TRUE;
1600
1601 Status = InsertFpdtRecord (CallerIdentifier, Guid, String, TimeStamp, Address, (UINT16)Identifier, Attribute);
1602
1603 mLockInsertRecord = FALSE;
1604
1605 return Status;
1606}
1607
1633RETURN_STATUS
1634EFIAPI
1636 IN CONST VOID *Handle OPTIONAL,
1637 IN CONST CHAR8 *Token OPTIONAL,
1638 IN CONST CHAR8 *Module OPTIONAL,
1639 IN UINT64 TimeStamp,
1640 IN UINT32 Identifier
1641 )
1642{
1643 CONST CHAR8 *String;
1644
1645 if (Token != NULL) {
1646 String = Token;
1647 } else if (Module != NULL) {
1648 String = Module;
1649 } else {
1650 String = NULL;
1651 }
1652
1653 return (RETURN_STATUS)CreatePerformanceMeasurement (Handle, NULL, String, TimeStamp, 0, Identifier, PerfStartEntry);
1654}
1655
1682RETURN_STATUS
1683EFIAPI
1685 IN CONST VOID *Handle OPTIONAL,
1686 IN CONST CHAR8 *Token OPTIONAL,
1687 IN CONST CHAR8 *Module OPTIONAL,
1688 IN UINT64 TimeStamp,
1689 IN UINT32 Identifier
1690 )
1691{
1692 CONST CHAR8 *String;
1693
1694 if (Token != NULL) {
1695 String = Token;
1696 } else if (Module != NULL) {
1697 String = Module;
1698 } else {
1699 String = NULL;
1700 }
1701
1702 return (RETURN_STATUS)CreatePerformanceMeasurement (Handle, NULL, String, TimeStamp, 0, Identifier, PerfEndEntry);
1703}
1704
1749UINTN
1750EFIAPI
1752 IN UINTN LogEntryKey,
1753 OUT CONST VOID **Handle,
1754 OUT CONST CHAR8 **Token,
1755 OUT CONST CHAR8 **Module,
1756 OUT UINT64 *StartTimeStamp,
1757 OUT UINT64 *EndTimeStamp,
1758 OUT UINT32 *Identifier
1759 )
1760{
1761 return 0;
1762}
1763
1787RETURN_STATUS
1788EFIAPI
1790 IN CONST VOID *Handle OPTIONAL,
1791 IN CONST CHAR8 *Token OPTIONAL,
1792 IN CONST CHAR8 *Module OPTIONAL,
1793 IN UINT64 TimeStamp
1794 )
1795{
1796 return StartPerformanceMeasurementEx (Handle, Token, Module, TimeStamp, 0);
1797}
1798
1823RETURN_STATUS
1824EFIAPI
1826 IN CONST VOID *Handle OPTIONAL,
1827 IN CONST CHAR8 *Token OPTIONAL,
1828 IN CONST CHAR8 *Module OPTIONAL,
1829 IN UINT64 TimeStamp
1830 )
1831{
1832 return EndPerformanceMeasurementEx (Handle, Token, Module, TimeStamp, 0);
1833}
1834
1876UINTN
1877EFIAPI
1879 IN UINTN LogEntryKey,
1880 OUT CONST VOID **Handle,
1881 OUT CONST CHAR8 **Token,
1882 OUT CONST CHAR8 **Module,
1883 OUT UINT64 *StartTimeStamp,
1884 OUT UINT64 *EndTimeStamp
1885 )
1886{
1887 return 0;
1888}
1889
1902BOOLEAN
1903EFIAPI
1905 VOID
1906 )
1907{
1908 return (BOOLEAN)((PcdGet8 (PcdPerformanceLibraryPropertyMask) & PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED) != 0);
1909}
1910
1926RETURN_STATUS
1927EFIAPI
1929 IN CONST VOID *CallerIdentifier,
1930 IN CONST VOID *Guid OPTIONAL,
1931 IN CONST CHAR8 *String OPTIONAL,
1932 IN UINT64 Address OPTIONAL,
1933 IN UINT32 Identifier
1934 )
1935{
1936 return (RETURN_STATUS)CreatePerformanceMeasurement (CallerIdentifier, Guid, String, 0, Address, Identifier, PerfEntry);
1937}
1938
1951BOOLEAN
1952EFIAPI
1954 IN CONST UINTN Type
1955 )
1956{
1957 //
1958 // When Performance measurement is enabled and the type is not filtered, the performance can be logged.
1959 //
1960 if (PerformanceMeasurementEnabled () && ((PcdGet8 (PcdPerformanceLibraryPropertyMask) & Type) == 0)) {
1961 return TRUE;
1962 }
1963
1964 return FALSE;
1965}
UINT64 UINTN
INT64 INTN
#define EFI_ACPI_5_0_FPDT_BOOT_PERFORMANCE_TABLE_SIGNATURE
Definition: Acpi50.h:1225
UINT64 EFIAPI GetPerformanceCounterProperties(OUT UINT64 *StartValue OPTIONAL, OUT UINT64 *EndValue OPTIONAL)
UINT64 EFIAPI GetTimeInNanoSecond(IN UINT64 Ticks)
UINT64 EFIAPI GetPerformanceCounter(VOID)
VOID *EFIAPI GetNextGuidHob(IN CONST EFI_GUID *Guid, IN CONST VOID *HobStart)
Definition: HobLib.c:176
VOID *EFIAPI GetHobList(VOID)
Definition: HobLib.c:76
UINTN EFIAPI StrSize(IN CONST CHAR16 *String)
Definition: String.c:72
RETURN_STATUS EFIAPI AsciiStrnCpyS(OUT CHAR8 *Destination, IN UINTN DestMax, IN CONST CHAR8 *Source, IN UINTN Length)
Definition: SafeString.c:1875
UINTN EFIAPI AsciiStrLen(IN CONST CHAR8 *String)
Definition: String.c:641
INTN EFIAPI AsciiStrCmp(IN CONST CHAR8 *FirstString, IN CONST CHAR8 *SecondString)
Definition: String.c:716
UINTN EFIAPI AsciiStrSize(IN CONST CHAR8 *String)
Definition: String.c:681
RETURN_STATUS EFIAPI UnicodeStrnToAsciiStrS(IN CONST CHAR16 *Source, IN UINTN Length, OUT CHAR8 *Destination, IN UINTN DestMax, OUT UINTN *DestinationLength)
Definition: SafeString.c:2757
RETURN_STATUS EFIAPI AsciiStrCpyS(OUT CHAR8 *Destination, IN UINTN DestMax, IN CONST CHAR8 *Source)
Definition: SafeString.c:1797
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
GUID *EFIAPI CopyGuid(OUT GUID *DestinationGuid, IN CONST GUID *SourceGuid)
Definition: MemLibGuid.c:39
VOID *EFIAPI ZeroMem(OUT VOID *Buffer, IN UINTN Length)
BOOLEAN EFIAPI IsZeroGuid(IN CONST GUID *Guid)
Definition: MemLibGuid.c:156
#define MEDIA_PIWG_FW_FILE_DP
Definition: DevicePath.h:1130
EFI_DEVICE_PATH_PROTOCOL *EFIAPI DevicePathFromHandle(IN EFI_HANDLE Handle)
CHAR16 *EFIAPI ConvertDevicePathToText(IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath, IN BOOLEAN DisplayOnly, IN BOOLEAN AllowShortcuts)
VOID EFIAPI UpdateBootPerformanceTable(IN EFI_EVENT Event, IN VOID *Context)
EFI_STATUS GetFpdtRecordPtr(IN UINT8 RecordSize, IN OUT FPDT_RECORD_PTR *FpdtRecordPtr)
RETURN_STATUS EFIAPI EndPerformanceMeasurementEx(IN CONST VOID *Handle OPTIONAL, IN CONST CHAR8 *Token OPTIONAL, IN CONST CHAR8 *Module OPTIONAL, IN UINT64 TimeStamp, IN UINT32 Identifier)
EFI_STATUS EFIAPI CreatePerformanceMeasurement(IN CONST VOID *CallerIdentifier, IN CONST VOID *Guid OPTIONAL, IN CONST CHAR8 *String OPTIONAL, IN UINT64 TimeStamp, IN UINT64 Address OPTIONAL, IN UINT32 Identifier, IN PERF_MEASUREMENT_ATTRIBUTE Attribute)
VOID InternalGetPeiPerformance(VOID *HobStart)
UINTN EFIAPI GetPerformanceMeasurement(IN UINTN LogEntryKey, OUT CONST VOID **Handle, OUT CONST CHAR8 **Token, OUT CONST CHAR8 **Module, OUT UINT64 *StartTimeStamp, OUT UINT64 *EndTimeStamp)
VOID CopyStringIntoPerfRecordAndUpdateLength(IN OUT CHAR8 *Destination, IN CONST CHAR8 *Source, IN OUT UINT8 *Length)
EFI_STATUS InsertFpdtRecord(IN CONST VOID *CallerIdentifier OPTIONAL, IN CONST VOID *Guid OPTIONAL, IN CONST CHAR8 *String OPTIONAL, IN UINT64 Ticker, IN UINT64 Address OPTIONAL, IN UINT16 PerfId, IN PERF_MEASUREMENT_ATTRIBUTE Attribute)
RETURN_STATUS EFIAPI StartPerformanceMeasurementEx(IN CONST VOID *Handle OPTIONAL, IN CONST CHAR8 *Token OPTIONAL, IN CONST CHAR8 *Module OPTIONAL, IN UINT64 TimeStamp, IN UINT32 Identifier)
EFI_STATUS GetFpdtRecordId(IN PERF_MEASUREMENT_ATTRIBUTE Attribute, IN CONST VOID *Handle, IN CONST CHAR8 *String, OUT UINT16 *ProgressID)
VOID InternalGetSmmPerfData(OUT VOID **SmmPerfData, OUT UINTN *SmmPerfDataSize, IN BOOLEAN SkipGetPerfData)
EFI_STATUS AllocateBootPerformanceTable(VOID)
RETURN_STATUS EFIAPI LogPerformanceMeasurement(IN CONST VOID *CallerIdentifier, IN CONST VOID *Guid OPTIONAL, IN CONST CHAR8 *String OPTIONAL, IN UINT64 Address OPTIONAL, IN UINT32 Identifier)
EFI_STATUS GetDeviceInfoFromHandleAndUpdateLength(IN CONST VOID *Handle, IN EFI_HANDLE ControllerHandle, OUT CHAR8 *ComponentNameString, IN OUT UINT8 *Length)
BOOLEAN EFIAPI LogPerformanceMeasurementEnabled(IN CONST UINTN Type)
BOOLEAN IsKnownTokens(IN CONST CHAR8 *Token)
BOOLEAN EFIAPI PerformanceMeasurementEnabled(VOID)
UINTN EFIAPI GetPerformanceMeasurementEx(IN UINTN LogEntryKey, OUT CONST VOID **Handle, OUT CONST CHAR8 **Token, OUT CONST CHAR8 **Module, OUT UINT64 *StartTimeStamp, OUT UINT64 *EndTimeStamp, OUT UINT32 *Identifier)
RETURN_STATUS EFIAPI EndPerformanceMeasurement(IN CONST VOID *Handle OPTIONAL, IN CONST CHAR8 *Token OPTIONAL, IN CONST CHAR8 *Module OPTIONAL, IN UINT64 TimeStamp)
BOOLEAN IsKnownID(IN UINT32 Identifier)
EFI_STATUS GetModuleInfoFromHandle(IN EFI_HANDLE Handle, OUT CHAR8 *NameString, IN UINTN BufferSize, OUT EFI_GUID *ModuleGuid OPTIONAL)
VOID EFIAPI ReportFpdtRecordBuffer(IN EFI_EVENT Event, IN VOID *Context)
EFI_STATUS EFIAPI DxeCorePerformanceLibConstructor(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
RETURN_STATUS EFIAPI StartPerformanceMeasurement(IN CONST VOID *Handle OPTIONAL, IN CONST CHAR8 *Token OPTIONAL, IN CONST CHAR8 *Module OPTIONAL, IN UINT64 TimeStamp)
VOID *EFIAPI AllocatePeiAccessiblePages(IN EFI_MEMORY_TYPE MemoryType, IN UINTN Pages)
Definition: Allocate.c:31
EFI_STATUS EFIAPI GetSectionFromAnyFv(IN CONST EFI_GUID *NameGuid, IN EFI_SECTION_TYPE SectionType, IN UINTN SectionInstance, OUT VOID **Buffer, OUT UINTN *Size)
VOID *EFIAPI ReallocatePool(IN UINTN OldSize, IN UINTN NewSize, IN VOID *OldBuffer OPTIONAL)
VOID *EFIAPI AllocateZeroPool(IN UINTN AllocationSize)
VOID EFIAPI FreePool(IN VOID *Buffer)
#define DRIVERBINDING_START_TOK
Driver Binding Start() function call.
#define PEI_TOK
PEI Phase.
#define DXE_TOK
DXE Phase.
#define PEIM_TOK
PEIM Modules Entry Point execution.
#define DRIVERBINDING_STOP_TOK
Driver Binding Stop() function call.
#define LOAD_IMAGE_TOK
Load a dispatched module.
#define START_IMAGE_TOK
Dispatched Modules Entry Point execution.
#define BDS_TOK
BDS Phase.
#define DRIVERBINDING_SUPPORT_TOK
Driver Binding Support() function call.
#define SEC_TOK
SEC Phase.
EFI_RUNTIME_SERVICES * gRT
#define NULL
Definition: Base.h:319
#define CONST
Definition: Base.h:259
#define RETURN_UNSUPPORTED
Definition: Base.h:1081
#define TRUE
Definition: Base.h:301
#define FALSE
Definition: Base.h:307
#define IN
Definition: Base.h:279
#define OUT
Definition: Base.h:284
#define ASSERT_EFI_ERROR(StatusParameter)
Definition: DebugLib.h:462
#define DEBUG(Expression)
Definition: DebugLib.h:434
#define REPORT_STATUS_CODE_EX(Type, Value, Instance, CallerId, ExtendedDataGuid, ExtendedData, ExtendedDataSize)
#define PcdGet8(TokenName)
Definition: PcdLib.h:336
#define PcdGet32(TokenName)
Definition: PcdLib.h:362
#define PcdGetBool(TokenName)
Definition: PcdLib.h:401
#define PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED
#define EFI_PROGRESS_CODE
Definition: PiStatusCode.h:43
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29
VOID * EFI_EVENT
Definition: UefiBaseType.h:37
#define EFI_SIZE_TO_PAGES(Size)
Definition: UefiBaseType.h:200
VOID * EFI_HANDLE
Definition: UefiBaseType.h:33
#define EFI_SUCCESS
Definition: UefiBaseType.h:112
EFI_BOOT_SERVICES * gBS
EFI_STATUS EFIAPI GetEfiGlobalVariable2(IN CONST CHAR16 *Name, OUT VOID **Value, OUT UINTN *Size OPTIONAL)
Definition: UefiLib.c:1470
EFI_STATUS EFIAPI EfiGetSystemConfigurationTable(IN EFI_GUID *TableGuid, OUT VOID **Table)
Definition: UefiLib.c:82
@ EfiReservedMemoryType
@ EfiConventionalMemory
@ AllocateAddress
Definition: UefiSpec.h:42
EFI_ACPI_5_0_FPDT_PERFORMANCE_TABLE_HEADER Header
Common ACPI table header.
EFI_DEVICE_PATH_PROTOCOL * FilePath
Definition: LoadedImage.h:54
VOID * ImageBase
The base address at which the image was loaded.
Definition: LoadedImage.h:67
EFI_PHYSICAL_ADDRESS PhysicalStart
Definition: UefiSpec.h:155
EFI_PHYSICAL_ADDRESS BootPerformanceTablePointer
Pointer to Boot Performance Table.
Definition: Base.h:213