⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dispatcher.c

📁 EFI BIOS是Intel提出的下一代的BIOS标准。这里上传的Edk源代码是EFI BIOS源代码中的与平台无关部分的代码
💻 C
📖 第 1 页 / 共 2 页
字号:
          //
          // don't process the default Fv again. (we don't know the order in which the hobs were created)
          //
          if ((NextFvAddress != DefaultFvAddress) && 
              (NextFvAddress != DispatchData->CurrentFvAddress)) {
            
            //
            // VerifyFv() is currently returns SUCCESS all the time, add code to it to 
            // actually verify the given FV
            //
            Status = VerifyFv (NextFvAddress);
            if (Status == EFI_SUCCESS) {
              NextFvFound = TRUE;
              DispatchData->CurrentFvAddress = NextFvAddress;
              DispatchData->CurrentPeimAddress = NULL;
              // 
              // current PRIM number (CurrentPeim) must continue as is, don't reset it here
              //
            }
          }         
        }
        //
        // if there is no next fv, get out of this loop of dispatching PEIMs
        //
        if (!NextFvFound) {
          break;
        }
        //
        // continue in the inner for(;;) loop with a new FV;
        //
      }
    }

    //
    // If all the PEIMs that we have found have been dispatched, then
    // there is nothing left to dispatch and we don't need to go search
    // through all PEIMs again.
    //
    if ((~(DispatchData->DispatchedPeimBitMap) & 
         ((1 << DispatchData->CurrentPeim)-1)) == 0) {
      break;
    }
      
    // 
    // Check if no more PEIMs that depex was satisfied
    //
    if (DispatchData->DispatchedPeimBitMap == DispatchData->PreviousPeimBitMap) {
      break;
    }

    //
    // Case when Depex is not satisfied and has to traverse the list again
    //
    DispatchData->CurrentPeim = 0;
    DispatchData->CurrentPeimAddress = 0;
    DispatchData->PreviousPeimBitMap = DispatchData->DispatchedPeimBitMap;

    //
    // don't go back to the loop without making sure that the CurrentFvAddress is the 
    // same as the 1st (or default) FV we started with. otherwise we will interpret the bimap wrongly and
    // mess it up, always start processing the PEIMs from the default FV just like in the first time around.
    //
    DispatchData->CurrentFv = 0;
    DispatchData->CurrentFvAddress = DefaultFvAddress;
  }

  PEI_DEBUG_CODE (

    DebugFoundPeimPoint = 0;
    //
    // Get bitmap of Peims that were not dispatched,
    // 

    DebugNotDispatchedBitmap = ((DispatchData->DispatchedPeimBitMap) ^ ((1 << DispatchData->CurrentPeim)-1));
    //
    // Scan bitmap of Peims not installed and print GUIDS
    //
    while (DebugNotDispatchedBitmap != 0) {
      if ((DebugNotDispatchedBitmap & 1) != 0) {
        PEI_DEBUG (
          (&PrivateData->PS, EFI_D_INFO, 
           "WARNING -> InstallPpi: Not Installed: %g\n", 
           &DebugFoundPeimList[DebugFoundPeimPoint])
          );
      }
      DebugFoundPeimPoint++;
      DebugNotDispatchedBitmap >>= 1;
    }

  )

   return EFI_NOT_FOUND;
}

VOID
InitializeDispatcherData (
  IN EFI_PEI_SERVICES             **PeiServices,
  IN PEI_CORE_INSTANCE            *OldCoreData,
  IN EFI_PEI_STARTUP_DESCRIPTOR   *PeiStartupDescriptor
  )
/*++

Routine Description:

  Initialize the Dispatcher's data members

Arguments:

  PeiServices          - The PEI core services table.
  OldCoreData          - Pointer to old core data (before switching stack).
                         NULL if being run in non-permament memory mode.
  PeiStartupDescriptor - Information and services provided by SEC phase.

Returns:

  None.

--*/
{
  PEI_CORE_INSTANCE *PrivateData;

  PrivateData = PEI_CORE_INSTANCE_FROM_PS_THIS (PeiServices);

  if (OldCoreData == NULL) {
    PrivateData->DispatchData.CurrentFvAddress = (EFI_FIRMWARE_VOLUME_HEADER *) PeiStartupDescriptor->BootFirmwareVolume;
    PrivateData->DispatchData.BootFvAddress = (EFI_FIRMWARE_VOLUME_HEADER *) PeiStartupDescriptor->BootFirmwareVolume;    
  } else {
    
    //
    // Current peim has been dispatched, but not count
    //
    PrivateData->DispatchData.CurrentPeim = (UINT8)(OldCoreData->DispatchData.CurrentPeim + 1);
  }

  return;
}


