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