]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Core/Dxe/Dispatcher/Dispatcher.c
MdeModulePkg DxeCore: Fix issue to print GUID value %g without pointer
[mirror_edk2.git] / MdeModulePkg / Core / Dxe / Dispatcher / Dispatcher.c
index 476c8b39adc9478acf651f2f771750ea4f9562eb..5eee71bb2cd33ce6fd10dd72c183d76db9239b4d 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 - 2011, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2017, 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
@@ -91,7 +91,6 @@ typedef struct {
 \r
 FV_FILEPATH_DEVICE_PATH mFvDevicePath;\r
 \r
-\r
 //\r
 // Function Prototypes\r
 //\r
@@ -393,25 +392,6 @@ CoreTrust (
   return EFI_NOT_FOUND;\r
 }\r
 \r
-\r
-/**\r
-  An empty function to pass error checking of CreateEventEx ().\r
-\r
-  @param  Event                 Event whose notification function is being invoked.\r
-  @param  Context               Pointer to the notification function's context,\r
-                                which is implementation-dependent.\r
-\r
-**/\r
-VOID\r
-EFIAPI\r
-CoreEmptyCallbackFunction (\r
-  IN EFI_EVENT                Event,\r
-  IN VOID                     *Context\r
-  )\r
-{\r
-  return;\r
-}\r
-\r
 /**\r
   This is the main Dispatcher for DXE and it exits when there are no more\r
   drivers to run. Drain the mScheduledQueue and load and start a PE\r
@@ -452,7 +432,7 @@ CoreDispatcher (
   Status = CoreCreateEventEx (\r
              EVT_NOTIFY_SIGNAL,\r
              TPL_NOTIFY,\r
-             CoreEmptyCallbackFunction,\r
+             EfiEventEmptyFunction,\r
              NULL,\r
              &gEfiEventDxeDispatchGuid,\r
              &DxeDispatchEvent\r
@@ -737,6 +717,8 @@ FvIsBeingProcesssed (
   LIST_ENTRY                            *Link;\r
   KNOWN_HANDLE                          *KnownHandle;\r
 \r
+  FwVolHeader = NULL;\r
+\r
   //\r
   // Get the FirmwareVolumeBlock protocol on that handle\r
   //\r
@@ -791,7 +773,7 @@ FvIsBeingProcesssed (
     for (Link = mFvHandleList.ForwardLink; Link != &mFvHandleList; Link = Link->ForwardLink) {\r
       KnownHandle = CR(Link, KNOWN_HANDLE, Link, KNOWN_HANDLE_SIGNATURE);\r
       if (CompareGuid (&FvNameGuid, &KnownHandle->FvNameGuid)) {\r
-        DEBUG ((EFI_D_ERROR, "FvImage on FvHandle %p and %p has the same FvNameGuid %g.\n", FvHandle, KnownHandle->Handle, FvNameGuid));\r
+        DEBUG ((EFI_D_ERROR, "FvImage on FvHandle %p and %p has the same FvNameGuid %g.\n", FvHandle, KnownHandle->Handle, &FvNameGuid));\r
         return NULL;\r
       }\r
     }\r
@@ -985,6 +967,7 @@ CoreProcessFvImageFile (
   UINTN                               BufferSize;\r
   EFI_FIRMWARE_VOLUME_HEADER          *FvHeader;\r
   UINT32                              FvAlignment;\r
+  EFI_DEVICE_PATH_PROTOCOL            *FvFileDevicePath;\r
 \r
   //\r
   // Read the first (and only the first) firmware volume section\r
@@ -1005,43 +988,79 @@ CoreProcessFvImageFile (
                  &AuthenticationStatus\r
                  );\r
   if (!EFI_ERROR (Status)) {\r
+     //\r
+    // Evaluate the authentication status of the Firmware Volume through\r
+    // Security Architectural Protocol\r
+    //\r
+    if (gSecurity != NULL) {\r
+      FvFileDevicePath = CoreFvToDevicePath (Fv, FvHandle, DriverName);\r
+      Status = gSecurity->FileAuthenticationState (\r
+                            gSecurity,\r
+                            AuthenticationStatus,\r
+                            FvFileDevicePath\r
+                            );\r
+      if (FvFileDevicePath != NULL) {\r
+        FreePool (FvFileDevicePath);\r
+      }\r
+\r
+      if (Status != EFI_SUCCESS) {\r
+        //\r
+        // Security check failed. The firmware volume should not be used for any purpose.\r
+        //\r
+        if (Buffer != NULL) {\r
+          FreePool (Buffer);\r
+        }\r
+        return Status;\r
+      }\r
+    }\r
+\r
     //\r
     // FvImage should be at its required alignment.\r
     //\r
     FvHeader = (EFI_FIRMWARE_VOLUME_HEADER *) Buffer;\r
     //\r
-    // Get FvHeader alignment\r
-    //\r
-    FvAlignment = 1 << ((FvHeader->Attributes & EFI_FVB2_ALIGNMENT) >> 16);\r
-    //\r
-    // FvAlignment must be greater than or equal to 8 bytes of the minimum FFS alignment value. \r
+    // If EFI_FVB2_WEAK_ALIGNMENT is set in the volume header then the first byte of the volume\r
+    // can be aligned on any power-of-two boundary. A weakly aligned volume can not be moved from\r
+    // its initial linked location and maintain its alignment.\r
     //\r
-    if (FvAlignment < 8) {\r
-      FvAlignment = 8;\r
-    }\r
-    //\r
-    // Allocate the aligned buffer for the FvImage.\r
-    //\r
-    AlignedBuffer = AllocateAlignedPages (EFI_SIZE_TO_PAGES (BufferSize), (UINTN) FvAlignment);\r
-    if (AlignedBuffer == NULL) {\r
-      Status = EFI_OUT_OF_RESOURCES;\r
-    } else {\r
+    if ((FvHeader->Attributes & EFI_FVB2_WEAK_ALIGNMENT) != EFI_FVB2_WEAK_ALIGNMENT) {\r
       //\r
-      // Move FvImage into the aligned buffer and release the original buffer.\r
+      // Get FvHeader alignment\r
       //\r
-      CopyMem (AlignedBuffer, Buffer, BufferSize);\r
-      CoreFreePool (Buffer);\r
-      Buffer = NULL;\r
+      FvAlignment = 1 << ((FvHeader->Attributes & EFI_FVB2_ALIGNMENT) >> 16);\r
       //\r
-      // Produce a FVB protocol for the file\r
+      // FvAlignment must be greater than or equal to 8 bytes of the minimum FFS alignment value.\r
       //\r
-      Status = ProduceFVBProtocolOnBuffer (\r
-                (EFI_PHYSICAL_ADDRESS) (UINTN) AlignedBuffer,\r
-                (UINT64)BufferSize,\r
-                FvHandle,\r
-                NULL\r
-                );\r
+      if (FvAlignment < 8) {\r
+        FvAlignment = 8;\r
+      }\r
+      //\r
+      // Allocate the aligned buffer for the FvImage.\r
+      //\r
+      AlignedBuffer = AllocateAlignedPages (EFI_SIZE_TO_PAGES (BufferSize), (UINTN) FvAlignment);\r
+      if (AlignedBuffer == NULL) {\r
+        FreePool (Buffer);\r
+        return EFI_OUT_OF_RESOURCES;\r
+      } else {\r
+        //\r
+        // Move FvImage into the aligned buffer and release the original buffer.\r
+        //\r
+        CopyMem (AlignedBuffer, Buffer, BufferSize);\r
+        FvHeader = (EFI_FIRMWARE_VOLUME_HEADER *) AlignedBuffer;\r
+        CoreFreePool (Buffer);\r
+        Buffer = NULL;\r
+      }\r
     }\r
+    //\r
+    // Produce a FVB protocol for the file\r
+    //\r
+    Status = ProduceFVBProtocolOnBuffer (\r
+              (EFI_PHYSICAL_ADDRESS) (UINTN) FvHeader,\r
+              (UINT64)BufferSize,\r
+              FvHandle,\r
+              AuthenticationStatus,\r
+              NULL\r
+              );\r
   }\r
 \r
   if (EFI_ERROR (Status)) {\r
@@ -1087,7 +1106,6 @@ CoreFwVolEventProtocolNotify (
 {\r
   EFI_STATUS                    Status;\r
   EFI_STATUS                    GetNextFileStatus;\r
-  EFI_STATUS                    SecurityStatus;\r
   EFI_FIRMWARE_VOLUME2_PROTOCOL *Fv;\r
   EFI_DEVICE_PATH_PROTOCOL      *FvDevicePath;\r
   EFI_HANDLE                    FvHandle;\r
@@ -1107,6 +1125,8 @@ CoreFwVolEventProtocolNotify (
   VOID                          *DepexBuffer;\r
   KNOWN_HANDLE                  *KnownHandle;\r
 \r
+  FvHandle = NULL;\r
+\r
   while (TRUE) {\r
     BufferSize = sizeof (EFI_HANDLE);\r
     Status = CoreLocateHandle (\r
@@ -1159,24 +1179,6 @@ CoreFwVolEventProtocolNotify (
       continue;\r
     }\r
 \r
-    //\r
-    // Evaluate the authentication status of the Firmware Volume through\r
-    // Security Architectural Protocol\r
-    //\r
-    if (gSecurity != NULL) {\r
-      SecurityStatus = gSecurity->FileAuthenticationState (\r
-                                    gSecurity,\r
-                                    0,\r
-                                    FvDevicePath\r
-                                    );\r
-      if (SecurityStatus != EFI_SUCCESS) {\r
-        //\r
-        // Security check failed. The firmware volume should not be used for any purpose.\r
-        //\r
-        continue;\r
-      }\r
-    }\r
-\r
     //\r
     // Discover Drivers in FV and add them to the Discovered Driver List.\r
     // Process EFI_FV_FILETYPE_DRIVER type and then EFI_FV_FILETYPE_COMBINED_PEIM_DRIVER\r
@@ -1227,29 +1229,6 @@ CoreFwVolEventProtocolNotify (
               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
             // Check if this EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE file has SMM depex section.\r
             //\r
@@ -1266,11 +1245,11 @@ CoreFwVolEventProtocolNotify (
                            );\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
+              // If SMM depex section is found, this FV image is invalid to be supported.\r
+              // ASSERT FALSE to report this FV image.  \r
               //\r
               FreePool (DepexBuffer);\r
-              continue;\r
+              ASSERT (FALSE);\r
             }\r
 \r
             //\r