are not included in a module.\r
\r
**/\r
-#define DEBUG_CODE_END() __DebugCodeLocal = 0; } } while (FALSE)\r
+#define DEBUG_CODE_END() __DebugCodeLocal = 0; __DebugCodeLocal++; } } while (FALSE)\r
\r
\r
/**\r
IN EFI_SYSTEM_TABLE *SystemTable\r
);\r
\r
+/**\r
+ Call destructors for all libraries. Automatics Generated by tool.\r
+\r
+ @param ImageHandle ImageHandle of the loaded driver.\r
+ @param SystemTable Pointer to the EFI System Table.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+ProcessLibraryDestructorList (\r
+ IN EFI_HANDLE ImageHandle,\r
+ IN EFI_SYSTEM_TABLE *SystemTable\r
+ );\r
\r
/**\r
Call the list of driver entry points. Automatics Generated by tool.\r
#ifndef __MODULE_ENTRY_POINT_H__\r
#define __MODULE_ENTRY_POINT_H__\r
\r
+/**\r
+ Enrty point to PEI core.\r
+\r
+ @param PeiStartupDescriptor Pointer of start up information.\r
+ \r
+ @return Status returned by entry points of core and drivers. \r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+_ModuleEntryPoint (\r
+ IN EFI_PEI_STARTUP_DESCRIPTOR *PeiStartupDescriptor\r
+ );\r
+\r
+/**\r
+ Wrapper of enrty point to PEI core.\r
+\r
+ @param PeiStartupDescriptor Pointer of start up information.\r
+ \r
+ @return Status returned by entry points of core and drivers. \r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EfiMain (\r
+ IN EFI_PEI_STARTUP_DESCRIPTOR *PeiStartupDescriptor\r
+ );\r
\r
/**\r
Call constructs for all libraries. Automatics Generated by tool.\r
Otherwise, the source lines between PERF_CODE_BEGIN() and PERF_CODE_END() are not included in a module.\r
\r
**/\r
-#define PERF_CODE_END() __PerformanceCodeLocal = 0; } } while (FALSE)\r
+#define PERF_CODE_END() __PerformanceCodeLocal = 0; __PerformanceCodeLocal++; } } while (FALSE)\r
\r
/**\r
Macro that declares a section of performance measurement source code.\r
IN UINT32 NewStack\r
);\r
\r
+/**\r
+ Worker function that locates the Node in the List\r
+\r
+ By searching the List, finds the location of the Node in List. At the same time,\r
+ verifies the validity of this list.\r
+\r
+ If List is NULL, then ASSERT().\r
+ If List->ForwardLink is NULL, then ASSERT().\r
+ If List->backLink is NULL, then ASSERT().\r
+ If Node is NULL, then ASSERT();\r
+ If PcdMaximumLinkedListLenth is not zero, and prior to insertion the number\r
+ of nodes in ListHead, including the ListHead node, is greater than or\r
+ equal to PcdMaximumLinkedListLength, then ASSERT().\r
+\r
+ @param List A pointer to a node in a linked list.\r
+ @param Node A pointer to one nod.\r
+\r
+ @retval TRUE Node is in List\r
+ @retval FALSE Node isn't in List, or List is invalid\r
+\r
+**/\r
+BOOLEAN\r
+IsNodeInList (\r
+ IN CONST LIST_ENTRY *List,\r
+ IN CONST LIST_ENTRY *Node\r
+ );\r
+\r
+/**\r
+ Performs an atomic increment of an 32-bit unsigned integer.\r
+\r
+ Performs an atomic increment of the 32-bit unsigned integer specified by\r
+ Value and returns the incremented value. The increment operation must be\r
+ performed using MP safe mechanisms. The state of the return value is not\r
+ guaranteed to be MP safe.\r
+\r
+ @param Value A pointer to the 32-bit value to increment.\r
+\r
+ @return The incremented value.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+InternalSyncIncrement (\r
+ IN volatile UINT32 *Value\r
+ );\r
+\r
+/**\r
+ Performs an atomic decrement of an 32-bit unsigned integer.\r
+\r
+ Performs an atomic decrement of the 32-bit unsigned integer specified by\r
+ Value and returns the decrement value. The decrement operation must be\r
+ performed using MP safe mechanisms. The state of the return value is not\r
+ guaranteed to be MP safe.\r
+\r
+ @param Value A pointer to the 32-bit value to decrement.\r
+\r
+ @return The decrement value.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+InternalSyncDecrement (\r
+ IN volatile UINT32 *Value\r
+ );\r
+\r
+/**\r
+ Performs an atomic compare exchange operation on a 32-bit unsigned integer.\r
+\r
+ Performs an atomic compare exchange operation on the 32-bit unsigned integer\r
+ specified by Value. If Value is equal to CompareValue, then Value is set to \r
+ ExchangeValue and CompareValue is returned. If Value is not equal to CompareValue,\r
+ then Value is returned. The compare exchange operation must be performed using \r
+ MP safe mechanisms.\r
+\r
+ @param Value A pointer to the 32-bit value for the compare exchange\r
+ operation.\r
+ @param CompareValue 32-bit value used in compare operation.\r
+ @param ExchangeValue 32-bit value used in exchange operation.\r
+\r
+ @return The original *Value before exchange.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+InternalSyncCompareExchange32 (\r
+ IN volatile UINT32 *Value,\r
+ IN UINT32 CompareValue,\r
+ IN UINT32 ExchangeValue\r
+ );\r
+\r
+/**\r
+ Performs an atomic compare exchange operation on a 64-bit unsigned integer.\r
+\r
+ Performs an atomic compare exchange operation on the 64-bit unsigned integer specified \r
+ by Value. If Value is equal to CompareValue, then Value is set to ExchangeValue and \r
+ CompareValue is returned. If Value is not equal to CompareValue, then Value is returned. \r
+ The compare exchange operation must be performed using MP safe mechanisms.\r
+\r
+ @param Value A pointer to the 64-bit value for the compare exchange\r
+ operation.\r
+ @param CompareValue 64-bit value used in compare operation.\r
+ @param ExchangeValue 64-bit value used in exchange operation.\r
+\r
+ @return The original *Value before exchange.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+InternalSyncCompareExchange64 (\r
+ IN volatile UINT64 *Value,\r
+ IN UINT64 CompareValue,\r
+ IN UINT64 ExchangeValue\r
+ );\r
+\r
+/**\r
+ Worker function that returns a bit field from Operand\r
+\r
+ Returns the bitfield specified by the StartBit and the EndBit from Operand.\r
+\r
+ @param Operand Operand on which to perform the bitfield operation.\r
+ @param StartBit The ordinal of the least significant bit in the bit field.\r
+ @param EndBit The ordinal of the most significant bit in the bit field.\r
+\r
+ @return The bit field read.\r
+\r
+**/\r
+unsigned int\r
+BitFieldReadUint (\r
+ IN unsigned int Operand,\r
+ IN UINTN StartBit,\r
+ IN UINTN EndBit\r
+ );\r
+\r
+/**\r
+ Worker function that reads a bit field from Operand, performs a bitwise OR, \r
+ and returns the result.\r
+\r
+ Performs a bitwise OR between the bit field specified by StartBit and EndBit\r
+ in Operand and the value specified by AndData. All other bits in Operand are\r
+ preserved. The new value is returned.\r
+\r
+ @param Operand Operand on which to perform the bitfield operation.\r
+ @param StartBit The ordinal of the least significant bit in the bit field.\r
+ @param EndBit The ordinal of the most significant bit in the bit field.\r
+ @param OrData The value to OR with the read value from the value\r
+\r
+ @return The new value.\r
+\r
+**/\r
+unsigned int\r
+BitFieldOrUint (\r
+ IN unsigned int Operand,\r
+ IN UINTN StartBit,\r
+ IN UINTN EndBit,\r
+ IN unsigned int OrData\r
+ );\r
+\r
+/**\r
+ Worker function that reads a bit field from Operand, performs a bitwise AND, \r
+ and returns the result.\r
+\r
+ Performs a bitwise AND between the bit field specified by StartBit and EndBit\r
+ in Operand and the value specified by AndData. All other bits in Operand are\r
+ preserved. The new value is returned.\r
+\r
+ @param Operand Operand on which to perform the bitfield operation.\r
+ @param StartBit The ordinal of the least significant bit in the bit field.\r
+ @param EndBit The ordinal of the most significant bit in the bit field.\r
+ @param AndData The value to And with the read value from the value\r
+\r
+ @return The new value.\r
+\r
+**/\r
+unsigned int\r
+BitFieldAndUint (\r
+ IN unsigned int Operand,\r
+ IN UINTN StartBit,\r
+ IN UINTN EndBit,\r
+ IN unsigned int AndData\r
+ );\r
+\r
+/**\r
+ Worker function that checks ASSERT condition for JumpBuffer\r
+\r
+ Checks ASSERT condition for JumpBuffer.\r
+\r
+ If JumpBuffer is NULL, then ASSERT().\r
+ For IPF CPUs, if JumpBuffer is not aligned on a 16-byte boundary, then ASSERT().\r
+\r
+ @param JumpBuffer A pointer to CPU context buffer.\r
+\r
+**/\r
+VOID\r
+InternalAssertJumpBuffer (\r
+ IN BASE_LIBRARY_JUMP_BUFFER *JumpBuffer\r
+ );\r
+\r
+/**\r
+ Restores the CPU context that was saved with SetJump().\r
+\r
+ Restores the CPU context from the buffer specified by JumpBuffer.\r
+ This function never returns to the caller.\r
+ Instead is resumes execution based on the state of JumpBuffer.\r
+\r
+ @param JumpBuffer A pointer to CPU context buffer.\r
+ @param Value The value to return when the SetJump() context is restored.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+InternalLongJump (\r
+ IN BASE_LIBRARY_JUMP_BUFFER *JumpBuffer,\r
+ IN UINTN Value\r
+ );\r
+\r
#endif\r
\r
**/\r
\r
+#include "BaseLibInternals.h"\r
+\r
/**\r
Worker function that returns a bit field from Operand\r
\r
IN UINT64 OrData\r
)\r
{\r
+ UINT64 Value1;\r
+ UINT64 Value2;\r
+\r
ASSERT (EndBit < sizeof (Operand) * 8);\r
ASSERT (StartBit <= EndBit);\r
- return Operand |\r
- (LShiftU64 (OrData, StartBit) & ~LShiftU64 ((UINT64)-2, EndBit));\r
+\r
+ Value1 = LShiftU64 (OrData, StartBit);\r
+ Value2 = LShiftU64 ((UINT64) - 2, EndBit);\r
+\r
+ return Operand | (Value1 & ~Value2);\r
}\r
\r
/**\r
IN UINT64 AndData\r
)\r
{\r
+ UINT64 Value1;\r
+ UINT64 Value2;\r
+ \r
ASSERT (EndBit < sizeof (Operand) * 8);\r
ASSERT (StartBit <= EndBit);\r
- return Operand &\r
- ~(LShiftU64 (~AndData, StartBit) & ~LShiftU64 ((UINT64)-2, EndBit));\r
+\r
+ Value1 = LShiftU64 (~AndData, StartBit);\r
+ Value2 = LShiftU64 ((UINT64)-2, EndBit);\r
+\r
+ return Operand & ~(Value1 & ~Value2);\r
}\r
\r
/**\r
\r
**/\r
\r
-/**\r
- Performs an atomic compare exchange operation on a 32-bit unsigned integer.\r
-\r
- Performs an atomic compare exchange operation on the 32-bit unsigned integer\r
- specified by Value. If Value is equal to CompareValue, then Value is set to \r
- ExchangeValue and CompareValue is returned. If Value is not equal to CompareValue,\r
- then Value is returned. The compare exchange operation must be performed using \r
- MP safe mechanisms.\r
-\r
- @param Value A pointer to the 32-bit value for the compare exchange\r
- operation.\r
- @param CompareValue 32-bit value used in compare operation.\r
- @param ExchangeValue 32-bit value used in exchange operation.\r
-\r
- @return The original *Value before exchange.\r
-\r
-**/\r
-UINT32\r
-EFIAPI\r
-InternalSyncCompareExchange32 (\r
- IN volatile UINT32 *Value,\r
- IN UINT32 CompareValue,\r
- IN UINT32 ExchangeValue\r
- );\r
+#include "BaseLibInternals.h"\r
\r
/**\r
Performs an atomic increment of an 32-bit unsigned integer.\r
IN CONST UINT32 *Buffer\r
)\r
{\r
+ UINT16 LowerBytes;\r
+ UINT16 HigherBytes;\r
+\r
ASSERT (Buffer != NULL);\r
\r
- return (UINT32)(\r
- ReadUnaligned16 ((UINT16*)Buffer) |\r
- (ReadUnaligned16 ((UINT16*)Buffer + 1) << 16)\r
- );\r
+ LowerBytes = ReadUnaligned16 ((UINT16*) Buffer);\r
+ HigherBytes = ReadUnaligned16 ((UINT16*) Buffer + 1);\r
+\r
+ return (UINT32) (LowerBytes | (HigherBytes << 16));\r
}\r
\r
/**\r
IN CONST UINT64 *Buffer\r
)\r
{\r
+ UINT32 LowerBytes;\r
+ UINT32 HigherBytes;\r
+\r
ASSERT (Buffer != NULL);\r
\r
- return (UINT64)(\r
- ReadUnaligned32 ((UINT32*)Buffer) |\r
- LShiftU64 (ReadUnaligned32 ((UINT32*)Buffer + 1), 32)\r
- );\r
+ LowerBytes = ReadUnaligned32 ((UINT32*) Buffer);\r
+ HigherBytes = ReadUnaligned32 ((UINT32*) Buffer + 1);\r
+\r
+ return (UINT64) (LowerBytes | LShiftU64 (HigherBytes, 32));\r
}\r
\r
/**\r
\r
**/\r
\r
+#include "BaseLibInternals.h"\r
+\r
/**\r
Worker function that locates the Node in the List\r
\r
\r
**/\r
\r
-/**\r
- Worker function that checks ASSERT condition for JumpBuffer\r
-\r
- Checks ASSERT condition for JumpBuffer.\r
-\r
- If JumpBuffer is NULL, then ASSERT().\r
- For IPF CPUs, if JumpBuffer is not aligned on a 16-byte boundary, then ASSERT().\r
-\r
- @param JumpBuffer A pointer to CPU context buffer.\r
-\r
-**/\r
-VOID\r
-InternalAssertJumpBuffer (\r
- IN BASE_LIBRARY_JUMP_BUFFER *JumpBuffer\r
- );\r
-\r
-/**\r
- Restores the CPU context that was saved with SetJump().\r
-\r
- Restores the CPU context from the buffer specified by JumpBuffer.\r
- This function never returns to the caller.\r
- Instead is resumes execution based on the state of JumpBuffer.\r
-\r
- @param JumpBuffer A pointer to CPU context buffer.\r
- @param Value The value to return when the SetJump() context is restored.\r
-\r
-**/\r
-VOID\r
-EFIAPI\r
-InternalLongJump (\r
- IN BASE_LIBRARY_JUMP_BUFFER *JumpBuffer,\r
- IN UINTN Value\r
- );\r
+#include "BaseLibInternals.h"\r
\r
/**\r
Restores the CPU context that was saved with SetJump().\r
IN UINTN Count\r
)\r
{\r
+ INTN TestValue;\r
+\r
//\r
// Test if this compiler supports arithmetic shift\r
//\r
- if ((((-1) << (sizeof (-1) * 8 - 1)) >> (sizeof (-1) * 8 - 1)) == -1) {\r
+ TestValue = (((-1) << (sizeof (-1) * 8 - 1)) >> (sizeof (-1) * 8 - 1));\r
+ if (TestValue == -1) {\r
//\r
// Arithmetic shift is supported\r
//\r
IN UINT64 Operand\r
)\r
{\r
- return (UINT64)(\r
- ((UINT64)SwapBytes32 ((UINT32)Operand) << 32) |\r
- ((UINT64)SwapBytes32 ((UINT32)(Operand >> 32)))\r
- );\r
+ UINT64 LowerBytes;\r
+ UINT64 HigherBytes;\r
+\r
+ LowerBytes = (UINT64) SwapBytes32 ((UINT32) Operand);\r
+ HigherBytes = (UINT64) SwapBytes32 ((UINT32) (Operand >> 32));\r
+\r
+ return (LowerBytes << 32 | HigherBytes);\r
}\r
\r
/**\r
\r
**/\r
\r
+#include "BaseLibInternals.h"\r
+\r
/**\r
Worker function that checks ASSERT condition for JumpBuffer\r
\r
IN CHAR8 Chr\r
)\r
{\r
- return (Chr >= 'a' && Chr <= 'z') ? Chr - ('a' - 'A') : Chr;\r
+ return (UINT8) ((Chr >= 'a' && Chr <= 'z') ? Chr - ('a' - 'A') : Chr);\r
}\r
\r
/**\r
IN CONST CHAR8 *SecondString\r
)\r
{\r
+ CHAR8 UpperFirstString;\r
+ CHAR8 UpperSecondString;\r
+\r
//\r
// ASSERT both strings are less long than PcdMaximumAsciiStringLength\r
//\r
ASSERT (AsciiStrSize (FirstString));\r
ASSERT (AsciiStrSize (SecondString));\r
\r
- while ((*FirstString != '\0') &&\r
- (AsciiToUpper (*FirstString) == AsciiToUpper (*SecondString))) {\r
+ UpperFirstString = AsciiToUpper (*FirstString);\r
+ UpperSecondString = AsciiToUpper (*SecondString);\r
+ while ((*FirstString != '\0') && (UpperFirstString == UpperSecondString)) {\r
FirstString++;\r
SecondString++;\r
+ UpperFirstString = AsciiToUpper (*FirstString);\r
+ UpperSecondString = AsciiToUpper (*SecondString);\r
}\r
\r
- return AsciiToUpper (*FirstString) - AsciiToUpper (*SecondString);\r
+ return UpperFirstString - UpperSecondString;\r
}\r
\r
/**\r
)\r
{\r
ASSERT (Value < 100);\r
- return ((Value / 10) << 4) | (Value % 10);\r
+ return (UINT8) (((Value / 10) << 4) | (Value % 10));\r
}\r
\r
/**\r
{\r
ASSERT (Value < 0xa0);\r
ASSERT ((Value & 0xf) < 0xa);\r
- return (Value >> 4) * 10 + (Value & 0xf);\r
+ return (UINT8) ((Value >> 4) * 10 + (Value & 0xf));\r
}\r
IN UINT16 Operand\r
)\r
{\r
- return (Operand << 8) | (Operand >> 8);\r
+ return (UINT16) ((Operand << 8) | (Operand >> 8));\r
}\r
IN UINT32 Operand\r
)\r
{\r
- return (UINT32)(\r
- ((UINT32)SwapBytes16 ((UINT16)Operand) << 16) |\r
- ((UINT32)SwapBytes16 ((UINT16)(Operand >> 16)))\r
- );\r
+ UINT32 LowerBytes;\r
+ UINT32 HigherBytes;\r
+\r
+ LowerBytes = (UINT32) SwapBytes16 ((UINT16) Operand);\r
+ HigherBytes = (UINT32) SwapBytes16 ((UINT16) (Operand >> 16));\r
+\r
+ return (LowerBytes << 16 | HigherBytes);\r
}\r
\r
**/\r
\r
+#include "BaseLibInternals.h"\r
+\r
#define SPIN_LOCK_RELEASED ((SPIN_LOCK)1)\r
#define SPIN_LOCK_ACQUIRED ((SPIN_LOCK)2)\r
\r
-/**\r
- Performs an atomic increment of an 32-bit unsigned integer.\r
-\r
- Performs an atomic increment of the 32-bit unsigned integer specified by\r
- Value and returns the incremented value. The increment operation must be\r
- performed using MP safe mechanisms. The state of the return value is not\r
- guaranteed to be MP safe.\r
-\r
- @param Value A pointer to the 32-bit value to increment.\r
-\r
- @return The incremented value.\r
-\r
-**/\r
-UINT32\r
-EFIAPI\r
-InternalSyncIncrement (\r
- IN volatile UINT32 *Value\r
- );\r
-\r
-/**\r
- Performs an atomic decrement of an 32-bit unsigned integer.\r
-\r
- Performs an atomic decrement of the 32-bit unsigned integer specified by\r
- Value and returns the decrement value. The decrement operation must be\r
- performed using MP safe mechanisms. The state of the return value is not\r
- guaranteed to be MP safe.\r
-\r
- @param Value A pointer to the 32-bit value to decrement.\r
-\r
- @return The decrement value.\r
-\r
-**/\r
-UINT32\r
-EFIAPI\r
-InternalSyncDecrement (\r
- IN volatile UINT32 *Value\r
- );\r
-\r
-/**\r
- Performs an atomic compare exchange operation on a 32-bit unsigned integer.\r
-\r
- Performs an atomic compare exchange operation on the 32-bit unsigned integer\r
- specified by Value. If Value is equal to CompareValue, then Value is set to \r
- ExchangeValue and CompareValue is returned. If Value is not equal to CompareValue,\r
- then Value is returned. The compare exchange operation must be performed using \r
- MP safe mechanisms.\r
-\r
- @param Value A pointer to the 32-bit value for the compare exchange\r
- operation.\r
- @param CompareValue 32-bit value used in compare operation.\r
- @param ExchangeValue 32-bit value used in exchange operation.\r
-\r
- @return The original *Value before exchange.\r
-\r
-**/\r
-UINT32\r
-EFIAPI\r
-InternalSyncCompareExchange32 (\r
- IN volatile UINT32 *Value,\r
- IN UINT32 CompareValue,\r
- IN UINT32 ExchangeValue\r
- );\r
-\r
-/**\r
- Performs an atomic compare exchange operation on a 64-bit unsigned integer.\r
-\r
- Performs an atomic compare exchange operation on the 64-bit unsigned integer specified \r
- by Value. If Value is equal to CompareValue, then Value is set to ExchangeValue and \r
- CompareValue is returned. If Value is not equal to CompareValue, then Value is returned. \r
- The compare exchange operation must be performed using MP safe mechanisms.\r
-\r
- @param Value A pointer to the 64-bit value for the compare exchange\r
- operation.\r
- @param CompareValue 64-bit value used in compare operation.\r
- @param ExchangeValue 64-bit value used in exchange operation.\r
-\r
- @return The original *Value before exchange.\r
-\r
-**/\r
-UINT64\r
-EFIAPI\r
-InternalSyncCompareExchange64 (\r
- IN volatile UINT64 *Value,\r
- IN UINT64 CompareValue,\r
- IN UINT64 ExchangeValue\r
- );\r
-\r
/**\r
Retrieves the architecture specific spin lock alignment requirements for\r
optimal spin lock performance.\r
IN VOID *ExchangeValue\r
)\r
{\r
- switch (sizeof (*Value)) {\r
+ UINT8 SizeOfValue;\r
+\r
+ SizeOfValue = sizeof (*Value);\r
+\r
+ switch (SizeOfValue) {\r
case sizeof (UINT32):\r
return (VOID*)(UINTN)InterlockedCompareExchange32 (\r
(UINT32*)Value,\r
\r
**/\r
\r
+#include "MemLibInternals.h"\r
+\r
/**\r
Copy Length bytes from Source to Destination.\r
\r
IN CONST GUID *Guid2\r
)\r
{\r
- return (BOOLEAN)(\r
- ReadUnaligned64 ((CONST UINT64*)Guid1)\r
- == ReadUnaligned64 ((CONST UINT64*)Guid2) &&\r
- ReadUnaligned64 ((CONST UINT64*)Guid1 + 1)\r
- == ReadUnaligned64 ((CONST UINT64*)Guid2 + 1)\r
- );\r
+ UINT64 LowPartOfGuid1;\r
+ UINT64 LowPartOfGuid2;\r
+ UINT64 HighPartOfGuid1;\r
+ UINT64 HighPartOfGuid2;\r
+\r
+ LowPartOfGuid1 = ReadUnaligned64 ((CONST UINT64*) Guid1);\r
+ LowPartOfGuid2 = ReadUnaligned64 ((CONST UINT64*) Guid2);\r
+ HighPartOfGuid1 = ReadUnaligned64 ((CONST UINT64*) Guid1 + 1);\r
+ HighPartOfGuid2 = ReadUnaligned64 ((CONST UINT64*) Guid2 + 1);\r
+\r
+ return (BOOLEAN) (LowPartOfGuid1 == LowPartOfGuid2 && HighPartOfGuid1 == HighPartOfGuid2);\r
}\r
\r
/**\r
\r
**/\r
\r
+#include "MemLibInternals.h"\r
\r
/**\r
Set Buffer to Value for Size bytes.\r
IN CONST GUID *Guid2\r
)\r
{\r
- return (BOOLEAN)(\r
- ReadUnaligned64 ((CONST UINT64*)Guid1)\r
- == ReadUnaligned64 ((CONST UINT64*)Guid2) &&\r
- ReadUnaligned64 ((CONST UINT64*)Guid1 + 1)\r
- == ReadUnaligned64 ((CONST UINT64*)Guid2 + 1)\r
- );\r
+ UINT64 LowPartOfGuid1;\r
+ UINT64 LowPartOfGuid2;\r
+ UINT64 HighPartOfGuid1;\r
+ UINT64 HighPartOfGuid2;\r
+\r
+ LowPartOfGuid1 = ReadUnaligned64 ((CONST UINT64*) Guid1);\r
+ LowPartOfGuid2 = ReadUnaligned64 ((CONST UINT64*) Guid2);\r
+ HighPartOfGuid1 = ReadUnaligned64 ((CONST UINT64*) Guid1 + 1);\r
+ HighPartOfGuid2 = ReadUnaligned64 ((CONST UINT64*) Guid2 + 1);\r
+\r
+ return (BOOLEAN) (LowPartOfGuid1 == LowPartOfGuid2 && HighPartOfGuid1 == HighPartOfGuid2);\r
}\r
\r
/**\r
@return The base address of PCI Express.\r
\r
**/\r
+STATIC\r
volatile VOID*\r
GetPciExpressBaseAddress (\r
VOID\r
\r
**/\r
\r
-\r
-/**\r
- Performs an Itanium-based specific relocation fixup and is a no-op on other\r
- instruction sets.\r
-\r
- @param Reloc Pointer to the relocation record.\r
- @param Fixup Pointer to the address to fix up.\r
- @param FixupData Pointer to a buffer to log the fixups.\r
- @param Adjust The offset to adjust the fixup.\r
-\r
- @return Status code.\r
-\r
-**/\r
-RETURN_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
-/**\r
- Performs an Itanium-based specific re-relocation fixup and is a no-op on other\r
- instruction sets. This is used to re-relocated the image into the EFI virtual\r
- space for runtime calls.\r
-\r
- @param Reloc Pointer to the relocation record.\r
- @param Fixup Pointer to the address to fix up.\r
- @param FixupData Pointer to a buffer to log the fixups.\r
- @param Adjust The offset to adjust the fixup.\r
-\r
- @return Status code.\r
-\r
-**/\r
-RETURN_STATUS\r
-PeHotRelocateImageEx (\r
- IN UINT16 *Reloc,\r
- IN OUT CHAR8 *Fixup,\r
- IN OUT CHAR8 **FixupData,\r
- IN UINT64 Adjust\r
- );\r
-\r
-\r
-/**\r
- Returns TRUE if the machine type of PE/COFF image is supported. Supported\r
- does not mean the image can be executed it means the PE/COFF loader supports\r
- loading and relocating of the image type. It's up to the caller to support\r
- the entry point.\r
-\r
- @param Machine Machine type from the PE Header.\r
-\r
- @return TRUE if this PE/COFF loader can load the image\r
-\r
-**/\r
-BOOLEAN\r
-PeCoffLoaderImageFormatSupported (\r
- IN UINT16 Machine\r
- );\r
-\r
+#include "BasePeCoffLibInternals.h"\r
\r
/**\r
Retrieves the magic value from the PE/COFF header.\r
</LibraryClassDefinitions>\r
<SourceFiles>\r
<Filename>BasePeCoff.c</Filename>\r
+ <Filename>BasePeCoffLibInternals.h</Filename>\r
<Filename SupArchList="IA32">Ia32/PeCoffLoaderEx.c</Filename>\r
<Filename SupArchList="X64">x64/PeCoffLoaderEx.c</Filename>\r
<Filename SupArchList="IPF">Ipf/PeCoffLoaderEx.c</Filename>\r
--- /dev/null
+/** @file\r
+ Declaration of internal functions in PE/COFF Lib.\r
+\r
+ Copyright (c) 2006, Intel Corporation<BR>\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: BasePeCoffLibInternals.h\r
+\r
+**/\r
+\r
+#ifndef __BASE_PECOFF_LIB_INTERNALS__\r
+#define __BASE_PECOFF_LIB_INTERNALS__\r
+\r
+/**\r
+ Performs an Itanium-based specific relocation fixup and is a no-op on other\r
+ instruction sets.\r
+\r
+ @param Reloc Pointer to the relocation record.\r
+ @param Fixup Pointer to the address to fix up.\r
+ @param FixupData Pointer to a buffer to log the fixups.\r
+ @param Adjust The offset to adjust the fixup.\r
+\r
+ @return Status code.\r
+\r
+**/\r
+RETURN_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
+/**\r
+ Performs an Itanium-based specific re-relocation fixup and is a no-op on other\r
+ instruction sets. This is used to re-relocated the image into the EFI virtual\r
+ space for runtime calls.\r
+\r
+ @param Reloc Pointer to the relocation record.\r
+ @param Fixup Pointer to the address to fix up.\r
+ @param FixupData Pointer to a buffer to log the fixups.\r
+ @param Adjust The offset to adjust the fixup.\r
+\r
+ @return Status code.\r
+\r
+**/\r
+RETURN_STATUS\r
+PeHotRelocateImageEx (\r
+ IN UINT16 *Reloc,\r
+ IN OUT CHAR8 *Fixup,\r
+ IN OUT CHAR8 **FixupData,\r
+ IN UINT64 Adjust\r
+ );\r
+\r
+\r
+/**\r
+ Returns TRUE if the machine type of PE/COFF image is supported. Supported\r
+ does not mean the image can be executed it means the PE/COFF loader supports\r
+ loading and relocating of the image type. It's up to the caller to support\r
+ the entry point.\r
+\r
+ @param Machine Machine type from the PE Header.\r
+\r
+ @return TRUE if this PE/COFF loader can load the image\r
+\r
+**/\r
+BOOLEAN\r
+PeCoffLoaderImageFormatSupported (\r
+ IN UINT16 Machine\r
+ );\r
+\r
+/**\r
+ Retrieves the magic value from the PE/COFF header.\r
+\r
+ @param Hdr The buffer in which to return the PE32, PE32+, or TE header.\r
+\r
+ @return EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC - Image is PE32\r
+ @return EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC - Image is PE32+\r
+\r
+**/\r
+UINT16\r
+PeCoffLoaderGetPeHeaderMagicValue (\r
+ IN EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION Hdr\r
+ );\r
+\r
+/**\r
+ Retrieves the PE or TE Header from a PE/COFF or TE image.\r
+\r
+ @param ImageContext The context of the image being loaded.\r
+ @param Hdr The buffer in which to return the PE32, PE32+, or TE header.\r
+\r
+ @retval RETURN_SUCCESS The PE or TE Header is read.\r
+ @retval Other The error status from reading the PE/COFF or TE image using the ImageRead function.\r
+\r
+**/\r
+RETURN_STATUS\r
+PeCoffLoaderGetPeHeader (\r
+ IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext,\r
+ OUT EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION Hdr\r
+ );\r
+\r
+/**\r
+ Converts an image address to the loaded address.\r
+\r
+ @param ImageContext The context of the image being loaded.\r
+ @param Address The address to be converted to the loaded address.\r
+\r
+ @return The converted address or NULL if the address can not be converted.\r
+\r
+**/\r
+VOID *\r
+PeCoffLoaderImageAddress (\r
+ IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext,\r
+ IN UINTN Address\r
+ );\r
+\r
+#endif\r
\r
**/\r
\r
-\r
+#include "BasePeCoffLibInternals.h"\r
\r
\r
\r
VOID\r
)\r
{\r
- return ((PcdGet8(PcdPerformanceLibraryPropertyMask) & PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED) != 0);\r
+ return (BOOLEAN) ((PcdGet8(PcdPerformanceLibraryPropertyMask) & PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED) != 0);\r
}\r
VOID\r
)\r
{\r
- return ((PcdGet8(PcdPostCodePropertyMask) & POST_CODE_PROPERTY_POST_CODE_ENABLED) != 0);\r
+ return (BOOLEAN) ((PcdGet8(PcdPostCodePropertyMask) & POST_CODE_PROPERTY_POST_CODE_ENABLED) != 0);\r
}\r
\r
\r
VOID\r
)\r
{\r
- return ((PcdGet8(PcdPostCodePropertyMask) & POST_CODE_PROPERTY_POST_CODE_ENABLED) != 0);\r
+ return (BOOLEAN) ((PcdGet8(PcdPostCodePropertyMask) & POST_CODE_PROPERTY_POST_CODE_ENABLED) != 0);\r
}\r
VOID\r
)\r
{\r
- return ((PcdGet8(PcdPostCodePropertyMask) & POST_CODE_PROPERTY_POST_CODE_ENABLED) != 0);\r
+ return (BOOLEAN) ((PcdGet8(PcdPostCodePropertyMask) & POST_CODE_PROPERTY_POST_CODE_ENABLED) != 0);\r
}\r
\r
\r
VOID\r
)\r
{\r
- return ((PcdGet8(PcdPostCodePropertyMask) & POST_CODE_PROPERTY_POST_CODE_ENABLED) != 0);\r
+ return (BOOLEAN) ((PcdGet8(PcdPostCodePropertyMask) & POST_CODE_PROPERTY_POST_CODE_ENABLED) != 0);\r
}\r
UINT8 Pad2;\r
} TIME;\r
\r
+/**\r
+ Worker function that produces a Null-terminated string in an output buffer \r
+ based on a Null-terminated format string and a VA_LIST argument list.\r
+\r
+ VSPrint 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
+ @param Buffer Character buffer to print the results of the parsing\r
+ of Format into.\r
+ @param BufferSize Maximum number of characters to put into buffer.\r
+ @param Flags Intial flags value.\r
+ Can only have FORMAT_UNICODE and OUTPUT_UNICODE set.\r
+ @param Format Null-terminated format string.\r
+ @param Marker Vararg list consumed by processing Format.\r
+\r
+ @return Number of characters printed not including the Null-terminator.\r
+\r
+**/\r
+UINTN\r
+BasePrintLibVSPrint (\r
+ OUT CHAR8 *Buffer,\r
+ IN UINTN BufferSize,\r
+ IN UINTN Flags,\r
+ IN CONST CHAR8 *Format,\r
+ IN VA_LIST Marker\r
+ );\r
+\r
/**\r
Worker function that produces a Null-terminated string in an output buffer \r
based on a Null-terminated format string and variable argument list.\r
\r
**/\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 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
+#include "BaseUefiDecompressLibInternals.h"\r
\r
/**\r
Read NumOfBit of bits from source into mBitBuf\r
UINT16 Avail;\r
UINT16 NextCode;\r
UINT16 Mask;\r
+ UINT16 WordOfStart;\r
+ UINT16 WordOfCount;\r
+\r
\r
for (Index = 1; Index <= 16; Index++) {\r
Count[Index] = 0;\r
Start[1] = 0;\r
\r
for (Index = 1; Index <= 16; Index++) {\r
- Start[Index + 1] = (UINT16) (Start[Index] + (Count[Index] << (16 - Index)));\r
+ WordOfStart = Start[Index];\r
+ WordOfCount = Count[Index];\r
+ Start[Index + 1] = (UINT16) (WordOfStart + (WordOfCount << (16 - Index)));\r
}\r
\r
if (Start[17] != 0) {\r
// \r
CharC = DecodeC (Sd);\r
if (Sd->mBadTableFlag != 0) {\r
- return ;\r
+ goto Done;\r
}\r
\r
if (CharC < 256) {\r
// Process an Original character\r
//\r
if (Sd->mOutBuf >= Sd->mOrigSize) {\r
- return ;\r
+ goto Done;\r
} else {\r
//\r
// Write orignal character into mDstBase\r
while ((INT16) (BytesRemain) >= 0) {\r
Sd->mDstBase[Sd->mOutBuf++] = Sd->mDstBase[DataIdx++];\r
if (Sd->mOutBuf >= Sd->mOrigSize) {\r
- return ;\r
+ goto Done;\r
}\r
\r
BytesRemain--;\r
}\r
}\r
\r
+Done:\r
return ;\r
}\r
\r
</LibraryClassDefinitions>\r
<SourceFiles>\r
<Filename>BaseUefiDecompressLib.c</Filename>\r
+ <Filename>BaseUefiDecompressLibInternals.h</Filename>\r
</SourceFiles>\r
<PackageDependencies>\r
<Package PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>\r
--- /dev/null
+/** @file\r
+ Internal include file for Base UEFI Decompress Libary.\r
+\r
+ Copyright (c) 2006, 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: BaseUefiDecompressLibInternals.h\r
+\r
+**/\r
+\r
+#ifndef __BASE_UEFI_DECOMPRESS_LIB_INTERNALS_H__\r
+#define __BASE_UEFI_DECOMPRESS_LIB_INTERNALS_H__\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 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
+/**\r
+ Read NumOfBit of bits from source into mBitBuf\r
+\r
+ Shift mBitBuf NumOfBits left. Read in NumOfBits of bits from source.\r
+\r
+ @param Sd The global scratch data\r
+ @param NumOfBits The number of bits to shift and read.\r
+\r
+**/\r
+VOID\r
+FillBuf (\r
+ IN SCRATCH_DATA *Sd,\r
+ IN UINT16 NumOfBits\r
+ );\r
+\r
+/**\r
+ Get NumOfBits of bits out from mBitBuf\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
+ @param Sd The global scratch data.\r
+ @param NumOfBits The number of bits to pop and read.\r
+\r
+ @return The bits that are popped out.\r
+\r
+**/\r
+UINT32\r
+GetBits (\r
+ IN SCRATCH_DATA *Sd,\r
+ IN UINT16 NumOfBits\r
+ );\r
+\r
+/**\r
+ Creates Huffman Code mapping table according to code length array.\r
+\r
+ Creates Huffman Code mapping table for Extra Set, Char&Len Set \r
+ and Position Set according to code length array.\r
+\r
+ @param Sd The global scratch data\r
+ @param NumOfChar Number of symbols in the symbol set\r
+ @param BitLen Code length array\r
+ @param TableBits The width of the mapping table\r
+ @param Table The table\r
+\r
+ @retval 0 OK.\r
+ @retval BAD_TABLE The table is corrupted.\r
+\r
+**/\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
+ Decodes a position value.\r
+\r
+ Get a position value according to Position Huffman Table.\r
+ \r
+ @param Sd the global scratch data\r
+\r
+ @return The position value decoded.\r
+\r
+**/\r
+UINT32\r
+DecodeP (\r
+ IN SCRATCH_DATA *Sd\r
+ );\r
+\r
+/**\r
+ Reads code lengths for the Extra Set or the Position Set.\r
+\r
+ Read in the Extra Set or Pointion Set Length Arrary, then\r
+ generate the Huffman code mapping for them.\r
+\r
+ @param Sd The global scratch data.\r
+ @param nn Number of symbols.\r
+ @param nbit Number of bits needed to represent nn.\r
+ @param Special The special symbol that needs to be taken care of.\r
+\r
+ @retval 0 OK.\r
+ @retval BAD_TABLE Table is corrupted.\r
+\r
+**/\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
+ Reads code lengths for Char&Len Set.\r
+ \r
+ Read in and decode the Char&Len Set Code Length Array, then\r
+ generate the Huffman Code mapping table for the Char&Len Set.\r
+\r
+ @param Sd the global scratch data\r
+\r
+**/\r
+VOID\r
+ReadCLen (\r
+ SCRATCH_DATA *Sd\r
+ );\r
+\r
+/**\r
+ Decode a character/length value.\r
+ \r
+ Read one value from mBitBuf, Get one code from mBitBuf. If it is at block boundary, generates\r
+ Huffman code mapping table for Extra Set, Code&Len Set and\r
+ Position Set.\r
+\r
+ @param Sd The global scratch data.\r
+\r
+ @return The value decoded.\r
+\r
+**/\r
+UINT16\r
+DecodeC (\r
+ SCRATCH_DATA *Sd\r
+ );\r
+\r
+/**\r
+ Decode the source data and put the resulting data into the destination buffer.\r
+\r
+ Decode the source data and put the resulting data into the destination buffer.\r
+ \r
+ @param Sd The global scratch data\r
+\r
+**/\r
+VOID\r
+Decode (\r
+ SCRATCH_DATA *Sd\r
+ );\r
+\r
+#endif\r
</LibraryClassDefinitions>\r
<SourceFiles>\r
<Filename>HobLib.c</Filename>\r
+ <Filename>HobLib.h</Filename>\r
</SourceFiles>\r
<PackageDependencies>\r
<Package PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>\r
\r
**/\r
\r
-\r
-\r
-extern VOID *gHobList;\r
-\r
+#include "HobLib.h"\r
\r
/**\r
Returns the pointer to the HOB list.\r
--- /dev/null
+/** @file\r
+ Internal include file of DXE Entry Point HOB Library.\r
+\r
+ Copyright (c) 2006, 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: HobLib.h\r
+\r
+**/\r
+\r
+#ifndef __DXE_ENTRY_POINT_HOB_LIB_H__\r
+#define __DXE_ENTRY_POINT_HOB_LIB_H__\r
+\r
+extern VOID *gHobList;\r
+\r
+#endif\r
--- /dev/null
+/** @file\r
+ Internal include file of DXE CPU IO Library.\r
+\r
+ Copyright (c) 2006, 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: DxeCpuIoLibInternal.h\r
+\r
+**/\r
+\r
+#ifndef __DXE_CPUIO_LIB_INTERNAL_H__\r
+#define __DXE_CPUIO_LIB_INTERNAL_H__\r
+\r
+/**\r
+ Reads registers in the EFI CPU I/O space.\r
+\r
+ Reads the I/O port specified by Port with registers width specified by Width.\r
+ The read value is returned. If such operations are not supported, then ASSERT().\r
+ This function must guarantee that all I/O read and write operations are serialized.\r
+\r
+ @param Port The base address of the I/O operation.\r
+ The caller is responsible for aligning the Address if required.\r
+ @param Width The width of the I/O operation.\r
+\r
+ @return Data read from registers in the EFI CPU I/O space.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+IoReadWorker (\r
+ IN UINTN Port,\r
+ IN EFI_CPU_IO_PROTOCOL_WIDTH Width\r
+ );\r
+\r
+/**\r
+ Writes registers in the EFI CPU I/O space.\r
+\r
+ Writes the I/O port specified by Port with registers width and value specified by Width\r
+ and Data respectively. Data is returned. If such operations are not supported, then ASSERT().\r
+ This function must guarantee that all I/O read and write operations are serialized.\r
+\r
+ @param Port The base address of the I/O operation.\r
+ The caller is responsible for aligning the Address if required.\r
+ @param Width The width of the I/O operation.\r
+ @param Data The value to write to the I/O port.\r
+\r
+ @return The paramter of Data.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+IoWriteWorker (\r
+ IN UINTN Port,\r
+ IN EFI_CPU_IO_PROTOCOL_WIDTH Width,\r
+ IN UINT64 Data\r
+ );\r
+\r
+/**\r
+ Reads memory-mapped registers in the EFI system memory space.\r
+\r
+ Reads the MMIO registers specified by Address with registers width specified by Width.\r
+ The read value is returned. If such operations are not supported, then ASSERT().\r
+ This function must guarantee that all MMIO read and write operations are serialized.\r
+\r
+ @param Address The MMIO register to read.\r
+ The caller is responsible for aligning the Address if required.\r
+ @param Width The width of the I/O operation.\r
+\r
+ @return Data read from registers in the EFI system memory space.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+MmioReadWorker (\r
+ IN UINTN Address,\r
+ IN EFI_CPU_IO_PROTOCOL_WIDTH Width\r
+ );\r
+\r
+/**\r
+ Writes memory-mapped registers in the EFI system memory space.\r
+\r
+ Writes the MMIO registers specified by Address with registers width and value specified by Width\r
+ and Data respectively. Data is returned. If such operations are not supported, then ASSERT().\r
+ This function must guarantee that all MMIO read and write operations are serialized.\r
+\r
+ @param Address The MMIO register to read.\r
+ The caller is responsible for aligning the Address if required.\r
+ @param Width The width of the I/O operation.\r
+\r
+ @return Data read from registers in the EFI system memory space.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+MmioWriteWorker (\r
+ IN UINTN Address,\r
+ IN EFI_CPU_IO_PROTOCOL_WIDTH Width,\r
+ IN UINT64 Data\r
+ );\r
+\r
+#endif\r
<SourceFiles>\r
<Filename>IoLib.c</Filename>\r
<Filename>IoHighLevel.c</Filename>\r
+ <Filename>DxeCpuIoLibInternal.h</Filename>\r
</SourceFiles>\r
<PackageDependencies>\r
<Package PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>\r
IN UINT8 OrData\r
)\r
{\r
- return IoWrite8 (Port, IoRead8 (Port) | OrData);\r
+ return IoWrite8 (Port, (UINT8) (IoRead8 (Port) | OrData));\r
}\r
\r
/**\r
IN UINT8 AndData\r
)\r
{\r
- return IoWrite8 (Port, IoRead8 (Port) & AndData);\r
+ return IoWrite8 (Port, (UINT8) (IoRead8 (Port) & AndData));\r
}\r
\r
/**\r
IN UINT8 OrData\r
)\r
{\r
- return IoWrite8 (Port, (IoRead8 (Port) & AndData) | OrData);\r
+ return IoWrite8 (Port, (UINT8) ((IoRead8 (Port) & AndData) | OrData));\r
}\r
\r
/**\r
IN UINT16 OrData\r
)\r
{\r
- return IoWrite16 (Port, IoRead16 (Port) | OrData);\r
+ return IoWrite16 (Port, (UINT16) (IoRead16 (Port) | OrData));\r
}\r
\r
/**\r
IN UINT16 AndData\r
)\r
{\r
- return IoWrite16 (Port, IoRead16 (Port) & AndData);\r
+ return IoWrite16 (Port, (UINT16) (IoRead16 (Port) & AndData));\r
}\r
\r
/**\r
IN UINT16 OrData\r
)\r
{\r
- return IoWrite16 (Port, (IoRead16 (Port) & AndData) | OrData);\r
+ return IoWrite16 (Port, (UINT16) ((IoRead16 (Port) & AndData) | OrData));\r
}\r
\r
/**\r
IN UINT8 OrData\r
)\r
{\r
- return MmioWrite8 (Address, MmioRead8 (Address) | OrData);\r
+ return MmioWrite8 (Address, (UINT8) (MmioRead8 (Address) | OrData));\r
}\r
\r
/**\r
IN UINT8 AndData\r
)\r
{\r
- return MmioWrite8 (Address, MmioRead8 (Address) & AndData);\r
+ return MmioWrite8 (Address, (UINT8) (MmioRead8 (Address) & AndData));\r
}\r
\r
/**\r
IN UINT8 OrData\r
)\r
{\r
- return MmioWrite8 (Address, (MmioRead8 (Address) & AndData) | OrData);\r
+ return MmioWrite8 (Address, (UINT8) ((MmioRead8 (Address) & AndData) | OrData));\r
}\r
\r
/**\r
IN UINT16 OrData\r
)\r
{\r
- return MmioWrite16 (Address, MmioRead16 (Address) | OrData);\r
+ return MmioWrite16 (Address, (UINT16) (MmioRead16 (Address) | OrData));\r
}\r
\r
/**\r
IN UINT16 AndData\r
)\r
{\r
- return MmioWrite16 (Address, MmioRead16 (Address) & AndData);\r
+ return MmioWrite16 (Address, (UINT16) (MmioRead16 (Address) & AndData));\r
}\r
\r
/**\r
IN UINT16 OrData\r
)\r
{\r
- return MmioWrite16 (Address, (MmioRead16 (Address) & AndData) | OrData);\r
+ return MmioWrite16 (Address, (UINT16) ((MmioRead16 (Address) & AndData) | OrData));\r
}\r
\r
/**\r
\r
**/\r
\r
+#include "DxeCpuIoLibInternal.h"\r
+\r
//\r
// Globle varible to cache pointer to CpuIo protocol.\r
//\r
</LibraryClassDefinitions>\r
<SourceFiles>\r
<Filename>MemoryAllocationLib.c</Filename>\r
+ <Filename>MemoryAllocationLibInternals.h</Filename>\r
</SourceFiles>\r
<PackageDependencies>\r
<Package PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>\r
\r
**/\r
\r
+#include "MemoryAllocationLibInternals.h"\r
\r
/**\r
Allocates one or more 4KB pages of a certain memory type.\r
--- /dev/null
+/** @file\r
+ Internal include file of DXE Memory Allocation Library.\r
+\r
+ Copyright (c) 2006, 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: MemoryAllocationLibInternals.h\r
+\r
+**/\r
+\r
+#ifndef __DXE_MEMORY_ALLOCATION_LIB_INTERNALS_H__\r
+#define __DXE_MEMORY_ALLOCATION_LIB_INTERNALS_H__\r
+\r
+/**\r
+ Allocates one or more 4KB pages of a certain memory type.\r
+\r
+ Allocates the number of 4KB pages of a certain memory type and returns a pointer to the allocated\r
+ buffer. The buffer returned is aligned on a 4KB boundary. If Pages is 0, then NULL is returned.\r
+ If there is not enough memory remaining to satisfy the request, then NULL is returned.\r
+\r
+ @param MemoryType The type of memory to allocate.\r
+ @param Pages The number of 4 KB pages to allocate.\r
+\r
+ @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+InternalAllocatePages (\r
+ IN EFI_MEMORY_TYPE MemoryType, \r
+ IN UINTN Pages\r
+ );\r
+\r
+/**\r
+ Allocates one or more 4KB pages of a certain memory type at a specified alignment.\r
+\r
+ Allocates the number of 4KB pages specified by Pages of a certain memory type with an alignment\r
+ specified by Alignment. The allocated buffer is returned. If Pages is 0, then NULL is returned.\r
+ If there is not enough memory at the specified alignment remaining to satisfy the request, then\r
+ NULL is returned.\r
+ If Alignment is not a power of two and Alignment is not zero, then ASSERT().\r
+\r
+ @param MemoryType The type of memory to allocate.\r
+ @param Pages The number of 4 KB pages to allocate.\r
+ @param Alignment The requested alignment of the allocation. Must be a power of two.\r
+ If Alignment is zero, then byte alignment is used.\r
+\r
+ @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+InternalAllocateAlignedPages (\r
+ IN EFI_MEMORY_TYPE MemoryType, \r
+ IN UINTN Pages,\r
+ IN UINTN Alignment\r
+ );\r
+\r
+/**\r
+ Allocates a buffer of a certain pool type.\r
+\r
+ Allocates the number bytes specified by AllocationSize of a certain pool type and returns a\r
+ pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is\r
+ returned. If there is not enough memory remaining to satisfy the request, then NULL is returned.\r
+\r
+ @param MemoryType The type of memory to allocate.\r
+ @param AllocationSize The number of bytes to allocate.\r
+\r
+ @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+InternalAllocatePool (\r
+ IN EFI_MEMORY_TYPE MemoryType, \r
+ IN UINTN AllocationSize\r
+ );\r
+\r
+/**\r
+ Allocates and zeros a buffer of a certian pool type.\r
+\r
+ Allocates the number bytes specified by AllocationSize of a certian pool type, clears the buffer\r
+ with zeros, and returns a pointer to the allocated buffer. If AllocationSize is 0, then a valid\r
+ buffer of 0 size is returned. If there is not enough memory remaining to satisfy the request,\r
+ then NULL is returned.\r
+\r
+ @param PoolType The type of memory to allocate.\r
+ @param AllocationSize The number of bytes to allocate and zero.\r
+\r
+ @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+InternalAllocateZeroPool (\r
+ IN EFI_MEMORY_TYPE PoolType, \r
+ IN UINTN AllocationSize\r
+ );\r
+\r
+/**\r
+ Copies a buffer to an allocated buffer of a certian pool type.\r
+\r
+ Allocates the number bytes specified by AllocationSize of a certian pool type, copies\r
+ AllocationSize bytes from Buffer to the newly allocated buffer, and returns a pointer to the\r
+ allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there\r
+ is not enough memory remaining to satisfy the request, then NULL is returned.\r
+ If Buffer is NULL, then ASSERT().\r
+ If AllocationSize is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT(). \r
+\r
+ @param PoolType The type of pool to allocate.\r
+ @param AllocationSize The number of bytes to allocate and zero.\r
+ @param Buffer The buffer to copy to the allocated buffer.\r
+\r
+ @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+InternalAllocateCopyPool (\r
+ IN EFI_MEMORY_TYPE PoolType, \r
+ IN UINTN AllocationSize,\r
+ IN CONST VOID *Buffer\r
+ );\r
+\r
+/**\r
+ Allocates a buffer of a certain pool type at a specified alignment.\r
+\r
+ Allocates the number bytes specified by AllocationSize of a certain pool type with an alignment\r
+ specified by Alignment. The allocated buffer is returned. If AllocationSize is 0, then a valid\r
+ buffer of 0 size is returned. If there is not enough memory at the specified alignment remaining\r
+ to satisfy the request, then NULL is returned.\r
+ If Alignment is not a power of two and Alignment is not zero, then ASSERT().\r
+\r
+ @param PoolType The type of pool to allocate.\r
+ @param AllocationSize The number of bytes to allocate.\r
+ @param Alignment The requested alignment of the allocation. Must be a power of two. If Alignment is zero, then byte alignment is used.\r
+ If Alignment is zero, then byte alignment is used.\r
+\r
+ @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+InternalAllocateAlignedPool (\r
+ IN EFI_MEMORY_TYPE PoolType,\r
+ IN UINTN AllocationSize,\r
+ IN UINTN Alignment\r
+ );\r
+\r
+/**\r
+ Allocates and zeros a buffer of a certain pool type at a specified alignment.\r
+\r
+ Allocates the number bytes specified by AllocationSize of a certain pool type with an alignment\r
+ specified by Alignment, clears the buffer with zeros, and returns a pointer to the allocated\r
+ buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there is not\r
+ enough memory at the specified alignment remaining to satisfy the request, then NULL is returned.\r
+ If Alignment is not a power of two and Alignment is not zero, then ASSERT().\r
+\r
+ @param PoolType The type of pool to allocate.\r
+ @param AllocationSize The number of bytes to allocate.\r
+ @param Alignment The requested alignment of the allocation. Must be a power of two.\r
+ If Alignment is zero, then byte alignment is used.\r
+\r
+ @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+InternalAllocateAlignedZeroPool (\r
+ IN EFI_MEMORY_TYPE PoolType,\r
+ IN UINTN AllocationSize,\r
+ IN UINTN Alignment\r
+ );\r
+\r
+/**\r
+ Copies a buffer to an allocated buffer of a certain pool type at a specified alignment.\r
+\r
+ Allocates the number bytes specified by AllocationSize of a certain pool type with an alignment\r
+ specified by Alignment. The allocated buffer is returned. If AllocationSize is 0, then a valid\r
+ buffer of 0 size is returned. If there is not enough memory at the specified alignment remaining\r
+ to satisfy the request, then NULL is returned.\r
+ If Alignment is not a power of two and Alignment is not zero, then ASSERT().\r
+\r
+ @param PoolType The type of pool to allocate.\r
+ @param AllocationSize The number of bytes to allocate.\r
+ @param Buffer The buffer to copy to the allocated buffer.\r
+ @param Alignment The requested alignment of the allocation. Must be a power of two.\r
+ If Alignment is zero, then byte alignment is used.\r
+\r
+ @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+InternalAllocateAlignedCopyPool (\r
+ IN EFI_MEMORY_TYPE PoolType,\r
+ IN UINTN AllocationSize,\r
+ IN CONST VOID *Buffer,\r
+ IN UINTN Alignment\r
+ );\r
+\r
+#endif\r
\r
**/\r
\r
+#include "MemLibInternals.h"\r
+\r
VOID *\r
EFIAPI\r
InternalMemCopyMem (\r
IN CONST GUID *Guid2\r
)\r
{\r
- return (BOOLEAN)(\r
- ReadUnaligned64 ((CONST UINT64*)Guid1)\r
- == ReadUnaligned64 ((CONST UINT64*)Guid2) &&\r
- ReadUnaligned64 ((CONST UINT64*)Guid1 + 1)\r
- == ReadUnaligned64 ((CONST UINT64*)Guid2 + 1)\r
- );\r
+ UINT64 LowPartOfGuid1;\r
+ UINT64 LowPartOfGuid2;\r
+ UINT64 HighPartOfGuid1;\r
+ UINT64 HighPartOfGuid2;\r
+\r
+ LowPartOfGuid1 = ReadUnaligned64 ((CONST UINT64*) Guid1);\r
+ LowPartOfGuid2 = ReadUnaligned64 ((CONST UINT64*) Guid2);\r
+ HighPartOfGuid1 = ReadUnaligned64 ((CONST UINT64*) Guid1 + 1);\r
+ HighPartOfGuid2 = ReadUnaligned64 ((CONST UINT64*) Guid2 + 1);\r
+\r
+ return (BOOLEAN) (LowPartOfGuid1 == LowPartOfGuid2 && HighPartOfGuid1 == HighPartOfGuid2);\r
}\r
\r
/**\r
@retval EFI_UNSUPPORTED Status Code Protocol is not available.\r
\r
**/\r
+STATIC\r
EFI_STATUS\r
InternalReportStatusCode (\r
IN EFI_STATUS_CODE_TYPE Type,\r
@return The size, in bytes, of DevicePath.\r
\r
**/\r
+STATIC\r
UINTN\r
InternalReportStatusCodeDevicePathSize (\r
IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath\r
//\r
if (((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_PROGRESS_CODE) ||\r
((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE) ) {\r
- *PostCode = (UINT8) (((Value & EFI_STATUS_CODE_CLASS_MASK) >> 24) << 5);\r
- *PostCode |= (UINT8) (((Value & EFI_STATUS_CODE_SUBCLASS_MASK) >> 16) & 0x1f);\r
+ *PostCode = (UINT8) ((((Value & EFI_STATUS_CODE_CLASS_MASK) >> 24) << 5) |\r
+ (((Value & EFI_STATUS_CODE_SUBCLASS_MASK) >> 16) & 0x1f));\r
return TRUE;\r
}\r
return FALSE;\r
VOID\r
)\r
{\r
- return ((PcdGet8(PcdReportStatusCodePropertyMask) & REPORT_STATUS_CODE_PROPERTY_PROGRESS_CODE_ENABLED) != 0);\r
+ return (BOOLEAN) ((PcdGet8(PcdReportStatusCodePropertyMask) & REPORT_STATUS_CODE_PROPERTY_PROGRESS_CODE_ENABLED) != 0);\r
}\r
\r
\r
VOID\r
)\r
{\r
- return ((PcdGet8(PcdReportStatusCodePropertyMask) & REPORT_STATUS_CODE_PROPERTY_ERROR_CODE_ENABLED) != 0);\r
+ return (BOOLEAN) ((PcdGet8(PcdReportStatusCodePropertyMask) & REPORT_STATUS_CODE_PROPERTY_ERROR_CODE_ENABLED) != 0);\r
}\r
\r
\r
VOID\r
)\r
{\r
- return ((PcdGet8(PcdReportStatusCodePropertyMask) & REPORT_STATUS_CODE_PROPERTY_DEBUG_CODE_ENABLED) != 0);\r
+ return (BOOLEAN) ((PcdGet8(PcdReportStatusCodePropertyMask) & REPORT_STATUS_CODE_PROPERTY_DEBUG_CODE_ENABLED) != 0);\r
}\r
EFI_DEBUG_ASSERT_DATA *AssertData;\r
UINTN TotalSize;\r
CHAR8 *Temp;\r
+ UINTN FileNameLength;\r
+ UINTN DescriptionLength;\r
\r
//\r
// Make sure it will all fit in the passed in buffer\r
//\r
- TotalSize = sizeof (EFI_DEBUG_ASSERT_DATA) + AsciiStrLen (FileName) + 1 + AsciiStrLen (Description) + 1;\r
+ FileNameLength = AsciiStrLen (FileName);\r
+ DescriptionLength = AsciiStrLen (Description);\r
+ TotalSize = sizeof (EFI_DEBUG_ASSERT_DATA) + FileNameLength + 1 + DescriptionLength + 1;\r
if (TotalSize <= EFI_STATUS_CODE_DATA_MAX_SIZE) {\r
//\r
// Fill in EFI_DEBUG_ASSERT_DATA\r
VOID\r
)\r
{\r
- return ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED) != 0);\r
+ return (BOOLEAN) ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED) != 0);\r
}\r
\r
\r
VOID\r
)\r
{\r
- return ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_DEBUG_PRINT_ENABLED) != 0);\r
+ return (BOOLEAN) ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_DEBUG_PRINT_ENABLED) != 0);\r
}\r
\r
\r
VOID\r
)\r
{\r
- return ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_DEBUG_CODE_ENABLED) != 0);\r
+ return (BOOLEAN) ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_DEBUG_CODE_ENABLED) != 0);\r
}\r
\r
\r
VOID\r
)\r
{\r
- return ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_CLEAR_MEMORY_ENABLED) != 0);\r
+ return (BOOLEAN) ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_CLEAR_MEMORY_ENABLED) != 0);\r
}\r
VOID\r
)\r
{\r
- return ((PcdGet8(PcdPostCodePropertyMask) & POST_CODE_PROPERTY_POST_CODE_ENABLED) != 0);\r
+ return (BOOLEAN) ((PcdGet8(PcdPostCodePropertyMask) & POST_CODE_PROPERTY_POST_CODE_ENABLED) != 0);\r
}\r
\r
\r
VOID\r
)\r
{\r
- return ((PcdGet8(PcdPostCodePropertyMask) & POST_CODE_PROPERTY_POST_CODE_ENABLED) != 0);\r
+ return (BOOLEAN) ((PcdGet8(PcdPostCodePropertyMask) & POST_CODE_PROPERTY_POST_CODE_ENABLED) != 0);\r
}\r
@return The address of new HOB.\r
\r
**/\r
+STATIC\r
VOID *\r
InternalPeiCreateHob (\r
IN UINT16 Type,\r
IN UINT8 OrData\r
)\r
{\r
- return IoWrite8 (Port, IoRead8 (Port) | OrData);\r
+ return IoWrite8 (Port, (UINT8) (IoRead8 (Port) | OrData));\r
}\r
\r
/**\r
IN UINT8 AndData\r
)\r
{\r
- return IoWrite8 (Port, IoRead8 (Port) & AndData);\r
+ return IoWrite8 (Port, (UINT8) (IoRead8 (Port) & AndData));\r
}\r
\r
/**\r
IN UINT8 OrData\r
)\r
{\r
- return IoWrite8 (Port, (IoRead8 (Port) & AndData) | OrData);\r
+ return IoWrite8 (Port, (UINT8) ((IoRead8 (Port) & AndData) | OrData));\r
}\r
\r
/**\r
IN UINT16 OrData\r
)\r
{\r
- return IoWrite16 (Port, IoRead16 (Port) | OrData);\r
+ return IoWrite16 (Port, (UINT16) (IoRead16 (Port) | OrData));\r
}\r
\r
/**\r
IN UINT16 AndData\r
)\r
{\r
- return IoWrite16 (Port, IoRead16 (Port) & AndData);\r
+ return IoWrite16 (Port, (UINT16) (IoRead16 (Port) & AndData));\r
}\r
\r
/**\r
IN UINT16 OrData\r
)\r
{\r
- return IoWrite16 (Port, (IoRead16 (Port) & AndData) | OrData);\r
+ return IoWrite16 (Port, (UINT16) ((IoRead16 (Port) & AndData) | OrData));\r
}\r
\r
/**\r
IN UINT8 OrData\r
)\r
{\r
- return MmioWrite8 (Address, MmioRead8 (Address) | OrData);\r
+ return MmioWrite8 (Address, (UINT8) (MmioRead8 (Address) | OrData));\r
}\r
\r
/**\r
IN UINT8 AndData\r
)\r
{\r
- return MmioWrite8 (Address, MmioRead8 (Address) & AndData);\r
+ return MmioWrite8 (Address, (UINT8) (MmioRead8 (Address) & AndData));\r
}\r
\r
/**\r
IN UINT8 OrData\r
)\r
{\r
- return MmioWrite8 (Address, (MmioRead8 (Address) & AndData) | OrData);\r
+ return MmioWrite8 (Address, (UINT8) ((MmioRead8 (Address) & AndData) | OrData));\r
}\r
\r
/**\r
IN UINT16 OrData\r
)\r
{\r
- return MmioWrite16 (Address, MmioRead16 (Address) | OrData);\r
+ return MmioWrite16 (Address, (UINT16) (MmioRead16 (Address) | OrData));\r
}\r
\r
/**\r
IN UINT16 AndData\r
)\r
{\r
- return MmioWrite16 (Address, MmioRead16 (Address) & AndData);\r
+ return MmioWrite16 (Address, (UINT16) (MmioRead16 (Address) & AndData));\r
}\r
\r
/**\r
IN UINT16 OrData\r
)\r
{\r
- return MmioWrite16 (Address, (MmioRead16 (Address) & AndData) | OrData);\r
+ return MmioWrite16 (Address, (UINT16) ((MmioRead16 (Address) & AndData) | OrData));\r
}\r
\r
/**\r
\r
**/\r
\r
+#include "MemoryAllocationLibInternals.h"\r
\r
/**\r
Allocates one or more 4KB pages of a certain memory type.\r
--- /dev/null
+/** @file\r
+ Internal include file of PEI Memory Allocation Library.\r
+\r
+ Copyright (c) 2006, 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: MemoryAllocationLibInternals.h\r
+\r
+**/\r
+\r
+#ifndef __PEI_MEMORY_ALLOCATION_LIB_INTERNALS_H__\r
+#define __PEI_MEMORY_ALLOCATION_LIB_INTERNALS_H__\r
+\r
+/**\r
+ Allocates one or more 4KB pages of a certain memory type.\r
+\r
+ Allocates the number of 4KB pages of a certain memory type and returns a pointer to the allocated\r
+ buffer. The buffer returned is aligned on a 4KB boundary. If Pages is 0, then NULL is returned.\r
+ If there is not enough memory remaining to satisfy the request, then NULL is returned.\r
+\r
+ @param MemoryType The type of memory to allocate.\r
+ @param Pages The number of 4 KB pages to allocate.\r
+\r
+ @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+InternalAllocatePages (\r
+ IN EFI_MEMORY_TYPE MemoryType, \r
+ IN UINTN Pages\r
+ );\r
+\r
+/**\r
+ Allocates one or more 4KB pages of a certain memory type at a specified alignment.\r
+\r
+ Allocates the number of 4KB pages specified by Pages of a certain memory type with an alignment\r
+ specified by Alignment. The allocated buffer is returned. If Pages is 0, then NULL is returned.\r
+ If there is not enough memory at the specified alignment remaining to satisfy the request, then\r
+ NULL is returned.\r
+ If Alignment is not a power of two and Alignment is not zero, then ASSERT().\r
+\r
+ @param MemoryType The type of memory to allocate.\r
+ @param Pages The number of 4 KB pages to allocate.\r
+ @param Alignment The requested alignment of the allocation. Must be a power of two.\r
+ If Alignment is zero, then byte alignment is used.\r
+\r
+ @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+InternalAllocateAlignedPages (\r
+ IN EFI_MEMORY_TYPE MemoryType, \r
+ IN UINTN Pages,\r
+ IN UINTN Alignment\r
+ );\r
+\r
+/**\r
+ Allocates a buffer of a certain pool type.\r
+\r
+ Allocates the number bytes specified by AllocationSize of a certain pool type and returns a\r
+ pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is\r
+ returned. If there is not enough memory remaining to satisfy the request, then NULL is returned.\r
+\r
+ @param MemoryType The type of memory to allocate.\r
+ @param AllocationSize The number of bytes to allocate.\r
+\r
+ @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+InternalAllocatePool (\r
+ IN EFI_MEMORY_TYPE MemoryType, \r
+ IN UINTN AllocationSize\r
+ );\r
+\r
+/**\r
+ Allocates and zeros a buffer of a certian pool type.\r
+\r
+ Allocates the number bytes specified by AllocationSize of a certian pool type, clears the buffer\r
+ with zeros, and returns a pointer to the allocated buffer. If AllocationSize is 0, then a valid\r
+ buffer of 0 size is returned. If there is not enough memory remaining to satisfy the request,\r
+ then NULL is returned.\r
+\r
+ @param PoolType The type of memory to allocate.\r
+ @param AllocationSize The number of bytes to allocate and zero.\r
+\r
+ @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+InternalAllocateZeroPool (\r
+ IN EFI_MEMORY_TYPE PoolType, \r
+ IN UINTN AllocationSize\r
+ );\r
+\r
+/**\r
+ Copies a buffer to an allocated buffer of a certian pool type.\r
+\r
+ Allocates the number bytes specified by AllocationSize of a certian pool type, copies\r
+ AllocationSize bytes from Buffer to the newly allocated buffer, and returns a pointer to the\r
+ allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there\r
+ is not enough memory remaining to satisfy the request, then NULL is returned.\r
+ If Buffer is NULL, then ASSERT().\r
+ If AllocationSize is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT(). \r
+\r
+ @param PoolType The type of pool to allocate.\r
+ @param AllocationSize The number of bytes to allocate and zero.\r
+ @param Buffer The buffer to copy to the allocated buffer.\r
+\r
+ @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+InternalAllocateCopyPool (\r
+ IN EFI_MEMORY_TYPE PoolType, \r
+ IN UINTN AllocationSize,\r
+ IN CONST VOID *Buffer\r
+ );\r
+\r
+/**\r
+ Allocates a buffer of a certain pool type at a specified alignment.\r
+\r
+ Allocates the number bytes specified by AllocationSize of a certain pool type with an alignment\r
+ specified by Alignment. The allocated buffer is returned. If AllocationSize is 0, then a valid\r
+ buffer of 0 size is returned. If there is not enough memory at the specified alignment remaining\r
+ to satisfy the request, then NULL is returned.\r
+ If Alignment is not a power of two and Alignment is not zero, then ASSERT().\r
+\r
+ @param PoolType The type of pool to allocate.\r
+ @param AllocationSize The number of bytes to allocate.\r
+ @param Alignment The requested alignment of the allocation. Must be a power of two. If Alignment is zero, then byte alignment is used.\r
+ If Alignment is zero, then byte alignment is used.\r
+\r
+ @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+InternalAllocateAlignedPool (\r
+ IN EFI_MEMORY_TYPE PoolType,\r
+ IN UINTN AllocationSize,\r
+ IN UINTN Alignment\r
+ );\r
+\r
+/**\r
+ Allocates and zeros a buffer of a certain pool type at a specified alignment.\r
+\r
+ Allocates the number bytes specified by AllocationSize of a certain pool type with an alignment\r
+ specified by Alignment, clears the buffer with zeros, and returns a pointer to the allocated\r
+ buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there is not\r
+ enough memory at the specified alignment remaining to satisfy the request, then NULL is returned.\r
+ If Alignment is not a power of two and Alignment is not zero, then ASSERT().\r
+\r
+ @param PoolType The type of pool to allocate.\r
+ @param AllocationSize The number of bytes to allocate.\r
+ @param Alignment The requested alignment of the allocation. Must be a power of two.\r
+ If Alignment is zero, then byte alignment is used.\r
+\r
+ @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+InternalAllocateAlignedZeroPool (\r
+ IN EFI_MEMORY_TYPE PoolType,\r
+ IN UINTN AllocationSize,\r
+ IN UINTN Alignment\r
+ );\r
+\r
+/**\r
+ Copies a buffer to an allocated buffer of a certain pool type at a specified alignment.\r
+\r
+ Allocates the number bytes specified by AllocationSize of a certain pool type with an alignment\r
+ specified by Alignment. The allocated buffer is returned. If AllocationSize is 0, then a valid\r
+ buffer of 0 size is returned. If there is not enough memory at the specified alignment remaining\r
+ to satisfy the request, then NULL is returned.\r
+ If Alignment is not a power of two and Alignment is not zero, then ASSERT().\r
+\r
+ @param PoolType The type of pool to allocate.\r
+ @param AllocationSize The number of bytes to allocate.\r
+ @param Buffer The buffer to copy to the allocated buffer.\r
+ @param Alignment The requested alignment of the allocation. Must be a power of two.\r
+ If Alignment is zero, then byte alignment is used.\r
+\r
+ @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+InternalAllocateAlignedCopyPool (\r
+ IN EFI_MEMORY_TYPE PoolType,\r
+ IN UINTN AllocationSize,\r
+ IN CONST VOID *Buffer,\r
+ IN UINTN Alignment\r
+ );\r
+\r
+#endif\r
</LibraryClassDefinitions>\r
<SourceFiles>\r
<Filename>MemoryAllocationLib.c</Filename>\r
+ <Filename>MemoryAllocationLibInternals.h</Filename>\r
</SourceFiles>\r
<PackageDependencies>\r
<Package PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>\r
\r
**/\r
\r
+#include "MemLibInternals.h"\r
+\r
VOID *\r
EFIAPI\r
InternalMemCopyMem (\r
IN CONST GUID *Guid2\r
)\r
{\r
- return (BOOLEAN)(\r
- ReadUnaligned64 ((CONST UINT64*)Guid1)\r
- == ReadUnaligned64 ((CONST UINT64*)Guid2) &&\r
- ReadUnaligned64 ((CONST UINT64*)Guid1 + 1)\r
- == ReadUnaligned64 ((CONST UINT64*)Guid2 + 1)\r
- );\r
+ UINT64 LowPartOfGuid1;\r
+ UINT64 LowPartOfGuid2;\r
+ UINT64 HighPartOfGuid1;\r
+ UINT64 HighPartOfGuid2;\r
+\r
+ LowPartOfGuid1 = ReadUnaligned64 ((CONST UINT64*) Guid1);\r
+ LowPartOfGuid2 = ReadUnaligned64 ((CONST UINT64*) Guid2);\r
+ HighPartOfGuid1 = ReadUnaligned64 ((CONST UINT64*) Guid1 + 1);\r
+ HighPartOfGuid2 = ReadUnaligned64 ((CONST UINT64*) Guid2 + 1);\r
+\r
+ return (BOOLEAN) (LowPartOfGuid1 == LowPartOfGuid2 && HighPartOfGuid1 == HighPartOfGuid2);\r
}\r
\r
/**\r
@retval PCD_PPI * The pointer to the PCD_PPI.\r
\r
**/\r
+STATIC\r
PCD_PPI *\r
GetPcdPpiPtr (\r
VOID\r
@retval EFI_UNSUPPORTED Status Code Protocol is not available.\r
\r
**/\r
+STATIC\r
EFI_STATUS\r
InternalReportStatusCode (\r
IN EFI_STATUS_CODE_TYPE Type,\r
//\r
if (((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_PROGRESS_CODE) ||\r
((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE) ) {\r
- *PostCode = (UINT8) (((Value & EFI_STATUS_CODE_CLASS_MASK) >> 24) << 5);\r
- *PostCode |= (UINT8) (((Value & EFI_STATUS_CODE_SUBCLASS_MASK) >> 16) & 0x1f);\r
+ *PostCode = (UINT8) ((((Value & EFI_STATUS_CODE_CLASS_MASK) >> 24) << 5) |\r
+ (((Value & EFI_STATUS_CODE_SUBCLASS_MASK) >> 16) & 0x1f));\r
return TRUE;\r
}\r
return FALSE;\r
VOID\r
)\r
{\r
- return ((PcdGet8(PcdReportStatusCodePropertyMask) & REPORT_STATUS_CODE_PROPERTY_PROGRESS_CODE_ENABLED) != 0);\r
+ return (BOOLEAN) ((PcdGet8(PcdReportStatusCodePropertyMask) & REPORT_STATUS_CODE_PROPERTY_PROGRESS_CODE_ENABLED) != 0);\r
}\r
\r
\r
VOID\r
)\r
{\r
- return ((PcdGet8(PcdReportStatusCodePropertyMask) & REPORT_STATUS_CODE_PROPERTY_ERROR_CODE_ENABLED) != 0);\r
+ return (BOOLEAN) ((PcdGet8(PcdReportStatusCodePropertyMask) & REPORT_STATUS_CODE_PROPERTY_ERROR_CODE_ENABLED) != 0);\r
}\r
\r
\r
VOID\r
)\r
{\r
- return ((PcdGet8(PcdReportStatusCodePropertyMask) & REPORT_STATUS_CODE_PROPERTY_DEBUG_CODE_ENABLED) != 0);\r
+ return (BOOLEAN) ((PcdGet8(PcdReportStatusCodePropertyMask) & REPORT_STATUS_CODE_PROPERTY_DEBUG_CODE_ENABLED) != 0);\r
}\r
\r
--*/\r
\r
-\r
-/**\r
- Reads the current value of Kr1.\r
-\r
- @return The current value of Kr1.\r
-\r
-**/\r
-UINT64\r
-EFIAPI\r
-AsmReadKr1 (\r
- VOID\r
- );\r
-\r
-/**\r
- Writes the current value of Kr1.\r
-\r
- @param Value The 64-bit value to write to Kr1.\r
-\r
-**/\r
-VOID\r
-EFIAPI\r
-AsmWriteKr1 (\r
- IN UINT64 Value\r
- );\r
+#include "PeiServicesTablePointerLibInternals.h"\r
\r
/**\r
The function returns the pointer to PeiServices.\r
--- /dev/null
+/** @file\r
+ Include file for internal functions of PEI Services table pointer libary.\r
+\r
+ Copyright (c) 2006, 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: PeiServicesTablePointerLibInternals.h\r
+\r
+**/\r
+\r
+#ifndef __PEI_SERVICES_TABLE_POINTER_LIB_INTERTALS_H__\r
+#define __PEI_SERVICES_TABLE_POINTER_LIB_INTERTALS_H__\r
+\r
+/**\r
+ Reads the current value of Kr1.\r
+\r
+ @return The current value of Kr1.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+AsmReadKr1 (\r
+ VOID\r
+ );\r
+\r
+/**\r
+ Writes the current value of Kr1.\r
+\r
+ @param Value The 64-bit value to write to Kr1.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+AsmWriteKr1 (\r
+ IN UINT64 Value\r
+ );\r
+\r
+#endif\r
</LibraryClassDefinitions>\r
<SourceFiles>\r
<Filename>PeiServicesTablePointer.c</Filename>\r
+ <Filename>PeiServicesTablePointerLibInternals.h</Filename>\r
<Filename SupArchList="IPF">Ipf/ReadKr1.s</Filename>\r
<Filename SupArchList="IPF">Ipf/WriteKr1.s</Filename>\r
</SourceFiles>\r
//\r
// Declaration for internal functions\r
//\r
+\r
+/**\r
+ Gets Smbus PPIs.\r
+\r
+ This internal function retrieves Smbus PPI from PPI database.\r
+\r
+ @param PeiServices An indirect pointer to the EFI_PEI_SERVICES published by the PEI Foundation.\r
+\r
+ @return The pointer to Smbus PPI.\r
+\r
+**/\r
+EFI_PEI_SMBUS_PPI *\r
+InternalGetSmbusPpi (\r
+ EFI_PEI_SERVICES **PeiServices\r
+ );\r
+\r
/**\r
Executes an SMBus operation to an SMBus controller. \r
\r
VOID\r
)\r
{\r
- return ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED) != 0);\r
+ return (BOOLEAN) ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED) != 0);\r
}\r
\r
\r
VOID\r
)\r
{\r
- return ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_DEBUG_PRINT_ENABLED) != 0);\r
+ return (BOOLEAN) ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_DEBUG_PRINT_ENABLED) != 0);\r
}\r
\r
\r
VOID\r
)\r
{\r
- return ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_DEBUG_CODE_ENABLED) != 0);\r
+ return (BOOLEAN) ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_DEBUG_CODE_ENABLED) != 0);\r
}\r
\r
\r
VOID\r
)\r
{\r
- return ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_CLEAR_MEMORY_ENABLED) != 0);\r
+ return (BOOLEAN) ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_CLEAR_MEMORY_ENABLED) != 0);\r
}\r
VOID\r
)\r
{\r
- return ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED) != 0);\r
+ return (BOOLEAN) ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED) != 0);\r
}\r
\r
\r
VOID\r
)\r
{\r
- return ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_DEBUG_PRINT_ENABLED) != 0);\r
+ return (BOOLEAN) ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_DEBUG_PRINT_ENABLED) != 0);\r
}\r
\r
\r
VOID\r
)\r
{\r
- return ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_DEBUG_CODE_ENABLED) != 0);\r
+ return (BOOLEAN) ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_DEBUG_CODE_ENABLED) != 0);\r
}\r
\r
\r
VOID\r
)\r
{\r
- return ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_CLEAR_MEMORY_ENABLED) != 0);\r
+ return (BOOLEAN) ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_CLEAR_MEMORY_ENABLED) != 0);\r
}\r
@retval EFI_SUCCESS\r
\r
**/\r
+STATIC\r
EFI_STATUS\r
EFIAPI\r
_DriverUnloadHandler (\r
@param Context Event Context.\r
\r
**/\r
+STATIC\r
VOID\r
EFIAPI\r
_DriverExitBootServices (\r
@retval FALSE Language 1 and language 2 are not the same.\r
\r
**/\r
+STATIC\r
BOOLEAN\r
CompareIso639LanguageCode (\r
IN CONST CHAR8 *Language1,\r
IN CONST CHAR8 *Language2\r
)\r
{\r
- return (BOOLEAN) (ReadUnaligned24 ((CONST UINT32 *) Language1) == ReadUnaligned24 ((CONST UINT32 *) Language2));\r
+ UINT32 Name1;\r
+ UINT32 Name2;\r
+\r
+ Name1 = ReadUnaligned24 ((CONST UINT32 *) Language1);\r
+ Name2 = ReadUnaligned24 ((CONST UINT32 *) Language2);\r
+\r
+ return (BOOLEAN) (Name1 == Name2);\r
}\r
\r
/**\r
checked correctly since it is now mapped into CreateEventEx() in UEFI 2.0.\r
\r
**/\r
+STATIC\r
VOID\r
EFIAPI\r
InternalEmptyFuntion (\r