/** @file\r
CPU Register Table Library functions.\r
\r
- Copyright (c) 2017 - 2020, Intel Corporation. All rights reserved.<BR>\r
+ Copyright (c) 2017 - 2021, Intel Corporation. All rights reserved.<BR>\r
SPDX-License-Identifier: BSD-2-Clause-Patent\r
\r
**/\r
EFI_PROCESSOR_INFORMATION ProcessorInfoBuffer;\r
\r
AcpiCpuData = (ACPI_CPU_DATA *) (UINTN) PcdGet64 (PcdCpuS3DataAddress);\r
- if (AcpiCpuData != NULL) {\r
- return AcpiCpuData;\r
- }\r
-\r
- AcpiCpuData = AllocatePages (EFI_SIZE_TO_PAGES (sizeof (ACPI_CPU_DATA)));\r
- ASSERT (AcpiCpuData != NULL);\r
+ if (AcpiCpuData == NULL) {\r
+ AcpiCpuData = AllocatePages (EFI_SIZE_TO_PAGES (sizeof (ACPI_CPU_DATA)));\r
+ ASSERT (AcpiCpuData != NULL);\r
+ ZeroMem (AcpiCpuData, sizeof (ACPI_CPU_DATA));\r
\r
- //\r
- // Set PcdCpuS3DataAddress to the base address of the ACPI_CPU_DATA structure\r
- //\r
- Status = PcdSet64S (PcdCpuS3DataAddress, (UINT64)(UINTN)AcpiCpuData);\r
- ASSERT_EFI_ERROR (Status);\r
+ //\r
+ // Set PcdCpuS3DataAddress to the base address of the ACPI_CPU_DATA structure\r
+ //\r
+ Status = PcdSet64S (PcdCpuS3DataAddress, (UINT64)(UINTN)AcpiCpuData);\r
+ ASSERT_EFI_ERROR (Status);\r
\r
- GetNumberOfProcessor (&NumberOfCpus, &NumberOfEnabledProcessors);\r
- AcpiCpuData->NumberOfCpus = (UINT32)NumberOfCpus;\r
+ GetNumberOfProcessor (&NumberOfCpus, &NumberOfEnabledProcessors);\r
+ AcpiCpuData->NumberOfCpus = (UINT32)NumberOfCpus;\r
+ }\r
\r
- //\r
- // Allocate buffer for empty RegisterTable and PreSmmInitRegisterTable for all CPUs\r
- //\r
- TableSize = 2 * NumberOfCpus * sizeof (CPU_REGISTER_TABLE);\r
- RegisterTable = AllocatePages (EFI_SIZE_TO_PAGES (TableSize));\r
- ASSERT (RegisterTable != NULL);\r
+ if (AcpiCpuData->RegisterTable == 0 ||\r
+ AcpiCpuData->PreSmmInitRegisterTable == 0) {\r
+ //\r
+ // Allocate buffer for empty RegisterTable and PreSmmInitRegisterTable for all CPUs\r
+ //\r
+ TableSize = 2 * NumberOfCpus * sizeof (CPU_REGISTER_TABLE);\r
+ RegisterTable = AllocatePages (EFI_SIZE_TO_PAGES (TableSize));\r
+ ASSERT (RegisterTable != NULL);\r
\r
- for (Index = 0; Index < NumberOfCpus; Index++) {\r
- Status = GetProcessorInformation (Index, &ProcessorInfoBuffer);\r
- ASSERT_EFI_ERROR (Status);\r
+ for (Index = 0; Index < NumberOfCpus; Index++) {\r
+ Status = GetProcessorInformation (Index, &ProcessorInfoBuffer);\r
+ ASSERT_EFI_ERROR (Status);\r
\r
- RegisterTable[Index].InitialApicId = (UINT32)ProcessorInfoBuffer.ProcessorId;\r
- RegisterTable[Index].TableLength = 0;\r
- RegisterTable[Index].AllocatedSize = 0;\r
- RegisterTable[Index].RegisterTableEntry = 0;\r
+ RegisterTable[Index].InitialApicId = (UINT32)ProcessorInfoBuffer.ProcessorId;\r
+ RegisterTable[Index].TableLength = 0;\r
+ RegisterTable[Index].AllocatedSize = 0;\r
+ RegisterTable[Index].RegisterTableEntry = 0;\r
\r
- RegisterTable[NumberOfCpus + Index].InitialApicId = (UINT32)ProcessorInfoBuffer.ProcessorId;\r
- RegisterTable[NumberOfCpus + Index].TableLength = 0;\r
- RegisterTable[NumberOfCpus + Index].AllocatedSize = 0;\r
- RegisterTable[NumberOfCpus + Index].RegisterTableEntry = 0;\r
+ RegisterTable[NumberOfCpus + Index].InitialApicId = (UINT32)ProcessorInfoBuffer.ProcessorId;\r
+ RegisterTable[NumberOfCpus + Index].TableLength = 0;\r
+ RegisterTable[NumberOfCpus + Index].AllocatedSize = 0;\r
+ RegisterTable[NumberOfCpus + Index].RegisterTableEntry = 0;\r
+ }\r
+ if (AcpiCpuData->RegisterTable == 0) {\r
+ AcpiCpuData->RegisterTable = (EFI_PHYSICAL_ADDRESS)(UINTN)RegisterTable;\r
+ }\r
+ if (AcpiCpuData->PreSmmInitRegisterTable == 0) {\r
+ AcpiCpuData->PreSmmInitRegisterTable = (EFI_PHYSICAL_ADDRESS)(UINTN)(RegisterTable + NumberOfCpus);\r
+ }\r
}\r
- AcpiCpuData->RegisterTable = (EFI_PHYSICAL_ADDRESS)(UINTN)RegisterTable;\r
- AcpiCpuData->PreSmmInitRegisterTable = (EFI_PHYSICAL_ADDRESS)(UINTN)(RegisterTable + NumberOfCpus);\r
\r
return AcpiCpuData;\r
}\r