From: bbahnsen Date: Thu, 1 Jun 2006 18:26:22 +0000 (+0000) Subject: Removing unused code. X-Git-Tag: edk2-stable201903~25359 X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=commitdiff_plain;h=1322edae9dd2dbe830b5bd00c6d4b5dd321c26e8 Removing unused code. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@373 6f19259b-4bc3-4df7-8a09-765794883524 --- diff --git a/Tools/Source/TianoTools/Common/PeiLib/Debug.c b/Tools/Source/TianoTools/Common/PeiLib/Debug.c deleted file mode 100644 index 9094eb2802..0000000000 --- a/Tools/Source/TianoTools/Common/PeiLib/Debug.c +++ /dev/null @@ -1,131 +0,0 @@ -/*++ - -Copyright (c) 2004 - 2005, Intel Corporation -All rights reserved. This program and the accompanying materials -are licensed and made available under the terms and conditions of the BSD License -which accompanies this distribution. The full text of the license may be found at -http://opensource.org/licenses/bsd-license.php - -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -Module Name: - - Debug.c - -Abstract: - - Support for Debug primatives. - ---*/ - -#include "Tiano.h" -#include "Pei.h" -#include "EfiPrintLib.h" -#include "EfiStatusCode.h" -#include "EfiCommonLib.h" -#include EFI_GUID_DEFINITION (StatusCodeCallerId) -#include EFI_GUID_DEFINITION (StatusCodeDataTypeId) - -VOID -PeiDebugAssert ( - IN EFI_PEI_SERVICES **PeiServices, - IN CHAR8 *FileName, - IN INTN LineNumber, - IN CHAR8 *Description - ) -/*++ - -Routine Description: - - Worker function for ASSERT(). If Error Logging hub is loaded log ASSERT - information. If Error Logging hub is not loaded DEADLOOP (). - -Arguments: - - PeiServices - The PEI core services table. - - FileName - File name of failing routine. - - LineNumber - Line number of failing ASSERT(). - - Description - Description, usually the assertion, - -Returns: - - None - ---*/ -{ - UINT64 Buffer[EFI_STATUS_CODE_DATA_MAX_SIZE]; - - EfiDebugAssertWorker (FileName, LineNumber, Description, sizeof (Buffer), Buffer); - - // - // We choose NOT to use PEI_REPORT_STATUS_CODE here, because when debug is enable, - // we want get enough information if assert. - // - (**PeiServices).PeiReportStatusCode ( - PeiServices, - (EFI_ERROR_CODE | EFI_ERROR_UNRECOVERED), - (EFI_SOFTWARE_PEI_MODULE | EFI_SW_EC_ILLEGAL_SOFTWARE_STATE), - 0, - &gEfiCallerIdGuid, - (EFI_STATUS_CODE_DATA *) Buffer - ); - - EFI_DEADLOOP (); -} - - -VOID -PeiDebugPrint ( - IN EFI_PEI_SERVICES **PeiServices, - IN UINTN ErrorLevel, - IN CHAR8 *Format, - ... - ) -/*++ - -Routine Description: - - Worker function for DEBUG(). If Error Logging hub is loaded log ASSERT - information. If Error Logging hub is not loaded do nothing. - -Arguments: - - PeiServices - The PEI core services table. - - ErrorLevel - If error level is set do the debug print. - - Format - String to use for the print, followed by Print arguments. - - ... - Print arguments - -Returns: - - None - ---*/ -{ - VA_LIST Marker; - UINT64 Buffer[EFI_STATUS_CODE_DATA_MAX_SIZE]; - - VA_START (Marker, Format); - EfiDebugVPrintWorker (ErrorLevel, Format, Marker, sizeof (Buffer), Buffer); - - // - // We choose NOT to use PEI_REPORT_STATUS_CODE here, because when debug is enable, - // we want get enough information if assert. - // - (**PeiServices).PeiReportStatusCode ( - PeiServices, - EFI_DEBUG_CODE, - (EFI_SOFTWARE_PEI_MODULE | EFI_DC_UNSPECIFIED), - 0, - &gEfiCallerIdGuid, - (EFI_STATUS_CODE_DATA *) Buffer - ); - - return ; -} diff --git a/Tools/Source/TianoTools/Common/PeiLib/Decompress.c b/Tools/Source/TianoTools/Common/PeiLib/Decompress.c deleted file mode 100644 index 43446a37dd..0000000000 --- a/Tools/Source/TianoTools/Common/PeiLib/Decompress.c +++ /dev/null @@ -1,1104 +0,0 @@ -/*++ - -Copyright (c) 2004, Intel Corporation -All rights reserved. This program and the accompanying materials -are licensed and made available under the terms and conditions of the BSD License -which accompanies this distribution. The full text of the license may be found at -http://opensource.org/licenses/bsd-license.php - -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -Module Name: - - Decompress.c - -Abstract: - - Decompressor. Algorithm Ported from OPSD code (Decomp.asm) - ---*/ - -#include "TianoCommon.h" -#include EFI_PROTOCOL_DEFINITION (Decompress) -#include EFI_PROTOCOL_DEFINITION (TianoDecompress) - -EFI_STATUS -EFIAPI -EfiGetInfo ( - IN EFI_DECOMPRESS_PROTOCOL *This, - IN VOID *Source, - IN UINT32 SrcSize, - OUT UINT32 *DstSize, - OUT UINT32 *ScratchSize - ); - -EFI_STATUS -EFIAPI -EfiDecompress ( - IN EFI_DECOMPRESS_PROTOCOL *This, - IN VOID *Source, - IN UINT32 SrcSize, - IN OUT VOID *Destination, - IN UINT32 DstSize, - IN OUT VOID *Scratch, - IN UINT32 ScratchSize - ); - -EFI_STATUS -EFIAPI -TianoGetInfo ( - IN EFI_TIANO_DECOMPRESS_PROTOCOL *This, - IN VOID *Source, - IN UINT32 SrcSize, - OUT UINT32 *DstSize, - OUT UINT32 *ScratchSize - ); - -EFI_STATUS -EFIAPI -TianoDecompress ( - IN EFI_TIANO_DECOMPRESS_PROTOCOL *This, - IN VOID *Source, - IN UINT32 SrcSize, - IN OUT VOID *Destination, - IN UINT32 DstSize, - IN OUT VOID *Scratch, - IN UINT32 ScratchSize - ); - -// -// The protocol instance -// - -EFI_DECOMPRESS_PROTOCOL mEfiDecompress = { - EfiGetInfo, - EfiDecompress -}; - -EFI_TIANO_DECOMPRESS_PROTOCOL mTianoDecompress = { - TianoGetInfo, - TianoDecompress -}; - -EFI_STATUS -InstallEfiDecompress ( - IN OUT EFI_DECOMPRESS_PROTOCOL **This - ) -/*++ - -Routine Description: - - Install EFI decompress protocol. - -Arguments: - - This - Pointer to get decompress protocol as output - -Returns: - - EFI_SUCCESS - EFI decompress protocol successfully installed. - ---*/ -{ - *This = &mEfiDecompress; - return EFI_SUCCESS; -} - -EFI_STATUS -InstallTianoDecompress ( - EFI_TIANO_DECOMPRESS_PROTOCOL **This - ) -/*++ - -Routine Description: - - Install Tiano decompress protocol. - -Arguments: - - This - Pointer to get decompress protocol as output - -Returns: - - EFI_SUCCESS - Tiano decompress protocol successfully installed. - ---*/ -{ - *This = &mTianoDecompress; - return EFI_SUCCESS; -} -// -// Decompression algorithm begins here -// -#define BITBUFSIZ 32 -#define MAXMATCH 256 -#define THRESHOLD 3 -#define CODE_BIT 16 -#define UINT8_MAX 0xff -#define BAD_TABLE - 1 - -// -// C: Char&Len Set; P: Position Set; T: exTra Set -// -#define NC (0xff + MAXMATCH + 2 - THRESHOLD) -#define CBIT 9 -#define MAXPBIT 5 -#define TBIT 5 -#define MAXNP ((1U << MAXPBIT) - 1) -#define NT (CODE_BIT + 3) -#if NT > MAXNP -#define NPT NT -#else -#define NPT MAXNP -#endif - -typedef struct { - UINT8 *mSrcBase; // Starting address of compressed data - UINT8 *mDstBase; // Starting address of decompressed data - UINT32 mOutBuf; - UINT32 mInBuf; - - UINT16 mBitCount; - UINT32 mBitBuf; - UINT32 mSubBitBuf; - UINT16 mBlockSize; - UINT32 mCompSize; - UINT32 mOrigSize; - - UINT16 mBadTableFlag; - - UINT16 mLeft[2 * NC - 1]; - UINT16 mRight[2 * NC - 1]; - UINT8 mCLen[NC]; - UINT8 mPTLen[NPT]; - UINT16 mCTable[4096]; - UINT16 mPTTable[256]; - - // - // The length of the field 'Position Set Code Length Array Size' in Block Header. - // For EFI 1.1 de/compression algorithm, mPBit = 4 - // For Tiano de/compression algorithm, mPBit = 5 - // - UINT8 mPBit; -} SCRATCH_DATA; - -STATIC -VOID -FillBuf ( - IN SCRATCH_DATA *Sd, - IN UINT16 NumOfBits - ) -/*++ - -Routine Description: - - Shift mBitBuf NumOfBits left. Read in NumOfBits of bits from source. - -Arguments: - - Sd - The global scratch data - NumOfBits - The number of bits to shift and read. - -Returns: (VOID) - ---*/ -{ - Sd->mBitBuf = (UINT32) (Sd->mBitBuf << NumOfBits); - - while (NumOfBits > Sd->mBitCount) { - - Sd->mBitBuf |= (UINT32) (Sd->mSubBitBuf << (NumOfBits = (UINT16) (NumOfBits - Sd->mBitCount))); - - if (Sd->mCompSize > 0) { - // - // Get 1 byte into SubBitBuf - // - Sd->mCompSize--; - Sd->mSubBitBuf = 0; - Sd->mSubBitBuf = Sd->mSrcBase[Sd->mInBuf++]; - Sd->mBitCount = 8; - - } else { - // - // No more bits from the source, just pad zero bit. - // - Sd->mSubBitBuf = 0; - Sd->mBitCount = 8; - - } - } - - Sd->mBitCount = (UINT16) (Sd->mBitCount - NumOfBits); - Sd->mBitBuf |= Sd->mSubBitBuf >> Sd->mBitCount; -} - -STATIC -UINT32 -GetBits ( - IN SCRATCH_DATA *Sd, - IN UINT16 NumOfBits - ) -/*++ - -Routine Description: - - Get NumOfBits of bits out from mBitBuf. Fill mBitBuf with subsequent - NumOfBits of bits from source. Returns NumOfBits of bits that are - popped out. - -Arguments: - - Sd - The global scratch data. - NumOfBits - The number of bits to pop and read. - -Returns: - - The bits that are popped out. - ---*/ -{ - UINT32 OutBits; - - OutBits = (UINT32) (Sd->mBitBuf >> (BITBUFSIZ - NumOfBits)); - - FillBuf (Sd, NumOfBits); - - return OutBits; -} - -STATIC -UINT16 -MakeTable ( - IN SCRATCH_DATA *Sd, - IN UINT16 NumOfChar, - IN UINT8 *BitLen, - IN UINT16 TableBits, - OUT UINT16 *Table - ) -/*++ - -Routine Description: - - Creates Huffman Code mapping table according to code length array. - -Arguments: - - Sd - The global scratch data - NumOfChar - Number of symbols in the symbol set - BitLen - Code length array - TableBits - The width of the mapping table - Table - The table - -Returns: - - 0 - OK. - BAD_TABLE - The table is corrupted. - ---*/ -{ - UINT16 Count[17]; - UINT16 Weight[17]; - UINT16 Start[18]; - UINT16 *Pointer; - UINT16 Index3; - UINT16 Index; - UINT16 Len; - UINT16 Char; - UINT16 JuBits; - UINT16 Avail; - UINT16 NextCode; - UINT16 Mask; - - for (Index = 1; Index <= 16; Index++) { - Count[Index] = 0; - } - - for (Index = 0; Index < NumOfChar; Index++) { - Count[BitLen[Index]]++; - } - - Start[1] = 0; - - for (Index = 1; Index <= 16; Index++) { - Start[Index + 1] = (UINT16) (Start[Index] + (Count[Index] << (16 - Index))); - } - - if (Start[17] != 0) { - /*(1U << 16)*/ - return (UINT16) BAD_TABLE; - } - - JuBits = (UINT16) (16 - TableBits); - - for (Index = 1; Index <= TableBits; Index++) { - Start[Index] >>= JuBits; - Weight[Index] = (UINT16) (1U << (TableBits - Index)); - } - - while (Index <= 16) { - Weight[Index++] = (UINT16) (1U << (16 - Index)); - } - - Index = (UINT16) (Start[TableBits + 1] >> JuBits); - - if (Index != 0) { - Index3 = (UINT16) (1U << TableBits); - while (Index != Index3) { - Table[Index++] = 0; - } - } - - Avail = NumOfChar; - Mask = (UINT16) (1U << (15 - TableBits)); - - for (Char = 0; Char < NumOfChar; Char++) { - - Len = BitLen[Char]; - if (Len == 0) { - continue; - } - - NextCode = (UINT16) (Start[Len] + Weight[Len]); - - if (Len <= TableBits) { - - for (Index = Start[Len]; Index < NextCode; Index++) { - Table[Index] = Char; - } - - } else { - - Index3 = Start[Len]; - Pointer = &Table[Index3 >> JuBits]; - Index = (UINT16) (Len - TableBits); - - while (Index != 0) { - if (*Pointer == 0) { - Sd->mRight[Avail] = Sd->mLeft[Avail] = 0; - *Pointer = Avail++; - } - - if (Index3 & Mask) { - Pointer = &Sd->mRight[*Pointer]; - } else { - Pointer = &Sd->mLeft[*Pointer]; - } - - Index3 <<= 1; - Index--; - } - - *Pointer = Char; - - } - - Start[Len] = NextCode; - } - // - // Succeeds - // - return 0; -} - -STATIC -UINT32 -DecodeP ( - IN SCRATCH_DATA *Sd - ) -/*++ - -Routine Description: - - Decodes a position value. - -Arguments: - - Sd - the global scratch data - -Returns: - - The position value decoded. - ---*/ -{ - UINT16 Val; - UINT32 Mask; - UINT32 Pos; - - Val = Sd->mPTTable[Sd->mBitBuf >> (BITBUFSIZ - 8)]; - - if (Val >= MAXNP) { - Mask = 1U << (BITBUFSIZ - 1 - 8); - - do { - - if (Sd->mBitBuf & Mask) { - Val = Sd->mRight[Val]; - } else { - Val = Sd->mLeft[Val]; - } - - Mask >>= 1; - } while (Val >= MAXNP); - } - // - // Advance what we have read - // - FillBuf (Sd, Sd->mPTLen[Val]); - - Pos = Val; - if (Val > 1) { - Pos = (UINT32) ((1U << (Val - 1)) + GetBits (Sd, (UINT16) (Val - 1))); - } - - return Pos; -} - -STATIC -UINT16 -ReadPTLen ( - IN SCRATCH_DATA *Sd, - IN UINT16 nn, - IN UINT16 nbit, - IN UINT16 Special - ) -/*++ - -Routine Description: - - Reads code lengths for the Extra Set or the Position Set - -Arguments: - - Sd - The global scratch data - nn - Number of symbols - nbit - Number of bits needed to represent nn - Special - The special symbol that needs to be taken care of - -Returns: - - 0 - OK. - BAD_TABLE - Table is corrupted. - ---*/ -{ - UINT16 Number; - UINT16 CharC; - UINT16 Index; - UINT32 Mask; - - Number = (UINT16) GetBits (Sd, nbit); - - if (Number == 0) { - CharC = (UINT16) GetBits (Sd, nbit); - - for (Index = 0; Index < 256; Index++) { - Sd->mPTTable[Index] = CharC; - } - - for (Index = 0; Index < nn; Index++) { - Sd->mPTLen[Index] = 0; - } - - return 0; - } - - Index = 0; - - while (Index < Number) { - - CharC = (UINT16) (Sd->mBitBuf >> (BITBUFSIZ - 3)); - - if (CharC == 7) { - Mask = 1U << (BITBUFSIZ - 1 - 3); - while (Mask & Sd->mBitBuf) { - Mask >>= 1; - CharC += 1; - } - } - - FillBuf (Sd, (UINT16) ((CharC < 7) ? 3 : CharC - 3)); - - Sd->mPTLen[Index++] = (UINT8) CharC; - - if (Index == Special) { - CharC = (UINT16) GetBits (Sd, 2); - while ((INT16) (--CharC) >= 0) { - Sd->mPTLen[Index++] = 0; - } - } - } - - while (Index < nn) { - Sd->mPTLen[Index++] = 0; - } - - return MakeTable (Sd, nn, Sd->mPTLen, 8, Sd->mPTTable); -} - -STATIC -VOID -ReadCLen ( - SCRATCH_DATA *Sd - ) -/*++ - -Routine Description: - - Reads code lengths for Char&Len Set. - -Arguments: - - Sd - the global scratch data - -Returns: (VOID) - ---*/ -{ - UINT16 Number; - UINT16 CharC; - UINT16 Index; - UINT32 Mask; - - Number = (UINT16) GetBits (Sd, CBIT); - - if (Number == 0) { - CharC = (UINT16) GetBits (Sd, CBIT); - - for (Index = 0; Index < NC; Index++) { - Sd->mCLen[Index] = 0; - } - - for (Index = 0; Index < 4096; Index++) { - Sd->mCTable[Index] = CharC; - } - - return ; - } - - Index = 0; - while (Index < Number) { - - CharC = Sd->mPTTable[Sd->mBitBuf >> (BITBUFSIZ - 8)]; - if (CharC >= NT) { - Mask = 1U << (BITBUFSIZ - 1 - 8); - - do { - - if (Mask & Sd->mBitBuf) { - CharC = Sd->mRight[CharC]; - } else { - CharC = Sd->mLeft[CharC]; - } - - Mask >>= 1; - - } while (CharC >= NT); - } - // - // Advance what we have read - // - FillBuf (Sd, Sd->mPTLen[CharC]); - - if (CharC <= 2) { - - if (CharC == 0) { - CharC = 1; - } else if (CharC == 1) { - CharC = (UINT16) (GetBits (Sd, 4) + 3); - } else if (CharC == 2) { - CharC = (UINT16) (GetBits (Sd, CBIT) + 20); - } - - while ((INT16) (--CharC) >= 0) { - Sd->mCLen[Index++] = 0; - } - - } else { - - Sd->mCLen[Index++] = (UINT8) (CharC - 2); - - } - } - - while (Index < NC) { - Sd->mCLen[Index++] = 0; - } - - MakeTable (Sd, NC, Sd->mCLen, 12, Sd->mCTable); - - return ; -} - -STATIC -UINT16 -DecodeC ( - SCRATCH_DATA *Sd - ) -/*++ - -Routine Description: - - Decode a character/length value. - -Arguments: - - Sd - The global scratch data. - -Returns: - - The value decoded. - ---*/ -{ - UINT16 Index2; - UINT32 Mask; - - if (Sd->mBlockSize == 0) { - // - // Starting a new block - // - Sd->mBlockSize = (UINT16) GetBits (Sd, 16); - Sd->mBadTableFlag = ReadPTLen (Sd, NT, TBIT, 3); - if (Sd->mBadTableFlag != 0) { - return 0; - } - - ReadCLen (Sd); - - Sd->mBadTableFlag = ReadPTLen (Sd, MAXNP, Sd->mPBit, (UINT16) (-1)); - if (Sd->mBadTableFlag != 0) { - return 0; - } - } - - Sd->mBlockSize--; - Index2 = Sd->mCTable[Sd->mBitBuf >> (BITBUFSIZ - 12)]; - - if (Index2 >= NC) { - Mask = 1U << (BITBUFSIZ - 1 - 12); - - do { - if (Sd->mBitBuf & Mask) { - Index2 = Sd->mRight[Index2]; - } else { - Index2 = Sd->mLeft[Index2]; - } - - Mask >>= 1; - } while (Index2 >= NC); - } - // - // Advance what we have read - // - FillBuf (Sd, Sd->mCLen[Index2]); - - return Index2; -} - -STATIC -VOID -Decode ( - SCRATCH_DATA *Sd - ) -/*++ - -Routine Description: - - Decode the source data and put the resulting data into the destination buffer. - -Arguments: - - Sd - The global scratch data - -Returns: (VOID) - - --*/ -{ - UINT16 BytesRemain; - UINT32 DataIdx; - UINT16 CharC; - - BytesRemain = (UINT16) (-1); - - DataIdx = 0; - - for (;;) { - CharC = DecodeC (Sd); - if (Sd->mBadTableFlag != 0) { - return ; - } - - if (CharC < 256) { - // - // Process an Original character - // - if (Sd->mOutBuf >= Sd->mOrigSize) { - return ; - } else { - Sd->mDstBase[Sd->mOutBuf++] = (UINT8) CharC; - } - - } else { - // - // Process a Pointer - // - CharC = (UINT16) (CharC - (UINT8_MAX + 1 - THRESHOLD)); - - BytesRemain = CharC; - - DataIdx = Sd->mOutBuf - DecodeP (Sd) - 1; - - BytesRemain--; - while ((INT16) (BytesRemain) >= 0) { - Sd->mDstBase[Sd->mOutBuf++] = Sd->mDstBase[DataIdx++]; - if (Sd->mOutBuf >= Sd->mOrigSize) { - return ; - } - - BytesRemain--; - } - } - } - - return ; -} - -EFI_STATUS -GetInfo ( - IN VOID *Source, - IN UINT32 SrcSize, - OUT UINT32 *DstSize, - OUT UINT32 *ScratchSize - ) -/*++ - -Routine Description: - - The internal implementation of *_DECOMPRESS_PROTOCOL.GetInfo(). - -Arguments: - - Source - The source buffer containing the compressed data. - SrcSize - The size of source buffer - DstSize - The size of destination buffer. - ScratchSize - The size of scratch buffer. - -Returns: - - EFI_SUCCESS - The size of destination buffer and the size of scratch buffer are successull retrieved. - EFI_INVALID_PARAMETER - The source data is corrupted - ---*/ -{ - UINT8 *Src; - - *ScratchSize = sizeof (SCRATCH_DATA); - - Src = Source; - if (SrcSize < 8) { - return EFI_INVALID_PARAMETER; - } - - *DstSize = Src[4] + (Src[5] << 8) + (Src[6] << 16) + (Src[7] << 24); - return EFI_SUCCESS; -} - -EFI_STATUS -Decompress ( - IN VOID *Source, - IN UINT32 SrcSize, - IN OUT VOID *Destination, - IN UINT32 DstSize, - IN OUT VOID *Scratch, - IN UINT32 ScratchSize, - IN UINT8 Version - ) -/*++ - -Routine Description: - - The internal implementation of *_DECOMPRESS_PROTOCOL.Decompress(). - -Arguments: - - Source - The source buffer containing the compressed data. - SrcSize - The size of source buffer - Destination - The destination buffer to store the decompressed data - DstSize - The size of destination buffer. - Scratch - The buffer used internally by the decompress routine. This buffer is needed to store intermediate data. - ScratchSize - The size of scratch buffer. - Version - The version of de/compression algorithm. - Version 1 for EFI 1.1 de/compression algorithm. - Version 2 for Tiano de/compression algorithm. - -Returns: - - EFI_SUCCESS - Decompression is successfull - EFI_INVALID_PARAMETER - The source data is corrupted - ---*/ -{ - UINT32 Index; - UINT32 CompSize; - UINT32 OrigSize; - EFI_STATUS Status; - SCRATCH_DATA *Sd; - UINT8 *Src; - UINT8 *Dst; - - Status = EFI_SUCCESS; - Src = Source; - Dst = Destination; - - if (ScratchSize < sizeof (SCRATCH_DATA)) { - return EFI_INVALID_PARAMETER; - } - - Sd = (SCRATCH_DATA *) Scratch; - - if (SrcSize < 8) { - return EFI_INVALID_PARAMETER; - } - - CompSize = Src[0] + (Src[1] << 8) + (Src[2] << 16) + (Src[3] << 24); - OrigSize = Src[4] + (Src[5] << 8) + (Src[6] << 16) + (Src[7] << 24); - - // - // If compressed file size is 0, return - // - if (OrigSize == 0) { - return Status; - } - - if (SrcSize < CompSize + 8) { - return EFI_INVALID_PARAMETER; - } - - if (DstSize != OrigSize) { - return EFI_INVALID_PARAMETER; - } - - Src = Src + 8; - - for (Index = 0; Index < sizeof (SCRATCH_DATA); Index++) { - ((UINT8 *) Sd)[Index] = 0; - } - // - // The length of the field 'Position Set Code Length Array Size' in Block Header. - // For EFI 1.1 de/compression algorithm(Version 1), mPBit = 4 - // For Tiano de/compression algorithm(Version 2), mPBit = 5 - // - switch (Version) { - case 1: - Sd->mPBit = 4; - break; - - case 2: - Sd->mPBit = 5; - break; - - default: - // - // Currently, only have 2 versions - // - return EFI_INVALID_PARAMETER; - } - - Sd->mSrcBase = Src; - Sd->mDstBase = Dst; - Sd->mCompSize = CompSize; - Sd->mOrigSize = OrigSize; - - // - // Fill the first BITBUFSIZ bits - // - FillBuf (Sd, BITBUFSIZ); - - // - // Decompress it - // - Decode (Sd); - - if (Sd->mBadTableFlag != 0) { - // - // Something wrong with the source - // - Status = EFI_INVALID_PARAMETER; - } - - return Status; -} - -EFI_STATUS -EFIAPI -EfiGetInfo ( - IN EFI_DECOMPRESS_PROTOCOL *This, - IN VOID *Source, - IN UINT32 SrcSize, - OUT UINT32 *DstSize, - OUT UINT32 *ScratchSize - ) -/*++ - -Routine Description: - - The implementation of EFI_DECOMPRESS_PROTOCOL.GetInfo(). - -Arguments: - - This - The protocol instance pointer - Source - The source buffer containing the compressed data. - SrcSize - The size of source buffer - DstSize - The size of destination buffer. - ScratchSize - The size of scratch buffer. - -Returns: - - EFI_SUCCESS - The size of destination buffer and the size of scratch buffer are successull retrieved. - EFI_INVALID_PARAMETER - The source data is corrupted - ---*/ -{ - return GetInfo ( - Source, - SrcSize, - DstSize, - ScratchSize - ); -} - -EFI_STATUS -EFIAPI -EfiDecompress ( - IN EFI_DECOMPRESS_PROTOCOL *This, - IN VOID *Source, - IN UINT32 SrcSize, - IN OUT VOID *Destination, - IN UINT32 DstSize, - IN OUT VOID *Scratch, - IN UINT32 ScratchSize - ) -/*++ - -Routine Description: - - The implementation of EFI_DECOMPRESS_PROTOCOL.Decompress(). - -Arguments: - - This - The protocol instance pointer - Source - The source buffer containing the compressed data. - SrcSize - The size of source buffer - Destination - The destination buffer to store the decompressed data - DstSize - The size of destination buffer. - Scratch - The buffer used internally by the decompress routine. This buffer is needed to store intermediate data. - ScratchSize - The size of scratch buffer. - -Returns: - - EFI_SUCCESS - Decompression is successfull - EFI_INVALID_PARAMETER - The source data is corrupted - ---*/ -{ - // - // For EFI 1.1 de/compression algorithm, the version is 1. - // - return Decompress ( - Source, - SrcSize, - Destination, - DstSize, - Scratch, - ScratchSize, - 1 - ); -} - -EFI_STATUS -EFIAPI -TianoGetInfo ( - IN EFI_TIANO_DECOMPRESS_PROTOCOL *This, - IN VOID *Source, - IN UINT32 SrcSize, - OUT UINT32 *DstSize, - OUT UINT32 *ScratchSize - ) -/*++ - -Routine Description: - - The implementation of EFI_TIANO_DECOMPRESS_PROTOCOL.GetInfo(). - -Arguments: - - This - The protocol instance pointer - Source - The source buffer containing the compressed data. - SrcSize - The size of source buffer - DstSize - The size of destination buffer. - ScratchSize - The size of scratch buffer. - -Returns: - - EFI_SUCCESS - The size of destination buffer and the size of scratch buffer are successull retrieved. - EFI_INVALID_PARAMETER - The source data is corrupted - ---*/ -{ - return GetInfo ( - Source, - SrcSize, - DstSize, - ScratchSize - ); -} - -EFI_STATUS -EFIAPI -TianoDecompress ( - IN EFI_TIANO_DECOMPRESS_PROTOCOL *This, - IN VOID *Source, - IN UINT32 SrcSize, - IN OUT VOID *Destination, - IN UINT32 DstSize, - IN OUT VOID *Scratch, - IN UINT32 ScratchSize - ) -/*++ - -Routine Description: - - The implementation of EFI_TIANO_DECOMPRESS_PROTOCOL.Decompress(). - -Arguments: - - This - The protocol instance pointer - Source - The source buffer containing the compressed data. - SrcSize - The size of source buffer - Destination - The destination buffer to store the decompressed data - DstSize - The size of destination buffer. - Scratch - The buffer used internally by the decompress routine. This buffer is needed to store intermediate data. - ScratchSize - The size of scratch buffer. - -Returns: - - EFI_SUCCESS - Decompression is successfull - EFI_INVALID_PARAMETER - The source data is corrupted - ---*/ -{ - // - // For Tiano de/compression algorithm, the version is 2. - // - return Decompress ( - Source, - SrcSize, - Destination, - DstSize, - Scratch, - ScratchSize, - 2 - ); -} diff --git a/Tools/Source/TianoTools/Common/PeiLib/Hob/Hob.c b/Tools/Source/TianoTools/Common/PeiLib/Hob/Hob.c deleted file mode 100644 index 0f1ff5ffb8..0000000000 --- a/Tools/Source/TianoTools/Common/PeiLib/Hob/Hob.c +++ /dev/null @@ -1,495 +0,0 @@ - -/*++ - -Copyright (c) 2004, Intel Corporation -All rights reserved. This program and the accompanying materials -are licensed and made available under the terms and conditions of the BSD License -which accompanies this distribution. The full text of the license may be found at -http://opensource.org/licenses/bsd-license.php - -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -Module Name: - - hob.c - -Abstract: - - PEI Library Functions - ---*/ - -#include "Tiano.h" -#include "Pei.h" -#include "peilib.h" -#include EFI_GUID_DEFINITION (MemoryAllocationHob) - - -EFI_STATUS -PeiBuildHobModule ( - IN EFI_PEI_SERVICES **PeiServices, - IN EFI_GUID *ModuleName, - IN EFI_PHYSICAL_ADDRESS MemoryAllocationModule, - IN UINT64 ModuleLength, - IN EFI_PHYSICAL_ADDRESS EntryPoint - ) -/*++ - -Routine Description: - - Builds a HOB for a loaded PE32 module - -Arguments: - - PeiServices - The PEI core services table. - ModuleName - The GUID File Name of the module - MemoryAllocationModule - The 64 bit physical address of the module - ModuleLength - The length of the module in bytes - EntryPoint - The 64 bit physical address of the entry point - to the module - -Returns: - - EFI_SUCCESS - Hob is successfully built. - Others - Errors occur while creating new Hob - ---*/ -{ - EFI_STATUS Status; - EFI_HOB_MEMORY_ALLOCATION_MODULE *Hob; - - Status = (*PeiServices)->CreateHob ( - PeiServices, - EFI_HOB_TYPE_GUID_EXTENSION, - sizeof (EFI_HOB_MEMORY_ALLOCATION_MODULE), - &Hob - ); - if (EFI_ERROR (Status)) { - return Status; - } - - Hob->MemoryAllocationHeader.Name = gEfiHobMemeryAllocModuleGuid; - Hob->MemoryAllocationHeader.MemoryBaseAddress = MemoryAllocationModule; - Hob->MemoryAllocationHeader.MemoryLength = ModuleLength; - Hob->MemoryAllocationHeader.MemoryType = EfiBootServicesCode; - - Hob->ModuleName = *ModuleName; - Hob->EntryPoint = EntryPoint; - - return EFI_SUCCESS; -} - - -EFI_STATUS -PeiBuildHobResourceDescriptor ( - IN EFI_PEI_SERVICES **PeiServices, - IN EFI_RESOURCE_TYPE ResourceType, - IN EFI_RESOURCE_ATTRIBUTE_TYPE ResourceAttribute, - IN EFI_PHYSICAL_ADDRESS PhysicalStart, - IN UINT64 NumberOfBytes - ) -/*++ - -Routine Description: - - Builds a HOB that describes a chunck of system memory - -Arguments: - - PeiServices - The PEI core services table. - - ResourceType - The type of resource described by this HOB - - ResourceAttribute - The resource attributes of the memory described by this HOB - - PhysicalStart - The 64 bit physical address of memory described by this HOB - - NumberOfBytes - The length of the memoty described by this HOB in bytes - -Returns: - - EFI_SUCCESS - Hob is successfully built. - Others - Errors occur while creating new Hob - ---*/ -{ - EFI_STATUS Status; - EFI_HOB_RESOURCE_DESCRIPTOR *Hob; - - Status = (*PeiServices)->CreateHob ( - PeiServices, - EFI_HOB_TYPE_RESOURCE_DESCRIPTOR, - sizeof (EFI_HOB_RESOURCE_DESCRIPTOR), - &Hob - ); - if (EFI_ERROR (Status)) { - return Status; - } - - Hob->ResourceType = ResourceType; - Hob->ResourceAttribute = ResourceAttribute; - Hob->PhysicalStart = PhysicalStart; - Hob->ResourceLength = NumberOfBytes; - - return EFI_SUCCESS; -} - - -EFI_STATUS -PeiBuildHobGuid ( - IN EFI_PEI_SERVICES **PeiServices, - IN EFI_GUID *Guid, - IN UINTN DataLength, - IN OUT VOID **Hob - ) -/*++ - -Routine Description: - - Builds a custom HOB that is tagged with a GUID for identification - -Arguments: - - PeiServices - The PEI core services table. - - Guid - The GUID of the custome HOB type - - DataLength - The size of the data payload for the GUIDed HOB - - Hob - Pointer to the Hob - -Returns: - - EFI_SUCCESS - Hob is successfully built. - Others - Errors occur while creating new Hob - ---*/ -{ - EFI_STATUS Status; - - Status = (*PeiServices)->CreateHob ( - PeiServices, - EFI_HOB_TYPE_GUID_EXTENSION, - (UINT16) (sizeof (EFI_HOB_GUID_TYPE) + DataLength), - Hob - ); - if (EFI_ERROR (Status)) { - return Status; - } - - ((EFI_HOB_GUID_TYPE *)(*Hob))->Name = *Guid; - - return EFI_SUCCESS; -} - - -EFI_STATUS -PeiBuildHobGuidData ( - IN EFI_PEI_SERVICES **PeiServices, - IN EFI_GUID *Guid, - IN VOID *Data, - IN UINTN DataLength - ) -/*++ - -Routine Description: - - Builds a custom HOB that is tagged with a GUID for identification - -Arguments: - - PeiServices - The PEI core services table. - - Guid - The GUID of the custome HOB type - - Data - The data to be copied into the GUIDed HOB data field. - - DataLength - The data field length. - -Returns: - - EFI_SUCCESS - Hob is successfully built. - Others - Errors occur while creating new Hob - ---*/ -{ - EFI_STATUS Status; - - EFI_HOB_GUID_TYPE *Hob; - - Status = PeiBuildHobGuid ( - PeiServices, - Guid, - DataLength, - &Hob - ); - - if (EFI_ERROR (Status)) { - return Status; - } - - Hob++; - (*PeiServices)->CopyMem (Hob, Data, DataLength); - - return EFI_SUCCESS; -} - - -EFI_STATUS -PeiBuildHobFv ( - IN EFI_PEI_SERVICES **PeiServices, - IN EFI_PHYSICAL_ADDRESS BaseAddress, - IN UINT64 Length - ) -/*++ - -Routine Description: - - Builds a Firmware Volume HOB - -Arguments: - - PeiServices - The PEI core services table. - - BaseAddress - The base address of the Firmware Volume - - Length - The size of the Firmware Volume in bytes - -Returns: - - EFI_SUCCESS - Hob is successfully built. - Others - Errors occur while creating new Hob - ---*/ -{ - EFI_STATUS Status; - EFI_HOB_FIRMWARE_VOLUME *Hob; - - Status = (*PeiServices)->CreateHob ( - PeiServices, - EFI_HOB_TYPE_FV, - sizeof (EFI_HOB_FIRMWARE_VOLUME), - &Hob - ); - if (EFI_ERROR (Status)) { - return Status; - } - - Hob->BaseAddress = BaseAddress; - Hob->Length = Length; - - return EFI_SUCCESS; -} - - -EFI_STATUS -PeiBuildHobCpu ( - IN EFI_PEI_SERVICES **PeiServices, - IN UINT8 SizeOfMemorySpace, - IN UINT8 SizeOfIoSpace - ) -/*++ - -Routine Description: - - Builds a HOB for the CPU - -Arguments: - - PeiServices - The PEI core services table. - - SizeOfMemorySpace - Identifies the maximum - physical memory addressibility of the processor. - - SizeOfIoSpace - Identifies the maximum physical I/O addressibility - of the processor. - -Returns: - - EFI_SUCCESS - Hob is successfully built. - Others - Errors occur while creating new Hob - ---*/ -{ - EFI_STATUS Status; - EFI_HOB_CPU *Hob; - - Status = (*PeiServices)->CreateHob ( - PeiServices, - EFI_HOB_TYPE_CPU, - sizeof (EFI_HOB_CPU), - &Hob - ); - if (EFI_ERROR (Status)) { - return Status; - } - - Hob->SizeOfMemorySpace = SizeOfMemorySpace; - Hob->SizeOfIoSpace = SizeOfIoSpace; - - return EFI_SUCCESS; -} - - - -EFI_STATUS -PeiBuildHobStack ( - IN EFI_PEI_SERVICES **PeiServices, - IN EFI_PHYSICAL_ADDRESS BaseAddress, - IN UINT64 Length - ) -/*++ - -Routine Description: - - Builds a HOB for the Stack - -Arguments: - - PeiServices - The PEI core services table. - - BaseAddress - The 64 bit physical address of the Stack - - Length - The length of the stack in bytes - -Returns: - - EFI_SUCCESS - Hob is successfully built. - Others - Errors occur while creating new Hob - ---*/ -{ - EFI_STATUS Status; - EFI_HOB_MEMORY_ALLOCATION_STACK *Hob; - - Status = (*PeiServices)->CreateHob ( - PeiServices, - EFI_HOB_TYPE_MEMORY_ALLOCATION, - sizeof (EFI_HOB_MEMORY_ALLOCATION_STACK), - &Hob - ); - if (EFI_ERROR (Status)) { - return Status; - } - - Hob->AllocDescriptor.Name = gEfiHobMemeryAllocStackGuid; - Hob->AllocDescriptor.MemoryBaseAddress = BaseAddress; - Hob->AllocDescriptor.MemoryLength = Length; - Hob->AllocDescriptor.MemoryType = EfiConventionalMemory; - - return EFI_SUCCESS; -} - - - -EFI_STATUS -PeiBuildHobBspStore ( - IN EFI_PEI_SERVICES **PeiServices, - IN EFI_PHYSICAL_ADDRESS BaseAddress, - IN UINT64 Length, - IN EFI_MEMORY_TYPE MemoryType - ) -/*++ - -Routine Description: - - Builds a HOB for the bsp store - -Arguments: - - PeiServices - The PEI core services table. - - BaseAddress - The 64 bit physical address of the bsp - - Length - The length of the bsp store in bytes - - MemoryType - Memory type - -Returns: - - EFI_SUCCESS - Hob is successfully built. - Others - Errors occur while creating new Hob - ---*/ -{ - EFI_STATUS Status; - EFI_HOB_MEMORY_ALLOCATION_BSP_STORE *Hob; - - Status = (*PeiServices)->CreateHob ( - PeiServices, - EFI_HOB_TYPE_MEMORY_ALLOCATION, - sizeof (EFI_HOB_MEMORY_ALLOCATION_BSP_STORE), - &Hob - ); - if (EFI_ERROR (Status)) { - return Status; - } - - Hob->AllocDescriptor.Name = gEfiHobMemeryAllocBspStoreGuid; - Hob->AllocDescriptor.MemoryBaseAddress = BaseAddress; - Hob->AllocDescriptor.MemoryLength = Length; - Hob->AllocDescriptor.MemoryType = MemoryType; - - return EFI_SUCCESS; -} - - -EFI_STATUS -PeiBuildHobMemoryAllocation ( - IN EFI_PEI_SERVICES **PeiServices, - IN EFI_PHYSICAL_ADDRESS BaseAddress, - IN UINT64 Length, - IN EFI_GUID *Name, - IN EFI_MEMORY_TYPE MemoryType - ) -/*++ - -Routine Description: - - Builds a HOB for the memory allocation. - -Arguments: - - PeiServices - The PEI core services table. - - BaseAddress - The 64 bit physical address of the memory - - Length - The length of the memory allocation in bytes - - Name - Name for Hob - - MemoryType - Memory type - -Returns: - - EFI_SUCCESS - Hob is successfully built. - Others - Errors occur while creating new Hob - ---*/ -{ - EFI_STATUS Status; - EFI_HOB_MEMORY_ALLOCATION *Hob; - - Status = (*PeiServices)->CreateHob ( - PeiServices, - EFI_HOB_TYPE_MEMORY_ALLOCATION, - sizeof (EFI_HOB_MEMORY_ALLOCATION), - &Hob - ); - if (EFI_ERROR (Status)) { - return Status; - } - - if (Name != NULL) { - Hob->AllocDescriptor.Name = *Name; - } else { - (*PeiServices)->SetMem(&(Hob->AllocDescriptor.Name), sizeof (EFI_GUID), 0); - } - - Hob->AllocDescriptor.MemoryBaseAddress = BaseAddress; - Hob->AllocDescriptor.MemoryLength = Length; - Hob->AllocDescriptor.MemoryType = MemoryType; - - return EFI_SUCCESS; -} diff --git a/Tools/Source/TianoTools/Common/PeiLib/Ipf/PeCoffLoaderEx.c b/Tools/Source/TianoTools/Common/PeiLib/Ipf/PeCoffLoaderEx.c deleted file mode 100644 index 09792818cc..0000000000 --- a/Tools/Source/TianoTools/Common/PeiLib/Ipf/PeCoffLoaderEx.c +++ /dev/null @@ -1,244 +0,0 @@ -/*++ - -Copyright (c) 2004, Intel Corporation -All rights reserved. This program and the accompanying materials -are licensed and made available under the terms and conditions of the BSD License -which accompanies this distribution. The full text of the license may be found at -http://opensource.org/licenses/bsd-license.php - -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -Module Name: - - PeCoffLoaderEx.c - -Abstract: - - Fixes Intel Itanium(TM) specific relocation types - - -Revision History - ---*/ - -#include "TianoCommon.h" -#include "EfiImage.h" - -#define EXT_IMM64(Value, Address, Size, InstPos, ValPos) \ - Value |= (((UINT64)((*(Address) >> InstPos) & (((UINT64)1 << Size) - 1))) << ValPos) - -#define INS_IMM64(Value, Address, Size, InstPos, ValPos) \ - *(UINT32*)Address = (*(UINT32*)Address & ~(((1 << Size) - 1) << InstPos)) | \ - ((UINT32)((((UINT64)Value >> ValPos) & (((UINT64)1 << Size) - 1))) << InstPos) - -#define IMM64_IMM7B_INST_WORD_X 3 -#define IMM64_IMM7B_SIZE_X 7 -#define IMM64_IMM7B_INST_WORD_POS_X 4 -#define IMM64_IMM7B_VAL_POS_X 0 - -#define IMM64_IMM9D_INST_WORD_X 3 -#define IMM64_IMM9D_SIZE_X 9 -#define IMM64_IMM9D_INST_WORD_POS_X 18 -#define IMM64_IMM9D_VAL_POS_X 7 - -#define IMM64_IMM5C_INST_WORD_X 3 -#define IMM64_IMM5C_SIZE_X 5 -#define IMM64_IMM5C_INST_WORD_POS_X 13 -#define IMM64_IMM5C_VAL_POS_X 16 - -#define IMM64_IC_INST_WORD_X 3 -#define IMM64_IC_SIZE_X 1 -#define IMM64_IC_INST_WORD_POS_X 12 -#define IMM64_IC_VAL_POS_X 21 - -#define IMM64_IMM41a_INST_WORD_X 1 -#define IMM64_IMM41a_SIZE_X 10 -#define IMM64_IMM41a_INST_WORD_POS_X 14 -#define IMM64_IMM41a_VAL_POS_X 22 - -#define IMM64_IMM41b_INST_WORD_X 1 -#define IMM64_IMM41b_SIZE_X 8 -#define IMM64_IMM41b_INST_WORD_POS_X 24 -#define IMM64_IMM41b_VAL_POS_X 32 - -#define IMM64_IMM41c_INST_WORD_X 2 -#define IMM64_IMM41c_SIZE_X 23 -#define IMM64_IMM41c_INST_WORD_POS_X 0 -#define IMM64_IMM41c_VAL_POS_X 40 - -#define IMM64_SIGN_INST_WORD_X 3 -#define IMM64_SIGN_SIZE_X 1 -#define IMM64_SIGN_INST_WORD_POS_X 27 -#define IMM64_SIGN_VAL_POS_X 63 - -EFI_STATUS -PeCoffLoaderRelocateImageEx ( - IN UINT16 *Reloc, - IN OUT CHAR8 *Fixup, - IN OUT CHAR8 **FixupData, - IN UINT64 Adjust - ) -/*++ - -Routine Description: - - Performs an Itanium-based specific relocation fixup - -Arguments: - - Reloc - Pointer to the relocation record - - Fixup - Pointer to the address to fix up - - FixupData - Pointer to a buffer to log the fixups - - Adjust - The offset to adjust the fixup - -Returns: - - Status code - ---*/ -{ - UINT64 *F64; - UINT64 FixupVal; - - switch ((*Reloc) >> 12) { - - case EFI_IMAGE_REL_BASED_DIR64: - F64 = (UINT64 *) Fixup; - *F64 = *F64 + (UINT64) Adjust; - if (*FixupData != NULL) { - *FixupData = ALIGN_POINTER(*FixupData, sizeof(UINT64)); - *(UINT64 *)(*FixupData) = *F64; - *FixupData = *FixupData + sizeof(UINT64); - } - break; - - case EFI_IMAGE_REL_BASED_IA64_IMM64: - - // - // Align it to bundle address before fixing up the - // 64-bit immediate value of the movl instruction. - // - - Fixup = (CHAR8 *)((UINTN) Fixup & (UINTN) ~(15)); - FixupVal = (UINT64)0; - - // - // Extract the lower 32 bits of IMM64 from bundle - // - EXT_IMM64(FixupVal, - (UINT32 *)Fixup + IMM64_IMM7B_INST_WORD_X, - IMM64_IMM7B_SIZE_X, - IMM64_IMM7B_INST_WORD_POS_X, - IMM64_IMM7B_VAL_POS_X - ); - - EXT_IMM64(FixupVal, - (UINT32 *)Fixup + IMM64_IMM9D_INST_WORD_X, - IMM64_IMM9D_SIZE_X, - IMM64_IMM9D_INST_WORD_POS_X, - IMM64_IMM9D_VAL_POS_X - ); - - EXT_IMM64(FixupVal, - (UINT32 *)Fixup + IMM64_IMM5C_INST_WORD_X, - IMM64_IMM5C_SIZE_X, - IMM64_IMM5C_INST_WORD_POS_X, - IMM64_IMM5C_VAL_POS_X - ); - - EXT_IMM64(FixupVal, - (UINT32 *)Fixup + IMM64_IC_INST_WORD_X, - IMM64_IC_SIZE_X, - IMM64_IC_INST_WORD_POS_X, - IMM64_IC_VAL_POS_X - ); - - EXT_IMM64(FixupVal, - (UINT32 *)Fixup + IMM64_IMM41a_INST_WORD_X, - IMM64_IMM41a_SIZE_X, - IMM64_IMM41a_INST_WORD_POS_X, - IMM64_IMM41a_VAL_POS_X - ); - - // - // Update 64-bit address - // - FixupVal += Adjust; - - // - // Insert IMM64 into bundle - // - INS_IMM64(FixupVal, - ((UINT32 *)Fixup + IMM64_IMM7B_INST_WORD_X), - IMM64_IMM7B_SIZE_X, - IMM64_IMM7B_INST_WORD_POS_X, - IMM64_IMM7B_VAL_POS_X - ); - - INS_IMM64(FixupVal, - ((UINT32 *)Fixup + IMM64_IMM9D_INST_WORD_X), - IMM64_IMM9D_SIZE_X, - IMM64_IMM9D_INST_WORD_POS_X, - IMM64_IMM9D_VAL_POS_X - ); - - INS_IMM64(FixupVal, - ((UINT32 *)Fixup + IMM64_IMM5C_INST_WORD_X), - IMM64_IMM5C_SIZE_X, - IMM64_IMM5C_INST_WORD_POS_X, - IMM64_IMM5C_VAL_POS_X - ); - - INS_IMM64(FixupVal, - ((UINT32 *)Fixup + IMM64_IC_INST_WORD_X), - IMM64_IC_SIZE_X, - IMM64_IC_INST_WORD_POS_X, - IMM64_IC_VAL_POS_X - ); - - INS_IMM64(FixupVal, - ((UINT32 *)Fixup + IMM64_IMM41a_INST_WORD_X), - IMM64_IMM41a_SIZE_X, - IMM64_IMM41a_INST_WORD_POS_X, - IMM64_IMM41a_VAL_POS_X - ); - - INS_IMM64(FixupVal, - ((UINT32 *)Fixup + IMM64_IMM41b_INST_WORD_X), - IMM64_IMM41b_SIZE_X, - IMM64_IMM41b_INST_WORD_POS_X, - IMM64_IMM41b_VAL_POS_X - ); - - INS_IMM64(FixupVal, - ((UINT32 *)Fixup + IMM64_IMM41c_INST_WORD_X), - IMM64_IMM41c_SIZE_X, - IMM64_IMM41c_INST_WORD_POS_X, - IMM64_IMM41c_VAL_POS_X - ); - - INS_IMM64(FixupVal, - ((UINT32 *)Fixup + IMM64_SIGN_INST_WORD_X), - IMM64_SIGN_SIZE_X, - IMM64_SIGN_INST_WORD_POS_X, - IMM64_SIGN_VAL_POS_X - ); - - F64 = (UINT64 *) Fixup; - if (*FixupData != NULL) { - *FixupData = ALIGN_POINTER(*FixupData, sizeof(UINT64)); - *(UINT64 *)(*FixupData) = *F64; - *FixupData = *FixupData + sizeof(UINT64); - } - break; - - default: - return EFI_UNSUPPORTED; - } - - return EFI_SUCCESS; -} diff --git a/Tools/Source/TianoTools/Common/PeiLib/Ipf/PeCoffLoaderEx.h b/Tools/Source/TianoTools/Common/PeiLib/Ipf/PeCoffLoaderEx.h deleted file mode 100644 index b79ead654a..0000000000 --- a/Tools/Source/TianoTools/Common/PeiLib/Ipf/PeCoffLoaderEx.h +++ /dev/null @@ -1,67 +0,0 @@ -/*++ - -Copyright (c) 2004, Intel Corporation -All rights reserved. This program and the accompanying materials -are licensed and made available under the terms and conditions of the BSD License -which accompanies this distribution. The full text of the license may be found at -http://opensource.org/licenses/bsd-license.php - -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -Module Name: - - PeCoffLoaderEx.h - -Abstract: - - Fixes Intel Itanium(TM) specific relocation types - - -Revision History - ---*/ - -#ifndef _PE_COFF_LOADER_EX_H_ -#define _PE_COFF_LOADER_EX_H_ - -// -// Define macro to determine if the machine type is supported. -// Returns 0 if the machine is not supported, Not 0 otherwise. -// -#define EFI_IMAGE_MACHINE_TYPE_SUPPORTED(Machine) \ - ((Machine) == EFI_IMAGE_MACHINE_IA64 || \ - (Machine) == EFI_IMAGE_MACHINE_EBC) - - -EFI_STATUS -PeCoffLoaderRelocateImageEx ( - IN UINT16 *Reloc, - IN OUT CHAR8 *Fixup, - IN OUT CHAR8 **FixupData, - IN UINT64 Adjust - ) -/*++ - -Routine Description: - - Performs an Itanium-based specific relocation fixup - -Arguments: - - Reloc - Pointer to the relocation record - - Fixup - Pointer to the address to fix up - - FixupData - Pointer to a buffer to log the fixups - - Adjust - The offset to adjust the fixup - -Returns: - - Status code - ---*/ -; - -#endif diff --git a/Tools/Source/TianoTools/Common/PeiLib/Ipf/PerformancePrimitives.s b/Tools/Source/TianoTools/Common/PeiLib/Ipf/PerformancePrimitives.s deleted file mode 100644 index 5814bb71b7..0000000000 --- a/Tools/Source/TianoTools/Common/PeiLib/Ipf/PerformancePrimitives.s +++ /dev/null @@ -1,61 +0,0 @@ -//++ -// Copyright (c) 2004, Intel Corporation -// All rights reserved. This program and the accompanying materials -// are licensed and made available under the terms and conditions of the BSD License -// which accompanies this distribution. The full text of the license may be found at -// http://opensource.org/licenses/bsd-license.php -// -// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -// -// Module Name: -// -// PerformancePrimitives.s -// -// Abstract: -// -// -// Revision History: -// -//-- - -.file "PerformancePrimitives.s" - -#include "IpfMacro.i" - -//----------------------------------------------------------------------------- -//++ -// GetTimerValue -// -// Implementation of CPU-based time service -// -// On Entry : -// EFI_STATUS -// GetTimerValue ( -// OUT UINT64 *TimerValue -// ) -// -// Return Value: -// r8 = Status -// r9 = 0 -// r10 = 0 -// r11 = 0 -// -// As per static calling conventions. -// -//-- -//--------------------------------------------------------------------------- -PROCEDURE_ENTRY (GetTimerValue) - - NESTED_SETUP (1,8,0,0) - mov r8 = ar.itc;; - st8 [r32]= r8 - mov r8 = r0 - mov r9 = r0 - mov r10 = r0 - mov r11 = r0 - NESTED_RETURN - -PROCEDURE_EXIT (GetTimerValue) -//--------------------------------------------------------------------------- - diff --git a/Tools/Source/TianoTools/Common/PeiLib/Ipf/SwitchStack.s b/Tools/Source/TianoTools/Common/PeiLib/Ipf/SwitchStack.s deleted file mode 100644 index 08ff773b27..0000000000 --- a/Tools/Source/TianoTools/Common/PeiLib/Ipf/SwitchStack.s +++ /dev/null @@ -1,122 +0,0 @@ -//++ -// Copyright (c) 2004, Intel Corporation -// All rights reserved. This program and the accompanying materials -// are licensed and made available under the terms and conditions of the BSD License -// which accompanies this distribution. The full text of the license may be found at -// http://opensource.org/licenses/bsd-license.php -// -// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -// -// Module Name: -// -// SwitchStack.s -// -// Abstract: -// -// Contains an implementation of a stack switch for the Itanium-based architecture. -// -// -// -// Revision History: -// -//-- - - .file "SwitchStack.s" - -#include -#include - -// Define hardware RSE Configuration Register -// -// RS Configuration (RSC) bit field positions - -#define RSC_MODE 0 -#define RSC_PL 2 -#define RSC_BE 4 -// RSC bits 5-15 reserved -#define RSC_MBZ0 5 -#define RSC_MBZ0_V 0x3ff -#define RSC_LOADRS 16 -#define RSC_LOADRS_LEN 14 -// RSC bits 30-63 reserved -#define RSC_MBZ1 30 -#define RSC_MBZ1_V 0x3ffffffffULL - -// RSC modes -// Lazy -#define RSC_MODE_LY (0x0) -// Store intensive -#define RSC_MODE_SI (0x1) -// Load intensive -#define RSC_MODE_LI (0x2) -// Eager -#define RSC_MODE_EA (0x3) - -// RSC Endian bit values -#define RSC_BE_LITTLE 0 -#define RSC_BE_BIG 1 - -// RSC while in kernel: enabled, little endian, pl = 0, eager mode -#define RSC_KERNEL ((RSC_MODE_EA<> Count; -} - -UINT64 -MultU64x32 ( - IN UINT64 Multiplicand, - IN UINTN Multiplier - ) -/*++ - -Routine Description: - - This routine allows a 64 bit value to be multiplied with a 32 bit - value returns 64bit result. - No checking if the result is greater than 64bits - -Arguments: - - Multiplicand - multiplicand - Multiplier - multiplier - -Returns: - - Multiplicand * Multiplier - ---*/ -{ - return Multiplicand * Multiplier; -} - -UINT64 -DivU64x32 ( - IN UINT64 Dividend, - IN UINTN Divisor, - OUT UINTN *Remainder OPTIONAL - ) -/*++ - -Routine Description: - - This routine allows a 64 bit value to be divided with a 32 bit value returns - 64bit result and the Remainder. - N.B. only works for 31bit divisors!! - -Arguments: - - Dividend - dividend - Divisor - divisor - Remainder - buffer for remainder - -Returns: - - Dividend / Divisor - Remainder = Dividend mod Divisor - ---*/ -{ - if (Remainder) { - *Remainder = Dividend % Divisor; - } - - return Dividend / Divisor; -} diff --git a/Tools/Source/TianoTools/Common/PeiLib/Ipf/pioflush.s b/Tools/Source/TianoTools/Common/PeiLib/Ipf/pioflush.s deleted file mode 100644 index e48a5e427d..0000000000 --- a/Tools/Source/TianoTools/Common/PeiLib/Ipf/pioflush.s +++ /dev/null @@ -1,106 +0,0 @@ -//++ -// Copyright (c) 2004, Intel Corporation -// All rights reserved. This program and the accompanying materials -// are licensed and made available under the terms and conditions of the BSD License -// which accompanies this distribution. The full text of the license may be found at -// http://opensource.org/licenses/bsd-license.php -// -// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -// -// Module Name: -// -// pioflush.s -// -// Abstract: -// -// -// Revision History: -// -//-- - - .file "pioflush.c" - .radix D - .section .text, "ax", "progbits" - .align 32 - .section .pdata, "a", "progbits" - .align 4 - .section .xdata, "a", "progbits" - .align 8 - .section .data, "wa", "progbits" - .align 16 - .section .rdata, "a", "progbits" - .align 16 - .section .bss, "wa", "nobits" - .align 16 - .section .tls$, "was", "progbits" - .align 16 - .section .sdata, "was", "progbits" - .align 16 - .section .sbss, "was", "nobits" - .align 16 - .section .srdata, "as", "progbits" - .align 16 - .section .rdata, "a", "progbits" - .align 16 - .section .rtcode, "ax", "progbits" - .align 32 - .type RtPioICacheFlush# ,@function - .global RtPioICacheFlush# -// Function compile flags: /Ogsy - .section .rtcode - -// Begin code for function: RtPioICacheFlush: - .proc RtPioICacheFlush# - .align 32 -RtPioICacheFlush: -// File e:\tmp\pioflush.c - { .mii //R-Addr: 0X00 - alloc r3=2, 0, 0, 0 //11, 00000002H - cmp4.leu p0,p6=32, r33;; //15, 00000020H - (p6) mov r33=32;; //16, 00000020H - } - { .mii //R-Addr: 0X010 - nop.m 0 - zxt4 r29=r33;; //21 - dep.z r30=r29, 0, 5;; //21, 00000005H - } - { .mii //R-Addr: 0X020 - cmp4.eq p0,p7=r0, r30 //21 - shr.u r28=r29, 5;; //19, 00000005H - (p7) adds r28=1, r28;; //22, 00000001H - } - { .mii //R-Addr: 0X030 - nop.m 0 - shl r27=r28, 5;; //25, 00000005H - zxt4 r26=r27;; //25 - } - { .mfb //R-Addr: 0X040 - add r31=r26, r32 //25 - nop.f 0 - nop.b 0 - } -$L143: - { .mii //R-Addr: 0X050 - fc r32 //27 - adds r32=32, r32;; //28, 00000020H - cmp.ltu p14,p15=r32, r31 //29 - } - { .mfb //R-Addr: 0X060 - nop.m 0 - nop.f 0 - (p14) br.cond.dptk.few $L143#;; //29, 880000/120000 - } - { .mmi - sync.i;; - srlz.i - nop.i 0;; - } - { .mfb //R-Addr: 0X070 - nop.m 0 - nop.f 0 - br.ret.sptk.few b0;; //31 - } -// End code for function: - .endp RtPioICacheFlush# -// END diff --git a/Tools/Source/TianoTools/Common/PeiLib/Ipf/processor.c b/Tools/Source/TianoTools/Common/PeiLib/Ipf/processor.c deleted file mode 100644 index e6d5c40435..0000000000 --- a/Tools/Source/TianoTools/Common/PeiLib/Ipf/processor.c +++ /dev/null @@ -1,118 +0,0 @@ -/*++ - -Copyright (c) 2004, Intel Corporation -All rights reserved. This program and the accompanying materials -are licensed and made available under the terms and conditions of the BSD License -which accompanies this distribution. The full text of the license may be found at -http://opensource.org/licenses/bsd-license.php - -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -Module Name: - - Processor.c - -Abstract: - ---*/ - -#include "Tiano.h" -#include "EfiJump.h" -#include "PeiHob.h" -#include EFI_GUID_DEFINITION (PeiFlushInstructionCache) -#include EFI_GUID_DEFINITION (PeiTransferControl) - -EFI_STATUS -WinNtFlushInstructionCacheFlush ( - IN EFI_PEI_FLUSH_INSTRUCTION_CACHE_PROTOCOL *This, - IN EFI_PHYSICAL_ADDRESS Start, - IN UINT64 Length - ); - -EFI_PEI_TRANSFER_CONTROL_PROTOCOL mTransferControl = { - SetJump, - LongJump, - sizeof (EFI_JUMP_BUFFER) -}; - -EFI_PEI_FLUSH_INSTRUCTION_CACHE_PROTOCOL mFlushInstructionCache = { - WinNtFlushInstructionCacheFlush -}; - -EFI_STATUS -InstallEfiPeiTransferControl ( - IN OUT EFI_PEI_TRANSFER_CONTROL_PROTOCOL **This - ) -/*++ - -Routine Description: - - Installs the pointer to the transfer control mechanism - -Arguments: - - This - Pointer to transfer control mechanism. - -Returns: - - EFI_SUCCESS - Successfully installed. - ---*/ -{ - *This = &mTransferControl; - return EFI_SUCCESS; -} - -EFI_STATUS -InstallEfiPeiFlushInstructionCache ( - IN OUT EFI_PEI_FLUSH_INSTRUCTION_CACHE_PROTOCOL **This - ) -/*++ - -Routine Description: - - Installs the pointer to the flush instruction cache mechanism - -Arguments: - - This - Pointer to flush instruction cache mechanism. - -Returns: - - EFI_SUCCESS - Successfully installed - ---*/ -{ - *This = &mFlushInstructionCache; - return EFI_SUCCESS; -} - -EFI_STATUS -WinNtFlushInstructionCacheFlush ( - IN EFI_PEI_FLUSH_INSTRUCTION_CACHE_PROTOCOL *This, - IN EFI_PHYSICAL_ADDRESS Start, - IN UINT64 Length - ) -/*++ - -Routine Description: - - This routine would provide support for flushing the CPU instruction cache. - -Arguments: - - This - Pointer to CPU Architectural Protocol interface - Start - Start adddress in memory to flush - Length - Length of memory to flush - -Returns: - - Status - EFI_SUCCESS - ---*/ -{ - RtPioICacheFlush ((UINT8 *) Start, (UINTN) Length); - return EFI_SUCCESS; -} diff --git a/Tools/Source/TianoTools/Common/PeiLib/Ipf/setjmp.s b/Tools/Source/TianoTools/Common/PeiLib/Ipf/setjmp.s deleted file mode 100644 index 4606437117..0000000000 --- a/Tools/Source/TianoTools/Common/PeiLib/Ipf/setjmp.s +++ /dev/null @@ -1,325 +0,0 @@ -//++ -// Copyright (c) 2004, Intel Corporation -// All rights reserved. This program and the accompanying materials -// are licensed and made available under the terms and conditions of the BSD License -// which accompanies this distribution. The full text of the license may be found at -// http://opensource.org/licenses/bsd-license.php -// -// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -// -// Module Name: -// -// setjmp.s -// -// Abstract: -// -// Contains an implementation of setjmp and longjmp for the -// Itanium-based architecture. -// -// -// -// Revision History: -// -//-- - - .file "setjmp.s" - -#include -#include - -// int SetJump(struct jmp_buffer save) -// -// Setup a non-local goto. -// -// Description: -// -// SetJump stores the current register set in the area pointed to -// by "save". It returns zero. Subsequent calls to "LongJump" will -// restore the registers and return non-zero to the same location. -// -// On entry, r32 contains the pointer to the jmp_buffer -// - -PROCEDURE_ENTRY(SetJump) - // - // Make sure buffer is aligned at 16byte boundary - // - mov r32 = r33 - - add r10 = -0x10,r0 ;; // mask the lower 4 bits - and r32 = r32, r10;; - add r32 = 0x10, r32;; // move to next 16 byte boundary - - add r10 = J_PREDS, r32 // skip Unats & pfs save area - add r11 = J_BSP, r32 - // - // save immediate context - // - mov r2 = ar.bsp // save backing store pointer - mov r3 = pr // save predicates - ;; - // - // save user Unat register - // - mov r16 = ar.lc // save loop count register - mov r14 = ar.unat // save user Unat register - - st8 [r10] = r3, J_LC-J_PREDS - st8 [r11] = r2, J_R4-J_BSP - ;; - st8 [r10] = r16, J_R5-J_LC - st8 [r32] = r14, J_NATS // Note: Unat at the - // beginning of the save area - mov r15 = ar.pfs - ;; - // - // save preserved general registers & NaT's - // - st8.spill [r11] = r4, J_R6-J_R4 - ;; - st8.spill [r10] = r5, J_R7-J_R5 - ;; - st8.spill [r11] = r6, J_SP-J_R6 - ;; - st8.spill [r10] = r7, J_F3-J_R7 - ;; - st8.spill [r11] = sp, J_F2-J_SP - ;; - // - // save spilled Unat and pfs registers - // - mov r2 = ar.unat // save Unat register after spill - ;; - st8 [r32] = r2, J_PFS-J_NATS // save unat for spilled regs - ;; - st8 [r32] = r15 // save pfs - // - // save floating registers - // - stf.spill [r11] = f2, J_F4-J_F2 - stf.spill [r10] = f3, J_F5-J_F3 - ;; - stf.spill [r11] = f4, J_F16-J_F4 - stf.spill [r10] = f5, J_F17-J_F5 - ;; - stf.spill [r11] = f16, J_F18-J_F16 - stf.spill [r10] = f17, J_F19-J_F17 - ;; - stf.spill [r11] = f18, J_F20-J_F18 - stf.spill [r10] = f19, J_F21-J_F19 - ;; - stf.spill [r11] = f20, J_F22-J_F20 - stf.spill [r10] = f21, J_F23-J_F21 - ;; - stf.spill [r11] = f22, J_F24-J_F22 - stf.spill [r10] = f23, J_F25-J_F23 - ;; - stf.spill [r11] = f24, J_F26-J_F24 - stf.spill [r10] = f25, J_F27-J_F25 - ;; - stf.spill [r11] = f26, J_F28-J_F26 - stf.spill [r10] = f27, J_F29-J_F27 - ;; - stf.spill [r11] = f28, J_F30-J_F28 - stf.spill [r10] = f29, J_F31-J_F29 - ;; - stf.spill [r11] = f30, J_FPSR-J_F30 - stf.spill [r10] = f31, J_B0-J_F31 // size of f31 + fpsr - // - // save FPSR register & branch registers - // - mov r2 = ar.fpsr // save fpsr register - mov r3 = b0 - ;; - st8 [r11] = r2, J_B1-J_FPSR - st8 [r10] = r3, J_B2-J_B0 - mov r2 = b1 - mov r3 = b2 - ;; - st8 [r11] = r2, J_B3-J_B1 - st8 [r10] = r3, J_B4-J_B2 - mov r2 = b3 - mov r3 = b4 - ;; - st8 [r11] = r2, J_B5-J_B3 - st8 [r10] = r3 - mov r2 = b5 - ;; - st8 [r11] = r2 - ;; - // - // return - // - mov r8 = r0 // return 0 from setjmp - mov ar.unat = r14 // restore unat - br.ret.sptk b0 - -PROCEDURE_EXIT(SetJump) - - -// -// void LongJump(struct jmp_buffer *) -// -// Perform a non-local goto. -// -// Description: -// -// LongJump initializes the register set to the values saved by a -// previous 'SetJump' and jumps to the return location saved by that -// 'SetJump'. This has the effect of unwinding the stack and returning -// for a second time to the 'SetJump'. -// - -PROCEDURE_ENTRY(LongJump) - // - // Make sure buffer is aligned at 16byte boundary - // - mov r32 = r33 - - add r10 = -0x10,r0 ;; // mask the lower 4 bits - and r32 = r32, r10;; - add r32 = 0x10, r32;; // move to next 16 byte boundary - - // - // caching the return value as we do invala in the end - // -/// mov r8 = r33 // return value - mov r8 = 1 // For now return hard coded 1 - - // - // get immediate context - // - mov r14 = ar.rsc // get user RSC conf - add r10 = J_PFS, r32 // get address of pfs - add r11 = J_NATS, r32 - ;; - ld8 r15 = [r10], J_BSP-J_PFS // get pfs - ld8 r2 = [r11], J_LC-J_NATS // get unat for spilled regs - ;; - mov ar.unat = r2 - ;; - ld8 r16 = [r10], J_PREDS-J_BSP // get backing store pointer - mov ar.rsc = r0 // put RSE in enforced lazy - mov ar.pfs = r15 - ;; - - // - // while returning from longjmp the BSPSTORE and BSP needs to be - // same and discard all the registers allocated after we did - // setjmp. Also, we need to generate the RNAT register since we - // did not flushed the RSE on setjmp. - // - mov r17 = ar.bspstore // get current BSPSTORE - ;; - cmp.ltu p6,p7 = r17, r16 // is it less than BSP of -(p6) br.spnt.few .flush_rse - mov r19 = ar.rnat // get current RNAT - ;; - loadrs // invalidate dirty regs - br.sptk.many .restore_rnat // restore RNAT - -.flush_rse: - flushrs - ;; - mov r19 = ar.rnat // get current RNAT - mov r17 = r16 // current BSPSTORE - ;; -.restore_rnat: - // - // check if RNAT is saved between saved BSP and curr BSPSTORE - // - dep r18 = 1,r16,3,6 // get RNAT address - ;; - cmp.ltu p8,p9 = r18, r17 // RNAT saved on RSE - ;; -(p8) ld8 r19 = [r18] // get RNAT from RSE - ;; - mov ar.bspstore = r16 // set new BSPSTORE - ;; - mov ar.rnat = r19 // restore RNAT - mov ar.rsc = r14 // restore RSC conf - - - ld8 r3 = [r11], J_R4-J_LC // get lc register - ld8 r2 = [r10], J_R5-J_PREDS // get predicates - ;; - mov pr = r2, -1 - mov ar.lc = r3 - // - // restore preserved general registers & NaT's - // - ld8.fill r4 = [r11], J_R6-J_R4 - ;; - ld8.fill r5 = [r10], J_R7-J_R5 - ld8.fill r6 = [r11], J_SP-J_R6 - ;; - ld8.fill r7 = [r10], J_F2-J_R7 - ld8.fill sp = [r11], J_F3-J_SP - ;; - // - // restore floating registers - // - ldf.fill f2 = [r10], J_F4-J_F2 - ldf.fill f3 = [r11], J_F5-J_F3 - ;; - ldf.fill f4 = [r10], J_F16-J_F4 - ldf.fill f5 = [r11], J_F17-J_F5 - ;; - ldf.fill f16 = [r10], J_F18-J_F16 - ldf.fill f17 = [r11], J_F19-J_F17 - ;; - ldf.fill f18 = [r10], J_F20-J_F18 - ldf.fill f19 = [r11], J_F21-J_F19 - ;; - ldf.fill f20 = [r10], J_F22-J_F20 - ldf.fill f21 = [r11], J_F23-J_F21 - ;; - ldf.fill f22 = [r10], J_F24-J_F22 - ldf.fill f23 = [r11], J_F25-J_F23 - ;; - ldf.fill f24 = [r10], J_F26-J_F24 - ldf.fill f25 = [r11], J_F27-J_F25 - ;; - ldf.fill f26 = [r10], J_F28-J_F26 - ldf.fill f27 = [r11], J_F29-J_F27 - ;; - ldf.fill f28 = [r10], J_F30-J_F28 - ldf.fill f29 = [r11], J_F31-J_F29 - ;; - ldf.fill f30 = [r10], J_FPSR-J_F30 - ldf.fill f31 = [r11], J_B0-J_F31 ;; - - // - // restore branch registers and fpsr - // - ld8 r16 = [r10], J_B1-J_FPSR // get fpsr - ld8 r17 = [r11], J_B2-J_B0 // get return pointer - ;; - mov ar.fpsr = r16 - mov b0 = r17 - ld8 r2 = [r10], J_B3-J_B1 - ld8 r3 = [r11], J_B4-J_B2 - ;; - mov b1 = r2 - mov b2 = r3 - ld8 r2 = [r10], J_B5-J_B3 - ld8 r3 = [r11] - ;; - mov b3 = r2 - mov b4 = r3 - ld8 r2 = [r10] - ld8 r21 = [r32] // get user unat - ;; - mov b5 = r2 - mov ar.unat = r21 - - // - // invalidate ALAT - // - invala ;; - - br.ret.sptk b0 -PROCEDURE_EXIT(LongJump) - - diff --git a/Tools/Source/TianoTools/Common/PeiLib/PeCoffLoader.c b/Tools/Source/TianoTools/Common/PeiLib/PeCoffLoader.c deleted file mode 100644 index d6c2cb3cac..0000000000 --- a/Tools/Source/TianoTools/Common/PeiLib/PeCoffLoader.c +++ /dev/null @@ -1,1180 +0,0 @@ -/*++ - -Copyright (c) 2004 - 2005, Intel Corporation -All rights reserved. This program and the accompanying materials -are licensed and made available under the terms and conditions of the BSD License -which accompanies this distribution. The full text of the license may be found at -http://opensource.org/licenses/bsd-license.php - -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -Module Name: - - PeCoffLoader.c - -Abstract: - - Tiano PE/COFF loader - -Revision History - ---*/ - -#include "Tiano.h" -#include "Pei.h" -#include "PeiLib.h" -#include "PeCoffLoaderEx.h" - - -STATIC -EFI_STATUS -PeCoffLoaderGetPeHeader ( - IN OUT EFI_PEI_PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext, - OUT EFI_IMAGE_NT_HEADERS *PeHdr, - OUT EFI_TE_IMAGE_HEADER *TeHdr - ); - -STATIC -EFI_STATUS -PeCoffLoaderCheckImageType ( - IN OUT EFI_PEI_PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext, - IN EFI_IMAGE_NT_HEADERS *PeHdr, - IN EFI_TE_IMAGE_HEADER *TeHdr - ); - -STATIC -VOID * -PeCoffLoaderImageAddress ( - IN OUT EFI_PEI_PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext, - IN UINTN Address - ); - -EFI_STATUS -EFIAPI -PeCoffLoaderGetImageInfo ( - IN EFI_PEI_PE_COFF_LOADER_PROTOCOL *This, - IN OUT EFI_PEI_PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext - ); - -EFI_STATUS -EFIAPI -PeCoffLoaderRelocateImage ( - IN EFI_PEI_PE_COFF_LOADER_PROTOCOL *This, - IN OUT EFI_PEI_PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext - ); - -EFI_STATUS -EFIAPI -PeCoffLoaderLoadImage ( - IN EFI_PEI_PE_COFF_LOADER_PROTOCOL *This, - IN OUT EFI_PEI_PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext - ); - -EFI_STATUS -EFIAPI -PeCoffLoaderUnloadImage ( - IN EFI_PEI_PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext - ); - -EFI_PEI_PE_COFF_LOADER_PROTOCOL mPeCoffLoader = { - PeCoffLoaderGetImageInfo, - PeCoffLoaderLoadImage, - PeCoffLoaderRelocateImage, - PeCoffLoaderUnloadImage -}; - - -EFI_STATUS -InstallEfiPeiPeCoffLoader ( - IN EFI_PEI_SERVICES **PeiServices, - IN OUT EFI_PEI_PE_COFF_LOADER_PROTOCOL **This, - IN EFI_PEI_PPI_DESCRIPTOR *ThisPpi - ) -/*++ - -Routine Description: - - Install PE/COFF loader PPI - -Arguments: - - PeiServices - General purpose services available to every PEIM - - This - Pointer to get Pei PE coff loader protocol as output - - ThisPpi - Passed in as EFI_NT_LOAD_AS_DLL_PPI on NT_EMULATOR platform - -Returns: - - EFI_SUCCESS - ---*/ -{ - if (NULL != This) { - *This = &mPeCoffLoader; - } - - return EFI_SUCCESS; -} - -STATIC -EFI_STATUS -PeCoffLoaderGetPeHeader ( - IN OUT EFI_PEI_PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext, - OUT EFI_IMAGE_NT_HEADERS *PeHdr, - OUT EFI_TE_IMAGE_HEADER *TeHdr - ) -/*++ - -Routine Description: - - Retrieves the PE or TE Header from a PE/COFF or TE image - -Arguments: - - ImageContext - The context of the image being loaded - - PeHdr - The buffer in which to return the PE header - - TeHdr - The buffer in which to return the TE header - -Returns: - - EFI_SUCCESS if the PE or TE Header is read, - Otherwise, the error status from reading the PE/COFF or TE image using the ImageRead function. - ---*/ -{ - EFI_STATUS Status; - EFI_IMAGE_DOS_HEADER DosHdr; - UINTN Size; - - ImageContext->IsTeImage = FALSE; - // - // Read the DOS image headers - // - Size = sizeof (EFI_IMAGE_DOS_HEADER); - Status = ImageContext->ImageRead ( - ImageContext->Handle, - 0, - &Size, - &DosHdr - ); - if (EFI_ERROR (Status)) { - ImageContext->ImageError = EFI_IMAGE_ERROR_IMAGE_READ; - return Status; - } - - ImageContext->PeCoffHeaderOffset = 0; - if (DosHdr.e_magic == EFI_IMAGE_DOS_SIGNATURE) { - // - // DOS image header is present, so read the PE header after the DOS image header - // - ImageContext->PeCoffHeaderOffset = DosHdr.e_lfanew; - } - // - // Read the PE/COFF Header - // - Size = sizeof (EFI_IMAGE_NT_HEADERS); - Status = ImageContext->ImageRead ( - ImageContext->Handle, - ImageContext->PeCoffHeaderOffset, - &Size, - PeHdr - ); - if (EFI_ERROR (Status)) { - ImageContext->ImageError = EFI_IMAGE_ERROR_IMAGE_READ; - return Status; - } - // - // Check the PE/COFF Header Signature. If not, then try to read a TE header - // - if (PeHdr->Signature != EFI_IMAGE_NT_SIGNATURE) { - Size = sizeof (EFI_TE_IMAGE_HEADER); - Status = ImageContext->ImageRead ( - ImageContext->Handle, - 0, - &Size, - TeHdr - ); - if (TeHdr->Signature != EFI_TE_IMAGE_HEADER_SIGNATURE) { - return EFI_UNSUPPORTED; - } - - ImageContext->IsTeImage = TRUE; - } - - return EFI_SUCCESS; -} - -STATIC -EFI_STATUS -PeCoffLoaderCheckImageType ( - IN OUT EFI_PEI_PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext, - IN EFI_IMAGE_NT_HEADERS *PeHdr, - IN EFI_TE_IMAGE_HEADER *TeHdr - ) -/*++ - -Routine Description: - - Checks the PE or TE header of a PE/COFF or TE image to determine if it supported - -Arguments: - - ImageContext - The context of the image being loaded - - PeHdr - The buffer in which to return the PE header - - TeHdr - The buffer in which to return the TE header - -Returns: - - EFI_SUCCESS if the PE/COFF or TE image is supported - EFI_UNSUPPORTED of the PE/COFF or TE image is not supported. - ---*/ -{ - // - // See if the machine type is supported. We support a native machine type (IA-32/Itanium-based) - // and the machine type for the Virtual Machine. - // - if (ImageContext->IsTeImage == FALSE) { - ImageContext->Machine = PeHdr->FileHeader.Machine; - } else { - ImageContext->Machine = TeHdr->Machine; - } - - if (!(EFI_IMAGE_MACHINE_TYPE_SUPPORTED (ImageContext->Machine))) { - ImageContext->ImageError = EFI_IMAGE_ERROR_INVALID_MACHINE_TYPE; - return EFI_UNSUPPORTED; - } - - // - // See if the image type is supported. We support EFI Applications, - // EFI Boot Service Drivers, and EFI Runtime Drivers. - // - if (ImageContext->IsTeImage == FALSE) { - ImageContext->ImageType = PeHdr->OptionalHeader.Subsystem; - } else { - ImageContext->ImageType = (UINT16) (TeHdr->Subsystem); - } - - switch (ImageContext->ImageType) { - - case EFI_IMAGE_SUBSYSTEM_EFI_APPLICATION: - ImageContext->ImageCodeMemoryType = EfiLoaderCode; - ImageContext->ImageDataMemoryType = EfiLoaderData; - break; - - case EFI_IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER: - ImageContext->ImageCodeMemoryType = EfiBootServicesCode; - ImageContext->ImageDataMemoryType = EfiBootServicesData; - break; - - case EFI_IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER: - case EFI_IMAGE_SUBSYSTEM_SAL_RUNTIME_DRIVER: - ImageContext->ImageCodeMemoryType = EfiRuntimeServicesCode; - ImageContext->ImageDataMemoryType = EfiRuntimeServicesData; - break; - - default: - ImageContext->ImageError = EFI_IMAGE_ERROR_INVALID_SUBSYSTEM; - return EFI_UNSUPPORTED; - } - - return EFI_SUCCESS; -} - -EFI_STATUS -EFIAPI -PeCoffLoaderGetImageInfo ( - IN EFI_PEI_PE_COFF_LOADER_PROTOCOL *This, - IN OUT EFI_PEI_PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext - ) -/*++ - -Routine Description: - - Retrieves information on a PE/COFF image - -Arguments: - - This - Calling context - ImageContext - The context of the image being loaded - -Returns: - - EFI_SUCCESS - The information on the PE/COFF image was collected. - EFI_INVALID_PARAMETER - ImageContext is NULL. - EFI_UNSUPPORTED - The PE/COFF image is not supported. - Otherwise - The error status from reading the PE/COFF image using the - ImageContext->ImageRead() function - ---*/ -{ - EFI_STATUS Status; - EFI_IMAGE_NT_HEADERS PeHdr; - EFI_TE_IMAGE_HEADER TeHdr; - EFI_IMAGE_DATA_DIRECTORY *DebugDirectoryEntry; - UINTN Size; - UINTN Index; - UINTN DebugDirectoryEntryRva; - UINTN DebugDirectoryEntryFileOffset; - UINTN SectionHeaderOffset; - EFI_IMAGE_SECTION_HEADER SectionHeader; - EFI_IMAGE_DEBUG_DIRECTORY_ENTRY DebugEntry; - - if (NULL == ImageContext) { - return EFI_INVALID_PARAMETER; - } - // - // Assume success - // - ImageContext->ImageError = EFI_IMAGE_ERROR_SUCCESS; - - Status = PeCoffLoaderGetPeHeader (ImageContext, &PeHdr, &TeHdr); - if (EFI_ERROR (Status)) { - return Status; - } - // - // Verify machine type - // - Status = PeCoffLoaderCheckImageType (ImageContext, &PeHdr, &TeHdr); - if (EFI_ERROR (Status)) { - return Status; - } - // - // Retrieve the base address of the image - // - if (!(ImageContext->IsTeImage)) { - ImageContext->ImageAddress = PeHdr.OptionalHeader.ImageBase; - } else { - ImageContext->ImageAddress = (EFI_PHYSICAL_ADDRESS) (TeHdr.ImageBase); - } - // - // Initialize the alternate destination address to 0 indicating that it - // should not be used. - // - ImageContext->DestinationAddress = 0; - - // - // Initialize the codeview pointer. - // - ImageContext->CodeView = NULL; - ImageContext->PdbPointer = NULL; - - // - // Three cases with regards to relocations: - // - Image has base relocs, RELOCS_STRIPPED==0 => image is relocatable - // - Image has no base relocs, RELOCS_STRIPPED==1 => Image is not relocatable - // - Image has no base relocs, RELOCS_STRIPPED==0 => Image is relocatable but - // has no base relocs to apply - // Obviously having base relocations with RELOCS_STRIPPED==1 is invalid. - // - // Look at the file header to determine if relocations have been stripped, and - // save this info in the image context for later use. - // - if ((!(ImageContext->IsTeImage)) && ((PeHdr.FileHeader.Characteristics & EFI_IMAGE_FILE_RELOCS_STRIPPED) != 0)) { - ImageContext->RelocationsStripped = TRUE; - } else { - ImageContext->RelocationsStripped = FALSE; - } - - if (!(ImageContext->IsTeImage)) { - ImageContext->ImageSize = (UINT64) PeHdr.OptionalHeader.SizeOfImage; - ImageContext->SectionAlignment = PeHdr.OptionalHeader.SectionAlignment; - ImageContext->SizeOfHeaders = PeHdr.OptionalHeader.SizeOfHeaders; - - // - // Modify ImageSize to contain .PDB file name if required and initialize - // PdbRVA field... - // - if (PeHdr.OptionalHeader.NumberOfRvaAndSizes > EFI_IMAGE_DIRECTORY_ENTRY_DEBUG) { - DebugDirectoryEntry = (EFI_IMAGE_DATA_DIRECTORY *) &(PeHdr.OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_DEBUG]); - - DebugDirectoryEntryRva = DebugDirectoryEntry->VirtualAddress; - - // - // Determine the file offset of the debug directory... This means we walk - // the sections to find which section contains the RVA of the debug - // directory - // - DebugDirectoryEntryFileOffset = 0; - - SectionHeaderOffset = (UINTN)( - ImageContext->PeCoffHeaderOffset + - sizeof (UINT32) + - sizeof (EFI_IMAGE_FILE_HEADER) + - PeHdr.FileHeader.SizeOfOptionalHeader - ); - - for (Index = 0; Index < PeHdr.FileHeader.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)) { - ImageContext->ImageError = EFI_IMAGE_ERROR_IMAGE_READ; - return Status; - } - - if (DebugDirectoryEntryRva >= SectionHeader.VirtualAddress && - DebugDirectoryEntryRva < SectionHeader.VirtualAddress + SectionHeader.Misc.VirtualSize) { - DebugDirectoryEntryFileOffset = - DebugDirectoryEntryRva - SectionHeader.VirtualAddress + SectionHeader.PointerToRawData; - break; - } - - SectionHeaderOffset += sizeof (EFI_IMAGE_SECTION_HEADER); - } - - if (DebugDirectoryEntryFileOffset != 0) { - for (Index = 0; Index < DebugDirectoryEntry->Size; Index++) { - // - // Read next debug directory entry - // - Size = sizeof (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY); - Status = ImageContext->ImageRead ( - ImageContext->Handle, - DebugDirectoryEntryFileOffset, - &Size, - &DebugEntry - ); - if (EFI_ERROR (Status)) { - ImageContext->ImageError = EFI_IMAGE_ERROR_IMAGE_READ; - return Status; - } - - if (DebugEntry.Type == EFI_IMAGE_DEBUG_TYPE_CODEVIEW) { - ImageContext->DebugDirectoryEntryRva = (UINT32) (DebugDirectoryEntryRva + Index * sizeof (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY)); - if (DebugEntry.RVA == 0 && DebugEntry.FileOffset != 0) { - ImageContext->ImageSize += DebugEntry.SizeOfData; - } - - return EFI_SUCCESS; - } - } - } - } - } else { - ImageContext->ImageSize = 0; - ImageContext->SectionAlignment = 4096; - ImageContext->SizeOfHeaders = sizeof (EFI_TE_IMAGE_HEADER) + (UINTN) TeHdr.BaseOfCode - (UINTN) TeHdr.StrippedSize; - - DebugDirectoryEntry = &TeHdr.DataDirectory[1]; - DebugDirectoryEntryRva = DebugDirectoryEntry->VirtualAddress; - SectionHeaderOffset = (UINTN) (sizeof (EFI_TE_IMAGE_HEADER)); - - DebugDirectoryEntryFileOffset = 0; - - for (Index = 0; Index < TeHdr.NumberOfSections;) { - // - // Read section header from file - // - Size = sizeof (EFI_IMAGE_SECTION_HEADER); - Status = ImageContext->ImageRead ( - ImageContext->Handle, - SectionHeaderOffset, - &Size, - &SectionHeader - ); - if (EFI_ERROR (Status)) { - ImageContext->ImageError = EFI_IMAGE_ERROR_IMAGE_READ; - return Status; - } - - if (DebugDirectoryEntryRva >= SectionHeader.VirtualAddress && - DebugDirectoryEntryRva < SectionHeader.VirtualAddress + SectionHeader.Misc.VirtualSize) { - DebugDirectoryEntryFileOffset = DebugDirectoryEntryRva - - SectionHeader.VirtualAddress + - SectionHeader.PointerToRawData + - sizeof (EFI_TE_IMAGE_HEADER) - - TeHdr.StrippedSize; - - // - // File offset of the debug directory was found, if this is not the last - // section, then skip to the last section for calculating the image size. - // - if (Index < (UINTN) TeHdr.NumberOfSections - 1) { - SectionHeaderOffset += (TeHdr.NumberOfSections - 1 - Index) * sizeof (EFI_IMAGE_SECTION_HEADER); - Index = TeHdr.NumberOfSections - 1; - continue; - } - } - - // - // In Te image header there is not a field to describe the ImageSize. - // Actually, the ImageSize equals the RVA plus the VirtualSize of - // the last section mapped into memory (Must be rounded up to - // a mulitple of Section Alignment). Per the PE/COFF specification, the - // section headers in the Section Table must appear in order of the RVA - // values for the corresponding sections. So the ImageSize can be determined - // by the RVA and the VirtualSize of the last section header in the - // Section Table. - // - if ((++Index) == (UINTN) TeHdr.NumberOfSections) { - ImageContext->ImageSize = (SectionHeader.VirtualAddress + SectionHeader.Misc.VirtualSize + - ImageContext->SectionAlignment - 1) & ~(ImageContext->SectionAlignment - 1); - } - - SectionHeaderOffset += sizeof (EFI_IMAGE_SECTION_HEADER); - } - - if (DebugDirectoryEntryFileOffset != 0) { - for (Index = 0; Index < DebugDirectoryEntry->Size; Index++) { - // - // Read next debug directory entry - // - Size = sizeof (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY); - Status = ImageContext->ImageRead ( - ImageContext->Handle, - DebugDirectoryEntryFileOffset, - &Size, - &DebugEntry - ); - if (EFI_ERROR (Status)) { - ImageContext->ImageError = EFI_IMAGE_ERROR_IMAGE_READ; - return Status; - } - - if (DebugEntry.Type == EFI_IMAGE_DEBUG_TYPE_CODEVIEW) { - ImageContext->DebugDirectoryEntryRva = (UINT32) (DebugDirectoryEntryRva + Index * sizeof (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY)); - return EFI_SUCCESS; - } - } - } - } - - return EFI_SUCCESS; -} - -STATIC -VOID * -PeCoffLoaderImageAddress ( - IN OUT EFI_PEI_PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext, - IN UINTN Address - ) -/*++ - -Routine Description: - - Converts an image address to the loaded address - -Arguments: - - ImageContext - The context of the image being loaded - - Address - The address to be converted to the loaded address - -Returns: - - NULL if the address can not be converted, otherwise, the converted address - ---*/ -{ - if (Address >= ImageContext->ImageSize) { - ImageContext->ImageError = EFI_IMAGE_ERROR_INVALID_IMAGE_ADDRESS; - return NULL; - } - - return (CHAR8 *) ((UINTN) ImageContext->ImageAddress + Address); -} - -EFI_STATUS -EFIAPI -PeCoffLoaderRelocateImage ( - IN EFI_PEI_PE_COFF_LOADER_PROTOCOL *This, - IN OUT EFI_PEI_PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext - ) -/*++ - -Routine Description: - - Relocates a PE/COFF image in memory - -Arguments: - - This - Calling context - - ImageContext - Contains information on the loaded image to relocate - -Returns: - - EFI_SUCCESS if the PE/COFF image was relocated - EFI_LOAD_ERROR if the image is not a valid PE/COFF image - EFI_UNSUPPORTED not support - ---*/ -{ - EFI_STATUS Status; - EFI_IMAGE_NT_HEADERS *PeHdr; - EFI_TE_IMAGE_HEADER *TeHdr; - EFI_IMAGE_DATA_DIRECTORY *RelocDir; - UINT64 Adjust; - EFI_IMAGE_BASE_RELOCATION *RelocBase; - EFI_IMAGE_BASE_RELOCATION *RelocBaseEnd; - UINT16 *Reloc; - UINT16 *RelocEnd; - CHAR8 *Fixup; - CHAR8 *FixupBase; - UINT16 *F16; - UINT32 *F32; - CHAR8 *FixupData; - EFI_PHYSICAL_ADDRESS BaseAddress; - - PeHdr = NULL; - TeHdr = NULL; - // - // Assume success - // - ImageContext->ImageError = EFI_IMAGE_ERROR_SUCCESS; - - // - // If there are no relocation entries, then we are done - // - if (ImageContext->RelocationsStripped) { - return EFI_SUCCESS; - } - - // - // If the destination address is not 0, use that rather than the - // image address as the relocation target. - // - if (ImageContext->DestinationAddress) { - BaseAddress = ImageContext->DestinationAddress; - } else { - BaseAddress = ImageContext->ImageAddress; - } - - if (!(ImageContext->IsTeImage)) { - PeHdr = (EFI_IMAGE_NT_HEADERS *)((UINTN)ImageContext->ImageAddress + - ImageContext->PeCoffHeaderOffset); - Adjust = (UINT64) BaseAddress - PeHdr->OptionalHeader.ImageBase; - PeHdr->OptionalHeader.ImageBase = (UINTN) BaseAddress; - - // - // Find the relocation block - // - // Per the PE/COFF spec, you can't assume that a given data directory - // is present in the image. You have to check the NumberOfRvaAndSizes in - // the optional header to verify a desired directory entry is there. - // - if (PeHdr->OptionalHeader.NumberOfRvaAndSizes > EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC) { - RelocDir = &PeHdr->OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC]; - RelocBase = PeCoffLoaderImageAddress (ImageContext, RelocDir->VirtualAddress); - RelocBaseEnd = PeCoffLoaderImageAddress ( - ImageContext, - RelocDir->VirtualAddress + RelocDir->Size - 1 - ); - } else { - // - // Set base and end to bypass processing below. - // - RelocBase = RelocBaseEnd = 0; - } - } else { - TeHdr = (EFI_TE_IMAGE_HEADER *) (UINTN) (ImageContext->ImageAddress); - Adjust = (UINT64) (BaseAddress - TeHdr->ImageBase); - TeHdr->ImageBase = (UINT64) (BaseAddress); - - // - // Find the relocation block - // - RelocDir = &TeHdr->DataDirectory[0]; - RelocBase = (EFI_IMAGE_BASE_RELOCATION *)(UINTN)( - ImageContext->ImageAddress + - RelocDir->VirtualAddress + - sizeof(EFI_TE_IMAGE_HEADER) - - TeHdr->StrippedSize - ); - RelocBaseEnd = (EFI_IMAGE_BASE_RELOCATION *) ((UINTN) RelocBase + (UINTN) RelocDir->Size - 1); - } - - // - // Run the relocation information and apply the fixups - // - FixupData = ImageContext->FixupData; - while (RelocBase < RelocBaseEnd) { - - Reloc = (UINT16 *) ((CHAR8 *) RelocBase + sizeof (EFI_IMAGE_BASE_RELOCATION)); - RelocEnd = (UINT16 *) ((CHAR8 *) RelocBase + RelocBase->SizeOfBlock); - if (!(ImageContext->IsTeImage)) { - FixupBase = PeCoffLoaderImageAddress (ImageContext, RelocBase->VirtualAddress); - } else { - FixupBase = (CHAR8 *)(UINTN)(ImageContext->ImageAddress + - RelocBase->VirtualAddress + - sizeof(EFI_TE_IMAGE_HEADER) - - TeHdr->StrippedSize - ); - } - - if ((CHAR8 *) RelocEnd < (CHAR8 *) ((UINTN) ImageContext->ImageAddress) || - (CHAR8 *) RelocEnd > (CHAR8 *)((UINTN)ImageContext->ImageAddress + - (UINTN)ImageContext->ImageSize)) { - ImageContext->ImageError = EFI_IMAGE_ERROR_FAILED_RELOCATION; - return EFI_LOAD_ERROR; - } - - // - // Run this relocation record - // - while (Reloc < RelocEnd) { - - Fixup = FixupBase + (*Reloc & 0xFFF); - switch ((*Reloc) >> 12) { - case EFI_IMAGE_REL_BASED_ABSOLUTE: - break; - - case EFI_IMAGE_REL_BASED_HIGH: - F16 = (UINT16 *) Fixup; - *F16 = (UINT16) ((*F16 << 16) + (UINT16) Adjust); - if (FixupData != NULL) { - *(UINT16 *) FixupData = *F16; - FixupData = FixupData + sizeof (UINT16); - } - break; - - case EFI_IMAGE_REL_BASED_LOW: - F16 = (UINT16 *) Fixup; - *F16 = (UINT16) (*F16 + (UINT16) Adjust); - if (FixupData != NULL) { - *(UINT16 *) FixupData = *F16; - FixupData = FixupData + sizeof (UINT16); - } - break; - - case EFI_IMAGE_REL_BASED_HIGHLOW: - F32 = (UINT32 *) Fixup; - *F32 = *F32 + (UINT32) Adjust; - if (FixupData != NULL) { - FixupData = ALIGN_POINTER (FixupData, sizeof (UINT32)); - *(UINT32 *) FixupData = *F32; - FixupData = FixupData + sizeof (UINT32); - } - break; - - case EFI_IMAGE_REL_BASED_HIGHADJ: - // - // Return the same EFI_UNSUPPORTED return code as - // PeCoffLoaderRelocateImageEx() returns if it does not recognize - // the relocation type. - // - ImageContext->ImageError = EFI_IMAGE_ERROR_FAILED_RELOCATION; - return EFI_UNSUPPORTED; - - default: - Status = PeCoffLoaderRelocateImageEx (Reloc, Fixup, &FixupData, Adjust); - if (EFI_ERROR (Status)) { - ImageContext->ImageError = EFI_IMAGE_ERROR_FAILED_RELOCATION; - return Status; - } - } - - // - // Next relocation record - // - Reloc += 1; - } - - // - // Next reloc block - // - RelocBase = (EFI_IMAGE_BASE_RELOCATION *) RelocEnd; - } - - return EFI_SUCCESS; -} - -EFI_STATUS -EFIAPI -PeCoffLoaderLoadImage ( - IN EFI_PEI_PE_COFF_LOADER_PROTOCOL *This, - IN OUT EFI_PEI_PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext - ) -/*++ - -Routine Description: - - Loads a PE/COFF image into memory - -Arguments: - - This - Calling context - - ImageContext - Contains information on image to load into memory - -Returns: - - EFI_SUCCESS if the PE/COFF image was loaded - EFI_BUFFER_TOO_SMALL if the caller did not provide a large enough buffer - EFI_LOAD_ERROR if the image is a runtime driver with no relocations - EFI_INVALID_PARAMETER if the image address is invalid - ---*/ -{ - EFI_STATUS Status; - EFI_IMAGE_NT_HEADERS *PeHdr; - EFI_TE_IMAGE_HEADER *TeHdr; - EFI_PEI_PE_COFF_LOADER_IMAGE_CONTEXT CheckContext; - EFI_IMAGE_SECTION_HEADER *FirstSection; - EFI_IMAGE_SECTION_HEADER *Section; - UINTN NumberOfSections; - UINTN Index; - CHAR8 *Base; - CHAR8 *End; - CHAR8 *MaxEnd; - EFI_IMAGE_DATA_DIRECTORY *DirectoryEntry; - EFI_IMAGE_DEBUG_DIRECTORY_ENTRY *DebugEntry; - UINTN Size; - UINT32 TempDebugEntryRva; - - PeHdr = NULL; - TeHdr = NULL; - // - // Assume success - // - ImageContext->ImageError = EFI_IMAGE_ERROR_SUCCESS; - - // - // Copy the provided context info into our local version, get what we - // can from the original image, and then use that to make sure everything - // is legit. - // - CopyMem (&CheckContext, ImageContext, sizeof (EFI_PEI_PE_COFF_LOADER_IMAGE_CONTEXT)); - - Status = PeCoffLoaderGetImageInfo ( - This, - &CheckContext - ); - if (EFI_ERROR (Status)) { - return Status; - } - - // - // Make sure there is enough allocated space for the image being loaded - // - if (ImageContext->ImageSize < CheckContext.ImageSize) { - ImageContext->ImageError = EFI_IMAGE_ERROR_INVALID_IMAGE_SIZE; - return EFI_BUFFER_TOO_SMALL; - } - - // - // If there's no relocations, then make sure it's not a runtime driver, - // and that it's being loaded at the linked address. - // - if (CheckContext.RelocationsStripped) { - // - // If the image does not contain relocations and it is a runtime driver - // then return an error. - // - if (CheckContext.ImageType == EFI_IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER) { - ImageContext->ImageError = EFI_IMAGE_ERROR_INVALID_SUBSYSTEM; - return EFI_LOAD_ERROR; - } - // - // If the image does not contain relocations, and the requested load address - // is not the linked address, then return an error. - // - if (CheckContext.ImageAddress != ImageContext->ImageAddress) { - ImageContext->ImageError = EFI_IMAGE_ERROR_INVALID_IMAGE_ADDRESS; - return EFI_INVALID_PARAMETER; - } - } - // - // Make sure the allocated space has the proper section alignment - // - if (!(ImageContext->IsTeImage)) { - if ((ImageContext->ImageAddress & (CheckContext.SectionAlignment - 1)) != 0) { - ImageContext->ImageError = EFI_IMAGE_ERROR_INVALID_SECTION_ALIGNMENT; - return EFI_INVALID_PARAMETER; - } - } - // - // Read the entire PE/COFF or TE header into memory - // - if (!(ImageContext->IsTeImage)) { - Status = ImageContext->ImageRead ( - ImageContext->Handle, - 0, - &ImageContext->SizeOfHeaders, - (VOID *) (UINTN) ImageContext->ImageAddress - ); - - PeHdr = (EFI_IMAGE_NT_HEADERS *) - ((UINTN)ImageContext->ImageAddress + ImageContext->PeCoffHeaderOffset); - - FirstSection = (EFI_IMAGE_SECTION_HEADER *) ( - (UINTN)ImageContext->ImageAddress + - ImageContext->PeCoffHeaderOffset + - sizeof(UINT32) + - sizeof(EFI_IMAGE_FILE_HEADER) + - PeHdr->FileHeader.SizeOfOptionalHeader - ); - NumberOfSections = (UINTN) (PeHdr->FileHeader.NumberOfSections); - } else { - Status = ImageContext->ImageRead ( - ImageContext->Handle, - 0, - &ImageContext->SizeOfHeaders, - (void *) (UINTN) ImageContext->ImageAddress - ); - - TeHdr = (EFI_TE_IMAGE_HEADER *) (UINTN) (ImageContext->ImageAddress); - - FirstSection = (EFI_IMAGE_SECTION_HEADER *) ( - (UINTN)ImageContext->ImageAddress + - sizeof(EFI_TE_IMAGE_HEADER) - ); - NumberOfSections = (UINTN) (TeHdr->NumberOfSections); - - } - - if (EFI_ERROR (Status)) { - ImageContext->ImageError = EFI_IMAGE_ERROR_IMAGE_READ; - return EFI_LOAD_ERROR; - } - - // - // Load each section of the image - // - Section = FirstSection; - for (Index = 0, MaxEnd = NULL; Index < NumberOfSections; Index++) { - - // - // Compute sections address - // - Base = PeCoffLoaderImageAddress (ImageContext, Section->VirtualAddress); - End = PeCoffLoaderImageAddress ( - ImageContext, - Section->VirtualAddress + Section->Misc.VirtualSize - 1 - ); - if (ImageContext->IsTeImage) { - Base = (CHAR8 *) ((UINTN) Base + sizeof (EFI_TE_IMAGE_HEADER) - (UINTN) TeHdr->StrippedSize); - End = (CHAR8 *) ((UINTN) End + sizeof (EFI_TE_IMAGE_HEADER) - (UINTN) TeHdr->StrippedSize); - } - - if (End > MaxEnd) { - MaxEnd = End; - } - // - // If the base start or end address resolved to 0, then fail. - // - if ((Base == NULL) || (End == NULL)) { - ImageContext->ImageError = EFI_IMAGE_ERROR_SECTION_NOT_LOADED; - return EFI_LOAD_ERROR; - } - - // - // Read the section - // - Size = (UINTN) Section->Misc.VirtualSize; - if ((Size == 0) || (Size > Section->SizeOfRawData)) { - Size = (UINTN) Section->SizeOfRawData; - } - - if (Section->SizeOfRawData) { - if (!(ImageContext->IsTeImage)) { - Status = ImageContext->ImageRead ( - ImageContext->Handle, - Section->PointerToRawData, - &Size, - Base - ); - } else { - Status = ImageContext->ImageRead ( - ImageContext->Handle, - Section->PointerToRawData + sizeof (EFI_TE_IMAGE_HEADER) - (UINTN) TeHdr->StrippedSize, - &Size, - Base - ); - } - - if (EFI_ERROR (Status)) { - ImageContext->ImageError = EFI_IMAGE_ERROR_IMAGE_READ; - return Status; - } - } - - // - // If raw size is less then virt size, zero fill the remaining - // - - if (Size < Section->Misc.VirtualSize) { - ZeroMem (Base + Size, Section->Misc.VirtualSize - Size); - } - - // - // Next Section - // - Section += 1; - } - - // - // Get image's entry point - // - if (!(ImageContext->IsTeImage)) { - ImageContext->EntryPoint = (EFI_PHYSICAL_ADDRESS) (UINTN) PeCoffLoaderImageAddress ( - ImageContext, - PeHdr->OptionalHeader.AddressOfEntryPoint - ); - } else { - ImageContext->EntryPoint = (EFI_PHYSICAL_ADDRESS) ( - (UINTN)ImageContext->ImageAddress + - (UINTN)TeHdr->AddressOfEntryPoint + - (UINTN)sizeof(EFI_TE_IMAGE_HEADER) - - (UINTN) TeHdr->StrippedSize - ); - } - - // - // Determine the size of the fixup data - // - // Per the PE/COFF spec, you can't assume that a given data directory - // is present in the image. You have to check the NumberOfRvaAndSizes in - // the optional header to verify a desired directory entry is there. - // - if (!(ImageContext->IsTeImage)) { - if (PeHdr->OptionalHeader.NumberOfRvaAndSizes > EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC) { - DirectoryEntry = (EFI_IMAGE_DATA_DIRECTORY *) - &PeHdr->OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC]; - ImageContext->FixupDataSize = DirectoryEntry->Size / sizeof (UINT16) * sizeof (UINTN); - } else { - ImageContext->FixupDataSize = 0; - } - } else { - DirectoryEntry = &TeHdr->DataDirectory[0]; - ImageContext->FixupDataSize = DirectoryEntry->Size / sizeof (UINT16) * sizeof (UINTN); - } - // - // Consumer must allocate a buffer for the relocation fixup log. - // Only used for runtime drivers. - // - ImageContext->FixupData = NULL; - - // - // Load the Codeview info if present - // - if (ImageContext->DebugDirectoryEntryRva != 0) { - if (!(ImageContext->IsTeImage)) { - DebugEntry = PeCoffLoaderImageAddress ( - ImageContext, - ImageContext->DebugDirectoryEntryRva - ); - } else { - DebugEntry = (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY *)(UINTN)( - ImageContext->ImageAddress + - ImageContext->DebugDirectoryEntryRva + - sizeof(EFI_TE_IMAGE_HEADER) - - TeHdr->StrippedSize - ); - } - - if (DebugEntry != NULL) { - TempDebugEntryRva = DebugEntry->RVA; - if (DebugEntry->RVA == 0 && DebugEntry->FileOffset != 0) { - Section--; - if ((UINTN) Section->SizeOfRawData < Section->Misc.VirtualSize) { - TempDebugEntryRva = Section->VirtualAddress + Section->Misc.VirtualSize; - } else { - TempDebugEntryRva = Section->VirtualAddress + Section->SizeOfRawData; - } - } - - if (TempDebugEntryRva != 0) { - if (!(ImageContext->IsTeImage)) { - ImageContext->CodeView = PeCoffLoaderImageAddress (ImageContext, TempDebugEntryRva); - } else { - ImageContext->CodeView = (VOID *)( - (UINTN)ImageContext->ImageAddress + - (UINTN)TempDebugEntryRva + - (UINTN)sizeof(EFI_TE_IMAGE_HEADER) - - (UINTN) TeHdr->StrippedSize - ); - } - - if (ImageContext->CodeView == NULL) { - ImageContext->ImageError = EFI_IMAGE_ERROR_IMAGE_READ; - return EFI_LOAD_ERROR; - } - - if (DebugEntry->RVA == 0) { - Size = DebugEntry->SizeOfData; - if (!(ImageContext->IsTeImage)) { - Status = ImageContext->ImageRead ( - ImageContext->Handle, - DebugEntry->FileOffset, - &Size, - ImageContext->CodeView - ); - } else { - Status = ImageContext->ImageRead ( - ImageContext->Handle, - DebugEntry->FileOffset + sizeof (EFI_TE_IMAGE_HEADER) - TeHdr->StrippedSize, - &Size, - ImageContext->CodeView - ); - // - // Should we apply fix up to this field according to the size difference between PE and TE? - // Because now we maintain TE header fields unfixed, this field will also remain as they are - // in original PE image. - // - } - - if (EFI_ERROR (Status)) { - ImageContext->ImageError = EFI_IMAGE_ERROR_IMAGE_READ; - return EFI_LOAD_ERROR; - } - - DebugEntry->RVA = TempDebugEntryRva; - } - - switch (*(UINT32 *) ImageContext->CodeView) { - case CODEVIEW_SIGNATURE_NB10: - ImageContext->PdbPointer = (CHAR8 *) ImageContext->CodeView + sizeof (EFI_IMAGE_DEBUG_CODEVIEW_NB10_ENTRY); - break; - - case CODEVIEW_SIGNATURE_RSDS: - ImageContext->PdbPointer = (CHAR8 *) ImageContext->CodeView + sizeof (EFI_IMAGE_DEBUG_CODEVIEW_RSDS_ENTRY); - break; - - default: - break; - } - } - } - } - - return Status; -} - -EFI_STATUS -EFIAPI -PeCoffLoaderUnloadImage ( - IN EFI_PEI_PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext - ) -/*++ - -Routine Description: - - Unload a PE/COFF image from memory - -Arguments: - - ImageContext - Contains information on image to load into memory - -Returns: - - EFI_SUCCESS - ---*/ -{ - return EFI_SUCCESS; -} diff --git a/Tools/Source/TianoTools/Common/PeiLib/PeiLib.c b/Tools/Source/TianoTools/Common/PeiLib/PeiLib.c deleted file mode 100644 index fec7182908..0000000000 --- a/Tools/Source/TianoTools/Common/PeiLib/PeiLib.c +++ /dev/null @@ -1,169 +0,0 @@ -/*++ - -Copyright (c) 2004, Intel Corporation -All rights reserved. This program and the accompanying materials -are licensed and made available under the terms and conditions of the BSD License -which accompanies this distribution. The full text of the license may be found at -http://opensource.org/licenses/bsd-license.php - -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -Module Name: - - PeiLib.c - -Abstract: - - PEI Library Functions - ---*/ - -#include "TianoCommon.h" -#include "PeiHob.h" -#include "Pei.h" - -VOID -PeiCopyMem ( - IN VOID *Destination, - IN VOID *Source, - IN UINTN Length - ); - -VOID -ZeroMem ( - IN VOID *Buffer, - IN UINTN Size - ) -/*++ - -Routine Description: - - Set Buffer to zero for Size bytes. - -Arguments: - - Buffer - Memory to set. - - Size - Number of bytes to set - -Returns: - - None - ---*/ -{ - INT8 *Ptr; - - Ptr = Buffer; - while (Size--) { - *(Ptr++) = 0; - } -} - -VOID -PeiCopyMem ( - IN VOID *Destination, - IN VOID *Source, - IN UINTN Length - ) -/*++ - -Routine Description: - - Copy Length bytes from Source to Destination. - -Arguments: - - Destination - Target of copy - - Source - Place to copy from - - Length - Number of bytes to copy - -Returns: - - None - ---*/ -{ - CHAR8 *Destination8; - CHAR8 *Source8; - - Destination8 = Destination; - Source8 = Source; - while (Length--) { - *(Destination8++) = *(Source8++); - } -} - -VOID -CopyMem ( - IN VOID *Destination, - IN VOID *Source, - IN UINTN Length - ) -/*++ - -Routine Description: - - Copy Length bytes from Source to Destination. - -Arguments: - - Destination - Target of copy - - Source - Place to copy from - - Length - Number of bytes to copy - -Returns: - - None - ---*/ -{ - CHAR8 *Destination8; - CHAR8 *Source8; - - Destination8 = Destination; - Source8 = Source; - while (Length--) { - *(Destination8++) = *(Source8++); - } -} - -BOOLEAN -CompareGuid ( - IN EFI_GUID *Guid1, - IN EFI_GUID *Guid2 - ) -/*++ - -Routine Description: - - Compares two GUIDs - -Arguments: - - Guid1 - guid to compare - Guid2 - guid to compare - -Returns: - = TRUE if Guid1 == Guid2 - = FALSE if Guid1 != Guid2 - ---*/ -{ - if ((((INT32 *) Guid1)[0] - ((INT32 *) Guid2)[0]) == 0) { - if ((((INT32 *) Guid1)[1] - ((INT32 *) Guid2)[1]) == 0) { - if ((((INT32 *) Guid1)[2] - ((INT32 *) Guid2)[2]) == 0) { - if ((((INT32 *) Guid1)[3] - ((INT32 *) Guid2)[3]) == 0) { - return TRUE; - } - } - } - } - - return FALSE; -} diff --git a/Tools/Source/TianoTools/Common/PeiLib/PeiLib.h b/Tools/Source/TianoTools/Common/PeiLib/PeiLib.h deleted file mode 100644 index 71783ac6bf..0000000000 --- a/Tools/Source/TianoTools/Common/PeiLib/PeiLib.h +++ /dev/null @@ -1,762 +0,0 @@ -/*++ - -Copyright (c) 2004, Intel Corporation -All rights reserved. This program and the accompanying materials -are licensed and made available under the terms and conditions of the BSD License -which accompanies this distribution. The full text of the license may be found at -http://opensource.org/licenses/bsd-license.php - -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -Module Name: - - PeiLib.h - -Abstract: - - PEI Library Functions - ---*/ - -#ifndef _PEI_LIB_H_ -#define _PEI_LIB_H_ - -#include "Tiano.h" -#include "Pei.h" -#include "peiHobLib.h" -#include EFI_PROTOCOL_DEFINITION (Decompress) -#include EFI_PROTOCOL_DEFINITION (TianoDecompress) -#include EFI_GUID_DEFINITION (PeiPeCoffLoader) - -VOID -PeiCopyMem ( - IN VOID *Destination, - IN VOID *Source, - IN UINTN Length - ) -/*++ - -Routine Description: - - Copy Length bytes from Source to Destination. - -Arguments: - - Destination - Target of copy - - Source - Place to copy from - - Length - Number of bytes to copy - -Returns: - - None - ---*/ -; - -VOID -ZeroMem ( - IN VOID *Buffer, - IN UINTN Size - ) -/*++ - -Routine Description: - - Set Buffer to zero for Size bytes. - -Arguments: - - Buffer - Memory to set. - - Size - Number of bytes to set - -Returns: - - None - ---*/ -; - -VOID -CopyMem ( - IN VOID *Destination, - IN VOID *Source, - IN UINTN Length - ) -/*++ - -Routine Description: - - Copy Length bytes from Source to Destination. - -Arguments: - - Destination - Target of copy - - Source - Place to copy from - - Length - Number of bytes to copy - -Returns: - - None - ---*/ -; - -BOOLEAN -CompareGuid ( - IN EFI_GUID *Guid1, - IN EFI_GUID *Guid2 - ) -/*++ - -Routine Description: - - Compares two GUIDs - -Arguments: - - Guid1 - guid to compare - Guid2 - guid to compare - -Returns: - = TRUE if Guid1 == Guid2 - = FALSE if Guid1 != Guid2 - ---*/ -; - -EFI_STATUS -InstallEfiPeiPeCoffLoader ( - IN EFI_PEI_SERVICES **PeiServices, - IN EFI_PEI_PE_COFF_LOADER_PROTOCOL **This, - IN EFI_PEI_PPI_DESCRIPTOR *ThisPpi - ) -/*++ - -Routine Description: - - Install EFI Pei PE coff loader protocol. - -Arguments: - - PeiServices - The PEI core services table. - - This - Pointer to get Pei PE coff loader protocol as output - - ThisPpi - Passed in as EFI_NT_LOAD_AS_DLL_PPI on NT_EMULATOR platform - -Returns: - - EFI_SUCCESS - ---*/ -; - -EFI_STATUS -InstallEfiDecompress ( - EFI_DECOMPRESS_PROTOCOL **This - ) -/*++ - -Routine Description: - - Install EFI decompress protocol. - -Arguments: - - This - Pointer to get decompress protocol as output - -Returns: - - EFI_SUCCESS - EFI decompress protocol successfully installed. - ---*/ -; - -EFI_STATUS -InstallTianoDecompress ( - EFI_TIANO_DECOMPRESS_PROTOCOL **This - ) -/*++ - -Routine Description: - - Install Tiano decompress protocol. - -Arguments: - - This - Pointer to get decompress protocol as output - -Returns: - - EFI_SUCCESS - Tiano decompress protocol successfully installed. - ---*/ -; - -VOID -PeiPerfMeasure ( - EFI_PEI_SERVICES **PeiServices, - IN UINT16 *Token, - IN EFI_FFS_FILE_HEADER *FileHeader, - IN BOOLEAN EntryExit, - IN UINT64 Value - ) -/*++ - -Routine Description: - - Log a timestamp count. - -Arguments: - - PeiServices - Pointer to the PEI Core Services table - - Token - Pointer to Token Name - - FileHeader - Pointer to the file header - - EntryExit - Indicates start or stop measurement - - Value - The start time or the stop time - -Returns: - ---*/ -; - -EFI_STATUS -GetTimerValue ( - OUT UINT64 *TimerValue - ) -/*++ - -Routine Description: - - Get timer value. - -Arguments: - - TimerValue - Pointer to the returned timer value - -Returns: - - EFI_SUCCESS - Successfully got timer value - ---*/ -; - -#ifdef EFI_PEI_PERFORMANCE -#define PEI_PERF_START(Ps, Token, FileHeader, Value) PeiPerfMeasure (Ps, Token, FileHeader, FALSE, Value) -#define PEI_PERF_END(Ps, Token, FileHeader, Value) PeiPerfMeasure (Ps, Token, FileHeader, TRUE, Value) -#else -#define PEI_PERF_START(Ps, Token, FileHeader, Value) -#define PEI_PERF_END(Ps, Token, FileHeader, Value) -#endif - -// -// hob.c -// -EFI_STATUS -PeiBuildHobModule ( - IN EFI_PEI_SERVICES **PeiServices, - IN EFI_GUID *ModuleName, - IN EFI_PHYSICAL_ADDRESS Module, - IN UINT64 ModuleLength, - IN EFI_PHYSICAL_ADDRESS EntryPoint - ) -/*++ - -Routine Description: - - Builds a HOB for a loaded PE32 module - -Arguments: - - PeiServices - The PEI core services table. - ModuleName - The GUID File Name of the module - Memory - The 64 bit physical address of the module - ModuleLength - The length of the module in bytes - EntryPoint - The 64 bit physical address of the entry point - to the module - -Returns: - - EFI_SUCCESS - Hob is successfully built. - Others - Errors occur while creating new Hob - ---*/ -; - -EFI_STATUS -PeiBuildHobResourceDescriptor ( - IN EFI_PEI_SERVICES **PeiServices, - IN EFI_RESOURCE_TYPE ResourceType, - IN EFI_RESOURCE_ATTRIBUTE_TYPE ResourceAttribute, - IN EFI_PHYSICAL_ADDRESS PhysicalStart, - IN UINT64 NumberOfBytes - ) -/*++ - -Routine Description: - - Builds a HOB that describes a chunck of system memory - -Arguments: - - PeiServices - The PEI core services table. - - ResourceType - The type of resource described by this HOB - - ResourceAttribute - The resource attributes of the memory described by this HOB - - PhysicalStart - The 64 bit physical address of memory described by this HOB - - NumberOfBytes - The length of the memoty described by this HOB in bytes - -Returns: - - EFI_SUCCESS - Hob is successfully built. - Others - Errors occur while creating new Hob - ---*/ -; - -EFI_STATUS -PeiBuildHobGuid ( - IN EFI_PEI_SERVICES **PeiServices, - IN EFI_GUID *Guid, - IN UINTN DataLength, - IN OUT VOID **Hob - ) -/*++ - -Routine Description: - - Builds a custom HOB that is tagged with a GUID for identification - -Arguments: - - PeiServices - The PEI core services table. - - Guid - The GUID of the custome HOB type - - DataLength - The size of the data payload for the GUIDed HOB - - Hob - Pointer to the Hob - -Returns: - - EFI_SUCCESS - Hob is successfully built. - Others - Errors occur while creating new Hob - ---*/ -; - -EFI_STATUS -PeiBuildHobGuidData ( - IN EFI_PEI_SERVICES **PeiServices, - IN EFI_GUID *Guid, - IN VOID *Data, - IN UINTN DataLength - ) -/*++ - -Routine Description: - - Builds a custom HOB that is tagged with a GUID for identification - -Arguments: - - PeiServices - The PEI core services table. - - Guid - The GUID of the custome HOB type - - Data - The data to be copied into the GUIDed HOB data field. - - DataLength - The data field length. - -Returns: - - EFI_SUCCESS - Hob is successfully built. - Others - Errors occur while creating new Hob - ---*/ -; - -EFI_STATUS -PeiBuildHobFv ( - IN EFI_PEI_SERVICES **PeiServices, - IN EFI_PHYSICAL_ADDRESS BaseAddress, - IN UINT64 Length - ) -/*++ - -Routine Description: - - Builds a Firmware Volume HOB - -Arguments: - - PeiServices - The PEI core services table. - - BaseAddress - The base address of the Firmware Volume - - Length - The size of the Firmware Volume in bytes - -Returns: - - EFI_SUCCESS - Hob is successfully built. - Others - Errors occur while creating new Hob - ---*/ -; - -EFI_STATUS -PeiBuildHobCpu ( - IN EFI_PEI_SERVICES **PeiServices, - IN UINT8 SizeOfMemorySpace, - IN UINT8 SizeOfIoSpace - ) -/*++ - -Routine Description: - - Builds a HOB for the CPU - -Arguments: - - PeiServices - The PEI core services table. - - SizeOfMemorySpace - Identifies the maximum - physical memory addressibility of the processor. - - SizeOfIoSpace - Identifies the maximum physical I/O addressibility - of the processor. - -Returns: - - EFI_SUCCESS - Hob is successfully built. - Others - Errors occur while creating new Hob - ---*/ -; - -EFI_STATUS -PeiBuildHobStack ( - IN EFI_PEI_SERVICES **PeiServices, - IN EFI_PHYSICAL_ADDRESS BaseAddress, - IN UINT64 Length - ) -/*++ - -Routine Description: - - Builds a HOB for the Stack - -Arguments: - - PeiServices - The PEI core services table. - - BaseAddress - The 64 bit physical address of the Stack - - Length - The length of the stack in bytes - -Returns: - - EFI_SUCCESS - Hob is successfully built. - Others - Errors occur while creating new Hob - ---*/ -; - -EFI_STATUS -PeiBuildHobBspStore ( - IN EFI_PEI_SERVICES **PeiServices, - IN EFI_PHYSICAL_ADDRESS BaseAddress, - IN UINT64 Length, - IN EFI_MEMORY_TYPE MemoryType - ) -/*++ - -Routine Description: - - Builds a HOB for the bsp store - -Arguments: - - PeiServices - The PEI core services table. - - BaseAddress - The 64 bit physical address of the bsp store - - Length - The length of the bsp store in bytes - - MemoryType - Memory type - -Returns: - - EFI_SUCCESS - Hob is successfully built. - Others - Errors occur while creating new Hob - ---*/ -; - -EFI_STATUS -PeiBuildHobMemoryAllocation ( - IN EFI_PEI_SERVICES **PeiServices, - IN EFI_PHYSICAL_ADDRESS BaseAddress, - IN UINT64 Length, - IN EFI_GUID *Name, - IN EFI_MEMORY_TYPE MemoryType - ) -/*++ - -Routine Description: - - Builds a HOB for the memory allocation - -Arguments: - - PeiServices - The PEI core services table. - - BaseAddress - The 64 bit physical address of the memory - - Length - The length of the memory allocation in bytes - - Name - Name for Hob - - MemoryType - Memory type - -Returns: - - EFI_SUCCESS - Hob is successfully built. - Others - Errors occur while creating new Hob - ---*/ -; - -// -// print.c -// -UINTN -AvSPrint ( - OUT CHAR8 *StartOfBuffer, - IN UINTN StrSize, - IN CONST CHAR8 *Format, - IN VA_LIST Marker - ) -/*++ - -Routine Description: - - AvSPrint function to process format and place the results in Buffer. Since a - VA_LIST is used this rountine allows the nesting of Vararg routines. Thus - this is the main print working routine - -Arguments: - - StartOfBuffer - Ascii buffer to print the results of the parsing of Format into. - - StrSize - Maximum number of characters to put into buffer. Zero means - no limit. - - FormatString - Ascii format string see file header for more details. - - Marker - Vararg list consumed by processing Format. - -Returns: - - Number of characters printed. - ---*/ -; - -UINTN -ASPrint ( - OUT CHAR8 *Buffer, - IN UINTN BufferSize, - IN CONST CHAR8 *Format, - ... - ) -/*++ - -Routine Description: - - ASPrint function to process format and place the results in Buffer. - -Arguments: - - Buffer - Ascii buffer to print the results of the parsing of Format into. - - BufferSize - Maximum number of characters to put into buffer. Zero means no - limit. - - Format - Ascii format string see file header for more details. - - ... - Vararg list consumed by processing Format. - -Returns: - - Number of characters printed. - ---*/ -; - -// -// math.c -// -UINT64 -MultU64x32 ( - IN UINT64 Multiplicand, - IN UINTN Multiplier - ) -/*++ - -Routine Description: - - This routine allows a 64 bit value to be multiplied with a 32 bit - value returns 64bit result. - No checking if the result is greater than 64bits - -Arguments: - - Multiplicand - multiplicand - Multiplier - multiplier - -Returns: - - Multiplicand * Multiplier - ---*/ -; - -UINT64 -DivU64x32 ( - IN UINT64 Dividend, - IN UINTN Divisor, - OUT UINTN *Remainder OPTIONAL - ) -/*++ - -Routine Description: - - This routine allows a 64 bit value to be divided with a 32 bit value returns - 64bit result and the Remainder. - N.B. only works for 31bit divisors!! - -Arguments: - - Dividend - dividend - Divisor - divisor - Remainder - buffer for remainder - -Returns: - - Dividend / Divisor - Remainder = Dividend mod Divisor - ---*/ -; - -UINT64 -RShiftU64 ( - IN UINT64 Operand, - IN UINTN Count - ) -/*++ - -Routine Description: - - This routine allows a 64 bit value to be right shifted by 32 bits and returns the - shifted value. - Count is valid up 63. (Only Bits 0-5 is valid for Count) - -Arguments: - - Operand - Value to be shifted - Count - Number of times to shift right. - -Returns: - - Value shifted right identified by the Count. - ---*/ -; - -UINT64 -LShiftU64 ( - IN UINT64 Operand, - IN UINTN Count - ) -/*++ - -Routine Description: - - This routine allows a 64 bit value to be left shifted by 32 bits and - returns the shifted value. - Count is valid up 63. (Only Bits 0-5 is valid for Count) - -Arguments: - - Operand - Value to be shifted - Count - Number of times to shift left. - -Returns: - - Value shifted left identified by the Count. - ---*/ -; - -VOID -RegisterNativeCpuIo ( - IN EFI_PEI_SERVICES **PeiServices, - IN VOID *CpuIo - ) -/*++ - -Routine Description: - - Register a native Cpu IO - -Arguments: - - PeiServices - Calling context - CpuIo - CpuIo instance to register - -Returns: - - None - ---*/ -; - -VOID -GetNativeCpuIo ( - IN EFI_PEI_SERVICES **PeiServices, - OUT VOID **CpuIo - ) -/*++ - -Routine Description: - - Get registered Cpu IO. - -Arguments: - - PeiServices - Calling context - CpuIo - CpuIo instance registered before - -Returns: - - None - ---*/ -; - -#endif diff --git a/Tools/Source/TianoTools/Common/PeiLib/Perf.c b/Tools/Source/TianoTools/Common/PeiLib/Perf.c deleted file mode 100644 index cfc265ee66..0000000000 --- a/Tools/Source/TianoTools/Common/PeiLib/Perf.c +++ /dev/null @@ -1,233 +0,0 @@ -/*++ - -Copyright (c) 2004 - 2005, Intel Corporation -All rights reserved. This program and the accompanying materials -are licensed and made available under the terms and conditions of the BSD License -which accompanies this distribution. The full text of the license may be found at -http://opensource.org/licenses/bsd-license.php - -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -Module Name: - - Perf.c - -Abstract: - - Support for performance primitives. - ---*/ - -#include "Tiano.h" -#include "Pei.h" -#include "PeiLib.h" -#include "PeiHob.h" - -#include EFI_GUID_DEFINITION (PeiPerformanceHob) - -// -// Perfomance HOB data definitions -// - -#define MAX_PEI_PERF_LOG_ENTRIES 28 - -// -// Prototype functions -// -EFI_STATUS -GetTimerValue ( - OUT UINT64 *TimerValue - ); - - -VOID -PeiPerfMeasure ( - EFI_PEI_SERVICES **PeiServices, - IN UINT16 *Token, - IN EFI_FFS_FILE_HEADER *FileHeader, - IN BOOLEAN EntryExit, - IN UINT64 Value - ) -/*++ - -Routine Description: - - Log a timestamp count. - -Arguments: - - PeiServices - Pointer to the PEI Core Services table - - Token - Pointer to Token Name - - FileHeader - Pointer to the file header - - EntryExit - Indicates start or stop measurement - - Value - The start time or the stop time - -Returns: - ---*/ -{ - EFI_STATUS Status; - EFI_HOB_GUID_TYPE *Hob; - EFI_HOB_GUID_DATA_PERFORMANCE_LOG *PerfHobData; - PEI_PERFORMANCE_MEASURE_LOG_ENTRY *Log; - EFI_PEI_PPI_DESCRIPTOR *PerfHobDescriptor; - UINT64 TimeCount; - INTN Index; - UINTN Index2; - EFI_GUID *Guid; - EFI_GUID *CheckGuid; - - TimeCount = 0; - // - // Get the END time as early as possible to make it more accurate. - // - if (EntryExit) { - GetTimerValue (&TimeCount); - } - - // - // Locate the Pei Performance Log Hob. - // - Status = (*PeiServices)->LocatePpi ( - PeiServices, - &gEfiPeiPerformanceHobGuid, - 0, - &PerfHobDescriptor, - NULL - ); - - // - // If the Performance Hob was not found, build and install one. - // - if (EFI_ERROR(Status)) { - Status = PeiBuildHobGuid ( - PeiServices, - &gEfiPeiPerformanceHobGuid, - (sizeof(EFI_HOB_GUID_DATA_PERFORMANCE_LOG) + - ((MAX_PEI_PERF_LOG_ENTRIES-1) * - sizeof(PEI_PERFORMANCE_MEASURE_LOG_ENTRY)) + - sizeof(EFI_PEI_PPI_DESCRIPTOR) - ), - &Hob - ); - ASSERT_PEI_ERROR(PeiServices, Status); - - PerfHobData = (EFI_HOB_GUID_DATA_PERFORMANCE_LOG *)(Hob+1); - PerfHobData->NumberOfEntries = 0; - - PerfHobDescriptor = (EFI_PEI_PPI_DESCRIPTOR *)((UINT8 *)(PerfHobData+1) + - (sizeof(PEI_PERFORMANCE_MEASURE_LOG_ENTRY) * - (MAX_PEI_PERF_LOG_ENTRIES-1) - ) - ); - PerfHobDescriptor->Flags = (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST); - PerfHobDescriptor->Guid = &gEfiPeiPerformanceHobGuid; - PerfHobDescriptor->Ppi = NULL; - - (*PeiServices)->InstallPpi ( - PeiServices, - PerfHobDescriptor - ); - } - - PerfHobData = (EFI_HOB_GUID_DATA_PERFORMANCE_LOG *)(((UINT8 *)(PerfHobDescriptor)) - - ((sizeof(PEI_PERFORMANCE_MEASURE_LOG_ENTRY) * - (MAX_PEI_PERF_LOG_ENTRIES-1) - ) - + sizeof(EFI_HOB_GUID_DATA_PERFORMANCE_LOG) - ) - ); - - if (PerfHobData->NumberOfEntries >= MAX_PEI_PERF_LOG_ENTRIES) { - return; - } - - if (!EntryExit) { - Log = &(PerfHobData->Log[PerfHobData->NumberOfEntries]); - (*PeiServices)->SetMem (Log, sizeof(PEI_PERFORMANCE_MEASURE_LOG_ENTRY), 0); - - // - // If not NULL pointer, copy the file name - // - if (FileHeader != NULL) { - Log->Name = FileHeader->Name; - } - - // - // Copy the description string - // - (*PeiServices)->CopyMem ( - &(Log->DescriptionString), - Token, - (PEI_PERF_MAX_DESC_STRING-1) * sizeof(UINT16) - ); - - // - // Get the start time as late as possible to make it more accurate. - // - GetTimerValue (&TimeCount); - - // - // Record the time stamp. - // - if (Value != 0) { - Log->StartTimeCount = Value; - } else { - Log->StartTimeCount = TimeCount; - } - Log->StopTimeCount = 0; - - // - // Increment the number of valid log entries. - // - PerfHobData->NumberOfEntries++; - - } else { - - for (Index = PerfHobData->NumberOfEntries-1; Index >= 0; Index--) { - Log = NULL; - for (Index2 = 0; Index2 < PEI_PERF_MAX_DESC_STRING; Index2++) { - if (PerfHobData->Log[Index].DescriptionString[Index2] == 0) { - Log = &(PerfHobData->Log[Index]); - break; - } - if (PerfHobData->Log[Index].DescriptionString[Index2] != - Token[Index2]) { - break; - } - } - if (Log != NULL) { - if (FileHeader != NULL) { - Guid = &(Log->Name); - CheckGuid = &(FileHeader->Name); - if ((((INT32 *)Guid)[0] == ((INT32 *)CheckGuid)[0]) && - (((INT32 *)Guid)[1] == ((INT32 *)CheckGuid)[1]) && - (((INT32 *)Guid)[2] == ((INT32 *)CheckGuid)[2]) && - (((INT32 *)Guid)[3] == ((INT32 *)CheckGuid)[3])) { - if (Value != 0) { - Log->StopTimeCount = Value; - } else { - Log->StopTimeCount = TimeCount; - } - break; - } - } else { - if (Value != 0) { - Log->StopTimeCount = Value; - } else { - Log->StopTimeCount = TimeCount; - } - break; - } - } - } - - } - - return; -} diff --git a/Tools/Source/TianoTools/Common/PeiLib/Print/Print.c b/Tools/Source/TianoTools/Common/PeiLib/Print/Print.c deleted file mode 100644 index 13e7d33ae0..0000000000 --- a/Tools/Source/TianoTools/Common/PeiLib/Print/Print.c +++ /dev/null @@ -1,736 +0,0 @@ -/*++ - -Copyright (c) 2004, Intel Corporation -All rights reserved. This program and the accompanying materials -are licensed and made available under the terms and conditions of the BSD License -which accompanies this distribution. The full text of the license may be found at -http://opensource.org/licenses/bsd-license.php - -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -Module Name: - - Print.c - -Abstract: - - Basic Ascii AvSPrintf() function named AvSPrint(). AvSPrint() enables very - simple implemenation of debug prints. - - You can not Print more than PEI_LIB_MAX_PRINT_BUFFER characters at a - time. This makes the implementation very simple. - - AvSPrint format specification has the follwoing form - - %[flags][width]type - - flags: - '-' - Left justify - '+' - Prefix a sign - ' ' - Prefix a blank - ',' - Place commas in numberss - '0' - Prefix for width with zeros - 'l' - UINT64 - 'L' - UINT64 - - width: - '*' - Get width from a UINTN argumnet from the argument list - Decimal number that represents width of print - - type: - 'X' - argument is a UINTN hex number, prefix '0' - 'x' - argument is a hex number - 'd' - argument is a decimal number - 'a' - argument is an ascii string - 'S', 's' - argument is an Unicode string - 'g' - argument is a pointer to an EFI_GUID - 't' - argument is a pointer to an EFI_TIME structure - 'c' - argument is an ascii character - 'r' - argument is EFI_STATUS - '%' - Print a % - ---*/ - -#include "Tiano.h" -#include "Pei.h" -#include "PeiLib.h" -#include "Print.h" - - -STATIC -CHAR8 * -GetFlagsAndWidth ( - IN CHAR8 *Format, - OUT UINTN *Flags, - OUT UINTN *Width, - IN OUT VA_LIST *Marker - ); - -STATIC -UINTN -ValueToString ( - IN OUT CHAR8 *Buffer, - IN INT64 Value, - IN UINTN Flags, - IN UINTN Width - ); - -STATIC -UINTN -ValueTomHexStr ( - IN OUT CHAR8 *Buffer, - IN UINT64 Value, - IN UINTN Flags, - IN UINTN Width - ); - -STATIC -UINTN -GuidToString ( - IN EFI_GUID *Guid, - IN OUT CHAR8 *Buffer, - IN UINTN BufferSize - ); - -STATIC -UINTN -TimeToString ( - IN EFI_TIME *Time, - IN OUT CHAR8 *Buffer, - IN UINTN BufferSize - ); - -STATIC -UINTN -EfiStatusToString ( - IN EFI_STATUS Status, - OUT CHAR8 *Buffer, - IN UINTN BufferSize - ); - - -UINTN -ASPrint ( - OUT CHAR8 *Buffer, - IN UINTN BufferSize, - IN CONST CHAR8 *Format, - ... - ) -/*++ - -Routine Description: - - ASPrint function to process format and place the results in Buffer. - -Arguments: - - Buffer - Ascii buffer to print the results of the parsing of Format into. - - BufferSize - Maximum number of characters to put into buffer. Zero means no - limit. - - Format - Ascii format string see file header for more details. - - ... - Vararg list consumed by processing Format. - -Returns: - - Number of characters printed. - ---*/ -{ - UINTN Return; - VA_LIST Marker; - - VA_START(Marker, Format); - Return = AvSPrint(Buffer, BufferSize, Format, Marker); - VA_END (Marker); - - return Return; -} - - -UINTN -AvSPrint ( - OUT CHAR8 *StartOfBuffer, - IN UINTN BufferSize, - IN CONST CHAR8 *FormatString, - IN VA_LIST Marker - ) -/*++ - -Routine Description: - - AvSPrint function to process format and place the results in Buffer. Since a - VA_LIST is used this rountine allows the nesting of Vararg routines. Thus - this is the main print working routine - -Arguments: - - StartOfBuffer - Ascii buffer to print the results of the parsing of Format into. - - BufferSize - Maximum number of characters to put into buffer. Zero means - no limit. - - FormatString - Ascii format string see file header for more details. - - Marker - Vararg list consumed by processing Format. - -Returns: - - Number of characters printed. - ---*/ -{ - CHAR8 *Buffer; - CHAR8 *AsciiStr; - CHAR16 *UnicodeStr; - CHAR8 *Format; - UINTN Index; - UINTN Flags; - UINTN Width; - UINT64 Value; - - // - // Process the format string. Stop if Buffer is over run. - // - - Buffer = StartOfBuffer; - Format = (CHAR8 *)FormatString; - for (Index = 0; (*Format != '\0') && (Index < BufferSize); Format++) { - if (*Format != '%') { - if (*Format == '\n') { - // - // If carage return add line feed - // - Buffer[Index++] = '\r'; - } - Buffer[Index++] = *Format; - } else { - - // - // Now it's time to parse what follows after % - // - Format = GetFlagsAndWidth (Format, &Flags, &Width, &Marker); - switch (*Format) { - case 'X': - Flags |= PREFIX_ZERO; - Width = sizeof (UINT64) * 2; - // - // break skiped on purpose - // - case 'x': - if ((Flags & LONG_TYPE) == LONG_TYPE) { - Value = VA_ARG (Marker, UINT64); - } else { - Value = VA_ARG (Marker, UINTN); - } - Index += ValueTomHexStr (&Buffer[Index], Value, Flags, Width); - break; - - case 'd': - if ((Flags & LONG_TYPE) == LONG_TYPE) { - Value = VA_ARG (Marker, UINT64); - } else { - Value = (UINTN)VA_ARG (Marker, UINTN); - } - Index += ValueToString (&Buffer[Index], Value, Flags, Width); - break; - - case 's': - case 'S': - UnicodeStr = (CHAR16 *)VA_ARG (Marker, CHAR16 *); - if (UnicodeStr == NULL) { - UnicodeStr = L""; - } - for ( ;*UnicodeStr != '\0'; UnicodeStr++) { - Buffer[Index++] = (CHAR8)*UnicodeStr; - } - break; - - case 'a': - AsciiStr = (CHAR8 *)VA_ARG (Marker, CHAR8 *); - if (AsciiStr == NULL) { - AsciiStr = ""; - } - while (*AsciiStr != '\0') { - Buffer[Index++] = *AsciiStr++; - } - break; - - case 'c': - Buffer[Index++] = (CHAR8)VA_ARG (Marker, UINTN); - break; - - case 'g': - Index += GuidToString ( - VA_ARG (Marker, EFI_GUID *), - &Buffer[Index], - BufferSize - ); - break; - - case 't': - Index += TimeToString ( - VA_ARG (Marker, EFI_TIME *), - &Buffer[Index], - BufferSize - ); - break; - - case 'r': - Index += EfiStatusToString ( - VA_ARG (Marker, EFI_STATUS), - &Buffer[Index], - BufferSize - ); - break; - - case '%': - Buffer[Index++] = *Format; - break; - - default: - // - // if the type is unknown print it to the screen - // - Buffer[Index++] = *Format; - } - - } - } - Buffer[Index++] = '\0'; - - return &Buffer[Index] - StartOfBuffer; -} - - - -STATIC -CHAR8 * -GetFlagsAndWidth ( - IN CHAR8 *Format, - OUT UINTN *Flags, - OUT UINTN *Width, - IN OUT VA_LIST *Marker - ) -/*++ - -Routine Description: - - AvSPrint worker function that parses flag and width information from the - Format string and returns the next index into the Format string that needs - to be parsed. See file headed for details of Flag and Width. - -Arguments: - - Format - Current location in the AvSPrint format string. - - Flags - Returns flags - - Width - Returns width of element - - Marker - Vararg list that may be paritally consumed and returned. - -Returns: - - Pointer indexed into the Format string for all the information parsed - by this routine. - ---*/ -{ - UINTN Count; - BOOLEAN Done; - - *Flags = 0; - *Width = 0; - for (Done = FALSE; !Done; ) { - Format++; - - switch (*Format) { - - case '-': *Flags |= LEFT_JUSTIFY; break; - case '+': *Flags |= PREFIX_SIGN; break; - case ' ': *Flags |= PREFIX_BLANK; break; - case ',': *Flags |= COMMA_TYPE; break; - case 'L': - case 'l': *Flags |= LONG_TYPE; break; - - case '*': - *Width = VA_ARG (*Marker, UINTN); - break; - - case '0': - *Flags |= PREFIX_ZERO; - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - Count = 0; - do { - Count = (Count * 10) + *Format - '0'; - Format++; - } while ((*Format >= '0') && (*Format <= '9')); - Format--; - *Width = Count; - break; - - default: - Done = TRUE; - } - } - return Format; -} - -static CHAR8 mHexStr[] = { '0','1','2','3','4','5','6','7', - '8','9','A','B','C','D','E','F' }; - -STATIC -UINTN -ValueTomHexStr ( - IN OUT CHAR8 *Buffer, - IN UINT64 Value, - IN UINTN Flags, - IN UINTN Width - ) -/*++ - -Routine Description: - - AvSPrint worker function that prints a Value as a hex number in Buffer - -Arguments: - - Buffer - Location to place ascii hex string of Value. - - Value - Hex value to convert to a string in Buffer. - - Flags - Flags to use in printing Hex string, see file header for details. - - Width - Width of hex value. - -Returns: - - Number of characters printed. - ---*/ -{ - CHAR8 TempBuffer[30]; - CHAR8 *TempStr; - CHAR8 Prefix; - CHAR8 *BufferPtr; - UINTN Count; - UINTN Index; - - TempStr = TempBuffer; - BufferPtr = Buffer; - - // - // Count starts at one since we will null terminate. Each iteration of the - // loop picks off one nibble. Oh yea TempStr ends up backwards - // - Count = 0; - do { - *(TempStr++) = mHexStr[Value & 0x0f]; - Value = RShiftU64 (Value, 4); - Count++; - } while (Value != 0); - - if (Flags & PREFIX_ZERO) { - Prefix = '0'; - } else if (!(Flags & LEFT_JUSTIFY)) { - Prefix = ' '; - } else { - Prefix = 0x00; - } - for (Index = Count; Index < Width; Index++) { - *(TempStr++) = Prefix; - } - - // - // Reverse temp string into Buffer. - // - while (TempStr != TempBuffer) { - *(BufferPtr++) = *(--TempStr); - } - - *BufferPtr = 0; - return Index; -} - -STATIC -UINTN -ValueToString ( - IN OUT CHAR8 *Buffer, - IN INT64 Value, - IN UINTN Flags, - IN UINTN Width - ) -/*++ - -Routine Description: - - AvSPrint worker function that prints a Value as a decimal number in Buffer - -Arguments: - - Buffer - Location to place ascii decimal number string of Value. - - Value - Decimal value to convert to a string in Buffer. - - Flags - Flags to use in printing decimal string, see file header for details. - - Width - Width of hex value. - -Returns: - - Number of characters printed. - ---*/ -{ - CHAR8 TempBuffer[30]; - CHAR8 *TempStr; - CHAR8 *BufferPtr; - UINTN Count; - UINTN Remainder; - - TempStr = TempBuffer; - BufferPtr = Buffer; - Count = 0; - - if (Value < 0) { - *(BufferPtr++) = '-'; - Value = -Value; - Count++; - } - - do { - Value = (INT64)DivU64x32 ((UINT64)Value, 10, &Remainder); - *(TempStr++) = (CHAR8)(Remainder + '0'); - Count++; - if ((Flags & COMMA_TYPE) == COMMA_TYPE) { - if (Count % 3 == 0) { - *(TempStr++) = ','; - } - } - } while (Value != 0); - - // - // Reverse temp string into Buffer. - // - while (TempStr != TempBuffer) { - *(BufferPtr++) = *(--TempStr); - } - - *BufferPtr = 0; - return Count; -} - -STATIC -UINTN -GuidToString ( - IN EFI_GUID *Guid, - IN CHAR8 *Buffer, - IN UINTN BufferSize - ) -/*++ - -Routine Description: - - AvSPrint worker function that prints an EFI_GUID. - -Arguments: - - Guid - Pointer to GUID to print. - - Buffer - Buffe to print Guid into. - - BufferSize - Size of Buffer. - -Returns: - - Number of characters printed. - ---*/ -{ - UINTN Size; - - Size = ASPrint ( - Buffer, - BufferSize, - "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x", - Guid->Data1, - Guid->Data2, - Guid->Data3, - Guid->Data4[0], - Guid->Data4[1], - Guid->Data4[2], - Guid->Data4[3], - Guid->Data4[4], - Guid->Data4[5], - Guid->Data4[6], - Guid->Data4[7] - ); - - // - // ASPrint will null terminate the string. The -1 skips the null - // - return Size - 1; -} - - -STATIC -UINTN -TimeToString ( - IN EFI_TIME *Time, - OUT CHAR8 *Buffer, - IN UINTN BufferSize - ) -/*++ - -Routine Description: - - AvSPrint worker function that prints EFI_TIME. - -Arguments: - - Time - Pointer to EFI_TIME sturcture to print. - - Buffer - Buffer to print Time into. - - BufferSize - Size of Buffer. - -Returns: - - Number of characters printed. - ---*/ -{ - UINTN Size; - - Size = ASPrint ( - Buffer, - BufferSize, - "%02d/%02d/%04d %02d:%02d", - Time->Month, - Time->Day, - Time->Year, - Time->Hour, - Time->Minute - ); - - // - // ASPrint will null terminate the string. The -1 skips the null - // - return Size - 1; -} - -STATIC -UINTN -EfiStatusToString ( - IN EFI_STATUS Status, - OUT CHAR8 *Buffer, - IN UINTN BufferSize - ) -/*++ - -Routine Description: - - AvSPrint worker function that prints EFI_STATUS as a string. If string is - not known a hex value will be printed. - -Arguments: - - Status - EFI_STATUS sturcture to print. - - Buffer - Buffer to print EFI_STATUS message string into. - - BufferSize - Size of Buffer. - -Returns: - - Number of characters printed. - ---*/ -{ - UINTN Size; - CHAR8 *Desc; - - if (Status == EFI_SUCCESS) { - Desc = "Success"; - } else if (Status == EFI_LOAD_ERROR) { - Desc = "Load Error"; - } else if (Status == EFI_INVALID_PARAMETER) { - Desc = "Invalid Parameter"; - } else if (Status == EFI_UNSUPPORTED) { - Desc = "Unsupported"; - } else if (Status == EFI_BAD_BUFFER_SIZE) { - Desc = "Bad Buffer Size"; - } else if (Status == EFI_BUFFER_TOO_SMALL) { - Desc = "Buffer Too Small"; - } else if (Status == EFI_NOT_READY) { - Desc = "Not Ready"; - } else if (Status == EFI_DEVICE_ERROR) { - Desc = "Device Error"; - } else if (Status == EFI_WRITE_PROTECTED) { - Desc = "Write Protected"; - } else if (Status == EFI_OUT_OF_RESOURCES) { - Desc = "Out of Resources"; - } else if (Status == EFI_VOLUME_CORRUPTED) { - Desc = "Volume Corrupt"; - } else if (Status == EFI_VOLUME_FULL) { - Desc = "Volume Full"; - } else if (Status == EFI_NO_MEDIA) { - Desc = "No Media"; - } else if (Status == EFI_MEDIA_CHANGED) { - Desc = "Media changed"; - } else if (Status == EFI_NOT_FOUND) { - Desc = "Not Found"; - } else if (Status == EFI_ACCESS_DENIED) { - Desc = "Access Denied"; - } else if (Status == EFI_NO_RESPONSE) { - Desc = "No Response"; - } else if (Status == EFI_NO_MAPPING) { - Desc = "No mapping"; - } else if (Status == EFI_TIMEOUT) { - Desc = "Time out"; - } else if (Status == EFI_NOT_STARTED) { - Desc = "Not started"; - } else if (Status == EFI_ALREADY_STARTED) { - Desc = "Already started"; - } else if (Status == EFI_ABORTED) { - Desc = "Aborted"; - } else if (Status == EFI_ICMP_ERROR) { - Desc = "ICMP Error"; - } else if (Status == EFI_TFTP_ERROR) { - Desc = "TFTP Error"; - } else if (Status == EFI_PROTOCOL_ERROR) { - Desc = "Protocol Error"; - } else if (Status == EFI_WARN_UNKNOWN_GLYPH) { - Desc = "Warning Unknown Glyph"; - } else if (Status == EFI_WARN_DELETE_FAILURE) { - Desc = "Warning Delete Failure"; - } else if (Status == EFI_WARN_WRITE_FAILURE) { - Desc = "Warning Write Failure"; - } else if (Status == EFI_WARN_BUFFER_TOO_SMALL) { - Desc = "Warning Buffer Too Small"; - } else { - Desc = NULL; - } - // - // If we found a match, copy the message to the user's buffer. Otherwise - // sprint the hex status code to their buffer. - // - if (Desc != NULL) { - Size = ASPrint (Buffer, BufferSize, "%a", Desc); - } else { - Size = ASPrint (Buffer, BufferSize, "%X", Status); - } - return Size - 1; -} diff --git a/Tools/Source/TianoTools/Common/PeiLib/Print/Print.h b/Tools/Source/TianoTools/Common/PeiLib/Print/Print.h deleted file mode 100644 index 18c1834b81..0000000000 --- a/Tools/Source/TianoTools/Common/PeiLib/Print/Print.h +++ /dev/null @@ -1,37 +0,0 @@ -/*++ - -Copyright (c) 2004, Intel Corporation -All rights reserved. This program and the accompanying materials -are licensed and made available under the terms and conditions of the BSD License -which accompanies this distribution. The full text of the license may be found at -http://opensource.org/licenses/bsd-license.php - -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -Module Name: - - Print.h - -Abstract: - - Private data for Print.c - ---*/ - -#ifndef _PRINT_H_ -#define _PRINT_H_ - -#define LEFT_JUSTIFY 0x01 -#define PREFIX_SIGN 0x02 -#define PREFIX_BLANK 0x04 -#define COMMA_TYPE 0x08 -#define LONG_TYPE 0x10 -#define PREFIX_ZERO 0x20 - -// -// Largest number of characters that can be printed out. -// -#define PEI_LIB_MAX_PRINT_BUFFER (80 * 4) - -#endif diff --git a/Tools/Source/TianoTools/Common/PeiLib/ia32/PeCoffLoaderEx.c b/Tools/Source/TianoTools/Common/PeiLib/ia32/PeCoffLoaderEx.c deleted file mode 100644 index 6e40bf8ddf..0000000000 --- a/Tools/Source/TianoTools/Common/PeiLib/ia32/PeCoffLoaderEx.c +++ /dev/null @@ -1,56 +0,0 @@ -/*++ - -Copyright (c) 2004, Intel Corporation -All rights reserved. This program and the accompanying materials -are licensed and made available under the terms and conditions of the BSD License -which accompanies this distribution. The full text of the license may be found at -http://opensource.org/licenses/bsd-license.php - -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -Module Name: - - PeCoffLoaderEx.c - -Abstract: - - IA-32 Specific relocation fixups - -Revision History - ---*/ - -#include "TianoCommon.h" - -EFI_STATUS -PeCoffLoaderRelocateImageEx ( - IN UINT16 *Reloc, - IN OUT CHAR8 *Fixup, - IN OUT CHAR8 **FixupData, - IN UINT64 Adjust - ) -/*++ - -Routine Description: - - Performs an IA-32 specific relocation fixup - -Arguments: - - Reloc - Pointer to the relocation record - - Fixup - Pointer to the address to fix up - - FixupData - Pointer to a buffer to log the fixups - - Adjust - The offset to adjust the fixup - -Returns: - - EFI_UNSUPPORTED - Unsupported now - ---*/ -{ - return EFI_UNSUPPORTED; -} diff --git a/Tools/Source/TianoTools/Common/PeiLib/ia32/PeCoffLoaderEx.h b/Tools/Source/TianoTools/Common/PeiLib/ia32/PeCoffLoaderEx.h deleted file mode 100644 index e0f1e22598..0000000000 --- a/Tools/Source/TianoTools/Common/PeiLib/ia32/PeCoffLoaderEx.h +++ /dev/null @@ -1,65 +0,0 @@ -/*++ - -Copyright (c) 2004, Intel Corporation -All rights reserved. This program and the accompanying materials -are licensed and made available under the terms and conditions of the BSD License -which accompanies this distribution. The full text of the license may be found at -http://opensource.org/licenses/bsd-license.php - -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -Module Name: - - PeCoffLoaderEx.h - -Abstract: - - IA-32 Specific relocation fixups - -Revision History - ---*/ - -#ifndef _PE_COFF_LOADER_EX_H_ -#define _PE_COFF_LOADER_EX_H_ - -// -// Define macro to determine if the machine type is supported. -// Returns 0 if the machine is not supported, Not 0 otherwise. -// -#define EFI_IMAGE_MACHINE_TYPE_SUPPORTED(Machine) \ - ((Machine) == EFI_IMAGE_MACHINE_IA32 || \ - (Machine) == EFI_IMAGE_MACHINE_EBC) - -EFI_STATUS -PeCoffLoaderRelocateImageEx ( - IN UINT16 *Reloc, - IN OUT CHAR8 *Fixup, - IN OUT CHAR8 **FixupData, - IN UINT64 Adjust - ) -/*++ - -Routine Description: - - Performs an IA-32 specific relocation fixup - -Arguments: - - Reloc - Pointer to the relocation record - - Fixup - Pointer to the address to fix up - - FixupData - Pointer to a buffer to log the fixups - - Adjust - The offset to adjust the fixup - -Returns: - - EFI_UNSUPPORTED - Unsupported now - ---*/ -; - -#endif diff --git a/Tools/Source/TianoTools/Common/PeiLib/ia32/PerformancePrimitives.c b/Tools/Source/TianoTools/Common/PeiLib/ia32/PerformancePrimitives.c deleted file mode 100644 index 4efec656ae..0000000000 --- a/Tools/Source/TianoTools/Common/PeiLib/ia32/PerformancePrimitives.c +++ /dev/null @@ -1,47 +0,0 @@ -/*++ - -Copyright (c) 2004, Intel Corporation -All rights reserved. This program and the accompanying materials -are licensed and made available under the terms and conditions of the BSD License -which accompanies this distribution. The full text of the license may be found at -http://opensource.org/licenses/bsd-license.php - -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -Module Name: - - PerformancePrimitives.c - -Abstract: - - Support for Performance library - ---*/ - -#include "TianoCommon.h" -#include "CpuIA32.h" - -EFI_STATUS -GetTimerValue ( - OUT UINT64 *TimerValue - ) -/*++ - -Routine Description: - - Get timer value. - -Arguments: - - TimerValue - Pointer to the returned timer value - -Returns: - - EFI_SUCCESS - Successfully got timer value - ---*/ -{ - *TimerValue = EfiReadTsc (); - return EFI_SUCCESS; -} diff --git a/Tools/Source/TianoTools/Common/PeiLib/ia32/Processor.c b/Tools/Source/TianoTools/Common/PeiLib/ia32/Processor.c deleted file mode 100644 index 4010db25a2..0000000000 --- a/Tools/Source/TianoTools/Common/PeiLib/ia32/Processor.c +++ /dev/null @@ -1,140 +0,0 @@ -/*++ - -Copyright (c) 2004 - 2005, Intel Corporation -All rights reserved. This program and the accompanying materials -are licensed and made available under the terms and conditions of the BSD License -which accompanies this distribution. The full text of the license may be found at -http://opensource.org/licenses/bsd-license.php - -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -Module Name: - - Processor.c - -Abstract: - ---*/ - -#include "Tiano.h" -#include "EfiJump.h" -#include EFI_GUID_DEFINITION (PeiFlushInstructionCache) -#include EFI_GUID_DEFINITION (PeiTransferControl) - -// -// Prototypes -// -EFI_STATUS -EFIAPI -TransferControlSetJump ( - IN EFI_PEI_TRANSFER_CONTROL_PROTOCOL *This, - IN EFI_JUMP_BUFFER *Jump - ); - -EFI_STATUS -EFIAPI -TransferControlLongJump ( - IN EFI_PEI_TRANSFER_CONTROL_PROTOCOL *This, - IN EFI_JUMP_BUFFER *Jump - ); - -EFI_STATUS -EFIAPI -FlushInstructionCacheFlush ( - IN EFI_PEI_FLUSH_INSTRUCTION_CACHE_PROTOCOL *This, - IN EFI_PHYSICAL_ADDRESS Start, - IN UINT64 Length - ); - -// -// Table declarations -// -EFI_PEI_TRANSFER_CONTROL_PROTOCOL mTransferControl = { - TransferControlSetJump, - TransferControlLongJump, - sizeof (EFI_JUMP_BUFFER) -}; - -EFI_PEI_FLUSH_INSTRUCTION_CACHE_PROTOCOL mFlushInstructionCache = { - FlushInstructionCacheFlush -}; - - -EFI_STATUS -InstallEfiPeiTransferControl ( - IN OUT EFI_PEI_TRANSFER_CONTROL_PROTOCOL **This - ) -/*++ - -Routine Description: - - Installs the pointer to the transfer control mechanism - -Arguments: - - This - Pointer to transfer control mechanism. - -Returns: - - EFI_SUCCESS - Successfully installed. - ---*/ -{ - *This = &mTransferControl; - return EFI_SUCCESS; -} - -EFI_STATUS -InstallEfiPeiFlushInstructionCache ( - IN OUT EFI_PEI_FLUSH_INSTRUCTION_CACHE_PROTOCOL **This - ) -/*++ - -Routine Description: - - Installs the pointer to the flush instruction cache mechanism - -Arguments: - - This - Pointer to flush instruction cache mechanism. - -Returns: - - EFI_SUCCESS - Successfully installed - ---*/ -{ - *This = &mFlushInstructionCache; - return EFI_SUCCESS; -} - -EFI_STATUS -EFIAPI -FlushInstructionCacheFlush ( - IN EFI_PEI_FLUSH_INSTRUCTION_CACHE_PROTOCOL *This, - IN EFI_PHYSICAL_ADDRESS Start, - IN UINT64 Length - ) -/*++ - -Routine Description: - - This routine would provide support for flushing the CPU instruction cache. - In the case of IA32, this flushing is not necessary and is thus not implemented. - -Arguments: - - This - Pointer to CPU Architectural Protocol interface - Start - Start adddress in memory to flush - Length - Length of memory to flush - -Returns: - - Status - EFI_SUCCESS - ---*/ -{ - return EFI_SUCCESS; -} diff --git a/Tools/Source/TianoTools/Common/PeiLib/ia32/ProcessorAsms.Asm b/Tools/Source/TianoTools/Common/PeiLib/ia32/ProcessorAsms.Asm deleted file mode 100644 index bf0d5cbed7..0000000000 --- a/Tools/Source/TianoTools/Common/PeiLib/ia32/ProcessorAsms.Asm +++ /dev/null @@ -1,223 +0,0 @@ -; -; Copyright (c) 2004, Intel Corporation -; All rights reserved. This program and the accompanying materials -; are licensed and made available under the terms and conditions of the BSD License -; which accompanies this distribution. The full text of the license may be found at -; http://opensource.org/licenses/bsd-license.php -; -; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -; -; Module Name: -; -; ProcessorAsms.Asm -; -; Abstract: -; This is separated from processor.c to allow this functions to be built with /O1 -; -; Notes: -; - Masm uses "This", "ebx", etc as a directive. -; - H2INC is still not embedded in our build process so I translated the struc manually. -; - Unreferenced variables/arguments (This, NewBsp, NewStack) were causing compile errors and -; did not know of "pragma" mechanism in MASM and I did not want to reduce the warning level. -; Instead, I did a dummy referenced. -; - - .686P - .MMX - .MODEL SMALL - .CODE - -EFI_SUCCESS equ 0 -EFI_WARN_RETURN_FROM_LONG_JUMP equ 5 - -; -; Generated by h2inc run manually -; -_EFI_JUMP_BUFFER STRUCT 2t -_ebx DWORD ? -_esi DWORD ? -_edi DWORD ? -_ebp DWORD ? -_esp DWORD ? -_eip DWORD ? -_EFI_JUMP_BUFFER ENDS - -EFI_JUMP_BUFFER TYPEDEF _EFI_JUMP_BUFFER - -TransferControlSetJump PROTO C \ - _This:PTR EFI_PEI_TRANSFER_CONTROL_PROTOCOL, \ - Jump:PTR EFI_JUMP_BUFFER - -TransferControlLongJump PROTO C \ - _This:PTR EFI_PEI_TRANSFER_CONTROL_PROTOCOL, \ - Jump:PTR EFI_JUMP_BUFFER - -SwitchStacks PROTO C \ - EntryPoint:PTR DWORD, \ - Parameter:DWORD, \ - NewStack:PTR DWORD, \ - NewBsp:PTR DWORD - -SwitchIplStacks PROTO C \ - EntryPoint:PTR DWORD, \ - Parameter1:DWORD, \ - Parameter2:DWORD, \ - NewStack:PTR DWORD, \ - NewBsp:PTR DWORD - -; -;Routine Description: -; -; This routine implements the IA32 variant of the SetJump call. Its -; responsibility is to store system state information for a possible -; subsequent LongJump. -; -;Arguments: -; -; Pointer to CPU context save buffer. -; -;Returns: -; -; EFI_SUCCESS -; -TransferControlSetJump PROC C \ - _This:PTR EFI_PEI_TRANSFER_CONTROL_PROTOCOL, \ - Jump:PTR EFI_JUMP_BUFFER - - mov eax, _This - mov ecx, Jump - mov (EFI_JUMP_BUFFER PTR [ecx])._ebx, ebx - mov (EFI_JUMP_BUFFER PTR [ecx])._esi, esi - mov (EFI_JUMP_BUFFER PTR [ecx])._edi, edi - mov eax, [ebp] - mov (EFI_JUMP_BUFFER PTR [ecx])._ebp, eax - lea eax, [ebp+4] - mov (EFI_JUMP_BUFFER PTR [ecx])._esp, eax - mov eax, [ebp+4] - mov (EFI_JUMP_BUFFER PTR [ecx])._eip, eax - mov eax, EFI_SUCCESS - - ret - -TransferControlSetJump ENDP - -; -; Routine Description: -; -; This routine implements the IA32 variant of the LongJump call. Its -; responsibility is restore the system state to the Context Buffer and -; pass control back. -; -; Arguments: -; -; Pointer to CPU context save buffer. -; -; Returns: -; -; EFI_WARN_RETURN_FROM_LONG_JUMP -; - -TransferControlLongJump PROC C \ - _This:PTR EFI_PEI_TRANSFER_CONTROL_PROTOCOL, \ - Jump:PTR EFI_JUMP_BUFFER - - push ebx - push esi - push edi - - mov eax, _This - ; set return from SetJump to EFI_WARN_RETURN_FROM_LONG_JUMP - mov eax, EFI_WARN_RETURN_FROM_LONG_JUMP - mov ecx, Jump - mov ebx, (EFI_JUMP_BUFFER PTR [ecx])._ebx - mov esi, (EFI_JUMP_BUFFER PTR [ecx])._esi - mov edi, (EFI_JUMP_BUFFER PTR [ecx])._edi - mov ebp, (EFI_JUMP_BUFFER PTR [ecx])._ebp - mov esp, (EFI_JUMP_BUFFER PTR [ecx])._esp - add esp, 4 ;pop the eip - jmp DWORD PTR (EFI_JUMP_BUFFER PTR [ecx])._eip - mov eax, EFI_WARN_RETURN_FROM_LONG_JUMP - - pop edi - pop esi - pop ebx - ret - -TransferControlLongJump ENDP - -; -; Routine Description: -; This allows the caller to switch the stack and goes to the new entry point -; -; Arguments: -; EntryPoint - Pointer to the location to enter -; Parameter - Parameter to pass in -; NewStack - New Location of the stack -; NewBsp - New BSP -; -; Returns: -; -; Nothing. Goes to the Entry Point passing in the new parameters -; -SwitchStacks PROC C \ - EntryPoint:PTR DWORD, \ - Parameter:DWORD, \ - NewStack:PTR DWORD, \ - NewBsp:PTR DWORD - - push ebx - mov eax, NewBsp - mov ebx, Parameter - mov ecx, EntryPoint - mov eax, NewStack - mov esp, eax - push ebx - push 0 - jmp ecx - - pop ebx - ret - -SwitchStacks ENDP - -; -; Routine Description: -; This allows the caller to switch the stack and goes to the new entry point -; -; Arguments: -; EntryPoint - Pointer to the location to enter -; Parameter1/Parameter2 - Parameter to pass in -; NewStack - New Location of the stack -; NewBsp - New BSP -; -; Returns: -; -; Nothing. Goes to the Entry Point passing in the new parameters -; -SwitchIplStacks PROC C \ - EntryPoint:PTR DWORD, \ - Parameter1:DWORD, \ - Parameter2:DWORD, \ - NewStack:PTR DWORD, \ - NewBsp:PTR DWORD - - push ebx - mov eax, NewBsp - mov ebx, Parameter1 - mov edx, Parameter2 - mov ecx, EntryPoint - mov eax, NewStack - mov esp, eax - - push edx - push ebx - call ecx - - pop ebx - ret - -SwitchIplStacks ENDP - - END - diff --git a/Tools/Source/TianoTools/Common/PeiLib/ia32/efijump.h b/Tools/Source/TianoTools/Common/PeiLib/ia32/efijump.h deleted file mode 100644 index cdd7ca8c84..0000000000 --- a/Tools/Source/TianoTools/Common/PeiLib/ia32/efijump.h +++ /dev/null @@ -1,34 +0,0 @@ -/*++ - -Copyright (c) 2004, Intel Corporation -All rights reserved. This program and the accompanying materials -are licensed and made available under the terms and conditions of the BSD License -which accompanies this distribution. The full text of the license may be found at -http://opensource.org/licenses/bsd-license.php - -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -Module Name: - - EfiJump.h - -Abstract: - - This is the Setjump/Longjump pair for an IA32 processor. - ---*/ - -#ifndef _EFI_JUMP_H_ -#define _EFI_JUMP_H_ - -typedef struct { - UINT32 ebx; - UINT32 esi; - UINT32 edi; - UINT32 ebp; - UINT32 esp; - UINT32 eip; -} EFI_JUMP_BUFFER; - -#endif