]> git.proxmox.com Git - mirror_edk2.git/blobdiff - UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c
MdeModulePkg/MdeModulePkg.dsc: add MM_STANDALONE FTW and variable modules
[mirror_edk2.git] / UefiCpuPkg / PiSmmCpuDxeSmm / CpuS3.c
index fec53c522ff8bf84a3f8ec17a90ea801c7f4a691..79372ce17a14269fa0f0a5dbc78cdc086eed0cc3 100644 (file)
@@ -41,9 +41,12 @@ typedef struct {
 // Flags used when program the register.\r
 //\r
 typedef struct {\r
-  volatile UINTN           ConsoleLogLock;       // Spinlock used to control console.\r
-  volatile UINTN           MemoryMappedLock;     // Spinlock used to program mmio\r
-  volatile UINT32          *SemaphoreCount;      // Semaphore used to program semaphore.\r
+  volatile UINTN           ConsoleLogLock;          // Spinlock used to control console.\r
+  volatile UINTN           MemoryMappedLock;        // Spinlock used to program mmio\r
+  volatile UINT32          *CoreSemaphoreCount;     // Semaphore container used to program\r
+                                                    // core level semaphore.\r
+  volatile UINT32          *PackageSemaphoreCount;  // Semaphore container used to program\r
+                                                    // package level semaphore.\r
 } PROGRAM_CPU_REGISTER_FLAGS;\r
 \r
 //\r
@@ -346,13 +349,14 @@ ProgramProcessorRegister (
       //  n * P(0)       n * P(1)      ...           n * P(n)\r
       //\r
       ASSERT (\r
-        (ApLocation != NULL) && \r
+        (ApLocation != NULL) &&\r
         (CpuStatus->ValidCoreCountPerPackage != 0) &&\r
-        (CpuFlags->SemaphoreCount) != NULL\r
+        (CpuFlags->CoreSemaphoreCount != NULL) &&\r
+        (CpuFlags->PackageSemaphoreCount != NULL)\r
         );\r
-      SemaphorePtr = CpuFlags->SemaphoreCount;\r
       switch (RegisterTableEntry->Value) {\r
       case CoreDepType:\r
+        SemaphorePtr = CpuFlags->CoreSemaphoreCount;\r
         //\r
         // Get Offset info for the first thread in the core which current thread belongs to.\r
         //\r
@@ -373,6 +377,7 @@ ProgramProcessorRegister (
         break;\r
 \r
       case PackageDepType:\r
+        SemaphorePtr = CpuFlags->PackageSemaphoreCount;\r
         ValidCoreCountPerPackage = (UINT32 *)(UINTN)CpuStatus->ValidCoreCountPerPackage;\r
         //\r
         // Get Offset info for the first thread in the package which current thread belongs to.\r
@@ -428,7 +433,7 @@ ProgramProcessorRegister (
 /**\r
 \r
   Set Processor register for one AP.\r
-  \r
+\r
   @param     PreSmmRegisterTable     Use pre Smm register table or register table.\r
 \r
 **/\r
@@ -451,6 +456,7 @@ SetRegister (
 \r
   InitApicId = GetInitialApicId ();\r
   RegisterTable = NULL;\r
+  ProcIndex = (UINTN)-1;\r
   for (Index = 0; Index < mAcpiCpuData.NumberOfCpus; Index++) {\r
     if (RegisterTables[Index].InitialApicId == InitApicId) {\r
       RegisterTable = &RegisterTables[Index];\r
@@ -1036,10 +1042,16 @@ GetAcpiCpuData (
     ASSERT (mAcpiCpuData.ApLocation != 0);\r
   }\r
   if (CpuStatus->PackageCount != 0) {\r
-    mCpuFlags.SemaphoreCount = AllocateZeroPool (\r
-                                 sizeof (UINT32) * CpuStatus->PackageCount *\r
-                                 CpuStatus->MaxCoreCount * CpuStatus->MaxThreadCount);\r
-    ASSERT (mCpuFlags.SemaphoreCount != NULL);\r
+    mCpuFlags.CoreSemaphoreCount = AllocateZeroPool (\r
+                                     sizeof (UINT32) * CpuStatus->PackageCount *\r
+                                     CpuStatus->MaxCoreCount * CpuStatus->MaxThreadCount\r
+                                     );\r
+    ASSERT (mCpuFlags.CoreSemaphoreCount != NULL);\r
+    mCpuFlags.PackageSemaphoreCount = AllocateZeroPool (\r
+                                        sizeof (UINT32) * CpuStatus->PackageCount *\r
+                                        CpuStatus->MaxCoreCount * CpuStatus->MaxThreadCount\r
+                                        );\r
+    ASSERT (mCpuFlags.PackageSemaphoreCount != NULL);\r
   }\r
   InitializeSpinLock((SPIN_LOCK*) &mCpuFlags.MemoryMappedLock);\r
   InitializeSpinLock((SPIN_LOCK*) &mCpuFlags.ConsoleLogLock);\r