10d1ba665SWarner Losh /** @file 20d1ba665SWarner Losh Provides string functions, linked list functions, math functions, synchronization 30d1ba665SWarner Losh functions, file path functions, and CPU architecture-specific functions. 40d1ba665SWarner Losh 5*3245fa21SMitchell Horne Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.<BR> 60d1ba665SWarner Losh Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR> 7*3245fa21SMitchell Horne Copyright (c) Microsoft Corporation.<BR> 8*3245fa21SMitchell Horne Portions Copyright (c) 2020, Hewlett Packard Enterprise Development LP. All rights reserved.<BR> 90d1ba665SWarner Losh 10*3245fa21SMitchell Horne SPDX-License-Identifier: BSD-2-Clause-Patent 110d1ba665SWarner Losh 120d1ba665SWarner Losh **/ 130d1ba665SWarner Losh 140d1ba665SWarner Losh #ifndef __BASE_LIB__ 150d1ba665SWarner Losh #define __BASE_LIB__ 160d1ba665SWarner Losh 170d1ba665SWarner Losh // 180d1ba665SWarner Losh // Definitions for architecture-specific types 190d1ba665SWarner Losh // 200d1ba665SWarner Losh #if defined (MDE_CPU_IA32) 210d1ba665SWarner Losh /// 220d1ba665SWarner Losh /// The IA-32 architecture context buffer used by SetJump() and LongJump(). 230d1ba665SWarner Losh /// 240d1ba665SWarner Losh typedef struct { 250d1ba665SWarner Losh UINT32 Ebx; 260d1ba665SWarner Losh UINT32 Esi; 270d1ba665SWarner Losh UINT32 Edi; 280d1ba665SWarner Losh UINT32 Ebp; 290d1ba665SWarner Losh UINT32 Esp; 300d1ba665SWarner Losh UINT32 Eip; 31*3245fa21SMitchell Horne UINT32 Ssp; 320d1ba665SWarner Losh } BASE_LIBRARY_JUMP_BUFFER; 330d1ba665SWarner Losh 340d1ba665SWarner Losh #define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 4 350d1ba665SWarner Losh 360d1ba665SWarner Losh #endif // defined (MDE_CPU_IA32) 370d1ba665SWarner Losh 380d1ba665SWarner Losh #if defined (MDE_CPU_X64) 390d1ba665SWarner Losh /// 400d1ba665SWarner Losh /// The x64 architecture context buffer used by SetJump() and LongJump(). 410d1ba665SWarner Losh /// 420d1ba665SWarner Losh typedef struct { 430d1ba665SWarner Losh UINT64 Rbx; 440d1ba665SWarner Losh UINT64 Rsp; 450d1ba665SWarner Losh UINT64 Rbp; 460d1ba665SWarner Losh UINT64 Rdi; 470d1ba665SWarner Losh UINT64 Rsi; 480d1ba665SWarner Losh UINT64 R12; 490d1ba665SWarner Losh UINT64 R13; 500d1ba665SWarner Losh UINT64 R14; 510d1ba665SWarner Losh UINT64 R15; 520d1ba665SWarner Losh UINT64 Rip; 530d1ba665SWarner Losh UINT64 MxCsr; 540d1ba665SWarner Losh UINT8 XmmBuffer[160]; ///< XMM6-XMM15. 55*3245fa21SMitchell Horne UINT64 Ssp; 560d1ba665SWarner Losh } BASE_LIBRARY_JUMP_BUFFER; 570d1ba665SWarner Losh 580d1ba665SWarner Losh #define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 8 590d1ba665SWarner Losh 600d1ba665SWarner Losh #endif // defined (MDE_CPU_X64) 610d1ba665SWarner Losh 620d1ba665SWarner Losh #if defined (MDE_CPU_EBC) 630d1ba665SWarner Losh /// 640d1ba665SWarner Losh /// The EBC context buffer used by SetJump() and LongJump(). 650d1ba665SWarner Losh /// 660d1ba665SWarner Losh typedef struct { 670d1ba665SWarner Losh UINT64 R0; 680d1ba665SWarner Losh UINT64 R1; 690d1ba665SWarner Losh UINT64 R2; 700d1ba665SWarner Losh UINT64 R3; 710d1ba665SWarner Losh UINT64 IP; 720d1ba665SWarner Losh } BASE_LIBRARY_JUMP_BUFFER; 730d1ba665SWarner Losh 740d1ba665SWarner Losh #define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 8 750d1ba665SWarner Losh 760d1ba665SWarner Losh #endif // defined (MDE_CPU_EBC) 770d1ba665SWarner Losh 780d1ba665SWarner Losh #if defined (MDE_CPU_ARM) 790d1ba665SWarner Losh 800d1ba665SWarner Losh typedef struct { 810d1ba665SWarner Losh UINT32 R3; ///< A copy of R13. 820d1ba665SWarner Losh UINT32 R4; 830d1ba665SWarner Losh UINT32 R5; 840d1ba665SWarner Losh UINT32 R6; 850d1ba665SWarner Losh UINT32 R7; 860d1ba665SWarner Losh UINT32 R8; 870d1ba665SWarner Losh UINT32 R9; 880d1ba665SWarner Losh UINT32 R10; 890d1ba665SWarner Losh UINT32 R11; 900d1ba665SWarner Losh UINT32 R12; 910d1ba665SWarner Losh UINT32 R14; 920d1ba665SWarner Losh } BASE_LIBRARY_JUMP_BUFFER; 930d1ba665SWarner Losh 940d1ba665SWarner Losh #define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 4 950d1ba665SWarner Losh 960d1ba665SWarner Losh #endif // defined (MDE_CPU_ARM) 970d1ba665SWarner Losh 980d1ba665SWarner Losh #if defined (MDE_CPU_AARCH64) 990d1ba665SWarner Losh typedef struct { 1000d1ba665SWarner Losh // GP regs 1010d1ba665SWarner Losh UINT64 X19; 1020d1ba665SWarner Losh UINT64 X20; 1030d1ba665SWarner Losh UINT64 X21; 1040d1ba665SWarner Losh UINT64 X22; 1050d1ba665SWarner Losh UINT64 X23; 1060d1ba665SWarner Losh UINT64 X24; 1070d1ba665SWarner Losh UINT64 X25; 1080d1ba665SWarner Losh UINT64 X26; 1090d1ba665SWarner Losh UINT64 X27; 1100d1ba665SWarner Losh UINT64 X28; 1110d1ba665SWarner Losh UINT64 FP; 1120d1ba665SWarner Losh UINT64 LR; 1130d1ba665SWarner Losh UINT64 IP0; 1140d1ba665SWarner Losh 1150d1ba665SWarner Losh // FP regs 1160d1ba665SWarner Losh UINT64 D8; 1170d1ba665SWarner Losh UINT64 D9; 1180d1ba665SWarner Losh UINT64 D10; 1190d1ba665SWarner Losh UINT64 D11; 1200d1ba665SWarner Losh UINT64 D12; 1210d1ba665SWarner Losh UINT64 D13; 1220d1ba665SWarner Losh UINT64 D14; 1230d1ba665SWarner Losh UINT64 D15; 1240d1ba665SWarner Losh } BASE_LIBRARY_JUMP_BUFFER; 1250d1ba665SWarner Losh 1260d1ba665SWarner Losh #define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 8 1270d1ba665SWarner Losh 1280d1ba665SWarner Losh #endif // defined (MDE_CPU_AARCH64) 1290d1ba665SWarner Losh 130*3245fa21SMitchell Horne #if defined (MDE_CPU_RISCV64) 131*3245fa21SMitchell Horne /// 132*3245fa21SMitchell Horne /// The RISC-V architecture context buffer used by SetJump() and LongJump(). 133*3245fa21SMitchell Horne /// 134*3245fa21SMitchell Horne typedef struct { 135*3245fa21SMitchell Horne UINT64 RA; 136*3245fa21SMitchell Horne UINT64 S0; 137*3245fa21SMitchell Horne UINT64 S1; 138*3245fa21SMitchell Horne UINT64 S2; 139*3245fa21SMitchell Horne UINT64 S3; 140*3245fa21SMitchell Horne UINT64 S4; 141*3245fa21SMitchell Horne UINT64 S5; 142*3245fa21SMitchell Horne UINT64 S6; 143*3245fa21SMitchell Horne UINT64 S7; 144*3245fa21SMitchell Horne UINT64 S8; 145*3245fa21SMitchell Horne UINT64 S9; 146*3245fa21SMitchell Horne UINT64 S10; 147*3245fa21SMitchell Horne UINT64 S11; 148*3245fa21SMitchell Horne UINT64 SP; 149*3245fa21SMitchell Horne } BASE_LIBRARY_JUMP_BUFFER; 150*3245fa21SMitchell Horne 151*3245fa21SMitchell Horne #define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 8 152*3245fa21SMitchell Horne 153*3245fa21SMitchell Horne #endif // defined (MDE_CPU_RISCV64) 1540d1ba665SWarner Losh 1550d1ba665SWarner Losh // 1560d1ba665SWarner Losh // String Services 1570d1ba665SWarner Losh // 1580d1ba665SWarner Losh 1590d1ba665SWarner Losh 1600d1ba665SWarner Losh /** 1610d1ba665SWarner Losh Returns the length of a Null-terminated Unicode string. 1620d1ba665SWarner Losh 1630d1ba665SWarner Losh This function is similar as strlen_s defined in C11. 1640d1ba665SWarner Losh 1650d1ba665SWarner Losh If String is not aligned on a 16-bit boundary, then ASSERT(). 1660d1ba665SWarner Losh 1670d1ba665SWarner Losh @param String A pointer to a Null-terminated Unicode string. 1680d1ba665SWarner Losh @param MaxSize The maximum number of Destination Unicode 1690d1ba665SWarner Losh char, including terminating null char. 1700d1ba665SWarner Losh 1710d1ba665SWarner Losh @retval 0 If String is NULL. 1720d1ba665SWarner Losh @retval MaxSize If there is no null character in the first MaxSize characters of String. 1730d1ba665SWarner Losh @return The number of characters that percede the terminating null character. 1740d1ba665SWarner Losh 1750d1ba665SWarner Losh **/ 1760d1ba665SWarner Losh UINTN 1770d1ba665SWarner Losh EFIAPI 1780d1ba665SWarner Losh StrnLenS ( 1790d1ba665SWarner Losh IN CONST CHAR16 *String, 1800d1ba665SWarner Losh IN UINTN MaxSize 1810d1ba665SWarner Losh ); 1820d1ba665SWarner Losh 1830d1ba665SWarner Losh /** 1840d1ba665SWarner Losh Returns the size of a Null-terminated Unicode string in bytes, including the 1850d1ba665SWarner Losh Null terminator. 1860d1ba665SWarner Losh 1870d1ba665SWarner Losh This function returns the size of the Null-terminated Unicode string 1880d1ba665SWarner Losh specified by String in bytes, including the Null terminator. 1890d1ba665SWarner Losh 1900d1ba665SWarner Losh If String is not aligned on a 16-bit boundary, then ASSERT(). 1910d1ba665SWarner Losh 1920d1ba665SWarner Losh @param String A pointer to a Null-terminated Unicode string. 1930d1ba665SWarner Losh @param MaxSize The maximum number of Destination Unicode 1940d1ba665SWarner Losh char, including the Null terminator. 1950d1ba665SWarner Losh 1960d1ba665SWarner Losh @retval 0 If String is NULL. 1970d1ba665SWarner Losh @retval (sizeof (CHAR16) * (MaxSize + 1)) 1980d1ba665SWarner Losh If there is no Null terminator in the first MaxSize characters of 1990d1ba665SWarner Losh String. 2000d1ba665SWarner Losh @return The size of the Null-terminated Unicode string in bytes, including 2010d1ba665SWarner Losh the Null terminator. 2020d1ba665SWarner Losh 2030d1ba665SWarner Losh **/ 2040d1ba665SWarner Losh UINTN 2050d1ba665SWarner Losh EFIAPI 2060d1ba665SWarner Losh StrnSizeS ( 2070d1ba665SWarner Losh IN CONST CHAR16 *String, 2080d1ba665SWarner Losh IN UINTN MaxSize 2090d1ba665SWarner Losh ); 2100d1ba665SWarner Losh 2110d1ba665SWarner Losh /** 2120d1ba665SWarner Losh Copies the string pointed to by Source (including the terminating null char) 2130d1ba665SWarner Losh to the array pointed to by Destination. 2140d1ba665SWarner Losh 2150d1ba665SWarner Losh This function is similar as strcpy_s defined in C11. 2160d1ba665SWarner Losh 2170d1ba665SWarner Losh If Destination is not aligned on a 16-bit boundary, then ASSERT(). 2180d1ba665SWarner Losh If Source is not aligned on a 16-bit boundary, then ASSERT(). 2190d1ba665SWarner Losh 2200d1ba665SWarner Losh If an error is returned, then the Destination is unmodified. 2210d1ba665SWarner Losh 2220d1ba665SWarner Losh @param Destination A pointer to a Null-terminated Unicode string. 2230d1ba665SWarner Losh @param DestMax The maximum number of Destination Unicode 2240d1ba665SWarner Losh char, including terminating null char. 2250d1ba665SWarner Losh @param Source A pointer to a Null-terminated Unicode string. 2260d1ba665SWarner Losh 2270d1ba665SWarner Losh @retval RETURN_SUCCESS String is copied. 2280d1ba665SWarner Losh @retval RETURN_BUFFER_TOO_SMALL If DestMax is NOT greater than StrLen(Source). 2290d1ba665SWarner Losh @retval RETURN_INVALID_PARAMETER If Destination is NULL. 2300d1ba665SWarner Losh If Source is NULL. 2310d1ba665SWarner Losh If PcdMaximumUnicodeStringLength is not zero, 2320d1ba665SWarner Losh and DestMax is greater than 2330d1ba665SWarner Losh PcdMaximumUnicodeStringLength. 2340d1ba665SWarner Losh If DestMax is 0. 2350d1ba665SWarner Losh @retval RETURN_ACCESS_DENIED If Source and Destination overlap. 2360d1ba665SWarner Losh **/ 2370d1ba665SWarner Losh RETURN_STATUS 2380d1ba665SWarner Losh EFIAPI 2390d1ba665SWarner Losh StrCpyS ( 2400d1ba665SWarner Losh OUT CHAR16 *Destination, 2410d1ba665SWarner Losh IN UINTN DestMax, 2420d1ba665SWarner Losh IN CONST CHAR16 *Source 2430d1ba665SWarner Losh ); 2440d1ba665SWarner Losh 2450d1ba665SWarner Losh /** 2460d1ba665SWarner Losh Copies not more than Length successive char from the string pointed to by 2470d1ba665SWarner Losh Source to the array pointed to by Destination. If no null char is copied from 2480d1ba665SWarner Losh Source, then Destination[Length] is always set to null. 2490d1ba665SWarner Losh 2500d1ba665SWarner Losh This function is similar as strncpy_s defined in C11. 2510d1ba665SWarner Losh 2520d1ba665SWarner Losh If Length > 0 and Destination is not aligned on a 16-bit boundary, then ASSERT(). 2530d1ba665SWarner Losh If Length > 0 and Source is not aligned on a 16-bit boundary, then ASSERT(). 2540d1ba665SWarner Losh 2550d1ba665SWarner Losh If an error is returned, then the Destination is unmodified. 2560d1ba665SWarner Losh 2570d1ba665SWarner Losh @param Destination A pointer to a Null-terminated Unicode string. 2580d1ba665SWarner Losh @param DestMax The maximum number of Destination Unicode 2590d1ba665SWarner Losh char, including terminating null char. 2600d1ba665SWarner Losh @param Source A pointer to a Null-terminated Unicode string. 2610d1ba665SWarner Losh @param Length The maximum number of Unicode characters to copy. 2620d1ba665SWarner Losh 2630d1ba665SWarner Losh @retval RETURN_SUCCESS String is copied. 2640d1ba665SWarner Losh @retval RETURN_BUFFER_TOO_SMALL If DestMax is NOT greater than 2650d1ba665SWarner Losh MIN(StrLen(Source), Length). 2660d1ba665SWarner Losh @retval RETURN_INVALID_PARAMETER If Destination is NULL. 2670d1ba665SWarner Losh If Source is NULL. 2680d1ba665SWarner Losh If PcdMaximumUnicodeStringLength is not zero, 2690d1ba665SWarner Losh and DestMax is greater than 2700d1ba665SWarner Losh PcdMaximumUnicodeStringLength. 2710d1ba665SWarner Losh If DestMax is 0. 2720d1ba665SWarner Losh @retval RETURN_ACCESS_DENIED If Source and Destination overlap. 2730d1ba665SWarner Losh **/ 2740d1ba665SWarner Losh RETURN_STATUS 2750d1ba665SWarner Losh EFIAPI 2760d1ba665SWarner Losh StrnCpyS ( 2770d1ba665SWarner Losh OUT CHAR16 *Destination, 2780d1ba665SWarner Losh IN UINTN DestMax, 2790d1ba665SWarner Losh IN CONST CHAR16 *Source, 2800d1ba665SWarner Losh IN UINTN Length 2810d1ba665SWarner Losh ); 2820d1ba665SWarner Losh 2830d1ba665SWarner Losh /** 2840d1ba665SWarner Losh Appends a copy of the string pointed to by Source (including the terminating 2850d1ba665SWarner Losh null char) to the end of the string pointed to by Destination. 2860d1ba665SWarner Losh 2870d1ba665SWarner Losh This function is similar as strcat_s defined in C11. 2880d1ba665SWarner Losh 2890d1ba665SWarner Losh If Destination is not aligned on a 16-bit boundary, then ASSERT(). 2900d1ba665SWarner Losh If Source is not aligned on a 16-bit boundary, then ASSERT(). 2910d1ba665SWarner Losh 2920d1ba665SWarner Losh If an error is returned, then the Destination is unmodified. 2930d1ba665SWarner Losh 2940d1ba665SWarner Losh @param Destination A pointer to a Null-terminated Unicode string. 2950d1ba665SWarner Losh @param DestMax The maximum number of Destination Unicode 2960d1ba665SWarner Losh char, including terminating null char. 2970d1ba665SWarner Losh @param Source A pointer to a Null-terminated Unicode string. 2980d1ba665SWarner Losh 2990d1ba665SWarner Losh @retval RETURN_SUCCESS String is appended. 3000d1ba665SWarner Losh @retval RETURN_BAD_BUFFER_SIZE If DestMax is NOT greater than 3010d1ba665SWarner Losh StrLen(Destination). 3020d1ba665SWarner Losh @retval RETURN_BUFFER_TOO_SMALL If (DestMax - StrLen(Destination)) is NOT 3030d1ba665SWarner Losh greater than StrLen(Source). 3040d1ba665SWarner Losh @retval RETURN_INVALID_PARAMETER If Destination is NULL. 3050d1ba665SWarner Losh If Source is NULL. 3060d1ba665SWarner Losh If PcdMaximumUnicodeStringLength is not zero, 3070d1ba665SWarner Losh and DestMax is greater than 3080d1ba665SWarner Losh PcdMaximumUnicodeStringLength. 3090d1ba665SWarner Losh If DestMax is 0. 3100d1ba665SWarner Losh @retval RETURN_ACCESS_DENIED If Source and Destination overlap. 3110d1ba665SWarner Losh **/ 3120d1ba665SWarner Losh RETURN_STATUS 3130d1ba665SWarner Losh EFIAPI 3140d1ba665SWarner Losh StrCatS ( 3150d1ba665SWarner Losh IN OUT CHAR16 *Destination, 3160d1ba665SWarner Losh IN UINTN DestMax, 3170d1ba665SWarner Losh IN CONST CHAR16 *Source 3180d1ba665SWarner Losh ); 3190d1ba665SWarner Losh 3200d1ba665SWarner Losh /** 3210d1ba665SWarner Losh Appends not more than Length successive char from the string pointed to by 3220d1ba665SWarner Losh Source to the end of the string pointed to by Destination. If no null char is 3230d1ba665SWarner Losh copied from Source, then Destination[StrLen(Destination) + Length] is always 3240d1ba665SWarner Losh set to null. 3250d1ba665SWarner Losh 3260d1ba665SWarner Losh This function is similar as strncat_s defined in C11. 3270d1ba665SWarner Losh 3280d1ba665SWarner Losh If Destination is not aligned on a 16-bit boundary, then ASSERT(). 3290d1ba665SWarner Losh If Source is not aligned on a 16-bit boundary, then ASSERT(). 3300d1ba665SWarner Losh 3310d1ba665SWarner Losh If an error is returned, then the Destination is unmodified. 3320d1ba665SWarner Losh 3330d1ba665SWarner Losh @param Destination A pointer to a Null-terminated Unicode string. 3340d1ba665SWarner Losh @param DestMax The maximum number of Destination Unicode 3350d1ba665SWarner Losh char, including terminating null char. 3360d1ba665SWarner Losh @param Source A pointer to a Null-terminated Unicode string. 3370d1ba665SWarner Losh @param Length The maximum number of Unicode characters to copy. 3380d1ba665SWarner Losh 3390d1ba665SWarner Losh @retval RETURN_SUCCESS String is appended. 3400d1ba665SWarner Losh @retval RETURN_BAD_BUFFER_SIZE If DestMax is NOT greater than 3410d1ba665SWarner Losh StrLen(Destination). 3420d1ba665SWarner Losh @retval RETURN_BUFFER_TOO_SMALL If (DestMax - StrLen(Destination)) is NOT 3430d1ba665SWarner Losh greater than MIN(StrLen(Source), Length). 3440d1ba665SWarner Losh @retval RETURN_INVALID_PARAMETER If Destination is NULL. 3450d1ba665SWarner Losh If Source is NULL. 3460d1ba665SWarner Losh If PcdMaximumUnicodeStringLength is not zero, 3470d1ba665SWarner Losh and DestMax is greater than 3480d1ba665SWarner Losh PcdMaximumUnicodeStringLength. 3490d1ba665SWarner Losh If DestMax is 0. 3500d1ba665SWarner Losh @retval RETURN_ACCESS_DENIED If Source and Destination overlap. 3510d1ba665SWarner Losh **/ 3520d1ba665SWarner Losh RETURN_STATUS 3530d1ba665SWarner Losh EFIAPI 3540d1ba665SWarner Losh StrnCatS ( 3550d1ba665SWarner Losh IN OUT CHAR16 *Destination, 3560d1ba665SWarner Losh IN UINTN DestMax, 3570d1ba665SWarner Losh IN CONST CHAR16 *Source, 3580d1ba665SWarner Losh IN UINTN Length 3590d1ba665SWarner Losh ); 3600d1ba665SWarner Losh 3610d1ba665SWarner Losh /** 3620d1ba665SWarner Losh Convert a Null-terminated Unicode decimal string to a value of type UINTN. 3630d1ba665SWarner Losh 3640d1ba665SWarner Losh This function outputs a value of type UINTN by interpreting the contents of 3650d1ba665SWarner Losh the Unicode string specified by String as a decimal number. The format of the 3660d1ba665SWarner Losh input Unicode string String is: 3670d1ba665SWarner Losh 3680d1ba665SWarner Losh [spaces] [decimal digits]. 3690d1ba665SWarner Losh 3700d1ba665SWarner Losh The valid decimal digit character is in the range [0-9]. The function will 3710d1ba665SWarner Losh ignore the pad space, which includes spaces or tab characters, before 3720d1ba665SWarner Losh [decimal digits]. The running zero in the beginning of [decimal digits] will 3730d1ba665SWarner Losh be ignored. Then, the function stops at the first character that is a not a 3740d1ba665SWarner Losh valid decimal character or a Null-terminator, whichever one comes first. 3750d1ba665SWarner Losh 3760d1ba665SWarner Losh If String is not aligned in a 16-bit boundary, then ASSERT(). 3770d1ba665SWarner Losh 3780d1ba665SWarner Losh If String has no valid decimal digits in the above format, then 0 is stored 3790d1ba665SWarner Losh at the location pointed to by Data. 3800d1ba665SWarner Losh If the number represented by String exceeds the range defined by UINTN, then 3810d1ba665SWarner Losh MAX_UINTN is stored at the location pointed to by Data. 3820d1ba665SWarner Losh 3830d1ba665SWarner Losh If EndPointer is not NULL, a pointer to the character that stopped the scan 3840d1ba665SWarner Losh is stored at the location pointed to by EndPointer. If String has no valid 3850d1ba665SWarner Losh decimal digits right after the optional pad spaces, the value of String is 3860d1ba665SWarner Losh stored at the location pointed to by EndPointer. 3870d1ba665SWarner Losh 3880d1ba665SWarner Losh @param String Pointer to a Null-terminated Unicode string. 3890d1ba665SWarner Losh @param EndPointer Pointer to character that stops scan. 3900d1ba665SWarner Losh @param Data Pointer to the converted value. 3910d1ba665SWarner Losh 3920d1ba665SWarner Losh @retval RETURN_SUCCESS Value is translated from String. 3930d1ba665SWarner Losh @retval RETURN_INVALID_PARAMETER If String is NULL. 3940d1ba665SWarner Losh If Data is NULL. 3950d1ba665SWarner Losh If PcdMaximumUnicodeStringLength is not 3960d1ba665SWarner Losh zero, and String contains more than 3970d1ba665SWarner Losh PcdMaximumUnicodeStringLength Unicode 3980d1ba665SWarner Losh characters, not including the 3990d1ba665SWarner Losh Null-terminator. 4000d1ba665SWarner Losh @retval RETURN_UNSUPPORTED If the number represented by String exceeds 4010d1ba665SWarner Losh the range defined by UINTN. 4020d1ba665SWarner Losh 4030d1ba665SWarner Losh **/ 4040d1ba665SWarner Losh RETURN_STATUS 4050d1ba665SWarner Losh EFIAPI 4060d1ba665SWarner Losh StrDecimalToUintnS ( 4070d1ba665SWarner Losh IN CONST CHAR16 *String, 4080d1ba665SWarner Losh OUT CHAR16 **EndPointer, OPTIONAL 4090d1ba665SWarner Losh OUT UINTN *Data 4100d1ba665SWarner Losh ); 4110d1ba665SWarner Losh 4120d1ba665SWarner Losh /** 4130d1ba665SWarner Losh Convert a Null-terminated Unicode decimal string to a value of type UINT64. 4140d1ba665SWarner Losh 4150d1ba665SWarner Losh This function outputs a value of type UINT64 by interpreting the contents of 4160d1ba665SWarner Losh the Unicode string specified by String as a decimal number. The format of the 4170d1ba665SWarner Losh input Unicode string String is: 4180d1ba665SWarner Losh 4190d1ba665SWarner Losh [spaces] [decimal digits]. 4200d1ba665SWarner Losh 4210d1ba665SWarner Losh The valid decimal digit character is in the range [0-9]. The function will 4220d1ba665SWarner Losh ignore the pad space, which includes spaces or tab characters, before 4230d1ba665SWarner Losh [decimal digits]. The running zero in the beginning of [decimal digits] will 4240d1ba665SWarner Losh be ignored. Then, the function stops at the first character that is a not a 4250d1ba665SWarner Losh valid decimal character or a Null-terminator, whichever one comes first. 4260d1ba665SWarner Losh 4270d1ba665SWarner Losh If String is not aligned in a 16-bit boundary, then ASSERT(). 4280d1ba665SWarner Losh 4290d1ba665SWarner Losh If String has no valid decimal digits in the above format, then 0 is stored 4300d1ba665SWarner Losh at the location pointed to by Data. 4310d1ba665SWarner Losh If the number represented by String exceeds the range defined by UINT64, then 4320d1ba665SWarner Losh MAX_UINT64 is stored at the location pointed to by Data. 4330d1ba665SWarner Losh 4340d1ba665SWarner Losh If EndPointer is not NULL, a pointer to the character that stopped the scan 4350d1ba665SWarner Losh is stored at the location pointed to by EndPointer. If String has no valid 4360d1ba665SWarner Losh decimal digits right after the optional pad spaces, the value of String is 4370d1ba665SWarner Losh stored at the location pointed to by EndPointer. 4380d1ba665SWarner Losh 4390d1ba665SWarner Losh @param String Pointer to a Null-terminated Unicode string. 4400d1ba665SWarner Losh @param EndPointer Pointer to character that stops scan. 4410d1ba665SWarner Losh @param Data Pointer to the converted value. 4420d1ba665SWarner Losh 4430d1ba665SWarner Losh @retval RETURN_SUCCESS Value is translated from String. 4440d1ba665SWarner Losh @retval RETURN_INVALID_PARAMETER If String is NULL. 4450d1ba665SWarner Losh If Data is NULL. 4460d1ba665SWarner Losh If PcdMaximumUnicodeStringLength is not 4470d1ba665SWarner Losh zero, and String contains more than 4480d1ba665SWarner Losh PcdMaximumUnicodeStringLength Unicode 4490d1ba665SWarner Losh characters, not including the 4500d1ba665SWarner Losh Null-terminator. 4510d1ba665SWarner Losh @retval RETURN_UNSUPPORTED If the number represented by String exceeds 4520d1ba665SWarner Losh the range defined by UINT64. 4530d1ba665SWarner Losh 4540d1ba665SWarner Losh **/ 4550d1ba665SWarner Losh RETURN_STATUS 4560d1ba665SWarner Losh EFIAPI 4570d1ba665SWarner Losh StrDecimalToUint64S ( 4580d1ba665SWarner Losh IN CONST CHAR16 *String, 4590d1ba665SWarner Losh OUT CHAR16 **EndPointer, OPTIONAL 4600d1ba665SWarner Losh OUT UINT64 *Data 4610d1ba665SWarner Losh ); 4620d1ba665SWarner Losh 4630d1ba665SWarner Losh /** 4640d1ba665SWarner Losh Convert a Null-terminated Unicode hexadecimal string to a value of type 4650d1ba665SWarner Losh UINTN. 4660d1ba665SWarner Losh 4670d1ba665SWarner Losh This function outputs a value of type UINTN by interpreting the contents of 4680d1ba665SWarner Losh the Unicode string specified by String as a hexadecimal number. The format of 4690d1ba665SWarner Losh the input Unicode string String is: 4700d1ba665SWarner Losh 4710d1ba665SWarner Losh [spaces][zeros][x][hexadecimal digits]. 4720d1ba665SWarner Losh 4730d1ba665SWarner Losh The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F]. 4740d1ba665SWarner Losh The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix. 4750d1ba665SWarner Losh If "x" appears in the input string, it must be prefixed with at least one 0. 4760d1ba665SWarner Losh The function will ignore the pad space, which includes spaces or tab 4770d1ba665SWarner Losh characters, before [zeros], [x] or [hexadecimal digit]. The running zero 4780d1ba665SWarner Losh before [x] or [hexadecimal digit] will be ignored. Then, the decoding starts 4790d1ba665SWarner Losh after [x] or the first valid hexadecimal digit. Then, the function stops at 4800d1ba665SWarner Losh the first character that is a not a valid hexadecimal character or NULL, 4810d1ba665SWarner Losh whichever one comes first. 4820d1ba665SWarner Losh 4830d1ba665SWarner Losh If String is not aligned in a 16-bit boundary, then ASSERT(). 4840d1ba665SWarner Losh 4850d1ba665SWarner Losh If String has no valid hexadecimal digits in the above format, then 0 is 4860d1ba665SWarner Losh stored at the location pointed to by Data. 4870d1ba665SWarner Losh If the number represented by String exceeds the range defined by UINTN, then 4880d1ba665SWarner Losh MAX_UINTN is stored at the location pointed to by Data. 4890d1ba665SWarner Losh 4900d1ba665SWarner Losh If EndPointer is not NULL, a pointer to the character that stopped the scan 4910d1ba665SWarner Losh is stored at the location pointed to by EndPointer. If String has no valid 4920d1ba665SWarner Losh hexadecimal digits right after the optional pad spaces, the value of String 4930d1ba665SWarner Losh is stored at the location pointed to by EndPointer. 4940d1ba665SWarner Losh 4950d1ba665SWarner Losh @param String Pointer to a Null-terminated Unicode string. 4960d1ba665SWarner Losh @param EndPointer Pointer to character that stops scan. 4970d1ba665SWarner Losh @param Data Pointer to the converted value. 4980d1ba665SWarner Losh 4990d1ba665SWarner Losh @retval RETURN_SUCCESS Value is translated from String. 5000d1ba665SWarner Losh @retval RETURN_INVALID_PARAMETER If String is NULL. 5010d1ba665SWarner Losh If Data is NULL. 5020d1ba665SWarner Losh If PcdMaximumUnicodeStringLength is not 5030d1ba665SWarner Losh zero, and String contains more than 5040d1ba665SWarner Losh PcdMaximumUnicodeStringLength Unicode 5050d1ba665SWarner Losh characters, not including the 5060d1ba665SWarner Losh Null-terminator. 5070d1ba665SWarner Losh @retval RETURN_UNSUPPORTED If the number represented by String exceeds 5080d1ba665SWarner Losh the range defined by UINTN. 5090d1ba665SWarner Losh 5100d1ba665SWarner Losh **/ 5110d1ba665SWarner Losh RETURN_STATUS 5120d1ba665SWarner Losh EFIAPI 5130d1ba665SWarner Losh StrHexToUintnS ( 5140d1ba665SWarner Losh IN CONST CHAR16 *String, 5150d1ba665SWarner Losh OUT CHAR16 **EndPointer, OPTIONAL 5160d1ba665SWarner Losh OUT UINTN *Data 5170d1ba665SWarner Losh ); 5180d1ba665SWarner Losh 5190d1ba665SWarner Losh /** 5200d1ba665SWarner Losh Convert a Null-terminated Unicode hexadecimal string to a value of type 5210d1ba665SWarner Losh UINT64. 5220d1ba665SWarner Losh 5230d1ba665SWarner Losh This function outputs a value of type UINT64 by interpreting the contents of 5240d1ba665SWarner Losh the Unicode string specified by String as a hexadecimal number. The format of 5250d1ba665SWarner Losh the input Unicode string String is: 5260d1ba665SWarner Losh 5270d1ba665SWarner Losh [spaces][zeros][x][hexadecimal digits]. 5280d1ba665SWarner Losh 5290d1ba665SWarner Losh The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F]. 5300d1ba665SWarner Losh The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix. 5310d1ba665SWarner Losh If "x" appears in the input string, it must be prefixed with at least one 0. 5320d1ba665SWarner Losh The function will ignore the pad space, which includes spaces or tab 5330d1ba665SWarner Losh characters, before [zeros], [x] or [hexadecimal digit]. The running zero 5340d1ba665SWarner Losh before [x] or [hexadecimal digit] will be ignored. Then, the decoding starts 5350d1ba665SWarner Losh after [x] or the first valid hexadecimal digit. Then, the function stops at 5360d1ba665SWarner Losh the first character that is a not a valid hexadecimal character or NULL, 5370d1ba665SWarner Losh whichever one comes first. 5380d1ba665SWarner Losh 5390d1ba665SWarner Losh If String is not aligned in a 16-bit boundary, then ASSERT(). 5400d1ba665SWarner Losh 5410d1ba665SWarner Losh If String has no valid hexadecimal digits in the above format, then 0 is 5420d1ba665SWarner Losh stored at the location pointed to by Data. 5430d1ba665SWarner Losh If the number represented by String exceeds the range defined by UINT64, then 5440d1ba665SWarner Losh MAX_UINT64 is stored at the location pointed to by Data. 5450d1ba665SWarner Losh 5460d1ba665SWarner Losh If EndPointer is not NULL, a pointer to the character that stopped the scan 5470d1ba665SWarner Losh is stored at the location pointed to by EndPointer. If String has no valid 5480d1ba665SWarner Losh hexadecimal digits right after the optional pad spaces, the value of String 5490d1ba665SWarner Losh is stored at the location pointed to by EndPointer. 5500d1ba665SWarner Losh 5510d1ba665SWarner Losh @param String Pointer to a Null-terminated Unicode string. 5520d1ba665SWarner Losh @param EndPointer Pointer to character that stops scan. 5530d1ba665SWarner Losh @param Data Pointer to the converted value. 5540d1ba665SWarner Losh 5550d1ba665SWarner Losh @retval RETURN_SUCCESS Value is translated from String. 5560d1ba665SWarner Losh @retval RETURN_INVALID_PARAMETER If String is NULL. 5570d1ba665SWarner Losh If Data is NULL. 5580d1ba665SWarner Losh If PcdMaximumUnicodeStringLength is not 5590d1ba665SWarner Losh zero, and String contains more than 5600d1ba665SWarner Losh PcdMaximumUnicodeStringLength Unicode 5610d1ba665SWarner Losh characters, not including the 5620d1ba665SWarner Losh Null-terminator. 5630d1ba665SWarner Losh @retval RETURN_UNSUPPORTED If the number represented by String exceeds 5640d1ba665SWarner Losh the range defined by UINT64. 5650d1ba665SWarner Losh 5660d1ba665SWarner Losh **/ 5670d1ba665SWarner Losh RETURN_STATUS 5680d1ba665SWarner Losh EFIAPI 5690d1ba665SWarner Losh StrHexToUint64S ( 5700d1ba665SWarner Losh IN CONST CHAR16 *String, 5710d1ba665SWarner Losh OUT CHAR16 **EndPointer, OPTIONAL 5720d1ba665SWarner Losh OUT UINT64 *Data 5730d1ba665SWarner Losh ); 5740d1ba665SWarner Losh 5750d1ba665SWarner Losh /** 5760d1ba665SWarner Losh Returns the length of a Null-terminated Ascii string. 5770d1ba665SWarner Losh 5780d1ba665SWarner Losh This function is similar as strlen_s defined in C11. 5790d1ba665SWarner Losh 5800d1ba665SWarner Losh @param String A pointer to a Null-terminated Ascii string. 5810d1ba665SWarner Losh @param MaxSize The maximum number of Destination Ascii 5820d1ba665SWarner Losh char, including terminating null char. 5830d1ba665SWarner Losh 5840d1ba665SWarner Losh @retval 0 If String is NULL. 5850d1ba665SWarner Losh @retval MaxSize If there is no null character in the first MaxSize characters of String. 5860d1ba665SWarner Losh @return The number of characters that percede the terminating null character. 5870d1ba665SWarner Losh 5880d1ba665SWarner Losh **/ 5890d1ba665SWarner Losh UINTN 5900d1ba665SWarner Losh EFIAPI 5910d1ba665SWarner Losh AsciiStrnLenS ( 5920d1ba665SWarner Losh IN CONST CHAR8 *String, 5930d1ba665SWarner Losh IN UINTN MaxSize 5940d1ba665SWarner Losh ); 5950d1ba665SWarner Losh 5960d1ba665SWarner Losh /** 5970d1ba665SWarner Losh Returns the size of a Null-terminated Ascii string in bytes, including the 5980d1ba665SWarner Losh Null terminator. 5990d1ba665SWarner Losh 6000d1ba665SWarner Losh This function returns the size of the Null-terminated Ascii string specified 6010d1ba665SWarner Losh by String in bytes, including the Null terminator. 6020d1ba665SWarner Losh 6030d1ba665SWarner Losh @param String A pointer to a Null-terminated Ascii string. 6040d1ba665SWarner Losh @param MaxSize The maximum number of Destination Ascii 6050d1ba665SWarner Losh char, including the Null terminator. 6060d1ba665SWarner Losh 6070d1ba665SWarner Losh @retval 0 If String is NULL. 6080d1ba665SWarner Losh @retval (sizeof (CHAR8) * (MaxSize + 1)) 6090d1ba665SWarner Losh If there is no Null terminator in the first MaxSize characters of 6100d1ba665SWarner Losh String. 6110d1ba665SWarner Losh @return The size of the Null-terminated Ascii string in bytes, including the 6120d1ba665SWarner Losh Null terminator. 6130d1ba665SWarner Losh 6140d1ba665SWarner Losh **/ 6150d1ba665SWarner Losh UINTN 6160d1ba665SWarner Losh EFIAPI 6170d1ba665SWarner Losh AsciiStrnSizeS ( 6180d1ba665SWarner Losh IN CONST CHAR8 *String, 6190d1ba665SWarner Losh IN UINTN MaxSize 6200d1ba665SWarner Losh ); 6210d1ba665SWarner Losh 6220d1ba665SWarner Losh /** 6230d1ba665SWarner Losh Copies the string pointed to by Source (including the terminating null char) 6240d1ba665SWarner Losh to the array pointed to by Destination. 6250d1ba665SWarner Losh 6260d1ba665SWarner Losh This function is similar as strcpy_s defined in C11. 6270d1ba665SWarner Losh 6280d1ba665SWarner Losh If an error is returned, then the Destination is unmodified. 6290d1ba665SWarner Losh 6300d1ba665SWarner Losh @param Destination A pointer to a Null-terminated Ascii string. 6310d1ba665SWarner Losh @param DestMax The maximum number of Destination Ascii 6320d1ba665SWarner Losh char, including terminating null char. 6330d1ba665SWarner Losh @param Source A pointer to a Null-terminated Ascii string. 6340d1ba665SWarner Losh 6350d1ba665SWarner Losh @retval RETURN_SUCCESS String is copied. 6360d1ba665SWarner Losh @retval RETURN_BUFFER_TOO_SMALL If DestMax is NOT greater than StrLen(Source). 6370d1ba665SWarner Losh @retval RETURN_INVALID_PARAMETER If Destination is NULL. 6380d1ba665SWarner Losh If Source is NULL. 6390d1ba665SWarner Losh If PcdMaximumAsciiStringLength is not zero, 6400d1ba665SWarner Losh and DestMax is greater than 6410d1ba665SWarner Losh PcdMaximumAsciiStringLength. 6420d1ba665SWarner Losh If DestMax is 0. 6430d1ba665SWarner Losh @retval RETURN_ACCESS_DENIED If Source and Destination overlap. 6440d1ba665SWarner Losh **/ 6450d1ba665SWarner Losh RETURN_STATUS 6460d1ba665SWarner Losh EFIAPI 6470d1ba665SWarner Losh AsciiStrCpyS ( 6480d1ba665SWarner Losh OUT CHAR8 *Destination, 6490d1ba665SWarner Losh IN UINTN DestMax, 6500d1ba665SWarner Losh IN CONST CHAR8 *Source 6510d1ba665SWarner Losh ); 6520d1ba665SWarner Losh 6530d1ba665SWarner Losh /** 6540d1ba665SWarner Losh Copies not more than Length successive char from the string pointed to by 6550d1ba665SWarner Losh Source to the array pointed to by Destination. If no null char is copied from 6560d1ba665SWarner Losh Source, then Destination[Length] is always set to null. 6570d1ba665SWarner Losh 6580d1ba665SWarner Losh This function is similar as strncpy_s defined in C11. 6590d1ba665SWarner Losh 6600d1ba665SWarner Losh If an error is returned, then the Destination is unmodified. 6610d1ba665SWarner Losh 6620d1ba665SWarner Losh @param Destination A pointer to a Null-terminated Ascii string. 6630d1ba665SWarner Losh @param DestMax The maximum number of Destination Ascii 6640d1ba665SWarner Losh char, including terminating null char. 6650d1ba665SWarner Losh @param Source A pointer to a Null-terminated Ascii string. 6660d1ba665SWarner Losh @param Length The maximum number of Ascii characters to copy. 6670d1ba665SWarner Losh 6680d1ba665SWarner Losh @retval RETURN_SUCCESS String is copied. 6690d1ba665SWarner Losh @retval RETURN_BUFFER_TOO_SMALL If DestMax is NOT greater than 6700d1ba665SWarner Losh MIN(StrLen(Source), Length). 6710d1ba665SWarner Losh @retval RETURN_INVALID_PARAMETER If Destination is NULL. 6720d1ba665SWarner Losh If Source is NULL. 6730d1ba665SWarner Losh If PcdMaximumAsciiStringLength is not zero, 6740d1ba665SWarner Losh and DestMax is greater than 6750d1ba665SWarner Losh PcdMaximumAsciiStringLength. 6760d1ba665SWarner Losh If DestMax is 0. 6770d1ba665SWarner Losh @retval RETURN_ACCESS_DENIED If Source and Destination overlap. 6780d1ba665SWarner Losh **/ 6790d1ba665SWarner Losh RETURN_STATUS 6800d1ba665SWarner Losh EFIAPI 6810d1ba665SWarner Losh AsciiStrnCpyS ( 6820d1ba665SWarner Losh OUT CHAR8 *Destination, 6830d1ba665SWarner Losh IN UINTN DestMax, 6840d1ba665SWarner Losh IN CONST CHAR8 *Source, 6850d1ba665SWarner Losh IN UINTN Length 6860d1ba665SWarner Losh ); 6870d1ba665SWarner Losh 6880d1ba665SWarner Losh /** 6890d1ba665SWarner Losh Appends a copy of the string pointed to by Source (including the terminating 6900d1ba665SWarner Losh null char) to the end of the string pointed to by Destination. 6910d1ba665SWarner Losh 6920d1ba665SWarner Losh This function is similar as strcat_s defined in C11. 6930d1ba665SWarner Losh 6940d1ba665SWarner Losh If an error is returned, then the Destination is unmodified. 6950d1ba665SWarner Losh 6960d1ba665SWarner Losh @param Destination A pointer to a Null-terminated Ascii string. 6970d1ba665SWarner Losh @param DestMax The maximum number of Destination Ascii 6980d1ba665SWarner Losh char, including terminating null char. 6990d1ba665SWarner Losh @param Source A pointer to a Null-terminated Ascii string. 7000d1ba665SWarner Losh 7010d1ba665SWarner Losh @retval RETURN_SUCCESS String is appended. 7020d1ba665SWarner Losh @retval RETURN_BAD_BUFFER_SIZE If DestMax is NOT greater than 7030d1ba665SWarner Losh StrLen(Destination). 7040d1ba665SWarner Losh @retval RETURN_BUFFER_TOO_SMALL If (DestMax - StrLen(Destination)) is NOT 7050d1ba665SWarner Losh greater than StrLen(Source). 7060d1ba665SWarner Losh @retval RETURN_INVALID_PARAMETER If Destination is NULL. 7070d1ba665SWarner Losh If Source is NULL. 7080d1ba665SWarner Losh If PcdMaximumAsciiStringLength is not zero, 7090d1ba665SWarner Losh and DestMax is greater than 7100d1ba665SWarner Losh PcdMaximumAsciiStringLength. 7110d1ba665SWarner Losh If DestMax is 0. 7120d1ba665SWarner Losh @retval RETURN_ACCESS_DENIED If Source and Destination overlap. 7130d1ba665SWarner Losh **/ 7140d1ba665SWarner Losh RETURN_STATUS 7150d1ba665SWarner Losh EFIAPI 7160d1ba665SWarner Losh AsciiStrCatS ( 7170d1ba665SWarner Losh IN OUT CHAR8 *Destination, 7180d1ba665SWarner Losh IN UINTN DestMax, 7190d1ba665SWarner Losh IN CONST CHAR8 *Source 7200d1ba665SWarner Losh ); 7210d1ba665SWarner Losh 7220d1ba665SWarner Losh /** 7230d1ba665SWarner Losh Appends not more than Length successive char from the string pointed to by 7240d1ba665SWarner Losh Source to the end of the string pointed to by Destination. If no null char is 7250d1ba665SWarner Losh copied from Source, then Destination[StrLen(Destination) + Length] is always 7260d1ba665SWarner Losh set to null. 7270d1ba665SWarner Losh 7280d1ba665SWarner Losh This function is similar as strncat_s defined in C11. 7290d1ba665SWarner Losh 7300d1ba665SWarner Losh If an error is returned, then the Destination is unmodified. 7310d1ba665SWarner Losh 7320d1ba665SWarner Losh @param Destination A pointer to a Null-terminated Ascii string. 7330d1ba665SWarner Losh @param DestMax The maximum number of Destination Ascii 7340d1ba665SWarner Losh char, including terminating null char. 7350d1ba665SWarner Losh @param Source A pointer to a Null-terminated Ascii string. 7360d1ba665SWarner Losh @param Length The maximum number of Ascii characters to copy. 7370d1ba665SWarner Losh 7380d1ba665SWarner Losh @retval RETURN_SUCCESS String is appended. 7390d1ba665SWarner Losh @retval RETURN_BAD_BUFFER_SIZE If DestMax is NOT greater than 7400d1ba665SWarner Losh StrLen(Destination). 7410d1ba665SWarner Losh @retval RETURN_BUFFER_TOO_SMALL If (DestMax - StrLen(Destination)) is NOT 7420d1ba665SWarner Losh greater than MIN(StrLen(Source), Length). 7430d1ba665SWarner Losh @retval RETURN_INVALID_PARAMETER If Destination is NULL. 7440d1ba665SWarner Losh If Source is NULL. 7450d1ba665SWarner Losh If PcdMaximumAsciiStringLength is not zero, 7460d1ba665SWarner Losh and DestMax is greater than 7470d1ba665SWarner Losh PcdMaximumAsciiStringLength. 7480d1ba665SWarner Losh If DestMax is 0. 7490d1ba665SWarner Losh @retval RETURN_ACCESS_DENIED If Source and Destination overlap. 7500d1ba665SWarner Losh **/ 7510d1ba665SWarner Losh RETURN_STATUS 7520d1ba665SWarner Losh EFIAPI 7530d1ba665SWarner Losh AsciiStrnCatS ( 7540d1ba665SWarner Losh IN OUT CHAR8 *Destination, 7550d1ba665SWarner Losh IN UINTN DestMax, 7560d1ba665SWarner Losh IN CONST CHAR8 *Source, 7570d1ba665SWarner Losh IN UINTN Length 7580d1ba665SWarner Losh ); 7590d1ba665SWarner Losh 7600d1ba665SWarner Losh /** 7610d1ba665SWarner Losh Convert a Null-terminated Ascii decimal string to a value of type UINTN. 7620d1ba665SWarner Losh 7630d1ba665SWarner Losh This function outputs a value of type UINTN by interpreting the contents of 7640d1ba665SWarner Losh the Ascii string specified by String as a decimal number. The format of the 7650d1ba665SWarner Losh input Ascii string String is: 7660d1ba665SWarner Losh 7670d1ba665SWarner Losh [spaces] [decimal digits]. 7680d1ba665SWarner Losh 7690d1ba665SWarner Losh The valid decimal digit character is in the range [0-9]. The function will 7700d1ba665SWarner Losh ignore the pad space, which includes spaces or tab characters, before 7710d1ba665SWarner Losh [decimal digits]. The running zero in the beginning of [decimal digits] will 7720d1ba665SWarner Losh be ignored. Then, the function stops at the first character that is a not a 7730d1ba665SWarner Losh valid decimal character or a Null-terminator, whichever one comes first. 7740d1ba665SWarner Losh 7750d1ba665SWarner Losh If String has no valid decimal digits in the above format, then 0 is stored 7760d1ba665SWarner Losh at the location pointed to by Data. 7770d1ba665SWarner Losh If the number represented by String exceeds the range defined by UINTN, then 7780d1ba665SWarner Losh MAX_UINTN is stored at the location pointed to by Data. 7790d1ba665SWarner Losh 7800d1ba665SWarner Losh If EndPointer is not NULL, a pointer to the character that stopped the scan 7810d1ba665SWarner Losh is stored at the location pointed to by EndPointer. If String has no valid 7820d1ba665SWarner Losh decimal digits right after the optional pad spaces, the value of String is 7830d1ba665SWarner Losh stored at the location pointed to by EndPointer. 7840d1ba665SWarner Losh 7850d1ba665SWarner Losh @param String Pointer to a Null-terminated Ascii string. 7860d1ba665SWarner Losh @param EndPointer Pointer to character that stops scan. 7870d1ba665SWarner Losh @param Data Pointer to the converted value. 7880d1ba665SWarner Losh 7890d1ba665SWarner Losh @retval RETURN_SUCCESS Value is translated from String. 7900d1ba665SWarner Losh @retval RETURN_INVALID_PARAMETER If String is NULL. 7910d1ba665SWarner Losh If Data is NULL. 7920d1ba665SWarner Losh If PcdMaximumAsciiStringLength is not zero, 7930d1ba665SWarner Losh and String contains more than 7940d1ba665SWarner Losh PcdMaximumAsciiStringLength Ascii 7950d1ba665SWarner Losh characters, not including the 7960d1ba665SWarner Losh Null-terminator. 7970d1ba665SWarner Losh @retval RETURN_UNSUPPORTED If the number represented by String exceeds 7980d1ba665SWarner Losh the range defined by UINTN. 7990d1ba665SWarner Losh 8000d1ba665SWarner Losh **/ 8010d1ba665SWarner Losh RETURN_STATUS 8020d1ba665SWarner Losh EFIAPI 8030d1ba665SWarner Losh AsciiStrDecimalToUintnS ( 8040d1ba665SWarner Losh IN CONST CHAR8 *String, 8050d1ba665SWarner Losh OUT CHAR8 **EndPointer, OPTIONAL 8060d1ba665SWarner Losh OUT UINTN *Data 8070d1ba665SWarner Losh ); 8080d1ba665SWarner Losh 8090d1ba665SWarner Losh /** 8100d1ba665SWarner Losh Convert a Null-terminated Ascii decimal string to a value of type UINT64. 8110d1ba665SWarner Losh 8120d1ba665SWarner Losh This function outputs a value of type UINT64 by interpreting the contents of 8130d1ba665SWarner Losh the Ascii string specified by String as a decimal number. The format of the 8140d1ba665SWarner Losh input Ascii string String is: 8150d1ba665SWarner Losh 8160d1ba665SWarner Losh [spaces] [decimal digits]. 8170d1ba665SWarner Losh 8180d1ba665SWarner Losh The valid decimal digit character is in the range [0-9]. The function will 8190d1ba665SWarner Losh ignore the pad space, which includes spaces or tab characters, before 8200d1ba665SWarner Losh [decimal digits]. The running zero in the beginning of [decimal digits] will 8210d1ba665SWarner Losh be ignored. Then, the function stops at the first character that is a not a 8220d1ba665SWarner Losh valid decimal character or a Null-terminator, whichever one comes first. 8230d1ba665SWarner Losh 8240d1ba665SWarner Losh If String has no valid decimal digits in the above format, then 0 is stored 8250d1ba665SWarner Losh at the location pointed to by Data. 8260d1ba665SWarner Losh If the number represented by String exceeds the range defined by UINT64, then 8270d1ba665SWarner Losh MAX_UINT64 is stored at the location pointed to by Data. 8280d1ba665SWarner Losh 8290d1ba665SWarner Losh If EndPointer is not NULL, a pointer to the character that stopped the scan 8300d1ba665SWarner Losh is stored at the location pointed to by EndPointer. If String has no valid 8310d1ba665SWarner Losh decimal digits right after the optional pad spaces, the value of String is 8320d1ba665SWarner Losh stored at the location pointed to by EndPointer. 8330d1ba665SWarner Losh 8340d1ba665SWarner Losh @param String Pointer to a Null-terminated Ascii string. 8350d1ba665SWarner Losh @param EndPointer Pointer to character that stops scan. 8360d1ba665SWarner Losh @param Data Pointer to the converted value. 8370d1ba665SWarner Losh 8380d1ba665SWarner Losh @retval RETURN_SUCCESS Value is translated from String. 8390d1ba665SWarner Losh @retval RETURN_INVALID_PARAMETER If String is NULL. 8400d1ba665SWarner Losh If Data is NULL. 8410d1ba665SWarner Losh If PcdMaximumAsciiStringLength is not zero, 8420d1ba665SWarner Losh and String contains more than 8430d1ba665SWarner Losh PcdMaximumAsciiStringLength Ascii 8440d1ba665SWarner Losh characters, not including the 8450d1ba665SWarner Losh Null-terminator. 8460d1ba665SWarner Losh @retval RETURN_UNSUPPORTED If the number represented by String exceeds 8470d1ba665SWarner Losh the range defined by UINT64. 8480d1ba665SWarner Losh 8490d1ba665SWarner Losh **/ 8500d1ba665SWarner Losh RETURN_STATUS 8510d1ba665SWarner Losh EFIAPI 8520d1ba665SWarner Losh AsciiStrDecimalToUint64S ( 8530d1ba665SWarner Losh IN CONST CHAR8 *String, 8540d1ba665SWarner Losh OUT CHAR8 **EndPointer, OPTIONAL 8550d1ba665SWarner Losh OUT UINT64 *Data 8560d1ba665SWarner Losh ); 8570d1ba665SWarner Losh 8580d1ba665SWarner Losh /** 8590d1ba665SWarner Losh Convert a Null-terminated Ascii hexadecimal string to a value of type UINTN. 8600d1ba665SWarner Losh 8610d1ba665SWarner Losh This function outputs a value of type UINTN by interpreting the contents of 8620d1ba665SWarner Losh the Ascii string specified by String as a hexadecimal number. The format of 8630d1ba665SWarner Losh the input Ascii string String is: 8640d1ba665SWarner Losh 8650d1ba665SWarner Losh [spaces][zeros][x][hexadecimal digits]. 8660d1ba665SWarner Losh 8670d1ba665SWarner Losh The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F]. 8680d1ba665SWarner Losh The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix. If 8690d1ba665SWarner Losh "x" appears in the input string, it must be prefixed with at least one 0. The 8700d1ba665SWarner Losh function will ignore the pad space, which includes spaces or tab characters, 8710d1ba665SWarner Losh before [zeros], [x] or [hexadecimal digits]. The running zero before [x] or 8720d1ba665SWarner Losh [hexadecimal digits] will be ignored. Then, the decoding starts after [x] or 8730d1ba665SWarner Losh the first valid hexadecimal digit. Then, the function stops at the first 8740d1ba665SWarner Losh character that is a not a valid hexadecimal character or Null-terminator, 8750d1ba665SWarner Losh whichever on comes first. 8760d1ba665SWarner Losh 8770d1ba665SWarner Losh If String has no valid hexadecimal digits in the above format, then 0 is 8780d1ba665SWarner Losh stored at the location pointed to by Data. 8790d1ba665SWarner Losh If the number represented by String exceeds the range defined by UINTN, then 8800d1ba665SWarner Losh MAX_UINTN is stored at the location pointed to by Data. 8810d1ba665SWarner Losh 8820d1ba665SWarner Losh If EndPointer is not NULL, a pointer to the character that stopped the scan 8830d1ba665SWarner Losh is stored at the location pointed to by EndPointer. If String has no valid 8840d1ba665SWarner Losh hexadecimal digits right after the optional pad spaces, the value of String 8850d1ba665SWarner Losh is stored at the location pointed to by EndPointer. 8860d1ba665SWarner Losh 8870d1ba665SWarner Losh @param String Pointer to a Null-terminated Ascii string. 8880d1ba665SWarner Losh @param EndPointer Pointer to character that stops scan. 8890d1ba665SWarner Losh @param Data Pointer to the converted value. 8900d1ba665SWarner Losh 8910d1ba665SWarner Losh @retval RETURN_SUCCESS Value is translated from String. 8920d1ba665SWarner Losh @retval RETURN_INVALID_PARAMETER If String is NULL. 8930d1ba665SWarner Losh If Data is NULL. 8940d1ba665SWarner Losh If PcdMaximumAsciiStringLength is not zero, 8950d1ba665SWarner Losh and String contains more than 8960d1ba665SWarner Losh PcdMaximumAsciiStringLength Ascii 8970d1ba665SWarner Losh characters, not including the 8980d1ba665SWarner Losh Null-terminator. 8990d1ba665SWarner Losh @retval RETURN_UNSUPPORTED If the number represented by String exceeds 9000d1ba665SWarner Losh the range defined by UINTN. 9010d1ba665SWarner Losh 9020d1ba665SWarner Losh **/ 9030d1ba665SWarner Losh RETURN_STATUS 9040d1ba665SWarner Losh EFIAPI 9050d1ba665SWarner Losh AsciiStrHexToUintnS ( 9060d1ba665SWarner Losh IN CONST CHAR8 *String, 9070d1ba665SWarner Losh OUT CHAR8 **EndPointer, OPTIONAL 9080d1ba665SWarner Losh OUT UINTN *Data 9090d1ba665SWarner Losh ); 9100d1ba665SWarner Losh 9110d1ba665SWarner Losh /** 9120d1ba665SWarner Losh Convert a Null-terminated Ascii hexadecimal string to a value of type UINT64. 9130d1ba665SWarner Losh 9140d1ba665SWarner Losh This function outputs a value of type UINT64 by interpreting the contents of 9150d1ba665SWarner Losh the Ascii string specified by String as a hexadecimal number. The format of 9160d1ba665SWarner Losh the input Ascii string String is: 9170d1ba665SWarner Losh 9180d1ba665SWarner Losh [spaces][zeros][x][hexadecimal digits]. 9190d1ba665SWarner Losh 9200d1ba665SWarner Losh The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F]. 9210d1ba665SWarner Losh The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix. If 9220d1ba665SWarner Losh "x" appears in the input string, it must be prefixed with at least one 0. The 9230d1ba665SWarner Losh function will ignore the pad space, which includes spaces or tab characters, 9240d1ba665SWarner Losh before [zeros], [x] or [hexadecimal digits]. The running zero before [x] or 9250d1ba665SWarner Losh [hexadecimal digits] will be ignored. Then, the decoding starts after [x] or 9260d1ba665SWarner Losh the first valid hexadecimal digit. Then, the function stops at the first 9270d1ba665SWarner Losh character that is a not a valid hexadecimal character or Null-terminator, 9280d1ba665SWarner Losh whichever on comes first. 9290d1ba665SWarner Losh 9300d1ba665SWarner Losh If String has no valid hexadecimal digits in the above format, then 0 is 9310d1ba665SWarner Losh stored at the location pointed to by Data. 9320d1ba665SWarner Losh If the number represented by String exceeds the range defined by UINT64, then 9330d1ba665SWarner Losh MAX_UINT64 is stored at the location pointed to by Data. 9340d1ba665SWarner Losh 9350d1ba665SWarner Losh If EndPointer is not NULL, a pointer to the character that stopped the scan 9360d1ba665SWarner Losh is stored at the location pointed to by EndPointer. If String has no valid 9370d1ba665SWarner Losh hexadecimal digits right after the optional pad spaces, the value of String 9380d1ba665SWarner Losh is stored at the location pointed to by EndPointer. 9390d1ba665SWarner Losh 9400d1ba665SWarner Losh @param String Pointer to a Null-terminated Ascii string. 9410d1ba665SWarner Losh @param EndPointer Pointer to character that stops scan. 9420d1ba665SWarner Losh @param Data Pointer to the converted value. 9430d1ba665SWarner Losh 9440d1ba665SWarner Losh @retval RETURN_SUCCESS Value is translated from String. 9450d1ba665SWarner Losh @retval RETURN_INVALID_PARAMETER If String is NULL. 9460d1ba665SWarner Losh If Data is NULL. 9470d1ba665SWarner Losh If PcdMaximumAsciiStringLength is not zero, 9480d1ba665SWarner Losh and String contains more than 9490d1ba665SWarner Losh PcdMaximumAsciiStringLength Ascii 9500d1ba665SWarner Losh characters, not including the 9510d1ba665SWarner Losh Null-terminator. 9520d1ba665SWarner Losh @retval RETURN_UNSUPPORTED If the number represented by String exceeds 9530d1ba665SWarner Losh the range defined by UINT64. 9540d1ba665SWarner Losh 9550d1ba665SWarner Losh **/ 9560d1ba665SWarner Losh RETURN_STATUS 9570d1ba665SWarner Losh EFIAPI 9580d1ba665SWarner Losh AsciiStrHexToUint64S ( 9590d1ba665SWarner Losh IN CONST CHAR8 *String, 9600d1ba665SWarner Losh OUT CHAR8 **EndPointer, OPTIONAL 9610d1ba665SWarner Losh OUT UINT64 *Data 9620d1ba665SWarner Losh ); 9630d1ba665SWarner Losh 9640d1ba665SWarner Losh 9650d1ba665SWarner Losh #ifndef DISABLE_NEW_DEPRECATED_INTERFACES 9660d1ba665SWarner Losh 9670d1ba665SWarner Losh /** 9680d1ba665SWarner Losh [ATTENTION] This function is deprecated for security reason. 9690d1ba665SWarner Losh 9700d1ba665SWarner Losh Copies one Null-terminated Unicode string to another Null-terminated Unicode 9710d1ba665SWarner Losh string and returns the new Unicode string. 9720d1ba665SWarner Losh 9730d1ba665SWarner Losh This function copies the contents of the Unicode string Source to the Unicode 9740d1ba665SWarner Losh string Destination, and returns Destination. If Source and Destination 9750d1ba665SWarner Losh overlap, then the results are undefined. 9760d1ba665SWarner Losh 9770d1ba665SWarner Losh If Destination is NULL, then ASSERT(). 9780d1ba665SWarner Losh If Destination is not aligned on a 16-bit boundary, then ASSERT(). 9790d1ba665SWarner Losh If Source is NULL, then ASSERT(). 9800d1ba665SWarner Losh If Source is not aligned on a 16-bit boundary, then ASSERT(). 9810d1ba665SWarner Losh If Source and Destination overlap, then ASSERT(). 9820d1ba665SWarner Losh If PcdMaximumUnicodeStringLength is not zero, and Source contains more than 9830d1ba665SWarner Losh PcdMaximumUnicodeStringLength Unicode characters not including the 9840d1ba665SWarner Losh Null-terminator, then ASSERT(). 9850d1ba665SWarner Losh 9860d1ba665SWarner Losh @param Destination The pointer to a Null-terminated Unicode string. 9870d1ba665SWarner Losh @param Source The pointer to a Null-terminated Unicode string. 9880d1ba665SWarner Losh 9890d1ba665SWarner Losh @return Destination. 9900d1ba665SWarner Losh 9910d1ba665SWarner Losh **/ 9920d1ba665SWarner Losh CHAR16 * 9930d1ba665SWarner Losh EFIAPI 9940d1ba665SWarner Losh StrCpy ( 9950d1ba665SWarner Losh OUT CHAR16 *Destination, 9960d1ba665SWarner Losh IN CONST CHAR16 *Source 9970d1ba665SWarner Losh ); 9980d1ba665SWarner Losh 9990d1ba665SWarner Losh 10000d1ba665SWarner Losh /** 10010d1ba665SWarner Losh [ATTENTION] This function is deprecated for security reason. 10020d1ba665SWarner Losh 10030d1ba665SWarner Losh Copies up to a specified length from one Null-terminated Unicode string to 10040d1ba665SWarner Losh another Null-terminated Unicode string and returns the new Unicode string. 10050d1ba665SWarner Losh 10060d1ba665SWarner Losh This function copies the contents of the Unicode string Source to the Unicode 10070d1ba665SWarner Losh string Destination, and returns Destination. At most, Length Unicode 10080d1ba665SWarner Losh characters are copied from Source to Destination. If Length is 0, then 10090d1ba665SWarner Losh Destination is returned unmodified. If Length is greater that the number of 10100d1ba665SWarner Losh Unicode characters in Source, then Destination is padded with Null Unicode 10110d1ba665SWarner Losh characters. If Source and Destination overlap, then the results are 10120d1ba665SWarner Losh undefined. 10130d1ba665SWarner Losh 10140d1ba665SWarner Losh If Length > 0 and Destination is NULL, then ASSERT(). 10150d1ba665SWarner Losh If Length > 0 and Destination is not aligned on a 16-bit boundary, then ASSERT(). 10160d1ba665SWarner Losh If Length > 0 and Source is NULL, then ASSERT(). 10170d1ba665SWarner Losh If Length > 0 and Source is not aligned on a 16-bit boundary, then ASSERT(). 10180d1ba665SWarner Losh If Source and Destination overlap, then ASSERT(). 10190d1ba665SWarner Losh If PcdMaximumUnicodeStringLength is not zero, and Length is greater than 10200d1ba665SWarner Losh PcdMaximumUnicodeStringLength, then ASSERT(). 10210d1ba665SWarner Losh If PcdMaximumUnicodeStringLength is not zero, and Source contains more than 10220d1ba665SWarner Losh PcdMaximumUnicodeStringLength Unicode characters, not including the Null-terminator, 10230d1ba665SWarner Losh then ASSERT(). 10240d1ba665SWarner Losh 10250d1ba665SWarner Losh @param Destination The pointer to a Null-terminated Unicode string. 10260d1ba665SWarner Losh @param Source The pointer to a Null-terminated Unicode string. 10270d1ba665SWarner Losh @param Length The maximum number of Unicode characters to copy. 10280d1ba665SWarner Losh 10290d1ba665SWarner Losh @return Destination. 10300d1ba665SWarner Losh 10310d1ba665SWarner Losh **/ 10320d1ba665SWarner Losh CHAR16 * 10330d1ba665SWarner Losh EFIAPI 10340d1ba665SWarner Losh StrnCpy ( 10350d1ba665SWarner Losh OUT CHAR16 *Destination, 10360d1ba665SWarner Losh IN CONST CHAR16 *Source, 10370d1ba665SWarner Losh IN UINTN Length 10380d1ba665SWarner Losh ); 1039*3245fa21SMitchell Horne #endif // !defined (DISABLE_NEW_DEPRECATED_INTERFACES) 10400d1ba665SWarner Losh 10410d1ba665SWarner Losh /** 10420d1ba665SWarner Losh Returns the length of a Null-terminated Unicode string. 10430d1ba665SWarner Losh 10440d1ba665SWarner Losh This function returns the number of Unicode characters in the Null-terminated 10450d1ba665SWarner Losh Unicode string specified by String. 10460d1ba665SWarner Losh 10470d1ba665SWarner Losh If String is NULL, then ASSERT(). 10480d1ba665SWarner Losh If String is not aligned on a 16-bit boundary, then ASSERT(). 10490d1ba665SWarner Losh If PcdMaximumUnicodeStringLength is not zero, and String contains more than 10500d1ba665SWarner Losh PcdMaximumUnicodeStringLength Unicode characters not including the 10510d1ba665SWarner Losh Null-terminator, then ASSERT(). 10520d1ba665SWarner Losh 10530d1ba665SWarner Losh @param String Pointer to a Null-terminated Unicode string. 10540d1ba665SWarner Losh 10550d1ba665SWarner Losh @return The length of String. 10560d1ba665SWarner Losh 10570d1ba665SWarner Losh **/ 10580d1ba665SWarner Losh UINTN 10590d1ba665SWarner Losh EFIAPI 10600d1ba665SWarner Losh StrLen ( 10610d1ba665SWarner Losh IN CONST CHAR16 *String 10620d1ba665SWarner Losh ); 10630d1ba665SWarner Losh 10640d1ba665SWarner Losh 10650d1ba665SWarner Losh /** 10660d1ba665SWarner Losh Returns the size of a Null-terminated Unicode string in bytes, including the 10670d1ba665SWarner Losh Null terminator. 10680d1ba665SWarner Losh 10690d1ba665SWarner Losh This function returns the size, in bytes, of the Null-terminated Unicode string 10700d1ba665SWarner Losh specified by String. 10710d1ba665SWarner Losh 10720d1ba665SWarner Losh If String is NULL, then ASSERT(). 10730d1ba665SWarner Losh If String is not aligned on a 16-bit boundary, then ASSERT(). 10740d1ba665SWarner Losh If PcdMaximumUnicodeStringLength is not zero, and String contains more than 10750d1ba665SWarner Losh PcdMaximumUnicodeStringLength Unicode characters not including the 10760d1ba665SWarner Losh Null-terminator, then ASSERT(). 10770d1ba665SWarner Losh 10780d1ba665SWarner Losh @param String The pointer to a Null-terminated Unicode string. 10790d1ba665SWarner Losh 10800d1ba665SWarner Losh @return The size of String. 10810d1ba665SWarner Losh 10820d1ba665SWarner Losh **/ 10830d1ba665SWarner Losh UINTN 10840d1ba665SWarner Losh EFIAPI 10850d1ba665SWarner Losh StrSize ( 10860d1ba665SWarner Losh IN CONST CHAR16 *String 10870d1ba665SWarner Losh ); 10880d1ba665SWarner Losh 10890d1ba665SWarner Losh 10900d1ba665SWarner Losh /** 10910d1ba665SWarner Losh Compares two Null-terminated Unicode strings, and returns the difference 10920d1ba665SWarner Losh between the first mismatched Unicode characters. 10930d1ba665SWarner Losh 10940d1ba665SWarner Losh This function compares the Null-terminated Unicode string FirstString to the 10950d1ba665SWarner Losh Null-terminated Unicode string SecondString. If FirstString is identical to 10960d1ba665SWarner Losh SecondString, then 0 is returned. Otherwise, the value returned is the first 10970d1ba665SWarner Losh mismatched Unicode character in SecondString subtracted from the first 10980d1ba665SWarner Losh mismatched Unicode character in FirstString. 10990d1ba665SWarner Losh 11000d1ba665SWarner Losh If FirstString is NULL, then ASSERT(). 11010d1ba665SWarner Losh If FirstString is not aligned on a 16-bit boundary, then ASSERT(). 11020d1ba665SWarner Losh If SecondString is NULL, then ASSERT(). 11030d1ba665SWarner Losh If SecondString is not aligned on a 16-bit boundary, then ASSERT(). 11040d1ba665SWarner Losh If PcdMaximumUnicodeStringLength is not zero, and FirstString contains more 11050d1ba665SWarner Losh than PcdMaximumUnicodeStringLength Unicode characters not including the 11060d1ba665SWarner Losh Null-terminator, then ASSERT(). 11070d1ba665SWarner Losh If PcdMaximumUnicodeStringLength is not zero, and SecondString contains more 11080d1ba665SWarner Losh than PcdMaximumUnicodeStringLength Unicode characters, not including the 11090d1ba665SWarner Losh Null-terminator, then ASSERT(). 11100d1ba665SWarner Losh 11110d1ba665SWarner Losh @param FirstString The pointer to a Null-terminated Unicode string. 11120d1ba665SWarner Losh @param SecondString The pointer to a Null-terminated Unicode string. 11130d1ba665SWarner Losh 11140d1ba665SWarner Losh @retval 0 FirstString is identical to SecondString. 11150d1ba665SWarner Losh @return others FirstString is not identical to SecondString. 11160d1ba665SWarner Losh 11170d1ba665SWarner Losh **/ 11180d1ba665SWarner Losh INTN 11190d1ba665SWarner Losh EFIAPI 11200d1ba665SWarner Losh StrCmp ( 11210d1ba665SWarner Losh IN CONST CHAR16 *FirstString, 11220d1ba665SWarner Losh IN CONST CHAR16 *SecondString 11230d1ba665SWarner Losh ); 11240d1ba665SWarner Losh 11250d1ba665SWarner Losh 11260d1ba665SWarner Losh /** 11270d1ba665SWarner Losh Compares up to a specified length the contents of two Null-terminated Unicode strings, 11280d1ba665SWarner Losh and returns the difference between the first mismatched Unicode characters. 11290d1ba665SWarner Losh 11300d1ba665SWarner Losh This function compares the Null-terminated Unicode string FirstString to the 11310d1ba665SWarner Losh Null-terminated Unicode string SecondString. At most, Length Unicode 11320d1ba665SWarner Losh characters will be compared. If Length is 0, then 0 is returned. If 11330d1ba665SWarner Losh FirstString is identical to SecondString, then 0 is returned. Otherwise, the 11340d1ba665SWarner Losh value returned is the first mismatched Unicode character in SecondString 11350d1ba665SWarner Losh subtracted from the first mismatched Unicode character in FirstString. 11360d1ba665SWarner Losh 11370d1ba665SWarner Losh If Length > 0 and FirstString is NULL, then ASSERT(). 11380d1ba665SWarner Losh If Length > 0 and FirstString is not aligned on a 16-bit boundary, then ASSERT(). 11390d1ba665SWarner Losh If Length > 0 and SecondString is NULL, then ASSERT(). 11400d1ba665SWarner Losh If Length > 0 and SecondString is not aligned on a 16-bit boundary, then ASSERT(). 11410d1ba665SWarner Losh If PcdMaximumUnicodeStringLength is not zero, and Length is greater than 11420d1ba665SWarner Losh PcdMaximumUnicodeStringLength, then ASSERT(). 11430d1ba665SWarner Losh If PcdMaximumUnicodeStringLength is not zero, and FirstString contains more than 11440d1ba665SWarner Losh PcdMaximumUnicodeStringLength Unicode characters, not including the Null-terminator, 11450d1ba665SWarner Losh then ASSERT(). 11460d1ba665SWarner Losh If PcdMaximumUnicodeStringLength is not zero, and SecondString contains more than 11470d1ba665SWarner Losh PcdMaximumUnicodeStringLength Unicode characters, not including the Null-terminator, 11480d1ba665SWarner Losh then ASSERT(). 11490d1ba665SWarner Losh 11500d1ba665SWarner Losh @param FirstString The pointer to a Null-terminated Unicode string. 11510d1ba665SWarner Losh @param SecondString The pointer to a Null-terminated Unicode string. 11520d1ba665SWarner Losh @param Length The maximum number of Unicode characters to compare. 11530d1ba665SWarner Losh 11540d1ba665SWarner Losh @retval 0 FirstString is identical to SecondString. 11550d1ba665SWarner Losh @return others FirstString is not identical to SecondString. 11560d1ba665SWarner Losh 11570d1ba665SWarner Losh **/ 11580d1ba665SWarner Losh INTN 11590d1ba665SWarner Losh EFIAPI 11600d1ba665SWarner Losh StrnCmp ( 11610d1ba665SWarner Losh IN CONST CHAR16 *FirstString, 11620d1ba665SWarner Losh IN CONST CHAR16 *SecondString, 11630d1ba665SWarner Losh IN UINTN Length 11640d1ba665SWarner Losh ); 11650d1ba665SWarner Losh 11660d1ba665SWarner Losh 11670d1ba665SWarner Losh #ifndef DISABLE_NEW_DEPRECATED_INTERFACES 11680d1ba665SWarner Losh 11690d1ba665SWarner Losh /** 11700d1ba665SWarner Losh [ATTENTION] This function is deprecated for security reason. 11710d1ba665SWarner Losh 11720d1ba665SWarner Losh Concatenates one Null-terminated Unicode string to another Null-terminated 11730d1ba665SWarner Losh Unicode string, and returns the concatenated Unicode string. 11740d1ba665SWarner Losh 11750d1ba665SWarner Losh This function concatenates two Null-terminated Unicode strings. The contents 11760d1ba665SWarner Losh of Null-terminated Unicode string Source are concatenated to the end of 11770d1ba665SWarner Losh Null-terminated Unicode string Destination. The Null-terminated concatenated 11780d1ba665SWarner Losh Unicode String is returned. If Source and Destination overlap, then the 11790d1ba665SWarner Losh results are undefined. 11800d1ba665SWarner Losh 11810d1ba665SWarner Losh If Destination is NULL, then ASSERT(). 11820d1ba665SWarner Losh If Destination is not aligned on a 16-bit boundary, then ASSERT(). 11830d1ba665SWarner Losh If Source is NULL, then ASSERT(). 11840d1ba665SWarner Losh If Source is not aligned on a 16-bit boundary, then ASSERT(). 11850d1ba665SWarner Losh If Source and Destination overlap, then ASSERT(). 11860d1ba665SWarner Losh If PcdMaximumUnicodeStringLength is not zero, and Destination contains more 11870d1ba665SWarner Losh than PcdMaximumUnicodeStringLength Unicode characters, not including the 11880d1ba665SWarner Losh Null-terminator, then ASSERT(). 11890d1ba665SWarner Losh If PcdMaximumUnicodeStringLength is not zero, and Source contains more than 11900d1ba665SWarner Losh PcdMaximumUnicodeStringLength Unicode characters, not including the 11910d1ba665SWarner Losh Null-terminator, then ASSERT(). 11920d1ba665SWarner Losh If PcdMaximumUnicodeStringLength is not zero, and concatenating Destination 11930d1ba665SWarner Losh and Source results in a Unicode string with more than 11940d1ba665SWarner Losh PcdMaximumUnicodeStringLength Unicode characters, not including the 11950d1ba665SWarner Losh Null-terminator, then ASSERT(). 11960d1ba665SWarner Losh 11970d1ba665SWarner Losh @param Destination The pointer to a Null-terminated Unicode string. 11980d1ba665SWarner Losh @param Source The pointer to a Null-terminated Unicode string. 11990d1ba665SWarner Losh 12000d1ba665SWarner Losh @return Destination. 12010d1ba665SWarner Losh 12020d1ba665SWarner Losh **/ 12030d1ba665SWarner Losh CHAR16 * 12040d1ba665SWarner Losh EFIAPI 12050d1ba665SWarner Losh StrCat ( 12060d1ba665SWarner Losh IN OUT CHAR16 *Destination, 12070d1ba665SWarner Losh IN CONST CHAR16 *Source 12080d1ba665SWarner Losh ); 12090d1ba665SWarner Losh 12100d1ba665SWarner Losh 12110d1ba665SWarner Losh /** 12120d1ba665SWarner Losh [ATTENTION] This function is deprecated for security reason. 12130d1ba665SWarner Losh 12140d1ba665SWarner Losh Concatenates up to a specified length one Null-terminated Unicode to the end 12150d1ba665SWarner Losh of another Null-terminated Unicode string, and returns the concatenated 12160d1ba665SWarner Losh Unicode string. 12170d1ba665SWarner Losh 12180d1ba665SWarner Losh This function concatenates two Null-terminated Unicode strings. The contents 12190d1ba665SWarner Losh of Null-terminated Unicode string Source are concatenated to the end of 12200d1ba665SWarner Losh Null-terminated Unicode string Destination, and Destination is returned. At 12210d1ba665SWarner Losh most, Length Unicode characters are concatenated from Source to the end of 12220d1ba665SWarner Losh Destination, and Destination is always Null-terminated. If Length is 0, then 12230d1ba665SWarner Losh Destination is returned unmodified. If Source and Destination overlap, then 12240d1ba665SWarner Losh the results are undefined. 12250d1ba665SWarner Losh 12260d1ba665SWarner Losh If Destination is NULL, then ASSERT(). 12270d1ba665SWarner Losh If Length > 0 and Destination is not aligned on a 16-bit boundary, then ASSERT(). 12280d1ba665SWarner Losh If Length > 0 and Source is NULL, then ASSERT(). 12290d1ba665SWarner Losh If Length > 0 and Source is not aligned on a 16-bit boundary, then ASSERT(). 12300d1ba665SWarner Losh If Source and Destination overlap, then ASSERT(). 12310d1ba665SWarner Losh If PcdMaximumUnicodeStringLength is not zero, and Length is greater than 12320d1ba665SWarner Losh PcdMaximumUnicodeStringLength, then ASSERT(). 12330d1ba665SWarner Losh If PcdMaximumUnicodeStringLength is not zero, and Destination contains more 12340d1ba665SWarner Losh than PcdMaximumUnicodeStringLength Unicode characters, not including the 12350d1ba665SWarner Losh Null-terminator, then ASSERT(). 12360d1ba665SWarner Losh If PcdMaximumUnicodeStringLength is not zero, and Source contains more than 12370d1ba665SWarner Losh PcdMaximumUnicodeStringLength Unicode characters, not including the 12380d1ba665SWarner Losh Null-terminator, then ASSERT(). 12390d1ba665SWarner Losh If PcdMaximumUnicodeStringLength is not zero, and concatenating Destination 12400d1ba665SWarner Losh and Source results in a Unicode string with more than PcdMaximumUnicodeStringLength 12410d1ba665SWarner Losh Unicode characters, not including the Null-terminator, then ASSERT(). 12420d1ba665SWarner Losh 12430d1ba665SWarner Losh @param Destination The pointer to a Null-terminated Unicode string. 12440d1ba665SWarner Losh @param Source The pointer to a Null-terminated Unicode string. 12450d1ba665SWarner Losh @param Length The maximum number of Unicode characters to concatenate from 12460d1ba665SWarner Losh Source. 12470d1ba665SWarner Losh 12480d1ba665SWarner Losh @return Destination. 12490d1ba665SWarner Losh 12500d1ba665SWarner Losh **/ 12510d1ba665SWarner Losh CHAR16 * 12520d1ba665SWarner Losh EFIAPI 12530d1ba665SWarner Losh StrnCat ( 12540d1ba665SWarner Losh IN OUT CHAR16 *Destination, 12550d1ba665SWarner Losh IN CONST CHAR16 *Source, 12560d1ba665SWarner Losh IN UINTN Length 12570d1ba665SWarner Losh ); 1258*3245fa21SMitchell Horne #endif // !defined (DISABLE_NEW_DEPRECATED_INTERFACES) 12590d1ba665SWarner Losh 12600d1ba665SWarner Losh /** 12610d1ba665SWarner Losh Returns the first occurrence of a Null-terminated Unicode sub-string 12620d1ba665SWarner Losh in a Null-terminated Unicode string. 12630d1ba665SWarner Losh 12640d1ba665SWarner Losh This function scans the contents of the Null-terminated Unicode string 12650d1ba665SWarner Losh specified by String and returns the first occurrence of SearchString. 12660d1ba665SWarner Losh If SearchString is not found in String, then NULL is returned. If 12670d1ba665SWarner Losh the length of SearchString is zero, then String is returned. 12680d1ba665SWarner Losh 12690d1ba665SWarner Losh If String is NULL, then ASSERT(). 12700d1ba665SWarner Losh If String is not aligned on a 16-bit boundary, then ASSERT(). 12710d1ba665SWarner Losh If SearchString is NULL, then ASSERT(). 12720d1ba665SWarner Losh If SearchString is not aligned on a 16-bit boundary, then ASSERT(). 12730d1ba665SWarner Losh 12740d1ba665SWarner Losh If PcdMaximumUnicodeStringLength is not zero, and SearchString 12750d1ba665SWarner Losh or String contains more than PcdMaximumUnicodeStringLength Unicode 12760d1ba665SWarner Losh characters, not including the Null-terminator, then ASSERT(). 12770d1ba665SWarner Losh 12780d1ba665SWarner Losh @param String The pointer to a Null-terminated Unicode string. 12790d1ba665SWarner Losh @param SearchString The pointer to a Null-terminated Unicode string to search for. 12800d1ba665SWarner Losh 12810d1ba665SWarner Losh @retval NULL If the SearchString does not appear in String. 12820d1ba665SWarner Losh @return others If there is a match. 12830d1ba665SWarner Losh 12840d1ba665SWarner Losh **/ 12850d1ba665SWarner Losh CHAR16 * 12860d1ba665SWarner Losh EFIAPI 12870d1ba665SWarner Losh StrStr ( 12880d1ba665SWarner Losh IN CONST CHAR16 *String, 12890d1ba665SWarner Losh IN CONST CHAR16 *SearchString 12900d1ba665SWarner Losh ); 12910d1ba665SWarner Losh 12920d1ba665SWarner Losh /** 12930d1ba665SWarner Losh Convert a Null-terminated Unicode decimal string to a value of 12940d1ba665SWarner Losh type UINTN. 12950d1ba665SWarner Losh 12960d1ba665SWarner Losh This function returns a value of type UINTN by interpreting the contents 12970d1ba665SWarner Losh of the Unicode string specified by String as a decimal number. The format 12980d1ba665SWarner Losh of the input Unicode string String is: 12990d1ba665SWarner Losh 13000d1ba665SWarner Losh [spaces] [decimal digits]. 13010d1ba665SWarner Losh 13020d1ba665SWarner Losh The valid decimal digit character is in the range [0-9]. The 13030d1ba665SWarner Losh function will ignore the pad space, which includes spaces or 13040d1ba665SWarner Losh tab characters, before [decimal digits]. The running zero in the 13050d1ba665SWarner Losh beginning of [decimal digits] will be ignored. Then, the function 13060d1ba665SWarner Losh stops at the first character that is a not a valid decimal character 13070d1ba665SWarner Losh or a Null-terminator, whichever one comes first. 13080d1ba665SWarner Losh 13090d1ba665SWarner Losh If String is NULL, then ASSERT(). 13100d1ba665SWarner Losh If String is not aligned in a 16-bit boundary, then ASSERT(). 13110d1ba665SWarner Losh If String has only pad spaces, then 0 is returned. 13120d1ba665SWarner Losh If String has no pad spaces or valid decimal digits, 13130d1ba665SWarner Losh then 0 is returned. 13140d1ba665SWarner Losh If the number represented by String overflows according 13150d1ba665SWarner Losh to the range defined by UINTN, then MAX_UINTN is returned. 13160d1ba665SWarner Losh 13170d1ba665SWarner Losh If PcdMaximumUnicodeStringLength is not zero, and String contains 13180d1ba665SWarner Losh more than PcdMaximumUnicodeStringLength Unicode characters not including 13190d1ba665SWarner Losh the Null-terminator, then ASSERT(). 13200d1ba665SWarner Losh 13210d1ba665SWarner Losh @param String The pointer to a Null-terminated Unicode string. 13220d1ba665SWarner Losh 13230d1ba665SWarner Losh @retval Value translated from String. 13240d1ba665SWarner Losh 13250d1ba665SWarner Losh **/ 13260d1ba665SWarner Losh UINTN 13270d1ba665SWarner Losh EFIAPI 13280d1ba665SWarner Losh StrDecimalToUintn ( 13290d1ba665SWarner Losh IN CONST CHAR16 *String 13300d1ba665SWarner Losh ); 13310d1ba665SWarner Losh 13320d1ba665SWarner Losh /** 13330d1ba665SWarner Losh Convert a Null-terminated Unicode decimal string to a value of 13340d1ba665SWarner Losh type UINT64. 13350d1ba665SWarner Losh 13360d1ba665SWarner Losh This function returns a value of type UINT64 by interpreting the contents 13370d1ba665SWarner Losh of the Unicode string specified by String as a decimal number. The format 13380d1ba665SWarner Losh of the input Unicode string String is: 13390d1ba665SWarner Losh 13400d1ba665SWarner Losh [spaces] [decimal digits]. 13410d1ba665SWarner Losh 13420d1ba665SWarner Losh The valid decimal digit character is in the range [0-9]. The 13430d1ba665SWarner Losh function will ignore the pad space, which includes spaces or 13440d1ba665SWarner Losh tab characters, before [decimal digits]. The running zero in the 13450d1ba665SWarner Losh beginning of [decimal digits] will be ignored. Then, the function 13460d1ba665SWarner Losh stops at the first character that is a not a valid decimal character 13470d1ba665SWarner Losh or a Null-terminator, whichever one comes first. 13480d1ba665SWarner Losh 13490d1ba665SWarner Losh If String is NULL, then ASSERT(). 13500d1ba665SWarner Losh If String is not aligned in a 16-bit boundary, then ASSERT(). 13510d1ba665SWarner Losh If String has only pad spaces, then 0 is returned. 13520d1ba665SWarner Losh If String has no pad spaces or valid decimal digits, 13530d1ba665SWarner Losh then 0 is returned. 13540d1ba665SWarner Losh If the number represented by String overflows according 13550d1ba665SWarner Losh to the range defined by UINT64, then MAX_UINT64 is returned. 13560d1ba665SWarner Losh 13570d1ba665SWarner Losh If PcdMaximumUnicodeStringLength is not zero, and String contains 13580d1ba665SWarner Losh more than PcdMaximumUnicodeStringLength Unicode characters not including 13590d1ba665SWarner Losh the Null-terminator, then ASSERT(). 13600d1ba665SWarner Losh 13610d1ba665SWarner Losh @param String The pointer to a Null-terminated Unicode string. 13620d1ba665SWarner Losh 13630d1ba665SWarner Losh @retval Value translated from String. 13640d1ba665SWarner Losh 13650d1ba665SWarner Losh **/ 13660d1ba665SWarner Losh UINT64 13670d1ba665SWarner Losh EFIAPI 13680d1ba665SWarner Losh StrDecimalToUint64 ( 13690d1ba665SWarner Losh IN CONST CHAR16 *String 13700d1ba665SWarner Losh ); 13710d1ba665SWarner Losh 13720d1ba665SWarner Losh 13730d1ba665SWarner Losh /** 13740d1ba665SWarner Losh Convert a Null-terminated Unicode hexadecimal string to a value of type UINTN. 13750d1ba665SWarner Losh 13760d1ba665SWarner Losh This function returns a value of type UINTN by interpreting the contents 13770d1ba665SWarner Losh of the Unicode string specified by String as a hexadecimal number. 13780d1ba665SWarner Losh The format of the input Unicode string String is: 13790d1ba665SWarner Losh 13800d1ba665SWarner Losh [spaces][zeros][x][hexadecimal digits]. 13810d1ba665SWarner Losh 13820d1ba665SWarner Losh The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F]. 13830d1ba665SWarner Losh The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix. 13840d1ba665SWarner Losh If "x" appears in the input string, it must be prefixed with at least one 0. 13850d1ba665SWarner Losh The function will ignore the pad space, which includes spaces or tab characters, 13860d1ba665SWarner Losh before [zeros], [x] or [hexadecimal digit]. The running zero before [x] or 13870d1ba665SWarner Losh [hexadecimal digit] will be ignored. Then, the decoding starts after [x] or the 13880d1ba665SWarner Losh first valid hexadecimal digit. Then, the function stops at the first character 13890d1ba665SWarner Losh that is a not a valid hexadecimal character or NULL, whichever one comes first. 13900d1ba665SWarner Losh 13910d1ba665SWarner Losh If String is NULL, then ASSERT(). 13920d1ba665SWarner Losh If String is not aligned in a 16-bit boundary, then ASSERT(). 13930d1ba665SWarner Losh If String has only pad spaces, then zero is returned. 13940d1ba665SWarner Losh If String has no leading pad spaces, leading zeros or valid hexadecimal digits, 13950d1ba665SWarner Losh then zero is returned. 13960d1ba665SWarner Losh If the number represented by String overflows according to the range defined by 13970d1ba665SWarner Losh UINTN, then MAX_UINTN is returned. 13980d1ba665SWarner Losh 13990d1ba665SWarner Losh If PcdMaximumUnicodeStringLength is not zero, and String contains more than 14000d1ba665SWarner Losh PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, 14010d1ba665SWarner Losh then ASSERT(). 14020d1ba665SWarner Losh 14030d1ba665SWarner Losh @param String The pointer to a Null-terminated Unicode string. 14040d1ba665SWarner Losh 14050d1ba665SWarner Losh @retval Value translated from String. 14060d1ba665SWarner Losh 14070d1ba665SWarner Losh **/ 14080d1ba665SWarner Losh UINTN 14090d1ba665SWarner Losh EFIAPI 14100d1ba665SWarner Losh StrHexToUintn ( 14110d1ba665SWarner Losh IN CONST CHAR16 *String 14120d1ba665SWarner Losh ); 14130d1ba665SWarner Losh 14140d1ba665SWarner Losh 14150d1ba665SWarner Losh /** 14160d1ba665SWarner Losh Convert a Null-terminated Unicode hexadecimal string to a value of type UINT64. 14170d1ba665SWarner Losh 14180d1ba665SWarner Losh This function returns a value of type UINT64 by interpreting the contents 14190d1ba665SWarner Losh of the Unicode string specified by String as a hexadecimal number. 14200d1ba665SWarner Losh The format of the input Unicode string String is 14210d1ba665SWarner Losh 14220d1ba665SWarner Losh [spaces][zeros][x][hexadecimal digits]. 14230d1ba665SWarner Losh 14240d1ba665SWarner Losh The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F]. 14250d1ba665SWarner Losh The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix. 14260d1ba665SWarner Losh If "x" appears in the input string, it must be prefixed with at least one 0. 14270d1ba665SWarner Losh The function will ignore the pad space, which includes spaces or tab characters, 14280d1ba665SWarner Losh before [zeros], [x] or [hexadecimal digit]. The running zero before [x] or 14290d1ba665SWarner Losh [hexadecimal digit] will be ignored. Then, the decoding starts after [x] or the 14300d1ba665SWarner Losh first valid hexadecimal digit. Then, the function stops at the first character that is 14310d1ba665SWarner Losh a not a valid hexadecimal character or NULL, whichever one comes first. 14320d1ba665SWarner Losh 14330d1ba665SWarner Losh If String is NULL, then ASSERT(). 14340d1ba665SWarner Losh If String is not aligned in a 16-bit boundary, then ASSERT(). 14350d1ba665SWarner Losh If String has only pad spaces, then zero is returned. 14360d1ba665SWarner Losh If String has no leading pad spaces, leading zeros or valid hexadecimal digits, 14370d1ba665SWarner Losh then zero is returned. 14380d1ba665SWarner Losh If the number represented by String overflows according to the range defined by 14390d1ba665SWarner Losh UINT64, then MAX_UINT64 is returned. 14400d1ba665SWarner Losh 14410d1ba665SWarner Losh If PcdMaximumUnicodeStringLength is not zero, and String contains more than 14420d1ba665SWarner Losh PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, 14430d1ba665SWarner Losh then ASSERT(). 14440d1ba665SWarner Losh 14450d1ba665SWarner Losh @param String The pointer to a Null-terminated Unicode string. 14460d1ba665SWarner Losh 14470d1ba665SWarner Losh @retval Value translated from String. 14480d1ba665SWarner Losh 14490d1ba665SWarner Losh **/ 14500d1ba665SWarner Losh UINT64 14510d1ba665SWarner Losh EFIAPI 14520d1ba665SWarner Losh StrHexToUint64 ( 14530d1ba665SWarner Losh IN CONST CHAR16 *String 14540d1ba665SWarner Losh ); 14550d1ba665SWarner Losh 14560d1ba665SWarner Losh /** 14570d1ba665SWarner Losh Convert a Null-terminated Unicode string to IPv6 address and prefix length. 14580d1ba665SWarner Losh 14590d1ba665SWarner Losh This function outputs a value of type IPv6_ADDRESS and may output a value 14600d1ba665SWarner Losh of type UINT8 by interpreting the contents of the Unicode string specified 14610d1ba665SWarner Losh by String. The format of the input Unicode string String is as follows: 14620d1ba665SWarner Losh 14630d1ba665SWarner Losh X:X:X:X:X:X:X:X[/P] 14640d1ba665SWarner Losh 14650d1ba665SWarner Losh X contains one to four hexadecimal digit characters in the range [0-9], [a-f] and 14660d1ba665SWarner Losh [A-F]. X is converted to a value of type UINT16, whose low byte is stored in low 14670d1ba665SWarner Losh memory address and high byte is stored in high memory address. P contains decimal 14680d1ba665SWarner Losh digit characters in the range [0-9]. The running zero in the beginning of P will 14690d1ba665SWarner Losh be ignored. /P is optional. 14700d1ba665SWarner Losh 14710d1ba665SWarner Losh When /P is not in the String, the function stops at the first character that is 14720d1ba665SWarner Losh not a valid hexadecimal digit character after eight X's are converted. 14730d1ba665SWarner Losh 14740d1ba665SWarner Losh When /P is in the String, the function stops at the first character that is not 14750d1ba665SWarner Losh a valid decimal digit character after P is converted. 14760d1ba665SWarner Losh 14770d1ba665SWarner Losh "::" can be used to compress one or more groups of X when X contains only 0. 14780d1ba665SWarner Losh The "::" can only appear once in the String. 14790d1ba665SWarner Losh 14800d1ba665SWarner Losh If String is not aligned in a 16-bit boundary, then ASSERT(). 14810d1ba665SWarner Losh 14820d1ba665SWarner Losh If EndPointer is not NULL and Address is translated from String, a pointer 14830d1ba665SWarner Losh to the character that stopped the scan is stored at the location pointed to 14840d1ba665SWarner Losh by EndPointer. 14850d1ba665SWarner Losh 14860d1ba665SWarner Losh @param String Pointer to a Null-terminated Unicode string. 14870d1ba665SWarner Losh @param EndPointer Pointer to character that stops scan. 14880d1ba665SWarner Losh @param Address Pointer to the converted IPv6 address. 14890d1ba665SWarner Losh @param PrefixLength Pointer to the converted IPv6 address prefix 14900d1ba665SWarner Losh length. MAX_UINT8 is returned when /P is 14910d1ba665SWarner Losh not in the String. 14920d1ba665SWarner Losh 14930d1ba665SWarner Losh @retval RETURN_SUCCESS Address is translated from String. 14940d1ba665SWarner Losh @retval RETURN_INVALID_PARAMETER If String is NULL. 14950d1ba665SWarner Losh If Data is NULL. 14960d1ba665SWarner Losh @retval RETURN_UNSUPPORTED If X contains more than four hexadecimal 14970d1ba665SWarner Losh digit characters. 14980d1ba665SWarner Losh If String contains "::" and number of X 14990d1ba665SWarner Losh is not less than 8. 15000d1ba665SWarner Losh If P starts with character that is not a 15010d1ba665SWarner Losh valid decimal digit character. 15020d1ba665SWarner Losh If the decimal number converted from P 15030d1ba665SWarner Losh exceeds 128. 15040d1ba665SWarner Losh 15050d1ba665SWarner Losh **/ 15060d1ba665SWarner Losh RETURN_STATUS 15070d1ba665SWarner Losh EFIAPI 15080d1ba665SWarner Losh StrToIpv6Address ( 15090d1ba665SWarner Losh IN CONST CHAR16 *String, 15100d1ba665SWarner Losh OUT CHAR16 **EndPointer, OPTIONAL 15110d1ba665SWarner Losh OUT IPv6_ADDRESS *Address, 15120d1ba665SWarner Losh OUT UINT8 *PrefixLength OPTIONAL 15130d1ba665SWarner Losh ); 15140d1ba665SWarner Losh 15150d1ba665SWarner Losh /** 15160d1ba665SWarner Losh Convert a Null-terminated Unicode string to IPv4 address and prefix length. 15170d1ba665SWarner Losh 15180d1ba665SWarner Losh This function outputs a value of type IPv4_ADDRESS and may output a value 15190d1ba665SWarner Losh of type UINT8 by interpreting the contents of the Unicode string specified 15200d1ba665SWarner Losh by String. The format of the input Unicode string String is as follows: 15210d1ba665SWarner Losh 15220d1ba665SWarner Losh D.D.D.D[/P] 15230d1ba665SWarner Losh 15240d1ba665SWarner Losh D and P are decimal digit characters in the range [0-9]. The running zero in 15250d1ba665SWarner Losh the beginning of D and P will be ignored. /P is optional. 15260d1ba665SWarner Losh 15270d1ba665SWarner Losh When /P is not in the String, the function stops at the first character that is 15280d1ba665SWarner Losh not a valid decimal digit character after four D's are converted. 15290d1ba665SWarner Losh 15300d1ba665SWarner Losh When /P is in the String, the function stops at the first character that is not 15310d1ba665SWarner Losh a valid decimal digit character after P is converted. 15320d1ba665SWarner Losh 15330d1ba665SWarner Losh If String is not aligned in a 16-bit boundary, then ASSERT(). 15340d1ba665SWarner Losh 15350d1ba665SWarner Losh If EndPointer is not NULL and Address is translated from String, a pointer 15360d1ba665SWarner Losh to the character that stopped the scan is stored at the location pointed to 15370d1ba665SWarner Losh by EndPointer. 15380d1ba665SWarner Losh 15390d1ba665SWarner Losh @param String Pointer to a Null-terminated Unicode string. 15400d1ba665SWarner Losh @param EndPointer Pointer to character that stops scan. 15410d1ba665SWarner Losh @param Address Pointer to the converted IPv4 address. 15420d1ba665SWarner Losh @param PrefixLength Pointer to the converted IPv4 address prefix 15430d1ba665SWarner Losh length. MAX_UINT8 is returned when /P is 15440d1ba665SWarner Losh not in the String. 15450d1ba665SWarner Losh 15460d1ba665SWarner Losh @retval RETURN_SUCCESS Address is translated from String. 15470d1ba665SWarner Losh @retval RETURN_INVALID_PARAMETER If String is NULL. 15480d1ba665SWarner Losh If Data is NULL. 15490d1ba665SWarner Losh @retval RETURN_UNSUPPORTED If String is not in the correct format. 15500d1ba665SWarner Losh If any decimal number converted from D 15510d1ba665SWarner Losh exceeds 255. 15520d1ba665SWarner Losh If the decimal number converted from P 15530d1ba665SWarner Losh exceeds 32. 15540d1ba665SWarner Losh 15550d1ba665SWarner Losh **/ 15560d1ba665SWarner Losh RETURN_STATUS 15570d1ba665SWarner Losh EFIAPI 15580d1ba665SWarner Losh StrToIpv4Address ( 15590d1ba665SWarner Losh IN CONST CHAR16 *String, 15600d1ba665SWarner Losh OUT CHAR16 **EndPointer, OPTIONAL 15610d1ba665SWarner Losh OUT IPv4_ADDRESS *Address, 15620d1ba665SWarner Losh OUT UINT8 *PrefixLength OPTIONAL 15630d1ba665SWarner Losh ); 15640d1ba665SWarner Losh 15650d1ba665SWarner Losh #define GUID_STRING_LENGTH 36 15660d1ba665SWarner Losh 15670d1ba665SWarner Losh /** 15680d1ba665SWarner Losh Convert a Null-terminated Unicode GUID string to a value of type 15690d1ba665SWarner Losh EFI_GUID. 15700d1ba665SWarner Losh 15710d1ba665SWarner Losh This function outputs a GUID value by interpreting the contents of 15720d1ba665SWarner Losh the Unicode string specified by String. The format of the input 15730d1ba665SWarner Losh Unicode string String consists of 36 characters, as follows: 15740d1ba665SWarner Losh 15750d1ba665SWarner Losh aabbccdd-eeff-gghh-iijj-kkllmmnnoopp 15760d1ba665SWarner Losh 15770d1ba665SWarner Losh The pairs aa - pp are two characters in the range [0-9], [a-f] and 15780d1ba665SWarner Losh [A-F], with each pair representing a single byte hexadecimal value. 15790d1ba665SWarner Losh 15800d1ba665SWarner Losh The mapping between String and the EFI_GUID structure is as follows: 15810d1ba665SWarner Losh aa Data1[24:31] 15820d1ba665SWarner Losh bb Data1[16:23] 15830d1ba665SWarner Losh cc Data1[8:15] 15840d1ba665SWarner Losh dd Data1[0:7] 15850d1ba665SWarner Losh ee Data2[8:15] 15860d1ba665SWarner Losh ff Data2[0:7] 15870d1ba665SWarner Losh gg Data3[8:15] 15880d1ba665SWarner Losh hh Data3[0:7] 15890d1ba665SWarner Losh ii Data4[0:7] 15900d1ba665SWarner Losh jj Data4[8:15] 15910d1ba665SWarner Losh kk Data4[16:23] 15920d1ba665SWarner Losh ll Data4[24:31] 15930d1ba665SWarner Losh mm Data4[32:39] 15940d1ba665SWarner Losh nn Data4[40:47] 15950d1ba665SWarner Losh oo Data4[48:55] 15960d1ba665SWarner Losh pp Data4[56:63] 15970d1ba665SWarner Losh 15980d1ba665SWarner Losh If String is not aligned in a 16-bit boundary, then ASSERT(). 15990d1ba665SWarner Losh 16000d1ba665SWarner Losh @param String Pointer to a Null-terminated Unicode string. 16010d1ba665SWarner Losh @param Guid Pointer to the converted GUID. 16020d1ba665SWarner Losh 16030d1ba665SWarner Losh @retval RETURN_SUCCESS Guid is translated from String. 16040d1ba665SWarner Losh @retval RETURN_INVALID_PARAMETER If String is NULL. 16050d1ba665SWarner Losh If Data is NULL. 16060d1ba665SWarner Losh @retval RETURN_UNSUPPORTED If String is not as the above format. 16070d1ba665SWarner Losh 16080d1ba665SWarner Losh **/ 16090d1ba665SWarner Losh RETURN_STATUS 16100d1ba665SWarner Losh EFIAPI 16110d1ba665SWarner Losh StrToGuid ( 16120d1ba665SWarner Losh IN CONST CHAR16 *String, 16130d1ba665SWarner Losh OUT GUID *Guid 16140d1ba665SWarner Losh ); 16150d1ba665SWarner Losh 16160d1ba665SWarner Losh /** 16170d1ba665SWarner Losh Convert a Null-terminated Unicode hexadecimal string to a byte array. 16180d1ba665SWarner Losh 16190d1ba665SWarner Losh This function outputs a byte array by interpreting the contents of 16200d1ba665SWarner Losh the Unicode string specified by String in hexadecimal format. The format of 16210d1ba665SWarner Losh the input Unicode string String is: 16220d1ba665SWarner Losh 16230d1ba665SWarner Losh [XX]* 16240d1ba665SWarner Losh 16250d1ba665SWarner Losh X is a hexadecimal digit character in the range [0-9], [a-f] and [A-F]. 16260d1ba665SWarner Losh The function decodes every two hexadecimal digit characters as one byte. The 16270d1ba665SWarner Losh decoding stops after Length of characters and outputs Buffer containing 16280d1ba665SWarner Losh (Length / 2) bytes. 16290d1ba665SWarner Losh 16300d1ba665SWarner Losh If String is not aligned in a 16-bit boundary, then ASSERT(). 16310d1ba665SWarner Losh 16320d1ba665SWarner Losh @param String Pointer to a Null-terminated Unicode string. 16330d1ba665SWarner Losh @param Length The number of Unicode characters to decode. 16340d1ba665SWarner Losh @param Buffer Pointer to the converted bytes array. 16350d1ba665SWarner Losh @param MaxBufferSize The maximum size of Buffer. 16360d1ba665SWarner Losh 16370d1ba665SWarner Losh @retval RETURN_SUCCESS Buffer is translated from String. 16380d1ba665SWarner Losh @retval RETURN_INVALID_PARAMETER If String is NULL. 16390d1ba665SWarner Losh If Data is NULL. 16400d1ba665SWarner Losh If Length is not multiple of 2. 16410d1ba665SWarner Losh If PcdMaximumUnicodeStringLength is not zero, 16420d1ba665SWarner Losh and Length is greater than 16430d1ba665SWarner Losh PcdMaximumUnicodeStringLength. 16440d1ba665SWarner Losh @retval RETURN_UNSUPPORTED If Length of characters from String contain 16450d1ba665SWarner Losh a character that is not valid hexadecimal 16460d1ba665SWarner Losh digit characters, or a Null-terminator. 16470d1ba665SWarner Losh @retval RETURN_BUFFER_TOO_SMALL If MaxBufferSize is less than (Length / 2). 16480d1ba665SWarner Losh **/ 16490d1ba665SWarner Losh RETURN_STATUS 16500d1ba665SWarner Losh EFIAPI 16510d1ba665SWarner Losh StrHexToBytes ( 16520d1ba665SWarner Losh IN CONST CHAR16 *String, 16530d1ba665SWarner Losh IN UINTN Length, 16540d1ba665SWarner Losh OUT UINT8 *Buffer, 16550d1ba665SWarner Losh IN UINTN MaxBufferSize 16560d1ba665SWarner Losh ); 16570d1ba665SWarner Losh 16580d1ba665SWarner Losh #ifndef DISABLE_NEW_DEPRECATED_INTERFACES 16590d1ba665SWarner Losh 16600d1ba665SWarner Losh /** 16610d1ba665SWarner Losh [ATTENTION] This function is deprecated for security reason. 16620d1ba665SWarner Losh 16630d1ba665SWarner Losh Convert a Null-terminated Unicode string to a Null-terminated 16640d1ba665SWarner Losh ASCII string and returns the ASCII string. 16650d1ba665SWarner Losh 16660d1ba665SWarner Losh This function converts the content of the Unicode string Source 16670d1ba665SWarner Losh to the ASCII string Destination by copying the lower 8 bits of 16680d1ba665SWarner Losh each Unicode character. It returns Destination. 16690d1ba665SWarner Losh 16700d1ba665SWarner Losh The caller is responsible to make sure Destination points to a buffer with size 16710d1ba665SWarner Losh equal or greater than ((StrLen (Source) + 1) * sizeof (CHAR8)) in bytes. 16720d1ba665SWarner Losh 16730d1ba665SWarner Losh If any Unicode characters in Source contain non-zero value in 16740d1ba665SWarner Losh the upper 8 bits, then ASSERT(). 16750d1ba665SWarner Losh 16760d1ba665SWarner Losh If Destination is NULL, then ASSERT(). 16770d1ba665SWarner Losh If Source is NULL, then ASSERT(). 16780d1ba665SWarner Losh If Source is not aligned on a 16-bit boundary, then ASSERT(). 16790d1ba665SWarner Losh If Source and Destination overlap, then ASSERT(). 16800d1ba665SWarner Losh 16810d1ba665SWarner Losh If PcdMaximumUnicodeStringLength is not zero, and Source contains 16820d1ba665SWarner Losh more than PcdMaximumUnicodeStringLength Unicode characters not including 16830d1ba665SWarner Losh the Null-terminator, then ASSERT(). 16840d1ba665SWarner Losh 16850d1ba665SWarner Losh If PcdMaximumAsciiStringLength is not zero, and Source contains more 16860d1ba665SWarner Losh than PcdMaximumAsciiStringLength Unicode characters not including the 16870d1ba665SWarner Losh Null-terminator, then ASSERT(). 16880d1ba665SWarner Losh 16890d1ba665SWarner Losh @param Source The pointer to a Null-terminated Unicode string. 16900d1ba665SWarner Losh @param Destination The pointer to a Null-terminated ASCII string. 16910d1ba665SWarner Losh 16920d1ba665SWarner Losh @return Destination. 16930d1ba665SWarner Losh 16940d1ba665SWarner Losh **/ 16950d1ba665SWarner Losh CHAR8 * 16960d1ba665SWarner Losh EFIAPI 16970d1ba665SWarner Losh UnicodeStrToAsciiStr ( 16980d1ba665SWarner Losh IN CONST CHAR16 *Source, 16990d1ba665SWarner Losh OUT CHAR8 *Destination 17000d1ba665SWarner Losh ); 17010d1ba665SWarner Losh 1702*3245fa21SMitchell Horne #endif // !defined (DISABLE_NEW_DEPRECATED_INTERFACES) 17030d1ba665SWarner Losh 17040d1ba665SWarner Losh /** 17050d1ba665SWarner Losh Convert a Null-terminated Unicode string to a Null-terminated 17060d1ba665SWarner Losh ASCII string. 17070d1ba665SWarner Losh 17080d1ba665SWarner Losh This function is similar to AsciiStrCpyS. 17090d1ba665SWarner Losh 17100d1ba665SWarner Losh This function converts the content of the Unicode string Source 17110d1ba665SWarner Losh to the ASCII string Destination by copying the lower 8 bits of 17120d1ba665SWarner Losh each Unicode character. The function terminates the ASCII string 17130d1ba665SWarner Losh Destination by appending a Null-terminator character at the end. 17140d1ba665SWarner Losh 17150d1ba665SWarner Losh The caller is responsible to make sure Destination points to a buffer with size 17160d1ba665SWarner Losh equal or greater than ((StrLen (Source) + 1) * sizeof (CHAR8)) in bytes. 17170d1ba665SWarner Losh 17180d1ba665SWarner Losh If any Unicode characters in Source contain non-zero value in 17190d1ba665SWarner Losh the upper 8 bits, then ASSERT(). 17200d1ba665SWarner Losh 17210d1ba665SWarner Losh If Source is not aligned on a 16-bit boundary, then ASSERT(). 17220d1ba665SWarner Losh 17230d1ba665SWarner Losh If an error is returned, then the Destination is unmodified. 17240d1ba665SWarner Losh 17250d1ba665SWarner Losh @param Source The pointer to a Null-terminated Unicode string. 17260d1ba665SWarner Losh @param Destination The pointer to a Null-terminated ASCII string. 17270d1ba665SWarner Losh @param DestMax The maximum number of Destination Ascii 17280d1ba665SWarner Losh char, including terminating null char. 17290d1ba665SWarner Losh 17300d1ba665SWarner Losh @retval RETURN_SUCCESS String is converted. 17310d1ba665SWarner Losh @retval RETURN_BUFFER_TOO_SMALL If DestMax is NOT greater than StrLen(Source). 17320d1ba665SWarner Losh @retval RETURN_INVALID_PARAMETER If Destination is NULL. 17330d1ba665SWarner Losh If Source is NULL. 17340d1ba665SWarner Losh If PcdMaximumAsciiStringLength is not zero, 17350d1ba665SWarner Losh and DestMax is greater than 17360d1ba665SWarner Losh PcdMaximumAsciiStringLength. 17370d1ba665SWarner Losh If PcdMaximumUnicodeStringLength is not zero, 17380d1ba665SWarner Losh and DestMax is greater than 17390d1ba665SWarner Losh PcdMaximumUnicodeStringLength. 17400d1ba665SWarner Losh If DestMax is 0. 17410d1ba665SWarner Losh @retval RETURN_ACCESS_DENIED If Source and Destination overlap. 17420d1ba665SWarner Losh 17430d1ba665SWarner Losh **/ 17440d1ba665SWarner Losh RETURN_STATUS 17450d1ba665SWarner Losh EFIAPI 17460d1ba665SWarner Losh UnicodeStrToAsciiStrS ( 17470d1ba665SWarner Losh IN CONST CHAR16 *Source, 17480d1ba665SWarner Losh OUT CHAR8 *Destination, 17490d1ba665SWarner Losh IN UINTN DestMax 17500d1ba665SWarner Losh ); 17510d1ba665SWarner Losh 17520d1ba665SWarner Losh /** 17530d1ba665SWarner Losh Convert not more than Length successive characters from a Null-terminated 17540d1ba665SWarner Losh Unicode string to a Null-terminated Ascii string. If no null char is copied 17550d1ba665SWarner Losh from Source, then Destination[Length] is always set to null. 17560d1ba665SWarner Losh 17570d1ba665SWarner Losh This function converts not more than Length successive characters from the 17580d1ba665SWarner Losh Unicode string Source to the Ascii string Destination by copying the lower 8 17590d1ba665SWarner Losh bits of each Unicode character. The function terminates the Ascii string 17600d1ba665SWarner Losh Destination by appending a Null-terminator character at the end. 17610d1ba665SWarner Losh 17620d1ba665SWarner Losh The caller is responsible to make sure Destination points to a buffer with size 17630d1ba665SWarner Losh equal or greater than ((StrLen (Source) + 1) * sizeof (CHAR8)) in bytes. 17640d1ba665SWarner Losh 17650d1ba665SWarner Losh If any Unicode characters in Source contain non-zero value in the upper 8 17660d1ba665SWarner Losh bits, then ASSERT(). 17670d1ba665SWarner Losh If Source is not aligned on a 16-bit boundary, then ASSERT(). 17680d1ba665SWarner Losh 17690d1ba665SWarner Losh If an error is returned, then the Destination is unmodified. 17700d1ba665SWarner Losh 17710d1ba665SWarner Losh @param Source The pointer to a Null-terminated Unicode string. 17720d1ba665SWarner Losh @param Length The maximum number of Unicode characters to 17730d1ba665SWarner Losh convert. 17740d1ba665SWarner Losh @param Destination The pointer to a Null-terminated Ascii string. 17750d1ba665SWarner Losh @param DestMax The maximum number of Destination Ascii 17760d1ba665SWarner Losh char, including terminating null char. 17770d1ba665SWarner Losh @param DestinationLength The number of Unicode characters converted. 17780d1ba665SWarner Losh 17790d1ba665SWarner Losh @retval RETURN_SUCCESS String is converted. 17800d1ba665SWarner Losh @retval RETURN_INVALID_PARAMETER If Destination is NULL. 17810d1ba665SWarner Losh If Source is NULL. 17820d1ba665SWarner Losh If DestinationLength is NULL. 17830d1ba665SWarner Losh If PcdMaximumAsciiStringLength is not zero, 17840d1ba665SWarner Losh and Length or DestMax is greater than 17850d1ba665SWarner Losh PcdMaximumAsciiStringLength. 17860d1ba665SWarner Losh If PcdMaximumUnicodeStringLength is not 17870d1ba665SWarner Losh zero, and Length or DestMax is greater than 17880d1ba665SWarner Losh PcdMaximumUnicodeStringLength. 17890d1ba665SWarner Losh If DestMax is 0. 17900d1ba665SWarner Losh @retval RETURN_BUFFER_TOO_SMALL If DestMax is NOT greater than 17910d1ba665SWarner Losh MIN(StrLen(Source), Length). 17920d1ba665SWarner Losh @retval RETURN_ACCESS_DENIED If Source and Destination overlap. 17930d1ba665SWarner Losh 17940d1ba665SWarner Losh **/ 17950d1ba665SWarner Losh RETURN_STATUS 17960d1ba665SWarner Losh EFIAPI 17970d1ba665SWarner Losh UnicodeStrnToAsciiStrS ( 17980d1ba665SWarner Losh IN CONST CHAR16 *Source, 17990d1ba665SWarner Losh IN UINTN Length, 18000d1ba665SWarner Losh OUT CHAR8 *Destination, 18010d1ba665SWarner Losh IN UINTN DestMax, 18020d1ba665SWarner Losh OUT UINTN *DestinationLength 18030d1ba665SWarner Losh ); 18040d1ba665SWarner Losh 18050d1ba665SWarner Losh #ifndef DISABLE_NEW_DEPRECATED_INTERFACES 18060d1ba665SWarner Losh 18070d1ba665SWarner Losh /** 18080d1ba665SWarner Losh [ATTENTION] This function is deprecated for security reason. 18090d1ba665SWarner Losh 18100d1ba665SWarner Losh Copies one Null-terminated ASCII string to another Null-terminated ASCII 18110d1ba665SWarner Losh string and returns the new ASCII string. 18120d1ba665SWarner Losh 18130d1ba665SWarner Losh This function copies the contents of the ASCII string Source to the ASCII 18140d1ba665SWarner Losh string Destination, and returns Destination. If Source and Destination 18150d1ba665SWarner Losh overlap, then the results are undefined. 18160d1ba665SWarner Losh 18170d1ba665SWarner Losh If Destination is NULL, then ASSERT(). 18180d1ba665SWarner Losh If Source is NULL, then ASSERT(). 18190d1ba665SWarner Losh If Source and Destination overlap, then ASSERT(). 18200d1ba665SWarner Losh If PcdMaximumAsciiStringLength is not zero and Source contains more than 18210d1ba665SWarner Losh PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, 18220d1ba665SWarner Losh then ASSERT(). 18230d1ba665SWarner Losh 18240d1ba665SWarner Losh @param Destination The pointer to a Null-terminated ASCII string. 18250d1ba665SWarner Losh @param Source The pointer to a Null-terminated ASCII string. 18260d1ba665SWarner Losh 18270d1ba665SWarner Losh @return Destination 18280d1ba665SWarner Losh 18290d1ba665SWarner Losh **/ 18300d1ba665SWarner Losh CHAR8 * 18310d1ba665SWarner Losh EFIAPI 18320d1ba665SWarner Losh AsciiStrCpy ( 18330d1ba665SWarner Losh OUT CHAR8 *Destination, 18340d1ba665SWarner Losh IN CONST CHAR8 *Source 18350d1ba665SWarner Losh ); 18360d1ba665SWarner Losh 18370d1ba665SWarner Losh 18380d1ba665SWarner Losh /** 18390d1ba665SWarner Losh [ATTENTION] This function is deprecated for security reason. 18400d1ba665SWarner Losh 18410d1ba665SWarner Losh Copies up to a specified length one Null-terminated ASCII string to another 18420d1ba665SWarner Losh Null-terminated ASCII string and returns the new ASCII string. 18430d1ba665SWarner Losh 18440d1ba665SWarner Losh This function copies the contents of the ASCII string Source to the ASCII 18450d1ba665SWarner Losh string Destination, and returns Destination. At most, Length ASCII characters 18460d1ba665SWarner Losh are copied from Source to Destination. If Length is 0, then Destination is 18470d1ba665SWarner Losh returned unmodified. If Length is greater that the number of ASCII characters 18480d1ba665SWarner Losh in Source, then Destination is padded with Null ASCII characters. If Source 18490d1ba665SWarner Losh and Destination overlap, then the results are undefined. 18500d1ba665SWarner Losh 18510d1ba665SWarner Losh If Destination is NULL, then ASSERT(). 18520d1ba665SWarner Losh If Source is NULL, then ASSERT(). 18530d1ba665SWarner Losh If Source and Destination overlap, then ASSERT(). 18540d1ba665SWarner Losh If PcdMaximumAsciiStringLength is not zero, and Length is greater than 18550d1ba665SWarner Losh PcdMaximumAsciiStringLength, then ASSERT(). 18560d1ba665SWarner Losh If PcdMaximumAsciiStringLength is not zero, and Source contains more than 18570d1ba665SWarner Losh PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator, 18580d1ba665SWarner Losh then ASSERT(). 18590d1ba665SWarner Losh 18600d1ba665SWarner Losh @param Destination The pointer to a Null-terminated ASCII string. 18610d1ba665SWarner Losh @param Source The pointer to a Null-terminated ASCII string. 18620d1ba665SWarner Losh @param Length The maximum number of ASCII characters to copy. 18630d1ba665SWarner Losh 18640d1ba665SWarner Losh @return Destination 18650d1ba665SWarner Losh 18660d1ba665SWarner Losh **/ 18670d1ba665SWarner Losh CHAR8 * 18680d1ba665SWarner Losh EFIAPI 18690d1ba665SWarner Losh AsciiStrnCpy ( 18700d1ba665SWarner Losh OUT CHAR8 *Destination, 18710d1ba665SWarner Losh IN CONST CHAR8 *Source, 18720d1ba665SWarner Losh IN UINTN Length 18730d1ba665SWarner Losh ); 1874*3245fa21SMitchell Horne #endif // !defined (DISABLE_NEW_DEPRECATED_INTERFACES) 18750d1ba665SWarner Losh 18760d1ba665SWarner Losh /** 18770d1ba665SWarner Losh Returns the length of a Null-terminated ASCII string. 18780d1ba665SWarner Losh 18790d1ba665SWarner Losh This function returns the number of ASCII characters in the Null-terminated 18800d1ba665SWarner Losh ASCII string specified by String. 18810d1ba665SWarner Losh 18820d1ba665SWarner Losh If Length > 0 and Destination is NULL, then ASSERT(). 18830d1ba665SWarner Losh If Length > 0 and Source is NULL, then ASSERT(). 18840d1ba665SWarner Losh If PcdMaximumAsciiStringLength is not zero and String contains more than 18850d1ba665SWarner Losh PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, 18860d1ba665SWarner Losh then ASSERT(). 18870d1ba665SWarner Losh 18880d1ba665SWarner Losh @param String The pointer to a Null-terminated ASCII string. 18890d1ba665SWarner Losh 18900d1ba665SWarner Losh @return The length of String. 18910d1ba665SWarner Losh 18920d1ba665SWarner Losh **/ 18930d1ba665SWarner Losh UINTN 18940d1ba665SWarner Losh EFIAPI 18950d1ba665SWarner Losh AsciiStrLen ( 18960d1ba665SWarner Losh IN CONST CHAR8 *String 18970d1ba665SWarner Losh ); 18980d1ba665SWarner Losh 18990d1ba665SWarner Losh 19000d1ba665SWarner Losh /** 19010d1ba665SWarner Losh Returns the size of a Null-terminated ASCII string in bytes, including the 19020d1ba665SWarner Losh Null terminator. 19030d1ba665SWarner Losh 19040d1ba665SWarner Losh This function returns the size, in bytes, of the Null-terminated ASCII string 19050d1ba665SWarner Losh specified by String. 19060d1ba665SWarner Losh 19070d1ba665SWarner Losh If String is NULL, then ASSERT(). 19080d1ba665SWarner Losh If PcdMaximumAsciiStringLength is not zero and String contains more than 19090d1ba665SWarner Losh PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, 19100d1ba665SWarner Losh then ASSERT(). 19110d1ba665SWarner Losh 19120d1ba665SWarner Losh @param String The pointer to a Null-terminated ASCII string. 19130d1ba665SWarner Losh 19140d1ba665SWarner Losh @return The size of String. 19150d1ba665SWarner Losh 19160d1ba665SWarner Losh **/ 19170d1ba665SWarner Losh UINTN 19180d1ba665SWarner Losh EFIAPI 19190d1ba665SWarner Losh AsciiStrSize ( 19200d1ba665SWarner Losh IN CONST CHAR8 *String 19210d1ba665SWarner Losh ); 19220d1ba665SWarner Losh 19230d1ba665SWarner Losh 19240d1ba665SWarner Losh /** 19250d1ba665SWarner Losh Compares two Null-terminated ASCII strings, and returns the difference 19260d1ba665SWarner Losh between the first mismatched ASCII characters. 19270d1ba665SWarner Losh 19280d1ba665SWarner Losh This function compares the Null-terminated ASCII string FirstString to the 19290d1ba665SWarner Losh Null-terminated ASCII string SecondString. If FirstString is identical to 19300d1ba665SWarner Losh SecondString, then 0 is returned. Otherwise, the value returned is the first 19310d1ba665SWarner Losh mismatched ASCII character in SecondString subtracted from the first 19320d1ba665SWarner Losh mismatched ASCII character in FirstString. 19330d1ba665SWarner Losh 19340d1ba665SWarner Losh If FirstString is NULL, then ASSERT(). 19350d1ba665SWarner Losh If SecondString is NULL, then ASSERT(). 19360d1ba665SWarner Losh If PcdMaximumAsciiStringLength is not zero and FirstString contains more than 19370d1ba665SWarner Losh PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, 19380d1ba665SWarner Losh then ASSERT(). 19390d1ba665SWarner Losh If PcdMaximumAsciiStringLength is not zero and SecondString contains more 19400d1ba665SWarner Losh than PcdMaximumAsciiStringLength ASCII characters not including the 19410d1ba665SWarner Losh Null-terminator, then ASSERT(). 19420d1ba665SWarner Losh 19430d1ba665SWarner Losh @param FirstString The pointer to a Null-terminated ASCII string. 19440d1ba665SWarner Losh @param SecondString The pointer to a Null-terminated ASCII string. 19450d1ba665SWarner Losh 19460d1ba665SWarner Losh @retval ==0 FirstString is identical to SecondString. 19470d1ba665SWarner Losh @retval !=0 FirstString is not identical to SecondString. 19480d1ba665SWarner Losh 19490d1ba665SWarner Losh **/ 19500d1ba665SWarner Losh INTN 19510d1ba665SWarner Losh EFIAPI 19520d1ba665SWarner Losh AsciiStrCmp ( 19530d1ba665SWarner Losh IN CONST CHAR8 *FirstString, 19540d1ba665SWarner Losh IN CONST CHAR8 *SecondString 19550d1ba665SWarner Losh ); 19560d1ba665SWarner Losh 19570d1ba665SWarner Losh 19580d1ba665SWarner Losh /** 19590d1ba665SWarner Losh Performs a case insensitive comparison of two Null-terminated ASCII strings, 19600d1ba665SWarner Losh and returns the difference between the first mismatched ASCII characters. 19610d1ba665SWarner Losh 19620d1ba665SWarner Losh This function performs a case insensitive comparison of the Null-terminated 19630d1ba665SWarner Losh ASCII string FirstString to the Null-terminated ASCII string SecondString. If 19640d1ba665SWarner Losh FirstString is identical to SecondString, then 0 is returned. Otherwise, the 19650d1ba665SWarner Losh value returned is the first mismatched lower case ASCII character in 19660d1ba665SWarner Losh SecondString subtracted from the first mismatched lower case ASCII character 19670d1ba665SWarner Losh in FirstString. 19680d1ba665SWarner Losh 19690d1ba665SWarner Losh If FirstString is NULL, then ASSERT(). 19700d1ba665SWarner Losh If SecondString is NULL, then ASSERT(). 19710d1ba665SWarner Losh If PcdMaximumAsciiStringLength is not zero and FirstString contains more than 19720d1ba665SWarner Losh PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, 19730d1ba665SWarner Losh then ASSERT(). 19740d1ba665SWarner Losh If PcdMaximumAsciiStringLength is not zero and SecondString contains more 19750d1ba665SWarner Losh than PcdMaximumAsciiStringLength ASCII characters not including the 19760d1ba665SWarner Losh Null-terminator, then ASSERT(). 19770d1ba665SWarner Losh 19780d1ba665SWarner Losh @param FirstString The pointer to a Null-terminated ASCII string. 19790d1ba665SWarner Losh @param SecondString The pointer to a Null-terminated ASCII string. 19800d1ba665SWarner Losh 19810d1ba665SWarner Losh @retval ==0 FirstString is identical to SecondString using case insensitive 19820d1ba665SWarner Losh comparisons. 19830d1ba665SWarner Losh @retval !=0 FirstString is not identical to SecondString using case 19840d1ba665SWarner Losh insensitive comparisons. 19850d1ba665SWarner Losh 19860d1ba665SWarner Losh **/ 19870d1ba665SWarner Losh INTN 19880d1ba665SWarner Losh EFIAPI 19890d1ba665SWarner Losh AsciiStriCmp ( 19900d1ba665SWarner Losh IN CONST CHAR8 *FirstString, 19910d1ba665SWarner Losh IN CONST CHAR8 *SecondString 19920d1ba665SWarner Losh ); 19930d1ba665SWarner Losh 19940d1ba665SWarner Losh 19950d1ba665SWarner Losh /** 19960d1ba665SWarner Losh Compares two Null-terminated ASCII strings with maximum lengths, and returns 19970d1ba665SWarner Losh the difference between the first mismatched ASCII characters. 19980d1ba665SWarner Losh 19990d1ba665SWarner Losh This function compares the Null-terminated ASCII string FirstString to the 20000d1ba665SWarner Losh Null-terminated ASCII string SecondString. At most, Length ASCII characters 20010d1ba665SWarner Losh will be compared. If Length is 0, then 0 is returned. If FirstString is 20020d1ba665SWarner Losh identical to SecondString, then 0 is returned. Otherwise, the value returned 20030d1ba665SWarner Losh is the first mismatched ASCII character in SecondString subtracted from the 20040d1ba665SWarner Losh first mismatched ASCII character in FirstString. 20050d1ba665SWarner Losh 20060d1ba665SWarner Losh If Length > 0 and FirstString is NULL, then ASSERT(). 20070d1ba665SWarner Losh If Length > 0 and SecondString is NULL, then ASSERT(). 20080d1ba665SWarner Losh If PcdMaximumAsciiStringLength is not zero, and Length is greater than 20090d1ba665SWarner Losh PcdMaximumAsciiStringLength, then ASSERT(). 20100d1ba665SWarner Losh If PcdMaximumAsciiStringLength is not zero, and FirstString contains more than 20110d1ba665SWarner Losh PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator, 20120d1ba665SWarner Losh then ASSERT(). 20130d1ba665SWarner Losh If PcdMaximumAsciiStringLength is not zero, and SecondString contains more than 20140d1ba665SWarner Losh PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator, 20150d1ba665SWarner Losh then ASSERT(). 20160d1ba665SWarner Losh 20170d1ba665SWarner Losh @param FirstString The pointer to a Null-terminated ASCII string. 20180d1ba665SWarner Losh @param SecondString The pointer to a Null-terminated ASCII string. 20190d1ba665SWarner Losh @param Length The maximum number of ASCII characters for compare. 20200d1ba665SWarner Losh 20210d1ba665SWarner Losh @retval ==0 FirstString is identical to SecondString. 20220d1ba665SWarner Losh @retval !=0 FirstString is not identical to SecondString. 20230d1ba665SWarner Losh 20240d1ba665SWarner Losh **/ 20250d1ba665SWarner Losh INTN 20260d1ba665SWarner Losh EFIAPI 20270d1ba665SWarner Losh AsciiStrnCmp ( 20280d1ba665SWarner Losh IN CONST CHAR8 *FirstString, 20290d1ba665SWarner Losh IN CONST CHAR8 *SecondString, 20300d1ba665SWarner Losh IN UINTN Length 20310d1ba665SWarner Losh ); 20320d1ba665SWarner Losh 20330d1ba665SWarner Losh 20340d1ba665SWarner Losh #ifndef DISABLE_NEW_DEPRECATED_INTERFACES 20350d1ba665SWarner Losh 20360d1ba665SWarner Losh /** 20370d1ba665SWarner Losh [ATTENTION] This function is deprecated for security reason. 20380d1ba665SWarner Losh 20390d1ba665SWarner Losh Concatenates one Null-terminated ASCII string to another Null-terminated 20400d1ba665SWarner Losh ASCII string, and returns the concatenated ASCII string. 20410d1ba665SWarner Losh 20420d1ba665SWarner Losh This function concatenates two Null-terminated ASCII strings. The contents of 20430d1ba665SWarner Losh Null-terminated ASCII string Source are concatenated to the end of Null- 20440d1ba665SWarner Losh terminated ASCII string Destination. The Null-terminated concatenated ASCII 20450d1ba665SWarner Losh String is returned. 20460d1ba665SWarner Losh 20470d1ba665SWarner Losh If Destination is NULL, then ASSERT(). 20480d1ba665SWarner Losh If Source is NULL, then ASSERT(). 20490d1ba665SWarner Losh If PcdMaximumAsciiStringLength is not zero and Destination contains more than 20500d1ba665SWarner Losh PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, 20510d1ba665SWarner Losh then ASSERT(). 20520d1ba665SWarner Losh If PcdMaximumAsciiStringLength is not zero and Source contains more than 20530d1ba665SWarner Losh PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, 20540d1ba665SWarner Losh then ASSERT(). 20550d1ba665SWarner Losh If PcdMaximumAsciiStringLength is not zero and concatenating Destination and 20560d1ba665SWarner Losh Source results in a ASCII string with more than PcdMaximumAsciiStringLength 20570d1ba665SWarner Losh ASCII characters, then ASSERT(). 20580d1ba665SWarner Losh 20590d1ba665SWarner Losh @param Destination The pointer to a Null-terminated ASCII string. 20600d1ba665SWarner Losh @param Source The pointer to a Null-terminated ASCII string. 20610d1ba665SWarner Losh 20620d1ba665SWarner Losh @return Destination 20630d1ba665SWarner Losh 20640d1ba665SWarner Losh **/ 20650d1ba665SWarner Losh CHAR8 * 20660d1ba665SWarner Losh EFIAPI 20670d1ba665SWarner Losh AsciiStrCat ( 20680d1ba665SWarner Losh IN OUT CHAR8 *Destination, 20690d1ba665SWarner Losh IN CONST CHAR8 *Source 20700d1ba665SWarner Losh ); 20710d1ba665SWarner Losh 20720d1ba665SWarner Losh 20730d1ba665SWarner Losh /** 20740d1ba665SWarner Losh [ATTENTION] This function is deprecated for security reason. 20750d1ba665SWarner Losh 20760d1ba665SWarner Losh Concatenates up to a specified length one Null-terminated ASCII string to 20770d1ba665SWarner Losh the end of another Null-terminated ASCII string, and returns the 20780d1ba665SWarner Losh concatenated ASCII string. 20790d1ba665SWarner Losh 20800d1ba665SWarner Losh This function concatenates two Null-terminated ASCII strings. The contents 20810d1ba665SWarner Losh of Null-terminated ASCII string Source are concatenated to the end of Null- 20820d1ba665SWarner Losh terminated ASCII string Destination, and Destination is returned. At most, 20830d1ba665SWarner Losh Length ASCII characters are concatenated from Source to the end of 20840d1ba665SWarner Losh Destination, and Destination is always Null-terminated. If Length is 0, then 20850d1ba665SWarner Losh Destination is returned unmodified. If Source and Destination overlap, then 20860d1ba665SWarner Losh the results are undefined. 20870d1ba665SWarner Losh 20880d1ba665SWarner Losh If Length > 0 and Destination is NULL, then ASSERT(). 20890d1ba665SWarner Losh If Length > 0 and Source is NULL, then ASSERT(). 20900d1ba665SWarner Losh If Source and Destination overlap, then ASSERT(). 20910d1ba665SWarner Losh If PcdMaximumAsciiStringLength is not zero, and Length is greater than 20920d1ba665SWarner Losh PcdMaximumAsciiStringLength, then ASSERT(). 20930d1ba665SWarner Losh If PcdMaximumAsciiStringLength is not zero, and Destination contains more than 20940d1ba665SWarner Losh PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator, 20950d1ba665SWarner Losh then ASSERT(). 20960d1ba665SWarner Losh If PcdMaximumAsciiStringLength is not zero, and Source contains more than 20970d1ba665SWarner Losh PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator, 20980d1ba665SWarner Losh then ASSERT(). 20990d1ba665SWarner Losh If PcdMaximumAsciiStringLength is not zero, and concatenating Destination and 21000d1ba665SWarner Losh Source results in a ASCII string with more than PcdMaximumAsciiStringLength 21010d1ba665SWarner Losh ASCII characters, not including the Null-terminator, then ASSERT(). 21020d1ba665SWarner Losh 21030d1ba665SWarner Losh @param Destination The pointer to a Null-terminated ASCII string. 21040d1ba665SWarner Losh @param Source The pointer to a Null-terminated ASCII string. 21050d1ba665SWarner Losh @param Length The maximum number of ASCII characters to concatenate from 21060d1ba665SWarner Losh Source. 21070d1ba665SWarner Losh 21080d1ba665SWarner Losh @return Destination 21090d1ba665SWarner Losh 21100d1ba665SWarner Losh **/ 21110d1ba665SWarner Losh CHAR8 * 21120d1ba665SWarner Losh EFIAPI 21130d1ba665SWarner Losh AsciiStrnCat ( 21140d1ba665SWarner Losh IN OUT CHAR8 *Destination, 21150d1ba665SWarner Losh IN CONST CHAR8 *Source, 21160d1ba665SWarner Losh IN UINTN Length 21170d1ba665SWarner Losh ); 2118*3245fa21SMitchell Horne #endif // !defined (DISABLE_NEW_DEPRECATED_INTERFACES) 21190d1ba665SWarner Losh 21200d1ba665SWarner Losh /** 21210d1ba665SWarner Losh Returns the first occurrence of a Null-terminated ASCII sub-string 21220d1ba665SWarner Losh in a Null-terminated ASCII string. 21230d1ba665SWarner Losh 21240d1ba665SWarner Losh This function scans the contents of the ASCII string specified by String 21250d1ba665SWarner Losh and returns the first occurrence of SearchString. If SearchString is not 21260d1ba665SWarner Losh found in String, then NULL is returned. If the length of SearchString is zero, 21270d1ba665SWarner Losh then String is returned. 21280d1ba665SWarner Losh 21290d1ba665SWarner Losh If String is NULL, then ASSERT(). 21300d1ba665SWarner Losh If SearchString is NULL, then ASSERT(). 21310d1ba665SWarner Losh 21320d1ba665SWarner Losh If PcdMaximumAsciiStringLength is not zero, and SearchString or 21330d1ba665SWarner Losh String contains more than PcdMaximumAsciiStringLength Unicode characters 21340d1ba665SWarner Losh not including the Null-terminator, then ASSERT(). 21350d1ba665SWarner Losh 21360d1ba665SWarner Losh @param String The pointer to a Null-terminated ASCII string. 21370d1ba665SWarner Losh @param SearchString The pointer to a Null-terminated ASCII string to search for. 21380d1ba665SWarner Losh 21390d1ba665SWarner Losh @retval NULL If the SearchString does not appear in String. 21400d1ba665SWarner Losh @retval others If there is a match return the first occurrence of SearchingString. 21410d1ba665SWarner Losh If the length of SearchString is zero,return String. 21420d1ba665SWarner Losh 21430d1ba665SWarner Losh **/ 21440d1ba665SWarner Losh CHAR8 * 21450d1ba665SWarner Losh EFIAPI 21460d1ba665SWarner Losh AsciiStrStr ( 21470d1ba665SWarner Losh IN CONST CHAR8 *String, 21480d1ba665SWarner Losh IN CONST CHAR8 *SearchString 21490d1ba665SWarner Losh ); 21500d1ba665SWarner Losh 21510d1ba665SWarner Losh 21520d1ba665SWarner Losh /** 21530d1ba665SWarner Losh Convert a Null-terminated ASCII decimal string to a value of type 21540d1ba665SWarner Losh UINTN. 21550d1ba665SWarner Losh 21560d1ba665SWarner Losh This function returns a value of type UINTN by interpreting the contents 21570d1ba665SWarner Losh of the ASCII string String as a decimal number. The format of the input 21580d1ba665SWarner Losh ASCII string String is: 21590d1ba665SWarner Losh 21600d1ba665SWarner Losh [spaces] [decimal digits]. 21610d1ba665SWarner Losh 21620d1ba665SWarner Losh The valid decimal digit character is in the range [0-9]. The function will 21630d1ba665SWarner Losh ignore the pad space, which includes spaces or tab characters, before the digits. 21640d1ba665SWarner Losh The running zero in the beginning of [decimal digits] will be ignored. Then, the 21650d1ba665SWarner Losh function stops at the first character that is a not a valid decimal character or 21660d1ba665SWarner Losh Null-terminator, whichever on comes first. 21670d1ba665SWarner Losh 21680d1ba665SWarner Losh If String has only pad spaces, then 0 is returned. 21690d1ba665SWarner Losh If String has no pad spaces or valid decimal digits, then 0 is returned. 21700d1ba665SWarner Losh If the number represented by String overflows according to the range defined by 21710d1ba665SWarner Losh UINTN, then MAX_UINTN is returned. 21720d1ba665SWarner Losh If String is NULL, then ASSERT(). 21730d1ba665SWarner Losh If PcdMaximumAsciiStringLength is not zero, and String contains more than 21740d1ba665SWarner Losh PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, 21750d1ba665SWarner Losh then ASSERT(). 21760d1ba665SWarner Losh 21770d1ba665SWarner Losh @param String The pointer to a Null-terminated ASCII string. 21780d1ba665SWarner Losh 21790d1ba665SWarner Losh @retval The value translated from String. 21800d1ba665SWarner Losh 21810d1ba665SWarner Losh **/ 21820d1ba665SWarner Losh UINTN 21830d1ba665SWarner Losh EFIAPI 21840d1ba665SWarner Losh AsciiStrDecimalToUintn ( 21850d1ba665SWarner Losh IN CONST CHAR8 *String 21860d1ba665SWarner Losh ); 21870d1ba665SWarner Losh 21880d1ba665SWarner Losh 21890d1ba665SWarner Losh /** 21900d1ba665SWarner Losh Convert a Null-terminated ASCII decimal string to a value of type 21910d1ba665SWarner Losh UINT64. 21920d1ba665SWarner Losh 21930d1ba665SWarner Losh This function returns a value of type UINT64 by interpreting the contents 21940d1ba665SWarner Losh of the ASCII string String as a decimal number. The format of the input 21950d1ba665SWarner Losh ASCII string String is: 21960d1ba665SWarner Losh 21970d1ba665SWarner Losh [spaces] [decimal digits]. 21980d1ba665SWarner Losh 21990d1ba665SWarner Losh The valid decimal digit character is in the range [0-9]. The function will 22000d1ba665SWarner Losh ignore the pad space, which includes spaces or tab characters, before the digits. 22010d1ba665SWarner Losh The running zero in the beginning of [decimal digits] will be ignored. Then, the 22020d1ba665SWarner Losh function stops at the first character that is a not a valid decimal character or 22030d1ba665SWarner Losh Null-terminator, whichever on comes first. 22040d1ba665SWarner Losh 22050d1ba665SWarner Losh If String has only pad spaces, then 0 is returned. 22060d1ba665SWarner Losh If String has no pad spaces or valid decimal digits, then 0 is returned. 22070d1ba665SWarner Losh If the number represented by String overflows according to the range defined by 22080d1ba665SWarner Losh UINT64, then MAX_UINT64 is returned. 22090d1ba665SWarner Losh If String is NULL, then ASSERT(). 22100d1ba665SWarner Losh If PcdMaximumAsciiStringLength is not zero, and String contains more than 22110d1ba665SWarner Losh PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, 22120d1ba665SWarner Losh then ASSERT(). 22130d1ba665SWarner Losh 22140d1ba665SWarner Losh @param String The pointer to a Null-terminated ASCII string. 22150d1ba665SWarner Losh 22160d1ba665SWarner Losh @retval Value translated from String. 22170d1ba665SWarner Losh 22180d1ba665SWarner Losh **/ 22190d1ba665SWarner Losh UINT64 22200d1ba665SWarner Losh EFIAPI 22210d1ba665SWarner Losh AsciiStrDecimalToUint64 ( 22220d1ba665SWarner Losh IN CONST CHAR8 *String 22230d1ba665SWarner Losh ); 22240d1ba665SWarner Losh 22250d1ba665SWarner Losh 22260d1ba665SWarner Losh /** 22270d1ba665SWarner Losh Convert a Null-terminated ASCII hexadecimal string to a value of type UINTN. 22280d1ba665SWarner Losh 22290d1ba665SWarner Losh This function returns a value of type UINTN by interpreting the contents of 22300d1ba665SWarner Losh the ASCII string String as a hexadecimal number. The format of the input ASCII 22310d1ba665SWarner Losh string String is: 22320d1ba665SWarner Losh 22330d1ba665SWarner Losh [spaces][zeros][x][hexadecimal digits]. 22340d1ba665SWarner Losh 22350d1ba665SWarner Losh The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F]. 22360d1ba665SWarner Losh The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix. If "x" 22370d1ba665SWarner Losh appears in the input string, it must be prefixed with at least one 0. The function 22380d1ba665SWarner Losh will ignore the pad space, which includes spaces or tab characters, before [zeros], 22390d1ba665SWarner Losh [x] or [hexadecimal digits]. The running zero before [x] or [hexadecimal digits] 22400d1ba665SWarner Losh will be ignored. Then, the decoding starts after [x] or the first valid hexadecimal 22410d1ba665SWarner Losh digit. Then, the function stops at the first character that is a not a valid 22420d1ba665SWarner Losh hexadecimal character or Null-terminator, whichever on comes first. 22430d1ba665SWarner Losh 22440d1ba665SWarner Losh If String has only pad spaces, then 0 is returned. 22450d1ba665SWarner Losh If String has no leading pad spaces, leading zeros or valid hexadecimal digits, then 22460d1ba665SWarner Losh 0 is returned. 22470d1ba665SWarner Losh 22480d1ba665SWarner Losh If the number represented by String overflows according to the range defined by UINTN, 22490d1ba665SWarner Losh then MAX_UINTN is returned. 22500d1ba665SWarner Losh If String is NULL, then ASSERT(). 22510d1ba665SWarner Losh If PcdMaximumAsciiStringLength is not zero, 22520d1ba665SWarner Losh and String contains more than PcdMaximumAsciiStringLength ASCII characters not including 22530d1ba665SWarner Losh the Null-terminator, then ASSERT(). 22540d1ba665SWarner Losh 22550d1ba665SWarner Losh @param String The pointer to a Null-terminated ASCII string. 22560d1ba665SWarner Losh 22570d1ba665SWarner Losh @retval Value translated from String. 22580d1ba665SWarner Losh 22590d1ba665SWarner Losh **/ 22600d1ba665SWarner Losh UINTN 22610d1ba665SWarner Losh EFIAPI 22620d1ba665SWarner Losh AsciiStrHexToUintn ( 22630d1ba665SWarner Losh IN CONST CHAR8 *String 22640d1ba665SWarner Losh ); 22650d1ba665SWarner Losh 22660d1ba665SWarner Losh 22670d1ba665SWarner Losh /** 22680d1ba665SWarner Losh Convert a Null-terminated ASCII hexadecimal string to a value of type UINT64. 22690d1ba665SWarner Losh 22700d1ba665SWarner Losh This function returns a value of type UINT64 by interpreting the contents of 22710d1ba665SWarner Losh the ASCII string String as a hexadecimal number. The format of the input ASCII 22720d1ba665SWarner Losh string String is: 22730d1ba665SWarner Losh 22740d1ba665SWarner Losh [spaces][zeros][x][hexadecimal digits]. 22750d1ba665SWarner Losh 22760d1ba665SWarner Losh The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F]. 22770d1ba665SWarner Losh The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix. If "x" 22780d1ba665SWarner Losh appears in the input string, it must be prefixed with at least one 0. The function 22790d1ba665SWarner Losh will ignore the pad space, which includes spaces or tab characters, before [zeros], 22800d1ba665SWarner Losh [x] or [hexadecimal digits]. The running zero before [x] or [hexadecimal digits] 22810d1ba665SWarner Losh will be ignored. Then, the decoding starts after [x] or the first valid hexadecimal 22820d1ba665SWarner Losh digit. Then, the function stops at the first character that is a not a valid 22830d1ba665SWarner Losh hexadecimal character or Null-terminator, whichever on comes first. 22840d1ba665SWarner Losh 22850d1ba665SWarner Losh If String has only pad spaces, then 0 is returned. 22860d1ba665SWarner Losh If String has no leading pad spaces, leading zeros or valid hexadecimal digits, then 22870d1ba665SWarner Losh 0 is returned. 22880d1ba665SWarner Losh 22890d1ba665SWarner Losh If the number represented by String overflows according to the range defined by UINT64, 22900d1ba665SWarner Losh then MAX_UINT64 is returned. 22910d1ba665SWarner Losh If String is NULL, then ASSERT(). 22920d1ba665SWarner Losh If PcdMaximumAsciiStringLength is not zero, 22930d1ba665SWarner Losh and String contains more than PcdMaximumAsciiStringLength ASCII characters not including 22940d1ba665SWarner Losh the Null-terminator, then ASSERT(). 22950d1ba665SWarner Losh 22960d1ba665SWarner Losh @param String The pointer to a Null-terminated ASCII string. 22970d1ba665SWarner Losh 22980d1ba665SWarner Losh @retval Value translated from String. 22990d1ba665SWarner Losh 23000d1ba665SWarner Losh **/ 23010d1ba665SWarner Losh UINT64 23020d1ba665SWarner Losh EFIAPI 23030d1ba665SWarner Losh AsciiStrHexToUint64 ( 23040d1ba665SWarner Losh IN CONST CHAR8 *String 23050d1ba665SWarner Losh ); 23060d1ba665SWarner Losh 23070d1ba665SWarner Losh /** 23080d1ba665SWarner Losh Convert a Null-terminated ASCII string to IPv6 address and prefix length. 23090d1ba665SWarner Losh 23100d1ba665SWarner Losh This function outputs a value of type IPv6_ADDRESS and may output a value 23110d1ba665SWarner Losh of type UINT8 by interpreting the contents of the ASCII string specified 23120d1ba665SWarner Losh by String. The format of the input ASCII string String is as follows: 23130d1ba665SWarner Losh 23140d1ba665SWarner Losh X:X:X:X:X:X:X:X[/P] 23150d1ba665SWarner Losh 23160d1ba665SWarner Losh X contains one to four hexadecimal digit characters in the range [0-9], [a-f] and 23170d1ba665SWarner Losh [A-F]. X is converted to a value of type UINT16, whose low byte is stored in low 23180d1ba665SWarner Losh memory address and high byte is stored in high memory address. P contains decimal 23190d1ba665SWarner Losh digit characters in the range [0-9]. The running zero in the beginning of P will 23200d1ba665SWarner Losh be ignored. /P is optional. 23210d1ba665SWarner Losh 23220d1ba665SWarner Losh When /P is not in the String, the function stops at the first character that is 23230d1ba665SWarner Losh not a valid hexadecimal digit character after eight X's are converted. 23240d1ba665SWarner Losh 23250d1ba665SWarner Losh When /P is in the String, the function stops at the first character that is not 23260d1ba665SWarner Losh a valid decimal digit character after P is converted. 23270d1ba665SWarner Losh 23280d1ba665SWarner Losh "::" can be used to compress one or more groups of X when X contains only 0. 23290d1ba665SWarner Losh The "::" can only appear once in the String. 23300d1ba665SWarner Losh 23310d1ba665SWarner Losh If EndPointer is not NULL and Address is translated from String, a pointer 23320d1ba665SWarner Losh to the character that stopped the scan is stored at the location pointed to 23330d1ba665SWarner Losh by EndPointer. 23340d1ba665SWarner Losh 23350d1ba665SWarner Losh @param String Pointer to a Null-terminated ASCII string. 23360d1ba665SWarner Losh @param EndPointer Pointer to character that stops scan. 23370d1ba665SWarner Losh @param Address Pointer to the converted IPv6 address. 23380d1ba665SWarner Losh @param PrefixLength Pointer to the converted IPv6 address prefix 23390d1ba665SWarner Losh length. MAX_UINT8 is returned when /P is 23400d1ba665SWarner Losh not in the String. 23410d1ba665SWarner Losh 23420d1ba665SWarner Losh @retval RETURN_SUCCESS Address is translated from String. 23430d1ba665SWarner Losh @retval RETURN_INVALID_PARAMETER If String is NULL. 23440d1ba665SWarner Losh If Data is NULL. 23450d1ba665SWarner Losh @retval RETURN_UNSUPPORTED If X contains more than four hexadecimal 23460d1ba665SWarner Losh digit characters. 23470d1ba665SWarner Losh If String contains "::" and number of X 23480d1ba665SWarner Losh is not less than 8. 23490d1ba665SWarner Losh If P starts with character that is not a 23500d1ba665SWarner Losh valid decimal digit character. 23510d1ba665SWarner Losh If the decimal number converted from P 23520d1ba665SWarner Losh exceeds 128. 23530d1ba665SWarner Losh 23540d1ba665SWarner Losh **/ 23550d1ba665SWarner Losh RETURN_STATUS 23560d1ba665SWarner Losh EFIAPI 23570d1ba665SWarner Losh AsciiStrToIpv6Address ( 23580d1ba665SWarner Losh IN CONST CHAR8 *String, 23590d1ba665SWarner Losh OUT CHAR8 **EndPointer, OPTIONAL 23600d1ba665SWarner Losh OUT IPv6_ADDRESS *Address, 23610d1ba665SWarner Losh OUT UINT8 *PrefixLength OPTIONAL 23620d1ba665SWarner Losh ); 23630d1ba665SWarner Losh 23640d1ba665SWarner Losh /** 23650d1ba665SWarner Losh Convert a Null-terminated ASCII string to IPv4 address and prefix length. 23660d1ba665SWarner Losh 23670d1ba665SWarner Losh This function outputs a value of type IPv4_ADDRESS and may output a value 23680d1ba665SWarner Losh of type UINT8 by interpreting the contents of the ASCII string specified 23690d1ba665SWarner Losh by String. The format of the input ASCII string String is as follows: 23700d1ba665SWarner Losh 23710d1ba665SWarner Losh D.D.D.D[/P] 23720d1ba665SWarner Losh 23730d1ba665SWarner Losh D and P are decimal digit characters in the range [0-9]. The running zero in 23740d1ba665SWarner Losh the beginning of D and P will be ignored. /P is optional. 23750d1ba665SWarner Losh 23760d1ba665SWarner Losh When /P is not in the String, the function stops at the first character that is 23770d1ba665SWarner Losh not a valid decimal digit character after four D's are converted. 23780d1ba665SWarner Losh 23790d1ba665SWarner Losh When /P is in the String, the function stops at the first character that is not 23800d1ba665SWarner Losh a valid decimal digit character after P is converted. 23810d1ba665SWarner Losh 23820d1ba665SWarner Losh If EndPointer is not NULL and Address is translated from String, a pointer 23830d1ba665SWarner Losh to the character that stopped the scan is stored at the location pointed to 23840d1ba665SWarner Losh by EndPointer. 23850d1ba665SWarner Losh 23860d1ba665SWarner Losh @param String Pointer to a Null-terminated ASCII string. 23870d1ba665SWarner Losh @param EndPointer Pointer to character that stops scan. 23880d1ba665SWarner Losh @param Address Pointer to the converted IPv4 address. 23890d1ba665SWarner Losh @param PrefixLength Pointer to the converted IPv4 address prefix 23900d1ba665SWarner Losh length. MAX_UINT8 is returned when /P is 23910d1ba665SWarner Losh not in the String. 23920d1ba665SWarner Losh 23930d1ba665SWarner Losh @retval RETURN_SUCCESS Address is translated from String. 23940d1ba665SWarner Losh @retval RETURN_INVALID_PARAMETER If String is NULL. 23950d1ba665SWarner Losh If Data is NULL. 23960d1ba665SWarner Losh @retval RETURN_UNSUPPORTED If String is not in the correct format. 23970d1ba665SWarner Losh If any decimal number converted from D 23980d1ba665SWarner Losh exceeds 255. 23990d1ba665SWarner Losh If the decimal number converted from P 24000d1ba665SWarner Losh exceeds 32. 24010d1ba665SWarner Losh 24020d1ba665SWarner Losh **/ 24030d1ba665SWarner Losh RETURN_STATUS 24040d1ba665SWarner Losh EFIAPI 24050d1ba665SWarner Losh AsciiStrToIpv4Address ( 24060d1ba665SWarner Losh IN CONST CHAR8 *String, 24070d1ba665SWarner Losh OUT CHAR8 **EndPointer, OPTIONAL 24080d1ba665SWarner Losh OUT IPv4_ADDRESS *Address, 24090d1ba665SWarner Losh OUT UINT8 *PrefixLength OPTIONAL 24100d1ba665SWarner Losh ); 24110d1ba665SWarner Losh 24120d1ba665SWarner Losh /** 24130d1ba665SWarner Losh Convert a Null-terminated ASCII GUID string to a value of type 24140d1ba665SWarner Losh EFI_GUID. 24150d1ba665SWarner Losh 24160d1ba665SWarner Losh This function outputs a GUID value by interpreting the contents of 24170d1ba665SWarner Losh the ASCII string specified by String. The format of the input 24180d1ba665SWarner Losh ASCII string String consists of 36 characters, as follows: 24190d1ba665SWarner Losh 24200d1ba665SWarner Losh aabbccdd-eeff-gghh-iijj-kkllmmnnoopp 24210d1ba665SWarner Losh 24220d1ba665SWarner Losh The pairs aa - pp are two characters in the range [0-9], [a-f] and 24230d1ba665SWarner Losh [A-F], with each pair representing a single byte hexadecimal value. 24240d1ba665SWarner Losh 24250d1ba665SWarner Losh The mapping between String and the EFI_GUID structure is as follows: 24260d1ba665SWarner Losh aa Data1[24:31] 24270d1ba665SWarner Losh bb Data1[16:23] 24280d1ba665SWarner Losh cc Data1[8:15] 24290d1ba665SWarner Losh dd Data1[0:7] 24300d1ba665SWarner Losh ee Data2[8:15] 24310d1ba665SWarner Losh ff Data2[0:7] 24320d1ba665SWarner Losh gg Data3[8:15] 24330d1ba665SWarner Losh hh Data3[0:7] 24340d1ba665SWarner Losh ii Data4[0:7] 24350d1ba665SWarner Losh jj Data4[8:15] 24360d1ba665SWarner Losh kk Data4[16:23] 24370d1ba665SWarner Losh ll Data4[24:31] 24380d1ba665SWarner Losh mm Data4[32:39] 24390d1ba665SWarner Losh nn Data4[40:47] 24400d1ba665SWarner Losh oo Data4[48:55] 24410d1ba665SWarner Losh pp Data4[56:63] 24420d1ba665SWarner Losh 24430d1ba665SWarner Losh @param String Pointer to a Null-terminated ASCII string. 24440d1ba665SWarner Losh @param Guid Pointer to the converted GUID. 24450d1ba665SWarner Losh 24460d1ba665SWarner Losh @retval RETURN_SUCCESS Guid is translated from String. 24470d1ba665SWarner Losh @retval RETURN_INVALID_PARAMETER If String is NULL. 24480d1ba665SWarner Losh If Data is NULL. 24490d1ba665SWarner Losh @retval RETURN_UNSUPPORTED If String is not as the above format. 24500d1ba665SWarner Losh 24510d1ba665SWarner Losh **/ 24520d1ba665SWarner Losh RETURN_STATUS 24530d1ba665SWarner Losh EFIAPI 24540d1ba665SWarner Losh AsciiStrToGuid ( 24550d1ba665SWarner Losh IN CONST CHAR8 *String, 24560d1ba665SWarner Losh OUT GUID *Guid 24570d1ba665SWarner Losh ); 24580d1ba665SWarner Losh 24590d1ba665SWarner Losh /** 24600d1ba665SWarner Losh Convert a Null-terminated ASCII hexadecimal string to a byte array. 24610d1ba665SWarner Losh 24620d1ba665SWarner Losh This function outputs a byte array by interpreting the contents of 24630d1ba665SWarner Losh the ASCII string specified by String in hexadecimal format. The format of 24640d1ba665SWarner Losh the input ASCII string String is: 24650d1ba665SWarner Losh 24660d1ba665SWarner Losh [XX]* 24670d1ba665SWarner Losh 24680d1ba665SWarner Losh X is a hexadecimal digit character in the range [0-9], [a-f] and [A-F]. 24690d1ba665SWarner Losh The function decodes every two hexadecimal digit characters as one byte. The 24700d1ba665SWarner Losh decoding stops after Length of characters and outputs Buffer containing 24710d1ba665SWarner Losh (Length / 2) bytes. 24720d1ba665SWarner Losh 24730d1ba665SWarner Losh @param String Pointer to a Null-terminated ASCII string. 24740d1ba665SWarner Losh @param Length The number of ASCII characters to decode. 24750d1ba665SWarner Losh @param Buffer Pointer to the converted bytes array. 24760d1ba665SWarner Losh @param MaxBufferSize The maximum size of Buffer. 24770d1ba665SWarner Losh 24780d1ba665SWarner Losh @retval RETURN_SUCCESS Buffer is translated from String. 24790d1ba665SWarner Losh @retval RETURN_INVALID_PARAMETER If String is NULL. 24800d1ba665SWarner Losh If Data is NULL. 24810d1ba665SWarner Losh If Length is not multiple of 2. 24820d1ba665SWarner Losh If PcdMaximumAsciiStringLength is not zero, 24830d1ba665SWarner Losh and Length is greater than 24840d1ba665SWarner Losh PcdMaximumAsciiStringLength. 24850d1ba665SWarner Losh @retval RETURN_UNSUPPORTED If Length of characters from String contain 24860d1ba665SWarner Losh a character that is not valid hexadecimal 24870d1ba665SWarner Losh digit characters, or a Null-terminator. 24880d1ba665SWarner Losh @retval RETURN_BUFFER_TOO_SMALL If MaxBufferSize is less than (Length / 2). 24890d1ba665SWarner Losh **/ 24900d1ba665SWarner Losh RETURN_STATUS 24910d1ba665SWarner Losh EFIAPI 24920d1ba665SWarner Losh AsciiStrHexToBytes ( 24930d1ba665SWarner Losh IN CONST CHAR8 *String, 24940d1ba665SWarner Losh IN UINTN Length, 24950d1ba665SWarner Losh OUT UINT8 *Buffer, 24960d1ba665SWarner Losh IN UINTN MaxBufferSize 24970d1ba665SWarner Losh ); 24980d1ba665SWarner Losh 24990d1ba665SWarner Losh #ifndef DISABLE_NEW_DEPRECATED_INTERFACES 25000d1ba665SWarner Losh 25010d1ba665SWarner Losh /** 25020d1ba665SWarner Losh [ATTENTION] This function is deprecated for security reason. 25030d1ba665SWarner Losh 25040d1ba665SWarner Losh Convert one Null-terminated ASCII string to a Null-terminated 25050d1ba665SWarner Losh Unicode string and returns the Unicode string. 25060d1ba665SWarner Losh 25070d1ba665SWarner Losh This function converts the contents of the ASCII string Source to the Unicode 25080d1ba665SWarner Losh string Destination, and returns Destination. The function terminates the 25090d1ba665SWarner Losh Unicode string Destination by appending a Null-terminator character at the end. 25100d1ba665SWarner Losh The caller is responsible to make sure Destination points to a buffer with size 25110d1ba665SWarner Losh equal or greater than ((AsciiStrLen (Source) + 1) * sizeof (CHAR16)) in bytes. 25120d1ba665SWarner Losh 25130d1ba665SWarner Losh If Destination is NULL, then ASSERT(). 25140d1ba665SWarner Losh If Destination is not aligned on a 16-bit boundary, then ASSERT(). 25150d1ba665SWarner Losh If Source is NULL, then ASSERT(). 25160d1ba665SWarner Losh If Source and Destination overlap, then ASSERT(). 25170d1ba665SWarner Losh If PcdMaximumAsciiStringLength is not zero, and Source contains more than 25180d1ba665SWarner Losh PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, 25190d1ba665SWarner Losh then ASSERT(). 25200d1ba665SWarner Losh If PcdMaximumUnicodeStringLength is not zero, and Source contains more than 25210d1ba665SWarner Losh PcdMaximumUnicodeStringLength ASCII characters not including the 25220d1ba665SWarner Losh Null-terminator, then ASSERT(). 25230d1ba665SWarner Losh 25240d1ba665SWarner Losh @param Source The pointer to a Null-terminated ASCII string. 25250d1ba665SWarner Losh @param Destination The pointer to a Null-terminated Unicode string. 25260d1ba665SWarner Losh 25270d1ba665SWarner Losh @return Destination. 25280d1ba665SWarner Losh 25290d1ba665SWarner Losh **/ 25300d1ba665SWarner Losh CHAR16 * 25310d1ba665SWarner Losh EFIAPI 25320d1ba665SWarner Losh AsciiStrToUnicodeStr ( 25330d1ba665SWarner Losh IN CONST CHAR8 *Source, 25340d1ba665SWarner Losh OUT CHAR16 *Destination 25350d1ba665SWarner Losh ); 25360d1ba665SWarner Losh 2537*3245fa21SMitchell Horne #endif // !defined (DISABLE_NEW_DEPRECATED_INTERFACES) 25380d1ba665SWarner Losh 25390d1ba665SWarner Losh /** 25400d1ba665SWarner Losh Convert one Null-terminated ASCII string to a Null-terminated 25410d1ba665SWarner Losh Unicode string. 25420d1ba665SWarner Losh 25430d1ba665SWarner Losh This function is similar to StrCpyS. 25440d1ba665SWarner Losh 25450d1ba665SWarner Losh This function converts the contents of the ASCII string Source to the Unicode 25460d1ba665SWarner Losh string Destination. The function terminates the Unicode string Destination by 25470d1ba665SWarner Losh appending a Null-terminator character at the end. 25480d1ba665SWarner Losh 25490d1ba665SWarner Losh The caller is responsible to make sure Destination points to a buffer with size 25500d1ba665SWarner Losh equal or greater than ((AsciiStrLen (Source) + 1) * sizeof (CHAR16)) in bytes. 25510d1ba665SWarner Losh 25520d1ba665SWarner Losh If Destination is not aligned on a 16-bit boundary, then ASSERT(). 25530d1ba665SWarner Losh 25540d1ba665SWarner Losh If an error is returned, then the Destination is unmodified. 25550d1ba665SWarner Losh 25560d1ba665SWarner Losh @param Source The pointer to a Null-terminated ASCII string. 25570d1ba665SWarner Losh @param Destination The pointer to a Null-terminated Unicode string. 25580d1ba665SWarner Losh @param DestMax The maximum number of Destination Unicode 25590d1ba665SWarner Losh char, including terminating null char. 25600d1ba665SWarner Losh 25610d1ba665SWarner Losh @retval RETURN_SUCCESS String is converted. 25620d1ba665SWarner Losh @retval RETURN_BUFFER_TOO_SMALL If DestMax is NOT greater than StrLen(Source). 25630d1ba665SWarner Losh @retval RETURN_INVALID_PARAMETER If Destination is NULL. 25640d1ba665SWarner Losh If Source is NULL. 25650d1ba665SWarner Losh If PcdMaximumUnicodeStringLength is not zero, 25660d1ba665SWarner Losh and DestMax is greater than 25670d1ba665SWarner Losh PcdMaximumUnicodeStringLength. 25680d1ba665SWarner Losh If PcdMaximumAsciiStringLength is not zero, 25690d1ba665SWarner Losh and DestMax is greater than 25700d1ba665SWarner Losh PcdMaximumAsciiStringLength. 25710d1ba665SWarner Losh If DestMax is 0. 25720d1ba665SWarner Losh @retval RETURN_ACCESS_DENIED If Source and Destination overlap. 25730d1ba665SWarner Losh 25740d1ba665SWarner Losh **/ 25750d1ba665SWarner Losh RETURN_STATUS 25760d1ba665SWarner Losh EFIAPI 25770d1ba665SWarner Losh AsciiStrToUnicodeStrS ( 25780d1ba665SWarner Losh IN CONST CHAR8 *Source, 25790d1ba665SWarner Losh OUT CHAR16 *Destination, 25800d1ba665SWarner Losh IN UINTN DestMax 25810d1ba665SWarner Losh ); 25820d1ba665SWarner Losh 25830d1ba665SWarner Losh /** 25840d1ba665SWarner Losh Convert not more than Length successive characters from a Null-terminated 25850d1ba665SWarner Losh Ascii string to a Null-terminated Unicode string. If no null char is copied 25860d1ba665SWarner Losh from Source, then Destination[Length] is always set to null. 25870d1ba665SWarner Losh 25880d1ba665SWarner Losh This function converts not more than Length successive characters from the 25890d1ba665SWarner Losh Ascii string Source to the Unicode string Destination. The function 25900d1ba665SWarner Losh terminates the Unicode string Destination by appending a Null-terminator 25910d1ba665SWarner Losh character at the end. 25920d1ba665SWarner Losh 25930d1ba665SWarner Losh The caller is responsible to make sure Destination points to a buffer with 25940d1ba665SWarner Losh size not smaller than 25950d1ba665SWarner Losh ((MIN(AsciiStrLen(Source), Length) + 1) * sizeof (CHAR8)) in bytes. 25960d1ba665SWarner Losh 25970d1ba665SWarner Losh If Destination is not aligned on a 16-bit boundary, then ASSERT(). 25980d1ba665SWarner Losh 25990d1ba665SWarner Losh If an error is returned, then Destination and DestinationLength are 26000d1ba665SWarner Losh unmodified. 26010d1ba665SWarner Losh 26020d1ba665SWarner Losh @param Source The pointer to a Null-terminated Ascii string. 26030d1ba665SWarner Losh @param Length The maximum number of Ascii characters to convert. 26040d1ba665SWarner Losh @param Destination The pointer to a Null-terminated Unicode string. 26050d1ba665SWarner Losh @param DestMax The maximum number of Destination Unicode char, 26060d1ba665SWarner Losh including terminating null char. 26070d1ba665SWarner Losh @param DestinationLength The number of Ascii characters converted. 26080d1ba665SWarner Losh 26090d1ba665SWarner Losh @retval RETURN_SUCCESS String is converted. 26100d1ba665SWarner Losh @retval RETURN_INVALID_PARAMETER If Destination is NULL. 26110d1ba665SWarner Losh If Source is NULL. 26120d1ba665SWarner Losh If DestinationLength is NULL. 26130d1ba665SWarner Losh If PcdMaximumUnicodeStringLength is not 26140d1ba665SWarner Losh zero, and Length or DestMax is greater than 26150d1ba665SWarner Losh PcdMaximumUnicodeStringLength. 26160d1ba665SWarner Losh If PcdMaximumAsciiStringLength is not zero, 26170d1ba665SWarner Losh and Length or DestMax is greater than 26180d1ba665SWarner Losh PcdMaximumAsciiStringLength. 26190d1ba665SWarner Losh If DestMax is 0. 26200d1ba665SWarner Losh @retval RETURN_BUFFER_TOO_SMALL If DestMax is NOT greater than 26210d1ba665SWarner Losh MIN(AsciiStrLen(Source), Length). 26220d1ba665SWarner Losh @retval RETURN_ACCESS_DENIED If Source and Destination overlap. 26230d1ba665SWarner Losh 26240d1ba665SWarner Losh **/ 26250d1ba665SWarner Losh RETURN_STATUS 26260d1ba665SWarner Losh EFIAPI 26270d1ba665SWarner Losh AsciiStrnToUnicodeStrS ( 26280d1ba665SWarner Losh IN CONST CHAR8 *Source, 26290d1ba665SWarner Losh IN UINTN Length, 26300d1ba665SWarner Losh OUT CHAR16 *Destination, 26310d1ba665SWarner Losh IN UINTN DestMax, 26320d1ba665SWarner Losh OUT UINTN *DestinationLength 26330d1ba665SWarner Losh ); 26340d1ba665SWarner Losh 26350d1ba665SWarner Losh /** 2636*3245fa21SMitchell Horne Convert a Unicode character to upper case only if 2637*3245fa21SMitchell Horne it maps to a valid small-case ASCII character. 2638*3245fa21SMitchell Horne 2639*3245fa21SMitchell Horne This internal function only deal with Unicode character 2640*3245fa21SMitchell Horne which maps to a valid small-case ASCII character, i.e. 2641*3245fa21SMitchell Horne L'a' to L'z'. For other Unicode character, the input character 2642*3245fa21SMitchell Horne is returned directly. 2643*3245fa21SMitchell Horne 2644*3245fa21SMitchell Horne @param Char The character to convert. 2645*3245fa21SMitchell Horne 2646*3245fa21SMitchell Horne @retval LowerCharacter If the Char is with range L'a' to L'z'. 2647*3245fa21SMitchell Horne @retval Unchanged Otherwise. 2648*3245fa21SMitchell Horne 2649*3245fa21SMitchell Horne **/ 2650*3245fa21SMitchell Horne CHAR16 2651*3245fa21SMitchell Horne EFIAPI 2652*3245fa21SMitchell Horne CharToUpper ( 2653*3245fa21SMitchell Horne IN CHAR16 Char 2654*3245fa21SMitchell Horne ); 2655*3245fa21SMitchell Horne 2656*3245fa21SMitchell Horne /** 2657*3245fa21SMitchell Horne Converts a lowercase Ascii character to upper one. 2658*3245fa21SMitchell Horne 2659*3245fa21SMitchell Horne If Chr is lowercase Ascii character, then converts it to upper one. 2660*3245fa21SMitchell Horne 2661*3245fa21SMitchell Horne If Value >= 0xA0, then ASSERT(). 2662*3245fa21SMitchell Horne If (Value & 0x0F) >= 0x0A, then ASSERT(). 2663*3245fa21SMitchell Horne 2664*3245fa21SMitchell Horne @param Chr one Ascii character 2665*3245fa21SMitchell Horne 2666*3245fa21SMitchell Horne @return The uppercase value of Ascii character 2667*3245fa21SMitchell Horne 2668*3245fa21SMitchell Horne **/ 2669*3245fa21SMitchell Horne CHAR8 2670*3245fa21SMitchell Horne EFIAPI 2671*3245fa21SMitchell Horne AsciiCharToUpper ( 2672*3245fa21SMitchell Horne IN CHAR8 Chr 2673*3245fa21SMitchell Horne ); 2674*3245fa21SMitchell Horne 2675*3245fa21SMitchell Horne /** 2676*3245fa21SMitchell Horne Convert binary data to a Base64 encoded ascii string based on RFC4648. 2677*3245fa21SMitchell Horne 2678*3245fa21SMitchell Horne Produce a Null-terminated Ascii string in the output buffer specified by Destination and DestinationSize. 2679*3245fa21SMitchell Horne The Ascii string is produced by converting the data string specified by Source and SourceLength. 2680*3245fa21SMitchell Horne 2681*3245fa21SMitchell Horne @param Source Input UINT8 data 2682*3245fa21SMitchell Horne @param SourceLength Number of UINT8 bytes of data 2683*3245fa21SMitchell Horne @param Destination Pointer to output string buffer 2684*3245fa21SMitchell Horne @param DestinationSize Size of ascii buffer. Set to 0 to get the size needed. 2685*3245fa21SMitchell Horne Caller is responsible for passing in buffer of DestinationSize 2686*3245fa21SMitchell Horne 2687*3245fa21SMitchell Horne @retval RETURN_SUCCESS When ascii buffer is filled in. 2688*3245fa21SMitchell Horne @retval RETURN_INVALID_PARAMETER If Source is NULL or DestinationSize is NULL. 2689*3245fa21SMitchell Horne @retval RETURN_INVALID_PARAMETER If SourceLength or DestinationSize is bigger than (MAX_ADDRESS - (UINTN)Destination). 2690*3245fa21SMitchell Horne @retval RETURN_BUFFER_TOO_SMALL If SourceLength is 0 and DestinationSize is <1. 2691*3245fa21SMitchell Horne @retval RETURN_BUFFER_TOO_SMALL If Destination is NULL or DestinationSize is smaller than required buffersize. 2692*3245fa21SMitchell Horne 2693*3245fa21SMitchell Horne **/ 2694*3245fa21SMitchell Horne RETURN_STATUS 2695*3245fa21SMitchell Horne EFIAPI 2696*3245fa21SMitchell Horne Base64Encode ( 2697*3245fa21SMitchell Horne IN CONST UINT8 *Source, 2698*3245fa21SMitchell Horne IN UINTN SourceLength, 2699*3245fa21SMitchell Horne OUT CHAR8 *Destination OPTIONAL, 2700*3245fa21SMitchell Horne IN OUT UINTN *DestinationSize 2701*3245fa21SMitchell Horne ); 2702*3245fa21SMitchell Horne 2703*3245fa21SMitchell Horne /** 2704*3245fa21SMitchell Horne Decode Base64 ASCII encoded data to 8-bit binary representation, based on 2705*3245fa21SMitchell Horne RFC4648. 2706*3245fa21SMitchell Horne 2707*3245fa21SMitchell Horne Decoding occurs according to "Table 1: The Base 64 Alphabet" in RFC4648. 2708*3245fa21SMitchell Horne 2709*3245fa21SMitchell Horne Whitespace is ignored at all positions: 2710*3245fa21SMitchell Horne - 0x09 ('\t') horizontal tab 2711*3245fa21SMitchell Horne - 0x0A ('\n') new line 2712*3245fa21SMitchell Horne - 0x0B ('\v') vertical tab 2713*3245fa21SMitchell Horne - 0x0C ('\f') form feed 2714*3245fa21SMitchell Horne - 0x0D ('\r') carriage return 2715*3245fa21SMitchell Horne - 0x20 (' ') space 2716*3245fa21SMitchell Horne 2717*3245fa21SMitchell Horne The minimum amount of required padding (with ASCII 0x3D, '=') is tolerated 2718*3245fa21SMitchell Horne and enforced at the end of the Base64 ASCII encoded data, and only there. 2719*3245fa21SMitchell Horne 2720*3245fa21SMitchell Horne Other characters outside of the encoding alphabet cause the function to 2721*3245fa21SMitchell Horne reject the Base64 ASCII encoded data. 2722*3245fa21SMitchell Horne 2723*3245fa21SMitchell Horne @param[in] Source Array of CHAR8 elements containing the Base64 2724*3245fa21SMitchell Horne ASCII encoding. May be NULL if SourceSize is 2725*3245fa21SMitchell Horne zero. 2726*3245fa21SMitchell Horne 2727*3245fa21SMitchell Horne @param[in] SourceSize Number of CHAR8 elements in Source. 2728*3245fa21SMitchell Horne 2729*3245fa21SMitchell Horne @param[out] Destination Array of UINT8 elements receiving the decoded 2730*3245fa21SMitchell Horne 8-bit binary representation. Allocated by the 2731*3245fa21SMitchell Horne caller. May be NULL if DestinationSize is 2732*3245fa21SMitchell Horne zero on input. If NULL, decoding is 2733*3245fa21SMitchell Horne performed, but the 8-bit binary 2734*3245fa21SMitchell Horne representation is not stored. If non-NULL and 2735*3245fa21SMitchell Horne the function returns an error, the contents 2736*3245fa21SMitchell Horne of Destination are indeterminate. 2737*3245fa21SMitchell Horne 2738*3245fa21SMitchell Horne @param[in,out] DestinationSize On input, the number of UINT8 elements that 2739*3245fa21SMitchell Horne the caller allocated for Destination. On 2740*3245fa21SMitchell Horne output, if the function returns 2741*3245fa21SMitchell Horne RETURN_SUCCESS or RETURN_BUFFER_TOO_SMALL, 2742*3245fa21SMitchell Horne the number of UINT8 elements that are 2743*3245fa21SMitchell Horne required for decoding the Base64 ASCII 2744*3245fa21SMitchell Horne representation. If the function returns a 2745*3245fa21SMitchell Horne value different from both RETURN_SUCCESS and 2746*3245fa21SMitchell Horne RETURN_BUFFER_TOO_SMALL, then DestinationSize 2747*3245fa21SMitchell Horne is indeterminate on output. 2748*3245fa21SMitchell Horne 2749*3245fa21SMitchell Horne @retval RETURN_SUCCESS SourceSize CHAR8 elements at Source have 2750*3245fa21SMitchell Horne been decoded to on-output DestinationSize 2751*3245fa21SMitchell Horne UINT8 elements at Destination. Note that 2752*3245fa21SMitchell Horne RETURN_SUCCESS covers the case when 2753*3245fa21SMitchell Horne DestinationSize is zero on input, and 2754*3245fa21SMitchell Horne Source decodes to zero bytes (due to 2755*3245fa21SMitchell Horne containing at most ignored whitespace). 2756*3245fa21SMitchell Horne 2757*3245fa21SMitchell Horne @retval RETURN_BUFFER_TOO_SMALL The input value of DestinationSize is not 2758*3245fa21SMitchell Horne large enough for decoding SourceSize CHAR8 2759*3245fa21SMitchell Horne elements at Source. The required number of 2760*3245fa21SMitchell Horne UINT8 elements has been stored to 2761*3245fa21SMitchell Horne DestinationSize. 2762*3245fa21SMitchell Horne 2763*3245fa21SMitchell Horne @retval RETURN_INVALID_PARAMETER DestinationSize is NULL. 2764*3245fa21SMitchell Horne 2765*3245fa21SMitchell Horne @retval RETURN_INVALID_PARAMETER Source is NULL, but SourceSize is not zero. 2766*3245fa21SMitchell Horne 2767*3245fa21SMitchell Horne @retval RETURN_INVALID_PARAMETER Destination is NULL, but DestinationSize is 2768*3245fa21SMitchell Horne not zero on input. 2769*3245fa21SMitchell Horne 2770*3245fa21SMitchell Horne @retval RETURN_INVALID_PARAMETER Source is non-NULL, and (Source + 2771*3245fa21SMitchell Horne SourceSize) would wrap around MAX_ADDRESS. 2772*3245fa21SMitchell Horne 2773*3245fa21SMitchell Horne @retval RETURN_INVALID_PARAMETER Destination is non-NULL, and (Destination + 2774*3245fa21SMitchell Horne DestinationSize) would wrap around 2775*3245fa21SMitchell Horne MAX_ADDRESS, as specified on input. 2776*3245fa21SMitchell Horne 2777*3245fa21SMitchell Horne @retval RETURN_INVALID_PARAMETER None of Source and Destination are NULL, 2778*3245fa21SMitchell Horne and CHAR8[SourceSize] at Source overlaps 2779*3245fa21SMitchell Horne UINT8[DestinationSize] at Destination, as 2780*3245fa21SMitchell Horne specified on input. 2781*3245fa21SMitchell Horne 2782*3245fa21SMitchell Horne @retval RETURN_INVALID_PARAMETER Invalid CHAR8 element encountered in 2783*3245fa21SMitchell Horne Source. 2784*3245fa21SMitchell Horne **/ 2785*3245fa21SMitchell Horne RETURN_STATUS 2786*3245fa21SMitchell Horne EFIAPI 2787*3245fa21SMitchell Horne Base64Decode ( 2788*3245fa21SMitchell Horne IN CONST CHAR8 *Source OPTIONAL, 2789*3245fa21SMitchell Horne IN UINTN SourceSize, 2790*3245fa21SMitchell Horne OUT UINT8 *Destination OPTIONAL, 2791*3245fa21SMitchell Horne IN OUT UINTN *DestinationSize 2792*3245fa21SMitchell Horne ); 2793*3245fa21SMitchell Horne 2794*3245fa21SMitchell Horne /** 27950d1ba665SWarner Losh Converts an 8-bit value to an 8-bit BCD value. 27960d1ba665SWarner Losh 27970d1ba665SWarner Losh Converts the 8-bit value specified by Value to BCD. The BCD value is 27980d1ba665SWarner Losh returned. 27990d1ba665SWarner Losh 28000d1ba665SWarner Losh If Value >= 100, then ASSERT(). 28010d1ba665SWarner Losh 28020d1ba665SWarner Losh @param Value The 8-bit value to convert to BCD. Range 0..99. 28030d1ba665SWarner Losh 28040d1ba665SWarner Losh @return The BCD value. 28050d1ba665SWarner Losh 28060d1ba665SWarner Losh **/ 28070d1ba665SWarner Losh UINT8 28080d1ba665SWarner Losh EFIAPI 28090d1ba665SWarner Losh DecimalToBcd8 ( 28100d1ba665SWarner Losh IN UINT8 Value 28110d1ba665SWarner Losh ); 28120d1ba665SWarner Losh 28130d1ba665SWarner Losh 28140d1ba665SWarner Losh /** 28150d1ba665SWarner Losh Converts an 8-bit BCD value to an 8-bit value. 28160d1ba665SWarner Losh 28170d1ba665SWarner Losh Converts the 8-bit BCD value specified by Value to an 8-bit value. The 8-bit 28180d1ba665SWarner Losh value is returned. 28190d1ba665SWarner Losh 28200d1ba665SWarner Losh If Value >= 0xA0, then ASSERT(). 28210d1ba665SWarner Losh If (Value & 0x0F) >= 0x0A, then ASSERT(). 28220d1ba665SWarner Losh 28230d1ba665SWarner Losh @param Value The 8-bit BCD value to convert to an 8-bit value. 28240d1ba665SWarner Losh 28250d1ba665SWarner Losh @return The 8-bit value is returned. 28260d1ba665SWarner Losh 28270d1ba665SWarner Losh **/ 28280d1ba665SWarner Losh UINT8 28290d1ba665SWarner Losh EFIAPI 28300d1ba665SWarner Losh BcdToDecimal8 ( 28310d1ba665SWarner Losh IN UINT8 Value 28320d1ba665SWarner Losh ); 28330d1ba665SWarner Losh 28340d1ba665SWarner Losh // 28350d1ba665SWarner Losh // File Path Manipulation Functions 28360d1ba665SWarner Losh // 28370d1ba665SWarner Losh 28380d1ba665SWarner Losh /** 28390d1ba665SWarner Losh Removes the last directory or file entry in a path. 28400d1ba665SWarner Losh 28410d1ba665SWarner Losh @param[in, out] Path The pointer to the path to modify. 28420d1ba665SWarner Losh 28430d1ba665SWarner Losh @retval FALSE Nothing was found to remove. 28440d1ba665SWarner Losh @retval TRUE A directory or file was removed. 28450d1ba665SWarner Losh **/ 28460d1ba665SWarner Losh BOOLEAN 28470d1ba665SWarner Losh EFIAPI 28480d1ba665SWarner Losh PathRemoveLastItem( 28490d1ba665SWarner Losh IN OUT CHAR16 *Path 28500d1ba665SWarner Losh ); 28510d1ba665SWarner Losh 28520d1ba665SWarner Losh /** 28530d1ba665SWarner Losh Function to clean up paths. 28540d1ba665SWarner Losh - Single periods in the path are removed. 28550d1ba665SWarner Losh - Double periods in the path are removed along with a single parent directory. 28560d1ba665SWarner Losh - Forward slashes L'/' are converted to backward slashes L'\'. 28570d1ba665SWarner Losh 28580d1ba665SWarner Losh This will be done inline and the existing buffer may be larger than required 28590d1ba665SWarner Losh upon completion. 28600d1ba665SWarner Losh 28610d1ba665SWarner Losh @param[in] Path The pointer to the string containing the path. 28620d1ba665SWarner Losh 28630d1ba665SWarner Losh @return Returns Path, otherwise returns NULL to indicate that an error has occurred. 28640d1ba665SWarner Losh **/ 28650d1ba665SWarner Losh CHAR16* 28660d1ba665SWarner Losh EFIAPI 28670d1ba665SWarner Losh PathCleanUpDirectories( 28680d1ba665SWarner Losh IN CHAR16 *Path 28690d1ba665SWarner Losh ); 28700d1ba665SWarner Losh 28710d1ba665SWarner Losh // 28720d1ba665SWarner Losh // Linked List Functions and Macros 28730d1ba665SWarner Losh // 28740d1ba665SWarner Losh 28750d1ba665SWarner Losh /** 28760d1ba665SWarner Losh Initializes the head node of a doubly linked list that is declared as a 28770d1ba665SWarner Losh global variable in a module. 28780d1ba665SWarner Losh 28790d1ba665SWarner Losh Initializes the forward and backward links of a new linked list. After 28800d1ba665SWarner Losh initializing a linked list with this macro, the other linked list functions 28810d1ba665SWarner Losh may be used to add and remove nodes from the linked list. This macro results 28820d1ba665SWarner Losh in smaller executables by initializing the linked list in the data section, 28830d1ba665SWarner Losh instead if calling the InitializeListHead() function to perform the 28840d1ba665SWarner Losh equivalent operation. 28850d1ba665SWarner Losh 28860d1ba665SWarner Losh @param ListHead The head note of a list to initialize. 28870d1ba665SWarner Losh 28880d1ba665SWarner Losh **/ 28890d1ba665SWarner Losh #define INITIALIZE_LIST_HEAD_VARIABLE(ListHead) {&(ListHead), &(ListHead)} 28900d1ba665SWarner Losh 2891*3245fa21SMitchell Horne /** 2892*3245fa21SMitchell Horne Iterates over each node in a doubly linked list using each node's forward link. 2893*3245fa21SMitchell Horne 2894*3245fa21SMitchell Horne @param Entry A pointer to a list node used as a loop cursor during iteration 2895*3245fa21SMitchell Horne @param ListHead The head node of the doubly linked list 2896*3245fa21SMitchell Horne 2897*3245fa21SMitchell Horne **/ 2898*3245fa21SMitchell Horne #define BASE_LIST_FOR_EACH(Entry, ListHead) \ 2899*3245fa21SMitchell Horne for(Entry = (ListHead)->ForwardLink; Entry != (ListHead); Entry = Entry->ForwardLink) 2900*3245fa21SMitchell Horne 2901*3245fa21SMitchell Horne /** 2902*3245fa21SMitchell Horne Iterates over each node in a doubly linked list using each node's forward link 2903*3245fa21SMitchell Horne with safety against node removal. 2904*3245fa21SMitchell Horne 2905*3245fa21SMitchell Horne This macro uses NextEntry to temporarily store the next list node so the node 2906*3245fa21SMitchell Horne pointed to by Entry may be deleted in the current loop iteration step and 2907*3245fa21SMitchell Horne iteration can continue from the node pointed to by NextEntry. 2908*3245fa21SMitchell Horne 2909*3245fa21SMitchell Horne @param Entry A pointer to a list node used as a loop cursor during iteration 2910*3245fa21SMitchell Horne @param NextEntry A pointer to a list node used to temporarily store the next node 2911*3245fa21SMitchell Horne @param ListHead The head node of the doubly linked list 2912*3245fa21SMitchell Horne 2913*3245fa21SMitchell Horne **/ 2914*3245fa21SMitchell Horne #define BASE_LIST_FOR_EACH_SAFE(Entry, NextEntry, ListHead) \ 2915*3245fa21SMitchell Horne for(Entry = (ListHead)->ForwardLink, NextEntry = Entry->ForwardLink;\ 2916*3245fa21SMitchell Horne Entry != (ListHead); Entry = NextEntry, NextEntry = Entry->ForwardLink) 2917*3245fa21SMitchell Horne 2918*3245fa21SMitchell Horne /** 2919*3245fa21SMitchell Horne Checks whether FirstEntry and SecondEntry are part of the same doubly-linked 2920*3245fa21SMitchell Horne list. 2921*3245fa21SMitchell Horne 2922*3245fa21SMitchell Horne If FirstEntry is NULL, then ASSERT(). 2923*3245fa21SMitchell Horne If FirstEntry->ForwardLink is NULL, then ASSERT(). 2924*3245fa21SMitchell Horne If FirstEntry->BackLink is NULL, then ASSERT(). 2925*3245fa21SMitchell Horne If SecondEntry is NULL, then ASSERT(); 2926*3245fa21SMitchell Horne If PcdMaximumLinkedListLength is not zero, and List contains more than 2927*3245fa21SMitchell Horne PcdMaximumLinkedListLength nodes, then ASSERT(). 2928*3245fa21SMitchell Horne 2929*3245fa21SMitchell Horne @param FirstEntry A pointer to a node in a linked list. 2930*3245fa21SMitchell Horne @param SecondEntry A pointer to the node to locate. 2931*3245fa21SMitchell Horne 2932*3245fa21SMitchell Horne @retval TRUE SecondEntry is in the same doubly-linked list as FirstEntry. 2933*3245fa21SMitchell Horne @retval FALSE SecondEntry isn't in the same doubly-linked list as FirstEntry, 2934*3245fa21SMitchell Horne or FirstEntry is invalid. 2935*3245fa21SMitchell Horne 2936*3245fa21SMitchell Horne **/ 2937*3245fa21SMitchell Horne BOOLEAN 2938*3245fa21SMitchell Horne EFIAPI 2939*3245fa21SMitchell Horne IsNodeInList ( 2940*3245fa21SMitchell Horne IN CONST LIST_ENTRY *FirstEntry, 2941*3245fa21SMitchell Horne IN CONST LIST_ENTRY *SecondEntry 2942*3245fa21SMitchell Horne ); 2943*3245fa21SMitchell Horne 29440d1ba665SWarner Losh 29450d1ba665SWarner Losh /** 29460d1ba665SWarner Losh Initializes the head node of a doubly linked list, and returns the pointer to 29470d1ba665SWarner Losh the head node of the doubly linked list. 29480d1ba665SWarner Losh 29490d1ba665SWarner Losh Initializes the forward and backward links of a new linked list. After 29500d1ba665SWarner Losh initializing a linked list with this function, the other linked list 29510d1ba665SWarner Losh functions may be used to add and remove nodes from the linked list. It is up 29520d1ba665SWarner Losh to the caller of this function to allocate the memory for ListHead. 29530d1ba665SWarner Losh 29540d1ba665SWarner Losh If ListHead is NULL, then ASSERT(). 29550d1ba665SWarner Losh 29560d1ba665SWarner Losh @param ListHead A pointer to the head node of a new doubly linked list. 29570d1ba665SWarner Losh 29580d1ba665SWarner Losh @return ListHead 29590d1ba665SWarner Losh 29600d1ba665SWarner Losh **/ 29610d1ba665SWarner Losh LIST_ENTRY * 29620d1ba665SWarner Losh EFIAPI 29630d1ba665SWarner Losh InitializeListHead ( 29640d1ba665SWarner Losh IN OUT LIST_ENTRY *ListHead 29650d1ba665SWarner Losh ); 29660d1ba665SWarner Losh 29670d1ba665SWarner Losh 29680d1ba665SWarner Losh /** 29690d1ba665SWarner Losh Adds a node to the beginning of a doubly linked list, and returns the pointer 29700d1ba665SWarner Losh to the head node of the doubly linked list. 29710d1ba665SWarner Losh 29720d1ba665SWarner Losh Adds the node Entry at the beginning of the doubly linked list denoted by 29730d1ba665SWarner Losh ListHead, and returns ListHead. 29740d1ba665SWarner Losh 29750d1ba665SWarner Losh If ListHead is NULL, then ASSERT(). 29760d1ba665SWarner Losh If Entry is NULL, then ASSERT(). 29770d1ba665SWarner Losh If ListHead was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or 29780d1ba665SWarner Losh InitializeListHead(), then ASSERT(). 29790d1ba665SWarner Losh If PcdMaximumLinkedListLength is not zero, and prior to insertion the number 29800d1ba665SWarner Losh of nodes in ListHead, including the ListHead node, is greater than or 29810d1ba665SWarner Losh equal to PcdMaximumLinkedListLength, then ASSERT(). 29820d1ba665SWarner Losh 29830d1ba665SWarner Losh @param ListHead A pointer to the head node of a doubly linked list. 29840d1ba665SWarner Losh @param Entry A pointer to a node that is to be inserted at the beginning 29850d1ba665SWarner Losh of a doubly linked list. 29860d1ba665SWarner Losh 29870d1ba665SWarner Losh @return ListHead 29880d1ba665SWarner Losh 29890d1ba665SWarner Losh **/ 29900d1ba665SWarner Losh LIST_ENTRY * 29910d1ba665SWarner Losh EFIAPI 29920d1ba665SWarner Losh InsertHeadList ( 29930d1ba665SWarner Losh IN OUT LIST_ENTRY *ListHead, 29940d1ba665SWarner Losh IN OUT LIST_ENTRY *Entry 29950d1ba665SWarner Losh ); 29960d1ba665SWarner Losh 29970d1ba665SWarner Losh 29980d1ba665SWarner Losh /** 29990d1ba665SWarner Losh Adds a node to the end of a doubly linked list, and returns the pointer to 30000d1ba665SWarner Losh the head node of the doubly linked list. 30010d1ba665SWarner Losh 30020d1ba665SWarner Losh Adds the node Entry to the end of the doubly linked list denoted by ListHead, 30030d1ba665SWarner Losh and returns ListHead. 30040d1ba665SWarner Losh 30050d1ba665SWarner Losh If ListHead is NULL, then ASSERT(). 30060d1ba665SWarner Losh If Entry is NULL, then ASSERT(). 30070d1ba665SWarner Losh If ListHead was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or 30080d1ba665SWarner Losh InitializeListHead(), then ASSERT(). 30090d1ba665SWarner Losh If PcdMaximumLinkedListLength is not zero, and prior to insertion the number 30100d1ba665SWarner Losh of nodes in ListHead, including the ListHead node, is greater than or 30110d1ba665SWarner Losh equal to PcdMaximumLinkedListLength, then ASSERT(). 30120d1ba665SWarner Losh 30130d1ba665SWarner Losh @param ListHead A pointer to the head node of a doubly linked list. 30140d1ba665SWarner Losh @param Entry A pointer to a node that is to be added at the end of the 30150d1ba665SWarner Losh doubly linked list. 30160d1ba665SWarner Losh 30170d1ba665SWarner Losh @return ListHead 30180d1ba665SWarner Losh 30190d1ba665SWarner Losh **/ 30200d1ba665SWarner Losh LIST_ENTRY * 30210d1ba665SWarner Losh EFIAPI 30220d1ba665SWarner Losh InsertTailList ( 30230d1ba665SWarner Losh IN OUT LIST_ENTRY *ListHead, 30240d1ba665SWarner Losh IN OUT LIST_ENTRY *Entry 30250d1ba665SWarner Losh ); 30260d1ba665SWarner Losh 30270d1ba665SWarner Losh 30280d1ba665SWarner Losh /** 30290d1ba665SWarner Losh Retrieves the first node of a doubly linked list. 30300d1ba665SWarner Losh 30310d1ba665SWarner Losh Returns the first node of a doubly linked list. List must have been 30320d1ba665SWarner Losh initialized with INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead(). 30330d1ba665SWarner Losh If List is empty, then List is returned. 30340d1ba665SWarner Losh 30350d1ba665SWarner Losh If List is NULL, then ASSERT(). 30360d1ba665SWarner Losh If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or 30370d1ba665SWarner Losh InitializeListHead(), then ASSERT(). 30380d1ba665SWarner Losh If PcdMaximumLinkedListLength is not zero, and the number of nodes 30390d1ba665SWarner Losh in List, including the List node, is greater than or equal to 30400d1ba665SWarner Losh PcdMaximumLinkedListLength, then ASSERT(). 30410d1ba665SWarner Losh 30420d1ba665SWarner Losh @param List A pointer to the head node of a doubly linked list. 30430d1ba665SWarner Losh 30440d1ba665SWarner Losh @return The first node of a doubly linked list. 30450d1ba665SWarner Losh @retval List The list is empty. 30460d1ba665SWarner Losh 30470d1ba665SWarner Losh **/ 30480d1ba665SWarner Losh LIST_ENTRY * 30490d1ba665SWarner Losh EFIAPI 30500d1ba665SWarner Losh GetFirstNode ( 30510d1ba665SWarner Losh IN CONST LIST_ENTRY *List 30520d1ba665SWarner Losh ); 30530d1ba665SWarner Losh 30540d1ba665SWarner Losh 30550d1ba665SWarner Losh /** 30560d1ba665SWarner Losh Retrieves the next node of a doubly linked list. 30570d1ba665SWarner Losh 30580d1ba665SWarner Losh Returns the node of a doubly linked list that follows Node. 30590d1ba665SWarner Losh List must have been initialized with INTIALIZE_LIST_HEAD_VARIABLE() 30600d1ba665SWarner Losh or InitializeListHead(). If List is empty, then List is returned. 30610d1ba665SWarner Losh 30620d1ba665SWarner Losh If List is NULL, then ASSERT(). 30630d1ba665SWarner Losh If Node is NULL, then ASSERT(). 30640d1ba665SWarner Losh If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or 30650d1ba665SWarner Losh InitializeListHead(), then ASSERT(). 30660d1ba665SWarner Losh If PcdMaximumLinkedListLength is not zero, and List contains more than 30670d1ba665SWarner Losh PcdMaximumLinkedListLength nodes, then ASSERT(). 30680d1ba665SWarner Losh If PcdVerifyNodeInList is TRUE and Node is not a node in List, then ASSERT(). 30690d1ba665SWarner Losh 30700d1ba665SWarner Losh @param List A pointer to the head node of a doubly linked list. 30710d1ba665SWarner Losh @param Node A pointer to a node in the doubly linked list. 30720d1ba665SWarner Losh 30730d1ba665SWarner Losh @return The pointer to the next node if one exists. Otherwise List is returned. 30740d1ba665SWarner Losh 30750d1ba665SWarner Losh **/ 30760d1ba665SWarner Losh LIST_ENTRY * 30770d1ba665SWarner Losh EFIAPI 30780d1ba665SWarner Losh GetNextNode ( 30790d1ba665SWarner Losh IN CONST LIST_ENTRY *List, 30800d1ba665SWarner Losh IN CONST LIST_ENTRY *Node 30810d1ba665SWarner Losh ); 30820d1ba665SWarner Losh 30830d1ba665SWarner Losh 30840d1ba665SWarner Losh /** 30850d1ba665SWarner Losh Retrieves the previous node of a doubly linked list. 30860d1ba665SWarner Losh 30870d1ba665SWarner Losh Returns the node of a doubly linked list that precedes Node. 30880d1ba665SWarner Losh List must have been initialized with INTIALIZE_LIST_HEAD_VARIABLE() 30890d1ba665SWarner Losh or InitializeListHead(). If List is empty, then List is returned. 30900d1ba665SWarner Losh 30910d1ba665SWarner Losh If List is NULL, then ASSERT(). 30920d1ba665SWarner Losh If Node is NULL, then ASSERT(). 30930d1ba665SWarner Losh If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or 30940d1ba665SWarner Losh InitializeListHead(), then ASSERT(). 30950d1ba665SWarner Losh If PcdMaximumLinkedListLength is not zero, and List contains more than 30960d1ba665SWarner Losh PcdMaximumLinkedListLength nodes, then ASSERT(). 30970d1ba665SWarner Losh If PcdVerifyNodeInList is TRUE and Node is not a node in List, then ASSERT(). 30980d1ba665SWarner Losh 30990d1ba665SWarner Losh @param List A pointer to the head node of a doubly linked list. 31000d1ba665SWarner Losh @param Node A pointer to a node in the doubly linked list. 31010d1ba665SWarner Losh 31020d1ba665SWarner Losh @return The pointer to the previous node if one exists. Otherwise List is returned. 31030d1ba665SWarner Losh 31040d1ba665SWarner Losh **/ 31050d1ba665SWarner Losh LIST_ENTRY * 31060d1ba665SWarner Losh EFIAPI 31070d1ba665SWarner Losh GetPreviousNode ( 31080d1ba665SWarner Losh IN CONST LIST_ENTRY *List, 31090d1ba665SWarner Losh IN CONST LIST_ENTRY *Node 31100d1ba665SWarner Losh ); 31110d1ba665SWarner Losh 31120d1ba665SWarner Losh 31130d1ba665SWarner Losh /** 31140d1ba665SWarner Losh Checks to see if a doubly linked list is empty or not. 31150d1ba665SWarner Losh 31160d1ba665SWarner Losh Checks to see if the doubly linked list is empty. If the linked list contains 31170d1ba665SWarner Losh zero nodes, this function returns TRUE. Otherwise, it returns FALSE. 31180d1ba665SWarner Losh 31190d1ba665SWarner Losh If ListHead is NULL, then ASSERT(). 31200d1ba665SWarner Losh If ListHead was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or 31210d1ba665SWarner Losh InitializeListHead(), then ASSERT(). 31220d1ba665SWarner Losh If PcdMaximumLinkedListLength is not zero, and the number of nodes 31230d1ba665SWarner Losh in List, including the List node, is greater than or equal to 31240d1ba665SWarner Losh PcdMaximumLinkedListLength, then ASSERT(). 31250d1ba665SWarner Losh 31260d1ba665SWarner Losh @param ListHead A pointer to the head node of a doubly linked list. 31270d1ba665SWarner Losh 31280d1ba665SWarner Losh @retval TRUE The linked list is empty. 31290d1ba665SWarner Losh @retval FALSE The linked list is not empty. 31300d1ba665SWarner Losh 31310d1ba665SWarner Losh **/ 31320d1ba665SWarner Losh BOOLEAN 31330d1ba665SWarner Losh EFIAPI 31340d1ba665SWarner Losh IsListEmpty ( 31350d1ba665SWarner Losh IN CONST LIST_ENTRY *ListHead 31360d1ba665SWarner Losh ); 31370d1ba665SWarner Losh 31380d1ba665SWarner Losh 31390d1ba665SWarner Losh /** 31400d1ba665SWarner Losh Determines if a node in a doubly linked list is the head node of a the same 31410d1ba665SWarner Losh doubly linked list. This function is typically used to terminate a loop that 31420d1ba665SWarner Losh traverses all the nodes in a doubly linked list starting with the head node. 31430d1ba665SWarner Losh 31440d1ba665SWarner Losh Returns TRUE if Node is equal to List. Returns FALSE if Node is one of the 31450d1ba665SWarner Losh nodes in the doubly linked list specified by List. List must have been 31460d1ba665SWarner Losh initialized with INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead(). 31470d1ba665SWarner Losh 31480d1ba665SWarner Losh If List is NULL, then ASSERT(). 31490d1ba665SWarner Losh If Node is NULL, then ASSERT(). 31500d1ba665SWarner Losh If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead(), 31510d1ba665SWarner Losh then ASSERT(). 31520d1ba665SWarner Losh If PcdMaximumLinkedListLength is not zero, and the number of nodes 31530d1ba665SWarner Losh in List, including the List node, is greater than or equal to 31540d1ba665SWarner Losh PcdMaximumLinkedListLength, then ASSERT(). 31550d1ba665SWarner Losh If PcdVerifyNodeInList is TRUE and Node is not a node in List the and Node is not equal 31560d1ba665SWarner Losh to List, then ASSERT(). 31570d1ba665SWarner Losh 31580d1ba665SWarner Losh @param List A pointer to the head node of a doubly linked list. 31590d1ba665SWarner Losh @param Node A pointer to a node in the doubly linked list. 31600d1ba665SWarner Losh 31610d1ba665SWarner Losh @retval TRUE Node is the head of the doubly-linked list pointed by List. 31620d1ba665SWarner Losh @retval FALSE Node is not the head of the doubly-linked list pointed by List. 31630d1ba665SWarner Losh 31640d1ba665SWarner Losh **/ 31650d1ba665SWarner Losh BOOLEAN 31660d1ba665SWarner Losh EFIAPI 31670d1ba665SWarner Losh IsNull ( 31680d1ba665SWarner Losh IN CONST LIST_ENTRY *List, 31690d1ba665SWarner Losh IN CONST LIST_ENTRY *Node 31700d1ba665SWarner Losh ); 31710d1ba665SWarner Losh 31720d1ba665SWarner Losh 31730d1ba665SWarner Losh /** 31740d1ba665SWarner Losh Determines if a node the last node in a doubly linked list. 31750d1ba665SWarner Losh 31760d1ba665SWarner Losh Returns TRUE if Node is the last node in the doubly linked list specified by 31770d1ba665SWarner Losh List. Otherwise, FALSE is returned. List must have been initialized with 31780d1ba665SWarner Losh INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead(). 31790d1ba665SWarner Losh 31800d1ba665SWarner Losh If List is NULL, then ASSERT(). 31810d1ba665SWarner Losh If Node is NULL, then ASSERT(). 31820d1ba665SWarner Losh If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or 31830d1ba665SWarner Losh InitializeListHead(), then ASSERT(). 31840d1ba665SWarner Losh If PcdMaximumLinkedListLength is not zero, and the number of nodes 31850d1ba665SWarner Losh in List, including the List node, is greater than or equal to 31860d1ba665SWarner Losh PcdMaximumLinkedListLength, then ASSERT(). 31870d1ba665SWarner Losh If PcdVerifyNodeInList is TRUE and Node is not a node in List, then ASSERT(). 31880d1ba665SWarner Losh 31890d1ba665SWarner Losh @param List A pointer to the head node of a doubly linked list. 31900d1ba665SWarner Losh @param Node A pointer to a node in the doubly linked list. 31910d1ba665SWarner Losh 31920d1ba665SWarner Losh @retval TRUE Node is the last node in the linked list. 31930d1ba665SWarner Losh @retval FALSE Node is not the last node in the linked list. 31940d1ba665SWarner Losh 31950d1ba665SWarner Losh **/ 31960d1ba665SWarner Losh BOOLEAN 31970d1ba665SWarner Losh EFIAPI 31980d1ba665SWarner Losh IsNodeAtEnd ( 31990d1ba665SWarner Losh IN CONST LIST_ENTRY *List, 32000d1ba665SWarner Losh IN CONST LIST_ENTRY *Node 32010d1ba665SWarner Losh ); 32020d1ba665SWarner Losh 32030d1ba665SWarner Losh 32040d1ba665SWarner Losh /** 32050d1ba665SWarner Losh Swaps the location of two nodes in a doubly linked list, and returns the 32060d1ba665SWarner Losh first node after the swap. 32070d1ba665SWarner Losh 32080d1ba665SWarner Losh If FirstEntry is identical to SecondEntry, then SecondEntry is returned. 32090d1ba665SWarner Losh Otherwise, the location of the FirstEntry node is swapped with the location 32100d1ba665SWarner Losh of the SecondEntry node in a doubly linked list. SecondEntry must be in the 32110d1ba665SWarner Losh same double linked list as FirstEntry and that double linked list must have 32120d1ba665SWarner Losh been initialized with INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead(). 32130d1ba665SWarner Losh SecondEntry is returned after the nodes are swapped. 32140d1ba665SWarner Losh 32150d1ba665SWarner Losh If FirstEntry is NULL, then ASSERT(). 32160d1ba665SWarner Losh If SecondEntry is NULL, then ASSERT(). 32170d1ba665SWarner Losh If PcdVerifyNodeInList is TRUE and SecondEntry and FirstEntry are not in the 32180d1ba665SWarner Losh same linked list, then ASSERT(). 32190d1ba665SWarner Losh If PcdMaximumLinkedListLength is not zero, and the number of nodes in the 32200d1ba665SWarner Losh linked list containing the FirstEntry and SecondEntry nodes, including 32210d1ba665SWarner Losh the FirstEntry and SecondEntry nodes, is greater than or equal to 32220d1ba665SWarner Losh PcdMaximumLinkedListLength, then ASSERT(). 32230d1ba665SWarner Losh 32240d1ba665SWarner Losh @param FirstEntry A pointer to a node in a linked list. 32250d1ba665SWarner Losh @param SecondEntry A pointer to another node in the same linked list. 32260d1ba665SWarner Losh 32270d1ba665SWarner Losh @return SecondEntry. 32280d1ba665SWarner Losh 32290d1ba665SWarner Losh **/ 32300d1ba665SWarner Losh LIST_ENTRY * 32310d1ba665SWarner Losh EFIAPI 32320d1ba665SWarner Losh SwapListEntries ( 32330d1ba665SWarner Losh IN OUT LIST_ENTRY *FirstEntry, 32340d1ba665SWarner Losh IN OUT LIST_ENTRY *SecondEntry 32350d1ba665SWarner Losh ); 32360d1ba665SWarner Losh 32370d1ba665SWarner Losh 32380d1ba665SWarner Losh /** 32390d1ba665SWarner Losh Removes a node from a doubly linked list, and returns the node that follows 32400d1ba665SWarner Losh the removed node. 32410d1ba665SWarner Losh 32420d1ba665SWarner Losh Removes the node Entry from a doubly linked list. It is up to the caller of 32430d1ba665SWarner Losh this function to release the memory used by this node if that is required. On 32440d1ba665SWarner Losh exit, the node following Entry in the doubly linked list is returned. If 32450d1ba665SWarner Losh Entry is the only node in the linked list, then the head node of the linked 32460d1ba665SWarner Losh list is returned. 32470d1ba665SWarner Losh 32480d1ba665SWarner Losh If Entry is NULL, then ASSERT(). 32490d1ba665SWarner Losh If Entry is the head node of an empty list, then ASSERT(). 32500d1ba665SWarner Losh If PcdMaximumLinkedListLength is not zero, and the number of nodes in the 32510d1ba665SWarner Losh linked list containing Entry, including the Entry node, is greater than 32520d1ba665SWarner Losh or equal to PcdMaximumLinkedListLength, then ASSERT(). 32530d1ba665SWarner Losh 32540d1ba665SWarner Losh @param Entry A pointer to a node in a linked list. 32550d1ba665SWarner Losh 32560d1ba665SWarner Losh @return Entry. 32570d1ba665SWarner Losh 32580d1ba665SWarner Losh **/ 32590d1ba665SWarner Losh LIST_ENTRY * 32600d1ba665SWarner Losh EFIAPI 32610d1ba665SWarner Losh RemoveEntryList ( 32620d1ba665SWarner Losh IN CONST LIST_ENTRY *Entry 32630d1ba665SWarner Losh ); 32640d1ba665SWarner Losh 32650d1ba665SWarner Losh // 32660d1ba665SWarner Losh // Math Services 32670d1ba665SWarner Losh // 32680d1ba665SWarner Losh 32690d1ba665SWarner Losh /** 32700d1ba665SWarner Losh Shifts a 64-bit integer left between 0 and 63 bits. The low bits are filled 32710d1ba665SWarner Losh with zeros. The shifted value is returned. 32720d1ba665SWarner Losh 32730d1ba665SWarner Losh This function shifts the 64-bit value Operand to the left by Count bits. The 32740d1ba665SWarner Losh low Count bits are set to zero. The shifted value is returned. 32750d1ba665SWarner Losh 32760d1ba665SWarner Losh If Count is greater than 63, then ASSERT(). 32770d1ba665SWarner Losh 32780d1ba665SWarner Losh @param Operand The 64-bit operand to shift left. 32790d1ba665SWarner Losh @param Count The number of bits to shift left. 32800d1ba665SWarner Losh 32810d1ba665SWarner Losh @return Operand << Count. 32820d1ba665SWarner Losh 32830d1ba665SWarner Losh **/ 32840d1ba665SWarner Losh UINT64 32850d1ba665SWarner Losh EFIAPI 32860d1ba665SWarner Losh LShiftU64 ( 32870d1ba665SWarner Losh IN UINT64 Operand, 32880d1ba665SWarner Losh IN UINTN Count 32890d1ba665SWarner Losh ); 32900d1ba665SWarner Losh 32910d1ba665SWarner Losh 32920d1ba665SWarner Losh /** 32930d1ba665SWarner Losh Shifts a 64-bit integer right between 0 and 63 bits. This high bits are 32940d1ba665SWarner Losh filled with zeros. The shifted value is returned. 32950d1ba665SWarner Losh 32960d1ba665SWarner Losh This function shifts the 64-bit value Operand to the right by Count bits. The 32970d1ba665SWarner Losh high Count bits are set to zero. The shifted value is returned. 32980d1ba665SWarner Losh 32990d1ba665SWarner Losh If Count is greater than 63, then ASSERT(). 33000d1ba665SWarner Losh 33010d1ba665SWarner Losh @param Operand The 64-bit operand to shift right. 33020d1ba665SWarner Losh @param Count The number of bits to shift right. 33030d1ba665SWarner Losh 33040d1ba665SWarner Losh @return Operand >> Count 33050d1ba665SWarner Losh 33060d1ba665SWarner Losh **/ 33070d1ba665SWarner Losh UINT64 33080d1ba665SWarner Losh EFIAPI 33090d1ba665SWarner Losh RShiftU64 ( 33100d1ba665SWarner Losh IN UINT64 Operand, 33110d1ba665SWarner Losh IN UINTN Count 33120d1ba665SWarner Losh ); 33130d1ba665SWarner Losh 33140d1ba665SWarner Losh 33150d1ba665SWarner Losh /** 33160d1ba665SWarner Losh Shifts a 64-bit integer right between 0 and 63 bits. The high bits are filled 33170d1ba665SWarner Losh with original integer's bit 63. The shifted value is returned. 33180d1ba665SWarner Losh 33190d1ba665SWarner Losh This function shifts the 64-bit value Operand to the right by Count bits. The 33200d1ba665SWarner Losh high Count bits are set to bit 63 of Operand. The shifted value is returned. 33210d1ba665SWarner Losh 33220d1ba665SWarner Losh If Count is greater than 63, then ASSERT(). 33230d1ba665SWarner Losh 33240d1ba665SWarner Losh @param Operand The 64-bit operand to shift right. 33250d1ba665SWarner Losh @param Count The number of bits to shift right. 33260d1ba665SWarner Losh 33270d1ba665SWarner Losh @return Operand >> Count 33280d1ba665SWarner Losh 33290d1ba665SWarner Losh **/ 33300d1ba665SWarner Losh UINT64 33310d1ba665SWarner Losh EFIAPI 33320d1ba665SWarner Losh ARShiftU64 ( 33330d1ba665SWarner Losh IN UINT64 Operand, 33340d1ba665SWarner Losh IN UINTN Count 33350d1ba665SWarner Losh ); 33360d1ba665SWarner Losh 33370d1ba665SWarner Losh 33380d1ba665SWarner Losh /** 33390d1ba665SWarner Losh Rotates a 32-bit integer left between 0 and 31 bits, filling the low bits 33400d1ba665SWarner Losh with the high bits that were rotated. 33410d1ba665SWarner Losh 33420d1ba665SWarner Losh This function rotates the 32-bit value Operand to the left by Count bits. The 33430d1ba665SWarner Losh low Count bits are fill with the high Count bits of Operand. The rotated 33440d1ba665SWarner Losh value is returned. 33450d1ba665SWarner Losh 33460d1ba665SWarner Losh If Count is greater than 31, then ASSERT(). 33470d1ba665SWarner Losh 33480d1ba665SWarner Losh @param Operand The 32-bit operand to rotate left. 33490d1ba665SWarner Losh @param Count The number of bits to rotate left. 33500d1ba665SWarner Losh 33510d1ba665SWarner Losh @return Operand << Count 33520d1ba665SWarner Losh 33530d1ba665SWarner Losh **/ 33540d1ba665SWarner Losh UINT32 33550d1ba665SWarner Losh EFIAPI 33560d1ba665SWarner Losh LRotU32 ( 33570d1ba665SWarner Losh IN UINT32 Operand, 33580d1ba665SWarner Losh IN UINTN Count 33590d1ba665SWarner Losh ); 33600d1ba665SWarner Losh 33610d1ba665SWarner Losh 33620d1ba665SWarner Losh /** 33630d1ba665SWarner Losh Rotates a 32-bit integer right between 0 and 31 bits, filling the high bits 33640d1ba665SWarner Losh with the low bits that were rotated. 33650d1ba665SWarner Losh 33660d1ba665SWarner Losh This function rotates the 32-bit value Operand to the right by Count bits. 33670d1ba665SWarner Losh The high Count bits are fill with the low Count bits of Operand. The rotated 33680d1ba665SWarner Losh value is returned. 33690d1ba665SWarner Losh 33700d1ba665SWarner Losh If Count is greater than 31, then ASSERT(). 33710d1ba665SWarner Losh 33720d1ba665SWarner Losh @param Operand The 32-bit operand to rotate right. 33730d1ba665SWarner Losh @param Count The number of bits to rotate right. 33740d1ba665SWarner Losh 33750d1ba665SWarner Losh @return Operand >> Count 33760d1ba665SWarner Losh 33770d1ba665SWarner Losh **/ 33780d1ba665SWarner Losh UINT32 33790d1ba665SWarner Losh EFIAPI 33800d1ba665SWarner Losh RRotU32 ( 33810d1ba665SWarner Losh IN UINT32 Operand, 33820d1ba665SWarner Losh IN UINTN Count 33830d1ba665SWarner Losh ); 33840d1ba665SWarner Losh 33850d1ba665SWarner Losh 33860d1ba665SWarner Losh /** 33870d1ba665SWarner Losh Rotates a 64-bit integer left between 0 and 63 bits, filling the low bits 33880d1ba665SWarner Losh with the high bits that were rotated. 33890d1ba665SWarner Losh 33900d1ba665SWarner Losh This function rotates the 64-bit value Operand to the left by Count bits. The 33910d1ba665SWarner Losh low Count bits are fill with the high Count bits of Operand. The rotated 33920d1ba665SWarner Losh value is returned. 33930d1ba665SWarner Losh 33940d1ba665SWarner Losh If Count is greater than 63, then ASSERT(). 33950d1ba665SWarner Losh 33960d1ba665SWarner Losh @param Operand The 64-bit operand to rotate left. 33970d1ba665SWarner Losh @param Count The number of bits to rotate left. 33980d1ba665SWarner Losh 33990d1ba665SWarner Losh @return Operand << Count 34000d1ba665SWarner Losh 34010d1ba665SWarner Losh **/ 34020d1ba665SWarner Losh UINT64 34030d1ba665SWarner Losh EFIAPI 34040d1ba665SWarner Losh LRotU64 ( 34050d1ba665SWarner Losh IN UINT64 Operand, 34060d1ba665SWarner Losh IN UINTN Count 34070d1ba665SWarner Losh ); 34080d1ba665SWarner Losh 34090d1ba665SWarner Losh 34100d1ba665SWarner Losh /** 34110d1ba665SWarner Losh Rotates a 64-bit integer right between 0 and 63 bits, filling the high bits 34120d1ba665SWarner Losh with the high low bits that were rotated. 34130d1ba665SWarner Losh 34140d1ba665SWarner Losh This function rotates the 64-bit value Operand to the right by Count bits. 34150d1ba665SWarner Losh The high Count bits are fill with the low Count bits of Operand. The rotated 34160d1ba665SWarner Losh value is returned. 34170d1ba665SWarner Losh 34180d1ba665SWarner Losh If Count is greater than 63, then ASSERT(). 34190d1ba665SWarner Losh 34200d1ba665SWarner Losh @param Operand The 64-bit operand to rotate right. 34210d1ba665SWarner Losh @param Count The number of bits to rotate right. 34220d1ba665SWarner Losh 34230d1ba665SWarner Losh @return Operand >> Count 34240d1ba665SWarner Losh 34250d1ba665SWarner Losh **/ 34260d1ba665SWarner Losh UINT64 34270d1ba665SWarner Losh EFIAPI 34280d1ba665SWarner Losh RRotU64 ( 34290d1ba665SWarner Losh IN UINT64 Operand, 34300d1ba665SWarner Losh IN UINTN Count 34310d1ba665SWarner Losh ); 34320d1ba665SWarner Losh 34330d1ba665SWarner Losh 34340d1ba665SWarner Losh /** 34350d1ba665SWarner Losh Returns the bit position of the lowest bit set in a 32-bit value. 34360d1ba665SWarner Losh 34370d1ba665SWarner Losh This function computes the bit position of the lowest bit set in the 32-bit 34380d1ba665SWarner Losh value specified by Operand. If Operand is zero, then -1 is returned. 34390d1ba665SWarner Losh Otherwise, a value between 0 and 31 is returned. 34400d1ba665SWarner Losh 34410d1ba665SWarner Losh @param Operand The 32-bit operand to evaluate. 34420d1ba665SWarner Losh 34430d1ba665SWarner Losh @retval 0..31 The lowest bit set in Operand was found. 34440d1ba665SWarner Losh @retval -1 Operand is zero. 34450d1ba665SWarner Losh 34460d1ba665SWarner Losh **/ 34470d1ba665SWarner Losh INTN 34480d1ba665SWarner Losh EFIAPI 34490d1ba665SWarner Losh LowBitSet32 ( 34500d1ba665SWarner Losh IN UINT32 Operand 34510d1ba665SWarner Losh ); 34520d1ba665SWarner Losh 34530d1ba665SWarner Losh 34540d1ba665SWarner Losh /** 34550d1ba665SWarner Losh Returns the bit position of the lowest bit set in a 64-bit value. 34560d1ba665SWarner Losh 34570d1ba665SWarner Losh This function computes the bit position of the lowest bit set in the 64-bit 34580d1ba665SWarner Losh value specified by Operand. If Operand is zero, then -1 is returned. 34590d1ba665SWarner Losh Otherwise, a value between 0 and 63 is returned. 34600d1ba665SWarner Losh 34610d1ba665SWarner Losh @param Operand The 64-bit operand to evaluate. 34620d1ba665SWarner Losh 34630d1ba665SWarner Losh @retval 0..63 The lowest bit set in Operand was found. 34640d1ba665SWarner Losh @retval -1 Operand is zero. 34650d1ba665SWarner Losh 34660d1ba665SWarner Losh 34670d1ba665SWarner Losh **/ 34680d1ba665SWarner Losh INTN 34690d1ba665SWarner Losh EFIAPI 34700d1ba665SWarner Losh LowBitSet64 ( 34710d1ba665SWarner Losh IN UINT64 Operand 34720d1ba665SWarner Losh ); 34730d1ba665SWarner Losh 34740d1ba665SWarner Losh 34750d1ba665SWarner Losh /** 34760d1ba665SWarner Losh Returns the bit position of the highest bit set in a 32-bit value. Equivalent 34770d1ba665SWarner Losh to log2(x). 34780d1ba665SWarner Losh 34790d1ba665SWarner Losh This function computes the bit position of the highest bit set in the 32-bit 34800d1ba665SWarner Losh value specified by Operand. If Operand is zero, then -1 is returned. 34810d1ba665SWarner Losh Otherwise, a value between 0 and 31 is returned. 34820d1ba665SWarner Losh 34830d1ba665SWarner Losh @param Operand The 32-bit operand to evaluate. 34840d1ba665SWarner Losh 34850d1ba665SWarner Losh @retval 0..31 Position of the highest bit set in Operand if found. 34860d1ba665SWarner Losh @retval -1 Operand is zero. 34870d1ba665SWarner Losh 34880d1ba665SWarner Losh **/ 34890d1ba665SWarner Losh INTN 34900d1ba665SWarner Losh EFIAPI 34910d1ba665SWarner Losh HighBitSet32 ( 34920d1ba665SWarner Losh IN UINT32 Operand 34930d1ba665SWarner Losh ); 34940d1ba665SWarner Losh 34950d1ba665SWarner Losh 34960d1ba665SWarner Losh /** 34970d1ba665SWarner Losh Returns the bit position of the highest bit set in a 64-bit value. Equivalent 34980d1ba665SWarner Losh to log2(x). 34990d1ba665SWarner Losh 35000d1ba665SWarner Losh This function computes the bit position of the highest bit set in the 64-bit 35010d1ba665SWarner Losh value specified by Operand. If Operand is zero, then -1 is returned. 35020d1ba665SWarner Losh Otherwise, a value between 0 and 63 is returned. 35030d1ba665SWarner Losh 35040d1ba665SWarner Losh @param Operand The 64-bit operand to evaluate. 35050d1ba665SWarner Losh 35060d1ba665SWarner Losh @retval 0..63 Position of the highest bit set in Operand if found. 35070d1ba665SWarner Losh @retval -1 Operand is zero. 35080d1ba665SWarner Losh 35090d1ba665SWarner Losh **/ 35100d1ba665SWarner Losh INTN 35110d1ba665SWarner Losh EFIAPI 35120d1ba665SWarner Losh HighBitSet64 ( 35130d1ba665SWarner Losh IN UINT64 Operand 35140d1ba665SWarner Losh ); 35150d1ba665SWarner Losh 35160d1ba665SWarner Losh 35170d1ba665SWarner Losh /** 35180d1ba665SWarner Losh Returns the value of the highest bit set in a 32-bit value. Equivalent to 35190d1ba665SWarner Losh 1 << log2(x). 35200d1ba665SWarner Losh 35210d1ba665SWarner Losh This function computes the value of the highest bit set in the 32-bit value 35220d1ba665SWarner Losh specified by Operand. If Operand is zero, then zero is returned. 35230d1ba665SWarner Losh 35240d1ba665SWarner Losh @param Operand The 32-bit operand to evaluate. 35250d1ba665SWarner Losh 35260d1ba665SWarner Losh @return 1 << HighBitSet32(Operand) 35270d1ba665SWarner Losh @retval 0 Operand is zero. 35280d1ba665SWarner Losh 35290d1ba665SWarner Losh **/ 35300d1ba665SWarner Losh UINT32 35310d1ba665SWarner Losh EFIAPI 35320d1ba665SWarner Losh GetPowerOfTwo32 ( 35330d1ba665SWarner Losh IN UINT32 Operand 35340d1ba665SWarner Losh ); 35350d1ba665SWarner Losh 35360d1ba665SWarner Losh 35370d1ba665SWarner Losh /** 35380d1ba665SWarner Losh Returns the value of the highest bit set in a 64-bit value. Equivalent to 35390d1ba665SWarner Losh 1 << log2(x). 35400d1ba665SWarner Losh 35410d1ba665SWarner Losh This function computes the value of the highest bit set in the 64-bit value 35420d1ba665SWarner Losh specified by Operand. If Operand is zero, then zero is returned. 35430d1ba665SWarner Losh 35440d1ba665SWarner Losh @param Operand The 64-bit operand to evaluate. 35450d1ba665SWarner Losh 35460d1ba665SWarner Losh @return 1 << HighBitSet64(Operand) 35470d1ba665SWarner Losh @retval 0 Operand is zero. 35480d1ba665SWarner Losh 35490d1ba665SWarner Losh **/ 35500d1ba665SWarner Losh UINT64 35510d1ba665SWarner Losh EFIAPI 35520d1ba665SWarner Losh GetPowerOfTwo64 ( 35530d1ba665SWarner Losh IN UINT64 Operand 35540d1ba665SWarner Losh ); 35550d1ba665SWarner Losh 35560d1ba665SWarner Losh 35570d1ba665SWarner Losh /** 35580d1ba665SWarner Losh Switches the endianness of a 16-bit integer. 35590d1ba665SWarner Losh 35600d1ba665SWarner Losh This function swaps the bytes in a 16-bit unsigned value to switch the value 35610d1ba665SWarner Losh from little endian to big endian or vice versa. The byte swapped value is 35620d1ba665SWarner Losh returned. 35630d1ba665SWarner Losh 35640d1ba665SWarner Losh @param Value A 16-bit unsigned value. 35650d1ba665SWarner Losh 35660d1ba665SWarner Losh @return The byte swapped Value. 35670d1ba665SWarner Losh 35680d1ba665SWarner Losh **/ 35690d1ba665SWarner Losh UINT16 35700d1ba665SWarner Losh EFIAPI 35710d1ba665SWarner Losh SwapBytes16 ( 35720d1ba665SWarner Losh IN UINT16 Value 35730d1ba665SWarner Losh ); 35740d1ba665SWarner Losh 35750d1ba665SWarner Losh 35760d1ba665SWarner Losh /** 35770d1ba665SWarner Losh Switches the endianness of a 32-bit integer. 35780d1ba665SWarner Losh 35790d1ba665SWarner Losh This function swaps the bytes in a 32-bit unsigned value to switch the value 35800d1ba665SWarner Losh from little endian to big endian or vice versa. The byte swapped value is 35810d1ba665SWarner Losh returned. 35820d1ba665SWarner Losh 35830d1ba665SWarner Losh @param Value A 32-bit unsigned value. 35840d1ba665SWarner Losh 35850d1ba665SWarner Losh @return The byte swapped Value. 35860d1ba665SWarner Losh 35870d1ba665SWarner Losh **/ 35880d1ba665SWarner Losh UINT32 35890d1ba665SWarner Losh EFIAPI 35900d1ba665SWarner Losh SwapBytes32 ( 35910d1ba665SWarner Losh IN UINT32 Value 35920d1ba665SWarner Losh ); 35930d1ba665SWarner Losh 35940d1ba665SWarner Losh 35950d1ba665SWarner Losh /** 35960d1ba665SWarner Losh Switches the endianness of a 64-bit integer. 35970d1ba665SWarner Losh 35980d1ba665SWarner Losh This function swaps the bytes in a 64-bit unsigned value to switch the value 35990d1ba665SWarner Losh from little endian to big endian or vice versa. The byte swapped value is 36000d1ba665SWarner Losh returned. 36010d1ba665SWarner Losh 36020d1ba665SWarner Losh @param Value A 64-bit unsigned value. 36030d1ba665SWarner Losh 36040d1ba665SWarner Losh @return The byte swapped Value. 36050d1ba665SWarner Losh 36060d1ba665SWarner Losh **/ 36070d1ba665SWarner Losh UINT64 36080d1ba665SWarner Losh EFIAPI 36090d1ba665SWarner Losh SwapBytes64 ( 36100d1ba665SWarner Losh IN UINT64 Value 36110d1ba665SWarner Losh ); 36120d1ba665SWarner Losh 36130d1ba665SWarner Losh 36140d1ba665SWarner Losh /** 36150d1ba665SWarner Losh Multiples a 64-bit unsigned integer by a 32-bit unsigned integer and 36160d1ba665SWarner Losh generates a 64-bit unsigned result. 36170d1ba665SWarner Losh 36180d1ba665SWarner Losh This function multiples the 64-bit unsigned value Multiplicand by the 32-bit 36190d1ba665SWarner Losh unsigned value Multiplier and generates a 64-bit unsigned result. This 64- 36200d1ba665SWarner Losh bit unsigned result is returned. 36210d1ba665SWarner Losh 36220d1ba665SWarner Losh @param Multiplicand A 64-bit unsigned value. 36230d1ba665SWarner Losh @param Multiplier A 32-bit unsigned value. 36240d1ba665SWarner Losh 36250d1ba665SWarner Losh @return Multiplicand * Multiplier 36260d1ba665SWarner Losh 36270d1ba665SWarner Losh **/ 36280d1ba665SWarner Losh UINT64 36290d1ba665SWarner Losh EFIAPI 36300d1ba665SWarner Losh MultU64x32 ( 36310d1ba665SWarner Losh IN UINT64 Multiplicand, 36320d1ba665SWarner Losh IN UINT32 Multiplier 36330d1ba665SWarner Losh ); 36340d1ba665SWarner Losh 36350d1ba665SWarner Losh 36360d1ba665SWarner Losh /** 36370d1ba665SWarner Losh Multiples a 64-bit unsigned integer by a 64-bit unsigned integer and 36380d1ba665SWarner Losh generates a 64-bit unsigned result. 36390d1ba665SWarner Losh 36400d1ba665SWarner Losh This function multiples the 64-bit unsigned value Multiplicand by the 64-bit 36410d1ba665SWarner Losh unsigned value Multiplier and generates a 64-bit unsigned result. This 64- 36420d1ba665SWarner Losh bit unsigned result is returned. 36430d1ba665SWarner Losh 36440d1ba665SWarner Losh @param Multiplicand A 64-bit unsigned value. 36450d1ba665SWarner Losh @param Multiplier A 64-bit unsigned value. 36460d1ba665SWarner Losh 36470d1ba665SWarner Losh @return Multiplicand * Multiplier. 36480d1ba665SWarner Losh 36490d1ba665SWarner Losh **/ 36500d1ba665SWarner Losh UINT64 36510d1ba665SWarner Losh EFIAPI 36520d1ba665SWarner Losh MultU64x64 ( 36530d1ba665SWarner Losh IN UINT64 Multiplicand, 36540d1ba665SWarner Losh IN UINT64 Multiplier 36550d1ba665SWarner Losh ); 36560d1ba665SWarner Losh 36570d1ba665SWarner Losh 36580d1ba665SWarner Losh /** 36590d1ba665SWarner Losh Multiples a 64-bit signed integer by a 64-bit signed integer and generates a 36600d1ba665SWarner Losh 64-bit signed result. 36610d1ba665SWarner Losh 36620d1ba665SWarner Losh This function multiples the 64-bit signed value Multiplicand by the 64-bit 36630d1ba665SWarner Losh signed value Multiplier and generates a 64-bit signed result. This 64-bit 36640d1ba665SWarner Losh signed result is returned. 36650d1ba665SWarner Losh 36660d1ba665SWarner Losh @param Multiplicand A 64-bit signed value. 36670d1ba665SWarner Losh @param Multiplier A 64-bit signed value. 36680d1ba665SWarner Losh 36690d1ba665SWarner Losh @return Multiplicand * Multiplier 36700d1ba665SWarner Losh 36710d1ba665SWarner Losh **/ 36720d1ba665SWarner Losh INT64 36730d1ba665SWarner Losh EFIAPI 36740d1ba665SWarner Losh MultS64x64 ( 36750d1ba665SWarner Losh IN INT64 Multiplicand, 36760d1ba665SWarner Losh IN INT64 Multiplier 36770d1ba665SWarner Losh ); 36780d1ba665SWarner Losh 36790d1ba665SWarner Losh 36800d1ba665SWarner Losh /** 36810d1ba665SWarner Losh Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates 36820d1ba665SWarner Losh a 64-bit unsigned result. 36830d1ba665SWarner Losh 36840d1ba665SWarner Losh This function divides the 64-bit unsigned value Dividend by the 32-bit 36850d1ba665SWarner Losh unsigned value Divisor and generates a 64-bit unsigned quotient. This 36860d1ba665SWarner Losh function returns the 64-bit unsigned quotient. 36870d1ba665SWarner Losh 36880d1ba665SWarner Losh If Divisor is 0, then ASSERT(). 36890d1ba665SWarner Losh 36900d1ba665SWarner Losh @param Dividend A 64-bit unsigned value. 36910d1ba665SWarner Losh @param Divisor A 32-bit unsigned value. 36920d1ba665SWarner Losh 36930d1ba665SWarner Losh @return Dividend / Divisor. 36940d1ba665SWarner Losh 36950d1ba665SWarner Losh **/ 36960d1ba665SWarner Losh UINT64 36970d1ba665SWarner Losh EFIAPI 36980d1ba665SWarner Losh DivU64x32 ( 36990d1ba665SWarner Losh IN UINT64 Dividend, 37000d1ba665SWarner Losh IN UINT32 Divisor 37010d1ba665SWarner Losh ); 37020d1ba665SWarner Losh 37030d1ba665SWarner Losh 37040d1ba665SWarner Losh /** 37050d1ba665SWarner Losh Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates 37060d1ba665SWarner Losh a 32-bit unsigned remainder. 37070d1ba665SWarner Losh 37080d1ba665SWarner Losh This function divides the 64-bit unsigned value Dividend by the 32-bit 37090d1ba665SWarner Losh unsigned value Divisor and generates a 32-bit remainder. This function 37100d1ba665SWarner Losh returns the 32-bit unsigned remainder. 37110d1ba665SWarner Losh 37120d1ba665SWarner Losh If Divisor is 0, then ASSERT(). 37130d1ba665SWarner Losh 37140d1ba665SWarner Losh @param Dividend A 64-bit unsigned value. 37150d1ba665SWarner Losh @param Divisor A 32-bit unsigned value. 37160d1ba665SWarner Losh 37170d1ba665SWarner Losh @return Dividend % Divisor. 37180d1ba665SWarner Losh 37190d1ba665SWarner Losh **/ 37200d1ba665SWarner Losh UINT32 37210d1ba665SWarner Losh EFIAPI 37220d1ba665SWarner Losh ModU64x32 ( 37230d1ba665SWarner Losh IN UINT64 Dividend, 37240d1ba665SWarner Losh IN UINT32 Divisor 37250d1ba665SWarner Losh ); 37260d1ba665SWarner Losh 37270d1ba665SWarner Losh 37280d1ba665SWarner Losh /** 37290d1ba665SWarner Losh Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates 37300d1ba665SWarner Losh a 64-bit unsigned result and an optional 32-bit unsigned remainder. 37310d1ba665SWarner Losh 37320d1ba665SWarner Losh This function divides the 64-bit unsigned value Dividend by the 32-bit 37330d1ba665SWarner Losh unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder 37340d1ba665SWarner Losh is not NULL, then the 32-bit unsigned remainder is returned in Remainder. 37350d1ba665SWarner Losh This function returns the 64-bit unsigned quotient. 37360d1ba665SWarner Losh 37370d1ba665SWarner Losh If Divisor is 0, then ASSERT(). 37380d1ba665SWarner Losh 37390d1ba665SWarner Losh @param Dividend A 64-bit unsigned value. 37400d1ba665SWarner Losh @param Divisor A 32-bit unsigned value. 37410d1ba665SWarner Losh @param Remainder A pointer to a 32-bit unsigned value. This parameter is 37420d1ba665SWarner Losh optional and may be NULL. 37430d1ba665SWarner Losh 37440d1ba665SWarner Losh @return Dividend / Divisor. 37450d1ba665SWarner Losh 37460d1ba665SWarner Losh **/ 37470d1ba665SWarner Losh UINT64 37480d1ba665SWarner Losh EFIAPI 37490d1ba665SWarner Losh DivU64x32Remainder ( 37500d1ba665SWarner Losh IN UINT64 Dividend, 37510d1ba665SWarner Losh IN UINT32 Divisor, 37520d1ba665SWarner Losh OUT UINT32 *Remainder OPTIONAL 37530d1ba665SWarner Losh ); 37540d1ba665SWarner Losh 37550d1ba665SWarner Losh 37560d1ba665SWarner Losh /** 37570d1ba665SWarner Losh Divides a 64-bit unsigned integer by a 64-bit unsigned integer and generates 37580d1ba665SWarner Losh a 64-bit unsigned result and an optional 64-bit unsigned remainder. 37590d1ba665SWarner Losh 37600d1ba665SWarner Losh This function divides the 64-bit unsigned value Dividend by the 64-bit 37610d1ba665SWarner Losh unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder 37620d1ba665SWarner Losh is not NULL, then the 64-bit unsigned remainder is returned in Remainder. 37630d1ba665SWarner Losh This function returns the 64-bit unsigned quotient. 37640d1ba665SWarner Losh 37650d1ba665SWarner Losh If Divisor is 0, then ASSERT(). 37660d1ba665SWarner Losh 37670d1ba665SWarner Losh @param Dividend A 64-bit unsigned value. 37680d1ba665SWarner Losh @param Divisor A 64-bit unsigned value. 37690d1ba665SWarner Losh @param Remainder A pointer to a 64-bit unsigned value. This parameter is 37700d1ba665SWarner Losh optional and may be NULL. 37710d1ba665SWarner Losh 37720d1ba665SWarner Losh @return Dividend / Divisor. 37730d1ba665SWarner Losh 37740d1ba665SWarner Losh **/ 37750d1ba665SWarner Losh UINT64 37760d1ba665SWarner Losh EFIAPI 37770d1ba665SWarner Losh DivU64x64Remainder ( 37780d1ba665SWarner Losh IN UINT64 Dividend, 37790d1ba665SWarner Losh IN UINT64 Divisor, 37800d1ba665SWarner Losh OUT UINT64 *Remainder OPTIONAL 37810d1ba665SWarner Losh ); 37820d1ba665SWarner Losh 37830d1ba665SWarner Losh 37840d1ba665SWarner Losh /** 37850d1ba665SWarner Losh Divides a 64-bit signed integer by a 64-bit signed integer and generates a 37860d1ba665SWarner Losh 64-bit signed result and a optional 64-bit signed remainder. 37870d1ba665SWarner Losh 37880d1ba665SWarner Losh This function divides the 64-bit signed value Dividend by the 64-bit signed 37890d1ba665SWarner Losh value Divisor and generates a 64-bit signed quotient. If Remainder is not 37900d1ba665SWarner Losh NULL, then the 64-bit signed remainder is returned in Remainder. This 37910d1ba665SWarner Losh function returns the 64-bit signed quotient. 37920d1ba665SWarner Losh 37930d1ba665SWarner Losh It is the caller's responsibility to not call this function with a Divisor of 0. 37940d1ba665SWarner Losh If Divisor is 0, then the quotient and remainder should be assumed to be 37950d1ba665SWarner Losh the largest negative integer. 37960d1ba665SWarner Losh 37970d1ba665SWarner Losh If Divisor is 0, then ASSERT(). 37980d1ba665SWarner Losh 37990d1ba665SWarner Losh @param Dividend A 64-bit signed value. 38000d1ba665SWarner Losh @param Divisor A 64-bit signed value. 38010d1ba665SWarner Losh @param Remainder A pointer to a 64-bit signed value. This parameter is 38020d1ba665SWarner Losh optional and may be NULL. 38030d1ba665SWarner Losh 38040d1ba665SWarner Losh @return Dividend / Divisor. 38050d1ba665SWarner Losh 38060d1ba665SWarner Losh **/ 38070d1ba665SWarner Losh INT64 38080d1ba665SWarner Losh EFIAPI 38090d1ba665SWarner Losh DivS64x64Remainder ( 38100d1ba665SWarner Losh IN INT64 Dividend, 38110d1ba665SWarner Losh IN INT64 Divisor, 38120d1ba665SWarner Losh OUT INT64 *Remainder OPTIONAL 38130d1ba665SWarner Losh ); 38140d1ba665SWarner Losh 38150d1ba665SWarner Losh 38160d1ba665SWarner Losh /** 38170d1ba665SWarner Losh Reads a 16-bit value from memory that may be unaligned. 38180d1ba665SWarner Losh 38190d1ba665SWarner Losh This function returns the 16-bit value pointed to by Buffer. The function 38200d1ba665SWarner Losh guarantees that the read operation does not produce an alignment fault. 38210d1ba665SWarner Losh 38220d1ba665SWarner Losh If the Buffer is NULL, then ASSERT(). 38230d1ba665SWarner Losh 38240d1ba665SWarner Losh @param Buffer The pointer to a 16-bit value that may be unaligned. 38250d1ba665SWarner Losh 38260d1ba665SWarner Losh @return The 16-bit value read from Buffer. 38270d1ba665SWarner Losh 38280d1ba665SWarner Losh **/ 38290d1ba665SWarner Losh UINT16 38300d1ba665SWarner Losh EFIAPI 38310d1ba665SWarner Losh ReadUnaligned16 ( 38320d1ba665SWarner Losh IN CONST UINT16 *Buffer 38330d1ba665SWarner Losh ); 38340d1ba665SWarner Losh 38350d1ba665SWarner Losh 38360d1ba665SWarner Losh /** 38370d1ba665SWarner Losh Writes a 16-bit value to memory that may be unaligned. 38380d1ba665SWarner Losh 38390d1ba665SWarner Losh This function writes the 16-bit value specified by Value to Buffer. Value is 38400d1ba665SWarner Losh returned. The function guarantees that the write operation does not produce 38410d1ba665SWarner Losh an alignment fault. 38420d1ba665SWarner Losh 38430d1ba665SWarner Losh If the Buffer is NULL, then ASSERT(). 38440d1ba665SWarner Losh 38450d1ba665SWarner Losh @param Buffer The pointer to a 16-bit value that may be unaligned. 38460d1ba665SWarner Losh @param Value 16-bit value to write to Buffer. 38470d1ba665SWarner Losh 38480d1ba665SWarner Losh @return The 16-bit value to write to Buffer. 38490d1ba665SWarner Losh 38500d1ba665SWarner Losh **/ 38510d1ba665SWarner Losh UINT16 38520d1ba665SWarner Losh EFIAPI 38530d1ba665SWarner Losh WriteUnaligned16 ( 38540d1ba665SWarner Losh OUT UINT16 *Buffer, 38550d1ba665SWarner Losh IN UINT16 Value 38560d1ba665SWarner Losh ); 38570d1ba665SWarner Losh 38580d1ba665SWarner Losh 38590d1ba665SWarner Losh /** 38600d1ba665SWarner Losh Reads a 24-bit value from memory that may be unaligned. 38610d1ba665SWarner Losh 38620d1ba665SWarner Losh This function returns the 24-bit value pointed to by Buffer. The function 38630d1ba665SWarner Losh guarantees that the read operation does not produce an alignment fault. 38640d1ba665SWarner Losh 38650d1ba665SWarner Losh If the Buffer is NULL, then ASSERT(). 38660d1ba665SWarner Losh 38670d1ba665SWarner Losh @param Buffer The pointer to a 24-bit value that may be unaligned. 38680d1ba665SWarner Losh 38690d1ba665SWarner Losh @return The 24-bit value read from Buffer. 38700d1ba665SWarner Losh 38710d1ba665SWarner Losh **/ 38720d1ba665SWarner Losh UINT32 38730d1ba665SWarner Losh EFIAPI 38740d1ba665SWarner Losh ReadUnaligned24 ( 38750d1ba665SWarner Losh IN CONST UINT32 *Buffer 38760d1ba665SWarner Losh ); 38770d1ba665SWarner Losh 38780d1ba665SWarner Losh 38790d1ba665SWarner Losh /** 38800d1ba665SWarner Losh Writes a 24-bit value to memory that may be unaligned. 38810d1ba665SWarner Losh 38820d1ba665SWarner Losh This function writes the 24-bit value specified by Value to Buffer. Value is 38830d1ba665SWarner Losh returned. The function guarantees that the write operation does not produce 38840d1ba665SWarner Losh an alignment fault. 38850d1ba665SWarner Losh 38860d1ba665SWarner Losh If the Buffer is NULL, then ASSERT(). 38870d1ba665SWarner Losh 38880d1ba665SWarner Losh @param Buffer The pointer to a 24-bit value that may be unaligned. 38890d1ba665SWarner Losh @param Value 24-bit value to write to Buffer. 38900d1ba665SWarner Losh 38910d1ba665SWarner Losh @return The 24-bit value to write to Buffer. 38920d1ba665SWarner Losh 38930d1ba665SWarner Losh **/ 38940d1ba665SWarner Losh UINT32 38950d1ba665SWarner Losh EFIAPI 38960d1ba665SWarner Losh WriteUnaligned24 ( 38970d1ba665SWarner Losh OUT UINT32 *Buffer, 38980d1ba665SWarner Losh IN UINT32 Value 38990d1ba665SWarner Losh ); 39000d1ba665SWarner Losh 39010d1ba665SWarner Losh 39020d1ba665SWarner Losh /** 39030d1ba665SWarner Losh Reads a 32-bit value from memory that may be unaligned. 39040d1ba665SWarner Losh 39050d1ba665SWarner Losh This function returns the 32-bit value pointed to by Buffer. The function 39060d1ba665SWarner Losh guarantees that the read operation does not produce an alignment fault. 39070d1ba665SWarner Losh 39080d1ba665SWarner Losh If the Buffer is NULL, then ASSERT(). 39090d1ba665SWarner Losh 39100d1ba665SWarner Losh @param Buffer The pointer to a 32-bit value that may be unaligned. 39110d1ba665SWarner Losh 39120d1ba665SWarner Losh @return The 32-bit value read from Buffer. 39130d1ba665SWarner Losh 39140d1ba665SWarner Losh **/ 39150d1ba665SWarner Losh UINT32 39160d1ba665SWarner Losh EFIAPI 39170d1ba665SWarner Losh ReadUnaligned32 ( 39180d1ba665SWarner Losh IN CONST UINT32 *Buffer 39190d1ba665SWarner Losh ); 39200d1ba665SWarner Losh 39210d1ba665SWarner Losh 39220d1ba665SWarner Losh /** 39230d1ba665SWarner Losh Writes a 32-bit value to memory that may be unaligned. 39240d1ba665SWarner Losh 39250d1ba665SWarner Losh This function writes the 32-bit value specified by Value to Buffer. Value is 39260d1ba665SWarner Losh returned. The function guarantees that the write operation does not produce 39270d1ba665SWarner Losh an alignment fault. 39280d1ba665SWarner Losh 39290d1ba665SWarner Losh If the Buffer is NULL, then ASSERT(). 39300d1ba665SWarner Losh 39310d1ba665SWarner Losh @param Buffer The pointer to a 32-bit value that may be unaligned. 39320d1ba665SWarner Losh @param Value 32-bit value to write to Buffer. 39330d1ba665SWarner Losh 39340d1ba665SWarner Losh @return The 32-bit value to write to Buffer. 39350d1ba665SWarner Losh 39360d1ba665SWarner Losh **/ 39370d1ba665SWarner Losh UINT32 39380d1ba665SWarner Losh EFIAPI 39390d1ba665SWarner Losh WriteUnaligned32 ( 39400d1ba665SWarner Losh OUT UINT32 *Buffer, 39410d1ba665SWarner Losh IN UINT32 Value 39420d1ba665SWarner Losh ); 39430d1ba665SWarner Losh 39440d1ba665SWarner Losh 39450d1ba665SWarner Losh /** 39460d1ba665SWarner Losh Reads a 64-bit value from memory that may be unaligned. 39470d1ba665SWarner Losh 39480d1ba665SWarner Losh This function returns the 64-bit value pointed to by Buffer. The function 39490d1ba665SWarner Losh guarantees that the read operation does not produce an alignment fault. 39500d1ba665SWarner Losh 39510d1ba665SWarner Losh If the Buffer is NULL, then ASSERT(). 39520d1ba665SWarner Losh 39530d1ba665SWarner Losh @param Buffer The pointer to a 64-bit value that may be unaligned. 39540d1ba665SWarner Losh 39550d1ba665SWarner Losh @return The 64-bit value read from Buffer. 39560d1ba665SWarner Losh 39570d1ba665SWarner Losh **/ 39580d1ba665SWarner Losh UINT64 39590d1ba665SWarner Losh EFIAPI 39600d1ba665SWarner Losh ReadUnaligned64 ( 39610d1ba665SWarner Losh IN CONST UINT64 *Buffer 39620d1ba665SWarner Losh ); 39630d1ba665SWarner Losh 39640d1ba665SWarner Losh 39650d1ba665SWarner Losh /** 39660d1ba665SWarner Losh Writes a 64-bit value to memory that may be unaligned. 39670d1ba665SWarner Losh 39680d1ba665SWarner Losh This function writes the 64-bit value specified by Value to Buffer. Value is 39690d1ba665SWarner Losh returned. The function guarantees that the write operation does not produce 39700d1ba665SWarner Losh an alignment fault. 39710d1ba665SWarner Losh 39720d1ba665SWarner Losh If the Buffer is NULL, then ASSERT(). 39730d1ba665SWarner Losh 39740d1ba665SWarner Losh @param Buffer The pointer to a 64-bit value that may be unaligned. 39750d1ba665SWarner Losh @param Value 64-bit value to write to Buffer. 39760d1ba665SWarner Losh 39770d1ba665SWarner Losh @return The 64-bit value to write to Buffer. 39780d1ba665SWarner Losh 39790d1ba665SWarner Losh **/ 39800d1ba665SWarner Losh UINT64 39810d1ba665SWarner Losh EFIAPI 39820d1ba665SWarner Losh WriteUnaligned64 ( 39830d1ba665SWarner Losh OUT UINT64 *Buffer, 39840d1ba665SWarner Losh IN UINT64 Value 39850d1ba665SWarner Losh ); 39860d1ba665SWarner Losh 39870d1ba665SWarner Losh 39880d1ba665SWarner Losh // 39890d1ba665SWarner Losh // Bit Field Functions 39900d1ba665SWarner Losh // 39910d1ba665SWarner Losh 39920d1ba665SWarner Losh /** 39930d1ba665SWarner Losh Returns a bit field from an 8-bit value. 39940d1ba665SWarner Losh 39950d1ba665SWarner Losh Returns the bitfield specified by the StartBit and the EndBit from Operand. 39960d1ba665SWarner Losh 39970d1ba665SWarner Losh If 8-bit operations are not supported, then ASSERT(). 39980d1ba665SWarner Losh If StartBit is greater than 7, then ASSERT(). 39990d1ba665SWarner Losh If EndBit is greater than 7, then ASSERT(). 40000d1ba665SWarner Losh If EndBit is less than StartBit, then ASSERT(). 40010d1ba665SWarner Losh 40020d1ba665SWarner Losh @param Operand Operand on which to perform the bitfield operation. 40030d1ba665SWarner Losh @param StartBit The ordinal of the least significant bit in the bit field. 40040d1ba665SWarner Losh Range 0..7. 40050d1ba665SWarner Losh @param EndBit The ordinal of the most significant bit in the bit field. 40060d1ba665SWarner Losh Range 0..7. 40070d1ba665SWarner Losh 40080d1ba665SWarner Losh @return The bit field read. 40090d1ba665SWarner Losh 40100d1ba665SWarner Losh **/ 40110d1ba665SWarner Losh UINT8 40120d1ba665SWarner Losh EFIAPI 40130d1ba665SWarner Losh BitFieldRead8 ( 40140d1ba665SWarner Losh IN UINT8 Operand, 40150d1ba665SWarner Losh IN UINTN StartBit, 40160d1ba665SWarner Losh IN UINTN EndBit 40170d1ba665SWarner Losh ); 40180d1ba665SWarner Losh 40190d1ba665SWarner Losh 40200d1ba665SWarner Losh /** 40210d1ba665SWarner Losh Writes a bit field to an 8-bit value, and returns the result. 40220d1ba665SWarner Losh 40230d1ba665SWarner Losh Writes Value to the bit field specified by the StartBit and the EndBit in 40240d1ba665SWarner Losh Operand. All other bits in Operand are preserved. The new 8-bit value is 40250d1ba665SWarner Losh returned. 40260d1ba665SWarner Losh 40270d1ba665SWarner Losh If 8-bit operations are not supported, then ASSERT(). 40280d1ba665SWarner Losh If StartBit is greater than 7, then ASSERT(). 40290d1ba665SWarner Losh If EndBit is greater than 7, then ASSERT(). 40300d1ba665SWarner Losh If EndBit is less than StartBit, then ASSERT(). 40310d1ba665SWarner Losh If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT(). 40320d1ba665SWarner Losh 40330d1ba665SWarner Losh @param Operand Operand on which to perform the bitfield operation. 40340d1ba665SWarner Losh @param StartBit The ordinal of the least significant bit in the bit field. 40350d1ba665SWarner Losh Range 0..7. 40360d1ba665SWarner Losh @param EndBit The ordinal of the most significant bit in the bit field. 40370d1ba665SWarner Losh Range 0..7. 40380d1ba665SWarner Losh @param Value New value of the bit field. 40390d1ba665SWarner Losh 40400d1ba665SWarner Losh @return The new 8-bit value. 40410d1ba665SWarner Losh 40420d1ba665SWarner Losh **/ 40430d1ba665SWarner Losh UINT8 40440d1ba665SWarner Losh EFIAPI 40450d1ba665SWarner Losh BitFieldWrite8 ( 40460d1ba665SWarner Losh IN UINT8 Operand, 40470d1ba665SWarner Losh IN UINTN StartBit, 40480d1ba665SWarner Losh IN UINTN EndBit, 40490d1ba665SWarner Losh IN UINT8 Value 40500d1ba665SWarner Losh ); 40510d1ba665SWarner Losh 40520d1ba665SWarner Losh 40530d1ba665SWarner Losh /** 40540d1ba665SWarner Losh Reads a bit field from an 8-bit value, performs a bitwise OR, and returns the 40550d1ba665SWarner Losh result. 40560d1ba665SWarner Losh 40570d1ba665SWarner Losh Performs a bitwise OR between the bit field specified by StartBit 40580d1ba665SWarner Losh and EndBit in Operand and the value specified by OrData. All other bits in 40590d1ba665SWarner Losh Operand are preserved. The new 8-bit value is returned. 40600d1ba665SWarner Losh 40610d1ba665SWarner Losh If 8-bit operations are not supported, then ASSERT(). 40620d1ba665SWarner Losh If StartBit is greater than 7, then ASSERT(). 40630d1ba665SWarner Losh If EndBit is greater than 7, then ASSERT(). 40640d1ba665SWarner Losh If EndBit is less than StartBit, then ASSERT(). 40650d1ba665SWarner Losh If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT(). 40660d1ba665SWarner Losh 40670d1ba665SWarner Losh @param Operand Operand on which to perform the bitfield operation. 40680d1ba665SWarner Losh @param StartBit The ordinal of the least significant bit in the bit field. 40690d1ba665SWarner Losh Range 0..7. 40700d1ba665SWarner Losh @param EndBit The ordinal of the most significant bit in the bit field. 40710d1ba665SWarner Losh Range 0..7. 40720d1ba665SWarner Losh @param OrData The value to OR with the read value from the value 40730d1ba665SWarner Losh 40740d1ba665SWarner Losh @return The new 8-bit value. 40750d1ba665SWarner Losh 40760d1ba665SWarner Losh **/ 40770d1ba665SWarner Losh UINT8 40780d1ba665SWarner Losh EFIAPI 40790d1ba665SWarner Losh BitFieldOr8 ( 40800d1ba665SWarner Losh IN UINT8 Operand, 40810d1ba665SWarner Losh IN UINTN StartBit, 40820d1ba665SWarner Losh IN UINTN EndBit, 40830d1ba665SWarner Losh IN UINT8 OrData 40840d1ba665SWarner Losh ); 40850d1ba665SWarner Losh 40860d1ba665SWarner Losh 40870d1ba665SWarner Losh /** 40880d1ba665SWarner Losh Reads a bit field from an 8-bit value, performs a bitwise AND, and returns 40890d1ba665SWarner Losh the result. 40900d1ba665SWarner Losh 40910d1ba665SWarner Losh Performs a bitwise AND between the bit field specified by StartBit and EndBit 40920d1ba665SWarner Losh in Operand and the value specified by AndData. All other bits in Operand are 40930d1ba665SWarner Losh preserved. The new 8-bit value is returned. 40940d1ba665SWarner Losh 40950d1ba665SWarner Losh If 8-bit operations are not supported, then ASSERT(). 40960d1ba665SWarner Losh If StartBit is greater than 7, then ASSERT(). 40970d1ba665SWarner Losh If EndBit is greater than 7, then ASSERT(). 40980d1ba665SWarner Losh If EndBit is less than StartBit, then ASSERT(). 40990d1ba665SWarner Losh If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT(). 41000d1ba665SWarner Losh 41010d1ba665SWarner Losh @param Operand Operand on which to perform the bitfield operation. 41020d1ba665SWarner Losh @param StartBit The ordinal of the least significant bit in the bit field. 41030d1ba665SWarner Losh Range 0..7. 41040d1ba665SWarner Losh @param EndBit The ordinal of the most significant bit in the bit field. 41050d1ba665SWarner Losh Range 0..7. 41060d1ba665SWarner Losh @param AndData The value to AND with the read value from the value. 41070d1ba665SWarner Losh 41080d1ba665SWarner Losh @return The new 8-bit value. 41090d1ba665SWarner Losh 41100d1ba665SWarner Losh **/ 41110d1ba665SWarner Losh UINT8 41120d1ba665SWarner Losh EFIAPI 41130d1ba665SWarner Losh BitFieldAnd8 ( 41140d1ba665SWarner Losh IN UINT8 Operand, 41150d1ba665SWarner Losh IN UINTN StartBit, 41160d1ba665SWarner Losh IN UINTN EndBit, 41170d1ba665SWarner Losh IN UINT8 AndData 41180d1ba665SWarner Losh ); 41190d1ba665SWarner Losh 41200d1ba665SWarner Losh 41210d1ba665SWarner Losh /** 41220d1ba665SWarner Losh Reads a bit field from an 8-bit value, performs a bitwise AND followed by a 41230d1ba665SWarner Losh bitwise OR, and returns the result. 41240d1ba665SWarner Losh 41250d1ba665SWarner Losh Performs a bitwise AND between the bit field specified by StartBit and EndBit 41260d1ba665SWarner Losh in Operand and the value specified by AndData, followed by a bitwise 41270d1ba665SWarner Losh OR with value specified by OrData. All other bits in Operand are 41280d1ba665SWarner Losh preserved. The new 8-bit value is returned. 41290d1ba665SWarner Losh 41300d1ba665SWarner Losh If 8-bit operations are not supported, then ASSERT(). 41310d1ba665SWarner Losh If StartBit is greater than 7, then ASSERT(). 41320d1ba665SWarner Losh If EndBit is greater than 7, then ASSERT(). 41330d1ba665SWarner Losh If EndBit is less than StartBit, then ASSERT(). 41340d1ba665SWarner Losh If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT(). 41350d1ba665SWarner Losh If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT(). 41360d1ba665SWarner Losh 41370d1ba665SWarner Losh @param Operand Operand on which to perform the bitfield operation. 41380d1ba665SWarner Losh @param StartBit The ordinal of the least significant bit in the bit field. 41390d1ba665SWarner Losh Range 0..7. 41400d1ba665SWarner Losh @param EndBit The ordinal of the most significant bit in the bit field. 41410d1ba665SWarner Losh Range 0..7. 41420d1ba665SWarner Losh @param AndData The value to AND with the read value from the value. 41430d1ba665SWarner Losh @param OrData The value to OR with the result of the AND operation. 41440d1ba665SWarner Losh 41450d1ba665SWarner Losh @return The new 8-bit value. 41460d1ba665SWarner Losh 41470d1ba665SWarner Losh **/ 41480d1ba665SWarner Losh UINT8 41490d1ba665SWarner Losh EFIAPI 41500d1ba665SWarner Losh BitFieldAndThenOr8 ( 41510d1ba665SWarner Losh IN UINT8 Operand, 41520d1ba665SWarner Losh IN UINTN StartBit, 41530d1ba665SWarner Losh IN UINTN EndBit, 41540d1ba665SWarner Losh IN UINT8 AndData, 41550d1ba665SWarner Losh IN UINT8 OrData 41560d1ba665SWarner Losh ); 41570d1ba665SWarner Losh 41580d1ba665SWarner Losh 41590d1ba665SWarner Losh /** 41600d1ba665SWarner Losh Returns a bit field from a 16-bit value. 41610d1ba665SWarner Losh 41620d1ba665SWarner Losh Returns the bitfield specified by the StartBit and the EndBit from Operand. 41630d1ba665SWarner Losh 41640d1ba665SWarner Losh If 16-bit operations are not supported, then ASSERT(). 41650d1ba665SWarner Losh If StartBit is greater than 15, then ASSERT(). 41660d1ba665SWarner Losh If EndBit is greater than 15, then ASSERT(). 41670d1ba665SWarner Losh If EndBit is less than StartBit, then ASSERT(). 41680d1ba665SWarner Losh 41690d1ba665SWarner Losh @param Operand Operand on which to perform the bitfield operation. 41700d1ba665SWarner Losh @param StartBit The ordinal of the least significant bit in the bit field. 41710d1ba665SWarner Losh Range 0..15. 41720d1ba665SWarner Losh @param EndBit The ordinal of the most significant bit in the bit field. 41730d1ba665SWarner Losh Range 0..15. 41740d1ba665SWarner Losh 41750d1ba665SWarner Losh @return The bit field read. 41760d1ba665SWarner Losh 41770d1ba665SWarner Losh **/ 41780d1ba665SWarner Losh UINT16 41790d1ba665SWarner Losh EFIAPI 41800d1ba665SWarner Losh BitFieldRead16 ( 41810d1ba665SWarner Losh IN UINT16 Operand, 41820d1ba665SWarner Losh IN UINTN StartBit, 41830d1ba665SWarner Losh IN UINTN EndBit 41840d1ba665SWarner Losh ); 41850d1ba665SWarner Losh 41860d1ba665SWarner Losh 41870d1ba665SWarner Losh /** 41880d1ba665SWarner Losh Writes a bit field to a 16-bit value, and returns the result. 41890d1ba665SWarner Losh 41900d1ba665SWarner Losh Writes Value to the bit field specified by the StartBit and the EndBit in 41910d1ba665SWarner Losh Operand. All other bits in Operand are preserved. The new 16-bit value is 41920d1ba665SWarner Losh returned. 41930d1ba665SWarner Losh 41940d1ba665SWarner Losh If 16-bit operations are not supported, then ASSERT(). 41950d1ba665SWarner Losh If StartBit is greater than 15, then ASSERT(). 41960d1ba665SWarner Losh If EndBit is greater than 15, then ASSERT(). 41970d1ba665SWarner Losh If EndBit is less than StartBit, then ASSERT(). 41980d1ba665SWarner Losh If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT(). 41990d1ba665SWarner Losh 42000d1ba665SWarner Losh @param Operand Operand on which to perform the bitfield operation. 42010d1ba665SWarner Losh @param StartBit The ordinal of the least significant bit in the bit field. 42020d1ba665SWarner Losh Range 0..15. 42030d1ba665SWarner Losh @param EndBit The ordinal of the most significant bit in the bit field. 42040d1ba665SWarner Losh Range 0..15. 42050d1ba665SWarner Losh @param Value New value of the bit field. 42060d1ba665SWarner Losh 42070d1ba665SWarner Losh @return The new 16-bit value. 42080d1ba665SWarner Losh 42090d1ba665SWarner Losh **/ 42100d1ba665SWarner Losh UINT16 42110d1ba665SWarner Losh EFIAPI 42120d1ba665SWarner Losh BitFieldWrite16 ( 42130d1ba665SWarner Losh IN UINT16 Operand, 42140d1ba665SWarner Losh IN UINTN StartBit, 42150d1ba665SWarner Losh IN UINTN EndBit, 42160d1ba665SWarner Losh IN UINT16 Value 42170d1ba665SWarner Losh ); 42180d1ba665SWarner Losh 42190d1ba665SWarner Losh 42200d1ba665SWarner Losh /** 42210d1ba665SWarner Losh Reads a bit field from a 16-bit value, performs a bitwise OR, and returns the 42220d1ba665SWarner Losh result. 42230d1ba665SWarner Losh 42240d1ba665SWarner Losh Performs a bitwise OR between the bit field specified by StartBit 42250d1ba665SWarner Losh and EndBit in Operand and the value specified by OrData. All other bits in 42260d1ba665SWarner Losh Operand are preserved. The new 16-bit value is returned. 42270d1ba665SWarner Losh 42280d1ba665SWarner Losh If 16-bit operations are not supported, then ASSERT(). 42290d1ba665SWarner Losh If StartBit is greater than 15, then ASSERT(). 42300d1ba665SWarner Losh If EndBit is greater than 15, then ASSERT(). 42310d1ba665SWarner Losh If EndBit is less than StartBit, then ASSERT(). 42320d1ba665SWarner Losh If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT(). 42330d1ba665SWarner Losh 42340d1ba665SWarner Losh @param Operand Operand on which to perform the bitfield operation. 42350d1ba665SWarner Losh @param StartBit The ordinal of the least significant bit in the bit field. 42360d1ba665SWarner Losh Range 0..15. 42370d1ba665SWarner Losh @param EndBit The ordinal of the most significant bit in the bit field. 42380d1ba665SWarner Losh Range 0..15. 42390d1ba665SWarner Losh @param OrData The value to OR with the read value from the value 42400d1ba665SWarner Losh 42410d1ba665SWarner Losh @return The new 16-bit value. 42420d1ba665SWarner Losh 42430d1ba665SWarner Losh **/ 42440d1ba665SWarner Losh UINT16 42450d1ba665SWarner Losh EFIAPI 42460d1ba665SWarner Losh BitFieldOr16 ( 42470d1ba665SWarner Losh IN UINT16 Operand, 42480d1ba665SWarner Losh IN UINTN StartBit, 42490d1ba665SWarner Losh IN UINTN EndBit, 42500d1ba665SWarner Losh IN UINT16 OrData 42510d1ba665SWarner Losh ); 42520d1ba665SWarner Losh 42530d1ba665SWarner Losh 42540d1ba665SWarner Losh /** 42550d1ba665SWarner Losh Reads a bit field from a 16-bit value, performs a bitwise AND, and returns 42560d1ba665SWarner Losh the result. 42570d1ba665SWarner Losh 42580d1ba665SWarner Losh Performs a bitwise AND between the bit field specified by StartBit and EndBit 42590d1ba665SWarner Losh in Operand and the value specified by AndData. All other bits in Operand are 42600d1ba665SWarner Losh preserved. The new 16-bit value is returned. 42610d1ba665SWarner Losh 42620d1ba665SWarner Losh If 16-bit operations are not supported, then ASSERT(). 42630d1ba665SWarner Losh If StartBit is greater than 15, then ASSERT(). 42640d1ba665SWarner Losh If EndBit is greater than 15, then ASSERT(). 42650d1ba665SWarner Losh If EndBit is less than StartBit, then ASSERT(). 42660d1ba665SWarner Losh If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT(). 42670d1ba665SWarner Losh 42680d1ba665SWarner Losh @param Operand Operand on which to perform the bitfield operation. 42690d1ba665SWarner Losh @param StartBit The ordinal of the least significant bit in the bit field. 42700d1ba665SWarner Losh Range 0..15. 42710d1ba665SWarner Losh @param EndBit The ordinal of the most significant bit in the bit field. 42720d1ba665SWarner Losh Range 0..15. 42730d1ba665SWarner Losh @param AndData The value to AND with the read value from the value 42740d1ba665SWarner Losh 42750d1ba665SWarner Losh @return The new 16-bit value. 42760d1ba665SWarner Losh 42770d1ba665SWarner Losh **/ 42780d1ba665SWarner Losh UINT16 42790d1ba665SWarner Losh EFIAPI 42800d1ba665SWarner Losh BitFieldAnd16 ( 42810d1ba665SWarner Losh IN UINT16 Operand, 42820d1ba665SWarner Losh IN UINTN StartBit, 42830d1ba665SWarner Losh IN UINTN EndBit, 42840d1ba665SWarner Losh IN UINT16 AndData 42850d1ba665SWarner Losh ); 42860d1ba665SWarner Losh 42870d1ba665SWarner Losh 42880d1ba665SWarner Losh /** 42890d1ba665SWarner Losh Reads a bit field from a 16-bit value, performs a bitwise AND followed by a 42900d1ba665SWarner Losh bitwise OR, and returns the result. 42910d1ba665SWarner Losh 42920d1ba665SWarner Losh Performs a bitwise AND between the bit field specified by StartBit and EndBit 42930d1ba665SWarner Losh in Operand and the value specified by AndData, followed by a bitwise 42940d1ba665SWarner Losh OR with value specified by OrData. All other bits in Operand are 42950d1ba665SWarner Losh preserved. The new 16-bit value is returned. 42960d1ba665SWarner Losh 42970d1ba665SWarner Losh If 16-bit operations are not supported, then ASSERT(). 42980d1ba665SWarner Losh If StartBit is greater than 15, then ASSERT(). 42990d1ba665SWarner Losh If EndBit is greater than 15, then ASSERT(). 43000d1ba665SWarner Losh If EndBit is less than StartBit, then ASSERT(). 43010d1ba665SWarner Losh If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT(). 43020d1ba665SWarner Losh If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT(). 43030d1ba665SWarner Losh 43040d1ba665SWarner Losh @param Operand Operand on which to perform the bitfield operation. 43050d1ba665SWarner Losh @param StartBit The ordinal of the least significant bit in the bit field. 43060d1ba665SWarner Losh Range 0..15. 43070d1ba665SWarner Losh @param EndBit The ordinal of the most significant bit in the bit field. 43080d1ba665SWarner Losh Range 0..15. 43090d1ba665SWarner Losh @param AndData The value to AND with the read value from the value. 43100d1ba665SWarner Losh @param OrData The value to OR with the result of the AND operation. 43110d1ba665SWarner Losh 43120d1ba665SWarner Losh @return The new 16-bit value. 43130d1ba665SWarner Losh 43140d1ba665SWarner Losh **/ 43150d1ba665SWarner Losh UINT16 43160d1ba665SWarner Losh EFIAPI 43170d1ba665SWarner Losh BitFieldAndThenOr16 ( 43180d1ba665SWarner Losh IN UINT16 Operand, 43190d1ba665SWarner Losh IN UINTN StartBit, 43200d1ba665SWarner Losh IN UINTN EndBit, 43210d1ba665SWarner Losh IN UINT16 AndData, 43220d1ba665SWarner Losh IN UINT16 OrData 43230d1ba665SWarner Losh ); 43240d1ba665SWarner Losh 43250d1ba665SWarner Losh 43260d1ba665SWarner Losh /** 43270d1ba665SWarner Losh Returns a bit field from a 32-bit value. 43280d1ba665SWarner Losh 43290d1ba665SWarner Losh Returns the bitfield specified by the StartBit and the EndBit from Operand. 43300d1ba665SWarner Losh 43310d1ba665SWarner Losh If 32-bit operations are not supported, then ASSERT(). 43320d1ba665SWarner Losh If StartBit is greater than 31, then ASSERT(). 43330d1ba665SWarner Losh If EndBit is greater than 31, then ASSERT(). 43340d1ba665SWarner Losh If EndBit is less than StartBit, then ASSERT(). 43350d1ba665SWarner Losh 43360d1ba665SWarner Losh @param Operand Operand on which to perform the bitfield operation. 43370d1ba665SWarner Losh @param StartBit The ordinal of the least significant bit in the bit field. 43380d1ba665SWarner Losh Range 0..31. 43390d1ba665SWarner Losh @param EndBit The ordinal of the most significant bit in the bit field. 43400d1ba665SWarner Losh Range 0..31. 43410d1ba665SWarner Losh 43420d1ba665SWarner Losh @return The bit field read. 43430d1ba665SWarner Losh 43440d1ba665SWarner Losh **/ 43450d1ba665SWarner Losh UINT32 43460d1ba665SWarner Losh EFIAPI 43470d1ba665SWarner Losh BitFieldRead32 ( 43480d1ba665SWarner Losh IN UINT32 Operand, 43490d1ba665SWarner Losh IN UINTN StartBit, 43500d1ba665SWarner Losh IN UINTN EndBit 43510d1ba665SWarner Losh ); 43520d1ba665SWarner Losh 43530d1ba665SWarner Losh 43540d1ba665SWarner Losh /** 43550d1ba665SWarner Losh Writes a bit field to a 32-bit value, and returns the result. 43560d1ba665SWarner Losh 43570d1ba665SWarner Losh Writes Value to the bit field specified by the StartBit and the EndBit in 43580d1ba665SWarner Losh Operand. All other bits in Operand are preserved. The new 32-bit value is 43590d1ba665SWarner Losh returned. 43600d1ba665SWarner Losh 43610d1ba665SWarner Losh If 32-bit operations are not supported, then ASSERT(). 43620d1ba665SWarner Losh If StartBit is greater than 31, then ASSERT(). 43630d1ba665SWarner Losh If EndBit is greater than 31, then ASSERT(). 43640d1ba665SWarner Losh If EndBit is less than StartBit, then ASSERT(). 43650d1ba665SWarner Losh If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT(). 43660d1ba665SWarner Losh 43670d1ba665SWarner Losh @param Operand Operand on which to perform the bitfield operation. 43680d1ba665SWarner Losh @param StartBit The ordinal of the least significant bit in the bit field. 43690d1ba665SWarner Losh Range 0..31. 43700d1ba665SWarner Losh @param EndBit The ordinal of the most significant bit in the bit field. 43710d1ba665SWarner Losh Range 0..31. 43720d1ba665SWarner Losh @param Value New value of the bit field. 43730d1ba665SWarner Losh 43740d1ba665SWarner Losh @return The new 32-bit value. 43750d1ba665SWarner Losh 43760d1ba665SWarner Losh **/ 43770d1ba665SWarner Losh UINT32 43780d1ba665SWarner Losh EFIAPI 43790d1ba665SWarner Losh BitFieldWrite32 ( 43800d1ba665SWarner Losh IN UINT32 Operand, 43810d1ba665SWarner Losh IN UINTN StartBit, 43820d1ba665SWarner Losh IN UINTN EndBit, 43830d1ba665SWarner Losh IN UINT32 Value 43840d1ba665SWarner Losh ); 43850d1ba665SWarner Losh 43860d1ba665SWarner Losh 43870d1ba665SWarner Losh /** 43880d1ba665SWarner Losh Reads a bit field from a 32-bit value, performs a bitwise OR, and returns the 43890d1ba665SWarner Losh result. 43900d1ba665SWarner Losh 43910d1ba665SWarner Losh Performs a bitwise OR between the bit field specified by StartBit 43920d1ba665SWarner Losh and EndBit in Operand and the value specified by OrData. All other bits in 43930d1ba665SWarner Losh Operand are preserved. The new 32-bit value is returned. 43940d1ba665SWarner Losh 43950d1ba665SWarner Losh If 32-bit operations are not supported, then ASSERT(). 43960d1ba665SWarner Losh If StartBit is greater than 31, then ASSERT(). 43970d1ba665SWarner Losh If EndBit is greater than 31, then ASSERT(). 43980d1ba665SWarner Losh If EndBit is less than StartBit, then ASSERT(). 43990d1ba665SWarner Losh If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT(). 44000d1ba665SWarner Losh 44010d1ba665SWarner Losh @param Operand Operand on which to perform the bitfield operation. 44020d1ba665SWarner Losh @param StartBit The ordinal of the least significant bit in the bit field. 44030d1ba665SWarner Losh Range 0..31. 44040d1ba665SWarner Losh @param EndBit The ordinal of the most significant bit in the bit field. 44050d1ba665SWarner Losh Range 0..31. 44060d1ba665SWarner Losh @param OrData The value to OR with the read value from the value. 44070d1ba665SWarner Losh 44080d1ba665SWarner Losh @return The new 32-bit value. 44090d1ba665SWarner Losh 44100d1ba665SWarner Losh **/ 44110d1ba665SWarner Losh UINT32 44120d1ba665SWarner Losh EFIAPI 44130d1ba665SWarner Losh BitFieldOr32 ( 44140d1ba665SWarner Losh IN UINT32 Operand, 44150d1ba665SWarner Losh IN UINTN StartBit, 44160d1ba665SWarner Losh IN UINTN EndBit, 44170d1ba665SWarner Losh IN UINT32 OrData 44180d1ba665SWarner Losh ); 44190d1ba665SWarner Losh 44200d1ba665SWarner Losh 44210d1ba665SWarner Losh /** 44220d1ba665SWarner Losh Reads a bit field from a 32-bit value, performs a bitwise AND, and returns 44230d1ba665SWarner Losh the result. 44240d1ba665SWarner Losh 44250d1ba665SWarner Losh Performs a bitwise AND between the bit field specified by StartBit and EndBit 44260d1ba665SWarner Losh in Operand and the value specified by AndData. All other bits in Operand are 44270d1ba665SWarner Losh preserved. The new 32-bit value is returned. 44280d1ba665SWarner Losh 44290d1ba665SWarner Losh If 32-bit operations are not supported, then ASSERT(). 44300d1ba665SWarner Losh If StartBit is greater than 31, then ASSERT(). 44310d1ba665SWarner Losh If EndBit is greater than 31, then ASSERT(). 44320d1ba665SWarner Losh If EndBit is less than StartBit, then ASSERT(). 44330d1ba665SWarner Losh If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT(). 44340d1ba665SWarner Losh 44350d1ba665SWarner Losh @param Operand Operand on which to perform the bitfield operation. 44360d1ba665SWarner Losh @param StartBit The ordinal of the least significant bit in the bit field. 44370d1ba665SWarner Losh Range 0..31. 44380d1ba665SWarner Losh @param EndBit The ordinal of the most significant bit in the bit field. 44390d1ba665SWarner Losh Range 0..31. 44400d1ba665SWarner Losh @param AndData The value to AND with the read value from the value 44410d1ba665SWarner Losh 44420d1ba665SWarner Losh @return The new 32-bit value. 44430d1ba665SWarner Losh 44440d1ba665SWarner Losh **/ 44450d1ba665SWarner Losh UINT32 44460d1ba665SWarner Losh EFIAPI 44470d1ba665SWarner Losh BitFieldAnd32 ( 44480d1ba665SWarner Losh IN UINT32 Operand, 44490d1ba665SWarner Losh IN UINTN StartBit, 44500d1ba665SWarner Losh IN UINTN EndBit, 44510d1ba665SWarner Losh IN UINT32 AndData 44520d1ba665SWarner Losh ); 44530d1ba665SWarner Losh 44540d1ba665SWarner Losh 44550d1ba665SWarner Losh /** 44560d1ba665SWarner Losh Reads a bit field from a 32-bit value, performs a bitwise AND followed by a 44570d1ba665SWarner Losh bitwise OR, and returns the result. 44580d1ba665SWarner Losh 44590d1ba665SWarner Losh Performs a bitwise AND between the bit field specified by StartBit and EndBit 44600d1ba665SWarner Losh in Operand and the value specified by AndData, followed by a bitwise 44610d1ba665SWarner Losh OR with value specified by OrData. All other bits in Operand are 44620d1ba665SWarner Losh preserved. The new 32-bit value is returned. 44630d1ba665SWarner Losh 44640d1ba665SWarner Losh If 32-bit operations are not supported, then ASSERT(). 44650d1ba665SWarner Losh If StartBit is greater than 31, then ASSERT(). 44660d1ba665SWarner Losh If EndBit is greater than 31, then ASSERT(). 44670d1ba665SWarner Losh If EndBit is less than StartBit, then ASSERT(). 44680d1ba665SWarner Losh If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT(). 44690d1ba665SWarner Losh If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT(). 44700d1ba665SWarner Losh 44710d1ba665SWarner Losh @param Operand Operand on which to perform the bitfield operation. 44720d1ba665SWarner Losh @param StartBit The ordinal of the least significant bit in the bit field. 44730d1ba665SWarner Losh Range 0..31. 44740d1ba665SWarner Losh @param EndBit The ordinal of the most significant bit in the bit field. 44750d1ba665SWarner Losh Range 0..31. 44760d1ba665SWarner Losh @param AndData The value to AND with the read value from the value. 44770d1ba665SWarner Losh @param OrData The value to OR with the result of the AND operation. 44780d1ba665SWarner Losh 44790d1ba665SWarner Losh @return The new 32-bit value. 44800d1ba665SWarner Losh 44810d1ba665SWarner Losh **/ 44820d1ba665SWarner Losh UINT32 44830d1ba665SWarner Losh EFIAPI 44840d1ba665SWarner Losh BitFieldAndThenOr32 ( 44850d1ba665SWarner Losh IN UINT32 Operand, 44860d1ba665SWarner Losh IN UINTN StartBit, 44870d1ba665SWarner Losh IN UINTN EndBit, 44880d1ba665SWarner Losh IN UINT32 AndData, 44890d1ba665SWarner Losh IN UINT32 OrData 44900d1ba665SWarner Losh ); 44910d1ba665SWarner Losh 44920d1ba665SWarner Losh 44930d1ba665SWarner Losh /** 44940d1ba665SWarner Losh Returns a bit field from a 64-bit value. 44950d1ba665SWarner Losh 44960d1ba665SWarner Losh Returns the bitfield specified by the StartBit and the EndBit from Operand. 44970d1ba665SWarner Losh 44980d1ba665SWarner Losh If 64-bit operations are not supported, then ASSERT(). 44990d1ba665SWarner Losh If StartBit is greater than 63, then ASSERT(). 45000d1ba665SWarner Losh If EndBit is greater than 63, then ASSERT(). 45010d1ba665SWarner Losh If EndBit is less than StartBit, then ASSERT(). 45020d1ba665SWarner Losh 45030d1ba665SWarner Losh @param Operand Operand on which to perform the bitfield operation. 45040d1ba665SWarner Losh @param StartBit The ordinal of the least significant bit in the bit field. 45050d1ba665SWarner Losh Range 0..63. 45060d1ba665SWarner Losh @param EndBit The ordinal of the most significant bit in the bit field. 45070d1ba665SWarner Losh Range 0..63. 45080d1ba665SWarner Losh 45090d1ba665SWarner Losh @return The bit field read. 45100d1ba665SWarner Losh 45110d1ba665SWarner Losh **/ 45120d1ba665SWarner Losh UINT64 45130d1ba665SWarner Losh EFIAPI 45140d1ba665SWarner Losh BitFieldRead64 ( 45150d1ba665SWarner Losh IN UINT64 Operand, 45160d1ba665SWarner Losh IN UINTN StartBit, 45170d1ba665SWarner Losh IN UINTN EndBit 45180d1ba665SWarner Losh ); 45190d1ba665SWarner Losh 45200d1ba665SWarner Losh 45210d1ba665SWarner Losh /** 45220d1ba665SWarner Losh Writes a bit field to a 64-bit value, and returns the result. 45230d1ba665SWarner Losh 45240d1ba665SWarner Losh Writes Value to the bit field specified by the StartBit and the EndBit in 45250d1ba665SWarner Losh Operand. All other bits in Operand are preserved. The new 64-bit value is 45260d1ba665SWarner Losh returned. 45270d1ba665SWarner Losh 45280d1ba665SWarner Losh If 64-bit operations are not supported, then ASSERT(). 45290d1ba665SWarner Losh If StartBit is greater than 63, then ASSERT(). 45300d1ba665SWarner Losh If EndBit is greater than 63, then ASSERT(). 45310d1ba665SWarner Losh If EndBit is less than StartBit, then ASSERT(). 45320d1ba665SWarner Losh If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT(). 45330d1ba665SWarner Losh 45340d1ba665SWarner Losh @param Operand Operand on which to perform the bitfield operation. 45350d1ba665SWarner Losh @param StartBit The ordinal of the least significant bit in the bit field. 45360d1ba665SWarner Losh Range 0..63. 45370d1ba665SWarner Losh @param EndBit The ordinal of the most significant bit in the bit field. 45380d1ba665SWarner Losh Range 0..63. 45390d1ba665SWarner Losh @param Value New value of the bit field. 45400d1ba665SWarner Losh 45410d1ba665SWarner Losh @return The new 64-bit value. 45420d1ba665SWarner Losh 45430d1ba665SWarner Losh **/ 45440d1ba665SWarner Losh UINT64 45450d1ba665SWarner Losh EFIAPI 45460d1ba665SWarner Losh BitFieldWrite64 ( 45470d1ba665SWarner Losh IN UINT64 Operand, 45480d1ba665SWarner Losh IN UINTN StartBit, 45490d1ba665SWarner Losh IN UINTN EndBit, 45500d1ba665SWarner Losh IN UINT64 Value 45510d1ba665SWarner Losh ); 45520d1ba665SWarner Losh 45530d1ba665SWarner Losh 45540d1ba665SWarner Losh /** 45550d1ba665SWarner Losh Reads a bit field from a 64-bit value, performs a bitwise OR, and returns the 45560d1ba665SWarner Losh result. 45570d1ba665SWarner Losh 45580d1ba665SWarner Losh Performs a bitwise OR between the bit field specified by StartBit 45590d1ba665SWarner Losh and EndBit in Operand and the value specified by OrData. All other bits in 45600d1ba665SWarner Losh Operand are preserved. The new 64-bit value is returned. 45610d1ba665SWarner Losh 45620d1ba665SWarner Losh If 64-bit operations are not supported, then ASSERT(). 45630d1ba665SWarner Losh If StartBit is greater than 63, then ASSERT(). 45640d1ba665SWarner Losh If EndBit is greater than 63, then ASSERT(). 45650d1ba665SWarner Losh If EndBit is less than StartBit, then ASSERT(). 45660d1ba665SWarner Losh If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT(). 45670d1ba665SWarner Losh 45680d1ba665SWarner Losh @param Operand Operand on which to perform the bitfield operation. 45690d1ba665SWarner Losh @param StartBit The ordinal of the least significant bit in the bit field. 45700d1ba665SWarner Losh Range 0..63. 45710d1ba665SWarner Losh @param EndBit The ordinal of the most significant bit in the bit field. 45720d1ba665SWarner Losh Range 0..63. 45730d1ba665SWarner Losh @param OrData The value to OR with the read value from the value 45740d1ba665SWarner Losh 45750d1ba665SWarner Losh @return The new 64-bit value. 45760d1ba665SWarner Losh 45770d1ba665SWarner Losh **/ 45780d1ba665SWarner Losh UINT64 45790d1ba665SWarner Losh EFIAPI 45800d1ba665SWarner Losh BitFieldOr64 ( 45810d1ba665SWarner Losh IN UINT64 Operand, 45820d1ba665SWarner Losh IN UINTN StartBit, 45830d1ba665SWarner Losh IN UINTN EndBit, 45840d1ba665SWarner Losh IN UINT64 OrData 45850d1ba665SWarner Losh ); 45860d1ba665SWarner Losh 45870d1ba665SWarner Losh 45880d1ba665SWarner Losh /** 45890d1ba665SWarner Losh Reads a bit field from a 64-bit value, performs a bitwise AND, and returns 45900d1ba665SWarner Losh the result. 45910d1ba665SWarner Losh 45920d1ba665SWarner Losh Performs a bitwise AND between the bit field specified by StartBit and EndBit 45930d1ba665SWarner Losh in Operand and the value specified by AndData. All other bits in Operand are 45940d1ba665SWarner Losh preserved. The new 64-bit value is returned. 45950d1ba665SWarner Losh 45960d1ba665SWarner Losh If 64-bit operations are not supported, then ASSERT(). 45970d1ba665SWarner Losh If StartBit is greater than 63, then ASSERT(). 45980d1ba665SWarner Losh If EndBit is greater than 63, then ASSERT(). 45990d1ba665SWarner Losh If EndBit is less than StartBit, then ASSERT(). 46000d1ba665SWarner Losh If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT(). 46010d1ba665SWarner Losh 46020d1ba665SWarner Losh @param Operand Operand on which to perform the bitfield operation. 46030d1ba665SWarner Losh @param StartBit The ordinal of the least significant bit in the bit field. 46040d1ba665SWarner Losh Range 0..63. 46050d1ba665SWarner Losh @param EndBit The ordinal of the most significant bit in the bit field. 46060d1ba665SWarner Losh Range 0..63. 46070d1ba665SWarner Losh @param AndData The value to AND with the read value from the value 46080d1ba665SWarner Losh 46090d1ba665SWarner Losh @return The new 64-bit value. 46100d1ba665SWarner Losh 46110d1ba665SWarner Losh **/ 46120d1ba665SWarner Losh UINT64 46130d1ba665SWarner Losh EFIAPI 46140d1ba665SWarner Losh BitFieldAnd64 ( 46150d1ba665SWarner Losh IN UINT64 Operand, 46160d1ba665SWarner Losh IN UINTN StartBit, 46170d1ba665SWarner Losh IN UINTN EndBit, 46180d1ba665SWarner Losh IN UINT64 AndData 46190d1ba665SWarner Losh ); 46200d1ba665SWarner Losh 46210d1ba665SWarner Losh 46220d1ba665SWarner Losh /** 46230d1ba665SWarner Losh Reads a bit field from a 64-bit value, performs a bitwise AND followed by a 46240d1ba665SWarner Losh bitwise OR, and returns the result. 46250d1ba665SWarner Losh 46260d1ba665SWarner Losh Performs a bitwise AND between the bit field specified by StartBit and EndBit 46270d1ba665SWarner Losh in Operand and the value specified by AndData, followed by a bitwise 46280d1ba665SWarner Losh OR with value specified by OrData. All other bits in Operand are 46290d1ba665SWarner Losh preserved. The new 64-bit value is returned. 46300d1ba665SWarner Losh 46310d1ba665SWarner Losh If 64-bit operations are not supported, then ASSERT(). 46320d1ba665SWarner Losh If StartBit is greater than 63, then ASSERT(). 46330d1ba665SWarner Losh If EndBit is greater than 63, then ASSERT(). 46340d1ba665SWarner Losh If EndBit is less than StartBit, then ASSERT(). 46350d1ba665SWarner Losh If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT(). 46360d1ba665SWarner Losh If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT(). 46370d1ba665SWarner Losh 46380d1ba665SWarner Losh @param Operand Operand on which to perform the bitfield operation. 46390d1ba665SWarner Losh @param StartBit The ordinal of the least significant bit in the bit field. 46400d1ba665SWarner Losh Range 0..63. 46410d1ba665SWarner Losh @param EndBit The ordinal of the most significant bit in the bit field. 46420d1ba665SWarner Losh Range 0..63. 46430d1ba665SWarner Losh @param AndData The value to AND with the read value from the value. 46440d1ba665SWarner Losh @param OrData The value to OR with the result of the AND operation. 46450d1ba665SWarner Losh 46460d1ba665SWarner Losh @return The new 64-bit value. 46470d1ba665SWarner Losh 46480d1ba665SWarner Losh **/ 46490d1ba665SWarner Losh UINT64 46500d1ba665SWarner Losh EFIAPI 46510d1ba665SWarner Losh BitFieldAndThenOr64 ( 46520d1ba665SWarner Losh IN UINT64 Operand, 46530d1ba665SWarner Losh IN UINTN StartBit, 46540d1ba665SWarner Losh IN UINTN EndBit, 46550d1ba665SWarner Losh IN UINT64 AndData, 46560d1ba665SWarner Losh IN UINT64 OrData 46570d1ba665SWarner Losh ); 46580d1ba665SWarner Losh 4659*3245fa21SMitchell Horne /** 4660*3245fa21SMitchell Horne Reads a bit field from a 32-bit value, counts and returns 4661*3245fa21SMitchell Horne the number of set bits. 4662*3245fa21SMitchell Horne 4663*3245fa21SMitchell Horne Counts the number of set bits in the bit field specified by 4664*3245fa21SMitchell Horne StartBit and EndBit in Operand. The count is returned. 4665*3245fa21SMitchell Horne 4666*3245fa21SMitchell Horne If StartBit is greater than 31, then ASSERT(). 4667*3245fa21SMitchell Horne If EndBit is greater than 31, then ASSERT(). 4668*3245fa21SMitchell Horne If EndBit is less than StartBit, then ASSERT(). 4669*3245fa21SMitchell Horne 4670*3245fa21SMitchell Horne @param Operand Operand on which to perform the bitfield operation. 4671*3245fa21SMitchell Horne @param StartBit The ordinal of the least significant bit in the bit field. 4672*3245fa21SMitchell Horne Range 0..31. 4673*3245fa21SMitchell Horne @param EndBit The ordinal of the most significant bit in the bit field. 4674*3245fa21SMitchell Horne Range 0..31. 4675*3245fa21SMitchell Horne 4676*3245fa21SMitchell Horne @return The number of bits set between StartBit and EndBit. 4677*3245fa21SMitchell Horne 4678*3245fa21SMitchell Horne **/ 4679*3245fa21SMitchell Horne UINT8 4680*3245fa21SMitchell Horne EFIAPI 4681*3245fa21SMitchell Horne BitFieldCountOnes32 ( 4682*3245fa21SMitchell Horne IN UINT32 Operand, 4683*3245fa21SMitchell Horne IN UINTN StartBit, 4684*3245fa21SMitchell Horne IN UINTN EndBit 4685*3245fa21SMitchell Horne ); 4686*3245fa21SMitchell Horne 4687*3245fa21SMitchell Horne /** 4688*3245fa21SMitchell Horne Reads a bit field from a 64-bit value, counts and returns 4689*3245fa21SMitchell Horne the number of set bits. 4690*3245fa21SMitchell Horne 4691*3245fa21SMitchell Horne Counts the number of set bits in the bit field specified by 4692*3245fa21SMitchell Horne StartBit and EndBit in Operand. The count is returned. 4693*3245fa21SMitchell Horne 4694*3245fa21SMitchell Horne If StartBit is greater than 63, then ASSERT(). 4695*3245fa21SMitchell Horne If EndBit is greater than 63, then ASSERT(). 4696*3245fa21SMitchell Horne If EndBit is less than StartBit, then ASSERT(). 4697*3245fa21SMitchell Horne 4698*3245fa21SMitchell Horne @param Operand Operand on which to perform the bitfield operation. 4699*3245fa21SMitchell Horne @param StartBit The ordinal of the least significant bit in the bit field. 4700*3245fa21SMitchell Horne Range 0..63. 4701*3245fa21SMitchell Horne @param EndBit The ordinal of the most significant bit in the bit field. 4702*3245fa21SMitchell Horne Range 0..63. 4703*3245fa21SMitchell Horne 4704*3245fa21SMitchell Horne @return The number of bits set between StartBit and EndBit. 4705*3245fa21SMitchell Horne 4706*3245fa21SMitchell Horne **/ 4707*3245fa21SMitchell Horne UINT8 4708*3245fa21SMitchell Horne EFIAPI 4709*3245fa21SMitchell Horne BitFieldCountOnes64 ( 4710*3245fa21SMitchell Horne IN UINT64 Operand, 4711*3245fa21SMitchell Horne IN UINTN StartBit, 4712*3245fa21SMitchell Horne IN UINTN EndBit 4713*3245fa21SMitchell Horne ); 4714*3245fa21SMitchell Horne 47150d1ba665SWarner Losh // 47160d1ba665SWarner Losh // Base Library Checksum Functions 47170d1ba665SWarner Losh // 47180d1ba665SWarner Losh 47190d1ba665SWarner Losh /** 47200d1ba665SWarner Losh Returns the sum of all elements in a buffer in unit of UINT8. 47210d1ba665SWarner Losh During calculation, the carry bits are dropped. 47220d1ba665SWarner Losh 47230d1ba665SWarner Losh This function calculates the sum of all elements in a buffer 47240d1ba665SWarner Losh in unit of UINT8. The carry bits in result of addition are dropped. 47250d1ba665SWarner Losh The result is returned as UINT8. If Length is Zero, then Zero is 47260d1ba665SWarner Losh returned. 47270d1ba665SWarner Losh 47280d1ba665SWarner Losh If Buffer is NULL, then ASSERT(). 47290d1ba665SWarner Losh If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). 47300d1ba665SWarner Losh 47310d1ba665SWarner Losh @param Buffer The pointer to the buffer to carry out the sum operation. 47320d1ba665SWarner Losh @param Length The size, in bytes, of Buffer. 47330d1ba665SWarner Losh 47340d1ba665SWarner Losh @return Sum The sum of Buffer with carry bits dropped during additions. 47350d1ba665SWarner Losh 47360d1ba665SWarner Losh **/ 47370d1ba665SWarner Losh UINT8 47380d1ba665SWarner Losh EFIAPI 47390d1ba665SWarner Losh CalculateSum8 ( 47400d1ba665SWarner Losh IN CONST UINT8 *Buffer, 47410d1ba665SWarner Losh IN UINTN Length 47420d1ba665SWarner Losh ); 47430d1ba665SWarner Losh 47440d1ba665SWarner Losh 47450d1ba665SWarner Losh /** 47460d1ba665SWarner Losh Returns the two's complement checksum of all elements in a buffer 47470d1ba665SWarner Losh of 8-bit values. 47480d1ba665SWarner Losh 47490d1ba665SWarner Losh This function first calculates the sum of the 8-bit values in the 47500d1ba665SWarner Losh buffer specified by Buffer and Length. The carry bits in the result 47510d1ba665SWarner Losh of addition are dropped. Then, the two's complement of the sum is 47520d1ba665SWarner Losh returned. If Length is 0, then 0 is returned. 47530d1ba665SWarner Losh 47540d1ba665SWarner Losh If Buffer is NULL, then ASSERT(). 47550d1ba665SWarner Losh If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). 47560d1ba665SWarner Losh 47570d1ba665SWarner Losh @param Buffer The pointer to the buffer to carry out the checksum operation. 47580d1ba665SWarner Losh @param Length The size, in bytes, of Buffer. 47590d1ba665SWarner Losh 47600d1ba665SWarner Losh @return Checksum The two's complement checksum of Buffer. 47610d1ba665SWarner Losh 47620d1ba665SWarner Losh **/ 47630d1ba665SWarner Losh UINT8 47640d1ba665SWarner Losh EFIAPI 47650d1ba665SWarner Losh CalculateCheckSum8 ( 47660d1ba665SWarner Losh IN CONST UINT8 *Buffer, 47670d1ba665SWarner Losh IN UINTN Length 47680d1ba665SWarner Losh ); 47690d1ba665SWarner Losh 47700d1ba665SWarner Losh 47710d1ba665SWarner Losh /** 47720d1ba665SWarner Losh Returns the sum of all elements in a buffer of 16-bit values. During 47730d1ba665SWarner Losh calculation, the carry bits are dropped. 47740d1ba665SWarner Losh 47750d1ba665SWarner Losh This function calculates the sum of the 16-bit values in the buffer 47760d1ba665SWarner Losh specified by Buffer and Length. The carry bits in result of addition are dropped. 47770d1ba665SWarner Losh The 16-bit result is returned. If Length is 0, then 0 is returned. 47780d1ba665SWarner Losh 47790d1ba665SWarner Losh If Buffer is NULL, then ASSERT(). 47800d1ba665SWarner Losh If Buffer is not aligned on a 16-bit boundary, then ASSERT(). 47810d1ba665SWarner Losh If Length is not aligned on a 16-bit boundary, then ASSERT(). 47820d1ba665SWarner Losh If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). 47830d1ba665SWarner Losh 47840d1ba665SWarner Losh @param Buffer The pointer to the buffer to carry out the sum operation. 47850d1ba665SWarner Losh @param Length The size, in bytes, of Buffer. 47860d1ba665SWarner Losh 47870d1ba665SWarner Losh @return Sum The sum of Buffer with carry bits dropped during additions. 47880d1ba665SWarner Losh 47890d1ba665SWarner Losh **/ 47900d1ba665SWarner Losh UINT16 47910d1ba665SWarner Losh EFIAPI 47920d1ba665SWarner Losh CalculateSum16 ( 47930d1ba665SWarner Losh IN CONST UINT16 *Buffer, 47940d1ba665SWarner Losh IN UINTN Length 47950d1ba665SWarner Losh ); 47960d1ba665SWarner Losh 47970d1ba665SWarner Losh 47980d1ba665SWarner Losh /** 47990d1ba665SWarner Losh Returns the two's complement checksum of all elements in a buffer of 48000d1ba665SWarner Losh 16-bit values. 48010d1ba665SWarner Losh 48020d1ba665SWarner Losh This function first calculates the sum of the 16-bit values in the buffer 48030d1ba665SWarner Losh specified by Buffer and Length. The carry bits in the result of addition 48040d1ba665SWarner Losh are dropped. Then, the two's complement of the sum is returned. If Length 48050d1ba665SWarner Losh is 0, then 0 is returned. 48060d1ba665SWarner Losh 48070d1ba665SWarner Losh If Buffer is NULL, then ASSERT(). 48080d1ba665SWarner Losh If Buffer is not aligned on a 16-bit boundary, then ASSERT(). 48090d1ba665SWarner Losh If Length is not aligned on a 16-bit boundary, then ASSERT(). 48100d1ba665SWarner Losh If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). 48110d1ba665SWarner Losh 48120d1ba665SWarner Losh @param Buffer The pointer to the buffer to carry out the checksum operation. 48130d1ba665SWarner Losh @param Length The size, in bytes, of Buffer. 48140d1ba665SWarner Losh 48150d1ba665SWarner Losh @return Checksum The two's complement checksum of Buffer. 48160d1ba665SWarner Losh 48170d1ba665SWarner Losh **/ 48180d1ba665SWarner Losh UINT16 48190d1ba665SWarner Losh EFIAPI 48200d1ba665SWarner Losh CalculateCheckSum16 ( 48210d1ba665SWarner Losh IN CONST UINT16 *Buffer, 48220d1ba665SWarner Losh IN UINTN Length 48230d1ba665SWarner Losh ); 48240d1ba665SWarner Losh 48250d1ba665SWarner Losh 48260d1ba665SWarner Losh /** 48270d1ba665SWarner Losh Returns the sum of all elements in a buffer of 32-bit values. During 48280d1ba665SWarner Losh calculation, the carry bits are dropped. 48290d1ba665SWarner Losh 48300d1ba665SWarner Losh This function calculates the sum of the 32-bit values in the buffer 48310d1ba665SWarner Losh specified by Buffer and Length. The carry bits in result of addition are dropped. 48320d1ba665SWarner Losh The 32-bit result is returned. If Length is 0, then 0 is returned. 48330d1ba665SWarner Losh 48340d1ba665SWarner Losh If Buffer is NULL, then ASSERT(). 48350d1ba665SWarner Losh If Buffer is not aligned on a 32-bit boundary, then ASSERT(). 48360d1ba665SWarner Losh If Length is not aligned on a 32-bit boundary, then ASSERT(). 48370d1ba665SWarner Losh If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). 48380d1ba665SWarner Losh 48390d1ba665SWarner Losh @param Buffer The pointer to the buffer to carry out the sum operation. 48400d1ba665SWarner Losh @param Length The size, in bytes, of Buffer. 48410d1ba665SWarner Losh 48420d1ba665SWarner Losh @return Sum The sum of Buffer with carry bits dropped during additions. 48430d1ba665SWarner Losh 48440d1ba665SWarner Losh **/ 48450d1ba665SWarner Losh UINT32 48460d1ba665SWarner Losh EFIAPI 48470d1ba665SWarner Losh CalculateSum32 ( 48480d1ba665SWarner Losh IN CONST UINT32 *Buffer, 48490d1ba665SWarner Losh IN UINTN Length 48500d1ba665SWarner Losh ); 48510d1ba665SWarner Losh 48520d1ba665SWarner Losh 48530d1ba665SWarner Losh /** 48540d1ba665SWarner Losh Returns the two's complement checksum of all elements in a buffer of 48550d1ba665SWarner Losh 32-bit values. 48560d1ba665SWarner Losh 48570d1ba665SWarner Losh This function first calculates the sum of the 32-bit values in the buffer 48580d1ba665SWarner Losh specified by Buffer and Length. The carry bits in the result of addition 48590d1ba665SWarner Losh are dropped. Then, the two's complement of the sum is returned. If Length 48600d1ba665SWarner Losh is 0, then 0 is returned. 48610d1ba665SWarner Losh 48620d1ba665SWarner Losh If Buffer is NULL, then ASSERT(). 48630d1ba665SWarner Losh If Buffer is not aligned on a 32-bit boundary, then ASSERT(). 48640d1ba665SWarner Losh If Length is not aligned on a 32-bit boundary, then ASSERT(). 48650d1ba665SWarner Losh If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). 48660d1ba665SWarner Losh 48670d1ba665SWarner Losh @param Buffer The pointer to the buffer to carry out the checksum operation. 48680d1ba665SWarner Losh @param Length The size, in bytes, of Buffer. 48690d1ba665SWarner Losh 48700d1ba665SWarner Losh @return Checksum The two's complement checksum of Buffer. 48710d1ba665SWarner Losh 48720d1ba665SWarner Losh **/ 48730d1ba665SWarner Losh UINT32 48740d1ba665SWarner Losh EFIAPI 48750d1ba665SWarner Losh CalculateCheckSum32 ( 48760d1ba665SWarner Losh IN CONST UINT32 *Buffer, 48770d1ba665SWarner Losh IN UINTN Length 48780d1ba665SWarner Losh ); 48790d1ba665SWarner Losh 48800d1ba665SWarner Losh 48810d1ba665SWarner Losh /** 48820d1ba665SWarner Losh Returns the sum of all elements in a buffer of 64-bit values. During 48830d1ba665SWarner Losh calculation, the carry bits are dropped. 48840d1ba665SWarner Losh 48850d1ba665SWarner Losh This function calculates the sum of the 64-bit values in the buffer 48860d1ba665SWarner Losh specified by Buffer and Length. The carry bits in result of addition are dropped. 48870d1ba665SWarner Losh The 64-bit result is returned. If Length is 0, then 0 is returned. 48880d1ba665SWarner Losh 48890d1ba665SWarner Losh If Buffer is NULL, then ASSERT(). 48900d1ba665SWarner Losh If Buffer is not aligned on a 64-bit boundary, then ASSERT(). 48910d1ba665SWarner Losh If Length is not aligned on a 64-bit boundary, then ASSERT(). 48920d1ba665SWarner Losh If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). 48930d1ba665SWarner Losh 48940d1ba665SWarner Losh @param Buffer The pointer to the buffer to carry out the sum operation. 48950d1ba665SWarner Losh @param Length The size, in bytes, of Buffer. 48960d1ba665SWarner Losh 48970d1ba665SWarner Losh @return Sum The sum of Buffer with carry bits dropped during additions. 48980d1ba665SWarner Losh 48990d1ba665SWarner Losh **/ 49000d1ba665SWarner Losh UINT64 49010d1ba665SWarner Losh EFIAPI 49020d1ba665SWarner Losh CalculateSum64 ( 49030d1ba665SWarner Losh IN CONST UINT64 *Buffer, 49040d1ba665SWarner Losh IN UINTN Length 49050d1ba665SWarner Losh ); 49060d1ba665SWarner Losh 49070d1ba665SWarner Losh 49080d1ba665SWarner Losh /** 49090d1ba665SWarner Losh Returns the two's complement checksum of all elements in a buffer of 49100d1ba665SWarner Losh 64-bit values. 49110d1ba665SWarner Losh 49120d1ba665SWarner Losh This function first calculates the sum of the 64-bit values in the buffer 49130d1ba665SWarner Losh specified by Buffer and Length. The carry bits in the result of addition 49140d1ba665SWarner Losh are dropped. Then, the two's complement of the sum is returned. If Length 49150d1ba665SWarner Losh is 0, then 0 is returned. 49160d1ba665SWarner Losh 49170d1ba665SWarner Losh If Buffer is NULL, then ASSERT(). 49180d1ba665SWarner Losh If Buffer is not aligned on a 64-bit boundary, then ASSERT(). 49190d1ba665SWarner Losh If Length is not aligned on a 64-bit boundary, then ASSERT(). 49200d1ba665SWarner Losh If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). 49210d1ba665SWarner Losh 49220d1ba665SWarner Losh @param Buffer The pointer to the buffer to carry out the checksum operation. 49230d1ba665SWarner Losh @param Length The size, in bytes, of Buffer. 49240d1ba665SWarner Losh 49250d1ba665SWarner Losh @return Checksum The two's complement checksum of Buffer. 49260d1ba665SWarner Losh 49270d1ba665SWarner Losh **/ 49280d1ba665SWarner Losh UINT64 49290d1ba665SWarner Losh EFIAPI 49300d1ba665SWarner Losh CalculateCheckSum64 ( 49310d1ba665SWarner Losh IN CONST UINT64 *Buffer, 49320d1ba665SWarner Losh IN UINTN Length 49330d1ba665SWarner Losh ); 49340d1ba665SWarner Losh 4935*3245fa21SMitchell Horne /** 4936*3245fa21SMitchell Horne Computes and returns a 32-bit CRC for a data buffer. 4937*3245fa21SMitchell Horne CRC32 value bases on ITU-T V.42. 4938*3245fa21SMitchell Horne 4939*3245fa21SMitchell Horne If Buffer is NULL, then ASSERT(). 4940*3245fa21SMitchell Horne If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). 4941*3245fa21SMitchell Horne 4942*3245fa21SMitchell Horne @param[in] Buffer A pointer to the buffer on which the 32-bit CRC is to be computed. 4943*3245fa21SMitchell Horne @param[in] Length The number of bytes in the buffer Data. 4944*3245fa21SMitchell Horne 4945*3245fa21SMitchell Horne @retval Crc32 The 32-bit CRC was computed for the data buffer. 4946*3245fa21SMitchell Horne 4947*3245fa21SMitchell Horne **/ 4948*3245fa21SMitchell Horne UINT32 4949*3245fa21SMitchell Horne EFIAPI 4950*3245fa21SMitchell Horne CalculateCrc32( 4951*3245fa21SMitchell Horne IN VOID *Buffer, 4952*3245fa21SMitchell Horne IN UINTN Length 4953*3245fa21SMitchell Horne ); 49540d1ba665SWarner Losh 49550d1ba665SWarner Losh // 49560d1ba665SWarner Losh // Base Library CPU Functions 49570d1ba665SWarner Losh // 49580d1ba665SWarner Losh 49590d1ba665SWarner Losh /** 49600d1ba665SWarner Losh Function entry point used when a stack switch is requested with SwitchStack() 49610d1ba665SWarner Losh 49620d1ba665SWarner Losh @param Context1 Context1 parameter passed into SwitchStack(). 49630d1ba665SWarner Losh @param Context2 Context2 parameter passed into SwitchStack(). 49640d1ba665SWarner Losh 49650d1ba665SWarner Losh **/ 49660d1ba665SWarner Losh typedef 49670d1ba665SWarner Losh VOID 49680d1ba665SWarner Losh (EFIAPI *SWITCH_STACK_ENTRY_POINT)( 49690d1ba665SWarner Losh IN VOID *Context1, OPTIONAL 49700d1ba665SWarner Losh IN VOID *Context2 OPTIONAL 49710d1ba665SWarner Losh ); 49720d1ba665SWarner Losh 49730d1ba665SWarner Losh 49740d1ba665SWarner Losh /** 49750d1ba665SWarner Losh Used to serialize load and store operations. 49760d1ba665SWarner Losh 49770d1ba665SWarner Losh All loads and stores that proceed calls to this function are guaranteed to be 49780d1ba665SWarner Losh globally visible when this function returns. 49790d1ba665SWarner Losh 49800d1ba665SWarner Losh **/ 49810d1ba665SWarner Losh VOID 49820d1ba665SWarner Losh EFIAPI 49830d1ba665SWarner Losh MemoryFence ( 49840d1ba665SWarner Losh VOID 49850d1ba665SWarner Losh ); 49860d1ba665SWarner Losh 49870d1ba665SWarner Losh 49880d1ba665SWarner Losh /** 49890d1ba665SWarner Losh Saves the current CPU context that can be restored with a call to LongJump() 49900d1ba665SWarner Losh and returns 0. 49910d1ba665SWarner Losh 49920d1ba665SWarner Losh Saves the current CPU context in the buffer specified by JumpBuffer and 49930d1ba665SWarner Losh returns 0. The initial call to SetJump() must always return 0. Subsequent 49940d1ba665SWarner Losh calls to LongJump() cause a non-zero value to be returned by SetJump(). 49950d1ba665SWarner Losh 49960d1ba665SWarner Losh If JumpBuffer is NULL, then ASSERT(). 49970d1ba665SWarner Losh For Itanium processors, if JumpBuffer is not aligned on a 16-byte boundary, then ASSERT(). 49980d1ba665SWarner Losh 49990d1ba665SWarner Losh NOTE: The structure BASE_LIBRARY_JUMP_BUFFER is CPU architecture specific. 50000d1ba665SWarner Losh The same structure must never be used for more than one CPU architecture context. 50010d1ba665SWarner Losh For example, a BASE_LIBRARY_JUMP_BUFFER allocated by an IA-32 module must never be used from an x64 module. 50020d1ba665SWarner Losh SetJump()/LongJump() is not currently supported for the EBC processor type. 50030d1ba665SWarner Losh 50040d1ba665SWarner Losh @param JumpBuffer A pointer to CPU context buffer. 50050d1ba665SWarner Losh 50060d1ba665SWarner Losh @retval 0 Indicates a return from SetJump(). 50070d1ba665SWarner Losh 50080d1ba665SWarner Losh **/ 5009*3245fa21SMitchell Horne RETURNS_TWICE 50100d1ba665SWarner Losh UINTN 50110d1ba665SWarner Losh EFIAPI 50120d1ba665SWarner Losh SetJump ( 50130d1ba665SWarner Losh OUT BASE_LIBRARY_JUMP_BUFFER *JumpBuffer 50140d1ba665SWarner Losh ); 50150d1ba665SWarner Losh 50160d1ba665SWarner Losh 50170d1ba665SWarner Losh /** 50180d1ba665SWarner Losh Restores the CPU context that was saved with SetJump(). 50190d1ba665SWarner Losh 50200d1ba665SWarner Losh Restores the CPU context from the buffer specified by JumpBuffer. This 50210d1ba665SWarner Losh function never returns to the caller. Instead is resumes execution based on 50220d1ba665SWarner Losh the state of JumpBuffer. 50230d1ba665SWarner Losh 50240d1ba665SWarner Losh If JumpBuffer is NULL, then ASSERT(). 50250d1ba665SWarner Losh For Itanium processors, if JumpBuffer is not aligned on a 16-byte boundary, then ASSERT(). 50260d1ba665SWarner Losh If Value is 0, then ASSERT(). 50270d1ba665SWarner Losh 50280d1ba665SWarner Losh @param JumpBuffer A pointer to CPU context buffer. 50290d1ba665SWarner Losh @param Value The value to return when the SetJump() context is 50300d1ba665SWarner Losh restored and must be non-zero. 50310d1ba665SWarner Losh 50320d1ba665SWarner Losh **/ 50330d1ba665SWarner Losh VOID 50340d1ba665SWarner Losh EFIAPI 50350d1ba665SWarner Losh LongJump ( 50360d1ba665SWarner Losh IN BASE_LIBRARY_JUMP_BUFFER *JumpBuffer, 50370d1ba665SWarner Losh IN UINTN Value 50380d1ba665SWarner Losh ); 50390d1ba665SWarner Losh 50400d1ba665SWarner Losh 50410d1ba665SWarner Losh /** 50420d1ba665SWarner Losh Enables CPU interrupts. 50430d1ba665SWarner Losh 50440d1ba665SWarner Losh **/ 50450d1ba665SWarner Losh VOID 50460d1ba665SWarner Losh EFIAPI 50470d1ba665SWarner Losh EnableInterrupts ( 50480d1ba665SWarner Losh VOID 50490d1ba665SWarner Losh ); 50500d1ba665SWarner Losh 50510d1ba665SWarner Losh 50520d1ba665SWarner Losh /** 50530d1ba665SWarner Losh Disables CPU interrupts. 50540d1ba665SWarner Losh 50550d1ba665SWarner Losh **/ 50560d1ba665SWarner Losh VOID 50570d1ba665SWarner Losh EFIAPI 50580d1ba665SWarner Losh DisableInterrupts ( 50590d1ba665SWarner Losh VOID 50600d1ba665SWarner Losh ); 50610d1ba665SWarner Losh 50620d1ba665SWarner Losh 50630d1ba665SWarner Losh /** 50640d1ba665SWarner Losh Disables CPU interrupts and returns the interrupt state prior to the disable 50650d1ba665SWarner Losh operation. 50660d1ba665SWarner Losh 50670d1ba665SWarner Losh @retval TRUE CPU interrupts were enabled on entry to this call. 50680d1ba665SWarner Losh @retval FALSE CPU interrupts were disabled on entry to this call. 50690d1ba665SWarner Losh 50700d1ba665SWarner Losh **/ 50710d1ba665SWarner Losh BOOLEAN 50720d1ba665SWarner Losh EFIAPI 50730d1ba665SWarner Losh SaveAndDisableInterrupts ( 50740d1ba665SWarner Losh VOID 50750d1ba665SWarner Losh ); 50760d1ba665SWarner Losh 50770d1ba665SWarner Losh 50780d1ba665SWarner Losh /** 50790d1ba665SWarner Losh Enables CPU interrupts for the smallest window required to capture any 50800d1ba665SWarner Losh pending interrupts. 50810d1ba665SWarner Losh 50820d1ba665SWarner Losh **/ 50830d1ba665SWarner Losh VOID 50840d1ba665SWarner Losh EFIAPI 50850d1ba665SWarner Losh EnableDisableInterrupts ( 50860d1ba665SWarner Losh VOID 50870d1ba665SWarner Losh ); 50880d1ba665SWarner Losh 50890d1ba665SWarner Losh 50900d1ba665SWarner Losh /** 50910d1ba665SWarner Losh Retrieves the current CPU interrupt state. 50920d1ba665SWarner Losh 50930d1ba665SWarner Losh Returns TRUE if interrupts are currently enabled. Otherwise 50940d1ba665SWarner Losh returns FALSE. 50950d1ba665SWarner Losh 50960d1ba665SWarner Losh @retval TRUE CPU interrupts are enabled. 50970d1ba665SWarner Losh @retval FALSE CPU interrupts are disabled. 50980d1ba665SWarner Losh 50990d1ba665SWarner Losh **/ 51000d1ba665SWarner Losh BOOLEAN 51010d1ba665SWarner Losh EFIAPI 51020d1ba665SWarner Losh GetInterruptState ( 51030d1ba665SWarner Losh VOID 51040d1ba665SWarner Losh ); 51050d1ba665SWarner Losh 51060d1ba665SWarner Losh 51070d1ba665SWarner Losh /** 51080d1ba665SWarner Losh Set the current CPU interrupt state. 51090d1ba665SWarner Losh 51100d1ba665SWarner Losh Sets the current CPU interrupt state to the state specified by 51110d1ba665SWarner Losh InterruptState. If InterruptState is TRUE, then interrupts are enabled. If 51120d1ba665SWarner Losh InterruptState is FALSE, then interrupts are disabled. InterruptState is 51130d1ba665SWarner Losh returned. 51140d1ba665SWarner Losh 51150d1ba665SWarner Losh @param InterruptState TRUE if interrupts should enabled. FALSE if 51160d1ba665SWarner Losh interrupts should be disabled. 51170d1ba665SWarner Losh 51180d1ba665SWarner Losh @return InterruptState 51190d1ba665SWarner Losh 51200d1ba665SWarner Losh **/ 51210d1ba665SWarner Losh BOOLEAN 51220d1ba665SWarner Losh EFIAPI 51230d1ba665SWarner Losh SetInterruptState ( 51240d1ba665SWarner Losh IN BOOLEAN InterruptState 51250d1ba665SWarner Losh ); 51260d1ba665SWarner Losh 51270d1ba665SWarner Losh 51280d1ba665SWarner Losh /** 51290d1ba665SWarner Losh Requests CPU to pause for a short period of time. 51300d1ba665SWarner Losh 51310d1ba665SWarner Losh Requests CPU to pause for a short period of time. Typically used in MP 51320d1ba665SWarner Losh systems to prevent memory starvation while waiting for a spin lock. 51330d1ba665SWarner Losh 51340d1ba665SWarner Losh **/ 51350d1ba665SWarner Losh VOID 51360d1ba665SWarner Losh EFIAPI 51370d1ba665SWarner Losh CpuPause ( 51380d1ba665SWarner Losh VOID 51390d1ba665SWarner Losh ); 51400d1ba665SWarner Losh 51410d1ba665SWarner Losh 51420d1ba665SWarner Losh /** 51430d1ba665SWarner Losh Transfers control to a function starting with a new stack. 51440d1ba665SWarner Losh 51450d1ba665SWarner Losh Transfers control to the function specified by EntryPoint using the 51460d1ba665SWarner Losh new stack specified by NewStack and passing in the parameters specified 51470d1ba665SWarner Losh by Context1 and Context2. Context1 and Context2 are optional and may 51480d1ba665SWarner Losh be NULL. The function EntryPoint must never return. This function 51490d1ba665SWarner Losh supports a variable number of arguments following the NewStack parameter. 51500d1ba665SWarner Losh These additional arguments are ignored on IA-32, x64, and EBC architectures. 51510d1ba665SWarner Losh Itanium processors expect one additional parameter of type VOID * that specifies 51520d1ba665SWarner Losh the new backing store pointer. 51530d1ba665SWarner Losh 51540d1ba665SWarner Losh If EntryPoint is NULL, then ASSERT(). 51550d1ba665SWarner Losh If NewStack is NULL, then ASSERT(). 51560d1ba665SWarner Losh 51570d1ba665SWarner Losh @param EntryPoint A pointer to function to call with the new stack. 51580d1ba665SWarner Losh @param Context1 A pointer to the context to pass into the EntryPoint 51590d1ba665SWarner Losh function. 51600d1ba665SWarner Losh @param Context2 A pointer to the context to pass into the EntryPoint 51610d1ba665SWarner Losh function. 51620d1ba665SWarner Losh @param NewStack A pointer to the new stack to use for the EntryPoint 51630d1ba665SWarner Losh function. 51640d1ba665SWarner Losh @param ... This variable argument list is ignored for IA-32, x64, and 51650d1ba665SWarner Losh EBC architectures. For Itanium processors, this variable 51660d1ba665SWarner Losh argument list is expected to contain a single parameter of 51670d1ba665SWarner Losh type VOID * that specifies the new backing store pointer. 51680d1ba665SWarner Losh 51690d1ba665SWarner Losh 51700d1ba665SWarner Losh **/ 51710d1ba665SWarner Losh VOID 51720d1ba665SWarner Losh EFIAPI 51730d1ba665SWarner Losh SwitchStack ( 51740d1ba665SWarner Losh IN SWITCH_STACK_ENTRY_POINT EntryPoint, 51750d1ba665SWarner Losh IN VOID *Context1, OPTIONAL 51760d1ba665SWarner Losh IN VOID *Context2, OPTIONAL 51770d1ba665SWarner Losh IN VOID *NewStack, 51780d1ba665SWarner Losh ... 51790d1ba665SWarner Losh ); 51800d1ba665SWarner Losh 51810d1ba665SWarner Losh 51820d1ba665SWarner Losh /** 51830d1ba665SWarner Losh Generates a breakpoint on the CPU. 51840d1ba665SWarner Losh 51850d1ba665SWarner Losh Generates a breakpoint on the CPU. The breakpoint must be implemented such 51860d1ba665SWarner Losh that code can resume normal execution after the breakpoint. 51870d1ba665SWarner Losh 51880d1ba665SWarner Losh **/ 51890d1ba665SWarner Losh VOID 51900d1ba665SWarner Losh EFIAPI 51910d1ba665SWarner Losh CpuBreakpoint ( 51920d1ba665SWarner Losh VOID 51930d1ba665SWarner Losh ); 51940d1ba665SWarner Losh 51950d1ba665SWarner Losh 51960d1ba665SWarner Losh /** 51970d1ba665SWarner Losh Executes an infinite loop. 51980d1ba665SWarner Losh 51990d1ba665SWarner Losh Forces the CPU to execute an infinite loop. A debugger may be used to skip 52000d1ba665SWarner Losh past the loop and the code that follows the loop must execute properly. This 52010d1ba665SWarner Losh implies that the infinite loop must not cause the code that follow it to be 52020d1ba665SWarner Losh optimized away. 52030d1ba665SWarner Losh 52040d1ba665SWarner Losh **/ 52050d1ba665SWarner Losh VOID 52060d1ba665SWarner Losh EFIAPI 52070d1ba665SWarner Losh CpuDeadLoop ( 52080d1ba665SWarner Losh VOID 52090d1ba665SWarner Losh ); 52100d1ba665SWarner Losh 52110d1ba665SWarner Losh 52120d1ba665SWarner Losh /** 5213*3245fa21SMitchell Horne Uses as a barrier to stop speculative execution. 52140d1ba665SWarner Losh 5215*3245fa21SMitchell Horne Ensures that no later instruction will execute speculatively, until all prior 5216*3245fa21SMitchell Horne instructions have completed. 52170d1ba665SWarner Losh 52180d1ba665SWarner Losh **/ 52190d1ba665SWarner Losh VOID 52200d1ba665SWarner Losh EFIAPI 5221*3245fa21SMitchell Horne SpeculationBarrier ( 52220d1ba665SWarner Losh VOID 52230d1ba665SWarner Losh ); 52240d1ba665SWarner Losh 52250d1ba665SWarner Losh 52260d1ba665SWarner Losh #if defined (MDE_CPU_IA32) || defined (MDE_CPU_X64) 52270d1ba665SWarner Losh /// 52280d1ba665SWarner Losh /// IA32 and x64 Specific Functions. 52290d1ba665SWarner Losh /// Byte packed structure for 16-bit Real Mode EFLAGS. 52300d1ba665SWarner Losh /// 52310d1ba665SWarner Losh typedef union { 52320d1ba665SWarner Losh struct { 52330d1ba665SWarner Losh UINT32 CF:1; ///< Carry Flag. 52340d1ba665SWarner Losh UINT32 Reserved_0:1; ///< Reserved. 52350d1ba665SWarner Losh UINT32 PF:1; ///< Parity Flag. 52360d1ba665SWarner Losh UINT32 Reserved_1:1; ///< Reserved. 52370d1ba665SWarner Losh UINT32 AF:1; ///< Auxiliary Carry Flag. 52380d1ba665SWarner Losh UINT32 Reserved_2:1; ///< Reserved. 52390d1ba665SWarner Losh UINT32 ZF:1; ///< Zero Flag. 52400d1ba665SWarner Losh UINT32 SF:1; ///< Sign Flag. 52410d1ba665SWarner Losh UINT32 TF:1; ///< Trap Flag. 52420d1ba665SWarner Losh UINT32 IF:1; ///< Interrupt Enable Flag. 52430d1ba665SWarner Losh UINT32 DF:1; ///< Direction Flag. 52440d1ba665SWarner Losh UINT32 OF:1; ///< Overflow Flag. 52450d1ba665SWarner Losh UINT32 IOPL:2; ///< I/O Privilege Level. 52460d1ba665SWarner Losh UINT32 NT:1; ///< Nested Task. 52470d1ba665SWarner Losh UINT32 Reserved_3:1; ///< Reserved. 52480d1ba665SWarner Losh } Bits; 52490d1ba665SWarner Losh UINT16 Uint16; 52500d1ba665SWarner Losh } IA32_FLAGS16; 52510d1ba665SWarner Losh 52520d1ba665SWarner Losh /// 52530d1ba665SWarner Losh /// Byte packed structure for EFLAGS/RFLAGS. 52540d1ba665SWarner Losh /// 32-bits on IA-32. 52550d1ba665SWarner Losh /// 64-bits on x64. The upper 32-bits on x64 are reserved. 52560d1ba665SWarner Losh /// 52570d1ba665SWarner Losh typedef union { 52580d1ba665SWarner Losh struct { 52590d1ba665SWarner Losh UINT32 CF:1; ///< Carry Flag. 52600d1ba665SWarner Losh UINT32 Reserved_0:1; ///< Reserved. 52610d1ba665SWarner Losh UINT32 PF:1; ///< Parity Flag. 52620d1ba665SWarner Losh UINT32 Reserved_1:1; ///< Reserved. 52630d1ba665SWarner Losh UINT32 AF:1; ///< Auxiliary Carry Flag. 52640d1ba665SWarner Losh UINT32 Reserved_2:1; ///< Reserved. 52650d1ba665SWarner Losh UINT32 ZF:1; ///< Zero Flag. 52660d1ba665SWarner Losh UINT32 SF:1; ///< Sign Flag. 52670d1ba665SWarner Losh UINT32 TF:1; ///< Trap Flag. 52680d1ba665SWarner Losh UINT32 IF:1; ///< Interrupt Enable Flag. 52690d1ba665SWarner Losh UINT32 DF:1; ///< Direction Flag. 52700d1ba665SWarner Losh UINT32 OF:1; ///< Overflow Flag. 52710d1ba665SWarner Losh UINT32 IOPL:2; ///< I/O Privilege Level. 52720d1ba665SWarner Losh UINT32 NT:1; ///< Nested Task. 52730d1ba665SWarner Losh UINT32 Reserved_3:1; ///< Reserved. 52740d1ba665SWarner Losh UINT32 RF:1; ///< Resume Flag. 52750d1ba665SWarner Losh UINT32 VM:1; ///< Virtual 8086 Mode. 52760d1ba665SWarner Losh UINT32 AC:1; ///< Alignment Check. 52770d1ba665SWarner Losh UINT32 VIF:1; ///< Virtual Interrupt Flag. 52780d1ba665SWarner Losh UINT32 VIP:1; ///< Virtual Interrupt Pending. 52790d1ba665SWarner Losh UINT32 ID:1; ///< ID Flag. 52800d1ba665SWarner Losh UINT32 Reserved_4:10; ///< Reserved. 52810d1ba665SWarner Losh } Bits; 52820d1ba665SWarner Losh UINTN UintN; 52830d1ba665SWarner Losh } IA32_EFLAGS32; 52840d1ba665SWarner Losh 52850d1ba665SWarner Losh /// 52860d1ba665SWarner Losh /// Byte packed structure for Control Register 0 (CR0). 52870d1ba665SWarner Losh /// 32-bits on IA-32. 52880d1ba665SWarner Losh /// 64-bits on x64. The upper 32-bits on x64 are reserved. 52890d1ba665SWarner Losh /// 52900d1ba665SWarner Losh typedef union { 52910d1ba665SWarner Losh struct { 52920d1ba665SWarner Losh UINT32 PE:1; ///< Protection Enable. 52930d1ba665SWarner Losh UINT32 MP:1; ///< Monitor Coprocessor. 52940d1ba665SWarner Losh UINT32 EM:1; ///< Emulation. 52950d1ba665SWarner Losh UINT32 TS:1; ///< Task Switched. 52960d1ba665SWarner Losh UINT32 ET:1; ///< Extension Type. 52970d1ba665SWarner Losh UINT32 NE:1; ///< Numeric Error. 52980d1ba665SWarner Losh UINT32 Reserved_0:10; ///< Reserved. 52990d1ba665SWarner Losh UINT32 WP:1; ///< Write Protect. 53000d1ba665SWarner Losh UINT32 Reserved_1:1; ///< Reserved. 53010d1ba665SWarner Losh UINT32 AM:1; ///< Alignment Mask. 53020d1ba665SWarner Losh UINT32 Reserved_2:10; ///< Reserved. 53030d1ba665SWarner Losh UINT32 NW:1; ///< Mot Write-through. 53040d1ba665SWarner Losh UINT32 CD:1; ///< Cache Disable. 53050d1ba665SWarner Losh UINT32 PG:1; ///< Paging. 53060d1ba665SWarner Losh } Bits; 53070d1ba665SWarner Losh UINTN UintN; 53080d1ba665SWarner Losh } IA32_CR0; 53090d1ba665SWarner Losh 53100d1ba665SWarner Losh /// 53110d1ba665SWarner Losh /// Byte packed structure for Control Register 4 (CR4). 53120d1ba665SWarner Losh /// 32-bits on IA-32. 53130d1ba665SWarner Losh /// 64-bits on x64. The upper 32-bits on x64 are reserved. 53140d1ba665SWarner Losh /// 53150d1ba665SWarner Losh typedef union { 53160d1ba665SWarner Losh struct { 53170d1ba665SWarner Losh UINT32 VME:1; ///< Virtual-8086 Mode Extensions. 53180d1ba665SWarner Losh UINT32 PVI:1; ///< Protected-Mode Virtual Interrupts. 53190d1ba665SWarner Losh UINT32 TSD:1; ///< Time Stamp Disable. 53200d1ba665SWarner Losh UINT32 DE:1; ///< Debugging Extensions. 53210d1ba665SWarner Losh UINT32 PSE:1; ///< Page Size Extensions. 53220d1ba665SWarner Losh UINT32 PAE:1; ///< Physical Address Extension. 53230d1ba665SWarner Losh UINT32 MCE:1; ///< Machine Check Enable. 53240d1ba665SWarner Losh UINT32 PGE:1; ///< Page Global Enable. 53250d1ba665SWarner Losh UINT32 PCE:1; ///< Performance Monitoring Counter 53260d1ba665SWarner Losh ///< Enable. 53270d1ba665SWarner Losh UINT32 OSFXSR:1; ///< Operating System Support for 53280d1ba665SWarner Losh ///< FXSAVE and FXRSTOR instructions 53290d1ba665SWarner Losh UINT32 OSXMMEXCPT:1; ///< Operating System Support for 53300d1ba665SWarner Losh ///< Unmasked SIMD Floating Point 53310d1ba665SWarner Losh ///< Exceptions. 5332*3245fa21SMitchell Horne UINT32 UMIP:1; ///< User-Mode Instruction Prevention. 5333*3245fa21SMitchell Horne UINT32 LA57:1; ///< Linear Address 57bit. 5334*3245fa21SMitchell Horne UINT32 VMXE:1; ///< VMX Enable. 5335*3245fa21SMitchell Horne UINT32 SMXE:1; ///< SMX Enable. 5336*3245fa21SMitchell Horne UINT32 Reserved_3:1; ///< Reserved. 5337*3245fa21SMitchell Horne UINT32 FSGSBASE:1; ///< FSGSBASE Enable. 5338*3245fa21SMitchell Horne UINT32 PCIDE:1; ///< PCID Enable. 5339*3245fa21SMitchell Horne UINT32 OSXSAVE:1; ///< XSAVE and Processor Extended States Enable. 5340*3245fa21SMitchell Horne UINT32 Reserved_4:1; ///< Reserved. 5341*3245fa21SMitchell Horne UINT32 SMEP:1; ///< SMEP Enable. 5342*3245fa21SMitchell Horne UINT32 SMAP:1; ///< SMAP Enable. 5343*3245fa21SMitchell Horne UINT32 PKE:1; ///< Protection-Key Enable. 5344*3245fa21SMitchell Horne UINT32 Reserved_5:9; ///< Reserved. 53450d1ba665SWarner Losh } Bits; 53460d1ba665SWarner Losh UINTN UintN; 53470d1ba665SWarner Losh } IA32_CR4; 53480d1ba665SWarner Losh 53490d1ba665SWarner Losh /// 53500d1ba665SWarner Losh /// Byte packed structure for a segment descriptor in a GDT/LDT. 53510d1ba665SWarner Losh /// 53520d1ba665SWarner Losh typedef union { 53530d1ba665SWarner Losh struct { 53540d1ba665SWarner Losh UINT32 LimitLow:16; 53550d1ba665SWarner Losh UINT32 BaseLow:16; 53560d1ba665SWarner Losh UINT32 BaseMid:8; 53570d1ba665SWarner Losh UINT32 Type:4; 53580d1ba665SWarner Losh UINT32 S:1; 53590d1ba665SWarner Losh UINT32 DPL:2; 53600d1ba665SWarner Losh UINT32 P:1; 53610d1ba665SWarner Losh UINT32 LimitHigh:4; 53620d1ba665SWarner Losh UINT32 AVL:1; 53630d1ba665SWarner Losh UINT32 L:1; 53640d1ba665SWarner Losh UINT32 DB:1; 53650d1ba665SWarner Losh UINT32 G:1; 53660d1ba665SWarner Losh UINT32 BaseHigh:8; 53670d1ba665SWarner Losh } Bits; 53680d1ba665SWarner Losh UINT64 Uint64; 53690d1ba665SWarner Losh } IA32_SEGMENT_DESCRIPTOR; 53700d1ba665SWarner Losh 53710d1ba665SWarner Losh /// 53720d1ba665SWarner Losh /// Byte packed structure for an IDTR, GDTR, LDTR descriptor. 53730d1ba665SWarner Losh /// 53740d1ba665SWarner Losh #pragma pack (1) 53750d1ba665SWarner Losh typedef struct { 53760d1ba665SWarner Losh UINT16 Limit; 53770d1ba665SWarner Losh UINTN Base; 53780d1ba665SWarner Losh } IA32_DESCRIPTOR; 53790d1ba665SWarner Losh #pragma pack () 53800d1ba665SWarner Losh 53810d1ba665SWarner Losh #define IA32_IDT_GATE_TYPE_TASK 0x85 53820d1ba665SWarner Losh #define IA32_IDT_GATE_TYPE_INTERRUPT_16 0x86 53830d1ba665SWarner Losh #define IA32_IDT_GATE_TYPE_TRAP_16 0x87 53840d1ba665SWarner Losh #define IA32_IDT_GATE_TYPE_INTERRUPT_32 0x8E 53850d1ba665SWarner Losh #define IA32_IDT_GATE_TYPE_TRAP_32 0x8F 53860d1ba665SWarner Losh 5387*3245fa21SMitchell Horne #define IA32_GDT_TYPE_TSS 0x9 5388*3245fa21SMitchell Horne #define IA32_GDT_ALIGNMENT 8 53890d1ba665SWarner Losh 53900d1ba665SWarner Losh #if defined (MDE_CPU_IA32) 53910d1ba665SWarner Losh /// 53920d1ba665SWarner Losh /// Byte packed structure for an IA-32 Interrupt Gate Descriptor. 53930d1ba665SWarner Losh /// 53940d1ba665SWarner Losh typedef union { 53950d1ba665SWarner Losh struct { 53960d1ba665SWarner Losh UINT32 OffsetLow:16; ///< Offset bits 15..0. 53970d1ba665SWarner Losh UINT32 Selector:16; ///< Selector. 53980d1ba665SWarner Losh UINT32 Reserved_0:8; ///< Reserved. 53990d1ba665SWarner Losh UINT32 GateType:8; ///< Gate Type. See #defines above. 54000d1ba665SWarner Losh UINT32 OffsetHigh:16; ///< Offset bits 31..16. 54010d1ba665SWarner Losh } Bits; 54020d1ba665SWarner Losh UINT64 Uint64; 54030d1ba665SWarner Losh } IA32_IDT_GATE_DESCRIPTOR; 54040d1ba665SWarner Losh 5405*3245fa21SMitchell Horne #pragma pack (1) 5406*3245fa21SMitchell Horne // 5407*3245fa21SMitchell Horne // IA32 Task-State Segment Definition 5408*3245fa21SMitchell Horne // 5409*3245fa21SMitchell Horne typedef struct { 5410*3245fa21SMitchell Horne UINT16 PreviousTaskLink; 5411*3245fa21SMitchell Horne UINT16 Reserved_2; 5412*3245fa21SMitchell Horne UINT32 ESP0; 5413*3245fa21SMitchell Horne UINT16 SS0; 5414*3245fa21SMitchell Horne UINT16 Reserved_10; 5415*3245fa21SMitchell Horne UINT32 ESP1; 5416*3245fa21SMitchell Horne UINT16 SS1; 5417*3245fa21SMitchell Horne UINT16 Reserved_18; 5418*3245fa21SMitchell Horne UINT32 ESP2; 5419*3245fa21SMitchell Horne UINT16 SS2; 5420*3245fa21SMitchell Horne UINT16 Reserved_26; 5421*3245fa21SMitchell Horne UINT32 CR3; 5422*3245fa21SMitchell Horne UINT32 EIP; 5423*3245fa21SMitchell Horne UINT32 EFLAGS; 5424*3245fa21SMitchell Horne UINT32 EAX; 5425*3245fa21SMitchell Horne UINT32 ECX; 5426*3245fa21SMitchell Horne UINT32 EDX; 5427*3245fa21SMitchell Horne UINT32 EBX; 5428*3245fa21SMitchell Horne UINT32 ESP; 5429*3245fa21SMitchell Horne UINT32 EBP; 5430*3245fa21SMitchell Horne UINT32 ESI; 5431*3245fa21SMitchell Horne UINT32 EDI; 5432*3245fa21SMitchell Horne UINT16 ES; 5433*3245fa21SMitchell Horne UINT16 Reserved_74; 5434*3245fa21SMitchell Horne UINT16 CS; 5435*3245fa21SMitchell Horne UINT16 Reserved_78; 5436*3245fa21SMitchell Horne UINT16 SS; 5437*3245fa21SMitchell Horne UINT16 Reserved_82; 5438*3245fa21SMitchell Horne UINT16 DS; 5439*3245fa21SMitchell Horne UINT16 Reserved_86; 5440*3245fa21SMitchell Horne UINT16 FS; 5441*3245fa21SMitchell Horne UINT16 Reserved_90; 5442*3245fa21SMitchell Horne UINT16 GS; 5443*3245fa21SMitchell Horne UINT16 Reserved_94; 5444*3245fa21SMitchell Horne UINT16 LDTSegmentSelector; 5445*3245fa21SMitchell Horne UINT16 Reserved_98; 5446*3245fa21SMitchell Horne UINT16 T; 5447*3245fa21SMitchell Horne UINT16 IOMapBaseAddress; 5448*3245fa21SMitchell Horne } IA32_TASK_STATE_SEGMENT; 5449*3245fa21SMitchell Horne 5450*3245fa21SMitchell Horne typedef union { 5451*3245fa21SMitchell Horne struct { 5452*3245fa21SMitchell Horne UINT32 LimitLow:16; ///< Segment Limit 15..00 5453*3245fa21SMitchell Horne UINT32 BaseLow:16; ///< Base Address 15..00 5454*3245fa21SMitchell Horne UINT32 BaseMid:8; ///< Base Address 23..16 5455*3245fa21SMitchell Horne UINT32 Type:4; ///< Type (1 0 B 1) 5456*3245fa21SMitchell Horne UINT32 Reserved_43:1; ///< 0 5457*3245fa21SMitchell Horne UINT32 DPL:2; ///< Descriptor Privilege Level 5458*3245fa21SMitchell Horne UINT32 P:1; ///< Segment Present 5459*3245fa21SMitchell Horne UINT32 LimitHigh:4; ///< Segment Limit 19..16 5460*3245fa21SMitchell Horne UINT32 AVL:1; ///< Available for use by system software 5461*3245fa21SMitchell Horne UINT32 Reserved_52:2; ///< 0 0 5462*3245fa21SMitchell Horne UINT32 G:1; ///< Granularity 5463*3245fa21SMitchell Horne UINT32 BaseHigh:8; ///< Base Address 31..24 5464*3245fa21SMitchell Horne } Bits; 5465*3245fa21SMitchell Horne UINT64 Uint64; 5466*3245fa21SMitchell Horne } IA32_TSS_DESCRIPTOR; 5467*3245fa21SMitchell Horne #pragma pack () 5468*3245fa21SMitchell Horne 5469*3245fa21SMitchell Horne #endif // defined (MDE_CPU_IA32) 54700d1ba665SWarner Losh 54710d1ba665SWarner Losh #if defined (MDE_CPU_X64) 54720d1ba665SWarner Losh /// 54730d1ba665SWarner Losh /// Byte packed structure for an x64 Interrupt Gate Descriptor. 54740d1ba665SWarner Losh /// 54750d1ba665SWarner Losh typedef union { 54760d1ba665SWarner Losh struct { 54770d1ba665SWarner Losh UINT32 OffsetLow:16; ///< Offset bits 15..0. 54780d1ba665SWarner Losh UINT32 Selector:16; ///< Selector. 54790d1ba665SWarner Losh UINT32 Reserved_0:8; ///< Reserved. 54800d1ba665SWarner Losh UINT32 GateType:8; ///< Gate Type. See #defines above. 54810d1ba665SWarner Losh UINT32 OffsetHigh:16; ///< Offset bits 31..16. 54820d1ba665SWarner Losh UINT32 OffsetUpper:32; ///< Offset bits 63..32. 54830d1ba665SWarner Losh UINT32 Reserved_1:32; ///< Reserved. 54840d1ba665SWarner Losh } Bits; 54850d1ba665SWarner Losh struct { 54860d1ba665SWarner Losh UINT64 Uint64; 54870d1ba665SWarner Losh UINT64 Uint64_1; 54880d1ba665SWarner Losh } Uint128; 54890d1ba665SWarner Losh } IA32_IDT_GATE_DESCRIPTOR; 54900d1ba665SWarner Losh 5491*3245fa21SMitchell Horne #pragma pack (1) 5492*3245fa21SMitchell Horne // 5493*3245fa21SMitchell Horne // IA32 Task-State Segment Definition 5494*3245fa21SMitchell Horne // 5495*3245fa21SMitchell Horne typedef struct { 5496*3245fa21SMitchell Horne UINT32 Reserved_0; 5497*3245fa21SMitchell Horne UINT64 RSP0; 5498*3245fa21SMitchell Horne UINT64 RSP1; 5499*3245fa21SMitchell Horne UINT64 RSP2; 5500*3245fa21SMitchell Horne UINT64 Reserved_28; 5501*3245fa21SMitchell Horne UINT64 IST[7]; 5502*3245fa21SMitchell Horne UINT64 Reserved_92; 5503*3245fa21SMitchell Horne UINT16 Reserved_100; 5504*3245fa21SMitchell Horne UINT16 IOMapBaseAddress; 5505*3245fa21SMitchell Horne } IA32_TASK_STATE_SEGMENT; 5506*3245fa21SMitchell Horne 5507*3245fa21SMitchell Horne typedef union { 5508*3245fa21SMitchell Horne struct { 5509*3245fa21SMitchell Horne UINT32 LimitLow:16; ///< Segment Limit 15..00 5510*3245fa21SMitchell Horne UINT32 BaseLow:16; ///< Base Address 15..00 5511*3245fa21SMitchell Horne UINT32 BaseMidl:8; ///< Base Address 23..16 5512*3245fa21SMitchell Horne UINT32 Type:4; ///< Type (1 0 B 1) 5513*3245fa21SMitchell Horne UINT32 Reserved_43:1; ///< 0 5514*3245fa21SMitchell Horne UINT32 DPL:2; ///< Descriptor Privilege Level 5515*3245fa21SMitchell Horne UINT32 P:1; ///< Segment Present 5516*3245fa21SMitchell Horne UINT32 LimitHigh:4; ///< Segment Limit 19..16 5517*3245fa21SMitchell Horne UINT32 AVL:1; ///< Available for use by system software 5518*3245fa21SMitchell Horne UINT32 Reserved_52:2; ///< 0 0 5519*3245fa21SMitchell Horne UINT32 G:1; ///< Granularity 5520*3245fa21SMitchell Horne UINT32 BaseMidh:8; ///< Base Address 31..24 5521*3245fa21SMitchell Horne UINT32 BaseHigh:32; ///< Base Address 63..32 5522*3245fa21SMitchell Horne UINT32 Reserved_96:32; ///< Reserved 5523*3245fa21SMitchell Horne } Bits; 5524*3245fa21SMitchell Horne struct { 5525*3245fa21SMitchell Horne UINT64 Uint64; 5526*3245fa21SMitchell Horne UINT64 Uint64_1; 5527*3245fa21SMitchell Horne } Uint128; 5528*3245fa21SMitchell Horne } IA32_TSS_DESCRIPTOR; 5529*3245fa21SMitchell Horne #pragma pack () 5530*3245fa21SMitchell Horne 5531*3245fa21SMitchell Horne #endif // defined (MDE_CPU_X64) 55320d1ba665SWarner Losh 55330d1ba665SWarner Losh /// 55340d1ba665SWarner Losh /// Byte packed structure for an FP/SSE/SSE2 context. 55350d1ba665SWarner Losh /// 55360d1ba665SWarner Losh typedef struct { 55370d1ba665SWarner Losh UINT8 Buffer[512]; 55380d1ba665SWarner Losh } IA32_FX_BUFFER; 55390d1ba665SWarner Losh 55400d1ba665SWarner Losh /// 55410d1ba665SWarner Losh /// Structures for the 16-bit real mode thunks. 55420d1ba665SWarner Losh /// 55430d1ba665SWarner Losh typedef struct { 55440d1ba665SWarner Losh UINT32 Reserved1; 55450d1ba665SWarner Losh UINT32 Reserved2; 55460d1ba665SWarner Losh UINT32 Reserved3; 55470d1ba665SWarner Losh UINT32 Reserved4; 55480d1ba665SWarner Losh UINT8 BL; 55490d1ba665SWarner Losh UINT8 BH; 55500d1ba665SWarner Losh UINT16 Reserved5; 55510d1ba665SWarner Losh UINT8 DL; 55520d1ba665SWarner Losh UINT8 DH; 55530d1ba665SWarner Losh UINT16 Reserved6; 55540d1ba665SWarner Losh UINT8 CL; 55550d1ba665SWarner Losh UINT8 CH; 55560d1ba665SWarner Losh UINT16 Reserved7; 55570d1ba665SWarner Losh UINT8 AL; 55580d1ba665SWarner Losh UINT8 AH; 55590d1ba665SWarner Losh UINT16 Reserved8; 55600d1ba665SWarner Losh } IA32_BYTE_REGS; 55610d1ba665SWarner Losh 55620d1ba665SWarner Losh typedef struct { 55630d1ba665SWarner Losh UINT16 DI; 55640d1ba665SWarner Losh UINT16 Reserved1; 55650d1ba665SWarner Losh UINT16 SI; 55660d1ba665SWarner Losh UINT16 Reserved2; 55670d1ba665SWarner Losh UINT16 BP; 55680d1ba665SWarner Losh UINT16 Reserved3; 55690d1ba665SWarner Losh UINT16 SP; 55700d1ba665SWarner Losh UINT16 Reserved4; 55710d1ba665SWarner Losh UINT16 BX; 55720d1ba665SWarner Losh UINT16 Reserved5; 55730d1ba665SWarner Losh UINT16 DX; 55740d1ba665SWarner Losh UINT16 Reserved6; 55750d1ba665SWarner Losh UINT16 CX; 55760d1ba665SWarner Losh UINT16 Reserved7; 55770d1ba665SWarner Losh UINT16 AX; 55780d1ba665SWarner Losh UINT16 Reserved8; 55790d1ba665SWarner Losh } IA32_WORD_REGS; 55800d1ba665SWarner Losh 55810d1ba665SWarner Losh typedef struct { 55820d1ba665SWarner Losh UINT32 EDI; 55830d1ba665SWarner Losh UINT32 ESI; 55840d1ba665SWarner Losh UINT32 EBP; 55850d1ba665SWarner Losh UINT32 ESP; 55860d1ba665SWarner Losh UINT32 EBX; 55870d1ba665SWarner Losh UINT32 EDX; 55880d1ba665SWarner Losh UINT32 ECX; 55890d1ba665SWarner Losh UINT32 EAX; 55900d1ba665SWarner Losh UINT16 DS; 55910d1ba665SWarner Losh UINT16 ES; 55920d1ba665SWarner Losh UINT16 FS; 55930d1ba665SWarner Losh UINT16 GS; 55940d1ba665SWarner Losh IA32_EFLAGS32 EFLAGS; 55950d1ba665SWarner Losh UINT32 Eip; 55960d1ba665SWarner Losh UINT16 CS; 55970d1ba665SWarner Losh UINT16 SS; 55980d1ba665SWarner Losh } IA32_DWORD_REGS; 55990d1ba665SWarner Losh 56000d1ba665SWarner Losh typedef union { 56010d1ba665SWarner Losh IA32_DWORD_REGS E; 56020d1ba665SWarner Losh IA32_WORD_REGS X; 56030d1ba665SWarner Losh IA32_BYTE_REGS H; 56040d1ba665SWarner Losh } IA32_REGISTER_SET; 56050d1ba665SWarner Losh 56060d1ba665SWarner Losh /// 56070d1ba665SWarner Losh /// Byte packed structure for an 16-bit real mode thunks. 56080d1ba665SWarner Losh /// 56090d1ba665SWarner Losh typedef struct { 56100d1ba665SWarner Losh IA32_REGISTER_SET *RealModeState; 56110d1ba665SWarner Losh VOID *RealModeBuffer; 56120d1ba665SWarner Losh UINT32 RealModeBufferSize; 56130d1ba665SWarner Losh UINT32 ThunkAttributes; 56140d1ba665SWarner Losh } THUNK_CONTEXT; 56150d1ba665SWarner Losh 56160d1ba665SWarner Losh #define THUNK_ATTRIBUTE_BIG_REAL_MODE 0x00000001 56170d1ba665SWarner Losh #define THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 0x00000002 56180d1ba665SWarner Losh #define THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL 0x00000004 56190d1ba665SWarner Losh 5620*3245fa21SMitchell Horne /// 5621*3245fa21SMitchell Horne /// Type definition for representing labels in NASM source code that allow for 5622*3245fa21SMitchell Horne /// the patching of immediate operands of IA32 and X64 instructions. 5623*3245fa21SMitchell Horne /// 5624*3245fa21SMitchell Horne /// While the type is technically defined as a function type (note: not a 5625*3245fa21SMitchell Horne /// pointer-to-function type), such labels in NASM source code never stand for 5626*3245fa21SMitchell Horne /// actual functions, and identifiers declared with this function type should 5627*3245fa21SMitchell Horne /// never be called. This is also why the EFIAPI calling convention specifier 5628*3245fa21SMitchell Horne /// is missing from the typedef, and why the typedef does not follow the usual 5629*3245fa21SMitchell Horne /// edk2 coding style for function (or pointer-to-function) typedefs. The VOID 5630*3245fa21SMitchell Horne /// return type and the VOID argument list are merely artifacts. 5631*3245fa21SMitchell Horne /// 5632*3245fa21SMitchell Horne typedef VOID (X86_ASSEMBLY_PATCH_LABEL) (VOID); 5633*3245fa21SMitchell Horne 56340d1ba665SWarner Losh /** 56350d1ba665SWarner Losh Retrieves CPUID information. 56360d1ba665SWarner Losh 56370d1ba665SWarner Losh Executes the CPUID instruction with EAX set to the value specified by Index. 56380d1ba665SWarner Losh This function always returns Index. 56390d1ba665SWarner Losh If Eax is not NULL, then the value of EAX after CPUID is returned in Eax. 56400d1ba665SWarner Losh If Ebx is not NULL, then the value of EBX after CPUID is returned in Ebx. 56410d1ba665SWarner Losh If Ecx is not NULL, then the value of ECX after CPUID is returned in Ecx. 56420d1ba665SWarner Losh If Edx is not NULL, then the value of EDX after CPUID is returned in Edx. 56430d1ba665SWarner Losh This function is only available on IA-32 and x64. 56440d1ba665SWarner Losh 56450d1ba665SWarner Losh @param Index The 32-bit value to load into EAX prior to invoking the CPUID 56460d1ba665SWarner Losh instruction. 56470d1ba665SWarner Losh @param Eax The pointer to the 32-bit EAX value returned by the CPUID 56480d1ba665SWarner Losh instruction. This is an optional parameter that may be NULL. 56490d1ba665SWarner Losh @param Ebx The pointer to the 32-bit EBX value returned by the CPUID 56500d1ba665SWarner Losh instruction. This is an optional parameter that may be NULL. 56510d1ba665SWarner Losh @param Ecx The pointer to the 32-bit ECX value returned by the CPUID 56520d1ba665SWarner Losh instruction. This is an optional parameter that may be NULL. 56530d1ba665SWarner Losh @param Edx The pointer to the 32-bit EDX value returned by the CPUID 56540d1ba665SWarner Losh instruction. This is an optional parameter that may be NULL. 56550d1ba665SWarner Losh 56560d1ba665SWarner Losh @return Index. 56570d1ba665SWarner Losh 56580d1ba665SWarner Losh **/ 56590d1ba665SWarner Losh UINT32 56600d1ba665SWarner Losh EFIAPI 56610d1ba665SWarner Losh AsmCpuid ( 56620d1ba665SWarner Losh IN UINT32 Index, 56630d1ba665SWarner Losh OUT UINT32 *Eax, OPTIONAL 56640d1ba665SWarner Losh OUT UINT32 *Ebx, OPTIONAL 56650d1ba665SWarner Losh OUT UINT32 *Ecx, OPTIONAL 56660d1ba665SWarner Losh OUT UINT32 *Edx OPTIONAL 56670d1ba665SWarner Losh ); 56680d1ba665SWarner Losh 56690d1ba665SWarner Losh 56700d1ba665SWarner Losh /** 56710d1ba665SWarner Losh Retrieves CPUID information using an extended leaf identifier. 56720d1ba665SWarner Losh 56730d1ba665SWarner Losh Executes the CPUID instruction with EAX set to the value specified by Index 56740d1ba665SWarner Losh and ECX set to the value specified by SubIndex. This function always returns 56750d1ba665SWarner Losh Index. This function is only available on IA-32 and x64. 56760d1ba665SWarner Losh 56770d1ba665SWarner Losh If Eax is not NULL, then the value of EAX after CPUID is returned in Eax. 56780d1ba665SWarner Losh If Ebx is not NULL, then the value of EBX after CPUID is returned in Ebx. 56790d1ba665SWarner Losh If Ecx is not NULL, then the value of ECX after CPUID is returned in Ecx. 56800d1ba665SWarner Losh If Edx is not NULL, then the value of EDX after CPUID is returned in Edx. 56810d1ba665SWarner Losh 56820d1ba665SWarner Losh @param Index The 32-bit value to load into EAX prior to invoking the 56830d1ba665SWarner Losh CPUID instruction. 56840d1ba665SWarner Losh @param SubIndex The 32-bit value to load into ECX prior to invoking the 56850d1ba665SWarner Losh CPUID instruction. 56860d1ba665SWarner Losh @param Eax The pointer to the 32-bit EAX value returned by the CPUID 56870d1ba665SWarner Losh instruction. This is an optional parameter that may be 56880d1ba665SWarner Losh NULL. 56890d1ba665SWarner Losh @param Ebx The pointer to the 32-bit EBX value returned by the CPUID 56900d1ba665SWarner Losh instruction. This is an optional parameter that may be 56910d1ba665SWarner Losh NULL. 56920d1ba665SWarner Losh @param Ecx The pointer to the 32-bit ECX value returned by the CPUID 56930d1ba665SWarner Losh instruction. This is an optional parameter that may be 56940d1ba665SWarner Losh NULL. 56950d1ba665SWarner Losh @param Edx The pointer to the 32-bit EDX value returned by the CPUID 56960d1ba665SWarner Losh instruction. This is an optional parameter that may be 56970d1ba665SWarner Losh NULL. 56980d1ba665SWarner Losh 56990d1ba665SWarner Losh @return Index. 57000d1ba665SWarner Losh 57010d1ba665SWarner Losh **/ 57020d1ba665SWarner Losh UINT32 57030d1ba665SWarner Losh EFIAPI 57040d1ba665SWarner Losh AsmCpuidEx ( 57050d1ba665SWarner Losh IN UINT32 Index, 57060d1ba665SWarner Losh IN UINT32 SubIndex, 57070d1ba665SWarner Losh OUT UINT32 *Eax, OPTIONAL 57080d1ba665SWarner Losh OUT UINT32 *Ebx, OPTIONAL 57090d1ba665SWarner Losh OUT UINT32 *Ecx, OPTIONAL 57100d1ba665SWarner Losh OUT UINT32 *Edx OPTIONAL 57110d1ba665SWarner Losh ); 57120d1ba665SWarner Losh 57130d1ba665SWarner Losh 57140d1ba665SWarner Losh /** 57150d1ba665SWarner Losh Set CD bit and clear NW bit of CR0 followed by a WBINVD. 57160d1ba665SWarner Losh 57170d1ba665SWarner Losh Disables the caches by setting the CD bit of CR0 to 1, clearing the NW bit of CR0 to 0, 57180d1ba665SWarner Losh and executing a WBINVD instruction. This function is only available on IA-32 and x64. 57190d1ba665SWarner Losh 57200d1ba665SWarner Losh **/ 57210d1ba665SWarner Losh VOID 57220d1ba665SWarner Losh EFIAPI 57230d1ba665SWarner Losh AsmDisableCache ( 57240d1ba665SWarner Losh VOID 57250d1ba665SWarner Losh ); 57260d1ba665SWarner Losh 57270d1ba665SWarner Losh 57280d1ba665SWarner Losh /** 57290d1ba665SWarner Losh Perform a WBINVD and clear both the CD and NW bits of CR0. 57300d1ba665SWarner Losh 57310d1ba665SWarner Losh Enables the caches by executing a WBINVD instruction and then clear both the CD and NW 57320d1ba665SWarner Losh bits of CR0 to 0. This function is only available on IA-32 and x64. 57330d1ba665SWarner Losh 57340d1ba665SWarner Losh **/ 57350d1ba665SWarner Losh VOID 57360d1ba665SWarner Losh EFIAPI 57370d1ba665SWarner Losh AsmEnableCache ( 57380d1ba665SWarner Losh VOID 57390d1ba665SWarner Losh ); 57400d1ba665SWarner Losh 57410d1ba665SWarner Losh 57420d1ba665SWarner Losh /** 57430d1ba665SWarner Losh Returns the lower 32-bits of a Machine Specific Register(MSR). 57440d1ba665SWarner Losh 57450d1ba665SWarner Losh Reads and returns the lower 32-bits of the MSR specified by Index. 57460d1ba665SWarner Losh No parameter checking is performed on Index, and some Index values may cause 57470d1ba665SWarner Losh CPU exceptions. The caller must either guarantee that Index is valid, or the 57480d1ba665SWarner Losh caller must set up exception handlers to catch the exceptions. This function 57490d1ba665SWarner Losh is only available on IA-32 and x64. 57500d1ba665SWarner Losh 57510d1ba665SWarner Losh @param Index The 32-bit MSR index to read. 57520d1ba665SWarner Losh 57530d1ba665SWarner Losh @return The lower 32 bits of the MSR identified by Index. 57540d1ba665SWarner Losh 57550d1ba665SWarner Losh **/ 57560d1ba665SWarner Losh UINT32 57570d1ba665SWarner Losh EFIAPI 57580d1ba665SWarner Losh AsmReadMsr32 ( 57590d1ba665SWarner Losh IN UINT32 Index 57600d1ba665SWarner Losh ); 57610d1ba665SWarner Losh 57620d1ba665SWarner Losh 57630d1ba665SWarner Losh /** 57640d1ba665SWarner Losh Writes a 32-bit value to a Machine Specific Register(MSR), and returns the value. 57650d1ba665SWarner Losh The upper 32-bits of the MSR are set to zero. 57660d1ba665SWarner Losh 57670d1ba665SWarner Losh Writes the 32-bit value specified by Value to the MSR specified by Index. The 57680d1ba665SWarner Losh upper 32-bits of the MSR write are set to zero. The 32-bit value written to 57690d1ba665SWarner Losh the MSR is returned. No parameter checking is performed on Index or Value, 57700d1ba665SWarner Losh and some of these may cause CPU exceptions. The caller must either guarantee 57710d1ba665SWarner Losh that Index and Value are valid, or the caller must establish proper exception 57720d1ba665SWarner Losh handlers. This function is only available on IA-32 and x64. 57730d1ba665SWarner Losh 57740d1ba665SWarner Losh @param Index The 32-bit MSR index to write. 57750d1ba665SWarner Losh @param Value The 32-bit value to write to the MSR. 57760d1ba665SWarner Losh 57770d1ba665SWarner Losh @return Value 57780d1ba665SWarner Losh 57790d1ba665SWarner Losh **/ 57800d1ba665SWarner Losh UINT32 57810d1ba665SWarner Losh EFIAPI 57820d1ba665SWarner Losh AsmWriteMsr32 ( 57830d1ba665SWarner Losh IN UINT32 Index, 57840d1ba665SWarner Losh IN UINT32 Value 57850d1ba665SWarner Losh ); 57860d1ba665SWarner Losh 57870d1ba665SWarner Losh 57880d1ba665SWarner Losh /** 57890d1ba665SWarner Losh Reads a 64-bit MSR, performs a bitwise OR on the lower 32-bits, and 57900d1ba665SWarner Losh writes the result back to the 64-bit MSR. 57910d1ba665SWarner Losh 57920d1ba665SWarner Losh Reads the 64-bit MSR specified by Index, performs a bitwise OR 57930d1ba665SWarner Losh between the lower 32-bits of the read result and the value specified by 57940d1ba665SWarner Losh OrData, and writes the result to the 64-bit MSR specified by Index. The lower 57950d1ba665SWarner Losh 32-bits of the value written to the MSR is returned. No parameter checking is 57960d1ba665SWarner Losh performed on Index or OrData, and some of these may cause CPU exceptions. The 57970d1ba665SWarner Losh caller must either guarantee that Index and OrData are valid, or the caller 57980d1ba665SWarner Losh must establish proper exception handlers. This function is only available on 57990d1ba665SWarner Losh IA-32 and x64. 58000d1ba665SWarner Losh 58010d1ba665SWarner Losh @param Index The 32-bit MSR index to write. 58020d1ba665SWarner Losh @param OrData The value to OR with the read value from the MSR. 58030d1ba665SWarner Losh 58040d1ba665SWarner Losh @return The lower 32-bit value written to the MSR. 58050d1ba665SWarner Losh 58060d1ba665SWarner Losh **/ 58070d1ba665SWarner Losh UINT32 58080d1ba665SWarner Losh EFIAPI 58090d1ba665SWarner Losh AsmMsrOr32 ( 58100d1ba665SWarner Losh IN UINT32 Index, 58110d1ba665SWarner Losh IN UINT32 OrData 58120d1ba665SWarner Losh ); 58130d1ba665SWarner Losh 58140d1ba665SWarner Losh 58150d1ba665SWarner Losh /** 58160d1ba665SWarner Losh Reads a 64-bit MSR, performs a bitwise AND on the lower 32-bits, and writes 58170d1ba665SWarner Losh the result back to the 64-bit MSR. 58180d1ba665SWarner Losh 58190d1ba665SWarner Losh Reads the 64-bit MSR specified by Index, performs a bitwise AND between the 58200d1ba665SWarner Losh lower 32-bits of the read result and the value specified by AndData, and 58210d1ba665SWarner Losh writes the result to the 64-bit MSR specified by Index. The lower 32-bits of 58220d1ba665SWarner Losh the value written to the MSR is returned. No parameter checking is performed 58230d1ba665SWarner Losh on Index or AndData, and some of these may cause CPU exceptions. The caller 58240d1ba665SWarner Losh must either guarantee that Index and AndData are valid, or the caller must 58250d1ba665SWarner Losh establish proper exception handlers. This function is only available on IA-32 58260d1ba665SWarner Losh and x64. 58270d1ba665SWarner Losh 58280d1ba665SWarner Losh @param Index The 32-bit MSR index to write. 58290d1ba665SWarner Losh @param AndData The value to AND with the read value from the MSR. 58300d1ba665SWarner Losh 58310d1ba665SWarner Losh @return The lower 32-bit value written to the MSR. 58320d1ba665SWarner Losh 58330d1ba665SWarner Losh **/ 58340d1ba665SWarner Losh UINT32 58350d1ba665SWarner Losh EFIAPI 58360d1ba665SWarner Losh AsmMsrAnd32 ( 58370d1ba665SWarner Losh IN UINT32 Index, 58380d1ba665SWarner Losh IN UINT32 AndData 58390d1ba665SWarner Losh ); 58400d1ba665SWarner Losh 58410d1ba665SWarner Losh 58420d1ba665SWarner Losh /** 58430d1ba665SWarner Losh Reads a 64-bit MSR, performs a bitwise AND followed by a bitwise OR 58440d1ba665SWarner Losh on the lower 32-bits, and writes the result back to the 64-bit MSR. 58450d1ba665SWarner Losh 58460d1ba665SWarner Losh Reads the 64-bit MSR specified by Index, performs a bitwise AND between the 58470d1ba665SWarner Losh lower 32-bits of the read result and the value specified by AndData 58480d1ba665SWarner Losh preserving the upper 32-bits, performs a bitwise OR between the 58490d1ba665SWarner Losh result of the AND operation and the value specified by OrData, and writes the 58500d1ba665SWarner Losh result to the 64-bit MSR specified by Address. The lower 32-bits of the value 58510d1ba665SWarner Losh written to the MSR is returned. No parameter checking is performed on Index, 58520d1ba665SWarner Losh AndData, or OrData, and some of these may cause CPU exceptions. The caller 58530d1ba665SWarner Losh must either guarantee that Index, AndData, and OrData are valid, or the 58540d1ba665SWarner Losh caller must establish proper exception handlers. This function is only 58550d1ba665SWarner Losh available on IA-32 and x64. 58560d1ba665SWarner Losh 58570d1ba665SWarner Losh @param Index The 32-bit MSR index to write. 58580d1ba665SWarner Losh @param AndData The value to AND with the read value from the MSR. 58590d1ba665SWarner Losh @param OrData The value to OR with the result of the AND operation. 58600d1ba665SWarner Losh 58610d1ba665SWarner Losh @return The lower 32-bit value written to the MSR. 58620d1ba665SWarner Losh 58630d1ba665SWarner Losh **/ 58640d1ba665SWarner Losh UINT32 58650d1ba665SWarner Losh EFIAPI 58660d1ba665SWarner Losh AsmMsrAndThenOr32 ( 58670d1ba665SWarner Losh IN UINT32 Index, 58680d1ba665SWarner Losh IN UINT32 AndData, 58690d1ba665SWarner Losh IN UINT32 OrData 58700d1ba665SWarner Losh ); 58710d1ba665SWarner Losh 58720d1ba665SWarner Losh 58730d1ba665SWarner Losh /** 58740d1ba665SWarner Losh Reads a bit field of an MSR. 58750d1ba665SWarner Losh 58760d1ba665SWarner Losh Reads the bit field in the lower 32-bits of a 64-bit MSR. The bit field is 58770d1ba665SWarner Losh specified by the StartBit and the EndBit. The value of the bit field is 58780d1ba665SWarner Losh returned. The caller must either guarantee that Index is valid, or the caller 58790d1ba665SWarner Losh must set up exception handlers to catch the exceptions. This function is only 58800d1ba665SWarner Losh available on IA-32 and x64. 58810d1ba665SWarner Losh 58820d1ba665SWarner Losh If StartBit is greater than 31, then ASSERT(). 58830d1ba665SWarner Losh If EndBit is greater than 31, then ASSERT(). 58840d1ba665SWarner Losh If EndBit is less than StartBit, then ASSERT(). 58850d1ba665SWarner Losh 58860d1ba665SWarner Losh @param Index The 32-bit MSR index to read. 58870d1ba665SWarner Losh @param StartBit The ordinal of the least significant bit in the bit field. 58880d1ba665SWarner Losh Range 0..31. 58890d1ba665SWarner Losh @param EndBit The ordinal of the most significant bit in the bit field. 58900d1ba665SWarner Losh Range 0..31. 58910d1ba665SWarner Losh 58920d1ba665SWarner Losh @return The bit field read from the MSR. 58930d1ba665SWarner Losh 58940d1ba665SWarner Losh **/ 58950d1ba665SWarner Losh UINT32 58960d1ba665SWarner Losh EFIAPI 58970d1ba665SWarner Losh AsmMsrBitFieldRead32 ( 58980d1ba665SWarner Losh IN UINT32 Index, 58990d1ba665SWarner Losh IN UINTN StartBit, 59000d1ba665SWarner Losh IN UINTN EndBit 59010d1ba665SWarner Losh ); 59020d1ba665SWarner Losh 59030d1ba665SWarner Losh 59040d1ba665SWarner Losh /** 59050d1ba665SWarner Losh Writes a bit field to an MSR. 59060d1ba665SWarner Losh 59070d1ba665SWarner Losh Writes Value to a bit field in the lower 32-bits of a 64-bit MSR. The bit 59080d1ba665SWarner Losh field is specified by the StartBit and the EndBit. All other bits in the 59090d1ba665SWarner Losh destination MSR are preserved. The lower 32-bits of the MSR written is 59100d1ba665SWarner Losh returned. The caller must either guarantee that Index and the data written 59110d1ba665SWarner Losh is valid, or the caller must set up exception handlers to catch the exceptions. 59120d1ba665SWarner Losh This function is only available on IA-32 and x64. 59130d1ba665SWarner Losh 59140d1ba665SWarner Losh If StartBit is greater than 31, then ASSERT(). 59150d1ba665SWarner Losh If EndBit is greater than 31, then ASSERT(). 59160d1ba665SWarner Losh If EndBit is less than StartBit, then ASSERT(). 59170d1ba665SWarner Losh If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT(). 59180d1ba665SWarner Losh 59190d1ba665SWarner Losh @param Index The 32-bit MSR index to write. 59200d1ba665SWarner Losh @param StartBit The ordinal of the least significant bit in the bit field. 59210d1ba665SWarner Losh Range 0..31. 59220d1ba665SWarner Losh @param EndBit The ordinal of the most significant bit in the bit field. 59230d1ba665SWarner Losh Range 0..31. 59240d1ba665SWarner Losh @param Value New value of the bit field. 59250d1ba665SWarner Losh 59260d1ba665SWarner Losh @return The lower 32-bit of the value written to the MSR. 59270d1ba665SWarner Losh 59280d1ba665SWarner Losh **/ 59290d1ba665SWarner Losh UINT32 59300d1ba665SWarner Losh EFIAPI 59310d1ba665SWarner Losh AsmMsrBitFieldWrite32 ( 59320d1ba665SWarner Losh IN UINT32 Index, 59330d1ba665SWarner Losh IN UINTN StartBit, 59340d1ba665SWarner Losh IN UINTN EndBit, 59350d1ba665SWarner Losh IN UINT32 Value 59360d1ba665SWarner Losh ); 59370d1ba665SWarner Losh 59380d1ba665SWarner Losh 59390d1ba665SWarner Losh /** 59400d1ba665SWarner Losh Reads a bit field in a 64-bit MSR, performs a bitwise OR, and writes the 59410d1ba665SWarner Losh result back to the bit field in the 64-bit MSR. 59420d1ba665SWarner Losh 59430d1ba665SWarner Losh Reads the 64-bit MSR specified by Index, performs a bitwise OR 59440d1ba665SWarner Losh between the read result and the value specified by OrData, and writes the 59450d1ba665SWarner Losh result to the 64-bit MSR specified by Index. The lower 32-bits of the value 59460d1ba665SWarner Losh written to the MSR are returned. Extra left bits in OrData are stripped. The 59470d1ba665SWarner Losh caller must either guarantee that Index and the data written is valid, or 59480d1ba665SWarner Losh the caller must set up exception handlers to catch the exceptions. This 59490d1ba665SWarner Losh function is only available on IA-32 and x64. 59500d1ba665SWarner Losh 59510d1ba665SWarner Losh If StartBit is greater than 31, then ASSERT(). 59520d1ba665SWarner Losh If EndBit is greater than 31, then ASSERT(). 59530d1ba665SWarner Losh If EndBit is less than StartBit, then ASSERT(). 59540d1ba665SWarner Losh If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT(). 59550d1ba665SWarner Losh 59560d1ba665SWarner Losh @param Index The 32-bit MSR index to write. 59570d1ba665SWarner Losh @param StartBit The ordinal of the least significant bit in the bit field. 59580d1ba665SWarner Losh Range 0..31. 59590d1ba665SWarner Losh @param EndBit The ordinal of the most significant bit in the bit field. 59600d1ba665SWarner Losh Range 0..31. 59610d1ba665SWarner Losh @param OrData The value to OR with the read value from the MSR. 59620d1ba665SWarner Losh 59630d1ba665SWarner Losh @return The lower 32-bit of the value written to the MSR. 59640d1ba665SWarner Losh 59650d1ba665SWarner Losh **/ 59660d1ba665SWarner Losh UINT32 59670d1ba665SWarner Losh EFIAPI 59680d1ba665SWarner Losh AsmMsrBitFieldOr32 ( 59690d1ba665SWarner Losh IN UINT32 Index, 59700d1ba665SWarner Losh IN UINTN StartBit, 59710d1ba665SWarner Losh IN UINTN EndBit, 59720d1ba665SWarner Losh IN UINT32 OrData 59730d1ba665SWarner Losh ); 59740d1ba665SWarner Losh 59750d1ba665SWarner Losh 59760d1ba665SWarner Losh /** 59770d1ba665SWarner Losh Reads a bit field in a 64-bit MSR, performs a bitwise AND, and writes the 59780d1ba665SWarner Losh result back to the bit field in the 64-bit MSR. 59790d1ba665SWarner Losh 59800d1ba665SWarner Losh Reads the 64-bit MSR specified by Index, performs a bitwise AND between the 59810d1ba665SWarner Losh read result and the value specified by AndData, and writes the result to the 59820d1ba665SWarner Losh 64-bit MSR specified by Index. The lower 32-bits of the value written to the 59830d1ba665SWarner Losh MSR are returned. Extra left bits in AndData are stripped. The caller must 59840d1ba665SWarner Losh either guarantee that Index and the data written is valid, or the caller must 59850d1ba665SWarner Losh set up exception handlers to catch the exceptions. This function is only 59860d1ba665SWarner Losh available on IA-32 and x64. 59870d1ba665SWarner Losh 59880d1ba665SWarner Losh If StartBit is greater than 31, then ASSERT(). 59890d1ba665SWarner Losh If EndBit is greater than 31, then ASSERT(). 59900d1ba665SWarner Losh If EndBit is less than StartBit, then ASSERT(). 59910d1ba665SWarner Losh If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT(). 59920d1ba665SWarner Losh 59930d1ba665SWarner Losh @param Index The 32-bit MSR index to write. 59940d1ba665SWarner Losh @param StartBit The ordinal of the least significant bit in the bit field. 59950d1ba665SWarner Losh Range 0..31. 59960d1ba665SWarner Losh @param EndBit The ordinal of the most significant bit in the bit field. 59970d1ba665SWarner Losh Range 0..31. 59980d1ba665SWarner Losh @param AndData The value to AND with the read value from the MSR. 59990d1ba665SWarner Losh 60000d1ba665SWarner Losh @return The lower 32-bit of the value written to the MSR. 60010d1ba665SWarner Losh 60020d1ba665SWarner Losh **/ 60030d1ba665SWarner Losh UINT32 60040d1ba665SWarner Losh EFIAPI 60050d1ba665SWarner Losh AsmMsrBitFieldAnd32 ( 60060d1ba665SWarner Losh IN UINT32 Index, 60070d1ba665SWarner Losh IN UINTN StartBit, 60080d1ba665SWarner Losh IN UINTN EndBit, 60090d1ba665SWarner Losh IN UINT32 AndData 60100d1ba665SWarner Losh ); 60110d1ba665SWarner Losh 60120d1ba665SWarner Losh 60130d1ba665SWarner Losh /** 60140d1ba665SWarner Losh Reads a bit field in a 64-bit MSR, performs a bitwise AND followed by a 60150d1ba665SWarner Losh bitwise OR, and writes the result back to the bit field in the 60160d1ba665SWarner Losh 64-bit MSR. 60170d1ba665SWarner Losh 60180d1ba665SWarner Losh Reads the 64-bit MSR specified by Index, performs a bitwise AND followed by a 60190d1ba665SWarner Losh bitwise OR between the read result and the value specified by 60200d1ba665SWarner Losh AndData, and writes the result to the 64-bit MSR specified by Index. The 60210d1ba665SWarner Losh lower 32-bits of the value written to the MSR are returned. Extra left bits 60220d1ba665SWarner Losh in both AndData and OrData are stripped. The caller must either guarantee 60230d1ba665SWarner Losh that Index and the data written is valid, or the caller must set up exception 60240d1ba665SWarner Losh handlers to catch the exceptions. This function is only available on IA-32 60250d1ba665SWarner Losh and x64. 60260d1ba665SWarner Losh 60270d1ba665SWarner Losh If StartBit is greater than 31, then ASSERT(). 60280d1ba665SWarner Losh If EndBit is greater than 31, then ASSERT(). 60290d1ba665SWarner Losh If EndBit is less than StartBit, then ASSERT(). 60300d1ba665SWarner Losh If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT(). 60310d1ba665SWarner Losh If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT(). 60320d1ba665SWarner Losh 60330d1ba665SWarner Losh @param Index The 32-bit MSR index to write. 60340d1ba665SWarner Losh @param StartBit The ordinal of the least significant bit in the bit field. 60350d1ba665SWarner Losh Range 0..31. 60360d1ba665SWarner Losh @param EndBit The ordinal of the most significant bit in the bit field. 60370d1ba665SWarner Losh Range 0..31. 60380d1ba665SWarner Losh @param AndData The value to AND with the read value from the MSR. 60390d1ba665SWarner Losh @param OrData The value to OR with the result of the AND operation. 60400d1ba665SWarner Losh 60410d1ba665SWarner Losh @return The lower 32-bit of the value written to the MSR. 60420d1ba665SWarner Losh 60430d1ba665SWarner Losh **/ 60440d1ba665SWarner Losh UINT32 60450d1ba665SWarner Losh EFIAPI 60460d1ba665SWarner Losh AsmMsrBitFieldAndThenOr32 ( 60470d1ba665SWarner Losh IN UINT32 Index, 60480d1ba665SWarner Losh IN UINTN StartBit, 60490d1ba665SWarner Losh IN UINTN EndBit, 60500d1ba665SWarner Losh IN UINT32 AndData, 60510d1ba665SWarner Losh IN UINT32 OrData 60520d1ba665SWarner Losh ); 60530d1ba665SWarner Losh 60540d1ba665SWarner Losh 60550d1ba665SWarner Losh /** 60560d1ba665SWarner Losh Returns a 64-bit Machine Specific Register(MSR). 60570d1ba665SWarner Losh 60580d1ba665SWarner Losh Reads and returns the 64-bit MSR specified by Index. No parameter checking is 60590d1ba665SWarner Losh performed on Index, and some Index values may cause CPU exceptions. The 60600d1ba665SWarner Losh caller must either guarantee that Index is valid, or the caller must set up 60610d1ba665SWarner Losh exception handlers to catch the exceptions. This function is only available 60620d1ba665SWarner Losh on IA-32 and x64. 60630d1ba665SWarner Losh 60640d1ba665SWarner Losh @param Index The 32-bit MSR index to read. 60650d1ba665SWarner Losh 60660d1ba665SWarner Losh @return The value of the MSR identified by Index. 60670d1ba665SWarner Losh 60680d1ba665SWarner Losh **/ 60690d1ba665SWarner Losh UINT64 60700d1ba665SWarner Losh EFIAPI 60710d1ba665SWarner Losh AsmReadMsr64 ( 60720d1ba665SWarner Losh IN UINT32 Index 60730d1ba665SWarner Losh ); 60740d1ba665SWarner Losh 60750d1ba665SWarner Losh 60760d1ba665SWarner Losh /** 60770d1ba665SWarner Losh Writes a 64-bit value to a Machine Specific Register(MSR), and returns the 60780d1ba665SWarner Losh value. 60790d1ba665SWarner Losh 60800d1ba665SWarner Losh Writes the 64-bit value specified by Value to the MSR specified by Index. The 60810d1ba665SWarner Losh 64-bit value written to the MSR is returned. No parameter checking is 60820d1ba665SWarner Losh performed on Index or Value, and some of these may cause CPU exceptions. The 60830d1ba665SWarner Losh caller must either guarantee that Index and Value are valid, or the caller 60840d1ba665SWarner Losh must establish proper exception handlers. This function is only available on 60850d1ba665SWarner Losh IA-32 and x64. 60860d1ba665SWarner Losh 60870d1ba665SWarner Losh @param Index The 32-bit MSR index to write. 60880d1ba665SWarner Losh @param Value The 64-bit value to write to the MSR. 60890d1ba665SWarner Losh 60900d1ba665SWarner Losh @return Value 60910d1ba665SWarner Losh 60920d1ba665SWarner Losh **/ 60930d1ba665SWarner Losh UINT64 60940d1ba665SWarner Losh EFIAPI 60950d1ba665SWarner Losh AsmWriteMsr64 ( 60960d1ba665SWarner Losh IN UINT32 Index, 60970d1ba665SWarner Losh IN UINT64 Value 60980d1ba665SWarner Losh ); 60990d1ba665SWarner Losh 61000d1ba665SWarner Losh 61010d1ba665SWarner Losh /** 61020d1ba665SWarner Losh Reads a 64-bit MSR, performs a bitwise OR, and writes the result 61030d1ba665SWarner Losh back to the 64-bit MSR. 61040d1ba665SWarner Losh 61050d1ba665SWarner Losh Reads the 64-bit MSR specified by Index, performs a bitwise OR 61060d1ba665SWarner Losh between the read result and the value specified by OrData, and writes the 61070d1ba665SWarner Losh result to the 64-bit MSR specified by Index. The value written to the MSR is 61080d1ba665SWarner Losh returned. No parameter checking is performed on Index or OrData, and some of 61090d1ba665SWarner Losh these may cause CPU exceptions. The caller must either guarantee that Index 61100d1ba665SWarner Losh and OrData are valid, or the caller must establish proper exception handlers. 61110d1ba665SWarner Losh This function is only available on IA-32 and x64. 61120d1ba665SWarner Losh 61130d1ba665SWarner Losh @param Index The 32-bit MSR index to write. 61140d1ba665SWarner Losh @param OrData The value to OR with the read value from the MSR. 61150d1ba665SWarner Losh 61160d1ba665SWarner Losh @return The value written back to the MSR. 61170d1ba665SWarner Losh 61180d1ba665SWarner Losh **/ 61190d1ba665SWarner Losh UINT64 61200d1ba665SWarner Losh EFIAPI 61210d1ba665SWarner Losh AsmMsrOr64 ( 61220d1ba665SWarner Losh IN UINT32 Index, 61230d1ba665SWarner Losh IN UINT64 OrData 61240d1ba665SWarner Losh ); 61250d1ba665SWarner Losh 61260d1ba665SWarner Losh 61270d1ba665SWarner Losh /** 61280d1ba665SWarner Losh Reads a 64-bit MSR, performs a bitwise AND, and writes the result back to the 61290d1ba665SWarner Losh 64-bit MSR. 61300d1ba665SWarner Losh 61310d1ba665SWarner Losh Reads the 64-bit MSR specified by Index, performs a bitwise AND between the 61320d1ba665SWarner Losh read result and the value specified by OrData, and writes the result to the 61330d1ba665SWarner Losh 64-bit MSR specified by Index. The value written to the MSR is returned. No 61340d1ba665SWarner Losh parameter checking is performed on Index or OrData, and some of these may 61350d1ba665SWarner Losh cause CPU exceptions. The caller must either guarantee that Index and OrData 61360d1ba665SWarner Losh are valid, or the caller must establish proper exception handlers. This 61370d1ba665SWarner Losh function is only available on IA-32 and x64. 61380d1ba665SWarner Losh 61390d1ba665SWarner Losh @param Index The 32-bit MSR index to write. 61400d1ba665SWarner Losh @param AndData The value to AND with the read value from the MSR. 61410d1ba665SWarner Losh 61420d1ba665SWarner Losh @return The value written back to the MSR. 61430d1ba665SWarner Losh 61440d1ba665SWarner Losh **/ 61450d1ba665SWarner Losh UINT64 61460d1ba665SWarner Losh EFIAPI 61470d1ba665SWarner Losh AsmMsrAnd64 ( 61480d1ba665SWarner Losh IN UINT32 Index, 61490d1ba665SWarner Losh IN UINT64 AndData 61500d1ba665SWarner Losh ); 61510d1ba665SWarner Losh 61520d1ba665SWarner Losh 61530d1ba665SWarner Losh /** 61540d1ba665SWarner Losh Reads a 64-bit MSR, performs a bitwise AND followed by a bitwise 61550d1ba665SWarner Losh OR, and writes the result back to the 64-bit MSR. 61560d1ba665SWarner Losh 61570d1ba665SWarner Losh Reads the 64-bit MSR specified by Index, performs a bitwise AND between read 61580d1ba665SWarner Losh result and the value specified by AndData, performs a bitwise OR 61590d1ba665SWarner Losh between the result of the AND operation and the value specified by OrData, 61600d1ba665SWarner Losh and writes the result to the 64-bit MSR specified by Index. The value written 61610d1ba665SWarner Losh to the MSR is returned. No parameter checking is performed on Index, AndData, 61620d1ba665SWarner Losh or OrData, and some of these may cause CPU exceptions. The caller must either 61630d1ba665SWarner Losh guarantee that Index, AndData, and OrData are valid, or the caller must 61640d1ba665SWarner Losh establish proper exception handlers. This function is only available on IA-32 61650d1ba665SWarner Losh and x64. 61660d1ba665SWarner Losh 61670d1ba665SWarner Losh @param Index The 32-bit MSR index to write. 61680d1ba665SWarner Losh @param AndData The value to AND with the read value from the MSR. 61690d1ba665SWarner Losh @param OrData The value to OR with the result of the AND operation. 61700d1ba665SWarner Losh 61710d1ba665SWarner Losh @return The value written back to the MSR. 61720d1ba665SWarner Losh 61730d1ba665SWarner Losh **/ 61740d1ba665SWarner Losh UINT64 61750d1ba665SWarner Losh EFIAPI 61760d1ba665SWarner Losh AsmMsrAndThenOr64 ( 61770d1ba665SWarner Losh IN UINT32 Index, 61780d1ba665SWarner Losh IN UINT64 AndData, 61790d1ba665SWarner Losh IN UINT64 OrData 61800d1ba665SWarner Losh ); 61810d1ba665SWarner Losh 61820d1ba665SWarner Losh 61830d1ba665SWarner Losh /** 61840d1ba665SWarner Losh Reads a bit field of an MSR. 61850d1ba665SWarner Losh 61860d1ba665SWarner Losh Reads the bit field in the 64-bit MSR. The bit field is specified by the 61870d1ba665SWarner Losh StartBit and the EndBit. The value of the bit field is returned. The caller 61880d1ba665SWarner Losh must either guarantee that Index is valid, or the caller must set up 61890d1ba665SWarner Losh exception handlers to catch the exceptions. This function is only available 61900d1ba665SWarner Losh on IA-32 and x64. 61910d1ba665SWarner Losh 61920d1ba665SWarner Losh If StartBit is greater than 63, then ASSERT(). 61930d1ba665SWarner Losh If EndBit is greater than 63, then ASSERT(). 61940d1ba665SWarner Losh If EndBit is less than StartBit, then ASSERT(). 61950d1ba665SWarner Losh 61960d1ba665SWarner Losh @param Index The 32-bit MSR index to read. 61970d1ba665SWarner Losh @param StartBit The ordinal of the least significant bit in the bit field. 61980d1ba665SWarner Losh Range 0..63. 61990d1ba665SWarner Losh @param EndBit The ordinal of the most significant bit in the bit field. 62000d1ba665SWarner Losh Range 0..63. 62010d1ba665SWarner Losh 62020d1ba665SWarner Losh @return The value read from the MSR. 62030d1ba665SWarner Losh 62040d1ba665SWarner Losh **/ 62050d1ba665SWarner Losh UINT64 62060d1ba665SWarner Losh EFIAPI 62070d1ba665SWarner Losh AsmMsrBitFieldRead64 ( 62080d1ba665SWarner Losh IN UINT32 Index, 62090d1ba665SWarner Losh IN UINTN StartBit, 62100d1ba665SWarner Losh IN UINTN EndBit 62110d1ba665SWarner Losh ); 62120d1ba665SWarner Losh 62130d1ba665SWarner Losh 62140d1ba665SWarner Losh /** 62150d1ba665SWarner Losh Writes a bit field to an MSR. 62160d1ba665SWarner Losh 62170d1ba665SWarner Losh Writes Value to a bit field in a 64-bit MSR. The bit field is specified by 62180d1ba665SWarner Losh the StartBit and the EndBit. All other bits in the destination MSR are 62190d1ba665SWarner Losh preserved. The MSR written is returned. The caller must either guarantee 62200d1ba665SWarner Losh that Index and the data written is valid, or the caller must set up exception 62210d1ba665SWarner Losh handlers to catch the exceptions. This function is only available on IA-32 and x64. 62220d1ba665SWarner Losh 62230d1ba665SWarner Losh If StartBit is greater than 63, then ASSERT(). 62240d1ba665SWarner Losh If EndBit is greater than 63, then ASSERT(). 62250d1ba665SWarner Losh If EndBit is less than StartBit, then ASSERT(). 62260d1ba665SWarner Losh If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT(). 62270d1ba665SWarner Losh 62280d1ba665SWarner Losh @param Index The 32-bit MSR index to write. 62290d1ba665SWarner Losh @param StartBit The ordinal of the least significant bit in the bit field. 62300d1ba665SWarner Losh Range 0..63. 62310d1ba665SWarner Losh @param EndBit The ordinal of the most significant bit in the bit field. 62320d1ba665SWarner Losh Range 0..63. 62330d1ba665SWarner Losh @param Value New value of the bit field. 62340d1ba665SWarner Losh 62350d1ba665SWarner Losh @return The value written back to the MSR. 62360d1ba665SWarner Losh 62370d1ba665SWarner Losh **/ 62380d1ba665SWarner Losh UINT64 62390d1ba665SWarner Losh EFIAPI 62400d1ba665SWarner Losh AsmMsrBitFieldWrite64 ( 62410d1ba665SWarner Losh IN UINT32 Index, 62420d1ba665SWarner Losh IN UINTN StartBit, 62430d1ba665SWarner Losh IN UINTN EndBit, 62440d1ba665SWarner Losh IN UINT64 Value 62450d1ba665SWarner Losh ); 62460d1ba665SWarner Losh 62470d1ba665SWarner Losh 62480d1ba665SWarner Losh /** 62490d1ba665SWarner Losh Reads a bit field in a 64-bit MSR, performs a bitwise OR, and 62500d1ba665SWarner Losh writes the result back to the bit field in the 64-bit MSR. 62510d1ba665SWarner Losh 62520d1ba665SWarner Losh Reads the 64-bit MSR specified by Index, performs a bitwise OR 62530d1ba665SWarner Losh between the read result and the value specified by OrData, and writes the 62540d1ba665SWarner Losh result to the 64-bit MSR specified by Index. The value written to the MSR is 62550d1ba665SWarner Losh returned. Extra left bits in OrData are stripped. The caller must either 62560d1ba665SWarner Losh guarantee that Index and the data written is valid, or the caller must set up 62570d1ba665SWarner Losh exception handlers to catch the exceptions. This function is only available 62580d1ba665SWarner Losh on IA-32 and x64. 62590d1ba665SWarner Losh 62600d1ba665SWarner Losh If StartBit is greater than 63, then ASSERT(). 62610d1ba665SWarner Losh If EndBit is greater than 63, then ASSERT(). 62620d1ba665SWarner Losh If EndBit is less than StartBit, then ASSERT(). 62630d1ba665SWarner Losh If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT(). 62640d1ba665SWarner Losh 62650d1ba665SWarner Losh @param Index The 32-bit MSR index to write. 62660d1ba665SWarner Losh @param StartBit The ordinal of the least significant bit in the bit field. 62670d1ba665SWarner Losh Range 0..63. 62680d1ba665SWarner Losh @param EndBit The ordinal of the most significant bit in the bit field. 62690d1ba665SWarner Losh Range 0..63. 62700d1ba665SWarner Losh @param OrData The value to OR with the read value from the bit field. 62710d1ba665SWarner Losh 62720d1ba665SWarner Losh @return The value written back to the MSR. 62730d1ba665SWarner Losh 62740d1ba665SWarner Losh **/ 62750d1ba665SWarner Losh UINT64 62760d1ba665SWarner Losh EFIAPI 62770d1ba665SWarner Losh AsmMsrBitFieldOr64 ( 62780d1ba665SWarner Losh IN UINT32 Index, 62790d1ba665SWarner Losh IN UINTN StartBit, 62800d1ba665SWarner Losh IN UINTN EndBit, 62810d1ba665SWarner Losh IN UINT64 OrData 62820d1ba665SWarner Losh ); 62830d1ba665SWarner Losh 62840d1ba665SWarner Losh 62850d1ba665SWarner Losh /** 62860d1ba665SWarner Losh Reads a bit field in a 64-bit MSR, performs a bitwise AND, and writes the 62870d1ba665SWarner Losh result back to the bit field in the 64-bit MSR. 62880d1ba665SWarner Losh 62890d1ba665SWarner Losh Reads the 64-bit MSR specified by Index, performs a bitwise AND between the 62900d1ba665SWarner Losh read result and the value specified by AndData, and writes the result to the 62910d1ba665SWarner Losh 64-bit MSR specified by Index. The value written to the MSR is returned. 62920d1ba665SWarner Losh Extra left bits in AndData are stripped. The caller must either guarantee 62930d1ba665SWarner Losh that Index and the data written is valid, or the caller must set up exception 62940d1ba665SWarner Losh handlers to catch the exceptions. This function is only available on IA-32 62950d1ba665SWarner Losh and x64. 62960d1ba665SWarner Losh 62970d1ba665SWarner Losh If StartBit is greater than 63, then ASSERT(). 62980d1ba665SWarner Losh If EndBit is greater than 63, then ASSERT(). 62990d1ba665SWarner Losh If EndBit is less than StartBit, then ASSERT(). 63000d1ba665SWarner Losh If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT(). 63010d1ba665SWarner Losh 63020d1ba665SWarner Losh @param Index The 32-bit MSR index to write. 63030d1ba665SWarner Losh @param StartBit The ordinal of the least significant bit in the bit field. 63040d1ba665SWarner Losh Range 0..63. 63050d1ba665SWarner Losh @param EndBit The ordinal of the most significant bit in the bit field. 63060d1ba665SWarner Losh Range 0..63. 63070d1ba665SWarner Losh @param AndData The value to AND with the read value from the bit field. 63080d1ba665SWarner Losh 63090d1ba665SWarner Losh @return The value written back to the MSR. 63100d1ba665SWarner Losh 63110d1ba665SWarner Losh **/ 63120d1ba665SWarner Losh UINT64 63130d1ba665SWarner Losh EFIAPI 63140d1ba665SWarner Losh AsmMsrBitFieldAnd64 ( 63150d1ba665SWarner Losh IN UINT32 Index, 63160d1ba665SWarner Losh IN UINTN StartBit, 63170d1ba665SWarner Losh IN UINTN EndBit, 63180d1ba665SWarner Losh IN UINT64 AndData 63190d1ba665SWarner Losh ); 63200d1ba665SWarner Losh 63210d1ba665SWarner Losh 63220d1ba665SWarner Losh /** 63230d1ba665SWarner Losh Reads a bit field in a 64-bit MSR, performs a bitwise AND followed by a 63240d1ba665SWarner Losh bitwise OR, and writes the result back to the bit field in the 63250d1ba665SWarner Losh 64-bit MSR. 63260d1ba665SWarner Losh 63270d1ba665SWarner Losh Reads the 64-bit MSR specified by Index, performs a bitwise AND followed by 63280d1ba665SWarner Losh a bitwise OR between the read result and the value specified by 63290d1ba665SWarner Losh AndData, and writes the result to the 64-bit MSR specified by Index. The 63300d1ba665SWarner Losh value written to the MSR is returned. Extra left bits in both AndData and 63310d1ba665SWarner Losh OrData are stripped. The caller must either guarantee that Index and the data 63320d1ba665SWarner Losh written is valid, or the caller must set up exception handlers to catch the 63330d1ba665SWarner Losh exceptions. This function is only available on IA-32 and x64. 63340d1ba665SWarner Losh 63350d1ba665SWarner Losh If StartBit is greater than 63, then ASSERT(). 63360d1ba665SWarner Losh If EndBit is greater than 63, then ASSERT(). 63370d1ba665SWarner Losh If EndBit is less than StartBit, then ASSERT(). 63380d1ba665SWarner Losh If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT(). 63390d1ba665SWarner Losh If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT(). 63400d1ba665SWarner Losh 63410d1ba665SWarner Losh @param Index The 32-bit MSR index to write. 63420d1ba665SWarner Losh @param StartBit The ordinal of the least significant bit in the bit field. 63430d1ba665SWarner Losh Range 0..63. 63440d1ba665SWarner Losh @param EndBit The ordinal of the most significant bit in the bit field. 63450d1ba665SWarner Losh Range 0..63. 63460d1ba665SWarner Losh @param AndData The value to AND with the read value from the bit field. 63470d1ba665SWarner Losh @param OrData The value to OR with the result of the AND operation. 63480d1ba665SWarner Losh 63490d1ba665SWarner Losh @return The value written back to the MSR. 63500d1ba665SWarner Losh 63510d1ba665SWarner Losh **/ 63520d1ba665SWarner Losh UINT64 63530d1ba665SWarner Losh EFIAPI 63540d1ba665SWarner Losh AsmMsrBitFieldAndThenOr64 ( 63550d1ba665SWarner Losh IN UINT32 Index, 63560d1ba665SWarner Losh IN UINTN StartBit, 63570d1ba665SWarner Losh IN UINTN EndBit, 63580d1ba665SWarner Losh IN UINT64 AndData, 63590d1ba665SWarner Losh IN UINT64 OrData 63600d1ba665SWarner Losh ); 63610d1ba665SWarner Losh 63620d1ba665SWarner Losh 63630d1ba665SWarner Losh /** 63640d1ba665SWarner Losh Reads the current value of the EFLAGS register. 63650d1ba665SWarner Losh 63660d1ba665SWarner Losh Reads and returns the current value of the EFLAGS register. This function is 63670d1ba665SWarner Losh only available on IA-32 and x64. This returns a 32-bit value on IA-32 and a 63680d1ba665SWarner Losh 64-bit value on x64. 63690d1ba665SWarner Losh 63700d1ba665SWarner Losh @return EFLAGS on IA-32 or RFLAGS on x64. 63710d1ba665SWarner Losh 63720d1ba665SWarner Losh **/ 63730d1ba665SWarner Losh UINTN 63740d1ba665SWarner Losh EFIAPI 63750d1ba665SWarner Losh AsmReadEflags ( 63760d1ba665SWarner Losh VOID 63770d1ba665SWarner Losh ); 63780d1ba665SWarner Losh 63790d1ba665SWarner Losh 63800d1ba665SWarner Losh /** 63810d1ba665SWarner Losh Reads the current value of the Control Register 0 (CR0). 63820d1ba665SWarner Losh 63830d1ba665SWarner Losh Reads and returns the current value of CR0. This function is only available 63840d1ba665SWarner Losh on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on 63850d1ba665SWarner Losh x64. 63860d1ba665SWarner Losh 63870d1ba665SWarner Losh @return The value of the Control Register 0 (CR0). 63880d1ba665SWarner Losh 63890d1ba665SWarner Losh **/ 63900d1ba665SWarner Losh UINTN 63910d1ba665SWarner Losh EFIAPI 63920d1ba665SWarner Losh AsmReadCr0 ( 63930d1ba665SWarner Losh VOID 63940d1ba665SWarner Losh ); 63950d1ba665SWarner Losh 63960d1ba665SWarner Losh 63970d1ba665SWarner Losh /** 63980d1ba665SWarner Losh Reads the current value of the Control Register 2 (CR2). 63990d1ba665SWarner Losh 64000d1ba665SWarner Losh Reads and returns the current value of CR2. This function is only available 64010d1ba665SWarner Losh on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on 64020d1ba665SWarner Losh x64. 64030d1ba665SWarner Losh 64040d1ba665SWarner Losh @return The value of the Control Register 2 (CR2). 64050d1ba665SWarner Losh 64060d1ba665SWarner Losh **/ 64070d1ba665SWarner Losh UINTN 64080d1ba665SWarner Losh EFIAPI 64090d1ba665SWarner Losh AsmReadCr2 ( 64100d1ba665SWarner Losh VOID 64110d1ba665SWarner Losh ); 64120d1ba665SWarner Losh 64130d1ba665SWarner Losh 64140d1ba665SWarner Losh /** 64150d1ba665SWarner Losh Reads the current value of the Control Register 3 (CR3). 64160d1ba665SWarner Losh 64170d1ba665SWarner Losh Reads and returns the current value of CR3. This function is only available 64180d1ba665SWarner Losh on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on 64190d1ba665SWarner Losh x64. 64200d1ba665SWarner Losh 64210d1ba665SWarner Losh @return The value of the Control Register 3 (CR3). 64220d1ba665SWarner Losh 64230d1ba665SWarner Losh **/ 64240d1ba665SWarner Losh UINTN 64250d1ba665SWarner Losh EFIAPI 64260d1ba665SWarner Losh AsmReadCr3 ( 64270d1ba665SWarner Losh VOID 64280d1ba665SWarner Losh ); 64290d1ba665SWarner Losh 64300d1ba665SWarner Losh 64310d1ba665SWarner Losh /** 64320d1ba665SWarner Losh Reads the current value of the Control Register 4 (CR4). 64330d1ba665SWarner Losh 64340d1ba665SWarner Losh Reads and returns the current value of CR4. This function is only available 64350d1ba665SWarner Losh on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on 64360d1ba665SWarner Losh x64. 64370d1ba665SWarner Losh 64380d1ba665SWarner Losh @return The value of the Control Register 4 (CR4). 64390d1ba665SWarner Losh 64400d1ba665SWarner Losh **/ 64410d1ba665SWarner Losh UINTN 64420d1ba665SWarner Losh EFIAPI 64430d1ba665SWarner Losh AsmReadCr4 ( 64440d1ba665SWarner Losh VOID 64450d1ba665SWarner Losh ); 64460d1ba665SWarner Losh 64470d1ba665SWarner Losh 64480d1ba665SWarner Losh /** 64490d1ba665SWarner Losh Writes a value to Control Register 0 (CR0). 64500d1ba665SWarner Losh 64510d1ba665SWarner Losh Writes and returns a new value to CR0. This function is only available on 64520d1ba665SWarner Losh IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64. 64530d1ba665SWarner Losh 64540d1ba665SWarner Losh @param Cr0 The value to write to CR0. 64550d1ba665SWarner Losh 64560d1ba665SWarner Losh @return The value written to CR0. 64570d1ba665SWarner Losh 64580d1ba665SWarner Losh **/ 64590d1ba665SWarner Losh UINTN 64600d1ba665SWarner Losh EFIAPI 64610d1ba665SWarner Losh AsmWriteCr0 ( 64620d1ba665SWarner Losh UINTN Cr0 64630d1ba665SWarner Losh ); 64640d1ba665SWarner Losh 64650d1ba665SWarner Losh 64660d1ba665SWarner Losh /** 64670d1ba665SWarner Losh Writes a value to Control Register 2 (CR2). 64680d1ba665SWarner Losh 64690d1ba665SWarner Losh Writes and returns a new value to CR2. This function is only available on 64700d1ba665SWarner Losh IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64. 64710d1ba665SWarner Losh 64720d1ba665SWarner Losh @param Cr2 The value to write to CR2. 64730d1ba665SWarner Losh 64740d1ba665SWarner Losh @return The value written to CR2. 64750d1ba665SWarner Losh 64760d1ba665SWarner Losh **/ 64770d1ba665SWarner Losh UINTN 64780d1ba665SWarner Losh EFIAPI 64790d1ba665SWarner Losh AsmWriteCr2 ( 64800d1ba665SWarner Losh UINTN Cr2 64810d1ba665SWarner Losh ); 64820d1ba665SWarner Losh 64830d1ba665SWarner Losh 64840d1ba665SWarner Losh /** 64850d1ba665SWarner Losh Writes a value to Control Register 3 (CR3). 64860d1ba665SWarner Losh 64870d1ba665SWarner Losh Writes and returns a new value to CR3. This function is only available on 64880d1ba665SWarner Losh IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64. 64890d1ba665SWarner Losh 64900d1ba665SWarner Losh @param Cr3 The value to write to CR3. 64910d1ba665SWarner Losh 64920d1ba665SWarner Losh @return The value written to CR3. 64930d1ba665SWarner Losh 64940d1ba665SWarner Losh **/ 64950d1ba665SWarner Losh UINTN 64960d1ba665SWarner Losh EFIAPI 64970d1ba665SWarner Losh AsmWriteCr3 ( 64980d1ba665SWarner Losh UINTN Cr3 64990d1ba665SWarner Losh ); 65000d1ba665SWarner Losh 65010d1ba665SWarner Losh 65020d1ba665SWarner Losh /** 65030d1ba665SWarner Losh Writes a value to Control Register 4 (CR4). 65040d1ba665SWarner Losh 65050d1ba665SWarner Losh Writes and returns a new value to CR4. This function is only available on 65060d1ba665SWarner Losh IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64. 65070d1ba665SWarner Losh 65080d1ba665SWarner Losh @param Cr4 The value to write to CR4. 65090d1ba665SWarner Losh 65100d1ba665SWarner Losh @return The value written to CR4. 65110d1ba665SWarner Losh 65120d1ba665SWarner Losh **/ 65130d1ba665SWarner Losh UINTN 65140d1ba665SWarner Losh EFIAPI 65150d1ba665SWarner Losh AsmWriteCr4 ( 65160d1ba665SWarner Losh UINTN Cr4 65170d1ba665SWarner Losh ); 65180d1ba665SWarner Losh 65190d1ba665SWarner Losh 65200d1ba665SWarner Losh /** 65210d1ba665SWarner Losh Reads the current value of Debug Register 0 (DR0). 65220d1ba665SWarner Losh 65230d1ba665SWarner Losh Reads and returns the current value of DR0. This function is only available 65240d1ba665SWarner Losh on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on 65250d1ba665SWarner Losh x64. 65260d1ba665SWarner Losh 65270d1ba665SWarner Losh @return The value of Debug Register 0 (DR0). 65280d1ba665SWarner Losh 65290d1ba665SWarner Losh **/ 65300d1ba665SWarner Losh UINTN 65310d1ba665SWarner Losh EFIAPI 65320d1ba665SWarner Losh AsmReadDr0 ( 65330d1ba665SWarner Losh VOID 65340d1ba665SWarner Losh ); 65350d1ba665SWarner Losh 65360d1ba665SWarner Losh 65370d1ba665SWarner Losh /** 65380d1ba665SWarner Losh Reads the current value of Debug Register 1 (DR1). 65390d1ba665SWarner Losh 65400d1ba665SWarner Losh Reads and returns the current value of DR1. This function is only available 65410d1ba665SWarner Losh on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on 65420d1ba665SWarner Losh x64. 65430d1ba665SWarner Losh 65440d1ba665SWarner Losh @return The value of Debug Register 1 (DR1). 65450d1ba665SWarner Losh 65460d1ba665SWarner Losh **/ 65470d1ba665SWarner Losh UINTN 65480d1ba665SWarner Losh EFIAPI 65490d1ba665SWarner Losh AsmReadDr1 ( 65500d1ba665SWarner Losh VOID 65510d1ba665SWarner Losh ); 65520d1ba665SWarner Losh 65530d1ba665SWarner Losh 65540d1ba665SWarner Losh /** 65550d1ba665SWarner Losh Reads the current value of Debug Register 2 (DR2). 65560d1ba665SWarner Losh 65570d1ba665SWarner Losh Reads and returns the current value of DR2. This function is only available 65580d1ba665SWarner Losh on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on 65590d1ba665SWarner Losh x64. 65600d1ba665SWarner Losh 65610d1ba665SWarner Losh @return The value of Debug Register 2 (DR2). 65620d1ba665SWarner Losh 65630d1ba665SWarner Losh **/ 65640d1ba665SWarner Losh UINTN 65650d1ba665SWarner Losh EFIAPI 65660d1ba665SWarner Losh AsmReadDr2 ( 65670d1ba665SWarner Losh VOID 65680d1ba665SWarner Losh ); 65690d1ba665SWarner Losh 65700d1ba665SWarner Losh 65710d1ba665SWarner Losh /** 65720d1ba665SWarner Losh Reads the current value of Debug Register 3 (DR3). 65730d1ba665SWarner Losh 65740d1ba665SWarner Losh Reads and returns the current value of DR3. This function is only available 65750d1ba665SWarner Losh on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on 65760d1ba665SWarner Losh x64. 65770d1ba665SWarner Losh 65780d1ba665SWarner Losh @return The value of Debug Register 3 (DR3). 65790d1ba665SWarner Losh 65800d1ba665SWarner Losh **/ 65810d1ba665SWarner Losh UINTN 65820d1ba665SWarner Losh EFIAPI 65830d1ba665SWarner Losh AsmReadDr3 ( 65840d1ba665SWarner Losh VOID 65850d1ba665SWarner Losh ); 65860d1ba665SWarner Losh 65870d1ba665SWarner Losh 65880d1ba665SWarner Losh /** 65890d1ba665SWarner Losh Reads the current value of Debug Register 4 (DR4). 65900d1ba665SWarner Losh 65910d1ba665SWarner Losh Reads and returns the current value of DR4. This function is only available 65920d1ba665SWarner Losh on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on 65930d1ba665SWarner Losh x64. 65940d1ba665SWarner Losh 65950d1ba665SWarner Losh @return The value of Debug Register 4 (DR4). 65960d1ba665SWarner Losh 65970d1ba665SWarner Losh **/ 65980d1ba665SWarner Losh UINTN 65990d1ba665SWarner Losh EFIAPI 66000d1ba665SWarner Losh AsmReadDr4 ( 66010d1ba665SWarner Losh VOID 66020d1ba665SWarner Losh ); 66030d1ba665SWarner Losh 66040d1ba665SWarner Losh 66050d1ba665SWarner Losh /** 66060d1ba665SWarner Losh Reads the current value of Debug Register 5 (DR5). 66070d1ba665SWarner Losh 66080d1ba665SWarner Losh Reads and returns the current value of DR5. This function is only available 66090d1ba665SWarner Losh on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on 66100d1ba665SWarner Losh x64. 66110d1ba665SWarner Losh 66120d1ba665SWarner Losh @return The value of Debug Register 5 (DR5). 66130d1ba665SWarner Losh 66140d1ba665SWarner Losh **/ 66150d1ba665SWarner Losh UINTN 66160d1ba665SWarner Losh EFIAPI 66170d1ba665SWarner Losh AsmReadDr5 ( 66180d1ba665SWarner Losh VOID 66190d1ba665SWarner Losh ); 66200d1ba665SWarner Losh 66210d1ba665SWarner Losh 66220d1ba665SWarner Losh /** 66230d1ba665SWarner Losh Reads the current value of Debug Register 6 (DR6). 66240d1ba665SWarner Losh 66250d1ba665SWarner Losh Reads and returns the current value of DR6. This function is only available 66260d1ba665SWarner Losh on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on 66270d1ba665SWarner Losh x64. 66280d1ba665SWarner Losh 66290d1ba665SWarner Losh @return The value of Debug Register 6 (DR6). 66300d1ba665SWarner Losh 66310d1ba665SWarner Losh **/ 66320d1ba665SWarner Losh UINTN 66330d1ba665SWarner Losh EFIAPI 66340d1ba665SWarner Losh AsmReadDr6 ( 66350d1ba665SWarner Losh VOID 66360d1ba665SWarner Losh ); 66370d1ba665SWarner Losh 66380d1ba665SWarner Losh 66390d1ba665SWarner Losh /** 66400d1ba665SWarner Losh Reads the current value of Debug Register 7 (DR7). 66410d1ba665SWarner Losh 66420d1ba665SWarner Losh Reads and returns the current value of DR7. This function is only available 66430d1ba665SWarner Losh on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on 66440d1ba665SWarner Losh x64. 66450d1ba665SWarner Losh 66460d1ba665SWarner Losh @return The value of Debug Register 7 (DR7). 66470d1ba665SWarner Losh 66480d1ba665SWarner Losh **/ 66490d1ba665SWarner Losh UINTN 66500d1ba665SWarner Losh EFIAPI 66510d1ba665SWarner Losh AsmReadDr7 ( 66520d1ba665SWarner Losh VOID 66530d1ba665SWarner Losh ); 66540d1ba665SWarner Losh 66550d1ba665SWarner Losh 66560d1ba665SWarner Losh /** 66570d1ba665SWarner Losh Writes a value to Debug Register 0 (DR0). 66580d1ba665SWarner Losh 66590d1ba665SWarner Losh Writes and returns a new value to DR0. This function is only available on 66600d1ba665SWarner Losh IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64. 66610d1ba665SWarner Losh 66620d1ba665SWarner Losh @param Dr0 The value to write to Dr0. 66630d1ba665SWarner Losh 66640d1ba665SWarner Losh @return The value written to Debug Register 0 (DR0). 66650d1ba665SWarner Losh 66660d1ba665SWarner Losh **/ 66670d1ba665SWarner Losh UINTN 66680d1ba665SWarner Losh EFIAPI 66690d1ba665SWarner Losh AsmWriteDr0 ( 66700d1ba665SWarner Losh UINTN Dr0 66710d1ba665SWarner Losh ); 66720d1ba665SWarner Losh 66730d1ba665SWarner Losh 66740d1ba665SWarner Losh /** 66750d1ba665SWarner Losh Writes a value to Debug Register 1 (DR1). 66760d1ba665SWarner Losh 66770d1ba665SWarner Losh Writes and returns a new value to DR1. This function is only available on 66780d1ba665SWarner Losh IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64. 66790d1ba665SWarner Losh 66800d1ba665SWarner Losh @param Dr1 The value to write to Dr1. 66810d1ba665SWarner Losh 66820d1ba665SWarner Losh @return The value written to Debug Register 1 (DR1). 66830d1ba665SWarner Losh 66840d1ba665SWarner Losh **/ 66850d1ba665SWarner Losh UINTN 66860d1ba665SWarner Losh EFIAPI 66870d1ba665SWarner Losh AsmWriteDr1 ( 66880d1ba665SWarner Losh UINTN Dr1 66890d1ba665SWarner Losh ); 66900d1ba665SWarner Losh 66910d1ba665SWarner Losh 66920d1ba665SWarner Losh /** 66930d1ba665SWarner Losh Writes a value to Debug Register 2 (DR2). 66940d1ba665SWarner Losh 66950d1ba665SWarner Losh Writes and returns a new value to DR2. This function is only available on 66960d1ba665SWarner Losh IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64. 66970d1ba665SWarner Losh 66980d1ba665SWarner Losh @param Dr2 The value to write to Dr2. 66990d1ba665SWarner Losh 67000d1ba665SWarner Losh @return The value written to Debug Register 2 (DR2). 67010d1ba665SWarner Losh 67020d1ba665SWarner Losh **/ 67030d1ba665SWarner Losh UINTN 67040d1ba665SWarner Losh EFIAPI 67050d1ba665SWarner Losh AsmWriteDr2 ( 67060d1ba665SWarner Losh UINTN Dr2 67070d1ba665SWarner Losh ); 67080d1ba665SWarner Losh 67090d1ba665SWarner Losh 67100d1ba665SWarner Losh /** 67110d1ba665SWarner Losh Writes a value to Debug Register 3 (DR3). 67120d1ba665SWarner Losh 67130d1ba665SWarner Losh Writes and returns a new value to DR3. This function is only available on 67140d1ba665SWarner Losh IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64. 67150d1ba665SWarner Losh 67160d1ba665SWarner Losh @param Dr3 The value to write to Dr3. 67170d1ba665SWarner Losh 67180d1ba665SWarner Losh @return The value written to Debug Register 3 (DR3). 67190d1ba665SWarner Losh 67200d1ba665SWarner Losh **/ 67210d1ba665SWarner Losh UINTN 67220d1ba665SWarner Losh EFIAPI 67230d1ba665SWarner Losh AsmWriteDr3 ( 67240d1ba665SWarner Losh UINTN Dr3 67250d1ba665SWarner Losh ); 67260d1ba665SWarner Losh 67270d1ba665SWarner Losh 67280d1ba665SWarner Losh /** 67290d1ba665SWarner Losh Writes a value to Debug Register 4 (DR4). 67300d1ba665SWarner Losh 67310d1ba665SWarner Losh Writes and returns a new value to DR4. This function is only available on 67320d1ba665SWarner Losh IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64. 67330d1ba665SWarner Losh 67340d1ba665SWarner Losh @param Dr4 The value to write to Dr4. 67350d1ba665SWarner Losh 67360d1ba665SWarner Losh @return The value written to Debug Register 4 (DR4). 67370d1ba665SWarner Losh 67380d1ba665SWarner Losh **/ 67390d1ba665SWarner Losh UINTN 67400d1ba665SWarner Losh EFIAPI 67410d1ba665SWarner Losh AsmWriteDr4 ( 67420d1ba665SWarner Losh UINTN Dr4 67430d1ba665SWarner Losh ); 67440d1ba665SWarner Losh 67450d1ba665SWarner Losh 67460d1ba665SWarner Losh /** 67470d1ba665SWarner Losh Writes a value to Debug Register 5 (DR5). 67480d1ba665SWarner Losh 67490d1ba665SWarner Losh Writes and returns a new value to DR5. This function is only available on 67500d1ba665SWarner Losh IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64. 67510d1ba665SWarner Losh 67520d1ba665SWarner Losh @param Dr5 The value to write to Dr5. 67530d1ba665SWarner Losh 67540d1ba665SWarner Losh @return The value written to Debug Register 5 (DR5). 67550d1ba665SWarner Losh 67560d1ba665SWarner Losh **/ 67570d1ba665SWarner Losh UINTN 67580d1ba665SWarner Losh EFIAPI 67590d1ba665SWarner Losh AsmWriteDr5 ( 67600d1ba665SWarner Losh UINTN Dr5 67610d1ba665SWarner Losh ); 67620d1ba665SWarner Losh 67630d1ba665SWarner Losh 67640d1ba665SWarner Losh /** 67650d1ba665SWarner Losh Writes a value to Debug Register 6 (DR6). 67660d1ba665SWarner Losh 67670d1ba665SWarner Losh Writes and returns a new value to DR6. This function is only available on 67680d1ba665SWarner Losh IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64. 67690d1ba665SWarner Losh 67700d1ba665SWarner Losh @param Dr6 The value to write to Dr6. 67710d1ba665SWarner Losh 67720d1ba665SWarner Losh @return The value written to Debug Register 6 (DR6). 67730d1ba665SWarner Losh 67740d1ba665SWarner Losh **/ 67750d1ba665SWarner Losh UINTN 67760d1ba665SWarner Losh EFIAPI 67770d1ba665SWarner Losh AsmWriteDr6 ( 67780d1ba665SWarner Losh UINTN Dr6 67790d1ba665SWarner Losh ); 67800d1ba665SWarner Losh 67810d1ba665SWarner Losh 67820d1ba665SWarner Losh /** 67830d1ba665SWarner Losh Writes a value to Debug Register 7 (DR7). 67840d1ba665SWarner Losh 67850d1ba665SWarner Losh Writes and returns a new value to DR7. This function is only available on 67860d1ba665SWarner Losh IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64. 67870d1ba665SWarner Losh 67880d1ba665SWarner Losh @param Dr7 The value to write to Dr7. 67890d1ba665SWarner Losh 67900d1ba665SWarner Losh @return The value written to Debug Register 7 (DR7). 67910d1ba665SWarner Losh 67920d1ba665SWarner Losh **/ 67930d1ba665SWarner Losh UINTN 67940d1ba665SWarner Losh EFIAPI 67950d1ba665SWarner Losh AsmWriteDr7 ( 67960d1ba665SWarner Losh UINTN Dr7 67970d1ba665SWarner Losh ); 67980d1ba665SWarner Losh 67990d1ba665SWarner Losh 68000d1ba665SWarner Losh /** 68010d1ba665SWarner Losh Reads the current value of Code Segment Register (CS). 68020d1ba665SWarner Losh 68030d1ba665SWarner Losh Reads and returns the current value of CS. This function is only available on 68040d1ba665SWarner Losh IA-32 and x64. 68050d1ba665SWarner Losh 68060d1ba665SWarner Losh @return The current value of CS. 68070d1ba665SWarner Losh 68080d1ba665SWarner Losh **/ 68090d1ba665SWarner Losh UINT16 68100d1ba665SWarner Losh EFIAPI 68110d1ba665SWarner Losh AsmReadCs ( 68120d1ba665SWarner Losh VOID 68130d1ba665SWarner Losh ); 68140d1ba665SWarner Losh 68150d1ba665SWarner Losh 68160d1ba665SWarner Losh /** 68170d1ba665SWarner Losh Reads the current value of Data Segment Register (DS). 68180d1ba665SWarner Losh 68190d1ba665SWarner Losh Reads and returns the current value of DS. This function is only available on 68200d1ba665SWarner Losh IA-32 and x64. 68210d1ba665SWarner Losh 68220d1ba665SWarner Losh @return The current value of DS. 68230d1ba665SWarner Losh 68240d1ba665SWarner Losh **/ 68250d1ba665SWarner Losh UINT16 68260d1ba665SWarner Losh EFIAPI 68270d1ba665SWarner Losh AsmReadDs ( 68280d1ba665SWarner Losh VOID 68290d1ba665SWarner Losh ); 68300d1ba665SWarner Losh 68310d1ba665SWarner Losh 68320d1ba665SWarner Losh /** 68330d1ba665SWarner Losh Reads the current value of Extra Segment Register (ES). 68340d1ba665SWarner Losh 68350d1ba665SWarner Losh Reads and returns the current value of ES. This function is only available on 68360d1ba665SWarner Losh IA-32 and x64. 68370d1ba665SWarner Losh 68380d1ba665SWarner Losh @return The current value of ES. 68390d1ba665SWarner Losh 68400d1ba665SWarner Losh **/ 68410d1ba665SWarner Losh UINT16 68420d1ba665SWarner Losh EFIAPI 68430d1ba665SWarner Losh AsmReadEs ( 68440d1ba665SWarner Losh VOID 68450d1ba665SWarner Losh ); 68460d1ba665SWarner Losh 68470d1ba665SWarner Losh 68480d1ba665SWarner Losh /** 68490d1ba665SWarner Losh Reads the current value of FS Data Segment Register (FS). 68500d1ba665SWarner Losh 68510d1ba665SWarner Losh Reads and returns the current value of FS. This function is only available on 68520d1ba665SWarner Losh IA-32 and x64. 68530d1ba665SWarner Losh 68540d1ba665SWarner Losh @return The current value of FS. 68550d1ba665SWarner Losh 68560d1ba665SWarner Losh **/ 68570d1ba665SWarner Losh UINT16 68580d1ba665SWarner Losh EFIAPI 68590d1ba665SWarner Losh AsmReadFs ( 68600d1ba665SWarner Losh VOID 68610d1ba665SWarner Losh ); 68620d1ba665SWarner Losh 68630d1ba665SWarner Losh 68640d1ba665SWarner Losh /** 68650d1ba665SWarner Losh Reads the current value of GS Data Segment Register (GS). 68660d1ba665SWarner Losh 68670d1ba665SWarner Losh Reads and returns the current value of GS. This function is only available on 68680d1ba665SWarner Losh IA-32 and x64. 68690d1ba665SWarner Losh 68700d1ba665SWarner Losh @return The current value of GS. 68710d1ba665SWarner Losh 68720d1ba665SWarner Losh **/ 68730d1ba665SWarner Losh UINT16 68740d1ba665SWarner Losh EFIAPI 68750d1ba665SWarner Losh AsmReadGs ( 68760d1ba665SWarner Losh VOID 68770d1ba665SWarner Losh ); 68780d1ba665SWarner Losh 68790d1ba665SWarner Losh 68800d1ba665SWarner Losh /** 68810d1ba665SWarner Losh Reads the current value of Stack Segment Register (SS). 68820d1ba665SWarner Losh 68830d1ba665SWarner Losh Reads and returns the current value of SS. This function is only available on 68840d1ba665SWarner Losh IA-32 and x64. 68850d1ba665SWarner Losh 68860d1ba665SWarner Losh @return The current value of SS. 68870d1ba665SWarner Losh 68880d1ba665SWarner Losh **/ 68890d1ba665SWarner Losh UINT16 68900d1ba665SWarner Losh EFIAPI 68910d1ba665SWarner Losh AsmReadSs ( 68920d1ba665SWarner Losh VOID 68930d1ba665SWarner Losh ); 68940d1ba665SWarner Losh 68950d1ba665SWarner Losh 68960d1ba665SWarner Losh /** 68970d1ba665SWarner Losh Reads the current value of Task Register (TR). 68980d1ba665SWarner Losh 68990d1ba665SWarner Losh Reads and returns the current value of TR. This function is only available on 69000d1ba665SWarner Losh IA-32 and x64. 69010d1ba665SWarner Losh 69020d1ba665SWarner Losh @return The current value of TR. 69030d1ba665SWarner Losh 69040d1ba665SWarner Losh **/ 69050d1ba665SWarner Losh UINT16 69060d1ba665SWarner Losh EFIAPI 69070d1ba665SWarner Losh AsmReadTr ( 69080d1ba665SWarner Losh VOID 69090d1ba665SWarner Losh ); 69100d1ba665SWarner Losh 69110d1ba665SWarner Losh 69120d1ba665SWarner Losh /** 69130d1ba665SWarner Losh Reads the current Global Descriptor Table Register(GDTR) descriptor. 69140d1ba665SWarner Losh 69150d1ba665SWarner Losh Reads and returns the current GDTR descriptor and returns it in Gdtr. This 69160d1ba665SWarner Losh function is only available on IA-32 and x64. 69170d1ba665SWarner Losh 69180d1ba665SWarner Losh If Gdtr is NULL, then ASSERT(). 69190d1ba665SWarner Losh 69200d1ba665SWarner Losh @param Gdtr The pointer to a GDTR descriptor. 69210d1ba665SWarner Losh 69220d1ba665SWarner Losh **/ 69230d1ba665SWarner Losh VOID 69240d1ba665SWarner Losh EFIAPI 69250d1ba665SWarner Losh AsmReadGdtr ( 69260d1ba665SWarner Losh OUT IA32_DESCRIPTOR *Gdtr 69270d1ba665SWarner Losh ); 69280d1ba665SWarner Losh 69290d1ba665SWarner Losh 69300d1ba665SWarner Losh /** 69310d1ba665SWarner Losh Writes the current Global Descriptor Table Register (GDTR) descriptor. 69320d1ba665SWarner Losh 69330d1ba665SWarner Losh Writes and the current GDTR descriptor specified by Gdtr. This function is 69340d1ba665SWarner Losh only available on IA-32 and x64. 69350d1ba665SWarner Losh 69360d1ba665SWarner Losh If Gdtr is NULL, then ASSERT(). 69370d1ba665SWarner Losh 69380d1ba665SWarner Losh @param Gdtr The pointer to a GDTR descriptor. 69390d1ba665SWarner Losh 69400d1ba665SWarner Losh **/ 69410d1ba665SWarner Losh VOID 69420d1ba665SWarner Losh EFIAPI 69430d1ba665SWarner Losh AsmWriteGdtr ( 69440d1ba665SWarner Losh IN CONST IA32_DESCRIPTOR *Gdtr 69450d1ba665SWarner Losh ); 69460d1ba665SWarner Losh 69470d1ba665SWarner Losh 69480d1ba665SWarner Losh /** 69490d1ba665SWarner Losh Reads the current Interrupt Descriptor Table Register(IDTR) descriptor. 69500d1ba665SWarner Losh 69510d1ba665SWarner Losh Reads and returns the current IDTR descriptor and returns it in Idtr. This 69520d1ba665SWarner Losh function is only available on IA-32 and x64. 69530d1ba665SWarner Losh 69540d1ba665SWarner Losh If Idtr is NULL, then ASSERT(). 69550d1ba665SWarner Losh 69560d1ba665SWarner Losh @param Idtr The pointer to a IDTR descriptor. 69570d1ba665SWarner Losh 69580d1ba665SWarner Losh **/ 69590d1ba665SWarner Losh VOID 69600d1ba665SWarner Losh EFIAPI 69610d1ba665SWarner Losh AsmReadIdtr ( 69620d1ba665SWarner Losh OUT IA32_DESCRIPTOR *Idtr 69630d1ba665SWarner Losh ); 69640d1ba665SWarner Losh 69650d1ba665SWarner Losh 69660d1ba665SWarner Losh /** 69670d1ba665SWarner Losh Writes the current Interrupt Descriptor Table Register(IDTR) descriptor. 69680d1ba665SWarner Losh 69690d1ba665SWarner Losh Writes the current IDTR descriptor and returns it in Idtr. This function is 69700d1ba665SWarner Losh only available on IA-32 and x64. 69710d1ba665SWarner Losh 69720d1ba665SWarner Losh If Idtr is NULL, then ASSERT(). 69730d1ba665SWarner Losh 69740d1ba665SWarner Losh @param Idtr The pointer to a IDTR descriptor. 69750d1ba665SWarner Losh 69760d1ba665SWarner Losh **/ 69770d1ba665SWarner Losh VOID 69780d1ba665SWarner Losh EFIAPI 69790d1ba665SWarner Losh AsmWriteIdtr ( 69800d1ba665SWarner Losh IN CONST IA32_DESCRIPTOR *Idtr 69810d1ba665SWarner Losh ); 69820d1ba665SWarner Losh 69830d1ba665SWarner Losh 69840d1ba665SWarner Losh /** 69850d1ba665SWarner Losh Reads the current Local Descriptor Table Register(LDTR) selector. 69860d1ba665SWarner Losh 69870d1ba665SWarner Losh Reads and returns the current 16-bit LDTR descriptor value. This function is 69880d1ba665SWarner Losh only available on IA-32 and x64. 69890d1ba665SWarner Losh 69900d1ba665SWarner Losh @return The current selector of LDT. 69910d1ba665SWarner Losh 69920d1ba665SWarner Losh **/ 69930d1ba665SWarner Losh UINT16 69940d1ba665SWarner Losh EFIAPI 69950d1ba665SWarner Losh AsmReadLdtr ( 69960d1ba665SWarner Losh VOID 69970d1ba665SWarner Losh ); 69980d1ba665SWarner Losh 69990d1ba665SWarner Losh 70000d1ba665SWarner Losh /** 70010d1ba665SWarner Losh Writes the current Local Descriptor Table Register (LDTR) selector. 70020d1ba665SWarner Losh 70030d1ba665SWarner Losh Writes and the current LDTR descriptor specified by Ldtr. This function is 70040d1ba665SWarner Losh only available on IA-32 and x64. 70050d1ba665SWarner Losh 70060d1ba665SWarner Losh @param Ldtr 16-bit LDTR selector value. 70070d1ba665SWarner Losh 70080d1ba665SWarner Losh **/ 70090d1ba665SWarner Losh VOID 70100d1ba665SWarner Losh EFIAPI 70110d1ba665SWarner Losh AsmWriteLdtr ( 70120d1ba665SWarner Losh IN UINT16 Ldtr 70130d1ba665SWarner Losh ); 70140d1ba665SWarner Losh 70150d1ba665SWarner Losh 70160d1ba665SWarner Losh /** 70170d1ba665SWarner Losh Save the current floating point/SSE/SSE2 context to a buffer. 70180d1ba665SWarner Losh 70190d1ba665SWarner Losh Saves the current floating point/SSE/SSE2 state to the buffer specified by 70200d1ba665SWarner Losh Buffer. Buffer must be aligned on a 16-byte boundary. This function is only 70210d1ba665SWarner Losh available on IA-32 and x64. 70220d1ba665SWarner Losh 70230d1ba665SWarner Losh If Buffer is NULL, then ASSERT(). 70240d1ba665SWarner Losh If Buffer is not aligned on a 16-byte boundary, then ASSERT(). 70250d1ba665SWarner Losh 70260d1ba665SWarner Losh @param Buffer The pointer to a buffer to save the floating point/SSE/SSE2 context. 70270d1ba665SWarner Losh 70280d1ba665SWarner Losh **/ 70290d1ba665SWarner Losh VOID 70300d1ba665SWarner Losh EFIAPI 70310d1ba665SWarner Losh AsmFxSave ( 70320d1ba665SWarner Losh OUT IA32_FX_BUFFER *Buffer 70330d1ba665SWarner Losh ); 70340d1ba665SWarner Losh 70350d1ba665SWarner Losh 70360d1ba665SWarner Losh /** 70370d1ba665SWarner Losh Restores the current floating point/SSE/SSE2 context from a buffer. 70380d1ba665SWarner Losh 70390d1ba665SWarner Losh Restores the current floating point/SSE/SSE2 state from the buffer specified 70400d1ba665SWarner Losh by Buffer. Buffer must be aligned on a 16-byte boundary. This function is 70410d1ba665SWarner Losh only available on IA-32 and x64. 70420d1ba665SWarner Losh 70430d1ba665SWarner Losh If Buffer is NULL, then ASSERT(). 70440d1ba665SWarner Losh If Buffer is not aligned on a 16-byte boundary, then ASSERT(). 70450d1ba665SWarner Losh If Buffer was not saved with AsmFxSave(), then ASSERT(). 70460d1ba665SWarner Losh 70470d1ba665SWarner Losh @param Buffer The pointer to a buffer to save the floating point/SSE/SSE2 context. 70480d1ba665SWarner Losh 70490d1ba665SWarner Losh **/ 70500d1ba665SWarner Losh VOID 70510d1ba665SWarner Losh EFIAPI 70520d1ba665SWarner Losh AsmFxRestore ( 70530d1ba665SWarner Losh IN CONST IA32_FX_BUFFER *Buffer 70540d1ba665SWarner Losh ); 70550d1ba665SWarner Losh 70560d1ba665SWarner Losh 70570d1ba665SWarner Losh /** 70580d1ba665SWarner Losh Reads the current value of 64-bit MMX Register #0 (MM0). 70590d1ba665SWarner Losh 70600d1ba665SWarner Losh Reads and returns the current value of MM0. This function is only available 70610d1ba665SWarner Losh on IA-32 and x64. 70620d1ba665SWarner Losh 70630d1ba665SWarner Losh @return The current value of MM0. 70640d1ba665SWarner Losh 70650d1ba665SWarner Losh **/ 70660d1ba665SWarner Losh UINT64 70670d1ba665SWarner Losh EFIAPI 70680d1ba665SWarner Losh AsmReadMm0 ( 70690d1ba665SWarner Losh VOID 70700d1ba665SWarner Losh ); 70710d1ba665SWarner Losh 70720d1ba665SWarner Losh 70730d1ba665SWarner Losh /** 70740d1ba665SWarner Losh Reads the current value of 64-bit MMX Register #1 (MM1). 70750d1ba665SWarner Losh 70760d1ba665SWarner Losh Reads and returns the current value of MM1. This function is only available 70770d1ba665SWarner Losh on IA-32 and x64. 70780d1ba665SWarner Losh 70790d1ba665SWarner Losh @return The current value of MM1. 70800d1ba665SWarner Losh 70810d1ba665SWarner Losh **/ 70820d1ba665SWarner Losh UINT64 70830d1ba665SWarner Losh EFIAPI 70840d1ba665SWarner Losh AsmReadMm1 ( 70850d1ba665SWarner Losh VOID 70860d1ba665SWarner Losh ); 70870d1ba665SWarner Losh 70880d1ba665SWarner Losh 70890d1ba665SWarner Losh /** 70900d1ba665SWarner Losh Reads the current value of 64-bit MMX Register #2 (MM2). 70910d1ba665SWarner Losh 70920d1ba665SWarner Losh Reads and returns the current value of MM2. This function is only available 70930d1ba665SWarner Losh on IA-32 and x64. 70940d1ba665SWarner Losh 70950d1ba665SWarner Losh @return The current value of MM2. 70960d1ba665SWarner Losh 70970d1ba665SWarner Losh **/ 70980d1ba665SWarner Losh UINT64 70990d1ba665SWarner Losh EFIAPI 71000d1ba665SWarner Losh AsmReadMm2 ( 71010d1ba665SWarner Losh VOID 71020d1ba665SWarner Losh ); 71030d1ba665SWarner Losh 71040d1ba665SWarner Losh 71050d1ba665SWarner Losh /** 71060d1ba665SWarner Losh Reads the current value of 64-bit MMX Register #3 (MM3). 71070d1ba665SWarner Losh 71080d1ba665SWarner Losh Reads and returns the current value of MM3. This function is only available 71090d1ba665SWarner Losh on IA-32 and x64. 71100d1ba665SWarner Losh 71110d1ba665SWarner Losh @return The current value of MM3. 71120d1ba665SWarner Losh 71130d1ba665SWarner Losh **/ 71140d1ba665SWarner Losh UINT64 71150d1ba665SWarner Losh EFIAPI 71160d1ba665SWarner Losh AsmReadMm3 ( 71170d1ba665SWarner Losh VOID 71180d1ba665SWarner Losh ); 71190d1ba665SWarner Losh 71200d1ba665SWarner Losh 71210d1ba665SWarner Losh /** 71220d1ba665SWarner Losh Reads the current value of 64-bit MMX Register #4 (MM4). 71230d1ba665SWarner Losh 71240d1ba665SWarner Losh Reads and returns the current value of MM4. This function is only available 71250d1ba665SWarner Losh on IA-32 and x64. 71260d1ba665SWarner Losh 71270d1ba665SWarner Losh @return The current value of MM4. 71280d1ba665SWarner Losh 71290d1ba665SWarner Losh **/ 71300d1ba665SWarner Losh UINT64 71310d1ba665SWarner Losh EFIAPI 71320d1ba665SWarner Losh AsmReadMm4 ( 71330d1ba665SWarner Losh VOID 71340d1ba665SWarner Losh ); 71350d1ba665SWarner Losh 71360d1ba665SWarner Losh 71370d1ba665SWarner Losh /** 71380d1ba665SWarner Losh Reads the current value of 64-bit MMX Register #5 (MM5). 71390d1ba665SWarner Losh 71400d1ba665SWarner Losh Reads and returns the current value of MM5. This function is only available 71410d1ba665SWarner Losh on IA-32 and x64. 71420d1ba665SWarner Losh 71430d1ba665SWarner Losh @return The current value of MM5. 71440d1ba665SWarner Losh 71450d1ba665SWarner Losh **/ 71460d1ba665SWarner Losh UINT64 71470d1ba665SWarner Losh EFIAPI 71480d1ba665SWarner Losh AsmReadMm5 ( 71490d1ba665SWarner Losh VOID 71500d1ba665SWarner Losh ); 71510d1ba665SWarner Losh 71520d1ba665SWarner Losh 71530d1ba665SWarner Losh /** 71540d1ba665SWarner Losh Reads the current value of 64-bit MMX Register #6 (MM6). 71550d1ba665SWarner Losh 71560d1ba665SWarner Losh Reads and returns the current value of MM6. This function is only available 71570d1ba665SWarner Losh on IA-32 and x64. 71580d1ba665SWarner Losh 71590d1ba665SWarner Losh @return The current value of MM6. 71600d1ba665SWarner Losh 71610d1ba665SWarner Losh **/ 71620d1ba665SWarner Losh UINT64 71630d1ba665SWarner Losh EFIAPI 71640d1ba665SWarner Losh AsmReadMm6 ( 71650d1ba665SWarner Losh VOID 71660d1ba665SWarner Losh ); 71670d1ba665SWarner Losh 71680d1ba665SWarner Losh 71690d1ba665SWarner Losh /** 71700d1ba665SWarner Losh Reads the current value of 64-bit MMX Register #7 (MM7). 71710d1ba665SWarner Losh 71720d1ba665SWarner Losh Reads and returns the current value of MM7. This function is only available 71730d1ba665SWarner Losh on IA-32 and x64. 71740d1ba665SWarner Losh 71750d1ba665SWarner Losh @return The current value of MM7. 71760d1ba665SWarner Losh 71770d1ba665SWarner Losh **/ 71780d1ba665SWarner Losh UINT64 71790d1ba665SWarner Losh EFIAPI 71800d1ba665SWarner Losh AsmReadMm7 ( 71810d1ba665SWarner Losh VOID 71820d1ba665SWarner Losh ); 71830d1ba665SWarner Losh 71840d1ba665SWarner Losh 71850d1ba665SWarner Losh /** 71860d1ba665SWarner Losh Writes the current value of 64-bit MMX Register #0 (MM0). 71870d1ba665SWarner Losh 71880d1ba665SWarner Losh Writes the current value of MM0. This function is only available on IA32 and 71890d1ba665SWarner Losh x64. 71900d1ba665SWarner Losh 71910d1ba665SWarner Losh @param Value The 64-bit value to write to MM0. 71920d1ba665SWarner Losh 71930d1ba665SWarner Losh **/ 71940d1ba665SWarner Losh VOID 71950d1ba665SWarner Losh EFIAPI 71960d1ba665SWarner Losh AsmWriteMm0 ( 71970d1ba665SWarner Losh IN UINT64 Value 71980d1ba665SWarner Losh ); 71990d1ba665SWarner Losh 72000d1ba665SWarner Losh 72010d1ba665SWarner Losh /** 72020d1ba665SWarner Losh Writes the current value of 64-bit MMX Register #1 (MM1). 72030d1ba665SWarner Losh 72040d1ba665SWarner Losh Writes the current value of MM1. This function is only available on IA32 and 72050d1ba665SWarner Losh x64. 72060d1ba665SWarner Losh 72070d1ba665SWarner Losh @param Value The 64-bit value to write to MM1. 72080d1ba665SWarner Losh 72090d1ba665SWarner Losh **/ 72100d1ba665SWarner Losh VOID 72110d1ba665SWarner Losh EFIAPI 72120d1ba665SWarner Losh AsmWriteMm1 ( 72130d1ba665SWarner Losh IN UINT64 Value 72140d1ba665SWarner Losh ); 72150d1ba665SWarner Losh 72160d1ba665SWarner Losh 72170d1ba665SWarner Losh /** 72180d1ba665SWarner Losh Writes the current value of 64-bit MMX Register #2 (MM2). 72190d1ba665SWarner Losh 72200d1ba665SWarner Losh Writes the current value of MM2. This function is only available on IA32 and 72210d1ba665SWarner Losh x64. 72220d1ba665SWarner Losh 72230d1ba665SWarner Losh @param Value The 64-bit value to write to MM2. 72240d1ba665SWarner Losh 72250d1ba665SWarner Losh **/ 72260d1ba665SWarner Losh VOID 72270d1ba665SWarner Losh EFIAPI 72280d1ba665SWarner Losh AsmWriteMm2 ( 72290d1ba665SWarner Losh IN UINT64 Value 72300d1ba665SWarner Losh ); 72310d1ba665SWarner Losh 72320d1ba665SWarner Losh 72330d1ba665SWarner Losh /** 72340d1ba665SWarner Losh Writes the current value of 64-bit MMX Register #3 (MM3). 72350d1ba665SWarner Losh 72360d1ba665SWarner Losh Writes the current value of MM3. This function is only available on IA32 and 72370d1ba665SWarner Losh x64. 72380d1ba665SWarner Losh 72390d1ba665SWarner Losh @param Value The 64-bit value to write to MM3. 72400d1ba665SWarner Losh 72410d1ba665SWarner Losh **/ 72420d1ba665SWarner Losh VOID 72430d1ba665SWarner Losh EFIAPI 72440d1ba665SWarner Losh AsmWriteMm3 ( 72450d1ba665SWarner Losh IN UINT64 Value 72460d1ba665SWarner Losh ); 72470d1ba665SWarner Losh 72480d1ba665SWarner Losh 72490d1ba665SWarner Losh /** 72500d1ba665SWarner Losh Writes the current value of 64-bit MMX Register #4 (MM4). 72510d1ba665SWarner Losh 72520d1ba665SWarner Losh Writes the current value of MM4. This function is only available on IA32 and 72530d1ba665SWarner Losh x64. 72540d1ba665SWarner Losh 72550d1ba665SWarner Losh @param Value The 64-bit value to write to MM4. 72560d1ba665SWarner Losh 72570d1ba665SWarner Losh **/ 72580d1ba665SWarner Losh VOID 72590d1ba665SWarner Losh EFIAPI 72600d1ba665SWarner Losh AsmWriteMm4 ( 72610d1ba665SWarner Losh IN UINT64 Value 72620d1ba665SWarner Losh ); 72630d1ba665SWarner Losh 72640d1ba665SWarner Losh 72650d1ba665SWarner Losh /** 72660d1ba665SWarner Losh Writes the current value of 64-bit MMX Register #5 (MM5). 72670d1ba665SWarner Losh 72680d1ba665SWarner Losh Writes the current value of MM5. This function is only available on IA32 and 72690d1ba665SWarner Losh x64. 72700d1ba665SWarner Losh 72710d1ba665SWarner Losh @param Value The 64-bit value to write to MM5. 72720d1ba665SWarner Losh 72730d1ba665SWarner Losh **/ 72740d1ba665SWarner Losh VOID 72750d1ba665SWarner Losh EFIAPI 72760d1ba665SWarner Losh AsmWriteMm5 ( 72770d1ba665SWarner Losh IN UINT64 Value 72780d1ba665SWarner Losh ); 72790d1ba665SWarner Losh 72800d1ba665SWarner Losh 72810d1ba665SWarner Losh /** 72820d1ba665SWarner Losh Writes the current value of 64-bit MMX Register #6 (MM6). 72830d1ba665SWarner Losh 72840d1ba665SWarner Losh Writes the current value of MM6. This function is only available on IA32 and 72850d1ba665SWarner Losh x64. 72860d1ba665SWarner Losh 72870d1ba665SWarner Losh @param Value The 64-bit value to write to MM6. 72880d1ba665SWarner Losh 72890d1ba665SWarner Losh **/ 72900d1ba665SWarner Losh VOID 72910d1ba665SWarner Losh EFIAPI 72920d1ba665SWarner Losh AsmWriteMm6 ( 72930d1ba665SWarner Losh IN UINT64 Value 72940d1ba665SWarner Losh ); 72950d1ba665SWarner Losh 72960d1ba665SWarner Losh 72970d1ba665SWarner Losh /** 72980d1ba665SWarner Losh Writes the current value of 64-bit MMX Register #7 (MM7). 72990d1ba665SWarner Losh 73000d1ba665SWarner Losh Writes the current value of MM7. This function is only available on IA32 and 73010d1ba665SWarner Losh x64. 73020d1ba665SWarner Losh 73030d1ba665SWarner Losh @param Value The 64-bit value to write to MM7. 73040d1ba665SWarner Losh 73050d1ba665SWarner Losh **/ 73060d1ba665SWarner Losh VOID 73070d1ba665SWarner Losh EFIAPI 73080d1ba665SWarner Losh AsmWriteMm7 ( 73090d1ba665SWarner Losh IN UINT64 Value 73100d1ba665SWarner Losh ); 73110d1ba665SWarner Losh 73120d1ba665SWarner Losh 73130d1ba665SWarner Losh /** 73140d1ba665SWarner Losh Reads the current value of Time Stamp Counter (TSC). 73150d1ba665SWarner Losh 73160d1ba665SWarner Losh Reads and returns the current value of TSC. This function is only available 73170d1ba665SWarner Losh on IA-32 and x64. 73180d1ba665SWarner Losh 73190d1ba665SWarner Losh @return The current value of TSC 73200d1ba665SWarner Losh 73210d1ba665SWarner Losh **/ 73220d1ba665SWarner Losh UINT64 73230d1ba665SWarner Losh EFIAPI 73240d1ba665SWarner Losh AsmReadTsc ( 73250d1ba665SWarner Losh VOID 73260d1ba665SWarner Losh ); 73270d1ba665SWarner Losh 73280d1ba665SWarner Losh 73290d1ba665SWarner Losh /** 73300d1ba665SWarner Losh Reads the current value of a Performance Counter (PMC). 73310d1ba665SWarner Losh 73320d1ba665SWarner Losh Reads and returns the current value of performance counter specified by 73330d1ba665SWarner Losh Index. This function is only available on IA-32 and x64. 73340d1ba665SWarner Losh 73350d1ba665SWarner Losh @param Index The 32-bit Performance Counter index to read. 73360d1ba665SWarner Losh 73370d1ba665SWarner Losh @return The value of the PMC specified by Index. 73380d1ba665SWarner Losh 73390d1ba665SWarner Losh **/ 73400d1ba665SWarner Losh UINT64 73410d1ba665SWarner Losh EFIAPI 73420d1ba665SWarner Losh AsmReadPmc ( 73430d1ba665SWarner Losh IN UINT32 Index 73440d1ba665SWarner Losh ); 73450d1ba665SWarner Losh 73460d1ba665SWarner Losh 73470d1ba665SWarner Losh /** 73480d1ba665SWarner Losh Sets up a monitor buffer that is used by AsmMwait(). 73490d1ba665SWarner Losh 73500d1ba665SWarner Losh Executes a MONITOR instruction with the register state specified by Eax, Ecx 73510d1ba665SWarner Losh and Edx. Returns Eax. This function is only available on IA-32 and x64. 73520d1ba665SWarner Losh 73530d1ba665SWarner Losh @param Eax The value to load into EAX or RAX before executing the MONITOR 73540d1ba665SWarner Losh instruction. 73550d1ba665SWarner Losh @param Ecx The value to load into ECX or RCX before executing the MONITOR 73560d1ba665SWarner Losh instruction. 73570d1ba665SWarner Losh @param Edx The value to load into EDX or RDX before executing the MONITOR 73580d1ba665SWarner Losh instruction. 73590d1ba665SWarner Losh 73600d1ba665SWarner Losh @return Eax 73610d1ba665SWarner Losh 73620d1ba665SWarner Losh **/ 73630d1ba665SWarner Losh UINTN 73640d1ba665SWarner Losh EFIAPI 73650d1ba665SWarner Losh AsmMonitor ( 73660d1ba665SWarner Losh IN UINTN Eax, 73670d1ba665SWarner Losh IN UINTN Ecx, 73680d1ba665SWarner Losh IN UINTN Edx 73690d1ba665SWarner Losh ); 73700d1ba665SWarner Losh 73710d1ba665SWarner Losh 73720d1ba665SWarner Losh /** 73730d1ba665SWarner Losh Executes an MWAIT instruction. 73740d1ba665SWarner Losh 73750d1ba665SWarner Losh Executes an MWAIT instruction with the register state specified by Eax and 73760d1ba665SWarner Losh Ecx. Returns Eax. This function is only available on IA-32 and x64. 73770d1ba665SWarner Losh 73780d1ba665SWarner Losh @param Eax The value to load into EAX or RAX before executing the MONITOR 73790d1ba665SWarner Losh instruction. 73800d1ba665SWarner Losh @param Ecx The value to load into ECX or RCX before executing the MONITOR 73810d1ba665SWarner Losh instruction. 73820d1ba665SWarner Losh 73830d1ba665SWarner Losh @return Eax 73840d1ba665SWarner Losh 73850d1ba665SWarner Losh **/ 73860d1ba665SWarner Losh UINTN 73870d1ba665SWarner Losh EFIAPI 73880d1ba665SWarner Losh AsmMwait ( 73890d1ba665SWarner Losh IN UINTN Eax, 73900d1ba665SWarner Losh IN UINTN Ecx 73910d1ba665SWarner Losh ); 73920d1ba665SWarner Losh 73930d1ba665SWarner Losh 73940d1ba665SWarner Losh /** 73950d1ba665SWarner Losh Executes a WBINVD instruction. 73960d1ba665SWarner Losh 73970d1ba665SWarner Losh Executes a WBINVD instruction. This function is only available on IA-32 and 73980d1ba665SWarner Losh x64. 73990d1ba665SWarner Losh 74000d1ba665SWarner Losh **/ 74010d1ba665SWarner Losh VOID 74020d1ba665SWarner Losh EFIAPI 74030d1ba665SWarner Losh AsmWbinvd ( 74040d1ba665SWarner Losh VOID 74050d1ba665SWarner Losh ); 74060d1ba665SWarner Losh 74070d1ba665SWarner Losh 74080d1ba665SWarner Losh /** 74090d1ba665SWarner Losh Executes a INVD instruction. 74100d1ba665SWarner Losh 74110d1ba665SWarner Losh Executes a INVD instruction. This function is only available on IA-32 and 74120d1ba665SWarner Losh x64. 74130d1ba665SWarner Losh 74140d1ba665SWarner Losh **/ 74150d1ba665SWarner Losh VOID 74160d1ba665SWarner Losh EFIAPI 74170d1ba665SWarner Losh AsmInvd ( 74180d1ba665SWarner Losh VOID 74190d1ba665SWarner Losh ); 74200d1ba665SWarner Losh 74210d1ba665SWarner Losh 74220d1ba665SWarner Losh /** 74230d1ba665SWarner Losh Flushes a cache line from all the instruction and data caches within the 74240d1ba665SWarner Losh coherency domain of the CPU. 74250d1ba665SWarner Losh 74260d1ba665SWarner Losh Flushed the cache line specified by LinearAddress, and returns LinearAddress. 74270d1ba665SWarner Losh This function is only available on IA-32 and x64. 74280d1ba665SWarner Losh 74290d1ba665SWarner Losh @param LinearAddress The address of the cache line to flush. If the CPU is 74300d1ba665SWarner Losh in a physical addressing mode, then LinearAddress is a 74310d1ba665SWarner Losh physical address. If the CPU is in a virtual 74320d1ba665SWarner Losh addressing mode, then LinearAddress is a virtual 74330d1ba665SWarner Losh address. 74340d1ba665SWarner Losh 74350d1ba665SWarner Losh @return LinearAddress. 74360d1ba665SWarner Losh **/ 74370d1ba665SWarner Losh VOID * 74380d1ba665SWarner Losh EFIAPI 74390d1ba665SWarner Losh AsmFlushCacheLine ( 74400d1ba665SWarner Losh IN VOID *LinearAddress 74410d1ba665SWarner Losh ); 74420d1ba665SWarner Losh 74430d1ba665SWarner Losh 74440d1ba665SWarner Losh /** 74450d1ba665SWarner Losh Enables the 32-bit paging mode on the CPU. 74460d1ba665SWarner Losh 74470d1ba665SWarner Losh Enables the 32-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables 74480d1ba665SWarner Losh must be properly initialized prior to calling this service. This function 74490d1ba665SWarner Losh assumes the current execution mode is 32-bit protected mode. This function is 74500d1ba665SWarner Losh only available on IA-32. After the 32-bit paging mode is enabled, control is 74510d1ba665SWarner Losh transferred to the function specified by EntryPoint using the new stack 74520d1ba665SWarner Losh specified by NewStack and passing in the parameters specified by Context1 and 74530d1ba665SWarner Losh Context2. Context1 and Context2 are optional and may be NULL. The function 74540d1ba665SWarner Losh EntryPoint must never return. 74550d1ba665SWarner Losh 74560d1ba665SWarner Losh If the current execution mode is not 32-bit protected mode, then ASSERT(). 74570d1ba665SWarner Losh If EntryPoint is NULL, then ASSERT(). 74580d1ba665SWarner Losh If NewStack is NULL, then ASSERT(). 74590d1ba665SWarner Losh 74600d1ba665SWarner Losh There are a number of constraints that must be followed before calling this 74610d1ba665SWarner Losh function: 74620d1ba665SWarner Losh 1) Interrupts must be disabled. 74630d1ba665SWarner Losh 2) The caller must be in 32-bit protected mode with flat descriptors. This 74640d1ba665SWarner Losh means all descriptors must have a base of 0 and a limit of 4GB. 74650d1ba665SWarner Losh 3) CR0 and CR4 must be compatible with 32-bit protected mode with flat 74660d1ba665SWarner Losh descriptors. 74670d1ba665SWarner Losh 4) CR3 must point to valid page tables that will be used once the transition 74680d1ba665SWarner Losh is complete, and those page tables must guarantee that the pages for this 74690d1ba665SWarner Losh function and the stack are identity mapped. 74700d1ba665SWarner Losh 74710d1ba665SWarner Losh @param EntryPoint A pointer to function to call with the new stack after 74720d1ba665SWarner Losh paging is enabled. 74730d1ba665SWarner Losh @param Context1 A pointer to the context to pass into the EntryPoint 74740d1ba665SWarner Losh function as the first parameter after paging is enabled. 74750d1ba665SWarner Losh @param Context2 A pointer to the context to pass into the EntryPoint 74760d1ba665SWarner Losh function as the second parameter after paging is enabled. 74770d1ba665SWarner Losh @param NewStack A pointer to the new stack to use for the EntryPoint 74780d1ba665SWarner Losh function after paging is enabled. 74790d1ba665SWarner Losh 74800d1ba665SWarner Losh **/ 74810d1ba665SWarner Losh VOID 74820d1ba665SWarner Losh EFIAPI 74830d1ba665SWarner Losh AsmEnablePaging32 ( 74840d1ba665SWarner Losh IN SWITCH_STACK_ENTRY_POINT EntryPoint, 74850d1ba665SWarner Losh IN VOID *Context1, OPTIONAL 74860d1ba665SWarner Losh IN VOID *Context2, OPTIONAL 74870d1ba665SWarner Losh IN VOID *NewStack 74880d1ba665SWarner Losh ); 74890d1ba665SWarner Losh 74900d1ba665SWarner Losh 74910d1ba665SWarner Losh /** 74920d1ba665SWarner Losh Disables the 32-bit paging mode on the CPU. 74930d1ba665SWarner Losh 74940d1ba665SWarner Losh Disables the 32-bit paging mode on the CPU and returns to 32-bit protected 74950d1ba665SWarner Losh mode. This function assumes the current execution mode is 32-paged protected 74960d1ba665SWarner Losh mode. This function is only available on IA-32. After the 32-bit paging mode 74970d1ba665SWarner Losh is disabled, control is transferred to the function specified by EntryPoint 74980d1ba665SWarner Losh using the new stack specified by NewStack and passing in the parameters 74990d1ba665SWarner Losh specified by Context1 and Context2. Context1 and Context2 are optional and 75000d1ba665SWarner Losh may be NULL. The function EntryPoint must never return. 75010d1ba665SWarner Losh 75020d1ba665SWarner Losh If the current execution mode is not 32-bit paged mode, then ASSERT(). 75030d1ba665SWarner Losh If EntryPoint is NULL, then ASSERT(). 75040d1ba665SWarner Losh If NewStack is NULL, then ASSERT(). 75050d1ba665SWarner Losh 75060d1ba665SWarner Losh There are a number of constraints that must be followed before calling this 75070d1ba665SWarner Losh function: 75080d1ba665SWarner Losh 1) Interrupts must be disabled. 75090d1ba665SWarner Losh 2) The caller must be in 32-bit paged mode. 75100d1ba665SWarner Losh 3) CR0, CR3, and CR4 must be compatible with 32-bit paged mode. 75110d1ba665SWarner Losh 4) CR3 must point to valid page tables that guarantee that the pages for 75120d1ba665SWarner Losh this function and the stack are identity mapped. 75130d1ba665SWarner Losh 75140d1ba665SWarner Losh @param EntryPoint A pointer to function to call with the new stack after 75150d1ba665SWarner Losh paging is disabled. 75160d1ba665SWarner Losh @param Context1 A pointer to the context to pass into the EntryPoint 75170d1ba665SWarner Losh function as the first parameter after paging is disabled. 75180d1ba665SWarner Losh @param Context2 A pointer to the context to pass into the EntryPoint 75190d1ba665SWarner Losh function as the second parameter after paging is 75200d1ba665SWarner Losh disabled. 75210d1ba665SWarner Losh @param NewStack A pointer to the new stack to use for the EntryPoint 75220d1ba665SWarner Losh function after paging is disabled. 75230d1ba665SWarner Losh 75240d1ba665SWarner Losh **/ 75250d1ba665SWarner Losh VOID 75260d1ba665SWarner Losh EFIAPI 75270d1ba665SWarner Losh AsmDisablePaging32 ( 75280d1ba665SWarner Losh IN SWITCH_STACK_ENTRY_POINT EntryPoint, 75290d1ba665SWarner Losh IN VOID *Context1, OPTIONAL 75300d1ba665SWarner Losh IN VOID *Context2, OPTIONAL 75310d1ba665SWarner Losh IN VOID *NewStack 75320d1ba665SWarner Losh ); 75330d1ba665SWarner Losh 75340d1ba665SWarner Losh 75350d1ba665SWarner Losh /** 75360d1ba665SWarner Losh Enables the 64-bit paging mode on the CPU. 75370d1ba665SWarner Losh 75380d1ba665SWarner Losh Enables the 64-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables 75390d1ba665SWarner Losh must be properly initialized prior to calling this service. This function 75400d1ba665SWarner Losh assumes the current execution mode is 32-bit protected mode with flat 75410d1ba665SWarner Losh descriptors. This function is only available on IA-32. After the 64-bit 75420d1ba665SWarner Losh paging mode is enabled, control is transferred to the function specified by 75430d1ba665SWarner Losh EntryPoint using the new stack specified by NewStack and passing in the 75440d1ba665SWarner Losh parameters specified by Context1 and Context2. Context1 and Context2 are 75450d1ba665SWarner Losh optional and may be 0. The function EntryPoint must never return. 75460d1ba665SWarner Losh 75470d1ba665SWarner Losh If the current execution mode is not 32-bit protected mode with flat 75480d1ba665SWarner Losh descriptors, then ASSERT(). 75490d1ba665SWarner Losh If EntryPoint is 0, then ASSERT(). 75500d1ba665SWarner Losh If NewStack is 0, then ASSERT(). 75510d1ba665SWarner Losh 75520d1ba665SWarner Losh @param Cs The 16-bit selector to load in the CS before EntryPoint 75530d1ba665SWarner Losh is called. The descriptor in the GDT that this selector 75540d1ba665SWarner Losh references must be setup for long mode. 75550d1ba665SWarner Losh @param EntryPoint The 64-bit virtual address of the function to call with 75560d1ba665SWarner Losh the new stack after paging is enabled. 75570d1ba665SWarner Losh @param Context1 The 64-bit virtual address of the context to pass into 75580d1ba665SWarner Losh the EntryPoint function as the first parameter after 75590d1ba665SWarner Losh paging is enabled. 75600d1ba665SWarner Losh @param Context2 The 64-bit virtual address of the context to pass into 75610d1ba665SWarner Losh the EntryPoint function as the second parameter after 75620d1ba665SWarner Losh paging is enabled. 75630d1ba665SWarner Losh @param NewStack The 64-bit virtual address of the new stack to use for 75640d1ba665SWarner Losh the EntryPoint function after paging is enabled. 75650d1ba665SWarner Losh 75660d1ba665SWarner Losh **/ 75670d1ba665SWarner Losh VOID 75680d1ba665SWarner Losh EFIAPI 75690d1ba665SWarner Losh AsmEnablePaging64 ( 75700d1ba665SWarner Losh IN UINT16 Cs, 75710d1ba665SWarner Losh IN UINT64 EntryPoint, 75720d1ba665SWarner Losh IN UINT64 Context1, OPTIONAL 75730d1ba665SWarner Losh IN UINT64 Context2, OPTIONAL 75740d1ba665SWarner Losh IN UINT64 NewStack 75750d1ba665SWarner Losh ); 75760d1ba665SWarner Losh 75770d1ba665SWarner Losh 75780d1ba665SWarner Losh /** 75790d1ba665SWarner Losh Disables the 64-bit paging mode on the CPU. 75800d1ba665SWarner Losh 75810d1ba665SWarner Losh Disables the 64-bit paging mode on the CPU and returns to 32-bit protected 75820d1ba665SWarner Losh mode. This function assumes the current execution mode is 64-paging mode. 75830d1ba665SWarner Losh This function is only available on x64. After the 64-bit paging mode is 75840d1ba665SWarner Losh disabled, control is transferred to the function specified by EntryPoint 75850d1ba665SWarner Losh using the new stack specified by NewStack and passing in the parameters 75860d1ba665SWarner Losh specified by Context1 and Context2. Context1 and Context2 are optional and 75870d1ba665SWarner Losh may be 0. The function EntryPoint must never return. 75880d1ba665SWarner Losh 75890d1ba665SWarner Losh If the current execution mode is not 64-bit paged mode, then ASSERT(). 75900d1ba665SWarner Losh If EntryPoint is 0, then ASSERT(). 75910d1ba665SWarner Losh If NewStack is 0, then ASSERT(). 75920d1ba665SWarner Losh 75930d1ba665SWarner Losh @param Cs The 16-bit selector to load in the CS before EntryPoint 75940d1ba665SWarner Losh is called. The descriptor in the GDT that this selector 75950d1ba665SWarner Losh references must be setup for 32-bit protected mode. 75960d1ba665SWarner Losh @param EntryPoint The 64-bit virtual address of the function to call with 75970d1ba665SWarner Losh the new stack after paging is disabled. 75980d1ba665SWarner Losh @param Context1 The 64-bit virtual address of the context to pass into 75990d1ba665SWarner Losh the EntryPoint function as the first parameter after 76000d1ba665SWarner Losh paging is disabled. 76010d1ba665SWarner Losh @param Context2 The 64-bit virtual address of the context to pass into 76020d1ba665SWarner Losh the EntryPoint function as the second parameter after 76030d1ba665SWarner Losh paging is disabled. 76040d1ba665SWarner Losh @param NewStack The 64-bit virtual address of the new stack to use for 76050d1ba665SWarner Losh the EntryPoint function after paging is disabled. 76060d1ba665SWarner Losh 76070d1ba665SWarner Losh **/ 76080d1ba665SWarner Losh VOID 76090d1ba665SWarner Losh EFIAPI 76100d1ba665SWarner Losh AsmDisablePaging64 ( 76110d1ba665SWarner Losh IN UINT16 Cs, 76120d1ba665SWarner Losh IN UINT32 EntryPoint, 76130d1ba665SWarner Losh IN UINT32 Context1, OPTIONAL 76140d1ba665SWarner Losh IN UINT32 Context2, OPTIONAL 76150d1ba665SWarner Losh IN UINT32 NewStack 76160d1ba665SWarner Losh ); 76170d1ba665SWarner Losh 76180d1ba665SWarner Losh 76190d1ba665SWarner Losh // 76200d1ba665SWarner Losh // 16-bit thunking services 76210d1ba665SWarner Losh // 76220d1ba665SWarner Losh 76230d1ba665SWarner Losh /** 76240d1ba665SWarner Losh Retrieves the properties for 16-bit thunk functions. 76250d1ba665SWarner Losh 76260d1ba665SWarner Losh Computes the size of the buffer and stack below 1MB required to use the 76270d1ba665SWarner Losh AsmPrepareThunk16(), AsmThunk16() and AsmPrepareAndThunk16() functions. This 76280d1ba665SWarner Losh buffer size is returned in RealModeBufferSize, and the stack size is returned 76290d1ba665SWarner Losh in ExtraStackSize. If parameters are passed to the 16-bit real mode code, 76300d1ba665SWarner Losh then the actual minimum stack size is ExtraStackSize plus the maximum number 76310d1ba665SWarner Losh of bytes that need to be passed to the 16-bit real mode code. 76320d1ba665SWarner Losh 76330d1ba665SWarner Losh If RealModeBufferSize is NULL, then ASSERT(). 76340d1ba665SWarner Losh If ExtraStackSize is NULL, then ASSERT(). 76350d1ba665SWarner Losh 76360d1ba665SWarner Losh @param RealModeBufferSize A pointer to the size of the buffer below 1MB 76370d1ba665SWarner Losh required to use the 16-bit thunk functions. 76380d1ba665SWarner Losh @param ExtraStackSize A pointer to the extra size of stack below 1MB 76390d1ba665SWarner Losh that the 16-bit thunk functions require for 76400d1ba665SWarner Losh temporary storage in the transition to and from 76410d1ba665SWarner Losh 16-bit real mode. 76420d1ba665SWarner Losh 76430d1ba665SWarner Losh **/ 76440d1ba665SWarner Losh VOID 76450d1ba665SWarner Losh EFIAPI 76460d1ba665SWarner Losh AsmGetThunk16Properties ( 76470d1ba665SWarner Losh OUT UINT32 *RealModeBufferSize, 76480d1ba665SWarner Losh OUT UINT32 *ExtraStackSize 76490d1ba665SWarner Losh ); 76500d1ba665SWarner Losh 76510d1ba665SWarner Losh 76520d1ba665SWarner Losh /** 76530d1ba665SWarner Losh Prepares all structures a code required to use AsmThunk16(). 76540d1ba665SWarner Losh 76550d1ba665SWarner Losh Prepares all structures and code required to use AsmThunk16(). 76560d1ba665SWarner Losh 76570d1ba665SWarner Losh This interface is limited to be used in either physical mode or virtual modes with paging enabled where the 76580d1ba665SWarner Losh virtual to physical mappings for ThunkContext.RealModeBuffer is mapped 1:1. 76590d1ba665SWarner Losh 76600d1ba665SWarner Losh If ThunkContext is NULL, then ASSERT(). 76610d1ba665SWarner Losh 76620d1ba665SWarner Losh @param ThunkContext A pointer to the context structure that describes the 76630d1ba665SWarner Losh 16-bit real mode code to call. 76640d1ba665SWarner Losh 76650d1ba665SWarner Losh **/ 76660d1ba665SWarner Losh VOID 76670d1ba665SWarner Losh EFIAPI 76680d1ba665SWarner Losh AsmPrepareThunk16 ( 76690d1ba665SWarner Losh IN OUT THUNK_CONTEXT *ThunkContext 76700d1ba665SWarner Losh ); 76710d1ba665SWarner Losh 76720d1ba665SWarner Losh 76730d1ba665SWarner Losh /** 76740d1ba665SWarner Losh Transfers control to a 16-bit real mode entry point and returns the results. 76750d1ba665SWarner Losh 76760d1ba665SWarner Losh Transfers control to a 16-bit real mode entry point and returns the results. 76770d1ba665SWarner Losh AsmPrepareThunk16() must be called with ThunkContext before this function is used. 76780d1ba665SWarner Losh This function must be called with interrupts disabled. 76790d1ba665SWarner Losh 76800d1ba665SWarner Losh The register state from the RealModeState field of ThunkContext is restored just prior 76810d1ba665SWarner Losh to calling the 16-bit real mode entry point. This includes the EFLAGS field of RealModeState, 76820d1ba665SWarner Losh which is used to set the interrupt state when a 16-bit real mode entry point is called. 76830d1ba665SWarner Losh Control is transferred to the 16-bit real mode entry point specified by the CS and Eip fields of RealModeState. 76840d1ba665SWarner Losh The stack is initialized to the SS and ESP fields of RealModeState. Any parameters passed to 76850d1ba665SWarner Losh the 16-bit real mode code must be populated by the caller at SS:ESP prior to calling this function. 76860d1ba665SWarner Losh The 16-bit real mode entry point is invoked with a 16-bit CALL FAR instruction, 76870d1ba665SWarner Losh so when accessing stack contents, the 16-bit real mode code must account for the 16-bit segment 76880d1ba665SWarner Losh and 16-bit offset of the return address that were pushed onto the stack. The 16-bit real mode entry 76890d1ba665SWarner Losh point must exit with a RETF instruction. The register state is captured into RealModeState immediately 76900d1ba665SWarner Losh after the RETF instruction is executed. 76910d1ba665SWarner Losh 76920d1ba665SWarner Losh If EFLAGS specifies interrupts enabled, or any of the 16-bit real mode code enables interrupts, 76930d1ba665SWarner Losh or any of the 16-bit real mode code makes a SW interrupt, then the caller is responsible for making sure 76940d1ba665SWarner Losh the IDT at address 0 is initialized to handle any HW or SW interrupts that may occur while in 16-bit real mode. 76950d1ba665SWarner Losh 76960d1ba665SWarner Losh If EFLAGS specifies interrupts enabled, or any of the 16-bit real mode code enables interrupts, 76970d1ba665SWarner Losh then the caller is responsible for making sure the 8259 PIC is in a state compatible with 16-bit real mode. 76980d1ba665SWarner Losh This includes the base vectors, the interrupt masks, and the edge/level trigger mode. 76990d1ba665SWarner Losh 77000d1ba665SWarner Losh If THUNK_ATTRIBUTE_BIG_REAL_MODE is set in the ThunkAttributes field of ThunkContext, then the user code 77010d1ba665SWarner Losh is invoked in big real mode. Otherwise, the user code is invoked in 16-bit real mode with 64KB segment limits. 77020d1ba665SWarner Losh 77030d1ba665SWarner Losh If neither THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 nor THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL are set in 77040d1ba665SWarner Losh ThunkAttributes, then it is assumed that the user code did not enable the A20 mask, and no attempt is made to 77050d1ba665SWarner Losh disable the A20 mask. 77060d1ba665SWarner Losh 77070d1ba665SWarner Losh If THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 is set and THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL is clear in 77080d1ba665SWarner Losh ThunkAttributes, then attempt to use the INT 15 service to disable the A20 mask. If this INT 15 call fails, 77090d1ba665SWarner Losh then attempt to disable the A20 mask by directly accessing the 8042 keyboard controller I/O ports. 77100d1ba665SWarner Losh 77110d1ba665SWarner Losh If THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 is clear and THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL is set in 77120d1ba665SWarner Losh ThunkAttributes, then attempt to disable the A20 mask by directly accessing the 8042 keyboard controller I/O ports. 77130d1ba665SWarner Losh 77140d1ba665SWarner Losh If ThunkContext is NULL, then ASSERT(). 77150d1ba665SWarner Losh If AsmPrepareThunk16() was not previously called with ThunkContext, then ASSERT(). 77160d1ba665SWarner Losh If both THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 and THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL are set in 77170d1ba665SWarner Losh ThunkAttributes, then ASSERT(). 77180d1ba665SWarner Losh 77190d1ba665SWarner Losh This interface is limited to be used in either physical mode or virtual modes with paging enabled where the 77200d1ba665SWarner Losh virtual to physical mappings for ThunkContext.RealModeBuffer are mapped 1:1. 77210d1ba665SWarner Losh 77220d1ba665SWarner Losh @param ThunkContext A pointer to the context structure that describes the 77230d1ba665SWarner Losh 16-bit real mode code to call. 77240d1ba665SWarner Losh 77250d1ba665SWarner Losh **/ 77260d1ba665SWarner Losh VOID 77270d1ba665SWarner Losh EFIAPI 77280d1ba665SWarner Losh AsmThunk16 ( 77290d1ba665SWarner Losh IN OUT THUNK_CONTEXT *ThunkContext 77300d1ba665SWarner Losh ); 77310d1ba665SWarner Losh 77320d1ba665SWarner Losh 77330d1ba665SWarner Losh /** 77340d1ba665SWarner Losh Prepares all structures and code for a 16-bit real mode thunk, transfers 77350d1ba665SWarner Losh control to a 16-bit real mode entry point, and returns the results. 77360d1ba665SWarner Losh 77370d1ba665SWarner Losh Prepares all structures and code for a 16-bit real mode thunk, transfers 77380d1ba665SWarner Losh control to a 16-bit real mode entry point, and returns the results. If the 77390d1ba665SWarner Losh caller only need to perform a single 16-bit real mode thunk, then this 77400d1ba665SWarner Losh service should be used. If the caller intends to make more than one 16-bit 77410d1ba665SWarner Losh real mode thunk, then it is more efficient if AsmPrepareThunk16() is called 77420d1ba665SWarner Losh once and AsmThunk16() can be called for each 16-bit real mode thunk. 77430d1ba665SWarner Losh 77440d1ba665SWarner Losh This interface is limited to be used in either physical mode or virtual modes with paging enabled where the 77450d1ba665SWarner Losh virtual to physical mappings for ThunkContext.RealModeBuffer is mapped 1:1. 77460d1ba665SWarner Losh 77470d1ba665SWarner Losh See AsmPrepareThunk16() and AsmThunk16() for the detailed description and ASSERT() conditions. 77480d1ba665SWarner Losh 77490d1ba665SWarner Losh @param ThunkContext A pointer to the context structure that describes the 77500d1ba665SWarner Losh 16-bit real mode code to call. 77510d1ba665SWarner Losh 77520d1ba665SWarner Losh **/ 77530d1ba665SWarner Losh VOID 77540d1ba665SWarner Losh EFIAPI 77550d1ba665SWarner Losh AsmPrepareAndThunk16 ( 77560d1ba665SWarner Losh IN OUT THUNK_CONTEXT *ThunkContext 77570d1ba665SWarner Losh ); 77580d1ba665SWarner Losh 77590d1ba665SWarner Losh /** 77600d1ba665SWarner Losh Generates a 16-bit random number through RDRAND instruction. 77610d1ba665SWarner Losh 77620d1ba665SWarner Losh if Rand is NULL, then ASSERT(). 77630d1ba665SWarner Losh 77640d1ba665SWarner Losh @param[out] Rand Buffer pointer to store the random result. 77650d1ba665SWarner Losh 77660d1ba665SWarner Losh @retval TRUE RDRAND call was successful. 77670d1ba665SWarner Losh @retval FALSE Failed attempts to call RDRAND. 77680d1ba665SWarner Losh 77690d1ba665SWarner Losh **/ 77700d1ba665SWarner Losh BOOLEAN 77710d1ba665SWarner Losh EFIAPI 77720d1ba665SWarner Losh AsmRdRand16 ( 77730d1ba665SWarner Losh OUT UINT16 *Rand 77740d1ba665SWarner Losh ); 77750d1ba665SWarner Losh 77760d1ba665SWarner Losh /** 77770d1ba665SWarner Losh Generates a 32-bit random number through RDRAND instruction. 77780d1ba665SWarner Losh 77790d1ba665SWarner Losh if Rand is NULL, then ASSERT(). 77800d1ba665SWarner Losh 77810d1ba665SWarner Losh @param[out] Rand Buffer pointer to store the random result. 77820d1ba665SWarner Losh 77830d1ba665SWarner Losh @retval TRUE RDRAND call was successful. 77840d1ba665SWarner Losh @retval FALSE Failed attempts to call RDRAND. 77850d1ba665SWarner Losh 77860d1ba665SWarner Losh **/ 77870d1ba665SWarner Losh BOOLEAN 77880d1ba665SWarner Losh EFIAPI 77890d1ba665SWarner Losh AsmRdRand32 ( 77900d1ba665SWarner Losh OUT UINT32 *Rand 77910d1ba665SWarner Losh ); 77920d1ba665SWarner Losh 77930d1ba665SWarner Losh /** 77940d1ba665SWarner Losh Generates a 64-bit random number through RDRAND instruction. 77950d1ba665SWarner Losh 77960d1ba665SWarner Losh if Rand is NULL, then ASSERT(). 77970d1ba665SWarner Losh 77980d1ba665SWarner Losh @param[out] Rand Buffer pointer to store the random result. 77990d1ba665SWarner Losh 78000d1ba665SWarner Losh @retval TRUE RDRAND call was successful. 78010d1ba665SWarner Losh @retval FALSE Failed attempts to call RDRAND. 78020d1ba665SWarner Losh 78030d1ba665SWarner Losh **/ 78040d1ba665SWarner Losh BOOLEAN 78050d1ba665SWarner Losh EFIAPI 78060d1ba665SWarner Losh AsmRdRand64 ( 78070d1ba665SWarner Losh OUT UINT64 *Rand 78080d1ba665SWarner Losh ); 78090d1ba665SWarner Losh 7810*3245fa21SMitchell Horne /** 7811*3245fa21SMitchell Horne Load given selector into TR register. 78120d1ba665SWarner Losh 7813*3245fa21SMitchell Horne @param[in] Selector Task segment selector 7814*3245fa21SMitchell Horne **/ 7815*3245fa21SMitchell Horne VOID 7816*3245fa21SMitchell Horne EFIAPI 7817*3245fa21SMitchell Horne AsmWriteTr ( 7818*3245fa21SMitchell Horne IN UINT16 Selector 7819*3245fa21SMitchell Horne ); 78200d1ba665SWarner Losh 7821*3245fa21SMitchell Horne /** 7822*3245fa21SMitchell Horne Performs a serializing operation on all load-from-memory instructions that 7823*3245fa21SMitchell Horne were issued prior the AsmLfence function. 7824*3245fa21SMitchell Horne 7825*3245fa21SMitchell Horne Executes a LFENCE instruction. This function is only available on IA-32 and x64. 7826*3245fa21SMitchell Horne 7827*3245fa21SMitchell Horne **/ 7828*3245fa21SMitchell Horne VOID 7829*3245fa21SMitchell Horne EFIAPI 7830*3245fa21SMitchell Horne AsmLfence ( 7831*3245fa21SMitchell Horne VOID 7832*3245fa21SMitchell Horne ); 7833*3245fa21SMitchell Horne 7834*3245fa21SMitchell Horne /** 7835*3245fa21SMitchell Horne Patch the immediate operand of an IA32 or X64 instruction such that the byte, 7836*3245fa21SMitchell Horne word, dword or qword operand is encoded at the end of the instruction's 7837*3245fa21SMitchell Horne binary representation. 7838*3245fa21SMitchell Horne 7839*3245fa21SMitchell Horne This function should be used to update object code that was compiled with 7840*3245fa21SMitchell Horne NASM from assembly source code. Example: 7841*3245fa21SMitchell Horne 7842*3245fa21SMitchell Horne NASM source code: 7843*3245fa21SMitchell Horne 7844*3245fa21SMitchell Horne mov eax, strict dword 0 ; the imm32 zero operand will be patched 7845*3245fa21SMitchell Horne ASM_PFX(gPatchCr3): 7846*3245fa21SMitchell Horne mov cr3, eax 7847*3245fa21SMitchell Horne 7848*3245fa21SMitchell Horne C source code: 7849*3245fa21SMitchell Horne 7850*3245fa21SMitchell Horne X86_ASSEMBLY_PATCH_LABEL gPatchCr3; 7851*3245fa21SMitchell Horne PatchInstructionX86 (gPatchCr3, AsmReadCr3 (), 4); 7852*3245fa21SMitchell Horne 7853*3245fa21SMitchell Horne @param[out] InstructionEnd Pointer right past the instruction to patch. The 7854*3245fa21SMitchell Horne immediate operand to patch is expected to 7855*3245fa21SMitchell Horne comprise the trailing bytes of the instruction. 7856*3245fa21SMitchell Horne If InstructionEnd is closer to address 0 than 7857*3245fa21SMitchell Horne ValueSize permits, then ASSERT(). 7858*3245fa21SMitchell Horne 7859*3245fa21SMitchell Horne @param[in] PatchValue The constant to write to the immediate operand. 7860*3245fa21SMitchell Horne The caller is responsible for ensuring that 7861*3245fa21SMitchell Horne PatchValue can be represented in the byte, word, 7862*3245fa21SMitchell Horne dword or qword operand (as indicated through 7863*3245fa21SMitchell Horne ValueSize); otherwise ASSERT(). 7864*3245fa21SMitchell Horne 7865*3245fa21SMitchell Horne @param[in] ValueSize The size of the operand in bytes; must be 1, 2, 7866*3245fa21SMitchell Horne 4, or 8. ASSERT() otherwise. 7867*3245fa21SMitchell Horne **/ 7868*3245fa21SMitchell Horne VOID 7869*3245fa21SMitchell Horne EFIAPI 7870*3245fa21SMitchell Horne PatchInstructionX86 ( 7871*3245fa21SMitchell Horne OUT X86_ASSEMBLY_PATCH_LABEL *InstructionEnd, 7872*3245fa21SMitchell Horne IN UINT64 PatchValue, 7873*3245fa21SMitchell Horne IN UINTN ValueSize 7874*3245fa21SMitchell Horne ); 7875*3245fa21SMitchell Horne 7876*3245fa21SMitchell Horne #endif // defined (MDE_CPU_IA32) || defined (MDE_CPU_X64) 7877*3245fa21SMitchell Horne #endif // !defined (__BASE_LIB__) 7878