本文整理汇总了C++中EFI_SIZE_TO_PAGES函数的典型用法代码示例。如果您正苦于以下问题:C++ EFI_SIZE_TO_PAGES函数的具体用法?C++ EFI_SIZE_TO_PAGES怎么用?C++ EFI_SIZE_TO_PAGES使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了EFI_SIZE_TO_PAGES函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: UhciDestoryFrameList
/**
Destory FrameList buffer.
@param Uhc The UHCI device.
**/
VOID
UhciDestoryFrameList (
IN USB_HC_DEV *Uhc
)
{
//
// Unmap the common buffer for framelist entry,
// and free the common buffer.
// Uhci's frame list occupy 4k memory.
//
Uhc->PciIo->Unmap (Uhc->PciIo, Uhc->FrameMapping);
Uhc->PciIo->FreeBuffer (
Uhc->PciIo,
EFI_SIZE_TO_PAGES (4096),
(VOID *) Uhc->FrameBase
);
if (Uhc->FrameBaseHostAddr != NULL) {
FreePool (Uhc->FrameBaseHostAddr);
}
if (Uhc->SyncIntQh != NULL) {
UsbHcFreeMem (Uhc->MemPool, Uhc->SyncIntQh, sizeof (UHCI_QH_SW));
}
if (Uhc->CtrlQh != NULL) {
UsbHcFreeMem (Uhc->MemPool, Uhc->CtrlQh, sizeof (UHCI_QH_SW));
}
if (Uhc->BulkQh != NULL) {
UsbHcFreeMem (Uhc->MemPool, Uhc->BulkQh, sizeof (UHCI_QH_SW));
}
Uhc->FrameBase = NULL;
Uhc->FrameBaseHostAddr = NULL;
Uhc->SyncIntQh = NULL;
Uhc->CtrlQh = NULL;
Uhc->BulkQh = NULL;
}
开发者ID:SunnyKi,项目名称:bareBoot,代码行数:46,代码来源:UhciSched.c
示例2: AllocateResetVector
/**
Allocate reset vector buffer.
@param[in, out] CpuMpData The pointer to CPU MP Data structure.
**/
VOID
AllocateResetVector (
IN OUT CPU_MP_DATA *CpuMpData
)
{
EFI_STATUS Status;
UINTN ApResetVectorSize;
EFI_PHYSICAL_ADDRESS StartAddress;
if (CpuMpData->SaveRestoreFlag) {
BackupAndPrepareWakeupBuffer (CpuMpData);
} else {
ApResetVectorSize = CpuMpData->AddressMap.RendezvousFunnelSize +
sizeof (MP_CPU_EXCHANGE_INFO);
StartAddress = BASE_1MB;
Status = gBS->AllocatePages (
AllocateMaxAddress,
EfiACPIMemoryNVS,
EFI_SIZE_TO_PAGES (ApResetVectorSize),
&StartAddress
);
ASSERT_EFI_ERROR (Status);
CpuMpData->WakeupBuffer = (UINTN) StartAddress;
CpuMpData->MpCpuExchangeInfo = (MP_CPU_EXCHANGE_INFO *) (UINTN)
(CpuMpData->WakeupBuffer + CpuMpData->AddressMap.RendezvousFunnelSize);
//
// copy AP reset code in it
//
CopyMem (
(VOID *) CpuMpData->WakeupBuffer,
(VOID *) CpuMpData->AddressMap.RendezvousFunnelAddress,
CpuMpData->AddressMap.RendezvousFunnelSize
);
}
}
开发者ID:coolstar,项目名称:edk2,代码行数:42,代码来源:DxeMpLib.c
示例3: InitShadowStack
/**
Initialize the shadow stack related data structure.
@param CpuIndex The index of CPU.
@param ShadowStack The bottom of the shadow stack for this CPU.
**/
VOID
InitShadowStack (
IN UINTN CpuIndex,
IN VOID *ShadowStack
)
{
UINTN SmmShadowStackSize;
UINT64 *InterruptSspTable;
if ((PcdGet32 (PcdControlFlowEnforcementPropertyMask) != 0) && mCetSupported) {
SmmShadowStackSize = EFI_PAGES_TO_SIZE (EFI_SIZE_TO_PAGES (PcdGet32 (PcdCpuSmmShadowStackSize)));
if (FeaturePcdGet (PcdCpuSmmStackGuard)) {
SmmShadowStackSize += EFI_PAGES_TO_SIZE (2);
}
mCetPl0Ssp = (UINT32)((UINTN)ShadowStack + SmmShadowStackSize - sizeof(UINT64));
PatchInstructionX86 (mPatchCetPl0Ssp, mCetPl0Ssp, 4);
DEBUG ((DEBUG_INFO, "mCetPl0Ssp - 0x%x\n", mCetPl0Ssp));
DEBUG ((DEBUG_INFO, "ShadowStack - 0x%x\n", ShadowStack));
DEBUG ((DEBUG_INFO, " SmmShadowStackSize - 0x%x\n", SmmShadowStackSize));
if (FeaturePcdGet (PcdCpuSmmStackGuard)) {
if (mSmmInterruptSspTables == 0) {
mSmmInterruptSspTables = (UINTN)AllocateZeroPool(sizeof(UINT64) * 8 * gSmmCpuPrivate->SmmCoreEntryContext.NumberOfCpus);
ASSERT (mSmmInterruptSspTables != 0);
DEBUG ((DEBUG_INFO, "mSmmInterruptSspTables - 0x%x\n", mSmmInterruptSspTables));
}
mCetInterruptSsp = (UINT32)((UINTN)ShadowStack + EFI_PAGES_TO_SIZE(1) - sizeof(UINT64));
mCetInterruptSspTable = (UINT32)(UINTN)(mSmmInterruptSspTables + sizeof(UINT64) * 8 * CpuIndex);
InterruptSspTable = (UINT64 *)(UINTN)mCetInterruptSspTable;
InterruptSspTable[1] = mCetInterruptSsp;
PatchInstructionX86 (mPatchCetInterruptSsp, mCetInterruptSsp, 4);
PatchInstructionX86 (mPatchCetInterruptSspTable, mCetInterruptSspTable, 4);
DEBUG ((DEBUG_INFO, "mCetInterruptSsp - 0x%x\n", mCetInterruptSsp));
DEBUG ((DEBUG_INFO, "mCetInterruptSspTable - 0x%x\n", mCetInterruptSspTable));
}
}
}
开发者ID:shijunjing,项目名称:edk2,代码行数:43,代码来源:SmmFuncsArch.c
示例4: Table
/**
Perform CPU specific actions required to migrate the PEI Services Table
pointer from temporary RAM to permanent RAM.
For IA32 CPUs, the PEI Services Table pointer is stored in the 4 bytes
immediately preceding the Interrupt Descriptor Table (IDT) in memory.
For X64 CPUs, the PEI Services Table pointer is stored in the 8 bytes
immediately preceding the Interrupt Descriptor Table (IDT) in memory.
For Itanium and ARM CPUs, a the PEI Services Table Pointer is stored in
a dedicated CPU register. This means that there is no memory storage
associated with storing the PEI Services Table pointer, so no additional
migration actions are required for Itanium or ARM CPUs.
If The cached PEI Services Table pointer is NULL, then ASSERT().
If the permanent memory is allocated failed, then ASSERT().
**/
VOID
EFIAPI
MigratePeiServicesTablePointer (
VOID
)
{
EFI_STATUS Status;
IA32_DESCRIPTOR Idtr;
EFI_PHYSICAL_ADDRESS IdtBase;
CONST EFI_PEI_SERVICES **PeiServices;
//
// Get PEI Services Table pointer
//
AsmReadIdtr (&Idtr);
PeiServices = (CONST EFI_PEI_SERVICES **) (*(UINTN*)(Idtr.Base - sizeof (UINTN)));
ASSERT (PeiServices != NULL);
//
// Allocate the permanent memory.
//
Status = (*PeiServices)->AllocatePages (
PeiServices,
EfiBootServicesCode,
EFI_SIZE_TO_PAGES(Idtr.Limit + 1 + sizeof (UINTN)),
&IdtBase
);
ASSERT_EFI_ERROR (Status);
//
// Idt table needs to be migrated into memory.
//
CopyMem ((VOID *) (UINTN) IdtBase, (VOID *) (Idtr.Base - sizeof (UINTN)), Idtr.Limit + 1 + sizeof (UINTN));
Idtr.Base = (UINTN) IdtBase + sizeof (UINTN);
AsmWriteIdtr (&Idtr);
return;
}
开发者ID:hsienchieh,项目名称:uefilab,代码行数:52,代码来源:PeiServicesTablePointer.c
示例5: InitSmmProfileInternal
/**
Initialize SMM profile data structures.
**/
VOID
InitSmmProfileInternal (
VOID
)
{
EFI_STATUS Status;
EFI_PHYSICAL_ADDRESS Base;
VOID *Registration;
UINTN Index;
UINTN MsrDsAreaSizePerCpu;
UINTN TotalSize;
mPFEntryCount = (UINTN *)AllocateZeroPool (sizeof (UINTN) * mMaxNumberOfCpus);
ASSERT (mPFEntryCount != NULL);
mLastPFEntryValue = (UINT64 (*)[MAX_PF_ENTRY_COUNT])AllocateZeroPool (
sizeof (mLastPFEntryValue[0]) * mMaxNumberOfCpus);
ASSERT (mLastPFEntryValue != NULL);
mLastPFEntryPointer = (UINT64 *(*)[MAX_PF_ENTRY_COUNT])AllocateZeroPool (
sizeof (mLastPFEntryPointer[0]) * mMaxNumberOfCpus);
ASSERT (mLastPFEntryPointer != NULL);
//
// Allocate memory for SmmProfile below 4GB.
// The base address
//
mSmmProfileSize = PcdGet32 (PcdCpuSmmProfileSize);
ASSERT ((mSmmProfileSize & 0xFFF) == 0);
if (mBtsSupported) {
TotalSize = mSmmProfileSize + mMsrDsAreaSize;
} else {
TotalSize = mSmmProfileSize;
}
Base = 0xFFFFFFFF;
Status = gBS->AllocatePages (
AllocateMaxAddress,
EfiReservedMemoryType,
EFI_SIZE_TO_PAGES (TotalSize),
&Base
);
ASSERT_EFI_ERROR (Status);
ZeroMem ((VOID *)(UINTN)Base, TotalSize);
mSmmProfileBase = (SMM_PROFILE_HEADER *)(UINTN)Base;
//
// Initialize SMM profile data header.
//
mSmmProfileBase->HeaderSize = sizeof (SMM_PROFILE_HEADER);
mSmmProfileBase->MaxDataEntries = (UINT64)((mSmmProfileSize - sizeof(SMM_PROFILE_HEADER)) / sizeof (SMM_PROFILE_ENTRY));
mSmmProfileBase->MaxDataSize = MultU64x64 (mSmmProfileBase->MaxDataEntries, sizeof(SMM_PROFILE_ENTRY));
mSmmProfileBase->CurDataEntries = 0;
mSmmProfileBase->CurDataSize = 0;
mSmmProfileBase->TsegStart = mCpuHotPlugData.SmrrBase;
mSmmProfileBase->TsegSize = mCpuHotPlugData.SmrrSize;
mSmmProfileBase->NumSmis = 0;
mSmmProfileBase->NumCpus = gSmmCpuPrivate->SmmCoreEntryContext.NumberOfCpus;
if (mBtsSupported) {
mMsrDsArea = (MSR_DS_AREA_STRUCT **)AllocateZeroPool (sizeof (MSR_DS_AREA_STRUCT *) * mMaxNumberOfCpus);
ASSERT (mMsrDsArea != NULL);
mMsrBTSRecord = (BRANCH_TRACE_RECORD **)AllocateZeroPool (sizeof (BRANCH_TRACE_RECORD *) * mMaxNumberOfCpus);
ASSERT (mMsrBTSRecord != NULL);
mMsrPEBSRecord = (PEBS_RECORD **)AllocateZeroPool (sizeof (PEBS_RECORD *) * mMaxNumberOfCpus);
ASSERT (mMsrPEBSRecord != NULL);
mMsrDsAreaBase = (MSR_DS_AREA_STRUCT *)((UINTN)Base + mSmmProfileSize);
MsrDsAreaSizePerCpu = mMsrDsAreaSize / mMaxNumberOfCpus;
mBTSRecordNumber = (MsrDsAreaSizePerCpu - sizeof(PEBS_RECORD) * PEBS_RECORD_NUMBER - sizeof(MSR_DS_AREA_STRUCT)) / sizeof(BRANCH_TRACE_RECORD);
for (Index = 0; Index < mMaxNumberOfCpus; Index++) {
mMsrDsArea[Index] = (MSR_DS_AREA_STRUCT *)((UINTN)mMsrDsAreaBase + MsrDsAreaSizePerCpu * Index);
mMsrBTSRecord[Index] = (BRANCH_TRACE_RECORD *)((UINTN)mMsrDsArea[Index] + sizeof(MSR_DS_AREA_STRUCT));
mMsrPEBSRecord[Index] = (PEBS_RECORD *)((UINTN)mMsrDsArea[Index] + MsrDsAreaSizePerCpu - sizeof(PEBS_RECORD) * PEBS_RECORD_NUMBER);
mMsrDsArea[Index]->BTSBufferBase = (UINTN)mMsrBTSRecord[Index];
mMsrDsArea[Index]->BTSIndex = mMsrDsArea[Index]->BTSBufferBase;
mMsrDsArea[Index]->BTSAbsoluteMaximum = mMsrDsArea[Index]->BTSBufferBase + mBTSRecordNumber * sizeof(BRANCH_TRACE_RECORD) + 1;
mMsrDsArea[Index]->BTSInterruptThreshold = mMsrDsArea[Index]->BTSAbsoluteMaximum + 1;
mMsrDsArea[Index]->PEBSBufferBase = (UINTN)mMsrPEBSRecord[Index];
mMsrDsArea[Index]->PEBSIndex = mMsrDsArea[Index]->PEBSBufferBase;
mMsrDsArea[Index]->PEBSAbsoluteMaximum = mMsrDsArea[Index]->PEBSBufferBase + PEBS_RECORD_NUMBER * sizeof(PEBS_RECORD) + 1;
mMsrDsArea[Index]->PEBSInterruptThreshold = mMsrDsArea[Index]->PEBSAbsoluteMaximum + 1;
}
}
mProtectionMemRange = mProtectionMemRangeTemplate;
mProtectionMemRangeCount = sizeof (mProtectionMemRangeTemplate) / sizeof (MEMORY_PROTECTION_RANGE);
//
// Update TSeg entry.
//
mProtectionMemRange[0].Range.Base = mCpuHotPlugData.SmrrBase;
mProtectionMemRange[0].Range.Top = mCpuHotPlugData.SmrrBase + mCpuHotPlugData.SmrrSize;
//
//.........这里部分代码省略.........
开发者ID:pmj,项目名称:edk2,代码行数:101,代码来源:SmmProfile.c
示例6: FvbInitialize
/**
Main entry point.
@param[in] ImageHandle The firmware allocated handle for the EFI image.
@param[in] SystemTable A pointer to the EFI System Table.
@retval EFI_SUCCESS Successfully initialized.
**/
EFI_STATUS
EFIAPI
FvbInitialize (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
{
EFI_STATUS Status;
VOID *Ptr;
VOID *SubPtr;
BOOLEAN Initialize;
EFI_HANDLE Handle;
EFI_PHYSICAL_ADDRESS Address;
RETURN_STATUS PcdStatus;
DEBUG ((EFI_D_INFO, "EMU Variable FVB Started\n"));
//
// Verify that the PCD's are set correctly.
//
if (
(PcdGet32 (PcdVariableStoreSize) +
PcdGet32 (PcdFlashNvStorageFtwWorkingSize)
) >
EMU_FVB_BLOCK_SIZE
) {
DEBUG ((EFI_D_ERROR, "EMU Variable invalid PCD sizes\n"));
return EFI_INVALID_PARAMETER;
}
if (PcdGet64 (PcdFlashNvStorageVariableBase64) != 0) {
DEBUG ((EFI_D_INFO, "Disabling EMU Variable FVB since "
"flash variables appear to be supported.\n"));
return EFI_ABORTED;
}
//
// By default we will initialize the FV contents. But, if
// PcdEmuVariableNvStoreReserved is non-zero, then we will
// use this location for our buffer.
//
// If this location does not have a proper FV header, then
// we will initialize it.
//
Initialize = TRUE;
if (PcdGet64 (PcdEmuVariableNvStoreReserved) != 0) {
Ptr = (VOID*)(UINTN) PcdGet64 (PcdEmuVariableNvStoreReserved);
DEBUG ((
EFI_D_INFO,
"EMU Variable FVB: Using pre-reserved block at %p\n",
Ptr
));
Status = ValidateFvHeader (Ptr);
if (!EFI_ERROR (Status)) {
DEBUG ((EFI_D_INFO, "EMU Variable FVB: Found valid pre-existing FV\n"));
Initialize = FALSE;
}
} else {
Ptr = AllocateAlignedRuntimePages (
EFI_SIZE_TO_PAGES (EMU_FVB_SIZE),
SIZE_64KB
);
}
mEmuVarsFvb.BufferPtr = Ptr;
//
// Initialize the main FV header and variable store header
//
if (Initialize) {
SetMem (Ptr, EMU_FVB_SIZE, ERASED_UINT8);
InitializeFvAndVariableStoreHeaders (Ptr);
}
PcdStatus = PcdSet64S (PcdFlashNvStorageVariableBase64, (UINT32)(UINTN) Ptr);
ASSERT_RETURN_ERROR (PcdStatus);
//
// Initialize the Fault Tolerant Write data area
//
SubPtr = (VOID*) ((UINT8*) Ptr + PcdGet32 (PcdVariableStoreSize));
PcdStatus = PcdSet32S (PcdFlashNvStorageFtwWorkingBase,
(UINT32)(UINTN) SubPtr);
ASSERT_RETURN_ERROR (PcdStatus);
//
// Initialize the Fault Tolerant Write spare block
//
SubPtr = (VOID*) ((UINT8*) Ptr + EMU_FVB_BLOCK_SIZE);
PcdStatus = PcdSet32S (PcdFlashNvStorageFtwSpareBase,
(UINT32)(UINTN) SubPtr);
ASSERT_RETURN_ERROR (PcdStatus);
//.........这里部分代码省略.........
开发者ID:EvanLloyd,项目名称:tianocore,代码行数:101,代码来源:Fvb.c
示例7: Decompress
/**
Decompresses a section to the output buffer.
This function looks up the compression type field in the input section and
applies the appropriate compression algorithm to compress the section to a
callee allocated buffer.
@param This Points to this instance of the
EFI_PEI_DECOMPRESS_PEI PPI.
@param CompressionSection Points to the compressed section.
@param OutputBuffer Holds the returned pointer to the decompressed
sections.
@param OutputSize Holds the returned size of the decompress
section streams.
@retval EFI_SUCCESS The section was decompressed successfully.
OutputBuffer contains the resulting data and
OutputSize contains the resulting size.
**/
EFI_STATUS
EFIAPI
Decompress (
IN CONST EFI_PEI_DECOMPRESS_PPI *This,
IN CONST EFI_COMPRESSION_SECTION *CompressionSection,
OUT VOID **OutputBuffer,
OUT UINTN *OutputSize
)
{
EFI_STATUS Status;
UINT8 *DstBuffer;
UINT8 *ScratchBuffer;
UINT32 DstBufferSize;
UINT32 ScratchBufferSize;
VOID *CompressionSource;
UINT32 CompressionSourceSize;
UINT32 UncompressedLength;
UINT8 CompressionType;
if (CompressionSection->CommonHeader.Type != EFI_SECTION_COMPRESSION) {
ASSERT (FALSE);
return EFI_INVALID_PARAMETER;
}
if (IS_SECTION2 (CompressionSection)) {
CompressionSource = (VOID *) ((UINT8 *) CompressionSection + sizeof (EFI_COMPRESSION_SECTION2));
CompressionSourceSize = (UINT32) (SECTION2_SIZE (CompressionSection) - sizeof (EFI_COMPRESSION_SECTION2));
UncompressedLength = ((EFI_COMPRESSION_SECTION2 *) CompressionSection)->UncompressedLength;
CompressionType = ((EFI_COMPRESSION_SECTION2 *) CompressionSection)->CompressionType;
} else {
CompressionSource = (VOID *) ((UINT8 *) CompressionSection + sizeof (EFI_COMPRESSION_SECTION));
CompressionSourceSize = (UINT32) (SECTION_SIZE (CompressionSection) - sizeof (EFI_COMPRESSION_SECTION));
UncompressedLength = CompressionSection->UncompressedLength;
CompressionType = CompressionSection->CompressionType;
}
//
// This is a compression set, expand it
//
switch (CompressionType) {
case EFI_STANDARD_COMPRESSION:
if (FeaturePcdGet(PcdDxeIplSupportUefiDecompress)) {
//
// Load EFI standard compression.
// For compressed data, decompress them to destination buffer.
//
Status = UefiDecompressGetInfo (
CompressionSource,
CompressionSourceSize,
&DstBufferSize,
&ScratchBufferSize
);
if (EFI_ERROR (Status)) {
//
// GetInfo failed
//
DEBUG ((DEBUG_ERROR, "Decompress GetInfo Failed - %r\n", Status));
return EFI_NOT_FOUND;
}
//
// Allocate scratch buffer
//
ScratchBuffer = AllocatePages (EFI_SIZE_TO_PAGES (ScratchBufferSize));
if (ScratchBuffer == NULL) {
return EFI_OUT_OF_RESOURCES;
}
//
// Allocate destination buffer, extra one page for adjustment
//
DstBuffer = AllocatePages (EFI_SIZE_TO_PAGES (DstBufferSize) + 1);
if (DstBuffer == NULL) {
return EFI_OUT_OF_RESOURCES;
}
//
// DstBuffer still is one section. Adjust DstBuffer offset, skip EFI section header
// to make section data at page alignment.
//
DstBuffer = DstBuffer + EFI_PAGE_SIZE - sizeof (EFI_COMMON_SECTION_HEADER);
//
// Call decompress function
//.........这里部分代码省略.........
开发者ID:M1cha,项目名称:edk2,代码行数:101,代码来源:DxeLoad.c
示例8: ExtractSection
/**
The ExtractSection() function processes the input section and
returns a pointer to the section contents. If the section being
extracted does not require processing (if the section
GuidedSectionHeader.Attributes has the
EFI_GUIDED_SECTION_PROCESSING_REQUIRED field cleared), then
OutputBuffer is just updated to point to the start of the
section's contents. Otherwise, *Buffer must be allocated
from PEI permanent memory.
@param This Indicates the
EFI_PEI_GUIDED_SECTION_EXTRACTION_PPI instance.
Buffer containing the input GUIDed section to be
processed. OutputBuffer OutputBuffer is
allocated from PEI permanent memory and contains
the new section stream.
@param InputSection A pointer to the input buffer, which contains
the input section to be processed.
@param OutputBuffer A pointer to a caller-allocated buffer, whose
size is specified by the contents of OutputSize.
@param OutputSize A pointer to a caller-allocated
UINTN in which the size of *OutputBuffer
allocation is stored. If the function
returns anything other than EFI_SUCCESS,
the value of OutputSize is undefined.
@param AuthenticationStatus A pointer to a caller-allocated
UINT32 that indicates the
authentication status of the
output buffer. If the input
section's GuidedSectionHeader.
Attributes field has the
EFI_GUIDED_SECTION_AUTH_STATUS_VALID
bit as clear,
AuthenticationStatus must return
zero. These bits reflect the
status of the extraction
operation. If the function
returns anything other than
EFI_SUCCESS, the value of
AuthenticationStatus is
undefined.
@retval EFI_SUCCESS The InputSection was
successfully processed and the
section contents were returned.
@retval EFI_OUT_OF_RESOURCES The system has insufficient
resources to process the request.
@retval EFI_INVALID_PARAMETER The GUID in InputSection does
not match this instance of the
GUIDed Section Extraction PPI.
**/
EFI_STATUS
EFIAPI
CustomGuidedSectionExtract (
IN CONST EFI_PEI_GUIDED_SECTION_EXTRACTION_PPI *This,
IN CONST VOID *InputSection,
OUT VOID **OutputBuffer,
OUT UINTN *OutputSize,
OUT UINT32 *AuthenticationStatus
)
{
EFI_STATUS Status;
UINT8 *ScratchBuffer;
UINT32 ScratchBufferSize;
UINT32 OutputBufferSize;
UINT16 SectionAttribute;
//
// Init local variable
//
ScratchBuffer = NULL;
//
// Call GetInfo to get the size and attribute of input guided section data.
//
Status = ExtractGuidedSectionGetInfo (
InputSection,
&OutputBufferSize,
&ScratchBufferSize,
&SectionAttribute
);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "GetInfo from guided section Failed - %r\n", Status));
return Status;
}
if (ScratchBufferSize != 0) {
//
// Allocate scratch buffer
//
ScratchBuffer = AllocatePages (EFI_SIZE_TO_PAGES (ScratchBufferSize));
if (ScratchBuffer == NULL) {
return EFI_OUT_OF_RESOURCES;
}
}
//.........这里部分代码省略.........
开发者ID:M1cha,项目名称:edk2,代码行数:101,代码来源:DxeLoad.c
示例9: efi_main
void
efi_main(EFI_HANDLE image_handle, EFI_SYSTEM_TABLE *system_table)
{
static EFI_GUID image_protocol = LOADED_IMAGE_PROTOCOL;
EFI_LOADED_IMAGE *img;
CHAR16 *argp, *args, **argv;
EFI_STATUS status;
int argc, addprog;
IH = image_handle;
ST = system_table;
BS = ST->BootServices;
RS = ST->RuntimeServices;
heapsize = 512*1024;
status = BS->AllocatePages(AllocateAnyPages, EfiLoaderData,
EFI_SIZE_TO_PAGES(heapsize), &heap);
if (status != EFI_SUCCESS)
BS->Exit(IH, status, 0, NULL);
setheap((void *)heap, (void *)(heap + heapsize));
/* Use exit() from here on... */
status = BS->HandleProtocol(IH, &image_protocol, (VOID**)&img);
if (status != EFI_SUCCESS)
exit(status);
/*
* Pre-process the (optional) load options. If the option string
* is given as an ASCII string, we use a poor man's ASCII to
* Unicode-16 translation. The size of the option string as given
* to us includes the terminating null character. We assume the
* string is an ASCII string if strlen() plus the terminating
* '\0' is less than LoadOptionsSize. Even if all Unicode-16
* characters have the upper 8 bits non-zero, the terminating
* null character will cause a one-off.
* If the string is already in Unicode-16, we make a copy so that
* we know we can always modify the string.
*/
if (img->LoadOptionsSize > 0 && img->LoadOptions != NULL) {
if (img->LoadOptionsSize == strlen(img->LoadOptions) + 1) {
args = malloc(img->LoadOptionsSize << 1);
for (argc = 0; argc < img->LoadOptionsSize; argc++)
args[argc] = ((char*)img->LoadOptions)[argc];
} else {
args = malloc(img->LoadOptionsSize);
memcpy(args, img->LoadOptions, img->LoadOptionsSize);
}
} else
args = NULL;
/*
* Use a quick and dirty algorithm to build the argv vector. We
* first count the number of words. Then, after allocating the
* vector, we split the string up. We don't deal with quotes or
* other more advanced shell features.
* The EFI shell will pas the name of the image as the first
* word in the argument list. This does not happen if we're
* loaded by the boot manager. This is not so easy to figure
* out though. The ParentHandle is not always NULL, because
* there can be a function (=image) that will perform the task
* for the boot manager.
*/
/* Part 1: Figure out if we need to add our program name. */
addprog = (args == NULL || img->ParentHandle == NULL ||
img->FilePath == NULL) ? 1 : 0;
if (!addprog) {
addprog =
(DevicePathType(img->FilePath) != MEDIA_DEVICE_PATH ||
DevicePathSubType(img->FilePath) != MEDIA_FILEPATH_DP ||
DevicePathNodeLength(img->FilePath) <=
sizeof(FILEPATH_DEVICE_PATH)) ? 1 : 0;
if (!addprog) {
/* XXX todo. */
}
}
/* Part 2: count words. */
argc = (addprog) ? 1 : 0;
argp = args;
while (argp != NULL && *argp != 0) {
argp = arg_skipsep(argp);
if (*argp == 0)
break;
argc++;
argp = arg_skipword(argp);
}
/* Part 3: build vector. */
argv = malloc((argc + 1) * sizeof(CHAR16*));
argc = 0;
if (addprog)
argv[argc++] = L"loader.efi";
argp = args;
while (argp != NULL && *argp != 0) {
argp = arg_skipsep(argp);
if (*argp == 0)
break;
argv[argc++] = argp;
argp = arg_skipword(argp);
/* Terminate the words. */
//.........这里部分代码省略.........
开发者ID:AhmadTux,项目名称:DragonFlyBSD,代码行数:101,代码来源:libefi.c
示例10: ldr_bootinfo
int
ldr_bootinfo(struct bootinfo *bi, uint64_t *bi_addr)
{
VOID *fpswa;
EFI_MEMORY_DESCRIPTOR *mm;
EFI_PHYSICAL_ADDRESS addr;
EFI_HANDLE handle;
EFI_STATUS status;
size_t bisz;
UINTN mmsz, pages, sz;
UINT32 mmver;
bi->bi_systab = (uint64_t)ST;
bi->bi_hcdp = (uint64_t)efi_get_table(&hcdp_guid);
sz = sizeof(EFI_HANDLE);
status = BS->LocateHandle(ByProtocol, &fpswa_guid, 0, &sz, &handle);
if (status == 0)
status = BS->HandleProtocol(handle, &fpswa_guid, &fpswa);
bi->bi_fpswa = (status == 0) ? (uint64_t)fpswa : 0;
bisz = (sizeof(struct bootinfo) + 0x0f) & ~0x0f;
/*
* Allocate enough pages to hold the bootinfo block and the memory
* map EFI will return to us. The memory map has an unknown size,
* so we have to determine that first. Note that the AllocatePages
* call can itself modify the memory map, so we have to take that
* into account as well. The changes to the memory map are caused
* by splitting a range of free memory into two (AFAICT), so that
* one is marked as being loader data.
*/
sz = 0;
BS->GetMemoryMap(&sz, NULL, &mapkey, &mmsz, &mmver);
sz += mmsz;
sz = (sz + 15) & ~15;
pages = EFI_SIZE_TO_PAGES(sz + bisz);
status = BS->AllocatePages(AllocateAnyPages, EfiLoaderData, pages,
&addr);
if (EFI_ERROR(status)) {
printf("%s: AllocatePages() returned 0x%lx\n", __func__,
(long)status);
return (ENOMEM);
}
/*
* Read the memory map and stash it after bootinfo. Align the
* memory map on a 16-byte boundary (the bootinfo block is page
* aligned).
*/
*bi_addr = addr;
mm = (void *)(addr + bisz);
sz = (EFI_PAGE_SIZE * pages) - bisz;
status = BS->GetMemoryMap(&sz, mm, &mapkey, &mmsz, &mmver);
if (EFI_ERROR(status)) {
printf("%s: GetMemoryMap() returned 0x%lx\n", __func__,
(long)status);
return (EINVAL);
}
bi->bi_memmap = (uint64_t)mm;
bi->bi_memmap_size = sz;
bi->bi_memdesc_size = mmsz;
bi->bi_memdesc_version = mmver;
bcopy(bi, (void *)(*bi_addr), sizeof(*bi));
return (0);
}
开发者ID:dcui,项目名称:FreeBSD-9.3_kernel,代码行数:67,代码来源:efimd.c
示例11: UncachedInternalAllocateAlignedPages
VOID *
UncachedInternalAllocateAlignedPages (
IN EFI_MEMORY_TYPE MemoryType,
IN UINTN Pages,
IN UINTN Alignment
)
{
EFI_STATUS Status;
EFI_PHYSICAL_ADDRESS Memory;
EFI_PHYSICAL_ADDRESS AlignedMemory;
UINTN AlignmentMask;
UINTN UnalignedPages;
UINTN RealPages;
EFI_GCD_MEMORY_SPACE_DESCRIPTOR Descriptor;
//
// Alignment must be a power of two or zero.
//
ASSERT ((Alignment & (Alignment - 1)) == 0);
if (Pages == 0) {
return NULL;
}
if (Alignment > EFI_PAGE_SIZE) {
//
// Caculate the total number of pages since alignment is larger than page size.
//
AlignmentMask = Alignment - 1;
RealPages = Pages + EFI_SIZE_TO_PAGES (Alignment);
//
// Make sure that Pages plus EFI_SIZE_TO_PAGES (Alignment) does not overflow.
//
ASSERT (RealPages > Pages);
Status = gBS->AllocatePages (AllocateAnyPages, MemoryType, RealPages, &Memory);
if (EFI_ERROR (Status)) {
return NULL;
}
AlignedMemory = ((UINTN) Memory + AlignmentMask) & ~AlignmentMask;
UnalignedPages = EFI_SIZE_TO_PAGES (AlignedMemory - (UINTN) Memory);
if (UnalignedPages > 0) {
//
// Free first unaligned page(s).
//
Status = gBS->FreePages (Memory, UnalignedPages);
ASSERT_EFI_ERROR (Status);
}
Memory = (EFI_PHYSICAL_ADDRESS) (AlignedMemory + EFI_PAGES_TO_SIZE (Pages));
UnalignedPages = RealPages - Pages - UnalignedPages;
if (UnalignedPages > 0) {
//
// Free last unaligned page(s).
//
Status = gBS->FreePages (Memory, UnalignedPages);
ASSERT_EFI_ERROR (Status);
}
} else {
//
// Do not over-allocate pages in this case.
//
Status = gBS->AllocatePages (AllocateAnyPages, MemoryType, Pages, &Memory);
if (EFI_ERROR (Status)) {
return NULL;
}
AlignedMemory = (UINTN) Memory;
}
Status = gDS->GetMemorySpaceDescriptor (Memory, &Descriptor);
if (!EFI_ERROR (Status)) {
// We are making an assumption that all of memory has the same default attributes
gAttributes = Descriptor.Attributes;
}
Status = gDS->SetMemorySpaceAttributes (Memory, EFI_PAGES_TO_SIZE (Pages), EFI_MEMORY_WC);
ASSERT_EFI_ERROR (Status);
return (VOID *)(UINTN)Memory;
}
开发者ID:B-Rich,项目名称:edk2,代码行数:78,代码来源:UncachedMemoryAllocationLib.c
示例12: ArmPlatformGetVirtualMemoryMap
/**
Return the Virtual Memory Map of your platform
This Virtual Memory Map is used by MemoryInitPei Module to initialize the MMU on your platform.
@param[out] VirtualMemoryMap Array of ARM_MEMORY_REGION_DESCRIPTOR describing a Physical-to-
Virtual Memory mapping. This array must be ended by a zero-filled
entry
**/
VOID
ArmPlatformGetVirtualMemoryMap (
IN ARM_MEMORY_REGION_DESCRIPTOR** VirtualMemoryMap
)
{
ARM_MEMORY_REGION_ATTRIBUTES CacheAttributes;
//EFI_RESOURCE_ATTRIBUTE_TYPE ResourceAttributes;
UINTN Index;
ARM_MEMORY_REGION_DESCRIPTOR *VirtualMemoryTable;
//UINT32 SysId;
//BOOLEAN HasSparseMemory;
//EFI_VIRTUAL_ADDRESS SparseMemoryBase;
//UINT64 SparseMemorySize;
EFI_PEI_HOB_POINTERS NextHob;
ASSERT (VirtualMemoryMap != NULL);
VirtualMemoryTable = (ARM_MEMORY_REGION_DESCRIPTOR*)AllocatePages(EFI_SIZE_TO_PAGES (sizeof(ARM_MEMORY_REGION_DESCRIPTOR) * MAX_VIRTUAL_MEMORY_MAP_DESCRIPTORS));
if (VirtualMemoryTable == NULL) {
return;
}
if (FeaturePcdGet(PcdCacheEnable) == TRUE) {
CacheAttributes = DDR_ATTRIBUTES_CACHED;
} else {
CacheAttributes = DDR_ATTRIBUTES_UNCACHED;
}
/*
// ReMap (Either NOR Flash or DRAM)
VirtualMemoryTable[Index].PhysicalBase = ARM_VE_REMAP_BASE;
VirtualMemoryTable[Index].VirtualBase = ARM_VE_REMAP_BASE;
VirtualMemoryTable[Index].Length = ARM_VE_REMAP_SZ;
if (FeaturePcdGet(PcdNorFlashRemapping) == FALSE) {
// Map the NOR Flash as Secure Memory
if (FeaturePcdGet(PcdCacheEnable) == TRUE) {
VirtualMemoryTable[Index].Attributes = DDR_ATTRIBUTES_CACHED;
} else {
VirtualMemoryTable[Index].Attributes = DDR_ATTRIBUTES_UNCACHED;
}
} else {
// DRAM mapping
VirtualMemoryTable[Index].Attributes = CacheAttributes;
}
*/
Index = OemSetVirtualMapDesc(VirtualMemoryTable, CacheAttributes);
// Search for System Memory Hob that contains the EFI resource system memory s00296804
NextHob.Raw = GetHobList ();
while ((NextHob.Raw = GetNextHob (EFI_HOB_TYPE_RESOURCE_DESCRIPTOR, NextHob.Raw)) != NULL)
{
if (NextHob.ResourceDescriptor->ResourceType == EFI_RESOURCE_SYSTEM_MEMORY)
{
if (NextHob.ResourceDescriptor->PhysicalStart > BASE_4GB)//只修改4G以上的属性
{
VirtualMemoryTable[++Index].PhysicalBase = NextHob.ResourceDescriptor->PhysicalStart;
VirtualMemoryTable[Index].VirtualBase = NextHob.ResourceDescriptor->PhysicalStart;
VirtualMemoryTable[Index].Length =NextHob.ResourceDescriptor->ResourceLength;
VirtualMemoryTable[Index].Attributes = CacheAttributes;
}
}
NextHob.Raw = GET_NEXT_HOB (NextHob);
}
// End of Table
VirtualMemoryTable[++Index].PhysicalBase = 0;
VirtualMemoryTable[Index].VirtualBase = 0;
VirtualMemoryTable[Index].Length = 0;
VirtualMemoryTable[Index].Attributes = (ARM_MEMORY_REGION_ATTRIBUTES)0;
ASSERT((Index + 1) <= MAX_VIRTUAL_MEMORY_MAP_DESCRIPTORS);
DEBUG((EFI_D_ERROR, "[%a]:[%dL] discriptor count=%d\n", __FUNCTION__, __LINE__, Index+1));
*VirtualMemoryMap = VirtualMemoryTable;
}
开发者ID:hzhuang1,项目名称:uefi,代码行数:87,代码来源:ArmPlatformLibMem.c
示例13: object
/**
Process a QEMU_LOADER_ALLOCATE command.
@param[in] Allocate The QEMU_LOADER_ALLOCATE command to process.
@param[in,out] Tracker The ORDERED_COLLECTION tracking the BLOB user
structures created thus far.
@retval EFI_SUCCESS An area of whole AcpiNVS pages has been
allocated for the blob contents, and the
contents have been saved. A BLOB object (user
structure) has been allocated from pool memory,
referencing the blob contents. The BLOB user
structure has been linked into Tracker.
@retval EFI_PROTOCOL_ERROR Malformed fw_cfg file name has been found in
Allocate, or the Allocate command references a
file that is already known by Tracker.
@retval EFI_UNSUPPORTED Unsupported alignment request has been found in
Allocate.
@retval EFI_OUT_OF_RESOURCES Pool allocation failed.
@return Error codes from QemuFwCfgFindFile() and
gBS->AllocatePages().
**/
STATIC
EFI_STATUS
EFIAPI
ProcessCmdAllocate (
IN CONST QEMU_LOADER_ALLOCATE *Allocate,
IN OUT ORDERED_COLLECTION *Tracker
)
{
FIRMWARE_CONFIG_ITEM FwCfgItem;
UINTN FwCfgSize;
EFI_STATUS Status;
UINTN NumPages;
EFI_PHYSICAL_ADDRESS Address;
BLOB *Blob;
if (Allocate->File[QEMU_LOADER_FNAME_SIZE - 1] != '\0') {
DEBUG ((EFI_D_ERROR, "%a: malformed file name\n", __FUNCTION__));
return EFI_PROTOCOL_ERROR;
}
if (Allocate->Alignment > EFI_PAGE_SIZE) {
DEBUG ((EFI_D_ERROR, "%a: unsupported alignment 0x%x\n", __FUNCTION__,
Allocate->Alignment));
return EFI_UNSUPPORTED;
}
Status = QemuFwCfgFindFile ((CHAR8 *)Allocate->File, &FwCfgItem, &FwCfgSize);
if (EFI_ERROR (Status)) {
DEBUG ((EFI_D_ERROR, "%a: QemuFwCfgFindFile(\"%a\"): %r\n", __FUNCTION__,
Allocate->File, Status));
return Status;
}
NumPages = EFI_SIZE_TO_PAGES (FwCfgSize);
Address = 0xFFFFFFFF;
Status = gBS->AllocatePages (AllocateMaxAddress, EfiACPIMemoryNVS, NumPages,
&Address);
if (EFI_ERROR (Status)) {
return Status;
}
Blob = AllocatePool (sizeof *Blob);
if (Blob == NULL) {
Status = EFI_OUT_OF_RESOURCES;
goto FreePages;
}
CopyMem (Blob->File, Allocate->File, QEMU_LOADER_FNAME_SIZE);
Blob->Size = FwCfgSize;
Blob->Base = (VOID *)(UINTN)Address;
Blob->HostsOnlyTableData = TRUE;
Status = OrderedCollectionInsert (Tracker, NULL, Blob);
if (Status == RETURN_ALREADY_STARTED) {
DEBUG ((EFI_D_ERROR, "%a: duplicated file \"%a\"\n", __FUNCTION__,
Allocate->File));
Status = EFI_PROTOCOL_ERROR;
}
if (EFI_ERROR (Status)) {
goto FreeBlob;
}
QemuFwCfgSelectItem (FwCfgItem);
QemuFwCfgReadBytes (FwCfgSize, Blob->Base);
ZeroMem (Blob->Base + Blob->Size, EFI_PAGES_TO_SIZE (NumPages) - Blob->Size);
DEBUG ((EFI_D_VERBOSE, "%a: File=\"%a\" Alignment=0x%x Zone=%d Size=0x%Lx "
"Address=0x%Lx\n", __FUNCTION__, Allocate->File, Allocate->Alignment,
Allocate->Zone, (UINT64)Blob->Size, (UINT64)(UINTN)Blob->Base));
return EFI_SUCCESS;
FreeBlob:
FreePool (Blob);
//.........这里部分代码省略.........
开发者ID:OznOg,项目名称:edk2,代码行数:101,代码来源:QemuFwCfgAcpi.c
示例14: InstallQemuFwCfgTables
//.........这里部分代码省略.........
Tracker = OrderedCollectionInit (BlobCompare, BlobKeyCompare);
if (Tracker == NULL) {
Status = EFI_OUT_OF_RESOURCES;
goto FreeLoader;
}
//
// first pass: process the commands
//
for (LoaderEntry = LoaderStart; LoaderEntry < LoaderEnd; ++LoaderEntry) {
switch (LoaderEntry->Type) {
case QemuLoaderCmdAllocate:
Status = ProcessCmdAllocate (&LoaderEntry->Command.Allocate, Tracker);
break;
case QemuLoaderCmdAddPointer:
Status = ProcessCmdAddPointer (&LoaderEntry->Command.AddPointer,
Tracker);
break;
case QemuLoaderCmdAddChecksum:
Status = ProcessCmdAddChecksum (&LoaderEntry->Command.AddChecksum,
Tracker);
break;
default:
DEBUG ((EFI_D_VERBOSE, "%a: unknown loader command: 0x%x\n",
__FUNCTION__, LoaderEntry->Type));
break;
}
if (EFI_ERROR (Status)) {
goto FreeTracker;
}
}
InstalledKey = AllocatePool (INSTALLED_TABLES_MAX * sizeof *InstalledKey);
if (InstalledKey == NULL) {
Status = EFI_OUT_OF_RESOURCES;
goto FreeTracker;
}
//
// second pass: identify and install ACPI tables
//
Installed = 0;
for (LoaderEntry = LoaderStart; LoaderEntry < LoaderEnd; ++LoaderEntry) {
if (LoaderEntry->Type == QemuLoaderCmdAddPointer) {
Status = Process2ndPassCmdAddPointer (&LoaderEntry->Command.AddPointer,
Tracker, AcpiProtocol, InstalledKey, &Installed);
if (EFI_ERROR (Status)) {
break;
}
}
}
if (EFI_ERROR (Status)) {
//
// roll back partial installation
//
while (Installed > 0) {
--Installed;
AcpiProtocol->UninstallAcpiTable (AcpiProtocol, InstalledKey[Installed]);
}
} else {
DEBUG ((EFI_D_INFO, "%a: installed %d tables\n", __FUNCTION__, Installed));
}
FreePool (InstalledKey);
FreeTracker:
//
// Tear down the tracker infrastructure. Each fw_cfg blob will be left in
// place only if we're exiting with success and the blob hosts data that is
// not directly part of some ACPI table.
//
for (TrackerEntry = OrderedCollectionMin (Tracker); TrackerEntry != NULL;
TrackerEntry = TrackerEntry2) {
VOID *UserStruct;
BLOB *Blob;
TrackerEntry2 = OrderedCollectionNext (TrackerEntry);
OrderedCollectionDelete (Tracker, TrackerEntry, &UserStruct);
Blob = UserStruct;
if (EFI_ERROR (Status) || Blob->HostsOnlyTableData) {
DEBUG ((EFI_D_VERBOSE, "%a: freeing \"%a\"\n", __FUNCTION__,
Blob->File));
gBS->FreePages ((UINTN)Blob->Base, EFI_SIZE_TO_PAGES (Blob->Size));
}
FreePool (Blob);
}
OrderedCollectionUninit (Tracker);
FreeLoader:
FreePool (LoaderStart);
return Status;
}
开发者ID:OznOg,项目名称:edk2,代码行数:101,代码来源:QemuFwCfgAcpi.c
示例15: EmmcIdentificationMode
STATIC
EFI_STATUS
EFIAPI
EmmcIdentificationMode (
IN MMC_HOST_INSTANCE *MmcHostInstance,
IN OCR_RESPONSE Response
)
{
EFI_MMC_HOST_PROTOCOL *Host;
EFI_BLOCK_IO_MEDIA *Media;
EFI_STATUS Status;
EMMC_DEVICE_STATE State;
UINT32 RCA;
Host = MmcHostInstance->MmcHost;
Media = MmcHostInstance->BlockIo.Media;
// Fetch card identity register
Status = Host->SendCommand (Host, MMC_CMD2, 0);
if (EFI_ERROR (Status)) {
DEBUG ((EFI_D_ERROR, "EmmcIdentificationMode(): Failed to send CMD2, Status=%r.\n", Status));
return Status;
}
Status = Host->ReceiveResponse (Host, MMC_RESPONSE_TYPE_R2, (UINT32 *)&(MmcHostInstance->CardInfo.CIDData));
if (EFI_ERROR (Status)) {
DEBUG ((EFI_D_ERROR, "EmmcIdentificationMode(): CID retrieval error, Status=%r.\n", Status));
return Status;
}
// Assign a relative address value to the card
MmcHostInstance->CardInfo.RCA = ++mEmmcRcaCount; // TODO: might need a more sophisticated way of doing this
RCA = MmcHostInstance->CardInfo.RCA << RCA_SHIFT_OFFSET;
Status = Host->SendCommand (Host, MMC_CMD3, RCA);
if (EFI_ERROR (Status)) {
DEBUG ((EFI_D_ERROR, "EmmcIdentificationMode(): RCA set error, Status=%r.\n", Status));
return Status;
}
// Fetch card specific data
Status = Host->SendCommand (Host, MMC_CMD9, RCA);
if (EFI_ERROR (Status)) {
DEBUG ((EFI_D_ERROR, "EmmcIdentificationMode(): Failed to send CMD9, Status=%r.\n", Status));
return Status;
}
Status = Host->ReceiveResponse (Host, MMC_RESPONSE_TYPE_R2, (UINT32 *)&(MmcHostInstance->CardInfo.CSDData));
if (EFI_ERROR (Status)) {
DEBUG ((EFI_D_ERROR, "EmmcIdentificationMode(): CSD retrieval error, Status=%r.\n", Status));
return Status;
}
// Select the card
Status = Host->SendCommand (Host, MMC_CMD7, RCA);
if (EFI_ERROR (Status)) {
DEBUG ((EFI_D_ERROR, "EmmcIdentificationMode(): Card selection error, Status=%r.\n", Status));
}
if (MMC_HOST_HAS_SETIOS(Host)) {
// Set 1-bit bus width
Status = Host->SetIos (Host, 0, 1, EMMCBACKWARD);
if (EFI_ERROR (Status)) {
DEBUG ((EFI_D_ERROR, "EmmcIdentificationMode(): Set 1-bit bus width error, Status=%r.\n", Status));
return Status;
}
// Set 1-bit bus width for EXTCSD
Status = EmmcSetEXTCSD (MmcHostInstance, EXTCSD_BUS_WIDTH, EMMC_BUS_WIDTH_1BIT);
if (EFI_ERROR (Status)) {
DEBUG ((EFI_D_ERROR, "EmmcIdentificationMode(): Set extcsd bus width error, Status=%r.\n", Status));
return Status;
}
}
// Fetch ECSD
MmcHostInstance->CardInfo.ECSDData = AllocatePages (EFI_SIZE_TO_PAGES (sizeof (ECSD)));
if (MmcHostInstance->CardInfo.ECSDData == NULL) {
return EFI_OUT_OF_RESOURCES;
}
Status = Host->SendCommand (Host, MMC_CMD8, 0);
if (EFI_ERROR (Status)) {
DEBUG ((EFI_D_ERROR, "EmmcIdentificationMode(): ECSD fetch error, Status=%r.\n", Status));
}
Status = Host->ReadBlockData (Host, 0, 512, (UINT32 *)MmcHostInstance->CardInfo.ECSDData);
if (EFI_ERROR (Status)) {
DEBUG ((EFI_D_ERROR, "EmmcIdentificationMode(): ECSD read error, Status=%r.\n&
|
请发表评论