]> git.proxmox.com Git - mirror_edk2.git/blobdiff - UefiCpuPkg/CpuS3DataDxe/CpuS3Data.c
UefiCpuPkg: Change use of EFI_D_* to DEBUG_*
[mirror_edk2.git] / UefiCpuPkg / CpuS3DataDxe / CpuS3Data.c
index 3e8c8b383c9d08f1ed1804ec1d9a9b80e2a723a1..6100799a79160bed7040a314e93dfa3a1d3d6b6b 100644 (file)
@@ -9,16 +9,10 @@ number of CPUs reported by the MP Services Protocol, so this module does not
 support hot plug CPUs.  This module can be copied into a CPU specific package\r
 and customized if these additional features are required.\r
 \r
-Copyright (c) 2013 - 2017, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2013 - 2021, Intel Corporation. All rights reserved.<BR>\r
 Copyright (c) 2015, Red Hat, Inc.\r
 \r
-This program and the accompanying materials\r
-are licensed and made available under the terms and conditions of the BSD License\r
-which accompanies this distribution.  The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
 **/\r
 \r
@@ -47,9 +41,7 @@ typedef struct {
 } ACPI_CPU_DATA_EX;\r
 \r
 /**\r
-  Allocate EfiACPIMemoryNVS below 4G memory address.\r
-\r
-  This function allocates EfiACPIMemoryNVS below 4G memory address.\r
+  Allocate EfiACPIMemoryNVS memory.\r
 \r
   @param[in] Size   Size of memory to allocate.\r
 \r
@@ -57,7 +49,7 @@ typedef struct {
 \r
 **/\r
 VOID *\r
-AllocateAcpiNvsMemoryBelow4G (\r
+AllocateAcpiNvsMemory (\r
   IN UINTN  Size\r
   )\r
 {\r
@@ -65,9 +57,8 @@ AllocateAcpiNvsMemoryBelow4G (
   EFI_STATUS            Status;\r
   VOID                  *Buffer;\r
 \r
-  Address = BASE_4GB - 1;\r
   Status  = gBS->AllocatePages (\r
-                   AllocateMaxAddress,\r
+                   AllocateAnyPages,\r
                    EfiACPIMemoryNVS,\r
                    EFI_SIZE_TO_PAGES (Size),\r
                    &Address\r
@@ -135,7 +126,7 @@ CpuS3DataOnEndOfDxe (
                   );\r
   ASSERT_EFI_ERROR (Status);\r
 \r
-  DEBUG ((EFI_D_VERBOSE, "%a\n", __FUNCTION__));\r
+  DEBUG ((DEBUG_VERBOSE, "%a\n", __FUNCTION__));\r
   MtrrGetAllMtrrs (&AcpiCpuDataEx->MtrrTable);\r
 \r
   //\r
@@ -174,10 +165,6 @@ CpuS3DataInitialize (
   UINTN                      NumberOfCpus;\r
   UINTN                      NumberOfEnabledProcessors;\r
   VOID                       *Stack;\r
-  UINTN                      TableSize;\r
-  CPU_REGISTER_TABLE         *RegisterTable;\r
-  UINTN                      Index;\r
-  EFI_PROCESSOR_INFORMATION  ProcessorInfoBuffer;\r
   UINTN                      GdtSize;\r
   UINTN                      IdtSize;\r
   VOID                       *Gdt;\r
@@ -230,9 +217,13 @@ CpuS3DataInitialize (
   AcpiCpuData->MtrrTable    = (EFI_PHYSICAL_ADDRESS)(UINTN)&AcpiCpuDataEx->MtrrTable;\r
 \r
   //\r
-  // Allocate stack space for all CPUs\r
+  // Allocate stack space for all CPUs.\r
+  // Use ACPI NVS memory type because this data will be directly used by APs\r
+  // in S3 resume phase in long mode. Also during S3 resume, the stack buffer\r
+  // will only be used as scratch space. i.e. we won't read anything from it\r
+  // before we write to it, in PiSmmCpuDxeSmm.\r
   //\r
-  Stack = AllocateAcpiNvsMemoryBelow4G (NumberOfCpus * AcpiCpuData->StackSize);\r
+  Stack = AllocateAcpiNvsMemory (NumberOfCpus * AcpiCpuData->StackSize);\r
   ASSERT (Stack != NULL);\r
   AcpiCpuData->StackAddress = (EFI_PHYSICAL_ADDRESS)(UINTN)Stack;\r
 \r
@@ -256,36 +247,7 @@ CpuS3DataInitialize (
   AcpiCpuDataEx->IdtrProfile.Base = (UINTN)Idt;\r
 \r
   if (OldAcpiCpuData != NULL) {\r
-    AcpiCpuData->RegisterTable           = OldAcpiCpuData->RegisterTable;\r
-    AcpiCpuData->PreSmmInitRegisterTable = OldAcpiCpuData->PreSmmInitRegisterTable;\r
-  } else {\r
-    //\r
-    // Allocate buffer for empty RegisterTable and PreSmmInitRegisterTable for all CPUs\r
-    //\r
-    TableSize = 2 * NumberOfCpus * sizeof (CPU_REGISTER_TABLE);\r
-    RegisterTable = (CPU_REGISTER_TABLE *)AllocateZeroPages (TableSize);\r
-    ASSERT (RegisterTable != NULL);\r
-\r
-    for (Index = 0; Index < NumberOfCpus; Index++) {\r
-      Status = MpServices->GetProcessorInfo (\r
-                           MpServices,\r
-                           Index,\r
-                           &ProcessorInfoBuffer\r
-                           );\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
-\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
-    AcpiCpuData->RegisterTable           = (EFI_PHYSICAL_ADDRESS)(UINTN)RegisterTable;\r
-    AcpiCpuData->PreSmmInitRegisterTable = (EFI_PHYSICAL_ADDRESS)(UINTN)(RegisterTable + NumberOfCpus);\r
+    CopyMem (&AcpiCpuData->CpuFeatureInitData, &OldAcpiCpuData->CpuFeatureInitData, sizeof (CPU_FEATURE_INIT_DATA));\r
   }\r
 \r
   //\r