]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Core/Dxe/Dispatcher/Dispatcher.c
Add comments for EFI_CACHE_SRAM_TYPE_DATA because of the inconsistency between CacheS...
[mirror_edk2.git] / MdeModulePkg / Core / Dxe / Dispatcher / Dispatcher.c
index 79b895bcfa68bb065044601c7284dbab264caf13..68f5ef5d6463385c9de692a49db72ebf435dbc3d 100644 (file)
@@ -26,7 +26,7 @@
   Depex - Dependency Expresion.\r
   SOR   - Schedule On Request - Don't schedule if this bit is set.\r
 \r
-Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>\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
@@ -168,6 +168,7 @@ CoreFvToDevicePath (
                                 EFI_CORE_DRIVER_ENTRY so that the PE image can be\r
                                 read out of the FV at a later time.\r
   @param  DriverName            Name of driver to add to mDiscoveredList.\r
+  @param  Type                  Fv File Type of file to add to mDiscoveredList.\r
 \r
   @retval EFI_SUCCESS           If driver was added to the mDiscoveredList.\r
   @retval EFI_ALREADY_STARTED   The driver has already been started. Only one\r
@@ -179,7 +180,8 @@ EFI_STATUS
 CoreAddToDriverList (\r
   IN  EFI_FIRMWARE_VOLUME2_PROTOCOL   *Fv,\r
   IN  EFI_HANDLE                      FvHandle,\r
-  IN  EFI_GUID                        *DriverName\r
+  IN  EFI_GUID                        *DriverName,\r
+  IN  EFI_FV_FILETYPE                 Type\r
   );\r
 \r
 /**\r
@@ -402,7 +404,7 @@ CoreTrust (
 **/\r
 VOID\r
 EFIAPI\r
-EmptyFuntion (\r
+CoreEmptyCallbackFunction (\r
   IN EFI_EVENT                Event,\r
   IN VOID                     *Context\r
   )\r
@@ -450,7 +452,7 @@ CoreDispatcher (
   Status = CoreCreateEventEx (\r
              EVT_NOTIFY_SIGNAL,\r
              TPL_NOTIFY,\r
-             EmptyFuntion,\r
+             CoreEmptyCallbackFunction,\r
              NULL,\r
              &gEfiEventDxeDispatchGuid,\r
              &DxeDispatchEvent\r
@@ -477,7 +479,7 @@ CoreDispatcher (
       // Untrused to Scheduled it would have already been loaded so we may need to\r
       // skip the LoadImage\r
       //\r
-      if (DriverEntry->ImageHandle == NULL) {\r
+      if (DriverEntry->ImageHandle == NULL && !DriverEntry->IsFvImage) {\r
         DEBUG ((DEBUG_INFO, "Loading driver %g\n", &DriverEntry->FileName));\r
         Status = CoreLoadImage (\r
                         FALSE,\r
@@ -530,21 +532,28 @@ CoreDispatcher (
       CoreReleaseDispatcherLock ();\r
 \r
  \r
-      REPORT_STATUS_CODE_WITH_EXTENDED_DATA (\r
-        EFI_PROGRESS_CODE,\r
-        (EFI_SOFTWARE_DXE_CORE | EFI_SW_PC_INIT_BEGIN),\r
-        &DriverEntry->ImageHandle,\r
-        sizeof (DriverEntry->ImageHandle)\r
-        );\r
-\r
-      Status = CoreStartImage (DriverEntry->ImageHandle, NULL, NULL);\r
-\r
-      REPORT_STATUS_CODE_WITH_EXTENDED_DATA (\r
-        EFI_PROGRESS_CODE,\r
-        (EFI_SOFTWARE_DXE_CORE | EFI_SW_PC_INIT_END),\r
-        &DriverEntry->ImageHandle,\r
-        sizeof (DriverEntry->ImageHandle)\r
-        );\r
+      if (DriverEntry->IsFvImage) {\r
+        //\r
+        // Produce a firmware volume block protocol for FvImage so it gets dispatched from. \r
+        //\r
+        Status = CoreProcessFvImageFile (DriverEntry->Fv, DriverEntry->FvHandle, &DriverEntry->FileName);\r
+      } else {\r
+        REPORT_STATUS_CODE_WITH_EXTENDED_DATA (\r
+          EFI_PROGRESS_CODE,\r
+          (EFI_SOFTWARE_DXE_CORE | EFI_SW_PC_INIT_BEGIN),\r
+          &DriverEntry->ImageHandle,\r
+          sizeof (DriverEntry->ImageHandle)\r
+          );\r
+  \r
+        Status = CoreStartImage (DriverEntry->ImageHandle, NULL, NULL);\r
+  \r
+        REPORT_STATUS_CODE_WITH_EXTENDED_DATA (\r
+          EFI_PROGRESS_CODE,\r
+          (EFI_SOFTWARE_DXE_CORE | EFI_SW_PC_INIT_END),\r
+          &DriverEntry->ImageHandle,\r
+          sizeof (DriverEntry->ImageHandle)\r
+          );\r
+      }\r
 \r
       ReturnStatus = EFI_SUCCESS;\r
     }\r
@@ -784,6 +793,7 @@ CoreFvToDevicePath (
                                 EFI_CORE_DRIVER_ENTRY so that the PE image can be\r
                                 read out of the FV at a later time.\r
   @param  DriverName            Name of driver to add to mDiscoveredList.\r
+  @param  Type                  Fv File Type of file to add to mDiscoveredList.\r
 \r
   @retval EFI_SUCCESS           If driver was added to the mDiscoveredList.\r
   @retval EFI_ALREADY_STARTED   The driver has already been started. Only one\r
@@ -795,7 +805,8 @@ EFI_STATUS
 CoreAddToDriverList (\r
   IN  EFI_FIRMWARE_VOLUME2_PROTOCOL   *Fv,\r
   IN  EFI_HANDLE                      FvHandle,\r
-  IN  EFI_GUID                        *DriverName\r
+  IN  EFI_GUID                        *DriverName,\r
+  IN  EFI_FV_FILETYPE                 Type\r
   )\r
 {\r
   EFI_CORE_DRIVER_ENTRY               *DriverEntry;\r
@@ -807,6 +818,9 @@ CoreAddToDriverList (
   //\r
   DriverEntry = AllocateZeroPool (sizeof (EFI_CORE_DRIVER_ENTRY));\r
   ASSERT (DriverEntry != NULL);\r
+  if (Type == EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE) {\r
+    DriverEntry->IsFvImage = TRUE;\r
+  }\r
 \r
   DriverEntry->Signature        = EFI_CORE_DRIVER_ENTRY_SIGNATURE;\r
   CopyGuid (&DriverEntry->FileName, DriverName);\r
@@ -1006,7 +1020,7 @@ CoreFwVolEventProtocolNotify (
   LIST_ENTRY                    *Link;\r
   UINT32                        AuthenticationStatus;\r
   UINTN                         SizeOfBuffer;\r
-\r
+  VOID                          *DepexBuffer;\r
 \r
   while (TRUE) {\r
     BufferSize = sizeof (EFI_HANDLE);\r
@@ -1120,17 +1134,84 @@ CoreFwVolEventProtocolNotify (
             if (FvFoundInHobFv2 (FvHandle, &NameGuid)) {\r
               continue;\r
             }\r
+\r
+            //\r
+            // Check if this EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE file has PEI depex section.\r
+            //\r
+            DepexBuffer  = NULL;\r
+            SizeOfBuffer = 0;\r
+            Status = Fv->ReadSection (\r
+                           Fv,\r
+                           &NameGuid,\r
+                           EFI_SECTION_PEI_DEPEX,\r
+                           0,\r
+                           &DepexBuffer,\r
+                           &SizeOfBuffer,\r
+                           &AuthenticationStatus\r
+                           );\r
+            if (!EFI_ERROR (Status)) {\r
+              //\r
+              // If PEI depex section is found, this FV image will be ignored in DXE phase.\r
+              // Now, DxeCore doesn't support FV image with more one type DEPEX section.\r
+              //\r
+              FreePool (DepexBuffer);\r
+              continue;\r
+            }\r
+\r
             //\r
-            // Found a firmware volume image. Produce a firmware volume block\r
-            // protocol for it so it gets dispatched from. This is usually a\r
-            // capsule.\r
+            // Check if this EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE file has SMM depex section.\r
             //\r
-            CoreProcessFvImageFile (Fv, FvHandle, &NameGuid);\r
+            DepexBuffer  = NULL;\r
+            SizeOfBuffer = 0;\r
+            Status = Fv->ReadSection (\r
+                           Fv,\r
+                           &NameGuid,\r
+                           EFI_SECTION_SMM_DEPEX,\r
+                           0,\r
+                           &DepexBuffer,\r
+                           &SizeOfBuffer,\r
+                           &AuthenticationStatus\r
+                           );\r
+            if (!EFI_ERROR (Status)) {\r
+              //\r
+              // If SMM depex section is found, this FV image will be ignored in DXE phase.\r
+              // Now, DxeCore doesn't support FV image with more one type DEPEX section.\r
+              //\r
+              FreePool (DepexBuffer);\r
+              continue;\r
+            }\r
+\r
+            //\r
+            // Check if this EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE file has DXE depex section.\r
+            //\r
+            DepexBuffer  = NULL;\r
+            SizeOfBuffer = 0;\r
+            Status = Fv->ReadSection (\r
+                           Fv,\r
+                           &NameGuid,\r
+                           EFI_SECTION_DXE_DEPEX,\r
+                           0,\r
+                           &DepexBuffer,\r
+                           &SizeOfBuffer,\r
+                           &AuthenticationStatus\r
+                           );\r
+            if (EFI_ERROR (Status)) {\r
+              //\r
+              // If no depex section, produce a firmware volume block protocol for it so it gets dispatched from. \r
+              //\r
+              CoreProcessFvImageFile (Fv, FvHandle, &NameGuid);\r
+            } else {\r
+              //\r
+              // If depex section is found, this FV image will be dispatched until its depex is evaluated to TRUE.\r
+              //\r
+              FreePool (DepexBuffer);\r
+              CoreAddToDriverList (Fv, FvHandle, &NameGuid, Type);\r
+            }\r
           } else {\r
             //\r
             // Transition driver from Undiscovered to Discovered state\r
             //\r
-            CoreAddToDriverList (Fv, FvHandle, &NameGuid);\r
+            CoreAddToDriverList (Fv, FvHandle, &NameGuid, Type);\r
           }\r
         }\r
       } while (!EFI_ERROR (GetNextFileStatus));\r