本文整理汇总了C++中PcdGet32函数的典型用法代码示例。如果您正苦于以下问题:C++ PcdGet32函数的具体用法?C++ PcdGet32怎么用?C++ PcdGet32使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PcdGet32函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AcquireSpinLock
EFIAPI
AcquireSpinLock (
IN OUT SPIN_LOCK *SpinLock
)
{
UINT64 Current;
UINT64 Previous;
UINT64 Total;
UINT64 Start;
UINT64 End;
UINT64 Timeout;
INT64 Cycle;
INT64 Delta;
if (PcdGet32 (PcdSpinLockTimeout) > 0) {
//
// Get the current timer value
//
Current = GetPerformanceCounter();
//
// Initialize local variables
//
Start = 0;
End = 0;
Total = 0;
//
// Retrieve the performance counter properties and compute the number of performance
// counter ticks required to reach the timeout
//
Timeout = DivU64x32 (
MultU64x32 (
GetPerformanceCounterProperties (&Start, &End),
PcdGet32 (PcdSpinLockTimeout)
),
1000000
);
Cycle = End - Start;
if (Cycle < 0) {
Cycle = -Cycle;
}
Cycle++;
while (!AcquireSpinLockOrFail (SpinLock)) {
CpuPause ();
Previous = Current;
Current = GetPerformanceCounter();
Delta = (INT64) (Current - Previous);
if (Start > End) {
Delta = -Delta;
}
if (Delta < 0) {
Delta += Cycle;
}
Total += Delta;
ASSERT (Total < Timeout);
}
} else {
while (!AcquireSpinLockOrFail (SpinLock)) {
CpuPause ();
}
}
return SpinLock;
}
示例2: system
/**
Initialize the system (or sometimes called permanent) memory
This memory is generally represented by the DRAM.
This function is called from InitializeMemory() in MemoryInitPeim, in the PEI
phase.
**/
VOID
ArmPlatformInitializeSystemMemory (
VOID
)
{
VOID *DeviceTreeBase;
INT32 Node, Prev;
UINT64 NewBase;
UINT64 NewSize;
CONST CHAR8 *Type;
INT32 Len;
CONST UINT64 *RegProp;
NewBase = 0;
NewSize = 0;
DeviceTreeBase = (VOID *)(UINTN)PcdGet64 (PcdDeviceTreeInitialBaseAddress);
ASSERT (DeviceTreeBase != NULL);
//
// Make sure we have a valid device tree blob
//
ASSERT (fdt_check_header (DeviceTreeBase) == 0);
//
// Look for a memory node
//
for (Prev = 0;; Prev = Node) {
Node = fdt_next_node (DeviceTreeBase, Prev, NULL);
if (Node < 0) {
break;
}
//
// Check for memory node
//
Type = fdt_getprop (DeviceTreeBase, Node, "device_type", &Len);
if (Type && AsciiStrnCmp (Type, "memory", Len) == 0) {
//
// Get the 'reg' property of this node. For now, we will assume
// two 8 byte quantities for base and size, respectively.
//
RegProp = fdt_getprop (DeviceTreeBase, Node, "reg", &Len);
if (RegProp != 0 && Len == (2 * sizeof (UINT64))) {
NewBase = fdt64_to_cpu (ReadUnaligned64 (RegProp));
NewSize = fdt64_to_cpu (ReadUnaligned64 (RegProp + 1));
//
// Make sure the start of DRAM matches our expectation
//
ASSERT (FixedPcdGet64 (PcdSystemMemoryBase) == NewBase);
PcdSet64 (PcdSystemMemorySize, NewSize);
DEBUG ((EFI_D_INFO, "%a: System RAM @ 0x%lx - 0x%lx\n",
__FUNCTION__, NewBase, NewBase + NewSize - 1));
} else {
DEBUG ((EFI_D_ERROR, "%a: Failed to parse FDT memory node\n",
__FUNCTION__));
}
break;
}
}
//
// We need to make sure that the machine we are running on has at least
// 128 MB of memory configured, and is currently executing this binary from
// NOR flash. This prevents a device tree image in DRAM from getting
// clobbered when our caller installs permanent PEI RAM, before we have a
// chance of marking its location as reserved or copy it to a freshly
// allocated block in the permanent PEI RAM in the platform PEIM.
//
ASSERT (NewSize >= SIZE_128MB);
ASSERT (
(((UINT64)PcdGet64 (PcdFdBaseAddress) +
(UINT64)PcdGet32 (PcdFdSize)) <= NewBase) ||
((UINT64)PcdGet64 (PcdFdBaseAddress) >= (NewBase + NewSize)));
}
示例3: ReadUsingMmio
BOOLEAN
ReadUsingMmio (
IN UINTN SpiOffset
)
{
return (BOOLEAN) ((SpiOffset >= BIOS_REGION_FLASH_OFFSET) && (SpiOffset < (BIOS_REGION_FLASH_OFFSET + PcdGet32 (PcdBiosImageSize))) && (!EfiAtRuntime ()));
}
示例4: InterruptDxeInitialize
/**
Initialize the state information for the CPU Architectural Protocol
@param ImageHandle of the loaded driver
@param SystemTable Pointer to the System Table
@retval EFI_SUCCESS Protocol registered
@retval EFI_OUT_OF_RESOURCES Cannot allocate protocol data structure
@retval EFI_DEVICE_ERROR Hardware problems
**/
EFI_STATUS
InterruptDxeInitialize (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
{
EFI_STATUS Status;
UINTN Index;
UINT32 RegOffset;
UINTN RegShift;
EFI_CPU_ARCH_PROTOCOL *Cpu;
// Make sure the Interrupt Controller Protocol is not already installed in the system.
ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL, &gHardwareInterruptProtocolGuid);
mGicNumInterrupts = ArmGicGetMaxNumInterrupts (PcdGet32(PcdGicDistributorBase));
for (Index = 0; Index < mGicNumInterrupts; Index++) {
DisableInterruptSource (&gHardwareInterruptProtocol, Index);
// Set Priority
RegOffset = Index / 4;
RegShift = (Index % 4) * 8;
MmioAndThenOr32 (
PcdGet32(PcdGicDistributorBase) + ARM_GIC_ICDIPR + (4*RegOffset),
~(0xff << RegShift),
ARM_GIC_DEFAULT_PRIORITY << RegShift
);
}
// Configure interrupts for cpu 0
for (Index = 0; Index < (mGicNumInterrupts / 4); Index++) {
MmioWrite32 (PcdGet32(PcdGicDistributorBase) + ARM_GIC_ICDIPTR + (Index*4), 0x01010101);
}
// Set binary point reg to 0x7 (no preemption)
MmioWrite32 (PcdGet32(PcdGicInterruptInterfaceBase) + ARM_GIC_ICCBPR, 0x7);
// Set priority mask reg to 0xff to allow all priorities through
MmioWrite32 (PcdGet32(PcdGicInterruptInterfaceBase) + ARM_GIC_ICCPMR, 0xff);
// Enable gic cpu interface
MmioWrite32 (PcdGet32(PcdGicInterruptInterfaceBase) + ARM_GIC_ICCICR, 0x1);
// Enable gic distributor
MmioWrite32 (PcdGet32(PcdGicDistributorBase) + ARM_GIC_ICDDCR, 0x1);
// Initialize the array for the Interrupt Handlers
gRegisteredInterruptHandlers = (HARDWARE_INTERRUPT_HANDLER*)AllocateZeroPool (sizeof(HARDWARE_INTERRUPT_HANDLER) * mGicNumInterrupts);
Status = gBS->InstallMultipleProtocolInterfaces (
&gHardwareInterruptHandle,
&gHardwareInterruptProtocolGuid, &gHardwareInterruptProtocol,
NULL
);
ASSERT_EFI_ERROR (Status);
//
// Get the CPU protocol that this driver requires.
//
Status = gBS->LocateProtocol(&gEfiCpuArchProtocolGuid, NULL, (VOID **)&Cpu);
ASSERT_EFI_ERROR(Status);
//
// Unregister the default exception handler.
//
Status = Cpu->RegisterInterruptHandler(Cpu, EXCEPT_ARM_IRQ, NULL);
ASSERT_EFI_ERROR(Status);
//
// Register to receive interrupts
//
Status = Cpu->RegisterInterruptHandler(Cpu, EXCEPT_ARM_IRQ, IrqInterruptHandler);
ASSERT_EFI_ERROR(Status);
// Register for an ExitBootServicesEvent
Status = gBS->CreateEvent (EVT_SIGNAL_EXIT_BOOT_SERVICES, TPL_NOTIFY, ExitBootServicesEvent, NULL, &EfiExitBootServicesEvent);
ASSERT_EFI_ERROR (Status);
return Status;
}
示例5: InitializeUserInterface
/**
The user Entry Point for Application. The user code starts with this function
as the real entry point for the image goes into a library that calls this
function.
@param[in] ImageHandle The firmware allocated handle for the EFI image.
@param[in] SystemTable A pointer to the EFI System Table.
@retval EFI_SUCCESS The entry point is executed successfully.
@retval other Some error occurs when executing this entry point.
**/
EFI_STATUS
EFIAPI
InitializeUserInterface (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
{
EFI_HII_HANDLE HiiHandle;
EFI_STATUS Status;
EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;
EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *SimpleTextOut;
UINTN BootTextColumn;
UINTN BootTextRow;
if (!mModeInitialized) {
//
// After the console is ready, get current video resolution
// and text mode before launching setup at first time.
//
Status = gBS->HandleProtocol (
gST->ConsoleOutHandle,
&gEfiGraphicsOutputProtocolGuid,
(VOID**)&GraphicsOutput
);
if (EFI_ERROR (Status)) {
GraphicsOutput = NULL;
}
Status = gBS->HandleProtocol (
gST->ConsoleOutHandle,
&gEfiSimpleTextOutProtocolGuid,
(VOID**)&SimpleTextOut
);
if (EFI_ERROR (Status)) {
SimpleTextOut = NULL;
}
if (GraphicsOutput != NULL) {
//
// Get current video resolution and text mode.
//
mBootHorizontalResolution = GraphicsOutput->Mode->Info->HorizontalResolution;
mBootVerticalResolution = GraphicsOutput->Mode->Info->VerticalResolution;
}
if (SimpleTextOut != NULL) {
Status = SimpleTextOut->QueryMode (
SimpleTextOut,
SimpleTextOut->Mode->Mode,
&BootTextColumn,
&BootTextRow
);
mBootTextModeColumn = (UINT32)BootTextColumn;
mBootTextModeRow = (UINT32)BootTextRow;
}
//
// Get user defined text mode for setup.
//
mSetupHorizontalResolution = PcdGet32 (PcdSetupVideoHorizontalResolution);
mSetupVerticalResolution = PcdGet32 (PcdSetupVideoVerticalResolution);
mSetupTextModeColumn = PcdGet32 (PcdSetupConOutColumn);
mSetupTextModeRow = PcdGet32 (PcdSetupConOutRow);
mModeInitialized = TRUE;
}
gBS->SetWatchdogTimer (0x0000, 0x0000, 0x0000, NULL);
gST->ConOut->ClearScreen (gST->ConOut);
//
// Install customized fonts needed by Front Page
//
HiiHandle = ExportFonts ();
ASSERT (HiiHandle != NULL);
InitializeStringSupport ();
BdsSetConsoleMode (TRUE);
UiEntry (FALSE);
BdsSetConsoleMode (FALSE);
UninitializeStringSupport ();
HiiRemovePackages (HiiHandle);
return EFI_SUCCESS;
}
示例6: GicV2DxeInitialize
/**
Initialize the state information for the CPU Architectural Protocol
@param ImageHandle of the loaded driver
@param SystemTable Pointer to the System Table
@retval EFI_SUCCESS Protocol registered
@retval EFI_OUT_OF_RESOURCES Cannot allocate protocol data structure
@retval EFI_DEVICE_ERROR Hardware problems
**/
EFI_STATUS
GicV2DxeInitialize (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
{
EFI_STATUS Status;
UINTN Index;
UINT32 RegOffset;
UINTN RegShift;
UINT32 CpuTarget;
// Make sure the Interrupt Controller Protocol is not already installed in the system.
ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL, &gHardwareInterruptProtocolGuid);
mGicInterruptInterfaceBase = PcdGet32 (PcdGicInterruptInterfaceBase);
mGicDistributorBase = PcdGet32 (PcdGicDistributorBase);
mGicNumInterrupts = ArmGicGetMaxNumInterrupts (mGicDistributorBase);
for (Index = 0; Index < mGicNumInterrupts; Index++) {
GicV2DisableInterruptSource (&gHardwareInterruptV2Protocol, Index);
// Set Priority
RegOffset = Index / 4;
RegShift = (Index % 4) * 8;
MmioAndThenOr32 (
mGicDistributorBase + ARM_GIC_ICDIPR + (4 * RegOffset),
~(0xff << RegShift),
ARM_GIC_DEFAULT_PRIORITY << RegShift
);
}
//
// Targets the interrupts to the Primary Cpu
//
// Only Primary CPU will run this code. We can identify our GIC CPU ID by reading
// the GIC Distributor Target register. The 8 first GICD_ITARGETSRn are banked to each
// connected CPU. These 8 registers hold the CPU targets fields for interrupts 0-31.
// More Info in the GIC Specification about "Interrupt Processor Targets Registers"
//
// Read the first Interrupt Processor Targets Register (that corresponds to the 4
// first SGIs)
CpuTarget = MmioRead32 (mGicDistributorBase + ARM_GIC_ICDIPTR);
// The CPU target is a bit field mapping each CPU to a GIC CPU Interface. This value
// is 0 when we run on a uniprocessor platform.
if (CpuTarget != 0) {
// The 8 first Interrupt Processor Targets Registers are read-only
for (Index = 8; Index < (mGicNumInterrupts / 4); Index++) {
MmioWrite32 (mGicDistributorBase + ARM_GIC_ICDIPTR + (Index * 4), CpuTarget);
}
}
// Set binary point reg to 0x7 (no preemption)
MmioWrite32 (mGicInterruptInterfaceBase + ARM_GIC_ICCBPR, 0x7);
// Set priority mask reg to 0xff to allow all priorities through
MmioWrite32 (mGicInterruptInterfaceBase + ARM_GIC_ICCPMR, 0xff);
// Enable gic cpu interface
ArmGicEnableInterruptInterface (mGicInterruptInterfaceBase);
// Enable gic distributor
ArmGicEnableDistributor (mGicDistributorBase);
Status = InstallAndRegisterInterruptService (
&gHardwareInterruptV2Protocol, GicV2IrqInterruptHandler, GicV2ExitBootServicesEvent);
return Status;
}
示例7: FtwNotificationEvent
/**
Fault Tolerant Write protocol notification event handler.
Non-Volatile variable write may needs FTW protocol to reclaim when
writting variable.
@param[in] Event Event whose notification function is being invoked.
@param[in] Context Pointer to the notification function's context.
**/
VOID
EFIAPI
FtwNotificationEvent (
IN EFI_EVENT Event,
IN VOID *Context
)
{
EFI_STATUS Status;
EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *FvbProtocol;
EFI_FAULT_TOLERANT_WRITE_PROTOCOL *FtwProtocol;
EFI_PHYSICAL_ADDRESS NvStorageVariableBase;
EFI_GCD_MEMORY_SPACE_DESCRIPTOR GcdDescriptor;
EFI_PHYSICAL_ADDRESS BaseAddress;
UINT64 Length;
EFI_PHYSICAL_ADDRESS VariableStoreBase;
UINT64 VariableStoreLength;
//
// Ensure FTW protocol is installed.
//
Status = GetFtwProtocol ((VOID**) &FtwProtocol);
if (EFI_ERROR (Status)) {
return ;
}
//
// Find the proper FVB protocol for variable.
//
NvStorageVariableBase = (EFI_PHYSICAL_ADDRESS) PcdGet64 (PcdFlashNvStorageVariableBase64);
if (NvStorageVariableBase == 0) {
NvStorageVariableBase = (EFI_PHYSICAL_ADDRESS) PcdGet32 (PcdFlashNvStorageVariableBase);
}
Status = GetFvbInfoByAddress (NvStorageVariableBase, NULL, &FvbProtocol);
if (EFI_ERROR (Status)) {
return ;
}
mVariableModuleGlobal->FvbInstance = FvbProtocol;
//
// Mark the variable storage region of the FLASH as RUNTIME.
//
VariableStoreBase = mVariableModuleGlobal->VariableGlobal.NonVolatileVariableBase;
VariableStoreLength = ((VARIABLE_STORE_HEADER *)(UINTN)VariableStoreBase)->Size;
BaseAddress = VariableStoreBase & (~EFI_PAGE_MASK);
Length = VariableStoreLength + (VariableStoreBase - BaseAddress);
Length = (Length + EFI_PAGE_SIZE - 1) & (~EFI_PAGE_MASK);
Status = gDS->GetMemorySpaceDescriptor (BaseAddress, &GcdDescriptor);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_WARN, "Variable driver failed to add EFI_MEMORY_RUNTIME attribute to Flash.\n"));
} else {
Status = gDS->SetMemorySpaceAttributes (
BaseAddress,
Length,
GcdDescriptor.Attributes | EFI_MEMORY_RUNTIME
);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_WARN, "Variable driver failed to add EFI_MEMORY_RUNTIME attribute to Flash.\n"));
}
}
Status = VariableWriteServiceInitialize ();
ASSERT_EFI_ERROR (Status);
//
// Install the Variable Write Architectural protocol.
//
Status = gBS->InstallProtocolInterface (
&mHandle,
&gEfiVariableWriteArchProtocolGuid,
EFI_NATIVE_INTERFACE,
NULL
);
ASSERT_EFI_ERROR (Status);
//
// Close the notify event to avoid install gEfiVariableWriteArchProtocolGuid again.
//
gBS->CloseEvent (Event);
}
示例8: MemoryDiscoveredPpiNotifyCallback
//.........这里部分代码省略.........
MtrrSetAllMtrrs (&MtrrSettings);
PERF_END (NULL, "SetCache", NULL, 0);
//
// Get necessary PPI
//
Status = PeiServicesLocatePpi (
&gEfiPeiReadOnlyVariable2PpiGuid, // GUID
0, // INSTANCE
NULL, // EFI_PEI_PPI_DESCRIPTOR
(VOID **)&VariableServices // PPI
);
ASSERT_EFI_ERROR (Status);
//
// Detect MOR request by the OS.
//
MorControl = 0;
DataSize = sizeof (MorControl);
Status = VariableServices->GetVariable (
VariableServices,
MEMORY_OVERWRITE_REQUEST_VARIABLE_NAME,
&gEfiMemoryOverwriteControlDataGuid,
NULL,
&DataSize,
&MorControl
);
//
// If OS requested a memory overwrite perform it now for Embedded SRAM
//
if (MOR_CLEAR_MEMORY_VALUE (MorControl)) {
DEBUG ((EFI_D_INFO, "Clear Embedded SRAM per MOR request.\n"));
if (PcdGet32 (PcdESramMemorySize) > 0) {
if (PcdGet32 (PcdEsramStage1Base) == 0) {
//
// ZeroMem() generates an ASSERT() if Buffer parameter is NULL.
// Clear byte at 0 and start clear operation at address 1.
//
*(UINT8 *)(0) = 0;
ZeroMem ((VOID *)1, (UINTN)PcdGet32 (PcdESramMemorySize) - 1);
} else {
ZeroMem (
(VOID *)(UINTN)PcdGet32 (PcdEsramStage1Base),
(UINTN)PcdGet32 (PcdESramMemorySize)
);
}
}
}
//
// Install PeiReset for PeiResetSystem service
//
Status = PeiServicesInstallPpi (&mPpiList[0]);
ASSERT_EFI_ERROR (Status);
//
// Do QNC initialization after MRC
//
PeiQNCPostMemInit ();
Status = PeiServicesInstallPpi (&mPpiStall[0]);
ASSERT_EFI_ERROR (Status);
//
// Set E000/F000 Routing
示例9: InitializeFvAndVariableStoreHeaders
/**
Initialises the FV Header and Variable Store Header
to support variable operations.
@param[in] Ptr - Location to initialise the headers
**/
EFI_STATUS
InitializeFvAndVariableStoreHeaders (
IN NOR_FLASH_INSTANCE *Instance
)
{
EFI_STATUS Status;
VOID* Headers;
UINTN HeadersLength;
EFI_FIRMWARE_VOLUME_HEADER *FirmwareVolumeHeader;
VARIABLE_STORE_HEADER *VariableStoreHeader;
if (!Instance->Initialized && Instance->Initialize) {
Instance->Initialize (Instance);
}
HeadersLength = sizeof(EFI_FIRMWARE_VOLUME_HEADER) + sizeof(EFI_FV_BLOCK_MAP_ENTRY) + sizeof(VARIABLE_STORE_HEADER);
Headers = AllocateZeroPool(HeadersLength);
// FirmwareVolumeHeader->FvLength is declared to have the Variable area AND the FTW working area AND the FTW Spare contiguous.
ASSERT(PcdGet32(PcdFlashNvStorageVariableBase) + PcdGet32(PcdFlashNvStorageVariableSize) == PcdGet32(PcdFlashNvStorageFtwWorkingBase));
ASSERT(PcdGet32(PcdFlashNvStorageFtwWorkingBase) + PcdGet32(PcdFlashNvStorageFtwWorkingSize) == PcdGet32(PcdFlashNvStorageFtwSpareBase));
// Check if the size of the area is at least one block size
ASSERT((PcdGet32(PcdFlashNvStorageVariableSize) > 0) && (PcdGet32(PcdFlashNvStorageVariableSize) / Instance->Media.BlockSize > 0));
ASSERT((PcdGet32(PcdFlashNvStorageFtwWorkingSize) > 0) && (PcdGet32(PcdFlashNvStorageFtwWorkingSize) / Instance->Media.BlockSize > 0));
ASSERT((PcdGet32(PcdFlashNvStorageFtwSpareSize) > 0) && (PcdGet32(PcdFlashNvStorageFtwSpareSize) / Instance->Media.BlockSize > 0));
// Ensure the Variable area Base Addresses are aligned on a block size boundaries
ASSERT(PcdGet32(PcdFlashNvStorageVariableBase) % Instance->Media.BlockSize == 0);
ASSERT(PcdGet32(PcdFlashNvStorageFtwWorkingBase) % Instance->Media.BlockSize == 0);
ASSERT(PcdGet32(PcdFlashNvStorageFtwSpareBase) % Instance->Media.BlockSize == 0);
//
// EFI_FIRMWARE_VOLUME_HEADER
//
FirmwareVolumeHeader = (EFI_FIRMWARE_VOLUME_HEADER*)Headers;
CopyGuid (&FirmwareVolumeHeader->FileSystemGuid, &gEfiSystemNvDataFvGuid);
FirmwareVolumeHeader->FvLength =
PcdGet32(PcdFlashNvStorageVariableSize) +
PcdGet32(PcdFlashNvStorageFtwWorkingSize) +
PcdGet32(PcdFlashNvStorageFtwSpareSize);
FirmwareVolumeHeader->Signature = EFI_FVH_SIGNATURE;
FirmwareVolumeHeader->Attributes = (EFI_FVB_ATTRIBUTES_2) (
EFI_FVB2_READ_ENABLED_CAP | // Reads may be enabled
EFI_FVB2_READ_STATUS | // Reads are currently enabled
EFI_FVB2_STICKY_WRITE | // A block erase is required to flip bits into EFI_FVB2_ERASE_POLARITY
EFI_FVB2_MEMORY_MAPPED | // It is memory mapped
EFI_FVB2_ERASE_POLARITY | // After erasure all bits take this value (i.e. '1')
EFI_FVB2_WRITE_STATUS | // Writes are currently enabled
EFI_FVB2_WRITE_ENABLED_CAP // Writes may be enabled
);
FirmwareVolumeHeader->HeaderLength = sizeof(EFI_FIRMWARE_VOLUME_HEADER) + sizeof(EFI_FV_BLOCK_MAP_ENTRY);
FirmwareVolumeHeader->Revision = EFI_FVH_REVISION;
FirmwareVolumeHeader->BlockMap[0].NumBlocks = Instance->Media.LastBlock + 1;
FirmwareVolumeHeader->BlockMap[0].Length = Instance->Media.BlockSize;
FirmwareVolumeHeader->BlockMap[1].NumBlocks = 0;
FirmwareVolumeHeader->BlockMap[1].Length = 0;
FirmwareVolumeHeader->Checksum = CalculateCheckSum16 ((UINT16*)FirmwareVolumeHeader,FirmwareVolumeHeader->HeaderLength);
//
// VARIABLE_STORE_HEADER
//
VariableStoreHeader = (VARIABLE_STORE_HEADER*)((UINTN)Headers + FirmwareVolumeHeader->HeaderLength);
CopyGuid (&VariableStoreHeader->Signature, &gEfiVariableGuid);
VariableStoreHeader->Size = PcdGet32(PcdFlashNvStorageVariableSize) - FirmwareVolumeHeader->HeaderLength;
VariableStoreHeader->Format = VARIABLE_STORE_FORMATTED;
VariableStoreHeader->State = VARIABLE_STORE_HEALTHY;
// Install the combined super-header in the NorFlash
Status = FvbWrite (&Instance->FvbProtocol, 0, 0, &HeadersLength, Headers);
FreePool (Headers);
return Status;
}
示例10: GetWorker
/**
Get the PCD entry pointer in PCD database.
This routine will visit PCD database to find the PCD entry according to given
token number. The given token number is autogened by build tools and it will be
translated to local token number. Local token number contains PCD's type and
offset of PCD entry in PCD database.
@param TokenNumber Token's number, it is autogened by build tools
@param GetSize The size of token's value
@return PCD entry pointer in PCD database
**/
VOID *
GetWorker (
IN UINTN TokenNumber,
IN UINTN GetSize
)
{
UINT32 Offset;
EFI_GUID *Guid;
UINT16 *Name;
VARIABLE_HEAD *VariableHead;
EFI_STATUS Status;
UINTN DataSize;
VOID *Data;
UINT8 *StringTable;
STRING_HEAD StringTableIdx;
PEI_PCD_DATABASE *PeiPcdDb;
UINT32 LocalTokenNumber;
UINT32 LocalTokenCount;
UINT8 *VaraiableDefaultBuffer;
//
// TokenNumber Zero is reserved as PCD_INVALID_TOKEN_NUMBER.
// We have to decrement TokenNumber by 1 to make it usable
// as the array index.
//
TokenNumber--;
PeiPcdDb = GetPcdDatabase ();
LocalTokenCount = PeiPcdDb->LocalTokenCount;
// EBC compiler is very choosy. It may report warning about comparison
// between UINTN and 0 . So we add 1 in each size of the
// comparison.
ASSERT (TokenNumber + 1 < (LocalTokenCount + 1));
ASSERT ((GetSize == PeiPcdGetSize(TokenNumber + 1)) || (GetSize == 0));
LocalTokenNumber = GetLocalTokenNumber (PeiPcdDb, TokenNumber + 1);
Offset = LocalTokenNumber & PCD_DATABASE_OFFSET_MASK;
StringTable = (UINT8 *)PeiPcdDb + PeiPcdDb->StringTableOffset;
switch (LocalTokenNumber & PCD_TYPE_ALL_SET) {
case PCD_TYPE_VPD:
{
VPD_HEAD *VpdHead;
VpdHead = (VPD_HEAD *) ((UINT8 *)PeiPcdDb + Offset);
return (VOID *) (UINTN) (PcdGet32 (PcdVpdBaseAddress) + VpdHead->Offset);
}
case PCD_TYPE_HII|PCD_TYPE_STRING:
case PCD_TYPE_HII:
{
VariableHead = (VARIABLE_HEAD *) ((UINT8 *)PeiPcdDb + Offset);
Guid = (EFI_GUID *) ((UINT8 *)PeiPcdDb + PeiPcdDb->GuidTableOffset) + VariableHead->GuidTableIndex;
Name = (UINT16*)&StringTable[VariableHead->StringIndex];
if ((LocalTokenNumber & PCD_TYPE_ALL_SET) == (PCD_TYPE_HII|PCD_TYPE_STRING)) {
//
// If a HII type PCD's datum type is VOID*, the DefaultValueOffset is the index of
// string array in string table.
//
VaraiableDefaultBuffer = (UINT8 *) &StringTable[*(STRING_HEAD*)((UINT8*) PeiPcdDb + VariableHead->DefaultValueOffset)];
} else {
VaraiableDefaultBuffer = (UINT8 *) PeiPcdDb + VariableHead->DefaultValueOffset;
}
Status = GetHiiVariable (Guid, Name, &Data, &DataSize);
if ((Status == EFI_SUCCESS) && (DataSize >= (VariableHead->Offset + GetSize))) {
if (GetSize == 0) {
//
// It is a pointer type. So get the MaxSize reserved for
// this PCD entry.
//
GetPtrTypeSize (TokenNumber, &GetSize, PeiPcdDb);
if (GetSize > (DataSize - VariableHead->Offset)) {
//
// Use actual valid size.
//
GetSize = DataSize - VariableHead->Offset;
}
}
//
// If the operation is successful, we copy the data
// to the default value buffer in the PCD Database.
//
//.........这里部分代码省略.........
示例11: MemoryDiscoveredPpiNotifyCallback
EFI_STATUS
EFIAPI
MemoryDiscoveredPpiNotifyCallback (
IN EFI_PEI_SERVICES **PeiServices,
IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor,
IN VOID *Ppi
)
{
EFI_STATUS Status;
EFI_BOOT_MODE BootMode;
UINT32 Pages;
VOID* Memory;
UINTN Size;
//
// Allocate LM memory and configure PDM if enabled by user.
// ConfigureLM(PeiServices);
//
Status = (*PeiServices)->GetBootMode (
(const EFI_PEI_SERVICES **)PeiServices,
&BootMode
);
if (BootMode != BOOT_ON_S3_RESUME) {
Size = (PcdGet32 (PcdFlashFvRecovery2Base) - PcdGet32 (PcdFlashFvMainBase)) + FixedPcdGet32(PcdFlashFvRecovery2Size);
Pages= Size/0x1000;
Memory = AllocatePages ( Pages );
CopyMem(Memory , (VOID *) FixedPcdGet32(PcdFlashFvMainBase) , Size);
//
// We don't verify just load
//
PeiServicesInstallFvInfoPpi (
NULL,
(VOID *) ((UINTN) Memory + (PcdGet32 (PcdFlashFvRecovery2Base) - PcdGet32 (PcdFlashFvMainBase))),
PcdGet32 (PcdFlashFvRecovery2Size),
NULL,
NULL
);
PeiServicesInstallFvInfoPpi (
NULL,
(VOID *) Memory,
PcdGet32 (PcdFlashFvMainSize),
NULL,
NULL
);
}
if (BootMode == BOOT_ON_S3_RESUME) {
PeiServicesInstallFvInfoPpi (
NULL,
(VOID *) (UINTN) (PcdGet32 (PcdFlashFvRecovery2Base)),
PcdGet32 (PcdFlashFvRecovery2Size),
NULL,
NULL
);
}
return EFI_SUCCESS;
}
示例12: PeiRegisterCallBackWorker
/**
The function registers the CallBackOnSet fucntion
according to TokenNumber and EFI_GUID space.
@param ExTokenNumber The token number.
@param Guid The GUID space.
@param CallBackFunction The Callback function to be registered.
@param Register To register or unregister the callback function.
@retval EFI_SUCCESS If the Callback function is registered.
@retval EFI_NOT_FOUND If the PCD Entry is not found according to Token Number and GUID space.
@retval EFI_OUT_OF_RESOURCES If the callback function can't be registered because there is not free
slot left in the CallbackFnTable.
@retval EFI_INVALID_PARAMETER If the callback function want to be de-registered can not be found.
**/
EFI_STATUS
PeiRegisterCallBackWorker (
IN UINTN ExTokenNumber,
IN CONST EFI_GUID *Guid, OPTIONAL
IN PCD_PPI_CALLBACK CallBackFunction,
IN BOOLEAN Register
)
{
EFI_HOB_GUID_TYPE *GuidHob;
PCD_PPI_CALLBACK *CallbackTable;
PCD_PPI_CALLBACK Compare;
PCD_PPI_CALLBACK Assign;
UINT32 LocalTokenNumber;
UINT32 LocalTokenCount;
UINTN PeiNexTokenNumber;
UINTN TokenNumber;
UINTN Idx;
PEI_PCD_DATABASE *PeiPcdDb;
PeiPcdDb = GetPcdDatabase();
LocalTokenCount = PeiPcdDb->LocalTokenCount;
PeiNexTokenNumber = PeiPcdDb->LocalTokenCount - PeiPcdDb->ExTokenCount;
if (Guid == NULL) {
TokenNumber = ExTokenNumber;
//
// TokenNumber Zero is reserved as PCD_INVALID_TOKEN_NUMBER.
// We have to decrement TokenNumber by 1 to make it usable
// as the array index.
//
TokenNumber--;
ASSERT (TokenNumber + 1 < (PeiNexTokenNumber + 1));
} else {
TokenNumber = GetExPcdTokenNumber (Guid, ExTokenNumber);
if (TokenNumber == PCD_INVALID_TOKEN_NUMBER) {
return EFI_NOT_FOUND;
}
//
// TokenNumber Zero is reserved as PCD_INVALID_TOKEN_NUMBER.
// We have to decrement TokenNumber by 1 to make it usable
// as the array index.
//
TokenNumber--;
// EBC compiler is very choosy. It may report warning about comparison
// between UINTN and 0 . So we add 1 in each size of the
// comparison.
ASSERT ((TokenNumber + 1) < (LocalTokenCount + 1));
}
LocalTokenNumber = *((UINT32 *)((UINT8 *)PeiPcdDb + PeiPcdDb->LocalTokenNumberTableOffset) + TokenNumber);
//
// We don't support SET for HII and VPD type PCD entry in PEI phase.
// So we will assert if any register callback for such PCD entry.
//
ASSERT ((LocalTokenNumber & PCD_TYPE_HII) == 0);
ASSERT ((LocalTokenNumber & PCD_TYPE_VPD) == 0);
GuidHob = GetFirstGuidHob (&gEfiCallerIdGuid);
ASSERT (GuidHob != NULL);
CallbackTable = GET_GUID_HOB_DATA (GuidHob);
CallbackTable = CallbackTable + (TokenNumber * PcdGet32 (PcdMaxPeiPcdCallBackNumberPerPcdEntry));
Compare = Register? NULL: CallBackFunction;
Assign = Register? CallBackFunction: NULL;
for (Idx = 0; Idx < PcdGet32 (PcdMaxPeiPcdCallBackNumberPerPcdEntry); Idx++) {
if (CallbackTable[Idx] == Compare) {
CallbackTable[Idx] = Assign;
return EFI_SUCCESS;
}
}
return Register? EFI_OUT_OF_RESOURCES : EFI_INVALID_PARAMETER;
}
示例13: CopySingleFile
/**
Function to Copy one file to another location
If the destination exists the user will be prompted and the result put into *resp
@param[in] Source pointer to source file name
@param[in] Dest pointer to destination file name
@param[out] Resp pointer to response from question. Pass back on looped calling
@param[in] SilentMode whether to run in quiet mode or not
@param[in] CmdName Source command name requesting single file copy
@retval SHELL_SUCCESS The source file was copied to the destination
**/
SHELL_STATUS
CopySingleFile(
IN CONST CHAR16 *Source,
IN CONST CHAR16 *Dest,
OUT VOID **Resp,
IN BOOLEAN SilentMode,
IN CONST CHAR16 *CmdName
)
{
VOID *Response;
UINTN ReadSize;
SHELL_FILE_HANDLE SourceHandle;
SHELL_FILE_HANDLE DestHandle;
EFI_STATUS Status;
VOID *Buffer;
CHAR16 *TempName;
UINTN Size;
EFI_SHELL_FILE_INFO *List;
SHELL_STATUS ShellStatus;
UINT64 SourceFileSize;
UINT64 DestFileSize;
EFI_FILE_PROTOCOL *DestVolumeFP;
EFI_FILE_SYSTEM_INFO *DestVolumeInfo;
UINTN DestVolumeInfoSize;
ASSERT(Resp != NULL);
SourceHandle = NULL;
DestHandle = NULL;
Response = *Resp;
List = NULL;
DestVolumeInfo = NULL;
ShellStatus = SHELL_SUCCESS;
ReadSize = PcdGet32(PcdShellFileOperationSize);
// Why bother copying a file to itself
if (StrCmp(Source, Dest) == 0) {
return (SHELL_SUCCESS);
}
//
// if the destination file existed check response and possibly prompt user
//
if (ShellFileExists(Dest) == EFI_SUCCESS) {
if (Response == NULL && !SilentMode) {
Status = ShellPromptForResponseHii(ShellPromptResponseTypeYesNoAllCancel, STRING_TOKEN (STR_GEN_DEST_EXIST_OVR), gShellLevel2HiiHandle, &Response);
}
//
// possibly return based on response
//
if (!SilentMode) {
switch (*(SHELL_PROMPT_RESPONSE*)Response) {
case ShellPromptResponseNo:
//
// return success here so we dont stop the process
//
return (SHELL_SUCCESS);
case ShellPromptResponseCancel:
*Resp = Response;
//
// indicate to stop everything
//
return (SHELL_ABORTED);
case ShellPromptResponseAll:
*Resp = Response;
case ShellPromptResponseYes:
break;
default:
return SHELL_ABORTED;
}
}
}
if (ShellIsDirectory(Source) == EFI_SUCCESS) {
Status = ShellCreateDirectory(Dest, &DestHandle);
if (EFI_ERROR(Status)) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_CP_DEST_DIR_FAIL), gShellLevel2HiiHandle, CmdName, Dest);
return (SHELL_ACCESS_DENIED);
}
//
// Now copy all the files under the directory...
//
TempName = NULL;
Size = 0;
StrnCatGrow(&TempName, &Size, Source, 0);
StrnCatGrow(&TempName, &Size, L"\\*", 0);
//.........这里部分代码省略.........
示例14: FirmwarePerformanceDxeEntryPoint
/**
The module Entry Point of the Firmware Performance Data Table DXE driver.
@param[in] ImageHandle The firmware allocated handle for the EFI image.
@param[in] SystemTable A pointer to the EFI System Table.
@retval EFI_SUCCESS The entry point is executed successfully.
@retval Other Some error occurs when executing this entry point.
**/
EFI_STATUS
EFIAPI
FirmwarePerformanceDxeEntryPoint (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
{
EFI_STATUS Status;
EFI_HOB_GUID_TYPE *GuidHob;
FIRMWARE_SEC_PERFORMANCE *Performance;
VOID *Registration;
UINT64 OemTableId;
CopyMem (
mFirmwarePerformanceTableTemplate.Header.OemId,
PcdGetPtr (PcdAcpiDefaultOemId),
sizeof (mFirmwarePerformanceTableTemplate.Header.OemId)
);
OemTableId = PcdGet64 (PcdAcpiDefaultOemTableId);
CopyMem (&mFirmwarePerformanceTableTemplate.Header.OemTableId, &OemTableId, sizeof (UINT64));
mFirmwarePerformanceTableTemplate.Header.OemRevision = PcdGet32 (PcdAcpiDefaultOemRevision);
mFirmwarePerformanceTableTemplate.Header.CreatorId = PcdGet32 (PcdAcpiDefaultCreatorId);
mFirmwarePerformanceTableTemplate.Header.CreatorRevision = PcdGet32 (PcdAcpiDefaultCreatorRevision);
//
// Get Report Status Code Handler Protocol.
//
Status = gBS->LocateProtocol (&gEfiRscHandlerProtocolGuid, NULL, (VOID **) &mRscHandlerProtocol);
ASSERT_EFI_ERROR (Status);
//
// Register report status code listener for OS Loader load and start.
//
Status = mRscHandlerProtocol->Register (FpdtStatusCodeListenerDxe, TPL_HIGH_LEVEL);
ASSERT_EFI_ERROR (Status);
//
// Register the notify function to update FPDT on ExitBootServices Event.
//
Status = gBS->CreateEventEx (
EVT_NOTIFY_SIGNAL,
TPL_NOTIFY,
FpdtExitBootServicesEventNotify,
NULL,
&gEfiEventExitBootServicesGuid,
&mExitBootServicesEvent
);
ASSERT_EFI_ERROR (Status);
//
// Create ready to boot event to install ACPI FPDT table.
//
Status = gBS->CreateEventEx (
EVT_NOTIFY_SIGNAL,
TPL_NOTIFY,
FpdtReadyToBootEventNotify,
NULL,
&gEfiEventReadyToBootGuid,
&mReadyToBootEvent
);
ASSERT_EFI_ERROR (Status);
//
// Retrieve GUID HOB data that contains the ResetEnd.
//
GuidHob = GetFirstGuidHob (&gEfiFirmwarePerformanceGuid);
if (GuidHob != NULL) {
Performance = (FIRMWARE_SEC_PERFORMANCE *) GET_GUID_HOB_DATA (GuidHob);
mBootPerformanceTableTemplate.BasicBoot.ResetEnd = Performance->ResetEnd;
} else {
//
// SEC Performance Data Hob not found, ResetEnd in ACPI FPDT table will be 0.
//
DEBUG ((EFI_D_ERROR, "FPDT: WARNING: SEC Performance Data Hob not found, ResetEnd will be set to 0!\n"));
}
if (FeaturePcdGet (PcdFirmwarePerformanceDataTableS3Support)) {
//
// Register callback function upon VariableArchProtocol and LockBoxProtocol
// to allocate S3 performance table memory and save the pointer to LockBox.
//
EfiCreateProtocolNotifyEvent (
&gEfiVariableArchProtocolGuid,
TPL_CALLBACK,
FpdtAllocateS3PerformanceTableMemory,
NULL,
&Registration
);
EfiCreateProtocolNotifyEvent (
&gEfiLockBoxProtocolGuid,
//.........这里部分代码省略.........
示例15: PeimInitializeWinNtFwh
EFI_STATUS
EFIAPI
PeimInitializeWinNtFwh (
IN EFI_FFS_FILE_HEADER *FfsHeader,
IN EFI_PEI_SERVICES **PeiServices
)
/*++
Routine Description:
Perform a call-back into the SEC simulator to get address of the Firmware Hub
Arguments:
FfsHeader - Ffs Header available to every PEIM
PeiServices - General purpose services available to every PEIM.
Returns:
None
--*/
{
EFI_STATUS Status;
EFI_PEI_PPI_DESCRIPTOR *PpiDescriptor;
NT_FWH_PPI *FwhPpi;
EFI_PHYSICAL_ADDRESS FdBase;
EFI_FIRMWARE_VOLUME_HEADER *FvHeader;
UINT64 FdSize;
UINTN Index;
DEBUG ((EFI_D_ERROR, "NT 32 Firmware Volume PEIM Loaded\n"));
//
// Get the Fwh Information PPI
//
Status = (**PeiServices).LocatePpi (
(const EFI_PEI_SERVICES **)PeiServices,
&gNtFwhPpiGuid, // GUID
0, // INSTANCE
&PpiDescriptor, // EFI_PEI_PPI_DESCRIPTOR
(VOID**)&FwhPpi // PPI
);
ASSERT_EFI_ERROR (Status);
Index = 0;
do {
//
// Get information about all the FD's in the system
//
Status = FwhPpi->NtFwh (Index, &FdBase, &FdSize);
if (!EFI_ERROR (Status)) {
//
// Assume the FD starts with an FV header
//
FvHeader = (EFI_FIRMWARE_VOLUME_HEADER *) (UINTN) FdBase;
//
// Make an FV Hob for the first FV in the FD
//
BuildFvHob (FdBase, FvHeader->FvLength);
if (Index == 0) {
//
// Assume the first FD was produced by the NT32.DSC
// All these strange offests are needed to keep in
// sync with the FlashMap and NT32.dsc file
//
BuildResourceDescriptorHob (
EFI_RESOURCE_FIRMWARE_DEVICE,
(EFI_RESOURCE_ATTRIBUTE_PRESENT | EFI_RESOURCE_ATTRIBUTE_INITIALIZED | EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE),
FdBase,
(
FvHeader->FvLength +
PcdGet32 (PcdFlashNvStorageVariableSize) +
PcdGet32 (PcdFlashNvStorageFtwWorkingSize) +
PcdGet32 (PcdFlashNvStorageFtwSpareSize) +
PcdGet32 (PcdWinNtFlashNvStorageEventLogSize)
)
);
//
// Hard code the address of the spare block and variable services.
// Assume it's a hard coded offset from FV0 in FD0.
//
FdSize =
PcdGet32 (PcdFlashNvStorageVariableSize) +
PcdGet32 (PcdFlashNvStorageFtwWorkingSize) +
PcdGet32 (PcdFlashNvStorageFtwSpareSize) +
PcdGet32 (PcdWinNtFlashNvStorageEventLogSize);
BuildFvHob (FdBase + PcdGet32 (PcdWinNtFlashNvStorageVariableBase), FdSize);
} else {
//
// For other FD's just map them in.
//
BuildResourceDescriptorHob (
EFI_RESOURCE_FIRMWARE_DEVICE,
(EFI_RESOURCE_ATTRIBUTE_PRESENT | EFI_RESOURCE_ATTRIBUTE_INITIALIZED | EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE),
FdBase,
FdSize
);
}
}
//.........这里部分代码省略.........