Add doxygen style comments for functions in DxeMain.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@5189 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
qhuang8 2008-05-09 07:08:30 +00:00
parent dc2e539a34
commit 162ed59443
38 changed files with 6088 additions and 7797 deletions

View File

@ -22,99 +22,69 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#define EFI_DEBUG_TABLE_ENTRY_SIZE (sizeof (VOID *))
/**
Creates and initializes the DebugImageInfo Table. Also creates the configuration
table and registers it into the system table.
Note:
This function allocates memory, frees it, and then allocates memory at an
address within the initial allocation. Since this function is called early
in DXE core initialization (before drivers are dispatched), this should not
be a problem.
**/
VOID
CoreInitializeDebugImageInfoTable (
VOID
)
/*++
Routine Description:
Creates and initializes the DebugImageInfo Table. Also creates the configuration
table and registers it into the system table.
Arguments:
None
Returns:
NA
Notes:
This function allocates memory, frees it, and then allocates memory at an
address within the initial allocation. Since this function is called early
in DXE core initialization (before drivers are dispatched), this should not
be a problem.
--*/
;
VOID
CoreUpdateDebugTableCrc32 (
VOID
)
/*++
Routine Description:
/**
Update the CRC32 in the Debug Table.
Since the CRC32 service is made available by the Runtime driver, we have to
wait for the Runtime Driver to be installed before the CRC32 can be computed.
This function is called elsewhere by the core when the runtime architectural
protocol is produced.
Arguments:
None
Returns:
NA
--*/
**/
VOID
CoreUpdateDebugTableCrc32 (
VOID
)
;
/**
Adds a new DebugImageInfo structure to the DebugImageInfo Table. Re-Allocates
the table if it's not large enough to accomidate another entry.
@param ImageInfoType type of debug image information
@param LoadedImage pointer to the loaded image protocol for the image being
loaded
@param ImageHandle image handle for the image being loaded
**/
VOID
CoreNewDebugImageInfoEntry (
UINT32 ImageInfoType,
EFI_LOADED_IMAGE_PROTOCOL *LoadedImage,
EFI_HANDLE ImageHandle
)
/*++
Routine Description:
Adds a new DebugImageInfo structure to the DebugImageInfo Table. Re-Allocates
the table if it's not large enough to accomidate another entry.
Arguments:
ImageInfoType - type of debug image information
LoadedImage - pointer to the loaded image protocol for the image being loaded
ImageHandle - image handle for the image being loaded
Returns:
NA
--*/
;
/**
Removes and frees an entry from the DebugImageInfo Table.
@param ImageHandle image handle for the image being unloaded
**/
VOID
CoreRemoveDebugImageInfoEntry (
EFI_HANDLE ImageHandle
)
/*++
Routine Description:
Removes and frees an entry from the DebugImageInfo Table.
Arguments:
ImageHandle - image handle for the image being unloaded
Returns:
NA
--*/
;
#endif

View File

