summaryrefslogtreecommitdiff
path: root/MdePkg/Library
diff options
context:
space:
mode:
authorxli24 <xli24@6f19259b-4bc3-4df7-8a09-765794883524>2007-01-25 06:05:36 +0000
committerxli24 <xli24@6f19259b-4bc3-4df7-8a09-765794883524>2007-01-25 06:05:36 +0000
commit582510249f2fb1334e507b99421b9485f6b89159 (patch)
treecd9d7414885d26e79565cd12ec241af93dc600f2 /MdePkg/Library
parentba3a1cb5bb97ffdea980f188fbd14b08200aeac6 (diff)
downloadedk2-platforms-582510249f2fb1334e507b99421b9485f6b89159.tar.xz
Make MDE package pass intel IPF compiler with /W4 /WX switched on.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@2312 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'MdePkg/Library')
-rw-r--r--MdePkg/Library/BaseLib/BaseLibInternals.h215
-rw-r--r--MdePkg/Library/BaseLib/BitField.c22
-rw-r--r--MdePkg/Library/BaseLib/Ipf/Synchronization.c25
-rw-r--r--MdePkg/Library/BaseLib/Ipf/Unaligned.c22
-rw-r--r--MdePkg/Library/BaseLib/LinkedList.c2
-rw-r--r--MdePkg/Library/BaseLib/LongJump.c34
-rw-r--r--MdePkg/Library/BaseLib/Math64.c16
-rw-r--r--MdePkg/Library/BaseLib/SetJump.c2
-rw-r--r--MdePkg/Library/BaseLib/String.c18
-rw-r--r--MdePkg/Library/BaseLib/SwapBytes16.c2
-rw-r--r--MdePkg/Library/BaseLib/SwapBytes32.c11
-rw-r--r--MdePkg/Library/BaseLib/Synchronization.c95
-rw-r--r--MdePkg/Library/BaseMemoryLib/CopyMem.c2
-rw-r--r--MdePkg/Library/BaseMemoryLib/MemLibGuid.c17
-rw-r--r--MdePkg/Library/BaseMemoryLib/SetMem.c1
-rw-r--r--MdePkg/Library/BaseMemoryLibMmx/MemLibGuid.c17
-rw-r--r--MdePkg/Library/BasePciExpressLib/PciLib.c1
-rw-r--r--MdePkg/Library/BasePeCoffLib/BasePeCoff.c61
-rw-r--r--MdePkg/Library/BasePeCoffLib/BasePeCoffLib.msa1
-rw-r--r--MdePkg/Library/BasePeCoffLib/BasePeCoffLibInternals.h124
-rw-r--r--MdePkg/Library/BasePeCoffLib/Ipf/PeCoffLoaderEx.c2
-rw-r--r--MdePkg/Library/BasePerformanceLibNull/PerformanceLib.c2
-rw-r--r--MdePkg/Library/BasePostCodeLibDebug/PostCode.c4
-rw-r--r--MdePkg/Library/BasePostCodeLibPort80/PostCode.c4
-rw-r--r--MdePkg/Library/BasePrintLib/PrintLibInternal.h28
-rw-r--r--MdePkg/Library/BaseUefiDecompressLib/BaseUefiDecompressLib.c68
-rw-r--r--MdePkg/Library/BaseUefiDecompressLib/BaseUefiDecompressLib.msa1
-rw-r--r--MdePkg/Library/BaseUefiDecompressLib/BaseUefiDecompressLibInternals.h215
-rw-r--r--MdePkg/Library/DxeCoreHobLib/DxeCoreHobLib.msa1
-rw-r--r--MdePkg/Library/DxeCoreHobLib/HobLib.c5
-rw-r--r--MdePkg/Library/DxeCoreHobLib/HobLib.h22
-rw-r--r--MdePkg/Library/DxeIoLibCpuIo/DxeCpuIoLibInternal.h107
-rw-r--r--MdePkg/Library/DxeIoLibCpuIo/DxeIoLibCpuIo.msa1
-rw-r--r--MdePkg/Library/DxeIoLibCpuIo/IoHighLevel.c24
-rw-r--r--MdePkg/Library/DxeIoLibCpuIo/IoLib.c2
-rw-r--r--MdePkg/Library/DxeMemoryAllocationLib/DxeMemoryAllocationLib.msa1
-rw-r--r--MdePkg/Library/DxeMemoryAllocationLib/MemoryAllocationLib.c1
-rw-r--r--MdePkg/Library/DxeMemoryAllocationLib/MemoryAllocationLibInternals.h200
-rw-r--r--MdePkg/Library/DxeMemoryLib/MemLib.c2
-rw-r--r--MdePkg/Library/DxeMemoryLib/MemLibGuid.c17
-rw-r--r--MdePkg/Library/DxeReportStatusCodeLib/ReportStatusCodeLib.c12
-rw-r--r--MdePkg/Library/PeiDxeDebugLibReportStatusCode/DebugLib.c14
-rw-r--r--MdePkg/Library/PeiDxePostCodeLibReportStatusCode/PostCode.c4
-rw-r--r--MdePkg/Library/PeiHobLib/HobLib.c1
-rw-r--r--MdePkg/Library/PeiIoLibCpuIo/IoHighLevel.c24
-rw-r--r--MdePkg/Library/PeiMemoryAllocationLib/MemoryAllocationLib.c1
-rw-r--r--MdePkg/Library/PeiMemoryAllocationLib/MemoryAllocationLibInternals.h200
-rw-r--r--MdePkg/Library/PeiMemoryAllocationLib/PeiMemoryAllocationLib.msa1
-rw-r--r--MdePkg/Library/PeiMemoryLib/MemLib.c2
-rw-r--r--MdePkg/Library/PeiMemoryLib/MemLibGuid.c17
-rw-r--r--MdePkg/Library/PeiPcdLib/PeiPcdLib.c1
-rw-r--r--MdePkg/Library/PeiReportStatusCodeLib/ReportStatusCodeLib.c11
-rw-r--r--MdePkg/Library/PeiServicesTablePointerLibKr1/PeiServicesTablePointer.c25
-rw-r--r--MdePkg/Library/PeiServicesTablePointerLibKr1/PeiServicesTablePointerLibInternals.h44
-rw-r--r--MdePkg/Library/PeiServicesTablePointerLibKr1/PeiServicesTablePointerLibKr1.msa1
-rw-r--r--MdePkg/Library/PeiSmbusLib/InternalSmbusLib.h16
-rw-r--r--MdePkg/Library/UefiDebugLibConOut/DebugLib.c8
-rw-r--r--MdePkg/Library/UefiDebugLibStdErr/DebugLib.c8
-rw-r--r--MdePkg/Library/UefiDriverEntryPoint/DriverEntryPoint.c2
-rw-r--r--MdePkg/Library/UefiLib/UefiLib.c9
-rw-r--r--MdePkg/Library/UefiLib/UefiNotTiano.c1
61 files changed, 1399 insertions, 398 deletions
diff --git a/MdePkg/Library/BaseLib/BaseLibInternals.h b/MdePkg/Library/BaseLib/BaseLibInternals.h
index e9caef3e58..d0b9ef6f20 100644
--- a/MdePkg/Library/BaseLib/BaseLibInternals.h
+++ b/MdePkg/Library/BaseLib/BaseLibInternals.h
@@ -575,4 +575,219 @@ InternalX86DisablePaging64 (
IN UINT32 NewStack
);
+/**
+ Worker function that locates the Node in the List
+
+ By searching the List, finds the location of the Node in List. At the same time,
+ verifies the validity of this list.
+
+ If List is NULL, then ASSERT().
+ If List->ForwardLink is NULL, then ASSERT().
+ If List->backLink is NULL, then ASSERT().
+ If Node is NULL, then ASSERT();
+ If PcdMaximumLinkedListLenth is not zero, and prior to insertion the number
+ of nodes in ListHead, including the ListHead node, is greater than or
+ equal to PcdMaximumLinkedListLength, then ASSERT().
+
+ @param List A pointer to a node in a linked list.
+ @param Node A pointer to one nod.
+
+ @retval TRUE Node is in List
+ @retval FALSE Node isn't in List, or List is invalid
+
+**/
+BOOLEAN
+IsNodeInList (
+ IN CONST LIST_ENTRY *List,
+ IN CONST LIST_ENTRY *Node
+ );
+
+/**
+ Performs an atomic increment of an 32-bit unsigned integer.
+
+ Performs an atomic increment of the 32-bit unsigned integer specified by
+ Value and returns the incremented value. The increment operation must be
+ performed using MP safe mechanisms. The state of the return value is not
+ guaranteed to be MP safe.
+
+ @param Value A pointer to the 32-bit value to increment.
+
+ @return The incremented value.
+
+**/
+UINT32
+EFIAPI
+InternalSyncIncrement (
+ IN volatile UINT32 *Value
+ );
+
+/**
+ Performs an atomic decrement of an 32-bit unsigned integer.
+
+ Performs an atomic decrement of the 32-bit unsigned integer specified by
+ Value and returns the decrement value. The decrement operation must be
+ performed using MP safe mechanisms. The state of the return value is not
+ guaranteed to be MP safe.
+
+ @param Value A pointer to the 32-bit value to decrement.
+
+ @return The decrement value.
+
+**/
+UINT32
+EFIAPI
+InternalSyncDecrement (
+ IN volatile UINT32 *Value
+ );
+
+/**
+ Performs an atomic compare exchange operation on a 32-bit unsigned integer.
+
+ Performs an atomic compare exchange operation on the 32-bit unsigned integer
+ specified by Value. If Value is equal to CompareValue, then Value is set to
+ ExchangeValue and CompareValue is returned. If Value is not equal to CompareValue,
+ then Value is returned. The compare exchange operation must be performed using
+ MP safe mechanisms.
+
+ @param Value A pointer to the 32-bit value for the compare exchange
+ operation.
+ @param CompareValue 32-bit value used in compare operation.
+ @param ExchangeValue 32-bit value used in exchange operation.
+
+ @return The original *Value before exchange.
+
+**/
+UINT32
+EFIAPI
+InternalSyncCompareExchange32 (
+ IN volatile UINT32 *Value,
+ IN UINT32 CompareValue,
+ IN UINT32 ExchangeValue
+ );
+
+/**
+ Performs an atomic compare exchange operation on a 64-bit unsigned integer.
+
+ Performs an atomic compare exchange operation on the 64-bit unsigned integer specified
+ by Value. If Value is equal to CompareValue, then Value is set to ExchangeValue and
+ CompareValue is returned. If Value is not equal to CompareValue, then Value is returned.
+ The compare exchange operation must be performed using MP safe mechanisms.
+
+ @param Value A pointer to the 64-bit value for the compare exchange
+ operation.
+ @param CompareValue 64-bit value used in compare operation.
+ @param ExchangeValue 64-bit value used in exchange operation.
+
+ @return The original *Value before exchange.
+
+**/
+UINT64
+EFIAPI
+InternalSyncCompareExchange64 (
+ IN volatile UINT64 *Value,
+ IN UINT64 CompareValue,
+ IN UINT64 ExchangeValue
+ );
+
+/**
+ Worker function that returns a bit field from Operand
+
+ Returns the bitfield specified by the StartBit and the EndBit from Operand.
+
+ @param Operand Operand on which to perform the bitfield operation.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+
+ @return The bit field read.
+
+**/
+unsigned int
+BitFieldReadUint (
+ IN unsigned int Operand,
+ IN UINTN StartBit,
+ IN UINTN EndBit
+ );
+
+/**
+ Worker function that reads a bit field from Operand, performs a bitwise OR,
+ and returns the result.
+
+ Performs a bitwise OR between the bit field specified by StartBit and EndBit
+ in Operand and the value specified by AndData. All other bits in Operand are
+ preserved. The new value is returned.
+
+ @param Operand Operand on which to perform the bitfield operation.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ @param OrData The value to OR with the read value from the value
+
+ @return The new value.
+
+**/
+unsigned int
+BitFieldOrUint (
+ IN unsigned int Operand,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN unsigned int OrData
+ );
+
+/**
+ Worker function that reads a bit field from Operand, performs a bitwise AND,
+ and returns the result.
+
+ Performs a bitwise AND between the bit field specified by StartBit and EndBit
+ in Operand and the value specified by AndData. All other bits in Operand are
+ preserved. The new value is returned.
+
+ @param Operand Operand on which to perform the bitfield operation.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ @param AndData The value to And with the read value from the value
+
+ @return The new value.
+
+**/
+unsigned int
+BitFieldAndUint (
+ IN unsigned int Operand,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN unsigned int AndData
+ );
+
+/**
+ Worker function that checks ASSERT condition for JumpBuffer
+
+ Checks ASSERT condition for JumpBuffer.
+
+ If JumpBuffer is NULL, then ASSERT().
+ For IPF CPUs, if JumpBuffer is not aligned on a 16-byte boundary, then ASSERT().
+
+ @param JumpBuffer A pointer to CPU context buffer.
+
+**/
+VOID
+InternalAssertJumpBuffer (
+ IN BASE_LIBRARY_JUMP_BUFFER *JumpBuffer
+ );
+
+/**
+ Restores the CPU context that was saved with SetJump().
+
+ Restores the CPU context from the buffer specified by JumpBuffer.
+ This function never returns to the caller.
+ Instead is resumes execution based on the state of JumpBuffer.
+
+ @param JumpBuffer A pointer to CPU context buffer.
+ @param Value The value to return when the SetJump() context is restored.
+
+**/
+VOID
+EFIAPI
+InternalLongJump (
+ IN BASE_LIBRARY_JUMP_BUFFER *JumpBuffer,
+ IN UINTN Value
+ );
+
#endif
diff --git a/MdePkg/Library/BaseLib/BitField.c b/MdePkg/Library/BaseLib/BitField.c
index 0b517aa974..3db8a23c95 100644
--- a/MdePkg/Library/BaseLib/BitField.c
+++ b/MdePkg/Library/BaseLib/BitField.c
@@ -14,6 +14,8 @@
**/
+#include "BaseLibInternals.h"
+
/**
Worker function that returns a bit field from Operand
@@ -763,10 +765,16 @@ BitFieldOr64 (
IN UINT64 OrData
)
{
+ UINT64 Value1;
+ UINT64 Value2;
+
ASSERT (EndBit < sizeof (Operand) * 8);
ASSERT (StartBit <= EndBit);
- return Operand |
- (LShiftU64 (OrData, StartBit) & ~LShiftU64 ((UINT64)-2, EndBit));
+
+ Value1 = LShiftU64 (OrData, StartBit);
+ Value2 = LShiftU64 ((UINT64) - 2, EndBit);
+
+ return Operand | (Value1 & ~Value2);
}
/**
@@ -801,10 +809,16 @@ BitFieldAnd64 (
IN UINT64 AndData
)
{
+ UINT64 Value1;
+ UINT64 Value2;
+
ASSERT (EndBit < sizeof (Operand) * 8);
ASSERT (StartBit <= EndBit);
- return Operand &
- ~(LShiftU64 (~AndData, StartBit) & ~LShiftU64 ((UINT64)-2, EndBit));
+
+ Value1 = LShiftU64 (~AndData, StartBit);
+ Value2 = LShiftU64 ((UINT64)-2, EndBit);
+
+ return Operand & ~(Value1 & ~Value2);
}
/**
diff --git a/MdePkg/Library/BaseLib/Ipf/Synchronization.c b/MdePkg/Library/BaseLib/Ipf/Synchronization.c
index 44593e1778..c29a8763d3 100644
--- a/MdePkg/Library/BaseLib/Ipf/Synchronization.c
+++ b/MdePkg/Library/BaseLib/Ipf/Synchronization.c
@@ -14,30 +14,7 @@
**/
-/**
- Performs an atomic compare exchange operation on a 32-bit unsigned integer.
-
- Performs an atomic compare exchange operation on the 32-bit unsigned integer
- specified by Value. If Value is equal to CompareValue, then Value is set to
- ExchangeValue and CompareValue is returned. If Value is not equal to CompareValue,
- then Value is returned. The compare exchange operation must be performed using
- MP safe mechanisms.
-
- @param Value A pointer to the 32-bit value for the compare exchange
- operation.
- @param CompareValue 32-bit value used in compare operation.
- @param ExchangeValue 32-bit value used in exchange operation.
-
- @return The original *Value before exchange.
-
-**/
-UINT32
-EFIAPI
-InternalSyncCompareExchange32 (
- IN volatile UINT32 *Value,
- IN UINT32 CompareValue,
- IN UINT32 ExchangeValue
- );
+#include "BaseLibInternals.h"
/**
Performs an atomic increment of an 32-bit unsigned integer.
diff --git a/MdePkg/Library/BaseLib/Ipf/Unaligned.c b/MdePkg/Library/BaseLib/Ipf/Unaligned.c
index 30e5b15c5f..fc634044b9 100644
--- a/MdePkg/Library/BaseLib/Ipf/Unaligned.c
+++ b/MdePkg/Library/BaseLib/Ipf/Unaligned.c
@@ -143,12 +143,15 @@ ReadUnaligned32 (
IN CONST UINT32 *Buffer
)
{
+ UINT16 LowerBytes;
+ UINT16 HigherBytes;
+
ASSERT (Buffer != NULL);
- return (UINT32)(
- ReadUnaligned16 ((UINT16*)Buffer) |
- (ReadUnaligned16 ((UINT16*)Buffer + 1) << 16)
- );
+ LowerBytes = ReadUnaligned16 ((UINT16*) Buffer);
+ HigherBytes = ReadUnaligned16 ((UINT16*) Buffer + 1);
+
+ return (UINT32) (LowerBytes | (HigherBytes << 16));
}
/**
@@ -199,12 +202,15 @@ ReadUnaligned64 (
IN CONST UINT64 *Buffer
)
{
+ UINT32 LowerBytes;
+ UINT32 HigherBytes;
+
ASSERT (Buffer != NULL);
- return (UINT64)(
- ReadUnaligned32 ((UINT32*)Buffer) |
- LShiftU64 (ReadUnaligned32 ((UINT32*)Buffer + 1), 32)
- );
+ LowerBytes = ReadUnaligned32 ((UINT32*) Buffer);
+ HigherBytes = ReadUnaligned32 ((UINT32*) Buffer + 1);
+
+ return (UINT64) (LowerBytes | LShiftU64 (HigherBytes, 32));
}
/**
diff --git a/MdePkg/Library/BaseLib/LinkedList.c b/MdePkg/Library/BaseLib/LinkedList.c
index 9347a2b579..f588eacd0c 100644
--- a/MdePkg/Library/BaseLib/LinkedList.c
+++ b/MdePkg/Library/BaseLib/LinkedList.c
@@ -14,6 +14,8 @@
**/
+#include "BaseLibInternals.h"
+
/**
Worker function that locates the Node in the List
diff --git a/MdePkg/Library/BaseLib/LongJump.c b/MdePkg/Library/BaseLib/LongJump.c
index a18c974e91..90a915e233 100644
--- a/MdePkg/Library/BaseLib/LongJump.c
+++ b/MdePkg/Library/BaseLib/LongJump.c
@@ -14,39 +14,7 @@
**/
-/**
- Worker function that checks ASSERT condition for JumpBuffer
-
- Checks ASSERT condition for JumpBuffer.
-
- If JumpBuffer is NULL, then ASSERT().
- For IPF CPUs, if JumpBuffer is not aligned on a 16-byte boundary, then ASSERT().
-
- @param JumpBuffer A pointer to CPU context buffer.
-
-**/
-VOID
-InternalAssertJumpBuffer (
- IN BASE_LIBRARY_JUMP_BUFFER *JumpBuffer
- );
-
-/**
- Restores the CPU context that was saved with SetJump().
-
- Restores the CPU context from the buffer specified by JumpBuffer.
- This function never returns to the caller.
- Instead is resumes execution based on the state of JumpBuffer.
-
- @param JumpBuffer A pointer to CPU context buffer.
- @param Value The value to return when the SetJump() context is restored.
-
-**/
-VOID
-EFIAPI
-InternalLongJump (
- IN BASE_LIBRARY_JUMP_BUFFER *JumpBuffer,
- IN UINTN Value
- );
+#include "BaseLibInternals.h"
/**
Restores the CPU context that was saved with SetJump().
diff --git a/MdePkg/Library/BaseLib/Math64.c b/MdePkg/Library/BaseLib/Math64.c
index 3312d789ac..514ae99020 100644
--- a/MdePkg/Library/BaseLib/Math64.c
+++ b/MdePkg/Library/BaseLib/Math64.c
@@ -85,10 +85,13 @@ InternalMathARShiftU64 (
IN UINTN Count
)
{
+ INTN TestValue;
+
//
// Test if this compiler supports arithmetic shift
//
- if ((((-1) << (sizeof (-1) * 8 - 1)) >> (sizeof (-1) * 8 - 1)) == -1) {
+ TestValue = (((-1) << (sizeof (-1) * 8 - 1)) >> (sizeof (-1) * 8 - 1));
+ if (TestValue == -1) {
//
// Arithmetic shift is supported
//
@@ -169,10 +172,13 @@ InternalMathSwapBytes64 (
IN UINT64 Operand
)
{
- return (UINT64)(
- ((UINT64)SwapBytes32 ((UINT32)Operand) << 32) |
- ((UINT64)SwapBytes32 ((UINT32)(Operand >> 32)))
- );
+ UINT64 LowerBytes;
+ UINT64 HigherBytes;
+
+ LowerBytes = (UINT64) SwapBytes32 ((UINT32) Operand);
+ HigherBytes = (UINT64) SwapBytes32 ((UINT32) (Operand >> 32));
+
+ return (LowerBytes << 32 | HigherBytes);
}
/**
diff --git a/MdePkg/Library/BaseLib/SetJump.c b/MdePkg/Library/BaseLib/SetJump.c
index f03479ae81..cb77d09611 100644
--- a/MdePkg/Library/BaseLib/SetJump.c
+++ b/MdePkg/Library/BaseLib/SetJump.c
@@ -14,6 +14,8 @@
**/
+#include "BaseLibInternals.h"
+
/**
Worker function that checks ASSERT condition for JumpBuffer
diff --git a/MdePkg/Library/BaseLib/String.c b/MdePkg/Library/BaseLib/String.c
index 2ac32254fc..7db468aee5 100644
--- a/MdePkg/Library/BaseLib/String.c
+++ b/MdePkg/Library/BaseLib/String.c
@@ -636,7 +636,7 @@ AsciiToUpper (
IN CHAR8 Chr
)
{
- return (Chr >= 'a' && Chr <= 'z') ? Chr - ('a' - 'A') : Chr;
+ return (UINT8) ((Chr >= 'a' && Chr <= 'z') ? Chr - ('a' - 'A') : Chr);
}
/**
@@ -675,19 +675,25 @@ AsciiStriCmp (
IN CONST CHAR8 *SecondString
)
{
+ CHAR8 UpperFirstString;
+ CHAR8 UpperSecondString;
+
//
// ASSERT both strings are less long than PcdMaximumAsciiStringLength
//
ASSERT (AsciiStrSize (FirstString));
ASSERT (AsciiStrSize (SecondString));
- while ((*FirstString != '\0') &&
- (AsciiToUpper (*FirstString) == AsciiToUpper (*SecondString))) {
+ UpperFirstString = AsciiToUpper (*FirstString);
+ UpperSecondString = AsciiToUpper (*SecondString);
+ while ((*FirstString != '\0') && (UpperFirstString == UpperSecondString)) {
FirstString++;
SecondString++;
+ UpperFirstString = AsciiToUpper (*FirstString);
+ UpperSecondString = AsciiToUpper (*SecondString);
}
- return AsciiToUpper (*FirstString) - AsciiToUpper (*SecondString);
+ return UpperFirstString - UpperSecondString;
}
/**
@@ -861,7 +867,7 @@ DecimalToBcd8 (
)
{
ASSERT (Value < 100);
- return ((Value / 10) << 4) | (Value % 10);
+ return (UINT8) (((Value / 10) << 4) | (Value % 10));
}
/**
@@ -886,5 +892,5 @@ BcdToDecimal8 (
{
ASSERT (Value < 0xa0);
ASSERT ((Value & 0xf) < 0xa);
- return (Value >> 4) * 10 + (Value & 0xf);
+ return (UINT8) ((Value >> 4) * 10 + (Value & 0xf));
}
diff --git a/MdePkg/Library/BaseLib/SwapBytes16.c b/MdePkg/Library/BaseLib/SwapBytes16.c
index c8460a28f7..134ccb1ef0 100644
--- a/MdePkg/Library/BaseLib/SwapBytes16.c
+++ b/MdePkg/Library/BaseLib/SwapBytes16.c
@@ -32,5 +32,5 @@ SwapBytes16 (
IN UINT16 Operand
)
{
- return (Operand << 8) | (Operand >> 8);
+ return (UINT16) ((Operand << 8) | (Operand >> 8));
}
diff --git a/MdePkg/Library/BaseLib/SwapBytes32.c b/MdePkg/Library/BaseLib/SwapBytes32.c
index 4e683b09d1..09396dba4e 100644
--- a/MdePkg/Library/BaseLib/SwapBytes32.c
+++ b/MdePkg/Library/BaseLib/SwapBytes32.c
@@ -32,8 +32,11 @@ SwapBytes32 (
IN UINT32 Operand
)
{
- return (UINT32)(
- ((UINT32)SwapBytes16 ((UINT16)Operand) << 16) |
- ((UINT32)SwapBytes16 ((UINT16)(Operand >> 16)))
- );
+ UINT32 LowerBytes;
+ UINT32 HigherBytes;
+
+ LowerBytes = (UINT32) SwapBytes16 ((UINT16) Operand);
+ HigherBytes = (UINT32) SwapBytes16 ((UINT16) (Operand >> 16));
+
+ return (LowerBytes << 16 | HigherBytes);
}
diff --git a/MdePkg/Library/BaseLib/Synchronization.c b/MdePkg/Library/BaseLib/Synchronization.c
index 18812e242f..e08aa62cf9 100644
--- a/MdePkg/Library/BaseLib/Synchronization.c
+++ b/MdePkg/Library/BaseLib/Synchronization.c
@@ -14,97 +14,12 @@
**/
+#include "BaseLibInternals.h"
+
#define SPIN_LOCK_RELEASED ((SPIN_LOCK)1)
#define SPIN_LOCK_ACQUIRED ((SPIN_LOCK)2)
/**
- Performs an atomic increment of an 32-bit unsigned integer.
-
- Performs an atomic increment of the 32-bit unsigned integer specified by
- Value and returns the incremented value. The increment operation must be
- performed using MP safe mechanisms. The state of the return value is not
- guaranteed to be MP safe.
-
- @param Value A pointer to the 32-bit value to increment.
-
- @return The incremented value.
-
-**/
-UINT32
-EFIAPI
-InternalSyncIncrement (
- IN volatile UINT32 *Value
- );
-
-/**
- Performs an atomic decrement of an 32-bit unsigned integer.
-
- Performs an atomic decrement of the 32-bit unsigned integer specified by
- Value and returns the decrement value. The decrement operation must be
- performed using MP safe mechanisms. The state of the return value is not
- guaranteed to be MP safe.
-
- @param Value A pointer to the 32-bit value to decrement.
-
- @return The decrement value.
-
-**/
-UINT32
-EFIAPI
-InternalSyncDecrement (
- IN volatile UINT32 *Value
- );
-
-/**
- Performs an atomic compare exchange operation on a 32-bit unsigned integer.
-
- Performs an atomic compare exchange operation on the 32-bit unsigned integer
- specified by Value. If Value is equal to CompareValue, then Value is set to
- ExchangeValue and CompareValue is returned. If Value is not equal to CompareValue,
- then Value is returned. The compare exchange operation must be performed using
- MP safe mechanisms.
-
- @param Value A pointer to the 32-bit value for the compare exchange
- operation.
- @param CompareValue 32-bit value used in compare operation.
- @param ExchangeValue 32-bit value used in exchange operation.
-
- @return The original *Value before exchange.
-
-**/
-UINT32
-EFIAPI
-InternalSyncCompareExchange32 (
- IN volatile UINT32 *Value,
- IN UINT32 CompareValue,
- IN UINT32 ExchangeValue
- );
-
-/**
- Performs an atomic compare exchange operation on a 64-bit unsigned integer.
-
- Performs an atomic compare exchange operation on the 64-bit unsigned integer specified
- by Value. If Value is equal to CompareValue, then Value is set to ExchangeValue and
- CompareValue is returned. If Value is not equal to CompareValue, then Value is returned.
- The compare exchange operation must be performed using MP safe mechanisms.
-
- @param Value A pointer to the 64-bit value for the compare exchange
- operation.
- @param CompareValue 64-bit value used in compare operation.
- @param ExchangeValue 64-bit value used in exchange operation.
-
- @return The original *Value before exchange.
-
-**/
-UINT64
-EFIAPI
-InternalSyncCompareExchange64 (
- IN volatile UINT64 *Value,
- IN UINT64 CompareValue,
- IN UINT64 ExchangeValue
- );
-
-/**
Retrieves the architecture specific spin lock alignment requirements for
optimal spin lock performance.
@@ -419,7 +334,11 @@ InterlockedCompareExchangePointer (
IN VOID *ExchangeValue
)
{
- switch (sizeof (*Value)) {
+ UINT8 SizeOfValue;
+
+ SizeOfValue = sizeof (*Value);
+
+ switch (SizeOfValue) {
case sizeof (UINT32):
return (VOID*)(UINTN)InterlockedCompareExchange32 (
(UINT32*)Value,
diff --git a/MdePkg/Library/BaseMemoryLib/CopyMem.c b/MdePkg/Library/BaseMemoryLib/CopyMem.c
index f2106acb18..632061a668 100644
--- a/MdePkg/Library/BaseMemoryLib/CopyMem.c
+++ b/MdePkg/Library/BaseMemoryLib/CopyMem.c
@@ -17,6 +17,8 @@
**/
+#include "MemLibInternals.h"
+
/**
Copy Length bytes from Source to Destination.
diff --git a/MdePkg/Library/BaseMemoryLib/MemLibGuid.c b/MdePkg/Library/BaseMemoryLib/MemLibGuid.c
index 6f50340bd7..36da5b7424 100644
--- a/MdePkg/Library/BaseMemoryLib/MemLibGuid.c
+++ b/MdePkg/Library/BaseMemoryLib/MemLibGuid.c
@@ -77,12 +77,17 @@ CompareGuid (
IN CONST GUID *Guid2
)
{
- return (BOOLEAN)(
- ReadUnaligned64 ((CONST UINT64*)Guid1)
- == ReadUnaligned64 ((CONST UINT64*)Guid2) &&
- ReadUnaligned64 ((CONST UINT64*)Guid1 + 1)
- == ReadUnaligned64 ((CONST UINT64*)Guid2 + 1)
- );
+ UINT64 LowPartOfGuid1;
+ UINT64 LowPartOfGuid2;
+ UINT64 HighPartOfGuid1;
+ UINT64 HighPartOfGuid2;
+
+ LowPartOfGuid1 = ReadUnaligned64 ((CONST UINT64*) Guid1);
+ LowPartOfGuid2 = ReadUnaligned64 ((CONST UINT64*) Guid2);
+ HighPartOfGuid1 = ReadUnaligned64 ((CONST UINT64*) Guid1 + 1);
+ HighPartOfGuid2 = ReadUnaligned64 ((CONST UINT64*) Guid2 + 1);
+
+ return (BOOLEAN) (LowPartOfGuid1 == LowPartOfGuid2 && HighPartOfGuid1 == HighPartOfGuid2);
}
/**
diff --git a/MdePkg/Library/BaseMemoryLib/SetMem.c b/MdePkg/Library/BaseMemoryLib/SetMem.c
index 07acc6fbfe..d051f2d63b 100644
--- a/MdePkg/Library/BaseMemoryLib/SetMem.c
+++ b/MdePkg/Library/BaseMemoryLib/SetMem.c
@@ -17,6 +17,7 @@
**/
+#include "MemLibInternals.h"
/**
Set Buffer to Value for Size bytes.
diff --git a/MdePkg/Library/BaseMemoryLibMmx/MemLibGuid.c b/MdePkg/Library/BaseMemoryLibMmx/MemLibGuid.c
index 6f50340bd7..36da5b7424 100644
--- a/MdePkg/Library/BaseMemoryLibMmx/MemLibGuid.c
+++ b/MdePkg/Library/BaseMemoryLibMmx/MemLibGuid.c
@@ -77,12 +77,17 @@ CompareGuid (
IN CONST GUID *Guid2
)
{
- return (BOOLEAN)(
- ReadUnaligned64 ((CONST UINT64*)Guid1)
- == ReadUnaligned64 ((CONST UINT64*)Guid2) &&
- ReadUnaligned64 ((CONST UINT64*)Guid1 + 1)
- == ReadUnaligned64 ((CONST UINT64*)Guid2 + 1)
- );
+ UINT64 LowPartOfGuid1;
+ UINT64 LowPartOfGuid2;
+ UINT64 HighPartOfGuid1;
+ UINT64 HighPartOfGuid2;
+
+ LowPartOfGuid1 = ReadUnaligned64 ((CONST UINT64*) Guid1);
+ LowPartOfGuid2 = ReadUnaligned64 ((CONST UINT64*) Guid2);
+ HighPartOfGuid1 = ReadUnaligned64 ((CONST UINT64*) Guid1 + 1);
+ HighPartOfGuid2 = ReadUnaligned64 ((CONST UINT64*) Guid2 + 1);
+
+ return (BOOLEAN) (LowPartOfGuid1 == LowPartOfGuid2 && HighPartOfGuid1 == HighPartOfGuid2);
}
/**
diff --git a/MdePkg/Library/BasePciExpressLib/PciLib.c b/MdePkg/Library/BasePciExpressLib/PciLib.c
index f7deedd642..9cdac21096 100644
--- a/MdePkg/Library/BasePciExpressLib/PciLib.c
+++ b/MdePkg/Library/BasePciExpressLib/PciLib.c
@@ -40,6 +40,7 @@
@return The base address of PCI Express.
**/
+STATIC
volatile VOID*
GetPciExpressBaseAddress (
VOID
diff --git a/MdePkg/Library/BasePeCoffLib/BasePeCoff.c b/MdePkg/Library/BasePeCoffLib/BasePeCoff.c
index d82107ecde..ad3635f2fb 100644
--- a/MdePkg/Library/BasePeCoffLib/BasePeCoff.c
+++ b/MdePkg/Library/BasePeCoffLib/BasePeCoff.c
@@ -17,66 +17,7 @@
**/
-
-/**
- Performs an Itanium-based specific relocation fixup and is a no-op on other
- instruction sets.
-
- @param Reloc Pointer to the relocation record.
- @param Fixup Pointer to the address to fix up.
- @param FixupData Pointer to a buffer to log the fixups.
- @param Adjust The offset to adjust the fixup.
-
- @return Status code.
-
-**/
-RETURN_STATUS
-PeCoffLoaderRelocateImageEx (
- IN UINT16 *Reloc,
- IN OUT CHAR8 *Fixup,
- IN OUT CHAR8 **FixupData,
- IN UINT64 Adjust
- );
-
-
-/**
- Performs an Itanium-based specific re-relocation fixup and is a no-op on other
- instruction sets. This is used to re-relocated the image into the EFI virtual
- space for runtime calls.
-
- @param Reloc Pointer to the relocation record.
- @param Fixup Pointer to the address to fix up.
- @param FixupData Pointer to a buffer to log the fixups.
- @param Adjust The offset to adjust the fixup.
-
- @return Status code.
-
-**/
-RETURN_STATUS
-PeHotRelocateImageEx (
- IN UINT16 *Reloc,
- IN OUT CHAR8 *Fixup,
- IN OUT CHAR8 **FixupData,
- IN UINT64 Adjust
- );
-
-
-/**
- Returns TRUE if the machine type of PE/COFF image is supported. Supported
- does not mean the image can be executed it means the PE/COFF loader supports
- loading and relocating of the image type. It's up to the caller to support
- the entry point.
-
- @param Machine Machine type from the PE Header.
-
- @return TRUE if this PE/COFF loader can load the image
-
-**/
-BOOLEAN
-PeCoffLoaderImageFormatSupported (
- IN UINT16 Machine
- );
-
+#include "BasePeCoffLibInternals.h"
/**
Retrieves the magic value from the PE/COFF header.
diff --git a/MdePkg/Library/BasePeCoffLib/BasePeCoffLib.msa b/MdePkg/Library/BasePeCoffLib/BasePeCoffLib.msa
index 09698a4889..b3d754d570 100644
--- a/MdePkg/Library/BasePeCoffLib/BasePeCoffLib.msa
+++ b/MdePkg/Library/BasePeCoffLib/BasePeCoffLib.msa
@@ -34,6 +34,7 @@
</LibraryClassDefinitions>
<SourceFiles>
<Filename>BasePeCoff.c</Filename>
+ <Filename>BasePeCoffLibInternals.h</Filename>
<Filename SupArchList="IA32">Ia32/PeCoffLoaderEx.c</Filename>
<Filename SupArchList="X64">x64/PeCoffLoaderEx.c</Filename>
<Filename SupArchList="IPF">Ipf/PeCoffLoaderEx.c</Filename>
diff --git a/MdePkg/Library/BasePeCoffLib/BasePeCoffLibInternals.h b/MdePkg/Library/BasePeCoffLib/BasePeCoffLibInternals.h
new file mode 100644
index 0000000000..3d4d71af33
--- /dev/null
+++ b/MdePkg/Library/BasePeCoffLib/BasePeCoffLibInternals.h
@@ -0,0 +1,124 @@
+/** @file
+ Declaration of internal functions in PE/COFF Lib.
+
+ Copyright (c) 2006, Intel Corporation<BR>
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+ Module Name: BasePeCoffLibInternals.h
+
+**/
+
+#ifndef __BASE_PECOFF_LIB_INTERNALS__
+#define __BASE_PECOFF_LIB_INTERNALS__
+
+/**
+ Performs an Itanium-based specific relocation fixup and is a no-op on other
+ instruction sets.
+
+ @param Reloc Pointer to the relocation record.
+ @param Fixup Pointer to the address to fix up.
+ @param FixupData Pointer to a buffer to log the fixups.
+ @param Adjust The offset to adjust the fixup.
+
+ @return Status code.
+
+**/
+RETURN_STATUS
+PeCoffLoaderRelocateImageEx (
+ IN UINT16 *Reloc,
+ IN OUT CHAR8 *Fixup,
+ IN OUT CHAR8 **FixupData,
+ IN UINT64 Adjust
+ );
+
+
+/**
+ Performs an Itanium-based specific re-relocation fixup and is a no-op on other
+ instruction sets. This is used to re-relocated the image into the EFI virtual
+ space for runtime calls.
+
+ @param Reloc Pointer to the relocation record.
+ @param Fixup Pointer to the address to fix up.
+ @param FixupData Pointer to a buffer to log the fixups.
+ @param Adjust The offset to adjust the fixup.
+
+ @return Status code.
+
+**/
+RETURN_STATUS
+PeHotRelocateImageEx (
+ IN UINT16 *Reloc,
+ IN OUT CHAR8 *Fixup,
+ IN OUT CHAR8 **FixupData,
+ IN UINT64 Adjust
+ );
+
+
+/**
+ Returns TRUE if the machine type of PE/COFF image is supported. Supported
+ does not mean the image can be executed it means the PE/COFF loader supports
+ loading and relocating of the image type. It's up to the caller to support
+ the entry point.
+
+ @param Machine Machine type from the PE Header.
+
+ @return TRUE if this PE/COFF loader can load the image
+
+**/
+BOOLEAN
+PeCoffLoaderImageFormatSupported (
+ IN UINT16 Machine
+ );
+
+/**
+ Retrieves the magic value from the PE/COFF header.
+
+ @param Hdr The buffer in which to return the PE32, PE32+, or TE header.
+
+ @return EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC - Image is PE32
+ @return EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC - Image is PE32+
+
+**/
+UINT16
+PeCoffLoaderGetPeHeaderMagicValue (
+ IN EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION Hdr
+ );
+
+/**
+ Retrieves the PE or TE Header from a PE/COFF or TE image.
+
+ @param ImageContext The context of the image being loaded.
+ @param Hdr The buffer in which to return the PE32, PE32+, or TE header.
+
+ @retval RETURN_SUCCESS The PE or TE Header is read.
+ @retval Other The error status from reading the PE/COFF or TE image using the ImageRead function.
+
+**/
+RETURN_STATUS
+PeCoffLoaderGetPeHeader (
+ IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext,
+ OUT EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION Hdr
+ );
+
+/**
+ Converts an image address to the loaded address.
+
+ @param ImageContext The context of the image being loaded.
+ @param Address The address to be converted to the loaded address.
+
+ @return The converted address or NULL if the address can not be converted.
+
+**/
+VOID *
+PeCoffLoaderImageAddress (
+ IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext,
+ IN UINTN Address
+ );
+
+#endif
diff --git a/MdePkg/Library/BasePeCoffLib/Ipf/PeCoffLoaderEx.c b/MdePkg/Library/BasePeCoffLib/Ipf/PeCoffLoaderEx.c
index babf7ca3a2..065aec42ac 100644
--- a/MdePkg/Library/BasePeCoffLib/Ipf/PeCoffLoaderEx.c
+++ b/MdePkg/Library/BasePeCoffLib/Ipf/PeCoffLoaderEx.c
@@ -14,7 +14,7 @@
**/
-
+#include "BasePeCoffLibInternals.h"
diff --git a/MdePkg/Library/BasePerformanceLibNull/PerformanceLib.c b/MdePkg/Library/BasePerformanceLibNull/PerformanceLib.c
index 406acb5ca0..b08617c3cc 100644
--- a/MdePkg/Library/BasePerformanceLibNull/PerformanceLib.c
+++ b/MdePkg/Library/BasePerformanceLibNull/PerformanceLib.c
@@ -156,5 +156,5 @@ PerformanceMeasurementEnabled (
VOID
)
{
- return ((PcdGet8(PcdPerformanceLibraryPropertyMask) & PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED) != 0);
+ return (BOOLEAN) ((PcdGet8(PcdPerformanceLibraryPropertyMask) & PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED) != 0);
}
diff --git a/MdePkg/Library/BasePostCodeLibDebug/PostCode.c b/MdePkg/Library/BasePostCodeLibDebug/PostCode.c
index 37f060228b..a4996d326a 100644
--- a/MdePkg/Library/BasePostCodeLibDebug/PostCode.c
+++ b/MdePkg/Library/BasePostCodeLibDebug/PostCode.c
@@ -96,7 +96,7 @@ PostCodeEnabled (
VOID
)
{
- return ((PcdGet8(PcdPostCodePropertyMask) & POST_CODE_PROPERTY_POST_CODE_ENABLED) != 0);
+ return (BOOLEAN) ((PcdGet8(PcdPostCodePropertyMask) & POST_CODE_PROPERTY_POST_CODE_ENABLED) != 0);
}
@@ -118,5 +118,5 @@ PostCodeDescriptionEnabled (
VOID
)
{
- return ((PcdGet8(PcdPostCodePropertyMask) & POST_CODE_PROPERTY_POST_CODE_ENABLED) != 0);
+ return (BOOLEAN) ((PcdGet8(PcdPostCodePropertyMask) & POST_CODE_PROPERTY_POST_CODE_ENABLED) != 0);
}
diff --git a/MdePkg/Library/BasePostCodeLibPort80/PostCode.c b/MdePkg/Library/BasePostCodeLibPort80/PostCode.c
index 93c24d5eb6..3dfd024c2d 100644
--- a/MdePkg/Library/BasePostCodeLibPort80/PostCode.c
+++ b/MdePkg/Library/BasePostCodeLibPort80/PostCode.c
@@ -96,7 +96,7 @@ PostCodeEnabled (
VOID
)
{
- return ((PcdGet8(PcdPostCodePropertyMask) & POST_CODE_PROPERTY_POST_CODE_ENABLED) != 0);
+ return (BOOLEAN) ((PcdGet8(PcdPostCodePropertyMask) & POST_CODE_PROPERTY_POST_CODE_ENABLED) != 0);
}
@@ -119,5 +119,5 @@ PostCodeDescriptionEnabled (
VOID
)
{
- return ((PcdGet8(PcdPostCodePropertyMask) & POST_CODE_PROPERTY_POST_CODE_ENABLED) != 0);
+ return (BOOLEAN) ((PcdGet8(PcdPostCodePropertyMask) & POST_CODE_PROPERTY_POST_CODE_ENABLED) != 0);
}
diff --git a/MdePkg/Library/BasePrintLib/PrintLibInternal.h b/MdePkg/Library/BasePrintLib/PrintLibInternal.h
index e0928b8c80..5a63cbb8b7 100644
--- a/MdePkg/Library/BasePrintLib/PrintLibInternal.h
+++ b/MdePkg/Library/BasePrintLib/PrintLibInternal.h
@@ -53,6 +53,34 @@ typedef struct {
/**
Worker function that produces a Null-terminated string in an output buffer
+ based on a Null-terminated format string and a VA_LIST argument list.
+
+ VSPrint function to process format and place the results in Buffer. Since a
+ VA_LIST is used this rountine allows the nesting of Vararg routines. Thus
+ this is the main print working routine.
+
+ @param Buffer Character buffer to print the results of the parsing
+ of Format into.
+ @param BufferSize Maximum number of characters to put into buffer.
+ @param Flags Intial flags value.
+ Can only have FORMAT_UNICODE and OUTPUT_UNICODE set.
+ @param Format Null-terminated format string.
+ @param Marker Vararg list consumed by processing Format.
+
+ @return Number of characters printed not including the Null-terminator.
+
+**/
+UINTN
+BasePrintLibVSPrint (
+ OUT CHAR8 *Buffer,
+ IN UINTN BufferSize,
+ IN UINTN Flags,
+ IN CONST CHAR8 *Format,
+ IN VA_LIST Marker
+ );
+
+/**
+ Worker function that produces a Null-terminated string in an output buffer
based on a Null-terminated format string and variable argument list.
VSPrint function to process format and place the results in Buffer. Since a
diff --git a/MdePkg/Library/BaseUefiDecompressLib/BaseUefiDecompressLib.c b/MdePkg/Library/BaseUefiDecompressLib/BaseUefiDecompressLib.c
index a336417760..e70dc88ef1 100644
--- a/MdePkg/Library/BaseUefiDecompressLib/BaseUefiDecompressLib.c
+++ b/MdePkg/Library/BaseUefiDecompressLib/BaseUefiDecompressLib.c
@@ -14,59 +14,7 @@
**/
-//
-// Decompression algorithm begins here
-//
-#define BITBUFSIZ 32
-#define MAXMATCH 256
-#define THRESHOLD 3
-#define CODE_BIT 16
-#define BAD_TABLE - 1
-
-//
-// C: Char&Len Set; P: Position Set; T: exTra Set
-//
-#define NC (0xff + MAXMATCH + 2 - THRESHOLD)
-#define CBIT 9
-#define MAXPBIT 5
-#define TBIT 5
-#define MAXNP ((1U << MAXPBIT) - 1)
-#define NT (CODE_BIT + 3)
-#if NT > MAXNP
-#define NPT NT
-#else
-#define NPT MAXNP
-#endif
-
-typedef struct {
- UINT8 *mSrcBase; ///< Starting address of compressed data
- UINT8 *mDstBase; ///< Starting address of decompressed data
- UINT32 mOutBuf;
- UINT32 mInBuf;
-
- UINT16 mBitCount;
- UINT32 mBitBuf;
- UINT32 mSubBitBuf;
- UINT16 mBlockSize;
- UINT32 mCompSize;
- UINT32 mOrigSize;
-
- UINT16 mBadTableFlag;
-
- UINT16 mLeft[2 * NC - 1];
- UINT16 mRight[2 * NC - 1];
- UINT8 mCLen[NC];
- UINT8 mPTLen[NPT];
- UINT16 mCTable[4096];
- UINT16 mPTTable[256];
-
- ///
- /// The length of the field 'Position Set Code Length Array Size' in Block Header.
- /// For EFI 1.1 de/compression algorithm, mPBit = 4
- /// For Tiano de/compression algorithm, mPBit = 5
- ///
- UINT8 mPBit;
-} SCRATCH_DATA;
+#include "BaseUefiDecompressLibInternals.h"
/**
Read NumOfBit of bits from source into mBitBuf
@@ -195,6 +143,9 @@ MakeTable (
UINT16 Avail;
UINT16 NextCode;
UINT16 Mask;
+ UINT16 WordOfStart;
+ UINT16 WordOfCount;
+
for (Index = 1; Index <= 16; Index++) {
Count[Index] = 0;
@@ -207,7 +158,9 @@ MakeTable (
Start[1] = 0;
for (Index = 1; Index <= 16; Index++) {
- Start[Index + 1] = (UINT16) (Start[Index] + (Count[Index] << (16 - Index)));
+ WordOfStart = Start[Index];
+ WordOfCount = Count[Index];
+ Start[Index + 1] = (UINT16) (WordOfStart + (WordOfCount << (16 - Index)));
}
if (Start[17] != 0) {
@@ -627,7 +580,7 @@ Decode (
//
CharC = DecodeC (Sd);
if (Sd->mBadTableFlag != 0) {
- return ;
+ goto Done;
}
if (CharC < 256) {
@@ -635,7 +588,7 @@ Decode (
// Process an Original character
//
if (Sd->mOutBuf >= Sd->mOrigSize) {
- return ;
+ goto Done;
} else {
//
// Write orignal character into mDstBase
@@ -666,7 +619,7 @@ Decode (
while ((INT16) (BytesRemain) >= 0) {
Sd->mDstBase[Sd->mOutBuf++] = Sd->mDstBase[DataIdx++];
if (Sd->mOutBuf >= Sd->mOrigSize) {
- return ;
+ goto Done;
}
BytesRemain--;
@@ -674,6 +627,7 @@ Decode (
}
}
+Done:
return ;
}
diff --git a/MdePkg/Library/BaseUefiDecompressLib/BaseUefiDecompressLib.msa b/MdePkg/Library/BaseUefiDecompressLib/BaseUefiDecompressLib.msa
index 08ac9af7f1..6302302d18 100644
--- a/MdePkg/Library/BaseUefiDecompressLib/BaseUefiDecompressLib.msa
+++ b/MdePkg/Library/BaseUefiDecompressLib/BaseUefiDecompressLib.msa
@@ -34,6 +34,7 @@
</LibraryClassDefinitions>
<SourceFiles>
<Filename>BaseUefiDecompressLib.c</Filename>
+ <Filename>BaseUefiDecompressLibInternals.h</Filename>
</SourceFiles>
<PackageDependencies>
<Package PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
diff --git a/MdePkg/Library/BaseUefiDecompressLib/BaseUefiDecompressLibInternals.h b/MdePkg/Library/BaseUefiDecompressLib/BaseUefiDecompressLibInternals.h
new file mode 100644
index 0000000000..70ae3f2974
--- /dev/null
+++ b/MdePkg/Library/BaseUefiDecompressLib/BaseUefiDecompressLibInternals.h
@@ -0,0 +1,215 @@
+/** @file
+ Internal include file for Base UEFI Decompress Libary.
+
+ Copyright (c) 2006, Intel Corporation
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+ Module Name: BaseUefiDecompressLibInternals.h
+
+**/
+
+#ifndef __BASE_UEFI_DECOMPRESS_LIB_INTERNALS_H__
+#define __BASE_UEFI_DECOMPRESS_LIB_INTERNALS_H__
+
+//
+// Decompression algorithm begins here
+//
+#define BITBUFSIZ 32
+#define MAXMATCH 256
+#define THRESHOLD 3
+#define CODE_BIT 16
+#define BAD_TABLE - 1
+
+//
+// C: Char&Len Set; P: Position Set; T: exTra Set
+//
+#define NC (0xff + MAXMATCH + 2 - THRESHOLD)
+#define CBIT 9
+#define MAXPBIT 5
+#define TBIT 5
+#define MAXNP ((1U << MAXPBIT) - 1)
+#define NT (CODE_BIT + 3)
+#if NT > MAXNP
+#define NPT NT
+#else
+#define NPT MAXNP
+#endif
+
+typedef struct {
+ UINT8 *mSrcBase; ///< Starting address of compressed data
+ UINT8 *mDstBase; ///< Starting address of decompressed data
+ UINT32 mOutBuf;
+ UINT32 mInBuf;
+
+ UINT16 mBitCount;
+ UINT32 mBitBuf;
+ UINT32 mSubBitBuf;
+ UINT16 mBlockSize;
+ UINT32 mCompSize;
+ UINT32 mOrigSize;
+
+ UINT16 mBadTableFlag;
+
+ UINT16 mLeft[2 * NC - 1];
+ UINT16 mRight[2 * NC - 1];
+ UINT8 mCLen[NC];
+ UINT8 mPTLen[NPT];
+ UINT16 mCTable[4096];
+ UINT16 mPTTable[256];
+
+ ///
+ /// The length of the field 'Position Set Code Length Array Size' in Block Header.
+ /// For EFI 1.1 de/compression algorithm, mPBit = 4
+ /// For Tiano de/compression algorithm, mPBit = 5
+ ///
+ UINT8 mPBit;
+} SCRATCH_DATA;
+
+/**
+ Read NumOfBit of bits from source into mBitBuf
+
+ Shift mBitBuf NumOfBits left. Read in NumOfBits of bits from source.
+
+ @param Sd The global scratch data
+ @param NumOfBits The number of bits to shift and read.
+
+**/
+VOID
+FillBuf (
+ IN SCRATCH_DATA *Sd,
+ IN UINT16 NumOfBits
+ );
+
+/**
+ Get NumOfBits of bits out from mBitBuf
+
+ Get NumOfBits of bits out from mBitBuf. Fill mBitBuf with subsequent
+ NumOfBits of bits from source. Returns NumOfBits of bits that are
+ popped out.
+
+ @param Sd The global scratch data.
+ @param NumOfBits The number of bits to pop and read.
+
+ @return The bits that are popped out.
+
+**/
+UINT32
+GetBits (
+ IN SCRATCH_DATA *Sd,
+ IN UINT16 NumOfBits
+ );
+
+/**
+ Creates Huffman Code mapping table according to code length array.
+
+ Creates Huffman Code mapping table for Extra Set, Char&Len Set
+ and Position Set according to code length array.
+
+ @param Sd The global scratch data
+ @param NumOfChar Number of symbols in the symbol set
+ @param BitLen Code length array
+ @param TableBits The width of the mapping table
+ @param Table The table
+
+ @retval 0 OK.
+ @retval BAD_TABLE The table is corrupted.
+
+**/
+UINT16
+MakeTable (
+ IN SCRATCH_DATA *Sd,
+ IN UINT16 NumOfChar,
+ IN UINT8 *BitLen,
+ IN UINT16 TableBits,
+ OUT UINT16 *Table
+ );
+
+/**
+ Decodes a position value.
+
+ Get a position value according to Position Huffman Table.
+
+ @param Sd the global scratch data
+
+ @return The position value decoded.
+
+**/
+UINT32
+DecodeP (
+ IN SCRATCH_DATA *Sd
+ );
+
+/**
+ Reads code lengths for the Extra Set or the Position Set.
+
+ Read in the Extra Set or Pointion Set Length Arrary, then
+ generate the Huffman code mapping for them.
+
+ @param Sd The global scratch data.
+ @param nn Number of symbols.
+ @param nbit Number of bits needed to represent nn.
+ @param Special The special symbol that needs to be taken care of.
+
+ @retval 0 OK.
+ @retval BAD_TABLE Table is corrupted.
+
+**/
+UINT16
+ReadPTLen (
+ IN SCRATCH_DATA *Sd,
+ IN UINT16 nn,
+ IN UINT16 nbit,
+ IN UINT16 Special
+ );
+
+/**
+ Reads code lengths for Char&Len Set.
+
+ Read in and decode the Char&Len Set Code Length Array, then
+ generate the Huffman Code mapping table for the Char&Len Set.
+
+ @param Sd the global scratch data
+
+**/
+VOID
+ReadCLen (
+ SCRATCH_DATA *Sd
+ );
+
+/**
+ Decode a character/length value.
+
+ Read one value from mBitBuf, Get one code from mBitBuf. If it is at block boundary, generates
+ Huffman code mapping table for Extra Set, Code&Len Set and
+ Position Set.
+
+ @param Sd The global scratch data.
+
+ @return The value decoded.
+
+**/
+UINT16
+DecodeC (
+ SCRATCH_DATA *Sd
+ );
+
+/**
+ Decode the source data and put the resulting data into the destination buffer.
+
+ Decode the source data and put the resulting data into the destination buffer.
+
+ @param Sd The global scratch data
+
+**/
+VOID
+Decode (
+ SCRATCH_DATA *Sd
+ );
+
+#endif
diff --git a/MdePkg/Library/DxeCoreHobLib/DxeCoreHobLib.msa b/MdePkg/Library/DxeCoreHobLib/DxeCoreHobLib.msa
index edd69fbde4..3a455c11e7 100644
--- a/MdePkg/Library/DxeCoreHobLib/DxeCoreHobLib.msa
+++ b/MdePkg/Library/DxeCoreHobLib/DxeCoreHobLib.msa
@@ -35,6 +35,7 @@
</LibraryClassDefinitions>
<SourceFiles>
<Filename>HobLib.c</Filename>
+ <Filename>HobLib.h</Filename>
</SourceFiles>
<PackageDependencies>
<Package PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
diff --git a/MdePkg/Library/DxeCoreHobLib/HobLib.c b/MdePkg/Library/DxeCoreHobLib/HobLib.c
index 43889df497..9901c6fb6d 100644
--- a/MdePkg/Library/DxeCoreHobLib/HobLib.c
+++ b/MdePkg/Library/DxeCoreHobLib/HobLib.c
@@ -14,10 +14,7 @@
**/
-
-
-extern VOID *gHobList;
-
+#include "HobLib.h"
/**
Returns the pointer to the HOB list.
diff --git a/MdePkg/Library/DxeCoreHobLib/HobLib.h b/MdePkg/Library/DxeCoreHobLib/HobLib.h
new file mode 100644
index 0000000000..8f0347639c
--- /dev/null
+++ b/MdePkg/Library/DxeCoreHobLib/HobLib.h
@@ -0,0 +1,22 @@
+/** @file
+ Internal include file of DXE Entry Point HOB Library.
+
+ Copyright (c) 2006, Intel Corporation
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+ Module Name: HobLib.h
+
+**/
+
+#ifndef __DXE_ENTRY_POINT_HOB_LIB_H__
+#define __DXE_ENTRY_POINT_HOB_LIB_H__
+
+extern VOID *gHobList;
+
+#endif
diff --git a/MdePkg/Library/DxeIoLibCpuIo/DxeCpuIoLibInternal.h b/MdePkg/Library/DxeIoLibCpuIo/DxeCpuIoLibInternal.h
new file mode 100644
index 0000000000..11a5f6eeb8
--- /dev/null
+++ b/MdePkg/Library/DxeIoLibCpuIo/DxeCpuIoLibInternal.h
@@ -0,0 +1,107 @@
+/** @file
+ Internal include file of DXE CPU IO Library.
+
+ Copyright (c) 2006, Intel Corporation
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+ Module Name: DxeCpuIoLibInternal.h
+
+**/
+
+#ifndef __DXE_CPUIO_LIB_INTERNAL_H__
+#define __DXE_CPUIO_LIB_INTERNAL_H__
+
+/**
+ Reads registers in the EFI CPU I/O space.
+
+ Reads the I/O port specified by Port with registers width specified by Width.
+ The read value is returned. If such operations are not supported, then ASSERT().
+ This function must guarantee that all I/O read and write operations are serialized.
+
+ @param Port The base address of the I/O operation.
+ The caller is responsible for aligning the Address if required.
+ @param Width The width of the I/O operation.
+
+ @return Data read from registers in the EFI CPU I/O space.
+
+**/
+UINT64
+EFIAPI
+IoReadWorker (
+ IN UINTN Port,
+ IN EFI_CPU_IO_PROTOCOL_WIDTH Width
+ );
+
+/**
+ Writes registers in the EFI CPU I/O space.
+
+ Writes the I/O port specified by Port with registers width and value specified by Width
+ and Data respectively. Data is returned. If such operations are not supported, then ASSERT().
+ This function must guarantee that all I/O read and write operations are serialized.
+
+ @param Port The base address of the I/O operation.
+ The caller is responsible for aligning the Address if required.
+ @param Width The width of the I/O operation.
+ @param Data The value to write to the I/O port.
+
+ @return The paramter of Data.
+
+**/
+UINT64
+EFIAPI
+IoWriteWorker (
+ IN UINTN Port,
+ IN EFI_CPU_IO_PROTOCOL_WIDTH Width,
+ IN UINT64 Data
+ );
+
+/**
+ Reads memory-mapped registers in the EFI system memory space.
+
+ Reads the MMIO registers specified by Address with registers width specified by Width.
+ The read value is returned. If such operations are not supported, then ASSERT().
+ This function must guarantee that all MMIO read and write operations are serialized.
+
+ @param Address The MMIO register to read.
+ The caller is responsible for aligning the Address if required.
+ @param Width The width of the I/O operation.
+
+ @return Data read from registers in the EFI system memory space.
+
+**/
+UINT64
+EFIAPI
+MmioReadWorker (
+ IN UINTN Address,
+ IN EFI_CPU_IO_PROTOCOL_WIDTH Width
+ );
+
+/**
+ Writes memory-mapped registers in the EFI system memory space.
+
+ Writes the MMIO registers specified by Address with registers width and value specified by Width
+ and Data respectively. Data is returned. If such operations are not supported, then ASSERT().
+ This function must guarantee that all MMIO read and write operations are serialized.
+
+ @param Address The MMIO register to read.
+ The caller is responsible for aligning the Address if required.
+ @param Width The width of the I/O operation.
+
+ @return Data read from registers in the EFI system memory space.
+
+**/
+UINT64
+EFIAPI
+MmioWriteWorker (
+ IN UINTN Address,
+ IN EFI_CPU_IO_PROTOCOL_WIDTH Width,
+ IN UINT64 Data
+ );
+
+#endif
diff --git a/MdePkg/Library/DxeIoLibCpuIo/DxeIoLibCpuIo.msa b/MdePkg/Library/DxeIoLibCpuIo/DxeIoLibCpuIo.msa
index c570679b15..8309d58192 100644
--- a/MdePkg/Library/DxeIoLibCpuIo/DxeIoLibCpuIo.msa
+++ b/MdePkg/Library/DxeIoLibCpuIo/DxeIoLibCpuIo.msa
@@ -39,6 +39,7 @@
<SourceFiles>
<Filename>IoLib.c</Filename>
<Filename>IoHighLevel.c</Filename>
+ <Filename>DxeCpuIoLibInternal.h</Filename>
</SourceFiles>
<PackageDependencies>
<Package PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
diff --git a/MdePkg/Library/DxeIoLibCpuIo/IoHighLevel.c b/MdePkg/Library/DxeIoLibCpuIo/IoHighLevel.c
index 0d8d0de8f4..ed09b4e5aa 100644
--- a/MdePkg/Library/DxeIoLibCpuIo/IoHighLevel.c
+++ b/MdePkg/Library/DxeIoLibCpuIo/IoHighLevel.c
@@ -48,7 +48,7 @@ IoOr8 (
IN UINT8 OrData
)
{
- return IoWrite8 (Port, IoRead8 (Port) | OrData);
+ return IoWrite8 (Port, (UINT8) (IoRead8 (Port) | OrData));
}
/**
@@ -76,7 +76,7 @@ IoAnd8 (
IN UINT8 AndData
)
{
- return IoWrite8 (Port, IoRead8 (Port) & AndData);
+ return IoWrite8 (Port, (UINT8) (IoRead8 (Port) & AndData));
}
/**
@@ -107,7 +107,7 @@ IoAndThenOr8 (
IN UINT8 OrData
)
{
- return IoWrite8 (Port, (IoRead8 (Port) & AndData) | OrData);
+ return IoWrite8 (Port, (UINT8) ((IoRead8 (Port) & AndData) | OrData));
}
/**
@@ -328,7 +328,7 @@ IoOr16 (
IN UINT16 OrData
)
{
- return IoWrite16 (Port, IoRead16 (Port) | OrData);
+ return IoWrite16 (Port, (UINT16) (IoRead16 (Port) | OrData));
}
/**
@@ -356,7 +356,7 @@ IoAnd16 (
IN UINT16 AndData
)
{
- return IoWrite16 (Port, IoRead16 (Port) & AndData);
+ return IoWrite16 (Port, (UINT16) (IoRead16 (Port) & AndData));
}
/**
@@ -387,7 +387,7 @@ IoAndThenOr16 (
IN UINT16 OrData
)
{
- return IoWrite16 (Port, (IoRead16 (Port) & AndData) | OrData);
+ return IoWrite16 (Port, (UINT16) ((IoRead16 (Port) & AndData) | OrData));
}
/**
@@ -1168,7 +1168,7 @@ MmioOr8 (
IN UINT8 OrData
)
{
- return MmioWrite8 (Address, MmioRead8 (Address) | OrData);
+ return MmioWrite8 (Address, (UINT8) (MmioRead8 (Address) | OrData));
}
/**
@@ -1196,7 +1196,7 @@ MmioAnd8 (
IN UINT8 AndData
)
{
- return MmioWrite8 (Address, MmioRead8 (Address) & AndData);
+ return MmioWrite8 (Address, (UINT8) (MmioRead8 (Address) & AndData));
}
/**
@@ -1228,7 +1228,7 @@ MmioAndThenOr8 (
IN UINT8 OrData
)
{
- return MmioWrite8 (Address, (MmioRead8 (Address) & AndData) | OrData);
+ return MmioWrite8 (Address, (UINT8) ((MmioRead8 (Address) & AndData) | OrData));
}
/**
@@ -1450,7 +1450,7 @@ MmioOr16 (
IN UINT16 OrData
)
{
- return MmioWrite16 (Address, MmioRead16 (Address) | OrData);
+ return MmioWrite16 (Address, (UINT16) (MmioRead16 (Address) | OrData));
}
/**
@@ -1478,7 +1478,7 @@ MmioAnd16 (
IN UINT16 AndData
)
{
- return MmioWrite16 (Address, MmioRead16 (Address) & AndData);
+ return MmioWrite16 (Address, (UINT16) (MmioRead16 (Address) & AndData));
}
/**
@@ -1510,7 +1510,7 @@ MmioAndThenOr16 (
IN UINT16 OrData
)
{
- return MmioWrite16 (Address, (MmioRead16 (Address) & AndData) | OrData);
+ return MmioWrite16 (Address, (UINT16) ((MmioRead16 (Address) & AndData) | OrData));
}
/**
diff --git a/MdePkg/Library/DxeIoLibCpuIo/IoLib.c b/MdePkg/Library/DxeIoLibCpuIo/IoLib.c
index 4736c561dc..64ba3480ef 100644
--- a/MdePkg/Library/DxeIoLibCpuIo/IoLib.c
+++ b/MdePkg/Library/DxeIoLibCpuIo/IoLib.c
@@ -14,6 +14,8 @@
**/
+#include "DxeCpuIoLibInternal.h"
+
//
// Globle varible to cache pointer to CpuIo protocol.
//
diff --git a/MdePkg/Library/DxeMemoryAllocationLib/DxeMemoryAllocationLib.msa b/MdePkg/Library/DxeMemoryAllocationLib/DxeMemoryAllocationLib.msa
index 12d5ea35f1..6f9330b360 100644
--- a/MdePkg/Library/DxeMemoryAllocationLib/DxeMemoryAllocationLib.msa
+++ b/MdePkg/Library/DxeMemoryAllocationLib/DxeMemoryAllocationLib.msa
@@ -38,6 +38,7 @@
</LibraryClassDefinitions>
<SourceFiles>
<Filename>MemoryAllocationLib.c</Filename>
+ <Filename>MemoryAllocationLibInternals.h</Filename>
</SourceFiles>
<PackageDependencies>
<Package PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
diff --git a/MdePkg/Library/DxeMemoryAllocationLib/MemoryAllocationLib.c b/MdePkg/Library/DxeMemoryAllocationLib/MemoryAllocationLib.c
index ab020ddc95..f67473af66 100644
--- a/MdePkg/Library/DxeMemoryAllocationLib/MemoryAllocationLib.c
+++ b/MdePkg/Library/DxeMemoryAllocationLib/MemoryAllocationLib.c
@@ -14,6 +14,7 @@
**/
+#include "MemoryAllocationLibInternals.h"
/**
Allocates one or more 4KB pages of a certain memory type.
diff --git a/MdePkg/Library/DxeMemoryAllocationLib/MemoryAllocationLibInternals.h b/MdePkg/Library/DxeMemoryAllocationLib/MemoryAllocationLibInternals.h
new file mode 100644
index 0000000000..1234e2e6c7
--- /dev/null
+++ b/MdePkg/Library/DxeMemoryAllocationLib/MemoryAllocationLibInternals.h
@@ -0,0 +1,200 @@
+/** @file
+ Internal include file of DXE Memory Allocation Library.
+
+ Copyright (c) 2006, Intel Corporation
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+ Module Name: MemoryAllocationLibInternals.h
+
+**/
+
+#ifndef __DXE_MEMORY_ALLOCATION_LIB_INTERNALS_H__
+#define __DXE_MEMORY_ALLOCATION_LIB_INTERNALS_H__
+
+/**
+ Allocates one or more 4KB pages of a certain memory type.
+
+ Allocates the number of 4KB pages of a certain memory type and returns a pointer to the allocated
+ buffer. The buffer returned is aligned on a 4KB boundary. If Pages is 0, then NULL is returned.
+ If there is not enough memory remaining to satisfy the request, then NULL is returned.
+
+ @param MemoryType The type of memory to allocate.
+ @param Pages The number of 4 KB pages to allocate.
+
+ @return A pointer to the allocated buffer or NULL if allocation fails.
+
+**/
+VOID *
+InternalAllocatePages (
+ IN EFI_MEMORY_TYPE MemoryType,
+ IN UINTN Pages
+ );
+
+/**
+ Allocates one or more 4KB pages of a certain memory type at a specified alignment.
+
+ Allocates the number of 4KB pages specified by Pages of a certain memory type with an alignment
+ specified by Alignment. The allocated buffer is returned. If Pages is 0, then NULL is returned.
+ If there is not enough memory at the specified alignment remaining to satisfy the request, then
+ NULL is returned.
+ If Alignment is not a power of two and Alignment is not zero, then ASSERT().
+
+ @param MemoryType The type of memory to allocate.
+ @param Pages The number of 4 KB pages to allocate.
+ @param Alignment The requested alignment of the allocation. Must be a power of two.
+ If Alignment is zero, then byte alignment is used.
+
+ @return A pointer to the allocated buffer or NULL if allocation fails.
+
+**/
+VOID *
+InternalAllocateAlignedPages (
+ IN EFI_MEMORY_TYPE MemoryType,
+ IN UINTN Pages,
+ IN UINTN Alignment
+ );
+
+/**
+ Allocates a buffer of a certain pool type.
+
+ Allocates the number bytes specified by AllocationSize of a certain pool type and returns a
+ pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is
+ returned. If there is not enough memory remaining to satisfy the request, then NULL is returned.
+
+ @param MemoryType The type of memory to allocate.
+ @param AllocationSize The number of bytes to allocate.
+
+ @return A pointer to the allocated buffer or NULL if allocation fails.
+
+**/
+VOID *
+InternalAllocatePool (
+ IN EFI_MEMORY_TYPE MemoryType,
+ IN UINTN AllocationSize
+ );
+
+/**
+ Allocates and zeros a buffer of a certian pool type.
+
+ Allocates the number bytes specified by AllocationSize of a certian pool type, clears the buffer
+ with zeros, and returns a pointer to the allocated buffer. If AllocationSize is 0, then a valid
+ buffer of 0 size is returned. If there is not enough memory remaining to satisfy the request,
+ then NULL is returned.
+
+ @param PoolType The type of memory to allocate.
+ @param AllocationSize The number of bytes to allocate and zero.
+
+ @return A pointer to the allocated buffer or NULL if allocation fails.
+
+**/
+VOID *
+InternalAllocateZeroPool (
+ IN EFI_MEMORY_TYPE PoolType,
+ IN UINTN AllocationSize
+ );
+
+/**
+ Copies a buffer to an allocated buffer of a certian pool type.
+
+ Allocates the number bytes specified by AllocationSize of a certian pool type, copies
+ AllocationSize bytes from Buffer to the newly allocated buffer, and returns a pointer to the
+ allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there
+ is not enough memory remaining to satisfy the request, then NULL is returned.
+ If Buffer is NULL, then ASSERT().
+ If AllocationSize is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT().
+
+ @param PoolType The type of pool to allocate.
+ @param AllocationSize The number of bytes to allocate and zero.
+ @param Buffer The buffer to copy to the allocated buffer.
+
+ @return A pointer to the allocated buffer or NULL if allocation fails.
+
+**/
+VOID *
+InternalAllocateCopyPool (
+ IN EFI_MEMORY_TYPE PoolType,
+ IN UINTN AllocationSize,
+ IN CONST VOID *Buffer
+ );
+
+/**
+ Allocates a buffer of a certain pool type at a specified alignment.
+
+ Allocates the number bytes specified by AllocationSize of a certain pool type with an alignment
+ specified by Alignment. The allocated buffer is returned. If AllocationSize is 0, then a valid
+ buffer of 0 size is returned. If there is not enough memory at the specified alignment remaining
+ to satisfy the request, then NULL is returned.
+ If Alignment is not a power of two and Alignment is not zero, then ASSERT().
+
+ @param PoolType The type of pool to allocate.
+ @param AllocationSize The number of bytes to allocate.
+ @param Alignment The requested alignment of the allocation. Must be a power of two. If Alignment is zero, then byte alignment is used.
+ If Alignment is zero, then byte alignment is used.
+
+ @return A pointer to the allocated buffer or NULL if allocation fails.
+
+**/
+VOID *
+InternalAllocateAlignedPool (
+ IN EFI_MEMORY_TYPE PoolType,
+ IN UINTN AllocationSize,
+ IN UINTN Alignment
+ );
+
+/**
+ Allocates and zeros a buffer of a certain pool type at a specified alignment.
+
+ Allocates the number bytes specified by AllocationSize of a certain pool type with an alignment
+ specified by Alignment, clears the buffer with zeros, and returns a pointer to the allocated
+ buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there is not
+ enough memory at the specified alignment remaining to satisfy the request, then NULL is returned.
+ If Alignment is not a power of two and Alignment is not zero, then ASSERT().
+
+ @param PoolType The type of pool to allocate.
+ @param AllocationSize The number of bytes to allocate.
+ @param Alignment The requested alignment of the allocation. Must be a power of two.
+ If Alignment is zero, then byte alignment is used.
+
+ @return A pointer to the allocated buffer or NULL if allocation fails.
+
+**/
+VOID *
+InternalAllocateAlignedZeroPool (
+ IN EFI_MEMORY_TYPE PoolType,
+ IN UINTN AllocationSize,
+ IN UINTN Alignment
+ );
+
+/**
+ Copies a buffer to an allocated buffer of a certain pool type at a specified alignment.
+
+ Allocates the number bytes specified by AllocationSize of a certain pool type with an alignment
+ specified by Alignment. The allocated buffer is returned. If AllocationSize is 0, then a valid
+ buffer of 0 size is returned. If there is not enough memory at the specified alignment remaining
+ to satisfy the request, then NULL is returned.
+ If Alignment is not a power of two and Alignment is not zero, then ASSERT().
+
+ @param PoolType The type of pool to allocate.
+ @param AllocationSize The number of bytes to allocate.
+ @param Buffer The buffer to copy to the allocated buffer.
+ @param Alignment The requested alignment of the allocation. Must be a power of two.
+ If Alignment is zero, then byte alignment is used.
+
+ @return A pointer to the allocated buffer or NULL if allocation fails.
+
+**/
+VOID *
+InternalAllocateAlignedCopyPool (
+ IN EFI_MEMORY_TYPE PoolType,
+ IN UINTN AllocationSize,
+ IN CONST VOID *Buffer,
+ IN UINTN Alignment
+ );
+
+#endif
diff --git a/MdePkg/Library/DxeMemoryLib/MemLib.c b/MdePkg/Library/DxeMemoryLib/MemLib.c
index f8f8e30d0a..37182db2b5 100644
--- a/MdePkg/Library/DxeMemoryLib/MemLib.c
+++ b/MdePkg/Library/DxeMemoryLib/MemLib.c
@@ -14,6 +14,8 @@
**/
+#include "MemLibInternals.h"
+
VOID *
EFIAPI
InternalMemCopyMem (
diff --git a/MdePkg/Library/DxeMemoryLib/MemLibGuid.c b/MdePkg/Library/DxeMemoryLib/MemLibGuid.c
index 6f50340bd7..36da5b7424 100644
--- a/MdePkg/Library/DxeMemoryLib/MemLibGuid.c
+++ b/MdePkg/Library/DxeMemoryLib/MemLibGuid.c
@@ -77,12 +77,17 @@ CompareGuid (
IN CONST GUID *Guid2
)
{
- return (BOOLEAN)(
- ReadUnaligned64 ((CONST UINT64*)Guid1)
- == ReadUnaligned64 ((CONST UINT64*)Guid2) &&
- ReadUnaligned64 ((CONST UINT64*)Guid1 + 1)
- == ReadUnaligned64 ((CONST UINT64*)Guid2 + 1)
- );
+ UINT64 LowPartOfGuid1;
+ UINT64 LowPartOfGuid2;
+ UINT64 HighPartOfGuid1;
+ UINT64 HighPartOfGuid2;
+
+ LowPartOfGuid1 = ReadUnaligned64 ((CONST UINT64*) Guid1);
+ LowPartOfGuid2 = ReadUnaligned64 ((CONST UINT64*) Guid2);
+ HighPartOfGuid1 = ReadUnaligned64 ((CONST UINT64*) Guid1 + 1);
+ HighPartOfGuid2 = ReadUnaligned64 ((CONST UINT64*) Guid2 + 1);
+
+ return (BOOLEAN) (LowPartOfGuid1 == LowPartOfGuid2 && HighPartOfGuid1 == HighPartOfGuid2);
}
/**
diff --git a/MdePkg/Library/DxeReportStatusCodeLib/ReportStatusCodeLib.c b/MdePkg/Library/DxeReportStatusCodeLib/ReportStatusCodeLib.c
index 616c237dad..4e140c61c8 100644
--- a/MdePkg/Library/DxeReportStatusCodeLib/ReportStatusCodeLib.c
+++ b/MdePkg/Library/DxeReportStatusCodeLib/ReportStatusCodeLib.c
@@ -40,6 +40,7 @@ static EFI_STATUS_CODE_PROTOCOL *gStatusCode = NULL;
@retval EFI_UNSUPPORTED Status Code Protocol is not available.
**/
+STATIC
EFI_STATUS
InternalReportStatusCode (
IN EFI_STATUS_CODE_TYPE Type,
@@ -78,6 +79,7 @@ InternalReportStatusCode (
@return The size, in bytes, of DevicePath.
**/
+STATIC
UINTN
InternalReportStatusCodeDevicePathSize (
IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath
@@ -139,8 +141,8 @@ CodeTypeToPostCode (
//
if (((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_PROGRESS_CODE) ||
((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE) ) {
- *PostCode = (UINT8) (((Value & EFI_STATUS_CODE_CLASS_MASK) >> 24) << 5);
- *PostCode |= (UINT8) (((Value & EFI_STATUS_CODE_SUBCLASS_MASK) >> 16) & 0x1f);
+ *PostCode = (UINT8) ((((Value & EFI_STATUS_CODE_CLASS_MASK) >> 24) << 5) |
+ (((Value & EFI_STATUS_CODE_SUBCLASS_MASK) >> 16) & 0x1f));
return TRUE;
}
return FALSE;
@@ -533,7 +535,7 @@ ReportProgressCodeEnabled (
VOID
)
{
- return ((PcdGet8(PcdReportStatusCodePropertyMask) & REPORT_STATUS_CODE_PROPERTY_PROGRESS_CODE_ENABLED) != 0);
+ return (BOOLEAN) ((PcdGet8(PcdReportStatusCodePropertyMask) & REPORT_STATUS_CODE_PROPERTY_PROGRESS_CODE_ENABLED) != 0);
}
@@ -555,7 +557,7 @@ ReportErrorCodeEnabled (
VOID
)
{
- return ((PcdGet8(PcdReportStatusCodePropertyMask) & REPORT_STATUS_CODE_PROPERTY_ERROR_CODE_ENABLED) != 0);
+ return (BOOLEAN) ((PcdGet8(PcdReportStatusCodePropertyMask) & REPORT_STATUS_CODE_PROPERTY_ERROR_CODE_ENABLED) != 0);
}
@@ -577,5 +579,5 @@ ReportDebugCodeEnabled (
VOID
)
{
- return ((PcdGet8(PcdReportStatusCodePropertyMask) & REPORT_STATUS_CODE_PROPERTY_DEBUG_CODE_ENABLED) != 0);
+ return (BOOLEAN) ((PcdGet8(PcdReportStatusCodePropertyMask) & REPORT_STATUS_CODE_PROPERTY_DEBUG_CODE_ENABLED) != 0);
}
diff --git a/MdePkg/Library/PeiDxeDebugLibReportStatusCode/DebugLib.c b/MdePkg/Library/PeiDxeDebugLibReportStatusCode/DebugLib.c
index 53f2063324..c14c100f42 100644
--- a/MdePkg/Library/PeiDxeDebugLibReportStatusCode/DebugLib.c
+++ b/MdePkg/Library/PeiDxeDebugLibReportStatusCode/DebugLib.c
@@ -122,11 +122,15 @@ DebugAssert (
EFI_DEBUG_ASSERT_DATA *AssertData;
UINTN TotalSize;
CHAR8 *Temp;
+ UINTN FileNameLength;
+ UINTN DescriptionLength;
//
// Make sure it will all fit in the passed in buffer
//
- TotalSize = sizeof (EFI_DEBUG_ASSERT_DATA) + AsciiStrLen (FileName) + 1 + AsciiStrLen (Description) + 1;
+ FileNameLength = AsciiStrLen (FileName);
+ DescriptionLength = AsciiStrLen (Description);
+ TotalSize = sizeof (EFI_DEBUG_ASSERT_DATA) + FileNameLength + 1 + DescriptionLength + 1;
if (TotalSize <= EFI_STATUS_CODE_DATA_MAX_SIZE) {
//
// Fill in EFI_DEBUG_ASSERT_DATA
@@ -216,7 +220,7 @@ DebugAssertEnabled (
VOID
)
{
- return ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED) != 0);
+ return (BOOLEAN) ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED) != 0);
}
@@ -237,7 +241,7 @@ DebugPrintEnabled (
VOID
)
{
- return ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_DEBUG_PRINT_ENABLED) != 0);
+ return (BOOLEAN) ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_DEBUG_PRINT_ENABLED) != 0);
}
@@ -258,7 +262,7 @@ DebugCodeEnabled (
VOID
)
{
- return ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_DEBUG_CODE_ENABLED) != 0);
+ return (BOOLEAN) ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_DEBUG_CODE_ENABLED) != 0);
}
@@ -279,5 +283,5 @@ DebugClearMemoryEnabled (
VOID
)
{
- return ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_CLEAR_MEMORY_ENABLED) != 0);
+ return (BOOLEAN) ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_CLEAR_MEMORY_ENABLED) != 0);
}
diff --git a/MdePkg/Library/PeiDxePostCodeLibReportStatusCode/PostCode.c b/MdePkg/Library/PeiDxePostCodeLibReportStatusCode/PostCode.c
index c57489dc3d..408ede45c7 100644
--- a/MdePkg/Library/PeiDxePostCodeLibReportStatusCode/PostCode.c
+++ b/MdePkg/Library/PeiDxePostCodeLibReportStatusCode/PostCode.c
@@ -123,7 +123,7 @@ PostCodeEnabled (
VOID
)
{
- return ((PcdGet8(PcdPostCodePropertyMask) & POST_CODE_PROPERTY_POST_CODE_ENABLED) != 0);
+ return (BOOLEAN) ((PcdGet8(PcdPostCodePropertyMask) & POST_CODE_PROPERTY_POST_CODE_ENABLED) != 0);
}
@@ -146,5 +146,5 @@ PostCodeDescriptionEnabled (
VOID
)
{
- return ((PcdGet8(PcdPostCodePropertyMask) & POST_CODE_PROPERTY_POST_CODE_ENABLED) != 0);
+ return (BOOLEAN) ((PcdGet8(PcdPostCodePropertyMask) & POST_CODE_PROPERTY_POST_CODE_ENABLED) != 0);
}
diff --git a/MdePkg/Library/PeiHobLib/HobLib.c b/MdePkg/Library/PeiHobLib/HobLib.c
index 3765d47cdb..43490cc46b 100644
--- a/MdePkg/Library/PeiHobLib/HobLib.c
+++ b/MdePkg/Library/PeiHobLib/HobLib.c
@@ -178,6 +178,7 @@ GetFirstGuidHob (
@return The address of new HOB.
**/
+STATIC
VOID *
InternalPeiCreateHob (
IN UINT16 Type,
diff --git a/MdePkg/Library/PeiIoLibCpuIo/IoHighLevel.c b/MdePkg/Library/PeiIoLibCpuIo/IoHighLevel.c
index 0d8d0de8f4..ed09b4e5aa 100644
--- a/MdePkg/Library/PeiIoLibCpuIo/IoHighLevel.c
+++ b/MdePkg/Library/PeiIoLibCpuIo/IoHighLevel.c
@@ -48,7 +48,7 @@ IoOr8 (
IN UINT8 OrData
)
{
- return IoWrite8 (Port, IoRead8 (Port) | OrData);
+ return IoWrite8 (Port, (UINT8) (IoRead8 (Port) | OrData));
}
/**
@@ -76,7 +76,7 @@ IoAnd8 (
IN UINT8 AndData
)
{
- return IoWrite8 (Port, IoRead8 (Port) & AndData);
+ return IoWrite8 (Port, (UINT8) (IoRead8 (Port) & AndData));
}
/**
@@ -107,7 +107,7 @@ IoAndThenOr8 (
IN UINT8 OrData
)
{
- return IoWrite8 (Port, (IoRead8 (Port) & AndData) | OrData);
+ return IoWrite8 (Port, (UINT8) ((IoRead8 (Port) & AndData) | OrData));
}
/**
@@ -328,7 +328,7 @@ IoOr16 (
IN UINT16 OrData
)
{
- return IoWrite16 (Port, IoRead16 (Port) | OrData);
+ return IoWrite16 (Port, (UINT16) (IoRead16 (Port) | OrData));
}
/**
@@ -356,7 +356,7 @@ IoAnd16 (
IN UINT16 AndData
)
{
- return IoWrite16 (Port, IoRead16 (Port) & AndData);
+ return IoWrite16 (Port, (UINT16) (IoRead16 (Port) & AndData));
}
/**
@@ -387,7 +387,7 @@ IoAndThenOr16 (
IN UINT16 OrData
)
{
- return IoWrite16 (Port, (IoRead16 (Port) & AndData) | OrData);
+ return IoWrite16 (Port, (UINT16) ((IoRead16 (Port) & AndData) | OrData));
}
/**
@@ -1168,7 +1168,7 @@ MmioOr8 (
IN UINT8 OrData
)
{
- return MmioWrite8 (Address, MmioRead8 (Address) | OrData);
+ return MmioWrite8 (Address, (UINT8) (MmioRead8 (Address) | OrData));
}
/**
@@ -1196,7 +1196,7 @@ MmioAnd8 (
IN UINT8 AndData
)
{
- return MmioWrite8 (Address, MmioRead8 (Address) & AndData);
+ return MmioWrite8 (Address, (UINT8) (MmioRead8 (Address) & AndData));
}
/**
@@ -1228,7 +1228,7 @@ MmioAndThenOr8 (
IN UINT8 OrData
)
{
- return MmioWrite8 (Address, (MmioRead8 (Address) & AndData) | OrData);
+ return MmioWrite8 (Address, (UINT8) ((MmioRead8 (Address) & AndData) | OrData));
}
/**
@@ -1450,7 +1450,7 @@ MmioOr16 (
IN UINT16 OrData
)
{
- return MmioWrite16 (Address, MmioRead16 (Address) | OrData);
+ return MmioWrite16 (Address, (UINT16) (MmioRead16 (Address) | OrData));
}
/**
@@ -1478,7 +1478,7 @@ MmioAnd16 (
IN UINT16 AndData
)
{
- return MmioWrite16 (Address, MmioRead16 (Address) & AndData);
+ return MmioWrite16 (Address, (UINT16) (MmioRead16 (Address) & AndData));
}
/**
@@ -1510,7 +1510,7 @@ MmioAndThenOr16 (
IN UINT16 OrData
)
{
- return MmioWrite16 (Address, (MmioRead16 (Address) & AndData) | OrData);
+ return MmioWrite16 (Address, (UINT16) ((MmioRead16 (Address) & AndData) | OrData));
}
/**
diff --git a/MdePkg/Library/PeiMemoryAllocationLib/MemoryAllocationLib.c b/MdePkg/Library/PeiMemoryAllocationLib/MemoryAllocationLib.c
index ae3481d19c..ece64d3dd7 100644
--- a/MdePkg/Library/PeiMemoryAllocationLib/MemoryAllocationLib.c
+++ b/MdePkg/Library/PeiMemoryAllocationLib/MemoryAllocationLib.c
@@ -14,6 +14,7 @@
**/
+#include "MemoryAllocationLibInternals.h"
/**
Allocates one or more 4KB pages of a certain memory type.
diff --git a/MdePkg/Library/PeiMemoryAllocationLib/MemoryAllocationLibInternals.h b/MdePkg/Library/PeiMemoryAllocationLib/MemoryAllocationLibInternals.h
new file mode 100644
index 0000000000..55e594fb38
--- /dev/null
+++ b/MdePkg/Library/PeiMemoryAllocationLib/MemoryAllocationLibInternals.h
@@ -0,0 +1,200 @@
+/** @file
+ Internal include file of PEI Memory Allocation Library.
+
+ Copyright (c) 2006, Intel Corporation
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+ Module Name: MemoryAllocationLibInternals.h
+
+**/
+
+#ifndef __PEI_MEMORY_ALLOCATION_LIB_INTERNALS_H__
+#define __PEI_MEMORY_ALLOCATION_LIB_INTERNALS_H__
+
+/**
+ Allocates one or more 4KB pages of a certain memory type.
+
+ Allocates the number of 4KB pages of a certain memory type and returns a pointer to the allocated
+ buffer. The buffer returned is aligned on a 4KB boundary. If Pages is 0, then NULL is returned.
+ If there is not enough memory remaining to satisfy the request, then NULL is returned.
+
+ @param MemoryType The type of memory to allocate.
+ @param Pages The number of 4 KB pages to allocate.
+
+ @return A pointer to the allocated buffer or NULL if allocation fails.
+
+**/
+VOID *
+InternalAllocatePages (
+ IN EFI_MEMORY_TYPE MemoryType,
+ IN UINTN Pages
+ );
+
+/**
+ Allocates one or more 4KB pages of a certain memory type at a specified alignment.
+
+ Allocates the number of 4KB pages specified by Pages of a certain memory type with an alignment
+ specified by Alignment. The allocated buffer is returned. If Pages is 0, then NULL is returned.
+ If there is not enough memory at the specified alignment remaining to satisfy the request, then
+ NULL is returned.
+ If Alignment is not a power of two and Alignment is not zero, then ASSERT().
+
+ @param MemoryType The type of memory to allocate.
+ @param Pages The number of 4 KB pages to allocate.
+ @param Alignment The requested alignment of the allocation. Must be a power of two.
+ If Alignment is zero, then byte alignment is used.
+
+ @return A pointer to the allocated buffer or NULL if allocation fails.
+
+**/
+VOID *
+InternalAllocateAlignedPages (
+ IN EFI_MEMORY_TYPE MemoryType,
+ IN UINTN Pages,
+ IN UINTN Alignment
+ );
+
+/**
+ Allocates a buffer of a certain pool type.
+
+ Allocates the number bytes specified by AllocationSize of a certain pool type and returns a
+ pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is
+ returned. If there is not enough memory remaining to satisfy the request, then NULL is returned.
+
+ @param MemoryType The type of memory to allocate.
+ @param AllocationSize The number of bytes to allocate.
+
+ @return A pointer to the allocated buffer or NULL if allocation fails.
+
+**/
+VOID *
+InternalAllocatePool (
+ IN EFI_MEMORY_TYPE MemoryType,
+ IN UINTN AllocationSize
+ );
+
+/**
+ Allocates and zeros a buffer of a certian pool type.
+
+ Allocates the number bytes specified by AllocationSize of a certian pool type, clears the buffer
+ with zeros, and returns a pointer to the allocated buffer. If AllocationSize is 0, then a valid
+ buffer of 0 size is returned. If there is not enough memory remaining to satisfy the request,
+ then NULL is returned.
+
+ @param PoolType The type of memory to allocate.
+ @param AllocationSize The number of bytes to allocate and zero.
+
+ @return A pointer to the allocated buffer or NULL if allocation fails.
+
+**/
+VOID *
+InternalAllocateZeroPool (
+ IN EFI_MEMORY_TYPE PoolType,
+ IN UINTN AllocationSize
+ );
+
+/**
+ Copies a buffer to an allocated buffer of a certian pool type.
+
+ Allocates the number bytes specified by AllocationSize of a certian pool type, copies
+ AllocationSize bytes from Buffer to the newly allocated buffer, and returns a pointer to the
+ allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there
+ is not enough memory remaining to satisfy the request, then NULL is returned.
+ If Buffer is NULL, then ASSERT().
+ If AllocationSize is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT().
+
+ @param PoolType The type of pool to allocate.
+ @param AllocationSize The number of bytes to allocate and zero.
+ @param Buffer The buffer to copy to the allocated buffer.
+
+ @return A pointer to the allocated buffer or NULL if allocation fails.
+
+**/
+VOID *
+InternalAllocateCopyPool (
+ IN EFI_MEMORY_TYPE PoolType,
+ IN UINTN AllocationSize,
+ IN CONST VOID *Buffer
+ );
+
+/**
+ Allocates a buffer of a certain pool type at a specified alignment.
+
+ Allocates the number bytes specified by AllocationSize of a certain pool type with an alignment
+ specified by Alignment. The allocated buffer is returned. If AllocationSize is 0, then a valid
+ buffer of 0 size is returned. If there is not enough memory at the specified alignment remaining
+ to satisfy the request, then NULL is returned.
+ If Alignment is not a power of two and Alignment is not zero, then ASSERT().
+
+ @param PoolType The type of pool to allocate.
+ @param AllocationSize The number of bytes to allocate.
+ @param Alignment The requested alignment of the allocation. Must be a power of two. If Alignment is zero, then byte alignment is used.
+ If Alignment is zero, then byte alignment is used.
+
+ @return A pointer to the allocated buffer or NULL if allocation fails.
+
+**/
+VOID *
+InternalAllocateAlignedPool (
+ IN EFI_MEMORY_TYPE PoolType,
+ IN UINTN AllocationSize,
+ IN UINTN Alignment
+ );
+
+/**
+ Allocates and zeros a buffer of a certain pool type at a specified alignment.
+
+ Allocates the number bytes specified by AllocationSize of a certain pool type with an alignment
+ specified by Alignment, clears the buffer with zeros, and returns a pointer to the allocated
+ buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there is not
+ enough memory at the specified alignment remaining to satisfy the request, then NULL is returned.
+ If Alignment is not a power of two and Alignment is not zero, then ASSERT().
+
+ @param PoolType The type of pool to allocate.
+ @param AllocationSize The number of bytes to allocate.
+ @param Alignment The requested alignment of the allocation. Must be a power of two.
+ If Alignment is zero, then byte alignment is used.
+
+ @return A pointer to the allocated buffer or NULL if allocation fails.
+
+**/
+VOID *
+InternalAllocateAlignedZeroPool (
+ IN EFI_MEMORY_TYPE PoolType,
+ IN UINTN AllocationSize,
+ IN UINTN Alignment
+ );
+
+/**
+ Copies a buffer to an allocated buffer of a certain pool type at a specified alignment.
+
+ Allocates the number bytes specified by AllocationSize of a certain pool type with an alignment
+ specified by Alignment. The allocated buffer is returned. If AllocationSize is 0, then a valid
+ buffer of 0 size is returned. If there is not enough memory at the specified alignment remaining
+ to satisfy the request, then NULL is returned.
+ If Alignment is not a power of two and Alignment is not zero, then ASSERT().
+
+ @param PoolType The type of pool to allocate.
+ @param AllocationSize The number of bytes to allocate.
+ @param Buffer The buffer to copy to the allocated buffer.
+ @param Alignment The requested alignment of the allocation. Must be a power of two.
+ If Alignment is zero, then byte alignment is used.
+
+ @return A pointer to the allocated buffer or NULL if allocation fails.
+
+**/
+VOID *
+InternalAllocateAlignedCopyPool (
+ IN EFI_MEMORY_TYPE PoolType,
+ IN UINTN AllocationSize,
+ IN CONST VOID *Buffer,
+ IN UINTN Alignment
+ );
+
+#endif
diff --git a/MdePkg/Library/PeiMemoryAllocationLib/PeiMemoryAllocationLib.msa b/MdePkg/Library/PeiMemoryAllocationLib/PeiMemoryAllocationLib.msa
index 6054b76c7d..14bdff7860 100644
--- a/MdePkg/Library/PeiMemoryAllocationLib/PeiMemoryAllocationLib.msa
+++ b/MdePkg/Library/PeiMemoryAllocationLib/PeiMemoryAllocationLib.msa
@@ -38,6 +38,7 @@
</LibraryClassDefinitions>
<SourceFiles>
<Filename>MemoryAllocationLib.c</Filename>
+ <Filename>MemoryAllocationLibInternals.h</Filename>
</SourceFiles>
<PackageDependencies>
<Package PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
diff --git a/MdePkg/Library/PeiMemoryLib/MemLib.c b/MdePkg/Library/PeiMemoryLib/MemLib.c
index 3a27ab2e83..6f81e21c24 100644
--- a/MdePkg/Library/PeiMemoryLib/MemLib.c
+++ b/MdePkg/Library/PeiMemoryLib/MemLib.c
@@ -14,6 +14,8 @@
**/
+#include "MemLibInternals.h"
+
VOID *
EFIAPI
InternalMemCopyMem (
diff --git a/MdePkg/Library/PeiMemoryLib/MemLibGuid.c b/MdePkg/Library/PeiMemoryLib/MemLibGuid.c
index 6f50340bd7..36da5b7424 100644
--- a/MdePkg/Library/PeiMemoryLib/MemLibGuid.c
+++ b/MdePkg/Library/PeiMemoryLib/MemLibGuid.c
@@ -77,12 +77,17 @@ CompareGuid (
IN CONST GUID *Guid2
)
{
- return (BOOLEAN)(
- ReadUnaligned64 ((CONST UINT64*)Guid1)
- == ReadUnaligned64 ((CONST UINT64*)Guid2) &&
- ReadUnaligned64 ((CONST UINT64*)Guid1 + 1)
- == ReadUnaligned64 ((CONST UINT64*)Guid2 + 1)
- );
+ UINT64 LowPartOfGuid1;
+ UINT64 LowPartOfGuid2;
+ UINT64 HighPartOfGuid1;
+ UINT64 HighPartOfGuid2;
+
+ LowPartOfGuid1 = ReadUnaligned64 ((CONST UINT64*) Guid1);
+ LowPartOfGuid2 = ReadUnaligned64 ((CONST UINT64*) Guid2);
+ HighPartOfGuid1 = ReadUnaligned64 ((CONST UINT64*) Guid1 + 1);
+ HighPartOfGuid2 = ReadUnaligned64 ((CONST UINT64*) Guid2 + 1);
+
+ return (BOOLEAN) (LowPartOfGuid1 == LowPartOfGuid2 && HighPartOfGuid1 == HighPartOfGuid2);
}
/**
diff --git a/MdePkg/Library/PeiPcdLib/PeiPcdLib.c b/MdePkg/Library/PeiPcdLib/PeiPcdLib.c
index f241227fb3..a7892f76f4 100644
--- a/MdePkg/Library/PeiPcdLib/PeiPcdLib.c
+++ b/MdePkg/Library/PeiPcdLib/PeiPcdLib.c
@@ -25,6 +25,7 @@ Module Name: PeiPcdLib.c
@retval PCD_PPI * The pointer to the PCD_PPI.
**/
+STATIC
PCD_PPI *
GetPcdPpiPtr (
VOID
diff --git a/MdePkg/Library/PeiReportStatusCodeLib/ReportStatusCodeLib.c b/MdePkg/Library/PeiReportStatusCodeLib/ReportStatusCodeLib.c
index dda3d717e8..05fdd9cdb8 100644
--- a/MdePkg/Library/PeiReportStatusCodeLib/ReportStatusCodeLib.c
+++ b/MdePkg/Library/PeiReportStatusCodeLib/ReportStatusCodeLib.c
@@ -40,6 +40,7 @@
@retval EFI_UNSUPPORTED Status Code Protocol is not available.
**/
+STATIC
EFI_STATUS
InternalReportStatusCode (
IN EFI_STATUS_CODE_TYPE Type,
@@ -102,8 +103,8 @@ CodeTypeToPostCode (
//
if (((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_PROGRESS_CODE) ||
((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE) ) {
- *PostCode = (UINT8) (((Value & EFI_STATUS_CODE_CLASS_MASK) >> 24) << 5);
- *PostCode |= (UINT8) (((Value & EFI_STATUS_CODE_SUBCLASS_MASK) >> 16) & 0x1f);
+ *PostCode = (UINT8) ((((Value & EFI_STATUS_CODE_CLASS_MASK) >> 24) << 5) |
+ (((Value & EFI_STATUS_CODE_SUBCLASS_MASK) >> 16) & 0x1f));
return TRUE;
}
return FALSE;
@@ -468,7 +469,7 @@ ReportProgressCodeEnabled (
VOID
)
{
- return ((PcdGet8(PcdReportStatusCodePropertyMask) & REPORT_STATUS_CODE_PROPERTY_PROGRESS_CODE_ENABLED) != 0);
+ return (BOOLEAN) ((PcdGet8(PcdReportStatusCodePropertyMask) & REPORT_STATUS_CODE_PROPERTY_PROGRESS_CODE_ENABLED) != 0);
}
@@ -490,7 +491,7 @@ ReportErrorCodeEnabled (
VOID
)
{
- return ((PcdGet8(PcdReportStatusCodePropertyMask) & REPORT_STATUS_CODE_PROPERTY_ERROR_CODE_ENABLED) != 0);
+ return (BOOLEAN) ((PcdGet8(PcdReportStatusCodePropertyMask) & REPORT_STATUS_CODE_PROPERTY_ERROR_CODE_ENABLED) != 0);
}
@@ -512,5 +513,5 @@ ReportDebugCodeEnabled (
VOID
)
{
- return ((PcdGet8(PcdReportStatusCodePropertyMask) & REPORT_STATUS_CODE_PROPERTY_DEBUG_CODE_ENABLED) != 0);
+ return (BOOLEAN) ((PcdGet8(PcdReportStatusCodePropertyMask) & REPORT_STATUS_CODE_PROPERTY_DEBUG_CODE_ENABLED) != 0);
}
diff --git a/MdePkg/Library/PeiServicesTablePointerLibKr1/PeiServicesTablePointer.c b/MdePkg/Library/PeiServicesTablePointerLibKr1/PeiServicesTablePointer.c
index 474748d332..aea35ef034 100644
--- a/MdePkg/Library/PeiServicesTablePointerLibKr1/PeiServicesTablePointer.c
+++ b/MdePkg/Library/PeiServicesTablePointerLibKr1/PeiServicesTablePointer.c
@@ -20,30 +20,7 @@ Abstract:
--*/
-
-/**
- Reads the current value of Kr1.
-
- @return The current value of Kr1.
-
-**/
-UINT64
-EFIAPI
-AsmReadKr1 (
- VOID
- );
-
-/**
- Writes the current value of Kr1.
-
- @param Value The 64-bit value to write to Kr1.
-
-**/
-VOID
-EFIAPI
-AsmWriteKr1 (
- IN UINT64 Value
- );
+#include "PeiServicesTablePointerLibInternals.h"
/**
The function returns the pointer to PeiServices.
diff --git a/MdePkg/Library/PeiServicesTablePointerLibKr1/PeiServicesTablePointerLibInternals.h b/MdePkg/Library/PeiServicesTablePointerLibKr1/PeiServicesTablePointerLibInternals.h
new file mode 100644
index 0000000000..bb0463ef2a
--- /dev/null
+++ b/MdePkg/Library/PeiServicesTablePointerLibKr1/PeiServicesTablePointerLibInternals.h
@@ -0,0 +1,44 @@
+/** @file
+ Include file for internal functions of PEI Services table pointer libary.
+
+ Copyright (c) 2006, Intel Corporation
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+ Module Name: PeiServicesTablePointerLibInternals.h
+
+**/
+
+#ifndef __PEI_SERVICES_TABLE_POINTER_LIB_INTERTALS_H__
+#define __PEI_SERVICES_TABLE_POINTER_LIB_INTERTALS_H__
+
+/**
+ Reads the current value of Kr1.
+
+ @return The current value of Kr1.
+
+**/
+UINT64
+EFIAPI
+AsmReadKr1 (
+ VOID
+ );
+
+/**
+ Writes the current value of Kr1.
+
+ @param Value The 64-bit value to write to Kr1.
+
+**/
+VOID
+EFIAPI
+AsmWriteKr1 (
+ IN UINT64 Value
+ );
+
+#endif
diff --git a/MdePkg/Library/PeiServicesTablePointerLibKr1/PeiServicesTablePointerLibKr1.msa b/MdePkg/Library/PeiServicesTablePointerLibKr1/PeiServicesTablePointerLibKr1.msa
index 2b39ae952f..a73f9a592d 100644
--- a/MdePkg/Library/PeiServicesTablePointerLibKr1/PeiServicesTablePointerLibKr1.msa
+++ b/MdePkg/Library/PeiServicesTablePointerLibKr1/PeiServicesTablePointerLibKr1.msa
@@ -35,6 +35,7 @@
</LibraryClassDefinitions>
<SourceFiles>
<Filename>PeiServicesTablePointer.c</Filename>
+ <Filename>PeiServicesTablePointerLibInternals.h</Filename>
<Filename SupArchList="IPF">Ipf/ReadKr1.s</Filename>
<Filename SupArchList="IPF">Ipf/WriteKr1.s</Filename>
</SourceFiles>
diff --git a/MdePkg/Library/PeiSmbusLib/InternalSmbusLib.h b/MdePkg/Library/PeiSmbusLib/InternalSmbusLib.h
index 47c00a7306..58b093d039 100644
--- a/MdePkg/Library/PeiSmbusLib/InternalSmbusLib.h
+++ b/MdePkg/Library/PeiSmbusLib/InternalSmbusLib.h
@@ -25,6 +25,22 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
//
// Declaration for internal functions
//
+
+/**
+ Gets Smbus PPIs.
+
+ This internal function retrieves Smbus PPI from PPI database.
+
+ @param PeiServices An indirect pointer to the EFI_PEI_SERVICES published by the PEI Foundation.
+
+ @return The pointer to Smbus PPI.
+
+**/
+EFI_PEI_SMBUS_PPI *
+InternalGetSmbusPpi (
+ EFI_PEI_SERVICES **PeiServices
+ );
+
/**
Executes an SMBus operation to an SMBus controller.
diff --git a/MdePkg/Library/UefiDebugLibConOut/DebugLib.c b/MdePkg/Library/UefiDebugLibConOut/DebugLib.c
index 1494607309..3fe3b6e043 100644
--- a/MdePkg/Library/UefiDebugLibConOut/DebugLib.c
+++ b/MdePkg/Library/UefiDebugLibConOut/DebugLib.c
@@ -180,7 +180,7 @@ DebugAssertEnabled (
VOID
)
{
- return ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED) != 0);
+ return (BOOLEAN) ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED) != 0);
}
@@ -201,7 +201,7 @@ DebugPrintEnabled (
VOID
)
{
- return ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_DEBUG_PRINT_ENABLED) != 0);
+ return (BOOLEAN) ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_DEBUG_PRINT_ENABLED) != 0);
}
@@ -222,7 +222,7 @@ DebugCodeEnabled (
VOID
)
{
- return ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_DEBUG_CODE_ENABLED) != 0);
+ return (BOOLEAN) ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_DEBUG_CODE_ENABLED) != 0);
}
@@ -243,5 +243,5 @@ DebugClearMemoryEnabled (
VOID
)
{
- return ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_CLEAR_MEMORY_ENABLED) != 0);
+ return (BOOLEAN) ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_CLEAR_MEMORY_ENABLED) != 0);
}
diff --git a/MdePkg/Library/UefiDebugLibStdErr/DebugLib.c b/MdePkg/Library/UefiDebugLibStdErr/DebugLib.c
index 041fbc72f0..9338217762 100644
--- a/MdePkg/Library/UefiDebugLibStdErr/DebugLib.c
+++ b/MdePkg/Library/UefiDebugLibStdErr/DebugLib.c
@@ -180,7 +180,7 @@ DebugAssertEnabled (
VOID
)
{
- return ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED) != 0);
+ return (BOOLEAN) ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED) != 0);
}
@@ -201,7 +201,7 @@ DebugPrintEnabled (
VOID
)
{
- return ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_DEBUG_PRINT_ENABLED) != 0);
+ return (BOOLEAN) ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_DEBUG_PRINT_ENABLED) != 0);
}
@@ -222,7 +222,7 @@ DebugCodeEnabled (
VOID
)
{
- return ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_DEBUG_CODE_ENABLED) != 0);
+ return (BOOLEAN) ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_DEBUG_CODE_ENABLED) != 0);
}
@@ -243,5 +243,5 @@ DebugClearMemoryEnabled (
VOID
)
{
- return ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_CLEAR_MEMORY_ENABLED) != 0);
+ return (BOOLEAN) ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_CLEAR_MEMORY_ENABLED) != 0);
}
diff --git a/MdePkg/Library/UefiDriverEntryPoint/DriverEntryPoint.c b/MdePkg/Library/UefiDriverEntryPoint/DriverEntryPoint.c
index 57b6a755b2..9ec19e3f4a 100644
--- a/MdePkg/Library/UefiDriverEntryPoint/DriverEntryPoint.c
+++ b/MdePkg/Library/UefiDriverEntryPoint/DriverEntryPoint.c
@@ -25,6 +25,7 @@ EFI_EVENT _mDriverExitBootServicesNotifyEvent;
@retval EFI_SUCCESS
**/
+STATIC
EFI_STATUS
EFIAPI
_DriverUnloadHandler (
@@ -70,6 +71,7 @@ _DriverUnloadHandler (
@param Context Event Context.
**/
+STATIC
VOID
EFIAPI
_DriverExitBootServices (
diff --git a/MdePkg/Library/UefiLib/UefiLib.c b/MdePkg/Library/UefiLib/UefiLib.c
index 1140854303..a2dd6a8c12 100644
--- a/MdePkg/Library/UefiLib/UefiLib.c
+++ b/MdePkg/Library/UefiLib/UefiLib.c
@@ -24,13 +24,20 @@
@retval FALSE Language 1 and language 2 are not the same.
**/
+STATIC
BOOLEAN
CompareIso639LanguageCode (
IN CONST CHAR8 *Language1,
IN CONST CHAR8 *Language2
)
{
- return (BOOLEAN) (ReadUnaligned24 ((CONST UINT32 *) Language1) == ReadUnaligned24 ((CONST UINT32 *) Language2));
+ UINT32 Name1;
+ UINT32 Name2;
+
+ Name1 = ReadUnaligned24 ((CONST UINT32 *) Language1);
+ Name2 = ReadUnaligned24 ((CONST UINT32 *) Language2);
+
+ return (BOOLEAN) (Name1 == Name2);
}
/**
diff --git a/MdePkg/Library/UefiLib/UefiNotTiano.c b/MdePkg/Library/UefiLib/UefiNotTiano.c
index 9342da9744..ce59eaf417 100644
--- a/MdePkg/Library/UefiLib/UefiNotTiano.c
+++ b/MdePkg/Library/UefiLib/UefiNotTiano.c
@@ -25,6 +25,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
checked correctly since it is now mapped into CreateEventEx() in UEFI 2.0.
**/
+STATIC
VOID
EFIAPI
InternalEmptyFuntion (