MdeModulePkg: Apply uncrustify changes
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3737 Apply uncrustify changes to .c/.h files in the MdeModulePkg package Cc: Andrew Fish <afish@apple.com> Cc: Leif Lindholm <leif@nuviainc.com> Cc: Michael D Kinney <michael.d.kinney@intel.com> Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com> Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
This commit is contained in:
committed by
mergify[bot]
parent
7c7184e201
commit
1436aea4d5
@@ -46,8 +46,8 @@ GrowDepexStack (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
BOOLEAN *NewStack;
|
||||
UINTN Size;
|
||||
BOOLEAN *NewStack;
|
||||
UINTN Size;
|
||||
|
||||
Size = DEPEX_STACK_SIZE_INCREMENT;
|
||||
if (mDepexEvaluationStack != NULL) {
|
||||
@@ -166,7 +166,7 @@ PopBool (
|
||||
**/
|
||||
BOOLEAN
|
||||
SmmIsSchedulable (
|
||||
IN EFI_SMM_DRIVER_ENTRY *DriverEntry
|
||||
IN EFI_SMM_DRIVER_ENTRY *DriverEntry
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
@@ -176,7 +176,7 @@ SmmIsSchedulable (
|
||||
EFI_GUID DriverGuid;
|
||||
VOID *Interface;
|
||||
|
||||
Operator = FALSE;
|
||||
Operator = FALSE;
|
||||
Operator2 = FALSE;
|
||||
|
||||
if (DriverEntry->After || DriverEntry->Before) {
|
||||
@@ -205,7 +205,6 @@ SmmIsSchedulable (
|
||||
//
|
||||
mDepexEvaluationStackPointer = mDepexEvaluationStack;
|
||||
|
||||
|
||||
Iterator = DriverEntry->Depex;
|
||||
|
||||
while (TRUE) {
|
||||
@@ -222,148 +221,155 @@ SmmIsSchedulable (
|
||||
// Look at the opcode of the dependency expression instruction.
|
||||
//
|
||||
switch (*Iterator) {
|
||||
case EFI_DEP_BEFORE:
|
||||
case EFI_DEP_AFTER:
|
||||
//
|
||||
// For a well-formed Dependency Expression, the code should never get here.
|
||||
// The BEFORE and AFTER are processed prior to this routine's invocation.
|
||||
// If the code flow arrives at this point, there was a BEFORE or AFTER
|
||||
// that were not the first opcodes.
|
||||
//
|
||||
DEBUG ((DEBUG_DISPATCH, " RESULT = FALSE (Unexpected BEFORE or AFTER opcode)\n"));
|
||||
ASSERT (FALSE);
|
||||
|
||||
case EFI_DEP_PUSH:
|
||||
//
|
||||
// Push operator is followed by a GUID. Test to see if the GUID protocol
|
||||
// is installed and push the boolean result on the stack.
|
||||
//
|
||||
CopyMem (&DriverGuid, Iterator + 1, sizeof (EFI_GUID));
|
||||
|
||||
Status = SmmLocateProtocol (&DriverGuid, NULL, &Interface);
|
||||
if (EFI_ERROR (Status)) {
|
||||
case EFI_DEP_BEFORE:
|
||||
case EFI_DEP_AFTER:
|
||||
//
|
||||
// For SMM Driver, it may depend on uefi protocols
|
||||
// For a well-formed Dependency Expression, the code should never get here.
|
||||
// The BEFORE and AFTER are processed prior to this routine's invocation.
|
||||
// If the code flow arrives at this point, there was a BEFORE or AFTER
|
||||
// that were not the first opcodes.
|
||||
//
|
||||
Status = gBS->LocateProtocol (&DriverGuid, NULL, &Interface);
|
||||
}
|
||||
DEBUG ((DEBUG_DISPATCH, " RESULT = FALSE (Unexpected BEFORE or AFTER opcode)\n"));
|
||||
ASSERT (FALSE);
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG ((DEBUG_DISPATCH, " PUSH GUID(%g) = FALSE\n", &DriverGuid));
|
||||
Status = PushBool (FALSE);
|
||||
} else {
|
||||
DEBUG ((DEBUG_DISPATCH, " PUSH GUID(%g) = TRUE\n", &DriverGuid));
|
||||
*Iterator = EFI_DEP_REPLACE_TRUE;
|
||||
case EFI_DEP_PUSH:
|
||||
//
|
||||
// Push operator is followed by a GUID. Test to see if the GUID protocol
|
||||
// is installed and push the boolean result on the stack.
|
||||
//
|
||||
CopyMem (&DriverGuid, Iterator + 1, sizeof (EFI_GUID));
|
||||
|
||||
Status = SmmLocateProtocol (&DriverGuid, NULL, &Interface);
|
||||
if (EFI_ERROR (Status)) {
|
||||
//
|
||||
// For SMM Driver, it may depend on uefi protocols
|
||||
//
|
||||
Status = gBS->LocateProtocol (&DriverGuid, NULL, &Interface);
|
||||
}
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG ((DEBUG_DISPATCH, " PUSH GUID(%g) = FALSE\n", &DriverGuid));
|
||||
Status = PushBool (FALSE);
|
||||
} else {
|
||||
DEBUG ((DEBUG_DISPATCH, " PUSH GUID(%g) = TRUE\n", &DriverGuid));
|
||||
*Iterator = EFI_DEP_REPLACE_TRUE;
|
||||
Status = PushBool (TRUE);
|
||||
}
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG ((DEBUG_DISPATCH, " RESULT = FALSE (Unexpected error)\n"));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
Iterator += sizeof (EFI_GUID);
|
||||
break;
|
||||
|
||||
case EFI_DEP_AND:
|
||||
DEBUG ((DEBUG_DISPATCH, " AND\n"));
|
||||
Status = PopBool (&Operator);
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG ((DEBUG_DISPATCH, " RESULT = FALSE (Unexpected error)\n"));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
Status = PopBool (&Operator2);
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG ((DEBUG_DISPATCH, " RESULT = FALSE (Unexpected error)\n"));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
Status = PushBool ((BOOLEAN)(Operator && Operator2));
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG ((DEBUG_DISPATCH, " RESULT = FALSE (Unexpected error)\n"));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case EFI_DEP_OR:
|
||||
DEBUG ((DEBUG_DISPATCH, " OR\n"));
|
||||
Status = PopBool (&Operator);
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG ((DEBUG_DISPATCH, " RESULT = FALSE (Unexpected error)\n"));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
Status = PopBool (&Operator2);
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG ((DEBUG_DISPATCH, " RESULT = FALSE (Unexpected error)\n"));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
Status = PushBool ((BOOLEAN)(Operator || Operator2));
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG ((DEBUG_DISPATCH, " RESULT = FALSE (Unexpected error)\n"));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case EFI_DEP_NOT:
|
||||
DEBUG ((DEBUG_DISPATCH, " NOT\n"));
|
||||
Status = PopBool (&Operator);
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG ((DEBUG_DISPATCH, " RESULT = FALSE (Unexpected error)\n"));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
Status = PushBool ((BOOLEAN)(!Operator));
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG ((DEBUG_DISPATCH, " RESULT = FALSE (Unexpected error)\n"));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case EFI_DEP_TRUE:
|
||||
DEBUG ((DEBUG_DISPATCH, " TRUE\n"));
|
||||
Status = PushBool (TRUE);
|
||||
}
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG ((DEBUG_DISPATCH, " RESULT = FALSE (Unexpected error)\n"));
|
||||
return FALSE;
|
||||
}
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG ((DEBUG_DISPATCH, " RESULT = FALSE (Unexpected error)\n"));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
Iterator += sizeof (EFI_GUID);
|
||||
break;
|
||||
break;
|
||||
|
||||
case EFI_DEP_AND:
|
||||
DEBUG ((DEBUG_DISPATCH, " AND\n"));
|
||||
Status = PopBool (&Operator);
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG ((DEBUG_DISPATCH, " RESULT = FALSE (Unexpected error)\n"));
|
||||
return FALSE;
|
||||
}
|
||||
case EFI_DEP_FALSE:
|
||||
DEBUG ((DEBUG_DISPATCH, " FALSE\n"));
|
||||
Status = PushBool (FALSE);
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG ((DEBUG_DISPATCH, " RESULT = FALSE (Unexpected error)\n"));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
Status = PopBool (&Operator2);
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG ((DEBUG_DISPATCH, " RESULT = FALSE (Unexpected error)\n"));
|
||||
return FALSE;
|
||||
}
|
||||
break;
|
||||
|
||||
Status = PushBool ((BOOLEAN)(Operator && Operator2));
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG ((DEBUG_DISPATCH, " RESULT = FALSE (Unexpected error)\n"));
|
||||
return FALSE;
|
||||
}
|
||||
break;
|
||||
case EFI_DEP_END:
|
||||
DEBUG ((DEBUG_DISPATCH, " END\n"));
|
||||
Status = PopBool (&Operator);
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG ((DEBUG_DISPATCH, " RESULT = FALSE (Unexpected error)\n"));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
case EFI_DEP_OR:
|
||||
DEBUG ((DEBUG_DISPATCH, " OR\n"));
|
||||
Status = PopBool (&Operator);
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG ((DEBUG_DISPATCH, " RESULT = FALSE (Unexpected error)\n"));
|
||||
return FALSE;
|
||||
}
|
||||
DEBUG ((DEBUG_DISPATCH, " RESULT = %a\n", Operator ? "TRUE" : "FALSE"));
|
||||
return Operator;
|
||||
|
||||
Status = PopBool (&Operator2);
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG ((DEBUG_DISPATCH, " RESULT = FALSE (Unexpected error)\n"));
|
||||
return FALSE;
|
||||
}
|
||||
case EFI_DEP_REPLACE_TRUE:
|
||||
CopyMem (&DriverGuid, Iterator + 1, sizeof (EFI_GUID));
|
||||
DEBUG ((DEBUG_DISPATCH, " PUSH GUID(%g) = TRUE\n", &DriverGuid));
|
||||
Status = PushBool (TRUE);
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG ((DEBUG_DISPATCH, " RESULT = FALSE (Unexpected error)\n"));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
Status = PushBool ((BOOLEAN)(Operator || Operator2));
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG ((DEBUG_DISPATCH, " RESULT = FALSE (Unexpected error)\n"));
|
||||
return FALSE;
|
||||
}
|
||||
break;
|
||||
Iterator += sizeof (EFI_GUID);
|
||||
break;
|
||||
|
||||
case EFI_DEP_NOT:
|
||||
DEBUG ((DEBUG_DISPATCH, " NOT\n"));
|
||||
Status = PopBool (&Operator);
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG ((DEBUG_DISPATCH, " RESULT = FALSE (Unexpected error)\n"));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
Status = PushBool ((BOOLEAN)(!Operator));
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG ((DEBUG_DISPATCH, " RESULT = FALSE (Unexpected error)\n"));
|
||||
return FALSE;
|
||||
}
|
||||
break;
|
||||
|
||||
case EFI_DEP_TRUE:
|
||||
DEBUG ((DEBUG_DISPATCH, " TRUE\n"));
|
||||
Status = PushBool (TRUE);
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG ((DEBUG_DISPATCH, " RESULT = FALSE (Unexpected error)\n"));
|
||||
return FALSE;
|
||||
}
|
||||
break;
|
||||
|
||||
case EFI_DEP_FALSE:
|
||||
DEBUG ((DEBUG_DISPATCH, " FALSE\n"));
|
||||
Status = PushBool (FALSE);
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG ((DEBUG_DISPATCH, " RESULT = FALSE (Unexpected error)\n"));
|
||||
return FALSE;
|
||||
}
|
||||
break;
|
||||
|
||||
case EFI_DEP_END:
|
||||
DEBUG ((DEBUG_DISPATCH, " END\n"));
|
||||
Status = PopBool (&Operator);
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG ((DEBUG_DISPATCH, " RESULT = FALSE (Unexpected error)\n"));
|
||||
return FALSE;
|
||||
}
|
||||
DEBUG ((DEBUG_DISPATCH, " RESULT = %a\n", Operator ? "TRUE" : "FALSE"));
|
||||
return Operator;
|
||||
|
||||
case EFI_DEP_REPLACE_TRUE:
|
||||
CopyMem (&DriverGuid, Iterator + 1, sizeof (EFI_GUID));
|
||||
DEBUG ((DEBUG_DISPATCH, " PUSH GUID(%g) = TRUE\n", &DriverGuid));
|
||||
Status = PushBool (TRUE);
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG ((DEBUG_DISPATCH, " RESULT = FALSE (Unexpected error)\n"));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
Iterator += sizeof (EFI_GUID);
|
||||
break;
|
||||
|
||||
default:
|
||||
DEBUG ((DEBUG_DISPATCH, " RESULT = FALSE (Unknown opcode)\n"));
|
||||
goto Done;
|
||||
default:
|
||||
DEBUG ((DEBUG_DISPATCH, " RESULT = FALSE (Unknown opcode)\n"));
|
||||
goto Done;
|
||||
}
|
||||
|
||||
//
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -12,8 +12,8 @@
|
||||
// mProtocolDatabase - A list of all protocols in the system. (simple list for now)
|
||||
// gHandleList - A list of all the handles in the system
|
||||
//
|
||||
LIST_ENTRY mProtocolDatabase = INITIALIZE_LIST_HEAD_VARIABLE (mProtocolDatabase);
|
||||
LIST_ENTRY gHandleList = INITIALIZE_LIST_HEAD_VARIABLE (gHandleList);
|
||||
LIST_ENTRY mProtocolDatabase = INITIALIZE_LIST_HEAD_VARIABLE (mProtocolDatabase);
|
||||
LIST_ENTRY gHandleList = INITIALIZE_LIST_HEAD_VARIABLE (gHandleList);
|
||||
|
||||
/**
|
||||
Check whether a handle is a valid EFI_HANDLE
|
||||
@@ -35,9 +35,11 @@ SmmValidateHandle (
|
||||
if (Handle == NULL) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
if (Handle->Signature != EFI_HANDLE_SIGNATURE) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -52,13 +54,13 @@ SmmValidateHandle (
|
||||
**/
|
||||
PROTOCOL_ENTRY *
|
||||
SmmFindProtocolEntry (
|
||||
IN EFI_GUID *Protocol,
|
||||
IN BOOLEAN Create
|
||||
IN EFI_GUID *Protocol,
|
||||
IN BOOLEAN Create
|
||||
)
|
||||
{
|
||||
LIST_ENTRY *Link;
|
||||
PROTOCOL_ENTRY *Item;
|
||||
PROTOCOL_ENTRY *ProtEntry;
|
||||
LIST_ENTRY *Link;
|
||||
PROTOCOL_ENTRY *Item;
|
||||
PROTOCOL_ENTRY *ProtEntry;
|
||||
|
||||
//
|
||||
// Search the database for the matching GUID
|
||||
@@ -67,9 +69,9 @@ SmmFindProtocolEntry (
|
||||
ProtEntry = NULL;
|
||||
for (Link = mProtocolDatabase.ForwardLink;
|
||||
Link != &mProtocolDatabase;
|
||||
Link = Link->ForwardLink) {
|
||||
|
||||
Item = CR(Link, PROTOCOL_ENTRY, AllEntries, PROTOCOL_ENTRY_SIGNATURE);
|
||||
Link = Link->ForwardLink)
|
||||
{
|
||||
Item = CR (Link, PROTOCOL_ENTRY, AllEntries, PROTOCOL_ENTRY_SIGNATURE);
|
||||
if (CompareGuid (&Item->ProtocolID, Protocol)) {
|
||||
//
|
||||
// This is the protocol entry
|
||||
@@ -84,7 +86,7 @@ SmmFindProtocolEntry (
|
||||
// allocate a new entry
|
||||
//
|
||||
if ((ProtEntry == NULL) && Create) {
|
||||
ProtEntry = AllocatePool (sizeof(PROTOCOL_ENTRY));
|
||||
ProtEntry = AllocatePool (sizeof (PROTOCOL_ENTRY));
|
||||
if (ProtEntry != NULL) {
|
||||
//
|
||||
// Initialize new protocol entry structure
|
||||
@@ -100,6 +102,7 @@ SmmFindProtocolEntry (
|
||||
InsertTailList (&mProtocolDatabase, &ProtEntry->AllEntries);
|
||||
}
|
||||
}
|
||||
|
||||
return ProtEntry;
|
||||
}
|
||||
|
||||
@@ -136,17 +139,19 @@ SmmFindProtocolInterface (
|
||||
//
|
||||
// Look at each protocol interface for any matches
|
||||
//
|
||||
for (Link = Handle->Protocols.ForwardLink; Link != &Handle->Protocols; Link=Link->ForwardLink) {
|
||||
for (Link = Handle->Protocols.ForwardLink; Link != &Handle->Protocols; Link = Link->ForwardLink) {
|
||||
//
|
||||
// If this protocol interface matches, remove it
|
||||
//
|
||||
Prot = CR(Link, PROTOCOL_INTERFACE, Link, PROTOCOL_INTERFACE_SIGNATURE);
|
||||
if (Prot->Interface == Interface && Prot->Protocol == ProtEntry) {
|
||||
Prot = CR (Link, PROTOCOL_INTERFACE, Link, PROTOCOL_INTERFACE_SIGNATURE);
|
||||
if ((Prot->Interface == Interface) && (Prot->Protocol == ProtEntry)) {
|
||||
break;
|
||||
}
|
||||
|
||||
Prot = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
return Prot;
|
||||
}
|
||||
|
||||
@@ -218,7 +223,7 @@ SmmInstallProtocolInterfaceNotify (
|
||||
// returns EFI_INVALID_PARAMETER if InterfaceType is invalid.
|
||||
// Also added check for invalid UserHandle and Protocol pointers.
|
||||
//
|
||||
if (UserHandle == NULL || Protocol == NULL) {
|
||||
if ((UserHandle == NULL) || (Protocol == NULL)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@@ -229,10 +234,10 @@ SmmInstallProtocolInterfaceNotify (
|
||||
//
|
||||
// Print debug message
|
||||
//
|
||||
DEBUG((DEBUG_LOAD | DEBUG_INFO, "SmmInstallProtocolInterface: %g %p\n", Protocol, Interface));
|
||||
DEBUG ((DEBUG_LOAD | DEBUG_INFO, "SmmInstallProtocolInterface: %g %p\n", Protocol, Interface));
|
||||
|
||||
Status = EFI_OUT_OF_RESOURCES;
|
||||
Prot = NULL;
|
||||
Prot = NULL;
|
||||
Handle = NULL;
|
||||
|
||||
if (*UserHandle != NULL) {
|
||||
@@ -253,7 +258,7 @@ SmmInstallProtocolInterfaceNotify (
|
||||
//
|
||||
// Allocate a new protocol interface structure
|
||||
//
|
||||
Prot = AllocateZeroPool (sizeof(PROTOCOL_INTERFACE));
|
||||
Prot = AllocateZeroPool (sizeof (PROTOCOL_INTERFACE));
|
||||
if (Prot == NULL) {
|
||||
Status = EFI_OUT_OF_RESOURCES;
|
||||
goto Done;
|
||||
@@ -264,7 +269,7 @@ SmmInstallProtocolInterfaceNotify (
|
||||
//
|
||||
Handle = (IHANDLE *)*UserHandle;
|
||||
if (Handle == NULL) {
|
||||
Handle = AllocateZeroPool (sizeof(IHANDLE));
|
||||
Handle = AllocateZeroPool (sizeof (IHANDLE));
|
||||
if (Handle == NULL) {
|
||||
Status = EFI_OUT_OF_RESOURCES;
|
||||
goto Done;
|
||||
@@ -284,7 +289,7 @@ SmmInstallProtocolInterfaceNotify (
|
||||
} else {
|
||||
Status = SmmValidateHandle (Handle);
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG((DEBUG_ERROR, "SmmInstallProtocolInterface: input handle at 0x%x is invalid\n", Handle));
|
||||
DEBUG ((DEBUG_ERROR, "SmmInstallProtocolInterface: input handle at 0x%x is invalid\n", Handle));
|
||||
goto Done;
|
||||
}
|
||||
}
|
||||
@@ -298,8 +303,8 @@ SmmInstallProtocolInterfaceNotify (
|
||||
// Initialize the protocol interface structure
|
||||
//
|
||||
Prot->Signature = PROTOCOL_INTERFACE_SIGNATURE;
|
||||
Prot->Handle = Handle;
|
||||
Prot->Protocol = ProtEntry;
|
||||
Prot->Handle = Handle;
|
||||
Prot->Protocol = ProtEntry;
|
||||
Prot->Interface = Interface;
|
||||
|
||||
//
|
||||
@@ -320,6 +325,7 @@ SmmInstallProtocolInterfaceNotify (
|
||||
if (Notify) {
|
||||
SmmNotifyProtocol (Prot);
|
||||
}
|
||||
|
||||
Status = EFI_SUCCESS;
|
||||
|
||||
Done:
|
||||
@@ -335,8 +341,10 @@ Done:
|
||||
if (Prot != NULL) {
|
||||
FreePool (Prot);
|
||||
}
|
||||
DEBUG((DEBUG_ERROR, "SmmInstallProtocolInterface: %g %p failed with %r\n", Protocol, Interface, Status));
|
||||
|
||||
DEBUG ((DEBUG_ERROR, "SmmInstallProtocolInterface: %g %p failed with %r\n", Protocol, Interface, Status));
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
@@ -417,6 +425,7 @@ SmmUninstallProtocolInterface (
|
||||
RemoveEntryList (&Handle->AllHandles);
|
||||
FreePool (Handle);
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
@@ -452,12 +461,13 @@ SmmGetProtocolInterface (
|
||||
// Look at each protocol interface for a match
|
||||
//
|
||||
for (Link = Handle->Protocols.ForwardLink; Link != &Handle->Protocols; Link = Link->ForwardLink) {
|
||||
Prot = CR(Link, PROTOCOL_INTERFACE, Link, PROTOCOL_INTERFACE_SIGNATURE);
|
||||
Prot = CR (Link, PROTOCOL_INTERFACE, Link, PROTOCOL_INTERFACE_SIGNATURE);
|
||||
ProtEntry = Prot->Protocol;
|
||||
if (CompareGuid (&ProtEntry->ProtocolID, Protocol)) {
|
||||
return Prot;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -53,15 +53,15 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
// Each entry occupies 8B/64b. 1-page can hold 512 entries, which spans 9
|
||||
// bits in address. (512 = 1 << 9)
|
||||
//
|
||||
#define BYTE_LENGTH_SHIFT 3 // (8 = 1 << 3)
|
||||
#define BYTE_LENGTH_SHIFT 3 // (8 = 1 << 3)
|
||||
|
||||
#define GUARDED_HEAP_MAP_TABLE_ENTRY_SHIFT \
|
||||
(EFI_PAGE_SHIFT - BYTE_LENGTH_SHIFT)
|
||||
|
||||
#define GUARDED_HEAP_MAP_TABLE_DEPTH 5
|
||||
#define GUARDED_HEAP_MAP_TABLE_DEPTH 5
|
||||
|
||||
// Use UINT64_index + bit_index_of_UINT64 to locate the bit in may
|
||||
#define GUARDED_HEAP_MAP_ENTRY_BIT_SHIFT 6 // (64 = 1 << 6)
|
||||
#define GUARDED_HEAP_MAP_ENTRY_BIT_SHIFT 6 // (64 = 1 << 6)
|
||||
|
||||
#define GUARDED_HEAP_MAP_ENTRY_BITS \
|
||||
(1 << GUARDED_HEAP_MAP_ENTRY_BIT_SHIFT)
|
||||
@@ -154,8 +154,8 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
//
|
||||
// Memory type to guard (matching the related PCD definition)
|
||||
//
|
||||
#define GUARD_HEAP_TYPE_PAGE BIT2
|
||||
#define GUARD_HEAP_TYPE_POOL BIT3
|
||||
#define GUARD_HEAP_TYPE_PAGE BIT2
|
||||
#define GUARD_HEAP_TYPE_POOL BIT3
|
||||
|
||||
//
|
||||
// Debug message level
|
||||
@@ -163,10 +163,10 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
#define HEAP_GUARD_DEBUG_LEVEL (DEBUG_POOL|DEBUG_PAGE)
|
||||
|
||||
typedef struct {
|
||||
UINT32 TailMark;
|
||||
UINT32 HeadMark;
|
||||
EFI_PHYSICAL_ADDRESS Address;
|
||||
LIST_ENTRY Link;
|
||||
UINT32 TailMark;
|
||||
UINT32 HeadMark;
|
||||
EFI_PHYSICAL_ADDRESS Address;
|
||||
LIST_ENTRY Link;
|
||||
} HEAP_GUARD_NODE;
|
||||
|
||||
/**
|
||||
@@ -179,8 +179,8 @@ typedef struct {
|
||||
**/
|
||||
VOID
|
||||
SetGuardForMemory (
|
||||
IN EFI_PHYSICAL_ADDRESS Memory,
|
||||
IN UINTN NumberOfPages
|
||||
IN EFI_PHYSICAL_ADDRESS Memory,
|
||||
IN UINTN NumberOfPages
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -193,8 +193,8 @@ SetGuardForMemory (
|
||||
**/
|
||||
VOID
|
||||
UnsetGuardForMemory (
|
||||
IN EFI_PHYSICAL_ADDRESS Memory,
|
||||
IN UINTN NumberOfPages
|
||||
IN EFI_PHYSICAL_ADDRESS Memory,
|
||||
IN UINTN NumberOfPages
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -207,8 +207,8 @@ UnsetGuardForMemory (
|
||||
**/
|
||||
VOID
|
||||
AdjustMemoryA (
|
||||
IN OUT EFI_PHYSICAL_ADDRESS *Memory,
|
||||
IN OUT UINTN *NumberOfPages
|
||||
IN OUT EFI_PHYSICAL_ADDRESS *Memory,
|
||||
IN OUT UINTN *NumberOfPages
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -225,8 +225,8 @@ AdjustMemoryA (
|
||||
**/
|
||||
VOID
|
||||
AdjustMemoryF (
|
||||
IN OUT EFI_PHYSICAL_ADDRESS *Memory,
|
||||
IN OUT UINTN *NumberOfPages
|
||||
IN OUT EFI_PHYSICAL_ADDRESS *Memory,
|
||||
IN OUT UINTN *NumberOfPages
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -240,7 +240,7 @@ AdjustMemoryF (
|
||||
**/
|
||||
BOOLEAN
|
||||
IsPoolTypeToGuard (
|
||||
IN EFI_MEMORY_TYPE MemoryType
|
||||
IN EFI_MEMORY_TYPE MemoryType
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -254,8 +254,8 @@ IsPoolTypeToGuard (
|
||||
**/
|
||||
BOOLEAN
|
||||
IsPageTypeToGuard (
|
||||
IN EFI_MEMORY_TYPE MemoryType,
|
||||
IN EFI_ALLOCATE_TYPE AllocateType
|
||||
IN EFI_MEMORY_TYPE MemoryType,
|
||||
IN EFI_ALLOCATE_TYPE AllocateType
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -269,7 +269,7 @@ IsPageTypeToGuard (
|
||||
BOOLEAN
|
||||
EFIAPI
|
||||
IsMemoryGuarded (
|
||||
IN EFI_PHYSICAL_ADDRESS Address
|
||||
IN EFI_PHYSICAL_ADDRESS Address
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -283,7 +283,7 @@ IsMemoryGuarded (
|
||||
BOOLEAN
|
||||
EFIAPI
|
||||
IsGuardPage (
|
||||
IN EFI_PHYSICAL_ADDRESS Address
|
||||
IN EFI_PHYSICAL_ADDRESS Address
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -308,9 +308,9 @@ DumpGuardedMemoryBitmap (
|
||||
**/
|
||||
VOID *
|
||||
AdjustPoolHeadA (
|
||||
IN EFI_PHYSICAL_ADDRESS Memory,
|
||||
IN UINTN NoPages,
|
||||
IN UINTN Size
|
||||
IN EFI_PHYSICAL_ADDRESS Memory,
|
||||
IN UINTN NoPages,
|
||||
IN UINTN Size
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -322,7 +322,7 @@ AdjustPoolHeadA (
|
||||
**/
|
||||
VOID *
|
||||
AdjustPoolHeadF (
|
||||
IN EFI_PHYSICAL_ADDRESS Memory
|
||||
IN EFI_PHYSICAL_ADDRESS Memory
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -337,10 +337,10 @@ AdjustPoolHeadF (
|
||||
**/
|
||||
UINTN
|
||||
InternalAllocMaxAddressWithGuard (
|
||||
IN OUT LIST_ENTRY *FreePageList,
|
||||
IN UINTN NumberOfPages,
|
||||
IN UINTN MaxAddress,
|
||||
IN EFI_MEMORY_TYPE MemoryType
|
||||
IN OUT LIST_ENTRY *FreePageList,
|
||||
IN UINTN NumberOfPages,
|
||||
IN UINTN MaxAddress,
|
||||
IN EFI_MEMORY_TYPE MemoryType
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -383,10 +383,10 @@ IsHeapGuardEnabled (
|
||||
**/
|
||||
BOOLEAN
|
||||
VerifyMemoryGuard (
|
||||
IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
||||
IN UINTN NumberOfPages
|
||||
IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
||||
IN UINTN NumberOfPages
|
||||
);
|
||||
|
||||
extern BOOLEAN mOnGuarding;
|
||||
extern BOOLEAN mOnGuarding;
|
||||
|
||||
#endif
|
||||
|
@@ -8,7 +8,7 @@
|
||||
|
||||
#include "PiSmmCore.h"
|
||||
|
||||
#define CONFIG_TABLE_SIZE_INCREASED 0x10
|
||||
#define CONFIG_TABLE_SIZE_INCREASED 0x10
|
||||
|
||||
UINTN mSmmSystemTableAllocateSize = 0;
|
||||
|
||||
@@ -86,7 +86,6 @@ SmmInstallConfigurationTable (
|
||||
&(ConfigurationTable[Index + 1]),
|
||||
(gSmmCoreSmst.NumberOfTableEntries - Index) * sizeof (EFI_CONFIGURATION_TABLE)
|
||||
);
|
||||
|
||||
} else {
|
||||
//
|
||||
// No matching GUIDs were found, so this is an add operation.
|
||||
@@ -106,7 +105,7 @@ SmmInstallConfigurationTable (
|
||||
// Allocate a table with one additional entry.
|
||||
//
|
||||
mSmmSystemTableAllocateSize += (CONFIG_TABLE_SIZE_INCREASED * sizeof (EFI_CONFIGURATION_TABLE));
|
||||
ConfigurationTable = AllocatePool (mSmmSystemTableAllocateSize);
|
||||
ConfigurationTable = AllocatePool (mSmmSystemTableAllocateSize);
|
||||
if (ConfigurationTable == NULL) {
|
||||
//
|
||||
// If a new table could not be allocated, then return an error.
|
||||
|
@@ -11,24 +11,24 @@
|
||||
//
|
||||
// ProtocolRequest - Last LocateHandle request ID
|
||||
//
|
||||
UINTN mEfiLocateHandleRequest = 0;
|
||||
UINTN mEfiLocateHandleRequest = 0;
|
||||
|
||||
//
|
||||
// Internal prototypes
|
||||
//
|
||||
|
||||
typedef struct {
|
||||
EFI_GUID *Protocol;
|
||||
VOID *SearchKey;
|
||||
LIST_ENTRY *Position;
|
||||
PROTOCOL_ENTRY *ProtEntry;
|
||||
EFI_GUID *Protocol;
|
||||
VOID *SearchKey;
|
||||
LIST_ENTRY *Position;
|
||||
PROTOCOL_ENTRY *ProtEntry;
|
||||
} LOCATE_POSITION;
|
||||
|
||||
typedef
|
||||
IHANDLE *
|
||||
(* CORE_GET_NEXT) (
|
||||
IN OUT LOCATE_POSITION *Position,
|
||||
OUT VOID **Interface
|
||||
(*CORE_GET_NEXT) (
|
||||
IN OUT LOCATE_POSITION *Position,
|
||||
OUT VOID **Interface
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -48,7 +48,7 @@ SmmGetNextLocateAllHandles (
|
||||
OUT VOID **Interface
|
||||
)
|
||||
{
|
||||
IHANDLE *Handle;
|
||||
IHANDLE *Handle;
|
||||
|
||||
//
|
||||
// Next handle
|
||||
@@ -58,11 +58,12 @@ SmmGetNextLocateAllHandles (
|
||||
//
|
||||
// If not at the end of the list, get the handle
|
||||
//
|
||||
Handle = NULL;
|
||||
*Interface = NULL;
|
||||
Handle = NULL;
|
||||
*Interface = NULL;
|
||||
if (Position->Position != &gHandleList) {
|
||||
Handle = CR (Position->Position, IHANDLE, AllHandles, EFI_HANDLE_SIGNATURE);
|
||||
}
|
||||
|
||||
return Handle;
|
||||
}
|
||||
|
||||
@@ -89,15 +90,15 @@ SmmGetNextLocateByRegisterNotify (
|
||||
PROTOCOL_INTERFACE *Prot;
|
||||
LIST_ENTRY *Link;
|
||||
|
||||
Handle = NULL;
|
||||
*Interface = NULL;
|
||||
Handle = NULL;
|
||||
*Interface = NULL;
|
||||
ProtNotify = Position->SearchKey;
|
||||
|
||||
//
|
||||
// If this is the first request, get the next handle
|
||||
//
|
||||
if (ProtNotify != NULL) {
|
||||
ASSERT(ProtNotify->Signature == PROTOCOL_NOTIFY_SIGNATURE);
|
||||
ASSERT (ProtNotify->Signature == PROTOCOL_NOTIFY_SIGNATURE);
|
||||
Position->SearchKey = NULL;
|
||||
|
||||
//
|
||||
@@ -105,11 +106,12 @@ SmmGetNextLocateByRegisterNotify (
|
||||
//
|
||||
Link = ProtNotify->Position->ForwardLink;
|
||||
if (Link != &ProtNotify->Protocol->Protocols) {
|
||||
Prot = CR (Link, PROTOCOL_INTERFACE, ByProtocol, PROTOCOL_INTERFACE_SIGNATURE);
|
||||
Handle = Prot->Handle;
|
||||
Prot = CR (Link, PROTOCOL_INTERFACE, ByProtocol, PROTOCOL_INTERFACE_SIGNATURE);
|
||||
Handle = Prot->Handle;
|
||||
*Interface = Prot->Interface;
|
||||
}
|
||||
}
|
||||
|
||||
return Handle;
|
||||
}
|
||||
|
||||
@@ -134,13 +136,13 @@ SmmGetNextLocateByProtocol (
|
||||
LIST_ENTRY *Link;
|
||||
PROTOCOL_INTERFACE *Prot;
|
||||
|
||||
Handle = NULL;
|
||||
*Interface = NULL;
|
||||
for (; ;) {
|
||||
Handle = NULL;
|
||||
*Interface = NULL;
|
||||
for ( ; ;) {
|
||||
//
|
||||
// Next entry
|
||||
//
|
||||
Link = Position->Position->ForwardLink;
|
||||
Link = Position->Position->ForwardLink;
|
||||
Position->Position = Link;
|
||||
|
||||
//
|
||||
@@ -154,8 +156,8 @@ SmmGetNextLocateByProtocol (
|
||||
//
|
||||
// Get the handle
|
||||
//
|
||||
Prot = CR(Link, PROTOCOL_INTERFACE, ByProtocol, PROTOCOL_INTERFACE_SIGNATURE);
|
||||
Handle = Prot->Handle;
|
||||
Prot = CR (Link, PROTOCOL_INTERFACE, ByProtocol, PROTOCOL_INTERFACE_SIGNATURE);
|
||||
Handle = Prot->Handle;
|
||||
*Interface = Prot->Interface;
|
||||
|
||||
//
|
||||
@@ -167,6 +169,7 @@ SmmGetNextLocateByProtocol (
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return Handle;
|
||||
}
|
||||
|
||||
@@ -194,17 +197,17 @@ SmmLocateProtocol (
|
||||
OUT VOID **Interface
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
LOCATE_POSITION Position;
|
||||
PROTOCOL_NOTIFY *ProtNotify;
|
||||
IHANDLE *Handle;
|
||||
EFI_STATUS Status;
|
||||
LOCATE_POSITION Position;
|
||||
PROTOCOL_NOTIFY *ProtNotify;
|
||||
IHANDLE *Handle;
|
||||
|
||||
if ((Interface == NULL) || (Protocol == NULL)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
*Interface = NULL;
|
||||
Status = EFI_SUCCESS;
|
||||
Status = EFI_SUCCESS;
|
||||
|
||||
//
|
||||
// Set initial position
|
||||
@@ -223,6 +226,7 @@ SmmLocateProtocol (
|
||||
if (Position.ProtEntry == NULL) {
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
Position.Position = &Position.ProtEntry->Protocols;
|
||||
|
||||
Handle = SmmGetNextLocateByProtocol (&Position, Interface);
|
||||
@@ -237,7 +241,7 @@ SmmLocateProtocol (
|
||||
// If this is a search by register notify and a handle was
|
||||
// returned, update the register notification position
|
||||
//
|
||||
ProtNotify = Registration;
|
||||
ProtNotify = Registration;
|
||||
ProtNotify->Position = ProtNotify->Position->ForwardLink;
|
||||
}
|
||||
|
||||
@@ -298,51 +302,54 @@ SmmLocateHandle (
|
||||
Position.SearchKey = SearchKey;
|
||||
Position.Position = &gHandleList;
|
||||
|
||||
ResultSize = 0;
|
||||
ResultBuffer = (IHANDLE **) Buffer;
|
||||
Status = EFI_SUCCESS;
|
||||
ResultSize = 0;
|
||||
ResultBuffer = (IHANDLE **)Buffer;
|
||||
Status = EFI_SUCCESS;
|
||||
|
||||
//
|
||||
// Get the search function based on type
|
||||
//
|
||||
switch (SearchType) {
|
||||
case AllHandles:
|
||||
GetNext = SmmGetNextLocateAllHandles;
|
||||
break;
|
||||
case AllHandles:
|
||||
GetNext = SmmGetNextLocateAllHandles;
|
||||
break;
|
||||
|
||||
case ByRegisterNotify:
|
||||
GetNext = SmmGetNextLocateByRegisterNotify;
|
||||
//
|
||||
// Must have SearchKey for locate ByRegisterNotify
|
||||
//
|
||||
if (SearchKey == NULL) {
|
||||
Status = EFI_INVALID_PARAMETER;
|
||||
}
|
||||
break;
|
||||
case ByRegisterNotify:
|
||||
GetNext = SmmGetNextLocateByRegisterNotify;
|
||||
//
|
||||
// Must have SearchKey for locate ByRegisterNotify
|
||||
//
|
||||
if (SearchKey == NULL) {
|
||||
Status = EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
case ByProtocol:
|
||||
GetNext = SmmGetNextLocateByProtocol;
|
||||
if (Protocol == NULL) {
|
||||
break;
|
||||
|
||||
case ByProtocol:
|
||||
GetNext = SmmGetNextLocateByProtocol;
|
||||
if (Protocol == NULL) {
|
||||
Status = EFI_INVALID_PARAMETER;
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
// Look up the protocol entry and set the head pointer
|
||||
//
|
||||
Position.ProtEntry = SmmFindProtocolEntry (Protocol, FALSE);
|
||||
if (Position.ProtEntry == NULL) {
|
||||
Status = EFI_NOT_FOUND;
|
||||
break;
|
||||
}
|
||||
|
||||
Position.Position = &Position.ProtEntry->Protocols;
|
||||
break;
|
||||
|
||||
default:
|
||||
Status = EFI_INVALID_PARAMETER;
|
||||
break;
|
||||
}
|
||||
//
|
||||
// Look up the protocol entry and set the head pointer
|
||||
//
|
||||
Position.ProtEntry = SmmFindProtocolEntry (Protocol, FALSE);
|
||||
if (Position.ProtEntry == NULL) {
|
||||
Status = EFI_NOT_FOUND;
|
||||
break;
|
||||
}
|
||||
Position.Position = &Position.ProtEntry->Protocols;
|
||||
break;
|
||||
|
||||
default:
|
||||
Status = EFI_INVALID_PARAMETER;
|
||||
break;
|
||||
}
|
||||
|
||||
if (EFI_ERROR(Status)) {
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
@@ -350,7 +357,7 @@ SmmLocateHandle (
|
||||
// Enumerate out the matching handles
|
||||
//
|
||||
mEfiLocateHandleRequest += 1;
|
||||
for (; ;) {
|
||||
for ( ; ;) {
|
||||
//
|
||||
// Get the next handle. If no more handles, stop
|
||||
//
|
||||
@@ -363,10 +370,10 @@ SmmLocateHandle (
|
||||
// Increase the resulting buffer size, and if this handle
|
||||
// fits return it
|
||||
//
|
||||
ResultSize += sizeof(Handle);
|
||||
ResultSize += sizeof (Handle);
|
||||
if (ResultSize <= *BufferSize) {
|
||||
*ResultBuffer = Handle;
|
||||
ResultBuffer += 1;
|
||||
*ResultBuffer = Handle;
|
||||
ResultBuffer += 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -387,13 +394,13 @@ SmmLocateHandle (
|
||||
|
||||
*BufferSize = ResultSize;
|
||||
|
||||
if (SearchType == ByRegisterNotify && !EFI_ERROR(Status)) {
|
||||
if ((SearchType == ByRegisterNotify) && !EFI_ERROR (Status)) {
|
||||
ASSERT (SearchKey != NULL);
|
||||
//
|
||||
// If this is a search by register notify and a handle was
|
||||
// returned, update the register notification position
|
||||
//
|
||||
ProtNotify = SearchKey;
|
||||
ProtNotify = SearchKey;
|
||||
ProtNotify->Position = ProtNotify->Position->ForwardLink;
|
||||
}
|
||||
}
|
||||
@@ -444,26 +451,27 @@ SmmLocateHandleBuffer (
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
BufferSize = 0;
|
||||
BufferSize = 0;
|
||||
*NumberHandles = 0;
|
||||
*Buffer = NULL;
|
||||
Status = SmmLocateHandle (
|
||||
SearchType,
|
||||
Protocol,
|
||||
SearchKey,
|
||||
&BufferSize,
|
||||
*Buffer
|
||||
);
|
||||
*Buffer = NULL;
|
||||
Status = SmmLocateHandle (
|
||||
SearchType,
|
||||
Protocol,
|
||||
SearchKey,
|
||||
&BufferSize,
|
||||
*Buffer
|
||||
);
|
||||
//
|
||||
// LocateHandleBuffer() returns incorrect status code if SearchType is
|
||||
// invalid.
|
||||
//
|
||||
// Add code to correctly handle expected errors from SmmLocateHandle().
|
||||
//
|
||||
if (EFI_ERROR(Status) && Status != EFI_BUFFER_TOO_SMALL) {
|
||||
if (EFI_ERROR (Status) && (Status != EFI_BUFFER_TOO_SMALL)) {
|
||||
if (Status != EFI_INVALID_PARAMETER) {
|
||||
Status = EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
@@ -480,8 +488,8 @@ SmmLocateHandleBuffer (
|
||||
*Buffer
|
||||
);
|
||||
|
||||
*NumberHandles = BufferSize / sizeof(EFI_HANDLE);
|
||||
if (EFI_ERROR(Status)) {
|
||||
*NumberHandles = BufferSize / sizeof (EFI_HANDLE);
|
||||
if (EFI_ERROR (Status)) {
|
||||
*NumberHandles = 0;
|
||||
}
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -24,8 +24,8 @@ SmmNotifyProtocol (
|
||||
LIST_ENTRY *Link;
|
||||
|
||||
ProtEntry = Prot->Protocol;
|
||||
for (Link=ProtEntry->Notify.ForwardLink; Link != &ProtEntry->Notify; Link=Link->ForwardLink) {
|
||||
ProtNotify = CR(Link, PROTOCOL_NOTIFY, Link, PROTOCOL_NOTIFY_SIGNATURE);
|
||||
for (Link = ProtEntry->Notify.ForwardLink; Link != &ProtEntry->Notify; Link = Link->ForwardLink) {
|
||||
ProtNotify = CR (Link, PROTOCOL_NOTIFY, Link, PROTOCOL_NOTIFY_SIGNATURE);
|
||||
ProtNotify->Function (&ProtEntry->ProtocolID, Prot->Interface, Prot->Handle);
|
||||
}
|
||||
}
|
||||
@@ -54,14 +54,13 @@ SmmRemoveInterfaceFromProtocol (
|
||||
|
||||
Prot = SmmFindProtocolInterface (Handle, Protocol, Interface);
|
||||
if (Prot != NULL) {
|
||||
|
||||
ProtEntry = Prot->Protocol;
|
||||
|
||||
//
|
||||
// If there's a protocol notify location pointing to this entry, back it up one
|
||||
//
|
||||
for(Link = ProtEntry->Notify.ForwardLink; Link != &ProtEntry->Notify; Link=Link->ForwardLink) {
|
||||
ProtNotify = CR(Link, PROTOCOL_NOTIFY, Link, PROTOCOL_NOTIFY_SIGNATURE);
|
||||
for (Link = ProtEntry->Notify.ForwardLink; Link != &ProtEntry->Notify; Link = Link->ForwardLink) {
|
||||
ProtNotify = CR (Link, PROTOCOL_NOTIFY, Link, PROTOCOL_NOTIFY_SIGNATURE);
|
||||
|
||||
if (ProtNotify->Position == &Prot->ByProtocol) {
|
||||
ProtNotify->Position = Prot->ByProtocol.BackLink;
|
||||
@@ -105,7 +104,7 @@ SmmRegisterProtocolNotify (
|
||||
LIST_ENTRY *Link;
|
||||
EFI_STATUS Status;
|
||||
|
||||
if (Protocol == NULL || Registration == NULL) {
|
||||
if ((Protocol == NULL) || (Registration == NULL)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@@ -113,16 +112,17 @@ SmmRegisterProtocolNotify (
|
||||
//
|
||||
// Get the protocol entry per Protocol
|
||||
//
|
||||
ProtEntry = SmmFindProtocolEntry ((EFI_GUID *) Protocol, FALSE);
|
||||
ProtEntry = SmmFindProtocolEntry ((EFI_GUID *)Protocol, FALSE);
|
||||
if (ProtEntry != NULL) {
|
||||
ProtNotify = (PROTOCOL_NOTIFY * )*Registration;
|
||||
ProtNotify = (PROTOCOL_NOTIFY *)*Registration;
|
||||
for (Link = ProtEntry->Notify.ForwardLink;
|
||||
Link != &ProtEntry->Notify;
|
||||
Link = Link->ForwardLink) {
|
||||
Link = Link->ForwardLink)
|
||||
{
|
||||
//
|
||||
// Compare the notification record
|
||||
//
|
||||
if (ProtNotify == (CR(Link, PROTOCOL_NOTIFY, Link, PROTOCOL_NOTIFY_SIGNATURE))){
|
||||
if (ProtNotify == (CR (Link, PROTOCOL_NOTIFY, Link, PROTOCOL_NOTIFY_SIGNATURE))) {
|
||||
//
|
||||
// If Registration is an existing registration, then unhook it
|
||||
//
|
||||
@@ -133,6 +133,7 @@ SmmRegisterProtocolNotify (
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// If the registration is not found
|
||||
//
|
||||
@@ -144,19 +145,19 @@ SmmRegisterProtocolNotify (
|
||||
//
|
||||
// Get the protocol entry to add the notification too
|
||||
//
|
||||
ProtEntry = SmmFindProtocolEntry ((EFI_GUID *) Protocol, TRUE);
|
||||
ProtEntry = SmmFindProtocolEntry ((EFI_GUID *)Protocol, TRUE);
|
||||
if (ProtEntry != NULL) {
|
||||
//
|
||||
// Find whether notification already exist
|
||||
//
|
||||
for (Link = ProtEntry->Notify.ForwardLink;
|
||||
Link != &ProtEntry->Notify;
|
||||
Link = Link->ForwardLink) {
|
||||
|
||||
ProtNotify = CR(Link, PROTOCOL_NOTIFY, Link, PROTOCOL_NOTIFY_SIGNATURE);
|
||||
Link = Link->ForwardLink)
|
||||
{
|
||||
ProtNotify = CR (Link, PROTOCOL_NOTIFY, Link, PROTOCOL_NOTIFY_SIGNATURE);
|
||||
if (CompareGuid (&ProtNotify->Protocol->ProtocolID, Protocol) &&
|
||||
(ProtNotify->Function == Function)) {
|
||||
|
||||
(ProtNotify->Function == Function))
|
||||
{
|
||||
//
|
||||
// Notification already exist
|
||||
//
|
||||
@@ -169,11 +170,11 @@ SmmRegisterProtocolNotify (
|
||||
//
|
||||
// Allocate a new notification record
|
||||
//
|
||||
ProtNotify = AllocatePool (sizeof(PROTOCOL_NOTIFY));
|
||||
ProtNotify = AllocatePool (sizeof (PROTOCOL_NOTIFY));
|
||||
if (ProtNotify != NULL) {
|
||||
ProtNotify->Signature = PROTOCOL_NOTIFY_SIGNATURE;
|
||||
ProtNotify->Protocol = ProtEntry;
|
||||
ProtNotify->Function = Function;
|
||||
ProtNotify->Protocol = ProtEntry;
|
||||
ProtNotify->Function = Function;
|
||||
//
|
||||
// Start at the ending
|
||||
//
|
||||
@@ -190,7 +191,8 @@ SmmRegisterProtocolNotify (
|
||||
Status = EFI_OUT_OF_RESOURCES;
|
||||
if (ProtNotify != NULL) {
|
||||
*Registration = ProtNotify;
|
||||
Status = EFI_SUCCESS;
|
||||
Status = EFI_SUCCESS;
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
@@ -17,36 +17,34 @@ LIST_ENTRY mSmmMemoryMap = INITIALIZE_LIST_HEAD_VARIABLE (mSmmMemoryMap);
|
||||
// For GetMemoryMap()
|
||||
//
|
||||
|
||||
#define MEMORY_MAP_SIGNATURE SIGNATURE_32('m','m','a','p')
|
||||
#define MEMORY_MAP_SIGNATURE SIGNATURE_32('m','m','a','p')
|
||||
typedef struct {
|
||||
UINTN Signature;
|
||||
LIST_ENTRY Link;
|
||||
|
||||
BOOLEAN FromStack;
|
||||
EFI_MEMORY_TYPE Type;
|
||||
UINT64 Start;
|
||||
UINT64 End;
|
||||
UINTN Signature;
|
||||
LIST_ENTRY Link;
|
||||
|
||||
BOOLEAN FromStack;
|
||||
EFI_MEMORY_TYPE Type;
|
||||
UINT64 Start;
|
||||
UINT64 End;
|
||||
} MEMORY_MAP;
|
||||
|
||||
LIST_ENTRY gMemoryMap = INITIALIZE_LIST_HEAD_VARIABLE (gMemoryMap);
|
||||
LIST_ENTRY gMemoryMap = INITIALIZE_LIST_HEAD_VARIABLE (gMemoryMap);
|
||||
|
||||
|
||||
#define MAX_MAP_DEPTH 6
|
||||
#define MAX_MAP_DEPTH 6
|
||||
|
||||
///
|
||||
/// mMapDepth - depth of new descriptor stack
|
||||
///
|
||||
UINTN mMapDepth = 0;
|
||||
UINTN mMapDepth = 0;
|
||||
///
|
||||
/// mMapStack - space to use as temp storage to build new map descriptors
|
||||
///
|
||||
MEMORY_MAP mMapStack[MAX_MAP_DEPTH];
|
||||
UINTN mFreeMapStack = 0;
|
||||
MEMORY_MAP mMapStack[MAX_MAP_DEPTH];
|
||||
UINTN mFreeMapStack = 0;
|
||||
///
|
||||
/// This list maintain the free memory map list
|
||||
///
|
||||
LIST_ENTRY mFreeMemoryMapEntryList = INITIALIZE_LIST_HEAD_VARIABLE (mFreeMemoryMapEntryList);
|
||||
LIST_ENTRY mFreeMemoryMapEntryList = INITIALIZE_LIST_HEAD_VARIABLE (mFreeMemoryMapEntryList);
|
||||
|
||||
/**
|
||||
Allocates pages from the memory map.
|
||||
@@ -91,16 +89,16 @@ AllocateMemoryMapEntry (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
EFI_PHYSICAL_ADDRESS Mem;
|
||||
EFI_STATUS Status;
|
||||
MEMORY_MAP* FreeDescriptorEntries;
|
||||
MEMORY_MAP* Entry;
|
||||
UINTN Index;
|
||||
EFI_PHYSICAL_ADDRESS Mem;
|
||||
EFI_STATUS Status;
|
||||
MEMORY_MAP *FreeDescriptorEntries;
|
||||
MEMORY_MAP *Entry;
|
||||
UINTN Index;
|
||||
|
||||
//DEBUG((DEBUG_INFO, "AllocateMemoryMapEntry\n"));
|
||||
// DEBUG((DEBUG_INFO, "AllocateMemoryMapEntry\n"));
|
||||
|
||||
if (IsListEmpty (&mFreeMemoryMapEntryList)) {
|
||||
//DEBUG((DEBUG_INFO, "mFreeMemoryMapEntryList is empty\n"));
|
||||
// DEBUG((DEBUG_INFO, "mFreeMemoryMapEntryList is empty\n"));
|
||||
//
|
||||
// The list is empty, to allocate one page to refuel the list
|
||||
//
|
||||
@@ -113,13 +111,13 @@ AllocateMemoryMapEntry (
|
||||
FALSE
|
||||
);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
if(!EFI_ERROR (Status)) {
|
||||
if (!EFI_ERROR (Status)) {
|
||||
FreeDescriptorEntries = (MEMORY_MAP *)(UINTN)Mem;
|
||||
//DEBUG((DEBUG_INFO, "New FreeDescriptorEntries - 0x%x\n", FreeDescriptorEntries));
|
||||
// DEBUG((DEBUG_INFO, "New FreeDescriptorEntries - 0x%x\n", FreeDescriptorEntries));
|
||||
//
|
||||
// Enqueue the free memory map entries into the list
|
||||
//
|
||||
for (Index = 0; Index< RUNTIME_PAGE_ALLOCATION_GRANULARITY / sizeof(MEMORY_MAP); Index++) {
|
||||
for (Index = 0; Index < RUNTIME_PAGE_ALLOCATION_GRANULARITY / sizeof (MEMORY_MAP); Index++) {
|
||||
FreeDescriptorEntries[Index].Signature = MEMORY_MAP_SIGNATURE;
|
||||
InsertTailList (&mFreeMemoryMapEntryList, &FreeDescriptorEntries[Index].Link);
|
||||
}
|
||||
@@ -127,6 +125,7 @@ AllocateMemoryMapEntry (
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// dequeue the first descriptor from the list
|
||||
//
|
||||
@@ -136,7 +135,6 @@ AllocateMemoryMapEntry (
|
||||
return Entry;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Internal function. Moves any memory descriptors that are on the
|
||||
temporary descriptor stack to heap.
|
||||
@@ -147,14 +145,14 @@ CoreFreeMemoryMapStack (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
MEMORY_MAP *Entry;
|
||||
MEMORY_MAP *Entry;
|
||||
|
||||
//
|
||||
// If already freeing the map stack, then return
|
||||
//
|
||||
if (mFreeMapStack != 0) {
|
||||
ASSERT (FALSE);
|
||||
return ;
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
@@ -175,8 +173,7 @@ CoreFreeMemoryMapStack (
|
||||
mMapDepth -= 1;
|
||||
|
||||
if (mMapStack[mMapDepth].Link.ForwardLink != NULL) {
|
||||
|
||||
CopyMem (Entry , &mMapStack[mMapDepth], sizeof (MEMORY_MAP));
|
||||
CopyMem (Entry, &mMapStack[mMapDepth], sizeof (MEMORY_MAP));
|
||||
Entry->FromStack = FALSE;
|
||||
|
||||
//
|
||||
@@ -203,25 +200,25 @@ CoreFreeMemoryMapStack (
|
||||
**/
|
||||
VOID
|
||||
InsertNewEntry (
|
||||
IN LIST_ENTRY *Link,
|
||||
IN UINT64 Start,
|
||||
IN UINT64 End,
|
||||
IN EFI_MEMORY_TYPE Type,
|
||||
IN BOOLEAN Next,
|
||||
IN BOOLEAN AddRegion
|
||||
IN LIST_ENTRY *Link,
|
||||
IN UINT64 Start,
|
||||
IN UINT64 End,
|
||||
IN EFI_MEMORY_TYPE Type,
|
||||
IN BOOLEAN Next,
|
||||
IN BOOLEAN AddRegion
|
||||
)
|
||||
{
|
||||
MEMORY_MAP *Entry;
|
||||
|
||||
Entry = &mMapStack[mMapDepth];
|
||||
Entry = &mMapStack[mMapDepth];
|
||||
mMapDepth += 1;
|
||||
ASSERT (mMapDepth < MAX_MAP_DEPTH);
|
||||
Entry->FromStack = TRUE;
|
||||
|
||||
Entry->Signature = MEMORY_MAP_SIGNATURE;
|
||||
Entry->Type = Type;
|
||||
Entry->Start = Start;
|
||||
Entry->End = End;
|
||||
Entry->Type = Type;
|
||||
Entry->Start = Start;
|
||||
Entry->End = End;
|
||||
if (Next) {
|
||||
InsertHeadList (Link, &Entry->Link);
|
||||
} else {
|
||||
@@ -263,17 +260,17 @@ ConvertSmmMemoryMapEntry (
|
||||
IN BOOLEAN AddRegion
|
||||
)
|
||||
{
|
||||
LIST_ENTRY *Link;
|
||||
MEMORY_MAP *Entry;
|
||||
MEMORY_MAP *NextEntry;
|
||||
LIST_ENTRY *NextLink;
|
||||
MEMORY_MAP *PreviousEntry;
|
||||
LIST_ENTRY *PreviousLink;
|
||||
EFI_PHYSICAL_ADDRESS Start;
|
||||
EFI_PHYSICAL_ADDRESS End;
|
||||
LIST_ENTRY *Link;
|
||||
MEMORY_MAP *Entry;
|
||||
MEMORY_MAP *NextEntry;
|
||||
LIST_ENTRY *NextLink;
|
||||
MEMORY_MAP *PreviousEntry;
|
||||
LIST_ENTRY *PreviousLink;
|
||||
EFI_PHYSICAL_ADDRESS Start;
|
||||
EFI_PHYSICAL_ADDRESS End;
|
||||
|
||||
Start = Memory;
|
||||
End = Memory + EFI_PAGES_TO_SIZE(NumberOfPages) - 1;
|
||||
End = Memory + EFI_PAGES_TO_SIZE (NumberOfPages) - 1;
|
||||
|
||||
//
|
||||
// Exclude memory region
|
||||
@@ -296,8 +293,9 @@ ConvertSmmMemoryMapEntry (
|
||||
if (Entry->Start > End) {
|
||||
if ((Entry->Start == End + 1) && (Entry->Type == Type)) {
|
||||
Entry->Start = Start;
|
||||
return ;
|
||||
return;
|
||||
}
|
||||
|
||||
InsertNewEntry (
|
||||
&Entry->Link,
|
||||
Start,
|
||||
@@ -306,7 +304,7 @@ ConvertSmmMemoryMapEntry (
|
||||
FALSE,
|
||||
AddRegion
|
||||
);
|
||||
return ;
|
||||
return;
|
||||
}
|
||||
|
||||
if ((Entry->Start <= Start) && (Entry->End >= End)) {
|
||||
@@ -331,6 +329,7 @@ ConvertSmmMemoryMapEntry (
|
||||
AddRegion
|
||||
);
|
||||
}
|
||||
|
||||
if (Entry->End > End) {
|
||||
//
|
||||
// ---------------------------------------------------
|
||||
@@ -351,12 +350,13 @@ ConvertSmmMemoryMapEntry (
|
||||
AddRegion
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Update this node
|
||||
//
|
||||
Entry->Start = Start;
|
||||
Entry->End = End;
|
||||
Entry->Type = Type;
|
||||
Entry->End = End;
|
||||
Entry->Type = Type;
|
||||
|
||||
//
|
||||
// Check adjacent
|
||||
@@ -375,6 +375,7 @@ ConvertSmmMemoryMapEntry (
|
||||
RemoveOldEntry (NextEntry);
|
||||
}
|
||||
}
|
||||
|
||||
PreviousLink = Entry->Link.BackLink;
|
||||
if (PreviousLink != &gMemoryMap) {
|
||||
PreviousEntry = CR (PreviousLink, MEMORY_MAP, Link, MEMORY_MAP_SIGNATURE);
|
||||
@@ -390,7 +391,8 @@ ConvertSmmMemoryMapEntry (
|
||||
}
|
||||
}
|
||||
}
|
||||
return ;
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -409,9 +411,10 @@ ConvertSmmMemoryMapEntry (
|
||||
Entry = CR (Link, MEMORY_MAP, Link, MEMORY_MAP_SIGNATURE);
|
||||
if ((Entry->End + 1 == Start) && (Entry->Type == Type)) {
|
||||
Entry->End = End;
|
||||
return ;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
InsertNewEntry (
|
||||
&gMemoryMap,
|
||||
Start,
|
||||
@@ -420,7 +423,7 @@ ConvertSmmMemoryMapEntry (
|
||||
FALSE,
|
||||
AddRegion
|
||||
);
|
||||
return ;
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -433,20 +436,19 @@ GetSmmMemoryMapEntryCount (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
LIST_ENTRY *Link;
|
||||
UINTN Count;
|
||||
LIST_ENTRY *Link;
|
||||
UINTN Count;
|
||||
|
||||
Count = 0;
|
||||
Link = gMemoryMap.ForwardLink;
|
||||
Link = gMemoryMap.ForwardLink;
|
||||
while (Link != &gMemoryMap) {
|
||||
Link = Link->ForwardLink;
|
||||
Link = Link->ForwardLink;
|
||||
Count++;
|
||||
}
|
||||
|
||||
return Count;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Internal Function. Allocate n pages from given free page node.
|
||||
|
||||
@@ -472,10 +474,11 @@ InternalAllocPagesOnOneNode (
|
||||
if (Top > Pages->NumberOfPages) {
|
||||
Top = Pages->NumberOfPages;
|
||||
}
|
||||
|
||||
Bottom = Top - NumberOfPages;
|
||||
|
||||
if (Top < Pages->NumberOfPages) {
|
||||
Node = (FREE_PAGE_LIST*)((UINTN)Pages + EFI_PAGES_TO_SIZE (Top));
|
||||
Node = (FREE_PAGE_LIST *)((UINTN)Pages + EFI_PAGES_TO_SIZE (Top));
|
||||
Node->NumberOfPages = Pages->NumberOfPages - Top;
|
||||
InsertHeadList (&Pages->Link, &Node->Link);
|
||||
}
|
||||
@@ -511,11 +514,13 @@ InternalAllocMaxAddress (
|
||||
|
||||
for (Node = FreePageList->BackLink; Node != FreePageList; Node = Node->BackLink) {
|
||||
Pages = BASE_CR (Node, FREE_PAGE_LIST, Link);
|
||||
if (Pages->NumberOfPages >= NumberOfPages &&
|
||||
(UINTN)Pages + EFI_PAGES_TO_SIZE (NumberOfPages) - 1 <= MaxAddress) {
|
||||
if ((Pages->NumberOfPages >= NumberOfPages) &&
|
||||
((UINTN)Pages + EFI_PAGES_TO_SIZE (NumberOfPages) - 1 <= MaxAddress))
|
||||
{
|
||||
return InternalAllocPagesOnOneNode (Pages, NumberOfPages, MaxAddress);
|
||||
}
|
||||
}
|
||||
|
||||
return (UINTN)(-1);
|
||||
}
|
||||
|
||||
@@ -545,15 +550,17 @@ InternalAllocAddress (
|
||||
}
|
||||
|
||||
EndAddress = Address + EFI_PAGES_TO_SIZE (NumberOfPages);
|
||||
for (Node = FreePageList->BackLink; Node!= FreePageList; Node = Node->BackLink) {
|
||||
for (Node = FreePageList->BackLink; Node != FreePageList; Node = Node->BackLink) {
|
||||
Pages = BASE_CR (Node, FREE_PAGE_LIST, Link);
|
||||
if ((UINTN)Pages <= Address) {
|
||||
if ((UINTN)Pages + EFI_PAGES_TO_SIZE (Pages->NumberOfPages) < EndAddress) {
|
||||
break;
|
||||
}
|
||||
|
||||
return InternalAllocPagesOnOneNode (Pages, NumberOfPages, EndAddress);
|
||||
}
|
||||
}
|
||||
|
||||
return ~Address;
|
||||
}
|
||||
|
||||
@@ -588,8 +595,9 @@ SmmInternalAllocatePagesEx (
|
||||
{
|
||||
UINTN RequestedAddress;
|
||||
|
||||
if (MemoryType != EfiRuntimeServicesCode &&
|
||||
MemoryType != EfiRuntimeServicesData) {
|
||||
if ((MemoryType != EfiRuntimeServicesCode) &&
|
||||
(MemoryType != EfiRuntimeServicesData))
|
||||
{
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@@ -607,11 +615,11 @@ SmmInternalAllocatePagesEx (
|
||||
case AllocateMaxAddress:
|
||||
if (NeedGuard) {
|
||||
*Memory = InternalAllocMaxAddressWithGuard (
|
||||
&mSmmMemoryMap,
|
||||
NumberOfPages,
|
||||
RequestedAddress,
|
||||
MemoryType
|
||||
);
|
||||
&mSmmMemoryMap,
|
||||
NumberOfPages,
|
||||
RequestedAddress,
|
||||
MemoryType
|
||||
);
|
||||
if (*Memory == (UINTN)-1) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
} else {
|
||||
@@ -628,6 +636,7 @@ SmmInternalAllocatePagesEx (
|
||||
if (*Memory == (UINTN)-1) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
break;
|
||||
case AllocateAddress:
|
||||
*Memory = InternalAllocAddress (
|
||||
@@ -638,6 +647,7 @@ SmmInternalAllocatePagesEx (
|
||||
if (*Memory != RequestedAddress) {
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
break;
|
||||
default:
|
||||
return EFI_INVALID_PARAMETER;
|
||||
@@ -648,7 +658,7 @@ SmmInternalAllocatePagesEx (
|
||||
//
|
||||
ConvertSmmMemoryMapEntry (MemoryType, *Memory, NumberOfPages, AddRegion);
|
||||
if (!AddRegion) {
|
||||
CoreFreeMemoryMapStack();
|
||||
CoreFreeMemoryMapStack ();
|
||||
}
|
||||
|
||||
return EFI_SUCCESS;
|
||||
@@ -682,8 +692,14 @@ SmmInternalAllocatePages (
|
||||
IN BOOLEAN NeedGuard
|
||||
)
|
||||
{
|
||||
return SmmInternalAllocatePagesEx (Type, MemoryType, NumberOfPages, Memory,
|
||||
FALSE, NeedGuard);
|
||||
return SmmInternalAllocatePagesEx (
|
||||
Type,
|
||||
MemoryType,
|
||||
NumberOfPages,
|
||||
Memory,
|
||||
FALSE,
|
||||
NeedGuard
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -715,18 +731,24 @@ SmmAllocatePages (
|
||||
BOOLEAN NeedGuard;
|
||||
|
||||
NeedGuard = IsPageTypeToGuard (MemoryType, Type);
|
||||
Status = SmmInternalAllocatePages (Type, MemoryType, NumberOfPages, Memory,
|
||||
NeedGuard);
|
||||
Status = SmmInternalAllocatePages (
|
||||
Type,
|
||||
MemoryType,
|
||||
NumberOfPages,
|
||||
Memory,
|
||||
NeedGuard
|
||||
);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
SmmCoreUpdateProfile (
|
||||
(EFI_PHYSICAL_ADDRESS) (UINTN) RETURN_ADDRESS (0),
|
||||
(EFI_PHYSICAL_ADDRESS)(UINTN)RETURN_ADDRESS (0),
|
||||
MemoryProfileActionAllocatePages,
|
||||
MemoryType,
|
||||
EFI_PAGES_TO_SIZE (NumberOfPages),
|
||||
(VOID *) (UINTN) *Memory,
|
||||
(VOID *)(UINTN)*Memory,
|
||||
NULL
|
||||
);
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
@@ -747,13 +769,15 @@ InternalMergeNodes (
|
||||
|
||||
Next = BASE_CR (First->Link.ForwardLink, FREE_PAGE_LIST, Link);
|
||||
ASSERT (
|
||||
TRUNCATE_TO_PAGES ((UINTN)Next - (UINTN)First) >= First->NumberOfPages);
|
||||
TRUNCATE_TO_PAGES ((UINTN)Next - (UINTN)First) >= First->NumberOfPages
|
||||
);
|
||||
|
||||
if (TRUNCATE_TO_PAGES ((UINTN)Next - (UINTN)First) == First->NumberOfPages) {
|
||||
First->NumberOfPages += Next->NumberOfPages;
|
||||
RemoveEntryList (&Next->Link);
|
||||
Next = First;
|
||||
}
|
||||
|
||||
return Next;
|
||||
}
|
||||
|
||||
@@ -784,17 +808,19 @@ SmmInternalFreePagesEx (
|
||||
}
|
||||
|
||||
Pages = NULL;
|
||||
Node = mSmmMemoryMap.ForwardLink;
|
||||
Node = mSmmMemoryMap.ForwardLink;
|
||||
while (Node != &mSmmMemoryMap) {
|
||||
Pages = BASE_CR (Node, FREE_PAGE_LIST, Link);
|
||||
if (Memory < (UINTN)Pages) {
|
||||
break;
|
||||
}
|
||||
|
||||
Node = Node->ForwardLink;
|
||||
}
|
||||
|
||||
if (Node != &mSmmMemoryMap &&
|
||||
Memory + EFI_PAGES_TO_SIZE (NumberOfPages) > (UINTN)Pages) {
|
||||
if ((Node != &mSmmMemoryMap) &&
|
||||
(Memory + EFI_PAGES_TO_SIZE (NumberOfPages) > (UINTN)Pages))
|
||||
{
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@@ -805,7 +831,7 @@ SmmInternalFreePagesEx (
|
||||
}
|
||||
}
|
||||
|
||||
Pages = (FREE_PAGE_LIST*)(UINTN)Memory;
|
||||
Pages = (FREE_PAGE_LIST *)(UINTN)Memory;
|
||||
Pages->NumberOfPages = NumberOfPages;
|
||||
InsertTailList (Node, &Pages->Link);
|
||||
|
||||
@@ -824,7 +850,7 @@ SmmInternalFreePagesEx (
|
||||
//
|
||||
ConvertSmmMemoryMapEntry (EfiConventionalMemory, Memory, NumberOfPages, AddRegion);
|
||||
if (!AddRegion) {
|
||||
CoreFreeMemoryMapStack();
|
||||
CoreFreeMemoryMapStack ();
|
||||
}
|
||||
|
||||
return EFI_SUCCESS;
|
||||
@@ -853,6 +879,7 @@ SmmInternalFreePages (
|
||||
if (IsGuarded) {
|
||||
return SmmInternalFreePagesExWithGuard (Memory, NumberOfPages, FALSE);
|
||||
}
|
||||
|
||||
return SmmInternalFreePagesEx (Memory, NumberOfPages, FALSE);
|
||||
}
|
||||
|
||||
@@ -872,9 +899,9 @@ InMemMap (
|
||||
IN UINTN NumberOfPages
|
||||
)
|
||||
{
|
||||
LIST_ENTRY *Link;
|
||||
MEMORY_MAP *Entry;
|
||||
EFI_PHYSICAL_ADDRESS Last;
|
||||
LIST_ENTRY *Link;
|
||||
MEMORY_MAP *Entry;
|
||||
EFI_PHYSICAL_ADDRESS Last;
|
||||
|
||||
Last = Memory + EFI_PAGES_TO_SIZE (NumberOfPages) - 1;
|
||||
|
||||
@@ -912,22 +939,23 @@ SmmFreePages (
|
||||
EFI_STATUS Status;
|
||||
BOOLEAN IsGuarded;
|
||||
|
||||
if (!InMemMap(Memory, NumberOfPages)) {
|
||||
if (!InMemMap (Memory, NumberOfPages)) {
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
IsGuarded = IsHeapGuardEnabled () && IsMemoryGuarded (Memory);
|
||||
Status = SmmInternalFreePages (Memory, NumberOfPages, IsGuarded);
|
||||
Status = SmmInternalFreePages (Memory, NumberOfPages, IsGuarded);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
SmmCoreUpdateProfile (
|
||||
(EFI_PHYSICAL_ADDRESS) (UINTN) RETURN_ADDRESS (0),
|
||||
(EFI_PHYSICAL_ADDRESS)(UINTN)RETURN_ADDRESS (0),
|
||||
MemoryProfileActionFreePages,
|
||||
EfiMaxMemoryType,
|
||||
EFI_PAGES_TO_SIZE (NumberOfPages),
|
||||
(VOID *) (UINTN) Memory,
|
||||
(VOID *)(UINTN)Memory,
|
||||
NULL
|
||||
);
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
@@ -969,7 +997,7 @@ SmmAddMemoryRegion (
|
||||
// Align range on an EFI_PAGE_SIZE boundary
|
||||
//
|
||||
AlignedMemBase = (UINTN)(MemBase + EFI_PAGE_MASK) & ~EFI_PAGE_MASK;
|
||||
MemLength -= AlignedMemBase - MemBase;
|
||||
MemLength -= AlignedMemBase - MemBase;
|
||||
if (Type == EfiConventionalMemory) {
|
||||
SmmInternalFreePagesEx (AlignedMemBase, TRUNCATE_TO_PAGES ((UINTN)MemLength), TRUE);
|
||||
} else {
|
||||
@@ -1019,11 +1047,11 @@ SmmCoreGetMemoryMap (
|
||||
OUT UINT32 *DescriptorVersion
|
||||
)
|
||||
{
|
||||
UINTN Count;
|
||||
LIST_ENTRY *Link;
|
||||
MEMORY_MAP *Entry;
|
||||
UINTN Size;
|
||||
UINTN BufferSize;
|
||||
UINTN Count;
|
||||
LIST_ENTRY *Link;
|
||||
MEMORY_MAP *Entry;
|
||||
UINTN Size;
|
||||
UINTN BufferSize;
|
||||
|
||||
Size = sizeof (EFI_MEMORY_DESCRIPTOR);
|
||||
|
||||
@@ -1032,7 +1060,7 @@ SmmCoreGetMemoryMap (
|
||||
// prevent people from having pointer math bugs in their code.
|
||||
// now you have to use *DescriptorSize to make things work.
|
||||
//
|
||||
Size += sizeof(UINT64) - (Size % sizeof (UINT64));
|
||||
Size += sizeof (UINT64) - (Size % sizeof (UINT64));
|
||||
|
||||
if (DescriptorSize != NULL) {
|
||||
*DescriptorSize = Size;
|
||||
@@ -1042,7 +1070,7 @@ SmmCoreGetMemoryMap (
|
||||
*DescriptorVersion = EFI_MEMORY_DESCRIPTOR_VERSION;
|
||||
}
|
||||
|
||||
Count = GetSmmMemoryMapEntryCount ();
|
||||
Count = GetSmmMemoryMapEntryCount ();
|
||||
BufferSize = Size * Count;
|
||||
if (*MemoryMapSize < BufferSize) {
|
||||
*MemoryMapSize = BufferSize;
|
||||
@@ -1060,9 +1088,9 @@ SmmCoreGetMemoryMap (
|
||||
Entry = CR (Link, MEMORY_MAP, Link, MEMORY_MAP_SIGNATURE);
|
||||
Link = Link->ForwardLink;
|
||||
|
||||
MemoryMap->Type = Entry->Type;
|
||||
MemoryMap->PhysicalStart = Entry->Start;
|
||||
MemoryMap->NumberOfPages = RShiftU64 (Entry->End - Entry->Start + 1, EFI_PAGE_SHIFT);
|
||||
MemoryMap->Type = Entry->Type;
|
||||
MemoryMap->PhysicalStart = Entry->Start;
|
||||
MemoryMap->NumberOfPages = RShiftU64 (Entry->End - Entry->Start + 1, EFI_PAGE_SHIFT);
|
||||
|
||||
MemoryMap = NEXT_MEMORY_DESCRIPTOR (MemoryMap, Size);
|
||||
}
|
||||
|
@@ -27,12 +27,12 @@ EFI_SMM_SYSTEM_TABLE2 gSmmCoreSmst = {
|
||||
SmmInstallConfigurationTable,
|
||||
{
|
||||
{
|
||||
(EFI_SMM_CPU_IO2) SmmEfiNotAvailableYetArg5, // SmmMemRead
|
||||
(EFI_SMM_CPU_IO2) SmmEfiNotAvailableYetArg5 // SmmMemWrite
|
||||
(EFI_SMM_CPU_IO2)SmmEfiNotAvailableYetArg5, // SmmMemRead
|
||||
(EFI_SMM_CPU_IO2)SmmEfiNotAvailableYetArg5 // SmmMemWrite
|
||||
},
|
||||
{
|
||||
(EFI_SMM_CPU_IO2) SmmEfiNotAvailableYetArg5, // SmmIoRead
|
||||
(EFI_SMM_CPU_IO2) SmmEfiNotAvailableYetArg5 // SmmIoWrite
|
||||
(EFI_SMM_CPU_IO2)SmmEfiNotAvailableYetArg5, // SmmIoRead
|
||||
(EFI_SMM_CPU_IO2)SmmEfiNotAvailableYetArg5 // SmmIoWrite
|
||||
}
|
||||
},
|
||||
SmmAllocatePool,
|
||||
@@ -81,30 +81,30 @@ BOOLEAN mAcpiS3Enable = FALSE;
|
||||
// Table of SMI Handlers that are registered by the SMM Core when it is initialized
|
||||
//
|
||||
SMM_CORE_SMI_HANDLERS mSmmCoreSmiHandlers[] = {
|
||||
{ SmmDriverDispatchHandler, &gEfiEventDxeDispatchGuid, NULL, TRUE },
|
||||
{ SmmReadyToLockHandler, &gEfiDxeSmmReadyToLockProtocolGuid, NULL, TRUE },
|
||||
{ SmmLegacyBootHandler, &gEfiEventLegacyBootGuid, NULL, FALSE },
|
||||
{ SmmExitBootServicesHandler, &gEfiEventExitBootServicesGuid, NULL, FALSE },
|
||||
{ SmmReadyToBootHandler, &gEfiEventReadyToBootGuid, NULL, FALSE },
|
||||
{ SmmEndOfDxeHandler, &gEfiEndOfDxeEventGroupGuid, NULL, TRUE },
|
||||
{ NULL, NULL, NULL, FALSE }
|
||||
{ SmmDriverDispatchHandler, &gEfiEventDxeDispatchGuid, NULL, TRUE },
|
||||
{ SmmReadyToLockHandler, &gEfiDxeSmmReadyToLockProtocolGuid, NULL, TRUE },
|
||||
{ SmmLegacyBootHandler, &gEfiEventLegacyBootGuid, NULL, FALSE },
|
||||
{ SmmExitBootServicesHandler, &gEfiEventExitBootServicesGuid, NULL, FALSE },
|
||||
{ SmmReadyToBootHandler, &gEfiEventReadyToBootGuid, NULL, FALSE },
|
||||
{ SmmEndOfDxeHandler, &gEfiEndOfDxeEventGroupGuid, NULL, TRUE },
|
||||
{ NULL, NULL, NULL, FALSE }
|
||||
};
|
||||
|
||||
//
|
||||
// Table of SMI Handlers that are registered by the SMM Core when it is initialized
|
||||
//
|
||||
SMM_CORE_SMI_HANDLERS mSmmCoreS3SmiHandlers[] = {
|
||||
{ SmmS3SmmInitDoneHandler, &gEdkiiS3SmmInitDoneGuid, NULL, FALSE },
|
||||
{ SmmEndOfS3ResumeHandler, &gEdkiiEndOfS3ResumeGuid, NULL, FALSE },
|
||||
{ NULL, NULL, NULL, FALSE }
|
||||
{ SmmS3SmmInitDoneHandler, &gEdkiiS3SmmInitDoneGuid, NULL, FALSE },
|
||||
{ SmmEndOfS3ResumeHandler, &gEdkiiEndOfS3ResumeGuid, NULL, FALSE },
|
||||
{ NULL, NULL, NULL, FALSE }
|
||||
};
|
||||
|
||||
UINTN mFullSmramRangeCount;
|
||||
EFI_SMRAM_DESCRIPTOR *mFullSmramRanges;
|
||||
UINTN mFullSmramRangeCount;
|
||||
EFI_SMRAM_DESCRIPTOR *mFullSmramRanges;
|
||||
|
||||
EFI_SMM_DRIVER_ENTRY *mSmmCoreDriverEntry;
|
||||
EFI_SMM_DRIVER_ENTRY *mSmmCoreDriverEntry;
|
||||
|
||||
EFI_LOADED_IMAGE_PROTOCOL *mSmmCoreLoadedImage;
|
||||
EFI_LOADED_IMAGE_PROTOCOL *mSmmCoreLoadedImage;
|
||||
|
||||
/**
|
||||
Place holder function until all the SMM System Table Service are available.
|
||||
@@ -123,11 +123,11 @@ EFI_LOADED_IMAGE_PROTOCOL *mSmmCoreLoadedImage;
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
SmmEfiNotAvailableYetArg5 (
|
||||
UINTN Arg1,
|
||||
UINTN Arg2,
|
||||
UINTN Arg3,
|
||||
UINTN Arg4,
|
||||
UINTN Arg5
|
||||
UINTN Arg1,
|
||||
UINTN Arg2,
|
||||
UINTN Arg3,
|
||||
UINTN Arg4,
|
||||
UINTN Arg5
|
||||
)
|
||||
{
|
||||
//
|
||||
@@ -163,20 +163,20 @@ SmmLegacyBootHandler (
|
||||
IN OUT UINTN *CommBufferSize OPTIONAL
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_HANDLE SmmHandle;
|
||||
UINTN Index;
|
||||
EFI_STATUS Status;
|
||||
EFI_HANDLE SmmHandle;
|
||||
UINTN Index;
|
||||
|
||||
//
|
||||
// Install SMM Legacy Boot protocol.
|
||||
//
|
||||
SmmHandle = NULL;
|
||||
Status = SmmInstallProtocolInterface (
|
||||
&SmmHandle,
|
||||
&gEdkiiSmmLegacyBootProtocolGuid,
|
||||
EFI_NATIVE_INTERFACE,
|
||||
NULL
|
||||
);
|
||||
Status = SmmInstallProtocolInterface (
|
||||
&SmmHandle,
|
||||
&gEdkiiSmmLegacyBootProtocolGuid,
|
||||
EFI_NATIVE_INTERFACE,
|
||||
NULL
|
||||
);
|
||||
|
||||
mInLegacyBoot = TRUE;
|
||||
|
||||
@@ -218,20 +218,20 @@ SmmExitBootServicesHandler (
|
||||
IN OUT UINTN *CommBufferSize OPTIONAL
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_HANDLE SmmHandle;
|
||||
UINTN Index;
|
||||
EFI_STATUS Status;
|
||||
EFI_HANDLE SmmHandle;
|
||||
UINTN Index;
|
||||
|
||||
//
|
||||
// Install SMM Exit Boot Services protocol.
|
||||
//
|
||||
SmmHandle = NULL;
|
||||
Status = SmmInstallProtocolInterface (
|
||||
&SmmHandle,
|
||||
&gEdkiiSmmExitBootServicesProtocolGuid,
|
||||
EFI_NATIVE_INTERFACE,
|
||||
NULL
|
||||
);
|
||||
Status = SmmInstallProtocolInterface (
|
||||
&SmmHandle,
|
||||
&gEdkiiSmmExitBootServicesProtocolGuid,
|
||||
EFI_NATIVE_INTERFACE,
|
||||
NULL
|
||||
);
|
||||
|
||||
SmiHandlerUnRegister (DispatchHandle);
|
||||
|
||||
@@ -269,10 +269,10 @@ SmmExitBootServicesHandler (
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
SmmS3EntryCallBack (
|
||||
IN EFI_HANDLE DispatchHandle,
|
||||
IN CONST VOID *Context OPTIONAL,
|
||||
IN OUT VOID *CommBuffer OPTIONAL,
|
||||
IN OUT UINTN *CommBufferSize OPTIONAL
|
||||
IN EFI_HANDLE DispatchHandle,
|
||||
IN CONST VOID *Context OPTIONAL,
|
||||
IN OUT VOID *CommBuffer OPTIONAL,
|
||||
IN OUT UINTN *CommBufferSize OPTIONAL
|
||||
)
|
||||
{
|
||||
mDuringS3Resume = TRUE;
|
||||
@@ -302,19 +302,19 @@ SmmReadyToBootHandler (
|
||||
IN OUT UINTN *CommBufferSize OPTIONAL
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_HANDLE SmmHandle;
|
||||
EFI_STATUS Status;
|
||||
EFI_HANDLE SmmHandle;
|
||||
|
||||
//
|
||||
// Install SMM Ready To Boot protocol.
|
||||
//
|
||||
SmmHandle = NULL;
|
||||
Status = SmmInstallProtocolInterface (
|
||||
&SmmHandle,
|
||||
&gEdkiiSmmReadyToBootProtocolGuid,
|
||||
EFI_NATIVE_INTERFACE,
|
||||
NULL
|
||||
);
|
||||
Status = SmmInstallProtocolInterface (
|
||||
&SmmHandle,
|
||||
&gEdkiiSmmReadyToBootProtocolGuid,
|
||||
EFI_NATIVE_INTERFACE,
|
||||
NULL
|
||||
);
|
||||
|
||||
SmiHandlerUnRegister (DispatchHandle);
|
||||
|
||||
@@ -365,12 +365,12 @@ SmmReadyToLockHandler (
|
||||
// Install SMM Ready to lock protocol
|
||||
//
|
||||
SmmHandle = NULL;
|
||||
Status = SmmInstallProtocolInterface (
|
||||
&SmmHandle,
|
||||
&gEfiSmmReadyToLockProtocolGuid,
|
||||
EFI_NATIVE_INTERFACE,
|
||||
NULL
|
||||
);
|
||||
Status = SmmInstallProtocolInterface (
|
||||
&SmmHandle,
|
||||
&gEfiSmmReadyToLockProtocolGuid,
|
||||
EFI_NATIVE_INTERFACE,
|
||||
NULL
|
||||
);
|
||||
|
||||
//
|
||||
// Make sure SMM CPU I/O 2 Protocol has been installed into the handle database
|
||||
@@ -381,9 +381,10 @@ SmmReadyToLockHandler (
|
||||
// Print a message on a debug build if the SMM CPU I/O 2 Protocol is not installed
|
||||
//
|
||||
DEBUG_CODE_BEGIN ();
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG ((DEBUG_ERROR, "\nSMM: SmmCpuIo Arch Protocol not present!!\n"));
|
||||
}
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG ((DEBUG_ERROR, "\nSMM: SmmCpuIo Arch Protocol not present!!\n"));
|
||||
}
|
||||
|
||||
DEBUG_CODE_END ();
|
||||
|
||||
//
|
||||
@@ -396,7 +397,7 @@ SmmReadyToLockHandler (
|
||||
// evaluated to false if this is a debug build
|
||||
//
|
||||
DEBUG_CODE_BEGIN ();
|
||||
SmmDisplayDiscoveredNotDispatched ();
|
||||
SmmDisplayDiscoveredNotDispatched ();
|
||||
DEBUG_CODE_END ();
|
||||
|
||||
//
|
||||
@@ -433,11 +434,11 @@ SmmEndOfDxeHandler (
|
||||
IN OUT UINTN *CommBufferSize OPTIONAL
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_HANDLE SmmHandle;
|
||||
EFI_SMM_SX_DISPATCH2_PROTOCOL *SxDispatch;
|
||||
EFI_SMM_SX_REGISTER_CONTEXT EntryRegisterContext;
|
||||
EFI_HANDLE S3EntryHandle;
|
||||
EFI_STATUS Status;
|
||||
EFI_HANDLE SmmHandle;
|
||||
EFI_SMM_SX_DISPATCH2_PROTOCOL *SxDispatch;
|
||||
EFI_SMM_SX_REGISTER_CONTEXT EntryRegisterContext;
|
||||
EFI_HANDLE S3EntryHandle;
|
||||
|
||||
DEBUG ((DEBUG_INFO, "SmmEndOfDxeHandler\n"));
|
||||
|
||||
@@ -445,12 +446,12 @@ SmmEndOfDxeHandler (
|
||||
// Install SMM EndOfDxe protocol
|
||||
//
|
||||
SmmHandle = NULL;
|
||||
Status = SmmInstallProtocolInterface (
|
||||
&SmmHandle,
|
||||
&gEfiSmmEndOfDxeProtocolGuid,
|
||||
EFI_NATIVE_INTERFACE,
|
||||
NULL
|
||||
);
|
||||
Status = SmmInstallProtocolInterface (
|
||||
&SmmHandle,
|
||||
&gEfiSmmEndOfDxeProtocolGuid,
|
||||
EFI_NATIVE_INTERFACE,
|
||||
NULL
|
||||
);
|
||||
|
||||
if (mAcpiS3Enable) {
|
||||
//
|
||||
@@ -468,12 +469,12 @@ SmmEndOfDxeHandler (
|
||||
//
|
||||
EntryRegisterContext.Type = SxS3;
|
||||
EntryRegisterContext.Phase = SxEntry;
|
||||
Status = SxDispatch->Register (
|
||||
SxDispatch,
|
||||
SmmS3EntryCallBack,
|
||||
&EntryRegisterContext,
|
||||
&S3EntryHandle
|
||||
);
|
||||
Status = SxDispatch->Register (
|
||||
SxDispatch,
|
||||
SmmS3EntryCallBack,
|
||||
&EntryRegisterContext,
|
||||
&S3EntryHandle
|
||||
);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
}
|
||||
}
|
||||
@@ -518,12 +519,12 @@ SmmS3SmmInitDoneHandler (
|
||||
// Install SMM S3SmmInitDone protocol
|
||||
//
|
||||
SmmHandle = NULL;
|
||||
Status = SmmInstallProtocolInterface (
|
||||
&SmmHandle,
|
||||
&gEdkiiS3SmmInitDoneGuid,
|
||||
EFI_NATIVE_INTERFACE,
|
||||
NULL
|
||||
);
|
||||
Status = SmmInstallProtocolInterface (
|
||||
&SmmHandle,
|
||||
&gEdkiiS3SmmInitDoneGuid,
|
||||
EFI_NATIVE_INTERFACE,
|
||||
NULL
|
||||
);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
//
|
||||
@@ -531,10 +532,10 @@ SmmS3SmmInitDoneHandler (
|
||||
// installation event.
|
||||
//
|
||||
Status = SmmUninstallProtocolInterface (
|
||||
SmmHandle,
|
||||
&gEdkiiS3SmmInitDoneGuid,
|
||||
NULL
|
||||
);
|
||||
SmmHandle,
|
||||
&gEdkiiS3SmmInitDoneGuid,
|
||||
NULL
|
||||
);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
return Status;
|
||||
@@ -577,12 +578,12 @@ SmmEndOfS3ResumeHandler (
|
||||
// Install SMM EndOfS3Resume protocol
|
||||
//
|
||||
SmmHandle = NULL;
|
||||
Status = SmmInstallProtocolInterface (
|
||||
&SmmHandle,
|
||||
&gEdkiiEndOfS3ResumeGuid,
|
||||
EFI_NATIVE_INTERFACE,
|
||||
NULL
|
||||
);
|
||||
Status = SmmInstallProtocolInterface (
|
||||
&SmmHandle,
|
||||
&gEdkiiEndOfS3ResumeGuid,
|
||||
EFI_NATIVE_INTERFACE,
|
||||
NULL
|
||||
);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
//
|
||||
@@ -590,10 +591,10 @@ SmmEndOfS3ResumeHandler (
|
||||
// installation event.
|
||||
//
|
||||
Status = SmmUninstallProtocolInterface (
|
||||
SmmHandle,
|
||||
&gEdkiiEndOfS3ResumeGuid,
|
||||
NULL
|
||||
);
|
||||
SmmHandle,
|
||||
&gEdkiiEndOfS3ResumeGuid,
|
||||
NULL
|
||||
);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
mDuringS3Resume = FALSE;
|
||||
@@ -614,10 +615,10 @@ SmmEndOfS3ResumeHandler (
|
||||
**/
|
||||
BOOLEAN
|
||||
InternalIsBufferOverlapped (
|
||||
IN UINT8 *Buff1,
|
||||
IN UINTN Size1,
|
||||
IN UINT8 *Buff2,
|
||||
IN UINTN Size2
|
||||
IN UINT8 *Buff1,
|
||||
IN UINTN Size1,
|
||||
IN UINT8 *Buff2,
|
||||
IN UINTN Size2
|
||||
)
|
||||
{
|
||||
//
|
||||
@@ -644,7 +645,7 @@ VOID
|
||||
EFIAPI
|
||||
SmmEntryPoint (
|
||||
IN CONST EFI_SMM_ENTRY_CONTEXT *SmmEntryContext
|
||||
)
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_SMM_COMMUNICATE_HEADER *CommunicateHeader;
|
||||
@@ -693,9 +694,9 @@ SmmEntryPoint (
|
||||
// Synchronous SMI for SMM Core or request from Communicate protocol
|
||||
//
|
||||
IsOverlapped = InternalIsBufferOverlapped (
|
||||
(UINT8 *) CommunicationBuffer,
|
||||
(UINT8 *)CommunicationBuffer,
|
||||
BufferSize,
|
||||
(UINT8 *) gSmmCorePrivate,
|
||||
(UINT8 *)gSmmCorePrivate,
|
||||
sizeof (*gSmmCorePrivate)
|
||||
);
|
||||
if (!SmmIsBufferOutsideSmmValid ((UINTN)CommunicationBuffer, BufferSize) || IsOverlapped) {
|
||||
@@ -705,23 +706,23 @@ SmmEntryPoint (
|
||||
// return EFI_INVALID_PARAMETER
|
||||
//
|
||||
gSmmCorePrivate->CommunicationBuffer = NULL;
|
||||
gSmmCorePrivate->ReturnStatus = EFI_ACCESS_DENIED;
|
||||
gSmmCorePrivate->ReturnStatus = EFI_ACCESS_DENIED;
|
||||
} else {
|
||||
CommunicateHeader = (EFI_SMM_COMMUNICATE_HEADER *)CommunicationBuffer;
|
||||
BufferSize -= OFFSET_OF (EFI_SMM_COMMUNICATE_HEADER, Data);
|
||||
Status = SmiManage (
|
||||
&CommunicateHeader->HeaderGuid,
|
||||
NULL,
|
||||
CommunicateHeader->Data,
|
||||
&BufferSize
|
||||
);
|
||||
BufferSize -= OFFSET_OF (EFI_SMM_COMMUNICATE_HEADER, Data);
|
||||
Status = SmiManage (
|
||||
&CommunicateHeader->HeaderGuid,
|
||||
NULL,
|
||||
CommunicateHeader->Data,
|
||||
&BufferSize
|
||||
);
|
||||
//
|
||||
// Update CommunicationBuffer, BufferSize and ReturnStatus
|
||||
// Communicate service finished, reset the pointer to CommBuffer to NULL
|
||||
//
|
||||
gSmmCorePrivate->BufferSize = BufferSize + OFFSET_OF (EFI_SMM_COMMUNICATE_HEADER, Data);
|
||||
gSmmCorePrivate->BufferSize = BufferSize + OFFSET_OF (EFI_SMM_COMMUNICATE_HEADER, Data);
|
||||
gSmmCorePrivate->CommunicationBuffer = NULL;
|
||||
gSmmCorePrivate->ReturnStatus = (Status == EFI_SUCCESS) ? EFI_SUCCESS : EFI_NOT_FOUND;
|
||||
gSmmCorePrivate->ReturnStatus = (Status == EFI_SUCCESS) ? EFI_SUCCESS : EFI_NOT_FOUND;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -755,13 +756,13 @@ SmmCoreInstallLoadedImage (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_HANDLE Handle;
|
||||
EFI_STATUS Status;
|
||||
EFI_HANDLE Handle;
|
||||
|
||||
//
|
||||
// Allocate a Loaded Image Protocol in EfiBootServicesData
|
||||
//
|
||||
Status = gBS->AllocatePool (EfiBootServicesData, sizeof(EFI_LOADED_IMAGE_PROTOCOL), (VOID **)&mSmmCoreLoadedImage);
|
||||
Status = gBS->AllocatePool (EfiBootServicesData, sizeof (EFI_LOADED_IMAGE_PROTOCOL), (VOID **)&mSmmCoreLoadedImage);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
ZeroMem (mSmmCoreLoadedImage, sizeof (EFI_LOADED_IMAGE_PROTOCOL));
|
||||
@@ -769,9 +770,9 @@ SmmCoreInstallLoadedImage (
|
||||
// Fill in the remaining fields of the Loaded Image Protocol instance.
|
||||
// Note: ImageBase is an SMRAM address that can not be accessed outside of SMRAM if SMRAM window is closed.
|
||||
//
|
||||
mSmmCoreLoadedImage->Revision = EFI_LOADED_IMAGE_PROTOCOL_REVISION;
|
||||
mSmmCoreLoadedImage->ParentHandle = gSmmCorePrivate->SmmIplImageHandle;
|
||||
mSmmCoreLoadedImage->SystemTable = gST;
|
||||
mSmmCoreLoadedImage->Revision = EFI_LOADED_IMAGE_PROTOCOL_REVISION;
|
||||
mSmmCoreLoadedImage->ParentHandle = gSmmCorePrivate->SmmIplImageHandle;
|
||||
mSmmCoreLoadedImage->SystemTable = gST;
|
||||
|
||||
mSmmCoreLoadedImage->ImageBase = (VOID *)(UINTN)gSmmCorePrivate->PiSmmCoreImageBase;
|
||||
mSmmCoreLoadedImage->ImageSize = gSmmCorePrivate->PiSmmCoreImageSize;
|
||||
@@ -784,7 +785,8 @@ SmmCoreInstallLoadedImage (
|
||||
Handle = NULL;
|
||||
Status = gBS->InstallMultipleProtocolInterfaces (
|
||||
&Handle,
|
||||
&gEfiLoadedImageProtocolGuid, mSmmCoreLoadedImage,
|
||||
&gEfiLoadedImageProtocolGuid,
|
||||
mSmmCoreLoadedImage,
|
||||
NULL
|
||||
);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
@@ -792,40 +794,40 @@ SmmCoreInstallLoadedImage (
|
||||
//
|
||||
// Allocate a Loaded Image Protocol in SMM
|
||||
//
|
||||
Status = SmmAllocatePool (EfiRuntimeServicesData, sizeof(EFI_SMM_DRIVER_ENTRY), (VOID **)&mSmmCoreDriverEntry);
|
||||
ASSERT_EFI_ERROR(Status);
|
||||
Status = SmmAllocatePool (EfiRuntimeServicesData, sizeof (EFI_SMM_DRIVER_ENTRY), (VOID **)&mSmmCoreDriverEntry);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
ZeroMem (mSmmCoreDriverEntry, sizeof(EFI_SMM_DRIVER_ENTRY));
|
||||
ZeroMem (mSmmCoreDriverEntry, sizeof (EFI_SMM_DRIVER_ENTRY));
|
||||
//
|
||||
// Fill in the remaining fields of the Loaded Image Protocol instance.
|
||||
//
|
||||
mSmmCoreDriverEntry->Signature = EFI_SMM_DRIVER_ENTRY_SIGNATURE;
|
||||
mSmmCoreDriverEntry->SmmLoadedImage.Revision = EFI_LOADED_IMAGE_PROTOCOL_REVISION;
|
||||
mSmmCoreDriverEntry->Signature = EFI_SMM_DRIVER_ENTRY_SIGNATURE;
|
||||
mSmmCoreDriverEntry->SmmLoadedImage.Revision = EFI_LOADED_IMAGE_PROTOCOL_REVISION;
|
||||
mSmmCoreDriverEntry->SmmLoadedImage.ParentHandle = gSmmCorePrivate->SmmIplImageHandle;
|
||||
mSmmCoreDriverEntry->SmmLoadedImage.SystemTable = gST;
|
||||
mSmmCoreDriverEntry->SmmLoadedImage.SystemTable = gST;
|
||||
|
||||
mSmmCoreDriverEntry->SmmLoadedImage.ImageBase = (VOID *)(UINTN)gSmmCorePrivate->PiSmmCoreImageBase;
|
||||
mSmmCoreDriverEntry->SmmLoadedImage.ImageSize = gSmmCorePrivate->PiSmmCoreImageSize;
|
||||
mSmmCoreDriverEntry->SmmLoadedImage.ImageBase = (VOID *)(UINTN)gSmmCorePrivate->PiSmmCoreImageBase;
|
||||
mSmmCoreDriverEntry->SmmLoadedImage.ImageSize = gSmmCorePrivate->PiSmmCoreImageSize;
|
||||
mSmmCoreDriverEntry->SmmLoadedImage.ImageCodeType = EfiRuntimeServicesCode;
|
||||
mSmmCoreDriverEntry->SmmLoadedImage.ImageDataType = EfiRuntimeServicesData;
|
||||
|
||||
mSmmCoreDriverEntry->ImageEntryPoint = gSmmCorePrivate->PiSmmCoreEntryPoint;
|
||||
mSmmCoreDriverEntry->ImageBuffer = gSmmCorePrivate->PiSmmCoreImageBase;
|
||||
mSmmCoreDriverEntry->NumberOfPage = EFI_SIZE_TO_PAGES((UINTN)gSmmCorePrivate->PiSmmCoreImageSize);
|
||||
mSmmCoreDriverEntry->NumberOfPage = EFI_SIZE_TO_PAGES ((UINTN)gSmmCorePrivate->PiSmmCoreImageSize);
|
||||
|
||||
//
|
||||
// Create a new image handle in the SMM handle database for the SMM Driver
|
||||
//
|
||||
mSmmCoreDriverEntry->SmmImageHandle = NULL;
|
||||
Status = SmmInstallProtocolInterface (
|
||||
&mSmmCoreDriverEntry->SmmImageHandle,
|
||||
&gEfiLoadedImageProtocolGuid,
|
||||
EFI_NATIVE_INTERFACE,
|
||||
&mSmmCoreDriverEntry->SmmLoadedImage
|
||||
);
|
||||
ASSERT_EFI_ERROR(Status);
|
||||
Status = SmmInstallProtocolInterface (
|
||||
&mSmmCoreDriverEntry->SmmImageHandle,
|
||||
&gEfiLoadedImageProtocolGuid,
|
||||
EFI_NATIVE_INTERFACE,
|
||||
&mSmmCoreDriverEntry->SmmLoadedImage
|
||||
);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
return ;
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -876,7 +878,7 @@ SmmMain (
|
||||
// Copy FullSmramRanges to SMRAM
|
||||
//
|
||||
mFullSmramRangeCount = gSmmCorePrivate->SmramRangeCount;
|
||||
mFullSmramRanges = AllocatePool (mFullSmramRangeCount * sizeof (EFI_SMRAM_DESCRIPTOR));
|
||||
mFullSmramRanges = AllocatePool (mFullSmramRangeCount * sizeof (EFI_SMRAM_DESCRIPTOR));
|
||||
ASSERT (mFullSmramRanges != NULL);
|
||||
CopyMem (mFullSmramRanges, gSmmCorePrivate->SmramRanges, mFullSmramRangeCount * sizeof (EFI_SMRAM_DESCRIPTOR));
|
||||
|
||||
|
@@ -62,10 +62,10 @@
|
||||
// Used to build a table of SMI Handlers that the SMM Core registers
|
||||
//
|
||||
typedef struct {
|
||||
EFI_SMM_HANDLER_ENTRY_POINT2 Handler;
|
||||
EFI_GUID *HandlerType;
|
||||
EFI_HANDLE DispatchHandle;
|
||||
BOOLEAN UnRegister;
|
||||
EFI_SMM_HANDLER_ENTRY_POINT2 Handler;
|
||||
EFI_GUID *HandlerType;
|
||||
EFI_HANDLE DispatchHandle;
|
||||
BOOLEAN UnRegister;
|
||||
} SMM_CORE_SMI_HANDLERS;
|
||||
|
||||
//
|
||||
@@ -74,89 +74,89 @@ typedef struct {
|
||||
|
||||
#define SMI_ENTRY_SIGNATURE SIGNATURE_32('s','m','i','e')
|
||||
|
||||
typedef struct {
|
||||
UINTN Signature;
|
||||
LIST_ENTRY AllEntries; // All entries
|
||||
typedef struct {
|
||||
UINTN Signature;
|
||||
LIST_ENTRY AllEntries; // All entries
|
||||
|
||||
EFI_GUID HandlerType; // Type of interrupt
|
||||
LIST_ENTRY SmiHandlers; // All handlers
|
||||
EFI_GUID HandlerType; // Type of interrupt
|
||||
LIST_ENTRY SmiHandlers; // All handlers
|
||||
} SMI_ENTRY;
|
||||
|
||||
#define SMI_HANDLER_SIGNATURE SIGNATURE_32('s','m','i','h')
|
||||
|
||||
typedef struct {
|
||||
UINTN Signature;
|
||||
LIST_ENTRY Link; // Link on SMI_ENTRY.SmiHandlers
|
||||
EFI_SMM_HANDLER_ENTRY_POINT2 Handler; // The smm handler's entry point
|
||||
UINTN CallerAddr; // The address of caller who register the SMI handler.
|
||||
SMI_ENTRY *SmiEntry;
|
||||
VOID *Context; // for profile
|
||||
UINTN ContextSize; // for profile
|
||||
typedef struct {
|
||||
UINTN Signature;
|
||||
LIST_ENTRY Link; // Link on SMI_ENTRY.SmiHandlers
|
||||
EFI_SMM_HANDLER_ENTRY_POINT2 Handler; // The smm handler's entry point
|
||||
UINTN CallerAddr; // The address of caller who register the SMI handler.
|
||||
SMI_ENTRY *SmiEntry;
|
||||
VOID *Context; // for profile
|
||||
UINTN ContextSize; // for profile
|
||||
} SMI_HANDLER;
|
||||
|
||||
//
|
||||
// Structure for recording the state of an SMM Driver
|
||||
//
|
||||
#define EFI_SMM_DRIVER_ENTRY_SIGNATURE SIGNATURE_32('s', 'd','r','v')
|
||||
#define EFI_SMM_DRIVER_ENTRY_SIGNATURE SIGNATURE_32('s', 'd','r','v')
|
||||
|
||||
typedef struct {
|
||||
UINTN Signature;
|
||||
LIST_ENTRY Link; // mDriverList
|
||||
UINTN Signature;
|
||||
LIST_ENTRY Link; // mDriverList
|
||||
|
||||
LIST_ENTRY ScheduledLink; // mScheduledQueue
|
||||
LIST_ENTRY ScheduledLink; // mScheduledQueue
|
||||
|
||||
EFI_HANDLE FvHandle;
|
||||
EFI_GUID FileName;
|
||||
EFI_DEVICE_PATH_PROTOCOL *FvFileDevicePath;
|
||||
EFI_FIRMWARE_VOLUME2_PROTOCOL *Fv;
|
||||
EFI_HANDLE FvHandle;
|
||||
EFI_GUID FileName;
|
||||
EFI_DEVICE_PATH_PROTOCOL *FvFileDevicePath;
|
||||
EFI_FIRMWARE_VOLUME2_PROTOCOL *Fv;
|
||||
|
||||
VOID *Depex;
|
||||
UINTN DepexSize;
|
||||
VOID *Depex;
|
||||
UINTN DepexSize;
|
||||
|
||||
BOOLEAN Before;
|
||||
BOOLEAN After;
|
||||
EFI_GUID BeforeAfterGuid;
|
||||
BOOLEAN Before;
|
||||
BOOLEAN After;
|
||||
EFI_GUID BeforeAfterGuid;
|
||||
|
||||
BOOLEAN Dependent;
|
||||
BOOLEAN Scheduled;
|
||||
BOOLEAN Initialized;
|
||||
BOOLEAN DepexProtocolError;
|
||||
BOOLEAN Dependent;
|
||||
BOOLEAN Scheduled;
|
||||
BOOLEAN Initialized;
|
||||
BOOLEAN DepexProtocolError;
|
||||
|
||||
EFI_HANDLE ImageHandle;
|
||||
EFI_LOADED_IMAGE_PROTOCOL *LoadedImage;
|
||||
EFI_HANDLE ImageHandle;
|
||||
EFI_LOADED_IMAGE_PROTOCOL *LoadedImage;
|
||||
//
|
||||
// Image EntryPoint in SMRAM
|
||||
//
|
||||
PHYSICAL_ADDRESS ImageEntryPoint;
|
||||
PHYSICAL_ADDRESS ImageEntryPoint;
|
||||
//
|
||||
// Image Buffer in SMRAM
|
||||
//
|
||||
PHYSICAL_ADDRESS ImageBuffer;
|
||||
PHYSICAL_ADDRESS ImageBuffer;
|
||||
//
|
||||
// Image Page Number
|
||||
//
|
||||
UINTN NumberOfPage;
|
||||
EFI_HANDLE SmmImageHandle;
|
||||
EFI_LOADED_IMAGE_PROTOCOL SmmLoadedImage;
|
||||
UINTN NumberOfPage;
|
||||
EFI_HANDLE SmmImageHandle;
|
||||
EFI_LOADED_IMAGE_PROTOCOL SmmLoadedImage;
|
||||
} EFI_SMM_DRIVER_ENTRY;
|
||||
|
||||
#define EFI_HANDLE_SIGNATURE SIGNATURE_32('s','h','d','l')
|
||||
#define EFI_HANDLE_SIGNATURE SIGNATURE_32('s','h','d','l')
|
||||
|
||||
///
|
||||
/// IHANDLE - contains a list of protocol handles
|
||||
///
|
||||
typedef struct {
|
||||
UINTN Signature;
|
||||
UINTN Signature;
|
||||
/// All handles list of IHANDLE
|
||||
LIST_ENTRY AllHandles;
|
||||
LIST_ENTRY AllHandles;
|
||||
/// List of PROTOCOL_INTERFACE's for this handle
|
||||
LIST_ENTRY Protocols;
|
||||
UINTN LocateRequest;
|
||||
LIST_ENTRY Protocols;
|
||||
UINTN LocateRequest;
|
||||
} IHANDLE;
|
||||
|
||||
#define ASSERT_IS_HANDLE(a) ASSERT((a)->Signature == EFI_HANDLE_SIGNATURE)
|
||||
|
||||
#define PROTOCOL_ENTRY_SIGNATURE SIGNATURE_32('s','p','t','e')
|
||||
#define PROTOCOL_ENTRY_SIGNATURE SIGNATURE_32('s','p','t','e')
|
||||
|
||||
///
|
||||
/// PROTOCOL_ENTRY - each different protocol has 1 entry in the protocol
|
||||
@@ -164,15 +164,15 @@ typedef struct {
|
||||
/// with a list of registered notifies.
|
||||
///
|
||||
typedef struct {
|
||||
UINTN Signature;
|
||||
UINTN Signature;
|
||||
/// Link Entry inserted to mProtocolDatabase
|
||||
LIST_ENTRY AllEntries;
|
||||
LIST_ENTRY AllEntries;
|
||||
/// ID of the protocol
|
||||
EFI_GUID ProtocolID;
|
||||
EFI_GUID ProtocolID;
|
||||
/// All protocol interfaces
|
||||
LIST_ENTRY Protocols;
|
||||
LIST_ENTRY Protocols;
|
||||
/// Registered notification handlers
|
||||
LIST_ENTRY Notify;
|
||||
LIST_ENTRY Notify;
|
||||
} PROTOCOL_ENTRY;
|
||||
|
||||
#define PROTOCOL_INTERFACE_SIGNATURE SIGNATURE_32('s','p','i','f')
|
||||
@@ -182,33 +182,33 @@ typedef struct {
|
||||
/// with a protocol interface structure
|
||||
///
|
||||
typedef struct {
|
||||
UINTN Signature;
|
||||
UINTN Signature;
|
||||
/// Link on IHANDLE.Protocols
|
||||
LIST_ENTRY Link;
|
||||
LIST_ENTRY Link;
|
||||
/// Back pointer
|
||||
IHANDLE *Handle;
|
||||
IHANDLE *Handle;
|
||||
/// Link on PROTOCOL_ENTRY.Protocols
|
||||
LIST_ENTRY ByProtocol;
|
||||
LIST_ENTRY ByProtocol;
|
||||
/// The protocol ID
|
||||
PROTOCOL_ENTRY *Protocol;
|
||||
PROTOCOL_ENTRY *Protocol;
|
||||
/// The interface value
|
||||
VOID *Interface;
|
||||
VOID *Interface;
|
||||
} PROTOCOL_INTERFACE;
|
||||
|
||||
#define PROTOCOL_NOTIFY_SIGNATURE SIGNATURE_32('s','p','t','n')
|
||||
#define PROTOCOL_NOTIFY_SIGNATURE SIGNATURE_32('s','p','t','n')
|
||||
|
||||
///
|
||||
/// PROTOCOL_NOTIFY - used for each register notification for a protocol
|
||||
///
|
||||
typedef struct {
|
||||
UINTN Signature;
|
||||
PROTOCOL_ENTRY *Protocol;
|
||||
UINTN Signature;
|
||||
PROTOCOL_ENTRY *Protocol;
|
||||
/// All notifications for this protocol
|
||||
LIST_ENTRY Link;
|
||||
LIST_ENTRY Link;
|
||||
/// Notification function
|
||||
EFI_SMM_NOTIFY_FN Function;
|
||||
EFI_SMM_NOTIFY_FN Function;
|
||||
/// Last position notified
|
||||
LIST_ENTRY *Position;
|
||||
LIST_ENTRY *Position;
|
||||
} PROTOCOL_NOTIFY;
|
||||
|
||||
//
|
||||
@@ -253,9 +253,9 @@ EFI_STATUS
|
||||
EFIAPI
|
||||
SmmInstallConfigurationTable (
|
||||
IN CONST EFI_SMM_SYSTEM_TABLE2 *SystemTable,
|
||||
IN CONST EFI_GUID *Guid,
|
||||
IN VOID *Table,
|
||||
IN UINTN TableSize
|
||||
IN CONST EFI_GUID *Guid,
|
||||
IN VOID *Table,
|
||||
IN UINTN TableSize
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -275,10 +275,10 @@ SmmInstallConfigurationTable (
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
SmmInstallProtocolInterface (
|
||||
IN OUT EFI_HANDLE *UserHandle,
|
||||
IN EFI_GUID *Protocol,
|
||||
IN EFI_INTERFACE_TYPE InterfaceType,
|
||||
IN VOID *Interface
|
||||
IN OUT EFI_HANDLE *UserHandle,
|
||||
IN EFI_GUID *Protocol,
|
||||
IN EFI_INTERFACE_TYPE InterfaceType,
|
||||
IN VOID *Interface
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -300,10 +300,10 @@ SmmInstallProtocolInterface (
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
SmmAllocatePages (
|
||||
IN EFI_ALLOCATE_TYPE Type,
|
||||
IN EFI_MEMORY_TYPE MemoryType,
|
||||
IN UINTN NumberOfPages,
|
||||
OUT EFI_PHYSICAL_ADDRESS *Memory
|
||||
IN EFI_ALLOCATE_TYPE Type,
|
||||
IN EFI_MEMORY_TYPE MemoryType,
|
||||
IN UINTN NumberOfPages,
|
||||
OUT EFI_PHYSICAL_ADDRESS *Memory
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -326,11 +326,11 @@ SmmAllocatePages (
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
SmmInternalAllocatePages (
|
||||
IN EFI_ALLOCATE_TYPE Type,
|
||||
IN EFI_MEMORY_TYPE MemoryType,
|
||||
IN UINTN NumberOfPages,
|
||||
OUT EFI_PHYSICAL_ADDRESS *Memory,
|
||||
IN BOOLEAN NeedGuard
|
||||
IN EFI_ALLOCATE_TYPE Type,
|
||||
IN EFI_MEMORY_TYPE MemoryType,
|
||||
IN UINTN NumberOfPages,
|
||||
OUT EFI_PHYSICAL_ADDRESS *Memory,
|
||||
IN BOOLEAN NeedGuard
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -347,8 +347,8 @@ SmmInternalAllocatePages (
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
SmmFreePages (
|
||||
IN EFI_PHYSICAL_ADDRESS Memory,
|
||||
IN UINTN NumberOfPages
|
||||
IN EFI_PHYSICAL_ADDRESS Memory,
|
||||
IN UINTN NumberOfPages
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -367,9 +367,9 @@ SmmFreePages (
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
SmmInternalFreePages (
|
||||
IN EFI_PHYSICAL_ADDRESS Memory,
|
||||
IN UINTN NumberOfPages,
|
||||
IN BOOLEAN IsGuarded
|
||||
IN EFI_PHYSICAL_ADDRESS Memory,
|
||||
IN UINTN NumberOfPages,
|
||||
IN BOOLEAN IsGuarded
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -388,9 +388,9 @@ SmmInternalFreePages (
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
SmmAllocatePool (
|
||||
IN EFI_MEMORY_TYPE PoolType,
|
||||
IN UINTN Size,
|
||||
OUT VOID **Buffer
|
||||
IN EFI_MEMORY_TYPE PoolType,
|
||||
IN UINTN Size,
|
||||
OUT VOID **Buffer
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -409,9 +409,9 @@ SmmAllocatePool (
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
SmmInternalAllocatePool (
|
||||
IN EFI_MEMORY_TYPE PoolType,
|
||||
IN UINTN Size,
|
||||
OUT VOID **Buffer
|
||||
IN EFI_MEMORY_TYPE PoolType,
|
||||
IN UINTN Size,
|
||||
OUT VOID **Buffer
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -426,7 +426,7 @@ SmmInternalAllocatePool (
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
SmmFreePool (
|
||||
IN VOID *Buffer
|
||||
IN VOID *Buffer
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -441,7 +441,7 @@ SmmFreePool (
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
SmmInternalFreePool (
|
||||
IN VOID *Buffer
|
||||
IN VOID *Buffer
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -463,11 +463,11 @@ SmmInternalFreePool (
|
||||
**/
|
||||
EFI_STATUS
|
||||
SmmInstallProtocolInterfaceNotify (
|
||||
IN OUT EFI_HANDLE *UserHandle,
|
||||
IN EFI_GUID *Protocol,
|
||||
IN EFI_INTERFACE_TYPE InterfaceType,
|
||||
IN VOID *Interface,
|
||||
IN BOOLEAN Notify
|
||||
IN OUT EFI_HANDLE *UserHandle,
|
||||
IN EFI_GUID *Protocol,
|
||||
IN EFI_INTERFACE_TYPE InterfaceType,
|
||||
IN VOID *Interface,
|
||||
IN BOOLEAN Notify
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -486,9 +486,9 @@ SmmInstallProtocolInterfaceNotify (
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
SmmUninstallProtocolInterface (
|
||||
IN EFI_HANDLE UserHandle,
|
||||
IN EFI_GUID *Protocol,
|
||||
IN VOID *Interface
|
||||
IN EFI_HANDLE UserHandle,
|
||||
IN EFI_GUID *Protocol,
|
||||
IN VOID *Interface
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -505,9 +505,9 @@ SmmUninstallProtocolInterface (
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
SmmHandleProtocol (
|
||||
IN EFI_HANDLE UserHandle,
|
||||
IN EFI_GUID *Protocol,
|
||||
OUT VOID **Interface
|
||||
IN EFI_HANDLE UserHandle,
|
||||
IN EFI_GUID *Protocol,
|
||||
OUT VOID **Interface
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -526,9 +526,9 @@ SmmHandleProtocol (
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
SmmRegisterProtocolNotify (
|
||||
IN CONST EFI_GUID *Protocol,
|
||||
IN EFI_SMM_NOTIFY_FN Function,
|
||||
OUT VOID **Registration
|
||||
IN CONST EFI_GUID *Protocol,
|
||||
IN EFI_SMM_NOTIFY_FN Function,
|
||||
OUT VOID **Registration
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -552,11 +552,11 @@ SmmRegisterProtocolNotify (
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
SmmLocateHandle (
|
||||
IN EFI_LOCATE_SEARCH_TYPE SearchType,
|
||||
IN EFI_GUID *Protocol OPTIONAL,
|
||||
IN VOID *SearchKey OPTIONAL,
|
||||
IN OUT UINTN *BufferSize,
|
||||
OUT EFI_HANDLE *Buffer
|
||||
IN EFI_LOCATE_SEARCH_TYPE SearchType,
|
||||
IN EFI_GUID *Protocol OPTIONAL,
|
||||
IN VOID *SearchKey OPTIONAL,
|
||||
IN OUT UINTN *BufferSize,
|
||||
OUT EFI_HANDLE *Buffer
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -632,10 +632,10 @@ SmmLocateHandleBuffer (
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
SmiManage (
|
||||
IN CONST EFI_GUID *HandlerType,
|
||||
IN CONST VOID *Context OPTIONAL,
|
||||
IN OUT VOID *CommBuffer OPTIONAL,
|
||||
IN OUT UINTN *CommBufferSize OPTIONAL
|
||||
IN CONST EFI_GUID *HandlerType,
|
||||
IN CONST VOID *Context OPTIONAL,
|
||||
IN OUT VOID *CommBuffer OPTIONAL,
|
||||
IN OUT UINTN *CommBufferSize OPTIONAL
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -652,9 +652,9 @@ SmiManage (
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
SmiHandlerRegister (
|
||||
IN EFI_SMM_HANDLER_ENTRY_POINT2 Handler,
|
||||
IN CONST EFI_GUID *HandlerType OPTIONAL,
|
||||
OUT EFI_HANDLE *DispatchHandle
|
||||
IN EFI_SMM_HANDLER_ENTRY_POINT2 Handler,
|
||||
IN CONST EFI_GUID *HandlerType OPTIONAL,
|
||||
OUT EFI_HANDLE *DispatchHandle
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -669,7 +669,7 @@ SmiHandlerRegister (
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
SmiHandlerUnRegister (
|
||||
IN EFI_HANDLE DispatchHandle
|
||||
IN EFI_HANDLE DispatchHandle
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -688,10 +688,10 @@ SmiHandlerUnRegister (
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
SmmDriverDispatchHandler (
|
||||
IN EFI_HANDLE DispatchHandle,
|
||||
IN CONST VOID *Context OPTIONAL,
|
||||
IN OUT VOID *CommBuffer OPTIONAL,
|
||||
IN OUT UINTN *CommBufferSize OPTIONAL
|
||||
IN EFI_HANDLE DispatchHandle,
|
||||
IN CONST VOID *Context OPTIONAL,
|
||||
IN OUT VOID *CommBuffer OPTIONAL,
|
||||
IN OUT UINTN *CommBufferSize OPTIONAL
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -710,10 +710,10 @@ SmmDriverDispatchHandler (
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
SmmLegacyBootHandler (
|
||||
IN EFI_HANDLE DispatchHandle,
|
||||
IN CONST VOID *Context OPTIONAL,
|
||||
IN OUT VOID *CommBuffer OPTIONAL,
|
||||
IN OUT UINTN *CommBufferSize OPTIONAL
|
||||
IN EFI_HANDLE DispatchHandle,
|
||||
IN CONST VOID *Context OPTIONAL,
|
||||
IN OUT VOID *CommBuffer OPTIONAL,
|
||||
IN OUT UINTN *CommBufferSize OPTIONAL
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -732,10 +732,10 @@ SmmLegacyBootHandler (
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
SmmReadyToLockHandler (
|
||||
IN EFI_HANDLE DispatchHandle,
|
||||
IN CONST VOID *Context OPTIONAL,
|
||||
IN OUT VOID *CommBuffer OPTIONAL,
|
||||
IN OUT UINTN *CommBufferSize OPTIONAL
|
||||
IN EFI_HANDLE DispatchHandle,
|
||||
IN CONST VOID *Context OPTIONAL,
|
||||
IN OUT VOID *CommBuffer OPTIONAL,
|
||||
IN OUT UINTN *CommBufferSize OPTIONAL
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -754,10 +754,10 @@ SmmReadyToLockHandler (
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
SmmEndOfDxeHandler (
|
||||
IN EFI_HANDLE DispatchHandle,
|
||||
IN CONST VOID *Context OPTIONAL,
|
||||
IN OUT VOID *CommBuffer OPTIONAL,
|
||||
IN OUT UINTN *CommBufferSize OPTIONAL
|
||||
IN EFI_HANDLE DispatchHandle,
|
||||
IN CONST VOID *Context OPTIONAL,
|
||||
IN OUT VOID *CommBuffer OPTIONAL,
|
||||
IN OUT UINTN *CommBufferSize OPTIONAL
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -776,10 +776,10 @@ SmmEndOfDxeHandler (
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
SmmExitBootServicesHandler (
|
||||
IN EFI_HANDLE DispatchHandle,
|
||||
IN CONST VOID *Context OPTIONAL,
|
||||
IN OUT VOID *CommBuffer OPTIONAL,
|
||||
IN OUT UINTN *CommBufferSize OPTIONAL
|
||||
IN EFI_HANDLE DispatchHandle,
|
||||
IN CONST VOID *Context OPTIONAL,
|
||||
IN OUT VOID *CommBuffer OPTIONAL,
|
||||
IN OUT UINTN *CommBufferSize OPTIONAL
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -798,10 +798,10 @@ SmmExitBootServicesHandler (
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
SmmReadyToBootHandler (
|
||||
IN EFI_HANDLE DispatchHandle,
|
||||
IN CONST VOID *Context OPTIONAL,
|
||||
IN OUT VOID *CommBuffer OPTIONAL,
|
||||
IN OUT UINTN *CommBufferSize OPTIONAL
|
||||
IN EFI_HANDLE DispatchHandle,
|
||||
IN CONST VOID *Context OPTIONAL,
|
||||
IN OUT VOID *CommBuffer OPTIONAL,
|
||||
IN OUT UINTN *CommBufferSize OPTIONAL
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -865,15 +865,15 @@ SmmEndOfS3ResumeHandler (
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
SmmEfiNotAvailableYetArg5 (
|
||||
UINTN Arg1,
|
||||
UINTN Arg2,
|
||||
UINTN Arg3,
|
||||
UINTN Arg4,
|
||||
UINTN Arg5
|
||||
UINTN Arg1,
|
||||
UINTN Arg2,
|
||||
UINTN Arg3,
|
||||
UINTN Arg4,
|
||||
UINTN Arg5
|
||||
);
|
||||
|
||||
//
|
||||
//Functions used during debug builds
|
||||
// Functions used during debug builds
|
||||
//
|
||||
|
||||
/**
|
||||
@@ -897,10 +897,10 @@ SmmDisplayDiscoveredNotDispatched (
|
||||
**/
|
||||
VOID
|
||||
SmmAddMemoryRegion (
|
||||
IN EFI_PHYSICAL_ADDRESS MemBase,
|
||||
IN UINT64 MemLength,
|
||||
IN EFI_MEMORY_TYPE Type,
|
||||
IN UINT64 Attributes
|
||||
IN EFI_PHYSICAL_ADDRESS MemBase,
|
||||
IN UINT64 MemLength,
|
||||
IN EFI_MEMORY_TYPE Type,
|
||||
IN UINT64 Attributes
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -914,8 +914,8 @@ SmmAddMemoryRegion (
|
||||
**/
|
||||
PROTOCOL_ENTRY *
|
||||
SmmFindProtocolEntry (
|
||||
IN EFI_GUID *Protocol,
|
||||
IN BOOLEAN Create
|
||||
IN EFI_GUID *Protocol,
|
||||
IN BOOLEAN Create
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -926,7 +926,7 @@ SmmFindProtocolEntry (
|
||||
**/
|
||||
VOID
|
||||
SmmNotifyProtocol (
|
||||
IN PROTOCOL_INTERFACE *Prot
|
||||
IN PROTOCOL_INTERFACE *Prot
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -943,9 +943,9 @@ SmmNotifyProtocol (
|
||||
**/
|
||||
PROTOCOL_INTERFACE *
|
||||
SmmFindProtocolInterface (
|
||||
IN IHANDLE *Handle,
|
||||
IN EFI_GUID *Protocol,
|
||||
IN VOID *Interface
|
||||
IN IHANDLE *Handle,
|
||||
IN EFI_GUID *Protocol,
|
||||
IN VOID *Interface
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -960,9 +960,9 @@ SmmFindProtocolInterface (
|
||||
**/
|
||||
PROTOCOL_INTERFACE *
|
||||
SmmRemoveInterfaceFromProtocol (
|
||||
IN IHANDLE *Handle,
|
||||
IN EFI_GUID *Protocol,
|
||||
IN VOID *Interface
|
||||
IN IHANDLE *Handle,
|
||||
IN EFI_GUID *Protocol,
|
||||
IN VOID *Interface
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -979,7 +979,7 @@ SmmRemoveInterfaceFromProtocol (
|
||||
**/
|
||||
BOOLEAN
|
||||
SmmIsSchedulable (
|
||||
IN EFI_SMM_DRIVER_ENTRY *DriverEntry
|
||||
IN EFI_SMM_DRIVER_ENTRY *DriverEntry
|
||||
);
|
||||
|
||||
//
|
||||
@@ -1018,8 +1018,8 @@ SmramProfileInstallProtocol (
|
||||
**/
|
||||
EFI_STATUS
|
||||
RegisterSmramProfileImage (
|
||||
IN EFI_SMM_DRIVER_ENTRY *DriverEntry,
|
||||
IN BOOLEAN RegisterToDxe
|
||||
IN EFI_SMM_DRIVER_ENTRY *DriverEntry,
|
||||
IN BOOLEAN RegisterToDxe
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -1036,8 +1036,8 @@ RegisterSmramProfileImage (
|
||||
**/
|
||||
EFI_STATUS
|
||||
UnregisterSmramProfileImage (
|
||||
IN EFI_SMM_DRIVER_ENTRY *DriverEntry,
|
||||
IN BOOLEAN UnregisterToDxe
|
||||
IN EFI_SMM_DRIVER_ENTRY *DriverEntry,
|
||||
IN BOOLEAN UnregisterToDxe
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -1171,12 +1171,12 @@ SmmCoreInitializeSmiHandlerProfile (
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
SmiHandlerProfileRegisterHandler (
|
||||
IN SMI_HANDLER_PROFILE_PROTOCOL *This,
|
||||
IN EFI_GUID *HandlerGuid,
|
||||
IN EFI_SMM_HANDLER_ENTRY_POINT2 Handler,
|
||||
IN PHYSICAL_ADDRESS CallerAddress,
|
||||
IN VOID *Context OPTIONAL,
|
||||
IN UINTN ContextSize OPTIONAL
|
||||
IN SMI_HANDLER_PROFILE_PROTOCOL *This,
|
||||
IN EFI_GUID *HandlerGuid,
|
||||
IN EFI_SMM_HANDLER_ENTRY_POINT2 Handler,
|
||||
IN PHYSICAL_ADDRESS CallerAddress,
|
||||
IN VOID *Context OPTIONAL,
|
||||
IN UINTN ContextSize OPTIONAL
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -1199,17 +1199,17 @@ SmiHandlerProfileRegisterHandler (
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
SmiHandlerProfileUnregisterHandler (
|
||||
IN SMI_HANDLER_PROFILE_PROTOCOL *This,
|
||||
IN EFI_GUID *HandlerGuid,
|
||||
IN EFI_SMM_HANDLER_ENTRY_POINT2 Handler,
|
||||
IN VOID *Context OPTIONAL,
|
||||
IN UINTN ContextSize OPTIONAL
|
||||
IN SMI_HANDLER_PROFILE_PROTOCOL *This,
|
||||
IN EFI_GUID *HandlerGuid,
|
||||
IN EFI_SMM_HANDLER_ENTRY_POINT2 Handler,
|
||||
IN VOID *Context OPTIONAL,
|
||||
IN UINTN ContextSize OPTIONAL
|
||||
);
|
||||
|
||||
extern UINTN mFullSmramRangeCount;
|
||||
extern EFI_SMRAM_DESCRIPTOR *mFullSmramRanges;
|
||||
extern UINTN mFullSmramRangeCount;
|
||||
extern EFI_SMRAM_DESCRIPTOR *mFullSmramRanges;
|
||||
|
||||
extern EFI_SMM_DRIVER_ENTRY *mSmmCoreDriverEntry;
|
||||
extern EFI_SMM_DRIVER_ENTRY *mSmmCoreDriverEntry;
|
||||
|
||||
extern EFI_LOADED_IMAGE_PROTOCOL *mSmmCoreLoadedImage;
|
||||
|
||||
@@ -1218,8 +1218,8 @@ extern EFI_LOADED_IMAGE_PROTOCOL *mSmmCoreLoadedImage;
|
||||
//
|
||||
|
||||
typedef struct {
|
||||
LIST_ENTRY Link;
|
||||
UINTN NumberOfPages;
|
||||
LIST_ENTRY Link;
|
||||
UINTN NumberOfPages;
|
||||
} FREE_PAGE_LIST;
|
||||
|
||||
extern LIST_ENTRY mSmmMemoryMap;
|
||||
@@ -1245,31 +1245,31 @@ extern LIST_ENTRY mSmmMemoryMap;
|
||||
//
|
||||
#define MAX_POOL_INDEX (MAX_POOL_SHIFT - MIN_POOL_SHIFT + 1)
|
||||
|
||||
#define POOL_HEAD_SIGNATURE SIGNATURE_32('s','p','h','d')
|
||||
#define POOL_HEAD_SIGNATURE SIGNATURE_32('s','p','h','d')
|
||||
|
||||
typedef struct {
|
||||
UINT32 Signature;
|
||||
BOOLEAN Available;
|
||||
EFI_MEMORY_TYPE Type;
|
||||
UINTN Size;
|
||||
UINT32 Signature;
|
||||
BOOLEAN Available;
|
||||
EFI_MEMORY_TYPE Type;
|
||||
UINTN Size;
|
||||
} POOL_HEADER;
|
||||
|
||||
#define POOL_TAIL_SIGNATURE SIGNATURE_32('s','p','t','l')
|
||||
#define POOL_TAIL_SIGNATURE SIGNATURE_32('s','p','t','l')
|
||||
|
||||
typedef struct {
|
||||
UINT32 Signature;
|
||||
UINT32 Reserved;
|
||||
UINTN Size;
|
||||
UINT32 Signature;
|
||||
UINT32 Reserved;
|
||||
UINTN Size;
|
||||
} POOL_TAIL;
|
||||
|
||||
#define POOL_OVERHEAD (sizeof(POOL_HEADER) + sizeof(POOL_TAIL))
|
||||
#define POOL_OVERHEAD (sizeof(POOL_HEADER) + sizeof(POOL_TAIL))
|
||||
|
||||
#define HEAD_TO_TAIL(a) \
|
||||
((POOL_TAIL *) (((CHAR8 *) (a)) + (a)->Size - sizeof(POOL_TAIL)));
|
||||
|
||||
typedef struct {
|
||||
POOL_HEADER Header;
|
||||
LIST_ENTRY Link;
|
||||
POOL_HEADER Header;
|
||||
LIST_ENTRY Link;
|
||||
} FREE_POOL_HEADER;
|
||||
|
||||
typedef enum {
|
||||
@@ -1292,9 +1292,9 @@ extern LIST_ENTRY mSmmPoolLists[SmmPoolTypeMax][MAX_POOL_INDEX];
|
||||
**/
|
||||
UINTN
|
||||
InternalAllocPagesOnOneNode (
|
||||
IN OUT FREE_PAGE_LIST *Pages,
|
||||
IN UINTN NumberOfPages,
|
||||
IN UINTN MaxAddress
|
||||
IN OUT FREE_PAGE_LIST *Pages,
|
||||
IN UINTN NumberOfPages,
|
||||
IN UINTN MaxAddress
|
||||
);
|
||||
|
||||
/**
|
||||
|
@@ -42,26 +42,26 @@
|
||||
/// thos structure.
|
||||
///
|
||||
typedef struct {
|
||||
UINTN Signature;
|
||||
UINTN Signature;
|
||||
|
||||
///
|
||||
/// The ImageHandle passed into the entry point of the SMM IPL. This ImageHandle
|
||||
/// is used by the SMM Core to fill in the ParentImageHandle field of the Loaded
|
||||
/// Image Protocol for each SMM Driver that is dispatched by the SMM Core.
|
||||
///
|
||||
EFI_HANDLE SmmIplImageHandle;
|
||||
EFI_HANDLE SmmIplImageHandle;
|
||||
|
||||
///
|
||||
/// The number of SMRAM ranges passed from the SMM IPL to the SMM Core. The SMM
|
||||
/// Core uses these ranges of SMRAM to initialize the SMM Core memory manager.
|
||||
///
|
||||
UINTN SmramRangeCount;
|
||||
UINTN SmramRangeCount;
|
||||
|
||||
///
|
||||
/// A table of SMRAM ranges passed from the SMM IPL to the SMM Core. The SMM
|
||||
/// Core uses these ranges of SMRAM to initialize the SMM Core memory manager.
|
||||
///
|
||||
EFI_SMRAM_DESCRIPTOR *SmramRanges;
|
||||
EFI_SMRAM_DESCRIPTOR *SmramRanges;
|
||||
|
||||
///
|
||||
/// The SMM Foundation Entry Point. The SMM Core fills in this field when the
|
||||
@@ -72,48 +72,48 @@ typedef struct {
|
||||
/// the SMM Foundation Entry Point as soon as the SMM Configuration Protocol is
|
||||
/// available.
|
||||
///
|
||||
EFI_SMM_ENTRY_POINT SmmEntryPoint;
|
||||
EFI_SMM_ENTRY_POINT SmmEntryPoint;
|
||||
|
||||
///
|
||||
/// Boolean flag set to TRUE while an SMI is being processed by the SMM Core.
|
||||
///
|
||||
BOOLEAN SmmEntryPointRegistered;
|
||||
BOOLEAN SmmEntryPointRegistered;
|
||||
|
||||
///
|
||||
/// Boolean flag set to TRUE while an SMI is being processed by the SMM Core.
|
||||
///
|
||||
BOOLEAN InSmm;
|
||||
BOOLEAN InSmm;
|
||||
|
||||
///
|
||||
/// This field is set by the SMM Core then the SMM Core is initialized. This field is
|
||||
/// used by the SMM Base 2 Protocol and SMM Communication Protocol implementations in
|
||||
/// the SMM IPL.
|
||||
///
|
||||
EFI_SMM_SYSTEM_TABLE2 *Smst;
|
||||
EFI_SMM_SYSTEM_TABLE2 *Smst;
|
||||
|
||||
///
|
||||
/// This field is used by the SMM Communication Protocol to pass a buffer into
|
||||
/// a software SMI handler and for the software SMI handler to pass a buffer back to
|
||||
/// the caller of the SMM Communication Protocol.
|
||||
///
|
||||
VOID *CommunicationBuffer;
|
||||
VOID *CommunicationBuffer;
|
||||
|
||||
///
|
||||
/// This field is used by the SMM Communication Protocol to pass the size of a buffer,
|
||||
/// in bytes, into a software SMI handler and for the software SMI handler to pass the
|
||||
/// size, in bytes, of a buffer back to the caller of the SMM Communication Protocol.
|
||||
///
|
||||
UINTN BufferSize;
|
||||
UINTN BufferSize;
|
||||
|
||||
///
|
||||
/// This field is used by the SMM Communication Protocol to pass the return status from
|
||||
/// a software SMI handler back to the caller of the SMM Communication Protocol.
|
||||
///
|
||||
EFI_STATUS ReturnStatus;
|
||||
EFI_STATUS ReturnStatus;
|
||||
|
||||
EFI_PHYSICAL_ADDRESS PiSmmCoreImageBase;
|
||||
UINT64 PiSmmCoreImageSize;
|
||||
EFI_PHYSICAL_ADDRESS PiSmmCoreEntryPoint;
|
||||
EFI_PHYSICAL_ADDRESS PiSmmCoreImageBase;
|
||||
UINT64 PiSmmCoreImageSize;
|
||||
EFI_PHYSICAL_ADDRESS PiSmmCoreEntryPoint;
|
||||
} SMM_CORE_PRIVATE_DATA;
|
||||
|
||||
#endif
|
||||
|
@@ -140,10 +140,10 @@ SmmCommunicationCommunicate (
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
SmmCommunicationMmCommunicate2 (
|
||||
IN CONST EFI_MM_COMMUNICATION2_PROTOCOL *This,
|
||||
IN OUT VOID *CommBufferPhysical,
|
||||
IN OUT VOID *CommBufferVirtual,
|
||||
IN OUT UINTN *CommSize OPTIONAL
|
||||
IN CONST EFI_MM_COMMUNICATION2_PROTOCOL *This,
|
||||
IN OUT VOID *CommBufferPhysical,
|
||||
IN OUT VOID *CommBufferVirtual,
|
||||
IN OUT UINTN *CommSize OPTIONAL
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -239,13 +239,13 @@ SmmIplSetVirtualAddressNotify (
|
||||
// notifications required by the SMM IPL
|
||||
//
|
||||
typedef struct {
|
||||
BOOLEAN Protocol;
|
||||
BOOLEAN CloseOnLock;
|
||||
EFI_GUID *Guid;
|
||||
EFI_EVENT_NOTIFY NotifyFunction;
|
||||
VOID *NotifyContext;
|
||||
EFI_TPL NotifyTpl;
|
||||
EFI_EVENT Event;
|
||||
BOOLEAN Protocol;
|
||||
BOOLEAN CloseOnLock;
|
||||
EFI_GUID *Guid;
|
||||
EFI_EVENT_NOTIFY NotifyFunction;
|
||||
VOID *NotifyContext;
|
||||
EFI_TPL NotifyTpl;
|
||||
EFI_EVENT Event;
|
||||
} SMM_IPL_EVENT_NOTIFICATION;
|
||||
|
||||
//
|
||||
@@ -309,8 +309,8 @@ BOOLEAN mEndOfDxe = FALSE;
|
||||
EFI_PHYSICAL_ADDRESS mSmramCacheBase;
|
||||
UINT64 mSmramCacheSize;
|
||||
|
||||
EFI_SMM_COMMUNICATE_HEADER mCommunicateHeader;
|
||||
EFI_LOAD_FIXED_ADDRESS_CONFIGURATION_TABLE *mLMFAConfigurationTable = NULL;
|
||||
EFI_SMM_COMMUNICATE_HEADER mCommunicateHeader;
|
||||
EFI_LOAD_FIXED_ADDRESS_CONFIGURATION_TABLE *mLMFAConfigurationTable = NULL;
|
||||
|
||||
//
|
||||
// Table of Protocol notification and GUIDed Event notifications that the SMM IPL requires
|
||||
@@ -389,15 +389,15 @@ SMM_IPL_EVENT_NOTIFICATION mSmmIplEvents[] = {
|
||||
**/
|
||||
VOID
|
||||
GetSmramCacheRange (
|
||||
IN EFI_SMRAM_DESCRIPTOR *SmramRange,
|
||||
OUT EFI_PHYSICAL_ADDRESS *SmramCacheBase,
|
||||
OUT UINT64 *SmramCacheSize
|
||||
IN EFI_SMRAM_DESCRIPTOR *SmramRange,
|
||||
OUT EFI_PHYSICAL_ADDRESS *SmramCacheBase,
|
||||
OUT UINT64 *SmramCacheSize
|
||||
)
|
||||
{
|
||||
UINTN Index;
|
||||
EFI_PHYSICAL_ADDRESS RangeCpuStart;
|
||||
UINT64 RangePhysicalSize;
|
||||
BOOLEAN FoundAjacentRange;
|
||||
UINTN Index;
|
||||
EFI_PHYSICAL_ADDRESS RangeCpuStart;
|
||||
UINT64 RangePhysicalSize;
|
||||
BOOLEAN FoundAjacentRange;
|
||||
|
||||
*SmramCacheBase = SmramRange->CpuStart;
|
||||
*SmramCacheSize = SmramRange->PhysicalSize;
|
||||
@@ -407,17 +407,16 @@ GetSmramCacheRange (
|
||||
for (Index = 0; Index < gSmmCorePrivate->SmramRangeCount; Index++) {
|
||||
RangeCpuStart = gSmmCorePrivate->SmramRanges[Index].CpuStart;
|
||||
RangePhysicalSize = gSmmCorePrivate->SmramRanges[Index].PhysicalSize;
|
||||
if (RangeCpuStart < *SmramCacheBase && *SmramCacheBase == (RangeCpuStart + RangePhysicalSize)) {
|
||||
if ((RangeCpuStart < *SmramCacheBase) && (*SmramCacheBase == (RangeCpuStart + RangePhysicalSize))) {
|
||||
*SmramCacheBase = RangeCpuStart;
|
||||
*SmramCacheSize += RangePhysicalSize;
|
||||
FoundAjacentRange = TRUE;
|
||||
} else if ((*SmramCacheBase + *SmramCacheSize) == RangeCpuStart && RangePhysicalSize > 0) {
|
||||
} else if (((*SmramCacheBase + *SmramCacheSize) == RangeCpuStart) && (RangePhysicalSize > 0)) {
|
||||
*SmramCacheSize += RangePhysicalSize;
|
||||
FoundAjacentRange = TRUE;
|
||||
}
|
||||
}
|
||||
} while (FoundAjacentRange);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -465,7 +464,7 @@ SmmBase2GetSmstLocation (
|
||||
OUT EFI_SMM_SYSTEM_TABLE2 **Smst
|
||||
)
|
||||
{
|
||||
if ((This == NULL) ||(Smst == NULL)) {
|
||||
if ((This == NULL) || (Smst == NULL)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@@ -524,7 +523,7 @@ SmmCommunicationCommunicate (
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
CommunicateHeader = (EFI_SMM_COMMUNICATE_HEADER *) CommBuffer;
|
||||
CommunicateHeader = (EFI_SMM_COMMUNICATE_HEADER *)CommBuffer;
|
||||
|
||||
if (CommSize == NULL) {
|
||||
TempCommSize = OFFSET_OF (EFI_SMM_COMMUNICATE_HEADER, Data) + CommunicateHeader->MessageLength;
|
||||
@@ -562,6 +561,7 @@ SmmCommunicationCommunicate (
|
||||
if (CommSize != NULL) {
|
||||
*CommSize = gSmmCorePrivate->BufferSize;
|
||||
}
|
||||
|
||||
return gSmmCorePrivate->ReturnStatus;
|
||||
}
|
||||
|
||||
@@ -571,7 +571,7 @@ SmmCommunicationCommunicate (
|
||||
// has been called, then a direct invocation of the Software SMI is not allowed,
|
||||
// so return EFI_INVALID_PARAMETER.
|
||||
//
|
||||
if (EfiGoneVirtual()) {
|
||||
if (EfiGoneVirtual ()) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@@ -585,19 +585,19 @@ SmmCommunicationCommunicate (
|
||||
//
|
||||
// Save current InSmm state and set InSmm state to TRUE
|
||||
//
|
||||
OldInSmm = gSmmCorePrivate->InSmm;
|
||||
OldInSmm = gSmmCorePrivate->InSmm;
|
||||
gSmmCorePrivate->InSmm = TRUE;
|
||||
|
||||
//
|
||||
// Before SetVirtualAddressMap(), we are in SMM or SMRAM is open and unlocked, call SmiManage() directly.
|
||||
//
|
||||
TempCommSize -= OFFSET_OF (EFI_SMM_COMMUNICATE_HEADER, Data);
|
||||
Status = gSmmCorePrivate->Smst->SmiManage (
|
||||
&CommunicateHeader->HeaderGuid,
|
||||
NULL,
|
||||
CommunicateHeader->Data,
|
||||
&TempCommSize
|
||||
);
|
||||
Status = gSmmCorePrivate->Smst->SmiManage (
|
||||
&CommunicateHeader->HeaderGuid,
|
||||
NULL,
|
||||
CommunicateHeader->Data,
|
||||
&TempCommSize
|
||||
);
|
||||
TempCommSize += OFFSET_OF (EFI_SMM_COMMUNICATE_HEADER, Data);
|
||||
if (CommSize != NULL) {
|
||||
*CommSize = TempCommSize;
|
||||
@@ -638,15 +638,17 @@ SmmCommunicationCommunicate (
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
SmmCommunicationMmCommunicate2 (
|
||||
IN CONST EFI_MM_COMMUNICATION2_PROTOCOL *This,
|
||||
IN OUT VOID *CommBufferPhysical,
|
||||
IN OUT VOID *CommBufferVirtual,
|
||||
IN OUT UINTN *CommSize OPTIONAL
|
||||
IN CONST EFI_MM_COMMUNICATION2_PROTOCOL *This,
|
||||
IN OUT VOID *CommBufferPhysical,
|
||||
IN OUT VOID *CommBufferVirtual,
|
||||
IN OUT UINTN *CommSize OPTIONAL
|
||||
)
|
||||
{
|
||||
return SmmCommunicationCommunicate (&mSmmCommunication,
|
||||
CommBufferPhysical,
|
||||
CommSize);
|
||||
return SmmCommunicationCommunicate (
|
||||
&mSmmCommunication,
|
||||
CommBufferPhysical,
|
||||
CommSize
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -663,14 +665,14 @@ SmmIplGuidedEventNotify (
|
||||
IN VOID *Context
|
||||
)
|
||||
{
|
||||
UINTN Size;
|
||||
UINTN Size;
|
||||
|
||||
//
|
||||
// Use Guid to initialize EFI_SMM_COMMUNICATE_HEADER structure
|
||||
//
|
||||
CopyGuid (&mCommunicateHeader.HeaderGuid, (EFI_GUID *)Context);
|
||||
mCommunicateHeader.MessageLength = 1;
|
||||
mCommunicateHeader.Data[0] = 0;
|
||||
mCommunicateHeader.Data[0] = 0;
|
||||
|
||||
//
|
||||
// Generate the Software SMI and return the result
|
||||
@@ -710,8 +712,8 @@ SmmIplDxeDispatchEventNotify (
|
||||
IN VOID *Context
|
||||
)
|
||||
{
|
||||
UINTN Size;
|
||||
EFI_STATUS Status;
|
||||
UINTN Size;
|
||||
EFI_STATUS Status;
|
||||
|
||||
//
|
||||
// Keep calling the SMM Core Dispatcher until there is no request to restart it.
|
||||
@@ -724,7 +726,7 @@ SmmIplDxeDispatchEventNotify (
|
||||
//
|
||||
CopyGuid (&mCommunicateHeader.HeaderGuid, (EFI_GUID *)Context);
|
||||
mCommunicateHeader.MessageLength = 1;
|
||||
mCommunicateHeader.Data[0] = 0;
|
||||
mCommunicateHeader.Data[0] = 0;
|
||||
|
||||
//
|
||||
// Generate the Software SMI and return the result
|
||||
@@ -911,89 +913,94 @@ SmmIplSetVirtualAddressNotify (
|
||||
@retval EFI_NOT_FOUND The image has no assigned fixed loading address.
|
||||
**/
|
||||
EFI_STATUS
|
||||
GetPeCoffImageFixLoadingAssignedAddress(
|
||||
GetPeCoffImageFixLoadingAssignedAddress (
|
||||
IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
|
||||
)
|
||||
{
|
||||
UINTN SectionHeaderOffset;
|
||||
EFI_STATUS Status;
|
||||
EFI_IMAGE_SECTION_HEADER SectionHeader;
|
||||
EFI_IMAGE_OPTIONAL_HEADER_UNION *ImgHdr;
|
||||
EFI_PHYSICAL_ADDRESS FixLoadingAddress;
|
||||
UINT16 Index;
|
||||
UINTN Size;
|
||||
UINT16 NumberOfSections;
|
||||
EFI_PHYSICAL_ADDRESS SmramBase;
|
||||
UINT64 SmmCodeSize;
|
||||
UINT64 ValueInSectionHeader;
|
||||
//
|
||||
// Build tool will calculate the smm code size and then patch the PcdLoadFixAddressSmmCodePageNumber
|
||||
//
|
||||
SmmCodeSize = EFI_PAGES_TO_SIZE (PcdGet32(PcdLoadFixAddressSmmCodePageNumber));
|
||||
UINTN SectionHeaderOffset;
|
||||
EFI_STATUS Status;
|
||||
EFI_IMAGE_SECTION_HEADER SectionHeader;
|
||||
EFI_IMAGE_OPTIONAL_HEADER_UNION *ImgHdr;
|
||||
EFI_PHYSICAL_ADDRESS FixLoadingAddress;
|
||||
UINT16 Index;
|
||||
UINTN Size;
|
||||
UINT16 NumberOfSections;
|
||||
EFI_PHYSICAL_ADDRESS SmramBase;
|
||||
UINT64 SmmCodeSize;
|
||||
UINT64 ValueInSectionHeader;
|
||||
|
||||
FixLoadingAddress = 0;
|
||||
Status = EFI_NOT_FOUND;
|
||||
SmramBase = mLMFAConfigurationTable->SmramBase;
|
||||
//
|
||||
// Get PeHeader pointer
|
||||
//
|
||||
ImgHdr = (EFI_IMAGE_OPTIONAL_HEADER_UNION *)((CHAR8* )ImageContext->Handle + ImageContext->PeCoffHeaderOffset);
|
||||
SectionHeaderOffset = ImageContext->PeCoffHeaderOffset +
|
||||
sizeof (UINT32) +
|
||||
sizeof (EFI_IMAGE_FILE_HEADER) +
|
||||
ImgHdr->Pe32.FileHeader.SizeOfOptionalHeader;
|
||||
NumberOfSections = ImgHdr->Pe32.FileHeader.NumberOfSections;
|
||||
//
|
||||
// Build tool will calculate the smm code size and then patch the PcdLoadFixAddressSmmCodePageNumber
|
||||
//
|
||||
SmmCodeSize = EFI_PAGES_TO_SIZE (PcdGet32 (PcdLoadFixAddressSmmCodePageNumber));
|
||||
|
||||
//
|
||||
// Get base address from the first section header that doesn't point to code section.
|
||||
//
|
||||
for (Index = 0; Index < NumberOfSections; Index++) {
|
||||
//
|
||||
// Read section header from file
|
||||
//
|
||||
Size = sizeof (EFI_IMAGE_SECTION_HEADER);
|
||||
Status = ImageContext->ImageRead (
|
||||
ImageContext->Handle,
|
||||
SectionHeaderOffset,
|
||||
&Size,
|
||||
&SectionHeader
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
FixLoadingAddress = 0;
|
||||
Status = EFI_NOT_FOUND;
|
||||
SmramBase = mLMFAConfigurationTable->SmramBase;
|
||||
//
|
||||
// Get PeHeader pointer
|
||||
//
|
||||
ImgHdr = (EFI_IMAGE_OPTIONAL_HEADER_UNION *)((CHAR8 *)ImageContext->Handle + ImageContext->PeCoffHeaderOffset);
|
||||
SectionHeaderOffset = ImageContext->PeCoffHeaderOffset +
|
||||
sizeof (UINT32) +
|
||||
sizeof (EFI_IMAGE_FILE_HEADER) +
|
||||
ImgHdr->Pe32.FileHeader.SizeOfOptionalHeader;
|
||||
NumberOfSections = ImgHdr->Pe32.FileHeader.NumberOfSections;
|
||||
|
||||
Status = EFI_NOT_FOUND;
|
||||
//
|
||||
// Get base address from the first section header that doesn't point to code section.
|
||||
//
|
||||
for (Index = 0; Index < NumberOfSections; Index++) {
|
||||
//
|
||||
// Read section header from file
|
||||
//
|
||||
Size = sizeof (EFI_IMAGE_SECTION_HEADER);
|
||||
Status = ImageContext->ImageRead (
|
||||
ImageContext->Handle,
|
||||
SectionHeaderOffset,
|
||||
&Size,
|
||||
&SectionHeader
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
if ((SectionHeader.Characteristics & EFI_IMAGE_SCN_CNT_CODE) == 0) {
|
||||
//
|
||||
// Build tool saves the offset to SMRAM base as image base in PointerToRelocations & PointerToLineNumbers fields in the
|
||||
// first section header that doesn't point to code section in image header. And there is an assumption that when the
|
||||
// feature is enabled, if a module is assigned a loading address by tools, PointerToRelocations & PointerToLineNumbers
|
||||
// fields should NOT be Zero, or else, these 2 fields should be set to Zero
|
||||
//
|
||||
ValueInSectionHeader = ReadUnaligned64((UINT64*)&SectionHeader.PointerToRelocations);
|
||||
if (ValueInSectionHeader != 0) {
|
||||
//
|
||||
// Found first section header that doesn't point to code section in which build tool saves the
|
||||
// offset to SMRAM base as image base in PointerToRelocations & PointerToLineNumbers fields
|
||||
//
|
||||
FixLoadingAddress = (EFI_PHYSICAL_ADDRESS)(SmramBase + (INT64)ValueInSectionHeader);
|
||||
Status = EFI_NOT_FOUND;
|
||||
|
||||
if (SmramBase + SmmCodeSize > FixLoadingAddress && SmramBase <= FixLoadingAddress) {
|
||||
//
|
||||
// The assigned address is valid. Return the specified loading address
|
||||
//
|
||||
ImageContext->ImageAddress = FixLoadingAddress;
|
||||
Status = EFI_SUCCESS;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
SectionHeaderOffset += sizeof (EFI_IMAGE_SECTION_HEADER);
|
||||
}
|
||||
DEBUG ((DEBUG_INFO|DEBUG_LOAD, "LOADING MODULE FIXED INFO: Loading module at fixed address %x, Status = %r \n", FixLoadingAddress, Status));
|
||||
return Status;
|
||||
if ((SectionHeader.Characteristics & EFI_IMAGE_SCN_CNT_CODE) == 0) {
|
||||
//
|
||||
// Build tool saves the offset to SMRAM base as image base in PointerToRelocations & PointerToLineNumbers fields in the
|
||||
// first section header that doesn't point to code section in image header. And there is an assumption that when the
|
||||
// feature is enabled, if a module is assigned a loading address by tools, PointerToRelocations & PointerToLineNumbers
|
||||
// fields should NOT be Zero, or else, these 2 fields should be set to Zero
|
||||
//
|
||||
ValueInSectionHeader = ReadUnaligned64 ((UINT64 *)&SectionHeader.PointerToRelocations);
|
||||
if (ValueInSectionHeader != 0) {
|
||||
//
|
||||
// Found first section header that doesn't point to code section in which build tool saves the
|
||||
// offset to SMRAM base as image base in PointerToRelocations & PointerToLineNumbers fields
|
||||
//
|
||||
FixLoadingAddress = (EFI_PHYSICAL_ADDRESS)(SmramBase + (INT64)ValueInSectionHeader);
|
||||
|
||||
if ((SmramBase + SmmCodeSize > FixLoadingAddress) && (SmramBase <= FixLoadingAddress)) {
|
||||
//
|
||||
// The assigned address is valid. Return the specified loading address
|
||||
//
|
||||
ImageContext->ImageAddress = FixLoadingAddress;
|
||||
Status = EFI_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
SectionHeaderOffset += sizeof (EFI_IMAGE_SECTION_HEADER);
|
||||
}
|
||||
|
||||
DEBUG ((DEBUG_INFO|DEBUG_LOAD, "LOADING MODULE FIXED INFO: Loading module at fixed address %x, Status = %r \n", FixLoadingAddress, Status));
|
||||
return Status;
|
||||
}
|
||||
|
||||
/**
|
||||
Load the SMM Core image into SMRAM and executes the SMM Core from SMRAM.
|
||||
|
||||
@@ -1009,9 +1016,9 @@ GetPeCoffImageFixLoadingAssignedAddress(
|
||||
**/
|
||||
EFI_STATUS
|
||||
ExecuteSmmCoreFromSmram (
|
||||
IN OUT EFI_SMRAM_DESCRIPTOR *SmramRange,
|
||||
IN OUT EFI_SMRAM_DESCRIPTOR *SmramRangeSmmCore,
|
||||
IN VOID *Context
|
||||
IN OUT EFI_SMRAM_DESCRIPTOR *SmramRange,
|
||||
IN OUT EFI_SMRAM_DESCRIPTOR *SmramRangeSmmCore,
|
||||
IN VOID *Context
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
@@ -1049,11 +1056,12 @@ ExecuteSmmCoreFromSmram (
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
//
|
||||
// if Loading module at Fixed Address feature is enabled, the SMM core driver will be loaded to
|
||||
// the address assigned by build tool.
|
||||
//
|
||||
if (PcdGet64(PcdLoadModuleAtFixAddressEnable) != 0) {
|
||||
if (PcdGet64 (PcdLoadModuleAtFixAddressEnable) != 0) {
|
||||
//
|
||||
// Get the fixed loading address assigned by Build tool
|
||||
//
|
||||
@@ -1066,23 +1074,23 @@ ExecuteSmmCoreFromSmram (
|
||||
//
|
||||
// Reserved Smram Region for SmmCore is not used, and remove it from SmramRangeCount.
|
||||
//
|
||||
gSmmCorePrivate->SmramRangeCount --;
|
||||
gSmmCorePrivate->SmramRangeCount--;
|
||||
} else {
|
||||
DEBUG ((DEBUG_INFO, "LOADING MODULE FIXED ERROR: Loading module at fixed address at address failed\n"));
|
||||
//
|
||||
// Allocate memory for the image being loaded from the EFI_SRAM_DESCRIPTOR
|
||||
// specified by SmramRange
|
||||
//
|
||||
PageCount = (UINTN)EFI_SIZE_TO_PAGES((UINTN)ImageContext.ImageSize + ImageContext.SectionAlignment);
|
||||
PageCount = (UINTN)EFI_SIZE_TO_PAGES ((UINTN)ImageContext.ImageSize + ImageContext.SectionAlignment);
|
||||
|
||||
ASSERT ((SmramRange->PhysicalSize & EFI_PAGE_MASK) == 0);
|
||||
ASSERT (SmramRange->PhysicalSize > EFI_PAGES_TO_SIZE (PageCount));
|
||||
|
||||
SmramRange->PhysicalSize -= EFI_PAGES_TO_SIZE (PageCount);
|
||||
SmramRangeSmmCore->CpuStart = SmramRange->CpuStart + SmramRange->PhysicalSize;
|
||||
SmramRange->PhysicalSize -= EFI_PAGES_TO_SIZE (PageCount);
|
||||
SmramRangeSmmCore->CpuStart = SmramRange->CpuStart + SmramRange->PhysicalSize;
|
||||
SmramRangeSmmCore->PhysicalStart = SmramRange->PhysicalStart + SmramRange->PhysicalSize;
|
||||
SmramRangeSmmCore->RegionState = SmramRange->RegionState | EFI_ALLOCATED;
|
||||
SmramRangeSmmCore->PhysicalSize = EFI_PAGES_TO_SIZE (PageCount);
|
||||
SmramRangeSmmCore->RegionState = SmramRange->RegionState | EFI_ALLOCATED;
|
||||
SmramRangeSmmCore->PhysicalSize = EFI_PAGES_TO_SIZE (PageCount);
|
||||
|
||||
//
|
||||
// Align buffer on section boundary
|
||||
@@ -1094,16 +1102,16 @@ ExecuteSmmCoreFromSmram (
|
||||
// Allocate memory for the image being loaded from the EFI_SRAM_DESCRIPTOR
|
||||
// specified by SmramRange
|
||||
//
|
||||
PageCount = (UINTN)EFI_SIZE_TO_PAGES((UINTN)ImageContext.ImageSize + ImageContext.SectionAlignment);
|
||||
PageCount = (UINTN)EFI_SIZE_TO_PAGES ((UINTN)ImageContext.ImageSize + ImageContext.SectionAlignment);
|
||||
|
||||
ASSERT ((SmramRange->PhysicalSize & EFI_PAGE_MASK) == 0);
|
||||
ASSERT (SmramRange->PhysicalSize > EFI_PAGES_TO_SIZE (PageCount));
|
||||
|
||||
SmramRange->PhysicalSize -= EFI_PAGES_TO_SIZE (PageCount);
|
||||
SmramRangeSmmCore->CpuStart = SmramRange->CpuStart + SmramRange->PhysicalSize;
|
||||
SmramRange->PhysicalSize -= EFI_PAGES_TO_SIZE (PageCount);
|
||||
SmramRangeSmmCore->CpuStart = SmramRange->CpuStart + SmramRange->PhysicalSize;
|
||||
SmramRangeSmmCore->PhysicalStart = SmramRange->PhysicalStart + SmramRange->PhysicalSize;
|
||||
SmramRangeSmmCore->RegionState = SmramRange->RegionState | EFI_ALLOCATED;
|
||||
SmramRangeSmmCore->PhysicalSize = EFI_PAGES_TO_SIZE (PageCount);
|
||||
SmramRangeSmmCore->RegionState = SmramRange->RegionState | EFI_ALLOCATED;
|
||||
SmramRangeSmmCore->PhysicalSize = EFI_PAGES_TO_SIZE (PageCount);
|
||||
|
||||
//
|
||||
// Align buffer on section boundary
|
||||
@@ -1150,7 +1158,7 @@ ExecuteSmmCoreFromSmram (
|
||||
// Execute image
|
||||
//
|
||||
EntryPoint = (EFI_IMAGE_ENTRY_POINT)(UINTN)ImageContext.EntryPoint;
|
||||
Status = EntryPoint ((EFI_HANDLE)Context, gST);
|
||||
Status = EntryPoint ((EFI_HANDLE)Context, gST);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1188,14 +1196,15 @@ SmmSplitSmramEntry (
|
||||
IN OUT UINTN *FinalRangeCount
|
||||
)
|
||||
{
|
||||
UINT64 RangeToCompareEnd;
|
||||
UINT64 ReservedRangeToCompareEnd;
|
||||
UINT64 RangeToCompareEnd;
|
||||
UINT64 ReservedRangeToCompareEnd;
|
||||
|
||||
RangeToCompareEnd = RangeToCompare->CpuStart + RangeToCompare->PhysicalSize;
|
||||
ReservedRangeToCompareEnd = ReservedRangeToCompare->SmramReservedStart + ReservedRangeToCompare->SmramReservedSize;
|
||||
|
||||
if ((RangeToCompare->CpuStart >= ReservedRangeToCompare->SmramReservedStart) &&
|
||||
(RangeToCompare->CpuStart < ReservedRangeToCompareEnd)) {
|
||||
(RangeToCompare->CpuStart < ReservedRangeToCompareEnd))
|
||||
{
|
||||
if (RangeToCompareEnd < ReservedRangeToCompareEnd) {
|
||||
//
|
||||
// RangeToCompare ReservedRangeToCompare
|
||||
@@ -1222,14 +1231,14 @@ SmmSplitSmramEntry (
|
||||
FinalRanges[*FinalRangeCount].PhysicalStart = RangeToCompare->PhysicalStart;
|
||||
FinalRanges[*FinalRangeCount].RegionState = RangeToCompare->RegionState | EFI_ALLOCATED;
|
||||
FinalRanges[*FinalRangeCount].PhysicalSize = RangeToCompare->PhysicalSize;
|
||||
*FinalRangeCount += 1;
|
||||
RangeToCompare->PhysicalSize = 0;
|
||||
*FinalRangeCount += 1;
|
||||
RangeToCompare->PhysicalSize = 0;
|
||||
//
|
||||
// 3. Update ReservedRanges[*ReservedRangeCount] and increment *ReservedRangeCount.
|
||||
//
|
||||
ReservedRanges[*ReservedRangeCount].SmramReservedStart = FinalRanges[*FinalRangeCount - 1].CpuStart + FinalRanges[*FinalRangeCount - 1].PhysicalSize;
|
||||
ReservedRanges[*ReservedRangeCount].SmramReservedSize = ReservedRangeToCompareEnd - RangeToCompareEnd;
|
||||
*ReservedRangeCount += 1;
|
||||
*ReservedRangeCount += 1;
|
||||
} else {
|
||||
//
|
||||
// RangeToCompare ReservedRangeToCompare
|
||||
@@ -1255,7 +1264,7 @@ SmmSplitSmramEntry (
|
||||
FinalRanges[*FinalRangeCount].PhysicalStart = RangeToCompare->PhysicalStart;
|
||||
FinalRanges[*FinalRangeCount].RegionState = RangeToCompare->RegionState | EFI_ALLOCATED;
|
||||
FinalRanges[*FinalRangeCount].PhysicalSize = ReservedRangeToCompareEnd - RangeToCompare->CpuStart;
|
||||
*FinalRangeCount += 1;
|
||||
*FinalRangeCount += 1;
|
||||
//
|
||||
// 3. Update RangeToCompare.
|
||||
//
|
||||
@@ -1264,7 +1273,8 @@ SmmSplitSmramEntry (
|
||||
RangeToCompare->PhysicalSize -= FinalRanges[*FinalRangeCount - 1].PhysicalSize;
|
||||
}
|
||||
} else if ((ReservedRangeToCompare->SmramReservedStart >= RangeToCompare->CpuStart) &&
|
||||
(ReservedRangeToCompare->SmramReservedStart < RangeToCompareEnd)) {
|
||||
(ReservedRangeToCompare->SmramReservedStart < RangeToCompareEnd))
|
||||
{
|
||||
if (ReservedRangeToCompareEnd < RangeToCompareEnd) {
|
||||
//
|
||||
// RangeToCompare ReservedRangeToCompare
|
||||
@@ -1291,8 +1301,8 @@ SmmSplitSmramEntry (
|
||||
FinalRanges[*FinalRangeCount].PhysicalStart = RangeToCompare->PhysicalStart + RangeToCompare->PhysicalSize;
|
||||
FinalRanges[*FinalRangeCount].RegionState = RangeToCompare->RegionState | EFI_ALLOCATED;
|
||||
FinalRanges[*FinalRangeCount].PhysicalSize = ReservedRangeToCompare->SmramReservedSize;
|
||||
*FinalRangeCount += 1;
|
||||
ReservedRangeToCompare->SmramReservedSize = 0;
|
||||
*FinalRangeCount += 1;
|
||||
ReservedRangeToCompare->SmramReservedSize = 0;
|
||||
//
|
||||
// 3. Update Ranges[*RangeCount] and increment *RangeCount.
|
||||
//
|
||||
@@ -1300,7 +1310,7 @@ SmmSplitSmramEntry (
|
||||
Ranges[*RangeCount].PhysicalStart = FinalRanges[*FinalRangeCount - 1].PhysicalStart + FinalRanges[*FinalRangeCount - 1].PhysicalSize;
|
||||
Ranges[*RangeCount].RegionState = RangeToCompare->RegionState;
|
||||
Ranges[*RangeCount].PhysicalSize = RangeToCompareEnd - ReservedRangeToCompareEnd;
|
||||
*RangeCount += 1;
|
||||
*RangeCount += 1;
|
||||
} else {
|
||||
//
|
||||
// RangeToCompare ReservedRangeToCompare
|
||||
@@ -1327,7 +1337,7 @@ SmmSplitSmramEntry (
|
||||
FinalRanges[*FinalRangeCount].PhysicalStart = RangeToCompare->PhysicalStart + RangeToCompare->PhysicalSize;
|
||||
FinalRanges[*FinalRangeCount].RegionState = RangeToCompare->RegionState | EFI_ALLOCATED;
|
||||
FinalRanges[*FinalRangeCount].PhysicalSize = RangeToCompareEnd - ReservedRangeToCompare->SmramReservedStart;
|
||||
*FinalRangeCount += 1;
|
||||
*FinalRangeCount += 1;
|
||||
//
|
||||
// 3. Update ReservedRangeToCompare.
|
||||
//
|
||||
@@ -1353,19 +1363,22 @@ SmmIsSmramOverlap (
|
||||
IN EFI_SMM_RESERVED_SMRAM_REGION *ReservedRangeToCompare
|
||||
)
|
||||
{
|
||||
UINT64 RangeToCompareEnd;
|
||||
UINT64 ReservedRangeToCompareEnd;
|
||||
UINT64 RangeToCompareEnd;
|
||||
UINT64 ReservedRangeToCompareEnd;
|
||||
|
||||
RangeToCompareEnd = RangeToCompare->CpuStart + RangeToCompare->PhysicalSize;
|
||||
ReservedRangeToCompareEnd = ReservedRangeToCompare->SmramReservedStart + ReservedRangeToCompare->SmramReservedSize;
|
||||
|
||||
if ((RangeToCompare->CpuStart >= ReservedRangeToCompare->SmramReservedStart) &&
|
||||
(RangeToCompare->CpuStart < ReservedRangeToCompareEnd)) {
|
||||
(RangeToCompare->CpuStart < ReservedRangeToCompareEnd))
|
||||
{
|
||||
return TRUE;
|
||||
} else if ((ReservedRangeToCompare->SmramReservedStart >= RangeToCompare->CpuStart) &&
|
||||
(ReservedRangeToCompare->SmramReservedStart < RangeToCompareEnd)) {
|
||||
(ReservedRangeToCompare->SmramReservedStart < RangeToCompareEnd))
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -1383,35 +1396,35 @@ SmmIsSmramOverlap (
|
||||
**/
|
||||
EFI_SMRAM_DESCRIPTOR *
|
||||
GetFullSmramRanges (
|
||||
OUT UINTN *FullSmramRangeCount
|
||||
OUT UINTN *FullSmramRangeCount
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_SMM_CONFIGURATION_PROTOCOL *SmmConfiguration;
|
||||
UINTN Size;
|
||||
UINTN Index;
|
||||
UINTN Index2;
|
||||
EFI_SMRAM_DESCRIPTOR *FullSmramRanges;
|
||||
UINTN TempSmramRangeCount;
|
||||
UINTN AdditionSmramRangeCount;
|
||||
EFI_SMRAM_DESCRIPTOR *TempSmramRanges;
|
||||
UINTN SmramRangeCount;
|
||||
EFI_SMRAM_DESCRIPTOR *SmramRanges;
|
||||
UINTN SmramReservedCount;
|
||||
EFI_SMM_RESERVED_SMRAM_REGION *SmramReservedRanges;
|
||||
UINTN MaxCount;
|
||||
BOOLEAN Rescan;
|
||||
EFI_STATUS Status;
|
||||
EFI_SMM_CONFIGURATION_PROTOCOL *SmmConfiguration;
|
||||
UINTN Size;
|
||||
UINTN Index;
|
||||
UINTN Index2;
|
||||
EFI_SMRAM_DESCRIPTOR *FullSmramRanges;
|
||||
UINTN TempSmramRangeCount;
|
||||
UINTN AdditionSmramRangeCount;
|
||||
EFI_SMRAM_DESCRIPTOR *TempSmramRanges;
|
||||
UINTN SmramRangeCount;
|
||||
EFI_SMRAM_DESCRIPTOR *SmramRanges;
|
||||
UINTN SmramReservedCount;
|
||||
EFI_SMM_RESERVED_SMRAM_REGION *SmramReservedRanges;
|
||||
UINTN MaxCount;
|
||||
BOOLEAN Rescan;
|
||||
|
||||
//
|
||||
// Get SMM Configuration Protocol if it is present.
|
||||
//
|
||||
SmmConfiguration = NULL;
|
||||
Status = gBS->LocateProtocol (&gEfiSmmConfigurationProtocolGuid, NULL, (VOID **) &SmmConfiguration);
|
||||
Status = gBS->LocateProtocol (&gEfiSmmConfigurationProtocolGuid, NULL, (VOID **)&SmmConfiguration);
|
||||
|
||||
//
|
||||
// Get SMRAM information.
|
||||
//
|
||||
Size = 0;
|
||||
Size = 0;
|
||||
Status = mSmmAccess->GetCapabilities (mSmmAccess, &Size, NULL);
|
||||
ASSERT (Status == EFI_BUFFER_TOO_SMALL);
|
||||
|
||||
@@ -1431,7 +1444,7 @@ GetFullSmramRanges (
|
||||
// Reserve one entry for SMM Core in the full SMRAM ranges.
|
||||
//
|
||||
AdditionSmramRangeCount = 1;
|
||||
if (PcdGet64(PcdLoadModuleAtFixAddressEnable) != 0) {
|
||||
if (PcdGet64 (PcdLoadModuleAtFixAddressEnable) != 0) {
|
||||
//
|
||||
// Reserve two entries for all SMM drivers and SMM Core in the full SMRAM ranges.
|
||||
//
|
||||
@@ -1443,8 +1456,8 @@ GetFullSmramRanges (
|
||||
// No reserved SMRAM entry from SMM Configuration Protocol.
|
||||
//
|
||||
*FullSmramRangeCount = SmramRangeCount + AdditionSmramRangeCount;
|
||||
Size = (*FullSmramRangeCount) * sizeof (EFI_SMRAM_DESCRIPTOR);
|
||||
FullSmramRanges = (EFI_SMRAM_DESCRIPTOR *) AllocateZeroPool (Size);
|
||||
Size = (*FullSmramRangeCount) * sizeof (EFI_SMRAM_DESCRIPTOR);
|
||||
FullSmramRanges = (EFI_SMRAM_DESCRIPTOR *)AllocateZeroPool (Size);
|
||||
ASSERT (FullSmramRanges != NULL);
|
||||
|
||||
Status = mSmmAccess->GetCapabilities (mSmmAccess, &Size, FullSmramRanges);
|
||||
@@ -1490,19 +1503,19 @@ GetFullSmramRanges (
|
||||
//
|
||||
MaxCount = SmramRangeCount + 2 * SmramReservedCount;
|
||||
|
||||
Size = MaxCount * sizeof (EFI_SMM_RESERVED_SMRAM_REGION);
|
||||
SmramReservedRanges = (EFI_SMM_RESERVED_SMRAM_REGION *) AllocatePool (Size);
|
||||
Size = MaxCount * sizeof (EFI_SMM_RESERVED_SMRAM_REGION);
|
||||
SmramReservedRanges = (EFI_SMM_RESERVED_SMRAM_REGION *)AllocatePool (Size);
|
||||
ASSERT (SmramReservedRanges != NULL);
|
||||
for (Index = 0; Index < SmramReservedCount; Index++) {
|
||||
CopyMem (&SmramReservedRanges[Index], &SmmConfiguration->SmramReservedRegions[Index], sizeof (EFI_SMM_RESERVED_SMRAM_REGION));
|
||||
}
|
||||
|
||||
Size = MaxCount * sizeof (EFI_SMRAM_DESCRIPTOR);
|
||||
TempSmramRanges = (EFI_SMRAM_DESCRIPTOR *) AllocatePool (Size);
|
||||
Size = MaxCount * sizeof (EFI_SMRAM_DESCRIPTOR);
|
||||
TempSmramRanges = (EFI_SMRAM_DESCRIPTOR *)AllocatePool (Size);
|
||||
ASSERT (TempSmramRanges != NULL);
|
||||
TempSmramRangeCount = 0;
|
||||
|
||||
SmramRanges = (EFI_SMRAM_DESCRIPTOR *) AllocatePool (Size);
|
||||
SmramRanges = (EFI_SMRAM_DESCRIPTOR *)AllocatePool (Size);
|
||||
ASSERT (SmramRanges != NULL);
|
||||
Status = mSmmAccess->GetCapabilities (mSmmAccess, &Size, SmramRanges);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
@@ -1522,7 +1535,8 @@ GetFullSmramRanges (
|
||||
if (SmmIsSmramOverlap (
|
||||
&SmramRanges[Index],
|
||||
&SmramReservedRanges[Index2]
|
||||
)) {
|
||||
))
|
||||
{
|
||||
//
|
||||
// There is overlap, need to split entry and then rescan.
|
||||
//
|
||||
@@ -1540,6 +1554,7 @@ GetFullSmramRanges (
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!Rescan) {
|
||||
//
|
||||
// No any overlap, copy the entry to the temp SMRAM ranges.
|
||||
@@ -1551,6 +1566,7 @@ GetFullSmramRanges (
|
||||
}
|
||||
}
|
||||
} while (Rescan);
|
||||
|
||||
ASSERT (TempSmramRangeCount <= MaxCount);
|
||||
|
||||
//
|
||||
@@ -1565,16 +1581,19 @@ GetFullSmramRanges (
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
ASSERT (Index < TempSmramRangeCount);
|
||||
for (Index2 = 0; Index2 < TempSmramRangeCount; Index2++) {
|
||||
if ((Index2 != Index) && (TempSmramRanges[Index2].PhysicalSize != 0) && (TempSmramRanges[Index2].CpuStart < TempSmramRanges[Index].CpuStart)) {
|
||||
Index = Index2;
|
||||
}
|
||||
}
|
||||
|
||||
CopyMem (&FullSmramRanges[*FullSmramRangeCount], &TempSmramRanges[Index], sizeof (EFI_SMRAM_DESCRIPTOR));
|
||||
*FullSmramRangeCount += 1;
|
||||
*FullSmramRangeCount += 1;
|
||||
TempSmramRanges[Index].PhysicalSize = 0;
|
||||
} while (*FullSmramRangeCount < TempSmramRangeCount);
|
||||
|
||||
ASSERT (*FullSmramRangeCount == TempSmramRangeCount);
|
||||
*FullSmramRangeCount += AdditionSmramRangeCount;
|
||||
|
||||
@@ -1606,15 +1625,15 @@ SmmIplEntry (
|
||||
IN EFI_SYSTEM_TABLE *SystemTable
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
UINTN Index;
|
||||
UINT64 MaxSize;
|
||||
VOID *Registration;
|
||||
UINT64 SmmCodeSize;
|
||||
EFI_CPU_ARCH_PROTOCOL *CpuArch;
|
||||
EFI_STATUS SetAttrStatus;
|
||||
EFI_SMRAM_DESCRIPTOR *SmramRangeSmmDriver;
|
||||
EFI_GCD_MEMORY_SPACE_DESCRIPTOR MemDesc;
|
||||
EFI_STATUS Status;
|
||||
UINTN Index;
|
||||
UINT64 MaxSize;
|
||||
VOID *Registration;
|
||||
UINT64 SmmCodeSize;
|
||||
EFI_CPU_ARCH_PROTOCOL *CpuArch;
|
||||
EFI_STATUS SetAttrStatus;
|
||||
EFI_SMRAM_DESCRIPTOR *SmramRangeSmmDriver;
|
||||
EFI_GCD_MEMORY_SPACE_DESCRIPTOR MemDesc;
|
||||
|
||||
//
|
||||
// Fill in the image handle of the SMM IPL so the SMM Core can use this as the
|
||||
@@ -1663,7 +1682,7 @@ SmmIplEntry (
|
||||
if (gSmmCorePrivate->SmramRanges[Index].CpuStart >= BASE_1MB) {
|
||||
if ((gSmmCorePrivate->SmramRanges[Index].CpuStart + gSmmCorePrivate->SmramRanges[Index].PhysicalSize - 1) <= MAX_ADDRESS) {
|
||||
if (gSmmCorePrivate->SmramRanges[Index].PhysicalSize >= MaxSize) {
|
||||
MaxSize = gSmmCorePrivate->SmramRanges[Index].PhysicalSize;
|
||||
MaxSize = gSmmCorePrivate->SmramRanges[Index].PhysicalSize;
|
||||
mCurrentSmramRange = &gSmmCorePrivate->SmramRanges[Index];
|
||||
}
|
||||
}
|
||||
@@ -1674,7 +1693,9 @@ SmmIplEntry (
|
||||
//
|
||||
// Print debug message showing SMRAM window that will be used by SMM IPL and SMM Core
|
||||
//
|
||||
DEBUG ((DEBUG_INFO, "SMM IPL found SMRAM window %p - %p\n",
|
||||
DEBUG ((
|
||||
DEBUG_INFO,
|
||||
"SMM IPL found SMRAM window %p - %p\n",
|
||||
(VOID *)(UINTN)mCurrentSmramRange->CpuStart,
|
||||
(VOID *)(UINTN)(mCurrentSmramRange->CpuStart + mCurrentSmramRange->PhysicalSize - 1)
|
||||
));
|
||||
@@ -1695,6 +1716,7 @@ SmmIplEntry (
|
||||
MemDesc.Capabilities | SMRAM_CAPABILITIES
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// If CPU AP is present, attempt to set SMRAM cacheability to WB and clear
|
||||
// all paging attributes.
|
||||
@@ -1702,15 +1724,15 @@ SmmIplEntry (
|
||||
// is not available here.
|
||||
//
|
||||
CpuArch = NULL;
|
||||
Status = gBS->LocateProtocol (&gEfiCpuArchProtocolGuid, NULL, (VOID **)&CpuArch);
|
||||
Status = gBS->LocateProtocol (&gEfiCpuArchProtocolGuid, NULL, (VOID **)&CpuArch);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
MemDesc.Attributes &= ~(EFI_CACHE_ATTRIBUTE_MASK | EFI_MEMORY_ATTRIBUTE_MASK);
|
||||
MemDesc.Attributes |= EFI_MEMORY_WB;
|
||||
Status = gDS->SetMemorySpaceAttributes (
|
||||
mSmramCacheBase,
|
||||
mSmramCacheSize,
|
||||
MemDesc.Attributes
|
||||
);
|
||||
Status = gDS->SetMemorySpaceAttributes (
|
||||
mSmramCacheBase,
|
||||
mSmramCacheSize,
|
||||
MemDesc.Attributes
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG ((DEBUG_WARN, "SMM IPL failed to set SMRAM window to EFI_MEMORY_WB\n"));
|
||||
}
|
||||
@@ -1722,17 +1744,18 @@ SmmIplEntry (
|
||||
);
|
||||
DEBUG ((DEBUG_INFO, "SMRAM attributes: %016lx\n", MemDesc.Attributes));
|
||||
ASSERT ((MemDesc.Attributes & EFI_MEMORY_ATTRIBUTE_MASK) == 0);
|
||||
);
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// if Loading module at Fixed Address feature is enabled, save the SMRAM base to Load
|
||||
// Modules At Fixed Address Configuration Table.
|
||||
//
|
||||
if (PcdGet64(PcdLoadModuleAtFixAddressEnable) != 0) {
|
||||
if (PcdGet64 (PcdLoadModuleAtFixAddressEnable) != 0) {
|
||||
//
|
||||
// Build tool will calculate the smm code size and then patch the PcdLoadFixAddressSmmCodePageNumber
|
||||
//
|
||||
SmmCodeSize = LShiftU64 (PcdGet32(PcdLoadFixAddressSmmCodePageNumber), EFI_PAGE_SHIFT);
|
||||
SmmCodeSize = LShiftU64 (PcdGet32 (PcdLoadFixAddressSmmCodePageNumber), EFI_PAGE_SHIFT);
|
||||
//
|
||||
// The SMRAM available memory is assumed to be larger than SmmCodeSize
|
||||
//
|
||||
@@ -1741,10 +1764,10 @@ SmmIplEntry (
|
||||
// Retrieve Load modules At fixed address configuration table and save the SMRAM base.
|
||||
//
|
||||
Status = EfiGetSystemConfigurationTable (
|
||||
&gLoadFixedAddressConfigurationTableGuid,
|
||||
(VOID **) &mLMFAConfigurationTable
|
||||
);
|
||||
if (!EFI_ERROR (Status) && mLMFAConfigurationTable != NULL) {
|
||||
&gLoadFixedAddressConfigurationTableGuid,
|
||||
(VOID **)&mLMFAConfigurationTable
|
||||
);
|
||||
if (!EFI_ERROR (Status) && (mLMFAConfigurationTable != NULL)) {
|
||||
mLMFAConfigurationTable->SmramBase = mCurrentSmramRange->CpuStart;
|
||||
//
|
||||
// Print the SMRAM base
|
||||
@@ -1755,16 +1778,17 @@ SmmIplEntry (
|
||||
//
|
||||
// Fill the Smram range for all SMM code
|
||||
//
|
||||
SmramRangeSmmDriver = &gSmmCorePrivate->SmramRanges[gSmmCorePrivate->SmramRangeCount - 2];
|
||||
SmramRangeSmmDriver = &gSmmCorePrivate->SmramRanges[gSmmCorePrivate->SmramRangeCount - 2];
|
||||
SmramRangeSmmDriver->CpuStart = mCurrentSmramRange->CpuStart;
|
||||
SmramRangeSmmDriver->PhysicalStart = mCurrentSmramRange->PhysicalStart;
|
||||
SmramRangeSmmDriver->RegionState = mCurrentSmramRange->RegionState | EFI_ALLOCATED;
|
||||
SmramRangeSmmDriver->PhysicalSize = SmmCodeSize;
|
||||
|
||||
mCurrentSmramRange->PhysicalSize -= SmmCodeSize;
|
||||
mCurrentSmramRange->CpuStart = mCurrentSmramRange->CpuStart + SmmCodeSize;
|
||||
mCurrentSmramRange->PhysicalStart = mCurrentSmramRange->PhysicalStart + SmmCodeSize;
|
||||
mCurrentSmramRange->PhysicalSize -= SmmCodeSize;
|
||||
mCurrentSmramRange->CpuStart = mCurrentSmramRange->CpuStart + SmmCodeSize;
|
||||
mCurrentSmramRange->PhysicalStart = mCurrentSmramRange->PhysicalStart + SmmCodeSize;
|
||||
}
|
||||
|
||||
//
|
||||
// Load SMM Core into SMRAM and execute it from SMRAM
|
||||
//
|
||||
@@ -1783,7 +1807,7 @@ SmmIplEntry (
|
||||
// Attempt to reset SMRAM cacheability to UC
|
||||
//
|
||||
if (CpuArch != NULL) {
|
||||
SetAttrStatus = gDS->SetMemorySpaceAttributes(
|
||||
SetAttrStatus = gDS->SetMemorySpaceAttributes (
|
||||
mSmramCacheBase,
|
||||
mSmramCacheSize,
|
||||
EFI_MEMORY_UC
|
||||
@@ -1804,7 +1828,7 @@ SmmIplEntry (
|
||||
// If the SMM Core could not be loaded then close SMRAM window, free allocated
|
||||
// resources, and return an error so SMM IPL will be unloaded.
|
||||
//
|
||||
if (mCurrentSmramRange == NULL || EFI_ERROR (Status)) {
|
||||
if ((mCurrentSmramRange == NULL) || EFI_ERROR (Status)) {
|
||||
//
|
||||
// Close all SMRAM ranges
|
||||
//
|
||||
@@ -1829,9 +1853,12 @@ SmmIplEntry (
|
||||
//
|
||||
Status = gBS->InstallMultipleProtocolInterfaces (
|
||||
&mSmmIplHandle,
|
||||
&gEfiSmmBase2ProtocolGuid, &mSmmBase2,
|
||||
&gEfiSmmCommunicationProtocolGuid, &mSmmCommunication,
|
||||
&gEfiMmCommunication2ProtocolGuid, &mMmCommunication2,
|
||||
&gEfiSmmBase2ProtocolGuid,
|
||||
&mSmmBase2,
|
||||
&gEfiSmmCommunicationProtocolGuid,
|
||||
&mSmmCommunication,
|
||||
&gEfiMmCommunication2ProtocolGuid,
|
||||
&mMmCommunication2,
|
||||
NULL
|
||||
);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
@@ -1846,8 +1873,8 @@ SmmIplEntry (
|
||||
mSmmIplEvents[Index].NotifyTpl,
|
||||
mSmmIplEvents[Index].NotifyFunction,
|
||||
mSmmIplEvents[Index].NotifyContext,
|
||||
&Registration
|
||||
);
|
||||
&Registration
|
||||
);
|
||||
} else {
|
||||
Status = gBS->CreateEventEx (
|
||||
EVT_NOTIFY_SIGNAL,
|
||||
|
@@ -13,7 +13,7 @@ LIST_ENTRY mSmmPoolLists[SmmPoolTypeMax][MAX_POOL_INDEX];
|
||||
// To cache the SMRAM base since when Loading modules At fixed address feature is enabled,
|
||||
// all module is assigned an offset relative the SMRAM base in build time.
|
||||
//
|
||||
GLOBAL_REMOVE_IF_UNREFERENCED EFI_PHYSICAL_ADDRESS gLoadModuleAtFixAddressSmramBase = 0;
|
||||
GLOBAL_REMOVE_IF_UNREFERENCED EFI_PHYSICAL_ADDRESS gLoadModuleAtFixAddressSmramBase = 0;
|
||||
|
||||
/**
|
||||
Convert a UEFI memory type to SMM pool type.
|
||||
@@ -24,21 +24,20 @@ GLOBAL_REMOVE_IF_UNREFERENCED EFI_PHYSICAL_ADDRESS gLoadModuleAtFixAddres
|
||||
**/
|
||||
SMM_POOL_TYPE
|
||||
UefiMemoryTypeToSmmPoolType (
|
||||
IN EFI_MEMORY_TYPE MemoryType
|
||||
IN EFI_MEMORY_TYPE MemoryType
|
||||
)
|
||||
{
|
||||
ASSERT ((MemoryType == EfiRuntimeServicesCode) || (MemoryType == EfiRuntimeServicesData));
|
||||
switch (MemoryType) {
|
||||
case EfiRuntimeServicesCode:
|
||||
return SmmPoolTypeCode;
|
||||
case EfiRuntimeServicesData:
|
||||
return SmmPoolTypeData;
|
||||
default:
|
||||
return SmmPoolTypeMax;
|
||||
case EfiRuntimeServicesCode:
|
||||
return SmmPoolTypeCode;
|
||||
case EfiRuntimeServicesData:
|
||||
return SmmPoolTypeData;
|
||||
default:
|
||||
return SmmPoolTypeMax;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Called to initialize the memory service.
|
||||
|
||||
@@ -52,10 +51,10 @@ SmmInitializeMemoryServices (
|
||||
IN EFI_SMRAM_DESCRIPTOR *SmramRanges
|
||||
)
|
||||
{
|
||||
UINTN Index;
|
||||
EFI_STATUS Status;
|
||||
UINTN SmmPoolTypeIndex;
|
||||
EFI_LOAD_FIXED_ADDRESS_CONFIGURATION_TABLE *LMFAConfigurationTable;
|
||||
UINTN Index;
|
||||
EFI_STATUS Status;
|
||||
UINTN SmmPoolTypeIndex;
|
||||
EFI_LOAD_FIXED_ADDRESS_CONFIGURATION_TABLE *LMFAConfigurationTable;
|
||||
|
||||
//
|
||||
// Initialize Pool list
|
||||
@@ -67,10 +66,10 @@ SmmInitializeMemoryServices (
|
||||
}
|
||||
|
||||
Status = EfiGetSystemConfigurationTable (
|
||||
&gLoadFixedAddressConfigurationTableGuid,
|
||||
(VOID **) &LMFAConfigurationTable
|
||||
);
|
||||
if (!EFI_ERROR (Status) && LMFAConfigurationTable != NULL) {
|
||||
&gLoadFixedAddressConfigurationTableGuid,
|
||||
(VOID **)&LMFAConfigurationTable
|
||||
);
|
||||
if (!EFI_ERROR (Status) && (LMFAConfigurationTable != NULL)) {
|
||||
gLoadModuleAtFixAddressSmramBase = LMFAConfigurationTable->SmramBase;
|
||||
}
|
||||
|
||||
@@ -82,6 +81,7 @@ SmmInitializeMemoryServices (
|
||||
if ((SmramRanges[Index].RegionState & (EFI_ALLOCATED | EFI_NEEDS_TESTING | EFI_NEEDS_ECC_INITIALIZATION)) != 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
SmmAddMemoryRegion (
|
||||
SmramRanges[Index].CpuStart,
|
||||
SmramRanges[Index].PhysicalSize,
|
||||
@@ -97,6 +97,7 @@ SmmInitializeMemoryServices (
|
||||
if ((SmramRanges[Index].RegionState & (EFI_ALLOCATED | EFI_NEEDS_TESTING | EFI_NEEDS_ECC_INITIALIZATION)) == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
SmmAddMemoryRegion (
|
||||
SmramRanges[Index].CpuStart,
|
||||
SmramRanges[Index].PhysicalSize,
|
||||
@@ -104,7 +105,6 @@ SmmInitializeMemoryServices (
|
||||
SmramRanges[Index].RegionState
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -132,19 +132,24 @@ InternalAllocPoolByIndex (
|
||||
SMM_POOL_TYPE SmmPoolType;
|
||||
|
||||
Address = 0;
|
||||
SmmPoolType = UefiMemoryTypeToSmmPoolType(PoolType);
|
||||
SmmPoolType = UefiMemoryTypeToSmmPoolType (PoolType);
|
||||
|
||||
ASSERT (PoolIndex <= MAX_POOL_INDEX);
|
||||
Status = EFI_SUCCESS;
|
||||
Hdr = NULL;
|
||||
Hdr = NULL;
|
||||
if (PoolIndex == MAX_POOL_INDEX) {
|
||||
Status = SmmInternalAllocatePages (AllocateAnyPages, PoolType,
|
||||
EFI_SIZE_TO_PAGES (MAX_POOL_SIZE << 1),
|
||||
&Address, FALSE);
|
||||
Status = SmmInternalAllocatePages (
|
||||
AllocateAnyPages,
|
||||
PoolType,
|
||||
EFI_SIZE_TO_PAGES (MAX_POOL_SIZE << 1),
|
||||
&Address,
|
||||
FALSE
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
Hdr = (FREE_POOL_HEADER *) (UINTN) Address;
|
||||
|
||||
Hdr = (FREE_POOL_HEADER *)(UINTN)Address;
|
||||
} else if (!IsListEmpty (&mSmmPoolLists[SmmPoolType][PoolIndex])) {
|
||||
Hdr = BASE_CR (GetFirstNode (&mSmmPoolLists[SmmPoolType][PoolIndex]), FREE_POOL_HEADER, Link);
|
||||
RemoveEntryList (&Hdr->Link);
|
||||
@@ -152,25 +157,25 @@ InternalAllocPoolByIndex (
|
||||
Status = InternalAllocPoolByIndex (PoolType, PoolIndex + 1, &Hdr);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
Hdr->Header.Signature = 0;
|
||||
Hdr->Header.Size >>= 1;
|
||||
Hdr->Header.Size >>= 1;
|
||||
Hdr->Header.Available = TRUE;
|
||||
Hdr->Header.Type = 0;
|
||||
Tail = HEAD_TO_TAIL(&Hdr->Header);
|
||||
Tail->Signature = 0;
|
||||
Tail->Size = 0;
|
||||
Hdr->Header.Type = 0;
|
||||
Tail = HEAD_TO_TAIL (&Hdr->Header);
|
||||
Tail->Signature = 0;
|
||||
Tail->Size = 0;
|
||||
InsertHeadList (&mSmmPoolLists[SmmPoolType][PoolIndex], &Hdr->Link);
|
||||
Hdr = (FREE_POOL_HEADER*)((UINT8*)Hdr + Hdr->Header.Size);
|
||||
Hdr = (FREE_POOL_HEADER *)((UINT8 *)Hdr + Hdr->Header.Size);
|
||||
}
|
||||
}
|
||||
|
||||
if (!EFI_ERROR (Status)) {
|
||||
Hdr->Header.Signature = POOL_HEAD_SIGNATURE;
|
||||
Hdr->Header.Size = MIN_POOL_SIZE << PoolIndex;
|
||||
Hdr->Header.Size = MIN_POOL_SIZE << PoolIndex;
|
||||
Hdr->Header.Available = FALSE;
|
||||
Hdr->Header.Type = PoolType;
|
||||
Tail = HEAD_TO_TAIL(&Hdr->Header);
|
||||
Tail->Signature = POOL_TAIL_SIGNATURE;
|
||||
Tail->Size = Hdr->Header.Size;
|
||||
Hdr->Header.Type = PoolType;
|
||||
Tail = HEAD_TO_TAIL (&Hdr->Header);
|
||||
Tail->Signature = POOL_TAIL_SIGNATURE;
|
||||
Tail->Size = Hdr->Header.Size;
|
||||
}
|
||||
|
||||
*FreePoolHdr = Hdr;
|
||||
@@ -192,21 +197,21 @@ InternalFreePoolByIndex (
|
||||
IN POOL_TAIL *PoolTail
|
||||
)
|
||||
{
|
||||
UINTN PoolIndex;
|
||||
SMM_POOL_TYPE SmmPoolType;
|
||||
UINTN PoolIndex;
|
||||
SMM_POOL_TYPE SmmPoolType;
|
||||
|
||||
ASSERT ((FreePoolHdr->Header.Size & (FreePoolHdr->Header.Size - 1)) == 0);
|
||||
ASSERT (((UINTN)FreePoolHdr & (FreePoolHdr->Header.Size - 1)) == 0);
|
||||
ASSERT (FreePoolHdr->Header.Size >= MIN_POOL_SIZE);
|
||||
|
||||
SmmPoolType = UefiMemoryTypeToSmmPoolType(FreePoolHdr->Header.Type);
|
||||
SmmPoolType = UefiMemoryTypeToSmmPoolType (FreePoolHdr->Header.Type);
|
||||
|
||||
PoolIndex = (UINTN) (HighBitSet32 ((UINT32)FreePoolHdr->Header.Size) - MIN_POOL_SHIFT);
|
||||
PoolIndex = (UINTN)(HighBitSet32 ((UINT32)FreePoolHdr->Header.Size) - MIN_POOL_SHIFT);
|
||||
FreePoolHdr->Header.Signature = 0;
|
||||
FreePoolHdr->Header.Available = TRUE;
|
||||
FreePoolHdr->Header.Type = 0;
|
||||
PoolTail->Signature = 0;
|
||||
PoolTail->Size = 0;
|
||||
FreePoolHdr->Header.Type = 0;
|
||||
PoolTail->Signature = 0;
|
||||
PoolTail->Size = 0;
|
||||
ASSERT (PoolIndex < MAX_POOL_INDEX);
|
||||
InsertHeadList (&mSmmPoolLists[SmmPoolType][PoolIndex], &FreePoolHdr->Link);
|
||||
return EFI_SUCCESS;
|
||||
@@ -245,8 +250,9 @@ SmmInternalAllocatePool (
|
||||
|
||||
Address = 0;
|
||||
|
||||
if (PoolType != EfiRuntimeServicesCode &&
|
||||
PoolType != EfiRuntimeServicesData) {
|
||||
if ((PoolType != EfiRuntimeServicesCode) &&
|
||||
(PoolType != EfiRuntimeServicesData))
|
||||
{
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@@ -258,14 +264,19 @@ SmmInternalAllocatePool (
|
||||
// Adjust the size by the pool header & tail overhead
|
||||
//
|
||||
Size += POOL_OVERHEAD;
|
||||
if (Size > MAX_POOL_SIZE || NeedGuard) {
|
||||
if ((Size > MAX_POOL_SIZE) || NeedGuard) {
|
||||
if (!HasPoolTail) {
|
||||
Size -= sizeof (POOL_TAIL);
|
||||
}
|
||||
|
||||
NoPages = EFI_SIZE_TO_PAGES (Size);
|
||||
Status = SmmInternalAllocatePages (AllocateAnyPages, PoolType, NoPages,
|
||||
&Address, NeedGuard);
|
||||
Status = SmmInternalAllocatePages (
|
||||
AllocateAnyPages,
|
||||
PoolType,
|
||||
NoPages,
|
||||
&Address,
|
||||
NeedGuard
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
@@ -279,32 +290,33 @@ SmmInternalAllocatePool (
|
||||
);
|
||||
}
|
||||
|
||||
PoolHdr = (POOL_HEADER*)(UINTN)Address;
|
||||
PoolHdr = (POOL_HEADER *)(UINTN)Address;
|
||||
PoolHdr->Signature = POOL_HEAD_SIGNATURE;
|
||||
PoolHdr->Size = EFI_PAGES_TO_SIZE (NoPages);
|
||||
PoolHdr->Size = EFI_PAGES_TO_SIZE (NoPages);
|
||||
PoolHdr->Available = FALSE;
|
||||
PoolHdr->Type = PoolType;
|
||||
PoolHdr->Type = PoolType;
|
||||
|
||||
if (HasPoolTail) {
|
||||
PoolTail = HEAD_TO_TAIL (PoolHdr);
|
||||
PoolTail = HEAD_TO_TAIL (PoolHdr);
|
||||
PoolTail->Signature = POOL_TAIL_SIGNATURE;
|
||||
PoolTail->Size = PoolHdr->Size;
|
||||
PoolTail->Size = PoolHdr->Size;
|
||||
}
|
||||
|
||||
*Buffer = PoolHdr + 1;
|
||||
return Status;
|
||||
}
|
||||
|
||||
Size = (Size + MIN_POOL_SIZE - 1) >> MIN_POOL_SHIFT;
|
||||
PoolIndex = (UINTN) HighBitSet32 ((UINT32)Size);
|
||||
Size = (Size + MIN_POOL_SIZE - 1) >> MIN_POOL_SHIFT;
|
||||
PoolIndex = (UINTN)HighBitSet32 ((UINT32)Size);
|
||||
if ((Size & (Size - 1)) != 0) {
|
||||
PoolIndex++;
|
||||
}
|
||||
|
||||
Status = InternalAllocPoolByIndex (PoolType, PoolIndex, &FreePoolHdr);
|
||||
if (!EFI_ERROR(Status)) {
|
||||
if (!EFI_ERROR (Status)) {
|
||||
*Buffer = &FreePoolHdr->Header + 1;
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
@@ -334,7 +346,7 @@ SmmAllocatePool (
|
||||
Status = SmmInternalAllocatePool (PoolType, Size, Buffer);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
SmmCoreUpdateProfile (
|
||||
(EFI_PHYSICAL_ADDRESS) (UINTN) RETURN_ADDRESS (0),
|
||||
(EFI_PHYSICAL_ADDRESS)(UINTN)RETURN_ADDRESS (0),
|
||||
MemoryProfileActionAllocatePool,
|
||||
PoolType,
|
||||
Size,
|
||||
@@ -342,6 +354,7 @@ SmmAllocatePool (
|
||||
NULL
|
||||
);
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
@@ -371,10 +384,10 @@ SmmInternalFreePool (
|
||||
|
||||
MemoryGuarded = IsHeapGuardEnabled () &&
|
||||
IsMemoryGuarded ((EFI_PHYSICAL_ADDRESS)(UINTN)Buffer);
|
||||
HasPoolTail = !(MemoryGuarded &&
|
||||
((PcdGet8 (PcdHeapGuardPropertyMask) & BIT7) == 0));
|
||||
HasPoolTail = !(MemoryGuarded &&
|
||||
((PcdGet8 (PcdHeapGuardPropertyMask) & BIT7) == 0));
|
||||
|
||||
FreePoolHdr = (FREE_POOL_HEADER*)((POOL_HEADER*)Buffer - 1);
|
||||
FreePoolHdr = (FREE_POOL_HEADER *)((POOL_HEADER *)Buffer - 1);
|
||||
ASSERT (FreePoolHdr->Header.Signature == POOL_HEAD_SIGNATURE);
|
||||
ASSERT (!FreePoolHdr->Header.Available);
|
||||
if (FreePoolHdr->Header.Signature != POOL_HEAD_SIGNATURE) {
|
||||
@@ -414,6 +427,7 @@ SmmInternalFreePool (
|
||||
FALSE
|
||||
);
|
||||
}
|
||||
|
||||
return InternalFreePoolByIndex (FreePoolHdr, PoolTail);
|
||||
}
|
||||
|
||||
@@ -437,7 +451,7 @@ SmmFreePool (
|
||||
Status = SmmInternalFreePool (Buffer);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
SmmCoreUpdateProfile (
|
||||
(EFI_PHYSICAL_ADDRESS) (UINTN) RETURN_ADDRESS (0),
|
||||
(EFI_PHYSICAL_ADDRESS)(UINTN)RETURN_ADDRESS (0),
|
||||
MemoryProfileActionFreePool,
|
||||
EfiMaxMemoryType,
|
||||
0,
|
||||
@@ -445,5 +459,6 @@ SmmFreePool (
|
||||
NULL
|
||||
);
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
@@ -8,12 +8,12 @@
|
||||
|
||||
#include "PiSmmCore.h"
|
||||
|
||||
LIST_ENTRY mSmiEntryList = INITIALIZE_LIST_HEAD_VARIABLE (mSmiEntryList);
|
||||
LIST_ENTRY mSmiEntryList = INITIALIZE_LIST_HEAD_VARIABLE (mSmiEntryList);
|
||||
|
||||
SMI_ENTRY mRootSmiEntry = {
|
||||
SMI_ENTRY mRootSmiEntry = {
|
||||
SMI_ENTRY_SIGNATURE,
|
||||
INITIALIZE_LIST_HEAD_VARIABLE (mRootSmiEntry.AllEntries),
|
||||
{0},
|
||||
{ 0 },
|
||||
INITIALIZE_LIST_HEAD_VARIABLE (mRootSmiEntry.SmiHandlers),
|
||||
};
|
||||
|
||||
@@ -43,8 +43,8 @@ SmmCoreFindSmiEntry (
|
||||
SmiEntry = NULL;
|
||||
for (Link = mSmiEntryList.ForwardLink;
|
||||
Link != &mSmiEntryList;
|
||||
Link = Link->ForwardLink) {
|
||||
|
||||
Link = Link->ForwardLink)
|
||||
{
|
||||
Item = CR (Link, SMI_ENTRY, AllEntries, SMI_ENTRY_SIGNATURE);
|
||||
if (CompareGuid (&Item->HandlerType, HandlerType)) {
|
||||
//
|
||||
@@ -60,7 +60,7 @@ SmmCoreFindSmiEntry (
|
||||
// allocate a new entry
|
||||
//
|
||||
if ((SmiEntry == NULL) && Create) {
|
||||
SmiEntry = AllocatePool (sizeof(SMI_ENTRY));
|
||||
SmiEntry = AllocatePool (sizeof (SMI_ENTRY));
|
||||
if (SmiEntry != NULL) {
|
||||
//
|
||||
// Initialize new SMI entry structure
|
||||
@@ -75,6 +75,7 @@ SmmCoreFindSmiEntry (
|
||||
InsertTailList (&mSmiEntryList, &SmiEntry->AllEntries);
|
||||
}
|
||||
}
|
||||
|
||||
return SmiEntry;
|
||||
}
|
||||
|
||||
@@ -108,7 +109,7 @@ SmiManage (
|
||||
BOOLEAN SuccessReturn;
|
||||
EFI_STATUS Status;
|
||||
|
||||
Status = EFI_NOT_FOUND;
|
||||
Status = EFI_NOT_FOUND;
|
||||
SuccessReturn = FALSE;
|
||||
if (HandlerType == NULL) {
|
||||
//
|
||||
@@ -119,7 +120,7 @@ SmiManage (
|
||||
//
|
||||
// Non-root SMI handler
|
||||
//
|
||||
SmiEntry = SmmCoreFindSmiEntry ((EFI_GUID *) HandlerType, FALSE);
|
||||
SmiEntry = SmmCoreFindSmiEntry ((EFI_GUID *)HandlerType, FALSE);
|
||||
if (SmiEntry == NULL) {
|
||||
//
|
||||
// There is no handler registered for this interrupt source
|
||||
@@ -127,62 +128,65 @@ SmiManage (
|
||||
return Status;
|
||||
}
|
||||
}
|
||||
|
||||
Head = &SmiEntry->SmiHandlers;
|
||||
|
||||
for (Link = Head->ForwardLink; Link != Head; Link = Link->ForwardLink) {
|
||||
SmiHandler = CR (Link, SMI_HANDLER, Link, SMI_HANDLER_SIGNATURE);
|
||||
|
||||
Status = SmiHandler->Handler (
|
||||
(EFI_HANDLE) SmiHandler,
|
||||
Context,
|
||||
CommBuffer,
|
||||
CommBufferSize
|
||||
);
|
||||
(EFI_HANDLE)SmiHandler,
|
||||
Context,
|
||||
CommBuffer,
|
||||
CommBufferSize
|
||||
);
|
||||
|
||||
switch (Status) {
|
||||
case EFI_INTERRUPT_PENDING:
|
||||
//
|
||||
// If a handler returns EFI_INTERRUPT_PENDING and HandlerType is not NULL then
|
||||
// no additional handlers will be processed and EFI_INTERRUPT_PENDING will be returned.
|
||||
//
|
||||
if (HandlerType != NULL) {
|
||||
return EFI_INTERRUPT_PENDING;
|
||||
}
|
||||
break;
|
||||
case EFI_INTERRUPT_PENDING:
|
||||
//
|
||||
// If a handler returns EFI_INTERRUPT_PENDING and HandlerType is not NULL then
|
||||
// no additional handlers will be processed and EFI_INTERRUPT_PENDING will be returned.
|
||||
//
|
||||
if (HandlerType != NULL) {
|
||||
return EFI_INTERRUPT_PENDING;
|
||||
}
|
||||
|
||||
case EFI_SUCCESS:
|
||||
//
|
||||
// If at least one of the handlers returns EFI_SUCCESS then the function will return
|
||||
// EFI_SUCCESS. If a handler returns EFI_SUCCESS and HandlerType is not NULL then no
|
||||
// additional handlers will be processed.
|
||||
//
|
||||
if (HandlerType != NULL) {
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
SuccessReturn = TRUE;
|
||||
break;
|
||||
break;
|
||||
|
||||
case EFI_WARN_INTERRUPT_SOURCE_QUIESCED:
|
||||
//
|
||||
// If at least one of the handlers returns EFI_WARN_INTERRUPT_SOURCE_QUIESCED
|
||||
// then the function will return EFI_SUCCESS.
|
||||
//
|
||||
SuccessReturn = TRUE;
|
||||
break;
|
||||
case EFI_SUCCESS:
|
||||
//
|
||||
// If at least one of the handlers returns EFI_SUCCESS then the function will return
|
||||
// EFI_SUCCESS. If a handler returns EFI_SUCCESS and HandlerType is not NULL then no
|
||||
// additional handlers will be processed.
|
||||
//
|
||||
if (HandlerType != NULL) {
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
case EFI_WARN_INTERRUPT_SOURCE_PENDING:
|
||||
//
|
||||
// If all the handlers returned EFI_WARN_INTERRUPT_SOURCE_PENDING
|
||||
// then EFI_WARN_INTERRUPT_SOURCE_PENDING will be returned.
|
||||
//
|
||||
break;
|
||||
SuccessReturn = TRUE;
|
||||
break;
|
||||
|
||||
default:
|
||||
//
|
||||
// Unexpected status code returned.
|
||||
//
|
||||
ASSERT (FALSE);
|
||||
break;
|
||||
case EFI_WARN_INTERRUPT_SOURCE_QUIESCED:
|
||||
//
|
||||
// If at least one of the handlers returns EFI_WARN_INTERRUPT_SOURCE_QUIESCED
|
||||
// then the function will return EFI_SUCCESS.
|
||||
//
|
||||
SuccessReturn = TRUE;
|
||||
break;
|
||||
|
||||
case EFI_WARN_INTERRUPT_SOURCE_PENDING:
|
||||
//
|
||||
// If all the handlers returned EFI_WARN_INTERRUPT_SOURCE_PENDING
|
||||
// then EFI_WARN_INTERRUPT_SOURCE_PENDING will be returned.
|
||||
//
|
||||
break;
|
||||
|
||||
default:
|
||||
//
|
||||
// Unexpected status code returned.
|
||||
//
|
||||
ASSERT (FALSE);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -216,7 +220,7 @@ SmiHandlerRegister (
|
||||
SMI_ENTRY *SmiEntry;
|
||||
LIST_ENTRY *List;
|
||||
|
||||
if (Handler == NULL || DispatchHandle == NULL) {
|
||||
if ((Handler == NULL) || (DispatchHandle == NULL)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@@ -225,8 +229,8 @@ SmiHandlerRegister (
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
SmiHandler->Signature = SMI_HANDLER_SIGNATURE;
|
||||
SmiHandler->Handler = Handler;
|
||||
SmiHandler->Signature = SMI_HANDLER_SIGNATURE;
|
||||
SmiHandler->Handler = Handler;
|
||||
SmiHandler->CallerAddr = (UINTN)RETURN_ADDRESS (0);
|
||||
|
||||
if (HandlerType == NULL) {
|
||||
@@ -238,17 +242,18 @@ SmiHandlerRegister (
|
||||
//
|
||||
// None root SMI handler
|
||||
//
|
||||
SmiEntry = SmmCoreFindSmiEntry ((EFI_GUID *) HandlerType, TRUE);
|
||||
SmiEntry = SmmCoreFindSmiEntry ((EFI_GUID *)HandlerType, TRUE);
|
||||
if (SmiEntry == NULL) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
}
|
||||
|
||||
List = &SmiEntry->SmiHandlers;
|
||||
|
||||
SmiHandler->SmiEntry = SmiEntry;
|
||||
InsertTailList (List, &SmiHandler->Link);
|
||||
|
||||
*DispatchHandle = (EFI_HANDLE) SmiHandler;
|
||||
*DispatchHandle = (EFI_HANDLE)SmiHandler;
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
@@ -282,9 +287,10 @@ SmiHandlerUnRegister (
|
||||
//
|
||||
SmiHandler = NULL;
|
||||
for ( HandlerLink = GetFirstNode (&mRootSmiEntry.SmiHandlers)
|
||||
; !IsNull (&mRootSmiEntry.SmiHandlers, HandlerLink) && ((EFI_HANDLE) SmiHandler != DispatchHandle)
|
||||
; HandlerLink = GetNextNode (&mRootSmiEntry.SmiHandlers, HandlerLink)
|
||||
) {
|
||||
; !IsNull (&mRootSmiEntry.SmiHandlers, HandlerLink) && ((EFI_HANDLE)SmiHandler != DispatchHandle)
|
||||
; HandlerLink = GetNextNode (&mRootSmiEntry.SmiHandlers, HandlerLink)
|
||||
)
|
||||
{
|
||||
SmiHandler = CR (HandlerLink, SMI_HANDLER, Link, SMI_HANDLER_SIGNATURE);
|
||||
}
|
||||
|
||||
@@ -292,19 +298,21 @@ SmiHandlerUnRegister (
|
||||
// Look for it in non-root SMI handlers
|
||||
//
|
||||
for ( EntryLink = GetFirstNode (&mSmiEntryList)
|
||||
; !IsNull (&mSmiEntryList, EntryLink) && ((EFI_HANDLE) SmiHandler != DispatchHandle)
|
||||
; EntryLink = GetNextNode (&mSmiEntryList, EntryLink)
|
||||
) {
|
||||
; !IsNull (&mSmiEntryList, EntryLink) && ((EFI_HANDLE)SmiHandler != DispatchHandle)
|
||||
; EntryLink = GetNextNode (&mSmiEntryList, EntryLink)
|
||||
)
|
||||
{
|
||||
SmiEntry = CR (EntryLink, SMI_ENTRY, AllEntries, SMI_ENTRY_SIGNATURE);
|
||||
for ( HandlerLink = GetFirstNode (&SmiEntry->SmiHandlers)
|
||||
; !IsNull (&SmiEntry->SmiHandlers, HandlerLink) && ((EFI_HANDLE) SmiHandler != DispatchHandle)
|
||||
; HandlerLink = GetNextNode (&SmiEntry->SmiHandlers, HandlerLink)
|
||||
) {
|
||||
; !IsNull (&SmiEntry->SmiHandlers, HandlerLink) && ((EFI_HANDLE)SmiHandler != DispatchHandle)
|
||||
; HandlerLink = GetNextNode (&SmiEntry->SmiHandlers, HandlerLink)
|
||||
)
|
||||
{
|
||||
SmiHandler = CR (HandlerLink, SMI_HANDLER, Link, SMI_HANDLER_SIGNATURE);
|
||||
}
|
||||
}
|
||||
|
||||
if ((EFI_HANDLE) SmiHandler != DispatchHandle) {
|
||||
if ((EFI_HANDLE)SmiHandler != DispatchHandle) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user