AGESA vendorcode: Drop alternate image dispatcher
Not used as we link AGESA into same romstage and ramstage ELF. Change-Id: Ia427b9c0cc88b870de75df14bba4ca337a28adff Signed-off-by: Kyösti Mälkki <kyosti.malkki@gmail.com> Reviewed-on: https://review.coreboot.org/14395 Tested-by: build bot (Jenkins) Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
This commit is contained in:
parent
898c47c5dc
commit
d867b7d87c
|
@ -76,19 +76,11 @@ AmdAgesaDispatcher (
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
AGESA_STATUS Status;
|
AGESA_STATUS Status;
|
||||||
IMAGE_ENTRY ImageEntry;
|
|
||||||
MODULE_ENTRY ModuleEntry;
|
MODULE_ENTRY ModuleEntry;
|
||||||
DISPATCH_TABLE *Entry;
|
DISPATCH_TABLE *Entry;
|
||||||
UINT32 ImageStart;
|
|
||||||
UINT32 ImageEnd;
|
|
||||||
AMD_IMAGE_HEADER* AltImagePtr;
|
|
||||||
|
|
||||||
Status = AGESA_UNSUPPORTED;
|
Status = AGESA_UNSUPPORTED;
|
||||||
ImageEntry = NULL;
|
|
||||||
ModuleEntry = NULL;
|
ModuleEntry = NULL;
|
||||||
ImageStart = 0xFFF00000;
|
|
||||||
ImageEnd = 0xFFFFFFFF;
|
|
||||||
AltImagePtr = NULL;
|
|
||||||
|
|
||||||
Entry = (DISPATCH_TABLE *) DispatchTable;
|
Entry = (DISPATCH_TABLE *) DispatchTable;
|
||||||
while (Entry->FunctionId != 0) {
|
while (Entry->FunctionId != 0) {
|
||||||
|
@ -107,21 +99,6 @@ AmdAgesaDispatcher (
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3. If not this image specific function, see if we can find alternative image instead
|
|
||||||
if (Status == AGESA_UNSUPPORTED) {
|
|
||||||
if ((((AMD_CONFIG_PARAMS *)ConfigPtr)->AltImageBasePtr != 0xFFFFFFFF ) && (((AMD_CONFIG_PARAMS *)ConfigPtr)->AltImageBasePtr != 0)) {
|
|
||||||
ImageStart = ((AMD_CONFIG_PARAMS *)ConfigPtr)->AltImageBasePtr;
|
|
||||||
ImageEnd = ImageStart + 4;
|
|
||||||
// Locate/test image base that matches this component
|
|
||||||
AltImagePtr = LibAmdLocateImage ((VOID *)ImageStart, (VOID *)ImageEnd, 4096, (CHAR8 *)AGESA_ID);
|
|
||||||
if (AltImagePtr != NULL) {
|
|
||||||
//Invoke alternative Image
|
|
||||||
ImageEntry = (IMAGE_ENTRY) (AltImagePtr + AltImagePtr->EntryPointAddress);
|
|
||||||
Status = (*ImageEntry) (ConfigPtr);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return (Status);
|
return (Status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1131,91 +1131,6 @@ LibAmdMemCopy (
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------------------*/
|
|
||||||
/**
|
|
||||||
* Verify checksum of binary image (B1/B2/B3)
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* @param[in] ImagePtr Pointer to image start
|
|
||||||
* @retval TRUE Checksum valid
|
|
||||||
* @retval FALSE Checksum invalid
|
|
||||||
*/
|
|
||||||
BOOLEAN
|
|
||||||
LibAmdVerifyImageChecksum (
|
|
||||||
IN VOID *ImagePtr
|
|
||||||
)
|
|
||||||
{
|
|
||||||
// Assume ImagePtr points to the binary start ($AMD)
|
|
||||||
// Checksum is on an even boundary in AMD_IMAGE_HEADER
|
|
||||||
|
|
||||||
UINT16 Sum;
|
|
||||||
UINT32 i;
|
|
||||||
|
|
||||||
Sum = 0;
|
|
||||||
|
|
||||||
i = ((AMD_IMAGE_HEADER*) ImagePtr)->ImageSize;
|
|
||||||
|
|
||||||
while (i > 1) {
|
|
||||||
Sum = Sum + *((UINT16 *)ImagePtr);
|
|
||||||
ImagePtr = (VOID *) ((UINT8 *)ImagePtr + 2);
|
|
||||||
i = i - 2;
|
|
||||||
}
|
|
||||||
if (i > 0) {
|
|
||||||
Sum = Sum + *((UINT8 *) ImagePtr);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (Sum == 0)?TRUE:FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------------------*/
|
|
||||||
/**
|
|
||||||
* Locate AMD binary image that contain specific module
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* @param[in] StartAddress Pointer to start range
|
|
||||||
* @param[in] EndAddress Pointer to end range
|
|
||||||
* @param[in] Alignment Image address alignment
|
|
||||||
* @param[in] ModuleSignature Module signature.
|
|
||||||
* @retval NULL if image not found
|
|
||||||
* @retval pointer to image header
|
|
||||||
*/
|
|
||||||
VOID *
|
|
||||||
LibAmdLocateImage (
|
|
||||||
IN VOID *StartAddress,
|
|
||||||
IN VOID *EndAddress,
|
|
||||||
IN UINT32 Alignment,
|
|
||||||
IN CHAR8 ModuleSignature[8]
|
|
||||||
)
|
|
||||||
|
|
||||||
{
|
|
||||||
UINT8 *CurrentPtr;
|
|
||||||
AMD_MODULE_HEADER *ModuleHeaderPtr;
|
|
||||||
UINT64 *SearchStr;
|
|
||||||
UINT64 *InputStr;
|
|
||||||
|
|
||||||
CurrentPtr = StartAddress;
|
|
||||||
InputStr = (UINT64 *)ModuleSignature;
|
|
||||||
|
|
||||||
// Search from start to end incrementing by alignment
|
|
||||||
while ((CurrentPtr >= (UINT8 *) StartAddress) && (CurrentPtr < (UINT8 *) EndAddress)) {
|
|
||||||
// First find a binary image
|
|
||||||
if (*((UINT32 *) CurrentPtr) == IMAGE_SIGNATURE) {
|
|
||||||
if (LibAmdVerifyImageChecksum (CurrentPtr)) {
|
|
||||||
// If we have a valid image, search module linked list for a match
|
|
||||||
ModuleHeaderPtr = (AMD_MODULE_HEADER*) ((UINT8 *)CurrentPtr + ((AMD_IMAGE_HEADER *) CurrentPtr)->ModuleInfoOffset);
|
|
||||||
while (ModuleHeaderPtr != NULL) {
|
|
||||||
SearchStr = (UINT64 *)&ModuleHeaderPtr->ModuleIdentifier;
|
|
||||||
if (*InputStr == *SearchStr) {
|
|
||||||
return CurrentPtr;
|
|
||||||
}
|
|
||||||
ModuleHeaderPtr = (AMD_MODULE_HEADER *)ModuleHeaderPtr->NextBlock;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
CurrentPtr += Alignment;
|
|
||||||
}
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------------------*/
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -298,24 +298,11 @@ LibAmdMemCopy (
|
||||||
IN OUT AMD_CONFIG_PARAMS *StdHeader
|
IN OUT AMD_CONFIG_PARAMS *StdHeader
|
||||||
);
|
);
|
||||||
|
|
||||||
VOID *
|
|
||||||
LibAmdLocateImage (
|
|
||||||
IN VOID *StartAddress,
|
|
||||||
IN VOID *EndAddress,
|
|
||||||
IN UINT32 Alignment,
|
|
||||||
IN CHAR8 ModuleSignature[8]
|
|
||||||
);
|
|
||||||
|
|
||||||
UINT32
|
UINT32
|
||||||
LibAmdGetPackageType (
|
LibAmdGetPackageType (
|
||||||
IN AMD_CONFIG_PARAMS *StdHeader
|
IN AMD_CONFIG_PARAMS *StdHeader
|
||||||
);
|
);
|
||||||
|
|
||||||
BOOLEAN
|
|
||||||
LibAmdVerifyImageChecksum (
|
|
||||||
IN VOID *ImagePtr
|
|
||||||
);
|
|
||||||
|
|
||||||
UINT8
|
UINT8
|
||||||
LibAmdBitScanReverse (
|
LibAmdBitScanReverse (
|
||||||
IN UINT32 value
|
IN UINT32 value
|
||||||
|
|
|
@ -79,19 +79,11 @@ AmdAgesaDispatcher (
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
AGESA_STATUS Status;
|
AGESA_STATUS Status;
|
||||||
IMAGE_ENTRY ImageEntry;
|
|
||||||
MODULE_ENTRY ModuleEntry;
|
MODULE_ENTRY ModuleEntry;
|
||||||
DISPATCH_TABLE *Entry;
|
DISPATCH_TABLE *Entry;
|
||||||
UINT32 ImageStart;
|
|
||||||
UINT32 ImageEnd;
|
|
||||||
CONST AMD_IMAGE_HEADER* AltImagePtr;
|
|
||||||
|
|
||||||
Status = AGESA_UNSUPPORTED;
|
Status = AGESA_UNSUPPORTED;
|
||||||
ImageEntry = NULL;
|
|
||||||
ModuleEntry = NULL;
|
ModuleEntry = NULL;
|
||||||
ImageStart = 0xFFF00000;
|
|
||||||
ImageEnd = 0xFFFFFFFF;
|
|
||||||
AltImagePtr = NULL;
|
|
||||||
|
|
||||||
Entry = (DISPATCH_TABLE *) DispatchTable;
|
Entry = (DISPATCH_TABLE *) DispatchTable;
|
||||||
while (Entry->FunctionId != 0) {
|
while (Entry->FunctionId != 0) {
|
||||||
|
@ -110,21 +102,6 @@ AmdAgesaDispatcher (
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3. If not this image specific function, see if we can find alternative image instead
|
|
||||||
if (Status == AGESA_UNSUPPORTED) {
|
|
||||||
if ((((AMD_CONFIG_PARAMS *)ConfigPtr)->AltImageBasePtr != 0xFFFFFFFF ) && (((AMD_CONFIG_PARAMS *)ConfigPtr)->AltImageBasePtr != 0)) {
|
|
||||||
ImageStart = ((AMD_CONFIG_PARAMS *)ConfigPtr)->AltImageBasePtr;
|
|
||||||
ImageEnd = ImageStart + 4;
|
|
||||||
// Locate/test image base that matches this component
|
|
||||||
AltImagePtr = LibAmdLocateImage ((VOID *) (intptr_t) ImageStart, (VOID *) (intptr_t) ImageEnd, 4096, (CHAR8 *)AGESA_ID);
|
|
||||||
if (AltImagePtr != NULL) {
|
|
||||||
//Invoke alternative Image
|
|
||||||
ImageEntry = (IMAGE_ENTRY) ((intptr_t) AltImagePtr + AltImagePtr->EntryPointAddress);
|
|
||||||
Status = (*ImageEntry) (ConfigPtr);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return (Status);
|
return (Status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1135,92 +1135,6 @@ LibAmdMemCopy (
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------------------*/
|
|
||||||
/**
|
|
||||||
* Verify checksum of binary image (B1/B2/B3)
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* @param[in] ImagePtr Pointer to image start
|
|
||||||
* @retval TRUE Checksum valid
|
|
||||||
* @retval FALSE Checksum invalid
|
|
||||||
*/
|
|
||||||
BOOLEAN
|
|
||||||
LibAmdVerifyImageChecksum (
|
|
||||||
IN CONST VOID *ImagePtr
|
|
||||||
)
|
|
||||||
{
|
|
||||||
// Assume ImagePtr points to the binary start ($AMD)
|
|
||||||
// Checksum is on an even boundary in AMD_IMAGE_HEADER
|
|
||||||
|
|
||||||
UINT16 Sum;
|
|
||||||
UINT32 i;
|
|
||||||
|
|
||||||
Sum = 0;
|
|
||||||
|
|
||||||
i = ((AMD_IMAGE_HEADER*) ImagePtr)->ImageSize;
|
|
||||||
|
|
||||||
while (i > 1) {
|
|
||||||
Sum = Sum + *((UINT16 *)ImagePtr);
|
|
||||||
ImagePtr = (VOID *) ((UINT8 *)ImagePtr + 2);
|
|
||||||
i = i - 2;
|
|
||||||
}
|
|
||||||
if (i > 0) {
|
|
||||||
Sum = Sum + *((UINT8 *) ImagePtr);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (Sum == 0)?TRUE:FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------------------*/
|
|
||||||
/**
|
|
||||||
* Locate AMD binary image that contain specific module
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* @param[in] StartAddress Pointer to start range
|
|
||||||
* @param[in] EndAddress Pointer to end range
|
|
||||||
* @param[in] Alignment Image address alignment
|
|
||||||
* @param[in] ModuleSignature Module signature.
|
|
||||||
* @retval NULL if image not found
|
|
||||||
* @retval pointer to image header
|
|
||||||
*/
|
|
||||||
CONST VOID *
|
|
||||||
LibAmdLocateImage (
|
|
||||||
IN CONST VOID *StartAddress,
|
|
||||||
IN CONST VOID *EndAddress,
|
|
||||||
IN UINT32 Alignment,
|
|
||||||
IN CONST CHAR8 ModuleSignature[8]
|
|
||||||
)
|
|
||||||
|
|
||||||
{
|
|
||||||
CONST UINT8 *CurrentPtr;
|
|
||||||
AMD_MODULE_HEADER *ModuleHeaderPtr;
|
|
||||||
CONST UINT64 *SearchStr;
|
|
||||||
CONST UINT64 *InputStr;
|
|
||||||
|
|
||||||
CurrentPtr = StartAddress;
|
|
||||||
InputStr = (UINT64 *)ModuleSignature;
|
|
||||||
|
|
||||||
// Search from start to end incrementing by alignment
|
|
||||||
while ((CurrentPtr >= (UINT8 *) StartAddress) && (CurrentPtr < (UINT8 *) EndAddress)) {
|
|
||||||
// First find a binary image
|
|
||||||
if (*((UINT32 *) CurrentPtr) == IMAGE_SIGNATURE) {
|
|
||||||
if (LibAmdVerifyImageChecksum (CurrentPtr)) {
|
|
||||||
// If we have a valid image, search module linked list for a match
|
|
||||||
ModuleHeaderPtr = (AMD_MODULE_HEADER*) ((UINT8 *)CurrentPtr + ((AMD_IMAGE_HEADER *) CurrentPtr)->ModuleInfoOffset);
|
|
||||||
while (ModuleHeaderPtr != NULL) {
|
|
||||||
SearchStr = (UINT64 *)&ModuleHeaderPtr->ModuleIdentifier;
|
|
||||||
if (*InputStr == *SearchStr) {
|
|
||||||
return CurrentPtr;
|
|
||||||
}
|
|
||||||
ModuleHeaderPtr = (AMD_MODULE_HEADER *)ModuleHeaderPtr->NextBlock;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
CurrentPtr += Alignment;
|
|
||||||
}
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------------------*/
|
||||||
/**
|
/**
|
||||||
* Returns the package type mask for the processor
|
* Returns the package type mask for the processor
|
||||||
|
|
|
@ -329,24 +329,11 @@ LibAmdMemCopy (
|
||||||
IN OUT AMD_CONFIG_PARAMS *StdHeader
|
IN OUT AMD_CONFIG_PARAMS *StdHeader
|
||||||
);
|
);
|
||||||
|
|
||||||
CONST VOID *
|
|
||||||
LibAmdLocateImage (
|
|
||||||
IN CONST VOID *StartAddress,
|
|
||||||
IN CONST VOID *EndAddress,
|
|
||||||
IN UINT32 Alignment,
|
|
||||||
IN CONST CHAR8 ModuleSignature[8]
|
|
||||||
);
|
|
||||||
|
|
||||||
UINT32
|
UINT32
|
||||||
LibAmdGetPackageType (
|
LibAmdGetPackageType (
|
||||||
IN AMD_CONFIG_PARAMS *StdHeader
|
IN AMD_CONFIG_PARAMS *StdHeader
|
||||||
);
|
);
|
||||||
|
|
||||||
BOOLEAN
|
|
||||||
LibAmdVerifyImageChecksum (
|
|
||||||
IN CONST VOID *ImagePtr
|
|
||||||
);
|
|
||||||
|
|
||||||
UINT8
|
UINT8
|
||||||
LibAmdBitScanReverse (
|
LibAmdBitScanReverse (
|
||||||
IN UINT32 value
|
IN UINT32 value
|
||||||
|
|
|
@ -82,19 +82,11 @@ AmdAgesaDispatcher (
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
AGESA_STATUS Status;
|
AGESA_STATUS Status;
|
||||||
IMAGE_ENTRY ImageEntry;
|
|
||||||
MODULE_ENTRY ModuleEntry;
|
MODULE_ENTRY ModuleEntry;
|
||||||
DISPATCH_TABLE *Entry;
|
DISPATCH_TABLE *Entry;
|
||||||
UINTN ImageStart;
|
|
||||||
UINTN ImageEnd;
|
|
||||||
CONST AMD_IMAGE_HEADER* AltImagePtr;
|
|
||||||
|
|
||||||
Status = AGESA_UNSUPPORTED;
|
Status = AGESA_UNSUPPORTED;
|
||||||
ImageEntry = NULL;
|
|
||||||
ModuleEntry = NULL;
|
ModuleEntry = NULL;
|
||||||
ImageStart = 0xFFF00000;
|
|
||||||
ImageEnd = 0xFFFFFFFF;
|
|
||||||
AltImagePtr = NULL;
|
|
||||||
|
|
||||||
Entry = (DISPATCH_TABLE *) DispatchTable;
|
Entry = (DISPATCH_TABLE *) DispatchTable;
|
||||||
while (Entry->FunctionId != 0) {
|
while (Entry->FunctionId != 0) {
|
||||||
|
@ -113,21 +105,6 @@ AmdAgesaDispatcher (
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3. If not this image specific function, see if we can find alternative image instead
|
|
||||||
if (Status == AGESA_UNSUPPORTED) {
|
|
||||||
if ((((AMD_CONFIG_PARAMS *)ConfigPtr)->AltImageBasePtr != 0xFFFFFFFF ) && (((AMD_CONFIG_PARAMS *)ConfigPtr)->AltImageBasePtr != 0)) {
|
|
||||||
ImageStart = ((AMD_CONFIG_PARAMS *)ConfigPtr)->AltImageBasePtr;
|
|
||||||
ImageEnd = ImageStart + 4;
|
|
||||||
// Locate/test image base that matches this component
|
|
||||||
AltImagePtr = LibAmdLocateImage ((VOID *)ImageStart, (VOID *)ImageEnd, 4096, (CHAR8 *)AGESA_ID);
|
|
||||||
if (AltImagePtr != NULL) {
|
|
||||||
//Invoke alternative Image
|
|
||||||
ImageEntry = (IMAGE_ENTRY) (AltImagePtr + AltImagePtr->EntryPointAddress);
|
|
||||||
Status = (*ImageEntry) (ConfigPtr);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return (Status);
|
return (Status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1135,92 +1135,6 @@ LibAmdMemCopy (
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------------------*/
|
|
||||||
/**
|
|
||||||
* Verify checksum of binary image (B1/B2/B3)
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* @param[in] ImagePtr Pointer to image start
|
|
||||||
* @retval TRUE Checksum valid
|
|
||||||
* @retval FALSE Checksum invalid
|
|
||||||
*/
|
|
||||||
BOOLEAN
|
|
||||||
LibAmdVerifyImageChecksum (
|
|
||||||
IN CONST VOID *ImagePtr
|
|
||||||
)
|
|
||||||
{
|
|
||||||
// Assume ImagePtr points to the binary start ($AMD)
|
|
||||||
// Checksum is on an even boundary in AMD_IMAGE_HEADER
|
|
||||||
|
|
||||||
UINT16 Sum;
|
|
||||||
UINT32 i;
|
|
||||||
|
|
||||||
Sum = 0;
|
|
||||||
|
|
||||||
i = ((AMD_IMAGE_HEADER*) ImagePtr)->ImageSize;
|
|
||||||
|
|
||||||
while (i > 1) {
|
|
||||||
Sum = Sum + *((UINT16 *)ImagePtr);
|
|
||||||
ImagePtr = (VOID *) ((UINT8 *)ImagePtr + 2);
|
|
||||||
i = i - 2;
|
|
||||||
}
|
|
||||||
if (i > 0) {
|
|
||||||
Sum = Sum + *((UINT8 *) ImagePtr);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (Sum == 0)?TRUE:FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------------------*/
|
|
||||||
/**
|
|
||||||
* Locate AMD binary image that contain specific module
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* @param[in] StartAddress Pointer to start range
|
|
||||||
* @param[in] EndAddress Pointer to end range
|
|
||||||
* @param[in] Alignment Image address alignment
|
|
||||||
* @param[in] ModuleSignature Module signature.
|
|
||||||
* @retval NULL if image not found
|
|
||||||
* @retval pointer to image header
|
|
||||||
*/
|
|
||||||
CONST VOID *
|
|
||||||
LibAmdLocateImage (
|
|
||||||
IN CONST VOID *StartAddress,
|
|
||||||
IN CONST VOID *EndAddress,
|
|
||||||
IN UINT32 Alignment,
|
|
||||||
IN CONST CHAR8 ModuleSignature[8]
|
|
||||||
)
|
|
||||||
|
|
||||||
{
|
|
||||||
CONST UINT8 *CurrentPtr;
|
|
||||||
AMD_MODULE_HEADER *ModuleHeaderPtr;
|
|
||||||
CONST UINT64 *SearchStr;
|
|
||||||
CONST UINT64 *InputStr;
|
|
||||||
|
|
||||||
CurrentPtr = StartAddress;
|
|
||||||
InputStr = (UINT64 *)ModuleSignature;
|
|
||||||
|
|
||||||
// Search from start to end incrementing by alignment
|
|
||||||
while ((CurrentPtr >= (UINT8 *) StartAddress) && (CurrentPtr < (UINT8 *) EndAddress)) {
|
|
||||||
// First find a binary image
|
|
||||||
if (*((UINT32 *) CurrentPtr) == IMAGE_SIGNATURE) {
|
|
||||||
if (LibAmdVerifyImageChecksum (CurrentPtr)) {
|
|
||||||
// If we have a valid image, search module linked list for a match
|
|
||||||
ModuleHeaderPtr = (AMD_MODULE_HEADER*) ((UINT8 *)CurrentPtr + ((AMD_IMAGE_HEADER *) CurrentPtr)->ModuleInfoOffset);
|
|
||||||
while (ModuleHeaderPtr != NULL) {
|
|
||||||
SearchStr = (UINT64 *)&ModuleHeaderPtr->ModuleIdentifier;
|
|
||||||
if (*InputStr == *SearchStr) {
|
|
||||||
return CurrentPtr;
|
|
||||||
}
|
|
||||||
ModuleHeaderPtr = (AMD_MODULE_HEADER *)ModuleHeaderPtr->NextBlock;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
CurrentPtr += Alignment;
|
|
||||||
}
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------------------*/
|
||||||
/**
|
/**
|
||||||
* Returns the package type mask for the processor
|
* Returns the package type mask for the processor
|
||||||
|
|
|
@ -331,24 +331,11 @@ LibAmdMemCopy (
|
||||||
IN OUT AMD_CONFIG_PARAMS *StdHeader
|
IN OUT AMD_CONFIG_PARAMS *StdHeader
|
||||||
);
|
);
|
||||||
|
|
||||||
CONST VOID *
|
|
||||||
LibAmdLocateImage (
|
|
||||||
IN CONST VOID *StartAddress,
|
|
||||||
IN CONST VOID *EndAddress,
|
|
||||||
IN UINT32 Alignment,
|
|
||||||
IN CONST CHAR8 ModuleSignature[8]
|
|
||||||
);
|
|
||||||
|
|
||||||
UINT32
|
UINT32
|
||||||
LibAmdGetPackageType (
|
LibAmdGetPackageType (
|
||||||
IN AMD_CONFIG_PARAMS *StdHeader
|
IN AMD_CONFIG_PARAMS *StdHeader
|
||||||
);
|
);
|
||||||
|
|
||||||
BOOLEAN
|
|
||||||
LibAmdVerifyImageChecksum (
|
|
||||||
IN CONST VOID *ImagePtr
|
|
||||||
);
|
|
||||||
|
|
||||||
UINT8
|
UINT8
|
||||||
LibAmdBitScanReverse (
|
LibAmdBitScanReverse (
|
||||||
IN UINT32 value
|
IN UINT32 value
|
||||||
|
|
|
@ -80,19 +80,11 @@ AmdAgesaDispatcher (
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
AGESA_STATUS Status;
|
AGESA_STATUS Status;
|
||||||
IMAGE_ENTRY ImageEntry;
|
|
||||||
MODULE_ENTRY ModuleEntry;
|
MODULE_ENTRY ModuleEntry;
|
||||||
DISPATCH_TABLE *Entry;
|
DISPATCH_TABLE *Entry;
|
||||||
UINTN ImageStart;
|
|
||||||
UINTN ImageEnd;
|
|
||||||
AMD_IMAGE_HEADER* AltImagePtr;
|
|
||||||
|
|
||||||
Status = AGESA_UNSUPPORTED;
|
Status = AGESA_UNSUPPORTED;
|
||||||
ImageEntry = NULL;
|
|
||||||
ModuleEntry = NULL;
|
ModuleEntry = NULL;
|
||||||
ImageStart = 0xFFF00000;
|
|
||||||
ImageEnd = 0xFFFFFFFF;
|
|
||||||
AltImagePtr = NULL;
|
|
||||||
|
|
||||||
Entry = (DISPATCH_TABLE *) DispatchTable;
|
Entry = (DISPATCH_TABLE *) DispatchTable;
|
||||||
while (Entry->FunctionId != 0) {
|
while (Entry->FunctionId != 0) {
|
||||||
|
@ -111,21 +103,6 @@ AmdAgesaDispatcher (
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3. If not this image specific function, see if we can find alternative image instead
|
|
||||||
if (Status == AGESA_UNSUPPORTED) {
|
|
||||||
if ((((AMD_CONFIG_PARAMS *)ConfigPtr)->AltImageBasePtr != 0xFFFFFFFF ) && (((AMD_CONFIG_PARAMS *)ConfigPtr)->AltImageBasePtr != 0)) {
|
|
||||||
ImageStart = ((AMD_CONFIG_PARAMS *)ConfigPtr)->AltImageBasePtr;
|
|
||||||
ImageEnd = ImageStart + 4;
|
|
||||||
// Locate/test image base that matches this component
|
|
||||||
AltImagePtr = LibAmdLocateImage ((VOID *) /* (UINT64) */ImageStart, (VOID *) /* (UINT64) */ImageEnd, 4096, (CHAR8 *) AGESA_ID);
|
|
||||||
if (AltImagePtr != NULL) {
|
|
||||||
//Invoke alternative Image
|
|
||||||
ImageEntry = (IMAGE_ENTRY) (/* (UINT64) */ AltImagePtr + AltImagePtr->EntryPointAddress);
|
|
||||||
Status = (*ImageEntry) (ConfigPtr);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return (Status);
|
return (Status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1156,92 +1156,6 @@ LibAmdMemCopy (
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------------------*/
|
|
||||||
/**
|
|
||||||
* Verify checksum of binary image (B1/B2/B3)
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* @param[in] ImagePtr Pointer to image start
|
|
||||||
* @retval TRUE Checksum valid
|
|
||||||
* @retval FALSE Checksum invalid
|
|
||||||
*/
|
|
||||||
BOOLEAN
|
|
||||||
LibAmdVerifyImageChecksum (
|
|
||||||
IN VOID *ImagePtr
|
|
||||||
)
|
|
||||||
{
|
|
||||||
// Assume ImagePtr points to the binary start ($AMD)
|
|
||||||
// Checksum is on an even boundary in AMD_IMAGE_HEADER
|
|
||||||
|
|
||||||
UINT16 Sum;
|
|
||||||
UINT32 i;
|
|
||||||
|
|
||||||
Sum = 0;
|
|
||||||
|
|
||||||
i = ((AMD_IMAGE_HEADER*) ImagePtr)->ImageSize;
|
|
||||||
|
|
||||||
while (i > 1) {
|
|
||||||
Sum = Sum + *((UINT16 *)ImagePtr);
|
|
||||||
ImagePtr = (VOID *) ((UINT8 *)ImagePtr + 2);
|
|
||||||
i = i - 2;
|
|
||||||
}
|
|
||||||
if (i > 0) {
|
|
||||||
Sum = Sum + *((UINT8 *) ImagePtr);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (Sum == 0)?TRUE:FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------------------*/
|
|
||||||
/**
|
|
||||||
* Locate AMD binary image that contain specific module
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* @param[in] StartAddress Pointer to start range
|
|
||||||
* @param[in] EndAddress Pointer to end range
|
|
||||||
* @param[in] Alignment Image address alignment
|
|
||||||
* @param[in] ModuleSignature Module signature.
|
|
||||||
* @retval NULL if image not found
|
|
||||||
* @retval pointer to image header
|
|
||||||
*/
|
|
||||||
VOID *
|
|
||||||
LibAmdLocateImage (
|
|
||||||
IN VOID *StartAddress,
|
|
||||||
IN VOID *EndAddress,
|
|
||||||
IN UINT32 Alignment,
|
|
||||||
IN CHAR8 ModuleSignature[8]
|
|
||||||
)
|
|
||||||
|
|
||||||
{
|
|
||||||
UINT8 *CurrentPtr;
|
|
||||||
AMD_MODULE_HEADER *ModuleHeaderPtr;
|
|
||||||
UINT64 *SearchStr;
|
|
||||||
UINT64 *InputStr;
|
|
||||||
|
|
||||||
CurrentPtr = StartAddress;
|
|
||||||
InputStr = (UINT64 *)ModuleSignature;
|
|
||||||
|
|
||||||
// Search from start to end incrementing by alignment
|
|
||||||
while ((CurrentPtr >= (UINT8 *) StartAddress) && (CurrentPtr < (UINT8 *) EndAddress)) {
|
|
||||||
// First find a binary image
|
|
||||||
if (*((UINT32 *) CurrentPtr) == IMAGE_SIGNATURE) {
|
|
||||||
if (LibAmdVerifyImageChecksum (CurrentPtr)) {
|
|
||||||
// If we have a valid image, search module linked list for a match
|
|
||||||
ModuleHeaderPtr = (AMD_MODULE_HEADER*) ((UINT8 *)CurrentPtr + ((AMD_IMAGE_HEADER *) CurrentPtr)->ModuleInfoOffset);
|
|
||||||
while (ModuleHeaderPtr != NULL) {
|
|
||||||
SearchStr = (UINT64 *)&ModuleHeaderPtr->ModuleIdentifier;
|
|
||||||
if (*InputStr == *SearchStr) {
|
|
||||||
return CurrentPtr;
|
|
||||||
}
|
|
||||||
ModuleHeaderPtr = (AMD_MODULE_HEADER *)ModuleHeaderPtr->NextBlock;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
CurrentPtr += Alignment;
|
|
||||||
}
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------------------*/
|
||||||
/**
|
/**
|
||||||
* Returns the package type mask for the processor
|
* Returns the package type mask for the processor
|
||||||
|
|
|
@ -313,24 +313,11 @@ LibAmdMemCopy (
|
||||||
IN OUT AMD_CONFIG_PARAMS *StdHeader
|
IN OUT AMD_CONFIG_PARAMS *StdHeader
|
||||||
);
|
);
|
||||||
|
|
||||||
VOID *
|
|
||||||
LibAmdLocateImage (
|
|
||||||
IN VOID *StartAddress,
|
|
||||||
IN VOID *EndAddress,
|
|
||||||
IN UINT32 Alignment,
|
|
||||||
IN CHAR8 ModuleSignature[8]
|
|
||||||
);
|
|
||||||
|
|
||||||
UINT32
|
UINT32
|
||||||
LibAmdGetPackageType (
|
LibAmdGetPackageType (
|
||||||
IN AMD_CONFIG_PARAMS *StdHeader
|
IN AMD_CONFIG_PARAMS *StdHeader
|
||||||
);
|
);
|
||||||
|
|
||||||
BOOLEAN
|
|
||||||
LibAmdVerifyImageChecksum (
|
|
||||||
IN VOID *ImagePtr
|
|
||||||
);
|
|
||||||
|
|
||||||
UINT8
|
UINT8
|
||||||
LibAmdBitScanReverse (
|
LibAmdBitScanReverse (
|
||||||
IN UINT32 value
|
IN UINT32 value
|
||||||
|
|
|
@ -79,19 +79,11 @@ AmdAgesaDispatcher (
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
AGESA_STATUS Status;
|
AGESA_STATUS Status;
|
||||||
IMAGE_ENTRY ImageEntry;
|
|
||||||
MODULE_ENTRY ModuleEntry;
|
MODULE_ENTRY ModuleEntry;
|
||||||
DISPATCH_TABLE *Entry;
|
DISPATCH_TABLE *Entry;
|
||||||
UINTN ImageStart;
|
|
||||||
UINTN ImageEnd;
|
|
||||||
CONST AMD_IMAGE_HEADER* AltImagePtr;
|
|
||||||
|
|
||||||
Status = AGESA_UNSUPPORTED;
|
Status = AGESA_UNSUPPORTED;
|
||||||
ImageEntry = NULL;
|
|
||||||
ModuleEntry = NULL;
|
ModuleEntry = NULL;
|
||||||
ImageStart = 0xFFF00000;
|
|
||||||
ImageEnd = 0xFFFFFFFF;
|
|
||||||
AltImagePtr = NULL;
|
|
||||||
|
|
||||||
Entry = (DISPATCH_TABLE *) DispatchTable;
|
Entry = (DISPATCH_TABLE *) DispatchTable;
|
||||||
while (Entry->FunctionId != 0) {
|
while (Entry->FunctionId != 0) {
|
||||||
|
@ -110,21 +102,6 @@ AmdAgesaDispatcher (
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3. If not this image specific function, see if we can find alternative image instead
|
|
||||||
if (Status == AGESA_UNSUPPORTED) {
|
|
||||||
if ((((AMD_CONFIG_PARAMS *)ConfigPtr)->AltImageBasePtr != 0xFFFFFFFF ) && (((AMD_CONFIG_PARAMS *)ConfigPtr)->AltImageBasePtr != 0)) {
|
|
||||||
ImageStart = ((AMD_CONFIG_PARAMS *)ConfigPtr)->AltImageBasePtr;
|
|
||||||
ImageEnd = ImageStart + 4;
|
|
||||||
// Locate/test image base that matches this component
|
|
||||||
AltImagePtr = LibAmdLocateImage ((VOID *) /* (UINT64) */ImageStart, (VOID *) /* (UINT64) */ImageEnd, 4096, (CHAR8 *) AGESA_ID);
|
|
||||||
if (AltImagePtr != NULL) {
|
|
||||||
//Invoke alternative Image
|
|
||||||
ImageEntry = (IMAGE_ENTRY) (/* (UINT64) */ AltImagePtr + AltImagePtr->EntryPointAddress);
|
|
||||||
Status = (*ImageEntry) (ConfigPtr);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return (Status);
|
return (Status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1157,92 +1157,6 @@ LibAmdMemCopy (
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------------------*/
|
|
||||||
/**
|
|
||||||
* Verify checksum of binary image (B1/B2/B3)
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* @param[in] ImagePtr Pointer to image start
|
|
||||||
* @retval TRUE Checksum valid
|
|
||||||
* @retval FALSE Checksum invalid
|
|
||||||
*/
|
|
||||||
BOOLEAN
|
|
||||||
LibAmdVerifyImageChecksum (
|
|
||||||
IN CONST VOID *ImagePtr
|
|
||||||
)
|
|
||||||
{
|
|
||||||
// Assume ImagePtr points to the binary start ($AMD)
|
|
||||||
// Checksum is on an even boundary in AMD_IMAGE_HEADER
|
|
||||||
|
|
||||||
UINT16 Sum;
|
|
||||||
UINT32 i;
|
|
||||||
|
|
||||||
Sum = 0;
|
|
||||||
|
|
||||||
i = ((AMD_IMAGE_HEADER*) ImagePtr)->ImageSize;
|
|
||||||
|
|
||||||
while (i > 1) {
|
|
||||||
Sum = Sum + *((UINT16 *)ImagePtr);
|
|
||||||
ImagePtr = (VOID *) ((UINT8 *)ImagePtr + 2);
|
|
||||||
i = i - 2;
|
|
||||||
}
|
|
||||||
if (i > 0) {
|
|
||||||
Sum = Sum + *((UINT8 *) ImagePtr);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (Sum == 0)?TRUE:FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------------------*/
|
|
||||||
/**
|
|
||||||
* Locate AMD binary image that contain specific module
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* @param[in] StartAddress Pointer to start range
|
|
||||||
* @param[in] EndAddress Pointer to end range
|
|
||||||
* @param[in] Alignment Image address alignment
|
|
||||||
* @param[in] ModuleSignature Module signature.
|
|
||||||
* @retval NULL if image not found
|
|
||||||
* @retval pointer to image header
|
|
||||||
*/
|
|
||||||
CONST VOID *
|
|
||||||
LibAmdLocateImage (
|
|
||||||
IN CONST VOID *StartAddress,
|
|
||||||
IN CONST VOID *EndAddress,
|
|
||||||
IN UINT32 Alignment,
|
|
||||||
IN CONST CHAR8 ModuleSignature[8]
|
|
||||||
)
|
|
||||||
|
|
||||||
{
|
|
||||||
CONST UINT8 *CurrentPtr;
|
|
||||||
AMD_MODULE_HEADER *ModuleHeaderPtr;
|
|
||||||
CONST UINT64 *SearchStr;
|
|
||||||
CONST UINT64 *InputStr;
|
|
||||||
|
|
||||||
CurrentPtr = StartAddress;
|
|
||||||
InputStr = (UINT64 *)ModuleSignature;
|
|
||||||
|
|
||||||
// Search from start to end incrementing by alignment
|
|
||||||
while ((CurrentPtr >= (UINT8 *) StartAddress) && (CurrentPtr < (UINT8 *) EndAddress)) {
|
|
||||||
// First find a binary image
|
|
||||||
if (*((UINT32 *) CurrentPtr) == IMAGE_SIGNATURE) {
|
|
||||||
if (LibAmdVerifyImageChecksum (CurrentPtr)) {
|
|
||||||
// If we have a valid image, search module linked list for a match
|
|
||||||
ModuleHeaderPtr = (AMD_MODULE_HEADER*) ((UINT8 *)CurrentPtr + ((AMD_IMAGE_HEADER *) CurrentPtr)->ModuleInfoOffset);
|
|
||||||
while (ModuleHeaderPtr != NULL) {
|
|
||||||
SearchStr = (UINT64 *)&ModuleHeaderPtr->ModuleIdentifier;
|
|
||||||
if (*InputStr == *SearchStr) {
|
|
||||||
return CurrentPtr;
|
|
||||||
}
|
|
||||||
ModuleHeaderPtr = (AMD_MODULE_HEADER *)ModuleHeaderPtr->NextBlock;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
CurrentPtr += Alignment;
|
|
||||||
}
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------------------*/
|
||||||
/**
|
/**
|
||||||
* Returns the package type mask for the processor
|
* Returns the package type mask for the processor
|
||||||
|
|
|
@ -299,24 +299,11 @@ LibAmdMemCopy (
|
||||||
IN OUT AMD_CONFIG_PARAMS *StdHeader
|
IN OUT AMD_CONFIG_PARAMS *StdHeader
|
||||||
);
|
);
|
||||||
|
|
||||||
CONST VOID *
|
|
||||||
LibAmdLocateImage (
|
|
||||||
IN CONST VOID *StartAddress,
|
|
||||||
IN CONST VOID *EndAddress,
|
|
||||||
IN UINT32 Alignment,
|
|
||||||
IN CONST CHAR8 ModuleSignature[8]
|
|
||||||
);
|
|
||||||
|
|
||||||
UINT32
|
UINT32
|
||||||
LibAmdGetPackageType (
|
LibAmdGetPackageType (
|
||||||
IN AMD_CONFIG_PARAMS *StdHeader
|
IN AMD_CONFIG_PARAMS *StdHeader
|
||||||
);
|
);
|
||||||
|
|
||||||
BOOLEAN
|
|
||||||
LibAmdVerifyImageChecksum (
|
|
||||||
IN CONST VOID *ImagePtr
|
|
||||||
);
|
|
||||||
|
|
||||||
UINT8
|
UINT8
|
||||||
LibAmdBitScanReverse (
|
LibAmdBitScanReverse (
|
||||||
IN UINT32 value
|
IN UINT32 value
|
||||||
|
|
|
@ -79,19 +79,11 @@ AmdAgesaDispatcher (
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
AGESA_STATUS Status;
|
AGESA_STATUS Status;
|
||||||
IMAGE_ENTRY ImageEntry;
|
|
||||||
MODULE_ENTRY ModuleEntry;
|
MODULE_ENTRY ModuleEntry;
|
||||||
DISPATCH_TABLE *Entry;
|
DISPATCH_TABLE *Entry;
|
||||||
UINTN ImageStart;
|
|
||||||
UINTN ImageEnd;
|
|
||||||
CONST AMD_IMAGE_HEADER* AltImagePtr;
|
|
||||||
|
|
||||||
Status = AGESA_UNSUPPORTED;
|
Status = AGESA_UNSUPPORTED;
|
||||||
ImageEntry = NULL;
|
|
||||||
ModuleEntry = NULL;
|
ModuleEntry = NULL;
|
||||||
ImageStart = 0xFFF00000;
|
|
||||||
ImageEnd = 0xFFFFFFFF;
|
|
||||||
AltImagePtr = NULL;
|
|
||||||
|
|
||||||
Entry = (DISPATCH_TABLE *) DispatchTable;
|
Entry = (DISPATCH_TABLE *) DispatchTable;
|
||||||
while (Entry->FunctionId != 0) {
|
while (Entry->FunctionId != 0) {
|
||||||
|
@ -110,21 +102,6 @@ AmdAgesaDispatcher (
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3. If not this image specific function, see if we can find alternative image instead
|
|
||||||
if (Status == AGESA_UNSUPPORTED) {
|
|
||||||
if ((((AMD_CONFIG_PARAMS *)ConfigPtr)->AltImageBasePtr != 0xFFFFFFFF ) && (((AMD_CONFIG_PARAMS *)ConfigPtr)->AltImageBasePtr != 0)) {
|
|
||||||
ImageStart = ((AMD_CONFIG_PARAMS *)ConfigPtr)->AltImageBasePtr;
|
|
||||||
ImageEnd = ImageStart + 4;
|
|
||||||
// Locate/test image base that matches this component
|
|
||||||
AltImagePtr = LibAmdLocateImage ((VOID *)ImageStart, (VOID *)ImageEnd, 4096, (CHAR8 *) AGESA_ID);
|
|
||||||
if (AltImagePtr != NULL) {
|
|
||||||
//Invoke alternative Image
|
|
||||||
ImageEntry = (IMAGE_ENTRY) ((UINTN) AltImagePtr + AltImagePtr->EntryPointAddress);
|
|
||||||
Status = (*ImageEntry) (ConfigPtr);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return (Status);
|
return (Status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1162,92 +1162,6 @@ LibAmdMemCopy (
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------------------*/
|
|
||||||
/**
|
|
||||||
* Verify checksum of binary image (B1/B2/B3)
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* @param[in] ImagePtr Pointer to image start
|
|
||||||
* @retval TRUE Checksum valid
|
|
||||||
* @retval FALSE Checksum invalid
|
|
||||||
*/
|
|
||||||
BOOLEAN
|
|
||||||
LibAmdVerifyImageChecksum (
|
|
||||||
IN CONST VOID *ImagePtr
|
|
||||||
)
|
|
||||||
{
|
|
||||||
// Assume ImagePtr points to the binary start ($AMD)
|
|
||||||
// Checksum is on an even boundary in AMD_IMAGE_HEADER
|
|
||||||
|
|
||||||
UINT16 Sum;
|
|
||||||
UINT32 i;
|
|
||||||
|
|
||||||
Sum = 0;
|
|
||||||
|
|
||||||
i = ((AMD_IMAGE_HEADER*) ImagePtr)->ImageSize;
|
|
||||||
|
|
||||||
while (i > 1) {
|
|
||||||
Sum = Sum + *((UINT16 *)ImagePtr);
|
|
||||||
ImagePtr = (VOID *) ((UINT8 *)ImagePtr + 2);
|
|
||||||
i = i - 2;
|
|
||||||
}
|
|
||||||
if (i > 0) {
|
|
||||||
Sum = Sum + *((UINT8 *) ImagePtr);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (Sum == 0)?TRUE:FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------------------*/
|
|
||||||
/**
|
|
||||||
* Locate AMD binary image that contain specific module
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* @param[in] StartAddress Pointer to start range
|
|
||||||
* @param[in] EndAddress Pointer to end range
|
|
||||||
* @param[in] Alignment Image address alignment
|
|
||||||
* @param[in] ModuleSignature Module signature.
|
|
||||||
* @retval NULL if image not found
|
|
||||||
* @retval pointer to image header
|
|
||||||
*/
|
|
||||||
CONST VOID *
|
|
||||||
LibAmdLocateImage (
|
|
||||||
IN CONST VOID *StartAddress,
|
|
||||||
IN CONST VOID *EndAddress,
|
|
||||||
IN UINT32 Alignment,
|
|
||||||
IN CONST CHAR8 ModuleSignature[8]
|
|
||||||
)
|
|
||||||
|
|
||||||
{
|
|
||||||
CONST UINT8 *CurrentPtr;
|
|
||||||
AMD_MODULE_HEADER *ModuleHeaderPtr;
|
|
||||||
CONST UINT64 *SearchStr;
|
|
||||||
CONST UINT64 *InputStr;
|
|
||||||
|
|
||||||
CurrentPtr = StartAddress;
|
|
||||||
InputStr = (UINT64 *)ModuleSignature;
|
|
||||||
|
|
||||||
// Search from start to end incrementing by alignment
|
|
||||||
while ((CurrentPtr >= (UINT8 *) StartAddress) && (CurrentPtr < (UINT8 *) EndAddress)) {
|
|
||||||
// First find a binary image
|
|
||||||
if (*((UINT32 *) CurrentPtr) == IMAGE_SIGNATURE) {
|
|
||||||
if (LibAmdVerifyImageChecksum (CurrentPtr)) {
|
|
||||||
// If we have a valid image, search module linked list for a match
|
|
||||||
ModuleHeaderPtr = (AMD_MODULE_HEADER*) ((UINT8 *)CurrentPtr + ((AMD_IMAGE_HEADER *) CurrentPtr)->ModuleInfoOffset);
|
|
||||||
while (ModuleHeaderPtr != NULL) {
|
|
||||||
SearchStr = (UINT64 *)&ModuleHeaderPtr->ModuleIdentifier;
|
|
||||||
if (*InputStr == *SearchStr) {
|
|
||||||
return CurrentPtr;
|
|
||||||
}
|
|
||||||
ModuleHeaderPtr = (AMD_MODULE_HEADER *)ModuleHeaderPtr->NextBlock;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
CurrentPtr += Alignment;
|
|
||||||
}
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------------------*/
|
||||||
/**
|
/**
|
||||||
* Returns the package type mask for the processor
|
* Returns the package type mask for the processor
|
||||||
|
|
|
@ -299,24 +299,11 @@ LibAmdMemCopy (
|
||||||
IN OUT AMD_CONFIG_PARAMS *StdHeader
|
IN OUT AMD_CONFIG_PARAMS *StdHeader
|
||||||
);
|
);
|
||||||
|
|
||||||
CONST VOID *
|
|
||||||
LibAmdLocateImage (
|
|
||||||
IN CONST VOID *StartAddress,
|
|
||||||
IN CONST VOID *EndAddress,
|
|
||||||
IN UINT32 Alignment,
|
|
||||||
IN CONST CHAR8 ModuleSignature[8]
|
|
||||||
);
|
|
||||||
|
|
||||||
UINT32
|
UINT32
|
||||||
LibAmdGetPackageType (
|
LibAmdGetPackageType (
|
||||||
IN AMD_CONFIG_PARAMS *StdHeader
|
IN AMD_CONFIG_PARAMS *StdHeader
|
||||||
);
|
);
|
||||||
|
|
||||||
BOOLEAN
|
|
||||||
LibAmdVerifyImageChecksum (
|
|
||||||
IN CONST VOID *ImagePtr
|
|
||||||
);
|
|
||||||
|
|
||||||
UINT8
|
UINT8
|
||||||
LibAmdBitScanReverse (
|
LibAmdBitScanReverse (
|
||||||
IN UINT32 value
|
IN UINT32 value
|
||||||
|
|
Loading…
Reference in New Issue