]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Core/Dxe/Dispatcher/Dispatcher.c
Use TmpStr as a backup, as StrCpy in BaseLib does not handle copy of two strings
[mirror_edk2.git] / MdeModulePkg / Core / Dxe / Dispatcher / Dispatcher.c
index 5a0efad1b79b05e1bd8a53c4b0b0eedf41e20111..27f18326e02047b0d1c3fa94c730c6cdd53f28eb 100644 (file)
   Depex - Dependency Expresion.\r
   SOR   - Schedule On Request - Don't schedule if this bit is set.\r
 \r
-Copyright (c) 2006 - 2008, Intel Corporation                                                         \r
-All rights reserved. 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
+Copyright (c) 2006 - 2008, Intel Corporation. <BR>\r
+All rights reserved. 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
 \r
 **/\r
 \r
@@ -76,7 +76,7 @@ VOID            *mFwVolEventRegistration;
 //\r
 // List of file types supported by dispatcher\r
 //\r
-STATIC EFI_FV_FILETYPE mDxeFileTypes[] = { \r
+EFI_FV_FILETYPE mDxeFileTypes[] = { \r
   EFI_FV_FILETYPE_DRIVER, \r
   EFI_FV_FILETYPE_COMBINED_PEIM_DRIVER, \r
   EFI_FV_FILETYPE_DXE_CORE,\r
@@ -105,7 +105,6 @@ FV_FILEPATH_DEVICE_PATH mFvDevicePath;
   @param  InsertedDriverEntry   The driver to insert on the ScheduledLink Queue\r
 \r
 **/\r
-STATIC\r
 VOID\r
 CoreInsertOnScheduledQueueWhileProcessingBeforeAndAfter (\r
   IN  EFI_CORE_DRIVER_ENTRY   *InsertedDriverEntry\r
@@ -128,7 +127,6 @@ CoreInsertOnScheduledQueueWhileProcessingBeforeAndAfter (
   @param  Context               Event Context, not used.\r
 \r
 **/\r
-STATIC\r
 VOID\r
 EFIAPI\r
 CoreFwVolEventProtocolNotify (\r
@@ -137,7 +135,7 @@ CoreFwVolEventProtocolNotify (
   );\r
 \r
 /**\r
-  Convert FvHandle and DriverName into an EFI device path\r
+  Convert FvHandle and DriverName into an EFI device path.\r
 \r
   @param  Fv                    Fv protocol, needed to read Depex info out of \r
                                 FLASH. \r
@@ -149,7 +147,6 @@ CoreFwVolEventProtocolNotify (
   @return Pointer to device path constructed from FvHandle and DriverName\r
 \r
 **/\r
-STATIC\r
 EFI_DEVICE_PATH_PROTOCOL *\r
 CoreFvToDevicePath (\r
   IN  EFI_FIRMWARE_VOLUME2_PROTOCOL   *Fv,\r
@@ -177,12 +174,11 @@ CoreFvToDevicePath (
                                 time.\r
 \r
 **/\r
-STATIC \r
 EFI_STATUS\r
 CoreAddToDriverList (\r
-  IN  EFI_FIRMWARE_VOLUME2_PROTOCOL *Fv,\r
-  IN  EFI_HANDLE                    FvHandle,\r
-  IN  EFI_GUID                      *DriverName\r
+  IN  EFI_FIRMWARE_VOLUME2_PROTOCOL   *Fv,\r
+  IN  EFI_HANDLE                      FvHandle,\r
+  IN  EFI_GUID                        *DriverName\r
   );\r
 \r
 /**\r
@@ -197,7 +193,6 @@ CoreAddToDriverList (
   @retval EFI_SUCCESS           Function successfully returned.\r
 \r
 **/\r
-STATIC\r
 EFI_STATUS \r
 CoreProcessFvImageFile (\r
   IN  EFI_FIRMWARE_VOLUME2_PROTOCOL   *Fv,\r
@@ -210,7 +205,6 @@ CoreProcessFvImageFile (
   Enter critical section by gaining lock on mDispatcherLock.\r
 \r
 **/\r
-STATIC\r
 VOID\r
 CoreAcquireDispatcherLock (\r
   VOID\r
@@ -224,7 +218,6 @@ CoreAcquireDispatcherLock (
   Exit critical section by releasing lock on mDispatcherLock.\r
 \r
 **/\r
-STATIC\r
 VOID\r
 CoreReleaseDispatcherLock (\r
   VOID\r
@@ -246,7 +239,6 @@ CoreReleaseDispatcherLock (
   @retval Error                 DEPEX not found.\r
 \r
 **/\r
-STATIC\r
 EFI_STATUS\r
 CoreGetDepexSectionAndPreProccess (\r
   IN  EFI_CORE_DRIVER_ENTRY   *DriverEntry\r
@@ -314,7 +306,6 @@ CoreGetDepexSectionAndPreProccess (
                                 not set. \r
 \r
 **/\r
-EFI_DXESERVICE\r
 EFI_STATUS\r
 EFIAPI\r
 CoreSchedule (\r
@@ -350,7 +341,7 @@ CoreSchedule (
 \r
 \r
 /**\r
-  Convert a driver from the Untrused back to the Scheduled state\r
+  Convert a driver from the Untrused back to the Scheduled state.\r
 \r
   @param  FirmwareVolumeHandle  The handle of the Firmware Volume that contains \r
                                 the firmware  file specified by DriverName. \r
@@ -361,7 +352,6 @@ CoreSchedule (
   @retval EFI_NOT_FOUND         The file was not found in the untrusted state. \r
 \r
 **/\r
-EFI_DXESERVICE\r
 EFI_STATUS\r
 EFIAPI\r
 CoreTrust (\r
@@ -406,14 +396,11 @@ CoreTrust (
   will be called, and when the Bds() exits the Dispatcher will be called\r
   again.\r
 \r
-  NONE\r
-\r
   @retval EFI_ALREADY_STARTED   The DXE Dispatcher is already running \r
   @retval EFI_NOT_FOUND         No DXE Drivers were dispatched \r
   @retval EFI_SUCCESS           One or more DXE Drivers were dispatched \r
 \r
 **/\r
-EFI_DXESERVICE\r
 EFI_STATUS\r
 EFIAPI\r
 CoreDispatcher (\r
@@ -558,7 +545,6 @@ CoreDispatcher (
   @param  InsertedDriverEntry   The driver to insert on the ScheduledLink Queue\r
 \r
 **/\r
-STATIC\r
 VOID\r
 CoreInsertOnScheduledQueueWhileProcessingBeforeAndAfter (\r
   IN  EFI_CORE_DRIVER_ENTRY   *InsertedDriverEntry\r
@@ -616,11 +602,9 @@ CoreInsertOnScheduledQueueWhileProcessingBeforeAndAfter (
   @param  FvHandle              The handle of a FV that's being tested \r
 \r
   @retval TRUE                  Fv protocol on FvHandle has been processed \r
-  @retval FALSE                 Fv protocol on FvHandle has not yet been \r
-                                processed\r
+  @retval FALSE                 Fv protocol on FvHandle has not yet been processed\r
 \r
 **/\r
-STATIC\r
 BOOLEAN\r
 FvHasBeenProcessed (\r
   IN  EFI_HANDLE      FvHandle\r
@@ -647,7 +631,6 @@ FvHasBeenProcessed (
   @param  FvHandle              The handle of a FV that has been processed\r
 \r
 **/\r
-STATIC\r
 VOID\r
 FvIsBeingProcesssed (\r
   IN  EFI_HANDLE    FvHandle\r
@@ -679,7 +662,6 @@ FvIsBeingProcesssed (
   @return Pointer to device path constructed from FvHandle and DriverName\r
 \r
 **/\r
-STATIC\r
 EFI_DEVICE_PATH_PROTOCOL *\r
 CoreFvToDevicePath (\r
   IN  EFI_FIRMWARE_VOLUME2_PROTOCOL   *Fv,\r
@@ -717,7 +699,6 @@ CoreFvToDevicePath (
 \r
 \r
 \r
-\r
 /**\r
   Add an entry to the mDiscoveredList. Allocate memory to store the DriverEntry,\r
   and initilize any state variables. Read the Depex from the FV and store it\r
@@ -756,7 +737,7 @@ CoreAddToDriverList (
   ASSERT (DriverEntry != NULL);\r
 \r
   DriverEntry->Signature        = EFI_CORE_DRIVER_ENTRY_SIGNATURE;\r
-  CopyMem (&DriverEntry->FileName, DriverName, sizeof (EFI_GUID));\r
+  CopyGuid (&DriverEntry->FileName, DriverName);\r
   DriverEntry->FvHandle         = FvHandle;\r
   DriverEntry->Fv               = Fv;\r
   DriverEntry->FvFileDevicePath = CoreFvToDevicePath (Fv, FvHandle, DriverName);\r
@@ -785,7 +766,6 @@ CoreAddToDriverList (
   @retval FALSE                 Not found.\r
 \r
 **/\r
-STATIC\r
 BOOLEAN\r
 FvFoundInHobFv2 (\r
   IN  EFI_HANDLE                      FvHandle,\r
@@ -839,21 +819,21 @@ CoreProcessFvImageFile (
   //\r
   // Read the first (and only the first) firmware volume section\r
   //\r
-  SectionType = EFI_SECTION_FIRMWARE_VOLUME_IMAGE;\r
-  FvHeader    = NULL;\r
-  FvAlignment = 0;\r
-  Buffer      = NULL;\r
-  BufferSize  = 0;\r
+  SectionType   = EFI_SECTION_FIRMWARE_VOLUME_IMAGE;\r
+  FvHeader      = NULL;\r
+  FvAlignment   = 0;\r
+  Buffer        = NULL;\r
+  BufferSize    = 0;\r
   AlignedBuffer = NULL;\r
   Status = Fv->ReadSection (\r
-                Fv, \r
-                DriverName, \r
-                SectionType, \r
-                0, \r
-                &Buffer, \r
-                &BufferSize,\r
-                &AuthenticationStatus\r
-                );\r
+                 Fv, \r
+                 DriverName, \r
+                 SectionType, \r
+                 0, \r
+                 &Buffer, \r
+                 &BufferSize,\r
+                 &AuthenticationStatus\r
+                 );\r
   if (!EFI_ERROR (Status)) {\r
     //\r
     // FvImage should be at its required alignment.\r
@@ -866,6 +846,9 @@ CoreProcessFvImageFile (
     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
@@ -922,7 +905,6 @@ CoreProcessFvImageFile (
   @param  Context               Event Context, not used.\r
 \r
 **/\r
-STATIC\r
 VOID\r
 EFIAPI\r
 CoreFwVolEventProtocolNotify (\r
@@ -954,12 +936,12 @@ CoreFwVolEventProtocolNotify (
   while (TRUE) {\r
     BufferSize = sizeof (EFI_HANDLE);\r
     Status = CoreLocateHandle (\r
-                    ByRegisterNotify,\r
-                    NULL,\r
-                    mFwVolEventRegistration,\r
-                    &BufferSize,\r
-                    &FvHandle\r
-                    );\r
+               ByRegisterNotify,\r
+               NULL,\r
+               mFwVolEventRegistration,\r
+               &BufferSize,\r
+               &FvHandle\r
+               );\r
     if (EFI_ERROR (Status)) {\r
       //\r
       // If no more notification events exit\r
@@ -988,7 +970,6 @@ CoreFwVolEventProtocolNotify (
     //\r
     FvIsBeingProcesssed (FvHandle);\r
 \r
-\r
     Status = CoreHandleProtocol (FvHandle, &gEfiFirmwareVolume2ProtocolGuid, (VOID **)&Fv);\r
     if (EFI_ERROR (Status)) {\r
       //\r
@@ -1031,7 +1012,7 @@ CoreFwVolEventProtocolNotify (
     //  EFI_FV_FILETYPE_DXE_CORE is processed to produce a Loaded Image protocol for the core\r
     //  EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE is processed to create a Fvb\r
     //\r
-    for (Index = 0; Index < sizeof (mDxeFileTypes)/sizeof (EFI_FV_FILETYPE); Index++) {\r
+    for (Index = 0; Index < sizeof (mDxeFileTypes) / sizeof (EFI_FV_FILETYPE); Index++) {\r
       //\r
       // Initialize the search key\r
       //\r
@@ -1144,7 +1125,7 @@ CoreFwVolEventProtocolNotify (
 \r
 /**\r
   Initialize the dispatcher. Initialize the notification function that runs when\r
-  a FV protocol is added to the system.\r
+  an FV2 protocol is added to the system.\r
 \r
 **/\r
 VOID\r