Clean up the gBS sevice (CopyMem, SetMem, AllocatePool, FreePool) with the corresponding APIs defined in Mde library class for these modules.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@2456 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
@@ -96,12 +96,12 @@ Returns:
|
||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL
|
||||
);
|
||||
if (Status == EFI_SUCCESS && DebugSupportProtocolPtr->Isa == EFI_ISA) {
|
||||
gBS->FreePool (HandlePtr);
|
||||
FreePool (HandlePtr);
|
||||
Status = EFI_ALREADY_STARTED;
|
||||
goto ErrExit;
|
||||
}
|
||||
} while (NumHandles > 0);
|
||||
gBS->FreePool (HandlePtr);
|
||||
FreePool (HandlePtr);
|
||||
}
|
||||
|
||||
//
|
||||
|
@@ -7,7 +7,7 @@
|
||||
<Version>1.0</Version>
|
||||
<Abstract>Component description file for DebugSupport module.</Abstract>
|
||||
<Description>This driver installs DebugSupport protocol for the selected processor.</Description>
|
||||
<Copyright>Copyright (c) 2006, Intel Corporation</Copyright>
|
||||
<Copyright>Copyright (c) 2006 - 2007, Intel Corporation</Copyright>
|
||||
<License>All rights reserved. This program and the accompanying materials
|
||||
are licensed and made available under the terms and conditions of the BSD License
|
||||
which accompanies this distribution. The full text of the license may be found at
|
||||
@@ -17,35 +17,38 @@
|
||||
<Specification>FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052</Specification>
|
||||
</MsaHeader>
|
||||
<ModuleDefinitions>
|
||||
<SupportedArchitectures>IA32 X64 IPF EBC</SupportedArchitectures>
|
||||
<SupportedArchitectures>IA32 X64 IPF</SupportedArchitectures>
|
||||
<BinaryModule>false</BinaryModule>
|
||||
<OutputFileBasename>DebugSupport</OutputFileBasename>
|
||||
</ModuleDefinitions>
|
||||
<LibraryClassDefinitions>
|
||||
<LibraryClass Usage="ALWAYS_CONSUMED">
|
||||
<LibraryClass Usage="ALWAYS_CONSUMED" RecommendedInstanceGuid="bda39d3a-451b-4350-8266-81ab10fa0523">
|
||||
<Keyword>DebugLib</Keyword>
|
||||
<HelpText>Recommended libary Instance is PeiDxeDebugLibReportStatusCode instance in MdePkg.</HelpText>
|
||||
</LibraryClass>
|
||||
<LibraryClass Usage="ALWAYS_CONSUMED">
|
||||
<Keyword>UefiDriverEntryPoint</Keyword>
|
||||
</LibraryClass>
|
||||
<LibraryClass Usage="ALWAYS_CONSUMED">
|
||||
<LibraryClass Usage="ALWAYS_CONSUMED" RecommendedInstanceGuid="f1bbe03d-2f28-4dee-bec7-d98d7a30c36a">
|
||||
<Keyword>BaseMemoryLib</Keyword>
|
||||
<HelpText>Recommended libary Instance is DxeMemoryLib instance in MdePkg.</HelpText>
|
||||
</LibraryClass>
|
||||
<LibraryClass Usage="ALWAYS_CONSUMED">
|
||||
<LibraryClass Usage="ALWAYS_CONSUMED" RecommendedInstanceGuid="4674739d-3195-4fb2-8094-ac1d22d00194">
|
||||
<Keyword>MemoryAllocationLib</Keyword>
|
||||
<HelpText>Recommended libary Instance is DxeMemoryAllocationLib instance in MdePkg.</HelpText>
|
||||
</LibraryClass>
|
||||
<LibraryClass Usage="ALWAYS_CONSUMED">
|
||||
<Keyword>UefiBootServicesTableLib</Keyword>
|
||||
</LibraryClass>
|
||||
<LibraryClass Usage="ALWAYS_CONSUMED" SupArchList="IA32 X64 IPF EBC">
|
||||
<LibraryClass Usage="ALWAYS_CONSUMED" SupArchList="IA32 X64">
|
||||
<Keyword>BaseLib</Keyword>
|
||||
</LibraryClass>
|
||||
</LibraryClassDefinitions>
|
||||
<SourceFiles>
|
||||
<Filename>DebugSupport.c</Filename>
|
||||
<Filename>DebugSupport.dxs</Filename>
|
||||
<Filename SupArchList="IA32">Ia32/AsmFuncs.asm</Filename>
|
||||
<Filename SupArchList="IA32">Ia32/AsmFuncs.S</Filename>
|
||||
<Filename ToolChainFamily="MSFT" SupArchList="IA32">Ia32/AsmFuncs.asm</Filename>
|
||||
<Filename ToolChainFamily="GCC" SupArchList="IA32">Ia32/AsmFuncs.S</Filename>
|
||||
<Filename SupArchList="IA32">Ia32/plDebugSupport.h</Filename>
|
||||
<Filename SupArchList="IA32">Ia32/plDebugSupport.c</Filename>
|
||||
<Filename SupArchList="IPF">ipf/AsmFuncs.s</Filename>
|
||||
@@ -60,11 +63,14 @@
|
||||
</SourceFiles>
|
||||
<PackageDependencies>
|
||||
<Package PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
|
||||
<Package PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d"/>
|
||||
</PackageDependencies>
|
||||
<Protocols>
|
||||
<Protocol Usage="SOMETIMES_PRODUCED">
|
||||
<ProtocolCName>gEfiDebugSupportProtocolGuid</ProtocolCName>
|
||||
<HelpText>If the debug support protocol for this processor type is not
|
||||
already installed, this protocol will be installed. Otherwise, it will
|
||||
be not installed again.
|
||||
</HelpText>
|
||||
</Protocol>
|
||||
<Protocol Usage="ALWAYS_CONSUMED">
|
||||
<ProtocolCName>gEfiLoadedImageProtocolGuid</ProtocolCName>
|
||||
|
@@ -45,16 +45,15 @@ Returns:
|
||||
|
||||
--*/
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
UINT8 *StubCopy;
|
||||
|
||||
//
|
||||
// First, allocate a new buffer and copy the stub code into it
|
||||
//
|
||||
Status = gBS->AllocatePool (EfiBootServicesData, StubSize, Stub);
|
||||
if (Status == EFI_SUCCESS) {
|
||||
*Stub = AllocatePool (StubSize);
|
||||
if (*Stub != NULL) {
|
||||
StubCopy = *Stub;
|
||||
gBS->CopyMem (StubCopy, InterruptEntryStub, StubSize);
|
||||
CopyMem (StubCopy, InterruptEntryStub, StubSize);
|
||||
|
||||
//
|
||||
// Next fixup the stub code for this vector
|
||||
@@ -78,9 +77,11 @@ Returns:
|
||||
// fixup the jump target to point to the common entry
|
||||
//
|
||||
*(UINT32 *) &StubCopy[0x0e] = (UINT32) CommonIdtEntry - (UINT32) &StubCopy[StubSize];
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
return Status;
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
STATIC
|
||||
@@ -144,20 +145,18 @@ Arguments:
|
||||
|
||||
Returns:
|
||||
EFI_SUCCESS
|
||||
Other values are passed through from FreePool
|
||||
|
||||
--*/
|
||||
{
|
||||
BOOLEAN OldIntFlagState;
|
||||
EFI_STATUS Status;
|
||||
|
||||
OldIntFlagState = WriteInterruptFlag (0);
|
||||
WriteIdt (ExceptionType, &(IdtEntryTable[ExceptionType].OrigDesc));
|
||||
Status = gBS->FreePool ((VOID *) (UINTN) IdtEntryTable[ExceptionType].StubEntry);
|
||||
FreePool ((VOID *) (UINTN) IdtEntryTable[ExceptionType].StubEntry);
|
||||
ZeroMem (&IdtEntryTable[ExceptionType], sizeof (IDT_ENTRY));
|
||||
WriteInterruptFlag (OldIntFlagState);
|
||||
|
||||
return (Status);
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -405,7 +404,7 @@ Returns:
|
||||
ManageIdtEntryTable (NULL, ExceptionType);
|
||||
}
|
||||
|
||||
gBS->FreePool (IdtEntryTable);
|
||||
FreePool (IdtEntryTable);
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
@@ -107,7 +107,7 @@ Returns:
|
||||
|
||||
--*/
|
||||
{
|
||||
gBS->SetMem (IvtEntryTable, sizeof (IvtEntryTable), 0);
|
||||
SetMem (IvtEntryTable, sizeof (IvtEntryTable), 0);
|
||||
ExternalInterruptCount = 0;
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
@@ -298,7 +298,7 @@ Returns:
|
||||
//
|
||||
// re-init IvtEntryTable
|
||||
//
|
||||
gBS->SetMem (&IvtEntryTable[ExceptionType], sizeof (IVT_ENTRY), 0);
|
||||
SetMem (&IvtEntryTable[ExceptionType], sizeof (IVT_ENTRY), 0);
|
||||
}
|
||||
} else {
|
||||
//
|
||||
@@ -356,15 +356,15 @@ Returns:
|
||||
//
|
||||
// copy original bundles from IVT to IvtEntryTable so we can restore them later
|
||||
//
|
||||
gBS->CopyMem (
|
||||
IvtEntryTable[ExceptionType].OrigBundles,
|
||||
B0Ptr,
|
||||
sizeof (BUNDLE) * NUM_BUNDLES_IN_STUB
|
||||
);
|
||||
CopyMem (
|
||||
IvtEntryTable[ExceptionType].OrigBundles,
|
||||
B0Ptr,
|
||||
sizeof (BUNDLE) * NUM_BUNDLES_IN_STUB
|
||||
);
|
||||
//
|
||||
// insert new B0
|
||||
//
|
||||
gBS->CopyMem (B0Ptr, NewBundles, sizeof (BUNDLE) * NUM_BUNDLES_IN_STUB);
|
||||
CopyMem (B0Ptr, NewBundles, sizeof (BUNDLE) * NUM_BUNDLES_IN_STUB);
|
||||
|
||||
//
|
||||
// fixup IVT entry so it stores its index and whether or not to chain...
|
||||
@@ -406,11 +406,11 @@ Returns:
|
||||
//
|
||||
// restore original bundles in IVT
|
||||
//
|
||||
gBS->CopyMem (
|
||||
B0Ptr,
|
||||
IvtEntryTable[ExceptionType].OrigBundles,
|
||||
sizeof (BUNDLE) * NUM_BUNDLES_IN_STUB
|
||||
);
|
||||
CopyMem (
|
||||
B0Ptr,
|
||||
IvtEntryTable[ExceptionType].OrigBundles,
|
||||
sizeof (BUNDLE) * NUM_BUNDLES_IN_STUB
|
||||
);
|
||||
InstructionCacheFlush (B0Ptr, 5);
|
||||
}
|
||||
|
||||
|
@@ -44,16 +44,15 @@ Returns:
|
||||
|
||||
--*/
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
UINT8 *StubCopy;
|
||||
|
||||
//
|
||||
// First, allocate a new buffer and copy the stub code into it
|
||||
//
|
||||
Status = gBS->AllocatePool (EfiBootServicesData, StubSize, Stub);
|
||||
if (Status == EFI_SUCCESS) {
|
||||
*Stub = AllocatePool (StubSize);
|
||||
if (*Stub != NULL) {
|
||||
StubCopy = *Stub;
|
||||
gBS->CopyMem (StubCopy, InterruptEntryStub, StubSize);
|
||||
CopyMem (StubCopy, InterruptEntryStub, StubSize);
|
||||
|
||||
//
|
||||
// Next fixup the stub code for this vector
|
||||
@@ -75,9 +74,11 @@ Returns:
|
||||
// fixup the jump target to point to the common entry
|
||||
//
|
||||
*(UINT32 *) &StubCopy[0x3] = (UINT32)((UINTN) CommonIdtEntry - (UINTN) &StubCopy[StubSize]);
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
return Status;
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
STATIC
|
||||
@@ -142,20 +143,18 @@ Arguments:
|
||||
|
||||
Returns:
|
||||
EFI_SUCCESS
|
||||
Other values are passed through from FreePool
|
||||
|
||||
--*/
|
||||
{
|
||||
BOOLEAN OldIntFlagState;
|
||||
EFI_STATUS Status;
|
||||
|
||||
|
||||
OldIntFlagState = WriteInterruptFlag (0);
|
||||
WriteIdt (ExceptionType, &(IdtEntryTable[ExceptionType].OrigDesc));
|
||||
Status = gBS->FreePool ((VOID *) (UINTN) IdtEntryTable[ExceptionType].StubEntry);
|
||||
FreePool ((VOID *) (UINTN) IdtEntryTable[ExceptionType].StubEntry);
|
||||
ZeroMem (&IdtEntryTable[ExceptionType], sizeof (IDT_ENTRY));
|
||||
WriteInterruptFlag (OldIntFlagState);
|
||||
|
||||
return (Status);
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
EFI_STATUS
|
||||
@@ -401,7 +400,7 @@ Returns:
|
||||
ManageIdtEntryTable (NULL, ExceptionType);
|
||||
}
|
||||
|
||||
gBS->FreePool (IdtEntryTable);
|
||||
FreePool (IdtEntryTable);
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user