Code scrub for DxeCore

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@5520 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
qhuang8
2008-07-18 09:50:09 +00:00
parent ff61847ddc
commit e94a9ff727
25 changed files with 327 additions and 567 deletions

View File

@ -1,5 +1,5 @@
/** @file /** @file
DXE Dispatcher Dependency Evaluator DXE Dispatcher Dependency Evaluator.
This routine evaluates a dependency expression (DEPENDENCY_EXPRESSION) to determine This routine evaluates a dependency expression (DEPENDENCY_EXPRESSION) to determine
if a driver can be scheduled for execution. The criteria for if a driver can be scheduled for execution. The criteria for
@ -34,8 +34,7 @@ BOOLEAN *mDepexEvaluationStackPointer = NULL;
Grow size of the Depex stack Grow size of the Depex stack
@retval EFI_SUCCESS Stack successfully growed. @retval EFI_SUCCESS Stack successfully growed.
@retval EFI_OUT_OF_RESOURCES There is not enough system memory to grow the @retval EFI_OUT_OF_RESOURCES There is not enough system memory to grow the stack.
stack.
**/ **/
EFI_STATUS EFI_STATUS
@ -85,13 +84,12 @@ GrowDepexStack (
/** /**
Push an element onto the Boolean Stack Push an element onto the Boolean Stack.
@param Value BOOLEAN to push. @param Value BOOLEAN to push.
@retval EFI_SUCCESS The value was pushed onto the stack. @retval EFI_SUCCESS The value was pushed onto the stack.
@retval EFI_OUT_OF_RESOURCES There is not enough system memory to grow the @retval EFI_OUT_OF_RESOURCES There is not enough system memory to grow the stack.
stack.
**/ **/
EFI_STATUS EFI_STATUS
@ -131,7 +129,7 @@ PushBool (
@param Value BOOLEAN to pop. @param Value BOOLEAN to pop.
@retval EFI_SUCCESS The value was popped onto the stack. @retval EFI_SUCCESS The value was popped onto the stack.
@retval EFI_ACCESS_DENIED The pop operation underflowed the stack @retval EFI_ACCESS_DENIED The pop operation underflowed the stack.
**/ **/
EFI_STATUS EFI_STATUS
@ -163,7 +161,7 @@ PopBool (
it will be cleared by CoreSchedule(), and then the driver can be it will be cleared by CoreSchedule(), and then the driver can be
dispatched. dispatched.
@param DriverEntry DriverEntry element to update @param DriverEntry DriverEntry element to update .
@retval EFI_SUCCESS It always works. @retval EFI_SUCCESS It always works.
@ -203,7 +201,7 @@ CorePreProcessDepex (
routine in this case. The SOR is just ignored and is a nop in the grammer. routine in this case. The SOR is just ignored and is a nop in the grammer.
POSTFIX means all the math is done on top of the stack. POSTFIX means all the math is done on top of the stack.
@param DriverEntry DriverEntry element to update @param DriverEntry DriverEntry element to update.
@retval TRUE If driver is ready to run. @retval TRUE If driver is ready to run.
@retval FALSE If driver is not ready to run or some fatal error @retval FALSE If driver is not ready to run or some fatal error
@ -243,7 +241,7 @@ CoreIsSchedulable (
// //
// Clean out memory leaks in Depex Boolean stack. Leaks are only caused by // Clean out memory leaks in Depex Boolean stack. Leaks are only caused by
// incorrectly formed DEPEX expressions // incorrectly formed DEPEX expressions
// //
mDepexEvaluationStackPointer = mDepexEvaluationStack; mDepexEvaluationStackPointer = mDepexEvaluationStack;

View File

@ -76,7 +76,7 @@ VOID *mFwVolEventRegistration;
// //
// List of file types supported by dispatcher // List of file types supported by dispatcher
// //
STATIC EFI_FV_FILETYPE mDxeFileTypes[] = { EFI_FV_FILETYPE mDxeFileTypes[] = {
EFI_FV_FILETYPE_DRIVER, EFI_FV_FILETYPE_DRIVER,
EFI_FV_FILETYPE_COMBINED_PEIM_DRIVER, EFI_FV_FILETYPE_COMBINED_PEIM_DRIVER,
EFI_FV_FILETYPE_DXE_CORE, EFI_FV_FILETYPE_DXE_CORE,
@ -135,7 +135,7 @@ CoreFwVolEventProtocolNotify (
); );
/** /**
Convert FvHandle and DriverName into an EFI device path Convert FvHandle and DriverName into an EFI device path.
@param Fv Fv protocol, needed to read Depex info out of @param Fv Fv protocol, needed to read Depex info out of
FLASH. FLASH.
@ -341,7 +341,7 @@ CoreSchedule (
/** /**
Convert a driver from the Untrused back to the Scheduled state Convert a driver from the Untrused back to the Scheduled state.
@param FirmwareVolumeHandle The handle of the Firmware Volume that contains @param FirmwareVolumeHandle The handle of the Firmware Volume that contains
the firmware file specified by DriverName. the firmware file specified by DriverName.
@ -602,8 +602,7 @@ CoreInsertOnScheduledQueueWhileProcessingBeforeAndAfter (
@param FvHandle The handle of a FV that's being tested @param FvHandle The handle of a FV that's being tested
@retval TRUE Fv protocol on FvHandle has been processed @retval TRUE Fv protocol on FvHandle has been processed
@retval FALSE Fv protocol on FvHandle has not yet been @retval FALSE Fv protocol on FvHandle has not yet been processed
processed
**/ **/
BOOLEAN BOOLEAN
@ -700,7 +699,6 @@ CoreFvToDevicePath (
/** /**
Add an entry to the mDiscoveredList. Allocate memory to store the DriverEntry, Add an entry to the mDiscoveredList. Allocate memory to store the DriverEntry,
and initilize any state variables. Read the Depex from the FV and store it and initilize any state variables. Read the Depex from the FV and store it
@ -739,7 +737,7 @@ CoreAddToDriverList (
ASSERT (DriverEntry != NULL); ASSERT (DriverEntry != NULL);
DriverEntry->Signature = EFI_CORE_DRIVER_ENTRY_SIGNATURE; DriverEntry->Signature = EFI_CORE_DRIVER_ENTRY_SIGNATURE;
CopyMem (&DriverEntry->FileName, DriverName, sizeof (EFI_GUID)); CopyGuid (&DriverEntry->FileName, DriverName);
DriverEntry->FvHandle = FvHandle; DriverEntry->FvHandle = FvHandle;
DriverEntry->Fv = Fv; DriverEntry->Fv = Fv;
DriverEntry->FvFileDevicePath = CoreFvToDevicePath (Fv, FvHandle, DriverName); DriverEntry->FvFileDevicePath = CoreFvToDevicePath (Fv, FvHandle, DriverName);
@ -821,21 +819,21 @@ CoreProcessFvImageFile (
// //
// Read the first (and only the first) firmware volume section // Read the first (and only the first) firmware volume section
// //
SectionType = EFI_SECTION_FIRMWARE_VOLUME_IMAGE; SectionType = EFI_SECTION_FIRMWARE_VOLUME_IMAGE;
FvHeader = NULL; FvHeader = NULL;
FvAlignment = 0; FvAlignment = 0;
Buffer = NULL; Buffer = NULL;
BufferSize = 0; BufferSize = 0;
AlignedBuffer = NULL; AlignedBuffer = NULL;
Status = Fv->ReadSection ( Status = Fv->ReadSection (
Fv, Fv,
DriverName, DriverName,
SectionType, SectionType,
0, 0,
&Buffer, &Buffer,
&BufferSize, &BufferSize,
&AuthenticationStatus &AuthenticationStatus
); );
if (!EFI_ERROR (Status)) { if (!EFI_ERROR (Status)) {
// //
// FvImage should be at its required alignment. // FvImage should be at its required alignment.
@ -848,6 +846,9 @@ CoreProcessFvImageFile (
if (FvAlignment < 8) { if (FvAlignment < 8) {
FvAlignment = 8; FvAlignment = 8;
} }
//
// Allocate the aligned buffer for the FvImage.
//
AlignedBuffer = AllocateAlignedPages (EFI_SIZE_TO_PAGES (BufferSize), (UINTN) FvAlignment); AlignedBuffer = AllocateAlignedPages (EFI_SIZE_TO_PAGES (BufferSize), (UINTN) FvAlignment);
if (AlignedBuffer == NULL) { if (AlignedBuffer == NULL) {
Status = EFI_OUT_OF_RESOURCES; Status = EFI_OUT_OF_RESOURCES;
@ -935,12 +936,12 @@ CoreFwVolEventProtocolNotify (
while (TRUE) { while (TRUE) {
BufferSize = sizeof (EFI_HANDLE); BufferSize = sizeof (EFI_HANDLE);
Status = CoreLocateHandle ( Status = CoreLocateHandle (
ByRegisterNotify, ByRegisterNotify,
NULL, NULL,
mFwVolEventRegistration, mFwVolEventRegistration,
&BufferSize, &BufferSize,
&FvHandle &FvHandle
); );
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
// //
// If no more notification events exit // If no more notification events exit
@ -969,7 +970,6 @@ CoreFwVolEventProtocolNotify (
// //
FvIsBeingProcesssed (FvHandle); FvIsBeingProcesssed (FvHandle);
Status = CoreHandleProtocol (FvHandle, &gEfiFirmwareVolume2ProtocolGuid, (VOID **)&Fv); Status = CoreHandleProtocol (FvHandle, &gEfiFirmwareVolume2ProtocolGuid, (VOID **)&Fv);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
// //
@ -1012,7 +1012,7 @@ CoreFwVolEventProtocolNotify (
// EFI_FV_FILETYPE_DXE_CORE is processed to produce a Loaded Image protocol for the core // EFI_FV_FILETYPE_DXE_CORE is processed to produce a Loaded Image protocol for the core
// EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE is processed to create a Fvb // EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE is processed to create a Fvb
// //
for (Index = 0; Index < sizeof (mDxeFileTypes)/sizeof (EFI_FV_FILETYPE); Index++) { for (Index = 0; Index < sizeof (mDxeFileTypes) / sizeof (EFI_FV_FILETYPE); Index++) {
// //
// Initialize the search key // Initialize the search key
// //
@ -1125,7 +1125,7 @@ CoreFwVolEventProtocolNotify (
/** /**
Initialize the dispatcher. Initialize the notification function that runs when Initialize the dispatcher. Initialize the notification function that runs when
a FV protocol is added to the system. an FV2 protocol is added to the system.
**/ **/
VOID VOID

View File

@ -29,6 +29,11 @@ EFI_TIMER_ARCH_PROTOCOL *gTimer = NULL;
EFI_BDS_ARCH_PROTOCOL *gBds = NULL; EFI_BDS_ARCH_PROTOCOL *gBds = NULL;
EFI_WATCHDOG_TIMER_ARCH_PROTOCOL *gWatchdogTimer = NULL; EFI_WATCHDOG_TIMER_ARCH_PROTOCOL *gWatchdogTimer = NULL;
//
// DXE Core Global used to update core loaded image protocol handle
//
EFI_GUID *gDxeCoreFileName;
EFI_LOADED_IMAGE_PROTOCOL *gDxeCoreLoadedImage;
// //
// BugBug: I'n not runtime, but is the PPI? // BugBug: I'n not runtime, but is the PPI?
@ -39,15 +44,6 @@ EFI_STATUS_CODE_PROTOCOL gStatusCodeInstance = {
EFI_STATUS_CODE_PROTOCOL *gStatusCode = &gStatusCodeInstance; EFI_STATUS_CODE_PROTOCOL *gStatusCode = &gStatusCodeInstance;
//
// DXE Core Global used to update core loaded image protocol handle
//
EFI_GUID *gDxeCoreFileName;
EFI_LOADED_IMAGE_PROTOCOL *gDxeCoreLoadedImage;
// //
// DXE Core Module Variables // DXE Core Module Variables
// //
@ -215,7 +211,6 @@ EFI_SYSTEM_TABLE *gDxeCoreST = NULL;
EFI_RUNTIME_SERVICES *gDxeCoreRT = &mEfiRuntimeServicesTableTemplate; EFI_RUNTIME_SERVICES *gDxeCoreRT = &mEfiRuntimeServicesTableTemplate;
EFI_HANDLE gDxeCoreImageHandle = NULL; EFI_HANDLE gDxeCoreImageHandle = NULL;
VOID *mHobStart;
// //
// EFI Decompress Protocol // EFI Decompress Protocol
@ -232,10 +227,9 @@ EFI_DECOMPRESS_PROTOCOL gEfiDecompress = {
/** /**
Main entry point to DXE Core. Main entry point to DXE Core.
@param HobStart Pointer to the beginning of the HOB List from @param HobStart Pointer to the beginning of the HOB List from PEI.
PEI
@return This function should never return @return This function should never return.
**/ **/
VOID VOID
@ -248,8 +242,6 @@ DxeMain (
EFI_PHYSICAL_ADDRESS MemoryBaseAddress; EFI_PHYSICAL_ADDRESS MemoryBaseAddress;
UINT64 MemoryLength; UINT64 MemoryLength;
mHobStart = HobStart;
// //
// Initialize Memory Services // Initialize Memory Services
// //
@ -287,10 +279,6 @@ DxeMain (
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
// //
// The HobStart is relocated in gcd service init. Sync mHobStart varible.
//
mHobStart = HobStart;
// Install the DXE Services Table into the EFI System Tables's Configuration Table // Install the DXE Services Table into the EFI System Tables's Configuration Table
// //
Status = CoreInstallConfigurationTable (&gEfiDxeServicesTableGuid, gDxeCoreDS); Status = CoreInstallConfigurationTable (&gEfiDxeServicesTableGuid, gDxeCoreDS);
@ -311,7 +299,7 @@ DxeMain (
// //
// Initialize the ReportStatusCode with PEI version, if available // Initialize the ReportStatusCode with PEI version, if available
// //
CoreGetPeiProtocol (&gEfiStatusCodeRuntimeProtocolGuid, (VOID **)&gStatusCode->ReportStatusCode); CoreGetPeiProtocol (&gEfiStatusCodeRuntimeProtocolGuid, (VOID **) &gStatusCode->ReportStatusCode);
// //
// Report Status Code here for DXE_ENTRY_POINT once it is available // Report Status Code here for DXE_ENTRY_POINT once it is available
@ -330,7 +318,7 @@ DxeMain (
gDxeCoreImageHandle gDxeCoreImageHandle
); );
DEBUG ((DEBUG_INFO | DEBUG_LOAD, "HOBLIST address in DXE = 0x%016lx\n", (UINT64) (UINTN) HobStart)); DEBUG ((DEBUG_INFO | DEBUG_LOAD, "HOBLIST address in DXE = 0x%p\n", HobStart));
// //
// Initialize the Event Services // Initialize the Event Services
@ -355,10 +343,10 @@ DxeMain (
// Publish the EFI, Tiano, and Custom Decompress protocols for use by other DXE components // Publish the EFI, Tiano, and Custom Decompress protocols for use by other DXE components
// //
Status = CoreInstallMultipleProtocolInterfaces ( Status = CoreInstallMultipleProtocolInterfaces (
&mDecompressHandle, &mDecompressHandle,
&gEfiDecompressProtocolGuid, &gEfiDecompress, &gEfiDecompressProtocolGuid, &gEfiDecompress,
NULL NULL
); );
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
// //
@ -412,6 +400,7 @@ DxeMain (
// Report Status code before transfer control to BDS // Report Status code before transfer control to BDS
// //
CoreReportProgressCode (FixedPcdGet32 (PcdStatusCodeValueDxeCoreHandoffToBds)); CoreReportProgressCode (FixedPcdGet32 (PcdStatusCodeValueDxeCoreHandoffToBds));
// //
// Display any drivers that were not dispatched because dependency expression // Display any drivers that were not dispatched because dependency expression
// evaluated to false if this is a debug build // evaluated to false if this is a debug build
@ -619,7 +608,7 @@ CoreGetPeiProtocol (
EFI_HOB_GUID_TYPE *GuidHob; EFI_HOB_GUID_TYPE *GuidHob;
VOID *Buffer; VOID *Buffer;
GuidHob = GetNextGuidHob (ProtocolGuid, mHobStart); GuidHob = GetFirstGuidHob (ProtocolGuid);
if (GuidHob == NULL) { if (GuidHob == NULL) {
return EFI_NOT_FOUND; return EFI_NOT_FOUND;
} }
@ -679,8 +668,8 @@ CoreExitBootServices (
IN UINTN MapKey IN UINTN MapKey
) )
{ {
EFI_STATUS Status; EFI_STATUS Status;
EFI_STATUS StatusTemp; EFI_STATUS StatusTemp;
EFI_TCG_PLATFORM_PROTOCOL *TcgPlatformProtocol; EFI_TCG_PLATFORM_PROTOCOL *TcgPlatformProtocol;
// //
@ -755,7 +744,7 @@ CoreExitBootServices (
// //
// Zero out the Boot Service Table // Zero out the Boot Service Table
// //
SetMem (gDxeCoreBS, sizeof (EFI_BOOT_SERVICES), 0); ZeroMem (gDxeCoreBS, sizeof (EFI_BOOT_SERVICES));
gDxeCoreBS = NULL; gDxeCoreBS = NULL;
// //
@ -824,9 +813,7 @@ DxeMainUefiDecompressGetInfo (
OUT UINT32 *ScratchSize OUT UINT32 *ScratchSize
) )
{ {
if (Source == NULL if (Source == NULL || DestinationSize == NULL || ScratchSize == NULL) {
|| DestinationSize == NULL
|| ScratchSize == NULL) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
return UefiDecompressGetInfo (Source, SourceSize, DestinationSize, ScratchSize); return UefiDecompressGetInfo (Source, SourceSize, DestinationSize, ScratchSize);
@ -870,7 +857,7 @@ DxeMainUefiDecompressGetInfo (
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
DxeMainUefiDecompress ( DxeMainUefiDecompress (
IN EFI_DECOMPRESS_PROTOCOL *This, IN EFI_DECOMPRESS_PROTOCOL *This,
IN VOID *Source, IN VOID *Source,
IN UINT32 SourceSize, IN UINT32 SourceSize,
IN OUT VOID *Destination, IN OUT VOID *Destination,
@ -883,9 +870,7 @@ DxeMainUefiDecompress (
UINT32 TestDestinationSize; UINT32 TestDestinationSize;
UINT32 TestScratchSize; UINT32 TestScratchSize;
if (Source == NULL if (Source == NULL || Destination== NULL || Scratch == NULL) {
|| Destination== NULL
|| Scratch == NULL) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }

View File

@ -36,7 +36,7 @@ ARCHITECTURAL_PROTOCOL_ENTRY mArchProtocols[] = {
{ &gEfiRuntimeArchProtocolGuid, (VOID **)&gRuntime, NULL, NULL, FALSE }, { &gEfiRuntimeArchProtocolGuid, (VOID **)&gRuntime, NULL, NULL, FALSE },
{ &gEfiVariableArchProtocolGuid, (VOID **)NULL, NULL, NULL, FALSE }, { &gEfiVariableArchProtocolGuid, (VOID **)NULL, NULL, NULL, FALSE },
{ &gEfiVariableWriteArchProtocolGuid, (VOID **)NULL, NULL, NULL, FALSE }, { &gEfiVariableWriteArchProtocolGuid, (VOID **)NULL, NULL, NULL, FALSE },
{ &gEfiCapsuleArchProtocolGuid, (VOID **)NULL, NULL, NULL, FALSE}, { &gEfiCapsuleArchProtocolGuid, (VOID **)NULL, NULL, NULL, FALSE },
{ &gEfiMonotonicCounterArchProtocolGuid, (VOID **)NULL, NULL, NULL, FALSE }, { &gEfiMonotonicCounterArchProtocolGuid, (VOID **)NULL, NULL, NULL, FALSE },
{ &gEfiResetArchProtocolGuid, (VOID **)NULL, NULL, NULL, FALSE }, { &gEfiResetArchProtocolGuid, (VOID **)NULL, NULL, NULL, FALSE },
{ &gEfiRealTimeClockArchProtocolGuid, (VOID **)NULL, NULL, NULL, FALSE }, { &gEfiRealTimeClockArchProtocolGuid, (VOID **)NULL, NULL, NULL, FALSE },
@ -48,7 +48,6 @@ ARCHITECTURAL_PROTOCOL_ENTRY mArchProtocols[] = {
/** /**
Return TRUE if all AP services are availible. Return TRUE if all AP services are availible.
@retval EFI_SUCCESS All AP services are available @retval EFI_SUCCESS All AP services are available
@retval EFI_NOT_FOUND At least one AP service is not available @retval EFI_NOT_FOUND At least one AP service is not available
@ -170,7 +169,6 @@ GenericArchProtocolNotify (
/** /**
Creates an event that is fired everytime a Protocol of a specific type is installed. Creates an event that is fired everytime a Protocol of a specific type is installed.
@ -218,7 +216,7 @@ typedef struct {
CHAR16 *GuidString; CHAR16 *GuidString;
} GUID_TO_STRING_PROTOCOL_ENTRY; } GUID_TO_STRING_PROTOCOL_ENTRY;
STATIC CONST GUID_TO_STRING_PROTOCOL_ENTRY MissingProtocols[] = { CONST GUID_TO_STRING_PROTOCOL_ENTRY MissingProtocols[] = {
{ &gEfiSecurityArchProtocolGuid, (CHAR16 *)L"Security" }, { &gEfiSecurityArchProtocolGuid, (CHAR16 *)L"Security" },
{ &gEfiCpuArchProtocolGuid, (CHAR16 *)L"CPU" }, { &gEfiCpuArchProtocolGuid, (CHAR16 *)L"CPU" },
{ &gEfiMetronomeArchProtocolGuid, (CHAR16 *)L"Metronome" }, { &gEfiMetronomeArchProtocolGuid, (CHAR16 *)L"Metronome" },
@ -231,7 +229,6 @@ STATIC CONST GUID_TO_STRING_PROTOCOL_ENTRY MissingProtocols[] = {
{ &gEfiCapsuleArchProtocolGuid, (CHAR16 *)L"Capsule" }, { &gEfiCapsuleArchProtocolGuid, (CHAR16 *)L"Capsule" },
{ &gEfiMonotonicCounterArchProtocolGuid, (CHAR16 *)L"Monotonic Counter" }, { &gEfiMonotonicCounterArchProtocolGuid, (CHAR16 *)L"Monotonic Counter" },
{ &gEfiResetArchProtocolGuid, (CHAR16 *)L"Reset" }, { &gEfiResetArchProtocolGuid, (CHAR16 *)L"Reset" },
// { &gEfiStatusCodeRuntimeProtocolGuid, (CHAR16 *)L"Status Code" },
{ &gEfiRealTimeClockArchProtocolGuid, (CHAR16 *)L"Real Time Clock" } { &gEfiRealTimeClockArchProtocolGuid, (CHAR16 *)L"Real Time Clock" }
}; };
@ -246,7 +243,7 @@ CoreDisplayMissingArchProtocols (
VOID VOID
) )
{ {
const GUID_TO_STRING_PROTOCOL_ENTRY *MissingEntry; CONST GUID_TO_STRING_PROTOCOL_ENTRY *MissingEntry;
ARCHITECTURAL_PROTOCOL_ENTRY *Entry; ARCHITECTURAL_PROTOCOL_ENTRY *Entry;
for (Entry = mArchProtocols; Entry->ProtocolGuid != NULL; Entry++) { for (Entry = mArchProtocols; Entry->ProtocolGuid != NULL; Entry++) {

View File

@ -92,7 +92,6 @@ CoreReleaseEventLock (
/** /**
Initializes "event" support and populates parts of the System and Runtime Table. Initializes "event" support and populates parts of the System and Runtime Table.
@retval EFI_SUCCESS Always return success @retval EFI_SUCCESS Always return success
**/ **/
@ -385,7 +384,7 @@ CoreCreateEventEx (
return EFI_OUT_OF_RESOURCES; return EFI_OUT_OF_RESOURCES;
} }
SetMem (IEvent, sizeof (IEVENT), 0); ZeroMem (IEvent, sizeof (IEVENT));
IEvent->Signature = EVENT_SIGNATURE; IEvent->Signature = EVENT_SIGNATURE;
IEvent->Type = Type; IEvent->Type = Type;
@ -433,9 +432,9 @@ CoreCreateEventEx (
/** /**
Signals the event. Queues the event to be notified if needed Signals the event. Queues the event to be notified if needed.
@param UserEvent The event to signal @param UserEvent The event to signal .
@retval EFI_INVALID_PARAMETER Parameters are not valid. @retval EFI_INVALID_PARAMETER Parameters are not valid.
@retval EFI_SUCCESS The event was signaled. @retval EFI_SUCCESS The event was signaled.
@ -521,7 +520,7 @@ CoreCheckEvent (
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
if (Event->Type & EVT_NOTIFY_SIGNAL) { if ((Event->Type & EVT_NOTIFY_SIGNAL) != 0) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
@ -532,7 +531,6 @@ CoreCheckEvent (
// //
// Queue the wait notify function // Queue the wait notify function
// //
CoreAcquireEventLock (); CoreAcquireEventLock ();
if (!Event->SignalCount) { if (!Event->SignalCount) {
CoreNotifyEvent (Event); CoreNotifyEvent (Event);
@ -560,7 +558,6 @@ CoreCheckEvent (
/** /**
Stops execution until an event is signaled. Stops execution until an event is signaled.
@ -616,7 +613,6 @@ CoreWaitForEvent (
} }
/** /**
Closes an event and frees the event structure. Closes an event and frees the event structure.
@ -648,7 +644,7 @@ CoreCloseEvent (
// //
// If it's a timer event, make sure it's not pending // If it's a timer event, make sure it's not pending
// //
if (Event->Type & EVT_TIMER) { if ((Event->Type & EVT_TIMER) != 0) {
CoreSetTimer (Event, TimerCancel, 0); CoreSetTimer (Event, TimerCancel, 0);
} }

View File

@ -60,18 +60,16 @@ CoreInsertEventTimer (
// Internal data // Internal data
// //
STATIC LIST_ENTRY mEfiTimerList = INITIALIZE_LIST_HEAD_VARIABLE (mEfiTimerList); LIST_ENTRY mEfiTimerList = INITIALIZE_LIST_HEAD_VARIABLE (mEfiTimerList);
STATIC EFI_LOCK mEfiTimerLock = EFI_INITIALIZE_LOCK_VARIABLE (TPL_HIGH_LEVEL - 1); EFI_LOCK mEfiTimerLock = EFI_INITIALIZE_LOCK_VARIABLE (TPL_HIGH_LEVEL - 1);
STATIC EFI_EVENT mEfiCheckTimerEvent; EFI_EVENT mEfiCheckTimerEvent = NULL;
STATIC EFI_LOCK mEfiSystemTimeLock = EFI_INITIALIZE_LOCK_VARIABLE (TPL_HIGH_LEVEL); EFI_LOCK mEfiSystemTimeLock = EFI_INITIALIZE_LOCK_VARIABLE (TPL_HIGH_LEVEL);
STATIC UINT64 mEfiSystemTime = 0; UINT64 mEfiSystemTime = 0;
// //
// Timer functions // Timer functions
// //
/** /**
Initializes timer support. Initializes timer support.
@ -84,12 +82,12 @@ CoreInitializeTimer (
EFI_STATUS Status; EFI_STATUS Status;
Status = CoreCreateEvent ( Status = CoreCreateEvent (
EVT_NOTIFY_SIGNAL, EVT_NOTIFY_SIGNAL,
TPL_HIGH_LEVEL - 1, TPL_HIGH_LEVEL - 1,
CoreCheckTimers, CoreCheckTimers,
NULL, NULL,
&mEfiCheckTimerEvent &mEfiCheckTimerEvent
); );
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
} }
@ -110,6 +108,7 @@ CoreCurrentSystemTime (
CoreAcquireLock (&mEfiSystemTimeLock); CoreAcquireLock (&mEfiSystemTimeLock);
SystemTime = mEfiSystemTime; SystemTime = mEfiSystemTime;
CoreReleaseLock (&mEfiSystemTimeLock); CoreReleaseLock (&mEfiSystemTimeLock);
return SystemTime; return SystemTime;
} }
@ -132,20 +131,17 @@ CoreTimerTick (
// //
// Check runtiem flag in case there are ticks while exiting boot services // Check runtiem flag in case there are ticks while exiting boot services
// //
CoreAcquireLock (&mEfiSystemTimeLock); CoreAcquireLock (&mEfiSystemTimeLock);
// //
// Update the system time // Update the system time
// //
mEfiSystemTime += Duration; mEfiSystemTime += Duration;
// //
// If the head of the list is expired, fire the timer event // If the head of the list is expired, fire the timer event
// to process it // to process it
// //
if (!IsListEmpty (&mEfiTimerList)) { if (!IsListEmpty (&mEfiTimerList)) {
Event = CR (mEfiTimerList.ForwardLink, IEVENT, u.Timer.Link, EVENT_SIGNATURE); Event = CR (mEfiTimerList.ForwardLink, IEVENT, u.Timer.Link, EVENT_SIGNATURE);
@ -179,7 +175,6 @@ CoreCheckTimers (
// //
// Check the timer database for expired timers // Check the timer database for expired timers
// //
CoreAcquireLock (&mEfiTimerLock); CoreAcquireLock (&mEfiTimerLock);
SystemTime = CoreCurrentSystemTime (); SystemTime = CoreCurrentSystemTime ();
@ -189,7 +184,6 @@ CoreCheckTimers (
// //
// If this timer is not expired, then we're done // If this timer is not expired, then we're done
// //
if (Event->u.Timer.TriggerTime > SystemTime) { if (Event->u.Timer.TriggerTime > SystemTime) {
break; break;
} }
@ -210,11 +204,9 @@ CoreCheckTimers (
// If this is a periodic timer, set it // If this is a periodic timer, set it
// //
if (Event->u.Timer.Period) { if (Event->u.Timer.Period) {
// //
// Compute the timers new trigger time // Compute the timers new trigger time
// //
Event->u.Timer.TriggerTime = Event->u.Timer.TriggerTime + Event->u.Timer.Period; Event->u.Timer.TriggerTime = Event->u.Timer.TriggerTime + Event->u.Timer.Period;
// //
@ -228,7 +220,6 @@ CoreCheckTimers (
// //
// Add the timer // Add the timer
// //
CoreInsertEventTimer (Event); CoreInsertEventTimer (Event);
} }
} }
@ -258,13 +249,11 @@ CoreInsertEventTimer (
// //
// Get the timer's trigger time // Get the timer's trigger time
// //
TriggerTime = Event->u.Timer.TriggerTime; TriggerTime = Event->u.Timer.TriggerTime;
// //
// Insert the timer into the timer database in assending sorted order // Insert the timer into the timer database in assending sorted order
// //
for (Link = mEfiTimerList.ForwardLink; Link != &mEfiTimerList; Link = Link->ForwardLink) { for (Link = mEfiTimerList.ForwardLink; Link != &mEfiTimerList; Link = Link->ForwardLink) {
Event2 = CR (Link, IEVENT, u.Timer.Link, EVENT_SIGNATURE); Event2 = CR (Link, IEVENT, u.Timer.Link, EVENT_SIGNATURE);
@ -278,7 +267,6 @@ CoreInsertEventTimer (
/** /**
Sets the type of timer and the trigger time for a timer event. Sets the type of timer and the trigger time for a timer event.
@ -323,7 +311,6 @@ CoreSetTimer (
// //
// If the timer is queued to the timer database, remove it // If the timer is queued to the timer database, remove it
// //
if (Event->u.Timer.Link.ForwardLink != NULL) { if (Event->u.Timer.Link.ForwardLink != NULL) {
RemoveEntryList (&Event->u.Timer.Link); RemoveEntryList (&Event->u.Timer.Link);
Event->u.Timer.Link.ForwardLink = NULL; Event->u.Timer.Link.ForwardLink = NULL;
@ -347,5 +334,6 @@ CoreSetTimer (
} }
CoreReleaseLock (&mEfiTimerLock); CoreReleaseLock (&mEfiTimerLock);
return EFI_SUCCESS; return EFI_SUCCESS;
} }

View File

@ -1,5 +1,5 @@
/** @file /** @file
Task priority (TPL) function Task priority (TPL) functions.
Copyright (c) 2006 - 2008, Intel Corporation. <BR> Copyright (c) 2006 - 2008, Intel Corporation. <BR>
All rights reserved. This program and the accompanying materials All rights reserved. This program and the accompanying materials
@ -52,14 +52,14 @@ CoreHighestSetBit (
IN UINTN Number IN UINTN Number
) )
{ {
UINTN msb; UINTN Msb;
msb = 31; Msb = 31;
while ((msb > 0) && ((Number & (UINTN)(1 << msb)) == 0)) { while ((Msb > 0) && ((Number & (UINTN)(1 << Msb)) == 0)) {
msb--; Msb--;
} }
return msb; return Msb;
} }

View File

@ -15,8 +15,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include <DxeMain.h> #include <DxeMain.h>
#define PHYSICAL_ADDRESS_TO_POINTER(Address) ((VOID *)((UINTN)(Address)))
/** /**
Get the FFS file state by checking the highest bit set in the header's state field. Get the FFS file state by checking the highest bit set in the header's state field.
@ -47,7 +45,7 @@ GetFileState (
HighestBit >>= 1; HighestBit >>= 1;
} }
return (EFI_FFS_FILE_STATE)HighestBit; return (EFI_FFS_FILE_STATE) HighestBit;
} }
@ -183,24 +181,23 @@ IsValidFfsHeader (
*FileState = GetFileState (ErasePolarity, FfsHeader); *FileState = GetFileState (ErasePolarity, FfsHeader);
switch (*FileState) { switch (*FileState) {
case EFI_FILE_HEADER_VALID: case EFI_FILE_HEADER_VALID:
case EFI_FILE_DATA_VALID: case EFI_FILE_DATA_VALID:
case EFI_FILE_MARKED_FOR_UPDATE: case EFI_FILE_MARKED_FOR_UPDATE:
case EFI_FILE_DELETED: case EFI_FILE_DELETED:
// //
// Here we need to verify header checksum // Here we need to verify header checksum
// //
return VerifyHeaderChecksum (FfsHeader); return VerifyHeaderChecksum (FfsHeader);
case EFI_FILE_HEADER_CONSTRUCTION: case EFI_FILE_HEADER_CONSTRUCTION:
case EFI_FILE_HEADER_INVALID: case EFI_FILE_HEADER_INVALID:
default: default:
return FALSE; return FALSE;
} }
} }
/** /**
Check if it's a valid FFS file. Check if it's a valid FFS file.
Here we are sure that it has a valid FFS file header since we must call IsValidFfsHeader() first. Here we are sure that it has a valid FFS file header since we must call IsValidFfsHeader() first.
@ -223,17 +220,17 @@ IsValidFfsFile (
FileState = GetFileState (ErasePolarity, FfsHeader); FileState = GetFileState (ErasePolarity, FfsHeader);
switch (FileState) { switch (FileState) {
case EFI_FILE_DELETED: case EFI_FILE_DELETED:
case EFI_FILE_DATA_VALID: case EFI_FILE_DATA_VALID:
case EFI_FILE_MARKED_FOR_UPDATE: case EFI_FILE_MARKED_FOR_UPDATE:
// //
// Some other vliadation like file content checksum might be done here. // Some other vliadation like file content checksum might be done here.
// For performance issue, Tiano only do FileState check. // For performance issue, Tiano only do FileState check.
// //
return TRUE; return TRUE;
default: default:
return FALSE; return FALSE;
} }
} }

View File

@ -52,8 +52,6 @@ FV_DEVICE mFvDevice = {
// //
// FFS helper functions // FFS helper functions
// //
/** /**
given the supplied FW_VOL_BLOCK_PROTOCOL, allocate a buffer for output and given the supplied FW_VOL_BLOCK_PROTOCOL, allocate a buffer for output and
copy the volume header into it. copy the volume header into it.
@ -122,8 +120,6 @@ GetFwVolHeader (
@param FvDevice pointer to the FvDevice to be freed. @param FvDevice pointer to the FvDevice to be freed.
@return None.
**/ **/
VOID VOID
FreeFvDeviceResource ( FreeFvDeviceResource (
@ -149,7 +145,7 @@ FreeFvDeviceResource (
CoreFreePool (FfsFileEntry); CoreFreePool (FfsFileEntry);
FfsFileEntry = (FFS_FILE_LIST_ENTRY *)NextEntry; FfsFileEntry = (FFS_FILE_LIST_ENTRY *) NextEntry;
} }
@ -169,9 +165,9 @@ FreeFvDeviceResource (
/** /**
Check if a FV is consistent and allocate cache Check if an FV is consistent and allocate cache for it.
@param FvDevice pointer to the FvDevice to be checked. @param FvDevice A pointer to the FvDevice to be checked.
@retval EFI_OUT_OF_RESOURCES No enough buffer could be allocated. @retval EFI_OUT_OF_RESOURCES No enough buffer could be allocated.
@retval EFI_SUCCESS FV is consistent and cache is allocated. @retval EFI_SUCCESS FV is consistent and cache is allocated.
@ -245,11 +241,11 @@ FvCheck (
Size -= LbaOffset; Size -= LbaOffset;
} }
Status = Fvb->Read (Fvb, Status = Fvb->Read (Fvb,
LbaIndex, LbaIndex,
LbaOffset, LbaOffset,
&Size, &Size,
CacheLocation CacheLocation
); );
// //
// Not check EFI_BAD_BUFFER_SIZE, for Size = BlockMap->Length // Not check EFI_BAD_BUFFER_SIZE, for Size = BlockMap->Length
// //
@ -288,11 +284,11 @@ FvCheck (
// //
// Build FFS list // Build FFS list
// //
FfsHeader = (EFI_FFS_FILE_HEADER *)FvDevice->CachedFv; FfsHeader = (EFI_FFS_FILE_HEADER *) FvDevice->CachedFv;
TopFvAddress = FvDevice->EndOfCachedFv; TopFvAddress = FvDevice->EndOfCachedFv;
while ((UINT8 *)FfsHeader < TopFvAddress) { while ((UINT8 *) FfsHeader < TopFvAddress) {
TestLength = TopFvAddress - ((UINT8 *)FfsHeader); TestLength = TopFvAddress - ((UINT8 *) FfsHeader);
if (TestLength > sizeof (EFI_FFS_FILE_HEADER)) { if (TestLength > sizeof (EFI_FFS_FILE_HEADER)) {
TestLength = sizeof (EFI_FFS_FILE_HEADER); TestLength = sizeof (EFI_FFS_FILE_HEADER);
} }
@ -308,9 +304,7 @@ FvCheck (
if ((FileState == EFI_FILE_HEADER_INVALID) || if ((FileState == EFI_FILE_HEADER_INVALID) ||
(FileState == EFI_FILE_HEADER_CONSTRUCTION)) { (FileState == EFI_FILE_HEADER_CONSTRUCTION)) {
FfsHeader++; FfsHeader++;
continue; continue;
} else { } else {
// //
// File system is corrputed // File system is corrputed
@ -476,9 +470,9 @@ NotifyFwVolBlock (
return; return;
} }
FvDevice->Fvb = Fvb; FvDevice->Fvb = Fvb;
FvDevice->Handle = Handle; FvDevice->Handle = Handle;
FvDevice->FwVolHeader = FwVolHeader; FvDevice->FwVolHeader = FwVolHeader;
FvDevice->Fv.ParentHandle = Fvb->ParentHandle; FvDevice->Fv.ParentHandle = Fvb->ParentHandle;
// //

View File

@ -200,7 +200,7 @@ FvGetNextFile (
// Return FileType, NameGuid, and Attributes // Return FileType, NameGuid, and Attributes
// //
*FileType = FfsFileHeader->Type; *FileType = FfsFileHeader->Type;
CopyMem (NameGuid, &FfsFileHeader->Name, sizeof (EFI_GUID)); CopyGuid (NameGuid, &FfsFileHeader->Name);
*Attributes = FfsAttributes2FvFileAttributes (FfsFileHeader->Attributes); *Attributes = FfsAttributes2FvFileAttributes (FfsFileHeader->Attributes);
// //
@ -280,7 +280,7 @@ FvReadFile (
EFI_FFS_FILE_HEADER *FfsHeader; EFI_FFS_FILE_HEADER *FfsHeader;
UINTN InputBufferSize; UINTN InputBufferSize;
if (NULL == NameGuid) { if (NameGuid == NULL) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
@ -412,7 +412,7 @@ FvReadFileSection (
UINT8 *FileBuffer; UINT8 *FileBuffer;
FFS_FILE_LIST_ENTRY *FfsEntry; FFS_FILE_LIST_ENTRY *FfsEntry;
if (NULL == NameGuid || Buffer == NULL) { if (NameGuid == NULL || Buffer == NULL) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
@ -434,7 +434,7 @@ FvReadFileSection (
// //
// Get the last key used by our call to FvReadFile as it is the FfsEntry for this file. // Get the last key used by our call to FvReadFile as it is the FfsEntry for this file.
// //
FfsEntry = (FFS_FILE_LIST_ENTRY *)FvDevice->LastKey; FfsEntry = (FFS_FILE_LIST_ENTRY *) FvDevice->LastKey;
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
return Status; return Status;
@ -453,10 +453,10 @@ FvReadFileSection (
// //
if (FfsEntry->StreamHandle == 0) { if (FfsEntry->StreamHandle == 0) {
Status = OpenSectionStream ( Status = OpenSectionStream (
FileSize, FileSize,
FileBuffer, FileBuffer,
&FfsEntry->StreamHandle &FfsEntry->StreamHandle
); );
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
goto Done; goto Done;
} }

View File

@ -1,9 +1,8 @@
/** @file /** @file
Firmware Volume Block protocol. Consumes FV hobs and creates Implementations for Firmware Volume Block protocol.
appropriate block protocols.
It consumes FV HOBs and creates read-lonly Firmare Volume Block protocol
Also consumes NT_NON_MM_FV envinronment variable and produces appropriate instances for each of them.
block protocols fro them also... (this is TBD)
Copyright (c) 2006 - 2008, Intel Corporation. <BR> Copyright (c) 2006 - 2008, Intel Corporation. <BR>
All rights reserved. This program and the accompanying materials All rights reserved. This program and the accompanying materials
@ -27,16 +26,22 @@ EFI_FW_VOL_BLOCK_DEVICE mFwVolBlock = {
{ {
HARDWARE_DEVICE_PATH, HARDWARE_DEVICE_PATH,
HW_MEMMAP_DP, HW_MEMMAP_DP,
{ (UINT8)(sizeof (MEMMAP_DEVICE_PATH)), (UINT8)(sizeof (MEMMAP_DEVICE_PATH) >> 8) } {
(UINT8)(sizeof (MEMMAP_DEVICE_PATH)),
(UINT8)(sizeof (MEMMAP_DEVICE_PATH) >> 8)
}
}, },
EfiMemoryMappedIO, EfiMemoryMappedIO,
(EFI_PHYSICAL_ADDRESS)0, (EFI_PHYSICAL_ADDRESS) 0,
(EFI_PHYSICAL_ADDRESS)0, (EFI_PHYSICAL_ADDRESS) 0,
}, },
{ {
END_DEVICE_PATH_TYPE, END_DEVICE_PATH_TYPE,
END_ENTIRE_DEVICE_PATH_SUBTYPE, END_ENTIRE_DEVICE_PATH_SUBTYPE,
{ END_DEVICE_PATH_LENGTH, 0 } {
END_DEVICE_PATH_LENGTH,
0
}
}, },
}, },
{ {
@ -57,8 +62,6 @@ EFI_FW_VOL_BLOCK_DEVICE mFwVolBlock = {
/** /**
Retrieves Volume attributes. No polarity translations are done. Retrieves Volume attributes. No polarity translations are done.
@ -195,7 +198,7 @@ FwVolBlockReadBlock (
return EFI_ACCESS_DENIED; return EFI_ACCESS_DENIED;
} }
LbaIndex = (UINTN)Lba; LbaIndex = (UINTN) Lba;
if (LbaIndex >= FvbDevice->NumBlocks) { if (LbaIndex >= FvbDevice->NumBlocks) {
// //
// Invalid Lba, read nothing. // Invalid Lba, read nothing.
@ -221,8 +224,8 @@ FwVolBlockReadBlock (
} }
LbaStart = FvbDevice->LbaCache[LbaIndex].Base; LbaStart = FvbDevice->LbaCache[LbaIndex].Base;
FwVolHeader = (EFI_FIRMWARE_VOLUME_HEADER *)((UINTN)FvbDevice->BaseAddress); FwVolHeader = (EFI_FIRMWARE_VOLUME_HEADER *)((UINTN) FvbDevice->BaseAddress);
LbaOffset = (UINT8 *)FwVolHeader + LbaStart + Offset; LbaOffset = (UINT8 *) FwVolHeader + LbaStart + Offset;
// //
// Perform read operation // Perform read operation
@ -412,7 +415,7 @@ ProduceFVBProtocolOnBuffer (
EFI_FV_BLOCK_MAP_ENTRY *PtrBlockMapEntry; EFI_FV_BLOCK_MAP_ENTRY *PtrBlockMapEntry;
FvAlignment = 0; FvAlignment = 0;
FwVolHeader = (EFI_FIRMWARE_VOLUME_HEADER *)(UINTN)BaseAddress; FwVolHeader = (EFI_FIRMWARE_VOLUME_HEADER *)(UINTN) BaseAddress;
// //
// Validate FV Header, if not as expected, return // Validate FV Header, if not as expected, return
// //
@ -450,8 +453,8 @@ ProduceFVBProtocolOnBuffer (
// //
FvbDev->NumBlocks = 0; FvbDev->NumBlocks = 0;
for (PtrBlockMapEntry = FwVolHeader->BlockMap; for (PtrBlockMapEntry = FwVolHeader->BlockMap;
PtrBlockMapEntry->NumBlocks != 0; PtrBlockMapEntry->NumBlocks != 0;
PtrBlockMapEntry++) { PtrBlockMapEntry++) {
FvbDev->NumBlocks += PtrBlockMapEntry->NumBlocks; FvbDev->NumBlocks += PtrBlockMapEntry->NumBlocks;
} }
// //
@ -468,7 +471,7 @@ ProduceFVBProtocolOnBuffer (
BlockIndex = 0; BlockIndex = 0;
LinearOffset = 0; LinearOffset = 0;
for (PtrBlockMapEntry = FwVolHeader->BlockMap; for (PtrBlockMapEntry = FwVolHeader->BlockMap;
PtrBlockMapEntry->NumBlocks != 0; PtrBlockMapEntry++) { PtrBlockMapEntry->NumBlocks != 0; PtrBlockMapEntry++) {
for (BlockIndex2 = 0; BlockIndex2 < PtrBlockMapEntry->NumBlocks; BlockIndex2++) { for (BlockIndex2 = 0; BlockIndex2 < PtrBlockMapEntry->NumBlocks; BlockIndex2++) {
FvbDev->LbaCache[BlockIndex].Base = LinearOffset; FvbDev->LbaCache[BlockIndex].Base = LinearOffset;
FvbDev->LbaCache[BlockIndex].Length = PtrBlockMapEntry->Length; FvbDev->LbaCache[BlockIndex].Length = PtrBlockMapEntry->Length;
@ -488,12 +491,12 @@ ProduceFVBProtocolOnBuffer (
// Attach FvVolBlock Protocol to new handle // Attach FvVolBlock Protocol to new handle
// //
Status = CoreInstallMultipleProtocolInterfaces ( Status = CoreInstallMultipleProtocolInterfaces (
&FvbDev->Handle, &FvbDev->Handle,
&gEfiFirmwareVolumeBlockProtocolGuid, &FvbDev->FwVolBlockInstance, &gEfiFirmwareVolumeBlockProtocolGuid, &FvbDev->FwVolBlockInstance,
&gEfiDevicePathProtocolGuid, &FvbDev->DevicePath, &gEfiDevicePathProtocolGuid, &FvbDev->DevicePath,
&gEfiFirmwareVolumeDispatchProtocolGuid, NULL, &gEfiFirmwareVolumeDispatchProtocolGuid, NULL,
NULL NULL
); );
// //
// If they want the handle back, set it. // If they want the handle back, set it.
@ -527,6 +530,7 @@ FwVolBlockDriverInit (
) )
{ {
EFI_PEI_HOB_POINTERS FvHob; EFI_PEI_HOB_POINTERS FvHob;
// //
// Core Needs Firmware Volumes to function // Core Needs Firmware Volumes to function
// //
@ -538,6 +542,7 @@ FwVolBlockDriverInit (
ProduceFVBProtocolOnBuffer (FvHob.FirmwareVolume->BaseAddress, FvHob.FirmwareVolume->Length, NULL, NULL); ProduceFVBProtocolOnBuffer (FvHob.FirmwareVolume->BaseAddress, FvHob.FirmwareVolume->Length, NULL, NULL);
FvHob.Raw = GET_NEXT_HOB (FvHob); FvHob.Raw = GET_NEXT_HOB (FvHob);
} }
return EFI_SUCCESS; return EFI_SUCCESS;
} }
@ -587,7 +592,7 @@ CoreProcessFirmwareVolume (
// //
if (!EFI_ERROR(Status)) { if (!EFI_ERROR(Status)) {
Ptr = NULL; Ptr = NULL;
Status = CoreHandleProtocol (*FVProtocolHandle, &gEfiFirmwareVolume2ProtocolGuid, (VOID **)&Ptr); Status = CoreHandleProtocol (*FVProtocolHandle, &gEfiFirmwareVolume2ProtocolGuid, (VOID **) &Ptr);
if (EFI_ERROR(Status) || (Ptr == NULL)) { if (EFI_ERROR(Status) || (Ptr == NULL)) {
return EFI_VOLUME_CORRUPTED; return EFI_VOLUME_CORRUPTED;
} }

View File

@ -1,7 +1,7 @@
/** @file /** @file
The file contains the GCD related services in the EFI Boot Services Table. The file contains the GCD related services in the EFI Boot Services Table.
The GCD services are used to manage the memory and I/O regions that The GCD services are used to manage the memory and I/O regions that
are accessible to the CPU that is executing the DXE core. are accessible to the CPU that is executing the DXE core.
Copyright (c) 2006 - 2008, Intel Corporation. <BR> Copyright (c) 2006 - 2008, Intel Corporation. <BR>
All rights reserved. This program and the accompanying materials All rights reserved. This program and the accompanying materials
@ -49,7 +49,10 @@ LIST_ENTRY mGcdIoSpaceMap = INITIALIZE_LIST_HEAD_VARIABLE (mGcdIoSp
EFI_GCD_MAP_ENTRY mGcdMemorySpaceMapEntryTemplate = { EFI_GCD_MAP_ENTRY mGcdMemorySpaceMapEntryTemplate = {
EFI_GCD_MAP_SIGNATURE, EFI_GCD_MAP_SIGNATURE,
{ NULL, NULL }, {
NULL,
NULL
},
0, 0,
0, 0,
0, 0,
@ -62,7 +65,10 @@ EFI_GCD_MAP_ENTRY mGcdMemorySpaceMapEntryTemplate = {
EFI_GCD_MAP_ENTRY mGcdIoSpaceMapEntryTemplate = { EFI_GCD_MAP_ENTRY mGcdIoSpaceMapEntryTemplate = {
EFI_GCD_MAP_SIGNATURE, EFI_GCD_MAP_SIGNATURE,
{ NULL, NULL }, {
NULL,
NULL
},
0, 0,
0, 0,
0, 0,
@ -85,7 +91,7 @@ GCD_ATTRIBUTE_CONVERSION_ENTRY mAttributeConversionTable[] = {
{ EFI_RESOURCE_ATTRIBUTE_PRESENT, EFI_MEMORY_PRESENT, FALSE }, { EFI_RESOURCE_ATTRIBUTE_PRESENT, EFI_MEMORY_PRESENT, FALSE },
{ EFI_RESOURCE_ATTRIBUTE_INITIALIZED, EFI_MEMORY_INITIALIZED, FALSE }, { EFI_RESOURCE_ATTRIBUTE_INITIALIZED, EFI_MEMORY_INITIALIZED, FALSE },
{ EFI_RESOURCE_ATTRIBUTE_TESTED, EFI_MEMORY_TESTED, FALSE }, { EFI_RESOURCE_ATTRIBUTE_TESTED, EFI_MEMORY_TESTED, FALSE },
{ 0, 0, FALSE } { 0, 0, FALSE }
}; };
@ -147,7 +153,6 @@ CoreReleaseGcdIoLock (
// //
// GCD Initialization Worker Functions // GCD Initialization Worker Functions
// //
/** /**
Aligns a value to the specified boundary. Aligns a value to the specified boundary.
@ -292,7 +297,7 @@ CoreInsertGcdMapEntry (
/** /**
Merge the Gcd region specified by Link and its adjacent entry Merge the Gcd region specified by Link and its adjacent entry.
@param Link Specify the entry to be merged (with its @param Link Specify the entry to be merged (with its
adjacent entry). adjacent entry).
@ -452,6 +457,7 @@ CoreSearchGcdMapEntry (
} }
Link = Link->ForwardLink; Link = Link->ForwardLink;
} }
return EFI_NOT_FOUND; return EFI_NOT_FOUND;
} }
@ -478,6 +484,7 @@ CoreCountGcdMapEntry (
Count++; Count++;
Link = Link->ForwardLink; Link = Link->ForwardLink;
} }
return Count; return Count;
} }
@ -655,7 +662,6 @@ CoreConvertSpace (
if ((Attributes & EFI_MEMORY_RUNTIME) != 0) { if ((Attributes & EFI_MEMORY_RUNTIME) != 0) {
if ((BaseAddress & EFI_PAGE_MASK) != 0 || (Length & EFI_PAGE_MASK) != 0) { if ((BaseAddress & EFI_PAGE_MASK) != 0 || (Length & EFI_PAGE_MASK) != 0) {
Status = EFI_INVALID_PARAMETER; Status = EFI_INVALID_PARAMETER;
goto Done; goto Done;
} }
} }
@ -677,9 +683,6 @@ CoreConvertSpace (
goto Done; goto Done;
} }
//
//
//
if (Operation == GCD_SET_ATTRIBUTES_MEMORY_OPERATION) { if (Operation == GCD_SET_ATTRIBUTES_MEMORY_OPERATION) {
// //
// Call CPU Arch Protocol to attempt to set attributes on the range // Call CPU Arch Protocol to attempt to set attributes on the range
@ -973,7 +976,7 @@ CoreAllocateSpace (
} }
if (GcdAllocateType == EfiGcdAllocateMaxAddressSearchTopDown || if (GcdAllocateType == EfiGcdAllocateMaxAddressSearchTopDown ||
GcdAllocateType == EfiGcdAllocateAnySearchTopDown ) { GcdAllocateType == EfiGcdAllocateAnySearchTopDown) {
if ((Entry->BaseAddress + Length) > MaxAddress) { if ((Entry->BaseAddress + Length) > MaxAddress) {
continue; continue;
} }
@ -1859,10 +1862,9 @@ CoreInitializeMemoryServices (
// //
// See if this resource descrior HOB describes tested system memory below MaxAddress // See if this resource descrior HOB describes tested system memory below MaxAddress
// //
if (ResourceHob->ResourceType == EFI_RESOURCE_SYSTEM_MEMORY && if (ResourceHob->ResourceType == EFI_RESOURCE_SYSTEM_MEMORY &&
(ResourceHob->ResourceAttribute & MEMORY_ATTRIBUTE_MASK) == TESTED_MEMORY_ATTRIBUTES && (ResourceHob->ResourceAttribute & MEMORY_ATTRIBUTE_MASK) == TESTED_MEMORY_ATTRIBUTES &&
ResourceHob->PhysicalStart + ResourceHob->ResourceLength <= MaxAddress ) { ResourceHob->PhysicalStart + ResourceHob->ResourceLength <= MaxAddress) {
// //
// See if this is the highest tested system memory region below MaxAddress // See if this is the highest tested system memory region below MaxAddress
// //
@ -1886,11 +1888,8 @@ CoreInitializeMemoryServices (
MaxAddress = ResourceHob->PhysicalStart; MaxAddress = ResourceHob->PhysicalStart;
} while (Found && MaxMemoryLength < MINIMUM_INITIAL_MEMORY_SIZE); } while (Found && MaxMemoryLength < MINIMUM_INITIAL_MEMORY_SIZE);
// if ((Length < MINIMUM_INITIAL_MEMORY_SIZE) ||
// (MaxMemoryBaseAddress > BaseAddress && MaxMemoryLength >= MINIMUM_INITIAL_MEMORY_SIZE)) {
//
if ((Length < MINIMUM_INITIAL_MEMORY_SIZE) ||
(MaxMemoryBaseAddress > BaseAddress && MaxMemoryLength >= MINIMUM_INITIAL_MEMORY_SIZE) ) {
BaseAddress = MaxMemoryBaseAddress; BaseAddress = MaxMemoryBaseAddress;
Length = MaxMemoryLength; Length = MaxMemoryLength;
Attributes = MaxMemoryAttributes; Attributes = MaxMemoryAttributes;
@ -1942,14 +1941,14 @@ CoreInitializeMemoryServices (
**/ **/
EFI_STATUS EFI_STATUS
CoreInitializeGcdServices ( CoreInitializeGcdServices (
IN OUT VOID **HobStart, IN OUT VOID **HobStart,
IN EFI_PHYSICAL_ADDRESS MemoryBaseAddress, IN EFI_PHYSICAL_ADDRESS MemoryBaseAddress,
IN UINT64 MemoryLength IN UINT64 MemoryLength
) )
{ {
EFI_PEI_HOB_POINTERS Hob; EFI_PEI_HOB_POINTERS Hob;
VOID *NewHobList; VOID *NewHobList;
EFI_HOB_HANDOFF_INFO_TABLE *PhitHob; EFI_HOB_HANDOFF_INFO_TABLE *PhitHob;
UINT8 SizeOfMemorySpace; UINT8 SizeOfMemorySpace;
UINT8 SizeOfIoSpace; UINT8 SizeOfIoSpace;
EFI_HOB_RESOURCE_DESCRIPTOR *ResourceHob; EFI_HOB_RESOURCE_DESCRIPTOR *ResourceHob;
@ -1967,6 +1966,7 @@ CoreInitializeGcdServices (
UINTN Index; UINTN Index;
UINT64 Capabilities; UINT64 Capabilities;
EFI_HOB_CPU * CpuHob; EFI_HOB_CPU * CpuHob;
// //
// Cache the PHIT HOB for later use // Cache the PHIT HOB for later use
// //
@ -2041,7 +2041,6 @@ CoreInitializeGcdServices (
} }
if (GcdMemoryType != EfiGcdMemoryTypeNonExistent) { if (GcdMemoryType != EfiGcdMemoryTypeNonExistent) {
// //
// Convert the Resource HOB Attributes to an EFI Memory Capabilities mask // Convert the Resource HOB Attributes to an EFI Memory Capabilities mask
// //

View File

@ -181,6 +181,33 @@ CoreUnregisterProtocolNotify (
IN EFI_EVENT Event IN EFI_EVENT Event
); );
/**
Connects a controller to a driver.
@param ControllerHandle Handle of the controller to be
connected.
@param ContextDriverImageHandles DriverImageHandle A pointer to an
ordered list of driver image
handles.
@param RemainingDevicePath RemainingDevicePath A pointer to
the device path that specifies a
child of the controller
specified by ControllerHandle.
@retval EFI_SUCCESS One or more drivers were
connected to ControllerHandle.
@retval EFI_OUT_OF_RESOURCES No enough system resources to
complete the request.
@retval EFI_NOT_FOUND No drivers were connected to
ControllerHandle.
**/
EFI_STATUS
CoreConnectSingleController (
IN EFI_HANDLE ControllerHandle,
IN EFI_HANDLE *ContextDriverImageHandles OPTIONAL,
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
);
/** /**
Attempts to disconnect all drivers that are using the protocol interface being queried. Attempts to disconnect all drivers that are using the protocol interface being queried.

View File

@ -14,41 +14,10 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include <DxeMain.h> #include <DxeMain.h>
//
// Driver Support Function Prototypes
//
/**
Connects a controller to a driver.
@param ControllerHandle Handle of the controller to be
connected.
@param ContextDriverImageHandles DriverImageHandle A pointer to an
ordered list of driver image
handles.
@param RemainingDevicePath RemainingDevicePath A pointer to
the device path that specifies a
child of the controller
specified by ControllerHandle.
@retval EFI_SUCCESS One or more drivers were
connected to ControllerHandle.
@retval EFI_OUT_OF_RESOURCES No enough system resources to
complete the request.
@retval EFI_NOT_FOUND No drivers were connected to
ControllerHandle.
**/
EFI_STATUS
CoreConnectSingleController (
IN EFI_HANDLE ControllerHandle,
IN EFI_HANDLE *ContextDriverImageHandles OPTIONAL,
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
);
// //
// Driver Support Functions // Driver Support Functions
// //
/** /**
Connects one or more drivers to a controller. Connects one or more drivers to a controller.
@ -114,10 +83,10 @@ CoreConnectController (
// //
do { do {
ReturnStatus = CoreConnectSingleController ( ReturnStatus = CoreConnectSingleController (
ControllerHandle, ControllerHandle,
DriverImageHandle, DriverImageHandle,
AlignedRemainingDevicePath AlignedRemainingDevicePath
); );
} while (ReturnStatus == EFI_NOT_READY); } while (ReturnStatus == EFI_NOT_READY);
// //
@ -269,7 +238,7 @@ AddSortedDriverBindingProtocol (
Status = CoreHandleProtocol ( Status = CoreHandleProtocol (
DriverBindingHandleBuffer[Index], DriverBindingHandleBuffer[Index],
&gEfiDriverBindingProtocolGuid, &gEfiDriverBindingProtocolGuid,
(VOID **)&DriverBinding (VOID **) &DriverBinding
); );
if (EFI_ERROR (Status) || DriverBinding == NULL) { if (EFI_ERROR (Status) || DriverBinding == NULL) {
continue; continue;
@ -299,7 +268,7 @@ AddSortedDriverBindingProtocol (
Status = CoreHandleProtocol( Status = CoreHandleProtocol(
DriverBindingHandle, DriverBindingHandle,
&gEfiDriverBindingProtocolGuid, &gEfiDriverBindingProtocolGuid,
(VOID **)&DriverBinding (VOID **) &DriverBinding
); );
// //
// If DriverBindingHandle does not support the Driver Binding Protocol then return // If DriverBindingHandle does not support the Driver Binding Protocol then return
@ -435,7 +404,7 @@ CoreConnectSingleController (
Status = CoreLocateProtocol ( Status = CoreLocateProtocol (
&gEfiPlatformDriverOverrideProtocolGuid, &gEfiPlatformDriverOverrideProtocolGuid,
NULL, NULL,
(VOID **)&PlatformDriverOverride (VOID **) &PlatformDriverOverride
); );
if (!EFI_ERROR (Status) && (PlatformDriverOverride != NULL)) { if (!EFI_ERROR (Status) && (PlatformDriverOverride != NULL)) {
DriverImageHandle = NULL; DriverImageHandle = NULL;
@ -464,7 +433,7 @@ CoreConnectSingleController (
Status = CoreHandleProtocol ( Status = CoreHandleProtocol (
ControllerHandle, ControllerHandle,
&gEfiBusSpecificDriverOverrideProtocolGuid, &gEfiBusSpecificDriverOverrideProtocolGuid,
(VOID **)&BusSpecificDriverOverride (VOID **) &BusSpecificDriverOverride
); );
if (!EFI_ERROR (Status) && (BusSpecificDriverOverride != NULL)) { if (!EFI_ERROR (Status) && (BusSpecificDriverOverride != NULL)) {
DriverImageHandle = NULL; DriverImageHandle = NULL;

View File

@ -21,7 +21,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
// gProtocolDatabaseLock - Lock to protect the mProtocolDatabase // gProtocolDatabaseLock - Lock to protect the mProtocolDatabase
// gHandleDatabaseKey - The Key to show that the handle has been created/modified // gHandleDatabaseKey - The Key to show that the handle has been created/modified
// //
STATIC LIST_ENTRY mProtocolDatabase = INITIALIZE_LIST_HEAD_VARIABLE (mProtocolDatabase); LIST_ENTRY mProtocolDatabase = INITIALIZE_LIST_HEAD_VARIABLE (mProtocolDatabase);
LIST_ENTRY gHandleList = INITIALIZE_LIST_HEAD_VARIABLE (gHandleList); LIST_ENTRY gHandleList = INITIALIZE_LIST_HEAD_VARIABLE (gHandleList);
EFI_LOCK gProtocolDatabaseLock = EFI_INITIALIZE_LOCK_VARIABLE (TPL_NOTIFY); EFI_LOCK gProtocolDatabaseLock = EFI_INITIALIZE_LOCK_VARIABLE (TPL_NOTIFY);
UINT64 gHandleDatabaseKey = 0; UINT64 gHandleDatabaseKey = 0;
@ -139,7 +139,7 @@ CoreFindProtocolEntry (
// Initialize new protocol entry structure // Initialize new protocol entry structure
// //
ProtEntry->Signature = PROTOCOL_ENTRY_SIGNATURE; ProtEntry->Signature = PROTOCOL_ENTRY_SIGNATURE;
CopyMem ((VOID *)&ProtEntry->ProtocolID, Protocol, sizeof (EFI_GUID)); CopyGuid ((VOID *)&ProtEntry->ProtocolID, Protocol);
InitializeListHead (&ProtEntry->Protocols); InitializeListHead (&ProtEntry->Protocols);
InitializeListHead (&ProtEntry->Notify); InitializeListHead (&ProtEntry->Notify);

View File

@ -139,10 +139,10 @@ CoreLocateHandle (
} }
GetNext = NULL; GetNext = NULL;
// //
// Set initial position // Set initial position
// //
Position.Protocol = Protocol; Position.Protocol = Protocol;
Position.SearchKey = SearchKey; Position.SearchKey = SearchKey;
Position.Position = &gHandleList; Position.Position = &gHandleList;
@ -154,7 +154,6 @@ CoreLocateHandle (
// //
// Lock the protocol database // Lock the protocol database
// //
CoreAcquireProtocolLock (); CoreAcquireProtocolLock ();
// //
@ -267,9 +266,8 @@ CoreLocateHandle (
@param Interface Return the interface structure for the matching @param Interface Return the interface structure for the matching
protocol. protocol.
@retval IHANDLE An IHANDLE is returned if the next Position is @return An pointer to IHANDLE if the next Position is not the end of the list.
not the end of the list. A NULL_HANDLE is Otherwise,NULL_HANDLE is returned.
returned if it's the end of the list.
**/ **/
IHANDLE * IHANDLE *
@ -307,9 +305,8 @@ CoreGetNextLocateAllHandles (
@param Interface Return the interface structure for the matching @param Interface Return the interface structure for the matching
protocol. protocol.
@retval IHANDLE An IHANDLE is returned if the next Position is @return An pointer to IHANDLE if the next Position is not the end of the list.
not the end of the list. A NULL_HANDLE is Otherwise,NULL_HANDLE is returned.
returned if it's the end of the list.
**/ **/
IHANDLE * IHANDLE *
@ -349,7 +346,6 @@ CoreGetNextLocateByRegisterNotify (
} }
/** /**
Routine to get the next Handle, when you are searching for a given protocol. Routine to get the next Handle, when you are searching for a given protocol.
@ -357,9 +353,8 @@ CoreGetNextLocateByRegisterNotify (
@param Interface Return the interface structure for the matching @param Interface Return the interface structure for the matching
protocol. protocol.
@retval IHANDLE An IHANDLE is returned if the next Position is @return An pointer to IHANDLE if the next Position is not the end of the list.
not the end of the list. A NULL_HANDLE is Otherwise,NULL_HANDLE is returned.
returned if it's the end of the list.
**/ **/
IHANDLE * IHANDLE *
@ -410,8 +405,6 @@ CoreGetNextLocateByProtocol (
} }
/** /**
Locates the handle to a device on the device path that best matches the specified protocol. Locates the handle to a device on the device path that best matches the specified protocol.
@ -529,9 +522,7 @@ CoreLocateDevicePath (
} }
/**
/**
Return the first Protocol Interface that matches the Protocol GUID. If Return the first Protocol Interface that matches the Protocol GUID. If
Registration is pasased in return a Protocol Instance that was just add Registration is pasased in return a Protocol Instance that was just add
to the system. If Retistration is NULL return the first Protocol Interface to the system. If Retistration is NULL return the first Protocol Interface
@ -585,7 +576,7 @@ CoreLocateProtocol (
mEfiLocateHandleRequest += 1; mEfiLocateHandleRequest += 1;
if (NULL == Registration) { if (Registration == NULL) {
// //
// Look up the protocol entry and set the head pointer // Look up the protocol entry and set the head pointer
// //
@ -601,9 +592,9 @@ CoreLocateProtocol (
Handle = CoreGetNextLocateByRegisterNotify (&Position, Interface); Handle = CoreGetNextLocateByRegisterNotify (&Position, Interface);
} }
if (NULL == Handle) { if (Handle == NULL) {
Status = EFI_NOT_FOUND; Status = EFI_NOT_FOUND;
} else if (NULL != Registration) { } else if (Registration != NULL) {
// //
// If this is a search by register notify and a handle was // If this is a search by register notify and a handle was
// returned, update the register notification position // returned, update the register notification position
@ -618,8 +609,6 @@ Done:
} }
/** /**
Function returns an array of handles that support the requested protocol Function returns an array of handles that support the requested protocol
in a buffer allocated from pool. This is a version of CoreLocateHandle() in a buffer allocated from pool. This is a version of CoreLocateHandle()
@ -639,7 +628,7 @@ Done:
@retval EFI_NOT_FOUND No handles match the search. @retval EFI_NOT_FOUND No handles match the search.
@retval EFI_OUT_OF_RESOURCES There is not enough pool memory to store the @retval EFI_OUT_OF_RESOURCES There is not enough pool memory to store the
matching results. matching results.
@retval EFI_INVALID_PARAMETER Invalid parameter @retval EFI_INVALID_PARAMETER One or more paramters are not valid.
**/ **/
EFI_STATUS EFI_STATUS
@ -699,7 +688,7 @@ CoreLocateHandleBuffer (
*Buffer *Buffer
); );
*NumberHandles = BufferSize/sizeof(EFI_HANDLE); *NumberHandles = BufferSize / sizeof(EFI_HANDLE);
if (EFI_ERROR(Status)) { if (EFI_ERROR(Status)) {
*NumberHandles = 0; *NumberHandles = 0;
} }

View File

@ -71,7 +71,6 @@ CoreRemoveInterfaceFromProtocol (
// //
// If there's a protocol notify location pointing to this entry, back it up one // If there's a protocol notify location pointing to this entry, back it up one
// //
for(Link = ProtEntry->Notify.ForwardLink; Link != &ProtEntry->Notify; Link=Link->ForwardLink) { for(Link = ProtEntry->Notify.ForwardLink; Link != &ProtEntry->Notify; Link=Link->ForwardLink) {
ProtNotify = CR(Link, PROTOCOL_NOTIFY, Link, PROTOCOL_NOTIFY_SIGNATURE); ProtNotify = CR(Link, PROTOCOL_NOTIFY, Link, PROTOCOL_NOTIFY_SIGNATURE);
@ -83,7 +82,6 @@ CoreRemoveInterfaceFromProtocol (
// //
// Remove the protocol interface entry // Remove the protocol interface entry
// //
RemoveEntryList (&Prot->ByProtocol); RemoveEntryList (&Prot->ByProtocol);
} }
@ -91,8 +89,6 @@ CoreRemoveInterfaceFromProtocol (
} }
/** /**
Add a new protocol notification record for the request protocol. Add a new protocol notification record for the request protocol.
@ -111,11 +107,11 @@ EFIAPI
CoreRegisterProtocolNotify ( CoreRegisterProtocolNotify (
IN EFI_GUID *Protocol, IN EFI_GUID *Protocol,
IN EFI_EVENT Event, IN EFI_EVENT Event,
OUT VOID **Registration OUT VOID **Registration
) )
{ {
PROTOCOL_ENTRY *ProtEntry; PROTOCOL_ENTRY *ProtEntry;
PROTOCOL_NOTIFY *ProtNotify; PROTOCOL_NOTIFY *ProtNotify;
EFI_STATUS Status; EFI_STATUS Status;
if ((Protocol == NULL) || (Event == NULL) || (Registration == NULL)) { if ((Protocol == NULL) || (Event == NULL) || (Registration == NULL)) {
@ -136,9 +132,7 @@ CoreRegisterProtocolNotify (
// //
// Allocate a new notification record // Allocate a new notification record
// //
ProtNotify = CoreAllocateBootServicesPool (sizeof(PROTOCOL_NOTIFY)); ProtNotify = CoreAllocateBootServicesPool (sizeof(PROTOCOL_NOTIFY));
if (ProtNotify != NULL) { if (ProtNotify != NULL) {
ProtNotify->Signature = PROTOCOL_NOTIFY_SIGNATURE; ProtNotify->Signature = PROTOCOL_NOTIFY_SIGNATURE;
@ -170,8 +164,6 @@ CoreRegisterProtocolNotify (
} }
/** /**
Reinstall a protocol interface on a device handle. The OldInterface for Protocol is replaced by the NewInterface. Reinstall a protocol interface on a device handle. The OldInterface for Protocol is replaced by the NewInterface.
@ -274,11 +266,11 @@ CoreReinstallProtocolInterface (
// //
CoreReleaseProtocolLock (); CoreReleaseProtocolLock ();
Status = CoreConnectController ( Status = CoreConnectController (
UserHandle, UserHandle,
NULL, NULL,
NULL, NULL,
TRUE TRUE
); );
CoreAcquireProtocolLock (); CoreAcquireProtocolLock ();
// //

View File

@ -416,8 +416,8 @@ CoreLoadPeImage (
Status = Image->Ebc->CreateThunk ( Status = Image->Ebc->CreateThunk (
Image->Ebc, Image->Ebc,
Image->Handle, Image->Handle,
(VOID *)(UINTN)Image->ImageContext.EntryPoint, (VOID *)(UINTN) Image->ImageContext.EntryPoint,
(VOID **)&Image->EntryPoint (VOID **) &Image->EntryPoint
); );
if (EFI_ERROR(Status)) { if (EFI_ERROR(Status)) {
goto Done; goto Done;
@ -466,20 +466,12 @@ CoreLoadPeImage (
UINTN StartIndex; UINTN StartIndex;
CHAR8 EfiFileName[256]; CHAR8 EfiFileName[256];
if (Image->ImageContext.Machine != IMAGE_FILE_MACHINE_IA64) {
DEBUG ((DEBUG_INFO | DEBUG_LOAD, DEBUG ((DEBUG_INFO | DEBUG_LOAD,
"Loading driver at 0x%10p EntryPoint=0x%10p ", "Loading driver at 0x%10p EntryPoint=0x%10p ",
(VOID *)(UINTN)Image->ImageContext.ImageAddress, (VOID *)(UINTN) Image->ImageContext.ImageAddress,
(VOID *)(UINTN)Image->ImageContext.EntryPoint)); FUNCTION_ENTRY_POINT ((UINTN) Image->ImageContext.EntryPoint)));
} else {
//
// For IPF Image, the real entry point should be print.
//
DEBUG ((DEBUG_INFO | DEBUG_LOAD,
"Loading driver at 0x%10p EntryPoint=0x%10p ",
(VOID *)(UINTN)Image->ImageContext.ImageAddress,
(VOID *)(UINTN)(*(UINT64 *)(UINTN)Image->ImageContext.EntryPoint)));
}
// //
// Print Module Name by Pdb file path // Print Module Name by Pdb file path
@ -559,7 +551,7 @@ CoreLoadedImageInfo (
if (!EFI_ERROR (Status)) { if (!EFI_ERROR (Status)) {
Image = LOADED_IMAGE_PRIVATE_DATA_FROM_THIS (LoadedImage); Image = LOADED_IMAGE_PRIVATE_DATA_FROM_THIS (LoadedImage);
} else { } else {
DEBUG ((DEBUG_LOAD, "CoreLoadedImageInfo: Not an ImageHandle %x\n", ImageHandle)); DEBUG ((DEBUG_LOAD, "CoreLoadedImageInfo: Not an ImageHandle %p\n", ImageHandle));
Image = NULL; Image = NULL;
} }
@ -698,7 +690,7 @@ CoreLoadImageCommon (
Status = CoreHandleProtocol (DeviceHandle, &gEfiDevicePathProtocolGuid, (VOID **)&HandleFilePath); Status = CoreHandleProtocol (DeviceHandle, &gEfiDevicePathProtocolGuid, (VOID **)&HandleFilePath);
if (!EFI_ERROR (Status)) { if (!EFI_ERROR (Status)) {
FilePathSize = CoreDevicePathSize (HandleFilePath) - sizeof(EFI_DEVICE_PATH_PROTOCOL); FilePathSize = CoreDevicePathSize (HandleFilePath) - sizeof(EFI_DEVICE_PATH_PROTOCOL);
FilePath = (EFI_DEVICE_PATH_PROTOCOL *) ( ((UINT8 *)FilePath) + FilePathSize ); FilePath = (EFI_DEVICE_PATH_PROTOCOL *) (((UINT8 *)FilePath) + FilePathSize );
} }
// //
@ -1061,12 +1053,7 @@ CoreStartImage (
DEBUG_CODE_BEGIN (); DEBUG_CODE_BEGIN ();
if (Image->ExitDataSize != 0 || Image->ExitData != NULL) { if (Image->ExitDataSize != 0 || Image->ExitData != NULL) {
DEBUG ( DEBUG ((DEBUG_LOAD, "StartImage: ExitDataSize %d, ExitData %x", Image->ExitDataSize, Image->ExitData));
(DEBUG_LOAD,
"StartImage: ExitDataSize %d, ExitData %x",
Image->ExitDataSize,
Image->ExitData)
);
if (Image->ExitData != NULL) { if (Image->ExitData != NULL) {
DEBUG ((DEBUG_LOAD, " (%hs)", Image->ExitData)); DEBUG ((DEBUG_LOAD, " (%hs)", Image->ExitData));
} }

View File

@ -79,7 +79,7 @@ CoreOpenImageFile (
if (SourceBuffer != NULL) { if (SourceBuffer != NULL) {
ImageFileHandle->Source = SourceBuffer; ImageFileHandle->Source = SourceBuffer;
ImageFileHandle->SourceSize = SourceSize; ImageFileHandle->SourceSize = SourceSize;
*DeviceHandle = NULL; *DeviceHandle = NULL;
CoreLocateDevicePath (&gEfiDevicePathProtocolGuid, FilePath, DeviceHandle); CoreLocateDevicePath (&gEfiDevicePathProtocolGuid, FilePath, DeviceHandle);
if (SourceSize > 0) { if (SourceSize > 0) {
Status = EFI_SUCCESS; Status = EFI_SUCCESS;
@ -252,7 +252,7 @@ CoreOpenImageFile (
// //
// Read the file into the buffer we allocated // Read the file into the buffer we allocated
// //
ImageFileHandle->SourceSize = (UINTN)FileInfo->FileSize; ImageFileHandle->SourceSize = (UINTN) FileInfo->FileSize;
ImageFileHandle->FreeBuffer = TRUE; ImageFileHandle->FreeBuffer = TRUE;
Status = FileHandle->Read (FileHandle, &ImageFileHandle->SourceSize, ImageFileHandle->Source); Status = FileHandle->Read (FileHandle, &ImageFileHandle->SourceSize, ImageFileHandle->Source);
@ -277,11 +277,11 @@ CoreOpenImageFile (
TempFilePath = *FilePath; TempFilePath = *FilePath;
Status = CoreDevicePathToInterface ( Status = CoreDevicePathToInterface (
&gEfiLoadFileProtocolGuid, &gEfiLoadFileProtocolGuid,
&TempFilePath, &TempFilePath,
(VOID*)&LoadFile, (VOID*) &LoadFile,
DeviceHandle DeviceHandle
); );
if (!EFI_ERROR (Status)) { if (!EFI_ERROR (Status)) {
// //
// Call LoadFile with the correct buffer size // Call LoadFile with the correct buffer size
@ -333,7 +333,6 @@ Done:
/** /**
Read image file (specified by UserHandle) into user specified buffer with specified offset Read image file (specified by UserHandle) into user specified buffer with specified offset
and length. and length.
@ -449,7 +448,6 @@ CoreGrowBuffer (
// //
// If the status code is "buffer too small", resize the buffer // If the status code is "buffer too small", resize the buffer
// //
if (*Status == EFI_BUFFER_TOO_SMALL) { if (*Status == EFI_BUFFER_TOO_SMALL) {
if (*Buffer != NULL) { if (*Buffer != NULL) {
CoreFreePool (*Buffer); CoreFreePool (*Buffer);

View File

@ -120,7 +120,7 @@ CoreAllocateZeroBootServicesPool (
VOID *Memory; VOID *Memory;
Memory = CoreAllocateBootServicesPool (AllocationSize); Memory = CoreAllocateBootServicesPool (AllocationSize);
SetMem (Memory, (Memory == NULL) ? 0 : AllocationSize, 0); ZeroMem (Memory, (Memory == NULL) ? 0 : AllocationSize);
return Memory; return Memory;
} }
@ -321,7 +321,7 @@ CoreDevicePathSize (
// //
// Compute the size and add back in the size of the end device path structure // Compute the size and add back in the size of the end device path structure
// //
return ((UINTN)DevicePath - (UINTN)Start) + sizeof(EFI_DEVICE_PATH_PROTOCOL); return ((UINTN) DevicePath - (UINTN) Start) + sizeof(EFI_DEVICE_PATH_PROTOCOL);
} }
@ -394,8 +394,6 @@ CoreDuplicateDevicePath (
} }
/** /**
Function is used to append a Src1 and Src2 together. Function is used to append a Src1 and Src2 together.
@ -445,8 +443,6 @@ CoreAppendDevicePath (
} }
/** /**
Create a protocol notification event and return it. Create a protocol notification event and return it.
@ -479,25 +475,23 @@ CoreCreateProtocolNotifyEvent (
// //
// Create the event // Create the event
// //
Status = CoreCreateEvent ( Status = CoreCreateEvent (
EVT_NOTIFY_SIGNAL, EVT_NOTIFY_SIGNAL,
NotifyTpl, NotifyTpl,
NotifyFunction, NotifyFunction,
NotifyContext, NotifyContext,
&Event &Event
); );
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
// //
// Register for protocol notifactions on this event // Register for protocol notifactions on this event
// //
Status = CoreRegisterProtocolNotify ( Status = CoreRegisterProtocolNotify (
ProtocolGuid, ProtocolGuid,
Event, Event,
Registration Registration
); );
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
if (SignalFlag) { if (SignalFlag) {

View File

@ -46,8 +46,8 @@ UINTN mFreeMapStack = 0;
// //
// This list maintain the free memory map list // This list maintain the free memory map list
// //
LIST_ENTRY mFreeMemoryMapEntryList = INITIALIZE_LIST_HEAD_VARIABLE (mFreeMemoryMapEntryList); LIST_ENTRY mFreeMemoryMapEntryList = INITIALIZE_LIST_HEAD_VARIABLE (mFreeMemoryMapEntryList);
BOOLEAN mMemoryTypeInformationInitialized = FALSE; BOOLEAN mMemoryTypeInformationInitialized = FALSE;
EFI_MEMORY_TYPE_STAISTICS mMemoryTypeStatistics[EfiMaxMemoryType + 1] = { EFI_MEMORY_TYPE_STAISTICS mMemoryTypeStatistics[EfiMaxMemoryType + 1] = {
{ 0, EFI_MAX_ADDRESS, 0, 0, EfiMaxMemoryType, TRUE, FALSE }, // EfiReservedMemoryType { 0, EFI_MAX_ADDRESS, 0, 0, EfiMaxMemoryType, TRUE, FALSE }, // EfiReservedMemoryType
@ -110,8 +110,6 @@ PromoteMemoryResource (
byte of a page byte of a page
@param Attribute The attributes of the memory range to add @param Attribute The attributes of the memory range to add
@return None. The range is added to the memory map
**/ **/
VOID VOID
CoreAddRange ( CoreAddRange (
@ -613,7 +611,7 @@ CoreFreeMemoryMapStack (
**/ **/
VOID VOID
RemoveMemoryMapEntry ( RemoveMemoryMapEntry (
MEMORY_MAP *Entry IN OUT MEMORY_MAP *Entry
) )
{ {
RemoveEntryList (&Entry->Link); RemoveEntryList (&Entry->Link);
@ -1151,9 +1149,6 @@ Done:
} }
/** /**
Frees previous allocated pages. Frees previous allocated pages.
@ -1235,8 +1230,6 @@ CoreFreePages (
} }
/** /**
This function returns a copy of the current memory map. The map is an array of This function returns a copy of the current memory map. The map is an array of
memory descriptors, each of which describes a contiguous block of memory. memory descriptors, each of which describes a contiguous block of memory.
@ -1373,7 +1366,7 @@ CoreGetMemoryMap (
if (mMemoryTypeStatistics[Type].Special && if (mMemoryTypeStatistics[Type].Special &&
mMemoryTypeStatistics[Type].NumberOfPages > 0 && mMemoryTypeStatistics[Type].NumberOfPages > 0 &&
Entry->Start >= mMemoryTypeStatistics[Type].BaseAddress && Entry->Start >= mMemoryTypeStatistics[Type].BaseAddress &&
Entry->End <= mMemoryTypeStatistics[Type].MaximumAddress ) { Entry->End <= mMemoryTypeStatistics[Type].MaximumAddress) {
MemoryMap->Type = Type; MemoryMap->Type = Type;
} }
} }
@ -1467,7 +1460,7 @@ CoreAllocatePoolPages (
CoreConvertPages (Start, NumberOfPages, PoolType); CoreConvertPages (Start, NumberOfPages, PoolType);
} }
return (VOID *)(UINTN)Start; return (VOID *)(UINTN) Start;
} }

View File

@ -68,13 +68,15 @@ typedef struct {
LIST_ENTRY Link; LIST_ENTRY Link;
} POOL; } POOL;
//
POOL PoolHead[EfiMaxMemoryType]; // Pool header for each memory type.
LIST_ENTRY PoolHeadList; //
POOL mPoolHead[EfiMaxMemoryType];
// //
// List of pool header to search for the appropriate memory type.
// //
// LIST_ENTRY mPoolHeadList;
/** /**
@ -90,14 +92,14 @@ CoreInitializePool (
UINTN Index; UINTN Index;
for (Type=0; Type < EfiMaxMemoryType; Type++) { for (Type=0; Type < EfiMaxMemoryType; Type++) {
PoolHead[Type].Signature = 0; mPoolHead[Type].Signature = 0;
PoolHead[Type].Used = 0; mPoolHead[Type].Used = 0;
PoolHead[Type].MemoryType = (EFI_MEMORY_TYPE) Type; mPoolHead[Type].MemoryType = (EFI_MEMORY_TYPE) Type;
for (Index=0; Index < MAX_POOL_LIST; Index++) { for (Index=0; Index < MAX_POOL_LIST; Index++) {
InitializeListHead (&PoolHead[Type].FreeList[Index]); InitializeListHead (&mPoolHead[Type].FreeList[Index]);
} }
} }
InitializeListHead (&PoolHeadList); InitializeListHead (&mPoolHeadList);
} }
@ -119,12 +121,12 @@ LookupPoolHead (
UINTN Index; UINTN Index;
if (MemoryType >= 0 && MemoryType < EfiMaxMemoryType) { if (MemoryType >= 0 && MemoryType < EfiMaxMemoryType) {
return &PoolHead[MemoryType]; return &mPoolHead[MemoryType];
} }
if (MemoryType < 0) { if (MemoryType < 0) {
for (Link = PoolHeadList.ForwardLink; Link != &PoolHeadList; Link = Link->ForwardLink) { for (Link = mPoolHeadList.ForwardLink; Link != &mPoolHeadList; Link = Link->ForwardLink) {
Pool = CR(Link, POOL, Link, POOL_SIGNATURE); Pool = CR(Link, POOL, Link, POOL_SIGNATURE);
if (Pool->MemoryType == MemoryType) { if (Pool->MemoryType == MemoryType) {
return Pool; return Pool;
@ -143,7 +145,7 @@ LookupPoolHead (
InitializeListHead (&Pool->FreeList[Index]); InitializeListHead (&Pool->FreeList[Index]);
} }
InsertHeadList (&PoolHeadList, &Pool->Link); InsertHeadList (&mPoolHeadList, &Pool->Link);
return Pool; return Pool;
} }
@ -153,7 +155,6 @@ LookupPoolHead (
/** /**
Allocate pool of a particular type. Allocate pool of a particular type.
@ -331,14 +332,13 @@ Done:
Buffer = Head->Data; Buffer = Head->Data;
DEBUG_CLEAR_MEMORY (Buffer, Size - POOL_OVERHEAD); DEBUG_CLEAR_MEMORY (Buffer, Size - POOL_OVERHEAD);
DEBUG ( DEBUG ((
(DEBUG_POOL, DEBUG_POOL,
"AllocatePoolI: Type %x, Addr %x (len %x) %,d\n", "AllocatePoolI: Type %x, Addr %x (len %x) %,d\n", PoolType,
PoolType, Buffer,
Buffer, Size - POOL_OVERHEAD,
Size - POOL_OVERHEAD, Pool->Used
Pool->Used) ));
);
// //
// Account the allocation // Account the allocation
@ -354,7 +354,6 @@ Done:
/** /**
Frees pool. Frees pool.
@ -372,7 +371,7 @@ CoreFreePool (
{ {
EFI_STATUS Status; EFI_STATUS Status;
if (NULL == Buffer) { if (Buffer == NULL) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
@ -486,7 +485,7 @@ CoreFreePoolI (
// //
NewPage = (CHAR8 *)((UINTN)Free & ~((DEFAULT_PAGE_ALLOCATION) -1)); NewPage = (CHAR8 *)((UINTN)Free & ~((DEFAULT_PAGE_ALLOCATION) -1));
Free = (POOL_FREE *) &NewPage[0]; Free = (POOL_FREE *) &NewPage[0];
ASSERT(NULL != Free); ASSERT(Free != NULL);
if (Free->Signature == POOL_FREE_SIGNATURE) { if (Free->Signature == POOL_FREE_SIGNATURE) {

View File

@ -16,13 +16,13 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include <DxeMain.h> #include <DxeMain.h>
STATIC EFI_DEBUG_IMAGE_INFO_TABLE_HEADER mDebugInfoTableHeader = { EFI_DEBUG_IMAGE_INFO_TABLE_HEADER mDebugInfoTableHeader = {
0, // volatile UINT32 UpdateStatus; 0, // volatile UINT32 UpdateStatus;
0, // UINT32 TableSize; 0, // UINT32 TableSize;
NULL // EFI_DEBUG_IMAGE_INFO *EfiDebugImageInfoTable; NULL // EFI_DEBUG_IMAGE_INFO *EfiDebugImageInfoTable;
}; };
STATIC EFI_SYSTEM_TABLE_POINTER *mDebugTable = NULL; EFI_SYSTEM_TABLE_POINTER *mDebugTable = NULL;

View File

@ -182,7 +182,7 @@ CoreInstallConfigurationTable (
// //
// Fill in the new entry // Fill in the new entry
// //
CopyMem ((VOID *)&EfiConfigurationTable[Index].VendorGuid, Guid, sizeof (EFI_GUID)); CopyGuid ((VOID *)&EfiConfigurationTable[Index].VendorGuid, Guid);
EfiConfigurationTable[Index].VendorTable = Table; EfiConfigurationTable[Index].VendorTable = Table;
// //

View File

@ -99,7 +99,6 @@ typedef struct {
// //
// Local prototypes // Local prototypes
// //
/** /**
Worker function. Determine if the input stream:child matches the input type. Worker function. Determine if the input stream:child matches the input type.
@ -123,41 +122,6 @@ ChildIsType (
IN EFI_GUID *SectionDefinitionGuid IN EFI_GUID *SectionDefinitionGuid
); );
#if 0
/**
RPN callback function. Removes a stale section stream and re-initializes it
with an updated AuthenticationStatus.
@param Event The event that fired
@param RpnContext A pointer to the context that allows us to
identify the relevent encapsulation...
**/
VOID
EFIAPI
NotifyGuidedExtraction (
IN EFI_EVENT Event,
IN VOID *RpnContext
);
#endif
#if 0
/**
Worker function. Constructor for RPN event if needed to keep AuthenticationStatus
cache correct when a missing GUIDED_SECTION_EXTRACTION_PROTOCOL appears...
@param ParentStream Indicates the parent of the ecnapsulation
section (child)
@param ChildNode Indicates the child node that is the
encapsulation section.
**/
VOID
CreateGuidedExtractionRpnEvent (
IN CORE_SECTION_STREAM_NODE *ParentStream,
IN CORE_SECTION_CHILD_NODE *ChildNode
);
#endif
/** /**
Worker function. Search stream database for requested stream handle. Worker function. Search stream database for requested stream handle.
@ -177,6 +141,7 @@ FindStreamNode (
OUT CORE_SECTION_STREAM_NODE **FoundStream OUT CORE_SECTION_STREAM_NODE **FoundStream
); );
/** /**
Worker function Recursively searches / builds section stream database Worker function Recursively searches / builds section stream database
looking for requested section. looking for requested section.
@ -214,6 +179,7 @@ FindChildNode (
OUT UINT32 *AuthenticationStatus OUT UINT32 *AuthenticationStatus
); );
/** /**
Worker function. Constructor for new child nodes. Worker function. Constructor for new child nodes.
@ -242,6 +208,7 @@ CreateChildNode (
OUT CORE_SECTION_CHILD_NODE **ChildNode OUT CORE_SECTION_CHILD_NODE **ChildNode
); );
/** /**
Worker function. Destructor for child nodes. Worker function. Destructor for child nodes.
@ -252,7 +219,8 @@ VOID
FreeChildNode ( FreeChildNode (
IN CORE_SECTION_CHILD_NODE *ChildNode IN CORE_SECTION_CHILD_NODE *ChildNode
); );
/** /**
Worker function. Constructor for section streams. Worker function. Constructor for section streams.
@ -294,7 +262,8 @@ OpenSectionStreamEx (
IN UINT32 AuthenticationStatus, IN UINT32 AuthenticationStatus,
OUT UINTN *SectionStreamHandle OUT UINTN *SectionStreamHandle
); );
/** /**
Check if a stream is valid. Check if a stream is valid.
@ -310,6 +279,7 @@ IsValidSectionStream (
IN UINTN SectionStreamLength IN UINTN SectionStreamLength
); );
/** /**
The ExtractSection() function processes the input section and The ExtractSection() function processes the input section and
allocates a buffer from the pool in which it returns the section allocates a buffer from the pool in which it returns the section
@ -339,7 +309,6 @@ IsValidSectionStream (
@param This Indicates the @param This Indicates the
EFI_GUIDED_SECTION_EXTRACTION_PROTOCOL instance. EFI_GUIDED_SECTION_EXTRACTION_PROTOCOL instance.
@param InputSection Buffer containing the input GUIDed section @param InputSection Buffer containing the input GUIDed section
to be processed. OutputBuffer OutputBuffer to be processed. OutputBuffer OutputBuffer
is allocated from boot services pool is allocated from boot services pool
@ -354,7 +323,6 @@ IsValidSectionStream (
is stored. If the function returns is stored. If the function returns
anything other than EFI_SUCCESS, the value anything other than EFI_SUCCESS, the value
of OutputSize is undefined. of OutputSize is undefined.
@param AuthenticationStatus A pointer to a caller-allocated @param AuthenticationStatus A pointer to a caller-allocated
UINT32 that indicates the UINT32 that indicates the
authentication status of the authentication status of the
@ -403,6 +371,7 @@ CustomGuidedSectionExtract (
OUT UINTN *OutputSize, OUT UINTN *OutputSize,
OUT UINT32 *AuthenticationStatus OUT UINT32 *AuthenticationStatus
); );
// //
// Module globals // Module globals
// //
@ -491,12 +460,12 @@ OpenSectionStream (
} }
return OpenSectionStreamEx ( return OpenSectionStreamEx (
SectionStreamLength, SectionStreamLength,
SectionStream, SectionStream,
TRUE, TRUE,
0, 0,
SectionStreamHandle SectionStreamHandle
); );
} }
@ -608,14 +577,14 @@ GetSection (
// There's a requested section type, so go find it and return it... // There's a requested section type, so go find it and return it...
// //
Status = FindChildNode ( Status = FindChildNode (
StreamNode, StreamNode,
*SectionType, *SectionType,
&Instance, &Instance,
SectionDefinitionGuid, SectionDefinitionGuid,
&ChildNode, &ChildNode,
&ChildStreamNode, &ChildStreamNode,
&ExtractedAuthenticationStatus &ExtractedAuthenticationStatus
); );
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
goto GetSection_Done; goto GetSection_Done;
} }
@ -648,6 +617,7 @@ GetSection (
GetSection_Done: GetSection_Done:
CoreRestoreTpl (OldTpl); CoreRestoreTpl (OldTpl);
return Status; return Status;
} }
@ -744,7 +714,6 @@ ChildIsType (
} }
/** /**
Worker function Recursively searches / builds section stream database Worker function Recursively searches / builds section stream database
looking for requested section. looking for requested section.
@ -797,7 +766,7 @@ FindChildNode (
} }
if (IsListEmpty (&SourceStream->Children) && if (IsListEmpty (&SourceStream->Children) &&
SourceStream->StreamLength >= sizeof (EFI_COMMON_SECTION_HEADER)) { SourceStream->StreamLength >= sizeof (EFI_COMMON_SECTION_HEADER)) {
// //
// This occurs when a section stream exists, but no child sections // This occurs when a section stream exists, but no child sections
// have been parsed out yet. Therefore, extract the first child and add it // have been parsed out yet. Therefore, extract the first child and add it
@ -882,7 +851,7 @@ FindChildNode (
// Round up to 4 byte boundary // Round up to 4 byte boundary
// //
NextChildOffset += 3; NextChildOffset += 3;
NextChildOffset &= ~(UINTN)3; NextChildOffset &= ~(UINTN) 3;
if (NextChildOffset <= SourceStream->StreamLength - sizeof (EFI_COMMON_SECTION_HEADER)) { if (NextChildOffset <= SourceStream->StreamLength - sizeof (EFI_COMMON_SECTION_HEADER)) {
// //
// There's an unparsed child remaining in the stream, so create a new child node // There's an unparsed child remaining in the stream, so create a new child node
@ -900,7 +869,6 @@ FindChildNode (
} }
/** /**
Worker function. Constructor for new child nodes. Worker function. Constructor for new child nodes.
@ -1153,120 +1121,6 @@ CreateChildNode (
} }
#if 0
/**
Worker function. Constructor for RPN event if needed to keep AuthenticationStatus
cache correct when a missing GUIDED_SECTION_EXTRACTION_PROTOCOL appears...
@param ParentStream Indicates the parent of the ecnapsulation
section (child)
@param ChildNode Indicates the child node that is the
encapsulation section.
**/
VOID
CreateGuidedExtractionRpnEvent (
IN CORE_SECTION_STREAM_NODE *ParentStream,
IN CORE_SECTION_CHILD_NODE *ChildNode
)
{
RPN_EVENT_CONTEXT *Context;
//
// Allocate new event structure and context
//
Context = CoreAllocateBootServicesPool (sizeof (RPN_EVENT_CONTEXT));
ASSERT (Context != NULL);
Context->ChildNode = ChildNode;
Context->ParentStream = ParentStream;
Context->Event = CoreCreateProtocolNotifyEvent (
Context->ChildNode->EncapsulationGuid,
TPL_NOTIFY,
NotifyGuidedExtraction,
Context,
&Context->Registration,
FALSE
);
}
#endif
#if 0
/**
RPN callback function. Removes a stale section stream and re-initializes it
with an updated AuthenticationStatus.
@param Event The event that fired
@param RpnContext A pointer to the context that allows us to
identify the relevent encapsulation...
**/
VOID
EFIAPI
NotifyGuidedExtraction (
IN EFI_EVENT Event,
IN VOID *RpnContext
)
{
EFI_STATUS Status;
EFI_GUID_DEFINED_SECTION *GuidedHeader;
EFI_GUIDED_SECTION_EXTRACTION_PROTOCOL *GuidedExtraction;
VOID *NewStreamBuffer;
UINTN NewStreamBufferSize;
UINT32 AuthenticationStatus;
RPN_EVENT_CONTEXT *Context;
Context = RpnContext;
Status = CloseSectionStream (Context->ChildNode->EncapsulatedStreamHandle);
if (!EFI_ERROR (Status)) {
//
// The stream closed successfully, so re-open the stream with correct AuthenticationStatus
//
GuidedHeader = (EFI_GUID_DEFINED_SECTION *)
(Context->ParentStream->StreamBuffer + Context->ChildNode->OffsetInStream);
ASSERT (GuidedHeader->CommonHeader.Type == EFI_SECTION_GUID_DEFINED);
Status = CoreLocateProtocol (Context->ChildNode->EncapsulationGuid, NULL, (VOID **)&GuidedExtraction);
ASSERT_EFI_ERROR (Status);
Status = GuidedExtraction->ExtractSection (
GuidedExtraction,
GuidedHeader,
&NewStreamBuffer,
&NewStreamBufferSize,
&AuthenticationStatus
);
ASSERT_EFI_ERROR (Status);
//
// OR in the parent stream's aggregagate status.
//
AuthenticationStatus |= Context->ParentStream->AuthenticationStatus & EFI_AUTH_STATUS_ALL;
Status = OpenSectionStreamEx (
NewStreamBufferSize,
NewStreamBuffer,
FALSE,
AuthenticationStatus,
&Context->ChildNode->EncapsulatedStreamHandle
);
ASSERT_EFI_ERROR (Status);
}
//
// If above, the stream did not close successfully, it indicates it's
// alread been closed by someone, so just destroy the event and be done with
// it.
//
CoreCloseEvent (Event);
CoreFreePool (Context);
}
#endif
/** /**
Worker function. Destructor for child nodes. Worker function. Destructor for child nodes.
@ -1443,7 +1297,6 @@ FindStreamNode (
} }
/** /**
Check if a stream is valid. Check if a stream is valid.
@ -1493,6 +1346,7 @@ IsValidSectionStream (
return FALSE; return FALSE;
} }
/** /**
The ExtractSection() function processes the input section and The ExtractSection() function processes the input section and
allocates a buffer from the pool in which it returns the section allocates a buffer from the pool in which it returns the section
@ -1522,7 +1376,6 @@ IsValidSectionStream (
@param This Indicates the @param This Indicates the
EFI_GUIDED_SECTION_EXTRACTION_PROTOCOL instance. EFI_GUIDED_SECTION_EXTRACTION_PROTOCOL instance.
@param InputSection Buffer containing the input GUIDed section @param InputSection Buffer containing the input GUIDed section
to be processed. OutputBuffer OutputBuffer to be processed. OutputBuffer OutputBuffer
is allocated from boot services pool is allocated from boot services pool
@ -1644,7 +1497,7 @@ CustomGuidedSectionExtract (
OutputBuffer, OutputBuffer,
ScratchBuffer, ScratchBuffer,
AuthenticationStatus AuthenticationStatus
); );
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
// //
// Decode failed // Decode failed