-/**\r
-\r
- Allocate a block of memory that will contain performance data to OS.\r
-\r
-**/\r
-VOID\r
-BdsAllocateMemoryForPerformanceData (\r
- VOID\r
- )\r
-{\r
- EFI_STATUS Status;\r
- EFI_PHYSICAL_ADDRESS AcpiLowMemoryBase;\r
- EDKII_VARIABLE_LOCK_PROTOCOL *VariableLock;\r
-\r
- AcpiLowMemoryBase = 0x0FFFFFFFFULL;\r
-\r
- //\r
- // Allocate a block of memory that will contain performance data to OS.\r
- //\r
- Status = gBS->AllocatePages (\r
- AllocateMaxAddress,\r
- EfiReservedMemoryType,\r
- EFI_SIZE_TO_PAGES (PERF_DATA_MAX_LENGTH),\r
- &AcpiLowMemoryBase\r
- );\r
- if (!EFI_ERROR (Status)) {\r
- //\r
- // Save the pointer to variable for use in S3 resume.\r
- //\r
- BdsDxeSetVariableAndReportStatusCodeOnError (\r
- L"PerfDataMemAddr",\r
- &gPerformanceProtocolGuid,\r
- EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,\r
- sizeof (EFI_PHYSICAL_ADDRESS),\r
- &AcpiLowMemoryBase\r
- );\r
- if (EFI_ERROR (Status)) {\r
- DEBUG ((EFI_D_ERROR, "[Bds] PerfDataMemAddr (%08x) cannot be saved to NV storage.\n", AcpiLowMemoryBase));\r
- }\r
- //\r
- // Mark L"PerfDataMemAddr" variable to read-only if the Variable Lock protocol exists\r
- // Still lock it even the variable cannot be saved to prevent it's set by 3rd party code.\r
- //\r
- Status = gBS->LocateProtocol (&gEdkiiVariableLockProtocolGuid, NULL, (VOID **) &VariableLock);\r
- if (!EFI_ERROR (Status)) {\r
- Status = VariableLock->RequestToLock (VariableLock, L"PerfDataMemAddr", &gPerformanceProtocolGuid);\r
- ASSERT_EFI_ERROR (Status);\r
- }\r
- }\r
-}\r
-\r