/** @file\r
- Memory-only library functions with no library constructor/destructor\r
+ Provides string functions, linked list functions, math functions, synchronization\r
+ functions, and CPU architecture specific functions.\r
\r
- Copyright (c) 2006 - 2007, Intel Corporation\r
- All rights reserved. This program and the accompanying materials\r
- are licensed and made available under the terms and conditions of the BSD License\r
- which accompanies this distribution. The full text of the license may be found at\r
- http://opensource.org/licenses/bsd-license.php\r
+Copyright (c) 2006 - 2008, Intel Corporation\r
+All rights reserved. This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution. The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
\r
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
\r
**/\r
\r
#ifndef __BASE_LIB__\r
#define __BASE_LIB__\r
\r
-//\r
-// Definitions for architecture specific types\r
-// These include SPIN_LOCK and BASE_LIBRARY_JUMP_BUFFER\r
-//\r
-\r
-//\r
-// SPIN_LOCK\r
-//\r
+///\r
+/// Definitions for SPIN_LOCK\r
+///\r
typedef volatile UINTN SPIN_LOCK;\r
\r
-#if defined (MDE_CPU_IA32)\r
//\r
-// IA32 context buffer used by SetJump() and LongJump()\r
+// Definitions for architecture specific types\r
//\r
+#if defined (MDE_CPU_IA32)\r
+///\r
+/// IA32 context buffer used by SetJump() and LongJump()\r
+///\r
typedef struct {\r
UINT32 Ebx;\r
UINT32 Esi;\r
\r
#elif defined (MDE_CPU_IPF)\r
\r
-//\r
-// IPF context buffer used by SetJump() and LongJump()\r
-//\r
+///\r
+/// IPF context buffer used by SetJump() and LongJump()\r
+///\r
typedef struct {\r
UINT64 F2[2];\r
UINT64 F3[2];\r
#define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 0x10\r
\r
#elif defined (MDE_CPU_X64)\r
-//\r
-// X64 context buffer used by SetJump() and LongJump()\r
-//\r
+///\r
+/// X64 context buffer used by SetJump() and LongJump()\r
+///\r
typedef struct {\r
UINT64 Rbx;\r
UINT64 Rsp;\r
#define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 8\r
\r
#elif defined (MDE_CPU_EBC)\r
-//\r
-// EBC context buffer used by SetJump() and LongJump()\r
-//\r
+///\r
+/// EBC context buffer used by SetJump() and LongJump()\r
+///\r
typedef struct {\r
UINT64 R0;\r
UINT64 R1;\r
@param FirstString Pointer to a Null-terminated Unicode string.\r
@param SecondString Pointer to a Null-terminated Unicode string.\r
\r
- @retval 0 FirstString is identical to SecondString.\r
- @retval !=0 FirstString is not identical to SecondString.\r
+ @retval 0 FirstString is identical to SecondString.\r
+ @return others FirstString is not identical to SecondString.\r
\r
**/\r
INTN\r
@param SecondString Pointer to a Null-terminated Unicode string.\r
@param Length Maximum number of Unicode characters to compare.\r
\r
- @retval 0 FirstString is identical to SecondString.\r
- @retval !=0 FirstString is not identical to SecondString.\r
+ @retval 0 FirstString is identical to SecondString.\r
+ @return others FirstString is not identical to SecondString.\r
\r
**/\r
INTN\r
@param SearchString Pointer to a Null-terminated Unicode string to search for.\r
\r
@retval NULL If the SearchString does not appear in String.\r
- @retval !NULL If there is a match.\r
+ @return others If there is a match.\r
\r
**/\r
CHAR16 *\r
\r
@param String Pointer to a Null-terminated Unicode string.\r
\r
- @retval UINTN\r
+ @retval Value translated from String.\r
\r
**/\r
UINTN\r
\r
@param String Pointer to a Null-terminated Unicode string.\r
\r
- @retval UINT64\r
+ @retval Value translated from String.\r
\r
**/\r
UINT64\r
\r
@param String Pointer to a Null-terminated Unicode string.\r
\r
- @retval UINTN\r
+ @retval Value translated from String.\r
\r
**/\r
UINTN\r
\r
@param String Pointer to a Null-terminated Unicode string.\r
\r
- @retval UINT64\r
+ @retval Value translated from String.\r
\r
**/\r
UINT64\r
EFIAPI\r
NibbleToHexChar (\r
IN UINT8 Nibble\r
- )\r
-;\r
+ );\r
\r
/** \r
Convert binary buffer to a Unicode String in a specified sequence. \r
\r
- This function converts bytes in the binary Buffer Buf to a Unicode String Str. \r
+ This function converts bytes in the memory block pointed by Buffer to a Unicode String Str. \r
Each byte will be represented by two Unicode characters. For example, byte 0xA1 will \r
be converted into two Unicode character L'A' and L'1'. In the output String, the Unicode Character \r
for the Most Significant Nibble will be put before the Unicode Character for the Least Significant\r
IN OUT UINTN *StringLen,\r
IN CONST UINT8 *Buffer,\r
IN UINTN BufferSizeInBytes\r
- )\r
-;\r
+ );\r
\r
\r
/**\r
IN OUT UINTN *BufferSizeInBytes,\r
IN CONST CHAR16 *String,\r
OUT UINTN *ConvertedStrLen OPTIONAL\r
- )\r
-;\r
+ );\r
\r
\r
/**\r
\r
If Digit is NULL, then ASSERT.\r
\r
+ @param Digit The output hexadecimal digit.\r
+\r
+ @param Char The input Unicode character.\r
+\r
@retval TRUE Char is in the range of Hexadecimal number. Digit is updated\r
to the byte value of the number.\r
@retval FALSE Char is not in the range of Hexadecimal number. Digit is keep\r
IsHexDigit (\r
OUT UINT8 *Digit,\r
IN CHAR16 Char\r
- )\r
-;\r
+ );\r
\r
/**\r
Convert one Null-terminated Unicode string to a Null-terminated\r
@param FirstString Pointer to a Null-terminated ASCII string.\r
@param SecondString Pointer to a Null-terminated ASCII string.\r
\r
- @retval 0 FirstString is identical to SecondString.\r
- @retval !=0 FirstString is not identical to SecondString.\r
+ @retval 0 FirstString is identical to SecondString.\r
+ @return others FirstString is not identical to SecondString.\r
\r
**/\r
INTN\r
@param FirstString Pointer to a Null-terminated ASCII string.\r
@param SecondString Pointer to a Null-terminated ASCII string.\r
\r
- @retval 0 FirstString is identical to SecondString using case insensitive\r
- comparisons.\r
- @retval !=0 FirstString is not identical to SecondString using case\r
- insensitive comparisons.\r
+ @retval 0 FirstString is identical to SecondString using case insensitive\r
+ comparisons.\r
+ @return others FirstString is not identical to SecondString using case\r
+ insensitive comparisons.\r
\r
**/\r
INTN\r
@param SecondString Pointer to a Null-terminated ASCII string.\r
@param Length Maximum number of ASCII characters for compare.\r
\r
- @retval 0 FirstString is identical to SecondString.\r
- @retval !=0 FirstString is not identical to SecondString.\r
+ @retval 0 FirstString is identical to SecondString.\r
+ @return others FirstString is not identical to SecondString.\r
\r
**/\r
INTN\r
String contains more than PcdMaximumAsciiStringLength Unicode characters\r
not including the Null-terminator, then ASSERT().\r
\r
- @param String Pointer to a Null-terminated ASCII string.\r
- @param SearchString Pointer to a Null-terminated ASCII string to search for.\r
+ @param String Pointer to a Null-terminated ASCII string.\r
+ @param SearchString Pointer to a Null-terminated ASCII string to search for.\r
\r
@retval NULL If the SearchString does not appear in String.\r
- @retval !NULL If there is a match.\r
+ @return others If there is a match.\r
\r
**/\r
CHAR8 *\r
\r
@param String Pointer to a Null-terminated ASCII string.\r
\r
- @retval UINTN\r
+ @retval Value translated from String.\r
\r
**/\r
UINTN\r
\r
@param String Pointer to a Null-terminated ASCII string.\r
\r
- @retval UINT64\r
+ @retval Value translated from String.\r
\r
**/\r
UINT64\r
\r
@param String Pointer to a Null-terminated ASCII string.\r
\r
- @retval UINTN\r
+ @retval Value translated from String.\r
\r
**/\r
UINTN\r
\r
@param String Pointer to a Null-terminated ASCII string.\r
\r
- @retval UINT64\r
+ @retval Value translated from String.\r
\r
**/\r
UINT64\r
LIST_ENTRY *\r
EFIAPI\r
InitializeListHead (\r
- IN LIST_ENTRY *ListHead\r
+ IN OUT LIST_ENTRY *ListHead\r
);\r
\r
\r
LIST_ENTRY *\r
EFIAPI\r
InsertHeadList (\r
- IN LIST_ENTRY *ListHead,\r
- IN LIST_ENTRY *Entry\r
+ IN OUT LIST_ENTRY *ListHead,\r
+ IN OUT LIST_ENTRY *Entry\r
);\r
\r
\r
LIST_ENTRY *\r
EFIAPI\r
InsertTailList (\r
- IN LIST_ENTRY *ListHead,\r
- IN LIST_ENTRY *Entry\r
+ IN OUT LIST_ENTRY *ListHead,\r
+ IN OUT LIST_ENTRY *Entry\r
);\r
\r
\r
\r
\r
/**\r
- Determines if a node in a doubly linked list is null.\r
+ Determines if a node in a doubly linked list is the head node of a the same\r
+ doubly linked list. This function is typically used to terminate a loop that\r
+ traverses all the nodes in a doubly linked list starting with the head node.\r
\r
- Returns FALSE if Node is one of the nodes in the doubly linked list specified\r
- by List. Otherwise, TRUE is returned. List must have been initialized with\r
- InitializeListHead().\r
+ Returns TRUE if Node is equal to List. Returns FALSE if Node is one of the\r
+ nodes in the doubly linked list specified by List. List must have been\r
+ initialized with InitializeListHead().\r
\r
If List is NULL, then ASSERT().\r
If Node is NULL, then ASSERT().\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
+ @return SecondEntry\r
\r
**/\r
LIST_ENTRY *\r
EFIAPI\r
SwapListEntries (\r
- IN LIST_ENTRY *FirstEntry,\r
- IN LIST_ENTRY *SecondEntry\r
+ IN OUT LIST_ENTRY *FirstEntry,\r
+ IN OUT LIST_ENTRY *SecondEntry\r
);\r
\r
\r
\r
If the Buffer is NULL, then ASSERT().\r
\r
- @param Uint16 Pointer to a 16-bit value that may be unaligned.\r
+ @param Buffer Pointer to a 16-bit value that may be unaligned.\r
\r
- @return *Uint16\r
+ @return The 16-bit value read from Buffer.\r
\r
**/\r
UINT16\r
EFIAPI\r
ReadUnaligned16 (\r
- IN CONST UINT16 *Uint16\r
+ IN CONST UINT16 *Buffer\r
);\r
\r
\r
\r
If the Buffer is NULL, then ASSERT().\r
\r
- @param Uint16 Pointer to a 16-bit value that may be unaligned.\r
+ @param Buffer Pointer to a 16-bit value that may be unaligned.\r
@param Value 16-bit value to write to Buffer.\r
\r
- @return Value\r
+ @return The 16-bit value to write to Buffer.\r
\r
**/\r
UINT16\r
EFIAPI\r
WriteUnaligned16 (\r
- OUT UINT16 *Uint16,\r
- IN UINT16 Value\r
+ OUT UINT16 *Buffer,\r
+ IN UINT16 Value\r
);\r
\r
\r
\r
@param Buffer Pointer to a 24-bit value that may be unaligned.\r
\r
- @return The value read.\r
+ @return The 24-bit value read from Buffer.\r
\r
**/\r
UINT32\r
EFIAPI\r
ReadUnaligned24 (\r
- IN CONST UINT32 *Buffer\r
+ IN CONST UINT32 *Buffer\r
);\r
\r
\r
@param Buffer Pointer to a 24-bit value that may be unaligned.\r
@param Value 24-bit value to write to Buffer.\r
\r
- @return The value written.\r
+ @return The 24-bit value to write to Buffer.\r
\r
**/\r
UINT32\r
EFIAPI\r
WriteUnaligned24 (\r
- OUT UINT32 *Buffer,\r
- IN UINT32 Value\r
+ OUT UINT32 *Buffer,\r
+ IN UINT32 Value\r
);\r
\r
\r
\r
If the Buffer is NULL, then ASSERT().\r
\r
- @param Uint32 Pointer to a 32-bit value that may be unaligned.\r
+ @param Buffer Pointer to a 32-bit value that may be unaligned.\r
\r
- @return *Uint32\r
+ @return The 32-bit value read from Buffer.\r
\r
**/\r
UINT32\r
EFIAPI\r
ReadUnaligned32 (\r
- IN CONST UINT32 *Uint32\r
+ IN CONST UINT32 *Buffer\r
);\r
\r
\r
\r
If the Buffer is NULL, then ASSERT().\r
\r
- @param Uint32 Pointer to a 32-bit value that may be unaligned.\r
+ @param Buffer Pointer to a 32-bit value that may be unaligned.\r
@param Value 32-bit value to write to Buffer.\r
\r
- @return Value\r
+ @return The 32-bit value to write to Buffer.\r
\r
**/\r
UINT32\r
EFIAPI\r
WriteUnaligned32 (\r
- OUT UINT32 *Uint32,\r
- IN UINT32 Value\r
+ OUT UINT32 *Buffer,\r
+ IN UINT32 Value\r
);\r
\r
\r
\r
If the Buffer is NULL, then ASSERT().\r
\r
- @param Uint64 Pointer to a 64-bit value that may be unaligned.\r
+ @param Buffer Pointer to a 64-bit value that may be unaligned.\r
\r
- @return *Uint64\r
+ @return The 64-bit value read from Buffer.\r
\r
**/\r
UINT64\r
EFIAPI\r
ReadUnaligned64 (\r
- IN CONST UINT64 *Uint64\r
+ IN CONST UINT64 *Buffer\r
);\r
\r
\r
\r
If the Buffer is NULL, then ASSERT().\r
\r
- @param Uint64 Pointer to a 64-bit value that may be unaligned.\r
+ @param Buffer Pointer to a 64-bit value that may be unaligned.\r
@param Value 64-bit value to write to Buffer.\r
\r
- @return Value\r
+ @return The 64-bit value to write to Buffer.\r
\r
**/\r
UINT64\r
EFIAPI\r
WriteUnaligned64 (\r
- OUT UINT64 *Uint64,\r
- IN UINT64 Value\r
+ OUT UINT64 *Buffer,\r
+ IN UINT64 Value\r
);\r
\r
\r
@param SpinLock A pointer to the spin lock to initialize to the released\r
state.\r
\r
- @return SpinLock\r
+ @return SpinLock in release state.\r
\r
**/\r
SPIN_LOCK *\r
EFIAPI\r
InitializeSpinLock (\r
- IN SPIN_LOCK *SpinLock\r
+ OUT SPIN_LOCK *SpinLock\r
);\r
\r
\r
\r
@param SpinLock A pointer to the spin lock to place in the acquired state.\r
\r
- @return SpinLock\r
+ @return SpinLock accquired lock.\r
\r
**/\r
SPIN_LOCK *\r
EFIAPI\r
AcquireSpinLock (\r
- IN SPIN_LOCK *SpinLock\r
+ IN OUT SPIN_LOCK *SpinLock\r
);\r
\r
\r
BOOLEAN\r
EFIAPI\r
AcquireSpinLockOrFail (\r
- IN SPIN_LOCK *SpinLock\r
+ IN OUT SPIN_LOCK *SpinLock\r
);\r
\r
\r
\r
@param SpinLock A pointer to the spin lock to release.\r
\r
- @return SpinLock\r
+ @return SpinLock released lock.\r
\r
**/\r
SPIN_LOCK *\r
EFIAPI\r
ReleaseSpinLock (\r
- IN SPIN_LOCK *SpinLock\r
+ IN OUT SPIN_LOCK *SpinLock\r
);\r
\r
\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
VOID *\r
EFIAPI\r
If Buffer is NULL, then ASSERT().\r
If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r
\r
- @param Buffer Pointer to the buffer to carry out the sum operation.\r
- @param Length The size, in bytes, of Buffer .\r
+ @param Buffer Pointer to the buffer to carry out the sum operation.\r
+ @param Length The size, in bytes, of Buffer .\r
\r
@return Sum The sum of Buffer with carry bits dropped during additions.\r
\r
If Buffer is NULL, then ASSERT().\r
If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r
\r
-\r
- @param Buffer Pointer to the buffer to carry out the checksum operation.\r
- @param Length The size, in bytes, of Buffer.\r
+ @param Buffer Pointer to the buffer to carry out the checksum operation.\r
+ @param Length The size, in bytes, of Buffer.\r
\r
@return Checksum The 2's complement checksum of Buffer.\r
\r
If Length is not aligned on a 16-bit boundary, then ASSERT().\r
If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r
\r
- @param Buffer Pointer to the buffer to carry out the sum operation.\r
- @param Length The size, in bytes, of Buffer.\r
+ @param Buffer Pointer to the buffer to carry out the sum operation.\r
+ @param Length The size, in bytes, of Buffer.\r
\r
@return Sum The sum of Buffer with carry bits dropped during additions.\r
\r
If Length is not aligned on a 16-bit boundary, then ASSERT().\r
If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r
\r
- @param Buffer Pointer to the buffer to carry out the checksum operation.\r
- @param Length The size, in bytes, of Buffer.\r
+ @param Buffer Pointer to the buffer to carry out the checksum operation.\r
+ @param Length The size, in bytes, of Buffer.\r
\r
@return Checksum The 2's complement checksum of Buffer.\r
\r
If Length is not aligned on a 32-bit boundary, then ASSERT().\r
If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r
\r
- @param Buffer Pointer to the buffer to carry out the sum operation.\r
- @param Length The size, in bytes, of Buffer.\r
+ @param Buffer Pointer to the buffer to carry out the sum operation.\r
+ @param Length The size, in bytes, of Buffer.\r
\r
@return Sum The sum of Buffer with carry bits dropped during additions.\r
\r
If Length is not aligned on a 32-bit boundary, then ASSERT().\r
If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r
\r
- @param Buffer Pointer to the buffer to carry out the checksum operation.\r
- @param Length The size, in bytes, of Buffer.\r
+ @param Buffer Pointer to the buffer to carry out the checksum operation.\r
+ @param Length The size, in bytes, of Buffer.\r
\r
@return Checksum The 2's complement checksum of Buffer.\r
\r
If Length is not aligned on a 64-bit boundary, then ASSERT().\r
If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r
\r
- @param Buffer Pointer to the buffer to carry out the sum operation.\r
- @param Length The size, in bytes, of Buffer.\r
+ @param Buffer Pointer to the buffer to carry out the sum operation.\r
+ @param Length The size, in bytes, of Buffer.\r
\r
@return Sum The sum of Buffer with carry bits dropped during additions.\r
\r
If Length is not aligned on a 64-bit boundary, then ASSERT().\r
If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r
\r
- @param Buffer Pointer to the buffer to carry out the checksum operation.\r
- @param Length The size, in bytes, of Buffer.\r
+ @param Buffer Pointer to the buffer to carry out the checksum operation.\r
+ @param Length The size, in bytes, of Buffer.\r
\r
@return Checksum The 2's complement checksum of Buffer.\r
\r
);\r
\r
\r
-//\r
-// Base Library CPU Functions\r
-//\r
+///\r
+/// Base Library CPU Functions\r
+///\r
typedef\r
VOID\r
-(EFIAPI *SWITCH_STACK_ENTRY_POINT) (\r
+(EFIAPI *SWITCH_STACK_ENTRY_POINT)(\r
IN VOID *Context1, OPTIONAL\r
IN VOID *Context2 OPTIONAL\r
);\r
/**\r
Enables CPU interrupts.\r
\r
- Enables CPU interrupts.\r
-\r
**/\r
VOID\r
EFIAPI\r
/**\r
Disables CPU interrupts.\r
\r
- Disables CPU interrupts.\r
-\r
**/\r
VOID\r
EFIAPI\r
Disables CPU interrupts and returns the interrupt state prior to the disable\r
operation.\r
\r
- Disables CPU interrupts and returns the interrupt state prior to the disable\r
- operation.\r
-\r
@retval TRUE CPU interrupts were enabled on entry to this call.\r
@retval FALSE CPU interrupts were disabled on entry to this call.\r
\r
Enables CPU interrupts for the smallest window required to capture any\r
pending interrupts.\r
\r
- Enables CPU interrupts for the smallest window required to capture any\r
- pending interrupts.\r
-\r
**/\r
VOID\r
EFIAPI\r
/**\r
Retrieves the current CPU interrupt state.\r
\r
- Retrieves the current CPU interrupt state. Returns TRUE is interrupts are\r
- currently enabled. Otherwise returns FALSE.\r
+ Returns TRUE is interrupts are currently enabled. Otherwise\r
+ returns FALSE.\r
\r
@retval TRUE CPU interrupts are enabled.\r
@retval FALSE CPU interrupts are disabled.\r
function.\r
@param NewStack A pointer to the new stack to use for the EntryPoint\r
function.\r
+ @param ... Extended parameters.\r
+\r
\r
**/\r
VOID\r
IN VOID *NewBsp\r
);\r
\r
-\r
-//\r
-// Bugbug: This call should be removed after\r
-// the PalCall Instance issue has been fixed.\r
-//\r
/**\r
+ @todo This call should be removed after the PalCall\r
+ Instance issue has been fixed.\r
+\r
Performs a PAL call using static calling convention.\r
\r
An internal function to perform a PAL call using static calling convention.\r
@param PalEntryPoint The entry point address of PAL. The address in ar.kr5\r
would be used if this parameter were NULL on input.\r
@param Arg1 The first argument of a PAL call.\r
- @param Arg1 The second argument of a PAL call.\r
- @param Arg1 The third argument of a PAL call.\r
- @param Arg1 The fourth argument of a PAL call.\r
+ @param Arg2 The second argument of a PAL call.\r
+ @param Arg3 The third argument of a PAL call.\r
+ @param Arg4 The fourth argument of a PAL call.\r
\r
@return The values returned in r8, r9, r10 and r11.\r
\r
\r
\r
#elif defined (MDE_CPU_IA32) || defined (MDE_CPU_X64)\r
-//\r
-// IA32 and X64 Specific Functions\r
-//\r
-//\r
-// Byte packed structure for 16-bit Real Mode EFLAGS\r
-//\r
+///\r
+/// IA32 and X64 Specific Functions\r
+/// Byte packed structure for 16-bit Real Mode EFLAGS\r
+///\r
typedef union {\r
struct {\r
- UINT32 CF:1; // Carry Flag\r
- UINT32 Reserved_0:1; // Reserved\r
- UINT32 PF:1; // Parity Flag\r
- UINT32 Reserved_1:1; // Reserved\r
- UINT32 AF:1; // Auxiliary Carry Flag\r
- UINT32 Reserved_2:1; // Reserved\r
- UINT32 ZF:1; // Zero Flag\r
- UINT32 SF:1; // Sign Flag\r
- UINT32 TF:1; // Trap Flag\r
- UINT32 IF:1; // Interrupt Enable Flag\r
- UINT32 DF:1; // Direction Flag\r
- UINT32 OF:1; // Overflow Flag\r
- UINT32 IOPL:2; // I/O Privilege Level\r
- UINT32 NT:1; // Nested Task\r
- UINT32 Reserved_3:1; // Reserved\r
+ UINT32 CF:1; /// Carry Flag\r
+ UINT32 Reserved_0:1; /// Reserved\r
+ UINT32 PF:1; /// Parity Flag\r
+ UINT32 Reserved_1:1; /// Reserved\r
+ UINT32 AF:1; /// Auxiliary Carry Flag\r
+ UINT32 Reserved_2:1; /// Reserved\r
+ UINT32 ZF:1; /// Zero Flag\r
+ UINT32 SF:1; /// Sign Flag\r
+ UINT32 TF:1; /// Trap Flag\r
+ UINT32 IF:1; /// Interrupt Enable Flag\r
+ UINT32 DF:1; /// Direction Flag\r
+ UINT32 OF:1; /// Overflow Flag\r
+ UINT32 IOPL:2; /// I/O Privilege Level\r
+ UINT32 NT:1; /// Nested Task\r
+ UINT32 Reserved_3:1; /// Reserved\r
} Bits;\r
UINT16 Uint16;\r
} IA32_FLAGS16;\r
\r
-//\r
-// Byte packed structure for EFLAGS/RFLAGS\r
-// 32-bits on IA-32\r
-// 64-bits on X64. The upper 32-bits on X64 are reserved\r
-//\r
+///\r
+/// Byte packed structure for EFLAGS/RFLAGS\r
+/// 32-bits on IA-32\r
+/// 64-bits on X64. The upper 32-bits on X64 are reserved\r
+///\r
typedef union {\r
struct {\r
- UINT32 CF:1; // Carry Flag\r
- UINT32 Reserved_0:1; // Reserved\r
- UINT32 PF:1; // Parity Flag\r
- UINT32 Reserved_1:1; // Reserved\r
- UINT32 AF:1; // Auxiliary Carry Flag\r
- UINT32 Reserved_2:1; // Reserved\r
- UINT32 ZF:1; // Zero Flag\r
- UINT32 SF:1; // Sign Flag\r
- UINT32 TF:1; // Trap Flag\r
- UINT32 IF:1; // Interrupt Enable Flag\r
- UINT32 DF:1; // Direction Flag\r
- UINT32 OF:1; // Overflow Flag\r
- UINT32 IOPL:2; // I/O Privilege Level\r
- UINT32 NT:1; // Nested Task\r
- UINT32 Reserved_3:1; // Reserved\r
- UINT32 RF:1; // Resume Flag\r
- UINT32 VM:1; // Virtual 8086 Mode\r
- UINT32 AC:1; // Alignment Check\r
- UINT32 VIF:1; // Virtual Interrupt Flag\r
- UINT32 VIP:1; // Virtual Interrupt Pending\r
- UINT32 ID:1; // ID Flag\r
- UINT32 Reserved_4:10; // Reserved\r
+ UINT32 CF:1; /// Carry Flag\r
+ UINT32 Reserved_0:1; /// Reserved\r
+ UINT32 PF:1; /// Parity Flag\r
+ UINT32 Reserved_1:1; /// Reserved\r
+ UINT32 AF:1; /// Auxiliary Carry Flag\r
+ UINT32 Reserved_2:1; /// Reserved\r
+ UINT32 ZF:1; /// Zero Flag\r
+ UINT32 SF:1; /// Sign Flag\r
+ UINT32 TF:1; /// Trap Flag\r
+ UINT32 IF:1; /// Interrupt Enable Flag\r
+ UINT32 DF:1; /// Direction Flag\r
+ UINT32 OF:1; /// Overflow Flag\r
+ UINT32 IOPL:2; /// I/O Privilege Level\r
+ UINT32 NT:1; /// Nested Task\r
+ UINT32 Reserved_3:1; /// Reserved\r
+ UINT32 RF:1; /// Resume Flag\r
+ UINT32 VM:1; /// Virtual 8086 Mode\r
+ UINT32 AC:1; /// Alignment Check\r
+ UINT32 VIF:1; /// Virtual Interrupt Flag\r
+ UINT32 VIP:1; /// Virtual Interrupt Pending\r
+ UINT32 ID:1; /// ID Flag\r
+ UINT32 Reserved_4:10; /// Reserved\r
} Bits;\r
UINTN UintN;\r
} IA32_EFLAGS32;\r
\r
-//\r
-// Byte packed structure for Control Register 0 (CR0)\r
-// 32-bits on IA-32\r
-// 64-bits on X64. The upper 32-bits on X64 are reserved\r
-//\r
+///\r
+/// Byte packed structure for Control Register 0 (CR0)\r
+/// 32-bits on IA-32\r
+/// 64-bits on X64. The upper 32-bits on X64 are reserved\r
+///\r
typedef union {\r
struct {\r
- UINT32 PE:1; // Protection Enable\r
- UINT32 MP:1; // Monitor Coprocessor\r
- UINT32 EM:1; // Emulation\r
- UINT32 TS:1; // Task Switched\r
- UINT32 ET:1; // Extension Type\r
- UINT32 NE:1; // Numeric Error\r
- UINT32 Reserved_0:10; // Reserved\r
- UINT32 WP:1; // Write Protect\r
- UINT32 Reserved_1:1; // Reserved\r
- UINT32 AM:1; // Alignment Mask\r
- UINT32 Reserved_2:10; // Reserved\r
- UINT32 NW:1; // Mot Write-through\r
- UINT32 CD:1; // Cache Disable\r
- UINT32 PG:1; // Paging\r
+ UINT32 PE:1; /// Protection Enable\r
+ UINT32 MP:1; /// Monitor Coprocessor\r
+ UINT32 EM:1; /// Emulation\r
+ UINT32 TS:1; /// Task Switched\r
+ UINT32 ET:1; /// Extension Type\r
+ UINT32 NE:1; /// Numeric Error\r
+ UINT32 Reserved_0:10; /// Reserved\r
+ UINT32 WP:1; /// Write Protect\r
+ UINT32 Reserved_1:1; /// Reserved\r
+ UINT32 AM:1; /// Alignment Mask\r
+ UINT32 Reserved_2:10; /// Reserved\r
+ UINT32 NW:1; /// Mot Write-through\r
+ UINT32 CD:1; /// Cache Disable\r
+ UINT32 PG:1; /// Paging\r
} Bits;\r
UINTN UintN;\r
} IA32_CR0;\r
\r
-//\r
-// Byte packed structure for Control Register 4 (CR4)\r
-// 32-bits on IA-32\r
-// 64-bits on X64. The upper 32-bits on X64 are reserved\r
-//\r
+///\r
+/// Byte packed structure for Control Register 4 (CR4)\r
+/// 32-bits on IA-32\r
+/// 64-bits on X64. The upper 32-bits on X64 are reserved\r
+///\r
typedef union {\r
struct {\r
- UINT32 VME:1; // Virtual-8086 Mode Extensions\r
- UINT32 PVI:1; // Protected-Mode Virtual Interrupts\r
- UINT32 TSD:1; // Time Stamp Disable\r
- UINT32 DE:1; // Debugging Extensions\r
- UINT32 PSE:1; // Page Size Extensions\r
- UINT32 PAE:1; // Physical Address Extension\r
- UINT32 MCE:1; // Machine Check Enable\r
- UINT32 PGE:1; // Page Global Enable\r
- UINT32 PCE:1; // Performance Monitoring Counter\r
- // Enable\r
- UINT32 OSFXSR:1; // Operating System Support for\r
- // FXSAVE and FXRSTOR instructions\r
- UINT32 OSXMMEXCPT:1; // Operating System Support for\r
- // Unmasked SIMD Floating Point\r
- // Exceptions\r
- UINT32 Reserved_0:2; // Reserved\r
- UINT32 VMXE:1; // VMX Enable\r
- UINT32 Reserved_1:18; // Reseved\r
+ UINT32 VME:1; /// Virtual-8086 Mode Extensions\r
+ UINT32 PVI:1; /// Protected-Mode Virtual Interrupts\r
+ UINT32 TSD:1; /// Time Stamp Disable\r
+ UINT32 DE:1; /// Debugging Extensions\r
+ UINT32 PSE:1; /// Page Size Extensions\r
+ UINT32 PAE:1; /// Physical Address Extension\r
+ UINT32 MCE:1; /// Machine Check Enable\r
+ UINT32 PGE:1; /// Page Global Enable\r
+ UINT32 PCE:1; /// Performance Monitoring Counter\r
+ /// Enable\r
+ UINT32 OSFXSR:1; /// Operating System Support for\r
+ /// FXSAVE and FXRSTOR instructions\r
+ UINT32 OSXMMEXCPT:1; /// Operating System Support for\r
+ /// Unmasked SIMD Floating Point\r
+ /// Exceptions\r
+ UINT32 Reserved_0:2; /// Reserved\r
+ UINT32 VMXE:1; /// VMX Enable\r
+ UINT32 Reserved_1:18; /// Reseved\r
} Bits;\r
UINTN UintN;\r
} IA32_CR4;\r
\r
-//\r
-// Byte packed structure for an IDTR, GDTR, LDTR descriptor\r
-/// @bug How to make this structure byte-packed in a compiler independent way?\r
-//\r
+///\r
+/// Byte packed structure for an IDTR, GDTR, LDTR descriptor\r
+/// @todo How to make this structure byte-packed in a compiler independent way?\r
+///\r
#pragma pack (1)\r
typedef struct {\r
UINT16 Limit;\r
#define IA32_IDT_GATE_TYPE_INTERRUPT_32 0x8E\r
#define IA32_IDT_GATE_TYPE_TRAP_32 0x8F\r
\r
-//\r
-// Byte packed structure for an Interrupt Gate Descriptor\r
-//\r
+///\r
+/// Byte packed structure for an Interrupt Gate Descriptor\r
+///\r
+#if defined (MDE_CPU_IA32)\r
+\r
typedef union {\r
struct {\r
UINT32 OffsetLow:16; // Offset bits 15..0\r
UINT64 Uint64;\r
} IA32_IDT_GATE_DESCRIPTOR;\r
\r
-//\r
-// Byte packed structure for an FP/SSE/SSE2 context\r
-//\r
+#endif\r
+\r
+#if defined (MDE_CPU_X64)\r
+\r
+typedef union {\r
+ struct {\r
+ UINT32 OffsetLow:16; // Offset bits 15..0\r
+ UINT32 Selector:16; // Selector\r
+ UINT32 Reserved_0:8; // Reserved\r
+ UINT32 GateType:8; // Gate Type. See #defines above\r
+ UINT32 OffsetHigh:16; // Offset bits 31..16\r
+ UINT32 OffsetUpper:32; // Offset bits 63..32\r
+ UINT32 Reserved_1:32; // Reserved\r
+ } Bits;\r
+ UINT64 Uint64;\r
+ UINT64 Uint64_1;\r
+} IA32_IDT_GATE_DESCRIPTOR;\r
+\r
+#endif\r
+\r
+///\r
+/// Byte packed structure for an FP/SSE/SSE2 context\r
+///\r
typedef struct {\r
UINT8 Buffer[512];\r
} IA32_FX_BUFFER;\r
\r
-//\r
-// Structures for the 16-bit real mode thunks\r
-//\r
+///\r
+/// Structures for the 16-bit real mode thunks\r
+///\r
typedef struct {\r
UINT32 Reserved1;\r
UINT32 Reserved2;\r
IA32_BYTE_REGS H;\r
} IA32_REGISTER_SET;\r
\r
-//\r
-// Byte packed structure for an 16-bit real mode thunks\r
-//\r
+///\r
+/// Byte packed structure for an 16-bit real mode thunks\r
+///\r
typedef struct {\r
IA32_REGISTER_SET *RealModeState;\r
VOID *RealModeBuffer;\r
If EntryPoint is 0, then ASSERT().\r
If NewStack is 0, then ASSERT().\r
\r
- @param Cs The 16-bit selector to load in the CS before EntryPoint\r
+ @param CodeSelector The 16-bit selector to load in the CS before EntryPoint\r
is called. The descriptor in the GDT that this selector\r
references must be setup for long mode.\r
@param EntryPoint The 64-bit virtual address of the function to call with\r
If EntryPoint is 0, then ASSERT().\r
If NewStack is 0, then ASSERT().\r
\r
- @param Cs The 16-bit selector to load in the CS before EntryPoint\r
+ @param CodeSelector The 16-bit selector to load in the CS before EntryPoint\r
is called. The descriptor in the GDT that this selector\r
references must be setup for 32-bit protected mode.\r
@param EntryPoint The 64-bit virtual address of the function to call with\r
IN OUT THUNK_CONTEXT *ThunkContext\r
);\r
\r
-#else\r
-\r
#endif\r
-\r
#endif\r
\r
\r