@ -1,4 +1,4 @@
/**@file
/** @file
DXE Dispatcher.
Step #1 - When a FV protocol is added to the system every driver in the FV
@ -26,7 +26,7 @@
Depex - Dependency Expresion.
SOR - Schedule On Request - Don't schedule if this bit is set.
Copyright (c) 2006 - 2007, Intel Corporation
Copyright (c) 2006 - 2008, Intel Corporation
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@ -94,12 +94,40 @@ FV_FILEPATH_DEVICE_PATH mFvDevicePath;
//
// Function Prototypes
//
/**
Insert InsertedDriverEntry onto the mScheduledQueue. To do this you
must add any driver with a before dependency on InsertedDriverEntry first.
You do this by recursively calling this routine. After all the Befores are
processed you can add InsertedDriverEntry to the mScheduledQueue.
Then you can add any driver with an After dependency on InsertedDriverEntry
by recursively calling this routine.
@param InsertedDriverEntry The driver to insert on the ScheduledLink Queue
**/
STATIC
VOID
CoreInsertOnScheduledQueueWhileProcessingBeforeAndAfter (
IN EFI_CORE_DRIVER_ENTRY *InsertedDriverEntry
);
/**
Event notification that is fired every time a FV dispatch protocol is added.
More than one protocol may have been added when this event is fired, so you
must loop on CoreLocateHandle () to see how many protocols were added and
do the following to each FV:
If the Fv has already been processed, skip it. If the Fv has not been
processed then mark it as being processed, as we are about to process it.
Read the Fv and add any driver in the Fv to the mDiscoveredList.The
mDiscoveredList is never free'ed and contains variables that define
the other states the DXE driver transitions to..
While you are at it read the A Priori file into memory.
Place drivers in the A Priori list onto the mScheduledQueue.
@param Event The Event that is being processed, not used.
@param Context Event Context, not used.
**/
STATIC
VOID
EFIAPI
@ -108,6 +136,19 @@ CoreFwVolEventProtocolNotify (
IN VOID *Context
);
/**
Convert FvHandle and DriverName into an EFI device path
@param Fv Fv protocol, needed to read Depex info out of
FLASH.
@param FvHandle Handle for Fv, needed in the
EFI_CORE_DRIVER_ENTRY so that the PE image can be
read out of the FV at a later time.
@param DriverName Name of driver to add to mDiscoveredList.
@return Pointer to device path constructed from FvHandle and DriverName
**/
STATIC
EFI_DEVICE_PATH_PROTOCOL *
CoreFvToDevicePath (
@ -116,6 +157,26 @@ CoreFvToDevicePath (
IN EFI_GUID *DriverName
);
/**
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
in DriverEntry. Pre-process the Depex to set the SOR, Before and After state.
The Discovered list is never free'ed and contains booleans that represent the
other possible DXE driver states.
@param Fv Fv protocol, needed to read Depex info out of
FLASH.
@param FvHandle Handle for Fv, needed in the
EFI_CORE_DRIVER_ENTRY so that the PE image can be
read out of the FV at a later time.
@param DriverName Name of driver to add to mDiscoveredList.
@retval EFI_SUCCESS If driver was added to the mDiscoveredList.
@retval EFI_ALREADY_STARTED The driver has already been started. Only one
DriverName may be active in the system at any one
time.
**/
STATIC
EFI_STATUS
CoreAddToDriverList (
@ -124,6 +185,18 @@ CoreAddToDriverList (
IN EFI_GUID *DriverName
);
/**
Get the driver from the FV through driver name, and produce a FVB protocol on FvHandle.
@param Fv The FIRMWARE_VOLUME protocol installed on the FV.
@param FvHandle The handle which FVB protocol installed on.
@param DriverName The driver guid specified.
@retval EFI_OUT_OF_RESOURCES No enough memory or other resource.
@retval EFI_VOLUME_CORRUPTED Corrupted volume.
@retval EFI_SUCCESS Function successfully returned.
**/
STATIC
EFI_STATUS
CoreProcessFvImageFile (
@ -132,81 +205,52 @@ CoreProcessFvImageFile (
IN EFI_GUID *DriverName
);
/**
Enter critical section by gaining lock on mDispatcherLock.
**/
STATIC
VOID
CoreAcquireDispatcherLock (
VOID
)
/*++
Routine Description:
Enter critical section by gaining lock on mDispatcherLock
Arguments:
None
Returns:
None
--*/
{
CoreAcquireLock (&mDispatcherLock);
}
/**
Exit critical section by releasing lock on mDispatcherLock.
**/
STATIC
VOID
CoreReleaseDispatcherLock (
VOID
)
/*++
Routine Description:
Exit critical section by releasing lock on mDispatcherLock
Arguments:
None
Returns:
None
--*/
{
CoreReleaseLock (&mDispatcherLock);
}
/**
Read Depex and pre-process the Depex for Before and After. If Section Extraction
protocol returns an error via ReadSection defer the reading of the Depex.
@param DriverEntry Driver to work on.
@retval EFI_SUCCESS Depex read and preprossesed
@retval EFI_PROTOCOL_ERROR The section extraction protocol returned an error
and Depex reading needs to be retried.
@retval Error DEPEX not found.
**/
STATIC
EFI_STATUS
CoreGetDepexSectionAndPreProccess (
IN EFI_CORE_DRIVER_ENTRY *DriverEntry
)
/*++
Routine Description:
Read Depex and pre-process the Depex for Before and After. If Section Extraction
protocol returns an error via ReadSection defer the reading of the Depex.
Arguments:
DriverEntry - Driver to work on.
Returns:
EFI_SUCCESS - Depex read and preprossesed
EFI_PROTOCOL_ERROR - The section extraction protocol returned an error and
Depex reading needs to be retried.
Other Error - DEPEX not found.
--*/
{
EFI_STATUS Status;
EFI_SECTION_TYPE SectionType;
@ -255,6 +299,21 @@ Returns:
return Status;
}
/**
Check every driver and locate a matching one. If the driver is found, the Unrequested
state flag is cleared.
@param FirmwareVolumeHandle The handle of the Firmware Volume that contains
the firmware file specified by DriverName.
@param DriverName The Driver name to put in the Dependent state.
@retval EFI_SUCCESS The DriverName was found and it's SOR bit was
cleared
@retval EFI_NOT_FOUND The DriverName does not exist or it's SOR bit was
not set.
**/
EFI_DXESERVICE
EFI_STATUS
EFIAPI
@ -262,27 +321,6 @@ CoreSchedule (
IN EFI_HANDLE FirmwareVolumeHandle,
IN EFI_GUID *DriverName
)
/*++
Routine Description:
Check every driver and locate a matching one. If the driver is found, the Unrequested
state flag is cleared.
Arguments:
FirmwareVolumeHandle - The handle of the Firmware Volume that contains the firmware
file specified by DriverName.
DriverName - The Driver name to put in the Dependent state.
Returns:
EFI_SUCCESS - The DriverName was found and it's SOR bit was cleared
EFI_NOT_FOUND - The DriverName does not exist or it's SOR bit was not set.
--*/
{
LIST_ENTRY *Link;
EFI_CORE_DRIVER_ENTRY *DriverEntry;
@ -310,6 +348,19 @@ Returns:
}
/**
Convert a driver from the Untrused back to the Scheduled state
@param FirmwareVolumeHandle The handle of the Firmware Volume that contains
the firmware file specified by DriverName.
@param DriverName The Driver name to put in the Scheduled state
@retval EFI_SUCCESS The file was found in the untrusted state, and it
was promoted to the trusted state.
@retval EFI_NOT_FOUND The file was not found in the untrusted state.
**/
EFI_DXESERVICE
EFI_STATUS
EFIAPI
@ -317,27 +368,6 @@ CoreTrust (
IN EFI_HANDLE FirmwareVolumeHandle,
IN EFI_GUID *DriverName
)
/*++
Routine Description:
Convert a driver from the Untrused back to the Scheduled state
Arguments:
FirmwareVolumeHandle - The handle of the Firmware Volume that contains the firmware
file specified by DriverName.
DriverName - The Driver name to put in the Scheduled state
Returns:
EFI_SUCCESS - The file was found in the untrusted state, and it was promoted
to the trusted state.
EFI_NOT_FOUND - The file was not found in the untrusted state.
--*/
{
LIST_ENTRY *Link;
EFI_CORE_DRIVER_ENTRY *DriverEntry;
@ -366,37 +396,29 @@ Returns:
}
/**
This is the main Dispatcher for DXE and it exits when there are no more
drivers to run. Drain the mScheduledQueue and load and start a PE
image for each driver. Search the mDiscoveredList to see if any driver can
be placed on the mScheduledQueue. If no drivers are placed on the
mScheduledQueue exit the function. On exit it is assumed the Bds()
will be called, and when the Bds() exits the Dispatcher will be called
again.
NONE
@retval EFI_ALREADY_STARTED The DXE Dispatcher is already running
@retval EFI_NOT_FOUND No DXE Drivers were dispatched
@retval EFI_SUCCESS One or more DXE Drivers were dispatched
**/
EFI_DXESERVICE
EFI_STATUS
EFIAPI
CoreDispatcher (
VOID
)
/*++
Routine Description:
This is the main Dispatcher for DXE and it exits when there are no more
drivers to run. Drain the mScheduledQueue and load and start a PE
image for each driver. Search the mDiscoveredList to see if any driver can
be placed on the mScheduledQueue. If no drivers are placed on the
mScheduledQueue exit the function. On exit it is assumed the Bds()
will be called, and when the Bds() exits the Dispatcher will be called
again.
Arguments:
NONE
Returns:
EFI_ALREADY_STARTED - The DXE Dispatcher is already running
EFI_NOT_FOUND - No DXE Drivers were dispatched
EFI_SUCCESS - One or more DXE Drivers were dispatched
--*/
{
EFI_STATUS Status;
EFI_STATUS ReturnStatus;
@ -524,31 +546,23 @@ Returns:
return ReturnStatus;
}
/**
Insert InsertedDriverEntry onto the mScheduledQueue. To do this you
must add any driver with a before dependency on InsertedDriverEntry first.
You do this by recursively calling this routine. After all the Befores are
processed you can add InsertedDriverEntry to the mScheduledQueue.
Then you can add any driver with an After dependency on InsertedDriverEntry
by recursively calling this routine.
@param InsertedDriverEntry The driver to insert on the ScheduledLink Queue
**/
STATIC
VOID
CoreInsertOnScheduledQueueWhileProcessingBeforeAndAfter (
IN EFI_CORE_DRIVER_ENTRY *InsertedDriverEntry
)
/*++
Routine Description:
Insert InsertedDriverEntry onto the mScheduledQueue. To do this you
must add any driver with a before dependency on InsertedDriverEntry first.
You do this by recursively calling this routine. After all the Befores are
processed you can add InsertedDriverEntry to the mScheduledQueue.
Then you can add any driver with an After dependency on InsertedDriverEntry
by recursively calling this routine.
Arguments:
InsertedDriverEntry - The driver to insert on the ScheduledLink Queue
Returns:
NONE
--*/
{
LIST_ENTRY *Link;
EFI_CORE_DRIVER_ENTRY *DriverEntry;
@ -595,28 +609,22 @@ Returns:
}
}
/**
Return TRUE if the Fv has been processed, FALSE if not.
@param FvHandle The handle of a FV that's being tested
@retval TRUE Fv protocol on FvHandle has been processed
@retval FALSE Fv protocol on FvHandle has not yet been
processed
**/
STATIC
BOOLEAN
FvHasBeenProcessed (
IN EFI_HANDLE FvHandle
)
/*++
Routine Description:
Return TRUE if the Fv has been processed, FALSE if not.
Arguments:
FvHandle - The handle of a FV that's being tested
Returns:
TRUE - Fv protocol on FvHandle has been processed
FALSE - Fv protocol on FvHandle has not yet been processed
--*/
{
LIST_ENTRY *Link;
KNOWN_HANDLE *KnownHandle;
@ -630,28 +638,20 @@ Returns:
return FALSE;
}
/**
Remember that Fv protocol on FvHandle has had it's drivers placed on the
mDiscoveredList. This fucntion adds entries on the mFvHandleList. Items are
never removed/freed from the mFvHandleList.
@param FvHandle The handle of a FV that has been processed
**/
STATIC
VOID
FvIsBeingProcesssed (
IN EFI_HANDLE FvHandle
)
/*++
Routine Description:
Remember that Fv protocol on FvHandle has had it's drivers placed on the
mDiscoveredList. This fucntion adds entries on the mFvHandleList. Items are
never removed/freed from the mFvHandleList.
Arguments:
FvHandle - The handle of a FV that has been processed
Returns:
None
--*/
{
KNOWN_HANDLE *KnownHandle;
@ -665,6 +665,20 @@ Returns:
/**
Convert FvHandle and DriverName into an EFI device path
@param Fv Fv protocol, needed to read Depex info out of
FLASH.
@param FvHandle Handle for Fv, needed in the
EFI_CORE_DRIVER_ENTRY so that the PE image can be
read out of the FV at a later time.
@param DriverName Name of driver to add to mDiscoveredList.
@return Pointer to device path constructed from FvHandle and DriverName
**/
STATIC
EFI_DEVICE_PATH_PROTOCOL *
CoreFvToDevicePath (
@ -672,26 +686,6 @@ CoreFvToDevicePath (
IN EFI_HANDLE FvHandle,
IN EFI_GUID *DriverName
)
/*++
Routine Description:
Convert FvHandle and DriverName into an EFI device path
Arguments:
Fv - Fv protocol, needed to read Depex info out of FLASH.
FvHandle - Handle for Fv, needed in the EFI_CORE_DRIVER_ENTRY so that the
PE image can be read out of the FV at a later time.
DriverName - Name of driver to add to mDiscoveredList.
Returns:
Pointer to device path constructed from FvHandle and DriverName
--*/
{
EFI_STATUS Status;
EFI_DEVICE_PATH_PROTOCOL *FvDevicePath;
@ -723,39 +717,33 @@ Returns:
/**
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
in DriverEntry. Pre-process the Depex to set the SOR, Before and After state.
The Discovered list is never free'ed and contains booleans that represent the
other possible DXE driver states.
@param Fv Fv protocol, needed to read Depex info out of
FLASH.
@param FvHandle Handle for Fv, needed in the
EFI_CORE_DRIVER_ENTRY so that the PE image can be
read out of the FV at a later time.
@param DriverName Name of driver to add to mDiscoveredList.
@retval EFI_SUCCESS If driver was added to the mDiscoveredList.
@retval EFI_ALREADY_STARTED The driver has already been started. Only one
DriverName may be active in the system at any one
time.
**/
EFI_STATUS
CoreAddToDriverList (
IN EFI_FIRMWARE_VOLUME2_PROTOCOL *Fv,
IN EFI_HANDLE FvHandle,
IN EFI_GUID *DriverName
)
/*++
Routine Description:
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
in DriverEntry. Pre-process the Depex to set the SOR, Before and After state.
The Discovered list is never free'ed and contains booleans that represent the
other possible DXE driver states.
Arguments:
Fv - Fv protocol, needed to read Depex info out of FLASH.
FvHandle - Handle for Fv, needed in the EFI_CORE_DRIVER_ENTRY so that the
PE image can be read out of the FV at a later time.
DriverName - Name of driver to add to mDiscoveredList.
Returns:
EFI_SUCCESS - If driver was added to the mDiscoveredList.
EFI_ALREADY_STARTED - The driver has already been started. Only one DriverName
may be active in the system at any one time.
--*/
{
EFI_CORE_DRIVER_ENTRY *DriverEntry;
@ -784,32 +772,25 @@ Returns:
return EFI_SUCCESS;
}
/**
Check if a FV Image type file (EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE) is
described by a EFI_HOB_FIRMWARE_VOLUME2 Hob.
@param FvHandle The handle which FVB protocol installed on.
@param DriverName The driver guid specified.
@retval TRUE This file is found in a EFI_HOB_FIRMWARE_VOLUME2
Hob.
@retval FALSE Not found.
**/
STATIC
BOOLEAN
FvFoundInHobFv2 (
IN EFI_HANDLE FvHandle,
IN CONST EFI_GUID *DriverName
)
/*++
Routine Description:
Check if a FV Image type file (EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE) is
described by a EFI_HOB_FIRMWARE_VOLUME2 Hob.
Arguments:
FvHandle - The handle which FVB protocol installed on.
DriverName - The driver guid specified.
Returns:
TRUE - This file is found in a EFI_HOB_FIRMWARE_VOLUME2 Hob.
FALSE - Not found.
--*/
{
EFI_PEI_HOB_POINTERS HobFv2;
@ -826,34 +807,25 @@ Returns:
}
/**
Get the driver from the FV through driver name, and produce a FVB protocol on FvHandle.
@param Fv The FIRMWARE_VOLUME protocol installed on the FV.
@param FvHandle The handle which FVB protocol installed on.
@param DriverName The driver guid specified.
@retval EFI_OUT_OF_RESOURCES No enough memory or other resource.
@retval EFI_VOLUME_CORRUPTED Corrupted volume.
@retval EFI_SUCCESS Function successfully returned.
**/
EFI_STATUS
CoreProcessFvImageFile (
IN EFI_FIRMWARE_VOLUME2_PROTOCOL *Fv,
IN EFI_HANDLE FvHandle,
IN EFI_GUID *DriverName
)
/*++
Routine Description:
Get the driver from the FV through driver name, and produce a FVB protocol on FvHandle.
Arguments:
Fv - The FIRMWARE_VOLUME protocol installed on the FV.
FvHandle - The handle which FVB protocol installed on.
DriverName - The driver guid specified.
Returns:
EFI_OUT_OF_RESOURCES - No enough memory or other resource.
EFI_VOLUME_CORRUPTED - Corrupted volume.
EFI_SUCCESS - Function successfully returned.
--*/
{
EFI_STATUS Status;
EFI_SECTION_TYPE SectionType;
@ -932,6 +904,24 @@ Returns:
return Status;
}
/**
Event notification that is fired every time a FV dispatch protocol is added.
More than one protocol may have been added when this event is fired, so you
must loop on CoreLocateHandle () to see how many protocols were added and
do the following to each FV:
If the Fv has already been processed, skip it. If the Fv has not been
processed then mark it as being processed, as we are about to process it.
Read the Fv and add any driver in the Fv to the mDiscoveredList.The
mDiscoveredList is never free'ed and contains variables that define
the other states the DXE driver transitions to..
While you are at it read the A Priori file into memory.
Place drivers in the A Priori list onto the mScheduledQueue.
@param Event The Event that is being processed, not used.
@param Context Event Context, not used.
**/
STATIC
VOID
EFIAPI
@ -939,36 +929,6 @@ CoreFwVolEventProtocolNotify (
IN EFI_EVENT Event,
IN VOID *Context
)
/*++
Routine Description:
Event notification that is fired every time a FV dispatch protocol is added.
More than one protocol may have been added when this event is fired, so you
must loop on CoreLocateHandle () to see how many protocols were added and
do the following to each FV:
If the Fv has already been processed, skip it. If the Fv has not been
processed then mark it as being processed, as we are about to process it.
Read the Fv and add any driver in the Fv to the mDiscoveredList.The
mDiscoveredList is never free'ed and contains variables that define
the other states the DXE driver transitions to..
While you are at it read the A Priori file into memory.
Place drivers in the A Priori list onto the mScheduledQueue.
Arguments:
Event - The Event that is being processed, not used.
Context - Event Context, not used.
Returns:
None
--*/
{
EFI_STATUS Status;
EFI_STATUS GetNextFileStatus;
@ -1181,26 +1141,16 @@ Returns:
}
/**
Initialize the dispatcher. Initialize the notification function that runs when
a FV protocol is added to the system.
**/
VOID
CoreInitializeDispatcher (
VOID
)
/*++
Routine Description:
Initialize the dispatcher. Initialize the notification function that runs when
a FV protocol is added to the system.
Arguments:
NONE
Returns:
NONE
--*/
{
mFwVolEvent = CoreCreateProtocolNotifyEvent (
&gEfiFirmwareVolume2ProtocolGuid,
@ -1215,26 +1165,16 @@ Returns:
//
// Function only used in debug builds
//
/**
Traverse the discovered list for any drivers that were discovered but not loaded
because the dependency experessions evaluated to false.
**/
VOID
CoreDisplayDiscoveredNotDispatched (
VOID
)
/*++
Routine Description:
Traverse the discovered list for any drivers that were discovered but not loaded
because the dependency experessions evaluated to false
Arguments:
NONE
Returns:
NONE
--*/
{
LIST_ENTRY *Link;
EFI_CORE_DRIVER_ENTRY *DriverEntry;
@ -1242,7 +1182,7 @@ Returns:
for (Link = mDiscoveredList.ForwardLink;Link !=&mDiscoveredList; Link = Link->ForwardLink) {
DriverEntry = CR(Link, EFI_CORE_DRIVER_ENTRY, Link, EFI_CORE_DRIVER_ENTRY_SIGNATURE);
if (DriverEntry->Dependent) {
DEBUG ((EFI_D_LOAD, "Driver %g was discovered but not loaded!!\n", &DriverEntry->FileName));
DEBUG ((DEBUG_LOAD, "Driver %g was discovered but not loaded!!\n", &DriverEntry->FileName));
}
}
}

View File

@ -30,32 +30,20 @@ BOOLEAN *mDepexEvaluationStackPointer = NULL;
// Worker functions
//
/**
Grow size of the Depex stack
@retval EFI_SUCCESS Stack successfully growed.
@retval EFI_OUT_OF_RESOURCES There is not enough system memory to grow the
stack.
**/
STATIC
EFI_STATUS
GrowDepexStack (
VOID
)
/*++
Routine Description:
Grow size of the Depex stack
Arguments:
Stack - Old stack on the way in and new stack on the way out
StackSize - New size of the stack
Returns:
EFI_SUCCESS - Stack successfully growed.
EFI_OUT_OF_RESOURCES - There is not enough system memory to grow the stack.
--*/
{
BOOLEAN *NewStack;
UINTN Size;
@ -97,28 +85,22 @@ Returns:
}
/**
Push an element onto the Boolean Stack
@param Value BOOLEAN to push.
@retval EFI_SUCCESS The value was pushed onto the stack.
@retval EFI_OUT_OF_RESOURCES There is not enough system memory to grow the
stack.
**/
STATIC
EFI_STATUS
PushBool (
IN BOOLEAN Value
)
/*++
Routine Description:
Push an element onto the Boolean Stack
Arguments:
Value - BOOLEAN to push.
Returns:
EFI_SUCCESS - The value was pushed onto the stack.
EFI_OUT_OF_RESOURCES - There is not enough system memory to grow the stack.
--*/
{
EFI_STATUS Status;
@ -145,28 +127,21 @@ Returns:
}
/**
Pop an element from the Boolean stack.
@param Value BOOLEAN to pop.
@retval EFI_SUCCESS The value was popped onto the stack.
@retval EFI_ACCESS_DENIED The pop operation underflowed the stack
**/
STATIC
EFI_STATUS
PopBool (
OUT BOOLEAN *Value
)
/*++
Routine Description:
Pop an element from the Boolean stack.
Arguments:
Value - BOOLEAN to pop.
Returns:
EFI_SUCCESS - The value was popped onto the stack.
EFI_ACCESS_DENIED - The pop operation underflowed the stack
--*/
{
//
// Check for a stack underflow condition
@ -184,29 +159,23 @@ Returns:
}
/**
Preprocess dependency expression and update DriverEntry to reflect the
state of Before, After, and SOR dependencies. If DriverEntry->Before
or DriverEntry->After is set it will never be cleared. If SOR is set
it will be cleared by CoreSchedule(), and then the driver can be
dispatched.
@param DriverEntry DriverEntry element to update
@retval EFI_SUCCESS It always works.
**/
EFI_STATUS
CorePreProcessDepex (
IN EFI_CORE_DRIVER_ENTRY *DriverEntry
)
/*++
Routine Description:
Preprocess dependency expression and update DriverEntry to reflect the
state of Before, After, and SOR dependencies. If DriverEntry->Before
or DriverEntry->After is set it will never be cleared. If SOR is set
it will be cleared by CoreSchedule(), and then the driver can be
dispatched.
Arguments:
DriverEntry - DriverEntry element to update
Returns:
EFI_SUCCESS - It always works.
--*/
{
UINT8 *Iterator;
@ -231,31 +200,24 @@ Returns:
}
/**
This is the POSTFIX version of the dependency evaluator. This code does
not need to handle Before or After, as it is not valid to call this
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.
@param DriverEntry DriverEntry element to update
@retval TRUE If driver is ready to run.
@retval FALSE If driver is not ready to run or some fatal error
was found.
**/
BOOLEAN
CoreIsSchedulable (
IN EFI_CORE_DRIVER_ENTRY *DriverEntry
)
/*++
Routine Description:
This is the POSTFIX version of the dependency evaluator. This code does
not need to handle Before or After, as it is not valid to call this
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.
Arguments:
DriverEntry - DriverEntry element to update
Returns:
TRUE - If driver is ready to run.
FALSE - If driver is not ready to run or some fatal error was found.
--*/
{
EFI_STATUS Status;
UINT8 *Iterator;
@ -444,3 +406,4 @@ Done:
return FALSE;
}

File diff suppressed because it is too large Load Diff

View File

@ -1,7 +1,7 @@
/**@file
/** @file
DXE Core Main Entry Point
Copyright (c) 2006 - 2007, Intel Corporation
Copyright (c) 2006 - 2008, Intel Corporation
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@ -228,26 +228,21 @@ EFI_DECOMPRESS_PROTOCOL gEfiDecompress = {
//
// Main entry point to the DXE Core
//
/**
Main entry point to DXE Core.
@param HobStart Pointer to the beginning of the HOB List from
PEI
@return This function should never return
**/
VOID
EFIAPI
DxeMain (
IN VOID *HobStart
)
/*++
Routine Description:
Main entry point to DXE Core.
Arguments:
HobStart - Pointer to the beginning of the HOB List from PEI
Returns:
This function should never return
--*/
{
EFI_STATUS Status;
EFI_PHYSICAL_ADDRESS MemoryBaseAddress;
@ -335,7 +330,7 @@ Returns:
gDxeCoreImageHandle
);
DEBUG ((EFI_D_INFO | EFI_D_LOAD, "HOBLIST address in DXE = 0x%016lx\n", (UINT64) (UINTN) HobStart));
DEBUG ((DEBUG_INFO | DEBUG_LOAD, "HOBLIST address in DXE = 0x%016lx\n", (UINT64) (UINTN) HobStart));
//
// Initialize the Event Services
@ -438,26 +433,19 @@ Returns:
}
/**
Place holder function until all the Boot Services and Runtime Services are
available.
@return EFI_NOT_AVAILABLE_YET
**/
EFI_STATUS
EFIAPI
CoreEfiNotAvailableYetArg0 (
VOID
)
/*++
Routine Description:
Place holder function until all the Boot Services and Runtime Services are available
Arguments:
None
Returns:
EFI_NOT_AVAILABLE_YET
--*/
{
//
// This function should never be executed. If it does, then the architectural protocols
@ -468,26 +456,21 @@ Returns:
return EFI_NOT_AVAILABLE_YET;
}
/**
Place holder function until all the Boot Services and Runtime Services are
available.
@param Arg1 Undefined
@return EFI_NOT_AVAILABLE_YET
**/
EFI_STATUS
EFIAPI
CoreEfiNotAvailableYetArg1 (
UINTN Arg1
)
/*++
Routine Description:
Place holder function until all the Boot Services and Runtime Services are available
Arguments:
Arg1 - Undefined
Returns:
EFI_NOT_AVAILABLE_YET
--*/
{
//
// This function should never be executed. If it does, then the architectural protocols
@ -498,29 +481,22 @@ Returns:
return EFI_NOT_AVAILABLE_YET;
}
/**
Place holder function until all the Boot Services and Runtime Services are available.
@param Arg1 Undefined
@param Arg2 Undefined
@return EFI_NOT_AVAILABLE_YET
**/
EFI_STATUS
EFIAPI
CoreEfiNotAvailableYetArg2 (
UINTN Arg1,
UINTN Arg2
)
/*++
Routine Description:
Place holder function until all the Boot Services and Runtime Services are available
Arguments:
Arg1 - Undefined
Arg2 - Undefined
Returns:
EFI_NOT_AVAILABLE_YET
--*/
{
//
// This function should never be executed. If it does, then the architectural protocols
@ -531,6 +507,17 @@ Returns:
return EFI_NOT_AVAILABLE_YET;
}
/**
Place holder function until all the Boot Services and Runtime Services are available.
@param Arg1 Undefined
@param Arg2 Undefined
@param Arg3 Undefined
@return EFI_NOT_AVAILABLE_YET
**/
EFI_STATUS
EFIAPI
CoreEfiNotAvailableYetArg3 (
@ -538,25 +525,6 @@ CoreEfiNotAvailableYetArg3 (
UINTN Arg2,
UINTN Arg3
)
/*++
Routine Description:
Place holder function until all the Boot Services and Runtime Services are available
Arguments:
Arg1 - Undefined
Arg2 - Undefined
Arg3 - Undefined
Returns:
EFI_NOT_AVAILABLE_YET
--*/
{
//
// This function should never be executed. If it does, then the architectural protocols
@ -567,6 +535,18 @@ Returns:
return EFI_NOT_AVAILABLE_YET;
}
/**
Place holder function until all the Boot Services and Runtime Services are available.
@param Arg1 Undefined
@param Arg2 Undefined
@param Arg3 Undefined
@param Arg4 Undefined
@return EFI_NOT_AVAILABLE_YET
**/
EFI_STATUS
EFIAPI
CoreEfiNotAvailableYetArg4 (
@ -575,27 +555,6 @@ CoreEfiNotAvailableYetArg4 (
UINTN Arg3,
UINTN Arg4
)
/*++
Routine Description:
Place holder function until all the Boot Services and Runtime Services are available
Arguments:
Arg1 - Undefined
Arg2 - Undefined
Arg3 - Undefined
Arg4 - Undefined
Returns:
EFI_NOT_AVAILABLE_YET
--*/
{
//
// This function should never be executed. If it does, then the architectural protocols
@ -606,6 +565,19 @@ Returns:
return EFI_NOT_AVAILABLE_YET;
}
/**
Place holder function until all the Boot Services and Runtime Services are available.
@param Arg1 Undefined
@param Arg2 Undefined
@param Arg3 Undefined
@param Arg4 Undefined
@param Arg5 Undefined
@return EFI_NOT_AVAILABLE_YET
**/
EFI_STATUS
EFIAPI
CoreEfiNotAvailableYetArg5 (
@ -615,29 +587,6 @@ CoreEfiNotAvailableYetArg5 (
UINTN Arg4,
UINTN Arg5
)
/*++
Routine Description:
Place holder function until all the Boot Services and Runtime Services are available
Arguments:
Arg1 - Undefined
Arg2 - Undefined
Arg3 - Undefined
Arg4 - Undefined
Arg5 - Undefined
Returns:
EFI_NOT_AVAILABLE_YET
--*/
{
//
// This function should never be executed. If it does, then the architectural protocols
@ -649,30 +598,23 @@ Returns:
}
/**
Searches for a Protocol Interface passed from PEI through a HOB.
@param ProtocolGuid The Protocol GUID to search for in the HOB List
@param Interface A pointer to the interface for the Protocol GUID
@retval EFI_SUCCESS The Protocol GUID was found and its interface is
returned in Interface
@retval EFI_NOT_FOUND The Protocol GUID was not found in the HOB List
**/
EFI_STATUS
CoreGetPeiProtocol (
IN EFI_GUID *ProtocolGuid,
IN VOID **Interface
)
/*++
Routine Description:
Searches for a Protocol Interface passed from PEI through a HOB
Arguments:
ProtocolGuid - The Protocol GUID to search for in the HOB List
Interface - A pointer to the interface for the Protocol GUID
Returns:
EFI_SUCCESS - The Protocol GUID was found and its interface is returned in Interface
EFI_NOT_FOUND - The Protocol GUID was not found in the HOB List
--*/
{
EFI_HOB_GUID_TYPE *GuidHob;
VOID *Buffer;
@ -691,26 +633,18 @@ Returns:
}
/**
Calcualte the 32-bit CRC in a EFI table using the service provided by the
gRuntime service.
@param Hdr Pointer to an EFI standard header
**/
VOID
CalculateEfiHdrCrc (
IN OUT EFI_TABLE_HEADER *Hdr
)
/*++
Routine Description:
Calcualte the 32-bit CRC in a EFI table using the service provided by the
gRuntime service.
Arguments:
Hdr - Pointer to an EFI standard header
Returns:
None
--*/
{
UINT32 Crc;
@ -727,30 +661,23 @@ Returns:
/**
Terminates all boot services.
@param ImageHandle Handle that identifies the exiting image.
@param MapKey Key to the latest memory map.
@retval EFI_SUCCESS Boot Services terminated
@retval EFI_INVALID_PARAMETER MapKey is incorrect.
**/
EFI_STATUS
EFIAPI
CoreExitBootServices (
IN EFI_HANDLE ImageHandle,
IN UINTN MapKey
)
/*++
Routine Description:
Terminates all boot services.
Arguments:
ImageHandle - Handle that identifies the exiting image.
MapKey -Key to the latest memory map.
Returns:
EFI_SUCCESS - Boot Services terminated
EFI_INVALID_PARAMETER - MapKey is incorrect.
--*/
{
EFI_STATUS Status;
EFI_STATUS StatusTemp;
@ -847,7 +774,48 @@ Returns:
return Status;
}
/**
Given a compressed source buffer, this function retrieves the size of the
uncompressed buffer and the size of the scratch buffer required to decompress
the compressed source buffer.
The GetInfo() function retrieves the size of the uncompressed buffer and the
temporary scratch buffer required to decompress the buffer specified by Source
and SourceSize. If the size of the uncompressed buffer or the size of the
scratch buffer cannot be determined from the compressed data specified by
Source and SourceData, then EFI_INVALID_PARAMETER is returned. Otherwise, the
size of the uncompressed buffer is returned in DestinationSize, the size of
the scratch buffer is returned in ScratchSize, and EFI_SUCCESS is returned.
The GetInfo() function does not have scratch buffer available to perform a
thorough checking of the validity of the source data. It just retrieves the
"Original Size" field from the beginning bytes of the source data and output
it as DestinationSize. And ScratchSize is specific to the decompression
implementation.
@param This A pointer to the EFI_DECOMPRESS_PROTOCOL instance.
@param Source The source buffer containing the compressed data.
@param SourceSize The size, in bytes, of the source buffer.
@param DestinationSize A pointer to the size, in bytes, of the
uncompressed buffer that will be generated when the
compressed buffer specified by Source and
SourceSize is decompressed.
@param ScratchSize A pointer to the size, in bytes, of the scratch
buffer that is required to decompress the
compressed buffer specified by Source and
SourceSize.
@retval EFI_SUCCESS The size of the uncompressed data was returned in
DestinationSize and the size of the scratch buffer
was returned in ScratchSize.
@retval EFI_INVALID_PARAMETER The size of the uncompressed data or the size of
the scratch buffer cannot be determined from the
compressed data specified by Source and
SourceSize.
**/
EFI_STATUS
EFIAPI
DxeMainUefiDecompressGetInfo (
IN EFI_DECOMPRESS_PROTOCOL *This,
IN VOID *Source,
@ -864,6 +832,41 @@ DxeMainUefiDecompressGetInfo (
return UefiDecompressGetInfo (Source, SourceSize, DestinationSize, ScratchSize);
}
/**
Decompresses a compressed source buffer.
The Decompress() function extracts decompressed data to its original form.
This protocol is designed so that the decompression algorithm can be
implemented without using any memory services. As a result, the Decompress()
Function is not allowed to call AllocatePool() or AllocatePages() in its
implementation. It is the caller¡¯s responsibility to allocate and free the
Destination and Scratch buffers.
If the compressed source data specified by Source and SourceSize is
sucessfully decompressed into Destination, then EFI_SUCCESS is returned. If
the compressed source data specified by Source and SourceSize is not in a
valid compressed data format, then EFI_INVALID_PARAMETER is returned.
@param This A pointer to the EFI_DECOMPRESS_PROTOCOL instance.
@param Source The source buffer containing the compressed data.
@param SourceSize SourceSizeThe size of source data.
@param Destination On output, the destination buffer that contains
the uncompressed data.
@param DestinationSize The size of the destination buffer. The size of
the destination buffer needed is obtained from
EFI_DECOMPRESS_PROTOCOL.GetInfo().
@param Scratch A temporary scratch buffer that is used to perform
the decompression.
@param ScratchSize The size of scratch buffer. The size of the
scratch buffer needed is obtained from GetInfo().
@retval EFI_SUCCESS Decompression completed successfully, and the
uncompressed buffer is returned in Destination.
@retval EFI_INVALID_PARAMETER The source buffer specified by Source and
SourceSize is corrupted (not in a valid
compressed format).
**/
EFI_STATUS
EFIAPI
DxeMainUefiDecompress (

View File

@ -45,23 +45,19 @@ ARCHITECTURAL_PROTOCOL_ENTRY mArchProtocols[] = {
};
/**
Return TRUE if all AP services are availible.
@retval EFI_SUCCESS All AP services are available
@retval EFI_NOT_FOUND At least one AP service is not available
**/
EFI_STATUS
CoreAllEfiServicesAvailable (
VOID
)
/*++
Routine Description:
Return TRUE if all AP services are availible.
Arguments:
NONE
Returns:
EFI_SUCCESS - All AP services are available
EFI_NOT_FOUND - At least one AP service is not available
--*/
{
ARCHITECTURAL_PROTOCOL_ENTRY *Entry;
@ -74,33 +70,25 @@ Returns:
return EFI_SUCCESS;
}
STATIC
VOID
EFIAPI
GenericArchProtocolNotify (
IN EFI_EVENT Event,
IN VOID *Context
)
/*++
Routine Description:
/**
Notification event handler registered by CoreNotifyOnArchProtocolInstallation ().
This notify function is registered for every architectural protocol. This handler
updates mArchProtocol[] array entry with protocol instance data and sets it's
present flag to TRUE. If any constructor is required it is executed. The EFI
System Table headers are updated.
Arguments:
@param Event The Event that is being processed, not used.
@param Context Event Context, not used.
Event - The Event that is being processed, not used.
Context - Event Context, not used.
Returns:
None
--*/
**/
STATIC
VOID
EFIAPI
GenericArchProtocolNotify (
IN EFI_EVENT Event,
IN VOID *Context
)
{
EFI_STATUS Status;
ARCHITECTURAL_PROTOCOL_ENTRY *Entry;
@ -184,22 +172,15 @@ Returns:
/**
Creates an event that is fired everytime a Protocol of a specific type is installed.
**/
VOID
CoreNotifyOnArchProtocolInstallation (
VOID
)
/*++
Routine Description:
Creates an event that is fired everytime a Protocol of a specific type is installed
Arguments:
NONE
Returns:
NONE
--*/
{
EFI_STATUS Status;
ARCHITECTURAL_PROTOCOL_ENTRY *Entry;
@ -256,23 +237,16 @@ static const GUID_TO_STRING_PROTOCOL_ENTRY MissingProtocols[] = {
{ &gEfiRealTimeClockArchProtocolGuid, (CHAR16 *)L"Real Time Clock" }
};
/**
Displays Architectural protocols that were not loaded and are required for DXE
core to function. Only used in Debug Builds.
**/
VOID
CoreDisplayMissingArchProtocols (
VOID
)
/*++
Routine Description:
Displays Architectural protocols that were not loaded and are required for DXE core to function
Only used in Debug Builds
Arguments:
NONE
Returns:
NONE
--*/
{
const GUID_TO_STRING_PROTOCOL_ENTRY *MissingEntry;
ARCHITECTURAL_PROTOCOL_ENTRY *Entry;
@ -282,7 +256,7 @@ Returns:
MissingEntry = MissingProtocols;
for (MissingEntry = MissingProtocols; TRUE ; MissingEntry++) {
if (CompareGuid (Entry->ProtocolGuid, MissingEntry->ProtocolGuid)) {
DEBUG ((EFI_D_ERROR, "\n%s Arch Protocol not present!!\n", MissingEntry->GuidString));
DEBUG ((DEBUG_ERROR, "\n%s Arch Protocol not present!!\n", MissingEntry->GuidString));
break;
}
}

View File

@ -62,74 +62,47 @@ UINT32 mEventTable[] = {
EVT_TIMER | EVT_NOTIFY_WAIT,
};
/**
Enter critical section by acquiring the lock on gEventQueueLock.
**/
STATIC
VOID
CoreAcquireEventLock (
VOID
)
/*++
Routine Description:
Enter critical section by acquiring the lock on gEventQueueLock.
Arguments:
None
Returns:
None
--*/
{
CoreAcquireLock (&gEventQueueLock);
}
/**
Exit critical section by releasing the lock on gEventQueueLock.
**/
STATIC
VOID
CoreReleaseEventLock (
VOID
)
/*++
Routine Description:
Exit critical section by releasing the lock on gEventQueueLock.
Arguments:
None
Returns:
None
--*/
{
CoreReleaseLock (&gEventQueueLock);
}
/**
Initializes "event" support and populates parts of the System and Runtime Table.
@retval EFI_SUCCESS Always return success
**/
EFI_STATUS
CoreInitializeEventServices (
VOID
)
/*++
Routine Description:
Initializes "event" support and populates parts of the System and Runtime Table.
Arguments:
None
Returns:
EFI_SUCCESS - Always return success
--*/
{
UINTN Index;
@ -143,25 +116,18 @@ Returns:
}
/**
Dispatches all pending events.
@param Priority The task priority level of event notifications
to dispatch
**/
VOID
CoreDispatchEventNotifies (
IN EFI_TPL Priority
)
/*++
Routine Description:
Dispatches all pending events.
Arguments:
Priority - The task priority level of event notifications to dispatch
Returns:
None
--*/
{
IEVENT *Event;
LIST_ENTRY *Head;
@ -207,26 +173,18 @@ Returns:
}
/**
Queues the event's notification function to fire.
@param Event The Event to notify
**/
STATIC
VOID
CoreNotifyEvent (
IN IEVENT *Event
)
/*++
Routine Description:
Queues the event's notification function to fire
Arguments:
Event - The Event to notify
Returns:
None
--*/
{
//
@ -253,23 +211,17 @@ Returns:
/**
Signals all events in the EventGroup.
@param EventGroup The list to signal
**/
VOID
CoreNotifySignalList (
IN EFI_GUID *EventGroup
)
/*++
Routine Description:
Signals all events in the EventGroup
Arguments:
EventGroup - The list to signal
Returns:
None
--*/
{
LIST_ENTRY *Link;
LIST_ENTRY *Head;
@ -288,6 +240,25 @@ Returns:
CoreReleaseEventLock ();
}
/**
Creates a general-purpose event structure.
@param Type The type of event to create and its mode and
attributes
@param NotifyTpl The task priority level of event notifications
@param NotifyFunction Pointer to the events notification function
@param NotifyContext Pointer to the notification functions context;
corresponds to parameter "Context" in the
notification function
@param Event Pointer to the newly created event if the call
succeeds; undefined otherwise
@retval EFI_SUCCESS The event structure was created
@retval EFI_INVALID_PARAMETER One of the parameters has an invalid value
@retval EFI_OUT_OF_RESOURCES The event could not be allocated
**/
EFI_STATUS
EFIAPI
CoreCreateEvent (
@ -297,30 +268,32 @@ CoreCreateEvent (
IN VOID *NotifyContext, OPTIONAL
OUT EFI_EVENT *Event
)
/*++
Routine Description:
Creates a general-purpose event structure
Arguments:
Type - The type of event to create and its mode and attributes
NotifyTpl - The task priority level of event notifications
NotifyFunction - Pointer to the events notification function
NotifyContext - Pointer to the notification functions context; corresponds to
parameter "Context" in the notification function
Event - Pointer to the newly created event if the call succeeds; undefined otherwise
Returns:
EFI_SUCCESS - The event structure was created
EFI_INVALID_PARAMETER - One of the parameters has an invalid value
EFI_OUT_OF_RESOURCES - The event could not be allocated
--*/
{
return CoreCreateEventEx (Type, NotifyTpl, NotifyFunction, NotifyContext, NULL, Event);
}
/**
Creates a general-purpose event structure
@param Type The type of event to create and its mode and
attributes
@param NotifyTpl The task priority level of event notifications
@param NotifyFunction Pointer to the events notification function
@param NotifyContext Pointer to the notification functions context;
corresponds to parameter "Context" in the
notification function
@param EventGroup GUID for EventGroup if NULL act the same as
gBS->CreateEvent().
@param Event Pointer to the newly created event if the call
succeeds; undefined otherwise
@retval EFI_SUCCESS The event structure was created
@retval EFI_INVALID_PARAMETER One of the parameters has an invalid value
@retval EFI_OUT_OF_RESOURCES The event could not be allocated
**/
EFI_STATUS
EFIAPI
CoreCreateEventEx (
@ -331,26 +304,6 @@ CoreCreateEventEx (
IN CONST EFI_GUID *EventGroup, OPTIONAL
OUT EFI_EVENT *Event
)
/*++
Routine Description:
Creates a general-purpose event structure
Arguments:
Type - The type of event to create and its mode and attributes
NotifyTpl - The task priority level of event notifications
NotifyFunction - Pointer to the events notification function
NotifyContext - Pointer to the notification functions context; corresponds to
parameter "Context" in the notification function
EventGroup - GUID for EventGroup if NULL act the same as gBS->CreateEvent().
Event - Pointer to the newly created event if the call succeeds; undefined otherwise
Returns:
EFI_SUCCESS - The event structure was created
EFI_INVALID_PARAMETER - One of the parameters has an invalid value
EFI_OUT_OF_RESOURCES - The event could not be allocated
--*/
{
EFI_STATUS Status;
IEVENT *IEvent;
@ -482,28 +435,21 @@ Returns:
/**
Signals the event. Queues the event to be notified if needed
@param UserEvent The event to signal
@retval EFI_INVALID_PARAMETER Parameters are not valid.
@retval EFI_SUCCESS The event was signaled.
**/
EFI_STATUS
EFIAPI
CoreSignalEvent (
IN EFI_EVENT UserEvent
)
/*++
Routine Description:
Signals the event. Queues the event to be notified if needed
Arguments:
UserEvent - The event to signal
Returns:
EFI_INVALID_PARAMETER - Parameters are not valid.
EFI_SUCCESS - The event was signaled.
--*/
{
IEVENT *Event;
@ -549,29 +495,22 @@ Returns:
}
/**
Check the status of an event.
@param UserEvent The event to check
@retval EFI_SUCCESS The event is in the signaled state
@retval EFI_NOT_READY The event is not in the signaled state
@retval EFI_INVALID_PARAMETER Event is of type EVT_NOTIFY_SIGNAL
**/
EFI_STATUS
EFIAPI
CoreCheckEvent (
IN EFI_EVENT UserEvent
)
/*++
Routine Description:
Check the status of an event
Arguments:
UserEvent - The event to check
Returns:
EFI_SUCCESS - The event is in the signaled state
EFI_NOT_READY - The event is not in the signaled state
EFI_INVALID_PARAMETER - Event is of type EVT_NOTIFY_SIGNAL
--*/
{
IEVENT *Event;
EFI_STATUS Status;
@ -625,6 +564,21 @@ Returns:
/**
Stops execution until an event is signaled.
@param NumberOfEvents The number of events in the UserEvents array
@param UserEvents An array of EFI_EVENT
@param UserIndex Pointer to the index of the event which
satisfied the wait condition
@retval EFI_SUCCESS The event indicated by Index was signaled.
@retval EFI_INVALID_PARAMETER The event indicated by Index has a notification
function or Event was not a valid type
@retval EFI_UNSUPPORTED The current TPL is not TPL_APPLICATION
**/
EFI_STATUS
EFIAPI
CoreWaitForEvent (
@ -632,27 +586,6 @@ CoreWaitForEvent (
IN EFI_EVENT *UserEvents,
OUT UINTN *UserIndex
)
/*++
Routine Description:
Stops execution until an event is signaled.
Arguments:
NumberOfEvents - The number of events in the UserEvents array
UserEvents - An array of EFI_EVENT
UserIndex - Pointer to the index of the event which satisfied the wait condition
Returns:
EFI_SUCCESS - The event indicated by Index was signaled.
EFI_INVALID_PARAMETER - The event indicated by Index has a notification function or
Event was not a valid type
EFI_UNSUPPORTED - The current TPL is not TPL_APPLICATION
--*/
{
EFI_STATUS Status;
UINTN Index;
@ -687,29 +620,21 @@ Returns:
}
/**
Closes an event and frees the event structure.
@param UserEvent Event to close
@retval EFI_INVALID_PARAMETER Parameters are not valid.
@retval EFI_SUCCESS The event has been closed
**/
EFI_STATUS
EFIAPI
CoreCloseEvent (
IN EFI_EVENT UserEvent
)
/*++
Routine Description:
Closes an event and frees the event structure.
Arguments:
UserEvent - Event to close
Returns:
EFI_INVALID_PARAMETER - Parameters are not valid.
EFI_SUCCESS - The event has been closed
--*/
{
EFI_STATUS Status;
IEVENT *Event;

View File

@ -19,12 +19,26 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
//
// Internal prototypes
//
/**
Returns the current system time.
@return The current system time
**/
STATIC
UINT64
CoreCurrentSystemTime (
VOID
);
/**
Checks the sorted timer list against the current system time.
Signals any expired event timer.
@param CheckEvent Not used
@param Context Not used
**/
STATIC
VOID
EFIAPI
@ -33,6 +47,13 @@ CoreCheckTimers (
IN VOID *Context
);
/**
Inserts the timer event.
@param Event Points to the internal structure of timer event
to be installed
**/
STATIC
VOID
CoreInsertEventTimer (
@ -54,25 +75,15 @@ static UINT64 mEfiSystemTime = 0;
// Timer functions
//
/**
Initializes timer support.
**/
VOID
CoreInitializeTimer (
VOID
)
/*++
Routine Description:
Initializes timer support
Arguments:
None
Returns:
None
--*/
{
EFI_STATUS Status;
@ -86,26 +97,18 @@ Returns:
ASSERT_EFI_ERROR (Status);
}
/**
Returns the current system time.
@return The current system time
**/
STATIC
UINT64
CoreCurrentSystemTime (
VOID
)
/*++
Routine Description:
Returns the current system time
Arguments:
None
Returns:
Returns the current system time
--*/
{
UINT64 SystemTime;
@ -115,26 +118,19 @@ Returns:
return SystemTime;
}
/**
Called by the platform code to process a tick.
@param Duration The number of 100ns elasped since the last call
to TimerTick
**/
VOID
EFIAPI
CoreTimerTick (
IN UINT64 Duration
)
/*++
Routine Description:
Called by the platform code to process a tick.
Arguments:
Duration - The number of 100ns elasped since the last call to TimerTick
Returns:
None
--*/
{
IEVENT *Event;
@ -166,6 +162,15 @@ Returns:
CoreReleaseLock (&mEfiSystemTimeLock);
}
/**
Checks the sorted timer list against the current system time.
Signals any expired event timer.
@param CheckEvent Not used
@param Context Not used
**/
STATIC
VOID
EFIAPI
@ -173,24 +178,6 @@ CoreCheckTimers (
IN EFI_EVENT CheckEvent,
IN VOID *Context
)
/*++
Routine Description:
Checks the sorted timer list against the current system time.
Signals any expired event timer.
Arguments:
CheckEvent - Not used
Context - Not used
Returns:
None
--*/
{
UINT64 SystemTime;
IEVENT *Event;
@ -255,26 +242,19 @@ Returns:
CoreReleaseLock (&mEfiTimerLock);
}
/**
Inserts the timer event.
@param Event Points to the internal structure of timer event
to be installed
**/
STATIC
VOID
CoreInsertEventTimer (
IN IEVENT *Event
)
/*++
Routine Description:
Inserts the timer event
Arguments:
Event - Points to the internal structure of timer event to be installed
Returns:
None
--*/
{
UINT64 TriggerTime;
LIST_ENTRY *Link;
@ -305,6 +285,22 @@ Returns:
/**
Sets the type of timer and the trigger time for a timer event.
@param UserEvent The timer event that is to be signaled at the
specified time
@param Type The type of time that is specified in
TriggerTime
@param TriggerTime The number of 100ns units until the timer
expires
@retval EFI_SUCCESS The event has been set to be signaled at the
requested time
@retval EFI_INVALID_PARAMETER Event or Type is not valid
**/
EFI_STATUS
EFIAPI
CoreSetTimer (
@ -312,24 +308,6 @@ CoreSetTimer (
IN EFI_TIMER_DELAY Type,
IN UINT64 TriggerTime
)
/*++
Routine Description:
Sets the type of timer and the trigger time for a timer event.
Arguments:
UserEvent - The timer event that is to be signaled at the specified time
Type - The type of time that is specified in TriggerTime
TriggerTime - The number of 100ns units until the timer expires
Returns:
EFI_SUCCESS - The event has been set to be signaled at the requested time
EFI_INVALID_PARAMETER - Event or Type is not valid
--*/
{
IEVENT *Event;

View File

@ -15,27 +15,18 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include <DxeMain.h>
/**
Set Interrupt State.
@param Enable The state of enable or disable interrupt
**/
STATIC
VOID
CoreSetInterruptState (
IN BOOLEAN Enable
)
/*++
Routine Description:
Set Interrupt State
Arguments:
Enable - The state of enable or disable interrupt
Returns:
None
--*/
{
if (gCpu != NULL) {
if (Enable) {
@ -49,25 +40,19 @@ Returns:
//
// Return the highest set bit
//
/**
Return the highest set bit.
@param Number The value to check
@return Bit position of the highest set bit
**/
UINTN
CoreHighestSetBit (
IN UINTN Number
)
/*++
Routine Description:
Return the highest set bit
Arguments:
Number - The value to check
Returns:
Bit position of the highest set bit
--*/
{
UINTN msb;
@ -81,27 +66,21 @@ Returns:
/**
Raise the task priority level to the new level.
High level is implemented by disabling processor interrupts.
@param NewTpl New task priority level
@return The previous task priority level
**/
EFI_TPL
EFIAPI
CoreRaiseTpl (
IN EFI_TPL NewTpl
)
/*++
Routine Description:
Raise the task priority level to the new level.
High level is implemented by disabling processor interrupts.
Arguments:
NewTpl - New task priority level
Returns:
The previous task priority level
--*/
{
EFI_TPL OldTpl;
@ -126,27 +105,19 @@ Returns:
/**
Lowers the task priority to the previous value. If the new
priority unmasks events at a higher priority, they are dispatched.
@param NewTpl New, lower, task priority
**/
VOID
EFIAPI
CoreRestoreTpl (
IN EFI_TPL NewTpl
)
/*++
Routine Description:
Lowers the task priority to the previous value. If the new
priority unmasks events at a higher priority, they are dispatched.
Arguments:
NewTpl - New, lower, task priority
Returns:
None
--*/
{
EFI_TPL OldTpl;

View File

@ -73,120 +73,76 @@ typedef struct {
// Internal prototypes
//
/**
Dispatches all pending events.
@param Priority The task priority level of event notifications
to dispatch
**/
VOID
CoreDispatchEventNotifies (
IN EFI_TPL Priority
)
/*++
Routine Description:
Dispatches all pending events.
Arguments:
Priority - The task priority level of event notifications to dispatch
Returns:
None
--*/
;
/**
Return the highest set bit.
@param Number The value to check
@return Bit position of the highest set bit
**/
UINTN
CoreHighestSetBit (
IN UINTN Number
)
/*++
Routine Description:
Return the highest set bit
Arguments:
Number - The value to check
Returns:
Bit position of the highest set bit
--*/
;
/**
Disables CPU interrupts.
@retval EFI_SUCCESS If interrupts were disabled in the CPU.
@retval EFI_INVALID_PARAMETER State is NULL.
**/
BOOLEAN
GetInterruptState (
VOID
)
/*++
Routine Description:
Disables CPU interrupts.
Arguments:
This - Protocol instance structure
State - Pointer to the CPU's current interrupt state
Returns:
EFI_SUCCESS - If interrupts were disabled in the CPU.
EFI_INVALID_PARAMETER - State is NULL.
--*/
;
//
// Exported functions
//
/**
A function out of date, should be removed.
**/
VOID
CoreEventVirtualAddressFixup (
VOID
)
/*++
Routine Description:
A function out of date, should be removed.
Arguments:
None
Returns:
None
--*/
;
/**
Initializes timer support.
**/
VOID
CoreInitializeTimer (
VOID
)
/*++
Routine Description:
Initializes timer support
Arguments:
None
Returns:
None
--*/
;
//
@ -197,6 +153,5 @@ extern EFI_LOCK gEventQueueLock;
extern UINTN gEventPending;
extern LIST_ENTRY gEventQueue[];
extern LIST_ENTRY gEventSignalQueue;
extern UINT8 gHSB[];
#endif

View File

@ -19,24 +19,20 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#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.
@param ErasePolarity Erase polarity attribute of the firmware volume
@param FfsHeader Points to the FFS file header
@return FFS File state
**/
EFI_FFS_FILE_STATE
GetFileState (
IN UINT8 ErasePolarity,
IN EFI_FFS_FILE_HEADER *FfsHeader
)
/*++
Routine Description:
Get the FFS file state by checking the highest bit set in the header's state field
Arguments:
ErasePolarity - Erase polarity attribute of the firmware volume
FfsHeader - Points to the FFS file header
Returns:
FFS File state
--*/
{
EFI_FFS_FILE_STATE FileState;
UINT8 HighestBit;
@ -56,27 +52,24 @@ Returns:
}
/**
Check if a block of buffer is erased.
@param ErasePolarity Erase polarity attribute of the firmware volume
@param InBuffer The buffer to be checked
@param BufferSize Size of the buffer in bytes
@retval TRUE The block of buffer is erased
@retval FALSE The block of buffer is not erased
**/
BOOLEAN
IsBufferErased (
IN UINT8 ErasePolarity,
IN VOID *InBuffer,
IN UINTN BufferSize
)
/*++
Routine Description:
Check if a block of buffer is erased
Arguments:
ErasePolarity - Erase polarity attribute of the firmware volume
InBuffer - The buffer to be checked
BufferSize - Size of the buffer in bytes
Returns:
TRUE - The block of buffer is erased
FALSE - The block of buffer is not erased
--*/
{
UINTN Count;
UINT8 EraseByte;
@ -99,35 +92,32 @@ Returns:
}
/**
Verify checksum of the firmware volume header.
@param FvHeader Points to the firmware volume header to be checked
@retval TRUE Checksum verification passed
@retval FALSE Checksum verification failed
**/
BOOLEAN
VerifyFvHeaderChecksum (
IN EFI_FIRMWARE_VOLUME_HEADER *FvHeader
)
/*++
Routine Description:
Verify checksum of the firmware volume header
Arguments:
FvHeader - Points to the firmware volume header to be checked
Returns:
TRUE - Checksum verification passed
FALSE - Checksum verification failed
--*/
{
UINT32 Index;
UINT32 HeaderLength;
UINT16 Checksum;
UINT16 *ptr;
UINT16 *Ptr;
HeaderLength = FvHeader->HeaderLength;
ptr = (UINT16 *)FvHeader;
Ptr = (UINT16 *)FvHeader;
Checksum = 0;
for (Index = 0; Index < HeaderLength / sizeof (UINT16); Index++) {
Checksum = (UINT16)(Checksum + ptr[Index]);
Checksum = (UINT16)(Checksum + Ptr[Index]);
}
if (Checksum == 0) {
@ -137,33 +127,30 @@ Returns:
}
}
/**
Verify checksum of the FFS file header.
@param FfsHeader Points to the FFS file header to be checked
@retval TRUE Checksum verification passed
@retval FALSE Checksum verification failed
**/
STATIC
BOOLEAN
VerifyHeaderChecksum (
IN EFI_FFS_FILE_HEADER *FfsHeader
)
/*++
Routine Description:
Verify checksum of the FFS file header
Arguments:
FfsHeader - Points to the FFS file header to be checked
Returns:
TRUE - Checksum verification passed
FALSE - Checksum verification failed
--*/
{
UINT32 Index;
UINT8 *ptr;
UINT8 *Ptr;
UINT8 HeaderChecksum;
ptr = (UINT8 *)FfsHeader;
Ptr = (UINT8 *)FfsHeader;
HeaderChecksum = 0;
for (Index = 0; Index < sizeof(EFI_FFS_FILE_HEADER); Index++) {
HeaderChecksum = (UINT8)(HeaderChecksum + ptr[Index]);
HeaderChecksum = (UINT8)(HeaderChecksum + Ptr[Index]);
}
HeaderChecksum = (UINT8) (HeaderChecksum - FfsHeader->State - FfsHeader->IntegrityCheck.Checksum.File);
@ -176,27 +163,24 @@ Returns:
}
/**
Check if it's a valid FFS file header.
@param ErasePolarity Erase polarity attribute of the firmware volume
@param FfsHeader Points to the FFS file header to be checked
@param FileState FFS file state to be returned
@retval TRUE Valid FFS file header
@retval FALSE Invalid FFS file header
**/
BOOLEAN
IsValidFfsHeader (
IN UINT8 ErasePolarity,
IN EFI_FFS_FILE_HEADER *FfsHeader,
OUT EFI_FFS_FILE_STATE *FileState
)
/*++
Routine Description:
Check if it's a valid FFS file header
Arguments:
ErasePolarity - Erase polarity attribute of the firmware volume
FfsHeader - Points to the FFS file header to be checked
FileState - FFS file state to be returned
Returns:
TRUE - Valid FFS file header
FALSE - Invalid FFS file header
--*/
{
*FileState = GetFileState (ErasePolarity, FfsHeader);
@ -218,26 +202,23 @@ Returns:
}
/**
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.
@param ErasePolarity Erase polarity attribute of the firmware volume
@param FfsHeader Points to the FFS file to be checked
@retval TRUE Valid FFS file
@retval FALSE Invalid FFS file
**/
BOOLEAN
IsValidFfsFile (
IN UINT8 ErasePolarity,
IN EFI_FFS_FILE_HEADER *FfsHeader
)
/*++
Routine Description:
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.
Arguments:
ErasePolarity - Erase polarity attribute of the firmware volume
FfsHeader - Points to the FFS file to be checked
Returns:
TRUE - Valid FFS file
FALSE - Invalid FFS file
--*/
{
EFI_FFS_FILE_STATE FileState;
@ -258,3 +239,4 @@ Returns:
}
}

View File

@ -1,9 +1,9 @@
/**@file
/** @file
Firmware File System driver that produce Firmware Volume protocol.
Layers on top of Firmware Block protocol to produce a file abstraction
of FV based files.
Copyright (c) 2006 - 2007 Intel Corporation. <BR>
Copyright (c) 2006 - 2008 Intel Corporation. <BR>
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@ -53,29 +53,26 @@ FV_DEVICE mFvDevice = {
// FFS helper functions
//
/**
given the supplied FW_VOL_BLOCK_PROTOCOL, allocate a buffer for output and
copy the volume header into it.
@param Fvb The FW_VOL_BLOCK_PROTOCOL instance from which to
read the volume header
@param FwVolHeader Pointer to pointer to allocated buffer in which
the volume header is returned.
@retval EFI_OUT_OF_RESOURCES No enough buffer could be allocated.
@retval EFI_SUCCESS Successfully read volume header to the allocated
buffer.
**/
EFI_STATUS
GetFwVolHeader (
IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *Fvb,
OUT EFI_FIRMWARE_VOLUME_HEADER **FwVolHeader
)
/*++
Routine Description:
given the supplied FW_VOL_BLOCK_PROTOCOL, allocate a buffer for output and
copy the volume header into it.
Arguments:
Fvb - The FW_VOL_BLOCK_PROTOCOL instance from which to read the volume
header
FwVolHeader - Pointer to pointer to allocated buffer in which the volume
header is returned.
Returns:
EFI_OUT_OF_RESOURCES - No enough buffer could be allocated.
EFI_SUCCESS - Successfully read volume header to the allocated buffer.
--*/
{
EFI_STATUS Status;
EFI_FIRMWARE_VOLUME_HEADER TempFvh;
@ -119,23 +116,20 @@ Returns:
}
/**
Free FvDevice resource when error happens
@param FvDevice pointer to the FvDevice to be freed.
@return None.
**/
STATIC
VOID
FreeFvDeviceResource (
IN FV_DEVICE *FvDevice
)
/*++
Routine Description:
Free FvDevice resource when error happens
Arguments:
FvDevice - pointer to the FvDevice to be freed.
Returns:
None.
--*/
{
FFS_FILE_LIST_ENTRY *FfsFileEntry;
LIST_ENTRY *NextEntry;
@ -174,24 +168,21 @@ Returns:
}
/**
Check if a FV is consistent and allocate cache
@param FvDevice pointer to the FvDevice to be checked.
@retval EFI_OUT_OF_RESOURCES No enough buffer could be allocated.
@retval EFI_SUCCESS FV is consistent and cache is allocated.
@retval EFI_VOLUME_CORRUPTED File system is corrupted.
**/
EFI_STATUS
FvCheck (
IN OUT FV_DEVICE *FvDevice
)
/*++
Routine Description:
Check if a FV is consistent and allocate cache
Arguments:
FvDevice - pointer to the FvDevice to be checked.
Returns:
EFI_OUT_OF_RESOURCES - No enough buffer could be allocated.
EFI_SUCCESS - FV is consistent and cache is allocated.
EFI_VOLUME_CORRUPTED - File system is corrupted.
--*/
{
EFI_STATUS Status;
EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *Fvb;
@ -380,6 +371,17 @@ Done:
}
/**
This notification function is invoked when an instance of the
EFI_FW_VOLUME_BLOCK_PROTOCOL is produced. It layers an instance of the
EFI_FIRMWARE_VOLUME2_PROTOCOL on the same handle. This is the function where
the actual initialization of the EFI_FIRMWARE_VOLUME2_PROTOCOL is done.
@param Event The event that occured
@param Context For EFI compatiblity. Not used.
**/
STATIC
VOID
EFIAPI
@ -387,23 +389,6 @@ NotifyFwVolBlock (
IN EFI_EVENT Event,
IN VOID *Context
)
/*++
Routine Description:
This notification function is invoked when an instance of the
EFI_FW_VOLUME_BLOCK_PROTOCOL is produced. It layers an instance of the
EFI_FIRMWARE_VOLUME2_PROTOCOL on the same handle. This is the function where
the actual initialization of the EFI_FIRMWARE_VOLUME2_PROTOCOL is done.
Arguments:
Event - The event that occured
Context - For EFI compatiblity. Not used.
Returns:
None.
--*/
{
EFI_HANDLE Handle;
EFI_STATUS Status;
@ -515,27 +500,24 @@ Returns:
}
/**
This routine is the driver initialization entry point. It initializes the
libraries, and registers two notification functions. These notification
functions are responsible for building the FV stack dynamically.
@param ImageHandle The image handle.
@param SystemTable The system table.
@retval EFI_SUCCESS Function successfully returned.
**/
EFI_STATUS
EFIAPI
FwVolDriverInit (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
/*++
Routine Description:
This routine is the driver initialization entry point. It initializes the
libraries, and registers two notification functions. These notification
functions are responsible for building the FV stack dynamically.
Arguments:
ImageHandle - The image handle.
SystemTable - The system table.
Returns:
EFI_SUCCESS - Function successfully returned.
--*/
{
gEfiFwVolBlockEvent = CoreCreateProtocolNotifyEvent (
&gEfiFirmwareVolumeBlockProtocolGuid,
@ -548,3 +530,4 @@ Returns:
return EFI_SUCCESS;
}

View File

@ -15,26 +15,23 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include <DxeMain.h>
/**
Retrieves attributes, insures positive polarity of attribute bits, returns
resulting attributes in output parameter.
@param This Calling context
@param Attributes output buffer which contains attributes
@retval EFI_SUCCESS Successfully got volume attributes
**/
EFI_STATUS
EFIAPI
FvGetVolumeAttributes (
IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL *This,
OUT EFI_FV_ATTRIBUTES *Attributes
)
/*++
Routine Description:
Retrieves attributes, insures positive polarity of attribute bits, returns
resulting attributes in output parameter
Arguments:
This - Calling context
Attributes - output buffer which contains attributes
Returns:
EFI_SUCCESS - Successfully got volume attributes
--*/
{
EFI_STATUS Status;
FV_DEVICE *FvDevice;
@ -67,30 +64,41 @@ Returns:
}
/**
Sets current attributes for volume
@param This Calling context
@param Attributes At input, contains attributes to be set. At output
contains new value of FV
@retval EFI_UNSUPPORTED Could not be set.
**/
EFI_STATUS
EFIAPI
FvSetVolumeAttributes (
IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL *This,
IN OUT EFI_FV_ATTRIBUTES *Attributes
)
/*++
Routine Description:
Sets current attributes for volume
Arguments:
This - Calling context
Attributes - At input, contains attributes to be set. At output contains
new value of FV
Returns:
EFI_UNSUPPORTED - Could not be set.
--*/
{
return EFI_UNSUPPORTED;
}
/**
Return information of type InformationType for the requested firmware
volume.
@param This Pointer to EFI_FIRMWARE_VOLUME2_PROTOCOL.
@param InformationType InformationType for requested.
@param BufferSize On input, size of Buffer.On output, the amount of data
returned in Buffer.
@param Buffer A poniter to the data buffer to return.
@retval EFI_SUCCESS Successfully got volume Information.
**/
EFI_STATUS
EFIAPI
FvGetVolumeInfo (
@ -99,27 +107,25 @@ FvGetVolumeInfo (
IN OUT UINTN *BufferSize,
OUT VOID *Buffer
)
/*++
Routine Description:
Return information of type InformationType for the requested firmware
volume.
Arguments:
This - Pointer to EFI_FIRMWARE_VOLUME2_PROTOCOL.
InformationType - InformationType for requested.
BufferSize - On input, size of Buffer.On output, the amount of
data returned in Buffer.
Buffer - A poniter to the data buffer to return.
Returns:
EFI_SUCCESS - Successfully got volume Information.
--*/
{
return EFI_UNSUPPORTED;
}
/**
Set information of type InformationType for the requested firmware
volume.
@param This Pointer to EFI_FIRMWARE_VOLUME2_PROTOCOL.
@param InformationType InformationType for requested.
@param BufferSize On input, size of Buffer.On output, the amount of data
returned in Buffer.
@param Buffer A poniter to the data buffer to return.
@retval EFI_SUCCESS Successfully set volume Information.
**/
EFI_STATUS
EFIAPI
FvSetVolumeInfo (
@ -128,24 +134,9 @@ FvSetVolumeInfo (
IN UINTN BufferSize,
IN CONST VOID *Buffer
)
/*++
Routine Description:
Set information of type InformationType for the requested firmware
volume.
Arguments:
This - Pointer to EFI_FIRMWARE_VOLUME2_PROTOCOL.
InformationType - InformationType for requested.
BufferSize - On input, size of Buffer.On output, the amount of
data returned in Buffer.
Buffer - A poniter to the data buffer to return.
Returns:
EFI_SUCCESS - Successfully set volume Information.
--*/
{
return EFI_UNSUPPORTED;
}

View File

@ -36,23 +36,20 @@ Required Alignment Alignment Value in FFS Alignment Value in
UINT8 mFvAttributes[] = {0, 4, 7, 9, 10, 12, 15, 16};
/**
Convert the FFS File Attributes to FV File Attributes
@param FfsAttributes The attributes of UINT8 type.
@return The attributes of EFI_FV_FILE_ATTRIBUTES
**/
STATIC
EFI_FV_FILE_ATTRIBUTES
FfsAttributes2FvFileAttributes (
IN EFI_FFS_FILE_ATTRIBUTES FfsAttributes
)
/*++
Routine Description:
Convert the FFS File Attributes to FV File Attributes
Arguments:
FfsAttributes - The attributes of UINT8 type.
Returns:
The attributes of EFI_FV_FILE_ATTRIBUTES
--*/
{
FfsAttributes = (EFI_FFS_FILE_ATTRIBUTES)((FfsAttributes & FFS_ATTRIB_DATA_ALIGNMENT) >> 3);
ASSERT (FfsAttributes < 8);
@ -61,6 +58,53 @@ FfsAttributes2FvFileAttributes (
}
/**
Given the input key, search for the next matching file in the volume.
@param This Indicates the calling context.
@param Key Key is a pointer to a caller allocated
buffer that contains implementation specific
data that is used to track where to begin
the search for the next file. The size of
the buffer must be at least This->KeySize
bytes long. To reinitialize the search and
begin from the beginning of the firmware
volume, the entire buffer must be cleared to
zero. Other than clearing the buffer to
initiate a new search, the caller must not
modify the data in the buffer between calls
to GetNextFile().
@param FileType FileType is a pointer to a caller allocated
EFI_FV_FILETYPE. The GetNextFile() API can
filter it's search for files based on the
value of *FileType input. A *FileType input
of 0 causes GetNextFile() to search for
files of all types. If a file is found, the
file's type is returned in *FileType.
*FileType is not modified if no file is
found.
@param NameGuid NameGuid is a pointer to a caller allocated
EFI_GUID. If a file is found, the file's
name is returned in *NameGuid. *NameGuid is
not modified if no file is found.
@param Attributes Attributes is a pointer to a caller
allocated EFI_FV_FILE_ATTRIBUTES. If a file
is found, the file's attributes are returned
in *Attributes. *Attributes is not modified
if no file is found.
@param Size Size is a pointer to a caller allocated
UINTN. If a file is found, the file's size
is returned in *Size. *Size is not modified
if no file is found.
@retval EFI_SUCCESS Successfully find the file.
@retval EFI_DEVICE_ERROR Device error.
@retval EFI_ACCESS_DENIED Fv could not read.
@retval EFI_NOT_FOUND No matching file found.
@retval EFI_INVALID_PARAMETER Invalid parameter
**/
EFI_STATUS
EFIAPI
FvGetNextFile (
@ -69,51 +113,8 @@ FvGetNextFile (
IN OUT EFI_FV_FILETYPE *FileType,
OUT EFI_GUID *NameGuid,
OUT EFI_FV_FILE_ATTRIBUTES *Attributes,
OUT UINTN *Size
OUT UINTN *Size
)
/*++
Routine Description:
Given the input key, search for the next matching file in the volume.
Arguments:
This - Indicates the calling context.
FileType - FileType is a pointer to a caller allocated
EFI_FV_FILETYPE. The GetNextFile() API can filter it's
search for files based on the value of *FileType input.
A *FileType input of 0 causes GetNextFile() to search for
files of all types. If a file is found, the file's type
is returned in *FileType. *FileType is not modified if
no file is found.
Key - Key is a pointer to a caller allocated buffer that
contains implementation specific data that is used to
track where to begin the search for the next file.
The size of the buffer must be at least This->KeySize
bytes long. To reinitialize the search and begin from
the beginning of the firmware volume, the entire buffer
must be cleared to zero. Other than clearing the buffer
to initiate a new search, the caller must not modify the
data in the buffer between calls to GetNextFile().
NameGuid - NameGuid is a pointer to a caller allocated EFI_GUID.
If a file is found, the file's name is returned in
*NameGuid. *NameGuid is not modified if no file is
found.
Attributes - Attributes is a pointer to a caller allocated
EFI_FV_FILE_ATTRIBUTES. If a file is found, the file's
attributes are returned in *Attributes. *Attributes is
not modified if no file is found.
Size - Size is a pointer to a caller allocated UINTN.
If a file is found, the file's size is returned in *Size.
*Size is not modified if no file is found.
Returns:
EFI_SUCCESS - Successfully find the file.
EFI_DEVICE_ERROR - Device error.
EFI_ACCESS_DENIED - Fv could not read.
EFI_NOT_FOUND - No matching file found.
EFI_INVALID_PARAMETER - Invalid parameter
--*/
{
EFI_STATUS Status;
FV_DEVICE *FvDevice;
@ -218,6 +219,47 @@ Returns:
}
/**
Locates a file in the firmware volume and
copies it to the supplied buffer.
@param This Indicates the calling context.
@param NameGuid Pointer to an EFI_GUID, which is the
filename.
@param Buffer Buffer is a pointer to pointer to a buffer
in which the file or section contents or are
returned.
@param BufferSize BufferSize is a pointer to caller allocated
UINTN. On input *BufferSize indicates the
size in bytes of the memory region pointed
to by Buffer. On output, *BufferSize
contains the number of bytes required to
read the file.
@param FoundType FoundType is a pointer to a caller allocated
EFI_FV_FILETYPE that on successful return
from Read() contains the type of file read.
This output reflects the file type
irrespective of the value of the SectionType
input.
@param FileAttributes FileAttributes is a pointer to a caller
allocated EFI_FV_FILE_ATTRIBUTES. On
successful return from Read(),
*FileAttributes contains the attributes of
the file read.
@param AuthenticationStatus AuthenticationStatus is a pointer to a
caller allocated UINTN in which the
authentication status is returned.
@retval EFI_SUCCESS Successfully read to memory buffer.
@retval EFI_WARN_BUFFER_TOO_SMALL Buffer too small.
@retval EFI_NOT_FOUND Not found.
@retval EFI_DEVICE_ERROR Device error.
@retval EFI_ACCESS_DENIED Could not read.
@retval EFI_INVALID_PARAMETER Invalid parameter.
@retval EFI_OUT_OF_RESOURCES Not enough buffer to be allocated.
**/
EFI_STATUS
EFIAPI
FvReadFile (
@ -229,44 +271,6 @@ FvReadFile (
OUT EFI_FV_FILE_ATTRIBUTES *FileAttributes,
OUT UINT32 *AuthenticationStatus
)
/*++
Routine Description:
Locates a file in the firmware volume and
copies it to the supplied buffer.
Arguments:
This - Indicates the calling context.
NameGuid - Pointer to an EFI_GUID, which is the filename.
Buffer - Buffer is a pointer to pointer to a buffer in
which the file or section contents or are returned.
BufferSize - BufferSize is a pointer to caller allocated
UINTN. On input *BufferSize indicates the size
in bytes of the memory region pointed to by
Buffer. On output, *BufferSize contains the number
of bytes required to read the file.
FoundType - FoundType is a pointer to a caller allocated
EFI_FV_FILETYPE that on successful return from Read()
contains the type of file read. This output reflects
the file type irrespective of the value of the
SectionType input.
FileAttributes - FileAttributes is a pointer to a caller allocated
EFI_FV_FILE_ATTRIBUTES. On successful return from
Read(), *FileAttributes contains the attributes of
the file read.
AuthenticationStatus - AuthenticationStatus is a pointer to a caller
allocated UINTN in which the authentication status
is returned.
Returns:
EFI_SUCCESS - Successfully read to memory buffer.
EFI_WARN_BUFFER_TOO_SMALL - Buffer too small.
EFI_NOT_FOUND - Not found.
EFI_DEVICE_ERROR - Device error.
EFI_ACCESS_DENIED - Could not read.
EFI_INVALID_PARAMETER - Invalid parameter.
EFI_OUT_OF_RESOURCES - Not enough buffer to be allocated.
--*/
{
EFI_STATUS Status;
FV_DEVICE *FvDevice;
@ -361,6 +365,35 @@ Returns:
}
/**
Locates a section in a given FFS File and
copies it to the supplied buffer (not including section header).
@param This Indicates the calling context.
@param NameGuid Pointer to an EFI_GUID, which is the
filename.
@param SectionType Indicates the section type to return.
@param SectionInstance Indicates which instance of sections with a
type of SectionType to return.
@param Buffer Buffer is a pointer to pointer to a buffer
in which the file or section contents or are
returned.
@param BufferSize BufferSize is a pointer to caller allocated
UINTN.
@param AuthenticationStatus AuthenticationStatus is a pointer to a
caller allocated UINT32 in which the
authentication status is returned.
@retval EFI_SUCCESS Successfully read the file section into
buffer.
@retval EFI_WARN_BUFFER_TOO_SMALL Buffer too small.
@retval EFI_NOT_FOUND Section not found.
@retval EFI_DEVICE_ERROR Device error.
@retval EFI_ACCESS_DENIED Could not read.
@retval EFI_INVALID_PARAMETER Invalid parameter.
**/
EFI_STATUS
EFIAPI
FvReadFileSection (
@ -372,34 +405,6 @@ FvReadFileSection (
IN OUT UINTN *BufferSize,
OUT UINT32 *AuthenticationStatus
)
/*++
Routine Description:
Locates a section in a given FFS File and
copies it to the supplied buffer (not including section header).
Arguments:
This - Indicates the calling context.
NameGuid - Pointer to an EFI_GUID, which is the filename.
SectionType - Indicates the section type to return.
SectionInstance - Indicates which instance of sections with a type of
SectionType to return.
Buffer - Buffer is a pointer to pointer to a buffer in which
the file or section contents or are returned.
BufferSize - BufferSize is a pointer to caller allocated UINTN.
AuthenticationStatus -AuthenticationStatus is a pointer to a caller
allocated UINT32 in which the authentication status
is returned.
Returns:
EFI_SUCCESS - Successfully read the file section into buffer.
EFI_WARN_BUFFER_TOO_SMALL - Buffer too small.
EFI_NOT_FOUND - Section not found.
EFI_DEVICE_ERROR - Device error.
EFI_ACCESS_DENIED - Could not read.
EFI_INVALID_PARAMETER - Invalid parameter.
--*/
{
EFI_STATUS Status;
FV_DEVICE *FvDevice;
@ -482,3 +487,4 @@ Done:
return Status;
}

View File

@ -16,6 +16,28 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include <DxeMain.h>
/**
Writes one or more files to the firmware volume.
@param This Indicates the calling context.
@param NumberOfFiles Number of files.
@param WritePolicy WritePolicy indicates the level of reliability
for the write in the event of a power failure or
other system failure during the write operation.
@param FileData FileData is an pointer to an array of
EFI_FV_WRITE_DATA. Each element of array
FileData represents a file to be written.
@retval EFI_SUCCESS Files successfully written to firmware volume
@retval EFI_OUT_OF_RESOURCES Not enough buffer to be allocated.
@retval EFI_DEVICE_ERROR Device error.
@retval EFI_WRITE_PROTECTED Write protected.
@retval EFI_NOT_FOUND Not found.
@retval EFI_INVALID_PARAMETER Invalid parameter.
@retval EFI_UNSUPPORTED This function not supported.
**/
EFI_STATUS
EFIAPI
FvWriteFile (
@ -24,31 +46,8 @@ FvWriteFile (
IN EFI_FV_WRITE_POLICY WritePolicy,
IN EFI_FV_WRITE_FILE_DATA *FileData
)
/*++
Routine Description:
Writes one or more files to the firmware volume.
Arguments:
This - Indicates the calling context.
NumberOfFiles - Number of files.
WritePolicy - WritePolicy indicates the level of reliability for
the write in the event of a power failure or other
system failure during the write operation.
FileData - FileData is an pointer to an array of EFI_FV_WRITE_DATA.
Each element of FileData[] represents a file to be written.
Returns:
EFI_SUCCESS - Files successfully written to firmware volume
EFI_OUT_OF_RESOURCES - Not enough buffer to be allocated.
EFI_DEVICE_ERROR - Device error.
EFI_WRITE_PROTECTED - Write protected.
EFI_NOT_FOUND - Not found.
EFI_INVALID_PARAMETER - Invalid parameter.
EFI_UNSUPPORTED - This function not supported.
--*/
{
return EFI_UNSUPPORTED;
}

View File

@ -47,106 +47,123 @@ typedef struct {
/**
This routine is the driver initialization entry point. It initializes the
libraries, consumes FV hobs and NT_NON_MM_FV environment variable and
produces instances of FW_VOL_BLOCK_PROTOCOL as appropriate.
@param ImageHandle The image handle.
@param SystemTable The system table.
@retval EFI_SUCCESS Successfully initialized firmware volume block
driver.
**/
EFI_STATUS
EFIAPI
FwVolBlockDriverInit (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
/*++
Routine Description:
This routine is the driver initialization entry point. It initializes the
libraries, consumes FV hobs and NT_NON_MM_FV environment variable and
produces instances of FW_VOL_BLOCK_PROTOCOL as appropriate.
Arguments:
ImageHandle - The image handle.
SystemTable - The system table.
Returns:
EFI_SUCCESS - Successfully initialized firmware volume block driver.
--*/
;
/**
Retrieves Volume attributes. No polarity translations are done.
@param This Calling context
@param Attributes output buffer which contains attributes
@retval EFI_SUCCESS The firmware volume attributes were returned.
**/
EFI_STATUS
EFIAPI
FwVolBlockGetAttributes (
IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,
OUT EFI_FVB_ATTRIBUTES *Attributes
)
/*++
Routine Description:
Retrieves Volume attributes. No polarity translations are done.
Arguments:
This - Calling context
Attributes - output buffer which contains attributes
Returns:
EFI_SUCCESS - The firmware volume attributes were returned.
--*/
;
/**
Modifies the current settings of the firmware volume according to the input parameter.
@param This Calling context
@param Attributes input buffer which contains attributes
@retval EFI_SUCCESS The firmware volume attributes were returned.
@retval EFI_INVALID_PARAMETER The attributes requested are in conflict with
the capabilities as declared in the firmware
volume header.
@retval EFI_UNSUPPORTED Not supported.
**/
EFI_STATUS
EFIAPI
FwVolBlockSetAttributes (
IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,
IN CONST EFI_FVB_ATTRIBUTES *Attributes
)
/*++
Routine Description:
Modifies the current settings of the firmware volume according to the input parameter.
Arguments:
This - Calling context
Attributes - input buffer which contains attributes
Returns:
EFI_SUCCESS - The firmware volume attributes were returned.
EFI_INVALID_PARAMETER - The attributes requested are in conflict with the capabilities as
declared in the firmware volume header.
EFI_UNSUPPORTED - Not supported.
--*/
;
/**
The EraseBlock() function erases one or more blocks as denoted by the
variable argument list. The entire parameter list of blocks must be verified
prior to erasing any blocks. If a block is requested that does not exist
within the associated firmware volume (it has a larger index than the last
block of the firmware volume), the EraseBlock() function must return
EFI_INVALID_PARAMETER without modifying the contents of the firmware volume.
@param This Calling context
@param ... Starting LBA followed by Number of Lba to erase.
a -1 to terminate the list.
@retval EFI_SUCCESS The erase request was successfully completed.
@retval EFI_ACCESS_DENIED The firmware volume is in the WriteDisabled
state.
@retval EFI_DEVICE_ERROR The block device is not functioning correctly
and could not be written. The firmware device
may have been partially erased.
@retval EFI_INVALID_PARAMETER One or more of the LBAs listed in the variable
argument list do
@retval EFI_UNSUPPORTED Not supported.
**/
EFI_STATUS
EFIAPI
FwVolBlockEraseBlock (
IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,
...
)
/*++
Routine Description:
The EraseBlock() function erases one or more blocks as denoted by the
variable argument list. The entire parameter list of blocks must be verified
prior to erasing any blocks. If a block is requested that does not exist
within the associated firmware volume (it has a larger index than the last
block of the firmware volume), the EraseBlock() function must return
EFI_INVALID_PARAMETER without modifying the contents of the firmware volume.
Arguments:
This - Calling context
... - Starting LBA followed by Number of Lba to erase. a -1 to terminate
the list.
Returns:
EFI_SUCCESS - The erase request was successfully completed.
EFI_ACCESS_DENIED - The firmware volume is in the WriteDisabled state.
EFI_DEVICE_ERROR - The block device is not functioning correctly and could not be
written. The firmware device may have been partially erased.
EFI_INVALID_PARAMETER - One or more of the LBAs listed in the variable argument list do
EFI_UNSUPPORTED - Not supported.
--*/
;
/**
Read the specified number of bytes from the block to the input buffer.
@param This Indicates the calling context.
@param Lba The starting logical block index to read.
@param Offset Offset into the block at which to begin reading.
@param NumBytes Pointer to a UINT32. At entry, *NumBytes
contains the total size of the buffer. At exit,
*NumBytes contains the total number of bytes
actually read.
@param Buffer Pinter to a caller-allocated buffer that
contains the destine for the read.
@retval EFI_SUCCESS The firmware volume was read successfully.
@retval EFI_BAD_BUFFER_SIZE The read was attempted across an LBA boundary.
@retval EFI_ACCESS_DENIED Access denied.
@retval EFI_DEVICE_ERROR The block device is malfunctioning and could not
be read.
**/
EFI_STATUS
EFIAPI
FwVolBlockReadBlock (
@ -156,30 +173,34 @@ FwVolBlockReadBlock (
IN OUT UINTN *NumBytes,
IN OUT UINT8 *Buffer
)
/*++
Routine Description:
Read the specified number of bytes from the block to the input buffer.
Arguments:
This - Indicates the calling context.
Lba - The starting logical block index to read.
Offset - Offset into the block at which to begin reading.
NumBytes - Pointer to a UINT32. At entry, *NumBytes contains the
total size of the buffer. At exit, *NumBytes contains the
total number of bytes actually read.
Buffer - Pinter to a caller-allocated buffer that contains the destine
for the read.
Returns:
EFI_SUCCESS - The firmware volume was read successfully.
EFI_BAD_BUFFER_SIZE - The read was attempted across an LBA boundary.
EFI_ACCESS_DENIED - Access denied.
EFI_DEVICE_ERROR - The block device is malfunctioning and could not be read.
--*/
;
/**
Writes the specified number of bytes from the input buffer to the block.
@param This Indicates the calling context.
@param Lba The starting logical block index to write to.
@param Offset Offset into the block at which to begin writing.
@param NumBytes Pointer to a UINT32. At entry, *NumBytes
contains the total size of the buffer. At exit,
*NumBytes contains the total number of bytes
actually written.
@param Buffer Pinter to a caller-allocated buffer that
contains the source for the write.
@retval EFI_SUCCESS The firmware volume was written successfully.
@retval EFI_BAD_BUFFER_SIZE The write was attempted across an LBA boundary.
On output, NumBytes contains the total number of
bytes actually written.
@retval EFI_ACCESS_DENIED The firmware volume is in the WriteDisabled
state.
@retval EFI_DEVICE_ERROR The block device is malfunctioning and could not
be written.
@retval EFI_UNSUPPORTED Not supported.
**/
EFI_STATUS
EFIAPI
FwVolBlockWriteBlock (
@ -189,54 +210,47 @@ FwVolBlockWriteBlock (
IN OUT UINTN *NumBytes,
IN UINT8 *Buffer
)
/*++
Routine Description:
Writes the specified number of bytes from the input buffer to the block.
Arguments:
This - Indicates the calling context.
Lba - The starting logical block index to write to.
Offset - Offset into the block at which to begin writing.
NumBytes - Pointer to a UINT32. At entry, *NumBytes contains the
total size of the buffer. At exit, *NumBytes contains the
total number of bytes actually written.
Buffer - Pinter to a caller-allocated buffer that contains the source
for the write.
Returns:
EFI_SUCCESS - The firmware volume was written successfully.
EFI_BAD_BUFFER_SIZE - The write was attempted across an LBA boundary. On output,
NumBytes contains the total number of bytes actually written.
EFI_ACCESS_DENIED - The firmware volume is in the WriteDisabled state.
EFI_DEVICE_ERROR - The block device is malfunctioning and could not be written.
EFI_UNSUPPORTED - Not supported.
--*/
;
/**
Get Fvb's base address.
@param This Indicates the calling context.
@param Address Fvb device base address.
@retval EFI_SUCCESS Successfully got Fvb's base address.
@retval EFI_UNSUPPORTED Not supported.
**/
EFI_STATUS
EFIAPI
FwVolBlockGetPhysicalAddress (
IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,
OUT EFI_PHYSICAL_ADDRESS *Address
)
/*++
Routine Description:
Get Fvb's base address.
Arguments:
This - Indicates the calling context.
Address - Fvb device base address.
Returns:
EFI_SUCCESS - Successfully got Fvb's base address.
EFI_UNSUPPORTED - Not supported.
--*/
;
/**
Retrieves the size in bytes of a specific block within a firmware volume.
@param This Indicates the calling context.
@param Lba Indicates the block for which to return the
size.
@param BlockSize Pointer to a caller-allocated UINTN in which the
size of the block is returned.
@param NumberOfBlocks Pointer to a caller-allocated UINTN in which the
number of consecutive blocks starting with Lba
is returned. All blocks in this range have a
size of BlockSize.
@retval EFI_SUCCESS The firmware volume base address is returned.
@retval EFI_INVALID_PARAMETER The requested LBA is out of range.
**/
EFI_STATUS
EFIAPI
FwVolBlockGetBlockSize (
@ -245,71 +259,52 @@ FwVolBlockGetBlockSize (
OUT UINTN *BlockSize,
OUT UINTN *NumberOfBlocks
)
/*++
Routine Description:
Retrieves the size in bytes of a specific block within a firmware volume.
Arguments:
This - Indicates the calling context.
Lba - Indicates the block for which to return the size.
BlockSize - Pointer to a caller-allocated UINTN in which the size of the
block is returned.
NumberOfBlocks - Pointer to a caller-allocated UINTN in which the number of
consecutive blocks starting with Lba is returned. All blocks
in this range have a size of BlockSize.
Returns:
EFI_SUCCESS - The firmware volume base address is returned.
EFI_INVALID_PARAMETER - The requested LBA is out of range.
--*/
;
/**
This routine is the driver initialization entry point. It initializes the
libraries, consumes FV hobs and NT_NON_MM_FV environment variable and
produces instances of FW_VOL_BLOCK_PROTOCOL as appropriate.
@param ImageHandle The image handle.
@param SystemTable The system table.
@retval EFI_SUCCESS Successfully initialized firmware volume block
driver.
**/
EFI_STATUS
FwVolBlockDriverInit (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
/*++
Routine Description:
This routine is the driver initialization entry point. It initializes the
libraries, consumes FV hobs and NT_NON_MM_FV environment variable and
produces instances of FW_VOL_BLOCK_PROTOCOL as appropriate.
Arguments:
ImageHandle - The image handle.
SystemTable - The system table.
Returns:
Status code
--*/
;
/**
This routine produces a firmware volume block protocol on a given
buffer.
@param BaseAddress base address of the firmware volume image
@param Length length of the firmware volume image
@param ParentHandle handle of parent firmware volume, if this image
came from an FV image file in another firmware
volume (ala capsules)
@param FvProtocol Firmware volume block protocol produced.
@retval EFI_VOLUME_CORRUPTED Volume corrupted.
@retval EFI_OUT_OF_RESOURCES No enough buffer to be allocated.
@retval EFI_SUCCESS Successfully produced a FVB protocol on given
buffer.
**/
EFI_STATUS
ProduceFVBProtocolOnBuffer (
IN EFI_PHYSICAL_ADDRESS BaseAddress,
IN UINT64 Length,
IN EFI_HANDLE ParentHandle,
OUT EFI_HANDLE *FvProtocolHandle OPTIONAL
OUT EFI_HANDLE *FvProtocol OPTIONAL
)
/*++
Routine Description:
This routine produces a firmware volume block protocol on a given
buffer.
Arguments:
BaseAddress - base address of the firmware volume image
Length - length of the firmware volume image
ParentHandle - handle of parent firmware volume, if this
image came from an FV image file in another
firmware volume (ala capsules)
FvProtocolHandle - Firmware volume block protocol produced.
Returns:
EFI_VOLUME_CORRUPTED - Volume corrupted.
EFI_OUT_OF_RESOURCES - No enough buffer to be allocated.
EFI_SUCCESS - Successfully produced a FVB protocol on given buffer.
--*/
;
#endif

View File

@ -1,11 +1,11 @@
/**@file
Firmware Volume Block protocol.. Consumes FV hobs and creates
/** @file
Firmware Volume Block protocol. Consumes FV hobs and creates
appropriate block protocols.
Also consumes NT_NON_MM_FV envinronment variable and produces appropriate
block protocols fro them also... (this is TBD)
Copyright (c) 2006, Intel Corporation
Copyright (c) 2006 - 2008, Intel Corporation
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@ -58,25 +58,22 @@ EFI_FW_VOL_BLOCK_DEVICE mFwVolBlock = {
/**
Retrieves Volume attributes. No polarity translations are done.
@param This Calling context
@param Attributes output buffer which contains attributes
@retval EFI_SUCCESS The firmware volume attributes were returned.
**/
EFI_STATUS
EFIAPI
FwVolBlockGetAttributes (
IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,
OUT EFI_FVB_ATTRIBUTES *Attributes
)
/*++
Routine Description:
Retrieves Volume attributes. No polarity translations are done.
Arguments:
This - Calling context
Attributes - output buffer which contains attributes
Returns:
EFI_SUCCESS - The firmware volume attributes were returned.
--*/
{
EFI_FW_VOL_BLOCK_DEVICE *FvbDevice;
@ -91,67 +88,87 @@ Returns:
}
/**
Modifies the current settings of the firmware volume according to the input parameter.
@param This Calling context
@param Attributes input buffer which contains attributes
@retval EFI_SUCCESS The firmware volume attributes were returned.
@retval EFI_INVALID_PARAMETER The attributes requested are in conflict with
the capabilities as declared in the firmware
volume header.
@retval EFI_UNSUPPORTED Not supported.
**/
EFI_STATUS
EFIAPI
FwVolBlockSetAttributes (
IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,
IN CONST EFI_FVB_ATTRIBUTES *Attributes
)
/*++
Routine Description:
Modifies the current settings of the firmware volume according to the input parameter.
Arguments:
This - Calling context
Attributes - input buffer which contains attributes
Returns:
EFI_SUCCESS - The firmware volume attributes were returned.
EFI_INVALID_PARAMETER - The attributes requested are in conflict with the capabilities as
declared in the firmware volume header.
EFI_UNSUPPORTED - Not supported.
--*/
{
return EFI_UNSUPPORTED;
}
/**
The EraseBlock() function erases one or more blocks as denoted by the
variable argument list. The entire parameter list of blocks must be verified
prior to erasing any blocks. If a block is requested that does not exist
within the associated firmware volume (it has a larger index than the last
block of the firmware volume), the EraseBlock() function must return
EFI_INVALID_PARAMETER without modifying the contents of the firmware volume.
@param This Calling context
@param ... Starting LBA followed by Number of Lba to erase.
a -1 to terminate the list.
@retval EFI_SUCCESS The erase request was successfully completed.
@retval EFI_ACCESS_DENIED The firmware volume is in the WriteDisabled
state.
@retval EFI_DEVICE_ERROR The block device is not functioning correctly
and could not be written. The firmware device
may have been partially erased.
@retval EFI_INVALID_PARAMETER One or more of the LBAs listed in the variable
argument list do
@retval EFI_UNSUPPORTED Not supported.
**/
EFI_STATUS
EFIAPI
FwVolBlockEraseBlock (
IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,
...
)
/*++
Routine Description:
The EraseBlock() function erases one or more blocks as denoted by the
variable argument list. The entire parameter list of blocks must be verified
prior to erasing any blocks. If a block is requested that does not exist
within the associated firmware volume (it has a larger index than the last
block of the firmware volume), the EraseBlock() function must return
EFI_INVALID_PARAMETER without modifying the contents of the firmware volume.
Arguments:
This - Calling context
... - Starting LBA followed by Number of Lba to erase. a -1 to terminate
the list.
Returns:
EFI_SUCCESS - The erase request was successfully completed.
EFI_ACCESS_DENIED - The firmware volume is in the WriteDisabled state.
EFI_DEVICE_ERROR - The block device is not functioning correctly and could not be
written. The firmware device may have been partially erased.
EFI_INVALID_PARAMETER - One or more of the LBAs listed in the variable argument list do
EFI_UNSUPPORTED - Not supported.
--*/
{
return EFI_UNSUPPORTED;
}
/**
Read the specified number of bytes from the block to the input buffer.
@param This Indicates the calling context.
@param Lba The starting logical block index to read.
@param Offset Offset into the block at which to begin reading.
@param NumBytes Pointer to a UINT32. At entry, *NumBytes
contains the total size of the buffer. At exit,
*NumBytes contains the total number of bytes
actually read.
@param Buffer Pinter to a caller-allocated buffer that
contains the destine for the read.
@retval EFI_SUCCESS The firmware volume was read successfully.
@retval EFI_BAD_BUFFER_SIZE The read was attempted across an LBA boundary.
@retval EFI_ACCESS_DENIED Access denied.
@retval EFI_DEVICE_ERROR The block device is malfunctioning and could not
be read.
**/
EFI_STATUS
EFIAPI
FwVolBlockReadBlock (
@ -161,27 +178,6 @@ FwVolBlockReadBlock (
IN OUT UINTN *NumBytes,
IN OUT UINT8 *Buffer
)
/*++
Routine Description:
Read the specified number of bytes from the block to the input buffer.
Arguments:
This - Indicates the calling context.
Lba - The starting logical block index to read.
Offset - Offset into the block at which to begin reading.
NumBytes - Pointer to a UINT32. At entry, *NumBytes contains the
total size of the buffer. At exit, *NumBytes contains the
total number of bytes actually read.
Buffer - Pinter to a caller-allocated buffer that contains the destine
for the read.
Returns:
EFI_SUCCESS - The firmware volume was read successfully.
EFI_BAD_BUFFER_SIZE - The read was attempted across an LBA boundary.
EFI_ACCESS_DENIED - Access denied.
EFI_DEVICE_ERROR - The block device is malfunctioning and could not be read.
--*/
{
EFI_FW_VOL_BLOCK_DEVICE *FvbDevice;
EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader;
@ -242,6 +238,31 @@ Returns:
}
/**
Writes the specified number of bytes from the input buffer to the block.
@param This Indicates the calling context.
@param Lba The starting logical block index to write to.
@param Offset Offset into the block at which to begin writing.
@param NumBytes Pointer to a UINT32. At entry, *NumBytes
contains the total size of the buffer. At exit,
*NumBytes contains the total number of bytes
actually written.
@param Buffer Pinter to a caller-allocated buffer that
contains the source for the write.
@retval EFI_SUCCESS The firmware volume was written successfully.
@retval EFI_BAD_BUFFER_SIZE The write was attempted across an LBA boundary.
On output, NumBytes contains the total number of
bytes actually written.
@retval EFI_ACCESS_DENIED The firmware volume is in the WriteDisabled
state.
@retval EFI_DEVICE_ERROR The block device is malfunctioning and could not
be written.
@retval EFI_UNSUPPORTED Not supported.
**/
EFI_STATUS
EFIAPI
FwVolBlockWriteBlock (
@ -251,53 +272,28 @@ FwVolBlockWriteBlock (
IN OUT UINTN *NumBytes,
IN UINT8 *Buffer
)
/*++
Routine Description:
Writes the specified number of bytes from the input buffer to the block.
Arguments:
This - Indicates the calling context.
Lba - The starting logical block index to write to.
Offset - Offset into the block at which to begin writing.
NumBytes - Pointer to a UINT32. At entry, *NumBytes contains the
total size of the buffer. At exit, *NumBytes contains the
total number of bytes actually written.
Buffer - Pinter to a caller-allocated buffer that contains the source
for the write.
Returns:
EFI_SUCCESS - The firmware volume was written successfully.
EFI_BAD_BUFFER_SIZE - The write was attempted across an LBA boundary. On output,
NumBytes contains the total number of bytes actually written.
EFI_ACCESS_DENIED - The firmware volume is in the WriteDisabled state.
EFI_DEVICE_ERROR - The block device is malfunctioning and could not be written.
EFI_UNSUPPORTED - Not supported.
--*/
{
return EFI_UNSUPPORTED;
}
/**
Get Fvb's base address.
@param This Indicates the calling context.
@param Address Fvb device base address.
@retval EFI_SUCCESS Successfully got Fvb's base address.
@retval EFI_UNSUPPORTED Not supported.
**/
EFI_STATUS
EFIAPI
FwVolBlockGetPhysicalAddress (
IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,
OUT EFI_PHYSICAL_ADDRESS *Address
)
/*++
Routine Description:
Get Fvb's base address.
Arguments:
This - Indicates the calling context.
Address - Fvb device base address.
Returns:
EFI_SUCCESS - Successfully got Fvb's base address.
EFI_UNSUPPORTED - Not supported.
--*/
{
EFI_FW_VOL_BLOCK_DEVICE *FvbDevice;
@ -312,6 +308,24 @@ Returns:
}
/**
Retrieves the size in bytes of a specific block within a firmware volume.
@param This Indicates the calling context.
@param Lba Indicates the block for which to return the
size.
@param BlockSize Pointer to a caller-allocated UINTN in which the
size of the block is returned.
@param NumberOfBlocks Pointer to a caller-allocated UINTN in which the
number of consecutive blocks starting with Lba
is returned. All blocks in this range have a
size of BlockSize.
@retval EFI_SUCCESS The firmware volume base address is returned.
@retval EFI_INVALID_PARAMETER The requested LBA is out of range.
**/
EFI_STATUS
EFIAPI
FwVolBlockGetBlockSize (
@ -320,23 +334,6 @@ FwVolBlockGetBlockSize (
IN OUT UINTN *BlockSize,
IN OUT UINTN *NumberOfBlocks
)
/*++
Routine Description:
Retrieves the size in bytes of a specific block within a firmware volume.
Arguments:
This - Indicates the calling context.
Lba - Indicates the block for which to return the size.
BlockSize - Pointer to a caller-allocated UINTN in which the size of the
block is returned.
NumberOfBlocks - Pointer to a caller-allocated UINTN in which the number of
consecutive blocks starting with Lba is returned. All blocks
in this range have a size of BlockSize.
Returns:
EFI_SUCCESS - The firmware volume base address is returned.
EFI_INVALID_PARAMETER - The requested LBA is out of range.
--*/
{
UINTN TotalBlocks;
EFI_FW_VOL_BLOCK_DEVICE *FvbDevice;
@ -379,6 +376,24 @@ Returns:
}
/**
This routine produces a firmware volume block protocol on a given
buffer.
@param BaseAddress base address of the firmware volume image
@param Length length of the firmware volume image
@param ParentHandle handle of parent firmware volume, if this image
came from an FV image file in another firmware
volume (ala capsules)
@param FvProtocol Firmware volume block protocol produced.
@retval EFI_VOLUME_CORRUPTED Volume corrupted.
@retval EFI_OUT_OF_RESOURCES No enough buffer to be allocated.
@retval EFI_SUCCESS Successfully produced a FVB protocol on given
buffer.
**/
EFI_STATUS
ProduceFVBProtocolOnBuffer (
IN EFI_PHYSICAL_ADDRESS BaseAddress,
@ -386,26 +401,6 @@ ProduceFVBProtocolOnBuffer (
IN EFI_HANDLE ParentHandle,
OUT EFI_HANDLE *FvProtocol OPTIONAL
)
/*++
Routine Description:
This routine produces a firmware volume block protocol on a given
buffer.
Arguments:
BaseAddress - base address of the firmware volume image
Length - length of the firmware volume image
ParentHandle - handle of parent firmware volume, if this
image came from an FV image file in another
firmware volume (ala capsules)
FvProtocol - Firmware volume block protocol produced.
Returns:
EFI_VOLUME_CORRUPTED - Volume corrupted.
EFI_OUT_OF_RESOURCES - No enough buffer to be allocated.
EFI_SUCCESS - Successfully produced a FVB protocol on given buffer.
--*/
{
EFI_STATUS Status;
EFI_FW_VOL_BLOCK_DEVICE *FvbDev;
@ -511,24 +506,25 @@ Returns:
}
/**
This routine is the driver initialization entry point. It initializes the
libraries, consumes FV hobs and NT_NON_MM_FV environment variable and
produces instances of FW_VOL_BLOCK_PROTOCOL as appropriate.
@param ImageHandle The image handle.
@param SystemTable The system table.
@retval EFI_SUCCESS Successfully initialized firmware volume block
driver.
**/
EFI_STATUS
EFIAPI
FwVolBlockDriverInit (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
/*++
Routine Description:
This routine is the driver initialization entry point. It initializes the
libraries, consumes FV hobs and NT_NON_MM_FV environment variable and
produces instances of FW_VOL_BLOCK_PROTOCOL as appropriate.
Arguments:
ImageHandle - The image handle.
SystemTable - The system table.
Returns:
EFI_SUCCESS - Successfully initialized firmware volume block driver.
--*/
{
EFI_PEI_HOB_POINTERS FvHob;
//
@ -546,33 +542,30 @@ Returns:
}
/**
This DXE service routine is used to process a firmware volume. In
particular, it can be called by BDS to process a single firmware
volume found in a capsule.
@param FvHeader pointer to a firmware volume header
@param Size the size of the buffer pointed to by FvHeader
@param FVProtocolHandle the handle on which a firmware volume protocol
was produced for the firmware volume passed in.
@retval EFI_OUT_OF_RESOURCES if an FVB could not be produced due to lack of
system resources
@retval EFI_VOLUME_CORRUPTED if the volume was corrupted
@retval EFI_SUCCESS a firmware volume protocol was produced for the
firmware volume
**/
EFI_STATUS
CoreProcessFirmwareVolume (
IN VOID *FvHeader,
IN UINTN Size,
OUT EFI_HANDLE *FVProtocolHandle
)
/*++
Routine Description:
This DXE service routine is used to process a firmware volume. In
particular, it can be called by BDS to process a single firmware
volume found in a capsule.
Arguments:
FvHeader - pointer to a firmware volume header
Size - the size of the buffer pointed to by FvHeader
FVProtocolHandle - the handle on which a firmware volume protocol
was produced for the firmware volume passed in.
Returns:
EFI_OUT_OF_RESOURCES - if an FVB could not be produced due to lack of
system resources
EFI_VOLUME_CORRUPTED - if the volume was corrupted
EFI_SUCCESS - a firmware volume protocol was produced for the
firmware volume
--*/
{
VOID *Ptr;
EFI_STATUS Status;
@ -604,3 +597,4 @@ Returns:
}

View File

@ -1,4 +1,4 @@
/**@file
/** @file
Firmware File System protocol. Layers on top of Firmware
Block protocol to produce a file abstraction of FV based files.
@ -14,8 +14,8 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#ifndef __FWVOL_H
#define __FWVOL_H
#ifndef __FW_VOL_DRIVER_H_
#define __FW_VOL_DRIVER_H_
#define FV2_DEVICE_SIGNATURE EFI_SIGNATURE_32 ('_', 'F', 'V', '2')
@ -48,50 +48,90 @@ typedef struct {
#define FV_DEVICE_FROM_THIS(a) CR(a, FV_DEVICE, Fv, FV2_DEVICE_SIGNATURE)
/**
Retrieves attributes, insures positive polarity of attribute bits, returns
resulting attributes in output parameter.
@param This Calling context
@param Attributes output buffer which contains attributes
@retval EFI_SUCCESS Successfully got volume attributes
**/
EFI_STATUS
EFIAPI
FvGetVolumeAttributes (
IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL *This,
OUT EFI_FV_ATTRIBUTES *Attributes
)
/*++
Routine Description:
Retrieves attributes, insures positive polarity of attribute bits, returns
resulting attributes in output parameter
Arguments:
This - Calling context
Attributes - output buffer which contains attributes
Returns:
EFI_SUCCESS - Successfully got volume attributes
--*/
;
/**
Sets current attributes for volume
@param This Calling context
@param Attributes At input, contains attributes to be set. At output
contains new value of FV
@retval EFI_UNSUPPORTED Could not be set.
**/
EFI_STATUS
EFIAPI
FvSetVolumeAttributes (
IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL *This,
IN OUT EFI_FV_ATTRIBUTES *Attributes
)
/*++
Routine Description:
Sets current attributes for volume
Arguments:
This - Calling context
Attributes - At input, contains attributes to be set. At output contains
new value of FV
Returns:
EFI_UNSUPPORTED - Could not be set.
--*/
;
/**
Given the input key, search for the next matching file in the volume.
@param This Indicates the calling context.
@param Key Key is a pointer to a caller allocated
buffer that contains implementation specific
data that is used to track where to begin
the search for the next file. The size of
the buffer must be at least This->KeySize
bytes long. To reinitialize the search and
begin from the beginning of the firmware
volume, the entire buffer must be cleared to
zero. Other than clearing the buffer to
initiate a new search, the caller must not
modify the data in the buffer between calls
to GetNextFile().
@param FileType FileType is a pointer to a caller allocated
EFI_FV_FILETYPE. The GetNextFile() API can
filter it's search for files based on the
value of *FileType input. A *FileType input
of 0 causes GetNextFile() to search for
files of all types. If a file is found, the
file's type is returned in *FileType.
*FileType is not modified if no file is
found.
@param NameGuid NameGuid is a pointer to a caller allocated
EFI_GUID. If a file is found, the file's
name is returned in *NameGuid. *NameGuid is
not modified if no file is found.
@param Attributes Attributes is a pointer to a caller
allocated EFI_FV_FILE_ATTRIBUTES. If a file
is found, the file's attributes are returned
in *Attributes. *Attributes is not modified
if no file is found.
@param Size Size is a pointer to a caller allocated
UINTN. If a file is found, the file's size
is returned in *Size. *Size is not modified
if no file is found.
@retval EFI_SUCCESS Successfully find the file.
@retval EFI_DEVICE_ERROR Device error.
@retval EFI_ACCESS_DENIED Fv could not read.
@retval EFI_NOT_FOUND No matching file found.
@retval EFI_INVALID_PARAMETER Invalid parameter
**/
EFI_STATUS
EFIAPI
FvGetNextFile (
@ -102,52 +142,50 @@ FvGetNextFile (
OUT EFI_FV_FILE_ATTRIBUTES *Attributes,
OUT UINTN *Size
)
/*++
Routine Description:
Given the input key, search for the next matching file in the volume.
Arguments:
This - Indicates the calling context.
FileType - FileType is a pointer to a caller allocated
EFI_FV_FILETYPE. The GetNextFile() API can filter it's
search for files based on the value of *FileType input.
A *FileType input of 0 causes GetNextFile() to search for
files of all types. If a file is found, the file's type
is returned in *FileType. *FileType is not modified if
no file is found.
Key - Key is a pointer to a caller allocated buffer that
contains implementation specific data that is used to
track where to begin the search for the next file.
The size of the buffer must be at least This->KeySize
bytes long. To reinitialize the search and begin from
the beginning of the firmware volume, the entire buffer
must be cleared to zero. Other than clearing the buffer
to initiate a new search, the caller must not modify the
data in the buffer between calls to GetNextFile().
NameGuid - NameGuid is a pointer to a caller allocated EFI_GUID.
If a file is found, the file's name is returned in
*NameGuid. *NameGuid is not modified if no file is
found.
Attributes - Attributes is a pointer to a caller allocated
EFI_FV_FILE_ATTRIBUTES. If a file is found, the file's
attributes are returned in *Attributes. *Attributes is
not modified if no file is found.
Size - Size is a pointer to a caller allocated UINTN.
If a file is found, the file's size is returned in *Size.
*Size is not modified if no file is found.
Returns:
EFI_SUCCESS - Successfully find the file.
EFI_DEVICE_ERROR - Device error.
EFI_ACCESS_DENIED - Fv could not read.
EFI_NOT_FOUND - No matching file found.
EFI_INVALID_PARAMETER - Invalid parameter
--*/
;
/**
Locates a file in the firmware volume and
copies it to the supplied buffer.
@param This Indicates the calling context.
@param NameGuid Pointer to an EFI_GUID, which is the
filename.
@param Buffer Buffer is a pointer to pointer to a buffer
in which the file or section contents or are
returned.
@param BufferSize BufferSize is a pointer to caller allocated
UINTN. On input *BufferSize indicates the
size in bytes of the memory region pointed
to by Buffer. On output, *BufferSize
contains the number of bytes required to
read the file.
@param FoundType FoundType is a pointer to a caller allocated
EFI_FV_FILETYPE that on successful return
from Read() contains the type of file read.
This output reflects the file type
irrespective of the value of the SectionType
input.
@param FileAttributes FileAttributes is a pointer to a caller
allocated EFI_FV_FILE_ATTRIBUTES. On
successful return from Read(),
*FileAttributes contains the attributes of
the file read.
@param AuthenticationStatus AuthenticationStatus is a pointer to a
caller allocated UINTN in which the
authentication status is returned.
@retval EFI_SUCCESS Successfully read to memory buffer.
@retval EFI_WARN_BUFFER_TOO_SMALL Buffer too small.
@retval EFI_NOT_FOUND Not found.
@retval EFI_DEVICE_ERROR Device error.
@retval EFI_ACCESS_DENIED Could not read.
@retval EFI_INVALID_PARAMETER Invalid parameter.
@retval EFI_OUT_OF_RESOURCES Not enough buffer to be allocated.
**/
EFI_STATUS
EFIAPI
FvReadFile (
@ -159,46 +197,37 @@ FvReadFile (
OUT EFI_FV_FILE_ATTRIBUTES *FileAttributes,
OUT UINT32 *AuthenticationStatus
)
/*++
Routine Description:
Locates a file in the firmware volume and
copies it to the supplied buffer.
Arguments:
This - Indicates the calling context.
NameGuid - Pointer to an EFI_GUID, which is the filename.
Buffer - Buffer is a pointer to pointer to a buffer in
which the file or section contents or are returned.
BufferSize - BufferSize is a pointer to caller allocated
UINTN. On input *BufferSize indicates the size
in bytes of the memory region pointed to by
Buffer. On output, *BufferSize contains the number
of bytes required to read the file.
FoundType - FoundType is a pointer to a caller allocated
EFI_FV_FILETYPE that on successful return from Read()
contains the type of file read. This output reflects
the file type irrespective of the value of the
SectionType input.
FileAttributes - FileAttributes is a pointer to a caller allocated
EFI_FV_FILE_ATTRIBUTES. On successful return from
Read(), *FileAttributes contains the attributes of
the file read.
AuthenticationStatus - AuthenticationStatus is a pointer to a caller
allocated UINTN in which the authentication status
is returned.
Returns:
EFI_SUCCESS - Successfully read to memory buffer.
EFI_WARN_BUFFER_TOO_SMALL - Buffer too small.
EFI_NOT_FOUND - Not found.
EFI_DEVICE_ERROR - Device error.
EFI_ACCESS_DENIED - Could not read.
EFI_INVALID_PARAMETER - Invalid parameter.
EFI_OUT_OF_RESOURCES - Not enough buffer to be allocated.
--*/
;
/**
Locates a section in a given FFS File and
copies it to the supplied buffer (not including section header).
@param This Indicates the calling context.
@param NameGuid Pointer to an EFI_GUID, which is the
filename.
@param SectionType Indicates the section type to return.
@param SectionInstance Indicates which instance of sections with a
type of SectionType to return.
@param Buffer Buffer is a pointer to pointer to a buffer
in which the file or section contents or are
returned.
@param BufferSize BufferSize is a pointer to caller allocated
UINTN.
@param AuthenticationStatus AuthenticationStatus is a pointer to a
caller allocated UINT32 in which the
authentication status is returned.
@retval EFI_SUCCESS Successfully read the file section into
buffer.
@retval EFI_WARN_BUFFER_TOO_SMALL Buffer too small.
@retval EFI_NOT_FOUND Section not found.
@retval EFI_DEVICE_ERROR Device error.
@retval EFI_ACCESS_DENIED Could not read.
@retval EFI_INVALID_PARAMETER Invalid parameter.
**/
EFI_STATUS
EFIAPI
FvReadFileSection (
@ -210,36 +239,30 @@ FvReadFileSection (
IN OUT UINTN *BufferSize,
OUT UINT32 *AuthenticationStatus
)
/*++
Routine Description:
Locates a section in a given FFS File and
copies it to the supplied buffer (not including section header).
Arguments:
This - Indicates the calling context.
NameGuid - Pointer to an EFI_GUID, which is the filename.
SectionType - Indicates the section type to return.
SectionInstance - Indicates which instance of sections with a type of
SectionType to return.
Buffer - Buffer is a pointer to pointer to a buffer in which
the file or section contents or are returned.
BufferSize - BufferSize is a pointer to caller allocated UINTN.
AuthenticationStatus -AuthenticationStatus is a pointer to a caller
allocated UINT32 in which the authentication status
is returned.
Returns:
EFI_SUCCESS - Successfully read the file section into buffer.
EFI_WARN_BUFFER_TOO_SMALL - Buffer too small.
EFI_NOT_FOUND - Section not found.
EFI_DEVICE_ERROR - Device error.
EFI_ACCESS_DENIED - Could not read.
EFI_INVALID_PARAMETER - Invalid parameter.
--*/
;
/**
Writes one or more files to the firmware volume.
@param This Indicates the calling context.
@param NumberOfFiles Number of files.
@param WritePolicy WritePolicy indicates the level of reliability
for the write in the event of a power failure or
other system failure during the write operation.
@param FileData FileData is an pointer to an array of
EFI_FV_WRITE_DATA. Each element of array
FileData represents a file to be written.
@retval EFI_SUCCESS Files successfully written to firmware volume
@retval EFI_OUT_OF_RESOURCES Not enough buffer to be allocated.
@retval EFI_DEVICE_ERROR Device error.
@retval EFI_WRITE_PROTECTED Write protected.
@retval EFI_NOT_FOUND Not found.
@retval EFI_INVALID_PARAMETER Invalid parameter.
@retval EFI_UNSUPPORTED This function not supported.
**/
EFI_STATUS
EFIAPI
FvWriteFile (
@ -248,31 +271,22 @@ FvWriteFile (
IN EFI_FV_WRITE_POLICY WritePolicy,
IN EFI_FV_WRITE_FILE_DATA *FileData
)
/*++
Routine Description:
Writes one or more files to the firmware volume.
Arguments:
This - Indicates the calling context.
WritePolicy - WritePolicy indicates the level of reliability for
the write in the event of a power failure or other
system failure during the write operation.
FileData - FileData is an pointer to an array of EFI_FV_WRITE_DATA.
Each element of FileData[] represents a file to be written.
Returns:
EFI_SUCCESS - Files successfully written to firmware volume
EFI_OUT_OF_RESOURCES - Not enough buffer to be allocated.
EFI_DEVICE_ERROR - Device error.
EFI_WRITE_PROTECTED - Write protected.
EFI_NOT_FOUND - Not found.
EFI_INVALID_PARAMETER - Invalid parameter.
EFI_UNSUPPORTED - This function not supported.
--*/
;
/**
Return information of type InformationType for the requested firmware
volume.
@param This Pointer to EFI_FIRMWARE_VOLUME2_PROTOCOL.
@param InformationType InformationType for requested.
@param BufferSize On input, size of Buffer.On output, the amount of data
returned in Buffer.
@param Buffer A poniter to the data buffer to return.
@retval EFI_SUCCESS Successfully got volume Information.
**/
EFI_STATUS
EFIAPI
FvGetVolumeInfo (
@ -281,25 +295,23 @@ FvGetVolumeInfo (
IN OUT UINTN *BufferSize,
OUT VOID *Buffer
)
/*++
Routine Description:
Return information of type InformationType for the requested firmware
volume.
Arguments:
This - Pointer to EFI_FIRMWARE_VOLUME2_PROTOCOL.
InformationType - InformationType for requested.
BufferSize - On input, size of Buffer.On output, the amount of
data returned in Buffer.
Buffer - A poniter to the data buffer to return.
Returns:
EFI_SUCCESS - Successfully got volume Information.
--*/
;
/**
Set information of type InformationType for the requested firmware
volume.
@param This Pointer to EFI_FIRMWARE_VOLUME2_PROTOCOL.
@param InformationType InformationType for requested.
@param BufferSize On input, size of Buffer.On output, the amount of data
returned in Buffer.
@param Buffer A poniter to the data buffer to return.
@retval EFI_SUCCESS Successfully set volume Information.
**/
EFI_STATUS
EFIAPI
FvSetVolumeInfo (
@ -308,22 +320,6 @@ FvSetVolumeInfo (
IN UINTN BufferSize,
IN CONST VOID *Buffer
)
/*++
Routine Description:
Set information of type InformationType for the requested firmware
volume.
Arguments:
This - Pointer to EFI_FIRMWARE_VOLUME2_PROTOCOL.
InformationType - InformationType for requested.
BufferSize - On input, size of Buffer.On output, the amount of
data returned in Buffer.
Buffer - A poniter to the data buffer to return.
Returns:
EFI_SUCCESS - Successfully set volume Information.
--*/
;
//
@ -338,175 +334,153 @@ typedef enum {
} EFI_CHECKSUM_TYPE;
/**
Check if a block of buffer is erased.
@param ErasePolarity Erase polarity attribute of the firmware volume
@param InBuffer The buffer to be checked
@param BufferSize Size of the buffer in bytes
@retval TRUE The block of buffer is erased
@retval FALSE The block of buffer is not erased
**/
BOOLEAN
IsBufferErased (
IN UINT8 ErasePolarity,
IN VOID *Buffer,
IN UINTN BufferSize
)
/*++
Routine Description:
Check if a block of buffer is erased
Arguments:
ErasePolarity - Erase polarity attribute of the firmware volume
Buffer - The buffer to be checked
BufferSize - Size of the buffer in bytes
Returns:
TRUE - The block of buffer is erased
FALSE - The block of buffer is not erased
--*/
;
/**
Get the FFS file state by checking the highest bit set in the header's state field.
@param ErasePolarity Erase polarity attribute of the firmware volume
@param FfsHeader Points to the FFS file header
@return FFS File state
**/
EFI_FFS_FILE_STATE
GetFileState (
IN UINT8 ErasePolarity,
IN EFI_FFS_FILE_HEADER *FfsHeader
)
/*++
Routine Description:
Get the FFS file state by checking the highest bit set in the header's state field
Arguments:
ErasePolarity - Erase polarity attribute of the firmware volume
FfsHeader - Points to the FFS file header
Returns:
FFS File state
--*/
;
/**
Set the FFS file state.
@param State The state to be set.
@param FfsHeader Points to the FFS file header
@return None.
**/
VOID
SetFileState (
IN UINT8 State,
IN EFI_FFS_FILE_HEADER *FfsHeader
)
/*++
Routine Description:
Set the FFS file state.
Arguments:
State - The state to be set.
FfsHeader - Points to the FFS file header
Returns:
None.
--*/
;
/**
Verify checksum of the firmware volume header.
@param FvHeader Points to the firmware volume header to be checked
@retval TRUE Checksum verification passed
@retval FALSE Checksum verification failed
**/
BOOLEAN
VerifyFvHeaderChecksum (
IN EFI_FIRMWARE_VOLUME_HEADER *FvHeader
)
/*++
Routine Description:
Verify checksum of the firmware volume header
Arguments:
FvHeader - Points to the firmware volume header to be checked
Returns:
TRUE - Checksum verification passed
FALSE - Checksum verification failed
--*/
;
/**
Check if it's a valid FFS file header.
@param ErasePolarity Erase polarity attribute of the firmware volume
@param FfsHeader Points to the FFS file header to be checked
@param FileState FFS file state to be returned
@retval TRUE Valid FFS file header
@retval FALSE Invalid FFS file header
**/
BOOLEAN
IsValidFfsHeader (
IN UINT8 ErasePolarity,
IN EFI_FFS_FILE_HEADER *FfsHeader,
OUT EFI_FFS_FILE_STATE *FileState
)
/*++
Routine Description:
Check if it's a valid FFS file header
Arguments:
ErasePolarity - Erase polarity attribute of the firmware volume
FfsHeader - Points to the FFS file header to be checked
FileState - FFS file state to be returned
Returns:
TRUE - Valid FFS file header
FALSE - Invalid FFS file header
--*/
;
/**
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.
@param ErasePolarity Erase polarity attribute of the firmware volume
@param FfsHeader Points to the FFS file to be checked
@retval TRUE Valid FFS file
@retval FALSE Invalid FFS file
**/
BOOLEAN
IsValidFfsFile (
IN UINT8 ErasePolarity,
IN EFI_FFS_FILE_HEADER *FfsHeader
)
/*++
Routine Description:
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.
Arguments:
ErasePolarity - Erase polarity attribute of the firmware volume
FfsHeader - Points to the FFS file to be checked
Returns:
TRUE - Valid FFS file
FALSE - Invalid FFS file
--*/
;
/**
given the supplied FW_VOL_BLOCK_PROTOCOL, allocate a buffer for output and
copy the volume header into it.
@param Fvb The FW_VOL_BLOCK_PROTOCOL instance from which to
read the volume header
@param FwVolHeader Pointer to pointer to allocated buffer in which
the volume header is returned.
@retval EFI_OUT_OF_RESOURCES No enough buffer could be allocated.
@retval EFI_SUCCESS Successfully read volume header to the allocated
buffer.
**/
EFI_STATUS
GetFwVolHeader (
IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *Fvb,
OUT EFI_FIRMWARE_VOLUME_HEADER **FwVolHeader
)
/*++
Routine Description:
given the supplied FW_VOL_BLOCK_PROTOCOL, allocate a buffer for output and
copy the volume header into it.
Arguments:
Fvb - The FW_VOL_BLOCK_PROTOCOL instance from which to read the volume
header
FwVolHeader - Pointer to pointer to allocated buffer in which the volume
header is returned.
Returns:
Status code.
--*/
;
/**
Check if a FV is consistent and allocate cache
@param FvDevice pointer to the FvDevice to be checked.
@retval EFI_OUT_OF_RESOURCES No enough buffer could be allocated.
@retval EFI_SUCCESS FV is consistent and cache is allocated.
@retval EFI_VOLUME_CORRUPTED File system is corrupted.
**/
EFI_STATUS
FvCheck (
IN OUT FV_DEVICE *FvDevice
)
/*++
Routine Description:
Check if a FV is consistent and allocate cache
Arguments:
FvDevice - pointer to the FvDevice to be checked.
Returns:
EFI_OUT_OF_RESOURCES - Not enough buffer to be allocated.
EFI_SUCCESS - FV is consistent and cache is allocated.
EFI_VOLUME_CORRUPTED - File system is corrupted.
--*/
;
#endif

File diff suppressed because it is too large Load Diff

View File

@ -17,7 +17,28 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
//
// 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,
@ -28,6 +49,25 @@ CoreConnectSingleController (
//
// Driver Support Functions
//
/**
Connects one or more drivers to a controller.
@param ControllerHandle Handle of the controller to be
connected.
@param DriverImageHandle 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.
@param Recursive Whether the function would be
called recursively or not.
@return Status code.
**/
EFI_STATUS
EFIAPI
CoreConnectController (
@ -36,28 +76,6 @@ CoreConnectController (
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL,
IN BOOLEAN Recursive
)
/*++
Routine Description:
Connects one or more drivers to a controller.
Arguments:
ControllerHandle - Handle of the controller to be connected.
DriverImageHandle - DriverImageHandle A pointer to an ordered list of driver image handles.
RemainingDevicePath - RemainingDevicePath A pointer to the device path that specifies a child of the
controller specified by ControllerHandle.
Recursive - Whether the function would be called recursively or not.
Returns:
Status code.
--*/
{
EFI_STATUS Status;
EFI_STATUS ReturnStatus;
@ -195,6 +213,26 @@ Returns:
return ReturnStatus;
}
/**
Add Driver Binding Protocols from Context Driver Image Handles to sorted
Driver Binding Protocol list.
@param DriverBindingHandle Handle of the driver binding
protocol.
@param NumberOfSortedDriverBindingProtocols Number Of sorted driver binding
protocols
@param SortedDriverBindingProtocols The sorted protocol list.
@param DriverBindingHandleCount Driver Binding Handle Count.
@param DriverBindingHandleBuffer The buffer of driver binding
protocol to be modified.
@param IsImageHandle Indicate whether
DriverBindingHandle is an image
handle
@return None.
**/
VOID
AddSortedDriverBindingProtocol (
IN EFI_HANDLE DriverBindingHandle,
@ -204,32 +242,6 @@ AddSortedDriverBindingProtocol (
IN OUT EFI_HANDLE *DriverBindingHandleBuffer,
IN BOOLEAN IsImageHandle
)
/*++
Routine Description:
Add Driver Binding Protocols from Context Driver Image Handles to sorted
Driver Binding Protocol list.
Arguments:
DriverBindingHandle - Handle of the driver binding protocol.
NumberOfSortedDriverBindingProtocols - Number Of sorted driver binding protocols
SortedDriverBindingProtocols - The sorted protocol list.
DriverBindingHandleCount - Driver Binding Handle Count.
DriverBindingHandleBuffer - The buffer of driver binding protocol to be modified.
IsImageHandle - Indicate whether DriverBindingHandle is an image handle
Returns:
None.
--*/
{
EFI_STATUS Status;
EFI_DRIVER_BINDING_PROTOCOL *DriverBinding;
@ -324,32 +336,34 @@ Returns:
}
}
/**
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
)
/*++
Routine Description:
Connects a controller to a driver.
Arguments:
ControllerHandle - Handle of the controller to be connected.
ContextDriverImageHandles - DriverImageHandle A pointer to an ordered list of driver image handles.
RemainingDevicePath - RemainingDevicePath A pointer to the device path that specifies a child
of the controller specified by ControllerHandle.
Returns:
EFI_SUCCESS - One or more drivers were connected to ControllerHandle.
EFI_OUT_OF_RESOURCES - No enough system resources to complete the request.
EFI_NOT_FOUND - No drivers were connected to ControllerHandle.
--*/
{
EFI_STATUS Status;
UINTN Index;
@ -610,6 +624,40 @@ Returns:
}
/**
Disonnects a controller from a driver
@param ControllerHandle ControllerHandle The handle of
the controller from which
driver(s) are to be
disconnected.
@param DriverImageHandle DriverImageHandle The driver to
disconnect from ControllerHandle.
@param ChildHandle ChildHandle The handle of the
child to destroy.
@retval EFI_SUCCESS One or more drivers were
disconnected from the controller.
@retval EFI_SUCCESS On entry, no drivers are managing
ControllerHandle.
@retval EFI_SUCCESS DriverImageHandle is not NULL,
and on entry DriverImageHandle is
not managing ControllerHandle.
@retval EFI_INVALID_PARAMETER ControllerHandle is not a valid
EFI_HANDLE.
@retval EFI_INVALID_PARAMETER DriverImageHandle is not NULL,
and it is not a valid EFI_HANDLE.
@retval EFI_INVALID_PARAMETER ChildHandle is not NULL, and it
is not a valid EFI_HANDLE.
@retval EFI_OUT_OF_RESOURCES There are not enough resources
available to disconnect any
drivers from ControllerHandle.
@retval EFI_DEVICE_ERROR The controller could not be
disconnected because of a device
error.
**/
EFI_STATUS
EFIAPI
CoreDisconnectController (
@ -617,31 +665,6 @@ CoreDisconnectController (
IN EFI_HANDLE DriverImageHandle OPTIONAL,
IN EFI_HANDLE ChildHandle OPTIONAL
)
/*++
Routine Description:
Disonnects a controller from a driver
Arguments:
ControllerHandle - ControllerHandle The handle of the controller from which driver(s)
are to be disconnected.
DriverImageHandle - DriverImageHandle The driver to disconnect from ControllerHandle.
ChildHandle - ChildHandle The handle of the child to destroy.
Returns:
EFI_SUCCESS - One or more drivers were disconnected from the controller.
EFI_SUCCESS - On entry, no drivers are managing ControllerHandle.
EFI_SUCCESS - DriverImageHandle is not NULL, and on entry DriverImageHandle is not managing ControllerHandle.
EFI_INVALID_PARAMETER - ControllerHandle is not a valid EFI_HANDLE.
EFI_INVALID_PARAMETER - DriverImageHandle is not NULL, and it is not a valid EFI_HANDLE.
EFI_INVALID_PARAMETER - ChildHandle is not NULL, and it is not a valid EFI_HANDLE.
EFI_OUT_OF_RESOURCES - There are not enough resources available to disconnect any drivers from ControllerHandle.
EFI_DEVICE_ERROR - The controller could not be disconnected because of a device error.
--*/
{
EFI_STATUS Status;
IHANDLE *Handle;

View File

@ -15,23 +15,17 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include <DxeMain.h>
/**
Signal event for every protocol in protocol entry.
@param ProtEntry Protocol entry
**/
VOID
CoreNotifyProtocolEntry (
IN PROTOCOL_ENTRY *ProtEntry
)
/*++
Routine Description:
Signal event for every protocol in protocol entry.
Arguments:
ProtEntry - Protocol entry
Returns:
--*/
{
PROTOCOL_NOTIFY *ProtNotify;
LIST_ENTRY *Link;
@ -45,31 +39,23 @@ Returns:
}
/**
Removes Protocol from the protocol list (but not the handle list).
@param Handle The handle to remove protocol on.
@param Protocol GUID of the protocol to be moved
@param Interface The interface of the protocol
@return Protocol Entry
**/
PROTOCOL_INTERFACE *
CoreRemoveInterfaceFromProtocol (
IN IHANDLE *Handle,
IN EFI_GUID *Protocol,
IN VOID *Interface
)
/*++
Routine Description:
Removes Protocol from the protocol list (but not the handle list).
Arguments:
Handle - The handle to remove protocol on.
Protocol - GUID of the protocol to be moved
Interface - The interface of the protocol
Returns:
Protocol Entry
--*/
{
PROTOCOL_INTERFACE *Prot;
PROTOCOL_NOTIFY *ProtNotify;
@ -107,6 +93,20 @@ Returns:
/**
Add a new protocol notification record for the request protocol.
@param Protocol The requested protocol to add the notify
registration
@param Event The event to signal
@param Registration Returns the registration record
@retval EFI_INVALID_PARAMETER Invalid parameter
@retval EFI_SUCCESS Successfully returned the registration record
that has been added
**/
EFI_STATUS
EFIAPI
CoreRegisterProtocolNotify (
@ -114,28 +114,6 @@ CoreRegisterProtocolNotify (
IN EFI_EVENT Event,
OUT VOID **Registration
)
/*++
Routine Description:
Add a new protocol notification record for the request protocol.
Arguments:
Protocol - The requested protocol to add the notify registration
Event - The event to signal
Registration - Returns the registration record
Returns:
EFI_INVALID_PARAMETER - Invalid parameter
EFI_SUCCESS - Successfully returned the registration record that has been added
--*/
{
PROTOCOL_ENTRY *ProtEntry;
PROTOCOL_NOTIFY *ProtNotify;
@ -194,6 +172,21 @@ Returns:
/**
Reinstall a protocol interface on a device handle. The OldInterface for Protocol is replaced by the NewInterface.
@param UserHandle Handle on which the interface is to be
reinstalled
@param Protocol The numeric ID of the interface
@param OldInterface A pointer to the old interface
@param NewInterface A pointer to the new interface
@retval EFI_SUCCESS The protocol interface was installed
@retval EFI_NOT_FOUND The OldInterface on the handle was not found
@retval EFI_INVALID_PARAMETER One of the parameters has an invalid value
**/
EFI_STATUS
EFIAPI
CoreReinstallProtocolInterface (
@ -202,29 +195,6 @@ CoreReinstallProtocolInterface (
IN VOID *OldInterface,
IN VOID *NewInterface
)
/*++
Routine Description:
Reinstall a protocol interface on a device handle. The OldInterface for Protocol is replaced by the NewInterface.
Arguments:
UserHandle - Handle on which the interface is to be reinstalled
Protocol - The numeric ID of the interface
OldInterface - A pointer to the old interface
NewInterface - A pointer to the new interface
Returns:
Status code.
On EFI_SUCCESS The protocol interface was installed
On EFI_NOT_FOUND The OldInterface on the handle was not found
On EFI_INVALID_PARAMETER One of the parameters has an invalid value
--*/
{
EFI_STATUS Status;
IHANDLE *Handle;

File diff suppressed because it is too large Load Diff

View File

@ -38,6 +38,18 @@ IHANDLE *
OUT VOID **Interface
);
/**
Routine to get the next Handle, when you are searching for all handles.
@param Position Information about which Handle to seach for.
@param Interface Return the interface structure for the matching
protocol.
@retval IHANDLE An IHANDLE is returned if the next Position is
not the end of the list. A NULL_HANDLE is
returned if it's the end of the list.
**/
STATIC
IHANDLE *
CoreGetNextLocateAllHandles (
@ -45,6 +57,19 @@ CoreGetNextLocateAllHandles (
OUT VOID **Interface
);
/**
Routine to get the next Handle, when you are searching for register protocol
notifies.
@param Position Information about which Handle to seach for.
@param Interface Return the interface structure for the matching
protocol.
@retval IHANDLE An IHANDLE is returned if the next Position is
not the end of the list. A NULL_HANDLE is
returned if it's the end of the list.
**/
STATIC
IHANDLE *
CoreGetNextLocateByRegisterNotify (
@ -52,6 +77,18 @@ CoreGetNextLocateByRegisterNotify (
OUT VOID **Interface
);
/**
Routine to get the next Handle, when you are searching for a given protocol.
@param Position Information about which Handle to seach for.
@param Interface Return the interface structure for the matching
protocol.
@retval IHANDLE An IHANDLE is returned if the next Position is
not the end of the list. A NULL_HANDLE is
returned if it's the end of the list.
**/
STATIC
IHANDLE *
CoreGetNextLocateByProtocol (
@ -59,13 +96,25 @@ CoreGetNextLocateByProtocol (
OUT VOID **Interface
);
//
//
//
/**
Locates the requested handle(s) and returns them in Buffer.
@param SearchType The type of search to perform to locate the
handles
@param Protocol The protocol to search for
@param SearchKey Dependant on SearchType
@param BufferSize On input the size of Buffer. On output the
size of data returned.
@param Buffer The buffer to return the results in
@retval EFI_BUFFER_TOO_SMALL Buffer too small, required buffer size is
returned in BufferSize.
@retval EFI_INVALID_PARAMETER Invalid parameter
@retval EFI_SUCCESS Successfully found the requested handle(s) and
returns them in Buffer.
**/
EFI_STATUS
EFIAPI
CoreLocateHandle (
@ -75,35 +124,6 @@ CoreLocateHandle (
IN OUT UINTN *BufferSize,
OUT EFI_HANDLE *Buffer
)
/*++
Routine Description:
Locates the requested handle(s) and returns them in Buffer.
Arguments:
SearchType - The type of search to perform to locate the handles
Protocol - The protocol to search for
SearchKey - Dependant on SearchType
BufferSize - On input the size of Buffer. On output the
size of data returned.
Buffer - The buffer to return the results in
Returns:
EFI_BUFFER_TOO_SMALL - Buffer too small, required buffer size is returned in BufferSize.
EFI_INVALID_PARAMETER - Invalid parameter
EFI_SUCCESS - Successfully found the requested handle(s) and returns them in Buffer.
--*/
{
EFI_STATUS Status;
LOCATE_POSITION Position;
@ -243,29 +263,25 @@ Returns:
}
/**
Routine to get the next Handle, when you are searching for all handles.
@param Position Information about which Handle to seach for.
@param Interface Return the interface structure for the matching
protocol.
@retval IHANDLE An IHANDLE is returned if the next Position is
not the end of the list. A NULL_HANDLE is
returned if it's the end of the list.
**/
STATIC
IHANDLE *
CoreGetNextLocateAllHandles (
IN OUT LOCATE_POSITION *Position,
OUT VOID **Interface
)
/*++
Routine Description:
Routine to get the next Handle, when you are searching for all handles.
Arguments:
Position - Information about which Handle to seach for.
Interface - Return the interface structure for the matching protocol.
Returns:
IHANDLE - An IHANDLE is returned if the next Position is not the end of the
list. A NULL_HANDLE is returned if it's the end of the list.
--*/
{
IHANDLE *Handle;
@ -287,30 +303,26 @@ Returns:
}
/**
Routine to get the next Handle, when you are searching for register protocol
notifies.
@param Position Information about which Handle to seach for.
@param Interface Return the interface structure for the matching
protocol.
@retval IHANDLE An IHANDLE is returned if the next Position is
not the end of the list. A NULL_HANDLE is
returned if it's the end of the list.
**/
STATIC
IHANDLE *
CoreGetNextLocateByRegisterNotify (
IN OUT LOCATE_POSITION *Position,
OUT VOID **Interface
)
/*++
Routine Description:
Routine to get the next Handle, when you are searching for register protocol
notifies.
Arguments:
Position - Information about which Handle to seach for.
Interface - Return the interface structure for the matching protocol.
Returns:
IHANDLE - An IHANDLE is returned if the next Position is not the end of the
list. A NULL_HANDLE is returned if it's the end of the list.
--*/
{
IHANDLE *Handle;
PROTOCOL_NOTIFY *ProtNotify;
@ -343,29 +355,25 @@ Returns:
}
/**
Routine to get the next Handle, when you are searching for a given protocol.
@param Position Information about which Handle to seach for.
@param Interface Return the interface structure for the matching
protocol.
@retval IHANDLE An IHANDLE is returned if the next Position is
not the end of the list. A NULL_HANDLE is
returned if it's the end of the list.
**/
STATIC
IHANDLE *
CoreGetNextLocateByProtocol (
IN OUT LOCATE_POSITION *Position,
OUT VOID **Interface
)
/*++
Routine Description:
Routine to get the next Handle, when you are searching for a given protocol.
Arguments:
Position - Information about which Handle to seach for.
Interface - Return the interface structure for the matching protocol.
Returns:
IHANDLE - An IHANDLE is returned if the next Position is not the end of the
list. A NULL_HANDLE is returned if it's the end of the list.
--*/
{
IHANDLE *Handle;
LIST_ENTRY *Link;
@ -410,6 +418,22 @@ Returns:
/**
Locates the handle to a device on the device path that best matches the specified protocol.
@param Protocol The protocol to search for.
@param DevicePath On input, a pointer to a pointer to the device
path. On output, the device path pointer is
modified to point to the remaining part of the
devicepath.
@param Device A pointer to the returned device handle.
@retval EFI_SUCCESS The resulting handle was returned.
@retval EFI_NOT_FOUND No handles matched the search.
@retval EFI_INVALID_PARAMETER One of the parameters has an invalid value.
**/
EFI_STATUS
EFIAPI
CoreLocateDevicePath (
@ -417,26 +441,6 @@ CoreLocateDevicePath (
IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath,
OUT EFI_HANDLE *Device
)
/*++
Routine Description:
Locates the handle to a device on the device path that best matches the specified protocol.
Arguments:
Protocol - The protocol to search for.
DevicePath - On input, a pointer to a pointer to the device path. On output, the device
path pointer is modified to point to the remaining part of the devicepath.
Device - A pointer to the returned device handle.
Returns:
EFI_SUCCESS - The resulting handle was returned.
EFI_NOT_FOUND - No handles matched the search.
EFI_INVALID_PARAMETER - One of the parameters has an invalid value.
--*/
{
INTN SourceSize;
INTN Size;
@ -469,7 +473,7 @@ Returns:
// The source path can only have 1 instance
//
if (CoreIsDevicePathMultiInstance (SourcePath)) {
DEBUG((EFI_D_ERROR, "LocateDevicePath: Device path has too many instances\n"));
DEBUG((DEBUG_ERROR, "LocateDevicePath: Device path has too many instances\n"));
return EFI_INVALID_PARAMETER;
}
@ -533,6 +537,23 @@ Returns:
/**
Return the first Protocol Interface that matches the Protocol GUID. If
Registration is pasased in return a Protocol Instance that was just add
to the system. If Retistration is NULL return the first Protocol Interface
you find.
@param Protocol The protocol to search for
@param Registration Optional Registration Key returned from
RegisterProtocolNotify()
@param Interface Return the Protocol interface (instance).
@retval EFI_SUCCESS If a valid Interface is returned
@retval EFI_INVALID_PARAMETER Invalid parameter
@retval EFI_NOT_FOUND Protocol interface not found
**/
EFI_STATUS
EFIAPI
CoreLocateProtocol (
@ -540,32 +561,6 @@ CoreLocateProtocol (
IN VOID *Registration OPTIONAL,
OUT VOID **Interface
)
/*++
Routine Description:
Return the first Protocol Interface that matches the Protocol GUID. If
Registration is pasased in return a Protocol Instance that was just add
to the system. If Retistration is NULL return the first Protocol Interface
you find.
Arguments:
Protocol - The protocol to search for
Registration - Optional Registration Key returned from RegisterProtocolNotify()
Interface - Return the Protocol interface (instance).
Returns:
EFI_SUCCESS - If a valid Interface is returned
EFI_INVALID_PARAMETER - Invalid parameter
EFI_NOT_FOUND - Protocol interface not found
--*/
{
EFI_STATUS Status;
LOCATE_POSITION Position;
@ -631,6 +626,29 @@ Done:
/**
Function returns an array of handles that support the requested protocol
in a buffer allocated from pool. This is a version of CoreLocateHandle()
that allocates a buffer for the caller.
@param SearchType Specifies which handle(s) are to be returned.
@param Protocol Provides the protocol to search by. This
parameter is only valid for SearchType
ByProtocol.
@param SearchKey Supplies the search key depending on the
SearchType.
@param NumberHandles The number of handles returned in Buffer.
@param Buffer A pointer to the buffer to return the requested
array of handles that support Protocol.
@retval EFI_SUCCESS The result array of handles was returned.
@retval EFI_NOT_FOUND No handles match the search.
@retval EFI_OUT_OF_RESOURCES There is not enough pool memory to store the
matching results.
@retval EFI_INVALID_PARAMETER Invalid parameter
**/
EFI_STATUS
EFIAPI
CoreLocateHandleBuffer (
@ -640,32 +658,6 @@ CoreLocateHandleBuffer (
IN OUT UINTN *NumberHandles,
OUT EFI_HANDLE **Buffer
)
/*++
Routine Description:
Function returns an array of handles that support the requested protocol
in a buffer allocated from pool. This is a version of CoreLocateHandle()
that allocates a buffer for the caller.
Arguments:
SearchType - Specifies which handle(s) are to be returned.
Protocol - Provides the protocol to search by.
This parameter is only valid for SearchType ByProtocol.
SearchKey - Supplies the search key depending on the SearchType.
NumberHandles - The number of handles returned in Buffer.
Buffer - A pointer to the buffer to return the requested array of
handles that support Protocol.
Returns:
EFI_SUCCESS - The result array of handles was returned.
EFI_NOT_FOUND - No handles match the search.
EFI_OUT_OF_RESOURCES - There is not enough pool memory to store the matching results.
EFI_INVALID_PARAMETER - Invalid parameter
--*/
{
EFI_STATUS Status;
UINTN BufferSize;
@ -723,3 +715,4 @@ Returns:
}

View File

@ -89,6 +89,30 @@ typedef struct {
// Abstractions for reading image contents
//
/**
Opens a file for (simple) reading. The simple read abstraction
will access the file either from a memory copy, from a file
system interface, or from the load file interface.
@param BootPolicy Policy for Open Image File.
@param SourceBuffer Pointer to the memory location containing copy
of the image to be loaded.
@param SourceSize The size in bytes of SourceBuffer.
@param FilePath The specific file path from which the image is
loaded
@param DeviceHandle Pointer to the return device handle.
@param ImageFileHandle Pointer to the image file handle.
@param AuthenticationStatus Pointer to a caller-allocated UINT32 in which
the authentication status is returned.
@retval EFI_SUCCESS Image file successfully opened.
@retval EFI_LOAD_ERROR If the caller passed a copy of the file, and
SourceSize is 0.
@retval EFI_INVALID_PARAMETER File path is not valid.
@retval EFI_NOT_FOUND File not found.
**/
EFI_STATUS
CoreOpenImageFile (
IN BOOLEAN BootPolicy,
@ -99,33 +123,24 @@ CoreOpenImageFile (
IN IMAGE_FILE_HANDLE *ImageFileHandle,
OUT UINT32 *AuthenticationStatus
)
/*++
Routine Description:
Opens a file for (simple) reading. The simple read abstraction
will access the file either from a memory copy, from a file
system interface, or from the load file interface.
Arguments:
BootPolicy - Policy for Open Image File.
SourceBuffer - Pointer to the memory location containing copy
of the image to be loaded.
SourceSize - The size in bytes of SourceBuffer.
FilePath - The specific file path from which the image is loaded
DeviceHandle - Pointer to the return device handle.
ImageFileHandle - Pointer to the image file handle.
AuthenticationStatus - Pointer to a caller-allocated UINT32 in which the authentication status is returned.
Returns:
A handle to access the file
--*/
;
/**
Read image file (specified by UserHandle) into user specified buffer with specified offset
and length.
@param UserHandle Image file handle
@param Offset Offset to the source file
@param ReadSize For input, pointer of size to read; For output,
pointer of size actually read.
@param Buffer Buffer to write into
@retval EFI_SUCCESS Successfully read the specified part of file
into buffer.
**/
EFI_STATUS
EFIAPI
CoreReadImageFile (
@ -134,56 +149,39 @@ CoreReadImageFile (
IN OUT UINTN *ReadSize,
OUT VOID *Buffer
)
/*++
Routine Description:
Read image file (specified by UserHandle) into user specified buffer with specified offset
and length.
Arguments:
UserHandle - Image file handle
Offset - Offset to the source file
ReadSize - For input, pointer of size to read;
For output, pointer of size actually read.
Buffer - Buffer to write into
Returns:
EFI_SUCCESS - Successfully read the specified part of file into buffer.
--*/
;
/**
A function out of date, should be removed.
@param ImageFileHandle Handle of the file to close
**/
VOID
EFIAPI
CoreCloseImageFile (
IN IMAGE_FILE_HANDLE *ImageFileHandle
)
/*++
Routine Description:
A function out of date, should be removed.
Arguments:
ImageFileHandle - Handle of the file to close
Returns:
None
--*/
;
//
// Image processing worker functions
//
/**
Search a handle to a device on a specified device path that supports a specified protocol,
interface of that protocol on that handle is another output.
@param Protocol The protocol to search for
@param FilePath The specified device path
@param Interface Interface of the protocol on the handle
@param Handle The handle to the device on the specified device
path that supports the protocol.
@return Status code.
**/
EFI_STATUS
CoreDevicePathToInterface (
IN EFI_GUID *Protocol,
@ -191,30 +189,30 @@ CoreDevicePathToInterface (
OUT VOID **Interface,
OUT EFI_HANDLE *Handle
)
/*++
Routine Description:
Search a handle to a device on a specified device path that supports a specified protocol,
interface of that protocol on that handle is another output.
Arguments:
Protocol - The protocol to search for
FilePath - The specified device path
Interface - Interface of the protocol on the handle
Handle - The handle to the device on the specified device path that supports the protocol.
Returns:
Status code.
--*/
;
/**
Loads, relocates, and invokes a PE/COFF image
@param BootPolicy If TRUE, indicates that the request originates
from the boot manager, and that the boot
manager is attempting to load FilePath as a
boot selection.
@param Pe32Handle The handle of PE32 image
@param Image PE image to be loaded
@param DstBuffer The buffer to store the image
@param EntryPoint A pointer to the entry point
@param Attribute The bit mask of attributes to set for the load
PE image
@retval EFI_SUCCESS The file was loaded, relocated, and invoked
@retval EFI_OUT_OF_RESOURCES There was not enough memory to load and
relocate the PE/COFF file
@retval EFI_INVALID_PARAMETER Invalid parameter
@retval EFI_BUFFER_TOO_SMALL Buffer for image is too small
**/
EFI_STATUS
CoreLoadPeImage (
IN BOOLEAN BootPolicy,
@ -224,76 +222,36 @@ CoreLoadPeImage (
OUT EFI_PHYSICAL_ADDRESS *EntryPoint OPTIONAL,
IN UINT32 Attribute
)
/*++
Routine Description:
Loads, relocates, and invokes a PE/COFF image
Arguments:
BootPolicy - Policy for Open Image File.
Pe32Handle - The handle of PE32 image
Image - PE image to be loaded
DstBuffer - The buffer to store the image
EntryPoint - A pointer to the entry point
Attribute - The bit mask of attributes to set for the load PE image
Returns:
EFI_SUCCESS - The file was loaded, relocated, and invoked
EFI_OUT_OF_RESOURCES - There was not enough memory to load and relocate the PE/COFF file
EFI_INVALID_PARAMETER - Invalid parameter
EFI_BUFFER_TOO_SMALL - Buffer for image is too small
--*/
;
/**
Get the image's private data from its handle.
@param ImageHandle The image handle
@return Return the image private data associated with ImageHandle.
**/
LOADED_IMAGE_PRIVATE_DATA *
CoreLoadedImageInfo (
IN EFI_HANDLE ImageHandle
)
/*++
Routine Description:
TODO: Add function description
Arguments:
ImageHandle - TODO: add argument description
Returns:
TODO: add return values
--*/
;
/**
Unloads EFI image from memory.
@param Image EFI image
@param FreePage Free allocated pages
**/
VOID
CoreUnloadAndCloseImage (
IN LOADED_IMAGE_PRIVATE_DATA *Image,
IN BOOLEAN FreePage
)
/*++
Routine Description:
Unloads EFI image from memory.
Arguments:
Image - EFI image
FreePage - Free allocated pages
Returns:
None
--*/
;
@ -301,6 +259,36 @@ Returns:
// Exported Image functions
//
/**
Loads an EFI image into memory and returns a handle to the image with extended parameters.
@param This Calling context
@param ParentImageHandle The caller's image handle.
@param FilePath The specific file path from which the image is
loaded.
@param SourceBuffer If not NULL, a pointer to the memory location
containing a copy of the image to be loaded.
@param SourceSize The size in bytes of SourceBuffer.
@param DstBuffer The buffer to store the image.
@param NumberOfPages For input, specifies the space size of the
image by caller if not NULL. For output,
specifies the actual space size needed.
@param ImageHandle Image handle for output.
@param EntryPoint Image entry point for output.
@param Attribute The bit mask of attributes to set for the load
PE image.
@retval EFI_SUCCESS The image was loaded into memory.
@retval EFI_NOT_FOUND The FilePath was not found.
@retval EFI_INVALID_PARAMETER One of the parameters has an invalid value.
@retval EFI_UNSUPPORTED The image type is not supported, or the device
path cannot be parsed to locate the proper
protocol for loading the file.
@retval EFI_OUT_OF_RESOURCES Image was not loaded due to insufficient
resources.
**/
EFI_STATUS
EFIAPI
CoreLoadImageEx (
@ -315,63 +303,25 @@ CoreLoadImageEx (
OUT EFI_PHYSICAL_ADDRESS *EntryPoint OPTIONAL,
IN UINT32 Attribute
)
/*++
Routine Description:
Loads an EFI image into memory and returns a handle to the image with extended parameters.
Arguments:
ParentImageHandle - The caller's image handle.
FilePath - The specific file path from which the image is loaded.
SourceBuffer - If not NULL, a pointer to the memory location containing a copy of
the image to be loaded.
SourceSize - The size in bytes of SourceBuffer.
DstBuffer - The buffer to store the image.
NumberOfPages - For input, specifies the space size of the image by caller if not NULL.
For output, specifies the actual space size needed.
ImageHandle - Image handle for output.
EntryPoint - Image entry point for output.
Attribute - The bit mask of attributes to set for the load PE image.
Returns:
EFI_SUCCESS - The image was loaded into memory.
EFI_NOT_FOUND - The FilePath was not found.
EFI_INVALID_PARAMETER - One of the parameters has an invalid value.
EFI_UNSUPPORTED - The image type is not supported, or the device path cannot be
parsed to locate the proper protocol for loading the file.
EFI_OUT_OF_RESOURCES - Image was not loaded due to insufficient resources.
--*/
;
/**
Unload the specified image.
@param This Indicates the calling context.
@param ImageHandle The specified image handle.
@retval EFI_INVALID_PARAMETER Image handle is NULL.
@retval EFI_UNSUPPORTED Attempt to unload an unsupported image.
@retval EFI_SUCCESS Image successfully unloaded.
**/
EFI_STATUS
EFIAPI
CoreUnloadImageEx (
IN EFI_PE32_IMAGE_PROTOCOL *This,
IN EFI_HANDLE ImageHandle
)
/*++
Routine Description:
Unload the specified image.
Arguments:
This - Indicates the calling context.
ImageHandle - The specified image handle.
Returns:
EFI_INVALID_PARAMETER - Image handle is NULL.
EFI_UNSUPPORTED - Attempt to unload an unsupported image.
EFI_SUCCESS - Image successfully unloaded.
--*/
;
#endif

View File

@ -72,26 +72,20 @@ LOADED_IMAGE_PRIVATE_DATA mCorePrivateImage = {
};
/**
Add the Image Services to EFI Boot Services Table and install the protocol
interfaces for this image.
@param HobStart The HOB to initialize
@return Status code.
**/
EFI_STATUS
CoreInitializeImageServices (
IN VOID *HobStart
)
/*++
Routine Description:
Add the Image Services to EFI Boot Services Table and install the protocol
interfaces for this image.
Arguments:
HobStart - The HOB to initialize
Returns:
Status code.
--*/
{
EFI_STATUS Status;
LOADED_IMAGE_PRIVATE_DATA *Image;
@ -161,6 +155,28 @@ Returns:
);
}
/**
Loads, relocates, and invokes a PE/COFF image
@param BootPolicy If TRUE, indicates that the request originates
from the boot manager, and that the boot
manager is attempting to load FilePath as a
boot selection.
@param Pe32Handle The handle of PE32 image
@param Image PE image to be loaded
@param DstBuffer The buffer to store the image
@param EntryPoint A pointer to the entry point
@param Attribute The bit mask of attributes to set for the load
PE image
@retval EFI_SUCCESS The file was loaded, relocated, and invoked
@retval EFI_OUT_OF_RESOURCES There was not enough memory to load and
relocate the PE/COFF file
@retval EFI_INVALID_PARAMETER Invalid parameter
@retval EFI_BUFFER_TOO_SMALL Buffer for image is too small
**/
EFI_STATUS
CoreLoadPeImage (
IN BOOLEAN BootPolicy,
@ -170,32 +186,6 @@ CoreLoadPeImage (
OUT EFI_PHYSICAL_ADDRESS *EntryPoint OPTIONAL,
IN UINT32 Attribute
)
/*++
Routine Description:
Loads, relocates, and invokes a PE/COFF image
Arguments:
BootPolicy - If TRUE, indicates that the request originates from the boot manager,
and that the boot manager is attempting to load FilePath as a boot selection.
Pe32Handle - The handle of PE32 image
Image - PE image to be loaded
DstBuffer - The buffer to store the image
EntryPoint - A pointer to the entry point
Attribute - The bit mask of attributes to set for the load PE image
Returns:
EFI_SUCCESS - The file was loaded, relocated, and invoked
EFI_OUT_OF_RESOURCES - There was not enough memory to load and relocate the PE/COFF file
EFI_INVALID_PARAMETER - Invalid parameter
EFI_BUFFER_TOO_SMALL - Buffer for image is too small
--*/
{
EFI_STATUS Status;
BOOLEAN DstBufAlocated;
@ -477,7 +467,7 @@ Returns:
CHAR8 EfiFileName[256];
if (Image->ImageContext.Machine != IMAGE_FILE_MACHINE_IA64) {
DEBUG ((EFI_D_INFO | EFI_D_LOAD,
DEBUG ((DEBUG_INFO | DEBUG_LOAD,
"Loading driver at 0x%10p EntryPoint=0x%10p ",
(VOID *)(UINTN)Image->ImageContext.ImageAddress,
(VOID *)(UINTN)Image->ImageContext.EntryPoint));
@ -485,7 +475,7 @@ Returns:
//
// For IPF Image, the real entry point should be print.
//
DEBUG ((EFI_D_INFO | EFI_D_LOAD,
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)));
@ -517,9 +507,9 @@ Returns:
break;
}
}
DEBUG ((EFI_D_INFO | EFI_D_LOAD, "%a", EfiFileName)); // &Image->ImageContext.PdbPointer[StartIndex]));
DEBUG ((DEBUG_INFO | DEBUG_LOAD, "%a", EfiFileName)); // &Image->ImageContext.PdbPointer[StartIndex]));
}
DEBUG ((EFI_D_INFO | EFI_D_LOAD, "\n"));
DEBUG ((DEBUG_INFO | DEBUG_LOAD, "\n"));
DEBUG_CODE_END ();
@ -543,25 +533,19 @@ Done:
}
/**
Get the image's private data from its handle.
@param ImageHandle The image handle
@return Return the image private data associated with ImageHandle.
**/
LOADED_IMAGE_PRIVATE_DATA *
CoreLoadedImageInfo (
IN EFI_HANDLE ImageHandle
)
/*++
Routine Description:
Get the image's private data from its handle.
Arguments:
ImageHandle - The image handle
Returns:
Return the image private data associated with ImageHandle.
--*/
{
EFI_STATUS Status;
EFI_LOADED_IMAGE_PROTOCOL *LoadedImage;
@ -575,13 +559,50 @@ Returns:
if (!EFI_ERROR (Status)) {
Image = LOADED_IMAGE_PRIVATE_DATA_FROM_THIS (LoadedImage);
} else {
DEBUG ((EFI_D_LOAD, "CoreLoadedImageInfo: Not an ImageHandle %x\n", ImageHandle));
DEBUG ((DEBUG_LOAD, "CoreLoadedImageInfo: Not an ImageHandle %x\n", ImageHandle));
Image = NULL;
}
return Image;
}
/**
Loads an EFI image into memory and returns a handle to the image.
@param BootPolicy If TRUE, indicates that the request originates
from the boot manager, and that the boot
manager is attempting to load FilePath as a
boot selection.
@param ParentImageHandle The caller's image handle.
@param FilePath The specific file path from which the image is
loaded.
@param SourceBuffer If not NULL, a pointer to the memory location
containing a copy of the image to be loaded.
@param SourceSize The size in bytes of SourceBuffer.
@param DstBuffer The buffer to store the image
@param NumberOfPages If not NULL, it inputs a pointer to the page
number of DstBuffer and outputs a pointer to
the page number of the image. If this number is
not enough, return EFI_BUFFER_TOO_SMALL and
this parameter contains the required number.
@param ImageHandle Pointer to the returned image handle that is
created when the image is successfully loaded.
@param EntryPoint A pointer to the entry point
@param Attribute The bit mask of attributes to set for the load
PE image
@retval EFI_SUCCESS The image was loaded into memory.
@retval EFI_NOT_FOUND The FilePath was not found.
@retval EFI_INVALID_PARAMETER One of the parameters has an invalid value.
@retval EFI_BUFFER_TOO_SMALL The buffer is too small
@retval EFI_UNSUPPORTED The image type is not supported, or the device
path cannot be parsed to locate the proper
protocol for loading the file.
@retval EFI_OUT_OF_RESOURCES Image was not loaded due to insufficient
resources.
**/
STATIC
EFI_STATUS
CoreLoadImageCommon (
@ -596,40 +617,6 @@ CoreLoadImageCommon (
OUT EFI_PHYSICAL_ADDRESS *EntryPoint OPTIONAL,
IN UINT32 Attribute
)
/*++
Routine Description:
Loads an EFI image into memory and returns a handle to the image.
Arguments:
BootPolicy - If TRUE, indicates that the request originates from the boot manager,
and that the boot manager is attempting to load FilePath as a boot selection.
ParentImageHandle - The caller's image handle.
FilePath - The specific file path from which the image is loaded.
SourceBuffer - If not NULL, a pointer to the memory location containing a copy of
the image to be loaded.
SourceSize - The size in bytes of SourceBuffer.
DstBuffer - The buffer to store the image
NumberOfPages - If not NULL, it inputs a pointer to the page number of DstBuffer and outputs
a pointer to the page number of the image. If this number is not enough,
return EFI_BUFFER_TOO_SMALL and this parameter contains the required number.
ImageHandle - Pointer to the returned image handle that is created when the image
is successfully loaded.
EntryPoint - A pointer to the entry point
Attribute - The bit mask of attributes to set for the load PE image
Returns:
EFI_SUCCESS - The image was loaded into memory.
EFI_NOT_FOUND - The FilePath was not found.
EFI_INVALID_PARAMETER - One of the parameters has an invalid value.
EFI_BUFFER_TOO_SMALL - The buffer is too small
EFI_UNSUPPORTED - The image type is not supported, or the device path cannot be
parsed to locate the proper protocol for loading the file.
EFI_OUT_OF_RESOURCES - Image was not loaded due to insufficient resources.
--*/
{
LOADED_IMAGE_PRIVATE_DATA *Image;
LOADED_IMAGE_PRIVATE_DATA *ParentImage;
@ -656,7 +643,7 @@ Returns:
ParentImage = CoreLoadedImageInfo (ParentImageHandle);
if (ParentImage == NULL) {
DEBUG((EFI_D_LOAD|EFI_D_ERROR, "LoadImageEx: Parent handle not an image handle\n"));
DEBUG((DEBUG_LOAD|DEBUG_ERROR, "LoadImageEx: Parent handle not an image handle\n"));
return EFI_INVALID_PARAMETER;
}
@ -721,7 +708,7 @@ Returns:
Image->Signature = LOADED_IMAGE_PRIVATE_DATA_SIGNATURE;
Image->Info.SystemTable = gDxeCoreST;
Image->Info.DeviceHandle = DeviceHandle;
Image->Info.Revision = EFI_LOADED_IMAGE_INFORMATION_REVISION;
Image->Info.Revision = EFI_LOADED_IMAGE_PROTOCOL_REVISION;
Image->Info.FilePath = CoreDuplicateDevicePath (FilePath);
Image->Info.ParentHandle = ParentImageHandle;
@ -836,6 +823,33 @@ Done:
/**
Loads an EFI image into memory and returns a handle to the image.
@param BootPolicy If TRUE, indicates that the request originates
from the boot manager, and that the boot
manager is attempting to load FilePath as a
boot selection.
@param ParentImageHandle The caller's image handle.
@param FilePath The specific file path from which the image is
loaded.
@param SourceBuffer If not NULL, a pointer to the memory location
containing a copy of the image to be loaded.
@param SourceSize The size in bytes of SourceBuffer.
@param ImageHandle Pointer to the returned image handle that is
created when the image is successfully loaded.
@retval EFI_SUCCESS The image was loaded into memory.
@retval EFI_NOT_FOUND The FilePath was not found.
@retval EFI_INVALID_PARAMETER One of the parameters has an invalid value.
@retval EFI_UNSUPPORTED The image type is not supported, or the device
path cannot be parsed to locate the proper
protocol for loading the file.
@retval EFI_OUT_OF_RESOURCES Image was not loaded due to insufficient
resources.
**/
EFI_STATUS
EFIAPI
CoreLoadImage (
@ -846,33 +860,6 @@ CoreLoadImage (
IN UINTN SourceSize,
OUT EFI_HANDLE *ImageHandle
)
/*++
Routine Description:
Loads an EFI image into memory and returns a handle to the image.
Arguments:
BootPolicy - If TRUE, indicates that the request originates from the boot manager,
and that the boot manager is attempting to load FilePath as a boot selection.
ParentImageHandle - The caller's image handle.
FilePath - The specific file path from which the image is loaded.
SourceBuffer - If not NULL, a pointer to the memory location containing a copy of
the image to be loaded.
SourceSize - The size in bytes of SourceBuffer.
ImageHandle - Pointer to the returned image handle that is created when the image
is successfully loaded.
Returns:
EFI_SUCCESS - The image was loaded into memory.
EFI_NOT_FOUND - The FilePath was not found.
EFI_INVALID_PARAMETER - One of the parameters has an invalid value.
EFI_UNSUPPORTED - The image type is not supported, or the device path cannot be
parsed to locate the proper protocol for loading the file.
EFI_OUT_OF_RESOURCES - Image was not loaded due to insufficient resources.
--*/
{
EFI_STATUS Status;
@ -897,6 +884,36 @@ Returns:
}
/**
Loads an EFI image into memory and returns a handle to the image with extended parameters.
@param This Calling context
@param ParentImageHandle The caller's image handle.
@param FilePath The specific file path from which the image is
loaded.
@param SourceBuffer If not NULL, a pointer to the memory location
containing a copy of the image to be loaded.
@param SourceSize The size in bytes of SourceBuffer.
@param DstBuffer The buffer to store the image.
@param NumberOfPages For input, specifies the space size of the
image by caller if not NULL. For output,
specifies the actual space size needed.
@param ImageHandle Image handle for output.
@param EntryPoint Image entry point for output.
@param Attribute The bit mask of attributes to set for the load
PE image.
@retval EFI_SUCCESS The image was loaded into memory.
@retval EFI_NOT_FOUND The FilePath was not found.
@retval EFI_INVALID_PARAMETER One of the parameters has an invalid value.
@retval EFI_UNSUPPORTED The image type is not supported, or the device
path cannot be parsed to locate the proper
protocol for loading the file.
@retval EFI_OUT_OF_RESOURCES Image was not loaded due to insufficient
resources.
**/
EFI_STATUS
EFIAPI
CoreLoadImageEx (
@ -911,36 +928,6 @@ CoreLoadImageEx (
OUT EFI_PHYSICAL_ADDRESS *EntryPoint OPTIONAL,
IN UINT32 Attribute
)
/*++
Routine Description:
Loads an EFI image into memory and returns a handle to the image with extended parameters.
Arguments:
This - Calling context
ParentImageHandle - The caller's image handle.
FilePath - The specific file path from which the image is loaded.
SourceBuffer - If not NULL, a pointer to the memory location containing a copy of
the image to be loaded.
SourceSize - The size in bytes of SourceBuffer.
DstBuffer - The buffer to store the image.
NumberOfPages - For input, specifies the space size of the image by caller if not NULL.
For output, specifies the actual space size needed.
ImageHandle - Image handle for output.
EntryPoint - Image entry point for output.
Attribute - The bit mask of attributes to set for the load PE image.
Returns:
EFI_SUCCESS - The image was loaded into memory.
EFI_NOT_FOUND - The FilePath was not found.
EFI_INVALID_PARAMETER - One of the parameters has an invalid value.
EFI_UNSUPPORTED - The image type is not supported, or the device path cannot be
parsed to locate the proper protocol for loading the file.
EFI_OUT_OF_RESOURCES - Image was not loaded due to insufficient resources.
--*/
{
return CoreLoadImageCommon (
TRUE,
@ -956,6 +943,25 @@ Returns:
);
}
/**
Transfer control to a loaded image's entry point.
@param ImageHandle Handle of image to be started.
@param ExitDataSize Pointer of the size to ExitData
@param ExitData Pointer to a pointer to a data buffer that
includes a Null-terminated Unicode string,
optionally followed by additional binary data.
The string is a description that the caller may
use to further indicate the reason for the
image's exit.
@retval EFI_INVALID_PARAMETER Invalid parameter
@retval EFI_OUT_OF_RESOURCES No enough buffer to allocate
@retval EFI_SUCCESS Successfully transfer control to the image's
entry point.
**/
EFI_STATUS
EFIAPI
CoreStartImage (
@ -963,32 +969,6 @@ CoreStartImage (
OUT UINTN *ExitDataSize,
OUT CHAR16 **ExitData OPTIONAL
)
/*++
Routine Description:
Transfer control to a loaded image's entry point.
Arguments:
ImageHandle - Handle of image to be started.
ExitDataSize - Pointer of the size to ExitData
ExitData - Pointer to a pointer to a data buffer that includes a Null-terminated
Unicode string, optionally followed by additional binary data. The string
is a description that the caller may use to further indicate the reason for
the image's exit.
Returns:
EFI_INVALID_PARAMETER - Invalid parameter
EFI_OUT_OF_RESOURCES - No enough buffer to allocate
EFI_SUCCESS - Successfully transfer control to the image's entry point.
--*/
{
EFI_STATUS Status;
LOADED_IMAGE_PRIVATE_DATA *Image;
@ -1048,7 +1028,7 @@ Returns:
//
DEBUG_CODE_BEGIN ();
if (EFI_ERROR (Image->Status)) {
DEBUG ((EFI_D_ERROR, "Error: Image at %10p start failed: %r\n", Image->Info.ImageBase, Image->Status));
DEBUG ((DEBUG_ERROR, "Error: Image at %10p start failed: %r\n", Image->Info.ImageBase, Image->Status));
}
DEBUG_CODE_END ();
@ -1083,15 +1063,15 @@ Returns:
if (Image->ExitDataSize != 0 || Image->ExitData != NULL) {
DEBUG (
(EFI_D_LOAD,
(DEBUG_LOAD,
"StartImage: ExitDataSize %d, ExitData %x",
Image->ExitDataSize,
Image->ExitData)
);
if (Image->ExitData != NULL) {
DEBUG ((EFI_D_LOAD, " (%hs)", Image->ExitData));
DEBUG ((DEBUG_LOAD, " (%hs)", Image->ExitData));
}
DEBUG ((EFI_D_LOAD, "\n"));
DEBUG ((DEBUG_LOAD, "\n"));
}
DEBUG_CODE_END ();
@ -1130,27 +1110,19 @@ Returns:
}
/**
Unloads EFI image from memory.
@param Image EFI image
@param FreePage Free allocated pages
**/
VOID
CoreUnloadAndCloseImage (
IN LOADED_IMAGE_PRIVATE_DATA *Image,
IN BOOLEAN FreePage
)
/*++
Routine Description:
Unloads EFI image from memory.
Arguments:
Image - EFI image
FreePage - Free allocated pages
Returns:
None
--*/
{
EFI_STATUS Status;
UINTN HandleCount;
@ -1281,6 +1253,30 @@ Returns:
/**
Terminates the currently loaded EFI image and returns control to boot services.
@param ImageHandle Handle that identifies the image. This
parameter is passed to the image on entry.
@param Status The image's exit code.
@param ExitDataSize The size, in bytes, of ExitData. Ignored if
ExitStatus is EFI_SUCCESS.
@param ExitData Pointer to a data buffer that includes a
Null-terminated Unicode string, optionally
followed by additional binary data. The string
is a description that the caller may use to
further indicate the reason for the image's
exit.
@retval EFI_INVALID_PARAMETER Image handle is NULL or it is not current
image.
@retval EFI_SUCCESS Successfully terminates the currently loaded
EFI image.
@retval EFI_ACCESS_DENIED Should never reach there.
@retval EFI_OUT_OF_RESOURCES Could not allocate pool
**/
EFI_STATUS
EFIAPI
CoreExit (
@ -1289,35 +1285,6 @@ CoreExit (
IN UINTN ExitDataSize,
IN CHAR16 *ExitData OPTIONAL
)
/*++
Routine Description:
Terminates the currently loaded EFI image and returns control to boot services.
Arguments:
ImageHandle - Handle that identifies the image. This parameter is passed to the image
on entry.
Status - The image's exit code.
ExitDataSize - The size, in bytes, of ExitData. Ignored if ExitStatus is
EFI_SUCCESS.
ExitData - Pointer to a data buffer that includes a Null-terminated Unicode string,
optionally followed by additional binary data. The string is a
description that the caller may use to further indicate the reason for
the image's exit.
Returns:
EFI_INVALID_PARAMETER - Image handle is NULL or it is not current image.
EFI_SUCCESS - Successfully terminates the currently loaded EFI image.
EFI_ACCESS_DENIED - Should never reach there.
EFI_OUT_OF_RESOURCES - Could not allocate pool
--*/
{
LOADED_IMAGE_PRIVATE_DATA *Image;
EFI_TPL OldTpl;
@ -1347,7 +1314,7 @@ Returns:
// Image has been started, verify this image can exit
//
if (Image != mCurrentImage) {
DEBUG ((EFI_D_LOAD|EFI_D_ERROR, "Exit: Image is not exitable image\n"));
DEBUG ((DEBUG_LOAD|DEBUG_ERROR, "Exit: Image is not exitable image\n"));
Status = EFI_INVALID_PARAMETER;
goto Done;
}
@ -1388,28 +1355,24 @@ Done:
/**
Unloads an image.
@param ImageHandle Handle that identifies the image to be
unloaded.
@retval EFI_SUCCESS The image has been unloaded.
@retval EFI_UNSUPPORTED The image has been sarted, and does not support
unload.
@retval EFI_INVALID_PARAMPETER ImageHandle is not a valid image handle.
**/
EFI_STATUS
EFIAPI
CoreUnloadImage (
IN EFI_HANDLE ImageHandle
)
/*++
Routine Description:
Unloads an image.
Arguments:
ImageHandle - Handle that identifies the image to be unloaded.
Returns:
EFI_SUCCESS - The image has been unloaded.
EFI_UNSUPPORTED - The image has been sarted, and does not support unload.
EFI_INVALID_PARAMPETER - ImageHandle is not a valid image handle.
--*/
{
EFI_STATUS Status;
LOADED_IMAGE_PRIVATE_DATA *Image;
@ -1460,33 +1423,24 @@ Done:
}
/**
Unload the specified image.
@param This Indicates the calling context.
@param ImageHandle The specified image handle.
@retval EFI_INVALID_PARAMETER Image handle is NULL.
@retval EFI_UNSUPPORTED Attempt to unload an unsupported image.
@retval EFI_SUCCESS Image successfully unloaded.
**/
EFI_STATUS
EFIAPI
CoreUnloadImageEx (
IN EFI_PE32_IMAGE_PROTOCOL *This,
IN EFI_HANDLE ImageHandle
)
/*++
Routine Description:
Unload the specified image.
Arguments:
This - Indicates the calling context.
ImageHandle - The specified image handle.
Returns:
EFI_INVALID_PARAMETER - Image handle is NULL.
EFI_UNSUPPORTED - Attempt to unload an unsupported image.
EFI_SUCCESS - Image successfully unloaded.
--*/
{
return CoreUnloadImage (ImageHandle);
}

View File

@ -15,6 +15,30 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include <DxeMain.h>
/**
Opens a file for (simple) reading. The simple read abstraction
will access the file either from a memory copy, from a file
system interface, or from the load file interface.
@param BootPolicy Policy for Open Image File.
@param SourceBuffer Pointer to the memory location containing copy
of the image to be loaded.
@param SourceSize The size in bytes of SourceBuffer.
@param FilePath The specific file path from which the image is
loaded
@param DeviceHandle Pointer to the return device handle.
@param ImageFileHandle Pointer to the image file handle.
@param AuthenticationStatus Pointer to a caller-allocated UINT32 in which
the authentication status is returned.
@retval EFI_SUCCESS Image file successfully opened.
@retval EFI_LOAD_ERROR If the caller passed a copy of the file, and
SourceSize is 0.
@retval EFI_INVALID_PARAMETER File path is not valid.
@retval EFI_NOT_FOUND File not found.
**/
EFI_STATUS
CoreOpenImageFile (
IN BOOLEAN BootPolicy,
@ -25,36 +49,6 @@ CoreOpenImageFile (
IN IMAGE_FILE_HANDLE *ImageFileHandle,
OUT UINT32 *AuthenticationStatus
)
/*++
Routine Description:
Opens a file for (simple) reading. The simple read abstraction
will access the file either from a memory copy, from a file
system interface, or from the load file interface.
Arguments:
BootPolicy - Policy for Open Image File.
SourceBuffer - Pointer to the memory location containing copy
of the image to be loaded.
SourceSize - The size in bytes of SourceBuffer.
FilePath - The specific file path from which the image is loaded
DeviceHandle - Pointer to the return device handle.
ImageFileHandle - Pointer to the image file handle.
AuthenticationStatus - Pointer to a caller-allocated UINT32 in which the authentication status is returned.
Returns:
EFI_SUCCESS - Image file successfully opened.
EFI_LOAD_ERROR - If the caller passed a copy of the file, and SourceSize is 0.
EFI_INVALID_PARAMETER - File path is not valid.
EFI_NOT_FOUND - File not found.
--*/
{
EFI_STATUS Status;
EFI_DEVICE_PATH_PROTOCOL *TempFilePath;
@ -318,7 +312,7 @@ Returns:
//
// Nothing else to try
//
DEBUG ((EFI_D_LOAD|EFI_D_WARN, "CoreOpenImageFile: Device did not support a known load protocol\n"));
DEBUG ((DEBUG_LOAD|DEBUG_WARN, "CoreOpenImageFile: Device did not support a known load protocol\n"));
Status = EFI_NOT_FOUND;
Done:
@ -340,6 +334,21 @@ Done:
/**
Read image file (specified by UserHandle) into user specified buffer with specified offset
and length.
@param UserHandle Image file handle
@param Offset Offset to the source file
@param ReadSize For input, pointer of size to read; For output,
pointer of size actually read.
@param Buffer Buffer to write into
@retval EFI_SUCCESS Successfully read the specified part of file
into buffer.
**/
EFI_STATUS
EFIAPI
CoreReadImageFile (
@ -348,29 +357,6 @@ CoreReadImageFile (
IN OUT UINTN *ReadSize,
OUT VOID *Buffer
)
/*++
Routine Description:
Read image file (specified by UserHandle) into user specified buffer with specified offset
and length.
Arguments:
UserHandle - Image file handle
Offset - Offset to the source file
ReadSize - For input, pointer of size to read;
For output, pointer of size actually read.
Buffer - Buffer to write into
Returns:
EFI_SUCCESS - Successfully read the specified part of file into buffer.
--*/
{
UINTN EndPosition;
IMAGE_FILE_HANDLE *FHand;
@ -393,6 +379,20 @@ Returns:
return EFI_SUCCESS;
}
/**
Search a handle to a device on a specified device path that supports a specified protocol,
interface of that protocol on that handle is another output.
@param Protocol The protocol to search for
@param FilePath The specified device path
@param Interface Interface of the protocol on the handle
@param Handle The handle to the device on the specified device
path that supports the protocol.
@return Status code.
**/
EFI_STATUS
CoreDevicePathToInterface (
IN EFI_GUID *Protocol,
@ -400,28 +400,6 @@ CoreDevicePathToInterface (
OUT VOID **Interface,
OUT EFI_HANDLE *Handle
)
/*++
Routine Description:
Search a handle to a device on a specified device path that supports a specified protocol,
interface of that protocol on that handle is another output.
Arguments:
Protocol - The protocol to search for
FilePath - The specified device path
Interface - Interface of the protocol on the handle
Handle - The handle to the device on the specified device path that supports the protocol.
Returns:
Status code.
--*/
{
EFI_STATUS Status;
@ -432,37 +410,28 @@ Returns:
return Status;
}
/**
Helper function called as part of the code needed
to allocate the proper sized buffer for various
EFI interfaces.
@param Status Current status
@param Buffer Current allocated buffer, or NULL
@param BufferSize Current buffer size needed
@retval TRUE if the buffer was reallocated and the caller
should try the API again.
@retval FALSE buffer could not be allocated and the caller
should not try the API again.
**/
BOOLEAN
CoreGrowBuffer (
IN OUT EFI_STATUS *Status,
IN OUT VOID **Buffer,
IN UINTN BufferSize
)
/*++
Routine Description:
Helper function called as part of the code needed
to allocate the proper sized buffer for various
EFI interfaces.
Arguments:
Status - Current status
Buffer - Current allocated buffer, or NULL
BufferSize - Current buffer size needed
Returns:
TRUE - if the buffer was reallocated and the caller
should try the API again.
FALSE - buffer could not be allocated and the caller
should not try the API again.
--*/
{
BOOLEAN TryAgain;
@ -506,3 +475,4 @@ Returns:
return TryAgain;
}

View File

@ -11,356 +11,286 @@ http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
--*/
**/
#ifndef _DXE_LIBRARY_H_
#define _DXE_LIBRARY_H_
/**
Report status code of type EFI_PROGRESS_CODE by caller ID gEfiCallerIdGuid.
@param Value Describes the class/subclass/operation of the
hardware or software entity that the Status Code
relates to.
**/
VOID
CoreReportProgressCode (
IN EFI_STATUS_CODE_VALUE Value
)
/*++
Routine Description:
Report status code of type EFI_PROGRESS_CODE by caller ID gEfiCallerIdGuid.
Arguments:
Value - Describes the class/subclass/operation of the hardware or software entity
that the Status Code relates to.
Returns:
None
--*/
;
/**
Report status code of type EFI_PROGRESS_CODE by caller ID gEfiCallerIdGuid,
with a handle as additional information.
@param Value Describes the class/subclass/operation of the
hardware or software entity that the Status Code
relates to.
@param Handle Additional information.
**/
VOID
CoreReportProgressCodeSpecific (
IN EFI_STATUS_CODE_VALUE Value,
IN EFI_HANDLE Handle
)
/*++
Routine Description:
Report status code of type EFI_PROGRESS_CODE by caller ID gEfiCallerIdGuid,
with a handle as additional information.
Arguments:
Value - Describes the class/subclass/operation of the hardware or software entity
that the Status Code relates to.
Handle - Additional information.
Returns:
None
--*/
;
/**
Raising to the task priority level of the mutual exclusion
lock, and then acquires ownership of the lock.
@param Lock The lock to acquire
@return Lock owned
**/
VOID
CoreAcquireLock (
IN EFI_LOCK *Lock
)
/*++
Routine Description:
Raising to the task priority level of the mutual exclusion
lock, and then acquires ownership of the lock.
Arguments:
Lock - The lock to acquire
Returns:
Lock owned
--*/
;
EFI_STATUS
CoreAcquireLockOrFail (
IN EFI_LOCK *Lock
)
/*++
Routine Description:
/**
Initialize a basic mutual exclusion lock. Each lock
provides mutual exclusion access at it's task priority
level. Since there is no-premption (at any TPL) or
multiprocessor support, acquiring the lock only consists
of raising to the locks TPL.
Arguments:
Lock - The EFI_LOCK structure to initialize
Returns:
@param Lock The EFI_LOCK structure to initialize
EFI_SUCCESS - Lock Owned.
EFI_ACCESS_DENIED - Reentrant Lock Acquisition, Lock not Owned.
@retval EFI_SUCCESS Lock Owned.
@retval EFI_ACCESS_DENIED Reentrant Lock Acquisition, Lock not Owned.
--*/
**/
EFI_STATUS
CoreAcquireLockOrFail (
IN EFI_LOCK *Lock
)
;
/**
Releases ownership of the mutual exclusion lock, and
restores the previous task priority level.
@param Lock The lock to release
@return Lock unowned
**/
VOID
CoreReleaseLock (
IN EFI_LOCK *Lock
)
/*++
Routine Description:
Releases ownership of the mutual exclusion lock, and
restores the previous task priority level.
Arguments:
Lock - The lock to release
Returns:
Lock unowned
--*/
;
//
// Device Path functions
//
/**
Calculate the size of a whole device path.
@param DevicePath The pointer to the device path data.
@return Size of device path data structure..
**/
UINTN
CoreDevicePathSize (
IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
)
/*++
Routine Description:
Calculate the size of a whole device path.
Arguments:
DevicePath - The pointer to the device path data.
Returns:
Size of device path data structure..
--*/
;
/**
Return TRUE is this is a multi instance device path.
@param DevicePath A pointer to a device path data structure.
@retval TRUE If DevicePath is multi instance. FALSE - If
DevicePath is not multi instance.
**/
BOOLEAN
CoreIsDevicePathMultiInstance (
IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
)
/*++
Routine Description:
Return TRUE is this is a multi instance device path.
Arguments:
DevicePath - A pointer to a device path data structure.
Returns:
TRUE - If DevicePath is multi instance. FALSE - If DevicePath is not multi
instance.
--*/
;
/**
Duplicate a new device path data structure from the old one.
@param DevicePath A pointer to a device path data structure.
@return A pointer to the new allocated device path data.
@return Caller must free the memory used by DevicePath if it is no longer needed.
**/
EFI_DEVICE_PATH_PROTOCOL *
CoreDuplicateDevicePath (
IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
)
/*++
Routine Description:
Duplicate a new device path data structure from the old one.
Arguments:
DevicePath - A pointer to a device path data structure.
Returns:
A pointer to the new allocated device path data.
Caller must free the memory used by DevicePath if it is no longer needed.
--*/
;
/**
Function is used to append a Src1 and Src2 together.
@param Src1 A pointer to a device path data structure.
@param Src2 A pointer to a device path data structure.
@return A pointer to the new device path is returned.
@return NULL is returned if space for the new device path could not be allocated from pool.
@return It is up to the caller to free the memory used by Src1 and Src2 if they are no longer needed.
**/
EFI_DEVICE_PATH_PROTOCOL *
CoreAppendDevicePath (
IN EFI_DEVICE_PATH_PROTOCOL *Src1,
IN EFI_DEVICE_PATH_PROTOCOL *Node
IN EFI_DEVICE_PATH_PROTOCOL *Src2
)
/*++
Routine Description:
Function is used to append a Src1 and Src2 together.
Arguments:
Src1 - A pointer to a device path data structure.
Node - A pointer to a device path data structure.
Returns:
A pointer to the new device path is returned.
NULL is returned if space for the new device path could not be allocated from pool.
It is up to the caller to free the memory used by Src1 and Src2 if they are no longer needed.
--*/
;
/**
Allocate pool of type EfiBootServicesData, the size is specified with AllocationSize.
@param AllocationSize Size to allocate.
@return Pointer of the allocated pool.
**/
VOID *
CoreAllocateBootServicesPool (
IN UINTN AllocationSize
)
/*++
Routine Description:
Allocate pool of type EfiBootServicesData, the size is specified with AllocationSize.
Arguments:
AllocationSize - Size to allocate.
Returns:
Pointer of the allocated pool.
--*/
;
/**
Allocate pool of type EfiBootServicesData and zero it, the size is specified with AllocationSize.
@param AllocationSize Size to allocate.
@return Pointer of the allocated pool.
**/
VOID *
CoreAllocateZeroBootServicesPool (
IN UINTN AllocationSize
)
/*++
Routine Description:
Allocate pool of type EfiBootServicesData and zero it, the size is specified with AllocationSize.
Arguments:
AllocationSize - Size to allocate.
Returns:
Pointer of the allocated pool.
--*/
;
/**
Find a config table by name in system table's ConfigurationTable.
@param Guid The table name to look for
@param Table Pointer of the config table
@retval EFI_NOT_FOUND Could not find the table in system table's
ConfigurationTable.
@retval EFI_SUCCESS Table successfully found.
**/
EFI_STATUS
CoreGetConfigTable (
IN EFI_GUID *Guid,
IN OUT VOID **Table
)
/*++
Routine Description:
Find a config table by name in system table's ConfigurationTable.
Arguments:
Guid - The table name to look for
Table - Pointer of the config table
Returns:
EFI_NOT_FOUND - Could not find the table in system table's ConfigurationTable.
EFI_SUCCESS - Table successfully found.
--*/
;
/**
Allocate pool of specified size with EfiRuntimeServicesData type, and copy specified buffer to this pool.
@param AllocationSize Size to allocate.
@param Buffer Specified buffer that will be copy to the allocated
pool
@return Pointer of the allocated pool.
**/
VOID *
CoreAllocateRuntimeCopyPool (
IN UINTN AllocationSize,
IN VOID *Buffer
)
/*++
Routine Description:
Allocate pool of specified size with EfiRuntimeServicesData type, and copy specified buffer to this pool.
Arguments:
AllocationSize - Size to allocate.
Buffer - Specified buffer that will be copy to the allocated pool
Returns:
Pointer of the allocated pool.
--*/
;
/**
Allocate pool of type EfiRuntimeServicesData, the size is specified with AllocationSize.
@param AllocationSize Size to allocate.
@return Pointer of the allocated pool.
**/
VOID *
CoreAllocateRuntimePool (
IN UINTN AllocationSize
)
/*++
Routine Description:
Allocate pool of type EfiRuntimeServicesData, the size is specified with AllocationSize.
Arguments:
AllocationSize - Size to allocate.
Returns:
Pointer of the allocated pool.
--*/
;
/**
Allocate pool of specified size with EfiBootServicesData type, and copy specified buffer to this pool.
@param AllocationSize Size to allocate.
@param Buffer Specified buffer that will be copy to the allocated
pool
@return Pointer of the allocated pool.
**/
VOID *
CoreAllocateCopyPool (
IN UINTN AllocationSize,
IN VOID *Buffer
)
/*++
Routine Description:
Allocate pool of specified size with EfiBootServicesData type, and copy specified buffer to this pool.
Arguments:
AllocationSize - Size to allocate.
Buffer - Specified buffer that will be copy to the allocated pool
Returns:
Pointer of the allocated pool.
--*/
;
/**
Create a protocol notification event and return it.
@param ProtocolGuid Protocol to register notification event on.
@param NotifyTpl Maximum TPL to signal the NotifyFunction.
@param NotifyFunction EFI notification routine.
@param NotifyContext Context passed into Event when it is created.
@param Registration Registration key returned from
RegisterProtocolNotify().
@param SignalFlag Boolean value to decide whether kick the event after
register or not.
@return The EFI_EVENT that has been registered to be signaled when a ProtocolGuid
is added to the system.
**/
EFI_EVENT
CoreCreateProtocolNotifyEvent (
IN EFI_GUID *ProtocolGuid,
@ -370,32 +300,6 @@ CoreCreateProtocolNotifyEvent (
OUT VOID **Registration,
IN BOOLEAN SignalFlag
)
/*++
Routine Description:
Create a protocol notification event and return it.
Arguments:
ProtocolGuid - Protocol to register notification event on.
NotifyTpl - Maximum TPL to signal the NotifyFunction.
NotifyFuncition - EFI notification routine.
NotifyContext - Context passed into Event when it is created.
Registration - Registration key returned from RegisterProtocolNotify().
SignalFlag - Boolean value to decide whether kick the event after register or not.
Returns:
The EFI_EVENT that has been registered to be signaled when a ProtocolGuid
is added to the system.
--*/
;
#endif

View File

@ -1,7 +1,7 @@
/**@file
/** @file
DXE Core library services.
Copyright (c) 2006 - 2007, Intel Corporation
Copyright (c) 2006 - 2008, Intel Corporation
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@ -14,7 +14,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include <DxeMain.h>
UINTN mErrorLevel = EFI_D_ERROR | EFI_D_LOAD;
UINTN mErrorLevel = DEBUG_ERROR | DEBUG_LOAD;
EFI_DXE_DEVICE_HANDLE_EXTENDED_DATA mStatusCodeData = {
{
@ -25,30 +25,22 @@ EFI_DXE_DEVICE_HANDLE_EXTENDED_DATA mStatusCodeData = {
NULL
};
/**
Report status code of type EFI_PROGRESS_CODE by caller ID gEfiCallerIdGuid,
with a handle as additional information.
@param Value Describes the class/subclass/operation of the
hardware or software entity that the Status Code
relates to.
@param Handle Additional information.
**/
VOID
CoreReportProgressCodeSpecific (
IN EFI_STATUS_CODE_VALUE Value,
IN EFI_HANDLE Handle
)
/*++
Routine Description:
Report status code of type EFI_PROGRESS_CODE by caller ID gEfiCallerIdGuid,
with a handle as additional information.
Arguments:
Value - Describes the class/subclass/operation of the hardware or software entity
that the Status Code relates to.
Handle - Additional information.
Returns:
None
--*/
{
mStatusCodeData.DataHeader.Size = sizeof (EFI_DXE_DEVICE_HANDLE_EXTENDED_DATA) - sizeof (EFI_STATUS_CODE_DATA);
mStatusCodeData.Handle = Handle;
@ -64,26 +56,19 @@ Returns:
}
}
/**
Report status code of type EFI_PROGRESS_CODE by caller ID gEfiCallerIdGuid.
@param Value Describes the class/subclass/operation of the
hardware or software entity that the Status Code
relates to.
**/
VOID
CoreReportProgressCode (
IN EFI_STATUS_CODE_VALUE Value
)
/*++
Routine Description:
Report status code of type EFI_PROGRESS_CODE by caller ID gEfiCallerIdGuid.
Arguments:
Value - Describes the class/subclass/operation of the hardware or software entity
that the Status Code relates to.
Returns:
None
--*/
{
if ((gStatusCode != NULL) && (gStatusCode->ReportStatusCode != NULL) ) {
gStatusCode->ReportStatusCode (
@ -97,25 +82,19 @@ Returns:
}
/**
Allocate pool of type EfiBootServicesData, the size is specified with AllocationSize.
@param AllocationSize Size to allocate.
@return Pointer of the allocated pool.
**/
VOID *
CoreAllocateBootServicesPool (
IN UINTN AllocationSize
)
/*++
Routine Description:
Allocate pool of type EfiBootServicesData, the size is specified with AllocationSize.
Arguments:
AllocationSize - Size to allocate.
Returns:
Pointer of the allocated pool.
--*/
{
VOID *Memory;
@ -124,25 +103,19 @@ Returns:
}
/**
Allocate pool of type EfiBootServicesData and zero it, the size is specified with AllocationSize.
@param AllocationSize Size to allocate.
@return Pointer of the allocated pool.
**/
VOID *
CoreAllocateZeroBootServicesPool (
IN UINTN AllocationSize
)
/*++
Routine Description:
Allocate pool of type EfiBootServicesData and zero it, the size is specified with AllocationSize.
Arguments:
AllocationSize - Size to allocate.
Returns:
Pointer of the allocated pool.
--*/
{
VOID *Memory;
@ -152,28 +125,22 @@ Returns:
}
/**
Allocate pool of specified size with EfiBootServicesData type, and copy specified buffer to this pool.
@param AllocationSize Size to allocate.
@param Buffer Specified buffer that will be copy to the allocated
pool
@return Pointer of the allocated pool.
**/
VOID *
CoreAllocateCopyPool (
IN UINTN AllocationSize,
IN VOID *Buffer
)
/*++
Routine Description:
Allocate pool of specified size with EfiBootServicesData type, and copy specified buffer to this pool.
Arguments:
AllocationSize - Size to allocate.
Buffer - Specified buffer that will be copy to the allocated pool
Returns:
Pointer of the allocated pool.
--*/
{
VOID *Memory;
@ -185,25 +152,19 @@ Returns:
/**
Allocate pool of type EfiRuntimeServicesData, the size is specified with AllocationSize.
@param AllocationSize Size to allocate.
@return Pointer of the allocated pool.
**/
VOID *
CoreAllocateRuntimePool (
IN UINTN AllocationSize
)
/*++
Routine Description:
Allocate pool of type EfiRuntimeServicesData, the size is specified with AllocationSize.
Arguments:
AllocationSize - Size to allocate.
Returns:
Pointer of the allocated pool.
--*/
{
VOID *Memory;
@ -211,29 +172,22 @@ Returns:
return Memory;
}
/**
Allocate pool of specified size with EfiRuntimeServicesData type, and copy specified buffer to this pool.
@param AllocationSize Size to allocate.
@param Buffer Specified buffer that will be copy to the allocated
pool
@return Pointer of the allocated pool.
**/
VOID *
CoreAllocateRuntimeCopyPool (
IN UINTN AllocationSize,
IN VOID *Buffer
)
/*++
Routine Description:
Allocate pool of specified size with EfiRuntimeServicesData type, and copy specified buffer to this pool.
Arguments:
AllocationSize - Size to allocate.
Buffer - Specified buffer that will be copy to the allocated pool
Returns:
Pointer of the allocated pool.
--*/
{
VOID *Memory;
@ -250,31 +204,23 @@ Returns:
//
EFI_STATUS
CoreAcquireLockOrFail (
IN EFI_LOCK *Lock
)
/*++
Routine Description:
/**
Initialize a basic mutual exclusion lock. Each lock
provides mutual exclusion access at it's task priority
level. Since there is no-premption (at any TPL) or
multiprocessor support, acquiring the lock only consists
of raising to the locks TPL.
Arguments:
@param Lock The EFI_LOCK structure to initialize
Lock - The EFI_LOCK structure to initialize
@retval EFI_SUCCESS Lock Owned.
@retval EFI_ACCESS_DENIED Reentrant Lock Acquisition, Lock not Owned.
Returns:
EFI_SUCCESS - Lock Owned.
EFI_ACCESS_DENIED - Reentrant Lock Acquisition, Lock not Owned.
--*/
**/
EFI_STATUS
CoreAcquireLockOrFail (
IN EFI_LOCK *Lock
)
{
ASSERT (Lock != NULL);
ASSERT (Lock->Lock != EfiLockUninitialized);
@ -293,26 +239,20 @@ Returns:
}
/**
Raising to the task priority level of the mutual exclusion
lock, and then acquires ownership of the lock.
@param Lock The lock to acquire
@return Lock owned
**/
VOID
CoreAcquireLock (
IN EFI_LOCK *Lock
)
/*++
Routine Description:
Raising to the task priority level of the mutual exclusion
lock, and then acquires ownership of the lock.
Arguments:
Lock - The lock to acquire
Returns:
Lock owned
--*/
{
ASSERT (Lock != NULL);
ASSERT (Lock->Lock == EfiLockReleased);
@ -322,26 +262,20 @@ Returns:
}
/**
Releases ownership of the mutual exclusion lock, and
restores the previous task priority level.
@param Lock The lock to release
@return Lock unowned
**/
VOID
CoreReleaseLock (
IN EFI_LOCK *Lock
)
/*++
Routine Description:
Releases ownership of the mutual exclusion lock, and
restores the previous task priority level.
Arguments:
Lock - The lock to release
Returns:
Lock unowned
--*/
{
EFI_TPL Tpl;
@ -356,25 +290,19 @@ Returns:
}
/**
Calculate the size of a whole device path.
@param DevicePath The pointer to the device path data.
@return Size of device path data structure..
**/
UINTN
CoreDevicePathSize (
IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
)
/*++
Routine Description:
Calculate the size of a whole device path.
Arguments:
DevicePath - The pointer to the device path data.
Returns:
Size of device path data structure..
--*/
{
EFI_DEVICE_PATH_PROTOCOL *Start;
@ -397,24 +325,20 @@ Returns:
}
/**
Return TRUE is this is a multi instance device path.
@param DevicePath A pointer to a device path data structure.
@retval TRUE If DevicePath is multi instance. FALSE - If
DevicePath is not multi instance.
**/
BOOLEAN
CoreIsDevicePathMultiInstance (
IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
)
/*++
Routine Description:
Return TRUE is this is a multi instance device path.
Arguments:
DevicePath - A pointer to a device path data structure.
Returns:
TRUE - If DevicePath is multi instance. FALSE - If DevicePath is not multi
instance.
--*/
{
EFI_DEVICE_PATH_PROTOCOL *Node;
@ -434,23 +358,20 @@ Returns:
/**
Duplicate a new device path data structure from the old one.
@param DevicePath A pointer to a device path data structure.
@return A pointer to the new allocated device path data.
@return Caller must free the memory used by DevicePath if it is no longer needed.
**/
EFI_DEVICE_PATH_PROTOCOL *
CoreDuplicateDevicePath (
IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
)
/*++
Routine Description:
Duplicate a new device path data structure from the old one.
Arguments:
DevicePath - A pointer to a device path data structure.
Returns:
A pointer to the new allocated device path data.
Caller must free the memory used by DevicePath if it is no longer needed.
--*/
{
EFI_DEVICE_PATH_PROTOCOL *NewDevicePath;
UINTN Size;
@ -474,28 +395,23 @@ Returns:
/**
Function is used to append a Src1 and Src2 together.
@param Src1 A pointer to a device path data structure.
@param Src2 A pointer to a device path data structure.
@return A pointer to the new device path is returned.
@return NULL is returned if space for the new device path could not be allocated from pool.
@return It is up to the caller to free the memory used by Src1 and Src2 if they are no longer needed.
**/
EFI_DEVICE_PATH_PROTOCOL *
CoreAppendDevicePath (
IN EFI_DEVICE_PATH_PROTOCOL *Src1,
IN EFI_DEVICE_PATH_PROTOCOL *Src2
)
/*++
Routine Description:
Function is used to append a Src1 and Src2 together.
Arguments:
Src1 - A pointer to a device path data structure.
Src2 - A pointer to a device path data structure.
Returns:
A pointer to the new device path is returned.
NULL is returned if space for the new device path could not be allocated from pool.
It is up to the caller to free the memory used by Src1 and Src2 if they are no longer needed.
--*/
{
UINTN Size;
UINTN Size1;
@ -530,6 +446,23 @@ Returns:
/**
Create a protocol notification event and return it.
@param ProtocolGuid Protocol to register notification event on.
@param NotifyTpl Maximum TPL to signal the NotifyFunction.
@param NotifyFunction EFI notification routine.
@param NotifyContext Context passed into Event when it is created.
@param Registration Registration key returned from
RegisterProtocolNotify().
@param SignalFlag Boolean value to decide whether kick the event after
register or not.
@return The EFI_EVENT that has been registered to be signaled when a ProtocolGuid
is added to the system.
**/
EFI_EVENT
CoreCreateProtocolNotifyEvent (
IN EFI_GUID *ProtocolGuid,
@ -539,32 +472,6 @@ CoreCreateProtocolNotifyEvent (
OUT VOID **Registration,
IN BOOLEAN SignalFlag
)
/*++
Routine Description:
Create a protocol notification event and return it.
Arguments:
ProtocolGuid - Protocol to register notification event on.
NotifyTpl - Maximum TPL to signal the NotifyFunction.
NotifyFuncition - EFI notification routine.
NotifyContext - Context passed into Event when it is created.
Registration - Registration key returned from RegisterProtocolNotify().
SignalFlag - Boolean value to decide whether kick the event after register or not.
Returns:
The EFI_EVENT that has been registered to be signaled when a ProtocolGuid
is added to the system.
--*/
{
EFI_STATUS Status;
EFI_EVENT Event;
@ -604,3 +511,4 @@ Returns:
return Event;
}

View File

@ -91,12 +91,30 @@ EFI_MEMORY_TYPE_INFORMATION gMemoryTypeInformation[EfiMaxMemoryType + 1] = {
//
// Internal prototypes
//
/**
Find untested but initialized memory regions in GCD map and convert them to be DXE allocatable.
**/
STATIC
VOID
PromoteMemoryResource (
VOID
);
);
/**
Internal function. Adds a ranges to the memory map.
The range must not already exist in the map.
@param Type The type of memory range to add
@param Start The starting address in the memory range Must be
paged aligned
@param End The last address in the range Must be the last
byte of a page
@param Attribute The attributes of the memory range to add
@return None. The range is added to the memory map
**/
STATIC
VOID
CoreAddRange (
@ -106,12 +124,33 @@ CoreAddRange (
IN UINT64 Attribute
);
/**
Internal function. Moves any memory descriptors that are on the
temporary descriptor stack to heap.
**/
STATIC
VOID
CoreFreeMemoryMapStack (
VOID
);
/**
Internal function. Converts a memory range to the specified type.
The range must exist in the memory map.
@param Start The first address of the range Must be page
aligned
@param NumberOfPages The number of pages to convert
@param NewType The new type for the memory range
@retval EFI_INVALID_PARAMETER Invalid parameter
@retval EFI_NOT_FOUND Could not find a descriptor cover the specified
range or convertion not allowed.
@retval EFI_SUCCESS Successfully converts the memory range to the
specified type.
**/
STATIC
EFI_STATUS
CoreConvertPages (
@ -120,90 +159,79 @@ CoreConvertPages (
IN EFI_MEMORY_TYPE NewType
);
/**
Internal function. Removes a descriptor entry.
@param Entry The entry to remove
**/
STATIC
VOID
RemoveMemoryMapEntry (
MEMORY_MAP *Entry
);
/**
Internal function. Deque a descriptor entry from the mFreeMemoryMapEntryList.
If the list is emtry, then allocate a new page to refuel the list.
Please Note this algorithm to allocate the memory map descriptor has a property
that the memory allocated for memory entries always grows, and will never really be freed
For example, if the current boot uses 2000 memory map entries at the maximum point, but
ends up with only 50 at the time the OS is booted, then the memory associated with the 1950
memory map entries is still allocated from EfiBootServicesMemory.
@return The Memory map descriptor dequed from the mFreeMemoryMapEntryList
**/
STATIC
MEMORY_MAP *
AllocateMemoryMapEntry (
VOID
);
/**
Enter critical section by gaining lock on gMemoryLock.
**/
VOID
CoreAcquireMemoryLock (
VOID
)
/*++
Routine Description:
Enter critical section by gaining lock on gMemoryLock
Arguments:
None
Returns:
None
--*/
{
CoreAcquireLock (&gMemoryLock);
}
/**
Exit critical section by releasing lock on gMemoryLock.
**/
VOID
CoreReleaseMemoryLock (
VOID
)
/*++
Routine Description:
Exit critical section by releasing lock on gMemoryLock
Arguments:
None
Returns:
None
--*/
{
CoreReleaseLock (&gMemoryLock);
}
/**
Find untested but initialized memory regions in GCD map and convert them to be DXE allocatable.
**/
STATIC
VOID
PromoteMemoryResource (
VOID
)
/*++
Routine Description:
Find untested but initialized memory regions in GCD map and convert them to be DXE allocatable.
Arguments:
None
Returns:
None
--*/
{
LIST_ENTRY *Link;
EFI_GCD_MAP_ENTRY *Entry;
DEBUG ((EFI_D_ERROR | EFI_D_PAGE, "Promote the memory resource\n"));
DEBUG ((DEBUG_ERROR | DEBUG_PAGE, "Promote the memory resource\n"));
CoreAcquireGcdMemoryLock ();
@ -246,6 +274,22 @@ Returns:
return;
}
/**
Called to initialize the memory map and add descriptors to
the current descriptor list.
The first descriptor that is added must be general usable
memory as the addition allocates heap.
@param Type The type of memory to add
@param Start The starting address in the memory range Must be
page aligned
@param NumberOfPages The number of pages in the range
@param Attribute Attributes of the memory to add
@return None. The range is added to the memory map
**/
VOID
CoreAddMemoryDescriptor (
IN EFI_MEMORY_TYPE Type,
@ -253,32 +297,6 @@ CoreAddMemoryDescriptor (
IN UINT64 NumberOfPages,
IN UINT64 Attribute
)
/*++
Routine Description:
Called to initialize the memory map and add descriptors to
the current descriptor list.
The first descriptor that is added must be general usable
memory as the addition allocates heap.
Arguments:
Type - The type of memory to add
Start - The starting address in the memory range
Must be page aligned
NumberOfPages - The number of pages in the range
Attribute - Attributes of the memory to add
Returns:
None. The range is added to the memory map
--*/
{
EFI_PHYSICAL_ADDRESS End;
EFI_STATUS Status;
@ -416,6 +434,21 @@ Returns:
}
/**
Internal function. Adds a ranges to the memory map.
The range must not already exist in the map.
@param Type The type of memory range to add
@param Start The starting address in the memory range Must be
paged aligned
@param End The last address in the range Must be the last
byte of a page
@param Attribute The attributes of the memory range to add
@return None. The range is added to the memory map
**/
STATIC
VOID
CoreAddRange (
@ -424,30 +457,6 @@ CoreAddRange (
IN EFI_PHYSICAL_ADDRESS End,
IN UINT64 Attribute
)
/*++
Routine Description:
Internal function. Adds a ranges to the memory map.
The range must not already exist in the map.
Arguments:
Type - The type of memory range to add
Start - The starting address in the memory range
Must be paged aligned
End - The last address in the range
Must be the last byte of a page
Attribute - The attributes of the memory range to add
Returns:
None. The range is added to the memory map
--*/
{
LIST_ENTRY *Link;
MEMORY_MAP *Entry;
@ -457,7 +466,7 @@ Returns:
ASSERT_LOCKED (&gMemoryLock);
DEBUG ((EFI_D_PAGE, "AddRange: %lx-%lx to %d\n", Start, End, Type));
DEBUG ((DEBUG_PAGE, "AddRange: %lx-%lx to %d\n", Start, End, Type));
//
// Memory map being altered so updated key
@ -527,27 +536,17 @@ Returns:
return ;
}
/**
Internal function. Moves any memory descriptors that are on the
temporary descriptor stack to heap.
**/
STATIC
VOID
CoreFreeMemoryMapStack (
VOID
)
/*++
Routine Description:
Internal function. Moves any memory descriptors that are on the
temporary descriptor stack to heap.
Arguments:
None
Returns:
None
--*/
{
MEMORY_MAP *Entry;
MEMORY_MAP *Entry2;
@ -615,64 +614,49 @@ Returns:
mFreeMapStack -= 1;
}
/**
Internal function. Removes a descriptor entry.
@param Entry The entry to remove
**/
STATIC
VOID
RemoveMemoryMapEntry (
MEMORY_MAP *Entry
)
/*++
Routine Description:
Internal function. Removes a descriptor entry.
Arguments:
Entry - The entry to remove
Returns:
None
--*/
{
RemoveEntryList (&Entry->Link);
Entry->Link.ForwardLink = NULL;
if (Entry->FromPages) {
//
// Insert the free memory map descriptor to the end of mFreeMemoryMapEntryList
//
//
// Insert the free memory map descriptor to the end of mFreeMemoryMapEntryList
//
InsertTailList (&mFreeMemoryMapEntryList, &Entry->Link);
}
}
/**
Internal function. Deque a descriptor entry from the mFreeMemoryMapEntryList.
If the list is emtry, then allocate a new page to refuel the list.
Please Note this algorithm to allocate the memory map descriptor has a property
that the memory allocated for memory entries always grows, and will never really be freed
For example, if the current boot uses 2000 memory map entries at the maximum point, but
ends up with only 50 at the time the OS is booted, then the memory associated with the 1950
memory map entries is still allocated from EfiBootServicesMemory.
@return The Memory map descriptor dequed from the mFreeMemoryMapEntryList
**/
STATIC
MEMORY_MAP *
AllocateMemoryMapEntry (
VOID
)
/*++
Routine Description:
Internal function. Deque a descriptor entry from the mFreeMemoryMapEntryList.
If the list is emtry, then allocate a new page to refuel the list.
Please Note this algorithm to allocate the memory map descriptor has a property
that the memory allocated for memory entries always grows, and will never really be freed
For example, if the current boot uses 2000 memory map entries at the maximum point, but
ends up with only 50 at the time the OS is booted, then the memory associated with the 1950
memory map entries is still allocated from EfiBootServicesMemory.
Arguments:
NONE
Returns:
The Memory map descriptor dequed from the mFreeMemoryMapEntryList
--*/
{
MEMORY_MAP* FreeDescriptorEntries;
MEMORY_MAP* Entry;
@ -704,6 +688,23 @@ Returns:
return Entry;
}
/**
Internal function. Converts a memory range to the specified type.
The range must exist in the memory map.
@param Start The first address of the range Must be page
aligned
@param NumberOfPages The number of pages to convert
@param NewType The new type for the memory range
@retval EFI_INVALID_PARAMETER Invalid parameter
@retval EFI_NOT_FOUND Could not find a descriptor cover the specified
range or convertion not allowed.
@retval EFI_SUCCESS Successfully converts the memory range to the
specified type.
**/
STATIC
EFI_STATUS
CoreConvertPages (
@ -711,32 +712,6 @@ CoreConvertPages (
IN UINT64 NumberOfPages,
IN EFI_MEMORY_TYPE NewType
)
/*++
Routine Description:
Internal function. Converts a memory range to the specified type.
The range must exist in the memory map.
Arguments:
Start - The first address of the range
Must be page aligned
NumberOfPages - The number of pages to convert
NewType - The new type for the memory range
Returns:
EFI_INVALID_PARAMETER - Invalid parameter
EFI_NOT_FOUND - Could not find a descriptor cover the specified range
or convertion not allowed.
EFI_SUCCESS - Successfully converts the memory range to the specified type.
--*/
{
UINT64 NumberOfBytes;
@ -777,7 +752,7 @@ Returns:
}
if (Link == &gMemoryMap) {
DEBUG ((EFI_D_ERROR | EFI_D_PAGE, "ConvertPages: failed to find range %lx - %lx\n", Start, End));
DEBUG ((DEBUG_ERROR | DEBUG_PAGE, "ConvertPages: failed to find range %lx - %lx\n", Start, End));
return EFI_NOT_FOUND;
}
@ -790,13 +765,13 @@ Returns:
RangeEnd = Entry->End;
}
DEBUG ((EFI_D_PAGE, "ConvertRange: %lx-%lx to %d\n", Start, RangeEnd, NewType));
DEBUG ((DEBUG_PAGE, "ConvertRange: %lx-%lx to %d\n", Start, RangeEnd, NewType));
//
// Debug code - verify conversion is allowed
//
if (!(NewType == EfiConventionalMemory ? 1 : 0) ^ (Entry->Type == EfiConventionalMemory ? 1 : 0)) {
DEBUG ((EFI_D_ERROR , "ConvertPages: Incompatible memory types\n"));
DEBUG ((DEBUG_ERROR , "ConvertPages: Incompatible memory types\n"));
return EFI_NOT_FOUND;
}
@ -909,6 +884,20 @@ Returns:
}
/**
Internal function. Finds a consecutive free page range below
the requested address.
@param MaxAddress The address that the range must be below
@param NumberOfPages Number of pages needed
@param NewType The type of memory the range is going to be
turned into
@param Alignment Bits to align with
@return The base address of the range, or 0 if the range was not found
**/
STATIC
UINT64
CoreFindFreePagesI (
@ -917,28 +906,6 @@ CoreFindFreePagesI (
IN EFI_MEMORY_TYPE NewType,
IN UINTN Alignment
)
/*++
Routine Description:
Internal function. Finds a consecutive free page range below
the requested address.
Arguments:
MaxAddress - The address that the range must be below
NumberOfPages - Number of pages needed
NewType - The type of memory the range is going to be turned into
Alignment - Bits to align with
Returns:
The base address of the range, or 0 if the range was not found
--*/
{
UINT64 NumberOfBytes;
UINT64 Target;
@ -1038,6 +1005,20 @@ Returns:
return Target;
}
/**
Internal function. Finds a consecutive free page range below
the requested address
@param MaxAddress The address that the range must be below
@param NoPages Number of pages needed
@param NewType The type of memory the range is going to be
turned into
@param Alignment Bits to align with
@return The base address of the range, or 0 if the range was not found.
**/
STATIC
UINT64
FindFreePages (
@ -1046,28 +1027,6 @@ FindFreePages (
IN EFI_MEMORY_TYPE NewType,
IN UINTN Alignment
)
/*++
Routine Description:
Internal function. Finds a consecutive free page range below
the requested address
Arguments:
MaxAddress - The address that the range must be below
NoPages - Number of pages needed
NewType - The type of memory the range is going to be turned into
Alignment - Bits to align with
Returns:
The base address of the range, or 0 if the range was not found.
--*/
{
UINT64 NewMaxAddress;
UINT64 Start;
@ -1103,6 +1062,25 @@ Returns:
}
/**
Allocates pages from the memory map.
@param Type The type of allocation to perform
@param MemoryType The type of memory to turn the allocated pages
into
@param NumberOfPages The number of pages to allocate
@param Memory A pointer to receive the base allocated memory
address
@return Status. On success, Memory is filled in with the base address allocated
@retval EFI_INVALID_PARAMETER Parameters violate checking rules defined in
spec.
@retval EFI_NOT_FOUND Could not allocate pages match the requirement.
@retval EFI_OUT_OF_RESOURCES No enough pages to allocate.
@retval EFI_SUCCESS Pages successfully allocated.
**/
EFI_STATUS
EFIAPI
CoreAllocatePages (
@ -1111,35 +1089,6 @@ CoreAllocatePages (
IN UINTN NumberOfPages,
IN OUT EFI_PHYSICAL_ADDRESS *Memory
)
/*++
Routine Description:
Allocates pages from the memory map.
Arguments:
Type - The type of allocation to perform
MemoryType - The type of memory to turn the allocated pages into
NumberOfPages - The number of pages to allocate
Memory - A pointer to receive the base allocated memory address
Returns:
Status. On success, Memory is filled in with the base address allocated
EFI_INVALID_PARAMETER - Parameters violate checking rules defined in spec.
EFI_NOT_FOUND - Could not allocate pages match the requirement.
EFI_OUT_OF_RESOURCES - No enough pages to allocate.
EFI_SUCCESS - Pages successfully allocated.
--*/
{
EFI_STATUS Status;
UINT64 Start;
@ -1219,33 +1168,24 @@ Done:
/**
Frees previous allocated pages.
@param Memory Base address of memory being freed
@param NumberOfPages The number of pages to free
@retval EFI_NOT_FOUND Could not find the entry that covers the range
@retval EFI_INVALID_PARAMETER Address not aligned
@return EFI_SUCCESS -Pages successfully freed.
**/
EFI_STATUS
EFIAPI
CoreFreePages (
IN EFI_PHYSICAL_ADDRESS Memory,
IN UINTN NumberOfPages
)
/*++
Routine Description:
Frees previous allocated pages.
Arguments:
Memory - Base address of memory being freed
NumberOfPages - The number of pages to free
Returns:
EFI_NOT_FOUND - Could not find the entry that covers the range
EFI_INVALID_PARAMETER - Address not aligned
EFI_SUCCESS -Pages successfully freed.
--*/
{
EFI_STATUS Status;
LIST_ENTRY *Link;
@ -1311,6 +1251,37 @@ Returns:
/**
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.
@param MemoryMapSize A pointer to the size, in bytes, of the
MemoryMap buffer. On input, this is the size of
the buffer allocated by the caller. On output,
it is the size of the buffer returned by the
firmware if the buffer was large enough, or the
size of the buffer needed to contain the map if
the buffer was too small.
@param MemoryMap A pointer to the buffer in which firmware places
the current memory map.
@param MapKey A pointer to the location in which firmware
returns the key for the current memory map.
@param DescriptorSize A pointer to the location in which firmware
returns the size, in bytes, of an individual
EFI_MEMORY_DESCRIPTOR.
@param DescriptorVersion A pointer to the location in which firmware
returns the version number associated with the
EFI_MEMORY_DESCRIPTOR.
@retval EFI_SUCCESS The memory map was returned in the MemoryMap
buffer.
@retval EFI_BUFFER_TOO_SMALL The MemoryMap buffer was too small. The current
buffer size needed to hold the memory map is
returned in MemoryMapSize.
@retval EFI_INVALID_PARAMETER One of the parameters has an invalid value.
**/
EFI_STATUS
EFIAPI
CoreGetMemoryMap (
@ -1320,36 +1291,6 @@ CoreGetMemoryMap (
OUT UINTN *DescriptorSize,
OUT UINT32 *DescriptorVersion
)
/*++
Routine Description:
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.
Arguments:
MemoryMapSize - A pointer to the size, in bytes, of the MemoryMap buffer. On
input, this is the size of the buffer allocated by the caller.
On output, it is the size of the buffer returned by the firmware
if the buffer was large enough, or the size of the buffer needed
to contain the map if the buffer was too small.
MemoryMap - A pointer to the buffer in which firmware places the current memory map.
MapKey - A pointer to the location in which firmware returns the key for the
current memory map.
DescriptorSize - A pointer to the location in which firmware returns the size, in
bytes, of an individual EFI_MEMORY_DESCRIPTOR.
DescriptorVersion - A pointer to the location in which firmware returns the version
number associated with the EFI_MEMORY_DESCRIPTOR.
Returns:
EFI_SUCCESS - The memory map was returned in the MemoryMap buffer.
EFI_BUFFER_TOO_SMALL - The MemoryMap buffer was too small. The current buffer size
needed to hold the memory map is returned in MemoryMapSize.
EFI_INVALID_PARAMETER - One of the parameters has an invalid value.
--*/
{
EFI_STATUS Status;
UINTN Size;
@ -1506,32 +1447,24 @@ Done:
return Status;
}
/**
Internal function. Used by the pool functions to allocate pages
to back pool allocation requests.
@param PoolType The type of memory for the new pool pages
@param NumberOfPages No of pages to allocate
@param Alignment Bits to align.
@return The allocated memory, or NULL
**/
VOID *
CoreAllocatePoolPages (
IN EFI_MEMORY_TYPE PoolType,
IN UINTN NumberOfPages,
IN UINTN Alignment
)
/*++
Routine Description:
Internal function. Used by the pool functions to allocate pages
to back pool allocation requests.
Arguments:
PoolType - The type of memory for the new pool pages
NumberOfPages - No of pages to allocate
Alignment - Bits to align.
Returns:
The allocated memory, or NULL
--*/
{
UINT64 Start;
@ -1544,7 +1477,7 @@ Returns:
// Convert it to boot services data
//
if (Start == 0) {
DEBUG ((EFI_D_ERROR | EFI_D_PAGE, "AllocatePoolPages: failed to allocate %d pages\n", NumberOfPages));
DEBUG ((DEBUG_ERROR | DEBUG_PAGE, "AllocatePoolPages: failed to allocate %d pages\n", NumberOfPages));
} else {
CoreConvertPages (Start, NumberOfPages, PoolType);
}
@ -1552,55 +1485,40 @@ Returns:
return (VOID *)(UINTN)Start;
}
/**
Internal function. Frees pool pages allocated via AllocatePoolPages ()
@param Memory The base address to free
@param NumberOfPages The number of pages to free
**/
VOID
CoreFreePoolPages (
IN EFI_PHYSICAL_ADDRESS Memory,
IN UINTN NumberOfPages
)
/*++
Routine Description:
Internal function. Frees pool pages allocated via AllocatePoolPages ()
Arguments:
Memory - The base address to free
NumberOfPages - The number of pages to free
Returns:
None
--*/
{
CoreConvertPages (Memory, NumberOfPages, EfiConventionalMemory);
}
/**
Make sure the memory map is following all the construction rules,
it is the last time to check memory map error before exit boot services.
@param MapKey Memory map key
@retval EFI_INVALID_PARAMETER Memory map not consistent with construction
rules.
@retval EFI_SUCCESS Valid memory map.
**/
EFI_STATUS
CoreTerminateMemoryMap (
IN UINTN MapKey
)
/*++
Routine Description:
Make sure the memory map is following all the construction rules,
it is the last time to check memory map error before exit boot services.
Arguments:
MapKey - Memory map key
Returns:
EFI_INVALID_PARAMETER - Memory map not consistent with construction rules.
EFI_SUCCESS - Valid memory map.
--*/
{
EFI_STATUS Status;
LIST_ENTRY *Link;
@ -1622,17 +1540,17 @@ Returns:
Entry = CR(Link, MEMORY_MAP, Link, MEMORY_MAP_SIGNATURE);
if (Entry->Attribute & EFI_MEMORY_RUNTIME) {
if (Entry->Type == EfiACPIReclaimMemory || Entry->Type == EfiACPIMemoryNVS) {
DEBUG((EFI_D_ERROR, "ExitBootServices: ACPI memory entry has RUNTIME attribute set.\n"));
DEBUG((DEBUG_ERROR, "ExitBootServices: ACPI memory entry has RUNTIME attribute set.\n"));
CoreReleaseMemoryLock ();
return EFI_INVALID_PARAMETER;
}
if (Entry->Start & (EFI_ACPI_RUNTIME_PAGE_ALLOCATION_ALIGNMENT - 1)) {
DEBUG((EFI_D_ERROR, "ExitBootServices: A RUNTIME memory entry is not on a proper alignment.\n"));
DEBUG((DEBUG_ERROR, "ExitBootServices: A RUNTIME memory entry is not on a proper alignment.\n"));
CoreReleaseMemoryLock ();
return EFI_INVALID_PARAMETER;
}
if ((Entry->End + 1) & (EFI_ACPI_RUNTIME_PAGE_ALLOCATION_ALIGNMENT - 1)) {
DEBUG((EFI_D_ERROR, "ExitBootServices: A RUNTIME memory entry is not on a proper alignment.\n"));
DEBUG((DEBUG_ERROR, "ExitBootServices: A RUNTIME memory entry is not on a proper alignment.\n"));
CoreReleaseMemoryLock ();
return EFI_INVALID_PARAMETER;
}
@ -1662,3 +1580,4 @@ Returns:

View File

@ -77,25 +77,15 @@ LIST_ENTRY PoolHeadList;
//
//
/**
Called to initialize the pool.
**/
VOID
CoreInitializePool (
VOID
)
/*++
Routine Description:
Called to initialize the pool.
Arguments:
None
Returns:
None
--*/
{
UINTN Type;
UINTN Index;
@ -111,26 +101,20 @@ Returns:
InitializeListHead (&PoolHeadList);
}
/**
Look up pool head for specified memory type.
@param MemoryType Memory type of which pool head is looked for
@return Pointer of Corresponding pool head.
**/
STATIC
POOL *
LookupPoolHead (
IN EFI_MEMORY_TYPE MemoryType
)
/*++
Routine Description:
Look up pool head for specified memory type.
Arguments:
MemoryType - Memory type of which pool head is looked for
Returns:
Pointer of Corresponding pool head.
--*/
{
LIST_ENTRY *Link;
POOL *Pool;
@ -171,6 +155,20 @@ Returns:
/**
Allocate pool of a particular type.
@param PoolType Type of pool to allocate
@param Size The amount of pool to allocate
@param Buffer The address to return a pointer to the allocated
pool
@retval EFI_INVALID_PARAMETER PoolType not valid
@retval EFI_OUT_OF_RESOURCES Size exceeds max pool size or allocation failed.
@retval EFI_SUCCESS Pool successfully allocated.
**/
EFI_STATUS
EFIAPI
CoreAllocatePool (
@ -178,29 +176,6 @@ CoreAllocatePool (
IN UINTN Size,
OUT VOID **Buffer
)
/*++
Routine Description:
Allocate pool of a particular type.
Arguments:
PoolType - Type of pool to allocate
Size - The amount of pool to allocate
Buffer - The address to return a pointer to the allocated pool
Returns:
EFI_INVALID_PARAMETER - PoolType not valid
EFI_OUT_OF_RESOURCES - Size exceeds max pool size or allocation failed.
EFI_SUCCESS - Pool successfully allocated.
--*/
{
EFI_STATUS Status;
@ -236,31 +211,22 @@ Returns:
}
/**
Internal function to allocate pool of a particular type.
Caller must have the memory lock held
@param PoolType Type of pool to allocate
@param Size The amount of pool to allocate
@return The allocate pool, or NULL
**/
VOID *
CoreAllocatePoolI (
IN EFI_MEMORY_TYPE PoolType,
IN UINTN Size
)
/*++
Routine Description:
Internal function to allocate pool of a particular type.
Caller must have the memory lock held
Arguments:
PoolType - Type of pool to allocate
Size - The amount of pool to allocate
Returns:
The allocate pool, or NULL
--*/
{
POOL *Pool;
POOL_FREE *Free;
@ -270,7 +236,7 @@ Returns:
VOID *Buffer;
UINTN Index;
UINTN FSize;
UINTN offset;
UINTN Offset;
UINTN Adjustment;
UINTN NoPages;
@ -322,23 +288,23 @@ Returns:
//
// Carve up new page into free pool blocks
//
offset = 0;
while (offset < DEFAULT_PAGE_ALLOCATION) {
Offset = 0;
while (Offset < DEFAULT_PAGE_ALLOCATION) {
ASSERT (Index < MAX_POOL_LIST);
FSize = LIST_TO_SIZE(Index);
while (offset + FSize <= DEFAULT_PAGE_ALLOCATION) {
Free = (POOL_FREE *) &NewPage[offset];
while (Offset + FSize <= DEFAULT_PAGE_ALLOCATION) {
Free = (POOL_FREE *) &NewPage[Offset];
Free->Signature = POOL_FREE_SIGNATURE;
Free->Index = (UINT32)Index;
InsertHeadList (&Pool->FreeList[Index], &Free->Link);
offset += FSize;
Offset += FSize;
}
Index -= 1;
}
ASSERT (offset == DEFAULT_PAGE_ALLOCATION);
ASSERT (Offset == DEFAULT_PAGE_ALLOCATION);
Index = SIZE_TO_LIST(Size);
}
@ -368,7 +334,7 @@ Done:
DEBUG_CLEAR_MEMORY (Buffer, Size - POOL_OVERHEAD);
DEBUG (
(EFI_D_POOL,
(DEBUG_POOL,
"AllocatePoolI: Type %x, Addr %x (len %x) %,d\n",
PoolType,
Buffer,
@ -382,7 +348,7 @@ Done:
Pool->Used += Size;
} else {
DEBUG ((EFI_D_ERROR | EFI_D_POOL, "AllocatePool: failed to allocate %d bytes\n", Size));
DEBUG ((DEBUG_ERROR | DEBUG_POOL, "AllocatePool: failed to allocate %d bytes\n", Size));
}
return Buffer;
@ -390,28 +356,21 @@ Done:
/**
Frees pool.
@param Buffer The allocated pool entry to free
@retval EFI_INVALID_PARAMETER Buffer is not a valid value.
@retval EFI_SUCCESS Pool successfully freed.
**/
EFI_STATUS
EFIAPI
CoreFreePool (
IN VOID *Buffer
)
/*++
Routine Description:
Frees pool.
Arguments:
Buffer - The allocated pool entry to free
Returns:
EFI_INVALID_PARAMETER - Buffer is not a valid value.
EFI_SUCCESS - Pool successfully freed.
--*/
{
EFI_STATUS Status;
@ -426,30 +385,21 @@ Returns:
}
/**
Internal function to free a pool entry.
Caller must have the memory lock held
@param Buffer The allocated pool entry to free
@retval EFI_INVALID_PARAMETER Buffer not valid
@retval EFI_SUCCESS Buffer successfully freed.
**/
EFI_STATUS
CoreFreePoolI (
IN VOID *Buffer
)
/*++
Routine Description:
Internal function to free a pool entry.
Caller must have the memory lock held
Arguments:
Buffer - The allocated pool entry to free
Returns:
EFI_INVALID_PARAMETER - Buffer not valid
EFI_SUCCESS - Buffer successfully freed.
--*/
{
POOL *Pool;
POOL_HEAD *Head;
@ -460,7 +410,7 @@ Returns:
UINTN Size;
CHAR8 *NewPage;
UINTN FSize;
UINTN offset;
UINTN Offset;
BOOLEAN AllFree;
ASSERT(NULL != Buffer);
@ -501,7 +451,7 @@ Returns:
return EFI_INVALID_PARAMETER;
}
Pool->Used -= Size;
DEBUG ((EFI_D_POOL, "FreePool: %x (len %x) %,d\n", Head->Data, Head->Size - POOL_OVERHEAD, Pool->Used));
DEBUG ((DEBUG_POOL, "FreePool: %x (len %x) %,d\n", Head->Data, Head->Size - POOL_OVERHEAD, Pool->Used));
//
// Determine the pool list
@ -545,17 +495,17 @@ Returns:
Index = Free->Index;
AllFree = TRUE;
offset = 0;
Offset = 0;
while ((offset < DEFAULT_PAGE_ALLOCATION) && (AllFree)) {
while ((Offset < DEFAULT_PAGE_ALLOCATION) && (AllFree)) {
FSize = LIST_TO_SIZE(Index);
while (offset + FSize <= DEFAULT_PAGE_ALLOCATION) {
Free = (POOL_FREE *) &NewPage[offset];
while (Offset + FSize <= DEFAULT_PAGE_ALLOCATION) {
Free = (POOL_FREE *) &NewPage[Offset];
ASSERT(NULL != Free);
if (Free->Signature != POOL_FREE_SIGNATURE) {
AllFree = FALSE;
}
offset += FSize;
Offset += FSize;
}
Index -= 1;
}
@ -570,15 +520,15 @@ Returns:
Free = (POOL_FREE *) &NewPage[0];
ASSERT(NULL != Free);
Index = Free->Index;
offset = 0;
Offset = 0;
while (offset < DEFAULT_PAGE_ALLOCATION) {
while (Offset < DEFAULT_PAGE_ALLOCATION) {
FSize = LIST_TO_SIZE(Index);
while (offset + FSize <= DEFAULT_PAGE_ALLOCATION) {
Free = (POOL_FREE *) &NewPage[offset];
while (Offset + FSize <= DEFAULT_PAGE_ALLOCATION) {
Free = (POOL_FREE *) &NewPage[Offset];
ASSERT(NULL != Free);
RemoveEntryList (&Free->Link);
offset += FSize;
Offset += FSize;
}
Index -= 1;
}

View File

@ -26,30 +26,22 @@ static EFI_DEBUG_IMAGE_INFO_TABLE_HEADER mDebugInfoTableHeader = {
static EFI_SYSTEM_TABLE_POINTER *mDebugTable = NULL;
/**
Creates and initializes the DebugImageInfo Table. Also creates the configuration
table and registers it into the system table.
Note:
This function allocates memory, frees it, and then allocates memory at an
address within the initial allocation. Since this function is called early
in DXE core initialization (before drivers are dispatched), this should not
be a problem.
**/
VOID
CoreInitializeDebugImageInfoTable (
VOID
)
/*++
Routine Description:
Creates and initializes the DebugImageInfo Table. Also creates the configuration
table and registers it into the system table.
Arguments:
None
Returns:
NA
Notes:
This function allocates memory, frees it, and then allocates memory at an
address within the initial allocation. Since this function is called early
in DXE core initialization (before drivers are dispatched), this should not
be a problem.
--*/
{
EFI_STATUS Status;
EFI_PHYSICAL_ADDRESS Mem;
@ -97,56 +89,42 @@ Notes:
ASSERT_EFI_ERROR (Status);
}
VOID
CoreUpdateDebugTableCrc32 (
VOID
)
/*++
Routine Description:
/**
Update the CRC32 in the Debug Table.
Since the CRC32 service is made available by the Runtime driver, we have to
wait for the Runtime Driver to be installed before the CRC32 can be computed.
This function is called elsewhere by the core when the runtime architectural
protocol is produced.
Arguments:
None
Returns:
NA
--*/
**/
VOID
CoreUpdateDebugTableCrc32 (
VOID
)
{
ASSERT(mDebugTable != NULL);
mDebugTable->Crc32 = 0;
gDxeCoreBS->CalculateCrc32 ((VOID *)mDebugTable, sizeof (EFI_SYSTEM_TABLE_POINTER), &mDebugTable->Crc32);
}
/**
Adds a new DebugImageInfo structure to the DebugImageInfo Table. Re-Allocates
the table if it's not large enough to accomidate another entry.
@param ImageInfoType type of debug image information
@param LoadedImage pointer to the loaded image protocol for the image being
loaded
@param ImageHandle image handle for the image being loaded
**/
VOID
CoreNewDebugImageInfoEntry (
IN UINT32 ImageInfoType,
IN EFI_LOADED_IMAGE_PROTOCOL *LoadedImage,
IN EFI_HANDLE ImageHandle
)
/*++
Routine Description:
Adds a new DebugImageInfo structure to the DebugImageInfo Table. Re-Allocates
the table if it's not large enough to accomidate another entry.
Arguments:
ImageInfoType - type of debug image information
LoadedImage - pointer to the loaded image protocol for the image being loaded
ImageHandle - image handle for the image being loaded
Returns:
NA
--*/
{
EFI_DEBUG_IMAGE_INFO *Table;
EFI_DEBUG_IMAGE_INFO *NewTable;
@ -211,25 +189,17 @@ Returns:
}
/**
Removes and frees an entry from the DebugImageInfo Table.
@param ImageHandle image handle for the image being unloaded
**/
VOID
CoreRemoveDebugImageInfoEntry (
EFI_HANDLE ImageHandle
)
/*++
Routine Description:
Removes and frees an entry from the DebugImageInfo Table.
Arguments:
ImageHandle - image handle for the image being unloaded
Returns:
NA
--*/
{
EFI_DEBUG_IMAGE_INFO *Table;
UINTN Index;
@ -252,3 +222,4 @@ Returns:
mDebugInfoTableHeader.UpdateStatus &= ~EFI_DEBUG_IMAGE_INFO_UPDATE_IN_PROGRESS;
}

View File

@ -20,30 +20,23 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
UINTN mSystemTableAllocateSize = 0;
/**
Find a config table by name in system table's ConfigurationTable.
@param Guid The table name to look for
@param Table Pointer of the config table
@retval EFI_NOT_FOUND Could not find the table in system table's
ConfigurationTable.
@retval EFI_SUCCESS Table successfully found.
**/
EFI_STATUS
CoreGetConfigTable (
IN EFI_GUID *Guid,
OUT VOID **Table
)
/*++
Routine Description:
Find a config table by name in system table's ConfigurationTable.
Arguments:
Guid - The table name to look for
Table - Pointer of the config table
Returns:
EFI_NOT_FOUND - Could not find the table in system table's ConfigurationTable.
EFI_SUCCESS - Table successfully found.
--*/
{
UINTN Index;
@ -59,33 +52,28 @@ Returns:
/**
Boot Service called to add, modify, or remove a system configuration table from
the EFI System Table.
@param Guid Pointer to the GUID for the entry to add, update, or
remove
@param Table Pointer to the configuration table for the entry to add,
update, or remove, may be NULL.
@return EFI_SUCCESS Guid, Table pair added, updated, or removed.
@return EFI_INVALID_PARAMETER Input GUID not valid.
@return EFI_NOT_FOUND Attempted to delete non-existant entry
@return EFI_OUT_OF_RESOURCES Not enough memory available
**/
EFI_STATUS
EFIAPI
CoreInstallConfigurationTable (
IN EFI_GUID *Guid,
IN VOID *Table
)
/*++
Routine Description:
Boot Service called to add, modify, or remove a system configuration table from
the EFI System Table.
Arguments:
Guid - Pointer to the GUID for the entry to add, update, or remove
Table - Pointer to the configuration table for the entry to add, update, or
remove, may be NULL.
Returns:
EFI_SUCCESS Guid, Table pair added, updated, or removed.
EFI_INVALID_PARAMETER Input GUID not valid.
EFI_NOT_FOUND Attempted to delete non-existant entry
EFI_OUT_OF_RESOURCES Not enough memory available
--*/
{
UINTN Index;
EFI_CONFIGURATION_TABLE *EfiConfigurationTable;

View File

@ -17,7 +17,28 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#define WATCHDOG_TIMER_CALIBRATE_PER_SECOND 10000000
/**
Sets the system's watchdog timer.
@param Timeout The number of seconds to set the watchdog timer to.
A value of zero disables the timer.
@param WatchdogCode The numeric code to log on a watchdog timer timeout
event. The firmware reserves codes 0x0000 to 0xFFFF.
Loaders and operating systems may use other timeout
codes.
@param DataSize The size, in bytes, of WatchdogData.
@param WatchdogData A data buffer that includes a Null-terminated Unicode
string, optionally followed by additional binary data.
The string is a description that the call may use to
further indicate the reason to be logged with a
watchdog event.
@return EFI_SUCCESS Timeout has been set
@return EFI_NOT_AVAILABLE_YET WatchdogTimer is not available yet
@return EFI_UNSUPPORTED System does not have a timer (currently not used)
@return EFI_DEVICE_ERROR Could not complete due to hardware error
**/
EFI_STATUS
EFIAPI
CoreSetWatchdogTimer (
@ -26,31 +47,6 @@ CoreSetWatchdogTimer (
IN UINTN DataSize,
IN CHAR16 *WatchdogData OPTIONAL
)
/*++
Routine Description:
Sets the system's watchdog timer.
Arguments:
Timeout The number of seconds. Zero disables the timer.
///////following three parameters are left for platform specific using
WatchdogCode The numberic code to log. 0x0 to 0xffff are firmware
DataSize Size of the optional data
WatchdogData Optional Null terminated unicode string followed by binary
data.
Returns:
EFI_SUCCESS Timeout has been set
EFI_NOT_AVAILABLE_YET WatchdogTimer is not available yet
EFI_UNSUPPORTED System does not have a timer (currently not used)
EFI_DEVICE_ERROR Could not complete due to hardware error
--*/
{
EFI_STATUS Status;

View File

@ -20,29 +20,22 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include <DxeMain.h>
/**
Introduces a fine-grained stall.
@param Microseconds The number of microseconds to stall execution.
@retval EFI_SUCCESS Execution was stalled for at least the requested
amount of microseconds.
@retval EFI_NOT_AVAILABLE_YET gMetronome is not available yet
**/
EFI_STATUS
EFIAPI
CoreStall (
IN UINTN Microseconds
)
/*++
Routine Description:
Introduces a fine-grained stall.
Arguments:
Microseconds The number of microseconds to stall execution
Returns:
EFI_SUCCESS - Execution was stalled for at least the requested amount
of microseconds.
EFI_NOT_AVAILABLE_YET - gMetronome is not available yet
--*/
{
UINT32 Counter;
UINT32 Remainder;

View File

@ -14,8 +14,8 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#ifndef _GCD_H
#define _GCD_H
#ifndef _GCD_H_
#define _GCD_H_
//
// GCD Operations

View File

@ -100,220 +100,151 @@ typedef struct {
//
/**
Finds the protocol entry for the requested protocol.
The gProtocolDatabaseLock must be owned
@param Protocol The ID of the protocol
@param Create Create a new entry if not found
@return Protocol entry
**/
PROTOCOL_ENTRY *
CoreFindProtocolEntry (
IN EFI_GUID *Protocol,
IN BOOLEAN Create
)
/*++
Routine Description:
Finds the protocol entry for the requested protocol.
The gProtocolDatabaseLock must be owned
Arguments:
Protocol - The ID of the protocol
Create - Create a new entry if not found
Returns:
Protocol entry
--*/
;
/**
Signal event for every protocol in protocol entry.
@param ProtEntry Protocol entry
**/
VOID
CoreNotifyProtocolEntry (
IN PROTOCOL_ENTRY *ProtEntry
)
/*++
Routine Description:
Signal event for every protocol in protocol entry.
Arguments:
ProtEntry - Protocol entry
Returns:
--*/
;
/**
Finds the protocol instance for the requested handle and protocol.
Note: This function doesn't do parameters checking, it's caller's responsibility
to pass in valid parameters.
@param Handle The handle to search the protocol on
@param Protocol GUID of the protocol
@param Interface The interface for the protocol being searched
@return Protocol instance (NULL: Not found)
**/
PROTOCOL_INTERFACE *
CoreFindProtocolInterface (
IN IHANDLE *Handle,
IN EFI_GUID *Protocol,
IN VOID *Interface
)
/*++
Routine Description:
Finds the protocol instance for the requested handle and protocol.
Note: This function doesn't do parameters checking, it's caller's responsibility
to pass in valid parameters.
Arguments:
Handle - The handle to search the protocol on
Protocol - GUID of the protocol
Interface - The interface for the protocol being searched
Returns:
Protocol instance (NULL: Not found)
--*/
;
/**
Removes Protocol from the protocol list (but not the handle list).
@param Handle The handle to remove protocol on.
@param Protocol GUID of the protocol to be moved
@param Interface The interface of the protocol
@return Protocol Entry
**/
PROTOCOL_INTERFACE *
CoreRemoveInterfaceFromProtocol (
IN IHANDLE *Handle,
IN EFI_GUID *Protocol,
IN VOID *Interface
)
/*++
Routine Description:
Removes Protocol from the protocol list (but not the handle list).
Arguments:
Handle - The handle to remove protocol on.
Protocol - GUID of the protocol to be moved
Interface - The interface of the protocol
Returns:
Protocol Entry
--*/
;
/**
Removes all the events in the protocol database that match Event.
@param Event The event to search for in the protocol
database.
@return EFI_SUCCESS when done searching the entire database.
**/
EFI_STATUS
CoreUnregisterProtocolNotify (
IN EFI_EVENT Event
)
/*++
Routine Description:
Removes all the events in the protocol database that match Event.
Arguments:
Event - The event to search for in the protocol database.
Returns:
EFI_SUCCESS when done searching the entire database.
--*/
;
/**
Attempts to disconnect all drivers that are using the protocol interface being queried.
If failed, reconnect all drivers disconnected.
Note: This function doesn't do parameters checking, it's caller's responsibility
to pass in valid parameters.
@param UserHandle The handle on which the protocol is installed
@param Prot The protocol to disconnect drivers from
@retval EFI_SUCCESS Drivers using the protocol interface are all
disconnected
@retval EFI_ACCESS_DENIED Failed to disconnect one or all of the drivers
**/
EFI_STATUS
CoreDisconnectControllersUsingProtocolInterface (
IN EFI_HANDLE UserHandle,
IN PROTOCOL_INTERFACE *Prot
)
/*++
Routine Description:
Attempts to disconnect all drivers that are using the protocol interface being queried.
If failed, reconnect all drivers disconnected.
Note: This function doesn't do parameters checking, it's caller's responsibility
to pass in valid parameters.
Arguments:
UserHandle - The handle on which the protocol is installed
Prot - The protocol to disconnect drivers from
Returns:
EFI_SUCCESS - Drivers using the protocol interface are all disconnected
EFI_ACCESS_DENIED - Failed to disconnect one or all of the drivers
--*/
;
/**
Acquire lock on gProtocolDatabaseLock.
**/
VOID
CoreAcquireProtocolLock (
VOID
)
/*++
Routine Description:
Acquire lock on gProtocolDatabaseLock.
Arguments:
None
Returns:
None
--*/
;
/**
Release lock on gProtocolDatabaseLock.
**/
VOID
CoreReleaseProtocolLock (
VOID
)
/*++
Routine Description:
Release lock on gProtocolDatabaseLock.
Arguments:
None
Returns:
None
--*/
;
/**
Check whether a handle is a valid EFI_HANDLE
@param UserHandle The handle to check
@retval EFI_INVALID_PARAMETER The handle is NULL or not a valid EFI_HANDLE.
@retval EFI_SUCCESS The handle is valid EFI_HANDLE.
**/
EFI_STATUS
CoreValidateHandle (
IN EFI_HANDLE UserHandle
)
/*++
Routine Description:
Check whether a handle is a valid EFI_HANDLE
Arguments:
UserHandle - The handle to check
Returns:
EFI_INVALID_PARAMETER - The handle is NULL or not a valid EFI_HANDLE.
EFI_SUCCESS - The handle is valid EFI_HANDLE.
--*/
;
//

View File

@ -11,7 +11,8 @@ http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
--*/
**/
#ifndef _IMEM_H_
#define _IMEM_H_
@ -55,155 +56,100 @@ typedef struct {
// Internal prototypes
//
/**
Internal function. Used by the pool functions to allocate pages
to back pool allocation requests.
@param PoolType The type of memory for the new pool pages
@param NumberOfPages No of pages to allocate
@param Alignment Bits to align.
@return The allocated memory, or NULL
**/
VOID *
CoreAllocatePoolPages (
IN EFI_MEMORY_TYPE PoolType,
IN UINTN NumberOfPages,
IN UINTN Alignment
)
/*++
Routine Description:
Internal function. Used by the pool functions to allocate pages
to back pool allocation requests.
Arguments:
PoolType - The type of memory for the new pool pages
NumberOfPages - No of pages to allocate
Alignment - Bits to align.
Returns:
The allocated memory, or NULL
--*/
;
/**
Internal function. Frees pool pages allocated via AllocatePoolPages ()
@param Memory The base address to free
@param NumberOfPages The number of pages to free
**/
VOID
CoreFreePoolPages (
IN EFI_PHYSICAL_ADDRESS Memory,
IN UINTN NumberOfPages
)
/*++
Routine Description:
Internal function. Frees pool pages allocated via AllocatePoolPages ()
Arguments:
Memory - The base address to free
NumberOfPages - The number of pages to free
Returns:
None
--*/
;
/**
Internal function to allocate pool of a particular type.
Caller must have the memory lock held
@param PoolType Type of pool to allocate
@param Size The amount of pool to allocate
@return The allocate pool, or NULL
**/
VOID *
CoreAllocatePoolI (
IN EFI_MEMORY_TYPE PoolType,
IN UINTN Size
)
/*++
Routine Description:
Internal function to allocate pool of a particular type.
Caller must have the memory lock held
Arguments:
PoolType - Type of pool to allocate
Size - The amount of pool to allocate
Returns:
The allocate pool, or NULL
--*/
;
/**
Internal function to free a pool entry.
Caller must have the memory lock held
@param Buffer The allocated pool entry to free
@retval EFI_INVALID_PARAMETER Buffer not valid
@retval EFI_SUCCESS Buffer successfully freed.
**/
EFI_STATUS
CoreFreePoolI (
IN VOID *Buffer
)
/*++
Routine Description:
Internal function to free a pool entry.
Caller must have the memory lock held
Arguments:
Buffer - The allocated pool entry to free
Returns:
EFI_INVALID_PARAMETER - Buffer not valid
EFI_SUCCESS - Buffer successfully freed.
--*/
;
/**
Enter critical section by gaining lock on gMemoryLock.
**/
VOID
CoreAcquireMemoryLock (
VOID
)
/*++
Routine Description:
Enter critical section by gaining lock on gMemoryLock
Arguments:
None
Returns:
None
--*/
;
/**
Exit critical section by releasing lock on gMemoryLock.
**/
VOID
CoreReleaseMemoryLock (
VOID
)
/*++
Routine Description:
Exit critical section by releasing lock on gMemoryLock
Arguments:
None
Returns:
None
--*/
;