#include "BaseLibInternals.h"\r
\r
/**\r
- Worker function that returns a bit field from Operand\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
}\r
\r
/**\r
- Worker function that reads a bit field from Operand, performs a bitwise OR, \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
}\r
\r
/**\r
- Worker function that reads a bit field from Operand, performs a bitwise AND, \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
UINT8\r
EFIAPI\r
CalculateSum8 (\r
- IN CONST UINT8 *Buffer,\r
- IN UINTN Length\r
+ IN CONST UINT8 *Buffer,\r
+ IN UINTN Length\r
)\r
{\r
UINT8 Sum;\r
UINT8\r
EFIAPI\r
CalculateCheckSum8 (\r
- IN CONST UINT8 *Buffer,\r
- IN UINTN Length\r
+ IN CONST UINT8 *Buffer,\r
+ IN UINTN Length\r
)\r
{\r
UINT8 CheckSum;\r
UINT16\r
EFIAPI\r
CalculateSum16 (\r
- IN CONST UINT16 *Buffer,\r
- IN UINTN Length\r
+ IN CONST UINT16 *Buffer,\r
+ IN UINTN Length\r
)\r
{\r
UINT16 Sum;\r
UINT16\r
EFIAPI\r
CalculateCheckSum16 (\r
- IN CONST UINT16 *Buffer,\r
- IN UINTN Length\r
+ IN CONST UINT16 *Buffer,\r
+ IN UINTN Length\r
)\r
{\r
UINT16 CheckSum;\r
UINT32\r
EFIAPI\r
CalculateSum32 (\r
- IN CONST UINT32 *Buffer,\r
- IN UINTN Length\r
+ IN CONST UINT32 *Buffer,\r
+ IN UINTN Length\r
)\r
{\r
UINT32 Sum;\r
UINT32\r
EFIAPI\r
CalculateCheckSum32 (\r
- IN CONST UINT32 *Buffer,\r
- IN UINTN Length\r
+ IN CONST UINT32 *Buffer,\r
+ IN UINTN Length\r
)\r
{\r
UINT32 CheckSum;\r
UINT64\r
EFIAPI\r
CalculateSum64 (\r
- IN CONST UINT64 *Buffer,\r
- IN UINTN Length\r
+ IN CONST UINT64 *Buffer,\r
+ IN UINTN Length\r
)\r
{\r
UINT64 Sum;\r
UINT64\r
EFIAPI\r
CalculateCheckSum64 (\r
- IN CONST UINT64 *Buffer,\r
- IN UINTN Length\r
+ IN CONST UINT64 *Buffer,\r
+ IN UINTN Length\r
)\r
{\r
UINT64 CheckSum;\r
#include "BaseLibInternals.h"\r
\r
/**\r
- Worker function that locates the Node in the List\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 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
LIST_ENTRY *\r
EFIAPI\r
InitializeListHead (\r
- IN OUT LIST_ENTRY *List\r
+ IN OUT LIST_ENTRY *ListHead\r
)\r
\r
{\r
- ASSERT (List != NULL);\r
+ ASSERT (ListHead != NULL);\r
\r
- List->ForwardLink = List;\r
- List->BackLink = List;\r
- return List;\r
+ ListHead->ForwardLink = ListHead;\r
+ ListHead->BackLink = ListHead;\r
+ return ListHead;\r
}\r
\r
/**\r
LIST_ENTRY *\r
EFIAPI\r
InsertHeadList (\r
- IN OUT LIST_ENTRY *List,\r
- IN OUT LIST_ENTRY *Entry\r
+ IN OUT LIST_ENTRY *ListHead,\r
+ IN OUT LIST_ENTRY *Entry\r
)\r
{\r
//\r
// ASSERT List not too long and Entry is not one of the nodes of List\r
//\r
- ASSERT (!IsNodeInList (List, Entry));\r
+ ASSERT (!IsNodeInList (ListHead, Entry));\r
\r
- Entry->ForwardLink = List->ForwardLink;\r
- Entry->BackLink = List;\r
+ Entry->ForwardLink = ListHead->ForwardLink;\r
+ Entry->BackLink = ListHead;\r
Entry->ForwardLink->BackLink = Entry;\r
- List->ForwardLink = Entry;\r
- return List;\r
+ ListHead->ForwardLink = Entry;\r
+ return ListHead;\r
}\r
\r
/**\r
LIST_ENTRY *\r
EFIAPI\r
InsertTailList (\r
- IN OUT LIST_ENTRY *List,\r
- IN OUT LIST_ENTRY *Entry\r
+ IN OUT LIST_ENTRY *ListHead,\r
+ IN OUT LIST_ENTRY *Entry\r
)\r
{\r
//\r
// ASSERT List not too long and Entry is not one of the nodes of List\r
//\r
- ASSERT (!IsNodeInList (List, Entry));\r
+ ASSERT (!IsNodeInList (ListHead, Entry));\r
\r
- Entry->ForwardLink = List;\r
- Entry->BackLink = List->BackLink;\r
+ Entry->ForwardLink = ListHead;\r
+ Entry->BackLink = ListHead->BackLink;\r
Entry->BackLink->ForwardLink = Entry;\r
- List->BackLink = Entry;\r
- return List;\r
+ ListHead->BackLink = Entry;\r
+ return ListHead;\r
}\r
\r
/**\r
LIST_ENTRY *\r
EFIAPI\r
GetFirstNode (\r
- IN CONST LIST_ENTRY *List\r
+ IN CONST LIST_ENTRY *List\r
)\r
{\r
//\r
LIST_ENTRY *\r
EFIAPI\r
GetNextNode (\r
- IN CONST LIST_ENTRY *List,\r
- IN CONST LIST_ENTRY *Node\r
+ IN CONST LIST_ENTRY *List,\r
+ IN CONST LIST_ENTRY *Node\r
)\r
{\r
//\r
BOOLEAN\r
EFIAPI\r
IsListEmpty (\r
- IN CONST LIST_ENTRY *List\r
+ IN CONST LIST_ENTRY *ListHead\r
)\r
{\r
//\r
// ASSERT List not too long\r
//\r
- ASSERT (IsNodeInList (List, List));\r
+ ASSERT (IsNodeInList (ListHead, ListHead));\r
\r
- return (BOOLEAN)(List->ForwardLink == List);\r
+ return (BOOLEAN)(ListHead->ForwardLink == ListHead);\r
}\r
\r
/**\r
BOOLEAN\r
EFIAPI\r
IsNull (\r
- IN CONST LIST_ENTRY *List,\r
- IN CONST LIST_ENTRY *Node\r
+ IN CONST LIST_ENTRY *List,\r
+ IN CONST LIST_ENTRY *Node\r
)\r
{\r
//\r
BOOLEAN\r
EFIAPI\r
IsNodeAtEnd (\r
- IN CONST LIST_ENTRY *List,\r
- IN CONST LIST_ENTRY *Node\r
+ IN CONST LIST_ENTRY *List,\r
+ IN CONST LIST_ENTRY *Node\r
)\r
{\r
//\r
\r
@param FirstEntry A pointer to a node in a linked list.\r
@param SecondEntry A pointer to another node in the same linked list.\r
-\r
+ \r
@return SecondEntry.\r
\r
**/\r
LIST_ENTRY *\r
EFIAPI\r
SwapListEntries (\r
- IN OUT LIST_ENTRY *FirstEntry,\r
- IN OUT LIST_ENTRY *SecondEntry\r
+ IN OUT LIST_ENTRY *FirstEntry,\r
+ IN OUT LIST_ENTRY *SecondEntry\r
)\r
{\r
LIST_ENTRY *Ptr;\r
LIST_ENTRY *\r
EFIAPI\r
RemoveEntryList (\r
- IN CONST LIST_ENTRY *Entry\r
+ IN CONST LIST_ENTRY *Entry\r
)\r
{\r
ASSERT (!IsListEmpty (Entry));\r
This function shifts the 64-bit value Operand to the right by Count bits. The\r
high Count bits are set to bit 63 of Operand. The shifted value is returned.\r
\r
- If Count is greater than 63, then ASSERT().\r
-\r
@param Operand The 64-bit operand to shift right.\r
@param Count The number of bits to shift right.\r
\r
\r
@param Operand A 64-bit unsigned value.\r
\r
- @return The byte swaped Operand.\r
+ @return The byte swapped Operand.\r
\r
**/\r
UINT64\r
unsigned value Divisor and generates a 64-bit unsigned quotient. This\r
function returns the 64-bit unsigned quotient.\r
\r
- @param Dividend A 64-bit unsigned value.\r
+ @param Dividend A 64-bit unsigned value.\r
@param Divisor A 32-bit unsigned value.\r
\r
@return Dividend / Divisor\r
}\r
\r
/**\r
- Divides a 64-bit unsigned integer by a 32-bit unsigned integer\r
- and generates a 32-bit unsigned remainder.\r
+ Divides a 64-bit unsigned integer by a 32-bit unsigned integer and\r
+ generates a 32-bit unsigned remainder.\r
\r
This function divides the 64-bit unsigned value Dividend by the 32-bit\r
unsigned value Divisor and generates a 32-bit remainder. This function\r
InternalMathDivRemU64x32 (\r
IN UINT64 Dividend,\r
IN UINT32 Divisor,\r
- OUT UINT32 *Remainder OPTIONAL\r
+ OUT UINT32 *Remainder OPTIONAL\r
)\r
{\r
if (Remainder != NULL) {\r
InternalMathDivRemU64x64 (\r
IN UINT64 Dividend,\r
IN UINT64 Divisor,\r
- OUT UINT64 *Remainder OPTIONAL\r
+ OUT UINT64 *Remainder OPTIONAL\r
)\r
{\r
if (Remainder != NULL) {\r
\r
/**\r
Divides a 64-bit signed integer by a 64-bit signed integer and\r
- generates a 64-bit signed result and a optional 64-bit signed remainder.\r
+ generates a 64-bit signed result and an optional 64-bit signed remainder.\r
\r
This function divides the 64-bit signed value Dividend by the 64-bit\r
signed value Divisor and generates a 64-bit signed quotient. If Remainder\r
Checks ASSERT condition for JumpBuffer.\r
\r
If JumpBuffer is NULL, then ASSERT().\r
- If JumpBuffer is not aligned on a BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT\r
- boundary, 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
Compares up to a specified length the contents of two Null-terminated Unicode strings,\r
and returns the difference between the first mismatched Unicode characters.\r
-\r
+ \r
This function compares the Null-terminated Unicode string FirstString to the\r
Null-terminated Unicode string SecondString. At most, Length Unicode\r
characters will be compared. If Length is 0, then 0 is returned. If\r
CHAR16 *\r
EFIAPI\r
StrStr (\r
- IN CONST CHAR16 *String,\r
- IN CONST CHAR16 *SearchString\r
+ IN CONST CHAR16 *String,\r
+ IN CONST CHAR16 *SearchString\r
)\r
{\r
CONST CHAR16 *FirstMatch;\r
UINTN\r
EFIAPI\r
StrDecimalToUintn (\r
- IN CONST CHAR16 *String\r
+ IN CONST CHAR16 *String\r
)\r
{\r
UINTN Result;\r
UINT64\r
EFIAPI\r
StrDecimalToUint64 (\r
- IN CONST CHAR16 *String\r
+ IN CONST CHAR16 *String\r
)\r
{\r
UINT64 Result;\r
UINTN\r
EFIAPI\r
StrHexToUintn (\r
- IN CONST CHAR16 *String\r
+ IN CONST CHAR16 *String\r
)\r
{\r
UINTN Result;\r
\r
@retval Value translated from String.\r
\r
- **/\r
+**/\r
UINT64\r
EFIAPI\r
StrHexToUint64 (\r
- IN CONST CHAR16 *String\r
+ IN CONST CHAR16 *String\r
)\r
{\r
UINT64 Result;\r
CHAR8 *\r
EFIAPI\r
UnicodeStrToAsciiStr (\r
- IN CONST CHAR16 *Source,\r
- OUT CHAR8 *Destination\r
+ IN CONST CHAR16 *Source,\r
+ OUT CHAR8 *Destination\r
)\r
{\r
CHAR8 *ReturnValue;\r
@param FirstString Pointer to a Null-terminated ASCII string.\r
@param SecondString Pointer to a Null-terminated ASCII string.\r
@param Length Maximum number of ASCII characters for compare.\r
-\r
+ \r
@retval ==0 FirstString is identical to SecondString.\r
@retval !=0 FirstString is not identical to SecondString.\r
\r
CHAR8 *\r
EFIAPI\r
AsciiStrStr (\r
- IN CONST CHAR8 *String,\r
- IN CONST CHAR8 *SearchString\r
+ IN CONST CHAR8 *String,\r
+ IN CONST CHAR8 *SearchString\r
)\r
{\r
CONST CHAR8 *FirstMatch;\r
UINT64\r
EFIAPI\r
AsciiStrDecimalToUint64 (\r
- IN CONST CHAR8 *String\r
+ IN CONST CHAR8 *String\r
)\r
{\r
UINT64 Result;\r
UINTN\r
EFIAPI\r
AsciiStrHexToUintn (\r
- IN CONST CHAR8 *String\r
+ IN CONST CHAR8 *String\r
)\r
{\r
UINTN Result;\r
UINT64\r
EFIAPI\r
AsciiStrHexToUint64 (\r
- IN CONST CHAR8 *String\r
+ IN CONST CHAR8 *String\r
)\r
{\r
UINT64 Result;\r
from little endian to big endian or vice versa. The byte swapped value is\r
returned.\r
\r
- @param Value Operand A 16-bit unsigned value.\r
+ @param Value A 16-bit unsigned value.\r
\r
- @return The byte swapped Operand.\r
+ @return The byte swapped value.\r
\r
**/\r
UINT16\r
EFIAPI\r
SwapBytes16 (\r
- IN UINT16 Operand\r
+ IN UINT16 Value\r
)\r
{\r
- return (UINT16) ((Operand << 8) | (Operand >> 8));\r
+ return (UINT16) ((Value<< 8) | (Value>> 8));\r
}\r
from little endian to big endian or vice versa. The byte swapped value is\r
returned.\r
\r
- @param Value Operand A 32-bit unsigned value.\r
+ @param Value A 32-bit unsigned value.\r
\r
- @return The byte swapped Operand.\r
+ @return The byte swapped Value.\r
\r
**/\r
UINT32\r
EFIAPI\r
SwapBytes32 (\r
- IN UINT32 Operand\r
+ IN UINT32 Value\r
)\r
{\r
UINT32 LowerBytes;\r
UINT32 HigherBytes;\r
\r
- LowerBytes = (UINT32) SwapBytes16 ((UINT16) Operand);\r
- HigherBytes = (UINT32) SwapBytes16 ((UINT16) (Operand >> 16));\r
+ LowerBytes = (UINT32) SwapBytes16 ((UINT16) Value);\r
+ HigherBytes = (UINT32) SwapBytes16 ((UINT16) (Value >> 16));\r
\r
return (LowerBytes << 16 | HigherBytes);\r
}\r
from little endian to big endian or vice versa. The byte swapped value is\r
returned.\r
\r
- @param Value Operand A 64-bit unsigned value.\r
+ @param Value A 64-bit unsigned value.\r
\r
- @return The byte swapped Operand.\r
+ @return The byte swapped Value.\r
\r
**/\r
UINT64\r
EFIAPI\r
SwapBytes64 (\r
- IN UINT64 Operand\r
+ IN UINT64 Value\r
)\r
{\r
- return InternalMathSwapBytes64 (Operand);\r
+ return InternalMathSwapBytes64 (Value);\r
}\r
a single parameter of type VOID * that specifies the new backing \r
store pointer.\r
\r
+\r
**/\r
VOID\r
EFIAPI\r
SPIN_LOCK *\r
EFIAPI\r
InitializeSpinLock (\r
- OUT SPIN_LOCK *SpinLock\r
+ OUT SPIN_LOCK *SpinLock\r
)\r
{\r
ASSERT (SpinLock != NULL);\r
operation.\r
@param CompareValue Pointer value used in compare operation.\r
@param ExchangeValue Pointer value used in exchange operation.\r
- \r
- @return The original *Value before exchange.\r
\r
+ @return The original *Value before exchange.\r
**/\r
VOID *\r
EFIAPI\r
SPIN_LOCK *\r
EFIAPI\r
InitializeSpinLock (\r
- OUT SPIN_LOCK *SpinLock\r
+ OUT SPIN_LOCK *SpinLock\r
)\r
{\r
ASSERT (SpinLock != NULL);\r
SPIN_LOCK *\r
EFIAPI\r
InitializeSpinLock (\r
- OUT SPIN_LOCK *SpinLock\r
+ OUT SPIN_LOCK *SpinLock\r
)\r
{\r
ASSERT (SpinLock != NULL);\r
operation.\r
@param CompareValue Pointer value used in compare operation.\r
@param ExchangeValue Pointer value used in exchange operation.\r
- \r
- @return The original *Value before exchange.\r
\r
+ @return The original *Value before exchange.\r
**/\r
VOID *\r
EFIAPI\r
VOID\r
EFIAPI\r
AsmFxRestore (\r
- IN CONST IA32_FX_BUFFER *Buffer\r
+ IN CONST IA32_FX_BUFFER *Buffer\r
)\r
{\r
ASSERT (Buffer != NULL);\r
}\r
\r
/**\r
- Zero-extend a 32-bit value and writes it to a Machine Specific Register(MSR).\r
+ Writes a 32-bit value to a Machine Specific Register(MSR), and returns the value.\r
+ The upper 32-bits of the MSR are set to zero.\r
\r
Writes the 32-bit value specified by Value to the MSR specified by Index. The\r
upper 32-bits of the MSR write are set to zero. The 32-bit value written to\r
/**\r
Writes a bit field to an MSR.\r
\r
- Writes Value to a bit field in the lower 32-bits of a 64-bit MSR. The bit\r
+ Writes Value to a bit field in the lower 32-bits of a 64-bit MSR. The bit\r
field is specified by the StartBit and the EndBit. All other bits in the\r
destination MSR are preserved. The lower 32-bits of the MSR written is\r
returned. The caller must either guarantee that Index and the data written \r
@param EndBit The ordinal of the most significant bit in the bit field.\r
Range 0..63.\r
\r
- @return The value written back to the MSR.\r
+ @return The value read from the MSR.\r
\r
**/\r
UINT64\r
#include "BaseLibInternals.h"\r
\r
/**\r
- Reads the current Interrupt Descriptor Table Register(GDTR) descriptor.\r
+ Reads the current Interrupt Descriptor Table Register(IDTR) descriptor.\r
\r
Reads and returns the current IDTR descriptor and returns it in Idtr. This\r
function is only available on IA-32 and x64.\r
Transfers control to a 16-bit real mode entry point and returns the results.\r
\r
Transfers control to a 16-bit real mode entry point and returns the results.\r
- AsmPrepareThunk16() must be called with ThunkContext before this function is\r
- used. This function must be called with interrupts disabled.\r
-\r
+ AsmPrepareThunk16() must be called with ThunkContext before this function is used.\r
+ This function must be called with interrupts disabled.\r
+\r
+ The register state from the RealModeState field of ThunkContext is restored just prior \r
+ to calling the 16-bit real mode entry point. This includes the EFLAGS field of RealModeState, \r
+ which is used to set the interrupt state when a 16-bit real mode entry point is called.\r
+ Control is transferred to the 16-bit real mode entry point specified by the CS and Eip fields of RealModeState.\r
+ The stack is initialized to the SS and ESP fields of RealModeState. Any parameters passed to \r
+ the 16-bit real mode code must be populated by the caller at SS:ESP prior to calling this function. \r
+ The 16-bit real mode entry point is invoked with a 16-bit CALL FAR instruction,\r
+ so when accessing stack contents, the 16-bit real mode code must account for the 16-bit segment \r
+ and 16-bit offset of the return address that were pushed onto the stack. The 16-bit real mode entry \r
+ point must exit with a RETF instruction. The register state is captured into RealModeState immediately \r
+ after the RETF instruction is executed.\r
+ \r
+ If EFLAGS specifies interrupts enabled, or any of the 16-bit real mode code enables interrupts, \r
+ or any of the 16-bit real mode code makes a SW interrupt, then the caller is responsible for making sure \r
+ the IDT at address 0 is initialized to handle any HW or SW interrupts that may occur while in 16-bit real mode. \r
+ \r
+ If EFLAGS specifies interrupts enabled, or any of the 16-bit real mode code enables interrupts, \r
+ then the caller is responsible for making sure the 8259 PIC is in a state compatible with 16-bit real mode. \r
+ This includes the base vectors, the interrupt masks, and the edge/level trigger mode.\r
+ \r
+ If THUNK_ATTRIBUTE_BIG_REAL_MODE is set in the ThunkAttributes field of ThunkContext, then the user code \r
+ is invoked in big real mode. Otherwise, the user code is invoked in 16-bit real mode with 64KB segment limits.\r
+ \r
+ If neither THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 nor THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL are set in \r
+ ThunkAttributes, then it is assumed that the user code did not enable the A20 mask, and no attempt is made to \r
+ disable the A20 mask.\r
+ \r
+ If THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 is set and THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL is clear in \r
+ ThunkAttributes, then attempt to use the INT 15 service to disable the A20 mask. If this INT 15 call fails, \r
+ then attempt to disable the A20 mask by directly accessing the 8042 keyboard controller I/O ports.\r
+ \r
+ If THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 is clear and THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL is set in \r
+ ThunkAttributes, then attempt to disable the A20 mask by directly accessing the 8042 keyboard controller I/O ports.\r
+ \r
If ThunkContext is NULL, then ASSERT().\r
If AsmPrepareThunk16() was not previously called with ThunkContext, then ASSERT().\r
+ If both THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 and THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL are set in \r
+ ThunkAttributes, then ASSERT().\r
\r
@param ThunkContext A pointer to the context structure that describes the\r
16-bit real mode code to call.\r
caller only need to perform a single 16-bit real mode thunk, then this\r
service should be used. If the caller intends to make more than one 16-bit\r
real mode thunk, then it is more efficient if AsmPrepareThunk16() is called\r
- once and AsmThunk16() can be called for each 16-bit real mode thunk. This\r
- function must be called with interrupts disabled.\r
+ once and AsmThunk16() can be called for each 16-bit real mode thunk.\r
\r
- If ThunkContext is NULL, then ASSERT().\r
+ See AsmPrepareThunk16() and AsmThunk16() for the detailed description and ASSERT() conditions.\r
\r
@param ThunkContext A pointer to the context structure that describes the\r
16-bit real mode code to call.\r
#include "BaseLibInternals.h"\r
\r
/**\r
- Writes the current Interrupt Descriptor Table Register(GDTR) descriptor.\r
+ Writes the current Interrupt Descriptor Table Register(IDTR) descriptor.\r
\r
Writes the current IDTR descriptor and returns it in Idtr. This function is\r
only available on IA-32 and x64.\r