diff options
Diffstat (limited to 'EDK/Foundation/Library/Dxe/Include')
27 files changed, 11496 insertions, 0 deletions
diff --git a/EDK/Foundation/Library/Dxe/Include/Ebc/ProcDep.h b/EDK/Foundation/Library/Dxe/Include/Ebc/ProcDep.h new file mode 100644 index 0000000..7fd542b --- /dev/null +++ b/EDK/Foundation/Library/Dxe/Include/Ebc/ProcDep.h @@ -0,0 +1,26 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + ProcDep.h + +Abstract: + + EBC- specific runtime lib. Only used to get a clean build of + EFI libraries. + +--*/ + +#ifndef _PROC_DEP_H_ +#define _PROC_DEP_H_ + +#endif diff --git a/EDK/Foundation/Library/Dxe/Include/EfiCombinationLib.h b/EDK/Foundation/Library/Dxe/Include/EfiCombinationLib.h new file mode 100644 index 0000000..f091fdc --- /dev/null +++ b/EDK/Foundation/Library/Dxe/Include/EfiCombinationLib.h @@ -0,0 +1,294 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + EfiCombinationLib.h + +Abstract: + + Library functions that can be called in both PEI and DXE phase + +--*/ + +#ifndef _EFI_COMBINATION_LIB_H_ +#define _EFI_COMBINATION_LIB_H_ + +EFI_STATUS +EfiInitializeCommonDriverLib ( + IN EFI_HANDLE ImageHandle, + IN VOID *SystemTable + ) +/*++ + +Routine Description: + + Initialize lib function calling phase: PEI or DXE + +Arguments: + + ImageHandle - The firmware allocated handle for the EFI image. + + SystemTable - A pointer to the EFI System Table. + +Returns: + + EFI_STATUS always returns EFI_SUCCESS + +--*/ +; + +EFI_STATUS +EfiCommonIoRead ( + IN UINT8 Width, + IN UINTN Address, + IN UINTN Count, + IN OUT VOID *Buffer + ) +/*++ + +Routine Description: + + Io read operation. + +Arguments: + + Width - Width of read operation + Address - Start IO address to read + Count - Read count + Buffer - Buffer to store result + +Returns: + + Status code + +--*/ +; + +EFI_STATUS +EfiCommonIoWrite ( + IN UINT8 Width, + IN UINTN Address, + IN UINTN Count, + IN OUT VOID *Buffer + ) +/*++ + +Routine Description: + + Io write operation. + +Arguments: + + Width - Width of write operation + Address - Start IO address to write + Count - Write count + Buffer - Buffer to write to the address + +Returns: + + Status code + +--*/ +; + +EFI_STATUS +EfiCommonPciRead ( + IN UINT8 Width, + IN UINT64 Address, + IN UINTN Count, + IN OUT VOID *Buffer + ) +/*++ + +Routine Description: + + Pci read operation + +Arguments: + + Width - Width of PCI read + Address - PCI address to read + Count - Read count + Buffer - Output buffer for the read + +Returns: + + Status code + +--*/ +; + +EFI_STATUS +EfiCommonPciWrite ( + IN UINT8 Width, + IN UINT64 Address, + IN UINTN Count, + IN OUT VOID *Buffer + ) +/*++ + +Routine Description: + + Pci write operation + +Arguments: + + Width - Width of PCI write + Address - PCI address to write + Count - Write count + Buffer - Buffer to write to the address + +Returns: + + Status code + +--*/ +; + +EFI_STATUS +EfiCommonStall ( + IN UINTN Microseconds + ) +/*++ + +Routine Description: + + Induces a fine-grained stall. + +Arguments: + + Microseconds - The number of microseconds to stall execution. + +Returns: + + Status code + +--*/ +; + +EFI_STATUS +EfiCommonCopyMem ( + IN VOID *Destination, + IN VOID *Source, + IN UINTN Length + ) +/*++ + +Routine Description: + + Copy Length bytes from Source to Destination. + +Arguments: + + Destination - Target of copy + + Source - Place to copy from + + Length - Number of bytes to copy + +Returns: + + Status code + +--*/ +; + +EFI_STATUS +EfiCommonAllocatePages ( + IN EFI_ALLOCATE_TYPE Type, + IN EFI_MEMORY_TYPE MemoryType, + IN UINTN Pages, + IN OUT EFI_PHYSICAL_ADDRESS *Memory + ) +/*++ + +Routine Description: + + Allocates memory pages from the system. + +Arguments: + + Type - The type of allocation to perform. + MemoryType - The type of memory to allocate. + Pages - The number of contiguous pages to allocate. + Memory - Pointer to a physical address. + +Returns: + + EFI_OUT_OF_RESOURCES - The pages could not be allocated. + + EFI_INVALID_PARAMETER - Invalid parameter + + EFI_NOT_FOUND - The requested pages could not be found. + + EFI_SUCCESS - The requested pages were allocated. + +--*/ +; + +EFI_STATUS +EfiCommonLocateInterface ( + IN EFI_GUID *Guid, + OUT VOID **Interface + ) +/*++ + +Routine Description: + + Returns the first protocol instance that matches the given protocol. + +Arguments: + + Guid - Provides the protocol to search for. + Interface - On return, a pointer to the first interface that matches Protocol + +Returns: + + Status code + +--*/ +; + +EFI_STATUS +EfiCommonReportStatusCode ( + IN EFI_STATUS_CODE_TYPE CodeType, + IN EFI_STATUS_CODE_VALUE Value, + IN UINT32 Instance, + IN EFI_GUID * CallerId, + IN EFI_STATUS_CODE_DATA * Data OPTIONAL + ) +/*++ + +Routine Description: + + Status Code reporter + +Arguments: + + CodeType - Type of Status Code. + + Value - Value to output for Status Code. + + Instance - Instance Number of this status code. + + CallerId - ID of the caller of this status code. + + Data - Optional data associated with this status code. + +Returns: + + Status code + +--*/ +; + +#endif diff --git a/EDK/Foundation/Library/Dxe/Include/EfiCommonLib.h b/EDK/Foundation/Library/Dxe/Include/EfiCommonLib.h new file mode 100644 index 0000000..d499d2b --- /dev/null +++ b/EDK/Foundation/Library/Dxe/Include/EfiCommonLib.h @@ -0,0 +1,1359 @@ +/*++ + +Copyright (c) 2004 - 2007, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + EfiCommonLib.h + +Abstract: + + Light weight lib to support EFI drivers. + +--*/ + +#ifndef _EFI_COMMON_LIB_H_ +#define _EFI_COMMON_LIB_H_ + +EFI_STATUS +EfiLibGetSystemConfigurationTable ( + IN EFI_GUID *TableGuid, + IN OUT VOID **Table + ) +/*++ + +Routine Description: + + Return the EFI 1.0 System Tabl entry with TableGuid + +Arguments: + + TableGuid - Name of entry to return in the system table + Table - Pointer in EFI system table associated with TableGuid + +Returns: + + EFI_SUCCESS - Table returned; + EFI_NOT_FOUND - TableGuid not in EFI system table + +--*/ +; + +// +// ASPrint and AvSPrint definitions you must include the specific library +// to get the expected behavior from the two functions +// PEI: PeiLib +// Graphics: Dxe\Graphics\Unicode Dxe\Graphics\ASCII +// ASCII: Dxe\Print\ASCII +// Unicode: Dxe\Print\Unicode +// +UINTN +ASPrint ( + OUT CHAR8 *Buffer, + IN UINTN BufferSize, + IN CONST CHAR8 *Format, + ... + ) +/*++ + +Routine Description: + + Process format and place the results in Buffer for narrow chars. + +Arguments: + + Buffer - Narrow char buffer to print the results of the parsing of Format into. + BufferSize - Maximum number of characters to put into buffer. + Format - Format string + ... - Vararg list consumed by processing Format. + +Returns: + + Number of characters printed. + +--*/ +; + +UINTN +AvSPrint ( + OUT CHAR8 *StartOfBuffer, + IN UINTN StrSize, + IN CONST CHAR8 *Format, + IN VA_LIST Marker + ) +/*++ + +Routine Description: + + Internal implementation of ASPrint. + Process format and place the results in Buffer for narrow chars. + +Arguments: + + StartOfBuffer - Narrow char buffer to print the results of the parsing of Format into. + StrSize - Maximum number of characters to put into buffer. + FormatString - Format string + Marker - Vararg list consumed by processing Format. + +Returns: + + Number of characters printed. + +--*/ +; + +// +// Lib functions which can be used in both PEI and DXE pahse +// +EFI_STATUS +EfiInitializeCommonDriverLib ( + IN EFI_HANDLE ImageHandle, + IN VOID *SystemTable + ) +/*++ + +Routine Description: + + Initialize lib function calling phase: PEI or DXE + +Arguments: + + ImageHandle - The firmware allocated handle for the EFI image. + + SystemTable - A pointer to the EFI System Table. + +Returns: + + EFI_STATUS always returns EFI_SUCCESS + +--*/ +; + +EFI_STATUS +EfiCommonIoRead ( + IN UINT8 Width, + IN UINTN Address, + IN UINTN Count, + IN OUT VOID *Buffer + ) +/*++ + +Routine Description: + + Io read operation. + +Arguments: + + Width - Width of read operation + Address - Start IO address to read + Count - Read count + Buffer - Buffer to store result + +Returns: + + Status code + +--*/ +; + +EFI_STATUS +EfiCommonIoWrite ( + IN UINT8 Width, + IN UINTN Address, + IN UINTN Count, + IN OUT VOID *Buffer + ) +/*++ + +Routine Description: + + Io write operation. + +Arguments: + + Width - Width of write operation + Address - Start IO address to write + Count - Write count + Buffer - Buffer to write to the address + +Returns: + + Status code + +--*/ +; + +EFI_STATUS +EfiCommonPciRead ( + IN UINT8 Width, + IN UINT64 Address, + IN UINTN Count, + IN OUT VOID *Buffer + ) +/*++ + +Routine Description: + + Pci read operation + +Arguments: + + Width - Width of PCI read + Address - PCI address to read + Count - Read count + Buffer - Output buffer for the read + +Returns: + + Status code + +--*/ +; + +EFI_STATUS +EfiCommonPciWrite ( + IN UINT8 Width, + IN UINT64 Address, + IN UINTN Count, + IN OUT VOID *Buffer + ) +/*++ + +Routine Description: + + Pci write operation + +Arguments: + + Width - Width of PCI write + Address - PCI address to write + Count - Write count + Buffer - Buffer to write to the address + +Returns: + + Status code + +--*/ +; + +BOOLEAN +EfiCompareGuid ( + IN EFI_GUID *Guid1, + IN EFI_GUID *Guid2 + ) +/*++ + +Routine Description: + + Compares two GUIDs + +Arguments: + + Guid1 - guid to compare + + Guid2 - guid to compare + +Returns: + TRUE if Guid1 == Guid2 + FALSE if Guid1 != Guid2 + +--*/ +; + +VOID +EfiCommonLibSetMem ( + IN VOID *Buffer, + IN UINTN Size, + IN UINT8 Value + ) +/*++ + +Routine Description: + + Set Buffer to Value for Size bytes. + +Arguments: + + Buffer - Memory to set. + + Size - Number of bytes to set + + Value - Value of the set operation. + +Returns: + + None + +--*/ +; + +VOID +EfiCommonLibCopyMem ( + IN VOID *Destination, + IN VOID *Source, + IN UINTN Length + ) +/*++ + +Routine Description: + + Copy Length bytes from Source to Destination. + +Arguments: + + Destination - Target of copy + + Source - Place to copy from + + Length - Number of bytes to copy + +Returns: + + None + +--*/ +; + +INTN +EfiCompareMem ( + IN VOID *MemOne, + IN VOID *MemTwo, + IN UINTN Len + ) +/*++ + +Routine Description: + + Compares two memory buffers of a given length. + +Arguments: + + MemOne - First memory buffer + + MemTwo - Second memory buffer + + Len - Length of Mem1 and Mem2 memory regions to compare + +Returns: + + = 0 if MemOne == MemTwo + + > 0 if MemOne > MemTwo + + < 0 if MemOne < MemTwo + +--*/ +; + +VOID +EfiCommonLibZeroMem ( + IN VOID *Buffer, + IN UINTN Size + ) +/*++ + +Routine Description: + + Set Buffer to 0 for Size bytes. + +Arguments: + + Buffer - Memory to set. + + Size - Number of bytes to set + +Returns: + + None + +--*/ +; + +// +// Min Max +// +#define EFI_MIN(a, b) (((a) < (b)) ? (a) : (b)) +#define EFI_MAX(a, b) (((a) > (b)) ? (a) : (b)) + +// +// Align a pointer. The pointer represented by ptr is aligned to the bound. +// The resulting pointer is always equal or greater (by no more than bound-1) +// than the ptr. I.e., if the ptr is already aligned, the result will be equal to ptr. +// Valid values for bound are powers of two: 2, 4, 8, 16, 32 etc. +// The returned pointer is VOID* this assignment-compatible with all pointer types. +// +#define EFI_ALIGN(ptr, bound) ((VOID *) (((UINTN) (ptr) + ((UINTN) (bound) - 1)) &~((UINTN) (bound) - 1))) + +// +// Alignment tests. +// +#define EFI_UINTN_ALIGN_MASK (sizeof (UINTN) - 1) +#define EFI_UINTN_ALIGNED(ptr) (((UINTN) (ptr)) & EFI_UINTN_ALIGN_MASK) + +// +// Integer division with rounding to the nearest rather than truncating. +// For example 8/3=2 but EFI_IDIV_ROUND(8,3)=3. 1/3=0 and EFI_IDIV_ROUND(1,3)=0. +// A half is rounded up e.g., EFI_IDIV_ROUND(1,2)=1 but 1/2=0. +// +#define EFI_IDIV_ROUND(r, s) ((r) / (s) + (((2 * ((r) % (s))) < (s)) ? 0 : 1)) + +// +// ReportStatusCode.c init +// +VOID * +EfiConstructStatusCodeData ( + IN UINT16 DataSize, + IN EFI_GUID *TypeGuid, + IN OUT EFI_STATUS_CODE_DATA *Data + ) +/*++ + +Routine Description: + + Construct stanader header for optional data passed into ReportStatusCode + +Arguments: + + DataSize - Size of optional data. Does not include EFI_STATUS_CODE_DATA header + TypeGuid - GUID to place in EFI_STATUS_CODE_DATA + Data - Buffer to use. + +Returns: + + Return pointer to Data buffer pointing past the end of EFI_STATUS_CODE_DATA + +--*/ +; + +EFI_STATUS +EfiDebugVPrintWorker ( + IN UINTN ErrorLevel, + IN CHAR8 *Format, + IN VA_LIST Marker, + IN UINTN BufferSize, + IN OUT VOID *Buffer + ) +/*++ + +Routine Description: + + Worker function for DEBUG(). If Error Logging hub is loaded log ASSERT + information. If Error Logging hub is not loaded do nothing. + + We use UINT64 buffers due to IPF alignment concerns. + +Arguments: + + ErrorLevel - If error level is set do the debug print. + + Format - String to use for the print, followed by Print arguments. + + Marker - VarArgs + + BufferSize - Size of Buffer. + + Buffer - Caller allocated buffer, contains ReportStatusCode extended data + +Returns: + + Status code + +--*/ +; + +EFI_STATUS +EfiDebugAssertWorker ( + IN CHAR8 *FileName, + IN INTN LineNumber, + IN CHAR8 *Description, + IN UINTN BufferSize, + IN OUT VOID *Buffer + ) +/*++ + +Routine Description: + + Worker function for ASSERT (). If Error Logging hub is loaded log ASSERT + information. If Error Logging hub is not loaded DEADLOOP (). + + We use UINT64 buffers due to IPF alignment concerns. + +Arguments: + + FileName - File name of failing routine. + + LineNumber - Line number of failing ASSERT(). + + Description - Description, usually the assertion, + + BufferSize - Size of Buffer. + + Buffer - Caller allocated buffer, contains ReportStatusCode extendecd data + +Returns: + + Status code + +--*/ +; + +BOOLEAN +ReportStatusCodeExtractAssertInfo ( + IN EFI_STATUS_CODE_TYPE CodeType, + IN EFI_STATUS_CODE_VALUE Value, + IN EFI_STATUS_CODE_DATA *Data, + OUT CHAR8 **Filename, + OUT CHAR8 **Description, + OUT UINT32 *LineNumber + ) +/*++ + +Routine Description: + + Extract assert information from status code data. + +Arguments: + + CodeType - Code type + Value - Code value + Data - Optional data associated with this status code. + Filename - Filename extracted from Data + Description - Description extracted from Data + LineNumber - Line number extracted from Data + +Returns: + + TRUE - Successfully extracted + + FALSE - Extraction failed + +--*/ +; + +BOOLEAN +ReportStatusCodeExtractDebugInfo ( + IN EFI_STATUS_CODE_DATA *Data, + OUT UINT32 *ErrorLevel, + OUT VA_LIST *Marker, + OUT CHAR8 **Format + ) +/*++ + +Routine Description: + + Extract debug information from status code data. + +Arguments: + + Data - Optional data associated with status code. + ErrorLevel - Error level extracted from Data + Marker - VA_LIST extracted from Data + Format - Format string extracted from Data + +Returns: + + TRUE - Successfully extracted + + FALSE - Extraction failed + +--*/ +; + +BOOLEAN +CodeTypeToPostCode ( + IN EFI_STATUS_CODE_TYPE CodeType, + IN EFI_STATUS_CODE_VALUE Value, + OUT UINT8 *PostCode + ) +/*++ + +Routine Description: + + Convert code value to an 8 bit post code + +Arguments: + + CodeType - Code type + Value - Code value + PostCode - Post code as output + +Returns: + + TRUE - Successfully converted + + FALSE - Convertion failed + +--*/ +; + +// +// math.c +// +UINT64 +MultU64x32 ( + IN UINT64 Multiplicand, + IN UINTN Multiplier + ) +/*++ + +Routine Description: + + This routine allows a 64 bit value to be multiplied with a 32 bit + value returns 64bit result. + No checking if the result is greater than 64bits + +Arguments: + + Multiplicand - multiplicand + Multiplier - multiplier + +Returns: + + Multiplicand * Multiplier + +--*/ +; + +UINT64 +DivU64x32 ( + IN UINT64 Dividend, + IN UINTN Divisor, + OUT UINTN *Remainder OPTIONAL + ) +/*++ + +Routine Description: + + This routine allows a 64 bit value to be divided with a 32 bit value returns + 64bit result and the Remainder. + +Arguments: + + Dividend - dividend + Divisor - divisor + Remainder - buffer for remainder + +Returns: + + Dividend / Divisor + Remainder = Dividend mod Divisor + +--*/ +; + +UINT64 +RShiftU64 ( + IN UINT64 Operand, + IN UINTN Count + ) +/*++ + +Routine Description: + + This routine allows a 64 bit value to be right shifted by 32 bits and returns the + shifted value. + Count is valid up 63. (Only Bits 0-5 is valid for Count) + +Arguments: + + Operand - Value to be shifted + Count - Number of times to shift right. + +Returns: + + Value shifted right identified by the Count. + +--*/ +; + +UINT64 +LShiftU64 ( + IN UINT64 Operand, + IN UINTN Count + ) +/*++ + +Routine Description: + + This routine allows a 64 bit value to be left shifted by 32 bits and + returns the shifted value. + Count is valid up 63. (Only Bits 0-5 is valid for Count) + +Arguments: + + Operand - Value to be shifted + Count - Number of times to shift left. + +Returns: + + Value shifted left identified by the Count. + +--*/ +; + +UINT64 +Power10U64 ( + IN UINT64 Operand, + IN UINTN Power + ) +/*++ + +Routine Description: + + Raise 10 to the power of Power, and multiply the result with Operand + +Arguments: + + Operand - multiplicand + Power - power + +Returns: + + Operand * 10 ^ Power + +--*/ +; + +UINT8 +Log2 ( + IN UINT64 Operand + ) +/*++ + +Routine Description: + + Calculates and floors logarithms based on 2 + +Arguments: + + Operand - value to calculate logarithm + +Returns: + + The largest integer that is less than or equal + to the logarithm of Operand based on 2 + +--*/ +; + +UINT64 +GetPowerOfTwo ( + IN UINT64 Input + ) +/*++ + +Routine Description: + + Calculates the largest integer that is both + a power of two and less than Input + +Arguments: + + Input - value to calculate power of two + +Returns: + + the largest integer that is both a power of + two and less than Input + +--*/ +; + +// +// Unicode String primatives +// +VOID +EfiStrCpy ( + IN CHAR16 *Destination, + IN CHAR16 *Source + ) +/*++ + +Routine Description: + Copy the Unicode string Source to Destination. + +Arguments: + Destination - Location to copy string + Source - String to copy + +Returns: + NONE + +--*/ +; + +VOID +EfiStrnCpy ( + OUT CHAR16 *Dst, + IN CHAR16 *Src, + IN UINTN Length + ) +/*++ + +Routine Description: + Copy a string from source to destination + +Arguments: + Dst Destination string + Src Source string + Length Length of destination string + +Returns: + +--*/ +; + +UINTN +EfiStrLen ( + IN CHAR16 *String + ) +/*++ + +Routine Description: + Return the number of Unicode characters in String. This is not the same as + the length of the string in bytes. + +Arguments: + String - String to process + +Returns: + Number of Unicode characters in String + +--*/ +; + +UINTN +EfiStrSize ( + IN CHAR16 *String + ) +/*++ + +Routine Description: + Return the number bytes in the Unicode String. This is not the same as + the length of the string in characters. The string size includes the NULL + +Arguments: + String - String to process + +Returns: + Number of bytes in String + +--*/ +; + +INTN +EfiStrCmp ( + IN CHAR16 *String, + IN CHAR16 *String2 + ) +/*++ + +Routine Description: + Return the alphabetic relationship between two stirngs. + +Arguments: + String - Compare to String2 + + String2 - Compare to String + +Returns: + 0 - Identical + + > 0 - String is alphabeticly greater than String2 + + < 0 - String is alphabeticly less than String2 + +--*/ +; + +INTN +EfiStrnCmp ( + IN CHAR16 *String, + IN CHAR16 *String2, + IN UINTN Length + ) +/*++ + +Routine Description: + This function compares the Unicode string String to the Unicode + string String2 for len characters. If the first len characters + of String is identical to the first len characters of String2, + then 0 is returned. If substring of String sorts lexicographically + after String2, the function returns a number greater than 0. If + substring of String sorts lexicographically before String2, the + function returns a number less than 0. + +Arguments: + String - Compare to String2 + String2 - Compare to String + Length - Number of Unicode characters to compare + +Returns: + 0 - The substring of String and String2 is identical. + > 0 - The substring of String sorts lexicographically after String2 + < 0 - The substring of String sorts lexicographically before String2 + +--*/ +; + +VOID +EfiStrCat ( + IN CHAR16 *Destination, + IN CHAR16 *Source + ) +/*++ + +Routine Description: + Concatinate Source on the end of Destination + +Arguments: + Destination - String to added to the end of. + Source - String to concatinate. + +Returns: + NONE + +--*/ +; + +VOID +EfiStrnCat ( + IN CHAR16 *Dest, + IN CHAR16 *Src, + IN UINTN Length + ) +/*++ + +Routine Description: + Concatinate Source on the end of Destination + +Arguments: + Dst Destination string + Src Source string + Length Length of destination string + +Returns: + +--*/ +; + +UINTN +EfiAsciiStrLen ( + IN CHAR8 *String + ) +/*++ + +Routine Description: + Return the number of Ascii characters in String. This is not the same as + the length of the string in bytes. + +Arguments: + String - String to process + +Returns: + Number of Unicode characters in String + +--*/ +; + +CHAR8 * +EfiAsciiStrCpy ( + IN CHAR8 *Destination, + IN CHAR8 *Source + ) +/*++ + +Routine Description: + Copy the Ascii string Source to Destination. + +Arguments: + Destination - Location to copy string + Source - String to copy + +Returns: + Pointer just pass the end of Destination + +--*/ +; + +VOID +EfiAsciiStrnCpy ( + OUT CHAR8 *Dst, + IN CHAR8 *Src, + IN UINTN Length + ) +/*++ + +Routine Description: + Copy the Ascii string from source to destination + +Arguments: + Dst Destination string + Src Source string + Length Length of destination string + +Returns: + +--*/ +; + +UINTN +EfiAsciiStrSize ( + IN CHAR8 *String + ) +/*++ + +Routine Description: + Return the number bytes in the Ascii String. This is not the same as + the length of the string in characters. The string size includes the NULL + +Arguments: + String - String to process + +Returns: + Number of bytes in String + +--*/ +; + + +INTN +EfiAsciiStrCmp ( + IN CHAR8 *String, + IN CHAR8 *String2 + ) +/*++ + +Routine Description: + Compare the Ascii string pointed by String to the string pointed by String2. + +Arguments: + String - String to process + + String2 - The other string to process + +Returns: + Return a positive integer if String is lexicall greater than String2; Zero if + the two strings are identical; and a negative interger if String is lexically + less than String2. +--*/ +; + +INTN +EfiAsciiStrnCmp ( + IN CHAR8 *String, + IN CHAR8 *String2, + IN UINTN Length + ) +/*++ + +Routine Description: + This function compares the ASCII string String to the ASCII + string String2 for len characters. If the first len characters + of String is identical to the first len characters of String2, + then 0 is returned. If substring of String sorts lexicographically + after String2, the function returns a number greater than 0. If + substring of String sorts lexicographically before String2, the + function returns a number less than 0. + +Arguments: + String - Compare to String2 + String2 - Compare to String + Length - Number of ASCII characters to compare + +Returns: + 0 - The substring of String and String2 is identical. + > 0 - The substring of String sorts lexicographically after String2 + < 0 - The substring of String sorts lexicographically before String2 + +--*/ +; + +VOID +EfiAsciiStrCat ( + IN CHAR8 *Destination, + IN CHAR8 *Source + ) +/*++ + +Routine Description: + Concatinate Source on the end of Destination + +Arguments: + Destination - String to added to the end of. + Source - String to concatinate. + +Returns: + NONE + +--*/ +; + +VOID +EfiAsciiStrnCat ( + IN CHAR8 *Destination, + IN CHAR8 *Source, + IN UINTN Length + ) +/*++ + +Routine Description: + Concatinate Source on the end of Destination + +Arguments: + Destination - String to added to the end of. + Source - String to concatinate. + +Returns: + NONE + +--*/ +; + +// +// Print primitives +// +#define LEFT_JUSTIFY 0x01 +#define PREFIX_SIGN 0x02 +#define PREFIX_BLANK 0x04 +#define COMMA_TYPE 0x08 +#define LONG_TYPE 0x10 +#define PREFIX_ZERO 0x20 + +// +// Length of temp string buffer to store value string. +// +#define CHARACTER_NUMBER_FOR_VALUE 30 + +UINTN +EfiValueToHexStr ( + IN OUT CHAR16 *Buffer, + IN UINT64 Value, + IN UINTN Flags, + IN UINTN Width + ) +/*++ + +Routine Description: + + VSPrint worker function that prints a Value as a hex number in Buffer + +Arguments: + + Buffer - Location to place ascii hex string of Value. + + Value - Hex value to convert to a string in Buffer. + + Flags - Flags to use in printing Hex string, see file header for details. + + Width - Width of hex value. + +Returns: + + Number of characters printed. + +--*/ +; + +UINTN +EfiValueToString ( + IN OUT CHAR16 *Buffer, + IN INT64 Value, + IN UINTN Flags, + IN UINTN Width + ) +/*++ + +Routine Description: + + VSPrint worker function that prints a Value as a decimal number in Buffer + +Arguments: + + Buffer - Location to place ascii decimal number string of Value. + + Value - Decimal value to convert to a string in Buffer. + + Flags - Flags to use in printing decimal string, see file header for details. + + Width - Width of hex value. + +Returns: + + Number of characters printed. + +--*/ +; + +BOOLEAN +IsHexDigit ( + OUT UINT8 *Digit, + IN CHAR16 Char + ) +/*++ + + Routine Description: + Determines if a Unicode character is a hexadecimal digit. + The test is case insensitive. + + Arguments: + Digit - Pointer to byte that receives the value of the hex character. + Char - Unicode character to test. + + Returns: + TRUE - If the character is a hexadecimal digit. + FALSE - Otherwise. + +--*/ +; + +CHAR16 +NibbleToHexChar ( + UINT8 Nibble + ) +/*++ + + Routine Description: + Converts the low nibble of a byte to hex unicode character. + + Arguments: + Nibble - lower nibble of a byte. + + Returns: + Hex unicode character. + +--*/ +; + +EFI_STATUS +HexStringToBuf ( + IN OUT UINT8 *Buf, + IN OUT UINTN *Len, + IN CHAR16 *Str, + OUT UINTN *ConvertedStrLen OPTIONAL + ) +/*++ + + Routine Description: + Converts Unicode string to binary buffer. + The conversion may be partial. + The first character in the string that is not hex digit stops the conversion. + At a minimum, any blob of data could be represented as a hex string. + + Arguments: + Buf - Pointer to buffer that receives the data. + Len - Length in bytes of the buffer to hold converted data. + If routine return with EFI_SUCCESS, containing length of converted data. + If routine return with EFI_BUFFER_TOO_SMALL, containg length of buffer desired. + Str - String to be converted from. + ConvertedStrLen - Length of the Hex String consumed. + + Returns: + EFI_SUCCESS: Routine Success. + EFI_BUFFER_TOO_SMALL: The buffer is too small to hold converted data. + EFI_ + +--*/ +; + +EFI_STATUS +BufToHexString ( + IN OUT CHAR16 *Str, + IN OUT UINTN *HexStringBufferLength, + IN UINT8 *Buf, + IN UINTN Len + ) +/*++ + + Routine Description: + Converts binary buffer to Unicode string. + At a minimum, any blob of data could be represented as a hex string. + + Arguments: + Str - Pointer to the string. + HexStringBufferLength - Length in bytes of buffer to hold the hex string. Includes tailing '\0' character. + If routine return with EFI_SUCCESS, containing length of hex string buffer. + If routine return with EFI_BUFFER_TOO_SMALL, containg length of hex string buffer desired. + Buf - Buffer to be converted from. + Len - Length in bytes of the buffer to be converted. + + Returns: + EFI_SUCCESS: Routine success. + EFI_BUFFER_TOO_SMALL: The hex string buffer is too small. + +--*/ +; + +VOID +EfiStrTrim ( + IN OUT CHAR16 *str, + IN CHAR16 CharC + ) +/*++ + +Routine Description: + + Removes (trims) specified leading and trailing characters from a string. + +Arguments: + + str - Pointer to the null-terminated string to be trimmed. On return, + str will hold the trimmed string. + CharC - Character will be trimmed from str. + +Returns: + + None + +--*/ +; +CHAR16* +EfiStrStr ( + IN CHAR16 *String, + IN CHAR16 *StrCharSet + ) +/*++ + +Routine Description: + + Find a substring. + +Arguments: + + String - Null-terminated string to search. + StrCharSet - Null-terminated string to search for. + +Returns: + The address of the first occurrence of the matching substring if successful, or NULL otherwise. +--*/ +; + +CHAR8* +EfiAsciiStrStr ( + IN CHAR8 *String, + IN CHAR8 *StrCharSet + ) +/*++ + +Routine Description: + + Find a Ascii substring. + +Arguments: + + String - Null-terminated Ascii string to search. + StrCharSet - Null-terminated Ascii string to search for. + +Returns: + The address of the first occurrence of the matching Ascii substring if successful, or NULL otherwise. +--*/ +; +#endif diff --git a/EDK/Foundation/Library/Dxe/Include/EfiDriverLib.h b/EDK/Foundation/Library/Dxe/Include/EfiDriverLib.h new file mode 100644 index 0000000..20ba3af --- /dev/null +++ b/EDK/Foundation/Library/Dxe/Include/EfiDriverLib.h @@ -0,0 +1,1231 @@ +/*++ + +Copyright (c) 2004 - 2008, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + EfiDriverLib.h + +Abstract: + + Light weight lib to support EFI drivers. + +--*/ + +#ifndef _EFI_DRIVER_LIB_H_ +#define _EFI_DRIVER_LIB_H_ + +#include "EfiStatusCode.h" +#include "EfiCommonLib.h" +#include "EfiPerf.h" +#include "LinkedList.h" +#include "GetImage.h" +#include "EfiImageFormat.h" +#include "EfiCompNameSupport.h" + +#include EFI_GUID_DEFINITION (DxeServices) +#include EFI_GUID_DEFINITION (EventGroup) +#include EFI_GUID_DEFINITION (EventLegacyBios) +#include EFI_GUID_DEFINITION (FrameworkDevicePath) +#include EFI_PROTOCOL_DEFINITION (FirmwareVolume) +#include EFI_PROTOCOL_DEFINITION (FirmwareVolume2) //;;## ...AMI_OVERRIDE... Support PI1.x +#include EFI_PROTOCOL_DEFINITION (DataHub) +#include EFI_PROTOCOL_DEFINITION (DriverBinding) +#include EFI_PROTOCOL_DEFINITION (ComponentName) +#include EFI_PROTOCOL_DEFINITION (ComponentName2) +#include EFI_PROTOCOL_DEFINITION (DriverConfiguration) +#include EFI_PROTOCOL_DEFINITION (DriverConfiguration2) +#include EFI_PROTOCOL_DEFINITION (DriverDiagnostics) +#include EFI_PROTOCOL_DEFINITION (DriverDiagnostics2) + +#include EFI_PROTOCOL_DEFINITION (DebugMask) + +typedef struct { + CHAR8 *Language; + CHAR16 *UnicodeString; +} EFI_UNICODE_STRING_TABLE; + +#if (EFI_SPECIFICATION_VERSION >= 0x00020000) +#define LANGUAGE_CODE_ENGLISH "en-US" +#else +#define LANGUAGE_CODE_ENGLISH "eng" +#endif + +// +// Macros for EFI Driver Library Functions that are really EFI Boot Services +// +#define EfiCopyMem(_Destination, _Source, _Length) gBS->CopyMem ((_Destination), (_Source), (_Length)) +#define EfiSetMem(_Destination, _Length, _Value) gBS->SetMem ((_Destination), (_Length), (_Value)) +#define EfiZeroMem(_Destination, _Length) gBS->SetMem ((_Destination), (_Length), 0) + +// +// Driver Lib Globals. +// +extern EFI_BOOT_SERVICES *gBS; +extern EFI_DXE_SERVICES *gDS; +extern EFI_RUNTIME_SERVICES *gRT; +extern EFI_SYSTEM_TABLE *gST; +extern UINTN gErrorLevel; +extern EFI_GUID gEfiCallerIdGuid; +extern EFI_DEBUG_MASK_PROTOCOL *gDebugMaskInterface; + +EFI_STATUS +EfiInitializeDriverLib ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +/*++ + +Routine Description: + + Intialize Driver Lib if it has not yet been initialized. + +Arguments: + + ImageHandle - The firmware allocated handle for the EFI image. + + SystemTable - A pointer to the EFI System Table. + + +Returns: + + EFI_STATUS always returns EFI_SUCCESS + +--*/ +; + +EFI_STATUS +DxeInitializeDriverLib ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +/*++ + +Routine Description: + + Intialize Driver Lib if it has not yet been initialized. + +Arguments: + + ImageHandle - The firmware allocated handle for the EFI image. + + SystemTable - A pointer to the EFI System Table. + +Returns: + + EFI_STATUS always returns EFI_SUCCESS + +--*/ +; + +EFI_STATUS +EfiLibInstallDriverBinding ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable, + IN EFI_DRIVER_BINDING_PROTOCOL *DriverBinding, + IN EFI_HANDLE DriverBindingHandle + ) +/*++ + +Routine Description: + + Intialize a driver by installing the Driver Binding Protocol onto the + driver's DriverBindingHandle. This is typically the same as the driver's + ImageHandle, but it can be different if the driver produces multiple + DriverBinding Protocols. This function also initializes the EFI Driver + Library that initializes the global variables gST, gBS, gRT. + +Arguments: + + ImageHandle - The image handle of the driver + + SystemTable - The EFI System Table that was passed to the driver's entry point + + DriverBinding - A Driver Binding Protocol instance that this driver is producing + + DriverBindingHandle - The handle that DriverBinding is to be installe onto. If this + parameter is NULL, then a new handle is created. + +Returns: + + EFI_SUCCESS is DriverBinding is installed onto DriverBindingHandle + + Otherwise, then return status from gBS->InstallProtocolInterface() + +--*/ +; + +EFI_STATUS +EfiLibInstallAllDriverProtocols ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable, + IN EFI_DRIVER_BINDING_PROTOCOL *DriverBinding, + IN EFI_HANDLE DriverBindingHandle, + IN EFI_COMPONENT_NAME_PROTOCOL *ComponentName, OPTIONAL + IN EFI_DRIVER_CONFIGURATION_PROTOCOL *DriverConfiguration, OPTIONAL + IN EFI_DRIVER_DIAGNOSTICS_PROTOCOL *DriverDiagnostics OPTIONAL + ) +/*++ + +Routine Description: + + Intialize a driver by installing the Driver Binding Protocol onto the + driver's DriverBindingHandle. This is typically the same as the driver's + ImageHandle, but it can be different if the driver produces multiple + DriverBinding Protocols. This function also initializes the EFI Driver + Library that initializes the global variables gST, gBS, gRT. + +Arguments: + + ImageHandle - The image handle of the driver + + SystemTable - The EFI System Table that was passed to the driver's entry point + + DriverBinding - A Driver Binding Protocol instance that this driver is producing + + DriverBindingHandle - The handle that DriverBinding is to be installe onto. If this + parameter is NULL, then a new handle is created. + + ComponentName - A Component Name Protocol instance that this driver is producing + + DriverConfiguration - A Driver Configuration Protocol instance that this driver is producing + + DriverDiagnostics - A Driver Diagnostics Protocol instance that this driver is producing + +Returns: + + EFI_SUCCESS if all the protocols were installed onto DriverBindingHandle + + Otherwise, then return status from gBS->InstallProtocolInterface() + +--*/ +; + +EFI_STATUS +EfiLibInstallAllDriverProtocols2 ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable, + IN EFI_DRIVER_BINDING_PROTOCOL *DriverBinding, + IN EFI_HANDLE DriverBindingHandle, + IN EFI_COMPONENT_NAME2_PROTOCOL *ComponentName2, OPTIONAL + IN EFI_DRIVER_CONFIGURATION2_PROTOCOL *DriverConfiguration2, OPTIONAL + IN EFI_DRIVER_DIAGNOSTICS2_PROTOCOL *DriverDiagnostics2 OPTIONAL + ) +/*++ + +Routine Description: + + Intialize a driver by installing the Driver Binding Protocol onto the + driver's DriverBindingHandle. This is typically the same as the driver's + ImageHandle, but it can be different if the driver produces multiple + DriverBinding Protocols. This function also initializes the EFI Driver + Library that initializes the global variables gST, gBS, gRT. + +Arguments: + + ImageHandle - The image handle of the driver + + SystemTable - The EFI System Table that was passed to the driver's entry point + + DriverBinding - A Driver Binding Protocol instance that this driver is producing + + DriverBindingHandle - The handle that DriverBinding is to be installe onto. If this + parameter is NULL, then a new handle is created. + + ComponentName2 - A Component Name2 Protocol instance that this driver is producing + + DriverConfiguration2- A Driver Configuration2 Protocol instance that this driver is producing + + DriverDiagnostics2 - A Driver Diagnostics2 Protocol instance that this driver is producing + +Returns: + + EFI_SUCCESS if all the protocols were installed onto DriverBindingHandle + + Otherwise, then return status from gBS->InstallProtocolInterface() + +--*/ +; + +EFI_STATUS +EfiLibGetSystemConfigurationTable ( + IN EFI_GUID *TableGuid, + OUT VOID **Table + ) +/*++ + +Routine Description: + + Return the EFI 1.0 System Tabl entry with TableGuid + +Arguments: + + TableGuid - Name of entry to return in the system table + Table - Pointer in EFI system table associated with TableGuid + +Returns: + + EFI_SUCCESS - Table returned; + EFI_NOT_FOUND - TableGuid not in EFI system table + +--*/ +; + +BOOLEAN +EfiLibCompareLanguage ( + CHAR8 *Language1, + CHAR8 *Language2 + ) +/*++ + +Routine Description: + + Compare two languages to say whether they are identical. + +Arguments: + + Language1 - first language + Language2 - second language + +Returns: + + TRUE - identical + FALSE - not identical + +--*/ +; + +// +// DevicePath.c +// +BOOLEAN +EfiIsDevicePathMultiInstance ( + IN EFI_DEVICE_PATH_PROTOCOL *DevicePath + ) +/*++ + +Routine Description: + Return TRUE is this is a multi instance device path. + +Arguments: + DevicePath - A pointer to a device path data structure. + + +Returns: + TRUE - If DevicePath is multi instance. + FALSE - If DevicePath is not multi instance. + +--*/ +; + +EFI_DEVICE_PATH_PROTOCOL * +EfiDevicePathInstance ( + IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath, + OUT UINTN *Size + ) +/*++ + +Routine Description: + Function retrieves the next device path instance from a device path data structure. + +Arguments: + DevicePath - A pointer to a device path data structure. + + Size - A pointer to the size of a device path instance in bytes. + +Returns: + + This function returns a pointer to the current device path instance. + In addition, it returns the size in bytes of the current device path instance in Size, + and a pointer to the next device path instance in DevicePath. + If there are no more device path instances in DevicePath, then DevicePath will be set to NULL. + +--*/ +; + +UINTN +EfiDevicePathSize ( + IN EFI_DEVICE_PATH_PROTOCOL *DevPath + ) +/*++ + +Routine Description: + + Calculate the size of a whole device path. + +Arguments: + + DevPath - The pointer to the device path data. + +Returns: + + Size of device path data structure.. + +--*/ +; + +EFI_DEVICE_PATH_PROTOCOL * +EfiAppendDevicePath ( + IN EFI_DEVICE_PATH_PROTOCOL *Src1, + IN EFI_DEVICE_PATH_PROTOCOL *Src2 + ) +/*++ + +Routine Description: + Function is used to append a Src1 and Src2 together. + +Arguments: + Src1 - A pointer to a device path data structure. + + Src2 - A pointer to a device path data structure. + +Returns: + + A pointer to the new device path is returned. + NULL is returned if space for the new device path could not be allocated from pool. + It is up to the caller to free the memory used by Src1 and Src2 if they are no longer needed. + +--*/ +; + +EFI_DEVICE_PATH_PROTOCOL * +EfiDevicePathFromHandle ( + IN EFI_HANDLE Handle + ) +/*++ + +Routine Description: + + Locate device path protocol interface on a device handle. + +Arguments: + + Handle - The device handle + +Returns: + + Device path protocol interface located. + +--*/ +; + +EFI_DEVICE_PATH_PROTOCOL * +EfiDuplicateDevicePath ( + IN EFI_DEVICE_PATH_PROTOCOL *DevPath + ) +/*++ + +Routine Description: + Duplicate a new device path data structure from the old one. + +Arguments: + DevPath - A pointer to a device path data structure. + +Returns: + A pointer to the new allocated device path data. + Caller must free the memory used by DevicePath if it is no longer needed. + +--*/ +; + +EFI_DEVICE_PATH_PROTOCOL * +EfiAppendDevicePathNode ( + IN EFI_DEVICE_PATH_PROTOCOL *Src1, + IN EFI_DEVICE_PATH_PROTOCOL *Src2 + ) +/*++ + +Routine Description: + Function is used to append a device path node to the end of another device path. + +Arguments: + Src1 - A pointer to a device path data structure. + + Src2 - A pointer to a device path data structure. + +Returns: + This function returns a pointer to the new device path. + If there is not enough temporary pool memory available to complete this function, + then NULL is returned. + + +--*/ +; + +EFI_DEVICE_PATH_PROTOCOL * +EfiFileDevicePath ( + IN EFI_HANDLE Device OPTIONAL, + IN CHAR16 *FileName + ) +/*++ + +Routine Description: + Create a device path that appends a MEDIA_DEVICE_PATH with + FileNameGuid to the device path of DeviceHandle. + +Arguments: + Device - Optional Device Handle to use as Root of the Device Path + + FileName - FileName + +Returns: + EFI_DEVICE_PATH_PROTOCOL that was allocated from dynamic memory + or NULL pointer. + +--*/ +; + +EFI_DEVICE_PATH_PROTOCOL * +EfiAppendDevicePathInstance ( + IN EFI_DEVICE_PATH_PROTOCOL *Src, + IN EFI_DEVICE_PATH_PROTOCOL *Instance + ) +/*++ + +Routine Description: + + Append a device path instance to another. + +Arguments: + + Src - The device path instance to be appended with. + Instance - The device path instance appending the other. + +Returns: + + The contaction of these two. + +--*/ +; + +// +// Lock.c +// +typedef struct { + EFI_TPL Tpl; + EFI_TPL OwnerTpl; + UINTN Lock; +} EFI_LOCK; + +VOID +EfiInitializeLock ( + IN OUT EFI_LOCK *Lock, + IN EFI_TPL Priority + ) +/*++ + +Routine Description: + + Initialize a basic mutual exclusion lock. Each lock + provides mutual exclusion access at it's task priority + level. Since there is no-premption (at any TPL) or + multiprocessor support, acquiring the lock only consists + of raising to the locks TPL. + + Note on a check build ASSERT()s are used to ensure proper + lock usage. + +Arguments: + + Lock - The EFI_LOCK structure to initialize + + Priority - The task priority level of the lock + + +Returns: + + An initialized Efi Lock structure. + +--*/ +; + +// +// Macro to initialize the state of a lock when a lock variable is declared +// +#define EFI_INITIALIZE_LOCK_VARIABLE(Tpl) {Tpl,0,0} + +VOID +EfiAcquireLock ( + IN EFI_LOCK *Lock + ) +/*++ + +Routine Description: + + Raising to the task priority level of the mutual exclusion + lock, and then acquires ownership of the lock. + +Arguments: + + Lock - The lock to acquire + +Returns: + + None + +--*/ +; + +EFI_STATUS +EfiAcquireLockOrFail ( + IN EFI_LOCK *Lock + ) +/*++ + +Routine Description: + + Initialize a basic mutual exclusion lock. Each lock + provides mutual exclusion access at it's task priority + level. Since there is no-premption (at any TPL) or + multiprocessor support, acquiring the lock only consists + of raising to the locks TPL. + +Arguments: + + Lock - The EFI_LOCK structure to initialize + +Returns: + + EFI_SUCCESS - Lock Owned. + EFI_ACCESS_DENIED - Reentrant Lock Acquisition, Lock not Owned. + +--*/ +; + +VOID +EfiReleaseLock ( + IN EFI_LOCK *Lock + ) +/*++ + +Routine Description: + + Releases ownership of the mutual exclusion lock, and + restores the previous task priority level. + +Arguments: + + Lock - The lock to release + +Returns: + + None + +--*/ +; + +VOID * +EfiLibAllocatePool ( + IN UINTN AllocationSize + ) +/*++ + +Routine Description: + + Allocate EfiBootServicesData pool of size AllocationSize + +Arguments: + + AllocationSize - Pool size + +Returns: + + Pointer to the pool allocated + +--*/ +; + +VOID * +EfiLibAllocateRuntimePool ( + IN UINTN AllocationSize + ) +/*++ + +Routine Description: + + Allocate EfiRuntimeServicesData pool of size AllocationSize + +Arguments: + + AllocationSize - Pool size + +Returns: + + Pointer to the pool allocated + +--*/ +; + +VOID * +EfiLibAllocateZeroPool ( + IN UINTN AllocationSize + ) +/*++ + +Routine Description: + + Allocate EfiBootServicesData pool of size AllocationSize and set memory to zero. + +Arguments: + + AllocationSize - Pool size + +Returns: + + Pointer to the pool allocated + +--*/ +; + +VOID * +EfiLibAllocateRuntimeZeroPool ( + IN UINTN AllocationSize + ) +/*++ + +Routine Description: + + Allocate EfiRuntimeServicesData pool of size AllocationSize and set memory to zero. + +Arguments: + + AllocationSize - Pool size + +Returns: + + Pointer to the pool allocated + +--*/ +; + +VOID * +EfiLibAllocateCopyPool ( + IN UINTN AllocationSize, + IN VOID *Buffer + ) +/*++ + +Routine Description: + + Allocate BootServicesData pool and use a buffer provided by + caller to fill it. + +Arguments: + + AllocationSize - The size to allocate + + Buffer - Buffer that will be filled into the buffer allocated + +Returns: + + Pointer of the buffer allocated. + +--*/ +; + +VOID * +EfiLibAllocateRuntimeCopyPool ( + IN UINTN AllocationSize, + IN VOID *Buffer + ) +/*++ + +Routine Description: + + Allocate RuntimeServicesData pool and use a buffer provided by + caller to fill it. + +Arguments: + + AllocationSize - The size to allocate + + Buffer - Buffer that will be filled into the buffer allocated + +Returns: + + Pointer of the buffer allocated. + +--*/ +; + +// +// Event.c +// +EFI_EVENT +EfiLibCreateProtocolNotifyEvent ( + IN EFI_GUID *ProtocolGuid, + IN EFI_TPL NotifyTpl, + IN EFI_EVENT_NOTIFY NotifyFunction, + IN VOID *NotifyContext, + OUT VOID **Registration + ) +/*++ + +Routine Description: + + Create a protocol notification event and return it. + +Arguments: + + ProtocolGuid - Protocol to register notification event on. + + NotifyTpl - Maximum TPL to single the NotifyFunction. + + NotifyFunction - EFI notification routine. + + NotifyContext - Context passed into Event when it is created. + + Registration - Registration key returned from RegisterProtocolNotify(). + +Returns: + + The EFI_EVENT that has been registered to be signaled when a ProtocolGuid + is added to the system. + +--*/ +; + +EFI_STATUS +EfiLibNamedEventSignal ( + IN EFI_GUID *Name + ) +/*++ + +Routine Description: + Signals a named event. All registered listeners will run. + The listeners should register using EfiLibNamedEventListen() function. + + NOTE: For now, the named listening/signalling is implemented + on a protocol interface being installed and uninstalled. + In the future, this maybe implemented based on a dedicated mechanism. + +Arguments: + Name - Name to perform the signaling on. The name is a GUID. + +Returns: + EFI_SUCCESS if successfull. + +--*/ +; + +EFI_STATUS +EfiLibNamedEventListen ( + IN EFI_GUID * Name, + IN EFI_TPL NotifyTpl, + IN EFI_EVENT_NOTIFY NotifyFunction, + IN VOID *NotifyContext + ) +/*++ + +Routine Description: + Listenes to signals on the name. + EfiLibNamedEventSignal() signals the event. + + NOTE: For now, the named listening/signalling is implemented + on a protocol interface being installed and uninstalled. + In the future, this maybe implemented based on a dedicated mechanism. + +Arguments: + Name - Name to register the listener on. + NotifyTpl - Maximum TPL to singnal the NotifyFunction. + NotifyFunction - The listener routine. + NotifyContext - Context passed into the listener routine. + +Returns: + EFI_SUCCESS if successful. + +--*/ +; + +// +// Handle.c +// +EFI_STATUS +EfiLibLocateHandleProtocolByProtocols ( + IN OUT EFI_HANDLE * Handle, OPTIONAL + OUT VOID **Interface, OPTIONAL + ... + ) +/*++ +Routine Description: + + Function locates Protocol and/or Handle on which all Protocols specified + as a variable list are installed. + It supports continued search. The caller must assure that no handles are added + or removed while performing continued search, by e.g., rising the TPL and not + calling any handle routines. Otherwise the behavior is undefined. + +Arguments: + + Handle - The address of handle to receive the handle on which protocols + indicated by the variable list are installed. + If points to NULL, all handles are searched. If pointing to a + handle returned from previous call, searches starting from next handle. + If NULL, the parameter is ignored. + + Interface - The address of a pointer to a protocol interface that will receive + the interface indicated by first variable argument. + If NULL, the parameter is ignored. + + ... - A variable argument list containing protocol GUIDs. Must end with NULL. + +Returns: + + EFI_SUCCESS - All the protocols where found on same handle. + EFI_NOT_FOUND - A Handle with all the protocols installed was not found. + Other values as may be returned from LocateHandleBuffer() or HandleProtocol(). + +--*/ +; + +// +// Debug.c init +// +EFI_STATUS +EfiDebugAssertInit ( + VOID + ) +/*++ + +Routine Description: + + Locate Debug Assert Protocol and set as mDebugAssert + +Arguments: + + None + +Returns: + + Status code + +--*/ +; + +// +// Unicode String Support +// +EFI_STATUS +EfiLibLookupUnicodeString ( + CHAR8 *Language, + CHAR8 *SupportedLanguages, + EFI_UNICODE_STRING_TABLE *UnicodeStringTable, + CHAR16 **UnicodeString + ) +/*++ + +Routine Description: + + Translate a unicode string to a specified language if supported. + +Arguments: + + Language - The name of language to translate to + SupportedLanguages - Supported languages set + UnicodeStringTable - Pointer of one item in translation dictionary + UnicodeString - The translated string + +Returns: + + EFI_INVALID_PARAMETER - Invalid parameter + EFI_UNSUPPORTED - System not supported this language or this string translation + EFI_SUCCESS - String successfully translated + +--*/ +; + +EFI_STATUS +EfiLibAddUnicodeString ( + CHAR8 *Language, + CHAR8 *SupportedLanguages, + EFI_UNICODE_STRING_TABLE **UnicodeStringTable, + CHAR16 *UnicodeString + ) +/*++ + +Routine Description: + + Add an translation to the dictionary if this language if supported. + +Arguments: + + Language - The name of language to translate to + SupportedLanguages - Supported languages set + UnicodeStringTable - Translation dictionary + UnicodeString - The corresponding string for the language to be translated to + +Returns: + + EFI_INVALID_PARAMETER - Invalid parameter + EFI_UNSUPPORTED - System not supported this language + EFI_ALREADY_STARTED - Already has a translation item of this language + EFI_OUT_OF_RESOURCES - No enough buffer to be allocated + EFI_SUCCESS - String successfully translated + +--*/ +; + +EFI_STATUS +EfiLibFreeUnicodeStringTable ( + EFI_UNICODE_STRING_TABLE *UnicodeStringTable + ) +/*++ + +Routine Description: + + Free a string table. + +Arguments: + + UnicodeStringTable - The string table to be freed. + +Returns: + + EFI_SUCCESS - The table successfully freed. + +--*/ +; + +EFI_STATUS +EfiLibReportStatusCode ( + IN EFI_STATUS_CODE_TYPE Type, + IN EFI_STATUS_CODE_VALUE Value, + IN UINT32 Instance, + IN EFI_GUID *CallerId OPTIONAL, + IN EFI_STATUS_CODE_DATA *Data OPTIONAL + ) +/*++ + +Routine Description: + + Report status code. + +Arguments: + + Type - Code type + Value - Code value + Instance - Instance number + CallerId - Caller name + DevicePath - Device path that to be reported + +Returns: + + Status code. + + EFI_OUT_OF_RESOURCES - No enough buffer could be allocated + +--*/ +; + +EFI_STATUS +ReportStatusCodeWithDevicePath ( + IN EFI_STATUS_CODE_TYPE Type, + IN EFI_STATUS_CODE_VALUE Value, + IN UINT32 Instance, + IN EFI_GUID * CallerId OPTIONAL, + IN EFI_DEVICE_PATH_PROTOCOL * DevicePath + ) +/*++ + +Routine Description: + + Report device path through status code. + +Arguments: + + Type - Code type + Value - Code value + Instance - Instance number + CallerId - Caller name + DevicePath - Device path that to be reported + +Returns: + + Status code. + + EFI_OUT_OF_RESOURCES - No enough buffer could be allocated + +--*/ +; + +EFI_STATUS +EFIAPI +EfiCreateEventLegacyBoot ( + IN EFI_TPL NotifyTpl, + IN EFI_EVENT_NOTIFY NotifyFunction, + IN VOID *NotifyContext, + OUT EFI_EVENT *LegacyBootEvent + ) +/*++ + +Routine Description: + Create a Legacy Boot Event. + Tiano extended the CreateEvent Type enum to add a legacy boot event type. + This was bad as Tiano did not own the enum. In UEFI 2.0 CreateEventEx was + added and now it's possible to not voilate the UEFI specification by + declaring a GUID for the legacy boot event class. This library supports + the R8.5/EFI 1.10 form and R8.6/UEFI 2.0 form and allows common code to + work both ways. + +Arguments: + LegacyBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex) + +Returns: + EFI_SUCCESS Event was created. + Other Event was not created. + +--*/ +; + +EFI_STATUS +EFIAPI +EfiCreateEventReadyToBoot ( + IN EFI_TPL NotifyTpl, + IN EFI_EVENT_NOTIFY NotifyFunction, + IN VOID *NotifyContext, + OUT EFI_EVENT *ReadyToBootEvent + ) +/*++ + +Routine Description: + Create a Read to Boot Event. + + Tiano extended the CreateEvent Type enum to add a ready to boot event type. + This was bad as Tiano did not own the enum. In UEFI 2.0 CreateEventEx was + added and now it's possible to not voilate the UEFI specification and use + the ready to boot event class defined in UEFI 2.0. This library supports + the R8.5/EFI 1.10 form and R8.6/UEFI 2.0 form and allows common code to + work both ways. + +Arguments: + @param LegacyBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex) + +Return: + EFI_SUCCESS - Event was created. + Other - Event was not created. + +--*/ +; + +VOID +EFIAPI +EfiInitializeFwVolDevicepathNode ( + IN MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvDevicePathNode, + IN EFI_GUID *NameGuid + ) +/*++ +Routine Description: + Initialize a Firmware Volume (FV) Media Device Path node. + +Arguments: + FvDevicePathNode - Pointer to a FV device path node to initialize + NameGuid - FV file name to use in FvDevicePathNode + +--*/ +; + +EFI_GUID * +EFIAPI +EfiGetNameGuidFromFwVolDevicePathNode ( + IN MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvDevicePathNode + ) +/*++ +Routine Description: + Check to see if the Firmware Volume (FV) Media Device Path is valid. + +Arguments: + FvDevicePathNode - Pointer to FV device path to check + +Return: + NULL - FvDevicePathNode is not valid. + Other - FvDevicePathNode is valid and pointer to NameGuid was returned. + +--*/ +; + +VOID +EfiLibSafeFreePool ( + IN VOID *Buffer + ) +/*++ + +Routine Description: + + Free pool safely. + +Arguments: + + Buffer - The allocated pool entry to free + +Returns: + + Pointer of the buffer allocated. + +--*/ +; + +EFI_STATUS +EfiLibTestManagedDevice ( + IN EFI_HANDLE ControllerHandle, + IN EFI_HANDLE DriverBindingHandle, + IN EFI_GUID *ManagedProtocolGuid + ) +/*++ + +Routine Description: + + Test to see if the controller is managed by a specific driver. + +Arguments: + + ControllerHandle - Handle for controller to test + + DriverBindingHandle - Driver binding handle for controller + + ManagedProtocolGuid - The protocol guid the driver opens on controller + +Returns: + + EFI_SUCCESS - The controller is managed by the driver + + EFI_UNSUPPORTED - The controller is not managed by the driver + +--*/ +; + +EFI_STATUS +EfiLibTestChildHandle ( + IN EFI_HANDLE ControllerHandle, + IN EFI_HANDLE ChildHandle, + IN EFI_GUID *ConsumedGuid + ) +/*++ + +Routine Description: + + Test to see if the child handle is the child of the controller + +Arguments: + + ControllerHandle - Handle for controller (parent) + + ChildHandle - Child handle to test + + ConsumsedGuid - Protocol guid consumed by child from controller + +Returns: + + EFI_SUCCESS - The child handle is the child of the controller + + EFI_UNSUPPORTED - The child handle is not the child of the controller + +--*/ +; +#endif diff --git a/EDK/Foundation/Library/Dxe/Include/EfiHobLib.h b/EDK/Foundation/Library/Dxe/Include/EfiHobLib.h new file mode 100644 index 0000000..787e872 --- /dev/null +++ b/EDK/Foundation/Library/Dxe/Include/EfiHobLib.h @@ -0,0 +1,299 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + EfiHobLib.h + +Abstract: + + +--*/ + +#ifndef _EFI_HOB_LIB_H_ +#define _EFI_HOB_LIB_H_ + +#include "PeiHob.h" + +VOID * +GetHob ( + IN UINT16 Type, + IN VOID *HobStart + ) +/*++ + +Routine Description: + + This function returns the first instance of a HOB type in a HOB list. + +Arguments: + + Type The HOB type to return. + HobStart The first HOB in the HOB list. + +Returns: + + HobStart There were no HOBs found with the requested type. + else Returns the first HOB with the matching type. + +--*/ +; + +UINTN +GetHobListSize ( + IN VOID *HobStart + ) +/*++ + +Routine Description: + + Get size of hob list. + +Arguments: + + HobStart - Start pointer of hob list + +Returns: + + Size of hob list. + +--*/ +; + +UINT32 +GetHobVersion ( + IN VOID *HobStart + ) +/*++ + +Routine Description: + + Get hob version. + +Arguments: + + HobStart - Start pointer of hob list + +Returns: + + Hob version. + +--*/ +; + +EFI_STATUS +GetHobBootMode ( + IN VOID *HobStart, + OUT EFI_BOOT_MODE *BootMode + ) +/*++ + +Routine Description: + + Get current boot mode. + +Arguments: + + HobStart - Start pointer of hob list + + BootMode - Current boot mode recorded in PHIT hob + +Returns: + + EFI_NOT_FOUND - Invalid hob header + + EFI_SUCCESS - Boot mode found + +--*/ +; + +EFI_STATUS +GetCpuHobInfo ( + IN VOID *HobStart, + OUT UINT8 *SizeOfMemorySpace, + OUT UINT8 *SizeOfIoSpace + ) +/*++ + +Routine Description: + + Get information recorded in CPU hob (Memory space size, Io space size) + +Arguments: + + HobStart - Start pointer of hob list + + SizeOfMemorySpace - Size of memory size + + SizeOfIoSpace - Size of IO size + +Returns: + + EFI_NOT_FOUND - CPU hob not found + + EFI_SUCCESS - CPU hob found and information got. + +--*/ +; + +EFI_STATUS +GetDxeCoreHobInfo ( + IN VOID *HobStart, + OUT EFI_PHYSICAL_ADDRESS *BaseAddress, + OUT UINT64 *Length, + OUT VOID **EntryPoint, + OUT EFI_GUID **FileName + ) +/*++ + +Routine Description: + + Get memory allocation hob created for DXE core and extract its information + +Arguments: + + HobStart - Start pointer of the hob list + + BaseAddress - Start address of memory allocated for DXE core + + Length - Length of memory allocated for DXE core + + EntryPoint - DXE core file name + + FileName - FileName + +Returns: + + EFI_NOT_FOUND - DxeCoreHob not found + + EFI_SUCCESS - DxeCoreHob found and information got + +--*/ +; + +EFI_STATUS +GetNextFirmwareVolumeHob ( + IN OUT VOID **HobStart, + OUT EFI_PHYSICAL_ADDRESS *BaseAddress, + OUT UINT64 *Length + ) +/*++ + +Routine Description: + + Get next firmware volume hob from HobStart + +Arguments: + + HobStart - Start pointer of hob list + + BaseAddress - Start address of next firmware volume + + Length - Length of next firmware volume + +Returns: + + EFI_NOT_FOUND - Next firmware volume not found + + EFI_SUCCESS - Next firmware volume found with address information + +--*/ +; + +//;;## ...AMI_OVERRIDE... Support PI1.x +#if (PI_SPECIFICATION_VERSION >= 0x00010000) +EFI_STATUS +GetNextFirmwareVolume2Hob ( + IN OUT VOID **HobStart, + OUT EFI_PHYSICAL_ADDRESS *BaseAddress, + OUT UINT64 *Length, + OUT EFI_GUID *FileName + ) +; +#endif + +EFI_STATUS +GetNextGuidHob ( + IN OUT VOID **HobStart, + IN EFI_GUID * Guid, + OUT VOID **Buffer, + OUT UINTN *BufferSize OPTIONAL + ) +/*++ + +Routine Description: + Get the next guid hob. + +Arguments: + HobStart A pointer to the start hob. + Guid A pointer to a guid. + Buffer A pointer to the buffer. + BufferSize Buffer size. + +Returns: + Status code. + + EFI_NOT_FOUND - Next Guid hob not found + + EFI_SUCCESS - Next Guid hob found and data for this Guid got + +--*/ +; + +EFI_STATUS +GetPalEntryHobInfo ( + IN VOID *HobStart, + OUT EFI_PHYSICAL_ADDRESS *PalEntry + ) +/*++ + +Routine Description: + + Get PAL entry from PalEntryHob + +Arguments: + + HobStart - Start pointer of hob list + + PalEntry - Pointer to PAL entry + +Returns: + + Status code. + +--*/ +; + +EFI_STATUS +GetIoPortSpaceAddressHobInfo ( + IN VOID *HobStart, + OUT EFI_PHYSICAL_ADDRESS *IoPortSpaceAddress + ) +/*++ + +Routine Description: + + Get IO port space address from IoBaseHob. + +Arguments: + + HobStart - Start pointer of hob list + + IoPortSpaceAddress - IO port space address + +Returns: + + Status code + +--*/ +; + +#endif diff --git a/EDK/Foundation/Library/Dxe/Include/EfiMgmtModeRuntimeLib.h b/EDK/Foundation/Library/Dxe/Include/EfiMgmtModeRuntimeLib.h new file mode 100644 index 0000000..89fb72e --- /dev/null +++ b/EDK/Foundation/Library/Dxe/Include/EfiMgmtModeRuntimeLib.h @@ -0,0 +1,429 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + EfiMgmtModeRuntimeLib.h + +Abstract: + + Light weight lib to support EFI drivers. + +--*/ + +#ifndef _EFI_RT_SUPPORT_LIB_H_ +#define _EFI_RT_SUPPORT_LIB_H_ + +#ifndef EFI_LOAD_IMAGE_SMM +#define EFI_LOAD_DRIVER_SMM FALSE +#else +#define EFI_LOAD_DRIVER_SMM TRUE +#endif + +#ifndef EFI_NO_LOAD_IMAGE_RT +#define EFI_NO_LOAD_DRIVER_RT FALSE +#else +#define EFI_NO_LOAD_DRIVER_RT TRUE +#endif + +#include "EfiCommonLib.h" +#include "LinkedList.h" +#include "ProcDep.h" + +#include EFI_PROTOCOL_DEFINITION (CpuIo) +#include EFI_PROTOCOL_DEFINITION (FirmwareVolumeBlock) + +// +// Driver Lib Globals. +// +extern EFI_BOOT_SERVICES *gBS; +extern EFI_SYSTEM_TABLE *gST; +extern UINTN gRtErrorLevel; +extern BOOLEAN mEfiLoadDriverSmm; +extern BOOLEAN mEfiNoLoadDriverRt; +extern EFI_DEVICE_PATH_PROTOCOL *mFilePath; + +// +// Runtime Memory Allocation/De-Allocation tools (Should be used in Boot Phase only) +// +EFI_STATUS +EfiAllocateRuntimeMemoryPool ( + IN UINTN Size, + OUT VOID **Buffer + ) +/*++ + +Routine Description: + + Allocate EfiRuntimeServicesData pool of specified size. + +Arguments: + + Size - Pool size + Buffer - Memory pointer for output + +Returns: + + Status code + +--*/ +; + +EFI_STATUS +EfiFreeRuntimeMemoryPool ( + IN VOID *Buffer + ) +/*++ + +Routine Description: + + Free allocated pool + +Arguments: + + Buffer - Pool to be freed + +Returns: + + Status code + +--*/ +; + +EFI_STATUS +EfiLocateProtocolHandleBuffers ( + IN EFI_GUID *Protocol, + IN OUT UINTN *NumberHandles, + OUT EFI_HANDLE **Buffer + ) +/*++ + +Routine Description: + + Returns an array of handles that support the requested protocol in a buffer allocated from pool. + +Arguments: + + Protocol - Provides the protocol to search by. + NumberHandles - The number of handles returned in Buffer. + Buffer - A pointer to the buffer to return the requested array of handles that + support Protocol. + +Returns: + + Status code + +--*/ +; + +EFI_STATUS +EfiHandleProtocol ( + IN EFI_HANDLE Handle, + IN EFI_GUID *Protocol, + OUT VOID **Interface + ) +/*++ + +Routine Description: + + Queries a handle to determine if it supports a specified protocol. + +Arguments: + + Handle - The handle being queried. + Protocol - The published unique identifier of the protocol. + Interface - Supplies the address where a pointer to the corresponding Protocol + Interface is returned. NULL will be returned in *Interface if a + structure is not associated with Protocol. + +Returns: + + Status code + +--*/ +; + +EFI_STATUS +EfiInstallProtocolInterface ( + IN OUT EFI_HANDLE *Handle, + IN EFI_GUID *Protocol, + IN EFI_INTERFACE_TYPE InterfaceType, + IN VOID *Interface + ) +/*++ + +Routine Description: + + Installs a protocol interface on a device handle. If the handle does not exist, it is created and added +to the list of handles in the system. + +Arguments: + + Handle - A pointer to the EFI_HANDLE on which the interface is to be installed. + Protocol - The numeric ID of the protocol interface. + InterfaceType - Indicates whether Interface is supplied in native form. + Interface - A pointer to the protocol interface. + +Returns: + + Status code + +--*/ +; + +EFI_STATUS +EfiReinstallProtocolInterface ( + IN EFI_HANDLE SmmProtocolHandle, + IN EFI_GUID *Protocol, + IN VOID *OldInterface, + IN VOID *NewInterface + ) +/*++ + +Routine Description: + + Reinstalls a protocol interface on a device handle. + +Arguments: + + SmmProtocolHandle - Handle on which the interface is to be reinstalled. + Protocol - The numeric ID of the interface. + OldInterface - A pointer to the old interface. + NewInterface - A pointer to the new interface. + +Returns: + + Status code + +--*/ +; + +EFI_STATUS +EfiLocateProtocolInterface ( + EFI_GUID *Protocol, + VOID *Registration, OPTIONAL + VOID **Interface + ) +/*++ + +Routine Description: + + Returns the first protocol instance that matches the given protocol. + +Arguments: + + Protocol - Provides the protocol to search for. + Registration - Optional registration key returned from + RegisterProtocolNotify(). If Registration is NULL, then + it is ignored. + Interface - On return, a pointer to the first interface that matches Protocol and + Registration. + +Returns: + + Status code + +--*/ +; + +EFI_STATUS +UninstallProtocolInterface ( + IN EFI_HANDLE SmmProtocolHandle, + IN EFI_GUID *Protocol, + IN VOID *Interface + ) +/*++ + +Routine Description: + + Removes a protocol interface from a device handle. + +Arguments: + + SmmProtocolHandle - The handle on which the interface was installed. + Protocol - The numeric ID of the interface. + Interface - A pointer to the interface. + +Returns: + + Status code + +--*/ +; + +EFI_STATUS +EfiRegisterProtocolCallback ( + IN EFI_EVENT_NOTIFY CallbackFunction, + IN VOID *Context, + IN EFI_GUID *ProtocolGuid, + IN EFI_TPL NotifyTpl, + OUT VOID **Registeration, + OUT EFI_EVENT *Event + ) +/*++ + +Routine Description: + + Register a callback function to be signaled whenever an interface is installed for + a specified protocol. + +Arguments: + + CallbackFunction - Call back function + Context - Context of call back function + ProtocolGuid - The numeric ID of the protocol for which the callback function + is to be registered. + NotifyTpl - Notify tpl of callback function + Registeration - A pointer to a memory location to receive the registration value. + Event - Event that is to be signaled whenever a protocol interface is registered + for Protocol. + +Returns: + + Status code + +--*/ +; + +EFI_STATUS +EfiSignalProtocolEvent ( + EFI_EVENT Event + ) +/*++ + +Routine Description: + + Signals an event. + +Arguments: + + Event - The event to signal. + +Returns: + + Status code + +--*/ +; + +EFI_STATUS +EfiInstallVendorConfigurationTable ( + IN EFI_GUID *Guid, + IN VOID *Table + ) +/*++ + +Routine Description: + + Adds, updates, or removes a configuration table entry from the EFI System Table. + +Arguments: + + Guid - A pointer to the GUID for the entry to add, update, or remove. + Table - A pointer to the configuration table for the entry to add, update, or + remove. May be NULL. + +Returns: + + Status code + +--*/ +; + +EFI_STATUS +EfiGetVendorConfigurationTable ( + IN EFI_GUID *Guid, + OUT VOID **Table + ) +/*++ + +Routine Description: + + Return the EFI 1.0 System Tabl entry with TableGuid + +Arguments: + + Guid - Name of entry to return in the system table + Table - Pointer in EFI system table associated with TableGuid + +Returns: + + EFI_SUCCESS - Table returned; + EFI_NOT_FOUND - TableGuid not in EFI system table + +--*/ +; + +EFI_STATUS +EfiInitializeUtilsRuntimeDriverLib ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable, + IN EFI_EVENT_NOTIFY GoVirtualChildEvent + ) +/*++ + +Routine Description: + + Intialize runtime Driver Lib if it has not yet been initialized. + +Arguments: + + ImageHandle - The firmware allocated handle for the EFI image. + + SystemTable - A pointer to the EFI System Table. + + GoVirtualChildEvent - Caller can register a virtual notification event. + +Returns: + + EFI_STATUS always returns EFI_SUCCESS + +--*/ +; + +BOOLEAN +EfiInManagementInterrupt ( + VOID + ) +/*++ + +Routine Description: + + Indicate whether the caller is already in SMM or not. + +Arguments: + + None + +Returns: + + TRUE - In SMM + FALSE - Not in SMM + +--*/ +; + +// +// This MACRO initializes the RUNTIME invironment and optionally loads Image to SMM or Non-SMM space +// based upon the presence of build flags EFI_LOAD_DRIVER_SMM and EFI_NO_LOAD_DRIVER_RT. +// +#define EFI_INITIALIZE_RUNTIME_DRIVER_LIB(ImageHandle, SystemTable, GoVirtualChildEvent, FilePath) \ + mEfiLoadDriverSmm = EFI_LOAD_DRIVER_SMM; \ + mEfiNoLoadDriverRt = EFI_NO_LOAD_DRIVER_RT; \ + mFilePath = (EFI_DEVICE_PATH_PROTOCOL*) FilePath; \ + EfiInitializeUtilsRuntimeDriverLib ((EFI_HANDLE) ImageHandle, (EFI_SYSTEM_TABLE*) SystemTable, (EFI_EVENT_NOTIFY) GoVirtualChildEvent); \ + if (!EfiInManagementInterrupt()) { \ + if (mEfiNoLoadDriverRt) { \ + return EFI_SUCCESS; \ + } \ + } + +#endif diff --git a/EDK/Foundation/Library/Dxe/Include/EfiPrintLib.h b/EDK/Foundation/Library/Dxe/Include/EfiPrintLib.h new file mode 100644 index 0000000..1fca597 --- /dev/null +++ b/EDK/Foundation/Library/Dxe/Include/EfiPrintLib.h @@ -0,0 +1,326 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + EfiPrintLib.h + +Abstract: + + Light weight lib to support EFI drivers. + +--*/ + +#ifndef _EFI_PRINT_LIB_H_ +#define _EFI_PRINT_LIB_H_ + +#include EFI_PROTOCOL_DEFINITION(GraphicsOutput) +#include EFI_PROTOCOL_DEFINITION(UgaDraw) +#include EFI_PROTOCOL_DEFINITION(Print) + +UINTN +ErrorPrint ( + IN CONST CHAR16 *ErrorString, + IN CONST CHAR8 *Format, + ... + ) +/*++ + +Routine Description: + + Print function for a maximum of EFI_DRIVER_LIB_MAX_PRINT_BUFFER ascii + characters. + +Arguments: + + ErrorString - Error message printed first + + Format - Ascii format string see file header for more details. + + ... - Vararg list consumed by processing Format. + +Returns: + + Number of characters printed. + +--*/ +; + +VOID +ErrorDumpHex ( + IN UINTN Indent, + IN UINTN Offset, + IN UINTN DataSize, + IN VOID *UserData + ) +/*++ + +Routine Description: + + Dump error info by hex. + +Arguments: + + Indent - Indent number + Offset - Offset number + DataSize - Size of user data + UserData - User data to dump + +Returns: + + None + +--*/ +; + +UINTN +Print ( + IN CONST CHAR16 *Format, + ... + ) +/*++ + +Routine Description: + + Prints a formatted unicode string to the default console + +Arguments: + + fmt - Format string + +Returns: + + Length of string printed to the console + +--*/ +; + +UINTN +PrintXY ( + IN UINTN X, + IN UINTN Y, + IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *Foreground, OPTIONAL + IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *Background, OPTIONAL + IN CHAR16 *Fmt, + ... + ) +/*++ + +Routine Description: + + Prints a formatted unicode string to the default console + +Arguments: + + X - X coordinate to start printing + + Y - Y coordinate to start printing + + ForeGround - Foreground color + + BackGround - Background color + + Fmt - Format string + + ... - Print arguments + +Returns: + + Length of string printed to the console + +--*/ +; + +UINTN +Aprint ( + IN CONST CHAR8 *Format, + ... + ) +/*++ + +Routine Description: + + Print function for a maximum of EFI_DRIVER_LIB_MAX_PRINT_BUFFER ascii + characters. + +Arguments: + + Format - Ascii format string see file header for more details. + + ... - Vararg list consumed by processing Format. + +Returns: + + Number of characters printed. + +--*/ +; + +UINTN +UPrint ( + IN CONST CHAR16 *Format, + ... + ) +/*++ + +Routine Description: + + Print function for a maximum of EFI_DRIVER_LIB_MAX_PRINT_BUFFER ascii + characters. + +Arguments: + + Format - Ascii format string see file header for more details. + + ... - Vararg list consumed by processing Format. + +Returns: + + Number of characters printed. + +--*/ +; + +UINTN +VSPrint ( + OUT CHAR16 *StartOfBuffer, + IN UINTN StrLen, + IN CONST CHAR16 *Format, + IN VA_LIST Marker + ) +/*++ + +Routine Description: + + Prints a formatted unicode string to a buffer + +Arguments: + + StartOfBuffer - Output buffer to print the formatted string into + StrLen - Size of Str. String is truncated to this size. + A size of 0 means there is no limit + Format - The format string + Marker - Vararg list consumed by processing Format. + +Returns: + + String length returned in buffer + +--*/ +; + +UINTN +SPrint ( + OUT CHAR16 *Buffer, + IN UINTN BufferSize, + IN CONST CHAR16 *Format, + ... + ) +/*++ + +Routine Description: + + SPrint function to process format and place the results in Buffer. + +Arguments: + + Buffer - Wide char buffer to print the results of the parsing of Format into. + + BufferSize - Maximum number of characters to put into buffer. Zero means no + limit. + + Format - Format string see file header for more details. + + ... - Vararg list consumed by processing Format. + +Returns: + + Number of characters printed. + +--*/ +; + +// +// BoxDraw support +// +BOOLEAN +IsValidEfiCntlChar ( + IN CHAR16 CharC + ) +/*++ + +Routine Description: + + Test whether a wide char is a valid control char. + +Arguments: + + CharC - A char + +Returns: + + TRUE - A control char + + FALSE - Not a control char + +--*/ +; + +BOOLEAN +IsValidAscii ( + IN CHAR16 Ascii + ) +/*++ + +Routine Description: + + Test whether a wide char is a normal printable char + +Arguments: + + Ascii - A char + +Returns: + + True - A normal, printable char + FALSE - Not a normal, printable char + +--*/ +; + +BOOLEAN +LibIsValidTextGraphics ( + IN CHAR16 Graphic, + OUT CHAR8 *PcAnsi, OPTIONAL + OUT CHAR8 *Ascii OPTIONAL + ) +/*++ + +Routine Description: + + Detects if a Unicode char is for Box Drawing text graphics. + +Arguments: + + Graphic - Unicode char to test. + + PcAnsi - Optional pointer to return PCANSI equivalent of Graphic. + + Ascii - Optional pointer to return Ascii equivalent of Graphic. + +Returns: + + TRUE if Gpaphic is a supported Unicode Box Drawing character. + +--*/ +; + +#endif diff --git a/EDK/Foundation/Library/Dxe/Include/EfiRegTableLib.h b/EDK/Foundation/Library/Dxe/Include/EfiRegTableLib.h new file mode 100644 index 0000000..6df50d8 --- /dev/null +++ b/EDK/Foundation/Library/Dxe/Include/EfiRegTableLib.h @@ -0,0 +1,205 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + EfiRegTableLib.h + +Abstract: + + Definitions and macros for building register tables for chipset + initialization.. + + Components linking this lib must include CpuIo, PciRootBridgeIo, and + BootScriptSave protocols in their DPX. + +Revision History: + +--*/ + +#ifndef EFI_REG_TABLE_H +#define EFI_REG_TABLE_H + +#include "Tiano.h" +#include "EfiScriptLib.h" +#include EFI_PROTOCOL_CONSUMER (CpuIo) +#include EFI_PROTOCOL_CONSUMER (PciRootBridgeIo) + +// +// RegTable OpCodes are encoded as follows: +// +// |31----------------------------16|15---------8|7-------0| +// \ \ \ +// \ \ \ +// 31:16 defined by Base OpCode---+ \ \ +// Opcode Flags---+ \ +// Base OpCode---+ +// +#define OPCODE_BASE(OpCode) ((UINT8)((OpCode) & 0xFF)) +#define OPCODE_FLAGS(OpCode) ((UINT8)(((OpCode) >> 8) & 0xFF)) +#define OPCODE_EXTRA_DATA(OpCode) ((UINT16)((OpCode) >> 16)) + +// +// RegTable Base OpCodes +// +#define OP_TERMINATE_TABLE 0 +#define OP_MEM_WRITE 1 +#define OP_MEM_READ_MODIFY_WRITE 2 +#define OP_IO_WRITE 3 +#define OP_IO_READ_MODIFY_WRITE 4 +#define OP_PCI_WRITE 5 +#define OP_PCI_READ_MODIFY_WRITE 6 +#define OP_STALL 7 + +// +// RegTable OpCode Flags +// +#define OPCODE_FLAG_S3SAVE 1 + + +#define TERMINATE_TABLE { (UINT32) OP_TERMINATE_TABLE, (UINT32) 0, (UINT32) 0 } + + +// +// REG_TABLE_ENTRY_PCI_WRITE encodes the width in the upper bits of the OpCode +// as one of the EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH values +// +typedef struct { + UINT32 OpCode; + UINT32 PciAddress; + UINT32 Data; +} EFI_REG_TABLE_PCI_WRITE; + +#define PCI_WRITE(Bus, Dev, Fnc, Reg, Width, Data, S3Flag) \ + { \ + (UINT32) (OP_PCI_WRITE | ((S3Flag) << 8) | ((Width) << 16)), \ + (UINT32) (EFI_PCI_ADDRESS ((Bus), (Dev), (Fnc), (Reg))), \ + (UINT32) (Data), \ + (UINT32) (0) \ + } + +typedef struct { + UINT32 OpCode; + UINT32 PciAddress; + UINT32 OrMask; + UINT32 AndMask; +} EFI_REG_TABLE_PCI_READ_MODIFY_WRITE; + +#define PCI_READ_MODIFY_WRITE(Bus, Dev, Fnc, Reg, Width, OrMask, AndMask, S3Flag) \ + { \ + (UINT32) (OP_PCI_READ_MODIFY_WRITE | ((S3Flag) << 8) | ((Width) << 16)), \ + (UINT32) (EFI_PCI_ADDRESS ((Bus), (Dev), (Fnc), (Reg))), \ + (UINT32) (OrMask), \ + (UINT32) (AndMask) \ + } + +typedef struct { + UINT32 OpCode; + UINT32 MemAddress; + UINT32 OrMask; + UINT32 AndMask; +} EFI_REG_TABLE_MEM_READ_MODIFY_WRITE; + +#define MEM_READ_MODIFY_WRITE(Address, Width, OrMask, AndMask, S3Flag) \ + { \ + (UINT32) (OP_MEM_READ_MODIFY_WRITE | ((S3Flag) << 8) | ((Width) << 16)), \ + (UINT32) (Address), \ + (UINT32) (OrMask), \ + (UINT32) (AndMask) \ + } + +typedef struct { + UINT32 OpCode; + UINT32 Field2; + UINT32 Field3; + UINT32 Field4; +} EFI_REG_TABLE_GENERIC; + +typedef union { + EFI_REG_TABLE_GENERIC Generic; + EFI_REG_TABLE_PCI_WRITE PciWrite; + EFI_REG_TABLE_PCI_READ_MODIFY_WRITE PciReadModifyWrite; + EFI_REG_TABLE_MEM_READ_MODIFY_WRITE MemReadModifyWrite; +} EFI_REG_TABLE; + +VOID +ProcessRegTablePci ( + EFI_REG_TABLE * RegTableEntry, + EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL * PciRootBridgeIo, + EFI_CPU_IO_PROTOCOL * CpuIo + ) +/*++ + +Routine Description: + Processes register table assuming which may contain PCI, IO, MEM, and STALL + entries. + + No parameter checking is done so the caller must be careful about omitting + values for PciRootBridgeIo or CpuIo parameters. If the regtable does + not contain any PCI accesses, it is safe to omit the PciRootBridgeIo (supply + NULL). If the regtable does not contain any IO or Mem entries, it is safe to + omit the CpuIo (supply NULL). + + The RegTableEntry parameter is not checked, but is required. + + gBS is assumed to have been defined and is used when processing stalls. + + The function processes each entry sequentially until an OP_TERMINATE_TABLE + entry is encountered. + +Arguments: + RegTableEntry - A pointer to the register table to process + + PciRootBridgeIo - A pointer to the instance of PciRootBridgeIo that is used + when processing PCI table entries + + CpuIo - A pointer to the instance of CpuIo that is used when processing IO and + MEM table entries + +Returns: + Nothing. + +--*/ +; + +VOID +ProcessRegTableCpu ( + EFI_REG_TABLE * RegTableEntry, + EFI_CPU_IO_PROTOCOL * CpuIo + ) +/*++ + +Routine Description: + Processes register table assuming which may contain IO, MEM, and STALL + entries, but must NOT contain any PCI entries. Any PCI entries cause an + ASSERT in a DEBUG build and are skipped in a free build. + + No parameter checking is done. Both RegTableEntry and CpuIo parameters are + required. + + gBS is assumed to have been defined and is used when processing stalls. + + The function processes each entry sequentially until an OP_TERMINATE_TABLE + entry is encountered. + +Arguments: + RegTableEntry - A pointer to the register table to process + + CpuIo - A pointer to the instance of CpuIo that is used when processing IO and + MEM table entries + +Returns: + Nothing. + +--*/ +; + +#endif diff --git a/EDK/Foundation/Library/Dxe/Include/EfiRuntimeLib.h b/EDK/Foundation/Library/Dxe/Include/EfiRuntimeLib.h new file mode 100644 index 0000000..b2ae8a0 --- /dev/null +++ b/EDK/Foundation/Library/Dxe/Include/EfiRuntimeLib.h @@ -0,0 +1,1691 @@ +/*++ + +Copyright (c) 2004 - 2007, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + EfiRuntimeLib.h + +Abstract: + + Light weight lib to support EFI drivers. + +--*/ + +#ifndef _EFI_RUNTIME_LIB_H_ +#define _EFI_RUNTIME_LIB_H_ +#define MAX_FVB_COUNT 16 +#include "EfiStatusCode.h" +#include "EfiCommonLib.h" + +#include "LinkedList.h" +#include "GetImage.h" +#include "RtDevicePath.h" + +#include EFI_GUID_DEFINITION (DxeServices) +#include EFI_GUID_DEFINITION (EventGroup) +#include EFI_GUID_DEFINITION (EventLegacyBios) +#include EFI_PROTOCOL_DEFINITION (CpuIo) +#include EFI_PROTOCOL_DEFINITION (FirmwareVolume) +#include EFI_PROTOCOL_DEFINITION (FirmwareVolume2) //;;## ...AMI_OVERRIDE... Support PI1.x +#include EFI_PROTOCOL_DEFINITION (FirmwareVolumeBlock) +#include EFI_PROTOCOL_DEFINITION (FvbExtension) +#include "ProcDep.h" + +typedef struct { + EFI_HANDLE Handle; + EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *Fvb; + EFI_FVB_EXTENSION_PROTOCOL *FvbExtension; +} FVB_ENTRY; + +// +// Driver Lib Globals. +// +extern EFI_BOOT_SERVICES *gBS; +extern EFI_SYSTEM_TABLE *gST; +extern EFI_DXE_SERVICES *gDS; +extern UINTN gRtErrorLevel; +extern FVB_ENTRY *mFvbEntry; + +VOID +EFIAPI +EfiRuntimeLibFvbVirtualNotifyEvent ( + IN EFI_EVENT Event, + IN VOID *Context + ) +/*++ + +Routine Description: + + Notify function to convert pointers to Fvb functions after ExitBootServices + +Arguments: + + Event - Event whose notification function is being invoked. + Context - Pointer to the notification function¡¯s context, which is + implementation-dependent. + +Returns: + + None + +--*/ +; + +EFI_STATUS +EfiInitializeRuntimeDriverLib ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable, + IN EFI_EVENT_NOTIFY RuntimeNotifyEventHandler + ) +/*++ + +Routine Description: + + Intialize Runtime Driver Lib if it has not yet been initialized. + +Arguments: + + ImageHandle - The firmware allocated handle for the EFI image. + + SystemTable - A pointer to the EFI System Table. + + RuntimeNotifyEventHandler - Virtual address change notification event + +Returns: + + EFI_STATUS always returns EFI_SUCCESS + +--*/ +; + +EFI_STATUS +EfiShutdownRuntimeDriverLib ( + VOID + ) +/*++ + +Routine Description: + + This routine will free some resources which have been allocated in + EfiInitializeRuntimeDriverLib(). If a runtime driver exits with an error, + it must call this routine to free the allocated resource before the exiting. + +Arguments: + + None + +Returns: + + EFI_SUCCESS - Shotdown the Runtime Driver Lib successfully + EFI_UNSUPPORTED - Runtime Driver lib was not initialized at all + +--*/ +; + +EFI_STATUS +EfiInitializeSmmDriverLib ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +/*++ + +Routine Description: + + Intialize Smm Driver Lib if it has not yet been initialized. + +Arguments: + + ImageHandle - The firmware allocated handle for the EFI image. + + SystemTable - A pointer to the EFI System Table. + +Returns: + + EFI_STATUS always returns EFI_SUCCESS + +--*/ +; + +EFI_STATUS +EfiLibGetSystemConfigurationTable ( + IN EFI_GUID *TableGuid, + IN OUT VOID **Table + ) +/*++ + +Routine Description: + + Return the EFI 1.0 System Tabl entry with TableGuid + +Arguments: + + TableGuid - Name of entry to return in the system table + Table - Pointer in EFI system table associated with TableGuid + +Returns: + + EFI_SUCCESS - Table returned; + EFI_NOT_FOUND - TableGuid not in EFI system table + +--*/ +; + +BOOLEAN +EfiAtRuntime ( + VOID + ) +/*++ + +Routine Description: + + Am I at runtime? + +Arguments: + + None + +Returns: + + TRUE - At runtime + FALSE - Not at runtime + +--*/ +; + +BOOLEAN +EfiGoneVirtual ( + VOID + ) +/*++ + +Routine Description: + Return TRUE if SetVirtualAddressMap () has been called + +Arguments: + NONE + +Returns: + TRUE - If SetVirtualAddressMap () has been called + FALSE - If SetVirtualAddressMap () has not been called + +--*/ +; + +EFI_STATUS +EfiLibGetSystemConfigurationTable ( + IN EFI_GUID *TableGuid, + IN OUT VOID **Table + ) +/*++ + + + +Routine Description: + + + + Get table from configuration table by name + + + +Arguments: + + + + TableGuid - Table name to search + + + + Table - Pointer to the table caller wants + + + +Returns: + + + + EFI_NOT_FOUND - Not found the table + + + + EFI_SUCCESS - Found the table + + + +--*/ + +; + +EFI_EVENT +RtEfiLibCreateProtocolNotifyEvent ( + IN EFI_GUID *ProtocolGuid, + IN EFI_TPL NotifyTpl, + IN EFI_EVENT_NOTIFY NotifyFunction, + IN VOID *NotifyContext, + OUT VOID **Registration + ) +/*++ + +Routine Description: + + Create a protocol notification event and return it. + +Arguments: + + ProtocolGuid - Protocol to register notification event on. + + NotifyTpl - Maximum TPL to single the NotifyFunction. + + NotifyFunction - EFI notification routine. + + NotifyContext - Context passed into Event when it is created. + + Registration - Registration key returned from RegisterProtocolNotify(). + +Returns: + + The EFI_EVENT that has been registered to be signaled when a ProtocolGuid + is added to the system. + +--*/ +; + +// +// Lock.c +// +typedef struct { + EFI_TPL Tpl; + EFI_TPL OwnerTpl; + UINTN Lock; +} EFI_LOCK; + +VOID +EfiInitializeLock ( + IN OUT EFI_LOCK *Lock, + IN EFI_TPL Priority + ) +/*++ + +Routine Description: + + Initialize a basic mutual exclusion lock. Each lock + provides mutual exclusion access at it's task priority + level. Since there is no-premption (at any TPL) or + multiprocessor support, acquiring the lock only consists + of raising to the locks TPL. + + Note on a check build ASSERT()s are used to ensure proper + lock usage. + +Arguments: + + Lock - The EFI_LOCK structure to initialize + + Priority - The task priority level of the lock + + +Returns: + + An initialized Efi Lock structure. + +--*/ +; + +// +// Macro to initialize the state of a lock when a lock variable is declared +// +#define EFI_INITIALIZE_LOCK_VARIABLE(Tpl) {Tpl,0,0} + + +VOID +EfiAcquireLock ( + IN EFI_LOCK *Lock + ) +/*++ + +Routine Description: + + Raising to the task priority level of the mutual exclusion + lock, and then acquires ownership of the lock. + +Arguments: + + Lock - The lock to acquire + +Returns: + + Lock owned + +--*/ +; + +EFI_STATUS +EfiAcquireLockOrFail ( + IN EFI_LOCK *Lock + ) +/*++ + +Routine Description: + + Initialize a basic mutual exclusion lock. Each lock + provides mutual exclusion access at it's task priority + level. Since there is no-premption (at any TPL) or + multiprocessor support, acquiring the lock only consists + of raising to the locks TPL. + +Arguments: + + Lock - The EFI_LOCK structure to initialize + +Returns: + + EFI_SUCCESS - Lock Owned. + EFI_ACCESS_DENIED - Reentrant Lock Acquisition, Lock not Owned. + +--*/ +; + +VOID +EfiReleaseLock ( + IN EFI_LOCK *Lock + ) +/*++ + +Routine Description: + + Releases ownership of the mutual exclusion lock, and + restores the previous task priority level. + +Arguments: + + Lock - The lock to release + +Returns: + + None + +--*/ +; + +#define EfiCopyMem EfiCommonLibCopyMem +#define EfiSetMem EfiCommonLibSetMem +#define EfiZeroMem EfiCommonLibZeroMem + +INTN +EfiCompareMem ( + IN VOID *MemOne, + IN VOID *MemTwo, + IN UINTN Len + ) +/*++ + +Routine Description: + + Compares two memory buffers of a given length. + +Arguments: + + MemOne - First memory buffer + + MemTwo - Second memory buffer + + Len - Length of Mem1 and Mem2 memory regions to compare + +Returns: + + = 0 if MemOne == MemTwo + + > 0 if MemOne > MemTwo + + < 0 if MemOne < MemTwo + +--*/ +; + +// +// Debug.c init +// +EFI_STATUS +EfiDebugAssertInit ( + VOID + ) +/*++ + +Routine Description: + + Locate Debug Assert Protocol and set as mDebugAssert + +Arguments: + + None + +Returns: + + Status code + +--*/ +; + +// +// Wrapper for EFI runtime functions +// +VOID +EfiResetSystem ( + IN EFI_RESET_TYPE ResetType, + IN EFI_STATUS ResetStatus, + IN UINTN DataSize, + IN CHAR16 *ResetData + ) +/*++ + +Routine Description: + + Resets the entire platform. + +Arguments: + + ResetType - The type of reset to perform. + ResetStatus - The status code for the reset. + DataSize - The size, in bytes, of ResetData. + ResetData - A data buffer that includes a Null-terminated Unicode string, optionally + followed by additional binary data. + +Returns: + + None + +--*/ +; + +EFI_STATUS +EfiGetNextHighMonotonicCount ( + OUT UINT32 *HighCount + ) +/*++ + +Routine Description: + + Returns the next high 32 bits of the platform¡¯s monotonic counter. + +Arguments: + + HighCount - Pointer to returned value. + +Returns: + + Status code + +--*/ +; + +EFI_STATUS +EfiGetTime ( + OUT EFI_TIME *Time, + OUT EFI_TIME_CAPABILITIES *Capabilities + ) +/*++ + +Routine Description: + + Returns the current time and date information, and the time-keeping + capabilities of the hardware platform. + +Arguments: + + Time - A pointer to storage to receive a snapshot of the current time. + Capabilities - An optional pointer to a buffer to receive the real time clock device¡¯s + capabilities. + +Returns: + + Status code + +--*/ +; + +EFI_STATUS +EfiSetTime ( + OUT EFI_TIME *Time + ) +/*++ + +Routine Description: + + Sets the current local time and date information. + +Arguments: + + Time - A pointer to the current time. + +Returns: + + Status code + +--*/ +; + +EFI_STATUS +EfiGetWakeupTime ( + OUT BOOLEAN *Enabled, + OUT BOOLEAN *Pending, + OUT EFI_TIME *Time + ) +/*++ + +Routine Description: + + Returns the current wakeup alarm clock setting. + +Arguments: + + Enabled - Indicates if the alarm is currently enabled or disabled. + Pending - Indicates if the alarm signal is pending and requires acknowledgement. + Time - The current alarm setting. + +Returns: + + Status code + +--*/ +; + +EFI_STATUS +EfiSetWakeupTime ( + IN BOOLEAN Enable, + IN EFI_TIME *Time + ) +/*++ + +Routine Description: + + Sets the system wakeup alarm clock time. + +Arguments: + + Enable - Enable or disable the wakeup alarm. + Time - If Enable is TRUE, the time to set the wakeup alarm for. + If Enable is FALSE, then this parameter is optional, and may be NULL. + +Returns: + + Status code + +--*/ +; + +EFI_STATUS +EfiGetVariable ( + IN CHAR16 *VariableName, + IN EFI_GUID * VendorGuid, + OUT UINT32 *Attributes OPTIONAL, + IN OUT UINTN *DataSize, + OUT VOID *Data + ) +/*++ + +Routine Description: + + Returns the value of a variable. + +Arguments: + + VariableName - A Null-terminated Unicode string that is the name of the + vendor¡¯s variable. + VendorGuid - A unique identifier for the vendor. + Attributes - If not NULL, a pointer to the memory location to return the + attributes bitmask for the variable. + DataSize - On input, the size in bytes of the return Data buffer. + On output the size of data returned in Data. + Data - The buffer to return the contents of the variable. + +Returns: + + Status code + +--*/ +; + +EFI_STATUS +EfiGetNextVariableName ( + IN OUT UINTN *VariableNameSize, + IN OUT CHAR16 *VariableName, + IN OUT EFI_GUID *VendorGuid + ) +/*++ + +Routine Description: + + Enumerates the current variable names. + +Arguments: + + VariableNameSize - The size of the VariableName buffer. + VariableName - On input, supplies the last VariableName that was returned + by GetNextVariableName(). + On output, returns the Nullterminated Unicode string of the + current variable. + VendorGuid - On input, supplies the last VendorGuid that was returned by + GetNextVariableName(). + On output, returns the VendorGuid of the current variable. + +Returns: + + Status code + +--*/ +; + +EFI_STATUS +EfiSetVariable ( + IN CHAR16 *VariableName, + IN EFI_GUID *VendorGuid, + IN UINT32 Attributes, + IN UINTN DataSize, + IN VOID *Data + ) +/*++ + +Routine Description: + + Sets the value of a variable. + +Arguments: + + VariableName - A Null-terminated Unicode string that is the name of the + vendor¡¯s variable. + VendorGuid - A unique identifier for the vendor. + Attributes - Attributes bitmask to set for the variable. + DataSize - The size in bytes of the Data buffer. + Data - The contents for the variable. + +Returns: + + Status code + +--*/ +; + +#if (EFI_SPECIFICATION_VERSION >= 0x00020000) + +EFI_STATUS +EfiQueryVariableInfo ( + IN UINT32 Attributes, + OUT UINT64 *MaximumVariableStorageSize, + OUT UINT64 *RemainingVariableStorageSize, + OUT UINT64 *MaximumVariableSize + ) +/*++ + +Routine Description: + + This code returns information about the EFI variables. + +Arguments: + + Attributes Attributes bitmask to specify the type of variables + on which to return information. + MaximumVariableStorageSize Pointer to the maximum size of the storage space available + for the EFI variables associated with the attributes specified. + RemainingVariableStorageSize Pointer to the remaining size of the storage space available + for the EFI variables associated with the attributes specified. + MaximumVariableSize Pointer to the maximum size of the individual EFI variables + associated with the attributes specified. + +Returns: + + Status code + +--*/ +; +#endif + + +EFI_STATUS +EfiReportStatusCode ( + IN EFI_STATUS_CODE_TYPE CodeType, + IN EFI_STATUS_CODE_VALUE Value, + IN UINT32 Instance, + IN EFI_GUID * CallerId, + IN EFI_STATUS_CODE_DATA * Data OPTIONAL + ) +/*++ + +Routine Description: + + Status Code reporter + +Arguments: + + CodeType - Type of Status Code. + + Value - Value to output for Status Code. + + Instance - Instance Number of this status code. + + CallerId - ID of the caller of this status code. + + Data - Optional data associated with this status code. + +Returns: + + Status code + +--*/ +; + +EFI_STATUS +EfiConvertPointer ( + IN UINTN DebugDisposition, + IN OUT VOID *Address + ) +/*++ + +Routine Description: + + Determines the new virtual address that is to be used on subsequent memory accesses. + +Arguments: + + DebugDisposition - Supplies type information for the pointer being converted. + Address - A pointer to a pointer that is to be fixed to be the value needed + for the new virtual address mappings being applied. + +Returns: + + Status code + +--*/ +; + +EFI_STATUS +EfiConvertList ( + IN UINTN DebugDisposition, + IN OUT EFI_LIST_ENTRY *ListHead + ) +/*++ + +Routine Description: + + Conver the standard Lib double linked list to a virtual mapping. + +Arguments: + + DebugDisposition - Argument to EfiConvertPointer (EFI 1.0 API) + + ListHead - Head of linked list to convert + +Returns: + + EFI_SUCCESS + +--*/ +; + +// +// Base IO Class Functions +// +EFI_STATUS +EfiIoRead ( + IN EFI_CPU_IO_PROTOCOL_WIDTH Width, + IN UINT64 Address, + IN UINTN Count, + IN OUT VOID *Buffer + ) +/*++ + +Routine Description: + Perform an IO read into Buffer. + +Arguments: + Width - Width of read transaction, and repeat operation to use + Address - IO address to read + Count - Number of times to read the IO address. + Buffer - Buffer to read data into. size is Width * Count + +Returns: + Status code + +--*/ +; + +UINT8 +IoRead8 ( + IN UINT64 Address + ) +/*++ + +Routine Description: + Do a one byte IO read + +Arguments: + Address - IO address to read + +Returns: + Data read + +--*/ +; + +UINT16 +IoRead16 ( + IN UINT64 Address + ) +/*++ + +Routine Description: + Do a two byte IO read + +Arguments: + Address - IO address to read + +Returns: + Data read + +--*/ +; + +UINT32 +IoRead32 ( + IN UINT64 Address + ) +/*++ + +Routine Description: + Do a four byte IO read + +Arguments: + Address - IO address to read + +Returns: + Data read + +--*/ +; + +EFI_STATUS +EfiIoWrite ( + IN EFI_CPU_IO_PROTOCOL_WIDTH Width, + IN UINT64 Address, + IN UINTN Count, + IN OUT VOID *Buffer + ) +/*++ + +Routine Description: + Perform an IO write into Buffer. + +Arguments: + Width - Width of write transaction, and repeat operation to use + Address - IO address to write + Count - Number of times to write the IO address. + Buffer - Buffer to write data from. size is Width * Count + +Returns: + Status code + +--*/ +; + +VOID +IoWrite8 ( + IN UINT64 Address, + IN UINT8 Data + ) +/*++ + +Routine Description: + Do a one byte IO write + +Arguments: + Address - IO address to write + Data - Data to write to Address + +Returns: + NONE + +--*/ +; + +VOID +IoWrite16 ( + IN UINT64 Address, + IN UINT16 Data + ) +/*++ + +Routine Description: + Do a two byte IO write + +Arguments: + Address - IO address to write + Data - Data to write to Address + +Returns: + NONE + +--*/ +; + +VOID +IoWrite32 ( + IN UINT64 Address, + IN UINT32 Data + ) +/*++ + +Routine Description: + Do a four byte IO write + +Arguments: + Address - IO address to write + Data - Data to write to Address + +Returns: + NONE + +--*/ +; + +EFI_STATUS +EfiMemRead ( + IN EFI_CPU_IO_PROTOCOL_WIDTH Width, + IN UINT64 Address, + IN UINTN Count, + IN OUT VOID *Buffer + ) +/*++ + +Routine Description: + Perform a Memory mapped IO read into Buffer. + +Arguments: + Width - Width of each read transaction. + Address - Memory mapped IO address to read + Count - Number of Width quanta to read + Buffer - Buffer to read data into. size is Width * Count + +Returns: + Status code + +--*/ +; + +UINT8 +MemRead8 ( + IN UINT64 Address + ) +/*++ + +Routine Description: + Do a one byte Memory mapped IO read + +Arguments: + Address - Memory mapped IO address to read + +Returns: + Data read + +--*/ +; + +UINT16 +MemRead16 ( + IN UINT64 Address + ) +/*++ + +Routine Description: + Do a two byte Memory mapped IO read + +Arguments: + Address - Memory mapped IO address to read + +Returns: + Data read + +--*/ +; + +UINT32 +MemRead32 ( + IN UINT64 Address + ) +/*++ + +Routine Description: + Do a four byte Memory mapped IO read + +Arguments: + Address - Memory mapped IO address to read + +Returns: + Data read + +--*/ +; + +UINT64 +MemRead64 ( + IN UINT64 Address + ) +/*++ + +Routine Description: + Do a eight byte Memory mapped IO read + +Arguments: + Address - Memory mapped IO address to read + +Returns: + Data read + +--*/ +; + +EFI_STATUS +EfiMemWrite ( + IN EFI_CPU_IO_PROTOCOL_WIDTH Width, + IN UINT64 Address, + IN UINTN Count, + IN OUT VOID *Buffer + ) +/*++ + +Routine Description: + Perform a memory mapped IO write into Buffer. + +Arguments: + Width - Width of write transaction, and repeat operation to use + Address - IO address to write + Count - Number of times to write the IO address. + Buffer - Buffer to write data from. size is Width * Count + +Returns: + Status code + +--*/ +; + +VOID +MemWrite8 ( + IN UINT64 Address, + IN UINT8 Data + ) +/*++ + +Routine Description: + Do a one byte Memory mapped IO write + +Arguments: + Address - Memory mapped IO address to write + Data - Data to write to Address + +Returns: + NONE + +--*/ +; + +VOID +MemWrite16 ( + IN UINT64 Address, + IN UINT16 Data + ) +/*++ + +Routine Description: + Do a two byte Memory mapped IO write + +Arguments: + Address - Memory mapped IO address to write + Data - Data to write to Address + +Returns: + NONE + +--*/ +; + +VOID +MemWrite32 ( + IN UINT64 Address, + IN UINT32 Data + ) +/*++ + +Routine Description: + Do a four byte Memory mapped IO write + +Arguments: + Address - Memory mapped IO address to write + Data - Data to write to Address + +Returns: + NONE + +--*/ +; + +VOID +MemWrite64 ( + IN UINT64 Address, + IN UINT64 Data + ) +/*++ + +Routine Description: + Do a eight byte Memory mapped IO write + +Arguments: + Address - Memory mapped IO address to write + Data - Data to write to Address + +Returns: + NONE + +--*/ +; + +// +// Platform specific functions +// +UINT8 +PciRead8 ( + UINT8 Segment, + UINT8 Bus, + UINT8 DevFunc, + UINT8 Register + ) +/*++ + +Routine Description: + Perform an one byte PCI config cycle read + +Arguments: + Segment - PCI Segment ACPI _SEG + Bus - PCI Bus + DevFunc - PCI Device(7:3) and Func(2:0) + Register - PCI config space register + +Returns: + Data read from PCI config space + +--*/ +; + +UINT16 +PciRead16 ( + UINT8 Segment, + UINT8 Bus, + UINT8 DevFunc, + UINT8 Register + ) +/*++ + +Routine Description: + Perform an two byte PCI config cycle read + +Arguments: + Segment - PCI Segment ACPI _SEG + Bus - PCI Bus + DevFunc - PCI Device(7:3) and Func(2:0) + Register - PCI config space register + +Returns: + Data read from PCI config space + +--*/ +; + +UINT32 +PciRead32 ( + UINT8 Segment, + UINT8 Bus, + UINT8 DevFunc, + UINT8 Register + ) +/*++ + +Routine Description: + Perform an four byte PCI config cycle read + +Arguments: + Segment - PCI Segment ACPI _SEG + Bus - PCI Bus + DevFunc - PCI Device(7:3) and Func(2:0) + Register - PCI config space register + +Returns: + Data read from PCI config space + +--*/ +; + +VOID +PciWrite8 ( + UINT8 Segment, + UINT8 Bus, + UINT8 DevFunc, + UINT8 Register, + UINT8 Data + ) +/*++ + +Routine Description: + Perform an one byte PCI config cycle write + +Arguments: + Segment - PCI Segment ACPI _SEG + Bus - PCI Bus + DevFunc - PCI Device(7:3) and Func(2:0) + Register - PCI config space register + Data - Data to write + +Returns: + NONE + +--*/ +; + +VOID +PciWrite16 ( + UINT8 Segment, + UINT8 Bus, + UINT8 DevFunc, + UINT8 Register, + UINT16 Data + ) +/*++ + +Routine Description: + Perform an two byte PCI config cycle write + +Arguments: + Segment - PCI Segment ACPI _SEG + Bus - PCI Bus + DevFunc - PCI Device(7:3) and Func(2:0) + Register - PCI config space register + Data - Data to write + +Returns: + NONE + +--*/ +; + +VOID +PciWrite32 ( + UINT8 Segment, + UINT8 Bus, + UINT8 DevFunc, + UINT8 Register, + UINT32 Data + ) +/*++ + +Routine Description: + Perform an four byte PCI config cycle write + +Arguments: + Segment - PCI Segment ACPI _SEG + Bus - PCI Bus + DevFunc - PCI Device(7:3) and Func(2:0) + Register - PCI config space register + Data - Data to write + +Returns: + NONE + +--*/ +; + +VOID +EfiStall ( + IN UINTN Microseconds + ) +/*++ + +Routine Description: + Delay for at least the request number of microseconds + +Arguments: + Microseconds - Number of microseconds to delay. + +Returns: + NONE + +--*/ +; + +// +// FVB Services. +// +EFI_STATUS +EfiFvbInitialize ( + VOID + ) +/*++ + +Routine Description: + Initialize globals and register Fvb Protocol notification function. + +Arguments: + None + +Returns: + EFI_SUCCESS + +--*/ +; + +EFI_STATUS +EfiFvbShutdown ( + VOID + ) +/*++ + +Routine Description: + Release resources allocated in EfiFvbInitialize. + +Arguments: + None + +Returns: + EFI_SUCCESS + +--*/ +; + +EFI_STATUS +EfiFvbReadBlock ( + IN UINTN Instance, + IN EFI_LBA Lba, + IN UINTN Offset, + IN OUT UINTN *NumBytes, + IN UINT8 *Buffer + ) +/*++ + +Routine Description: + Reads specified number of bytes into a buffer from the specified block + +Arguments: + Instance - The FV instance to be read from + Lba - The logical block address to be read from + Offset - Offset into the block at which to begin reading + NumBytes - Pointer that on input contains the total size of + the buffer. On output, it contains the total number + of bytes read + Buffer - Pointer to a caller allocated buffer that will be + used to hold the data read + +Returns: + Status code + +--*/ +; + +EFI_STATUS +EfiFvbWriteBlock ( + IN UINTN Instance, + IN EFI_LBA Lba, + IN UINTN Offset, + IN OUT UINTN *NumBytes, + IN UINT8 *Buffer + ) +/*++ + +Routine Description: + Writes specified number of bytes from the input buffer to the block + +Arguments: + Instance - The FV instance to be written to + Lba - The starting logical block index to write to + Offset - Offset into the block at which to begin writing + NumBytes - Pointer that on input contains the total size of + the buffer. On output, it contains the total number + of bytes actually written + Buffer - Pointer to a caller allocated buffer that contains + the source for the write + +Returns: + Status code + +--*/ +; + +EFI_STATUS +EfiFvbEraseBlock ( + IN UINTN Instance, + IN EFI_LBA Lba + ) +/*++ + +Routine Description: + Erases and initializes a firmware volume block + +Arguments: + Instance - The FV instance to be erased + Lba - The logical block index to be erased + +Returns: + Status code + +--*/ +; + +EFI_STATUS +EfiFvbGetVolumeAttributes ( + IN UINTN Instance, + OUT EFI_FVB_ATTRIBUTES *Attributes + ) +/*++ + +Routine Description: + Retrieves attributes, insures positive polarity of attribute bits, returns + resulting attributes in output parameter + +Arguments: + Instance - The FV instance whose attributes is going to be + returned + Attributes - Output buffer which contains attributes + +Returns: + Status code + +--*/ +; + +EFI_STATUS +EfiFvbSetVolumeAttributes ( + IN UINTN Instance, + IN EFI_FVB_ATTRIBUTES Attributes + ) +/*++ + +Routine Description: + Modifies the current settings of the firmware volume according to the + input parameter. + +Arguments: + Instance - The FV instance whose attributes is going to be + modified + Attributes - It is a pointer to EFI_FVB_ATTRIBUTES + containing the desired firmware volume settings. + +Returns: + Status code + +--*/ +; + +EFI_STATUS +EfiFvbGetPhysicalAddress ( + IN UINTN Instance, + OUT EFI_PHYSICAL_ADDRESS *Address + ) +/*++ + +Routine Description: + Retrieves the physical address of a memory mapped FV + +Arguments: + Instance - The FV instance whose base address is going to be + returned + Address - Pointer to a caller allocated EFI_PHYSICAL_ADDRESS + that on successful return, contains the base address + of the firmware volume. + +Returns: + Status code + +--*/ +; + +EFI_STATUS +EfiFvbGetBlockSize ( + IN UINTN Instance, + IN EFI_LBA Lba, + OUT UINTN *BlockSize, + OUT UINTN *NumOfBlocks + ) +/*++ + +Routine Description: + Retrieve the size of a logical block + +Arguments: + Instance - The FV instance whose block size is going to be + returned + Lba - Indicates which block to return the size for. + BlockSize - A pointer to a caller allocated UINTN in which + the size of the block is returned + NumOfBlocks - a pointer to a caller allocated UINTN in which the + number of consecutive blocks starting with Lba is + returned. All blocks in this range have a size of + BlockSize + +Returns: + EFI_SUCCESS - The firmware volume was read successfully and + contents are in Buffer + +--*/ +; +EFI_STATUS +EfiFvbEraseCustomBlockRange ( + IN UINTN Instance, + IN EFI_LBA StartLba, + IN UINTN OffsetStartLba, + IN EFI_LBA LastLba, + IN UINTN OffsetLastLba + ) +/*++ + +Routine Description: + Erases and initializes a specified range of a firmware volume + +Arguments: + Instance - The FV instance to be erased + StartLba - The starting logical block index to be erased + OffsetStartLba - Offset into the starting block at which to + begin erasing + LastLba - The last logical block index to be erased + OffsetLastLba - Offset into the last block at which to end erasing + +Returns: + Status code + +--*/ +; + +EFI_STATUS +EfiCpuFlushCache ( + IN EFI_PHYSICAL_ADDRESS Start, + IN UINT64 Length + ) +/*++ + +Routine Description: + + Flush cache with specified range. + +Arguments: + + Start - Start address + Length - Length in bytes + +Returns: + + Status code + +--*/ +; + +EFI_STATUS +EFIAPI +RtEfiCreateEventLegacyBoot ( + IN EFI_TPL NotifyTpl, + IN EFI_EVENT_NOTIFY NotifyFunction, + IN VOID *NotifyContext, + OUT EFI_EVENT *LegacyBootEvent + ) +/*++ + +Routine Description: + Create a Legacy Boot Event. + Tiano extended the CreateEvent Type enum to add a legacy boot event type. + This was bad as Tiano did not own the enum. In UEFI 2.0 CreateEventEx was + added and now it's possible to not voilate the UEFI specification by + declaring a GUID for the legacy boot event class. This library supports + the R8.5/EFI 1.10 form and R8.6/UEFI 2.0 form and allows common code to + work both ways. + +Arguments: + LegacyBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex) + +Returns: + EFI_SUCCESS Event was created. + Other Event was not created. + +--*/ +; + +EFI_STATUS +EFIAPI +RtEfiCreateEventReadyToBoot ( + IN EFI_TPL NotifyTpl, + IN EFI_EVENT_NOTIFY NotifyFunction, + IN VOID *NotifyContext, + OUT EFI_EVENT *ReadyToBootEvent + ) +/*++ + +Routine Description: + Create a Read to Boot Event. + + Tiano extended the CreateEvent Type enum to add a ready to boot event type. + This was bad as Tiano did not own the enum. In UEFI 2.0 CreateEventEx was + added and now it's possible to not voilate the UEFI specification and use + the ready to boot event class defined in UEFI 2.0. This library supports + the R8.5/EFI 1.10 form and R8.6/UEFI 2.0 form and allows common code to + work both ways. + +Arguments: + ReadyToBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex) + +Return: + EFI_SUCCESS - Event was created. + Other - Event was not created. + +--*/ +; + +#endif diff --git a/EDK/Foundation/Library/Dxe/Include/EfiScriptLib.h b/EDK/Foundation/Library/Dxe/Include/EfiScriptLib.h new file mode 100644 index 0000000..53b523f --- /dev/null +++ b/EDK/Foundation/Library/Dxe/Include/EfiScriptLib.h @@ -0,0 +1,570 @@ +/*++ + +Copyright (c) 2004 - 2008, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + EfiScriptLib.h + +Abstract: + + +--*/ + +#ifndef _EFI_SCRIPT_LIB_H_ +#define _EFI_SCRIPT_LIB_H_ + +#include "Tiano.h" +#include "EfiCommonLib.h" +#include "EfiBootScript.h" +#include EFI_PROTOCOL_DEFINITION (BootScriptSave) + + +EFI_STATUS +EFIAPI +BootScriptSaveInitialize ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +/*++ + +Routine Description: + + Intialize Boot Script Lib if it has not yet been initialized. + +Arguments: + + ImageHandle - The firmware allocated handle for the EFI image. + + SystemTable - A pointer to the EFI System Table. + +Returns: + + EFI_STATUS always returns EFI_SUCCESS + +--*/ +; + +EFI_STATUS +EFIAPI +BootScriptSaveIoWrite ( + IN UINT16 TableName, + IN EFI_BOOT_SCRIPT_WIDTH Width, + IN UINT64 Address, + IN UINTN Count, + IN VOID *Buffer + ) +/*++ + +Routine Description: + + Save I/O write to boot script with opcode EFI_BOOT_SCRIPT_IO_WRITE_OPCODE + +Arguments: + + TableName - Desired boot script table + + Width - The width of the I/O operations. + + Address - The base address of the I/O operations. + + Count - The number of I/O operations to perform. + + Buffer - The source buffer from which to write data. + +Returns: + + EFI_NOT_FOUND - BootScriptSave Protocol not exist. + + EFI_STATUS - BootScriptSave Protocol exist, always returns EFI_SUCCESS + +--*/ +; + +EFI_STATUS +EFIAPI +BootScriptSaveIoReadWrite ( + IN UINT16 TableName, + IN EFI_BOOT_SCRIPT_WIDTH Width, + IN UINT64 Address, + IN VOID *Data, + IN VOID *DataMask + ) +/*++ + +Routine Description: + + Save I/O modify to boot script with opcode EFI_BOOT_SCRIPT_IO_READ_WRITE_OPCODE + +Arguments: + + TableName - Desired boot script table + + Width - The width of the I/O operations. + + Address - The base address of the I/O operations. + + Data - A pointer to the data to be OR-ed. + + DataMask - A pointer to the data mask to be AND-ed with the data read from the register. + +Returns: + + EFI_NOT_FOUND - BootScriptSave Protocol not exist. + + EFI_STATUS - BootScriptSave Protocol exist, always returns EFI_SUCCESS + +--*/ +; + +EFI_STATUS +EFIAPI +BootScriptSaveMemWrite ( + IN UINT16 TableName, + IN EFI_BOOT_SCRIPT_WIDTH Width, + IN UINT64 Address, + IN UINTN Count, + IN VOID *Buffer + ) +/*++ + +Routine Description: + + Save memory write to boot script with opcode EFI_BOOT_SCRIPT_MEM_WRITE_OPCODE + +Arguments: + + TableName - Desired boot script table + + Width - The width of the memory operations. + + Address - The base address of the memory operations. + + Count - The number of memory operations to perform. + + Buffer - The source buffer from which to write the data. + +Returns: + + EFI_NOT_FOUND - BootScriptSave Protocol not exist. + + EFI_STATUS - BootScriptSave Protocol exist, always returns EFI_SUCCESS + +--*/ +; + +EFI_STATUS +EFIAPI +BootScriptSaveMemReadWrite ( + IN UINT16 TableName, + IN EFI_BOOT_SCRIPT_WIDTH Width, + IN UINT64 Address, + IN VOID *Data, + IN VOID *DataMask + ) +/*++ + +Routine Description: + + Save memory modify to boot script with opcode EFI_BOOT_SCRIPT_MEM_READ_WRITE_OPCODE + +Arguments: + + TableName - Desired boot script table + + Width - The width of the memory operations. + + Address - The base address of the memory operations. + + Data - A pointer to the data to be OR-ed. + + DataMask - A pointer to the data mask to be AND-ed with the data read from the register. + +Returns: + + EFI_NOT_FOUND - BootScriptSave Protocol not exist. + + EFI_STATUS - BootScriptSave Protocol exist, always returns EFI_SUCCESS + +--*/ +; + +EFI_STATUS +EFIAPI +BootScriptSavePciCfgWrite ( + IN UINT16 TableName, + IN EFI_BOOT_SCRIPT_WIDTH Width, + IN UINT64 Address, + IN UINTN Count, + IN VOID *Buffer + ) +/*++ + +Routine Description: + + Save PCI configuration space write operation to boot script with opcode + EFI_BOOT_SCRIPT_PCI_CONFIG_WRITE_OPCODE + +Arguments: + + TableName - Desired boot script table + + Width - The width of the PCI operations + + Address - The address within the PCI configuration space. + + Count - The number of PCI operations to perform. + + Buffer - The source buffer from which to write the data. + +Returns: + + EFI_NOT_FOUND - BootScriptSave Protocol not exist. + + EFI_STATUS - BootScriptSave Protocol exist, always returns EFI_SUCCESS + +--*/ +; + +EFI_STATUS +EFIAPI +BootScriptSavePciCfgReadWrite ( + IN UINT16 TableName, + IN EFI_BOOT_SCRIPT_WIDTH Width, + IN UINT64 Address, + IN VOID *Data, + IN VOID *DataMask + ) +/*++ + +Routine Description: + + Save PCI configuration space modify operation to boot script with opcode + EFI_BOOT_SCRIPT_PCI_CONFIG_READ_WRITE_OPCODE + +Arguments: + + TableName - Desired boot script table + + Width - The width of the PCI operations + + Address - The address within the PCI configuration space. + + Data - A pointer to the data to be OR-ed. + + DataMask - A pointer to the data mask to be AND-ed with the data read from the register. + +Returns: + + EFI_NOT_FOUND - BootScriptSave Protocol not exist. + + EFI_STATUS - BootScriptSave Protocol exist, always returns EFI_SUCCESS + +--*/ +; +; + +EFI_STATUS +EFIAPI +BootScriptSaveSmbusExecute ( + IN UINT16 TableName, + IN EFI_SMBUS_DEVICE_ADDRESS SlaveAddress, + IN EFI_SMBUS_DEVICE_COMMAND Command, + IN EFI_SMBUS_OPERATION Operation, + IN BOOLEAN PecCheck, + IN UINTN *Length, + IN VOID *Buffer + ) +/*++ + +Routine Description: + + Save SMBus command execution to boot script with opcode + EFI_BOOT_SCRIPT_SMBUS_EXECUTE_OPCODE + +Arguments: + + TableName - Desired boot script table + SlaveAddress - The SMBus address for the slave device that the operation is targeting. + Command - The command that is transmitted by the SMBus host controller to the + SMBus slave device. + Operation - Indicates which particular SMBus protocol it will use to execute the + SMBus transactions. + PecCheck - Defines if Packet Error Code (PEC) checking is required for this operation. + Length - A pointer to signify the number of bytes that this operation will do. + Buffer - Contains the value of data to execute to the SMBUS slave device. + +Returns: + + EFI_NOT_FOUND - BootScriptSave Protocol not exist. + + EFI_STATUS - BootScriptSave Protocol exist, always returns EFI_SUCCESS + +--*/ +; + +EFI_STATUS +EFIAPI +BootScriptSaveStall ( + IN UINT16 TableName, + IN UINTN Duration + ) +/*++ + +Routine Description: + + Save execution stall on the processor to boot script with opcode + EFI_BOOT_SCRIPT_STALL_OPCODE + +Arguments: + + TableName - Desired boot script table + + Duration - Duration in microseconds of the stall. + +Returns: + + EFI_NOT_FOUND - BootScriptSave Protocol not exist. + + EFI_STATUS - BootScriptSave Protocol exist, always returns EFI_SUCCESS + +--*/ +; + +EFI_STATUS +EFIAPI +BootScriptSaveDispatch ( + IN UINT16 TableName, + IN EFI_PHYSICAL_ADDRESS EntryPoint + ) +/*++ + +Routine Description: + + Save dispatching specified arbitrary code to boot script with opcode + EFI_BOOT_SCRIPT_DISPATCH_OPCODE + +Arguments: + + TableName - Desired boot script table + + EntryPoint - Entry point of the code to be dispatched. + +Returns: + + EFI_NOT_FOUND - BootScriptSave Protocol not exist. + + EFI_STATUS - BootScriptSave Protocol exist, always returns EFI_SUCCESS + +--*/ +; + +EFI_STATUS +EFIAPI +BootScriptMemPoll ( + IN UINT16 TableName, + IN EFI_BOOT_SCRIPT_WIDTH Width, + IN UINT64 Address, + IN VOID *BitMask, + IN VOID *BitValue, + IN UINTN Duration, + IN UINTN LoopTimes + ) +/*++ + +Routine Description: + Polling one memory mapping register + +Arguments: + TableName - Desired boot script table + + Width - The width of the memory operations. + + Address - The base address of the memory operations. + + BitMask - A pointer to the bit mask to be AND-ed with the data read from the register. + + BitValue - A pointer to the data value after to be Masked. + + Duration - Duration in microseconds of the stall. + + LoopTimes - The times of the register polling. + +Returns: + + EFI_SUCCESS - The operation was executed successfully + +--*/ +; + +EFI_STATUS +EFIAPI +BootScriptSaveInformation ( + IN UINT16 TableName, + IN UINT32 Length, + IN EFI_PHYSICAL_ADDRESS Buffer + ) +/*++ + +Routine Description: + + Save a Information Opcode record in table specified with TableName + +Arguments: + + TableName - Desired boot script table + Length - Length of information in bytes + Buffer - Content of information that will be saved in script table + +Returns: + + EFI_NOT_FOUND - BootScriptSave Protocol not exist. + + EFI_STATUS - BootScriptSave Protocol exist, always returns EFI_SUCCESS + +--*/ +; + +EFI_STATUS +EFIAPI +BootScriptSaveInformationUnicodeString ( + IN UINT16 TableName, + IN CHAR16 *String + ) +/*++ + +Routine Description: + + Save a Information Opcode record in table specified with TableName, the information + is a unicode string. + +Arguments: + + TableName - Desired boot script table + String - The string that will be saved in script table + +Returns: + + EFI_NOT_FOUND - BootScriptSave Protocol not exist. + + EFI_STATUS - BootScriptSave Protocol exist, always returns EFI_SUCCESS + +--*/ +; + +EFI_STATUS +EFIAPI +BootScriptSaveInformationAsciiString ( + IN UINT16 TableName, + IN CHAR8 *String + ) +/*++ + +Routine Description: + + Save a Information Opcode record in table specified with TableName, the information + is a ascii string. + +Arguments: + + TableName - Desired boot script table + String - The string that will be saved in script table + +Returns: + + EFI_NOT_FOUND - BootScriptSave Protocol not exist. + + EFI_STATUS - BootScriptSave Protocol exist, always returns EFI_SUCCESS + +--*/ +; + +#ifdef EFI_S3_RESUME + +#define INITIALIZE_SCRIPT(ImageHandle, SystemTable) \ + BootScriptSaveInitialize(ImageHandle, SystemTable) + +#define SCRIPT_IO_WRITE(TableName, Width, Address, Count, Buffer) \ + BootScriptSaveIoWrite(TableName, Width, Address, Count, Buffer) + +#define SCRIPT_IO_READ_WRITE(TableName, Width, Address, Data, DataMask) \ + BootScriptSaveIoReadWrite(TableName, Width, Address, Data, DataMask) + +#define SCRIPT_MEM_WRITE(TableName, Width, Address, Count, Buffer) \ + BootScriptSaveMemWrite(TableName, Width, Address, Count, Buffer) + +#define SCRIPT_MEM_WRITE_THIS(TableName, Width, Address, Count) \ + BootScriptSaveMemWrite(TableName, Width, Address, Count, (VOID*)(UINTN)Address) + +#define SCRIPT_MEM_READ_WRITE(TableName, Width, Address, Data, DataMask) \ + BootScriptSaveMemReadWrite(TableName, Width, Address, Data, DataMask) + +#define SCRIPT_PCI_CFG_WRITE(TableName, Width, Address, Count, Buffer) \ + BootScriptSavePciCfgWrite(TableName, Width, Address, Count, Buffer) + +#define SCRIPT_PCI_CFG_READ_WRITE(TableName, Width, Address, Data, DataMask) \ + BootScriptSavePciCfgReadWrite(TableName, Width, Address, Data, DataMask) + +#define SCRIPT_SMBUS_EXECUTE(TableName, SlaveAddress, Command, Operation, PecCheck, Length, Buffer) \ + BootScriptSaveSmbusExecute(TableName, SlaveAddress, Command, Operation, PecCheck, Length, Buffer) + +#define SCRIPT_STALL(TableName, Duration) \ + BootScriptSaveStall(TableName, Duration) + +#define SCRIPT_DISPATCH(TableName, EntryPoint) \ + BootScriptSaveDispatch(TableName, EntryPoint) + +#define SCRIPT_MEM_POLL(TableName, Width, Address, BitMask, BitValue, Duration, LoopTimes) \ + BootScriptMemPoll(TableName, Width, Address, BitMask, BitValue, Duration, LoopTimes) + +#define SCRIPT_INFORMATION(TableName, Length, Buffer) \ + BootScriptSaveInformation(TableName, Length, Buffer) + +#define SCRIPT_INFORMATION_UNICODE_STRING(TableName, String) \ + BootScriptSaveInformationUnicodeString(TableName, String) + +#define SCRIPT_INFORMATION_ASCII_STRING(TableName, String) \ + BootScriptSaveInformationAsciiString(TableName, String) + +#else + +#define INITIALIZE_SCRIPT(ImageHandle, SystemTable) + +#define SCRIPT_IO_WRITE(TableName, Width, Address, Count, Buffer) + +#define SCRIPT_IO_READ_WRITE(TableName, Width, Address, Data, DataMask) + +#define SCRIPT_MEM_WRITE(TableName, Width, Address, Count, Buffer) + +#define SCRIPT_MEM_WRITE_THIS(TableName, Width, Address, Count) + +#define SCRIPT_MEM_READ_WRITE(TableName, Width, Address, Data, DataMask) + +#define SCRIPT_PCI_CFG_WRITE(TableName, Width, Address, Count, Buffer) + +#define SCRIPT_PCI_CFG_READ_WRITE(TableName, Width, Address, Data, DataMask) + +#define SCRIPT_SMBUS_EXECUTE(TableName, SlaveAddress, Command, Operation, PecCheck, Length, Buffer) + +#define SCRIPT_STALL(TableName, Duration) + +#define SCRIPT_DISPATCH(TableName, EntryPoint) + +#define SCRIPT_MEM_POLL(TableName, Width, Address, BitMask, BitValue, Duration, LoopTimes) + +#define SCRIPT_INFORMATION(TableName, Length, Buffer) + +#define SCRIPT_INFORMATION_UNICODE_STRING(TableName, String) + +#define SCRIPT_INFORMATION_ASCII_STRING(TableName, String) + +#endif + +#endif diff --git a/EDK/Foundation/Library/Dxe/Include/EfiSmmDriverLib.h b/EDK/Foundation/Library/Dxe/Include/EfiSmmDriverLib.h new file mode 100644 index 0000000..5b6e74a --- /dev/null +++ b/EDK/Foundation/Library/Dxe/Include/EfiSmmDriverLib.h @@ -0,0 +1,226 @@ +/*++ + +Copyright (c) 2004 - 2007, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + EfiSmmDriverLib.h + +Abstract: + + Light weight lib to support EFI Smm drivers. + +--*/ + +#ifndef _EFI_SMM_DRIVER_LIB_H_ +#define _EFI_SMM_DRIVER_LIB_H_ + +#include "Tiano.h" +#include "GetImage.h" +#include "EfiCommonLib.h" +#include EFI_GUID_DEFINITION (EventLegacyBios) +#include EFI_GUID_DEFINITION (EventGroup) +#include EFI_PROTOCOL_DEFINITION (FirmwareVolume) +#include EFI_PROTOCOL_DEFINITION (FirmwareVolume2) //;;## ...AMI_OVERRIDE... Support PI1.x +#include EFI_PROTOCOL_DEFINITION (SmmBase) +#include EFI_PROTOCOL_DEFINITION (SmmStatusCode) +// +// Driver Lib Globals. +// +extern EFI_BOOT_SERVICES *gBS; +extern EFI_SYSTEM_TABLE *gST; +extern EFI_RUNTIME_SERVICES *gRT; +extern EFI_SMM_BASE_PROTOCOL *gSMM; +extern EFI_SMM_STATUS_CODE_PROTOCOL *mSmmDebug; +extern UINTN gErrorLevel; + +#define EfiCopyMem EfiCommonLibCopyMem +#define EfiSetMem EfiCommonLibSetMem +#define EfiZeroMem EfiCommonLibZeroMem + +EFI_STATUS +EfiInitializeSmmDriverLib ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable, + IN OUT BOOLEAN *InSmm + ) +/*++ + +Routine Description: + + Intialize Smm Driver Lib if it has not yet been initialized. + +Arguments: + + ImageHandle - The firmware allocated handle for the EFI image. + + SystemTable - A pointer to the EFI System Table. + + InSmm - If InSmm is NULL, it will not register Image to SMM. + If InSmm is not NULL, it will register Image to SMM and + return information on currently in SMM mode or not. + +Returns: + + EFI_STATUS always returns EFI_SUCCESS + +--*/ +; + +VOID +EfiDebugAssert ( + IN CHAR8 *FileName, + IN INTN LineNumber, + IN CHAR8 *Description + ) +/*++ + +Routine Description: + + Worker function for ASSERT (). If Error Logging hub is loaded log ASSERT + information. If Error Logging hub is not loaded DEADLOOP (). + +Arguments: + + FileName - File name of failing routine. + + LineNumber - Line number of failing ASSERT(). + + Description - Description, usually the assertion, + +Returns: + + None + +--*/ +; + +VOID +EfiDebugVPrint ( + IN UINTN ErrorLevel, + IN CHAR8 *Format, + IN VA_LIST Marker + ) +/*++ + +Routine Description: + + Worker function for DEBUG(). If Error Logging hub is loaded log ASSERT + information. If Error Logging hub is not loaded do nothing. + +Arguments: + + ErrorLevel - If error level is set do the debug print. + + Format - String to use for the print, followed by Print arguments. + + Marker - VarArgs + +Returns: + + None + +--*/ +; + +VOID +EfiDebugPrint ( + IN UINTN ErrorLevel, + IN CHAR8 *Format, + ... + ) +/*++ + +Routine Description: + + Worker function for DEBUG(). If Error Logging hub is loaded log ASSERT + information. If Error Logging hub is not loaded do nothing. + +Arguments: + + ErrorLevel - If error level is set do the debug print. + + Format - String to use for the print, followed by Print arguments. + + ... - VAR args for Format + +Returns: + + None + +--*/ +; + +EFI_STATUS +EFIAPI +SmmEfiCreateEventLegacyBoot ( + IN EFI_TPL NotifyTpl, + IN EFI_EVENT_NOTIFY NotifyFunction, + IN VOID *NotifyContext, + OUT EFI_EVENT *LegacyBootEvent + ) +/*++ + +Routine Description: + Create a Legacy Boot Event. + Tiano extended the CreateEvent Type enum to add a legacy boot event type. + This was bad as Tiano did not own the enum. In UEFI 2.0 CreateEventEx was + added and now it's possible to not voilate the UEFI specification by + declaring a GUID for the legacy boot event class. This library supports + the R8.5/EFI 1.10 form and R8.6/UEFI 2.0 form and allows common code to + work both ways. + +Arguments: + LegacyBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex) + +Returns: + EFI_SUCCESS Event was created. + Other Event was not created. + +--*/ +; + +EFI_STATUS +EFIAPI +SmmEfiCreateEventReadyToBoot ( + IN EFI_TPL NotifyTpl, + IN EFI_EVENT_NOTIFY NotifyFunction, + IN VOID *NotifyContext, + OUT EFI_EVENT *ReadyToBootEvent + ) +/*++ + +Routine Description: + Create a Read to Boot Event. + + Tiano extended the CreateEvent Type enum to add a ready to boot event type. + This was bad as Tiano did not own the enum. In UEFI 2.0 CreateEventEx was + added and now it's possible to not voilate the UEFI specification and use + the ready to boot event class defined in UEFI 2.0. This library supports + the R8.5/EFI 1.10 form and R8.6/UEFI 2.0 form and allows common code to + work both ways. + +Arguments: + ReadyToBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex) + +Return: + EFI_SUCCESS - Event was created. + Other - Event was not created. + +--*/ +; + +// +// These macros let code use the same name as boot service driver lib. +// +#define EfiCreateEventLegacyBoot SmmEfiCreateEventLegacyBoot +#define EfiCreateEventReadyToBoot SmmEfiCreateEventReadyToBoot + +#endif diff --git a/EDK/Foundation/Library/Dxe/Include/EfiUiLib.h b/EDK/Foundation/Library/Dxe/Include/EfiUiLib.h new file mode 100644 index 0000000..0e2bc59 --- /dev/null +++ b/EDK/Foundation/Library/Dxe/Include/EfiUiLib.h @@ -0,0 +1,205 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + EfiUiLib.h + +Abstract: + Collection of usefull UI functions. + +Revision History: + +--*/ + +#ifndef _EFI_UI_LIB_H_ +#define _EFI_UI_LIB_H_ + +#include "Tiano.h" +#include "TianoTypes.h" +#include "EfiDriverLib.h" + +CHAR16 * +StrHzToString ( + OUT CHAR16 *String, + IN UINT64 Val + ) +/*++ + +Routine Description: + Converts frequency in Hz to Unicode string. + Three significant digits are delivered. Used for processor info display. + +Arguments: + String - string that will contain the frequency. + Val - value to convert, minimum is 100000 i.e., 0.1 MHz. + +Returns: + String that contains the frequency. + +--*/ +; + +CHAR16 * +StrBytesToString ( + OUT CHAR16 *String, + IN UINT64 Val + ) +/*++ + +Routine Description: + Converts size in bytes to Unicode string. + Used for memory/cache size display. + +Arguments: + String - string that will contain the value + Val - value to convert in bytes + +Returns: + String that contains the value. + +--*/ +; + +CHAR16 * +StrVersionToString ( + OUT CHAR16 *String, + IN UINT8 Version + ) +/*++ + +Routine Description: + Converts 8 bit version value to Unicode string. + The upper nibble contains the upper part, the lower nibble contains the minor part. + The output format is <major>.<minor>. + +Arguments: + String - string that will contain the version value + Version - Version value to convert + +Returns: + String that contains the version value. + +--*/ +; + +CHAR16 * +StrMacToString ( + OUT CHAR16 *String, + IN EFI_MAC_ADDRESS *MacAddr, + IN UINT32 AddrSize + ) +/*++ + +Routine Description: + Converts MAC address to Unicode string. + The value is 64-bit and the resulting string will be 12 + digit hex number in pairs of digits separated by dashes. + +Arguments: + String - string that will contain the value + MacAddr - MAC address to convert + AddrSize - Size of address + +Returns: + String that contains the value. + +--*/ +; + +CHAR16 * +StrIp4AdrToString ( + OUT CHAR16 *String, + IN EFI_IPv4_ADDRESS *Ip4Addr + ) +/*++ + +Routine Description: + Converts IP v4 address to Unicode string. + The value is 64-bit and the resulting string will + be four decimal values 0-255 separated by dots. + +Arguments: + String - string that will contain the value + Ip4Addr - IP v4 address to convert from + +Returns: + + String that contain the value + +--*/ +; + +EFI_STATUS +StrStringToIp4Adr ( + OUT EFI_IPv4_ADDRESS *Ip4Addr, + IN CHAR16 *String + ) +/*++ + +Routine Description: + Parses and converts Unicode string to IP v4 address. + The value will 64-bit. + The string must be four decimal values 0-255 separated by dots. + The string is parsed and format verified. + +Arguments: + Ip4Addr - pointer to the variable to store the value to + String - string that contains the value to parse and convert + +Returns: + EFI_SUCCESS - if successful + EFI_INVALID_PARAMETER - if String contains invalid IP v4 format + +--*/ +; + +CHAR16 * +Ascii2Unicode ( + OUT CHAR16 *UnicodeStr, + IN CHAR8 *AsciiStr + ) +/*++ + +Routine Description: + Converts ASCII characters to Unicode. + +Arguments: + UnicodeStr - the Unicode string to be written to. The buffer must be large enough. + AsciiStr - The ASCII string to be converted. + +Returns: + The address to the Unicode string - same as UnicodeStr. + +--*/ +; + +CHAR8 * +Unicode2Ascii ( + OUT CHAR8 *AsciiStr, + IN CHAR16 *UnicodeStr + ) +/*++ + +Routine Description: + Converts ASCII characters to Unicode. + Assumes that the Unicode characters are only these defined in the ASCII set. + +Arguments: + AsciiStr - The ASCII string to be written to. The buffer must be large enough. + UnicodeStr - the Unicode string to be converted. + +Returns: + The address to the ASCII string - same as AsciiStr. + +--*/ +; + +#endif diff --git a/EDK/Foundation/Library/Dxe/Include/EfiWinNtLib.h b/EDK/Foundation/Library/Dxe/Include/EfiWinNtLib.h new file mode 100644 index 0000000..8f7bd57 --- /dev/null +++ b/EDK/Foundation/Library/Dxe/Include/EfiWinNtLib.h @@ -0,0 +1,75 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + EfiWinNtLib.h + +Abstract: + + Set up gWinNt pointer so we can call WinNT APIs. + +--*/ + +#ifndef _EFI_WIN_NT_LIB_H_ +#define _EFI_WIN_NT_LIB_H_ + +extern EFI_WIN_NT_THUNK_PROTOCOL *gWinNt; + +EFI_STATUS +EfiInitializeWinNtDriverLib ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +/*++ + +Routine Description: + + Intialize gWinNt and initialize debug console. + +Arguments: + + ImageHandle - The firmware allocated handle for the EFI image. + + SystemTable - A pointer to the EFI System Table. + +Returns: + + Status code + +--*/ +; + +// +// NTDebugConsole Prototypes +// +VOID +NtDebugConsoleInit ( + VOID + ) +/*++ + +Routine Description: + + Nt debug console initialize. + +Arguments: + + None + +Returns: + + None + +--*/ +; + +#endif diff --git a/EDK/Foundation/Library/Dxe/Include/GetImage.h b/EDK/Foundation/Library/Dxe/Include/GetImage.h new file mode 100644 index 0000000..0f22c5e --- /dev/null +++ b/EDK/Foundation/Library/Dxe/Include/GetImage.h @@ -0,0 +1,104 @@ +/*++ + +Copyright (c) 2006 - 2007, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + GetImage.h + +Abstract: + + Image data retrieval support for common use. + +--*/ + +#ifndef _GET_IMAGE_H_ +#define _GET_IMAGE_H_ +#include "EfiImageFormat.h" + +EFI_STATUS +GetImage ( + IN EFI_GUID *NameGuid, + IN EFI_SECTION_TYPE SectionType, + OUT VOID **Buffer, + OUT UINTN *Size + ) +/*++ + +Routine Description: + Enumerate all the FVs, and fill Buffer with the SectionType section content in NameGuid file. + + Note: + 1. when SectionType is EFI_SECTION_PE32, it tries to read NameGuid file after failure on + reading EFI_SECTION_PE32 section. + 2. when SectionType is EFI_SECTION_TE, it tries to get EFI_SECTION_PE32 section after failure on + reading EFI_SECTION_TE section. If it's failed again, it tries to read NameGuid file. + 3. Callee allocates memory, which caller is responsible to free. + +Arguments: + + NameGuid - Pointer to EFI_GUID, which is file name. + SectionType - Required section type. + Buffer - Pointer to a pointer in which the read content is returned. + Caller is responsible to free Buffer. + Size - Pointer to a UINTN, which indicates the size of returned *Buffer. + +Returns: + EFI_NOT_FOUND - Required content can not be found. + EFI_SUCCESS - Required content can be found, but whether the Buffer is filled + with section content or not depends on the Buffer and Size. +--*/ +; + +EFI_STATUS +GetImageEx ( + IN EFI_HANDLE ImageHandle, + IN EFI_GUID *NameGuid, + IN EFI_SECTION_TYPE SectionType, + OUT VOID **Buffer, + OUT UINTN *Size, + BOOLEAN WithinImageFv + ) +/*++ + +Routine Description: + Search FVs, and fill Buffer with the SectionType section content in NameGuid file. + If ImageHandle is not NULL, the FV from which the ImageHandle is loaded is searched + first. If WithinImageFv is TRUE, only the FV from which the ImageHandle is loaded + is searched. If ImageHandle is NULL or WithinImageFv is FALSE, all FVs in the system + is searched. + + Note: + 1. when SectionType is EFI_SECTION_PE32, it tries to read NameGuid file after failure on + reading EFI_SECTION_PE32 section. + 2. when SectionType is EFI_SECTION_TE, it tries to get EFI_SECTION_PE32 section after failure on + reading EFI_SECTION_TE section. If it's failed again, it tries to read NameGuid file. + 3. Callee allocates memory, which caller is responsible to free. + +Arguments: + + ImageHandle - The caller's driver image handle. + NameGuid - Pointer to EFI_GUID, which is file name. + SectionType - Required section type. + Buffer - Pointer to a pointer in which the read content is returned. + Caller is responsible to free Buffer. + Size - Pointer to a UINTN, which indicates the size of returned *Buffer. + WithinImageFv - Whether the search only performs on the FV from which the caller's + driver image is loaded. + +Returns: + EFI_INVALID_PARAMETER - ImageHandle is NULL and WithinImageFv is TRUE. + EFI_NOT_FOUND - Required content can not be found. + EFI_SUCCESS - Required content can be found, but whether the Buffer is filled + with section content or not depends on the Buffer and Size. +--*/ +; + +#endif //_GET_IMAGE_H_ diff --git a/EDK/Foundation/Library/Dxe/Include/GraphicsLib.h b/EDK/Foundation/Library/Dxe/Include/GraphicsLib.h new file mode 100644 index 0000000..02f1d97 --- /dev/null +++ b/EDK/Foundation/Library/Dxe/Include/GraphicsLib.h @@ -0,0 +1,181 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + GraphicsLib.h + +Abstract: + + +--*/ + +#ifndef _EFI_GRAPHICS_LIB_H_ +#define _EFI_GRAPHICS_LIB_H_ + +#include EFI_PROTOCOL_DEFINITION (ConsoleControl) +#include EFI_PROTOCOL_DEFINITION (FirmwareVolume) +#include EFI_PROTOCOL_DEFINITION (GraphicsOutput) +#include EFI_PROTOCOL_DEFINITION (UgaDraw) +#include EFI_PROTOCOL_DEFINITION (EfiOEMBadging) + +#include EFI_GUID_DEFINITION (Bmp) + +EFI_STATUS +GetGraphicsBitMapFromFV ( + IN EFI_GUID *FileNameGuid, + OUT VOID **Image, + OUT UINTN *ImageSize + ) +/*++ + +Routine Description: + + Return the graphics image file named FileNameGuid into Image and return it's + size in ImageSize. All Firmware Volumes (FV) in the system are searched for the + file name. + +Arguments: + + FileNameGuid - File Name of graphics file in the FV(s). + + Image - Pointer to pointer to return graphics image. If NULL, a + buffer will be allocated. + + ImageSize - Size of the graphics Image in bytes. Zero if no image found. + + +Returns: + + EFI_SUCCESS - Image and ImageSize are valid. + EFI_BUFFER_TOO_SMALL - Image not big enough. ImageSize has required size + EFI_NOT_FOUND - FileNameGuid not found + +--*/ +; + +EFI_STATUS +ConvertBmpToGopBlt ( + IN VOID *BmpImage, + IN UINTN BmpImageSize, + IN OUT VOID **GopBlt, + IN OUT UINTN *GopBltSize, + OUT UINTN *PixelHeight, + OUT UINTN *PixelWidth + ) +/*++ + +Routine Description: + + Convert a *.BMP graphics image to a GOP/UGA blt buffer. If a NULL Blt buffer + is passed in a GopBlt buffer will be allocated by this routine. If a GopBlt + buffer is passed in it will be used if it is big enough. + +Arguments: + + BmpImage - Pointer to BMP file + + BmpImageSize - Number of bytes in BmpImage + + GopBlt - Buffer containing GOP version of BmpImage. + + GopBltSize - Size of GopBlt in bytes. + + PixelHeight - Height of GopBlt/BmpImage in pixels + + PixelWidth - Width of GopBlt/BmpImage in pixels + + +Returns: + + EFI_SUCCESS - GopBlt and GopBltSize are returned. + EFI_UNSUPPORTED - BmpImage is not a valid *.BMP image + EFI_BUFFER_TOO_SMALL - The passed in GopBlt buffer is not big enough. + GopBltSize will contain the required size. + EFI_OUT_OF_RESOURCES - No enough buffer to allocate + +--*/ +; + +EFI_STATUS +EnableQuietBoot ( + IN EFI_GUID *LogoFile + ) +/*++ + +Routine Description: + + Use Console Control to turn off UGA based Simple Text Out consoles from going + to the UGA device. Put up LogoFile on every UGA device that is a console + +Arguments: + + LogoFile - File name of logo to display on the center of the screen. + + +Returns: + + EFI_SUCCESS - ConsoleControl has been flipped to graphics and logo + displayed. + EFI_UNSUPPORTED - Logo not found + +--*/ +; + +EFI_STATUS +DisableQuietBoot ( + VOID + ) +/*++ + +Routine Description: + + Use Console Control to turn on UGA based Simple Text Out consoles. The UGA + Simple Text Out screens will now be synced up with all non UGA output devices + +Arguments: + + NONE + +Returns: + + EFI_SUCCESS - UGA devices are back in text mode and synced up. + EFI_UNSUPPORTED - Logo not found + +--*/ +; + +EFI_STATUS +LockKeyboards ( + IN CHAR16 *Password + ) +/*++ + +Routine Description: + Use Console Control Protocol to lock the Console In Spliter virtual handle. + This is the ConInHandle and ConIn handle in the EFI system table. All key + presses will be ignored until the Password is typed in. The only way to + disable the password is to type it in to a ConIn device. + +Arguments: + Password - Password used to lock ConIn device + + +Returns: + + EFI_SUCCESS - ConsoleControl has been flipped to graphics and logo + displayed. + EFI_UNSUPPORTED - Logo not found + +--*/ +; + +#endif diff --git a/EDK/Foundation/Library/Dxe/Include/Ia32/CpuFuncs.h b/EDK/Foundation/Library/Dxe/Include/Ia32/CpuFuncs.h new file mode 100644 index 0000000..affb3bd --- /dev/null +++ b/EDK/Foundation/Library/Dxe/Include/Ia32/CpuFuncs.h @@ -0,0 +1,260 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + CpuFuncs.h + +Abstract: + +--*/ + +#ifndef _CPU_FUNCS_H_ +#define _CPU_FUNCS_H_ + +#define EFI_CPUID_SIGNATURE 0x0 +#define EFI_CPUID_VERSION_INFO 0x1 +#define EFI_CPUID_CACHE_INFO 0x2 +#define EFI_CPUID_SERIAL_NUMBER 0x3 +#define EFI_CPUID_EXTENDED_FUNCTION 0x80000000 +#define EFI_CPUID_EXTENDED_CPU_SIG 0x80000001 +#define EFI_CPUID_BRAND_STRING1 0x80000002 +#define EFI_CPUID_BRAND_STRING2 0x80000003 +#define EFI_CPUID_BRAND_STRING3 0x80000004 + +// +// CPUID version information masks +// Note: leaving masks here is for the compatibility +// use EfiCpuVersion (...) instead +// +#define EFI_CPUID_FAMILY 0x0F00 +#define EFI_CPUID_MODEL 0x00F0 +#define EFI_CPUID_STEPPING 0x000F + +#define EFI_CPUID_PENTIUM_M 0x0600 +#define EFI_CPUID_BANIAS 0x0090 +#define EFI_CPUID_DOTHAN 0x00D0 +#define EFI_CPUID_NETBURST 0x0F00 + +#define EFI_MSR_IA32_PLATFORM_ID 0x17 +#define EFI_MSR_IA32_APIC_BASE 0x1B +#define EFI_MSR_EBC_HARD_POWERON 0x2A +#define EFI_MSR_EBC_SOFT_POWERON 0x2B +#define BINIT_DRIVER_DISABLE 0x40 +#define INTERNAL_MCERR_DISABLE 0x20 +#define INITIATOR_MCERR_DISABLE 0x10 +#define EFI_MSR_EBC_FREQUENCY_ID 0x2C +#define EFI_MSR_IA32_BIOS_UPDT_TRIG 0x79 +#define EFI_MSR_IA32_BIOS_SIGN_ID 0x8B +#define EFI_MSR_PSB_CLOCK_STATUS 0xCD +#define EFI_APIC_GLOBAL_ENABLE 0x800 +#define EFI_MSR_IA32_MISC_ENABLE 0x1A0 +#define LIMIT_CPUID_MAXVAL_ENABLE_BIT 0x00400000 +#define AUTOMATIC_THERMAL_CONTROL_ENABLE_BIT 0x00000008 +#define COMPATIBLE_FPU_OPCODE_ENABLE_BIT 0x00000004 +#define LOGICAL_PROCESSOR_PRIORITY_ENABLE_BIT 0x00000002 +#define FAST_STRING_ENABLE_BIT 0x00000001 + +#define EFI_CACHE_VARIABLE_MTRR_BASE 0x200 +#define EFI_CACHE_VARIABLE_MTRR_END 0x20F +#define EFI_CACHE_IA32_MTRR_DEF_TYPE 0x2FF +#define EFI_CACHE_VALID_ADDRESS 0xFFFFFF000 +#define EFI_CACHE_MTRR_VALID 0x800 +#define EFI_CACHE_FIXED_MTRR_VALID 0x400 +#define EFI_MSR_VALID_MASK 0xFFFFFFFFF + +#define EFI_IA32_MTRR_FIX64K_00000 0x250 +#define EFI_IA32_MTRR_FIX16K_80000 0x258 +#define EFI_IA32_MTRR_FIX16K_A0000 0x259 +#define EFI_IA32_MTRR_FIX4K_C0000 0x268 +#define EFI_IA32_MTRR_FIX4K_C8000 0x269 +#define EFI_IA32_MTRR_FIX4K_D0000 0x26A +#define EFI_IA32_MTRR_FIX4K_D8000 0x26B +#define EFI_IA32_MTRR_FIX4K_E0000 0x26C +#define EFI_IA32_MTRR_FIX4K_E8000 0x26D +#define EFI_IA32_MTRR_FIX4K_F0000 0x26E +#define EFI_IA32_MTRR_FIX4K_F8000 0x26F + +#define EFI_IA32_MCG_CAP 0x179 +#define EFI_IA32_MCG_CTL 0x17B +#define EFI_IA32_MC0_CTL 0x400 +#define EFI_IA32_MC0_STATUS 0x401 + +#define EFI_CACHE_UNCACHEABLE 0 +#define EFI_CACHE_WRITECOMBINING 1 +#define EFI_CACHE_WRITETHROUGH 4 +#define EFI_CACHE_WRITEPROTECTED 5 +#define EFI_CACHE_WRITEBACK 6 + +// +// Combine f(FamilyId), m(Model), s(SteppingId) to a single 32 bit number +// +#define EfiMakeCpuVersion(f, m, s) \ + (((UINT32) (f) << 16) | ((UINT32) (m) << 8) | ((UINT32) (s))) + +typedef struct { + UINT32 HeaderVersion; + UINT32 UpdateRevision; + UINT32 Date; + UINT32 ProcessorId; + UINT32 Checksum; + UINT32 LoaderRevision; + UINT32 ProcessorFlags; + UINT32 DataSize; + UINT32 TotalSize; + UINT8 Reserved[12]; +} EFI_CPU_MICROCODE_HEADER; + +typedef struct { + UINT32 ExtSigCount; + UINT32 ExtChecksum; + UINT8 Reserved[12]; + UINT32 ProcessorId; + UINT32 ProcessorFlags; + UINT32 Checksum; +} EFI_CPU_MICROCODE_EXT_HEADER; + +typedef struct { + UINT32 RegEax; + UINT32 RegEbx; + UINT32 RegEcx; + UINT32 RegEdx; +} EFI_CPUID_REGISTER; + +VOID +EfiWriteMsr ( + IN UINT32 Input, + IN UINT64 Value + ) +/*++ + +Routine Description: + + Write Cpu MSR + +Arguments: + + Input -The index value to select the register + Value -The value to write to the selected register + +Returns: + + None + +--*/ +; + +UINT64 +EfiReadMsr ( + IN UINT32 Input + ) +/*++ + +Routine Description: + + Read Cpu MSR. + +Arguments: + + Input: -The index value to select the register + +Returns: + + Return the read data + +--*/ +; + +VOID +EfiCpuid ( + IN UINT32 RegEax, + OUT EFI_CPUID_REGISTER *Reg + ) +/*++ + +Routine Description: + + Get the Cpu info by excute the CPUID instruction. + +Arguments: + + RegEax -The input value to put into register EAX + Reg -The Output value + +Returns: + + None + +--*/ +; + +VOID +EfiCpuVersion ( + IN UINT16 *FamilyId, OPTIONAL + IN UINT8 *Model, OPTIONAL + IN UINT8 *SteppingId, OPTIONAL + IN UINT8 *Processor OPTIONAL + ) +/*++ + +Routine Description: + Extract CPU detail version infomation + +Arguments: + FamilyId - FamilyId, including ExtendedFamilyId + Model - Model, including ExtendedModel + SteppingId - SteppingId + Processor - Processor + +--*/ +; + +UINT64 +EfiReadTsc ( + VOID + ) +/*++ + +Routine Description: + + Read Time stamp. + +Arguments: + + None + +Returns: + + Return the read data + +--*/ +; +VOID +EfiCpuidExt ( + IN UINT32 RegisterInEax, + IN UINT32 CacheLevel, + OUT EFI_CPUID_REGISTER *Regs + ) +/*++ +Routine Description: + When RegisterInEax != 4, the functionality is the same as EfiCpuid. + When RegisterInEax == 4, the function return the deterministic cache + parameters by excuting the CPUID instruction +Arguments: + RegisterInEax: - The input value to put into register EAX + CacheLevel: - The deterministic cache level + Regs: - The Output value +Returns: + None +--*/ +; + +#endif diff --git a/EDK/Foundation/Library/Dxe/Include/Ia32/ProcDep.h b/EDK/Foundation/Library/Dxe/Include/Ia32/ProcDep.h new file mode 100644 index 0000000..2e072d2 --- /dev/null +++ b/EDK/Foundation/Library/Dxe/Include/Ia32/ProcDep.h @@ -0,0 +1,26 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + ProcDep.h + +Abstract: + + IA-32 specific Runtime Lib code. At this time there is non. + IPF has different code due to extra API requirements. + +--*/ + +#ifndef _PROC_DEP_H_ +#define _PROC_DEP_H_ + +#endif diff --git a/EDK/Foundation/Library/Dxe/Include/Ia32EfiRuntimeDriverLib.h b/EDK/Foundation/Library/Dxe/Include/Ia32EfiRuntimeDriverLib.h new file mode 100644 index 0000000..df833c4 --- /dev/null +++ b/EDK/Foundation/Library/Dxe/Include/Ia32EfiRuntimeDriverLib.h @@ -0,0 +1,111 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + Ia32EfiRuntimeDriverLib.h + +Abstract: + + Light weight lib to support IA32 EFI Libraries. + +--*/ + +#ifndef _IA32_EFI_RUNTIME_LIB_H_ +#define _IA32_EFI_RUNTIME_LIB_H_ + +#include "Tiano.h" +#include "EfiRuntimeLib.h" +#include EFI_PROTOCOL_DEFINITION (ExtendedSalGuid) + +typedef +EFI_STATUS +(EFIAPI *COMMON_PROC_ENTRY) ( + IN UINTN FunctionId, + IN UINTN Arg2, + IN UINTN Arg3, + IN UINTN Arg4, + IN UINTN Arg5, + IN UINTN Arg6, + IN UINTN Arg7, + IN UINTN Arg8 + ); + +typedef struct { + COMMON_PROC_ENTRY CommonProcEntry; +} COMMON_PROC_ENTRY_STRUCT; + +EFI_STATUS +InstallPlatformRuntimeLib ( + IN EFI_GUID *Guid, + IN COMMON_PROC_ENTRY_STRUCT *CommonEntry + ) +/*++ + +Routine Description: + + Install platform runtime lib. + +Arguments: + + Guid - Guid for runtime lib + CommonEntry - Common entry + +Returns: + + Status code + +--*/ +; + +EFI_STATUS +GetPlatformRuntimeLib ( + IN EFI_SYSTEM_TABLE *SystemTable + ) +/*++ + +Routine Description: + + Get platform runtime lib. + +Arguments: + + SystemTable - Pointer to system table + +Returns: + + Status code + +--*/ +; + +EFI_STATUS +ConvertPlatformRuntimeLibPtr ( + IN EFI_RUNTIME_SERVICES *mRT + ) +/*++ + +Routine Description: + + Convert platform runtime lib pointer. + +Arguments: + + mRT - Pointer to runtime service table. + +Returns: + + Status code + +--*/ +; + +#endif diff --git a/EDK/Foundation/Library/Dxe/Include/Ipf/CpuFuncs.h b/EDK/Foundation/Library/Dxe/Include/Ipf/CpuFuncs.h new file mode 100644 index 0000000..3818170 --- /dev/null +++ b/EDK/Foundation/Library/Dxe/Include/Ipf/CpuFuncs.h @@ -0,0 +1,93 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + CpuFuncs.h + +Abstract: + +--*/ + +#ifndef _CPU_FUNCS_H +#define _CPU_FUNCS_H + +#define EFI_CPUID_SIGNATURE 0x0 +#define EFI_CPUID_VERSION_INFO 0x1 +#define EFI_CPUID_CACHE_INFO 0x2 +#define EFI_CPUID_SERIAL_NUMBER 0x3 +#define EFI_CPUID_EXTENDED_FUNCTION 0x80000000 +#define EFI_CPUID_EXTENDED_CPU_SIG 0x80000001 +#define EFI_CPUID_BRAND_STRING1 0x80000002 +#define EFI_CPUID_BRAND_STRING2 0x80000003 +#define EFI_CPUID_BRAND_STRING3 0x80000004 + +#define EFI_MSR_IA32_APIC_BASE 0x1B +#define EFI_MSR_EBC_HARD_POWERON 0x2A +#define EFI_MSR_EBC_SOFT_POWERON 0x2B +#define EFI_MSR_EBC_FREQUENCY_ID 0x2C +#define EFI_MSR_IA32_BIOS_UPDT_TRIG 0x79 +#define EFI_MSR_IA32_BIOS_SIGN_ID 0x8B +#define EFI_APIC_GLOBAL_ENABLE 0x800 + +#define EFI_CACHE_VARIABLE_MTRR_BASE 0x200 +#define EFI_CACHE_VARIABLE_MTRR_END 0x20F +#define EFI_CACHE_IA32_MTRR_DEF_TYPE 0x2FF +#define EFI_CACHE_VALID_ADDRESS 0xFFFFFF000 +#define EFI_CACHE_MTRR_VALID 0x800 +#define EFI_CACHE_FIXED_MTRR_VALID 0x400 +#define EFI_MSR_VALID_MASK 0xFFFFFFFFF + +#define EFI_IA32_MTRR_FIX64K_00000 0x250 +#define EFI_IA32_MTRR_FIX16K_80000 0x258 +#define EFI_IA32_MTRR_FIX16K_A0000 0x259 +#define EFI_IA32_MTRR_FIX4K_C0000 0x268 +#define EFI_IA32_MTRR_FIX4K_C8000 0x269 +#define EFI_IA32_MTRR_FIX4K_D0000 0x26A +#define EFI_IA32_MTRR_FIX4K_D8000 0x26B +#define EFI_IA32_MTRR_FIX4K_E0000 0x26C +#define EFI_IA32_MTRR_FIX4K_E8000 0x26D +#define EFI_IA32_MTRR_FIX4K_F0000 0x26E +#define EFI_IA32_MTRR_FIX4K_F8000 0x26F + +#define EFI_IA32_MCG_CAP 0x179 +#define EFI_IA32_MCG_CTL 0x17B +#define EFI_IA32_MC0_CTL 0x400 +#define EFI_IA32_MC0_STATUS 0x401 + +#define EFI_CACHE_UNCACHEABLE 0 +#define EFI_CACHE_WRITECOMBINING 1 +#define EFI_CACHE_WRITETHROUGH 4 +#define EFI_CACHE_WRITEPROTECTED 5 +#define EFI_CACHE_WRITEBACK 6 + +UINT64 +EfiReadTsc ( + VOID + ) +/*++ + +Routine Description: + + Read Time stamp. + +Arguments: + + None + +Returns: + + Return the read data + +--*/ +; + +#endif diff --git a/EDK/Foundation/Library/Dxe/Include/Ipf/EsalRuntimeLib.h b/EDK/Foundation/Library/Dxe/Include/Ipf/EsalRuntimeLib.h new file mode 100644 index 0000000..7f29acf --- /dev/null +++ b/EDK/Foundation/Library/Dxe/Include/Ipf/EsalRuntimeLib.h @@ -0,0 +1,1305 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + EsalRuntimeLib.h + +Abstract: + + SAL Driver Lib + +Revision History + +--*/ + +#ifndef _ESAL_RUNTIME_LIB_H_ +#define _ESAL_RUNTIME_LIB_H_ + +#include "SalApi.h" +#include "EfiFirmwareVolumeHeader.h" + +#include EFI_PROTOCOL_DEFINITION (ExtendedSalBootService) +#include EFI_PROTOCOL_DEFINITION (ExtendedSalGuid) +#include EFI_PROTOCOL_DEFINITION (FirmwareVolumeBlock) + +VOID +EsalRuntimeLibVirtualNotify ( + VOID + ) +/*++ + +Routine Description: + + TODO: Add function description + +Arguments: + + None + +Returns: + + TODO: add return values + +--*/ +; + +EFI_STATUS +EsalInitializeRuntimeDriverLib ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +/*++ + +Routine Description: + + TODO: Add function description + +Arguments: + + ImageHandle - Image Handle + SystemTable - the System Table + +Returns: + + TODO: add return values + +--*/ +; +SAL_RETURN_REGS +CallEsalService ( + IN EFI_GUID *ClassGuid, + IN UINT64 FunctionId, + IN UINT64 Arg2, + IN UINT64 Arg3, + IN UINT64 Arg4, + IN UINT64 Arg5, + IN UINT64 Arg6, + IN UINT64 Arg7, + IN UINT64 Arg8 + ) +/*++ + +Routine Description: + + TODO: Add function description + +Arguments: + + ClassGuid - TODO: add argument description + FunctionId - TODO: add argument description + Arg2 - TODO: add argument description + Arg3 - TODO: add argument description + Arg4 - TODO: add argument description + Arg5 - TODO: add argument description + Arg6 - TODO: add argument description + Arg7 - TODO: add argument description + Arg8 - TODO: add argument description + +Returns: + + TODO: add return values + +--*/ +; + +// +// Assembly Functions +// + +SAL_RETURN_REGS +EsalGetEntryPoint ( + VOID + ) +/*++ + +Routine Description: + + TODO: Add function description + +Arguments: + + None + +Returns: + + TODO: add return values + +--*/ +; + +SAL_RETURN_REGS +EsalSetPhysicalEntryPoint ( + IN UINT64 EntryPoint, + IN UINT64 Gp + ) +/*++ + +Routine Description: + + TODO: Add function description + +Arguments: + + EntryPoint - TODO: add argument description + Gp - TODO: add argument description + +Returns: + + TODO: add return values + +--*/ +; + +SAL_RETURN_REGS +EsalSetVirtualEntryPoint ( + IN UINT64 EntryPoint, + IN UINT64 Gp + ) +/*++ + +Routine Description: + + TODO: Add function description + +Arguments: + + EntryPoint - TODO: add argument description + Gp - TODO: add argument description + +Returns: + + TODO: add return values + +--*/ +; + +SAL_RETURN_REGS +EsalSetPhysicalModuleGlobal ( + IN VOID *Global + ) +/*++ + +Routine Description: + + TODO: Add function description + +Arguments: + + Global - TODO: add argument description + +Returns: + + TODO: add return values + +--*/ +; + +SAL_RETURN_REGS +EsalSetVirtualModuleGlobal ( + IN VOID *Global + ) +/*++ + +Routine Description: + + TODO: Add function description + +Arguments: + + Global - TODO: add argument description + +Returns: + + TODO: add return values + +--*/ +; + +SAL_RETURN_REGS +EsalGetModuleGlobal ( + VOID + ) +/*++ + +Routine Description: + + TODO: Add function description + +Arguments: + + None + +Returns: + + TODO: add return values + +--*/ +; + +SAL_RETURN_REGS +GetIrrData ( + VOID + ) +/*++ + +Routine Description: + + TODO: Add function description + +Arguments: + + None + +Returns: + + TODO: add return values + +--*/ +; + +SAL_RETURN_REGS +GetPsrData ( + VOID + ) +/*++ + +Routine Description: + + TODO: Add function description + +Arguments: + + None + +Returns: + + TODO: add return values + +--*/ +; + +SAL_RETURN_REGS +GetProcIdData ( + VOID + ) +/*++ + +Routine Description: + + TODO: Add function description + +Arguments: + + None + +Returns: + + TODO: add return values + +--*/ +; + +VOID +SwitchCpuStack ( + IN UINT64 NewBsp, + IN UINT64 OldBsp + ) +/*++ + +Routine Description: + + TODO: Add function description + +Arguments: + + NewBsp - TODO: add argument description + OldBsp - TODO: add argument description + +Returns: + + TODO: add return values + +--*/ +; + +// +// PAL PROC Class +// + +SAL_RETURN_REGS +SalPalProc ( + IN UINT64 Arg1, + IN UINT64 Arg2, + IN UINT64 Arg3, + IN UINT64 Arg4 + ) +/*++ + +Routine Description: + + TODO: Add function description + +Arguments: + + Arg1 - TODO: add argument description + Arg2 - TODO: add argument description + Arg3 - TODO: add argument description + Arg4 - TODO: add argument description + +Returns: + + TODO: add return values + +--*/ +; + +SAL_RETURN_REGS +SalRegisterNewPalEntry ( + IN BOOLEAN PhysicalPalAddress, + IN EFI_PHYSICAL_ADDRESS NewPalAddress + ) +/*++ + +Routine Description: + + TODO: Add function description + +Arguments: + + PhysicalPalAddress - TODO: add argument description + NewPalAddress - TODO: add argument description + +Returns: + + TODO: add return values + +--*/ +; + +SAL_RETURN_REGS +SalGetPalEntryPointer ( + IN BOOLEAN PhysicalPalAddress + ) +/*++ + +Routine Description: + + TODO: Add function description + +Arguments: + + PhysicalPalAddress - TODO: add argument description + +Returns: + + TODO: add return values + +--*/ +; + +// +// SAL BASE Class +// + +SAL_RETURN_REGS +SalProcSetVectors ( + IN UINT64 SalVectorType, + IN UINT64 PhyAddr1, + IN UINT64 Gp1, + IN UINT64 LengthCs1, + IN UINT64 PhyAddr2, + IN UINT64 Gp2, + IN UINT64 LengthCs2 + ) +/*++ + +Routine Description: + + TODO: Add function description + +Arguments: + + SalVectorType - TODO: add argument description + PhyAddr1 - TODO: add argument description + Gp1 - TODO: add argument description + LengthCs1 - TODO: add argument description + PhyAddr2 - TODO: add argument description + Gp2 - TODO: add argument description + LengthCs2 - TODO: add argument description + +Returns: + + TODO: add return values + +--*/ +; + +SAL_RETURN_REGS +SalProcMcRendez ( + VOID + ) +/*++ + +Routine Description: + + TODO: Add function description + +Arguments: + + None + +Returns: + + TODO: add return values + +--*/ +; + +SAL_RETURN_REGS +SalProcMcSetParams ( + IN UINT64 ParamType, + IN UINT64 IntOrMem, + IN UINT64 IntOrMemVal, + IN UINT64 Timeout, + IN UINT64 McaOpt + ) +/*++ + +Routine Description: + + TODO: Add function description + +Arguments: + + ParamType - TODO: add argument description + IntOrMem - TODO: add argument description + IntOrMemVal - TODO: add argument description + Timeout - TODO: add argument description + McaOpt - TODO: add argument description + +Returns: + + TODO: add return values + +--*/ +; + +SAL_RETURN_REGS +EsalProcGetVectors ( + IN UINT64 VectorType + ) +/*++ + +Routine Description: + + TODO: Add function description + +Arguments: + + VectorType - TODO: add argument description + +Returns: + + TODO: add return values + +--*/ +; + +SAL_RETURN_REGS +EsalProcMcGetParams ( + IN UINT64 ParamInfoType + ) +/*++ + +Routine Description: + + TODO: Add function description + +Arguments: + + ParamInfoType - TODO: add argument description + +Returns: + + TODO: add return values + +--*/ +; + +SAL_RETURN_REGS +EsalProcMcGetMcParams ( + VOID + ) +/*++ + +Routine Description: + + TODO: Add function description + +Arguments: + + None + +Returns: + + TODO: add return values + +--*/ +; + +SAL_RETURN_REGS +EsalProcGetMcCheckinFlags ( + IN UINT64 ProcessorUnit + ) +/*++ + +Routine Description: + + TODO: Add function description + +Arguments: + + ProcessorUnit - TODO: add argument description + +Returns: + + TODO: add return values + +--*/ +; + +// +// Sal Base Class enums +// + +typedef enum { + McaVector, + BspInitVector, + BootRendezVector, + ApInitVector +} ESAL_GET_VECTOR_TYPE; + +SAL_RETURN_REGS +SalInitializeThreshold ( + IN VOID *ThresholdStruct, + IN UINT64 Count, + IN UINT64 Duration + ) +/*++ + +Routine Description: + + TODO: Add function description + +Arguments: + + ThresholdStruct - TODO: add argument description + Count - TODO: add argument description + Duration - TODO: add argument description + +Returns: + + TODO: add return values + +--*/ +; + +SAL_RETURN_REGS +SalBumpThresholdCount ( + IN VOID *ThresholdStruct, + IN UINT64 Count, + IN UINT64 Duration + ) +/*++ + +Routine Description: + + TODO: Add function description + +Arguments: + + ThresholdStruct - TODO: add argument description + Count - TODO: add argument description + Duration - TODO: add argument description + +Returns: + + TODO: add return values + +--*/ +; + +SAL_RETURN_REGS +SalGetThresholdCount ( + IN VOID *ThresholdStruct, + IN UINT64 Count, + IN UINT64 Duration + ) +/*++ + +Routine Description: + + TODO: Add function description + +Arguments: + + ThresholdStruct - TODO: add argument description + Count - TODO: add argument description + Duration - TODO: add argument description + +Returns: + + TODO: add return values + +--*/ +; + +// +// Common Lib Function +// + +EFI_STATUS +RegisterEsalFunction ( + IN UINT64 FunctionId, + IN EFI_GUID *ClassGuid, + IN SAL_INTERNAL_EXTENDED_SAL_PROC Function, + IN VOID *ModuleGlobal + ) +/*++ + +Routine Description: + + TODO: Add function description + +Arguments: + + FunctionId - TODO: add argument description + ClassGuid - TODO: add argument description + Function - TODO: add argument description + ModuleGlobal - TODO: add argument description + +Returns: + + TODO: add return values + +--*/ +; + +EFI_STATUS +RegisterEsalClass ( + IN EFI_GUID *ClassGuid, + IN VOID *ModuleGlobal, + ... + ) +/*++ + +Routine Description: + + TODO: Add function description + +Arguments: + + ClassGuid - TODO: add argument description + ModuleGlobal - TODO: add argument description + ... - TODO: add argument description + +Returns: + + TODO: add return values + +--*/ +; + +// +// MP Class Functions +// +SAL_RETURN_REGS +LibMpAddCpuData ( + IN UINT64 CpuGlobalId, + IN BOOLEAN Enabled, + IN UINT64 PalCompatability + ) +/*++ + +Routine Description: + + TODO: Add function description + +Arguments: + + CpuGlobalId - TODO: add argument description + Enabled - TODO: add argument description + PalCompatability - TODO: add argument description + +Returns: + + TODO: add return values + +--*/ +; + +SAL_RETURN_REGS +LibMpRemoveCpuData ( + IN UINT64 CpuGlobalId + ) +/*++ + +Routine Description: + + TODO: Add function description + +Arguments: + + CpuGlobalId - TODO: add argument description + +Returns: + + TODO: add return values + +--*/ +; + +SAL_RETURN_REGS +LibMpModifyCpuData ( + IN UINT64 CpuGlobalId, + IN BOOLEAN Enabled, + IN UINT64 PalCompatability + ) +/*++ + +Routine Description: + + TODO: Add function description + +Arguments: + + CpuGlobalId - TODO: add argument description + Enabled - TODO: add argument description + PalCompatability - TODO: add argument description + +Returns: + + TODO: add return values + +--*/ +; + +SAL_RETURN_REGS +LibMpGetCpuDataByID ( + IN UINT64 CpuGlobalId, + IN BOOLEAN IndexByEnabledCpu + ) +/*++ + +Routine Description: + + TODO: Add function description + +Arguments: + + CpuGlobalId - TODO: add argument description + IndexByEnabledCpu - TODO: add argument description + +Returns: + + TODO: add return values + +--*/ +; + +SAL_RETURN_REGS +LibMpGetCpuDataByIndex ( + IN UINT64 Index, + IN BOOLEAN IndexByEnabledCpu + ) +/*++ + +Routine Description: + + TODO: Add function description + +Arguments: + + Index - TODO: add argument description + IndexByEnabledCpu - TODO: add argument description + +Returns: + + TODO: add return values + +--*/ +; + +SAL_RETURN_REGS +LibMpSendIpi ( + IN UINT64 ProcessorNumber, + IN UINT64 VectorNumber, + IN EFI_DELIVERY_MODE DeliveryMode, + IN BOOLEAN IRFlag + ) +/*++ + +Routine Description: + + TODO: Add function description + +Arguments: + + ProcessorNumber - TODO: add argument description + VectorNumber - TODO: add argument description + DeliveryMode - TODO: add argument description + IRFlag - TODO: add argument description + +Returns: + + TODO: add return values + +--*/ +; + +SAL_RETURN_REGS +LibMpCurrentProcessor ( + IN BOOLEAN IndexByEnabledCpu + ) +/*++ + +Routine Description: + + TODO: Add function description + +Arguments: + + IndexByEnabledCpu - TODO: add argument description + +Returns: + + TODO: add return values + +--*/ +; + +SAL_RETURN_REGS +LibGetNumProcessors ( + VOID + ) +/*++ + +Routine Description: + + TODO: Add function description + +Arguments: + + None + +Returns: + + TODO: add return values + +--*/ +; + +SAL_RETURN_REGS +LibMpSaveMinStatePointer ( + IN UINT64 CpuGlobalId, + IN EFI_PHYSICAL_ADDRESS MinStatePointer + ) +/*++ + +Routine Description: + + TODO: Add function description + +Arguments: + + CpuGlobalId - TODO: add argument description + MinStatePointer - TODO: add argument description + +Returns: + + TODO: add return values + +--*/ +; + +SAL_RETURN_REGS +LibMpRestoreMinStatePointer ( + IN UINT64 CpuGlobalId + ) +/*++ + +Routine Description: + + TODO: Add function description + +Arguments: + + CpuGlobalId - TODO: add argument description + +Returns: + + TODO: add return values + +--*/ +; + +// +// MCA Class Functions +// + +EFI_STATUS +LibMcaGetStateInfo ( + IN UINT64 CpuId, + OUT EFI_PHYSICAL_ADDRESS *StateBufferPointer, + OUT UINT64 *RequiredStateBufferSize + ) +/*++ + +Routine Description: + + TODO: Add function description + +Arguments: + + CpuId - TODO: add argument description + StateBufferPointer - TODO: add argument description + RequiredStateBufferSize - TODO: add argument description + +Returns: + + TODO: add return values + +--*/ +; + +EFI_STATUS +LibMcaRegisterCpu ( + IN UINT64 CpuId, + IN EFI_PHYSICAL_ADDRESS StateBufferAddress + ) +/*++ + +Routine Description: + + TODO: Add function description + +Arguments: + + CpuId - TODO: add argument description + StateBufferAddress - TODO: add argument description + +Returns: + + TODO: add return values + +--*/ +; + +// +// FVB Variables Class +// +EFI_STATUS +EsalReadBlock ( + IN UINTN Instance, + IN EFI_LBA Lba, + IN UINTN Offset, + IN OUT UINTN *NumBytes, + IN UINT8 *Buffer + ) +/*++ + +Routine Description: + + TODO: Add function description + +Arguments: + + Instance - TODO: add argument description + Lba - TODO: add argument description + Offset - TODO: add argument description + NumBytes - TODO: add argument description + Buffer - TODO: add argument description + +Returns: + + TODO: add return values + +--*/ +; + +EFI_STATUS +EsalWriteBlock ( + IN UINTN Instance, + IN EFI_LBA Lba, + IN UINTN Offset, + IN OUT UINTN *NumBytes, + IN UINT8 *Buffer + ) +/*++ + +Routine Description: + + TODO: Add function description + +Arguments: + + Instance - TODO: add argument description + Lba - TODO: add argument description + Offset - TODO: add argument description + NumBytes - TODO: add argument description + Buffer - TODO: add argument description + +Returns: + + TODO: add return values + +--*/ +; + +EFI_STATUS +EsalEraseBlock ( + IN UINTN Instance, + IN UINTN Lba + ) +/*++ + +Routine Description: + + TODO: Add function description + +Arguments: + + Instance - TODO: add argument description + Lba - TODO: add argument description + +Returns: + + TODO: add return values + +--*/ +; + +EFI_STATUS +EsalGetVolumeAttributes ( + IN UINTN Instance, + OUT EFI_FVB_ATTRIBUTES *Attributes + ) +/*++ + +Routine Description: + + TODO: Add function description + +Arguments: + + Instance - TODO: add argument description + Attributes - TODO: add argument description + +Returns: + + TODO: add return values + +--*/ +; + +EFI_STATUS +EsalSetVolumeAttributes ( + IN UINTN Instance, + IN EFI_FVB_ATTRIBUTES Attributes + ) +/*++ + +Routine Description: + + TODO: Add function description + +Arguments: + + Instance - TODO: add argument description + Attributes - TODO: add argument description + +Returns: + + TODO: add return values + +--*/ +; + +EFI_STATUS +EsalGetPhysicalAddress ( + IN UINTN Instance, + OUT EFI_PHYSICAL_ADDRESS *Address + ) +/*++ + +Routine Description: + + TODO: Add function description + +Arguments: + + Instance - TODO: add argument description + Address - TODO: add argument description + +Returns: + + TODO: add return values + +--*/ +; + +EFI_STATUS +EsalGetBlockSize ( + IN UINTN Instance, + IN EFI_LBA Lba, + OUT UINTN *BlockSize, + OUT UINTN *NumOfBlocks + ) +/*++ + +Routine Description: + + TODO: Add function description + +Arguments: + + Instance - TODO: add argument description + Lba - TODO: add argument description + BlockSize - TODO: add argument description + NumOfBlocks - TODO: add argument description + +Returns: + + TODO: add return values + +--*/ +; + +// +// SAL ELOG Functions +// +EFI_STATUS +LibSalGetStateInfo ( + IN UINT64 McaType, + IN UINT8 *McaBuffer, + OUT UINTN *Size + ) +/*++ + +Routine Description: + + TODO: Add function description + +Arguments: + + McaType - TODO: add argument description + McaBuffer - TODO: add argument description + Size - TODO: add argument description + +Returns: + + TODO: add return values + +--*/ +; + +EFI_STATUS +LibSalGetStateInfoSize ( + IN UINT64 McaType, + OUT UINTN *Size + ) +/*++ + +Routine Description: + + TODO: Add function description + +Arguments: + + McaType - TODO: add argument description + Size - TODO: add argument description + +Returns: + + TODO: add return values + +--*/ +; + +EFI_STATUS +LibSalClearStateInfo ( + IN UINT64 McaType + ) +/*++ + +Routine Description: + + TODO: Add function description + +Arguments: + + McaType - TODO: add argument description + +Returns: + + TODO: add return values + +--*/ +; + +EFI_STATUS +LibEsalGetStateBuffer ( + IN UINT64 McaType, + OUT UINT8 **McaBuffer, + OUT UINTN *Index + ) +/*++ + +Routine Description: + + TODO: Add function description + +Arguments: + + McaType - TODO: add argument description + McaBuffer - TODO: add argument description + Index - TODO: add argument description + +Returns: + + TODO: add return values + +--*/ +; + +EFI_STATUS +LibEsalSaveStateBuffer ( + IN UINT64 McaType + ) +/*++ + +Routine Description: + + TODO: Add function description + +Arguments: + + McaType - TODO: add argument description + +Returns: + + TODO: add return values + +--*/ +; + +#endif diff --git a/EDK/Foundation/Library/Dxe/Include/Ipf/ProcDep.h b/EDK/Foundation/Library/Dxe/Include/Ipf/ProcDep.h new file mode 100644 index 0000000..2df940f --- /dev/null +++ b/EDK/Foundation/Library/Dxe/Include/Ipf/ProcDep.h @@ -0,0 +1,119 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + ProcDep.h + +Abstract: + + IPF specific Runtime Lib code. IPF has a SAL API that does not + exit on IA-32. Thus + +--*/ + +#ifndef _PROC_DEP_H_ +#define _PROC_DEP_H_ + +#include EFI_PROTOCOL_DEFINITION (ExtendedSalGuid) +#include EFI_PROTOCOL_DEFINITION (ExtendedSalBootService) +#include "SalApi.h" + +EFI_STATUS +RegisterEsalFunction ( + IN UINT64 FunctionId, + IN EFI_GUID *ClassGuid, + IN SAL_INTERNAL_EXTENDED_SAL_PROC Function, + IN VOID *ModuleGlobal + ) +/*++ + +Routine Description: + + Register ESAL Class Function and it's asociated global. + This function is boot service only! + +Arguments: + FunctionId - ID of function to register + ClassGuid - GUID of function class + Function - Function to register under ClassGuid/FunctionId pair + ModuleGlobal - Module global for Function. + +Returns: + EFI_SUCCESS - If ClassGuid/FunctionId Function was registered. + +--*/ +; + +EFI_STATUS +RegisterEsalClass ( + IN EFI_GUID *ClassGuid, + IN VOID *ModuleGlobal, + ... + ) +/*++ + +Routine Description: + + Register ESAL Class and it's asociated global. + This function is boot service only! + +Arguments: + ClassGuid - GUID of function class + ModuleGlobal - Module global for Function. + .. - SAL_INTERNAL_EXTENDED_SAL_PROC and FunctionId pairs. NULL + indicates the end of the list. + +Returns: + EFI_SUCCESS - All members of ClassGuid registered + +--*/ +; + +SAL_RETURN_REGS +EfiCallEsalService ( + IN EFI_GUID *ClassGuid, + IN UINT64 FunctionId, + IN UINT64 Arg2, + IN UINT64 Arg3, + IN UINT64 Arg4, + IN UINT64 Arg5, + IN UINT64 Arg6, + IN UINT64 Arg7, + IN UINT64 Arg8 + ) +/*++ + +Routine Description: + + Call module that is not linked direclty to this module. This code is IP + relative and hides the binding issues of virtual or physical calling. The + function that gets dispatched has extra arguments that include the registered + module global and a boolean flag to indicate if the system is in virutal mode. + +Arguments: + ClassGuid - GUID of function + FunctionId - Function in ClassGuid to call + Arg2 - Argument 2 ClassGuid/FunctionId defined + Arg3 - Argument 3 ClassGuid/FunctionId defined + Arg4 - Argument 4 ClassGuid/FunctionId defined + Arg5 - Argument 5 ClassGuid/FunctionId defined + Arg6 - Argument 6 ClassGuid/FunctionId defined + Arg7 - Argument 7 ClassGuid/FunctionId defined + Arg8 - Argument 8 ClassGuid/FunctionId defined + +Returns: + Status of ClassGuid/FuncitonId + +--*/ +; + +#endif diff --git a/EDK/Foundation/Library/Dxe/Include/Ipf/SalDriverLib.h b/EDK/Foundation/Library/Dxe/Include/Ipf/SalDriverLib.h new file mode 100644 index 0000000..c294706 --- /dev/null +++ b/EDK/Foundation/Library/Dxe/Include/Ipf/SalDriverLib.h @@ -0,0 +1,1454 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + SalDriverLib.h + +Abstract: + + SAL Driver Lib + +Revision History + +--*/ + +#ifndef _SAL_DRIVER_LIB_H_ +#define _SAL_DRIVER_LIB_H_ + +#include "Tiano.h" +#include "EfiDriverLib.h" +#include "SalApi.h" + +#include EFI_PROTOCOL_DEFINITION (ExtendedSalBootService) +#include EFI_PROTOCOL_DEFINITION (ExtendedSalGuid) + +// +// Assembly Functions +// +SAL_RETURN_REGS +LibGetEsalPhyData ( + VOID + ) +/*++ + +Routine Description: + + Get Esal global data in physical mode. + +Arguments: + + None + +Returns: + + Output regs + +--*/ +; + +SAL_RETURN_REGS +LibGetEsalVirtData ( + VOID + ) +/*++ + +Routine Description: + + Get Esal global data in virtual mode. + +Arguments: + + None + +Returns: + + Output regs + +--*/ +; + +SAL_RETURN_REGS +LibSetEsalPhyData ( + IN VOID *Ptr, + IN UINT64 GP + ) +/*++ + +Routine Description: + + Set Esal global data in physical mode. + +Arguments: + + Ptr - Pointer to the data + GP - Global pointer + +Returns: + + Output regs + +--*/ +; + +SAL_RETURN_REGS +LibSetEsalVirtData ( + IN VOID *Ptr, + IN UINT64 GP + ) +/*++ + +Routine Description: + + Set Esal global data in virtual mode. + +Arguments: + + Ptr - Pointer to the data + GP - Global pointer + +Returns: + + Output regs + +--*/ +; + +SAL_RETURN_REGS +LibGetGlobalPhyData ( + VOID + ) +/*++ + +Routine Description: + + Get Esal global data in physical mode. + +Arguments: + + None + +Returns: + + Output regs + +--*/ +; + +SAL_RETURN_REGS +LibGetGlobalVirtData ( + VOID + ) +/*++ + +Routine Description: + + Get Esal global data in virtual mode. + +Arguments: + + None + +Returns: + + Output regs + +--*/ +; + +SAL_RETURN_REGS +LibSetGlobalPhyData ( + IN VOID *Ptr, + IN UINT64 GP + ) +/*++ + +Routine Description: + + Set Esal global data in physical mode. + +Arguments: + + Ptr - Pointer to the data + GP - Global pointer + +Returns: + + Output regs + +--*/ +; + +SAL_RETURN_REGS +LibSetGlobalVirtData ( + IN VOID *Ptr, + IN UINT64 GP + ) +/*++ + +Routine Description: + + Set Esal global data in virtual mode. + +Arguments: + + Ptr - Pointer to the data + GP - Global pointer + +Returns: + + Output regs + +--*/ +; + +SAL_RETURN_REGS +GetIrrData ( + VOID + ) +/*++ + +Routine Description: + + Get interrupt request register. + +Arguments: + + None + +Returns: + + Output regs + +--*/ +; + +VOID +PrepareApsForHandOverToOS ( + VOID + ) +/*++ + +Routine Description: + + Prepare AP info for hand over to OS. + +Arguments: + + None + +Returns: + + None + +--*/ +; + +VOID +HandOverApsToOS ( + IN UINT64 a1, + IN UINT64 a2, + IN UINT64 a3 + ) +/*++ + +Routine Description: + + Hand over AP info to OS. + +Arguments: + + a1 - Address to call into + + a2 - GP + + a3 - Undefined + +Returns: + + None + +--*/ +; + +SAL_RETURN_REGS +GetPsrData ( + VOID + ) +/*++ + +Routine Description: + + Get PSR register. + +Arguments: + + None + +Returns: + + Output regs. + +--*/ +; + +SAL_RETURN_REGS +GetProcIdData ( + VOID + ) +/*++ + +Routine Description: + + Get LID + +Arguments: + + None + +Returns: + + Output regs + +--*/ +; + +VOID +SwitchCpuStack ( + IN UINT64 NewBsp, + IN UINT64 OldBsp + ) +/*++ + +Routine Description: + + Switch BSP + +Arguments: + + NewBsp - New BSP index + OldBsp - Old BSP index + +Returns: + + None + +--*/ +; + +// +// SAL Reset Class +// +VOID +SalResetSystem ( + IN EFI_RESET_TYPE ResetType, + IN EFI_STATUS ResetStatus, + IN UINTN DataSize, + IN CHAR16 *ResetData + ) +/*++ + +Routine Description: + + Reset system + +Arguments: + + ResetType - Reset type + ResetStatus - Reset status + DataSize - Size of ResetData + ResetData - Description string + +Returns: + + None + +--*/ +; + +// +// PAL PROC Class +// +SAL_RETURN_REGS +SalPalProc ( + IN UINT64 Arg1, + IN UINT64 Arg2, + IN UINT64 Arg3, + IN UINT64 Arg4 + ) +/*++ + +Routine Description: + + Call pal proc. + +Arguments: + + Arg1 - Pal call index + Arg2 - First arg + Arg3 - Second arg + Arg4 - Third arg + +Returns: + + Output regs + +--*/ +; + +SAL_RETURN_REGS +SalRegisterNewPalEntry ( + IN BOOLEAN PhysicalPalAddress, + IN EFI_PHYSICAL_ADDRESS NewPalAddress + ) +/*++ + +Routine Description: + + Register Pal entry. + +Arguments: + + PhysicalPalAddress - The address is physical or virtual + NewPalAddress - New Pal entry address + +Returns: + + Output regs + +--*/ +; + +SAL_RETURN_REGS +SalGetPalEntryPointer ( + IN BOOLEAN PhysicalPalAddress + ) +/*++ + +Routine Description: + + Get Pal entry. + +Arguments: + + PhysicalPalAddress - The address is physical or virtual + +Returns: + + Output regs + +--*/ +; + +// +// SAL MTC Class +// +EFI_STATUS +SalGetNextHighMonotonicCount ( + OUT UINT32 *HighCount + ) +/*++ + +Routine Description: + + Get next high 32 bits of monotonic count. + +Arguments: + + HighCount - High 32 bits of monotonic count. + +Returns: + + Status code + +--*/ +; + +// +// SAL BASE Class +// +SAL_RETURN_REGS +SalProcSetVectors ( + IN UINT64 SalVectorType, + IN UINT64 PhyAddr1, + IN UINT64 Gp1, + IN UINT64 LengthCs1, + IN UINT64 PhyAddr2, + IN UINT64 Gp2, + IN UINT64 LengthCs2 + ) +/*++ + +Routine Description: + + Set vectors. + +Arguments: + + SalVectorType - Vector type + PhyAddr1 - OS MCA entry point + Gp1 - GP for OS MCA entry + LengthCs1 - Length of OS MCA + PhyAddr2 - OS INIT entry point + Gp2 - GP for OS Init entry + LengthCs2 - Length of OS INIT + +Returns: + + Output regs + +--*/ +; + +SAL_RETURN_REGS +SalProcMcRendez ( + VOID + ) +/*++ + +Routine Description: + + Mc rendezvous function. + +Arguments: + + None + +Returns: + + Output regs + +--*/ +; + +SAL_RETURN_REGS +SalProcMcSetParams ( + IN UINT64 ParamType, + IN UINT64 IntOrMem, + IN UINT64 IntOrMemVal, + IN UINT64 Timeout, + IN UINT64 McaOpt + ) +/*++ + +Routine Description: + + Set MCA parameters. + +Arguments: + + ParamType - Parameter type + IntOrMem - Interrupt or memory address + IntOrMemVal - Interrupt number or memory address value + Timeout - Time out value + McaOpt - Option for MCA + +Returns: + + Output regs + +--*/ +; + +SAL_RETURN_REGS +EsalProcGetVectors ( + IN UINT64 VectorType + ) +/*++ + +Routine Description: + + Get OS MCA vector. + +Arguments: + + VectorType - Vector type + +Returns: + + Output regs + +--*/ +; + +SAL_RETURN_REGS +EsalProcMcGetParams ( + IN UINT64 ParamInfoType + ) +/*++ + +Routine Description: + + Get MCA parameter. + +Arguments: + + ParamInfoType - Parameter info type + +Returns: + + Output regs + +--*/ +; + +SAL_RETURN_REGS +EsalProcMcGetMcParams ( + VOID + ) +/*++ + +Routine Description: + + Get MCA parameter. + +Arguments: + + +Returns: + + Output regs + +--*/ +; + +SAL_RETURN_REGS +EsalProcGetMcCheckinFlags ( + IN UINT64 ProcessorUnit + ) +/*++ + +Routine Description: + + Get process status. + +Arguments: + + ProcessorUnit - Processor Index + +Returns: + + Output regs + +--*/ +; + +// +// Sal Base Class enums +// +typedef enum { + McaVector, + BspInitVector, + BootRendezVector, + ApInitVector +} ESAL_GET_VECTOR_TYPE; + +// +// Sal RTC Class +// +EFI_STATUS +SalGetTime ( + OUT EFI_TIME *Time, + OUT EFI_TIME_CAPABILITIES *Capabilities + ) +/*++ + +Routine Description: + + Returns the current time and date information, and the time-keeping + capabilities of the hardware platform. + +Arguments: + + Time - A pointer to storage to receive a snapshot of the current time. + Capabilities - An optional pointer to a buffer to receive the real time clock device¡¯s + capabilities. + +Returns: + + Status code + +--*/ +; + +EFI_STATUS +SalSetTime ( + OUT EFI_TIME *Time + ) +/*++ + +Routine Description: + + Sets the current local time and date information. + +Arguments: + + Time - A pointer to the current time. + +Returns: + + Status code + +--*/ +; + +EFI_STATUS +SalGetWakeupTime ( + OUT BOOLEAN *Enabled, + OUT BOOLEAN *Pending, + OUT EFI_TIME *Time + ) +/*++ + +Routine Description: + + Returns the current wakeup alarm clock setting. + +Arguments: + + Enabled - Indicates if the alarm is currently enabled or disabled. + Pending - Indicates if the alarm signal is pending and requires acknowledgement. + Time - The current alarm setting. + +Returns: + + Status code + +--*/ +; + +EFI_STATUS +SalSetWakeupTime ( + IN BOOLEAN Enable, + IN EFI_TIME *Time + ) +/*++ + +Routine Description: + + Sets the system wakeup alarm clock time. + +Arguments: + + Enable - Enable or disable the wakeup alarm. + Time - If Enable is TRUE, the time to set the wakeup alarm for. + If Enable is FALSE, then this parameter is optional, and may be NULL. + +Returns: + + Status code + +--*/ +; + +SAL_RETURN_REGS +SalInitializeThreshold ( + IN VOID *ThresholdStruct, + IN UINT64 Count, + IN UINT64 Duration + ) +/*++ + +Routine Description: + + Init threshold structure. + +Arguments: + + ThresholdStruct - Threshold structure + Count - Threshold count + Duration - Duration + +Returns: + + Output regs + +--*/ +; + +SAL_RETURN_REGS +SalBumpThresholdCount ( + IN VOID *ThresholdStruct, + IN UINT64 Count, + IN UINT64 Duration + ) +/*++ + +Routine Description: + + Bump threshold count. + +Arguments: + + ThresholdStruct - Threshold structure + Count - Threshold count + Duration - Duration + +Returns: + + Output regs + +--*/ +; + +SAL_RETURN_REGS +SalGetThresholdCount ( + IN VOID *ThresholdStruct, + IN UINT64 Count, + IN UINT64 Duration + ) +/*++ + +Routine Description: + + Get threshold structure. + +Arguments: + + ThresholdStruct - Threshold structure + Count - Threshold count + Duration - Duration + +Returns: + + Output regs + +--*/ +; + +// +// Common Lib Function +// +EFI_STATUS +RegisterEsalFunction ( + IN UINT64 FunctionId, + IN EFI_GUID *ClassGuid, + IN SAL_INTERNAL_EXTENDED_SAL_PROC Function, + IN VOID *ModuleGlobal + ) +/*++ + +Routine Description: + + Register ESAL Class Function and it's asociated global. + This function is boot service only! + +Arguments: + FunctionId - ID of function to register + ClassGuid - GUID of function class + Function - Function to register under ClassGuid/FunctionId pair + ModuleGlobal - Module global for Function. + +Returns: + EFI_SUCCESS - If ClassGuid/FunctionId Function was registered. + +--*/ +; + +EFI_STATUS +EfiInitializeSalDriverLib ( + IN BOOLEAN Runtime + ) +/*++ + +Routine Description: + + Initialize Sal driver lib. + +Arguments: + Runtime - At runtime or not? + +Returns: + Status code + +--*/ +; + +// +// MCA PMI INIT Registeration Functions. +// +EFI_STATUS +LibRegisterMcaFunction ( + IN EFI_SAL_MCA_HANDLER McaHandler, + IN VOID *ModuleGlobal, + IN BOOLEAN MakeFirst, + IN BOOLEAN MakeLast + ) +/*++ + +Routine Description: + + Register MCA handler. + +Arguments: + McaHandler - MCA handler + ModuleGlobal - Module global for function + MakeFirst - Make it as first? + MakeLast - Make it as last? + +Returns: + Status code + +--*/ +; + +EFI_STATUS +LibRegisterPmiFunction ( + IN EFI_SAL_PMI_HANDLER PmiHandler, + IN VOID *ModuleGlobal, + IN BOOLEAN MakeFirst, + IN BOOLEAN MakeLast + ) +/*++ + +Routine Description: + + Register PMI handler. + +Arguments: + PmiHandler - PMI handler + ModuleGlobal - Module global for function + MakeFirst - Make it as first? + MakeLast - Make it as last? + +Returns: + Status code + +--*/ +; + +EFI_STATUS +LibRegisterInitFunction ( + IN EFI_SAL_INIT_HANDLER InitHandler, + IN VOID *ModuleGlobal, + IN BOOLEAN MakeFirst, + IN BOOLEAN MakeLast + ) +/*++ + +Routine Description: + + Register INIT handler. + +Arguments: + InitHandler - INIT handler + ModuleGlobal - Module global for function + MakeFirst - Make it as first? + MakeLast - Make it as last? + +Returns: + Status code + +--*/ +; + +// +// Base IO Class Functions +// +EFI_STATUS +ESalIoRead ( + IN EFI_CPU_IO_PROTOCOL_WIDTH Width, + IN UINT64 Address, + IN UINTN Count, + IN OUT VOID *Buffer + ) +/*++ + +Routine Description: + + Io read operation. + +Arguments: + + Width - Width of read operation + Address - Start IO address to read + Count - Read count + Buffer - Buffer to store result + +Returns: + + Status code + +--*/ +; + +EFI_STATUS +ESalIoWrite ( + IN EFI_CPU_IO_PROTOCOL_WIDTH Width, + IN UINT64 Address, + IN UINTN Count, + IN OUT VOID *Buffer + ) +/*++ + +Routine Description: + + Io write operation. + +Arguments: + + Width - Width of write operation + Address - Start IO address to write + Count - Write count + Buffer - Buffer to write to the address + +Returns: + + Status code + +--*/ +; + +EFI_STATUS +ESalMemRead ( + IN EFI_CPU_IO_PROTOCOL_WIDTH Width, + IN UINT64 Address, + IN UINTN Count, + IN OUT VOID *Buffer + ) +/*++ + +Routine Description: + Perform a Memory mapped IO read into Buffer. + +Arguments: + Width - Width of each read transaction. + Address - Memory mapped IO address to read + Count - Number of Width quanta to read + Buffer - Buffer to read data into. size is Width * Count + +Returns: + Status code + +--*/ +; + +EFI_STATUS +ESalMemWrite ( + IN EFI_CPU_IO_PROTOCOL_WIDTH Width, + IN UINT64 Address, + IN UINTN Count, + IN OUT VOID *Buffer + ) +/*++ + +Routine Description: + Perform a memory mapped IO write into Buffer. + +Arguments: + Width - Width of write transaction, and repeat operation to use + Address - IO address to write + Count - Number of times to write the IO address. + Buffer - Buffer to write data from. size is Width * Count + +Returns: + Status code + +--*/ +; + +// +// PCI Class Functions +// +SAL_RETURN_REGS +SalPCIConfigRead ( + IN UINT64 Address, + IN UINT64 Size + ) +/*++ + +Routine Description: + Pci config space read. + +Arguments: + Address - PCI address to read + Size - Size to read + +Returns: + Output regs + +--*/ +; + +SAL_RETURN_REGS +SalPCIConfigWrite ( + IN UINT64 Address, + IN UINT64 Size, + IN UINT64 Value + ) +/*++ + +Routine Description: + Pci config space write. + +Arguments: + Address - PCI address to write + Size - Size to write + Value - Value to write + +Returns: + Output regs + +--*/ +; + +// +// MP Class Functions +// +SAL_RETURN_REGS +LibMPAddCpuData ( + IN UINT64 CpuGlobalId, + IN BOOLEAN Enabled, + IN UINT64 PalCompatability + ) +/*++ + +Routine Description: + Add CPU data. + +Arguments: + CpuGlobalId - CPU ID + Enabled - Enabled or not + PalCompatability - Pal compatability + +Returns: + Output regs + +--*/ +; + +SAL_RETURN_REGS +LibMPRemoveCpuData ( + IN UINT64 CpuGlobalId + ) +/*++ + +Routine Description: + Remove CPU data. + +Arguments: + CpuGlobalId - CPU ID + +Returns: + Output regs + +--*/ +; + +SAL_RETURN_REGS +LibMPModifyCpuData ( + IN UINT64 CpuGlobalId, + IN BOOLEAN Enabled, + IN UINT64 PalCompatability + ) +/*++ + +Routine Description: + Modify CPU data. + +Arguments: + CpuGlobalId - CPU ID + Enabled - Enabled or not + PalCompatability - Pal compatability + +Returns: + Output regs + +--*/ +; + +SAL_RETURN_REGS +LibMPGetCpuDataByID ( + IN UINT64 CpuGlobalId, + IN BOOLEAN IndexByEnabledCpu + ) +/*++ + +Routine Description: + Get CPU data. + +Arguments: + CpuGlobalId - CPU ID + IndexByEnabledCpu - Whether indexed by enabled CPU + +Returns: + Output regs + +--*/ +; + +SAL_RETURN_REGS +LibMPGetCpuDataByIndex ( + IN UINT64 Index, + IN BOOLEAN IndexByEnabledCpu + ) +/*++ + +Routine Description: + Get CPU data. + +Arguments: + Index - CPU index + IndexByEnabledCpu - Whether indexed by enabled CPU + +Returns: + Output regs + +--*/ +; + +SAL_RETURN_REGS +LibMPSendIpi ( + IN UINT64 ProcessorNumber, + IN UINT64 VectorNumber, + IN EFI_DELIVERY_MODE DeliveryMode, + IN BOOLEAN IRFlag + ) +/*++ + +Routine Description: + Send IPI. + +Arguments: + ProcessorNumber - Processor number + VectorNumber - Vector number + DeliveryMode - Delivery mode + IRFlag - Interrupt Redirection flag + +Returns: + Output regs + +--*/ +; + +SAL_RETURN_REGS +LibMpCurrentProcessor ( + IN BOOLEAN IndexByEnabledCpu + ) +/*++ + +Routine Description: + Get current processor index. + +Arguments: + IndexByEnabledCpu - Whether indexed by enabled CPU + +Returns: + Output regs + +--*/ +; + +SAL_RETURN_REGS +LibGetNumProcessors ( + VOID + ) +/*++ + +Routine Description: + Get number of processors. + +Arguments: + None + +Returns: + Output regs + +--*/ +; + +SAL_RETURN_REGS +LibMpSaveMinStatePointer ( + IN UINT64 CpuGlobalId, + IN EFI_PHYSICAL_ADDRESS MinStatePointer + ) +/*++ + +Routine Description: + Register pointer to save min state. + +Arguments: + CpuGlobalId - CPU global ID + MinStatePointer - Pointer to save min state + +Returns: + Output regs + +--*/ +; + +SAL_RETURN_REGS +LibMpRestoreMinStatePointer ( + IN UINT64 CpuGlobalId + ) +/*++ + +Routine Description: + Restore pointer to save min state. + +Arguments: + CpuGlobalId - CPU global ID + +Returns: + Output regs + +--*/ +; + +// +// MCA Class Functions +// +EFI_STATUS +LibMcaGetStateInfo ( + IN UINT64 CpuId, + OUT EFI_PHYSICAL_ADDRESS *StateBufferPointer, + OUT UINT64 *RequiredStateBufferSize + ) +/*++ + +Routine Description: + MCA get state info. + +Arguments: + CpuId - CPU ID + StateBufferPointer - Pointer of state buffer + RequiredStateBufferSize - Size of required state buffer + +Returns: + Status code + +--*/ +; + +EFI_STATUS +LibMcaRegisterCpu ( + IN UINT64 CpuId, + IN EFI_PHYSICAL_ADDRESS StateBufferAddress + ) +/*++ + +Routine Description: + MCA register CPU state info. + +Arguments: + CpuId - CPU ID + StateBufferAddress - Pointer of state buffer + +Returns: + Status code + +--*/ +; + +// +// SAL ELOG Functions +// +EFI_STATUS +LibSalGetStateInfo ( + IN UINT64 McaType, + IN UINT8 *McaBuffer, + OUT UINTN *Size + ) +/*++ + +Routine Description: + Get state info. + +Arguments: + McaType - MCA type + McaBuffer - Info buffer provided by caller + Size - Size of info + +Returns: + Status code + +--*/ +; + +EFI_STATUS +LibSalGetStateInfoSize ( + IN UINT64 McaType, + OUT UINTN *Size + ) +/*++ + +Routine Description: + Get state info size. + +Arguments: + McaType - MCA type + Size - Size required + +Returns: + Status code + +--*/ +; + +EFI_STATUS +LibSalClearStateInfo ( + IN UINT64 McaType + ) +/*++ + +Routine Description: + Clear state info. + +Arguments: + McaType - MCA type + +Returns: + Status code + +--*/ +; + +EFI_STATUS +LibEsalGetStateBuffer ( + IN UINT64 McaType, + OUT UINT8 **McaBuffer, + OUT UINTN *Index + ) +/*++ + +Routine Description: + Get state buffer. + +Arguments: + McaType - MCA type + McaBuffer - MCA buffer + Index - CPU index + +Returns: + Status code + +--*/ +; + +EFI_STATUS +LibEsalSaveStateBuffer ( + IN UINT64 McaType + ) +/*++ + +Routine Description: + Save state buffer. + +Arguments: + McaType - MCA type + +Returns: + Status code + +--*/ +; + +#endif diff --git a/EDK/Foundation/Library/Dxe/Include/LinkedList.h b/EDK/Foundation/Library/Dxe/Include/LinkedList.h new file mode 100644 index 0000000..4e1d140 --- /dev/null +++ b/EDK/Foundation/Library/Dxe/Include/LinkedList.h @@ -0,0 +1,310 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + LinkedList.h + +Abstract: + + This implementation of a linked list provides data structures for the + list itself and for list nodes. It provides operations for initializing + the list, modifying the list, and walking the list. + +--*/ + +// +// Prevent multiple includes in the same source file +// +#ifndef _LINKED_LIST_H_ +#define _LINKED_LIST_H_ + + +typedef struct _EFI_LIST_ENTRY { + struct _EFI_LIST_ENTRY *ForwardLink; + struct _EFI_LIST_ENTRY *BackLink; +} EFI_LIST_ENTRY; + +typedef EFI_LIST_ENTRY EFI_LIST; +typedef EFI_LIST_ENTRY EFI_LIST_NODE; + +#define INITIALIZE_LIST_HEAD_VARIABLE(ListHead) {&ListHead, &ListHead} + +// +// EFI_FIELD_OFFSET - returns the byte offset to a field within a structure +// + +#define EFI_FIELD_OFFSET(TYPE,Field) ((UINTN)(&(((TYPE *) 0)->Field))) + +// +// A lock structure +// + +typedef struct { + EFI_TPL Tpl; + EFI_TPL OwnerTpl; + UINTN Lock; +} FLOCK; + +VOID +InitializeListHead ( + EFI_LIST_ENTRY *List + ) +/*++ + +Routine Description: + + Initialize the head of the List. The caller must allocate the memory + for the EFI_LIST. This function must be called before the other linked + list macros can be used. + +Arguments: + + List - Pointer to list head to initialize + +Returns: + + None. + +--*/ +; + +BOOLEAN +IsListEmpty ( + EFI_LIST_ENTRY *List + ) +/*++ + +Routine Description: + + Return TRUE is the list contains zero nodes. Otherzise return FALSE. + The list must have been initialized with InitializeListHead () before using + this function. + +Arguments: + + List - Pointer to list head to test + + +Returns: + + Return TRUE is the list contains zero nodes. Otherzise return FALSE. + +--*/ +; + +VOID +RemoveEntryList ( + EFI_LIST_ENTRY *Entry + ) +/*++ + +Routine Description: + + Remove Node from the doubly linked list. It is the caller's responsibility + to free any memory used by the entry if needed. The list must have been + initialized with InitializeListHead () before using this function. + +Arguments: + + Entry - Element to remove from the list. + +Returns: + + None + +--*/ +; + +VOID +InsertTailList ( + EFI_LIST_ENTRY *ListHead, + EFI_LIST_ENTRY *Entry + ) +/*++ + +Routine Description: + + Insert a Node into the end of a doubly linked list. The list must have + been initialized with InitializeListHead () before using this function. + +Arguments: + + ListHead - Head of doubly linked list + + Entry - Element to insert at the end of the list. + +Returns: + + None + +--*/ +; + +VOID +InsertHeadList ( + EFI_LIST_ENTRY *ListHead, + EFI_LIST_ENTRY *Entry + ) +/*++ + +Routine Description: + + Insert a Node into the start of a doubly linked list. The list must have + been initialized with InitializeListHead () before using this function. + +Arguments: + + ListHead - Head of doubly linked list + + Entry - Element to insert to beginning of list + +Returns: + + None + +--*/ +; + +VOID +SwapListEntries ( + EFI_LIST_ENTRY *Entry1, + EFI_LIST_ENTRY *Entry2 + ) +/*++ + +Routine Description: + + Swap the location of the two elements of a doubly linked list. Node2 + is placed in front of Node1. The list must have been initialized with + InitializeListHead () before using this function. + +Arguments: + + Entry1 - Element in the doubly linked list in front of Node2. + + Entry2 - Element in the doubly linked list behind Node1. + +Returns: + + None + +--*/ +; + +EFI_LIST_ENTRY * +GetFirstNode ( + EFI_LIST_ENTRY *List + ) +/*++ + +Routine Description: + + Return the first node pointed to by the list head. The list must + have been initialized with InitializeListHead () before using this + function and must contain data. + +Arguments: + + List - The head of the doubly linked list. + +Returns: + + Pointer to the first node, if the list contains nodes. The list will + return a null value--that is, the value of List--when the list is empty. + See the description of IsNull for more information. + + +--*/ +; + +EFI_LIST_ENTRY * +GetNextNode ( + EFI_LIST_ENTRY *List, + EFI_LIST_ENTRY *Node + ) +/*++ + +Routine Description: + + Returns the node following Node in the list. The list must + have been initialized with InitializeListHead () before using this + function and must contain data. + +Arguments: + + List - The head of the list. MUST NOT be the literal value NULL. + Node - The node in the list. This value MUST NOT be the literal value NULL. + See the description of IsNull for more information. + +Returns: + + Pointer to the next node, if one exists. Otherwise, returns a null value, + which is actually a pointer to List. + See the description of IsNull for more information. + +--*/ +; + +BOOLEAN +IsNull ( + EFI_LIST_ENTRY *List, + EFI_LIST_ENTRY *Node + ) +/*++ + +Routine Description: + + Determines whether the given node is null. Note that Node is null + when its value is equal to the value of List. It is an error for + Node to be the literal value NULL [(VOID*)0x0]. + +Arguments: + + List - The head of the list. MUST NOT be the literal value NULL. + Node - The node to test. MUST NOT be the literal value NULL. See + the description above. + +Returns: + + Returns true if the node is null. + +--*/ +; + +BOOLEAN +IsNodeAtEnd ( + EFI_LIST_ENTRY *List, + EFI_LIST_ENTRY *Node + ) +/*++ + +Routine Description: + + Determines whether the given node is at the end of the list. Used + to walk the list. The list must have been initialized with + InitializeListHead () before using this function and must contain + data. + +Arguments: + + List - The head of the list. MUST NOT be the literal value NULL. + Node - The node to test. MUST NOT be the literal value NULL. + See the description of IsNull for more information. + +Returns: + + Returns true if the list is the tail. + +--*/ +; + +#endif diff --git a/EDK/Foundation/Library/Dxe/Include/RtDevicePath.h b/EDK/Foundation/Library/Dxe/Include/RtDevicePath.h new file mode 100644 index 0000000..765b575 --- /dev/null +++ b/EDK/Foundation/Library/Dxe/Include/RtDevicePath.h @@ -0,0 +1,231 @@ +/*++ + +Copyright (c) 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + RtDevicePath.h + +Abstract: + + Device Path services. The thing to remember is device paths are built out of + nodes. The device path is terminated by an end node that is length + sizeof(EFI_DEVICE_PATH_PROTOCOL). That would be why there is sizeof(EFI_DEVICE_PATH_PROTOCOL) + all over this file. + + The only place where multi-instance device paths are supported is in + environment varibles. Multi-instance device paths should never be placed + on a Handle. + +--*/ +#ifndef _RT_DEVICE_PATH_H_ +#define _RT_DEVICE_PATH_H_ + +BOOLEAN +RtEfiIsDevicePathMultiInstance ( + IN EFI_DEVICE_PATH_PROTOCOL *DevicePath + ) +/*++ + +Routine Description: + Return TRUE is this is a multi instance device path. + +Arguments: + DevicePath - A pointer to a device path data structure. + + +Returns: + TRUE - If DevicePath is multi instance. + FALSE - If DevicePath is not multi instance. + +--*/ +; + +EFI_DEVICE_PATH_PROTOCOL * +RtEfiDevicePathInstance ( + IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath, + OUT UINTN *Size + ) +/*++ + +Routine Description: + Function retrieves the next device path instance from a device path data structure. + +Arguments: + DevicePath - A pointer to a device path data structure. + + Size - A pointer to the size of a device path instance in bytes. + +Returns: + + This function returns a pointer to the current device path instance. + In addition, it returns the size in bytes of the current device path instance in Size, + and a pointer to the next device path instance in DevicePath. + If there are no more device path instances in DevicePath, then DevicePath will be set to NULL. + +--*/ +; + +UINTN +RtEfiDevicePathSize ( + IN EFI_DEVICE_PATH_PROTOCOL *DevPath + ) +/*++ + +Routine Description: + + Calculate the size of a whole device path. + +Arguments: + + DevPath - The pointer to the device path data. + +Returns: + + Size of device path data structure.. + +--*/ +; + +EFI_DEVICE_PATH_PROTOCOL * +RtEfiAppendDevicePath ( + IN EFI_DEVICE_PATH_PROTOCOL *Src1, + IN EFI_DEVICE_PATH_PROTOCOL *Src2 + ) +/*++ + +Routine Description: + Function is used to append a Src1 and Src2 together. + +Arguments: + Src1 - A pointer to a device path data structure. + + Src2 - A pointer to a device path data structure. + +Returns: + + A pointer to the new device path is returned. + NULL is returned if space for the new device path could not be allocated from pool. + It is up to the caller to free the memory used by Src1 and Src2 if they are no longer needed. + +--*/ +; + +EFI_DEVICE_PATH_PROTOCOL * +RtEfiDevicePathFromHandle ( + IN EFI_HANDLE Handle + ) +/*++ + +Routine Description: + + Locate device path protocol interface on a device handle. + +Arguments: + + Handle - The device handle + +Returns: + + Device path protocol interface located. + +--*/ +; + +EFI_DEVICE_PATH_PROTOCOL * +RtEfiDuplicateDevicePath ( + IN EFI_DEVICE_PATH_PROTOCOL *DevPath + ) +/*++ + +Routine Description: + Duplicate a new device path data structure from the old one. + +Arguments: + DevPath - A pointer to a device path data structure. + +Returns: + A pointer to the new allocated device path data. + Caller must free the memory used by DevicePath if it is no longer needed. + +--*/ +; + +EFI_DEVICE_PATH_PROTOCOL * +RtEfiAppendDevicePathNode ( + IN EFI_DEVICE_PATH_PROTOCOL *Src1, + IN EFI_DEVICE_PATH_PROTOCOL *Src2 + ) +/*++ + +Routine Description: + Function is used to append a device path node to the end of another device path. + +Arguments: + Src1 - A pointer to a device path data structure. + + Src2 - A pointer to a device path data structure. + +Returns: + This function returns a pointer to the new device path. + If there is not enough temporary pool memory available to complete this function, + then NULL is returned. + + +--*/ +; + +EFI_DEVICE_PATH_PROTOCOL * +RtEfiFileDevicePath ( + IN EFI_HANDLE Device OPTIONAL, + IN CHAR16 *FileName + ) +/*++ + +Routine Description: + Create a device path that appends a MEDIA_DEVICE_PATH with + FileNameGuid to the device path of DeviceHandle. + +Arguments: + Device - Optional Device Handle to use as Root of the Device Path + + FileName - FileName + +Returns: + EFI_DEVICE_PATH_PROTOCOL that was allocated from dynamic memory + or NULL pointer. + +--*/ +; + +EFI_DEVICE_PATH_PROTOCOL * +RtEfiAppendDevicePathInstance ( + IN EFI_DEVICE_PATH_PROTOCOL *Src, + IN EFI_DEVICE_PATH_PROTOCOL *Instance + ) +/*++ + +Routine Description: + + Append a device path instance to another. + +Arguments: + + Src - The device path instance to be appended with. + Instance - The device path instance appending the other. + +Returns: + + The contaction of these two. + +--*/ +; + +#endif diff --git a/EDK/Foundation/Library/Dxe/Include/SmmRuntimeLib.h b/EDK/Foundation/Library/Dxe/Include/SmmRuntimeLib.h new file mode 100644 index 0000000..d60a029 --- /dev/null +++ b/EDK/Foundation/Library/Dxe/Include/SmmRuntimeLib.h @@ -0,0 +1,75 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + SmmRuntimeLib.h + +Abstract: + + SMM Related prototypes that can be referenced for Preboot Configuration only. + +--*/ + +#ifndef _SMM_RUNTIME_LIB_H_ +#define _SMM_RUNTIME_LIB_H_ + +#include "Tiano.h" +#include "EfiRuntimeLib.h" + +BOOLEAN +EfiInSmm ( + VOID + ) +/*++ + +Routine Description: + + Test whether in Smm mode currently. + +Arguments: + + None + +Returns: + + TRUE - In Smm mode + FALSE - Not in Smm mode + +--*/ +; + +EFI_STATUS +RegisterSmmRuntimeDriver ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable, + OUT EFI_HANDLE *SmmImageHandle + ) +/*++ + +Routine Description: + + Registers a Driver with the SMM. + +Arguments: + + ImageHandle - The firmware allocated handle for the EFI image. + SystemTable - A pointer to the EFI System Table. + SmmImageHandle - Image handle returned by the SMM driver. + +Returns: + + Status code + +--*/ +; + +#endif diff --git a/EDK/Foundation/Library/Dxe/Include/x64/CpuFuncs.h b/EDK/Foundation/Library/Dxe/Include/x64/CpuFuncs.h new file mode 100644 index 0000000..a39647d --- /dev/null +++ b/EDK/Foundation/Library/Dxe/Include/x64/CpuFuncs.h @@ -0,0 +1,262 @@ +/*++ + +Copyright (c) 2005 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + CpuFuncs.h + +Abstract: + +--*/ + +#ifndef _CPU_FUNCS_H_ +#define _CPU_FUNCS_H_ + +#define EFI_CPUID_SIGNATURE 0x0 +#define EFI_CPUID_VERSION_INFO 0x1 +#define EFI_CPUID_CACHE_INFO 0x2 +#define EFI_CPUID_SERIAL_NUMBER 0x3 +#define EFI_CPUID_EXTENDED_FUNCTION 0x80000000 +#define EFI_CPUID_EXTENDED_CPU_SIG 0x80000001 +#define EFI_CPUID_BRAND_STRING1 0x80000002 +#define EFI_CPUID_BRAND_STRING2 0x80000003 +#define EFI_CPUID_BRAND_STRING3 0x80000004 + +// +// CPUID version information masks +// Note: leaving masks here is for the compatibility +// use EfiCpuVersion (...) instead +// + +#define EFI_CPUID_FAMILY 0x0F00 +#define EFI_CPUID_MODEL 0x00F0 +#define EFI_CPUID_STEPPING 0x000F + +#define EFI_CPUID_PENTIUM_M 0x0600 +#define EFI_CPUID_BANIAS 0x0090 +#define EFI_CPUID_DOTHAN 0x00D0 +#define EFI_CPUID_NETBURST 0x0F00 + +#define EFI_MSR_IA32_PLATFORM_ID 0x17 +#define EFI_MSR_IA32_APIC_BASE 0x1B +#define EFI_MSR_EBC_HARD_POWERON 0x2A +#define EFI_MSR_EBC_SOFT_POWERON 0x2B +#define BINIT_DRIVER_DISABLE 0x40 +#define INTERNAL_MCERR_DISABLE 0x20 +#define INITIATOR_MCERR_DISABLE 0x10 +#define EFI_MSR_EBC_FREQUENCY_ID 0x2C +#define EFI_MSR_IA32_BIOS_UPDT_TRIG 0x79 +#define EFI_MSR_IA32_BIOS_SIGN_ID 0x8B +#define EFI_MSR_PSB_CLOCK_STATUS 0xCD +#define EFI_APIC_GLOBAL_ENABLE 0x800 +#define EFI_MSR_IA32_MISC_ENABLE 0x1A0 +#define LIMIT_CPUID_MAXVAL_ENABLE_BIT 0x00400000 +#define AUTOMATIC_THERMAL_CONTROL_ENABLE_BIT 0x00000008 +#define COMPATIBLE_FPU_OPCODE_ENABLE_BIT 0x00000004 +#define LOGICAL_PROCESSOR_PRIORITY_ENABLE_BIT 0x00000002 +#define FAST_STRING_ENABLE_BIT 0x00000001 + +#define EFI_CACHE_VARIABLE_MTRR_BASE 0x200 +#define EFI_CACHE_VARIABLE_MTRR_END 0x20F +#define EFI_CACHE_IA32_MTRR_DEF_TYPE 0x2FF +#define EFI_CACHE_VALID_ADDRESS 0xFFFFFF000 +#define EFI_CACHE_MTRR_VALID 0x800 +#define EFI_CACHE_FIXED_MTRR_VALID 0x400 +#define EFI_MSR_VALID_MASK 0xFFFFFFFFF + +#define EFI_IA32_MTRR_FIX64K_00000 0x250 +#define EFI_IA32_MTRR_FIX16K_80000 0x258 +#define EFI_IA32_MTRR_FIX16K_A0000 0x259 +#define EFI_IA32_MTRR_FIX4K_C0000 0x268 +#define EFI_IA32_MTRR_FIX4K_C8000 0x269 +#define EFI_IA32_MTRR_FIX4K_D0000 0x26A +#define EFI_IA32_MTRR_FIX4K_D8000 0x26B +#define EFI_IA32_MTRR_FIX4K_E0000 0x26C +#define EFI_IA32_MTRR_FIX4K_E8000 0x26D +#define EFI_IA32_MTRR_FIX4K_F0000 0x26E +#define EFI_IA32_MTRR_FIX4K_F8000 0x26F + +#define EFI_IA32_MCG_CAP 0x179 +#define EFI_IA32_MCG_CTL 0x17B +#define EFI_IA32_MC0_CTL 0x400 +#define EFI_IA32_MC0_STATUS 0x401 + +#define EFI_CACHE_UNCACHEABLE 0 +#define EFI_CACHE_WRITECOMBINING 1 +#define EFI_CACHE_WRITETHROUGH 4 +#define EFI_CACHE_WRITEPROTECTED 5 +#define EFI_CACHE_WRITEBACK 6 + +// +// Combine f(FamilyId), m(Model), s(SteppingId) to a single 32 bit number +// +#define EfiMakeCpuVersion(f, m, s) \ + (((UINT32) (f) << 16) | ((UINT32) (m) << 8) | ((UINT32) (s))) + + +typedef struct { + UINT32 HeaderVersion; + UINT32 UpdateRevision; + UINT32 Date; + UINT32 ProcessorId; + UINT32 Checksum; + UINT32 LoaderRevision; + UINT32 ProcessorFlags; + UINT32 DataSize; + UINT32 TotalSize; + UINT8 Reserved[12]; +} EFI_CPU_MICROCODE_HEADER; + +typedef struct { + UINT32 ExtSigCount; + UINT32 ExtChecksum; + UINT8 Reserved[12]; + UINT32 ProcessorId; + UINT32 ProcessorFlags; + UINT32 Checksum; +} EFI_CPU_MICROCODE_EXT_HEADER; + +typedef struct { + UINT32 RegEax; + UINT32 RegEbx; + UINT32 RegEcx; + UINT32 RegEdx; +} EFI_CPUID_REGISTER; + +VOID +EfiWriteMsr ( + IN UINT32 Input, + IN UINT64 Value + ) +/*++ + +Routine Description: + + Write Cpu MSR + +Arguments: + + Input -The index value to select the register + Value -The value to write to the selected register + +Returns: + + None + +--*/ +; + +UINT64 +EfiReadMsr ( + IN UINT32 Input + ) +/*++ + +Routine Description: + + Read Cpu MSR. + +Arguments: + + Input: -The index value to select the register + +Returns: + + Return the read data + +--*/ +; + +VOID +EfiCpuid ( + IN UINT32 RegEax, + OUT EFI_CPUID_REGISTER *Reg + ) +/*++ + +Routine Description: + + Get the Cpu info by excute the CPUID instruction. + +Arguments: + + RegEax -The input value to put into register EAX + Reg -The Output value + +Returns: + + None + +--*/ +; + +VOID +EfiCpuVersion ( + IN UINT16 *FamilyId, OPTIONAL + IN UINT8 *Model, OPTIONAL + IN UINT8 *SteppingId, OPTIONAL + IN UINT8 *Processor OPTIONAL + ) +/*++ + +Routine Description: + Extract CPU detail version infomation + +Arguments: + FamilyId - FamilyId, including ExtendedFamilyId + Model - Model, including ExtendedModel + SteppingId - SteppingId + Processor - Processor + +--*/ +; + +UINT64 +EfiReadTsc ( + VOID + ) +/*++ + +Routine Description: + + Read Time stamp. + +Arguments: + + None + +Returns: + + Return the read data + +--*/ +; +VOID +EfiCpuidExt ( + IN UINT32 RegisterInEax, + IN UINT32 CacheLevel, + OUT EFI_CPUID_REGISTER *Regs + ) +/*++ +Routine Description: + When RegisterInEax != 4, the functionality is the same as EfiCpuid. + When RegisterInEax == 4, the function return the deterministic cache + parameters by excuting the CPUID instruction +Arguments: + RegisterInEax: - The input value to put into register EAX + CacheLevel: - The deterministic cache level + Regs: - The Output value +Returns: + None +--*/ +; + +#endif diff --git a/EDK/Foundation/Library/Dxe/Include/x64/ProcDep.h b/EDK/Foundation/Library/Dxe/Include/x64/ProcDep.h new file mode 100644 index 0000000..b3e3be4 --- /dev/null +++ b/EDK/Foundation/Library/Dxe/Include/x64/ProcDep.h @@ -0,0 +1,29 @@ +/*++ + +Copyright (c) 2005, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + ProcDep.h + +Abstract: + + x64 specific Runtime Lib code. At this time there is non. + IPF has different code due to extra API requirements. + +--*/ + +#ifndef _PROC_DEP_H_ +#define _PROC_DEP_H_ + + + +#endif |