BOOLEAN
Dispatched (
  IN UINT8  CurrentPeim,
  IN UINT32 DispatchedPeimBitMap
  )
/*++

Routine Description:

  This routine checks to see if a particular PEIM has been dispatched during
  the PEI core dispatch.

Arguments:
  CurrentPeim          - The PEIM/FV in the bit array to check.
  DispatchedPeimBitMap - Bit array, each bit corresponds to a PEIM/FV.

Returns:
  TRUE  - PEIM already dispatched
  FALSE - Otherwise

--*/
{
  return (BOOLEAN)((DispatchedPeimBitMap & (1 << CurrentPeim)) != 0);
}

VOID 
SetDispatched ( 
  IN EFI_PEI_SERVICES   **PeiServices,
  IN UINT8              CurrentPeim,
  OUT UINT32            *DispatchedPeimBitMap
  ) 
/*++

Routine Description:

  This routine sets a PEIM as having been dispatched once its entry
  point has been invoked.

Arguments:

  PeiServices          - The PEI core services table.
  CurrentPeim          - The PEIM/FV in the bit array to check.
  DispatchedPeimBitMap - Bit array, each bit corresponds to a PEIM/FV.

Returns:
  None

--*/
{
  //
  // Check if the total number of PEIMs exceed the bitmap.
  // CurrentPeim is 0-based
  //
PEI_DEBUG_CODE (
  if (CurrentPeim > (sizeof (*DispatchedPeimBitMap) * 8 - 1)) {
    ASSERT_PEI_ERROR (PeiServices, EFI_OUT_OF_RESOURCES);
  }
)
  *DispatchedPeimBitMap |= (1 << CurrentPeim);
  return;
}

BOOLEAN
DepexSatisfied (
  IN EFI_PEI_SERVICES  **PeiServices,
  IN VOID              *CurrentPeimAddress
  )
/*++

Routine Description:

  This routine parses the Dependency Expression, if available, and
  decides if the module can be executed.

Arguments:
  PeiServices - The PEI Service Table
  CurrentPeimAddress - Address of the PEIM Firmware File under investigation

Returns:
  TRUE  - Can be dispatched
  FALSE - Cannot be dispatched

--*/
{
  EFI_STATUS  Status;
  INT8        *DepexData;
  BOOLEAN     Runnable;

  Status = PeiFfsFindSectionData (
            PeiServices,
            EFI_SECTION_PEI_DEPEX,
            CurrentPeimAddress,
            &DepexData 
            );
  //
  // If there is no DEPEX, assume the module can be executed
  //
  if (EFI_ERROR (Status)) {
    return TRUE;
  }

  //
  // Evaluate a given DEPEX
  //
  Status = PeimDispatchReadiness (
            PeiServices, 
            DepexData, 
            &Runnable  
            );

  return Runnable;
}


EFI_STATUS
TransferOldDataToNewDataRange (
  IN PEI_CORE_INSTANCE        *PrivateData,
  OUT UINTN                   *PrivateDataInMem
  )
/*++

Routine Description:

  This routine transfers the contents of the pre-permanent memory
  PEI Core private data to a post-permanent memory data location.

Arguments:
  PrivateData       - Pointer to the current PEI Core private data pre-permanent memory
  PrivateDataInMem  - Pointer to the PrivateData once the private data has been transferred
                      to permanent memory

Returns:
  EFI_SUCCESS   - Successfully transfered
  EFI_ERROR     - Fail to transfer

--*/
{
    EFI_STATUS  Status;

    Status = PeiBuildHobGuid (
              &(PrivateData->PS),
              &gEfiPeiCorePrivateGuid,
              sizeof (PEI_CORE_INSTANCE),
              (VOID*)PrivateDataInMem
              );
    if (EFI_ERROR (Status)) {
      return Status;
    }
    (*PrivateDataInMem) += sizeof (EFI_HOB_GUID_TYPE);
    PrivateData->PS->CopyMem (
                      (VOID*)(*PrivateDataInMem),
                      (VOID*)PrivateData,
                      sizeof (PEI_CORE_INSTANCE)
                      );

    return EFI_SUCCESS;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -