diff options
Diffstat (limited to 'EDK/Foundation/Library/EdkIIGlueLib')
578 files changed, 75796 insertions, 0 deletions
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/EntryPoints/EdkIIGlueDxeDriverEntryPoint.c b/EDK/Foundation/Library/EdkIIGlueLib/EntryPoints/EdkIIGlueDxeDriverEntryPoint.c new file mode 100644 index 0000000..07db3b2 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/EntryPoints/EdkIIGlueDxeDriverEntryPoint.c @@ -0,0 +1,592 @@ +/*++ + +Copyright (c) 2004 - 2011, 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: + + EdkIIGlueDxeDriverEntryPoint.c + +Abstract: + + DXE Driver entry point template file + +--*/ + +#include "EdkIIGlueDxe.h" +#include "Common/EdkIIGlueDependencies.h" + +// +// Check definitions in .inf file to determine __EDKII_GLUE_DRIVER_MODEL_PROTOCOL_SELECTION__ +// +// __EDKII_GLUE_DRIVER_MODEL_PROTOCOL_SELECTION__ +// 1: only install ComponentName, DriverConfiguration and DriverDiagnostics +// 2: only install ComponentName2, DriverConfiguration2 and DriverDiagnostics2 +// 3: install all including ComponentName, DriverConfiguration, DriverDiagnostics AND +// ComponentName2, DriverConfiguration2 and DriverDiagnostics2 +// 4: install automatically according to EFI_SPECIFICATION_VERSION: +// if EFI_SPECIFICATION_VERSION < 0x00020000: only install ComponentName, DriverConfiguration and DriverDiagnostics +// if EFI_SPECIFICATION_VERSION >= 0x00020000: only install ComponentName2, DriverConfiguration2 and DriverDiagnostics2 +// +#ifdef __EDKII_GLUE_DRIVER_MODEL_VERSION_1_DEFINED__ +#undef __EDKII_GLUE_DRIVER_MODEL_VERSION_1_DEFINED__ +#endif + +#ifdef __EDKII_GLUE_DRIVER_MODEL_VERSION_2_DEFINED__ +#undef __EDKII_GLUE_DRIVER_MODEL_VERSION_2_DEFINED__ +#endif + +#ifdef __EDKII_GLUE_DRIVER_MODEL_PROTOCOL_SELECTION__ +#undef __EDKII_GLUE_DRIVER_MODEL_PROTOCOL_SELECTION__ +#endif + +#if defined(__EDKII_GLUE_COMPONENT_NAME_PROTOCOL_INSTANCE__) || defined(__EDKII_GLUE_DRIVER_CONFIGURATION_PROTOCOL_INSTANCE__) || defined(__EDKII_GLUE_DRIVER_DIAGNOSTICS_PROTOCOL_INSTANCE__) +#define __EDKII_GLUE_DRIVER_MODEL_VERSION_1_DEFINED__ +#endif + +#if defined(__EDKII_GLUE_COMPONENT_NAME2_PROTOCOL_INSTANCE__) || defined(__EDKII_GLUE_DRIVER_CONFIGURATION2_PROTOCOL_INSTANCE__) || defined(__EDKII_GLUE_DRIVER_DIAGNOSTICS2_PROTOCOL_INSTANCE__) +#define __EDKII_GLUE_DRIVER_MODEL_VERSION_2_DEFINED__ +#endif + +#if defined(__EDKII_GLUE_DRIVER_MODEL_VERSION_1_DEFINED__) && !defined(__EDKII_GLUE_DRIVER_MODEL_VERSION_2_DEFINED__) && !defined(__EDKII_GLUE_DRIVER_MODEL_AUTO_SELECT_PROTOCOLS_BY_EFI_VERSION__) +#define __EDKII_GLUE_DRIVER_MODEL_PROTOCOL_SELECTION__ 1 +#endif + +#if !defined(__EDKII_GLUE_DRIVER_MODEL_VERSION_1_DEFINED__) && defined(__EDKII_GLUE_DRIVER_MODEL_VERSION_2_DEFINED__) && !defined(__EDKII_GLUE_DRIVER_MODEL_AUTO_SELECT_PROTOCOLS_BY_EFI_VERSION__) +#define __EDKII_GLUE_DRIVER_MODEL_PROTOCOL_SELECTION__ 2 +#endif + +#if defined(__EDKII_GLUE_DRIVER_MODEL_VERSION_1_DEFINED__) && defined(__EDKII_GLUE_DRIVER_MODEL_VERSION_2_DEFINED__) && !defined(__EDKII_GLUE_DRIVER_MODEL_AUTO_SELECT_PROTOCOLS_BY_EFI_VERSION__) +#define __EDKII_GLUE_DRIVER_MODEL_PROTOCOL_SELECTION__ 3 +#endif + +// +// To use Auto-Select, it must be: +// 1. both Protocol and Protocol2 are defined +// 2. The Protocol and Protocol2 must use same names, for example, gDriverControllerName as __EDKII_GLUE_COMPONENT_NAME_PROTOCOL_INSTANCE__ and __EDKII_GLUE_COMPONENT_NAME2_PROTOCOL_INSTANCE__ +// +#if defined(__EDKII_GLUE_DRIVER_MODEL_AUTO_SELECT_PROTOCOLS_BY_EFI_VERSION__) +#if !(defined(__EDKII_GLUE_DRIVER_MODEL_VERSION_1_DEFINED__) && defined(__EDKII_GLUE_DRIVER_MODEL_VERSION_2_DEFINED__)) +#error "To use Auto-Select please define both Protocol and Protocol2 instances" +#endif +#define __EDKII_GLUE_DRIVER_MODEL_PROTOCOL_SELECTION__ 4 +#endif + +#if (__EDKII_GLUE_DRIVER_MODEL_PROTOCOL_SELECTION__ == 4) +#undef __EDKII_GLUE_DRIVER_MODEL_PROTOCOL_SELECTION__ +#if (EFI_SPECIFICATION_VERSION >= 0x00020000) +#define __EDKII_GLUE_DRIVER_MODEL_PROTOCOL_SELECTION__ 2 +#else +#define __EDKII_GLUE_DRIVER_MODEL_PROTOCOL_SELECTION__ 1 +#endif +#endif + +#if (__EDKII_GLUE_DRIVER_MODEL_PROTOCOL_SELECTION__ == 1) +UINT8 _gEdkIIGlueDriverModelProtocolSelection = 1; +#elif (__EDKII_GLUE_DRIVER_MODEL_PROTOCOL_SELECTION__ == 2) +UINT8 _gEdkIIGlueDriverModelProtocolSelection = 2; +#elif (__EDKII_GLUE_DRIVER_MODEL_PROTOCOL_SELECTION__ == 3) +UINT8 _gEdkIIGlueDriverModelProtocolSelection = 3; +#else +UINT8 _gEdkIIGlueDriverModelProtocolSelection = 0; +#endif + +// +// Driver Model related definitions. +// LIMITATION: only support one instance of Driver Model protocols per driver. +// In case where multiple Driver Model protocols need to be installed in a single driver, +// manually edit this file and compile/link the modified file with the driver. +// +#if defined(__EDKII_GLUE_DRIVER_BINDING_PROTOCOL_INSTANCE__) +extern EFI_DRIVER_BINDING_PROTOCOL __EDKII_GLUE_DRIVER_BINDING_PROTOCOL_INSTANCE__; +#endif + +#if (__EDKII_GLUE_DRIVER_MODEL_PROTOCOL_SELECTION__ == 1) || (__EDKII_GLUE_DRIVER_MODEL_PROTOCOL_SELECTION__ == 3) +#if defined(__EDKII_GLUE_COMPONENT_NAME_PROTOCOL_INSTANCE__) +extern EFI_COMPONENT_NAME_PROTOCOL __EDKII_GLUE_COMPONENT_NAME_PROTOCOL_INSTANCE__; +#endif + +#if defined(__EDKII_GLUE_DRIVER_CONFIGURATION_PROTOCOL_INSTANCE__) +extern EFI_DRIVER_CONFIGURATION_PROTOCOL __EDKII_GLUE_DRIVER_CONFIGURATION_PROTOCOL_INSTANCE__; +#endif +#endif + +#if defined(__EDKII_GLUE_DRIVER_DIAGNOSTICS_PROTOCOL_INSTANCE__) +extern EFI_DRIVER_DIAGNOSTICS_PROTOCOL __EDKII_GLUE_DRIVER_DIAGNOSTICS_PROTOCOL_INSTANCE__; +#endif + +#if (__EDKII_GLUE_DRIVER_MODEL_PROTOCOL_SELECTION__ == 2) || (__EDKII_GLUE_DRIVER_MODEL_PROTOCOL_SELECTION__ == 3) +#if defined(__EDKII_GLUE_COMPONENT_NAME2_PROTOCOL_INSTANCE__) +extern EFI_COMPONENT_NAME2_PROTOCOL __EDKII_GLUE_COMPONENT_NAME2_PROTOCOL_INSTANCE__; +#endif + +#if defined(__EDKII_GLUE_DRIVER_CONFIGURATION2_PROTOCOL_INSTANCE__) +extern EFI_DRIVER_CONFIGURATION2_PROTOCOL __EDKII_GLUE_DRIVER_CONFIGURATION2_PROTOCOL_INSTANCE__; +#endif + +#if defined(__EDKII_GLUE_DRIVER_DIAGNOSTICS2_PROTOCOL_INSTANCE__) +extern EFI_DRIVER_DIAGNOSTICS2_PROTOCOL __EDKII_GLUE_DRIVER_DIAGNOSTICS2_PROTOCOL_INSTANCE__; +#endif +#endif + +GLOBAL_REMOVE_IF_UNREFERENCED const EFI_DRIVER_MODEL_PROTOCOL_LIST _gDriverModelProtocolList[] = { + { +#ifdef __EDKII_GLUE_DRIVER_BINDING_PROTOCOL_INSTANCE__ + &__EDKII_GLUE_DRIVER_BINDING_PROTOCOL_INSTANCE__, +#else + NULL, +#endif + +#if defined(__EDKII_GLUE_COMPONENT_NAME_PROTOCOL_INSTANCE__) && !(__EDKII_GLUE_DRIVER_MODEL_PROTOCOL_SELECTION__ == 2) + &__EDKII_GLUE_COMPONENT_NAME_PROTOCOL_INSTANCE__, +#else + NULL, +#endif + +#if defined(__EDKII_GLUE_DRIVER_CONFIGURATION_PROTOCOL_INSTANCE__) && !(__EDKII_GLUE_DRIVER_MODEL_PROTOCOL_SELECTION__ == 2) + &__EDKII_GLUE_DRIVER_CONFIGURATION_PROTOCOL_INSTANCE__, +#else + NULL, +#endif + +#if defined(__EDKII_GLUE_DRIVER_DIAGNOSTICS_PROTOCOL_INSTANCE__) && !(__EDKII_GLUE_DRIVER_MODEL_PROTOCOL_SELECTION__ == 2) + &__EDKII_GLUE_DRIVER_DIAGNOSTICS_PROTOCOL_INSTANCE__, +#else + NULL, +#endif + +#if defined(__EDKII_GLUE_COMPONENT_NAME2_PROTOCOL_INSTANCE__) && !(__EDKII_GLUE_DRIVER_MODEL_PROTOCOL_SELECTION__ == 1) + &__EDKII_GLUE_COMPONENT_NAME2_PROTOCOL_INSTANCE__, +#else + NULL, +#endif + +#if defined(__EDKII_GLUE_DRIVER_CONFIGURATION2_PROTOCOL_INSTANCE__) && !(__EDKII_GLUE_DRIVER_MODEL_PROTOCOL_SELECTION__ == 1) + &__EDKII_GLUE_DRIVER_CONFIGURATION2_PROTOCOL_INSTANCE__, +#else + NULL, +#endif + +#if defined(__EDKII_GLUE_DRIVER_DIAGNOSTICS2_PROTOCOL_INSTANCE__) && !(__EDKII_GLUE_DRIVER_MODEL_PROTOCOL_SELECTION__ == 1) + &__EDKII_GLUE_DRIVER_DIAGNOSTICS2_PROTOCOL_INSTANCE__, +#else + NULL, +#endif + } +}; + +// +// Global Interface for Debug Mask Protocol +// +EFI_DEBUG_MASK_PROTOCOL *gDebugMaskInterface = NULL; + +// +// NOTE: Limitation: +// Only one handler for SetVirtualAddressMap Event and ExitBootServices Event each +// + +#ifdef __EDKII_GLUE_SET_VIRTUAL_ADDRESS_MAP_EVENT_HANDLER__ +VOID +__EDKII_GLUE_SET_VIRTUAL_ADDRESS_MAP_EVENT_HANDLER__ ( + EFI_HANDLE ImageHandle, + EFI_SYSTEM_TABLE *SystemTable + ); +#endif + +/** + Enrty point to DXE Driver. + + @param ImageHandle ImageHandle of the loaded driver. + @param SystemTable Pointer to the EFI System Table. + + @retval EFI_SUCCESS One or more of the drivers returned a success code. + @retval !EFI_SUCESS The return status from the last driver entry point in the list. + +**/ + +GLOBAL_REMOVE_IF_UNREFERENCED const EFI_EVENT_NOTIFY _gDriverSetVirtualAddressMapEvent[] = { +#ifdef __EDKII_GLUE_SET_VIRTUAL_ADDRESS_MAP_EVENT_HANDLER__ + __EDKII_GLUE_SET_VIRTUAL_ADDRESS_MAP_EVENT_HANDLER__, +#endif + NULL +}; + +GLOBAL_REMOVE_IF_UNREFERENCED const EFI_EVENT_NOTIFY _gDriverExitBootServicesEvent[] = { +#ifdef __EDKII_GLUE_EXTI_BOOT_SERVICES_EVENT__HANDLER__ + __EDKII_GLUE_EXTI_BOOT_SERVICES_EVENT__HANDLER__, +#endif + NULL +}; + + +// +// Module Unload Handler +// + +#ifdef __EDKII_GLUE_MODULE_UNLOAD_HANDLER__ +EFI_STATUS +EFIAPI +__EDKII_GLUE_MODULE_UNLOAD_HANDLER__ ( + EFI_HANDLE ImageHandle + ); +#endif + +EFI_STATUS +EFIAPI +ProcessModuleUnloadList ( + EFI_HANDLE ImageHandle + ) +{ +#ifdef __EDKII_GLUE_MODULE_UNLOAD_HANDLER__ + return (__EDKII_GLUE_MODULE_UNLOAD_HANDLER__ (ImageHandle)); +#else + return EFI_SUCCESS; +#endif +} + +#ifdef __EDKII_GLUE_EFI_CALLER_ID_GUID__ + GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiCallerIdGuid = __EDKII_GLUE_EFI_CALLER_ID_GUID__; +#endif + +// +// Library constructors +// +VOID +ProcessLibraryConstructorList ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ +// +// Declare "Status" if any of the following libraries are used +// +#if defined(__EDKII_GLUE_DXE_HOB_LIB__) \ + || defined(__EDKII_GLUE_UEFI_BOOT_SERVICES_TABLE_LIB__) \ + || defined(__EDKII_GLUE_UEFI_DRIVER_MODEL_LIB__) \ + || defined(__EDKII_GLUE_EDK_DXE_RUNTIME_DRIVER_LIB__) \ + || defined(__EDKII_GLUE_DXE_SERVICES_TABLE_LIB__) \ + || defined(__EDKII_GLUE_DXE_SMBUS_LIB__) \ + || defined(__EDKII_GLUE_UEFI_RUNTIME_SERVICES_TABLE_LIB__) \ + || defined(__EDKII_GLUE_SMM_RUNTIME_DXE_REPORT_STATUS_CODE_LIB__) + EFI_STATUS Status; +#endif + +// +// EdkII Glue Library Constructors: +// NOTE: the constructors must be called according to dependency order +// +// UefiBootServicesTableLib UefiBootServicesTableLibConstructor() +// UefiRuntimeServicesTableLib UefiRuntimeServicesTableLibConstructor() +// DxeServicesTableLib DxeServicesTableLibConstructor() +// EdkDxeRuntimeDriverLib RuntimeDriverLibConstruct() +// SmmRuntimeDxeReportStatusCodeLib ReportStatusCodeLibConstruct() +// DxeHobLib HobLibConstructor() +// UefiDriverModelLib UefiDriverModelLibConstructor() +// DxeSmbusLib SmbusLibConstructor() +// +#ifdef __EDKII_GLUE_UEFI_BOOT_SERVICES_TABLE_LIB__ + Status = UefiBootServicesTableLibConstructor (ImageHandle, SystemTable); + ASSERT_EFI_ERROR (Status); +#endif + +#ifdef __EDKII_GLUE_UEFI_RUNTIME_SERVICES_TABLE_LIB__ + Status = UefiRuntimeServicesTableLibConstructor (ImageHandle, SystemTable); + ASSERT_EFI_ERROR (Status); +#endif + +#ifdef __EDKII_GLUE_DXE_SERVICES_TABLE_LIB__ + Status = DxeServicesTableLibConstructor (ImageHandle, SystemTable); + ASSERT_EFI_ERROR (Status); +#endif + +#ifdef __EDKII_GLUE_EDK_DXE_RUNTIME_DRIVER_LIB__ + Status = RuntimeDriverLibConstruct (ImageHandle, SystemTable); + ASSERT_EFI_ERROR (Status); +#endif + +#ifdef __EDKII_GLUE_SMM_RUNTIME_DXE_REPORT_STATUS_CODE_LIB__ + Status = ReportStatusCodeLibConstruct (ImageHandle, SystemTable); + ASSERT_EFI_ERROR (Status); +#endif + +#ifdef __EDKII_GLUE_UEFI_DRIVER_MODEL_LIB__ + Status = UefiDriverModelLibConstructor (ImageHandle, SystemTable); + ASSERT_EFI_ERROR (Status); +#endif + +#ifdef __EDKII_GLUE_DXE_HOB_LIB__ + Status = HobLibConstructor (ImageHandle, SystemTable); + ASSERT_EFI_ERROR (Status); +#endif + +#ifdef __EDKII_GLUE_DXE_SMBUS_LIB__ + Status = SmbusLibConstructor (ImageHandle, SystemTable); + ASSERT_EFI_ERROR (Status); +#endif + +} + +// +// Library Destructors +// +VOID +ProcessLibraryDestructorList ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ +// +// NOTE: the destructors must be called according to dependency order +// +#if defined(__EDKII_GLUE_UEFI_DRIVER_MODEL_LIB__) \ + || defined(__EDKII_GLUE_SMM_RUNTIME_DXE_REPORT_STATUS_CODE_LIB__) \ + || defined(__EDKII_GLUE_EDK_DXE_RUNTIME_DRIVER_LIB__) + EFI_STATUS Status; +#endif + +#ifdef __EDKII_GLUE_UEFI_DRIVER_MODEL_LIB__ + Status = UefiDriverModelLibDestructor (ImageHandle, SystemTable); + ASSERT_EFI_ERROR (Status); +#endif + +#ifdef __EDKII_GLUE_SMM_RUNTIME_DXE_REPORT_STATUS_CODE_LIB__ + Status = ReportStatusCodeLibDestruct (ImageHandle, SystemTable); + ASSERT_EFI_ERROR (Status); +#endif + +#ifdef __EDKII_GLUE_EDK_DXE_RUNTIME_DRIVER_LIB__ + Status = RuntimeDriverLibDeconstruct (); + ASSERT_EFI_ERROR (Status); +#endif +} + + +/** + Unload function that is registered in the LoadImage protocol. It un-installs + protocols produced and deallocates pool used by the driver. Called by the core + when unloading the driver. + + @param ImageHandle + + @retval EFI_SUCCESS + +**/ +EFI_STATUS +EFIAPI +_DriverUnloadHandler ( + EFI_HANDLE ImageHandle + ) +{ + EFI_STATUS Status; + + // + // If an UnloadImage() handler is specified, then call it + // + Status = ProcessModuleUnloadList (ImageHandle); + + // + // If the driver specific unload handler does not return an error, then call all of the + // library destructors. If the unload handler returned an error, then the driver can not be + // unloaded, and the library destructors should not be called + // + if (!EFI_ERROR (Status)) { + // + // NOTE: To allow passing in gST here, any library instance having a destructor + // must depend on EfiDriverLib + // +#if defined(__EDKII_GLUE_UEFI_DRIVER_MODEL_LIB__) \ + || defined(__EDKII_GLUE_EDK_DXE_RUNTIME_DRIVER_LIB__) + ProcessLibraryDestructorList (ImageHandle, gST); +#endif + } + + // + // Return the status from the driver specific unload handler + // + return Status; +} + +EFI_DRIVER_ENTRY_POINT (_ModuleEntryPoint); + +// +// Module Entry Point +// +#ifdef __EDKII_GLUE_MODULE_ENTRY_POINT__ +EFI_STATUS +EFIAPI +__EDKII_GLUE_MODULE_ENTRY_POINT__ ( + EFI_HANDLE ImageHandle, + EFI_SYSTEM_TABLE *SystemTable + ); +#endif + +/** + Enrty point to DXE Driver. + + @param ImageHandle ImageHandle of the loaded driver. + @param SystemTable Pointer to the EFI System Table. + + @retval EFI_SUCCESS One or more of the drivers returned a success code. + @retval !EFI_SUCESS The return status from the last driver entry point in the list. + +**/ +EFI_STATUS +EFIAPI +_ModuleEntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + EFI_LOADED_IMAGE_PROTOCOL *LoadedImage; + +// if (_gUefiDriverRevision != 0) { +// // +// // Make sure that the EFI/UEFI spec revision of the platform is >= EFI/UEFI spec revision of the driver +// // +// if (SystemTable->Hdr.Revision < _gUefiDriverRevision) { +// return EFI_INCOMPATIBLE_VERSION; +// } +// } + +// DEBUG ((EFI_D_ERROR, "EdkII Glue Driver Entry - 0\n")); + + // + // Call constructor for all libraries + // + ProcessLibraryConstructorList (ImageHandle, SystemTable); + Status = SystemTable->BootServices->HandleProtocol ( + ImageHandle, + &gEfiRuntimeDebugMaskProtocolGuid, + (VOID **)&gDebugMaskInterface + ); + if (EFI_ERROR(Status)) { + Status = SystemTable->BootServices->HandleProtocol ( + ImageHandle, + &gEfiDebugMaskProtocolGuid, + (VOID **)&gDebugMaskInterface + ); + if (EFI_ERROR(Status)) { + gDebugMaskInterface = NULL; + } + } + // + // Install unload handler... + // + Status = SystemTable->BootServices->HandleProtocol ( + ImageHandle, + &gEfiLoadedImageProtocolGuid, + (VOID **)&LoadedImage + ); + ASSERT_EFI_ERROR (Status); + LoadedImage->Unload = _DriverUnloadHandler; + + // + // Call the driver entry point + // + #ifdef __EDKII_GLUE_MODULE_ENTRY_POINT__ + Status = (__EDKII_GLUE_MODULE_ENTRY_POINT__ (ImageHandle, SystemTable)); + #else + Status = EFI_SUCCESS; + #endif + + // + // If all of the drivers returned errors, then invoke all of the library destructors + // + if (EFI_ERROR (Status)) { + ProcessLibraryDestructorList (ImageHandle, SystemTable); + } + + // + // Return the cummalative return status code from all of the driver entry points + // + return Status; +} + + +/** + Enrty point wrapper of DXE Driver. + + @param ImageHandle ImageHandle of the loaded driver. + @param SystemTable Pointer to the EFI System Table. + + @retval EFI_SUCCESS One or more of the drivers returned a success code. + @retval !EFI_SUCESS The return status from the last driver entry point in the list. + +**/ +EFI_STATUS +EFIAPI +EfiMain ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + return _ModuleEntryPoint (ImageHandle, SystemTable); +} + +// +// Guids not present in R8.6 code base +// + +// +// Protocol/Arch Protocol GUID globals +// +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gUefiDriverConfigurationProtocolGuid = { 0xbfd7dc1d, 0x24f1, 0x40d9, { 0x82, 0xe7, 0x2e, 0x09, 0xbb, 0x6b, 0x4e, 0xbe } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gUefiDriverDiagnosticsProtocolGuid = { 0x4d330321, 0x025f, 0x4aac, { 0x90, 0xd8, 0x5e, 0xd9, 0x00, 0x17, 0x3b, 0x63 } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiArpProtocolGuid = { 0xf4b427bb, 0xba21, 0x4f16, { 0xbc, 0x4e, 0x43, 0xe4, 0x16, 0xab, 0x61, 0x9c } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiArpServiceBindingProtocolGuid = { 0xf44c00ee, 0x1f2c, 0x4a00, { 0xaa, 0x09, 0x1c, 0x9f, 0x3e, 0x08, 0x00, 0xa3 } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiDhcp4ProtocolGuid = { 0x8a219718, 0x4ef5, 0x4761, { 0x91, 0xc8, 0xc0, 0xf0, 0x4b, 0xda, 0x9e, 0x56 } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiDhcp4ServiceBindingProtocolGuid = { 0x9d9a39d8, 0xbd42, 0x4a73, { 0xa4, 0xd5, 0x8e, 0xe9, 0x4b, 0xe1, 0x13, 0x80 } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiIp4ProtocolGuid = { 0x41d94cd2, 0x35b6, 0x455a, { 0x82, 0x58, 0xd4, 0xe5, 0x13, 0x34, 0xaa, 0xdd } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiIp4ServiceBindingProtocolGuid = { 0xc51711e7, 0xb4bf, 0x404a, { 0xbf, 0xb8, 0x0a, 0x04, 0x8e, 0xf1, 0xff, 0xe4 } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiIp4ConfigProtocolGuid = { 0x3b95aa31, 0x3793, 0x434b, { 0x86, 0x67, 0xc8, 0x07, 0x08, 0x92, 0xe0, 0x5e } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiManagedNetworkProtocolGuid = { 0x3b95aa31, 0x3793, 0x434b, { 0x86, 0x67, 0xc8, 0x07, 0x08, 0x92, 0xe0, 0x5e } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiManagedNetworkServiceBindingProtocolGuid = { 0xf36ff770, 0xa7e1, 0x42cf, { 0x9e, 0xd2, 0x56, 0xf0, 0xf2, 0x71, 0xf4, 0x4c } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiMtftp4ProtocolGuid = { 0x3ad9df29, 0x4501, 0x478d, { 0xb1, 0xf8, 0x7f, 0x7f, 0xe7, 0x0e, 0x50, 0xf3 } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiMtftp4ServiceBindingProtocolGuid = { 0x2FE800BE, 0x8F01, 0x4aa6, { 0x94, 0x6B, 0xD7, 0x13, 0x88, 0xE1, 0x83, 0x3F } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiTcp4ProtocolGuid = { 0x65530BC7, 0xA359, 0x410f, { 0xB0, 0x10, 0x5A, 0xAD, 0xC7, 0xEC, 0x2B, 0x62 } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiTcp4ServiceBindingProtocolGuid = { 0x00720665, 0x67EB, 0x4a99, { 0xBA, 0xF7, 0xD3, 0xC3, 0x3A, 0x1C, 0x7C, 0xC9 } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiUdp4ProtocolGuid = { 0x3ad9df29, 0x4501, 0x478d, { 0xb1, 0xf8, 0x7f, 0x7f, 0xe7, 0x0e, 0x50, 0xf3 } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiUdp4ServiceBindingProtocolGuid = { 0x83f01464, 0x99bd, 0x45e5, { 0xb3, 0x83, 0xaf, 0x63, 0x05, 0xd8, 0xe9, 0xe6 } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiAuthenticationInfoProtocolGuid = { 0x7671d9d0, 0x53db, 0x4173, { 0xaa, 0x69, 0x23, 0x27, 0xf2, 0x1f, 0x0b, 0xc7 } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiDevicePathFromTextProtocolGuid = { 0x5c99a21, 0xc70f, 0x4ad2, { 0x8a, 0x5f, 0x35, 0xdf, 0x33, 0x43, 0xf5, 0x1e } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiDevicePathToTextProtocolGuid = { 0x8b843e20, 0x8132, 0x4852, { 0x90, 0xcc, 0x55, 0x1a, 0x4e, 0x4a, 0x7f, 0x1c } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiDevicePathUtilitiesProtocolGuid = { 0x379be4e, 0xd706, 0x437d, { 0xb0, 0x37, 0xed, 0xb8, 0x2f, 0xb7, 0x72, 0xa4 } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiHashProtocolGuid = { 0xc5184932, 0xdba5, 0x46db, { 0xa5, 0xba, 0xcc, 0x0b, 0xda, 0x9c, 0x14, 0x35 } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiHashServiceBindingProtocolGuid = { 0x42881c98, 0xa4f3, 0x44b0, { 0xa3, 0x9d, 0xdf, 0xa1, 0x86, 0x67, 0xd8, 0xcd } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiIScsiInitiatorNameProtocolGuid = { 0xa6a72875, 0x2962, 0x4c18, { 0x9f, 0x46, 0x8d, 0xa6, 0x44, 0xcc, 0xfe, 0x00 } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiExtScsiPassThruProtocolGuid = { 0x1d3de7f0, 0x0807, 0x424f, { 0xaa, 0x69, 0x11, 0xa5, 0x4e, 0x19, 0xa4, 0x6f } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiTapeIoProtocolGuid = { 0x1e93e633, 0xd65a, 0x459e, { 0xab, 0x84, 0x93, 0xd9, 0xec, 0x26, 0x6d, 0x18 } }; +#if (EFI_SPECIFICATION_VERSION < 0x00020000) +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiUsb2HcProtocolGuid = { 0x3e745226, 0x9818, 0x45b6, { 0xa2, 0xac, 0xd7, 0xcd, 0x0e, 0x8b, 0xa2, 0xbc } }; +#endif + +// +// PPI GUID globals +// + +// +// GUID globals +// +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiHobMemoryAllocBspStoreGuid = { 0x564b33cd, 0xc92a, 0x4593, { 0x90, 0xbf, 0x24, 0x73, 0xe4, 0x3c, 0x63, 0x22 } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiHobMemoryAllocStackGuid = { 0x4ed4bf27, 0x4092, 0x42e9, { 0x80, 0x7d, 0x52, 0x7b, 0x1d, 0x00, 0xc9, 0xbd } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiHobMemoryAllocModuleGuid = { 0xf8e21975, 0x0899, 0x4f58, { 0xa4, 0xbe, 0x55, 0x25, 0xa9, 0xc6, 0xd7, 0x7a } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiAuthenticationChapRadiusGuid = { 0xd6062b50, 0x15ca, 0x11da, { 0x92, 0x19, 0x00, 0x10, 0x83, 0xff, 0xca, 0x4d } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiAuthenticationChapLocalGuid = { 0xc280c73e, 0x15ca, 0x11da, { 0xb0, 0xca, 0x00, 0x10, 0x83, 0xff, 0xca, 0x4d } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiHashAlgorithmSha1Guid = { 0x2ae9d80f, 0x3fb2, 0x4095, { 0xb7, 0xb1, 0xe9, 0x31, 0x57, 0xb9, 0x46, 0xb6 } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiHashAlgorithmSha224Guid = { 0x8df01a06, 0x9bd5, 0x4bf7, { 0xb0, 0x21, 0xdb, 0x4f, 0xd9, 0xcc, 0xf4, 0x5b } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiHashAlgorithmSha256Guid = { 0x51aa59de, 0xfdf2, 0x4ea3, { 0xbc, 0x63, 0x87, 0x5f, 0xb7, 0x84, 0x2e, 0xe9 } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiHashAlgorithmSha384Guid = { 0xefa96432, 0xde33, 0x4dd2, { 0xae, 0xe6, 0x32, 0x8c, 0x33, 0xdf, 0x77, 0x7a } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiHashAlgorithmSha512Guid = { 0xcaa4381e, 0x750c, 0x4770, { 0xb8, 0x70, 0x7a, 0x23, 0xb4, 0xe4, 0x21, 0x30 } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiHashAlgorithmMD5Guid = { 0xaf7c79c, 0x65b5, 0x4319, { 0xb0, 0xae, 0x44, 0xec, 0x48, 0x4e, 0x4a, 0xd7 } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gBootObjectAuthorizationParmsetGuid = { 0xedd35e31, 0x7b9, 0x11d2, { 0x83, 0xa3, 0x00, 0xa0, 0xc9, 0x1f, 0xad, 0xcf } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gSmmCommunicateHeaderGuid = { 0xf328e36c, 0x23b6, 0x4a95, { 0x85, 0x4b, 0x32, 0xe1, 0x95, 0x34, 0xcd, 0x75 } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiCapsuleGuid = { 0x3B6686BD, 0x0D76, 0x4030, { 0xB7, 0x0E, 0xB5, 0x51, 0x9E, 0x2F, 0xC5, 0xA0 } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiConfigFileNameGuid = { 0x98B8D59B, 0xE8BA, 0x48EE, { 0x98, 0xDD, 0xC2, 0x95, 0x39, 0x2F, 0x1E, 0xDB } }; diff --git a/EDK/Foundation/Library/EdkIIGlueLib/EntryPoints/EdkIIGluePeimEntryPoint.c b/EDK/Foundation/Library/EdkIIGlueLib/EntryPoints/EdkIIGluePeimEntryPoint.c new file mode 100644 index 0000000..fb4c542 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/EntryPoints/EdkIIGluePeimEntryPoint.c @@ -0,0 +1,180 @@ +/*++ + +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: + + EdkIIGluePeimEntryPoint.c + +Abstract: + + PEIM entry point template file + +--*/ + +#include "EdkIIGluePeim.h" +#include "Common/EdkIIGlueDependencies.h" + + +#ifdef __EDKII_GLUE_EFI_CALLER_ID_GUID__ + GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiCallerIdGuid = __EDKII_GLUE_EFI_CALLER_ID_GUID__; +#endif + +// +// Library constructors +// +VOID +ProcessLibraryConstructorList ( + IN EFI_FFS_FILE_HEADER *FfsHeader, + IN EFI_PEI_SERVICES **PeiServices + ) +{ +// +// Declare "Status" if any of the following libraries are used +// +#if defined(__EDKII_GLUE_PEI_SERVICES_TABLE_POINTER_LIB_MM7__) \ + || defined(__EDKII_GLUE_PEI_SERVICES_TABLE_POINTER_LIB__) + EFI_STATUS Status; +#endif + +// +// EdkII Glue Library Constructors: +// PeiServicesTablePointerLib PeiServicesTablePointerLibConstructor() +// PeiServicesTablePointerLibMm7 PeiServicesTablePointerLibConstructor() +// + +#if defined(__EDKII_GLUE_PEI_SERVICES_TABLE_POINTER_LIB_MM7__) \ + || defined(__EDKII_GLUE_PEI_SERVICES_TABLE_POINTER_LIB__) + Status = PeiServicesTablePointerLibConstructor (FfsHeader, PeiServices); + ASSERT_EFI_ERROR (Status); +#endif +} + +EFI_PEIM_ENTRY_POINT (_ModuleEntryPoint); + +EFI_STATUS +EFIAPI +__EDKII_GLUE_MODULE_ENTRY_POINT__ ( + IN EFI_FFS_FILE_HEADER *FfsHeader, + IN EFI_PEI_SERVICES **PeiServices + ); + +/** + Image entry point of Peim. + + @param FfsHeader Pointer to FFS header the loaded driver. + @param PeiServices Pointer to the PEI services. + + @return Status returned by entry points of Peims. + +--*/ +EFI_STATUS +EFIAPI +_ModuleEntryPoint ( + IN EFI_FFS_FILE_HEADER *FfsHeader, + IN EFI_PEI_SERVICES **PeiServices + ) +{ +// if (_gPeimRevision != 0) { +// // +// // Make sure that the PEI spec revision of the platform is >= PEI spec revision of the driver +// // +// ASSERT ((*PeiServices)->Hdr.Revision >= _gPeimRevision); +// } + + // + // Call constructor for all libraries + // + ProcessLibraryConstructorList (FfsHeader, PeiServices); + + // + // Call the driver entry point + // + return __EDKII_GLUE_MODULE_ENTRY_POINT__ (FfsHeader, PeiServices); +} + + +/** + Wrapper of Peim image entry point. + + @param FfsHeader Pointer to FFS header the loaded driver. + @param PeiServices Pointer to the PEI services. + + @return Status returned by entry points of Peims. + +**/ +EFI_STATUS +EFIAPI +EfiMain ( + IN EFI_FFS_FILE_HEADER *FfsHeader, + IN EFI_PEI_SERVICES **PeiServices + ) +{ + return _ModuleEntryPoint (FfsHeader, PeiServices); +} + +// +// Guids not present in R8.6 code base +// + +// +// Protocol/Arch Protocol GUID globals +// +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gUefiDriverConfigurationProtocolGuid = { 0xbfd7dc1d, 0x24f1, 0x40d9, { 0x82, 0xe7, 0x2e, 0x09, 0xbb, 0x6b, 0x4e, 0xbe } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gUefiDriverDiagnosticsProtocolGuid = { 0x4d330321, 0x025f, 0x4aac, { 0x90, 0xd8, 0x5e, 0xd9, 0x00, 0x17, 0x3b, 0x63 } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiArpProtocolGuid = { 0xf4b427bb, 0xba21, 0x4f16, { 0xbc, 0x4e, 0x43, 0xe4, 0x16, 0xab, 0x61, 0x9c } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiArpServiceBindingProtocolGuid = { 0xf44c00ee, 0x1f2c, 0x4a00, { 0xaa, 0x09, 0x1c, 0x9f, 0x3e, 0x08, 0x00, 0xa3 } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiDhcp4ProtocolGuid = { 0x8a219718, 0x4ef5, 0x4761, { 0x91, 0xc8, 0xc0, 0xf0, 0x4b, 0xda, 0x9e, 0x56 } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiDhcp4ServiceBindingProtocolGuid = { 0x9d9a39d8, 0xbd42, 0x4a73, { 0xa4, 0xd5, 0x8e, 0xe9, 0x4b, 0xe1, 0x13, 0x80 } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiIp4ProtocolGuid = { 0x41d94cd2, 0x35b6, 0x455a, { 0x82, 0x58, 0xd4, 0xe5, 0x13, 0x34, 0xaa, 0xdd } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiIp4ServiceBindingProtocolGuid = { 0xc51711e7, 0xb4bf, 0x404a, { 0xbf, 0xb8, 0x0a, 0x04, 0x8e, 0xf1, 0xff, 0xe4 } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiIp4ConfigProtocolGuid = { 0x3b95aa31, 0x3793, 0x434b, { 0x86, 0x67, 0xc8, 0x07, 0x08, 0x92, 0xe0, 0x5e } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiManagedNetworkProtocolGuid = { 0x3b95aa31, 0x3793, 0x434b, { 0x86, 0x67, 0xc8, 0x07, 0x08, 0x92, 0xe0, 0x5e } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiManagedNetworkServiceBindingProtocolGuid = { 0xf36ff770, 0xa7e1, 0x42cf, { 0x9e, 0xd2, 0x56, 0xf0, 0xf2, 0x71, 0xf4, 0x4c } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiMtftp4ProtocolGuid = { 0x3ad9df29, 0x4501, 0x478d, { 0xb1, 0xf8, 0x7f, 0x7f, 0xe7, 0x0e, 0x50, 0xf3 } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiMtftp4ServiceBindingProtocolGuid = { 0x2FE800BE, 0x8F01, 0x4aa6, { 0x94, 0x6B, 0xD7, 0x13, 0x88, 0xE1, 0x83, 0x3F } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiTcp4ProtocolGuid = { 0x65530BC7, 0xA359, 0x410f, { 0xB0, 0x10, 0x5A, 0xAD, 0xC7, 0xEC, 0x2B, 0x62 } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiTcp4ServiceBindingProtocolGuid = { 0x00720665, 0x67EB, 0x4a99, { 0xBA, 0xF7, 0xD3, 0xC3, 0x3A, 0x1C, 0x7C, 0xC9 } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiUdp4ProtocolGuid = { 0x3ad9df29, 0x4501, 0x478d, { 0xb1, 0xf8, 0x7f, 0x7f, 0xe7, 0x0e, 0x50, 0xf3 } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiUdp4ServiceBindingProtocolGuid = { 0x83f01464, 0x99bd, 0x45e5, { 0xb3, 0x83, 0xaf, 0x63, 0x05, 0xd8, 0xe9, 0xe6 } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiAuthenticationInfoProtocolGuid = { 0x7671d9d0, 0x53db, 0x4173, { 0xaa, 0x69, 0x23, 0x27, 0xf2, 0x1f, 0x0b, 0xc7 } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiDevicePathFromTextProtocolGuid = { 0x5c99a21, 0xc70f, 0x4ad2, { 0x8a, 0x5f, 0x35, 0xdf, 0x33, 0x43, 0xf5, 0x1e } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiDevicePathToTextProtocolGuid = { 0x8b843e20, 0x8132, 0x4852, { 0x90, 0xcc, 0x55, 0x1a, 0x4e, 0x4a, 0x7f, 0x1c } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiDevicePathUtilitiesProtocolGuid = { 0x379be4e, 0xd706, 0x437d, { 0xb0, 0x37, 0xed, 0xb8, 0x2f, 0xb7, 0x72, 0xa4 } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiHashProtocolGuid = { 0xc5184932, 0xdba5, 0x46db, { 0xa5, 0xba, 0xcc, 0x0b, 0xda, 0x9c, 0x14, 0x35 } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiHashServiceBindingProtocolGuid = { 0x42881c98, 0xa4f3, 0x44b0, { 0xa3, 0x9d, 0xdf, 0xa1, 0x86, 0x67, 0xd8, 0xcd } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiIScsiInitiatorNameProtocolGuid = { 0xa6a72875, 0x2962, 0x4c18, { 0x9f, 0x46, 0x8d, 0xa6, 0x44, 0xcc, 0xfe, 0x00 } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiExtScsiPassThruProtocolGuid = { 0x1d3de7f0, 0x0807, 0x424f, { 0xaa, 0x69, 0x11, 0xa5, 0x4e, 0x19, 0xa4, 0x6f } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiTapeIoProtocolGuid = { 0x1e93e633, 0xd65a, 0x459e, { 0xab, 0x84, 0x93, 0xd9, 0xec, 0x26, 0x6d, 0x18 } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiUsb2HcProtocolGuid = { 0x3e745226, 0x9818, 0x45b6, { 0xa2, 0xac, 0xd7, 0xcd, 0x0e, 0x8b, 0xa2, 0xbc } }; + +// +// PPI GUID globals +// + +// +// GUID globals +// +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiHobMemoryAllocBspStoreGuid = { 0x564b33cd, 0xc92a, 0x4593, { 0x90, 0xbf, 0x24, 0x73, 0xe4, 0x3c, 0x63, 0x22 } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiHobMemoryAllocStackGuid = { 0x4ed4bf27, 0x4092, 0x42e9, { 0x80, 0x7d, 0x52, 0x7b, 0x1d, 0x00, 0xc9, 0xbd } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiHobMemoryAllocModuleGuid = { 0xf8e21975, 0x0899, 0x4f58, { 0xa4, 0xbe, 0x55, 0x25, 0xa9, 0xc6, 0xd7, 0x7a } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiAuthenticationChapRadiusGuid = { 0xd6062b50, 0x15ca, 0x11da, { 0x92, 0x19, 0x00, 0x10, 0x83, 0xff, 0xca, 0x4d } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiAuthenticationChapLocalGuid = { 0xc280c73e, 0x15ca, 0x11da, { 0xb0, 0xca, 0x00, 0x10, 0x83, 0xff, 0xca, 0x4d } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiHashAlgorithmSha1Guid = { 0x2ae9d80f, 0x3fb2, 0x4095, { 0xb7, 0xb1, 0xe9, 0x31, 0x57, 0xb9, 0x46, 0xb6 } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiHashAlgorithmSha224Guid = { 0x8df01a06, 0x9bd5, 0x4bf7, { 0xb0, 0x21, 0xdb, 0x4f, 0xd9, 0xcc, 0xf4, 0x5b } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiHashAlgorithmSha256Guid = { 0x51aa59de, 0xfdf2, 0x4ea3, { 0xbc, 0x63, 0x87, 0x5f, 0xb7, 0x84, 0x2e, 0xe9 } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiHashAlgorithmSha384Guid = { 0xefa96432, 0xde33, 0x4dd2, { 0xae, 0xe6, 0x32, 0x8c, 0x33, 0xdf, 0x77, 0x7a } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiHashAlgorithmSha512Guid = { 0xcaa4381e, 0x750c, 0x4770, { 0xb8, 0x70, 0x7a, 0x23, 0xb4, 0xe4, 0x21, 0x30 } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiHashAlgorithmMD5Guid = { 0xaf7c79c, 0x65b5, 0x4319, { 0xb0, 0xae, 0x44, 0xec, 0x48, 0x4e, 0x4a, 0xd7 } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gBootObjectAuthorizationParmsetGuid = { 0xedd35e31, 0x7b9, 0x11d2, { 0x83, 0xa3, 0x00, 0xa0, 0xc9, 0x1f, 0xad, 0xcf } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gSmmCommunicateHeaderGuid = { 0xf328e36c, 0x23b6, 0x4a95, { 0x85, 0x4b, 0x32, 0xe1, 0x95, 0x34, 0xcd, 0x75 } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiCapsuleGuid = { 0x3B6686BD, 0x0D76, 0x4030, { 0xB7, 0x0E, 0xB5, 0x51, 0x9E, 0x2F, 0xC5, 0xA0 } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiConfigFileNameGuid = { 0x98B8D59B, 0xE8BA, 0x48EE, { 0x98, 0xDD, 0xC2, 0x95, 0x39, 0x2F, 0x1E, 0xDB } }; diff --git a/EDK/Foundation/Library/EdkIIGlueLib/EntryPoints/EdkIIGlueSmmDriverEntryPoint.c b/EDK/Foundation/Library/EdkIIGlueLib/EntryPoints/EdkIIGlueSmmDriverEntryPoint.c new file mode 100644 index 0000000..a0a5cc9 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/EntryPoints/EdkIIGlueSmmDriverEntryPoint.c @@ -0,0 +1,493 @@ +/*++ + +Copyright (c) 2004 - 2011, 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: + + EdkIIGlueSmmDriverEntryPoint.c + +Abstract: + + Smm Driver entry point template file + +--*/ + +#include "EdkIIGlueDxe.h" +#include "Common/EdkIIGlueDependencies.h" + + +// +// Module Unload Handler +// +#ifdef __EDKII_GLUE_MODULE_UNLOAD_HANDLER__ +EFI_STATUS +EFIAPI +__EDKII_GLUE_MODULE_UNLOAD_HANDLER__ ( + EFI_HANDLE ImageHandle + ); +#endif + +EFI_STATUS +EFIAPI +ProcessModuleUnloadList ( + EFI_HANDLE ImageHandle + ) +{ +#ifdef __EDKII_GLUE_MODULE_UNLOAD_HANDLER__ + return (__EDKII_GLUE_MODULE_UNLOAD_HANDLER__ (ImageHandle)); +#else + return EFI_SUCCESS; +#endif +} + +#ifdef __EDKII_GLUE_EFI_CALLER_ID_GUID__ + GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiCallerIdGuid = __EDKII_GLUE_EFI_CALLER_ID_GUID__; +#endif + +// +// Global Interface for Debug Mask Protocol +// +EFI_DEBUG_MASK_PROTOCOL *gDebugMaskInterface = NULL; + +// +// Library constructors +// +VOID +ProcessLibraryConstructorList ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ +// +// Declare "Status" if any of the following libraries are used +// +#if defined(__EDKII_GLUE_DXE_HOB_LIB__) \ + || defined(__EDKII_GLUE_UEFI_BOOT_SERVICES_TABLE_LIB__) \ + || defined(__EDKII_GLUE_DXE_SERVICES_TABLE_LIB__) \ + || defined(__EDKII_GLUE_DXE_SMBUS_LIB__) \ + || defined(__EDKII_GLUE_UEFI_RUNTIME_SERVICES_TABLE_LIB__) \ + || defined(__EDKII_GLUE_SMM_RUNTIME_DXE_REPORT_STATUS_CODE_LIB__) + EFI_STATUS Status; +#endif + +// +// EdkII Glue Library Constructors: +// NOTE: the constructors must be called according to dependency order +// +// UefiBootServicesTableLib UefiBootServicesTableLibConstructor() +// EdkDxeRuntimeDriverLib RuntimeDriverLibConstruct() +// SmmRuntimeDxeReportStatusCodeLib ReportStatusCodeLibConstruct() +// DxeHobLib HobLibConstructor() +// UefiDriverModelLib UefiDriverModelLibConstructor() +// DxeSmbusLib SmbusLibConstructor() +// DxeServicesTableLib DxeServicesTableLibConstructor() +// UefiRuntimeServicesTableLib UefiRuntimeServicesTableLibConstructor() +// check here: check lib usage +#ifdef __EDKII_GLUE_UEFI_BOOT_SERVICES_TABLE_LIB__ + Status = UefiBootServicesTableLibConstructor (ImageHandle, SystemTable); + ASSERT_EFI_ERROR (Status); +#endif + +#ifdef __EDKII_GLUE_UEFI_RUNTIME_SERVICES_TABLE_LIB__ + Status = UefiRuntimeServicesTableLibConstructor (ImageHandle, SystemTable); + ASSERT_EFI_ERROR (Status); +#endif + +#ifdef __EDKII_GLUE_DXE_SERVICES_TABLE_LIB__ + Status = DxeServicesTableLibConstructor (ImageHandle, SystemTable); + ASSERT_EFI_ERROR (Status); +#endif + +#ifdef __EDKII_GLUE_SMM_RUNTIME_DXE_REPORT_STATUS_CODE_LIB__ + Status = ReportStatusCodeLibConstruct (ImageHandle, SystemTable); + ASSERT_EFI_ERROR (Status); +#endif + +#ifdef __EDKII_GLUE_DXE_HOB_LIB__ + Status = HobLibConstructor (ImageHandle, SystemTable); + ASSERT_EFI_ERROR (Status); +#endif + +#ifdef __EDKII_GLUE_DXE_SMBUS_LIB__ + Status = SmbusLibConstructor (ImageHandle, SystemTable); + ASSERT_EFI_ERROR (Status); +#endif +} + +// +// Library destructors +// +VOID +ProcessLibraryDestructorList ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ +#if defined (__EDKII_GLUE_SMM_RUNTIME_DXE_REPORT_STATUS_CODE_LIB__) + EFI_STATUS Status; +#endif + +// +// NOTE: the destructors must be called according to dependency order +// +#ifdef __EDKII_GLUE_SMM_RUNTIME_DXE_REPORT_STATUS_CODE_LIB__ + Status = ReportStatusCodeLibDestruct (ImageHandle, SystemTable); + ASSERT_EFI_ERROR (Status); +#endif +} + +EFI_BOOT_SERVICES *mBS; + +/** + This function returns the size, in bytes, + of the device path data structure specified by DevicePath. + If DevicePath is NULL, then 0 is returned. + + @param DevicePath A pointer to a device path data structure. + + @return The size of a device path in bytes. + +**/ +STATIC +UINTN +EFIAPI +SmmGetDevicePathSize ( + IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath + ) +{ + CONST EFI_DEVICE_PATH_PROTOCOL *Start; + + if (DevicePath == NULL) { + return 0; + } + + // + // Search for the end of the device path structure + // + Start = DevicePath; + while (!EfiIsDevicePathEnd (DevicePath)) { + DevicePath = EfiNextDevicePathNode (DevicePath); + } + + // + // Compute the size and add back in the size of the end device path structure + // + return ((UINTN) DevicePath - (UINTN) Start) + sizeof (EFI_DEVICE_PATH_PROTOCOL); +} + +/** + This function appends the device path SecondDevicePath + to every device path instance in FirstDevicePath. + + @param FirstDevicePath A pointer to a device path data structure. + + @param SecondDevicePath A pointer to a device path data structure. + + @return 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 FirstDevicePath and SecondDevicePath + if they are no longer needed. + +**/ +EFI_DEVICE_PATH_PROTOCOL * +EFIAPI +SmmAppendDevicePath ( + IN CONST EFI_DEVICE_PATH_PROTOCOL *FirstDevicePath, + IN CONST EFI_DEVICE_PATH_PROTOCOL *SecondDevicePath + ) +{ + EFI_STATUS Status; + UINTN Size; + UINTN Size1; + UINTN Size2; + EFI_DEVICE_PATH_PROTOCOL *NewDevicePath; + EFI_DEVICE_PATH_PROTOCOL *DevicePath2; + + ASSERT (FirstDevicePath != NULL && SecondDevicePath != NULL); + + // + // Allocate space for the combined device path. It only has one end node of + // length EFI_DEVICE_PATH_PROTOCOL + // + Size1 = SmmGetDevicePathSize (FirstDevicePath); + Size2 = SmmGetDevicePathSize (SecondDevicePath); + Size = Size1 + Size2 - sizeof (EFI_DEVICE_PATH_PROTOCOL); + + Status = (mBS->AllocatePool) (EfiBootServicesData, Size, (VOID **) &NewDevicePath); + + if (EFI_SUCCESS == Status) { + (mBS->CopyMem) ((VOID *) NewDevicePath, (VOID *) FirstDevicePath, Size1); + // + // Over write Src1 EndNode and do the copy + // + DevicePath2 = (EFI_DEVICE_PATH_PROTOCOL *) ((CHAR8 *) NewDevicePath + (Size1 - sizeof (EFI_DEVICE_PATH_PROTOCOL))); + (mBS->CopyMem) ((VOID *) DevicePath2, (VOID *) SecondDevicePath, Size2); + } + + return NewDevicePath; +} + +/** + Unload function that is registered in the LoadImage protocol. It un-installs + protocols produced and deallocates pool used by the driver. Called by the core + when unloading the driver. + + @param ImageHandle ImageHandle of the unloaded driver + + @return Status of the ProcessModuleUnloadList. + +**/ +EFI_STATUS +EFIAPI +_DriverUnloadHandler ( + EFI_HANDLE ImageHandle + ) +{ + EFI_STATUS Status; + + // + // Call the unload handlers for all the modules + // + Status = ProcessModuleUnloadList (ImageHandle); + + // + // If the driver specific unload handler does not return an error, then call all of the + // library destructors. If the unload handler returned an error, then the driver can not be + // unloaded, and the library destructors should not be called + // + if (!EFI_ERROR (Status)) { + // + // NOTE: To allow passing in gST here, any library instance having a destructor + // must depend on EfiDriverLib + // + } + + // + // Return the status from the driver specific unload handler + // + return Status; +} + +EFI_DRIVER_ENTRY_POINT (_ModuleEntryPoint); + +// +// Module Entry Point +// +#ifdef __EDKII_GLUE_MODULE_ENTRY_POINT__ +EFI_STATUS +EFIAPI +__EDKII_GLUE_MODULE_ENTRY_POINT__ ( + EFI_HANDLE ImageHandle, + EFI_SYSTEM_TABLE *SystemTable + ); +#endif + +/** + Enrty point to DXE SMM Driver. + + @param ImageHandle ImageHandle of the loaded driver. + @param SystemTable Pointer to the EFI System Table. + + @retval EFI_SUCCESS One or more of the drivers returned a success code. + @retval !EFI_SUCESS The return status from the last driver entry point in the list. + +**/ +EFI_STATUS +EFIAPI +_ModuleEntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + EFI_LOADED_IMAGE_PROTOCOL *LoadedImage; + EFI_SMM_BASE_PROTOCOL *SmmBase; + BOOLEAN InSmm; + EFI_DEVICE_PATH_PROTOCOL *CompleteFilePath; + EFI_DEVICE_PATH_PROTOCOL *ImageDevicePath; + EFI_HANDLE Handle; + + // + // Cache a pointer to the Boot Services Table + // + mBS = SystemTable->BootServices; + + // + // Retrieve the Loaded Image Protocol + // + Status = mBS->HandleProtocol ( + ImageHandle, + &gEfiLoadedImageProtocolGuid, + (VOID*)&LoadedImage + ); + ASSERT_EFI_ERROR (Status); + + // + // Retrieve SMM Base Protocol + // + Status = mBS->LocateProtocol ( + &gEfiSmmBaseProtocolGuid, + NULL, + (VOID **) &SmmBase + ); + ASSERT_EFI_ERROR (Status); + + // + // Check to see if we are already in SMM + // + SmmBase->InSmm (SmmBase, &InSmm); + + // + // + // + if (!InSmm) { + // + // Retrieve the Device Path Protocol from the DeviceHandle tha this driver was loaded from + // + Status = mBS->HandleProtocol ( + LoadedImage->DeviceHandle, + &gEfiDevicePathProtocolGuid, + (VOID*)&ImageDevicePath + ); + ASSERT_EFI_ERROR (Status); + + // + // Build the full device path to the currently execuing image + // + CompleteFilePath = SmmAppendDevicePath (ImageDevicePath, LoadedImage->FilePath); + + // + // Load the image in memory to SMRAM; it will automatically generate the + // SMI. + // + Status = SmmBase->Register (SmmBase, CompleteFilePath, NULL, 0, &Handle, FALSE); + ASSERT_EFI_ERROR (Status); + return Status; + } + + // + // Call constructor for all libraries + // + ProcessLibraryConstructorList (ImageHandle, SystemTable); + + Status = mBS->HandleProtocol ( + ImageHandle, + &gEfiSmmDebugMaskProtocolGuid, + (VOID **)&gDebugMaskInterface + ); + if (EFI_ERROR(Status)) { + gDebugMaskInterface = NULL; + } + + // + // Install the unload handler + // + Status = mBS->HandleProtocol ( + ImageHandle, + &gEfiLoadedImageProtocolGuid, + (VOID **)&LoadedImage + ); + ASSERT_EFI_ERROR (Status); + LoadedImage->Unload = _DriverUnloadHandler; + + // + // Call the list of driver entry points + // + #ifdef __EDKII_GLUE_MODULE_ENTRY_POINT__ + Status = (__EDKII_GLUE_MODULE_ENTRY_POINT__ (ImageHandle, SystemTable)); + #else + Status = EFI_SUCCESS; + #endif + + if (EFI_ERROR (Status)) { + ProcessLibraryDestructorList (ImageHandle, SystemTable); + } + + return Status; +} + +/** + Enrty point wrapper of DXE SMM Driver. + + @param ImageHandle ImageHandle of the loaded driver. + @param SystemTable Pointer to the EFI System Table. + + @retval EFI_SUCCESS One or more of the drivers returned a success code. + @retval !EFI_SUCESS The return status from the last driver entry point in the list. + +**/ +EFI_STATUS +EFIAPI +EfiMain ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + return _ModuleEntryPoint (ImageHandle, SystemTable); +} + +// +// Guids not present in R8.6 code base +// + +// +// Protocol/Arch Protocol GUID globals +// +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gUefiDriverConfigurationProtocolGuid = { 0xbfd7dc1d, 0x24f1, 0x40d9, { 0x82, 0xe7, 0x2e, 0x09, 0xbb, 0x6b, 0x4e, 0xbe } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gUefiDriverDiagnosticsProtocolGuid = { 0x4d330321, 0x025f, 0x4aac, { 0x90, 0xd8, 0x5e, 0xd9, 0x00, 0x17, 0x3b, 0x63 } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiArpProtocolGuid = { 0xf4b427bb, 0xba21, 0x4f16, { 0xbc, 0x4e, 0x43, 0xe4, 0x16, 0xab, 0x61, 0x9c } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiArpServiceBindingProtocolGuid = { 0xf44c00ee, 0x1f2c, 0x4a00, { 0xaa, 0x09, 0x1c, 0x9f, 0x3e, 0x08, 0x00, 0xa3 } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiDhcp4ProtocolGuid = { 0x8a219718, 0x4ef5, 0x4761, { 0x91, 0xc8, 0xc0, 0xf0, 0x4b, 0xda, 0x9e, 0x56 } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiDhcp4ServiceBindingProtocolGuid = { 0x9d9a39d8, 0xbd42, 0x4a73, { 0xa4, 0xd5, 0x8e, 0xe9, 0x4b, 0xe1, 0x13, 0x80 } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiIp4ProtocolGuid = { 0x41d94cd2, 0x35b6, 0x455a, { 0x82, 0x58, 0xd4, 0xe5, 0x13, 0x34, 0xaa, 0xdd } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiIp4ServiceBindingProtocolGuid = { 0xc51711e7, 0xb4bf, 0x404a, { 0xbf, 0xb8, 0x0a, 0x04, 0x8e, 0xf1, 0xff, 0xe4 } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiIp4ConfigProtocolGuid = { 0x3b95aa31, 0x3793, 0x434b, { 0x86, 0x67, 0xc8, 0x07, 0x08, 0x92, 0xe0, 0x5e } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiManagedNetworkProtocolGuid = { 0x3b95aa31, 0x3793, 0x434b, { 0x86, 0x67, 0xc8, 0x07, 0x08, 0x92, 0xe0, 0x5e } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiManagedNetworkServiceBindingProtocolGuid = { 0xf36ff770, 0xa7e1, 0x42cf, { 0x9e, 0xd2, 0x56, 0xf0, 0xf2, 0x71, 0xf4, 0x4c } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiMtftp4ProtocolGuid = { 0x3ad9df29, 0x4501, 0x478d, { 0xb1, 0xf8, 0x7f, 0x7f, 0xe7, 0x0e, 0x50, 0xf3 } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiMtftp4ServiceBindingProtocolGuid = { 0x2FE800BE, 0x8F01, 0x4aa6, { 0x94, 0x6B, 0xD7, 0x13, 0x88, 0xE1, 0x83, 0x3F } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiTcp4ProtocolGuid = { 0x65530BC7, 0xA359, 0x410f, { 0xB0, 0x10, 0x5A, 0xAD, 0xC7, 0xEC, 0x2B, 0x62 } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiTcp4ServiceBindingProtocolGuid = { 0x00720665, 0x67EB, 0x4a99, { 0xBA, 0xF7, 0xD3, 0xC3, 0x3A, 0x1C, 0x7C, 0xC9 } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiUdp4ProtocolGuid = { 0x3ad9df29, 0x4501, 0x478d, { 0xb1, 0xf8, 0x7f, 0x7f, 0xe7, 0x0e, 0x50, 0xf3 } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiUdp4ServiceBindingProtocolGuid = { 0x83f01464, 0x99bd, 0x45e5, { 0xb3, 0x83, 0xaf, 0x63, 0x05, 0xd8, 0xe9, 0xe6 } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiAuthenticationInfoProtocolGuid = { 0x7671d9d0, 0x53db, 0x4173, { 0xaa, 0x69, 0x23, 0x27, 0xf2, 0x1f, 0x0b, 0xc7 } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiDevicePathFromTextProtocolGuid = { 0x5c99a21, 0xc70f, 0x4ad2, { 0x8a, 0x5f, 0x35, 0xdf, 0x33, 0x43, 0xf5, 0x1e } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiDevicePathToTextProtocolGuid = { 0x8b843e20, 0x8132, 0x4852, { 0x90, 0xcc, 0x55, 0x1a, 0x4e, 0x4a, 0x7f, 0x1c } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiDevicePathUtilitiesProtocolGuid = { 0x379be4e, 0xd706, 0x437d, { 0xb0, 0x37, 0xed, 0xb8, 0x2f, 0xb7, 0x72, 0xa4 } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiHashProtocolGuid = { 0xc5184932, 0xdba5, 0x46db, { 0xa5, 0xba, 0xcc, 0x0b, 0xda, 0x9c, 0x14, 0x35 } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiHashServiceBindingProtocolGuid = { 0x42881c98, 0xa4f3, 0x44b0, { 0xa3, 0x9d, 0xdf, 0xa1, 0x86, 0x67, 0xd8, 0xcd } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiIScsiInitiatorNameProtocolGuid = { 0xa6a72875, 0x2962, 0x4c18, { 0x9f, 0x46, 0x8d, 0xa6, 0x44, 0xcc, 0xfe, 0x00 } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiExtScsiPassThruProtocolGuid = { 0x1d3de7f0, 0x0807, 0x424f, { 0xaa, 0x69, 0x11, 0xa5, 0x4e, 0x19, 0xa4, 0x6f } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiTapeIoProtocolGuid = { 0x1e93e633, 0xd65a, 0x459e, { 0xab, 0x84, 0x93, 0xd9, 0xec, 0x26, 0x6d, 0x18 } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiUsb2HcProtocolGuid = { 0x3e745226, 0x9818, 0x45b6, { 0xa2, 0xac, 0xd7, 0xcd, 0x0e, 0x8b, 0xa2, 0xbc } }; + +// +// PPI GUID globals +// + +// +// GUID globals +// +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiHobMemoryAllocBspStoreGuid = { 0x564b33cd, 0xc92a, 0x4593, { 0x90, 0xbf, 0x24, 0x73, 0xe4, 0x3c, 0x63, 0x22 } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiHobMemoryAllocStackGuid = { 0x4ed4bf27, 0x4092, 0x42e9, { 0x80, 0x7d, 0x52, 0x7b, 0x1d, 0x00, 0xc9, 0xbd } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiHobMemoryAllocModuleGuid = { 0xf8e21975, 0x0899, 0x4f58, { 0xa4, 0xbe, 0x55, 0x25, 0xa9, 0xc6, 0xd7, 0x7a } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiAuthenticationChapRadiusGuid = { 0xd6062b50, 0x15ca, 0x11da, { 0x92, 0x19, 0x00, 0x10, 0x83, 0xff, 0xca, 0x4d } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiAuthenticationChapLocalGuid = { 0xc280c73e, 0x15ca, 0x11da, { 0xb0, 0xca, 0x00, 0x10, 0x83, 0xff, 0xca, 0x4d } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiHashAlgorithmSha1Guid = { 0x2ae9d80f, 0x3fb2, 0x4095, { 0xb7, 0xb1, 0xe9, 0x31, 0x57, 0xb9, 0x46, 0xb6 } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiHashAlgorithmSha224Guid = { 0x8df01a06, 0x9bd5, 0x4bf7, { 0xb0, 0x21, 0xdb, 0x4f, 0xd9, 0xcc, 0xf4, 0x5b } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiHashAlgorithmSha256Guid = { 0x51aa59de, 0xfdf2, 0x4ea3, { 0xbc, 0x63, 0x87, 0x5f, 0xb7, 0x84, 0x2e, 0xe9 } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiHashAlgorithmSha384Guid = { 0xefa96432, 0xde33, 0x4dd2, { 0xae, 0xe6, 0x32, 0x8c, 0x33, 0xdf, 0x77, 0x7a } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiHashAlgorithmSha512Guid = { 0xcaa4381e, 0x750c, 0x4770, { 0xb8, 0x70, 0x7a, 0x23, 0xb4, 0xe4, 0x21, 0x30 } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiHashAlgorithmMD5Guid = { 0xaf7c79c, 0x65b5, 0x4319, { 0xb0, 0xae, 0x44, 0xec, 0x48, 0x4e, 0x4a, 0xd7 } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gBootObjectAuthorizationParmsetGuid = { 0xedd35e31, 0x7b9, 0x11d2, { 0x83, 0xa3, 0x00, 0xa0, 0xc9, 0x1f, 0xad, 0xcf } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gSmmCommunicateHeaderGuid = { 0xf328e36c, 0x23b6, 0x4a95, { 0x85, 0x4b, 0x32, 0xe1, 0x95, 0x34, 0xcd, 0x75 } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiCapsuleGuid = { 0x3B6686BD, 0x0D76, 0x4030, { 0xB7, 0x0E, 0xB5, 0x51, 0x9E, 0x2F, 0xC5, 0xA0 } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiConfigFileNameGuid = { 0x98B8D59B, 0xE8BA, 0x48EE, { 0x98, 0xDD, 0xC2, 0x95, 0x39, 0x2F, 0x1E, 0xDB } }; diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Include/AutoGen.h b/EDK/Foundation/Library/EdkIIGlueLib/Include/AutoGen.h new file mode 100644 index 0000000..626ffed --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Include/AutoGen.h @@ -0,0 +1,37 @@ +/*++ + +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: + + AutoGen.h + +Abstract: + + This file is used by .dxe file. To write common .dxs for R8.x and R9, a + header file named AutoGen.h musted be present. Here the AutoGen.h isn't + auto-generated by any tool. + +--*/ + +#ifndef __EDKII_GLUELIB_AUTOGEN_H__ +#define __EDKII_GLUELIB_AUTOGEN_H__ + + +// +// Users can use this macro in .dxs file +// +#ifndef BUILD_WITH_GLUELIB + #define BUILD_WITH_GLUELIB +#endif + + +#endif diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Include/Common/EdkIIGlueBaseTypes.h b/EDK/Foundation/Library/EdkIIGlueLib/Include/Common/EdkIIGlueBaseTypes.h new file mode 100644 index 0000000..81180e9 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Include/Common/EdkIIGlueBaseTypes.h @@ -0,0 +1,90 @@ +/*++ + +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: + + EdkIIGlueBaseTypes.h + +Abstract: + + Defines additional data types for use by Base modules + +--*/ + +#ifndef __EDKII_GLUE_BASE_TYPES_H__ +#define __EDKII_GLUE_BASE_TYPES_H__ + +#include "..\EdkIIGlueConfig.h" + +#define BREAKPOINT EFI_BREAKPOINT +#define DEADLOOP EFI_DEADLOOP + +#define MAX_BIT EFI_MAX_BIT +#define MAX_ADDRESS EFI_MAX_ADDRESS + +#ifndef UINT8_MAX + #define UINT8_MAX 0xff +#endif + +// +// EFI Error Codes common to all execution phases +// + +typedef INTN RETURN_STATUS; + +/// +/// Set the upper bit to indicate EFI Error. +/// +#define ENCODE_ERROR(a) (MAX_BIT | (a)) + +#define ENCODE_WARNING(a) (a) +#define RETURN_ERROR(a) ((a) < 0) + +#define RETURN_SUCCESS 0 +#define RETURN_LOAD_ERROR ENCODE_ERROR (1) +#define RETURN_INVALID_PARAMETER ENCODE_ERROR (2) +#define RETURN_UNSUPPORTED ENCODE_ERROR (3) +#define RETURN_BAD_BUFFER_SIZE ENCODE_ERROR (4) +#define RETURN_BUFFER_TOO_SMALL ENCODE_ERROR (5) +#define RETURN_NOT_READY ENCODE_ERROR (6) +#define RETURN_DEVICE_ERROR ENCODE_ERROR (7) +#define RETURN_WRITE_PROTECTED ENCODE_ERROR (8) +#define RETURN_OUT_OF_RESOURCES ENCODE_ERROR (9) +#define RETURN_VOLUME_CORRUPTED ENCODE_ERROR (10) +#define RETURN_VOLUME_FULL ENCODE_ERROR (11) +#define RETURN_NO_MEDIA ENCODE_ERROR (12) +#define RETURN_MEDIA_CHANGED ENCODE_ERROR (13) +#define RETURN_NOT_FOUND ENCODE_ERROR (14) +#define RETURN_ACCESS_DENIED ENCODE_ERROR (15) +#define RETURN_NO_RESPONSE ENCODE_ERROR (16) +#define RETURN_NO_MAPPING ENCODE_ERROR (17) +#define RETURN_TIMEOUT ENCODE_ERROR (18) +#define RETURN_NOT_STARTED ENCODE_ERROR (19) +#define RETURN_ALREADY_STARTED ENCODE_ERROR (20) +#define RETURN_ABORTED ENCODE_ERROR (21) +#define RETURN_ICMP_ERROR ENCODE_ERROR (22) +#define RETURN_TFTP_ERROR ENCODE_ERROR (23) +#define RETURN_PROTOCOL_ERROR ENCODE_ERROR (24) +#define RETURN_INCOMPATIBLE_VERSION ENCODE_ERROR (25) +#define RETURN_SECURITY_VIOLATION ENCODE_ERROR (26) +#define RETURN_CRC_ERROR ENCODE_ERROR (27) +#define RETURN_END_OF_MEDIA ENCODE_ERROR (28) +#define RETURN_END_OF_FILE ENCODE_ERROR (31) + +#define RETURN_WARN_UNKNOWN_GLYPH ENCODE_WARNING (1) +#define RETURN_WARN_DELETE_FAILURE ENCODE_WARNING (2) +#define RETURN_WARN_WRITE_FAILURE ENCODE_WARNING (3) +#define RETURN_WARN_BUFFER_TOO_SMALL ENCODE_WARNING (4) + +typedef UINT64 PHYSICAL_ADDRESS; + +#endif diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Include/Common/EdkIIGlueDefinitionChangesBase.h b/EDK/Foundation/Library/EdkIIGlueLib/Include/Common/EdkIIGlueDefinitionChangesBase.h new file mode 100644 index 0000000..aafcdd2 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Include/Common/EdkIIGlueDefinitionChangesBase.h @@ -0,0 +1,118 @@ +/*++ + +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: + + EdkIIGlueDefinitionChangesBase.h + +Abstract: + + Data structure definition changes from EDK to EDKII + +--*/ + +#ifndef __EDKII_GLUE_DEFINITION_CHANGES_BASE_H__ +#define __EDKII_GLUE_DEFINITION_CHANGES_BASE_H__ + +#if (EFI_SPECIFICATION_VERSION >= 0x0002000A) +#include "TianoHii.h" +#else +#include "EfiInternalFormRepresentation.h" +#endif +#include "EfiPxe.h" + + +// ---------------------------------------------------------------------------------- +// Data Hub Record GUID Name changes +// ---------------------------------------------------------------------------------- +#define gEfiProcessorSubClassGuid gProcessorSubClassName +#define gEfiCacheSubClassGuid gCacheSubClassName +#define gEfiMiscSubClassGuid gMiscSubClassName +#define gEfiProcessorProducerGuid gProcessorProducerGuid +#define gEfiMemoryProducerGuid gMemoryProducerGuid +#define gEfiMiscProducerGuid gMiscProducerGuid + + +// ---------------------------------------------------------------------------------- +// Hob.h: Get the data and data size field of GUID +// ---------------------------------------------------------------------------------- +#define GET_GUID_HOB_DATA(GuidHob) ((VOID *) (((UINT8 *) &((GuidHob)->Name)) + sizeof (EFI_GUID))) +#define GET_GUID_HOB_DATA_SIZE(GuidHob) (((GuidHob)->Header).HobLength - sizeof (EFI_HOB_GUID_TYPE)) + +// ---------------------------------------------------------------------------------- +// InternalFormRepresentation.h: +// ---------------------------------------------------------------------------------- +#if (EFI_SPECIFICATION_VERSION < 0x0002000A) +typedef struct { + EFI_IFR_OP_HEADER Header; + UINT16 QuestionId; // The ID designating what the question is about...sucked in from a #define, likely in the form of a variable name + UINT8 Width; // The Size of the Data being saved + STRING_REF Prompt; // The String Token for the Prompt + STRING_REF Help; // The string Token for the context-help + UINT8 Flags; // For now, if non-zero, means that it is the default option, - further definition likely + UINT16 Key; // Value to be passed to caller to identify this particular op-code +} EFI_IFR_CHECKBOX; + +typedef struct { + EFI_IFR_OP_HEADER Header; + UINT8 Flags; +} EFI_IFR_GRAY_OUT; + +typedef struct { + EFI_IFR_OP_HEADER Header; +} EFI_IFR_END_EXPR; +#endif + +// ------------------------ +// define GUID as EFI_GUID +// ------------------------ +typedef EFI_GUID GUID; + + +// ------------------- +// EdkII Names - Edk Names +// ------------------- +#define EFI_GLOBAL_VARIABLE EFI_GLOBAL_VARIABLE_GUID +#define MPS_TABLE_GUID EFI_MPS_TABLE_GUID +#define SAL_SYSTEM_TABLE_GUID EFI_SAL_SYSTEM_TABLE_GUID +#define SMBIOS_TABLE_GUID EFI_SMBIOS_TABLE_GUID +#define EFI_OPTIONAL_PTR EFI_OPTIONAL_POINTER +#define PXE_FRAME_TYPE_FILTERED_MULTICAST PXE_FRAME_TYPE_MULTICAST +#define IMAGE_FILE_MACHINE_I386 EFI_IMAGE_MACHINE_IA32 +#define IMAGE_FILE_MACHINE_IA64 EFI_IMAGE_MACHINE_IA64 +#define IMAGE_FILE_MACHINE_EBC EFI_IMAGE_MACHINE_EBC +#define IMAGE_FILE_MACHINE_X64 EFI_IMAGE_MACHINE_X64 +#define EVENT_TIMER EFI_EVENT_TIMER +#define EVENT_RUNTIME EFI_EVENT_RUNTIME +#define EVENT_RUNTIME_CONTEXT EFI_EVENT_RUNTIME_CONTEXT +#define EVENT_NOTIFY_WAIT EFI_EVENT_NOTIFY_WAIT +#define EVENT_NOTIFY_SIGNAL EFI_EVENT_NOTIFY_SIGNAL +#define EVENT_SIGNAL_EXIT_BOOT_SERVICES EFI_EVENT_SIGNAL_EXIT_BOOT_SERVICES +#define EVENT_SIGNAL_VIRTUAL_ADDRESS_CHANGE EFI_EVENT_SIGNAL_VIRTUAL_ADDRESS_CHANGE +#define TPL_APPLICATION EFI_TPL_APPLICATION +#define TPL_CALLBACK EFI_TPL_CALLBACK +#define TPL_NOTIFY EFI_TPL_NOTIFY +#define TPL_HIGH_LEVEL EFI_TPL_HIGH_LEVEL + +// +// Typos in R8.x +// +#define gEfiHobMemoryAllocModuleGuid gEfiHobMemeryAllocModuleGuid +#define gEfiHobMemoryAllocStackGuid gEfiHobMemeryAllocStackGuid +#define gEfiHobMemoryAllocBspStoreGuid gEfiHobMemeryAllocBspStoreGuid + +// +// typedef Edk types - EdkII types +// +typedef PXE_CPB_START PXE_CPB_START_30; + +#endif diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Include/Common/EdkIIGlueDefinitionChangesDxe.h b/EDK/Foundation/Library/EdkIIGlueLib/Include/Common/EdkIIGlueDefinitionChangesDxe.h new file mode 100644 index 0000000..dcedbe5 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Include/Common/EdkIIGlueDefinitionChangesDxe.h @@ -0,0 +1,95 @@ +/*++ + +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: + + EdkIIGlueDefinitionChangesDxe.h + +Abstract: + + Data structure definition changes from EDK to EDKII + +--*/ + +#ifndef __EDKII_GLUE_DEFINITION_CHANGES_DXE_H__ +#define __EDKII_GLUE_DEFINITION_CHANGES_DXE_H__ + +#if (EFI_SPECIFICATION_VERSION >= 0x0002000A) +#include "TianoHii.h" +#else +#include "EfiInternalFormRepresentation.h" +#endif + +#include "EdkIIGlueDefinitionChangesBase.h" + +#if (TIANO_RELEASE_VERSION <= 0x00080005) + #define gEfiStatusCodeRuntimeProtocolGuid gEfiStatusCodeArchProtocolGuid +#endif + +// +// typedef Edk types - EdkII types +// +typedef EFI_MEMORY_ARRAY_START_ADDRESS EFI_MEMORY_ARRAY_START_ADDRESS_DATA; +typedef EFI_MEMORY_DEVICE_START_ADDRESS EFI_MEMORY_DEVICE_START_ADDRESS_DATA; +typedef EFI_MISC_LAST_PCI_BUS EFI_MISC_LAST_PCI_BUS_DATA; +typedef EFI_MISC_BIOS_VENDOR EFI_MISC_BIOS_VENDOR_DATA; +typedef EFI_MISC_SYSTEM_MANUFACTURER EFI_MISC_SYSTEM_MANUFACTURER_DATA; +typedef EFI_MISC_BASE_BOARD_MANUFACTURER EFI_MISC_BASE_BOARD_MANUFACTURER_DATA; +typedef EFI_MISC_CHASSIS_MANUFACTURER EFI_MISC_CHASSIS_MANUFACTURER_DATA; +typedef EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA; +typedef EFI_MISC_SYSTEM_SLOT_DESIGNATION EFI_MISC_SYSTEM_SLOT_DESIGNATION_DATA; +typedef EFI_MISC_ONBOARD_DEVICE EFI_MISC_ONBOARD_DEVICE_DATA; +typedef EFI_MISC_ONBOARD_DEVICE_TYPE_DATA EFI_MISC_PORTING_DEVICE_TYPE_DATA; +typedef EFI_MISC_OEM_STRING EFI_MISC_OEM_STRING_DATA; +typedef EFI_MISC_SYSTEM_OPTION_STRING EFI_MISC_SYSTEM_OPTION_STRING_DATA; +typedef EFI_MISC_NUMBER_OF_INSTALLABLE_LANGUAGES EFI_MISC_NUMBER_OF_INSTALLABLE_LANGUAGES_DATA; +typedef EFI_MISC_SYSTEM_LANGUAGE_STRING EFI_MISC_SYSTEM_LANGUAGE_STRING_DATA; +typedef EFI_MISC_BIS_ENTRY_POINT EFI_MISC_BIS_ENTRY_POINT_DATA; +typedef EFI_MISC_BOOT_INFORMATION_STATUS EFI_MISC_BOOT_INFORMATION_STATUS_DATA; +typedef EFI_MISC_SYSTEM_POWER_SUPPLY EFI_MISC_SYSTEM_POWER_SUPPLY_DATA ; +typedef EFI_MISC_SMBIOS_STRUCT_ENCAPSULATION EFI_MISC_SMBIOS_STRUCT_ENCAPSULATION_DATA; + +// ------------------- +// EdkII Names - Edk Names +// ------------------- +#define gEfiAcpiSupportProtocolGuid gEfiAcpiSupportGuid +#define gEfiLoadPeImageProtocolGuid gEfiLoadPeImageGuid +#if (EFI_SPECIFICATION_VERSION < 0x0002000A) +#define EFI_GLYPH_NON_SPACING GLYPH_NON_SPACING +#define EFI_GLYPH_WIDE GLYPH_NON_BREAKING +#endif +#define BOOT_OBJECT_AUTHORIZATION_PARMSET_GUID BOOT_OBJECT_AUTHORIZATION_PARMSET_GUIDVALUE +#define EFI_EBC_PROTOCOL_GUID EFI_EBC_INTERPRETER_PROTOCOL_GUID +#define EFI_FILE_SYSTEM_VOLUME_LABEL_ID EFI_FILE_SYSTEM_VOLUME_LABEL_INFO_ID_GUID +#define EFI_LOADED_IMAGE_PROTOCOL_REVISION EFI_LOADED_IMAGE_INFORMATION_REVISION +#define EFI_LOAD_FILE_PROTOCOL_GUID LOAD_FILE_PROTOCOL_GUID +#define EFI_PXE_BASE_CODE_PROTOCOL_REVISION EFI_PXE_BASE_CODE_INTERFACE_REVISION +#define EFI_PXE_BASE_CODE_CALLBACK_PROTOCOL_REVISION EFI_PXE_BASE_CODE_CALLBACK_INTERFACE_REVISION +#define EFI_SERIAL_IO_PROTOCOL_REVISION SERIAL_IO_INTERFACE_REVISION +#define EFI_FILE_PROTOCOL_REVISION EFI_FILE_HANDLE_REVISION +#define EFI_SIMPLE_TEXT_INPUT_PROTOCOL_GUID EFI_SIMPLE_TEXT_IN_PROTOCOL_GUID + + +// +// typedef Edk types - EdkII types +// +typedef EFI_VOLUME_OPEN EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_OPEN_VOLUME; +typedef EFI_TEXT_OUTPUT_STRING EFI_TEXT_STRING; +#if (EFI_SPECIFICATION_VERSION < 0x0002000A) +typedef SCREEN_DESCRIPTOR EFI_SCREEN_DESCRIPTOR; +#endif +typedef EFI_SIMPLE_TEXT_IN_PROTOCOL EFI_SIMPLE_TEXT_INPUT_PROTOCOL; +typedef EFI_SIMPLE_TEXT_OUT_PROTOCOL EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL; +//typedef EFI_TO_LEGACY16_INIT_TABLE EFI_TO_COMPATIBILITY16_INIT_TABLE; +//typedef DISPATCH_OPROM_TABLE EFI_DISPATCH_OPROM_TABLE; + +#endif diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Include/Common/EdkIIGlueDefinitionChangesPeim.h b/EDK/Foundation/Library/EdkIIGlueLib/Include/Common/EdkIIGlueDefinitionChangesPeim.h new file mode 100644 index 0000000..373c9b4 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Include/Common/EdkIIGlueDefinitionChangesPeim.h @@ -0,0 +1,165 @@ +/*++ + +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: + + EdkIIGlueDefinitionChangesPeim.h + +Abstract: + + Data structure definition changes from EDK to EDKII + +--*/ + +#ifndef __EDKII_GLUE_DEFINITION_CHANGES_PEIM_H__ +#define __EDKII_GLUE_DEFINITION_CHANGES_PEIM_H__ + +#if (EFI_SPECIFICATION_VERSION >= 0x0002000A) +#include "TianoHii.h" +#else +#include "EfiInternalFormRepresentation.h" +#endif + +#include "EdkIIGlueDefinitionChangesBase.h" + +#include "EfiPciCfg.h" + +// +// typedef Edk types - EdkII types +// +typedef EFI_MEMORY_ARRAY_START_ADDRESS EFI_MEMORY_ARRAY_START_ADDRESS_DATA; +typedef EFI_MEMORY_DEVICE_START_ADDRESS EFI_MEMORY_DEVICE_START_ADDRESS_DATA; +typedef EFI_MISC_LAST_PCI_BUS EFI_MISC_LAST_PCI_BUS_DATA; +typedef EFI_MISC_BIOS_VENDOR EFI_MISC_BIOS_VENDOR_DATA; +typedef EFI_MISC_SYSTEM_MANUFACTURER EFI_MISC_SYSTEM_MANUFACTURER_DATA; +typedef EFI_MISC_BASE_BOARD_MANUFACTURER EFI_MISC_BASE_BOARD_MANUFACTURER_DATA; +typedef EFI_MISC_CHASSIS_MANUFACTURER EFI_MISC_CHASSIS_MANUFACTURER_DATA; +typedef EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA; +typedef EFI_MISC_SYSTEM_SLOT_DESIGNATION EFI_MISC_SYSTEM_SLOT_DESIGNATION_DATA; +typedef EFI_MISC_ONBOARD_DEVICE EFI_MISC_ONBOARD_DEVICE_DATA; +typedef EFI_MISC_ONBOARD_DEVICE_TYPE_DATA EFI_MISC_PORTING_DEVICE_TYPE_DATA; +typedef EFI_MISC_OEM_STRING EFI_MISC_OEM_STRING_DATA; +typedef EFI_MISC_SYSTEM_OPTION_STRING EFI_MISC_SYSTEM_OPTION_STRING_DATA; +typedef EFI_MISC_NUMBER_OF_INSTALLABLE_LANGUAGES EFI_MISC_NUMBER_OF_INSTALLABLE_LANGUAGES_DATA; +typedef EFI_MISC_SYSTEM_LANGUAGE_STRING EFI_MISC_SYSTEM_LANGUAGE_STRING_DATA; +typedef EFI_MISC_BIS_ENTRY_POINT EFI_MISC_BIS_ENTRY_POINT_DATA; +typedef EFI_MISC_BOOT_INFORMATION_STATUS EFI_MISC_BOOT_INFORMATION_STATUS_DATA; +typedef EFI_MISC_SYSTEM_POWER_SUPPLY EFI_MISC_SYSTEM_POWER_SUPPLY_DATA ; +typedef EFI_MISC_SMBIOS_STRUCT_ENCAPSULATION EFI_MISC_SMBIOS_STRUCT_ENCAPSULATION_DATA; + +// ------------------- +// EdkII Names - Edk Names +// ------------------- +#define gEfiPeiCpuIoPpiInServiceTableGuid gPeiCpuIoPpiInServiceTableGuid +#define gEfiEndOfPeiSignalPpiGuid gEndOfPeiSignalPpiGuid +#define gEfiPeiFvFileLoaderPpiGuid gPeiFvFileLoaderPpiGuid +#define gEfiPeiMasterBootModePpiGuid gPeiMasterBootModePpiGuid +#define gEfiPeiMemoryDiscoveredPpiGuid gPeiMemoryDiscoveredPpiGuid +#define gEfiPciCfgPpiInServiceTableGuid gPeiPciCfgPpiInServiceTableGuid +#define gEfiPeiReadOnlyVariablePpiGuid gPeiReadOnlyVariablePpiGuid +#define gEfiPeiRecoveryModulePpiGuid gPeiRecoveryModulePpiGuid +#define gEfiPeiResetPpiGuid gPeiResetPpiGuid +#define gEfiPeiS3ResumePpiGuid gPeiS3ResumePpiGuid +#define gEfiPeiSectionExtractionPpiGuid gPeiSectionExtractionPpiGuid +#define gEfiPeiSecurityPpiGuid gPeiSecurityPpiGuid +#define gEfiPeiStatusCodePpiGuid gPeiStatusCodePpiGuid +#define gEfiPeiBootScriptExecuterPpiGuid gPeiBootScriptExecuterPpiGuid +#define gEfiPeiSmbusPpiGuid gPeiSmbusPpiGuid +#define gEfiPeiBlockIoPpiGuid gPeiBlockIoPpiGuid +#define gEfiPeiDeviceRecoveryModulePpiGuid gPeiDeviceRecoveryModulePpiGuid +#define gEfiPeiStallPpiGuid gPeiStallPpiGuid +#define gEfiPeiPciCfgPpiInServiceTableGuid gPeiPciCfgPpiInServiceTableGuid +#define gEfiPeiAtaControllerPpiGuid gPeiAtaControllerPpiGuid +#define EFI_PEI_CPU_IO_PPI_INSTALLED_GUID PEI_CPU_IO_PPI_GUID +#define EFI_PEI_RESET_PPI_GUID PEI_RESET_PPI_GUID +#define EFI_PEI_PCI_CFG_PPI_INSTALLED_GUID PEI_PCI_CFG_PPI_GUID +#define EFI_PEI_REPORT_PROGRESS_CODE_PPI_GUID PEI_STATUS_CODE_PPI_GUID +#define EFI_PEI_BOOT_IN_RECOVERY_MODE_PEIM_PPI PEI_BOOT_IN_RECOVERY_MODE_PEIM_PPI +#define EFI_PEI_END_OF_PEI_PHASE_PPI_GUID PEI_END_OF_PEI_PHASE_PPI_GUID +#define EFI_PEI_MASTER_BOOT_MODE_PEIM_PPI PEI_MASTER_BOOT_MODE_PEIM_PPI +#define EFI_PEI_PERMANENT_MEMORY_INSTALLED_PPI_GUID PEI_PERMANENT_MEMORY_INSTALLED_PPI_GUID +#define EFI_PEI_READ_ONLY_VARIABLE_ACCESS_PPI_GUID PEI_READ_ONLY_VARIABLE_ACCESS_PPI_GUID +#define EFI_PEI_RECOVERY_MODULE_PPI_GUID PEI_RECOVERY_MODULE_INTERFACE_PPI +#define EFI_PEI_S3_RESUME_PPI_GUID PEI_S3_RESUME_PPI_GUID +#define EFI_PEI_SECURITY_PPI_GUID PEI_SECURITY_PPI_GUID +#define EFI_PEI_STALL_PPI_GUID PEI_STALL_PPI_GUID +#define EFI_PEI_SMBUS_PPI_GUID PEI_SMBUS_PPI_GUID +#define EFI_PEI_BOOT_SCRIPT_EXECUTER_PPI_GUID PEI_BOOT_SCRIPT_EXECUTER_PPI_GUID +#define EFI_PEI_FIND_FV_PPI_GUID EFI_FIND_FV_PPI_GUID +#define EFI_PEI_VIRTUAL_BLOCK_IO_PPI PEI_BLOCK_IO_PPI_GUID +#define EFI_PEI_DEVICE_RECOVERY_MODULE_PPI_GUID PEI_DEVICE_RECOVERY_MODULE_INTERFACE_PPI + + +// +// typedef Edk types - EdkII types +// +typedef PEI_RECOVERY_MODULE_INTERFACE EFI_PEI_RECOVERY_MODULE_PPI; +typedef PEI_CPU_IO_PPI EFI_PEI_CPU_IO_PPI; +typedef PEI_STALL_PPI EFI_PEI_STALL_PPI; +typedef PEI_SMBUS_PPI EFI_PEI_SMBUS_PPI; +typedef PEI_READ_ONLY_VARIABLE_PPI EFI_PEI_READ_ONLY_VARIABLE_PPI; +typedef PEI_PCI_CFG_PPI EFI_PEI_PCI_CFG_PPI; +typedef PEI_STATUS_CODE_PPI EFI_PEI_PROGRESS_CODE_PPI; +typedef PEI_CPU_IO_PPI_WIDTH EFI_PEI_CPU_IO_PPI_WIDTH; +typedef PEI_CPU_IO_PPI_IO_MEM EFI_PEI_CPU_IO_PPI_IO_MEM; +typedef PEI_CPU_IO_PPI_ACCESS EFI_PEI_CPU_IO_PPI_ACCESS; +typedef PEI_CPU_IO_PPI_IO_READ8 EFI_PEI_CPU_IO_PPI_IO_READ8; +typedef PEI_CPU_IO_PPI_IO_READ16 EFI_PEI_CPU_IO_PPI_IO_READ16; +typedef PEI_CPU_IO_PPI_IO_READ32 EFI_PEI_CPU_IO_PPI_IO_READ32; +typedef PEI_CPU_IO_PPI_IO_READ64 EFI_PEI_CPU_IO_PPI_IO_READ64; +typedef PEI_CPU_IO_PPI_IO_WRITE8 EFI_PEI_CPU_IO_PPI_IO_WRITE8; +typedef PEI_CPU_IO_PPI_IO_WRITE16 EFI_PEI_CPU_IO_PPI_IO_WRITE16; +typedef PEI_CPU_IO_PPI_IO_WRITE32 EFI_PEI_CPU_IO_PPI_IO_WRITE32; +typedef PEI_CPU_IO_PPI_IO_WRITE64 EFI_PEI_CPU_IO_PPI_IO_WRITE64; +typedef PEI_CPU_IO_PPI_MEM_READ8 EFI_PEI_CPU_IO_PPI_MEM_READ8; +typedef PEI_CPU_IO_PPI_MEM_READ16 EFI_PEI_CPU_IO_PPI_MEM_READ16; +typedef PEI_CPU_IO_PPI_MEM_READ32 EFI_PEI_CPU_IO_PPI_MEM_READ32; +typedef PEI_CPU_IO_PPI_MEM_READ64 EFI_PEI_CPU_IO_PPI_MEM_READ64; +typedef PEI_CPU_IO_PPI_MEM_WRITE8 EFI_PEI_CPU_IO_PPI_MEM_WRITE8; +typedef PEI_CPU_IO_PPI_MEM_WRITE16 EFI_PEI_CPU_IO_PPI_MEM_WRITE16; +typedef PEI_CPU_IO_PPI_MEM_WRITE32 EFI_PEI_CPU_IO_PPI_MEM_WRITE32; +typedef PEI_CPU_IO_PPI_MEM_WRITE64 EFI_PEI_CPU_IO_PPI_MEM_WRITE64; +//;;## ...AMI_OVERRIDE... Support PI1.x typedef PEI_PCI_CFG_PPI_WIDTH EFI_PEI_PCI_CFG_PPI_WIDTH; +//;;## ...AMI_OVERRIDE... Support PI1.x typedef PEI_PCI_CFG_PPI_PCI_ADDRESS EFI_PEI_PCI_CFG_PPI_PCI_ADDRESS; +typedef PEI_GET_VARIABLE EFI_PEI_GET_VARIABLE; +typedef PEI_GET_NEXT_VARIABLE_NAME EFI_PEI_GET_NEXT_VARIABLE_NAME; +typedef PEI_LOAD_RECOVERY_CAPSULE EFI_PEI_LOAD_RECOVERY_CAPSULE; +typedef PEI_RESET_PPI EFI_PEI_RESET_PPI; +typedef PEI_S3_RESUME_PPI EFI_PEI_S3_RESUME_PPI; +typedef PEI_S3_RESUME_PPI_RESTORE_CONFIG EFI_PEI_S3_RESUME_PPI_RESTORE_CONFIG; +typedef SEC_PLATFORM_INFORMATION EFI_SEC_PLATFORM_INFORMATION; +typedef PEI_SECURITY_PPI EFI_PEI_SECURITY_PPI; +typedef PEI_SECURITY_AUTHENTICATION_STATE EFI_PEI_SECURITY_AUTHENTICATION_STATE; +typedef PEI_STALL EFI_PEI_STALL; +typedef PEI_SMBUS_PPI_EXECUTE_OPERATION EFI_PEI_SMBUS_PPI_EXECUTE_OPERATION; +typedef PEI_SMBUS_NOTIFY_FUNCTION EFI_PEI_SMBUS_NOTIFY_FUNCTION; +typedef PEI_SMBUS_PPI_ARP_DEVICE EFI_PEI_SMBUS_PPI_ARP_DEVICE; +typedef PEI_SMBUS_PPI_GET_ARP_MAP EFI_PEI_SMBUS_PPI_GET_ARP_MAP; +typedef PEI_SMBUS_PPI_NOTIFY EFI_PEI_SMBUS_PPI_NOTIFY; +typedef PEI_BOOT_SCRIPT_EXECUTE EFI_PEI_BOOT_SCRIPT_EXECUTE; +typedef PEI_BOOT_SCRIPT_EXECUTER_PPI EFI_PEI_BOOT_SCRIPT_EXECUTER_PPI; +typedef EFI_FIND_FV_FINDFV EFI_PEI_FIND_FV_FINDFV; +typedef EFI_FIND_FV_PPI EFI_PEI_FIND_FV_PPI; +typedef PEI_RECOVERY_BLOCK_IO_INTERFACE EFI_PEI_RECOVERY_BLOCK_IO_PPI; +typedef PEI_LBA EFI_PEI_LBA; +typedef PEI_BLOCK_IO_MEDIA EFI_PEI_BLOCK_IO_MEDIA; +typedef PEI_BLOCK_DEVICE_TYPE EFI_PEI_BLOCK_DEVICE_TYPE; +typedef PEI_GET_NUMBER_BLOCK_DEVICES EFI_PEI_GET_NUMBER_BLOCK_DEVICES; +typedef PEI_GET_DEVICE_MEDIA_INFORMATION EFI_PEI_GET_DEVICE_MEDIA_INFORMATION; +typedef PEI_READ_BLOCKS EFI_PEI_READ_BLOCKS; +typedef PEI_DEVICE_RECOVERY_MODULE_INTERFACE EFI_PEI_DEVICE_RECOVERY_MODULE_PPI; +typedef PEI_DEVICE_GET_NUMBER_RECOVERY_CAPSULE EFI_PEI_DEVICE_GET_NUMBER_RECOVERY_CAPSULE; +typedef PEI_DEVICE_GET_RECOVERY_CAPSULE_INFO EFI_PEI_DEVICE_GET_RECOVERY_CAPSULE_INFO; +typedef PEI_DEVICE_LOAD_RECOVERY_CAPSULE EFI_PEI_DEVICE_LOAD_RECOVERY_CAPSULE; + + +#endif diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Include/Common/EdkIIGlueDependencies.h b/EDK/Foundation/Library/EdkIIGlueLib/Include/Common/EdkIIGlueDependencies.h new file mode 100644 index 0000000..3d5aafe --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Include/Common/EdkIIGlueDependencies.h @@ -0,0 +1,698 @@ +/*++ + +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: + + EdkIIGlueDepedencies.h + +Abstract: + + Header file that lists dependency relations among library instances + +--*/ + +#ifndef __EDKII_GLUE_DEPENDENCIES_H__ +#define __EDKII_GLUE_DEPENDENCIES_H__ + + +// +// Declarations of dependencies among EdkII Glue Library instances and R8 Libraries +// Pay attention to the order of following #define structures +// + + +// +// PeiDxeDebugLibReportStatusCode +// Actually almost every module and GlueLib instance needs this library, but GlueLib +// instances don't have to list this library in their own inf files. Module inf +// does this. +// +#if defined(__EDKII_GLUE_PEI_DEBUG_LIB_REPORT_STATUS_CODE__) || defined(__EDKII_GLUE_DXE_DEBUG_LIB_REPORT_STATUS_CODE__) + #ifndef __EDKII_GLUE_BASE_LIB__ + #define __EDKII_GLUE_BASE_LIB__ + #endif + #ifndef __EDKII_GLUE_BASE_MEMORY_LIB__ + #define __EDKII_GLUE_BASE_MEMORY_LIB__ + #endif +#endif + +// +// BaseDebugLibNull +// +#ifdef __EDKII_GLUE_BASE_DEBUG_LIB_NULL__ + #ifndef __EDKII_GLUE_BASE_LIB__ + #define __EDKII_GLUE_BASE_LIB__ + #endif + #ifndef __EDKII_GLUE_BASE_MEMORY_LIB__ + #define __EDKII_GLUE_BASE_MEMORY_LIB__ + #endif + #ifndef __EDKII_GLUE_BASE_PRINT_LIB__ + #define __EDKII_GLUE_BASE_PRINT_LIB__ + #endif +#endif + +// +// EdkDxeRuntimeDriverLib +// +#ifdef __EDKII_GLUE_EDK_DXE_RUNTIME_DRIVER_LIB__ + #ifndef __EDKII_GLUE_UEFI_LIB__ + #define __EDKII_GLUE_UEFI_LIB__ + #endif + #ifndef __EDKII_GLUE_BASE_LIB__ + #define __EDKII_GLUE_BASE_LIB__ + #endif + #ifndef __EDKII_GLUE_UEFI_BOOT_SERVICES_TABLE_LIB__ + #define __EDKII_GLUE_UEFI_BOOT_SERVICES_TABLE_LIB__ + #endif +#endif + + +// +// BasePciLibCf8 +// +#ifdef __EDKII_GLUE_BASE_PCI_LIB_CF8__ + #ifndef __EDKII_GLUE_BASE_PCI_CF8_LIB__ + #define __EDKII_GLUE_BASE_PCI_CF8_LIB__ + #endif +#endif + +// +// BasePciLibPciExpress +// +#ifdef __EDKII_GLUE_BASE_PCI_LIB_PCI_EXPRESS__ + #ifndef __EDKII_GLUE_BASE_PCI_EXPRESS_LIB__ + #define __EDKII_GLUE_BASE_PCI_EXPRESS_LIB__ + #endif +#endif + +// +// BasePciCf8Lib +// +#ifdef __EDKII_GLUE_BASE_PCI_CF8_LIB__ + #ifndef __EDKII_GLUE_BASE_IO_LIB_INTRINSIC__ + #define __EDKII_GLUE_BASE_IO_LIB_INTRINSIC__ + #endif +#endif + +// BasePciExpressLib +// +#ifdef __EDKII_GLUE_BASE_PCI_EXPRESS_LIB__ + #ifndef __EDKII_GLUE_BASE_IO_LIB_INTRINSIC__ + #define __EDKII_GLUE_BASE_IO_LIB_INTRINSIC__ + #endif +#endif + +// +// BaseTimerLibLocalApic +// +#ifdef __EDKII_GLUE_BASE_TIMER_LIB_LOCAL_APIC__ + #ifndef __EDKII_GLUE_BASE_LIB__ + #define __EDKII_GLUE_BASE_LIB__ + #endif + #ifndef __EDKII_GLUE_BASE_IO_LIB_INTRINSIC__ + #define __EDKII_GLUE_BASE_IO_LIB_INTRINSIC__ + #endif +#endif + +// +// DxeReportStatusCodeLib +// +#ifdef __EDKII_GLUE_DXE_REPORT_STATUS_CODE_LIB__ + #ifndef __EDKII_GLUE_BASE_LIB__ + #define __EDKII_GLUE_BASE_LIB__ + #endif + #ifndef __EDKII_GLUE_BASE_IO_LIB_INTRINSIC__ + #define __EDKII_GLUE_BASE_IO_LIB_INTRINSIC__ + #endif + #ifndef __EDKII_GLUE_BASE_MEMORY_LIB__ + #define __EDKII_GLUE_BASE_MEMORY_LIB__ + #endif + #ifndef __EDKII_GLUE_UEFI_BOOT_SERVICES_TABLE_LIB__ + #define __EDKII_GLUE_UEFI_BOOT_SERVICES_TABLE_LIB__ + #endif + #ifndef __EDKII_GLUE_UEFI_RUNTIME_SERVICES_TABLE_LIB__ + #define __EDKII_GLUE_UEFI_RUNTIME_SERVICES_TABLE_LIB__ + #endif +#endif + +// +// SmmRuntimeDxeReportStatusCodeLib - typically used by SMM driver and Runtime driver +// +#ifdef __EDKII_GLUE_SMM_RUNTIME_DXE_REPORT_STATUS_CODE_LIB__ + #ifndef __EDKII_GLUE_BASE_LIB__ + #define __EDKII_GLUE_BASE_LIB__ + #endif + #ifndef __EDKII_GLUE_BASE_MEMORY_LIB__ + #define __EDKII_GLUE_BASE_MEMORY_LIB__ + #endif + #ifndef __EDKII_GLUE_UEFI_BOOT_SERVICES_TABLE_LIB__ + #define __EDKII_GLUE_UEFI_BOOT_SERVICES_TABLE_LIB__ + #endif + #ifndef __EDKII_GLUE_UEFI_RUNTIME_SERVICES_TABLE_LIB__ + #define __EDKII_GLUE_UEFI_RUNTIME_SERVICES_TABLE_LIB__ + #endif +#endif + +// +// PeiReportStatusCodeLib +// +#ifdef __EDKII_GLUE_PEI_REPORT_STATUS_CODE_LIB__ + #ifndef __EDKII_GLUE_BASE_LIB__ + #define __EDKII_GLUE_BASE_LIB__ + #endif + #ifndef __EDKII_GLUE_BASE_MEMORY_LIB__ + #define __EDKII_GLUE_BASE_MEMORY_LIB__ + #endif + #ifndef __EDKII_GLUE_BASE_IO_LIB_INTRINSIC__ + #define __EDKII_GLUE_BASE_IO_LIB_INTRINSIC__ + #endif + #ifndef __EDKII_GLUE_PEI_SERVICES_TABLE_POINTER_LIB_MM7__ + #define __EDKII_GLUE_PEI_SERVICES_TABLE_POINTER_LIB_MM7__ + #endif + // + // If necessary, __EDKII_GLUE_PEI_SERVICES_TABLE_POINTER_LIB_MM7__ can be + // replaced with __EDKII_GLUE_PEI_SERVICES_TABLE_POINTER_LIB__ + // +#endif + +// +// BasePeCoffLib +// +#ifdef __EDKII_GLUE_BASE_PE_COFF_LIB__ + #ifndef __EDKII_GLUE_BASE_MEMORY_LIB__ + #define __EDKII_GLUE_BASE_MEMORY_LIB__ + #endif +#endif + +// +// BaseUefiDecompressLib +// +#ifdef __EDKII_GLUE_BASE_UEFI_DECOMPRESS_LIB__ + #ifndef __EDKII_GLUE_BASE_MEMORY_LIB__ + #define __EDKII_GLUE_BASE_MEMORY_LIB__ + #endif +#endif + +// +// DxeHobLib +// +#ifdef __EDKII_GLUE_DXE_HOB_LIB__ + #ifndef __EDKII_GLUE_BASE_MEMORY_LIB__ + #define __EDKII_GLUE_BASE_MEMORY_LIB__ + #endif + #ifndef __EDKII_GLUE_UEFI_LIB__ + #define __EDKII_GLUE_UEFI_LIB__ + #endif +#endif + +// +// HiiLib +// +#ifdef __EDKII_GLUE_HII_LIB__ + #ifndef __EDKII_GLUE_DXE_MEMORY_ALLOCATION_LIB__ + #define __EDKII_GLUE_DXE_MEMORY_ALLOCATION_LIB__ + #endif +#endif + +// +// UefiDevicePathLib +// +#ifdef __EDKII_GLUE_UEFI_DEVICE_PATH_LIB__ + #ifndef __EDKII_GLUE_BASE_MEMORY_LIB__ + #define __EDKII_GLUE_BASE_MEMORY_LIB__ + #endif + #ifndef __EDKII_GLUE_UEFI_BOOT_SERVICES_TABLE_LIB__ + #define __EDKII_GLUE_UEFI_BOOT_SERVICES_TABLE_LIB__ + #endif + #ifndef __EDKII_GLUE_DXE_MEMORY_ALLOCATION_LIB__ + #define __EDKII_GLUE_DXE_MEMORY_ALLOCATION_LIB__ + #endif +#endif + +// +// DxeServicesTableLib +// +#ifdef __EDKII_GLUE_DXE_SERVICES_TABLE_LIB__ + #ifndef __EDKII_GLUE_UEFI_LIB__ + #define __EDKII_GLUE_UEFI_LIB__ + #endif +#endif + +// +// UefiLib +// +#ifdef __EDKII_GLUE_UEFI_LIB__ + #ifndef __EDKII_GLUE_BASE_LIB__ + #define __EDKII_GLUE_BASE_LIB__ + #endif + #ifndef __EDKII_GLUE_BASE_MEMORY_LIB__ + #define __EDKII_GLUE_BASE_MEMORY_LIB__ + #endif + #ifndef __EDKII_GLUE_UEFI_BOOT_SERVICES_TABLE_LIB__ + #define __EDKII_GLUE_UEFI_BOOT_SERVICES_TABLE_LIB__ + #endif + #ifndef __EDKII_GLUE_DXE_MEMORY_ALLOCATION_LIB__ + #define __EDKII_GLUE_DXE_MEMORY_ALLOCATION_LIB__ + #endif +#endif + +// +// DxeMemoryAllocationLib +// +#ifdef __EDKII_GLUE_DXE_MEMORY_ALLOCATION_LIB__ + #ifndef __EDKII_GLUE_BASE_MEMORY_LIB__ + #define __EDKII_GLUE_BASE_MEMORY_LIB__ + #endif + #ifndef __EDKII_GLUE_UEFI_BOOT_SERVICES_TABLE_LIB__ + #define __EDKII_GLUE_UEFI_BOOT_SERVICES_TABLE_LIB__ + #endif +#endif + +// +// DxeSmbusLib +// +#ifdef __EDKII_GLUE_DXE_SMBUS_LIB__ + #ifndef __EDKII_GLUE_BASE_MEMORY_LIB__ + #define __EDKII_GLUE_BASE_MEMORY_LIB__ + #endif + #ifndef __EDKII_GLUE_UEFI_BOOT_SERVICES_TABLE_LIB__ + #define __EDKII_GLUE_UEFI_BOOT_SERVICES_TABLE_LIB__ + #endif +#endif + +// +// PeiHobLib +// +#ifdef __EDKII_GLUE_PEI_HOB_LIB__ + #ifndef __EDKII_GLUE_BASE_MEMORY_LIB__ + #define __EDKII_GLUE_BASE_MEMORY_LIB__ + #endif + #ifndef __EDKII_GLUE_PEI_SERVICES_LIB__ + #define __EDKII_GLUE_PEI_SERVICES_LIB__ + #endif +#endif + +// +// PeiMemoryAllocationLib +// +#ifdef __EDKII_GLUE_PEI_MEMORY_ALLOCATION_LIB__ + #ifndef __EDKII_GLUE_BASE_MEMORY_LIB__ + #define __EDKII_GLUE_BASE_MEMORY_LIB__ + #endif + #ifndef __EDKII_GLUE_PEI_SERVICES_TABLE_POINTER_LIB_MM7__ + #define __EDKII_GLUE_PEI_SERVICES_TABLE_POINTER_LIB_MM7__ + #endif + // + // If necessary, __EDKII_GLUE_PEI_SERVICES_TABLE_POINTER_LIB_MM7__ can be + // replaced with __EDKII_GLUE_PEI_SERVICES_TABLE_POINTER_LIB__ + // +#endif + +// +// PeiResourcePublicationLib +// +#ifdef __EDKII_GLUE_PEI_RESOURCE_PUBLICATION_LIB__ + #ifndef __EDKII_GLUE_PEI_SERVICES_LIB__ + #define __EDKII_GLUE_PEI_SERVICES_LIB__ + #endif +#endif + +// +// PeiServicesLib +// +#ifdef __EDKII_GLUE_PEI_SERVICES_LIB__ + #ifndef __EDKII_GLUE_PEI_SERVICES_TABLE_POINTER_LIB_MM7__ + #define __EDKII_GLUE_PEI_SERVICES_TABLE_POINTER_LIB_MM7__ + #endif + // + // If necessary, __EDKII_GLUE_PEI_SERVICES_TABLE_POINTER_LIB_MM7__ can be + // replaced with __EDKII_GLUE_PEI_SERVICES_TABLE_POINTER_LIB__ + // +#endif + +// +// PeiSmbusLib +// +#ifdef __EDKII_GLUE_PEI_SMBUS_LIB__ + #ifndef __EDKII_GLUE_BASE_MEMORY_LIB__ + #define __EDKII_GLUE_BASE_MEMORY_LIB__ + #endif + #ifndef __EDKII_GLUE_PEI_SERVICES_TABLE_POINTER_LIB_MM7__ + #define __EDKII_GLUE_PEI_SERVICES_TABLE_POINTER_LIB_MM7__ + #endif + // + // If necessary, __EDKII_GLUE_PEI_SERVICES_TABLE_POINTER_LIB_MM7__ can be + // replaced with __EDKII_GLUE_PEI_SERVICES_TABLE_POINTER_LIB__ + // +#endif + +// +// PeiServicesTablePointerLibMm7 +// +#ifdef __EDKII_GLUE_PEI_SERVICES_TABLE_POINTER_LIB_MM7__ + #ifndef __EDKII_GLUE_BASE_LIB__ + #define __EDKII_GLUE_BASE_LIB__ + #endif +#endif + +// +// UefiDriverModelLib +// +#ifdef __EDKII_GLUE_UEFI_DRIVER_MODEL_LIB__ + #ifndef __EDKII_GLUE_UEFI_BOOT_SERVICES_TABLE_LIB__ + #define __EDKII_GLUE_UEFI_BOOT_SERVICES_TABLE_LIB__ + #endif +#endif + + +// +// UefiBootServicesTableLib +#ifdef __EDKII_GLUE_UEFI_BOOT_SERVICES_TABLE_LIB__ +#endif + +// +// BasePrintLib +// +#ifdef __EDKII_GLUE_BASE_PRINT_LIB__ + #ifndef __EDKII_GLUE_BASE_LIB__ + #define __EDKII_GLUE_BASE_LIB__ + #endif +#endif + +// +// BaseMemoryLib +// +#ifdef __EDKII_GLUE_BASE_MEMORY_LIB__ + #ifndef __EDKII_GLUE_BASE_LIB__ + #define __EDKII_GLUE_BASE_LIB__ + #endif +#endif + +// +// BasePostCodeLibPort80 +// +#ifdef __EDKII_GLUE_BASE_POST_CODE_LIB_PORT_80__ + #ifndef __EDKII_GLUE_BASE_IO_LIB_INTRINSIC__ + #define __EDKII_GLUE_BASE_IO_LIB_INTRINSIC__ + #endif +#endif + +// +// BaseIoLibIntrinsic +// +#ifdef __EDKII_GLUE_BASE_IO_LIB_INTRINSIC__ + #ifndef __EDKII_GLUE_BASE_LIB__ + #define __EDKII_GLUE_BASE_LIB__ + #endif +#endif + +// +// BaseCacheMaintenanceLib +// +#ifdef __EDKII_GLUE_BASE_CACHE_MAINTENANCE_LIB__ + #ifndef __EDKII_GLUE_BASE_LIB__ + #define __EDKII_GLUE_BASE_LIB__ + #endif +#endif + +// +// BaseLib +// +#ifdef __EDKII_GLUE_BASE_LIB__ +#endif + +// +// UefiRuntimeServicesTableLib +// +#ifdef __EDKII_GLUE_UEFI_RUNTIME_SERVICES_TABLE_LIB__ + +#endif + +// +// BasePeCoffGetEntryPointLib +// +#ifdef __EDKII_GLUE_BASE_PE_COFF_GET_ENTRY_POINT_LIB__ +#endif + +// +// PeiServicesTablePointerLib +// +#ifdef __EDKII_GLUE_PEI_SERVICES_TABLE_POINTER_LIB__ +#endif + +// +// BasePostCodeLibDebug +// +#ifdef __EDKII_GLUE_BASE_POST_CODE_LIB_DEBUG__ + // + // A DebugLib instance + // Usually either EdkIIGluePeiDebugLibReportStatusCodeLib or EdkIIGlueDxeDebugLibReportStatusCodeLib is listed in module inf + // +#endif + +// +// PeiDxePostCodeLibReportStatusCode +// +#ifdef __EDKII_GLUE_PEI_DXE_POST_CODE_LIB_REPORT_STATUS_CODE__ + // + // PEI or DXE ReportStatusCodeLib instance + // Usually EdkIIGluePei/DxeReportStatusCodeLib is listed in module inf + // +#endif + + +// +// Check against multiple instances of same library class being used +// +#if defined(__EDKII_GLUE_PEI_DEBUG_LIB_REPORT_STATUS_CODE__) && defined(__EDKII_GLUE_BASE_DEBUG_LIB_NULL__) + #error EdkIIGluePeiDebugLibReportStatusCode and EdkIIGlueBaseDebugLibNull: can only be mutual exclusively used. +#endif + +#if defined(__EDKII_GLUE_DXE_DEBUG_LIB_REPORT_STATUS_CODE__) && defined(__EDKII_GLUE_BASE_DEBUG_LIB_NULL__) + #error EdkIIGlueDxeDebugLibReportStatusCode and EdkIIGlueBaseDebugLibNull: can only be mutual exclusively used. +#endif + +#if defined(__EDKII_GLUE_PEI_DEBUG_LIB_REPORT_STATUS_CODE__) && defined(__EDKII_GLUE_DXE_DEBUG_LIB_REPORT_STATUS_CODE__) + #error EdkIIGluePeiDebugLibReportStatusCode and EdkIIGlueDxeDebugLibReportStatusCode: can only be mutual exclusively used. +#endif + +#if defined(__EDKII_GLUE_BASE_PCI_LIB_PCI_EXPRESS__) && defined(__EDKII_GLUE_BASE_PCI_LIB_CF8__) + #error EdkIIGluePciLibPciExpress and EdkIIGluePciLibCf8: can only be mutual exclusively used. +#endif + +#if defined (__EDKII_GLUE_DXE_HOB_LIB__) && defined(__EDKII_GLUE_PEI_HOB_LIB__) + #error EdkIIGlueDxeHobLib and EdkIIGluePeiHobLib: can only be mutual exclusively used. +#endif + +#if defined(__EDKII_GLUE_BASE_POST_CODE_LIB_PORT_80__) && defined(__EDKII_GLUE_BASE_POST_CODE_LIB_DEBUG__) + #error EdkIIGlueBasePostCodeLibPort80 and EdkIIGlueBasePostCodeLibDebug: can only be mutual exclusively used. +#endif + +#if defined(__EDKII_GLUE_BASE_POST_CODE_LIB_PORT_80__) && defined(__EDKII_GLUE_PEI_DXE_POST_CODE_LIB_REPORT_STATUS_CODE__) + #error EdkIIGlueBasePostCodeLibPort80 and EdkIIGluePeiDxePostCodeLibReportStatusCode: can only be mutual exclusively used. +#endif + +#if defined(__EDKII_GLUE_BASE_POST_CODE_LIB_DEBUG__) && defined(__EDKII_GLUE_PEI_DXE_POST_CODE_LIB_REPORT_STATUS_CODE__) + #error EdkIIGlueBasePostCodeLibDebug and EdkIIGluePeiDxePostCodeLibReportStatusCode: can only be mutual exclusively used. +#endif + +#if defined(__EDKII_GLUE_PEI_SERVICES_TABLE_POINTER_LIB__) && defined(__EDKII_GLUE_PEI_SERVICES_TABLE_POINTER_LIB_MM7__) + #error EdkIIGluePeiServicesTablePointerLib and EdkIIGluePeiServicesTablePointerLibMm7: can only be mutual exclusively used. +#endif + +#if defined(__EDKII_GLUE_DXE_REPORT_STATUS_CODE_LIB__) && defined(__EDKII_GLUE_PEI_REPORT_STATUS_CODE_LIB__) + #error EdkIIGlueDxeReportStatusCodeLib and EdkIIGluePeiReportStatusCodeLib: can only be mutual exclusively used. +#endif + +#if defined(__EDKII_GLUE_SMM_RUNTIME_DXE_REPORT_STATUS_CODE_LIB__) && defined(__EDKII_GLUE_PEI_REPORT_STATUS_CODE_LIB__) + #error EdkIIGlueSmmRuntimeDxeReportStatusCodeLib and EdkIIGluePeiReportStatusCodeLib: can only be mutual exclusively used. +#endif + +#if defined(__EDKII_GLUE_DXE_REPORT_STATUS_CODE_LIB__) && defined(__EDKII_GLUE_SMM_RUNTIME_DXE_REPORT_STATUS_CODE_LIB__) + #error EdkIIGlueDxeReportStatusCodeLib and EdkIIGlueSmmRuntimeDxeReportStatusCodeLib: can only be mutual exclusively used. +#endif + +#if defined(__EDKII_GLUE_DXE_MEMORY_ALLOCATION_LIB__) && defined(__EDKII_GLUE_PEI_MEMORY_ALLOCATION_LIB__) + #error EdkIIGlueDxeMemoryAllocationLib and EdkIIGluePeiMemoryAllocationLib: can only be mutual exclusively used. +#endif + +#if defined(__EDKII_GLUE_DXE_SMBUS_LIB__) && defined(__EDKII_GLUE_PEI_SMBUS_LIB__) + #error EdkIIGlueDxeSmbusLib and EdkIIGluePeiSmbusLib: can only be mutual exclusively used. +#endif + +// +// Some instances must be supplied +// +#ifdef __EDKII_GLUE_PEI_DEBUG_LIB_REPORT_STATUS_CODE__ + #if !defined(__EDKII_GLUE_PEI_REPORT_STATUS_CODE_LIB__) + #error You use EdkIIGluePeiDebugLibReportStatusCode, \ + so EdkIIGluePeiReportStatusCodeLib must be supplied + #endif +#endif + +#ifdef __EDKII_GLUE_DXE_DEBUG_LIB_REPORT_STATUS_CODE__ + #if !defined(__EDKII_GLUE_DXE_REPORT_STATUS_CODE_LIB__) \ + && !defined(__EDKII_GLUE_SMM_RUNTIME_DXE_REPORT_STATUS_CODE_LIB__) + #error You use EdkIIGlueDxeDebugLibReportStatusCode, \ + so either EdkIIGlueDxeReportStatusCodeLib, or EdkIIGlueSmmRuntimeDxeReportStatusCodeLib must be supplied + #endif +#endif + +#ifdef __EDKII_GLUE_BASE_POST_CODE_LIB_DEBUG__ + #if !defined(__EDKII_GLUE_PEI_DEBUG_LIB_REPORT_STATUS_CODE__) \ + && !defined(__EDKII_GLUE_DXE_DEBUG_LIB_REPORT_STATUS_CODE__) \ + && !defined(__EDKII_GLUE_BASE_DEBUG_LIB_NULL__) + #error You use EdkIIGlueBasePostCodeLibDebug, so either EdkIIGluePeiDebugLibReportStatusCode, EdkIIGlueDxeDebugLibReportStatusCode, \ + or EdkIIGlueBaseDebugLibNull must be supplied + #endif +#endif + +// +// EdkIIGlueUefiDriverModelLib used, but no Driver Binding Protocol defined +// +#ifdef __EDKII_GLUE_UEFI_DRIVER_MODEL_LIB__ + #ifndef __EDKII_GLUE_DRIVER_BINDING_PROTOCOL_INSTANCE__ + #error "EdkIIGlueUefiDriverModelLib used, but no Driver Binding Protocol defined. Please define __EDKII_GLUE_DRIVER_BINDING_PROTOCOL_INSTANCE__." + #endif +#endif + +// +// EdkII Glue Library Constructors: +// NOTE: the constructors must be called according to dependency order +// +// UefiBootServicesTableLib UefiBootServicesTableLibConstructor() +// UefiRuntimeServicesTableLib UefiRuntimeServicesTableLibConstructor() +// EdkDxeRuntimeDriverLib RuntimeDriverLibConstruct() +// SmmRuntimeDxeReportStatusCodeLib ReportStatusCodeLibConstruct() +// DxeHobLib HobLibConstructor() +// UefiDriverModelLib UefiDriverModelLibConstructor() +// PeiServicesTablePointerLib PeiServicesTablePointerLibConstructor() +// PeiServicesTablePointerLibMm7 PeiServicesTablePointerLibConstructor() +// DxeSmbusLib SmbusLibConstructor() +// DxeServicesTableLib DxeServicesTableLibConstructor() +// + +#ifdef __EDKII_GLUE_UEFI_BOOT_SERVICES_TABLE_LIB__ +EFI_STATUS +UefiBootServicesTableLibConstructor ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ); +#endif + +#ifdef __EDKII_GLUE_UEFI_RUNTIME_SERVICES_TABLE_LIB__ +EFI_STATUS +UefiRuntimeServicesTableLibConstructor ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ); +#endif + +#ifdef __EDKII_GLUE_EDK_DXE_RUNTIME_DRIVER_LIB__ +EFI_STATUS +RuntimeDriverLibConstruct ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ); +#endif + +#ifdef __EDKII_GLUE_SMM_RUNTIME_DXE_REPORT_STATUS_CODE_LIB__ +EFI_STATUS +EFIAPI +ReportStatusCodeLibConstruct ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ); +#endif + +#ifdef __EDKII_GLUE_DXE_HOB_LIB__ +EFI_STATUS +HobLibConstructor ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ); +#endif + +#ifdef __EDKII_GLUE_UEFI_DRIVER_MODEL_LIB__ +EFI_STATUS +UefiDriverModelLibConstructor ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ); +#endif + +#ifdef __EDKII_GLUE_PEI_SERVICES_TABLE_POINTER_LIB__ +EFI_STATUS +PeiServicesTablePointerLibConstructor ( + IN EFI_FFS_FILE_HEADER *FfsHeader, + IN EFI_PEI_SERVICES **PeiServices + ); +#endif + +#ifdef __EDKII_GLUE_PEI_SERVICES_TABLE_POINTER_LIB_MM7__ +EFI_STATUS +PeiServicesTablePointerLibConstructor ( + IN EFI_FFS_FILE_HEADER *FfsHeader, + IN EFI_PEI_SERVICES **PeiServices + ); +#endif + +#ifdef __EDKII_GLUE_DXE_SMBUS_LIB__ +EFI_STATUS +EFIAPI +SmbusLibConstructor ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ); +#endif + +#ifdef __EDKII_GLUE_DXE_SERVICES_TABLE_LIB__ +EFI_STATUS +DxeServicesTableLibConstructor ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ); +#endif + +// +// EdkII Glue Library Destructors: +// NOTE: the destructors must be called according to dependency order +// +// UefiDriverModelLibDestructor UefiDriverModelLibDestructor() +// SmmRuntimeDxeReportStatusCodeLib ReportStatusCodeLibDestruct() +// EdkDxeRuntimeDriverLib RuntimeDriverLibDeconstruct() +// +#ifdef __EDKII_GLUE_UEFI_DRIVER_MODEL_LIB__ +EFI_STATUS +UefiDriverModelLibDestructor ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ); +#endif + +#ifdef __EDKII_GLUE_SMM_RUNTIME_DXE_REPORT_STATUS_CODE_LIB__ +EFI_STATUS +EFIAPI +ReportStatusCodeLibDestruct ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ); +#endif + +#ifdef __EDKII_GLUE_EDK_DXE_RUNTIME_DRIVER_LIB__ +EFI_STATUS +RuntimeDriverLibDeconstruct ( + VOID + ); +#endif + +#endif diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Include/DxeDepex.h b/EDK/Foundation/Library/EdkIIGlueLib/Include/DxeDepex.h new file mode 100644 index 0000000..24d2d07 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Include/DxeDepex.h @@ -0,0 +1,34 @@ +/*++ + +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: + + DxeDepex.h + +Abstract: + + This file is used by .dxs file. To write common .dxs for R8.x and R9, a + header file named DxeDepex.h musted be present. + +--*/ + + +#ifndef __EDKII_GLUELIB_DXEDEPEX_H__ +#define __EDKII_GLUELIB_DXEDEPEX_H__ + + +// +// this file is used by .dxs file, just a place holder +// + + +#endif diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Include/EdkIIGlueBase.h b/EDK/Foundation/Library/EdkIIGlueLib/Include/EdkIIGlueBase.h new file mode 100644 index 0000000..d24c581 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Include/EdkIIGlueBase.h @@ -0,0 +1,98 @@ +/*++ + +Copyright (c) 2004 - 2011, 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: + + EdkIIGlueBase.h + +Abstract: + + Root include file for Base modules + +--*/ + +#ifndef __EDKII_GLUE_BASE_H__ +#define __EDKII_GLUE_BASE_H__ + +// +// Using this header means building with EdkIIGlueLib +// +#ifndef BUILD_WITH_EDKII_GLUE_LIB + #define BUILD_WITH_EDKII_GLUE_LIB +#endif + +#ifndef BUILD_WITH_GLUELIB + #define BUILD_WITH_GLUELIB +#endif + +// +// General Type & API definitions +// + +#include "EfiBind.h" +#include "EfiTypes.h" +#include "EfiError.h" +#include "Common\EdkIIGlueBaseTypes.h" +#include "EfiImage.h" +#include "EfiPeOptionalHeader.h" +#include "EfiStdArg.h" +#include "EfiDebug.h" +#include "EdkIIGlueProcessorBind.h" + +// +// Some Status Code data type definitions are in TianoSpecTypes.h in R8.5 +// +#if (TIANO_RELEASE_VERSION <= 0x00080005) +#include "TianoSpecTypes.h" +#endif +#include "EfiStatusCode.h" + +// +// R8.x Library headers used by EdkII Glue Libraries +// +#include "LinkedList.h" +#include "EfiCommonLib.h" + +#include "Common\EdkIIGlueDefinitionChangesBase.h" + +// +// EdkII Glue Library Class headers +// + +#include "Library\EdkIIGlueBaseLib.h" +#include "Library\EdkIIGlueBaseMemoryLib.h" +#include "Library\EdkIIGlueCacheMaintenanceLib.h" +#include "Library\EdkIIGlueIoLib.h" +#include "Library\EdkIIGluePciCf8Lib.h" +#include "Library\EdkIIGluePciExpressLib.h" +#include "Library\EdkIIGluePciLib.h" +#include "Library\EdkIIGluePeCoffGetEntryPointLib.h" +#include "Library\EdkIIGluePeCoffLib.h" +#include "Library\EdkIIGluePostCodeLib.h" +#include "Library\EdkIIGluePrintLib.h" +#include "Library\EdkIIGlueTimerLib.h" +#include "Library\EdkIIGlueUefiDecompressLib.h" +#include "Library\EdkIIGlueDebugLib.h" + +// +// Publish MDE Library PCDs +// +#include "Pcd\EdkIIGluePcdBaseLib.h" +#include "Pcd\EdkIIGluePcdDebugLib.h" +#include "Pcd\EdkIIGluePcdIoLib.h" +#include "Pcd\EdkIIGluePcdPciExpressLib.h" +#include "Pcd\EdkIIGluePcdPostCodeLib.h" +#include "Pcd\EdkIIGluePcdReportStatusCodeLib.h" +#include "Pcd\EdkIIGluePcdTimerLib.h" +#include "Pcd\EdkIIGluePcdPerformanceLib.h" + +#endif diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Include/EdkIIGlueConfig.h b/EDK/Foundation/Library/EdkIIGlueLib/Include/EdkIIGlueConfig.h new file mode 100644 index 0000000..5dabdff --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Include/EdkIIGlueConfig.h @@ -0,0 +1,173 @@ +/*++ + +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: + + EdkIIGlueConfig.h + +Abstract: + + Configurable items provided by GlueLib + +--*/ + +#ifndef __EDKII_GLUE_CONFIG_H__ +#define __EDKII_GLUE_CONFIG_H__ + +#include "EdkIIGlueProcessorBind.h" + +// +// Glue Library version +// +// 0x3000 - the 3rd release +// 0x5000 - support IPF. Jan, 2007 +// 0x6000 - support EBC. Feb, 2007 +// 0x7000 - size reduction, Jun, 2007 +// 0x7100 - backward compatibility supported, Jun, 2007 +// +// For reference only, don't change the value +// +#define EDKII_GLUE_LIBRARY_VERSION 0x7100 + + +// +// Check to make sure EFI_SPECIFICATION_VERSION and TIANO_RELEASE_VERSION are defined. +// +#if !defined(EFI_SPECIFICATION_VERSION) + #error EFI_SPECIFICATION_VERSION not defined +#elif !defined(TIANO_RELEASE_VERSION) + #error TIANO_RELEASE_VERSION not defined +#elif (TIANO_RELEASE_VERSION == 0) + #error TIANO_RELEASE_VERSION can not be zero +#endif + + +// +// Glue Library debug flag +// +// Controls debug ON/OFF of GlueLib itself, no +// effect on any other libraries or modules +// +// Values: +// FALSE : debug off +// any TRUE value : debug on +// +#define EDKII_GLUE_LIBRARY_DEBUG_ENABLE 0 + + +// +// max unicode string length +// +#define EDKII_GLUE_MaximumUnicodeStringLength 1000000 + +// +// max ascii string length +// +#define EDKII_GLUE_MaximumAsciiStringLength 1000000 + +// +// spin lock timeout +// +#define EDKII_GLUE_SpinLockTimeout 10000000 + +// +// max linked list length +// +#define EDKII_GLUE_MaximumLinkedListLength 1000000 + +// +// debug print level +// +#ifndef EDKII_GLUE_DebugPrintErrorLevel +#define EDKII_GLUE_DebugPrintErrorLevel EFI_D_ERROR +#endif + +// +// debug propery mask +// +#ifndef EDKII_GLUE_DebugPropertyMask +#define EDKII_GLUE_DebugPropertyMask ( DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED \ + | DEBUG_PROPERTY_DEBUG_PRINT_ENABLED \ + | DEBUG_PROPERTY_DEBUG_CODE_ENABLED \ + | DEBUG_PROPERTY_CLEAR_MEMORY_ENABLED \ + | DEBUG_PROPERTY_ASSERT_DEADLOOP_ENABLED \ + ) +#endif + +// +// clear memory value +// +#define EDKII_GLUE_DebugClearMemoryValue 0xAF + +// +// pci express base address +// +#ifndef EDKII_GLUE_PciExpressBaseAddress +#define EDKII_GLUE_PciExpressBaseAddress 0xE0000000 +#endif + +// +// +// This value is FSB Clock frequency. Its unit is Hz and its +// default value is 200000000, that means FSB frequency is 200Mhz. +// +#ifndef EDKII_GLUE_FSBClock +#define EDKII_GLUE_FSBClock 200000000 +#endif + +// +// This Value is MSR offset for platform information in hex +// +#ifndef EDKII_GLUE_PlatformInfoMsr +#define EDKII_GLUE_PlatformInfoMsr 0xCE +#endif + +// +// This Value is MSR offset for APIC Base in hex +// +#ifndef EDKII_GLUE_XAPICBaseMsr +#define EDKII_GLUE_XAPICBaseMsr 0x1B +#endif + +// +// This Value is MSR offset for EXT XAPIC Logical APIC ID in hex +// +#ifndef EDKII_GLUE_ExtXAPICLogicalAPICIdMsr +#define EDKII_GLUE_ExtXAPICLogicalAPICIdMsr 0x802 +#endif + +// +// post code property mask +// +#define EDKII_GLUE_PostCodePropertyMask ( POST_CODE_PROPERTY_POST_CODE_ENABLED \ + | POST_CODE_PROPERTY_POST_CODE_DESCRIPTION_ENABLED \ + ) + +// +// status code property mask +// +#define EDKII_GLUE_ReportStatusCodePropertyMask ( REPORT_STATUS_CODE_PROPERTY_PROGRESS_CODE_ENABLED \ + | REPORT_STATUS_CODE_PROPERTY_ERROR_CODE_ENABLED \ + | REPORT_STATUS_CODE_PROPERTY_DEBUG_CODE_ENABLED \ + ) + +// +// for IPF only +// The base address of IPF IO Block +// +#ifdef MDE_CPU_IPF +#ifndef EDKII_GLUE_IoBlockBaseAddressForIpf +#define EDKII_GLUE_IoBlockBaseAddressForIpf 0x0ffffc000000 +#endif +#endif + +#endif diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Include/EdkIIGlueDxe.h b/EDK/Foundation/Library/EdkIIGlueLib/Include/EdkIIGlueDxe.h new file mode 100644 index 0000000..2a631fc --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Include/EdkIIGlueDxe.h @@ -0,0 +1,256 @@ +/*++ + +Copyright (c) 2004 - 2011, 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: + + EdkIIGlueDxe.h + +Abstract: + + Root include file for DXE modules + +--*/ + +#ifndef __EDKII_GLUE_DXE_H__ +#define __EDKII_GLUE_DXE_H__ + + +// +// General Type & API definitions +// + +#include "Tiano.h" +#include "BootMode.h" +#include "EfiBootScript.h" +#include "EfiCapsule.h" +#include "EfiDependency.h" +#include "EfiImageFormat.h" +#include "EfiImage.h" +#include "EfiPeOptionalHeader.h" +#include "EfiFirmwareVolumeHeader.h" +#include "EfiFirmwareFileSystem.h" +#include "PeiHob.h" +#if (EFI_SPECIFICATION_VERSION >= 0x0002000A) +#include "TianoHii.h" +#else +#include "EfiInternalFormRepresentation.h" +#endif +#include "EfiStatusCode.h" + +// +// GUID definitions +// + +#if (EFI_SPECIFICATION_VERSION >= 0x00020000) +#include EFI_GUID_DEFINITION (EventGroup) +#include EFI_GUID_DEFINITION (EventLegacybios) +#include EFI_GUID_DEFINITION (FrameworkDevicePath) + +#include EFI_PROTOCOL_DEFINITION (EdidActive) +#include EFI_PROTOCOL_DEFINITION (EdidDiscovered) +#include EFI_PROTOCOL_DEFINITION (EdidOverride) +#include EFI_PROTOCOL_DEFINITION (GraphicsOutput) +#include EFI_PROTOCOL_DEFINITION (Hash) +#include EFI_PROTOCOL_DEFINITION (ScsiPassThruExt) +#include EFI_PROTOCOL_DEFINITION (TapeIo) +#endif + +#include EFI_GUID_DEFINITION (Acpi) +#include EFI_GUID_DEFINITION (AcpiTableStorage) +#include EFI_GUID_DEFINITION (Apriori) +#include EFI_GUID_DEFINITION (Capsule) +#include EFI_GUID_DEFINITION (DataHubRecords) +#include EFI_GUID_DEFINITION (DebugImageInfoTable) +#include EFI_GUID_DEFINITION (DxeServices) +#include EFI_GUID_DEFINITION (FirmwareFileSystem) +#include EFI_GUID_DEFINITION (GlobalVariable) +#include EFI_GUID_DEFINITION (Gpt) +#include EFI_GUID_DEFINITION (Hob) +#include EFI_GUID_DEFINITION (MemoryAllocationHob) +#include EFI_GUID_DEFINITION (Mps) +#include EFI_GUID_DEFINITION (PcAnsi) +#include EFI_GUID_DEFINITION (SalSystemTable) +#include EFI_GUID_DEFINITION (Smbios) +//#include EFI_GUID_DEFINITION (SmmCommunicate) +#include EFI_GUID_DEFINITION (SmramMemoryReserve) +// +// *** NOTE ***: StatusCodeDataTypeId definition differences need to be +// resolved when porting a module to real EDK II +// +#include EFI_GUID_DEFINITION (StatusCodeDataTypeId) + +// +// Protocol definitions +// +#if (EFI_SPECIFICATION_VERSION >= 0x0002000A) +#include EFI_PROTOCOL_DEFINITION (FormBrowser2) +#include EFI_PROTOCOL_DEFINITION (HiiConfigAccess) +#include EFI_PROTOCOL_DEFINITION (HiiConfigRouting) +#include EFI_PROTOCOL_DEFINITION (HiiDatabase) +#include EFI_PROTOCOL_DEFINITION (HiiFont) +#include EFI_PROTOCOL_DEFINITION (HiiImage) +#include EFI_PROTOCOL_DEFINITION (HiiString) +#endif + +#if (EFI_SPECIFICATION_VERSION >= 0x00020000) +#include EFI_PROTOCOL_DEFINITION (DevicePathFromText) +#include EFI_PROTOCOL_DEFINITION (DevicePathToText) +#include EFI_PROTOCOL_DEFINITION (DevicePathUtilities) +#include EFI_PROTOCOL_DEFINITION (Dhcp4) +#include EFI_PROTOCOL_DEFINITION (Ip4) +#include EFI_PROTOCOL_DEFINITION (Ip4Config) +#include EFI_PROTOCOL_DEFINITION (IScsiInitiatorName) +#include EFI_PROTOCOL_DEFINITION (UsbHostController) +#include EFI_PROTOCOL_DEFINITION (ManagedNetwork) +#include EFI_PROTOCOL_DEFINITION (Mtftp4) +#include EFI_PROTOCOL_DEFINITION (ServiceBinding) +#include EFI_PROTOCOL_DEFINITION (Tcp4) +#include EFI_PROTOCOL_DEFINITION (Udp4) +#include EFI_PROTOCOL_DEFINITION (Arp) +// check here: currently not implementated +//#include EFI_PROTOCOL_DEFINITION (AuthenticationInfo) +#endif + +#include EFI_PROTOCOL_DEFINITION (AcpiSupport) +#include EFI_PROTOCOL_DEFINITION (Bis) +#include EFI_PROTOCOL_DEFINITION (BlockIo) +#include EFI_PROTOCOL_DEFINITION (BootScriptSave) +#include EFI_PROTOCOL_DEFINITION (BusSpecificDriverOverride) +#include EFI_PROTOCOL_DEFINITION (ComponentName) +#if (EFI_SPECIFICATION_VERSION >= 0x00020000) +#include EFI_PROTOCOL_DEFINITION (ComponentName2) +#endif +#include EFI_PROTOCOL_DEFINITION (CpuIo) +#include EFI_PROTOCOL_DEFINITION (DataHub) +#include EFI_PROTOCOL_DEFINITION (DebugPort) +#include EFI_PROTOCOL_DEFINITION (DebugSupport) +#include EFI_PROTOCOL_DEFINITION (Decompress) +#include EFI_PROTOCOL_DEFINITION (DeviceIo) +#include EFI_PROTOCOL_DEFINITION (DevicePath) +#include EFI_PROTOCOL_DEFINITION (DiskIo) +#include EFI_PROTOCOL_DEFINITION (DriverBinding) +#include EFI_PROTOCOL_DEFINITION (DriverConfiguration) +#include EFI_PROTOCOL_DEFINITION (DriverDiagnostics) +#include EFI_PROTOCOL_DEFINITION (Ebc) +#include EFI_PROTOCOL_DEFINITION (EfiNetworkInterfaceIdentifier) +#include EFI_PROTOCOL_DEFINITION (FileInfo) +#include EFI_PROTOCOL_DEFINITION (FileSystemInfo) +#include EFI_PROTOCOL_DEFINITION (FileSystemVolumeLabelInfo) +#include EFI_PROTOCOL_DEFINITION (FirmwareVolume) +#include EFI_PROTOCOL_DEFINITION (FirmwareVolumeBlock) +#include EFI_PROTOCOL_DEFINITION (FirmwareVolumeDispatch) +#if (EFI_SPECIFICATION_VERSION < 0x0002000A) +#include EFI_PROTOCOL_DEFINITION (FormBrowser) +#include EFI_PROTOCOL_DEFINITION (FormCallback) +#endif +#include EFI_PROTOCOL_DEFINITION (GuidedSectionExtraction) +#if (EFI_SPECIFICATION_VERSION < 0x0002000A) +#include EFI_PROTOCOL_DEFINITION (Hii) +#endif +#include EFI_PROTOCOL_DEFINITION (IdeControllerInit) +#include EFI_PROTOCOL_DEFINITION (IncompatiblePciDeviceSupport) +#include EFI_PROTOCOL_DEFINITION (Legacy8259) +#include EFI_PROTOCOL_DEFINITION (LegacyBios) +#include EFI_PROTOCOL_DEFINITION (LegacyBiosPlatform) +#include EFI_PROTOCOL_DEFINITION (LegacyInterrupt) +#include EFI_PROTOCOL_DEFINITION (LegacyRegion) +#include EFI_PROTOCOL_DEFINITION (LoadedImage) +#include EFI_PROTOCOL_DEFINITION (LoadFile) +#include EFI_PROTOCOL_DEFINITION (PciHostBridgeResourceAllocation) +#include EFI_PROTOCOL_DEFINITION (PciHotplugInit) +#include EFI_PROTOCOL_DEFINITION (PciIo) +#include EFI_PROTOCOL_DEFINITION (PciPlatform) +#include EFI_PROTOCOL_DEFINITION (PciRootBridgeIo) +#include EFI_PROTOCOL_DEFINITION (PlatformDriverOverride) +#include EFI_PROTOCOL_DEFINITION (PxeBaseCode) +#include EFI_PROTOCOL_DEFINITION (PxeBaseCodeCallBack) +#include EFI_PROTOCOL_DEFINITION (ScsiIo) +#include EFI_PROTOCOL_DEFINITION (ScsiPassThru) +#include EFI_PROTOCOL_DEFINITION (SectionExtraction) +#include EFI_PROTOCOL_DEFINITION (SerialIo) +#include EFI_PROTOCOL_DEFINITION (SimpleFilesystem) +#include EFI_PROTOCOL_DEFINITION (SimpleNetwork) +#include EFI_PROTOCOL_DEFINITION (SimplePointer) +#include EFI_PROTOCOL_DEFINITION (SimpleTextIn) +#include EFI_PROTOCOL_DEFINITION (SimpleTextOut) +#include EFI_PROTOCOL_DEFINITION (Smbus) +#include EFI_PROTOCOL_DEFINITION (SmmAccess) +#include EFI_PROTOCOL_DEFINITION (SmmBase) +#include EFI_PROTOCOL_DEFINITION (SmmControl) +#include EFI_PROTOCOL_DEFINITION (SmmGpiDispatch) +#include EFI_PROTOCOL_DEFINITION (SmmIchnDispatch) +#include EFI_PROTOCOL_DEFINITION (SmmPeriodicTimerDispatch) +#include EFI_PROTOCOL_DEFINITION (SmmPowerButtonDispatch) +#include EFI_PROTOCOL_DEFINITION (SmmStandbyButtonDispatch) +#include EFI_PROTOCOL_DEFINITION (SmmStatusCode) +#include EFI_PROTOCOL_DEFINITION (SmmSwDispatch) +#include EFI_PROTOCOL_DEFINITION (SmmSxDispatch) +#include EFI_PROTOCOL_DEFINITION (SmmUsbDispatch) +#include EFI_PROTOCOL_DEFINITION (UgaDraw) +#include EFI_PROTOCOL_DEFINITION (UnicodeCollation) +#include EFI_PROTOCOL_DEFINITION (UsbHostController) +#include EFI_PROTOCOL_DEFINITION (UsbIo) +#include EFI_PROTOCOL_DEFINITION (SecurityPolicy) +#include EFI_PROTOCOL_DEFINITION (LoadPe32Image) + +// +// Arch Protocol definitions +// + +#include EFI_ARCH_PROTOCOL_DEFINITION (Bds) +#include EFI_ARCH_PROTOCOL_DEFINITION (Cpu) +#include EFI_ARCH_PROTOCOL_DEFINITION (Metronome) +#include EFI_ARCH_PROTOCOL_DEFINITION (Monotoniccounter) +#include EFI_ARCH_PROTOCOL_DEFINITION (RealTimeClock) +#include EFI_ARCH_PROTOCOL_DEFINITION (Reset) +#include EFI_ARCH_PROTOCOL_DEFINITION (Runtime) +#include EFI_ARCH_PROTOCOL_DEFINITION (Security) +#include EFI_ARCH_PROTOCOL_DEFINITION (StatusCode) +#include EFI_ARCH_PROTOCOL_DEFINITION (Timer) +#include EFI_ARCH_PROTOCOL_DEFINITION (Variable) +#include EFI_ARCH_PROTOCOL_DEFINITION (Variablewrite) +#include EFI_ARCH_PROTOCOL_DEFINITION (WatchdogTimer) + +// +// R8.x Library headers used by EdkII Glue Libraries +// +#include "EfiDriverLib.h" +#include "EfiCapsule.h" + +#include "Common\EdkIIGlueDefinitionChangesDxe.h" + + +// +// EdkII Glue Library Class headers +// + +#include "EdkIIGlueBase.h" +#include "Library\EdkIIGlueDebugLib.h" +#include "Library\EdkIIGluePostCodeLib.h" +#include "Library\EdkIIGlueReportStatusCodeLib.h" +#include "Library\EdkIIGlueHiiLib.h" +#include "Library\EdkIIGlueHobLib.h" +#include "Library\EdkIIGlueMemoryAllocationLib.h" +#include "Library\EdkIIGlueSmbusLib.h" +#include "Library\EdkIIGlueDxeRuntimeDriverLib.h" +#include "Library\EdkIIGlueDxeServicesTableLib.h" +#include "Library\EdkIIGlueDxeSmmDriverEntryPoint.h" +#include "Library\EdkIIGlueDevicePathLib.h" +#include "Library\EdkIIGlueUefiLib.h" +#include "Library\EdkIIGlueUefiDecompressLib.h" +#include "Library\EdkIIGlueUefiDriverModelLib.h" +#include "Library\EdkIIGlueUefiBootServicesTableLib.h" +#include "Library\EdkIIGlueUefiDriverEntryPoint.h" +#include "Library\EdkIIGlueUefiRuntimeServicesTableLib.h" +#include "Library\EdkIIGlueFirmwarePerformanceLib.h" + +#endif diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Include/EdkIIGlueInclude.cif b/EDK/Foundation/Library/EdkIIGlueLib/Include/EdkIIGlueInclude.cif new file mode 100644 index 0000000..f85ea5d --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Include/EdkIIGlueInclude.cif @@ -0,0 +1,64 @@ +<component> + name = "EdkIIGlueInclude" + category = ModulePart + LocalRoot = "EDK\Foundation\Library\EdkIIGlueLib\Include\" + RefName = "EdkIIGlueInclude" +[files] +"AutoGen.h" +"DxeDepex.h" +"EdkIIGlueBase.h" +"EdkIIGlueConfig.h" +"EdkIIGlueDxe.h" +"EdkIIGluePeim.h" +"EdkIIGlueUefi.h" +"PeimDepex.h" +"Common\EdkIIGlueBaseTypes.h" +"Common\EdkIIGlueDefinitionChangesBase.h" +"Common\EdkIIGlueDefinitionChangesDxe.h" +"Common\EdkIIGlueDefinitionChangesPeim.h" +"Common\EdkIIGlueDependencies.h" +"Ia32\EdkIIGlueProcessorBind.h" +"Library\EdkIIGlueBaseLib.h" +"Library\EdkIIGlueBaseMemoryLib.h" +"Library\EdkIIGlueCacheMaintenanceLib.h" +"Library\EdkIIGlueDebugLib.h" +"Library\EdkIIGlueDevicePathLib.h" +"Library\EdkIIGlueDxeRuntimeDriverLib.h" +"Library\EdkIIGlueDxeServicesTableLib.h" +"Library\EdkIIGlueDxeSmmDriverEntryPoint.h" +"Library\EdkIIGlueHiiLib.h" +"Library\EdkIIGlueHobLib.h" +"Library\EdkIIGlueIoLib.h" +"Library\EdkIIGlueMemoryAllocationLib.h" +"Library\EdkIIGluePciCf8Lib.h" +"Library\EdkIIGluePciExpressLib.h" +"Library\EdkIIGluePciLib.h" +"Library\EdkIIGluePeCoffGetEntryPointLib.h" +"Library\EdkIIGluePeCoffLib.h" +"Library\EdkIIGluePeimEntryPoint.h" +"Library\EdkIIGluePeiServicesLib.h" +"Library\EdkIIGluePeiServicesTablePointerLib.h" +"Library\EdkIIGluePostCodeLib.h" +"Library\EdkIIGluePrintLib.h" +"Library\EdkIIGlueReportStatusCodeLib.h" +"Library\EdkIIGlueResourcePublicationLib.h" +"Library\EdkIIGlueSmbusLib.h" +"Library\EdkIIGlueTimerLib.h" +"Library\EdkIIGlueUefiBootServicesTableLib.h" +"Library\EdkIIGlueUefiDecompressLib.h" +"Library\EdkIIGlueUefiDriverEntryPoint.h" +"Library\EdkIIGlueUefiDriverModelLib.h" +"Library\EdkIIGlueUefiLib.h" +"Library\EdkIIGlueUefiRuntimeServicesTableLib.h" +"Library\EdkIIGlueFirmwarePerformanceLib.h" +"Pcd\EdkIIGluePcd.h" +"Pcd\EdkIIGluePcdBaseLib.h" +"Pcd\EdkIIGluePcdDebugLib.h" +"Pcd\EdkIIGluePcdPciExpressLib.h" +"Pcd\EdkIIGluePcdPostCodeLib.h" +"Pcd\EdkIIGluePcdReportStatusCodeLib.h" +"x64\EdkIIGlueProcessorBind.h" +"Pcd\EdkIIGluePcdIoLib.h" +"Pcd\EdkIIGluePcdTimerLib.h" +"Pcd\EdkIIGluePcdPerformanceLib.h" +<endComponent> diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Include/EdkIIGluePeim.h b/EDK/Foundation/Library/EdkIIGlueLib/Include/EdkIIGluePeim.h new file mode 100644 index 0000000..a106568 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Include/EdkIIGluePeim.h @@ -0,0 +1,114 @@ +/*++ + +Copyright (c) 2004 - 2011, 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: + + EdkIIGluePeim.h + +Abstract: + + Root include file for PEI Modules + +**/ + + +#ifndef __EDKII_GLUE_PEIM_H__ +#define __EDKII_GLUE_PEIM_H__ + + +// +// Check to make sure TIANO_RELEASE_VERSION is defined +// +#if !defined(TIANO_RELEASE_VERSION) + #error TIANO_RELEASE_VERSION not defined +#elif (TIANO_RELEASE_VERSION == 0) + #error TIANO_RELEASE_VERSION can not be zero +#endif + +// +// General Type & API definitions +// + +#include "Pei.h" +#include "EfiBootScript.h" +#include "EfiImage.h" +#include "EfiPeOptionalHeader.h" +#include "EfiCapsule.h" +#include EFI_PROTOCOL_DEFINITION (DevicePath) +#include "TianoDevicePath.h" + +// +// GUID definitions +// + +#include EFI_GUID_DEFINITION (Apriori) +#include EFI_GUID_DEFINITION (Capsule) +#include EFI_GUID_DEFINITION (DxeServices) +#include EFI_GUID_DEFINITION (Hob) +#include EFI_GUID_DEFINITION (MemoryAllocationHob) +#include EFI_GUID_DEFINITION (FirmwareFileSystem) +#include EFI_GUID_DEFINITION (SmramMemoryReserve) +#include EFI_GUID_DEFINITION (DataHubRecords) +// +// *** NOTE ***: StatusCodeDataTypeId definition differences need to be +// resolved when porting a module to real EDK II +// +#include EFI_GUID_DEFINITION (StatusCodeDataTypeId) + +// +// Ppi definitions +// + +#include EFI_PPI_DEFINITION (BlockIo) +#include EFI_PPI_DEFINITION (BootInRecoveryMode) +#include EFI_PPI_DEFINITION (BootScriptExecuter) +#include EFI_PPI_DEFINITION (CpuIo) +#include EFI_PPI_DEFINITION (DeviceRecoveryModule) +#include EFI_PPI_DEFINITION (DxeIpl) +#include EFI_PPI_DEFINITION (EndOfPeiSignal) +#include EFI_PPI_DEFINITION (FindFv) +#include EFI_PPI_DEFINITION (LoadFile) +#include EFI_PPI_DEFINITION (BootMode) +#include EFI_PPI_DEFINITION (MemoryDiscovered) +#include EFI_PPI_DEFINITION (PciCfg) +#include EFI_PPI_DEFINITION (Variable) +#include EFI_PPI_DEFINITION (RecoveryModule) +#include EFI_PPI_DEFINITION (Reset) +#include EFI_PPI_DEFINITION (S3Resume) +#include EFI_PPI_DEFINITION (SecPlatforminformation) +#include EFI_PPI_DEFINITION (SectionExtraction) +#include EFI_PPI_DEFINITION (Security) +#include EFI_PPI_DEFINITION (Smbus) +#include EFI_PPI_DEFINITION (Stall) +#include EFI_PPI_DEFINITION (StatusCode) + + +#include "Common\EdkIIGlueDefinitionChangesPeim.h" + +// +// EdkII Glue Library Class headers +// + +#include "EdkIIGlueBase.h" +#include "Library\EdkIIGlueDebugLib.h" +#include "Library\EdkIIGluePostCodeLib.h" +#include "Library\EdkIIGlueReportStatusCodeLib.h" +#include "Library\EdkIIGlueHobLib.h" +#include "Library\EdkIIGlueMemoryAllocationLib.h" +#include "Library\EdkIIGlueSmbusLib.h" +#include "Library\EdkIIGluePeiServicesLib.h" +#include "Library\EdkIIGluePeiServicesTablePointerLib.h" +#include "Library\EdkIIGlueResourcePublicationLib.h" +#include "Library\EdkIIGluePeimEntryPoint.h" +#include "Library\EdkIIGlueFirmwarePerformanceLib.h" + +#endif diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Include/EdkIIGlueUefi.h b/EDK/Foundation/Library/EdkIIGlueLib/Include/EdkIIGlueUefi.h new file mode 100644 index 0000000..5ed0f1e --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Include/EdkIIGlueUefi.h @@ -0,0 +1,178 @@ +/*++ + +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: + + EdkIIGlueUefi.h + +Abstract: + + Root include file for UEFI modules. + +**/ + + +#ifndef __EDKII_GLUE_UEFI_H__ +#define __EDKII_GLUE_UEFI_H__ + + +// +// Check to make sure EFI_SPECIFICATION_VERSION and TIANO_RELEASE_VERSION are defined. +// also check for legal combinations +// +#if !defined(EFI_SPECIFICATION_VERSION) + #error EFI_SPECIFICATION_VERSION not defined +#elif !defined(TIANO_RELEASE_VERSION) + #error TIANO_RELEASE_VERSION not defined +#elif TIANO_RELEASE_VERSION == 0x00000000 + +// +// UEFI mode with no Tiano extensions is legal +// +#elif (TIANO_RELEASE_VERSION <= 0x00080005) && (EFI_SPECIFICATION_VERSION >= 0x00020000) + #error Illegal combination of EFI_SPECIFICATION_VERSION and EDK_RELEASE_VERSION versions +#endif + +// +// General Type & API definitions +// + +#include "EfiSpec.h" +#include "EfiPxe.h" + + +// +// Protocols from EFI 1.10 that got thier names fixed in UEFI 2.0 +// +#include EFI_PROTOCOL_DEFINITION(LoadedImage) +#include EFI_PROTOCOL_DEFINITION(SimpleTextIn) +#include EFI_PROTOCOL_DEFINITION(SimpleTextOut) +#include EFI_PROTOCOL_DEFINITION(SerialIo) +#include EFI_PROTOCOL_DEFINITION(LoadFile) +#include EFI_PROTOCOL_DEFINITION(SimpleFileSystem) +#include EFI_PROTOCOL_DEFINITION(DiskIo) +#include EFI_PROTOCOL_DEFINITION(BlockIo) +#include EFI_PROTOCOL_DEFINITION(UnicodeCollation) +#include EFI_PROTOCOL_DEFINITION(SimpleNetwork) +#include EFI_PROTOCOL_DEFINITION(EfiNetworkInterfaceIdentifier) +#include EFI_PROTOCOL_DEFINITION(PxeBaseCode) +#include EFI_PROTOCOL_DEFINITION(PxeBaseCodeCallBack) + +// +// EFI 1.10 Protocols +// +#include EFI_PROTOCOL_DEFINITION(Bis) +#include EFI_PROTOCOL_DEFINITION(BusSpecificDriverOverride) +#include EFI_PROTOCOL_DEFINITION(ComponentName) +#if (EFI_SPECIFICATION_VERSION >= 0x00020000) +#include EFI_PROTOCOL_DEFINITION (ComponentName2) +#endif +#include EFI_PROTOCOL_DEFINITION(DebugPort) +#include EFI_PROTOCOL_DEFINITION(DebugSupport) +#include EFI_PROTOCOL_DEFINITION(Decompress) +#include EFI_PROTOCOL_DEFINITION(DriverBinding) +#include EFI_PROTOCOL_DEFINITION(DriverConfiguration) +#include EFI_PROTOCOL_DEFINITION(DriverDiagnostics) +#include EFI_PROTOCOL_DEFINITION(Ebc) +#include EFI_PROTOCOL_DEFINITION(EfiNetworkInterfaceIdentifier) +#include EFI_PROTOCOL_DEFINITION(FileInfo) +#include EFI_PROTOCOL_DEFINITION(FileSystemInfo) +#include EFI_PROTOCOL_DEFINITION(FileSystemVolumeLabelInfo) +#include EFI_PROTOCOL_DEFINITION(PciIo) +#include EFI_PROTOCOL_DEFINITION(PciRootBridgeIo) +#include EFI_PROTOCOL_DEFINITION(PlatformDriverOverride) +#include EFI_PROTOCOL_DEFINITION(SimplePointer) +#include EFI_PROTOCOL_DEFINITION(ScsiPassThru) +#include EFI_PROTOCOL_DEFINITION(UsbIo) +#include EFI_PROTOCOL_DEFINITION(UsbHostController) +#include EFI_PROTOCOL_DEFINITION(UgaDraw) + +// +// EFI 1.10 GUIDs +// +#include EFI_GUID_DEFINITION(Acpi) +#include EFI_GUID_DEFINITION(DebugImageInfoTable) +#include EFI_GUID_DEFINITION(GlobalVariable) +#include EFI_GUID_DEFINITION(Gpt) +#include EFI_GUID_DEFINITION(PcAnsi) +#include EFI_GUID_DEFINITION(SmBios) +#include EFI_GUID_DEFINITION(SalSystemTable) + + +#if (EFI_SPECIFICATION_VERSION >= 0x00020000) +// +// UEFI 2.0 Protocols and GUIDs +// +// check here: currently not implementated +//#include EFI_PROTOCOL_DEFINITION(AuthenticationInfo) +#include EFI_PROTOCOL_DEFINITION(DevicePathUtilities) +#include EFI_PROTOCOL_DEFINITION(DevicePathToText) +#include EFI_PROTOCOL_DEFINITION(DevicePathFromText) +#include EFI_PROTOCOL_DEFINITION(GraphicsOutput) +#include EFI_PROTOCOL_DEFINITION(EdidDiscovered) +#include EFI_PROTOCOL_DEFINITION(EdidActive) +#include EFI_PROTOCOL_DEFINITION(EdidOverride) +#include EFI_PROTOCOL_DEFINITION(ScsiIo) +#include EFI_PROTOCOL_DEFINITION(ScsiPassThruExt) +#include EFI_PROTOCOL_DEFINITION(IScsiInitiatorName) +#include EFI_PROTOCOL_DEFINITION(UsbHostController) +#include EFI_PROTOCOL_DEFINITION(TapeIo) +#include EFI_PROTOCOL_DEFINITION(ManagedNetwork) +#include EFI_PROTOCOL_DEFINITION(Arp) +#include EFI_PROTOCOL_DEFINITION(Dhcp4) +#include EFI_PROTOCOL_DEFINITION(IP4) +#include EFI_PROTOCOL_DEFINITION(IP4Config) +#include EFI_PROTOCOL_DEFINITION(Tcp4) +#include EFI_PROTOCOL_DEFINITION(Udp4) +#include EFI_PROTOCOL_DEFINITION(Mtftp4) +#include EFI_PROTOCOL_DEFINITION(ServiceBinding) +#include EFI_PROTOCOL_DEFINITION(Hash) +#include EFI_GUID_DEFINITION(EventGroup) +//#include <Guid/WinCertificateUefi.h> +#endif + +#if (TIANO_RELEASE_VERSION > 0x00080005) +// +// Need due to R8.5 Tiano contamination of UEFI enumes. +// There is a UEFI library that does things the new way and the old way +// This is why these definitions are need in Uefi.h +// +#include EFI_GUID_DEFINITION (EventLegacyBios) +#include EFI_GUID_DEFINITION (FrameworkDevicePath) +#endif + +// +// R8.x Library headers used by EdkII Glue Libraries +// +#include "TianoSpecTypes.h" +#include "TianoSpecApi.h" +#include "TianoSpecDevicePath.h" +#include "EfiDriverLib.h" + +#include "Common\EdkIIGlueDefinitionChangesBase.h" + +// +// EdkII Glue Library Class headers +// + +#include "EdkIIGlueBase.h" +#include "Library\EdkIIGlueUefiDecompressLib.h" +#include "Library\EdkIIGlueDevicePathLib.h" +#include "Library\EdkIIGlueUefiBootServicesTableLib.h" +#include "Library\EdkIIGlueUefiDriverEntryPoint.h" +#include "Library\EdkIIGlueUefiDriverModelLib.h" +#include "Library\EdkIIGlueUefiLib.h" +#include "Library\EdkIIGlueUefiRuntimeServicesTableLib.h" + +extern UINT8 _gEdkIIGlueDriverModelProtocolSelection; + +#endif diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Include/Ia32/EdkIIGlueProcessorBind.h b/EDK/Foundation/Library/EdkIIGlueLib/Include/Ia32/EdkIIGlueProcessorBind.h new file mode 100644 index 0000000..55a1e96 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Include/Ia32/EdkIIGlueProcessorBind.h @@ -0,0 +1,41 @@ +/*++ + +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: + + EdkIIGlueProcessorBind.h + +Abstract: + + Processor specific definitions + +--*/ + +#ifndef __EDKII_GLUE_PROCESSOR_BIND_H__ +#define __EDKII_GLUE_PROCESSOR_BIND_H__ + +// +// The Microsoft* C compiler can removed references to unreferenced data items +// if the /OPT:REF linker option is used. We defined a macro as this is a +// a non standard extension +// +#if _MSC_EXTENSIONS + #define GLOBAL_REMOVE_IF_UNREFERENCED __declspec(selectany) +#else + #define GLOBAL_REMOVE_IF_UNREFERENCED +#endif + +#ifndef MDE_CPU_IA32 + #define MDE_CPU_IA32 +#endif + +#endif diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueBaseLib.h b/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueBaseLib.h new file mode 100644 index 0000000..7eadcf0 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueBaseLib.h @@ -0,0 +1,5109 @@ +/*++ + +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: + + EdkIIGlueBaseLib.h + +Abstract: + + Memory-only library functions with no library constructor/destructor + +--*/ + +#ifndef __EDKII_GLUE_BASE_LIB_H__ +#define __EDKII_GLUE_BASE_LIB_H__ + + +// +// String Functions +// +#define StrCpy(_Dest, _Source) GlueStrCpy(_Dest, _Source) +#define StrnCpy(_Dest, _Source, _Length) GlueStrnCpy(_Dest, _Source, _Length) +#define StrLen(_String) GlueStrLen(_String) +#define StrSize(_String) GlueStrSize(_String) +#define StrCmp(_FristString, _SecondString) GlueStrCmp(_FristString, _SecondString) +#define StrnCmp(_FirstString, _SecondString, _Length) GlueStrnCmp(_FirstString, _SecondString, _Length) +#define StrCat(_Dest, _Source) GlueStrCat(_Dest, _Source) +#define StrnCat(_Dest, _Source, _Length) GlueStrnCat(_Dest, _Source, _Length) + +// +// Linked List +// +#define InitializeListHead(_ListHead) GlueInitializeListHead(_ListHead) +#define InsertHeadList(_ListHead, _Entry ) GlueInsertHeadList(_ListHead, _Entry) +#define InsertTailList(_ListHead, _Entry) GlueInsertTailList(_ListHead, _Entry) +#define GetFirstNode(_List) GlueGetFirstNode(_List) +#define GetNextNode(_List, _Node) GlueGetNextNode(_List, _Node) +#define IsListEmpty(_ListHead) GlueIsListEmpty(_ListHead) +#define IsNull(_List, _Node) GlueIsNull(_List, _Node) +#define IsNodeAtEnd(_List, _Node) GlueIsNodeAtEnd(_List, _Node) +#define SwapListEntries(_FirstEntry, _SecondEntry) GlueSwapListEntries(_FirstEntry, _SecondEntry) +#define RemoveEntryList(_Entry) GlueRemoveEntryList(_Entry) + +// +// Math Functions +// +#define LShiftU64(_Op, _Count) GlueLShiftU64(_Op, _Count) +#define RShiftU64(_Op, _Count) GlueRShiftU64(_Op, _Count) +#define MultU64x32(_Multiplicand, _Multiplier) GlueMultU64x32(_Multiplicand, _Multiplier) +#define DivU64x32(_Dividend, _Divisor) GlueDivU64x32(_Dividend, _Divisor) + +// +// Others +// +#define GetInterruptState() GlueGetInterruptState() + + +// +// Definitions for architecture specific types +// These include SPIN_LOCK and BASE_LIBRARY_JUMP_BUFFER +// + +// +// SPIN_LOCK +// +typedef VOLATILE UINTN SPIN_LOCK; + +#if defined (MDE_CPU_IA32) +// +// IA32 context buffer used by SetJump() and LongJump() +// +typedef struct { + UINT32 Ebx; + UINT32 Esi; + UINT32 Edi; + UINT32 Ebp; + UINT32 Esp; + UINT32 Eip; +} BASE_LIBRARY_JUMP_BUFFER; + +#elif defined (MDE_CPU_IPF) +// +// IPF context buffer used by SetJump() and LongJump() +// +typedef struct { + UINT64 F2[2]; + UINT64 F3[2]; + UINT64 F4[2]; + UINT64 F5[2]; + UINT64 F16[2]; + UINT64 F17[2]; + UINT64 F18[2]; + UINT64 F19[2]; + UINT64 F20[2]; + UINT64 F21[2]; + UINT64 F22[2]; + UINT64 F23[2]; + UINT64 F24[2]; + UINT64 F25[2]; + UINT64 F26[2]; + UINT64 F27[2]; + UINT64 F28[2]; + UINT64 F29[2]; + UINT64 F30[2]; + UINT64 F31[2]; + UINT64 R4; + UINT64 R5; + UINT64 R6; + UINT64 R7; + UINT64 SP; + UINT64 BR0; + UINT64 BR1; + UINT64 BR2; + UINT64 BR3; + UINT64 BR4; + UINT64 BR5; + UINT64 InitialUNAT; + UINT64 AfterSpillUNAT; + UINT64 PFS; + UINT64 BSP; + UINT64 Predicates; + UINT64 LoopCount; + UINT64 FPSR; +} BASE_LIBRARY_JUMP_BUFFER; + +#elif defined (MDE_CPU_X64) +// +// X64 context buffer used by SetJump() and LongJump() +// +typedef struct { + UINT64 Rbx; + UINT64 Rsp; + UINT64 Rbp; + UINT64 Rdi; + UINT64 Rsi; + UINT64 R12; + UINT64 R13; + UINT64 R14; + UINT64 R15; + UINT64 Rip; +} BASE_LIBRARY_JUMP_BUFFER; + +#elif defined (MDE_CPU_EBC) +// +// EBC context buffer used by SetJump() and LongJump() +// +typedef struct { + UINT64 R0; + UINT64 R1; + UINT64 R2; + UINT64 R3; + UINT64 IP; +} BASE_LIBRARY_JUMP_BUFFER; + +#else +#error Unknown Processor Type +#endif + +// +// String Services +// + +/** + Copies one Null-terminated Unicode string to another Null-terminated Unicode + string and returns the new Unicode string. + + This function copies the contents of the Unicode string Source to the Unicode + string Destination, and returns Destination. If Source and Destination + overlap, then the results are undefined. + + If Destination is NULL, then ASSERT(). + If Source is NULL, then ASSERT(). + If Source and Destination overlap, then ASSERT(). + If PcdMaximumUnicodeStringLength is not zero, and Source contains more than + PcdMaximumUnicodeStringLength Unicode characters not including the + Null-terminator, then ASSERT(). + + @param Destination Pointer to a Null-terminated Unicode string. + @param Source Pointer to a Null-terminated Unicode string. + + @return Destiantion + +**/ +CHAR16 * +EFIAPI +GlueStrCpy ( + OUT CHAR16 *Destination, + IN CONST CHAR16 *Source + ); +/** + Copies one Null-terminated Unicode string with a maximum length to another + Null-terminated Unicode string with a maximum length and returns the new + Unicode string. + + This function copies the contents of the Unicode string Source to the Unicode + string Destination, and returns Destination. At most, Length Unicode + characters are copied from Source to Destination. If Length is 0, then + Destination is returned unmodified. If Length is greater that the number of + Unicode characters in Source, then Destination is padded with Null Unicode + characters. If Source and Destination overlap, then the results are + undefined. + + If Destination is NULL, then ASSERT(). + If Source is NULL, then ASSERT(). + If Source and Destination overlap, then ASSERT(). + If PcdMaximumUnicodeStringLength is not zero, and Source contains more than + PcdMaximumUnicodeStringLength Unicode characters not including the + Null-terminator, then ASSERT(). + + @param Destination Pointer to a Null-terminated Unicode string. + @param Source Pointer to a Null-terminated Unicode string. + @param Length Maximum number of Unicode characters to copy. + + @return Destination + +**/ +CHAR16 * +EFIAPI +GlueStrnCpy ( + OUT CHAR16 *Destination, + IN CONST CHAR16 *Source, + IN UINTN Length + ); +/** + Returns the length of a Null-terminated Unicode string. + + This function returns the number of Unicode characters in the Null-terminated + Unicode string specified by String. + + If String is NULL, then ASSERT(). + If PcdMaximumUnicodeStringLength is not zero, and String contains more than + PcdMaximumUnicodeStringLength Unicode characters not including the + Null-terminator, then ASSERT(). + + @param String Pointer to a Null-terminated Unicode string. + + @return The length of String. + +**/ +UINTN +EFIAPI +GlueStrLen ( + IN CONST CHAR16 *String + ); +/** + Returns the size of a Null-terminated Unicode string in bytes, including the + Null terminator. + + This function returns the size, in bytes, of the Null-terminated Unicode + string specified by String. + + If String is NULL, then ASSERT(). + If PcdMaximumUnicodeStringLength is not zero, and String contains more than + PcdMaximumUnicodeStringLength Unicode characters not including the + Null-terminator, then ASSERT(). + + @param String Pointer to a Null-terminated Unicode string. + + @return The size of String. + +**/ +UINTN +EFIAPI +GlueStrSize ( + IN CONST CHAR16 *String + ); +/** + Compares two Null-terminated Unicode strings, and returns the difference + between the first mismatched Unicode characters. + + This function compares the Null-terminated Unicode string FirstString to the + Null-terminated Unicode string SecondString. If FirstString is identical to + SecondString, then 0 is returned. Otherwise, the value returned is the first + mismatched Unicode character in SecondString subtracted from the first + mismatched Unicode character in FirstString. + + If FirstString is NULL, then ASSERT(). + If SecondString is NULL, then ASSERT(). + If PcdMaximumUnicodeStringLength is not zero, and FirstString contains more + than PcdMaximumUnicodeStringLength Unicode characters not including the + Null-terminator, then ASSERT(). + If PcdMaximumUnicodeStringLength is not zero, and SecondString contains more + than PcdMaximumUnicodeStringLength Unicode characters not including the + Null-terminator, then ASSERT(). + + @param FirstString Pointer to a Null-terminated Unicode string. + @param SecondString Pointer to a Null-terminated Unicode string. + + @retval 0 FirstString is identical to SecondString. + @retval !=0 FirstString is not identical to SecondString. + +**/ +INTN +EFIAPI +GlueStrCmp ( + IN CONST CHAR16 *FirstString, + IN CONST CHAR16 *SecondString + ); +/** + Compares two Null-terminated Unicode strings with maximum lengths, and + returns the difference between the first mismatched Unicode characters. + + This function compares the Null-terminated Unicode string FirstString to the + Null-terminated Unicode string SecondString. At most, Length Unicode + characters will be compared. If Length is 0, then 0 is returned. If + FirstString is identical to SecondString, then 0 is returned. Otherwise, the + value returned is the first mismatched Unicode character in SecondString + subtracted from the first mismatched Unicode character in FirstString. + + If FirstString is NULL, then ASSERT(). + If SecondString is NULL, then ASSERT(). + If PcdMaximumUnicodeStringLength is not zero, and FirstString contains more + than PcdMaximumUnicodeStringLength Unicode characters not including the + Null-terminator, then ASSERT(). + If PcdMaximumUnicodeStringLength is not zero, and SecondString contains more + than PcdMaximumUnicodeStringLength Unicode characters not including the + Null-terminator, then ASSERT(). + + @param FirstString Pointer to a Null-terminated Unicode string. + @param SecondString Pointer to a Null-terminated Unicode string. + @param Length Maximum number of Unicode characters to compare. + + @retval 0 FirstString is identical to SecondString. + @retval !=0 FirstString is not identical to SecondString. + +**/ +INTN +EFIAPI +GlueStrnCmp ( + IN CONST CHAR16 *FirstString, + IN CONST CHAR16 *SecondString, + IN UINTN Length + ); +/** + Concatenates one Null-terminated Unicode string to another Null-terminated + Unicode string, and returns the concatenated Unicode string. + + This function concatenates two Null-terminated Unicode strings. The contents + of Null-terminated Unicode string Source are concatenated to the end of + Null-terminated Unicode string Destination. The Null-terminated concatenated + Unicode String is returned. If Source and Destination overlap, then the + results are undefined. + + If Destination is NULL, then ASSERT(). + If Source is NULL, then ASSERT(). + If Source and Destination overlap, then ASSERT(). + If PcdMaximumUnicodeStringLength is not zero, and Destination contains more + than PcdMaximumUnicodeStringLength Unicode characters not including the + Null-terminator, then ASSERT(). + If PcdMaximumUnicodeStringLength is not zero, and Source contains more than + PcdMaximumUnicodeStringLength Unicode characters not including the + Null-terminator, then ASSERT(). + If PcdMaximumUnicodeStringLength is not zero, and concatenating Destination + and Source results in a Unicode string with more than + PcdMaximumUnicodeStringLength Unicode characters not including the + Null-terminator, then ASSERT(). + + @param Destination Pointer to a Null-terminated Unicode string. + @param Source Pointer to a Null-terminated Unicode string. + + @return Destination + +**/ +CHAR16 * +EFIAPI +GlueStrCat ( + IN OUT CHAR16 *Destination, + IN CONST CHAR16 *Source + ); +/** + Concatenates one Null-terminated Unicode string with a maximum length to the + end of another Null-terminated Unicode string, and returns the concatenated + Unicode string. + + This function concatenates two Null-terminated Unicode strings. The contents + of Null-terminated Unicode string Source are concatenated to the end of + Null-terminated Unicode string Destination, and Destination is returned. At + most, Length Unicode characters are concatenated from Source to the end of + Destination, and Destination is always Null-terminated. If Length is 0, then + Destination is returned unmodified. If Source and Destination overlap, then + the results are undefined. + + If Destination is NULL, then ASSERT(). + If Source is NULL, then ASSERT(). + If Source and Destination overlap, then ASSERT(). + If PcdMaximumUnicodeStringLength is not zero, and Destination contains more + than PcdMaximumUnicodeStringLength Unicode characters not including the + Null-terminator, then ASSERT(). + If PcdMaximumUnicodeStringLength is not zero, and Source contains more than + PcdMaximumUnicodeStringLength Unicode characters not including the + Null-terminator, then ASSERT(). + If PcdMaximumUnicodeStringLength is not zero, and concatenating Destination + and Source results in a Unicode string with more than + PcdMaximumUnicodeStringLength Unicode characters not including the + Null-terminator, then ASSERT(). + + @param Destination Pointer to a Null-terminated Unicode string. + @param Source Pointer to a Null-terminated Unicode string. + @param Length Maximum number of Unicode characters to concatenate from + Source. + + @return Destination + +**/ +CHAR16 * +EFIAPI +GlueStrnCat ( + IN OUT CHAR16 *Destination, + IN CONST CHAR16 *Source, + IN UINTN Length + ); + +//;;## ...AMI_OVERRIDE... Support Unicode Str To Ascii Str start. +/** + Convert one Null-terminated Unicode string to a Null-terminated + ASCII string and returns the ASCII string. + + This function converts the content of the Unicode string Source + to the ASCII string Destination by copying the lower 8 bits of + each Unicode character. It returns Destination. + + If any Unicode characters in Source contain non-zero value in + the upper 8 bits, then ASSERT(). + + If Destination is NULL, then ASSERT(). + If Source is NULL, then ASSERT(). + If Source is not aligned on a 16-bit boundary, then ASSERT(). + If Source and Destination overlap, then ASSERT(). + + If PcdMaximumUnicodeStringLength is not zero, and Source contains + more than PcdMaximumUnicodeStringLength Unicode characters not including + the Null-terminator, then ASSERT(). + + If PcdMaximumAsciiStringLength is not zero, and Source contains more + than PcdMaximumAsciiStringLength Unicode characters not including the + Null-terminator, then ASSERT(). + + @param Source Pointer to a Null-terminated Unicode string. + @param Destination Pointer to a Null-terminated ASCII string. + + @reture Destination + +**/ +CHAR8 * +EFIAPI +UnicodeStrToAsciiStr ( + IN CONST CHAR16 *Source, + OUT CHAR8 *Destination + ); +//;;## ...AMI_OVERRIDE... Support Unicode Str To Ascii Str end. + +/** + Copies one Null-terminated ASCII string to another Null-terminated ASCII + string and returns the new ASCII string. + + This function copies the contents of the ASCII string Source to the ASCII + string Destination, and returns Destination. If Source and Destination + overlap, then the results are undefined. + + If Destination is NULL, then ASSERT(). + If Source is NULL, then ASSERT(). + If Source and Destination overlap, then ASSERT(). + If PcdMaximumAsciiStringLength is not zero and Source contains more than + PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, + then ASSERT(). + + @param Destination Pointer to a Null-terminated ASCII string. + @param Source Pointer to a Null-terminated ASCII string. + + @return Destination + +**/ +CHAR8 * +EFIAPI +AsciiStrCpy ( + OUT CHAR8 *Destination, + IN CONST CHAR8 *Source + ); +/** + Copies one Null-terminated ASCII string with a maximum length to another + Null-terminated ASCII string with a maximum length and returns the new ASCII + string. + + This function copies the contents of the ASCII string Source to the ASCII + string Destination, and returns Destination. At most, Length ASCII characters + are copied from Source to Destination. If Length is 0, then Destination is + returned unmodified. If Length is greater that the number of ASCII characters + in Source, then Destination is padded with Null ASCII characters. If Source + and Destination overlap, then the results are undefined. + + If Destination is NULL, then ASSERT(). + If Source is NULL, then ASSERT(). + If Source and Destination overlap, then ASSERT(). + If PcdMaximumAsciiStringLength is not zero, and Source contains more than + PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, + then ASSERT(). + + @param Destination Pointer to a Null-terminated ASCII string. + @param Source Pointer to a Null-terminated ASCII string. + @param Length Maximum number of ASCII characters to copy. + + @return Destination + +**/ +CHAR8 * +EFIAPI +AsciiStrnCpy ( + OUT CHAR8 *Destination, + IN CONST CHAR8 *Source, + IN UINTN Length + ); +/** + Returns the length of a Null-terminated ASCII string. + + This function returns the number of ASCII characters in the Null-terminated + ASCII string specified by String. + + If String is NULL, then ASSERT(). + If PcdMaximumAsciiStringLength is not zero and String contains more than + PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, + then ASSERT(). + + @param String Pointer to a Null-terminated ASCII string. + + @return The length of String. + +**/ +UINTN +EFIAPI +AsciiStrLen ( + IN CONST CHAR8 *String + ); +/** + Returns the size of a Null-terminated ASCII string in bytes, including the + Null terminator. + + This function returns the size, in bytes, of the Null-terminated ASCII string + specified by String. + + If String is NULL, then ASSERT(). + If PcdMaximumAsciiStringLength is not zero and String contains more than + PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, + then ASSERT(). + + @param String Pointer to a Null-terminated ASCII string. + + @return The size of String. + +**/ +UINTN +EFIAPI +AsciiStrSize ( + IN CONST CHAR8 *String + ); +/** + Compares two Null-terminated ASCII strings, and returns the difference + between the first mismatched ASCII characters. + + This function compares the Null-terminated ASCII string FirstString to the + Null-terminated ASCII string SecondString. If FirstString is identical to + SecondString, then 0 is returned. Otherwise, the value returned is the first + mismatched ASCII character in SecondString subtracted from the first + mismatched ASCII character in FirstString. + + If FirstString is NULL, then ASSERT(). + If SecondString is NULL, then ASSERT(). + If PcdMaximumAsciiStringLength is not zero and FirstString contains more than + PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, + then ASSERT(). + If PcdMaximumAsciiStringLength is not zero and SecondString contains more + than PcdMaximumAsciiStringLength ASCII characters not including the + Null-terminator, then ASSERT(). + + @param FirstString Pointer to a Null-terminated ASCII string. + @param SecondString Pointer to a Null-terminated ASCII string. + + @retval 0 FirstString is identical to SecondString. + @retval !=0 FirstString is not identical to SecondString. + +**/ +INTN +EFIAPI +AsciiStrCmp ( + IN CONST CHAR8 *FirstString, + IN CONST CHAR8 *SecondString + ); +/** + Performs a case insensitive comparison of two Null-terminated ASCII strings, + and returns the difference between the first mismatched ASCII characters. + + This function performs a case insensitive comparison of the Null-terminated + ASCII string FirstString to the Null-terminated ASCII string SecondString. If + FirstString is identical to SecondString, then 0 is returned. Otherwise, the + value returned is the first mismatched lower case ASCII character in + SecondString subtracted from the first mismatched lower case ASCII character + in FirstString. + + If FirstString is NULL, then ASSERT(). + If SecondString is NULL, then ASSERT(). + If PcdMaximumAsciiStringLength is not zero and FirstString contains more than + PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, + then ASSERT(). + If PcdMaximumAsciiStringLength is not zero and SecondString contains more + than PcdMaximumAsciiStringLength ASCII characters not including the + Null-terminator, then ASSERT(). + + @param FirstString Pointer to a Null-terminated ASCII string. + @param SecondString Pointer to a Null-terminated ASCII string. + + @retval 0 FirstString is identical to SecondString using case insensitive + comparisons. + @retval !=0 FirstString is not identical to SecondString using case + insensitive comparisons. + +**/ +INTN +EFIAPI +AsciiStriCmp ( + IN CONST CHAR8 *FirstString, + IN CONST CHAR8 *SecondString + ); +/** + Compares two Null-terminated ASCII strings with maximum lengths, and returns + the difference between the first mismatched ASCII characters. + + This function compares the Null-terminated ASCII string FirstString to the + Null-terminated ASCII string SecondString. At most, Length ASCII characters + will be compared. If Length is 0, then 0 is returned. If FirstString is + identical to SecondString, then 0 is returned. Otherwise, the value returned + is the first mismatched ASCII character in SecondString subtracted from the + first mismatched ASCII character in FirstString. + + If FirstString is NULL, then ASSERT(). + If SecondString is NULL, then ASSERT(). + If PcdMaximumAsciiStringLength is not zero and FirstString contains more than + PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, + then ASSERT(). + If PcdMaximumAsciiStringLength is not zero and SecondString contains more than + PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, + then ASSERT(). + + @param FirstString Pointer to a Null-terminated ASCII string. + @param SecondString Pointer to a Null-terminated ASCII string. + + @retval 0 FirstString is identical to SecondString. + @retval !=0 FirstString is not identical to SecondString. + +**/ +INTN +EFIAPI +AsciiStrnCmp ( + IN CONST CHAR8 *FirstString, + IN CONST CHAR8 *SecondString, + IN UINTN Length + ); +/** + Concatenates one Null-terminated ASCII string to another Null-terminated + ASCII string, and returns the concatenated ASCII string. + + This function concatenates two Null-terminated ASCII strings. The contents of + Null-terminated ASCII string Source are concatenated to the end of Null- + terminated ASCII string Destination. The Null-terminated concatenated ASCII + String is returned. + + If Destination is NULL, then ASSERT(). + If Source is NULL, then ASSERT(). + If PcdMaximumAsciiStringLength is not zero and Destination contains more than + PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, + then ASSERT(). + If PcdMaximumAsciiStringLength is not zero and Source contains more than + PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, + then ASSERT(). + If PcdMaximumAsciiStringLength is not zero and concatenating Destination and + Source results in a ASCII string with more than PcdMaximumAsciiStringLength + ASCII characters, then ASSERT(). + + @param Destination Pointer to a Null-terminated ASCII string. + @param Source Pointer to a Null-terminated ASCII string. + + @return Destination + +**/ +CHAR8 * +EFIAPI +AsciiStrCat ( + IN OUT CHAR8 *Destination, + IN CONST CHAR8 *Source + ); +/** + Concatenates one Null-terminated ASCII string with a maximum length to the + end of another Null-terminated ASCII string, and returns the concatenated + ASCII string. + + This function concatenates two Null-terminated ASCII strings. The contents + of Null-terminated ASCII string Source are concatenated to the end of Null- + terminated ASCII string Destination, and Destination is returned. At most, + Length ASCII characters are concatenated from Source to the end of + Destination, and Destination is always Null-terminated. If Length is 0, then + Destination is returned unmodified. If Source and Destination overlap, then + the results are undefined. + + If Destination is NULL, then ASSERT(). + If Source is NULL, then ASSERT(). + If Source and Destination overlap, then ASSERT(). + If PcdMaximumAsciiStringLength is not zero, and Destination contains more than + PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, + then ASSERT(). + If PcdMaximumAsciiStringLength is not zero, and Source contains more than + PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, + then ASSERT(). + If PcdMaximumAsciiStringLength is not zero, and concatenating Destination and + Source results in a ASCII string with more than PcdMaximumAsciiStringLength + ASCII characters not including the Null-terminator, then ASSERT(). + + @param Destination Pointer to a Null-terminated ASCII string. + @param Source Pointer to a Null-terminated ASCII string. + @param Length Maximum number of ASCII characters to concatenate from + Source. + + @return Destination + +**/ +CHAR8 * +EFIAPI +AsciiStrnCat ( + IN OUT CHAR8 *Destination, + IN CONST CHAR8 *Source, + IN UINTN Length + ); +/** + Converts an 8-bit value to an 8-bit BCD value. + + Converts the 8-bit value specified by Value to BCD. The BCD value is + returned. + + If Value >= 100, then ASSERT(). + + @param Value The 8-bit value to convert to BCD. Range 0..99. + + @return The BCD value + +**/ +UINT8 +EFIAPI +DecimalToBcd8 ( + IN UINT8 Value + ); + +/** + Converts an 8-bit BCD value to an 8-bit value. + + Converts the 8-bit BCD value specified by Value to an 8-bit value. The 8-bit + value is returned. + + If Value >= 0xA0, then ASSERT(). + If (Value & 0x0F) >= 0x0A, then ASSERT(). + + @param Value The 8-bit BCD value to convert to an 8-bit value. + + @return The 8-bit value is returned. + +**/ +UINT8 +EFIAPI +BcdToDecimal8 ( + IN UINT8 Value + ); + +// +// LIST_ENTRY definition +// +typedef struct _LIST_ENTRY LIST_ENTRY; + +struct _LIST_ENTRY { + LIST_ENTRY *ForwardLink; + LIST_ENTRY *BackLink; +}; + +// +// Linked List Functions and Macros +// + +/** + Initializes the head node of a doubly linked list that is declared as a + global variable in a module. + + Initializes the forward and backward links of a new linked list. After + initializing a linked list with this macro, the other linked list functions + may be used to add and remove nodes from the linked list. This macro results + in smaller executables by initializing the linked list in the data section, + instead if calling the InitializeListHead() function to perform the + equivalent operation. + + @param ListHead The head note of a list to initiailize. + +**/ +#define INITIALIZE_LIST_HEAD_VARIABLE(ListHead) {&ListHead, &ListHead} + +/** + Initializes the head node of a doubly linked list, and returns the pointer to + the head node of the doubly linked list. + + Initializes the forward and backward links of a new linked list. After + initializing a linked list with this function, the other linked list + functions may be used to add and remove nodes from the linked list. It is up + to the caller of this function to allocate the memory for ListHead. + + If ListHead is NULL, then ASSERT(). + + @param ListHead A pointer to the head node of a new doubly linked list. + + @return ListHead + +**/ +LIST_ENTRY * +EFIAPI +GlueInitializeListHead ( + IN LIST_ENTRY *ListHead + ); + +/** + Adds a node to the beginning of a doubly linked list, and returns the pointer + to the head node of the doubly linked list. + + Adds the node Entry at the beginning of the doubly linked list denoted by + ListHead, and returns ListHead. + + If ListHead is NULL, then ASSERT(). + If Entry is NULL, then ASSERT(). + If ListHead was not initialized with InitializeListHead(), then ASSERT(). + If PcdMaximumLinkedListLenth is not zero, and prior to insertion the number + of nodes in ListHead, including the ListHead node, is greater than or + equal to PcdMaximumLinkedListLength, then ASSERT(). + + @param ListHead A pointer to the head node of a doubly linked list. + @param Entry A pointer to a node that is to be inserted at the beginning + of a doubly linked list. + + @return ListHead + +**/ +LIST_ENTRY * +EFIAPI +GlueInsertHeadList ( + IN LIST_ENTRY *ListHead, + IN LIST_ENTRY *Entry + ); + +/** + Adds a node to the end of a doubly linked list, and returns the pointer to + the head node of the doubly linked list. + + Adds the node Entry to the end of the doubly linked list denoted by ListHead, + and returns ListHead. + + If ListHead is NULL, then ASSERT(). + If Entry is NULL, then ASSERT(). + If ListHead was not initialized with InitializeListHead(), then ASSERT(). + If PcdMaximumLinkedListLenth is not zero, and prior to insertion the number + of nodes in ListHead, including the ListHead node, is greater than or + equal to PcdMaximumLinkedListLength, then ASSERT(). + + @param ListHead A pointer to the head node of a doubly linked list. + @param Entry A pointer to a node that is to be added at the end of the + doubly linked list. + + @return ListHead + +**/ +LIST_ENTRY * +EFIAPI +GlueInsertTailList ( + IN LIST_ENTRY *ListHead, + IN LIST_ENTRY *Entry + ); + +/** + Retrieves the first node of a doubly linked list. + + Returns the first node of a doubly linked list. List must have been + initialized with InitializeListHead(). If List is empty, then NULL is + returned. + + If List is NULL, then ASSERT(). + If List was not initialized with InitializeListHead(), then ASSERT(). + If PcdMaximumLinkedListLenth is not zero, and the number of nodes + in List, including the List node, is greater than or equal to + PcdMaximumLinkedListLength, then ASSERT(). + + @param List A pointer to the head node of a doubly linked list. + + @return The first node of a doubly linked list. + @retval NULL The list is empty. + +**/ +LIST_ENTRY * +EFIAPI +GlueGetFirstNode ( + IN CONST LIST_ENTRY *List + ); + +/** + Retrieves the next node of a doubly linked list. + + Returns the node of a doubly linked list that follows Node. List must have + been initialized with InitializeListHead(). If List is empty, then List is + returned. + + If List is NULL, then ASSERT(). + If Node is NULL, then ASSERT(). + If List was not initialized with InitializeListHead(), then ASSERT(). + If PcdMaximumLinkedListLenth is not zero, and List contains more than + PcdMaximumLinkedListLenth nodes, then ASSERT(). + If Node is not a node in List, then ASSERT(). + + @param List A pointer to the head node of a doubly linked list. + @param Node A pointer to a node in the doubly linked list. + + @return Pointer to the next node if one exists. Otherwise a null value which + is actually List is returned. + +**/ +LIST_ENTRY * +EFIAPI +GlueGetNextNode ( + IN CONST LIST_ENTRY *List, + IN CONST LIST_ENTRY *Node + ); + +/** + Checks to see if a doubly linked list is empty or not. + + Checks to see if the doubly linked list is empty. If the linked list contains + zero nodes, this function returns TRUE. Otherwise, it returns FALSE. + + If ListHead is NULL, then ASSERT(). + If ListHead was not initialized with InitializeListHead(), then ASSERT(). + If PcdMaximumLinkedListLenth is not zero, and the number of nodes + in List, including the List node, is greater than or equal to + PcdMaximumLinkedListLength, then ASSERT(). + + @param ListHead A pointer to the head node of a doubly linked list. + + @retval TRUE The linked list is empty. + @retval FALSE The linked list is not empty. + +**/ +BOOLEAN +EFIAPI +GlueIsListEmpty ( + IN CONST LIST_ENTRY *ListHead + ); + +/** + Determines if a node in a doubly linked list is null. + + Returns FALSE if Node is one of the nodes in the doubly linked list specified + by List. Otherwise, TRUE is returned. List must have been initialized with + InitializeListHead(). + + If List is NULL, then ASSERT(). + If Node is NULL, then ASSERT(). + If List was not initialized with InitializeListHead(), then ASSERT(). + If PcdMaximumLinkedListLenth is not zero, and the number of nodes + in List, including the List node, is greater than or equal to + PcdMaximumLinkedListLength, then ASSERT(). + If Node is not a node in List and Node is not equal to List, then ASSERT(). + + @param List A pointer to the head node of a doubly linked list. + @param Node A pointer to a node in the doubly linked list. + + @retval TRUE Node is one of the nodes in the doubly linked list. + @retval FALSE Node is not one of the nodes in the doubly linked list. + +**/ +BOOLEAN +EFIAPI +GlueIsNull ( + IN CONST LIST_ENTRY *List, + IN CONST LIST_ENTRY *Node + ); + +/** + Determines if a node the last node in a doubly linked list. + + Returns TRUE if Node is the last node in the doubly linked list specified by + List. Otherwise, FALSE is returned. List must have been initialized with + InitializeListHead(). + + If List is NULL, then ASSERT(). + If Node is NULL, then ASSERT(). + If List was not initialized with InitializeListHead(), then ASSERT(). + If PcdMaximumLinkedListLenth is not zero, and the number of nodes + in List, including the List node, is greater than or equal to + PcdMaximumLinkedListLength, then ASSERT(). + If Node is not a node in List, then ASSERT(). + + @param List A pointer to the head node of a doubly linked list. + @param Node A pointer to a node in the doubly linked list. + + @retval TRUE Node is the last node in the linked list. + @retval FALSE Node is not the last node in the linked list. + +**/ +BOOLEAN +EFIAPI +GlueIsNodeAtEnd ( + IN CONST LIST_ENTRY *List, + IN CONST LIST_ENTRY *Node + ); + +/** + Swaps the location of two nodes in a doubly linked list, and returns the + first node after the swap. + + If FirstEntry is identical to SecondEntry, then SecondEntry is returned. + Otherwise, the location of the FirstEntry node is swapped with the location + of the SecondEntry node in a doubly linked list. SecondEntry must be in the + same double linked list as FirstEntry and that double linked list must have + been initialized with InitializeListHead(). SecondEntry is returned after the + nodes are swapped. + + If FirstEntry is NULL, then ASSERT(). + If SecondEntry is NULL, then ASSERT(). + If SecondEntry and FirstEntry are not in the same linked list, then ASSERT(). + If PcdMaximumLinkedListLength is not zero, and the number of nodes in the + linked list containing the FirstEntry and SecondEntry nodes, including + the FirstEntry and SecondEntry nodes, is greater than or equal to + PcdMaximumLinkedListLength, then ASSERT(). + + @param FirstEntry A pointer to a node in a linked list. + @param SecondEntry A pointer to another node in the same linked list. + +**/ +LIST_ENTRY * +EFIAPI +GlueSwapListEntries ( + IN LIST_ENTRY *FirstEntry, + IN LIST_ENTRY *SecondEntry + ); + +/** + Removes a node from a doubly linked list, and returns the node that follows + the removed node. + + Removes the node Entry from a doubly linked list. It is up to the caller of + this function to release the memory used by this node if that is required. On + exit, the node following Entry in the doubly linked list is returned. If + Entry is the only node in the linked list, then the head node of the linked + list is returned. + + If Entry is NULL, then ASSERT(). + If Entry is the head node of an empty list, then ASSERT(). + If PcdMaximumLinkedListLength is not zero, and the number of nodes in the + linked list containing Entry, including the Entry node, is greater than + or equal to PcdMaximumLinkedListLength, then ASSERT(). + + @param Entry A pointer to a node in a linked list + + @return Entry + +**/ +LIST_ENTRY * +EFIAPI +GlueRemoveEntryList ( + IN CONST LIST_ENTRY *Entry + ); + +// +// Math Services +// + +/** + Shifts a 64-bit integer left between 0 and 63 bits. The low bits are filled + with zeros. The shifted value is returned. + + This function shifts the 64-bit value Operand to the left by Count bits. The + low Count bits are set to zero. The shifted value is returned. + + If Count is greater than 63, then ASSERT(). + + @param Operand The 64-bit operand to shift left. + @param Count The number of bits to shift left. + + @return Operand << Count + +**/ +UINT64 +EFIAPI +GlueLShiftU64 ( + IN UINT64 Operand, + IN UINTN Count + ); + +/** + Shifts a 64-bit integer right between 0 and 63 bits. This high bits are + filled with zeros. The shifted value is returned. + + This function shifts the 64-bit value Operand to the right by Count bits. The + high Count bits are set to zero. The shifted value is returned. + + If Count is greater than 63, then ASSERT(). + + @param Operand The 64-bit operand to shift right. + @param Count The number of bits to shift right. + + @return Operand >> Count + +**/ +UINT64 +EFIAPI +GlueRShiftU64 ( + IN UINT64 Operand, + IN UINTN Count + ); + +/** + Shifts a 64-bit integer right between 0 and 63 bits. The high bits are filled + with original integer's bit 63. The shifted value is returned. + + This function shifts the 64-bit value Operand to the right by Count bits. The + high Count bits are set to bit 63 of Operand. The shifted value is returned. + + If Count is greater than 63, then ASSERT(). + + @param Operand The 64-bit operand to shift right. + @param Count The number of bits to shift right. + + @return Operand >> Count + +**/ +UINT64 +EFIAPI +ARShiftU64 ( + IN UINT64 Operand, + IN UINTN Count + ); + +/** + Rotates a 32-bit integer left between 0 and 31 bits, filling the low bits + with the high bits that were rotated. + + This function rotates the 32-bit value Operand to the left by Count bits. The + low Count bits are fill with the high Count bits of Operand. The rotated + value is returned. + + If Count is greater than 31, then ASSERT(). + + @param Operand The 32-bit operand to rotate left. + @param Count The number of bits to rotate left. + + @return Operand <<< Count + +**/ +UINT32 +EFIAPI +LRotU32 ( + IN UINT32 Operand, + IN UINTN Count + ); + +/** + Rotates a 32-bit integer right between 0 and 31 bits, filling the high bits + with the low bits that were rotated. + + This function rotates the 32-bit value Operand to the right by Count bits. + The high Count bits are fill with the low Count bits of Operand. The rotated + value is returned. + + If Count is greater than 31, then ASSERT(). + + @param Operand The 32-bit operand to rotate right. + @param Count The number of bits to rotate right. + + @return Operand >>> Count + +**/ +UINT32 +EFIAPI +RRotU32 ( + IN UINT32 Operand, + IN UINTN Count + ); + +/** + Rotates a 64-bit integer left between 0 and 63 bits, filling the low bits + with the high bits that were rotated. + + This function rotates the 64-bit value Operand to the left by Count bits. The + low Count bits are fill with the high Count bits of Operand. The rotated + value is returned. + + If Count is greater than 63, then ASSERT(). + + @param Operand The 64-bit operand to rotate left. + @param Count The number of bits to rotate left. + + @return Operand <<< Count + +**/ +UINT64 +EFIAPI +LRotU64 ( + IN UINT64 Operand, + IN UINTN Count + ); + +/** + Rotates a 64-bit integer right between 0 and 63 bits, filling the high bits + with the high low bits that were rotated. + + This function rotates the 64-bit value Operand to the right by Count bits. + The high Count bits are fill with the low Count bits of Operand. The rotated + value is returned. + + If Count is greater than 63, then ASSERT(). + + @param Operand The 64-bit operand to rotate right. + @param Count The number of bits to rotate right. + + @return Operand >>> Count + +**/ +UINT64 +EFIAPI +RRotU64 ( + IN UINT64 Operand, + IN UINTN Count + ); + +/** + Returns the bit position of the lowest bit set in a 32-bit value. + + This function computes the bit position of the lowest bit set in the 32-bit + value specified by Operand. If Operand is zero, then -1 is returned. + Otherwise, a value between 0 and 31 is returned. + + @param Operand The 32-bit operand to evaluate. + + @return Position of the lowest bit set in Operand if found. + @retval -1 Operand is zero. + +**/ +INTN +EFIAPI +LowBitSet32 ( + IN UINT32 Operand + ); + +/** + Returns the bit position of the lowest bit set in a 64-bit value. + + This function computes the bit position of the lowest bit set in the 64-bit + value specified by Operand. If Operand is zero, then -1 is returned. + Otherwise, a value between 0 and 63 is returned. + + @param Operand The 64-bit operand to evaluate. + + @return Position of the lowest bit set in Operand if found. + @retval -1 Operand is zero. + +**/ +INTN +EFIAPI +LowBitSet64 ( + IN UINT64 Operand + ); + +/** + Returns the bit position of the highest bit set in a 32-bit value. Equivalent + to log2(x). + + This function computes the bit position of the highest bit set in the 32-bit + value specified by Operand. If Operand is zero, then -1 is returned. + Otherwise, a value between 0 and 31 is returned. + + @param Operand The 32-bit operand to evaluate. + + @return Position of the highest bit set in Operand if found. + @retval -1 Operand is zero. + +**/ +INTN +EFIAPI +HighBitSet32 ( + IN UINT32 Operand + ); + +/** + Returns the bit position of the highest bit set in a 64-bit value. Equivalent + to log2(x). + + This function computes the bit position of the highest bit set in the 64-bit + value specified by Operand. If Operand is zero, then -1 is returned. + Otherwise, a value between 0 and 63 is returned. + + @param Operand The 64-bit operand to evaluate. + + @return Position of the highest bit set in Operand if found. + @retval -1 Operand is zero. + +**/ +INTN +EFIAPI +HighBitSet64 ( + IN UINT64 Operand + ); + +/** + Returns the value of the highest bit set in a 32-bit value. Equivalent to + 1 << HighBitSet32(x). + + This function computes the value of the highest bit set in the 32-bit value + specified by Operand. If Operand is zero, then zero is returned. + + @param Operand The 32-bit operand to evaluate. + + @return 1 << HighBitSet32(Operand) + @retval 0 Operand is zero. + +**/ +UINT32 +EFIAPI +GetPowerOfTwo32 ( + IN UINT32 Operand + ); + +/** + Returns the value of the highest bit set in a 64-bit value. Equivalent to + 1 << HighBitSet64(x). + + This function computes the value of the highest bit set in the 64-bit value + specified by Operand. If Operand is zero, then zero is returned. + + @param Operand The 64-bit operand to evaluate. + + @return 1 << HighBitSet64(Operand) + @retval 0 Operand is zero. + +**/ +UINT64 +EFIAPI +GetPowerOfTwo64 ( + IN UINT64 Operand + ); + +/** + Switches the endianess of a 16-bit integer. + + This function swaps the bytes in a 16-bit unsigned value to switch the value + from little endian to big endian or vice versa. The byte swapped value is + returned. + + @param Operand A 16-bit unsigned value. + + @return The byte swaped Operand. + +**/ +UINT16 +EFIAPI +SwapBytes16 ( + IN UINT16 Value + ); + +/** + Switches the endianess of a 32-bit integer. + + This function swaps the bytes in a 32-bit unsigned value to switch the value + from little endian to big endian or vice versa. The byte swapped value is + returned. + + @param Operand A 32-bit unsigned value. + + @return The byte swaped Operand. + +**/ +UINT32 +EFIAPI +SwapBytes32 ( + IN UINT32 Value + ); + +/** + Switches the endianess of a 64-bit integer. + + This function swaps the bytes in a 64-bit unsigned value to switch the value + from little endian to big endian or vice versa. The byte swapped value is + returned. + + @param Operand A 64-bit unsigned value. + + @return The byte swaped Operand. + +**/ +UINT64 +EFIAPI +SwapBytes64 ( + IN UINT64 Value + ); + +/** + Multiples a 64-bit unsigned integer by a 32-bit unsigned integer and + generates a 64-bit unsigned result. + + This function multiples the 64-bit unsigned value Multiplicand by the 32-bit + unsigned value Multiplier and generates a 64-bit unsigned result. This 64- + bit unsigned result is returned. + + If the result overflows, then ASSERT(). + + @param Multiplicand A 64-bit unsigned value. + @param Multiplier A 32-bit unsigned value. + + @return Multiplicand * Multiplier + +**/ +UINT64 +EFIAPI +GlueMultU64x32 ( + IN UINT64 Multiplicand, + IN UINT32 Multiplier + ); + +/** + Multiples a 64-bit unsigned integer by a 64-bit unsigned integer and + generates a 64-bit unsigned result. + + This function multiples the 64-bit unsigned value Multiplicand by the 64-bit + unsigned value Multiplier and generates a 64-bit unsigned result. This 64- + bit unsigned result is returned. + + If the result overflows, then ASSERT(). + + @param Multiplicand A 64-bit unsigned value. + @param Multiplier A 64-bit unsigned value. + + @return Multiplicand * Multiplier + +**/ +UINT64 +EFIAPI +MultU64x64 ( + IN UINT64 Multiplicand, + IN UINT64 Multiplier + ); + +/** + Multiples a 64-bit signed integer by a 64-bit signed integer and generates a + 64-bit signed result. + + This function multiples the 64-bit signed value Multiplicand by the 64-bit + signed value Multiplier and generates a 64-bit signed result. This 64-bit + signed result is returned. + + If the result overflows, then ASSERT(). + + @param Multiplicand A 64-bit signed value. + @param Multiplier A 64-bit signed value. + + @return Multiplicand * Multiplier + +**/ +INT64 +EFIAPI +MultS64x64 ( + IN INT64 Multiplicand, + IN INT64 Multiplier + ); + +/** + Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates + a 64-bit unsigned result. + + This function divides the 64-bit unsigned value Dividend by the 32-bit + unsigned value Divisor and generates a 64-bit unsigned quotient. This + function returns the 64-bit unsigned quotient. + + If Divisor is 0, then ASSERT(). + + @param Dividend A 64-bit unsigned value. + @param Divisor A 32-bit unsigned value. + + @return Dividend / Divisor + +**/ +UINT64 +EFIAPI +GlueDivU64x32 ( + IN UINT64 Dividend, + IN UINT32 Divisor + ); + +/** + Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates + a 32-bit unsigned remainder. + + This function divides the 64-bit unsigned value Dividend by the 32-bit + unsigned value Divisor and generates a 32-bit remainder. This function + returns the 32-bit unsigned remainder. + + If Divisor is 0, then ASSERT(). + + @param Dividend A 64-bit unsigned value. + @param Divisor A 32-bit unsigned value. + + @return Dividend % Divisor + +**/ +UINT32 +EFIAPI +ModU64x32 ( + IN UINT64 Dividend, + IN UINT32 Divisor + ); + +/** + Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates + a 64-bit unsigned result and an optional 32-bit unsigned remainder. + + This function divides the 64-bit unsigned value Dividend by the 32-bit + unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder + is not NULL, then the 32-bit unsigned remainder is returned in Remainder. + This function returns the 64-bit unsigned quotient. + + If Divisor is 0, then ASSERT(). + + @param Dividend A 64-bit unsigned value. + @param Divisor A 32-bit unsigned value. + @param Remainder A pointer to a 32-bit unsigned value. This parameter is + optional and may be NULL. + + @return Dividend / Divisor + +**/ +UINT64 +EFIAPI +DivU64x32Remainder ( + IN UINT64 Dividend, + IN UINT32 Divisor, + OUT UINT32 *Remainder OPTIONAL + ); + +/** + Divides a 64-bit unsigned integer by a 64-bit unsigned integer and generates + a 64-bit unsigned result and an optional 64-bit unsigned remainder. + + This function divides the 64-bit unsigned value Dividend by the 64-bit + unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder + is not NULL, then the 64-bit unsigned remainder is returned in Remainder. + This function returns the 64-bit unsigned quotient. + + If Divisor is 0, then ASSERT(). + + @param Dividend A 64-bit unsigned value. + @param Divisor A 64-bit unsigned value. + @param Remainder A pointer to a 64-bit unsigned value. This parameter is + optional and may be NULL. + + @return Dividend / Divisor + +**/ +UINT64 +EFIAPI +DivU64x64Remainder ( + IN UINT64 Dividend, + IN UINT64 Divisor, + OUT UINT64 *Remainder OPTIONAL + ); + +/** + Divides a 64-bit signed integer by a 64-bit signed integer and generates a + 64-bit signed result and a optional 64-bit signed remainder. + + This function divides the 64-bit signed value Dividend by the 64-bit signed + value Divisor and generates a 64-bit signed quotient. If Remainder is not + NULL, then the 64-bit signed remainder is returned in Remainder. This + function returns the 64-bit signed quotient. + + If Divisor is 0, then ASSERT(). + + @param Dividend A 64-bit signed value. + @param Divisor A 64-bit signed value. + @param Remainder A pointer to a 64-bit signed value. This parameter is + optional and may be NULL. + + @return Dividend / Divisor + +**/ +INT64 +EFIAPI +DivS64x64Remainder ( + IN INT64 Dividend, + IN INT64 Divisor, + OUT INT64 *Remainder OPTIONAL + ); + +/** + Reads a 16-bit value from memory that may be unaligned. + + This function returns the 16-bit value pointed to by Buffer. The function + guarantees that the read operation does not produce an alignment fault. + + If the Buffer is NULL, then ASSERT(). + + @param Buffer Pointer to a 16-bit value that may be unaligned. + + @return *Uint16 + +**/ +UINT16 +EFIAPI +ReadUnaligned16 ( + IN CONST UINT16 *Uint16 + ); + +/** + Writes a 16-bit value to memory that may be unaligned. + + This function writes the 16-bit value specified by Value to Buffer. Value is + returned. The function guarantees that the write operation does not produce + an alignment fault. + + If the Buffer is NULL, then ASSERT(). + + @param Buffer Pointer to a 16-bit value that may be unaligned. + @param Value 16-bit value to write to Buffer. + + @return Value + +**/ +UINT16 +EFIAPI +WriteUnaligned16 ( + OUT UINT16 *Uint16, + IN UINT16 Value + ); + +/** + Reads a 24-bit value from memory that may be unaligned. + + This function returns the 24-bit value pointed to by Buffer. The function + guarantees that the read operation does not produce an alignment fault. + + If the Buffer is NULL, then ASSERT(). + + @param Buffer Pointer to a 24-bit value that may be unaligned. + + @return The value read. + +**/ +UINT32 +EFIAPI +ReadUnaligned24 ( + IN CONST UINT32 *Buffer + ); + +/** + Writes a 24-bit value to memory that may be unaligned. + + This function writes the 24-bit value specified by Value to Buffer. Value is + returned. The function guarantees that the write operation does not produce + an alignment fault. + + If the Buffer is NULL, then ASSERT(). + + @param Buffer Pointer to a 24-bit value that may be unaligned. + @param Value 24-bit value to write to Buffer. + + @return The value written. + +**/ +UINT32 +EFIAPI +WriteUnaligned24 ( + OUT UINT32 *Buffer, + IN UINT32 Value + ); + +/** + Reads a 32-bit value from memory that may be unaligned. + + This function returns the 32-bit value pointed to by Buffer. The function + guarantees that the read operation does not produce an alignment fault. + + If the Buffer is NULL, then ASSERT(). + + @param Buffer Pointer to a 32-bit value that may be unaligned. + + @return *Uint32 + +**/ +UINT32 +EFIAPI +ReadUnaligned32 ( + IN CONST UINT32 *Uint32 + ); + +/** + Writes a 32-bit value to memory that may be unaligned. + + This function writes the 32-bit value specified by Value to Buffer. Value is + returned. The function guarantees that the write operation does not produce + an alignment fault. + + If the Buffer is NULL, then ASSERT(). + + @param Buffer Pointer to a 32-bit value that may be unaligned. + @param Value 32-bit value to write to Buffer. + + @return Value + +**/ +UINT32 +EFIAPI +WriteUnaligned32 ( + OUT UINT32 *Uint32, + IN UINT32 Value + ); + +/** + Reads a 64-bit value from memory that may be unaligned. + + This function returns the 64-bit value pointed to by Buffer. The function + guarantees that the read operation does not produce an alignment fault. + + If the Buffer is NULL, then ASSERT(). + + @param Buffer Pointer to a 64-bit value that may be unaligned. + + @return *Uint64 + +**/ +UINT64 +EFIAPI +ReadUnaligned64 ( + IN CONST UINT64 *Uint64 + ); + +/** + Writes a 64-bit value to memory that may be unaligned. + + This function writes the 64-bit value specified by Value to Buffer. Value is + returned. The function guarantees that the write operation does not produce + an alignment fault. + + If the Buffer is NULL, then ASSERT(). + + @param Buffer Pointer to a 64-bit value that may be unaligned. + @param Value 64-bit value to write to Buffer. + + @return Value + +**/ +UINT64 +EFIAPI +WriteUnaligned64 ( + OUT UINT64 *Uint64, + IN UINT64 Value + ); + +// +// Bit Field Functions +// + +/** + Returns a bit field from an 8-bit value. + + Returns the bitfield specified by the StartBit and the EndBit from Operand. + + If 8-bit operations are not supported, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Operand Operand on which to perform the bitfield operation. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..7. + + @return The bit field read. + +**/ +UINT8 +EFIAPI +BitFieldRead8 ( + IN UINT8 Operand, + IN UINTN StartBit, + IN UINTN EndBit + ); + +/** + Writes a bit field to an 8-bit value, and returns the result. + + Writes Value to the bit field specified by the StartBit and the EndBit in + Operand. All other bits in Operand are preserved. The new 8-bit value is + returned. + + If 8-bit operations are not supported, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Operand Operand on which to perform the bitfield operation. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..7. + @param Value New value of the bit field. + + @return The new 8-bit value. + +**/ +UINT8 +EFIAPI +BitFieldWrite8 ( + IN UINT8 Operand, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT8 Value + ); + +/** + Reads a bit field from an 8-bit value, performs a bitwise OR, and returns the + result. + + Performs a bitwise inclusive OR between the bit field specified by StartBit + and EndBit in Operand and the value specified by OrData. All other bits in + Operand are preserved. The new 8-bit value is returned. + + If 8-bit operations are not supported, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Operand Operand on which to perform the bitfield operation. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..7. + @param OrData The value to OR with the read value from the value + + @return The new 8-bit value. + +**/ +UINT8 +EFIAPI +BitFieldOr8 ( + IN UINT8 Operand, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT8 OrData + ); + +/** + Reads a bit field from an 8-bit value, performs a bitwise AND, and returns + the result. + + Performs a bitwise AND between the bit field specified by StartBit and EndBit + in Operand and the value specified by AndData. All other bits in Operand are + preserved. The new 8-bit value is returned. + + If 8-bit operations are not supported, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Operand Operand on which to perform the bitfield operation. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..7. + @param AndData The value to AND with the read value from the value. + + @return The new 8-bit value. + +**/ +UINT8 +EFIAPI +BitFieldAnd8 ( + IN UINT8 Operand, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT8 AndData + ); + +/** + Reads a bit field from an 8-bit value, performs a bitwise AND followed by a + bitwise OR, and returns the result. + + Performs a bitwise AND between the bit field specified by StartBit and EndBit + in Operand and the value specified by AndData, followed by a bitwise + inclusive OR with value specified by OrData. All other bits in Operand are + preserved. The new 8-bit value is returned. + + If 8-bit operations are not supported, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Operand Operand on which to perform the bitfield operation. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..7. + @param AndData The value to AND with the read value from the value. + @param OrData The value to OR with the result of the AND operation. + + @return The new 8-bit value. + +**/ +UINT8 +EFIAPI +BitFieldAndThenOr8 ( + IN UINT8 Operand, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT8 AndData, + IN UINT8 OrData + ); + +/** + Returns a bit field from a 16-bit value. + + Returns the bitfield specified by the StartBit and the EndBit from Operand. + + If 16-bit operations are not supported, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Operand Operand on which to perform the bitfield operation. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..15. + + @return The bit field read. + +**/ +UINT16 +EFIAPI +BitFieldRead16 ( + IN UINT16 Operand, + IN UINTN StartBit, + IN UINTN EndBit + ); + +/** + Writes a bit field to a 16-bit value, and returns the result. + + Writes Value to the bit field specified by the StartBit and the EndBit in + Operand. All other bits in Operand are preserved. The new 16-bit value is + returned. + + If 16-bit operations are not supported, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Operand Operand on which to perform the bitfield operation. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..15. + @param Value New value of the bit field. + + @return The new 16-bit value. + +**/ +UINT16 +EFIAPI +BitFieldWrite16 ( + IN UINT16 Operand, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT16 Value + ); + +/** + Reads a bit field from a 16-bit value, performs a bitwise OR, and returns the + result. + + Performs a bitwise inclusive OR between the bit field specified by StartBit + and EndBit in Operand and the value specified by OrData. All other bits in + Operand are preserved. The new 16-bit value is returned. + + If 16-bit operations are not supported, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Operand Operand on which to perform the bitfield operation. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..15. + @param OrData The value to OR with the read value from the value + + @return The new 16-bit value. + +**/ +UINT16 +EFIAPI +BitFieldOr16 ( + IN UINT16 Operand, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT16 OrData + ); + +/** + Reads a bit field from a 16-bit value, performs a bitwise AND, and returns + the result. + + Performs a bitwise AND between the bit field specified by StartBit and EndBit + in Operand and the value specified by AndData. All other bits in Operand are + preserved. The new 16-bit value is returned. + + If 16-bit operations are not supported, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Operand Operand on which to perform the bitfield operation. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..15. + @param AndData The value to AND with the read value from the value + + @return The new 16-bit value. + +**/ +UINT16 +EFIAPI +BitFieldAnd16 ( + IN UINT16 Operand, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT16 AndData + ); + +/** + Reads a bit field from a 16-bit value, performs a bitwise AND followed by a + bitwise OR, and returns the result. + + Performs a bitwise AND between the bit field specified by StartBit and EndBit + in Operand and the value specified by AndData, followed by a bitwise + inclusive OR with value specified by OrData. All other bits in Operand are + preserved. The new 16-bit value is returned. + + If 16-bit operations are not supported, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Operand Operand on which to perform the bitfield operation. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..15. + @param AndData The value to AND with the read value from the value. + @param OrData The value to OR with the result of the AND operation. + + @return The new 16-bit value. + +**/ +UINT16 +EFIAPI +BitFieldAndThenOr16 ( + IN UINT16 Operand, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT16 AndData, + IN UINT16 OrData + ); + +/** + Returns a bit field from a 32-bit value. + + Returns the bitfield specified by the StartBit and the EndBit from Operand. + + If 32-bit operations are not supported, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Operand Operand on which to perform the bitfield operation. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + + @return The bit field read. + +**/ +UINT32 +EFIAPI +BitFieldRead32 ( + IN UINT32 Operand, + IN UINTN StartBit, + IN UINTN EndBit + ); + +/** + Writes a bit field to a 32-bit value, and returns the result. + + Writes Value to the bit field specified by the StartBit and the EndBit in + Operand. All other bits in Operand are preserved. The new 32-bit value is + returned. + + If 32-bit operations are not supported, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Operand Operand on which to perform the bitfield operation. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + @param Value New value of the bit field. + + @return The new 32-bit value. + +**/ +UINT32 +EFIAPI +BitFieldWrite32 ( + IN UINT32 Operand, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT32 Value + ); + +/** + Reads a bit field from a 32-bit value, performs a bitwise OR, and returns the + result. + + Performs a bitwise inclusive OR between the bit field specified by StartBit + and EndBit in Operand and the value specified by OrData. All other bits in + Operand are preserved. The new 32-bit value is returned. + + If 32-bit operations are not supported, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Operand Operand on which to perform the bitfield operation. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + @param OrData The value to OR with the read value from the value + + @return The new 32-bit value. + +**/ +UINT32 +EFIAPI +BitFieldOr32 ( + IN UINT32 Operand, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT32 OrData + ); + +/** + Reads a bit field from a 32-bit value, performs a bitwise AND, and returns + the result. + + Performs a bitwise AND between the bit field specified by StartBit and EndBit + in Operand and the value specified by AndData. All other bits in Operand are + preserved. The new 32-bit value is returned. + + If 32-bit operations are not supported, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Operand Operand on which to perform the bitfield operation. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + @param AndData The value to AND with the read value from the value + + @return The new 32-bit value. + +**/ +UINT32 +EFIAPI +BitFieldAnd32 ( + IN UINT32 Operand, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT32 AndData + ); + +/** + Reads a bit field from a 32-bit value, performs a bitwise AND followed by a + bitwise OR, and returns the result. + + Performs a bitwise AND between the bit field specified by StartBit and EndBit + in Operand and the value specified by AndData, followed by a bitwise + inclusive OR with value specified by OrData. All other bits in Operand are + preserved. The new 32-bit value is returned. + + If 32-bit operations are not supported, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Operand Operand on which to perform the bitfield operation. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + @param AndData The value to AND with the read value from the value. + @param OrData The value to OR with the result of the AND operation. + + @return The new 32-bit value. + +**/ +UINT32 +EFIAPI +BitFieldAndThenOr32 ( + IN UINT32 Operand, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT32 AndData, + IN UINT32 OrData + ); + +/** + Returns a bit field from a 64-bit value. + + Returns the bitfield specified by the StartBit and the EndBit from Operand. + + If 64-bit operations are not supported, then ASSERT(). + If StartBit is greater than 63, then ASSERT(). + If EndBit is greater than 63, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Operand Operand on which to perform the bitfield operation. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..63. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..63. + + @return The bit field read. + +**/ +UINT64 +EFIAPI +BitFieldRead64 ( + IN UINT64 Operand, + IN UINTN StartBit, + IN UINTN EndBit + ); + +/** + Writes a bit field to a 64-bit value, and returns the result. + + Writes Value to the bit field specified by the StartBit and the EndBit in + Operand. All other bits in Operand are preserved. The new 64-bit value is + returned. + + If 64-bit operations are not supported, then ASSERT(). + If StartBit is greater than 63, then ASSERT(). + If EndBit is greater than 63, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Operand Operand on which to perform the bitfield operation. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..63. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..63. + @param Value New value of the bit field. + + @return The new 64-bit value. + +**/ +UINT64 +EFIAPI +BitFieldWrite64 ( + IN UINT64 Operand, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT64 Value + ); + +/** + Reads a bit field from a 64-bit value, performs a bitwise OR, and returns the + result. + + Performs a bitwise inclusive OR between the bit field specified by StartBit + and EndBit in Operand and the value specified by OrData. All other bits in + Operand are preserved. The new 64-bit value is returned. + + If 64-bit operations are not supported, then ASSERT(). + If StartBit is greater than 63, then ASSERT(). + If EndBit is greater than 63, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Operand Operand on which to perform the bitfield operation. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..63. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..63. + @param OrData The value to OR with the read value from the value + + @return The new 64-bit value. + +**/ +UINT64 +EFIAPI +BitFieldOr64 ( + IN UINT64 Operand, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT64 OrData + ); + +/** + Reads a bit field from a 64-bit value, performs a bitwise AND, and returns + the result. + + Performs a bitwise AND between the bit field specified by StartBit and EndBit + in Operand and the value specified by AndData. All other bits in Operand are + preserved. The new 64-bit value is returned. + + If 64-bit operations are not supported, then ASSERT(). + If StartBit is greater than 63, then ASSERT(). + If EndBit is greater than 63, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Operand Operand on which to perform the bitfield operation. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..63. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..63. + @param AndData The value to AND with the read value from the value + + @return The new 64-bit value. + +**/ +UINT64 +EFIAPI +BitFieldAnd64 ( + IN UINT64 Operand, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT64 AndData + ); + +/** + Reads a bit field from a 64-bit value, performs a bitwise AND followed by a + bitwise OR, and returns the result. + + Performs a bitwise AND between the bit field specified by StartBit and EndBit + in Operand and the value specified by AndData, followed by a bitwise + inclusive OR with value specified by OrData. All other bits in Operand are + preserved. The new 64-bit value is returned. + + If 64-bit operations are not supported, then ASSERT(). + If StartBit is greater than 63, then ASSERT(). + If EndBit is greater than 63, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Operand Operand on which to perform the bitfield operation. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..63. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..63. + @param AndData The value to AND with the read value from the value. + @param OrData The value to OR with the result of the AND operation. + + @return The new 64-bit value. + +**/ +UINT64 +EFIAPI +BitFieldAndThenOr64 ( + IN UINT64 Operand, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT64 AndData, + IN UINT64 OrData + ); + +// +// Base Library Synchronization Functions +// + +/** + Retrieves the architecture specific spin lock alignment requirements for + optimal spin lock performance. + + This function retrieves the spin lock alignment requirements for optimal + performance on a given CPU architecture. The spin lock alignment must be a + power of two and is returned by this function. If there are no alignment + requirements, then 1 must be returned. The spin lock synchronization + functions must function correctly if the spin lock size and alignment values + returned by this function are not used at all. These values are hints to the + consumers of the spin lock synchronization functions to obtain optimal spin + lock performance. + + @return The architecture specific spin lock alignment. + +**/ +UINTN +EFIAPI +GetSpinLockProperties ( + VOID + ); + +/** + Initializes a spin lock to the released state and returns the spin lock. + + This function initializes the spin lock specified by SpinLock to the released + state, and returns SpinLock. Optimal performance can be achieved by calling + GetSpinLockProperties() to determine the size and alignment requirements for + SpinLock. + + If SpinLock is NULL, then ASSERT(). + + @param SpinLock A pointer to the spin lock to initialize to the released + state. + + @return SpinLock + +**/ +SPIN_LOCK * +EFIAPI +InitializeSpinLock ( + IN SPIN_LOCK *SpinLock + ); + +/** + Waits until a spin lock can be placed in the acquired state. + + This function checks the state of the spin lock specified by SpinLock. If + SpinLock is in the released state, then this function places SpinLock in the + acquired state and returns SpinLock. Otherwise, this function waits + indefinitely for the spin lock to be released, and then places it in the + acquired state and returns SpinLock. All state transitions of SpinLock must + be performed using MP safe mechanisms. + + If SpinLock is NULL, then ASSERT(). + If SpinLock was not initialized with InitializeSpinLock(), then ASSERT(). + If PcdSpinLockTimeout is not zero, and SpinLock is can not be acquired in + PcdSpinLockTimeout microseconds, then ASSERT(). + + @param SpinLock A pointer to the spin lock to place in the acquired state. + + @return SpinLock + +**/ +SPIN_LOCK * +EFIAPI +AcquireSpinLock ( + IN SPIN_LOCK *SpinLock + ); + +/** + Attempts to place a spin lock in the acquired state. + + This function checks the state of the spin lock specified by SpinLock. If + SpinLock is in the released state, then this function places SpinLock in the + acquired state and returns TRUE. Otherwise, FALSE is returned. All state + transitions of SpinLock must be performed using MP safe mechanisms. + + If SpinLock is NULL, then ASSERT(). + If SpinLock was not initialized with InitializeSpinLock(), then ASSERT(). + + @param SpinLock A pointer to the spin lock to place in the acquired state. + + @retval TRUE SpinLock was placed in the acquired state. + @retval FALSE SpinLock could not be acquired. + +**/ +BOOLEAN +EFIAPI +AcquireSpinLockOrFail ( + IN SPIN_LOCK *SpinLock + ); + +/** + Releases a spin lock. + + This function places the spin lock specified by SpinLock in the release state + and returns SpinLock. + + If SpinLock is NULL, then ASSERT(). + If SpinLock was not initialized with InitializeSpinLock(), then ASSERT(). + + @param SpinLock A pointer to the spin lock to release. + + @return SpinLock + +**/ +SPIN_LOCK * +EFIAPI +ReleaseSpinLock ( + IN SPIN_LOCK *SpinLock + ); + +/** + Performs an atomic increment of an 32-bit unsigned integer. + + Performs an atomic increment of the 32-bit unsigned integer specified by + Value and returns the incremented value. The increment operation must be + performed using MP safe mechanisms. The state of the return value is not + guaranteed to be MP safe. + + If Value is NULL, then ASSERT(). + + @param Value A pointer to the 32-bit value to increment. + + @return The incremented value. + +**/ +UINT32 +EFIAPI +InterlockedIncrement ( + IN UINT32 *Value + ); + +/** + Performs an atomic decrement of an 32-bit unsigned integer. + + Performs an atomic decrement of the 32-bit unsigned integer specified by + Value and returns the decremented value. The decrement operation must be + performed using MP safe mechanisms. The state of the return value is not + guaranteed to be MP safe. + + If Value is NULL, then ASSERT(). + + @param Value A pointer to the 32-bit value to decrement. + + @return The decremented value. + +**/ +UINT32 +EFIAPI +InterlockedDecrement ( + IN UINT32 *Value + ); + +/** + Performs an atomic compare exchange operation on a 32-bit unsigned integer. + + Performs an atomic compare exchange operation on the 32-bit unsigned integer + specified by Value. If Value is equal to CompareValue, then Value is set to + ExchangeValue and CompareValue is returned. If Value is not equal to CompareValue, + then Value is returned. The compare exchange operation must be performed using + MP safe mechanisms. + + If Value is NULL, then ASSERT(). + + @param Value A pointer to the 32-bit value for the compare exchange + operation. + @param CompareValue 32-bit value used in compare operation. + @param ExchangeValue 32-bit value used in exchange operation. + + @return The original *Value before exchange. + +**/ +UINT32 +EFIAPI +InterlockedCompareExchange32 ( + IN OUT VOLATILE UINT32 *Value, + IN UINT32 CompareValue, + IN UINT32 ExchangeValue + ); + +/** + Performs an atomic compare exchange operation on a 64-bit unsigned integer. + + Performs an atomic compare exchange operation on the 64-bit unsigned integer specified + by Value. If Value is equal to CompareValue, then Value is set to ExchangeValue and + CompareValue is returned. If Value is not equal to CompareValue, then Value is returned. + The compare exchange operation must be performed using MP safe mechanisms. + + If Value is NULL, then ASSERT(). + + @param Value A pointer to the 64-bit value for the compare exchange + operation. + @param CompareValue 64-bit value used in compare operation. + @param ExchangeValue 64-bit value used in exchange operation. + + @return The original *Value before exchange. + +**/ +UINT64 +EFIAPI +InterlockedCompareExchange64 ( + IN OUT VOLATILE UINT64 *Value, + IN UINT64 CompareValue, + IN UINT64 ExchangeValue + ); + +/** + Performs an atomic compare exchange operation on a pointer value. + + Performs an atomic compare exchange operation on the pointer value specified + by Value. If Value is equal to CompareValue, then Value is set to + ExchangeValue and CompareValue is returned. If Value is not equal to + CompareValue, then Value is returned. The compare exchange operation must be + performed using MP safe mechanisms. + + If Value is NULL, then ASSERT(). + + @param Value A pointer to the pointer value for the compare exchange + operation. + @param CompareValue Pointer value used in compare operation. + @param ExchangeValue Pointer value used in exchange operation. + +**/ +VOID * +EFIAPI +InterlockedCompareExchangePointer ( + IN OUT VOLATILE VOID **Value, + IN VOID *CompareValue, + IN VOID *ExchangeValue + ); + +// +// Base Library CPU Functions +// +typedef +VOID +(EFIAPI *SWITCH_STACK_ENTRY_POINT) ( + IN VOID *Context1, OPTIONAL + IN VOID *Context2 OPTIONAL + ); + +/** + Used to serialize load and store operations. + + All loads and stores that proceed calls to this function are guaranteed to be + globally visible when this function returns. + +**/ +VOID +EFIAPI +MemoryFence ( + VOID + ); + +/** + Saves the current CPU context that can be restored with a call to LongJump() + and returns 0. + + Saves the current CPU context in the buffer specified by JumpBuffer and + returns 0. The initial call to SetJump() must always return 0. Subsequent + calls to LongJump() cause a non-zero value to be returned by SetJump(). + + If JumpBuffer is NULL, then ASSERT(). + For IPF CPUs, if JumpBuffer is not aligned on a 16-byte boundary, then ASSERT(). + + @param JumpBuffer A pointer to CPU context buffer. + + @retval 0 Indicates a return from SetJump(). + +**/ +UINTN +EFIAPI +SetJump ( + OUT BASE_LIBRARY_JUMP_BUFFER *JumpBuffer + ); + +/** + Restores the CPU context that was saved with SetJump(). + + Restores the CPU context from the buffer specified by JumpBuffer. This + function never returns to the caller. Instead is resumes execution based on + the state of JumpBuffer. + + If JumpBuffer is NULL, then ASSERT(). + For IPF CPUs, if JumpBuffer is not aligned on a 16-byte boundary, then ASSERT(). + If Value is 0, then ASSERT(). + + @param JumpBuffer A pointer to CPU context buffer. + @param Value The value to return when the SetJump() context is + restored and must be non-zero. + +**/ +VOID +EFIAPI +LongJump ( + IN BASE_LIBRARY_JUMP_BUFFER *JumpBuffer, + IN UINTN Value + ); + +/** + Enables CPU interrupts. + + Enables CPU interrupts. + +**/ +VOID +EFIAPI +EnableInterrupts ( + VOID + ); + +/** + Disables CPU interrupts. + + Disables CPU interrupts. + +**/ +VOID +EFIAPI +DisableInterrupts ( + VOID + ); + +/** + Disables CPU interrupts and returns the interrupt state prior to the disable + operation. + + Disables CPU interrupts and returns the interrupt state prior to the disable + operation. + + @retval TRUE CPU interrupts were enabled on entry to this call. + @retval FALSE CPU interrupts were disabled on entry to this call. + +**/ +BOOLEAN +EFIAPI +SaveAndDisableInterrupts ( + VOID + ); + +/** + Enables CPU interrupts for the smallest window required to capture any + pending interrupts. + + Enables CPU interrupts for the smallest window required to capture any + pending interrupts. + +**/ +VOID +EFIAPI +EnableDisableInterrupts ( + VOID + ); + +/** + Retrieves the current CPU interrupt state. + + Retrieves the current CPU interrupt state. Returns TRUE is interrupts are + currently enabled. Otherwise returns FALSE. + + @retval TRUE CPU interrupts are enabled. + @retval FALSE CPU interrupts are disabled. + +**/ +BOOLEAN +EFIAPI +GlueGetInterruptState ( + VOID + ); + +/** + Set the current CPU interrupt state. + + Sets the current CPU interrupt state to the state specified by + InterruptState. If InterruptState is TRUE, then interrupts are enabled. If + InterruptState is FALSE, then interrupts are disabled. InterruptState is + returned. + + @param InterruptState TRUE if interrupts should enabled. FALSE if + interrupts should be disabled. + + @return InterruptState + +**/ +BOOLEAN +EFIAPI +SetInterruptState ( + IN BOOLEAN InterruptState + ); + +/** + Places the CPU in a sleep state until an interrupt is received. + + Places the CPU in a sleep state until an interrupt is received. If interrupts + are disabled prior to calling this function, then the CPU will be placed in a + sleep state indefinitely. + +**/ +VOID +EFIAPI +CpuSleep ( + VOID + ); + +/** + Requests CPU to pause for a short period of time. + + Requests CPU to pause for a short period of time. Typically used in MP + systems to prevent memory starvation while waiting for a spin lock. + +**/ +VOID +EFIAPI +CpuPause ( + VOID + ); + +/** + Flushes all the Translation Lookaside Buffers(TLB) entries in a CPU. + + Flushes all the Translation Lookaside Buffers(TLB) entries in a CPU. + +**/ +VOID +EFIAPI +CpuFlushTlb ( + VOID + ); + +/** + Transfers control to a function starting with a new stack. + + Transfers control to the function specified by EntryPoint using the new stack + specified by NewStack and passing in the parameters specified by Context1 and + Context2. Context1 and Context2 are optional and may be NULL. The function + EntryPoint must never return. + + If EntryPoint is NULL, then ASSERT(). + If NewStack is NULL, then ASSERT(). + + @param EntryPoint A pointer to function to call with the new stack. + @param Context1 A pointer to the context to pass into the EntryPoint + function. + @param Context2 A pointer to the context to pass into the EntryPoint + function. + @param NewStack A pointer to the new stack to use for the EntryPoint + function. + +**/ +VOID +EFIAPI +SwitchStack ( + IN SWITCH_STACK_ENTRY_POINT EntryPoint, + IN VOID *Context1, OPTIONAL + IN VOID *Context2, OPTIONAL + IN VOID *NewStack + ); + +/** + Generates a breakpoint on the CPU. + + Generates a breakpoint on the CPU. The breakpoint must be implemented such + that code can resume normal execution after the breakpoint. + +**/ +VOID +EFIAPI +CpuBreakpoint ( + VOID + ); + +/** + Executes an infinite loop. + + Forces the CPU to execute an infinite loop. A debugger may be used to skip + past the loop and the code that follows the loop must execute properly. This + implies that the infinite loop must not cause the code that follow it to be + optimized away. + +**/ +VOID +EFIAPI +CpuDeadLoop ( + VOID + ); + +// +// IA32 and X64 Specific Functions +// +// +// Byte packed structure for 16-bit Real Mode EFLAGS +// +typedef union { + struct { + UINT32 CF:1; // Carry Flag + UINT32 Reserved_0:1; // Reserved + UINT32 PF:1; // Parity Flag + UINT32 Reserved_1:1; // Reserved + UINT32 AF:1; // Auxiliary Carry Flag + UINT32 Reserved_2:1; // Reserved + UINT32 ZF:1; // Zero Flag + UINT32 SF:1; // Sign Flag + UINT32 TF:1; // Trap Flag + UINT32 IF:1; // Interrupt Enable Flag + UINT32 DF:1; // Direction Flag + UINT32 OF:1; // Overflow Flag + UINT32 IOPL:2; // I/O Privilege Level + UINT32 NT:1; // Nested Task + UINT32 Reserved_3:1; // Reserved + } Bits; + UINT16 Uint16; +} IA32_FLAGS16; + +// +// Byte packed structure for EFLAGS/RFLAGS +// 32-bits on IA-32 +// 64-bits on X64. The upper 32-bits on X64 are reserved +// +typedef union { + struct { + UINT32 CF:1; // Carry Flag + UINT32 Reserved_0:1; // Reserved + UINT32 PF:1; // Parity Flag + UINT32 Reserved_1:1; // Reserved + UINT32 AF:1; // Auxiliary Carry Flag + UINT32 Reserved_2:1; // Reserved + UINT32 ZF:1; // Zero Flag + UINT32 SF:1; // Sign Flag + UINT32 TF:1; // Trap Flag + UINT32 IF:1; // Interrupt Enable Flag + UINT32 DF:1; // Direction Flag + UINT32 OF:1; // Overflow Flag + UINT32 IOPL:2; // I/O Privilege Level + UINT32 NT:1; // Nested Task + UINT32 Reserved_3:1; // Reserved + UINT32 RF:1; // Resume Flag + UINT32 VM:1; // Virtual 8086 Mode + UINT32 AC:1; // Alignment Check + UINT32 VIF:1; // Virtual Interrupt Flag + UINT32 VIP:1; // Virtual Interrupt Pending + UINT32 ID:1; // ID Flag + UINT32 Reserved_4:10; // Reserved + } Bits; + UINTN UintN; +} IA32_EFLAGS32; + +// +// Byte packed structure for Control Register 0 (CR0) +// 32-bits on IA-32 +// 64-bits on X64. The upper 32-bits on X64 are reserved +// +typedef union { + struct { + UINT32 PE:1; // Protection Enable + UINT32 MP:1; // Monitor Coprocessor + UINT32 EM:1; // Emulation + UINT32 TS:1; // Task Switched + UINT32 ET:1; // Extension Type + UINT32 NE:1; // Numeric Error + UINT32 Reserved_0:10; // Reserved + UINT32 WP:1; // Write Protect + UINT32 Reserved_1:1; // Reserved + UINT32 AM:1; // Alignment Mask + UINT32 Reserved_2:10; // Reserved + UINT32 NW:1; // Mot Write-through + UINT32 CD:1; // Cache Disable + UINT32 PG:1; // Paging + } Bits; + UINTN UintN; +} IA32_CR0; + +// +// Byte packed structure for Control Register 4 (CR4) +// 32-bits on IA-32 +// 64-bits on X64. The upper 32-bits on X64 are reserved +// +typedef union { + struct { + UINT32 VME:1; // Virtual-8086 Mode Extensions + UINT32 PVI:1; // Protected-Mode Virtual Interrupts + UINT32 TSD:1; // Time Stamp Disable + UINT32 DE:1; // Debugging Extensions + UINT32 PSE:1; // Page Size Extensions + UINT32 PAE:1; // Physical Address Extension + UINT32 MCE:1; // Machine Check Enable + UINT32 PGE:1; // Page Global Enable + UINT32 PCE:1; // Performance Monitoring Counter + // Enable + UINT32 OSFXSR:1; // Operating System Support for + // FXSAVE and FXRSTOR instructions + UINT32 OSXMMEXCPT:1; // Operating System Support for + // Unmasked SIMD Floating Point + // Exceptions + UINT32 Reserved_0:2; // Reserved + UINT32 VMXE:1; // VMX Enable + UINT32 Reserved_1:18; // Reseved + } Bits; + UINTN UintN; +} IA32_CR4; + +// +// Byte packed structure for an IDTR, GDTR, LDTR descriptor +/// @bug How to make this structure byte-packed in a compiler independent way? +// +#pragma pack (1) +typedef struct { + UINT16 Limit; + UINTN Base; +} IA32_DESCRIPTOR; +#pragma pack () + +#define IA32_IDT_GATE_TYPE_TASK 0x85 +#define IA32_IDT_GATE_TYPE_INTERRUPT_16 0x86 +#define IA32_IDT_GATE_TYPE_TRAP_16 0x87 +#define IA32_IDT_GATE_TYPE_INTERRUPT_32 0x8E +#define IA32_IDT_GATE_TYPE_TRAP_32 0x8F + +// +// Byte packed structure for an Interrupt Gate Descriptor +// +typedef union { + struct { + UINT32 OffsetLow:16; // Offset bits 15..0 + UINT32 Selector:16; // Selector + UINT32 Reserved_0:8; // Reserved + UINT32 GateType:8; // Gate Type. See #defines above + UINT32 OffsetHigh:16; // Offset bits 31..16 + } Bits; + UINT64 Uint64; +} IA32_IDT_GATE_DESCRIPTOR; + +// +// Byte packed structure for an FP/SSE/SSE2 context +// +typedef struct { + UINT8 Buffer[512]; +} IA32_FX_BUFFER; + +// +// Structures for the 16-bit real mode thunks +// +typedef struct { + UINT32 Reserved1; + UINT32 Reserved2; + UINT32 Reserved3; + UINT32 Reserved4; + UINT8 BL; + UINT8 BH; + UINT16 Reserved5; + UINT8 DL; + UINT8 DH; + UINT16 Reserved6; + UINT8 CL; + UINT8 CH; + UINT16 Reserved7; + UINT8 AL; + UINT8 AH; + UINT16 Reserved8; +} IA32_BYTE_REGS; + +typedef struct { + UINT16 DI; + UINT16 Reserved1; + UINT16 SI; + UINT16 Reserved2; + UINT16 BP; + UINT16 Reserved3; + UINT16 SP; + UINT16 Reserved4; + UINT16 BX; + UINT16 Reserved5; + UINT16 DX; + UINT16 Reserved6; + UINT16 CX; + UINT16 Reserved7; + UINT16 AX; + UINT16 Reserved8; +} IA32_WORD_REGS; + +typedef struct { + UINT32 EDI; + UINT32 ESI; + UINT32 EBP; + UINT32 ESP; + UINT32 EBX; + UINT32 EDX; + UINT32 ECX; + UINT32 EAX; + UINT16 DS; + UINT16 ES; + UINT16 FS; + UINT16 GS; + IA32_EFLAGS32 EFLAGS; + UINT32 Eip; + UINT16 CS; + UINT16 SS; +} IA32_DWORD_REGS; + +typedef union { + IA32_DWORD_REGS E; + IA32_WORD_REGS X; + IA32_BYTE_REGS H; +} IA32_REGISTER_SET; + +// +// Byte packed structure for an 16-bit real mode thunks +// +typedef struct { + IA32_REGISTER_SET *RealModeState; + VOID *RealModeBuffer; + UINT32 RealModeBufferSize; + UINT32 ThunkAttributes; +} THUNK_CONTEXT; + +#define THUNK_ATTRIBUTE_BIG_REAL_MODE 0x00000001 +#define THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 0x00000002 +#define THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL 0x00000004 + +/** + Retrieves CPUID information. + + Executes the CPUID instruction with EAX set to the value specified by Index. + This function always returns Index. + If Eax is not NULL, then the value of EAX after CPUID is returned in Eax. + If Ebx is not NULL, then the value of EBX after CPUID is returned in Ebx. + If Ecx is not NULL, then the value of ECX after CPUID is returned in Ecx. + If Edx is not NULL, then the value of EDX after CPUID is returned in Edx. + This function is only available on IA-32 and X64. + + @param Index The 32-bit value to load into EAX prior to invoking the CPUID + instruction. + @param Eax Pointer to the 32-bit EAX value returned by the CPUID + instruction. This is an optional parameter that may be NULL. + @param Ebx Pointer to the 32-bit EBX value returned by the CPUID + instruction. This is an optional parameter that may be NULL. + @param Ecx Pointer to the 32-bit ECX value returned by the CPUID + instruction. This is an optional parameter that may be NULL. + @param Edx Pointer to the 32-bit EDX value returned by the CPUID + instruction. This is an optional parameter that may be NULL. + + @return Index + +**/ +UINT32 +EFIAPI +AsmCpuid ( + IN UINT32 Index, + OUT UINT32 *Eax, OPTIONAL + OUT UINT32 *Ebx, OPTIONAL + OUT UINT32 *Ecx, OPTIONAL + OUT UINT32 *Edx OPTIONAL + ); + +/** + Retrieves CPUID information using an extended leaf identifier. + + Executes the CPUID instruction with EAX set to the value specified by Index + and ECX set to the value specified by SubIndex. This function always returns + Index. This function is only available on IA-32 and x64. + + If Eax is not NULL, then the value of EAX after CPUID is returned in Eax. + If Ebx is not NULL, then the value of EBX after CPUID is returned in Ebx. + If Ecx is not NULL, then the value of ECX after CPUID is returned in Ecx. + If Edx is not NULL, then the value of EDX after CPUID is returned in Edx. + + @param Index The 32-bit value to load into EAX prior to invoking the + CPUID instruction. + @param SubIndex The 32-bit value to load into ECX prior to invoking the + CPUID instruction. + @param Eax Pointer to the 32-bit EAX value returned by the CPUID + instruction. This is an optional parameter that may be + NULL. + @param Ebx Pointer to the 32-bit EBX value returned by the CPUID + instruction. This is an optional parameter that may be + NULL. + @param Ecx Pointer to the 32-bit ECX value returned by the CPUID + instruction. This is an optional parameter that may be + NULL. + @param Edx Pointer to the 32-bit EDX value returned by the CPUID + instruction. This is an optional parameter that may be + NULL. + + @return Index + +**/ +UINT32 +EFIAPI +AsmCpuidEx ( + IN UINT32 Index, + IN UINT32 SubIndex, + OUT UINT32 *Eax, OPTIONAL + OUT UINT32 *Ebx, OPTIONAL + OUT UINT32 *Ecx, OPTIONAL + OUT UINT32 *Edx OPTIONAL + ); + +/** + Returns the lower 32-bits of a Machine Specific Register(MSR). + + Reads and returns the lower 32-bits of the MSR specified by Index. + No parameter checking is performed on Index, and some Index values may cause + CPU exceptions. The caller must either guarantee that Index is valid, or the + caller must set up exception handlers to catch the exceptions. This function + is only available on IA-32 and X64. + + @param Index The 32-bit MSR index to read. + + @return The lower 32 bits of the MSR identified by Index. + +**/ +UINT32 +EFIAPI +AsmReadMsr32 ( + IN UINT32 Index + ); + +/** + Zero-extend a 32-bit value and writes it to a Machine Specific Register(MSR). + + Writes the 32-bit value specified by Value to the MSR specified by Index. The + upper 32-bits of the MSR write are set to zero. The 32-bit value written to + the MSR is returned. No parameter checking is performed on Index or Value, + and some of these may cause CPU exceptions. The caller must either guarantee + that Index and Value are valid, or the caller must establish proper exception + handlers. This function is only available on IA-32 and X64. + + @param Index The 32-bit MSR index to write. + @param Value The 32-bit value to write to the MSR. + + @return Value + +**/ +UINT32 +EFIAPI +AsmWriteMsr32 ( + IN UINT32 Index, + IN UINT32 Value + ); + +/** + Reads a 64-bit MSR, performs a bitwise inclusive OR on the lower 32-bits, and + writes the result back to the 64-bit MSR. + + Reads the 64-bit MSR specified by Index, performs a bitwise inclusive OR + between the lower 32-bits of the read result and the value specified by + OrData, and writes the result to the 64-bit MSR specified by Index. The lower + 32-bits of the value written to the MSR is returned. No parameter checking is + performed on Index or OrData, and some of these may cause CPU exceptions. The + caller must either guarantee that Index and OrData are valid, or the caller + must establish proper exception handlers. This function is only available on + IA-32 and X64. + + @param Index The 32-bit MSR index to write. + @param OrData The value to OR with the read value from the MSR. + + @return The lower 32-bit value written to the MSR. + +**/ +UINT32 +EFIAPI +AsmMsrOr32 ( + IN UINT32 Index, + IN UINT32 OrData + ); + +/** + Reads a 64-bit MSR, performs a bitwise AND on the lower 32-bits, and writes + the result back to the 64-bit MSR. + + Reads the 64-bit MSR specified by Index, performs a bitwise AND between the + lower 32-bits of the read result and the value specified by AndData, and + writes the result to the 64-bit MSR specified by Index. The lower 32-bits of + the value written to the MSR is returned. No parameter checking is performed + on Index or AndData, and some of these may cause CPU exceptions. The caller + must either guarantee that Index and AndData are valid, or the caller must + establish proper exception handlers. This function is only available on IA-32 + and X64. + + @param Index The 32-bit MSR index to write. + @param AndData The value to AND with the read value from the MSR. + + @return The lower 32-bit value written to the MSR. + +**/ +UINT32 +EFIAPI +AsmMsrAnd32 ( + IN UINT32 Index, + IN UINT32 AndData + ); + +/** + Reads a 64-bit MSR, performs a bitwise AND followed by a bitwise inclusive OR + on the lower 32-bits, and writes the result back to the 64-bit MSR. + + Reads the 64-bit MSR specified by Index, performs a bitwise AND between the + lower 32-bits of the read result and the value specified by AndData + preserving the upper 32-bits, performs a bitwise inclusive OR between the + result of the AND operation and the value specified by OrData, and writes the + result to the 64-bit MSR specified by Address. The lower 32-bits of the value + written to the MSR is returned. No parameter checking is performed on Index, + AndData, or OrData, and some of these may cause CPU exceptions. The caller + must either guarantee that Index, AndData, and OrData are valid, or the + caller must establish proper exception handlers. This function is only + available on IA-32 and X64. + + @param Index The 32-bit MSR index to write. + @param AndData The value to AND with the read value from the MSR. + @param OrData The value to OR with the result of the AND operation. + + @return The lower 32-bit value written to the MSR. + +**/ +UINT32 +EFIAPI +AsmMsrAndThenOr32 ( + IN UINT32 Index, + IN UINT32 AndData, + IN UINT32 OrData + ); + +/** + Reads a bit field of an MSR. + + Reads the bit field in the lower 32-bits of a 64-bit MSR. The bit field is + specified by the StartBit and the EndBit. The value of the bit field is + returned. The caller must either guarantee that Index is valid, or the caller + must set up exception handlers to catch the exceptions. This function is only + available on IA-32 and X64. + + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Index The 32-bit MSR index to read. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + + @return The bit field read from the MSR. + +**/ +UINT32 +EFIAPI +AsmMsrBitFieldRead32 ( + IN UINT32 Index, + IN UINTN StartBit, + IN UINTN EndBit + ); + +/** + Writes a bit field to an MSR. + + Writes Value to a bit field in the lower 32-bits of a 64-bit MSR. The bit + field is specified by the StartBit and the EndBit. All other bits in the + destination MSR are preserved. The lower 32-bits of the MSR written is + returned. Extra left bits in Value are stripped. The caller must either + guarantee that Index and the data written is valid, or the caller must set up + exception handlers to catch the exceptions. This function is only available + on IA-32 and X64. + + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Index The 32-bit MSR index to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + @param Value New value of the bit field. + + @return The lower 32-bit of the value written to the MSR. + +**/ +UINT32 +EFIAPI +AsmMsrBitFieldWrite32 ( + IN UINT32 Index, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT32 Value + ); + +/** + Reads a bit field in a 64-bit MSR, performs a bitwise OR, and writes the + result back to the bit field in the 64-bit MSR. + + Reads the 64-bit MSR specified by Index, performs a bitwise inclusive OR + between the read result and the value specified by OrData, and writes the + result to the 64-bit MSR specified by Index. The lower 32-bits of the value + written to the MSR are returned. Extra left bits in OrData are stripped. The + caller must either guarantee that Index and the data written is valid, or + the caller must set up exception handlers to catch the exceptions. This + function is only available on IA-32 and X64. + + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Index The 32-bit MSR index to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + @param OrData The value to OR with the read value from the MSR. + + @return The lower 32-bit of the value written to the MSR. + +**/ +UINT32 +EFIAPI +AsmMsrBitFieldOr32 ( + IN UINT32 Index, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT32 OrData + ); + +/** + Reads a bit field in a 64-bit MSR, performs a bitwise AND, and writes the + result back to the bit field in the 64-bit MSR. + + Reads the 64-bit MSR specified by Index, performs a bitwise AND between the + read result and the value specified by AndData, and writes the result to the + 64-bit MSR specified by Index. The lower 32-bits of the value written to the + MSR are returned. Extra left bits in AndData are stripped. The caller must + either guarantee that Index and the data written is valid, or the caller must + set up exception handlers to catch the exceptions. This function is only + available on IA-32 and X64. + + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Index The 32-bit MSR index to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + @param AndData The value to AND with the read value from the MSR. + + @return The lower 32-bit of the value written to the MSR. + +**/ +UINT32 +EFIAPI +AsmMsrBitFieldAnd32 ( + IN UINT32 Index, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT32 AndData + ); + +/** + Reads a bit field in a 64-bit MSR, performs a bitwise AND followed by a + bitwise inclusive OR, and writes the result back to the bit field in the + 64-bit MSR. + + Reads the 64-bit MSR specified by Index, performs a bitwise AND followed by a + bitwise inclusive OR between the read result and the value specified by + AndData, and writes the result to the 64-bit MSR specified by Index. The + lower 32-bits of the value written to the MSR are returned. Extra left bits + in both AndData and OrData are stripped. The caller must either guarantee + that Index and the data written is valid, or the caller must set up exception + handlers to catch the exceptions. This function is only available on IA-32 + and X64. + + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Index The 32-bit MSR index to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + @param AndData The value to AND with the read value from the MSR. + @param OrData The value to OR with the result of the AND operation. + + @return The lower 32-bit of the value written to the MSR. + +**/ +UINT32 +EFIAPI +AsmMsrBitFieldAndThenOr32 ( + IN UINT32 Index, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT32 AndData, + IN UINT32 OrData + ); + +/** + Returns a 64-bit Machine Specific Register(MSR). + + Reads and returns the 64-bit MSR specified by Index. No parameter checking is + performed on Index, and some Index values may cause CPU exceptions. The + caller must either guarantee that Index is valid, or the caller must set up + exception handlers to catch the exceptions. This function is only available + on IA-32 and X64. + + @param Index The 32-bit MSR index to read. + + @return The value of the MSR identified by Index. + +**/ +UINT64 +EFIAPI +AsmReadMsr64 ( + IN UINT32 Index + ); + +/** + Writes a 64-bit value to a Machine Specific Register(MSR), and returns the + value. + + Writes the 64-bit value specified by Value to the MSR specified by Index. The + 64-bit value written to the MSR is returned. No parameter checking is + performed on Index or Value, and some of these may cause CPU exceptions. The + caller must either guarantee that Index and Value are valid, or the caller + must establish proper exception handlers. This function is only available on + IA-32 and X64. + + @param Index The 32-bit MSR index to write. + @param Value The 64-bit value to write to the MSR. + + @return Value + +**/ +UINT64 +EFIAPI +AsmWriteMsr64 ( + IN UINT32 Index, + IN UINT64 Value + ); + +/** + Reads a 64-bit MSR, performs a bitwise inclusive OR, and writes the result + back to the 64-bit MSR. + + Reads the 64-bit MSR specified by Index, performs a bitwise inclusive OR + between the read result and the value specified by OrData, and writes the + result to the 64-bit MSR specified by Index. The value written to the MSR is + returned. No parameter checking is performed on Index or OrData, and some of + these may cause CPU exceptions. The caller must either guarantee that Index + and OrData are valid, or the caller must establish proper exception handlers. + This function is only available on IA-32 and X64. + + @param Index The 32-bit MSR index to write. + @param OrData The value to OR with the read value from the MSR. + + @return The value written back to the MSR. + +**/ +UINT64 +EFIAPI +AsmMsrOr64 ( + IN UINT32 Index, + IN UINT64 OrData + ); + +/** + Reads a 64-bit MSR, performs a bitwise AND, and writes the result back to the + 64-bit MSR. + + Reads the 64-bit MSR specified by Index, performs a bitwise AND between the + read result and the value specified by OrData, and writes the result to the + 64-bit MSR specified by Index. The value written to the MSR is returned. No + parameter checking is performed on Index or OrData, and some of these may + cause CPU exceptions. The caller must either guarantee that Index and OrData + are valid, or the caller must establish proper exception handlers. This + function is only available on IA-32 and X64. + + @param Index The 32-bit MSR index to write. + @param AndData The value to AND with the read value from the MSR. + + @return The value written back to the MSR. + +**/ +UINT64 +EFIAPI +AsmMsrAnd64 ( + IN UINT32 Index, + IN UINT64 AndData + ); + +/** + Reads a 64-bit MSR, performs a bitwise AND followed by a bitwise inclusive + OR, and writes the result back to the 64-bit MSR. + + Reads the 64-bit MSR specified by Index, performs a bitwise AND between read + result and the value specified by AndData, performs a bitwise inclusive OR + between the result of the AND operation and the value specified by OrData, + and writes the result to the 64-bit MSR specified by Index. The value written + to the MSR is returned. No parameter checking is performed on Index, AndData, + or OrData, and some of these may cause CPU exceptions. The caller must either + guarantee that Index, AndData, and OrData are valid, or the caller must + establish proper exception handlers. This function is only available on IA-32 + and X64. + + @param Index The 32-bit MSR index to write. + @param AndData The value to AND with the read value from the MSR. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the MSR. + +**/ +UINT64 +EFIAPI +AsmMsrAndThenOr64 ( + IN UINT32 Index, + IN UINT64 AndData, + IN UINT64 OrData + ); + +/** + Reads a bit field of an MSR. + + Reads the bit field in the 64-bit MSR. The bit field is specified by the + StartBit and the EndBit. The value of the bit field is returned. The caller + must either guarantee that Index is valid, or the caller must set up + exception handlers to catch the exceptions. This function is only available + on IA-32 and X64. + + If StartBit is greater than 63, then ASSERT(). + If EndBit is greater than 63, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Index The 32-bit MSR index to read. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..63. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..63. + + @return The value read from the MSR. + +**/ +UINT64 +EFIAPI +AsmMsrBitFieldRead64 ( + IN UINT32 Index, + IN UINTN StartBit, + IN UINTN EndBit + ); + +/** + Writes a bit field to an MSR. + + Writes Value to a bit field in a 64-bit MSR. The bit field is specified by + the StartBit and the EndBit. All other bits in the destination MSR are + preserved. The MSR written is returned. Extra left bits in Value are + stripped. The caller must either guarantee that Index and the data written is + valid, or the caller must set up exception handlers to catch the exceptions. + This function is only available on IA-32 and X64. + + If StartBit is greater than 63, then ASSERT(). + If EndBit is greater than 63, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Index The 32-bit MSR index to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..63. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..63. + @param Value New value of the bit field. + + @return The value written back to the MSR. + +**/ +UINT64 +EFIAPI +AsmMsrBitFieldWrite64 ( + IN UINT32 Index, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT64 Value + ); + +/** + Reads a bit field in a 64-bit MSR, performs a bitwise inclusive OR, and + writes the result back to the bit field in the 64-bit MSR. + + Reads the 64-bit MSR specified by Index, performs a bitwise inclusive OR + between the read result and the value specified by OrData, and writes the + result to the 64-bit MSR specified by Index. The value written to the MSR is + returned. Extra left bits in OrData are stripped. The caller must either + guarantee that Index and the data written is valid, or the caller must set up + exception handlers to catch the exceptions. This function is only available + on IA-32 and X64. + + If StartBit is greater than 63, then ASSERT(). + If EndBit is greater than 63, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Index The 32-bit MSR index to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..63. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..63. + @param OrData The value to OR with the read value from the bit field. + + @return The value written back to the MSR. + +**/ +UINT64 +EFIAPI +AsmMsrBitFieldOr64 ( + IN UINT32 Index, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT64 OrData + ); + +/** + Reads a bit field in a 64-bit MSR, performs a bitwise AND, and writes the + result back to the bit field in the 64-bit MSR. + + Reads the 64-bit MSR specified by Index, performs a bitwise AND between the + read result and the value specified by AndData, and writes the result to the + 64-bit MSR specified by Index. The value written to the MSR is returned. + Extra left bits in AndData are stripped. The caller must either guarantee + that Index and the data written is valid, or the caller must set up exception + handlers to catch the exceptions. This function is only available on IA-32 + and X64. + + If StartBit is greater than 63, then ASSERT(). + If EndBit is greater than 63, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Index The 32-bit MSR index to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..63. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..63. + @param AndData The value to AND with the read value from the bit field. + + @return The value written back to the MSR. + +**/ +UINT64 +EFIAPI +AsmMsrBitFieldAnd64 ( + IN UINT32 Index, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT64 AndData + ); + +/** + Reads a bit field in a 64-bit MSR, performs a bitwise AND followed by a + bitwise inclusive OR, and writes the result back to the bit field in the + 64-bit MSR. + + Reads the 64-bit MSR specified by Index, performs a bitwise AND followed by + a bitwise inclusive OR between the read result and the value specified by + AndData, and writes the result to the 64-bit MSR specified by Index. The + value written to the MSR is returned. Extra left bits in both AndData and + OrData are stripped. The caller must either guarantee that Index and the data + written is valid, or the caller must set up exception handlers to catch the + exceptions. This function is only available on IA-32 and X64. + + If StartBit is greater than 63, then ASSERT(). + If EndBit is greater than 63, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Index The 32-bit MSR index to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..63. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..63. + @param AndData The value to AND with the read value from the bit field. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the MSR. + +**/ +UINT64 +EFIAPI +AsmMsrBitFieldAndThenOr64 ( + IN UINT32 Index, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT64 AndData, + IN UINT64 OrData + ); + +/** + Reads the current value of the EFLAGS register. + + Reads and returns the current value of the EFLAGS register. This function is + only available on IA-32 and X64. This returns a 32-bit value on IA-32 and a + 64-bit value on X64. + + @return EFLAGS on IA-32 or RFLAGS on X64. + +**/ +UINTN +EFIAPI +AsmReadEflags ( + VOID + ); + +/** + Reads the current value of the Control Register 0 (CR0). + + Reads and returns the current value of CR0. This function is only available + on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on + X64. + + @return The value of the Control Register 0 (CR0). + +**/ +UINTN +EFIAPI +AsmReadCr0 ( + VOID + ); + +/** + Reads the current value of the Control Register 2 (CR2). + + Reads and returns the current value of CR2. This function is only available + on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on + X64. + + @return The value of the Control Register 2 (CR2). + +**/ +UINTN +EFIAPI +AsmReadCr2 ( + VOID + ); + +/** + Reads the current value of the Control Register 3 (CR3). + + Reads and returns the current value of CR3. This function is only available + on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on + X64. + + @return The value of the Control Register 3 (CR3). + +**/ +UINTN +EFIAPI +AsmReadCr3 ( + VOID + ); + +/** + Reads the current value of the Control Register 4 (CR4). + + Reads and returns the current value of CR4. This function is only available + on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on + X64. + + @return The value of the Control Register 4 (CR4). + +**/ +UINTN +EFIAPI +AsmReadCr4 ( + VOID + ); + +/** + Writes a value to Control Register 0 (CR0). + + Writes and returns a new value to CR0. This function is only available on + IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64. + + @param Cr0 The value to write to CR0. + + @return The value written to CR0. + +**/ +UINTN +EFIAPI +AsmWriteCr0 ( + UINTN Cr0 + ); + +/** + Writes a value to Control Register 2 (CR2). + + Writes and returns a new value to CR2. This function is only available on + IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64. + + @param Cr2 The value to write to CR2. + + @return The value written to CR2. + +**/ +UINTN +EFIAPI +AsmWriteCr2 ( + UINTN Cr2 + ); + +/** + Writes a value to Control Register 3 (CR3). + + Writes and returns a new value to CR3. This function is only available on + IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64. + + @param Cr3 The value to write to CR3. + + @return The value written to CR3. + +**/ +UINTN +EFIAPI +AsmWriteCr3 ( + UINTN Cr3 + ); + +/** + Writes a value to Control Register 4 (CR4). + + Writes and returns a new value to CR4. This function is only available on + IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64. + + @param Cr4 The value to write to CR4. + + @return The value written to CR4. + +**/ +UINTN +EFIAPI +AsmWriteCr4 ( + UINTN Cr4 + ); + +/** + Reads the current value of Debug Register 0 (DR0). + + Reads and returns the current value of DR0. This function is only available + on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on + X64. + + @return The value of Debug Register 0 (DR0). + +**/ +UINTN +EFIAPI +AsmReadDr0 ( + VOID + ); + +/** + Reads the current value of Debug Register 1 (DR1). + + Reads and returns the current value of DR1. This function is only available + on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on + X64. + + @return The value of Debug Register 1 (DR1). + +**/ +UINTN +EFIAPI +AsmReadDr1 ( + VOID + ); + +/** + Reads the current value of Debug Register 2 (DR2). + + Reads and returns the current value of DR2. This function is only available + on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on + X64. + + @return The value of Debug Register 2 (DR2). + +**/ +UINTN +EFIAPI +AsmReadDr2 ( + VOID + ); + +/** + Reads the current value of Debug Register 3 (DR3). + + Reads and returns the current value of DR3. This function is only available + on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on + X64. + + @return The value of Debug Register 3 (DR3). + +**/ +UINTN +EFIAPI +AsmReadDr3 ( + VOID + ); + +/** + Reads the current value of Debug Register 4 (DR4). + + Reads and returns the current value of DR4. This function is only available + on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on + X64. + + @return The value of Debug Register 4 (DR4). + +**/ +UINTN +EFIAPI +AsmReadDr4 ( + VOID + ); + +/** + Reads the current value of Debug Register 5 (DR5). + + Reads and returns the current value of DR5. This function is only available + on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on + X64. + + @return The value of Debug Register 5 (DR5). + +**/ +UINTN +EFIAPI +AsmReadDr5 ( + VOID + ); + +/** + Reads the current value of Debug Register 6 (DR6). + + Reads and returns the current value of DR6. This function is only available + on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on + X64. + + @return The value of Debug Register 6 (DR6). + +**/ +UINTN +EFIAPI +AsmReadDr6 ( + VOID + ); + +/** + Reads the current value of Debug Register 7 (DR7). + + Reads and returns the current value of DR7. This function is only available + on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on + X64. + + @return The value of Debug Register 7 (DR7). + +**/ +UINTN +EFIAPI +AsmReadDr7 ( + VOID + ); + +/** + Writes a value to Debug Register 0 (DR0). + + Writes and returns a new value to DR0. This function is only available on + IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64. + + @param Dr0 The value to write to Dr0. + + @return The value written to Debug Register 0 (DR0). + +**/ +UINTN +EFIAPI +AsmWriteDr0 ( + UINTN Dr0 + ); + +/** + Writes a value to Debug Register 1 (DR1). + + Writes and returns a new value to DR1. This function is only available on + IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64. + + @param Dr1 The value to write to Dr1. + + @return The value written to Debug Register 1 (DR1). + +**/ +UINTN +EFIAPI +AsmWriteDr1 ( + UINTN Dr1 + ); + +/** + Writes a value to Debug Register 2 (DR2). + + Writes and returns a new value to DR2. This function is only available on + IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64. + + @param Dr2 The value to write to Dr2. + + @return The value written to Debug Register 2 (DR2). + +**/ +UINTN +EFIAPI +AsmWriteDr2 ( + UINTN Dr2 + ); + +/** + Writes a value to Debug Register 3 (DR3). + + Writes and returns a new value to DR3. This function is only available on + IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64. + + @param Dr3 The value to write to Dr3. + + @return The value written to Debug Register 3 (DR3). + +**/ +UINTN +EFIAPI +AsmWriteDr3 ( + UINTN Dr3 + ); + +/** + Writes a value to Debug Register 4 (DR4). + + Writes and returns a new value to DR4. This function is only available on + IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64. + + @param Dr4 The value to write to Dr4. + + @return The value written to Debug Register 4 (DR4). + +**/ +UINTN +EFIAPI +AsmWriteDr4 ( + UINTN Dr4 + ); + +/** + Writes a value to Debug Register 5 (DR5). + + Writes and returns a new value to DR5. This function is only available on + IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64. + + @param Dr5 The value to write to Dr5. + + @return The value written to Debug Register 5 (DR5). + +**/ +UINTN +EFIAPI +AsmWriteDr5 ( + UINTN Dr5 + ); + +/** + Writes a value to Debug Register 6 (DR6). + + Writes and returns a new value to DR6. This function is only available on + IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64. + + @param Dr6 The value to write to Dr6. + + @return The value written to Debug Register 6 (DR6). + +**/ +UINTN +EFIAPI +AsmWriteDr6 ( + UINTN Dr6 + ); + +/** + Writes a value to Debug Register 7 (DR7). + + Writes and returns a new value to DR7. This function is only available on + IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64. + + @param Dr7 The value to write to Dr7. + + @return The value written to Debug Register 7 (DR7). + +**/ +UINTN +EFIAPI +AsmWriteDr7 ( + UINTN Dr7 + ); + +/** + Reads the current value of Code Segment Register (CS). + + Reads and returns the current value of CS. This function is only available on + IA-32 and X64. + + @return The current value of CS. + +**/ +UINT16 +EFIAPI +AsmReadCs ( + VOID + ); + +/** + Reads the current value of Data Segment Register (DS). + + Reads and returns the current value of DS. This function is only available on + IA-32 and X64. + + @return The current value of DS. + +**/ +UINT16 +EFIAPI +AsmReadDs ( + VOID + ); + +/** + Reads the current value of Extra Segment Register (ES). + + Reads and returns the current value of ES. This function is only available on + IA-32 and X64. + + @return The current value of ES. + +**/ +UINT16 +EFIAPI +AsmReadEs ( + VOID + ); + +/** + Reads the current value of FS Data Segment Register (FS). + + Reads and returns the current value of FS. This function is only available on + IA-32 and X64. + + @return The current value of FS. + +**/ +UINT16 +EFIAPI +AsmReadFs ( + VOID + ); + +/** + Reads the current value of GS Data Segment Register (GS). + + Reads and returns the current value of GS. This function is only available on + IA-32 and X64. + + @return The current value of GS. + +**/ +UINT16 +EFIAPI +AsmReadGs ( + VOID + ); + +/** + Reads the current value of Stack Segment Register (SS). + + Reads and returns the current value of SS. This function is only available on + IA-32 and X64. + + @return The current value of SS. + +**/ +UINT16 +EFIAPI +AsmReadSs ( + VOID + ); + +/** + Reads the current value of Task Register (TR). + + Reads and returns the current value of TR. This function is only available on + IA-32 and X64. + + @return The current value of TR. + +**/ +UINT16 +EFIAPI +AsmReadTr ( + VOID + ); + +/** + Reads the current Global Descriptor Table Register(GDTR) descriptor. + + Reads and returns the current GDTR descriptor and returns it in Gdtr. This + function is only available on IA-32 and X64. + + If Gdtr is NULL, then ASSERT(). + + @param Gdtr Pointer to a GDTR descriptor. + +**/ +VOID +EFIAPI +AsmReadGdtr ( + OUT IA32_DESCRIPTOR *Gdtr + ); + +/** + Writes the current Global Descriptor Table Register (GDTR) descriptor. + + Writes and the current GDTR descriptor specified by Gdtr. This function is + only available on IA-32 and X64. + + If Gdtr is NULL, then ASSERT(). + + @param Gdtr Pointer to a GDTR descriptor. + +**/ +VOID +EFIAPI +AsmWriteGdtr ( + IN CONST IA32_DESCRIPTOR *Gdtr + ); + +/** + Reads the current Interrupt Descriptor Table Register(GDTR) descriptor. + + Reads and returns the current IDTR descriptor and returns it in Idtr. This + function is only available on IA-32 and X64. + + If Idtr is NULL, then ASSERT(). + + @param Idtr Pointer to a IDTR descriptor. + +**/ +VOID +EFIAPI +AsmReadIdtr ( + OUT IA32_DESCRIPTOR *Idtr + ); + +/** + Writes the current Interrupt Descriptor Table Register(GDTR) descriptor. + + Writes the current IDTR descriptor and returns it in Idtr. This function is + only available on IA-32 and X64. + + If Idtr is NULL, then ASSERT(). + + @param Idtr Pointer to a IDTR descriptor. + +**/ +VOID +EFIAPI +AsmWriteIdtr ( + IN CONST IA32_DESCRIPTOR *Idtr + ); + +/** + Reads the current Local Descriptor Table Register(LDTR) selector. + + Reads and returns the current 16-bit LDTR descriptor value. This function is + only available on IA-32 and X64. + + @return The current selector of LDT. + +**/ +UINT16 +EFIAPI +AsmReadLdtr ( + VOID + ); + +/** + Writes the current Local Descriptor Table Register (GDTR) selector. + + Writes and the current LDTR descriptor specified by Ldtr. This function is + only available on IA-32 and X64. + + @param Ldtr 16-bit LDTR selector value. + +**/ +VOID +EFIAPI +AsmWriteLdtr ( + IN UINT16 Ldtr + ); + +/** + Save the current floating point/SSE/SSE2 context to a buffer. + + Saves the current floating point/SSE/SSE2 state to the buffer specified by + Buffer. Buffer must be aligned on a 16-byte boundary. This function is only + available on IA-32 and X64. + + If Buffer is NULL, then ASSERT(). + If Buffer is not aligned on a 16-byte boundary, then ASSERT(). + + @param Buffer Pointer to a buffer to save the floating point/SSE/SSE2 context. + +**/ +VOID +EFIAPI +AsmFxSave ( + OUT IA32_FX_BUFFER *Buffer + ); + +/** + Restores the current floating point/SSE/SSE2 context from a buffer. + + Restores the current floating point/SSE/SSE2 state from the buffer specified + by Buffer. Buffer must be aligned on a 16-byte boundary. This function is + only available on IA-32 and X64. + + If Buffer is NULL, then ASSERT(). + If Buffer is not aligned on a 16-byte boundary, then ASSERT(). + If Buffer was not saved with AsmFxSave(), then ASSERT(). + + @param Buffer Pointer to a buffer to save the floating point/SSE/SSE2 context. + +**/ +VOID +EFIAPI +AsmFxRestore ( + IN CONST IA32_FX_BUFFER *Buffer + ); + +/** + Reads the current value of 64-bit MMX Register #0 (MM0). + + Reads and returns the current value of MM0. This function is only available + on IA-32 and X64. + + @return The current value of MM0. + +**/ +UINT64 +EFIAPI +AsmReadMm0 ( + VOID + ); + +/** + Reads the current value of 64-bit MMX Register #1 (MM1). + + Reads and returns the current value of MM1. This function is only available + on IA-32 and X64. + + @return The current value of MM1. + +**/ +UINT64 +EFIAPI +AsmReadMm1 ( + VOID + ); + +/** + Reads the current value of 64-bit MMX Register #2 (MM2). + + Reads and returns the current value of MM2. This function is only available + on IA-32 and X64. + + @return The current value of MM2. + +**/ +UINT64 +EFIAPI +AsmReadMm2 ( + VOID + ); + +/** + Reads the current value of 64-bit MMX Register #3 (MM3). + + Reads and returns the current value of MM3. This function is only available + on IA-32 and X64. + + @return The current value of MM3. + +**/ +UINT64 +EFIAPI +AsmReadMm3 ( + VOID + ); + +/** + Reads the current value of 64-bit MMX Register #4 (MM4). + + Reads and returns the current value of MM4. This function is only available + on IA-32 and X64. + + @return The current value of MM4. + +**/ +UINT64 +EFIAPI +AsmReadMm4 ( + VOID + ); + +/** + Reads the current value of 64-bit MMX Register #5 (MM5). + + Reads and returns the current value of MM5. This function is only available + on IA-32 and X64. + + @return The current value of MM5. + +**/ +UINT64 +EFIAPI +AsmReadMm5 ( + VOID + ); + +/** + Reads the current value of 64-bit MMX Register #6 (MM6). + + Reads and returns the current value of MM6. This function is only available + on IA-32 and X64. + + @return The current value of MM6. + +**/ +UINT64 +EFIAPI +AsmReadMm6 ( + VOID + ); + +/** + Reads the current value of 64-bit MMX Register #7 (MM7). + + Reads and returns the current value of MM7. This function is only available + on IA-32 and X64. + + @return The current value of MM7. + +**/ +UINT64 +EFIAPI +AsmReadMm7 ( + VOID + ); + +/** + Writes the current value of 64-bit MMX Register #0 (MM0). + + Writes the current value of MM0. This function is only available on IA32 and + X64. + + @param Value The 64-bit value to write to MM0. + +**/ +VOID +EFIAPI +AsmWriteMm0 ( + IN UINT64 Value + ); + +/** + Writes the current value of 64-bit MMX Register #1 (MM1). + + Writes the current value of MM1. This function is only available on IA32 and + X64. + + @param Value The 64-bit value to write to MM1. + +**/ +VOID +EFIAPI +AsmWriteMm1 ( + IN UINT64 Value + ); + +/** + Writes the current value of 64-bit MMX Register #2 (MM2). + + Writes the current value of MM2. This function is only available on IA32 and + X64. + + @param Value The 64-bit value to write to MM2. + +**/ +VOID +EFIAPI +AsmWriteMm2 ( + IN UINT64 Value + ); + +/** + Writes the current value of 64-bit MMX Register #3 (MM3). + + Writes the current value of MM3. This function is only available on IA32 and + X64. + + @param Value The 64-bit value to write to MM3. + +**/ +VOID +EFIAPI +AsmWriteMm3 ( + IN UINT64 Value + ); + +/** + Writes the current value of 64-bit MMX Register #4 (MM4). + + Writes the current value of MM4. This function is only available on IA32 and + X64. + + @param Value The 64-bit value to write to MM4. + +**/ +VOID +EFIAPI +AsmWriteMm4 ( + IN UINT64 Value + ); + +/** + Writes the current value of 64-bit MMX Register #5 (MM5). + + Writes the current value of MM5. This function is only available on IA32 and + X64. + + @param Value The 64-bit value to write to MM5. + +**/ +VOID +EFIAPI +AsmWriteMm5 ( + IN UINT64 Value + ); + +/** + Writes the current value of 64-bit MMX Register #6 (MM6). + + Writes the current value of MM6. This function is only available on IA32 and + X64. + + @param Value The 64-bit value to write to MM6. + +**/ +VOID +EFIAPI +AsmWriteMm6 ( + IN UINT64 Value + ); + +/** + Writes the current value of 64-bit MMX Register #7 (MM7). + + Writes the current value of MM7. This function is only available on IA32 and + X64. + + @param Value The 64-bit value to write to MM7. + +**/ +VOID +EFIAPI +AsmWriteMm7 ( + IN UINT64 Value + ); + +/** + Reads the current value of Time Stamp Counter (TSC). + + Reads and returns the current value of TSC. This function is only available + on IA-32 and X64. + + @return The current value of TSC + +**/ +UINT64 +EFIAPI +AsmReadTsc ( + VOID + ); + +/** + Reads the current value of a Performance Counter (PMC). + + Reads and returns the current value of performance counter specified by + Index. This function is only available on IA-32 and X64. + + @param Index The 32-bit Performance Counter index to read. + + @return The value of the PMC specified by Index. + +**/ +UINT64 +EFIAPI +AsmReadPmc ( + IN UINT32 Index + ); + +/** + Sets up a monitor buffer that is used by AsmMwait(). + + Executes a MONITOR instruction with the register state specified by Eax, Ecx + and Edx. Returns Eax. This function is only available on IA-32 and X64. + + @param Eax The value to load into EAX or RAX before executing the MONITOR + instruction. + @param Ecx The value to load into ECX or RCX before executing the MONITOR + instruction. + @param Edx The value to load into EDX or RDX before executing the MONITOR + instruction. + + @return Eax + +**/ +UINTN +EFIAPI +AsmMonitor ( + IN UINTN Eax, + IN UINTN Ecx, + IN UINTN Edx + ); + +/** + Executes an MWAIT instruction. + + Executes an MWAIT instruction with the register state specified by Eax and + Ecx. Returns Eax. This function is only available on IA-32 and X64. + + @param Eax The value to load into EAX or RAX before executing the MONITOR + instruction. + @param Ecx The value to load into ECX or RCX before executing the MONITOR + instruction. + + @return Eax + +**/ +UINTN +EFIAPI +AsmMwait ( + IN UINTN Eax, + IN UINTN Ecx + ); + +/** + Executes a WBINVD instruction. + + Executes a WBINVD instruction. This function is only available on IA-32 and + X64. + +**/ +VOID +EFIAPI +AsmWbinvd ( + VOID + ); + +/** + Executes a INVD instruction. + + Executes a INVD instruction. This function is only available on IA-32 and + X64. + +**/ +VOID +EFIAPI +AsmInvd ( + VOID + ); + +/** + Flushes a cache line from all the instruction and data caches within the + coherency domain of the CPU. + + Flushed the cache line specified by LinearAddress, and returns LinearAddress. + This function is only available on IA-32 and X64. + + @param LinearAddress The address of the cache line to flush. If the CPU is + in a physical addressing mode, then LinearAddress is a + physical address. If the CPU is in a virtual + addressing mode, then LinearAddress is a virtual + address. + + @return LinearAddress +**/ +VOID * +EFIAPI +AsmFlushCacheLine ( + IN VOID *LinearAddress + ); + +/** + Enables the 32-bit paging mode on the CPU. + + Enables the 32-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables + must be properly initialized prior to calling this service. This function + assumes the current execution mode is 32-bit protected mode. This function is + only available on IA-32. After the 32-bit paging mode is enabled, control is + transferred to the function specified by EntryPoint using the new stack + specified by NewStack and passing in the parameters specified by Context1 and + Context2. Context1 and Context2 are optional and may be NULL. The function + EntryPoint must never return. + + If the current execution mode is not 32-bit protected mode, then ASSERT(). + If EntryPoint is NULL, then ASSERT(). + If NewStack is NULL, then ASSERT(). + + There are a number of constraints that must be followed before calling this + function: + 1) Interrupts must be disabled. + 2) The caller must be in 32-bit protected mode with flat descriptors. This + means all descriptors must have a base of 0 and a limit of 4GB. + 3) CR0 and CR4 must be compatible with 32-bit protected mode with flat + descriptors. + 4) CR3 must point to valid page tables that will be used once the transition + is complete, and those page tables must guarantee that the pages for this + function and the stack are identity mapped. + + @param EntryPoint A pointer to function to call with the new stack after + paging is enabled. + @param Context1 A pointer to the context to pass into the EntryPoint + function as the first parameter after paging is enabled. + @param Context2 A pointer to the context to pass into the EntryPoint + function as the second parameter after paging is enabled. + @param NewStack A pointer to the new stack to use for the EntryPoint + function after paging is enabled. + +**/ +VOID +EFIAPI +AsmEnablePaging32 ( + IN SWITCH_STACK_ENTRY_POINT EntryPoint, + IN VOID *Context1, OPTIONAL + IN VOID *Context2, OPTIONAL + IN VOID *NewStack + ); + +/** + Disables the 32-bit paging mode on the CPU. + + Disables the 32-bit paging mode on the CPU and returns to 32-bit protected + mode. This function assumes the current execution mode is 32-paged protected + mode. This function is only available on IA-32. After the 32-bit paging mode + is disabled, control is transferred to the function specified by EntryPoint + using the new stack specified by NewStack and passing in the parameters + specified by Context1 and Context2. Context1 and Context2 are optional and + may be NULL. The function EntryPoint must never return. + + If the current execution mode is not 32-bit paged mode, then ASSERT(). + If EntryPoint is NULL, then ASSERT(). + If NewStack is NULL, then ASSERT(). + + There are a number of constraints that must be followed before calling this + function: + 1) Interrupts must be disabled. + 2) The caller must be in 32-bit paged mode. + 3) CR0, CR3, and CR4 must be compatible with 32-bit paged mode. + 4) CR3 must point to valid page tables that guarantee that the pages for + this function and the stack are identity mapped. + + @param EntryPoint A pointer to function to call with the new stack after + paging is disabled. + @param Context1 A pointer to the context to pass into the EntryPoint + function as the first parameter after paging is disabled. + @param Context2 A pointer to the context to pass into the EntryPoint + function as the second parameter after paging is + disabled. + @param NewStack A pointer to the new stack to use for the EntryPoint + function after paging is disabled. + +**/ +VOID +EFIAPI +AsmDisablePaging32 ( + IN SWITCH_STACK_ENTRY_POINT EntryPoint, + IN VOID *Context1, OPTIONAL + IN VOID *Context2, OPTIONAL + IN VOID *NewStack + ); + +/** + Enables the 64-bit paging mode on the CPU. + + Enables the 64-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables + must be properly initialized prior to calling this service. This function + assumes the current execution mode is 32-bit protected mode with flat + descriptors. This function is only available on IA-32. After the 64-bit + paging mode is enabled, control is transferred to the function specified by + EntryPoint using the new stack specified by NewStack and passing in the + parameters specified by Context1 and Context2. Context1 and Context2 are + optional and may be 0. The function EntryPoint must never return. + + If the current execution mode is not 32-bit protected mode with flat + descriptors, then ASSERT(). + If EntryPoint is 0, then ASSERT(). + If NewStack is 0, then ASSERT(). + + @param Cs The 16-bit selector to load in the CS before EntryPoint + is called. The descriptor in the GDT that this selector + references must be setup for long mode. + @param EntryPoint The 64-bit virtual address of the function to call with + the new stack after paging is enabled. + @param Context1 The 64-bit virtual address of the context to pass into + the EntryPoint function as the first parameter after + paging is enabled. + @param Context2 The 64-bit virtual address of the context to pass into + the EntryPoint function as the second parameter after + paging is enabled. + @param NewStack The 64-bit virtual address of the new stack to use for + the EntryPoint function after paging is enabled. + +**/ +VOID +EFIAPI +AsmEnablePaging64 ( + IN UINT16 CodeSelector, + IN UINT64 EntryPoint, + IN UINT64 Context1, OPTIONAL + IN UINT64 Context2, OPTIONAL + IN UINT64 NewStack + ); + +/** + Disables the 64-bit paging mode on the CPU. + + Disables the 64-bit paging mode on the CPU and returns to 32-bit protected + mode. This function assumes the current execution mode is 64-paging mode. + This function is only available on X64. After the 64-bit paging mode is + disabled, control is transferred to the function specified by EntryPoint + using the new stack specified by NewStack and passing in the parameters + specified by Context1 and Context2. Context1 and Context2 are optional and + may be 0. The function EntryPoint must never return. + + If the current execution mode is not 64-bit paged mode, then ASSERT(). + If EntryPoint is 0, then ASSERT(). + If NewStack is 0, then ASSERT(). + + @param Cs The 16-bit selector to load in the CS before EntryPoint + is called. The descriptor in the GDT that this selector + references must be setup for 32-bit protected mode. + @param EntryPoint The 64-bit virtual address of the function to call with + the new stack after paging is disabled. + @param Context1 The 64-bit virtual address of the context to pass into + the EntryPoint function as the first parameter after + paging is disabled. + @param Context2 The 64-bit virtual address of the context to pass into + the EntryPoint function as the second parameter after + paging is disabled. + @param NewStack The 64-bit virtual address of the new stack to use for + the EntryPoint function after paging is disabled. + +**/ +VOID +EFIAPI +AsmDisablePaging64 ( + IN UINT16 CodeSelector, + IN UINT32 EntryPoint, + IN UINT32 Context1, OPTIONAL + IN UINT32 Context2, OPTIONAL + IN UINT32 NewStack + ); + +// +// 16-bit thunking services +// + +/** + Retrieves the properties for 16-bit thunk functions. + + Computes the size of the buffer and stack below 1MB required to use the + AsmPrepareThunk16(), AsmThunk16() and AsmPrepareAndThunk16() functions. This + buffer size is returned in RealModeBufferSize, and the stack size is returned + in ExtraStackSize. If parameters are passed to the 16-bit real mode code, + then the actual minimum stack size is ExtraStackSize plus the maximum number + of bytes that need to be passed to the 16-bit real mode code. + + If RealModeBufferSize is NULL, then ASSERT(). + If ExtraStackSize is NULL, then ASSERT(). + + @param RealModeBufferSize A pointer to the size of the buffer below 1MB + required to use the 16-bit thunk functions. + @param ExtraStackSize A pointer to the extra size of stack below 1MB + that the 16-bit thunk functions require for + temporary storage in the transition to and from + 16-bit real mode. + +**/ +VOID +EFIAPI +AsmGetThunk16Properties ( + OUT UINT32 *RealModeBufferSize, + OUT UINT32 *ExtraStackSize + ); + +/** + Prepares all structures a code required to use AsmThunk16(). + + Prepares all structures and code required to use AsmThunk16(). + + If ThunkContext is NULL, then ASSERT(). + + @param ThunkContext A pointer to the context structure that describes the + 16-bit real mode code to call. + +**/ +VOID +EFIAPI +AsmPrepareThunk16 ( + OUT THUNK_CONTEXT *ThunkContext + ); + +/** + Transfers control to a 16-bit real mode entry point and returns the results. + + Transfers control to a 16-bit real mode entry point and returns the results. + AsmPrepareThunk16() must be called with ThunkContext before this function is + used. + + If ThunkContext is NULL, then ASSERT(). + If AsmPrepareThunk16() was not previously called with ThunkContext, then ASSERT(). + + @param ThunkContext A pointer to the context structure that describes the + 16-bit real mode code to call. + +**/ +VOID +EFIAPI +AsmThunk16 ( + IN OUT THUNK_CONTEXT *ThunkContext + ); + +/** + Prepares all structures and code for a 16-bit real mode thunk, transfers + control to a 16-bit real mode entry point, and returns the results. + + Prepares all structures and code for a 16-bit real mode thunk, transfers + control to a 16-bit real mode entry point, and returns the results. If the + caller only need to perform a single 16-bit real mode thunk, then this + service should be used. If the caller intends to make more than one 16-bit + real mode thunk, then it is more efficient if AsmPrepareThunk16() is called + once and AsmThunk16() can be called for each 16-bit real mode thunk. + + If ThunkContext is NULL, then ASSERT(). + + @param ThunkContext A pointer to the context structure that describes the + 16-bit real mode code to call. + +**/ +VOID +EFIAPI +AsmPrepareAndThunk16 ( + IN OUT THUNK_CONTEXT *ThunkContext + ); + +/** + Transfers control to a function starting with a new stack. + + Transfers control to the function specified by EntryPoint using the new stack + specified by NewStack and passing in the parameters specified by Context1 and + Context2. Context1 and Context2 are optional and may be NULL. The function + EntryPoint must never return. + + If EntryPoint is NULL, then ASSERT(). + If NewStack is NULL, then ASSERT(). + + @param EntryPoint A pointer to function to call with the new stack. + @param Context1 A pointer to the context to pass into the EntryPoint + function. + @param Context2 A pointer to the context to pass into the EntryPoint + function. + @param NewStack A pointer to the new stack to use for the EntryPoint + function. + @param NewBsp A pointer to the new memory location for RSE backing + store. + +**/ +VOID +EFIAPI +AsmSwitchStackAndBackingStore ( + IN SWITCH_STACK_ENTRY_POINT EntryPoint, + IN VOID *Context1, OPTIONAL + IN VOID *Context2, OPTIONAL + IN VOID *NewStack, + IN VOID *NewBsp + ); + +#endif diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueBaseMemoryLib.h b/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueBaseMemoryLib.h new file mode 100644 index 0000000..cd9468f --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueBaseMemoryLib.h @@ -0,0 +1,391 @@ +/*++ + +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: + + EdkIIGlueBaseMemoryLib.h + +Abstract: + + Memory-only library functions with no library constructor/destructor + +--*/ + +#ifndef __EDKII_GLUE_BASE_MEMORY_LIB_H__ +#define __EDKII_GLUE_BASE_MEMORY_LIB_H__ + + +#define CopyMem(_DESTINATIONBUFFER, _SOURCEBUFFER, _LENGTH) GlueCopyMem(_DESTINATIONBUFFER, _SOURCEBUFFER, _LENGTH) +#define ZeroMem(_BUFFER, _LENGTH) GlueZeroMem(_BUFFER, _LENGTH) +#define SetMem(_BUFFER, _LENGTH, _VALUE) GlueSetMem(_BUFFER, _LENGTH, _VALUE) +#define CompareMem(_DESTINATIONBUFFER, _SOURCEBUFFER, _LENGTH) GlueCompareMem(_DESTINATIONBUFFER, _SOURCEBUFFER, _LENGTH) +#define CompareGuid(_GUID1, _GUID2) GlueCompareGuid(_GUID1, _GUID2) + + +/** + Copies a source buffer to a destination buffer, and returns the destination buffer. + + This function copies Length bytes from SourceBuffer to DestinationBuffer, and returns + DestinationBuffer. The implementation must be reentrant, and it must handle the case + where SourceBuffer overlaps DestinationBuffer. + If Length is greater than (MAX_ADDRESS - DestinationBuffer + 1), then ASSERT(). + If Length is greater than (MAX_ADDRESS - SourceBuffer + 1), then ASSERT(). + + @param DestinationBuffer Pointer to the destination buffer of the memory copy. + @param SourceBuffer Pointer to the source buffer of the memory copy. + @param Length Number of bytes to copy from SourceBuffer to DestinationBuffer. + + @return DestinationBuffer. + +**/ +VOID * +EFIAPI +GlueCopyMem ( + OUT VOID *DestinationBuffer, + IN CONST VOID *SourceBuffer, + IN UINTN Length + ); + +/** + Fills a target buffer with a byte value, and returns the target buffer. + + This function fills Length bytes of Buffer with Value, and returns Buffer. + If Length is greater than (MAX_ADDRESS ?Buffer + 1), then ASSERT(). + + @param Buffer Memory to set. + @param Length Number of bytes to set. + @param Value Value of the set operation. + + @return Buffer. + +**/ +VOID * +EFIAPI +GlueSetMem ( + OUT VOID *Buffer, + IN UINTN Length, + IN UINT8 Value + ); + +/** + Fills a target buffer with a 16-bit value, and returns the target buffer. + + This function fills Length bytes of Buffer with the 16-bit value specified by + Value, and returns Buffer. Value is repeated every 16-bits in for Length + bytes of Buffer. + + If Length > 0 and Buffer is NULL, then ASSERT(). + If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). + If Buffer is not aligned on a 16-bit boundary, then ASSERT(). + If Length is not aligned on a 16-bit boundary, then ASSERT(). + + @param Buffer Pointer to the target buffer to fill. + @param Length Number of bytes in Buffer to fill. + @param Value Value with which to fill Length bytes of Buffer. + + @return Buffer. + +**/ +VOID * +EFIAPI +SetMem16 ( + OUT VOID *Buffer, + IN UINTN Length, + IN UINT16 Value + ); + +/** + Fills a target buffer with a 32-bit value, and returns the target buffer. + + This function fills Length bytes of Buffer with the 32-bit value specified by + Value, and returns Buffer. Value is repeated every 32-bits in for Length + bytes of Buffer. + + If Length > 0 and Buffer is NULL, then ASSERT(). + If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). + If Buffer is not aligned on a 32-bit boundary, then ASSERT(). + If Length is not aligned on a 32-bit boundary, then ASSERT(). + + @param Buffer Pointer to the target buffer to fill. + @param Length Number of bytes in Buffer to fill. + @param Value Value with which to fill Length bytes of Buffer. + + @return Buffer. + +**/ +VOID * +EFIAPI +SetMem32 ( + OUT VOID *Buffer, + IN UINTN Length, + IN UINT32 Value + ); + +/** + Fills a target buffer with a 64-bit value, and returns the target buffer. + + This function fills Length bytes of Buffer with the 64-bit value specified by + Value, and returns Buffer. Value is repeated every 64-bits in for Length + bytes of Buffer. + + If Length > 0 and Buffer is NULL, then ASSERT(). + If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). + If Buffer is not aligned on a 64-bit boundary, then ASSERT(). + If Length is not aligned on a 64-bit boundary, then ASSERT(). + + @param Buffer Pointer to the target buffer to fill. + @param Length Number of bytes in Buffer to fill. + @param Value Value with which to fill Length bytes of Buffer. + + @return Buffer. + +**/ +VOID * +EFIAPI +SetMem64 ( + OUT VOID *Buffer, + IN UINTN Length, + IN UINT64 Value + ); + +/** + Fills a target buffer with zeros, and returns the target buffer. + + This function fills Length bytes of Buffer with zeros, and returns Buffer. + If Length > 0 and Buffer is NULL, then ASSERT(). + If Length is greater than (MAX_ADDRESS ?Buffer + 1), then ASSERT(). + + @param Buffer Pointer to the target buffer to fill with zeros. + @param Length Number of bytes in Buffer to fill with zeros. + + @return Buffer. + +**/ +VOID * +EFIAPI +GlueZeroMem ( + OUT VOID *Buffer, + IN UINTN Length + ); + +/** + Compares the contents of two buffers. + + This function compares Length bytes of SourceBuffer to Length bytes of DestinationBuffer. + If all Length bytes of the two buffers are identical, then 0 is returned. Otherwise, the + value returned is the first mismatched byte in SourceBuffer subtracted from the first + mismatched byte in DestinationBuffer. + If Length > 0 and DestinationBuffer is NULL and Length > 0, then ASSERT(). + If Length > 0 and SourceBuffer is NULL and Length > 0, then ASSERT(). + If Length is greater than (MAX_ADDRESS - DestinationBuffer + 1), then ASSERT(). + If Length is greater than (MAX_ADDRESS - SourceBuffer + 1), then ASSERT(). + + @param DestinationBuffer Pointer to the destination buffer to compare. + @param SourceBuffer Pointer to the source buffer to compare. + @param Length Number of bytes to compare. + + @return 0 All Length bytes of the two buffers are identical. + @retval Non-zero The first mismatched byte in SourceBuffer subtracted from the first + mismatched byte in DestinationBuffer. + +**/ +INTN +EFIAPI +GlueCompareMem ( + IN CONST VOID *DestinationBuffer, + IN CONST VOID *SourceBuffer, + IN UINTN Length + ); + +/** + Scans a target buffer for an 8-bit value, and returns a pointer to the matching 8-bit value + in the target buffer. + + This function searches target the buffer specified by Buffer and Length from the lowest + address to the highest address for an 8-bit value that matches Value. If a match is found, + then a pointer to the matching byte in the target buffer is returned. If no match is found, + then NULL is returned. If Length is 0, then NULL is returned. + If Length > 0 and Buffer is NULL, then ASSERT(). + If Length is greater than (MAX_ADDRESS ?Buffer + 1), then ASSERT(). + + @param Buffer Pointer to the target buffer to scan. + @param Length Number of bytes in Buffer to scan. + @param Value Value to search for in the target buffer. + + @return A pointer to the matching byte in the target buffer or NULL otherwise. + +**/ +VOID * +EFIAPI +ScanMem8 ( + IN CONST VOID *Buffer, + IN UINTN Length, + IN UINT8 Value + ); + +/** + Scans a target buffer for a 16-bit value, and returns a pointer to the matching 16-bit value + in the target buffer. + + This function searches target the buffer specified by Buffer and Length from the lowest + address to the highest address for a 16-bit value that matches Value. If a match is found, + then a pointer to the matching byte in the target buffer is returned. If no match is found, + then NULL is returned. If Length is 0, then NULL is returned. + If Length > 0 and Buffer is NULL, then ASSERT(). + If Buffer is not aligned on a 16-bit boundary, then ASSERT(). + If Length is not aligned on a 16-bit boundary, then ASSERT(). + If Length is greater than (MAX_ADDRESS ?Buffer + 1), then ASSERT(). + + @param Buffer Pointer to the target buffer to scan. + @param Length Number of bytes in Buffer to scan. + @param Value Value to search for in the target buffer. + + @return A pointer to the matching byte in the target buffer or NULL otherwise. + +**/ +VOID * +EFIAPI +ScanMem16 ( + IN CONST VOID *Buffer, + IN UINTN Length, + IN UINT16 Value + ); + +/** + Scans a target buffer for a 32-bit value, and returns a pointer to the matching 32-bit value + in the target buffer. + + This function searches target the buffer specified by Buffer and Length from the lowest + address to the highest address for a 32-bit value that matches Value. If a match is found, + then a pointer to the matching byte in the target buffer is returned. If no match is found, + then NULL is returned. If Length is 0, then NULL is returned. + If Length > 0 and Buffer is NULL, then ASSERT(). + If Buffer is not aligned on a 32-bit boundary, then ASSERT(). + If Length is not aligned on a 32-bit boundary, then ASSERT(). + If Length is greater than (MAX_ADDRESS ?Buffer + 1), then ASSERT(). + + @param Buffer Pointer to the target buffer to scan. + @param Length Number of bytes in Buffer to scan. + @param Value Value to search for in the target buffer. + + @return A pointer to the matching byte in the target buffer or NULL otherwise. + +**/ +VOID * +EFIAPI +ScanMem32 ( + IN CONST VOID *Buffer, + IN UINTN Length, + IN UINT32 Value + ); + +/** + Scans a target buffer for a 64-bit value, and returns a pointer to the matching 64-bit value + in the target buffer. + + This function searches target the buffer specified by Buffer and Length from the lowest + address to the highest address for a 64-bit value that matches Value. If a match is found, + then a pointer to the matching byte in the target buffer is returned. If no match is found, + then NULL is returned. If Length is 0, then NULL is returned. + If Length > 0 and Buffer is NULL, then ASSERT(). + If Buffer is not aligned on a 64-bit boundary, then ASSERT(). + If Length is not aligned on a 64-bit boundary, then ASSERT(). + If Length is greater than (MAX_ADDRESS ?Buffer + 1), then ASSERT(). + + @param Buffer Pointer to the target buffer to scan. + @param Length Number of bytes in Buffer to scan. + @param Value Value to search for in the target buffer. + + @return A pointer to the matching byte in the target buffer or NULL otherwise. + +**/ +VOID * +EFIAPI +ScanMem64 ( + IN CONST VOID *Buffer, + IN UINTN Length, + IN UINT64 Value + ); + +/** + Copies a source GUID to a destination GUID. + + This function copies the contents of the 128-bit GUID specified by SourceGuid to + DestinationGuid, and returns DestinationGuid. + If DestinationGuid is NULL, then ASSERT(). + If SourceGuid is NULL, then ASSERT(). + + @param DestinationGuid Pointer to the destination GUID. + @param SourceGuid Pointer to the source GUID. + + @return DestinationGuid. + +**/ +GUID * +EFIAPI +CopyGuid ( + OUT GUID *DestinationGuid, + IN CONST GUID *SourceGuid + ); + +/** + Compares two GUIDs. + + This function compares Guid1 to Guid2. If the GUIDs are identical then TRUE is returned. + If there are any bit differences in the two GUIDs, then FALSE is returned. + If Guid1 is NULL, then ASSERT(). + If Guid2 is NULL, then ASSERT(). + + @param Guid1 A pointer to a 128 bit GUID. + @param Guid2 A pointer to a 128 bit GUID. + + @retval TRUE Guid1 and Guid2 are identical. + @retval FALSE Guid1 and Guid2 are not identical. + +**/ +BOOLEAN +EFIAPI +GlueCompareGuid ( + IN CONST GUID *Guid1, + IN CONST GUID *Guid2 + ); + +/** + Scans a target buffer for a GUID, and returns a pointer to the matching GUID + in the target buffer. + + This function searches target the buffer specified by Buffer and Length from + the lowest address to the highest address at 128-bit increments for the 128-bit + GUID value that matches Guid. If a match is found, then a pointer to the matching + GUID in the target buffer is returned. If no match is found, then NULL is returned. + If Length is 0, then NULL is returned. + If Length > 0 and Buffer is NULL, then ASSERT(). + If Buffer is not aligned on a 32-bit boundary, then ASSERT(). + If Length is not aligned on a 128-bit boundary, then ASSERT(). + If Length is greater than (MAX_ADDRESS ?Buffer + 1), then ASSERT(). + + @param Buffer Pointer to the target buffer to scan. + @param Length Number of bytes in Buffer to scan. + @param Guid Value to search for in the target buffer. + + @return A pointer to the matching Guid in the target buffer or NULL otherwise. + +**/ +VOID * +EFIAPI +ScanGuid ( + IN CONST VOID *Buffer, + IN UINTN Length, + IN CONST GUID *Guid + ); + +#endif diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueCacheMaintenanceLib.h b/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueCacheMaintenanceLib.h new file mode 100644 index 0000000..48c244c --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueCacheMaintenanceLib.h @@ -0,0 +1,224 @@ +/*++ + +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: + + EdkIIGlueCacheMaintenanceLib.h + +Abstract: + + Cache Maintenance Functions + +--*/ + +#ifndef __EDKII_GLUE_CACHE_MAINTENANCE_LIB_H__ +#define __EDKII_GLUE_CACHE_MAINTENANCE_LIB_H__ + + +#define InvalidateInstructionCache() GlueInvalidateInstructionCache() + + +/** + Invalidates the entire instruction cache in cache coherency domain of the + calling CPU. + + Invalidates the entire instruction cache in cache coherency domain of the + calling CPU. + +**/ +VOID +EFIAPI +GlueInvalidateInstructionCache ( + VOID + ); + +/** + Invalidates a range of instruction cache lines in the cache coherency domain + of the calling CPU. + + Invalidates the instruction cache lines specified by Address and Length. If + Address is not aligned on a cache line boundary, then entire instruction + cache line containing Address is invalidated. If Address + Length is not + aligned on a cache line boundary, then the entire instruction cache line + containing Address + Length -1 is invalidated. This function may choose to + invalidate the entire instruction cache if that is more efficient than + invalidating the specified range. If Length is 0, the no instruction cache + lines are invalidated. Address is returned. + + If Length is greater than (MAX_ADDRESS - Address + 1), then ASSERT(). + + @param Address The base address of the instruction cache lines to + invalidate. If the CPU is in a physical addressing mode, then + Address is a physical address. If the CPU is in a virtual + addressing mode, then Address is a virtual address. + + @param Length The number of bytes to invalidate from the instruction cache. + + @return Address + +**/ +VOID * +EFIAPI +InvalidateInstructionCacheRange ( + IN VOID *Address, + IN UINTN Length + ); + +/** + Writes Back and Invalidates the entire data cache in cache coherency domain + of the calling CPU. + + Writes Back and Invalidates the entire data cache in cache coherency domain + of the calling CPU. This function guarantees that all dirty cache lines are + written back to system memory, and also invalidates all the data cache lines + in the cache coherency domain of the calling CPU. + +**/ +VOID +EFIAPI +WriteBackInvalidateDataCache ( + VOID + ); + +/** + Writes Back and Invalidates a range of data cache lines in the cache + coherency domain of the calling CPU. + + Writes Back and Invalidate the data cache lines specified by Address and + Length. If Address is not aligned on a cache line boundary, then entire data + cache line containing Address is written back and invalidated. If Address + + Length is not aligned on a cache line boundary, then the entire data cache + line containing Address + Length -1 is written back and invalidated. This + function may choose to write back and invalidate the entire data cache if + that is more efficient than writing back and invalidating the specified + range. If Length is 0, the no data cache lines are written back and + invalidated. Address is returned. + + If Length is greater than (MAX_ADDRESS - Address + 1), then ASSERT(). + + @param Address The base address of the data cache lines to write back and + invalidate. If the CPU is in a physical addressing mode, then + Address is a physical address. If the CPU is in a virtual + addressing mode, then Address is a virtual address. + @param Length The number of bytes to write back and invalidate from the + data cache. + + @return Address + +**/ +VOID * +EFIAPI +WriteBackInvalidateDataCacheRange ( + IN VOID *Address, + IN UINTN Length + ); + +/** + Writes Back the entire data cache in cache coherency domain of the calling + CPU. + + Writes Back the entire data cache in cache coherency domain of the calling + CPU. This function guarantees that all dirty cache lines are written back to + system memory. This function may also invalidate all the data cache lines in + the cache coherency domain of the calling CPU. + +**/ +VOID +EFIAPI +WriteBackDataCache ( + VOID + ); + +/** + Writes Back a range of data cache lines in the cache coherency domain of the + calling CPU. + + Writes Back the data cache lines specified by Address and Length. If Address + is not aligned on a cache line boundary, then entire data cache line + containing Address is written back. If Address + Length is not aligned on a + cache line boundary, then the entire data cache line containing Address + + Length -1 is written back. This function may choose to write back the entire + data cache if that is more efficient than writing back the specified range. + If Length is 0, the no data cache lines are written back. This function may + also invalidate all the data cache lines in the specified range of the cache + coherency domain of the calling CPU. Address is returned. + + If Length is greater than (MAX_ADDRESS - Address + 1), then ASSERT(). + + @param Address The base address of the data cache lines to write back. If + the CPU is in a physical addressing mode, then Address is a + physical address. If the CPU is in a virtual addressing + mode, then Address is a virtual address. + @param Length The number of bytes to write back from the data cache. + + @return Address + +**/ +VOID * +EFIAPI +WriteBackDataCacheRange ( + IN VOID *Address, + IN UINTN Length + ); + +/** + Invalidates the entire data cache in cache coherency domain of the calling + CPU. + + Invalidates the entire data cache in cache coherency domain of the calling + CPU. This function must be used with care because dirty cache lines are not + written back to system memory. It is typically used for cache diagnostics. If + the CPU does not support invalidation of the entire data cache, then a write + back and invalidate operation should be performed on the entire data cache. + +**/ +VOID +EFIAPI +InvalidateDataCache ( + VOID + ); + +/** + Invalidates a range of data cache lines in the cache coherency domain of the + calling CPU. + + Invalidates the data cache lines specified by Address and Length. If Address + is not aligned on a cache line boundary, then entire data cache line + containing Address is invalidated. If Address + Length is not aligned on a + cache line boundary, then the entire data cache line containing Address + + Length -1 is invalidated. This function must never invalidate any cache lines + outside the specified range. If Length is 0, the no data cache lines are + invalidated. Address is returned. This function must be used with care + because dirty cache lines are not written back to system memory. It is + typically used for cache diagnostics. If the CPU does not support + invalidation of a data cache range, then a write back and invalidate + operation should be performed on the data cache range. + + If Length is greater than (MAX_ADDRESS - Address + 1), then ASSERT(). + + @param Address The base address of the data cache lines to invalidate. If + the CPU is in a physical addressing mode, then Address is a + physical address. If the CPU is in a virtual addressing mode, + then Address is a virtual address. + @param Length The number of bytes to invalidate from the data cache. + + @return Address + +**/ +VOID * +EFIAPI +InvalidateDataCacheRange ( + IN VOID *Address, + IN UINTN Length + ); + +#endif diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueDebugLib.h b/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueDebugLib.h new file mode 100644 index 0000000..b7cd4a9 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueDebugLib.h @@ -0,0 +1,575 @@ +/*++ + +Copyright (c) 2004 - 2011, 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: + + EdkIIGlueDebugLib.h + +Abstract: + + Public include file for the Debug Library + +--*/ + +#ifndef __EDKII_GLUE_DEBUG_LIB_H__ +#define __EDKII_GLUE_DEBUG_LIB_H__ + +// +// To use EdkII code, these R8.x macros are undefined +// +#undef ASSERT +#undef DEBUG +#undef ASSERT_EFI_ERROR +#undef ASSERT_PROTOCOL_ALREADY_INSTALLED +#undef DEBUG_CODE +#undef CR + +// +// Declare bits for PcdDebugPropertyMask +// +#define DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED 0x01 +#define DEBUG_PROPERTY_DEBUG_PRINT_ENABLED 0x02 +#define DEBUG_PROPERTY_DEBUG_CODE_ENABLED 0x04 +#define DEBUG_PROPERTY_CLEAR_MEMORY_ENABLED 0x08 +#define DEBUG_PROPERTY_ASSERT_BREAKPOINT_ENABLED 0x10 +#define DEBUG_PROPERTY_ASSERT_DEADLOOP_ENABLED 0x20 + +// +// Declare bits for PcdDebugPrintErrorLevel and the ErrorLevel parameter of DebugPrint() +// +#define EFI_D_INIT 0x00000001 // Initialization style messages +#define EFI_D_WARN 0x00000002 // Warnings +#define EFI_D_LOAD 0x00000004 // Load events +#define EFI_D_FS 0x00000008 // EFI File system +#define EFI_D_POOL 0x00000010 // Alloc & Free's +#define EFI_D_PAGE 0x00000020 // Alloc & Free's +#define EFI_D_INFO 0x00000040 // Informational debug messages +#define EFI_D_VARIABLE 0x00000100 // Variable +#define EFI_D_BM 0x00000400 // Boot Manager (BDS) +#define EFI_D_BLKIO 0x00001000 // BlkIo Driver +#define EFI_D_NET 0x00004000 // SNI Driver +#define EFI_D_UNDI 0x00010000 // UNDI Driver +#define EFI_D_LOADFILE 0x00020000 // UNDI Driver +#define EFI_D_EVENT 0x00080000 // Event messages +#define EFI_D_VERBOSE 0x00400000 // Detailed debug messages that may significantly impact boot performance +#define EFI_D_ERROR 0x80000000 // Error + +/** + + Gets the error level. + + If DebugMaskInterface is not NULL, return the error level from DebugMaskInterface. + + If DebugMaskInterface is NULL, return the default define DebugPrintErrorLevel error level. + + @retval Debug Message Error Level + +**/ +UINTN +EFIAPI +EdkIIGlueGetDebugPrintErrorLevel ( + VOID + ); + +/** + + Prints a debug message to the debug output device if the specified error level is enabled. + + If any bit in ErrorLevel is also set in PcdDebugPrintErrorLevel, then print + the message specified by Format and the associated variable argument list to + the debug output device. + + If Format is NULL, then ASSERT(). + + @param ErrorLevel The error level of the debug message. + @param Format Format string for the debug message to print. + +**/ +VOID +EFIAPI +DebugPrint ( + IN UINTN ErrorLevel, + IN CONST CHAR8 *Format, + ... + ); + + +/** + + Prints an assert message containing a filename, line number, and description. + This may be followed by a breakpoint or a dead loop. + + Print a message of the form "ASSERT <FileName>(<LineNumber>): <Description>\n" + to the debug output device. If DEBUG_PROPERTY_ASSERT_BREAKPOINT_ENABLED bit of + PcdDebugProperyMask is set then CpuBreakpoint() is called. Otherwise, if + DEBUG_PROPERTY_ASSERT_DEADLOOP_ENABLED bit of PcdDebugProperyMask is set then + CpuDeadLoop() is called. If neither of these bits are set, then this function + returns immediately after the message is printed to the debug output device. + DebugAssert() must actively prevent recusrsion. If DebugAssert() is called while + processing another DebugAssert(), then DebugAssert() must return immediately. + + If FileName is NULL, then a <FileName> string of ?NULL) Filename?is printed. + + If Description is NULL, then a <Description> string of ?NULL) Description?is printed. + + @param FileName Pointer to the name of the source file that generated the assert condition. + @param LineNumber The line number in the source file that generated the assert condition + @param Description Pointer to the description of the assert condition. + +**/ +VOID +EFIAPI +DebugAssert ( + IN CONST CHAR8 *FileName, + IN UINTN LineNumber, + IN CONST CHAR8 *Description + ); + + +/** + + Fills a target buffer with PcdDebugClearMemoryValue, and returns the target buffer. + + This function fills Length bytes of Buffer with the value specified by + PcdDebugClearMemoryValue, and returns Buffer. + + If Buffer is NULL, then ASSERT(). + + If Length is greater than (MAX_ADDRESS ?Buffer + 1), then ASSERT(). + + @param Buffer Pointer to the target buffer to fill with PcdDebugClearMemoryValue. + @param Length Number of bytes in Buffer to fill with zeros PcdDebugClearMemoryValue. + + @return Buffer + +**/ +VOID * +EFIAPI +DebugClearMemory ( + OUT VOID *Buffer, + IN UINTN Length + ); + + +/** + + Returns TRUE if ASSERT() macros are enabled. + + This function returns TRUE if the DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED bit of + PcdDebugProperyMask is set. Otherwise FALSE is returned. + + @retval TRUE The DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED bit of PcdDebugProperyMask is set. + @retval FALSE The DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED bit of PcdDebugProperyMask is clear. + +**/ +BOOLEAN +EFIAPI +DebugAssertEnabled ( + VOID + ); + + +/** + + Returns TRUE if DEBUG()macros are enabled. + + This function returns TRUE if the DEBUG_PROPERTY_DEBUG_PRINT_ENABLED bit of + PcdDebugProperyMask is set. Otherwise FALSE is returned. + + @retval TRUE The DEBUG_PROPERTY_DEBUG_PRINT_ENABLED bit of PcdDebugProperyMask is set. + @retval FALSE The DEBUG_PROPERTY_DEBUG_PRINT_ENABLED bit of PcdDebugProperyMask is clear. + +**/ +BOOLEAN +EFIAPI +DebugPrintEnabled ( + VOID + ); + + +/** + + Returns TRUE if DEBUG_CODE()macros are enabled. + + This function returns TRUE if the DEBUG_PROPERTY_DEBUG_CODE_ENABLED bit of + PcdDebugProperyMask is set. Otherwise FALSE is returned. + + @retval TRUE The DEBUG_PROPERTY_DEBUG_CODE_ENABLED bit of PcdDebugProperyMask is set. + @retval FALSE The DEBUG_PROPERTY_DEBUG_CODE_ENABLED bit of PcdDebugProperyMask is clear. + +**/ +BOOLEAN +EFIAPI +DebugCodeEnabled ( + VOID + ); + + +/** + + Returns TRUE if DEBUG_CLEAR_MEMORY()macro is enabled. + + This function returns TRUE if the DEBUG_PROPERTY_DEBUG_CLEAR_MEMORY_ENABLED bit of + PcdDebugProperyMask is set. Otherwise FALSE is returned. + + @retval TRUE The DEBUG_PROPERTY_DEBUG_CLEAR_MEMORY_ENABLED bit of PcdDebugProperyMask is set. + @retval FALSE The DEBUG_PROPERTY_DEBUG_CLEAR_MEMORY_ENABLED bit of PcdDebugProperyMask is clear. + +**/ +BOOLEAN +EFIAPI +DebugClearMemoryEnabled ( + VOID + ); + + +/** + + Internal worker macro that calls DebugAssert(). + + This macro calls DebugAssert() passing in the filename, line number, and + expression that evailated to FALSE. + + @param Expression Boolean expression that evailated to FALSE + +**/ +#ifdef EFI_DEBUG +#define _ASSERT(Expression) DebugAssert (__FILE__, __LINE__, #Expression) +#else +#define _ASSERT(Expression) + +#endif + +/** + + Internal worker macro that calls DebugPrint(). + + This macro calls DebugPrint() passing in the debug error level, a format + string, and a variable argument list. + + @param Expression Expression containing an error level, a format string, + and a variable argument list based on the format string. + +**/ +#ifdef EFI_DEBUG +#define _DEBUG(Expression) DebugPrint Expression +#else +#define _DEBUG(Expression) + +#endif + +/** + + Macro that calls DebugAssert() if a expression evaluates to FALSE. + + If the DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED bit of PcdDebugProperyMask is set, + then this macro evaluates the Boolean expression specified by Expression. If + Expression evaluates to FALSE, then DebugAssert() is called passing in the + source filename, source line number, and Expression. + + @param Expression Boolean expression + +**/ +#ifdef EDKII_GLUE_LIBRARY_IMPLEMENTATION + // Glue Library internal + + #if EDKII_GLUE_LIBRARY_DEBUG_ENABLE + #ifdef EFI_DEBUG + #define ASSERT(Expression) \ + do { \ + if (DebugAssertEnabled ()) { \ + if (!(Expression)) { \ + _ASSERT (Expression); \ + } \ + } \ + } while (FALSE) + #endif + #else + #define ASSERT(Expression) do{} while(0) + #endif + +#else + // External usage + + #ifdef EFI_DEBUG + #define ASSERT(Expression) \ + do { \ + if (DebugAssertEnabled ()) { \ + if (!(Expression)) { \ + _ASSERT (Expression); \ + } \ + } \ + } while (FALSE) + #else + #define ASSERT(Expression) do{} while(0) + #endif + +#endif + +/** + + Macro that calls DebugPrint(). + + If the DEBUG_PROPERTY_DEBUG_PRINT_ENABLED bit of PcdDebugProperyMask is set, + then this macro passes Expression to DebugPrint(). + + @param Expression Expression containing an error level, a format string, + and a variable argument list based on the format string. + + +**/ +#ifdef EDKII_GLUE_LIBRARY_IMPLEMENTATION + // Glue Library internal + + #if EDKII_GLUE_LIBRARY_DEBUG_ENABLE + #ifdef EFI_DEBUG + #define DEBUG(Expression) \ + do { \ + if (DebugPrintEnabled ()) { \ + _DEBUG (Expression); \ + } \ + } while (FALSE) + #endif + #else + #define DEBUG(Expression) do{} while(0) + #endif + +#else + // External usage + + #ifdef EFI_DEBUG + #define DEBUG(Expression) \ + do { \ + if (DebugPrintEnabled ()) { \ + _DEBUG (Expression); \ + } \ + } while (FALSE) + #else + #define DEBUG(Expression) do{} while(0) + #endif + +#endif + + +/** + + Macro that calls DebugAssert() if an EFI_STATUS evaluates to an error code. + + If the DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED bit of PcdDebugProperyMask is set, + then this macro evaluates the EFI_STATUS value specified by StatusParameter. + If StatusParameter is an error code, then DebugAssert() is called passing in + the source filename, source line number, and StatusParameter. + + @param StatusParameter EFI_STATUS value to evaluate. + +**/ +#ifdef EDKII_GLUE_LIBRARY_IMPLEMENTATION + // Glue Library internal + + #if EDKII_GLUE_LIBRARY_DEBUG_ENABLE + #ifdef EFI_DEBUG + #define ASSERT_EFI_ERROR(StatusParameter) \ + do { \ + if (DebugAssertEnabled ()) { \ + if (EFI_ERROR (StatusParameter)) { \ + DEBUG ((EFI_D_ERROR, "\nASSERT_EFI_ERROR, Status = %r (0x%08X)\n", \ + StatusParameter, StatusParameter)); \ + _ASSERT (!EFI_ERROR (StatusParameter)); \ + } \ + } \ + } while (FALSE) + #endif + #else + #define ASSERT_EFI_ERROR(Expression) do{} while(0) + #endif + +#else + // External usage + + #ifdef EFI_DEBUG + #define ASSERT_EFI_ERROR(StatusParameter) \ + do { \ + if (DebugAssertEnabled ()) { \ + if (EFI_ERROR (StatusParameter)) { \ + DEBUG ((EFI_D_ERROR, "\nASSERT_EFI_ERROR, Status = %r (0x%08X)\n", \ + StatusParameter, StatusParameter)); \ + _ASSERT (!EFI_ERROR (StatusParameter)); \ + } \ + } \ + } while (FALSE) + #else + #define ASSERT_EFI_ERROR(Expression) do{} while(0) + #endif + +#endif + + +/** + + Macro that calls DebugAssert() if a protocol is already installed in the + handle database. + + If the DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED bit of PcdDebugProperyMask is clear, + then return. + + If Handle is NULL, then a check is made to see if the protocol specified by Guid + is present on any handle in the handle database. If Handle is not NULL, then + a check is made to see if the protocol specified by Guid is present on the + handle specified by Handle. If the check finds the protocol, then DebugAssert() + is called passing in the source filename, source line number, and Guid. + + If Guid is NULL, then ASSERT(). + + @param Handle The handle to check for the protocol. This is an optional + parameter that may be NULL. If it is NULL, then the entire + handle database is searched. + + @param Guid Pointer to a protocol GUID. + +**/ +#ifdef EFI_DEBUG +#define ASSERT_PROTOCOL_ALREADY_INSTALLED(Handle, Guid) \ + do { \ + if (DebugAssertEnabled ()) { \ + VOID *Instance; \ + ASSERT (Guid != NULL); \ + if (Handle == NULL) { \ + if (!EFI_ERROR (gBS->LocateProtocol ((EFI_GUID *)Guid, NULL, &Instance))) { \ + _ASSERT (Guid already installed in database); \ + } \ + } else { \ + if (!EFI_ERROR (gBS->HandleProtocol (Handle, (EFI_GUID *)Guid, &Instance))) { \ + _ASSERT (Guid already installed on Handle); \ + } \ + } \ + } \ + } while (FALSE) +#else +#define ASSERT_PROTOCOL_ALREADY_INSTALLED(Handle, Guid) \ + do {} while(0); +#endif + + +/** + Macro that marks the beginning of debug source code. + + If the DEBUG_PROPERTY_DEBUG_CODE_ENABLED bit of PcdDebugProperyMask is set, + then this macro marks the beginning of source code that is included in a module. + Otherwise, the source lines between DEBUG_CODE_BEGIN() and DEBUG_CODE_END() + are not included in a module. + +**/ +#define DEBUG_CODE_BEGIN() do { if (DebugCodeEnabled ()) { UINT8 __DebugCodeLocal + + +/** + + Macro that marks the end of debug source code. + + If the DEBUG_PROPERTY_DEBUG_CODE_ENABLED bit of PcdDebugProperyMask is set, + then this macro marks the end of source code that is included in a module. + Otherwise, the source lines between DEBUG_CODE_BEGIN() and DEBUG_CODE_END() + are not included in a module. + +**/ +#define DEBUG_CODE_END() __DebugCodeLocal = 0; } } while (FALSE) + + +/** + + Macro that declares a section of debug source code. + + If the DEBUG_PROPERTY_DEBUG_CODE_ENABLED bit of PcdDebugProperyMask is set, + then the source code specified by Expression is included in a module. + Otherwise, the source specified by Expression is not included in a module. + +**/ +#define DEBUG_CODE(Expression) \ + DEBUG_CODE_BEGIN (); \ + Expression \ + DEBUG_CODE_END () + + +/** + + Macro that calls DebugClearMemory() to clear a buffer to a default value. + + If the DEBUG_PROPERTY_CLEAR_MEMORY_ENABLED bit of PcdDebugProperyMask is set, + then this macro calls DebugClearMemory() passing in Address and Length. + + @param Address Pointer to a buffer. + @param Length The number of bytes in the buffer to set. + +**/ +#define DEBUG_CLEAR_MEMORY(Address, Length) \ + do { \ + if (DebugClearMemoryEnabled ()) { \ + DebugClearMemory (Address, Length); \ + } \ + } while (FALSE) + + +/** + + Macro that calls DebugAssert() if the containing record does not have a + matching signature. If the signatures matches, then a pointer to the data + structure that contains a specified field of that data structure is returned. + This is a light weight method hide information by placing a public data + structure inside a larger private data structure and using a pointer to the + public data structure to retrieve a pointer to the private data structure. + + If the DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED bit of PcdDebugProperyMask is clear, + then this macro computes the offset, in bytes, of field specified by Field + from the beginning of the data structure specified by TYPE. This offset is + subtracted from Record, and is used to return a pointer to a data structure + of the type specified by TYPE. + + If the DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED bit of PcdDebugProperyMask is set, + then this macro computes the offset, in bytes, of field specified by Field from + the beginning of the data structure specified by TYPE. This offset is + subtracted from Record, and is used to compute a pointer to a data structure of + the type specified by TYPE. The Signature field of the data structure specified + by TYPE is compared to TestSignature. If the signatures match, then a pointer + to the pointer to a data structure of the type specified by TYPE is returned. + If the signatures do not match, then DebugAssert() is called with a description + of "CR has a bad signature" and Record is returned. + + If the data type specified by TYPE does not contain the field specified by Field, + then the module will not compile. + + If TYPE does not contain a field called Signature, then the module will not + compile. + + @param Record Pointer to the field specified by Field within a data + structure of type TYPE. + + @param TYPE The name of the data structure type to return This + data structure must contain the field specified by Field. + + @param Field The name of the field in the data structure specified + by TYPE to which Record points. + + @param TestSignature The 32-bit signature value to match. + +**/ +#ifdef EFI_DEBUG + #define CR(Record, TYPE, Field, TestSignature) \ + (DebugAssertEnabled () && (_CR (Record, TYPE, Field)->Signature != TestSignature)) ? \ + (TYPE *) (_ASSERT (CR has Bad Signature), Record) : \ + _CR (Record, TYPE, Field) +#else + #define CR(Record, TYPE, Field, TestSignature) \ + _CR (Record, TYPE, Field) +#endif + + +#endif diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueDevicePathLib.h b/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueDevicePathLib.h new file mode 100644 index 0000000..2c2a730 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueDevicePathLib.h @@ -0,0 +1,269 @@ +/*++ + +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: + + EdkIIGlueDevicePathLib.h + +Abstract: + + Public header file for Device Path Lib + +--*/ + +#ifndef __EDKII_GLUE_DEVICE_PATH_LIB_H__ +#define __EDKII_GLUE_DEVICE_PATH_LIB_H__ + + +#define GetDevicePathSize(_DEVICEPATH) GlueGetDevicePathSize(_DEVICEPATH) +#define DuplicateDevicePath(_DEVICEPATH) GlueDuplicateDevicePath(_DEVICEPATH) +#define AppendDevicePath(_FIRSTPATH, _SECONDPATH) GlueAppendDevicePath(_FIRSTPATH, _SECONDPATH) +#define AppendDevicePathNode(_DEVICEPATH, _DEVICEPATHNODE) GlueAppendDevicePathNode(_DEVICEPATH, _DEVICEPATHNODE) +#define AppendDevicePathInstance(_SOURCE, _INSTANCE) GlueAppendDevicePathInstance(_SOURCE,_INSTANCE) +#define GetNextDevicePathInstance(_DEVICEPATH, _SIZE) GlueGetNextDevicePathInstance(_DEVICEPATH, _SIZE) +#define IsDevicePathMultiInstance(_DEVICEPATH) GlueIsDevicePathMultiInstance(_DEVICEPATH) +#define DevicePathFromHandle(_HANDLE) GlueDevicePathFromHandle(_HANDLE) +#define FileDevicePath(_DEVICE, _FILENAME) GlueFileDevicePath(_DEVICE, _FILENAME) + + +/** + Returns the size of a device path in bytes. + + This function returns the size, in bytes, of the device path data structure specified by + DevicePath including the end of device path node. If DevicePath is NULL, then 0 is returned. + + @param DevicePath A pointer to a device path data structure. + + @return The size of a device path in bytes. + +**/ +UINTN +EFIAPI +GlueGetDevicePathSize ( + IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath + ); + +/** + Creates a new device path by appending a second device path to a first device path. + + This function allocates space for a new copy of the device path specified by DevicePath. If + DevicePath is NULL, then NULL is returned. If the memory is successfully allocated, then the + contents of DevicePath are copied to the newly allocated buffer, and a pointer to that buffer + is returned. Otherwise, NULL is returned. + + @param DevicePath A pointer to a device path data structure. + + @return A pointer to the duplicated device path. + +**/ +EFI_DEVICE_PATH_PROTOCOL * +EFIAPI +GlueDuplicateDevicePath ( + IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath + ); + +/** + Creates a new device path by appending a second device path to a first device path. + + This function creates a new device path by appending a copy of SecondDevicePath to a copy of + FirstDevicePath in a newly allocated buffer. Only the end-of-device-path device node from + SecondDevicePath is retained. The newly created device path is returned. + If FirstDevicePath is NULL, then it is ignored, and a duplicate of SecondDevicePath is returned. + If SecondDevicePath is NULL, then it is ignored, and a duplicate of FirstDevicePath is returned. + If both FirstDevicePath and SecondDevicePath are NULL, then NULL is returned. + If there is not enough memory for the newly allocated buffer, then NULL is returned. + The memory for the new device path is allocated from EFI boot services memory. It is the + responsibility of the caller to free the memory allocated. + + @param FirstDevicePath A pointer to a device path data structure. + @param SecondDevicePath A pointer to a device path data structure. + + @return A pointer to the new device path. + +**/ +EFI_DEVICE_PATH_PROTOCOL * +EFIAPI +GlueAppendDevicePath ( + IN CONST EFI_DEVICE_PATH_PROTOCOL *FirstDevicePath, OPTIONAL + IN CONST EFI_DEVICE_PATH_PROTOCOL *SecondDevicePath OPTIONAL + ); + +/** + Creates a new path by appending the device node to the device path. + + This function creates a new device path by appending a copy of the device node specified by + DevicePathNode to a copy of the device path specified by DevicePath in an allocated buffer. + The end-of-device-path device node is moved after the end of the appended device node. + If DevicePath is NULL, then NULL is returned. + If DevicePathNode is NULL, then NULL is returned. + If there is not enough memory to allocate space for the new device path, then NULL is returned. + The memory is allocated from EFI boot services memory. It is the responsibility of the caller to + free the memory allocated. + + @param DevicePath A pointer to a device path data structure. + @param DevicePathNode A pointer to a single device path node. + + @return A pointer to the new device path. + +**/ +EFI_DEVICE_PATH_PROTOCOL * +EFIAPI +GlueAppendDevicePathNode ( + IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath, OPTIONAL + IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePathNode OPTIONAL + ); + +/** + Creates a new device path by appending the specified device path instance to the specified device + path. + + This function creates a new device path by appending a copy of the device path instance specified + by DevicePathInstance to a copy of the device path secified by DevicePath in a allocated buffer. + The end-of-device-path device node is moved after the end of the appended device path instance + and a new end-of-device-path-instance node is inserted between. + If DevicePath is NULL, then a copy if DevicePathInstance is returned. + If DevicePathInstance is NULL, then NULL is returned. + If there is not enough memory to allocate space for the new device path, then NULL is returned. + The memory is allocated from EFI boot services memory. It is the responsibility of the caller to + free the memory allocated. + + @param DevicePath A pointer to a device path data structure. + @param DevicePathInstance A pointer to a device path instance. + + @return A pointer to the new device path. + +**/ +EFI_DEVICE_PATH_PROTOCOL * +EFIAPI +GlueAppendDevicePathInstance ( + IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath, OPTIONAL + IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePathInstance OPTIONAL + ); + +/** + Creates a copy of the current device path instance and returns a pointer to the next device path + instance. + + This function creates a copy of the current device path instance. It also updates DevicePath to + point to the next device path instance in the device path (or NULL if no more) and updates Size + to hold the size of the device path instance copy. + If DevicePath is NULL, then NULL is returned. + If there is not enough memory to allocate space for the new device path, then NULL is returned. + The memory is allocated from EFI boot services memory. It is the responsibility of the caller to + free the memory allocated. + If Size is NULL, then ASSERT(). + + @param DevicePath On input, this holds the pointer to the current device path + instance. On output, this holds the pointer to the next device + path instance or NULL if there are no more device path + instances in the device path pointer to a device path data + structure. + @param Size On output, this holds the size of the device path instance, in + bytes or zero, if DevicePath is NULL. + + @return A pointer to the current device path instance. + +**/ +EFI_DEVICE_PATH_PROTOCOL * +EFIAPI +GlueGetNextDevicePathInstance ( + IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath, + OUT UINTN *Size + ); + +/** + Creates a copy of the current device path instance and returns a pointer to the next device path + instance. + + This function creates a new device node in a newly allocated buffer of size NodeLength and + initializes the device path node header with NodeType and NodeSubType. The new device path node + is returned. + If NodeLength is smaller than a device path header, then NULL is returned. + If there is not enough memory to allocate space for the new device path, then NULL is returned. + The memory is allocated from EFI boot services memory. It is the responsibility of the caller to + free the memory allocated. + + @param NodeType The device node type for the new device node. + @param NodeSubType The device node sub-type for the new device node. + @param NodeLength The length of the new device node. + + @return The new device path. + +**/ +EFI_DEVICE_PATH_PROTOCOL * +EFIAPI +CreateDeviceNode ( + IN UINT8 NodeType, + IN UINT8 NodeSubType, + IN UINT16 NodeLength + ); + +/** + Determines if a device path is single or multi-instance. + + This function returns TRUE if the device path specified by DevicePath is multi-instance. + Otherwise, FALSE is returned. If DevicePath is NULL, then FALSE is returned. + + @param DevicePath A pointer to a device path data structure. + + @retval TRUE DevicePath is multi-instance. + @retval FALSE DevicePath is not multi-instance or DevicePath is NULL. + +**/ +BOOLEAN +EFIAPI +GlueIsDevicePathMultiInstance ( + IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath + ); + +/** + Retrieves the device path protocol from a handle. + + This function returns the device path protocol from the handle specified by Handle. If Handle is + NULL or Handle does not contain a device path protocol, then NULL is returned. + + @param Handle The handle from which to retrieve the device path protocol. + + @return The device path protocol from the handle specified by Handle. + +**/ +EFI_DEVICE_PATH_PROTOCOL * +EFIAPI +GlueDevicePathFromHandle ( + IN EFI_HANDLE Handle + ); + +/** + Allocates a device path for a file and appends it to an existing device path. + + If Device is a valid device handle that contains a device path protocol, then a device path for + the file specified by FileName is allocated and appended to the device path associated with the + handle Device. The allocated device path is returned. If Device is NULL or Device is a handle + that does not support the device path protocol, then a device path containing a single device + path node for the file specified by FileName is allocated and returned. + If FileName is NULL, then ASSERT(). + + @param Device A pointer to a device handle. This parameter is optional and + may be NULL. + @param FileName A pointer to a Null-terminated Unicode string. + + @return The allocated device path. + +**/ +EFI_DEVICE_PATH_PROTOCOL * +EFIAPI +GlueFileDevicePath ( + IN EFI_HANDLE Device, OPTIONAL + IN CONST CHAR16 *FileName + ); + +#endif diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueDxeRuntimeDriverLib.h b/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueDxeRuntimeDriverLib.h new file mode 100644 index 0000000..2ec3f4f --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueDxeRuntimeDriverLib.h @@ -0,0 +1,451 @@ +/*++ + +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: + + EdkIIGlueDxeRuntimeDriverLib.h + +Abstract: + + Library that abstracts runtime services + +--*/ + +#ifndef __EDKII_GLUE_DXE_RUNTIME_DRIVER_LIB_H__ +#define __EDKII_GLUE_DXE_RUNTIME_DRIVER_LIB_H__ + +#if (EFI_SPECIFICATION_VERSION < 0x00020000) + +typedef struct { + EFI_GUID CapsuleGuid; + UINT32 HeaderSize; + UINT32 Flags; + UINT32 CapsuleImageSize; +} UEFI_CAPSULE_HEADER; + +#else + +typedef EFI_CAPSULE_HEADER UEFI_CAPSULE_HEADER; + +#endif + +extern const EFI_EVENT_NOTIFY _gDriverExitBootServicesEvent[]; + +extern const EFI_EVENT_NOTIFY _gDriverSetVirtualAddressMapEvent[]; + +/** + Check to see if the execute context is in Runtime phase or not. + + @param None. + + @retval TRUE The driver is in SMM. + @retval FALSE The driver is not in SMM. + +**/ +BOOLEAN +EFIAPI +EfiAtRuntime ( + VOID + ); + +/** + Check to see if the SetVirtualAddressMsp() is invoked or not. + + @retval TRUE SetVirtualAddressMsp() has been called. + @retval FALSE SetVirtualAddressMsp() has not been called. + +**/ +BOOLEAN +EFIAPI +EfiGoneVirtual ( + VOID + ); + +/** + Return current time and date information, and time-keeping + capabilities of hardware platform. + + @param Time A pointer to storage to receive a snapshot of the current time. + @param Capabilities An optional pointer to a buffer to receive the real time clock device¡¯s + capabilities. + + @retval EFI_SUCCESS Success to execute the function. + @retval !EFI_SUCCESS Failed to e3xecute the function. + +**/ +EFI_STATUS +EFIAPI +EfiGetTime ( + OUT EFI_TIME *Time, + OUT EFI_TIME_CAPABILITIES *Capabilities + ); + +/** + Set current time and date information. + + @param Time A pointer to cache of time setting. + + @retval EFI_SUCCESS Success to execute the function. + @retval !EFI_SUCCESS Failed to execute the function. + +**/ +EFI_STATUS +EFIAPI +EfiSetTime ( + IN EFI_TIME *Time + ); + +/** + Return current wakeup alarm clock setting. + + @param Enabled Indicate if the alarm clock is enabled or disabled. + @param Pending Indicate if the alarm signal is pending and requires acknowledgement. + @param Time Current alarm clock setting. + + @retval EFI_SUCCESS Success to execute the function. + @retval !EFI_SUCCESS Failed to e3xecute the function. + +**/ +EFI_STATUS +EFIAPI +EfiGetWakeupTime ( + OUT BOOLEAN *Enabled, + OUT BOOLEAN *Pending, + OUT EFI_TIME *Time + ); + +/** + Set current wakeup alarm clock. + + @param Enable Enable or disable current alarm clock.. + @param Time Point to alarm clock setting. + + @retval EFI_SUCCESS Success to execute the function. + @retval !EFI_SUCCESS Failed to e3xecute the function. + +**/ +EFI_STATUS +EFIAPI +EfiSetWakeupTime ( + IN BOOLEAN Enable, + IN EFI_TIME *Time + ); + +/** + Return value of variable. + + @param VariableName the name of the vendor's variable, it's a + Null-Terminated Unicode String + @param VendorGuid Unify identifier for vendor. + @param Attributes Point to memory location to return the attributes of variable. If the point + is NULL, the parameter would be ignored. + @param DataSize As input, point to the maxinum size of return Data-Buffer. + As output, point to the actual size of the returned Data-Buffer. + @param Data Point to return Data-Buffer. + + @retval EFI_SUCCESS Success to execute the function. + @retval !EFI_SUCCESS Failed to e3xecute the function. + +**/ +EFI_STATUS +EFIAPI +EfiGetVariable ( + IN CHAR16 *VariableName, + IN EFI_GUID *VendorGuid, + OUT UINT32 *Attributes, + IN OUT UINTN *DataSize, + OUT VOID *Data + ) +; + +/** + Enumerates variable's name. + + @param VariableNameSize As input, point to maxinum size of variable name. + As output, point to actual size of varaible name. + @param VariableName As input, supplies the last VariableName that was returned by + GetNextVariableName(). + As output, returns the name of variable. The name + string is Null-Terminated Unicode string. + @param VendorGuid As input, supplies the last VendorGuid that was returned by + GetNextVriableName(). + As output, returns the VendorGuid of the current variable. + + @retval EFI_SUCCESS Success to execute the function. + @retval !EFI_SUCCESS Failed to e3xecute the function. + +**/ +EFI_STATUS +EFIAPI +EfiGetNextVariableName ( + IN OUT UINTN *VariableNameSize, + IN OUT CHAR16 *VariableName, + IN OUT EFI_GUID *VendorGuid + ); + +/** + Sets value of variable. + + @param VariableName the name of the vendor's variable, it's a + Null-Terminated Unicode String + @param VendorGuid Unify identifier for vendor. + @param Attributes Point to memory location to return the attributes of variable. If the point + is NULL, the parameter would be ignored. + @param DataSize The size in bytes of Data-Buffer. + @param Data Point to the content of the variable. + + @retval EFI_SUCCESS Success to execute the function. + @retval !EFI_SUCCESS Failed to e3xecute the function. + +**/ +EFI_STATUS +EFIAPI +EfiSetVariable ( + IN CHAR16 *VariableName, + IN EFI_GUID *VendorGuid, + IN UINT32 Attributes, + IN UINTN DataSize, + IN VOID *Data + ); + +/** + Returns the next high 32 bits of platform's monotonic counter. + + @param HighCount Pointer to returned value. + + @retval EFI_SUCCESS Success to execute the function. + @retval !EFI_SUCCESS Failed to e3xecute the function. + +**/ +EFI_STATUS +EFIAPI +EfiGetNextHighMonotonicCount ( + OUT UINT32 *HighCount + ); + +/** + Resets the entire platform. + + @param ResetType The type of reset to perform. + @param ResetStatus The status code for reset. + @param DataSize The size in bytes of reset data. + @param ResetData Pointer to data buffer that includes + Null-Terminated Unicode string. + + @retval EFI_SUCCESS Success to execute the function. + @retval !EFI_SUCCESS Failed to e3xecute the function. + +**/ +VOID +EfiResetSystem ( + IN EFI_RESET_TYPE ResetType, + IN EFI_STATUS ResetStatus, + IN UINTN DataSize, + IN CHAR16 *ResetData + ); + +/** + Determines the new virtual address that is to be used on subsequent memory accesses. + + @param DebugDisposition Supplies type information for the pointer being converted. + @param Address The pointer to a pointer that is to be fixed to be the + value needed for the new virtual address mapping being + applied. + + @retval EFI_SUCCESS Success to execute the function. + @retval !EFI_SUCCESS Failed to e3xecute the function. + +**/ +EFI_STATUS +EFIAPI +EfiConvertPointer ( + IN UINTN DebugDisposition, + IN OUT VOID *Address + ); + + +/** + Change the runtime addressing mode of EFI firmware from physical to virtual. + + @param MemoryMapSize The size in bytes of VirtualMap. + @param DescriptorSize The size in bytes of an entry in the VirtualMap. + @param DescriptorVersion The version of the structure entries in VirtualMap. + @param VirtualMap An array of memory descriptors which contain new virtual + address mapping information for all runtime ranges. Type + EFI_MEMORY_DESCRIPTOR is defined in the + GetMemoryMap() function description. + + @retval EFI_SUCCESS The virtual address map has been applied. + @retval EFI_UNSUPPORTED EFI firmware is not at runtime, or the EFI firmware is already in + virtual address mapped mode. + @retval EFI_INVALID_PARAMETER DescriptorSize or DescriptorVersion is + invalid. + @retval EFI_NO_MAPPING A virtual address was not supplied for a range in the memory + map that requires a mapping. + @retval EFI_NOT_FOUND A virtual address was supplied for an address that is not found + in the memory map. +**/ +EFI_STATUS +EFIAPI +EfiSetVirtualAddressMap ( + IN UINTN MemoryMapSize, + IN UINTN DescriptorSize, + IN UINT32 DescriptorVersion, + IN CONST EFI_MEMORY_DESCRIPTOR *VirtualMap + ); + + +/** + Conver the standard Lib double linked list to a virtual mapping. + + @param DebugDisposition Supplies type information for the pointer being converted. + @param ListHead Head of linked list to convert. + + @retval EFI_SUCCESS Success to execute the function. + @retval !EFI_SUCCESS Failed to e3xecute the function. + +**/ +EFI_STATUS +EFIAPI +EfiConvertList ( + IN UINTN DebugDisposition, + IN OUT LIST_ENTRY *ListHead + ); + + +/** + + Passes capsules to the firmware with both virtual and physical mapping. + Depending on the intended consumption, the firmware may + process the capsule immediately. If the payload should persist across a + system reset, the reset value returned from EFI_QueryCapsuleCapabilities must + be passed into ResetSystem() and will cause the capsule to be processed by + the firmware as part of the reset process. + + @param CapsuleHeaderArray Virtual pointer to an array of virtual pointers to the capsules + being passed into update capsule. Each capsules is assumed to + stored in contiguous virtual memory. The capsules in the + CapsuleHeaderArray must be the same capsules as the + ScatterGatherList. The CapsuleHeaderArray must + have the capsules in the same order as the ScatterGatherList. + @param CapsuleCount Number of pointers to EFI_CAPSULE_HEADER in + CaspuleHeaderArray. + @param ScatterGatherList Physical pointer to a set of + EFI_CAPSULE_BLOCK_DESCRIPTOR that describes the + location in physical memory of a set of capsules. See Related + Definitions for an explanation of how more than one capsule is + passed via this interface. The capsules in the + ScatterGatherList must be in the same order as the + CapsuleHeaderArray. This parameter is only referenced if + the capsules are defined to persist across system reset. + + @retval EFI_SUCCESS Valid capsule was passed. I Valid capsule was passed. If + CAPSULE_FLAGS_PERSIT_ACROSS_RESET is not set, the + capsule has been successfully processed by the firmware. + @retval EFI_INVALID_PARAMETER CapsuleSize is NULL or ResetTye is NULL. + @retval EFI_DEVICE_ERROR The capsule update was started, but failed due to a device error. + +**/ +EFI_STATUS +EFIAPI +EfiUpdateCapsule ( + IN UEFI_CAPSULE_HEADER **CapsuleHeaderArray, + IN UINTN CapsuleCount, + IN EFI_PHYSICAL_ADDRESS ScatterGatherList + ); + + +/** + + The QueryCapsuleCapabilities() function allows a caller to test to see if a capsule or + capsules can be updated via UpdateCapsule(). The Flags values in the capsule header and + size of the entire capsule is checked. + If the caller needs to query for generic capsule capability a fake EFI_CAPSULE_HEADER can be + constructed where CapsuleImageSize is equal to HeaderSize that is equal to sizeof + (EFI_CAPSULE_HEADER). To determine reset requirements, + CAPSULE_FLAGS_PERSIST_ACROSS_RESET should be set in the Flags field of the + EFI_CAPSULE_HEADER. + The firmware must support any capsule that has the + CAPSULE_FLAGS_PERSIST_ACROSS_RESET flag set in EFI_CAPSULE_HEADER. The + firmware sets the policy for what capsules are supported that do not have the + CAPSULE_FLAGS_PERSIST_ACROSS_RESET flag set. + + @param CapsuleHeaderArray Virtual pointer to an array of virtual pointers to the capsules + being passed into update capsule. The capsules are assumed to + stored in contiguous virtual memory. + @param CapsuleCount Number of pointers to EFI_CAPSULE_HEADER in + CaspuleHeaderArray. + @param MaxiumCapsuleSize On output the maximum size that UpdateCapsule() can + support as an argument to UpdateCapsule() via + CapsuleHeaderArray and ScatterGatherList. + Undefined on input. + @param ResetType Returns the type of reset required for the capsule update. + + @retval EFI_SUCCESS Valid answer returned.. + @retval EFI_INVALID_PARAMETER MaximumCapsuleSize is NULL. + @retval EFI_UNSUPPORTED The capsule type is not supported on this platform, and + MaximumCapsuleSize and ResetType are undefined. + +**/ +EFI_STATUS +EFIAPI +EfiQueryCapsuleCapabilities ( + IN UEFI_CAPSULE_HEADER **CapsuleHeaderArray, + IN UINTN CapsuleCount, + OUT UINT64 *MaximumCapsuleSize, + OUT EFI_RESET_TYPE *ResetType + ); + + +/** + + The QueryVariableInfo() function allows a caller to obtain the information about the + maximum size of the storage space available for the EFI variables, the remaining size of the storage + space available for the EFI variables and the maximum size of each individual EFI variable, + associated with the attributes specified. + The returned MaximumVariableStorageSize, RemainingVariableStorageSize, + MaximumVariableSize information may change immediately after the call based on other + runtime activities including asynchronous error events. Also, these values associated with different + attributes are not additive in nature. + + @param Attributes Attributes bitmask to specify the type of variables on + which to return information. Refer to the + GetVariable() function description. + @param MaximumVariableStorageSize + On output the maximum size of the storage space + available for the EFI variables associated with the + attributes specified. + @param RemainingVariableStorageSize + Returns the remaining size of the storage space + available for the EFI variables associated with the + attributes specified.. + @param MaximumVariableSize Returns the maximum size of the individual EFI + variables associated with the attributes specified. + + @retval EFI_SUCCESS Valid answer returned. + @retval EFI_INVALID_PARAMETER An invalid combination of attribute bits was supplied. + @retval EFI_UNSUPPORTED EFI_UNSUPPORTED The attribute is not supported on this platform, and the + MaximumVariableStorageSize, + RemainingVariableStorageSize, MaximumVariableSize + are undefined. +**/ +EFI_STATUS +EFIAPI +EfiQueryVariableInfo ( + IN UINT32 Attrubutes, + OUT UINT64 *MaximumVariableStorageSize, + OUT UINT64 *RemainingVariableStorageSize, + OUT UINT64 *MaximumVariableSize + ); + +#endif + diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueDxeServicesTableLib.h b/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueDxeServicesTableLib.h new file mode 100644 index 0000000..4660dc6 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueDxeServicesTableLib.h @@ -0,0 +1,32 @@ +/*++ + +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: + + EdkIIGlueDxeServicesTableLib.h + +Abstract: + + Library that provides a global pointer to the DXE Services Table + +--*/ + +#ifndef __EDKII_GLUE_DXE_SERVICES_TABLE_LIB_H__ +#define __EDKII_GLUE_DXE_SERVICES_TABLE_LIB_H__ + +// +// Cache copy of the DXE Services Table +// +extern EFI_DXE_SERVICES *gDS; + +#endif + diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueDxeSmmDriverEntryPoint.h b/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueDxeSmmDriverEntryPoint.h new file mode 100644 index 0000000..2592afc --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueDxeSmmDriverEntryPoint.h @@ -0,0 +1,147 @@ +/*++ + +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: + + EdkIIGlueDxeSmmDriverEntryPoint.h + +Abstract: + + Public header file for DXE SMM Driver Entry Point Lib + +--*/ + +#ifndef __EDKII_GLUE_MODULE_ENTRY_POINT_H__ +#define __EDKII_GLUE_MODULE_ENTRY_POINT_H__ + +// +// Declare the EFI/UEFI Specification Revision to which this driver is implemented +// +extern const UINT32 _gUefiDriverRevision; + +// +// Declare the number of entry points in the image. +// +extern const UINT8 _gDriverEntryPointCount; + +// +// Declare the number of unload handler in the image. +// +extern const UINT8 _gDriverUnloadImageCount; + +/** + Enrty point to DXE SMM Driver. + + @param ImageHandle ImageHandle of the loaded driver. + @param SystemTable Pointer to the EFI System Table. + + @retval EFI_SUCCESS One or more of the drivers returned a success code. + @retval !EFI_SUCESS The return status from the last driver entry point in the list. + +**/ +EFI_STATUS +EFIAPI +_ModuleEntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ); + +/** + Enrty point wrapper of DXE SMM Driver. + + @param ImageHandle ImageHandle of the loaded driver. + @param SystemTable Pointer to the EFI System Table. + + @retval EFI_SUCCESS One or more of the drivers returned a success code. + @retval !EFI_SUCESS The return status from the last driver entry point in the list. + +**/ +EFI_STATUS +EFIAPI +EfiMain ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ); + +/** + Computes the cummulative return status for the driver entry point and perform + a long jump back into DriverEntryPoint(). + + @param Status Status returned by the driver that is exiting. + +**/ +VOID +EFIAPI +ExitDriver ( + IN EFI_STATUS Status + ); + +/** + Call constructs for all libraries. Automatics Generated by tool. + + @param ImageHandle ImageHandle of the loaded driver. + @param SystemTable Pointer to the EFI System Table. + +**/ +VOID +EFIAPI +ProcessLibraryConstructorList ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ); + +/** + Call destructors for all libraries. Automatics Generated by tool. + + @param ImageHandle ImageHandle of the loaded driver. + @param SystemTable Pointer to the EFI System Table. + +**/ +VOID +EFIAPI +ProcessLibraryDestructorList ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ); + + +/** + Call the list of driver entry points. Automatics Generated by tool. + + @param ImageHandle ImageHandle of the loaded driver. + @param SystemTable Pointer to the EFI System Table. + + @return Status returned by entry points of drivers. + +**/ +EFI_STATUS +EFIAPI +ProcessModuleEntryPointList ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ); + + +/** + Call the unload handlers for all the modules. Automatics Generated by tool. + + @param ImageHandle ImageHandle of the loaded driver. + + @return Status returned by unload handlers of drivers. + +**/ +EFI_STATUS +EFIAPI +ProcessModuleUnloadList ( + IN EFI_HANDLE ImageHandle + ); + +#endif diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueFirmwarePerformanceLib.h b/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueFirmwarePerformanceLib.h new file mode 100644 index 0000000..668599e --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueFirmwarePerformanceLib.h @@ -0,0 +1,155 @@ +/*++ + +Copyright (c) 2011, 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: + + EdkIIGluePerformanceLib.h + +Abstract: + + Public header file for Firmware Performance Lib + + +--*/ + +#ifndef __EDKII_GLUE_FIRMWARE_PERFORMANCE_LIB_H_ +#define __EDKII_GLUE_FIRMWARE_PERFORMANCE_LIB_H_ + +EFI_STATUS +StartMeasure ( + IN VOID *Handle, + IN UINT16 *Token, + IN UINT16 *Module, + IN UINT64 TimeStamp + ) +/*++ + +Routine Description: + + Start measurement according to token field and insert into pre-allocated buffer + +Arguments: + + Handle - Handle to measure + Token - Token to measure + Module - Module to measure + Timestamp - Ticker as start tick + +Returns: + + EFI_SUCCESS - Located protocol successfully, and buffer is updated with new record + EFI_NOT_FOUND - Failure in update + +--*/ +; + +EFI_STATUS +EndMeasure ( + IN VOID *Handle, + IN UINT16 *Token, + IN UINT16 *Module, + IN UINT64 TimeStamp + ) +/*++ + +Routine Description: + + End measurement according to token field and insert into pre-allocated buffer + +Arguments: + + Handle - Handle to stop + Token - Token to stop + Module - Module to stop + Timestamp - Ticker as end tick + +Returns: + + EFI_SUCCESS - Located protocol successfully, and buffer is updated with new record + EFI_NOT_FOUND - Failure in update + +--*/ +; + +EFI_STATUS +StartMeasureEx ( + IN VOID *Handle, + IN UINT16 *Token, + IN UINT16 *Module, + IN UINT64 TimeStamp, + IN UINT16 Identifier + ) +/*++ + +Routine Description: + + Start extended measurement according to token field and insert into pre-allocated buffer + +Arguments: + + Handle - Handle to stop + Token - Token to stop + Module - Module to stop + Timestamp - Ticker as end tick + Identifier - Identifier for a given record +Returns: + + EFI_SUCCESS - Located protocol successfully, and buffer is updated with new record + EFI_NOT_FOUND - Failure in update + +--*/ +; + +EFI_STATUS +EndMeasureEx ( + IN VOID *Handle, + IN UINT16 *Token, + IN UINT16 *Module, + IN UINT64 TimeStamp, + IN UINT16 Identifier + ) +/*++ + +Routine Description: + + End extended measurement according to token field and insert into pre-allocated buffer + +Arguments: + + Handle - Handle to stop + Token - Token to stop + Module - Module to stop + Timestamp - Ticker as end tick + Identifier - Identifier for a given record + +Returns: + + EFI_SUCCESS - Located protocol successfully, and buffer is updated with new record + EFI_NOT_FOUND - Failure in update + +--*/ +; + +#ifdef FIRMWARE_PERFORMANCE +#define PERF_START(Handle, Token, Module, TimeStamp) StartMeasure (Handle, Token, Module, TimeStamp) +#define PERF_END(Handle, Token, Module, TimeStamp) EndMeasure (Handle, Token, Module, TimeStamp) +#define PERF_START_EX(Handle, Token, Module, TimeStamp, Identifier) StartMeasureEx (Handle, Token, Module, TimeStamp, Identifier) +#define PERF_END_EX(Handle, Token, Module, TimeStamp, Identifier) EndMeasureEx (Handle, Token, Module, TimeStamp, Identifier) +#define PERF_CODE(code) code +#else +#define PERF_START(Handle, Token, Module, TimeStamp) +#define PERF_END(Handle, Token, Module, TimeStamp) +#define PERF_START_EX(Handle, Token, Module, TimeStamp, Identifier) +#define PERF_END_EX(Handle, Token, Module, TimeStamp, Identifier) +#define PERF_CODE(code) +#endif + +#endif
\ No newline at end of file diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueHiiLib.h b/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueHiiLib.h new file mode 100644 index 0000000..fb9ce47 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueHiiLib.h @@ -0,0 +1,55 @@ +/*++ + +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: + + EdkIIGlueHiiLib.h + +Abstract: + + Public header file for Hii Lib + +--*/ + +#ifndef __EDKII_GLUE_HII_LIB_H__ +#define __EDKII_GLUE_HII_LIB_H__ + +#if (EFI_SPECIFICATION_VERSION < 0x0002000A) + +#define PreparePackages GluePreparePackages + + +/** + This function allocates pool for an EFI_HII_PACKAGES structure + with enough space for the variable argument list of package pointers. + The allocated structure is initialized using NumberOfPackages, Guid, + and the variable length argument list of package pointers. + + @param NumberOfPackages The number of HII packages to prepare. + @param Guid Package GUID. + + @return + The allocated and initialized packages. + +**/ +EFI_HII_PACKAGES * +EFIAPI +GluePreparePackages ( + IN UINTN NumberOfPackages, + IN CONST EFI_GUID *Guid OPTIONAL, + ... + ) +; + +#endif + +#endif diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueHobLib.h b/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueHobLib.h new file mode 100644 index 0000000..6c03086 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueHobLib.h @@ -0,0 +1,384 @@ +/*++ + +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: + + EdkIIGlueHobLib.h + +Abstract: + + Public header file for Hob Lib + +--*/ + +#ifndef __EDKII_GLUE_HOB_LIB_H__ +#define __EDKII_GLUE_HOB_LIB_H__ + + +#define GetFirstGuidHob(_GUID) GlueGetFirstGuidHob(_GUID) +#define GetNextGuidHob(_GUID, _HobStart) GlueGetNextGuidHob(_GUID, _HobStart) +#define BuildModuleHob(_MODULENAME, _MEMORYALLOCATIONMODULE, _MODULELENGTH, _ENTRYPOINT) GlueBuildModuleHob(_MODULENAME, _MEMORYALLOCATIONMODULE, _MODULELENGTH, _ENTRYPOINT) +#define BuildMemoryAllocationHob(_BASEADDRESS, _LENGTH, _MEMORYTYPE) GlueBuildMemoryAllocationHob(_BASEADDRESS, _LENGTH, _MEMORYTYPE) + + +/** + Returns the pointer to the HOB list. + + This function returns the pointer to first HOB in the list. + + @return The pointer to the HOB list. + +**/ +VOID * +EFIAPI +GetHobList ( + VOID + ) +; + +/** + Returns the next instance of a HOB type from the starting HOB. + + This function searches the first instance of a HOB type from the starting HOB pointer. + If there does not exist such HOB type from the starting HOB pointer, it will return NULL. + In contrast with macro GET_NEXT_HOB(), this function does not skip the starting HOB pointer + unconditionally: it returns HobStart back if HobStart itself meets the requirement; + caller is required to use GET_NEXT_HOB() if it wishes to skip current HobStart. + If HobStart is NULL, then ASSERT(). + + @param Type The HOB type to return. + @param HobStart The starting HOB pointer to search from. + + @return The next instance of a HOB type from the starting HOB. + +**/ +VOID * +EFIAPI +GetNextHob ( + IN UINT16 Type, + IN CONST VOID *HobStart + ) +; + +/** + Returns the first instance of a HOB type among the whole HOB list. + + This function searches the first instance of a HOB type among the whole HOB list. + If there does not exist such HOB type in the HOB list, it will return NULL. + + @param Type The HOB type to return. + + @return The next instance of a HOB type from the starting HOB. + +**/ +VOID * +EFIAPI +GetFirstHob ( + IN UINT16 Type + ) +; + +/** + This function searches the first instance of a HOB from the starting HOB pointer. + Such HOB should satisfy two conditions: + its HOB type is EFI_HOB_TYPE_GUID_EXTENSION and its GUID Name equals to the input Guid. + If there does not exist such HOB from the starting HOB pointer, it will return NULL. + Caller is required to apply GET_GUID_HOB_DATA () and GET_GUID_HOB_DATA_SIZE () + to extract the data section and its size info respectively. + In contrast with macro GET_NEXT_HOB(), this function does not skip the starting HOB pointer + unconditionally: it returns HobStart back if HobStart itself meets the requirement; + caller is required to use GET_NEXT_HOB() if it wishes to skip current HobStart. + If Guid is NULL, then ASSERT(). + If HobStart is NULL, then ASSERT(). + + @param Guid The GUID to match with in the HOB list. + @param HobStart A pointer to a Guid. + + @return The next instance of the matched GUID HOB from the starting HOB. + +**/ +VOID * +EFIAPI +GlueGetNextGuidHob ( + IN CONST EFI_GUID *Guid, + IN CONST VOID *HobStart + ) +; + +/** + This function searches the first instance of a HOB among the whole HOB list. + Such HOB should satisfy two conditions: + its HOB type is EFI_HOB_TYPE_GUID_EXTENSION and its GUID Name equals to the input Guid. + If there does not exist such HOB from the starting HOB pointer, it will return NULL. + Caller is required to apply GET_GUID_HOB_DATA () and GET_GUID_HOB_DATA_SIZE () + to extract the data section and its size info respectively. + If Guid is NULL, then ASSERT(). + + @param Guid The GUID to match with in the HOB list. + + @return The first instance of the matched GUID HOB among the whole HOB list. + +**/ +VOID * +EFIAPI +GlueGetFirstGuidHob ( + IN CONST EFI_GUID *Guid + ) +; + +/** + Get the Boot Mode from the HOB list. + + This function returns the system boot mode information from the + PHIT HOB in HOB list. + + @param VOID + + @return The Boot Mode. + +**/ +EFI_BOOT_MODE +EFIAPI +GetBootModeHob ( + VOID + ) +; + +/** + Builds a HOB for a loaded PE32 module. + + This function builds a HOB for a loaded PE32 module. + It can only be invoked during PEI phase; + for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase. + If ModuleName is NULL, then ASSERT(). + If there is no additional space for HOB creation, then ASSERT(). + + @param ModuleName The GUID File Name of the module. + @param MemoryAllocationModule The 64 bit physical address of the module. + @param ModuleLength The length of the module in bytes. + @param EntryPoint The 64 bit physical address of the module entry point. + +**/ +VOID +EFIAPI +GlueBuildModuleHob ( + IN CONST EFI_GUID *ModuleName, + IN EFI_PHYSICAL_ADDRESS MemoryAllocationModule, + IN UINT64 ModuleLength, + IN EFI_PHYSICAL_ADDRESS EntryPoint + ) +; + +/** + Builds a HOB that describes a chunk of system memory. + + This function builds a HOB that describes a chunk of system memory. + It can only be invoked during PEI phase; + for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase. + If there is no additional space for HOB creation, then ASSERT(). + + @param ResourceType The type of resource described by this HOB. + @param ResourceAttribute The resource attributes of the memory described by this HOB. + @param PhysicalStart The 64 bit physical address of memory described by this HOB. + @param NumberOfBytes The length of the memory described by this HOB in bytes. + +**/ +VOID +EFIAPI +BuildResourceDescriptorHob ( + IN EFI_RESOURCE_TYPE ResourceType, + IN EFI_RESOURCE_ATTRIBUTE_TYPE ResourceAttribute, + IN EFI_PHYSICAL_ADDRESS PhysicalStart, + IN UINT64 NumberOfBytes + ) +; + +/** + Builds a GUID HOB with a certain data length. + + This function builds a customized HOB tagged with a GUID for identification + and returns the start address of GUID HOB data so that caller can fill the customized data. + The HOB Header and Name field is already stripped. + It can only be invoked during PEI phase; + for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase. + If Guid is NULL, then ASSERT(). + If there is no additional space for HOB creation, then ASSERT(). + If DataLength >= (0x10000 - sizeof (EFI_HOB_GUID_TYPE)), then ASSERT(). + + @param Guid The GUID to tag the customized HOB. + @param DataLength The size of the data payload for the GUID HOB. + + @return The start address of GUID HOB data. + +**/ +VOID * +EFIAPI +BuildGuidHob ( + IN CONST EFI_GUID *Guid, + IN UINTN DataLength + ) +; + +/** + Copies a data buffer to a newly-built HOB. + + This function builds a customized HOB tagged with a GUID for identification, + copies the input data to the HOB data field and returns the start address of the GUID HOB data. + The HOB Header and Name field is already stripped. + It can only be invoked during PEI phase; + for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase. + If Guid is NULL, then ASSERT(). + If Data is NULL and DataLength > 0, then ASSERT(). + If there is no additional space for HOB creation, then ASSERT(). + If DataLength >= (0x10000 - sizeof (EFI_HOB_GUID_TYPE)), then ASSERT(). + + @param Guid The GUID to tag the customized HOB. + @param Data The data to be copied into the data field of the GUID HOB. + @param DataLength The size of the data payload for the GUID HOB. + + @return The start address of GUID HOB data. + +**/ +VOID * +EFIAPI +BuildGuidDataHob ( + IN CONST EFI_GUID *Guid, + IN VOID *Data, + IN UINTN DataLength + ) +; + +/** + Builds a Firmware Volume HOB. + + This function builds a Firmware Volume HOB. + It can only be invoked during PEI phase; + for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase. + If there is no additional space for HOB creation, then ASSERT(). + + @param BaseAddress The base address of the Firmware Volume. + @param Length The size of the Firmware Volume in bytes. + +**/ +VOID +EFIAPI +BuildFvHob ( + IN EFI_PHYSICAL_ADDRESS BaseAddress, + IN UINT64 Length + ) +; + +/** + Builds a Capsule Volume HOB. + + This function builds a Capsule Volume HOB. + It can only be invoked during PEI phase; + for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase. + If there is no additional space for HOB creation, then ASSERT(). + + @param BaseAddress The base address of the Capsule Volume. + @param Length The size of the Capsule Volume in bytes. + +**/ +VOID +EFIAPI +BuildCvHob ( + IN EFI_PHYSICAL_ADDRESS BaseAddress, + IN UINT64 Length + ) +; + +/** + Builds a HOB for the CPU. + + This function builds a HOB for the CPU. + It can only be invoked during PEI phase; + for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase. + If there is no additional space for HOB creation, then ASSERT(). + + @param SizeOfMemorySpace The maximum physical memory addressability of the processor. + @param SizeOfIoSpace The maximum physical I/O addressability of the processor. + +**/ +VOID +EFIAPI +BuildCpuHob ( + IN UINT8 SizeOfMemorySpace, + IN UINT8 SizeOfIoSpace + ) +; + +/** + Builds a HOB for the Stack. + + This function builds a HOB for the stack. + It can only be invoked during PEI phase; + for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase. + If there is no additional space for HOB creation, then ASSERT(). + + @param BaseAddress The 64 bit physical address of the Stack. + @param Length The length of the stack in bytes. + +**/ +VOID +EFIAPI +BuildStackHob ( + IN EFI_PHYSICAL_ADDRESS BaseAddress, + IN UINT64 Length + ) +; + +/** + Builds a HOB for the BSP store. + + This function builds a HOB for BSP store. + It can only be invoked during PEI phase; + for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase. + If there is no additional space for HOB creation, then ASSERT(). + + @param BaseAddress The 64 bit physical address of the BSP. + @param Length The length of the BSP store in bytes. + @param MemoryType Type of memory allocated by this HOB. + +**/ +VOID +EFIAPI +BuildBspStoreHob ( + IN EFI_PHYSICAL_ADDRESS BaseAddress, + IN UINT64 Length, + IN EFI_MEMORY_TYPE MemoryType + ) +; + +/** + Builds a HOB for the memory allocation. + + This function builds a HOB for the memory allocation. + It can only be invoked during PEI phase; + for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase. + If there is no additional space for HOB creation, then ASSERT(). + + @param BaseAddress The 64 bit physical address of the memory. + @param Length The length of the memory allocation in bytes. + @param MemoryType Type of memory allocated by this HOB. + +**/ +VOID +EFIAPI +GlueBuildMemoryAllocationHob ( + IN EFI_PHYSICAL_ADDRESS BaseAddress, + IN UINT64 Length, + IN EFI_MEMORY_TYPE MemoryType + ) +; + +#endif diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueIoLib.h b/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueIoLib.h new file mode 100644 index 0000000..73f1df2 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueIoLib.h @@ -0,0 +1,2326 @@ +/*++ + +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: + + EdkIIGlueIoLib.h + +Abstract: + + Public header file for IO Lib + +--*/ + +#ifndef __EDKII_GLUE_IO_LIB_H__ +#define __EDKII_GLUE_IO_LIB_H__ + + +#define IoRead8(_PORT) GlueIoRead8(_PORT) +#define IoWrite8(_PORT,_VALUE) GlueIoWrite8(_PORT,_VALUE) +#define IoRead16(_PORT) GlueIoRead16(_PORT) +#define IoWrite16(_PORT,_VALUE) GlueIoWrite16(_PORT,_VALUE) +#define IoRead32(_PORT) GlueIoRead32(_PORT) +#define IoWrite32(_PORT,_VALUE) GlueIoWrite32(_PORT,_VALUE) + + +#define IO_LIB_ADDRESS(Segment,Port) \ + ( ((Port) & 0xffff) | (((Segment) & 0xffff) << 16) ) + +/** + Reads an 8-bit I/O port. + + Reads the 8-bit I/O port specified by Port. The 8-bit read value is returned. + This function must guarantee that all I/O read and write operations are + serialized. + + If 8-bit I/O port operations are not supported, then ASSERT(). + + @param Port The I/O port to read. + + @return The value read. + +**/ +UINT8 +EFIAPI +GlueIoRead8 ( + IN UINTN Port + ); + +/** + Writes an 8-bit I/O port. + + Writes the 8-bit I/O port specified by Port with the value specified by Value + and returns Value. This function must guarantee that all I/O read and write + operations are serialized. + + If 8-bit I/O port operations are not supported, then ASSERT(). + + @param Port The I/O port to write. + @param Value The value to write to the I/O port. + + @return The value written the I/O port. + +**/ +UINT8 +EFIAPI +GlueIoWrite8 ( + IN UINTN Port, + IN UINT8 Value + ); + +/** + Reads an 8-bit I/O port, performs a bitwise inclusive OR, and writes the + result back to the 8-bit I/O port. + + Reads the 8-bit I/O port specified by Port, performs a bitwise inclusive OR + between the read result and the value specified by OrData, and writes the + result to the 8-bit I/O port specified by Port. The value written to the I/O + port is returned. This function must guarantee that all I/O read and write + operations are serialized. + + If 8-bit I/O port operations are not supported, then ASSERT(). + + @param Port The I/O port to write. + @param OrData The value to OR with the read value from the I/O port. + + @return The value written back to the I/O port. + +**/ +UINT8 +EFIAPI +IoOr8 ( + IN UINTN Port, + IN UINT8 OrData + ); + +/** + Reads an 8-bit I/O port, performs a bitwise AND, and writes the result back + to the 8-bit I/O port. + + Reads the 8-bit I/O port specified by Port, performs a bitwise AND between + the read result and the value specified by AndData, and writes the result to + the 8-bit I/O port specified by Port. The value written to the I/O port is + returned. This function must guarantee that all I/O read and write operations + are serialized. + + If 8-bit I/O port operations are not supported, then ASSERT(). + + @param Port The I/O port to write. + @param AndData The value to AND with the read value from the I/O port. + + @return The value written back to the I/O port. + +**/ +UINT8 +EFIAPI +IoAnd8 ( + IN UINTN Port, + IN UINT8 AndData + ); + +/** + Reads an 8-bit I/O port, performs a bitwise AND followed by a bitwise + inclusive OR, and writes the result back to the 8-bit I/O port. + + Reads the 8-bit I/O port specified by Port, performs a bitwise AND between + the read result and the value specified by AndData, performs a bitwise OR + between the result of the AND operation and the value specified by OrData, + and writes the result to the 8-bit I/O port specified by Port. The value + written to the I/O port is returned. This function must guarantee that all + I/O read and write operations are serialized. + + If 8-bit I/O port operations are not supported, then ASSERT(). + + @param Port The I/O port to write. + @param AndData The value to AND with the read value from the I/O port. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the I/O port. + +**/ +UINT8 +EFIAPI +IoAndThenOr8 ( + IN UINTN Port, + IN UINT8 AndData, + IN UINT8 OrData + ); + +/** + Reads a bit field of an I/O register. + + Reads the bit field in an 8-bit I/O register. The bit field is specified by + the StartBit and the EndBit. The value of the bit field is returned. + + If 8-bit I/O port operations are not supported, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Port The I/O port to read. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..7. + + @return The value read. + +**/ +UINT8 +EFIAPI +IoBitFieldRead8 ( + IN UINTN Port, + IN UINTN StartBit, + IN UINTN EndBit + ); + +/** + Writes a bit field to an I/O register. + + Writes Value to the bit field of the I/O register. The bit field is specified + by the StartBit and the EndBit. All other bits in the destination I/O + register are preserved. The value written to the I/O port is returned. Extra + left bits in Value are stripped. + + If 8-bit I/O port operations are not supported, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Port The I/O port to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..7. + @param Value New value of the bit field. + + @return The value written back to the I/O port. + +**/ +UINT8 +EFIAPI +IoBitFieldWrite8 ( + IN UINTN Port, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT8 Value + ); + +/** + Reads a bit field in an 8-bit port, performs a bitwise OR, and writes the + result back to the bit field in the 8-bit port. + + Reads the 8-bit I/O port specified by Port, performs a bitwise inclusive OR + between the read result and the value specified by OrData, and writes the + result to the 8-bit I/O port specified by Port. The value written to the I/O + port is returned. This function must guarantee that all I/O read and write + operations are serialized. Extra left bits in OrData are stripped. + + If 8-bit I/O port operations are not supported, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Port The I/O port to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..7. + @param OrData The value to OR with the read value from the I/O port. + + @return The value written back to the I/O port. + +**/ +UINT8 +EFIAPI +IoBitFieldOr8 ( + IN UINTN Port, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT8 OrData + ); + +/** + Reads a bit field in an 8-bit port, performs a bitwise AND, and writes the + result back to the bit field in the 8-bit port. + + Reads the 8-bit I/O port specified by Port, performs a bitwise AND between + the read result and the value specified by AndData, and writes the result to + the 8-bit I/O port specified by Port. The value written to the I/O port is + returned. This function must guarantee that all I/O read and write operations + are serialized. Extra left bits in AndData are stripped. + + If 8-bit I/O port operations are not supported, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Port The I/O port to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..7. + @param AndData The value to AND with the read value from the I/O port. + + @return The value written back to the I/O port. + +**/ +UINT8 +EFIAPI +IoBitFieldAnd8 ( + IN UINTN Port, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT8 AndData + ); + +/** + Reads a bit field in an 8-bit port, performs a bitwise AND followed by a + bitwise inclusive OR, and writes the result back to the bit field in the + 8-bit port. + + Reads the 8-bit I/O port specified by Port, performs a bitwise AND followed + by a bitwise inclusive OR between the read result and the value specified by + AndData, and writes the result to the 8-bit I/O port specified by Port. The + value written to the I/O port is returned. This function must guarantee that + all I/O read and write operations are serialized. Extra left bits in both + AndData and OrData are stripped. + + If 8-bit I/O port operations are not supported, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Port The I/O port to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..7. + @param AndData The value to AND with the read value from the I/O port. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the I/O port. + +**/ +UINT8 +EFIAPI +IoBitFieldAndThenOr8 ( + IN UINTN Port, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT8 AndData, + IN UINT8 OrData + ); + +/** + Reads a 16-bit I/O port. + + Reads the 16-bit I/O port specified by Port. The 16-bit read value is returned. + This function must guarantee that all I/O read and write operations are + serialized. + + If 16-bit I/O port operations are not supported, then ASSERT(). + + @param Port The I/O port to read. + + @return The value read. + +**/ +UINT16 +EFIAPI +GlueIoRead16 ( + IN UINTN Port + ); + +/** + Writes a 16-bit I/O port. + + Writes the 16-bit I/O port specified by Port with the value specified by Value + and returns Value. This function must guarantee that all I/O read and write + operations are serialized. + + If 16-bit I/O port operations are not supported, then ASSERT(). + + @param Port The I/O port to write. + @param Value The value to write to the I/O port. + + @return The value written the I/O port. + +**/ +UINT16 +EFIAPI +GlueIoWrite16 ( + IN UINTN Port, + IN UINT16 Value + ); + +/** + Reads a 16-bit I/O port, performs a bitwise inclusive OR, and writes the + result back to the 16-bit I/O port. + + Reads the 16-bit I/O port specified by Port, performs a bitwise inclusive OR + between the read result and the value specified by OrData, and writes the + result to the 16-bit I/O port specified by Port. The value written to the I/O + port is returned. This function must guarantee that all I/O read and write + operations are serialized. + + If 16-bit I/O port operations are not supported, then ASSERT(). + + @param Port The I/O port to write. + @param OrData The value to OR with the read value from the I/O port. + + @return The value written back to the I/O port. + +**/ +UINT16 +EFIAPI +IoOr16 ( + IN UINTN Port, + IN UINT16 OrData + ); + +/** + Reads a 16-bit I/O port, performs a bitwise AND, and writes the result back + to the 16-bit I/O port. + + Reads the 16-bit I/O port specified by Port, performs a bitwise AND between + the read result and the value specified by AndData, and writes the result to + the 16-bit I/O port specified by Port. The value written to the I/O port is + returned. This function must guarantee that all I/O read and write operations + are serialized. + + If 16-bit I/O port operations are not supported, then ASSERT(). + + @param Port The I/O port to write. + @param AndData The value to AND with the read value from the I/O port. + + @return The value written back to the I/O port. + +**/ +UINT16 +EFIAPI +IoAnd16 ( + IN UINTN Port, + IN UINT16 AndData + ); + +/** + Reads a 16-bit I/O port, performs a bitwise AND followed by a bitwise + inclusive OR, and writes the result back to the 16-bit I/O port. + + Reads the 16-bit I/O port specified by Port, performs a bitwise AND between + the read result and the value specified by AndData, performs a bitwise OR + between the result of the AND operation and the value specified by OrData, + and writes the result to the 16-bit I/O port specified by Port. The value + written to the I/O port is returned. This function must guarantee that all + I/O read and write operations are serialized. + + If 16-bit I/O port operations are not supported, then ASSERT(). + + @param Port The I/O port to write. + @param AndData The value to AND with the read value from the I/O port. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the I/O port. + +**/ +UINT16 +EFIAPI +IoAndThenOr16 ( + IN UINTN Port, + IN UINT16 AndData, + IN UINT16 OrData + ); + +/** + Reads a bit field of an I/O register. + + Reads the bit field in a 16-bit I/O register. The bit field is specified by + the StartBit and the EndBit. The value of the bit field is returned. + + If 16-bit I/O port operations are not supported, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Port The I/O port to read. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..15. + + @return The value read. + +**/ +UINT16 +EFIAPI +IoBitFieldRead16 ( + IN UINTN Port, + IN UINTN StartBit, + IN UINTN EndBit + ); + +/** + Writes a bit field to an I/O register. + + Writes Value to the bit field of the I/O register. The bit field is specified + by the StartBit and the EndBit. All other bits in the destination I/O + register are preserved. The value written to the I/O port is returned. Extra + left bits in Value are stripped. + + If 16-bit I/O port operations are not supported, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Port The I/O port to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..15. + @param Value New value of the bit field. + + @return The value written back to the I/O port. + +**/ +UINT16 +EFIAPI +IoBitFieldWrite16 ( + IN UINTN Port, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT16 Value + ); + +/** + Reads a bit field in a 16-bit port, performs a bitwise OR, and writes the + result back to the bit field in the 16-bit port. + + Reads the 16-bit I/O port specified by Port, performs a bitwise inclusive OR + between the read result and the value specified by OrData, and writes the + result to the 16-bit I/O port specified by Port. The value written to the I/O + port is returned. This function must guarantee that all I/O read and write + operations are serialized. Extra left bits in OrData are stripped. + + If 16-bit I/O port operations are not supported, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Port The I/O port to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..15. + @param OrData The value to OR with the read value from the I/O port. + + @return The value written back to the I/O port. + +**/ +UINT16 +EFIAPI +IoBitFieldOr16 ( + IN UINTN Port, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT16 OrData + ); + +/** + Reads a bit field in a 16-bit port, performs a bitwise AND, and writes the + result back to the bit field in the 16-bit port. + + Reads the 16-bit I/O port specified by Port, performs a bitwise AND between + the read result and the value specified by AndData, and writes the result to + the 16-bit I/O port specified by Port. The value written to the I/O port is + returned. This function must guarantee that all I/O read and write operations + are serialized. Extra left bits in AndData are stripped. + + If 16-bit I/O port operations are not supported, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Port The I/O port to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..15. + @param AndData The value to AND with the read value from the I/O port. + + @return The value written back to the I/O port. + +**/ +UINT16 +EFIAPI +IoBitFieldAnd16 ( + IN UINTN Port, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT16 AndData + ); + +/** + Reads a bit field in a 16-bit port, performs a bitwise AND followed by a + bitwise inclusive OR, and writes the result back to the bit field in the + 16-bit port. + + Reads the 16-bit I/O port specified by Port, performs a bitwise AND followed + by a bitwise inclusive OR between the read result and the value specified by + AndData, and writes the result to the 16-bit I/O port specified by Port. The + value written to the I/O port is returned. This function must guarantee that + all I/O read and write operations are serialized. Extra left bits in both + AndData and OrData are stripped. + + If 16-bit I/O port operations are not supported, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Port The I/O port to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..15. + @param AndData The value to AND with the read value from the I/O port. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the I/O port. + +**/ +UINT16 +EFIAPI +IoBitFieldAndThenOr16 ( + IN UINTN Port, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT16 AndData, + IN UINT16 OrData + ); + +/** + Reads a 32-bit I/O port. + + Reads the 32-bit I/O port specified by Port. The 32-bit read value is returned. + This function must guarantee that all I/O read and write operations are + serialized. + + If 32-bit I/O port operations are not supported, then ASSERT(). + + @param Port The I/O port to read. + + @return The value read. + +**/ +UINT32 +EFIAPI +GlueIoRead32 ( + IN UINTN Port + ); + +/** + Writes a 32-bit I/O port. + + Writes the 32-bit I/O port specified by Port with the value specified by Value + and returns Value. This function must guarantee that all I/O read and write + operations are serialized. + + If 32-bit I/O port operations are not supported, then ASSERT(). + + @param Port The I/O port to write. + @param Value The value to write to the I/O port. + + @return The value written the I/O port. + +**/ +UINT32 +EFIAPI +GlueIoWrite32 ( + IN UINTN Port, + IN UINT32 Value + ); + +/** + Reads a 32-bit I/O port, performs a bitwise inclusive OR, and writes the + result back to the 32-bit I/O port. + + Reads the 32-bit I/O port specified by Port, performs a bitwise inclusive OR + between the read result and the value specified by OrData, and writes the + result to the 32-bit I/O port specified by Port. The value written to the I/O + port is returned. This function must guarantee that all I/O read and write + operations are serialized. + + If 32-bit I/O port operations are not supported, then ASSERT(). + + @param Port The I/O port to write. + @param OrData The value to OR with the read value from the I/O port. + + @return The value written back to the I/O port. + +**/ +UINT32 +EFIAPI +IoOr32 ( + IN UINTN Port, + IN UINT32 OrData + ); + +/** + Reads a 32-bit I/O port, performs a bitwise AND, and writes the result back + to the 32-bit I/O port. + + Reads the 32-bit I/O port specified by Port, performs a bitwise AND between + the read result and the value specified by AndData, and writes the result to + the 32-bit I/O port specified by Port. The value written to the I/O port is + returned. This function must guarantee that all I/O read and write operations + are serialized. + + If 32-bit I/O port operations are not supported, then ASSERT(). + + @param Port The I/O port to write. + @param AndData The value to AND with the read value from the I/O port. + + @return The value written back to the I/O port. + +**/ +UINT32 +EFIAPI +IoAnd32 ( + IN UINTN Port, + IN UINT32 AndData + ); + +/** + Reads a 32-bit I/O port, performs a bitwise AND followed by a bitwise + inclusive OR, and writes the result back to the 32-bit I/O port. + + Reads the 32-bit I/O port specified by Port, performs a bitwise AND between + the read result and the value specified by AndData, performs a bitwise OR + between the result of the AND operation and the value specified by OrData, + and writes the result to the 32-bit I/O port specified by Port. The value + written to the I/O port is returned. This function must guarantee that all + I/O read and write operations are serialized. + + If 32-bit I/O port operations are not supported, then ASSERT(). + + @param Port The I/O port to write. + @param AndData The value to AND with the read value from the I/O port. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the I/O port. + +**/ +UINT32 +EFIAPI +IoAndThenOr32 ( + IN UINTN Port, + IN UINT32 AndData, + IN UINT32 OrData + ); + +/** + Reads a bit field of an I/O register. + + Reads the bit field in a 32-bit I/O register. The bit field is specified by + the StartBit and the EndBit. The value of the bit field is returned. + + If 32-bit I/O port operations are not supported, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Port The I/O port to read. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + + @return The value read. + +**/ +UINT32 +EFIAPI +IoBitFieldRead32 ( + IN UINTN Port, + IN UINTN StartBit, + IN UINTN EndBit + ); + +/** + Writes a bit field to an I/O register. + + Writes Value to the bit field of the I/O register. The bit field is specified + by the StartBit and the EndBit. All other bits in the destination I/O + register are preserved. The value written to the I/O port is returned. Extra + left bits in Value are stripped. + + If 32-bit I/O port operations are not supported, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Port The I/O port to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + @param Value New value of the bit field. + + @return The value written back to the I/O port. + +**/ +UINT32 +EFIAPI +IoBitFieldWrite32 ( + IN UINTN Port, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT32 Value + ); + +/** + Reads a bit field in a 32-bit port, performs a bitwise OR, and writes the + result back to the bit field in the 32-bit port. + + Reads the 32-bit I/O port specified by Port, performs a bitwise inclusive OR + between the read result and the value specified by OrData, and writes the + result to the 32-bit I/O port specified by Port. The value written to the I/O + port is returned. This function must guarantee that all I/O read and write + operations are serialized. Extra left bits in OrData are stripped. + + If 32-bit I/O port operations are not supported, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Port The I/O port to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + @param OrData The value to OR with the read value from the I/O port. + + @return The value written back to the I/O port. + +**/ +UINT32 +EFIAPI +IoBitFieldOr32 ( + IN UINTN Port, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT32 OrData + ); + +/** + Reads a bit field in a 32-bit port, performs a bitwise AND, and writes the + result back to the bit field in the 32-bit port. + + Reads the 32-bit I/O port specified by Port, performs a bitwise AND between + the read result and the value specified by AndData, and writes the result to + the 32-bit I/O port specified by Port. The value written to the I/O port is + returned. This function must guarantee that all I/O read and write operations + are serialized. Extra left bits in AndData are stripped. + + If 32-bit I/O port operations are not supported, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Port The I/O port to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + @param AndData The value to AND with the read value from the I/O port. + + @return The value written back to the I/O port. + +**/ +UINT32 +EFIAPI +IoBitFieldAnd32 ( + IN UINTN Port, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT32 AndData + ); + +/** + Reads a bit field in a 32-bit port, performs a bitwise AND followed by a + bitwise inclusive OR, and writes the result back to the bit field in the + 32-bit port. + + Reads the 32-bit I/O port specified by Port, performs a bitwise AND followed + by a bitwise inclusive OR between the read result and the value specified by + AndData, and writes the result to the 32-bit I/O port specified by Port. The + value written to the I/O port is returned. This function must guarantee that + all I/O read and write operations are serialized. Extra left bits in both + AndData and OrData are stripped. + + If 32-bit I/O port operations are not supported, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Port The I/O port to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + @param AndData The value to AND with the read value from the I/O port. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the I/O port. + +**/ +UINT32 +EFIAPI +IoBitFieldAndThenOr32 ( + IN UINTN Port, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT32 AndData, + IN UINT32 OrData + ); + +/** + Reads a 64-bit I/O port. + + Reads the 64-bit I/O port specified by Port. The 64-bit read value is returned. + This function must guarantee that all I/O read and write operations are + serialized. + + If 64-bit I/O port operations are not supported, then ASSERT(). + + @param Port The I/O port to read. + + @return The value read. + +**/ +UINT64 +EFIAPI +IoRead64 ( + IN UINTN Port + ); + +/** + Writes a 64-bit I/O port. + + Writes the 64-bit I/O port specified by Port with the value specified by Value + and returns Value. This function must guarantee that all I/O read and write + operations are serialized. + + If 64-bit I/O port operations are not supported, then ASSERT(). + + @param Port The I/O port to write. + @param Value The value to write to the I/O port. + + @return The value written the I/O port. + +**/ +UINT64 +EFIAPI +IoWrite64 ( + IN UINTN Port, + IN UINT64 Value + ); + +/** + Reads a 64-bit I/O port, performs a bitwise inclusive OR, and writes the + result back to the 64-bit I/O port. + + Reads the 64-bit I/O port specified by Port, performs a bitwise inclusive OR + between the read result and the value specified by OrData, and writes the + result to the 64-bit I/O port specified by Port. The value written to the I/O + port is returned. This function must guarantee that all I/O read and write + operations are serialized. + + If 64-bit I/O port operations are not supported, then ASSERT(). + + @param Port The I/O port to write. + @param OrData The value to OR with the read value from the I/O port. + + @return The value written back to the I/O port. + +**/ +UINT64 +EFIAPI +IoOr64 ( + IN UINTN Port, + IN UINT64 OrData + ); + +/** + Reads a 64-bit I/O port, performs a bitwise AND, and writes the result back + to the 64-bit I/O port. + + Reads the 64-bit I/O port specified by Port, performs a bitwise AND between + the read result and the value specified by AndData, and writes the result to + the 64-bit I/O port specified by Port. The value written to the I/O port is + returned. This function must guarantee that all I/O read and write operations + are serialized. + + If 64-bit I/O port operations are not supported, then ASSERT(). + + @param Port The I/O port to write. + @param AndData The value to AND with the read value from the I/O port. + + @return The value written back to the I/O port. + +**/ +UINT64 +EFIAPI +IoAnd64 ( + IN UINTN Port, + IN UINT64 AndData + ); + +/** + Reads a 64-bit I/O port, performs a bitwise AND followed by a bitwise + inclusive OR, and writes the result back to the 64-bit I/O port. + + Reads the 64-bit I/O port specified by Port, performs a bitwise AND between + the read result and the value specified by AndData, performs a bitwise OR + between the result of the AND operation and the value specified by OrData, + and writes the result to the 64-bit I/O port specified by Port. The value + written to the I/O port is returned. This function must guarantee that all + I/O read and write operations are serialized. + + If 64-bit I/O port operations are not supported, then ASSERT(). + + @param Port The I/O port to write. + @param AndData The value to AND with the read value from the I/O port. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the I/O port. + +**/ +UINT64 +EFIAPI +IoAndThenOr64 ( + IN UINTN Port, + IN UINT64 AndData, + IN UINT64 OrData + ); + +/** + Reads a bit field of an I/O register. + + Reads the bit field in a 64-bit I/O register. The bit field is specified by + the StartBit and the EndBit. The value of the bit field is returned. + + If 64-bit I/O port operations are not supported, then ASSERT(). + If StartBit is greater than 63, then ASSERT(). + If EndBit is greater than 63, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Port The I/O port to read. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..63. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..63. + + @return The value read. + +**/ +UINT64 +EFIAPI +IoBitFieldRead64 ( + IN UINTN Port, + IN UINTN StartBit, + IN UINTN EndBit + ); + +/** + Writes a bit field to an I/O register. + + Writes Value to the bit field of the I/O register. The bit field is specified + by the StartBit and the EndBit. All other bits in the destination I/O + register are preserved. The value written to the I/O port is returned. Extra + left bits in Value are stripped. + + If 64-bit I/O port operations are not supported, then ASSERT(). + If StartBit is greater than 63, then ASSERT(). + If EndBit is greater than 63, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Port The I/O port to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..63. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..63. + @param Value New value of the bit field. + + @return The value written back to the I/O port. + +**/ +UINT64 +EFIAPI +IoBitFieldWrite64 ( + IN UINTN Port, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT64 Value + ); + +/** + Reads a bit field in a 64-bit port, performs a bitwise OR, and writes the + result back to the bit field in the 64-bit port. + + Reads the 64-bit I/O port specified by Port, performs a bitwise inclusive OR + between the read result and the value specified by OrData, and writes the + result to the 64-bit I/O port specified by Port. The value written to the I/O + port is returned. This function must guarantee that all I/O read and write + operations are serialized. Extra left bits in OrData are stripped. + + If 64-bit I/O port operations are not supported, then ASSERT(). + If StartBit is greater than 63, then ASSERT(). + If EndBit is greater than 63, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Port The I/O port to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..63. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..63. + @param OrData The value to OR with the read value from the I/O port. + + @return The value written back to the I/O port. + +**/ +UINT64 +EFIAPI +IoBitFieldOr64 ( + IN UINTN Port, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT64 OrData + ); + +/** + Reads a bit field in a 64-bit port, performs a bitwise AND, and writes the + result back to the bit field in the 64-bit port. + + Reads the 64-bit I/O port specified by Port, performs a bitwise AND between + the read result and the value specified by AndData, and writes the result to + the 64-bit I/O port specified by Port. The value written to the I/O port is + returned. This function must guarantee that all I/O read and write operations + are serialized. Extra left bits in AndData are stripped. + + If 64-bit I/O port operations are not supported, then ASSERT(). + If StartBit is greater than 63, then ASSERT(). + If EndBit is greater than 63, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Port The I/O port to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..63. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..63. + @param AndData The value to AND with the read value from the I/O port. + + @return The value written back to the I/O port. + +**/ +UINT64 +EFIAPI +IoBitFieldAnd64 ( + IN UINTN Port, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT64 AndData + ); + +/** + Reads a bit field in a 64-bit port, performs a bitwise AND followed by a + bitwise inclusive OR, and writes the result back to the bit field in the + 64-bit port. + + Reads the 64-bit I/O port specified by Port, performs a bitwise AND followed + by a bitwise inclusive OR between the read result and the value specified by + AndData, and writes the result to the 64-bit I/O port specified by Port. The + value written to the I/O port is returned. This function must guarantee that + all I/O read and write operations are serialized. Extra left bits in both + AndData and OrData are stripped. + + If 64-bit I/O port operations are not supported, then ASSERT(). + If StartBit is greater than 63, then ASSERT(). + If EndBit is greater than 63, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Port The I/O port to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..63. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..63. + @param AndData The value to AND with the read value from the I/O port. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the I/O port. + +**/ +UINT64 +EFIAPI +IoBitFieldAndThenOr64 ( + IN UINTN Port, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT64 AndData, + IN UINT64 OrData + ); + +/** + Reads an 8-bit MMIO register. + + Reads the 8-bit MMIO register specified by Address. The 8-bit read value is + returned. This function must guarantee that all MMIO read and write + operations are serialized. + + If 8-bit MMIO register operations are not supported, then ASSERT(). + + @param Address The MMIO register to read. + + @return The value read. + +**/ +UINT8 +EFIAPI +MmioRead8 ( + IN UINTN Address + ); + +/** + Writes an 8-bit MMIO register. + + Writes the 8-bit MMIO register specified by Address with the value specified + by Value and returns Value. This function must guarantee that all MMIO read + and write operations are serialized. + + If 8-bit MMIO register operations are not supported, then ASSERT(). + + @param Address The MMIO register to write. + @param Value The value to write to the MMIO register. + +**/ +UINT8 +EFIAPI +MmioWrite8 ( + IN UINTN Address, + IN UINT8 Value + ); + +/** + Reads an 8-bit MMIO register, performs a bitwise inclusive OR, and writes the + result back to the 8-bit MMIO register. + + Reads the 8-bit MMIO register specified by Address, performs a bitwise + inclusive OR between the read result and the value specified by OrData, and + writes the result to the 8-bit MMIO register specified by Address. The value + written to the MMIO register is returned. This function must guarantee that + all MMIO read and write operations are serialized. + + If 8-bit MMIO register operations are not supported, then ASSERT(). + + @param Address The MMIO register to write. + @param OrData The value to OR with the read value from the MMIO register. + + @return The value written back to the MMIO register. + +**/ +UINT8 +EFIAPI +MmioOr8 ( + IN UINTN Address, + IN UINT8 OrData + ); + +/** + Reads an 8-bit MMIO register, performs a bitwise AND, and writes the result + back to the 8-bit MMIO register. + + Reads the 8-bit MMIO register specified by Address, performs a bitwise AND + between the read result and the value specified by AndData, and writes the + result to the 8-bit MMIO register specified by Address. The value written to + the MMIO register is returned. This function must guarantee that all MMIO + read and write operations are serialized. + + If 8-bit MMIO register operations are not supported, then ASSERT(). + + @param Address The MMIO register to write. + @param AndData The value to AND with the read value from the MMIO register. + + @return The value written back to the MMIO register. + +**/ +UINT8 +EFIAPI +MmioAnd8 ( + IN UINTN Address, + IN UINT8 AndData + ); + +/** + Reads an 8-bit MMIO register, performs a bitwise AND followed by a bitwise + inclusive OR, and writes the result back to the 8-bit MMIO register. + + Reads the 8-bit MMIO register specified by Address, performs a bitwise AND + between the read result and the value specified by AndData, performs a + bitwise OR between the result of the AND operation and the value specified by + OrData, and writes the result to the 8-bit MMIO register specified by + Address. The value written to the MMIO register is returned. This function + must guarantee that all MMIO read and write operations are serialized. + + If 8-bit MMIO register operations are not supported, then ASSERT(). + + + @param Address The MMIO register to write. + @param AndData The value to AND with the read value from the MMIO register. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the MMIO register. + +**/ +UINT8 +EFIAPI +MmioAndThenOr8 ( + IN UINTN Address, + IN UINT8 AndData, + IN UINT8 OrData + ); + +/** + Reads a bit field of a MMIO register. + + Reads the bit field in an 8-bit MMIO register. The bit field is specified by + the StartBit and the EndBit. The value of the bit field is returned. + + If 8-bit MMIO register operations are not supported, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address MMIO register to read. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..7. + + @return The value read. + +**/ +UINT8 +EFIAPI +MmioBitFieldRead8 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit + ); + +/** + Writes a bit field to a MMIO register. + + Writes Value to the bit field of the MMIO register. The bit field is + specified by the StartBit and the EndBit. All other bits in the destination + MMIO register are preserved. The new value of the 8-bit register is returned. + + If 8-bit MMIO register operations are not supported, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address MMIO register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..7. + @param Value New value of the bit field. + + @return The value written back to the MMIO register. + +**/ +UINT8 +EFIAPI +MmioBitFieldWrite8 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT8 Value + ); + +/** + Reads a bit field in an 8-bit MMIO register, performs a bitwise OR, and + writes the result back to the bit field in the 8-bit MMIO register. + + Reads the 8-bit MMIO register specified by Address, performs a bitwise + inclusive OR between the read result and the value specified by OrData, and + writes the result to the 8-bit MMIO register specified by Address. The value + written to the MMIO register is returned. This function must guarantee that + all MMIO read and write operations are serialized. Extra left bits in OrData + are stripped. + + If 8-bit MMIO register operations are not supported, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address MMIO register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..7. + @param OrData The value to OR with read value from the MMIO register. + + @return The value written back to the MMIO register. + +**/ +UINT8 +EFIAPI +MmioBitFieldOr8 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT8 OrData + ); + +/** + Reads a bit field in an 8-bit MMIO register, performs a bitwise AND, and + writes the result back to the bit field in the 8-bit MMIO register. + + Reads the 8-bit MMIO register specified by Address, performs a bitwise AND + between the read result and the value specified by AndData, and writes the + result to the 8-bit MMIO register specified by Address. The value written to + the MMIO register is returned. This function must guarantee that all MMIO + read and write operations are serialized. Extra left bits in AndData are + stripped. + + If 8-bit MMIO register operations are not supported, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address MMIO register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..7. + @param AndData The value to AND with read value from the MMIO register. + + @return The value written back to the MMIO register. + +**/ +UINT8 +EFIAPI +MmioBitFieldAnd8 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT8 AndData + ); + +/** + Reads a bit field in an 8-bit MMIO register, performs a bitwise AND followed + by a bitwise inclusive OR, and writes the result back to the bit field in the + 8-bit MMIO register. + + Reads the 8-bit MMIO register specified by Address, performs a bitwise AND + followed by a bitwise inclusive OR between the read result and the value + specified by AndData, and writes the result to the 8-bit MMIO register + specified by Address. The value written to the MMIO register is returned. + This function must guarantee that all MMIO read and write operations are + serialized. Extra left bits in both AndData and OrData are stripped. + + If 8-bit MMIO register operations are not supported, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address MMIO register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..7. + @param AndData The value to AND with read value from the MMIO register. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the MMIO register. + +**/ +UINT8 +EFIAPI +MmioBitFieldAndThenOr8 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT8 AndData, + IN UINT8 OrData + ); + +/** + Reads a 16-bit MMIO register. + + Reads the 16-bit MMIO register specified by Address. The 16-bit read value is + returned. This function must guarantee that all MMIO read and write + operations are serialized. + + If 16-bit MMIO register operations are not supported, then ASSERT(). + + @param Address The MMIO register to read. + + @return The value read. + +**/ +UINT16 +EFIAPI +MmioRead16 ( + IN UINTN Address + ); + +/** + Writes a 16-bit MMIO register. + + Writes the 16-bit MMIO register specified by Address with the value specified + by Value and returns Value. This function must guarantee that all MMIO read + and write operations are serialized. + + If 16-bit MMIO register operations are not supported, then ASSERT(). + + @param Address The MMIO register to write. + @param Value The value to write to the MMIO register. + +**/ +UINT16 +EFIAPI +MmioWrite16 ( + IN UINTN Address, + IN UINT16 Value + ); + +/** + Reads a 16-bit MMIO register, performs a bitwise inclusive OR, and writes the + result back to the 16-bit MMIO register. + + Reads the 16-bit MMIO register specified by Address, performs a bitwise + inclusive OR between the read result and the value specified by OrData, and + writes the result to the 16-bit MMIO register specified by Address. The value + written to the MMIO register is returned. This function must guarantee that + all MMIO read and write operations are serialized. + + If 16-bit MMIO register operations are not supported, then ASSERT(). + + @param Address The MMIO register to write. + @param OrData The value to OR with the read value from the MMIO register. + + @return The value written back to the MMIO register. + +**/ +UINT16 +EFIAPI +MmioOr16 ( + IN UINTN Address, + IN UINT16 OrData + ); + +/** + Reads a 16-bit MMIO register, performs a bitwise AND, and writes the result + back to the 16-bit MMIO register. + + Reads the 16-bit MMIO register specified by Address, performs a bitwise AND + between the read result and the value specified by AndData, and writes the + result to the 16-bit MMIO register specified by Address. The value written to + the MMIO register is returned. This function must guarantee that all MMIO + read and write operations are serialized. + + If 16-bit MMIO register operations are not supported, then ASSERT(). + + @param Address The MMIO register to write. + @param AndData The value to AND with the read value from the MMIO register. + + @return The value written back to the MMIO register. + +**/ +UINT16 +EFIAPI +MmioAnd16 ( + IN UINTN Address, + IN UINT16 AndData + ); + +/** + Reads a 16-bit MMIO register, performs a bitwise AND followed by a bitwise + inclusive OR, and writes the result back to the 16-bit MMIO register. + + Reads the 16-bit MMIO register specified by Address, performs a bitwise AND + between the read result and the value specified by AndData, performs a + bitwise OR between the result of the AND operation and the value specified by + OrData, and writes the result to the 16-bit MMIO register specified by + Address. The value written to the MMIO register is returned. This function + must guarantee that all MMIO read and write operations are serialized. + + If 16-bit MMIO register operations are not supported, then ASSERT(). + + + @param Address The MMIO register to write. + @param AndData The value to AND with the read value from the MMIO register. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the MMIO register. + +**/ +UINT16 +EFIAPI +MmioAndThenOr16 ( + IN UINTN Address, + IN UINT16 AndData, + IN UINT16 OrData + ); + +/** + Reads a bit field of a MMIO register. + + Reads the bit field in a 16-bit MMIO register. The bit field is specified by + the StartBit and the EndBit. The value of the bit field is returned. + + If 16-bit MMIO register operations are not supported, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address MMIO register to read. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..15. + + @return The value read. + +**/ +UINT16 +EFIAPI +MmioBitFieldRead16 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit + ); + +/** + Writes a bit field to a MMIO register. + + Writes Value to the bit field of the MMIO register. The bit field is + specified by the StartBit and the EndBit. All other bits in the destination + MMIO register are preserved. The new value of the 16-bit register is returned. + + If 16-bit MMIO register operations are not supported, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address MMIO register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..15. + @param Value New value of the bit field. + + @return The value written back to the MMIO register. + +**/ +UINT16 +EFIAPI +MmioBitFieldWrite16 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT16 Value + ); + +/** + Reads a bit field in a 16-bit MMIO register, performs a bitwise OR, and + writes the result back to the bit field in the 16-bit MMIO register. + + Reads the 16-bit MMIO register specified by Address, performs a bitwise + inclusive OR between the read result and the value specified by OrData, and + writes the result to the 16-bit MMIO register specified by Address. The value + written to the MMIO register is returned. This function must guarantee that + all MMIO read and write operations are serialized. Extra left bits in OrData + are stripped. + + If 16-bit MMIO register operations are not supported, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address MMIO register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..15. + @param OrData The value to OR with read value from the MMIO register. + + @return The value written back to the MMIO register. + +**/ +UINT16 +EFIAPI +MmioBitFieldOr16 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT16 OrData + ); + +/** + Reads a bit field in a 16-bit MMIO register, performs a bitwise AND, and + writes the result back to the bit field in the 16-bit MMIO register. + + Reads the 16-bit MMIO register specified by Address, performs a bitwise AND + between the read result and the value specified by AndData, and writes the + result to the 16-bit MMIO register specified by Address. The value written to + the MMIO register is returned. This function must guarantee that all MMIO + read and write operations are serialized. Extra left bits in AndData are + stripped. + + If 16-bit MMIO register operations are not supported, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address MMIO register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..15. + @param AndData The value to AND with read value from the MMIO register. + + @return The value written back to the MMIO register. + +**/ +UINT16 +EFIAPI +MmioBitFieldAnd16 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT16 AndData + ); + +/** + Reads a bit field in a 16-bit MMIO register, performs a bitwise AND followed + by a bitwise inclusive OR, and writes the result back to the bit field in the + 16-bit MMIO register. + + Reads the 16-bit MMIO register specified by Address, performs a bitwise AND + followed by a bitwise inclusive OR between the read result and the value + specified by AndData, and writes the result to the 16-bit MMIO register + specified by Address. The value written to the MMIO register is returned. + This function must guarantee that all MMIO read and write operations are + serialized. Extra left bits in both AndData and OrData are stripped. + + If 16-bit MMIO register operations are not supported, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address MMIO register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..15. + @param AndData The value to AND with read value from the MMIO register. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the MMIO register. + +**/ +UINT16 +EFIAPI +MmioBitFieldAndThenOr16 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT16 AndData, + IN UINT16 OrData + ); + +/** + Reads a 32-bit MMIO register. + + Reads the 32-bit MMIO register specified by Address. The 32-bit read value is + returned. This function must guarantee that all MMIO read and write + operations are serialized. + + If 32-bit MMIO register operations are not supported, then ASSERT(). + + @param Address The MMIO register to read. + + @return The value read. + +**/ +UINT32 +EFIAPI +MmioRead32 ( + IN UINTN Address + ); + +/** + Writes a 32-bit MMIO register. + + Writes the 32-bit MMIO register specified by Address with the value specified + by Value and returns Value. This function must guarantee that all MMIO read + and write operations are serialized. + + If 32-bit MMIO register operations are not supported, then ASSERT(). + + @param Address The MMIO register to write. + @param Value The value to write to the MMIO register. + +**/ +UINT32 +EFIAPI +MmioWrite32 ( + IN UINTN Address, + IN UINT32 Value + ); + +/** + Reads a 32-bit MMIO register, performs a bitwise inclusive OR, and writes the + result back to the 32-bit MMIO register. + + Reads the 32-bit MMIO register specified by Address, performs a bitwise + inclusive OR between the read result and the value specified by OrData, and + writes the result to the 32-bit MMIO register specified by Address. The value + written to the MMIO register is returned. This function must guarantee that + all MMIO read and write operations are serialized. + + If 32-bit MMIO register operations are not supported, then ASSERT(). + + @param Address The MMIO register to write. + @param OrData The value to OR with the read value from the MMIO register. + + @return The value written back to the MMIO register. + +**/ +UINT32 +EFIAPI +MmioOr32 ( + IN UINTN Address, + IN UINT32 OrData + ); + +/** + Reads a 32-bit MMIO register, performs a bitwise AND, and writes the result + back to the 32-bit MMIO register. + + Reads the 32-bit MMIO register specified by Address, performs a bitwise AND + between the read result and the value specified by AndData, and writes the + result to the 32-bit MMIO register specified by Address. The value written to + the MMIO register is returned. This function must guarantee that all MMIO + read and write operations are serialized. + + If 32-bit MMIO register operations are not supported, then ASSERT(). + + @param Address The MMIO register to write. + @param AndData The value to AND with the read value from the MMIO register. + + @return The value written back to the MMIO register. + +**/ +UINT32 +EFIAPI +MmioAnd32 ( + IN UINTN Address, + IN UINT32 AndData + ); + +/** + Reads a 32-bit MMIO register, performs a bitwise AND followed by a bitwise + inclusive OR, and writes the result back to the 32-bit MMIO register. + + Reads the 32-bit MMIO register specified by Address, performs a bitwise AND + between the read result and the value specified by AndData, performs a + bitwise OR between the result of the AND operation and the value specified by + OrData, and writes the result to the 32-bit MMIO register specified by + Address. The value written to the MMIO register is returned. This function + must guarantee that all MMIO read and write operations are serialized. + + If 32-bit MMIO register operations are not supported, then ASSERT(). + + + @param Address The MMIO register to write. + @param AndData The value to AND with the read value from the MMIO register. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the MMIO register. + +**/ +UINT32 +EFIAPI +MmioAndThenOr32 ( + IN UINTN Address, + IN UINT32 AndData, + IN UINT32 OrData + ); + +/** + Reads a bit field of a MMIO register. + + Reads the bit field in a 32-bit MMIO register. The bit field is specified by + the StartBit and the EndBit. The value of the bit field is returned. + + If 32-bit MMIO register operations are not supported, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address MMIO register to read. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + + @return The value read. + +**/ +UINT32 +EFIAPI +MmioBitFieldRead32 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit + ); + +/** + Writes a bit field to a MMIO register. + + Writes Value to the bit field of the MMIO register. The bit field is + specified by the StartBit and the EndBit. All other bits in the destination + MMIO register are preserved. The new value of the 32-bit register is returned. + + If 32-bit MMIO register operations are not supported, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address MMIO register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + @param Value New value of the bit field. + + @return The value written back to the MMIO register. + +**/ +UINT32 +EFIAPI +MmioBitFieldWrite32 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT32 Value + ); + +/** + Reads a bit field in a 32-bit MMIO register, performs a bitwise OR, and + writes the result back to the bit field in the 32-bit MMIO register. + + Reads the 32-bit MMIO register specified by Address, performs a bitwise + inclusive OR between the read result and the value specified by OrData, and + writes the result to the 32-bit MMIO register specified by Address. The value + written to the MMIO register is returned. This function must guarantee that + all MMIO read and write operations are serialized. Extra left bits in OrData + are stripped. + + If 32-bit MMIO register operations are not supported, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address MMIO register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + @param OrData The value to OR with read value from the MMIO register. + + @return The value written back to the MMIO register. + +**/ +UINT32 +EFIAPI +MmioBitFieldOr32 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT32 OrData + ); + +/** + Reads a bit field in a 32-bit MMIO register, performs a bitwise AND, and + writes the result back to the bit field in the 32-bit MMIO register. + + Reads the 32-bit MMIO register specified by Address, performs a bitwise AND + between the read result and the value specified by AndData, and writes the + result to the 32-bit MMIO register specified by Address. The value written to + the MMIO register is returned. This function must guarantee that all MMIO + read and write operations are serialized. Extra left bits in AndData are + stripped. + + If 32-bit MMIO register operations are not supported, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address MMIO register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + @param AndData The value to AND with read value from the MMIO register. + + @return The value written back to the MMIO register. + +**/ +UINT32 +EFIAPI +MmioBitFieldAnd32 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT32 AndData + ); + +/** + Reads a bit field in a 32-bit MMIO register, performs a bitwise AND followed + by a bitwise inclusive OR, and writes the result back to the bit field in the + 32-bit MMIO register. + + Reads the 32-bit MMIO register specified by Address, performs a bitwise AND + followed by a bitwise inclusive OR between the read result and the value + specified by AndData, and writes the result to the 32-bit MMIO register + specified by Address. The value written to the MMIO register is returned. + This function must guarantee that all MMIO read and write operations are + serialized. Extra left bits in both AndData and OrData are stripped. + + If 32-bit MMIO register operations are not supported, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address MMIO register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + @param AndData The value to AND with read value from the MMIO register. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the MMIO register. + +**/ +UINT32 +EFIAPI +MmioBitFieldAndThenOr32 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT32 AndData, + IN UINT32 OrData + ); + +/** + Reads a 64-bit MMIO register. + + Reads the 64-bit MMIO register specified by Address. The 64-bit read value is + returned. This function must guarantee that all MMIO read and write + operations are serialized. + + If 64-bit MMIO register operations are not supported, then ASSERT(). + + @param Address The MMIO register to read. + + @return The value read. + +**/ +UINT64 +EFIAPI +MmioRead64 ( + IN UINTN Address + ); + +/** + Writes a 64-bit MMIO register. + + Writes the 64-bit MMIO register specified by Address with the value specified + by Value and returns Value. This function must guarantee that all MMIO read + and write operations are serialized. + + If 64-bit MMIO register operations are not supported, then ASSERT(). + + @param Address The MMIO register to write. + @param Value The value to write to the MMIO register. + +**/ +UINT64 +EFIAPI +MmioWrite64 ( + IN UINTN Address, + IN UINT64 Value + ); + +/** + Reads a 64-bit MMIO register, performs a bitwise inclusive OR, and writes the + result back to the 64-bit MMIO register. + + Reads the 64-bit MMIO register specified by Address, performs a bitwise + inclusive OR between the read result and the value specified by OrData, and + writes the result to the 64-bit MMIO register specified by Address. The value + written to the MMIO register is returned. This function must guarantee that + all MMIO read and write operations are serialized. + + If 64-bit MMIO register operations are not supported, then ASSERT(). + + @param Address The MMIO register to write. + @param OrData The value to OR with the read value from the MMIO register. + + @return The value written back to the MMIO register. + +**/ +UINT64 +EFIAPI +MmioOr64 ( + IN UINTN Address, + IN UINT64 OrData + ); + +/** + Reads a 64-bit MMIO register, performs a bitwise AND, and writes the result + back to the 64-bit MMIO register. + + Reads the 64-bit MMIO register specified by Address, performs a bitwise AND + between the read result and the value specified by AndData, and writes the + result to the 64-bit MMIO register specified by Address. The value written to + the MMIO register is returned. This function must guarantee that all MMIO + read and write operations are serialized. + + If 64-bit MMIO register operations are not supported, then ASSERT(). + + @param Address The MMIO register to write. + @param AndData The value to AND with the read value from the MMIO register. + + @return The value written back to the MMIO register. + +**/ +UINT64 +EFIAPI +MmioAnd64 ( + IN UINTN Address, + IN UINT64 AndData + ); + +/** + Reads a 64-bit MMIO register, performs a bitwise AND followed by a bitwise + inclusive OR, and writes the result back to the 64-bit MMIO register. + + Reads the 64-bit MMIO register specified by Address, performs a bitwise AND + between the read result and the value specified by AndData, performs a + bitwise OR between the result of the AND operation and the value specified by + OrData, and writes the result to the 64-bit MMIO register specified by + Address. The value written to the MMIO register is returned. This function + must guarantee that all MMIO read and write operations are serialized. + + If 64-bit MMIO register operations are not supported, then ASSERT(). + + + @param Address The MMIO register to write. + @param AndData The value to AND with the read value from the MMIO register. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the MMIO register. + +**/ +UINT64 +EFIAPI +MmioAndThenOr64 ( + IN UINTN Address, + IN UINT64 AndData, + IN UINT64 OrData + ); + +/** + Reads a bit field of a MMIO register. + + Reads the bit field in a 64-bit MMIO register. The bit field is specified by + the StartBit and the EndBit. The value of the bit field is returned. + + If 64-bit MMIO register operations are not supported, then ASSERT(). + If StartBit is greater than 63, then ASSERT(). + If EndBit is greater than 63, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address MMIO register to read. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..63. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..63. + + @return The value read. + +**/ +UINT64 +EFIAPI +MmioBitFieldRead64 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit + ); + +/** + Writes a bit field to a MMIO register. + + Writes Value to the bit field of the MMIO register. The bit field is + specified by the StartBit and the EndBit. All other bits in the destination + MMIO register are preserved. The new value of the 64-bit register is returned. + + If 64-bit MMIO register operations are not supported, then ASSERT(). + If StartBit is greater than 63, then ASSERT(). + If EndBit is greater than 63, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address MMIO register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..63. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..63. + @param Value New value of the bit field. + + @return The value written back to the MMIO register. + +**/ +UINT64 +EFIAPI +MmioBitFieldWrite64 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT64 Value + ); + +/** + Reads a bit field in a 64-bit MMIO register, performs a bitwise OR, and + writes the result back to the bit field in the 64-bit MMIO register. + + Reads the 64-bit MMIO register specified by Address, performs a bitwise + inclusive OR between the read result and the value specified by OrData, and + writes the result to the 64-bit MMIO register specified by Address. The value + written to the MMIO register is returned. This function must guarantee that + all MMIO read and write operations are serialized. Extra left bits in OrData + are stripped. + + If 64-bit MMIO register operations are not supported, then ASSERT(). + If StartBit is greater than 63, then ASSERT(). + If EndBit is greater than 63, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address MMIO register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..63. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..63. + @param OrData The value to OR with read value from the MMIO register. + + @return The value written back to the MMIO register. + +**/ +UINT64 +EFIAPI +MmioBitFieldOr64 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT64 OrData + ); + +/** + Reads a bit field in a 64-bit MMIO register, performs a bitwise AND, and + writes the result back to the bit field in the 64-bit MMIO register. + + Reads the 64-bit MMIO register specified by Address, performs a bitwise AND + between the read result and the value specified by AndData, and writes the + result to the 64-bit MMIO register specified by Address. The value written to + the MMIO register is returned. This function must guarantee that all MMIO + read and write operations are serialized. Extra left bits in AndData are + stripped. + + If 64-bit MMIO register operations are not supported, then ASSERT(). + If StartBit is greater than 63, then ASSERT(). + If EndBit is greater than 63, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address MMIO register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..63. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..63. + @param AndData The value to AND with read value from the MMIO register. + + @return The value written back to the MMIO register. + +**/ +UINT64 +EFIAPI +MmioBitFieldAnd64 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT64 AndData + ); + +/** + Reads a bit field in a 64-bit MMIO register, performs a bitwise AND followed + by a bitwise inclusive OR, and writes the result back to the bit field in the + 64-bit MMIO register. + + Reads the 64-bit MMIO register specified by Address, performs a bitwise AND + followed by a bitwise inclusive OR between the read result and the value + specified by AndData, and writes the result to the 64-bit MMIO register + specified by Address. The value written to the MMIO register is returned. + This function must guarantee that all MMIO read and write operations are + serialized. Extra left bits in both AndData and OrData are stripped. + + If 64-bit MMIO register operations are not supported, then ASSERT(). + If StartBit is greater than 63, then ASSERT(). + If EndBit is greater than 63, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address MMIO register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..63. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..63. + @param AndData The value to AND with read value from the MMIO register. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the MMIO register. + +**/ +UINT64 +EFIAPI +MmioBitFieldAndThenOr64 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT64 AndData, + IN UINT64 OrData + ); + +#endif diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueMemoryAllocationLib.h b/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueMemoryAllocationLib.h new file mode 100644 index 0000000..395ee4a --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueMemoryAllocationLib.h @@ -0,0 +1,637 @@ +/*++ + +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: + + EdkIIGlueMemoryAllocationLib.h + +Abstract: + + Public header file for Memory Allocation Lib + +--*/ + +#ifndef __EDKII_GLUE_MEMORY_ALLOCATION_LIB_H__ +#define __EDKII_GLUE_MEMORY_ALLOCATION_LIB_H__ + + +#define AllocatePages(_PAGES) GlueAllocatePages(_PAGES) +#define FreePages(_BUFFER, _PAGES) GlueFreePages(_BUFFER, _PAGES) +#define AllocatePool(_SIZE) GlueAllocatePool(_SIZE) +#define AllocateZeroPool(_ALLOCATIONSIZE) GlueAllocateZeroPool(_ALLOCATIONSIZE) +#define AllocateCopyPool(_ALLOCATIONSIZE, _BUFFER) GlueAllocateCopyPool(_ALLOCATIONSIZE, _BUFFER) +#define FreePool(_BUFFER) GlueFreePool(_BUFFER) + + +/** + Allocates one or more 4KB pages of type EfiBootServicesData. + + Allocates the number of 4KB pages of type EfiBootServicesData and returns a pointer to the + allocated buffer. The buffer returned is aligned on a 4KB boundary. If Pages is 0, then NULL + is returned. If there is not enough memory remaining to satisfy the request, then NULL is + returned. + + @param Pages The number of 4 KB pages to allocate. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +GlueAllocatePages ( + IN UINTN Pages + ); + +/** + Allocates one or more 4KB pages of type EfiRuntimeServicesData. + + Allocates the number of 4KB pages of type EfiRuntimeServicesData and returns a pointer to the + allocated buffer. The buffer returned is aligned on a 4KB boundary. If Pages is 0, then NULL + is returned. If there is not enough memory remaining to satisfy the request, then NULL is + returned. + + @param Pages The number of 4 KB pages to allocate. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +AllocateRuntimePages ( + IN UINTN Pages + ); + +/** + Allocates one or more 4KB pages of type EfiReservedMemoryType. + + Allocates the number of 4KB pages of type EfiReservedMemoryType and returns a pointer to the + allocated buffer. The buffer returned is aligned on a 4KB boundary. If Pages is 0, then NULL + is returned. If there is not enough memory remaining to satisfy the request, then NULL is + returned. + + @param Pages The number of 4 KB pages to allocate. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +AllocateReservedPages ( + IN UINTN Pages + ); + +/** + Frees one or more 4KB pages that were previously allocated with one of the page allocation + functions in the Memory Allocation Library. + + Frees the number of 4KB pages specified by Pages from the buffer specified by Buffer. Buffer + must have been allocated on a previous call to the page allocation services of the Memory + Allocation Library. + If Buffer was not allocated with a page allocation function in the Memory Allocation Library, + then ASSERT(). + If Pages is zero, then ASSERT(). + + @param Buffer Pointer to the buffer of pages to free. + @param Pages The number of 4 KB pages to free. + +**/ +VOID +EFIAPI +GlueFreePages ( + IN VOID *Buffer, + IN UINTN Pages + ); + +/** + Allocates one or more 4KB pages of type EfiBootServicesData at a specified alignment. + + Allocates the number of 4KB pages specified by Pages of type EfiBootServicesData with an + alignment specified by Alignment. The allocated buffer is returned. If Pages is 0, then NULL is + returned. If there is not enough memory at the specified alignment remaining to satisfy the + request, then NULL is returned. + If Alignment is not a power of two and Alignment is not zero, then ASSERT(). + + @param Pages The number of 4 KB pages to allocate. + @param Alignment The requested alignment of the allocation. Must be a power of two. + If Alignment is zero, then byte alignment is used. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +AllocateAlignedPages ( + IN UINTN Pages, + IN UINTN Alignment + ); + +/** + Allocates one or more 4KB pages of type EfiRuntimeServicesData at a specified alignment. + + Allocates the number of 4KB pages specified by Pages of type EfiRuntimeServicesData with an + alignment specified by Alignment. The allocated buffer is returned. If Pages is 0, then NULL is + returned. If there is not enough memory at the specified alignment remaining to satisfy the + request, then NULL is returned. + If Alignment is not a power of two and Alignment is not zero, then ASSERT(). + + @param Pages The number of 4 KB pages to allocate. + @param Alignment The requested alignment of the allocation. Must be a power of two. + If Alignment is zero, then byte alignment is used. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +AllocateAlignedRuntimePages ( + IN UINTN Pages, + IN UINTN Alignment + ); + +/** + Allocates one or more 4KB pages of type EfiReservedMemoryType at a specified alignment. + + Allocates the number of 4KB pages specified by Pages of type EfiReservedMemoryType with an + alignment specified by Alignment. The allocated buffer is returned. If Pages is 0, then NULL is + returned. If there is not enough memory at the specified alignment remaining to satisfy the + request, then NULL is returned. + If Alignment is not a power of two and Alignment is not zero, then ASSERT(). + + @param Pages The number of 4 KB pages to allocate. + @param Alignment The requested alignment of the allocation. Must be a power of two. + If Alignment is zero, then byte alignment is used. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +AllocateAlignedReservedPages ( + IN UINTN Pages, + IN UINTN Alignment + ); + +/** + Frees one or more 4KB pages that were previously allocated with one of the aligned page + allocation functions in the Memory Allocation Library. + + Frees the number of 4KB pages specified by Pages from the buffer specified by Buffer. Buffer + must have been allocated on a previous call to the aligned page allocation services of the Memory + Allocation Library. + If Buffer was not allocated with an aligned page allocation function in the Memory Allocation + Library, then ASSERT(). + If Pages is zero, then ASSERT(). + + @param Buffer Pointer to the buffer of pages to free. + @param Pages The number of 4 KB pages to free. + +**/ +VOID +EFIAPI +FreeAlignedPages ( + IN VOID *Buffer, + IN UINTN Pages + ); + +/** + Allocates a buffer of type EfiBootServicesData. + + Allocates the number bytes specified by AllocationSize of type EfiBootServicesData and returns a + pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is + returned. If there is not enough memory remaining to satisfy the request, then NULL is returned. + + @param AllocationSize The number of bytes to allocate. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +GlueAllocatePool ( + IN UINTN AllocationSize + ); + +/** + Allocates a buffer of type EfiRuntimeServicesData. + + Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData and returns + a pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is + returned. If there is not enough memory remaining to satisfy the request, then NULL is returned. + + @param AllocationSize The number of bytes to allocate. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +AllocateRuntimePool ( + IN UINTN AllocationSize + ); + +/** + Allocates a buffer of type EfieservedMemoryType. + + Allocates the number bytes specified by AllocationSize of type EfieservedMemoryType and returns + a pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is + returned. If there is not enough memory remaining to satisfy the request, then NULL is returned. + + @param AllocationSize The number of bytes to allocate. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +AllocateReservedPool ( + IN UINTN AllocationSize + ); + +/** + Allocates and zeros a buffer of type EfiBootServicesData. + + Allocates the number bytes specified by AllocationSize of type EfiBootServicesData, clears the + buffer with zeros, and returns a pointer to the allocated buffer. If AllocationSize is 0, then a + valid buffer of 0 size is returned. If there is not enough memory remaining to satisfy the + request, then NULL is returned. + + @param AllocationSize The number of bytes to allocate and zero. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +GlueAllocateZeroPool ( + IN UINTN AllocationSize + ); + +/** + Allocates and zeros a buffer of type EfiRuntimeServicesData. + + Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData, clears the + buffer with zeros, and returns a pointer to the allocated buffer. If AllocationSize is 0, then a + valid buffer of 0 size is returned. If there is not enough memory remaining to satisfy the + request, then NULL is returned. + + @param AllocationSize The number of bytes to allocate and zero. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +AllocateRuntimeZeroPool ( + IN UINTN AllocationSize + ); + +/** + Allocates and zeros a buffer of type EfiReservedMemoryType. + + Allocates the number bytes specified by AllocationSize of type EfiReservedMemoryType, clears the + buffer with zeros, and returns a pointer to the allocated buffer. If AllocationSize is 0, then a + valid buffer of 0 size is returned. If there is not enough memory remaining to satisfy the + request, then NULL is returned. + + @param AllocationSize The number of bytes to allocate and zero. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +AllocateReservedZeroPool ( + IN UINTN AllocationSize + ); + +/** + Copies a buffer to an allocated buffer of type EfiBootServicesData. + + Allocates the number bytes specified by AllocationSize of type EfiBootServicesData, copies + AllocationSize bytes from Buffer to the newly allocated buffer, and returns a pointer to the + allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there + is not enough memory remaining to satisfy the request, then NULL is returned. + If Buffer is NULL, then ASSERT(). + If AllocationSize is greater than (MAX_ADDRESS ?Buffer + 1), then ASSERT(). + + @param AllocationSize The number of bytes to allocate and zero. + @param Buffer The buffer to copy to the allocated buffer. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +GlueAllocateCopyPool ( + IN UINTN AllocationSize, + IN CONST VOID *Buffer + ); + +/** + Copies a buffer to an allocated buffer of type EfiRuntimeServicesData. + + Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData, copies + AllocationSize bytes from Buffer to the newly allocated buffer, and returns a pointer to the + allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there + is not enough memory remaining to satisfy the request, then NULL is returned. + If Buffer is NULL, then ASSERT(). + If AllocationSize is greater than (MAX_ADDRESS ?Buffer + 1), then ASSERT(). + + @param AllocationSize The number of bytes to allocate and zero. + @param Buffer The buffer to copy to the allocated buffer. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +AllocateRuntimeCopyPool ( + IN UINTN AllocationSize, + IN CONST VOID *Buffer + ); + +/** + Copies a buffer to an allocated buffer of type EfiReservedMemoryType. + + Allocates the number bytes specified by AllocationSize of type EfiReservedMemoryType, copies + AllocationSize bytes from Buffer to the newly allocated buffer, and returns a pointer to the + allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there + is not enough memory remaining to satisfy the request, then NULL is returned. + If Buffer is NULL, then ASSERT(). + If AllocationSize is greater than (MAX_ADDRESS ?Buffer + 1), then ASSERT(). + + @param AllocationSize The number of bytes to allocate and zero. + @param Buffer The buffer to copy to the allocated buffer. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +AllocateReservedCopyPool ( + IN UINTN AllocationSize, + IN CONST VOID *Buffer + ); + +/** + Frees a buffer that was previously allocated with one of the pool allocation functions in the + Memory Allocation Library. + + Frees the buffer specified by Buffer. Buffer must have been allocated on a previous call to the + pool allocation services of the Memory Allocation Library. + If Buffer was not allocated with a pool allocation function in the Memory Allocation Library, + then ASSERT(). + + @param Buffer Pointer to the buffer to free. + +**/ +VOID +EFIAPI +GlueFreePool ( + IN VOID *Buffer + ); + +/** + Allocates a buffer of type EfiBootServicesData at a specified alignment. + + Allocates the number bytes specified by AllocationSize of type EfiBootServicesData with an + alignment specified by Alignment. The allocated buffer is returned. If AllocationSize is 0, + then a valid buffer of 0 size is returned. If there is not enough memory at the specified + alignment remaining to satisfy the request, then NULL is returned. + If Alignment is not a power of two and Alignment is not zero, then ASSERT(). + + @param AllocationSize The number of bytes to allocate. + @param Alignment The requested alignment of the allocation. Must be a power of two. + If Alignment is zero, then byte alignment is used. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +AllocateAlignedPool ( + IN UINTN AllocationSize, + IN UINTN Alignment + ); + +/** + Allocates a buffer of type EfiRuntimeServicesData at a specified alignment. + + Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData with an + alignment specified by Alignment. The allocated buffer is returned. If AllocationSize is 0, + then a valid buffer of 0 size is returned. If there is not enough memory at the specified + alignment remaining to satisfy the request, then NULL is returned. + If Alignment is not a power of two and Alignment is not zero, then ASSERT(). + + @param AllocationSize The number of bytes to allocate. + @param Alignment The requested alignment of the allocation. Must be a power of two. + If Alignment is zero, then byte alignment is used. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +AllocateAlignedRuntimePool ( + IN UINTN AllocationSize, + IN UINTN Alignment + ); + +/** + Allocates a buffer of type EfieservedMemoryType at a specified alignment. + + Allocates the number bytes specified by AllocationSize of type EfieservedMemoryType with an + alignment specified by Alignment. The allocated buffer is returned. If AllocationSize is 0, + then a valid buffer of 0 size is returned. If there is not enough memory at the specified + alignment remaining to satisfy the request, then NULL is returned. + If Alignment is not a power of two and Alignment is not zero, then ASSERT(). + + @param AllocationSize The number of bytes to allocate. + @param Alignment The requested alignment of the allocation. Must be a power of two. + If Alignment is zero, then byte alignment is used. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +AllocateAlignedReservedPool ( + IN UINTN AllocationSize, + IN UINTN Alignment + ); + +/** + Allocates and zeros a buffer of type EfiBootServicesData at a specified alignment. + + Allocates the number bytes specified by AllocationSize of type EfiBootServicesData with an + alignment specified by Alignment, clears the buffer with zeros, and returns a pointer to the + allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there + is not enough memory at the specified alignment remaining to satisfy the request, then NULL is + returned. + If Alignment is not a power of two and Alignment is not zero, then ASSERT(). + + @param AllocationSize The number of bytes to allocate. + @param Alignment The requested alignment of the allocation. Must be a power of two. + If Alignment is zero, then byte alignment is used. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +AllocateAlignedZeroPool ( + IN UINTN AllocationSize, + IN UINTN Alignment + ); + +/** + Allocates and zeros a buffer of type EfiRuntimeServicesData at a specified alignment. + + Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData with an + alignment specified by Alignment, clears the buffer with zeros, and returns a pointer to the + allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there + is not enough memory at the specified alignment remaining to satisfy the request, then NULL is + returned. + If Alignment is not a power of two and Alignment is not zero, then ASSERT(). + + @param AllocationSize The number of bytes to allocate. + @param Alignment The requested alignment of the allocation. Must be a power of two. + If Alignment is zero, then byte alignment is used. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +AllocateAlignedRuntimeZeroPool ( + IN UINTN AllocationSize, + IN UINTN Alignment + ); + +/** + Allocates and zeros a buffer of type EfieservedMemoryType at a specified alignment. + + Allocates the number bytes specified by AllocationSize of type EfieservedMemoryType with an + alignment specified by Alignment, clears the buffer with zeros, and returns a pointer to the + allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there + is not enough memory at the specified alignment remaining to satisfy the request, then NULL is + returned. + If Alignment is not a power of two and Alignment is not zero, then ASSERT(). + + @param AllocationSize The number of bytes to allocate. + @param Alignment The requested alignment of the allocation. Must be a power of two. + If Alignment is zero, then byte alignment is used. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +AllocateAlignedReservedZeroPool ( + IN UINTN AllocationSize, + IN UINTN Alignment + ); + +/** + Copies a buffer to an allocated buffer of type EfiBootServicesData at a specified alignment. + + Allocates the number bytes specified by AllocationSize of type EfiBootServicesData type with an + alignment specified by Alignment. The allocated buffer is returned. If AllocationSize is 0, + then a valid buffer of 0 size is returned. If there is not enough memory at the specified + alignment remaining to satisfy the request, then NULL is returned. + If Alignment is not a power of two and Alignment is not zero, then ASSERT(). + + @param AllocationSize The number of bytes to allocate. + @param Buffer The buffer to copy to the allocated buffer. + @param Alignment The requested alignment of the allocation. Must be a power of two. + If Alignment is zero, then byte alignment is used. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +AllocateAlignedCopyPool ( + IN UINTN AllocationSize, + IN CONST VOID *Buffer, + IN UINTN Alignment + ); + +/** + Copies a buffer to an allocated buffer of type EfiRuntimeServicesData at a specified alignment. + + Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData type with an + alignment specified by Alignment. The allocated buffer is returned. If AllocationSize is 0, + then a valid buffer of 0 size is returned. If there is not enough memory at the specified + alignment remaining to satisfy the request, then NULL is returned. + If Alignment is not a power of two and Alignment is not zero, then ASSERT(). + + @param AllocationSize The number of bytes to allocate. + @param Buffer The buffer to copy to the allocated buffer. + @param Alignment The requested alignment of the allocation. Must be a power of two. + If Alignment is zero, then byte alignment is used. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +AllocateAlignedRuntimeCopyPool ( + IN UINTN AllocationSize, + IN CONST VOID *Buffer, + IN UINTN Alignment + ); + +/** + Copies a buffer to an allocated buffer of type EfiReservedMemoryType at a specified alignment. + + Allocates the number bytes specified by AllocationSize of type EfiReservedMemoryType type with an + alignment specified by Alignment. The allocated buffer is returned. If AllocationSize is 0, + then a valid buffer of 0 size is returned. If there is not enough memory at the specified + alignment remaining to satisfy the request, then NULL is returned. + If Alignment is not a power of two and Alignment is not zero, then ASSERT(). + + @param AllocationSize The number of bytes to allocate. + @param Buffer The buffer to copy to the allocated buffer. + @param Alignment The requested alignment of the allocation. Must be a power of two. + If Alignment is zero, then byte alignment is used. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +AllocateAlignedReservedCopyPool ( + IN UINTN AllocationSize, + IN CONST VOID *Buffer, + IN UINTN Alignment + ); + +/** + Frees a buffer that was previously allocated with one of the aligned pool allocation functions + in the Memory Allocation Library. + + Frees the buffer specified by Buffer. Buffer must have been allocated on a previous call to the + aligned pool allocation services of the Memory Allocation Library. + If Buffer was not allocated with an aligned pool allocation function in the Memory Allocation + Library, then ASSERT(). + + @param Buffer Pointer to the buffer to free. + +**/ +VOID +EFIAPI +FreeAlignedPool ( + IN VOID *Buffer + ); + +#endif diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGluePciCf8Lib.h b/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGluePciCf8Lib.h new file mode 100644 index 0000000..7bd22ab --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGluePciCf8Lib.h @@ -0,0 +1,1055 @@ +/*++ + +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: + + EdkIIGluePciCf8Lib.h + +Abstract: + + Public header file for Pci Cf8 Lib + +--*/ + +#ifndef __EDKII_GLUE_PCI_CF8_LIB_H__ +#define __EDKII_GLUE_PCI_CF8_LIB_H__ + + +/** + Macro that converts PCI Bus, PCI Device, PCI Function and PCI Register to an + address that can be passed to the PCI Library functions. + + Computes an address that is compatible with the PCI Library functions. The + unused upper bits of Bus, Device, Function and Register are stripped prior to + the generation of the address. + + @param Bus PCI Bus number. Range 0..255. + @param Device PCI Device number. Range 0..31. + @param Function PCI Function number. Range 0..7. + @param Register PCI Register number. Range 0..255. + + @return The encode PCI address. + +**/ +#define PCI_CF8_LIB_ADDRESS(Bus,Device,Function,Offset) \ + (((Offset) & 0xfff) | (((Function) & 0x07) << 12) | (((Device) & 0x1f) << 15) | (((Bus) & 0xff) << 20)) + +/** + Reads an 8-bit PCI configuration register. + + Reads and returns the 8-bit PCI configuration register specified by Address. + This function must guarantee that all PCI read and write operations are + serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + If the register specified by Address >= 0x100, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + + @return The read value from the PCI configuration register. + +**/ +UINT8 +EFIAPI +PciCf8Read8 ( + IN UINTN Address + ); + +/** + Writes an 8-bit PCI configuration register. + + Writes the 8-bit PCI configuration register specified by Address with the + value specified by Value. Value is returned. This function must guarantee + that all PCI read and write operations are serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + If the register specified by Address >= 0x100, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param Value The value to write. + + @return The value written to the PCI configuration register. + +**/ +UINT8 +EFIAPI +PciCf8Write8 ( + IN UINTN Address, + IN UINT8 Data + ); + +/** + Performs a bitwise inclusive OR of an 8-bit PCI configuration register with + an 8-bit value. + + Reads the 8-bit PCI configuration register specified by Address, performs a + bitwise inclusive OR between the read result and the value specified by + OrData, and writes the result to the 8-bit PCI configuration register + specified by Address. The value written to the PCI configuration register is + returned. This function must guarantee that all PCI read and write operations + are serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + If the register specified by Address >= 0x100, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param OrData The value to OR with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT8 +EFIAPI +PciCf8Or8 ( + IN UINTN Address, + IN UINT8 OrData + ); + +/** + Performs a bitwise AND of an 8-bit PCI configuration register with an 8-bit + value. + + Reads the 8-bit PCI configuration register specified by Address, performs a + bitwise AND between the read result and the value specified by AndData, and + writes the result to the 8-bit PCI configuration register specified by + Address. The value written to the PCI configuration register is returned. + This function must guarantee that all PCI read and write operations are + serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + If the register specified by Address >= 0x100, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param AndData The value to AND with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT8 +EFIAPI +PciCf8And8 ( + IN UINTN Address, + IN UINT8 AndData + ); + +/** + Performs a bitwise AND of an 8-bit PCI configuration register with an 8-bit + value, followed a bitwise inclusive OR with another 8-bit value. + + Reads the 8-bit PCI configuration register specified by Address, performs a + bitwise AND between the read result and the value specified by AndData, + performs a bitwise inclusive OR between the result of the AND operation and + the value specified by OrData, and writes the result to the 8-bit PCI + configuration register specified by Address. The value written to the PCI + configuration register is returned. This function must guarantee that all PCI + read and write operations are serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + If the register specified by Address >= 0x100, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param AndData The value to AND with the PCI configuration register. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the PCI configuration register. + +**/ +UINT8 +EFIAPI +PciCf8AndThenOr8 ( + IN UINTN Address, + IN UINT8 AndData, + IN UINT8 OrData + ); + +/** + Reads a bit field of a PCI configuration register. + + Reads the bit field in an 8-bit PCI configuration register. The bit field is + specified by the StartBit and the EndBit. The value of the bit field is + returned. + + If Address > 0x0FFFFFFF, then ASSERT(). + If the register specified by Address >= 0x100, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to read. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..7. + + @return The value of the bit field read from the PCI configuration register. + +**/ +UINT8 +EFIAPI +PciCf8BitFieldRead8 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit + ); + +/** + Writes a bit field to a PCI configuration register. + + Writes Value to the bit field of the PCI configuration register. The bit + field is specified by the StartBit and the EndBit. All other bits in the + destination PCI configuration register are preserved. The new value of the + 8-bit register is returned. + + If Address > 0x0FFFFFFF, then ASSERT(). + If the register specified by Address >= 0x100, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..7. + @param Value New value of the bit field. + + @return The value written back to the PCI configuration register. + +**/ +UINT8 +EFIAPI +PciCf8BitFieldWrite8 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT8 Value + ); + +/** + Reads a bit field in an 8-bit PCI configuration, performs a bitwise OR, and + writes the result back to the bit field in the 8-bit port. + + Reads the 8-bit PCI configuration register specified by Address, performs a + bitwise inclusive OR between the read result and the value specified by + OrData, and writes the result to the 8-bit PCI configuration register + specified by Address. The value written to the PCI configuration register is + returned. This function must guarantee that all PCI read and write operations + are serialized. Extra left bits in OrData are stripped. + + If Address > 0x0FFFFFFF, then ASSERT(). + If the register specified by Address >= 0x100, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..7. + @param OrData The value to OR with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT8 +EFIAPI +PciCf8BitFieldOr8 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT8 OrData + ); + +/** + Reads a bit field in an 8-bit PCI configuration register, performs a bitwise + AND, and writes the result back to the bit field in the 8-bit register. + + Reads the 8-bit PCI configuration register specified by Address, performs a + bitwise AND between the read result and the value specified by AndData, and + writes the result to the 8-bit PCI configuration register specified by + Address. The value written to the PCI configuration register is returned. + This function must guarantee that all PCI read and write operations are + serialized. Extra left bits in AndData are stripped. + + If Address > 0x0FFFFFFF, then ASSERT(). + If the register specified by Address >= 0x100, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..7. + @param AndData The value to AND with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT8 +EFIAPI +PciCf8BitFieldAnd8 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT8 AndData + ); + +/** + Reads a bit field in an 8-bit port, performs a bitwise AND followed by a + bitwise inclusive OR, and writes the result back to the bit field in the + 8-bit port. + + Reads the 8-bit PCI configuration register specified by Address, performs a + bitwise AND followed by a bitwise inclusive OR between the read result and + the value specified by AndData, and writes the result to the 8-bit PCI + configuration register specified by Address. The value written to the PCI + configuration register is returned. This function must guarantee that all PCI + read and write operations are serialized. Extra left bits in both AndData and + OrData are stripped. + + If Address > 0x0FFFFFFF, then ASSERT(). + If the register specified by Address >= 0x100, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..7. + @param AndData The value to AND with the PCI configuration register. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the PCI configuration register. + +**/ +UINT8 +EFIAPI +PciCf8BitFieldAndThenOr8 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT8 AndData, + IN UINT8 OrData + ); + +/** + Reads a 16-bit PCI configuration register. + + Reads and returns the 16-bit PCI configuration register specified by Address. + This function must guarantee that all PCI read and write operations are + serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 16-bit boundary, then ASSERT(). + If the register specified by Address >= 0x100, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + + @return The read value from the PCI configuration register. + +**/ +UINT16 +EFIAPI +PciCf8Read16 ( + IN UINTN Address + ); + +/** + Writes a 16-bit PCI configuration register. + + Writes the 16-bit PCI configuration register specified by Address with the + value specified by Value. Value is returned. This function must guarantee + that all PCI read and write operations are serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 16-bit boundary, then ASSERT(). + If the register specified by Address >= 0x100, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param Value The value to write. + + @return The value written to the PCI configuration register. + +**/ +UINT16 +EFIAPI +PciCf8Write16 ( + IN UINTN Address, + IN UINT16 Data + ); + +/** + Performs a bitwise inclusive OR of a 16-bit PCI configuration register with + a 16-bit value. + + Reads the 16-bit PCI configuration register specified by Address, performs a + bitwise inclusive OR between the read result and the value specified by + OrData, and writes the result to the 16-bit PCI configuration register + specified by Address. The value written to the PCI configuration register is + returned. This function must guarantee that all PCI read and write operations + are serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 16-bit boundary, then ASSERT(). + If the register specified by Address >= 0x100, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param OrData The value to OR with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT16 +EFIAPI +PciCf8Or16 ( + IN UINTN Address, + IN UINT16 OrData + ); + +/** + Performs a bitwise AND of a 16-bit PCI configuration register with a 16-bit + value. + + Reads the 16-bit PCI configuration register specified by Address, performs a + bitwise AND between the read result and the value specified by AndData, and + writes the result to the 16-bit PCI configuration register specified by + Address. The value written to the PCI configuration register is returned. + This function must guarantee that all PCI read and write operations are + serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 16-bit boundary, then ASSERT(). + If the register specified by Address >= 0x100, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param AndData The value to AND with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT16 +EFIAPI +PciCf8And16 ( + IN UINTN Address, + IN UINT16 AndData + ); + +/** + Performs a bitwise AND of a 16-bit PCI configuration register with a 16-bit + value, followed a bitwise inclusive OR with another 16-bit value. + + Reads the 16-bit PCI configuration register specified by Address, performs a + bitwise AND between the read result and the value specified by AndData, + performs a bitwise inclusive OR between the result of the AND operation and + the value specified by OrData, and writes the result to the 16-bit PCI + configuration register specified by Address. The value written to the PCI + configuration register is returned. This function must guarantee that all PCI + read and write operations are serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 16-bit boundary, then ASSERT(). + If the register specified by Address >= 0x100, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param AndData The value to AND with the PCI configuration register. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the PCI configuration register. + +**/ +UINT16 +EFIAPI +PciCf8AndThenOr16 ( + IN UINTN Address, + IN UINT16 AndData, + IN UINT16 OrData + ); + +/** + Reads a bit field of a PCI configuration register. + + Reads the bit field in a 16-bit PCI configuration register. The bit field is + specified by the StartBit and the EndBit. The value of the bit field is + returned. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 16-bit boundary, then ASSERT(). + If the register specified by Address >= 0x100, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to read. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..15. + + @return The value of the bit field read from the PCI configuration register. + +**/ +UINT16 +EFIAPI +PciCf8BitFieldRead16 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit + ); + +/** + Writes a bit field to a PCI configuration register. + + Writes Value to the bit field of the PCI configuration register. The bit + field is specified by the StartBit and the EndBit. All other bits in the + destination PCI configuration register are preserved. The new value of the + 16-bit register is returned. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 16-bit boundary, then ASSERT(). + If the register specified by Address >= 0x100, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..15. + @param Value New value of the bit field. + + @return The value written back to the PCI configuration register. + +**/ +UINT16 +EFIAPI +PciCf8BitFieldWrite16 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT16 Value + ); + +/** + Reads a bit field in a 16-bit PCI configuration, performs a bitwise OR, and + writes the result back to the bit field in the 16-bit port. + + Reads the 16-bit PCI configuration register specified by Address, performs a + bitwise inclusive OR between the read result and the value specified by + OrData, and writes the result to the 16-bit PCI configuration register + specified by Address. The value written to the PCI configuration register is + returned. This function must guarantee that all PCI read and write operations + are serialized. Extra left bits in OrData are stripped. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 16-bit boundary, then ASSERT(). + If the register specified by Address >= 0x100, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..15. + @param OrData The value to OR with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT16 +EFIAPI +PciCf8BitFieldOr16 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT16 OrData + ); + +/** + Reads a bit field in a 16-bit PCI configuration register, performs a bitwise + AND, and writes the result back to the bit field in the 16-bit register. + + Reads the 16-bit PCI configuration register specified by Address, performs a + bitwise AND between the read result and the value specified by AndData, and + writes the result to the 16-bit PCI configuration register specified by + Address. The value written to the PCI configuration register is returned. + This function must guarantee that all PCI read and write operations are + serialized. Extra left bits in AndData are stripped. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 16-bit boundary, then ASSERT(). + If the register specified by Address >= 0x100, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..15. + @param AndData The value to AND with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT16 +EFIAPI +PciCf8BitFieldAnd16 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT16 AndData + ); + +/** + Reads a bit field in a 16-bit port, performs a bitwise AND followed by a + bitwise inclusive OR, and writes the result back to the bit field in the + 16-bit port. + + Reads the 16-bit PCI configuration register specified by Address, performs a + bitwise AND followed by a bitwise inclusive OR between the read result and + the value specified by AndData, and writes the result to the 16-bit PCI + configuration register specified by Address. The value written to the PCI + configuration register is returned. This function must guarantee that all PCI + read and write operations are serialized. Extra left bits in both AndData and + OrData are stripped. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 16-bit boundary, then ASSERT(). + If the register specified by Address >= 0x100, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..15. + @param AndData The value to AND with the PCI configuration register. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the PCI configuration register. + +**/ +UINT16 +EFIAPI +PciCf8BitFieldAndThenOr16 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT16 AndData, + IN UINT16 OrData + ); + +/** + Reads a 32-bit PCI configuration register. + + Reads and returns the 32-bit PCI configuration register specified by Address. + This function must guarantee that all PCI read and write operations are + serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 32-bit boundary, then ASSERT(). + If the register specified by Address >= 0x100, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + + @return The read value from the PCI configuration register. + +**/ +UINT32 +EFIAPI +PciCf8Read32 ( + IN UINTN Address + ); + +/** + Writes a 32-bit PCI configuration register. + + Writes the 32-bit PCI configuration register specified by Address with the + value specified by Value. Value is returned. This function must guarantee + that all PCI read and write operations are serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 32-bit boundary, then ASSERT(). + If the register specified by Address >= 0x100, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param Value The value to write. + + @return The value written to the PCI configuration register. + +**/ +UINT32 +EFIAPI +PciCf8Write32 ( + IN UINTN Address, + IN UINT32 Data + ); + +/** + Performs a bitwise inclusive OR of a 32-bit PCI configuration register with + a 32-bit value. + + Reads the 32-bit PCI configuration register specified by Address, performs a + bitwise inclusive OR between the read result and the value specified by + OrData, and writes the result to the 32-bit PCI configuration register + specified by Address. The value written to the PCI configuration register is + returned. This function must guarantee that all PCI read and write operations + are serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 32-bit boundary, then ASSERT(). + If the register specified by Address >= 0x100, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param OrData The value to OR with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT32 +EFIAPI +PciCf8Or32 ( + IN UINTN Address, + IN UINT32 OrData + ); + +/** + Performs a bitwise AND of a 32-bit PCI configuration register with a 32-bit + value. + + Reads the 32-bit PCI configuration register specified by Address, performs a + bitwise AND between the read result and the value specified by AndData, and + writes the result to the 32-bit PCI configuration register specified by + Address. The value written to the PCI configuration register is returned. + This function must guarantee that all PCI read and write operations are + serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 32-bit boundary, then ASSERT(). + If the register specified by Address >= 0x100, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param AndData The value to AND with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT32 +EFIAPI +PciCf8And32 ( + IN UINTN Address, + IN UINT32 AndData + ); + +/** + Performs a bitwise AND of a 32-bit PCI configuration register with a 32-bit + value, followed a bitwise inclusive OR with another 32-bit value. + + Reads the 32-bit PCI configuration register specified by Address, performs a + bitwise AND between the read result and the value specified by AndData, + performs a bitwise inclusive OR between the result of the AND operation and + the value specified by OrData, and writes the result to the 32-bit PCI + configuration register specified by Address. The value written to the PCI + configuration register is returned. This function must guarantee that all PCI + read and write operations are serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 32-bit boundary, then ASSERT(). + If the register specified by Address >= 0x100, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param AndData The value to AND with the PCI configuration register. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the PCI configuration register. + +**/ +UINT32 +EFIAPI +PciCf8AndThenOr32 ( + IN UINTN Address, + IN UINT32 AndData, + IN UINT32 OrData + ); + +/** + Reads a bit field of a PCI configuration register. + + Reads the bit field in a 32-bit PCI configuration register. The bit field is + specified by the StartBit and the EndBit. The value of the bit field is + returned. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 32-bit boundary, then ASSERT(). + If the register specified by Address >= 0x100, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to read. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + + @return The value of the bit field read from the PCI configuration register. + +**/ +UINT32 +EFIAPI +PciCf8BitFieldRead32 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit + ); + +/** + Writes a bit field to a PCI configuration register. + + Writes Value to the bit field of the PCI configuration register. The bit + field is specified by the StartBit and the EndBit. All other bits in the + destination PCI configuration register are preserved. The new value of the + 32-bit register is returned. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 32-bit boundary, then ASSERT(). + If the register specified by Address >= 0x100, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + @param Value New value of the bit field. + + @return The value written back to the PCI configuration register. + +**/ +UINT32 +EFIAPI +PciCf8BitFieldWrite32 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT32 Value + ); + +/** + Reads a bit field in a 32-bit PCI configuration, performs a bitwise OR, and + writes the result back to the bit field in the 32-bit port. + + Reads the 32-bit PCI configuration register specified by Address, performs a + bitwise inclusive OR between the read result and the value specified by + OrData, and writes the result to the 32-bit PCI configuration register + specified by Address. The value written to the PCI configuration register is + returned. This function must guarantee that all PCI read and write operations + are serialized. Extra left bits in OrData are stripped. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 32-bit boundary, then ASSERT(). + If the register specified by Address >= 0x100, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + @param OrData The value to OR with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT32 +EFIAPI +PciCf8BitFieldOr32 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT32 OrData + ); + +/** + Reads a bit field in a 32-bit PCI configuration register, performs a bitwise + AND, and writes the result back to the bit field in the 32-bit register. + + Reads the 32-bit PCI configuration register specified by Address, performs a + bitwise AND between the read result and the value specified by AndData, and + writes the result to the 32-bit PCI configuration register specified by + Address. The value written to the PCI configuration register is returned. + This function must guarantee that all PCI read and write operations are + serialized. Extra left bits in AndData are stripped. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 32-bit boundary, then ASSERT(). + If the register specified by Address >= 0x100, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + @param AndData The value to AND with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT32 +EFIAPI +PciCf8BitFieldAnd32 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT32 AndData + ); + +/** + Reads a bit field in a 32-bit port, performs a bitwise AND followed by a + bitwise inclusive OR, and writes the result back to the bit field in the + 32-bit port. + + Reads the 32-bit PCI configuration register specified by Address, performs a + bitwise AND followed by a bitwise inclusive OR between the read result and + the value specified by AndData, and writes the result to the 32-bit PCI + configuration register specified by Address. The value written to the PCI + configuration register is returned. This function must guarantee that all PCI + read and write operations are serialized. Extra left bits in both AndData and + OrData are stripped. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 32-bit boundary, then ASSERT(). + If the register specified by Address >= 0x100, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + @param AndData The value to AND with the PCI configuration register. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the PCI configuration register. + +**/ +UINT32 +EFIAPI +PciCf8BitFieldAndThenOr32 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT32 AndData, + IN UINT32 OrData + ); + +/** + Reads a range of PCI configuration registers into a caller supplied buffer. + + Reads the range of PCI configuration registers specified by StartAddress and + Size into the buffer specified by Buffer. This function only allows the PCI + configuration registers from a single PCI function to be read. Size is + returned. When possible 32-bit PCI configuration read cycles are used to read + from StartAdress to StartAddress + Size. Due to alignment restrictions, 8-bit + and 16-bit PCI configuration read cycles may be used at the beginning and the + end of the range. + + If StartAddress > 0x0FFFFFFF, then ASSERT(). + If the register specified by StartAddress >= 0x100, then ASSERT(). + If ((StartAddress & 0xFFF) + Size) > 0x100, then ASSERT(). + If Size > 0 and Buffer is NULL, then ASSERT(). + + @param StartAddress Starting address that encodes the PCI Bus, Device, + Function and Register. + @param Size Size in bytes of the transfer. + @param Buffer Pointer to a buffer receiving the data read. + + @return Size + +**/ +UINTN +EFIAPI +PciCf8ReadBuffer ( + IN UINTN StartAddress, + IN UINTN Size, + OUT VOID *Buffer + ); + +/** + Copies the data in a caller supplied buffer to a specified range of PCI + configuration space. + + Writes the range of PCI configuration registers specified by StartAddress and + Size from the buffer specified by Buffer. This function only allows the PCI + configuration registers from a single PCI function to be written. Size is + returned. When possible 32-bit PCI configuration write cycles are used to + write from StartAdress to StartAddress + Size. Due to alignment restrictions, + 8-bit and 16-bit PCI configuration write cycles may be used at the beginning + and the end of the range. + + If StartAddress > 0x0FFFFFFF, then ASSERT(). + If the register specified by StartAddress >= 0x100, then ASSERT(). + If ((StartAddress & 0xFFF) + Size) > 0x100, then ASSERT(). + If Size > 0 and Buffer is NULL, then ASSERT(). + + @param StartAddress Starting address that encodes the PCI Bus, Device, + Function and Register. + @param Size Size in bytes of the transfer. + @param Buffer Pointer to a buffer containing the data to write. + + @return Size + +**/ +UINTN +EFIAPI +PciCf8WriteBuffer ( + IN UINTN StartAddress, + IN UINTN Size, + IN VOID *Buffer + ); + +#endif diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGluePciExpressLib.h b/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGluePciExpressLib.h new file mode 100644 index 0000000..4fe4668 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGluePciExpressLib.h @@ -0,0 +1,1023 @@ +/*++ + +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: + + EdkIIGluePciExpressLib.h + +Abstract: + + Public header file for Pci Express Lib + +--*/ + +#ifndef __EDKII_GLUE_PCI_EXPRESS_LIB_H__ +#define __EDKII_GLUE_PCI_EXPRESS_LIB_H__ + + +/** + Macro that converts PCI Bus, PCI Device, PCI Function and PCI Register to an + address that can be passed to the PCI Library functions. + + Computes an address that is compatible with the PCI Library functions. The + unused upper bits of Bus, Device, Function and Register are stripped prior to + the generation of the address. + + @param Bus PCI Bus number. Range 0..255. + @param Device PCI Device number. Range 0..31. + @param Function PCI Function number. Range 0..7. + @param Register PCI Register number. Range 0..4095. + + @return The encode PCI address. + +**/ +#define PCI_EXPRESS_LIB_ADDRESS(Bus,Device,Function,Offset) \ + (((Offset) & 0xfff) | (((Function) & 0x07) << 12) | (((Device) & 0x1f) << 15) | (((Bus) & 0xff) << 20)) + +/** + Reads an 8-bit PCI configuration register. + + Reads and returns the 8-bit PCI configuration register specified by Address. + This function must guarantee that all PCI read and write operations are + serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + + @return The read value from the PCI configuration register. + +**/ +UINT8 +EFIAPI +PciExpressRead8 ( + IN UINTN Address + ); + +/** + Writes an 8-bit PCI configuration register. + + Writes the 8-bit PCI configuration register specified by Address with the + value specified by Value. Value is returned. This function must guarantee + that all PCI read and write operations are serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param Value The value to write. + + @return The value written to the PCI configuration register. + +**/ +UINT8 +EFIAPI +PciExpressWrite8 ( + IN UINTN Address, + IN UINT8 Data + ); + +/** + Performs a bitwise inclusive OR of an 8-bit PCI configuration register with + an 8-bit value. + + Reads the 8-bit PCI configuration register specified by Address, performs a + bitwise inclusive OR between the read result and the value specified by + OrData, and writes the result to the 8-bit PCI configuration register + specified by Address. The value written to the PCI configuration register is + returned. This function must guarantee that all PCI read and write operations + are serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param OrData The value to OR with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT8 +EFIAPI +PciExpressOr8 ( + IN UINTN Address, + IN UINT8 OrData + ); + +/** + Performs a bitwise AND of an 8-bit PCI configuration register with an 8-bit + value. + + Reads the 8-bit PCI configuration register specified by Address, performs a + bitwise AND between the read result and the value specified by AndData, and + writes the result to the 8-bit PCI configuration register specified by + Address. The value written to the PCI configuration register is returned. + This function must guarantee that all PCI read and write operations are + serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param AndData The value to AND with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT8 +EFIAPI +PciExpressAnd8 ( + IN UINTN Address, + IN UINT8 AndData + ); + +/** + Performs a bitwise AND of an 8-bit PCI configuration register with an 8-bit + value, followed a bitwise inclusive OR with another 8-bit value. + + Reads the 8-bit PCI configuration register specified by Address, performs a + bitwise AND between the read result and the value specified by AndData, + performs a bitwise inclusive OR between the result of the AND operation and + the value specified by OrData, and writes the result to the 8-bit PCI + configuration register specified by Address. The value written to the PCI + configuration register is returned. This function must guarantee that all PCI + read and write operations are serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param AndData The value to AND with the PCI configuration register. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the PCI configuration register. + +**/ +UINT8 +EFIAPI +PciExpressAndThenOr8 ( + IN UINTN Address, + IN UINT8 AndData, + IN UINT8 OrData + ); + +/** + Reads a bit field of a PCI configuration register. + + Reads the bit field in an 8-bit PCI configuration register. The bit field is + specified by the StartBit and the EndBit. The value of the bit field is + returned. + + If Address > 0x0FFFFFFF, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to read. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..7. + + @return The value of the bit field read from the PCI configuration register. + +**/ +UINT8 +EFIAPI +PciExpressBitFieldRead8 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit + ); + +/** + Writes a bit field to a PCI configuration register. + + Writes Value to the bit field of the PCI configuration register. The bit + field is specified by the StartBit and the EndBit. All other bits in the + destination PCI configuration register are preserved. The new value of the + 8-bit register is returned. + + If Address > 0x0FFFFFFF, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..7. + @param Value New value of the bit field. + + @return The value written back to the PCI configuration register. + +**/ +UINT8 +EFIAPI +PciExpressBitFieldWrite8 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT8 Value + ); + +/** + Reads a bit field in an 8-bit PCI configuration, performs a bitwise OR, and + writes the result back to the bit field in the 8-bit port. + + Reads the 8-bit PCI configuration register specified by Address, performs a + bitwise inclusive OR between the read result and the value specified by + OrData, and writes the result to the 8-bit PCI configuration register + specified by Address. The value written to the PCI configuration register is + returned. This function must guarantee that all PCI read and write operations + are serialized. Extra left bits in OrData are stripped. + + If Address > 0x0FFFFFFF, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..7. + @param OrData The value to OR with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT8 +EFIAPI +PciExpressBitFieldOr8 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT8 OrData + ); + +/** + Reads a bit field in an 8-bit PCI configuration register, performs a bitwise + AND, and writes the result back to the bit field in the 8-bit register. + + Reads the 8-bit PCI configuration register specified by Address, performs a + bitwise AND between the read result and the value specified by AndData, and + writes the result to the 8-bit PCI configuration register specified by + Address. The value written to the PCI configuration register is returned. + This function must guarantee that all PCI read and write operations are + serialized. Extra left bits in AndData are stripped. + + If Address > 0x0FFFFFFF, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..7. + @param AndData The value to AND with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT8 +EFIAPI +PciExpressBitFieldAnd8 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT8 AndData + ); + +/** + Reads a bit field in an 8-bit port, performs a bitwise AND followed by a + bitwise inclusive OR, and writes the result back to the bit field in the + 8-bit port. + + Reads the 8-bit PCI configuration register specified by Address, performs a + bitwise AND followed by a bitwise inclusive OR between the read result and + the value specified by AndData, and writes the result to the 8-bit PCI + configuration register specified by Address. The value written to the PCI + configuration register is returned. This function must guarantee that all PCI + read and write operations are serialized. Extra left bits in both AndData and + OrData are stripped. + + If Address > 0x0FFFFFFF, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..7. + @param AndData The value to AND with the PCI configuration register. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the PCI configuration register. + +**/ +UINT8 +EFIAPI +PciExpressBitFieldAndThenOr8 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT8 AndData, + IN UINT8 OrData + ); + +/** + Reads a 16-bit PCI configuration register. + + Reads and returns the 16-bit PCI configuration register specified by Address. + This function must guarantee that all PCI read and write operations are + serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 16-bit boundary, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + + @return The read value from the PCI configuration register. + +**/ +UINT16 +EFIAPI +PciExpressRead16 ( + IN UINTN Address + ); + +/** + Writes a 16-bit PCI configuration register. + + Writes the 16-bit PCI configuration register specified by Address with the + value specified by Value. Value is returned. This function must guarantee + that all PCI read and write operations are serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 16-bit boundary, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param Value The value to write. + + @return The value written to the PCI configuration register. + +**/ +UINT16 +EFIAPI +PciExpressWrite16 ( + IN UINTN Address, + IN UINT16 Data + ); + +/** + Performs a bitwise inclusive OR of a 16-bit PCI configuration register with + a 16-bit value. + + Reads the 16-bit PCI configuration register specified by Address, performs a + bitwise inclusive OR between the read result and the value specified by + OrData, and writes the result to the 16-bit PCI configuration register + specified by Address. The value written to the PCI configuration register is + returned. This function must guarantee that all PCI read and write operations + are serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 16-bit boundary, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param OrData The value to OR with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT16 +EFIAPI +PciExpressOr16 ( + IN UINTN Address, + IN UINT16 OrData + ); + +/** + Performs a bitwise AND of a 16-bit PCI configuration register with a 16-bit + value. + + Reads the 16-bit PCI configuration register specified by Address, performs a + bitwise AND between the read result and the value specified by AndData, and + writes the result to the 16-bit PCI configuration register specified by + Address. The value written to the PCI configuration register is returned. + This function must guarantee that all PCI read and write operations are + serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 16-bit boundary, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param AndData The value to AND with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT16 +EFIAPI +PciExpressAnd16 ( + IN UINTN Address, + IN UINT16 AndData + ); + +/** + Performs a bitwise AND of a 16-bit PCI configuration register with a 16-bit + value, followed a bitwise inclusive OR with another 16-bit value. + + Reads the 16-bit PCI configuration register specified by Address, performs a + bitwise AND between the read result and the value specified by AndData, + performs a bitwise inclusive OR between the result of the AND operation and + the value specified by OrData, and writes the result to the 16-bit PCI + configuration register specified by Address. The value written to the PCI + configuration register is returned. This function must guarantee that all PCI + read and write operations are serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 16-bit boundary, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param AndData The value to AND with the PCI configuration register. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the PCI configuration register. + +**/ +UINT16 +EFIAPI +PciExpressAndThenOr16 ( + IN UINTN Address, + IN UINT16 AndData, + IN UINT16 OrData + ); + +/** + Reads a bit field of a PCI configuration register. + + Reads the bit field in a 16-bit PCI configuration register. The bit field is + specified by the StartBit and the EndBit. The value of the bit field is + returned. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 16-bit boundary, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to read. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..15. + + @return The value of the bit field read from the PCI configuration register. + +**/ +UINT16 +EFIAPI +PciExpressBitFieldRead16 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit + ); + +/** + Writes a bit field to a PCI configuration register. + + Writes Value to the bit field of the PCI configuration register. The bit + field is specified by the StartBit and the EndBit. All other bits in the + destination PCI configuration register are preserved. The new value of the + 16-bit register is returned. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 16-bit boundary, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..15. + @param Value New value of the bit field. + + @return The value written back to the PCI configuration register. + +**/ +UINT16 +EFIAPI +PciExpressBitFieldWrite16 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT16 Value + ); + +/** + Reads a bit field in a 16-bit PCI configuration, performs a bitwise OR, and + writes the result back to the bit field in the 16-bit port. + + Reads the 16-bit PCI configuration register specified by Address, performs a + bitwise inclusive OR between the read result and the value specified by + OrData, and writes the result to the 16-bit PCI configuration register + specified by Address. The value written to the PCI configuration register is + returned. This function must guarantee that all PCI read and write operations + are serialized. Extra left bits in OrData are stripped. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 16-bit boundary, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..15. + @param OrData The value to OR with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT16 +EFIAPI +PciExpressBitFieldOr16 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT16 OrData + ); + +/** + Reads a bit field in a 16-bit PCI configuration register, performs a bitwise + AND, and writes the result back to the bit field in the 16-bit register. + + Reads the 16-bit PCI configuration register specified by Address, performs a + bitwise AND between the read result and the value specified by AndData, and + writes the result to the 16-bit PCI configuration register specified by + Address. The value written to the PCI configuration register is returned. + This function must guarantee that all PCI read and write operations are + serialized. Extra left bits in AndData are stripped. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 16-bit boundary, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..15. + @param AndData The value to AND with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT16 +EFIAPI +PciExpressBitFieldAnd16 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT16 AndData + ); + +/** + Reads a bit field in a 16-bit port, performs a bitwise AND followed by a + bitwise inclusive OR, and writes the result back to the bit field in the + 16-bit port. + + Reads the 16-bit PCI configuration register specified by Address, performs a + bitwise AND followed by a bitwise inclusive OR between the read result and + the value specified by AndData, and writes the result to the 16-bit PCI + configuration register specified by Address. The value written to the PCI + configuration register is returned. This function must guarantee that all PCI + read and write operations are serialized. Extra left bits in both AndData and + OrData are stripped. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 16-bit boundary, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..15. + @param AndData The value to AND with the PCI configuration register. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the PCI configuration register. + +**/ +UINT16 +EFIAPI +PciExpressBitFieldAndThenOr16 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT16 AndData, + IN UINT16 OrData + ); + +/** + Reads a 32-bit PCI configuration register. + + Reads and returns the 32-bit PCI configuration register specified by Address. + This function must guarantee that all PCI read and write operations are + serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 32-bit boundary, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + + @return The read value from the PCI configuration register. + +**/ +UINT32 +EFIAPI +PciExpressRead32 ( + IN UINTN Address + ); + +/** + Writes a 32-bit PCI configuration register. + + Writes the 32-bit PCI configuration register specified by Address with the + value specified by Value. Value is returned. This function must guarantee + that all PCI read and write operations are serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 32-bit boundary, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param Value The value to write. + + @return The value written to the PCI configuration register. + +**/ +UINT32 +EFIAPI +PciExpressWrite32 ( + IN UINTN Address, + IN UINT32 Data + ); + +/** + Performs a bitwise inclusive OR of a 32-bit PCI configuration register with + a 32-bit value. + + Reads the 32-bit PCI configuration register specified by Address, performs a + bitwise inclusive OR between the read result and the value specified by + OrData, and writes the result to the 32-bit PCI configuration register + specified by Address. The value written to the PCI configuration register is + returned. This function must guarantee that all PCI read and write operations + are serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 32-bit boundary, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param OrData The value to OR with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT32 +EFIAPI +PciExpressOr32 ( + IN UINTN Address, + IN UINT32 OrData + ); + +/** + Performs a bitwise AND of a 32-bit PCI configuration register with a 32-bit + value. + + Reads the 32-bit PCI configuration register specified by Address, performs a + bitwise AND between the read result and the value specified by AndData, and + writes the result to the 32-bit PCI configuration register specified by + Address. The value written to the PCI configuration register is returned. + This function must guarantee that all PCI read and write operations are + serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 32-bit boundary, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param AndData The value to AND with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT32 +EFIAPI +PciExpressAnd32 ( + IN UINTN Address, + IN UINT32 AndData + ); + +/** + Performs a bitwise AND of a 32-bit PCI configuration register with a 32-bit + value, followed a bitwise inclusive OR with another 32-bit value. + + Reads the 32-bit PCI configuration register specified by Address, performs a + bitwise AND between the read result and the value specified by AndData, + performs a bitwise inclusive OR between the result of the AND operation and + the value specified by OrData, and writes the result to the 32-bit PCI + configuration register specified by Address. The value written to the PCI + configuration register is returned. This function must guarantee that all PCI + read and write operations are serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 32-bit boundary, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param AndData The value to AND with the PCI configuration register. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the PCI configuration register. + +**/ +UINT32 +EFIAPI +PciExpressAndThenOr32 ( + IN UINTN Address, + IN UINT32 AndData, + IN UINT32 OrData + ); + +/** + Reads a bit field of a PCI configuration register. + + Reads the bit field in a 32-bit PCI configuration register. The bit field is + specified by the StartBit and the EndBit. The value of the bit field is + returned. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 32-bit boundary, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to read. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + + @return The value of the bit field read from the PCI configuration register. + +**/ +UINT32 +EFIAPI +PciExpressBitFieldRead32 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit + ); + +/** + Writes a bit field to a PCI configuration register. + + Writes Value to the bit field of the PCI configuration register. The bit + field is specified by the StartBit and the EndBit. All other bits in the + destination PCI configuration register are preserved. The new value of the + 32-bit register is returned. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 32-bit boundary, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + @param Value New value of the bit field. + + @return The value written back to the PCI configuration register. + +**/ +UINT32 +EFIAPI +PciExpressBitFieldWrite32 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT32 Value + ); + +/** + Reads a bit field in a 32-bit PCI configuration, performs a bitwise OR, and + writes the result back to the bit field in the 32-bit port. + + Reads the 32-bit PCI configuration register specified by Address, performs a + bitwise inclusive OR between the read result and the value specified by + OrData, and writes the result to the 32-bit PCI configuration register + specified by Address. The value written to the PCI configuration register is + returned. This function must guarantee that all PCI read and write operations + are serialized. Extra left bits in OrData are stripped. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 32-bit boundary, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + @param OrData The value to OR with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT32 +EFIAPI +PciExpressBitFieldOr32 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT32 OrData + ); + +/** + Reads a bit field in a 32-bit PCI configuration register, performs a bitwise + AND, and writes the result back to the bit field in the 32-bit register. + + Reads the 32-bit PCI configuration register specified by Address, performs a + bitwise AND between the read result and the value specified by AndData, and + writes the result to the 32-bit PCI configuration register specified by + Address. The value written to the PCI configuration register is returned. + This function must guarantee that all PCI read and write operations are + serialized. Extra left bits in AndData are stripped. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 32-bit boundary, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + @param AndData The value to AND with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT32 +EFIAPI +PciExpressBitFieldAnd32 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT32 AndData + ); + +/** + Reads a bit field in a 32-bit port, performs a bitwise AND followed by a + bitwise inclusive OR, and writes the result back to the bit field in the + 32-bit port. + + Reads the 32-bit PCI configuration register specified by Address, performs a + bitwise AND followed by a bitwise inclusive OR between the read result and + the value specified by AndData, and writes the result to the 32-bit PCI + configuration register specified by Address. The value written to the PCI + configuration register is returned. This function must guarantee that all PCI + read and write operations are serialized. Extra left bits in both AndData and + OrData are stripped. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 32-bit boundary, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + @param AndData The value to AND with the PCI configuration register. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the PCI configuration register. + +**/ +UINT32 +EFIAPI +PciExpressBitFieldAndThenOr32 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT32 AndData, + IN UINT32 OrData + ); + +/** + Reads a range of PCI configuration registers into a caller supplied buffer. + + Reads the range of PCI configuration registers specified by StartAddress and + Size into the buffer specified by Buffer. This function only allows the PCI + configuration registers from a single PCI function to be read. Size is + returned. When possible 32-bit PCI configuration read cycles are used to read + from StartAdress to StartAddress + Size. Due to alignment restrictions, 8-bit + and 16-bit PCI configuration read cycles may be used at the beginning and the + end of the range. + + If StartAddress > 0x0FFFFFFF, then ASSERT(). + If ((StartAddress & 0xFFF) + Size) > 0x1000, then ASSERT(). + If Size > 0 and Buffer is NULL, then ASSERT(). + + @param StartAddress Starting address that encodes the PCI Bus, Device, + Function and Register. + @param Size Size in bytes of the transfer. + @param Buffer Pointer to a buffer receiving the data read. + + @return Size + +**/ +UINTN +EFIAPI +PciExpressReadBuffer ( + IN UINTN StartAddress, + IN UINTN Size, + OUT VOID *Buffer + ); + +/** + Copies the data in a caller supplied buffer to a specified range of PCI + configuration space. + + Writes the range of PCI configuration registers specified by StartAddress and + Size from the buffer specified by Buffer. This function only allows the PCI + configuration registers from a single PCI function to be written. Size is + returned. When possible 32-bit PCI configuration write cycles are used to + write from StartAdress to StartAddress + Size. Due to alignment restrictions, + 8-bit and 16-bit PCI configuration write cycles may be used at the beginning + and the end of the range. + + If StartAddress > 0x0FFFFFFF, then ASSERT(). + If ((StartAddress & 0xFFF) + Size) > 0x1000, then ASSERT(). + If Size > 0 and Buffer is NULL, then ASSERT(). + + @param StartAddress Starting address that encodes the PCI Bus, Device, + Function and Register. + @param Size Size in bytes of the transfer. + @param Buffer Pointer to a buffer containing the data to write. + + @return Size + +**/ +UINTN +EFIAPI +PciExpressWriteBuffer ( + IN UINTN StartAddress, + IN UINTN Size, + IN VOID *Buffer + ); + +#endif diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGluePciLib.h b/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGluePciLib.h new file mode 100644 index 0000000..26193dd --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGluePciLib.h @@ -0,0 +1,1019 @@ +/*++ + +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: + + EdkIIGluePciLib.h + +Abstract: + + Public header file for Pci Lib + +--*/ + +#ifndef __EDKII_GLUE_PCI_LIB_H__ +#define __EDKII_GLUE_PCI_LIB_H__ + +/** + Macro that converts PCI Bus, PCI Device, PCI Function and PCI Register to an + address that can be passed to the PCI Library functions. + + @param Bus PCI Bus number. Range 0..255. + @param Device PCI Device number. Range 0..31. + @param Function PCI Function number. Range 0..7. + @param Register PCI Register number. Range 0..255 for PCI. Range 0..4095 + for PCI Express. + + @return The encoded PCI address. + +**/ +#define PCI_LIB_ADDRESS(Bus,Device,Function,Offset) \ + (((Offset) & 0xfff) | (((Function) & 0x07) << 12) | (((Device) & 0x1f) << 15) | (((Bus) & 0xff) << 20)) + +/** + Reads an 8-bit PCI configuration register. + + Reads and returns the 8-bit PCI configuration register specified by Address. + This function must guarantee that all PCI read and write operations are + serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + + @return The read value from the PCI configuration register. + +**/ +UINT8 +EFIAPI +PciRead8 ( + IN UINTN Address + ); + +/** + Writes an 8-bit PCI configuration register. + + Writes the 8-bit PCI configuration register specified by Address with the + value specified by Value. Value is returned. This function must guarantee + that all PCI read and write operations are serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param Value The value to write. + + @return The value written to the PCI configuration register. + +**/ +UINT8 +EFIAPI +PciWrite8 ( + IN UINTN Address, + IN UINT8 Data + ); + +/** + Performs a bitwise inclusive OR of an 8-bit PCI configuration register with + an 8-bit value. + + Reads the 8-bit PCI configuration register specified by Address, performs a + bitwise inclusive OR between the read result and the value specified by + OrData, and writes the result to the 8-bit PCI configuration register + specified by Address. The value written to the PCI configuration register is + returned. This function must guarantee that all PCI read and write operations + are serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param OrData The value to OR with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT8 +EFIAPI +PciOr8 ( + IN UINTN Address, + IN UINT8 OrData + ); + +/** + Performs a bitwise AND of an 8-bit PCI configuration register with an 8-bit + value. + + Reads the 8-bit PCI configuration register specified by Address, performs a + bitwise AND between the read result and the value specified by AndData, and + writes the result to the 8-bit PCI configuration register specified by + Address. The value written to the PCI configuration register is returned. + This function must guarantee that all PCI read and write operations are + serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param AndData The value to AND with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT8 +EFIAPI +PciAnd8 ( + IN UINTN Address, + IN UINT8 AndData + ); + +/** + Performs a bitwise AND of an 8-bit PCI configuration register with an 8-bit + value, followed a bitwise inclusive OR with another 8-bit value. + + Reads the 8-bit PCI configuration register specified by Address, performs a + bitwise AND between the read result and the value specified by AndData, + performs a bitwise inclusive OR between the result of the AND operation and + the value specified by OrData, and writes the result to the 8-bit PCI + configuration register specified by Address. The value written to the PCI + configuration register is returned. This function must guarantee that all PCI + read and write operations are serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param AndData The value to AND with the PCI configuration register. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the PCI configuration register. + +**/ +UINT8 +EFIAPI +PciAndThenOr8 ( + IN UINTN Address, + IN UINT8 AndData, + IN UINT8 OrData + ); + +/** + Reads a bit field of a PCI configuration register. + + Reads the bit field in an 8-bit PCI configuration register. The bit field is + specified by the StartBit and the EndBit. The value of the bit field is + returned. + + If Address > 0x0FFFFFFF, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to read. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..7. + + @return The value of the bit field read from the PCI configuration register. + +**/ +UINT8 +EFIAPI +PciBitFieldRead8 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit + ); + +/** + Writes a bit field to a PCI configuration register. + + Writes Value to the bit field of the PCI configuration register. The bit + field is specified by the StartBit and the EndBit. All other bits in the + destination PCI configuration register are preserved. The new value of the + 8-bit register is returned. + + If Address > 0x0FFFFFFF, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..7. + @param Value New value of the bit field. + + @return The value written back to the PCI configuration register. + +**/ +UINT8 +EFIAPI +PciBitFieldWrite8 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT8 Value + ); + +/** + Reads a bit field in an 8-bit PCI configuration, performs a bitwise OR, and + writes the result back to the bit field in the 8-bit port. + + Reads the 8-bit PCI configuration register specified by Address, performs a + bitwise inclusive OR between the read result and the value specified by + OrData, and writes the result to the 8-bit PCI configuration register + specified by Address. The value written to the PCI configuration register is + returned. This function must guarantee that all PCI read and write operations + are serialized. Extra left bits in OrData are stripped. + + If Address > 0x0FFFFFFF, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..7. + @param OrData The value to OR with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT8 +EFIAPI +PciBitFieldOr8 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT8 OrData + ); + +/** + Reads a bit field in an 8-bit PCI configuration register, performs a bitwise + AND, and writes the result back to the bit field in the 8-bit register. + + Reads the 8-bit PCI configuration register specified by Address, performs a + bitwise AND between the read result and the value specified by AndData, and + writes the result to the 8-bit PCI configuration register specified by + Address. The value written to the PCI configuration register is returned. + This function must guarantee that all PCI read and write operations are + serialized. Extra left bits in AndData are stripped. + + If Address > 0x0FFFFFFF, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..7. + @param AndData The value to AND with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT8 +EFIAPI +PciBitFieldAnd8 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT8 AndData + ); + +/** + Reads a bit field in an 8-bit port, performs a bitwise AND followed by a + bitwise inclusive OR, and writes the result back to the bit field in the + 8-bit port. + + Reads the 8-bit PCI configuration register specified by Address, performs a + bitwise AND followed by a bitwise inclusive OR between the read result and + the value specified by AndData, and writes the result to the 8-bit PCI + configuration register specified by Address. The value written to the PCI + configuration register is returned. This function must guarantee that all PCI + read and write operations are serialized. Extra left bits in both AndData and + OrData are stripped. + + If Address > 0x0FFFFFFF, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..7. + @param AndData The value to AND with the PCI configuration register. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the PCI configuration register. + +**/ +UINT8 +EFIAPI +PciBitFieldAndThenOr8 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT8 AndData, + IN UINT8 OrData + ); + +/** + Reads a 16-bit PCI configuration register. + + Reads and returns the 16-bit PCI configuration register specified by Address. + This function must guarantee that all PCI read and write operations are + serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 16-bit boundary, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + + @return The read value from the PCI configuration register. + +**/ +UINT16 +EFIAPI +PciRead16 ( + IN UINTN Address + ); + +/** + Writes a 16-bit PCI configuration register. + + Writes the 16-bit PCI configuration register specified by Address with the + value specified by Value. Value is returned. This function must guarantee + that all PCI read and write operations are serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 16-bit boundary, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param Value The value to write. + + @return The value written to the PCI configuration register. + +**/ +UINT16 +EFIAPI +PciWrite16 ( + IN UINTN Address, + IN UINT16 Data + ); + +/** + Performs a bitwise inclusive OR of a 16-bit PCI configuration register with + a 16-bit value. + + Reads the 16-bit PCI configuration register specified by Address, performs a + bitwise inclusive OR between the read result and the value specified by + OrData, and writes the result to the 16-bit PCI configuration register + specified by Address. The value written to the PCI configuration register is + returned. This function must guarantee that all PCI read and write operations + are serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 16-bit boundary, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param OrData The value to OR with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT16 +EFIAPI +PciOr16 ( + IN UINTN Address, + IN UINT16 OrData + ); + +/** + Performs a bitwise AND of a 16-bit PCI configuration register with a 16-bit + value. + + Reads the 16-bit PCI configuration register specified by Address, performs a + bitwise AND between the read result and the value specified by AndData, and + writes the result to the 16-bit PCI configuration register specified by + Address. The value written to the PCI configuration register is returned. + This function must guarantee that all PCI read and write operations are + serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 16-bit boundary, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param AndData The value to AND with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT16 +EFIAPI +PciAnd16 ( + IN UINTN Address, + IN UINT16 AndData + ); + +/** + Performs a bitwise AND of a 16-bit PCI configuration register with a 16-bit + value, followed a bitwise inclusive OR with another 16-bit value. + + Reads the 16-bit PCI configuration register specified by Address, performs a + bitwise AND between the read result and the value specified by AndData, + performs a bitwise inclusive OR between the result of the AND operation and + the value specified by OrData, and writes the result to the 16-bit PCI + configuration register specified by Address. The value written to the PCI + configuration register is returned. This function must guarantee that all PCI + read and write operations are serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 16-bit boundary, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param AndData The value to AND with the PCI configuration register. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the PCI configuration register. + +**/ +UINT16 +EFIAPI +PciAndThenOr16 ( + IN UINTN Address, + IN UINT16 AndData, + IN UINT16 OrData + ); + +/** + Reads a bit field of a PCI configuration register. + + Reads the bit field in a 16-bit PCI configuration register. The bit field is + specified by the StartBit and the EndBit. The value of the bit field is + returned. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 16-bit boundary, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to read. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..15. + + @return The value of the bit field read from the PCI configuration register. + +**/ +UINT16 +EFIAPI +PciBitFieldRead16 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit + ); + +/** + Writes a bit field to a PCI configuration register. + + Writes Value to the bit field of the PCI configuration register. The bit + field is specified by the StartBit and the EndBit. All other bits in the + destination PCI configuration register are preserved. The new value of the + 16-bit register is returned. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 16-bit boundary, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..15. + @param Value New value of the bit field. + + @return The value written back to the PCI configuration register. + +**/ +UINT16 +EFIAPI +PciBitFieldWrite16 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT16 Value + ); + +/** + Reads a bit field in a 16-bit PCI configuration, performs a bitwise OR, and + writes the result back to the bit field in the 16-bit port. + + Reads the 16-bit PCI configuration register specified by Address, performs a + bitwise inclusive OR between the read result and the value specified by + OrData, and writes the result to the 16-bit PCI configuration register + specified by Address. The value written to the PCI configuration register is + returned. This function must guarantee that all PCI read and write operations + are serialized. Extra left bits in OrData are stripped. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 16-bit boundary, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..15. + @param OrData The value to OR with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT16 +EFIAPI +PciBitFieldOr16 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT16 OrData + ); + +/** + Reads a bit field in a 16-bit PCI configuration register, performs a bitwise + AND, and writes the result back to the bit field in the 16-bit register. + + Reads the 16-bit PCI configuration register specified by Address, performs a + bitwise AND between the read result and the value specified by AndData, and + writes the result to the 16-bit PCI configuration register specified by + Address. The value written to the PCI configuration register is returned. + This function must guarantee that all PCI read and write operations are + serialized. Extra left bits in AndData are stripped. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 16-bit boundary, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..15. + @param AndData The value to AND with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT16 +EFIAPI +PciBitFieldAnd16 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT16 AndData + ); + +/** + Reads a bit field in a 16-bit port, performs a bitwise AND followed by a + bitwise inclusive OR, and writes the result back to the bit field in the + 16-bit port. + + Reads the 16-bit PCI configuration register specified by Address, performs a + bitwise AND followed by a bitwise inclusive OR between the read result and + the value specified by AndData, and writes the result to the 16-bit PCI + configuration register specified by Address. The value written to the PCI + configuration register is returned. This function must guarantee that all PCI + read and write operations are serialized. Extra left bits in both AndData and + OrData are stripped. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 16-bit boundary, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..15. + @param AndData The value to AND with the PCI configuration register. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the PCI configuration register. + +**/ +UINT16 +EFIAPI +PciBitFieldAndThenOr16 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT16 AndData, + IN UINT16 OrData + ); + +/** + Reads a 32-bit PCI configuration register. + + Reads and returns the 32-bit PCI configuration register specified by Address. + This function must guarantee that all PCI read and write operations are + serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 32-bit boundary, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + + @return The read value from the PCI configuration register. + +**/ +UINT32 +EFIAPI +PciRead32 ( + IN UINTN Address + ); + +/** + Writes a 32-bit PCI configuration register. + + Writes the 32-bit PCI configuration register specified by Address with the + value specified by Value. Value is returned. This function must guarantee + that all PCI read and write operations are serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 32-bit boundary, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param Value The value to write. + + @return The value written to the PCI configuration register. + +**/ +UINT32 +EFIAPI +PciWrite32 ( + IN UINTN Address, + IN UINT32 Data + ); + +/** + Performs a bitwise inclusive OR of a 32-bit PCI configuration register with + a 32-bit value. + + Reads the 32-bit PCI configuration register specified by Address, performs a + bitwise inclusive OR between the read result and the value specified by + OrData, and writes the result to the 32-bit PCI configuration register + specified by Address. The value written to the PCI configuration register is + returned. This function must guarantee that all PCI read and write operations + are serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 32-bit boundary, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param OrData The value to OR with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT32 +EFIAPI +PciOr32 ( + IN UINTN Address, + IN UINT32 OrData + ); + +/** + Performs a bitwise AND of a 32-bit PCI configuration register with a 32-bit + value. + + Reads the 32-bit PCI configuration register specified by Address, performs a + bitwise AND between the read result and the value specified by AndData, and + writes the result to the 32-bit PCI configuration register specified by + Address. The value written to the PCI configuration register is returned. + This function must guarantee that all PCI read and write operations are + serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 32-bit boundary, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param AndData The value to AND with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT32 +EFIAPI +PciAnd32 ( + IN UINTN Address, + IN UINT32 AndData + ); + +/** + Performs a bitwise AND of a 32-bit PCI configuration register with a 32-bit + value, followed a bitwise inclusive OR with another 32-bit value. + + Reads the 32-bit PCI configuration register specified by Address, performs a + bitwise AND between the read result and the value specified by AndData, + performs a bitwise inclusive OR between the result of the AND operation and + the value specified by OrData, and writes the result to the 32-bit PCI + configuration register specified by Address. The value written to the PCI + configuration register is returned. This function must guarantee that all PCI + read and write operations are serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 32-bit boundary, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param AndData The value to AND with the PCI configuration register. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the PCI configuration register. + +**/ +UINT32 +EFIAPI +PciAndThenOr32 ( + IN UINTN Address, + IN UINT32 AndData, + IN UINT32 OrData + ); + +/** + Reads a bit field of a PCI configuration register. + + Reads the bit field in a 32-bit PCI configuration register. The bit field is + specified by the StartBit and the EndBit. The value of the bit field is + returned. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 32-bit boundary, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to read. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + + @return The value of the bit field read from the PCI configuration register. + +**/ +UINT32 +EFIAPI +PciBitFieldRead32 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit + ); + +/** + Writes a bit field to a PCI configuration register. + + Writes Value to the bit field of the PCI configuration register. The bit + field is specified by the StartBit and the EndBit. All other bits in the + destination PCI configuration register are preserved. The new value of the + 32-bit register is returned. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 32-bit boundary, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + @param Value New value of the bit field. + + @return The value written back to the PCI configuration register. + +**/ +UINT32 +EFIAPI +PciBitFieldWrite32 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT32 Value + ); + +/** + Reads a bit field in a 32-bit PCI configuration, performs a bitwise OR, and + writes the result back to the bit field in the 32-bit port. + + Reads the 32-bit PCI configuration register specified by Address, performs a + bitwise inclusive OR between the read result and the value specified by + OrData, and writes the result to the 32-bit PCI configuration register + specified by Address. The value written to the PCI configuration register is + returned. This function must guarantee that all PCI read and write operations + are serialized. Extra left bits in OrData are stripped. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 32-bit boundary, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + @param OrData The value to OR with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT32 +EFIAPI +PciBitFieldOr32 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT32 OrData + ); + +/** + Reads a bit field in a 32-bit PCI configuration register, performs a bitwise + AND, and writes the result back to the bit field in the 32-bit register. + + Reads the 32-bit PCI configuration register specified by Address, performs a + bitwise AND between the read result and the value specified by AndData, and + writes the result to the 32-bit PCI configuration register specified by + Address. The value written to the PCI configuration register is returned. + This function must guarantee that all PCI read and write operations are + serialized. Extra left bits in AndData are stripped. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 32-bit boundary, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + @param AndData The value to AND with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT32 +EFIAPI +PciBitFieldAnd32 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT32 AndData + ); + +/** + Reads a bit field in a 32-bit port, performs a bitwise AND followed by a + bitwise inclusive OR, and writes the result back to the bit field in the + 32-bit port. + + Reads the 32-bit PCI configuration register specified by Address, performs a + bitwise AND followed by a bitwise inclusive OR between the read result and + the value specified by AndData, and writes the result to the 32-bit PCI + configuration register specified by Address. The value written to the PCI + configuration register is returned. This function must guarantee that all PCI + read and write operations are serialized. Extra left bits in both AndData and + OrData are stripped. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 32-bit boundary, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + @param AndData The value to AND with the PCI configuration register. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the PCI configuration register. + +**/ +UINT32 +EFIAPI +PciBitFieldAndThenOr32 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT32 AndData, + IN UINT32 OrData + ); + +/** + Reads a range of PCI configuration registers into a caller supplied buffer. + + Reads the range of PCI configuration registers specified by StartAddress and + Size into the buffer specified by Buffer. This function only allows the PCI + configuration registers from a single PCI function to be read. Size is + returned. When possible 32-bit PCI configuration read cycles are used to read + from StartAdress to StartAddress + Size. Due to alignment restrictions, 8-bit + and 16-bit PCI configuration read cycles may be used at the beginning and the + end of the range. + + If StartAddress > 0x0FFFFFFF, then ASSERT(). + If ((StartAddress & 0xFFF) + Size) > 0x1000, then ASSERT(). + If Size > 0 and Buffer is NULL, then ASSERT(). + + @param StartAddress Starting address that encodes the PCI Bus, Device, + Function and Register. + @param Size Size in bytes of the transfer. + @param Buffer Pointer to a buffer receiving the data read. + + @return Size + +**/ +UINTN +EFIAPI +PciReadBuffer ( + IN UINTN StartAddress, + IN UINTN Size, + OUT VOID *Buffer + ); + +/** + Copies the data in a caller supplied buffer to a specified range of PCI + configuration space. + + Writes the range of PCI configuration registers specified by StartAddress and + Size from the buffer specified by Buffer. This function only allows the PCI + configuration registers from a single PCI function to be written. Size is + returned. When possible 32-bit PCI configuration write cycles are used to + write from StartAdress to StartAddress + Size. Due to alignment restrictions, + 8-bit and 16-bit PCI configuration write cycles may be used at the beginning + and the end of the range. + + If StartAddress > 0x0FFFFFFF, then ASSERT(). + If ((StartAddress & 0xFFF) + Size) > 0x1000, then ASSERT(). + If Size > 0 and Buffer is NULL, then ASSERT(). + + @param StartAddress Starting address that encodes the PCI Bus, Device, + Function and Register. + @param Size Size in bytes of the transfer. + @param Buffer Pointer to a buffer containing the data to write. + + @return Size + +**/ +UINTN +EFIAPI +PciWriteBuffer ( + IN UINTN StartAddress, + IN UINTN Size, + IN VOID *Buffer + ); + +#endif diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGluePeCoffGetEntryPointLib.h b/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGluePeCoffGetEntryPointLib.h new file mode 100644 index 0000000..a82ea3c --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGluePeCoffGetEntryPointLib.h @@ -0,0 +1,93 @@ +/*++ + +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: + + EdkIIGluePeCoffGetEntryPointLib.h + +Abstract: + + Public header file for PeCoff Get Entry Point Lib + +--*/ + +#ifndef __EDKII_GLUE_PE_COFF_GET_ENTRY_POINT_LIB_H__ +#define __EDKII_GLUE_PE_COFF_GET_ENTRY_POINT_LIB_H__ + +/** + Retrieves and returns a pointer to the entry point to a PE/COFF image that has been loaded + into system memory with the PE/COFF Loader Library functions. + + Retrieves the entry point to the PE/COFF image specified by Pe32Data and returns this entry + point in EntryPoint. If the entry point could not be retrieved from the PE/COFF image, then + return RETURN_INVALID_PARAMETER. Otherwise return RETURN_SUCCESS. + If Pe32Data is NULL, then ASSERT(). + If EntryPoint is NULL, then ASSERT(). + + @param Pe32Data Pointer to the PE/COFF image that is loaded in system memory. + @param EntryPoint Pointer to entry point to the PE/COFF image to return. + + @retval RETURN_SUCCESS EntryPoint was returned. + @retval RETURN_INVALID_PARAMETER The entry point could not be found in the PE/COFF image. + +**/ +RETURN_STATUS +EFIAPI +PeCoffLoaderGetEntryPoint ( + IN VOID *Pe32Data, + OUT VOID **EntryPoint + ); + +/** + Returns the machine type of a PE/COFF image. + + Returns the machine type from the PE/COFF image specified by Pe32Data. + If Pe32Data is NULL, then ASSERT(). + + @param Pe32Data Pointer to the PE/COFF image that is loaded in system + memory. + + @return Machine type or zero if not a valid iamge. + +**/ +UINT16 +EFIAPI +PeCoffLoaderGetMachineType ( + IN VOID *Pe32Data + ); + +/** + Returns a pointer to the PDB file name for a PE/COFF image that has been + loaded into system memory with the PE/COFF Loader Library functions. + + Returns the PDB file name for the PE/COFF image specified by Pe32Data. If + the PE/COFF image specified by Pe32Data is not a valid, then NULL is + returned. If the PE/COFF image specified by Pe32Data does not contain a + debug directory entry, then NULL is returned. If the debug directory entry + in the PE/COFF image specified by Pe32Data does not contain a PDB file name, + then NULL is returned. + If Pe32Data is NULL, then ASSERT(). + + @param Pe32Data Pointer to the PE/COFF image that is loaded in system + memory. + + @return The PDB file name for the PE/COFF image specified by Pe32Data or NULL + if it cannot be retrieved. + +**/ +VOID * +EFIAPI +PeCoffLoaderGetPdbPointer ( + IN VOID *Pe32Data + ); + +#endif diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGluePeCoffLib.h b/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGluePeCoffLib.h new file mode 100644 index 0000000..4c1f59f --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGluePeCoffLib.h @@ -0,0 +1,227 @@ +/*++ + +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: + + EdkIIGluePeCoffLib.h + +Abstract: + + Public header file for PeCoff Lib + +--*/ + +#ifndef __EDKII_GLUE_BASE_PE_COFF_LIB_H__ +#define __EDKII_GLUE_BASE_PE_COFF_LIB_H__ + + +#define PeCoffLoaderGetImageInfo(_IMAGECONTEXT) GluePeCoffLoaderGetImageInfo(_IMAGECONTEXT) +#define PeCoffLoaderRelocateImage(_IMAGECONTEXT) GluePeCoffLoaderRelocateImage(_IMAGECONTEXT) +#define PeCoffLoaderLoadImage(_IMAGECONTEXT) GluePeCoffLoaderLoadImage(_IMAGECONTEXT) +#define PeCoffLoaderGetPeHeader(_IMAGECONTEXT, _HDR) GluePeCoffLoaderGetPeHeader(_IMAGECONTEXT, _HDR) +#define PeCoffLoaderImageAddress(_IMAGECONTEXT, _ADR) GluePeCoffLoaderImageAddress(_IMAGECONTEXT, _ADR) +#define PeCoffLoaderRelocateImage(_IMAGECONTEXT) GluePeCoffLoaderRelocateImage(_IMAGECONTEXT) +#define PeCoffLoaderRelocateImageEx(_RELOC, _FIXUP, _FIXUPDATA, _ADJUST) \ + GluePeCoffLoaderRelocateImageEx(_RELOC, _FIXUP, _FIXUPDATA, _ADJUST) +#define PeHotRelocateImageEx(_RELOC, _FIXUP, _FIXUPDATA, _ADJUST) \ + GluePeHotRelocateImageEx(_RELOC, _FIXUP, _FIXUPDATA, _ADJUST) + + +// +// Return status codes from the PE/COFF Loader services +// BUGBUG: Find where used and see if can be replaced by RETURN_STATUS codes +// +#define IMAGE_ERROR_SUCCESS 0 +#define IMAGE_ERROR_IMAGE_READ 1 +#define IMAGE_ERROR_INVALID_PE_HEADER_SIGNATURE 2 +#define IMAGE_ERROR_INVALID_MACHINE_TYPE 3 +#define IMAGE_ERROR_INVALID_SUBSYSTEM 4 +#define IMAGE_ERROR_INVALID_IMAGE_ADDRESS 5 +#define IMAGE_ERROR_INVALID_IMAGE_SIZE 6 +#define IMAGE_ERROR_INVALID_SECTION_ALIGNMENT 7 +#define IMAGE_ERROR_SECTION_NOT_LOADED 8 +#define IMAGE_ERROR_FAILED_RELOCATION 9 +#define IMAGE_ERROR_FAILED_ICACHE_FLUSH 10 + +// +// PE/COFF Loader Read Function passed in by caller +// +typedef +RETURN_STATUS +(EFIAPI *PE_COFF_LOADER_READ_FILE) ( + IN VOID *FileHandle, + IN UINTN FileOffset, + IN OUT UINTN *ReadSize, + OUT VOID *Buffer + ); + +// +// Context structure used while PE/COFF image is being loaded and relocated +// +typedef struct { + PHYSICAL_ADDRESS ImageAddress; + UINT64 ImageSize; + PHYSICAL_ADDRESS DestinationAddress; + PHYSICAL_ADDRESS EntryPoint; + PE_COFF_LOADER_READ_FILE ImageRead; + VOID *Handle; + VOID *FixupData; + UINT32 SectionAlignment; + UINT32 PeCoffHeaderOffset; + UINT32 DebugDirectoryEntryRva; + VOID *CodeView; + CHAR8 *PdbPointer; + UINTN SizeOfHeaders; + UINT32 ImageCodeMemoryType; + UINT32 ImageDataMemoryType; + UINT32 ImageError; + UINTN FixupDataSize; + UINT16 Machine; + UINT16 ImageType; + BOOLEAN RelocationsStripped; + BOOLEAN IsTeImage; +} PE_COFF_LOADER_IMAGE_CONTEXT; + + +/** + Retrieves information about a PE/COFF image. + + Computes the PeCoffHeaderOffset, ImageAddress, ImageSize, DestinationAddress, CodeView, + PdbPointer, RelocationsStripped, SectionAlignment, SizeOfHeaders, and DebugDirectoryEntryRva + fields of the ImageContext structure. If ImageContext is NULL, then return RETURN_INVALID_PARAMETER. + If the PE/COFF image accessed through the ImageRead service in the ImageContext structure is not + a supported PE/COFF image type, then return RETURN_UNSUPPORTED. If any errors occur while + computing the fields of ImageContext, then the error status is returned in the ImageError field of + ImageContext. + + @param ImageContext Pointer to the image context structure that describes the PE/COFF + image that needs to be examined by this function. + + @retval RETURN_SUCCESS The information on the PE/COFF image was collected. + @retval RETURN_INVALID_PARAMETER ImageContext is NULL. + @retval RETURN_UNSUPPORTED The PE/COFF image is not supported. + +**/ +RETURN_STATUS +EFIAPI +GluePeCoffLoaderGetImageInfo ( + IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext + ) +; + +/** + Applies relocation fixups to a PE/COFF image that was loaded with PeCoffLoaderLoadImage(). + + If the DestinationAddress field of ImageContext is 0, then use the ImageAddress field of + ImageContext as the relocation base address. Otherwise, use the DestinationAddress field + of ImageContext as the relocation base address. The caller must allocate the relocation + fixup log buffer and fill in the FixupData field of ImageContext prior to calling this function. + If ImageContext is NULL, then ASSERT(). + + @param ImageContext Pointer to the image context structure that describes the PE/COFF + image that is being relocated. + + @retval RETURN_SUCCESS The PE/COFF image was relocated. + Extended status information is in the ImageError field of ImageContext. + @retval RETURN_LOAD_ERROR The image in not a valid PE/COFF image. + Extended status information is in the ImageError field of ImageContext. + @retval RETURN_UNSUPPORTED A relocation record type is not supported. + Extended status information is in the ImageError field of ImageContext. + +**/ +RETURN_STATUS +EFIAPI +GluePeCoffLoaderRelocateImage ( + IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext + ) +; + +/** + Loads a PE/COFF image into memory. + + Loads the PE/COFF image accessed through the ImageRead service of ImageContext into the buffer + specified by the ImageAddress and ImageSize fields of ImageContext. The caller must allocate + the load buffer and fill in the ImageAddress and ImageSize fields prior to calling this function. + The EntryPoint, FixupDataSize, CodeView, and PdbPointer fields of ImageContext are computed. + If ImageContext is NULL, then ASSERT(). + + @param ImageContext Pointer to the image context structure that describes the PE/COFF + image that is being loaded. + + @retval RETURN_SUCCESS The PE/COFF image was loaded into the buffer specified by + the ImageAddress and ImageSize fields of ImageContext. + Extended status information is in the ImageError field of ImageContext. + @retval RETURN_BUFFER_TOO_SMALL The caller did not provide a large enough buffer. + Extended status information is in the ImageError field of ImageContext. + @retval RETURN_LOAD_ERROR The PE/COFF image is an EFI Runtime image with no relocations. + Extended status information is in the ImageError field of ImageContext. + @retval RETURN_INVALID_PARAMETER The image address is invalid. + Extended status information is in the ImageError field of ImageContext. + +**/ +RETURN_STATUS +EFIAPI +GluePeCoffLoaderLoadImage ( + IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext + ) +; + + +/** + ImageRead function that operates on a memory buffer whos base is passed into + FileHandle. + + @param FileHandle Ponter to baes of the input stream + @param FileOffset Offset to the start of the buffer + @param ReadSize Number of bytes to copy into the buffer + @param Buffer Location to place results of read + + @retval RETURN_SUCCESS Data is read from FileOffset from the Handle into + the buffer. +**/ +RETURN_STATUS +EFIAPI +PeCoffLoaderImageReadFromMemory ( + IN VOID *FileHandle, + IN UINTN FileOffset, + IN OUT UINTN *ReadSize, + OUT VOID *Buffer + ) +; + + +/** + Reapply fixups on a fixed up PE32/PE32+ image to allow virutal calling at EFI + runtime. + + PE_COFF_LOADER_IMAGE_CONTEXT.FixupData stores information needed to reapply + the fixups with a virtual mapping. + + + @param ImageBase Base address of relocated image + @param VirtImageBase Virtual mapping for ImageBase + @param ImageSize Size of the image to relocate + @param RelocationData Location to place results of read + +**/ +VOID +EFIAPI +PeCoffLoaderRelocateImageForRuntime ( + IN PHYSICAL_ADDRESS ImageBase, + IN PHYSICAL_ADDRESS VirtImageBase, + IN UINTN ImageSize, + IN VOID *RelocationData + ) +; + + +#endif diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGluePeiServicesLib.h b/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGluePeiServicesLib.h new file mode 100644 index 0000000..32e6574 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGluePeiServicesLib.h @@ -0,0 +1,361 @@ +/*++ + +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: + + EdkIIGluePeiServicesLib.h + +Abstract: + + Public header file for PEI Services Lib + +--*/ + +#ifndef __EDKII_GLUE_PEI_SERVICES_LIB_H__ +#define __EDKII_GLUE_PEI_SERVICES_LIB_H__ + +/** + This service enables a given PEIM to register an interface into the PEI Foundation. + + @param PpiList A pointer to the list of interfaces that the caller shall install. + + @retval EFI_SUCCESS The interface was successfully installed. + @retval EFI_INVALID_PARAMETER The PpiList pointer is NULL. + @retval EFI_INVALID_PARAMETER Any of the PEI PPI descriptors in the list do not have the + EFI_PEI_PPI_DESCRIPTOR_PPI bit set in the Flags field. + @retval EFI_OUT_OF_RESOURCES There is no additional space in the PPI database. + +**/ +EFI_STATUS +EFIAPI +PeiServicesInstallPpi ( + IN EFI_PEI_PPI_DESCRIPTOR *PpiList + ); + +/** + This service enables PEIMs to replace an entry in the PPI database with an alternate entry. + + @param OldPpi Pointer to the old PEI PPI Descriptors. + @param NewPpi Pointer to the new PEI PPI Descriptors. + + @retval EFI_SUCCESS The interface was successfully installed. + @retval EFI_INVALID_PARAMETER The OldPpi or NewPpi is NULL. + @retval EFI_INVALID_PARAMETER Any of the PEI PPI descriptors in the list do not have the + EFI_PEI_PPI_DESCRIPTOR_PPI bit set in the Flags field. + @retval EFI_OUT_OF_RESOURCES There is no additional space in the PPI database. + @retval EFI_NOT_FOUND The PPI for which the reinstallation was requested has not been + installed. + +**/ +EFI_STATUS +EFIAPI +PeiServicesReInstallPpi ( + IN EFI_PEI_PPI_DESCRIPTOR *OldPpi, + IN EFI_PEI_PPI_DESCRIPTOR *NewPpi + ); + +/** + This service enables PEIMs to discover a given instance of an interface. + + @param Guid A pointer to the GUID whose corresponding interface needs to be + found. + @param Instance The N-th instance of the interface that is required. + @param PpiDescriptor A pointer to instance of the EFI_PEI_PPI_DESCRIPTOR. + @param Ppi A pointer to the instance of the interface. + + @retval EFI_SUCCESS The interface was successfully returned. + @retval EFI_NOT_FOUND The PPI descriptor is not found in the database. + +**/ +EFI_STATUS +EFIAPI +PeiServicesLocatePpi ( + IN EFI_GUID *Guid, + IN UINTN Instance, + IN OUT EFI_PEI_PPI_DESCRIPTOR **PpiDescriptor, + IN OUT VOID **Ppi + ); + +/** + This service enables PEIMs to register a given service to be invoked when another service is + installed or reinstalled. + + @param NotifyList A pointer to the list of notification interfaces that the caller + shall install. + + @retval EFI_SUCCESS The interface was successfully installed. + @retval EFI_INVALID_PARAMETER The NotifyList pointer is NULL. + @retval EFI_INVALID_PARAMETER Any of the PEI notify descriptors in the list do not have the + EFI_PEI_PPI_DESCRIPTOR_NOTIFY_TYPES bit set in the Flags field. + @retval EFI_OUT_OF_RESOURCES There is no additional space in the PPI database. + +**/ +EFI_STATUS +EFIAPI +PeiServicesNotifyPpi ( + IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyList + ); + +/** + This service enables PEIMs to ascertain the present value of the boot mode. + + @param BootMode A pointer to contain the value of the boot mode. + + @retval EFI_SUCCESS The boot mode was returned successfully. + @retval EFI_INVALID_PARAMETER BootMode is NULL. + +**/ +EFI_STATUS +EFIAPI +PeiServicesGetBootMode ( + IN OUT EFI_BOOT_MODE *BootMode + ); + +/** + This service enables PEIMs to update the boot mode variable. + + @param BootMode The value of the boot mode to set. + + @retval EFI_SUCCESS The value was successfully updated + +**/ +EFI_STATUS +EFIAPI +PeiServicesSetBootMode ( + IN EFI_BOOT_MODE BootMode + ); + +/** + This service enables a PEIM to ascertain the address of the list of HOBs in memory. + + @param HobList A pointer to the list of HOBs that the PEI Foundation will initialize. + + @retval EFI_SUCCESS The list was successfully returned. + @retval EFI_NOT_AVAILABLE_YET The HOB list is not yet published. + +**/ +EFI_STATUS +EFIAPI +PeiServicesGetHobList ( + IN OUT VOID **HobList + ); + +/** + This service enables PEIMs to create various types of HOBs. + + @param Type The type of HOB to be installed. + @param Length The length of the HOB to be added. + @param Hob The address of a pointer that will contain the HOB header. + + @retval EFI_SUCCESS The HOB was successfully created. + @retval EFI_OUT_OF_RESOURCES There is no additional space for HOB creation. + +**/ +EFI_STATUS +EFIAPI +PeiServicesCreateHob ( + IN UINT16 Type, + IN UINT16 Length, + IN OUT VOID **Hob + ); + +//;;## ...AMI_OVERRIDE... Support PI1.x +#if (PI_SPECIFICATION_VERSION < 0x00010000) +/** + This service enables PEIMs to discover additional firmware volumes. + + @param Instance This instance of the firmware volume to find. The value 0 is the + Boot Firmware Volume (BFV). + @param FwVolHeader Pointer to the firmware volume header of the volume to return. + + @retval EFI_SUCCESS The volume was found. + @retval EFI_NOT_FOUND The volume was not found. + @retval EFI_INVALID_PARAMETER FwVolHeader is NULL. + +**/ +EFI_STATUS +EFIAPI +PeiServicesFfsFindNextVolume ( + IN UINTN Instance, + IN OUT EFI_FIRMWARE_VOLUME_HEADER **FwVolHeader + ); + +/** + This service enables PEIMs to discover additional firmware files. + + @param SearchType A filter to find files only of this type. + @param FwVolHeader Pointer to the firmware volume header of the volume to search. + This parameter must point to a valid FFS volume. + @param FileHeader Pointer to the current file from which to begin searching. + + @retval EFI_SUCCESS The file was found. + @retval EFI_NOT_FOUND The file was not found. + @retval EFI_NOT_FOUND The header checksum was not zero. + +**/ +EFI_STATUS +EFIAPI +PeiServicesFfsFindNextFile ( + IN EFI_FV_FILETYPE SearchType, + IN EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader, + IN OUT EFI_FFS_FILE_HEADER **FileHeader + ); + +/** + This service enables PEIMs to discover sections of a given type within a valid FFS file. + + @param SearchType The value of the section type to find. + @param FfsFileHeader A pointer to the file header that contains the set of sections to + be searched. + @param SectionData A pointer to the discovered section, if successful. + + @retval EFI_SUCCESS The section was found. + @retval EFI_NOT_FOUND The section was not found. + +**/ +EFI_STATUS +EFIAPI +PeiServicesFfsFindSectionData ( + IN EFI_SECTION_TYPE SectionType, + IN EFI_FFS_FILE_HEADER *FfsFileHeader, + IN OUT VOID **SectionData + ); +#endif + +/** + This service enables PEIMs to register the permanent memory configuration + that has been initialized with the PEI Foundation. + + @param MemoryBegin The value of a region of installed memory. + @param MemoryLength The corresponding length of a region of installed memory. + + @retval EFI_SUCCESS The region was successfully installed in a HOB. + @retval EFI_INVALID_PARAMETER MemoryBegin and MemoryLength are illegal for this system. + @retval EFI_OUT_OF_RESOURCES There is no additional space for HOB creation. + +**/ +EFI_STATUS +EFIAPI +PeiServicesInstallPeiMemory ( + IN EFI_PHYSICAL_ADDRESS MemoryBegin, + IN UINT64 MemoryLength + ); + +/** + This service enables PEIMs to allocate memory after the permanent memory has been installed by a + PEIM. + + @param MemoryType Type of memory to allocate. + @param Pages Number of pages to allocate. + @param Memory Pointer of memory allocated. + + @retval EFI_SUCCESS The memory range was successfully allocated. + @retval EFI_INVALID_PARAMETER Type is not equal to AllocateAnyPages. + @retval EFI_NOT_AVAILABLE_YET Called with permanent memory not available. + @retval EFI_OUT_OF_RESOURCES The pages could not be allocated. + +**/ +EFI_STATUS +EFIAPI +PeiServicesAllocatePages ( + IN EFI_MEMORY_TYPE MemoryType, + IN UINTN Pages, + IN OUT EFI_PHYSICAL_ADDRESS *Memory + ); + +/** + This service allocates memory from the Hand-Off Block (HOB) heap. + + @param Size The number of bytes to allocate from the pool. + @param Buffer If the call succeeds, a pointer to a pointer to the allocate + buffer; undefined otherwise. + + @retval EFI_SUCCESS The allocation was successful + @retval EFI_OUT_OF_RESOURCES There is not enough heap to allocate the requested size. + +**/ +EFI_STATUS +EFIAPI +PeiServicesAllocatePool ( + IN UINTN Size, + OUT VOID **Buffer + ); + +/** + This service resets the entire platform, including all processors and devices, and reboots the + system. + + @retval EFI_NOT_AVAILABLE_YET The service has not been installed yet. + +**/ +EFI_STATUS +EFIAPI +PeiServicesResetSystem ( + VOID + ); + +/** + PCI read-modify-write operations. + + PIWG's PI specification replaces Inte's EFI Specification 1.10. + EFI_PEI_PCI_CFG_PPI defined in Inte's EFI Specification 1.10 is replaced by + EFI_PEI_PCI_CFG2_PPI in PI 1.0. "Modify" function in these two PPI are not + compatibile with each other. + + For Framework code that make the following call: + PciCfg->Modify ( + PeiServices, + PciCfg, + Width, + Address, + SetBits, + ClearBits + ); + it will be updated to the following code which call this library API: + PeiLibPciCfgModify ( + PeiServices, + PciCfg, + Width, + Address, + SetBits, + ClearBits + ); + + @param PeiServices An indirect pointer to the PEI Services Table + published by the PEI Foundation. + @param PciCfg A pointer to the this pointer of EFI_PEI_PCI_CFG_PPI. + This parameter is unused as a place holder to make + the parameter list identical to PEI_PCI_CFG_PPI_RW. + @param Width The width of the access. Enumerated in bytes. Type + EFI_PEI_PCI_CFG_PPI_WIDTH is defined in Read(). + @param Address The physical address of the access. + @param SetBits Points to value to bitwise-OR with the read configuration value. + The size of the value is determined by Width. + @param ClearBits Points to the value to negate and bitwise-AND with the read configuration value. + The size of the value is determined by Width. + + @retval EFI_SUCCESS The function completed successfully. + @retval EFI_DEVICE_ERROR There was a problem with the transaction. +**/ +EFI_STATUS +EFIAPI +PeiLibPciCfgModify ( + IN EFI_PEI_SERVICES **PeiServices, + IN PEI_PCI_CFG_PPI *PciCfg, + IN PEI_PCI_CFG_PPI_WIDTH Width, + IN UINT64 Address, + IN UINTN SetBits, + IN UINTN ClearBits + ) +; + +#endif diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGluePeiServicesTablePointerLib.h b/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGluePeiServicesTablePointerLib.h new file mode 100644 index 0000000..7214558 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGluePeiServicesTablePointerLib.h @@ -0,0 +1,41 @@ +/*++ + +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: + + EdkIIGluePeiServicesTablePointerLib.h + +Abstract: + + Public header file for PEI Services Table Pointer Lib + +--*/ + +#ifndef __EDKII_GLUE_PEI_SERVICES_TABLE_POINTER_LIB_H__ +#define __EDKII_GLUE_PEI_SERVICES_TABLE_POINTER_LIB_H__ + +/** + The function returns the pointer to PEI services. + + The function returns the pointer to PEI services. + It will ASSERT() if the pointer to PEI services is NULL. + + @retval The pointer to PeiServices. + +**/ +EFI_PEI_SERVICES ** +GetPeiServicesTablePointer ( + VOID + ); + +#endif + diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGluePeimEntryPoint.h b/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGluePeimEntryPoint.h new file mode 100644 index 0000000..6febd76 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGluePeimEntryPoint.h @@ -0,0 +1,111 @@ +/*++ + +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: + + EdkIIGluePeimEntryPoint.h + +Abstract: + + Public header file for PEIM Entry Point Lib + +--*/ + +#ifndef __EDKII_GLUE_PEIM_ENTRY_POINT_H__ +#define __EDKII_GLUE_PEIM_ENTRY_POINT_H__ + +// +// Declare the EFI/UEFI Specification Revision to which this driver is implemented +// +extern const UINT32 _gPeimRevision; + +/** + Image entry point of Peim. + + @param FfsHeader Pointer to FFS header the loaded driver. + @param PeiServices Pointer to the PEI services. + + @return Status returned by entry points of Peims. + +**/ +EFI_STATUS +EFIAPI +_ModuleEntryPoint ( + IN EFI_FFS_FILE_HEADER *FfsHeader, + IN EFI_PEI_SERVICES **PeiServices + ); + + +/** + Wrapper of Peim image entry point. + + @param FfsHeader Pointer to FFS header the loaded driver. + @param PeiServices Pointer to the PEI services. + + @return Status returned by entry points of Peims. + +**/ +EFI_STATUS +EFIAPI +EfiMain ( + IN EFI_FFS_FILE_HEADER *FfsHeader, + IN EFI_PEI_SERVICES **PeiServices + ); + + +/** + Call constructs for all libraries. Automatics Generated by tool. + + @param FfsHeader Pointer to FFS header the loaded driver. + @param PeiServices Pointer to the PEI services. + +**/ +VOID +EFIAPI +ProcessLibraryConstructorList ( + IN EFI_FFS_FILE_HEADER *FfsHeader, + IN EFI_PEI_SERVICES **PeiServices + ); + + +/** + Call destructors for all libraries. Automatics Generated by tool. + + @param FfsHeader Pointer to FFS header the loaded driver. + @param PeiServices Pointer to the PEI services. + +**/ +VOID +EFIAPI +ProcessLibraryDestructorList ( + IN EFI_FFS_FILE_HEADER *FfsHeader, + IN EFI_PEI_SERVICES **PeiServices + ); + + +/** + Call the list of driver entry points. Automatics Generated by tool. + + @param FfsHeader Pointer to FFS header the loaded driver. + @param PeiServices Pointer to the PEI services. + + @return Status returned by entry points of drivers. + +**/ +EFI_STATUS +EFIAPI +ProcessModuleEntryPointList ( + IN EFI_FFS_FILE_HEADER *FfsHeader, + IN EFI_PEI_SERVICES **PeiServices + ); + +#endif diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGluePostCodeLib.h b/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGluePostCodeLib.h new file mode 100644 index 0000000..2f561db --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGluePostCodeLib.h @@ -0,0 +1,165 @@ +/*++ + +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: + + EdkIIGluePostCodeLib.h + +Abstract: + + Public header file for Post Code Lib + +--*/ + +#ifndef __EDKII_GLUE_POST_CODE_LIB_H__ +#define __EDKII_GLUE_POST_CODE_LIB_H__ + + +#define PostCode(_VALUE) GluePostCode(_VALUE) +#define PostCodeWithDescription(_VALUE, _DESC) GluePostCodeWithDescription(_VALUE, _DESC) +#define PostCodeEnabled() GluePostCodeEnabled() +#define PostCodeDescriptionEnabled() GluePostCodeDescriptionEnabled() + + +#define POST_CODE_PROPERTY_POST_CODE_ENABLED 0x00000008 +#define POST_CODE_PROPERTY_POST_CODE_DESCRIPTION_ENABLED 0x00000010 + +/** + Sends an 32-bit value to a POST card. + + Sends the 32-bit value specified by Value to a POST card, and returns Value. + Some implementations of this library function may perform I/O operations + directly to a POST card device. Other implementations may send Value to + ReportStatusCode(), and the status code reporting mechanism will eventually + display the 32-bit value on the status reporting device. + + PostCode() must actively prevent recursion. If PostCode() is called while + processing another any other Report Status Code Library function, then + PostCode() must return Value immediately. + + @param Value The 32-bit value to write to the POST card. + + @return Value + +**/ +UINT32 +EFIAPI +GluePostCode ( + IN UINT32 Value + ); + + +/** + Sends an 32-bit value to a POST and associated ASCII string. + + Sends the 32-bit value specified by Value to a POST card, and returns Value. + If Description is not NULL, then the ASCII string specified by Description is + also passed to the handler that displays the POST card value. Some + implementations of this library function may perform I/O operations directly + to a POST card device. Other implementations may send Value to ReportStatusCode(), + and the status code reporting mechanism will eventually display the 32-bit + value on the status reporting device. + + PostCodeWithDescription()must actively prevent recursion. If + PostCodeWithDescription() is called while processing another any other Report + Status Code Library function, then PostCodeWithDescription() must return Value + immediately. + + @param Value The 32-bit value to write to the POST card. + @param Description Pointer to an ASCII string that is a description of the + POST code value. This is an optional parameter that may + be NULL. + + @return Value + +**/ +UINT32 +EFIAPI +GluePostCodeWithDescription ( + IN UINT32 Value, + IN CONST CHAR8 *Description OPTIONAL + ); + + +/** + Returns TRUE if POST Codes are enabled. + + This function returns TRUE if the POST_CODE_PROPERTY_POST_CODE_ENABLED + bit of PcdPostCodePropertyMask is set. Otherwise FALSE is returned. + + @retval TRUE The POST_CODE_PROPERTY_POST_CODE_ENABLED bit of + PcdPostCodeProperyMask is set. + @retval FALSE The POST_CODE_PROPERTY_POST_CODE_ENABLED bit of + PcdPostCodeProperyMask is clear. + +**/ +BOOLEAN +EFIAPI +GluePostCodeEnabled ( + VOID + ); + + +/** + Returns TRUE if POST code descriptions are enabled. + + This function returns TRUE if the + POST_CODE_PROPERTY_POST_CODE_ENABLED bit of + PcdPostCodePropertyMask is set. Otherwise FALSE is returned. + + @retval TRUE The POST_CODE_PROPERTY_POST_CODE_ENABLED + bit of PcdPostCodeProperyMask is set. + @retval FALSE The POST_CODE_PROPERTY_POST_CODE_ENABLED + bit of PcdPostCodeProperyMask is clear. + +**/ +BOOLEAN +EFIAPI +GluePostCodeDescriptionEnabled ( + VOID + ); + + +/** + Sends an 32-bit value to a POST card. + + If POST codes are enabled in PcdPostCodeProperyMask, then call PostCode() + passing in Value. Value is returned. + + @param Value The 32-bit value to write to the POST card. + + @return Value + +**/ +#define POST_CODE(Value) PostCodeEnabled() ? PostCode(Value) : Value + +/** + Sends an 32-bit value to a POST and associated ASCII string. + + If POST codes and POST code descriptions are enabled in + PcdPostCodeProperyMask, then call PostCodeWithDescription() passing in + Value and Description. If only POST codes are enabled, then call PostCode() + passing in Value. Value is returned. + + @param Value The 32-bit value to write to the POST card. + @param Description Pointer to an ASCII string that is a description of the + POST code value. + +**/ +#define POST_CODE_WITH_DESCRIPTION(Value,Description) \ + PostCodeEnabled() ? \ + (PostCodeDescriptionEnabled() ? \ + PostCodeWithDescription(Value,Description) : \ + PostCode(Value)) : \ + Value + +#endif diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGluePrintLib.h b/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGluePrintLib.h new file mode 100644 index 0000000..314f578 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGluePrintLib.h @@ -0,0 +1,481 @@ +/*++ + +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: + + EdkIIGluePrintLib.h + +Abstract: + + Public header file Print Lib + +--*/ + +#ifndef __EDKII_GLUE_PRINT_LIB_H__ +#define __EDKII_GLUE_PRINT_LIB_H__ + +/// +/// Define the maximum number of characters that are required to +/// encode a decimal, hexidecimal, GUID, or TIME value with a NULL +/// terminator. +/// +/// Maximum Length Decimal String = 28 +/// "-9,223,372,036,854,775,808" +/// Maximum Length Hexidecimal String = 17 +/// "FFFFFFFFFFFFFFFF" +/// Maximum Length GUID = 37 +/// "00000000-0000-0000-0000-000000000000" +/// Maximum Length TIME = 18 +/// "12/12/2006 12:12" +/// +#define MAXIMUM_VALUE_CHARACTERS 38 + +/// +/// Flags bitmask values use in UnicodeValueToString() and +/// AsciiValueToString() +/// +#define LEFT_JUSTIFY 0x01 +#define COMMA_TYPE 0x08 +#define PREFIX_ZERO 0x20 +#define RADIX_HEX 0x80 + +/** + Produces a Null-terminated Unicode string in an output buffer based on + a Null-terminated Unicode format string and a VA_LIST argument list + + Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer + and BufferSize. + The Unicode string is produced by parsing the format string specified by FormatString. + Arguments are pulled from the variable argument list specified by Marker based on the + contents of the format string. + The number of Unicode characters in the produced output buffer is returned not including + the Null-terminator. + If BufferSize is 0 or 1, then no output buffer is produced and 0 is returned. + + If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT(). + If BufferSize > 1 and StartOfBuffer is not aligned on a 16-bit boundary, then ASSERT(). + If BufferSize > 1 and FormatString is NULL, then ASSERT(). + If BufferSize > 1 and FormatString is not aligned on a 16-bit boundary, then ASSERT(). + If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than + PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then + ASSERT(). + If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string + contains more than PcdMaximumUnicodeStringLength Unicode characters not including the + Null-terminator, then ASSERT(). + + @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated + Unicode string. + @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer. + @param FormatString Null-terminated Unicode format string. + @param Marker VA_LIST marker for the variable argument list. + + @return The number of Unicode characters in the produced output buffer not including the + Null-terminator. + +**/ +UINTN +EFIAPI +UnicodeVSPrint ( + OUT CHAR16 *StartOfBuffer, + IN UINTN BufferSize, + IN CONST CHAR16 *FormatString, + IN VA_LIST Marker + ); + +/** + Produces a Null-terminated Unicode string in an output buffer based on a Null-terminated + Unicode format string and variable argument list. + + Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer + and BufferSize. + The Unicode string is produced by parsing the format string specified by FormatString. + Arguments are pulled from the variable argument list based on the contents of the format string. + The number of Unicode characters in the produced output buffer is returned not including + the Null-terminator. + If BufferSize is 0 or 1, then no output buffer is produced and 0 is returned. + + If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT(). + If BufferSize > 1 and StartOfBuffer is not aligned on a 16-bit boundary, then ASSERT(). + If BufferSize > 1 and FormatString is NULL, then ASSERT(). + If BufferSize > 1 and FormatString is not aligned on a 16-bit boundary, then ASSERT(). + If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than + PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then + ASSERT(). + If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string + contains more than PcdMaximumUnicodeStringLength Unicode characters not including the + Null-terminator, then ASSERT(). + + @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated + Unicode string. + @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer. + @param FormatString Null-terminated Unicode format string. + + @return The number of Unicode characters in the produced output buffer not including the + Null-terminator. + +**/ +UINTN +EFIAPI +UnicodeSPrint ( + OUT CHAR16 *StartOfBuffer, + IN UINTN BufferSize, + IN CONST CHAR16 *FormatString, + ... + ); + +/** + Produces a Null-terminated Unicode string in an output buffer based on a Null-terminated + ASCII format string and a VA_LIST argument list + + Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer + and BufferSize. + The Unicode string is produced by parsing the format string specified by FormatString. + Arguments are pulled from the variable argument list specified by Marker based on the + contents of the format string. + The number of Unicode characters in the produced output buffer is returned not including + the Null-terminator. + If BufferSize is 0 or 1, then no output buffer is produced and 0 is returned. + + If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT(). + If BufferSize > 1 and StartOfBuffer is not aligned on a 16-bit boundary, then ASSERT(). + If BufferSize > 1 and FormatString is NULL, then ASSERT(). + If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than + PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, then + ASSERT(). + If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string + contains more than PcdMaximumUnicodeStringLength Unicode characters not including the + Null-terminator, then ASSERT(). + + @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated + Unicode string. + @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer. + @param FormatString Null-terminated Unicode format string. + @param Marker VA_LIST marker for the variable argument list. + + @return The number of Unicode characters in the produced output buffer not including the + Null-terminator. + +**/ +UINTN +EFIAPI +UnicodeVSPrintAsciiFormat ( + OUT CHAR16 *StartOfBuffer, + IN UINTN BufferSize, + IN CONST CHAR8 *FormatString, + IN VA_LIST Marker + ); + +/** + Produces a Null-terminated Unicode string in an output buffer based on a Null-terminated + ASCII format string and variable argument list. + + Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer + and BufferSize. + The Unicode string is produced by parsing the format string specified by FormatString. + Arguments are pulled from the variable argument list based on the contents of the + format string. + The number of Unicode characters in the produced output buffer is returned not including + the Null-terminator. + If BufferSize is 0 or 1, then no output buffer is produced and 0 is returned. + + If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT(). + If BufferSize > 1 and StartOfBuffer is not aligned on a 16-bit boundary, then ASSERT(). + If BufferSize > 1 and FormatString is NULL, then ASSERT(). + If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than + PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, then + ASSERT(). + If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string + contains more than PcdMaximumUnicodeStringLength Unicode characters not including the + Null-terminator, then ASSERT(). + + @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated + Unicode string. + @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer. + @param FormatString Null-terminated Unicode format string. + + @return The number of Unicode characters in the produced output buffer not including the + Null-terminator. + +**/ +UINTN +EFIAPI +UnicodeSPrintAsciiFormat ( + OUT CHAR16 *StartOfBuffer, + IN UINTN BufferSize, + IN CONST CHAR8 *FormatString, + ... + ); + +/** + Converts a decimal value to a Null-terminated Unicode string. + + Converts the decimal number specified by Value to a Null-terminated Unicode + string specified by Buffer containing at most Width characters. No padding of spaces + is ever performed. If Width is 0 then a width of MAXIMUM_VALUE_CHARACTERS is assumed. + The number of Unicode characters in Buffer is returned not including the Null-terminator. + If the conversion contains more than Width characters, then only the first + Width characters are returned, and the total number of characters + required to perform the conversion is returned. + Additional conversion parameters are specified in Flags. + + The Flags bit LEFT_JUSTIFY is always ignored. + All conversions are left justified in Buffer. + If Width is 0, PREFIX_ZERO is ignored in Flags. + If COMMA_TYPE is set in Flags, then PREFIX_ZERO is ignored in Flags, and commas + are inserted every 3rd digit starting from the right. + If HEX_RADIX is set in Flags, then the output buffer will be + formatted in hexadecimal format. + If Value is < 0 and HEX_RADIX is not set in Flags, then the fist character in Buffer is a '-'. + If PREFIX_ZERO is set in Flags and PREFIX_ZERO is not being ignored, + then Buffer is padded with '0' characters so the combination of the optional '-' + sign character, '0' characters, digit characters for Value, and the Null-terminator + add up to Width characters. + If both COMMA_TYPE and HEX_RADIX are set in Flags, then ASSERT(). + If Buffer is NULL, then ASSERT(). + If Buffer is not aligned on a 16-bit boundary, then ASSERT(). + If unsupported bits are set in Flags, then ASSERT(). + If both COMMA_TYPE and HEX_RADIX are set in Flags, then ASSERT(). + If Width >= MAXIMUM_VALUE_CHARACTERS, then ASSERT() + + @param Buffer Pointer to the output buffer for the produced Null-terminated + Unicode string. + @param Flags The bitmask of flags that specify left justification, zero pad, and commas. + @param Value The 64-bit signed value to convert to a string. + @param Width The maximum number of Unicode characters to place in Buffer, not including + the Null-terminator. + + @return The number of Unicode characters in Buffer not including the Null-terminator. + +**/ +UINTN +EFIAPI +UnicodeValueToString ( + IN OUT CHAR16 *Buffer, + IN UINTN Flags, + IN INT64 Value, + IN UINTN Width + ); + +/** + Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated + ASCII format string and a VA_LIST argument list. + + Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer + and BufferSize. + The ASCII string is produced by parsing the format string specified by FormatString. + Arguments are pulled from the variable argument list specified by Marker based on + the contents of the format string. + The number of ASCII characters in the produced output buffer is returned not including + the Null-terminator. + If BufferSize is 0, then no output buffer is produced and 0 is returned. + + If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT(). + If BufferSize > 0 and FormatString is NULL, then ASSERT(). + If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than + PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, then + ASSERT(). + If PcdMaximumAsciiStringLength is not zero, and produced Null-terminated ASCII string + contains more than PcdMaximumAsciiStringLength ASCII characters not including the + Null-terminator, then ASSERT(). + + @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated + ASCII string. + @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer. + @param FormatString Null-terminated Unicode format string. + @param Marker VA_LIST marker for the variable argument list. + + @return The number of ASCII characters in the produced output buffer not including the + Null-terminator. + +**/ +UINTN +EFIAPI +AsciiVSPrint ( + OUT CHAR8 *StartOfBuffer, + IN UINTN BufferSize, + IN CONST CHAR8 *FormatString, + IN VA_LIST Marker + ); + +/** + Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated + ASCII format string and variable argument list. + + Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer + and BufferSize. + The ASCII string is produced by parsing the format string specified by FormatString. + Arguments are pulled from the variable argument list based on the contents of the + format string. + The number of ASCII characters in the produced output buffer is returned not including + the Null-terminator. + If BufferSize is 0, then no output buffer is produced and 0 is returned. + + If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT(). + If BufferSize > 0 and FormatString is NULL, then ASSERT(). + If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than + PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, then + ASSERT(). + If PcdMaximumAsciiStringLength is not zero, and produced Null-terminated ASCII string + contains more than PcdMaximumAsciiStringLength ASCII characters not including the + Null-terminator, then ASSERT(). + + @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated + ASCII string. + @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer. + @param FormatString Null-terminated Unicode format string. + + @return The number of ASCII characters in the produced output buffer not including the + Null-terminator. + +**/ +UINTN +EFIAPI +AsciiSPrint ( + OUT CHAR8 *StartOfBuffer, + IN UINTN BufferSize, + IN CONST CHAR8 *FormatString, + ... + ); + +/** + Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated + ASCII format string and a VA_LIST argument list. + + Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer + and BufferSize. + The ASCII string is produced by parsing the format string specified by FormatString. + Arguments are pulled from the variable argument list specified by Marker based on + the contents of the format string. + The number of ASCII characters in the produced output buffer is returned not including + the Null-terminator. + If BufferSize is 0, then no output buffer is produced and 0 is returned. + + If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT(). + If BufferSize > 0 and FormatString is NULL, then ASSERT(). + If BufferSize > 0 and FormatString is not aligned on a 16-bit boundary, then ASSERT(). + If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than + PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then + ASSERT(). + If PcdMaximumAsciiStringLength is not zero, and produced Null-terminated ASCII string + contains more than PcdMaximumAsciiStringLength ASCII characters not including the + Null-terminator, then ASSERT(). + + @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated + ASCII string. + @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer. + @param FormatString Null-terminated Unicode format string. + @param Marker VA_LIST marker for the variable argument list. + + @return The number of ASCII characters in the produced output buffer not including the + Null-terminator. + +**/ +UINTN +EFIAPI +AsciiVSPrintUnicodeFormat ( + OUT CHAR8 *StartOfBuffer, + IN UINTN BufferSize, + IN CONST CHAR16 *FormatString, + IN VA_LIST Marker + ); + +/** + Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated + ASCII format string and variable argument list. + + Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer + and BufferSize. + The ASCII string is produced by parsing the format string specified by FormatString. + Arguments are pulled from the variable argument list based on the contents of the + format string. + The number of ASCII characters in the produced output buffer is returned not including + the Null-terminator. + If BufferSize is 0, then no output buffer is produced and 0 is returned. + + If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT(). + If BufferSize > 0 and FormatString is NULL, then ASSERT(). + If BufferSize > 0 and FormatString is not aligned on a 16-bit boundary, then ASSERT(). + If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than + PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then + ASSERT(). + If PcdMaximumAsciiStringLength is not zero, and produced Null-terminated ASCII string + contains more than PcdMaximumAsciiStringLength ASCII characters not including the + Null-terminator, then ASSERT(). + + @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated + ASCII string. + @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer. + @param FormatString Null-terminated Unicode format string. + + @return The number of ASCII characters in the produced output buffer not including the + Null-terminator. + +**/ +UINTN +EFIAPI +AsciiSPrintUnicodeFormat ( + OUT CHAR8 *StartOfBuffer, + IN UINTN BufferSize, + IN CONST CHAR16 *FormatString, + ... + ); + +/** + Converts a decimal value to a Null-terminated ASCII string. + + Converts the decimal number specified by Value to a Null-terminated ASCII string + specified by Buffer containing at most Width characters. No padding of spaces + is ever performed. + If Width is 0 then a width of MAXIMUM_VALUE_CHARACTERS is assumed. + The number of ASCII characters in Buffer is returned not including the Null-terminator. + If the conversion contains more than Width characters, then only the first Width + characters are returned, and the total number of characters required to perform + the conversion is returned. + Additional conversion parameters are specified in Flags. + The Flags bit LEFT_JUSTIFY is always ignored. + All conversions are left justified in Buffer. + If Width is 0, PREFIX_ZERO is ignored in Flags. + If COMMA_TYPE is set in Flags, then PREFIX_ZERO is ignored in Flags, and commas + are inserted every 3rd digit starting from the right. + If HEX_RADIX is set in Flags, then the output buffer will be + formatted in hexadecimal format. + If Value is < 0 and HEX_RADIX is not set in Flags, then the fist character in Buffer is a '-'. + If PREFIX_ZERO is set in Flags and PREFIX_ZERO is not being ignored, + then Buffer is padded with '0' characters so the combination of the optional '-' + sign character, '0' characters, digit characters for Value, and the Null-terminator + add up to Width characters. + + If Buffer is NULL, then ASSERT(). + If unsupported bits are set in Flags, then ASSERT(). + If both COMMA_TYPE and HEX_RADIX are set in Flags, then ASSERT(). + If Width >= MAXIMUM_VALUE_CHARACTERS, then ASSERT() + + @param Buffer Pointer to the output buffer for the produced Null-terminated + ASCII string. + @param Flags The bitmask of flags that specify left justification, zero pad, and commas. + @param Value The 64-bit signed value to convert to a string. + @param Width The maximum number of ASCII characters to place in Buffer, not including + the Null-terminator. + + @return The number of ASCII characters in Buffer not including the Null-terminator. + +**/ +UINTN +EFIAPI +AsciiValueToString ( + IN OUT CHAR8 *Buffer, + IN UINTN Flags, + IN INT64 Value, + IN UINTN Width + ); + +#endif diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueReportStatusCodeLib.h b/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueReportStatusCodeLib.h new file mode 100644 index 0000000..aaad1a0 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueReportStatusCodeLib.h @@ -0,0 +1,659 @@ +/*++ + +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: + + EdkIIGlueReportStatusCodeLib.h + +Abstract: + + Public header file for Report Status Code Lib + +--*/ + +#ifndef __EDKII_GLUE_REPORT_STATUS_CODE_LIB_H__ +#define __EDKII_GLUE_REPORT_STATUS_CODE_LIB_H__ + + + +#define CodeTypeToPostCode(_CODETYPE, _VALUE, _POSTCODE) GlueCodeTypeToPostCode(_CODETYPE, _VALUE, _POSTCODE) +#define ReportStatusCodeExtractAssertInfo(_CODETYPE, _VALUE, _DATA, _FILENAME, _DESC, _LINENUMBER) \ + GlueReportStatusCodeExtractAssertInfo(_CODETYPE, _VALUE, _DATA, _FILENAME, _DESC, _LINENUMBER) +#define ReportStatusCodeExtractDebugInfo(_DATA, _ERRORLEVEL, _MARKER, _FORMAT) \ + GlueReportStatusCodeExtractDebugInfo(_DATA, _ERRORLEVEL, _MARKER, _FORMAT) +#define ReportStatusCode(_TYPE, _VALUE) GlueReportStatusCode(_TYPE, _VALUE) +#define ReportStatusCodeWithDevicePath(_TYPE, _VALUE, _DEVICEPATH) \ + GlueReportStatusCodeWithDevicePath(_TYPE, _VALUE, _DEVICEPATH) +#define ReportStatusCodeWithExtendedData(_TYPE, _VALUE, _EXDATA, _EXDATASIZE) \ + GlueReportStatusCodeWithExtendedData(_TYPE, _VALUE, _EXDATA, _EXDATASIZE) +#define ReportStatusCodeEx(_TYPE, _VALUE, _INSTANCE, _CALLERID, _EXDATAGUID, _EXDATA, _EXDATASIZE) \ + GlueReportStatusCodeEx(_TYPE, _VALUE, _INSTANCE, _CALLERID, _EXDATAGUID, _EXDATA, _EXDATASIZE) +#define ReportProgressCodeEnabled() GlueReportProgressCodeEnabled() +#define ReportErrorCodeEnabled() GlueReportErrorCodeEnabled() +#define ReportDebugCodeEnabled() GlueReportDebugCodeEnabled() + + +// +// Declare bits for PcdReportStatusCodePropertyMask +// +#define REPORT_STATUS_CODE_PROPERTY_PROGRESS_CODE_ENABLED 0x00000001 +#define REPORT_STATUS_CODE_PROPERTY_ERROR_CODE_ENABLED 0x00000002 +#define REPORT_STATUS_CODE_PROPERTY_DEBUG_CODE_ENABLED 0x00000004 + +// +// Extended Data structure definitions with EFI_STATUS_CODE_DATA headers removed +// + +/// +/// Voltage Extended Error Data +/// +typedef struct { + EFI_EXP_BASE10_DATA Voltage; + EFI_EXP_BASE10_DATA Threshold; +} REPORT_STATUS_CODE_LIBRARY_COMPUTING_UNIT_VOLTAGE_ERROR_DATA; + +/// +/// Microcode Update Extended Error Data +/// +typedef struct { + UINT32 Version; +} REPORT_STATUS_CODE_LIBRARY_COMPUTING_UNIT_MICROCODE_UPDATE_ERROR_DATA; + +/// +/// Asynchronous Timer Extended Error Data +/// +typedef struct { + EFI_EXP_BASE10_DATA TimerLimit; +} REPORT_STATUS_CODE_LIBRARY_COMPUTING_UNIT_TIMER_EXPIRED_ERROR_DATA; + +/// +/// Host Processor Mismatch Extended Error Data +/// +typedef struct { + UINT32 Instance; + UINT16 Attributes; +} REPORT_STATUS_CODE_LIBRARY_HOST_PROCESSOR_MISMATCH_ERROR_DATA; + +/// +/// Thermal Extended Error Data +/// +typedef struct { + EFI_EXP_BASE10_DATA Temperature; + EFI_EXP_BASE10_DATA Threshold; +} REPORT_STATUS_CODE_LIBRARY_COMPUTING_UNIT_THERMAL_ERROR_DATA; + +/// +/// Processor Disabled Extended Error Data +/// +typedef struct { + UINT32 Cause; + BOOLEAN SoftwareDisabled; +} REPORT_STATUS_CODE_LIBRARY_COMPUTING_UNIT_CPU_DISABLED_ERROR_DATA; + +/// +/// Embedded cache init extended data +/// +typedef struct { + UINT32 Level; + EFI_INIT_CACHE_TYPE Type; +} REPORT_STATUS_CODE_LIBRARY_CACHE_INIT_DATA; + +/// +/// Memory Extended Error Data +/// +typedef struct { + EFI_MEMORY_ERROR_GRANULARITY Granularity; + EFI_MEMORY_ERROR_OPERATION Operation; + UINTN Syndrome; + EFI_PHYSICAL_ADDRESS Address; + UINTN Resolution; +} REPORT_STATUS_CODE_LIBRARY_MEMORY_EXTENDED_ERROR_DATA; + +/// +/// DIMM number +/// +typedef struct { + UINT16 Array; + UINT16 Device; +} REPORT_STATUS_CODE_LIBRARY_STATUS_CODE_DIMM_NUMBER; + +/// +/// Memory Module Mismatch Extended Error Data +/// +typedef struct { + EFI_STATUS_CODE_DIMM_NUMBER Instance; +} REPORT_STATUS_CODE_LIBRARY_MEMORY_MODULE_MISMATCH_ERROR_DATA; + +/// +/// Memory Range Extended Data +/// +typedef struct { + EFI_PHYSICAL_ADDRESS Start; + EFI_PHYSICAL_ADDRESS Length; +} REPORT_STATUS_CODE_LIBRARY_MEMORY_RANGE_EXTENDED_DATA; + +/// +/// Device handle Extended Data. Used for many +/// errors and progress codes to point to the device. +/// +typedef struct { + EFI_HANDLE Handle; +} REPORT_STATUS_CODE_LIBRARY_DEVICE_HANDLE_EXTENDED_DATA; + +typedef struct { + UINT8 *DevicePath; +} REPORT_STATUS_CODE_LIBRARY_DEVICE_PATH_EXTENDED_DATA; + +typedef struct { + EFI_HANDLE ControllerHandle; + EFI_HANDLE DriverBindingHandle; + UINT16 DevicePathSize; + UINT8 *RemainingDevicePath; +} REPORT_STATUS_CODE_LIBRARY_STATUS_CODE_START_EXTENDED_DATA; + +/// +/// Resource Allocation Failure Extended Error Data +/// +typedef struct { + UINT32 Bar; + UINT16 DevicePathSize; + UINT16 ReqResSize; + UINT16 AllocResSize; + UINT8 *DevicePath; + UINT8 *ReqRes; + UINT8 *AllocRes; +} REPORT_STATUS_CODE_LIBRARY_RESOURCE_ALLOC_FAILURE_ERROR_DATA; + +/// +/// Extended Error Data for Assert +/// +typedef struct { + UINT32 LineNumber; + UINT32 FileNameSize; + EFI_STATUS_CODE_STRING_DATA *FileName; +} REPORT_STATUS_CODE_LIBRARY_DEBUG_ASSERT_DATA; + +/// +/// System Context Data EBC/IA32/IPF +/// +typedef struct { + EFI_STATUS_CODE_EXCEP_SYSTEM_CONTEXT Context; +} REPORT_STATUS_CODE_LIBRARY_STATUS_CODE_EXCEP_EXTENDED_DATA; + +/// +/// Legacy Oprom extended data +/// +typedef struct { + EFI_HANDLE DeviceHandle; + EFI_PHYSICAL_ADDRESS RomImageBase; +} REPORT_STATUS_CODE_LIBRARY_LEGACY_OPROM_EXTENDED_DATA; + +// +// Extern for the modules Caller ID GUID +// +extern EFI_GUID gEfiCallerIdGuid; + +/** + Converts a status code to an 8-bit POST code value. + + Converts the status code specified by CodeType and Value to an 8-bit POST code + and returns the 8-bit POST code in PostCode. If CodeType is an + EFI_PROGRESS_CODE or CodeType is an EFI_ERROR_CODE, then bits 0..4 of PostCode + are set to bits 16..20 of Value, and bits 5..7 of PostCode are set to bits + 24..26 of Value., and TRUE is returned. Otherwise, FALSE is returned. + + If PostCode is NULL, then ASSERT(). + + @param CodeType The type of status code being converted. + @param Value The status code value being converted. + @param PostCode A pointer to the 8-bit POST code value to return. + + @retval TRUE The status code specified by CodeType and Value was converted + to an 8-bit POST code and returned in PostCode. + @retval FALSE The status code specified by CodeType and Value could not be + converted to an 8-bit POST code value. + +**/ +BOOLEAN +EFIAPI +GlueCodeTypeToPostCode ( + IN EFI_STATUS_CODE_TYPE CodeType, + IN EFI_STATUS_CODE_VALUE Value, + OUT UINT8 *PostCode + ); + + +/** + Extracts ASSERT() information from a status code structure. + + Converts the status code specified by CodeType, Value, and Data to the ASSERT() + arguments specified by Filename, Description, and LineNumber. If CodeType is + an EFI_ERROR_CODE, and CodeType has a severity of EFI_ERROR_UNRECOVERED, and + Value has an operation mask of EFI_SW_EC_ILLEGAL_SOFTWARE_STATE, extract + Filename, Description, and LineNumber from the optional data area of the + status code buffer specified by Data. The optional data area of Data contains + a Null-terminated ASCII string for the FileName, followed by a Null-terminated + ASCII string for the Description, followed by a 32-bit LineNumber. If the + ASSERT() information could be extracted from Data, then return TRUE. + Otherwise, FALSE is returned. + + If Data is NULL, then ASSERT(). + If Filename is NULL, then ASSERT(). + If Description is NULL, then ASSERT(). + If LineNumber is NULL, then ASSERT(). + + @param CodeType The type of status code being converted. + @param Value The status code value being converted. + @param Data Pointer to status code data buffer. + @param Filename Pointer to the source file name that generated the ASSERT(). + @param Description Pointer to the description of the ASSERT(). + @param LineNumber Pointer to source line number that generated the ASSERT(). + + @retval TRUE The status code specified by CodeType, Value, and Data was + converted ASSERT() arguments specified by Filename, Description, + and LineNumber. + @retval FALSE The status code specified by CodeType, Value, and Data could + not be converted to ASSERT() arguments. + +**/ +BOOLEAN +EFIAPI +GlueReportStatusCodeExtractAssertInfo ( + IN EFI_STATUS_CODE_TYPE CodeType, + IN EFI_STATUS_CODE_VALUE Value, + IN CONST EFI_STATUS_CODE_DATA *Data, + OUT CHAR8 **Filename, + OUT CHAR8 **Description, + OUT UINT32 *LineNumber + ); + + +/** + Extracts DEBUG() information from a status code structure. + + Converts the status code specified by Data to the DEBUG() arguments specified + by ErrorLevel, Marker, and Format. If type GUID in Data is + EFI_STATUS_CODE_DATA_TYPE_DEBUG_GUID, then extract ErrorLevel, Marker, and + Format from the optional data area of the status code buffer specified by Data. + The optional data area of Data contains a 32-bit ErrorLevel followed by Marker + which is 12 UINTN parameters, followed by a Null-terminated ASCII string for + the Format. If the DEBUG() information could be extracted from Data, then + return TRUE. Otherwise, FALSE is returned. + + If Data is NULL, then ASSERT(). + If ErrorLevel is NULL, then ASSERT(). + If Marker is NULL, then ASSERT(). + If Format is NULL, then ASSERT(). + + @param Data Pointer to status code data buffer. + @param ErrorLevel Pointer to error level mask for a debug message. + @param Marker Pointer to the variable argument list associated with Format. + @param Format Pointer to a Null-terminated ASCII format string of a + debug message. + + @retval TRUE The status code specified by Data was converted DEBUG() arguments + specified by ErrorLevel, Marker, and Format. + @retval FALSE The status code specified by Data could not be converted to + DEBUG() arguments. + +**/ +BOOLEAN +EFIAPI +GlueReportStatusCodeExtractDebugInfo ( + IN CONST EFI_STATUS_CODE_DATA *Data, + OUT UINT32 *ErrorLevel, + OUT VA_LIST *Marker, + OUT CHAR8 **Format + ); + + +/** + Reports a status code. + + Reports the status code specified by the parameters Type and Value. Status + code also require an instance, caller ID, and extended data. This function + passed in a zero instance, NULL extended data, and a caller ID of + gEfiCallerIdGuid, which is the GUID for the module. + + ReportStatusCode()must actively prevent recusrsion. If ReportStatusCode() + is called while processing another any other Report Status Code Library function, + then ReportStatusCode() must return immediately. + + @param Type Status code type. + @param Value Status code value. + + @retval EFI_SUCCESS The status code was reported. + @retval EFI_DEVICE_ERROR There status code could not be reported due to a + device error. + @retval EFI_UNSUPPORTED Report status code is not supported + +**/ +EFI_STATUS +EFIAPI +GlueReportStatusCode ( + IN EFI_STATUS_CODE_TYPE Type, + IN EFI_STATUS_CODE_VALUE Value + ); + + +/** + Reports a status code with a Device Path Protocol as the extended data. + + Allocates and fills in the extended data section of a status code with the + Device Path Protocol specified by DevicePath. This function is responsible + for allocating a buffer large enough for the standard header and the device + path. The standard header is filled in with a GUID of + gEfiStatusCodeSpecificDataGuid. The status code is reported with a zero + instance and a caller ID of gEfiCallerIdGuid. + + ReportStatusCodeWithDevicePath()must actively prevent recursion. If + ReportStatusCodeWithDevicePath() is called while processing another any other + Report Status Code Library function, then ReportStatusCodeWithDevicePath() + must return EFI_DEVICE_ERROR immediately. + + If DevicePath is NULL, then ASSERT(). + + @param Type Status code type. + @param Value Status code value. + @param DevicePath Pointer to the Device Path Protocol to be reported. + + @retval EFI_SUCCESS The status code was reported with the extended + data specified by DevicePath. + @retval EFI_OUT_OF_RESOURCES There were not enough resources to allocate the + extended data section. + @retval EFI_UNSUPPORTED Report status code is not supported + +**/ +EFI_STATUS +EFIAPI +GlueReportStatusCodeWithDevicePath ( + IN EFI_STATUS_CODE_TYPE Type, + IN EFI_STATUS_CODE_VALUE Value, + IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath + ); + + +/** + Reports a status code with an extended data buffer. + + Allocates and fills in the extended data section of a status code with the + extended data specified by ExtendedData and ExtendedDataSize. ExtendedData + is assumed to be one of the data structures specified in Related Definitions. + These data structure do not have the standard header, so this function is + responsible for allocating a buffer large enough for the standard header and + the extended data passed into this function. The standard header is filled + in with a GUID of gEfiStatusCodeSpecificDataGuid. The status code is reported + with a zero instance and a caller ID of gEfiCallerIdGuid. + + ReportStatusCodeWithExtendedData()must actively prevent recursion. If + ReportStatusCodeWithExtendedData() is called while processing another any other + Report Status Code Library function, then ReportStatusCodeWithExtendedData() + must return EFI_DEVICE_ERROR immediately. + + If ExtendedData is NULL, then ASSERT(). + If ExtendedDataSize is 0, then ASSERT(). + + @param Type Status code type. + @param Value Status code value. + @param ExtendedData Pointer to the extended data buffer to be reported. + @param ExtendedDataSize The size, in bytes, of the extended data buffer to + be reported. + + @retval EFI_SUCCESS The status code was reported with the extended + data specified by ExtendedData and ExtendedDataSize. + @retval EFI_OUT_OF_RESOURCES There were not enough resources to allocate the + extended data section. + @retval EFI_UNSUPPORTED Report status code is not supported + +**/ +EFI_STATUS +EFIAPI +GlueReportStatusCodeWithExtendedData ( + IN EFI_STATUS_CODE_TYPE Type, + IN EFI_STATUS_CODE_VALUE Value, + IN CONST VOID *ExtendedData, + IN UINTN ExtendedDataSize + ); + + +/** + Reports a status code with full parameters. + + The function reports a status code. If ExtendedData is NULL and ExtendedDataSize + is 0, then an extended data buffer is not reported. If ExtendedData is not + NULL and ExtendedDataSize is not 0, then an extended data buffer is allocated. + ExtendedData is assumed not have the standard status code header, so this function + is responsible for allocating a buffer large enough for the standard header and + the extended data passed into this function. The standard header is filled in + with a GUID specified by ExtendedDataGuid. If ExtendedDataGuid is NULL, then a + GUID of gEfiStatusCodeSpecificDatauid is used. The status code is reported with + an instance specified by Instance and a caller ID specified by CallerId. If + CallerId is NULL, then a caller ID of gEfiCallerIdGuid is used. + + ReportStatusCodeEx()must actively prevent recursion. If ReportStatusCodeEx() + is called while processing another any other Report Status Code Library function, + then ReportStatusCodeEx() must return EFI_DEVICE_ERROR immediately. + + If ExtendedData is NULL and ExtendedDataSize is not zero, then ASSERT(). + If ExtendedData is not NULL and ExtendedDataSize is zero, then ASSERT(). + + @param Type Status code type. + @param Value Status code value. + @param Instance Status code instance number. + @param CallerId Pointer to a GUID that identifies the caller of this + function. If this parameter is NULL, then a caller + ID of gEfiCallerIdGuid is used. + @param ExtendedDataGuid Pointer to the GUID for the extended data buffer. + If this parameter is NULL, then a the status code + standard header is filled in with + gEfiStatusCodeSpecificDataGuid. + @param ExtendedData Pointer to the extended data buffer. This is an + optional parameter that may be NULL. + @param ExtendedDataSize The size, in bytes, of the extended data buffer. + + @retval EFI_SUCCESS The status code was reported. + @retval EFI_OUT_OF_RESOURCES There were not enough resources to allocate + the extended data section if it was specified. + @retval EFI_UNSUPPORTED Report status code is not supported + +**/ +EFI_STATUS +EFIAPI +GlueReportStatusCodeEx ( + IN EFI_STATUS_CODE_TYPE Type, + IN EFI_STATUS_CODE_VALUE Value, + IN UINT32 Instance, + IN CONST EFI_GUID *CallerId OPTIONAL, + IN CONST EFI_GUID *ExtendedDataGuid OPTIONAL, + IN CONST VOID *ExtendedData OPTIONAL, + IN UINTN ExtendedDataSize + ); + + +/** + Returns TRUE if status codes of type EFI_PROGRESS_CODE are enabled + + This function returns TRUE if the REPORT_STATUS_CODE_PROPERTY_PROGRESS_CODE_ENABLED + bit of PcdReportStatusCodeProperyMask is set. Otherwise FALSE is returned. + + @retval TRUE The REPORT_STATUS_CODE_PROPERTY_PROGRESS_CODE_ENABLED bit of + PcdReportStatusCodeProperyMask is set. + @retval FALSE The REPORT_STATUS_CODE_PROPERTY_PROGRESS_CODE_ENABLED bit of + PcdReportStatusCodeProperyMask is clear. + +**/ +BOOLEAN +EFIAPI +GlueReportProgressCodeEnabled ( + VOID + ); + + +/** + Returns TRUE if status codes of type EFI_ERROR_CODE are enabled + + This function returns TRUE if the REPORT_STATUS_CODE_PROPERTY_ERROR_CODE_ENABLED + bit of PcdReportStatusCodeProperyMask is set. Otherwise FALSE is returned. + + @retval TRUE The REPORT_STATUS_CODE_PROPERTY_ERROR_CODE_ENABLED bit of + PcdReportStatusCodeProperyMask is set. + @retval FALSE The REPORT_STATUS_CODE_PROPERTY_ERROR_CODE_ENABLED bit of + PcdReportStatusCodeProperyMask is clear. + +**/ +BOOLEAN +EFIAPI +GlueReportErrorCodeEnabled ( + VOID + ); + + +/** + Returns TRUE if status codes of type EFI_DEBUG_CODE are enabled + + This function returns TRUE if the REPORT_STATUS_CODE_PROPERTY_DEBUG_CODE_ENABLED + bit of PcdReportStatusCodeProperyMask is set. Otherwise FALSE is returned. + + @retval TRUE The REPORT_STATUS_CODE_PROPERTY_DEBUG_CODE_ENABLED bit of + PcdReportStatusCodeProperyMask is set. + @retval FALSE The REPORT_STATUS_CODE_PROPERTY_DEBUG_CODE_ENABLED bit of + PcdReportStatusCodeProperyMask is clear. + +**/ +BOOLEAN +EFIAPI +GlueReportDebugCodeEnabled ( + VOID + ); + + +/** + Reports a status code with minimal parameters if the status code type is enabled. + + If the status code type specified by Type is enabled in + PcdReportStatusCodeProperyMask, then call ReportStatusCode() passing in Type + and Value. + + @param Type Status code type. + @param Value Status code value. + + @retval EFI_SUCCESS The status code was reported. + @retval EFI_DEVICE_ERROR There status code could not be reported due to a device error. + @retval EFI_UNSUPPORTED Report status code is not supported + +**/ +#define REPORT_STATUS_CODE(Type,Value) \ + (ReportProgressCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_PROGRESS_CODE) ? \ + ReportStatusCode(Type,Value) : \ + (ReportErrorCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE) ? \ + ReportStatusCode(Type,Value) : \ + (ReportDebugCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_DEBUG_CODE) ? \ + ReportStatusCode(Type,Value) : \ + EFI_UNSUPPORTED + + +/** + Reports a status code with a Device Path Protocol as the extended data if the + status code type is enabled. + + If the status code type specified by Type is enabled in + PcdReportStatusCodeProperyMask, then call ReportStatusCodeWithDevicePath() + passing in Type, Value, and DevicePath. + + @param Type Status code type. + @param Value Status code value. + @param DevicePath Pointer to the Device Path Protocol to be reported. + + @retval EFI_SUCCESS The status code was reported with the extended + data specified by DevicePath. + @retval EFI_OUT_OF_RESOURCES There were not enough resources to allocate the + extended data section. + @retval EFI_UNSUPPORTED Report status code is not supported + +**/ +#define REPORT_STATUS_CODE_WITH_DEVICE_PATH(Type,Value,DevicePathParameter) \ + (ReportProgressCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_PROGRESS_CODE) ? \ + ReportStatusCodeWithDevicePath(Type,Value,DevicePathParameter) : \ + (ReportErrorCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE) ? \ + ReportStatusCodeWithDevicePath(Type,Value,DevicePathParameter) : \ + (ReportDebugCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_DEBUG_CODE) ? \ + ReportStatusCodeWithDevicePath(Type,Value,DevicePathParameter) : \ + EFI_UNSUPPORTED + + +/** + Reports a status code with an extended data buffer if the status code type + is enabled. + + If the status code type specified by Type is enabled in + PcdReportStatusCodeProperyMask, then call ReportStatusCodeWithExtendedData() + passing in Type, Value, ExtendedData, and ExtendedDataSize. + + @param Type Status code type. + @param Value Status code value. + @param ExtendedData Pointer to the extended data buffer to be reported. + @param ExtendedDataSize The size, in bytes, of the extended data buffer to + be reported. + + @retval EFI_SUCCESS The status code was reported with the extended + data specified by ExtendedData and ExtendedDataSize. + @retval EFI_OUT_OF_RESOURCES There were not enough resources to allocate the + extended data section. + @retval EFI_UNSUPPORTED Report status code is not supported + +**/ +#define REPORT_STATUS_CODE_WITH_EXTENDED_DATA(Type,Value,ExtendedData,ExtendedDataSize) \ + (ReportProgressCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_PROGRESS_CODE) ? \ + ReportStatusCodeWithExtendedData(Type,Value,ExtendedData,ExtendedDataSize) : \ + (ReportErrorCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE) ? \ + ReportStatusCodeWithExtendedData(Type,Value,ExtendedData,ExtendedDataSize) : \ + (ReportDebugCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_DEBUG_CODE) ? \ + ReportStatusCodeWithExtendedData(Type,Value,ExtendedData,ExtendedDataSize) : \ + EFI_UNSUPPORTED + +/** + Reports a status code specifying all parameters if the status code type is enabled. + + If the status code type specified by Type is enabled in + PcdReportStatusCodeProperyMask, then call ReportStatusCodeEx() passing in Type, + Value, Instance, CallerId, ExtendedDataGuid, ExtendedData, and ExtendedDataSize. + + @param Type Status code type. + @param Value Status code value. + @param Instance Status code instance number. + @param CallerId Pointer to a GUID that identifies the caller of this + function. If this parameter is NULL, then a caller + ID of gEfiCallerIdGuid is used. + @param ExtendedDataGuid Pointer to the GUID for the extended data buffer. + If this parameter is NULL, then a the status code + standard header is filled in with + gEfiStatusCodeSpecificDataGuid. + @param ExtendedData Pointer to the extended data buffer. This is an + optional parameter that may be NULL. + @param ExtendedDataSize The size, in bytes, of the extended data buffer. + + @retval EFI_SUCCESS The status code was reported. + @retval EFI_OUT_OF_RESOURCES There were not enough resources to allocate the + extended data section if it was specified. + @retval EFI_UNSUPPORTED Report status code is not supported + +**/ +#define REPORT_STATUS_CODE_EX(Type,Value,Instance,CallerId,ExtendedDataGuid,ExtendedData,ExtendedDataSize) \ + (ReportProgressCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_PROGRESS_CODE) ? \ + ReportStatusCodeEx(Type,Value,Instance,CallerId,ExtendedDataGuid,ExtendedData,ExtendedDataSize) : \ + (ReportErrorCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE) ? \ + ReportStatusCodeEx(Type,Value,Instance,CallerId,ExtendedDataGuid,ExtendedData,ExtendedDataSize) : \ + (ReportDebugCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_DEBUG_CODE) ? \ + ReportStatusCodeEx(Type,Value,Instance,CallerId,ExtendedDataGuid,ExtendedData,ExtendedDataSize) : \ + EFI_UNSUPPORTED + +#endif diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueResourcePublicationLib.h b/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueResourcePublicationLib.h new file mode 100644 index 0000000..36b78db --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueResourcePublicationLib.h @@ -0,0 +1,50 @@ +/*++ + +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: + + EdkIIGlueResourcePublicationLib.h + +Abstract: + + Public header file for Resource Publication Lib + +--*/ + +#ifndef __EDKII_GLUE_RESOURCE_PUBLICATION_LIB_H__ +#define __EDKII_GLUE_RESOURCE_PUBLICATION_LIB_H__ + +/** + + Declares the presence of permanent system memory in the platform. + + Declares that the system memory buffer specified by MemoryBegin and MemoryLength + as permanent memory that may be used for general purpose use by software. + The amount of memory available to software may be less than MemoryLength + if published memory has alignment restrictions. + + @param MemoryBegin The start address of the memory being declared. + @param MemoryLength The number of bytes of memory being declared. + + @retval RETURN_SUCCESS The memory buffer was published. + @retval RETURN_OUT_OF_RESOURCES There are not enough resources to publish the memory buffer + +**/ +RETURN_STATUS +EFIAPI +PublishSystemMemory ( + IN PHYSICAL_ADDRESS MemoryBegin, + IN UINT64 MemoryLength + ) +; + +#endif diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueSmbusLib.h b/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueSmbusLib.h new file mode 100644 index 0000000..8fd2f33 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueSmbusLib.h @@ -0,0 +1,394 @@ +/*++ + +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: + + EdkIIGlueSmbusLib.h + +Abstract: + + Public header file for Smbus Lib + +--*/ + +#ifndef __EDKII_GLUE_SMBUS_LIB_H__ +#define __EDKII_GLUE_SMBUS_LIB_H__ + +// +// PEC BIT is bit 22 in SMBUS address +// +#define SMBUS_LIB_PEC_BIT (1 << 22) + +/** + Macro that converts SMBUS slave address, SMBUS command, SMBUS data length, + and PEC to a value that can be passed to the SMBUS Library functions. + + Computes an address that is compatible with the SMBUS Library functions. + The unused upper bits of SlaveAddress, Command, and Length are stripped + prior to the generation of the address. + + @param SlaveAddress SMBUS Slave Address. Range 0..127. + @param Command SMBUS Command. Range 0..255. + @param Length SMBUS Data Length. Range 0..32. + @param Pec TRUE if Packet Error Checking is enabled. Otherwise FALSE. + +**/ +#define SMBUS_LIB_ADDRESS(SlaveAddress,Command,Length,Pec) \ + ( ((Pec) ? SMBUS_LIB_PEC_BIT: 0) | \ + (((SlaveAddress) & 0x7f) << 1) | \ + (((Command) & 0xff) << 8) | \ + (((Length) & 0x3f) << 16) \ + ) + +/** + Executes an SMBUS quick read command. + + Executes an SMBUS quick read command on the SMBUS device specified by SmBusAddress. + Only the SMBUS slave address field of SmBusAddress is required. + If Status is not NULL, then the status of the executed command is returned in Status. + If PEC is set in SmBusAddress, then ASSERT(). + If Command in SmBusAddress is not zero, then ASSERT(). + If Length in SmBusAddress is not zero, then ASSERT(). + If any reserved bits of SmBusAddress are set, then ASSERT(). + + @param SmBusAddress Address that encodes the SMBUS Slave Address, + SMBUS Command, SMBUS Data Length, and PEC. + @param Status Return status for the executed command. + This is an optional parameter and may be NULL. + +**/ +VOID +EFIAPI +SmBusQuickRead ( + IN UINTN SmBusAddress, + OUT RETURN_STATUS *Status OPTIONAL + ) +; + +/** + Executes an SMBUS quick write command. + + Executes an SMBUS quick write command on the SMBUS device specified by SmBusAddress. + Only the SMBUS slave address field of SmBusAddress is required. + If Status is not NULL, then the status of the executed command is returned in Status. + If PEC is set in SmBusAddress, then ASSERT(). + If Command in SmBusAddress is not zero, then ASSERT(). + If Length in SmBusAddress is not zero, then ASSERT(). + If any reserved bits of SmBusAddress are set, then ASSERT(). + + @param SmBusAddress Address that encodes the SMBUS Slave Address, + SMBUS Command, SMBUS Data Length, and PEC. + @param Status Return status for the executed command. + This is an optional parameter and may be NULL. + +**/ +VOID +EFIAPI +SmBusQuickWrite ( + IN UINTN SmBusAddress, + OUT RETURN_STATUS *Status OPTIONAL + ) +; + +/** + Executes an SMBUS receive byte command. + + Executes an SMBUS receive byte command on the SMBUS device specified by SmBusAddress. + Only the SMBUS slave address field of SmBusAddress is required. + The byte received from the SMBUS is returned. + If Status is not NULL, then the status of the executed command is returned in Status. + If Command in SmBusAddress is not zero, then ASSERT(). + If Length in SmBusAddress is not zero, then ASSERT(). + If any reserved bits of SmBusAddress are set, then ASSERT(). + + @param SmBusAddress Address that encodes the SMBUS Slave Address, + SMBUS Command, SMBUS Data Length, and PEC. + @param Status Return status for the executed command. + This is an optional parameter and may be NULL. + + @return The byte received from the SMBUS. + +**/ +UINT8 +EFIAPI +SmBusReceiveByte ( + IN UINTN SmBusAddress, + OUT RETURN_STATUS *Status OPTIONAL + ) +; + +/** + Executes an SMBUS send byte command. + + Executes an SMBUS send byte command on the SMBUS device specified by SmBusAddress. + The byte specified by Value is sent. + Only the SMBUS slave address field of SmBusAddress is required. Value is returned. + If Status is not NULL, then the status of the executed command is returned in Status. + If Command in SmBusAddress is not zero, then ASSERT(). + If Length in SmBusAddress is not zero, then ASSERT(). + If any reserved bits of SmBusAddress are set, then ASSERT(). + + @param SmBusAddress Address that encodes the SMBUS Slave Address, + SMBUS Command, SMBUS Data Length, and PEC. + @param Value The 8-bit value to send. + @param Status Return status for the executed command. + This is an optional parameter and may be NULL. + + @return The parameter of Value. + +**/ +UINT8 +EFIAPI +SmBusSendByte ( + IN UINTN SmBusAddress, + IN UINT8 Value, + OUT RETURN_STATUS *Status OPTIONAL + ) +; + +/** + Executes an SMBUS read data byte command. + + Executes an SMBUS read data byte command on the SMBUS device specified by SmBusAddress. + Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required. + The 8-bit value read from the SMBUS is returned. + If Status is not NULL, then the status of the executed command is returned in Status. + If Length in SmBusAddress is not zero, then ASSERT(). + If any reserved bits of SmBusAddress are set, then ASSERT(). + + @param SmBusAddress Address that encodes the SMBUS Slave Address, + SMBUS Command, SMBUS Data Length, and PEC. + @param Status Return status for the executed command. + This is an optional parameter and may be NULL. + + @return The byte read from the SMBUS. + +**/ +UINT8 +EFIAPI +SmBusReadDataByte ( + IN UINTN SmBusAddress, + OUT RETURN_STATUS *Status OPTIONAL + ) +; + +/** + Executes an SMBUS write data byte command. + + Executes an SMBUS write data byte command on the SMBUS device specified by SmBusAddress. + The 8-bit value specified by Value is written. + Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required. + Value is returned. + If Status is not NULL, then the status of the executed command is returned in Status. + If Length in SmBusAddress is not zero, then ASSERT(). + If any reserved bits of SmBusAddress are set, then ASSERT(). + + @param SmBusAddress Address that encodes the SMBUS Slave Address, + SMBUS Command, SMBUS Data Length, and PEC. + @param Value The 8-bit value to write. + @param Status Return status for the executed command. + This is an optional parameter and may be NULL. + + @return The parameter of Value. + +**/ +UINT8 +EFIAPI +SmBusWriteDataByte ( + IN UINTN SmBusAddress, + IN UINT8 Value, + OUT RETURN_STATUS *Status OPTIONAL + ) +; + +/** + Executes an SMBUS read data word command. + + Executes an SMBUS read data word command on the SMBUS device specified by SmBusAddress. + Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required. + The 16-bit value read from the SMBUS is returned. + If Status is not NULL, then the status of the executed command is returned in Status. + If Length in SmBusAddress is not zero, then ASSERT(). + If any reserved bits of SmBusAddress are set, then ASSERT(). + + @param SmBusAddress Address that encodes the SMBUS Slave Address, + SMBUS Command, SMBUS Data Length, and PEC. + @param Status Return status for the executed command. + This is an optional parameter and may be NULL. + + @return The byte read from the SMBUS. + +**/ +UINT16 +EFIAPI +SmBusReadDataWord ( + IN UINTN SmBusAddress, + OUT RETURN_STATUS *Status OPTIONAL + ) +; + +/** + Executes an SMBUS write data word command. + + Executes an SMBUS write data word command on the SMBUS device specified by SmBusAddress. + The 16-bit value specified by Value is written. + Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required. + Value is returned. + If Status is not NULL, then the status of the executed command is returned in Status. + If Length in SmBusAddress is not zero, then ASSERT(). + If any reserved bits of SmBusAddress are set, then ASSERT(). + + @param SmBusAddress Address that encodes the SMBUS Slave Address, + SMBUS Command, SMBUS Data Length, and PEC. + @param Value The 16-bit value to write. + @param Status Return status for the executed command. + This is an optional parameter and may be NULL. + + @return The parameter of Value. + +**/ +UINT16 +EFIAPI +SmBusWriteDataWord ( + IN UINTN SmBusAddress, + IN UINT16 Value, + OUT RETURN_STATUS *Status OPTIONAL + ) +; + +/** + Executes an SMBUS process call command. + + Executes an SMBUS process call command on the SMBUS device specified by SmBusAddress. + The 16-bit value specified by Value is written. + Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required. + The 16-bit value returned by the process call command is returned. + If Status is not NULL, then the status of the executed command is returned in Status. + If Length in SmBusAddress is not zero, then ASSERT(). + If any reserved bits of SmBusAddress are set, then ASSERT(). + + @param SmBusAddress Address that encodes the SMBUS Slave Address, + SMBUS Command, SMBUS Data Length, and PEC. + @param Value The 16-bit value to write. + @param Status Return status for the executed command. + This is an optional parameter and may be NULL. + + @return The 16-bit value returned by the process call command. + +**/ +UINT16 +EFIAPI +SmBusProcessCall ( + IN UINTN SmBusAddress, + IN UINT16 Value, + OUT RETURN_STATUS *Status OPTIONAL + ) +; + +/** + Executes an SMBUS read block command. + + Executes an SMBUS read block command on the SMBUS device specified by SmBusAddress. + Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required. + Bytes are read from the SMBUS and stored in Buffer. + The number of bytes read is returned, and will never return a value larger than 32-bytes. + If Status is not NULL, then the status of the executed command is returned in Status. + It is the caller's responsibility to make sure Buffer is large enough for the total number of bytes read. + SMBUS supports a maximum transfer size of 32 bytes, so Buffer does not need to be any larger than 32 bytes. + If Length in SmBusAddress is not zero, then ASSERT(). + If Buffer is NULL, then ASSERT(). + If any reserved bits of SmBusAddress are set, then ASSERT(). + + @param SmBusAddress Address that encodes the SMBUS Slave Address, + SMBUS Command, SMBUS Data Length, and PEC. + @param Buffer Pointer to the buffer to store the bytes read from the SMBUS. + @param Status Return status for the executed command. + This is an optional parameter and may be NULL. + + @return The number of bytes read. + +**/ +UINTN +EFIAPI +SmBusReadBlock ( + IN UINTN SmBusAddress, + OUT VOID *Buffer, + OUT RETURN_STATUS *Status OPTIONAL + ) +; + +/** + Executes an SMBUS write block command. + + Executes an SMBUS write block command on the SMBUS device specified by SmBusAddress. + The SMBUS slave address, SMBUS command, and SMBUS length fields of SmBusAddress are required. + Bytes are written to the SMBUS from Buffer. + The number of bytes written is returned, and will never return a value larger than 32-bytes. + If Status is not NULL, then the status of the executed command is returned in Status. + If Length in SmBusAddress is zero or greater than 32, then ASSERT(). + If Buffer is NULL, then ASSERT(). + If any reserved bits of SmBusAddress are set, then ASSERT(). + + @param SmBusAddress Address that encodes the SMBUS Slave Address, + SMBUS Command, SMBUS Data Length, and PEC. + @param Buffer Pointer to the buffer to store the bytes read from the SMBUS. + @param Status Return status for the executed command. + This is an optional parameter and may be NULL. + + @return The number of bytes written. + +**/ +UINTN +EFIAPI +SmBusWriteBlock ( + IN UINTN SmBusAddress, + OUT VOID *Buffer, + OUT RETURN_STATUS *Status OPTIONAL + ) +; + +/** + Executes an SMBUS block process call command. + + Executes an SMBUS block process call command on the SMBUS device specified by SmBusAddress. + The SMBUS slave address, SMBUS command, and SMBUS length fields of SmBusAddress are required. + Bytes are written to the SMBUS from WriteBuffer. Bytes are then read from the SMBUS into ReadBuffer. + If Status is not NULL, then the status of the executed command is returned in Status. + It is the caller's responsibility to make sure ReadBuffer is large enough for the total number of bytes read. + SMBUS supports a maximum transfer size of 32 bytes, so Buffer does not need to be any larger than 32 bytes. + If Length in SmBusAddress is zero or greater than 32, then ASSERT(). + If WriteBuffer is NULL, then ASSERT(). + If ReadBuffer is NULL, then ASSERT(). + If any reserved bits of SmBusAddress are set, then ASSERT(). + + @param SmBusAddress Address that encodes the SMBUS Slave Address, + SMBUS Command, SMBUS Data Length, and PEC. + @param WriteBuffer Pointer to the buffer of bytes to write to the SMBUS. + @param ReadBuffer Pointer to the buffer of bytes to read from the SMBUS. + @param Status Return status for the executed command. + This is an optional parameter and may be NULL. + + @return The number of bytes written. + +**/ +UINTN +EFIAPI +SmBusBlockProcessCall ( + IN UINTN SmBusAddress, + IN VOID *WriteBuffer, + OUT VOID *ReadBuffer, + OUT RETURN_STATUS *Status OPTIONAL + ) +; + + +#endif diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueTimerLib.h b/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueTimerLib.h new file mode 100644 index 0000000..822ad5f --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueTimerLib.h @@ -0,0 +1,130 @@ +/*++ + +Copyright (c) 2004 - 2011, 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: + + EdkIIGlueTimerLib.h + +Abstract: + + Public header file for Timer Lib + +--*/ + +#ifndef __EDKII_GLUE_TIMER_LIB_H__ +#define __EDKII_GLUE_TIMER_LIB_H__ + +/** + Stalls the CPU for at least the given number of microseconds. + + Stalls the CPU for the number of microseconds specified by MicroSeconds. + + @param MicroSeconds The minimum number of microseconds to delay. + + @return MicroSeconds + +**/ +UINTN +EFIAPI +MicroSecondDelay ( + IN UINTN MicroSeconds + ); + +/** + Stalls the CPU for at least the given number of nanoseconds. + + Stalls the CPU for the number of nanoseconds specified by NanoSeconds. + + @param NanoSeconds The minimum number of nanoseconds to delay. + + @return NanoSeconds + +**/ +UINTN +EFIAPI +NanoSecondDelay ( + IN UINTN NanoSeconds + ); + +/** + Retrieves the current value of a 64-bit free running performance counter. + + Retrieves the current value of a 64-bit free running performance counter. The + counter can either count up by 1 or count down by 1. If the physical + performance counter counts by a larger increment, then the counter values + must be translated. The properties of the counter can be retrieved from + GetPerformanceCounterProperties(). + + @return The current value of the free running performance counter. + +**/ +UINT64 +EFIAPI +GetPerformanceCounter ( + VOID + ); + +/** + Retrieves the 64-bit frequency in Hz and the range of performance counter + values. + + If StartValue is not NULL, then the value that the performance counter starts + with immediately after is it rolls over is returned in StartValue. If + EndValue is not NULL, then the value that the performance counter end with + immediately before it rolls over is returned in EndValue. The 64-bit + frequency of the performance counter in Hz is always returned. If StartValue + is less than EndValue, then the performance counter counts up. If StartValue + is greater than EndValue, then the performance counter counts down. For + example, a 64-bit free running counter that counts up would have a StartValue + of 0 and an EndValue of 0xFFFFFFFFFFFFFFFF. A 24-bit free running counter + that counts down would have a StartValue of 0xFFFFFF and an EndValue of 0. + + @param StartValue The value the performance counter starts with when it + rolls over. + @param EndValue The value that the performance counter ends with before + it rolls over. + + @return The frequency in Hz. + +**/ +UINT64 +EFIAPI +GetPerformanceCounterProperties ( + IN UINT64 *StartValue, OPTIONAL + IN UINT64 *EndValue OPTIONAL + ); + +/** + Converts TSC value into nano second value. + + @param TimeStamp - TSC timer ticker + + @return UINT64 value in naosecond unit converted from TSC ticker + +**/ +UINT64 +GetTimeInNanoSec ( + UINT64 Timestamp + ); + +/** + Retrieves current APIC ID. + + @return UINT32 value of APIC ID + +**/ +UINT32 +GetApicId ( + VOID + ); + +#endif
\ No newline at end of file diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueUefiBootServicesTableLib.h b/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueUefiBootServicesTableLib.h new file mode 100644 index 0000000..d7b8c0e --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueUefiBootServicesTableLib.h @@ -0,0 +1,41 @@ +/*++ + +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: + + EdkIIGlueUefiBootServicesTableLib.h + +Abstract: + + Public header file for UEFI Boot Services Table Lib + +--*/ + +#ifndef __EDKII_GLUE_UEFI_BOOT_SERVICES_TABLE_LIB_H__ +#define __EDKII_GLUE_UEFI_BOOT_SERVICES_TABLE_LIB_H__ + +// +// Cache the Image Handle +// +extern EFI_HANDLE gImageHandle; + +// +// Cache pointer to the EFI System Table +// +extern EFI_SYSTEM_TABLE *gST; + +// +// Cache pointer to the EFI Boot Services Table +// +extern EFI_BOOT_SERVICES *gBS; + +#endif diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueUefiDecompressLib.h b/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueUefiDecompressLib.h new file mode 100644 index 0000000..2f23b6b --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueUefiDecompressLib.h @@ -0,0 +1,113 @@ +/*++ + +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: + + EdkIIGlueUefiDecompressLib.h + +Abstract: + + Public header file for UEFI Decompress Lib + +--*/ + +#ifndef __EDKII_GLUE_UEFI_DECPOMPRESS_LIB_H__ +#define __EDKII_GLUE_UEFI_DECPOMPRESS_LIB_H__ + +#define FillBuf(_SD, _NUMOFBITS) GlueFillBuf(_SD, _NUMOFBITS) +#define GetBits(_SD, _NUMOFBITS) GlueGetBits(_SD, _NUMOFBITS) +#define MakeTable(_SD, _NUMOFCHAR, _BITLEN, _TABLEBITS, _TABLE) GlueMakeTable(_SD, _NUMOFCHAR, _BITLEN, _TABLEBITS, _TABLE) +#define DecodeP(_SD) GlueDecodeP(_SD) +#define ReadPTLen( _SD, _NN, _NBIT, _SPECIAL) GlueReadPTLen( _SD, _NN, _NBIT, _SPECIAL) +#define ReadCLen(_SD) GlueReadCLen(_SD) +#define DecodeC(_SD) GlueDecodeC(_SD) +#define Decode(_SD) GlueDecode(_SD) + + + +/** + Retrieves the size of the uncompressed buffer and the size of the scratch buffer. + + Retrieves the size of the uncompressed buffer and the temporary scratch buffer + required to decompress the buffer specified by Source and SourceSize. + If the size of the uncompressed buffer or the size of the scratch buffer cannot + be determined from the compressed data specified by Source and SourceData, + then RETURN_INVALID_PARAMETER is returned. Otherwise, the size of the uncompressed + buffer is returned in DestinationSize, the size of the scratch buffer is returned + in ScratchSize, and RETURN_SUCCESS is returned. + This function does not have scratch buffer available to perform a thorough + checking of the validity of the source data. It just retrieves the "Original Size" + field from the beginning bytes of the source data and output it as DestinationSize. + And ScratchSize is specific to the decompression implementation. + + If Source is NULL, then ASSERT(). + If DestinationSize is NULL, then ASSERT(). + If ScratchSize is NULL, then ASSERT(). + + @param Source The source buffer containing the compressed data. + @param SourceSize The size, in bytes, of the source buffer. + @param DestinationSize A pointer to the size, in bytes, of the uncompressed buffer + that will be generated when the compressed buffer specified + by Source and SourceSize is decompressed.. + @param ScratchSize A pointer to the size, in bytes, of the scratch buffer that + is required to decompress the compressed buffer specified + by Source and SourceSize. + + @retval RETURN_SUCCESS The size of destination buffer and the size of scratch + buffer are successull retrieved. + @retval RETURN_INVALID_PARAMETER The source data is corrupted + +**/ +RETURN_STATUS +EFIAPI +UefiDecompressGetInfo ( + IN CONST VOID *Source, + IN UINT32 SourceSize, + OUT UINT32 *DestinationSize, + OUT UINT32 *ScratchSize + ); + +/** + Decompresses a compressed source buffer. + + This function is designed so that the decompression algorithm can be implemented + without using any memory services. As a result, this function is not allowed to + call any memory allocation services in its implementation. It is the caller¡¯s r + esponsibility to allocate and free the Destination and Scratch buffers. + If the compressed source data specified by Source is sucessfully decompressed + into Destination, then RETURN_SUCCESS is returned. If the compressed source data + specified by Source is not in a valid compressed data format, + then RETURN_INVALID_PARAMETER is returned. + + If Source is NULL, then ASSERT(). + If Destination is NULL, then ASSERT(). + If the required scratch buffer size > 0 and Scratch is NULL, then ASSERT(). + + @param Source The source buffer containing the compressed data. + @param Destination The destination buffer to store the decompressed data + @param Scratch A temporary scratch buffer that is used to perform the decompression. + This is an optional parameter that may be NULL if the + required scratch buffer size is 0. + + @retval RETURN_SUCCESS Decompression is successfull + @retval RETURN_INVALID_PARAMETER The source data is corrupted + +**/ +RETURN_STATUS +EFIAPI +UefiDecompress ( + IN CONST VOID *Source, + IN OUT VOID *Destination, + IN OUT VOID *Scratch + ); + +#endif diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueUefiDriverEntryPoint.h b/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueUefiDriverEntryPoint.h new file mode 100644 index 0000000..edc195b --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueUefiDriverEntryPoint.h @@ -0,0 +1,162 @@ +/*++ + +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: + + EdkIIGlueUefiDriverEntryPoint.h + +Abstract: + + Public header file for UEFI Driver Entry Point Lib + +--*/ + +#ifndef __EDKII_GLUE_UEFI_DRIVER_ENTRY_POINT_H__ +#define __EDKII_GLUE_UEFI_DRIVER_ENTRY_POINT_H__ + +// +// Declare the EFI/UEFI Specification Revision to which this driver is implemented +// +extern const UINT32 _gUefiDriverRevision; + +// +// Declare the number of entry points in the image. +// +extern const UINT8 _gDriverEntryPointCount; + +// +// Declare the number of unload handler in the image. +// +extern const UINT8 _gDriverUnloadImageCount; + +// +// Declare the arrary of Boot Sevice Exit Event callbacks . +// +extern const EFI_EVENT_NOTIFY _gDriverExitBootServicesEvent[]; + +// +// Declare the arrary of Virtual Address Change Event callbacks . +// +extern const EFI_EVENT_NOTIFY _gDriverSetVirtualAddressMapEvent[]; + +/** + Enrty point to DXE SMM Driver. + + @param ImageHandle ImageHandle of the loaded driver. + @param SystemTable Pointer to the EFI System Table. + + @retval EFI_SUCCESS One or more of the drivers returned a success code. + @retval !EFI_SUCESS The return status from the last driver entry point in the list. + +**/ +EFI_STATUS +EFIAPI +_ModuleEntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ); + + +/** + Enrty point wrapper of DXE Driver. + + @param ImageHandle ImageHandle of the loaded driver. + @param SystemTable Pointer to the EFI System Table. + + @retval EFI_SUCCESS One or more of the drivers returned a success code. + @retval !EFI_SUCESS The return status from the last driver entry point in the list. + +**/ +EFI_STATUS +EFIAPI +EfiMain ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ); + + +/** + Computes the cummulative return status for the driver entry point and perform + a long jump back into DriverEntryPoint(). + + @param Status Status returned by the driver that is exiting. + +**/ +VOID +EFIAPI +ExitDriver ( + IN EFI_STATUS Status + ); + + +/** + Call constructs for all libraries. Automatics Generated by tool. + + @param ImageHandle ImageHandle of the loaded driver. + @param SystemTable Pointer to the EFI System Table. + +**/ +VOID +EFIAPI +ProcessLibraryConstructorList ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ); + + +/** + Call destructors for all libraries. Automatics Generated by tool. + + @param ImageHandle ImageHandle of the loaded driver. + @param SystemTable Pointer to the EFI System Table. + +**/ +VOID +EFIAPI +ProcessLibraryDestructorList ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ); + +/** + Call the list of driver entry points. Automatics Generated by tool. + + @param ImageHandle ImageHandle of the loaded driver. + @param SystemTable Pointer to the EFI System Table. + + @return Status returned by entry points of drivers. + +**/ + +EFI_STATUS +EFIAPI +ProcessModuleEntryPointList ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ); + + +/** + Call the unload handlers for all the modules. Automatics Generated by tool. + + @param ImageHandle ImageHandle of the loaded driver. + + @return Status returned by unload handlers of drivers. + +**/ +EFI_STATUS +EFIAPI +ProcessModuleUnloadList ( + IN EFI_HANDLE ImageHandle + ); + +#endif diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueUefiDriverModelLib.h b/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueUefiDriverModelLib.h new file mode 100644 index 0000000..0fa33ea --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueUefiDriverModelLib.h @@ -0,0 +1,52 @@ +/*++ + +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: + + EdkIIGlueUefiDriverModelLib.h + +Abstract: + + Public header file for UEFI Driver Model Lib + +--*/ + +#ifndef __EDKII_GLUE_UEFI_DRIVER_MODEL_LIB_H__ +#define __EDKII_GLUE_UEFI_DRIVER_MODEL_LIB_H__ + +// +// Declare bitmask values for the protocols that are enabled +// +#define UEFI_DRIVER_MODEL_LIBRARY_COMPONENT_NAME_PROTOCOL_ENABLED 0x01 +#define UEFI_DRIVER_MODEL_LIBRARY_DRIVER_DIAGNOSTICS_PROTOCOL_ENABLED 0x02 +#define UEFI_DRIVER_MODEL_LIBRARY_DRIVER_CONFIGURATION_PROTOCOL_ENABLED 0x04 + +// +// Data structure that declares pointers to the Driver Model +// Protocols. +// +typedef struct { + const EFI_DRIVER_BINDING_PROTOCOL *DriverBinding; + const EFI_COMPONENT_NAME_PROTOCOL *ComponentName; + const EFI_DRIVER_CONFIGURATION_PROTOCOL *DriverConfiguration; + const EFI_DRIVER_DIAGNOSTICS_PROTOCOL *DriverDiagnostics; + const EFI_COMPONENT_NAME2_PROTOCOL *ComponentName2; + const EFI_DRIVER_CONFIGURATION2_PROTOCOL *DriverConfiguration2; + const EFI_DRIVER_DIAGNOSTICS2_PROTOCOL *DriverDiagnostics2; +} EFI_DRIVER_MODEL_PROTOCOL_LIST; + +// +// UEFI Driver Model Protocols arrary +// +extern const EFI_DRIVER_MODEL_PROTOCOL_LIST _gDriverModelProtocolList[]; + +#endif diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueUefiLib.h b/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueUefiLib.h new file mode 100644 index 0000000..946fabd --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueUefiLib.h @@ -0,0 +1,590 @@ +/*++ + +Copyright (c) 2004 - 2011, 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: + + EdkIIGlueUefiLib.h + +Abstract: + + Public header file for UEFI Lib + +--*/ + +#ifndef __EDKII_GLUE_UEFI_LIB_H__ +#define __EDKII_GLUE_UEFI_LIB_H__ + + +#define EfiInitializeLock(_LOCK, _PRIORITY) GlueEfiInitializeLock(_LOCK, _PRIORITY) +#define EfiAcquireLock(_LOCK) GlueEfiAcquireLock(_LOCK) +#define EfiAcquireLockOrFail(_LOCK) GlueEfiAcquireLockOrFail(_LOCK) +#define EfiReleaseLock(_LOCK) GlueEfiReleaseLock(_LOCK) +#define GetGlyphWidth(_UNICODECHAR) GlueGetGlyphWidth(_UNICODECHAR) +#define EfiCreateEventLegacyBoot(_LEGACYBOOT) GlueEfiCreateEventLegacyBoot(_LEGACYBOOT) +#define EfiCreateEventReadyToBoot(_READYTOBOOTEVENT) GlueEfiCreateEventReadyToBoot(_READYTOBOOTEVENT) +#define EfiGetNameGuidFromFwVolDevicePathNode(_FVDEVICEPATHNODE) GlueEfiGetNameGuidFromFwVolDevicePathNode(_FVDEVICEPATHNODE) +#define EfiInitializeFwVolDevicepathNode(_FVDEVICEPATHNODE, _NAMEGUID) GlueEfiInitializeFwVolDevicepathNode(_FVDEVICEPATHNODE, _NAMEGUID) + + +// +// Unicode String Table +// +typedef struct { + CHAR8 *Language; + CHAR16 *UnicodeString; +} GLUE_EFI_UNICODE_STRING_TABLE; + +// +// EFI Lock Status +// +typedef enum { + EfiLockUninitialized = 0, + EfiLockReleased = 1, + EfiLockAcquired = 2 +} EFI_LOCK_STATE; + +// +// EFI Lock +// +typedef struct { + EFI_TPL Tpl; + EFI_TPL OwnerTpl; + EFI_LOCK_STATE Lock; +} GLUE_EFI_LOCK; + +/** + This function searches the list of configuration tables stored in the EFI System + Table for a table with a GUID that matches TableGuid. If a match is found, + then a pointer to the configuration table is returned in Table, and EFI_SUCCESS + is returned. If a matching GUID is not found, then EFI_NOT_FOUND is returned. + + @param TableGuid Pointer to table's GUID type.. + @param Table Pointer to the table associated with TableGuid in the EFI System Table. + + @retval EFI_SUCCESS A configuration table matching TableGuid was found. + @retval EFI_NOT_FOUND A configuration table matching TableGuid could not be found. + +**/ +EFI_STATUS +EFIAPI +EfiGetSystemConfigurationTable ( + IN EFI_GUID *TableGuid, + OUT VOID **Table + ); + +/** + This function causes the notification function to be executed for every protocol + of type ProtocolGuid instance that exists in the system when this function is + invoked. In addition, every time a protocol of type ProtocolGuid instance is + installed or reinstalled, the notification function is also executed. + + @param ProtocolGuid Supplies GUID of the protocol upon whose installation the event is fired. + @param NotifyTpl Supplies the task priority level of the event notifications. + @param NotifyFunction Supplies the function to notify when the event is signaled. + @param NotifyContext The context parameter to pass to NotifyFunction. + @param Registration A pointer to a memory location to receive the registration value. + + @return The notification event that was created. + +**/ +EFI_EVENT +EFIAPI +EfiCreateProtocolNotifyEvent( + IN EFI_GUID *ProtocolGuid, + IN EFI_TPL NotifyTpl, + IN EFI_EVENT_NOTIFY NotifyFunction, + IN VOID *NotifyContext, OPTIONAL + OUT VOID **Registration + ); + +/** + This function creates an event using NotifyTpl, NoifyFunction, and NotifyContext. + This event is signaled with EfiNamedEventSignal(). This provide the ability for + one or more listeners on the same event named by the GUID specified by Name. + + @param Name Supplies GUID name of the event. + @param NotifyTpl Supplies the task priority level of the event notifications. + @param NotifyFunction Supplies the function to notify when the event is signaled. + @param NotifyContext The context parameter to pass to NotifyFunction. + @param Registration A pointer to a memory location to receive the registration value. + + @retval EFI_SUCCESS A named event was created. + @retval EFI_OUT_OF_RESOURCES There are not enough resource to create the named event. + +**/ +EFI_STATUS +EFIAPI +EfiNamedEventListen ( + IN CONST EFI_GUID *Name, + IN EFI_TPL NotifyTpl, + IN EFI_EVENT_NOTIFY NotifyFunction, + IN CONST VOID *NotifyContext, OPTIONAL + OUT VOID *Registration OPTIONAL + ); + +/** + This function signals the named event specified by Name. The named event must + have been created with EfiNamedEventListen(). + + @param Name Supplies GUID name of the event. + + @retval EFI_SUCCESS A named event was signaled. + @retval EFI_OUT_OF_RESOURCES There are not enough resource to signal the named event. + +**/ +EFI_STATUS +EFIAPI +EfiNamedEventSignal ( + IN CONST EFI_GUID *Name + ); + +/** + This function initializes a basic mutual exclusion lock to the released state + and returns the lock. Each lock provides mutual exclusion access at its task + priority level. Since there is no preemption or multiprocessor support in EFI, + acquiring the lock only consists of raising to the locks TPL. + + @param Lock A pointer to the lock data structure to initialize. + @param Priority EFI TPL associated with the lock. + + @return The lock. + +**/ +EFI_LOCK * +EFIAPI +GlueEfiInitializeLock ( + IN OUT EFI_LOCK *Lock, + IN EFI_TPL Priority + ); + +/** + This macro initializes the contents of a basic mutual exclusion lock to the + released state. Each lock provides mutual exclusion access at its task + priority level. Since there is no preemption or multiprocessor support in EFI, + acquiring the lock only consists of raising to the locks TPL. + + @param Lock A pointer to the lock data structure to initialize. + @param Priority The task priority level of the lock. + + @return The lock. + +**/ +#ifdef EFI_INITIALIZE_LOCK_VARIABLE +#undef EFI_INITIALIZE_LOCK_VARIABLE +#endif + +#define EFI_INITIALIZE_LOCK_VARIABLE(Priority) \ + {Priority, EFI_TPL_APPLICATION, EfiLockReleased } + + +/** + + Macro that calls DebugAssert() if an EFI_LOCK structure is not in the locked state. + + If the DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED bit of PcdDebugProperyMask is set, + then this macro evaluates the EFI_LOCK structure specified by Lock. If Lock + is not in the locked state, then DebugAssert() is called passing in the source + filename, source line number, and Lock. + + If Lock is NULL, then ASSERT(). + + @param LockParameter A pointer to the lock to acquire. + +**/ +#ifdef ASSERT_LOCKED +#undef ASSERT_LOCKED +#endif + +#define ASSERT_LOCKED(LockParameter) \ + do { \ + if (DebugAssertEnabled ()) { \ + ASSERT (LockParameter != NULL); \ + if ((LockParameter)->Lock != EfiLockAcquired) { \ + _ASSERT (LockParameter not locked); \ + } \ + } \ + } while (FALSE) + + +/** + This function raises the system¡¯s current task priority level to the task + priority level of the mutual exclusion lock. Then, it places the lock in the + acquired state. + + @param Priority The task priority level of the lock. + +**/ +VOID +EFIAPI +GlueEfiAcquireLock ( + IN EFI_LOCK *Lock + ); + +/** + This function raises the system¡¯s current task priority level to the task + priority level of the mutual exclusion lock. Then, it attempts to place the + lock in the acquired state. + + @param Lock A pointer to the lock to acquire. + + @retval EFI_SUCCESS The lock was acquired. + @retval EFI_ACCESS_DENIED The lock could not be acquired because it is already owned. + +**/ +EFI_STATUS +EFIAPI +GlueEfiAcquireLockOrFail ( + IN EFI_LOCK *Lock + ); + +/** + This function transitions a mutual exclusion lock from the acquired state to + the released state, and restores the system¡¯s task priority level to its + previous level. + + @param Lock A pointer to the lock to release. + +**/ +VOID +EFIAPI +GlueEfiReleaseLock ( + IN EFI_LOCK *Lock + ); + +/** + This function looks up a Unicode string in UnicodeStringTable. If Language is + a member of SupportedLanguages and a Unicode string is found in UnicodeStringTable + that matches the language code specified by Language, then it is returned in + UnicodeString. + + @param Language A pointer to the ISO 639-2 language code for the + Unicode string to look up and return. + @param SupportedLanguages A pointer to the set of ISO 639-2 language codes + that the Unicode string table supports. Language + must be a member of this set. + @param UnicodeStringTable A pointer to the table of Unicode strings. + @param UnicodeString A pointer to the Unicode string from UnicodeStringTable + that matches the language specified by Language. + + @retval EFI_SUCCESS The Unicode string that matches the language + specified by Language was found + in the table of Unicoide strings UnicodeStringTable, + and it was returned in UnicodeString. + @retval EFI_INVALID_PARAMETER Language is NULL. + @retval EFI_INVALID_PARAMETER UnicodeString is NULL. + @retval EFI_UNSUPPORTED SupportedLanguages is NULL. + @retval EFI_UNSUPPORTED UnicodeStringTable is NULL. + @retval EFI_UNSUPPORTED The language specified by Language is not a + member of SupportedLanguages. + @retval EFI_UNSUPPORTED The language specified by Language is not + supported by UnicodeStringTable. + +**/ +EFI_STATUS +EFIAPI +LookupUnicodeString ( + IN CONST CHAR8 *Language, + IN CONST CHAR8 *SupportedLanguages, + IN CONST EFI_UNICODE_STRING_TABLE *UnicodeStringTable, + OUT CHAR16 **UnicodeString + ); + +/** + This function adds a Unicode string to UnicodeStringTable. + If Language is a member of SupportedLanguages then UnicodeString is added to + UnicodeStringTable. New buffers are allocated for both Language and + UnicodeString. The contents of Language and UnicodeString are copied into + these new buffers. These buffers are automatically freed when + FreeUnicodeStringTable() is called. + + @param Language A pointer to the ISO 639-2 language code for the Unicode + string to add. + @param SupportedLanguages A pointer to the set of ISO 639-2 language codes + that the Unicode string table supports. + Language must be a member of this set. + @param UnicodeStringTable A pointer to the table of Unicode strings. + @param UnicodeString A pointer to the Unicode string to add. + + @retval EFI_SUCCESS The Unicode string that matches the language + specified by Language was found in the table of + Unicode strings UnicodeStringTable, and it was + returned in UnicodeString. + @retval EFI_INVALID_PARAMETER Language is NULL. + @retval EFI_INVALID_PARAMETER UnicodeString is NULL. + @retval EFI_INVALID_PARAMETER UnicodeString is an empty string. + @retval EFI_UNSUPPORTED SupportedLanguages is NULL. + @retval EFI_ALREADY_STARTED A Unicode string with language Language is + already present in UnicodeStringTable. + @retval EFI_OUT_OF_RESOURCES There is not enough memory to add another + Unicode string to UnicodeStringTable. + @retval EFI_UNSUPPORTED The language specified by Language is not a + member of SupportedLanguages. + +**/ +EFI_STATUS +EFIAPI +AddUnicodeString ( + IN CONST CHAR8 *Language, + IN CONST CHAR8 *SupportedLanguages, + IN EFI_UNICODE_STRING_TABLE **UnicodeStringTable, + IN CONST CHAR16 *UnicodeString + ); + +/** + This function frees the table of Unicode strings in UnicodeStringTable. + If UnicodeStringTable is NULL, then EFI_SUCCESS is returned. + Otherwise, each language code, and each Unicode string in the Unicode string + table are freed, and EFI_SUCCESS is returned. + + @param UnicodeStringTable A pointer to the table of Unicode strings. + + @retval EFI_SUCCESS The Unicode string table was freed. + +**/ +EFI_STATUS +EFIAPI +FreeUnicodeStringTable ( + IN EFI_UNICODE_STRING_TABLE *UnicodeStringTable + ); + +/** + This function computes and returns the width of the Unicode character + specified by UnicodeChar. + + @param UnicodeChar A Unicode character. + + @retval 0 The width if UnicodeChar could not be determined. + @retval 1 UnicodeChar is a narrow glyph. + @retval 2 UnicodeChar is a wide glyph. + +**/ + +EFI_GUID * +GetGuidFromHandle ( + EFI_HANDLE Handle + ); +/*++ + +Routine Description: + + retrieves GUID name from Handle + +Arguments: + + Handle - Handle of image + +Returns: + + Pointer to GUID name + +--*/ + +UINTN +EFIAPI +GlueGetGlyphWidth ( + IN CHAR16 UnicodeChar + ); + +/** + This function computes and returns the display length of + the Null-terminated Unicode string specified by String. + If String is NULL, then 0 is returned. + If any of the widths of the Unicode characters in String + can not be determined, then 0 is returned. + + @param String A pointer to a Null-terminated Unicode string. + + @return The display length of the Null-terminated Unicode string specified by String. + +**/ +UINTN +EFIAPI +UnicodeStringDisplayLength ( + IN CONST CHAR16 *String + ); + +// +// Functions that abstract early Framework contamination of UEFI. +// +/** + Signal a Ready to Boot Event. + + Create a Ready to Boot Event. Signal it and close it. This causes other + events of the same event group to be signaled in other modules. + +**/ +VOID +EFIAPI +EfiSignalEventReadyToBoot ( + VOID + ); + +/** + Signal a Legacy Boot Event. + + Create a legacy Boot Event. Signal it and close it. This causes other + events of the same event group to be signaled in other modules. + +**/ +VOID +EFIAPI +EfiSignalEventLegacyBoot ( + VOID + ); + +/** + 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 EDK/EFI 1.10 form and EDK II/UEFI 2.0 form and allows common code to + work both ways. + + @param LegacyBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex). + + @retval EFI_SUCCESS Event was created. + @retval Other Event was not created. + +**/ +EFI_STATUS +EFIAPI +GlueEfiCreateEventLegacyBoot ( + OUT EFI_EVENT *LegacyBootEvent + ); + +/** + Create an EFI event in the Legacy Boot Event Group and allows + the caller to specify a notification function. + + This function abstracts the creation of the Legacy Boot Event. + The Framework moved from a proprietary to UEFI 2.0 based mechanism. + This library abstracts the caller from how this event is created to prevent + to code form having to change with the version of the specification supported. + If LegacyBootEvent is NULL, then ASSERT(). + + @param NotifyTpl The task priority level of the event. + @param NotifyFunction The notification function to call when the event is signaled. + @param NotifyContext The content to pass to NotifyFunction when the event is signaled. + @param LegacyBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex). + + @retval EFI_SUCCESS Event was created. + @retval Other Event was not created. + +**/ +EFI_STATUS +EFIAPI +EfiCreateEventLegacyBootEx ( + IN EFI_TPL NotifyTpl, + IN EFI_EVENT_NOTIFY NotifyFunction, OPTIONAL + IN VOID *NotifyContext, OPTIONAL + OUT EFI_EVENT *LegacyBootEvent + ); + +/** + 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 EDK/EFI 1.10 form and EDKII/UEFI 2.0 form and allows common code to + work both ways. + + @param LegacyBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex). + + @retval EFI_SUCCESS Event was created. + @retval Other Event was not created. + +**/ +EFI_STATUS +EFIAPI +GlueEfiCreateEventReadyToBoot ( + OUT EFI_EVENT *ReadyToBootEvent + ); + +/** + Create an EFI event in the Ready To Boot Event Group and allows + the caller to specify a notification function. + + This function abstracts the creation of the Ready to Boot Event. + The Framework moved from a proprietary to UEFI 2.0 based mechanism. + This library abstracts the caller from how this event is created to prevent + to code form having to change with the version of the specification supported. + If ReadyToBootEvent is NULL, then ASSERT(). + + @param NotifyTpl The task priority level of the event. + @param NotifyFunction The notification function to call when the event is signaled. + @param NotifyContext The content to pass to NotifyFunction when the event is signaled. + @param LegacyBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex). + + @retval EFI_SUCCESS Event was created. + @retval Other Event was not created. + +**/ +EFI_STATUS +EFIAPI +EfiCreateEventReadyToBootEx ( + IN EFI_TPL NotifyTpl, + IN EFI_EVENT_NOTIFY NotifyFunction, OPTIONAL + IN VOID *NotifyContext, OPTIONAL + OUT EFI_EVENT *ReadyToBootEvent + ); + +/** + Initialize a Firmware Volume (FV) Media Device Path node. + + Tiano extended the EFI 1.10 device path nodes. Tiano does not own this enum + so as we move to UEFI 2.0 support we must use a mechanism that conforms with + the UEFI 2.0 specification to define the FV device path. An UEFI GUIDed + device path is defined for Tiano extensions of device path. If the code + is compiled to conform with the UEFI 2.0 specification use the new device path + else use the old form for backwards compatability. + + @param FvDevicePathNode Pointer to a FV device path node to initialize + @param NameGuid FV file name to use in FvDevicePathNode + +**/ +VOID +EFIAPI +GlueEfiInitializeFwVolDevicepathNode ( + IN OUT MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvDevicePathNode, + IN CONST EFI_GUID *NameGuid + ); + +/** + Check to see if the Firmware Volume (FV) Media Device Path is valid + + Tiano extended the EFI 1.10 device path nodes. Tiano does not own this enum + so as we move to UEFI 2.0 support we must use a mechanism that conforms with + the UEFI 2.0 specification to define the FV device path. An UEFI GUIDed + device path is defined for Tiano extensions of device path. If the code + is compiled to conform with the UEFI 2.0 specification use the new device path + else use the old form for backwards compatability. The return value to this + function points to a location in FvDevicePathNode and it does not allocate + new memory for the GUID pointer that is returned. + + @param FvDevicePathNode Pointer to FV device path to check. + + @retval NULL FvDevicePathNode is not valid. + @retval Other FvDevicePathNode is valid and pointer to NameGuid was returned. + +**/ +EFI_GUID * +EFIAPI +GlueEfiGetNameGuidFromFwVolDevicePathNode ( + IN CONST MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvDevicePathNode + ); + + +#endif diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueUefiRuntimeServicesTableLib.h b/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueUefiRuntimeServicesTableLib.h new file mode 100644 index 0000000..6fb2ea3 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueUefiRuntimeServicesTableLib.h @@ -0,0 +1,31 @@ +/*++ + +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: + + EdkIIGlueUefiRuntimeServicesTableLib.h + +Abstract: + + Library that provides a global pointer to the UEFI Runtime Services Tables + +--*/ + +#ifndef __EDKII_GLUE_UEFI_RUNTIME_SERVICES_TABLE_LIB_H__ +#define __EDKII_GLUE_UEFI_RUNTIME_SERVICES_TABLE_LIB_H__ + +// +// Cached copy of the EFI Runtime Services Table +// +extern EFI_RUNTIME_SERVICES *gRT; + +#endif diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Include/Pcd/EdkIIGluePcd.h b/EDK/Foundation/Library/EdkIIGlueLib/Include/Pcd/EdkIIGluePcd.h new file mode 100644 index 0000000..238d37e --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Include/Pcd/EdkIIGluePcd.h @@ -0,0 +1,42 @@ +/*++ + +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: + + EdkIIGluePcd.h + +Abstract: + + Fixed-at-build PCD macro expansion definitions + +--*/ + +#ifndef __EDKII_GLUE_PCD_H__ +#define __EDKII_GLUE_PCD_H__ + +// +// Redefine Pcd functions into compile time hardcoded values +// +#define FixedPcdGet8(TokenName) __EDKII_GLUE_PCD_##TokenName##__ +#define FixedPcdGet16(TokenName) __EDKII_GLUE_PCD_##TokenName##__ +#define FixedPcdGet32(TokenName) __EDKII_GLUE_PCD_##TokenName##__ +#define FixedPcdGet64(TokenName) __EDKII_GLUE_PCD_##TokenName##__ +#define FixedPcdGetBool(TokenName) __EDKII_GLUE_PCD_##TokenName##__ + +#define PcdGet8(TokenName) __EDKII_GLUE_PCD_##TokenName##__ +#define PcdGet16(TokenName) __EDKII_GLUE_PCD_##TokenName##__ +#define PcdGet32(TokenName) __EDKII_GLUE_PCD_##TokenName##__ +#define PcdGet64(TokenName) __EDKII_GLUE_PCD_##TokenName##__ +#define PcdGetPtr(TokenName) __EDKII_GLUE_PCD_##TokenName##__ +#define PcdGetBool(TokenName) __EDKII_GLUE_PCD_##TokenName##__ + +#endif diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Include/Pcd/EdkIIGluePcdBaseLib.h b/EDK/Foundation/Library/EdkIIGlueLib/Include/Pcd/EdkIIGluePcdBaseLib.h new file mode 100644 index 0000000..3047ae2 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Include/Pcd/EdkIIGluePcdBaseLib.h @@ -0,0 +1,52 @@ +/*++ + +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: + + EdkIIGluePcdBaseLib.h + +Abstract: + + PCD vadues for library customization + +--*/ + +#ifndef __EDKII_GLUE_PCD_BASE_LIB_H__ +#define __EDKII_GLUE_PCD_BASE_LIB_H__ + +// +// Following Pcd values are hard coded at compile time. +// Override these through compiler option "/D" in PlatformTools.env if needed +// + +#ifndef __EDKII_GLUE_PCD_PcdMaximumUnicodeStringLength__ +#define __EDKII_GLUE_PCD_PcdMaximumUnicodeStringLength__ EDKII_GLUE_MaximumUnicodeStringLength +#endif + +#ifndef __EDKII_GLUE_PCD_PcdMaximumAsciiStringLength__ +#define __EDKII_GLUE_PCD_PcdMaximumAsciiStringLength__ EDKII_GLUE_MaximumAsciiStringLength +#endif + +// +// SpinLock Pcds +// +#ifndef __EDKII_GLUE_PCD_PcdSpinLockTimeout__ +#define __EDKII_GLUE_PCD_PcdSpinLockTimeout__ EDKII_GLUE_SpinLockTimeout +#endif + +// Linked List +#ifndef __EDKII_GLUE_PCD_PcdMaximumLinkedListLength__ +#define __EDKII_GLUE_PCD_PcdMaximumLinkedListLength__ EDKII_GLUE_MaximumLinkedListLength +#endif + +#include "Pcd/EdkIIGluePcd.h" +#endif diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Include/Pcd/EdkIIGluePcdDebugLib.h b/EDK/Foundation/Library/EdkIIGlueLib/Include/Pcd/EdkIIGluePcdDebugLib.h new file mode 100644 index 0000000..44431c4 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Include/Pcd/EdkIIGluePcdDebugLib.h @@ -0,0 +1,50 @@ +/*++ + +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: + + EdkIIGluePcdDebugLib.h + +Abstract: + + PCD values for library customization + +--*/ + +#ifndef __EDKII_GLUE_PCD_DEBUG_LIB_H__ +#define __EDKII_GLUE_PCD_DEBUG_LIB_H__ + +// +// Following Pcd values are hard coded at compile time. +// Override these through compiler option "/D" in PlatformTools.env if needed +// + + +// +// Debug Pcds +// +#ifndef __EDKII_GLUE_PCD_PcdDebugPrintErrorLevel__ +#define __EDKII_GLUE_PCD_PcdDebugPrintErrorLevel__ EdkIIGlueGetDebugPrintErrorLevel() +#endif + + +#ifndef __EDKII_GLUE_PCD_PcdDebugPropertyMask__ +#define __EDKII_GLUE_PCD_PcdDebugPropertyMask__ EDKII_GLUE_DebugPropertyMask +#endif + + +#ifndef __EDKII_GLUE_PCD_PcdDebugClearMemoryValue__ +#define __EDKII_GLUE_PCD_PcdDebugClearMemoryValue__ EDKII_GLUE_DebugClearMemoryValue +#endif + +#include "Pcd/EdkIIGluePcd.h" +#endif diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Include/Pcd/EdkIIGluePcdIoLib.h b/EDK/Foundation/Library/EdkIIGlueLib/Include/Pcd/EdkIIGluePcdIoLib.h new file mode 100644 index 0000000..320073d --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Include/Pcd/EdkIIGluePcdIoLib.h @@ -0,0 +1,42 @@ +/*++ + +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: + + EdkIIGluePcdIoLib.h + +Abstract: + + PCD values for library customization + +--*/ + +#ifndef __EDKII_GLUE_PCD_IO_LIB_H__ +#define __EDKII_GLUE_PCD_IO_LIB_H__ + +// +// Following Pcd values are hard coded at compile time. +// Override these through compiler option "/D" in PlatformTools.env if needed +// + + +// +// IoBlockBaseAddressForIpf Pcd +// +#ifdef MDE_CPU_IPF +#ifndef __EDKII_GLUE_PCD_PcdIoBlockBaseAddressForIpf__ +#define __EDKII_GLUE_PCD_PcdIoBlockBaseAddressForIpf__ EDKII_GLUE_IoBlockBaseAddressForIpf +#endif +#endif + +#include "Pcd/EdkIIGluePcd.h" +#endif diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Include/Pcd/EdkIIGluePcdPciExpressLib.h b/EDK/Foundation/Library/EdkIIGlueLib/Include/Pcd/EdkIIGluePcdPciExpressLib.h new file mode 100644 index 0000000..3d7392d --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Include/Pcd/EdkIIGluePcdPciExpressLib.h @@ -0,0 +1,40 @@ +/*++ + +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: + + EdkIIGluePcdPciExpressLib.h + +Abstract: + + PCD values for library customization + +--*/ + +#ifndef __EDKII_GLUE_PCD_PCI_EXPRESS_LIB_H__ +#define __EDKII_GLUE_PCD_PCI_EXPRESS_LIB_H__ + +// +// Following Pcd values are hard coded at compile time. +// Override these through compiler option "/D" in PlatformTools.env if needed +// + + +// +// PciExpress Pcds +// +#ifndef __EDKII_GLUE_PCD_PcdPciExpressBaseAddress__ +#define __EDKII_GLUE_PCD_PcdPciExpressBaseAddress__ EDKII_GLUE_PciExpressBaseAddress +#endif + +#include "Pcd/EdkIIGluePcd.h" +#endif diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Include/Pcd/EdkIIGluePcdPerformanceLib.h b/EDK/Foundation/Library/EdkIIGlueLib/Include/Pcd/EdkIIGluePcdPerformanceLib.h new file mode 100644 index 0000000..d2599ea --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Include/Pcd/EdkIIGluePcdPerformanceLib.h @@ -0,0 +1,47 @@ +/*++ + +Copyright (c) 2011, 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: + + EdkIIGluePcdPerformanceLib.h + +Abstract: + + PCD values for library customization + +--*/ + +#ifndef __EDKII_GLUE_PCD_PERFORMANCE_LIB_H__ +#define __EDKII_GLUE_PCD_PERFORMANCE_LIB_H__ + +// +// Following Pcd values are hard coded at compile time. +// Override these through compiler option "/D" in PlatformTools.env if needed +// + +// +// Performance Lib Pcds +// +#ifndef __EDKII_GLUE_PCD_PlatformInfoMsr__ +#define __EDKII_GLUE_PCD_PlatformInfoMsr__ EDKII_GLUE_PlatformInfoMsr +#endif + +#ifndef __EDKII_GLUE_PCD_XAPICBaseMsr__ +#define __EDKII_GLUE_PCD_XAPICBaseMsr__ EDKII_GLUE_XAPICBaseMsr +#endif + +#ifndef __EDKII_GLUE_PCD_ExtXAPICLogicalAPICIdMsr__ +#define __EDKII_GLUE_PCD_ExtXAPICLogicalAPICIdMsr__ EDKII_GLUE_ExtXAPICLogicalAPICIdMsr +#endif + +#include "Pcd/EdkIIGluePcd.h" +#endif diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Include/Pcd/EdkIIGluePcdPostCodeLib.h b/EDK/Foundation/Library/EdkIIGlueLib/Include/Pcd/EdkIIGluePcdPostCodeLib.h new file mode 100644 index 0000000..6314f3d --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Include/Pcd/EdkIIGluePcdPostCodeLib.h @@ -0,0 +1,40 @@ +/*++ + +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: + + EdkIIGluePcdPostCodeLib.h + +Abstract: + + PCD values for library customization + +--*/ + +#ifndef __EDKII_GLUE_PCD_POST_CODE_LIB_H__ +#define __EDKII_GLUE_PCD_POST_CODE_LIB_H__ + +// +// Following Pcd values are hard coded at compile time. +// Override these through compiler option "/D" in PlatformTools.env if needed +// + +// +// PostCode Pcds +// +#ifndef __EDKII_GLUE_PCD_PcdPostCodePropertyMask__ +#define __EDKII_GLUE_PCD_PcdPostCodePropertyMask__ EDKII_GLUE_PostCodePropertyMask +#endif + +#include "Pcd/EdkIIGluePcd.h" + +#endif diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Include/Pcd/EdkIIGluePcdReportStatusCodeLib.h b/EDK/Foundation/Library/EdkIIGlueLib/Include/Pcd/EdkIIGluePcdReportStatusCodeLib.h new file mode 100644 index 0000000..25481a4 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Include/Pcd/EdkIIGluePcdReportStatusCodeLib.h @@ -0,0 +1,40 @@ +/*++ + +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: + + EdkIIGluePcdReportStatusCodeLib.h + +Abstract: + + Pcd values for library customization + +--*/ + +#ifndef __EDKII_GLUE_PCD_REPORT_STATUS_CODE_LIB_H__ +#define __EDKII_GLUE_PCD_REPORT_STATUS_CODE_LIB_H__ + +// +// Following Pcd values are hard coded at compile time. +// Override these through compiler option "/D" in PlatformTools.env if needed +// + +// +// ReportStatusCode Pcds +// +#ifndef __EDKII_GLUE_PCD_PcdReportStatusCodePropertyMask__ +#define __EDKII_GLUE_PCD_PcdReportStatusCodePropertyMask__ EDKII_GLUE_ReportStatusCodePropertyMask +#endif + +#include "Pcd/EdkIIGluePcd.h" + +#endif diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Include/Pcd/EdkIIGluePcdTimerLib.h b/EDK/Foundation/Library/EdkIIGlueLib/Include/Pcd/EdkIIGluePcdTimerLib.h new file mode 100644 index 0000000..2cc6ac3 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Include/Pcd/EdkIIGluePcdTimerLib.h @@ -0,0 +1,40 @@ +/*++ + +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: + + EdkIIGluePcdTimerLib.h + +Abstract: + + PCD values for library customization + +--*/ + +#ifndef __EDKII_GLUE_PCD_TIMER_LIB_H__ +#define __EDKII_GLUE_PCD_TIMER_LIB_H__ + +// +// Following Pcd values are hard coded at compile time. +// Override these through compiler option "/D" in PlatformTools.env if needed +// + + +// +// Timer Lib Pcds +// +#ifndef __EDKII_GLUE_PCD_PcdFSBClock__ +#define __EDKII_GLUE_PCD_PcdFSBClock__ EDKII_GLUE_FSBClock +#endif + +#include "Pcd/EdkIIGluePcd.h" +#endif diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Include/PeimDepex.h b/EDK/Foundation/Library/EdkIIGlueLib/Include/PeimDepex.h new file mode 100644 index 0000000..f27d5ec --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Include/PeimDepex.h @@ -0,0 +1,34 @@ +/*++ + +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: + + PeimDepex.h + +Abstract: + + This file is used by .dxs file. To write common .dxs for R8.x and R9, a + header file named PeimDepex.h musted be present. + +--*/ + + +#ifndef __EDKII_GLUELIB_PEIMDEPEX_H__ +#define __EDKII_GLUELIB_PEIMDEPEX_H__ + + +// +// this file is used by .dxs file, just a place holder +// + + +#endif diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Include/x64/EdkIIGlueProcessorBind.h b/EDK/Foundation/Library/EdkIIGlueLib/Include/x64/EdkIIGlueProcessorBind.h new file mode 100644 index 0000000..4363dda --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Include/x64/EdkIIGlueProcessorBind.h @@ -0,0 +1,41 @@ +/*++ + +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: + + EdkIIGlueProcessorBind.h + +Abstract: + + Processor specific definitions + +--*/ + +#ifndef __EDKII_GLUE_PROCESSOR_BIND_H__ +#define __EDKII_GLUE_PROCESSOR_BIND_H__ + +// +// The Microsoft* C compiler can removed references to unreferenced data items +// if the /OPT:REF linker option is used. We defined a macro as this is a +// a non standard extension +// +#if _MSC_EXTENSIONS + #define GLOBAL_REMOVE_IF_UNREFERENCED __declspec(selectany) +#else + #define GLOBAL_REMOVE_IF_UNREFERENCED +#endif + +#ifndef MDE_CPU_X64 + #define MDE_CPU_X64 +#endif + +#endif diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseCacheMaintenanceLib/BaseCacheMaintenanceLib.inf b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseCacheMaintenanceLib/BaseCacheMaintenanceLib.inf new file mode 100644 index 0000000..15c2656 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseCacheMaintenanceLib/BaseCacheMaintenanceLib.inf @@ -0,0 +1,76 @@ +#/*++ +# +# 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: +# +# BaseCacheMaintenanceLib.inf +# +# Abstract: +# +# Component description file for BaseCacheMaintenanceLib. +# +#--*/ + +[defines] +BASE_NAME = EdkIIGlueBaseCacheMaintenanceLib +COMPONENT_TYPE = LIBRARY + +[sources.common] + +[sources.ia32] + x86Cache.c + +[sources.x64] + x86Cache.c + +[sources.ipf] + +[sources.ebc] + +[includes.common] + . + ..\..\Include + ..\..\Include\Library + $(EDK_SOURCE)\Foundation + $(EDK_SOURCE)\Foundation\Framework + $(EDK_SOURCE)\Foundation\Efi + $(EDK_SOURCE)\Foundation\Include + $(EDK_SOURCE)\Foundation\Efi\Include + $(EDK_SOURCE)\Foundation\Framework\Include + $(EDK_SOURCE)\Foundation\Include\IndustryStandard + $(EDK_SOURCE)\Foundation\Core\Dxe + $(EDK_SOURCE)\Foundation\Library\Dxe\Include + $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include + +[libraries.common] + EdkIIGlueBaseLib + +[libraries.ia32] + + +[libraries.x64] + + +[nmake.common] + C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION + LIB_STD_FLAGS = /NOLOGO /IGNORE:4006 + +[nmake.ia32] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32 + +[nmake.x64] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64 + +[nmake.ipf] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF + +[nmake.ebc] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_EBC
\ No newline at end of file diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseCacheMaintenanceLib/EdkIIGlueBaseCacheMaintenanceLib.cif b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseCacheMaintenanceLib/EdkIIGlueBaseCacheMaintenanceLib.cif new file mode 100644 index 0000000..44016b9 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseCacheMaintenanceLib/EdkIIGlueBaseCacheMaintenanceLib.cif @@ -0,0 +1,11 @@ +<component> + name = "EdkIIGlueBaseCacheMaintenanceLib" + category = ModulePart + LocalRoot = "Edk\Foundation\Library\EdkIIGlueLib\Library\BaseCacheMaintenanceLib" + RefName = "EdkIIGlueBaseCacheMaintenanceLib" +[files] +"EdkIIGlueBaseCacheMaintenanceLib.sdl" +"EdkIIGlueBaseCacheMaintenanceLib.mak" +"BaseCacheMaintenanceLib.inf" +"x86Cache.c" +<endComponent>
\ No newline at end of file diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseCacheMaintenanceLib/EdkIIGlueBaseCacheMaintenanceLib.mak b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseCacheMaintenanceLib/EdkIIGlueBaseCacheMaintenanceLib.mak new file mode 100644 index 0000000..99b73ce --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseCacheMaintenanceLib/EdkIIGlueBaseCacheMaintenanceLib.mak @@ -0,0 +1,90 @@ +#********************************************************************** +#********************************************************************** +#** ** +#** (C)Copyright 1985-2009, American Megatrends, Inc. ** +#** ** +#** All Rights Reserved. ** +#** ** +#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +#** ** +#** Phone: (770)-246-8600 ** +#** ** +#********************************************************************** +#********************************************************************** + +#********************************************************************** +# $Header: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGlueBaseCacheMaintenanceLib/EdkIIGlueBaseCacheMaintenanceLib.mak 1 1/20/12 3:48a Jeffch $ +# +# $Revision: 1 $ +# +# $Date: 1/20/12 3:48a $ +#********************************************************************** +# Revision History +# ---------------- +# $Log: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGlueBaseCacheMaintenanceLib/EdkIIGlueBaseCacheMaintenanceLib.mak $ +# +# 1 1/20/12 3:48a Jeffch +# Create Intel EDK 1117 Patch 7. +# +# 1 1/20/12 3:27a Jeffch +# Create Intel EDK 1117 Patch 7. +# +# 1 9/27/11 6:09a Wesleychen +# Intel EDK initially releases. +# +# 1 9/18/09 1:49a Iminglin +# +#********************************************************************** +#<AMI_FHDR_START> +# +# Name: EdkIIGlueBaseCacheMaintenanceLib.mak +# +# Description: +# +#<AMI_FHDR_END> +#********************************************************************** + +!IF "$(PROCESSOR)"=="IA32" || "$(PROCESSOR)"=="x64" +EdkIIGlueBaseCacheMaintenanceLib_OBJECTS=\ +$$(BUILD_DIR)\$(EdkIIGlueBaseCacheMaintenanceLib_DIR)\x86Cache.obj +!ENDIF + +$(EdkIIGlueBaseCacheMaintenanceLib_LIB) : EdkIIGlueBaseCacheMaintenanceLib + +EdkIIGlueBaseCacheMaintenanceLib : $(BUILD_DIR)\EdkIIGlueBaseCacheMaintenanceLib.mak EdkIIGlueBaseCacheMaintenanceLibBin + +$(BUILD_DIR)\EdkIIGlueBaseCacheMaintenanceLib.mak : $(EdkIIGlueBaseCacheMaintenanceLib_DIR)\$(@B).cif $(EdkIIGlueBaseCacheMaintenanceLib_DIR)\$(@B).mak $(BUILD_RULES) + $(CIF2MAK) $(EdkIIGlueBaseCacheMaintenanceLib_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS) + +EdkIIGlueBaseCacheMaintenanceLibBin : $(EdkIIGlueBaseLib_LIB) +!IF "$(x64_BUILD)"=="1" + $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\ + BUILD_DIR=$(BUILD_DIR)\ + /f $(BUILD_DIR)\EdkIIGlueBaseCacheMaintenanceLib.mak all\ + TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueBaseCacheMaintenanceLib_LIB)"\ + "OBJECTS=$(EdkIIGlueBaseCacheMaintenanceLib_OBJECTS)" + $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\ + BUILD_DIR=$(BUILD_DIR)\IA32\ + /f $(BUILD_DIR)\EdkIIGlueBaseCacheMaintenanceLib.mak all\ + TYPE=PEI_LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueBaseCacheMaintenanceLib_LIB)"\ + "OBJECTS=$(EdkIIGlueBaseCacheMaintenanceLib_OBJECTS)" +!ELSE + $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\ + BUILD_DIR=$(BUILD_DIR)\ + /f $(BUILD_DIR)\EdkIIGlueBaseCacheMaintenanceLib.mak all\ + TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueBaseCacheMaintenanceLib_LIB)"\ + "OBJECTS=$(EdkIIGlueBaseCacheMaintenanceLib_OBJECTS)" +!ENDIF +#********************************************************************** +#********************************************************************** +#** ** +#** (C)Copyright 1985-2009, American Megatrends, Inc. ** +#** ** +#** All Rights Reserved. ** +#** ** +#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +#** ** +#** Phone: (770)-246-8600 ** +#** ** +#********************************************************************** +#********************************************************************** diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseCacheMaintenanceLib/EdkIIGlueBaseCacheMaintenanceLib.sdl b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseCacheMaintenanceLib/EdkIIGlueBaseCacheMaintenanceLib.sdl new file mode 100644 index 0000000..3d51d7c --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseCacheMaintenanceLib/EdkIIGlueBaseCacheMaintenanceLib.sdl @@ -0,0 +1,26 @@ +TOKEN + Name = "EdkIIGlueBaseCacheMaintenanceLib_SUPPORT" + Value = "1" + Help = "Main switch to enable EdkIIGlueBaseCacheMaintenanceLib support in Project" + TokenType = Boolean + TargetEQU = Yes + TargetMAK = Yes + Master = Yes +End + +TOKEN + Name = "EdkIIGlueBaseCacheMaintenanceLib_LIB" + Value = "$$(LIB_BUILD_DIR)\EdkIIGlueBaseCacheMaintenanceLib.lib" + TokenType = Expression + TargetMAK = Yes +End + +PATH + Name = "EdkIIGlueBaseCacheMaintenanceLib_DIR" +End + +MODULE + Help = "Includes EdkIIGlueBaseCacheMaintenanceLib.mak to Project" + File = "EdkIIGlueBaseCacheMaintenanceLib.mak" +End + diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseCacheMaintenanceLib/x86Cache.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseCacheMaintenanceLib/x86Cache.c new file mode 100644 index 0000000..9abbf39 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseCacheMaintenanceLib/x86Cache.c @@ -0,0 +1,254 @@ +/*++ + +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: + + x86Cache.c + +Abstract: + + Cache Maintenance Functions. + +--*/ + +#include "EdkIIGlueBase.h" + +/** + Invalidates the entire instruction cache in cache coherency domain of the + calling CPU. + + Invalidates the entire instruction cache in cache coherency domain of the + calling CPU. + +**/ +VOID +EFIAPI +GlueInvalidateInstructionCache ( + VOID + ) +{ +} + +/** + Invalidates a range of instruction cache lines in the cache coherency domain + of the calling CPU. + + Invalidates the instruction cache lines specified by Address and Length. If + Address is not aligned on a cache line boundary, then entire instruction + cache line containing Address is invalidated. If Address + Length is not + aligned on a cache line boundary, then the entire instruction cache line + containing Address + Length -1 is invalidated. This function may choose to + invalidate the entire instruction cache if that is more efficient than + invalidating the specified range. If Length is 0, the no instruction cache + lines are invalidated. Address is returned. + + If Length is greater than (MAX_ADDRESS - Address + 1), then ASSERT(). + + @param Address The base address of the instruction cache lines to + invalidate. If the CPU is in a physical addressing mode, then + Address is a physical address. If the CPU is in a virtual + addressing mode, then Address is a virtual address. + + @param Length The number of bytes to invalidate from the instruction cache. + + @return Address + +**/ +VOID * +EFIAPI +InvalidateInstructionCacheRange ( + IN VOID *Address, + IN UINTN Length + ) +{ + ASSERT (Length <= MAX_ADDRESS - (UINTN)Address + 1); + return Address; +} + +/** + Writes Back and Invalidates the entire data cache in cache coherency domain + of the calling CPU. + + Writes Back and Invalidates the entire data cache in cache coherency domain + of the calling CPU. This function guarantees that all dirty cache lines are + written back to system memory, and also invalidates all the data cache lines + in the cache coherency domain of the calling CPU. + +**/ +VOID +EFIAPI +WriteBackInvalidateDataCache ( + VOID + ) +{ + AsmWbinvd (); +} + +/** + Writes Back and Invalidates a range of data cache lines in the cache + coherency domain of the calling CPU. + + Writes Back and Invalidate the data cache lines specified by Address and + Length. If Address is not aligned on a cache line boundary, then entire data + cache line containing Address is written back and invalidated. If Address + + Length is not aligned on a cache line boundary, then the entire data cache + line containing Address + Length -1 is written back and invalidated. This + function may choose to write back and invalidate the entire data cache if + that is more efficient than writing back and invalidating the specified + range. If Length is 0, the no data cache lines are written back and + invalidated. Address is returned. + + If Length is greater than (MAX_ADDRESS - Address + 1), then ASSERT(). + + @param Address The base address of the data cache lines to write back and + invalidate. If the CPU is in a physical addressing mode, then + Address is a physical address. If the CPU is in a virtual + addressing mode, then Address is a virtual address. + @param Length The number of bytes to write back and invalidate from the + data cache. + + @return Address + +**/ +VOID * +EFIAPI +WriteBackInvalidateDataCacheRange ( + IN VOID *Address, + IN UINTN Length + ) +{ + UINT8 (*Uint8Ptr)[32]; + + ASSERT (Length <= MAX_ADDRESS - (UINTN)Address + 1); + + Uint8Ptr = Address; + while (Length > sizeof (*Uint8Ptr)) { + AsmFlushCacheLine (Uint8Ptr++); + Length -= sizeof (*Uint8Ptr); + } + if (Length > 0) { + AsmFlushCacheLine (Uint8Ptr); + AsmFlushCacheLine (&(*Uint8Ptr)[Length - 1]); + } + return Address; +} + +/** + Writes Back the entire data cache in cache coherency domain of the calling + CPU. + + Writes Back the entire data cache in cache coherency domain of the calling + CPU. This function guarantees that all dirty cache lines are written back to + system memory. This function may also invalidate all the data cache lines in + the cache coherency domain of the calling CPU. + +**/ +VOID +EFIAPI +WriteBackDataCache ( + VOID + ) +{ + WriteBackInvalidateDataCache (); +} + +/** + Writes Back a range of data cache lines in the cache coherency domain of the + calling CPU. + + Writes Back the data cache lines specified by Address and Length. If Address + is not aligned on a cache line boundary, then entire data cache line + containing Address is written back. If Address + Length is not aligned on a + cache line boundary, then the entire data cache line containing Address + + Length -1 is written back. This function may choose to write back the entire + data cache if that is more efficient than writing back the specified range. + If Length is 0, the no data cache lines are written back. This function may + also invalidate all the data cache lines in the specified range of the cache + coherency domain of the calling CPU. Address is returned. + + If Length is greater than (MAX_ADDRESS - Address + 1), then ASSERT(). + + @param Address The base address of the data cache lines to write back. If + the CPU is in a physical addressing mode, then Address is a + physical address. If the CPU is in a virtual addressing + mode, then Address is a virtual address. + @param Length The number of bytes to write back from the data cache. + + @return Address + +**/ +VOID * +EFIAPI +WriteBackDataCacheRange ( + IN VOID *Address, + IN UINTN Length + ) +{ + return WriteBackInvalidateDataCacheRange (Address, Length); +} + +/** + Invalidates the entire data cache in cache coherency domain of the calling + CPU. + + Invalidates the entire data cache in cache coherency domain of the calling + CPU. This function must be used with care because dirty cache lines are not + written back to system memory. It is typically used for cache diagnostics. If + the CPU does not support invalidation of the entire data cache, then a write + back and invalidate operation should be performed on the entire data cache. + +**/ +VOID +EFIAPI +InvalidateDataCache ( + VOID + ) +{ + AsmInvd (); +} + +/** + Invalidates a range of data cache lines in the cache coherency domain of the + calling CPU. + + Invalidates the data cache lines specified by Address and Length. If Address + is not aligned on a cache line boundary, then entire data cache line + containing Address is invalidated. If Address + Length is not aligned on a + cache line boundary, then the entire data cache line containing Address + + Length -1 is invalidated. This function must never invalidate any cache lines + outside the specified range. If Length is 0, the no data cache lines are + invalidated. Address is returned. This function must be used with care + because dirty cache lines are not written back to system memory. It is + typically used for cache diagnostics. If the CPU does not support + invalidation of a data cache range, then a write back and invalidate + operation should be performed on the data cache range. + + If Length is greater than (MAX_ADDRESS - Address + 1), then ASSERT(). + + @param Address The base address of the data cache lines to invalidate. If + the CPU is in a physical addressing mode, then Address is a + physical address. If the CPU is in a virtual addressing mode, + then Address is a virtual address. + @param Length The number of bytes to invalidate from the data cache. + + @return Address + +**/ +VOID * +EFIAPI +InvalidateDataCacheRange ( + IN VOID *Address, + IN UINTN Length + ) +{ + return WriteBackInvalidateDataCacheRange (Address, Length); +} diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseDebugLibNull/BaseDebugLibNull.inf b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseDebugLibNull/BaseDebugLibNull.inf new file mode 100644 index 0000000..1733099 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseDebugLibNull/BaseDebugLibNull.inf @@ -0,0 +1,77 @@ +#/*++ +# +# 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: +# +# BaseDebugLibNull.inf +# +# Abstract: +# +# Component description file for BaseDebugLibNull. +# +#--*/ + +[defines] +BASE_NAME = EdkIIGlueBaseDebugLibNull +COMPONENT_TYPE = LIBRARY + +[sources.common] + DebugLib.c + +[sources.ia32] + +[sources.x64] + +[sources.ipf] + +[sources.ebc] + +[includes.common] + . + ..\..\Include + ..\..\Include\Library + $(EDK_SOURCE)\Foundation + $(EDK_SOURCE)\Foundation\Framework + $(EDK_SOURCE)\Foundation\Efi + $(EDK_SOURCE)\Foundation\Include + $(EDK_SOURCE)\Foundation\Efi\Include + $(EDK_SOURCE)\Foundation\Framework\Include + $(EDK_SOURCE)\Foundation\Include\IndustryStandard + $(EDK_SOURCE)\Foundation\Core\Dxe + $(EDK_SOURCE)\Foundation\Library\Dxe\Include + $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include + +[libraries.common] + EdkIIGlueBaseLib + EdkIIGlueBaseMemoryLib + EdkIIGlueBasePrintLib + +[libraries.ia32] + + +[libraries.x64] + + +[nmake.common] + C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION + LIB_STD_FLAGS = /NOLOGO /IGNORE:4006 + +[nmake.ia32] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32 + +[nmake.x64] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64 + +[nmake.ipf] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF + +[nmake.ebc] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_EBC
\ No newline at end of file diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseDebugLibNull/DebugLib.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseDebugLibNull/DebugLib.c new file mode 100644 index 0000000..c2865e2 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseDebugLibNull/DebugLib.c @@ -0,0 +1,236 @@ +/*++ + +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: + + DebugLib.c + +Abstract: + + Base Debug Library that uses PrintLib to print messages to a memory buffer. + +--*/ + +#include "EdkIIGlueBase.h" +#include "Pcd\EdkIIGluePcdDebugLib.h" + +// +// Define the maximum debug and assert message length that this library supports +// +#define MAX_DEBUG_MESSAGE_LENGTH 0x100 + +/** + + Prints a debug message to the debug output device if the specified error level is enabled. + + If any bit in ErrorLevel is also set in PcdDebugPrintErrorLevel, then print + the message specified by Format and the associated variable argument list to + the debug output device. + + If Format is NULL, then ASSERT(). + + @param ErrorLevel The error level of the debug message. + @param Format Format string for the debug message to print. + +**/ +VOID +EFIAPI +DebugPrint ( + IN UINTN ErrorLevel, + IN CONST CHAR8 *Format, + ... + ) +{ + CHAR8 Buffer[MAX_DEBUG_MESSAGE_LENGTH]; + VA_LIST Marker; + + // + // If Format is NULL, then ASSERT(). + // + ASSERT (Format != NULL); + + // + // Print the assert message to a buffer + // + VA_START (Marker, Format); + AsciiVSPrint (Buffer, sizeof (Buffer), Format, Marker); + VA_END (Marker); +} + + +/** + + Prints an assert message containing a filename, line number, and description. + This may be followed by a breakpoint or a dead loop. + + Print a message of the form "ASSERT <FileName>(<LineNumber>): <Description>\n" + to the debug output device. If DEBUG_PROPERTY_ASSERT_BREAKPOINT_ENABLED bit of + PcdDebugProperyMask is set then CpuBreakpoint() is called. Otherwise, if + DEBUG_PROPERTY_ASSERT_DEADLOOP_ENABLED bit of PcdDebugProperyMask is set then + CpuDeadLoop() is called. If neither of these bits are set, then this function + returns immediately after the message is printed to the debug output device. + DebugAssert() must actively prevent recusrsion. If DebugAssert() is called while + processing another DebugAssert(), then DebugAssert() must return immediately. + + If FileName is NULL, then a <FileName> string of "(NULL) Filename" is printed. + + If Description is NULL, then a <Description> string of "(NULL) Description" is printed. + + @param FileName Pointer to the name of the source file that generated the assert condition. + @param LineNumber The line number in the source file that generated the assert condition + @param Description Pointer to the description of the assert condition. + +**/ +VOID +EFIAPI +DebugAssert ( + IN CONST CHAR8 *FileName, + IN UINTN LineNumber, + IN CONST CHAR8 *Description + ) +{ + CHAR8 Buffer[MAX_DEBUG_MESSAGE_LENGTH]; + + // + // Print the assert message to a buffer + // + AsciiSPrint (Buffer, sizeof (Buffer), "ASSERT %s(%d): %s\n", FileName, LineNumber, Description); + + // + // Generate a Breakpoint, DeadLoop, or NOP based on PCD settings + // + if ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_ASSERT_BREAKPOINT_ENABLED) != 0) { + CpuBreakpoint (); + } else if ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_ASSERT_DEADLOOP_ENABLED) != 0) { + CpuDeadLoop (); + } +} + + +/** + + Fills a target buffer with PcdDebugClearMemoryValue, and returns the target buffer. + + This function fills Length bytes of Buffer with the value specified by + PcdDebugClearMemoryValue, and returns Buffer. + + If Buffer is NULL, then ASSERT(). + + If Length is greater than (MAX_ADDRESS ?Buffer + 1), then ASSERT(). + + @param Buffer Pointer to the target buffer to fill with PcdDebugClearMemoryValue. + @param Length Number of bytes in Buffer to fill with zeros PcdDebugClearMemoryValue. + + @return Buffer + +**/ +VOID * +EFIAPI +DebugClearMemory ( + OUT VOID *Buffer, + IN UINTN Length + ) +{ + // + // If Buffer is NULL, then ASSERT(). + // + ASSERT (Buffer != NULL); + + // + // SetMem() checks for the the ASSERT() condition on Length and returns Buffer + // + return SetMem (Buffer, Length, PcdGet8(PcdDebugClearMemoryValue)); +} + + +/** + + Returns TRUE if ASSERT() macros are enabled. + + This function returns TRUE if the DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED bit of + PcdDebugProperyMask is set. Otherwise FALSE is returned. + + @retval TRUE The DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED bit of PcdDebugProperyMask is set. + @retval FALSE The DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED bit of PcdDebugProperyMask is clear. + +**/ +BOOLEAN +EFIAPI +DebugAssertEnabled ( + VOID + ) +{ + return ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED) != 0); +} + + +/** + + Returns TRUE if DEBUG()macros are enabled. + + This function returns TRUE if the DEBUG_PROPERTY_DEBUG_PRINT_ENABLED bit of + PcdDebugProperyMask is set. Otherwise FALSE is returned. + + @retval TRUE The DEBUG_PROPERTY_DEBUG_PRINT_ENABLED bit of PcdDebugProperyMask is set. + @retval FALSE The DEBUG_PROPERTY_DEBUG_PRINT_ENABLED bit of PcdDebugProperyMask is clear. + +**/ +BOOLEAN +EFIAPI +DebugPrintEnabled ( + VOID + ) +{ + return ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_DEBUG_PRINT_ENABLED) != 0); +} + + +/** + + Returns TRUE if DEBUG_CODE()macros are enabled. + + This function returns TRUE if the DEBUG_PROPERTY_DEBUG_CODE_ENABLED bit of + PcdDebugProperyMask is set. Otherwise FALSE is returned. + + @retval TRUE The DEBUG_PROPERTY_DEBUG_CODE_ENABLED bit of PcdDebugProperyMask is set. + @retval FALSE The DEBUG_PROPERTY_DEBUG_CODE_ENABLED bit of PcdDebugProperyMask is clear. + +**/ +BOOLEAN +EFIAPI +DebugCodeEnabled ( + VOID + ) +{ + return ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_DEBUG_CODE_ENABLED) != 0); +} + + +/** + + Returns TRUE if DEBUG_CLEAR_MEMORY()macro is enabled. + + This function returns TRUE if the DEBUG_PROPERTY_DEBUG_CLEAR_MEMORY_ENABLED bit of + PcdDebugProperyMask is set. Otherwise FALSE is returned. + + @retval TRUE The DEBUG_PROPERTY_DEBUG_CLEAR_MEMORY_ENABLED bit of PcdDebugProperyMask is set. + @retval FALSE The DEBUG_PROPERTY_DEBUG_CLEAR_MEMORY_ENABLED bit of PcdDebugProperyMask is clear. + +**/ +BOOLEAN +EFIAPI +DebugClearMemoryEnabled ( + VOID + ) +{ + return ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_CLEAR_MEMORY_ENABLED) != 0); +} diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseDebugLibNull/EdkIIGlueBaseDebugLibNull.cif b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseDebugLibNull/EdkIIGlueBaseDebugLibNull.cif new file mode 100644 index 0000000..5ff52c7 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseDebugLibNull/EdkIIGlueBaseDebugLibNull.cif @@ -0,0 +1,11 @@ +<component> + name = "EdkIIGlueBaseDebugLibNull" + category = ModulePart + LocalRoot = "Edk\Foundation\Library\EdkIIGlueLib\Library\BaseDebugLibNull" + RefName = "EdkIIGlueBaseDebugLibNull" +[files] +"EdkIIGlueBaseDebugLibNull.sdl" +"EdkIIGlueBaseDebugLibNull.mak" +"BaseDebugLibNull.inf" +"DebugLib.c" +<endComponent> diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseDebugLibNull/EdkIIGlueBaseDebugLibNull.mak b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseDebugLibNull/EdkIIGlueBaseDebugLibNull.mak new file mode 100644 index 0000000..6b47770 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseDebugLibNull/EdkIIGlueBaseDebugLibNull.mak @@ -0,0 +1,83 @@ +#********************************************************************** +#********************************************************************** +#** ** +#** (C)Copyright 1985-2009, American Megatrends, Inc. ** +#** ** +#** All Rights Reserved. ** +#** ** +#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +#** ** +#** Phone: (770)-246-8600 ** +#** ** +#********************************************************************** +#********************************************************************** + +#********************************************************************** +# $Header: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGlueBaseDebugLibNull/EdkIIGlueBaseDebugLibNull.mak 1 1/20/12 3:48a Jeffch $ +# +# $Revision: 1 $ +# +# $Date: 1/20/12 3:48a $ +#********************************************************************** +# Revision History +# ---------------- +# $Log: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGlueBaseDebugLibNull/EdkIIGlueBaseDebugLibNull.mak $ +# +# 1 1/20/12 3:48a Jeffch +# Create Intel EDK 1117 Patch 7. +# +# 1 1/20/12 3:27a Jeffch +# Create Intel EDK 1117 Patch 7. +# +# 1 9/27/11 6:09a Wesleychen +# Intel EDK initially releases. +# +# 1 9/18/09 1:50a Iminglin +# +#********************************************************************** +#<AMI_FHDR_START> +# +# Name: EdkIIGlueBaseDebugLibNull.mak +# +# Description: +# +#<AMI_FHDR_END> +#********************************************************************** + + +$(EdkIIGlueBaseDebugLibNull_LIB) : EdkIIGlueBaseDebugLibNull + +EdkIIGlueBaseDebugLibNull : $(BUILD_DIR)\EdkIIGlueBaseDebugLibNull.mak EdkIIGlueBaseDebugLibNullBin + +$(BUILD_DIR)\EdkIIGlueBaseDebugLibNull.mak : $(EdkIIGlueBaseDebugLibNull_DIR)\$(@B).cif $(EdkIIGlueBaseDebugLibNull_DIR)\$(@B).mak $(BUILD_RULES) + $(CIF2MAK) $(EdkIIGlueBaseDebugLibNull_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS) + +EdkIIGlueBaseDebugLibNullBin : $(EdkIIGlueBaseLib_LIB) $(EdkIIGlueBaseMemoryLib_LIB) $(EdkIIGlueBasePrintLib_LIB) +!IF "$(x64_BUILD)"=="1" + $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\ + BUILD_DIR=$(BUILD_DIR)\ + /f $(BUILD_DIR)\EdkIIGlueBaseDebugLibNull.mak all\ + TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueBaseDebugLibNull_LIB)" + $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\ + BUILD_DIR=$(BUILD_DIR)\IA32\ + /f $(BUILD_DIR)\EdkIIGlueBaseDebugLibNull.mak all\ + TYPE=PEI_LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueBaseDebugLibNull_LIB)" +!ELSE + $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\ + BUILD_DIR=$(BUILD_DIR)\ + /f $(BUILD_DIR)\EdkIIGlueBaseDebugLibNull.mak all\ + TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueBaseDebugLibNull_LIB)" +!ENDIF +#********************************************************************** +#********************************************************************** +#** ** +#** (C)Copyright 1985-2009, American Megatrends, Inc. ** +#** ** +#** All Rights Reserved. ** +#** ** +#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +#** ** +#** Phone: (770)-246-8600 ** +#** ** +#********************************************************************** +#********************************************************************** diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseDebugLibNull/EdkIIGlueBaseDebugLibNull.sdl b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseDebugLibNull/EdkIIGlueBaseDebugLibNull.sdl new file mode 100644 index 0000000..0e71af1 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseDebugLibNull/EdkIIGlueBaseDebugLibNull.sdl @@ -0,0 +1,26 @@ +TOKEN + Name = "EdkIIGlueBaseDebugLibNull_SUPPORT" + Value = "1" + Help = "Main switch to enable BaseDebugLibNull support in Project" + TokenType = Boolean + TargetEQU = Yes + TargetMAK = Yes + Master = Yes +End + +TOKEN + Name = "EdkIIGlueBaseDebugLibNull_LIB" + Value = "$$(LIB_BUILD_DIR)\EdkIIGlueBaseDebugLibNull.lib" + TokenType = Expression + TargetMAK = Yes +End + +PATH + Name = "EdkIIGlueBaseDebugLibNull_DIR" +End + +MODULE + Help = "Includes EdkIIGlueBaseDebugLibNull.mak to Project" + File = "EdkIIGlueBaseDebugLibNull.mak" +End + diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsic.inf b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsic.inf new file mode 100644 index 0000000..b111552 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsic.inf @@ -0,0 +1,77 @@ +#/*++ +# +# 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: +# +# BaseIoLibIntrinsic.inf +# +# Abstract: +# +# Component description file for BaseIoLibIntrinsic. +# +#--*/ + +[defines] +BASE_NAME = EdkIIGlueBaseIoLibIntrinsic +COMPONENT_TYPE = LIBRARY + +[sources.common] + IoLib.c + IoLibMsc.c + IoHighLevel.c + +[sources.ia32] + +[sources.x64] + +[sources.ipf] + +[sources.ebc] + +[includes.common] + . + ..\..\Include + ..\..\include\Library + $(EDK_SOURCE)\Foundation + $(EDK_SOURCE)\Foundation\Framework + $(EDK_SOURCE)\Foundation\Efi + $(EDK_SOURCE)\Foundation\Include + $(EDK_SOURCE)\Foundation\Efi\Include + $(EDK_SOURCE)\Foundation\Framework\Include + $(EDK_SOURCE)\Foundation\Include\IndustryStandard + $(EDK_SOURCE)\Foundation\Core\Dxe + $(EDK_SOURCE)\Foundation\Library\Dxe\Include + $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include + +[libraries.common] + EdkIIGlueBaseLib + +[libraries.ia32] + + +[libraries.x64] + + +[nmake.common] + C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION + LIB_STD_FLAGS = /NOLOGO /IGNORE:4006 + +[nmake.ia32] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32 + +[nmake.x64] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64 + +[nmake.ipf] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF + +[nmake.ebc] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_EBC
\ No newline at end of file diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseIoLibIntrinsic/EdkIIGlueBaseIoLibIntrinsic.cif b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseIoLibIntrinsic/EdkIIGlueBaseIoLibIntrinsic.cif new file mode 100644 index 0000000..785361c --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseIoLibIntrinsic/EdkIIGlueBaseIoLibIntrinsic.cif @@ -0,0 +1,13 @@ +<component> + name = "EdkIIGlueBaseIoLibIntrinsic" + category = ModulePart + LocalRoot = "Edk\Foundation\Library\EdkIIGlueLib\Library\BaseIoLibIntrinsic" + RefName = "EdkIIGlueBaseIoLibIntrinsic" +[files] +"EdkIIGlueBaseIoLibIntrinsic.sdl" +"EdkIIGlueBaseIoLibIntrinsic.mak" +"BaseIoLibIntrinsic.inf" +"IoHighLevel.c" +"IoLib.c" +"IoLibMsc.c" +<endComponent> diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseIoLibIntrinsic/EdkIIGlueBaseIoLibIntrinsic.mak b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseIoLibIntrinsic/EdkIIGlueBaseIoLibIntrinsic.mak new file mode 100644 index 0000000..3f4aba2 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseIoLibIntrinsic/EdkIIGlueBaseIoLibIntrinsic.mak @@ -0,0 +1,95 @@ +#********************************************************************** +#********************************************************************** +#** ** +#** (C)Copyright 1985-2009, American Megatrends, Inc. ** +#** ** +#** All Rights Reserved. ** +#** ** +#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +#** ** +#** Phone: (770)-246-8600 ** +#** ** +#********************************************************************** +#********************************************************************** + +#********************************************************************** +# $Header: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGlueBaseIoLibIntrinsic/EdkIIGlueBaseIoLibIntrinsic.mak 1 1/20/12 3:48a Jeffch $ +# +# $Revision: 1 $ +# +# $Date: 1/20/12 3:48a $ +#********************************************************************** +# Revision History +# ---------------- +# $Log: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGlueBaseIoLibIntrinsic/EdkIIGlueBaseIoLibIntrinsic.mak $ +# +# 1 1/20/12 3:48a Jeffch +# Create Intel EDK 1117 Patch 7. +# +# 1 1/20/12 3:27a Jeffch +# Create Intel EDK 1117 Patch 7. +# +# 1 9/27/11 6:10a Wesleychen +# Intel EDK initially releases. +# +# 1 9/18/09 1:50a Iminglin +# +#********************************************************************** +#<AMI_FHDR_START> +# +# Name: EdkIIGlueBaseIoLibIntrinsic.mak +# +# Description: +# +#<AMI_FHDR_END> +#********************************************************************** + + +EDKIIGLUEBASEIOLIBINTRINSIC_OBJECTS= + +!IF "$(PROCESSOR)"=="IA32" || "$(PROCESSOR)"=="x64" +EDKIIGLUEBASEIOLIBINTRINSIC_OBJECTS=$(EDKIIGLUEBASEIOLIBINTRINSIC_OBJECTS)\ +$$(BUILD_DIR)\$(EdkIIGlueBaseIoLibIntrinsic_DIR)\IoLib.obj\ +$$(BUILD_DIR)\$(EdkIIGlueBaseIoLibIntrinsic_DIR)\IoLibMsc.obj\ +$$(BUILD_DIR)\$(EdkIIGlueBaseIoLibIntrinsic_DIR)\IoHighLevel.obj +!ENDIF + +$(EdkIIGlueBaseIoLibIntrinsic_LIB) : EdkIIGlueBaseIoLibIntrinsic + +EdkIIGlueBaseIoLibIntrinsic : $(BUILD_DIR)\EdkIIGlueBaseIoLibIntrinsic.mak EdkIIGlueBaseIoLibIntrinsicBin + +$(BUILD_DIR)\EdkIIGlueBaseIoLibIntrinsic.mak : $(EdkIIGlueBaseIoLibIntrinsic_DIR)\$(@B).cif $(EdkIIGlueBaseIoLibIntrinsic_DIR)\$(@B).mak $(BUILD_RULES) + $(CIF2MAK) $(EdkIIGlueBaseIoLibIntrinsic_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS) + +EdkIIGlueBaseIoLibIntrinsicBin : $(EdkIIGlueBaseLib_LIB) +!IF "$(x64_BUILD)"=="1" + $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\ + BUILD_DIR=$(BUILD_DIR)\ + /f $(BUILD_DIR)\EdkIIGlueBaseIoLibIntrinsic.mak all\ + TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueBaseIoLibIntrinsic_LIB)"\ + "OBJECTS=$(EDKIIGLUEBASEIOLIBINTRINSIC_OBJECTS)" + $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\ + BUILD_DIR=$(BUILD_DIR)\IA32\ + /f $(BUILD_DIR)\EdkIIGlueBaseIoLibIntrinsic.mak all\ + TYPE=PEI_LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueBaseIoLibIntrinsic_LIB)"\ + "OBJECTS=$(EDKIIGLUEBASEIOLIBINTRINSIC_OBJECTS)" +!ELSE + $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\ + BUILD_DIR=$(BUILD_DIR)\ + /f $(BUILD_DIR)\EdkIIGlueBaseIoLibIntrinsic.mak all\ + TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueBaseIoLibIntrinsic_LIB)"\ + "OBJECTS=$(EDKIIGLUEBASEIOLIBINTRINSIC_OBJECTS)" +!ENDIF +#********************************************************************** +#********************************************************************** +#** ** +#** (C)Copyright 1985-2009, American Megatrends, Inc. ** +#** ** +#** All Rights Reserved. ** +#** ** +#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +#** ** +#** Phone: (770)-246-8600 ** +#** ** +#********************************************************************** +#********************************************************************** diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseIoLibIntrinsic/EdkIIGlueBaseIoLibIntrinsic.sdl b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseIoLibIntrinsic/EdkIIGlueBaseIoLibIntrinsic.sdl new file mode 100644 index 0000000..b94f6dc --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseIoLibIntrinsic/EdkIIGlueBaseIoLibIntrinsic.sdl @@ -0,0 +1,26 @@ +TOKEN + Name = "EdkIIGlueBaseIoLibIntrinsic_SUPPORT" + Value = "1" + Help = "Main switch to enable EdkIIGlueBaseIoLibIntrinsic support in Project" + TokenType = Boolean + TargetEQU = Yes + TargetMAK = Yes + Master = Yes +End + +TOKEN + Name = "EdkIIGlueBaseIoLibIntrinsic_LIB" + Value = "$$(LIB_BUILD_DIR)\EdkIIGlueBaseIoLibIntrinsic.lib" + TokenType = Expression + TargetMAK = Yes +End + +PATH + Name = "EdkIIGlueBaseIoLibIntrinsic_DIR" +End + +MODULE + Help = "Includes EdkIIGlueBaseIoLibIntrinsic.mak to Project" + File = "EdkIIGlueBaseIoLibIntrinsic.mak" +End + diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseIoLibIntrinsic/IoHighLevel.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseIoLibIntrinsic/IoHighLevel.c new file mode 100644 index 0000000..debc9e0 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseIoLibIntrinsic/IoHighLevel.c @@ -0,0 +1,2280 @@ +/*++ + +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: + + IoHighLevel.c + +Abstract: + + High-level Io/Mmio functions. + + All assertions for bit field operations are handled bit field functions in the + Base Library. + + The following IoLib instances share the same version of this file: + + BaseIoLibIntrinsic + DxeIoLibCpuIo + PeiIoLibCpuIo + +--*/ + +#include "EdkIIGlueBase.h" + +/** + Reads an 8-bit I/O port, performs a bitwise inclusive OR, and writes the + result back to the 8-bit I/O port. + + Reads the 8-bit I/O port specified by Port, performs a bitwise inclusive OR + between the read result and the value specified by OrData, and writes the + result to the 8-bit I/O port specified by Port. The value written to the I/O + port is returned. This function must guarantee that all I/O read and write + operations are serialized. + + If 8-bit I/O port operations are not supported, then ASSERT(). + + @param Port The I/O port to write. + @param OrData The value to OR with the read value from the I/O port. + + @return The value written back to the I/O port. + +**/ +UINT8 +EFIAPI +IoOr8 ( + IN UINTN Port, + IN UINT8 OrData + ) +{ + return IoWrite8 (Port, IoRead8 (Port) | OrData); +} + +/** + Reads an 8-bit I/O port, performs a bitwise AND, and writes the result back + to the 8-bit I/O port. + + Reads the 8-bit I/O port specified by Port, performs a bitwise AND between + the read result and the value specified by AndData, and writes the result to + the 8-bit I/O port specified by Port. The value written to the I/O port is + returned. This function must guarantee that all I/O read and write operations + are serialized. + + If 8-bit I/O port operations are not supported, then ASSERT(). + + @param Port The I/O port to write. + @param AndData The value to AND with the read value from the I/O port. + + @return The value written back to the I/O port. + +**/ +UINT8 +EFIAPI +IoAnd8 ( + IN UINTN Port, + IN UINT8 AndData + ) +{ + return IoWrite8 (Port, IoRead8 (Port) & AndData); +} + +/** + Reads an 8-bit I/O port, performs a bitwise AND followed by a bitwise + inclusive OR, and writes the result back to the 8-bit I/O port. + + Reads the 8-bit I/O port specified by Port, performs a bitwise AND between + the read result and the value specified by AndData, performs a bitwise OR + between the result of the AND operation and the value specified by OrData, + and writes the result to the 8-bit I/O port specified by Port. The value + written to the I/O port is returned. This function must guarantee that all + I/O read and write operations are serialized. + + If 8-bit I/O port operations are not supported, then ASSERT(). + + @param Port The I/O port to write. + @param AndData The value to AND with the read value from the I/O port. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the I/O port. + +**/ +UINT8 +EFIAPI +IoAndThenOr8 ( + IN UINTN Port, + IN UINT8 AndData, + IN UINT8 OrData + ) +{ + return IoWrite8 (Port, (IoRead8 (Port) & AndData) | OrData); +} + +/** + Reads a bit field of an I/O register. + + Reads the bit field in an 8-bit I/O register. The bit field is specified by + the StartBit and the EndBit. The value of the bit field is returned. + + If 8-bit I/O port operations are not supported, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Port The I/O port to read. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..7. + + @return The value read. + +**/ +UINT8 +EFIAPI +IoBitFieldRead8 ( + IN UINTN Port, + IN UINTN StartBit, + IN UINTN EndBit + ) +{ + return BitFieldRead8 (IoRead8 (Port), StartBit, EndBit); +} + +/** + Writes a bit field to an I/O register. + + Writes Value to the bit field of the I/O register. The bit field is specified + by the StartBit and the EndBit. All other bits in the destination I/O + register are preserved. The value written to the I/O port is returned. Extra + left bits in Value are stripped. + + If 8-bit I/O port operations are not supported, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Port The I/O port to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..7. + @param Value New value of the bit field. + + @return The value written back to the I/O port. + +**/ +UINT8 +EFIAPI +IoBitFieldWrite8 ( + IN UINTN Port, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT8 Value + ) +{ + return IoWrite8 ( + Port, + BitFieldWrite8 (IoRead8 (Port), StartBit, EndBit, Value) + ); +} + +/** + Reads a bit field in an 8-bit port, performs a bitwise OR, and writes the + result back to the bit field in the 8-bit port. + + Reads the 8-bit I/O port specified by Port, performs a bitwise inclusive OR + between the read result and the value specified by OrData, and writes the + result to the 8-bit I/O port specified by Port. The value written to the I/O + port is returned. This function must guarantee that all I/O read and write + operations are serialized. Extra left bits in OrData are stripped. + + If 8-bit I/O port operations are not supported, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Port The I/O port to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..7. + @param OrData The value to OR with the read value from the I/O port. + + @return The value written back to the I/O port. + +**/ +UINT8 +EFIAPI +IoBitFieldOr8 ( + IN UINTN Port, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT8 OrData + ) +{ + return IoWrite8 ( + Port, + BitFieldOr8 (IoRead8 (Port), StartBit, EndBit, OrData) + ); +} + +/** + Reads a bit field in an 8-bit port, performs a bitwise AND, and writes the + result back to the bit field in the 8-bit port. + + Reads the 8-bit I/O port specified by Port, performs a bitwise AND between + the read result and the value specified by AndData, and writes the result to + the 8-bit I/O port specified by Port. The value written to the I/O port is + returned. This function must guarantee that all I/O read and write operations + are serialized. Extra left bits in AndData are stripped. + + If 8-bit I/O port operations are not supported, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Port The I/O port to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..7. + @param AndData The value to AND with the read value from the I/O port. + + @return The value written back to the I/O port. + +**/ +UINT8 +EFIAPI +IoBitFieldAnd8 ( + IN UINTN Port, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT8 AndData + ) +{ + return IoWrite8 ( + Port, + BitFieldAnd8 (IoRead8 (Port), StartBit, EndBit, AndData) + ); +} + +/** + Reads a bit field in an 8-bit port, performs a bitwise AND followed by a + bitwise inclusive OR, and writes the result back to the bit field in the + 8-bit port. + + Reads the 8-bit I/O port specified by Port, performs a bitwise AND followed + by a bitwise inclusive OR between the read result and the value specified by + AndData, and writes the result to the 8-bit I/O port specified by Port. The + value written to the I/O port is returned. This function must guarantee that + all I/O read and write operations are serialized. Extra left bits in both + AndData and OrData are stripped. + + If 8-bit I/O port operations are not supported, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Port The I/O port to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..7. + @param AndData The value to AND with the read value from the I/O port. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the I/O port. + +**/ +UINT8 +EFIAPI +IoBitFieldAndThenOr8 ( + IN UINTN Port, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT8 AndData, + IN UINT8 OrData + ) +{ + return IoWrite8 ( + Port, + BitFieldAndThenOr8 (IoRead8 (Port), StartBit, EndBit, AndData, OrData) + ); +} + +/** + Reads a 16-bit I/O port, performs a bitwise inclusive OR, and writes the + result back to the 16-bit I/O port. + + Reads the 16-bit I/O port specified by Port, performs a bitwise inclusive OR + between the read result and the value specified by OrData, and writes the + result to the 16-bit I/O port specified by Port. The value written to the I/O + port is returned. This function must guarantee that all I/O read and write + operations are serialized. + + If 16-bit I/O port operations are not supported, then ASSERT(). + + @param Port The I/O port to write. + @param OrData The value to OR with the read value from the I/O port. + + @return The value written back to the I/O port. + +**/ +UINT16 +EFIAPI +IoOr16 ( + IN UINTN Port, + IN UINT16 OrData + ) +{ + return IoWrite16 (Port, IoRead16 (Port) | OrData); +} + +/** + Reads a 16-bit I/O port, performs a bitwise AND, and writes the result back + to the 16-bit I/O port. + + Reads the 16-bit I/O port specified by Port, performs a bitwise AND between + the read result and the value specified by AndData, and writes the result to + the 16-bit I/O port specified by Port. The value written to the I/O port is + returned. This function must guarantee that all I/O read and write operations + are serialized. + + If 16-bit I/O port operations are not supported, then ASSERT(). + + @param Port The I/O port to write. + @param AndData The value to AND with the read value from the I/O port. + + @return The value written back to the I/O port. + +**/ +UINT16 +EFIAPI +IoAnd16 ( + IN UINTN Port, + IN UINT16 AndData + ) +{ + return IoWrite16 (Port, IoRead16 (Port) & AndData); +} + +/** + Reads a 16-bit I/O port, performs a bitwise AND followed by a bitwise + inclusive OR, and writes the result back to the 16-bit I/O port. + + Reads the 16-bit I/O port specified by Port, performs a bitwise AND between + the read result and the value specified by AndData, performs a bitwise OR + between the result of the AND operation and the value specified by OrData, + and writes the result to the 16-bit I/O port specified by Port. The value + written to the I/O port is returned. This function must guarantee that all + I/O read and write operations are serialized. + + If 16-bit I/O port operations are not supported, then ASSERT(). + + @param Port The I/O port to write. + @param AndData The value to AND with the read value from the I/O port. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the I/O port. + +**/ +UINT16 +EFIAPI +IoAndThenOr16 ( + IN UINTN Port, + IN UINT16 AndData, + IN UINT16 OrData + ) +{ + return IoWrite16 (Port, (IoRead16 (Port) & AndData) | OrData); +} + +/** + Reads a bit field of an I/O register. + + Reads the bit field in a 16-bit I/O register. The bit field is specified by + the StartBit and the EndBit. The value of the bit field is returned. + + If 16-bit I/O port operations are not supported, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Port The I/O port to read. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..15. + + @return The value read. + +**/ +UINT16 +EFIAPI +IoBitFieldRead16 ( + IN UINTN Port, + IN UINTN StartBit, + IN UINTN EndBit + ) +{ + return BitFieldRead16 (IoRead16 (Port), StartBit, EndBit); +} + +/** + Writes a bit field to an I/O register. + + Writes Value to the bit field of the I/O register. The bit field is specified + by the StartBit and the EndBit. All other bits in the destination I/O + register are preserved. The value written to the I/O port is returned. Extra + left bits in Value are stripped. + + If 16-bit I/O port operations are not supported, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Port The I/O port to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..15. + @param Value New value of the bit field. + + @return The value written back to the I/O port. + +**/ +UINT16 +EFIAPI +IoBitFieldWrite16 ( + IN UINTN Port, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT16 Value + ) +{ + return IoWrite16 ( + Port, + BitFieldWrite16 (IoRead16 (Port), StartBit, EndBit, Value) + ); +} + +/** + Reads a bit field in a 16-bit port, performs a bitwise OR, and writes the + result back to the bit field in the 16-bit port. + + Reads the 16-bit I/O port specified by Port, performs a bitwise inclusive OR + between the read result and the value specified by OrData, and writes the + result to the 16-bit I/O port specified by Port. The value written to the I/O + port is returned. This function must guarantee that all I/O read and write + operations are serialized. Extra left bits in OrData are stripped. + + If 16-bit I/O port operations are not supported, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Port The I/O port to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..15. + @param OrData The value to OR with the read value from the I/O port. + + @return The value written back to the I/O port. + +**/ +UINT16 +EFIAPI +IoBitFieldOr16 ( + IN UINTN Port, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT16 OrData + ) +{ + return IoWrite16 ( + Port, + BitFieldOr16 (IoRead16 (Port), StartBit, EndBit, OrData) + ); +} + +/** + Reads a bit field in a 16-bit port, performs a bitwise AND, and writes the + result back to the bit field in the 16-bit port. + + Reads the 16-bit I/O port specified by Port, performs a bitwise AND between + the read result and the value specified by AndData, and writes the result to + the 16-bit I/O port specified by Port. The value written to the I/O port is + returned. This function must guarantee that all I/O read and write operations + are serialized. Extra left bits in AndData are stripped. + + If 16-bit I/O port operations are not supported, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Port The I/O port to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..15. + @param AndData The value to AND with the read value from the I/O port. + + @return The value written back to the I/O port. + +**/ +UINT16 +EFIAPI +IoBitFieldAnd16 ( + IN UINTN Port, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT16 AndData + ) +{ + return IoWrite16 ( + Port, + BitFieldAnd16 (IoRead16 (Port), StartBit, EndBit, AndData) + ); +} + +/** + Reads a bit field in a 16-bit port, performs a bitwise AND followed by a + bitwise inclusive OR, and writes the result back to the bit field in the + 16-bit port. + + Reads the 16-bit I/O port specified by Port, performs a bitwise AND followed + by a bitwise inclusive OR between the read result and the value specified by + AndData, and writes the result to the 16-bit I/O port specified by Port. The + value written to the I/O port is returned. This function must guarantee that + all I/O read and write operations are serialized. Extra left bits in both + AndData and OrData are stripped. + + If 16-bit I/O port operations are not supported, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Port The I/O port to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..15. + @param AndData The value to AND with the read value from the I/O port. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the I/O port. + +**/ +UINT16 +EFIAPI +IoBitFieldAndThenOr16 ( + IN UINTN Port, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT16 AndData, + IN UINT16 OrData + ) +{ + return IoWrite16 ( + Port, + BitFieldAndThenOr16 (IoRead16 (Port), StartBit, EndBit, AndData, OrData) + ); +} + +/** + Reads a 32-bit I/O port, performs a bitwise inclusive OR, and writes the + result back to the 32-bit I/O port. + + Reads the 32-bit I/O port specified by Port, performs a bitwise inclusive OR + between the read result and the value specified by OrData, and writes the + result to the 32-bit I/O port specified by Port. The value written to the I/O + port is returned. This function must guarantee that all I/O read and write + operations are serialized. + + If 32-bit I/O port operations are not supported, then ASSERT(). + + @param Port The I/O port to write. + @param OrData The value to OR with the read value from the I/O port. + + @return The value written back to the I/O port. + +**/ +UINT32 +EFIAPI +IoOr32 ( + IN UINTN Port, + IN UINT32 OrData + ) +{ + return IoWrite32 (Port, IoRead32 (Port) | OrData); +} + +/** + Reads a 32-bit I/O port, performs a bitwise AND, and writes the result back + to the 32-bit I/O port. + + Reads the 32-bit I/O port specified by Port, performs a bitwise AND between + the read result and the value specified by AndData, and writes the result to + the 32-bit I/O port specified by Port. The value written to the I/O port is + returned. This function must guarantee that all I/O read and write operations + are serialized. + + If 32-bit I/O port operations are not supported, then ASSERT(). + + @param Port The I/O port to write. + @param AndData The value to AND with the read value from the I/O port. + + @return The value written back to the I/O port. + +**/ +UINT32 +EFIAPI +IoAnd32 ( + IN UINTN Port, + IN UINT32 AndData + ) +{ + return IoWrite32 (Port, IoRead32 (Port) & AndData); +} + +/** + Reads a 32-bit I/O port, performs a bitwise AND followed by a bitwise + inclusive OR, and writes the result back to the 32-bit I/O port. + + Reads the 32-bit I/O port specified by Port, performs a bitwise AND between + the read result and the value specified by AndData, performs a bitwise OR + between the result of the AND operation and the value specified by OrData, + and writes the result to the 32-bit I/O port specified by Port. The value + written to the I/O port is returned. This function must guarantee that all + I/O read and write operations are serialized. + + If 32-bit I/O port operations are not supported, then ASSERT(). + + @param Port The I/O port to write. + @param AndData The value to AND with the read value from the I/O port. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the I/O port. + +**/ +UINT32 +EFIAPI +IoAndThenOr32 ( + IN UINTN Port, + IN UINT32 AndData, + IN UINT32 OrData + ) +{ + return IoWrite32 (Port, (IoRead32 (Port) & AndData) | OrData); +} + +/** + Reads a bit field of an I/O register. + + Reads the bit field in a 32-bit I/O register. The bit field is specified by + the StartBit and the EndBit. The value of the bit field is returned. + + If 32-bit I/O port operations are not supported, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Port The I/O port to read. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + + @return The value read. + +**/ +UINT32 +EFIAPI +IoBitFieldRead32 ( + IN UINTN Port, + IN UINTN StartBit, + IN UINTN EndBit + ) +{ + return BitFieldRead32 (IoRead32 (Port), StartBit, EndBit); +} + +/** + Writes a bit field to an I/O register. + + Writes Value to the bit field of the I/O register. The bit field is specified + by the StartBit and the EndBit. All other bits in the destination I/O + register are preserved. The value written to the I/O port is returned. Extra + left bits in Value are stripped. + + If 32-bit I/O port operations are not supported, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Port The I/O port to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + @param Value New value of the bit field. + + @return The value written back to the I/O port. + +**/ +UINT32 +EFIAPI +IoBitFieldWrite32 ( + IN UINTN Port, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT32 Value + ) +{ + return IoWrite32 ( + Port, + BitFieldWrite32 (IoRead32 (Port), StartBit, EndBit, Value) + ); +} + +/** + Reads a bit field in a 32-bit port, performs a bitwise OR, and writes the + result back to the bit field in the 32-bit port. + + Reads the 32-bit I/O port specified by Port, performs a bitwise inclusive OR + between the read result and the value specified by OrData, and writes the + result to the 32-bit I/O port specified by Port. The value written to the I/O + port is returned. This function must guarantee that all I/O read and write + operations are serialized. Extra left bits in OrData are stripped. + + If 32-bit I/O port operations are not supported, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Port The I/O port to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + @param OrData The value to OR with the read value from the I/O port. + + @return The value written back to the I/O port. + +**/ +UINT32 +EFIAPI +IoBitFieldOr32 ( + IN UINTN Port, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT32 OrData + ) +{ + return IoWrite32 ( + Port, + BitFieldOr32 (IoRead32 (Port), StartBit, EndBit, OrData) + ); +} + +/** + Reads a bit field in a 32-bit port, performs a bitwise AND, and writes the + result back to the bit field in the 32-bit port. + + Reads the 32-bit I/O port specified by Port, performs a bitwise AND between + the read result and the value specified by AndData, and writes the result to + the 32-bit I/O port specified by Port. The value written to the I/O port is + returned. This function must guarantee that all I/O read and write operations + are serialized. Extra left bits in AndData are stripped. + + If 32-bit I/O port operations are not supported, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Port The I/O port to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + @param AndData The value to AND with the read value from the I/O port. + + @return The value written back to the I/O port. + +**/ +UINT32 +EFIAPI +IoBitFieldAnd32 ( + IN UINTN Port, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT32 AndData + ) +{ + return IoWrite32 ( + Port, + BitFieldAnd32 (IoRead32 (Port), StartBit, EndBit, AndData) + ); +} + +/** + Reads a bit field in a 32-bit port, performs a bitwise AND followed by a + bitwise inclusive OR, and writes the result back to the bit field in the + 32-bit port. + + Reads the 32-bit I/O port specified by Port, performs a bitwise AND followed + by a bitwise inclusive OR between the read result and the value specified by + AndData, and writes the result to the 32-bit I/O port specified by Port. The + value written to the I/O port is returned. This function must guarantee that + all I/O read and write operations are serialized. Extra left bits in both + AndData and OrData are stripped. + + If 32-bit I/O port operations are not supported, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Port The I/O port to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + @param AndData The value to AND with the read value from the I/O port. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the I/O port. + +**/ +UINT32 +EFIAPI +IoBitFieldAndThenOr32 ( + IN UINTN Port, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT32 AndData, + IN UINT32 OrData + ) +{ + return IoWrite32 ( + Port, + BitFieldAndThenOr32 (IoRead32 (Port), StartBit, EndBit, AndData, OrData) + ); +} + +/** + Reads a 64-bit I/O port, performs a bitwise inclusive OR, and writes the + result back to the 64-bit I/O port. + + Reads the 64-bit I/O port specified by Port, performs a bitwise inclusive OR + between the read result and the value specified by OrData, and writes the + result to the 64-bit I/O port specified by Port. The value written to the I/O + port is returned. This function must guarantee that all I/O read and write + operations are serialized. + + If 64-bit I/O port operations are not supported, then ASSERT(). + + @param Port The I/O port to write. + @param OrData The value to OR with the read value from the I/O port. + + @return The value written back to the I/O port. + +**/ +UINT64 +EFIAPI +IoOr64 ( + IN UINTN Port, + IN UINT64 OrData + ) +{ + return IoWrite64 (Port, IoRead64 (Port) | OrData); +} + +/** + Reads a 64-bit I/O port, performs a bitwise AND, and writes the result back + to the 64-bit I/O port. + + Reads the 64-bit I/O port specified by Port, performs a bitwise AND between + the read result and the value specified by AndData, and writes the result to + the 64-bit I/O port specified by Port. The value written to the I/O port is + returned. This function must guarantee that all I/O read and write operations + are serialized. + + If 64-bit I/O port operations are not supported, then ASSERT(). + + @param Port The I/O port to write. + @param AndData The value to AND with the read value from the I/O port. + + @return The value written back to the I/O port. + +**/ +UINT64 +EFIAPI +IoAnd64 ( + IN UINTN Port, + IN UINT64 AndData + ) +{ + return IoWrite64 (Port, IoRead64 (Port) & AndData); +} + +/** + Reads a 64-bit I/O port, performs a bitwise AND followed by a bitwise + inclusive OR, and writes the result back to the 64-bit I/O port. + + Reads the 64-bit I/O port specified by Port, performs a bitwise AND between + the read result and the value specified by AndData, performs a bitwise OR + between the result of the AND operation and the value specified by OrData, + and writes the result to the 64-bit I/O port specified by Port. The value + written to the I/O port is returned. This function must guarantee that all + I/O read and write operations are serialized. + + If 64-bit I/O port operations are not supported, then ASSERT(). + + @param Port The I/O port to write. + @param AndData The value to AND with the read value from the I/O port. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the I/O port. + +**/ +UINT64 +EFIAPI +IoAndThenOr64 ( + IN UINTN Port, + IN UINT64 AndData, + IN UINT64 OrData + ) +{ + return IoWrite64 (Port, (IoRead64 (Port) & AndData) | OrData); +} + +/** + Reads a bit field of an I/O register. + + Reads the bit field in a 64-bit I/O register. The bit field is specified by + the StartBit and the EndBit. The value of the bit field is returned. + + If 64-bit I/O port operations are not supported, then ASSERT(). + If StartBit is greater than 63, then ASSERT(). + If EndBit is greater than 63, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Port The I/O port to read. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..63. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..63. + + @return The value read. + +**/ +UINT64 +EFIAPI +IoBitFieldRead64 ( + IN UINTN Port, + IN UINTN StartBit, + IN UINTN EndBit + ) +{ + return BitFieldRead64 (IoRead64 (Port), StartBit, EndBit); +} + +/** + Writes a bit field to an I/O register. + + Writes Value to the bit field of the I/O register. The bit field is specified + by the StartBit and the EndBit. All other bits in the destination I/O + register are preserved. The value written to the I/O port is returned. Extra + left bits in Value are stripped. + + If 64-bit I/O port operations are not supported, then ASSERT(). + If StartBit is greater than 63, then ASSERT(). + If EndBit is greater than 63, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Port The I/O port to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..63. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..63. + @param Value New value of the bit field. + + @return The value written back to the I/O port. + +**/ +UINT64 +EFIAPI +IoBitFieldWrite64 ( + IN UINTN Port, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT64 Value + ) +{ + return IoWrite64 ( + Port, + BitFieldWrite64 (IoRead64 (Port), StartBit, EndBit, Value) + ); +} + +/** + Reads a bit field in a 64-bit port, performs a bitwise OR, and writes the + result back to the bit field in the 64-bit port. + + Reads the 64-bit I/O port specified by Port, performs a bitwise inclusive OR + between the read result and the value specified by OrData, and writes the + result to the 64-bit I/O port specified by Port. The value written to the I/O + port is returned. This function must guarantee that all I/O read and write + operations are serialized. Extra left bits in OrData are stripped. + + If 64-bit I/O port operations are not supported, then ASSERT(). + If StartBit is greater than 63, then ASSERT(). + If EndBit is greater than 63, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Port The I/O port to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..63. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..63. + @param OrData The value to OR with the read value from the I/O port. + + @return The value written back to the I/O port. + +**/ +UINT64 +EFIAPI +IoBitFieldOr64 ( + IN UINTN Port, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT64 OrData + ) +{ + return IoWrite64 ( + Port, + BitFieldOr64 (IoRead64 (Port), StartBit, EndBit, OrData) + ); +} + +/** + Reads a bit field in a 64-bit port, performs a bitwise AND, and writes the + result back to the bit field in the 64-bit port. + + Reads the 64-bit I/O port specified by Port, performs a bitwise AND between + the read result and the value specified by AndData, and writes the result to + the 64-bit I/O port specified by Port. The value written to the I/O port is + returned. This function must guarantee that all I/O read and write operations + are serialized. Extra left bits in AndData are stripped. + + If 64-bit I/O port operations are not supported, then ASSERT(). + If StartBit is greater than 63, then ASSERT(). + If EndBit is greater than 63, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Port The I/O port to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..63. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..63. + @param AndData The value to AND with the read value from the I/O port. + + @return The value written back to the I/O port. + +**/ +UINT64 +EFIAPI +IoBitFieldAnd64 ( + IN UINTN Port, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT64 AndData + ) +{ + return IoWrite64 ( + Port, + BitFieldAnd64 (IoRead64 (Port), StartBit, EndBit, AndData) + ); +} + +/** + Reads a bit field in a 64-bit port, performs a bitwise AND followed by a + bitwise inclusive OR, and writes the result back to the bit field in the + 64-bit port. + + Reads the 64-bit I/O port specified by Port, performs a bitwise AND followed + by a bitwise inclusive OR between the read result and the value specified by + AndData, and writes the result to the 64-bit I/O port specified by Port. The + value written to the I/O port is returned. This function must guarantee that + all I/O read and write operations are serialized. Extra left bits in both + AndData and OrData are stripped. + + If 64-bit I/O port operations are not supported, then ASSERT(). + If StartBit is greater than 63, then ASSERT(). + If EndBit is greater than 63, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Port The I/O port to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..63. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..63. + @param AndData The value to AND with the read value from the I/O port. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the I/O port. + +**/ +UINT64 +EFIAPI +IoBitFieldAndThenOr64 ( + IN UINTN Port, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT64 AndData, + IN UINT64 OrData + ) +{ + return IoWrite64 ( + Port, + BitFieldAndThenOr64 (IoRead64 (Port), StartBit, EndBit, AndData, OrData) + ); +} + +/** + Reads an 8-bit MMIO register, performs a bitwise inclusive OR, and writes the + result back to the 8-bit MMIO register. + + Reads the 8-bit MMIO register specified by Address, performs a bitwise + inclusive OR between the read result and the value specified by OrData, and + writes the result to the 8-bit MMIO register specified by Address. The value + written to the MMIO register is returned. This function must guarantee that + all MMIO read and write operations are serialized. + + If 8-bit MMIO register operations are not supported, then ASSERT(). + + @param Address The MMIO register to write. + @param OrData The value to OR with the read value from the MMIO register. + + @return The value written back to the MMIO register. + +**/ +UINT8 +EFIAPI +MmioOr8 ( + IN UINTN Address, + IN UINT8 OrData + ) +{ + return MmioWrite8 (Address, MmioRead8 (Address) | OrData); +} + +/** + Reads an 8-bit MMIO register, performs a bitwise AND, and writes the result + back to the 8-bit MMIO register. + + Reads the 8-bit MMIO register specified by Address, performs a bitwise AND + between the read result and the value specified by AndData, and writes the + result to the 8-bit MMIO register specified by Address. The value written to + the MMIO register is returned. This function must guarantee that all MMIO + read and write operations are serialized. + + If 8-bit MMIO register operations are not supported, then ASSERT(). + + @param Address The MMIO register to write. + @param AndData The value to AND with the read value from the MMIO register. + + @return The value written back to the MMIO register. + +**/ +UINT8 +EFIAPI +MmioAnd8 ( + IN UINTN Address, + IN UINT8 AndData + ) +{ + return MmioWrite8 (Address, MmioRead8 (Address) & AndData); +} + +/** + Reads an 8-bit MMIO register, performs a bitwise AND followed by a bitwise + inclusive OR, and writes the result back to the 8-bit MMIO register. + + Reads the 8-bit MMIO register specified by Address, performs a bitwise AND + between the read result and the value specified by AndData, performs a + bitwise OR between the result of the AND operation and the value specified by + OrData, and writes the result to the 8-bit MMIO register specified by + Address. The value written to the MMIO register is returned. This function + must guarantee that all MMIO read and write operations are serialized. + + If 8-bit MMIO register operations are not supported, then ASSERT(). + + + @param Address The MMIO register to write. + @param AndData The value to AND with the read value from the MMIO register. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the MMIO register. + +**/ +UINT8 +EFIAPI +MmioAndThenOr8 ( + IN UINTN Address, + IN UINT8 AndData, + IN UINT8 OrData + ) +{ + return MmioWrite8 (Address, (MmioRead8 (Address) & AndData) | OrData); +} + +/** + Reads a bit field of a MMIO register. + + Reads the bit field in an 8-bit MMIO register. The bit field is specified by + the StartBit and the EndBit. The value of the bit field is returned. + + If 8-bit MMIO register operations are not supported, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address MMIO register to read. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..7. + + @return The value read. + +**/ +UINT8 +EFIAPI +MmioBitFieldRead8 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit + ) +{ + return BitFieldRead8 (MmioRead8 (Address), StartBit, EndBit); +} + +/** + Writes a bit field to a MMIO register. + + Writes Value to the bit field of the MMIO register. The bit field is + specified by the StartBit and the EndBit. All other bits in the destination + MMIO register are preserved. The new value of the 8-bit register is returned. + + If 8-bit MMIO register operations are not supported, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address MMIO register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..7. + @param Value New value of the bit field. + + @return The value written back to the MMIO register. + +**/ +UINT8 +EFIAPI +MmioBitFieldWrite8 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT8 Value + ) +{ + return MmioWrite8 ( + Address, + BitFieldWrite8 (MmioRead8 (Address), StartBit, EndBit, Value) + ); +} + +/** + Reads a bit field in an 8-bit MMIO register, performs a bitwise OR, and + writes the result back to the bit field in the 8-bit MMIO register. + + Reads the 8-bit MMIO register specified by Address, performs a bitwise + inclusive OR between the read result and the value specified by OrData, and + writes the result to the 8-bit MMIO register specified by Address. The value + written to the MMIO register is returned. This function must guarantee that + all MMIO read and write operations are serialized. Extra left bits in OrData + are stripped. + + If 8-bit MMIO register operations are not supported, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address MMIO register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..7. + @param OrData The value to OR with read value from the MMIO register. + + @return The value written back to the MMIO register. + +**/ +UINT8 +EFIAPI +MmioBitFieldOr8 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT8 OrData + ) +{ + return MmioWrite8 ( + Address, + BitFieldOr8 (MmioRead8 (Address), StartBit, EndBit, OrData) + ); +} + +/** + Reads a bit field in an 8-bit MMIO register, performs a bitwise AND, and + writes the result back to the bit field in the 8-bit MMIO register. + + Reads the 8-bit MMIO register specified by Address, performs a bitwise AND + between the read result and the value specified by AndData, and writes the + result to the 8-bit MMIO register specified by Address. The value written to + the MMIO register is returned. This function must guarantee that all MMIO + read and write operations are serialized. Extra left bits in AndData are + stripped. + + If 8-bit MMIO register operations are not supported, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address MMIO register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..7. + @param AndData The value to AND with read value from the MMIO register. + + @return The value written back to the MMIO register. + +**/ +UINT8 +EFIAPI +MmioBitFieldAnd8 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT8 AndData + ) +{ + return MmioWrite8 ( + Address, + BitFieldAnd8 (MmioRead8 (Address), StartBit, EndBit, AndData) + ); +} + +/** + Reads a bit field in an 8-bit MMIO register, performs a bitwise AND followed + by a bitwise inclusive OR, and writes the result back to the bit field in the + 8-bit MMIO register. + + Reads the 8-bit MMIO register specified by Address, performs a bitwise AND + followed by a bitwise inclusive OR between the read result and the value + specified by AndData, and writes the result to the 8-bit MMIO register + specified by Address. The value written to the MMIO register is returned. + This function must guarantee that all MMIO read and write operations are + serialized. Extra left bits in both AndData and OrData are stripped. + + If 8-bit MMIO register operations are not supported, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address MMIO register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..7. + @param AndData The value to AND with read value from the MMIO register. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the MMIO register. + +**/ +UINT8 +EFIAPI +MmioBitFieldAndThenOr8 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT8 AndData, + IN UINT8 OrData + ) +{ + return MmioWrite8 ( + Address, + BitFieldAndThenOr8 (MmioRead8 (Address), StartBit, EndBit, AndData, OrData) + ); +} + +/** + Reads a 16-bit MMIO register, performs a bitwise inclusive OR, and writes the + result back to the 16-bit MMIO register. + + Reads the 16-bit MMIO register specified by Address, performs a bitwise + inclusive OR between the read result and the value specified by OrData, and + writes the result to the 16-bit MMIO register specified by Address. The value + written to the MMIO register is returned. This function must guarantee that + all MMIO read and write operations are serialized. + + If 16-bit MMIO register operations are not supported, then ASSERT(). + + @param Address The MMIO register to write. + @param OrData The value to OR with the read value from the MMIO register. + + @return The value written back to the MMIO register. + +**/ +UINT16 +EFIAPI +MmioOr16 ( + IN UINTN Address, + IN UINT16 OrData + ) +{ + return MmioWrite16 (Address, MmioRead16 (Address) | OrData); +} + +/** + Reads a 16-bit MMIO register, performs a bitwise AND, and writes the result + back to the 16-bit MMIO register. + + Reads the 16-bit MMIO register specified by Address, performs a bitwise AND + between the read result and the value specified by AndData, and writes the + result to the 16-bit MMIO register specified by Address. The value written to + the MMIO register is returned. This function must guarantee that all MMIO + read and write operations are serialized. + + If 16-bit MMIO register operations are not supported, then ASSERT(). + + @param Address The MMIO register to write. + @param AndData The value to AND with the read value from the MMIO register. + + @return The value written back to the MMIO register. + +**/ +UINT16 +EFIAPI +MmioAnd16 ( + IN UINTN Address, + IN UINT16 AndData + ) +{ + return MmioWrite16 (Address, MmioRead16 (Address) & AndData); +} + +/** + Reads a 16-bit MMIO register, performs a bitwise AND followed by a bitwise + inclusive OR, and writes the result back to the 16-bit MMIO register. + + Reads the 16-bit MMIO register specified by Address, performs a bitwise AND + between the read result and the value specified by AndData, performs a + bitwise OR between the result of the AND operation and the value specified by + OrData, and writes the result to the 16-bit MMIO register specified by + Address. The value written to the MMIO register is returned. This function + must guarantee that all MMIO read and write operations are serialized. + + If 16-bit MMIO register operations are not supported, then ASSERT(). + + + @param Address The MMIO register to write. + @param AndData The value to AND with the read value from the MMIO register. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the MMIO register. + +**/ +UINT16 +EFIAPI +MmioAndThenOr16 ( + IN UINTN Address, + IN UINT16 AndData, + IN UINT16 OrData + ) +{ + return MmioWrite16 (Address, (MmioRead16 (Address) & AndData) | OrData); +} + +/** + Reads a bit field of a MMIO register. + + Reads the bit field in a 16-bit MMIO register. The bit field is specified by + the StartBit and the EndBit. The value of the bit field is returned. + + If 16-bit MMIO register operations are not supported, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address MMIO register to read. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..15. + + @return The value read. + +**/ +UINT16 +EFIAPI +MmioBitFieldRead16 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit + ) +{ + return BitFieldRead16 (MmioRead16 (Address), StartBit, EndBit); +} + +/** + Writes a bit field to a MMIO register. + + Writes Value to the bit field of the MMIO register. The bit field is + specified by the StartBit and the EndBit. All other bits in the destination + MMIO register are preserved. The new value of the 16-bit register is returned. + + If 16-bit MMIO register operations are not supported, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address MMIO register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..15. + @param Value New value of the bit field. + + @return The value written back to the MMIO register. + +**/ +UINT16 +EFIAPI +MmioBitFieldWrite16 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT16 Value + ) +{ + return MmioWrite16 ( + Address, + BitFieldWrite16 (MmioRead16 (Address), StartBit, EndBit, Value) + ); +} + +/** + Reads a bit field in a 16-bit MMIO register, performs a bitwise OR, and + writes the result back to the bit field in the 16-bit MMIO register. + + Reads the 16-bit MMIO register specified by Address, performs a bitwise + inclusive OR between the read result and the value specified by OrData, and + writes the result to the 16-bit MMIO register specified by Address. The value + written to the MMIO register is returned. This function must guarantee that + all MMIO read and write operations are serialized. Extra left bits in OrData + are stripped. + + If 16-bit MMIO register operations are not supported, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address MMIO register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..15. + @param OrData The value to OR with read value from the MMIO register. + + @return The value written back to the MMIO register. + +**/ +UINT16 +EFIAPI +MmioBitFieldOr16 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT16 OrData + ) +{ + return MmioWrite16 ( + Address, + BitFieldOr16 (MmioRead16 (Address), StartBit, EndBit, OrData) + ); +} + +/** + Reads a bit field in a 16-bit MMIO register, performs a bitwise AND, and + writes the result back to the bit field in the 16-bit MMIO register. + + Reads the 16-bit MMIO register specified by Address, performs a bitwise AND + between the read result and the value specified by AndData, and writes the + result to the 16-bit MMIO register specified by Address. The value written to + the MMIO register is returned. This function must guarantee that all MMIO + read and write operations are serialized. Extra left bits in AndData are + stripped. + + If 16-bit MMIO register operations are not supported, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address MMIO register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..15. + @param AndData The value to AND with read value from the MMIO register. + + @return The value written back to the MMIO register. + +**/ +UINT16 +EFIAPI +MmioBitFieldAnd16 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT16 AndData + ) +{ + return MmioWrite16 ( + Address, + BitFieldAnd16 (MmioRead16 (Address), StartBit, EndBit, AndData) + ); +} + +/** + Reads a bit field in a 16-bit MMIO register, performs a bitwise AND followed + by a bitwise inclusive OR, and writes the result back to the bit field in the + 16-bit MMIO register. + + Reads the 16-bit MMIO register specified by Address, performs a bitwise AND + followed by a bitwise inclusive OR between the read result and the value + specified by AndData, and writes the result to the 16-bit MMIO register + specified by Address. The value written to the MMIO register is returned. + This function must guarantee that all MMIO read and write operations are + serialized. Extra left bits in both AndData and OrData are stripped. + + If 16-bit MMIO register operations are not supported, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address MMIO register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..15. + @param AndData The value to AND with read value from the MMIO register. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the MMIO register. + +**/ +UINT16 +EFIAPI +MmioBitFieldAndThenOr16 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT16 AndData, + IN UINT16 OrData + ) +{ + return MmioWrite16 ( + Address, + BitFieldAndThenOr16 (MmioRead16 (Address), StartBit, EndBit, AndData, OrData) + ); +} + +/** + Reads a 32-bit MMIO register, performs a bitwise inclusive OR, and writes the + result back to the 32-bit MMIO register. + + Reads the 32-bit MMIO register specified by Address, performs a bitwise + inclusive OR between the read result and the value specified by OrData, and + writes the result to the 32-bit MMIO register specified by Address. The value + written to the MMIO register is returned. This function must guarantee that + all MMIO read and write operations are serialized. + + If 32-bit MMIO register operations are not supported, then ASSERT(). + + @param Address The MMIO register to write. + @param OrData The value to OR with the read value from the MMIO register. + + @return The value written back to the MMIO register. + +**/ +UINT32 +EFIAPI +MmioOr32 ( + IN UINTN Address, + IN UINT32 OrData + ) +{ + return MmioWrite32 (Address, MmioRead32 (Address) | OrData); +} + +/** + Reads a 32-bit MMIO register, performs a bitwise AND, and writes the result + back to the 32-bit MMIO register. + + Reads the 32-bit MMIO register specified by Address, performs a bitwise AND + between the read result and the value specified by AndData, and writes the + result to the 32-bit MMIO register specified by Address. The value written to + the MMIO register is returned. This function must guarantee that all MMIO + read and write operations are serialized. + + If 32-bit MMIO register operations are not supported, then ASSERT(). + + @param Address The MMIO register to write. + @param AndData The value to AND with the read value from the MMIO register. + + @return The value written back to the MMIO register. + +**/ +UINT32 +EFIAPI +MmioAnd32 ( + IN UINTN Address, + IN UINT32 AndData + ) +{ + return MmioWrite32 (Address, MmioRead32 (Address) & AndData); +} + +/** + Reads a 32-bit MMIO register, performs a bitwise AND followed by a bitwise + inclusive OR, and writes the result back to the 32-bit MMIO register. + + Reads the 32-bit MMIO register specified by Address, performs a bitwise AND + between the read result and the value specified by AndData, performs a + bitwise OR between the result of the AND operation and the value specified by + OrData, and writes the result to the 32-bit MMIO register specified by + Address. The value written to the MMIO register is returned. This function + must guarantee that all MMIO read and write operations are serialized. + + If 32-bit MMIO register operations are not supported, then ASSERT(). + + + @param Address The MMIO register to write. + @param AndData The value to AND with the read value from the MMIO register. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the MMIO register. + +**/ +UINT32 +EFIAPI +MmioAndThenOr32 ( + IN UINTN Address, + IN UINT32 AndData, + IN UINT32 OrData + ) +{ + return MmioWrite32 (Address, (MmioRead32 (Address) & AndData) | OrData); +} + +/** + Reads a bit field of a MMIO register. + + Reads the bit field in a 32-bit MMIO register. The bit field is specified by + the StartBit and the EndBit. The value of the bit field is returned. + + If 32-bit MMIO register operations are not supported, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address MMIO register to read. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + + @return The value read. + +**/ +UINT32 +EFIAPI +MmioBitFieldRead32 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit + ) +{ + return BitFieldRead32 (MmioRead32 (Address), StartBit, EndBit); +} + +/** + Writes a bit field to a MMIO register. + + Writes Value to the bit field of the MMIO register. The bit field is + specified by the StartBit and the EndBit. All other bits in the destination + MMIO register are preserved. The new value of the 32-bit register is returned. + + If 32-bit MMIO register operations are not supported, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address MMIO register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + @param Value New value of the bit field. + + @return The value written back to the MMIO register. + +**/ +UINT32 +EFIAPI +MmioBitFieldWrite32 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT32 Value + ) +{ + return MmioWrite32 ( + Address, + BitFieldWrite32 (MmioRead32 (Address), StartBit, EndBit, Value) + ); +} + +/** + Reads a bit field in a 32-bit MMIO register, performs a bitwise OR, and + writes the result back to the bit field in the 32-bit MMIO register. + + Reads the 32-bit MMIO register specified by Address, performs a bitwise + inclusive OR between the read result and the value specified by OrData, and + writes the result to the 32-bit MMIO register specified by Address. The value + written to the MMIO register is returned. This function must guarantee that + all MMIO read and write operations are serialized. Extra left bits in OrData + are stripped. + + If 32-bit MMIO register operations are not supported, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address MMIO register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + @param OrData The value to OR with read value from the MMIO register. + + @return The value written back to the MMIO register. + +**/ +UINT32 +EFIAPI +MmioBitFieldOr32 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT32 OrData + ) +{ + return MmioWrite32 ( + Address, + BitFieldOr32 (MmioRead32 (Address), StartBit, EndBit, OrData) + ); +} + +/** + Reads a bit field in a 32-bit MMIO register, performs a bitwise AND, and + writes the result back to the bit field in the 32-bit MMIO register. + + Reads the 32-bit MMIO register specified by Address, performs a bitwise AND + between the read result and the value specified by AndData, and writes the + result to the 32-bit MMIO register specified by Address. The value written to + the MMIO register is returned. This function must guarantee that all MMIO + read and write operations are serialized. Extra left bits in AndData are + stripped. + + If 32-bit MMIO register operations are not supported, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address MMIO register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + @param AndData The value to AND with read value from the MMIO register. + + @return The value written back to the MMIO register. + +**/ +UINT32 +EFIAPI +MmioBitFieldAnd32 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT32 AndData + ) +{ + return MmioWrite32 ( + Address, + BitFieldAnd32 (MmioRead32 (Address), StartBit, EndBit, AndData) + ); +} + +/** + Reads a bit field in a 32-bit MMIO register, performs a bitwise AND followed + by a bitwise inclusive OR, and writes the result back to the bit field in the + 32-bit MMIO register. + + Reads the 32-bit MMIO register specified by Address, performs a bitwise AND + followed by a bitwise inclusive OR between the read result and the value + specified by AndData, and writes the result to the 32-bit MMIO register + specified by Address. The value written to the MMIO register is returned. + This function must guarantee that all MMIO read and write operations are + serialized. Extra left bits in both AndData and OrData are stripped. + + If 32-bit MMIO register operations are not supported, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address MMIO register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + @param AndData The value to AND with read value from the MMIO register. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the MMIO register. + +**/ +UINT32 +EFIAPI +MmioBitFieldAndThenOr32 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT32 AndData, + IN UINT32 OrData + ) +{ + return MmioWrite32 ( + Address, + BitFieldAndThenOr32 (MmioRead32 (Address), StartBit, EndBit, AndData, OrData) + ); +} + +/** + Reads a 64-bit MMIO register, performs a bitwise inclusive OR, and writes the + result back to the 64-bit MMIO register. + + Reads the 64-bit MMIO register specified by Address, performs a bitwise + inclusive OR between the read result and the value specified by OrData, and + writes the result to the 64-bit MMIO register specified by Address. The value + written to the MMIO register is returned. This function must guarantee that + all MMIO read and write operations are serialized. + + If 64-bit MMIO register operations are not supported, then ASSERT(). + + @param Address The MMIO register to write. + @param OrData The value to OR with the read value from the MMIO register. + + @return The value written back to the MMIO register. + +**/ +UINT64 +EFIAPI +MmioOr64 ( + IN UINTN Address, + IN UINT64 OrData + ) +{ + return MmioWrite64 (Address, MmioRead64 (Address) | OrData); +} + +/** + Reads a 64-bit MMIO register, performs a bitwise AND, and writes the result + back to the 64-bit MMIO register. + + Reads the 64-bit MMIO register specified by Address, performs a bitwise AND + between the read result and the value specified by AndData, and writes the + result to the 64-bit MMIO register specified by Address. The value written to + the MMIO register is returned. This function must guarantee that all MMIO + read and write operations are serialized. + + If 64-bit MMIO register operations are not supported, then ASSERT(). + + @param Address The MMIO register to write. + @param AndData The value to AND with the read value from the MMIO register. + + @return The value written back to the MMIO register. + +**/ +UINT64 +EFIAPI +MmioAnd64 ( + IN UINTN Address, + IN UINT64 AndData + ) +{ + return MmioWrite64 (Address, MmioRead64 (Address) & AndData); +} + +/** + Reads a 64-bit MMIO register, performs a bitwise AND followed by a bitwise + inclusive OR, and writes the result back to the 64-bit MMIO register. + + Reads the 64-bit MMIO register specified by Address, performs a bitwise AND + between the read result and the value specified by AndData, performs a + bitwise OR between the result of the AND operation and the value specified by + OrData, and writes the result to the 64-bit MMIO register specified by + Address. The value written to the MMIO register is returned. This function + must guarantee that all MMIO read and write operations are serialized. + + If 64-bit MMIO register operations are not supported, then ASSERT(). + + + @param Address The MMIO register to write. + @param AndData The value to AND with the read value from the MMIO register. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the MMIO register. + +**/ +UINT64 +EFIAPI +MmioAndThenOr64 ( + IN UINTN Address, + IN UINT64 AndData, + IN UINT64 OrData + ) +{ + return MmioWrite64 (Address, (MmioRead64 (Address) & AndData) | OrData); +} + +/** + Reads a bit field of a MMIO register. + + Reads the bit field in a 64-bit MMIO register. The bit field is specified by + the StartBit and the EndBit. The value of the bit field is returned. + + If 64-bit MMIO register operations are not supported, then ASSERT(). + If StartBit is greater than 63, then ASSERT(). + If EndBit is greater than 63, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address MMIO register to read. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..63. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..63. + + @return The value read. + +**/ +UINT64 +EFIAPI +MmioBitFieldRead64 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit + ) +{ + return BitFieldRead64 (MmioRead64 (Address), StartBit, EndBit); +} + +/** + Writes a bit field to a MMIO register. + + Writes Value to the bit field of the MMIO register. The bit field is + specified by the StartBit and the EndBit. All other bits in the destination + MMIO register are preserved. The new value of the 64-bit register is returned. + + If 64-bit MMIO register operations are not supported, then ASSERT(). + If StartBit is greater than 63, then ASSERT(). + If EndBit is greater than 63, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address MMIO register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..63. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..63. + @param Value New value of the bit field. + + @return The value written back to the MMIO register. + +**/ +UINT64 +EFIAPI +MmioBitFieldWrite64 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT64 Value + ) +{ + return MmioWrite64 ( + Address, + BitFieldWrite64 (MmioRead64 (Address), StartBit, EndBit, Value) + ); +} + +/** + Reads a bit field in a 64-bit MMIO register, performs a bitwise OR, and + writes the result back to the bit field in the 64-bit MMIO register. + + Reads the 64-bit MMIO register specified by Address, performs a bitwise + inclusive OR between the read result and the value specified by OrData, and + writes the result to the 64-bit MMIO register specified by Address. The value + written to the MMIO register is returned. This function must guarantee that + all MMIO read and write operations are serialized. Extra left bits in OrData + are stripped. + + If 64-bit MMIO register operations are not supported, then ASSERT(). + If StartBit is greater than 63, then ASSERT(). + If EndBit is greater than 63, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address MMIO register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..63. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..63. + @param OrData The value to OR with read value from the MMIO register. + + @return The value written back to the MMIO register. + +**/ +UINT64 +EFIAPI +MmioBitFieldOr64 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT64 OrData + ) +{ + return MmioWrite64 ( + Address, + BitFieldOr64 (MmioRead64 (Address), StartBit, EndBit, OrData) + ); +} + +/** + Reads a bit field in a 64-bit MMIO register, performs a bitwise AND, and + writes the result back to the bit field in the 64-bit MMIO register. + + Reads the 64-bit MMIO register specified by Address, performs a bitwise AND + between the read result and the value specified by AndData, and writes the + result to the 64-bit MMIO register specified by Address. The value written to + the MMIO register is returned. This function must guarantee that all MMIO + read and write operations are serialized. Extra left bits in AndData are + stripped. + + If 64-bit MMIO register operations are not supported, then ASSERT(). + If StartBit is greater than 63, then ASSERT(). + If EndBit is greater than 63, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address MMIO register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..63. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..63. + @param AndData The value to AND with read value from the MMIO register. + + @return The value written back to the MMIO register. + +**/ +UINT64 +EFIAPI +MmioBitFieldAnd64 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT64 AndData + ) +{ + return MmioWrite64 ( + Address, + BitFieldAnd64 (MmioRead64 (Address), StartBit, EndBit, AndData) + ); +} + +/** + Reads a bit field in a 64-bit MMIO register, performs a bitwise AND followed + by a bitwise inclusive OR, and writes the result back to the bit field in the + 64-bit MMIO register. + + Reads the 64-bit MMIO register specified by Address, performs a bitwise AND + followed by a bitwise inclusive OR between the read result and the value + specified by AndData, and writes the result to the 64-bit MMIO register + specified by Address. The value written to the MMIO register is returned. + This function must guarantee that all MMIO read and write operations are + serialized. Extra left bits in both AndData and OrData are stripped. + + If 64-bit MMIO register operations are not supported, then ASSERT(). + If StartBit is greater than 63, then ASSERT(). + If EndBit is greater than 63, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address MMIO register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..63. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..63. + @param AndData The value to AND with read value from the MMIO register. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the MMIO register. + +**/ +UINT64 +EFIAPI +MmioBitFieldAndThenOr64 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT64 AndData, + IN UINT64 OrData + ) +{ + return MmioWrite64 ( + Address, + BitFieldAndThenOr64 (MmioRead64 (Address), StartBit, EndBit, AndData, OrData) + ); +} diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseIoLibIntrinsic/IoLib.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseIoLibIntrinsic/IoLib.c new file mode 100644 index 0000000..b56f2cb --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseIoLibIntrinsic/IoLib.c @@ -0,0 +1,74 @@ +/*++ + +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: + + IoLib.c + +Abstract: + + Common I/O Library routines. + +--*/ + +#include "EdkIIGlueBase.h" + +/** + Reads a 64-bit I/O port. + + Reads the 64-bit I/O port specified by Port. The 64-bit read value is returned. + This function must guarantee that all I/O read and write operations are + serialized. + + If 64-bit I/O port operations are not supported, then ASSERT(). + + @param Port The I/O port to read. + + @return The value read. + +**/ +UINT64 +EFIAPI +IoRead64 ( + IN UINTN Port + ) +{ + ASSERT (FALSE); + return 0; +} + +/** + Writes a 64-bit I/O port. + + Writes the 64-bit I/O port specified by Port with the value specified by Value + and returns Value. This function must guarantee that all I/O read and write + operations are serialized. + + If 64-bit I/O port operations are not supported, then ASSERT(). + + @param Port The I/O port to write. + @param Value The value to write to the I/O port. + + @return The value written the I/O port. + +**/ +UINT64 +EFIAPI +IoWrite64 ( + IN UINTN Port, + IN UINT64 Value + ) +{ + ASSERT (FALSE); + return 0; +} + diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseIoLibIntrinsic/IoLibMsc.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseIoLibIntrinsic/IoLibMsc.c new file mode 100644 index 0000000..ea3eafb --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseIoLibIntrinsic/IoLibMsc.c @@ -0,0 +1,436 @@ +/*++ + +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: + + IoLibMsc.c + +Abstract: + + I/O Library. This file has compiler specifics for Microsft C as there is no + ANSI C standard for doing IO. + + MSC - uses intrinsic functions and the optimize will remove the function call + overhead. + + We don't advocate putting compiler specifics in libraries or drivers but there + is no other way to make this work. + +--*/ + +#include "EdkIIGlueBase.h" + +#if _MSC_EXTENSIONS + +// +// Microsoft Visual Studio 7.1 Function Prototypes for I/O Intrinsics +// +int _inp (unsigned short port); +unsigned short _inpw (unsigned short port); +unsigned long _inpd (unsigned short port); +int _outp (unsigned short port, int databyte ); +unsigned short _outpw (unsigned short port, unsigned short dataword ); +unsigned long _outpd (unsigned short port, unsigned long dataword ); +void _ReadWriteBarrier (void); + +#pragma intrinsic(_inp) +#pragma intrinsic(_inpw) +#pragma intrinsic(_inpd) +#pragma intrinsic(_outp) +#pragma intrinsic(_outpw) +#pragma intrinsic(_outpd) +#pragma intrinsic(_ReadWriteBarrier) + +// +// _ReadWriteBarrier() forces memory reads and writes to complete at the point +// in the call. This is only a hint to the compiler and does emit code. +// In past versions of the compiler, _ReadWriteBarrier was enforced only +// locally and did not affect functions up the call tree. In Visual C++ +// 2005, _ReadWriteBarrier is enforced all the way up the call tree. +// + +/** + Reads an 8-bit I/O port. + + Reads the 8-bit I/O port specified by Port. The 8-bit read value is returned. + This function must guarantee that all I/O read and write operations are + serialized. + + If 8-bit I/O port operations are not supported, then ASSERT(). + + @param Port The I/O port to read. + + @return The value read. + +**/ +UINT8 +EFIAPI +GlueIoRead8 ( + IN UINTN Port + ) +{ + UINT8 Value; + + _ReadWriteBarrier (); + Value = (UINT8)_inp ((UINT16)Port); + _ReadWriteBarrier (); + return Value; +} + +/** + Writes an 8-bit I/O port. + + Writes the 8-bit I/O port specified by Port with the value specified by Value + and returns Value. This function must guarantee that all I/O read and write + operations are serialized. + + If 8-bit I/O port operations are not supported, then ASSERT(). + + @param Port The I/O port to write. + @param Value The value to write to the I/O port. + + @return The value written the I/O port. + +**/ +UINT8 +EFIAPI +GlueIoWrite8 ( + IN UINTN Port, + IN UINT8 Value + ) +{ + _ReadWriteBarrier (); + (UINT8)_outp ((UINT16)Port, Value); + _ReadWriteBarrier (); + return Value; +} + +/** + Reads a 16-bit I/O port. + + Reads the 16-bit I/O port specified by Port. The 16-bit read value is returned. + This function must guarantee that all I/O read and write operations are + serialized. + + If 16-bit I/O port operations are not supported, then ASSERT(). + + @param Port The I/O port to read. + + @return The value read. + +**/ +UINT16 +EFIAPI +GlueIoRead16 ( + IN UINTN Port + ) +{ + UINT16 Value; + + ASSERT ((Port & 1) == 0); + _ReadWriteBarrier (); + Value = _inpw ((UINT16)Port); + _ReadWriteBarrier (); + return Value; +} + +/** + Writes a 16-bit I/O port. + + Writes the 16-bit I/O port specified by Port with the value specified by Value + and returns Value. This function must guarantee that all I/O read and write + operations are serialized. + + If 16-bit I/O port operations are not supported, then ASSERT(). + + @param Port The I/O port to write. + @param Value The value to write to the I/O port. + + @return The value written the I/O port. + +**/ +UINT16 +EFIAPI +GlueIoWrite16 ( + IN UINTN Port, + IN UINT16 Value + ) +{ + ASSERT ((Port & 1) == 0); + _ReadWriteBarrier (); + _outpw ((UINT16)Port, Value); + _ReadWriteBarrier (); + return Value; +} + +/** + Reads a 32-bit I/O port. + + Reads the 32-bit I/O port specified by Port. The 32-bit read value is returned. + This function must guarantee that all I/O read and write operations are + serialized. + + If 32-bit I/O port operations are not supported, then ASSERT(). + + @param Port The I/O port to read. + + @return The value read. + +**/ +UINT32 +EFIAPI +GlueIoRead32 ( + IN UINTN Port + ) +{ + UINT32 Value; + + ASSERT ((Port & 3) == 0); + _ReadWriteBarrier (); + Value = _inpd ((UINT16)Port); + _ReadWriteBarrier (); + return Value; +} + +/** + Writes a 32-bit I/O port. + + Writes the 32-bit I/O port specified by Port with the value specified by Value + and returns Value. This function must guarantee that all I/O read and write + operations are serialized. + + If 32-bit I/O port operations are not supported, then ASSERT(). + + @param Port The I/O port to write. + @param Value The value to write to the I/O port. + + @return The value written the I/O port. + +**/ +UINT32 +EFIAPI +GlueIoWrite32 ( + IN UINTN Port, + IN UINT32 Value + ) +{ + ASSERT ((Port & 3) == 0); + _ReadWriteBarrier (); + _outpd ((UINT16)Port, Value); + _ReadWriteBarrier (); + return Value; +} + + +/** + Reads an 8-bit MMIO register. + + Reads the 8-bit MMIO register specified by Address. The 8-bit read value is + returned. This function must guarantee that all MMIO read and write + operations are serialized. + + If 8-bit MMIO register operations are not supported, then ASSERT(). + + @param Address The MMIO register to read. + + @return The value read. + +**/ +UINT8 +EFIAPI +MmioRead8 ( + IN UINTN Address + ) +{ + UINT8 Value; + + Value = *(volatile UINT8*)Address; + return Value; +} + +/** + Writes an 8-bit MMIO register. + + Writes the 8-bit MMIO register specified by Address with the value specified + by Value and returns Value. This function must guarantee that all MMIO read + and write operations are serialized. + + If 8-bit MMIO register operations are not supported, then ASSERT(). + + @param Address The MMIO register to write. + @param Value The value to write to the MMIO register. + +**/ +UINT8 +EFIAPI +MmioWrite8 ( + IN UINTN Address, + IN UINT8 Value + ) +{ + return *(volatile UINT8*)Address = Value; +} + +/** + Reads a 16-bit MMIO register. + + Reads the 16-bit MMIO register specified by Address. The 16-bit read value is + returned. This function must guarantee that all MMIO read and write + operations are serialized. + + If 16-bit MMIO register operations are not supported, then ASSERT(). + + @param Address The MMIO register to read. + + @return The value read. + +**/ +UINT16 +EFIAPI +MmioRead16 ( + IN UINTN Address + ) +{ + UINT16 Value; + + ASSERT ((Address & 1) == 0); + Value = *(volatile UINT16*)Address; + return Value; +} + +/** + Writes a 16-bit MMIO register. + + Writes the 16-bit MMIO register specified by Address with the value specified + by Value and returns Value. This function must guarantee that all MMIO read + and write operations are serialized. + + If 16-bit MMIO register operations are not supported, then ASSERT(). + + @param Address The MMIO register to write. + @param Value The value to write to the MMIO register. + +**/ +UINT16 +EFIAPI +MmioWrite16 ( + IN UINTN Address, + IN UINT16 Value + ) +{ + ASSERT ((Address & 1) == 0); + return *(volatile UINT16*)Address = Value; +} + +/** + Reads a 32-bit MMIO register. + + Reads the 32-bit MMIO register specified by Address. The 32-bit read value is + returned. This function must guarantee that all MMIO read and write + operations are serialized. + + If 32-bit MMIO register operations are not supported, then ASSERT(). + + @param Address The MMIO register to read. + + @return The value read. + +**/ +UINT32 +EFIAPI +MmioRead32 ( + IN UINTN Address + ) +{ + UINT32 Value; + + ASSERT ((Address & 3) == 0); + Value = *(volatile UINT32*)Address; + return Value; +} + +/** + Writes a 32-bit MMIO register. + + Writes the 32-bit MMIO register specified by Address with the value specified + by Value and returns Value. This function must guarantee that all MMIO read + and write operations are serialized. + + If 32-bit MMIO register operations are not supported, then ASSERT(). + + @param Address The MMIO register to write. + @param Value The value to write to the MMIO register. + +**/ +UINT32 +EFIAPI +MmioWrite32 ( + IN UINTN Address, + IN UINT32 Value + ) +{ + ASSERT ((Address & 3) == 0); + return *(volatile UINT32*)Address = Value; +} + +/** + Reads a 64-bit MMIO register. + + Reads the 64-bit MMIO register specified by Address. The 64-bit read value is + returned. This function must guarantee that all MMIO read and write + operations are serialized. + + If 64-bit MMIO register operations are not supported, then ASSERT(). + + @param Address The MMIO register to read. + + @return The value read. + +**/ +UINT64 +EFIAPI +MmioRead64 ( + IN UINTN Address + ) +{ + UINT64 Value; + + ASSERT ((Address & 7) == 0); + Value = *(volatile UINT64*)Address; + return Value; +} + +/** + Writes a 64-bit MMIO register. + + Writes the 64-bit MMIO register specified by Address with the value specified + by Value and returns Value. This function must guarantee that all MMIO read + and write operations are serialized. + + If 64-bit MMIO register operations are not supported, then ASSERT(). + + @param Address The MMIO register to write. + @param Value The value to write to the MMIO register. + +**/ +UINT64 +EFIAPI +MmioWrite64 ( + IN UINTN Address, + IN UINT64 Value + ) +{ + ASSERT ((Address & 7) == 0); + return *(volatile UINT64*)Address = Value; +} + +#endif diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/ARShiftU64.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/ARShiftU64.c new file mode 100644 index 0000000..5f57b9d --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/ARShiftU64.c @@ -0,0 +1,49 @@ +/*++ + +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: + + ARShiftU64.c + +Abstract: + + Math worker functions. + +--*/ + +#include "BaseLibInternal.h" + +/** + Shifts a 64-bit integer right between 0 and 63 bits. The high bits are filled + with original integer's bit 63. The shifted value is returned. + + This function shifts the 64-bit value Operand to the right by Count bits. The + high Count bits are set to bit 63 of Operand. The shifted value is returned. + + If Count is greater than 63, then ASSERT(). + + @param Operand The 64-bit operand to shift right. + @param Count The number of bits to shift right. + + @return Operand arithmetically shifted right by Count + +**/ +UINT64 +EFIAPI +ARShiftU64 ( + IN UINT64 Operand, + IN UINTN Count + ) +{ + ASSERT (Count < sizeof (Operand) * 8); + return InternalMathARShiftU64 (Operand, Count); +} diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/BaseLib.inf b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/BaseLib.inf new file mode 100644 index 0000000..824cdfd --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/BaseLib.inf @@ -0,0 +1,335 @@ +#/*++ +# +# 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: +# +# BaseLib.inf +# +# Abstract: +# +# Component description file for BaseLib. +# +#--*/ + +[defines] +BASE_NAME = EdkIIGlueBaseLib +COMPONENT_TYPE = LIBRARY + +[sources.common] + String.c + LinkedList.c + Synchronization.c + Cpu.c + CpuDeadLoop.c + BitField.c + ARShiftU64.c + DivS64x64Remainder.c + DivU64x32.c + DivU64x32Remainder.c + DivU64x64Remainder.c + GetPowerOfTwo32.c + GetPowerOfTwo64.c + HighBitSet32.c + HighBitSet64.c + LowBitSet32.c + LowBitSet64.c + LRotU32.c + LRotU64.c + LShiftU64.c + ModU64x32.c + MultS64x64.c + MultU64x32.c + MultU64x64.c + RRotU32.c + RRotU64.c + RShiftU64.c + SetJump.c + LongJump.c + SwapBytes16.c + SwapBytes32.c + SwapBytes64.c + SwitchStack.c + +[sources.ia32] + x86DisablePaging32.c + x86DisablePaging64.c + x86EnablePaging32.c + x86EnablePaging64.c + x86FxRestore.c + x86FxSave.c + x86GetInterruptState.c + x86MemoryFence.c + x86Msr.c + x86ReadGdtr.c + x86ReadIdtr.c + x86Thunk.c + x86WriteGdtr.c + x86WriteIdtr.c + Unaligned.c + Ia32\Non-existing.c + Ia32\InternalSwitchStack.c + Ia32\LShiftU64.asm + Ia32\RShiftU64.asm + Ia32\ARShiftU64.asm + Ia32\LRotU64.asm + Ia32\RRotU64.asm + Ia32\MultU64x32.asm + Ia32\MultU64x64.asm + Ia32\DivU64x32.asm + Ia32\ModU64x32.asm + Ia32\DivU64x32Remainder.asm + Ia32\DivU64x64Remainder.asm + Ia32\DivS64x64Remainder.c + Ia32\SwapBytes64.asm + Ia32\SetJump.asm + Ia32\LongJump.asm + Ia32\CpuId.asm + Ia32\CpuIdEx.asm + Ia32\ReadEflags.asm + Ia32\ReadMsr64.asm + Ia32\WriteMsr64.asm + Ia32\ReadCr0.asm + Ia32\ReadCr2.asm + Ia32\ReadCr3.asm + Ia32\ReadCr4.asm + Ia32\WriteCr0.asm + Ia32\WriteCr2.asm + Ia32\WriteCr3.asm + Ia32\WriteCr4.asm + Ia32\ReadDr0.asm + Ia32\ReadDr1.asm + Ia32\ReadDr2.asm + Ia32\ReadDr3.asm + Ia32\ReadDr4.asm + Ia32\ReadDr5.asm + Ia32\ReadDr6.asm + Ia32\ReadDr7.asm + Ia32\WriteDr0.asm + Ia32\WriteDr1.asm + Ia32\WriteDr2.asm + Ia32\WriteDr3.asm + Ia32\WriteDr4.asm + Ia32\WriteDr5.asm + Ia32\WriteDr6.asm + Ia32\WriteDr7.asm + Ia32\ReadCs.asm + Ia32\ReadDs.asm + Ia32\ReadEs.asm + Ia32\ReadFs.asm + Ia32\ReadGs.asm + Ia32\ReadSs.asm + Ia32\ReadTr.asm + Ia32\ReadGdtr.asm + Ia32\WriteGdtr.asm + Ia32\ReadIdtr.asm + Ia32\WriteIdtr.asm + Ia32\ReadLdtr.asm + Ia32\WriteLdtr.asm + Ia32\FxSave.asm + Ia32\FxRestore.asm + Ia32\ReadMm0.asm + Ia32\ReadMm1.asm + Ia32\ReadMm2.asm + Ia32\ReadMm3.asm + Ia32\ReadMm4.asm + Ia32\ReadMm5.asm + Ia32\ReadMm6.asm + Ia32\ReadMm7.asm + Ia32\WriteMm0.asm + Ia32\WriteMm1.asm + Ia32\WriteMm2.asm + Ia32\WriteMm3.asm + Ia32\WriteMm4.asm + Ia32\WriteMm5.asm + Ia32\WriteMm6.asm + Ia32\WriteMm7.asm + Ia32\ReadTsc.asm + Ia32\ReadPmc.asm + Ia32\Monitor.asm + Ia32\Mwait.asm + Ia32\EnablePaging32.asm + Ia32\DisablePaging32.asm + Ia32\EnablePaging64.asm + Ia32\Wbinvd.asm + Ia32\Invd.asm + Ia32\FlushCacheLine.asm + Ia32\InterlockedIncrement.asm + Ia32\InterlockedDecrement.asm + Ia32\InterlockedCompareExchange32.asm + Ia32\InterlockedCompareExchange64.asm + Ia32\EnableInterrupts.asm + Ia32\DisableInterrupts.asm + Ia32\EnableDisableInterrupts.asm + Ia32\CpuSleep.asm + Ia32\CpuPause.asm + Ia32\CpuBreakpoint.asm + Ia32\CpuFlushTlb.asm + Ia32\Thunk16.asm + +[sources.x64] + x86DisablePaging32.c + x86DisablePaging64.c + x86EnablePaging32.c + x86EnablePaging64.c + x86FxRestore.c + x86FxSave.c + x86GetInterruptState.c + x86MemoryFence.c + x86Msr.c + x86ReadGdtr.c + x86ReadIdtr.c + x86Thunk.c + x86WriteGdtr.c + x86WriteIdtr.c + Unaligned.c + Math64.c + X64\Non-existing.c + X64\SwitchStack.asm + X64\SetJump.asm + X64\LongJump.asm + X64\CpuId.asm + X64\CpuIdEx.asm + X64\ReadEflags.asm + X64\ReadMsr64.asm + X64\WriteMsr64.asm + X64\ReadCr0.asm + X64\ReadCr2.asm + X64\ReadCr3.asm + X64\ReadCr4.asm + X64\WriteCr0.asm + X64\WriteCr2.asm + X64\WriteCr3.asm + X64\WriteCr4.asm + X64\ReadDr0.asm + X64\ReadDr1.asm + X64\ReadDr2.asm + X64\ReadDr3.asm + X64\ReadDr4.asm + X64\ReadDr5.asm + X64\ReadDr6.asm + X64\ReadDr7.asm + X64\WriteDr0.asm + X64\WriteDr1.asm + X64\WriteDr2.asm + X64\WriteDr3.asm + X64\WriteDr4.asm + X64\WriteDr5.asm + X64\WriteDr6.asm + X64\WriteDr7.asm + X64\ReadCs.asm + X64\ReadDs.asm + X64\ReadEs.asm + X64\ReadFs.asm + X64\ReadGs.asm + X64\ReadSs.asm + X64\ReadTr.asm + X64\ReadGdtr.asm + X64\WriteGdtr.asm + X64\ReadIdtr.asm + X64\WriteIdtr.asm + X64\ReadLdtr.asm + X64\WriteLdtr.asm + X64\FxSave.asm + X64\FxRestore.asm + X64\ReadMm0.asm + X64\ReadMm1.asm + X64\ReadMm2.asm + X64\ReadMm3.asm + X64\ReadMm4.asm + X64\ReadMm5.asm + X64\ReadMm6.asm + X64\ReadMm7.asm + X64\WriteMm0.asm + X64\WriteMm1.asm + X64\WriteMm2.asm + X64\WriteMm3.asm + X64\WriteMm4.asm + X64\WriteMm5.asm + X64\WriteMm6.asm + X64\WriteMm7.asm + X64\ReadTsc.asm + X64\ReadPmc.asm + X64\Monitor.asm + X64\Mwait.asm + X64\EnablePaging64.asm + X64\DisablePaging64.asm + X64\Wbinvd.asm + X64\Invd.asm + X64\FlushCacheLine.asm + X64\InterlockedIncrement.asm + X64\InterlockedDecrement.asm + X64\InterlockedCompareExchange32.asm + X64\InterlockedCompareExchange64.asm + X64\EnableInterrupts.asm + X64\DisableInterrupts.asm + X64\EnableDisableInterrupts.asm + X64\CpuSleep.asm + X64\CpuPause.asm + X64\CpuBreakpoint.asm + X64\CpuFlushTlb.asm + X64\Thunk16.asm + +[sources.ipf] + +[sources.ebc] + + +[includes.common] + . + ..\..\Include + ..\..\Include\Library + $(EDK_SOURCE)\Foundation + $(EDK_SOURCE)\Foundation\Framework + $(EDK_SOURCE)\Foundation\Efi + $(EDK_SOURCE)\Foundation\Include + $(EDK_SOURCE)\Foundation\Efi\Include + $(EDK_SOURCE)\Foundation\Framework\Include + $(EDK_SOURCE)\Foundation\Include\IndustryStandard + $(EDK_SOURCE)\Foundation\Core\Dxe + $(EDK_SOURCE)\Foundation\Library\Dxe\Include + $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include + +[includes.IA32] + ..\..\Include\Ia32 + +[includes.X64] + ..\..\Include\x64 + + +[libraries.common] +# +# Actually, BaesLib may refer +# BaseTimerLibLocalApic::GetPerformanceCounter()in AcquireSpinLock() +# BaseMemoryLib::ZeroMem() in StrnCpy() +# + + +[libraries.ia32] + + +[libraries.x64] + + +[nmake.common] + C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION + LIB_STD_FLAGS = /NOLOGO /IGNORE:4006 + +[nmake.ia32] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32 + +[nmake.x64] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64 + +[nmake.ipf] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF + +[nmake.ebc] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_EBC
\ No newline at end of file diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/BaseLibInternal.h b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/BaseLibInternal.h new file mode 100644 index 0000000..e67143f --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/BaseLibInternal.h @@ -0,0 +1,586 @@ +/*++ + +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: + + BaseLibInternals.h + +Abstract: + + Declaration of internal functions in BaseLib. + +--*/ + +#ifndef __BASE_LIB_INTERNALS_H__ +#define __BASE_LIB_INTERNALS_H__ + +#include "EdkIIGlueBase.h" + +// +// Math functions +// + +/** + Shifts a 64-bit integer left between 0 and 63 bits. The low bits + are filled with zeros. The shifted value is returned. + + This function shifts the 64-bit value Operand to the left by Count bits. The + low Count bits are set to zero. The shifted value is returned. + + @param Operand The 64-bit operand to shift left. + @param Count The number of bits to shift left. + + @return Operand << Count + +**/ +UINT64 +EFIAPI +InternalMathLShiftU64 ( + IN UINT64 Operand, + IN UINTN Count + ); + +/** + Shifts a 64-bit integer right between 0 and 63 bits. This high bits + are filled with zeros. The shifted value is returned. + + This function shifts the 64-bit value Operand to the right by Count bits. The + high Count bits are set to zero. The shifted value is returned. + + @param Operand The 64-bit operand to shift right. + @param Count The number of bits to shift right. + + @return Operand >> Count + +**/ +UINT64 +EFIAPI +InternalMathRShiftU64 ( + IN UINT64 Operand, + IN UINTN Count + ); + +/** + Shifts a 64-bit integer right between 0 and 63 bits. The high bits + are filled with original integer's bit 63. The shifted value is returned. + + This function shifts the 64-bit value Operand to the right by Count bits. The + high Count bits are set to bit 63 of Operand. The shifted value is returned. + + @param Operand The 64-bit operand to shift right. + @param Count The number of bits to shift right. + + @return Operand arithmetically shifted right by Count + +**/ +UINT64 +EFIAPI +InternalMathARShiftU64 ( + IN UINT64 Operand, + IN UINTN Count + ); + +/** + Rotates a 64-bit integer left between 0 and 63 bits, filling + the low bits with the high bits that were rotated. + + This function rotates the 64-bit value Operand to the left by Count bits. The + low Count bits are fill with the high Count bits of Operand. The rotated + value is returned. + + @param Operand The 64-bit operand to rotate left. + @param Count The number of bits to rotate left. + + @return Operand <<< Count + +**/ +UINT64 +EFIAPI +InternalMathLRotU64 ( + IN UINT64 Operand, + IN UINTN Count + ); + +/** + Rotates a 64-bit integer right between 0 and 63 bits, filling + the high bits with the high low bits that were rotated. + + This function rotates the 64-bit value Operand to the right by Count bits. + The high Count bits are fill with the low Count bits of Operand. The rotated + value is returned. + + @param Operand The 64-bit operand to rotate right. + @param Count The number of bits to rotate right. + + @return Operand >>> Count + +**/ +UINT64 +EFIAPI +InternalMathRRotU64 ( + IN UINT64 Operand, + IN UINTN Count + ); + +/** + Switches the endianess of a 64-bit integer. + + This function swaps the bytes in a 64-bit unsigned value to switch the value + from little endian to big endian or vice versa. The byte swapped value is + returned. + + @param Operand A 64-bit unsigned value. + + @return The byte swaped Operand. + +**/ +UINT64 +EFIAPI +InternalMathSwapBytes64 ( + IN UINT64 Operand + ); + +/** + Multiples a 64-bit unsigned integer by a 32-bit unsigned integer + and generates a 64-bit unsigned result. + + This function multiples the 64-bit unsigned value Multiplicand by the 32-bit + unsigned value Multiplier and generates a 64-bit unsigned result. This 64- + bit unsigned result is returned. + + @param Multiplicand A 64-bit unsigned value. + @param Multiplier A 32-bit unsigned value. + + @return Multiplicand * Multiplier + +**/ +UINT64 +EFIAPI +InternalMathMultU64x32 ( + IN UINT64 Multiplicand, + IN UINT32 Multiplier + ); + +/** + Multiples a 64-bit unsigned integer by a 64-bit unsigned integer + and generates a 64-bit unsigned result. + + This function multiples the 64-bit unsigned value Multiplicand by the 64-bit + unsigned value Multiplier and generates a 64-bit unsigned result. This 64- + bit unsigned result is returned. + + @param Multiplicand A 64-bit unsigned value. + @param Multiplier A 64-bit unsigned value. + + @return Multiplicand * Multiplier + +**/ +UINT64 +EFIAPI +InternalMathMultU64x64 ( + IN UINT64 Multiplicand, + IN UINT64 Multiplier + ); + +/** + Divides a 64-bit unsigned integer by a 32-bit unsigned integer and + generates a 64-bit unsigned result. + + This function divides the 64-bit unsigned value Dividend by the 32-bit + unsigned value Divisor and generates a 64-bit unsigned quotient. This + function returns the 64-bit unsigned quotient. + + @param Dividend A 64-bit unsigned value. + @param Divisor A 32-bit unsigned value. + + @return Dividend / Divisor + +**/ +UINT64 +EFIAPI +InternalMathDivU64x32 ( + IN UINT64 Dividend, + IN UINT32 Divisor + ); + +/** + Divides a 64-bit unsigned integer by a 32-bit unsigned integer and + generates a 32-bit unsigned remainder. + + This function divides the 64-bit unsigned value Dividend by the 32-bit + unsigned value Divisor and generates a 32-bit remainder. This function + returns the 32-bit unsigned remainder. + + @param Dividend A 64-bit unsigned value. + @param Divisor A 32-bit unsigned value. + + @return Dividend % Divisor + +**/ +UINT32 +EFIAPI +InternalMathModU64x32 ( + IN UINT64 Dividend, + IN UINT32 Divisor + ); + +/** + Divides a 64-bit unsigned integer by a 32-bit unsigned integer and + generates a 64-bit unsigned result and an optional 32-bit unsigned remainder. + + This function divides the 64-bit unsigned value Dividend by the 32-bit + unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder + is not NULL, then the 32-bit unsigned remainder is returned in Remainder. + This function returns the 64-bit unsigned quotient. + + @param Dividend A 64-bit unsigned value. + @param Divisor A 32-bit unsigned value. + @param Remainder A pointer to a 32-bit unsigned value. This parameter is + optional and may be NULL. + + @return Dividend / Divisor + +**/ +UINT64 +EFIAPI +InternalMathDivRemU64x32 ( + IN UINT64 Dividend, + IN UINT32 Divisor, + OUT UINT32 *Remainder + ); + +/** + Divides a 64-bit unsigned integer by a 64-bit unsigned integer and + generates a 64-bit unsigned result and an optional 64-bit unsigned remainder. + + This function divides the 64-bit unsigned value Dividend by the 64-bit + unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder + is not NULL, then the 64-bit unsigned remainder is returned in Remainder. + This function returns the 64-bit unsigned quotient. + + @param Dividend A 64-bit unsigned value. + @param Divisor A 64-bit unsigned value. + @param Remainder A pointer to a 64-bit unsigned value. This parameter is + optional and may be NULL. + + @return Dividend / Divisor + +**/ +UINT64 +EFIAPI +InternalMathDivRemU64x64 ( + IN UINT64 Dividend, + IN UINT64 Divisor, + OUT UINT64 *Remainder + ); + +/** + Divides a 64-bit signed integer by a 64-bit signed integer and + generates a 64-bit signed result and a optional 64-bit signed remainder. + + This function divides the 64-bit unsigned value Dividend by the 64-bit + unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder + is not NULL, then the 64-bit unsigned remainder is returned in Remainder. + This function returns the 64-bit unsigned quotient. + + @param Dividend A 64-bit signed value. + @param Divisor A 64-bit signed value. + @param Remainder A pointer to a 64-bit signed value. This parameter is + optional and may be NULL. + + @return Dividend / Divisor + +**/ +INT64 +InternalMathDivRemS64x64 ( + IN INT64 Dividend, + IN INT64 Divisor, + OUT INT64 *Remainder OPTIONAL + ); + +/** + Transfers control to a function starting with a new stack. + + Transfers control to the function specified by EntryPoint using the new stack + specified by NewStack and passing in the parameters specified by Context1 and + Context2. Context1 and Context2 are optional and may be NULL. The function + EntryPoint must never return. + + @param EntryPoint A pointer to function to call with the new stack. + @param Context1 A pointer to the context to pass into the EntryPoint + function. + @param Context2 A pointer to the context to pass into the EntryPoint + function. + @param NewStack A pointer to the new stack to use for the EntryPoint + function. + +**/ +VOID +EFIAPI +InternalSwitchStack ( + IN SWITCH_STACK_ENTRY_POINT EntryPoint, + IN VOID *Context1, + IN VOID *Context2, + IN VOID *NewStack + ); + +// +// Ia32 and x64 specific functions +// + +/** + Reads the current Global Descriptor Table Register(GDTR) descriptor. + + Reads and returns the current GDTR descriptor and returns it in Gdtr. This + function is only available on IA-32 and X64. + + @param Gdtr Pointer to a GDTR descriptor. + +**/ +VOID +EFIAPI +InternalX86ReadGdtr ( + OUT IA32_DESCRIPTOR *Gdtr + ); + +/** + Writes the current Global Descriptor Table Register (GDTR) descriptor. + + Writes and the current GDTR descriptor specified by Gdtr. This function is + only available on IA-32 and X64. + + @param Gdtr Pointer to a GDTR descriptor. + +**/ +VOID +EFIAPI +InternalX86WriteGdtr ( + IN CONST IA32_DESCRIPTOR *Gdtr + ); + +/** + Reads the current Interrupt Descriptor Table Register(GDTR) descriptor. + + Reads and returns the current IDTR descriptor and returns it in Idtr. This + function is only available on IA-32 and X64. + + @param Idtr Pointer to a IDTR descriptor. + +**/ +VOID +EFIAPI +InternalX86ReadIdtr ( + OUT IA32_DESCRIPTOR *Idtr + ); + +/** + Writes the current Interrupt Descriptor Table Register(GDTR) descriptor. + + Writes the current IDTR descriptor and returns it in Idtr. This function is + only available on IA-32 and X64. + + @param Idtr Pointer to a IDTR descriptor. + +**/ +VOID +EFIAPI +InternalX86WriteIdtr ( + IN CONST IA32_DESCRIPTOR *Idtr + ); + +/** + Save the current floating point/SSE/SSE2 context to a buffer. + + Saves the current floating point/SSE/SSE2 state to the buffer specified by + Buffer. Buffer must be aligned on a 16-byte boundary. This function is only + available on IA-32 and X64. + + @param Buffer Pointer to a buffer to save the floating point/SSE/SSE2 context. + +**/ +VOID +EFIAPI +InternalX86FxSave ( + OUT IA32_FX_BUFFER *Buffer + ); + +/** + Restores the current floating point/SSE/SSE2 context from a buffer. + + Restores the current floating point/SSE/SSE2 state from the buffer specified + by Buffer. Buffer must be aligned on a 16-byte boundary. This function is + only available on IA-32 and X64. + + @param Buffer Pointer to a buffer to save the floating point/SSE/SSE2 context. + +**/ +VOID +EFIAPI +InternalX86FxRestore ( + IN CONST IA32_FX_BUFFER *Buffer + ); + +/** + Enables the 32-bit paging mode on the CPU. + + Enables the 32-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables + must be properly initialized prior to calling this service. This function + assumes the current execution mode is 32-bit protected mode. This function is + only available on IA-32. After the 32-bit paging mode is enabled, control is + transferred to the function specified by EntryPoint using the new stack + specified by NewStack and passing in the parameters specified by Context1 and + Context2. Context1 and Context2 are optional and may be NULL. The function + EntryPoint must never return. + + There are a number of constraints that must be followed before calling this + function: + 1) Interrupts must be disabled. + 2) The caller must be in 32-bit protected mode with flat descriptors. This + means all descriptors must have a base of 0 and a limit of 4GB. + 3) CR0 and CR4 must be compatible with 32-bit protected mode with flat + descriptors. + 4) CR3 must point to valid page tables that will be used once the transition + is complete, and those page tables must guarantee that the pages for this + function and the stack are identity mapped. + + @param EntryPoint A pointer to function to call with the new stack after + paging is enabled. + @param Context1 A pointer to the context to pass into the EntryPoint + function as the first parameter after paging is enabled. + @param Context2 A pointer to the context to pass into the EntryPoint + function as the second parameter after paging is enabled. + @param NewStack A pointer to the new stack to use for the EntryPoint + function after paging is enabled. + +**/ +VOID +EFIAPI +InternalX86EnablePaging32 ( + IN SWITCH_STACK_ENTRY_POINT EntryPoint, + IN VOID *Context1, OPTIONAL + IN VOID *Context2, OPTIONAL + IN VOID *NewStack + ); + +/** + Disables the 32-bit paging mode on the CPU. + + Disables the 32-bit paging mode on the CPU and returns to 32-bit protected + mode. This function assumes the current execution mode is 32-paged protected + mode. This function is only available on IA-32. After the 32-bit paging mode + is disabled, control is transferred to the function specified by EntryPoint + using the new stack specified by NewStack and passing in the parameters + specified by Context1 and Context2. Context1 and Context2 are optional and + may be NULL. The function EntryPoint must never return. + + There are a number of constraints that must be followed before calling this + function: + 1) Interrupts must be disabled. + 2) The caller must be in 32-bit paged mode. + 3) CR0, CR3, and CR4 must be compatible with 32-bit paged mode. + 4) CR3 must point to valid page tables that guarantee that the pages for + this function and the stack are identity mapped. + + @param EntryPoint A pointer to function to call with the new stack after + paging is disabled. + @param Context1 A pointer to the context to pass into the EntryPoint + function as the first parameter after paging is disabled. + @param Context2 A pointer to the context to pass into the EntryPoint + function as the second parameter after paging is + disabled. + @param NewStack A pointer to the new stack to use for the EntryPoint + function after paging is disabled. + +**/ +VOID +EFIAPI +InternalX86DisablePaging32 ( + IN SWITCH_STACK_ENTRY_POINT EntryPoint, + IN VOID *Context1, OPTIONAL + IN VOID *Context2, OPTIONAL + IN VOID *NewStack + ); + +/** + Enables the 64-bit paging mode on the CPU. + + Enables the 64-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables + must be properly initialized prior to calling this service. This function + assumes the current execution mode is 32-bit protected mode with flat + descriptors. This function is only available on IA-32. After the 64-bit + paging mode is enabled, control is transferred to the function specified by + EntryPoint using the new stack specified by NewStack and passing in the + parameters specified by Context1 and Context2. Context1 and Context2 are + optional and may be 0. The function EntryPoint must never return. + + @param Cs The 16-bit selector to load in the CS before EntryPoint + is called. The descriptor in the GDT that this selector + references must be setup for long mode. + @param EntryPoint The 64-bit virtual address of the function to call with + the new stack after paging is enabled. + @param Context1 The 64-bit virtual address of the context to pass into + the EntryPoint function as the first parameter after + paging is enabled. + @param Context2 The 64-bit virtual address of the context to pass into + the EntryPoint function as the second parameter after + paging is enabled. + @param NewStack The 64-bit virtual address of the new stack to use for + the EntryPoint function after paging is enabled. + +**/ +VOID +EFIAPI +InternalX86EnablePaging64 ( + IN UINT16 Cs, + IN UINT64 EntryPoint, + IN UINT64 Context1, OPTIONAL + IN UINT64 Context2, OPTIONAL + IN UINT64 NewStack + ); + +/** + Disables the 64-bit paging mode on the CPU. + + Disables the 64-bit paging mode on the CPU and returns to 32-bit protected + mode. This function assumes the current execution mode is 64-paging mode. + This function is only available on X64. After the 64-bit paging mode is + disabled, control is transferred to the function specified by EntryPoint + using the new stack specified by NewStack and passing in the parameters + specified by Context1 and Context2. Context1 and Context2 are optional and + may be 0. The function EntryPoint must never return. + + @param Cs The 16-bit selector to load in the CS before EntryPoint + is called. The descriptor in the GDT that this selector + references must be setup for 32-bit protected mode. + @param EntryPoint The 64-bit virtual address of the function to call with + the new stack after paging is disabled. + @param Context1 The 64-bit virtual address of the context to pass into + the EntryPoint function as the first parameter after + paging is disabled. + @param Context2 The 64-bit virtual address of the context to pass into + the EntryPoint function as the second parameter after + paging is disabled. + @param NewStack The 64-bit virtual address of the new stack to use for + the EntryPoint function after paging is disabled. + +**/ +VOID +EFIAPI +InternalX86DisablePaging64 ( + IN UINT16 Cs, + IN UINT32 EntryPoint, + IN UINT32 Context1, OPTIONAL + IN UINT32 Context2, OPTIONAL + IN UINT32 NewStack + ); + +#endif diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/BitField.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/BitField.c new file mode 100644 index 0000000..a98e187 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/BitField.c @@ -0,0 +1,861 @@ +/*++ + +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: + + BitField.c + +Abstract: + + Bit field functions of BaseLib. + +--*/ + +#include "BaseLibInternal.h" + +/** + Worker function that returns a bit field from Operand + + Returns the bitfield specified by the StartBit and the EndBit from Operand. + + @param Operand Operand on which to perform the bitfield operation. + @param StartBit The ordinal of the least significant bit in the bit field. + @param EndBit The ordinal of the most significant bit in the bit field. + + @return The bit field read. + +**/ +unsigned int +BitFieldReadUint ( + IN unsigned int Operand, + IN UINTN StartBit, + IN UINTN EndBit + ) +{ + // + // ~((unsigned int)-2 << EndBit) is a mask in which bit[0] thru bit[EndBit] + // are 1's while bit[EndBit + 1] thru the most significant bit are 0's. + // + return (Operand & ~((unsigned int)-2 << EndBit)) >> StartBit; +} + +/** + Worker function that reads a bit field from Operand, performs a bitwise OR, + and returns the result. + + Performs a bitwise OR between the bit field specified by StartBit and EndBit + in Operand and the value specified by AndData. All other bits in Operand are + preserved. The new value is returned. + + @param Operand Operand on which to perform the bitfield operation. + @param StartBit The ordinal of the least significant bit in the bit field. + @param EndBit The ordinal of the most significant bit in the bit field. + @param OrData The value to OR with the read value from the value + + @return The new value. + +**/ +unsigned int +BitFieldOrUint ( + IN unsigned int Operand, + IN UINTN StartBit, + IN UINTN EndBit, + IN unsigned int OrData + ) +{ + // + // ~((unsigned int)-2 << EndBit) is a mask in which bit[0] thru bit[EndBit] + // are 1's while bit[EndBit + 1] thru the most significant bit are 0's. + // + return Operand | ((OrData << StartBit) & ~((unsigned int) -2 << EndBit)); +} + +/** + Worker function that reads a bit field from Operand, performs a bitwise AND, + and returns the result. + + Performs a bitwise AND between the bit field specified by StartBit and EndBit + in Operand and the value specified by AndData. All other bits in Operand are + preserved. The new value is returned. + + @param Operand Operand on which to perform the bitfield operation. + @param StartBit The ordinal of the least significant bit in the bit field. + @param EndBit The ordinal of the most significant bit in the bit field. + @param AndData The value to And with the read value from the value + + @return The new value. + +**/ +unsigned int +BitFieldAndUint ( + IN unsigned int Operand, + IN UINTN StartBit, + IN UINTN EndBit, + IN unsigned int AndData + ) +{ + // + // ~((unsigned int)-2 << EndBit) is a mask in which bit[0] thru bit[EndBit] + // are 1's while bit[EndBit + 1] thru the most significant bit are 0's. + // + return Operand & ~((~AndData << StartBit) & ~((unsigned int) -2 << EndBit)); +} + +/** + Returns a bit field from an 8-bit value. + + Returns the bitfield specified by the StartBit and the EndBit from Operand. + + If 8-bit operations are not supported, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Operand Operand on which to perform the bitfield operation. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..7. + + @return The bit field read. + +**/ +UINT8 +EFIAPI +BitFieldRead8 ( + IN UINT8 Operand, + IN UINTN StartBit, + IN UINTN EndBit + ) +{ +// ASSERT (EndBit < sizeof (Operand) * 8); +// ASSERT (StartBit <= EndBit); + return (UINT8)BitFieldReadUint (Operand, StartBit, EndBit); +} + +/** + Writes a bit field to an 8-bit value, and returns the result. + + Writes Value to the bit field specified by the StartBit and the EndBit in + Operand. All other bits in Operand are preserved. The new 8-bit value is + returned. + + If 8-bit operations are not supported, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Operand Operand on which to perform the bitfield operation. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..7. + @param Value New value of the bit field. + + @return The new 8-bit value. + +**/ +UINT8 +EFIAPI +BitFieldWrite8 ( + IN UINT8 Operand, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT8 Value + ) +{ +// ASSERT (EndBit < sizeof (Operand) * 8); +// ASSERT (StartBit <= EndBit); + return BitFieldAndThenOr8 (Operand, StartBit, EndBit, 0, Value); +} + +/** + Reads a bit field from an 8-bit value, performs a bitwise OR, and returns the + result. + + Performs a bitwise inclusive OR between the bit field specified by StartBit + and EndBit in Operand and the value specified by OrData. All other bits in + Operand are preserved. The new 8-bit value is returned. + + If 8-bit operations are not supported, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Operand Operand on which to perform the bitfield operation. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..7. + @param OrData The value to OR with the read value from the value + + @return The new 8-bit value. + +**/ +UINT8 +EFIAPI +BitFieldOr8 ( + IN UINT8 Operand, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT8 OrData + ) +{ +// ASSERT (EndBit < sizeof (Operand) * 8); +// ASSERT (StartBit <= EndBit); + return (UINT8)BitFieldOrUint (Operand, StartBit, EndBit, OrData); +} + +/** + Reads a bit field from an 8-bit value, performs a bitwise AND, and returns + the result. + + Performs a bitwise AND between the bit field specified by StartBit and EndBit + in Operand and the value specified by AndData. All other bits in Operand are + preserved. The new 8-bit value is returned. + + If 8-bit operations are not supported, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Operand Operand on which to perform the bitfield operation. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..7. + @param AndData The value to AND with the read value from the value. + + @return The new 8-bit value. + +**/ +UINT8 +EFIAPI +BitFieldAnd8 ( + IN UINT8 Operand, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT8 AndData + ) +{ +// ASSERT (EndBit < sizeof (Operand) * 8); +// ASSERT (StartBit <= EndBit); + return (UINT8)BitFieldAndUint (Operand, StartBit, EndBit, AndData); +} + +/** + Reads a bit field from an 8-bit value, performs a bitwise AND followed by a + bitwise OR, and returns the result. + + Performs a bitwise AND between the bit field specified by StartBit and EndBit + in Operand and the value specified by AndData, followed by a bitwise + inclusive OR with value specified by OrData. All other bits in Operand are + preserved. The new 8-bit value is returned. + + If 8-bit operations are not supported, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Operand Operand on which to perform the bitfield operation. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..7. + @param AndData The value to AND with the read value from the value. + @param OrData The value to OR with the result of the AND operation. + + @return The new 8-bit value. + +**/ +UINT8 +EFIAPI +BitFieldAndThenOr8 ( + IN UINT8 Operand, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT8 AndData, + IN UINT8 OrData + ) +{ +// ASSERT (EndBit < sizeof (Operand) * 8); +// ASSERT (StartBit <= EndBit); + return BitFieldOr8 ( + BitFieldAnd8 (Operand, StartBit, EndBit, AndData), + StartBit, + EndBit, + OrData + ); +} + +/** + Returns a bit field from a 16-bit value. + + Returns the bitfield specified by the StartBit and the EndBit from Operand. + + If 16-bit operations are not supported, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Operand Operand on which to perform the bitfield operation. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..15. + + @return The bit field read. + +**/ +UINT16 +EFIAPI +BitFieldRead16 ( + IN UINT16 Operand, + IN UINTN StartBit, + IN UINTN EndBit + ) +{ +// ASSERT (EndBit < sizeof (Operand) * 8); +// ASSERT (StartBit <= EndBit); + return (UINT16)BitFieldReadUint (Operand, StartBit, EndBit); +} + +/** + Writes a bit field to a 16-bit value, and returns the result. + + Writes Value to the bit field specified by the StartBit and the EndBit in + Operand. All other bits in Operand are preserved. The new 16-bit value is + returned. + + If 16-bit operations are not supported, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Operand Operand on which to perform the bitfield operation. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..15. + @param Value New value of the bit field. + + @return The new 16-bit value. + +**/ +UINT16 +EFIAPI +BitFieldWrite16 ( + IN UINT16 Operand, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT16 Value + ) +{ +// ASSERT (EndBit < sizeof (Operand) * 8); +// ASSERT (StartBit <= EndBit); + return BitFieldAndThenOr16 (Operand, StartBit, EndBit, 0, Value); +} + +/** + Reads a bit field from a 16-bit value, performs a bitwise OR, and returns the + result. + + Performs a bitwise inclusive OR between the bit field specified by StartBit + and EndBit in Operand and the value specified by OrData. All other bits in + Operand are preserved. The new 16-bit value is returned. + + If 16-bit operations are not supported, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Operand Operand on which to perform the bitfield operation. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..15. + @param OrData The value to OR with the read value from the value + + @return The new 16-bit value. + +**/ +UINT16 +EFIAPI +BitFieldOr16 ( + IN UINT16 Operand, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT16 OrData + ) +{ +// ASSERT (EndBit < sizeof (Operand) * 8); +// ASSERT (StartBit <= EndBit); + return (UINT16)BitFieldOrUint (Operand, StartBit, EndBit, OrData); +} + +/** + Reads a bit field from a 16-bit value, performs a bitwise AND, and returns + the result. + + Performs a bitwise AND between the bit field specified by StartBit and EndBit + in Operand and the value specified by AndData. All other bits in Operand are + preserved. The new 16-bit value is returned. + + If 16-bit operations are not supported, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Operand Operand on which to perform the bitfield operation. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..15. + @param AndData The value to AND with the read value from the value + + @return The new 16-bit value. + +**/ +UINT16 +EFIAPI +BitFieldAnd16 ( + IN UINT16 Operand, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT16 AndData + ) +{ +// ASSERT (EndBit < sizeof (Operand) * 8); +// ASSERT (StartBit <= EndBit); + return (UINT16)BitFieldAndUint (Operand, StartBit, EndBit, AndData); +} + +/** + Reads a bit field from a 16-bit value, performs a bitwise AND followed by a + bitwise OR, and returns the result. + + Performs a bitwise AND between the bit field specified by StartBit and EndBit + in Operand and the value specified by AndData, followed by a bitwise + inclusive OR with value specified by OrData. All other bits in Operand are + preserved. The new 16-bit value is returned. + + If 16-bit operations are not supported, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Operand Operand on which to perform the bitfield operation. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..15. + @param AndData The value to AND with the read value from the value. + @param OrData The value to OR with the result of the AND operation. + + @return The new 16-bit value. + +**/ +UINT16 +EFIAPI +BitFieldAndThenOr16 ( + IN UINT16 Operand, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT16 AndData, + IN UINT16 OrData + ) +{ +// ASSERT (EndBit < sizeof (Operand) * 8); +// ASSERT (StartBit <= EndBit); + return BitFieldOr16 ( + BitFieldAnd16 (Operand, StartBit, EndBit, AndData), + StartBit, + EndBit, + OrData + ); +} + +/** + Returns a bit field from a 32-bit value. + + Returns the bitfield specified by the StartBit and the EndBit from Operand. + + If 32-bit operations are not supported, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Operand Operand on which to perform the bitfield operation. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + + @return The bit field read. + +**/ +UINT32 +EFIAPI +BitFieldRead32 ( + IN UINT32 Operand, + IN UINTN StartBit, + IN UINTN EndBit + ) +{ +// ASSERT (EndBit < sizeof (Operand) * 8); +// ASSERT (StartBit <= EndBit); + return (UINT32)BitFieldReadUint (Operand, StartBit, EndBit); +} + +/** + Writes a bit field to a 32-bit value, and returns the result. + + Writes Value to the bit field specified by the StartBit and the EndBit in + Operand. All other bits in Operand are preserved. The new 32-bit value is + returned. + + If 32-bit operations are not supported, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Operand Operand on which to perform the bitfield operation. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + @param Value New value of the bit field. + + @return The new 32-bit value. + +**/ +UINT32 +EFIAPI +BitFieldWrite32 ( + IN UINT32 Operand, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT32 Value + ) +{ +// ASSERT (EndBit < sizeof (Operand) * 8); +// ASSERT (StartBit <= EndBit); + return BitFieldAndThenOr32 (Operand, StartBit, EndBit, 0, Value); +} + +/** + Reads a bit field from a 32-bit value, performs a bitwise OR, and returns the + result. + + Performs a bitwise inclusive OR between the bit field specified by StartBit + and EndBit in Operand and the value specified by OrData. All other bits in + Operand are preserved. The new 32-bit value is returned. + + If 32-bit operations are not supported, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Operand Operand on which to perform the bitfield operation. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + @param OrData The value to OR with the read value from the value + + @return The new 32-bit value. + +**/ +UINT32 +EFIAPI +BitFieldOr32 ( + IN UINT32 Operand, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT32 OrData + ) +{ +// ASSERT (EndBit < sizeof (Operand) * 8); +// ASSERT (StartBit <= EndBit); + return (UINT32)BitFieldOrUint (Operand, StartBit, EndBit, OrData); +} + +/** + Reads a bit field from a 32-bit value, performs a bitwise AND, and returns + the result. + + Performs a bitwise AND between the bit field specified by StartBit and EndBit + in Operand and the value specified by AndData. All other bits in Operand are + preserved. The new 32-bit value is returned. + + If 32-bit operations are not supported, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Operand Operand on which to perform the bitfield operation. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + @param AndData The value to AND with the read value from the value + + @return The new 32-bit value. + +**/ +UINT32 +EFIAPI +BitFieldAnd32 ( + IN UINT32 Operand, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT32 AndData + ) +{ +// ASSERT (EndBit < sizeof (Operand) * 8); +// ASSERT (StartBit <= EndBit); + return (UINT32)BitFieldAndUint (Operand, StartBit, EndBit, AndData); +} + +/** + Reads a bit field from a 32-bit value, performs a bitwise AND followed by a + bitwise OR, and returns the result. + + Performs a bitwise AND between the bit field specified by StartBit and EndBit + in Operand and the value specified by AndData, followed by a bitwise + inclusive OR with value specified by OrData. All other bits in Operand are + preserved. The new 32-bit value is returned. + + If 32-bit operations are not supported, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Operand Operand on which to perform the bitfield operation. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + @param AndData The value to AND with the read value from the value. + @param OrData The value to OR with the result of the AND operation. + + @return The new 32-bit value. + +**/ +UINT32 +EFIAPI +BitFieldAndThenOr32 ( + IN UINT32 Operand, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT32 AndData, + IN UINT32 OrData + ) +{ +// ASSERT (EndBit < sizeof (Operand) * 8); +// ASSERT (StartBit <= EndBit); + return BitFieldOr32 ( + BitFieldAnd32 (Operand, StartBit, EndBit, AndData), + StartBit, + EndBit, + OrData + ); +} + +/** + Returns a bit field from a 64-bit value. + + Returns the bitfield specified by the StartBit and the EndBit from Operand. + + If 64-bit operations are not supported, then ASSERT(). + If StartBit is greater than 63, then ASSERT(). + If EndBit is greater than 63, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Operand Operand on which to perform the bitfield operation. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..63. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..63. + + @return The bit field read. + +**/ +UINT64 +EFIAPI +BitFieldRead64 ( + IN UINT64 Operand, + IN UINTN StartBit, + IN UINTN EndBit + ) +{ +// ASSERT (EndBit < sizeof (Operand) * 8); +// ASSERT (StartBit <= EndBit); + return RShiftU64 (Operand & ~LShiftU64 ((UINT64)-2, EndBit), StartBit); +} + +/** + Writes a bit field to a 64-bit value, and returns the result. + + Writes Value to the bit field specified by the StartBit and the EndBit in + Operand. All other bits in Operand are preserved. The new 64-bit value is + returned. + + If 64-bit operations are not supported, then ASSERT(). + If StartBit is greater than 63, then ASSERT(). + If EndBit is greater than 63, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Operand Operand on which to perform the bitfield operation. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..63. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..63. + @param Value New value of the bit field. + + @return The new 64-bit value. + +**/ +UINT64 +EFIAPI +BitFieldWrite64 ( + IN UINT64 Operand, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT64 Value + ) +{ +// ASSERT (EndBit < sizeof (Operand) * 8); +// ASSERT (StartBit <= EndBit); + return BitFieldAndThenOr64 (Operand, StartBit, EndBit, 0, Value); +} + +/** + Reads a bit field from a 64-bit value, performs a bitwise OR, and returns the + result. + + Performs a bitwise inclusive OR between the bit field specified by StartBit + and EndBit in Operand and the value specified by OrData. All other bits in + Operand are preserved. The new 64-bit value is returned. + + If 64-bit operations are not supported, then ASSERT(). + If StartBit is greater than 63, then ASSERT(). + If EndBit is greater than 63, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Operand Operand on which to perform the bitfield operation. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..63. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..63. + @param OrData The value to OR with the read value from the value + + @return The new 64-bit value. + +**/ +UINT64 +EFIAPI +BitFieldOr64 ( + IN UINT64 Operand, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT64 OrData + ) +{ +// ASSERT (EndBit < sizeof (Operand) * 8); +// ASSERT (StartBit <= EndBit); + return Operand | + (LShiftU64 (OrData, StartBit) & ~LShiftU64 ((UINT64)-2, EndBit)); +} + +/** + Reads a bit field from a 64-bit value, performs a bitwise AND, and returns + the result. + + Performs a bitwise AND between the bit field specified by StartBit and EndBit + in Operand and the value specified by AndData. All other bits in Operand are + preserved. The new 64-bit value is returned. + + If 64-bit operations are not supported, then ASSERT(). + If StartBit is greater than 63, then ASSERT(). + If EndBit is greater than 63, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Operand Operand on which to perform the bitfield operation. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..63. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..63. + @param AndData The value to AND with the read value from the value + + @return The new 64-bit value. + +**/ +UINT64 +EFIAPI +BitFieldAnd64 ( + IN UINT64 Operand, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT64 AndData + ) +{ +// ASSERT (EndBit < sizeof (Operand) * 8); +// ASSERT (StartBit <= EndBit); + return Operand & + ~(LShiftU64 (~AndData, StartBit) & ~LShiftU64 ((UINT64)-2, EndBit)); +} + +/** + Reads a bit field from a 64-bit value, performs a bitwise AND followed by a + bitwise OR, and returns the result. + + Performs a bitwise AND between the bit field specified by StartBit and EndBit + in Operand and the value specified by AndData, followed by a bitwise + inclusive OR with value specified by OrData. All other bits in Operand are + preserved. The new 64-bit value is returned. + + If 64-bit operations are not supported, then ASSERT(). + If StartBit is greater than 63, then ASSERT(). + If EndBit is greater than 63, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Operand Operand on which to perform the bitfield operation. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..63. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..63. + @param AndData The value to AND with the read value from the value. + @param OrData The value to OR with the result of the AND operation. + + @return The new 64-bit value. + +**/ +UINT64 +EFIAPI +BitFieldAndThenOr64 ( + IN UINT64 Operand, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT64 AndData, + IN UINT64 OrData + ) +{ +// ASSERT (EndBit < sizeof (Operand) * 8); +// ASSERT (StartBit <= EndBit); + return BitFieldOr64 ( + BitFieldAnd64 (Operand, StartBit, EndBit, AndData), + StartBit, + EndBit, + OrData + ); +} diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Cpu.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Cpu.c new file mode 100644 index 0000000..79d0739 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Cpu.c @@ -0,0 +1,75 @@ +/*++ + +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: + + Cpu.c + +Abstract: + + Base Library CPU Functions for all architectures. + +--*/ + +#include "BaseLibInternal.h" + +/** + Disables CPU interrupts and returns the interrupt state prior to the disable + operation. + + Disables CPU interrupts and returns the interrupt state prior to the disable + operation. + + @retval TRUE CPU interrupts were enabled on entry to this call. + @retval FALSE CPU interrupts were disabled on entry to this call. + +**/ +BOOLEAN +EFIAPI +SaveAndDisableInterrupts ( + VOID + ) +{ + BOOLEAN InterruptState; + + InterruptState = GetInterruptState (); + DisableInterrupts (); + return InterruptState; +} + +/** + Set the current CPU interrupt state. + + Sets the current CPU interrupt state to the state specified by + InterruptState. If InterruptState is TRUE, then interrupts are enabled. If + InterruptState is FALSE, then interrupts are disabled. InterruptState is + returned. + + @param InterruptState TRUE if interrupts should enabled. FALSE if + interrupts should be disabled. + + @return InterruptState + +**/ +BOOLEAN +EFIAPI +SetInterruptState ( + IN BOOLEAN InterruptState + ) +{ + if (InterruptState) { + EnableInterrupts (); + } else { + DisableInterrupts (); + } + return InterruptState; +} diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/CpuDeadLoop.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/CpuDeadLoop.c new file mode 100644 index 0000000..e5e7f6d --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/CpuDeadLoop.c @@ -0,0 +1,42 @@ +/*++ + +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: + + CpuDeadLoop.c + +Abstract: + + Base Library CPU Functions for all architectures. + +--*/ + +#include "BaseLibInternal.h" + +/** + Executes an infinite loop. + + Forces the CPU to execute an infinite loop. A debugger may be used to skip + past the loop and the code that follows the loop must execute properly. This + implies that the infinite loop must not cause the code that follow it to be + optimized away. + +**/ +VOID +EFIAPI +CpuDeadLoop ( + VOID + ) +{ + volatile UINTN Index; + + for (Index = 0; Index == 0;); +} diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/DivS64x64Remainder.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/DivS64x64Remainder.c new file mode 100644 index 0000000..bdea3e0 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/DivS64x64Remainder.c @@ -0,0 +1,54 @@ +/*++ + +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: + + DivS64x64Remainder.c + +Abstract: + + Math worker functions. + +--*/ + +#include "BaseLibInternal.h" + +/** + Divides a 64-bit signed integer by a 64-bit signed integer and generates a + 64-bit signed result and a optional 64-bit signed remainder. + + This function divides the 64-bit signed value Dividend by the 64-bit signed + value Divisor and generates a 64-bit signed quotient. If Remainder is not + NULL, then the 64-bit signed remainder is returned in Remainder. This + function returns the 64-bit signed quotient. + + If Divisor is 0, then ASSERT(). + + @param Dividend A 64-bit signed value. + @param Divisor A 64-bit signed value. + @param Remainder A pointer to a 64-bit signed value. This parameter is + optional and may be NULL. + + @return Dividend / Divisor + +**/ +INT64 +EFIAPI +DivS64x64Remainder ( + IN INT64 Dividend, + IN INT64 Divisor, + OUT INT64 *Remainder OPTIONAL + ) +{ + ASSERT (Divisor != 0); + return InternalMathDivRemS64x64 (Dividend, Divisor, Remainder); +} diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/DivU64x32.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/DivU64x32.c new file mode 100644 index 0000000..4dbddb8 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/DivU64x32.c @@ -0,0 +1,50 @@ +/*++ + +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: + + DivU64x32.c + +Abstract: + + Math worker functions. + +--*/ + +#include "BaseLibInternal.h" + +/** + Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates + a 64-bit unsigned result. + + This function divides the 64-bit unsigned value Dividend by the 32-bit + unsigned value Divisor and generates a 64-bit unsigned quotient. This + function returns the 64-bit unsigned quotient. + + If Divisor is 0, then ASSERT(). + + @param Dividend A 64-bit unsigned value. + @param Divisor A 32-bit unsigned value. + + @return Dividend / Divisor + +**/ +UINT64 +EFIAPI +GlueDivU64x32 ( + IN UINT64 Dividend, + IN UINT32 Divisor + ) +{ + ASSERT (Divisor != 0); + return InternalMathDivU64x32 (Dividend, Divisor); +} diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/DivU64x32Remainder.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/DivU64x32Remainder.c new file mode 100644 index 0000000..57a24d2 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/DivU64x32Remainder.c @@ -0,0 +1,54 @@ +/*++ + +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: + + DivU64x32Remainder.c + +Abstract: + + Math worker functions + +--*/ + +#include "BaseLibInternal.h" + +/** + Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates + a 64-bit unsigned result and an optional 32-bit unsigned remainder. + + This function divides the 64-bit unsigned value Dividend by the 32-bit + unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder + is not NULL, then the 32-bit unsigned remainder is returned in Remainder. + This function returns the 64-bit unsigned quotient. + + If Divisor is 0, then ASSERT(). + + @param Dividend A 64-bit unsigned value. + @param Divisor A 32-bit unsigned value. + @param Remainder A pointer to a 32-bit unsigned value. This parameter is + optional and may be NULL. + + @return Dividend / Divisor + +**/ +UINT64 +EFIAPI +DivU64x32Remainder ( + IN UINT64 Dividend, + IN UINT32 Divisor, + OUT UINT32 *Remainder OPTIONAL + ) +{ + ASSERT (Divisor != 0); + return InternalMathDivRemU64x32 (Dividend, Divisor, Remainder); +} diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/DivU64x64Remainder.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/DivU64x64Remainder.c new file mode 100644 index 0000000..961b4d0 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/DivU64x64Remainder.c @@ -0,0 +1,53 @@ +/*++ + +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: + + DivU64x64Remainder.c + +Abstract: + + Math worker functions. + +--*/ + +#include "BaseLibInternal.h" + +/** + Divides a 64-bit unsigned integer by a 64-bit unsigned integer and generates + a 64-bit unsigned result and an optional 64-bit unsigned remainder. + + This function divides the 64-bit unsigned value Dividend by the 64-bit + unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder + is not NULL, then the 64-bit unsigned remainder is returned in Remainder. + This function returns the 64-bit unsigned quotient. + + If Divisor is 0, then ASSERT(). + + @param Dividend A 64-bit unsigned value. + @param Divisor A 64-bit unsigned value. + @param Remainder A pointer to a 64-bit unsigned value. This parameter is + optional and may be NULL. + + @return Dividend / Divisor + +**/ +UINT64 +EFIAPI +DivU64x64Remainder ( + IN UINT64 Dividend, + IN UINT64 Divisor, + OUT UINT64 *Remainder OPTIONAL + ) +{ + ASSERT (Divisor != 0); + return InternalMathDivRemU64x64 (Dividend, Divisor, Remainder); +} diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/EdkIIGlueBaseLib.cif b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/EdkIIGlueBaseLib.cif new file mode 100644 index 0000000..d0a478f --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/EdkIIGlueBaseLib.cif @@ -0,0 +1,47 @@ +<component> + name = "EdkIIGlueBaseLib" + category = ModulePart + LocalRoot = "Edk\Foundation\Library\EdkIIGlueLib\Library\BaseLib" + RefName = "EdkIIGlueBaseLib" +[files] +"EdkIIGlueBaseLib.sdl" +"EdkIIGlueBaseLib.mak" +"BaseLib.inf" +"String.c" +"LinkedList.c" +"Synchronization.c" +"Cpu.c" +"CpuDeadLoop.c" +"BitField.c" +"ARShiftU64.c" +"DivS64x64Remainder.c" +"DivU64x32.c" +"DivU64x32Remainder.c" +"DivU64x64Remainder.c" +"GetPowerOfTwo32.c" +"GetPowerOfTwo64.c" +"HighBitSet32.c" +"HighBitSet64.c" +"LowBitSet32.c" +"LowBitSet64.c" +"LRotU32.c" +"LRotU64.c" +"LShiftU64.c" +"ModU64x32.c" +"MultS64x64.c" +"MultU64x32.c" +"MultU64x64.c" +"RRotU32.c" +"RRotU64.c" +"RShiftU64.c" +"SetJump.c" +"LongJump.c" +"SwapBytes16.c" +"SwapBytes32.c" +"SwapBytes64.c" +"SwitchStack.c" +"BaseLibInternal.h" +[parts] +"EdkIIGlueBaseLibIA32" +"EdkIIGlueBaseLibX64" +<endComponent> diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/EdkIIGlueBaseLib.mak b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/EdkIIGlueBaseLib.mak new file mode 100644 index 0000000..30458df --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/EdkIIGlueBaseLib.mak @@ -0,0 +1,106 @@ +#********************************************************************** +#********************************************************************** +#** ** +#** (C)Copyright 1985-2009, American Megatrends, Inc. ** +#** ** +#** All Rights Reserved. ** +#** ** +#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +#** ** +#** Phone: (770)-246-8600 ** +#** ** +#********************************************************************** +#********************************************************************** + +#********************************************************************** +# $Header: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGlueBaseLib/EdkIIGlueBaseLib.mak 1 1/20/12 3:48a Jeffch $ +# +# $Revision: 1 $ +# +# $Date: 1/20/12 3:48a $ +#********************************************************************** +# Revision History +# ---------------- +# $Log: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGlueBaseLib/EdkIIGlueBaseLib.mak $ +# +# 1 1/20/12 3:48a Jeffch +# Create Intel EDK 1117 Patch 7. +# +# 1 1/20/12 3:28a Jeffch +# Create Intel EDK 1117 Patch 7. +# +# 1 9/27/11 6:10a Wesleychen +# Intel EDK initially releases. +# +# 1 9/18/09 1:50a Iminglin +# +#********************************************************************** +#<AMI_FHDR_START> +# +# Name: EdkIIGlueBaseLib.mak +# +# Description: +# +#<AMI_FHDR_END> +#********************************************************************** + + +!IF "$(PROCESSOR)"=="IA32" +EdkIIGlueBaseLib_PORCESSOR_CIF=$(EdkIIGlueBaseLib_DIR)\EdkIIGlueBaseLibIa32.cif +!ELSEIF "$(PROCESSOR)"=="x64" +EdkIIGlueBaseLib_PORCESSOR_PEI_CIF=$(EdkIIGlueBaseLib_DIR)\EdkIIGlueBaseLibIa32.cif +EdkIIGlueBaseLib_PORCESSOR_DXE_CIF=$(EdkIIGlueBaseLib_DIR)\EdkIIGlueBaseLibX64.cif +!ENDIF + +$(EdkIIGlueBaseLib_LIB) : EdkIIGlueBaseLib + +!IF "$(x64_BUILD)"=="1" +EdkIIGlueBaseLib : $(BUILD_DIR)\EdkIIGlueBaseLib.mak $(BUILD_DIR)\EdkIIGlueBaseLibPei.mak EdkIIGlueBaseLibBin + +$(BUILD_DIR)\EdkIIGlueBaseLib.mak : $(EdkIIGlueBaseLib_DIR)\EdkIIGlueBaseLib.cif $(EdkIIGlueBaseLib_DIR)\EdkIIGlueBaseLib.mak $(BUILD_RULES) $(EdkIIGlueBaseLib_PORCESSOR_DXE_CIF) + $(CIF2MAK) $(EdkIIGlueBaseLib_DIR)\EdkIIGlueBaseLib.cif $(CIF2MAK_DEFAULTS) $(EdkIIGlueBaseLib_PORCESSOR_DXE_CIF) + +$(BUILD_DIR)\EdkIIGlueBaseLibPei.mak : $(EdkIIGlueBaseLib_DIR)\EdkIIGlueBaseLib.cif $(EdkIIGlueBaseLib_DIR)\EdkIIGlueBaseLib.mak $(BUILD_RULES) $(EdkIIGlueBaseLib_PORCESSOR_PEI_CIF) + $(CIF2MAK) $(EdkIIGlueBaseLib_DIR)\EdkIIGlueBaseLib.cif $(CIF2MAK_DEFAULTS) $(EdkIIGlueBaseLib_PORCESSOR_PEI_CIF) +!ELSE +EdkIIGlueBaseLib : $(BUILD_DIR)\EdkIIGlueBaseLib.mak EdkIIGlueBaseLibBin + +$(BUILD_DIR)\EdkIIGlueBaseLib.mak : $(EdkIIGlueBaseLib_DIR)\EdkIIGlueBaseLib.cif $(EdkIIGlueBaseLib_DIR)\EdkIIGlueBaseLib.mak $(BUILD_RULES) $(EdkIIGlueBaseLib_PORCESSOR_CIF) + $(CIF2MAK) $(EdkIIGlueBaseLib_DIR)\EdkIIGlueBaseLib.cif $(CIF2MAK_DEFAULTS) $(EdkIIGlueBaseLib_PORCESSOR_CIF) +!ENDIF + +EdkIIGlueBaseLibBin : +!IF "$(x64_BUILD)"=="1" + $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\ + BUILD_DIR=$(BUILD_DIR)\ + /f $(BUILD_DIR)\EdkIIGlueBaseLib.mak all\ + "MY_INCLUDES=/I$(EdkIIGlueBaseLib_DIR)"\ + "MY_DEFINES=/D"CPU_STACK_ALIGNMENT=2""\ + TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueBaseLib_LIB)" + $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\ + BUILD_DIR=$(BUILD_DIR)\IA32\ + /f $(BUILD_DIR)\EdkIIGlueBaseLibPei.mak all\ + "MY_INCLUDES=/I$(EdkIIGlueBaseLib_DIR)"\ + "MY_DEFINES=/D"CPU_STACK_ALIGNMENT=2""\ + TYPE=PEI_LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueBaseLib_LIB)" +!ELSE + $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\ + BUILD_DIR=$(BUILD_DIR)\ + /f $(BUILD_DIR)\EdkIIGlueBaseLib.mak all\ + "MY_INCLUDES=/I$(EdkIIGlueBaseLib_DIR)"\ + "MY_DEFINES=/D"CPU_STACK_ALIGNMENT=2""\ + TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueBaseLib_LIB)" +!ENDIF +#********************************************************************** +#********************************************************************** +#** ** +#** (C)Copyright 1985-2009, American Megatrends, Inc. ** +#** ** +#** All Rights Reserved. ** +#** ** +#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +#** ** +#** Phone: (770)-246-8600 ** +#** ** +#********************************************************************** +#********************************************************************** diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/EdkIIGlueBaseLib.sdl b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/EdkIIGlueBaseLib.sdl new file mode 100644 index 0000000..5d37d81 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/EdkIIGlueBaseLib.sdl @@ -0,0 +1,25 @@ +TOKEN + Name = "EdkIIGlueBaseLib_SUPPORT" + Value = "1" + Help = "Main switch to enable EdkIIGlueBaseLib support in Project" + TokenType = Boolean + TargetEQU = Yes + TargetMAK = Yes + Master = Yes +End + +TOKEN + Name = "EdkIIGlueBaseLib_LIB" + Value = "$$(LIB_BUILD_DIR)\EdkIIGlueBaseLib.lib" + TokenType = Expression + TargetMAK = Yes +End + +PATH + Name = "EdkIIGlueBaseLib_DIR" +End + +MODULE + Help = "Includes EdkIIGlueBaseLib.mak to Project" + File = "EdkIIGlueBaseLib.mak" +End diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/EdkIIGlueBaseLibIA32.cif b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/EdkIIGlueBaseLibIA32.cif new file mode 100644 index 0000000..40856ca --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/EdkIIGlueBaseLibIA32.cif @@ -0,0 +1,121 @@ +<component> + name = "EdkIIGlueBaseLibIA32" + category = ModulePart + LocalRoot = "Edk\Foundation\Library\EdkIIGlueLib\Library\BaseLib" + RefName = "EdkIIGlueBaseLibIA32" +[files] +"x86DisablePaging32.c" +"x86DisablePaging64.c" +"x86EnablePaging32.c" +"x86EnablePaging64.c" +"x86FxRestore.c" +"x86FxSave.c" +"x86GetInterruptState.c" +"x86MemoryFence.c" +"x86Msr.c" +"x86ReadGdtr.c" +"x86ReadIdtr.c" +"x86Thunk.c" +"x86WriteGdtr.c" +"x86WriteIdtr.c" +"Unaligned.c" +"Ia32\Non-existing.c" +"Ia32\InternalSwitchStack.c" +"Ia32\LShiftU64.asm" +"Ia32\RShiftU64.asm" +"Ia32\ARShiftU64.asm" +"Ia32\LRotU64.asm" +"Ia32\RRotU64.asm" +"Ia32\MultU64x32.asm" +"Ia32\MultU64x64.asm" +"Ia32\DivU64x32.asm" +"Ia32\ModU64x32.asm" +"Ia32\DivU64x32Remainder.asm" +"Ia32\DivU64x64Remainder.asm" +"Ia32\DivS64x64Remainder.c" +"Ia32\SwapBytes64.asm" +"Ia32\SetJump.asm" +"Ia32\LongJump.asm" +"Ia32\CpuId.asm" +"Ia32\CpuIdEx.asm" +"Ia32\ReadEflags.asm" +"Ia32\ReadMsr64.asm" +"Ia32\WriteMsr64.asm" +"Ia32\ReadCr0.asm" +"Ia32\ReadCr2.asm" +"Ia32\ReadCr3.asm" +"Ia32\ReadCr4.asm" +"Ia32\WriteCr0.asm" +"Ia32\WriteCr2.asm" +"Ia32\WriteCr3.asm" +"Ia32\WriteCr4.asm" +"Ia32\ReadDr0.asm" +"Ia32\ReadDr1.asm" +"Ia32\ReadDr2.asm" +"Ia32\ReadDr3.asm" +"Ia32\ReadDr4.asm" +"Ia32\ReadDr5.asm" +"Ia32\ReadDr6.asm" +"Ia32\ReadDr7.asm" +"Ia32\WriteDr0.asm" +"Ia32\WriteDr1.asm" +"Ia32\WriteDr2.asm" +"Ia32\WriteDr3.asm" +"Ia32\WriteDr4.asm" +"Ia32\WriteDr5.asm" +"Ia32\WriteDr6.asm" +"Ia32\WriteDr7.asm" +"Ia32\ReadCs.asm" +"Ia32\ReadDs.asm" +"Ia32\ReadEs.asm" +"Ia32\ReadFs.asm" +"Ia32\ReadGs.asm" +"Ia32\ReadSs.asm" +"Ia32\ReadTr.asm" +"Ia32\ReadGdtr.asm" +"Ia32\WriteGdtr.asm" +"Ia32\ReadIdtr.asm" +"Ia32\WriteIdtr.asm" +"Ia32\ReadLdtr.asm" +"Ia32\WriteLdtr.asm" +"Ia32\FxSave.asm" +"Ia32\FxRestore.asm" +"Ia32\ReadMm0.asm" +"Ia32\ReadMm1.asm" +"Ia32\ReadMm2.asm" +"Ia32\ReadMm3.asm" +"Ia32\ReadMm4.asm" +"Ia32\ReadMm5.asm" +"Ia32\ReadMm6.asm" +"Ia32\ReadMm7.asm" +"Ia32\WriteMm0.asm" +"Ia32\WriteMm1.asm" +"Ia32\WriteMm2.asm" +"Ia32\WriteMm3.asm" +"Ia32\WriteMm4.asm" +"Ia32\WriteMm5.asm" +"Ia32\WriteMm6.asm" +"Ia32\WriteMm7.asm" +"Ia32\ReadTsc.asm" +"Ia32\ReadPmc.asm" +"Ia32\Monitor.asm" +"Ia32\Mwait.asm" +"Ia32\EnablePaging32.asm" +"Ia32\DisablePaging32.asm" +"Ia32\EnablePaging64.asm" +"Ia32\Wbinvd.asm" +"Ia32\Invd.asm" +"Ia32\FlushCacheLine.asm" +"Ia32\InterlockedIncrement.asm" +"Ia32\InterlockedDecrement.asm" +"Ia32\InterlockedCompareExchange32.asm" +"Ia32\InterlockedCompareExchange64.asm" +"Ia32\EnableInterrupts.asm" +"Ia32\DisableInterrupts.asm" +"Ia32\EnableDisableInterrupts.asm" +"Ia32\CpuSleep.asm" +"Ia32\CpuPause.asm" +"Ia32\CpuBreakpoint.asm" +"Ia32\CpuFlushTlb.asm" +"Ia32\Thunk16.asm" +<endComponent> diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/EdkIIGlueBaseLibX64.cif b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/EdkIIGlueBaseLibX64.cif new file mode 100644 index 0000000..1dd7619 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/EdkIIGlueBaseLibX64.cif @@ -0,0 +1,108 @@ +<component> + name = "EdkIIGlueBaseLibX64" + category = ModulePart + LocalRoot = "Edk\Foundation\Library\EdkIIGlueLib\Library\BaseLib" + RefName = "EdkIIGlueBaseLibX64" +[files] +"x86DisablePaging32.c" +"x86DisablePaging64.c" +"x86EnablePaging32.c" +"x86EnablePaging64.c" +"x86FxRestore.c" +"x86FxSave.c" +"x86GetInterruptState.c" +"x86MemoryFence.c" +"x86Msr.c" +"x86ReadGdtr.c" +"x86ReadIdtr.c" +"x86Thunk.c" +"x86WriteGdtr.c" +"x86WriteIdtr.c" +"Unaligned.c" +"Math64.c" +"X64\Non-existing.c" +"X64\SwitchStack.asm" +"X64\SetJump.asm" +"X64\LongJump.asm" +"X64\CpuId.asm" +"X64\CpuIdEx.asm" +"X64\ReadEflags.asm" +"X64\ReadMsr64.asm" +"X64\WriteMsr64.asm" +"X64\ReadCr0.asm" +"X64\ReadCr2.asm" +"X64\ReadCr3.asm" +"X64\ReadCr4.asm" +"X64\WriteCr0.asm" +"X64\WriteCr2.asm" +"X64\WriteCr3.asm" +"X64\WriteCr4.asm" +"X64\ReadDr0.asm" +"X64\ReadDr1.asm" +"X64\ReadDr2.asm" +"X64\ReadDr3.asm" +"X64\ReadDr4.asm" +"X64\ReadDr5.asm" +"X64\ReadDr6.asm" +"X64\ReadDr7.asm" +"X64\WriteDr0.asm" +"X64\WriteDr1.asm" +"X64\WriteDr2.asm" +"X64\WriteDr3.asm" +"X64\WriteDr4.asm" +"X64\WriteDr5.asm" +"X64\WriteDr6.asm" +"X64\WriteDr7.asm" +"X64\ReadCs.asm" +"X64\ReadDs.asm" +"X64\ReadEs.asm" +"X64\ReadFs.asm" +"X64\ReadGs.asm" +"X64\ReadSs.asm" +"X64\ReadTr.asm" +"X64\ReadGdtr.asm" +"X64\WriteGdtr.asm" +"X64\ReadIdtr.asm" +"X64\WriteIdtr.asm" +"X64\ReadLdtr.asm" +"X64\WriteLdtr.asm" +"X64\FxSave.asm" +"X64\FxRestore.asm" +"X64\ReadMm0.asm" +"X64\ReadMm1.asm" +"X64\ReadMm2.asm" +"X64\ReadMm3.asm" +"X64\ReadMm4.asm" +"X64\ReadMm5.asm" +"X64\ReadMm6.asm" +"X64\ReadMm7.asm" +"X64\WriteMm0.asm" +"X64\WriteMm1.asm" +"X64\WriteMm2.asm" +"X64\WriteMm3.asm" +"X64\WriteMm4.asm" +"X64\WriteMm5.asm" +"X64\WriteMm6.asm" +"X64\WriteMm7.asm" +"X64\ReadTsc.asm" +"X64\ReadPmc.asm" +"X64\Monitor.asm" +"X64\Mwait.asm" +"X64\EnablePaging64.asm" +"X64\DisablePaging64.asm" +"X64\Wbinvd.asm" +"X64\Invd.asm" +"X64\FlushCacheLine.asm" +"X64\InterlockedIncrement.asm" +"X64\InterlockedDecrement.asm" +"X64\InterlockedCompareExchange32.asm" +"X64\InterlockedCompareExchange64.asm" +"X64\EnableInterrupts.asm" +"X64\DisableInterrupts.asm" +"X64\EnableDisableInterrupts.asm" +"X64\CpuSleep.asm" +"X64\CpuPause.asm" +"X64\CpuBreakpoint.asm" +"X64\CpuFlushTlb.asm" +"X64\Thunk16.asm" +<endComponent> diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/GetPowerOfTwo32.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/GetPowerOfTwo32.c new file mode 100644 index 0000000..2b8c47b --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/GetPowerOfTwo32.c @@ -0,0 +1,48 @@ +/*++ + +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: + + GetPowerOfTwo32.c + +Abstract: + + Math worker functions. + +--*/ + +#include "BaseLibInternal.h" + +/** + Returns the value of the highest bit set in a 32-bit value. Equivalent to + 1 << HighBitSet32(x). + + This function computes the value of the highest bit set in the 32-bit value + specified by Operand. If Operand is zero, then zero is returned. + + @param Operand The 32-bit operand to evaluate. + + @return 1 << HighBitSet32(Operand) + @retval 0 Operand is zero. + +**/ +UINT32 +EFIAPI +GetPowerOfTwo32 ( + IN UINT32 Operand + ) +{ + if (Operand == 0) { + return 0; + } + + return 1ul << HighBitSet32 (Operand); +} diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/GetPowerOfTwo64.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/GetPowerOfTwo64.c new file mode 100644 index 0000000..9b1f081 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/GetPowerOfTwo64.c @@ -0,0 +1,49 @@ +/*++ + +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: + + GetPowerOfTwo64.c + +Abstract: + + Math worker functions. + +--*/ + +#include "BaseLibInternal.h" + +/** + Returns the value of the highest bit set in a 64-bit value. Equivalent to + 1 << HighBitSet64(x). + + This function computes the value of the highest bit set in the 64-bit value + specified by Operand. If Operand is zero, then zero is returned. + + @param Operand The 64-bit operand to evaluate. + + @return 1 << HighBitSet64(Operand) + @retval 0 Operand is zero. + +**/ +UINT64 +EFIAPI +GetPowerOfTwo64 ( + IN UINT64 Operand + ) +{ + if (Operand == 0) { + return 0; + } + + return LShiftU64 (1, HighBitSet64 (Operand)); +} diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/HighBitSet32.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/HighBitSet32.c new file mode 100644 index 0000000..7db1a02 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/HighBitSet32.c @@ -0,0 +1,49 @@ +/*++ + +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: + + HighBitSet32.c + +Abstract: + + Math worker functions. + +--*/ + +#include "BaseLibInternal.h" + +/** + Returns the bit position of the highest bit set in a 32-bit value. Equivalent + to log2(x). + + This function computes the bit position of the highest bit set in the 32-bit + value specified by Operand. If Operand is zero, then -1 is returned. + Otherwise, a value between 0 and 31 is returned. + + @param Operand The 32-bit operand to evaluate. + + @return Position of the highest bit set in Operand if found. + @retval -1 Operand is zero. + +**/ +INTN +EFIAPI +HighBitSet32 ( + IN UINT32 Operand + ) +{ + INTN BitIndex; + + for (BitIndex = -1; Operand != 0; BitIndex++, Operand >>= 1); + return BitIndex; +} diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/HighBitSet64.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/HighBitSet64.c new file mode 100644 index 0000000..807871b --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/HighBitSet64.c @@ -0,0 +1,51 @@ +/*++ + +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: + + HighBitSet64.c + +Abstract: + + Math worker functions. + +--*/ + +#include "BaseLibInternal.h" + +/** + Returns the bit position of the highest bit set in a 64-bit value. Equivalent + to log2(x). + + This function computes the bit position of the highest bit set in the 64-bit + value specified by Operand. If Operand is zero, then -1 is returned. + Otherwise, a value between 0 and 63 is returned. + + @param Operand The 64-bit operand to evaluate. + + @return Position of the highest bit set in Operand if found. + @retval -1 Operand is zero. + +**/ +INTN +EFIAPI +HighBitSet64 ( + IN UINT64 Operand + ) +{ + INTN BitIndex; + + for (BitIndex = -1; + Operand != 0; + BitIndex++, Operand = RShiftU64 (Operand, 1)); + return BitIndex; +} diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ARShiftU64.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ARShiftU64.asm new file mode 100644 index 0000000..3885bbc --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ARShiftU64.asm @@ -0,0 +1,44 @@ +; 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: +; +; ARShiftU64.asm +; +; Abstract: +; +; 64-bit arithmetic right shift function for IA-32 +; +;------------------------------------------------------------------------------ + + .686 + .model flat,C + .code + +;------------------------------------------------------------------------------ +; UINT64 +; EFIAPI +; InternalMathARShiftU64 ( +; IN UINT64 Operand, +; IN UINTN Count +; ); +;------------------------------------------------------------------------------ +InternalMathARShiftU64 PROC + mov cl, [esp + 12] + mov eax, [esp + 8] + cdq + test cl, 32 + cmovz edx, eax + cmovz eax, [esp + 4] + shrd eax, edx, cl + sar edx, cl + ret +InternalMathARShiftU64 ENDP + + END
\ No newline at end of file diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/CpuBreakpoint.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/CpuBreakpoint.asm new file mode 100644 index 0000000..2f5c181 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/CpuBreakpoint.asm @@ -0,0 +1,39 @@ +; 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: +; +; CpuBreakpoint.Asm +; +; Abstract: +; +; CpuBreakpoint function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .686 + .model flat + .xmm + .code + +;------------------------------------------------------------------------------ +; VOID +; EFIAPI +; CpuBreakpoint ( +; VOID +; ); +;------------------------------------------------------------------------------ +_CpuBreakpoint PROC + int 3 + ret +_CpuBreakpoint ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/CpuFlushTlb.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/CpuFlushTlb.asm new file mode 100644 index 0000000..acf3833 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/CpuFlushTlb.asm @@ -0,0 +1,39 @@ +; 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: +; +; CpuFlushTlb.Asm +; +; Abstract: +; +; CpuFlushTlb function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .386p + .model flat,C + .code + +;------------------------------------------------------------------------------ +; VOID +; EFIAPI +; CpuFlushTlb ( +; VOID +; ); +;------------------------------------------------------------------------------ +CpuFlushTlb PROC + mov eax, cr3 + mov cr3, eax + ret +CpuFlushTlb ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/CpuId.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/CpuId.asm new file mode 100644 index 0000000..9b87d60 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/CpuId.asm @@ -0,0 +1,64 @@ +; 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: +; +; CpuId.Asm +; +; Abstract: +; +; AsmCpuid function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .586P + .model flat,C + .code + +;------------------------------------------------------------------------------ +; VOID +; EFIAPI +; AsmCpuid ( +; IN UINT32 RegisterInEax, +; OUT UINT32 *RegisterOutEax OPTIONAL, +; OUT UINT32 *RegisterOutEbx OPTIONAL, +; OUT UINT32 *RegisterOutEcx OPTIONAL, +; OUT UINT32 *RegisterOutEdx OPTIONAL +; ); +;------------------------------------------------------------------------------ +AsmCpuid PROC USES ebx + push ebp + mov ebp, esp + mov eax, [ebp + 12] + cpuid + push ecx + mov ecx, [ebp + 16] + jecxz @F + mov [ecx], eax +@@: + mov ecx, [ebp + 20] + jecxz @F + mov [ecx], ebx +@@: + mov ecx, [ebp + 24] + jecxz @F + pop [ecx] +@@: + mov ecx, [ebp + 28] + jecxz @F + mov [ecx], edx +@@: + mov eax, [ebp + 12] + leave + ret +AsmCpuid ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/CpuIdEx.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/CpuIdEx.asm new file mode 100644 index 0000000..4c52315 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/CpuIdEx.asm @@ -0,0 +1,66 @@ +; 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: +; +; CpuIdEx.Asm +; +; Abstract: +; +; AsmCpuidEx function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .686 + .model flat,C + .code + +;------------------------------------------------------------------------------ +; UINT32 +; EFIAPI +; AsmCpuidEx ( +; IN UINT32 RegisterInEax, +; IN UINT32 RegisterInEcx, +; OUT UINT32 *RegisterOutEax OPTIONAL, +; OUT UINT32 *RegisterOutEbx OPTIONAL, +; OUT UINT32 *RegisterOutEcx OPTIONAL, +; OUT UINT32 *RegisterOutEdx OPTIONAL +; ) +;------------------------------------------------------------------------------ +AsmCpuidEx PROC USES ebx + push ebp + mov ebp, esp + mov eax, [ebp + 12] + mov ecx, [ebp + 16] + cpuid + push ecx + mov ecx, [ebp + 20] + jecxz @F + mov [ecx], eax +@@: + mov ecx, [ebp + 24] + jecxz @F + mov [ecx], ebx +@@: + mov ecx, [ebp + 28] + jecxz @F + pop [ecx] +@@: + mov edx, [ebp + 32] + jecxz @F + mov [ecx], edx +@@: + mov eax, [ebp + 12] + leave + ret +AsmCpuidEx ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/CpuPause.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/CpuPause.asm new file mode 100644 index 0000000..46b8a19 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/CpuPause.asm @@ -0,0 +1,39 @@ +; 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: +; +; CpuPause.Asm +; +; Abstract: +; +; CpuPause function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .686 + .model flat,C + .xmm + .code + +;------------------------------------------------------------------------------ +; VOID +; EFIAPI +; CpuPause ( +; VOID +; ); +;------------------------------------------------------------------------------ +CpuPause PROC + pause + ret +CpuPause ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/CpuSleep.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/CpuSleep.asm new file mode 100644 index 0000000..0f72a5d --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/CpuSleep.asm @@ -0,0 +1,38 @@ +; 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: +; +; CpuSleep.Asm +; +; Abstract: +; +; CpuSleep function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .386 + .model flat,C + .code + +;------------------------------------------------------------------------------ +; VOID +; EFIAPI +; CpuSleep ( +; VOID +; ); +;------------------------------------------------------------------------------ +CpuSleep PROC + hlt + ret +CpuSleep ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/DisableInterrupts.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/DisableInterrupts.asm new file mode 100644 index 0000000..ca1e775 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/DisableInterrupts.asm @@ -0,0 +1,38 @@ +; 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: +; +; DisableInterrupts.Asm +; +; Abstract: +; +; DisableInterrupts function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .386p + .model flat,C + .code + +;------------------------------------------------------------------------------ +; VOID +; EFIAPI +; DisableInterrupts ( +; VOID +; ); +;------------------------------------------------------------------------------ +DisableInterrupts PROC + cli + ret +DisableInterrupts ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/DisablePaging32.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/DisablePaging32.asm new file mode 100644 index 0000000..ab77ec0 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/DisablePaging32.asm @@ -0,0 +1,55 @@ +; 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: +; +; DisablePaging32.Asm +; +; Abstract: +; +; AsmDisablePaging32 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .386 + .model flat,C + .code + +;------------------------------------------------------------------------------ +; VOID +; EFIAPI +; InternalX86DisablePaging32 ( +; IN SWITCH_STACK_ENTRY_POINT EntryPoint, +; IN VOID *Context1, OPTIONAL +; IN VOID *Context2, OPTIONAL +; IN VOID *NewStack +; ); +;------------------------------------------------------------------------------ +InternalX86DisablePaging32 PROC + mov ebx, [esp + 4] + mov ecx, [esp + 8] + mov edx, [esp + 12] + pushfd + pop edi ; save EFLAGS to edi + cli + mov eax, cr0 + btr eax, 31 + mov esp, [esp + 16] + mov cr0, eax + push edi + popfd ; restore EFLAGS from edi + push edx + push ecx + call ebx + jmp $ ; EntryPoint() should not return +InternalX86DisablePaging32 ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/DivS64x64Remainder.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/DivS64x64Remainder.c new file mode 100644 index 0000000..d9df26e --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/DivS64x64Remainder.c @@ -0,0 +1,60 @@ +/*++ + +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: + + DivS64x64Remainder.c + +Abstract: + + Integer division worker functions for Ia32. + +--*/ + +#include "..\BaseLibInternal.h" + +/** + Worker function that Divides a 64-bit signed integer by a 64-bit signed integer and + generates a 64-bit signed result and a optional 64-bit signed remainder. + + This function divides the 64-bit unsigned value Dividend by the 64-bit + unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder + is not NULL, then the 64-bit unsigned remainder is returned in Remainder. + This function returns the 64-bit unsigned quotient. + + @param Dividend A 64-bit signed value. + @param Divisor A 64-bit signed value. + @param Remainder A pointer to a 64-bit signed value. This parameter is + optional and may be NULL. + + @return Dividend / Divisor + +**/ +INT64 +InternalMathDivRemS64x64 ( + IN INT64 Dividend, + IN INT64 Divisor, + OUT INT64 *Remainder OPTIONAL + ) +{ + INT64 Quot; + + Quot = InternalMathDivRemU64x64 ( + Dividend >= 0 ? Dividend : -Dividend, + Divisor >= 0 ? Divisor : -Divisor, + (UINT64 *) Remainder + ); + if (Remainder != NULL && Dividend < 0) { + *Remainder = -*Remainder; + } + return (Dividend ^ Divisor) >= 0 ? Quot : -Quot; +} diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/DivU64x32.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/DivU64x32.asm new file mode 100644 index 0000000..999c8ad --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/DivU64x32.asm @@ -0,0 +1,44 @@ +; 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: +; +; DivU64x32.asm +; +; Abstract: +; +; Calculate the quotient of a 64-bit integer by a 32-bit integer +; +;------------------------------------------------------------------------------ + + .386 + .model flat,C + .code + +;------------------------------------------------------------------------------ +; UINT64 +; EFIAPI +; InternalMathDivU64x32 ( +; IN UINT64 Dividend, +; IN UINT32 Divisor +; ); +;------------------------------------------------------------------------------ +InternalMathDivU64x32 PROC + mov eax, [esp + 8] + mov ecx, [esp + 12] + xor edx, edx + div ecx + push eax ; save quotient on stack + mov eax, [esp + 8] + div ecx + pop edx ; restore high-order dword of the quotient + ret +InternalMathDivU64x32 ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/DivU64x32Remainder.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/DivU64x32Remainder.asm new file mode 100644 index 0000000..a9f58b9 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/DivU64x32Remainder.asm @@ -0,0 +1,49 @@ +; 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: +; +; DivError.asm +; +; Abstract: +; +; Set error flag for all division functions +; +;------------------------------------------------------------------------------ + + .386 + .model flat,C + .code + +;------------------------------------------------------------------------------ +; UINT64 +; EFIAPI +; InternalMathDivRemU64x32 ( +; IN UINT64 Dividend, +; IN UINT32 Divisor, +; OUT UINT32 *Remainder +; ); +;------------------------------------------------------------------------------ +InternalMathDivRemU64x32 PROC + mov ecx, [esp + 12] + mov eax, [esp + 8] + xor edx, edx + div ecx + push eax + mov eax, [esp + 8] + div ecx + mov ecx, [esp + 20] + jecxz @F ; abandon remainder if Remainder == NULL + mov [ecx], edx +@@: + pop edx + ret +InternalMathDivRemU64x32 ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/DivU64x64Remainder.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/DivU64x64Remainder.asm new file mode 100644 index 0000000..eb16032 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/DivU64x64Remainder.asm @@ -0,0 +1,90 @@ +; 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: +; +; DivU64x64Remainder.asm +; +; Abstract: +; +; Calculate the quotient of a 64-bit integer by a 64-bit integer and returns +; both the quotient and the remainder +; +;------------------------------------------------------------------------------ + + .386 + .model flat,C + .code + +EXTERN InternalMathDivRemU64x32:PROC + +;------------------------------------------------------------------------------ +; UINT64 +; EFIAPI +; InternalMathDivRemU64x64 ( +; IN UINT64 Dividend, +; IN UINT64 Divisor, +; OUT UINT64 *Remainder OPTIONAL +; ); +;------------------------------------------------------------------------------ +InternalMathDivRemU64x64 PROC + mov ecx, [esp + 16] + test ecx, ecx + jnz _@DivRemU64x64 ; call _@DivRemU64x64 if Divisor > 2^32 + mov ecx, [esp + 20] + jecxz @F + and dword ptr [ecx + 4], 0 + mov [esp + 16], ecx +@@: + jmp InternalMathDivRemU64x32 +InternalMathDivRemU64x64 ENDP + +_@DivRemU64x64 PROC USES ebx esi edi + mov edx, dword ptr [esp + 20] + mov eax, dword ptr [esp + 16] ; edx:eax <- dividend + mov edi, edx + mov esi, eax ; edi:esi <- dividend + mov ebx, dword ptr [esp + 24] ; ecx:ebx <- divisor +@@: + shr edx, 1 + rcr eax, 1 + shrd ebx, ecx, 1 + shr ecx, 1 + jnz @B + div ebx + mov ebx, eax ; ebx <- quotient + mov ecx, [esp + 28] + mul dword ptr [esp + 24] + imul ecx, ebx + add edx, ecx + mov ecx, dword ptr [esp + 32] + jc @TooLarge ; product > 2^64 + cmp edi, edx ; compare high 32 bits + ja @Correct + jb @TooLarge ; product > dividend + cmp esi, eax + jae @Correct ; product <= dividend +@TooLarge: + dec ebx ; adjust quotient by -1 + jecxz @Return ; return if Remainder == NULL + sub eax, dword ptr [esp + 24] + sbb edx, dword ptr [esp + 28] +@Correct: + jecxz @Return + sub esi, eax + sbb edi, edx ; edi:esi <- remainder + mov [ecx], esi + mov [ecx + 4], edi +@Return: + mov eax, ebx ; eax <- quotient + xor edx, edx + ret +_@DivRemU64x64 ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/EnableDisableInterrupts.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/EnableDisableInterrupts.asm new file mode 100644 index 0000000..80a07e6 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/EnableDisableInterrupts.asm @@ -0,0 +1,39 @@ +; 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: +; +; EnableDisableInterrupts.Asm +; +; Abstract: +; +; EnableDisableInterrupts function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .386p + .model flat + .code + +;------------------------------------------------------------------------------ +; VOID +; EFIAPI +; EnableDisableInterrupts ( +; VOID +; ); +;------------------------------------------------------------------------------ +_EnableDisableInterrupts PROC + sti + cli + ret +_EnableDisableInterrupts ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/EnableInterrupts.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/EnableInterrupts.asm new file mode 100644 index 0000000..961bb32 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/EnableInterrupts.asm @@ -0,0 +1,38 @@ +; 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: +; +; EnableInterrupts.Asm +; +; Abstract: +; +; EnableInterrupts function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .386p + .model flat + .code + +;------------------------------------------------------------------------------ +; VOID +; EFIAPI +; EnableInterrupts ( +; VOID +; ); +;------------------------------------------------------------------------------ +_EnableInterrupts PROC + sti + ret +_EnableInterrupts ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/EnablePaging32.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/EnablePaging32.asm new file mode 100644 index 0000000..16d4ae1 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/EnablePaging32.asm @@ -0,0 +1,55 @@ +; 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: +; +; EnablePaging32.Asm +; +; Abstract: +; +; AsmEnablePaging32 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .386 + .model flat,C + .code + +;------------------------------------------------------------------------------ +; VOID +; EFIAPI +; InternalX86EnablePaging32 ( +; IN SWITCH_STACK_ENTRY_POINT EntryPoint, +; IN VOID *Context1, OPTIONAL +; IN VOID *Context2, OPTIONAL +; IN VOID *NewStack +; ); +;------------------------------------------------------------------------------ +InternalX86EnablePaging32 PROC + mov ebx, [esp + 4] + mov ecx, [esp + 8] + mov edx, [esp + 12] + pushfd + pop edi + cli + mov eax, cr0 + bts eax, 31 + mov esp, [esp + 16] + mov cr0, eax + push edi + popfd + push edx + push ecx + call ebx + jmp $ +InternalX86EnablePaging32 ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/EnablePaging64.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/EnablePaging64.asm new file mode 100644 index 0000000..ce30372 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/EnablePaging64.asm @@ -0,0 +1,66 @@ +; 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: +; +; EnablePaging64.Asm +; +; Abstract: +; +; AsmEnablePaging64 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .686p + .model flat,C + .code + +;------------------------------------------------------------------------------ +; VOID +; EFIAPI +; InternalX86EnablePaging64 ( +; IN UINT16 Cs, +; IN UINT64 EntryPoint, +; IN UINT64 Context1, OPTIONAL +; IN UINT64 Context2, OPTIONAL +; IN UINT64 NewStack +; ); +;------------------------------------------------------------------------------ +InternalX86EnablePaging64 PROC + cli + mov [esp], @F ; offset for far retf, seg is the 1st arg + mov eax, cr4 + or al, (1 SHL 5) + mov cr4, eax ; enable PAE + mov ecx, 0c0000080h + rdmsr + or ah, 1 ; set LME + wrmsr + mov eax, cr0 + bts eax, 31 + mov cr0, eax ; enable paging + retf +@@: ; long mode starts here + DB 67h, 48h + mov ebx, [esp] ; mov rbx, [esp] + DB 67h, 48h + mov ecx, [esp + 8] ; mov rcx, [esp + 8] + DB 67h, 48h + mov edx, [esp + 10h] ; mov rdx, [esp + 10h] + DB 67h, 48h + mov esp, [esp + 18h] ; mov rsp, [esp + 18h] + DB 48h + add esp, -20h ; add rsp, -20h + call ebx ; call rbx + jmp $ +InternalX86EnablePaging64 ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/FlushCacheLine.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/FlushCacheLine.asm new file mode 100644 index 0000000..b6ba954 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/FlushCacheLine.asm @@ -0,0 +1,40 @@ +; 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: +; +; FlushCacheLine.Asm +; +; Abstract: +; +; AsmFlushCacheLine function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .586P + .model flat,C + .xmm + .code + +;------------------------------------------------------------------------------ +; VOID * +; EFIAPI +; AsmFlushCacheLine ( +; IN VOID *LinearAddress +; ); +;------------------------------------------------------------------------------ +AsmFlushCacheLine PROC + mov eax, [esp + 4] + clflush [eax] + ret +AsmFlushCacheLine ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/FxRestore.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/FxRestore.asm new file mode 100644 index 0000000..f1c4f1d --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/FxRestore.asm @@ -0,0 +1,40 @@ +; 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: +; +; FxRestore.Asm +; +; Abstract: +; +; AsmFxRestore function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .586 + .model flat,C + .xmm + .code + +;------------------------------------------------------------------------------ +; VOID +; EFIAPI +; InternalX86FxRestore ( +; IN CONST IA32_FX_BUFFER *Buffer +; ); +;------------------------------------------------------------------------------ +InternalX86FxRestore PROC + mov eax, [esp + 4] + fxrstor [eax] + ret +InternalX86FxRestore ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/FxSave.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/FxSave.asm new file mode 100644 index 0000000..ebdb6ba --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/FxSave.asm @@ -0,0 +1,40 @@ +; 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: +; +; FxSave.Asm +; +; Abstract: +; +; AsmFxSave function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .586 + .model flat,C + .xmm + .code + +;------------------------------------------------------------------------------ +; VOID +; EFIAPI +; InternalX86FxSave ( +; OUT IA32_FX_BUFFER *Buffer +; ); +;------------------------------------------------------------------------------ +InternalX86FxSave PROC + mov eax, [esp + 4] + fxsave [eax] + ret +InternalX86FxSave ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/InterlockedCompareExchange32.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/InterlockedCompareExchange32.asm new file mode 100644 index 0000000..c18f136 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/InterlockedCompareExchange32.asm @@ -0,0 +1,43 @@ +; 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: +; +; InterlockedCompareExchange32.Asm +; +; Abstract: +; +; InterlockedCompareExchange32 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .486 + .model flat,C + .code + +;------------------------------------------------------------------------------ +; UINT32 +; EFIAPI +; InternalSyncCompareExchange32 ( +; IN UINT32 *Value, +; IN UINT32 CompareValue, +; IN UINT32 ExchangeValue +; ); +;------------------------------------------------------------------------------ +InternalSyncCompareExchange32 PROC + mov ecx, [esp + 4] + mov eax, [esp + 8] + mov edx, [esp + 12] + lock cmpxchg [ecx], edx + ret +InternalSyncCompareExchange32 ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/InterlockedCompareExchange64.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/InterlockedCompareExchange64.asm new file mode 100644 index 0000000..965f195 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/InterlockedCompareExchange64.asm @@ -0,0 +1,45 @@ +; 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: +; +; InterlockedCompareExchange64.Asm +; +; Abstract: +; +; InterlockedCompareExchange64 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .586P + .model flat,C + .code + +;------------------------------------------------------------------------------ +; UINT64 +; EFIAPI +; InternalSyncCompareExchange64 ( +; IN UINT64 *Value, +; IN UINT64 CompareValue, +; IN UINT64 ExchangeValue +; ); +;------------------------------------------------------------------------------ +InternalSyncCompareExchange64 PROC USES esi ebx + mov esi, [esp + 12] + mov eax, [esp + 16] + mov edx, [esp + 20] + mov ebx, [esp + 24] + mov ecx, [esp + 28] + lock cmpxchg8b qword ptr [esi] + ret +InternalSyncCompareExchange64 ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/InterlockedDecrement.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/InterlockedDecrement.asm new file mode 100644 index 0000000..d84e8e6 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/InterlockedDecrement.asm @@ -0,0 +1,40 @@ +; 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: +; +; InterlockedDecrement.Asm +; +; Abstract: +; +; InterlockedDecrement function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .386 + .model flat,C + .code + +;------------------------------------------------------------------------------ +; UINT32 +; EFIAPI +; InternalSyncDecrement ( +; IN UINT32 *Value +; ); +;------------------------------------------------------------------------------ +InternalSyncDecrement PROC + mov eax, [esp + 4] + lock dec dword ptr [eax] + mov eax, [eax] + ret +InternalSyncDecrement ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/InterlockedIncrement.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/InterlockedIncrement.asm new file mode 100644 index 0000000..dff11e1 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/InterlockedIncrement.asm @@ -0,0 +1,40 @@ +; 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: +; +; InterlockedIncrement.Asm +; +; Abstract: +; +; InterlockedIncrement function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .386 + .model flat,C + .code + +;------------------------------------------------------------------------------ +; UINT32 +; EFIAPI +; InternalSyncIncrement ( +; IN UINT32 *Value +; ); +;------------------------------------------------------------------------------ +InternalSyncIncrement PROC + mov eax, [esp + 4] + lock inc dword ptr [eax] + mov eax, [eax] + ret +InternalSyncIncrement ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/InternalSwitchStack.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/InternalSwitchStack.c new file mode 100644 index 0000000..0f777d2 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/InternalSwitchStack.c @@ -0,0 +1,60 @@ +/*++ + +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: + + InternalSwitchStack.c + +Abstract: + + SwitchStack() function for IA-32. + +--*/ + +#include "..\BaseLibInternal.h" + +/** + Transfers control to a function starting with a new stack. + + Transfers control to the function specified by EntryPoint using the new stack + specified by NewStack and passing in the parameters specified by Context1 and + Context2. Context1 and Context2 are optional and may be NULL. The function + EntryPoint must never return. + + @param EntryPoint A pointer to function to call with the new stack. + @param Context1 A pointer to the context to pass into the EntryPoint + function. + @param Context2 A pointer to the context to pass into the EntryPoint + function. + @param NewStack A pointer to the new stack to use for the EntryPoint + function. + +**/ +VOID +EFIAPI +InternalSwitchStack ( + IN SWITCH_STACK_ENTRY_POINT EntryPoint, + IN VOID *Context1, + IN VOID *Context2, + IN VOID *NewStack + ) +{ + BASE_LIBRARY_JUMP_BUFFER JumpBuffer; + + JumpBuffer.Eip = (UINTN)EntryPoint; + JumpBuffer.Esp = (UINTN)NewStack - sizeof (VOID*); + JumpBuffer.Esp -= sizeof (Context1) + sizeof (Context2); + ((VOID**)JumpBuffer.Esp)[1] = Context1; + ((VOID**)JumpBuffer.Esp)[2] = Context2; + + LongJump (&JumpBuffer, (UINTN)-1); +} diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/Invd.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/Invd.asm new file mode 100644 index 0000000..8f3ba9b --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/Invd.asm @@ -0,0 +1,38 @@ +; 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: +; +; Invd.Asm +; +; Abstract: +; +; AsmInvd function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .486p + .model flat + .code + +;------------------------------------------------------------------------------ +; VOID +; EFIAPI +; AsmInvd ( +; VOID +; ); +;------------------------------------------------------------------------------ +_AsmInvd PROC + invd + ret +_AsmInvd ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/LRotU64.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/LRotU64.asm new file mode 100644 index 0000000..9a9307a --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/LRotU64.asm @@ -0,0 +1,47 @@ +; 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: +; +; LRotU64.asm +; +; Abstract: +; +; 64-bit left rotation for Ia32 +; +;------------------------------------------------------------------------------ + + .686 + .model flat,C + .code + +;------------------------------------------------------------------------------ +; UINT64 +; EFIAPI +; InternalMathLRotU64 ( +; IN UINT64 Operand, +; IN UINTN Count +; ); +;------------------------------------------------------------------------------ +InternalMathLRotU64 PROC USES ebx + mov cl, [esp + 16] + mov edx, [esp + 12] + mov eax, [esp + 8] + shld ebx, edx, cl + shld edx, eax, cl + ror ebx, cl + shld eax, ebx, cl + test cl, 32 ; Count >= 32? + cmovnz ecx, eax + cmovnz eax, edx + cmovnz edx, ecx + ret +InternalMathLRotU64 ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/LShiftU64.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/LShiftU64.asm new file mode 100644 index 0000000..4b71204 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/LShiftU64.asm @@ -0,0 +1,44 @@ +; 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: +; +; LShiftU64.asm +; +; Abstract: +; +; 64-bit left shift function for IA-32 +; +;------------------------------------------------------------------------------ + + .686 + .model flat,C + .code + +;------------------------------------------------------------------------------ +; UINT64 +; EFIAPI +; InternalMathLShiftU64 ( +; IN UINT64 Operand, +; IN UINTN Count +; ); +;------------------------------------------------------------------------------ +InternalMathLShiftU64 PROC + mov cl, [esp + 12] + xor eax, eax + mov edx, [esp + 4] + test cl, 32 ; Count >= 32? + cmovz eax, edx + cmovz edx, [esp + 8] + shld edx, eax, cl + shl eax, cl + ret +InternalMathLShiftU64 ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/LongJump.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/LongJump.asm new file mode 100644 index 0000000..5a46082 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/LongJump.asm @@ -0,0 +1,44 @@ +; 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: +; +; LongJump.Asm +; +; Abstract: +; +; Implementation of _LongJump() on IA-32. +; +;------------------------------------------------------------------------------ + + .386 + .model flat,C + .code + +;------------------------------------------------------------------------------ +; VOID +; EFIAPI +; InternalLongJump ( +; IN BASE_LIBRARY_JUMP_BUFFER *JumpBuffer, +; IN UINTN Value +; ); +;------------------------------------------------------------------------------ +InternalLongJump PROC + pop eax ; skip return address + pop edx ; edx <- JumpBuffer + pop eax ; eax <- Value + mov ebx, [edx] + mov esi, [edx + 4] + mov edi, [edx + 8] + mov ebp, [edx + 12] + mov esp, [edx + 16] + jmp dword ptr [edx + 20] +InternalLongJump ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ModU64x32.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ModU64x32.asm new file mode 100644 index 0000000..db06549 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ModU64x32.asm @@ -0,0 +1,43 @@ +; 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: +; +; DivU64x32.asm +; +; Abstract: +; +; Calculate the remainder of a 64-bit integer by a 32-bit integer +; +;------------------------------------------------------------------------------ + + .386 + .model flat,C + .code + +;------------------------------------------------------------------------------ +; UINT32 +; EFIAPI +; InternalMathModU64x32 ( +; IN UINT64 Dividend, +; IN UINT32 Divisor +; ); +;------------------------------------------------------------------------------ +InternalMathModU64x32 PROC + mov eax, [esp + 8] + mov ecx, [esp + 12] + xor edx, edx + div ecx + mov eax, [esp + 4] + div ecx + mov eax, edx + ret +InternalMathModU64x32 ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/Monitor.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/Monitor.asm new file mode 100644 index 0000000..f06048c --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/Monitor.asm @@ -0,0 +1,43 @@ +; 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: +; +; Monitor.Asm +; +; Abstract: +; +; AsmMonitor function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .686 + .model flat,C + .code + +;------------------------------------------------------------------------------ +; UINTN +; EFIAPI +; AsmMonitor ( +; IN UINTN Eax, +; IN UINTN Ecx, +; IN UINTN Edx +; ); +;------------------------------------------------------------------------------ +AsmMonitor PROC + mov eax, [esp + 4] + mov ecx, [esp + 8] + mov edx, [esp + 12] + DB 0fh, 1, 0c8h ; monitor + ret +AsmMonitor ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/MultU64x32.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/MultU64x32.asm new file mode 100644 index 0000000..c8970ec --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/MultU64x32.asm @@ -0,0 +1,41 @@ +; 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: +; +; MultU64x32.asm +; +; Abstract: +; +; Calculate the product of a 64-bit integer and a 32-bit integer +; +;------------------------------------------------------------------------------ + + .386 + .model flat,C + .code + +;------------------------------------------------------------------------------ +; UINT64 +; EFIAPI +; InternalMathMultU64x32 ( +; IN UINT64 Multiplicand, +; IN UINT32 Multiplier +; ); +;------------------------------------------------------------------------------ +InternalMathMultU64x32 PROC + mov ecx, [esp + 12] + mov eax, ecx + imul ecx, [esp + 8] ; overflow not detectable + mul dword ptr [esp + 4] + add edx, ecx + ret +InternalMathMultU64x32 ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/MultU64x64.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/MultU64x64.asm new file mode 100644 index 0000000..7d6acae --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/MultU64x64.asm @@ -0,0 +1,45 @@ +; 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: +; +; MultU64x64.asm +; +; Abstract: +; +; Calculate the product of a 64-bit integer and another 64-bit integer +; +;------------------------------------------------------------------------------ + + .386 + .model flat,C + .code + +;------------------------------------------------------------------------------ +; UINT64 +; EFIAPI +; InternalMathMultU64x64 ( +; IN UINT64 Multiplicand, +; IN UINT64 Multiplier +; ); +;------------------------------------------------------------------------------ +InternalMathMultU64x64 PROC USES ebx + mov ebx, [esp + 8] + mov edx, [esp + 16] + mov ecx, ebx + mov eax, edx + imul ebx, [esp + 20] + imul edx, [esp + 12] + add ebx, edx + mul ecx + add edx, ebx + ret +InternalMathMultU64x64 ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/Mwait.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/Mwait.asm new file mode 100644 index 0000000..0e97013 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/Mwait.asm @@ -0,0 +1,41 @@ +; 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: +; +; Mwait.Asm +; +; Abstract: +; +; AsmMwait function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .686 + .model flat,C + .code + +;------------------------------------------------------------------------------ +; UINTN +; EFIAPI +; AsmMwait ( +; IN UINTN Eax, +; IN UINTN Ecx +; ); +;------------------------------------------------------------------------------ +AsmMwait PROC + mov eax, [esp + 4] + mov ecx, [esp + 8] + DB 0fh, 1, 0c9h ; mwait + ret +AsmMwait ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/Non-existing.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/Non-existing.c new file mode 100644 index 0000000..e0c32c1 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/Non-existing.c @@ -0,0 +1,66 @@ +/*++ + +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: + + Non-existing.c + +Abstract: + + Non-existing BaseLib functions on Ia32 + +--*/ + +#include "..\BaseLibInternal.h" + + +/** + Disables the 64-bit paging mode on the CPU. + + Disables the 64-bit paging mode on the CPU and returns to 32-bit protected + mode. This function assumes the current execution mode is 64-paging mode. + This function is only available on X64. After the 64-bit paging mode is + disabled, control is transferred to the function specified by EntryPoint + using the new stack specified by NewStack and passing in the parameters + specified by Context1 and Context2. Context1 and Context2 are optional and + may be 0. The function EntryPoint must never return. + + @param Cs The 16-bit selector to load in the CS before EntryPoint + is called. The descriptor in the GDT that this selector + references must be setup for 32-bit protected mode. + @param EntryPoint The 64-bit virtual address of the function to call with + the new stack after paging is disabled. + @param Context1 The 64-bit virtual address of the context to pass into + the EntryPoint function as the first parameter after + paging is disabled. + @param Context2 The 64-bit virtual address of the context to pass into + the EntryPoint function as the second parameter after + paging is disabled. + @param NewStack The 64-bit virtual address of the new stack to use for + the EntryPoint function after paging is disabled. + +**/ +VOID +EFIAPI +InternalX86DisablePaging64 ( + IN UINT16 CodeSelector, + IN UINT32 EntryPoint, + IN UINT32 Context1, OPTIONAL + IN UINT32 Context2, OPTIONAL + IN UINT32 NewStack + ) +{ + // + // This function cannot work on IA32 platform + // + ASSERT (FALSE); +} diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/RRotU64.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/RRotU64.asm new file mode 100644 index 0000000..5cac1ba --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/RRotU64.asm @@ -0,0 +1,47 @@ +; 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: +; +; RRotU64.asm +; +; Abstract: +; +; 64-bit right rotation for Ia32 +; +;------------------------------------------------------------------------------ + + .686 + .model flat,C + .code + +;------------------------------------------------------------------------------ +; UINT64 +; EFIAPI +; InternalMathRRotU64 ( +; IN UINT64 Operand, +; IN UINTN Count +; ); +;------------------------------------------------------------------------------ +InternalMathRRotU64 PROC USES ebx + mov cl, [esp + 16] + mov eax, [esp + 8] + mov edx, [esp + 12] + shrd ebx, eax, cl + shrd eax, edx, cl + rol ebx, cl + shrd edx, ebx, cl + test cl, 32 ; Count >= 32? + cmovnz ecx, eax + cmovnz eax, edx + cmovnz edx, ecx + ret +InternalMathRRotU64 ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/RShiftU64.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/RShiftU64.asm new file mode 100644 index 0000000..3b4b45c --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/RShiftU64.asm @@ -0,0 +1,44 @@ +; 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: +; +; RShiftU64.asm +; +; Abstract: +; +; 64-bit logical right shift function for IA-32 +; +;------------------------------------------------------------------------------ + + .686 + .model flat,C + .code + +;------------------------------------------------------------------------------ +; UINT64 +; EFIAPI +; InternalMathRShiftU64 ( +; IN UINT64 Operand, +; IN UINTN Count +; ); +;------------------------------------------------------------------------------ +InternalMathRShiftU64 PROC + mov cl, [esp + 12] + xor edx, edx + mov eax, [esp + 8] + test cl, 32 + cmovz edx, eax + cmovz eax, [esp + 4] + shrd eax, edx, cl + shr edx, cl + ret +InternalMathRShiftU64 ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadCr0.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadCr0.asm new file mode 100644 index 0000000..39b9f92 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadCr0.asm @@ -0,0 +1,38 @@ +; 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: +; +; ReadCr0.Asm +; +; Abstract: +; +; AsmReadCr0 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .386p + .model flat,C + .code + +;------------------------------------------------------------------------------ +; UINTN +; EFIAPI +; AsmReadCr0 ( +; VOID +; ); +;------------------------------------------------------------------------------ +AsmReadCr0 PROC + mov eax, cr0 + ret +AsmReadCr0 ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadCr2.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadCr2.asm new file mode 100644 index 0000000..22cd069 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadCr2.asm @@ -0,0 +1,38 @@ +; 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: +; +; ReadCr2.Asm +; +; Abstract: +; +; AsmReadCr2 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .386p + .model flat,C + .code + +;------------------------------------------------------------------------------ +; UINTN +; EFIAPI +; AsmReadCr2 ( +; VOID +; ); +;------------------------------------------------------------------------------ +AsmReadCr2 PROC + mov eax, cr2 + ret +AsmReadCr2 ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadCr3.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadCr3.asm new file mode 100644 index 0000000..56f0103 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadCr3.asm @@ -0,0 +1,38 @@ +; 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: +; +; ReadCr3.Asm +; +; Abstract: +; +; AsmReadCr3 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .386p + .model flat,C + .code + +;------------------------------------------------------------------------------ +; UINTN +; EFIAPI +; AsmReadCr3 ( +; VOID +; ); +;------------------------------------------------------------------------------ +AsmReadCr3 PROC + mov eax, cr3 + ret +AsmReadCr3 ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadCr4.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadCr4.asm new file mode 100644 index 0000000..61832ed --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadCr4.asm @@ -0,0 +1,38 @@ +; 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: +; +; ReadCr4.Asm +; +; Abstract: +; +; AsmReadCr4 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .586p + .model flat,C + .code + +;------------------------------------------------------------------------------ +; UINTN +; EFIAPI +; AsmReadCr4 ( +; VOID +; ); +;------------------------------------------------------------------------------ +AsmReadCr4 PROC + mov eax, cr4 + ret +AsmReadCr4 ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadCs.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadCs.asm new file mode 100644 index 0000000..a7f189e --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadCs.asm @@ -0,0 +1,38 @@ +; 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: +; +; ReadCs.Asm +; +; Abstract: +; +; AsmReadCs function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .386 + .model flat,C + .code + +;------------------------------------------------------------------------------ +; UINT16 +; EFIAPI +; AsmReadCs ( +; VOID +; ); +;------------------------------------------------------------------------------ +AsmReadCs PROC + mov eax, cs + ret +AsmReadCs ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadDr0.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadDr0.asm new file mode 100644 index 0000000..b9d1fbb --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadDr0.asm @@ -0,0 +1,38 @@ +; 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: +; +; ReadDr0.Asm +; +; Abstract: +; +; AsmReadDr0 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .586p + .model flat,C + .code + +;------------------------------------------------------------------------------ +; UINTN +; EFIAPI +; AsmReadDr0 ( +; VOID +; ); +;------------------------------------------------------------------------------ +AsmReadDr0 PROC + mov eax, dr0 + ret +AsmReadDr0 ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadDr1.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadDr1.asm new file mode 100644 index 0000000..f7367d9 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadDr1.asm @@ -0,0 +1,38 @@ +; 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: +; +; ReadDr1.Asm +; +; Abstract: +; +; AsmReadDr1 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .586p + .model flat,C + .code + +;------------------------------------------------------------------------------ +; UINTN +; EFIAPI +; AsmReadDr1 ( +; VOID +; ); +;------------------------------------------------------------------------------ +AsmReadDr1 PROC + mov eax, dr1 + ret +AsmReadDr1 ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadDr2.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadDr2.asm new file mode 100644 index 0000000..04c55f4 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadDr2.asm @@ -0,0 +1,38 @@ +; 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: +; +; ReadDr2.Asm +; +; Abstract: +; +; AsmReadDr2 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .586p + .model flat,C + .code + +;------------------------------------------------------------------------------ +; UINTN +; EFIAPI +; AsmReadDr2 ( +; VOID +; ); +;------------------------------------------------------------------------------ +AsmReadDr2 PROC + mov eax, dr2 + ret +AsmReadDr2 ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadDr3.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadDr3.asm new file mode 100644 index 0000000..50a96ff --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadDr3.asm @@ -0,0 +1,38 @@ +; 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: +; +; ReadDr3.Asm +; +; Abstract: +; +; AsmReadDr3 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .586p + .model flat,C + .code + +;------------------------------------------------------------------------------ +; UINTN +; EFIAPI +; AsmReadDr3 ( +; VOID +; ); +;------------------------------------------------------------------------------ +AsmReadDr3 PROC + mov eax, dr3 + ret +AsmReadDr3 ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadDr4.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadDr4.asm new file mode 100644 index 0000000..2e822e5 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadDr4.asm @@ -0,0 +1,38 @@ +; 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: +; +; ReadDr4.Asm +; +; Abstract: +; +; AsmReadDr4 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .586p + .model flat,C + .code + +;------------------------------------------------------------------------------ +; UINTN +; EFIAPI +; AsmReadDr4 ( +; VOID +; ); +;------------------------------------------------------------------------------ +AsmReadDr4 PROC + DB 0fh, 21h, 0e0h + ret +AsmReadDr4 ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadDr5.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadDr5.asm new file mode 100644 index 0000000..fec5b2b --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadDr5.asm @@ -0,0 +1,38 @@ +; 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: +; +; ReadDr5.Asm +; +; Abstract: +; +; AsmReadDr5 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .586p + .model flat,C + .code + +;------------------------------------------------------------------------------ +; UINTN +; EFIAPI +; AsmReadDr5 ( +; VOID +; ); +;------------------------------------------------------------------------------ +AsmReadDr5 PROC + DB 0fh, 21h, 0e8h + ret +AsmReadDr5 ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadDr6.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadDr6.asm new file mode 100644 index 0000000..09cbb15 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadDr6.asm @@ -0,0 +1,38 @@ +; 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: +; +; ReadDr6.Asm +; +; Abstract: +; +; AsmReadDr6 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .586p + .model flat,C + .code + +;------------------------------------------------------------------------------ +; UINTN +; EFIAPI +; AsmReadDr6 ( +; VOID +; ); +;------------------------------------------------------------------------------ +AsmReadDr6 PROC + mov eax, dr6 + ret +AsmReadDr6 ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadDr7.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadDr7.asm new file mode 100644 index 0000000..aab8a8f --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadDr7.asm @@ -0,0 +1,38 @@ +; 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: +; +; ReadDr7.Asm +; +; Abstract: +; +; AsmReadDr7 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .586p + .model flat,C + .code + +;------------------------------------------------------------------------------ +; UINTN +; EFIAPI +; AsmReadDr7 ( +; VOID +; ); +;------------------------------------------------------------------------------ +AsmReadDr7 PROC + mov eax, dr7 + ret +AsmReadDr7 ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadDs.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadDs.asm new file mode 100644 index 0000000..ca942b8 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadDs.asm @@ -0,0 +1,38 @@ +; 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: +; +; ReadDs.Asm +; +; Abstract: +; +; AsmReadDs function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .386 + .model flat,C + .code + +;------------------------------------------------------------------------------ +; UINT16 +; EFIAPI +; AsmReadDs ( +; VOID +; ); +;------------------------------------------------------------------------------ +AsmReadDs PROC + mov eax, ds + ret +AsmReadDs ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadEflags.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadEflags.asm new file mode 100644 index 0000000..8ef9ec3 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadEflags.asm @@ -0,0 +1,39 @@ +; 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: +; +; ReadEflags.Asm +; +; Abstract: +; +; AsmReadEflags function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .386 + .model flat,C + .code + +;------------------------------------------------------------------------------ +; UINTN +; EFIAPI +; AsmReadEflags ( +; VOID +; ); +;------------------------------------------------------------------------------ +AsmReadEflags PROC + pushfd + pop eax + ret +AsmReadEflags ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadEs.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadEs.asm new file mode 100644 index 0000000..4c0d3b7 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadEs.asm @@ -0,0 +1,38 @@ +; 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: +; +; ReadEs.Asm +; +; Abstract: +; +; AsmReadEs function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .386 + .model flat,C + .code + +;------------------------------------------------------------------------------ +; UINT16 +; EFIAPI +; AsmReadEs ( +; VOID +; ); +;------------------------------------------------------------------------------ +AsmReadEs PROC + mov eax, es + ret +AsmReadEs ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadFs.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadFs.asm new file mode 100644 index 0000000..7e54318 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadFs.asm @@ -0,0 +1,38 @@ +; 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: +; +; ReadFs.Asm +; +; Abstract: +; +; AsmReadFs function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .386 + .model flat,C + .code + +;------------------------------------------------------------------------------ +; UINT16 +; EFIAPI +; AsmReadFs ( +; VOID +; ); +;------------------------------------------------------------------------------ +AsmReadFs PROC + mov eax, fs + ret +AsmReadFs ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadGdtr.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadGdtr.asm new file mode 100644 index 0000000..9cf0314 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadGdtr.asm @@ -0,0 +1,39 @@ +; 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: +; +; ReadGdtr.Asm +; +; Abstract: +; +; AsmReadGdtr function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .386 + .model flat,C + .code + +;------------------------------------------------------------------------------ +; VOID +; EFIAPI +; InternalX86ReadGdtr ( +; OUT IA32_DESCRIPTOR *Gdtr +; ); +;------------------------------------------------------------------------------ +InternalX86ReadGdtr PROC + mov eax, [esp + 4] + sgdt fword ptr [eax] + ret +InternalX86ReadGdtr ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadGs.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadGs.asm new file mode 100644 index 0000000..40e9531 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadGs.asm @@ -0,0 +1,38 @@ +; 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: +; +; ReadGs.Asm +; +; Abstract: +; +; AsmReadGs function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .386 + .model flat,C + .code + +;------------------------------------------------------------------------------ +; UINT16 +; EFIAPI +; AsmReadGs ( +; VOID +; ); +;------------------------------------------------------------------------------ +AsmReadGs PROC + mov eax, gs + ret +AsmReadGs ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadIdtr.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadIdtr.asm new file mode 100644 index 0000000..e459392 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadIdtr.asm @@ -0,0 +1,39 @@ +; 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: +; +; ReadIdtr.Asm +; +; Abstract: +; +; AsmReadIdtr function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .386 + .model flat,C + .code + +;------------------------------------------------------------------------------ +; VOID +; EFIAPI +; InternalX86ReadIdtr ( +; OUT IA32_DESCRIPTOR *Idtr +; ); +;------------------------------------------------------------------------------ +InternalX86ReadIdtr PROC + mov eax, [esp + 4] + sidt fword ptr [eax] + ret +InternalX86ReadIdtr ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadLdtr.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadLdtr.asm new file mode 100644 index 0000000..0097adc --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadLdtr.asm @@ -0,0 +1,38 @@ +; 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: +; +; ReadLdtr.Asm +; +; Abstract: +; +; AsmReadLdtr function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .386 + .model flat,C + .code + +;------------------------------------------------------------------------------ +; UINT16 +; EFIAPI +; AsmReadLdtr ( +; VOID +; ); +;------------------------------------------------------------------------------ +AsmReadLdtr PROC + sldt ax + ret +AsmReadLdtr ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadMm0.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadMm0.asm new file mode 100644 index 0000000..b5098af --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadMm0.asm @@ -0,0 +1,43 @@ +; 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: +; +; ReadMm0.Asm +; +; Abstract: +; +; AsmReadMm0 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .586 + .model flat,C + .mmx + .code + +;------------------------------------------------------------------------------ +; UINT64 +; EFIAPI +; AsmReadMm0 ( +; VOID +; ); +;------------------------------------------------------------------------------ +AsmReadMm0 PROC + push eax + push eax + movq [esp], mm0 + pop eax + pop edx + ret +AsmReadMm0 ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadMm1.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadMm1.asm new file mode 100644 index 0000000..ac67159 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadMm1.asm @@ -0,0 +1,43 @@ +; 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: +; +; ReadMm1.Asm +; +; Abstract: +; +; AsmReadMm1 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .586 + .model flat,C + .mmx + .code + +;------------------------------------------------------------------------------ +; UINT64 +; EFIAPI +; AsmReadMm1 ( +; VOID +; ); +;------------------------------------------------------------------------------ +AsmReadMm1 PROC + push eax + push eax + movq [esp], mm1 + pop eax + pop edx + ret +AsmReadMm1 ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadMm2.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadMm2.asm new file mode 100644 index 0000000..fed7997 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadMm2.asm @@ -0,0 +1,43 @@ +; 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: +; +; ReadMm2.Asm +; +; Abstract: +; +; AsmReadMm2 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .586 + .model flat,C + .mmx + .code + +;------------------------------------------------------------------------------ +; UINT64 +; EFIAPI +; AsmReadMm2 ( +; VOID +; ); +;------------------------------------------------------------------------------ +AsmReadMm2 PROC + push eax + push eax + movq [esp], mm2 + pop eax + pop edx + ret +AsmReadMm2 ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadMm3.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadMm3.asm new file mode 100644 index 0000000..3a230b1 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadMm3.asm @@ -0,0 +1,43 @@ +; 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: +; +; ReadMm3.Asm +; +; Abstract: +; +; AsmReadMm3 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .586 + .model flat,C + .mmx + .code + +;------------------------------------------------------------------------------ +; UINT64 +; EFIAPI +; AsmReadMm3 ( +; VOID +; ); +;------------------------------------------------------------------------------ +AsmReadMm3 PROC + push eax + push eax + movq [esp], mm3 + pop eax + pop edx + ret +AsmReadMm3 ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadMm4.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadMm4.asm new file mode 100644 index 0000000..f71ed15 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadMm4.asm @@ -0,0 +1,43 @@ +; 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: +; +; ReadMm4.Asm +; +; Abstract: +; +; AsmReadMm4 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .586 + .model flat,C + .mmx + .code + +;------------------------------------------------------------------------------ +; UINT64 +; EFIAPI +; AsmReadMm4 ( +; VOID +; ); +;------------------------------------------------------------------------------ +AsmReadMm4 PROC + push eax + push eax + movq [esp], mm4 + pop eax + pop edx + ret +AsmReadMm4 ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadMm5.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadMm5.asm new file mode 100644 index 0000000..47a4f62 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadMm5.asm @@ -0,0 +1,43 @@ +; 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: +; +; ReadMm5.Asm +; +; Abstract: +; +; AsmReadMm5 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .586 + .model flat,C + .mmx + .code + +;------------------------------------------------------------------------------ +; UINT64 +; EFIAPI +; AsmReadMm5 ( +; VOID +; ); +;------------------------------------------------------------------------------ +AsmReadMm5 PROC + push eax + push eax + movq [esp], mm5 + pop eax + pop edx + ret +AsmReadMm5 ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadMm6.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadMm6.asm new file mode 100644 index 0000000..cd450a5 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadMm6.asm @@ -0,0 +1,43 @@ +; 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: +; +; ReadMm6.Asm +; +; Abstract: +; +; AsmReadMm6 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .586 + .model flat,C + .mmx + .code + +;------------------------------------------------------------------------------ +; UINT64 +; EFIAPI +; AsmReadMm6 ( +; VOID +; ); +;------------------------------------------------------------------------------ +AsmReadMm6 PROC + push eax + push eax + movq [esp], mm6 + pop eax + pop edx + ret +AsmReadMm6 ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadMm7.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadMm7.asm new file mode 100644 index 0000000..1460c85 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadMm7.asm @@ -0,0 +1,43 @@ +; 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: +; +; ReadMm7.Asm +; +; Abstract: +; +; AsmReadMm7 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .586 + .model flat,C + .mmx + .code + +;------------------------------------------------------------------------------ +; UINT64 +; EFIAPI +; AsmReadMm7 ( +; VOID +; ); +;------------------------------------------------------------------------------ +AsmReadMm7 PROC + push eax + push eax + movq [esp], mm7 + pop eax + pop edx + ret +AsmReadMm7 ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadMsr64.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadMsr64.asm new file mode 100644 index 0000000..003d8b5 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadMsr64.asm @@ -0,0 +1,39 @@ +; 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: +; +; ReadMsr64.Asm +; +; Abstract: +; +; AsmReadMsr64 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .586p + .model flat,C + .code + +;------------------------------------------------------------------------------ +; UINT64 +; EFIAPI +; AsmReadMsr64 ( +; IN UINT64 Index +; ); +;------------------------------------------------------------------------------ +AsmReadMsr64 PROC + mov ecx, [esp + 4] + rdmsr + ret +AsmReadMsr64 ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadPmc.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadPmc.asm new file mode 100644 index 0000000..e51dee1 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadPmc.asm @@ -0,0 +1,39 @@ +; 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: +; +; ReadPmc.Asm +; +; Abstract: +; +; AsmReadPmc function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .586p + .model flat,C + .code + +;------------------------------------------------------------------------------ +; UINT64 +; EFIAPI +; AsmReadPmc ( +; IN UINT32 PmcIndex +; ); +;------------------------------------------------------------------------------ +AsmReadPmc PROC + mov ecx, [esp + 4] + rdpmc + ret +AsmReadPmc ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadSs.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadSs.asm new file mode 100644 index 0000000..741ed42 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadSs.asm @@ -0,0 +1,38 @@ +; 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: +; +; ReadSs.Asm +; +; Abstract: +; +; AsmReadSs function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .386 + .model flat,C + .code + +;------------------------------------------------------------------------------ +; UINT16 +; EFIAPI +; AsmReadSs ( +; VOID +; ); +;------------------------------------------------------------------------------ +AsmReadSs PROC + mov eax, ss + ret +AsmReadSs ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadTr.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadTr.asm new file mode 100644 index 0000000..6f2060c --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadTr.asm @@ -0,0 +1,38 @@ +; 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: +; +; ReadTr.Asm +; +; Abstract: +; +; AsmReadTr function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .386 + .model flat,C + .code + +;------------------------------------------------------------------------------ +; UINT16 +; EFIAPI +; AsmReadTr ( +; VOID +; ); +;------------------------------------------------------------------------------ +AsmReadTr PROC + str ax + ret +AsmReadTr ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadTsc.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadTsc.asm new file mode 100644 index 0000000..ab75959 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadTsc.asm @@ -0,0 +1,38 @@ +; 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: +; +; ReadTsc.Asm +; +; Abstract: +; +; AsmReadTsc function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .586p + .model flat,C + .code + +;------------------------------------------------------------------------------ +; UINT64 +; EFIAPI +; AsmReadTsc ( +; VOID +; ); +;------------------------------------------------------------------------------ +AsmReadTsc PROC + rdtsc + ret +AsmReadTsc ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/SetJump.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/SetJump.asm new file mode 100644 index 0000000..39c81e9 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/SetJump.asm @@ -0,0 +1,49 @@ +; 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: +; +; SetJump.Asm +; +; Abstract: +; +; Implementation of SetJump() on IA-32. +; +;------------------------------------------------------------------------------ + + .386 + .model flat,C + .code + +InternalAssertJumpBuffer PROTO C + +;------------------------------------------------------------------------------ +; UINTN +; EFIAPI +; SetJump ( +; OUT BASE_LIBRARY_JUMP_BUFFER *JumpBuffer +; ); +;------------------------------------------------------------------------------ +SetJump PROC + push [esp + 4] + call InternalAssertJumpBuffer + pop ecx + pop ecx + mov edx, [esp] + mov [edx], ebx + mov [edx + 4], esi + mov [edx + 8], edi + mov [edx + 12], ebp + mov [edx + 16], esp + mov [edx + 20], ecx + xor eax, eax + jmp ecx +SetJump ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/SwapBytes64.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/SwapBytes64.asm new file mode 100644 index 0000000..679973d --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/SwapBytes64.asm @@ -0,0 +1,41 @@ +; 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: +; +; CpuId.Asm +; +; Abstract: +; +; AsmCpuid function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .586 + .model flat,C + .code + +;------------------------------------------------------------------------------ +; UINT64 +; EFIAPI +; InternalMathSwapBytes64 ( +; IN UINT64 Operand +; ); +;------------------------------------------------------------------------------ +InternalMathSwapBytes64 PROC + mov eax, [esp + 8] + mov edx, [esp + 4] + bswap eax + bswap edx + ret +InternalMathSwapBytes64 ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/Thunk16.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/Thunk16.asm new file mode 100644 index 0000000..3223d53 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/Thunk16.asm @@ -0,0 +1,241 @@ +; 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: +; +; Thunk.asm +; +; Abstract: +; +; Real mode thunk +; +;------------------------------------------------------------------------------ + + .686p + .model flat,C + +EXTERNDEF C m16Start:BYTE +EXTERNDEF C m16Size:WORD +EXTERNDEF C mThunk16Attr:WORD +EXTERNDEF C m16Gdt:WORD +EXTERNDEF C m16GdtrBase:WORD +EXTERNDEF C mTransition:WORD + +THUNK_ATTRIBUTE_BIG_REAL_MODE EQU 1 +THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 EQU 2 +THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL EQU 4 + +; +; Here is the layout of the real mode stack. _ToUserCode() is responsible for +; loading all these registers from real mode stack. +; +IA32_REGS STRUC 4t +_EDI DD ? +_ESI DD ? +_EBP DD ? +_ESP DD ? +_EBX DD ? +_EDX DD ? +_ECX DD ? +_EAX DD ? +_DS DW ? +_ES DW ? +_FS DW ? +_GS DW ? +_EFLAGS DD ? +_EIP DD ? +_CS DW ? +_SS DW ? +IA32_REGS ENDS + + .const + +; +; These are global constant to convey information to C code. +; +m16Size DW InternalAsmThunk16 - m16Start +mThunk16Attr DW _ThunkAttr - m16Start +m16Gdt DW _NullSegDesc - m16Start +m16GdtrBase DW _16GdtrBase - m16Start +mTransition DW _EntryPoint - m16Start + + .code + +m16Start LABEL BYTE + +SavedGdt LABEL FWORD + DW ? + DD ? +;------------------------------------------------------------------------------ +; _BackFromUserCode() takes control in real mode after 'retf' has been executed +; by user code. It will be shadowed to somewhere in memory below 1MB. +;------------------------------------------------------------------------------ +_BackFromUserCode PROC + push ss + push cs + DB 66h + call @Base ; push eip +@Base: + pushf ; pushfd actually + cli ; disable interrupts + push gs + push fs + push es + push ds + pushaw ; pushad actually + DB 66h, 0bah ; mov edx, imm32 +_ThunkAttr DD ? + test dl, THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 + jz @1 + mov eax, 15cd2401h ; mov ax, 2401h & int 15h + cli ; disable interrupts + jnc @2 +@1: + test dl, THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL + jz @2 + in al, 92h + or al, 2 + out 92h, al ; deactivate A20M# +@2: + xor ax, ax ; xor eax, eax + mov eax, ss + DB 67h + lea bp, [esp + sizeof (IA32_REGS)] + mov word ptr (IA32_REGS ptr [esi - sizeof (IA32_REGS)])._ESP, bp + mov ebx, (IA32_REGS ptr [esi - sizeof (IA32_REGS)])._EIP + shl ax, 4 ; shl eax, 4 + add bp, ax ; add ebp, eax + DB 66h, 0b8h ; mov eax, imm32 +SavedCr4 DD ? + mov cr4, eax + DB 66h + lgdt fword ptr cs:[edi + (SavedGdt - @Base)] + DB 66h, 0b8h ; mov eax, imm32 +SavedCr0 DD ? + mov cr0, eax + DB 0b8h ; mov ax, imm16 +SavedSs DW ? + mov ss, eax + DB 66h, 0bch ; mov esp, imm32 +SavedEsp DD ? + DB 66h + retf ; return to protected mode +_BackFromUserCode ENDP + +_EntryPoint DD _ToUserCode - m16Start + DW 8h +_16Idtr FWORD (1 SHL 10) - 1 +_16Gdtr LABEL FWORD + DW GdtEnd - _NullSegDesc - 1 +_16GdtrBase DD _NullSegDesc + +;------------------------------------------------------------------------------ +; _ToUserCode() takes control in real mode before passing control to user code. +; It will be shadowed to somewhere in memory below 1MB. +;------------------------------------------------------------------------------ +_ToUserCode PROC + mov edx, ss + mov ss, ecx ; set new segment selectors + mov ds, ecx + mov es, ecx + mov fs, ecx + mov gs, ecx + mov cr0, eax + mov cr4, ebp ; real mode starts at next instruction + mov ss, esi ; set up 16-bit stack segment + xchg sp, bx ; set up 16-bit stack pointer + DB 66h + call @Base ; push eip +@Base: + pop bp ; ebp <- address of @Base + DB 67h ; address size override + push [esp + sizeof (IA32_REGS) + 2] + lea eax, [esi + (@RealMode - @Base)] + push eax + retf +@RealMode: + mov cs:[esi + (SavedSs - @Base)], edx + mov cs:[esi + (SavedEsp - @Base)], bx + DB 66h + lidt fword ptr cs:[esi + (_16Idtr - @Base)] + popaw ; popad actually + pop ds + pop es + pop fs + pop gs + popf ; popfd + DB 66h + retf ; transfer control to user code +_ToUserCode ENDP + +_NullSegDesc DQ 0 +_16CsDesc LABEL QWORD + DW -1 + DW 0 + DB 0 + DB 9bh + DB 8fh ; 16-bit segment, 4GB limit + DB 0 +_16DsDesc LABEL QWORD + DW -1 + DW 0 + DB 0 + DB 93h + DB 8fh ; 16-bit segment, 4GB limit + DB 0 +GdtEnd LABEL QWORD + +;------------------------------------------------------------------------------ +; IA32_REGISTER_SET * +; EFIAPI +; InternalAsmThunk16 ( +; IN IA32_REGISTER_SET *RegisterSet, +; IN OUT VOID *Transition +; ); +;------------------------------------------------------------------------------ +InternalAsmThunk16 PROC USES ebp ebx esi edi ds es fs gs + mov esi, [esp + 36] ; esi <- RegSet + movzx edx, (IA32_REGS ptr [esi])._SS + mov edi, (IA32_REGS ptr [esi])._ESP + add edi, - (sizeof (IA32_REGS) + 4) ; reserve stack space + mov ebx, edi ; ebx <- stack offset + imul eax, edx, 16 ; eax <- edx * 16 + push sizeof (IA32_REGS) / 4 + add edi, eax ; edi <- linear address of 16-bit stack + pop ecx + rep movsd ; copy RegSet + mov eax, [esp + 40] ; eax <- address of transition code + mov esi, edx ; esi <- 16-bit stack segment + lea edx, [eax + (SavedCr0 - m16Start)] + mov ecx, eax + and ecx, 0fh + shl eax, 12 + lea ecx, [ecx + (_BackFromUserCode - m16Start)] + mov ax, cx + stosd ; [edi] <- return address of user code + sgdt fword ptr [edx + (SavedGdt - SavedCr0)] + sidt fword ptr [esp + 36] ; save IDT stack in argument space + mov eax, cr0 + mov [edx], eax ; save CR0 in SavedCr0 + and eax, 7ffffffeh ; clear PE, PG bits + mov ebp, cr4 + mov [edx + (SavedCr4 - SavedCr0)], ebp + and ebp, 300h ; clear all but PCE and OSFXSR bits + push 10h + pop ecx ; ecx <- selector for data segments + lgdt fword ptr [edx + (_16Gdtr - SavedCr0)] + pushfd + call fword ptr [edx + (_EntryPoint - SavedCr0)] + popfd + lidt fword ptr [esp + 36] ; restore protected mode IDTR + lea eax, [ebp - sizeof (IA32_REGS)] + ret +InternalAsmThunk16 ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/Wbinvd.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/Wbinvd.asm new file mode 100644 index 0000000..629c66b --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/Wbinvd.asm @@ -0,0 +1,38 @@ +; 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: +; +; Wbinvd.Asm +; +; Abstract: +; +; AsmWbinvd function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .486p + .model flat,C + .code + +;------------------------------------------------------------------------------ +; VOID +; EFIAPI +; AsmWbinvd ( +; VOID +; ); +;------------------------------------------------------------------------------ +AsmWbinvd PROC + wbinvd + ret +AsmWbinvd ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteCr0.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteCr0.asm new file mode 100644 index 0000000..01b05ff --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteCr0.asm @@ -0,0 +1,39 @@ +; 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: +; +; WriteCr0.Asm +; +; Abstract: +; +; AsmWriteCr0 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .386p + .model flat,C + .code + +;------------------------------------------------------------------------------ +; UINTN +; EFIAPI +; AsmWriteCr0 ( +; UINTN Cr0 +; ); +;------------------------------------------------------------------------------ +AsmWriteCr0 PROC + mov eax, [esp + 4] + mov cr0, eax + ret +AsmWriteCr0 ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteCr2.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteCr2.asm new file mode 100644 index 0000000..5506636 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteCr2.asm @@ -0,0 +1,39 @@ +; 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: +; +; WriteCr2.Asm +; +; Abstract: +; +; AsmWriteCr2 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .386p + .model flat,C + .code + +;------------------------------------------------------------------------------ +; UINTN +; EFIAPI +; AsmWriteCr2 ( +; UINTN Cr2 +; ); +;------------------------------------------------------------------------------ +AsmWriteCr2 PROC + mov eax, [esp + 4] + mov cr2, eax + ret +AsmWriteCr2 ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteCr3.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteCr3.asm new file mode 100644 index 0000000..01faffe --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteCr3.asm @@ -0,0 +1,39 @@ +; 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: +; +; WriteCr3.Asm +; +; Abstract: +; +; AsmWriteCr3 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .386p + .model flat,C + .code + +;------------------------------------------------------------------------------ +; UINTN +; EFIAPI +; AsmWriteCr3 ( +; UINTN Cr3 +; ); +;------------------------------------------------------------------------------ +AsmWriteCr3 PROC + mov eax, [esp + 4] + mov cr3, eax + ret +AsmWriteCr3 ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteCr4.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteCr4.asm new file mode 100644 index 0000000..8469cf5 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteCr4.asm @@ -0,0 +1,39 @@ +; 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: +; +; WriteCr4.Asm +; +; Abstract: +; +; AsmWriteCr4 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .586p + .model flat,C + .code + +;------------------------------------------------------------------------------ +; UINTN +; EFIAPI +; AsmWriteCr4 ( +; UINTN Cr4 +; ); +;------------------------------------------------------------------------------ +AsmWriteCr4 PROC + mov eax, [esp + 4] + mov cr4, eax + ret +AsmWriteCr4 ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteDr0.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteDr0.asm new file mode 100644 index 0000000..0b2dce9 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteDr0.asm @@ -0,0 +1,39 @@ +; 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: +; +; WriteDr0.Asm +; +; Abstract: +; +; AsmWriteDr0 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .586p + .model flat,C + .code + +;------------------------------------------------------------------------------ +; UINTN +; EFIAPI +; AsmWriteDr0 ( +; IN UINTN Value +; ); +;------------------------------------------------------------------------------ +AsmWriteDr0 PROC + mov eax, [esp + 4] + mov dr0, eax + ret +AsmWriteDr0 ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteDr1.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteDr1.asm new file mode 100644 index 0000000..3f27325 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteDr1.asm @@ -0,0 +1,39 @@ +; 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: +; +; WriteDr1.Asm +; +; Abstract: +; +; AsmWriteDr1 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .586p + .model flat,C + .code + +;------------------------------------------------------------------------------ +; UINTN +; EFIAPI +; AsmWriteDr1 ( +; IN UINTN Value +; ); +;------------------------------------------------------------------------------ +AsmWriteDr1 PROC + mov eax, [esp + 4] + mov dr1, eax + ret +AsmWriteDr1 ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteDr2.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteDr2.asm new file mode 100644 index 0000000..afff84b --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteDr2.asm @@ -0,0 +1,39 @@ +; 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: +; +; WriteDr2.Asm +; +; Abstract: +; +; AsmWriteDr2 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .586p + .model flat,C + .code + +;------------------------------------------------------------------------------ +; UINTN +; EFIAPI +; AsmWriteDr2 ( +; IN UINTN Value +; ); +;------------------------------------------------------------------------------ +AsmWriteDr2 PROC + mov eax, [esp + 4] + mov dr2, eax + ret +AsmWriteDr2 ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteDr3.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteDr3.asm new file mode 100644 index 0000000..3cdddce --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteDr3.asm @@ -0,0 +1,39 @@ +; 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: +; +; WriteDr3.Asm +; +; Abstract: +; +; AsmWriteDr3 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .586p + .model flat,C + .code + +;------------------------------------------------------------------------------ +; UINTN +; EFIAPI +; AsmWriteDr3 ( +; IN UINTN Value +; ); +;------------------------------------------------------------------------------ +AsmWriteDr3 PROC + mov eax, [esp + 4] + mov dr3, eax + ret +AsmWriteDr3 ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteDr4.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteDr4.asm new file mode 100644 index 0000000..4b3cc9d --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteDr4.asm @@ -0,0 +1,39 @@ +; 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: +; +; WriteDr4.Asm +; +; Abstract: +; +; AsmWriteDr4 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .586p + .model flat,C + .code + +;------------------------------------------------------------------------------ +; UINTN +; EFIAPI +; AsmWriteDr4 ( +; IN UINTN Value +; ); +;------------------------------------------------------------------------------ +AsmWriteDr4 PROC + mov eax, [esp + 4] + DB 0fh, 23h, 0e0h + ret +AsmWriteDr4 ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteDr5.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteDr5.asm new file mode 100644 index 0000000..d03d1f8 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteDr5.asm @@ -0,0 +1,39 @@ +; 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: +; +; WriteDr5.Asm +; +; Abstract: +; +; AsmWriteDr5 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .586p + .model flat,C + .code + +;------------------------------------------------------------------------------ +; UINTN +; EFIAPI +; AsmWriteDr5 ( +; IN UINTN Value +; ); +;------------------------------------------------------------------------------ +AsmWriteDr5 PROC + mov eax, [esp + 4] + DB 0fh, 23h, 0e8h + ret +AsmWriteDr5 ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteDr6.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteDr6.asm new file mode 100644 index 0000000..70fe09b --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteDr6.asm @@ -0,0 +1,39 @@ +; 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: +; +; WriteDr6.Asm +; +; Abstract: +; +; AsmWriteDr6 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .586p + .model flat,C + .code + +;------------------------------------------------------------------------------ +; UINTN +; EFIAPI +; AsmWriteDr6 ( +; IN UINTN Value +; ); +;------------------------------------------------------------------------------ +AsmWriteDr6 PROC + mov eax, [esp + 4] + mov dr6, eax + ret +AsmWriteDr6 ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteDr7.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteDr7.asm new file mode 100644 index 0000000..4fa5717 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteDr7.asm @@ -0,0 +1,39 @@ +; 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: +; +; WriteDr7.Asm +; +; Abstract: +; +; AsmWriteDr7 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .586p + .model flat,C + .code + +;------------------------------------------------------------------------------ +; UINTN +; EFIAPI +; AsmWriteDr7 ( +; IN UINTN Value +; ); +;------------------------------------------------------------------------------ +AsmWriteDr7 PROC + mov eax, [esp + 4] + mov dr7, eax + ret +AsmWriteDr7 ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteGdtr.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteGdtr.asm new file mode 100644 index 0000000..655c528 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteGdtr.asm @@ -0,0 +1,39 @@ +; 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: +; +; WriteGdtr.Asm +; +; Abstract: +; +; AsmWriteGdtr function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .386p + .model flat,C + .code + +;------------------------------------------------------------------------------ +; VOID +; EFIAPI +; InternalX86WriteGdtr ( +; IN CONST IA32_DESCRIPTOR *Idtr +; ); +;------------------------------------------------------------------------------ +InternalX86WriteGdtr PROC + mov eax, [esp + 4] + lgdt fword ptr [eax] + ret +InternalX86WriteGdtr ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteIdtr.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteIdtr.asm new file mode 100644 index 0000000..043771b --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteIdtr.asm @@ -0,0 +1,39 @@ +; 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: +; +; WriteIdtr.Asm +; +; Abstract: +; +; AsmWriteIdtr function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .386p + .model flat,C + .code + +;------------------------------------------------------------------------------ +; VOID +; EFIAPI +; InternalX86WriteIdtr ( +; IN CONST IA32_DESCRIPTOR *Idtr +; ); +;------------------------------------------------------------------------------ +InternalX86WriteIdtr PROC + mov eax, [esp + 4] + lidt fword ptr [eax] + ret +InternalX86WriteIdtr ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteLdtr.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteLdtr.asm new file mode 100644 index 0000000..a33b1bf --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteLdtr.asm @@ -0,0 +1,39 @@ +; 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: +; +; WriteLdtr.Asm +; +; Abstract: +; +; AsmWriteLdtr function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .386p + .model flat + .code + +;------------------------------------------------------------------------------ +; VOID +; EFIAPI +; AsmWriteLdtr ( +; IN UINT16 Ldtr +; ); +;------------------------------------------------------------------------------ +_AsmWriteLdtr PROC + mov eax, [esp + 4] + lldt ax + ret +_AsmWriteLdtr ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteMm0.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteMm0.asm new file mode 100644 index 0000000..e8468e8 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteMm0.asm @@ -0,0 +1,39 @@ +; 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: +; +; WriteMm0.Asm +; +; Abstract: +; +; AsmWriteMm0 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .586 + .model flat,C + .mmx + .code + +;------------------------------------------------------------------------------ +; VOID +; EFIAPI +; AsmWriteMm0 ( +; IN UINT64 Value +; ); +;------------------------------------------------------------------------------ +AsmWriteMm0 PROC + movq mm0, [esp + 4] + ret +AsmWriteMm0 ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteMm1.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteMm1.asm new file mode 100644 index 0000000..e04219b --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteMm1.asm @@ -0,0 +1,39 @@ +; 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: +; +; WriteMm1.Asm +; +; Abstract: +; +; AsmWriteMm1 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .586 + .model flat,C + .mmx + .code + +;------------------------------------------------------------------------------ +; VOID +; EFIAPI +; AsmWriteMm1 ( +; IN UINT64 Value +; ); +;------------------------------------------------------------------------------ +AsmWriteMm1 PROC + movq mm1, [esp + 4] + ret +AsmWriteMm1 ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteMm2.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteMm2.asm new file mode 100644 index 0000000..a63c3d1 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteMm2.asm @@ -0,0 +1,39 @@ +; 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: +; +; WriteMm2.Asm +; +; Abstract: +; +; AsmWriteMm2 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .586 + .model flat,C + .mmx + .code + +;------------------------------------------------------------------------------ +; VOID +; EFIAPI +; AsmWriteMm2 ( +; IN UINT64 Value +; ); +;------------------------------------------------------------------------------ +AsmWriteMm2 PROC + movq mm2, [esp + 4] + ret +AsmWriteMm2 ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteMm3.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteMm3.asm new file mode 100644 index 0000000..c3ceae3 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteMm3.asm @@ -0,0 +1,39 @@ +; 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: +; +; WriteMm3.Asm +; +; Abstract: +; +; AsmWriteMm3 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .586 + .model flat,C + .mmx + .code + +;------------------------------------------------------------------------------ +; VOID +; EFIAPI +; AsmWriteMm3 ( +; IN UINT64 Value +; ); +;------------------------------------------------------------------------------ +AsmWriteMm3 PROC + movq mm3, [esp + 4] + ret +AsmWriteMm3 ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteMm4.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteMm4.asm new file mode 100644 index 0000000..458384e --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteMm4.asm @@ -0,0 +1,39 @@ +; 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: +; +; WriteMm4.Asm +; +; Abstract: +; +; AsmWriteMm4 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .586 + .model flat,C + .mmx + .code + +;------------------------------------------------------------------------------ +; VOID +; EFIAPI +; AsmWriteMm4 ( +; IN UINT64 Value +; ); +;------------------------------------------------------------------------------ +AsmWriteMm4 PROC + movq mm4, [esp + 4] + ret +AsmWriteMm4 ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteMm5.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteMm5.asm new file mode 100644 index 0000000..d69b33e --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteMm5.asm @@ -0,0 +1,39 @@ +; 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: +; +; WriteMm5.Asm +; +; Abstract: +; +; AsmWriteMm5 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .586 + .model flat,C + .mmx + .code + +;------------------------------------------------------------------------------ +; VOID +; EFIAPI +; AsmWriteMm5 ( +; IN UINT64 Value +; ); +;------------------------------------------------------------------------------ +AsmWriteMm5 PROC + movq mm5, [esp + 4] + ret +AsmWriteMm5 ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteMm6.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteMm6.asm new file mode 100644 index 0000000..9e8732e --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteMm6.asm @@ -0,0 +1,39 @@ +; 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: +; +; WriteMm6.Asm +; +; Abstract: +; +; AsmWriteMm6 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .586 + .model flat,C + .mmx + .code + +;------------------------------------------------------------------------------ +; VOID +; EFIAPI +; AsmWriteMm6 ( +; IN UINT64 Value +; ); +;------------------------------------------------------------------------------ +AsmWriteMm6 PROC + movq mm6, [esp + 4] + ret +AsmWriteMm6 ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteMm7.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteMm7.asm new file mode 100644 index 0000000..127d6e6 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteMm7.asm @@ -0,0 +1,39 @@ +; 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: +; +; WriteMm7.Asm +; +; Abstract: +; +; AsmWriteMm7 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .586 + .model flat,C + .mmx + .code + +;------------------------------------------------------------------------------ +; VOID +; EFIAPI +; AsmWriteMm7 ( +; IN UINT64 Value +; ); +;------------------------------------------------------------------------------ +AsmWriteMm7 PROC + movq mm7, [esp + 4] + ret +AsmWriteMm7 ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteMsr64.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteMsr64.asm new file mode 100644 index 0000000..0df165c --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteMsr64.asm @@ -0,0 +1,42 @@ +; 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: +; +; WriteMsr64.Asm +; +; Abstract: +; +; AsmWriteMsr64 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .586p + .model flat,C + .code + +;------------------------------------------------------------------------------ +; UINT64 +; EFIAPI +; AsmWriteMsr64 ( +; IN UINT32 Index, +; IN UINT64 Value +; ); +;------------------------------------------------------------------------------ +AsmWriteMsr64 PROC + mov edx, [esp + 12] + mov eax, [esp + 8] + mov ecx, [esp + 4] + wrmsr + ret +AsmWriteMsr64 ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/LRotU32.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/LRotU32.c new file mode 100644 index 0000000..9d69d2f --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/LRotU32.c @@ -0,0 +1,50 @@ +/*++ + +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: + + LRotU32.c + +Abstract: + + Math worker functions. + +--*/ + +#include "BaseLibInternal.h" + +/** + Rotates a 32-bit integer left between 0 and 31 bits, filling the low bits + with the high bits that were rotated. + + This function rotates the 32-bit value Operand to the left by Count bits. The + low Count bits are fill with the high Count bits of Operand. The rotated + value is returned. + + If Count is greater than 31, then ASSERT(). + + @param Operand The 32-bit operand to rotate left. + @param Count The number of bits to rotate left. + + @return Operand <<< Count + +**/ +UINT32 +EFIAPI +LRotU32 ( + IN UINT32 Operand, + IN UINTN Count + ) +{ + ASSERT (Count < sizeof (Operand) * 8); + return (Operand << Count) | (Operand >> (32 - Count)); +} diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/LRotU64.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/LRotU64.c new file mode 100644 index 0000000..ebc8e91 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/LRotU64.c @@ -0,0 +1,50 @@ +/*++ + +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: + + LRotU64.c + +Abstract: + + Math worker functions. + +--*/ + +#include "BaseLibInternal.h" + +/** + Rotates a 64-bit integer left between 0 and 63 bits, filling the low bits + with the high bits that were rotated. + + This function rotates the 64-bit value Operand to the left by Count bits. The + low Count bits are fill with the high Count bits of Operand. The rotated + value is returned. + + If Count is greater than 63, then ASSERT(). + + @param Operand The 64-bit operand to rotate left. + @param Count The number of bits to rotate left. + + @return Operand <<< Count + +**/ +UINT64 +EFIAPI +LRotU64 ( + IN UINT64 Operand, + IN UINTN Count + ) +{ + ASSERT (Count < sizeof (Operand) * 8); + return InternalMathLRotU64 (Operand, Count); +} diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/LShiftU64.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/LShiftU64.c new file mode 100644 index 0000000..c079f53 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/LShiftU64.c @@ -0,0 +1,49 @@ +/*++ + +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: + + LShiftU64.c + +Abstract: + + Math worker functions. + +--*/ + +#include "BaseLibInternal.h" + +/** + Shifts a 64-bit integer left between 0 and 63 bits. The low bits are filled + with zeros. The shifted value is returned. + + This function shifts the 64-bit value Operand to the left by Count bits. The + low Count bits are set to zero. The shifted value is returned. + + If Count is greater than 63, then ASSERT(). + + @param Operand The 64-bit operand to shift left. + @param Count The number of bits to shift left. + + @return Operand << Count + +**/ +UINT64 +EFIAPI +GlueLShiftU64 ( + IN UINT64 Operand, + IN UINTN Count + ) +{ + ASSERT (Count < sizeof (Operand) * 8); + return InternalMathLShiftU64 (Operand, Count); +} diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/LinkedList.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/LinkedList.c new file mode 100644 index 0000000..cb84470 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/LinkedList.c @@ -0,0 +1,473 @@ +/*++ + +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: + + LinkedList.c + +Abstract: + + Linked List Library Functions. + +--*/ + +#include "BaseLibInternal.h" +#include "Pcd\EdkIIGluePcdBaseLib.h" + + +/** + Worker function that locates the Node in the List + + By searching the List, finds the location of the Node in List. At the same time, + verifies the validity of this list. + + If List is NULL, then ASSERT(). + If List->ForwardLink is NULL, then ASSERT(). + If List->backLink is NULL, then ASSERT(). + If Node is NULL, then ASSERT(); + If PcdMaximumLinkedListLenth is not zero, and prior to insertion the number + of nodes in ListHead, including the ListHead node, is greater than or + equal to PcdMaximumLinkedListLength, then ASSERT(). + + @param List A pointer to a node in a linked list. + @param Node A pointer to one nod. + + @retval TRUE Node is in List + @retval FALSE Node isn't in List, or List is invalid + +**/ +BOOLEAN +IsNodeInList ( + IN CONST LIST_ENTRY *List, + IN CONST LIST_ENTRY *Node + ) +{ + UINTN Count; + CONST LIST_ENTRY *Ptr; + BOOLEAN Found; + + // + // Test the validity of List and Node + // + ASSERT (List != NULL); + ASSERT (List->ForwardLink != NULL); + ASSERT (List->BackLink != NULL); + ASSERT (Node != NULL); + + Count = PcdGet32 (PcdMaximumLinkedListLength); + + Ptr = List; + do { + Ptr = Ptr->ForwardLink; + Count--; + } while ((Ptr != List) && (Ptr != Node) && (Count > 0)); + Found = (BOOLEAN)(Ptr == Node); + + if (PcdGet32 (PcdMaximumLinkedListLength) > 0) { + while ((Count > 0) && (Ptr != List)) { + Ptr = Ptr->ForwardLink; + Count--; + } + ASSERT (Count > 0); + } + + return Found; +} + +/** + Initializes the head node of a doubly linked list, and returns the pointer to + the head node of the doubly linked list. + + Initializes the forward and backward links of a new linked list. After + initializing a linked list with this function, the other linked list + functions may be used to add and remove nodes from the linked list. It is up + to the caller of this function to allocate the memory for ListHead. + + If ListHead is NULL, then ASSERT(). + + @param ListHead A pointer to the head node of a new doubly linked list. + + @return ListHead + +**/ +LIST_ENTRY * +EFIAPI +GlueInitializeListHead ( + IN OUT LIST_ENTRY *List + ) + +{ + ASSERT (List != NULL); + + List->ForwardLink = List; + List->BackLink = List; + return List; +} + +/** + Adds a node to the beginning of a doubly linked list, and returns the pointer + to the head node of the doubly linked list. + + Adds the node Entry at the beginning of the doubly linked list denoted by + ListHead, and returns ListHead. + + If ListHead is NULL, then ASSERT(). + If Entry is NULL, then ASSERT(). + If ListHead was not initialized with InitializeListHead(), then ASSERT(). + If PcdMaximumLinkedListLenth is not zero, and prior to insertion the number + of nodes in ListHead, including the ListHead node, is greater than or + equal to PcdMaximumLinkedListLength, then ASSERT(). + + @param ListHead A pointer to the head node of a doubly linked list. + @param Entry A pointer to a node that is to be inserted at the beginning + of a doubly linked list. + + @return ListHead + +**/ +LIST_ENTRY * +EFIAPI +GlueInsertHeadList ( + IN OUT LIST_ENTRY *List, + IN OUT LIST_ENTRY *Entry + ) +{ + // + // ASSERT List not too long and Entry is not one of the nodes of List + // + ASSERT (!IsNodeInList (List, Entry)); + + Entry->ForwardLink = List->ForwardLink; + Entry->BackLink = List; + Entry->ForwardLink->BackLink = Entry; + List->ForwardLink = Entry; + return List; +} + +/** + Adds a node to the end of a doubly linked list, and returns the pointer to + the head node of the doubly linked list. + + Adds the node Entry to the end of the doubly linked list denoted by ListHead, + and returns ListHead. + + If ListHead is NULL, then ASSERT(). + If Entry is NULL, then ASSERT(). + If ListHead was not initialized with InitializeListHead(), then ASSERT(). + If PcdMaximumLinkedListLenth is not zero, and prior to insertion the number + of nodes in ListHead, including the ListHead node, is greater than or + equal to PcdMaximumLinkedListLength, then ASSERT(). + + @param ListHead A pointer to the head node of a doubly linked list. + @param Entry A pointer to a node that is to be added at the end of the + doubly linked list. + + @return ListHead + +**/ +LIST_ENTRY * +EFIAPI +GlueInsertTailList ( + IN OUT LIST_ENTRY *List, + IN OUT LIST_ENTRY *Entry + ) +{ + // + // ASSERT List not too long and Entry is not one of the nodes of List + // + ASSERT (!IsNodeInList (List, Entry)); + + Entry->ForwardLink = List; + Entry->BackLink = List->BackLink; + Entry->BackLink->ForwardLink = Entry; + List->BackLink = Entry; + return List; +} + +/** + Retrieves the first node of a doubly linked list. + + Returns the first node of a doubly linked list. List must have been + initialized with InitializeListHead(). If List is empty, then NULL is + returned. + + If List is NULL, then ASSERT(). + If List was not initialized with InitializeListHead(), then ASSERT(). + If PcdMaximumLinkedListLenth is not zero, and the number of nodes + in List, including the List node, is greater than or equal to + PcdMaximumLinkedListLength, then ASSERT(). + + @param List A pointer to the head node of a doubly linked list. + + @return The first node of a doubly linked list. + @retval NULL The list is empty. + +**/ +LIST_ENTRY * +EFIAPI +GlueGetFirstNode ( + IN CONST LIST_ENTRY *List + ) +{ + // + // ASSERT List not too long + // + ASSERT (IsNodeInList (List, List)); + + return List->ForwardLink; +} + +/** + Retrieves the next node of a doubly linked list. + + Returns the node of a doubly linked list that follows Node. List must have + been initialized with InitializeListHead(). If List is empty, then List is + returned. + + If List is NULL, then ASSERT(). + If Node is NULL, then ASSERT(). + If List was not initialized with InitializeListHead(), then ASSERT(). + If PcdMaximumLinkedListLenth is not zero, and List contains more than + PcdMaximumLinkedListLenth nodes, then ASSERT(). + If Node is not a node in List, then ASSERT(). + + @param List A pointer to the head node of a doubly linked list. + @param Node A pointer to a node in the doubly linked list. + + @return Pointer to the next node if one exists. Otherwise a null value which + is actually List is returned. + +**/ +LIST_ENTRY * +EFIAPI +GlueGetNextNode ( + IN CONST LIST_ENTRY *List, + IN CONST LIST_ENTRY *Node + ) +{ + // + // ASSERT List not too long and Node is one of the nodes of List + // + ASSERT (IsNodeInList (List, Node)); + + return Node->ForwardLink; +} + +/** + Checks to see if a doubly linked list is empty or not. + + Checks to see if the doubly linked list is empty. If the linked list contains + zero nodes, this function returns TRUE. Otherwise, it returns FALSE. + + If ListHead is NULL, then ASSERT(). + If ListHead was not initialized with InitializeListHead(), then ASSERT(). + If PcdMaximumLinkedListLenth is not zero, and the number of nodes + in List, including the List node, is greater than or equal to + PcdMaximumLinkedListLength, then ASSERT(). + + @param ListHead A pointer to the head node of a doubly linked list. + + @retval TRUE The linked list is empty. + @retval FALSE The linked list is not empty. + +**/ +BOOLEAN +EFIAPI +GlueIsListEmpty ( + IN CONST LIST_ENTRY *List + ) +{ + // + // ASSERT List not too long + // + ASSERT (IsNodeInList (List, List)); + + return (BOOLEAN)(List->ForwardLink == List); +} + +/** + Determines if a node in a doubly linked list is null. + + Returns FALSE if Node is one of the nodes in the doubly linked list specified + by List. Otherwise, TRUE is returned. List must have been initialized with + InitializeListHead(). + + If List is NULL, then ASSERT(). + If Node is NULL, then ASSERT(). + If List was not initialized with InitializeListHead(), then ASSERT(). + If PcdMaximumLinkedListLenth is not zero, and the number of nodes + in List, including the List node, is greater than or equal to + PcdMaximumLinkedListLength, then ASSERT(). + If Node is not a node in List and Node is not equal to List, then ASSERT(). + + @param List A pointer to the head node of a doubly linked list. + @param Node A pointer to a node in the doubly linked list. + + @retval TRUE Node is one of the nodes in the doubly linked list. + @retval FALSE Node is not one of the nodes in the doubly linked list. + +**/ +BOOLEAN +EFIAPI +GlueIsNull ( + IN CONST LIST_ENTRY *List, + IN CONST LIST_ENTRY *Node + ) +{ + // + // ASSERT List not too long and Node is one of the nodes of List + // + ASSERT (IsNodeInList (List, Node)); + + return (BOOLEAN)(Node == List); +} + +/** + Determines if a node the last node in a doubly linked list. + + Returns TRUE if Node is the last node in the doubly linked list specified by + List. Otherwise, FALSE is returned. List must have been initialized with + InitializeListHead(). + + If List is NULL, then ASSERT(). + If Node is NULL, then ASSERT(). + If List was not initialized with InitializeListHead(), then ASSERT(). + If PcdMaximumLinkedListLenth is not zero, and the number of nodes + in List, including the List node, is greater than or equal to + PcdMaximumLinkedListLength, then ASSERT(). + If Node is not a node in List, then ASSERT(). + + @param List A pointer to the head node of a doubly linked list. + @param Node A pointer to a node in the doubly linked list. + + @retval TRUE Node is the last node in the linked list. + @retval FALSE Node is not the last node in the linked list. + +**/ +BOOLEAN +EFIAPI +GlueIsNodeAtEnd ( + IN CONST LIST_ENTRY *List, + IN CONST LIST_ENTRY *Node + ) +{ + // + // ASSERT List not too long and Node is one of the nodes of List + // + ASSERT (IsNodeInList (List, Node)); + + return (BOOLEAN)(!IsNull (List, Node) && List->BackLink == Node); +} + +/** + Swaps the location of two nodes in a doubly linked list, and returns the + first node after the swap. + + If FirstEntry is identical to SecondEntry, then SecondEntry is returned. + Otherwise, the location of the FirstEntry node is swapped with the location + of the SecondEntry node in a doubly linked list. SecondEntry must be in the + same double linked list as FirstEntry and that double linked list must have + been initialized with InitializeListHead(). SecondEntry is returned after the + nodes are swapped. + + If FirstEntry is NULL, then ASSERT(). + If SecondEntry is NULL, then ASSERT(). + If SecondEntry and FirstEntry are not in the same linked list, then ASSERT(). + If PcdMaximumLinkedListLength is not zero, and the number of nodes in the + linked list containing the FirstEntry and SecondEntry nodes, including + the FirstEntry and SecondEntry nodes, is greater than or equal to + PcdMaximumLinkedListLength, then ASSERT(). + + @param FirstEntry A pointer to a node in a linked list. + @param SecondEntry A pointer to another node in the same linked list. + +**/ +LIST_ENTRY * +EFIAPI +GlueSwapListEntries ( + IN OUT LIST_ENTRY *FirstEntry, + IN OUT LIST_ENTRY *SecondEntry + ) +{ + LIST_ENTRY *Ptr; + + if (FirstEntry == SecondEntry) { + return SecondEntry; + } + + // + // ASSERT Entry1 and Entry2 are in the same linked list + // + ASSERT (IsNodeInList (FirstEntry, SecondEntry)); + + // + // Ptr is the node pointed to by FirstEntry->ForwardLink + // + Ptr = RemoveEntryList (FirstEntry); + + // + // If FirstEntry immediately follows SecondEntry, FirstEntry willl be placed + // immediately in front of SecondEntry + // + if (Ptr->BackLink == SecondEntry) { + return InsertTailList (SecondEntry, FirstEntry); + } + + // + // Ptr == SecondEntry means SecondEntry immediately follows FirstEntry, + // then there are no further steps necessary + // + if (Ptr == InsertHeadList (SecondEntry, FirstEntry)) { + return Ptr; + } + + // + // Move SecondEntry to the front of Ptr + // + RemoveEntryList (SecondEntry); + InsertTailList (Ptr, SecondEntry); + return SecondEntry; +} + +/** + Removes a node from a doubly linked list, and returns the node that follows + the removed node. + + Removes the node Entry from a doubly linked list. It is up to the caller of + this function to release the memory used by this node if that is required. On + exit, the node following Entry in the doubly linked list is returned. If + Entry is the only node in the linked list, then the head node of the linked + list is returned. + + If Entry is NULL, then ASSERT(). + If Entry is the head node of an empty list, then ASSERT(). + If PcdMaximumLinkedListLength is not zero, and the number of nodes in the + linked list containing Entry, including the Entry node, is greater than + or equal to PcdMaximumLinkedListLength, then ASSERT(). + + @param Entry A pointer to a node in a linked list + + @return Entry + +**/ +LIST_ENTRY * +EFIAPI +GlueRemoveEntryList ( + IN CONST LIST_ENTRY *Entry + ) +{ + ASSERT (!IsListEmpty (Entry)); + + Entry->ForwardLink->BackLink = Entry->BackLink; + Entry->BackLink->ForwardLink = Entry->ForwardLink; + return Entry->ForwardLink; +} diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/LongJump.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/LongJump.c new file mode 100644 index 0000000..baa2d47 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/LongJump.c @@ -0,0 +1,85 @@ +/*++ + +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: + + LongJump.c + +Abstract: + + Long Jump functions + +--*/ + +#include "BaseLibInternal.h" + +/** + Worker function that checks ASSERT condition for JumpBuffer + + Checks ASSERT condition for JumpBuffer. + + If JumpBuffer is NULL, then ASSERT(). + For IPF CPUs, if JumpBuffer is not aligned on a 16-byte boundary, then ASSERT(). + + @param JumpBuffer A pointer to CPU context buffer. + +**/ +VOID +InternalAssertJumpBuffer ( + IN BASE_LIBRARY_JUMP_BUFFER *JumpBuffer + ); + +/** + Restores the CPU context that was saved with SetJump(). + + Restores the CPU context from the buffer specified by JumpBuffer. + This function never returns to the caller. + Instead is resumes execution based on the state of JumpBuffer. + + @param JumpBuffer A pointer to CPU context buffer. + @param Value The value to return when the SetJump() context is restored. + +**/ +VOID +EFIAPI +InternalLongJump ( + IN BASE_LIBRARY_JUMP_BUFFER *JumpBuffer, + IN UINTN Value + ); + +/** + Restores the CPU context that was saved with SetJump(). + + Restores the CPU context from the buffer specified by JumpBuffer. + This function never returns to the caller. + Instead is resumes execution based on the state of JumpBuffer. + + If JumpBuffer is NULL, then ASSERT(). + For IPF CPUs, if JumpBuffer is not aligned on a 16-byte boundary, then ASSERT(). + If Value is 0, then ASSERT(). + + @param JumpBuffer A pointer to CPU context buffer. + @param Value The value to return when the SetJump() context is restored. + +**/ +VOID +EFIAPI +LongJump ( + IN BASE_LIBRARY_JUMP_BUFFER *JumpBuffer, + IN UINTN Value + ) +{ + InternalAssertJumpBuffer (JumpBuffer); + ASSERT (Value != 0); + + InternalLongJump (JumpBuffer, Value); +} diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/LowBitSet32.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/LowBitSet32.c new file mode 100644 index 0000000..99ebe42 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/LowBitSet32.c @@ -0,0 +1,52 @@ +/*++ + +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: + + LowBitSet32.c + +Abstract: + + Math worker functions. + +--*/ + +#include "BaseLibInternal.h" + +/** + Returns the bit position of the lowest bit set in a 32-bit value. + + This function computes the bit position of the lowest bit set in the 32-bit + value specified by Operand. If Operand is zero, then -1 is returned. + Otherwise, a value between 0 and 31 is returned. + + @param Operand The 32-bit operand to evaluate. + + @return Position of the lowest bit set in Operand if found. + @retval -1 Operand is zero. + +**/ +INTN +EFIAPI +LowBitSet32 ( + IN UINT32 Operand + ) +{ + INTN BitIndex; + + if (Operand == 0) { + return -1; + } + + for (BitIndex = 0; (Operand & 1) == 0; BitIndex++, Operand >>= 1); + return BitIndex; +} diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/LowBitSet64.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/LowBitSet64.c new file mode 100644 index 0000000..10bd132 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/LowBitSet64.c @@ -0,0 +1,54 @@ +/*++ + +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: + + LowBitSet64.c + +Abstract: + + Math worker functions. + +--*/ + +#include "BaseLibInternal.h" + +/** + Returns the bit position of the lowest bit set in a 64-bit value. + + This function computes the bit position of the lowest bit set in the 64-bit + value specified by Operand. If Operand is zero, then -1 is returned. + Otherwise, a value between 0 and 63 is returned. + + @param Operand The 64-bit operand to evaluate. + + @return Position of the lowest bit set in Operand if found. + @retval -1 Operand is zero. + +**/ +INTN +EFIAPI +LowBitSet64 ( + IN UINT64 Operand + ) +{ + INTN BitIndex; + + if (Operand == 0) { + return -1; + } + + for (BitIndex = 0; + (Operand & 1) == 0; + BitIndex++, Operand = RShiftU64 (Operand, 1)); + return BitIndex; +} diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Math64.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Math64.c new file mode 100644 index 0000000..48f06dd --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Math64.c @@ -0,0 +1,371 @@ +/*++ + +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: + + Match64.c + +Abstract: + + Leaf math worker functions that require 64-bit arithmetic support from the + compiler. + +--*/ + +#include "BaseLibInternal.h" + +/** + Shifts a 64-bit integer left between 0 and 63 bits. The low bits + are filled with zeros. The shifted value is returned. + + This function shifts the 64-bit value Operand to the left by Count bits. The + low Count bits are set to zero. The shifted value is returned. + + @param Operand The 64-bit operand to shift left. + @param Count The number of bits to shift left. + + @return Operand << Count + +**/ +UINT64 +EFIAPI +InternalMathLShiftU64 ( + IN UINT64 Operand, + IN UINTN Count + ) +{ + return Operand << Count; +} + +/** + Shifts a 64-bit integer right between 0 and 63 bits. This high bits + are filled with zeros. The shifted value is returned. + + This function shifts the 64-bit value Operand to the right by Count bits. The + high Count bits are set to zero. The shifted value is returned. + + @param Operand The 64-bit operand to shift right. + @param Count The number of bits to shift right. + + @return Operand >> Count + +**/ +UINT64 +EFIAPI +InternalMathRShiftU64 ( + IN UINT64 Operand, + IN UINTN Count + ) +{ + return Operand >> Count; +} + +/** + Shifts a 64-bit integer right between 0 and 63 bits. The high bits + are filled with original integer's bit 63. The shifted value is returned. + + This function shifts the 64-bit value Operand to the right by Count bits. The + high Count bits are set to bit 63 of Operand. The shifted value is returned. + + If Count is greater than 63, then ASSERT(). + + @param Operand The 64-bit operand to shift right. + @param Count The number of bits to shift right. + + @return Operand arithmetically shifted right by Count + +**/ +UINT64 +EFIAPI +InternalMathARShiftU64 ( + IN UINT64 Operand, + IN UINTN Count + ) +{ + // + // Test if this compiler supports arithmetic shift + // + if ((((-1) << (sizeof (-1) * 8 - 1)) >> (sizeof (-1) * 8 - 1)) == -1) { + // + // Arithmetic shift is supported + // + return (UINT64)((INT64)Operand >> Count); + } + + // + // Arithmetic is not supported + // + return (Operand >> Count) | + ((INTN)Operand < 0 ? ~((UINTN)-1 >> Count) : 0); +} + + +/** + Rotates a 64-bit integer left between 0 and 63 bits, filling + the low bits with the high bits that were rotated. + + This function rotates the 64-bit value Operand to the left by Count bits. The + low Count bits are fill with the high Count bits of Operand. The rotated + value is returned. + + @param Operand The 64-bit operand to rotate left. + @param Count The number of bits to rotate left. + + @return Operand <<< Count + +**/ +UINT64 +EFIAPI +InternalMathLRotU64 ( + IN UINT64 Operand, + IN UINTN Count + ) +{ + return (Operand << Count) | (Operand >> (64 - Count)); +} + +/** + Rotates a 64-bit integer right between 0 and 63 bits, filling + the high bits with the high low bits that were rotated. + + This function rotates the 64-bit value Operand to the right by Count bits. + The high Count bits are fill with the low Count bits of Operand. The rotated + value is returned. + + @param Operand The 64-bit operand to rotate right. + @param Count The number of bits to rotate right. + + @return Operand >>> Count + +**/ +UINT64 +EFIAPI +InternalMathRRotU64 ( + IN UINT64 Operand, + IN UINTN Count + ) +{ + return (Operand >> Count) | (Operand << (64 - Count)); +} + +/** + Switches the endianess of a 64-bit integer. + + This function swaps the bytes in a 64-bit unsigned value to switch the value + from little endian to big endian or vice versa. The byte swapped value is + returned. + + @param Operand A 64-bit unsigned value. + + @return The byte swaped Operand. + +**/ +UINT64 +EFIAPI +InternalMathSwapBytes64 ( + IN UINT64 Operand + ) +{ + return (UINT64)( + ((UINT64)SwapBytes32 ((UINT32)Operand) << 32) | + ((UINT64)SwapBytes32 ((UINT32)(Operand >> 32))) + ); +} + +/** + Multiples a 64-bit unsigned integer by a 32-bit unsigned integer + and generates a 64-bit unsigned result. + + This function multiples the 64-bit unsigned value Multiplicand by the 32-bit + unsigned value Multiplier and generates a 64-bit unsigned result. This 64- + bit unsigned result is returned. + + @param Multiplicand A 64-bit unsigned value. + @param Multiplier A 32-bit unsigned value. + + @return Multiplicand * Multiplier + +**/ +UINT64 +EFIAPI +InternalMathMultU64x32 ( + IN UINT64 Multiplicand, + IN UINT32 Multiplier + ) +{ + return Multiplicand * Multiplier; +} + + +/** + Multiples a 64-bit unsigned integer by a 64-bit unsigned integer + and generates a 64-bit unsigned result. + + This function multiples the 64-bit unsigned value Multiplicand by the 64-bit + unsigned value Multiplier and generates a 64-bit unsigned result. This 64- + bit unsigned result is returned. + + @param Multiplicand A 64-bit unsigned value. + @param Multiplier A 64-bit unsigned value. + + @return Multiplicand * Multiplier + +**/ +UINT64 +EFIAPI +InternalMathMultU64x64 ( + IN UINT64 Multiplicand, + IN UINT64 Multiplier + ) +{ + return Multiplicand * Multiplier; +} + +/** + Divides a 64-bit unsigned integer by a 32-bit unsigned integer and + generates a 64-bit unsigned result. + + This function divides the 64-bit unsigned value Dividend by the 32-bit + unsigned value Divisor and generates a 64-bit unsigned quotient. This + function returns the 64-bit unsigned quotient. + + @param Dividend A 64-bit unsigned value. + @param Divisor A 32-bit unsigned value. + + @return Dividend / Divisor + +**/ +UINT64 +EFIAPI +InternalMathDivU64x32 ( + IN UINT64 Dividend, + IN UINT32 Divisor + ) +{ + return Dividend / Divisor; +} + +/** + Divides a 64-bit unsigned integer by a 32-bit unsigned integer + and generates a 32-bit unsigned remainder. + + This function divides the 64-bit unsigned value Dividend by the 32-bit + unsigned value Divisor and generates a 32-bit remainder. This function + returns the 32-bit unsigned remainder. + + @param Dividend A 64-bit unsigned value. + @param Divisor A 32-bit unsigned value. + + @return Dividend % Divisor + +**/ +UINT32 +EFIAPI +InternalMathModU64x32 ( + IN UINT64 Dividend, + IN UINT32 Divisor + ) +{ + return (UINT32)(Dividend % Divisor); +} + +/** + Divides a 64-bit unsigned integer by a 32-bit unsigned integer and + generates a 64-bit unsigned result and an optional 32-bit unsigned remainder. + + This function divides the 64-bit unsigned value Dividend by the 32-bit + unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder + is not NULL, then the 32-bit unsigned remainder is returned in Remainder. + This function returns the 64-bit unsigned quotient. + + @param Dividend A 64-bit unsigned value. + @param Divisor A 32-bit unsigned value. + @param Remainder A pointer to a 32-bit unsigned value. This parameter is + optional and may be NULL. + + @return Dividend / Divisor + +**/ +UINT64 +EFIAPI +InternalMathDivRemU64x32 ( + IN UINT64 Dividend, + IN UINT32 Divisor, + OUT UINT32 *Remainder OPTIONAL + ) +{ + if (Remainder != NULL) { + *Remainder = (UINT32)(Dividend % Divisor); + } + return Dividend / Divisor; +} + +/** + Divides a 64-bit unsigned integer by a 64-bit unsigned integer and + generates a 64-bit unsigned result and an optional 64-bit unsigned remainder. + + This function divides the 64-bit unsigned value Dividend by the 64-bit + unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder + is not NULL, then the 64-bit unsigned remainder is returned in Remainder. + This function returns the 64-bit unsigned quotient. + + @param Dividend A 64-bit unsigned value. + @param Divisor A 64-bit unsigned value. + @param Remainder A pointer to a 64-bit unsigned value. This parameter is + optional and may be NULL. + + @return Dividend / Divisor + +**/ +UINT64 +EFIAPI +InternalMathDivRemU64x64 ( + IN UINT64 Dividend, + IN UINT64 Divisor, + OUT UINT64 *Remainder OPTIONAL + ) +{ + if (Remainder != NULL) { + *Remainder = Dividend % Divisor; + } + return Dividend / Divisor; +} + +/** + Divides a 64-bit signed integer by a 64-bit signed integer and + generates a 64-bit signed result and a optional 64-bit signed remainder. + + This function divides the 64-bit unsigned value Dividend by the 64-bit + unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder + is not NULL, then the 64-bit unsigned remainder is returned in Remainder. + This function returns the 64-bit unsigned quotient. + + @param Dividend A 64-bit signed value. + @param Divisor A 64-bit signed value. + @param Remainder A pointer to a 64-bit signed value. This parameter is + optional and may be NULL. + + @return Dividend / Divisor + +**/ +INT64 +InternalMathDivRemS64x64 ( + IN INT64 Dividend, + IN INT64 Divisor, + OUT INT64 *Remainder OPTIONAL + ) +{ + if (Remainder != NULL) { + *Remainder = Dividend % Divisor; + } + return Dividend / Divisor; +} diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/ModU64x32.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/ModU64x32.c new file mode 100644 index 0000000..350a704 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/ModU64x32.c @@ -0,0 +1,50 @@ +/*++ + +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: + + ModU64x32.c + +Abstract: + + Math worker functions. + +--*/ + +#include "BaseLibInternal.h" + +/** + Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates + a 32-bit unsigned remainder. + + This function divides the 64-bit unsigned value Dividend by the 32-bit + unsigned value Divisor and generates a 32-bit remainder. This function + returns the 32-bit unsigned remainder. + + If Divisor is 0, then ASSERT(). + + @param Dividend A 64-bit unsigned value. + @param Divisor A 32-bit unsigned value. + + @return Dividend % Divisor + +**/ +UINT32 +EFIAPI +ModU64x32 ( + IN UINT64 Dividend, + IN UINT32 Divisor + ) +{ + ASSERT (Divisor != 0); + return InternalMathModU64x32 (Dividend, Divisor); +} diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/MultS64x64.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/MultS64x64.c new file mode 100644 index 0000000..52c7adb --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/MultS64x64.c @@ -0,0 +1,49 @@ +/*++ + +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: + + MultS64x64.c + +Abstract: + + Math worker functions. + +--*/ + +#include "BaseLibInternal.h" + +/** + Multiples a 64-bit signed integer by a 64-bit signed integer and generates a + 64-bit signed result. + + This function multiples the 64-bit signed value Multiplicand by the 64-bit + signed value Multiplier and generates a 64-bit signed result. This 64-bit + signed result is returned. + + If the result overflows, then ASSERT(). + + @param Multiplicand A 64-bit signed value. + @param Multiplier A 64-bit signed value. + + @return Multiplicand * Multiplier + +**/ +INT64 +EFIAPI +MultS64x64 ( + IN INT64 Multiplicand, + IN INT64 Multiplier + ) +{ + return (INT64)MultU64x64 (Multiplicand, Multiplier); +} diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/MultU64x32.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/MultU64x32.c new file mode 100644 index 0000000..be271b8 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/MultU64x32.c @@ -0,0 +1,51 @@ +/*++ + +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: + + MultU64x32.c + +Abstract: + + Math worker functions. + +--*/ + +#include "BaseLibInternal.h" + +/** + Multiples a 64-bit unsigned integer by a 32-bit unsigned integer and + generates a 64-bit unsigned result. + + This function multiples the 64-bit unsigned value Multiplicand by the 32-bit + unsigned value Multiplier and generates a 64-bit unsigned result. This 64- + bit unsigned result is returned. + + @param Multiplicand A 64-bit unsigned value. + @param Multiplier A 32-bit unsigned value. + + @return Multiplicand * Multiplier + +**/ +UINT64 +EFIAPI +GlueMultU64x32 ( + IN UINT64 Multiplicand, + IN UINT32 Multiplier + ) +{ + UINT64 Result; + + Result = InternalMathMultU64x32 (Multiplicand, Multiplier); + + return Result; +} diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/MultU64x64.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/MultU64x64.c new file mode 100644 index 0000000..a0e5b39 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/MultU64x64.c @@ -0,0 +1,51 @@ +/*++ + +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: + + MultU64x64.c + +Abstract: + + Math worker functions. + +--*/ + +#include "BaseLibInternal.h" + +/** + Multiples a 64-bit unsigned integer by a 64-bit unsigned integer and + generates a 64-bit unsigned result. + + This function multiples the 64-bit unsigned value Multiplicand by the 64-bit + unsigned value Multiplier and generates a 64-bit unsigned result. This 64- + bit unsigned result is returned. + + @param Multiplicand A 64-bit unsigned value. + @param Multiplier A 64-bit unsigned value. + + @return Multiplicand * Multiplier + +**/ +UINT64 +EFIAPI +MultU64x64 ( + IN UINT64 Multiplicand, + IN UINT64 Multiplier + ) +{ + UINT64 Result; + + Result = InternalMathMultU64x64 (Multiplicand, Multiplier); + + return Result; +} diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/RRotU32.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/RRotU32.c new file mode 100644 index 0000000..e07d2b0 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/RRotU32.c @@ -0,0 +1,50 @@ +/*++ + +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: + + RRotU32.c + +Abstract: + + Math worker functions. + +--*/ + +#include "BaseLibInternal.h" + +/** + Rotates a 32-bit integer right between 0 and 31 bits, filling the high bits + with the low bits that were rotated. + + This function rotates the 32-bit value Operand to the right by Count bits. + The high Count bits are fill with the low Count bits of Operand. The rotated + value is returned. + + If Count is greater than 31, then ASSERT(). + + @param Operand The 32-bit operand to rotate right. + @param Count The number of bits to rotate right. + + @return Operand >>> Count + +**/ +UINT32 +EFIAPI +RRotU32 ( + IN UINT32 Operand, + IN UINTN Count + ) +{ + ASSERT (Count < sizeof (Operand) * 8); + return (Operand >> Count) | (Operand << (32 - Count)); +} diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/RRotU64.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/RRotU64.c new file mode 100644 index 0000000..f862278 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/RRotU64.c @@ -0,0 +1,50 @@ +/*++ + +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: + + RRotU64.c + +Abstract: + + Math worker functions. + +--*/ + +#include "BaseLibInternal.h" + +/** + Rotates a 64-bit integer right between 0 and 63 bits, filling the high bits + with the high low bits that were rotated. + + This function rotates the 64-bit value Operand to the right by Count bits. + The high Count bits are fill with the low Count bits of Operand. The rotated + value is returned. + + If Count is greater than 63, then ASSERT(). + + @param Operand The 64-bit operand to rotate right. + @param Count The number of bits to rotate right. + + @return Operand >>> Count + +**/ +UINT64 +EFIAPI +RRotU64 ( + IN UINT64 Operand, + IN UINTN Count + ) +{ + ASSERT (Count < sizeof (Operand) * 8); + return InternalMathRRotU64 (Operand, Count); +} diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/RShiftU64.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/RShiftU64.c new file mode 100644 index 0000000..954394d --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/RShiftU64.c @@ -0,0 +1,49 @@ +/*++ + +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: + + RShiftU64.c + +Abstract: + + Math worker functions. + +--*/ + +#include "BaseLibInternal.h" + +/** + Shifts a 64-bit integer right between 0 and 63 bits. This high bits are + filled with zeros. The shifted value is returned. + + This function shifts the 64-bit value Operand to the right by Count bits. The + high Count bits are set to zero. The shifted value is returned. + + If Count is greater than 63, then ASSERT(). + + @param Operand The 64-bit operand to shift right. + @param Count The number of bits to shift right. + + @return Operand >> Count + +**/ +UINT64 +EFIAPI +GlueRShiftU64 ( + IN UINT64 Operand, + IN UINTN Count + ) +{ + ASSERT (Count < sizeof (Operand) * 8); + return InternalMathRShiftU64 (Operand, Count); +} diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/SetJump.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/SetJump.c new file mode 100644 index 0000000..6d4eb66 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/SetJump.c @@ -0,0 +1,43 @@ +/*++ + +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: + + SetJump.c + +Abstract: + + Internal ASSERT () functions for SetJump. + +--*/ + +#include "BaseLibInternal.h" + +/** + Worker function that checks ASSERT condition for JumpBuffer + + Checks ASSERT condition for JumpBuffer. + + If JumpBuffer is NULL, then ASSERT(). + For IPF CPUs, if JumpBuffer is not aligned on a 16-byte boundary, then ASSERT(). + + @param JumpBuffer A pointer to CPU context buffer. + +**/ +VOID +EFIAPI +InternalAssertJumpBuffer ( + IN BASE_LIBRARY_JUMP_BUFFER *JumpBuffer + ) +{ + ASSERT (JumpBuffer != NULL); +} diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/String.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/String.c new file mode 100644 index 0000000..a0dee7e --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/String.c @@ -0,0 +1,974 @@ +/*++ + +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: + + String.c + +Abstract: + + Unicode string primatives. + +--*/ + +#include "BaseLibInternal.h" +#include "Pcd\EdkIIGluePcdBaseLib.h" + + +/** + Copies one Null-terminated Unicode string to another Null-terminated Unicode + string and returns the new Unicode string. + + This function copies the contents of the Unicode string Source to the Unicode + string Destination, and returns Destination. If Source and Destination + overlap, then the results are undefined. + + If Destination is NULL, then ASSERT(). + If Source is NULL, then ASSERT(). + If Source and Destination overlap, then ASSERT(). + If PcdMaximumUnicodeStringLength is not zero, and Source contains more than + PcdMaximumUnicodeStringLength Unicode characters not including the + Null-terminator, then ASSERT(). + + @param Destination Pointer to a Null-terminated Unicode string. + @param Source Pointer to a Null-terminated Unicode string. + + @return Destiantion + +**/ +CHAR16 * +EFIAPI +GlueStrCpy ( + OUT CHAR16 *Destination, + IN CONST CHAR16 *Source + ) +{ + CHAR16 *ReturnValue; + + // + // Destination cannot be NULL + // + ASSERT (Destination != NULL); + + // + // Destination and source cannot overlap + // + ASSERT ((UINTN)(Destination - Source) > StrLen (Source)); + ASSERT ((UINTN)(Source - Destination) > StrLen (Source)); + + ReturnValue = Destination; + while (*Source) { + *(Destination++) = *(Source++); + } + *Destination = 0; + return ReturnValue; +} + +/** + Copies one Null-terminated Unicode string with a maximum length to another + Null-terminated Unicode string with a maximum length and returns the new + Unicode string. + + This function copies the contents of the Unicode string Source to the Unicode + string Destination, and returns Destination. At most, Length Unicode + characters are copied from Source to Destination. If Length is 0, then + Destination is returned unmodified. If Length is greater that the number of + Unicode characters in Source, then Destination is padded with Null Unicode + characters. If Source and Destination overlap, then the results are + undefined. + + If Destination is NULL, then ASSERT(). + If Source is NULL, then ASSERT(). + If Source and Destination overlap, then ASSERT(). + If PcdMaximumUnicodeStringLength is not zero, and Source contains more than + PcdMaximumUnicodeStringLength Unicode characters not including the + Null-terminator, then ASSERT(). + + @param Destination Pointer to a Null-terminated Unicode string. + @param Source Pointer to a Null-terminated Unicode string. + @param Length Maximum number of Unicode characters to copy. + + @return Destination + +**/ +CHAR16 * +EFIAPI +GlueStrnCpy ( + OUT CHAR16 *Destination, + IN CONST CHAR16 *Source, + IN UINTN Length + ) +{ + CHAR16 *ReturnValue; + + if (Length == 0) { + return Destination; + } + + // + // Destination cannot be NULL if Length is not zero + // + ASSERT (Destination != NULL); + + // + // Destination and source cannot overlap + // Q: Does Source have to be NULL-terminated? + // + ASSERT ((UINTN)(Destination - Source) > StrLen (Source)); + ASSERT ((UINTN)(Source - Destination) >= Length); + + ReturnValue = Destination; + + while ((*Source != L'\0') && (Length > 0)) { + *(Destination++) = *(Source++); + Length--; + } + + ZeroMem (Destination, Length * sizeof (*Destination)); + return ReturnValue; +} + +/** + Returns the length of a Null-terminated Unicode string. + + This function returns the number of Unicode characters in the Null-terminated + Unicode string specified by String. + + If String is NULL, then ASSERT(). + If PcdMaximumUnicodeStringLength is not zero, and String contains more than + PcdMaximumUnicodeStringLength Unicode characters not including the + Null-terminator, then ASSERT(). + + @param String Pointer to a Null-terminated Unicode string. + + @return The length of String. + +**/ +UINTN +EFIAPI +GlueStrLen ( + IN CONST CHAR16 *String + ) +{ + UINTN Length; + + ASSERT (String != NULL); + + for (Length = 0; *String != L'\0'; String++, Length++) { + // + // If PcdMaximumUnicodeStringLength is not zero, + // length should not more than PcdMaximumUnicodeStringLength + // + if (PcdGet32 (PcdMaximumUnicodeStringLength) != 0) { + ASSERT (Length < PcdGet32 (PcdMaximumUnicodeStringLength)); + } + } + return Length; +} + +/** + Returns the size of a Null-terminated Unicode string in bytes, including the + Null terminator. + + This function returns the size, in bytes, of the Null-terminated Unicode + string specified by String. + + If String is NULL, then ASSERT(). + If PcdMaximumUnicodeStringLength is not zero, and String contains more than + PcdMaximumUnicodeStringLength Unicode characters not including the + Null-terminator, then ASSERT(). + + @param String Pointer to a Null-terminated Unicode string. + + @return The size of String. + +**/ +UINTN +EFIAPI +GlueStrSize ( + IN CONST CHAR16 *String + ) +{ + return (StrLen (String) + 1) * sizeof (*String); +} + +/** + Compares two Null-terminated Unicode strings, and returns the difference + between the first mismatched Unicode characters. + + This function compares the Null-terminated Unicode string FirstString to the + Null-terminated Unicode string SecondString. If FirstString is identical to + SecondString, then 0 is returned. Otherwise, the value returned is the first + mismatched Unicode character in SecondString subtracted from the first + mismatched Unicode character in FirstString. + + If FirstString is NULL, then ASSERT(). + If SecondString is NULL, then ASSERT(). + If PcdMaximumUnicodeStringLength is not zero, and FirstString contains more + than PcdMaximumUnicodeStringLength Unicode characters not including the + Null-terminator, then ASSERT(). + If PcdMaximumUnicodeStringLength is not zero, and SecondString contains more + than PcdMaximumUnicodeStringLength Unicode characters not including the + Null-terminator, then ASSERT(). + + @param FirstString Pointer to a Null-terminated Unicode string. + @param SecondString Pointer to a Null-terminated Unicode string. + + @retval 0 FirstString is identical to SecondString. + @retval !=0 FirstString is not identical to SecondString. + +**/ +INTN +EFIAPI +GlueStrCmp ( + IN CONST CHAR16 *FirstString, + IN CONST CHAR16 *SecondString + ) +{ + // + // ASSERT both strings are less long than PcdMaximumUnicodeStringLength + // + ASSERT (StrSize (FirstString) != 0); + ASSERT (StrSize (SecondString) != 0); + + while ((*FirstString != L'\0') && (*FirstString == *SecondString)) { + FirstString++; + SecondString++; + } + return *FirstString - *SecondString; +} + +/** + Compares two Null-terminated Unicode strings with maximum lengths, and + returns the difference between the first mismatched Unicode characters. + + This function compares the Null-terminated Unicode string FirstString to the + Null-terminated Unicode string SecondString. At most, Length Unicode + characters will be compared. If Length is 0, then 0 is returned. If + FirstString is identical to SecondString, then 0 is returned. Otherwise, the + value returned is the first mismatched Unicode character in SecondString + subtracted from the first mismatched Unicode character in FirstString. + + If FirstString is NULL, then ASSERT(). + If SecondString is NULL, then ASSERT(). + If PcdMaximumUnicodeStringLength is not zero, and FirstString contains more + than PcdMaximumUnicodeStringLength Unicode characters not including the + Null-terminator, then ASSERT(). + If PcdMaximumUnicodeStringLength is not zero, and SecondString contains more + than PcdMaximumUnicodeStringLength Unicode characters not including the + Null-terminator, then ASSERT(). + + @param FirstString Pointer to a Null-terminated Unicode string. + @param SecondString Pointer to a Null-terminated Unicode string. + @param Length Maximum number of Unicode characters to compare. + + @retval 0 FirstString is identical to SecondString. + @retval !=0 FirstString is not identical to SecondString. + +**/ +INTN +EFIAPI +GlueStrnCmp ( + IN CONST CHAR16 *FirstString, + IN CONST CHAR16 *SecondString, + IN UINTN Length + ) +{ + if (Length == 0) { + return 0; + } + + // + // ASSERT both strings are less long than PcdMaximumUnicodeStringLength. + // Length tests are performed inside StrLen(). + // + ASSERT (StrSize (FirstString) != 0); + ASSERT (StrSize (SecondString) != 0); + + while ((*FirstString != L'\0') && + (*FirstString == *SecondString) && + (Length > 1)) { + FirstString++; + SecondString++; + Length--; + } + + return *FirstString - *SecondString; +} + +/** + Concatenates one Null-terminated Unicode string to another Null-terminated + Unicode string, and returns the concatenated Unicode string. + + This function concatenates two Null-terminated Unicode strings. The contents + of Null-terminated Unicode string Source are concatenated to the end of + Null-terminated Unicode string Destination. The Null-terminated concatenated + Unicode String is returned. If Source and Destination overlap, then the + results are undefined. + + If Destination is NULL, then ASSERT(). + If Source is NULL, then ASSERT(). + If Source and Destination overlap, then ASSERT(). + If PcdMaximumUnicodeStringLength is not zero, and Destination contains more + than PcdMaximumUnicodeStringLength Unicode characters not including the + Null-terminator, then ASSERT(). + If PcdMaximumUnicodeStringLength is not zero, and Source contains more than + PcdMaximumUnicodeStringLength Unicode characters not including the + Null-terminator, then ASSERT(). + If PcdMaximumUnicodeStringLength is not zero, and concatenating Destination + and Source results in a Unicode string with more than + PcdMaximumUnicodeStringLength Unicode characters not including the + Null-terminator, then ASSERT(). + + @param Destination Pointer to a Null-terminated Unicode string. + @param Source Pointer to a Null-terminated Unicode string. + + @return Destination + +**/ +CHAR16 * +EFIAPI +GlueStrCat ( + IN OUT CHAR16 *Destination, + IN CONST CHAR16 *Source + ) +{ + StrCpy (Destination + StrLen (Destination), Source); + + // + // Size of the resulting string should never be zero. + // PcdMaximumUnicodeStringLength is tested inside StrLen(). + // + ASSERT (StrSize (Destination) != 0); + return Destination; +} + +/** + Concatenates one Null-terminated Unicode string with a maximum length to the + end of another Null-terminated Unicode string, and returns the concatenated + Unicode string. + + This function concatenates two Null-terminated Unicode strings. The contents + of Null-terminated Unicode string Source are concatenated to the end of + Null-terminated Unicode string Destination, and Destination is returned. At + most, Length Unicode characters are concatenated from Source to the end of + Destination, and Destination is always Null-terminated. If Length is 0, then + Destination is returned unmodified. If Source and Destination overlap, then + the results are undefined. + + If Destination is NULL, then ASSERT(). + If Source is NULL, then ASSERT(). + If Source and Destination overlap, then ASSERT(). + If PcdMaximumUnicodeStringLength is not zero, and Destination contains more + than PcdMaximumUnicodeStringLength Unicode characters not including the + Null-terminator, then ASSERT(). + If PcdMaximumUnicodeStringLength is not zero, and Source contains more than + PcdMaximumUnicodeStringLength Unicode characters not including the + Null-terminator, then ASSERT(). + If PcdMaximumUnicodeStringLength is not zero, and concatenating Destination + and Source results in a Unicode string with more than + PcdMaximumUnicodeStringLength Unicode characters not including the + Null-terminator, then ASSERT(). + + @param Destination Pointer to a Null-terminated Unicode string. + @param Source Pointer to a Null-terminated Unicode string. + @param Length Maximum number of Unicode characters to concatenate from + Source. + + @return Destination + +**/ +CHAR16 * +EFIAPI +GlueStrnCat ( + IN OUT CHAR16 *Destination, + IN CONST CHAR16 *Source, + IN UINTN Length + ) +{ + StrnCpy (Destination + StrLen (Destination), Source, Length); + + // + // Size of the resulting string should never be zero. + // PcdMaximumUnicodeStringLength is tested inside StrLen(). + // + ASSERT (StrSize (Destination) != 0); + return Destination; +} + +//;;## ...AMI_OVERRIDE... Support Unicode Str To Ascii Str start. +/** + Convert a Null-terminated Unicode string to a Null-terminated + ASCII string and returns the ASCII string. + + This function converts the content of the Unicode string Source + to the ASCII string Destination by copying the lower 8 bits of + each Unicode character. It returns Destination. The function terminates + the ASCII string Destination by appending a Null-terminator character + at the end. The caller is responsible to make sure Destination points + to a buffer with size equal or greater than (StrLen (Source) + 1) in bytes. + + If Destination is NULL, then ASSERT(). + If Source is NULL, then ASSERT(). + If Source is not aligned on a 16-bit boundary, then ASSERT(). + If Source and Destination overlap, then ASSERT(). + + If any Unicode characters in Source contain non-zero value in + the upper 8 bits, then ASSERT(). + + If PcdMaximumUnicodeStringLength is not zero, and Source contains + more than PcdMaximumUnicodeStringLength Unicode characters not including + the Null-terminator, then ASSERT(). + + If PcdMaximumAsciiStringLength is not zero, and Source contains more + than PcdMaximumAsciiStringLength Unicode characters not including the + Null-terminator, then ASSERT(). + + @param Source Pointer to a Null-terminated Unicode string. + @param Destination Pointer to a Null-terminated ASCII string. + + @reture Destination + +**/ +CHAR8 * +EFIAPI +UnicodeStrToAsciiStr ( + IN CONST CHAR16 *Source, + OUT CHAR8 *Destination + ) +{ + ASSERT (Destination != NULL); + ASSERT (Source != NULL); + ASSERT (((UINTN) Source & 0x01) == 0); + + // + // Source and Destination should not overlap + // + ASSERT ((UINTN) ((CHAR16 *) Destination - Source) > StrLen (Source)); + ASSERT ((UINTN) ((CHAR8 *) Source - Destination) > StrLen (Source)); + + // + // If PcdMaximumUnicodeStringLength is not zero, + // length of Source should not more than PcdMaximumUnicodeStringLength + // + if (PcdGet32 (PcdMaximumUnicodeStringLength) != 0) { + ASSERT (StrLen (Source) < PcdGet32 (PcdMaximumUnicodeStringLength)); + } + + while (*Source != '\0') { + // + // If any Unicode characters in Source contain + // non-zero value in the upper 8 bits, then ASSERT(). + // + ASSERT (*Source < 0x100); + *(Destination++) = (CHAR8) *(Source++); + } + + *Destination = '\0'; + + return Destination; +} +//;;## ...AMI_OVERRIDE... Support Unicode Str To Ascii Str end. + +/** + Copies one Null-terminated ASCII string to another Null-terminated ASCII + string and returns the new ASCII string. + + This function copies the contents of the ASCII string Source to the ASCII + string Destination, and returns Destination. If Source and Destination + overlap, then the results are undefined. + + If Destination is NULL, then ASSERT(). + If Source is NULL, then ASSERT(). + If Source and Destination overlap, then ASSERT(). + If PcdMaximumAsciiStringLength is not zero and Source contains more than + PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, + then ASSERT(). + + @param Destination Pointer to a Null-terminated ASCII string. + @param Source Pointer to a Null-terminated ASCII string. + + @return Destination + +**/ +CHAR8 * +EFIAPI +AsciiStrCpy ( + OUT CHAR8 *Destination, + IN CONST CHAR8 *Source + ) +{ + CHAR8 *ReturnValue; + + // + // Destination cannot be NULL + // + ASSERT (Destination != NULL); + + // + // Destination and source cannot overlap + // + ASSERT ((UINTN)(Destination - Source) > AsciiStrLen (Source)); + ASSERT ((UINTN)(Source - Destination) > AsciiStrLen (Source)); + + ReturnValue = Destination; + while (*Source) { + *(Destination++) = *(Source++); + } + *Destination = 0; + return ReturnValue; +} + +/** + Copies one Null-terminated ASCII string with a maximum length to another + Null-terminated ASCII string with a maximum length and returns the new ASCII + string. + + This function copies the contents of the ASCII string Source to the ASCII + string Destination, and returns Destination. At most, Length ASCII characters + are copied from Source to Destination. If Length is 0, then Destination is + returned unmodified. If Length is greater that the number of ASCII characters + in Source, then Destination is padded with Null ASCII characters. If Source + and Destination overlap, then the results are undefined. + + If Destination is NULL, then ASSERT(). + If Source is NULL, then ASSERT(). + If Source and Destination overlap, then ASSERT(). + If PcdMaximumAsciiStringLength is not zero, and Source contains more than + PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, + then ASSERT(). + + @param Destination Pointer to a Null-terminated ASCII string. + @param Source Pointer to a Null-terminated ASCII string. + @param Length Maximum number of ASCII characters to copy. + + @return Destination + +**/ +CHAR8 * +EFIAPI +AsciiStrnCpy ( + OUT CHAR8 *Destination, + IN CONST CHAR8 *Source, + IN UINTN Length + ) +{ + CHAR8 *ReturnValue; + + if (Length == 0) { + return Destination; + } + + // + // Destination cannot be NULL + // + ASSERT (Destination != NULL); + + // + // Destination and source cannot overlap + // + ASSERT ((UINTN)(Destination - Source) > AsciiStrLen (Source)); + ASSERT ((UINTN)(Source - Destination) >= Length); + + ReturnValue = Destination; + + while (*Source && Length > 0) { + *(Destination++) = *(Source++); + Length--; + } + + ZeroMem (Destination, Length * sizeof (*Destination)); + return ReturnValue; +} + +/** + Returns the length of a Null-terminated ASCII string. + + This function returns the number of ASCII characters in the Null-terminated + ASCII string specified by String. + + If String is NULL, then ASSERT(). + If PcdMaximumAsciiStringLength is not zero and String contains more than + PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, + then ASSERT(). + + @param String Pointer to a Null-terminated ASCII string. + + @return The length of String. + +**/ +UINTN +EFIAPI +AsciiStrLen ( + IN CONST CHAR8 *String + ) +{ + UINTN Length; + + ASSERT (String != NULL); + + for (Length = 0; *String != '\0'; String++, Length++) { + // + // If PcdMaximumUnicodeStringLength is not zero, + // length should not more than PcdMaximumUnicodeStringLength + // + if (PcdGet32 (PcdMaximumAsciiStringLength) != 0) { + ASSERT (Length < PcdGet32 (PcdMaximumAsciiStringLength)); + } + } + return Length; +} + +/** + Returns the size of a Null-terminated ASCII string in bytes, including the + Null terminator. + + This function returns the size, in bytes, of the Null-terminated ASCII string + specified by String. + + If String is NULL, then ASSERT(). + If PcdMaximumAsciiStringLength is not zero and String contains more than + PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, + then ASSERT(). + + @param String Pointer to a Null-terminated ASCII string. + + @return The size of String. + +**/ +UINTN +EFIAPI +AsciiStrSize ( + IN CONST CHAR8 *String + ) +{ + return (AsciiStrLen (String) + 1) * sizeof (*String); +} + +/** + Compares two Null-terminated ASCII strings, and returns the difference + between the first mismatched ASCII characters. + + This function compares the Null-terminated ASCII string FirstString to the + Null-terminated ASCII string SecondString. If FirstString is identical to + SecondString, then 0 is returned. Otherwise, the value returned is the first + mismatched ASCII character in SecondString subtracted from the first + mismatched ASCII character in FirstString. + + If FirstString is NULL, then ASSERT(). + If SecondString is NULL, then ASSERT(). + If PcdMaximumAsciiStringLength is not zero and FirstString contains more than + PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, + then ASSERT(). + If PcdMaximumAsciiStringLength is not zero and SecondString contains more + than PcdMaximumAsciiStringLength ASCII characters not including the + Null-terminator, then ASSERT(). + + @param FirstString Pointer to a Null-terminated ASCII string. + @param SecondString Pointer to a Null-terminated ASCII string. + + @retval 0 FirstString is identical to SecondString. + @retval !=0 FirstString is not identical to SecondString. + +**/ +INTN +EFIAPI +AsciiStrCmp ( + IN CONST CHAR8 *FirstString, + IN CONST CHAR8 *SecondString + ) +{ + // + // ASSERT both strings are less long than PcdMaximumAsciiStringLength + // + ASSERT (AsciiStrSize (FirstString)); + ASSERT (AsciiStrSize (SecondString)); + + while ((*FirstString != '\0') && (*FirstString == *SecondString)) { + FirstString++; + SecondString++; + } + + return *FirstString - *SecondString; +} + +/** + Converts a lowercase Ascii character to upper one + + If Chr is lowercase Ascii character, then converts it to upper one. + + If Value >= 0xA0, then ASSERT(). + If (Value & 0x0F) >= 0x0A, then ASSERT(). + + @param chr one Ascii character + + @return The uppercase value of Ascii character + +**/ +STATIC +CHAR8 +AsciiToUpper ( + IN CHAR8 Chr + ) +{ + return (Chr >= 'a' && Chr <= 'z') ? Chr - ('a' - 'A') : Chr; +} + +/** + Performs a case insensitive comparison of two Null-terminated ASCII strings, + and returns the difference between the first mismatched ASCII characters. + + This function performs a case insensitive comparison of the Null-terminated + ASCII string FirstString to the Null-terminated ASCII string SecondString. If + FirstString is identical to SecondString, then 0 is returned. Otherwise, the + value returned is the first mismatched lower case ASCII character in + SecondString subtracted from the first mismatched lower case ASCII character + in FirstString. + + If FirstString is NULL, then ASSERT(). + If SecondString is NULL, then ASSERT(). + If PcdMaximumAsciiStringLength is not zero and FirstString contains more than + PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, + then ASSERT(). + If PcdMaximumAsciiStringLength is not zero and SecondString contains more + than PcdMaximumAsciiStringLength ASCII characters not including the + Null-terminator, then ASSERT(). + + @param FirstString Pointer to a Null-terminated ASCII string. + @param SecondString Pointer to a Null-terminated ASCII string. + + @retval 0 FirstString is identical to SecondString using case insensitive + comparisons. + @retval !=0 FirstString is not identical to SecondString using case + insensitive comparisons. + +**/ +INTN +EFIAPI +AsciiStriCmp ( + IN CONST CHAR8 *FirstString, + IN CONST CHAR8 *SecondString + ) +{ + // + // ASSERT both strings are less long than PcdMaximumAsciiStringLength + // + ASSERT (AsciiStrSize (FirstString)); + ASSERT (AsciiStrSize (SecondString)); + + while ((*FirstString != '\0') && + (AsciiToUpper (*FirstString) == AsciiToUpper (*SecondString))) { + FirstString++; + SecondString++; + } + + return AsciiToUpper (*FirstString) - AsciiToUpper (*SecondString); +} + +/** + Compares two Null-terminated ASCII strings with maximum lengths, and returns + the difference between the first mismatched ASCII characters. + + This function compares the Null-terminated ASCII string FirstString to the + Null-terminated ASCII string SecondString. At most, Length ASCII characters + will be compared. If Length is 0, then 0 is returned. If FirstString is + identical to SecondString, then 0 is returned. Otherwise, the value returned + is the first mismatched ASCII character in SecondString subtracted from the + first mismatched ASCII character in FirstString. + + If FirstString is NULL, then ASSERT(). + If SecondString is NULL, then ASSERT(). + If PcdMaximumAsciiStringLength is not zero and FirstString contains more than + PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, + then ASSERT(). + If PcdMaximumAsciiStringLength is not zero and SecondString contains more than + PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, + then ASSERT(). + + @param FirstString Pointer to a Null-terminated ASCII string. + @param SecondString Pointer to a Null-terminated ASCII string. + + @retval 0 FirstString is identical to SecondString. + @retval !=0 FirstString is not identical to SecondString. + +**/ +INTN +EFIAPI +AsciiStrnCmp ( + IN CONST CHAR8 *FirstString, + IN CONST CHAR8 *SecondString, + IN UINTN Length + ) +{ + if (Length == 0) { + return 0; + } + + // + // ASSERT both strings are less long than PcdMaximumAsciiStringLength + // + ASSERT (AsciiStrSize (FirstString)); + ASSERT (AsciiStrSize (SecondString)); + + while ((*FirstString != '\0') && + (*FirstString == *SecondString) && + (Length > 1)) { + FirstString++; + SecondString++; + Length--; + } + return *FirstString - *SecondString; +} + +/** + Concatenates one Null-terminated ASCII string to another Null-terminated + ASCII string, and returns the concatenated ASCII string. + + This function concatenates two Null-terminated ASCII strings. The contents of + Null-terminated ASCII string Source are concatenated to the end of Null- + terminated ASCII string Destination. The Null-terminated concatenated ASCII + String is returned. + + If Destination is NULL, then ASSERT(). + If Source is NULL, then ASSERT(). + If PcdMaximumAsciiStringLength is not zero and Destination contains more than + PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, + then ASSERT(). + If PcdMaximumAsciiStringLength is not zero and Source contains more than + PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, + then ASSERT(). + If PcdMaximumAsciiStringLength is not zero and concatenating Destination and + Source results in a ASCII string with more than PcdMaximumAsciiStringLength + ASCII characters, then ASSERT(). + + @param Destination Pointer to a Null-terminated ASCII string. + @param Source Pointer to a Null-terminated ASCII string. + + @return Destination + +**/ +CHAR8 * +EFIAPI +AsciiStrCat ( + IN OUT CHAR8 *Destination, + IN CONST CHAR8 *Source + ) +{ + AsciiStrCpy (Destination + AsciiStrLen (Destination), Source); + + // + // Size of the resulting string should never be zero. + // PcdMaximumUnicodeStringLength is tested inside StrLen(). + // + ASSERT (AsciiStrSize (Destination) != 0); + return Destination; +} + +/** + Concatenates one Null-terminated ASCII string with a maximum length to the + end of another Null-terminated ASCII string, and returns the concatenated + ASCII string. + + This function concatenates two Null-terminated ASCII strings. The contents + of Null-terminated ASCII string Source are concatenated to the end of Null- + terminated ASCII string Destination, and Destination is returned. At most, + Length ASCII characters are concatenated from Source to the end of + Destination, and Destination is always Null-terminated. If Length is 0, then + Destination is returned unmodified. If Source and Destination overlap, then + the results are undefined. + + If Destination is NULL, then ASSERT(). + If Source is NULL, then ASSERT(). + If Source and Destination overlap, then ASSERT(). + If PcdMaximumAsciiStringLength is not zero, and Destination contains more than + PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, + then ASSERT(). + If PcdMaximumAsciiStringLength is not zero, and Source contains more than + PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, + then ASSERT(). + If PcdMaximumAsciiStringLength is not zero, and concatenating Destination and + Source results in a ASCII string with more than PcdMaximumAsciiStringLength + ASCII characters not including the Null-terminator, then ASSERT(). + + @param Destination Pointer to a Null-terminated ASCII string. + @param Source Pointer to a Null-terminated ASCII string. + @param Length Maximum number of ASCII characters to concatenate from + Source. + + @return Destination + +**/ +CHAR8 * +EFIAPI +AsciiStrnCat ( + IN OUT CHAR8 *Destination, + IN CONST CHAR8 *Source, + IN UINTN Length + ) +{ + AsciiStrnCpy (Destination + AsciiStrLen (Destination), Source, Length); + + // + // Size of the resulting string should never be zero. + // PcdMaximumUnicodeStringLength is tested inside StrLen(). + // + ASSERT (AsciiStrSize (Destination) != 0); + return Destination; +} + +/** + Converts an 8-bit value to an 8-bit BCD value. + + Converts the 8-bit value specified by Value to BCD. The BCD value is + returned. + + If Value >= 100, then ASSERT(). + + @param Value The 8-bit value to convert to BCD. Range 0..99. + + @return The BCD value + +**/ +UINT8 +EFIAPI +DecimalToBcd8 ( + IN UINT8 Value + ) +{ + ASSERT (Value < 100); + return ((Value / 10) << 4) | (Value % 10); +} + +/** + Converts an 8-bit BCD value to an 8-bit value. + + Converts the 8-bit BCD value specified by Value to an 8-bit value. The 8-bit + value is returned. + + If Value >= 0xA0, then ASSERT(). + If (Value & 0x0F) >= 0x0A, then ASSERT(). + + @param Value The 8-bit BCD value to convert to an 8-bit value. + + @return The 8-bit value is returned. + +**/ +UINT8 +EFIAPI +BcdToDecimal8 ( + IN UINT8 Value + ) +{ + ASSERT (Value < 0xa0); + ASSERT ((Value & 0xf) < 0xa); + return (Value >> 4) * 10 + (Value & 0xf); +} diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/SwapBytes16.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/SwapBytes16.c new file mode 100644 index 0000000..07392ed --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/SwapBytes16.c @@ -0,0 +1,44 @@ +/*++ + +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: + + SwapBytes16.c + +Abstract: + + Math worker functions. + +--*/ + +#include "BaseLibInternal.h" + +/** + Switches the endianess of a 16-bit integer. + + This function swaps the bytes in a 16-bit unsigned value to switch the value + from little endian to big endian or vice versa. The byte swapped value is + returned. + + @param Operand A 16-bit unsigned value. + + @return The byte swaped Operand. + +**/ +UINT16 +EFIAPI +SwapBytes16 ( + IN UINT16 Operand + ) +{ + return (Operand << 8) | (Operand >> 8); +} diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/SwapBytes32.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/SwapBytes32.c new file mode 100644 index 0000000..1b5b129 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/SwapBytes32.c @@ -0,0 +1,47 @@ +/*++ + +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: + + SwapBytes32.c + +Abstract: + + Math worker functions. + +--*/ + +#include "BaseLibInternal.h" + +/** + Switches the endianess of a 32-bit integer. + + This function swaps the bytes in a 32-bit unsigned value to switch the value + from little endian to big endian or vice versa. The byte swapped value is + returned. + + @param Operand A 32-bit unsigned value. + + @return The byte swaped Operand. + +**/ +UINT32 +EFIAPI +SwapBytes32 ( + IN UINT32 Operand + ) +{ + return (UINT32)( + ((UINT32)SwapBytes16 ((UINT16)Operand) << 16) | + ((UINT32)SwapBytes16 ((UINT16)(Operand >> 16))) + ); +} diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/SwapBytes64.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/SwapBytes64.c new file mode 100644 index 0000000..5f6891c --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/SwapBytes64.c @@ -0,0 +1,44 @@ +/*++ + +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: + + SwapBytes64.c + +Abstract: + + Math worker functions. + +--*/ + +#include "BaseLibInternal.h" + +/** + Switches the endianess of a 64-bit integer. + + This function swaps the bytes in a 64-bit unsigned value to switch the value + from little endian to big endian or vice versa. The byte swapped value is + returned. + + @param Operand A 64-bit unsigned value. + + @return The byte swaped Operand. + +**/ +UINT64 +EFIAPI +SwapBytes64 ( + IN UINT64 Operand + ) +{ + return InternalMathSwapBytes64 (Operand); +} diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/SwitchStack.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/SwitchStack.c new file mode 100644 index 0000000..34f8dce --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/SwitchStack.c @@ -0,0 +1,58 @@ +/*++ + +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: + + SwitchStack.c + +Abstract: + + Switch Stack functions. + +--*/ + +#include "BaseLibInternal.h" + +/** + Transfers control to a function starting with a new stack. + + Transfers control to the function specified by EntryPoint using the new stack + specified by NewStack and passing in the parameters specified by Context1 and + Context2. Context1 and Context2 are optional and may be NULL. The function + EntryPoint must never return. + + If EntryPoint is NULL, then ASSERT(). + If NewStack is NULL, then ASSERT(). + For IPF CPUs, if NewStack is not aligned on a 16-byte boundary, then ASSERT(). + + @param EntryPoint A pointer to function to call with the new stack. + @param Context1 A pointer to the context to pass into the EntryPoint + function. + @param Context2 A pointer to the context to pass into the EntryPoint + function. + @param NewStack A pointer to the new stack to use for the EntryPoint + function. + +**/ +VOID +EFIAPI +SwitchStack ( + IN SWITCH_STACK_ENTRY_POINT EntryPoint, + IN VOID *Context1, + IN VOID *Context2, + IN VOID *NewStack + ) +{ + ASSERT (EntryPoint != NULL && NewStack != NULL); + + InternalSwitchStack (EntryPoint, Context1, Context2, NewStack); +} diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Synchronization.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Synchronization.c new file mode 100644 index 0000000..8056f6e --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Synchronization.c @@ -0,0 +1,438 @@ +/*++ + +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: + + Synchronization.c + +Abstract: + + Implementation of synchronization functions. + +--*/ + +#include "BaseLibInternal.h" +#include "Pcd\EdkIIGluePcdBaseLib.h" + +#define SPIN_LOCK_RELEASED ((UINTN)1) +#define SPIN_LOCK_ACQUIRED ((UINTN)2) + +/** + Performs an atomic increment of an 32-bit unsigned integer. + + Performs an atomic increment of the 32-bit unsigned integer specified by + Value and returns the incremented value. The increment operation must be + performed using MP safe mechanisms. The state of the return value is not + guaranteed to be MP safe. + + @param Value A pointer to the 32-bit value to increment. + + @return The incremented value. + +**/ +UINT32 +EFIAPI +InternalSyncIncrement ( + IN volatile UINT32 *Value + ); + +/** + Performs an atomic decrement of an 32-bit unsigned integer. + + Performs an atomic decrement of the 32-bit unsigned integer specified by + Value and returns the decrement value. The decrement operation must be + performed using MP safe mechanisms. The state of the return value is not + guaranteed to be MP safe. + + @param Value A pointer to the 32-bit value to decrement. + + @return The decrement value. + +**/ +UINT32 +EFIAPI +InternalSyncDecrement ( + IN volatile UINT32 *Value + ); + +/** + Performs an atomic compare exchange operation on a 32-bit unsigned integer. + + Performs an atomic compare exchange operation on the 32-bit unsigned integer + specified by Value. If Value is equal to CompareValue, then Value is set to + ExchangeValue and CompareValue is returned. If Value is not equal to CompareValue, + then Value is returned. The compare exchange operation must be performed using + MP safe mechanisms. + + @param Value A pointer to the 32-bit value for the compare exchange + operation. + @param CompareValue 32-bit value used in compare operation. + @param ExchangeValue 32-bit value used in exchange operation. + + @return The original *Value before exchange. + +**/ +UINT32 +EFIAPI +InternalSyncCompareExchange32 ( + IN volatile UINT32 *Value, + IN UINT32 CompareValue, + IN UINT32 ExchangeValue + ); + +/** + Performs an atomic compare exchange operation on a 64-bit unsigned integer. + + Performs an atomic compare exchange operation on the 64-bit unsigned integer specified + by Value. If Value is equal to CompareValue, then Value is set to ExchangeValue and + CompareValue is returned. If Value is not equal to CompareValue, then Value is returned. + The compare exchange operation must be performed using MP safe mechanisms. + + @param Value A pointer to the 64-bit value for the compare exchange + operation. + @param CompareValue 64-bit value used in compare operation. + @param ExchangeValue 64-bit value used in exchange operation. + + @return The original *Value before exchange. + +**/ +UINT64 +EFIAPI +InternalSyncCompareExchange64 ( + IN volatile UINT64 *Value, + IN UINT64 CompareValue, + IN UINT64 ExchangeValue + ); + +/** + Retrieves the architecture specific spin lock alignment requirements for + optimal spin lock performance. + + This function retrieves the spin lock alignment requirements for optimal + performance on a given CPU architecture. The spin lock alignment must be a + power of two and is returned by this function. If there are no alignment + requirements, then 1 must be returned. The spin lock synchronization + functions must function correctly if the spin lock size and alignment values + returned by this function are not used at all. These values are hints to the + consumers of the spin lock synchronization functions to obtain optimal spin + lock performance. + + @return The architecture specific spin lock alignment. + +**/ +UINTN +EFIAPI +GetSpinLockProperties ( + VOID + ) +{ + // @bug May use a PCD entry to determine this alignment. + return 32; +} + +/** + Initializes a spin lock to the released state and returns the spin lock. + + This function initializes the spin lock specified by SpinLock to the released + state, and returns SpinLock. Optimal performance can be achieved by calling + GetSpinLockProperties() to determine the size and alignment requirements for + SpinLock. + + If SpinLock is NULL, then ASSERT(). + + @param SpinLock A pointer to the spin lock to initialize to the released + state. + + @return SpinLock + +**/ +SPIN_LOCK * +EFIAPI +InitializeSpinLock ( + OUT SPIN_LOCK *SpinLock + ) +{ + ASSERT (SpinLock != NULL); + *SpinLock = SPIN_LOCK_RELEASED; + return SpinLock; +} + +/** + Waits until a spin lock can be placed in the acquired state. + + This function checks the state of the spin lock specified by SpinLock. If + SpinLock is in the released state, then this function places SpinLock in the + acquired state and returns SpinLock. Otherwise, this function waits + indefinitely for the spin lock to be released, and then places it in the + acquired state and returns SpinLock. All state transitions of SpinLock must + be performed using MP safe mechanisms. + + If SpinLock is NULL, then ASSERT(). + If SpinLock was not initialized with InitializeSpinLock(), then ASSERT(). + If PcdSpinLockTimeout is not zero, and SpinLock is can not be acquired in + PcdSpinLockTimeout microseconds, then ASSERT(). + + @param SpinLock A pointer to the spin lock to place in the acquired state. + + @return SpinLock + +**/ +SPIN_LOCK * +EFIAPI +AcquireSpinLock ( + IN OUT SPIN_LOCK *SpinLock + ) +{ + UINT64 Tick; + UINT64 Start, End; + UINT64 Timeout; + + Tick = 0; + Start = 0; + End = 0; + if (PcdGet32 (PcdSpinLockTimeout) > 0) { + Tick = GetPerformanceCounter (); + Timeout = DivU64x32 ( + MultU64x32 ( + GetPerformanceCounterProperties (&Start, &End), + PcdGet32 (PcdSpinLockTimeout) + ), + 1000000 + ); + if (Start < End) { + Tick += Timeout; + } else { + Tick -= Timeout; + } + } + + while (!AcquireSpinLockOrFail (SpinLock)) { + CpuPause (); + ASSERT ((Start < End) ^ (Tick <= GetPerformanceCounter ())); + } + return SpinLock; +} + +/** + Attempts to place a spin lock in the acquired state. + + This function checks the state of the spin lock specified by SpinLock. If + SpinLock is in the released state, then this function places SpinLock in the + acquired state and returns TRUE. Otherwise, FALSE is returned. All state + transitions of SpinLock must be performed using MP safe mechanisms. + + If SpinLock is NULL, then ASSERT(). + If SpinLock was not initialized with InitializeSpinLock(), then ASSERT(). + + @param SpinLock A pointer to the spin lock to place in the acquired state. + + @retval TRUE SpinLock was placed in the acquired state. + @retval FALSE SpinLock could not be acquired. + +**/ +BOOLEAN +EFIAPI +AcquireSpinLockOrFail ( + IN OUT SPIN_LOCK *SpinLock + ) +{ + ASSERT (SpinLock != NULL); + ASSERT (*SpinLock == SPIN_LOCK_ACQUIRED || *SpinLock == SPIN_LOCK_RELEASED); + return (BOOLEAN)( + InterlockedCompareExchangePointer ( + (VOID**)SpinLock, + (VOID*)SPIN_LOCK_RELEASED, + (VOID*)SPIN_LOCK_ACQUIRED + ) == (VOID*)SPIN_LOCK_RELEASED + ); +} + +/** + Releases a spin lock. + + This function places the spin lock specified by SpinLock in the release state + and returns SpinLock. + + If SpinLock is NULL, then ASSERT(). + If SpinLock was not initialized with InitializeSpinLock(), then ASSERT(). + + @param SpinLock A pointer to the spin lock to release. + + @return SpinLock + +**/ +SPIN_LOCK * +EFIAPI +ReleaseSpinLock ( + IN OUT SPIN_LOCK *SpinLock + ) +{ + ASSERT (SpinLock != NULL); + ASSERT (*SpinLock == SPIN_LOCK_ACQUIRED || *SpinLock == SPIN_LOCK_RELEASED); + *SpinLock = SPIN_LOCK_RELEASED; + return SpinLock; +} + +/** + Performs an atomic increment of an 32-bit unsigned integer. + + Performs an atomic increment of the 32-bit unsigned integer specified by + Value and returns the incremented value. The increment operation must be + performed using MP safe mechanisms. The state of the return value is not + guaranteed to be MP safe. + + If Value is NULL, then ASSERT(). + + @param Value A pointer to the 32-bit value to increment. + + @return The incremented value. + +**/ +UINT32 +EFIAPI +InterlockedIncrement ( + IN UINT32 *Value + ) +{ + ASSERT (Value != NULL); + return InternalSyncIncrement (Value); +} + +/** + Performs an atomic decrement of an 32-bit unsigned integer. + + Performs an atomic decrement of the 32-bit unsigned integer specified by + Value and returns the decremented value. The decrement operation must be + performed using MP safe mechanisms. The state of the return value is not + guaranteed to be MP safe. + + If Value is NULL, then ASSERT(). + + @param Value A pointer to the 32-bit value to decrement. + + @return The decremented value. + +**/ +UINT32 +EFIAPI +InterlockedDecrement ( + IN UINT32 *Value + ) +{ + ASSERT (Value != NULL); + return InternalSyncDecrement (Value); +} + +/** + Performs an atomic compare exchange operation on a 32-bit unsigned integer. + + Performs an atomic compare exchange operation on the 32-bit unsigned integer + specified by Value. If Value is equal to CompareValue, then Value is set to + ExchangeValue and CompareValue is returned. If Value is not equal to CompareValue, + then Value is returned. The compare exchange operation must be performed using + MP safe mechanisms. + + If Value is NULL, then ASSERT(). + + @param Value A pointer to the 32-bit value for the compare exchange + operation. + @param CompareValue 32-bit value used in compare operation. + @param ExchangeValue 32-bit value used in exchange operation. + + @return The original *Value before exchange. + +**/ +UINT32 +EFIAPI +InterlockedCompareExchange32 ( + IN OUT VOLATILE UINT32 *Value, + IN UINT32 CompareValue, + IN UINT32 ExchangeValue + ) +{ + ASSERT (Value != NULL); + return InternalSyncCompareExchange32 (Value, CompareValue, ExchangeValue); +} + +/** + Performs an atomic compare exchange operation on a 64-bit unsigned integer. + + Performs an atomic compare exchange operation on the 64-bit unsigned integer specified + by Value. If Value is equal to CompareValue, then Value is set to ExchangeValue and + CompareValue is returned. If Value is not equal to CompareValue, then Value is returned. + The compare exchange operation must be performed using MP safe mechanisms. + + If Value is NULL, then ASSERT(). + + @param Value A pointer to the 64-bit value for the compare exchange + operation. + @param CompareValue 64-bit value used in compare operation. + @param ExchangeValue 64-bit value used in exchange operation. + + @return The original *Value before exchange. + +**/ +UINT64 +EFIAPI +InterlockedCompareExchange64 ( + IN OUT VOLATILE UINT64 *Value, + IN UINT64 CompareValue, + IN UINT64 ExchangeValue + ) +{ + ASSERT (Value != NULL); + return InternalSyncCompareExchange64 (Value, CompareValue, ExchangeValue); +} + +/** + Performs an atomic compare exchange operation on a pointer value. + + Performs an atomic compare exchange operation on the pointer value specified + by Value. If Value is equal to CompareValue, then Value is set to + ExchangeValue and CompareValue is returned. If Value is not equal to + CompareValue, then Value is returned. The compare exchange operation must be + performed using MP safe mechanisms. + + If Value is NULL, then ASSERT(). + + @param Value A pointer to the pointer value for the compare exchange + operation. + @param CompareValue Pointer value used in compare operation. + @param ExchangeValue Pointer value used in exchange operation. + +**/ +VOID * +EFIAPI +InterlockedCompareExchangePointer ( + IN OUT VOLATILE VOID **Value, + IN VOID *CompareValue, + IN VOID *ExchangeValue + ) +{ + switch (sizeof (*Value)) { + case sizeof (UINT32): + return (VOID*)(UINTN)InterlockedCompareExchange32 ( + (UINT32*)Value, + (UINT32)(UINTN)CompareValue, + (UINT32)(UINTN)ExchangeValue + ); + case sizeof (UINT64): + return (VOID*)(UINTN)InterlockedCompareExchange64 ( + (UINT64*)Value, + (UINT64)(UINTN)CompareValue, + (UINT64)(UINTN)ExchangeValue + ); + default: + ASSERT (FALSE); + return NULL; + } +} diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Unaligned.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Unaligned.c new file mode 100644 index 0000000..42e7b69 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Unaligned.c @@ -0,0 +1,228 @@ +/*++ + +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: + + Unaligned.c + +Abstract: + + Unaligned access functions of BaseLib. + +--*/ + +#include "BaseLibInternal.h" + +/** + Reads a 16-bit value from memory that may be unaligned. + + This function returns the 16-bit value pointed to by Buffer. The function + guarantees that the read operation does not produce an alignment fault. + + If the Buffer is NULL, then ASSERT(). + + @param Buffer Pointer to a 16-bit value that may be unaligned. + + @return *Uint16 + +**/ +UINT16 +EFIAPI +ReadUnaligned16 ( + IN CONST UINT16 *Buffer + ) +{ + ASSERT (Buffer != NULL); + + return *Buffer; +} + +/** + Writes a 16-bit value to memory that may be unaligned. + + This function writes the 16-bit value specified by Value to Buffer. Value is + returned. The function guarantees that the write operation does not produce + an alignment fault. + + If the Buffer is NULL, then ASSERT(). + + @param Buffer Pointer to a 16-bit value that may be unaligned. + @param Value 16-bit value to write to Buffer. + + @return Value + +**/ +UINT16 +EFIAPI +WriteUnaligned16 ( + OUT UINT16 *Buffer, + IN UINT16 Value + ) +{ + ASSERT (Buffer != NULL); + + return *Buffer = Value; +} + +/** + Reads a 24-bit value from memory that may be unaligned. + + This function returns the 24-bit value pointed to by Buffer. The function + guarantees that the read operation does not produce an alignment fault. + + If the Buffer is NULL, then ASSERT(). + + @param Buffer Pointer to a 24-bit value that may be unaligned. + + @return The value read. + +**/ +UINT32 +EFIAPI +ReadUnaligned24 ( + IN CONST UINT32 *Buffer + ) +{ + ASSERT (Buffer != NULL); + + return *Buffer & 0xffffff; +} + +/** + Writes a 24-bit value to memory that may be unaligned. + + This function writes the 24-bit value specified by Value to Buffer. Value is + returned. The function guarantees that the write operation does not produce + an alignment fault. + + If the Buffer is NULL, then ASSERT(). + + @param Buffer Pointer to a 24-bit value that may be unaligned. + @param Value 24-bit value to write to Buffer. + + @return The value written. + +**/ +UINT32 +EFIAPI +WriteUnaligned24 ( + OUT UINT32 *Buffer, + IN UINT32 Value + ) +{ + ASSERT (Buffer != NULL); + + *Buffer = BitFieldWrite32 (*Buffer, 0, 23, Value); + return Value; +} + +/** + Reads a 32-bit value from memory that may be unaligned. + + This function returns the 32-bit value pointed to by Buffer. The function + guarantees that the read operation does not produce an alignment fault. + + If the Buffer is NULL, then ASSERT(). + + @param Buffer Pointer to a 32-bit value that may be unaligned. + + @return *Uint32 + +**/ +UINT32 +EFIAPI +ReadUnaligned32 ( + IN CONST UINT32 *Buffer + ) +{ + ASSERT (Buffer != NULL); + + return *Buffer; +} + +/** + Writes a 32-bit value to memory that may be unaligned. + + This function writes the 32-bit value specified by Value to Buffer. Value is + returned. The function guarantees that the write operation does not produce + an alignment fault. + + If the Buffer is NULL, then ASSERT(). + + @param Buffer Pointer to a 32-bit value that may be unaligned. + @param Value 32-bit value to write to Buffer. + + @return Value + +**/ +UINT32 +EFIAPI +WriteUnaligned32 ( + OUT UINT32 *Buffer, + IN UINT32 Value + ) +{ + ASSERT (Buffer != NULL); + + return *Buffer = Value; +} + +/** + Reads a 64-bit value from memory that may be unaligned. + + This function returns the 64-bit value pointed to by Buffer. The function + guarantees that the read operation does not produce an alignment fault. + + If the Buffer is NULL, then ASSERT(). + + @param Buffer Pointer to a 64-bit value that may be unaligned. + + @return *Uint64 + +**/ +UINT64 +EFIAPI +ReadUnaligned64 ( + IN CONST UINT64 *Buffer + ) +{ + ASSERT (Buffer != NULL); + + return *Buffer; +} + +/** + Writes a 64-bit value to memory that may be unaligned. + + This function writes the 64-bit value specified by Value to Buffer. Value is + returned. The function guarantees that the write operation does not produce + an alignment fault. + + If the Buffer is NULL, then ASSERT(). + + @param Buffer Pointer to a 64-bit value that may be unaligned. + @param Value 64-bit value to write to Buffer. + + @return Value + +**/ +UINT64 +EFIAPI +WriteUnaligned64 ( + OUT UINT64 *Buffer, + IN UINT64 Value + ) +{ + ASSERT (Buffer != NULL); + + return *Buffer = Value; +} diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/CpuBreakpoint.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/CpuBreakpoint.asm new file mode 100644 index 0000000..cd517d3 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/CpuBreakpoint.asm @@ -0,0 +1,36 @@ +; 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: +; +; CpuBreakpoint.Asm +; +; Abstract: +; +; CpuBreakpoint function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; VOID +; EFIAPI +; CpuBreakpoint ( +; VOID +; ); +;------------------------------------------------------------------------------ +CpuBreakpoint PROC + int 3 + ret +CpuBreakpoint ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/CpuFlushTlb.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/CpuFlushTlb.asm new file mode 100644 index 0000000..617c6ad --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/CpuFlushTlb.asm @@ -0,0 +1,37 @@ +; 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: +; +; CpuFlushTlb.Asm +; +; Abstract: +; +; CpuFlushTlb function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; VOID +; EFIAPI +; CpuFlushTlb ( +; VOID +; ); +;------------------------------------------------------------------------------ +CpuFlushTlb PROC + mov rax, cr3 + mov cr3, rax + ret +CpuFlushTlb ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/CpuId.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/CpuId.asm new file mode 100644 index 0000000..e46802c --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/CpuId.asm @@ -0,0 +1,60 @@ +; 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: +; +; CpuId.Asm +; +; Abstract: +; +; AsmCpuid function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; VOID +; EFIAPI +; AsmCpuid ( +; IN UINT32 RegisterInEax, +; OUT UINT32 *RegisterOutEax OPTIONAL, +; OUT UINT32 *RegisterOutEbx OPTIONAL, +; OUT UINT32 *RegisterOutEcx OPTIONAL, +; OUT UINT32 *RegisterOutEdx OPTIONAL +; ) +;------------------------------------------------------------------------------ +AsmCpuid PROC USES rbx + mov eax, ecx + push rax ; save Index on stack + push rdx + cpuid + test r9, r9 + jz @F + mov [r9], ecx +@@: + pop rcx + jrcxz @F + mov [rcx], eax +@@: + mov rcx, r8 + jrcxz @F + mov [rcx], ebx +@@: + mov rcx, [rsp + 38h] + jrcxz @F + mov [rcx], edx +@@: + pop rax ; restore Index to rax as return value + ret +AsmCpuid ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/CpuIdEx.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/CpuIdEx.asm new file mode 100644 index 0000000..c6fce10 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/CpuIdEx.asm @@ -0,0 +1,62 @@ +; 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: +; +; CpuIdEx.Asm +; +; Abstract: +; +; AsmCpuidEx function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; UINT32 +; EFIAPI +; AsmCpuidEx ( +; IN UINT32 RegisterInEax, +; IN UINT32 RegisterInEcx, +; OUT UINT32 *RegisterOutEax OPTIONAL, +; OUT UINT32 *RegisterOutEbx OPTIONAL, +; OUT UINT32 *RegisterOutEcx OPTIONAL, +; OUT UINT32 *RegisterOutEdx OPTIONAL +; ) +;------------------------------------------------------------------------------ +AsmCpuidEx PROC USES rbx + mov eax, ecx + mov ecx, edx + push rax ; save Index on stack + cpuid + mov r10, [rsp + 38h] + test r10, r10 + jz @F + mov [r10], ecx +@@: + mov rcx, r8 + jrcxz @F + mov [rcx], eax +@@: + mov rcx, r9 + jrcxz @F + mov [rcx], ebx +@@: + mov rcx, [rsp + 40h] + jrcxz @F + mov [rcx], edx +@@: + pop rax ; restore Index to rax as return value + ret +AsmCpuidEx ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/CpuPause.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/CpuPause.asm new file mode 100644 index 0000000..680d8ed --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/CpuPause.asm @@ -0,0 +1,36 @@ +; 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: +; +; CpuPause.Asm +; +; Abstract: +; +; CpuPause function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; VOID +; EFIAPI +; CpuPause ( +; VOID +; ); +;------------------------------------------------------------------------------ +CpuPause PROC + pause + ret +CpuPause ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/CpuSleep.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/CpuSleep.asm new file mode 100644 index 0000000..44457f1 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/CpuSleep.asm @@ -0,0 +1,36 @@ +; 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: +; +; CpuSleep.Asm +; +; Abstract: +; +; CpuSleep function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; VOID +; EFIAPI +; CpuSleep ( +; VOID +; ); +;------------------------------------------------------------------------------ +CpuSleep PROC + hlt + ret +CpuSleep ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/DisableInterrupts.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/DisableInterrupts.asm new file mode 100644 index 0000000..90b0c8e --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/DisableInterrupts.asm @@ -0,0 +1,36 @@ +; 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: +; +; DisableInterrupts.Asm +; +; Abstract: +; +; DisableInterrupts function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; VOID +; EFIAPI +; DisableInterrupts ( +; VOID +; ); +;------------------------------------------------------------------------------ +DisableInterrupts PROC + cli + ret +DisableInterrupts ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/DisablePaging64.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/DisablePaging64.asm new file mode 100644 index 0000000..3d86cc5 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/DisablePaging64.asm @@ -0,0 +1,64 @@ +; 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: +; +; DisablePaging64.Asm +; +; Abstract: +; +; AsmDisablePaging64 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; VOID +; EFIAPI +; InternalX86DisablePaging64 ( +; IN UINT16 Cs, +; IN UINT32 EntryPoint, +; IN UINT32 Context1, OPTIONAL +; IN UINT32 Context2, OPTIONAL +; IN UINT32 NewStack +; ); +;------------------------------------------------------------------------------ +InternalX86DisablePaging64 PROC + cli + shl rcx, 32 + lea eax, @F + mov ecx, eax + push rcx + mov ebx, edx + mov esi, r8d + mov edi, r9d + mov eax, [rsp + 28h] + retf +@@: + mov esp, eax ; set up new stack + mov rax, cr0 + btr eax, 31 + mov cr0, rax ; disable paging + mov ecx, 0c0000080h + rdmsr + and ah, NOT 1 ; clear LME + wrmsr + mov rax, cr4 + and al, NOT (1 SHL 5) ; clear PAE + mov cr4, rax + push rdi + push rsi + call rbx + jmp $ +InternalX86DisablePaging64 ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/EnableDisableInterrupts.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/EnableDisableInterrupts.asm new file mode 100644 index 0000000..3cd7f79 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/EnableDisableInterrupts.asm @@ -0,0 +1,37 @@ +; 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: +; +; EnableDisableInterrupts.Asm +; +; Abstract: +; +; EnableDisableInterrupts function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; VOID +; EFIAPI +; EnableDisableInterrupts ( +; VOID +; ); +;------------------------------------------------------------------------------ +EnableDisableInterrupts PROC + sti + cli + ret +EnableDisableInterrupts ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/EnableInterrupts.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/EnableInterrupts.asm new file mode 100644 index 0000000..a772947 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/EnableInterrupts.asm @@ -0,0 +1,36 @@ +; 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: +; +; EnableInterrupts.Asm +; +; Abstract: +; +; EnableInterrupts function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; VOID +; EFIAPI +; EnableInterrupts ( +; VOID +; ); +;------------------------------------------------------------------------------ +EnableInterrupts PROC + sti + ret +EnableInterrupts ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/EnablePaging64.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/EnablePaging64.asm new file mode 100644 index 0000000..97e90c9 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/EnablePaging64.asm @@ -0,0 +1,62 @@ +; 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: +; +; EnablePaging64.Asm +; +; Abstract: +; +; AsmEnablePaging64 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; VOID +; EFIAPI +; InternalX86EnablePaging64 ( +; IN UINT16 Cs, +; IN UINT64 EntryPoint, +; IN UINT64 Context1, OPTIONAL +; IN UINT64 Context2, OPTIONAL +; IN UINT64 NewStack +; ); +;------------------------------------------------------------------------------ +InternalX86EnablePaging64 PROC + cli + pop rax + call @Base +@Base: + add dword ptr [rsp], @F - @Base ; offset for far retf, seg is the 1st arg + mov rax, cr4 ; mov eax, cr4 + or al, (1 SHL 5) + mov cr4, rax ; enable PAE + mov ecx, 0c0000080h + rdmsr + or ah, 1 ; set LME + wrmsr + mov rax, cr0 ; mov eax, cr0 + bts eax, 31 + mov cr0, rax ; enable paging + retf +@@: ; long mode starts here + mov rbx, [esp] + mov rcx, [esp + 8] + mov rdx, [esp + 10h] + mov rsp, [esp + 18h] + add rsp, -20h + call rbx + jmp $ ; halt processor if EntryPoint() returned +InternalX86EnablePaging64 ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/FlushCacheLine.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/FlushCacheLine.asm new file mode 100644 index 0000000..5f0a1be --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/FlushCacheLine.asm @@ -0,0 +1,37 @@ +; 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: +; +; FlushCacheLine.Asm +; +; Abstract: +; +; AsmFlushCacheLine function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; VOID * +; EFIAPI +; AsmFlushCacheLine ( +; IN VOID *LinearAddress +; ); +;------------------------------------------------------------------------------ +AsmFlushCacheLine PROC + clflush [rcx] + mov rax, rcx + ret +AsmFlushCacheLine ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/FxRestore.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/FxRestore.asm new file mode 100644 index 0000000..b47184c --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/FxRestore.asm @@ -0,0 +1,36 @@ +; 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: +; +; FxRestore.Asm +; +; Abstract: +; +; AsmFxRestore function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; VOID +; EFIAPI +; InternalX86FxRestore ( +; IN CONST IA32_FX_BUFFER *Buffer +; ); +;------------------------------------------------------------------------------ +InternalX86FxRestore PROC + fxrstor [rcx] + ret +InternalX86FxRestore ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/FxSave.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/FxSave.asm new file mode 100644 index 0000000..e8fcd61 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/FxSave.asm @@ -0,0 +1,36 @@ +; 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: +; +; FxSave.Asm +; +; Abstract: +; +; AsmFxSave function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; VOID +; EFIAPI +; InternalX86FxSave ( +; OUT IA32_FX_BUFFER *Buffer +; ); +;------------------------------------------------------------------------------ +InternalX86FxSave PROC + fxsave [rcx] + ret +InternalX86FxSave ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/InterlockedCompareExchange32.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/InterlockedCompareExchange32.asm new file mode 100644 index 0000000..9450532 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/InterlockedCompareExchange32.asm @@ -0,0 +1,39 @@ +; 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: +; +; InterlockedCompareExchange32.Asm +; +; Abstract: +; +; InterlockedCompareExchange32 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; UINT32 +; EFIAPI +; InterlockedCompareExchange32 ( +; IN UINT32 *Value, +; IN UINT32 CompareValue, +; IN UINT32 ExchangeValue +; ); +;------------------------------------------------------------------------------ +InternalSyncCompareExchange32 PROC + mov eax, edx + lock cmpxchg [rcx], r8d + ret +InternalSyncCompareExchange32 ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/InterlockedCompareExchange64.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/InterlockedCompareExchange64.asm new file mode 100644 index 0000000..4391e41 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/InterlockedCompareExchange64.asm @@ -0,0 +1,39 @@ +; 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: +; +; InterlockedCompareExchange64.Asm +; +; Abstract: +; +; InterlockedCompareExchange64 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; UINT64 +; EFIAPI +; InterlockedCompareExchange64 ( +; IN UINT64 *Value, +; IN UINT64 CompareValue, +; IN UINT64 ExchangeValue +; ); +;------------------------------------------------------------------------------ +InternalSyncCompareExchange64 PROC + mov rax, rdx + lock cmpxchg [rcx], r8 + ret +InternalSyncCompareExchange64 ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/InterlockedDecrement.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/InterlockedDecrement.asm new file mode 100644 index 0000000..ffa1e58 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/InterlockedDecrement.asm @@ -0,0 +1,37 @@ +; 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: +; +; InterlockedDecrement.Asm +; +; Abstract: +; +; InterlockedDecrement function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; UINT32 +; EFIAPI +; InterlockedDecrement ( +; IN UINT32 *Value +; ); +;------------------------------------------------------------------------------ +InternalSyncDecrement PROC + lock dec dword ptr [rcx] + mov eax, [rcx] + ret +InternalSyncDecrement ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/InterlockedIncrement.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/InterlockedIncrement.asm new file mode 100644 index 0000000..8e49d8b --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/InterlockedIncrement.asm @@ -0,0 +1,37 @@ +; 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: +; +; InterlockedIncrement.Asm +; +; Abstract: +; +; InterlockedIncrement function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; UINT32 +; EFIAPI +; InterlockedIncrement ( +; IN UINT32 *Value +; ); +;------------------------------------------------------------------------------ +InternalSyncIncrement PROC + lock inc dword ptr [rcx] + mov eax, [rcx] + ret +InternalSyncIncrement ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/Invd.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/Invd.asm new file mode 100644 index 0000000..87775c7 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/Invd.asm @@ -0,0 +1,36 @@ +; 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: +; +; Invd.Asm +; +; Abstract: +; +; AsmInvd function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; VOID +; EFIAPI +; AsmInvd ( +; VOID +; ); +;------------------------------------------------------------------------------ +AsmInvd PROC + invd + ret +AsmInvd ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/LongJump.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/LongJump.asm new file mode 100644 index 0000000..e669aee --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/LongJump.asm @@ -0,0 +1,44 @@ +; 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: +; +; LongJump.Asm +; +; Abstract: +; +; Implementation of _LongJump() on x64. +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; VOID +; EFIAPI +; InternalLongJump ( +; IN BASE_LIBRARY_JUMP_BUFFER *JumpBuffer, +; IN UINTN Value +; ); +;------------------------------------------------------------------------------ +InternalLongJump PROC + mov rbx, [rcx] + mov rsp, [rcx + 8] + mov rbp, [rcx + 10h] + mov rdi, [rcx + 18h] + mov rsi, [rcx + 20h] + mov r12, [rcx + 28h] + mov r13, [rcx + 30h] + mov r14, [rcx + 38h] + mov r15, [rcx + 40h] + mov rax, rdx + jmp qword ptr [rcx + 48h] +InternalLongJump ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/Monitor.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/Monitor.asm new file mode 100644 index 0000000..88f7dbe --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/Monitor.asm @@ -0,0 +1,41 @@ +; 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: +; +; Monitor.Asm +; +; Abstract: +; +; AsmMonitor function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; UINT64 +; EFIAPI +; AsmMonitor ( +; IN UINTN Eax, +; IN UINTN Ecx, +; IN UINTN Edx +; ); +;------------------------------------------------------------------------------ +AsmMonitor PROC + mov eax, ecx + mov ecx, edx + mov edx, r8d + DB 0fh, 1, 0c8h + ret +AsmMonitor ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/Mwait.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/Mwait.asm new file mode 100644 index 0000000..ec66cf6 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/Mwait.asm @@ -0,0 +1,39 @@ +; 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: +; +; Mwait.Asm +; +; Abstract: +; +; AsmMwait function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; UINT64 +; EFIAPI +; AsmMwait ( +; IN UINTN Eax, +; IN UINTN Ecx +; ); +;------------------------------------------------------------------------------ +AsmMwait PROC + mov eax, ecx + mov ecx, edx + DB 0fh, 1, 0c9h + ret +AsmMwait ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/Non-existing.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/Non-existing.c new file mode 100644 index 0000000..b5c0acd --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/Non-existing.c @@ -0,0 +1,116 @@ +/*++ + +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: + + Non-existing.c + +Abstract: + + Non-existing BaseLib functions on x64 + +--*/ + +#include "..\BaseLibInternal.h" + +/** + Enables the 32-bit paging mode on the CPU. + + Enables the 32-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables + must be properly initialized prior to calling this service. This function + assumes the current execution mode is 32-bit protected mode. This function is + only available on IA-32. After the 32-bit paging mode is enabled, control is + transferred to the function specified by EntryPoint using the new stack + specified by NewStack and passing in the parameters specified by Context1 and + Context2. Context1 and Context2 are optional and may be NULL. The function + EntryPoint must never return. + + There are a number of constraints that must be followed before calling this + function: + 1) Interrupts must be disabled. + 2) The caller must be in 32-bit protected mode with flat descriptors. This + means all descriptors must have a base of 0 and a limit of 4GB. + 3) CR0 and CR4 must be compatible with 32-bit protected mode with flat + descriptors. + 4) CR3 must point to valid page tables that will be used once the transition + is complete, and those page tables must guarantee that the pages for this + function and the stack are identity mapped. + + @param EntryPoint A pointer to function to call with the new stack after + paging is enabled. + @param Context1 A pointer to the context to pass into the EntryPoint + function as the first parameter after paging is enabled. + @param Context2 A pointer to the context to pass into the EntryPoint + function as the second parameter after paging is enabled. + @param NewStack A pointer to the new stack to use for the EntryPoint + function after paging is enabled. + +**/ +VOID +EFIAPI +InternalX86EnablePaging32 ( + IN SWITCH_STACK_ENTRY_POINT EntryPoint, + IN VOID *Context1, OPTIONAL + IN VOID *Context2, OPTIONAL + IN VOID *NewStack + ) +{ + // + // This function cannot work on X64 platform + // + ASSERT (FALSE); +} + +/** + Disables the 32-bit paging mode on the CPU. + + Disables the 32-bit paging mode on the CPU and returns to 32-bit protected + mode. This function assumes the current execution mode is 32-paged protected + mode. This function is only available on IA-32. After the 32-bit paging mode + is disabled, control is transferred to the function specified by EntryPoint + using the new stack specified by NewStack and passing in the parameters + specified by Context1 and Context2. Context1 and Context2 are optional and + may be NULL. The function EntryPoint must never return. + + There are a number of constraints that must be followed before calling this + function: + 1) Interrupts must be disabled. + 2) The caller must be in 32-bit paged mode. + 3) CR0, CR3, and CR4 must be compatible with 32-bit paged mode. + 4) CR3 must point to valid page tables that guarantee that the pages for + this function and the stack are identity mapped. + + @param EntryPoint A pointer to function to call with the new stack after + paging is disabled. + @param Context1 A pointer to the context to pass into the EntryPoint + function as the first parameter after paging is disabled. + @param Context2 A pointer to the context to pass into the EntryPoint + function as the second parameter after paging is + disabled. + @param NewStack A pointer to the new stack to use for the EntryPoint + function after paging is disabled. + +**/ +VOID +EFIAPI +InternalX86DisablePaging32 ( + IN SWITCH_STACK_ENTRY_POINT EntryPoint, + IN VOID *Context1, OPTIONAL + IN VOID *Context2, OPTIONAL + IN VOID *NewStack + ) +{ + // + // This function cannot work on X64 platform + // + ASSERT (FALSE); +} diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadCr0.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadCr0.asm new file mode 100644 index 0000000..b25df23 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadCr0.asm @@ -0,0 +1,36 @@ +; 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: +; +; ReadCr0.Asm +; +; Abstract: +; +; AsmReadCr0 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; UINTN +; EFIAPI +; AsmReadCr0 ( +; VOID +; ); +;------------------------------------------------------------------------------ +AsmReadCr0 PROC + mov rax, cr0 + ret +AsmReadCr0 ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadCr2.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadCr2.asm new file mode 100644 index 0000000..3416ec6 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadCr2.asm @@ -0,0 +1,36 @@ +; 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: +; +; ReadCr2.Asm +; +; Abstract: +; +; AsmReadCr2 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; UINTN +; EFIAPI +; AsmReadCr2 ( +; VOID +; ); +;------------------------------------------------------------------------------ +AsmReadCr2 PROC + mov rax, cr2 + ret +AsmReadCr2 ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadCr3.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadCr3.asm new file mode 100644 index 0000000..c4130d9 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadCr3.asm @@ -0,0 +1,36 @@ +; 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: +; +; ReadCr3.Asm +; +; Abstract: +; +; AsmReadCr3 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; UINTN +; EFIAPI +; AsmReadCr3 ( +; VOID +; ); +;------------------------------------------------------------------------------ +AsmReadCr3 PROC + mov rax, cr3 + ret +AsmReadCr3 ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadCr4.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadCr4.asm new file mode 100644 index 0000000..a964adb --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadCr4.asm @@ -0,0 +1,36 @@ +; 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: +; +; ReadCr4.Asm +; +; Abstract: +; +; AsmReadCr4 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; UINTN +; EFIAPI +; AsmReadCr4 ( +; VOID +; ); +;------------------------------------------------------------------------------ +AsmReadCr4 PROC + mov rax, cr4 + ret +AsmReadCr4 ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadCs.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadCs.asm new file mode 100644 index 0000000..507209c --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadCs.asm @@ -0,0 +1,36 @@ +; 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: +; +; ReadCs.Asm +; +; Abstract: +; +; AsmReadCs function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; UINT16 +; EFIAPI +; AsmReadCs ( +; VOID +; ); +;------------------------------------------------------------------------------ +AsmReadCs PROC + mov eax, cs + ret +AsmReadCs ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadDr0.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadDr0.asm new file mode 100644 index 0000000..a9748fe --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadDr0.asm @@ -0,0 +1,36 @@ +; 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: +; +; ReadDr0.Asm +; +; Abstract: +; +; AsmReadDr0 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; UINTN +; EFIAPI +; AsmReadDr0 ( +; VOID +; ); +;------------------------------------------------------------------------------ +AsmReadDr0 PROC + mov rax, dr0 + ret +AsmReadDr0 ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadDr1.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadDr1.asm new file mode 100644 index 0000000..a3927b4 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadDr1.asm @@ -0,0 +1,36 @@ +; 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: +; +; ReadDr1.Asm +; +; Abstract: +; +; AsmReadDr1 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; UINTN +; EFIAPI +; AsmReadDr1 ( +; VOID +; ); +;------------------------------------------------------------------------------ +AsmReadDr1 PROC + mov rax, dr1 + ret +AsmReadDr1 ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadDr2.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadDr2.asm new file mode 100644 index 0000000..c71a00d --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadDr2.asm @@ -0,0 +1,36 @@ +; 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: +; +; ReadDr2.Asm +; +; Abstract: +; +; AsmReadDr2 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; UINTN +; EFIAPI +; AsmReadDr2 ( +; VOID +; ); +;------------------------------------------------------------------------------ +AsmReadDr2 PROC + mov rax, dr2 + ret +AsmReadDr2 ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadDr3.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadDr3.asm new file mode 100644 index 0000000..8e5a835 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadDr3.asm @@ -0,0 +1,36 @@ +; 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: +; +; ReadDr3.Asm +; +; Abstract: +; +; AsmReadDr3 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; UINTN +; EFIAPI +; AsmReadDr3 ( +; VOID +; ); +;------------------------------------------------------------------------------ +AsmReadDr3 PROC + mov rax, dr3 + ret +AsmReadDr3 ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadDr4.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadDr4.asm new file mode 100644 index 0000000..da2d793 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadDr4.asm @@ -0,0 +1,36 @@ +; 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: +; +; ReadDr4.Asm +; +; Abstract: +; +; AsmReadDr4 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; UINTN +; EFIAPI +; AsmReadDr4 ( +; VOID +; ); +;------------------------------------------------------------------------------ +AsmReadDr4 PROC + DB 0fh, 21h, 0e0h + ret +AsmReadDr4 ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadDr5.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadDr5.asm new file mode 100644 index 0000000..2c5cdbc --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadDr5.asm @@ -0,0 +1,36 @@ +; 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: +; +; ReadDr5.Asm +; +; Abstract: +; +; AsmReadDr5 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; UINTN +; EFIAPI +; AsmReadDr5 ( +; VOID +; ); +;------------------------------------------------------------------------------ +AsmReadDr5 PROC + DB 0fh, 21h, 0e8h + ret +AsmReadDr5 ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadDr6.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadDr6.asm new file mode 100644 index 0000000..5a6cdd3 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadDr6.asm @@ -0,0 +1,36 @@ +; 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: +; +; ReadDr6.Asm +; +; Abstract: +; +; AsmReadDr6 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; UINTN +; EFIAPI +; AsmReadDr6 ( +; VOID +; ); +;------------------------------------------------------------------------------ +AsmReadDr6 PROC + mov rax, dr6 + ret +AsmReadDr6 ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadDr7.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadDr7.asm new file mode 100644 index 0000000..a96a2a4 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadDr7.asm @@ -0,0 +1,36 @@ +; 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: +; +; ReadDr7.Asm +; +; Abstract: +; +; AsmReadDr7 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; UINTN +; EFIAPI +; AsmReadDr7 ( +; VOID +; ); +;------------------------------------------------------------------------------ +AsmReadDr7 PROC + mov rax, dr7 + ret +AsmReadDr7 ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadDs.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadDs.asm new file mode 100644 index 0000000..fe36b76 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadDs.asm @@ -0,0 +1,36 @@ +; 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: +; +; ReadDs.Asm +; +; Abstract: +; +; AsmReadDs function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; UINT16 +; EFIAPI +; AsmReadDs ( +; VOID +; ); +;------------------------------------------------------------------------------ +AsmReadDs PROC + mov eax, ds + ret +AsmReadDs ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadEflags.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadEflags.asm new file mode 100644 index 0000000..9a399e7 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadEflags.asm @@ -0,0 +1,37 @@ +; 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: +; +; ReadEflags.Asm +; +; Abstract: +; +; AsmReadEflags function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; UINTN +; EFIAPI +; AsmReadEflags ( +; VOID +; ); +;------------------------------------------------------------------------------ +AsmReadEflags PROC + pushfq + pop rax + ret +AsmReadEflags ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadEs.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadEs.asm new file mode 100644 index 0000000..4ba0c12 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadEs.asm @@ -0,0 +1,36 @@ +; 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: +; +; ReadEs.Asm +; +; Abstract: +; +; AsmReadEs function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; UINT16 +; EFIAPI +; AsmReadEs ( +; VOID +; ); +;------------------------------------------------------------------------------ +AsmReadEs PROC + mov eax, es + ret +AsmReadEs ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadFs.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadFs.asm new file mode 100644 index 0000000..7d0d5af --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadFs.asm @@ -0,0 +1,36 @@ +; 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: +; +; ReadFs.Asm +; +; Abstract: +; +; AsmReadFs function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; UINT16 +; EFIAPI +; AsmReadFs ( +; VOID +; ); +;------------------------------------------------------------------------------ +AsmReadFs PROC + mov eax, fs + ret +AsmReadFs ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadGdtr.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadGdtr.asm new file mode 100644 index 0000000..6c319fd --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadGdtr.asm @@ -0,0 +1,36 @@ +; 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: +; +; ReadGdtr.Asm +; +; Abstract: +; +; AsmReadGdtr function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; VOID +; EFIAPI +; InternalX86ReadGdtr ( +; OUT IA32_DESCRIPTOR *Gdtr +; ); +;------------------------------------------------------------------------------ +InternalX86ReadGdtr PROC + sgdt fword ptr [rcx] + ret +InternalX86ReadGdtr ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadGs.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadGs.asm new file mode 100644 index 0000000..321410d --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadGs.asm @@ -0,0 +1,36 @@ +; 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: +; +; ReadGs.Asm +; +; Abstract: +; +; AsmReadGs function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; UINT16 +; EFIAPI +; AsmReadGs ( +; VOID +; ); +;------------------------------------------------------------------------------ +AsmReadGs PROC + mov eax, gs + ret +AsmReadGs ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadIdtr.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadIdtr.asm new file mode 100644 index 0000000..325c97b --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadIdtr.asm @@ -0,0 +1,36 @@ +; 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: +; +; ReadIdtr.Asm +; +; Abstract: +; +; AsmReadIdtr function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; VOID +; EFIAPI +; InternalX86ReadIdtr ( +; OUT IA32_DESCRIPTOR *Idtr +; ); +;------------------------------------------------------------------------------ +InternalX86ReadIdtr PROC + sidt fword ptr [rcx] + ret +InternalX86ReadIdtr ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadLdtr.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadLdtr.asm new file mode 100644 index 0000000..8268e5c --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadLdtr.asm @@ -0,0 +1,36 @@ +; 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: +; +; ReadLdtr.Asm +; +; Abstract: +; +; AsmReadLdtr function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; UINT16 +; EFIAPI +; AsmReadLdtr ( +; VOID +; ); +;------------------------------------------------------------------------------ +AsmReadLdtr PROC + sldt eax + ret +AsmReadLdtr ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadMm0.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadMm0.asm new file mode 100644 index 0000000..31090d5 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadMm0.asm @@ -0,0 +1,36 @@ +; 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: +; +; ReadMm0.Asm +; +; Abstract: +; +; AsmReadMm0 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; UINT64 +; EFIAPI +; AsmReadMm0 ( +; VOID +; ); +;------------------------------------------------------------------------------ +AsmReadMm0 PROC + DB 48h, 0fh, 7eh, 0c0h + ret +AsmReadMm0 ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadMm1.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadMm1.asm new file mode 100644 index 0000000..d2a4f5f --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadMm1.asm @@ -0,0 +1,36 @@ +; 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: +; +; ReadMm1.Asm +; +; Abstract: +; +; AsmReadMm1 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; UINT64 +; EFIAPI +; AsmReadMm1 ( +; VOID +; ); +;------------------------------------------------------------------------------ +AsmReadMm1 PROC + DB 48h, 0fh, 7eh, 0c8h + ret +AsmReadMm1 ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadMm2.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadMm2.asm new file mode 100644 index 0000000..c6ac1d6 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadMm2.asm @@ -0,0 +1,36 @@ +; 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: +; +; ReadMm2.Asm +; +; Abstract: +; +; AsmReadMm2 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; UINT64 +; EFIAPI +; AsmReadMm2 ( +; VOID +; ); +;------------------------------------------------------------------------------ +AsmReadMm2 PROC + DB 48h, 0fh, 7eh, 0d0h + ret +AsmReadMm2 ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadMm3.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadMm3.asm new file mode 100644 index 0000000..2a3cd6e --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadMm3.asm @@ -0,0 +1,36 @@ +; 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: +; +; ReadMm3.Asm +; +; Abstract: +; +; AsmReadMm3 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; UINT64 +; EFIAPI +; AsmReadMm3 ( +; VOID +; ); +;------------------------------------------------------------------------------ +AsmReadMm3 PROC + DB 48h, 0fh, 7eh, 0d8h + ret +AsmReadMm3 ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadMm4.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadMm4.asm new file mode 100644 index 0000000..1b03ad1 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadMm4.asm @@ -0,0 +1,36 @@ +; 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: +; +; ReadMm4.Asm +; +; Abstract: +; +; AsmReadMm4 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; UINT64 +; EFIAPI +; AsmReadMm4 ( +; VOID +; ); +;------------------------------------------------------------------------------ +AsmReadMm4 PROC + DB 48h, 0fh, 7eh, 0e0h + ret +AsmReadMm4 ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadMm5.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadMm5.asm new file mode 100644 index 0000000..c7f9ecf --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadMm5.asm @@ -0,0 +1,36 @@ +; 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: +; +; ReadMm5.Asm +; +; Abstract: +; +; AsmReadMm5 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; UINT64 +; EFIAPI +; AsmReadMm5 ( +; VOID +; ); +;------------------------------------------------------------------------------ +AsmReadMm5 PROC + DB 48h, 0fh, 7eh, 0e8h + ret +AsmReadMm5 ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadMm6.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadMm6.asm new file mode 100644 index 0000000..19eaf0d --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadMm6.asm @@ -0,0 +1,36 @@ +; 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: +; +; ReadMm6.Asm +; +; Abstract: +; +; AsmReadMm6 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; UINT64 +; EFIAPI +; AsmReadMm6 ( +; VOID +; ); +;------------------------------------------------------------------------------ +AsmReadMm6 PROC + DB 48h, 0fh, 7eh, 0f0h + ret +AsmReadMm6 ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadMm7.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadMm7.asm new file mode 100644 index 0000000..595b829 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadMm7.asm @@ -0,0 +1,36 @@ +; 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: +; +; ReadMm7.Asm +; +; Abstract: +; +; AsmReadMm7 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; UINT64 +; EFIAPI +; AsmReadMm7 ( +; VOID +; ); +;------------------------------------------------------------------------------ +AsmReadMm7 PROC + DB 48h, 0fh, 7eh, 0f8h + ret +AsmReadMm7 ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadMsr64.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadMsr64.asm new file mode 100644 index 0000000..328c12e --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadMsr64.asm @@ -0,0 +1,38 @@ +; 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: +; +; ReadMsr64.Asm +; +; Abstract: +; +; AsmReadMsr64 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; UINT64 +; EFIAPI +; AsmReadMsr64 ( +; IN UINT32 Index +; ); +;------------------------------------------------------------------------------ +AsmReadMsr64 PROC + rdmsr ; edx & eax are zero extended + shl rdx, 20h + or rax, rdx + ret +AsmReadMsr64 ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadPmc.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadPmc.asm new file mode 100644 index 0000000..3e958dc --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadPmc.asm @@ -0,0 +1,38 @@ +; 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: +; +; ReadPmc.Asm +; +; Abstract: +; +; AsmReadPmc function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; UINT64 +; EFIAPI +; AsmReadPmc ( +; IN UINT32 PmcIndex +; ); +;------------------------------------------------------------------------------ +AsmReadPmc PROC + rdpmc + shl rdx, 20h + or rax, rdx + ret +AsmReadPmc ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadSs.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadSs.asm new file mode 100644 index 0000000..02d950d --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadSs.asm @@ -0,0 +1,36 @@ +; 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: +; +; ReadSs.Asm +; +; Abstract: +; +; AsmReadSs function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; UINT16 +; EFIAPI +; AsmReadSs ( +; VOID +; ); +;------------------------------------------------------------------------------ +AsmReadSs PROC + mov eax, ss + ret +AsmReadSs ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadTr.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadTr.asm new file mode 100644 index 0000000..ad17008 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadTr.asm @@ -0,0 +1,36 @@ +; 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: +; +; ReadTr.Asm +; +; Abstract: +; +; AsmReadTr function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; UINT16 +; EFIAPI +; AsmReadTr ( +; VOID +; ); +;------------------------------------------------------------------------------ +AsmReadTr PROC + str eax + ret +AsmReadTr ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadTsc.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadTsc.asm new file mode 100644 index 0000000..67329a9 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadTsc.asm @@ -0,0 +1,38 @@ +; 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: +; +; ReadTsc.Asm +; +; Abstract: +; +; AsmReadTsc function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; UINT64 +; EFIAPI +; AsmReadTsc ( +; VOID +; ); +;------------------------------------------------------------------------------ +AsmReadTsc PROC + rdtsc + shl rdx, 20h + or rax, rdx + ret +AsmReadTsc ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/SetJump.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/SetJump.asm new file mode 100644 index 0000000..78d238a --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/SetJump.asm @@ -0,0 +1,52 @@ +; 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: +; +; SetJump.Asm +; +; Abstract: +; +; Implementation of SetJump() on x64. +; +;------------------------------------------------------------------------------ + + .code + +EXTERNDEF InternalAssertJumpBuffer:PROC + +;------------------------------------------------------------------------------ +; UINTN +; EFIAPI +; SetJump ( +; OUT BASE_LIBRARY_JUMP_BUFFER *JumpBuffer +; ); +;------------------------------------------------------------------------------ +SetJump PROC + push rcx + add rsp, -20h + call InternalAssertJumpBuffer + add rsp, 20h + pop rcx + pop rdx + mov [rcx], rbx + mov [rcx + 8], rsp + mov [rcx + 10h], rbp + mov [rcx + 18h], rdi + mov [rcx + 20h], rsi + mov [rcx + 28h], r12 + mov [rcx + 30h], r13 + mov [rcx + 38h], r14 + mov [rcx + 40h], r15 + mov [rcx + 48h], rdx + xor rax, rax + jmp rdx +SetJump ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/SwitchStack.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/SwitchStack.asm new file mode 100644 index 0000000..dcfafe3 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/SwitchStack.asm @@ -0,0 +1,45 @@ +; 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: +; +; SwitchStack.Asm +; +; Abstract: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; Routine Description: +; +; Routine for switching stacks with 1 parameter +; +; Arguments: +; +; (rcx) EntryPoint - Entry point with new stack. +; (rdx) Context - Parameter for entry point. +; (r8) Context2 - Parameter2 for entry point. +; (r9) NewStack - Pointer to new stack. +; +; Returns: +; +; None +; +;------------------------------------------------------------------------------ +InternalSwitchStack PROC + mov rax, rcx + mov rcx, rdx + mov rdx, r8 + lea rsp, [r9 - 20h] + call rax +InternalSwitchStack ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/Thunk16.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/Thunk16.asm new file mode 100644 index 0000000..243c053 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/Thunk16.asm @@ -0,0 +1,251 @@ +; 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: +; +; Thunk.asm +; +; Abstract: +; +; Real mode thunk +; +;------------------------------------------------------------------------------ + +EXTERNDEF m16Start:BYTE +EXTERNDEF m16Size:WORD +EXTERNDEF mThunk16Attr:WORD +EXTERNDEF m16Gdt:WORD +EXTERNDEF m16GdtrBase:WORD +EXTERNDEF mTransition:WORD + +THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 EQU 2 +THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL EQU 4 + +IA32_REGS STRUC 4t +_EDI DD ? +_ESI DD ? +_EBP DD ? +_ESP DD ? +_EBX DD ? +_EDX DD ? +_ECX DD ? +_EAX DD ? +_DS DW ? +_ES DW ? +_FS DW ? +_GS DW ? +_EFLAGS DQ ? +_EIP DD ? +_CS DW ? +_SS DW ? +IA32_REGS ENDS + + .const + +m16Size DW InternalAsmThunk16 - m16Start +mThunk16Attr DW _ThunkAttr - m16Start +m16Gdt DW _NullSegDesc - m16Start +m16GdtrBase DW _16GdtrBase - m16Start +mTransition DW _EntryPoint - m16Start + + .code + +m16Start LABEL BYTE + +SavedGdt LABEL FWORD + DW ? + DQ ? + +;------------------------------------------------------------------------------ +; _BackFromUserCode() takes control in real mode after 'retf' has been executed +; by user code. It will be shadowed to somewhere in memory below 1MB. +;------------------------------------------------------------------------------ +_BackFromUserCode PROC + DB 16h ; push ss + DB 0eh ; push cs + DB 66h + call @Base ; push eip +@Base: + DB 66h + push 0 ; reserved high order 32 bits of EFlags + pushf ; pushfd actually + cli ; disable interrupts + push gs + push fs + DB 6 ; push es + DB 1eh ; push ds + DB 66h, 60h ; pushad + DB 66h, 0bah ; mov edx, imm32 +_ThunkAttr DD ? + test dl, THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 + jz @1 + mov eax, 15cd2401h ; mov ax, 2401h & int 15h + cli ; disable interrupts + jnc @2 +@1: + test dl, THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL + jz @2 + in al, 92h + or al, 2 + out 92h, al ; deactivate A20M# +@2: + xor ax, ax ; xor eax, eax + mov eax, ss + lea bp, [esp + sizeof (IA32_REGS)] + mov word ptr (IA32_REGS ptr [rsi - sizeof (IA32_REGS)])._ESP, bp + mov ebx, (IA32_REGS ptr [rsi - sizeof (IA32_REGS)])._EIP + shl ax, 4 ; shl eax, 4 + add bp, ax ; add ebp, eax + DB 66h, 0b8h ; mov eax, imm32 +SavedCr4 DD ? + mov cr4, rax + DB 66h, 2eh + lgdt fword ptr [rdi + (SavedGdt - @Base)] + DB 66h + mov ecx, 0c0000080h + rdmsr + or ah, 1 + wrmsr + DB 66h, 0b8h ; mov eax, imm32 +SavedCr0 DD ? + mov cr0, rax + DB 0b8h ; mov ax, imm16 +SavedSs DW ? + mov ss, eax + DB 66h, 0bch ; mov esp, imm32 +SavedEsp DD ? + DB 66h + retf ; return to protected mode +_BackFromUserCode ENDP + +_EntryPoint DD _ToUserCode - m16Start + DW 8h +_16Gdtr LABEL FWORD + DW GdtEnd - _NullSegDesc - 1 +_16GdtrBase DQ _NullSegDesc +_16Idtr FWORD (1 SHL 10) - 1 + +;------------------------------------------------------------------------------ +; _ToUserCode() takes control in real mode before passing control to user code. +; It will be shadowed to somewhere in memory below 1MB. +;------------------------------------------------------------------------------ +_ToUserCode PROC + mov edi, ss + mov ss, edx ; set new segment selectors + mov ds, edx + mov es, edx + mov fs, edx + mov gs, edx + DB 66h + mov ecx, 0c0000080h + mov cr0, rax ; real mode starts at next instruction + rdmsr + and ah, NOT 1 + wrmsr + mov cr4, rbp + mov ss, esi ; set up 16-bit stack segment + xchg sp, bx ; set up 16-bit stack pointer + DB 66h + call @Base ; push eip +@Base: + pop bp ; ebp <- address of @Base + push [esp + sizeof (IA32_REGS) + 2] + lea eax, [rsi + (@RealMode - @Base)] + push rax + retf +@RealMode: + DB 2eh ; cs: + mov [rsi + (SavedSs - @Base)], edi + DB 2eh ; cs: + mov [rsi + (SavedEsp - @Base)], bx + DB 66h, 2eh ; CS and operand size override + lidt fword ptr [rsi + (_16Idtr - @Base)] + DB 66h, 61h ; popad + DB 1fh ; pop ds + DB 07h ; pop es + pop fs + pop gs + popf ; popfd + lea sp, [esp + 4] ; skip high order 32 bits of EFlags + DB 66h + retf ; transfer control to user code +_ToUserCode ENDP + +_NullSegDesc DQ 0 +_16CsDesc LABEL QWORD + DW -1 + DW 0 + DB 0 + DB 9bh + DB 8fh ; 16-bit segment, 4GB limit + DB 0 +_16DsDesc LABEL QWORD + DW -1 + DW 0 + DB 0 + DB 93h + DB 8fh ; 16-bit segment, 4GB limit + DB 0 +GdtEnd LABEL QWORD + +;------------------------------------------------------------------------------ +; IA32_REGISTER_SET * +; EFIAPI +; InternalAsmThunk16 ( +; IN IA32_REGISTER_SET *RegisterSet, +; IN OUT VOID *Transition +; ); +;------------------------------------------------------------------------------ +InternalAsmThunk16 PROC USES rbp rbx rsi rdi + mov r10d, ds + mov r11d, es + push fs + push gs + mov rsi, rcx + movzx r8d, (IA32_REGS ptr [rsi])._SS + mov edi, (IA32_REGS ptr [rsi])._ESP + lea rdi, [edi - (sizeof (IA32_REGS) + 4)] + imul eax, r8d, 16 ; eax <- r8d(stack segment) * 16 + mov ebx, edi ; ebx <- stack for 16-bit code + push sizeof (IA32_REGS) / 4 + add edi, eax ; edi <- linear address of 16-bit stack + pop rcx + rep movsd ; copy RegSet + lea ecx, [rdx + (SavedCr4 - m16Start)] + mov eax, edx ; eax <- transition code address + and edx, 0fh + shl eax, 12 + lea edx, [rdx + (_BackFromUserCode - m16Start)] + mov ax, dx + stosd ; [edi] <- return address of user code + sgdt fword ptr [rcx + (SavedGdt - SavedCr4)] + sidt fword ptr [rsp + 38h] ; save IDT stack in argument space + mov rax, cr0 + mov [rcx + (SavedCr0 - SavedCr4)], eax + and eax, 7ffffffeh ; clear PE, PG bits + mov rbp, cr4 + mov [rcx], ebp ; save CR4 in SavedCr4 + and ebp, 300h ; clear all but PCE and OSFXSR bits + mov esi, r8d ; esi <- 16-bit stack segment + push 10h + pop rdx ; rdx <- selector for data segments + lgdt fword ptr [rcx + (_16Gdtr - SavedCr4)] + pushfq + call fword ptr [rcx + (_EntryPoint - SavedCr4)] + popfq + lidt fword ptr [rsp + 38h] ; restore protected mode IDTR + lea eax, [rbp - sizeof (IA32_REGS)] + pop gs + pop fs + mov es, r11d + mov ds, r10d + ret +InternalAsmThunk16 ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/Wbinvd.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/Wbinvd.asm new file mode 100644 index 0000000..0349ec7 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/Wbinvd.asm @@ -0,0 +1,36 @@ +; 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: +; +; Wbinvd.Asm +; +; Abstract: +; +; AsmWbinvd function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; VOID +; EFIAPI +; AsmWbinvd ( +; VOID +; ); +;------------------------------------------------------------------------------ +AsmWbinvd PROC + wbinvd + ret +AsmWbinvd ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteCr0.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteCr0.asm new file mode 100644 index 0000000..b321dd2 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteCr0.asm @@ -0,0 +1,37 @@ +; 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: +; +; WriteCr0.Asm +; +; Abstract: +; +; AsmWriteCr0 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; UINTN +; EFIAPI +; AsmWriteCr0 ( +; UINTN Cr0 +; ); +;------------------------------------------------------------------------------ +AsmWriteCr0 PROC + mov cr0, rcx + mov rax, rcx + ret +AsmWriteCr0 ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteCr2.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteCr2.asm new file mode 100644 index 0000000..7a44b69 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteCr2.asm @@ -0,0 +1,37 @@ +; 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: +; +; WriteCr2.Asm +; +; Abstract: +; +; AsmWriteCr2 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; UINTN +; EFIAPI +; AsmWriteCr2 ( +; UINTN Cr2 +; ); +;------------------------------------------------------------------------------ +AsmWriteCr2 PROC + mov cr2, rcx + mov rax, rcx + ret +AsmWriteCr2 ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteCr3.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteCr3.asm new file mode 100644 index 0000000..867eb3e --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteCr3.asm @@ -0,0 +1,37 @@ +; 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: +; +; WriteCr3.Asm +; +; Abstract: +; +; AsmWriteCr3 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; UINTN +; EFIAPI +; AsmWriteCr3 ( +; UINTN Cr3 +; ); +;------------------------------------------------------------------------------ +AsmWriteCr3 PROC + mov cr3, rcx + mov rax, rcx + ret +AsmWriteCr3 ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteCr4.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteCr4.asm new file mode 100644 index 0000000..765d8d1 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteCr4.asm @@ -0,0 +1,37 @@ +; 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: +; +; WriteCr4.Asm +; +; Abstract: +; +; AsmWriteCr4 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; UINTN +; EFIAPI +; AsmWriteCr4 ( +; UINTN Cr4 +; ); +;------------------------------------------------------------------------------ +AsmWriteCr4 PROC + mov cr4, rcx + mov rax, rcx + ret +AsmWriteCr4 ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteDr0.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteDr0.asm new file mode 100644 index 0000000..4762337 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteDr0.asm @@ -0,0 +1,37 @@ +; 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: +; +; WriteDr0.Asm +; +; Abstract: +; +; AsmWriteDr0 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; UINTN +; EFIAPI +; AsmWriteDr0 ( +; IN UINTN Value +; ); +;------------------------------------------------------------------------------ +AsmWriteDr0 PROC + mov dr0, rcx + mov rax, rcx + ret +AsmWriteDr0 ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteDr1.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteDr1.asm new file mode 100644 index 0000000..11c5b7f --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteDr1.asm @@ -0,0 +1,37 @@ +; 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: +; +; WriteDr1.Asm +; +; Abstract: +; +; AsmWriteDr1 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; UINTN +; EFIAPI +; AsmWriteDr1 ( +; IN UINTN Value +; ); +;------------------------------------------------------------------------------ +AsmWriteDr1 PROC + mov dr1, rcx + mov rax, rcx + ret +AsmWriteDr1 ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteDr2.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteDr2.asm new file mode 100644 index 0000000..42ecea9 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteDr2.asm @@ -0,0 +1,37 @@ +; 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: +; +; WriteDr2.Asm +; +; Abstract: +; +; AsmWriteDr2 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; UINTN +; EFIAPI +; AsmWriteDr2 ( +; IN UINTN Value +; ); +;------------------------------------------------------------------------------ +AsmWriteDr2 PROC + mov dr2, rcx + mov rax, rcx + ret +AsmWriteDr2 ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteDr3.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteDr3.asm new file mode 100644 index 0000000..c0bbead --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteDr3.asm @@ -0,0 +1,37 @@ +; 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: +; +; WriteDr3.Asm +; +; Abstract: +; +; AsmWriteDr3 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; UINTN +; EFIAPI +; AsmWriteDr3 ( +; IN UINTN Value +; ); +;------------------------------------------------------------------------------ +AsmWriteDr3 PROC + mov dr3, rcx + mov rax, rcx + ret +AsmWriteDr3 ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteDr4.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteDr4.asm new file mode 100644 index 0000000..adb4d2f --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteDr4.asm @@ -0,0 +1,37 @@ +; 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: +; +; WriteDr4.Asm +; +; Abstract: +; +; AsmWriteDr4 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; UINTN +; EFIAPI +; AsmWriteDr4 ( +; IN UINTN Value +; ); +;------------------------------------------------------------------------------ +AsmWriteDr4 PROC + DB 0fh, 23h, 0e1h + mov rax, rcx + ret +AsmWriteDr4 ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteDr5.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteDr5.asm new file mode 100644 index 0000000..dc15442 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteDr5.asm @@ -0,0 +1,37 @@ +; 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: +; +; WriteDr5.Asm +; +; Abstract: +; +; AsmWriteDr5 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; UINTN +; EFIAPI +; AsmWriteDr6 ( +; IN UINTN Value +; ); +;------------------------------------------------------------------------------ +AsmWriteDr5 PROC + DB 0fh, 23h, 0e9h + mov rax, rcx + ret +AsmWriteDr5 ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteDr6.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteDr6.asm new file mode 100644 index 0000000..7c94162 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteDr6.asm @@ -0,0 +1,37 @@ +; 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: +; +; WriteDr6.Asm +; +; Abstract: +; +; AsmWriteDr6 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; UINTN +; EFIAPI +; AsmWriteDr6 ( +; IN UINTN Value +; ); +;------------------------------------------------------------------------------ +AsmWriteDr6 PROC + mov dr6, rcx + mov rax, rcx + ret +AsmWriteDr6 ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteDr7.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteDr7.asm new file mode 100644 index 0000000..bf7a43f --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteDr7.asm @@ -0,0 +1,37 @@ +; 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: +; +; WriteDr7.Asm +; +; Abstract: +; +; AsmWriteDr7 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; UINTN +; EFIAPI +; AsmWriteDr7 ( +; IN UINTN Value +; ); +;------------------------------------------------------------------------------ +AsmWriteDr7 PROC + mov dr7, rcx + mov rax, rcx + ret +AsmWriteDr7 ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteGdtr.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteGdtr.asm new file mode 100644 index 0000000..b288963 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteGdtr.asm @@ -0,0 +1,36 @@ +; 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: +; +; WriteGdtr.Asm +; +; Abstract: +; +; AsmWriteGdtr function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; VOID +; EFIAPI +; InternalX86WriteGdtr ( +; IN CONST IA32_DESCRIPTOR *Idtr +; ); +;------------------------------------------------------------------------------ +InternalX86WriteGdtr PROC + lgdt fword ptr [rcx] + ret +InternalX86WriteGdtr ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteIdtr.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteIdtr.asm new file mode 100644 index 0000000..d2d9660 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteIdtr.asm @@ -0,0 +1,36 @@ +; 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: +; +; WriteIdtr.Asm +; +; Abstract: +; +; AsmWriteIdtr function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; VOID +; EFIAPI +; InternalX86WriteIdtr ( +; IN CONST IA32_DESCRIPTOR *Idtr +; ); +;------------------------------------------------------------------------------ +InternalX86WriteIdtr PROC + lidt fword ptr [rcx] + ret +InternalX86WriteIdtr ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteLdtr.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteLdtr.asm new file mode 100644 index 0000000..a026776 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteLdtr.asm @@ -0,0 +1,36 @@ +; 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: +; +; WriteLdtr.Asm +; +; Abstract: +; +; AsmWriteLdtr function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; VOID +; EFIAPI +; AsmWriteLdtr ( +; IN UINT16 Ldtr +; ); +;------------------------------------------------------------------------------ +AsmWriteLdtr PROC + lldt cx + ret +AsmWriteLdtr ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteMm0.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteMm0.asm new file mode 100644 index 0000000..c6adfbf --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteMm0.asm @@ -0,0 +1,36 @@ +; 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: +; +; WriteMm0.Asm +; +; Abstract: +; +; AsmWriteMm0 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; VOID +; EFIAPI +; AsmWriteMm0 ( +; IN UINT64 Value +; ); +;------------------------------------------------------------------------------ +AsmWriteMm0 PROC + DB 48h, 0fh, 6eh, 0c1h + ret +AsmWriteMm0 ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteMm1.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteMm1.asm new file mode 100644 index 0000000..b941ade --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteMm1.asm @@ -0,0 +1,36 @@ +; 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: +; +; WriteMm1.Asm +; +; Abstract: +; +; AsmWriteMm1 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; VOID +; EFIAPI +; AsmWriteMm1 ( +; IN UINT64 Value +; ); +;------------------------------------------------------------------------------ +AsmWriteMm1 PROC + DB 48h, 0fh, 6eh, 0c9h + ret +AsmWriteMm1 ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteMm2.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteMm2.asm new file mode 100644 index 0000000..218c625 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteMm2.asm @@ -0,0 +1,36 @@ +; 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: +; +; WriteMm2.Asm +; +; Abstract: +; +; AsmWriteMm2 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; VOID +; EFIAPI +; AsmWriteMm2 ( +; IN UINT64 Value +; ); +;------------------------------------------------------------------------------ +AsmWriteMm2 PROC + DB 48h, 0fh, 6eh, 0d1h + ret +AsmWriteMm2 ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteMm3.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteMm3.asm new file mode 100644 index 0000000..c374b9a --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteMm3.asm @@ -0,0 +1,36 @@ +; 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: +; +; WriteMm3.Asm +; +; Abstract: +; +; AsmWriteMm3 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; VOID +; EFIAPI +; AsmWriteMm3 ( +; IN UINT64 Value +; ); +;------------------------------------------------------------------------------ +AsmWriteMm3 PROC + DB 48h, 0fh, 6eh, 0d9h + ret +AsmWriteMm3 ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteMm4.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteMm4.asm new file mode 100644 index 0000000..a69193e --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteMm4.asm @@ -0,0 +1,36 @@ +; 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: +; +; WriteMm4.Asm +; +; Abstract: +; +; AsmWriteMm4 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; VOID +; EFIAPI +; AsmWriteMm4 ( +; IN UINT64 Value +; ); +;------------------------------------------------------------------------------ +AsmWriteMm4 PROC + DB 48h, 0fh, 6eh, 0e1h + ret +AsmWriteMm4 ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteMm5.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteMm5.asm new file mode 100644 index 0000000..6e50afc --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteMm5.asm @@ -0,0 +1,36 @@ +; 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: +; +; WriteMm5.Asm +; +; Abstract: +; +; AsmWriteMm5 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; VOID +; EFIAPI +; AsmWriteMm5 ( +; IN UINT64 Value +; ); +;------------------------------------------------------------------------------ +AsmWriteMm5 PROC + DB 48h, 0fh, 6eh, 0e9h + ret +AsmWriteMm5 ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteMm6.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteMm6.asm new file mode 100644 index 0000000..aed61e4 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteMm6.asm @@ -0,0 +1,36 @@ +; 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: +; +; WriteMm6.Asm +; +; Abstract: +; +; AsmWriteMm6 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; VOID +; EFIAPI +; AsmWriteMm6 ( +; IN UINT64 Value +; ); +;------------------------------------------------------------------------------ +AsmWriteMm6 PROC + DB 48h, 0fh, 6eh, 0f1h + ret +AsmWriteMm6 ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteMm7.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteMm7.asm new file mode 100644 index 0000000..ec42248 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteMm7.asm @@ -0,0 +1,36 @@ +; 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: +; +; WriteMm7.Asm +; +; Abstract: +; +; AsmWriteMm7 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; VOID +; EFIAPI +; AsmWriteMm7 ( +; IN UINT64 Value +; ); +;------------------------------------------------------------------------------ +AsmWriteMm7 PROC + DB 48h, 0fh, 6eh, 0f9h + ret +AsmWriteMm7 ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteMsr64.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteMsr64.asm new file mode 100644 index 0000000..a37caf5 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteMsr64.asm @@ -0,0 +1,39 @@ +; 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: +; +; WriteMsr64.Asm +; +; Abstract: +; +; AsmWriteMsr64 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; UINT64 +; EFIAPI +; AsmWriteMsr64 ( +; IN UINT32 Index, +; IN UINT64 Value +; ); +;------------------------------------------------------------------------------ +AsmWriteMsr64 PROC + mov rax, rdx + shr rdx, 20h + wrmsr + ret +AsmWriteMsr64 ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86DisablePaging32.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86DisablePaging32.c new file mode 100644 index 0000000..db4b66d --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86DisablePaging32.c @@ -0,0 +1,71 @@ +/*++ + +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: + + x86DisablePaging32.c + +Abstract: + + IA-32/x64 specific functions. + +--*/ + +#include "BaseLibInternal.h" + +/** + Disables the 32-bit paging mode on the CPU. + + Disables the 32-bit paging mode on the CPU and returns to 32-bit protected + mode. This function assumes the current execution mode is 32-paged protected + mode. This function is only available on IA-32. After the 32-bit paging mode + is disabled, control is transferred to the function specified by EntryPoint + using the new stack specified by NewStack and passing in the parameters + specified by Context1 and Context2. Context1 and Context2 are optional and + may be NULL. The function EntryPoint must never return. + + If the current execution mode is not 32-bit paged mode, then ASSERT(). + If EntryPoint is NULL, then ASSERT(). + If NewStack is NULL, then ASSERT(). + + There are a number of constraints that must be followed before calling this + function: + 1) Interrupts must be disabled. + 2) The caller must be in 32-bit paged mode. + 3) CR0, CR3, and CR4 must be compatible with 32-bit paged mode. + 4) CR3 must point to valid page tables that guarantee that the pages for + this function and the stack are identity mapped. + + @param EntryPoint A pointer to function to call with the new stack after + paging is disabled. + @param Context1 A pointer to the context to pass into the EntryPoint + function as the first parameter after paging is disabled. + @param Context2 A pointer to the context to pass into the EntryPoint + function as the second parameter after paging is + disabled. + @param NewStack A pointer to the new stack to use for the EntryPoint + function after paging is disabled. + +**/ +VOID +EFIAPI +AsmDisablePaging32 ( + IN SWITCH_STACK_ENTRY_POINT EntryPoint, + IN VOID *Context1, OPTIONAL + IN VOID *Context2, OPTIONAL + IN VOID *NewStack + ) +{ + ASSERT (EntryPoint != NULL); + ASSERT (NewStack != NULL); + InternalX86DisablePaging32 (EntryPoint, Context1, Context2, NewStack); +} diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86DisablePaging64.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86DisablePaging64.c new file mode 100644 index 0000000..d4bf650 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86DisablePaging64.c @@ -0,0 +1,68 @@ +/*++ + +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: + + x86DisablePaging64.c + +Abstract: + + IA-32/x64 specific functions. + +--*/ + +#include "BaseLibInternal.h" + +/** + Disables the 64-bit paging mode on the CPU. + + Disables the 64-bit paging mode on the CPU and returns to 32-bit protected + mode. This function assumes the current execution mode is 64-paging mode. + This function is only available on X64. After the 64-bit paging mode is + disabled, control is transferred to the function specified by EntryPoint + using the new stack specified by NewStack and passing in the parameters + specified by Context1 and Context2. Context1 and Context2 are optional and + may be 0. The function EntryPoint must never return. + + If the current execution mode is not 64-bit paged mode, then ASSERT(). + If EntryPoint is 0, then ASSERT(). + If NewStack is 0, then ASSERT(). + + @param Cs The 16-bit selector to load in the CS before EntryPoint + is called. The descriptor in the GDT that this selector + references must be setup for 32-bit protected mode. + @param EntryPoint The 64-bit virtual address of the function to call with + the new stack after paging is disabled. + @param Context1 The 64-bit virtual address of the context to pass into + the EntryPoint function as the first parameter after + paging is disabled. + @param Context2 The 64-bit virtual address of the context to pass into + the EntryPoint function as the second parameter after + paging is disabled. + @param NewStack The 64-bit virtual address of the new stack to use for + the EntryPoint function after paging is disabled. + +**/ +VOID +EFIAPI +AsmDisablePaging64 ( + IN UINT16 Cs, + IN UINT32 EntryPoint, + IN UINT32 Context1, OPTIONAL + IN UINT32 Context2, OPTIONAL + IN UINT32 NewStack + ) +{ + ASSERT (EntryPoint != 0); + ASSERT (NewStack != 0); + InternalX86DisablePaging64 (Cs, EntryPoint, Context1, Context2, NewStack); +} diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86EnablePaging32.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86EnablePaging32.c new file mode 100644 index 0000000..44b0ee4 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86EnablePaging32.c @@ -0,0 +1,74 @@ +/*++ + +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: + + x86EnablePaging32.c + +Abstract: + + IA-32/x64 specific functions. + +--*/ + +#include "BaseLibInternal.h" + +/** + Enables the 32-bit paging mode on the CPU. + + Enables the 32-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables + must be properly initialized prior to calling this service. This function + assumes the current execution mode is 32-bit protected mode. This function is + only available on IA-32. After the 32-bit paging mode is enabled, control is + transferred to the function specified by EntryPoint using the new stack + specified by NewStack and passing in the parameters specified by Context1 and + Context2. Context1 and Context2 are optional and may be NULL. The function + EntryPoint must never return. + + If the current execution mode is not 32-bit protected mode, then ASSERT(). + If EntryPoint is NULL, then ASSERT(). + If NewStack is NULL, then ASSERT(). + + There are a number of constraints that must be followed before calling this + function: + 1) Interrupts must be disabled. + 2) The caller must be in 32-bit protected mode with flat descriptors. This + means all descriptors must have a base of 0 and a limit of 4GB. + 3) CR0 and CR4 must be compatible with 32-bit protected mode with flat + descriptors. + 4) CR3 must point to valid page tables that will be used once the transition + is complete, and those page tables must guarantee that the pages for this + function and the stack are identity mapped. + + @param EntryPoint A pointer to function to call with the new stack after + paging is enabled. + @param Context1 A pointer to the context to pass into the EntryPoint + function as the first parameter after paging is enabled. + @param Context2 A pointer to the context to pass into the EntryPoint + function as the second parameter after paging is enabled. + @param NewStack A pointer to the new stack to use for the EntryPoint + function after paging is enabled. + +**/ +VOID +EFIAPI +AsmEnablePaging32 ( + IN SWITCH_STACK_ENTRY_POINT EntryPoint, + IN VOID *Context1, OPTIONAL + IN VOID *Context2, OPTIONAL + IN VOID *NewStack + ) +{ + ASSERT (EntryPoint != NULL); + ASSERT (NewStack != NULL); + InternalX86EnablePaging32 (EntryPoint, Context1, Context2, NewStack); +} diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86EnablePaging64.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86EnablePaging64.c new file mode 100644 index 0000000..c9388db --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86EnablePaging64.c @@ -0,0 +1,70 @@ +/*++ + +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: + + x86EnablePaging64.c + +Abstract: + + IA-32/x64 specific functions. + +--*/ + +#include "BaseLibInternal.h" + +/** + Enables the 64-bit paging mode on the CPU. + + Enables the 64-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables + must be properly initialized prior to calling this service. This function + assumes the current execution mode is 32-bit protected mode with flat + descriptors. This function is only available on IA-32. After the 64-bit + paging mode is enabled, control is transferred to the function specified by + EntryPoint using the new stack specified by NewStack and passing in the + parameters specified by Context1 and Context2. Context1 and Context2 are + optional and may be 0. The function EntryPoint must never return. + + If the current execution mode is not 32-bit protected mode with flat + descriptors, then ASSERT(). + If EntryPoint is 0, then ASSERT(). + If NewStack is 0, then ASSERT(). + + @param Cs The 16-bit selector to load in the CS before EntryPoint + is called. The descriptor in the GDT that this selector + references must be setup for long mode. + @param EntryPoint The 64-bit virtual address of the function to call with + the new stack after paging is enabled. + @param Context1 The 64-bit virtual address of the context to pass into + the EntryPoint function as the first parameter after + paging is enabled. + @param Context2 The 64-bit virtual address of the context to pass into + the EntryPoint function as the second parameter after + paging is enabled. + @param NewStack The 64-bit virtual address of the new stack to use for + the EntryPoint function after paging is enabled. + +**/ +VOID +EFIAPI +AsmEnablePaging64 ( + IN UINT16 Cs, + IN UINT64 EntryPoint, + IN UINT64 Context1, OPTIONAL + IN UINT64 Context2, OPTIONAL + IN UINT64 NewStack + ) +{ + ASSERT (EntryPoint != 0); + ASSERT (NewStack != 0); + InternalX86EnablePaging64 (Cs, EntryPoint, Context1, Context2, NewStack); +} diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86FxRestore.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86FxRestore.c new file mode 100644 index 0000000..3a9cd16 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86FxRestore.c @@ -0,0 +1,54 @@ +/*++ + +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: + + x86FxRestore.c + +Abstract: + + IA-32/x64 specific functions. + +--*/ + +#include "BaseLibInternal.h" + +/** + Restores the current floating point/SSE/SSE2 context from a buffer. + + Restores the current floating point/SSE/SSE2 state from the buffer specified + by Buffer. Buffer must be aligned on a 16-byte boundary. This function is + only available on IA-32 and X64. + + If Buffer is NULL, then ASSERT(). + If Buffer is not aligned on a 16-byte boundary, then ASSERT(). + If Buffer was not saved with AsmFxSave(), then ASSERT(). + + @param Buffer Pointer to a buffer to save the floating point/SSE/SSE2 context. + +**/ +VOID +EFIAPI +AsmFxRestore ( + IN CONST IA32_FX_BUFFER *Buffer + ) +{ + ASSERT (Buffer != NULL); + ASSERT (((UINTN)Buffer & 0xf) == 0); + + // + // Check the flag recorded by AsmFxSave() + // + ASSERT (*(UINT32 *) (&Buffer[sizeof (IA32_FX_BUFFER) - 4]) == 0xAA5555AA); + + InternalX86FxRestore (Buffer); +} diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86FxSave.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86FxSave.c new file mode 100644 index 0000000..4622ede --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86FxSave.c @@ -0,0 +1,53 @@ +/*++ + +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: + + x86FxSave.c + +Abstract: + + IA-32/x64 specific functions. + +--*/ + +#include "BaseLibInternal.h" + +/** + Save the current floating point/SSE/SSE2 context to a buffer. + + Saves the current floating point/SSE/SSE2 state to the buffer specified by + Buffer. Buffer must be aligned on a 16-byte boundary. This function is only + available on IA-32 and X64. + + If Buffer is NULL, then ASSERT(). + If Buffer is not aligned on a 16-byte boundary, then ASSERT(). + + @param Buffer Pointer to a buffer to save the floating point/SSE/SSE2 context. + +**/ +VOID +EFIAPI +AsmFxSave ( + OUT IA32_FX_BUFFER *Buffer + ) +{ + ASSERT (Buffer != NULL); + ASSERT (((UINTN)Buffer & 0xf) == 0); + + InternalX86FxSave (Buffer); + + // + // Mark one flag at end of Buffer, it will be check by AsmFxRestor() + // + *(UINT32 *) (&Buffer[sizeof (IA32_FX_BUFFER) - 4]) = 0xAA5555AA; +} diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86GetInterruptState.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86GetInterruptState.c new file mode 100644 index 0000000..328c9a9 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86GetInterruptState.c @@ -0,0 +1,47 @@ +/*++ + +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: + + x86GetInterruptState.c + +Abstract: + + IA-32/x64 specific functions. + +--*/ + +#include "BaseLibInternal.h" + +/** + Retrieves the current CPU interrupt state. + + Retrieves the current CPU interrupt state. Returns TRUE is interrupts are + currently enabled. Otherwise returns FALSE. + + @retval TRUE CPU interrupts are enabled. + @retval FALSE CPU interrupts are disabled. + +**/ +BOOLEAN +EFIAPI +GlueGetInterruptState ( + VOID + ) +{ + IA32_EFLAGS32 EFlags; + + EFlags.UintN = AsmReadEflags (); + return (BOOLEAN)(EFlags.Bits.IF == 1); +} + + diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86MemoryFence.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86MemoryFence.c new file mode 100644 index 0000000..1112f41 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86MemoryFence.c @@ -0,0 +1,39 @@ +/*++ + +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: + + x86MemoryFence.c + +Abstract: + + IA-32/x64 specific functions. + +--*/ + +#include "BaseLibInternal.h" + +/** + Used to serialize load and store operations. + + All loads and stores that proceed calls to this function are guaranteed to be + globally visible when this function returns. + +**/ +VOID +EFIAPI +MemoryFence ( + VOID + ) +{ + return; +} diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86Msr.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86Msr.c new file mode 100644 index 0000000..e22489b --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86Msr.c @@ -0,0 +1,657 @@ +/*++ + +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: + + x86Msr.c + +Abstract: + + IA-32/x64 specific functions. + +--*/ + +#include "BaseLibInternal.h" + +/** + Returns the lower 32-bits of a Machine Specific Register(MSR). + + Reads and returns the lower 32-bits of the MSR specified by Index. + No parameter checking is performed on Index, and some Index values may cause + CPU exceptions. The caller must either guarantee that Index is valid, or the + caller must set up exception handlers to catch the exceptions. This function + is only available on IA-32 and X64. + + @param Index The 32-bit MSR index to read. + + @return The lower 32 bits of the MSR identified by Index. + +**/ +UINT32 +EFIAPI +AsmReadMsr32 ( + IN UINT32 Index + ) +{ + return (UINT32)AsmReadMsr64 (Index); +} + +/** + Zero-extend a 32-bit value and writes it to a Machine Specific Register(MSR). + + Writes the 32-bit value specified by Value to the MSR specified by Index. The + upper 32-bits of the MSR write are set to zero. The 32-bit value written to + the MSR is returned. No parameter checking is performed on Index or Value, + and some of these may cause CPU exceptions. The caller must either guarantee + that Index and Value are valid, or the caller must establish proper exception + handlers. This function is only available on IA-32 and X64. + + @param Index The 32-bit MSR index to write. + @param Value The 32-bit value to write to the MSR. + + @return Value + +**/ +UINT32 +EFIAPI +AsmWriteMsr32 ( + IN UINT32 Index, + IN UINT32 Value + ) +{ + return (UINT32)AsmWriteMsr64 (Index, Value); +} + +/** + Reads a 64-bit MSR, performs a bitwise inclusive OR on the lower 32-bits, and + writes the result back to the 64-bit MSR. + + Reads the 64-bit MSR specified by Index, performs a bitwise inclusive OR + between the lower 32-bits of the read result and the value specified by + OrData, and writes the result to the 64-bit MSR specified by Index. The lower + 32-bits of the value written to the MSR is returned. No parameter checking is + performed on Index or OrData, and some of these may cause CPU exceptions. The + caller must either guarantee that Index and OrData are valid, or the caller + must establish proper exception handlers. This function is only available on + IA-32 and X64. + + @param Index The 32-bit MSR index to write. + @param OrData The value to OR with the read value from the MSR. + + @return The lower 32-bit value written to the MSR. + +**/ +UINT32 +EFIAPI +AsmMsrOr32 ( + IN UINT32 Index, + IN UINT32 OrData + ) +{ + return (UINT32)AsmMsrOr64 (Index, OrData); +} + +/** + Reads a 64-bit MSR, performs a bitwise AND on the lower 32-bits, and writes + the result back to the 64-bit MSR. + + Reads the 64-bit MSR specified by Index, performs a bitwise AND between the + lower 32-bits of the read result and the value specified by AndData, and + writes the result to the 64-bit MSR specified by Index. The lower 32-bits of + the value written to the MSR is returned. No parameter checking is performed + on Index or AndData, and some of these may cause CPU exceptions. The caller + must either guarantee that Index and AndData are valid, or the caller must + establish proper exception handlers. This function is only available on IA-32 + and X64. + + @param Index The 32-bit MSR index to write. + @param AndData The value to AND with the read value from the MSR. + + @return The lower 32-bit value written to the MSR. + +**/ +UINT32 +EFIAPI +AsmMsrAnd32 ( + IN UINT32 Index, + IN UINT32 AndData + ) +{ + return (UINT32)AsmMsrAnd64 (Index, AndData); +} + +/** + Reads a 64-bit MSR, performs a bitwise AND followed by a bitwise inclusive OR + on the lower 32-bits, and writes the result back to the 64-bit MSR. + + Reads the 64-bit MSR specified by Index, performs a bitwise AND between the + lower 32-bits of the read result and the value specified by AndData + preserving the upper 32-bits, performs a bitwise inclusive OR between the + result of the AND operation and the value specified by OrData, and writes the + result to the 64-bit MSR specified by Address. The lower 32-bits of the value + written to the MSR is returned. No parameter checking is performed on Index, + AndData, or OrData, and some of these may cause CPU exceptions. The caller + must either guarantee that Index, AndData, and OrData are valid, or the + caller must establish proper exception handlers. This function is only + available on IA-32 and X64. + + @param Index The 32-bit MSR index to write. + @param AndData The value to AND with the read value from the MSR. + @param OrData The value to OR with the result of the AND operation. + + @return The lower 32-bit value written to the MSR. + +**/ +UINT32 +EFIAPI +AsmMsrAndThenOr32 ( + IN UINT32 Index, + IN UINT32 AndData, + IN UINT32 OrData + ) +{ + return (UINT32)AsmMsrAndThenOr64 (Index, AndData, OrData); +} + +/** + Reads a bit field of an MSR. + + Reads the bit field in the lower 32-bits of a 64-bit MSR. The bit field is + specified by the StartBit and the EndBit. The value of the bit field is + returned. The caller must either guarantee that Index is valid, or the caller + must set up exception handlers to catch the exceptions. This function is only + available on IA-32 and X64. + + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Index The 32-bit MSR index to read. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + + @return The bit field read from the MSR. + +**/ +UINT32 +EFIAPI +AsmMsrBitFieldRead32 ( + IN UINT32 Index, + IN UINTN StartBit, + IN UINTN EndBit + ) +{ + return BitFieldRead32 (AsmReadMsr32 (Index), StartBit, EndBit); +} + +/** + Writes a bit field to an MSR. + + Writes Value to a bit field in the lower 32-bits of a 64-bit MSR. The bit + field is specified by the StartBit and the EndBit. All other bits in the + destination MSR are preserved. The lower 32-bits of the MSR written is + returned. Extra left bits in Value are stripped. The caller must either + guarantee that Index and the data written is valid, or the caller must set up + exception handlers to catch the exceptions. This function is only available + on IA-32 and X64. + + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Index The 32-bit MSR index to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + @param Value New value of the bit field. + + @return The lower 32-bit of the value written to the MSR. + +**/ +UINT32 +EFIAPI +AsmMsrBitFieldWrite32 ( + IN UINT32 Index, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT32 Value + ) +{ + ASSERT (EndBit < sizeof (Value) * 8); + ASSERT (StartBit <= EndBit); + return (UINT32)AsmMsrBitFieldWrite64 (Index, StartBit, EndBit, Value); +} + +/** + Reads a bit field in a 64-bit MSR, performs a bitwise OR, and writes the + result back to the bit field in the 64-bit MSR. + + Reads the 64-bit MSR specified by Index, performs a bitwise inclusive OR + between the read result and the value specified by OrData, and writes the + result to the 64-bit MSR specified by Index. The lower 32-bits of the value + written to the MSR are returned. Extra left bits in OrData are stripped. The + caller must either guarantee that Index and the data written is valid, or + the caller must set up exception handlers to catch the exceptions. This + function is only available on IA-32 and X64. + + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Index The 32-bit MSR index to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + @param OrData The value to OR with the read value from the MSR. + + @return The lower 32-bit of the value written to the MSR. + +**/ +UINT32 +EFIAPI +AsmMsrBitFieldOr32 ( + IN UINT32 Index, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT32 OrData + ) +{ + ASSERT (EndBit < sizeof (OrData) * 8); + ASSERT (StartBit <= EndBit); + return (UINT32)AsmMsrBitFieldOr64 (Index, StartBit, EndBit, OrData); +} + +/** + Reads a bit field in a 64-bit MSR, performs a bitwise AND, and writes the + result back to the bit field in the 64-bit MSR. + + Reads the 64-bit MSR specified by Index, performs a bitwise AND between the + read result and the value specified by AndData, and writes the result to the + 64-bit MSR specified by Index. The lower 32-bits of the value written to the + MSR are returned. Extra left bits in AndData are stripped. The caller must + either guarantee that Index and the data written is valid, or the caller must + set up exception handlers to catch the exceptions. This function is only + available on IA-32 and X64. + + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Index The 32-bit MSR index to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + @param AndData The value to AND with the read value from the MSR. + + @return The lower 32-bit of the value written to the MSR. + +**/ +UINT32 +EFIAPI +AsmMsrBitFieldAnd32 ( + IN UINT32 Index, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT32 AndData + ) +{ + ASSERT (EndBit < sizeof (AndData) * 8); + ASSERT (StartBit <= EndBit); + return (UINT32)AsmMsrBitFieldAnd64 (Index, StartBit, EndBit, AndData); +} + +/** + Reads a bit field in a 64-bit MSR, performs a bitwise AND followed by a + bitwise inclusive OR, and writes the result back to the bit field in the + 64-bit MSR. + + Reads the 64-bit MSR specified by Index, performs a bitwise AND followed by a + bitwise inclusive OR between the read result and the value specified by + AndData, and writes the result to the 64-bit MSR specified by Index. The + lower 32-bits of the value written to the MSR are returned. Extra left bits + in both AndData and OrData are stripped. The caller must either guarantee + that Index and the data written is valid, or the caller must set up exception + handlers to catch the exceptions. This function is only available on IA-32 + and X64. + + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Index The 32-bit MSR index to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + @param AndData The value to AND with the read value from the MSR. + @param OrData The value to OR with the result of the AND operation. + + @return The lower 32-bit of the value written to the MSR. + +**/ +UINT32 +EFIAPI +AsmMsrBitFieldAndThenOr32 ( + IN UINT32 Index, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT32 AndData, + IN UINT32 OrData + ) +{ + ASSERT (EndBit < sizeof (AndData) * 8); + ASSERT (StartBit <= EndBit); + return (UINT32)AsmMsrBitFieldAndThenOr64 ( + Index, + StartBit, + EndBit, + AndData, + OrData + ); +} + +/** + Reads a 64-bit MSR, performs a bitwise inclusive OR, and writes the result + back to the 64-bit MSR. + + Reads the 64-bit MSR specified by Index, performs a bitwise inclusive OR + between the read result and the value specified by OrData, and writes the + result to the 64-bit MSR specified by Index. The value written to the MSR is + returned. No parameter checking is performed on Index or OrData, and some of + these may cause CPU exceptions. The caller must either guarantee that Index + and OrData are valid, or the caller must establish proper exception handlers. + This function is only available on IA-32 and X64. + + @param Index The 32-bit MSR index to write. + @param OrData The value to OR with the read value from the MSR. + + @return The value written back to the MSR. + +**/ +UINT64 +EFIAPI +AsmMsrOr64 ( + IN UINT32 Index, + IN UINT64 OrData + ) +{ + return AsmWriteMsr64 (Index, AsmReadMsr64 (Index) | OrData); +} + +/** + Reads a 64-bit MSR, performs a bitwise AND, and writes the result back to the + 64-bit MSR. + + Reads the 64-bit MSR specified by Index, performs a bitwise AND between the + read result and the value specified by OrData, and writes the result to the + 64-bit MSR specified by Index. The value written to the MSR is returned. No + parameter checking is performed on Index or OrData, and some of these may + cause CPU exceptions. The caller must either guarantee that Index and OrData + are valid, or the caller must establish proper exception handlers. This + function is only available on IA-32 and X64. + + @param Index The 32-bit MSR index to write. + @param AndData The value to AND with the read value from the MSR. + + @return The value written back to the MSR. + +**/ +UINT64 +EFIAPI +AsmMsrAnd64 ( + IN UINT32 Index, + IN UINT64 AndData + ) +{ + return AsmWriteMsr64 (Index, AsmReadMsr64 (Index) & AndData); +} + +/** + Reads a 64-bit MSR, performs a bitwise AND followed by a bitwise inclusive + OR, and writes the result back to the 64-bit MSR. + + Reads the 64-bit MSR specified by Index, performs a bitwise AND between read + result and the value specified by AndData, performs a bitwise inclusive OR + between the result of the AND operation and the value specified by OrData, + and writes the result to the 64-bit MSR specified by Index. The value written + to the MSR is returned. No parameter checking is performed on Index, AndData, + or OrData, and some of these may cause CPU exceptions. The caller must either + guarantee that Index, AndData, and OrData are valid, or the caller must + establish proper exception handlers. This function is only available on IA-32 + and X64. + + @param Index The 32-bit MSR index to write. + @param AndData The value to AND with the read value from the MSR. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the MSR. + +**/ +UINT64 +EFIAPI +AsmMsrAndThenOr64 ( + IN UINT32 Index, + IN UINT64 AndData, + IN UINT64 OrData + ) +{ + return AsmWriteMsr64 (Index, (AsmReadMsr64 (Index) & AndData) | OrData); +} + +/** + Reads a bit field of an MSR. + + Reads the bit field in the 64-bit MSR. The bit field is specified by the + StartBit and the EndBit. The value of the bit field is returned. The caller + must either guarantee that Index is valid, or the caller must set up + exception handlers to catch the exceptions. This function is only available + on IA-32 and X64. + + If StartBit is greater than 63, then ASSERT(). + If EndBit is greater than 63, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Index The 32-bit MSR index to read. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..63. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..63. + + @return The value written back to the MSR. + +**/ +UINT64 +EFIAPI +AsmMsrBitFieldRead64 ( + IN UINT32 Index, + IN UINTN StartBit, + IN UINTN EndBit + ) +{ + return BitFieldRead64 (AsmReadMsr64 (Index), StartBit, EndBit); +} + +/** + Writes a bit field to an MSR. + + Writes Value to a bit field in a 64-bit MSR. The bit field is specified by + the StartBit and the EndBit. All other bits in the destination MSR are + preserved. The MSR written is returned. Extra left bits in Value are + stripped. The caller must either guarantee that Index and the data written is + valid, or the caller must set up exception handlers to catch the exceptions. + This function is only available on IA-32 and X64. + + If StartBit is greater than 63, then ASSERT(). + If EndBit is greater than 63, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Index The 32-bit MSR index to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..63. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..63. + @param Value New value of the bit field. + + @return The value written back to the MSR. + +**/ +UINT64 +EFIAPI +AsmMsrBitFieldWrite64 ( + IN UINT32 Index, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT64 Value + ) +{ + return AsmWriteMsr64 ( + Index, + BitFieldWrite64 (AsmReadMsr64 (Index), StartBit, EndBit, Value) + ); +} + +/** + Reads a bit field in a 64-bit MSR, performs a bitwise inclusive OR, and + writes the result back to the bit field in the 64-bit MSR. + + Reads the 64-bit MSR specified by Index, performs a bitwise inclusive OR + between the read result and the value specified by OrData, and writes the + result to the 64-bit MSR specified by Index. The value written to the MSR is + returned. Extra left bits in OrData are stripped. The caller must either + guarantee that Index and the data written is valid, or the caller must set up + exception handlers to catch the exceptions. This function is only available + on IA-32 and X64. + + If StartBit is greater than 63, then ASSERT(). + If EndBit is greater than 63, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Index The 32-bit MSR index to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..63. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..63. + @param OrData The value to OR with the read value from the bit field. + + @return The value written back to the MSR. + +**/ +UINT64 +EFIAPI +AsmMsrBitFieldOr64 ( + IN UINT32 Index, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT64 OrData + ) +{ + return AsmWriteMsr64 ( + Index, + BitFieldOr64 (AsmReadMsr64 (Index), StartBit, EndBit, OrData) + ); +} + +/** + Reads a bit field in a 64-bit MSR, performs a bitwise AND, and writes the + result back to the bit field in the 64-bit MSR. + + Reads the 64-bit MSR specified by Index, performs a bitwise AND between the + read result and the value specified by AndData, and writes the result to the + 64-bit MSR specified by Index. The value written to the MSR is returned. + Extra left bits in AndData are stripped. The caller must either guarantee + that Index and the data written is valid, or the caller must set up exception + handlers to catch the exceptions. This function is only available on IA-32 + and X64. + + If StartBit is greater than 63, then ASSERT(). + If EndBit is greater than 63, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Index The 32-bit MSR index to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..63. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..63. + @param AndData The value to AND with the read value from the bit field. + + @return The value written back to the MSR. + +**/ +UINT64 +EFIAPI +AsmMsrBitFieldAnd64 ( + IN UINT32 Index, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT64 AndData + ) +{ + return AsmWriteMsr64 ( + Index, + BitFieldAnd64 (AsmReadMsr64 (Index), StartBit, EndBit, AndData) + ); +} + +/** + Reads a bit field in a 64-bit MSR, performs a bitwise AND followed by a + bitwise inclusive OR, and writes the result back to the bit field in the + 64-bit MSR. + + Reads the 64-bit MSR specified by Index, performs a bitwise AND followed by + a bitwise inclusive OR between the read result and the value specified by + AndData, and writes the result to the 64-bit MSR specified by Index. The + value written to the MSR is returned. Extra left bits in both AndData and + OrData are stripped. The caller must either guarantee that Index and the data + written is valid, or the caller must set up exception handlers to catch the + exceptions. This function is only available on IA-32 and X64. + + If StartBit is greater than 63, then ASSERT(). + If EndBit is greater than 63, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Index The 32-bit MSR index to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..63. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..63. + @param AndData The value to AND with the read value from the bit field. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the MSR. + +**/ +UINT64 +EFIAPI +AsmMsrBitFieldAndThenOr64 ( + IN UINT32 Index, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT64 AndData, + IN UINT64 OrData + ) +{ + return AsmWriteMsr64 ( + Index, + BitFieldAndThenOr64 ( + AsmReadMsr64 (Index), + StartBit, + EndBit, + AndData, + OrData + ) + ); +} diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86ReadGdtr.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86ReadGdtr.c new file mode 100644 index 0000000..dbb367e --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86ReadGdtr.c @@ -0,0 +1,44 @@ +/*++ + +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: + + x86ReadGdtr.c + +Abstract: + + IA-32/x64 specific functions. + +--*/ + +#include "BaseLibInternal.h" + +/** + Reads the current Global Descriptor Table Register(GDTR) descriptor. + + Reads and returns the current GDTR descriptor and returns it in Gdtr. This + function is only available on IA-32 and X64. + + If Gdtr is NULL, then ASSERT(). + + @param Gdtr Pointer to a GDTR descriptor. + +**/ +VOID +EFIAPI +AsmReadGdtr ( + OUT IA32_DESCRIPTOR *Gdtr + ) +{ + ASSERT (Gdtr != NULL); + InternalX86ReadGdtr (Gdtr); +} diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86ReadIdtr.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86ReadIdtr.c new file mode 100644 index 0000000..873535a --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86ReadIdtr.c @@ -0,0 +1,44 @@ +/*++ + +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: + + x86ReadIdtr.c + +Abstract: + + IA-32/x64 specific functions. + +--*/ + +#include "BaseLibInternal.h" + +/** + Reads the current Interrupt Descriptor Table Register(GDTR) descriptor. + + Reads and returns the current IDTR descriptor and returns it in Idtr. This + function is only available on IA-32 and X64. + + If Idtr is NULL, then ASSERT(). + + @param Idtr Pointer to a IDTR descriptor. + +**/ +VOID +EFIAPI +AsmReadIdtr ( + OUT IA32_DESCRIPTOR *Idtr + ) +{ + ASSERT (Idtr != NULL); + InternalX86ReadIdtr (Idtr); +} diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86Thunk.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86Thunk.c new file mode 100644 index 0000000..0176e90 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86Thunk.c @@ -0,0 +1,250 @@ +/*++ + +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: + + x86Thunk.c + +Abstract: + + Real Mode Thunk Functions for IA32 and X64. + +--*/ + +#include "BaseLibInternal.h" +// +// Byte packed structure for a segment descriptor in a GDT/LDT +// +typedef union { + struct { + UINT32 LimitLow:16; + UINT32 BaseLow:16; + UINT32 BaseMid:8; + UINT32 Type:4; + UINT32 S:1; + UINT32 DPL:2; + UINT32 P:1; + UINT32 LimitHigh:4; + UINT32 AVL:1; + UINT32 L:1; + UINT32 DB:1; + UINT32 G:1; + UINT32 BaseHigh:8; + } Bits; + UINT64 Uint64; +} IA32_SEGMENT_DESCRIPTOR; + +extern CONST UINT8 m16Start; +extern CONST UINT16 m16Size; +extern CONST UINT16 mThunk16Attr; +extern CONST UINT16 m16Gdt; +extern CONST UINT16 m16GdtrBase; +extern CONST UINT16 mTransition; + +/** + Invokes 16-bit code in big real mode and returns the updated register set. + + This function transfers control to the 16-bit code specified by CS:EIP using + the stack specified by SS:ESP in RegisterSet. The updated registers are saved + on the real mode stack and the starting address of the save area is returned. + + @param RegisterSet Values of registers before invocation of 16-bit code. + @param Transition Pointer to the transition code under 1MB. + + @return The pointer to a IA32_REGISTER_SET structure containing the updated + register values. + +**/ +IA32_REGISTER_SET * +EFIAPI +InternalAsmThunk16 ( + IN IA32_REGISTER_SET *RegisterSet, + IN OUT VOID *Transition + ); + +/** + Retrieves the properties for 16-bit thunk functions. + + Computes the size of the buffer and stack below 1MB required to use the + AsmPrepareThunk16(), AsmThunk16() and AsmPrepareAndThunk16() functions. This + buffer size is returned in RealModeBufferSize, and the stack size is returned + in ExtraStackSize. If parameters are passed to the 16-bit real mode code, + then the actual minimum stack size is ExtraStackSize plus the maximum number + of bytes that need to be passed to the 16-bit real mode code. + + If RealModeBufferSize is NULL, then ASSERT(). + If ExtraStackSize is NULL, then ASSERT(). + + @param RealModeBufferSize A pointer to the size of the buffer below 1MB + required to use the 16-bit thunk functions. + @param ExtraStackSize A pointer to the extra size of stack below 1MB + that the 16-bit thunk functions require for + temporary storage in the transition to and from + 16-bit real mode. + +**/ +VOID +EFIAPI +AsmGetThunk16Properties ( + OUT UINT32 *RealModeBufferSize, + OUT UINT32 *ExtraStackSize + ) +{ + ASSERT (RealModeBufferSize != NULL); + ASSERT (ExtraStackSize != NULL); + + *RealModeBufferSize = m16Size; + + // + // Extra 4 bytes for return address, and another 4 bytes for mode transition + // + *ExtraStackSize = sizeof (IA32_DWORD_REGS) + 8; +} + +/** + Prepares all structures a code required to use AsmThunk16(). + + Prepares all structures and code required to use AsmThunk16(). + + If ThunkContext is NULL, then ASSERT(). + + @param ThunkContext A pointer to the context structure that describes the + 16-bit real mode code to call. + +**/ +VOID +EFIAPI +AsmPrepareThunk16 ( + OUT THUNK_CONTEXT *ThunkContext + ) +{ + IA32_SEGMENT_DESCRIPTOR *RealModeGdt; + + ASSERT (ThunkContext != NULL); + ASSERT ((UINTN)ThunkContext->RealModeBuffer < 0x100000); + ASSERT (ThunkContext->RealModeBufferSize >= m16Size); + ASSERT ((UINTN)ThunkContext->RealModeBuffer + m16Size <= 0x100000); + + CopyMem (ThunkContext->RealModeBuffer, &m16Start, m16Size); + + // + // Point RealModeGdt to the GDT to be used in transition + // + // RealModeGdt[0]: Reserved as NULL descriptor + // RealModeGdt[1]: Code Segment + // RealModeGdt[2]: Data Segment + // RealModeGdt[3]: Call Gate + // + RealModeGdt = (IA32_SEGMENT_DESCRIPTOR*)( + (UINTN)ThunkContext->RealModeBuffer + m16Gdt); + + // + // Update Code & Data Segment Descriptor + // + RealModeGdt[1].Bits.BaseLow = + (UINT32)(UINTN)ThunkContext->RealModeBuffer & ~0xf; + RealModeGdt[1].Bits.BaseMid = + (UINT32)(UINTN)ThunkContext->RealModeBuffer >> 16; + + // + // Update transition code entry point offset + // + *(UINT32*)((UINTN)ThunkContext->RealModeBuffer + mTransition) += + (UINT32)(UINTN)ThunkContext->RealModeBuffer & 0xf; + + // + // Update Segment Limits for both Code and Data Segment Descriptors + // + if ((ThunkContext->ThunkAttributes & THUNK_ATTRIBUTE_BIG_REAL_MODE) == 0) { + // + // Set segment limits to 64KB + // + RealModeGdt[1].Bits.LimitHigh = 0; + RealModeGdt[1].Bits.G = 0; + RealModeGdt[2].Bits.LimitHigh = 0; + RealModeGdt[2].Bits.G = 0; + } + + // + // Update GDTBASE for this thunk context + // + *(VOID**)((UINTN)ThunkContext->RealModeBuffer + m16GdtrBase) = RealModeGdt; + + // + // Update Thunk Attributes + // + *(UINT32*)((UINTN)ThunkContext->RealModeBuffer + mThunk16Attr) = + ThunkContext->ThunkAttributes; +} + +/** + Transfers control to a 16-bit real mode entry point and returns the results. + + Transfers control to a 16-bit real mode entry point and returns the results. + AsmPrepareThunk16() must be called with ThunkContext before this function is + used. This function must be called with interrupts disabled. + + If ThunkContext is NULL, then ASSERT(). + If AsmPrepareThunk16() was not previously called with ThunkContext, then ASSERT(). + + @param ThunkContext A pointer to the context structure that describes the + 16-bit real mode code to call. + +**/ +VOID +EFIAPI +AsmThunk16 ( + IN OUT THUNK_CONTEXT *ThunkContext + ) +{ + IA32_REGISTER_SET *UpdatedRegs; + + ASSERT (ThunkContext != NULL); + ASSERT ((UINTN)ThunkContext->RealModeBuffer < 0x100000); + ASSERT (ThunkContext->RealModeBufferSize >= m16Size); + ASSERT ((UINTN)ThunkContext->RealModeBuffer + m16Size <= 0x100000); + + UpdatedRegs = InternalAsmThunk16 ( + ThunkContext->RealModeState, + ThunkContext->RealModeBuffer + ); + + CopyMem (ThunkContext->RealModeState, UpdatedRegs, sizeof (*UpdatedRegs)); +} + +/** + Prepares all structures and code for a 16-bit real mode thunk, transfers + control to a 16-bit real mode entry point, and returns the results. + + Prepares all structures and code for a 16-bit real mode thunk, transfers + control to a 16-bit real mode entry point, and returns the results. If the + caller only need to perform a single 16-bit real mode thunk, then this + service should be used. If the caller intends to make more than one 16-bit + real mode thunk, then it is more efficient if AsmPrepareThunk16() is called + once and AsmThunk16() can be called for each 16-bit real mode thunk. This + function must be called with interrupts disabled. + + If ThunkContext is NULL, then ASSERT(). + + @param ThunkContext A pointer to the context structure that describes the + 16-bit real mode code to call. + +**/ +VOID +EFIAPI +AsmPrepareAndThunk16 ( + IN OUT THUNK_CONTEXT *ThunkContext + ) +{ + AsmPrepareThunk16 (ThunkContext); + AsmThunk16 (ThunkContext); +} diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86WriteGdtr.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86WriteGdtr.c new file mode 100644 index 0000000..8e7c189 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86WriteGdtr.c @@ -0,0 +1,44 @@ +/*++ + +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: + + x86WriteGdtr.c + +Abstract: + + IA-32/x64 specific functions. + +--*/ + +#include "BaseLibInternal.h" + +/** + Writes the current Global Descriptor Table Register (GDTR) descriptor. + + Writes and the current GDTR descriptor specified by Gdtr. This function is + only available on IA-32 and X64. + + If Gdtr is NULL, then ASSERT(). + + @param Gdtr Pointer to a GDTR descriptor. + +**/ +VOID +EFIAPI +AsmWriteGdtr ( + IN CONST IA32_DESCRIPTOR *Gdtr + ) +{ + ASSERT (Gdtr != NULL); + InternalX86WriteGdtr (Gdtr); +} diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86WriteIdtr.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86WriteIdtr.c new file mode 100644 index 0000000..e82c0e3 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86WriteIdtr.c @@ -0,0 +1,44 @@ +/*++ + +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: + + x86WriteIdtr.c + +Abstract: + + IA-32/x64 specific functions. + +--*/ + +#include "BaseLibInternal.h" + +/** + Writes the current Interrupt Descriptor Table Register(GDTR) descriptor. + + Writes the current IDTR descriptor and returns it in Idtr. This function is + only available on IA-32 and X64. + + If Idtr is NULL, then ASSERT(). + + @param Idtr Pointer to a IDTR descriptor. + +**/ +VOID +EFIAPI +AsmWriteIdtr ( + IN CONST IA32_DESCRIPTOR *Idtr + ) +{ + ASSERT (Idtr != NULL); + InternalX86WriteIdtr (Idtr); +} diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/BaseMemoryLib.inf b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/BaseMemoryLib.inf new file mode 100644 index 0000000..ac186c3 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/BaseMemoryLib.inf @@ -0,0 +1,119 @@ +#/*++ +# +# 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: +# +# BaseMemoryLib.inf +# +# Abstract: +# +# Component description file for BaseMemoryLib. This instance is not the +# BaseMemoryLib in EdkII but almost BaseMemoryLibRepStr. +# Use REP string instructions for Ia32 and X64 for high performance and small size +# Use C implementation for IPF and EBC +# +#--*/ + +[defines] +BASE_NAME = EdkIIGlueBaseMemoryLib +COMPONENT_TYPE = LIBRARY + +[sources.common] + MemLibGuid.c + CopyMemWrapper.c + SetMemWrapper.c + SetMem16Wrapper.c + SetMem32Wrapper.c + SetMem64Wrapper.c + CompareMemWrapper.c + ZeroMemWrapper.c + ScanMem8Wrapper.c + ScanMem16Wrapper.c + ScanMem32Wrapper.c + ScanMem64Wrapper.c + +[sources.ia32] + Ia32/CopyMem.asm + Ia32/SetMem.asm + Ia32/SetMem16.asm + Ia32/SetMem32.asm + Ia32/SetMem64.asm + Ia32/ZeroMem.asm + Ia32/CompareMem.asm + Ia32/ScanMem8.asm + Ia32/ScanMem16.asm + Ia32/ScanMem32.asm + Ia32/ScanMem64.asm + +[sources.x64] + X64/CopyMem.asm + X64/SetMem.asm + X64/SetMem16.asm + X64/SetMem32.asm + X64/SetMem64.asm + X64/ZeroMem.asm + X64/CompareMem.asm + X64/ScanMem8.asm + X64/ScanMem16.asm + X64/ScanMem32.asm + X64/ScanMem64.asm + +[sources.ipf] + Ipf/CopyMem.c + Ipf/MemLibGeneric.c + Ipf/SetMem.c + +[sources.ebc] + Ebc/CopyMem.c + Ebc/MemLibGeneric.c + Ebc/SetMem.c + +[includes.common] + . + ..\..\Include + ..\..\include\Library + $(EDK_SOURCE)\Foundation + $(EDK_SOURCE)\Foundation\Framework + $(EDK_SOURCE)\Foundation\Efi + $(EDK_SOURCE)\Foundation\Include + $(EDK_SOURCE)\Foundation\Efi\Include + $(EDK_SOURCE)\Foundation\Framework\Include + $(EDK_SOURCE)\Foundation\Include\IndustryStandard + $(EDK_SOURCE)\Foundation\Core\Dxe + $(EDK_SOURCE)\Foundation\Library\Dxe\Include + $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include + +[libraries.common] + EdkIIGlueBaseLib + +[libraries.ia32] + + +[libraries.x64] + + +[nmake.common] + C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION + LIB_STD_FLAGS = $(LIB_STD_FLAGS) /IGNORE:4006 /IGNORE:4221 + +[nmake.ia32] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32 + +[nmake.x64] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64 + +[nmake.ipf] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF + +[nmake.ebc] + EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION + EBC_LIB_STD_FLAGS = $(EBC_LIB_STD_FLAGS) /IGNORE:4006 /IGNORE:4221 + EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D MDE_CPU_EBC diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/BaseMemoryLibInternal.h b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/BaseMemoryLibInternal.h new file mode 100644 index 0000000..5a2df01 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/BaseMemoryLibInternal.h @@ -0,0 +1,227 @@ +/*++ + +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: + + BaseMemoryLibInternals.h + +Abstract: + + Header file for Base Memory Library. + +--*/ + +#ifndef __BASEMEMORY_LIB_INTERNALS_H__ +#define __BASEMEMORY_LIB_INTERNALS_H__ + +#include "EdkIIGlueBase.h" +/** + Copy Length bytes from Source to Destination. + + @param Destination Target of copy + @param Source Place to copy from + @param Length Number of bytes to copy + + @return Destination + +**/ +VOID * +EFIAPI +InternalMemCopyMem ( + OUT VOID *DestinationBuffer, + IN CONST VOID *SourceBuffer, + IN UINTN Length + ); + +/** + Set Buffer to Value for Size bytes. + + @param Buffer Memory to set. + @param Size Number of bytes to set + @param Value Value of the set operation. + + @return Buffer + +**/ +VOID * +EFIAPI +InternalMemSetMem ( + OUT VOID *Buffer, + IN UINTN Length, + IN UINT8 Value + ); + +/** + Fills a target buffer with a 16-bit value, and returns the target buffer. + + @param Buffer Pointer to the target buffer to fill. + @param Length Number of bytes in Buffer to fill. + @param Value Value with which to fill Length bytes of Buffer. + + @return Buffer + +**/ +VOID * +EFIAPI +InternalMemSetMem16 ( + OUT VOID *Buffer, + IN UINTN Length, + IN UINT16 Value + ); + +/** + Fills a target buffer with a 32-bit value, and returns the target buffer. + + @param Buffer Pointer to the target buffer to fill. + @param Length Number of bytes in Buffer to fill. + @param Value Value with which to fill Length bytes of Buffer. + + @return Buffer + +**/ +VOID * +EFIAPI +InternalMemSetMem32 ( + OUT VOID *Buffer, + IN UINTN Length, + IN UINT32 Value + ); + +/** + Fills a target buffer with a 64-bit value, and returns the target buffer. + + @param Buffer Pointer to the target buffer to fill. + @param Length Number of bytes in Buffer to fill. + @param Value Value with which to fill Length bytes of Buffer. + + @return Buffer + +**/ +VOID * +EFIAPI +InternalMemSetMem64 ( + OUT VOID *Buffer, + IN UINTN Length, + IN UINT64 Value + ); + +/** + Set Buffer to 0 for Size bytes. + + @param Buffer Memory to set. + @param Size Number of bytes to set + + @return Buffer + +**/ +VOID * +EFIAPI +InternalMemZeroMem ( + OUT VOID *Buffer, + IN UINTN Length + ); + +/** + Compares two memory buffers of a given length. + + @param DestinationBuffer First memory buffer + @param SourceBuffer Second memory buffer + @param Length Length of DestinationBuffer and SourceBuffer memory + regions to compare. Must be non-zero. + + @retval 0 if MemOne == MemTwo + +**/ +INTN +EFIAPI +InternalMemCompareMem ( + IN CONST VOID *DestinationBuffer, + IN CONST VOID *SourceBuffer, + IN UINTN Length + ); + +/** + Scans a target buffer for an 8-bit value, and returns a pointer to the + matching 8-bit value in the target buffer. + + @param Buffer Pointer to the target buffer to scan. + @param Length Number of bytes in Buffer to scan. Must be non-zero. + @param Value Value to search for in the target buffer. + + @return Pointer to the first occurrence or NULL if not found. + +**/ +CONST VOID * +EFIAPI +InternalMemScanMem8 ( + IN CONST VOID *Buffer, + IN UINTN Length, + IN UINT8 Value + ); + +/** + Scans a target buffer for a 16-bit value, and returns a pointer to the + matching 16-bit value in the target buffer. + + @param Buffer Pointer to the target buffer to scan. + @param Length Number of bytes in Buffer to scan. Must be non-zero. + @param Value Value to search for in the target buffer. + + @return Pointer to the first occurrence or NULL if not found. + +**/ +CONST VOID * +EFIAPI +InternalMemScanMem16 ( + IN CONST VOID *Buffer, + IN UINTN Length, + IN UINT16 Value + ); + +/** + Scans a target buffer for a 32-bit value, and returns a pointer to the + matching 32-bit value in the target buffer. + + @param Buffer Pointer to the target buffer to scan. + @param Length Number of bytes in Buffer to scan. Must be non-zero. + @param Value Value to search for in the target buffer. + + @return Pointer to the first occurrence or NULL if not found. + +**/ +CONST VOID * +EFIAPI +InternalMemScanMem32 ( + IN CONST VOID *Buffer, + IN UINTN Length, + IN UINT32 Value + ); + +/** + Scans a target buffer for a 64-bit value, and returns a pointer to the + matching 64-bit value in the target buffer. + + @param Buffer Pointer to the target buffer to scan. + @param Length Number of bytes in Buffer to scan. Must be non-zero. + @param Value Value to search for in the target buffer. + + @return Pointer to the first occurrence or NULL if not found. + +**/ +CONST VOID * +EFIAPI +InternalMemScanMem64 ( + IN CONST VOID *Buffer, + IN UINTN Length, + IN UINT64 Value + ); + +#endif diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/CompareMemWrapper.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/CompareMemWrapper.c new file mode 100644 index 0000000..a1a27cf --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/CompareMemWrapper.c @@ -0,0 +1,63 @@ +/*++ + +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: + + CompareMemWrapper.c + +Abstract: + + CompareMem() implementation. + +--*/ + +#include "BaseMemoryLibInternal.h" + +/** + Compares the contents of two buffers. + + This function compares Length bytes of SourceBuffer to Length bytes of DestinationBuffer. + If all Length bytes of the two buffers are identical, then 0 is returned. Otherwise, the + value returned is the first mismatched byte in SourceBuffer subtracted from the first + mismatched byte in DestinationBuffer. + If Length > 0 and DestinationBuffer is NULL and Length > 0, then ASSERT(). + If Length > 0 and SourceBuffer is NULL and Length > 0, then ASSERT(). + If Length is greater than (MAX_ADDRESS - DestinationBuffer + 1), then ASSERT(). + If Length is greater than (MAX_ADDRESS - SourceBuffer + 1), then ASSERT(). + + + @param DestinationBuffer Pointer to the destination buffer to compare. + @param SourceBuffer Pointer to the source buffer to compare. + @param Length Number of bytes to compare. + + @return 0 All Length bytes of the two buffers are identical. + @retval Non-zero The first mismatched byte in SourceBuffer subtracted from the first + mismatched byte in DestinationBuffer. + +**/ +INTN +EFIAPI +GlueCompareMem ( + IN CONST VOID *DestinationBuffer, + IN CONST VOID *SourceBuffer, + IN UINTN Length + ) +{ + if (Length == 0 || DestinationBuffer == SourceBuffer) { + return 0; + } + ASSERT (DestinationBuffer != NULL); + ASSERT (SourceBuffer != NULL); + ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN)DestinationBuffer)); + ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN)SourceBuffer)); + + return InternalMemCompareMem (DestinationBuffer, SourceBuffer, Length); +} diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/CopyMem.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/CopyMem.c new file mode 100644 index 0000000..17ea273 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/CopyMem.c @@ -0,0 +1,65 @@ +/*++ + +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: + + CopyMem.c + +Abstract: + + Internal CopyMem + +--*/ + +#include "BaseMemoryLibInternal.h" + +/** + Copy Length bytes from Source to Destination. + + @param Destination Target of copy + @param Source Place to copy from + @param Length Number of bytes to copy + + @return Destination + +**/ +VOID * +EFIAPI +InternalMemCopyMem ( + OUT VOID *Destination, + IN CONST VOID *Source, + IN UINTN Length + ) +{ + // + // Declare the local variables that actually move the data elements as + // volatile to prevent the optimizer from replacing this function with + // the intrinsic memcpy() + // + volatile UINT8 *Destination8; + CONST UINT8 *Source8; + + if (Source > Destination) { + Destination8 = (UINT8*)Destination; + Source8 = (CONST UINT8*)Source; + while (Length-- != 0) { + *(Destination8++) = *(Source8++); + } + } else if (Source < Destination) { + Destination8 = (UINT8*)Destination + Length; + Source8 = (CONST UINT8*)Source + Length; + while (Length-- != 0) { + *(--Destination8) = *(--Source8); + } + } + return Destination; +} diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/CopyMemWrapper.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/CopyMemWrapper.c new file mode 100644 index 0000000..b9d8101 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/CopyMemWrapper.c @@ -0,0 +1,58 @@ +/*++ + +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: + + CopyMemWrapper.c + +Abstract: + + CopyMem() implementation. + +--*/ + +#include "BaseMemoryLibInternal.h" + +/** + Copies a source buffer to a destination buffer, and returns the destination buffer. + + This function copies Length bytes from SourceBuffer to DestinationBuffer, and returns + DestinationBuffer. The implementation must be reentrant, and it must handle the case + where SourceBuffer overlaps DestinationBuffer. + If Length is greater than (MAX_ADDRESS - DestinationBuffer + 1), then ASSERT(). + If Length is greater than (MAX_ADDRESS - SourceBuffer + 1), then ASSERT(). + + @param DestinationBuffer Pointer to the destination buffer of the memory copy. + @param SourceBuffer Pointer to the source buffer of the memory copy. + @param Length Number of bytes to copy from SourceBuffer to DestinationBuffer. + + @return DestinationBuffer. + +**/ +VOID * +EFIAPI +GlueCopyMem ( + OUT VOID *DestinationBuffer, + IN CONST VOID *SourceBuffer, + IN UINTN Length + ) +{ + if (Length == 0) { + return DestinationBuffer; + } + ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN)DestinationBuffer)); + ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN)SourceBuffer)); + + if (DestinationBuffer == SourceBuffer) { + return DestinationBuffer; + } + return InternalMemCopyMem (DestinationBuffer, SourceBuffer, Length); +} diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/Ebc/CopyMem.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/Ebc/CopyMem.c new file mode 100644 index 0000000..17ea273 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/Ebc/CopyMem.c @@ -0,0 +1,65 @@ +/*++ + +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: + + CopyMem.c + +Abstract: + + Internal CopyMem + +--*/ + +#include "BaseMemoryLibInternal.h" + +/** + Copy Length bytes from Source to Destination. + + @param Destination Target of copy + @param Source Place to copy from + @param Length Number of bytes to copy + + @return Destination + +**/ +VOID * +EFIAPI +InternalMemCopyMem ( + OUT VOID *Destination, + IN CONST VOID *Source, + IN UINTN Length + ) +{ + // + // Declare the local variables that actually move the data elements as + // volatile to prevent the optimizer from replacing this function with + // the intrinsic memcpy() + // + volatile UINT8 *Destination8; + CONST UINT8 *Source8; + + if (Source > Destination) { + Destination8 = (UINT8*)Destination; + Source8 = (CONST UINT8*)Source; + while (Length-- != 0) { + *(Destination8++) = *(Source8++); + } + } else if (Source < Destination) { + Destination8 = (UINT8*)Destination + Length; + Source8 = (CONST UINT8*)Source + Length; + while (Length-- != 0) { + *(--Destination8) = *(--Source8); + } + } + return Destination; +} diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/Ebc/MemLibGeneric.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/Ebc/MemLibGeneric.c new file mode 100644 index 0000000..284a492 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/Ebc/MemLibGeneric.c @@ -0,0 +1,261 @@ +/*++ + +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: + + MemLibGeneric.c + +Abstract: + + Architecture Independent Base Memory Library Implementation. + +--*/ + +#include "BaseMemoryLibInternal.h" + +/** + Fills a target buffer with a 16-bit value, and returns the target buffer. + + @param Buffer Pointer to the target buffer to fill. + @param Length Number of bytes in Buffer to fill. + @param Value Value with which to fill Length bytes of Buffer. + + @return Buffer + +**/ +VOID * +EFIAPI +InternalMemSetMem16 ( + OUT VOID *Buffer, + IN UINTN Length, + IN UINT16 Value + ) +{ + do { + ((UINT16*)Buffer)[--Length] = Value; + } while (Length != 0); + return Buffer; +} + +/** + Fills a target buffer with a 32-bit value, and returns the target buffer. + + @param Buffer Pointer to the target buffer to fill. + @param Length Number of bytes in Buffer to fill. + @param Value Value with which to fill Length bytes of Buffer. + + @return Buffer + +**/ +VOID * +EFIAPI +InternalMemSetMem32 ( + OUT VOID *Buffer, + IN UINTN Length, + IN UINT32 Value + ) +{ + do { + ((UINT32*)Buffer)[--Length] = Value; + } while (Length != 0); + return Buffer; +} + +/** + Fills a target buffer with a 64-bit value, and returns the target buffer. + + @param Buffer Pointer to the target buffer to fill. + @param Length Number of bytes in Buffer to fill. + @param Value Value with which to fill Length bytes of Buffer. + + @return Buffer + +**/ +VOID * +EFIAPI +InternalMemSetMem64 ( + OUT VOID *Buffer, + IN UINTN Length, + IN UINT64 Value + ) +{ + do { + ((UINT64*)Buffer)[--Length] = Value; + } while (Length != 0); + return Buffer; +} + +/** + Set Buffer to 0 for Size bytes. + + @param Buffer Memory to set. + @param Size Number of bytes to set + + @return Buffer + +**/ +VOID * +EFIAPI +InternalMemZeroMem ( + OUT VOID *Buffer, + IN UINTN Length + ) +{ + return InternalMemSetMem (Buffer, Length, 0); +} + +/** + Compares two memory buffers of a given length. + + @param DestinationBuffer First memory buffer + @param SourceBuffer Second memory buffer + @param Length Length of DestinationBuffer and SourceBuffer memory + regions to compare. Must be non-zero. + + @retval 0 if MemOne == MemTwo + +**/ +INTN +EFIAPI +InternalMemCompareMem ( + IN CONST VOID *DestinationBuffer, + IN CONST VOID *SourceBuffer, + IN UINTN Length + ) +{ + while ((--Length != 0) && + (*(INT8*)DestinationBuffer == *(INT8*)SourceBuffer)) { + DestinationBuffer = (INT8*)DestinationBuffer + 1; + SourceBuffer = (INT8*)SourceBuffer + 1; + } + return (INTN)*(UINT8*)DestinationBuffer - (INTN)*(UINT8*)SourceBuffer; +} + +/** + Scans a target buffer for an 8-bit value, and returns a pointer to the + matching 8-bit value in the target buffer. + + @param Buffer Pointer to the target buffer to scan. + @param Length Number of bytes in Buffer to scan. Must be non-zero. + @param Value Value to search for in the target buffer. + + @return Pointer to the first occurrence or NULL if not found. + +**/ +CONST VOID * +EFIAPI +InternalMemScanMem8 ( + IN CONST VOID *Buffer, + IN UINTN Length, + IN UINT8 Value + ) +{ + CONST UINT8 *Pointer; + + Pointer = (CONST UINT8*)Buffer; + do { + if (*(Pointer++) == Value) { + return Pointer; + } + } while (--Length != 0); + return NULL; +} + +/** + Scans a target buffer for a 16-bit value, and returns a pointer to the + matching 16-bit value in the target buffer. + + @param Buffer Pointer to the target buffer to scan. + @param Length Number of bytes in Buffer to scan. Must be non-zero. + @param Value Value to search for in the target buffer. + + @return Pointer to the first occurrence or NULL if not found. + +**/ +CONST VOID * +EFIAPI +InternalMemScanMem16 ( + IN CONST VOID *Buffer, + IN UINTN Length, + IN UINT16 Value + ) +{ + CONST UINT16 *Pointer; + + Pointer = (CONST UINT16*)Buffer; + do { + if (*(Pointer++) == Value) { + return Pointer; + } + } while (--Length != 0); + return NULL; +} + +/** + Scans a target buffer for a 32-bit value, and returns a pointer to the + matching 32-bit value in the target buffer. + + @param Buffer Pointer to the target buffer to scan. + @param Length Number of bytes in Buffer to scan. Must be non-zero. + @param Value Value to search for in the target buffer. + + @return Pointer to the first occurrence or NULL if not found. + +**/ +CONST VOID * +EFIAPI +InternalMemScanMem32 ( + IN CONST VOID *Buffer, + IN UINTN Length, + IN UINT32 Value + ) +{ + CONST UINT32 *Pointer; + + Pointer = (CONST UINT32*)Buffer; + do { + if (*(Pointer++) == Value) { + return Pointer; + } + } while (--Length != 0); + return NULL; +} + +/** + Scans a target buffer for a 64-bit value, and returns a pointer to the + matching 64-bit value in the target buffer. + + @param Buffer Pointer to the target buffer to scan. + @param Length Number of bytes in Buffer to scan. Must be non-zero. + @param Value Value to search for in the target buffer. + + @return Pointer to the first occurrence or NULL if not found. + +**/ +CONST VOID * +EFIAPI +InternalMemScanMem64 ( + IN CONST VOID *Buffer, + IN UINTN Length, + IN UINT64 Value + ) +{ + CONST UINT64 *Pointer; + + Pointer = (CONST UINT64*)Buffer; + do { + if (*(Pointer++) == Value) { + return Pointer; + } + } while (--Length != 0); + return NULL; +} diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/Ebc/SetMem.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/Ebc/SetMem.c new file mode 100644 index 0000000..9c94c91 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/Ebc/SetMem.c @@ -0,0 +1,55 @@ +/*++ + +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: + + SetMem.c + +Abstract: + + Internal SetMem + +--*/ + +#include "BaseMemoryLibInternal.h" + +/** + Set Buffer to Value for Size bytes. + + @param Buffer Memory to set. + @param Size Number of bytes to set + @param Value Value of the set operation. + + @return Buffer + +**/ +VOID * +EFIAPI +InternalMemSetMem ( + IN VOID *Buffer, + IN UINTN Size, + IN UINT8 Value + ) +{ + // + // Declare the local variables that actually move the data elements as + // volatile to prevent the optimizer from replacing this function with + // the intrinsic memset() + // + volatile UINT8 *Pointer; + + Pointer = (UINT8*)Buffer; + while (Size-- != 0) { + *(Pointer++) = Value; + } + return Buffer; +} diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/EdkIIGlueBaseMemoryLib.cif b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/EdkIIGlueBaseMemoryLib.cif new file mode 100644 index 0000000..a290dfe --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/EdkIIGlueBaseMemoryLib.cif @@ -0,0 +1,57 @@ +<component> + name = "EdkIIGlueBaseMemoryLib" + category = ModulePart + LocalRoot = "Edk\Foundation\Library\EdkIIGlueLib\Library\BaseMemoryLib" + RefName = "EdkIIGlueBaseMemoryLib" +[files] +"EdkIIGlueBaseMemoryLib.sdl" +"EdkIIGlueBaseMemoryLib.mak" +"BaseMemoryLib.inf" +"BaseMemoryLibInternal.h" +"MemLibGuid.c" +"MemLibGeneric.c" +"CopyMem.c" +"CopyMemWrapper.c" +"SetMem.c" +"SetMemWrapper.c" +"SetMem16Wrapper.c" +"SetMem32Wrapper.c" +"SetMem64Wrapper.c" +"CompareMemWrapper.c" +"ZeroMemWrapper.c" +"ScanMem8Wrapper.c" +"ScanMem16Wrapper.c" +"ScanMem32Wrapper.c" +"ScanMem64Wrapper.c" +"Ia32\SetMem16.asm" +"Ia32\SetMem32.asm" +"Ia32\SetMem64.asm" +"Ia32\ZeroMem.asm" +"Ia32\CompareMem.asm" +"Ia32\CopyMem.asm" +"Ia32\ScanMem8.asm" +"Ia32\ScanMem16.asm" +"Ia32\ScanMem32.asm" +"Ia32\ScanMem64.asm" +"Ia32\SetMem.asm" +"X64\SetMem16.asm" +"X64\SetMem32.asm" +"X64\SetMem64.asm" +"X64\ZeroMem.asm" +"X64\CompareMem.asm" +"X64\CopyMem.asm" +"X64\ScanMem8.asm" +"X64\ScanMem16.asm" +"X64\ScanMem32.asm" +"X64\ScanMem64.asm" +"X64\SetMem.asm" +"Ipf\CopyMem.c" +"Ipf\MemLibGeneric.c" +"Ipf\SetMem.c" +"Ebc\CopyMem.c" +"Ebc\MemLibGeneric.c" +"Ebc\SetMem.c" +[parts] +"EdkIIGlueBaseMemoryLibIA32" +"EdkIIGlueBaseMemoryLibX64" +<endComponent> diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/EdkIIGlueBaseMemoryLib.mak b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/EdkIIGlueBaseMemoryLib.mak new file mode 100644 index 0000000..f8bd54d --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/EdkIIGlueBaseMemoryLib.mak @@ -0,0 +1,142 @@ +#********************************************************************** +#********************************************************************** +#** ** +#** (C)Copyright 1985-2009, American Megatrends, Inc. ** +#** ** +#** All Rights Reserved. ** +#** ** +#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +#** ** +#** Phone: (770)-246-8600 ** +#** ** +#********************************************************************** +#********************************************************************** + +#********************************************************************** +# $Header: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGlueBaseMemoryLib/EdkIIGlueBaseMemoryLib.mak 1 1/20/12 3:51a Jeffch $ +# +# $Revision: 1 $ +# +# $Date: 1/20/12 3:51a $ +#********************************************************************** +# Revision History +# ---------------- +# $Log: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGlueBaseMemoryLib/EdkIIGlueBaseMemoryLib.mak $ +# +# 1 1/20/12 3:51a Jeffch +# Create Intel EDK 1117 Patch 7. +# +# 1 1/20/12 3:30a Jeffch +# Create Intel EDK 1117 Patch 7. +# +# 1 9/27/11 6:14a Wesleychen +# Intel EDK initially releases. +# +# 1 9/18/09 1:51a Iminglin +# +#********************************************************************** +#<AMI_FHDR_START> +# +# Name: EdkIIGlueBaseMemoryLib.mak +# +# Description: +# +#<AMI_FHDR_END> +#********************************************************************** + +EdkIIGlueBaseMemoryLib_OBJECTS=\ +$$(BUILD_DIR)\$(EdkIIGlueBaseMemoryLib_DIR)\ScanMem32Wrapper.obj \ +$$(BUILD_DIR)\$(EdkIIGlueBaseMemoryLib_DIR)\ScanMem64Wrapper.obj \ +$$(BUILD_DIR)\$(EdkIIGlueBaseMemoryLib_DIR)\SetMem16Wrapper.obj \ +$$(BUILD_DIR)\$(EdkIIGlueBaseMemoryLib_DIR)\SetMem32Wrapper.obj \ +$$(BUILD_DIR)\$(EdkIIGlueBaseMemoryLib_DIR)\SetMem64Wrapper.obj \ +$$(BUILD_DIR)\$(EdkIIGlueBaseMemoryLib_DIR)\SetMemWrapper.obj \ +$$(BUILD_DIR)\$(EdkIIGlueBaseMemoryLib_DIR)\ZeroMemWrapper.obj \ +$$(BUILD_DIR)\$(EdkIIGlueBaseMemoryLib_DIR)\CompareMemWrapper.obj \ +$$(BUILD_DIR)\$(EdkIIGlueBaseMemoryLib_DIR)\CopyMemWrapper.obj \ +$$(BUILD_DIR)\$(EdkIIGlueBaseMemoryLib_DIR)\MemLibGuid.obj \ +$$(BUILD_DIR)\$(EdkIIGlueBaseMemoryLib_DIR)\ScanMem8Wrapper.obj \ +$$(BUILD_DIR)\$(EdkIIGlueBaseMemoryLib_DIR)\ScanMem16Wrapper.obj + +EdkIIGlueBaseMemoryLib_IA32_OBJECTS=\ +$$(BUILD_DIR)\$(EdkIIGlueBaseMemoryLib_DIR)\Ia32\ScanMem8.obj \ +$$(BUILD_DIR)\$(EdkIIGlueBaseMemoryLib_DIR)\Ia32\ScanMem16.obj \ +$$(BUILD_DIR)\$(EdkIIGlueBaseMemoryLib_DIR)\Ia32\ScanMem32.obj \ +$$(BUILD_DIR)\$(EdkIIGlueBaseMemoryLib_DIR)\Ia32\ScanMem64.obj \ +$$(BUILD_DIR)\$(EdkIIGlueBaseMemoryLib_DIR)\Ia32\SetMem.obj \ +$$(BUILD_DIR)\$(EdkIIGlueBaseMemoryLib_DIR)\Ia32\SetMem16.obj \ +$$(BUILD_DIR)\$(EdkIIGlueBaseMemoryLib_DIR)\Ia32\SetMem32.obj \ +$$(BUILD_DIR)\$(EdkIIGlueBaseMemoryLib_DIR)\Ia32\SetMem64.obj \ +$$(BUILD_DIR)\$(EdkIIGlueBaseMemoryLib_DIR)\Ia32\ZeroMem.obj \ +$$(BUILD_DIR)\$(EdkIIGlueBaseMemoryLib_DIR)\Ia32\CompareMem.obj \ +$$(BUILD_DIR)\$(EdkIIGlueBaseMemoryLib_DIR)\Ia32\CopyMem.obj + +!IF "$(PROCESSOR)"=="IA32" +EdkIIGlueBaseMemoryLib_OBJECTS =$(EdkIIGlueBaseMemoryLib_OBJECTS) $(EdkIIGlueBaseMemoryLib_IA32_OBJECTS) +!ELSEIF "$(PROCESSOR)"=="x64" +EdkIIGlueBaseMemoryLib_PEI_OBJECTS =$(EdkIIGlueBaseMemoryLib_OBJECTS) $(EdkIIGlueBaseMemoryLib_IA32_OBJECTS) +EdkIIGlueBaseMemoryLib_DXE_OBJECTS =$(EdkIIGlueBaseMemoryLib_OBJECTS)\ +$$(BUILD_DIR)\$(EdkIIGlueBaseMemoryLib_DIR)\X64\CompareMem.obj\ +$$(BUILD_DIR)\$(EdkIIGlueBaseMemoryLib_DIR)\X64\CopyMem.obj\ +$$(BUILD_DIR)\$(EdkIIGlueBaseMemoryLib_DIR)\X64\ScanMem16.obj\ +$$(BUILD_DIR)\$(EdkIIGlueBaseMemoryLib_DIR)\X64\ScanMem32.obj\ +$$(BUILD_DIR)\$(EdkIIGlueBaseMemoryLib_DIR)\X64\ScanMem64.obj\ +$$(BUILD_DIR)\$(EdkIIGlueBaseMemoryLib_DIR)\X64\ScanMem8.obj\ +$$(BUILD_DIR)\$(EdkIIGlueBaseMemoryLib_DIR)\X64\SetMem.obj\ +$$(BUILD_DIR)\$(EdkIIGlueBaseMemoryLib_DIR)\X64\SetMem16.obj\ +$$(BUILD_DIR)\$(EdkIIGlueBaseMemoryLib_DIR)\X64\SetMem32.obj\ +$$(BUILD_DIR)\$(EdkIIGlueBaseMemoryLib_DIR)\X64\SetMem64.obj\ +$$(BUILD_DIR)\$(EdkIIGlueBaseMemoryLib_DIR)\X64\ZeroMem.obj +!ENDIF + +!IF "$(PROCESSOR)"=="IA32" +EdkIIGlueBaseMemoryLib_PORCESSOR_CIF=$(EdkIIGlueBaseMemoryLib_DIR)\Ia32\EdkIIGlueBaseMemoryLibIa32.cif +!ELSEIF "$(PROCESSOR)"=="x64" +EdkIIGlueBaseMemoryLib_PORCESSOR_PEI_CIF=$(EdkIIGlueBaseMemoryLib_DIR)\Ia32\EdkIIGlueBaseMemoryLibIa32.cif +EdkIIGlueBaseMemoryLib_PORCESSOR_DXE_CIF=$(EdkIIGlueBaseMemoryLib_DIR)\X64\EdkIIGlueBaseMemoryLibX64.cif +!ENDIF + +$(EdkIIGlueBaseMemoryLib_LIB) : EdkIIGlueBaseMemoryLib + +EdkIIGlueBaseMemoryLib : $(BUILD_DIR)\EdkIIGlueBaseMemoryLib.mak EdkIIGlueBaseMemoryLibBin + +!IF "$(PROCESSOR)"=="x64" +$(BUILD_DIR)\EdkIIGlueBaseMemoryLib.mak : $(EdkIIGlueBaseMemoryLib_DIR)\$(@B).cif $(EdkIIGlueBaseMemoryLib_DIR)\$(@B).mak $(BUILD_RULES) $(EdkIIGlueBaseMemoryLib_PORCESSOR_PEI_CIF) $(EdkIIGlueBaseMemoryLib_PORCESSOR_DXE_CIF) + $(CIF2MAK) $(EdkIIGlueBaseMemoryLib_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS) $(EdkIIGlueBaseMemoryLib_PORCESSOR_PEI_CIF) $(EdkIIGlueBaseMemoryLib_PORCESSOR_DXE_CIF) +!ELSE +$(BUILD_DIR)\EdkIIGlueBaseMemoryLib.mak : $(EdkIIGlueBaseMemoryLib_DIR)\$(@B).cif $(EdkIIGlueBaseMemoryLib_DIR)\$(@B).mak $(BUILD_RULES) $(EdkIIGlueBaseMemoryLib_PORCESSOR_CIF) + $(CIF2MAK) $(EdkIIGlueBaseMemoryLib_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS) $(EdkIIGlueBaseMemoryLib_PORCESSOR_CIF) +!ENDIF + +EdkIIGlueBaseMemoryLibBin : $(EdkIIGlueBaseLib_LIB) +!IF "$(x64_BUILD)"=="1" + $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\ + BUILD_DIR=$(BUILD_DIR)\ + /f $(BUILD_DIR)\EdkIIGlueBaseMemoryLib.mak all\ + TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueBaseMemoryLib_LIB)"\ + "OBJECTS=$(EdkIIGlueBaseMemoryLib_DXE_OBJECTS)" + $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\ + BUILD_DIR=$(BUILD_DIR)\IA32\ + /f $(BUILD_DIR)\EdkIIGlueBaseMemoryLib.mak all\ + TYPE=PEI_LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueBaseMemoryLib_LIB)"\ + "OBJECTS=$(EdkIIGlueBaseMemoryLib_PEI_OBJECTS)" +!ELSE + $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\ + BUILD_DIR=$(BUILD_DIR)\ + /f $(BUILD_DIR)\EdkIIGlueBaseMemoryLib.mak all\ + TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueBaseMemoryLib_LIB)"\ + "OBJECTS=$(EdkIIGlueBaseMemoryLib_OBJECTS)" +!ENDIF +#********************************************************************** +#********************************************************************** +#** ** +#** (C)Copyright 1985-2009, American Megatrends, Inc. ** +#** ** +#** All Rights Reserved. ** +#** ** +#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +#** ** +#** Phone: (770)-246-8600 ** +#** ** +#********************************************************************** +#********************************************************************** diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/EdkIIGlueBaseMemoryLib.sdl b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/EdkIIGlueBaseMemoryLib.sdl new file mode 100644 index 0000000..f4ea6ce --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/EdkIIGlueBaseMemoryLib.sdl @@ -0,0 +1,26 @@ +TOKEN + Name = "EdkIIGlueBaseMemoryLib_SUPPORT" + Value = "1" + Help = "Main switch to enable EdkIIGlueBaseMemoryLib support in Project" + TokenType = Boolean + TargetEQU = Yes + TargetMAK = Yes + Master = Yes +End + +TOKEN + Name = "EdkIIGlueBaseMemoryLib_LIB" + Value = "$$(LIB_BUILD_DIR)\EdkIIGlueBaseMemoryLib.lib" + TokenType = Expression + TargetMAK = Yes +End + +PATH + Name = "EdkIIGlueBaseMemoryLib_DIR" +End + +MODULE + Help = "Includes EdkIIGlueBaseMemoryLib.mak to Project" + File = "EdkIIGlueBaseMemoryLib.mak" +End + diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/Ia32/CompareMem.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/Ia32/CompareMem.asm new file mode 100644 index 0000000..d811ca9 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/Ia32/CompareMem.asm @@ -0,0 +1,54 @@ +;------------------------------------------------------------------------------ +; +; 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: +; +; CompareMem.Asm +; +; Abstract: +; +; CompareMem function +; +; Notes: +; +; The following BaseMemoryLib instances share the same version of this file: +; +; BaseMemoryLibRepStr +; BaseMemoryLibMmx +; BaseMemoryLibSse2 +; +;------------------------------------------------------------------------------ + + .686 + .model flat,C + .code + +;------------------------------------------------------------------------------ +; INTN +; EFIAPI +; InternalMemCompareMem ( +; IN CONST VOID *DestinationBuffer, +; IN CONST VOID *SourceBuffer, +; IN UINTN Length +; ); +;------------------------------------------------------------------------------ +InternalMemCompareMem PROC USES esi edi + mov esi, [esp + 12] + mov edi, [esp + 16] + mov ecx, [esp + 20] + repe cmpsb + movzx eax, byte ptr [esi - 1] + movzx edx, byte ptr [edi - 1] + sub eax, edx + ret +InternalMemCompareMem ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/Ia32/CopyMem.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/Ia32/CopyMem.asm new file mode 100644 index 0000000..6f818f0 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/Ia32/CopyMem.asm @@ -0,0 +1,63 @@ +;------------------------------------------------------------------------------ +; +; 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: +; +; CopyMem.Asm +; +; Abstract: +; +; CopyMem function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .386 + .model flat,C + .code + +;------------------------------------------------------------------------------ +; VOID * +; InternalMemCopyMem ( +; IN VOID *Destination, +; IN VOID *Source, +; IN UINTN Count +; ) +;------------------------------------------------------------------------------ +InternalMemCopyMem PROC USES esi edi + mov esi, [esp + 16] ; esi <- Source + mov edi, [esp + 12] ; edi <- Destination + mov edx, [esp + 20] ; edx <- Count + lea eax, [esi + edx - 1] ; eax <- End of Source + cmp esi, edi + jae @F + cmp eax, edi + jae @CopyBackward ; Copy backward if overlapped +@@: + mov ecx, edx + and edx, 3 + shr ecx, 2 + rep movsd ; Copy as many Dwords as possible + jmp @CopyBytes +@CopyBackward: + mov esi, eax ; esi <- End of Source + lea edi, [edi + edx - 1] ; edi <- End of Destination + std +@CopyBytes: + mov ecx, edx + rep movsb ; Copy bytes backward + cld + mov eax, [esp + 12] ; eax <- Destination as return value + ret +InternalMemCopyMem ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/Ia32/EdkIIGlueBaseMemoryLibIA32.cif b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/Ia32/EdkIIGlueBaseMemoryLibIA32.cif new file mode 100644 index 0000000..84776e8 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/Ia32/EdkIIGlueBaseMemoryLibIA32.cif @@ -0,0 +1,18 @@ +<component> + name = "EdkIIGlueBaseMemoryLibIa32" + category = ModulePart + LocalRoot = "Edk\Foundation\Library\EdkIIGlueLib\Library\BaseMemoryLib\Ia32" + RefName = "EdkIIGlueBaseMemoryLibIa32" +[files] +"CompareMem.asm" +"CopyMem.asm" +"ScanMem16.asm" +"ScanMem32.asm" +"ScanMem64.asm" +"ScanMem8.asm" +"SetMem.asm" +"SetMem16.asm" +"SetMem32.asm" +"SetMem64.asm" +"ZeroMem.asm" +<endComponent> diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/Ia32/ScanMem16.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/Ia32/ScanMem16.asm new file mode 100644 index 0000000..8143e03 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/Ia32/ScanMem16.asm @@ -0,0 +1,53 @@ +;------------------------------------------------------------------------------ +; +; 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: +; +; ScanMem16.Asm +; +; Abstract: +; +; ScanMem16 function +; +; Notes: +; +; The following BaseMemoryLib instances share the same version of this file: +; +; BaseMemoryLibRepStr +; BaseMemoryLibMmx +; BaseMemoryLibSse2 +; +;------------------------------------------------------------------------------ + + .686 + .model flat,C + .code + +;------------------------------------------------------------------------------ +; CONST VOID * +; EFIAPI +; InternalMemScanMem16 ( +; IN CONST VOID *Buffer, +; IN UINTN Length, +; IN UINT16 Value +; ); +;------------------------------------------------------------------------------ +InternalMemScanMem16 PROC USES edi + mov ecx, [esp + 12] + mov edi, [esp + 8] + mov eax, [esp + 16] + repne scasw + lea eax, [edi - 2] + cmovnz eax, ecx + ret +InternalMemScanMem16 ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/Ia32/ScanMem32.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/Ia32/ScanMem32.asm new file mode 100644 index 0000000..1d22040 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/Ia32/ScanMem32.asm @@ -0,0 +1,53 @@ +;------------------------------------------------------------------------------ +; +; 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: +; +; ScanMem32.Asm +; +; Abstract: +; +; ScanMem32 function +; +; Notes: +; +; The following BaseMemoryLib instances share the same version of this file: +; +; BaseMemoryLibRepStr +; BaseMemoryLibMmx +; BaseMemoryLibSse2 +; +;------------------------------------------------------------------------------ + + .686 + .model flat,C + .code + +;------------------------------------------------------------------------------ +; CONST VOID * +; EFIAPI +; InternalMemScanMem32 ( +; IN CONST VOID *Buffer, +; IN UINTN Length, +; IN UINT32 Value +; ); +;------------------------------------------------------------------------------ +InternalMemScanMem32 PROC USES edi + mov ecx, [esp + 12] + mov edi, [esp + 8] + mov eax, [esp + 16] + repne scasd + lea eax, [edi - 4] + cmovnz eax, ecx + ret +InternalMemScanMem32 ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/Ia32/ScanMem64.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/Ia32/ScanMem64.asm new file mode 100644 index 0000000..ae4e6ce --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/Ia32/ScanMem64.asm @@ -0,0 +1,62 @@ +;------------------------------------------------------------------------------ +; +; 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: +; +; ScanMem64.Asm +; +; Abstract: +; +; ScanMem64 function +; +; Notes: +; +; The following BaseMemoryLib instances share the same version of this file: +; +; BaseMemoryLibRepStr +; BaseMemoryLibMmx +; BaseMemoryLibSse2 +; +;------------------------------------------------------------------------------ + + .686 + .model flat,C + .code + +;------------------------------------------------------------------------------ +; CONST VOID * +; EFIAPI +; InternalMemScanMem64 ( +; IN CONST VOID *Buffer, +; IN UINTN Length, +; IN UINT64 Value +; ); +;------------------------------------------------------------------------------ +InternalMemScanMem64 PROC USES edi + mov ecx, [esp + 12] + mov eax, [esp + 16] + mov edx, [esp + 20] + mov edi, [esp + 8] +@@: + cmp eax, [edi] + lea edi, [edi + 8] + loopne @B + jne @F + cmp edx, [edi - 4] + jecxz @F + jne @B +@@: + lea eax, [edi - 8] + cmovne eax, ecx + ret +InternalMemScanMem64 ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/Ia32/ScanMem8.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/Ia32/ScanMem8.asm new file mode 100644 index 0000000..8420b74 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/Ia32/ScanMem8.asm @@ -0,0 +1,53 @@ +;------------------------------------------------------------------------------ +; +; 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: +; +; ScanMem8.Asm +; +; Abstract: +; +; ScanMem8 function +; +; Notes: +; +; The following BaseMemoryLib instances share the same version of this file: +; +; BaseMemoryLibRepStr +; BaseMemoryLibMmx +; BaseMemoryLibSse2 +; +;------------------------------------------------------------------------------ + + .686 + .model flat,C + .code + +;------------------------------------------------------------------------------ +; CONST VOID * +; EFIAPI +; InternalMemScanMem8 ( +; IN CONST VOID *Buffer, +; IN UINTN Length, +; IN UINT8 Value +; ); +;------------------------------------------------------------------------------ +InternalMemScanMem8 PROC USES edi + mov ecx, [esp + 12] + mov edi, [esp + 8] + mov al, [esp + 16] + repne scasb + lea eax, [edi - 1] + cmovnz eax, ecx + ret +InternalMemScanMem8 ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/Ia32/SetMem.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/Ia32/SetMem.asm new file mode 100644 index 0000000..fc26b94 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/Ia32/SetMem.asm @@ -0,0 +1,45 @@ +;------------------------------------------------------------------------------ +; +; 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: +; +; SetMem.Asm +; +; Abstract: +; +; SetMem function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .386 + .model flat,C + .code + +;------------------------------------------------------------------------------ +; VOID * +; InternalMemSetMem ( +; IN VOID *Buffer, +; IN UINTN Count, +; IN UINT8 Value +; ) +;------------------------------------------------------------------------------ +InternalMemSetMem PROC USES edi + mov eax, [esp + 16] + mov edi, [esp + 8] + mov ecx, [esp + 12] + rep stosb + mov eax, [esp + 8] + ret +InternalMemSetMem ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/Ia32/SetMem16.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/Ia32/SetMem16.asm new file mode 100644 index 0000000..fd52154 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/Ia32/SetMem16.asm @@ -0,0 +1,45 @@ +;------------------------------------------------------------------------------ +; +; 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: +; +; SetMem16.Asm +; +; Abstract: +; +; SetMem16 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .386 + .model flat,C + .code + +;------------------------------------------------------------------------------ +; VOID * +; InternalMemSetMem16 ( +; IN VOID *Buffer, +; IN UINTN Count, +; IN UINT16 Value +; ) +;------------------------------------------------------------------------------ +InternalMemSetMem16 PROC USES edi + mov eax, [esp + 16] + mov edi, [esp + 8] + mov ecx, [esp + 12] + rep stosw + mov eax, [esp + 8] + ret +InternalMemSetMem16 ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/Ia32/SetMem32.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/Ia32/SetMem32.asm new file mode 100644 index 0000000..2c58ef3 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/Ia32/SetMem32.asm @@ -0,0 +1,45 @@ +;------------------------------------------------------------------------------ +; +; 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: +; +; SetMem32.Asm +; +; Abstract: +; +; SetMem32 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .386 + .model flat,C + .code + +;------------------------------------------------------------------------------ +; VOID * +; InternalMemSetMem32 ( +; IN VOID *Buffer, +; IN UINTN Count, +; IN UINT32 Value +; ) +;------------------------------------------------------------------------------ +InternalMemSetMem32 PROC USES edi + mov eax, [esp + 16] + mov edi, [esp + 8] + mov ecx, [esp + 12] + rep stosd + mov eax, [esp + 8] + ret +InternalMemSetMem32 ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/Ia32/SetMem64.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/Ia32/SetMem64.asm new file mode 100644 index 0000000..f379810 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/Ia32/SetMem64.asm @@ -0,0 +1,49 @@ +;------------------------------------------------------------------------------ +; +; 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: +; +; SetMem64.Asm +; +; Abstract: +; +; SetMem64 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .386 + .model flat,C + .code + +;------------------------------------------------------------------------------ +; VOID * +; InternalMemSetMem64 ( +; IN VOID *Buffer, +; IN UINTN Count, +; IN UINT64 Value +; ) +;------------------------------------------------------------------------------ +InternalMemSetMem64 PROC USES edi + mov ecx, [esp + 12] + mov eax, [esp + 16] + mov edx, [esp + 20] + mov edi, [esp + 8] +@@: + mov [edi + ecx*8 - 8], eax + mov [edi + ecx*8 - 4], edx + loop @B + mov eax, edi + ret +InternalMemSetMem64 ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/Ia32/ZeroMem.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/Ia32/ZeroMem.asm new file mode 100644 index 0000000..8419ead --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/Ia32/ZeroMem.asm @@ -0,0 +1,50 @@ +;------------------------------------------------------------------------------ +; +; 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: +; +; ZeroMem.Asm +; +; Abstract: +; +; ZeroMem function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .386 + .model flat,C + .code + +;------------------------------------------------------------------------------ +; VOID * +; InternalMemZeroMem ( +; IN VOID *Buffer, +; IN UINTN Count +; ); +;------------------------------------------------------------------------------ +InternalMemZeroMem PROC USES edi + xor eax, eax + mov edi, [esp + 8] + mov ecx, [esp + 12] + mov edx, ecx + shr ecx, 2 + and edx, 3 + push edi + rep stosd + mov ecx, edx + rep stosb + pop eax + ret +InternalMemZeroMem ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/Ipf/CopyMem.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/Ipf/CopyMem.c new file mode 100644 index 0000000..17ea273 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/Ipf/CopyMem.c @@ -0,0 +1,65 @@ +/*++ + +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: + + CopyMem.c + +Abstract: + + Internal CopyMem + +--*/ + +#include "BaseMemoryLibInternal.h" + +/** + Copy Length bytes from Source to Destination. + + @param Destination Target of copy + @param Source Place to copy from + @param Length Number of bytes to copy + + @return Destination + +**/ +VOID * +EFIAPI +InternalMemCopyMem ( + OUT VOID *Destination, + IN CONST VOID *Source, + IN UINTN Length + ) +{ + // + // Declare the local variables that actually move the data elements as + // volatile to prevent the optimizer from replacing this function with + // the intrinsic memcpy() + // + volatile UINT8 *Destination8; + CONST UINT8 *Source8; + + if (Source > Destination) { + Destination8 = (UINT8*)Destination; + Source8 = (CONST UINT8*)Source; + while (Length-- != 0) { + *(Destination8++) = *(Source8++); + } + } else if (Source < Destination) { + Destination8 = (UINT8*)Destination + Length; + Source8 = (CONST UINT8*)Source + Length; + while (Length-- != 0) { + *(--Destination8) = *(--Source8); + } + } + return Destination; +} diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/Ipf/MemLibGeneric.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/Ipf/MemLibGeneric.c new file mode 100644 index 0000000..284a492 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/Ipf/MemLibGeneric.c @@ -0,0 +1,261 @@ +/*++ + +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: + + MemLibGeneric.c + +Abstract: + + Architecture Independent Base Memory Library Implementation. + +--*/ + +#include "BaseMemoryLibInternal.h" + +/** + Fills a target buffer with a 16-bit value, and returns the target buffer. + + @param Buffer Pointer to the target buffer to fill. + @param Length Number of bytes in Buffer to fill. + @param Value Value with which to fill Length bytes of Buffer. + + @return Buffer + +**/ +VOID * +EFIAPI +InternalMemSetMem16 ( + OUT VOID *Buffer, + IN UINTN Length, + IN UINT16 Value + ) +{ + do { + ((UINT16*)Buffer)[--Length] = Value; + } while (Length != 0); + return Buffer; +} + +/** + Fills a target buffer with a 32-bit value, and returns the target buffer. + + @param Buffer Pointer to the target buffer to fill. + @param Length Number of bytes in Buffer to fill. + @param Value Value with which to fill Length bytes of Buffer. + + @return Buffer + +**/ +VOID * +EFIAPI +InternalMemSetMem32 ( + OUT VOID *Buffer, + IN UINTN Length, + IN UINT32 Value + ) +{ + do { + ((UINT32*)Buffer)[--Length] = Value; + } while (Length != 0); + return Buffer; +} + +/** + Fills a target buffer with a 64-bit value, and returns the target buffer. + + @param Buffer Pointer to the target buffer to fill. + @param Length Number of bytes in Buffer to fill. + @param Value Value with which to fill Length bytes of Buffer. + + @return Buffer + +**/ +VOID * +EFIAPI +InternalMemSetMem64 ( + OUT VOID *Buffer, + IN UINTN Length, + IN UINT64 Value + ) +{ + do { + ((UINT64*)Buffer)[--Length] = Value; + } while (Length != 0); + return Buffer; +} + +/** + Set Buffer to 0 for Size bytes. + + @param Buffer Memory to set. + @param Size Number of bytes to set + + @return Buffer + +**/ +VOID * +EFIAPI +InternalMemZeroMem ( + OUT VOID *Buffer, + IN UINTN Length + ) +{ + return InternalMemSetMem (Buffer, Length, 0); +} + +/** + Compares two memory buffers of a given length. + + @param DestinationBuffer First memory buffer + @param SourceBuffer Second memory buffer + @param Length Length of DestinationBuffer and SourceBuffer memory + regions to compare. Must be non-zero. + + @retval 0 if MemOne == MemTwo + +**/ +INTN +EFIAPI +InternalMemCompareMem ( + IN CONST VOID *DestinationBuffer, + IN CONST VOID *SourceBuffer, + IN UINTN Length + ) +{ + while ((--Length != 0) && + (*(INT8*)DestinationBuffer == *(INT8*)SourceBuffer)) { + DestinationBuffer = (INT8*)DestinationBuffer + 1; + SourceBuffer = (INT8*)SourceBuffer + 1; + } + return (INTN)*(UINT8*)DestinationBuffer - (INTN)*(UINT8*)SourceBuffer; +} + +/** + Scans a target buffer for an 8-bit value, and returns a pointer to the + matching 8-bit value in the target buffer. + + @param Buffer Pointer to the target buffer to scan. + @param Length Number of bytes in Buffer to scan. Must be non-zero. + @param Value Value to search for in the target buffer. + + @return Pointer to the first occurrence or NULL if not found. + +**/ +CONST VOID * +EFIAPI +InternalMemScanMem8 ( + IN CONST VOID *Buffer, + IN UINTN Length, + IN UINT8 Value + ) +{ + CONST UINT8 *Pointer; + + Pointer = (CONST UINT8*)Buffer; + do { + if (*(Pointer++) == Value) { + return Pointer; + } + } while (--Length != 0); + return NULL; +} + +/** + Scans a target buffer for a 16-bit value, and returns a pointer to the + matching 16-bit value in the target buffer. + + @param Buffer Pointer to the target buffer to scan. + @param Length Number of bytes in Buffer to scan. Must be non-zero. + @param Value Value to search for in the target buffer. + + @return Pointer to the first occurrence or NULL if not found. + +**/ +CONST VOID * +EFIAPI +InternalMemScanMem16 ( + IN CONST VOID *Buffer, + IN UINTN Length, + IN UINT16 Value + ) +{ + CONST UINT16 *Pointer; + + Pointer = (CONST UINT16*)Buffer; + do { + if (*(Pointer++) == Value) { + return Pointer; + } + } while (--Length != 0); + return NULL; +} + +/** + Scans a target buffer for a 32-bit value, and returns a pointer to the + matching 32-bit value in the target buffer. + + @param Buffer Pointer to the target buffer to scan. + @param Length Number of bytes in Buffer to scan. Must be non-zero. + @param Value Value to search for in the target buffer. + + @return Pointer to the first occurrence or NULL if not found. + +**/ +CONST VOID * +EFIAPI +InternalMemScanMem32 ( + IN CONST VOID *Buffer, + IN UINTN Length, + IN UINT32 Value + ) +{ + CONST UINT32 *Pointer; + + Pointer = (CONST UINT32*)Buffer; + do { + if (*(Pointer++) == Value) { + return Pointer; + } + } while (--Length != 0); + return NULL; +} + +/** + Scans a target buffer for a 64-bit value, and returns a pointer to the + matching 64-bit value in the target buffer. + + @param Buffer Pointer to the target buffer to scan. + @param Length Number of bytes in Buffer to scan. Must be non-zero. + @param Value Value to search for in the target buffer. + + @return Pointer to the first occurrence or NULL if not found. + +**/ +CONST VOID * +EFIAPI +InternalMemScanMem64 ( + IN CONST VOID *Buffer, + IN UINTN Length, + IN UINT64 Value + ) +{ + CONST UINT64 *Pointer; + + Pointer = (CONST UINT64*)Buffer; + do { + if (*(Pointer++) == Value) { + return Pointer; + } + } while (--Length != 0); + return NULL; +} diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/Ipf/SetMem.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/Ipf/SetMem.c new file mode 100644 index 0000000..9c94c91 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/Ipf/SetMem.c @@ -0,0 +1,55 @@ +/*++ + +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: + + SetMem.c + +Abstract: + + Internal SetMem + +--*/ + +#include "BaseMemoryLibInternal.h" + +/** + Set Buffer to Value for Size bytes. + + @param Buffer Memory to set. + @param Size Number of bytes to set + @param Value Value of the set operation. + + @return Buffer + +**/ +VOID * +EFIAPI +InternalMemSetMem ( + IN VOID *Buffer, + IN UINTN Size, + IN UINT8 Value + ) +{ + // + // Declare the local variables that actually move the data elements as + // volatile to prevent the optimizer from replacing this function with + // the intrinsic memset() + // + volatile UINT8 *Pointer; + + Pointer = (UINT8*)Buffer; + while (Size-- != 0) { + *(Pointer++) = Value; + } + return Buffer; +} diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/MemLibGeneric.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/MemLibGeneric.c new file mode 100644 index 0000000..284a492 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/MemLibGeneric.c @@ -0,0 +1,261 @@ +/*++ + +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: + + MemLibGeneric.c + +Abstract: + + Architecture Independent Base Memory Library Implementation. + +--*/ + +#include "BaseMemoryLibInternal.h" + +/** + Fills a target buffer with a 16-bit value, and returns the target buffer. + + @param Buffer Pointer to the target buffer to fill. + @param Length Number of bytes in Buffer to fill. + @param Value Value with which to fill Length bytes of Buffer. + + @return Buffer + +**/ +VOID * +EFIAPI +InternalMemSetMem16 ( + OUT VOID *Buffer, + IN UINTN Length, + IN UINT16 Value + ) +{ + do { + ((UINT16*)Buffer)[--Length] = Value; + } while (Length != 0); + return Buffer; +} + +/** + Fills a target buffer with a 32-bit value, and returns the target buffer. + + @param Buffer Pointer to the target buffer to fill. + @param Length Number of bytes in Buffer to fill. + @param Value Value with which to fill Length bytes of Buffer. + + @return Buffer + +**/ +VOID * +EFIAPI +InternalMemSetMem32 ( + OUT VOID *Buffer, + IN UINTN Length, + IN UINT32 Value + ) +{ + do { + ((UINT32*)Buffer)[--Length] = Value; + } while (Length != 0); + return Buffer; +} + +/** + Fills a target buffer with a 64-bit value, and returns the target buffer. + + @param Buffer Pointer to the target buffer to fill. + @param Length Number of bytes in Buffer to fill. + @param Value Value with which to fill Length bytes of Buffer. + + @return Buffer + +**/ +VOID * +EFIAPI +InternalMemSetMem64 ( + OUT VOID *Buffer, + IN UINTN Length, + IN UINT64 Value + ) +{ + do { + ((UINT64*)Buffer)[--Length] = Value; + } while (Length != 0); + return Buffer; +} + +/** + Set Buffer to 0 for Size bytes. + + @param Buffer Memory to set. + @param Size Number of bytes to set + + @return Buffer + +**/ +VOID * +EFIAPI +InternalMemZeroMem ( + OUT VOID *Buffer, + IN UINTN Length + ) +{ + return InternalMemSetMem (Buffer, Length, 0); +} + +/** + Compares two memory buffers of a given length. + + @param DestinationBuffer First memory buffer + @param SourceBuffer Second memory buffer + @param Length Length of DestinationBuffer and SourceBuffer memory + regions to compare. Must be non-zero. + + @retval 0 if MemOne == MemTwo + +**/ +INTN +EFIAPI +InternalMemCompareMem ( + IN CONST VOID *DestinationBuffer, + IN CONST VOID *SourceBuffer, + IN UINTN Length + ) +{ + while ((--Length != 0) && + (*(INT8*)DestinationBuffer == *(INT8*)SourceBuffer)) { + DestinationBuffer = (INT8*)DestinationBuffer + 1; + SourceBuffer = (INT8*)SourceBuffer + 1; + } + return (INTN)*(UINT8*)DestinationBuffer - (INTN)*(UINT8*)SourceBuffer; +} + +/** + Scans a target buffer for an 8-bit value, and returns a pointer to the + matching 8-bit value in the target buffer. + + @param Buffer Pointer to the target buffer to scan. + @param Length Number of bytes in Buffer to scan. Must be non-zero. + @param Value Value to search for in the target buffer. + + @return Pointer to the first occurrence or NULL if not found. + +**/ +CONST VOID * +EFIAPI +InternalMemScanMem8 ( + IN CONST VOID *Buffer, + IN UINTN Length, + IN UINT8 Value + ) +{ + CONST UINT8 *Pointer; + + Pointer = (CONST UINT8*)Buffer; + do { + if (*(Pointer++) == Value) { + return Pointer; + } + } while (--Length != 0); + return NULL; +} + +/** + Scans a target buffer for a 16-bit value, and returns a pointer to the + matching 16-bit value in the target buffer. + + @param Buffer Pointer to the target buffer to scan. + @param Length Number of bytes in Buffer to scan. Must be non-zero. + @param Value Value to search for in the target buffer. + + @return Pointer to the first occurrence or NULL if not found. + +**/ +CONST VOID * +EFIAPI +InternalMemScanMem16 ( + IN CONST VOID *Buffer, + IN UINTN Length, + IN UINT16 Value + ) +{ + CONST UINT16 *Pointer; + + Pointer = (CONST UINT16*)Buffer; + do { + if (*(Pointer++) == Value) { + return Pointer; + } + } while (--Length != 0); + return NULL; +} + +/** + Scans a target buffer for a 32-bit value, and returns a pointer to the + matching 32-bit value in the target buffer. + + @param Buffer Pointer to the target buffer to scan. + @param Length Number of bytes in Buffer to scan. Must be non-zero. + @param Value Value to search for in the target buffer. + + @return Pointer to the first occurrence or NULL if not found. + +**/ +CONST VOID * +EFIAPI +InternalMemScanMem32 ( + IN CONST VOID *Buffer, + IN UINTN Length, + IN UINT32 Value + ) +{ + CONST UINT32 *Pointer; + + Pointer = (CONST UINT32*)Buffer; + do { + if (*(Pointer++) == Value) { + return Pointer; + } + } while (--Length != 0); + return NULL; +} + +/** + Scans a target buffer for a 64-bit value, and returns a pointer to the + matching 64-bit value in the target buffer. + + @param Buffer Pointer to the target buffer to scan. + @param Length Number of bytes in Buffer to scan. Must be non-zero. + @param Value Value to search for in the target buffer. + + @return Pointer to the first occurrence or NULL if not found. + +**/ +CONST VOID * +EFIAPI +InternalMemScanMem64 ( + IN CONST VOID *Buffer, + IN UINTN Length, + IN UINT64 Value + ) +{ + CONST UINT64 *Pointer; + + Pointer = (CONST UINT64*)Buffer; + do { + if (*(Pointer++) == Value) { + return Pointer; + } + } while (--Length != 0); + return NULL; +} diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/MemLibGuid.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/MemLibGuid.c new file mode 100644 index 0000000..7f752d4 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/MemLibGuid.c @@ -0,0 +1,130 @@ +/*++ + +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: + + MemLibGuid.c + +Abstract: + + Implementation of GUID functions. + +--*/ + +#include "BaseMemoryLibInternal.h" + +/** + Copies a source GUID to a destination GUID. + + This function copies the contents of the 128-bit GUID specified by SourceGuid to + DestinationGuid, and returns DestinationGuid. + If DestinationGuid is NULL, then ASSERT(). + If SourceGuid is NULL, then ASSERT(). + + @param DestinationGuid Pointer to the destination GUID. + @param SourceGuid Pointer to the source GUID. + + @return DestinationGuid. + +**/ +GUID * +EFIAPI +CopyGuid ( + OUT GUID *DestinationGuid, + IN CONST GUID *SourceGuid + ) +{ + WriteUnaligned64 ( + (UINT64*)DestinationGuid, + ReadUnaligned64 ((CONST UINT64*)SourceGuid) + ); + WriteUnaligned64 ( + (UINT64*)DestinationGuid + 1, + ReadUnaligned64 ((CONST UINT64*)SourceGuid + 1) + ); + return DestinationGuid; +} + +/** + Compares two GUIDs. + + This function compares Guid1 to Guid2. If the GUIDs are identical then TRUE is returned. + If there are any bit differences in the two GUIDs, then FALSE is returned. + If Guid1 is NULL, then ASSERT(). + If Guid2 is NULL, then ASSERT(). + + @param Guid1 A pointer to a 128 bit GUID. + @param Guid2 A pointer to a 128 bit GUID. + + @retval TRUE Guid1 and Guid2 are identical. + @retval FALSE Guid1 and Guid2 are not identical. + +**/ +BOOLEAN +EFIAPI +GlueCompareGuid ( + IN CONST GUID *Guid1, + IN CONST GUID *Guid2 + ) +{ + return (BOOLEAN)( + ReadUnaligned64 ((CONST UINT64*)Guid1) + == ReadUnaligned64 ((CONST UINT64*)Guid2) && + ReadUnaligned64 ((CONST UINT64*)Guid1 + 1) + == ReadUnaligned64 ((CONST UINT64*)Guid2 + 1) + ); +} + +/** + Scans a target buffer for a GUID, and returns a pointer to the matching GUID + in the target buffer. + + This function searches target the buffer specified by Buffer and Length from + the lowest address to the highest address at 128-bit increments for the 128-bit + GUID value that matches Guid. If a match is found, then a pointer to the matching + GUID in the target buffer is returned. If no match is found, then NULL is returned. + If Length is 0, then NULL is returned. + If Length > 0 and Buffer is NULL, then ASSERT(). + If Buffer is not aligned on a 32-bit boundary, then ASSERT(). + If Length is not aligned on a 128-bit boundary, then ASSERT(). + If Length is greater than (MAX_ADDRESS ?Buffer + 1), then ASSERT(). + + @param Buffer Pointer to the target buffer to scan. + @param Length Number of bytes in Buffer to scan. + @param Guid Value to search for in the target buffer. + + @return A pointer to the matching Guid in the target buffer or NULL otherwise. + +**/ +VOID * +EFIAPI +ScanGuid ( + IN CONST VOID *Buffer, + IN UINTN Length, + IN CONST GUID *Guid + ) +{ + CONST GUID *GuidPtr; + + ASSERT (((UINTN)Buffer & (sizeof (Guid->Data1) - 1)) == 0); + ASSERT (Length <= (MAX_ADDRESS - (UINTN)Buffer + 1)); + ASSERT ((Length & (sizeof (*GuidPtr) - 1)) == 0); + + GuidPtr = (GUID*)Buffer; + Buffer = GuidPtr + Length / sizeof (*GuidPtr); + while (GuidPtr < (CONST GUID*)Buffer) { + if (CompareGuid (GuidPtr, Guid)) { + return (VOID*)GuidPtr; + } + GuidPtr++; + } + return NULL; +} diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/ScanMem16Wrapper.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/ScanMem16Wrapper.c new file mode 100644 index 0000000..9a93479 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/ScanMem16Wrapper.c @@ -0,0 +1,63 @@ +/*++ + +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: + + ScanMem16Wrapper.c + +Abstract: + + ScanMem16() implementation. + +--*/ + +#include "BaseMemoryLibInternal.h" + +/** + Scans a target buffer for a 16-bit value, and returns a pointer to the matching 16-bit value + in the target buffer. + + This function searches target the buffer specified by Buffer and Length from the lowest + address to the highest address for a 16-bit value that matches Value. If a match is found, + then a pointer to the matching byte in the target buffer is returned. If no match is found, + then NULL is returned. If Length is 0, then NULL is returned. + If Length > 0 and Buffer is NULL, then ASSERT(). + If Buffer is not aligned on a 16-bit boundary, then ASSERT(). + If Length is not aligned on a 16-bit boundary, then ASSERT(). + If Length is greater than (MAX_ADDRESS ?Buffer + 1), then ASSERT(). + + @param Buffer Pointer to the target buffer to scan. + @param Length Number of bytes in Buffer to scan. + @param Value Value to search for in the target buffer. + + @return A pointer to the matching byte in the target buffer or NULL otherwise. + +**/ +VOID * +EFIAPI +ScanMem16 ( + IN CONST VOID *Buffer, + IN UINTN Length, + IN UINT16 Value + ) +{ + if (Length == 0) { + return NULL; + } + + ASSERT (Buffer != NULL); + ASSERT (((UINTN)Buffer & (sizeof (Value) - 1)) == 0); + ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN)Buffer)); + ASSERT ((Length & (sizeof (Value) - 1)) == 0); + + return (VOID*)InternalMemScanMem16 (Buffer, Length / sizeof (Value), Value); +} diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/ScanMem32Wrapper.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/ScanMem32Wrapper.c new file mode 100644 index 0000000..42e7dd0 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/ScanMem32Wrapper.c @@ -0,0 +1,63 @@ +/*++ + +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: + + ScanMem32Wrapper.c + +Abstract: + + ScanMem32() implementation. + +--*/ + +#include "BaseMemoryLibInternal.h" + +/** + Scans a target buffer for a 32-bit value, and returns a pointer to the matching 32-bit value + in the target buffer. + + This function searches target the buffer specified by Buffer and Length from the lowest + address to the highest address for a 32-bit value that matches Value. If a match is found, + then a pointer to the matching byte in the target buffer is returned. If no match is found, + then NULL is returned. If Length is 0, then NULL is returned. + If Length > 0 and Buffer is NULL, then ASSERT(). + If Buffer is not aligned on a 32-bit boundary, then ASSERT(). + If Length is not aligned on a 32-bit boundary, then ASSERT(). + If Length is greater than (MAX_ADDRESS ?Buffer + 1), then ASSERT(). + + @param Buffer Pointer to the target buffer to scan. + @param Length Number of bytes in Buffer to scan. + @param Value Value to search for in the target buffer. + + @return A pointer to the matching byte in the target buffer or NULL otherwise. + +**/ +VOID * +EFIAPI +ScanMem32 ( + IN CONST VOID *Buffer, + IN UINTN Length, + IN UINT32 Value + ) +{ + if (Length == 0) { + return NULL; + } + + ASSERT (Buffer != NULL); + ASSERT (((UINTN)Buffer & (sizeof (Value) - 1)) == 0); + ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN)Buffer)); + ASSERT ((Length & (sizeof (Value) - 1)) == 0); + + return (VOID*)InternalMemScanMem32 (Buffer, Length / sizeof (Value), Value); +} diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/ScanMem64Wrapper.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/ScanMem64Wrapper.c new file mode 100644 index 0000000..c7b39f5 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/ScanMem64Wrapper.c @@ -0,0 +1,62 @@ +/*++ + +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: + + ScanMem64Wrapper.c + +Abstract: + + ScanMem64() implementation. + +--*/ + +#include "BaseMemoryLibInternal.h" + +/** + Scans a target buffer for a 64-bit value, and returns a pointer to the matching 64-bit value + in the target buffer. + + This function searches target the buffer specified by Buffer and Length from the lowest + address to the highest address for a 64-bit value that matches Value. If a match is found, + then a pointer to the matching byte in the target buffer is returned. If no match is found, + then NULL is returned. If Length is 0, then NULL is returned. + If Length > 0 and Buffer is NULL, then ASSERT(). + If Buffer is not aligned on a 64-bit boundary, then ASSERT(). + If Length is not aligned on a 64-bit boundary, then ASSERT(). + If Length is greater than (MAX_ADDRESS ?Buffer + 1), then ASSERT(). + + @param Buffer Pointer to the target buffer to scan. + @param Length Number of bytes in Buffer to scan. + @param Value Value to search for in the target buffer. + + @return A pointer to the matching byte in the target buffer or NULL otherwise. + +**/ +VOID * +EFIAPI +ScanMem64 ( + IN CONST VOID *Buffer, + IN UINTN Length, + IN UINT64 Value + ) +{ + if (Length == 0) { + return NULL; + } + + ASSERT (Buffer != NULL); + ASSERT (((UINTN)Buffer & (sizeof (Value) - 1)) == 0); + ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN)Buffer)); + ASSERT ((Length & (sizeof (Value) - 1)) == 0); + + return (VOID*)InternalMemScanMem64 (Buffer, Length / sizeof (Value), Value); +} diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/ScanMem8Wrapper.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/ScanMem8Wrapper.c new file mode 100644 index 0000000..084526b --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/ScanMem8Wrapper.c @@ -0,0 +1,57 @@ +/*++ + +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: + + ScanMem8Wrapper.c + +Abstract: + + ScanMem8() implementation. + +--*/ + +#include "BaseMemoryLibInternal.h" + +/** + Scans a target buffer for an 8-bit value, and returns a pointer to the matching 8-bit value + in the target buffer. + + This function searches target the buffer specified by Buffer and Length from the lowest + address to the highest address for an 8-bit value that matches Value. If a match is found, + then a pointer to the matching byte in the target buffer is returned. If no match is found, + then NULL is returned. If Length is 0, then NULL is returned. + If Length > 0 and Buffer is NULL, then ASSERT(). + If Length is greater than (MAX_ADDRESS ?Buffer + 1), then ASSERT(). + + @param Buffer Pointer to the target buffer to scan. + @param Length Number of bytes in Buffer to scan. + @param Value Value to search for in the target buffer. + + @return A pointer to the matching byte in the target buffer or NULL otherwise. + +**/ +VOID * +EFIAPI +ScanMem8 ( + IN CONST VOID *Buffer, + IN UINTN Length, + IN UINT8 Value + ) +{ + if (Length == 0) { + return NULL; + } + ASSERT (Buffer != NULL); + ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN)Buffer)); + + return (VOID*)InternalMemScanMem8 (Buffer, Length, Value); +} diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/SetMem.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/SetMem.c new file mode 100644 index 0000000..9c94c91 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/SetMem.c @@ -0,0 +1,55 @@ +/*++ + +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: + + SetMem.c + +Abstract: + + Internal SetMem + +--*/ + +#include "BaseMemoryLibInternal.h" + +/** + Set Buffer to Value for Size bytes. + + @param Buffer Memory to set. + @param Size Number of bytes to set + @param Value Value of the set operation. + + @return Buffer + +**/ +VOID * +EFIAPI +InternalMemSetMem ( + IN VOID *Buffer, + IN UINTN Size, + IN UINT8 Value + ) +{ + // + // Declare the local variables that actually move the data elements as + // volatile to prevent the optimizer from replacing this function with + // the intrinsic memset() + // + volatile UINT8 *Pointer; + + Pointer = (UINT8*)Buffer; + while (Size-- != 0) { + *(Pointer++) = Value; + } + return Buffer; +} diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/SetMem16Wrapper.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/SetMem16Wrapper.c new file mode 100644 index 0000000..729d439 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/SetMem16Wrapper.c @@ -0,0 +1,61 @@ +/*++ + +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: + + SetMem16Wrapper.c + +Abstract: + + SetMem16() implementation. + +--*/ + +#include "BaseMemoryLibInternal.h" + +/** + Fills a target buffer with a 16-bit value, and returns the target buffer. + + This function fills Length bytes of Buffer with the 16-bit value specified by + Value, and returns Buffer. Value is repeated every 16-bits in for Length + bytes of Buffer. + + If Length > 0 and Buffer is NULL, then ASSERT(). + If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). + If Buffer is not aligned on a 16-bit boundary, then ASSERT(). + If Length is not aligned on a 16-bit boundary, then ASSERT(). + + @param Buffer Pointer to the target buffer to fill. + @param Length Number of bytes in Buffer to fill. + @param Value Value with which to fill Length bytes of Buffer. + + @return Buffer. + +**/ +VOID * +EFIAPI +SetMem16 ( + OUT VOID *Buffer, + IN UINTN Length, + IN UINT16 Value + ) +{ + if (Length == 0) { + return Buffer; + } + + ASSERT (Buffer != NULL); + ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN)Buffer)); + ASSERT ((((UINTN)Buffer) & (sizeof (Value) - 1)) == 0); + ASSERT ((Length & (sizeof (Value) - 1)) == 0); + + return InternalMemSetMem16 (Buffer, Length / sizeof (Value), Value); +} diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/SetMem32Wrapper.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/SetMem32Wrapper.c new file mode 100644 index 0000000..517bb59 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/SetMem32Wrapper.c @@ -0,0 +1,61 @@ +/*++ + +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: + + SetMem32Wrapper.c + +Abstract: + + SetMem32() implementation. + +--*/ + +#include "BaseMemoryLibInternal.h" + +/** + Fills a target buffer with a 32-bit value, and returns the target buffer. + + This function fills Length bytes of Buffer with the 32-bit value specified by + Value, and returns Buffer. Value is repeated every 32-bits in for Length + bytes of Buffer. + + If Length > 0 and Buffer is NULL, then ASSERT(). + If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). + If Buffer is not aligned on a 32-bit boundary, then ASSERT(). + If Length is not aligned on a 32-bit boundary, then ASSERT(). + + @param Buffer Pointer to the target buffer to fill. + @param Length Number of bytes in Buffer to fill. + @param Value Value with which to fill Length bytes of Buffer. + + @return Buffer. + +**/ +VOID * +EFIAPI +SetMem32 ( + OUT VOID *Buffer, + IN UINTN Length, + IN UINT32 Value + ) +{ + if (Length == 0) { + return Buffer; + } + + ASSERT (Buffer != NULL); + ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN)Buffer)); + ASSERT ((((UINTN)Buffer) & (sizeof (Value) - 1)) == 0); + ASSERT ((Length & (sizeof (Value) - 1)) == 0); + + return InternalMemSetMem32 (Buffer, Length / sizeof (Value), Value); +} diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/SetMem64Wrapper.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/SetMem64Wrapper.c new file mode 100644 index 0000000..2e265f5 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/SetMem64Wrapper.c @@ -0,0 +1,62 @@ +/*++ + +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: + + SetMem64Wrapper.c + +Abstract: + + SetMem64() implementation. + +--*/ + +#include "BaseMemoryLibInternal.h" + +/** + Fills a target buffer with a 64-bit value, and returns the target buffer. + + This function fills Length bytes of Buffer with the 64-bit value specified by + Value, and returns Buffer. Value is repeated every 64-bits in for Length + bytes of Buffer. + + If Length > 0 and Buffer is NULL, then ASSERT(). + If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). + If Buffer is not aligned on a 64-bit boundary, then ASSERT(). + If Length is not aligned on a 64-bit boundary, then ASSERT(). + + @param Buffer Pointer to the target buffer to fill. + @param Length Number of bytes in Buffer to fill. + @param Value Value with which to fill Length bytes of Buffer. + + @return Buffer. + +**/ +VOID * +EFIAPI +SetMem64 ( + OUT VOID *Buffer, + IN UINTN Length, + IN UINT64 Value + ) +{ + if (Length == 0) { + return Buffer; + } + + ASSERT (Buffer != NULL); + ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN)Buffer)); + ASSERT ((((UINTN)Buffer) & (sizeof (Value) - 1)) == 0); + ASSERT ((Length & (sizeof (Value) - 1)) == 0); + + return InternalMemSetMem64 (Buffer, Length / sizeof (Value), Value); +} diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/SetMemWrapper.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/SetMemWrapper.c new file mode 100644 index 0000000..f55c84c --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/SetMemWrapper.c @@ -0,0 +1,52 @@ +/*++ + +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: + + SetMemWrapper.c + +Abstract: + + SetMem() implementation. + +--*/ + +#include "BaseMemoryLibInternal.h" + +/** + Fills a target buffer with a byte value, and returns the target buffer. + + This function fills Length bytes of Buffer with Value, and returns Buffer. + If Length is greater than (MAX_ADDRESS ?Buffer + 1), then ASSERT(). + + @param Buffer Memory to set. + @param Length Number of bytes to set. + @param Value Value of the set operation. + + @return Buffer. + +**/ +VOID * +EFIAPI +GlueSetMem ( + OUT VOID *Buffer, + IN UINTN Length, + IN UINT8 Value + ) +{ + if (Length == 0) { + return Buffer; + } + + ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN)Buffer)); + + return InternalMemSetMem (Buffer, Length, Value); +} diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/X64/CompareMem.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/X64/CompareMem.asm new file mode 100644 index 0000000..d8e84e8 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/X64/CompareMem.asm @@ -0,0 +1,52 @@ +;------------------------------------------------------------------------------ +; +; 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: +; +; CompareMem.Asm +; +; Abstract: +; +; CompareMem function +; +; Notes: +; +; The following BaseMemoryLib instances share the same version of this file: +; +; BaseMemoryLibRepStr +; BaseMemoryLibMmx +; BaseMemoryLibSse2 +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; INTN +; EFIAPI +; InternalMemCompareMem ( +; IN CONST VOID *DestinationBuffer, +; IN CONST VOID *SourceBuffer, +; IN UINTN Length +; ); +;------------------------------------------------------------------------------ +InternalMemCompareMem PROC USES rsi rdi + mov rsi, rcx + mov rdi, rdx + mov rcx, r8 + repe cmpsb + movzx rax, byte ptr [rsi - 1] + movzx rdx, byte ptr [rdi - 1] + sub rax, rdx + ret +InternalMemCompareMem ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/X64/CopyMem.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/X64/CopyMem.asm new file mode 100644 index 0000000..0297975 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/X64/CopyMem.asm @@ -0,0 +1,61 @@ +;------------------------------------------------------------------------------ +; +; 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: +; +; CopyMem.Asm +; +; Abstract: +; +; CopyMem function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; VOID * +; EFIAPI +; InternalMemCopyMem ( +; IN VOID *Destination, +; IN VOID *Source, +; IN UINTN Count +; ) +;------------------------------------------------------------------------------ +InternalMemCopyMem PROC USES rsi rdi + mov rsi, rdx ; rsi <- Source + mov rdi, rcx ; rdi <- Destination + lea r9, [rsi + r8 - 1] ; r9 <- End of Source + cmp rsi, rdi + mov rax, rdi ; rax <- Destination as return value + jae @F + cmp r9, rdi + jae @CopyBackward ; Copy backward if overlapped +@@: + mov rcx, r8 + and r8, 7 + shr rcx, 3 + rep movsq ; Copy as many Qwords as possible + jmp @CopyBytes +@CopyBackward: + mov rsi, r9 ; rsi <- End of Source + lea rdi, [rdi + r8 - 1] ; esi <- End of Destination + std ; set direction flag +@CopyBytes: + mov rcx, r8 + rep movsb ; Copy bytes backward + cld + ret +InternalMemCopyMem ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/X64/EdkIIGlueBaseMemoryLibX64.cif b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/X64/EdkIIGlueBaseMemoryLibX64.cif new file mode 100644 index 0000000..676b818 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/X64/EdkIIGlueBaseMemoryLibX64.cif @@ -0,0 +1,18 @@ +<component> + name = "EdkIIGlueBaseMemoryLibX64" + category = ModulePart + LocalRoot = "Edk\Foundation\Library\EdkIIGlueLib\Library\BaseMemoryLib\X64" + RefName = "EdkIIGlueBaseMemoryLibX64" +[files] +"CompareMem.asm" +"CopyMem.asm" +"ScanMem16.asm" +"ScanMem32.asm" +"ScanMem64.asm" +"ScanMem8.asm" +"SetMem.asm" +"SetMem16.asm" +"SetMem32.asm" +"SetMem64.asm" +"ZeroMem.asm" +<endComponent> diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/X64/ScanMem16.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/X64/ScanMem16.asm new file mode 100644 index 0000000..9d4bcab --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/X64/ScanMem16.asm @@ -0,0 +1,51 @@ +;------------------------------------------------------------------------------ +; +; 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: +; +; ScanMem16.Asm +; +; Abstract: +; +; ScanMem16 function +; +; Notes: +; +; The following BaseMemoryLib instances share the same version of this file: +; +; BaseMemoryLibRepStr +; BaseMemoryLibMmx +; BaseMemoryLibSse2 +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; CONST VOID * +; EFIAPI +; InternalMemScanMem16 ( +; IN CONST VOID *Buffer, +; IN UINTN Length, +; IN UINT16 Value +; ); +;------------------------------------------------------------------------------ +InternalMemScanMem16 PROC USES rdi + mov rdi, rcx + mov rax, r8 + mov rcx, rdx + repne scasw + lea rax, [rdi - 2] + cmovnz rax, rcx + ret +InternalMemScanMem16 ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/X64/ScanMem32.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/X64/ScanMem32.asm new file mode 100644 index 0000000..a59c5b4 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/X64/ScanMem32.asm @@ -0,0 +1,51 @@ +;------------------------------------------------------------------------------ +; +; 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: +; +; ScanMem32.Asm +; +; Abstract: +; +; ScanMem32 function +; +; Notes: +; +; The following BaseMemoryLib instances share the same version of this file: +; +; BaseMemoryLibRepStr +; BaseMemoryLibMmx +; BaseMemoryLibSse2 +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; CONST VOID * +; EFIAPI +; InternalMemScanMem32 ( +; IN CONST VOID *Buffer, +; IN UINTN Length, +; IN UINT32 Value +; ); +;------------------------------------------------------------------------------ +InternalMemScanMem32 PROC USES rdi + mov rdi, rcx + mov rax, r8 + mov rcx, rdx + repne scasd + lea rax, [rdi - 4] + cmovnz rax, rcx + ret +InternalMemScanMem32 ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/X64/ScanMem64.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/X64/ScanMem64.asm new file mode 100644 index 0000000..87c8dfb --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/X64/ScanMem64.asm @@ -0,0 +1,51 @@ +;------------------------------------------------------------------------------ +; +; 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: +; +; ScanMem64.Asm +; +; Abstract: +; +; ScanMem64 function +; +; Notes: +; +; The following BaseMemoryLib instances share the same version of this file: +; +; BaseMemoryLibRepStr +; BaseMemoryLibMmx +; BaseMemoryLibSse2 +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; CONST VOID * +; EFIAPI +; InternalMemScanMem64 ( +; IN CONST VOID *Buffer, +; IN UINTN Length, +; IN UINT64 Value +; ); +;------------------------------------------------------------------------------ +InternalMemScanMem64 PROC USES rdi + mov rdi, rcx + mov rax, r8 + mov rcx, rdx + repne scasq + lea rax, [rdi - 8] + cmovnz rax, rcx + ret +InternalMemScanMem64 ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/X64/ScanMem8.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/X64/ScanMem8.asm new file mode 100644 index 0000000..dff52e5 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/X64/ScanMem8.asm @@ -0,0 +1,51 @@ +;------------------------------------------------------------------------------ +; +; 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: +; +; ScanMem8.Asm +; +; Abstract: +; +; ScanMem8 function +; +; Notes: +; +; The following BaseMemoryLib instances share the same version of this file: +; +; BaseMemoryLibRepStr +; BaseMemoryLibMmx +; BaseMemoryLibSse2 +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; CONST VOID * +; EFIAPI +; InternalMemScanMem8 ( +; IN CONST VOID *Buffer, +; IN UINTN Length, +; IN UINT8 Value +; ); +;------------------------------------------------------------------------------ +InternalMemScanMem8 PROC USES rdi + mov rdi, rcx + mov rcx, rdx + mov rax, r8 + repne scasb + lea rax, [rdi - 1] + cmovnz rax, rcx ; set rax to 0 if not found + ret +InternalMemScanMem8 ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/X64/SetMem.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/X64/SetMem.asm new file mode 100644 index 0000000..39791f3 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/X64/SetMem.asm @@ -0,0 +1,44 @@ +;------------------------------------------------------------------------------ +; +; 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: +; +; SetMem.Asm +; +; Abstract: +; +; SetMem function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; VOID * +; EFIAPI +; InternalMemSetMem ( +; IN VOID *Buffer, +; IN UINTN Count, +; IN UINT8 Value +; ) +;------------------------------------------------------------------------------ +InternalMemSetMem PROC USES rdi + mov rax, r8 + mov rdi, rcx + xchg rcx, rdx + rep stosb + mov rax, rdx + ret +InternalMemSetMem ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/X64/SetMem16.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/X64/SetMem16.asm new file mode 100644 index 0000000..9dc9525 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/X64/SetMem16.asm @@ -0,0 +1,44 @@ +;------------------------------------------------------------------------------ +; +; 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: +; +; SetMem16.Asm +; +; Abstract: +; +; SetMem16 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; VOID * +; EFIAPI +; InternalMemSetMem16 ( +; IN VOID *Buffer, +; IN UINTN Count, +; IN UINT16 Value +; ) +;------------------------------------------------------------------------------ +InternalMemSetMem16 PROC USES rdi + mov rdi, rcx + mov rax, r8 + xchg rcx, rdx + rep stosw + mov rax, rdx + ret +InternalMemSetMem16 ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/X64/SetMem32.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/X64/SetMem32.asm new file mode 100644 index 0000000..416577b --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/X64/SetMem32.asm @@ -0,0 +1,44 @@ +;------------------------------------------------------------------------------ +; +; 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: +; +; SetMem32.Asm +; +; Abstract: +; +; SetMem32 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; VOID * +; EFIAPI +; InternalMemSetMem32 ( +; IN VOID *Buffer, +; IN UINTN Count, +; IN UINT32 Value +; ); +;------------------------------------------------------------------------------ +InternalMemSetMem32 PROC USES rdi + mov rdi, rcx + mov rax, r8 + xchg rcx, rdx + rep stosd + mov rax, rdx + ret +InternalMemSetMem32 ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/X64/SetMem64.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/X64/SetMem64.asm new file mode 100644 index 0000000..4cece3d --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/X64/SetMem64.asm @@ -0,0 +1,43 @@ +;------------------------------------------------------------------------------ +; +; 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: +; +; SetMem64.Asm +; +; Abstract: +; +; SetMem64 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; VOID * +; InternalMemSetMem64 ( +; IN VOID *Buffer, +; IN UINTN Count, +; IN UINT64 Value +; ) +;------------------------------------------------------------------------------ +InternalMemSetMem64 PROC USES rdi + mov rdi, rcx + mov rax, r8 + xchg rcx, rdx + rep stosq + mov rax, rdx + ret +InternalMemSetMem64 ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/X64/ZeroMem.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/X64/ZeroMem.asm new file mode 100644 index 0000000..1b1b809 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/X64/ZeroMem.asm @@ -0,0 +1,47 @@ +;------------------------------------------------------------------------------ +; +; 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: +; +; ZeroMem.Asm +; +; Abstract: +; +; ZeroMem function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; VOID * +; InternalMemZeroMem ( +; IN VOID *Buffer, +; IN UINTN Count +; ); +;------------------------------------------------------------------------------ +InternalMemZeroMem PROC USES rdi + push rcx + xor rax, rax + mov rdi, rcx + mov rcx, rdx + shr rcx, 3 + and rdx, 7 + rep stosq + mov ecx, edx + rep stosb + pop rax + ret +InternalMemZeroMem ENDP + + END diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/ZeroMemWrapper.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/ZeroMemWrapper.c new file mode 100644 index 0000000..5d7c1e0 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/ZeroMemWrapper.c @@ -0,0 +1,47 @@ +/*++ + +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: + + ZeroMemWrapper.c + +Abstract: + + ZeroMem() implementation. + +--*/ + +#include "BaseMemoryLibInternal.h" + +/** + Fills a target buffer with zeros, and returns the target buffer. + + This function fills Length bytes of Buffer with zeros, and returns Buffer. + If Length > 0 and Buffer is NULL, then ASSERT(). + If Length is greater than (MAX_ADDRESS ?Buffer + 1), then ASSERT(). + + @param Buffer Pointer to the target buffer to fill with zeros. + @param Length Number of bytes in Buffer to fill with zeros. + + @return Buffer. + +**/ +VOID * +EFIAPI +GlueZeroMem ( + OUT VOID *Buffer, + IN UINTN Length + ) +{ + ASSERT (!(Buffer == NULL && Length > 0)); + ASSERT (Length <= (MAX_ADDRESS - (UINTN)Buffer + 1)); + return InternalMemZeroMem (Buffer, Length); +} diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePciCf8Lib/BasePciCf8Lib.inf b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePciCf8Lib/BasePciCf8Lib.inf new file mode 100644 index 0000000..737e75d --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePciCf8Lib/BasePciCf8Lib.inf @@ -0,0 +1,79 @@ +#/*++ +# +# 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: +# +# BasePciCf8Lib.inf +# +# Abstract: +# +# Component description file for BasePciCf8Lib. +# +#--*/ + +[defines] +BASE_NAME = EdkIIGlueBasePciCf8Lib +COMPONENT_TYPE = LIBRARY + +[sources.common] + PciLib.c + +[sources.ia32] + + +[sources.x64] + + +[sources.ipf] + + +[sources.ebc] + + +[includes.common] + . + ..\..\Include + ..\..\include\Library + $(EDK_SOURCE)\Foundation + $(EDK_SOURCE)\Foundation\Framework + $(EDK_SOURCE)\Foundation\Efi + $(EDK_SOURCE)\Foundation\Include + $(EDK_SOURCE)\Foundation\Efi\Include + $(EDK_SOURCE)\Foundation\Framework\Include + $(EDK_SOURCE)\Foundation\Include\IndustryStandard + $(EDK_SOURCE)\Foundation\Core\Dxe + $(EDK_SOURCE)\Foundation\Library\Dxe\Include + $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include + +[libraries.common] + EdkIIGlueBaseIoLibIntrinsic + +[libraries.ia32] + + +[libraries.x64] + + +[nmake.common] + C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION + LIB_STD_FLAGS = /NOLOGO /IGNORE:4006 + +[nmake.ia32] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32 + +[nmake.x64] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64 + +[nmake.ipf] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF + +[nmake.ebc] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_EBC
\ No newline at end of file diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePciCf8Lib/EdkIIGlueBasePciCf8Lib.cif b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePciCf8Lib/EdkIIGlueBasePciCf8Lib.cif new file mode 100644 index 0000000..f3b575a --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePciCf8Lib/EdkIIGlueBasePciCf8Lib.cif @@ -0,0 +1,11 @@ +<component> + name = "EdkIIGlueBasePciCf8Lib" + category = ModulePart + LocalRoot = "Edk\Foundation\Library\EdkIIGlueLib\Library\BasePciCf8Lib" + RefName = "EdkIIGlueBasePciCf8Lib" +[files] +"EdkIIGlueBasePciCf8Lib.sdl" +"EdkIIGlueBasePciCf8Lib.mak" +"BasePciCf8Lib.inf" +"PciLib.c" +<endComponent> diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePciCf8Lib/EdkIIGlueBasePciCf8Lib.mak b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePciCf8Lib/EdkIIGlueBasePciCf8Lib.mak new file mode 100644 index 0000000..e0d1e10 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePciCf8Lib/EdkIIGlueBasePciCf8Lib.mak @@ -0,0 +1,85 @@ +#********************************************************************** +#********************************************************************** +#** ** +#** (C)Copyright 1985-2009, American Megatrends, Inc. ** +#** ** +#** All Rights Reserved. ** +#** ** +#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +#** ** +#** Phone: (770)-246-8600 ** +#** ** +#********************************************************************** +#********************************************************************** + +#********************************************************************** +# $Header: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGlueBasePciCf8Lib/EdkIIGlueBasePciCf8Lib.mak 1 1/20/12 3:53a Jeffch $ +# +# $Revision: 1 $ +# +# $Date: 1/20/12 3:53a $ +#********************************************************************** +# Revision History +# ---------------- +# $Log: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGlueBasePciCf8Lib/EdkIIGlueBasePciCf8Lib.mak $ +# +# 1 1/20/12 3:53a Jeffch +# Create Intel EDK 1117 Patch 7. +# +# 1 9/27/11 6:15a Wesleychen +# Intel EDK initially releases. +# +# 1 9/18/09 1:51a Iminglin +# +#********************************************************************** +#<AMI_FHDR_START> +# +# Name: EdkIIGlueBasePciCf8Lib.mak +# +# Description: +# +#<AMI_FHDR_END> +#********************************************************************** + + +$(EdkIIGlueBasePciCf8Lib_LIB) : EdkIIGlueBasePciCf8Lib + +EdkIIGlueBasePciCf8Lib : $(BUILD_DIR)\EdkIIGlueBasePciCf8Lib.mak EdkIIGlueBasePciCf8LibBin + +$(BUILD_DIR)\EdkIIGlueBasePciCf8Lib.mak : $(EdkIIGlueBasePciCf8Lib_DIR)\$(@B).cif $(EdkIIGlueBasePciCf8Lib_DIR)\$(@B).mak $(BUILD_RULES) + $(CIF2MAK) $(EdkIIGlueBasePciCf8Lib_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS) + +EdkIIGlueBasePciCf8Lib_LIB_LINKS=\ +!IF "$(PROCESSOR)"=="IA32" || "$(PROCESSOR)"=="x64" +$(EdkIIGlueBaseIoLibIntrinsic_LIB) +!ENDIF + +EdkIIGlueBasePciCf8LibBin : $(EdkIIGlueBasePciCf8Lib_LIB_LINKS) +!IF "$(x64_BUILD)"=="1" + $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\ + BUILD_DIR=$(BUILD_DIR)\ + /f $(BUILD_DIR)\EdkIIGlueBasePciCf8Lib.mak all\ + TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueBasePciCf8Lib_LIB)" + $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\ + BUILD_DIR=$(BUILD_DIR)\IA32\ + /f $(BUILD_DIR)\EdkIIGlueBasePciCf8Lib.mak all\ + TYPE=PEI_LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueBasePciCf8Lib_LIB)" +!ELSE + $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\ + BUILD_DIR=$(BUILD_DIR)\ + /f $(BUILD_DIR)\EdkIIGlueBasePciCf8Lib.mak all\ + TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueBasePciCf8Lib_LIB)" +!ENDIF +#********************************************************************** +#********************************************************************** +#** ** +#** (C)Copyright 1985-2009, American Megatrends, Inc. ** +#** ** +#** All Rights Reserved. ** +#** ** +#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +#** ** +#** Phone: (770)-246-8600 ** +#** ** +#********************************************************************** +#********************************************************************** diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePciCf8Lib/EdkIIGlueBasePciCf8Lib.sdl b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePciCf8Lib/EdkIIGlueBasePciCf8Lib.sdl new file mode 100644 index 0000000..00c7a6f --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePciCf8Lib/EdkIIGlueBasePciCf8Lib.sdl @@ -0,0 +1,26 @@ +TOKEN + Name = "EdkIIGlueBasePciCf8Lib_SUPPORT" + Value = "1" + Help = "Main switch to enable EdkIIGlueBasePciCf8Lib support in Project" + TokenType = Boolean + TargetEQU = Yes + TargetMAK = Yes + Master = Yes +End + +TOKEN + Name = "EdkIIGlueBasePciCf8Lib_LIB" + Value = "$$(LIB_BUILD_DIR)\EdkIIGlueBasePciCf8Lib.lib" + TokenType = Expression + TargetMAK = Yes +End + +PATH + Name = "EdkIIGlueBasePciCf8Lib_DIR" +End + +MODULE + Help = "Includes EdkIIGlueBasePciCf8Lib.mak to Project" + File = "EdkIIGlueBasePciCf8Lib.mak" +End + diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePciCf8Lib/PciLib.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePciCf8Lib/PciLib.c new file mode 100644 index 0000000..ee09942 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePciCf8Lib/PciLib.c @@ -0,0 +1,1468 @@ +/*++ + +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: + + PciLib.c + +Abstract: + + PCI Library. + +--*/ + +#include "EdkIIGlueBase.h" + +// +// Declare I/O Ports used to perform PCI Confguration Cycles +// +#define PCI_CONFIGURATION_ADDRESS_PORT 0xCF8 +#define PCI_CONFIGURATION_DATA_PORT 0xCFC + +// +// Declare macro to convert PCI Library formatted address to CF8 formatted address +// +// PCI Library formatted address CF8 Formatted Address +// ============================= ====================== +// Bits 00..11 Register Bits 00..07 Register +// Bits 12..14 Function Bits 08..10 Function +// Bits 15..19 Device Bits 11..15 Device +// Bits 20..27 Bus Bits 16..23 Bus +// Bits 28..31 Reserved(MBZ) Bits 24..30 Reserved(MBZ) +// Bits 31..31 Must be 1 +// + +/** + Assert the validity of a PCI address. A valid PCI address should contain 1's + only in the low 28 bits. + + @param A The address to validate. + @param M Additional bits to assert to be zero. + +**/ +#define ASSERT_INVALID_PCI_ADDRESS(A,M) \ + ASSERT (((A) & (~0xffff0ff | (M))) == 0) + +/** + Convert a PCI Express address to PCI CF8 address. + + @param A The address to convert. + + @retval The coverted address. + +**/ +#define PCI_TO_CF8_ADDRESS(A) \ + ((UINT32) ((((A) >> 4) & 0x00ffff00) | ((A) & 0xfc) | 0x80000000)) + +/** + Reads an 8-bit PCI configuration register. + + Reads and returns the 8-bit PCI configuration register specified by Address. + This function must guarantee that all PCI read and write operations are + serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + If the register specified by Address >= 0x100, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + + @return The read value from the PCI configuration register. + +**/ +UINT8 +EFIAPI +PciCf8Read8 ( + IN UINTN Address + ) +{ + ASSERT_INVALID_PCI_ADDRESS (Address, 0); + IoWrite32 (PCI_CONFIGURATION_ADDRESS_PORT, PCI_TO_CF8_ADDRESS (Address)); + return IoRead8 (PCI_CONFIGURATION_DATA_PORT + (UINT16)(Address & 3)); +} + +/** + Writes an 8-bit PCI configuration register. + + Writes the 8-bit PCI configuration register specified by Address with the + value specified by Value. Value is returned. This function must guarantee + that all PCI read and write operations are serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + If the register specified by Address >= 0x100, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param Value The value to write. + + @return The value written to the PCI configuration register. + +**/ +UINT8 +EFIAPI +PciCf8Write8 ( + IN UINTN Address, + IN UINT8 Value + ) +{ + ASSERT_INVALID_PCI_ADDRESS (Address, 0); + IoWrite32 (PCI_CONFIGURATION_ADDRESS_PORT, PCI_TO_CF8_ADDRESS (Address)); + return IoWrite8 ( + PCI_CONFIGURATION_DATA_PORT + (UINT16)(Address & 3), + Value + ); +} + +/** + Performs a bitwise inclusive OR of an 8-bit PCI configuration register with + an 8-bit value. + + Reads the 8-bit PCI configuration register specified by Address, performs a + bitwise inclusive OR between the read result and the value specified by + OrData, and writes the result to the 8-bit PCI configuration register + specified by Address. The value written to the PCI configuration register is + returned. This function must guarantee that all PCI read and write operations + are serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + If the register specified by Address >= 0x100, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param OrData The value to OR with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT8 +EFIAPI +PciCf8Or8 ( + IN UINTN Address, + IN UINT8 OrData + ) +{ + ASSERT_INVALID_PCI_ADDRESS (Address, 0); + IoWrite32 (PCI_CONFIGURATION_ADDRESS_PORT, PCI_TO_CF8_ADDRESS (Address)); + return IoOr8 ( + PCI_CONFIGURATION_DATA_PORT + (UINT16)(Address & 3), + OrData + ); +} + +/** + Performs a bitwise AND of an 8-bit PCI configuration register with an 8-bit + value. + + Reads the 8-bit PCI configuration register specified by Address, performs a + bitwise AND between the read result and the value specified by AndData, and + writes the result to the 8-bit PCI configuration register specified by + Address. The value written to the PCI configuration register is returned. + This function must guarantee that all PCI read and write operations are + serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + If the register specified by Address >= 0x100, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param AndData The value to AND with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT8 +EFIAPI +PciCf8And8 ( + IN UINTN Address, + IN UINT8 AndData + ) +{ + ASSERT_INVALID_PCI_ADDRESS (Address, 0); + IoWrite32 (PCI_CONFIGURATION_ADDRESS_PORT, PCI_TO_CF8_ADDRESS (Address)); + return IoAnd8 ( + PCI_CONFIGURATION_DATA_PORT + (UINT16)(Address & 3), + AndData + ); +} + +/** + Performs a bitwise AND of an 8-bit PCI configuration register with an 8-bit + value, followed a bitwise inclusive OR with another 8-bit value. + + Reads the 8-bit PCI configuration register specified by Address, performs a + bitwise AND between the read result and the value specified by AndData, + performs a bitwise inclusive OR between the result of the AND operation and + the value specified by OrData, and writes the result to the 8-bit PCI + configuration register specified by Address. The value written to the PCI + configuration register is returned. This function must guarantee that all PCI + read and write operations are serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + If the register specified by Address >= 0x100, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param AndData The value to AND with the PCI configuration register. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the PCI configuration register. + +**/ +UINT8 +EFIAPI +PciCf8AndThenOr8 ( + IN UINTN Address, + IN UINT8 AndData, + IN UINT8 OrData + ) +{ + ASSERT_INVALID_PCI_ADDRESS (Address, 0); + IoWrite32 (PCI_CONFIGURATION_ADDRESS_PORT, PCI_TO_CF8_ADDRESS (Address)); + return IoAndThenOr8 ( + PCI_CONFIGURATION_DATA_PORT + (UINT16)(Address & 3), + AndData, + OrData + ); +} + +/** + Reads a bit field of a PCI configuration register. + + Reads the bit field in an 8-bit PCI configuration register. The bit field is + specified by the StartBit and the EndBit. The value of the bit field is + returned. + + If Address > 0x0FFFFFFF, then ASSERT(). + If the register specified by Address >= 0x100, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to read. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..7. + + @return The value of the bit field read from the PCI configuration register. + +**/ +UINT8 +EFIAPI +PciCf8BitFieldRead8 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit + ) +{ + ASSERT_INVALID_PCI_ADDRESS (Address, 0); + IoWrite32 (PCI_CONFIGURATION_ADDRESS_PORT, PCI_TO_CF8_ADDRESS (Address)); + return IoBitFieldRead8 ( + PCI_CONFIGURATION_DATA_PORT + (UINT16)(Address & 3), + StartBit, + EndBit + ); +} + +/** + Writes a bit field to a PCI configuration register. + + Writes Value to the bit field of the PCI configuration register. The bit + field is specified by the StartBit and the EndBit. All other bits in the + destination PCI configuration register are preserved. The new value of the + 8-bit register is returned. + + If Address > 0x0FFFFFFF, then ASSERT(). + If the register specified by Address >= 0x100, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..7. + @param Value New value of the bit field. + + @return The value written back to the PCI configuration register. + +**/ +UINT8 +EFIAPI +PciCf8BitFieldWrite8 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT8 Value + ) +{ + ASSERT_INVALID_PCI_ADDRESS (Address, 0); + IoWrite32 (PCI_CONFIGURATION_ADDRESS_PORT, PCI_TO_CF8_ADDRESS (Address)); + return IoBitFieldWrite8 ( + PCI_CONFIGURATION_DATA_PORT + (UINT16)(Address & 3), + StartBit, + EndBit, + Value + ); +} + +/** + Reads a bit field in an 8-bit PCI configuration, performs a bitwise OR, and + writes the result back to the bit field in the 8-bit port. + + Reads the 8-bit PCI configuration register specified by Address, performs a + bitwise inclusive OR between the read result and the value specified by + OrData, and writes the result to the 8-bit PCI configuration register + specified by Address. The value written to the PCI configuration register is + returned. This function must guarantee that all PCI read and write operations + are serialized. Extra left bits in OrData are stripped. + + If Address > 0x0FFFFFFF, then ASSERT(). + If the register specified by Address >= 0x100, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..7. + @param OrData The value to OR with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT8 +EFIAPI +PciCf8BitFieldOr8 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT8 OrData + ) +{ + ASSERT_INVALID_PCI_ADDRESS (Address, 0); + IoWrite32 (PCI_CONFIGURATION_ADDRESS_PORT, PCI_TO_CF8_ADDRESS (Address)); + return IoBitFieldOr8 ( + PCI_CONFIGURATION_DATA_PORT + (UINT16)(Address & 3), + StartBit, + EndBit, + OrData + ); +} + +/** + Reads a bit field in an 8-bit PCI configuration register, performs a bitwise + AND, and writes the result back to the bit field in the 8-bit register. + + Reads the 8-bit PCI configuration register specified by Address, performs a + bitwise AND between the read result and the value specified by AndData, and + writes the result to the 8-bit PCI configuration register specified by + Address. The value written to the PCI configuration register is returned. + This function must guarantee that all PCI read and write operations are + serialized. Extra left bits in AndData are stripped. + + If Address > 0x0FFFFFFF, then ASSERT(). + If the register specified by Address >= 0x100, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..7. + @param AndData The value to AND with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT8 +EFIAPI +PciCf8BitFieldAnd8 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT8 AndData + ) +{ + ASSERT_INVALID_PCI_ADDRESS (Address, 0); + IoWrite32 (PCI_CONFIGURATION_ADDRESS_PORT, PCI_TO_CF8_ADDRESS (Address)); + return IoBitFieldAnd8 ( + PCI_CONFIGURATION_DATA_PORT + (UINT16)(Address & 3), + StartBit, + EndBit, + AndData + ); +} + +/** + Reads a bit field in an 8-bit port, performs a bitwise AND followed by a + bitwise inclusive OR, and writes the result back to the bit field in the + 8-bit port. + + Reads the 8-bit PCI configuration register specified by Address, performs a + bitwise AND followed by a bitwise inclusive OR between the read result and + the value specified by AndData, and writes the result to the 8-bit PCI + configuration register specified by Address. The value written to the PCI + configuration register is returned. This function must guarantee that all PCI + read and write operations are serialized. Extra left bits in both AndData and + OrData are stripped. + + If Address > 0x0FFFFFFF, then ASSERT(). + If the register specified by Address >= 0x100, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..7. + @param AndData The value to AND with the PCI configuration register. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the PCI configuration register. + +**/ +UINT8 +EFIAPI +PciCf8BitFieldAndThenOr8( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT8 AndData, + IN UINT8 OrData + ) +{ + ASSERT_INVALID_PCI_ADDRESS (Address, 0); + IoWrite32 (PCI_CONFIGURATION_ADDRESS_PORT, PCI_TO_CF8_ADDRESS (Address)); + return IoBitFieldAndThenOr8 ( + PCI_CONFIGURATION_DATA_PORT + (UINT16)(Address & 3), + StartBit, + EndBit, + AndData, + OrData + ); +} + +/** + Reads a 16-bit PCI configuration register. + + Reads and returns the 16-bit PCI configuration register specified by Address. + This function must guarantee that all PCI read and write operations are + serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 16-bit boundary, then ASSERT(). + If the register specified by Address >= 0x100, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + + @return The read value from the PCI configuration register. + +**/ +UINT16 +EFIAPI +PciCf8Read16 ( + IN UINTN Address + ) +{ + ASSERT_INVALID_PCI_ADDRESS (Address, 1); + IoWrite32 (PCI_CONFIGURATION_ADDRESS_PORT, PCI_TO_CF8_ADDRESS (Address)); + return IoRead16 (PCI_CONFIGURATION_DATA_PORT + (UINT16)(Address & 2)); +} + +/** + Writes a 16-bit PCI configuration register. + + Writes the 16-bit PCI configuration register specified by Address with the + value specified by Value. Value is returned. This function must guarantee + that all PCI read and write operations are serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 16-bit boundary, then ASSERT(). + If the register specified by Address >= 0x100, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param Value The value to write. + + @return The value written to the PCI configuration register. + +**/ +UINT16 +EFIAPI +PciCf8Write16 ( + IN UINTN Address, + IN UINT16 Value + ) +{ + ASSERT_INVALID_PCI_ADDRESS (Address, 1); + IoWrite32 (PCI_CONFIGURATION_ADDRESS_PORT, PCI_TO_CF8_ADDRESS (Address)); + return IoWrite16 ( + PCI_CONFIGURATION_DATA_PORT + (UINT16)(Address & 2), + Value + ); +} + +/** + Performs a bitwise inclusive OR of a 16-bit PCI configuration register with + a 16-bit value. + + Reads the 16-bit PCI configuration register specified by Address, performs a + bitwise inclusive OR between the read result and the value specified by + OrData, and writes the result to the 16-bit PCI configuration register + specified by Address. The value written to the PCI configuration register is + returned. This function must guarantee that all PCI read and write operations + are serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 16-bit boundary, then ASSERT(). + If the register specified by Address >= 0x100, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param OrData The value to OR with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT16 +EFIAPI +PciCf8Or16 ( + IN UINTN Address, + IN UINT16 OrData + ) +{ + ASSERT_INVALID_PCI_ADDRESS (Address, 1); + IoWrite32 (PCI_CONFIGURATION_ADDRESS_PORT, PCI_TO_CF8_ADDRESS (Address)); + return IoOr16 ( + PCI_CONFIGURATION_DATA_PORT + (UINT16)(Address & 2), + OrData + ); +} + +/** + Performs a bitwise AND of a 16-bit PCI configuration register with a 16-bit + value. + + Reads the 16-bit PCI configuration register specified by Address, performs a + bitwise AND between the read result and the value specified by AndData, and + writes the result to the 16-bit PCI configuration register specified by + Address. The value written to the PCI configuration register is returned. + This function must guarantee that all PCI read and write operations are + serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 16-bit boundary, then ASSERT(). + If the register specified by Address >= 0x100, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param AndData The value to AND with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT16 +EFIAPI +PciCf8And16 ( + IN UINTN Address, + IN UINT16 AndData + ) +{ + ASSERT_INVALID_PCI_ADDRESS (Address, 1); + IoWrite32 (PCI_CONFIGURATION_ADDRESS_PORT, PCI_TO_CF8_ADDRESS (Address)); + return IoAnd16 ( + PCI_CONFIGURATION_DATA_PORT + (UINT16)(Address & 2), + AndData + ); +} + +/** + Performs a bitwise AND of a 16-bit PCI configuration register with a 16-bit + value, followed a bitwise inclusive OR with another 16-bit value. + + Reads the 16-bit PCI configuration register specified by Address, performs a + bitwise AND between the read result and the value specified by AndData, + performs a bitwise inclusive OR between the result of the AND operation and + the value specified by OrData, and writes the result to the 16-bit PCI + configuration register specified by Address. The value written to the PCI + configuration register is returned. This function must guarantee that all PCI + read and write operations are serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 16-bit boundary, then ASSERT(). + If the register specified by Address >= 0x100, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param AndData The value to AND with the PCI configuration register. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the PCI configuration register. + +**/ +UINT16 +EFIAPI +PciCf8AndThenOr16 ( + IN UINTN Address, + IN UINT16 AndData, + IN UINT16 OrData + ) +{ + ASSERT_INVALID_PCI_ADDRESS (Address, 1); + IoWrite32 (PCI_CONFIGURATION_ADDRESS_PORT, PCI_TO_CF8_ADDRESS (Address)); + return IoAndThenOr16 ( + PCI_CONFIGURATION_DATA_PORT + (UINT16)(Address & 2), + AndData, + OrData + ); +} + +/** + Reads a bit field of a PCI configuration register. + + Reads the bit field in a 16-bit PCI configuration register. The bit field is + specified by the StartBit and the EndBit. The value of the bit field is + returned. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 16-bit boundary, then ASSERT(). + If the register specified by Address >= 0x100, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to read. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..15. + + @return The value of the bit field read from the PCI configuration register. + +**/ +UINT16 +EFIAPI +PciCf8BitFieldRead16 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit + ) +{ + ASSERT_INVALID_PCI_ADDRESS (Address, 1); + IoWrite32 (PCI_CONFIGURATION_ADDRESS_PORT, PCI_TO_CF8_ADDRESS (Address)); + return IoBitFieldRead16 ( + PCI_CONFIGURATION_DATA_PORT + (UINT16)(Address & 2), + StartBit, + EndBit + ); +} + +/** + Writes a bit field to a PCI configuration register. + + Writes Value to the bit field of the PCI configuration register. The bit + field is specified by the StartBit and the EndBit. All other bits in the + destination PCI configuration register are preserved. The new value of the + 16-bit register is returned. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 16-bit boundary, then ASSERT(). + If the register specified by Address >= 0x100, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..15. + @param Value New value of the bit field. + + @return The value written back to the PCI configuration register. + +**/ +UINT16 +EFIAPI +PciCf8BitFieldWrite16 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT16 Value + ) +{ + ASSERT_INVALID_PCI_ADDRESS (Address, 1); + IoWrite32 (PCI_CONFIGURATION_ADDRESS_PORT, PCI_TO_CF8_ADDRESS (Address)); + return IoBitFieldWrite16 ( + PCI_CONFIGURATION_DATA_PORT + (UINT16)(Address & 2), + StartBit, + EndBit, + Value + ); +} + +/** + Reads a bit field in a 16-bit PCI configuration, performs a bitwise OR, and + writes the result back to the bit field in the 16-bit port. + + Reads the 16-bit PCI configuration register specified by Address, performs a + bitwise inclusive OR between the read result and the value specified by + OrData, and writes the result to the 16-bit PCI configuration register + specified by Address. The value written to the PCI configuration register is + returned. This function must guarantee that all PCI read and write operations + are serialized. Extra left bits in OrData are stripped. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 16-bit boundary, then ASSERT(). + If the register specified by Address >= 0x100, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..15. + @param OrData The value to OR with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT16 +EFIAPI +PciCf8BitFieldOr16 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT16 OrData + ) +{ + ASSERT_INVALID_PCI_ADDRESS (Address, 1); + IoWrite32 (PCI_CONFIGURATION_ADDRESS_PORT, PCI_TO_CF8_ADDRESS (Address)); + return IoBitFieldOr16 ( + PCI_CONFIGURATION_DATA_PORT + (UINT16)(Address & 2), + StartBit, + EndBit, + OrData + ); +} + +/** + Reads a bit field in a 16-bit PCI configuration register, performs a bitwise + AND, and writes the result back to the bit field in the 16-bit register. + + Reads the 16-bit PCI configuration register specified by Address, performs a + bitwise AND between the read result and the value specified by AndData, and + writes the result to the 16-bit PCI configuration register specified by + Address. The value written to the PCI configuration register is returned. + This function must guarantee that all PCI read and write operations are + serialized. Extra left bits in AndData are stripped. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 16-bit boundary, then ASSERT(). + If the register specified by Address >= 0x100, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..15. + @param AndData The value to AND with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT16 +EFIAPI +PciCf8BitFieldAnd16 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT16 AndData + ) +{ + ASSERT_INVALID_PCI_ADDRESS (Address, 1); + IoWrite32 (PCI_CONFIGURATION_ADDRESS_PORT, PCI_TO_CF8_ADDRESS (Address)); + return IoBitFieldAnd16 ( + PCI_CONFIGURATION_DATA_PORT + (UINT16)(Address & 2), + StartBit, + EndBit, + AndData + ); +} + +/** + Reads a bit field in a 16-bit port, performs a bitwise AND followed by a + bitwise inclusive OR, and writes the result back to the bit field in the + 16-bit port. + + Reads the 16-bit PCI configuration register specified by Address, performs a + bitwise AND followed by a bitwise inclusive OR between the read result and + the value specified by AndData, and writes the result to the 16-bit PCI + configuration register specified by Address. The value written to the PCI + configuration register is returned. This function must guarantee that all PCI + read and write operations are serialized. Extra left bits in both AndData and + OrData are stripped. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 16-bit boundary, then ASSERT(). + If the register specified by Address >= 0x100, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..15. + @param AndData The value to AND with the PCI configuration register. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the PCI configuration register. + +**/ +UINT16 +EFIAPI +PciCf8BitFieldAndThenOr16( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT16 AndData, + IN UINT16 OrData + ) +{ + ASSERT_INVALID_PCI_ADDRESS (Address, 1); + IoWrite32 (PCI_CONFIGURATION_ADDRESS_PORT, PCI_TO_CF8_ADDRESS (Address)); + return IoBitFieldAndThenOr16 ( + PCI_CONFIGURATION_DATA_PORT + (UINT16)(Address & 2), + StartBit, + EndBit, + AndData, + OrData + ); +} + +/** + Reads a 32-bit PCI configuration register. + + Reads and returns the 32-bit PCI configuration register specified by Address. + This function must guarantee that all PCI read and write operations are + serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 32-bit boundary, then ASSERT(). + If the register specified by Address >= 0x100, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + + @return The read value from the PCI configuration register. + +**/ +UINT32 +EFIAPI +PciCf8Read32 ( + IN UINTN Address + ) +{ + ASSERT_INVALID_PCI_ADDRESS (Address, 3); + IoWrite32 (PCI_CONFIGURATION_ADDRESS_PORT, PCI_TO_CF8_ADDRESS (Address)); + return IoRead32 (PCI_CONFIGURATION_DATA_PORT); +} + +/** + Writes a 32-bit PCI configuration register. + + Writes the 32-bit PCI configuration register specified by Address with the + value specified by Value. Value is returned. This function must guarantee + that all PCI read and write operations are serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 32-bit boundary, then ASSERT(). + If the register specified by Address >= 0x100, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param Value The value to write. + + @return The value written to the PCI configuration register. + +**/ +UINT32 +EFIAPI +PciCf8Write32 ( + IN UINTN Address, + IN UINT32 Value + ) +{ + ASSERT_INVALID_PCI_ADDRESS (Address, 3); + IoWrite32 (PCI_CONFIGURATION_ADDRESS_PORT, PCI_TO_CF8_ADDRESS (Address)); + return IoWrite32 ( + PCI_CONFIGURATION_DATA_PORT, + Value + ); +} + +/** + Performs a bitwise inclusive OR of a 32-bit PCI configuration register with + a 32-bit value. + + Reads the 32-bit PCI configuration register specified by Address, performs a + bitwise inclusive OR between the read result and the value specified by + OrData, and writes the result to the 32-bit PCI configuration register + specified by Address. The value written to the PCI configuration register is + returned. This function must guarantee that all PCI read and write operations + are serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 32-bit boundary, then ASSERT(). + If the register specified by Address >= 0x100, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param OrData The value to OR with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT32 +EFIAPI +PciCf8Or32 ( + IN UINTN Address, + IN UINT32 OrData + ) +{ + ASSERT_INVALID_PCI_ADDRESS (Address, 3); + IoWrite32 (PCI_CONFIGURATION_ADDRESS_PORT, PCI_TO_CF8_ADDRESS (Address)); + return IoOr32 ( + PCI_CONFIGURATION_DATA_PORT, + OrData + ); +} + +/** + Performs a bitwise AND of a 32-bit PCI configuration register with a 32-bit + value. + + Reads the 32-bit PCI configuration register specified by Address, performs a + bitwise AND between the read result and the value specified by AndData, and + writes the result to the 32-bit PCI configuration register specified by + Address. The value written to the PCI configuration register is returned. + This function must guarantee that all PCI read and write operations are + serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 32-bit boundary, then ASSERT(). + If the register specified by Address >= 0x100, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param AndData The value to AND with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT32 +EFIAPI +PciCf8And32 ( + IN UINTN Address, + IN UINT32 AndData + ) +{ + ASSERT_INVALID_PCI_ADDRESS (Address, 3); + IoWrite32 (PCI_CONFIGURATION_ADDRESS_PORT, PCI_TO_CF8_ADDRESS (Address)); + return IoAnd32 ( + PCI_CONFIGURATION_DATA_PORT, + AndData + ); +} + +/** + Performs a bitwise AND of a 32-bit PCI configuration register with a 32-bit + value, followed a bitwise inclusive OR with another 32-bit value. + + Reads the 32-bit PCI configuration register specified by Address, performs a + bitwise AND between the read result and the value specified by AndData, + performs a bitwise inclusive OR between the result of the AND operation and + the value specified by OrData, and writes the result to the 32-bit PCI + configuration register specified by Address. The value written to the PCI + configuration register is returned. This function must guarantee that all PCI + read and write operations are serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 32-bit boundary, then ASSERT(). + If the register specified by Address >= 0x100, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param AndData The value to AND with the PCI configuration register. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the PCI configuration register. + +**/ +UINT32 +EFIAPI +PciCf8AndThenOr32 ( + IN UINTN Address, + IN UINT32 AndData, + IN UINT32 OrData + ) +{ + ASSERT_INVALID_PCI_ADDRESS (Address, 3); + IoWrite32 (PCI_CONFIGURATION_ADDRESS_PORT, PCI_TO_CF8_ADDRESS (Address)); + return IoAndThenOr32 ( + PCI_CONFIGURATION_DATA_PORT, + AndData, + OrData + ); +} + +/** + Reads a bit field of a PCI configuration register. + + Reads the bit field in a 32-bit PCI configuration register. The bit field is + specified by the StartBit and the EndBit. The value of the bit field is + returned. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 32-bit boundary, then ASSERT(). + If the register specified by Address >= 0x100, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to read. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + + @return The value of the bit field read from the PCI configuration register. + +**/ +UINT32 +EFIAPI +PciCf8BitFieldRead32 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit + ) +{ + ASSERT_INVALID_PCI_ADDRESS (Address, 3); + IoWrite32 (PCI_CONFIGURATION_ADDRESS_PORT, PCI_TO_CF8_ADDRESS (Address)); + return IoBitFieldRead32 ( + PCI_CONFIGURATION_DATA_PORT, + StartBit, + EndBit + ); +} + +/** + Writes a bit field to a PCI configuration register. + + Writes Value to the bit field of the PCI configuration register. The bit + field is specified by the StartBit and the EndBit. All other bits in the + destination PCI configuration register are preserved. The new value of the + 32-bit register is returned. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 32-bit boundary, then ASSERT(). + If the register specified by Address >= 0x100, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + @param Value New value of the bit field. + + @return The value written back to the PCI configuration register. + +**/ +UINT32 +EFIAPI +PciCf8BitFieldWrite32 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT32 Value + ) +{ + ASSERT_INVALID_PCI_ADDRESS (Address, 3); + IoWrite32 (PCI_CONFIGURATION_ADDRESS_PORT, PCI_TO_CF8_ADDRESS (Address)); + return IoBitFieldWrite32 ( + PCI_CONFIGURATION_DATA_PORT, + StartBit, + EndBit, + Value + ); +} + +/** + Reads a bit field in a 32-bit PCI configuration, performs a bitwise OR, and + writes the result back to the bit field in the 32-bit port. + + Reads the 32-bit PCI configuration register specified by Address, performs a + bitwise inclusive OR between the read result and the value specified by + OrData, and writes the result to the 32-bit PCI configuration register + specified by Address. The value written to the PCI configuration register is + returned. This function must guarantee that all PCI read and write operations + are serialized. Extra left bits in OrData are stripped. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 32-bit boundary, then ASSERT(). + If the register specified by Address >= 0x100, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + @param OrData The value to OR with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT32 +EFIAPI +PciCf8BitFieldOr32 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT32 OrData + ) +{ + ASSERT_INVALID_PCI_ADDRESS (Address, 3); + IoWrite32 (PCI_CONFIGURATION_ADDRESS_PORT, PCI_TO_CF8_ADDRESS (Address)); + return IoBitFieldOr32 ( + PCI_CONFIGURATION_DATA_PORT, + StartBit, + EndBit, + OrData + ); +} + +/** + Reads a bit field in a 32-bit PCI configuration register, performs a bitwise + AND, and writes the result back to the bit field in the 32-bit register. + + Reads the 32-bit PCI configuration register specified by Address, performs a + bitwise AND between the read result and the value specified by AndData, and + writes the result to the 32-bit PCI configuration register specified by + Address. The value written to the PCI configuration register is returned. + This function must guarantee that all PCI read and write operations are + serialized. Extra left bits in AndData are stripped. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 32-bit boundary, then ASSERT(). + If the register specified by Address >= 0x100, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + @param AndData The value to AND with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT32 +EFIAPI +PciCf8BitFieldAnd32 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT32 AndData + ) +{ + ASSERT_INVALID_PCI_ADDRESS (Address, 3); + IoWrite32 (PCI_CONFIGURATION_ADDRESS_PORT, PCI_TO_CF8_ADDRESS (Address)); + return IoBitFieldAnd32 ( + PCI_CONFIGURATION_DATA_PORT, + StartBit, + EndBit, + AndData + ); +} + +/** + Reads a bit field in a 32-bit port, performs a bitwise AND followed by a + bitwise inclusive OR, and writes the result back to the bit field in the + 32-bit port. + + Reads the 32-bit PCI configuration register specified by Address, performs a + bitwise AND followed by a bitwise inclusive OR between the read result and + the value specified by AndData, and writes the result to the 32-bit PCI + configuration register specified by Address. The value written to the PCI + configuration register is returned. This function must guarantee that all PCI + read and write operations are serialized. Extra left bits in both AndData and + OrData are stripped. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 32-bit boundary, then ASSERT(). + If the register specified by Address >= 0x100, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + @param AndData The value to AND with the PCI configuration register. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the PCI configuration register. + +**/ +UINT32 +EFIAPI +PciCf8BitFieldAndThenOr32( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT32 AndData, + IN UINT32 OrData + ) +{ + ASSERT_INVALID_PCI_ADDRESS (Address, 3); + IoWrite32 (PCI_CONFIGURATION_ADDRESS_PORT, PCI_TO_CF8_ADDRESS (Address)); + return IoBitFieldAndThenOr32 ( + PCI_CONFIGURATION_DATA_PORT, + StartBit, + EndBit, + AndData, + OrData + ); +} + +/** + Reads a range of PCI configuration registers into a caller supplied buffer. + + Reads the range of PCI configuration registers specified by StartAddress and + Size into the buffer specified by Buffer. This function only allows the PCI + configuration registers from a single PCI function to be read. Size is + returned. When possible 32-bit PCI configuration read cycles are used to read + from StartAdress to StartAddress + Size. Due to alignment restrictions, 8-bit + and 16-bit PCI configuration read cycles may be used at the beginning and the + end of the range. + + If StartAddress > 0x0FFFFFFF, then ASSERT(). + If the register specified by StartAddress >= 0x100, then ASSERT(). + If ((StartAddress & 0xFFF) + Size) > 0x100, then ASSERT(). + If Size > 0 and Buffer is NULL, then ASSERT(). + + @param StartAddress Starting address that encodes the PCI Bus, Device, + Function and Register. + @param Size Size in bytes of the transfer. + @param Buffer Pointer to a buffer receiving the data read. + + @return Size + +**/ +UINTN +EFIAPI +PciCf8ReadBuffer ( + IN UINTN StartAddress, + IN UINTN Size, + OUT VOID *Buffer + ) +{ + UINTN ReturnValue; + + ASSERT_INVALID_PCI_ADDRESS (StartAddress, 0); + ASSERT (((StartAddress & 0xFFF) + Size) <= 0x100); + + if (Size == 0) { + return Size; + } + + ASSERT (Buffer != NULL); + + // + // Save Size for return + // + ReturnValue = Size; + + if ((StartAddress & 1) != 0) { + // + // Read a byte if StartAddress is byte aligned + // + *(volatile UINT8 *)Buffer = PciCf8Read8 (StartAddress); + StartAddress += sizeof (UINT8); + Size -= sizeof (UINT8); + Buffer = (UINT8*)Buffer + 1; + } + + if (Size >= sizeof (UINT16) && (StartAddress & 2) != 0) { + // + // Read a word if StartAddress is word aligned + // + *(volatile UINT16 *)Buffer = PciCf8Read16 (StartAddress); + StartAddress += sizeof (UINT16); + Size -= sizeof (UINT16); + Buffer = (UINT16*)Buffer + 1; + } + + while (Size >= sizeof (UINT32)) { + // + // Read as many double words as possible + // + *(volatile UINT32 *)Buffer = PciCf8Read32 (StartAddress); + StartAddress += sizeof (UINT32); + Size -= sizeof (UINT32); + Buffer = (UINT32*)Buffer + 1; + } + + if (Size >= sizeof (UINT16)) { + // + // Read the last remaining word if exist + // + *(volatile UINT16 *)Buffer = PciCf8Read16 (StartAddress); + StartAddress += sizeof (UINT16); + Size -= sizeof (UINT16); + Buffer = (UINT16*)Buffer + 1; + } + + if (Size >= sizeof (UINT8)) { + // + // Read the last remaining byte if exist + // + *(volatile UINT8 *)Buffer = PciCf8Read8 (StartAddress); + } + + return ReturnValue; +} + +/** + Copies the data in a caller supplied buffer to a specified range of PCI + configuration space. + + Writes the range of PCI configuration registers specified by StartAddress and + Size from the buffer specified by Buffer. This function only allows the PCI + configuration registers from a single PCI function to be written. Size is + returned. When possible 32-bit PCI configuration write cycles are used to + write from StartAdress to StartAddress + Size. Due to alignment restrictions, + 8-bit and 16-bit PCI configuration write cycles may be used at the beginning + and the end of the range. + + If StartAddress > 0x0FFFFFFF, then ASSERT(). + If the register specified by StartAddress >= 0x100, then ASSERT(). + If ((StartAddress & 0xFFF) + Size) > 0x100, then ASSERT(). + If Size > 0 and Buffer is NULL, then ASSERT(). + + @param StartAddress Starting address that encodes the PCI Bus, Device, + Function and Register. + @param Size Size in bytes of the transfer. + @param Buffer Pointer to a buffer containing the data to write. + + @return Size + +**/ +UINTN +EFIAPI +PciCf8WriteBuffer ( + IN UINTN StartAddress, + IN UINTN Size, + IN VOID *Buffer + ) +{ + UINTN ReturnValue; + + ASSERT_INVALID_PCI_ADDRESS (StartAddress, 0); + ASSERT (((StartAddress & 0xFFF) + Size) <= 0x100); + + if (Size == 0) { + return 0; + } + + ASSERT (Buffer != NULL); + + // + // Save Size for return + // + ReturnValue = Size; + + if ((StartAddress & 1) != 0) { + // + // Write a byte if StartAddress is byte aligned + // + PciCf8Write8 (StartAddress, *(UINT8*)Buffer); + StartAddress += sizeof (UINT8); + Size -= sizeof (UINT8); + Buffer = (UINT8*)Buffer + 1; + } + + if (Size >= sizeof (UINT16) && (StartAddress & 2) != 0) { + // + // Write a word if StartAddress is word aligned + // + PciCf8Write16 (StartAddress, *(UINT16*)Buffer); + StartAddress += sizeof (UINT16); + Size -= sizeof (UINT16); + Buffer = (UINT16*)Buffer + 1; + } + + while (Size >= sizeof (UINT32)) { + // + // Write as many double words as possible + // + PciCf8Write32 (StartAddress, *(UINT32*)Buffer); + StartAddress += sizeof (UINT32); + Size -= sizeof (UINT32); + Buffer = (UINT32*)Buffer + 1; + } + + if (Size >= sizeof (UINT16)) { + // + // Write the last remaining word if exist + // + PciCf8Write16 (StartAddress, *(UINT16*)Buffer); + StartAddress += sizeof (UINT16); + Size -= sizeof (UINT16); + Buffer = (UINT16*)Buffer + 1; + } + + if (Size >= sizeof (UINT8)) { + // + // Write the last remaining byte if exist + // + PciCf8Write8 (StartAddress, *(UINT8*)Buffer); + } + + return ReturnValue; +} diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePciExpressLib/BasePciExpressLib.inf b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePciExpressLib/BasePciExpressLib.inf new file mode 100644 index 0000000..e179ebe --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePciExpressLib/BasePciExpressLib.inf @@ -0,0 +1,79 @@ +#/*++ +# +# 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: +# +# BasePciExpressLib.inf +# +# Abstract: +# +# Component description file for BasePciExpressLib. +# +#--*/ + +[defines] +BASE_NAME = EdkIIGlueBasePciExpressLib +COMPONENT_TYPE = LIBRARY + +[sources.common] + PciLib.c + +[sources.ia32] + + +[sources.x64] + + +[sources.ipf] + + +[sources.ebc] + + +[includes.common] + . + ..\..\Include + ..\..\Include\Library + $(EDK_SOURCE)\Foundation + $(EDK_SOURCE)\Foundation\Framework + $(EDK_SOURCE)\Foundation\Efi + $(EDK_SOURCE)\Foundation\Include + $(EDK_SOURCE)\Foundation\Efi\Include + $(EDK_SOURCE)\Foundation\Framework\Include + $(EDK_SOURCE)\Foundation\Include\IndustryStandard + $(EDK_SOURCE)\Foundation\Core\Dxe + $(EDK_SOURCE)\Foundation\Library\Dxe\Include + $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include + +[libraries.common] + EdkIIGlueBaseIoLibIntrinsic + +[libraries.ia32] + + +[libraries.x64] + + +[nmake.common] + C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION + LIB_STD_FLAGS = /NOLOGO /IGNORE:4006 + +[nmake.ia32] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32 + +[nmake.x64] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64 + +[nmake.ipf] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF + +[nmake.ebc] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_EBC
\ No newline at end of file diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePciExpressLib/EdkIIGlueBasePciExpressLib.cif b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePciExpressLib/EdkIIGlueBasePciExpressLib.cif new file mode 100644 index 0000000..73476ae --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePciExpressLib/EdkIIGlueBasePciExpressLib.cif @@ -0,0 +1,11 @@ +<component> + name = "EdkIIGlueBasePciExpressLib" + category = ModulePart + LocalRoot = "Edk\Foundation\Library\EdkIIGlueLib\Library\BasePciExpressLib" + RefName = "EdkIIGlueBasePciExpressLib" +[files] +"EdkIIGlueBasePciExpressLib.sdl" +"EdkIIGlueBasePciExpressLib.mak" +"BasePciExpressLib.inf" +"PciLib.c" +<endComponent> diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePciExpressLib/EdkIIGlueBasePciExpressLib.mak b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePciExpressLib/EdkIIGlueBasePciExpressLib.mak new file mode 100644 index 0000000..abe41a4 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePciExpressLib/EdkIIGlueBasePciExpressLib.mak @@ -0,0 +1,85 @@ +#********************************************************************** +#********************************************************************** +#** ** +#** (C)Copyright 1985-2009, American Megatrends, Inc. ** +#** ** +#** All Rights Reserved. ** +#** ** +#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +#** ** +#** Phone: (770)-246-8600 ** +#** ** +#********************************************************************** +#********************************************************************** + +#********************************************************************** +# $Header: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGlueBasePciExpressLib/EdkIIGlueBasePciExpressLib.mak 1 1/20/12 3:53a Jeffch $ +# +# $Revision: 1 $ +# +# $Date: 1/20/12 3:53a $ +#********************************************************************** +# Revision History +# ---------------- +# $Log: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGlueBasePciExpressLib/EdkIIGlueBasePciExpressLib.mak $ +# +# 1 1/20/12 3:53a Jeffch +# Create Intel EDK 1117 Patch 7. +# +# 1 9/27/11 6:15a Wesleychen +# Intel EDK initially releases. +# +# 1 9/18/09 1:52a Iminglin +# +#********************************************************************** +#<AMI_FHDR_START> +# +# Name: EdkIIGlueBasePciExpressLib.mak +# +# Description: +# +#<AMI_FHDR_END> +#********************************************************************** + + +$(EdkIIGlueBasePciExpressLib_LIB) : EdkIIGlueBasePciExpressLib + +EdkIIGlueBasePciExpressLib : $(BUILD_DIR)\EdkIIGlueBasePciExpressLib.mak EdkIIGlueBasePciExpressLibBin + +$(BUILD_DIR)\EdkIIGlueBasePciExpressLib.mak : $(EdkIIGlueBasePciExpressLib_DIR)\$(@B).cif $(EdkIIGlueBasePciExpressLib_DIR)\$(@B).mak $(BUILD_RULES) + $(CIF2MAK) $(EdkIIGlueBasePciExpressLib_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS) + +EdkIIGlueBasePciExpressLib_LIB_LINKS=\ +!IF "$(PROCESSOR)"=="IA32" || "$(PROCESSOR)"=="x64" +$(EdkIIGlueBaseIoLibIntrinsic_LIB) +!ENDIF + +EdkIIGlueBasePciExpressLibBin : $(EdkIIGlueBasePciExpressLib_LIB_LINKS) +!IF "$(x64_BUILD)"=="1" + $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\ + BUILD_DIR=$(BUILD_DIR)\ + /f $(BUILD_DIR)\EdkIIGlueBasePciExpressLib.mak all\ + TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueBasePciExpressLib_LIB)" + $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\ + BUILD_DIR=$(BUILD_DIR)\IA32\ + /f $(BUILD_DIR)\EdkIIGlueBasePciExpressLib.mak all\ + TYPE=PEI_LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueBasePciExpressLib_LIB)" +!ELSE + $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\ + BUILD_DIR=$(BUILD_DIR)\ + /f $(BUILD_DIR)\EdkIIGlueBasePciExpressLib.mak all\ + TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueBasePciExpressLib_LIB)" +!ENDIF +#********************************************************************** +#********************************************************************** +#** ** +#** (C)Copyright 1985-2009, American Megatrends, Inc. ** +#** ** +#** All Rights Reserved. ** +#** ** +#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +#** ** +#** Phone: (770)-246-8600 ** +#** ** +#********************************************************************** +#********************************************************************** diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePciExpressLib/EdkIIGlueBasePciExpressLib.sdl b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePciExpressLib/EdkIIGlueBasePciExpressLib.sdl new file mode 100644 index 0000000..fe523de --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePciExpressLib/EdkIIGlueBasePciExpressLib.sdl @@ -0,0 +1,26 @@ +TOKEN + Name = "EdkIIGlueBasePciExpressLib_SUPPORT" + Value = "1" + Help = "Main switch to enable EdkIIGlueBasePciExpressLib support in Project" + TokenType = Boolean + TargetEQU = Yes + TargetMAK = Yes + Master = Yes +End + +TOKEN + Name = "EdkIIGlueBasePciExpressLib_LIB" + Value = "$$(LIB_BUILD_DIR)\EdkIIGlueBasePciExpressLib.lib" + TokenType = Expression + TargetMAK = Yes +End + +PATH + Name = "EdkIIGlueBasePciExpressLib_DIR" +End + +MODULE + Help = "Includes EdkIIGlueBasePciExpressLib.mak to Project" + File = "EdkIIGlueBasePciExpressLib.mak" +End + diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePciExpressLib/PciLib.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePciExpressLib/PciLib.c new file mode 100644 index 0000000..ba78a78 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePciExpressLib/PciLib.c @@ -0,0 +1,1377 @@ +/*++ + +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: + + PciLib.c + +Abstract: + + PCI Library. + + Functions in this library instance make use of MMIO functions in IoLib to + access memory mapped PCI configuration space. + + All assertions for I/O operations are handled in MMIO functions in the IoLib + Library. + +--*/ + +#include "EdkIIGlueBase.h" +#include "Pcd\EdkIIGluePcdPciExpressLib.h" + +/** + Assert the validity of a PCI address. A valid PCI address should contain 1's + only in the low 28 bits. + + @param A The address to validate. + +**/ +// +// Uncommenting this will improve verification of PCI address validity, but will make the debug size significantly larger. +// +#define ASSERT_INVALID_PCI_ADDRESS(A) +// #define ASSERT_INVALID_PCI_ADDRESS(A) \ +// ASSERT (((A) & ~0xfffffff) == 0) + + +/** + Gets the base address of PCI Express. + + This internal functions retrieves PCI Express Base Address via a PCD entry + PcdPciExpressBaseAddress. + + @return The base address of PCI Express. + +**/ +volatile VOID* +GetPciExpressBaseAddress ( + VOID + ) +{ + return (VOID*)(UINTN) PcdGet64 (PcdPciExpressBaseAddress); +} + +/** + Reads an 8-bit PCI configuration register. + + Reads and returns the 8-bit PCI configuration register specified by Address. + This function must guarantee that all PCI read and write operations are + serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + + @return The read value from the PCI configuration register. + +**/ +UINT8 +EFIAPI +PciExpressRead8 ( + IN UINTN Address + ) +{ + ASSERT_INVALID_PCI_ADDRESS (Address); + return MmioRead8 ((UINTN) GetPciExpressBaseAddress () + Address); +} + +/** + Writes an 8-bit PCI configuration register. + + Writes the 8-bit PCI configuration register specified by Address with the + value specified by Value. Value is returned. This function must guarantee + that all PCI read and write operations are serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param Value The value to write. + + @return The value written to the PCI configuration register. + +**/ +UINT8 +EFIAPI +PciExpressWrite8 ( + IN UINTN Address, + IN UINT8 Value + ) +{ + ASSERT_INVALID_PCI_ADDRESS (Address); + return MmioWrite8 ((UINTN) GetPciExpressBaseAddress () + Address, Value); +} + +/** + Performs a bitwise inclusive OR of an 8-bit PCI configuration register with + an 8-bit value. + + Reads the 8-bit PCI configuration register specified by Address, performs a + bitwise inclusive OR between the read result and the value specified by + OrData, and writes the result to the 8-bit PCI configuration register + specified by Address. The value written to the PCI configuration register is + returned. This function must guarantee that all PCI read and write operations + are serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param OrData The value to OR with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT8 +EFIAPI +PciExpressOr8 ( + IN UINTN Address, + IN UINT8 OrData + ) +{ + ASSERT_INVALID_PCI_ADDRESS (Address); + return MmioOr8 ((UINTN) GetPciExpressBaseAddress () + Address, OrData); +} + +/** + Performs a bitwise AND of an 8-bit PCI configuration register with an 8-bit + value. + + Reads the 8-bit PCI configuration register specified by Address, performs a + bitwise AND between the read result and the value specified by AndData, and + writes the result to the 8-bit PCI configuration register specified by + Address. The value written to the PCI configuration register is returned. + This function must guarantee that all PCI read and write operations are + serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param AndData The value to AND with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT8 +EFIAPI +PciExpressAnd8 ( + IN UINTN Address, + IN UINT8 AndData + ) +{ + ASSERT_INVALID_PCI_ADDRESS (Address); + return MmioAnd8 ((UINTN) GetPciExpressBaseAddress () + Address, AndData); +} + +/** + Performs a bitwise AND of an 8-bit PCI configuration register with an 8-bit + value, followed a bitwise inclusive OR with another 8-bit value. + + Reads the 8-bit PCI configuration register specified by Address, performs a + bitwise AND between the read result and the value specified by AndData, + performs a bitwise inclusive OR between the result of the AND operation and + the value specified by OrData, and writes the result to the 8-bit PCI + configuration register specified by Address. The value written to the PCI + configuration register is returned. This function must guarantee that all PCI + read and write operations are serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param AndData The value to AND with the PCI configuration register. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the PCI configuration register. + +**/ +UINT8 +EFIAPI +PciExpressAndThenOr8 ( + IN UINTN Address, + IN UINT8 AndData, + IN UINT8 OrData + ) +{ + ASSERT_INVALID_PCI_ADDRESS (Address); + return MmioAndThenOr8 ( + (UINTN) GetPciExpressBaseAddress () + Address, + AndData, + OrData + ); +} + +/** + Reads a bit field of a PCI configuration register. + + Reads the bit field in an 8-bit PCI configuration register. The bit field is + specified by the StartBit and the EndBit. The value of the bit field is + returned. + + If Address > 0x0FFFFFFF, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to read. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..7. + + @return The value of the bit field read from the PCI configuration register. + +**/ +UINT8 +EFIAPI +PciExpressBitFieldRead8 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit + ) +{ + ASSERT_INVALID_PCI_ADDRESS (Address); + return MmioBitFieldRead8 ( + (UINTN) GetPciExpressBaseAddress () + Address, + StartBit, + EndBit + ); +} + +/** + Writes a bit field to a PCI configuration register. + + Writes Value to the bit field of the PCI configuration register. The bit + field is specified by the StartBit and the EndBit. All other bits in the + destination PCI configuration register are preserved. The new value of the + 8-bit register is returned. + + If Address > 0x0FFFFFFF, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..7. + @param Value New value of the bit field. + + @return The value written back to the PCI configuration register. + +**/ +UINT8 +EFIAPI +PciExpressBitFieldWrite8 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT8 Value + ) +{ + ASSERT_INVALID_PCI_ADDRESS (Address); + return MmioBitFieldWrite8 ( + (UINTN) GetPciExpressBaseAddress () + Address, + StartBit, + EndBit, + Value + ); +} + +/** + Reads a bit field in an 8-bit PCI configuration, performs a bitwise OR, and + writes the result back to the bit field in the 8-bit port. + + Reads the 8-bit PCI configuration register specified by Address, performs a + bitwise inclusive OR between the read result and the value specified by + OrData, and writes the result to the 8-bit PCI configuration register + specified by Address. The value written to the PCI configuration register is + returned. This function must guarantee that all PCI read and write operations + are serialized. Extra left bits in OrData are stripped. + + If Address > 0x0FFFFFFF, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..7. + @param OrData The value to OR with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT8 +EFIAPI +PciExpressBitFieldOr8 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT8 OrData + ) +{ + ASSERT_INVALID_PCI_ADDRESS (Address); + return MmioBitFieldOr8 ( + (UINTN) GetPciExpressBaseAddress () + Address, + StartBit, + EndBit, + OrData + ); +} + +/** + Reads a bit field in an 8-bit PCI configuration register, performs a bitwise + AND, and writes the result back to the bit field in the 8-bit register. + + Reads the 8-bit PCI configuration register specified by Address, performs a + bitwise AND between the read result and the value specified by AndData, and + writes the result to the 8-bit PCI configuration register specified by + Address. The value written to the PCI configuration register is returned. + This function must guarantee that all PCI read and write operations are + serialized. Extra left bits in AndData are stripped. + + If Address > 0x0FFFFFFF, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..7. + @param AndData The value to AND with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT8 +EFIAPI +PciExpressBitFieldAnd8 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT8 AndData + ) +{ + ASSERT_INVALID_PCI_ADDRESS (Address); + return MmioBitFieldAnd8 ( + (UINTN) GetPciExpressBaseAddress () + Address, + StartBit, + EndBit, + AndData + ); +} + +/** + Reads a bit field in an 8-bit port, performs a bitwise AND followed by a + bitwise inclusive OR, and writes the result back to the bit field in the + 8-bit port. + + Reads the 8-bit PCI configuration register specified by Address, performs a + bitwise AND followed by a bitwise inclusive OR between the read result and + the value specified by AndData, and writes the result to the 8-bit PCI + configuration register specified by Address. The value written to the PCI + configuration register is returned. This function must guarantee that all PCI + read and write operations are serialized. Extra left bits in both AndData and + OrData are stripped. + + If Address > 0x0FFFFFFF, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..7. + @param AndData The value to AND with the PCI configuration register. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the PCI configuration register. + +**/ +UINT8 +EFIAPI +PciExpressBitFieldAndThenOr8 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT8 AndData, + IN UINT8 OrData + ) +{ + ASSERT_INVALID_PCI_ADDRESS (Address); + return MmioBitFieldAndThenOr8 ( + (UINTN) GetPciExpressBaseAddress () + Address, + StartBit, + EndBit, + AndData, + OrData + ); +} + +/** + Reads a 16-bit PCI configuration register. + + Reads and returns the 16-bit PCI configuration register specified by Address. + This function must guarantee that all PCI read and write operations are + serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 16-bit boundary, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + + @return The read value from the PCI configuration register. + +**/ +UINT16 +EFIAPI +PciExpressRead16 ( + IN UINTN Address + ) +{ + ASSERT_INVALID_PCI_ADDRESS (Address); + return MmioRead16 ((UINTN) GetPciExpressBaseAddress () + Address); +} + +/** + Writes a 16-bit PCI configuration register. + + Writes the 16-bit PCI configuration register specified by Address with the + value specified by Value. Value is returned. This function must guarantee + that all PCI read and write operations are serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 16-bit boundary, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param Value The value to write. + + @return The value written to the PCI configuration register. + +**/ +UINT16 +EFIAPI +PciExpressWrite16 ( + IN UINTN Address, + IN UINT16 Value + ) +{ + ASSERT_INVALID_PCI_ADDRESS (Address); + return MmioWrite16 ((UINTN) GetPciExpressBaseAddress () + Address, Value); +} + +/** + Performs a bitwise inclusive OR of a 16-bit PCI configuration register with + a 16-bit value. + + Reads the 16-bit PCI configuration register specified by Address, performs a + bitwise inclusive OR between the read result and the value specified by + OrData, and writes the result to the 16-bit PCI configuration register + specified by Address. The value written to the PCI configuration register is + returned. This function must guarantee that all PCI read and write operations + are serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 16-bit boundary, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param OrData The value to OR with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT16 +EFIAPI +PciExpressOr16 ( + IN UINTN Address, + IN UINT16 OrData + ) +{ + ASSERT_INVALID_PCI_ADDRESS (Address); + return MmioOr16 ((UINTN) GetPciExpressBaseAddress () + Address, OrData); +} + +/** + Performs a bitwise AND of a 16-bit PCI configuration register with a 16-bit + value. + + Reads the 16-bit PCI configuration register specified by Address, performs a + bitwise AND between the read result and the value specified by AndData, and + writes the result to the 16-bit PCI configuration register specified by + Address. The value written to the PCI configuration register is returned. + This function must guarantee that all PCI read and write operations are + serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 16-bit boundary, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param AndData The value to AND with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT16 +EFIAPI +PciExpressAnd16 ( + IN UINTN Address, + IN UINT16 AndData + ) +{ + ASSERT_INVALID_PCI_ADDRESS (Address); + return MmioAnd16 ((UINTN) GetPciExpressBaseAddress () + Address, AndData); +} + +/** + Performs a bitwise AND of a 16-bit PCI configuration register with a 16-bit + value, followed a bitwise inclusive OR with another 16-bit value. + + Reads the 16-bit PCI configuration register specified by Address, performs a + bitwise AND between the read result and the value specified by AndData, + performs a bitwise inclusive OR between the result of the AND operation and + the value specified by OrData, and writes the result to the 16-bit PCI + configuration register specified by Address. The value written to the PCI + configuration register is returned. This function must guarantee that all PCI + read and write operations are serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 16-bit boundary, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param AndData The value to AND with the PCI configuration register. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the PCI configuration register. + +**/ +UINT16 +EFIAPI +PciExpressAndThenOr16 ( + IN UINTN Address, + IN UINT16 AndData, + IN UINT16 OrData + ) +{ + ASSERT_INVALID_PCI_ADDRESS (Address); + return MmioAndThenOr16 ( + (UINTN) GetPciExpressBaseAddress () + Address, + AndData, + OrData + ); +} + +/** + Reads a bit field of a PCI configuration register. + + Reads the bit field in a 16-bit PCI configuration register. The bit field is + specified by the StartBit and the EndBit. The value of the bit field is + returned. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 16-bit boundary, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to read. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..15. + + @return The value of the bit field read from the PCI configuration register. + +**/ +UINT16 +EFIAPI +PciExpressBitFieldRead16 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit + ) +{ + ASSERT_INVALID_PCI_ADDRESS (Address); + return MmioBitFieldRead16 ( + (UINTN) GetPciExpressBaseAddress () + Address, + StartBit, + EndBit + ); +} + +/** + Writes a bit field to a PCI configuration register. + + Writes Value to the bit field of the PCI configuration register. The bit + field is specified by the StartBit and the EndBit. All other bits in the + destination PCI configuration register are preserved. The new value of the + 16-bit register is returned. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 16-bit boundary, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..15. + @param Value New value of the bit field. + + @return The value written back to the PCI configuration register. + +**/ +UINT16 +EFIAPI +PciExpressBitFieldWrite16 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT16 Value + ) +{ + ASSERT_INVALID_PCI_ADDRESS (Address); + return MmioBitFieldWrite16 ( + (UINTN) GetPciExpressBaseAddress () + Address, + StartBit, + EndBit, + Value + ); +} + +/** + Reads a bit field in a 16-bit PCI configuration, performs a bitwise OR, and + writes the result back to the bit field in the 16-bit port. + + Reads the 16-bit PCI configuration register specified by Address, performs a + bitwise inclusive OR between the read result and the value specified by + OrData, and writes the result to the 16-bit PCI configuration register + specified by Address. The value written to the PCI configuration register is + returned. This function must guarantee that all PCI read and write operations + are serialized. Extra left bits in OrData are stripped. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 16-bit boundary, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..15. + @param OrData The value to OR with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT16 +EFIAPI +PciExpressBitFieldOr16 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT16 OrData + ) +{ + ASSERT_INVALID_PCI_ADDRESS (Address); + return MmioBitFieldOr16 ( + (UINTN) GetPciExpressBaseAddress () + Address, + StartBit, + EndBit, + OrData + ); +} + +/** + Reads a bit field in a 16-bit PCI configuration register, performs a bitwise + AND, and writes the result back to the bit field in the 16-bit register. + + Reads the 16-bit PCI configuration register specified by Address, performs a + bitwise AND between the read result and the value specified by AndData, and + writes the result to the 16-bit PCI configuration register specified by + Address. The value written to the PCI configuration register is returned. + This function must guarantee that all PCI read and write operations are + serialized. Extra left bits in AndData are stripped. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 16-bit boundary, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..15. + @param AndData The value to AND with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT16 +EFIAPI +PciExpressBitFieldAnd16 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT16 AndData + ) +{ + ASSERT_INVALID_PCI_ADDRESS (Address); + return MmioBitFieldAnd16 ( + (UINTN) GetPciExpressBaseAddress () + Address, + StartBit, + EndBit, + AndData + ); +} + +/** + Reads a bit field in a 16-bit port, performs a bitwise AND followed by a + bitwise inclusive OR, and writes the result back to the bit field in the + 16-bit port. + + Reads the 16-bit PCI configuration register specified by Address, performs a + bitwise AND followed by a bitwise inclusive OR between the read result and + the value specified by AndData, and writes the result to the 16-bit PCI + configuration register specified by Address. The value written to the PCI + configuration register is returned. This function must guarantee that all PCI + read and write operations are serialized. Extra left bits in both AndData and + OrData are stripped. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 16-bit boundary, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..15. + @param AndData The value to AND with the PCI configuration register. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the PCI configuration register. + +**/ +UINT16 +EFIAPI +PciExpressBitFieldAndThenOr16 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT16 AndData, + IN UINT16 OrData + ) +{ + ASSERT_INVALID_PCI_ADDRESS (Address); + return MmioBitFieldAndThenOr16 ( + (UINTN) GetPciExpressBaseAddress () + Address, + StartBit, + EndBit, + AndData, + OrData + ); +} + +/** + Reads a 32-bit PCI configuration register. + + Reads and returns the 32-bit PCI configuration register specified by Address. + This function must guarantee that all PCI read and write operations are + serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 32-bit boundary, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + + @return The read value from the PCI configuration register. + +**/ +UINT32 +EFIAPI +PciExpressRead32 ( + IN UINTN Address + ) +{ + ASSERT_INVALID_PCI_ADDRESS (Address); + return MmioRead32 ((UINTN) GetPciExpressBaseAddress () + Address); +} + +/** + Writes a 32-bit PCI configuration register. + + Writes the 32-bit PCI configuration register specified by Address with the + value specified by Value. Value is returned. This function must guarantee + that all PCI read and write operations are serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 32-bit boundary, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param Value The value to write. + + @return The value written to the PCI configuration register. + +**/ +UINT32 +EFIAPI +PciExpressWrite32 ( + IN UINTN Address, + IN UINT32 Value + ) +{ + ASSERT_INVALID_PCI_ADDRESS (Address); + return MmioWrite32 ((UINTN) GetPciExpressBaseAddress () + Address, Value); +} + +/** + Performs a bitwise inclusive OR of a 32-bit PCI configuration register with + a 32-bit value. + + Reads the 32-bit PCI configuration register specified by Address, performs a + bitwise inclusive OR between the read result and the value specified by + OrData, and writes the result to the 32-bit PCI configuration register + specified by Address. The value written to the PCI configuration register is + returned. This function must guarantee that all PCI read and write operations + are serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 32-bit boundary, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param OrData The value to OR with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT32 +EFIAPI +PciExpressOr32 ( + IN UINTN Address, + IN UINT32 OrData + ) +{ + ASSERT_INVALID_PCI_ADDRESS (Address); + return MmioOr32 ((UINTN) GetPciExpressBaseAddress () + Address, OrData); +} + +/** + Performs a bitwise AND of a 32-bit PCI configuration register with a 32-bit + value. + + Reads the 32-bit PCI configuration register specified by Address, performs a + bitwise AND between the read result and the value specified by AndData, and + writes the result to the 32-bit PCI configuration register specified by + Address. The value written to the PCI configuration register is returned. + This function must guarantee that all PCI read and write operations are + serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 32-bit boundary, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param AndData The value to AND with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT32 +EFIAPI +PciExpressAnd32 ( + IN UINTN Address, + IN UINT32 AndData + ) +{ + ASSERT_INVALID_PCI_ADDRESS (Address); + return MmioAnd32 ((UINTN) GetPciExpressBaseAddress () + Address, AndData); +} + +/** + Performs a bitwise AND of a 32-bit PCI configuration register with a 32-bit + value, followed a bitwise inclusive OR with another 32-bit value. + + Reads the 32-bit PCI configuration register specified by Address, performs a + bitwise AND between the read result and the value specified by AndData, + performs a bitwise inclusive OR between the result of the AND operation and + the value specified by OrData, and writes the result to the 32-bit PCI + configuration register specified by Address. The value written to the PCI + configuration register is returned. This function must guarantee that all PCI + read and write operations are serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 32-bit boundary, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param AndData The value to AND with the PCI configuration register. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the PCI configuration register. + +**/ +UINT32 +EFIAPI +PciExpressAndThenOr32 ( + IN UINTN Address, + IN UINT32 AndData, + IN UINT32 OrData + ) +{ + ASSERT_INVALID_PCI_ADDRESS (Address); + return MmioAndThenOr32 ( + (UINTN) GetPciExpressBaseAddress () + Address, + AndData, + OrData + ); +} + +/** + Reads a bit field of a PCI configuration register. + + Reads the bit field in a 32-bit PCI configuration register. The bit field is + specified by the StartBit and the EndBit. The value of the bit field is + returned. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 32-bit boundary, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to read. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + + @return The value of the bit field read from the PCI configuration register. + +**/ +UINT32 +EFIAPI +PciExpressBitFieldRead32 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit + ) +{ + ASSERT_INVALID_PCI_ADDRESS (Address); + return MmioBitFieldRead32 ( + (UINTN) GetPciExpressBaseAddress () + Address, + StartBit, + EndBit + ); +} + +/** + Writes a bit field to a PCI configuration register. + + Writes Value to the bit field of the PCI configuration register. The bit + field is specified by the StartBit and the EndBit. All other bits in the + destination PCI configuration register are preserved. The new value of the + 32-bit register is returned. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 32-bit boundary, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + @param Value New value of the bit field. + + @return The value written back to the PCI configuration register. + +**/ +UINT32 +EFIAPI +PciExpressBitFieldWrite32 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT32 Value + ) +{ + ASSERT_INVALID_PCI_ADDRESS (Address); + return MmioBitFieldWrite32 ( + (UINTN) GetPciExpressBaseAddress () + Address, + StartBit, + EndBit, + Value + ); +} + +/** + Reads a bit field in a 32-bit PCI configuration, performs a bitwise OR, and + writes the result back to the bit field in the 32-bit port. + + Reads the 32-bit PCI configuration register specified by Address, performs a + bitwise inclusive OR between the read result and the value specified by + OrData, and writes the result to the 32-bit PCI configuration register + specified by Address. The value written to the PCI configuration register is + returned. This function must guarantee that all PCI read and write operations + are serialized. Extra left bits in OrData are stripped. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 32-bit boundary, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + @param OrData The value to OR with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT32 +EFIAPI +PciExpressBitFieldOr32 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT32 OrData + ) +{ + ASSERT_INVALID_PCI_ADDRESS (Address); + return MmioBitFieldOr32 ( + (UINTN) GetPciExpressBaseAddress () + Address, + StartBit, + EndBit, + OrData + ); +} + +/** + Reads a bit field in a 32-bit PCI configuration register, performs a bitwise + AND, and writes the result back to the bit field in the 32-bit register. + + Reads the 32-bit PCI configuration register specified by Address, performs a + bitwise AND between the read result and the value specified by AndData, and + writes the result to the 32-bit PCI configuration register specified by + Address. The value written to the PCI configuration register is returned. + This function must guarantee that all PCI read and write operations are + serialized. Extra left bits in AndData are stripped. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 32-bit boundary, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + @param AndData The value to AND with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT32 +EFIAPI +PciExpressBitFieldAnd32 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT32 AndData + ) +{ + ASSERT_INVALID_PCI_ADDRESS (Address); + return MmioBitFieldAnd32 ( + (UINTN) GetPciExpressBaseAddress () + Address, + StartBit, + EndBit, + AndData + ); +} + +/** + Reads a bit field in a 32-bit port, performs a bitwise AND followed by a + bitwise inclusive OR, and writes the result back to the bit field in the + 32-bit port. + + Reads the 32-bit PCI configuration register specified by Address, performs a + bitwise AND followed by a bitwise inclusive OR between the read result and + the value specified by AndData, and writes the result to the 32-bit PCI + configuration register specified by Address. The value written to the PCI + configuration register is returned. This function must guarantee that all PCI + read and write operations are serialized. Extra left bits in both AndData and + OrData are stripped. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 32-bit boundary, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + @param AndData The value to AND with the PCI configuration register. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the PCI configuration register. + +**/ +UINT32 +EFIAPI +PciExpressBitFieldAndThenOr32 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT32 AndData, + IN UINT32 OrData + ) +{ + ASSERT_INVALID_PCI_ADDRESS (Address); + return MmioBitFieldAndThenOr32 ( + (UINTN) GetPciExpressBaseAddress () + Address, + StartBit, + EndBit, + AndData, + OrData + ); +} + +/** + Reads a range of PCI configuration registers into a caller supplied buffer. + + Reads the range of PCI configuration registers specified by StartAddress and + Size into the buffer specified by Buffer. This function only allows the PCI + configuration registers from a single PCI function to be read. Size is + returned. When possible 32-bit PCI configuration read cycles are used to read + from StartAdress to StartAddress + Size. Due to alignment restrictions, 8-bit + and 16-bit PCI configuration read cycles may be used at the beginning and the + end of the range. + + If StartAddress > 0x0FFFFFFF, then ASSERT(). + If ((StartAddress & 0xFFF) + Size) > 0x1000, then ASSERT(). + If Size > 0 and Buffer is NULL, then ASSERT(). + + @param StartAddress Starting address that encodes the PCI Bus, Device, + Function and Register. + @param Size Size in bytes of the transfer. + @param Buffer Pointer to a buffer receiving the data read. + + @return Size + +**/ +UINTN +EFIAPI +PciExpressReadBuffer ( + IN UINTN StartAddress, + IN UINTN Size, + OUT VOID *Buffer + ) +{ + UINTN ReturnValue; + + ASSERT_INVALID_PCI_ADDRESS (StartAddress); + ASSERT (((StartAddress & 0xFFF) + Size) <= 0x1000); + + if (Size == 0) { + return Size; + } + + ASSERT (Buffer != NULL); + + // + // Save Size for return + // + ReturnValue = Size; + + if ((StartAddress & 1) != 0) { + // + // Read a byte if StartAddress is byte aligned + // + *(volatile UINT8 *)Buffer = PciExpressRead8 (StartAddress); + StartAddress += sizeof (UINT8); + Size -= sizeof (UINT8); + Buffer = (UINT8*)Buffer + 1; + } + + if (Size >= sizeof (UINT16) && (StartAddress & 2) != 0) { + // + // Read a word if StartAddress is word aligned + // + *(volatile UINT16 *)Buffer = PciExpressRead16 (StartAddress); + StartAddress += sizeof (UINT16); + Size -= sizeof (UINT16); + Buffer = (UINT16*)Buffer + 1; + } + + while (Size >= sizeof (UINT32)) { + // + // Read as many double words as possible + // + *(volatile UINT32 *)Buffer = PciExpressRead32 (StartAddress); + StartAddress += sizeof (UINT32); + Size -= sizeof (UINT32); + Buffer = (UINT32*)Buffer + 1; + } + + if (Size >= sizeof (UINT16)) { + // + // Read the last remaining word if exist + // + *(volatile UINT16 *)Buffer = PciExpressRead16 (StartAddress); + StartAddress += sizeof (UINT16); + Size -= sizeof (UINT16); + Buffer = (UINT16*)Buffer + 1; + } + + if (Size >= sizeof (UINT8)) { + // + // Read the last remaining byte if exist + // + *(volatile UINT8 *)Buffer = PciExpressRead8 (StartAddress); + } + + return ReturnValue; +} + +/** + Copies the data in a caller supplied buffer to a specified range of PCI + configuration space. + + Writes the range of PCI configuration registers specified by StartAddress and + Size from the buffer specified by Buffer. This function only allows the PCI + configuration registers from a single PCI function to be written. Size is + returned. When possible 32-bit PCI configuration write cycles are used to + write from StartAdress to StartAddress + Size. Due to alignment restrictions, + 8-bit and 16-bit PCI configuration write cycles may be used at the beginning + and the end of the range. + + If StartAddress > 0x0FFFFFFF, then ASSERT(). + If ((StartAddress & 0xFFF) + Size) > 0x1000, then ASSERT(). + If Size > 0 and Buffer is NULL, then ASSERT(). + + @param StartAddress Starting address that encodes the PCI Bus, Device, + Function and Register. + @param Size Size in bytes of the transfer. + @param Buffer Pointer to a buffer containing the data to write. + + @return Size + +**/ +UINTN +EFIAPI +PciExpressWriteBuffer ( + IN UINTN StartAddress, + IN UINTN Size, + IN VOID *Buffer + ) +{ + UINTN ReturnValue; + + ASSERT_INVALID_PCI_ADDRESS (StartAddress); + ASSERT (((StartAddress & 0xFFF) + Size) <= 0x1000); + + if (Size == 0) { + return 0; + } + + ASSERT (Buffer != NULL); + + // + // Save Size for return + // + ReturnValue = Size; + + if ((StartAddress & 1) != 0) { + // + // Write a byte if StartAddress is byte aligned + // + PciExpressWrite8 (StartAddress, *(UINT8*)Buffer); + StartAddress += sizeof (UINT8); + Size -= sizeof (UINT8); + Buffer = (UINT8*)Buffer + 1; + } + + if (Size >= sizeof (UINT16) && (StartAddress & 2) != 0) { + // + // Write a word if StartAddress is word aligned + // + PciExpressWrite16 (StartAddress, *(UINT16*)Buffer); + StartAddress += sizeof (UINT16); + Size -= sizeof (UINT16); + Buffer = (UINT16*)Buffer + 1; + } + + while (Size >= sizeof (UINT32)) { + // + // Write as many double words as possible + // + PciExpressWrite32 (StartAddress, *(UINT32*)Buffer); + StartAddress += sizeof (UINT32); + Size -= sizeof (UINT32); + Buffer = (UINT32*)Buffer + 1; + } + + if (Size >= sizeof (UINT16)) { + // + // Write the last remaining word if exist + // + PciExpressWrite16 (StartAddress, *(UINT16*)Buffer); + StartAddress += sizeof (UINT16); + Size -= sizeof (UINT16); + Buffer = (UINT16*)Buffer + 1; + } + + if (Size >= sizeof (UINT8)) { + // + // Write the last remaining byte if exist + // + PciExpressWrite8 (StartAddress, *(UINT8*)Buffer); + } + + return ReturnValue; +} diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePciLibCf8/BasePciLibCf8.inf b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePciLibCf8/BasePciLibCf8.inf new file mode 100644 index 0000000..a543f41 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePciLibCf8/BasePciLibCf8.inf @@ -0,0 +1,79 @@ +#/*++ +# +# 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: +# +# BasePciLibCf8.inf +# +# Abstract: +# +# Component description file for BasePciLibCf8. +# +#--*/ + +[defines] +BASE_NAME = EdkIIGlueBasePciLibCf8 +COMPONENT_TYPE = LIBRARY + +[sources.common] + PciLib.c + +[sources.ia32] + + +[sources.x64] + + +[sources.ipf] + + +[sources.ebc] + + +[includes.common] + . + ..\..\Include + ..\..\include\Library + $(EDK_SOURCE)\Foundation + $(EDK_SOURCE)\Foundation\Framework + $(EDK_SOURCE)\Foundation\Efi + $(EDK_SOURCE)\Foundation\Include + $(EDK_SOURCE)\Foundation\Efi\Include + $(EDK_SOURCE)\Foundation\Framework\Include + $(EDK_SOURCE)\Foundation\Include\IndustryStandard + $(EDK_SOURCE)\Foundation\Core\Dxe + $(EDK_SOURCE)\Foundation\Library\Dxe\Include + $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include + +[libraries.common] + EdkIIGlueBasePciCf8Lib + +[libraries.ia32] + + +[libraries.x64] + + +[nmake.common] + C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION + LIB_STD_FLAGS = /NOLOGO /IGNORE:4006 + +[nmake.ia32] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32 + +[nmake.x64] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64 + +[nmake.ipf] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF + +[nmake.ebc] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_EBC
\ No newline at end of file diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePciLibCf8/EdkIIGlueBasePciLibCf8.cif b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePciLibCf8/EdkIIGlueBasePciLibCf8.cif new file mode 100644 index 0000000..db1ff75 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePciLibCf8/EdkIIGlueBasePciLibCf8.cif @@ -0,0 +1,11 @@ +<component> + name = "EdkIIGlueBasePciLibCf8" + category = ModulePart + LocalRoot = "Edk\Foundation\Library\EdkIIGlueLib\Library\BasePciLibCf8" + RefName = "EdkIIGlueBasePciLibCf8" +[files] +"EdkIIGlueBasePciLibCf8.sdl" +"EdkIIGlueBasePciLibCf8.mak" +"BasePciLibCf8.inf" +"PciLib.c" +<endComponent> diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePciLibCf8/EdkIIGlueBasePciLibCf8.mak b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePciLibCf8/EdkIIGlueBasePciLibCf8.mak new file mode 100644 index 0000000..8aa5b37 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePciLibCf8/EdkIIGlueBasePciLibCf8.mak @@ -0,0 +1,80 @@ +#********************************************************************** +#********************************************************************** +#** ** +#** (C)Copyright 1985-2009, American Megatrends, Inc. ** +#** ** +#** All Rights Reserved. ** +#** ** +#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +#** ** +#** Phone: (770)-246-8600 ** +#** ** +#********************************************************************** +#********************************************************************** + +#********************************************************************** +# $Header: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGlueBasePciLibCf8/EdkIIGlueBasePciLibCf8.mak 1 1/20/12 3:53a Jeffch $ +# +# $Revision: 1 $ +# +# $Date: 1/20/12 3:53a $ +#********************************************************************** +# Revision History +# ---------------- +# $Log: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGlueBasePciLibCf8/EdkIIGlueBasePciLibCf8.mak $ +# +# 1 1/20/12 3:53a Jeffch +# Create Intel EDK 1117 Patch 7. +# +# 1 9/27/11 6:15a Wesleychen +# Intel EDK initially releases. +# +# 1 9/18/09 1:52a Iminglin +# +#********************************************************************** +#<AMI_FHDR_START> +# +# Name: EdkIIGlueBasePciLibCf8.mak +# +# Description: +# +#<AMI_FHDR_END> +#********************************************************************** + + +$(EdkIIGlueBasePciLibCf8_LIB) : EdkIIGlueBasePciLibCf8 + +EdkIIGlueBasePciLibCf8 : $(BUILD_DIR)\EdkIIGlueBasePciLibCf8.mak EdkIIGlueBasePciLibCf8Bin + +$(BUILD_DIR)\EdkIIGlueBasePciLibCf8.mak : $(EdkIIGlueBasePciLibCf8_DIR)\$(@B).cif $(EdkIIGlueBasePciLibCf8_DIR)\$(@B).mak $(BUILD_RULES) + $(CIF2MAK) $(EdkIIGlueBasePciLibCf8_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS) + +EdkIIGlueBasePciLibCf8Bin : $(EdkIIGlueBasePciCf8Lib_LIB) +!IF "$(x64_BUILD)"=="1" + $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\ + BUILD_DIR=$(BUILD_DIR)\ + /f $(BUILD_DIR)\EdkIIGlueBasePciLibCf8.mak all\ + TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueBasePciLibCf8_LIB)" + $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\ + BUILD_DIR=$(BUILD_DIR)\IA32\ + /f $(BUILD_DIR)\EdkIIGlueBasePciLibCf8.mak all\ + TYPE=PEI_LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueBasePciLibCf8_LIB)" +!ELSE + $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\ + BUILD_DIR=$(BUILD_DIR)\ + /f $(BUILD_DIR)\EdkIIGlueBasePciLibCf8.mak all\ + TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueBasePciLibCf8_LIB)" +!ENDIF +#********************************************************************** +#********************************************************************** +#** ** +#** (C)Copyright 1985-2009, American Megatrends, Inc. ** +#** ** +#** All Rights Reserved. ** +#** ** +#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +#** ** +#** Phone: (770)-246-8600 ** +#** ** +#********************************************************************** +#********************************************************************** diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePciLibCf8/EdkIIGlueBasePciLibCf8.sdl b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePciLibCf8/EdkIIGlueBasePciLibCf8.sdl new file mode 100644 index 0000000..8f85282 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePciLibCf8/EdkIIGlueBasePciLibCf8.sdl @@ -0,0 +1,26 @@ +TOKEN + Name = "EdkIIGlueBasePciLibCf8_SUPPORT" + Value = "1" + Help = "Main switch to enable EdkIIGlueBasePciLibCf8 support in Project" + TokenType = Boolean + TargetEQU = Yes + TargetMAK = Yes + Master = Yes +End + +TOKEN + Name = "EdkIIGlueBasePciLibCf8_LIB" + Value = "$$(LIB_BUILD_DIR)\EdkIIGlueBasePciLibCf8.lib" + TokenType = Expression + TargetMAK = Yes +End + +PATH + Name = "EdkIIGlueBasePciLibCf8_DIR" +End + +MODULE + Help = "Includes EdkIIGlueBasePciLibCf8.mak to Project" + File = "EdkIIGlueBasePciLibCf8.mak" +End + diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePciLibCf8/PciLib.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePciLibCf8/PciLib.c new file mode 100644 index 0000000..7f85431 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePciLibCf8/PciLib.c @@ -0,0 +1,1076 @@ +/*++ + +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: + + PciLib.c + +Abstract: + + PCI Library using Port CF8/CFC access. + +--*/ + +#include "EdkIIGlueBase.h" + +/** + Reads an 8-bit PCI configuration register. + + Reads and returns the 8-bit PCI configuration register specified by Address. + This function must guarantee that all PCI read and write operations are + serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + + @return The read value from the PCI configuration register. + +**/ +UINT8 +EFIAPI +PciRead8 ( + IN UINTN Address + ) +{ + return PciCf8Read8 (Address); +} + +/** + Writes an 8-bit PCI configuration register. + + Writes the 8-bit PCI configuration register specified by Address with the + value specified by Value. Value is returned. This function must guarantee + that all PCI read and write operations are serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param Value The value to write. + + @return The value written to the PCI configuration register. + +**/ +UINT8 +EFIAPI +PciWrite8 ( + IN UINTN Address, + IN UINT8 Data + ) +{ + return PciCf8Write8 (Address, Data); +} + +/** + Performs a bitwise inclusive OR of an 8-bit PCI configuration register with + an 8-bit value. + + Reads the 8-bit PCI configuration register specified by Address, performs a + bitwise inclusive OR between the read result and the value specified by + OrData, and writes the result to the 8-bit PCI configuration register + specified by Address. The value written to the PCI configuration register is + returned. This function must guarantee that all PCI read and write operations + are serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param OrData The value to OR with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT8 +EFIAPI +PciOr8 ( + IN UINTN Address, + IN UINT8 OrData + ) +{ + return PciCf8Or8 (Address, OrData); +} + +/** + Performs a bitwise AND of an 8-bit PCI configuration register with an 8-bit + value. + + Reads the 8-bit PCI configuration register specified by Address, performs a + bitwise AND between the read result and the value specified by AndData, and + writes the result to the 8-bit PCI configuration register specified by + Address. The value written to the PCI configuration register is returned. + This function must guarantee that all PCI read and write operations are + serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param AndData The value to AND with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT8 +EFIAPI +PciAnd8 ( + IN UINTN Address, + IN UINT8 AndData + ) +{ + return PciCf8And8 (Address, AndData); +} + +/** + Performs a bitwise AND of an 8-bit PCI configuration register with an 8-bit + value, followed a bitwise inclusive OR with another 8-bit value. + + Reads the 8-bit PCI configuration register specified by Address, performs a + bitwise AND between the read result and the value specified by AndData, + performs a bitwise inclusive OR between the result of the AND operation and + the value specified by OrData, and writes the result to the 8-bit PCI + configuration register specified by Address. The value written to the PCI + configuration register is returned. This function must guarantee that all PCI + read and write operations are serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param AndData The value to AND with the PCI configuration register. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the PCI configuration register. + +**/ +UINT8 +EFIAPI +PciAndThenOr8 ( + IN UINTN Address, + IN UINT8 AndData, + IN UINT8 OrData + ) +{ + return PciCf8AndThenOr8 (Address, AndData, OrData); +} + +/** + Reads a bit field of a PCI configuration register. + + Reads the bit field in an 8-bit PCI configuration register. The bit field is + specified by the StartBit and the EndBit. The value of the bit field is + returned. + + If Address > 0x0FFFFFFF, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to read. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..7. + + @return The value of the bit field read from the PCI configuration register. + +**/ +UINT8 +EFIAPI +PciBitFieldRead8 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit + ) +{ + return PciCf8BitFieldRead8 (Address, StartBit, EndBit); +} + +/** + Writes a bit field to a PCI configuration register. + + Writes Value to the bit field of the PCI configuration register. The bit + field is specified by the StartBit and the EndBit. All other bits in the + destination PCI configuration register are preserved. The new value of the + 8-bit register is returned. + + If Address > 0x0FFFFFFF, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..7. + @param Value New value of the bit field. + + @return The value written back to the PCI configuration register. + +**/ +UINT8 +EFIAPI +PciBitFieldWrite8 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT8 Value + ) +{ + return PciCf8BitFieldWrite8 (Address, StartBit, EndBit, Value); +} + +/** + Reads a bit field in an 8-bit PCI configuration, performs a bitwise OR, and + writes the result back to the bit field in the 8-bit port. + + Reads the 8-bit PCI configuration register specified by Address, performs a + bitwise inclusive OR between the read result and the value specified by + OrData, and writes the result to the 8-bit PCI configuration register + specified by Address. The value written to the PCI configuration register is + returned. This function must guarantee that all PCI read and write operations + are serialized. Extra left bits in OrData are stripped. + + If Address > 0x0FFFFFFF, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..7. + @param OrData The value to OR with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT8 +EFIAPI +PciBitFieldOr8 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT8 OrData + ) +{ + return PciCf8BitFieldOr8 (Address, StartBit, EndBit, OrData); +} + +/** + Reads a bit field in an 8-bit PCI configuration register, performs a bitwise + AND, and writes the result back to the bit field in the 8-bit register. + + Reads the 8-bit PCI configuration register specified by Address, performs a + bitwise AND between the read result and the value specified by AndData, and + writes the result to the 8-bit PCI configuration register specified by + Address. The value written to the PCI configuration register is returned. + This function must guarantee that all PCI read and write operations are + serialized. Extra left bits in AndData are stripped. + + If Address > 0x0FFFFFFF, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..7. + @param AndData The value to AND with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT8 +EFIAPI +PciBitFieldAnd8 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT8 AndData + ) +{ + return PciCf8BitFieldAnd8 (Address, StartBit, EndBit, AndData); +} + +/** + Reads a bit field in an 8-bit port, performs a bitwise AND followed by a + bitwise inclusive OR, and writes the result back to the bit field in the + 8-bit port. + + Reads the 8-bit PCI configuration register specified by Address, performs a + bitwise AND followed by a bitwise inclusive OR between the read result and + the value specified by AndData, and writes the result to the 8-bit PCI + configuration register specified by Address. The value written to the PCI + configuration register is returned. This function must guarantee that all PCI + read and write operations are serialized. Extra left bits in both AndData and + OrData are stripped. + + If Address > 0x0FFFFFFF, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..7. + @param AndData The value to AND with the PCI configuration register. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the PCI configuration register. + +**/ +UINT8 +EFIAPI +PciBitFieldAndThenOr8 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT8 AndData, + IN UINT8 OrData + ) +{ + return PciCf8BitFieldAndThenOr8 (Address, StartBit, EndBit, AndData, OrData); +} + +/** + Reads a 16-bit PCI configuration register. + + Reads and returns the 16-bit PCI configuration register specified by Address. + This function must guarantee that all PCI read and write operations are + serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + + @return The read value from the PCI configuration register. + +**/ +UINT16 +EFIAPI +PciRead16 ( + IN UINTN Address + ) +{ + return PciCf8Read16 (Address); +} + +/** + Writes a 16-bit PCI configuration register. + + Writes the 16-bit PCI configuration register specified by Address with the + value specified by Value. Value is returned. This function must guarantee + that all PCI read and write operations are serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param Value The value to write. + + @return The value written to the PCI configuration register. + +**/ +UINT16 +EFIAPI +PciWrite16 ( + IN UINTN Address, + IN UINT16 Data + ) +{ + return PciCf8Write16 (Address, Data); +} + +/** + Performs a bitwise inclusive OR of a 16-bit PCI configuration register with + a 16-bit value. + + Reads the 16-bit PCI configuration register specified by Address, performs a + bitwise inclusive OR between the read result and the value specified by + OrData, and writes the result to the 16-bit PCI configuration register + specified by Address. The value written to the PCI configuration register is + returned. This function must guarantee that all PCI read and write operations + are serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param OrData The value to OR with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT16 +EFIAPI +PciOr16 ( + IN UINTN Address, + IN UINT16 OrData + ) +{ + return PciCf8Or16 (Address, OrData); +} + +/** + Performs a bitwise AND of a 16-bit PCI configuration register with a 16-bit + value. + + Reads the 16-bit PCI configuration register specified by Address, performs a + bitwise AND between the read result and the value specified by AndData, and + writes the result to the 16-bit PCI configuration register specified by + Address. The value written to the PCI configuration register is returned. + This function must guarantee that all PCI read and write operations are + serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param AndData The value to AND with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT16 +EFIAPI +PciAnd16 ( + IN UINTN Address, + IN UINT16 AndData + ) +{ + return PciCf8And16 (Address, AndData); +} + +/** + Performs a bitwise AND of a 16-bit PCI configuration register with a 16-bit + value, followed a bitwise inclusive OR with another 16-bit value. + + Reads the 16-bit PCI configuration register specified by Address, performs a + bitwise AND between the read result and the value specified by AndData, + performs a bitwise inclusive OR between the result of the AND operation and + the value specified by OrData, and writes the result to the 16-bit PCI + configuration register specified by Address. The value written to the PCI + configuration register is returned. This function must guarantee that all PCI + read and write operations are serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param AndData The value to AND with the PCI configuration register. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the PCI configuration register. + +**/ +UINT16 +EFIAPI +PciAndThenOr16 ( + IN UINTN Address, + IN UINT16 AndData, + IN UINT16 OrData + ) +{ + return PciCf8AndThenOr16 (Address, AndData, OrData); +} + +/** + Reads a bit field of a PCI configuration register. + + Reads the bit field in a 16-bit PCI configuration register. The bit field is + specified by the StartBit and the EndBit. The value of the bit field is + returned. + + If Address > 0x0FFFFFFF, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to read. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..15. + + @return The value of the bit field read from the PCI configuration register. + +**/ +UINT16 +EFIAPI +PciBitFieldRead16 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit + ) +{ + return PciCf8BitFieldRead16 (Address, StartBit, EndBit); +} + +/** + Writes a bit field to a PCI configuration register. + + Writes Value to the bit field of the PCI configuration register. The bit + field is specified by the StartBit and the EndBit. All other bits in the + destination PCI configuration register are preserved. The new value of the + 16-bit register is returned. + + If Address > 0x0FFFFFFF, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..15. + @param Value New value of the bit field. + + @return The value written back to the PCI configuration register. + +**/ +UINT16 +EFIAPI +PciBitFieldWrite16 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT16 Value + ) +{ + return PciCf8BitFieldWrite16 (Address, StartBit, EndBit, Value); +} + +/** + Reads a bit field in a 16-bit PCI configuration, performs a bitwise OR, and + writes the result back to the bit field in the 16-bit port. + + Reads the 16-bit PCI configuration register specified by Address, performs a + bitwise inclusive OR between the read result and the value specified by + OrData, and writes the result to the 16-bit PCI configuration register + specified by Address. The value written to the PCI configuration register is + returned. This function must guarantee that all PCI read and write operations + are serialized. Extra left bits in OrData are stripped. + + If Address > 0x0FFFFFFF, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..15. + @param OrData The value to OR with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT16 +EFIAPI +PciBitFieldOr16 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT16 OrData + ) +{ + return PciCf8BitFieldOr16 (Address, StartBit, EndBit, OrData); +} + +/** + Reads a bit field in a 16-bit PCI configuration register, performs a bitwise + AND, and writes the result back to the bit field in the 16-bit register. + + Reads the 16-bit PCI configuration register specified by Address, performs a + bitwise AND between the read result and the value specified by AndData, and + writes the result to the 16-bit PCI configuration register specified by + Address. The value written to the PCI configuration register is returned. + This function must guarantee that all PCI read and write operations are + serialized. Extra left bits in AndData are stripped. + + If Address > 0x0FFFFFFF, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..15. + @param AndData The value to AND with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT16 +EFIAPI +PciBitFieldAnd16 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT16 AndData + ) +{ + return PciCf8BitFieldAnd16 (Address, StartBit, EndBit, AndData); +} + +/** + Reads a bit field in a 16-bit port, performs a bitwise AND followed by a + bitwise inclusive OR, and writes the result back to the bit field in the + 16-bit port. + + Reads the 16-bit PCI configuration register specified by Address, performs a + bitwise AND followed by a bitwise inclusive OR between the read result and + the value specified by AndData, and writes the result to the 16-bit PCI + configuration register specified by Address. The value written to the PCI + configuration register is returned. This function must guarantee that all PCI + read and write operations are serialized. Extra left bits in both AndData and + OrData are stripped. + + If Address > 0x0FFFFFFF, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..15. + @param AndData The value to AND with the PCI configuration register. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the PCI configuration register. + +**/ +UINT16 +EFIAPI +PciBitFieldAndThenOr16 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT16 AndData, + IN UINT16 OrData + ) +{ + return PciCf8BitFieldAndThenOr16 (Address, StartBit, EndBit, AndData, OrData); +} + +/** + Reads a 32-bit PCI configuration register. + + Reads and returns the 32-bit PCI configuration register specified by Address. + This function must guarantee that all PCI read and write operations are + serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + + @return The read value from the PCI configuration register. + +**/ +UINT32 +EFIAPI +PciRead32 ( + IN UINTN Address + ) +{ + return PciCf8Read32 (Address); +} + +/** + Writes a 32-bit PCI configuration register. + + Writes the 32-bit PCI configuration register specified by Address with the + value specified by Value. Value is returned. This function must guarantee + that all PCI read and write operations are serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param Value The value to write. + + @return The value written to the PCI configuration register. + +**/ +UINT32 +EFIAPI +PciWrite32 ( + IN UINTN Address, + IN UINT32 Data + ) +{ + return PciCf8Write32 (Address, Data); +} + +/** + Performs a bitwise inclusive OR of a 32-bit PCI configuration register with + a 32-bit value. + + Reads the 32-bit PCI configuration register specified by Address, performs a + bitwise inclusive OR between the read result and the value specified by + OrData, and writes the result to the 32-bit PCI configuration register + specified by Address. The value written to the PCI configuration register is + returned. This function must guarantee that all PCI read and write operations + are serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param OrData The value to OR with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT32 +EFIAPI +PciOr32 ( + IN UINTN Address, + IN UINT32 OrData + ) +{ + return PciCf8Or32 (Address, OrData); +} + +/** + Performs a bitwise AND of a 32-bit PCI configuration register with a 32-bit + value. + + Reads the 32-bit PCI configuration register specified by Address, performs a + bitwise AND between the read result and the value specified by AndData, and + writes the result to the 32-bit PCI configuration register specified by + Address. The value written to the PCI configuration register is returned. + This function must guarantee that all PCI read and write operations are + serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param AndData The value to AND with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT32 +EFIAPI +PciAnd32 ( + IN UINTN Address, + IN UINT32 AndData + ) +{ + return PciCf8And32 (Address, AndData); +} + +/** + Performs a bitwise AND of a 32-bit PCI configuration register with a 32-bit + value, followed a bitwise inclusive OR with another 32-bit value. + + Reads the 32-bit PCI configuration register specified by Address, performs a + bitwise AND between the read result and the value specified by AndData, + performs a bitwise inclusive OR between the result of the AND operation and + the value specified by OrData, and writes the result to the 32-bit PCI + configuration register specified by Address. The value written to the PCI + configuration register is returned. This function must guarantee that all PCI + read and write operations are serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param AndData The value to AND with the PCI configuration register. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the PCI configuration register. + +**/ +UINT32 +EFIAPI +PciAndThenOr32 ( + IN UINTN Address, + IN UINT32 AndData, + IN UINT32 OrData + ) +{ + return PciCf8AndThenOr32 (Address, AndData, OrData); +} + +/** + Reads a bit field of a PCI configuration register. + + Reads the bit field in a 32-bit PCI configuration register. The bit field is + specified by the StartBit and the EndBit. The value of the bit field is + returned. + + If Address > 0x0FFFFFFF, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to read. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + + @return The value of the bit field read from the PCI configuration register. + +**/ +UINT32 +EFIAPI +PciBitFieldRead32 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit + ) +{ + return PciCf8BitFieldRead32 (Address, StartBit, EndBit); +} + +/** + Writes a bit field to a PCI configuration register. + + Writes Value to the bit field of the PCI configuration register. The bit + field is specified by the StartBit and the EndBit. All other bits in the + destination PCI configuration register are preserved. The new value of the + 32-bit register is returned. + + If Address > 0x0FFFFFFF, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + @param Value New value of the bit field. + + @return The value written back to the PCI configuration register. + +**/ +UINT32 +EFIAPI +PciBitFieldWrite32 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT32 Value + ) +{ + return PciCf8BitFieldWrite32 (Address, StartBit, EndBit, Value); +} + +/** + Reads a bit field in a 32-bit PCI configuration, performs a bitwise OR, and + writes the result back to the bit field in the 32-bit port. + + Reads the 32-bit PCI configuration register specified by Address, performs a + bitwise inclusive OR between the read result and the value specified by + OrData, and writes the result to the 32-bit PCI configuration register + specified by Address. The value written to the PCI configuration register is + returned. This function must guarantee that all PCI read and write operations + are serialized. Extra left bits in OrData are stripped. + + If Address > 0x0FFFFFFF, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + @param OrData The value to OR with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT32 +EFIAPI +PciBitFieldOr32 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT32 OrData + ) +{ + return PciCf8BitFieldOr32 (Address, StartBit, EndBit, OrData); +} + +/** + Reads a bit field in a 32-bit PCI configuration register, performs a bitwise + AND, and writes the result back to the bit field in the 32-bit register. + + Reads the 32-bit PCI configuration register specified by Address, performs a + bitwise AND between the read result and the value specified by AndData, and + writes the result to the 32-bit PCI configuration register specified by + Address. The value written to the PCI configuration register is returned. + This function must guarantee that all PCI read and write operations are + serialized. Extra left bits in AndData are stripped. + + If Address > 0x0FFFFFFF, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + @param AndData The value to AND with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT32 +EFIAPI +PciBitFieldAnd32 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT32 AndData + ) +{ + return PciCf8BitFieldAnd32 (Address, StartBit, EndBit, AndData); +} + +/** + Reads a bit field in a 32-bit port, performs a bitwise AND followed by a + bitwise inclusive OR, and writes the result back to the bit field in the + 32-bit port. + + Reads the 32-bit PCI configuration register specified by Address, performs a + bitwise AND followed by a bitwise inclusive OR between the read result and + the value specified by AndData, and writes the result to the 32-bit PCI + configuration register specified by Address. The value written to the PCI + configuration register is returned. This function must guarantee that all PCI + read and write operations are serialized. Extra left bits in both AndData and + OrData are stripped. + + If Address > 0x0FFFFFFF, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + @param AndData The value to AND with the PCI configuration register. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the PCI configuration register. + +**/ +UINT32 +EFIAPI +PciBitFieldAndThenOr32 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT32 AndData, + IN UINT32 OrData + ) +{ + return PciCf8BitFieldAndThenOr32 (Address, StartBit, EndBit, AndData, OrData); +} + +/** + Reads a range of PCI configuration registers into a caller supplied buffer. + + Reads the range of PCI configuration registers specified by StartAddress and + Size into the buffer specified by Buffer. This function only allows the PCI + configuration registers from a single PCI function to be read. Size is + returned. When possible 32-bit PCI configuration read cycles are used to read + from StartAdress to StartAddress + Size. Due to alignment restrictions, 8-bit + and 16-bit PCI configuration read cycles may be used at the beginning and the + end of the range. + + If StartAddress > 0x0FFFFFFF, then ASSERT(). + If ((StartAddress & 0xFFF) + Size) > 0x1000, then ASSERT(). + If Size > 0 and Buffer is NULL, then ASSERT(). + + @param StartAddress Starting address that encodes the PCI Bus, Device, + Function and Register. + @param Size Size in bytes of the transfer. + @param Buffer Pointer to a buffer receiving the data read. + + @return Size + +**/ +UINTN +EFIAPI +PciReadBuffer ( + IN UINTN StartAddress, + IN UINTN Size, + OUT VOID *Buffer + ) +{ + return PciCf8ReadBuffer (StartAddress, Size, Buffer); +} + +/** + Copies the data in a caller supplied buffer to a specified range of PCI + configuration space. + + Writes the range of PCI configuration registers specified by StartAddress and + Size from the buffer specified by Buffer. This function only allows the PCI + configuration registers from a single PCI function to be written. Size is + returned. When possible 32-bit PCI configuration write cycles are used to + write from StartAdress to StartAddress + Size. Due to alignment restrictions, + 8-bit and 16-bit PCI configuration write cycles may be used at the beginning + and the end of the range. + + If StartAddress > 0x0FFFFFFF, then ASSERT(). + If ((StartAddress & 0xFFF) + Size) > 0x1000, then ASSERT(). + If Size > 0 and Buffer is NULL, then ASSERT(). + + @param StartAddress Starting address that encodes the PCI Bus, Device, + Function and Register. + @param Size Size in bytes of the transfer. + @param Buffer Pointer to a buffer containing the data to write. + + @return Size + +**/ +UINTN +EFIAPI +PciWriteBuffer ( + IN UINTN StartAddress, + IN UINTN Size, + IN VOID *Buffer + ) +{ + return PciCf8WriteBuffer (StartAddress, Size, Buffer); +} diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePciLibPciExpress/BasePciLibPciExpress.inf b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePciLibPciExpress/BasePciLibPciExpress.inf new file mode 100644 index 0000000..0d2ad19 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePciLibPciExpress/BasePciLibPciExpress.inf @@ -0,0 +1,79 @@ +#/*++ +# +# 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: +# +# BasePciLibPciExpress.inf +# +# Abstract: +# +# Component description file for BasePciLibPciExpress. +# +#--*/ + +[defines] +BASE_NAME = EdkIIGlueBasePciLibPciExpress +COMPONENT_TYPE = LIBRARY + +[sources.common] + PciLib.c + +[sources.ia32] + + +[sources.x64] + + +[sources.ipf] + + +[sources.ebc] + + +[includes.common] + . + ..\..\Include + ..\..\include\Library + $(EDK_SOURCE)\Foundation + $(EDK_SOURCE)\Foundation\Framework + $(EDK_SOURCE)\Foundation\Efi + $(EDK_SOURCE)\Foundation\Include + $(EDK_SOURCE)\Foundation\Efi\Include + $(EDK_SOURCE)\Foundation\Framework\Include + $(EDK_SOURCE)\Foundation\Include\IndustryStandard + $(EDK_SOURCE)\Foundation\Core\Dxe + $(EDK_SOURCE)\Foundation\Library\Dxe\Include + $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include + +[libraries.common] + EdkIIGlueBasePciExpressLib + +[libraries.ia32] + + +[libraries.x64] + + +[nmake.common] + C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION + LIB_STD_FLAGS = /NOLOGO /IGNORE:4006 + +[nmake.ia32] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32 + +[nmake.x64] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64 + +[nmake.ipf] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF + +[nmake.ebc] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_EBC
\ No newline at end of file diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePciLibPciExpress/EdkIIGlueBasePciLibPciExpress.cif b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePciLibPciExpress/EdkIIGlueBasePciLibPciExpress.cif new file mode 100644 index 0000000..6913cab --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePciLibPciExpress/EdkIIGlueBasePciLibPciExpress.cif @@ -0,0 +1,11 @@ +<component> + name = "EdkIIGlueBasePciLibPciExpress" + category = ModulePart + LocalRoot = "Edk\Foundation\Library\EdkIIGlueLib\Library\BasePciLibPciExpress" + RefName = "EdkIIGlueBasePciLibPciExpress" +[files] +"EdkIIGlueBasePciLibPciExpress.sdl" +"EdkIIGlueBasePciLibPciExpress.mak" +"BasePciLibPciExpress.inf" +"PciLib.c" +<endComponent> diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePciLibPciExpress/EdkIIGlueBasePciLibPciExpress.mak b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePciLibPciExpress/EdkIIGlueBasePciLibPciExpress.mak new file mode 100644 index 0000000..4591e24 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePciLibPciExpress/EdkIIGlueBasePciLibPciExpress.mak @@ -0,0 +1,80 @@ +#********************************************************************** +#********************************************************************** +#** ** +#** (C)Copyright 1985-2009, American Megatrends, Inc. ** +#** ** +#** All Rights Reserved. ** +#** ** +#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +#** ** +#** Phone: (770)-246-8600 ** +#** ** +#********************************************************************** +#********************************************************************** + +#********************************************************************** +# $Header: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGlueBasePciLibPciExpress/EdkIIGlueBasePciLibPciExpress.mak 1 1/20/12 3:53a Jeffch $ +# +# $Revision: 1 $ +# +# $Date: 1/20/12 3:53a $ +#********************************************************************** +# Revision History +# ---------------- +# $Log: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGlueBasePciLibPciExpress/EdkIIGlueBasePciLibPciExpress.mak $ +# +# 1 1/20/12 3:53a Jeffch +# Create Intel EDK 1117 Patch 7. +# +# 1 9/27/11 6:15a Wesleychen +# Intel EDK initially releases. +# +# 1 9/18/09 1:52a Iminglin +# +#********************************************************************** +#<AMI_FHDR_START> +# +# Name: EdkIIGlueBasePciLibPciExpress.mak +# +# Description: +# +#<AMI_FHDR_END> +#********************************************************************** + + +$(EdkIIGlueBasePciLibPciExpress_LIB) : EdkIIGlueBasePciLibPciExpress + +EdkIIGlueBasePciLibPciExpress : $(BUILD_DIR)\EdkIIGlueBasePciLibPciExpress.mak EdkIIGlueBasePciLibPciExpressBin + +$(BUILD_DIR)\EdkIIGlueBasePciLibPciExpress.mak : $(EdkIIGlueBasePciLibPciExpress_DIR)\$(@B).cif $(EdkIIGlueBasePciLibPciExpress_DIR)\$(@B).mak $(BUILD_RULES) + $(CIF2MAK) $(EdkIIGlueBasePciLibPciExpress_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS) + +EdkIIGlueBasePciLibPciExpressBin : $(EdkIIGlueBasePciExpressLib_LIB) +!IF "$(x64_BUILD)"=="1" + $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\ + BUILD_DIR=$(BUILD_DIR)\ + /f $(BUILD_DIR)\EdkIIGlueBasePciLibPciExpress.mak all\ + TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueBasePciLibPciExpress_LIB)" + $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\ + BUILD_DIR=$(BUILD_DIR)\IA32\ + /f $(BUILD_DIR)\EdkIIGlueBasePciLibPciExpress.mak all\ + TYPE=PEI_LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueBasePciLibPciExpress_LIB)" +!ELSE + $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\ + BUILD_DIR=$(BUILD_DIR)\ + /f $(BUILD_DIR)\EdkIIGlueBasePciLibPciExpress.mak all\ + TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueBasePciLibPciExpress_LIB)" +!ENDIF +#********************************************************************** +#********************************************************************** +#** ** +#** (C)Copyright 1985-2009, American Megatrends, Inc. ** +#** ** +#** All Rights Reserved. ** +#** ** +#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +#** ** +#** Phone: (770)-246-8600 ** +#** ** +#********************************************************************** +#**********************************************************************
\ No newline at end of file diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePciLibPciExpress/EdkIIGlueBasePciLibPciExpress.sdl b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePciLibPciExpress/EdkIIGlueBasePciLibPciExpress.sdl new file mode 100644 index 0000000..ff7527a --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePciLibPciExpress/EdkIIGlueBasePciLibPciExpress.sdl @@ -0,0 +1,26 @@ +TOKEN + Name = "EdkIIGlueBasePciLibPciExpress_SUPPORT" + Value = "1" + Help = "Main switch to enable EdkIIGlueBasePciLibPciExpress support in Project" + TokenType = Boolean + TargetEQU = Yes + TargetMAK = Yes + Master = Yes +End + +TOKEN + Name = "EdkIIGlueBasePciLibPciExpress_LIB" + Value = "$$(LIB_BUILD_DIR)\EdkIIGlueBasePciLibPciExpress.lib" + TokenType = Expression + TargetMAK = Yes +End + +PATH + Name = "EdkIIGlueBasePciLibPciExpress_DIR" +End + +MODULE + Help = "Includes EdkIIGlueBasePciLibPciExpress.mak to Project" + File = "EdkIIGlueBasePciLibPciExpress.mak" +End + diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePciLibPciExpress/PciLib.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePciLibPciExpress/PciLib.c new file mode 100644 index 0000000..4d97a37 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePciLibPciExpress/PciLib.c @@ -0,0 +1,1076 @@ +/*++ + +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: + + PciLib.c + +Abstract: + + PCI Library using PC Express access. + +--*/ + +#include "EdkIIGlueBase.h" + +/** + Reads an 8-bit PCI configuration register. + + Reads and returns the 8-bit PCI configuration register specified by Address. + This function must guarantee that all PCI read and write operations are + serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + + @return The read value from the PCI configuration register. + +**/ +UINT8 +EFIAPI +PciRead8 ( + IN UINTN Address + ) +{ + return PciExpressRead8 (Address); +} + +/** + Writes an 8-bit PCI configuration register. + + Writes the 8-bit PCI configuration register specified by Address with the + value specified by Value. Value is returned. This function must guarantee + that all PCI read and write operations are serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param Value The value to write. + + @return The value written to the PCI configuration register. + +**/ +UINT8 +EFIAPI +PciWrite8 ( + IN UINTN Address, + IN UINT8 Data + ) +{ + return PciExpressWrite8 (Address, Data); +} + +/** + Performs a bitwise inclusive OR of an 8-bit PCI configuration register with + an 8-bit value. + + Reads the 8-bit PCI configuration register specified by Address, performs a + bitwise inclusive OR between the read result and the value specified by + OrData, and writes the result to the 8-bit PCI configuration register + specified by Address. The value written to the PCI configuration register is + returned. This function must guarantee that all PCI read and write operations + are serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param OrData The value to OR with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT8 +EFIAPI +PciOr8 ( + IN UINTN Address, + IN UINT8 OrData + ) +{ + return PciExpressOr8 (Address, OrData); +} + +/** + Performs a bitwise AND of an 8-bit PCI configuration register with an 8-bit + value. + + Reads the 8-bit PCI configuration register specified by Address, performs a + bitwise AND between the read result and the value specified by AndData, and + writes the result to the 8-bit PCI configuration register specified by + Address. The value written to the PCI configuration register is returned. + This function must guarantee that all PCI read and write operations are + serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param AndData The value to AND with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT8 +EFIAPI +PciAnd8 ( + IN UINTN Address, + IN UINT8 AndData + ) +{ + return PciExpressAnd8 (Address, AndData); +} + +/** + Performs a bitwise AND of an 8-bit PCI configuration register with an 8-bit + value, followed a bitwise inclusive OR with another 8-bit value. + + Reads the 8-bit PCI configuration register specified by Address, performs a + bitwise AND between the read result and the value specified by AndData, + performs a bitwise inclusive OR between the result of the AND operation and + the value specified by OrData, and writes the result to the 8-bit PCI + configuration register specified by Address. The value written to the PCI + configuration register is returned. This function must guarantee that all PCI + read and write operations are serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param AndData The value to AND with the PCI configuration register. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the PCI configuration register. + +**/ +UINT8 +EFIAPI +PciAndThenOr8 ( + IN UINTN Address, + IN UINT8 AndData, + IN UINT8 OrData + ) +{ + return PciExpressAndThenOr8 (Address, AndData, OrData); +} + +/** + Reads a bit field of a PCI configuration register. + + Reads the bit field in an 8-bit PCI configuration register. The bit field is + specified by the StartBit and the EndBit. The value of the bit field is + returned. + + If Address > 0x0FFFFFFF, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to read. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..7. + + @return The value of the bit field read from the PCI configuration register. + +**/ +UINT8 +EFIAPI +PciBitFieldRead8 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit + ) +{ + return PciExpressBitFieldRead8 (Address, StartBit, EndBit); +} + +/** + Writes a bit field to a PCI configuration register. + + Writes Value to the bit field of the PCI configuration register. The bit + field is specified by the StartBit and the EndBit. All other bits in the + destination PCI configuration register are preserved. The new value of the + 8-bit register is returned. + + If Address > 0x0FFFFFFF, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..7. + @param Value New value of the bit field. + + @return The value written back to the PCI configuration register. + +**/ +UINT8 +EFIAPI +PciBitFieldWrite8 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT8 Value + ) +{ + return PciExpressBitFieldWrite8 (Address, StartBit, EndBit, Value); +} + +/** + Reads a bit field in an 8-bit PCI configuration, performs a bitwise OR, and + writes the result back to the bit field in the 8-bit port. + + Reads the 8-bit PCI configuration register specified by Address, performs a + bitwise inclusive OR between the read result and the value specified by + OrData, and writes the result to the 8-bit PCI configuration register + specified by Address. The value written to the PCI configuration register is + returned. This function must guarantee that all PCI read and write operations + are serialized. Extra left bits in OrData are stripped. + + If Address > 0x0FFFFFFF, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..7. + @param OrData The value to OR with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT8 +EFIAPI +PciBitFieldOr8 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT8 OrData + ) +{ + return PciExpressBitFieldOr8 (Address, StartBit, EndBit, OrData); +} + +/** + Reads a bit field in an 8-bit PCI configuration register, performs a bitwise + AND, and writes the result back to the bit field in the 8-bit register. + + Reads the 8-bit PCI configuration register specified by Address, performs a + bitwise AND between the read result and the value specified by AndData, and + writes the result to the 8-bit PCI configuration register specified by + Address. The value written to the PCI configuration register is returned. + This function must guarantee that all PCI read and write operations are + serialized. Extra left bits in AndData are stripped. + + If Address > 0x0FFFFFFF, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..7. + @param AndData The value to AND with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT8 +EFIAPI +PciBitFieldAnd8 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT8 AndData + ) +{ + return PciExpressBitFieldAnd8 (Address, StartBit, EndBit, AndData); +} + +/** + Reads a bit field in an 8-bit port, performs a bitwise AND followed by a + bitwise inclusive OR, and writes the result back to the bit field in the + 8-bit port. + + Reads the 8-bit PCI configuration register specified by Address, performs a + bitwise AND followed by a bitwise inclusive OR between the read result and + the value specified by AndData, and writes the result to the 8-bit PCI + configuration register specified by Address. The value written to the PCI + configuration register is returned. This function must guarantee that all PCI + read and write operations are serialized. Extra left bits in both AndData and + OrData are stripped. + + If Address > 0x0FFFFFFF, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..7. + @param AndData The value to AND with the PCI configuration register. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the PCI configuration register. + +**/ +UINT8 +EFIAPI +PciBitFieldAndThenOr8 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT8 AndData, + IN UINT8 OrData + ) +{ + return PciExpressBitFieldAndThenOr8 (Address, StartBit, EndBit, AndData, OrData); +} + +/** + Reads a 16-bit PCI configuration register. + + Reads and returns the 16-bit PCI configuration register specified by Address. + This function must guarantee that all PCI read and write operations are + serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + + @return The read value from the PCI configuration register. + +**/ +UINT16 +EFIAPI +PciRead16 ( + IN UINTN Address + ) +{ + return PciExpressRead16 (Address); +} + +/** + Writes a 16-bit PCI configuration register. + + Writes the 16-bit PCI configuration register specified by Address with the + value specified by Value. Value is returned. This function must guarantee + that all PCI read and write operations are serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param Value The value to write. + + @return The value written to the PCI configuration register. + +**/ +UINT16 +EFIAPI +PciWrite16 ( + IN UINTN Address, + IN UINT16 Data + ) +{ + return PciExpressWrite16 (Address, Data); +} + +/** + Performs a bitwise inclusive OR of a 16-bit PCI configuration register with + a 16-bit value. + + Reads the 16-bit PCI configuration register specified by Address, performs a + bitwise inclusive OR between the read result and the value specified by + OrData, and writes the result to the 16-bit PCI configuration register + specified by Address. The value written to the PCI configuration register is + returned. This function must guarantee that all PCI read and write operations + are serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param OrData The value to OR with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT16 +EFIAPI +PciOr16 ( + IN UINTN Address, + IN UINT16 OrData + ) +{ + return PciExpressOr16 (Address, OrData); +} + +/** + Performs a bitwise AND of a 16-bit PCI configuration register with a 16-bit + value. + + Reads the 16-bit PCI configuration register specified by Address, performs a + bitwise AND between the read result and the value specified by AndData, and + writes the result to the 16-bit PCI configuration register specified by + Address. The value written to the PCI configuration register is returned. + This function must guarantee that all PCI read and write operations are + serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param AndData The value to AND with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT16 +EFIAPI +PciAnd16 ( + IN UINTN Address, + IN UINT16 AndData + ) +{ + return PciExpressAnd16 (Address, AndData); +} + +/** + Performs a bitwise AND of a 16-bit PCI configuration register with a 16-bit + value, followed a bitwise inclusive OR with another 16-bit value. + + Reads the 16-bit PCI configuration register specified by Address, performs a + bitwise AND between the read result and the value specified by AndData, + performs a bitwise inclusive OR between the result of the AND operation and + the value specified by OrData, and writes the result to the 16-bit PCI + configuration register specified by Address. The value written to the PCI + configuration register is returned. This function must guarantee that all PCI + read and write operations are serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param AndData The value to AND with the PCI configuration register. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the PCI configuration register. + +**/ +UINT16 +EFIAPI +PciAndThenOr16 ( + IN UINTN Address, + IN UINT16 AndData, + IN UINT16 OrData + ) +{ + return PciExpressAndThenOr16 (Address, AndData, OrData); +} + +/** + Reads a bit field of a PCI configuration register. + + Reads the bit field in a 16-bit PCI configuration register. The bit field is + specified by the StartBit and the EndBit. The value of the bit field is + returned. + + If Address > 0x0FFFFFFF, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to read. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..15. + + @return The value of the bit field read from the PCI configuration register. + +**/ +UINT16 +EFIAPI +PciBitFieldRead16 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit + ) +{ + return PciExpressBitFieldRead16 (Address, StartBit, EndBit); +} + +/** + Writes a bit field to a PCI configuration register. + + Writes Value to the bit field of the PCI configuration register. The bit + field is specified by the StartBit and the EndBit. All other bits in the + destination PCI configuration register are preserved. The new value of the + 16-bit register is returned. + + If Address > 0x0FFFFFFF, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..15. + @param Value New value of the bit field. + + @return The value written back to the PCI configuration register. + +**/ +UINT16 +EFIAPI +PciBitFieldWrite16 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT16 Value + ) +{ + return PciExpressBitFieldWrite16 (Address, StartBit, EndBit, Value); +} + +/** + Reads a bit field in a 16-bit PCI configuration, performs a bitwise OR, and + writes the result back to the bit field in the 16-bit port. + + Reads the 16-bit PCI configuration register specified by Address, performs a + bitwise inclusive OR between the read result and the value specified by + OrData, and writes the result to the 16-bit PCI configuration register + specified by Address. The value written to the PCI configuration register is + returned. This function must guarantee that all PCI read and write operations + are serialized. Extra left bits in OrData are stripped. + + If Address > 0x0FFFFFFF, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..15. + @param OrData The value to OR with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT16 +EFIAPI +PciBitFieldOr16 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT16 OrData + ) +{ + return PciExpressBitFieldOr16 (Address, StartBit, EndBit, OrData); +} + +/** + Reads a bit field in a 16-bit PCI configuration register, performs a bitwise + AND, and writes the result back to the bit field in the 16-bit register. + + Reads the 16-bit PCI configuration register specified by Address, performs a + bitwise AND between the read result and the value specified by AndData, and + writes the result to the 16-bit PCI configuration register specified by + Address. The value written to the PCI configuration register is returned. + This function must guarantee that all PCI read and write operations are + serialized. Extra left bits in AndData are stripped. + + If Address > 0x0FFFFFFF, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..15. + @param AndData The value to AND with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT16 +EFIAPI +PciBitFieldAnd16 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT16 AndData + ) +{ + return PciExpressBitFieldAnd16 (Address, StartBit, EndBit, AndData); +} + +/** + Reads a bit field in a 16-bit port, performs a bitwise AND followed by a + bitwise inclusive OR, and writes the result back to the bit field in the + 16-bit port. + + Reads the 16-bit PCI configuration register specified by Address, performs a + bitwise AND followed by a bitwise inclusive OR between the read result and + the value specified by AndData, and writes the result to the 16-bit PCI + configuration register specified by Address. The value written to the PCI + configuration register is returned. This function must guarantee that all PCI + read and write operations are serialized. Extra left bits in both AndData and + OrData are stripped. + + If Address > 0x0FFFFFFF, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..15. + @param AndData The value to AND with the PCI configuration register. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the PCI configuration register. + +**/ +UINT16 +EFIAPI +PciBitFieldAndThenOr16 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT16 AndData, + IN UINT16 OrData + ) +{ + return PciExpressBitFieldAndThenOr16 (Address, StartBit, EndBit, AndData, OrData); +} + +/** + Reads a 32-bit PCI configuration register. + + Reads and returns the 32-bit PCI configuration register specified by Address. + This function must guarantee that all PCI read and write operations are + serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + + @return The read value from the PCI configuration register. + +**/ +UINT32 +EFIAPI +PciRead32 ( + IN UINTN Address + ) +{ + return PciExpressRead32 (Address); +} + +/** + Writes a 32-bit PCI configuration register. + + Writes the 32-bit PCI configuration register specified by Address with the + value specified by Value. Value is returned. This function must guarantee + that all PCI read and write operations are serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param Value The value to write. + + @return The value written to the PCI configuration register. + +**/ +UINT32 +EFIAPI +PciWrite32 ( + IN UINTN Address, + IN UINT32 Data + ) +{ + return PciExpressWrite32 (Address, Data); +} + +/** + Performs a bitwise inclusive OR of a 32-bit PCI configuration register with + a 32-bit value. + + Reads the 32-bit PCI configuration register specified by Address, performs a + bitwise inclusive OR between the read result and the value specified by + OrData, and writes the result to the 32-bit PCI configuration register + specified by Address. The value written to the PCI configuration register is + returned. This function must guarantee that all PCI read and write operations + are serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param OrData The value to OR with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT32 +EFIAPI +PciOr32 ( + IN UINTN Address, + IN UINT32 OrData + ) +{ + return PciExpressOr32 (Address, OrData); +} + +/** + Performs a bitwise AND of a 32-bit PCI configuration register with a 32-bit + value. + + Reads the 32-bit PCI configuration register specified by Address, performs a + bitwise AND between the read result and the value specified by AndData, and + writes the result to the 32-bit PCI configuration register specified by + Address. The value written to the PCI configuration register is returned. + This function must guarantee that all PCI read and write operations are + serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param AndData The value to AND with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT32 +EFIAPI +PciAnd32 ( + IN UINTN Address, + IN UINT32 AndData + ) +{ + return PciExpressAnd32 (Address, AndData); +} + +/** + Performs a bitwise AND of a 32-bit PCI configuration register with a 32-bit + value, followed a bitwise inclusive OR with another 32-bit value. + + Reads the 32-bit PCI configuration register specified by Address, performs a + bitwise AND between the read result and the value specified by AndData, + performs a bitwise inclusive OR between the result of the AND operation and + the value specified by OrData, and writes the result to the 32-bit PCI + configuration register specified by Address. The value written to the PCI + configuration register is returned. This function must guarantee that all PCI + read and write operations are serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param AndData The value to AND with the PCI configuration register. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the PCI configuration register. + +**/ +UINT32 +EFIAPI +PciAndThenOr32 ( + IN UINTN Address, + IN UINT32 AndData, + IN UINT32 OrData + ) +{ + return PciExpressAndThenOr32 (Address, AndData, OrData); +} + +/** + Reads a bit field of a PCI configuration register. + + Reads the bit field in a 32-bit PCI configuration register. The bit field is + specified by the StartBit and the EndBit. The value of the bit field is + returned. + + If Address > 0x0FFFFFFF, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to read. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + + @return The value of the bit field read from the PCI configuration register. + +**/ +UINT32 +EFIAPI +PciBitFieldRead32 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit + ) +{ + return PciExpressBitFieldRead32 (Address, StartBit, EndBit); +} + +/** + Writes a bit field to a PCI configuration register. + + Writes Value to the bit field of the PCI configuration register. The bit + field is specified by the StartBit and the EndBit. All other bits in the + destination PCI configuration register are preserved. The new value of the + 32-bit register is returned. + + If Address > 0x0FFFFFFF, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + @param Value New value of the bit field. + + @return The value written back to the PCI configuration register. + +**/ +UINT32 +EFIAPI +PciBitFieldWrite32 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT32 Value + ) +{ + return PciExpressBitFieldWrite32 (Address, StartBit, EndBit, Value); +} + +/** + Reads a bit field in a 32-bit PCI configuration, performs a bitwise OR, and + writes the result back to the bit field in the 32-bit port. + + Reads the 32-bit PCI configuration register specified by Address, performs a + bitwise inclusive OR between the read result and the value specified by + OrData, and writes the result to the 32-bit PCI configuration register + specified by Address. The value written to the PCI configuration register is + returned. This function must guarantee that all PCI read and write operations + are serialized. Extra left bits in OrData are stripped. + + If Address > 0x0FFFFFFF, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + @param OrData The value to OR with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT32 +EFIAPI +PciBitFieldOr32 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT32 OrData + ) +{ + return PciExpressBitFieldOr32 (Address, StartBit, EndBit, OrData); +} + +/** + Reads a bit field in a 32-bit PCI configuration register, performs a bitwise + AND, and writes the result back to the bit field in the 32-bit register. + + Reads the 32-bit PCI configuration register specified by Address, performs a + bitwise AND between the read result and the value specified by AndData, and + writes the result to the 32-bit PCI configuration register specified by + Address. The value written to the PCI configuration register is returned. + This function must guarantee that all PCI read and write operations are + serialized. Extra left bits in AndData are stripped. + + If Address > 0x0FFFFFFF, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + @param AndData The value to AND with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT32 +EFIAPI +PciBitFieldAnd32 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT32 AndData + ) +{ + return PciExpressBitFieldAnd32 (Address, StartBit, EndBit, AndData); +} + +/** + Reads a bit field in a 32-bit port, performs a bitwise AND followed by a + bitwise inclusive OR, and writes the result back to the bit field in the + 32-bit port. + + Reads the 32-bit PCI configuration register specified by Address, performs a + bitwise AND followed by a bitwise inclusive OR between the read result and + the value specified by AndData, and writes the result to the 32-bit PCI + configuration register specified by Address. The value written to the PCI + configuration register is returned. This function must guarantee that all PCI + read and write operations are serialized. Extra left bits in both AndData and + OrData are stripped. + + If Address > 0x0FFFFFFF, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + @param AndData The value to AND with the PCI configuration register. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the PCI configuration register. + +**/ +UINT32 +EFIAPI +PciBitFieldAndThenOr32 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT32 AndData, + IN UINT32 OrData + ) +{ + return PciExpressBitFieldAndThenOr32 (Address, StartBit, EndBit, AndData, OrData); +} + +/** + Reads a range of PCI configuration registers into a caller supplied buffer. + + Reads the range of PCI configuration registers specified by StartAddress and + Size into the buffer specified by Buffer. This function only allows the PCI + configuration registers from a single PCI function to be read. Size is + returned. When possible 32-bit PCI configuration read cycles are used to read + from StartAdress to StartAddress + Size. Due to alignment restrictions, 8-bit + and 16-bit PCI configuration read cycles may be used at the beginning and the + end of the range. + + If StartAddress > 0x0FFFFFFF, then ASSERT(). + If ((StartAddress & 0xFFF) + Size) > 0x1000, then ASSERT(). + If Size > 0 and Buffer is NULL, then ASSERT(). + + @param StartAddress Starting address that encodes the PCI Bus, Device, + Function and Register. + @param Size Size in bytes of the transfer. + @param Buffer Pointer to a buffer receiving the data read. + + @return Size + +**/ +UINTN +EFIAPI +PciReadBuffer ( + IN UINTN StartAddress, + IN UINTN Size, + OUT VOID *Buffer + ) +{ + return PciExpressReadBuffer (StartAddress, Size, Buffer); +} + +/** + Copies the data in a caller supplied buffer to a specified range of PCI + configuration space. + + Writes the range of PCI configuration registers specified by StartAddress and + Size from the buffer specified by Buffer. This function only allows the PCI + configuration registers from a single PCI function to be written. Size is + returned. When possible 32-bit PCI configuration write cycles are used to + write from StartAdress to StartAddress + Size. Due to alignment restrictions, + 8-bit and 16-bit PCI configuration write cycles may be used at the beginning + and the end of the range. + + If StartAddress > 0x0FFFFFFF, then ASSERT(). + If ((StartAddress & 0xFFF) + Size) > 0x1000, then ASSERT(). + If Size > 0 and Buffer is NULL, then ASSERT(). + + @param StartAddress Starting address that encodes the PCI Bus, Device, + Function and Register. + @param Size Size in bytes of the transfer. + @param Buffer Pointer to a buffer containing the data to write. + + @return Size + +**/ +UINTN +EFIAPI +PciWriteBuffer ( + IN UINTN StartAddress, + IN UINTN Size, + IN VOID *Buffer + ) +{ + return PciExpressWriteBuffer (StartAddress, Size, Buffer); +} diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffGetEntryPointLib/BasePeCoffGetEntryPointLib.inf b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffGetEntryPointLib/BasePeCoffGetEntryPointLib.inf new file mode 100644 index 0000000..9ef8d0a --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffGetEntryPointLib/BasePeCoffGetEntryPointLib.inf @@ -0,0 +1,82 @@ +#/*++ +# +# 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: +# +# BasePeCoffGetEntryPointLib.inf +# +# Abstract: +# +# Component description file for BasePeCoffGetEntryPointLib. +# +#--*/ + +[defines] +BASE_NAME = EdkIIGlueBasePeCoffGetEntryPointLib +COMPONENT_TYPE = LIBRARY + +[sources.common] + PeCoffGetEntryPoint.c + +[sources.ia32] + + +[sources.x64] + + +[sources.ipf] + + +[sources.ebc] + + +[includes.common] + . + ..\..\Include + ..\..\include\Library + $(EDK_SOURCE)\Foundation + $(EDK_SOURCE)\Foundation\Framework + $(EDK_SOURCE)\Foundation\Efi + $(EDK_SOURCE)\Foundation\Include + $(EDK_SOURCE)\Foundation\Efi\Include + $(EDK_SOURCE)\Foundation\Framework\Include + $(EDK_SOURCE)\Foundation\Include\IndustryStandard + $(EDK_SOURCE)\Foundation\Core\Dxe + $(EDK_SOURCE)\Foundation\Library\Dxe\Include + $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include + + $(EDK_SOURCE)\Foundation\Efi\Include + + +[libraries.common] + + +[libraries.ia32] + + +[libraries.x64] + + +[nmake.common] + C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION + LIB_STD_FLAGS = /NOLOGO /IGNORE:4006 + +[nmake.ia32] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32 + +[nmake.x64] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64 + +[nmake.ipf] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF + +[nmake.ebc] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_EBC
\ No newline at end of file diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffGetEntryPointLib/EdkIIGlueBasePeCoffGetEntryPointLib.cif b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffGetEntryPointLib/EdkIIGlueBasePeCoffGetEntryPointLib.cif new file mode 100644 index 0000000..c21dfa7 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffGetEntryPointLib/EdkIIGlueBasePeCoffGetEntryPointLib.cif @@ -0,0 +1,11 @@ +<component> + name = "EdkIIGlueBasePeCoffGetEntryPointLib" + category = ModulePart + LocalRoot = "Edk\Foundation\Library\EdkIIGlueLib\Library\BasePeCoffGetEntryPointLib" + RefName = "EdkIIGlueBasePeCoffGetEntryPointLib" +[files] +"EdkIIGlueBasePeCoffGetEntryPointLib.sdl" +"EdkIIGlueBasePeCoffGetEntryPointLib.mak" +"BasePeCoffGetEntryPointLib.inf" +"PeCoffGetEntryPoint.c" +<endComponent> diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffGetEntryPointLib/EdkIIGlueBasePeCoffGetEntryPointLib.mak b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffGetEntryPointLib/EdkIIGlueBasePeCoffGetEntryPointLib.mak new file mode 100644 index 0000000..871cf28 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffGetEntryPointLib/EdkIIGlueBasePeCoffGetEntryPointLib.mak @@ -0,0 +1,80 @@ +#********************************************************************** +#********************************************************************** +#** ** +#** (C)Copyright 1985-2009, American Megatrends, Inc. ** +#** ** +#** All Rights Reserved. ** +#** ** +#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +#** ** +#** Phone: (770)-246-8600 ** +#** ** +#********************************************************************** +#********************************************************************** + +#********************************************************************** +# $Header: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGlueBasePeCoffGetEntryPointLib/EdkIIGlueBasePeCoffGetEntryPointLib.mak 1 1/20/12 3:53a Jeffch $ +# +# $Revision: 1 $ +# +# $Date: 1/20/12 3:53a $ +#********************************************************************** +# Revision History +# ---------------- +# $Log: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGlueBasePeCoffGetEntryPointLib/EdkIIGlueBasePeCoffGetEntryPointLib.mak $ +# +# 1 1/20/12 3:53a Jeffch +# Create Intel EDK 1117 Patch 7. +# +# 1 9/27/11 6:16a Wesleychen +# Intel EDK initially releases. +# +# 1 9/18/09 1:52a Iminglin +# +#********************************************************************** +#<AMI_FHDR_START> +# +# Name: EdkIIGlueBasePeCoffGetEntryPointLib.mak +# +# Description: +# +#<AMI_FHDR_END> +#********************************************************************** + + +$(EdkIIGlueBasePeCoffGetEntryPointLib_LIB) : EdkIIGlueBasePeCoffGetEntryPointLib + +EdkIIGlueBasePeCoffGetEntryPointLib : $(BUILD_DIR)\EdkIIGlueBasePeCoffGetEntryPointLib.mak EdkIIGlueBasePeCoffGetEntryPointLibBin + +$(BUILD_DIR)\EdkIIGlueBasePeCoffGetEntryPointLib.mak : $(EdkIIGlueBasePeCoffGetEntryPointLib_DIR)\$(@B).cif $(EdkIIGlueBasePeCoffGetEntryPointLib_DIR)\$(@B).mak $(BUILD_RULES) + $(CIF2MAK) $(EdkIIGlueBasePeCoffGetEntryPointLib_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS) + +EdkIIGlueBasePeCoffGetEntryPointLibBin : +!IF "$(x64_BUILD)"=="1" + $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\ + BUILD_DIR=$(BUILD_DIR)\ + /f $(BUILD_DIR)\EdkIIGlueBasePeCoffGetEntryPointLib.mak all\ + TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueBasePeCoffGetEntryPointLib_LIB)" + $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\ + BUILD_DIR=$(BUILD_DIR)\IA32\ + /f $(BUILD_DIR)\EdkIIGlueBasePeCoffGetEntryPointLib.mak all\ + TYPE=PEI_LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueBasePeCoffGetEntryPointLib_LIB)" +!ELSE + $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\ + BUILD_DIR=$(BUILD_DIR)\ + /f $(BUILD_DIR)\EdkIIGlueBasePeCoffGetEntryPointLib.mak all\ + TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueBasePeCoffGetEntryPointLib_LIB)" +!ENDIF +#********************************************************************** +#********************************************************************** +#** ** +#** (C)Copyright 1985-2009, American Megatrends, Inc. ** +#** ** +#** All Rights Reserved. ** +#** ** +#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +#** ** +#** Phone: (770)-246-8600 ** +#** ** +#********************************************************************** +#**********************************************************************
\ No newline at end of file diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffGetEntryPointLib/EdkIIGlueBasePeCoffGetEntryPointLib.sdl b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffGetEntryPointLib/EdkIIGlueBasePeCoffGetEntryPointLib.sdl new file mode 100644 index 0000000..27c457a --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffGetEntryPointLib/EdkIIGlueBasePeCoffGetEntryPointLib.sdl @@ -0,0 +1,26 @@ +TOKEN + Name = "EdkIIGlueBasePeCoffGetEntryPointLib_SUPPORT" + Value = "1" + Help = "Main switch to enable EdkIIGlueBasePeCoffGetEntryPointLib support in Project" + TokenType = Boolean + TargetEQU = Yes + TargetMAK = Yes + Master = Yes +End + +TOKEN + Name = "EdkIIGlueBasePeCoffGetEntryPointLib_LIB" + Value = "$$(LIB_BUILD_DIR)\EdkIIGlueBasePeCoffGetEntryPointLib.lib" + TokenType = Expression + TargetMAK = Yes +End + +PATH + Name = "EdkIIGlueBasePeCoffGetEntryPointLib_DIR" +End + +MODULE + Help = "Includes EdkIIGlueBasePeCoffGetEntryPointLib.mak to Project" + File = "EdkIIGlueBasePeCoffGetEntryPointLib.mak" +End + diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffGetEntryPointLib/PeCoffGetEntryPoint.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffGetEntryPointLib/PeCoffGetEntryPoint.c new file mode 100644 index 0000000..208d662 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffGetEntryPointLib/PeCoffGetEntryPoint.c @@ -0,0 +1,222 @@ +/*++ + +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: + + PeCoffGetEntryPoint.c + +Abstract: + + Pe/Coff loader + +--*/ + +#include "EdkIIGlueBase.h" + +/** + Retrieves and returns a pointer to the entry point to a PE/COFF image that has been loaded + into system memory with the PE/COFF Loader Library functions. + + Retrieves the entry point to the PE/COFF image specified by Pe32Data and returns this entry + point in EntryPoint. If the entry point could not be retrieved from the PE/COFF image, then + return RETURN_INVALID_PARAMETER. Otherwise return RETURN_SUCCESS. + If Pe32Data is NULL, then ASSERT(). + If EntryPoint is NULL, then ASSERT(). + + @param Pe32Data Pointer to the PE/COFF image that is loaded in system memory. + @param EntryPoint Pointer to entry point to the PE/COFF image to return. + + @retval RETURN_SUCCESS EntryPoint was returned. + @retval RETURN_INVALID_PARAMETER The entry point could not be found in the PE/COFF image. + +**/ +RETURN_STATUS +EFIAPI +PeCoffLoaderGetEntryPoint ( + IN VOID *Pe32Data, + OUT VOID **EntryPoint + ) +{ + EFI_IMAGE_DOS_HEADER *DosHeader; + EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION Header; + + ASSERT (Pe32Data != NULL); + ASSERT (EntryPoint != NULL); + + DosHeader = (EFI_IMAGE_DOS_HEADER *)Pe32Data; + if (DosHeader->e_magic == EFI_IMAGE_DOS_SIGNATURE) { + // + // DOS image header is present, so read the PE header after the DOS image header. + // + Header.Pe32 = (EFI_IMAGE_NT_HEADERS32 *)((UINTN) Pe32Data + (UINTN) ((DosHeader->e_lfanew) & 0x0ffff)); + } else { + // + // DOS image header is not present, so PE header is at the image base. + // + Header.Pe32 = (EFI_IMAGE_NT_HEADERS32 *)Pe32Data; + } + + // + // Calculate the entry point relative to the start of the image. + // AddressOfEntryPoint is common for PE32 & PE32+ + // + *EntryPoint = (VOID *)((UINTN)Pe32Data + (UINTN)(Header.Pe32->OptionalHeader.AddressOfEntryPoint & 0x0ffffffff)); + return RETURN_SUCCESS; +} + + +/** + Returns the machine type of a PE/COFF image. + + Returns the machine type from the PE/COFF image specified by Pe32Data. + If Pe32Data is NULL, then ASSERT(). + + @param Pe32Data Pointer to the PE/COFF image that is loaded in system + memory. + + @return Machine type or zero if not a valid iamge. + +**/ +UINT16 +EFIAPI +PeCoffLoaderGetMachineType ( + IN VOID *Pe32Data + ) +{ + EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION Hdr; + EFI_IMAGE_DOS_HEADER *DosHdr; + + DosHdr = (EFI_IMAGE_DOS_HEADER *)Pe32Data; + if (DosHdr->e_magic == EFI_IMAGE_DOS_SIGNATURE) { + Hdr.Pe32 = (EFI_IMAGE_NT_HEADERS32 *)((UINTN)Pe32Data + DosHdr->e_lfanew); + } else { + Hdr.Pe32 = (EFI_IMAGE_NT_HEADERS32 *)((UINTN)Pe32Data); + } + + if (Hdr.Pe32->Signature == EFI_IMAGE_NT_SIGNATURE) { + return Hdr.Pe32->FileHeader.Machine; + } + + return 0x0000; +} + +/** + Returns a pointer to the PDB file name for a PE/COFF image that has been + loaded into system memory with the PE/COFF Loader Library functions. + + Returns the PDB file name for the PE/COFF image specified by Pe32Data. If + the PE/COFF image specified by Pe32Data is not a valid, then NULL is + returned. If the PE/COFF image specified by Pe32Data does not contain a + debug directory entry, then NULL is returned. If the debug directory entry + in the PE/COFF image specified by Pe32Data does not contain a PDB file name, + then NULL is returned. + If Pe32Data is NULL, then ASSERT(). + + @param Pe32Data Pointer to the PE/COFF image that is loaded in system + memory. + + @return The PDB file name for the PE/COFF image specified by Pe32Data or NULL + if it cannot be retrieved. + +**/ +VOID * +EFIAPI +PeCoffLoaderGetPdbPointer ( + IN VOID *Pe32Data + ) +{ + EFI_IMAGE_DOS_HEADER *DosHeader; + EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION Hdr; + EFI_IMAGE_DATA_DIRECTORY *DirectoryEntry; + EFI_IMAGE_DEBUG_DIRECTORY_ENTRY *DebugEntry; + UINTN DirCount; + VOID *CodeViewEntryPointer; + INTN TEImageAdjust; + UINT32 NumberOfRvaAndSizes; + + ASSERT (Pe32Data != NULL); + + TEImageAdjust = 0; + DirectoryEntry = NULL; + DebugEntry = NULL; + NumberOfRvaAndSizes = 0; + + DosHeader = (EFI_IMAGE_DOS_HEADER *)Pe32Data; + if (DosHeader->e_magic == EFI_IMAGE_DOS_SIGNATURE) { + // + // DOS image header is present, so read the PE header after the DOS image header. + // + Hdr.Pe32 = (EFI_IMAGE_NT_HEADERS32 *)((UINTN) Pe32Data + (UINTN) ((DosHeader->e_lfanew) & 0x0ffff)); + } else { + // + // DOS image header is not present, so PE header is at the image base. + // + Hdr.Pe32 = (EFI_IMAGE_NT_HEADERS32 *)Pe32Data; + } + + if (Hdr.Te->Signature == EFI_TE_IMAGE_HEADER_SIGNATURE) { + if (Hdr.Te->DataDirectory[EFI_TE_IMAGE_DIRECTORY_ENTRY_DEBUG].VirtualAddress != 0) { + DirectoryEntry = &Hdr.Te->DataDirectory[EFI_TE_IMAGE_DIRECTORY_ENTRY_DEBUG]; + TEImageAdjust = sizeof (EFI_TE_IMAGE_HEADER) - Hdr.Te->StrippedSize; + DebugEntry = (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY *)((UINTN) Hdr.Te + + Hdr.Te->DataDirectory[EFI_TE_IMAGE_DIRECTORY_ENTRY_DEBUG].VirtualAddress + + TEImageAdjust); + } + } else if (Hdr.Pe32->Signature == EFI_IMAGE_NT_SIGNATURE) { + if (Hdr.Pe32->OptionalHeader.Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) { + // + // Use PE32 offset get Debug Directory Entry + // + NumberOfRvaAndSizes = Hdr.Pe32->OptionalHeader.NumberOfRvaAndSizes; + DirectoryEntry = (EFI_IMAGE_DATA_DIRECTORY *)&(Hdr.Pe32->OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_DEBUG]); + DebugEntry = (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY *) ((UINTN) Pe32Data + DirectoryEntry->VirtualAddress); + } else if (Hdr.Pe32->OptionalHeader.Magic == EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC) { + // + // Use PE32+ offset get Debug Directory Entry + // + NumberOfRvaAndSizes = Hdr.Pe32Plus->OptionalHeader.NumberOfRvaAndSizes; + DirectoryEntry = (EFI_IMAGE_DATA_DIRECTORY *)&(Hdr.Pe32Plus->OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_DEBUG]); + DebugEntry = (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY *) ((UINTN) Pe32Data + DirectoryEntry->VirtualAddress); + } + + if (NumberOfRvaAndSizes <= EFI_IMAGE_DIRECTORY_ENTRY_DEBUG) { + DirectoryEntry = NULL; + DebugEntry = NULL; + } + } else { + return NULL; + } + + if (DebugEntry == NULL || DirectoryEntry == NULL) { + return NULL; + } + + for (DirCount = 0; DirCount < DirectoryEntry->Size; DirCount++, DebugEntry++) { + if (DebugEntry->Type == EFI_IMAGE_DEBUG_TYPE_CODEVIEW) { + if (DebugEntry->SizeOfData > 0) { + CodeViewEntryPointer = (VOID *) ((UINTN) DebugEntry->RVA + ((UINTN)Pe32Data) + (UINTN)TEImageAdjust); + switch (* (UINT32 *) CodeViewEntryPointer) { + case CODEVIEW_SIGNATURE_NB10: + return (VOID *) ((CHAR8 *)CodeViewEntryPointer + sizeof (EFI_IMAGE_DEBUG_CODEVIEW_NB10_ENTRY)); + case CODEVIEW_SIGNATURE_RSDS: + return (VOID *) ((CHAR8 *)CodeViewEntryPointer + sizeof (EFI_IMAGE_DEBUG_CODEVIEW_RSDS_ENTRY)); + default: + break; + } + } + } + } + + return NULL; +} + + diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffLib/BasePeCoff.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffLib/BasePeCoff.c new file mode 100644 index 0000000..3b8264a --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffLib/BasePeCoff.c @@ -0,0 +1,1357 @@ +/*++ + +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: + + EdkIIGlueDxeDriverEntryPoint.c + +Abstract: + + Pe/Coff loader + +--*/ + +#include "BasePeCoffLibInternals.h" + +/** + Retrieves the magic value from the PE/COFF header. + + @param Hdr The buffer in which to return the PE32, PE32+, or TE header. + + @return EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC - Image is PE32 + @return EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC - Image is PE32+ + +**/ +UINT16 +PeCoffLoaderGetPeHeaderMagicValue ( + IN EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION Hdr + ) +{ + // + // NOTE: Some versions of Linux ELILO for Itanium have an incorrect magic value + // in the PE/COFF Header. If the MachineType is Itanium(IA64) and the + // Magic value in the OptionalHeader is EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC + // then override the returned value to EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC + // + if (Hdr.Pe32->FileHeader.Machine == EFI_IMAGE_MACHINE_IA64 && Hdr.Pe32->OptionalHeader.Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) { + return EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC; + } + // + // Return the magic value from the PC/COFF Optional Header + // + return Hdr.Pe32->OptionalHeader.Magic; +} + + +/** + Retrieves the PE or TE Header from a PE/COFF or TE image. + + @param ImageContext The context of the image being loaded. + @param Hdr The buffer in which to return the PE32, PE32+, or TE header. + + @retval RETURN_SUCCESS The PE or TE Header is read. + @retval Other The error status from reading the PE/COFF or TE image using the ImageRead function. + +**/ +RETURN_STATUS +GluePeCoffLoaderGetPeHeader ( + IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext, + OUT EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION Hdr + ) +{ + RETURN_STATUS Status; + EFI_IMAGE_DOS_HEADER DosHdr; + UINTN Size; + UINT16 Magic; + + // + // Read the DOS image header to check for it's existance + // + Size = sizeof (EFI_IMAGE_DOS_HEADER); + Status = ImageContext->ImageRead ( + ImageContext->Handle, + 0, + &Size, + &DosHdr + ); + if (RETURN_ERROR (Status)) { + ImageContext->ImageError = IMAGE_ERROR_IMAGE_READ; + return Status; + } + + ImageContext->PeCoffHeaderOffset = 0; + if (DosHdr.e_magic == EFI_IMAGE_DOS_SIGNATURE) { + // + // DOS image header is present, so read the PE header after the DOS image + // header + // + ImageContext->PeCoffHeaderOffset = DosHdr.e_lfanew; + } + + // + // Read the PE/COFF Header. For PE32 (32-bit) this will read in too much + // data, but that should not hurt anythine. Hdr.Pe32->OptionalHeader.Magic + // determins if this is a PE32 or PE32+ image. The magic is in the same + // location in both images. + // + Size = sizeof (EFI_IMAGE_OPTIONAL_HEADER_UNION); + Status = ImageContext->ImageRead ( + ImageContext->Handle, + ImageContext->PeCoffHeaderOffset, + &Size, + Hdr.Pe32 + ); + if (RETURN_ERROR (Status)) { + ImageContext->ImageError = IMAGE_ERROR_IMAGE_READ; + return Status; + } + + // + // Use Signature to figure out if we understand the image format + // + if (Hdr.Te->Signature == EFI_TE_IMAGE_HEADER_SIGNATURE) { + ImageContext->IsTeImage = TRUE; + ImageContext->Machine = Hdr.Te->Machine; + ImageContext->ImageType = (UINT16)(Hdr.Te->Subsystem); + ImageContext->ImageSize = 0; + ImageContext->SectionAlignment = 4096; + ImageContext->SizeOfHeaders = sizeof (EFI_TE_IMAGE_HEADER) + (UINTN)Hdr.Te->BaseOfCode - (UINTN)Hdr.Te->StrippedSize; + + } else if (Hdr.Pe32->Signature == EFI_IMAGE_NT_SIGNATURE) { + ImageContext->IsTeImage = FALSE; + ImageContext->Machine = Hdr.Pe32->FileHeader.Machine; + + Magic = PeCoffLoaderGetPeHeaderMagicValue (Hdr); + + if (Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) { + // + // Use PE32 offset + // + ImageContext->ImageType = Hdr.Pe32->OptionalHeader.Subsystem; + ImageContext->ImageSize = (UINT64)Hdr.Pe32->OptionalHeader.SizeOfImage; + ImageContext->SectionAlignment = Hdr.Pe32->OptionalHeader.SectionAlignment; + ImageContext->SizeOfHeaders = Hdr.Pe32->OptionalHeader.SizeOfHeaders; + + } else if (Magic == EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC) { + // + // Use PE32+ offset + // + ImageContext->ImageType = Hdr.Pe32Plus->OptionalHeader.Subsystem; + ImageContext->ImageSize = (UINT64) Hdr.Pe32Plus->OptionalHeader.SizeOfImage; + ImageContext->SectionAlignment = Hdr.Pe32Plus->OptionalHeader.SectionAlignment; + ImageContext->SizeOfHeaders = Hdr.Pe32Plus->OptionalHeader.SizeOfHeaders; + } else { + ImageContext->ImageError = IMAGE_ERROR_INVALID_MACHINE_TYPE; + return RETURN_UNSUPPORTED; + } + } else { + ImageContext->ImageError = IMAGE_ERROR_INVALID_MACHINE_TYPE; + return RETURN_UNSUPPORTED; + } + + if (!PeCoffLoaderImageFormatSupported (ImageContext->Machine)) { + // + // If the PE/COFF loader does not support the image type return + // unsupported. This library can suport lots of types of images + // this does not mean the user of this library can call the entry + // point of the image. + // + return RETURN_UNSUPPORTED; + } + + return RETURN_SUCCESS; +} + + +/** + Retrieves information about a PE/COFF image. + + Computes the PeCoffHeaderOffset, ImageAddress, ImageSize, DestinationAddress, CodeView, + PdbPointer, RelocationsStripped, SectionAlignment, SizeOfHeaders, and DebugDirectoryEntryRva + fields of the ImageContext structure. If ImageContext is NULL, then return RETURN_INVALID_PARAMETER. + If the PE/COFF image accessed through the ImageRead service in the ImageContext structure is not + a supported PE/COFF image type, then return RETURN_UNSUPPORTED. If any errors occur while + computing the fields of ImageContext, then the error status is returned in the ImageError field of + ImageContext. + + @param ImageContext Pointer to the image context structure that describes the PE/COFF + image that needs to be examined by this function. + + @retval RETURN_SUCCESS The information on the PE/COFF image was collected. + @retval RETURN_INVALID_PARAMETER ImageContext is NULL. + @retval RETURN_UNSUPPORTED The PE/COFF image is not supported. + +**/ +RETURN_STATUS +EFIAPI +GluePeCoffLoaderGetImageInfo ( + IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext + ) +{ + RETURN_STATUS Status; + EFI_IMAGE_OPTIONAL_HEADER_UNION HdrData; + EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION Hdr; + EFI_IMAGE_DATA_DIRECTORY *DebugDirectoryEntry; + UINTN Size; + UINTN Index; + UINTN DebugDirectoryEntryRva; + UINTN DebugDirectoryEntryFileOffset; + UINTN SectionHeaderOffset; + EFI_IMAGE_SECTION_HEADER SectionHeader; + EFI_IMAGE_DEBUG_DIRECTORY_ENTRY DebugEntry; + UINT32 NumberOfRvaAndSizes; + UINT16 Magic; + + if (NULL == ImageContext) { + return RETURN_INVALID_PARAMETER; + } + // + // Assume success + // + ImageContext->ImageError = IMAGE_ERROR_SUCCESS; + + Hdr.Union = &HdrData; + Status = PeCoffLoaderGetPeHeader (ImageContext, Hdr); + if (RETURN_ERROR (Status)) { + return Status; + } + + Magic = PeCoffLoaderGetPeHeaderMagicValue (Hdr); + + // + // Retrieve the base address of the image + // + if (!(ImageContext->IsTeImage)) { + if (Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) { + // + // Use PE32 offset + // + ImageContext->ImageAddress = Hdr.Pe32->OptionalHeader.ImageBase; + } else { + // + // Use PE32+ offset + // + ImageContext->ImageAddress = Hdr.Pe32Plus->OptionalHeader.ImageBase; + } + } else { + ImageContext->ImageAddress = (PHYSICAL_ADDRESS)(Hdr.Te->ImageBase + Hdr.Te->StrippedSize - sizeof (EFI_TE_IMAGE_HEADER)); + } + + // + // Initialize the alternate destination address to 0 indicating that it + // should not be used. + // + ImageContext->DestinationAddress = 0; + + // + // Initialize the codeview pointer. + // + ImageContext->CodeView = NULL; + ImageContext->PdbPointer = NULL; + + // + // Three cases with regards to relocations: + // - Image has base relocs, RELOCS_STRIPPED==0 => image is relocatable + // - Image has no base relocs, RELOCS_STRIPPED==1 => Image is not relocatable + // - Image has no base relocs, RELOCS_STRIPPED==0 => Image is relocatable but + // has no base relocs to apply + // Obviously having base relocations with RELOCS_STRIPPED==1 is invalid. + // + // Look at the file header to determine if relocations have been stripped, and + // save this info in the image context for later use. + // + if ((!(ImageContext->IsTeImage)) && ((Hdr.Pe32->FileHeader.Characteristics & EFI_IMAGE_FILE_RELOCS_STRIPPED) != 0)) { + ImageContext->RelocationsStripped = TRUE; + } else { + ImageContext->RelocationsStripped = FALSE; + } + + if (!(ImageContext->IsTeImage)) { + if (Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) { + // + // Use PE32 offset + // + NumberOfRvaAndSizes = Hdr.Pe32->OptionalHeader.NumberOfRvaAndSizes; + DebugDirectoryEntry = (EFI_IMAGE_DATA_DIRECTORY *)&(Hdr.Pe32->OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_DEBUG]); + } else { + // + // Use PE32+ offset + // + NumberOfRvaAndSizes = Hdr.Pe32Plus->OptionalHeader.NumberOfRvaAndSizes; + DebugDirectoryEntry = (EFI_IMAGE_DATA_DIRECTORY *)&(Hdr.Pe32Plus->OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_DEBUG]); + } + + if (NumberOfRvaAndSizes > EFI_IMAGE_DIRECTORY_ENTRY_DEBUG) { + + DebugDirectoryEntryRva = DebugDirectoryEntry->VirtualAddress; + + // + // Determine the file offset of the debug directory... This means we walk + // the sections to find which section contains the RVA of the debug + // directory + // + DebugDirectoryEntryFileOffset = 0; + + SectionHeaderOffset = (UINTN)( + ImageContext->PeCoffHeaderOffset + + sizeof (UINT32) + + sizeof (EFI_IMAGE_FILE_HEADER) + + Hdr.Pe32->FileHeader.SizeOfOptionalHeader + ); + + for (Index = 0; Index < Hdr.Pe32->FileHeader.NumberOfSections; Index++) { + // + // Read section header from file + // + Size = sizeof (EFI_IMAGE_SECTION_HEADER); + Status = ImageContext->ImageRead ( + ImageContext->Handle, + SectionHeaderOffset, + &Size, + &SectionHeader + ); + if (RETURN_ERROR (Status)) { + ImageContext->ImageError = IMAGE_ERROR_IMAGE_READ; + return Status; + } + + if (DebugDirectoryEntryRva >= SectionHeader.VirtualAddress && + DebugDirectoryEntryRva < SectionHeader.VirtualAddress + SectionHeader.Misc.VirtualSize) { + + DebugDirectoryEntryFileOffset = DebugDirectoryEntryRva - SectionHeader.VirtualAddress + SectionHeader.PointerToRawData; + break; + } + + SectionHeaderOffset += sizeof (EFI_IMAGE_SECTION_HEADER); + } + + if (DebugDirectoryEntryFileOffset != 0) { + for (Index = 0; Index < DebugDirectoryEntry->Size; Index += sizeof (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY)) { + // + // Read next debug directory entry + // + Size = sizeof (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY); + Status = ImageContext->ImageRead ( + ImageContext->Handle, + DebugDirectoryEntryFileOffset, + &Size, + &DebugEntry + ); + if (RETURN_ERROR (Status)) { + ImageContext->ImageError = IMAGE_ERROR_IMAGE_READ; + return Status; + } + if (DebugEntry.Type == EFI_IMAGE_DEBUG_TYPE_CODEVIEW) { + ImageContext->DebugDirectoryEntryRva = (UINT32) (DebugDirectoryEntryRva + Index); + if (DebugEntry.RVA == 0 && DebugEntry.FileOffset != 0) { + ImageContext->ImageSize += DebugEntry.SizeOfData; + } + + return RETURN_SUCCESS; + } + } + } + } + } else { + + DebugDirectoryEntry = &Hdr.Te->DataDirectory[1]; + DebugDirectoryEntryRva = DebugDirectoryEntry->VirtualAddress; + SectionHeaderOffset = (UINTN)(sizeof (EFI_TE_IMAGE_HEADER)); + + DebugDirectoryEntryFileOffset = 0; + + for (Index = 0; Index < Hdr.Te->NumberOfSections;) { + // + // Read section header from file + // + Size = sizeof (EFI_IMAGE_SECTION_HEADER); + Status = ImageContext->ImageRead ( + ImageContext->Handle, + SectionHeaderOffset, + &Size, + &SectionHeader + ); + if (RETURN_ERROR (Status)) { + ImageContext->ImageError = IMAGE_ERROR_IMAGE_READ; + return Status; + } + + if (DebugDirectoryEntryRva >= SectionHeader.VirtualAddress && + DebugDirectoryEntryRva < SectionHeader.VirtualAddress + SectionHeader.Misc.VirtualSize) { + DebugDirectoryEntryFileOffset = DebugDirectoryEntryRva - + SectionHeader.VirtualAddress + + SectionHeader.PointerToRawData + + sizeof (EFI_TE_IMAGE_HEADER) - + Hdr.Te->StrippedSize; + + // + // File offset of the debug directory was found, if this is not the last + // section, then skip to the last section for calculating the image size. + // + if (Index < (UINTN) Hdr.Te->NumberOfSections - 1) { + SectionHeaderOffset += (Hdr.Te->NumberOfSections - 1 - Index) * sizeof (EFI_IMAGE_SECTION_HEADER); + Index = Hdr.Te->NumberOfSections - 1; + continue; + } + } + + // + // In Te image header there is not a field to describe the ImageSize. + // Actually, the ImageSize equals the RVA plus the VirtualSize of + // the last section mapped into memory (Must be rounded up to + // a mulitple of Section Alignment). Per the PE/COFF specification, the + // section headers in the Section Table must appear in order of the RVA + // values for the corresponding sections. So the ImageSize can be determined + // by the RVA and the VirtualSize of the last section header in the + // Section Table. + // + if ((++Index) == (UINTN)Hdr.Te->NumberOfSections) { + ImageContext->ImageSize = (SectionHeader.VirtualAddress + SectionHeader.Misc.VirtualSize + + ImageContext->SectionAlignment - 1) & ~(ImageContext->SectionAlignment - 1); + } + + SectionHeaderOffset += sizeof (EFI_IMAGE_SECTION_HEADER); + } + + if (DebugDirectoryEntryFileOffset != 0) { + for (Index = 0; Index < DebugDirectoryEntry->Size; Index += sizeof (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY)) { + // + // Read next debug directory entry + // + Size = sizeof (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY); + Status = ImageContext->ImageRead ( + ImageContext->Handle, + DebugDirectoryEntryFileOffset, + &Size, + &DebugEntry + ); + if (RETURN_ERROR (Status)) { + ImageContext->ImageError = IMAGE_ERROR_IMAGE_READ; + return Status; + } + + if (DebugEntry.Type == EFI_IMAGE_DEBUG_TYPE_CODEVIEW) { + ImageContext->DebugDirectoryEntryRva = (UINT32) (DebugDirectoryEntryRva + Index); + return RETURN_SUCCESS; + } + } + } + } + + return RETURN_SUCCESS; +} + + +/** + Converts an image address to the loaded address. + + @param ImageContext The context of the image being loaded. + @param Address The address to be converted to the loaded address. + + @return The converted address or NULL if the address can not be converted. + +**/ +VOID * +GluePeCoffLoaderImageAddress ( + IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext, + IN UINTN Address + ) +{ + // + // @bug Check to make sure ImageSize is correct for the relocated image. + // it may only work for the file we start with and not the relocated image + // + if (Address >= ImageContext->ImageSize) { + ImageContext->ImageError = IMAGE_ERROR_INVALID_IMAGE_ADDRESS; + return NULL; + } + + return (CHAR8 *)((UINTN) ImageContext->ImageAddress + Address); +} + +/** + Applies relocation fixups to a PE/COFF image that was loaded with PeCoffLoaderLoadImage(). + + If the DestinationAddress field of ImageContext is 0, then use the ImageAddress field of + ImageContext as the relocation base address. Otherwise, use the DestinationAddress field + of ImageContext as the relocation base address. The caller must allocate the relocation + fixup log buffer and fill in the FixupData field of ImageContext prior to calling this function. + If ImageContext is NULL, then ASSERT(). + + @param ImageContext Pointer to the image context structure that describes the PE/COFF + image that is being relocated. + + @retval RETURN_SUCCESS The PE/COFF image was relocated. + Extended status information is in the ImageError field of ImageContext. + @retval RETURN_LOAD_ERROR The image in not a valid PE/COFF image. + Extended status information is in the ImageError field of ImageContext. + @retval RETURN_UNSUPPORTED A relocation record type is not supported. + Extended status information is in the ImageError field of ImageContext. + +**/ +RETURN_STATUS +EFIAPI +GluePeCoffLoaderRelocateImage ( + IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext + ) +{ + RETURN_STATUS Status; + EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION Hdr; + EFI_IMAGE_DATA_DIRECTORY *RelocDir; + UINT64 Adjust; + EFI_IMAGE_BASE_RELOCATION *RelocBase; + EFI_IMAGE_BASE_RELOCATION *RelocBaseEnd; + UINT16 *Reloc; + UINT16 *RelocEnd; + CHAR8 *Fixup; + CHAR8 *FixupBase; + UINT16 *F16; + UINT32 *F32; + UINT64 *F64; + CHAR8 *FixupData; + PHYSICAL_ADDRESS BaseAddress; + UINT32 NumberOfRvaAndSizes; + UINT16 Magic; + + ASSERT (ImageContext != NULL); + + // + // Assume success + // + ImageContext->ImageError = IMAGE_ERROR_SUCCESS; + + // + // If there are no relocation entries, then we are done + // + if (ImageContext->RelocationsStripped) { + return RETURN_SUCCESS; + } + + // + // If the destination address is not 0, use that rather than the + // image address as the relocation target. + // + if (ImageContext->DestinationAddress != 0) { + BaseAddress = ImageContext->DestinationAddress; + } else if (!(ImageContext->IsTeImage)) { + BaseAddress = ImageContext->ImageAddress; + } else { + Hdr.Te = (EFI_TE_IMAGE_HEADER *)(UINTN)(ImageContext->ImageAddress); + BaseAddress = ImageContext->ImageAddress + sizeof (EFI_TE_IMAGE_HEADER) - Hdr.Te->StrippedSize; + } + + if (!(ImageContext->IsTeImage)) { + Hdr.Pe32 = (EFI_IMAGE_NT_HEADERS32 *)((UINTN)ImageContext->ImageAddress + ImageContext->PeCoffHeaderOffset); + + Magic = PeCoffLoaderGetPeHeaderMagicValue (Hdr); + + if (Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) { + // + // Use PE32 offset + // + Adjust = (UINT64)BaseAddress - Hdr.Pe32->OptionalHeader.ImageBase; + Hdr.Pe32->OptionalHeader.ImageBase = (UINT32)BaseAddress; + + NumberOfRvaAndSizes = Hdr.Pe32->OptionalHeader.NumberOfRvaAndSizes; + RelocDir = &Hdr.Pe32->OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC]; + } else { + // + // Use PE32+ offset + // + Adjust = (UINT64) BaseAddress - Hdr.Pe32Plus->OptionalHeader.ImageBase; + Hdr.Pe32Plus->OptionalHeader.ImageBase = (UINT64)BaseAddress; + + NumberOfRvaAndSizes = Hdr.Pe32Plus->OptionalHeader.NumberOfRvaAndSizes; + RelocDir = &Hdr.Pe32Plus->OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC]; + } + + // + // Find the relocation block + // Per the PE/COFF spec, you can't assume that a given data directory + // is present in the image. You have to check the NumberOfRvaAndSizes in + // the optional header to verify a desired directory entry is there. + // + + if (NumberOfRvaAndSizes > EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC && RelocDir->Size > 0) { + RelocBase = PeCoffLoaderImageAddress (ImageContext, RelocDir->VirtualAddress); + RelocBaseEnd = PeCoffLoaderImageAddress ( + ImageContext, + RelocDir->VirtualAddress + RelocDir->Size - 1 + ); + if ((RelocBase == NULL) || (RelocBaseEnd == NULL)) { + // + // If the base start or end address resolved to 0, then fail. + // + return RETURN_LOAD_ERROR; + } + } else { + // + // Set base and end to bypass processing below. + // + RelocBase = RelocBaseEnd = 0; + } + } else { + Hdr.Te = (EFI_TE_IMAGE_HEADER *)(UINTN)(ImageContext->ImageAddress); + Adjust = (UINT64) (BaseAddress - Hdr.Te->ImageBase); + Hdr.Te->ImageBase = (UINT64) (BaseAddress); + + // + // Find the relocation block + // + RelocDir = &Hdr.Te->DataDirectory[0]; + if (RelocDir->Size > 0) { + RelocBase = (EFI_IMAGE_BASE_RELOCATION *)(UINTN)( + ImageContext->ImageAddress + + RelocDir->VirtualAddress + + sizeof(EFI_TE_IMAGE_HEADER) - + Hdr.Te->StrippedSize + ); + RelocBaseEnd = (EFI_IMAGE_BASE_RELOCATION *) ((UINTN) RelocBase + (UINTN) RelocDir->Size - 1); + } else { + // + // Set base and end to bypass processing below. + // + RelocBase = RelocBaseEnd = 0; + } + } + + // + // Run the relocation information and apply the fixups + // + FixupData = ImageContext->FixupData; + while (RelocBase < RelocBaseEnd) { + + Reloc = (UINT16 *) ((CHAR8 *) RelocBase + sizeof (EFI_IMAGE_BASE_RELOCATION)); + RelocEnd = (UINT16 *) ((CHAR8 *) RelocBase + RelocBase->SizeOfBlock); + if (!(ImageContext->IsTeImage)) { + FixupBase = PeCoffLoaderImageAddress (ImageContext, RelocBase->VirtualAddress); + + if (FixupBase == NULL) { + // + // If the FixupBase address resolved to 0, then fail. + // + return RETURN_LOAD_ERROR; + } + + } else { + FixupBase = (CHAR8 *)(UINTN)(ImageContext->ImageAddress + + RelocBase->VirtualAddress + + sizeof(EFI_TE_IMAGE_HEADER) - + Hdr.Te->StrippedSize + ); + } + + if ((CHAR8 *) RelocEnd < (CHAR8 *) ((UINTN) ImageContext->ImageAddress) || + (CHAR8 *) RelocEnd > (CHAR8 *)((UINTN)ImageContext->ImageAddress + + (UINTN)ImageContext->ImageSize)) { + ImageContext->ImageError = IMAGE_ERROR_FAILED_RELOCATION; + return RETURN_LOAD_ERROR; + } + + // + // Run this relocation record + // + while (Reloc < RelocEnd) { + + Fixup = FixupBase + (*Reloc & 0xFFF); + switch ((*Reloc) >> 12) { + case EFI_IMAGE_REL_BASED_ABSOLUTE: + break; + + case EFI_IMAGE_REL_BASED_HIGH: + F16 = (UINT16 *) Fixup; + *F16 = (UINT16) (*F16 + ((UINT16) ((UINT32) Adjust >> 16))); + if (FixupData != NULL) { + *(UINT16 *) FixupData = *F16; + FixupData = FixupData + sizeof (UINT16); + } + break; + + case EFI_IMAGE_REL_BASED_LOW: + F16 = (UINT16 *) Fixup; + *F16 = (UINT16) (*F16 + (UINT16) Adjust); + if (FixupData != NULL) { + *(UINT16 *) FixupData = *F16; + FixupData = FixupData + sizeof (UINT16); + } + break; + + case EFI_IMAGE_REL_BASED_HIGHLOW: + F32 = (UINT32 *) Fixup; + *F32 = *F32 + (UINT32) Adjust; + if (FixupData != NULL) { + FixupData = ALIGN_POINTER (FixupData, sizeof (UINT32)); + *(UINT32 *)FixupData = *F32; + FixupData = FixupData + sizeof (UINT32); + } + break; + + case EFI_IMAGE_REL_BASED_DIR64: + F64 = (UINT64 *) Fixup; + *F64 = *F64 + (UINT64) Adjust; + if (FixupData != NULL) { + FixupData = ALIGN_POINTER (FixupData, sizeof(UINT64)); + *(UINT64 *)(FixupData) = *F64; + FixupData = FixupData + sizeof(UINT64); + } + break; + + default: + // + // The common code does not handle some of the stranger IPF relocations + // PeCoffLoaderRelocateImageEx () addes support for these complex fixups + // on IPF and is a No-Op on other archtiectures. + // + Status = PeCoffLoaderRelocateImageEx (Reloc, Fixup, &FixupData, Adjust); + if (RETURN_ERROR (Status)) { + ImageContext->ImageError = IMAGE_ERROR_FAILED_RELOCATION; + return Status; + } + } + + // + // Next relocation record + // + Reloc += 1; + } + + // + // Next reloc block + // + RelocBase = (EFI_IMAGE_BASE_RELOCATION *) RelocEnd; + } + + return RETURN_SUCCESS; +} + +/** + Loads a PE/COFF image into memory. + + Loads the PE/COFF image accessed through the ImageRead service of ImageContext into the buffer + specified by the ImageAddress and ImageSize fields of ImageContext. The caller must allocate + the load buffer and fill in the ImageAddress and ImageSize fields prior to calling this function. + The EntryPoint, FixupDataSize, CodeView, and PdbPointer fields of ImageContext are computed. + If ImageContext is NULL, then ASSERT(). + + @param ImageContext Pointer to the image context structure that describes the PE/COFF + image that is being loaded. + + @retval RETURN_SUCCESS The PE/COFF image was loaded into the buffer specified by + the ImageAddress and ImageSize fields of ImageContext. + Extended status information is in the ImageError field of ImageContext. + @retval RETURN_BUFFER_TOO_SMALL The caller did not provide a large enough buffer. + Extended status information is in the ImageError field of ImageContext. + @retval RETURN_LOAD_ERROR The PE/COFF image is an EFI Runtime image with no relocations. + Extended status information is in the ImageError field of ImageContext. + @retval RETURN_INVALID_PARAMETER The image address is invalid. + Extended status information is in the ImageError field of ImageContext. + +**/ +RETURN_STATUS +EFIAPI +GluePeCoffLoaderLoadImage ( + IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext + ) +{ + RETURN_STATUS Status; + EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION Hdr; + PE_COFF_LOADER_IMAGE_CONTEXT CheckContext; + EFI_IMAGE_SECTION_HEADER *FirstSection; + EFI_IMAGE_SECTION_HEADER *Section; + UINTN NumberOfSections; + UINTN Index; + CHAR8 *Base; + CHAR8 *End; + CHAR8 *MaxEnd; + EFI_IMAGE_DATA_DIRECTORY *DirectoryEntry; + EFI_IMAGE_DEBUG_DIRECTORY_ENTRY *DebugEntry; + UINTN Size; + UINT32 TempDebugEntryRva; + UINT32 NumberOfRvaAndSizes; + UINT16 Magic; + + ASSERT (ImageContext != NULL); + + // + // Assume success + // + ImageContext->ImageError = IMAGE_ERROR_SUCCESS; + + // + // Copy the provided context info into our local version, get what we + // can from the original image, and then use that to make sure everything + // is legit. + // + CopyMem (&CheckContext, ImageContext, sizeof (PE_COFF_LOADER_IMAGE_CONTEXT)); + + Status = PeCoffLoaderGetImageInfo (&CheckContext); + if (RETURN_ERROR (Status)) { + return Status; + } + + // + // Make sure there is enough allocated space for the image being loaded + // + if (ImageContext->ImageSize < CheckContext.ImageSize) { + ImageContext->ImageError = IMAGE_ERROR_INVALID_IMAGE_SIZE; + return RETURN_BUFFER_TOO_SMALL; + } + if (ImageContext->ImageAddress == 0) { + // + // Image cannot be loaded into 0 address. + // + ImageContext->ImageError = IMAGE_ERROR_INVALID_IMAGE_ADDRESS; + return RETURN_INVALID_PARAMETER; + } + // + // If there's no relocations, then make sure it's not a runtime driver, + // and that it's being loaded at the linked address. + // + if (CheckContext.RelocationsStripped) { + // + // If the image does not contain relocations and it is a runtime driver + // then return an error. + // + if (CheckContext.ImageType == EFI_IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER) { + ImageContext->ImageError = IMAGE_ERROR_INVALID_SUBSYSTEM; + return RETURN_LOAD_ERROR; + } + // + // If the image does not contain relocations, and the requested load address + // is not the linked address, then return an error. + // + if (CheckContext.ImageAddress != ImageContext->ImageAddress) { + ImageContext->ImageError = IMAGE_ERROR_INVALID_IMAGE_ADDRESS; + return RETURN_INVALID_PARAMETER; + } + } + // + // Make sure the allocated space has the proper section alignment + // + if (!(ImageContext->IsTeImage)) { + if ((ImageContext->ImageAddress & (CheckContext.SectionAlignment - 1)) != 0) { + ImageContext->ImageError = IMAGE_ERROR_INVALID_SECTION_ALIGNMENT; + return RETURN_INVALID_PARAMETER; + } + } + // + // Read the entire PE/COFF or TE header into memory + // + if (!(ImageContext->IsTeImage)) { + Status = ImageContext->ImageRead ( + ImageContext->Handle, + 0, + &ImageContext->SizeOfHeaders, + (VOID *) (UINTN) ImageContext->ImageAddress + ); + + Hdr.Pe32 = (EFI_IMAGE_NT_HEADERS32 *)((UINTN)ImageContext->ImageAddress + ImageContext->PeCoffHeaderOffset); + + FirstSection = (EFI_IMAGE_SECTION_HEADER *) ( + (UINTN)ImageContext->ImageAddress + + ImageContext->PeCoffHeaderOffset + + sizeof(UINT32) + + sizeof(EFI_IMAGE_FILE_HEADER) + + Hdr.Pe32->FileHeader.SizeOfOptionalHeader + ); + NumberOfSections = (UINTN) (Hdr.Pe32->FileHeader.NumberOfSections); + } else { + Status = ImageContext->ImageRead ( + ImageContext->Handle, + 0, + &ImageContext->SizeOfHeaders, + (void *)(UINTN)ImageContext->ImageAddress + ); + + Hdr.Te = (EFI_TE_IMAGE_HEADER *)(UINTN)(ImageContext->ImageAddress); + + FirstSection = (EFI_IMAGE_SECTION_HEADER *) ( + (UINTN)ImageContext->ImageAddress + + sizeof(EFI_TE_IMAGE_HEADER) + ); + NumberOfSections = (UINTN) (Hdr.Te->NumberOfSections); + + } + + if (RETURN_ERROR (Status)) { + ImageContext->ImageError = IMAGE_ERROR_IMAGE_READ; + return RETURN_LOAD_ERROR; + } + + // + // Load each section of the image + // + Section = FirstSection; + for (Index = 0, MaxEnd = NULL; Index < NumberOfSections; Index++) { + + // + // Compute sections address + // + Base = PeCoffLoaderImageAddress (ImageContext, Section->VirtualAddress); + End = PeCoffLoaderImageAddress ( + ImageContext, + Section->VirtualAddress + Section->Misc.VirtualSize - 1 + ); + if (ImageContext->IsTeImage) { + Base = (CHAR8 *)((UINTN) Base + sizeof (EFI_TE_IMAGE_HEADER) - (UINTN)Hdr.Te->StrippedSize); + End = (CHAR8 *)((UINTN) End + sizeof (EFI_TE_IMAGE_HEADER) - (UINTN)Hdr.Te->StrippedSize); + } + + if (End > MaxEnd) { + MaxEnd = End; + } + // + // If the base start or end address resolved to 0, then fail. + // + if ((Base == NULL) || (End == NULL)) { + ImageContext->ImageError = IMAGE_ERROR_SECTION_NOT_LOADED; + return RETURN_LOAD_ERROR; + } + + // + // Read the section + // + Size = (UINTN) Section->Misc.VirtualSize; + if ((Size == 0) || (Size > Section->SizeOfRawData)) { + Size = (UINTN) Section->SizeOfRawData; + } + + if (Section->SizeOfRawData) { + if (!(ImageContext->IsTeImage)) { + Status = ImageContext->ImageRead ( + ImageContext->Handle, + Section->PointerToRawData, + &Size, + Base + ); + } else { + Status = ImageContext->ImageRead ( + ImageContext->Handle, + Section->PointerToRawData + sizeof (EFI_TE_IMAGE_HEADER) - (UINTN)Hdr.Te->StrippedSize, + &Size, + Base + ); + } + + if (RETURN_ERROR (Status)) { + ImageContext->ImageError = IMAGE_ERROR_IMAGE_READ; + return Status; + } + } + + // + // If raw size is less then virt size, zero fill the remaining + // + + if (Size < Section->Misc.VirtualSize) { + ZeroMem (Base + Size, Section->Misc.VirtualSize - Size); + } + + // + // Next Section + // + Section += 1; + } + + // + // Get image's entry point + // + Magic = PeCoffLoaderGetPeHeaderMagicValue (Hdr); + if (!(ImageContext->IsTeImage)) { + // + // Sizes of AddressOfEntryPoint are different so we need to do this safely + // + if (Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) { + // + // Use PE32 offset + // + ImageContext->EntryPoint = (PHYSICAL_ADDRESS)(UINTN)PeCoffLoaderImageAddress ( + ImageContext, + (UINTN)Hdr.Pe32->OptionalHeader.AddressOfEntryPoint + ); + } else { + // + // Use PE32+ offset + // + ImageContext->EntryPoint = (PHYSICAL_ADDRESS)(UINTN)PeCoffLoaderImageAddress ( + ImageContext, + (UINTN)Hdr.Pe32Plus->OptionalHeader.AddressOfEntryPoint + ); + } + } else { + ImageContext->EntryPoint = (PHYSICAL_ADDRESS) ( + (UINTN)ImageContext->ImageAddress + + (UINTN)Hdr.Te->AddressOfEntryPoint + + (UINTN)sizeof(EFI_TE_IMAGE_HEADER) - + (UINTN)Hdr.Te->StrippedSize + ); + } + + // + // Determine the size of the fixup data + // + // Per the PE/COFF spec, you can't assume that a given data directory + // is present in the image. You have to check the NumberOfRvaAndSizes in + // the optional header to verify a desired directory entry is there. + // + if (!(ImageContext->IsTeImage)) { + if (Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) { + // + // Use PE32 offset + // + NumberOfRvaAndSizes = Hdr.Pe32->OptionalHeader.NumberOfRvaAndSizes; + DirectoryEntry = (EFI_IMAGE_DATA_DIRECTORY *)&Hdr.Pe32->OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC]; + } else { + // + // Use PE32+ offset + // + NumberOfRvaAndSizes = Hdr.Pe32Plus->OptionalHeader.NumberOfRvaAndSizes; + DirectoryEntry = (EFI_IMAGE_DATA_DIRECTORY *)&Hdr.Pe32Plus->OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC]; + } + + if (NumberOfRvaAndSizes > EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC) { + ImageContext->FixupDataSize = DirectoryEntry->Size / sizeof (UINT16) * sizeof (UINTN); + } else { + ImageContext->FixupDataSize = 0; + } + } else { + DirectoryEntry = &Hdr.Te->DataDirectory[0]; + ImageContext->FixupDataSize = DirectoryEntry->Size / sizeof (UINT16) * sizeof (UINTN); + } + // + // Consumer must allocate a buffer for the relocation fixup log. + // Only used for runtime drivers. + // + ImageContext->FixupData = NULL; + + // + // Load the Codeview info if present + // + if (ImageContext->DebugDirectoryEntryRva != 0) { + if (!(ImageContext->IsTeImage)) { + DebugEntry = PeCoffLoaderImageAddress ( + ImageContext, + ImageContext->DebugDirectoryEntryRva + ); + } else { + DebugEntry = (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY *)(UINTN)( + ImageContext->ImageAddress + + ImageContext->DebugDirectoryEntryRva + + sizeof(EFI_TE_IMAGE_HEADER) - + Hdr.Te->StrippedSize + ); + } + + if (DebugEntry != NULL) { + TempDebugEntryRva = DebugEntry->RVA; + if (DebugEntry->RVA == 0 && DebugEntry->FileOffset != 0) { + Section--; + if ((UINTN)Section->SizeOfRawData < Section->Misc.VirtualSize) { + TempDebugEntryRva = Section->VirtualAddress + Section->Misc.VirtualSize; + } else { + TempDebugEntryRva = Section->VirtualAddress + Section->SizeOfRawData; + } + } + + if (TempDebugEntryRva != 0) { + if (!(ImageContext->IsTeImage)) { + ImageContext->CodeView = PeCoffLoaderImageAddress (ImageContext, TempDebugEntryRva); + } else { + ImageContext->CodeView = (VOID *)( + (UINTN)ImageContext->ImageAddress + + (UINTN)TempDebugEntryRva + + (UINTN)sizeof (EFI_TE_IMAGE_HEADER) - + (UINTN) Hdr.Te->StrippedSize + ); + } + + if (ImageContext->CodeView == NULL) { + ImageContext->ImageError = IMAGE_ERROR_IMAGE_READ; + return RETURN_LOAD_ERROR; + } + + if (DebugEntry->RVA == 0) { + Size = DebugEntry->SizeOfData; + if (!(ImageContext->IsTeImage)) { + Status = ImageContext->ImageRead ( + ImageContext->Handle, + DebugEntry->FileOffset, + &Size, + ImageContext->CodeView + ); + } else { + Status = ImageContext->ImageRead ( + ImageContext->Handle, + DebugEntry->FileOffset + sizeof (EFI_TE_IMAGE_HEADER) - Hdr.Te->StrippedSize, + &Size, + ImageContext->CodeView + ); + // + // Should we apply fix up to this field according to the size difference between PE and TE? + // Because now we maintain TE header fields unfixed, this field will also remain as they are + // in original PE image. + // + } + + if (RETURN_ERROR (Status)) { + ImageContext->ImageError = IMAGE_ERROR_IMAGE_READ; + return RETURN_LOAD_ERROR; + } + + DebugEntry->RVA = TempDebugEntryRva; + } + + switch (*(UINT32 *) ImageContext->CodeView) { + case CODEVIEW_SIGNATURE_NB10: + ImageContext->PdbPointer = (CHAR8 *)ImageContext->CodeView + sizeof (EFI_IMAGE_DEBUG_CODEVIEW_NB10_ENTRY); + break; + + case CODEVIEW_SIGNATURE_RSDS: + ImageContext->PdbPointer = (CHAR8 *)ImageContext->CodeView + sizeof (EFI_IMAGE_DEBUG_CODEVIEW_RSDS_ENTRY); + break; + + default: + break; + } + } + } + } + + return Status; +} + + +/** + Reapply fixups on a fixed up PE32/PE32+ image to allow virutal calling at EFI + runtime. + + PE_COFF_LOADER_IMAGE_CONTEXT.FixupData stores information needed to reapply + the fixups with a virtual mapping. + + + @param ImageBase Base address of relocated image + @param VirtImageBase Virtual mapping for ImageBase + @param ImageSize Size of the image to relocate + @param RelocationData Location to place results of read + +**/ +VOID +EFIAPI +PeCoffLoaderRelocateImageForRuntime ( + IN PHYSICAL_ADDRESS ImageBase, + IN PHYSICAL_ADDRESS VirtImageBase, + IN UINTN ImageSize, + IN VOID *RelocationData + ) +{ + CHAR8 *OldBase; + CHAR8 *NewBase; + EFI_IMAGE_DOS_HEADER *DosHdr; + EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION Hdr; + UINT32 NumberOfRvaAndSizes; + EFI_IMAGE_DATA_DIRECTORY *DataDirectory; + EFI_IMAGE_DATA_DIRECTORY *RelocDir; + EFI_IMAGE_BASE_RELOCATION *RelocBase; + EFI_IMAGE_BASE_RELOCATION *RelocBaseEnd; + UINT16 *Reloc; + UINT16 *RelocEnd; + CHAR8 *Fixup; + CHAR8 *FixupBase; + UINT16 *F16; + UINT32 *F32; + UINT64 *F64; + CHAR8 *FixupData; + UINTN Adjust; + RETURN_STATUS Status; + UINT16 Magic; + + OldBase = (CHAR8 *)((UINTN)ImageBase); + NewBase = (CHAR8 *)((UINTN)VirtImageBase); + Adjust = (UINTN) NewBase - (UINTN) OldBase; + + // + // Find the image's relocate dir info + // + DosHdr = (EFI_IMAGE_DOS_HEADER *)OldBase; + if (DosHdr->e_magic == EFI_IMAGE_DOS_SIGNATURE) { + // + // Valid DOS header so get address of PE header + // + Hdr.Pe32 = (EFI_IMAGE_NT_HEADERS32 *)(((CHAR8 *)DosHdr) + DosHdr->e_lfanew); + } else { + // + // No Dos header so assume image starts with PE header. + // + Hdr.Pe32 = (EFI_IMAGE_NT_HEADERS32 *)OldBase; + } + + if (Hdr.Pe32->Signature != EFI_IMAGE_NT_SIGNATURE) { + // + // Not a valid PE image so Exit + // + return ; + } + + Magic = PeCoffLoaderGetPeHeaderMagicValue (Hdr); + + if (Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) { + // + // Use PE32 offset + // + NumberOfRvaAndSizes = Hdr.Pe32->OptionalHeader.NumberOfRvaAndSizes; + DataDirectory = (EFI_IMAGE_DATA_DIRECTORY *)&(Hdr.Pe32->OptionalHeader.DataDirectory[0]); + } else { + // + // Use PE32+ offset + // + NumberOfRvaAndSizes = Hdr.Pe32Plus->OptionalHeader.NumberOfRvaAndSizes; + DataDirectory = (EFI_IMAGE_DATA_DIRECTORY *)&(Hdr.Pe32Plus->OptionalHeader.DataDirectory[0]); + } + + // + // Find the relocation block + // + // Per the PE/COFF spec, you can't assume that a given data directory + // is present in the image. You have to check the NumberOfRvaAndSizes in + // the optional header to verify a desired directory entry is there. + // + if (NumberOfRvaAndSizes > EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC) { + RelocDir = DataDirectory + EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC; + RelocBase = (EFI_IMAGE_BASE_RELOCATION *)(UINTN)(ImageBase + RelocDir->VirtualAddress); + RelocBaseEnd = (EFI_IMAGE_BASE_RELOCATION *)(UINTN)(ImageBase + RelocDir->VirtualAddress + RelocDir->Size); + } else { + // + // Cannot find relocations, cannot continue + // + ASSERT (FALSE); + return ; + } + + ASSERT (RelocBase != NULL && RelocBaseEnd != NULL); + + // + // Run the whole relocation block. And re-fixup data that has not been + // modified. The FixupData is used to see if the image has been modified + // since it was relocated. This is so data sections that have been updated + // by code will not be fixed up, since that would set them back to + // defaults. + // + FixupData = RelocationData; + while (RelocBase < RelocBaseEnd) { + + Reloc = (UINT16 *) ((UINT8 *) RelocBase + sizeof (EFI_IMAGE_BASE_RELOCATION)); + RelocEnd = (UINT16 *) ((UINT8 *) RelocBase + RelocBase->SizeOfBlock); + FixupBase = (CHAR8 *) ((UINTN)ImageBase) + RelocBase->VirtualAddress; + + // + // Run this relocation record + // + while (Reloc < RelocEnd) { + + Fixup = FixupBase + (*Reloc & 0xFFF); + switch ((*Reloc) >> 12) { + + case EFI_IMAGE_REL_BASED_ABSOLUTE: + break; + + case EFI_IMAGE_REL_BASED_HIGH: + F16 = (UINT16 *) Fixup; + if (*(UINT16 *) FixupData == *F16) { + *F16 = (UINT16) (*F16 + ((UINT16) ((UINT32) Adjust >> 16))); + } + + FixupData = FixupData + sizeof (UINT16); + break; + + case EFI_IMAGE_REL_BASED_LOW: + F16 = (UINT16 *) Fixup; + if (*(UINT16 *) FixupData == *F16) { + *F16 = (UINT16) (*F16 + ((UINT16) Adjust & 0xffff)); + } + + FixupData = FixupData + sizeof (UINT16); + break; + + case EFI_IMAGE_REL_BASED_HIGHLOW: + F32 = (UINT32 *) Fixup; + FixupData = ALIGN_POINTER (FixupData, sizeof (UINT32)); + if (*(UINT32 *) FixupData == *F32) { + *F32 = *F32 + (UINT32) Adjust; + } + + FixupData = FixupData + sizeof (UINT32); + break; + + case EFI_IMAGE_REL_BASED_DIR64: + F64 = (UINT64 *)Fixup; + FixupData = ALIGN_POINTER (FixupData, sizeof (UINT64)); + if (*(UINT64 *) FixupData == *F64) { + *F64 = *F64 + (UINT64)Adjust; + } + + FixupData = FixupData + sizeof (UINT64); + break; + + case EFI_IMAGE_REL_BASED_HIGHADJ: + // + // Not implemented, but not used in EFI 1.0 + // + ASSERT (FALSE); + break; + + default: + // + // Only Itanium requires ConvertPeImage_Ex + // + Status = PeHotRelocateImageEx (Reloc, Fixup, &FixupData, Adjust); + if (RETURN_ERROR (Status)) { + return ; + } + } + // + // Next relocation record + // + Reloc += 1; + } + // + // next reloc block + // + RelocBase = (EFI_IMAGE_BASE_RELOCATION *) RelocEnd; + } +} + + +/** + ImageRead function that operates on a memory buffer whos base is passed into + FileHandle. + + @param FileHandle Ponter to baes of the input stream + @param FileOffset Offset to the start of the buffer + @param ReadSize Number of bytes to copy into the buffer + @param Buffer Location to place results of read + + @retval RETURN_SUCCESS Data is read from FileOffset from the Handle into + the buffer. +**/ +RETURN_STATUS +EFIAPI +PeCoffLoaderImageReadFromMemory ( + IN VOID *FileHandle, + IN UINTN FileOffset, + IN OUT UINTN *ReadSize, + OUT VOID *Buffer + ) +{ + CopyMem (Buffer, ((UINT8 *)FileHandle) + FileOffset, *ReadSize); + return RETURN_SUCCESS; +} + diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffLib/BasePeCoffLib.inf b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffLib/BasePeCoffLib.inf new file mode 100644 index 0000000..cca4a8c --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffLib/BasePeCoffLib.inf @@ -0,0 +1,81 @@ +#/*++ +# +# 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: +# +# BasePeCoffLib.inf +# +# Abstract: +# +# Component description file for BasePeCoffLib. +# +#--*/ + +[defines] +BASE_NAME = EdkIIGlueBasePeCoffLib +COMPONENT_TYPE = LIBRARY + +[sources.common] + BasePeCoff.c + +[sources.ia32] + Ia32\PeCoffLoaderEx.c + +[sources.x64] + X64\PeCoffLoaderEx.c + +[sources.ipf] + + +[sources.ebc] + + +[includes.common] + . + ..\..\Include + ..\..\include\Library + $(EDK_SOURCE)\Foundation + $(EDK_SOURCE)\Foundation\Framework + $(EDK_SOURCE)\Foundation\Efi + $(EDK_SOURCE)\Foundation\Include + $(EDK_SOURCE)\Foundation\Efi\Include + $(EDK_SOURCE)\Foundation\Framework\Include + $(EDK_SOURCE)\Foundation\Include\IndustryStandard + $(EDK_SOURCE)\Foundation\Core\Dxe + $(EDK_SOURCE)\Foundation\Library\Dxe\Include + $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include + $(EDK_SOURCE)\Foundation\Guid\PeiPeCoffLoader + + +[libraries.common] + EdkIIGlueBaseMemoryLib + +[libraries.ia32] + + +[libraries.x64] + + +[nmake.common] + C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION + LIB_STD_FLAGS = /NOLOGO /IGNORE:4006 + +[nmake.ia32] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32 + +[nmake.x64] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64 + +[nmake.ipf] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF + +[nmake.ebc] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_EBC
\ No newline at end of file diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffLib/BasePeCoffLibInternals.h b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffLib/BasePeCoffLibInternals.h new file mode 100644 index 0000000..5c7d18c --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffLib/BasePeCoffLibInternals.h @@ -0,0 +1,131 @@ +/*++ + +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: + + BasePeCoffLibInternals.h + +Abstract: + + Header file for Base PeCoff Library + +--*/ + +#ifndef __BASE_PECOFF_LIB_INTERNALS__ +#define __BASE_PECOFF_LIB_INTERNALS__ + +#include "EdkIIGlueBase.h" + +/** + Performs an Itanium-based specific relocation fixup and is a no-op on other + instruction sets. + + @param Reloc Pointer to the relocation record. + @param Fixup Pointer to the address to fix up. + @param FixupData Pointer to a buffer to log the fixups. + @param Adjust The offset to adjust the fixup. + + @return Status code. + +**/ +RETURN_STATUS +GluePeCoffLoaderRelocateImageEx ( + IN UINT16 *Reloc, + IN OUT CHAR8 *Fixup, + IN OUT CHAR8 **FixupData, + IN UINT64 Adjust + ); + + +/** + Performs an Itanium-based specific re-relocation fixup and is a no-op on other + instruction sets. This is used to re-relocated the image into the EFI virtual + space for runtime calls. + + @param Reloc Pointer to the relocation record. + @param Fixup Pointer to the address to fix up. + @param FixupData Pointer to a buffer to log the fixups. + @param Adjust The offset to adjust the fixup. + + @return Status code. + +**/ +RETURN_STATUS +GluePeHotRelocateImageEx ( + IN UINT16 *Reloc, + IN OUT CHAR8 *Fixup, + IN OUT CHAR8 **FixupData, + IN UINT64 Adjust + ); + + +/** + Returns TRUE if the machine type of PE/COFF image is supported. Supported + does not mean the image can be executed it means the PE/COFF loader supports + loading and relocating of the image type. It's up to the caller to support + the entry point. + + @param Machine Machine type from the PE Header. + + @return TRUE if this PE/COFF loader can load the image + +**/ +BOOLEAN +PeCoffLoaderImageFormatSupported ( + IN UINT16 Machine + ); + +/** + Retrieves the magic value from the PE/COFF header. + + @param Hdr The buffer in which to return the PE32, PE32+, or TE header. + + @return EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC - Image is PE32 + @return EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC - Image is PE32+ + +**/ +UINT16 +PeCoffLoaderGetPeHeaderMagicValue ( + IN EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION Hdr + ); + +/** + Retrieves the PE or TE Header from a PE/COFF or TE image. + + @param ImageContext The context of the image being loaded. + @param Hdr The buffer in which to return the PE32, PE32+, or TE header. + + @retval RETURN_SUCCESS The PE or TE Header is read. + @retval Other The error status from reading the PE/COFF or TE image using the ImageRead function. + +**/ +RETURN_STATUS +PeCoffLoaderGetPeHeader ( + IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext, + OUT EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION Hdr + ); + +/** + Converts an image address to the loaded address. + + @param ImageContext The context of the image being loaded. + @param Address The address to be converted to the loaded address. + + @return The converted address or NULL if the address can not be converted. + +**/ +VOID * +PeCoffLoaderImageAddress ( + IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext, + IN UINTN Address + ); + +#endif diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffLib/EdkIIGlueBasePeCoffLib.cif b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffLib/EdkIIGlueBasePeCoffLib.cif new file mode 100644 index 0000000..7803f70 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffLib/EdkIIGlueBasePeCoffLib.cif @@ -0,0 +1,14 @@ +<component> + name = "EdkIIGlueBasePeCoffLib" + category = ModulePart + LocalRoot = "Edk\Foundation\Library\EdkIIGlueLib\Library\BasePeCoffLib" + RefName = "EdkIIGlueBasePeCoffLib" +[files] +"EdkIIGlueBasePeCoffLib.sdl" +"EdkIIGlueBasePeCoffLib.mak" +"BasePeCoffLib.inf" +"BasePeCoff.c" +"BasePeCoffLibInternals.h" +"Ia32\PeCoffLoaderEx.c" +"X64\PeCoffLoaderEx.c" +<endComponent> diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffLib/EdkIIGlueBasePeCoffLib.mak b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffLib/EdkIIGlueBasePeCoffLib.mak new file mode 100644 index 0000000..9888fe0 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffLib/EdkIIGlueBasePeCoffLib.mak @@ -0,0 +1,100 @@ +#********************************************************************** +#********************************************************************** +#** ** +#** (C)Copyright 1985-2009, American Megatrends, Inc. ** +#** ** +#** All Rights Reserved. ** +#** ** +#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +#** ** +#** Phone: (770)-246-8600 ** +#** ** +#********************************************************************** +#********************************************************************** + +#********************************************************************** +# $Header: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGlueBasePeCoffLib/EdkIIGlueBasePeCoffLib.mak 1 1/20/12 3:54a Jeffch $ +# +# $Revision: 1 $ +# +# $Date: 1/20/12 3:54a $ +#********************************************************************** +# Revision History +# ---------------- +# $Log: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGlueBasePeCoffLib/EdkIIGlueBasePeCoffLib.mak $ +# +# 1 1/20/12 3:54a Jeffch +# Create Intel EDK 1117 Patch 7. +# +# 1 9/27/11 6:16a Wesleychen +# Intel EDK initially releases. +# +# 1 9/18/09 1:52a Iminglin +# +#********************************************************************** +#<AMI_FHDR_START> +# +# Name: EdkIIGlueBasePeCoffLib.mak +# +# Description: +# +#<AMI_FHDR_END> +#********************************************************************** + + +EdkIIGlueBasePeCoffLib_OBJECTS=\ +$$(BUILD_DIR)\$(EdkIIGlueBasePeCoffLib_DIR)\BasePeCoff.obj + +EdkIIGlueBasePeCoffLib_IA32_OBJECTS=\ +$$(BUILD_DIR)\$(EdkIIGlueBasePeCoffLib_DIR)\Ia32\PeCoffLoaderEx.obj + +!IF "$(PROCESSOR)"=="IA32" +EdkIIGlueBasePeCoffLib_OBJECTS =$(EdkIIGlueBasePeCoffLib_OBJECTS) $(EdkIIGlueBasePeCoffLib_IA32_OBJECTS) +!ELSEIF "$(PROCESSOR)"=="x64" +EdkIIGlueBasePeCoffLib_PEI_OBJECTS =$(EdkIIGlueBasePeCoffLib_OBJECTS) $(EdkIIGlueBasePeCoffLib_IA32_OBJECTS) +EdkIIGlueBasePeCoffLib_DXE_OBJECTS =$(EdkIIGlueBasePeCoffLib_OBJECTS)\ +$$(BUILD_DIR)\$(EdkIIGlueBasePeCoffLib_DIR)\X64\PeCoffLoaderEx.obj +!ENDIF + +$(EdkIIGlueBasePeCoffLib_LIB) : EdkIIGlueBasePeCoffLib + +EdkIIGlueBasePeCoffLib : $(BUILD_DIR)\EdkIIGlueBasePeCoffLib.mak EdkIIGlueBasePeCoffLibBin + +$(BUILD_DIR)\EdkIIGlueBasePeCoffLib.mak : $(EdkIIGlueBasePeCoffLib_DIR)\$(@B).cif $(EdkIIGlueBasePeCoffLib_DIR)\$(@B).mak $(BUILD_RULES) + $(CIF2MAK) $(EdkIIGlueBasePeCoffLib_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS) + +EdkIIGlueBasePeCoffLibBin : $(EdkIIGlueBaseMemoryLib_LIB) +!IF "$(x64_BUILD)"=="1" + $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\ + BUILD_DIR=$(BUILD_DIR)\ + /f $(BUILD_DIR)\EdkIIGlueBasePeCoffLib.mak all\ + "MY_INCLUDES=/I$(EdkIIGlueBasePeCoffLib_DIR)"\ + TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueBasePeCoffLib_LIB)"\ + "OBJECTS=$(EdkIIGlueBasePeCoffLib_DXE_OBJECTS)" + $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\ + BUILD_DIR=$(BUILD_DIR)\IA32\ + /f $(BUILD_DIR)\EdkIIGlueBasePeCoffLib.mak all\ + "MY_INCLUDES=/I$(EdkIIGlueBasePeCoffLib_DIR)"\ + TYPE=PEI_LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueBasePeCoffLib_LIB)"\ + "OBJECTS=$(EdkIIGlueBasePeCoffLib_PEI_OBJECTS)" +!ELSE + $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\ + BUILD_DIR=$(BUILD_DIR)\ + /f $(BUILD_DIR)\EdkIIGlueBasePeCoffLib.mak all\ + "MY_INCLUDES=/I$(EdkIIGlueBasePeCoffLib_DIR)"\ + TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueBasePeCoffLib_LIB)"\ + "OBJECTS=$(EdkIIGlueBasePeCoffLib_OBJECTS)" +!ENDIF +#********************************************************************** +#********************************************************************** +#** ** +#** (C)Copyright 1985-2009, American Megatrends, Inc. ** +#** ** +#** All Rights Reserved. ** +#** ** +#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +#** ** +#** Phone: (770)-246-8600 ** +#** ** +#********************************************************************** +#********************************************************************** diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffLib/EdkIIGlueBasePeCoffLib.sdl b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffLib/EdkIIGlueBasePeCoffLib.sdl new file mode 100644 index 0000000..13901f4 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffLib/EdkIIGlueBasePeCoffLib.sdl @@ -0,0 +1,26 @@ +TOKEN + Name = "EdkIIGlueBasePeCoffLib_SUPPORT" + Value = "1" + Help = "Main switch to enable EdkIIGlueBasePeCoffLib support in Project" + TokenType = Boolean + TargetEQU = Yes + TargetMAK = Yes + Master = Yes +End + +TOKEN + Name = "EdkIIGlueBasePeCoffLib_LIB" + Value = "$$(LIB_BUILD_DIR)\EdkIIGlueBasePeCoffLib.lib" + TokenType = Expression + TargetMAK = Yes +End + +PATH + Name = "EdkIIGlueBasePeCoffLib_DIR" +End + +MODULE + Help = "Includes EdkIIGlueBasePeCoffLib.mak to Project" + File = "EdkIIGlueBasePeCoffLib.mak" +End + diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffLib/Ia32/PeCoffLoaderEx.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffLib/Ia32/PeCoffLoaderEx.c new file mode 100644 index 0000000..245d9e9 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffLib/Ia32/PeCoffLoaderEx.c @@ -0,0 +1,98 @@ +/*++ + +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: + + PeCoffLoaderEx.c + +Abstract: + + IA-32 Specific relocation fixups. + +--*/ + +#include "EdkIIGlueBase.h" + +/** + Performs an IA-32 specific relocation fixup. + + @param Reloc Pointer to the relocation record. + @param Fixup Pointer to the address to fix up. + @param FixupData Pointer to a buffer to log the fixups. + @param Adjust The offset to adjust the fixup. + + @retval EFI_UNSUPPORTED Unsupported now. + +**/ +RETURN_STATUS +GluePeCoffLoaderRelocateImageEx ( + IN UINT16 *Reloc, + IN OUT CHAR8 *Fixup, + IN OUT CHAR8 **FixupData, + IN UINT64 Adjust + ) +{ + return RETURN_UNSUPPORTED; +} + +/** + Returns TRUE if the machine type of PE/COFF image is supported. Supported + does not mean the image can be executed it means the PE/COFF loader supports + loading and relocating of the image type. It's up to the caller to support + the entry point. + + This function implies the basic PE/COFF loader/relocator supports IA32, EBC, + & X64 images. Calling the entry point in a correct mannor is up to the + consumer of this library. + + @param Machine Machine type from the PE Header. + + @return TRUE if this PE/COFF loader can load the image + +**/ +BOOLEAN +PeCoffLoaderImageFormatSupported ( + IN UINT16 Machine + ) +{ + if ((Machine == EFI_IMAGE_MACHINE_IA32) || (Machine == EFI_IMAGE_MACHINE_X64) || + (Machine == EFI_IMAGE_MACHINE_EBC)) { + return TRUE; + } + + return FALSE; +} + +/** + Performs an Itanium-based specific re-relocation fixup and is a no-op on other + instruction sets. This is used to re-relocated the image into the EFI virtual + space for runtime calls. + + @param Reloc Pointer to the relocation record. + @param Fixup Pointer to the address to fix up. + @param FixupData Pointer to a buffer to log the fixups. + @param Adjust The offset to adjust the fixup. + + @return Status code. + +**/ +RETURN_STATUS +GluePeHotRelocateImageEx ( + IN UINT16 *Reloc, + IN OUT CHAR8 *Fixup, + IN OUT CHAR8 **FixupData, + IN UINT64 Adjust + ) +{ + return RETURN_UNSUPPORTED; +} + diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffLib/X64/PeCoffLoaderEx.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffLib/X64/PeCoffLoaderEx.c new file mode 100644 index 0000000..6a17a51 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffLib/X64/PeCoffLoaderEx.c @@ -0,0 +1,97 @@ +/*++ + +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: + + PeCoffLoaderEx.c + +Abstract: + + x64 Specific relocation fixups. + +--*/ + +#include "EdkIIGlueBase.h" + + +/** + Performs an x64 specific relocation fixup. + + @param Reloc Pointer to the relocation record + @param Fixup Pointer to the address to fix up + @param FixupData Pointer to a buffer to log the fixups + @param Adjust The offset to adjust the fixup + +**/ +RETURN_STATUS +GluePeCoffLoaderRelocateImageEx ( + IN UINT16 *Reloc, + IN OUT CHAR8 *Fixup, + IN OUT CHAR8 **FixupData, + IN UINT64 Adjust + ) +{ + return RETURN_UNSUPPORTED; +} + +/** + Returns TRUE if the machine type of PE/COFF image is supported. Supported + does not mean the image can be executed it means the PE/COFF loader supports + loading and relocating of the image type. It's up to the caller to support + the entry point. + + This function implies the basic PE/COFF loader/relocator supports IA32, EBC, + & X64 images. Calling the entry point in a correct mannor is up to the + consumer of this library. + + @param Machine Machine type from the PE Header. + + @return TRUE if this PE/COFF loader can load the image + +**/ +BOOLEAN +PeCoffLoaderImageFormatSupported ( + IN UINT16 Machine + ) +{ + if ((Machine == EFI_IMAGE_MACHINE_IA32) || (Machine == EFI_IMAGE_MACHINE_X64) || + (Machine == EFI_IMAGE_MACHINE_EBC)) { + return TRUE; + } + + return FALSE; +} + + +/** + Performs an Itanium-based specific re-relocation fixup and is a no-op on other + instruction sets. This is used to re-relocated the image into the EFI virtual + space for runtime calls. + + @param Reloc Pointer to the relocation record. + @param Fixup Pointer to the address to fix up. + @param FixupData Pointer to a buffer to log the fixups. + @param Adjust The offset to adjust the fixup. + + @return Status code. + +**/ +RETURN_STATUS +GluePeHotRelocateImageEx ( + IN UINT16 *Reloc, + IN OUT CHAR8 *Fixup, + IN OUT CHAR8 **FixupData, + IN UINT64 Adjust + ) +{ + return RETURN_UNSUPPORTED; +} diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePostCodeLibDebug/BasePostCodeLibDebug.inf b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePostCodeLibDebug/BasePostCodeLibDebug.inf new file mode 100644 index 0000000..7e5a618 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePostCodeLibDebug/BasePostCodeLibDebug.inf @@ -0,0 +1,79 @@ +#/*++ +# +# 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: +# +# BasePostCodeLibDebug.inf +# +# Abstract: +# +# Component description file for BasePostCodeLibDebug +# +#--*/ + +[defines] +BASE_NAME = EdkIIGlueBasePostCodeLibDebug +COMPONENT_TYPE = LIBRARY + +[sources.common] + PostCode.c + +[sources.ia32] + +[sources.x64] + +[sources.ipf] + + +[sources.ebc] + + +[includes.common] + . + ..\..\Include + ..\..\include\Library + $(EDK_SOURCE)\Foundation + $(EDK_SOURCE)\Foundation\Framework + $(EDK_SOURCE)\Foundation\Efi + $(EDK_SOURCE)\Foundation\Include + $(EDK_SOURCE)\Foundation\Efi\Include + $(EDK_SOURCE)\Foundation\Framework\Include + $(EDK_SOURCE)\Foundation\Include\IndustryStandard + $(EDK_SOURCE)\Foundation\Core\Dxe + $(EDK_SOURCE)\Foundation\Library\Dxe\Include + $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include + $(EDK_SOURCE)\Foundation\Guid\PeiPeCoffLoader + + +[libraries.common] +# A DebugLib instance + +[libraries.ia32] + + +[libraries.x64] + + +[nmake.common] + C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION + LIB_STD_FLAGS = /NOLOGO /IGNORE:4006 + +[nmake.ia32] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32 + +[nmake.x64] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64 + +[nmake.ipf] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF + +[nmake.ebc] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_EBC
\ No newline at end of file diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePostCodeLibDebug/EdkIIGlueBasePostCodeLibDebug.cif b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePostCodeLibDebug/EdkIIGlueBasePostCodeLibDebug.cif new file mode 100644 index 0000000..3022ef5 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePostCodeLibDebug/EdkIIGlueBasePostCodeLibDebug.cif @@ -0,0 +1,11 @@ +<component> + name = "EdkIIGlueBasePostCodeLibDebug" + category = ModulePart + LocalRoot = "Edk\Foundation\Library\EdkIIGlueLib\Library\BasePostCodeLibDebug" + RefName = "EdkIIGlueBasePostCodeLibDebug" +[files] +"EdkIIGlueBasePostCodeLibDebug.sdl" +"EdkIIGlueBasePostCodeLibDebug.mak" +"BasePostCodeLibDebug.inf" +"PostCode.c" +<endComponent> diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePostCodeLibDebug/EdkIIGlueBasePostCodeLibDebug.mak b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePostCodeLibDebug/EdkIIGlueBasePostCodeLibDebug.mak new file mode 100644 index 0000000..305b8e1 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePostCodeLibDebug/EdkIIGlueBasePostCodeLibDebug.mak @@ -0,0 +1,80 @@ +#********************************************************************** +#********************************************************************** +#** ** +#** (C)Copyright 1985-2009, American Megatrends, Inc. ** +#** ** +#** All Rights Reserved. ** +#** ** +#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +#** ** +#** Phone: (770)-246-8600 ** +#** ** +#********************************************************************** +#********************************************************************** + +#********************************************************************** +# $Header: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGlueBasePostCodeLibDebug/EdkIIGlueBasePostCodeLibDebug.mak 1 1/20/12 3:54a Jeffch $ +# +# $Revision: 1 $ +# +# $Date: 1/20/12 3:54a $ +#********************************************************************** +# Revision History +# ---------------- +# $Log: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGlueBasePostCodeLibDebug/EdkIIGlueBasePostCodeLibDebug.mak $ +# +# 1 1/20/12 3:54a Jeffch +# Create Intel EDK 1117 Patch 7. +# +# 1 9/27/11 6:16a Wesleychen +# Intel EDK initially releases. +# +# 1 9/18/09 1:53a Iminglin +# +#********************************************************************** +#<AMI_FHDR_START> +# +# Name: EdkIIGlueBasePostCodeLibDebug.mak +# +# Description: +# +#<AMI_FHDR_END> +#********************************************************************** + + +$(EdkIIGlueBasePostCodeLibDebug_LIB) : EdkIIGlueBasePostCodeLibDebug + +EdkIIGlueBasePostCodeLibDebug : $(BUILD_DIR)\EdkIIGlueBasePostCodeLibDebug.mak EdkIIGlueBasePostCodeLibDebugBin + +$(BUILD_DIR)\EdkIIGlueBasePostCodeLibDebug.mak : $(EdkIIGlueBasePostCodeLibDebug_DIR)\$(@B).cif $(EdkIIGlueBasePostCodeLibDebug_DIR)\$(@B).mak $(BUILD_RULES) + $(CIF2MAK) $(EdkIIGlueBasePostCodeLibDebug_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS) + +EdkIIGlueBasePostCodeLibDebugBin : +!IF "$(x64_BUILD)"=="1" + $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\ + BUILD_DIR=$(BUILD_DIR)\ + /f $(BUILD_DIR)\EdkIIGlueBasePostCodeLibDebug.mak all\ + TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueBasePostCodeLibDebug_LIB)" + $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\ + BUILD_DIR=$(BUILD_DIR)\IA32\ + /f $(BUILD_DIR)\EdkIIGlueBasePostCodeLibDebug.mak all\ + TYPE=PEI_LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueBasePostCodeLibDebug_LIB)" +!ELSE + $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\ + BUILD_DIR=$(BUILD_DIR)\ + /f $(BUILD_DIR)\EdkIIGlueBasePostCodeLibDebug.mak all\ + TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueBasePostCodeLibDebug_LIB)" +!ENDIF +#********************************************************************** +#********************************************************************** +#** ** +#** (C)Copyright 1985-2009, American Megatrends, Inc. ** +#** ** +#** All Rights Reserved. ** +#** ** +#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +#** ** +#** Phone: (770)-246-8600 ** +#** ** +#********************************************************************** +#**********************************************************************
\ No newline at end of file diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePostCodeLibDebug/EdkIIGlueBasePostCodeLibDebug.sdl b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePostCodeLibDebug/EdkIIGlueBasePostCodeLibDebug.sdl new file mode 100644 index 0000000..82ebae4 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePostCodeLibDebug/EdkIIGlueBasePostCodeLibDebug.sdl @@ -0,0 +1,26 @@ +TOKEN + Name = "EdkIIGlueBasePostCodeLibDebug_SUPPORT" + Value = "1" + Help = "Main switch to enable EdkIIGlueBasePostCodeLibDebug support in Project" + TokenType = Boolean + TargetEQU = Yes + TargetMAK = Yes + Master = Yes +End + +TOKEN + Name = "EdkIIGlueBasePostCodeLibDebug_LIB" + Value = "$$(LIB_BUILD_DIR)\EdkIIGlueBasePostCodeLibDebug.lib" + TokenType = Expression + TargetMAK = Yes +End + +PATH + Name = "EdkIIGlueBasePostCodeLibDebug_DIR" +End + +MODULE + Help = "Includes EdkIIGlueBasePostCodeLibDebug.mak to Project" + File = "EdkIIGlueBasePostCodeLibDebug.mak" +End + diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePostCodeLibDebug/PostCode.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePostCodeLibDebug/PostCode.c new file mode 100644 index 0000000..a8c5a78 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePostCodeLibDebug/PostCode.c @@ -0,0 +1,132 @@ +/*++ + +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: + + PostCode.c + +Abstract: + + Post Code functions + +--*/ + +#include "EdkIIGlueBase.h" +#include "Pcd\EdkIIGluePcdPostCodeLib.h" + +/** + Sends an 32-bit value to a POST card. + + Sends the 32-bit value specified by Value to a POST card, and returns Value. + Some implementations of this library function may perform I/O operations + directly to a POST card device. Other implementations may send Value to + ReportStatusCode(), and the status code reporting mechanism will eventually + display the 32-bit value on the status reporting device. + + PostCode() must actively prevent recursion. If PostCode() is called while + processing another any other Report Status Code Library function, then + PostCode() must return Value immediately. + + @param Value The 32-bit value to write to the POST card. + + @return Value + +**/ +UINT32 +EFIAPI +GluePostCode ( + IN UINT32 Value + ) +{ + DEBUG((EFI_D_INFO, "POST %08x\n", Value)); + return Value; +} + + +/** + Sends an 32-bit value to a POST and associated ASCII string. + + Sends the 32-bit value specified by Value to a POST card, and returns Value. + If Description is not NULL, then the ASCII string specified by Description is + also passed to the handler that displays the POST card value. Some + implementations of this library function may perform I/O operations directly + to a POST card device. Other implementations may send Value to ReportStatusCode(), + and the status code reporting mechanism will eventually display the 32-bit + value on the status reporting device. + + PostCodeWithDescription()must actively prevent recursion. If + PostCodeWithDescription() is called while processing another any other Report + Status Code Library function, then PostCodeWithDescription() must return Value + immediately. + + @param Value The 32-bit value to write to the POST card. + @param Description Pointer to an ASCII string that is a description of the + POST code value. This is an optional parameter that may + be NULL. + + @return Value + +**/ +UINT32 +EFIAPI +GluePostCodeWithDescription ( + IN UINT32 Value, + IN CONST CHAR8 *Description OPTIONAL + ) +{ + DEBUG((EFI_D_INFO, "POST %08x - %s\n", Value, Description)); + return Value; +} + + +/** + Returns TRUE if POST Codes are enabled. + + This function returns TRUE if the POST_CODE_PROPERTY_POST_CODE_ENABLED + bit of PcdPostCodePropertyMask is set. Otherwise FALSE is returned. + + @retval TRUE The POST_CODE_PROPERTY_POST_CODE_ENABLED bit of + PcdPostCodeProperyMask is set. + @retval FALSE The POST_CODE_PROPERTY_POST_CODE_ENABLED bit of + PcdPostCodeProperyMask is clear. + +**/ +BOOLEAN +EFIAPI +GluePostCodeEnabled ( + VOID + ) +{ + return ((PcdGet8(PcdPostCodePropertyMask) & POST_CODE_PROPERTY_POST_CODE_ENABLED) != 0); +} + + +/** + Returns TRUE if POST code descriptions are enabled. + + This function returns TRUE if the POST_CODE_PROPERTY_POST_CODE_ENABLED + bit of PcdPostCodePropertyMask is set. Otherwise FALSE is returned. + + @retval TRUE The POST_CODE_PROPERTY_POST_CODE_ENABLED bit of + PcdPostCodeProperyMask is set. + @retval FALSE The POST_CODE_PROPERTY_POST_CODE_ENABLED bit of + PcdPostCodeProperyMask is clear. + +**/ +BOOLEAN +EFIAPI +GluePostCodeDescriptionEnabled ( + VOID + ) +{ + return ((PcdGet8(PcdPostCodePropertyMask) & POST_CODE_PROPERTY_POST_CODE_ENABLED) != 0); +} diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePostCodeLibPort80/BasePostCodeLibPort80.inf b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePostCodeLibPort80/BasePostCodeLibPort80.inf new file mode 100644 index 0000000..921483e --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePostCodeLibPort80/BasePostCodeLibPort80.inf @@ -0,0 +1,79 @@ +#/*++ +# +# 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: +# +# BasePostCodeLibPort80.inf +# +# Abstract: +# +# Component description file for BasePostCodeLibPort80 +# +#--*/ + +[defines] +BASE_NAME = EdkIIGlueBasePostCodeLibPort80 +COMPONENT_TYPE = LIBRARY + +[sources.common] + PostCode.c + +[sources.ia32] + +[sources.x64] + +[sources.ipf] + + +[sources.ebc] + + +[includes.common] + . + ..\..\Include + ..\..\include\Library + $(EDK_SOURCE)\Foundation + $(EDK_SOURCE)\Foundation\Framework + $(EDK_SOURCE)\Foundation\Efi + $(EDK_SOURCE)\Foundation\Include + $(EDK_SOURCE)\Foundation\Efi\Include + $(EDK_SOURCE)\Foundation\Framework\Include + $(EDK_SOURCE)\Foundation\Include\IndustryStandard + $(EDK_SOURCE)\Foundation\Core\Dxe + $(EDK_SOURCE)\Foundation\Library\Dxe\Include + $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include + $(EDK_SOURCE)\Foundation\Guid\PeiPeCoffLoader + + +[libraries.common] + EdkIIGlueBaseIoLibIntrinsic + +[libraries.ia32] + + +[libraries.x64] + + +[nmake.common] + C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION + LIB_STD_FLAGS = /NOLOGO /IGNORE:4006 + +[nmake.ia32] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32 + +[nmake.x64] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64 + +[nmake.ipf] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF + +[nmake.ebc] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_EBC
\ No newline at end of file diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePostCodeLibPort80/EdkIIGlueBasePostCodeLibPort80.cif b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePostCodeLibPort80/EdkIIGlueBasePostCodeLibPort80.cif new file mode 100644 index 0000000..341bf9d --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePostCodeLibPort80/EdkIIGlueBasePostCodeLibPort80.cif @@ -0,0 +1,11 @@ +<component> + name = "EdkIIGlueBasePostCodeLibPort80" + category = ModulePart + LocalRoot = "Edk\Foundation\Library\EdkIIGlueLib\Library\BasePostCodeLibPort80" + RefName = "EdkIIGlueBasePostCodeLibPort80" +[files] +"EdkIIGlueBasePostCodeLibPort80.sdl" +"EdkIIGlueBasePostCodeLibPort80.mak" +"BasePostCodeLibPort80.inf" +"PostCode.c" +<endComponent> diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePostCodeLibPort80/EdkIIGlueBasePostCodeLibPort80.mak b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePostCodeLibPort80/EdkIIGlueBasePostCodeLibPort80.mak new file mode 100644 index 0000000..7689553 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePostCodeLibPort80/EdkIIGlueBasePostCodeLibPort80.mak @@ -0,0 +1,87 @@ +#********************************************************************** +#********************************************************************** +#** ** +#** (C)Copyright 1985-2009, American Megatrends, Inc. ** +#** ** +#** All Rights Reserved. ** +#** ** +#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +#** ** +#** Phone: (770)-246-8600 ** +#** ** +#********************************************************************** +#********************************************************************** + +#********************************************************************** +# $Header: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGlueBasePostCodeLibPort80/EdkIIGlueBasePostCodeLibPort80.mak 1 1/20/12 3:54a Jeffch $ +# +# $Revision: 1 $ +# +# $Date: 1/20/12 3:54a $ +#********************************************************************** +# Revision History +# ---------------- +# $Log: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGlueBasePostCodeLibPort80/EdkIIGlueBasePostCodeLibPort80.mak $ +# +# 1 1/20/12 3:54a Jeffch +# Create Intel EDK 1117 Patch 7. +# +# 1 9/27/11 6:16a Wesleychen +# Intel EDK initially releases. +# +# 1 9/18/09 1:53a Iminglin +# +#********************************************************************** +#<AMI_FHDR_START> +# +# Name: EdkIIGlueBasePostCodeLibPort80.mak +# +# Description: +# +#<AMI_FHDR_END> +#********************************************************************** + + +$(EdkIIGlueBasePostCodeLibPort80_LIB) : EdkIIGlueBasePostCodeLibPort80 + +EdkIIGlueBasePostCodeLibPort80 : $(BUILD_DIR)\EdkIIGlueBasePostCodeLibPort80.mak EdkIIGlueBasePostCodeLibPort80Bin + +$(BUILD_DIR)\EdkIIGlueBasePostCodeLibPort80.mak : $(EdkIIGlueBasePostCodeLibPort80_DIR)\$(@B).cif $(EdkIIGlueBasePostCodeLibPort80_DIR)\$(@B).mak $(BUILD_RULES) + $(CIF2MAK) $(EdkIIGlueBasePostCodeLibPort80_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS) + +EdkIIGlueBasePostCodeLibPort80_LIB_LINKS=\ +!IF "$(PROCESSOR)"=="IA32" || "$(PROCESSOR)"=="x64" +$(EdkIIGlueBaseIoLibIntrinsic_LIB) +!ELSEIF "$(PROCESSOR)"=="EBC" +$(EdkIIGlueDxeIoLibCpuIo_LIB) +!ENDIF + +EdkIIGlueBasePostCodeLibPort80Bin : $(EdkIIGlueBasePostCodeLibPort80_LIB_LINKS) +!IF "$(x64_BUILD)"=="1" + $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\ + BUILD_DIR=$(BUILD_DIR)\ + /f $(BUILD_DIR)\EdkIIGlueBasePostCodeLibPort80.mak all\ + TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueBasePostCodeLibPort80_LIB)" + $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\ + BUILD_DIR=$(BUILD_DIR)\IA32\ + /f $(BUILD_DIR)\EdkIIGlueBasePostCodeLibPort80.mak all\ + TYPE=PEI_LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueBasePostCodeLibPort80_LIB)" +!ELSE + $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\ + BUILD_DIR=$(BUILD_DIR)\ + /f $(BUILD_DIR)\EdkIIGlueBasePostCodeLibPort80.mak all\ + TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueBasePostCodeLibPort80_LIB)" +!ENDIF +#********************************************************************** +#********************************************************************** +#** ** +#** (C)Copyright 1985-2009, American Megatrends, Inc. ** +#** ** +#** All Rights Reserved. ** +#** ** +#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +#** ** +#** Phone: (770)-246-8600 ** +#** ** +#********************************************************************** +#**********************************************************************
\ No newline at end of file diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePostCodeLibPort80/EdkIIGlueBasePostCodeLibPort80.sdl b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePostCodeLibPort80/EdkIIGlueBasePostCodeLibPort80.sdl new file mode 100644 index 0000000..27db987 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePostCodeLibPort80/EdkIIGlueBasePostCodeLibPort80.sdl @@ -0,0 +1,26 @@ +TOKEN + Name = "EdkIIGlueBasePostCodeLibPort80_SUPPORT" + Value = "1" + Help = "Main switch to enable EdkIIGlueBasePostCodeLibPort80 support in Project" + TokenType = Boolean + TargetEQU = Yes + TargetMAK = Yes + Master = Yes +End + +TOKEN + Name = "EdkIIGlueBasePostCodeLibPort80_LIB" + Value = "$$(LIB_BUILD_DIR)\EdkIIGlueBasePostCodeLibPort80.lib" + TokenType = Expression + TargetMAK = Yes +End + +PATH + Name = "EdkIIGlueBasePostCodeLibPort80_DIR" +End + +MODULE + Help = "Includes EdkIIGlueBasePostCodeLibPort80.mak to Project" + File = "EdkIIGlueBasePostCodeLibPort80.mak" +End + diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePostCodeLibPort80/PostCode.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePostCodeLibPort80/PostCode.c new file mode 100644 index 0000000..e2aec10 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePostCodeLibPort80/PostCode.c @@ -0,0 +1,132 @@ +/*++ + +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: + + PostCode.c + +Abstract: + + Post Code functions + +--*/ + +#include "EdkIIGlueBase.h" +#include "Pcd\EdkIIGluePcdPostCodeLib.h" + +/** + Sends an 32-bit value to a POST card. + + Sends the 32-bit value specified by Value to a POST card, and returns Value. + Some implementations of this library function may perform I/O operations + directly to a POST card device. Other implementations may send Value to + ReportStatusCode(), and the status code reporting mechanism will eventually + display the 32-bit value on the status reporting device. + + PostCode() must actively prevent recursion. If PostCode() is called while + processing another any other Report Status Code Library function, then + PostCode() must return Value immediately. + + @param Value The 32-bit value to write to the POST card. + + @return Value + +**/ +UINT32 +EFIAPI +GluePostCode ( + IN UINT32 Value + ) +{ + IoWrite8 (0x80, (UINT8)(Value)); + return Value; +} + + +/** + Sends an 32-bit value to a POST and associated ASCII string. + + Sends the 32-bit value specified by Value to a POST card, and returns Value. + If Description is not NULL, then the ASCII string specified by Description is + also passed to the handler that displays the POST card value. Some + implementations of this library function may perform I/O operations directly + to a POST card device. Other implementations may send Value to ReportStatusCode(), + and the status code reporting mechanism will eventually display the 32-bit + value on the status reporting device. + + PostCodeWithDescription()must actively prevent recursion. If + PostCodeWithDescription() is called while processing another any other Report + Status Code Library function, then PostCodeWithDescription() must return Value + immediately. + + @param Value The 32-bit value to write to the POST card. + @param Description Pointer to an ASCII string that is a description of the + POST code value. This is an optional parameter that may + be NULL. + + @return Value + +**/ +UINT32 +EFIAPI +GluePostCodeWithDescription ( + IN UINT32 Value, + IN CONST CHAR8 *Description OPTIONAL + ) +{ + IoWrite8 (0x80, (UINT8)(Value)); + return Value; +} + + +/** + Returns TRUE if POST Codes are enabled. + + This function returns TRUE if the POST_CODE_PROPERTY_POST_CODE_ENABLED + bit of PcdPostCodePropertyMask is set. Otherwise FALSE is returned. + + @retval TRUE The POST_CODE_PROPERTY_POST_CODE_ENABLED bit of + PcdPostCodeProperyMask is set. + @retval FALSE The POST_CODE_PROPERTY_POST_CODE_ENABLED bit of + PcdPostCodeProperyMask is clear. + +**/ +BOOLEAN +EFIAPI +GluePostCodeEnabled ( + VOID + ) +{ + return ((PcdGet8(PcdPostCodePropertyMask) & POST_CODE_PROPERTY_POST_CODE_ENABLED) != 0); +} + + +/** + Returns TRUE if POST code descriptions are enabled. + + This function returns TRUE if the + POST_CODE_PROPERTY_POST_CODE_ENABLED bit of + PcdPostCodePropertyMask is set. Otherwise FALSE is returned. + + @retval TRUE The POST_CODE_PROPERTY_POST_CODE_ENABLED + bit of PcdPostCodeProperyMask is set. + @retval FALSE The POST_CODE_PROPERTY_POST_CODE_ENABLED + bit of PcdPostCodeProperyMask is clear. + +**/ +BOOLEAN +EFIAPI +GluePostCodeDescriptionEnabled ( + VOID + ) +{ + return ((PcdGet8(PcdPostCodePropertyMask) & POST_CODE_PROPERTY_POST_CODE_ENABLED) != 0); +} diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePrintLib/BasePrintLib.inf b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePrintLib/BasePrintLib.inf new file mode 100644 index 0000000..fb2cf50 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePrintLib/BasePrintLib.inf @@ -0,0 +1,80 @@ +#/*++ +# +# 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: +# +# BasePrintLib.inf +# +# Abstract: +# +# Component description file for BasePrintLib. +# +#--*/ + +[defines] +BASE_NAME = EdkIIGlueBasePrintLib +COMPONENT_TYPE = LIBRARY + +[sources.common] + PrintLib.c + PrintLibInternal.c + +[sources.ia32] + +[sources.x64] + +[sources.ipf] + + +[sources.ebc] + + +[includes.common] + . + ..\..\Include + ..\..\include\Library + $(EDK_SOURCE)\Foundation + $(EDK_SOURCE)\Foundation\Framework + $(EDK_SOURCE)\Foundation\Efi + $(EDK_SOURCE)\Foundation\Include + $(EDK_SOURCE)\Foundation\Efi\Include + $(EDK_SOURCE)\Foundation\Framework\Include + $(EDK_SOURCE)\Foundation\Include\IndustryStandard + $(EDK_SOURCE)\Foundation\Core\Dxe + $(EDK_SOURCE)\Foundation\Library\Dxe\Include + $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include + $(EDK_SOURCE)\Foundation\Guid\PeiPeCoffLoader + + +[libraries.common] + EdkIIGlueBaseLib + +[libraries.ia32] + + +[libraries.x64] + + +[nmake.common] + C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION + LIB_STD_FLAGS = /NOLOGO /IGNORE:4006 + +[nmake.ia32] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32 + +[nmake.x64] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64 + +[nmake.ipf] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF + +[nmake.ebc] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_EBC
\ No newline at end of file diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePrintLib/EdkIIGlueBasePrintLib.cif b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePrintLib/EdkIIGlueBasePrintLib.cif new file mode 100644 index 0000000..64dfc7c --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePrintLib/EdkIIGlueBasePrintLib.cif @@ -0,0 +1,13 @@ +<component> + name = "EdkIIGlueBasePrintLib" + category = ModulePart + LocalRoot = "Edk\Foundation\Library\EdkIIGlueLib\Library\BasePrintLib" + RefName = "EdkIIGlueBasePrintLib" +[files] +"EdkIIGlueBasePrintLib.sdl" +"EdkIIGlueBasePrintLib.mak" +"BasePrintLib.inf" +"PrintLib.c" +"PrintLibInternal.c" +"PrintLibInternal.h" +<endComponent> diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePrintLib/EdkIIGlueBasePrintLib.mak b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePrintLib/EdkIIGlueBasePrintLib.mak new file mode 100644 index 0000000..d974948 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePrintLib/EdkIIGlueBasePrintLib.mak @@ -0,0 +1,80 @@ +#********************************************************************** +#********************************************************************** +#** ** +#** (C)Copyright 1985-2009, American Megatrends, Inc. ** +#** ** +#** All Rights Reserved. ** +#** ** +#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +#** ** +#** Phone: (770)-246-8600 ** +#** ** +#********************************************************************** +#********************************************************************** + +#********************************************************************** +# $Header: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGlueBasePrintLib/EdkIIGlueBasePrintLib.mak 1 1/20/12 3:54a Jeffch $ +# +# $Revision: 1 $ +# +# $Date: 1/20/12 3:54a $ +#********************************************************************** +# Revision History +# ---------------- +# $Log: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGlueBasePrintLib/EdkIIGlueBasePrintLib.mak $ +# +# 1 1/20/12 3:54a Jeffch +# Create Intel EDK 1117 Patch 7. +# +# 1 9/27/11 6:16a Wesleychen +# Intel EDK initially releases. +# +# 1 9/18/09 1:53a Iminglin +# +#********************************************************************** +#<AMI_FHDR_START> +# +# Name: EdkIIGlueBasePrintLib.mak +# +# Description: +# +#<AMI_FHDR_END> +#********************************************************************** + + +$(EdkIIGlueBasePrintLib_LIB) : EdkIIGlueBasePrintLib + +EdkIIGlueBasePrintLib : $(BUILD_DIR)\EdkIIGlueBasePrintLib.mak EdkIIGlueBasePrintLibBin + +$(BUILD_DIR)\EdkIIGlueBasePrintLib.mak : $(EdkIIGlueBasePrintLib_DIR)\$(@B).cif $(EdkIIGlueBasePrintLib_DIR)\$(@B).mak $(BUILD_RULES) + $(CIF2MAK) $(EdkIIGlueBasePrintLib_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS) + +EdkIIGlueBasePrintLibBin : $(EdkIIGlueBaseLib_LIB) +!IF "$(x64_BUILD)"=="1" + $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\ + BUILD_DIR=$(BUILD_DIR)\ + /f $(BUILD_DIR)\EdkIIGlueBasePrintLib.mak all\ + TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueBasePrintLib_LIB)" + $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\ + BUILD_DIR=$(BUILD_DIR)\IA32\ + /f $(BUILD_DIR)\EdkIIGlueBasePrintLib.mak all\ + TYPE=PEI_LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueBasePrintLib_LIB)" +!ELSE + $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\ + BUILD_DIR=$(BUILD_DIR)\ + /f $(BUILD_DIR)\EdkIIGlueBasePrintLib.mak all\ + TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueBasePrintLib_LIB)" +!ENDIF +#********************************************************************** +#********************************************************************** +#** ** +#** (C)Copyright 1985-2009, American Megatrends, Inc. ** +#** ** +#** All Rights Reserved. ** +#** ** +#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +#** ** +#** Phone: (770)-246-8600 ** +#** ** +#********************************************************************** +#**********************************************************************
\ No newline at end of file diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePrintLib/EdkIIGlueBasePrintLib.sdl b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePrintLib/EdkIIGlueBasePrintLib.sdl new file mode 100644 index 0000000..2df6627 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePrintLib/EdkIIGlueBasePrintLib.sdl @@ -0,0 +1,26 @@ +TOKEN + Name = "EdkIIGlueBasePrintLib_SUPPORT" + Value = "1" + Help = "Main switch to enable EdkIIGlueBasePrintLib support in Project" + TokenType = Boolean + TargetEQU = Yes + TargetMAK = Yes + Master = Yes +End + +TOKEN + Name = "EdkIIGlueBasePrintLib_LIB" + Value = "$$(LIB_BUILD_DIR)\EdkIIGlueBasePrintLib.lib" + TokenType = Expression + TargetMAK = Yes +End + +PATH + Name = "EdkIIGlueBasePrintLib_DIR" +End + +MODULE + Help = "Includes EdkIIGlueBasePrintLib.mak to Project" + File = "EdkIIGlueBasePrintLib.mak" +End + diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePrintLib/PrintLib.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePrintLib/PrintLib.c new file mode 100644 index 0000000..9446e02 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePrintLib/PrintLib.c @@ -0,0 +1,1061 @@ +/*++ + +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: + + PrintLib.c + +Abstract: + + Print Library. + +--*/ + +#include "PrintLibInternal.h" + +#define WARNING_STATUS_NUMBER 4 +#define ERROR_STATUS_NUMBER 24 + +STATIC CONST CHAR8 *StatusString [] = { + "Success", // RETURN_SUCCESS = 0 + "Warning Unknown Glyph", // RETURN_WARN_UNKNOWN_GLYPH = 1 + "Warning Delete Failure", // RETURN_WARN_DELETE_FAILURE = 2 + "Warning Write Failure", // RETURN_WARN_WRITE_FAILURE = 3 + "Warning Buffer Too Small", // RETURN_WARN_BUFFER_TOO_SMALL = 4 + "Load Error", // RETURN_LOAD_ERROR = 1 | MAX_BIT + "Invalid Parameter", // RETURN_INVALID_PARAMETER = 2 | MAX_BIT + "Unsupported", // RETURN_UNSUPPORTED = 3 | MAX_BIT + "Bad Buffer Size", // RETURN_BAD_BUFFER_SIZE = 4 | MAX_BIT + "Buffer Too Small", // RETURN_BUFFER_TOO_SMALL, = 5 | MAX_BIT + "Not Ready", // RETURN_NOT_READY = 6 | MAX_BIT + "Device Error", // RETURN_DEVICE_ERROR = 7 | MAX_BIT + "Write Protected", // RETURN_WRITE_PROTECTED = 8 | MAX_BIT + "Out of Resources", // RETURN_OUT_OF_RESOURCES = 9 | MAX_BIT + "Volume Corrupt", // RETURN_VOLUME_CORRUPTED = 10 | MAX_BIT + "Volume Full", // RETURN_VOLUME_FULL = 11 | MAX_BIT + "No Media", // RETURN_NO_MEDIA = 12 | MAX_BIT + "Media changed", // RETURN_MEDIA_CHANGED = 13 | MAX_BIT + "Not Found", // RETURN_NOT_FOUND = 14 | MAX_BIT + "Access Denied", // RETURN_ACCESS_DENIED = 15 | MAX_BIT + "No Response", // RETURN_NO_RESPONSE = 16 | MAX_BIT + "No mapping", // RETURN_NO_MAPPING = 17 | MAX_BIT + "Time out", // RETURN_TIMEOUT = 18 | MAX_BIT + "Not started", // RETURN_NOT_STARTED = 19 | MAX_BIT + "Already started", // RETURN_ALREADY_STARTED = 20 | MAX_BIT + "Aborted", // RETURN_ABORTED = 21 | MAX_BIT + "ICMP Error", // RETURN_ICMP_ERROR = 22 | MAX_BIT + "TFTP Error", // RETURN_TFTP_ERROR = 23 | MAX_BIT + "Protocol Error" // RETURN_PROTOCOL_ERROR = 24 | MAX_BIT +}; + +/** + Worker function that produces a Null-terminated string in an output buffer + based on a Null-terminated format string and a VA_LIST argument list. + + VSPrint function to process format and place the results in Buffer. Since a + VA_LIST is used this rountine allows the nesting of Vararg routines. Thus + this is the main print working routine. + + @param Buffer Character buffer to print the results of the parsing + of Format into. + @param BufferSize Maximum number of characters to put into buffer. + @param Flags Intial flags value. + Can only have FORMAT_UNICODE and OUTPUT_UNICODE set. + @param Format Null-terminated format string. + @param Marker Vararg list consumed by processing Format. + + @return Number of characters printed not including the Null-terminator. + +**/ +UINTN +BasePrintLibVSPrint ( + OUT CHAR8 *Buffer, + IN UINTN BufferSize, + IN UINTN Flags, + IN CONST CHAR8 *Format, + IN VA_LIST Marker + ) +{ + CHAR8 *OriginalBuffer; + CHAR8 *EndBuffer; + CHAR8 ValueBuffer[MAXIMUM_VALUE_CHARACTERS]; + UINTN BytesPerOutputCharacter; + UINTN BytesPerFormatCharacter; + UINTN FormatMask; + UINTN FormatCharacter; + UINTN Width; + UINTN Precision; + INT64 Value; + CONST CHAR8 *ArgumentString; + UINTN Character; + GUID *TmpGuid; + TIME *TmpTime; + UINTN Count; + UINTN ArgumentMask; + INTN BytesPerArgumentCharacter; + UINTN ArgumentCharacter; + BOOLEAN Done; + UINTN Index; + CHAR8 Prefix; + BOOLEAN ZeroPad; + BOOLEAN Comma; + UINTN Digits; + UINTN Radix; + RETURN_STATUS Status; + + if (BufferSize == 0) { + return 0; + } + ASSERT (Buffer != NULL); + + if ((Flags & OUTPUT_UNICODE) != 0) { + BytesPerOutputCharacter = 2; + } else { + BytesPerOutputCharacter = 1; + } + + // + // Reserve space for the Null terminator. + // + BufferSize--; + OriginalBuffer = Buffer; + // + // Set the tag for the end of the input Buffer. + // + EndBuffer = Buffer + BufferSize * BytesPerOutputCharacter; + + if ((Flags & FORMAT_UNICODE) != 0) { + // + // Make sure format string cannot contain more than PcdMaximumUnicodeStringLength + // Unicode characters if PcdMaximumUnicodeStringLength is not zero. + // + ASSERT (StrSize ((CHAR16 *) Format) != 0); + BytesPerFormatCharacter = 2; + FormatMask = 0xffff; + } else { + // + // Make sure format string cannot contain more than PcdMaximumAsciiStringLength + // Ascii characters if PcdMaximumAsciiStringLength is not zero. + // + ASSERT (AsciiStrSize (Format) != 0); + BytesPerFormatCharacter = 1; + FormatMask = 0xff; + } + + + + // + // Get the first character from the format string + // + FormatCharacter = (*Format | (*(Format + 1) << 8)) & FormatMask; + + // + // Loop until the end of the format string is reached or the output buffer is full + // + while (FormatCharacter != 0 && Buffer < EndBuffer) { + // + // Clear all the flag bits except those that may have been passed in + // + Flags &= (OUTPUT_UNICODE | FORMAT_UNICODE); + + // + // Set the default width to zero, and the default precision to 1 + // + Width = 0; + Precision = 1; + Prefix = 0; + Comma = FALSE; + ZeroPad = FALSE; + Count = 0; + Digits = 0; + + switch (FormatCharacter) { + case '%': + // + // Parse Flags and Width + // + for (Done = FALSE; !Done; ) { + Format += BytesPerFormatCharacter; + FormatCharacter = (*Format | (*(Format + 1) << 8)) & FormatMask; + switch (FormatCharacter) { + case '.': + Flags |= PRECISION; + break; + case '-': + Flags |= LEFT_JUSTIFY; + break; + case '+': + Flags |= PREFIX_SIGN; + break; + case ' ': + Flags |= PREFIX_BLANK; + break; + case ',': + Flags |= COMMA_TYPE; + break; + case 'L': + case 'l': + Flags |= LONG_TYPE; + break; + case '*': + if ((Flags & PRECISION) == 0) { + Flags |= PAD_TO_WIDTH; + Width = VA_ARG (Marker, UINTN); + } else { + Precision = VA_ARG (Marker, UINTN); + } + break; + case '0': + if ((Flags & PRECISION) == 0) { + Flags |= PREFIX_ZERO; + } + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + for (Count = 0; ((FormatCharacter >= '0') && (FormatCharacter <= '9')); ){ + Count = (Count * 10) + FormatCharacter - '0'; + Format += BytesPerFormatCharacter; + FormatCharacter = (*Format | (*(Format + 1) << 8)) & FormatMask; + } + Format -= BytesPerFormatCharacter; + if ((Flags & PRECISION) == 0) { + Flags |= PAD_TO_WIDTH; + Width = Count; + } else { + Precision = Count; + } + break; + + case '\0': + // + // Make no output if Format string terminates unexpectedly when + // looking up for flag, width, precision and type. + // + Format -= BytesPerFormatCharacter; + Precision = 0; + // + // break skipped on purpose. + // + default: + Done = TRUE; + break; + } + } + + // + // Handle each argument type + // + switch (FormatCharacter) { + case 'p': + // + // Flag space, +, 0, L & l are invalid for type p. + // + Flags &= ~(PREFIX_BLANK | PREFIX_SIGN | PREFIX_ZERO | LONG_TYPE); + if (sizeof (VOID *) > 4) { + Flags |= LONG_TYPE; + } + case 'X': + Flags |= PREFIX_ZERO; + // + // break skipped on purpose + // + case 'x': + Flags |= RADIX_HEX; + // + // break skipped on purpose + // + case 'd': + if ((Flags & LONG_TYPE) == 0) { + Value = (VA_ARG (Marker, int)); + } else { + Value = VA_ARG (Marker, INT64); + } + if ((Flags & PREFIX_BLANK) != 0) { + Prefix = ' '; + } + if ((Flags & PREFIX_SIGN) != 0) { + Prefix = '+'; + } + if ((Flags & COMMA_TYPE) != 0) { + Comma = TRUE; + } + if ((Flags & RADIX_HEX) == 0) { + Radix = 10; + if (Comma) { + Flags &= (~PREFIX_ZERO); + Precision = 1; + } + if (Value < 0) { + Flags |= PREFIX_SIGN; + Prefix = '-'; + Value = -Value; + } + } else { + Radix = 16; + Comma = FALSE; + if ((Flags & LONG_TYPE) == 0 && Value < 0) { + Value = (unsigned int)Value; + } + } + // + // Convert Value to a reversed string + // + Count = BasePrintLibValueToString (ValueBuffer, Value, Radix); + if (Value == 0 && Precision == 0) { + Count = 0; + } + ArgumentString = (CHAR8 *)ValueBuffer + Count; + + Digits = Count % 3; + if (Digits != 0) { + Digits = 3 - Digits; + } + if (Comma && Count != 0) { + Count += ((Count - 1) / 3); + } + if (Prefix != 0) { + Count++; + Precision++; + } + Flags |= ARGUMENT_REVERSED; + ZeroPad = TRUE; + if ((Flags & PREFIX_ZERO) != 0) { + if ((Flags & LEFT_JUSTIFY) == 0) { + if ((Flags & PAD_TO_WIDTH) != 0) { + if ((Flags & PRECISION) == 0) { + Precision = Width; + } + } + } + } + break; + + case 's': + case 'S': + Flags |= ARGUMENT_UNICODE; + // + // break skipped on purpose + // + case 'a': + ArgumentString = (CHAR8 *)VA_ARG (Marker, CHAR8 *); + if (ArgumentString == NULL) { + Flags &= (~ARGUMENT_UNICODE); + ArgumentString = "<null string>"; + } + break; + + case 'c': + Character = VA_ARG (Marker, UINTN) & 0xffff; + ArgumentString = (CHAR8 *)&Character; + Flags |= ARGUMENT_UNICODE; + break; + + case 'g': + TmpGuid = VA_ARG (Marker, GUID *); + if (TmpGuid == NULL) { + ArgumentString = "<null guid>"; + } else { + BasePrintLibSPrint ( + ValueBuffer, + MAXIMUM_VALUE_CHARACTERS, + 0, + "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x", + TmpGuid->Data1, + TmpGuid->Data2, + TmpGuid->Data3, + TmpGuid->Data4[0], + TmpGuid->Data4[1], + TmpGuid->Data4[2], + TmpGuid->Data4[3], + TmpGuid->Data4[4], + TmpGuid->Data4[5], + TmpGuid->Data4[6], + TmpGuid->Data4[7] + ); + ArgumentString = ValueBuffer; + } + break; + + case 't': + TmpTime = VA_ARG (Marker, TIME *); + if (TmpTime == NULL) { + ArgumentString = "<null time>"; + } else { + BasePrintLibSPrint ( + ValueBuffer, + MAXIMUM_VALUE_CHARACTERS, + 0, + "%02d/%02d/%04d %02d:%02d", + TmpTime->Month, + TmpTime->Day, + TmpTime->Year, + TmpTime->Hour, + TmpTime->Minute + ); + ArgumentString = ValueBuffer; + } + break; + + case 'r': + Status = VA_ARG (Marker, RETURN_STATUS); + ArgumentString = ValueBuffer; + if (RETURN_ERROR (Status)) { + // + // Clear error bit + // + Index = Status & ~MAX_BIT; + if (Index > 0 && Index <= ERROR_STATUS_NUMBER) { + ArgumentString = StatusString [Index + WARNING_STATUS_NUMBER]; + } + } else { + Index = Status; + if (Index <= WARNING_STATUS_NUMBER) { + ArgumentString = StatusString [Index]; + } + } + if (ArgumentString == ValueBuffer) { + BasePrintLibSPrint ((CHAR8 *) ValueBuffer, MAXIMUM_VALUE_CHARACTERS, 0, "%08X", Status); + } + break; + + case '\n': + ArgumentString = "\n\r"; + break; + + case '%': + default: + // + // if the type is '%' or unknown, then print it to the screen + // + ArgumentString = (CHAR8 *)&FormatCharacter; + Flags |= ARGUMENT_UNICODE; + break; + } + break; + + case '\n': + ArgumentString = "\n\r"; + break; + + default: + ArgumentString = (CHAR8 *)&FormatCharacter; + Flags |= ARGUMENT_UNICODE; + break; + } + + // + // Retrieve the ArgumentString attriubutes + // + if ((Flags & ARGUMENT_UNICODE) != 0) { + ArgumentMask = 0xffff; + BytesPerArgumentCharacter = 2; + } else { + ArgumentMask = 0xff; + BytesPerArgumentCharacter = 1; + } + if ((Flags & ARGUMENT_REVERSED) != 0) { + BytesPerArgumentCharacter = -BytesPerArgumentCharacter; + } else { + // + // Compute the number of characters in ArgumentString and store it in Count + // ArgumentString is either null-terminated, or it contains Precision characters + // + for (Count = 0; Count < Precision || ((Flags & PRECISION) == 0); Count++) { + ArgumentCharacter = ((ArgumentString[Count * BytesPerArgumentCharacter] & 0xff) | ((ArgumentString[Count * BytesPerArgumentCharacter + 1]) << 8)) & ArgumentMask; + if (ArgumentCharacter == 0) { + break; + } + } + } + + if (Precision < Count) { + Precision = Count; + } + + // + // Pad before the string + // + if ((Flags & (PAD_TO_WIDTH | LEFT_JUSTIFY)) == (PAD_TO_WIDTH)) { + Buffer = BasePrintLibFillBuffer (Buffer, EndBuffer, Width - Precision, ' ', BytesPerOutputCharacter); + } + + if (ZeroPad) { + if (Prefix != 0) { + Buffer = BasePrintLibFillBuffer (Buffer, EndBuffer, 1, Prefix, BytesPerOutputCharacter); + } + Buffer = BasePrintLibFillBuffer (Buffer, EndBuffer, Precision - Count, '0', BytesPerOutputCharacter); + } else { + Buffer = BasePrintLibFillBuffer (Buffer, EndBuffer, Precision - Count, ' ', BytesPerOutputCharacter); + if (Prefix != 0) { + Buffer = BasePrintLibFillBuffer (Buffer, EndBuffer, 1, Prefix, BytesPerOutputCharacter); + } + } + + // + // Output the Prefix character if it is present + // + Index = 0; + if (Prefix != 0) { + Index++; + } + + // + // Copy the string into the output buffer performing the required type conversions + // + while (Index < Count) { + ArgumentCharacter = ((*ArgumentString & 0xff) | (*(ArgumentString + 1) << 8)) & ArgumentMask; + + Buffer = BasePrintLibFillBuffer (Buffer, EndBuffer, 1, ArgumentCharacter, BytesPerOutputCharacter); + ArgumentString += BytesPerArgumentCharacter; + Index++; + if (Comma) { + Digits++; + if (Digits == 3) { + Digits = 0; + Index++; + if (Index < Count) { + Buffer = BasePrintLibFillBuffer (Buffer, EndBuffer, 1, ',', BytesPerOutputCharacter); + } + } + } + } + + // + // Pad after the string + // + if ((Flags & (PAD_TO_WIDTH | LEFT_JUSTIFY)) == (PAD_TO_WIDTH | LEFT_JUSTIFY)) { + Buffer = BasePrintLibFillBuffer (Buffer, EndBuffer, Width - Precision, ' ', BytesPerOutputCharacter); + } + + // + // Get the next character from the format string + // + Format += BytesPerFormatCharacter; + + // + // Get the next character from the format string + // + FormatCharacter = (*Format | (*(Format + 1) << 8)) & FormatMask; + } + + // + // Null terminate the Unicode or ASCII string + // + BasePrintLibFillBuffer (Buffer, EndBuffer + BytesPerOutputCharacter, 1, 0, BytesPerOutputCharacter); + // + // Make sure output buffer cannot contain more than PcdMaximumUnicodeStringLength + // Unicode characters if PcdMaximumUnicodeStringLength is not zero. + // + ASSERT ((((Flags & OUTPUT_UNICODE) == 0)) || (StrSize ((CHAR16 *) OriginalBuffer) != 0)); + // + // Make sure output buffer cannot contain more than PcdMaximumAsciiStringLength + // ASCII characters if PcdMaximumAsciiStringLength is not zero. + // + ASSERT ((((Flags & OUTPUT_UNICODE) != 0)) || (AsciiStrSize (OriginalBuffer) != 0)); + + return ((Buffer - OriginalBuffer) / BytesPerOutputCharacter); +} + +/** + Worker function that produces a Null-terminated string in an output buffer + based on a Null-terminated format string and variable argument list. + + VSPrint function to process format and place the results in Buffer. Since a + VA_LIST is used this rountine allows the nesting of Vararg routines. Thus + this is the main print working routine. + + @param Buffer Character buffer to print the results of the parsing + of Format into. + @param BufferSize Maximum number of characters to put into buffer. + Zero means no limit. + @param Flags Intial flags value. + Can only have FORMAT_UNICODE and OUTPUT_UNICODE set + @param FormatString Null-terminated format string. + + @return Number of characters printed not including the Null-terminator. + +**/ +UINTN +BasePrintLibSPrint ( + OUT CHAR8 *StartOfBuffer, + IN UINTN BufferSize, + IN UINTN Flags, + IN CONST CHAR8 *FormatString, + ... + ) +{ + VA_LIST Marker; + + VA_START (Marker, FormatString); + return BasePrintLibVSPrint (StartOfBuffer, BufferSize, Flags, FormatString, Marker); +} + +/** + Produces a Null-terminated Unicode string in an output buffer based on + a Null-terminated Unicode format string and a VA_LIST argument list + + Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer + and BufferSize. + The Unicode string is produced by parsing the format string specified by FormatString. + Arguments are pulled from the variable argument list specified by Marker based on the + contents of the format string. + The number of Unicode characters in the produced output buffer is returned not including + the Null-terminator. + If BufferSize is 0 or 1, then no output buffer is produced and 0 is returned. + + If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT(). + If BufferSize > 1 and FormatString is NULL, then ASSERT(). + If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than + PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then + ASSERT(). + If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string + contains more than PcdMaximumUnicodeStringLength Unicode characters not including the + Null-terminator, then ASSERT(). + + @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated + Unicode string. + @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer. + @param FormatString Null-terminated Unicode format string. + @param Marker VA_LIST marker for the variable argument list. + + @return The number of Unicode characters in the produced output buffer not including the + Null-terminator. + +**/ +UINTN +EFIAPI +UnicodeVSPrint ( + OUT CHAR16 *StartOfBuffer, + IN UINTN BufferSize, + IN CONST CHAR16 *FormatString, + IN VA_LIST Marker + ) +{ + return BasePrintLibVSPrint ((CHAR8 *)StartOfBuffer, BufferSize >> 1, FORMAT_UNICODE | OUTPUT_UNICODE, (CHAR8 *)FormatString, Marker); +} + +/** + Produces a Null-terminated Unicode string in an output buffer based on a Null-terminated + Unicode format string and variable argument list. + + Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer + and BufferSize. + The Unicode string is produced by parsing the format string specified by FormatString. + Arguments are pulled from the variable argument list based on the contents of the format string. + The number of Unicode characters in the produced output buffer is returned not including + the Null-terminator. + If BufferSize is 0 or 1, then no output buffer is produced and 0 is returned. + + If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT(). + If BufferSize > 1 and FormatString is NULL, then ASSERT(). + If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than + PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then + ASSERT(). + If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string + contains more than PcdMaximumUnicodeStringLength Unicode characters not including the + Null-terminator, then ASSERT(). + + @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated + Unicode string. + @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer. + @param FormatString Null-terminated Unicode format string. + + @return The number of Unicode characters in the produced output buffer not including the + Null-terminator. + +**/ +UINTN +EFIAPI +UnicodeSPrint ( + OUT CHAR16 *StartOfBuffer, + IN UINTN BufferSize, + IN CONST CHAR16 *FormatString, + ... + ) +{ + VA_LIST Marker; + + VA_START (Marker, FormatString); + return UnicodeVSPrint (StartOfBuffer, BufferSize, FormatString, Marker); +} + +/** + Produces a Null-terminated Unicode string in an output buffer based on a Null-terminated + ASCII format string and a VA_LIST argument list + + Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer + and BufferSize. + The Unicode string is produced by parsing the format string specified by FormatString. + Arguments are pulled from the variable argument list specified by Marker based on the + contents of the format string. + The number of Unicode characters in the produced output buffer is returned not including + the Null-terminator. + If BufferSize is 0 or 1, then no output buffer is produced and 0 is returned. + + If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT(). + If BufferSize > 1 and FormatString is NULL, then ASSERT(). + If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than + PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, then + ASSERT(). + If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string + contains more than PcdMaximumUnicodeStringLength Unicode characters not including the + Null-terminator, then ASSERT(). + + @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated + Unicode string. + @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer. + @param FormatString Null-terminated Unicode format string. + @param Marker VA_LIST marker for the variable argument list. + + @return The number of Unicode characters in the produced output buffer not including the + Null-terminator. + +**/ +UINTN +EFIAPI +UnicodeVSPrintAsciiFormat ( + OUT CHAR16 *StartOfBuffer, + IN UINTN BufferSize, + IN CONST CHAR8 *FormatString, + IN VA_LIST Marker + ) +{ + return BasePrintLibVSPrint ((CHAR8 *)StartOfBuffer, BufferSize >> 1, OUTPUT_UNICODE,FormatString, Marker); +} + +/** + Produces a Null-terminated Unicode string in an output buffer based on a Null-terminated + ASCII format string and variable argument list. + + Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer + and BufferSize. + The Unicode string is produced by parsing the format string specified by FormatString. + Arguments are pulled from the variable argument list based on the contents of the + format string. + The number of Unicode characters in the produced output buffer is returned not including + the Null-terminator. + If BufferSize is 0 or 1, then no output buffer is produced and 0 is returned. + + If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT(). + If BufferSize > 1 and FormatString is NULL, then ASSERT(). + If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than + PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, then + ASSERT(). + If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string + contains more than PcdMaximumUnicodeStringLength Unicode characters not including the + Null-terminator, then ASSERT(). + + @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated + Unicode string. + @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer. + @param FormatString Null-terminated Unicode format string. + + @return The number of Unicode characters in the produced output buffer not including the + Null-terminator. + +**/ +UINTN +EFIAPI +UnicodeSPrintAsciiFormat ( + OUT CHAR16 *StartOfBuffer, + IN UINTN BufferSize, + IN CONST CHAR8 *FormatString, + ... + ) +{ + VA_LIST Marker; + + VA_START (Marker, FormatString); + return UnicodeVSPrintAsciiFormat (StartOfBuffer, BufferSize, FormatString, Marker); +} + +/** + Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated + ASCII format string and a VA_LIST argument list. + + Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer + and BufferSize. + The ASCII string is produced by parsing the format string specified by FormatString. + Arguments are pulled from the variable argument list specified by Marker based on + the contents of the format string. + The number of ASCII characters in the produced output buffer is returned not including + the Null-terminator. + If BufferSize is 0, then no output buffer is produced and 0 is returned. + + If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT(). + If BufferSize > 0 and FormatString is NULL, then ASSERT(). + If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than + PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, then + ASSERT(). + If PcdMaximumAsciiStringLength is not zero, and produced Null-terminated ASCII string + contains more than PcdMaximumAsciiStringLength ASCII characters not including the + Null-terminator, then ASSERT(). + + @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated + ASCII string. + @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer. + @param FormatString Null-terminated Unicode format string. + @param Marker VA_LIST marker for the variable argument list. + + @return The number of ASCII characters in the produced output buffer not including the + Null-terminator. + +**/ +UINTN +EFIAPI +AsciiVSPrint ( + OUT CHAR8 *StartOfBuffer, + IN UINTN BufferSize, + IN CONST CHAR8 *FormatString, + IN VA_LIST Marker + ) +{ + return BasePrintLibVSPrint (StartOfBuffer, BufferSize, 0, FormatString, Marker); +} + +/** + Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated + ASCII format string and variable argument list. + + Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer + and BufferSize. + The ASCII string is produced by parsing the format string specified by FormatString. + Arguments are pulled from the variable argument list based on the contents of the + format string. + The number of ASCII characters in the produced output buffer is returned not including + the Null-terminator. + If BufferSize is 0, then no output buffer is produced and 0 is returned. + + If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT(). + If BufferSize > 0 and FormatString is NULL, then ASSERT(). + If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than + PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, then + ASSERT(). + If PcdMaximumAsciiStringLength is not zero, and produced Null-terminated ASCII string + contains more than PcdMaximumAsciiStringLength ASCII characters not including the + Null-terminator, then ASSERT(). + + @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated + ASCII string. + @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer. + @param FormatString Null-terminated Unicode format string. + + @return The number of ASCII characters in the produced output buffer not including the + Null-terminator. + +**/ +UINTN +EFIAPI +AsciiSPrint ( + OUT CHAR8 *StartOfBuffer, + IN UINTN BufferSize, + IN CONST CHAR8 *FormatString, + ... + ) +{ + VA_LIST Marker; + + VA_START (Marker, FormatString); + return AsciiVSPrint (StartOfBuffer, BufferSize, FormatString, Marker); +} + +/** + Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated + ASCII format string and a VA_LIST argument list. + + Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer + and BufferSize. + The ASCII string is produced by parsing the format string specified by FormatString. + Arguments are pulled from the variable argument list specified by Marker based on + the contents of the format string. + The number of ASCII characters in the produced output buffer is returned not including + the Null-terminator. + If BufferSize is 0, then no output buffer is produced and 0 is returned. + + If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT(). + If BufferSize > 0 and FormatString is NULL, then ASSERT(). + If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than + PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then + ASSERT(). + If PcdMaximumAsciiStringLength is not zero, and produced Null-terminated ASCII string + contains more than PcdMaximumAsciiStringLength ASCII characters not including the + Null-terminator, then ASSERT(). + + @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated + ASCII string. + @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer. + @param FormatString Null-terminated Unicode format string. + @param Marker VA_LIST marker for the variable argument list. + + @return The number of ASCII characters in the produced output buffer not including the + Null-terminator. + +**/ +UINTN +EFIAPI +AsciiVSPrintUnicodeFormat ( + OUT CHAR8 *StartOfBuffer, + IN UINTN BufferSize, + IN CONST CHAR16 *FormatString, + IN VA_LIST Marker + ) +{ + return BasePrintLibVSPrint (StartOfBuffer, BufferSize, FORMAT_UNICODE, (CHAR8 *)FormatString, Marker); +} + +/** + Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated + ASCII format string and variable argument list. + + Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer + and BufferSize. + The ASCII string is produced by parsing the format string specified by FormatString. + Arguments are pulled from the variable argument list based on the contents of the + format string. + The number of ASCII characters in the produced output buffer is returned not including + the Null-terminator. + If BufferSize is 0, then no output buffer is produced and 0 is returned. + + If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT(). + If BufferSize > 0 and FormatString is NULL, then ASSERT(). + If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than + PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then + ASSERT(). + If PcdMaximumAsciiStringLength is not zero, and produced Null-terminated ASCII string + contains more than PcdMaximumAsciiStringLength ASCII characters not including the + Null-terminator, then ASSERT(). + + @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated + ASCII string. + @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer. + @param FormatString Null-terminated Unicode format string. + + @return The number of ASCII characters in the produced output buffer not including the + Null-terminator. + +**/ +UINTN +EFIAPI +AsciiSPrintUnicodeFormat ( + OUT CHAR8 *StartOfBuffer, + IN UINTN BufferSize, + IN CONST CHAR16 *FormatString, + ... + ) +{ + VA_LIST Marker; + + VA_START (Marker, FormatString); + return AsciiVSPrintUnicodeFormat (StartOfBuffer, BufferSize, FormatString, Marker); +} + +/** + Converts a decimal value to a Null-terminated Unicode string. + + Converts the decimal number specified by Value to a Null-terminated Unicode + string specified by Buffer containing at most Width characters. + If Width is 0 then a width of MAXIMUM_VALUE_CHARACTERS is assumed. + The number of Unicode characters in Buffer is returned not including the Null-terminator. + If the conversion contains more than Width characters, then only the first + Width characters are returned, and the total number of characters + required to perform the conversion is returned. + Additional conversion parameters are specified in Flags. + The Flags bit LEFT_JUSTIFY is always ignored. + All conversions are left justified in Buffer. + If Width is 0, PREFIX_ZERO is ignored in Flags. + If COMMA_TYPE is set in Flags, then PREFIX_ZERO is ignored in Flags, and commas + are inserted every 3rd digit starting from the right. + If Value is < 0, then the fist character in Buffer is a '-'. + If PREFIX_ZERO is set in Flags and PREFIX_ZERO is not being ignored, + then Buffer is padded with '0' characters so the combination of the optional '-' + sign character, '0' characters, digit characters for Value, and the Null-terminator + add up to Width characters. + + If Buffer is NULL, then ASSERT(). + If unsupported bits are set in Flags, then ASSERT(). + If Width >= MAXIMUM_VALUE_CHARACTERS, then ASSERT() + + @param Buffer Pointer to the output buffer for the produced Null-terminated + Unicode string. + @param Flags The bitmask of flags that specify left justification, zero pad, and commas. + @param Value The 64-bit signed value to convert to a string. + @param Width The maximum number of Unicode characters to place in Buffer, not including + the Null-terminator. + + @return The number of Unicode characters in Buffer not including the Null-terminator. + +**/ +UINTN +EFIAPI +UnicodeValueToString ( + IN OUT CHAR16 *Buffer, + IN UINTN Flags, + IN INT64 Value, + IN UINTN Width + ) +{ + return BasePrintLibConvertValueToString ((CHAR8 *)Buffer, Flags, Value, Width, 2); +} + +/** + Converts a decimal value to a Null-terminated ASCII string. + + Converts the decimal number specified by Value to a Null-terminated ASCII string + specified by Buffer containing at most Width characters. + If Width is 0 then a width of MAXIMUM_VALUE_CHARACTERS is assumed. + The number of ASCII characters in Buffer is returned not including the Null-terminator. + If the conversion contains more than Width characters, then only the first Width + characters are returned, and the total number of characters required to perform + the conversion is returned. + Additional conversion parameters are specified in Flags. + The Flags bit LEFT_JUSTIFY is always ignored. + All conversions are left justified in Buffer. + If Width is 0, PREFIX_ZERO is ignored in Flags. + If COMMA_TYPE is set in Flags, then PREFIX_ZERO is ignored in Flags, and commas + are inserted every 3rd digit starting from the right. + If Value is < 0, then the fist character in Buffer is a '-'. + If PREFIX_ZERO is set in Flags and PREFIX_ZERO is not being ignored, then Buffer + is padded with '0' characters so the combination of the optional '-' + sign character, '0' characters, digit characters for Value, and the + Null-terminator add up to Width characters. + + If Buffer is NULL, then ASSERT(). + If unsupported bits are set in Flags, then ASSERT(). + If Width >= MAXIMUM_VALUE_CHARACTERS, then ASSERT() + + @param Buffer Pointer to the output buffer for the produced Null-terminated + ASCII string. + @param Flags The bitmask of flags that specify left justification, zero pad, and commas. + @param Value The 64-bit signed value to convert to a string. + @param Width The maximum number of ASCII characters to place in Buffer, not including + the Null-terminator. + + @return The number of ASCII characters in Buffer not including the Null-terminator. + +**/ +UINTN +EFIAPI +AsciiValueToString ( + IN OUT CHAR8 *Buffer, + IN UINTN Flags, + IN INT64 Value, + IN UINTN Width + ) +{ + return BasePrintLibConvertValueToString ((CHAR8 *)Buffer, Flags, Value, Width, 1); +} diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePrintLib/PrintLibInternal.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePrintLib/PrintLibInternal.c new file mode 100644 index 0000000..83f75a5 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePrintLib/PrintLibInternal.c @@ -0,0 +1,215 @@ +/*++ + +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: + + PrintLibInternal.c + +Abstract: + + Print Library worker functions. + +--*/ + +#include "PrintLibInternal.h" + +GLOBAL_REMOVE_IF_UNREFERENCED CONST CHAR8 mHexStr[] = {'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'}; + + +/** + Internal function that places the character into the Buffer. + + Internal function that places ASCII or Unicode character into the Buffer. + + @param Buffer Buffer to place the Unicode or ASCII string. + @param EndBuffer The end of the input Buffer. No characters will be + placed after that. + @param Length Count of character to be placed into Buffer. + @param Character Character to be placed into Buffer. + @param Increment Character increment in Buffer. + + @return Number of characters printed. + +**/ +CHAR8 * +BasePrintLibFillBuffer ( + CHAR8 *Buffer, + CHAR8 *EndBuffer, + INTN Length, + UINTN Character, + INTN Increment + ) +{ + INTN Index; + + for (Index = 0; Index < Length && Buffer < EndBuffer; Index++) { + *Buffer = (CHAR8) Character; + *(Buffer + 1) = (CHAR8) (Character >> 8); + Buffer += Increment; + } + return Buffer; +} + +/** + Internal function that convert a decimal number to a string in Buffer. + + Print worker function that convert a decimal number to a string in Buffer. + + @param Buffer Location to place the Unicode or ASCII string of Value. + @param Value Value to convert to a Decimal or Hexidecimal string in Buffer. + @param Radix Radix of the value + + @return Number of characters printed. + +**/ +UINTN +EFIAPI +BasePrintLibValueToString ( + IN OUT CHAR8 *Buffer, + IN INT64 Value, + IN UINTN Radix + ) +{ + UINTN Digits; + UINT32 Remainder; + + // + // Loop to convert one digit at a time in reverse order + // + *(Buffer++) = 0; + Digits = 0; + do { + Value = (INT64)DivU64x32Remainder ((UINT64)Value, (UINT32)Radix, &Remainder); + *(Buffer++) = mHexStr[Remainder]; + Digits++; + } while (Value != 0); + return Digits; +} + +/** + Internal function that converts a decimal value to a Null-terminated string. + + Converts the decimal number specified by Value to a Null-terminated + string specified by Buffer containing at most Width characters. + If Width is 0 then a width of MAXIMUM_VALUE_CHARACTERS is assumed. + The number of characters in Buffer is returned not including the Null-terminator. + If the conversion contains more than Width characters, then only the first + Width characters are returned, and the total number of characters + required to perform the conversion is returned. + Additional conversion parameters are specified in Flags. + The Flags bit LEFT_JUSTIFY is always ignored. + All conversions are left justified in Buffer. + If Width is 0, PREFIX_ZERO is ignored in Flags. + If COMMA_TYPE is set in Flags, then PREFIX_ZERO is ignored in Flags, and commas + are inserted every 3rd digit starting from the right. + If HEX_RADIX is set in Flags, then the output buffer will be formatted in hexadecimal format. + If Value is < 0 and HEX_RADIX is not set in Flags, then the fist character in Buffer is a '-'. + If PREFIX_ZERO is set in Flags and PREFIX_ZERO is not being ignored, + then Buffer is padded with '0' characters so the combination of the optional '-' + sign character, '0' characters, digit characters for Value, and the Null-terminator + add up to Width characters. + If both COMMA_TYPE and HEX_RADIX are set in Flags, then ASSERT(). + + If Buffer is NULL, then ASSERT(). + If unsupported bits are set in Flags, then ASSERT(). + If Width >= MAXIMUM_VALUE_CHARACTERS, then ASSERT() + + @param Buffer Pointer to the output buffer for the produced Null-terminated + string. + @param Flags The bitmask of flags that specify left justification, zero pad, + and commas. + @param Value The 64-bit signed value to convert to a string. + @param Width The maximum number of characters to place in Buffer, not including + the Null-terminator. + @param Increment Character increment in Buffer. + + @return The number of characters in Buffer not including the Null-terminator. + +**/ +UINTN +BasePrintLibConvertValueToString ( + IN OUT CHAR8 *Buffer, + IN UINTN Flags, + IN INT64 Value, + IN UINTN Width, + IN UINTN Increment + ) +{ + CHAR8 *OriginalBuffer; + CHAR8 *EndBuffer; + CHAR8 ValueBuffer[MAXIMUM_VALUE_CHARACTERS]; + UINTN Count; + UINTN Digits; + UINTN Index; + UINTN Radix; + + ASSERT (Buffer != NULL); + ASSERT (Width < MAXIMUM_VALUE_CHARACTERS); + // + // Make sure Flags can only contain supported bits. + // + ASSERT ((Flags & ~(LEFT_JUSTIFY | COMMA_TYPE | PREFIX_ZERO | RADIX_HEX)) == 0); + + // + // If both COMMA_TYPE and HEX_RADIX are set, then ASSERT () + // + ASSERT (((Flags & COMMA_TYPE) != 0 && (Flags & RADIX_HEX) != 0) == FALSE); + + OriginalBuffer = Buffer; + + if (Width == 0 || (Flags & COMMA_TYPE) != 0) { + Flags &= (~PREFIX_ZERO); + } + + if (Width == 0) { + Width = MAXIMUM_VALUE_CHARACTERS - 1; + } + // + // Set the tag for the end of the input Buffer. + // + EndBuffer = Buffer + Width * Increment; + + if ((Value < 0) && ((Flags & RADIX_HEX) == 0)) { + Value = -Value; + Buffer = BasePrintLibFillBuffer (Buffer, EndBuffer, 1, '-', Increment); + Width--; + } + + Radix = ((Flags & RADIX_HEX) == 0)? 10 : 16; + Count = BasePrintLibValueToString (ValueBuffer, Value, Radix); + + if ((Flags & PREFIX_ZERO) != 0) { + Buffer = BasePrintLibFillBuffer (Buffer, EndBuffer, Width - Count, '0', Increment); + } + + Digits = Count % 3; + if (Digits != 0) { + Digits = 3 - Digits; + } + for (Index = 0; Index < Count; Index++) { + Buffer = BasePrintLibFillBuffer (Buffer, EndBuffer, 1, ValueBuffer[Count - Index], Increment); + if ((Flags & COMMA_TYPE) != 0) { + Digits++; + if (Digits == 3) { + Digits = 0; + if ((Index + 1) < Count) { + Buffer = BasePrintLibFillBuffer (Buffer, EndBuffer, 1, ',', Increment); + } + } + } + } + + BasePrintLibFillBuffer (Buffer, EndBuffer + Increment, 1, 0, Increment); + + return ((Buffer - OriginalBuffer) / Increment); +} + diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePrintLib/PrintLibInternal.h b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePrintLib/PrintLibInternal.h new file mode 100644 index 0000000..db621f2 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePrintLib/PrintLibInternal.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: + + PrintLibInternal.h + +Abstract: + + Print Library. + +--*/ + +#ifndef __PRINT_LIB_INTERNAL_H__ +#define __PRINT_LIB_INTERNAL_H__ + +#include "EdkIIGlueBase.h" + +// +// 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 +#define OUTPUT_UNICODE 0x40 +#define RADIX_HEX 0x80 +#define FORMAT_UNICODE 0x100 +#define PAD_TO_WIDTH 0x200 +#define ARGUMENT_UNICODE 0x400 +#define PRECISION 0x800 +#define ARGUMENT_REVERSED 0x1000 + +// +// Record date and time information +// +typedef struct { + UINT16 Year; + UINT8 Month; + UINT8 Day; + UINT8 Hour; + UINT8 Minute; + UINT8 Second; + UINT8 Pad1; + UINT32 Nanosecond; + INT16 TimeZone; + UINT8 Daylight; + UINT8 Pad2; +} TIME; + +/** + Worker function that produces a Null-terminated string in an output buffer + based on a Null-terminated format string and variable argument list. + + VSPrint function to process format and place the results in Buffer. Since a + VA_LIST is used this rountine allows the nesting of Vararg routines. Thus + this is the main print working routine + + @param Buffer Character buffer to print the results of the parsing + of Format into. + @param BufferSize Maximum number of characters to put into buffer. + Zero means no limit. + @param Flags Intial flags value. + Can only have FORMAT_UNICODE and OUTPUT_UNICODE set + @param FormatString Null-terminated format string. + + @return Number of characters printed. + +**/ +UINTN +BasePrintLibSPrint ( + OUT CHAR8 *Buffer, + IN UINTN BufferSize, + IN UINTN Flags, + IN CONST CHAR8 *FormatString, + ... + ); + +/** + Internal function that places the character into the Buffer. + + Internal function that places ASCII or Unicode character into the Buffer. + + @param Buffer Buffer to place the Unicode or ASCII string. + @param EndBuffer The end of the input Buffer. No characters will be + placed after that. + @param Length Count of character to be placed into Buffer. + @param Character Character to be placed into Buffer. + @param Increment Character increment in Buffer. + + @return Number of characters printed. + +**/ +CHAR8 * +BasePrintLibFillBuffer ( + CHAR8 *Buffer, + CHAR8 *EndBuffer, + INTN Length, + UINTN Character, + INTN Increment + ); + +/** + Internal function that convert a decimal number to a string in Buffer. + + Print worker function that convert a decimal number to a string in Buffer. + + @param Buffer Location to place the Unicode or ASCII string of Value. + @param Value Value to convert to a Decimal or Hexidecimal string in Buffer. + @param Radix Radix of the value + + @return Number of characters printed. + +**/ +UINTN +EFIAPI +BasePrintLibValueToString ( + IN OUT CHAR8 *Buffer, + IN INT64 Value, + IN UINTN Radix + ); + +/** + Internal function that converts a decimal value to a Null-terminated string. + + Converts the decimal number specified by Value to a Null-terminated + string specified by Buffer containing at most Width characters. + If Width is 0 then a width of MAXIMUM_VALUE_CHARACTERS is assumed. + The total number of characters placed in Buffer is returned. + If the conversion contains more than Width characters, then only the first + Width characters are returned, and the total number of characters + required to perform the conversion is returned. + Additional conversion parameters are specified in Flags. + The Flags bit LEFT_JUSTIFY is always ignored. + All conversions are left justified in Buffer. + If Width is 0, PREFIX_ZERO is ignored in Flags. + If COMMA_TYPE is set in Flags, then PREFIX_ZERO is ignored in Flags, and commas + are inserted every 3rd digit starting from the right. + If Value is < 0, then the fist character in Buffer is a '-'. + If PREFIX_ZERO is set in Flags and PREFIX_ZERO is not being ignored, + then Buffer is padded with '0' characters so the combination of the optional '-' + sign character, '0' characters, digit characters for Value, and the Null-terminator + add up to Width characters. + + If Buffer is NULL, then ASSERT(). + If unsupported bits are set in Flags, then ASSERT(). + If Width >= MAXIMUM_VALUE_CHARACTERS, then ASSERT() + + @param Buffer Pointer to the output buffer for the produced Null-terminated + string. + @param Flags The bitmask of flags that specify left justification, zero pad, + and commas. + @param Value The 64-bit signed value to convert to a string. + @param Width The maximum number of characters to place in Buffer, not including + the Null-terminator. + @param Increment Character increment in Buffer. + + @return Total number of characters required to perform the conversion. + +**/ +UINTN +BasePrintLibConvertValueToString ( + IN OUT CHAR8 *Buffer, + IN UINTN Flags, + IN INT64 Value, + IN UINTN Width, + IN UINTN Increment + ); + +#endif diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseTimerLibLocalApic/BaseTimerLibLocalApic.inf b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseTimerLibLocalApic/BaseTimerLibLocalApic.inf new file mode 100644 index 0000000..e41daab --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseTimerLibLocalApic/BaseTimerLibLocalApic.inf @@ -0,0 +1,79 @@ +#/*++ +# +# 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: +# +# BaseTimerLibLocalApic.inf +# +# Abstract: +# +# Component description file for BaseTimerLibLocalApic. +# +#--*/ + +[defines] +BASE_NAME = EdkIIGlueBaseTimerLibLocalApic +COMPONENT_TYPE = LIBRARY + +[sources.common] + +[sources.ia32] + x86TimerLib.c + +[sources.x64] + x86TimerLib.c + + +[sources.ipf] + +[sources.ebc] + + +[includes.common] + . + ..\..\Include + ..\..\include\Library + $(EDK_SOURCE)\Foundation + $(EDK_SOURCE)\Foundation\Framework + $(EDK_SOURCE)\Foundation\Efi + $(EDK_SOURCE)\Foundation\Include + $(EDK_SOURCE)\Foundation\Efi\Include + $(EDK_SOURCE)\Foundation\Framework\Include + $(EDK_SOURCE)\Foundation\Include\IndustryStandard + $(EDK_SOURCE)\Foundation\Core\Dxe + $(EDK_SOURCE)\Foundation\Library\Dxe\Include + $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include + +[libraries.common] + EdkIIGlueBaseLib + EdkIIGlueBaseIoLibIntrinsic + +[libraries.ia32] + + +[libraries.x64] + + +[nmake.common] + C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION + LIB_STD_FLAGS = /NOLOGO /IGNORE:4006 + +[nmake.ia32] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32 + +[nmake.x64] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64 + +[nmake.ipf] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF + +[nmake.ebc] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_EBC
\ No newline at end of file diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseTimerLibLocalApic/EdkIIGlueBaseTimerLibLocalApic.cif b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseTimerLibLocalApic/EdkIIGlueBaseTimerLibLocalApic.cif new file mode 100644 index 0000000..89bdee3 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseTimerLibLocalApic/EdkIIGlueBaseTimerLibLocalApic.cif @@ -0,0 +1,11 @@ +<component> + name = "EdkIIGlueBaseTimerLibLocalApic" + category = ModulePart + LocalRoot = "Edk\Foundation\Library\EdkIIGlueLib\Library\BaseTimerLibLocalApic" + RefName = "EdkIIGlueBaseTimerLibLocalApic" +[files] +"EdkIIGlueBaseTimerLibLocalApic.sdl" +"EdkIIGlueBaseTimerLibLocalApic.mak" +"BaseTimerLibLocalApic.inf" +"x86TimerLib.c" +<endComponent> diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseTimerLibLocalApic/EdkIIGlueBaseTimerLibLocalApic.mak b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseTimerLibLocalApic/EdkIIGlueBaseTimerLibLocalApic.mak new file mode 100644 index 0000000..a4798db --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseTimerLibLocalApic/EdkIIGlueBaseTimerLibLocalApic.mak @@ -0,0 +1,87 @@ +#********************************************************************** +#********************************************************************** +#** ** +#** (C)Copyright 1985-2009, American Megatrends, Inc. ** +#** ** +#** All Rights Reserved. ** +#** ** +#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +#** ** +#** Phone: (770)-246-8600 ** +#** ** +#********************************************************************** +#********************************************************************** + +#********************************************************************** +# $Header: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGlueBaseTimerLibLocalApic/EdkIIGlueBaseTimerLibLocalApic.mak 1 1/20/12 3:54a Jeffch $ +# +# $Revision: 1 $ +# +# $Date: 1/20/12 3:54a $ +#********************************************************************** +# Revision History +# ---------------- +# $Log: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGlueBaseTimerLibLocalApic/EdkIIGlueBaseTimerLibLocalApic.mak $ +# +# 1 1/20/12 3:54a Jeffch +# Create Intel EDK 1117 Patch 7. +# +# 1 9/27/11 6:16a Wesleychen +# Intel EDK initially releases. +# +# 1 9/18/09 1:53a Iminglin +# +#********************************************************************** +#<AMI_FHDR_START> +# +# Name: EdkIIGlueBaseTimerLibLocalApic.mak +# +# Description: +# +#<AMI_FHDR_END> +#***************************************************************s******* + + +$(EdkIIGlueBaseTimerLibLocalApic_LIB) : EdkIIGlueBaseTimerLibLocalApic + +$(EdkIIGlueBaseTimerLibLocalApic_LIB) : EdkIIGlueBaseTimerLibLocalApic + +EdkIIGlueBaseTimerLibLocalApic : $(BUILD_DIR)\EdkIIGlueBaseTimerLibLocalApic.mak EdkIIGlueBaseTimerLibLocalApicBin + +$(BUILD_DIR)\EdkIIGlueBaseTimerLibLocalApic.mak : $(EdkIIGlueBaseTimerLibLocalApic_DIR)\$(@B).cif $(EdkIIGlueBaseTimerLibLocalApic_DIR)\$(@B).mak $(BUILD_RULES) + $(CIF2MAK) $(EdkIIGlueBaseTimerLibLocalApic_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS) + +EdkIIGlueBaseTimerLibLocalApic_LIB_LINKS=$(EdkIIGlueBaseLib_LIB)\ +!IF "$(PROCESSOR)"=="IA32" || "$(PROCESSOR)"=="x64" +$(EdkIIGlueBaseIoLibIntrinsic_LIB) +!ENDIF + +EdkIIGlueBaseTimerLibLocalApicBin : $(EdkIIGlueBaseTimerLibLocalApic_LIB_LINKS) +!IF "$(x64_BUILD)"=="1" + $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\ + BUILD_DIR=$(BUILD_DIR)\ + /f $(BUILD_DIR)\EdkIIGlueBaseTimerLibLocalApic.mak all\ + TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueBaseTimerLibLocalApic_LIB)" + $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\ + BUILD_DIR=$(BUILD_DIR)\IA32\ + /f $(BUILD_DIR)\EdkIIGlueBaseTimerLibLocalApic.mak all\ + TYPE=PEI_LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueBaseTimerLibLocalApic_LIB)" +!ELSE + $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\ + BUILD_DIR=$(BUILD_DIR)\ + /f $(BUILD_DIR)\EdkIIGlueBaseTimerLibLocalApic.mak all\ + TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueBaseTimerLibLocalApic_LIB)" +!ENDIF +#********************************************************************** +#********************************************************************** +#** ** +#** (C)Copyright 1985-2009, American Megatrends, Inc. ** +#** ** +#** All Rights Reserved. ** +#** ** +#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +#** ** +#** Phone: (770)-246-8600 ** +#** ** +#********************************************************************** +#********************************************************************** diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseTimerLibLocalApic/EdkIIGlueBaseTimerLibLocalApic.sdl b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseTimerLibLocalApic/EdkIIGlueBaseTimerLibLocalApic.sdl new file mode 100644 index 0000000..b132527 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseTimerLibLocalApic/EdkIIGlueBaseTimerLibLocalApic.sdl @@ -0,0 +1,26 @@ +TOKEN + Name = "EdkIIGlueBaseTimerLibLocalApic_SUPPORT" + Value = "1" + Help = "Main switch to enable EdkIIGlueBaseTimerLibLocalApic support in Project" + TokenType = Boolean + TargetEQU = Yes + TargetMAK = Yes + Master = Yes +End + +TOKEN + Name = "EdkIIGlueBaseTimerLibLocalApic_LIB" + Value = "$$(LIB_BUILD_DIR)\EdkIIGlueBaseTimerLibLocalApic.lib" + TokenType = Expression + TargetMAK = Yes +End + +PATH + Name = "EdkIIGlueBaseTimerLibLocalApic_DIR" +End + +MODULE + Help = "Includes EdkIIGlueBaseTimerLibLocalApic.mak to Project" + File = "EdkIIGlueBaseTimerLibLocalApic.mak" +End + diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseTimerLibLocalApic/x86TimerLib.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseTimerLibLocalApic/x86TimerLib.c new file mode 100644 index 0000000..a19e16d --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseTimerLibLocalApic/x86TimerLib.c @@ -0,0 +1,293 @@ +/*++ + +Copyright (c) 2004 - 2011, 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: + + x86TimerLib.c + +Abstract: + + Timer Library functions built upon local APIC on IA32/x64. + + @bug Should use PCD to retrieve all the constants including index of + the IA32_APIC_BASE MSR, the offsets of InitialCount, CorrentCount + and DivideConfiguration. + +--*/ + +#include "EdkIIGlueBase.h" + +// +// The following 2 arrays are used in calculating the frequency of local APIC +// timer. Refer to IA-32 developers' manual for more details. +// + +GLOBAL_REMOVE_IF_UNREFERENCED +CONST UINT32 mTimerLibLocalApicFrequencies[] = { + 100000000, + 133000000, + 200000000, + 166000000 +}; + +GLOBAL_REMOVE_IF_UNREFERENCED +CONST UINT8 mTimerLibLocalApicDivisor[] = { + 0x02, 0x04, 0x08, 0x10, + 0x02, 0x04, 0x08, 0x10, + 0x20, 0x40, 0x80, 0x01, + 0x20, 0x40, 0x80, 0x01 +}; + +/** + Internal function to retrieve the base address of local APIC. + + Internal function to retrieve the base address of local APIC. + + @return The base address of local APIC + +**/ +STATIC +UINTN +InternalX86GetApicBase ( + VOID + ) +{ + return (UINTN)AsmMsrBitFieldRead64 (27, 12, 35) << 12; +} + +/** + Internal function to return the frequency of the local APIC timer. + + Internal function to return the frequency of the local APIC timer. + + @param ApicBase The base address of memory mapped registers of local APIC. + + @return The frequency of the timer in Hz. + +**/ +STATIC +UINT32 +InternalX86GetTimerFrequency ( + IN UINTN ApicBase + ) +{ + return + mTimerLibLocalApicFrequencies[AsmMsrBitFieldRead32 (44, 16, 18)] / + mTimerLibLocalApicDivisor[MmioBitFieldRead32 (ApicBase + 0x3e0, 0, 3)]; +} + +/** + Internal function to read the current tick counter of local APIC. + + Internal function to read the current tick counter of local APIC. + + @param ApicBase The base address of memory mapped registers of local APIC. + + @return The tick counter read. + +**/ +STATIC +INT32 +InternalX86GetTimerTick ( + IN UINTN ApicBase + ) +{ + return MmioRead32 (ApicBase + 0x390); +} + +/** + Stalls the CPU for at least the given number of ticks. + + Stalls the CPU for at least the given number of ticks. It's invoked by + MicroSecondDelay() and NanoSecondDelay(). + + @param ApicBase The base address of memory mapped registers of local APIC. + @param Delay A period of time to delay in ticks. + +**/ +STATIC +VOID +InternalX86Delay ( + IN UINTN ApicBase, + IN UINT32 Delay + ) +{ + INT32 Ticks; + + // + // The target timer count is calculated here + // + Ticks = InternalX86GetTimerTick (ApicBase) - Delay; + + // + // Wait until time out + // Delay > 2^31 could not be handled by this function + // Timer wrap-arounds are handled correctly by this function + // + while (InternalX86GetTimerTick (ApicBase) - Ticks >= 0); +} + +/** + Stalls the CPU for at least the given number of microseconds. + + Stalls the CPU for the number of microseconds specified by MicroSeconds. + + @param MicroSeconds The minimum number of microseconds to delay. + + @return MicroSeconds + +**/ +UINTN +EFIAPI +MicroSecondDelay ( + IN UINTN MicroSeconds + ) +{ + UINTN ApicBase; + + ApicBase = InternalX86GetApicBase (); + InternalX86Delay ( + ApicBase, + (UINT32)DivU64x32 ( + MultU64x64 ( + InternalX86GetTimerFrequency (ApicBase), + MicroSeconds + ), + 1000000u + ) + ); + return MicroSeconds; +} + +/** + Stalls the CPU for at least the given number of nanoseconds. + + Stalls the CPU for the number of nanoseconds specified by NanoSeconds. + + @param NanoSeconds The minimum number of nanoseconds to delay. + + @return NanoSeconds + +**/ +UINTN +EFIAPI +NanoSecondDelay ( + IN UINTN NanoSeconds + ) +{ + UINTN ApicBase; + + ApicBase = InternalX86GetApicBase (); + InternalX86Delay ( + ApicBase, + (UINT32)DivU64x32 ( + MultU64x64 ( + InternalX86GetTimerFrequency (ApicBase), + NanoSeconds + ), + 1000000000u + ) + ); + return NanoSeconds; +} + +/** + Retrieves the current value of a 64-bit free running performance counter. + + Retrieves the current value of a 64-bit free running performance counter. The + counter can either count up by 1 or count down by 1. If the physical + performance counter counts by a larger increment, then the counter values + must be translated. The properties of the counter can be retrieved from + GetPerformanceCounterProperties(). + + @return The current value of the free running performance counter. + +**/ +UINT64 +EFIAPI +GetPerformanceCounter ( + VOID + ) +{ + return (UINT32)InternalX86GetTimerTick (InternalX86GetApicBase ()); +} + +/** + Retrieves the 64-bit frequency in Hz and the range of performance counter + values. + + If StartValue is not NULL, then the value that the performance counter starts + with immediately after is it rolls over is returned in StartValue. If + EndValue is not NULL, then the value that the performance counter end with + immediately before it rolls over is returned in EndValue. The 64-bit + frequency of the performance counter in Hz is always returned. If StartValue + is less than EndValue, then the performance counter counts up. If StartValue + is greater than EndValue, then the performance counter counts down. For + example, a 64-bit free running counter that counts up would have a StartValue + of 0 and an EndValue of 0xFFFFFFFFFFFFFFFF. A 24-bit free running counter + that counts down would have a StartValue of 0xFFFFFF and an EndValue of 0. + + @param StartValue The value the performance counter starts with when it + rolls over. + @param EndValue The value that the performance counter ends with before + it rolls over. + + @return The frequency in Hz. + +**/ +UINT64 +EFIAPI +GetPerformanceCounterProperties ( + IN UINT64 *StartValue, + IN UINT64 *EndValue + ) +{ + UINTN ApicBase; + + ApicBase = InternalX86GetApicBase (); + + if (StartValue != NULL) { + *StartValue = MmioRead32 (ApicBase + 0x380); + } + + if (EndValue != NULL) { + *EndValue = 0; + } + + return InternalX86GetTimerFrequency (ApicBase); +} + +/** + Retrieves current APIC ID. + + @return UINT32 value of APIC ID + +**/ +UINT32 +GetApicId ( + VOID + ) +{ + UINT32 ApicId; + BOOLEAN x2ApicEnabled; + UINT64 LocalApicBase; + + x2ApicEnabled = (BOOLEAN) (((AsmReadMsr64 (PcdGet16(XAPICBaseMsr))) & (0x0C00)) == 0x0C00); + if (x2ApicEnabled) { + ApicId = (UINT32) AsmReadMsr64 (PcdGet32(ExtXAPICLogicalAPICIdMsr)); + } else { + LocalApicBase = ((UINT32) AsmReadMsr64 (PcdGet16(XAPICBaseMsr))) & 0xFFFFF000; + ApicId = (UINT8) (*(volatile UINT32 *) (UINTN) (LocalApicBase + 0x20) >> 24); + } + + return ApicId; +}
\ No newline at end of file diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseTimerLibTsc/BaseTimerLibTsc.inf b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseTimerLibTsc/BaseTimerLibTsc.inf new file mode 100644 index 0000000..4979885 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseTimerLibTsc/BaseTimerLibTsc.inf @@ -0,0 +1,78 @@ +#/*++ +# +# Copyright (c) 2011, 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: +# +# EdkIIGlueBaseTimerLibTsc.inf +# +# Abstract: +# +# Component description file for BaseTimerLibTsc. +# +#--*/ + +[defines] +BASE_NAME = EdkIIGlueBaseTimerLibTsc +COMPONENT_TYPE = LIBRARY + +[sources.common] + TimerLibTsc.c + +[sources.ia32] + +[sources.x64] + +[sources.ipf] + + +[sources.ebc] + + +[includes.common] + . + ..\..\Include + ..\..\include\Library + $(EDK_SOURCE)\Foundation + $(EDK_SOURCE)\Foundation\Framework + $(EDK_SOURCE)\Foundation\Efi + $(EDK_SOURCE)\Foundation\Include + $(EDK_SOURCE)\Foundation\Efi\Include + $(EDK_SOURCE)\Foundation\Framework\Include + $(EDK_SOURCE)\Foundation\Include\IndustryStandard + $(EDK_SOURCE)\Foundation\Core\Dxe + $(EDK_SOURCE)\Foundation\Library\Dxe\Include + $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include + $(EDK_SOURCE)\Foundation\Guid\PeiPeCoffLoader + + +[libraries.common] + +[libraries.ia32] + + +[libraries.x64] + + +[nmake.common] + C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION + LIB_STD_FLAGS = /NOLOGO /IGNORE:4006 + +[nmake.ia32] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32 + +[nmake.x64] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64 + +[nmake.ipf] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF + +[nmake.ebc] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_EBC
\ No newline at end of file diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseTimerLibTsc/EdkIIGlueBaseTimerLibTsc.cif b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseTimerLibTsc/EdkIIGlueBaseTimerLibTsc.cif new file mode 100644 index 0000000..d65f67f --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseTimerLibTsc/EdkIIGlueBaseTimerLibTsc.cif @@ -0,0 +1,11 @@ +<component> + name = "EdkIIGlueBaseTimerLibTsc" + category = ModulePart + LocalRoot = "Edk\Foundation\Library\EdkIIGlueLib\Library\BaseTimerLibTsc" + RefName = "EdkIIGlueBaseTimerLibTsc" +[files] +"EdkIIGlueBaseTimerLibTsc.sdl" +"EdkIIGlueBaseTimerLibTsc.mak" +"BaseTimerLibTsc.inf" +"TimerLibTsc.c" +<endComponent> diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseTimerLibTsc/EdkIIGlueBaseTimerLibTsc.mak b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseTimerLibTsc/EdkIIGlueBaseTimerLibTsc.mak new file mode 100644 index 0000000..81102d1 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseTimerLibTsc/EdkIIGlueBaseTimerLibTsc.mak @@ -0,0 +1,78 @@ +#********************************************************************** +#********************************************************************** +#** ** +#** (C)Copyright 1985-2011, American Megatrends, Inc. ** +#** ** +#** All Rights Reserved. ** +#** ** +#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +#** ** +#** Phone: (770)-246-8600 ** +#** ** +#********************************************************************** +#********************************************************************** + +#********************************************************************** +# $Header: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGlueBaseTimerLibTsc/EdkIIGlueBaseTimerLibTsc.mak 1 1/20/12 3:59a Jeffch $ +# +# $Revision: 1 $ +# +# $Date: 1/20/12 3:59a $ +#********************************************************************** +# Revision History +# ---------------- +# $Log: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGlueBaseTimerLibTsc/EdkIIGlueBaseTimerLibTsc.mak $ +# +# 1 1/20/12 3:59a Jeffch +# +# 1 9/27/11 6:21a Wesleychen +# Intel EDK initially releases. +# +# +#********************************************************************** +#<AMI_FHDR_START> +# +# Name: EdkIIGlueBaseTimerLibTsc.mak +# +# Description: +# +#<AMI_FHDR_END> +#********************************************************************** + + +$(EdkIIGlueBaseTimerLibTsc_LIB) : EdkIIGlueBaseTimerLibTsc + +EdkIIGlueBaseTimerLibTsc : $(BUILD_DIR)\EdkIIGlueBaseTimerLibTsc.mak EdkIIGlueBaseTimerLibTscBin + +$(BUILD_DIR)\EdkIIGlueBaseTimerLibTsc.mak : $(EdkIIGlueBaseTimerLibTsc_DIR)\$(@B).cif $(EdkIIGlueBaseTimerLibTsc_DIR)\$(@B).mak $(BUILD_RULES) + $(CIF2MAK) $(EdkIIGlueBaseTimerLibTsc_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS) + +EdkIIGlueBaseTimerLibTscBin : $(EFIPROTOCOLLIB) $(EDKGUIDLIB) $(ARCHPROTOCOLLIB) +!IF "$(x64_BUILD)"=="1" + $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\ + BUILD_DIR=$(BUILD_DIR)\ + /f $(BUILD_DIR)\EdkIIGlueBaseTimerLibTsc.mak all\ + TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueBaseTimerLibTsc_LIB)" + $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\ + BUILD_DIR=$(BUILD_DIR)\IA32\ + /f $(BUILD_DIR)\EdkIIGlueBaseTimerLibTsc.mak all\ + TYPE=PEI_LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueBaseTimerLibTsc_LIB)" +!ELSE + $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\ + BUILD_DIR=$(BUILD_DIR)\ + /f $(BUILD_DIR)\EdkIIGlueBaseTimerLibTsc.mak all\ + TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueBaseTimerLibTsc_LIB)" +!ENDIF +#********************************************************************** +#********************************************************************** +#** ** +#** (C)Copyright 1985-2011, American Megatrends, Inc. ** +#** ** +#** All Rights Reserved. ** +#** ** +#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +#** ** +#** Phone: (770)-246-8600 ** +#** ** +#********************************************************************** +#**********************************************************************
\ No newline at end of file diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseTimerLibTsc/EdkIIGlueBaseTimerLibTsc.sdl b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseTimerLibTsc/EdkIIGlueBaseTimerLibTsc.sdl new file mode 100644 index 0000000..6a8b42d --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseTimerLibTsc/EdkIIGlueBaseTimerLibTsc.sdl @@ -0,0 +1,26 @@ +TOKEN + Name = "EdkIIGlueBaseTimerLibTsc_SUPPORT" + Value = "1" + Help = "Main switch to enable EdkIIGlueBaseTimerLibTsc support in Project" + TokenType = Boolean + TargetEQU = Yes + TargetMAK = Yes + Master = Yes +End + +TOKEN + Name = "EdkIIGlueBaseTimerLibTsc_LIB" + Value = "$$(LIB_BUILD_DIR)\EdkIIGlueBaseTimerLibTsc.lib" + TokenType = Expression + TargetMAK = Yes +End + +PATH + Name = "EdkIIGlueBaseTimerLibTsc_DIR" +End + +MODULE + Help = "Includes EdkIIGlueBaseTimerLibTsc.mak to Project" + File = "EdkIIGlueBaseTimerLibTsc.mak" +End + diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseTimerLibTsc/TimerLibTsc.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseTimerLibTsc/TimerLibTsc.c new file mode 100644 index 0000000..7860d8d --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseTimerLibTsc/TimerLibTsc.c @@ -0,0 +1,46 @@ +/*++ + +Copyright (c) 2011, 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: + + TimerLibTsc.c + +Abstract: + + Timer Library based on TSC timer. + +--*/ + +#include "EdkIIGlueBase.h" + +/** + Converts TSC value into nano second value. + + @param Timestamp TSC ticker + + @return UINT64 value in naosecond unit converted from TSC + +**/ +UINT64 +EFIAPI +GetTimeInNanoSec ( + UINT64 Timestamp + ) +{ + UINT64 pi; + UINT8 Ratio; + + pi = AsmReadMsr64 (PcdGet16(PlatformInfoMsr)); + Ratio = (UINT8) (((UINT32) (UINTN) RShiftU64 (pi, 8)) & 0xff); + + return (UINT64) DivU64x32 (MultU64x32 (Timestamp, 10), (UINT32) (Ratio)); +} diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseUefiDecompressLib/BaseUefiDecompressLib.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseUefiDecompressLib/BaseUefiDecompressLib.c new file mode 100644 index 0000000..72a64b5 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseUefiDecompressLib/BaseUefiDecompressLib.c @@ -0,0 +1,892 @@ +/*++ + +Copyright (c) 2004 - 2011, 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: + + BaseUefiDecompressLib.c + +Abstract: + + UEFI Decompress Library. + +--*/ + +#include "EdkIIGlueBase.h" + +// +// Decompression algorithm begins here +// +#define BITBUFSIZ 32 +#define MAXMATCH 256 +#define THRESHOLD 3 +#define CODE_BIT 16 +#define BAD_TABLE - 1 + +// +// C: Char&Len Set; P: Position Set; T: exTra Set +// +#define NC (0xff + MAXMATCH + 2 - THRESHOLD) +#define CBIT 9 +#define MAXPBIT 5 +#define TBIT 5 +#define MAXNP ((1U << MAXPBIT) - 1) +#define NT (CODE_BIT + 3) +#if NT > MAXNP +#define NPT NT +#else +#define NPT MAXNP +#endif + +typedef struct { + UINT8 *mSrcBase; ///< Starting address of compressed data + UINT8 *mDstBase; ///< Starting address of decompressed data + UINT32 mOutBuf; + UINT32 mInBuf; + + UINT16 mBitCount; + UINT32 mBitBuf; + UINT32 mSubBitBuf; + UINT16 mBlockSize; + UINT32 mCompSize; + UINT32 mOrigSize; + + UINT16 mBadTableFlag; + + UINT16 mLeft[2 * NC - 1]; + UINT16 mRight[2 * NC - 1]; + UINT8 mCLen[NC]; + UINT8 mPTLen[NPT]; + UINT16 mCTable[4096]; + UINT16 mPTTable[256]; + + /// + /// The length of the field 'Position Set Code Length Array Size' in Block Header. + /// For EFI 1.1 de/compression algorithm, mPBit = 4 + /// For Tiano de/compression algorithm, mPBit = 5 + /// + UINT8 mPBit; +} SCRATCH_DATA; + +/** + Read NumOfBit of bits from source into mBitBuf + + Shift mBitBuf NumOfBits left. Read in NumOfBits of bits from source. + + @param Sd The global scratch data + @param NumOfBits The number of bits to shift and read. + +**/ +VOID +GlueFillBuf ( + IN SCRATCH_DATA *Sd, + IN UINT16 NumOfBits + ) +{ + // + // Left shift NumOfBits of bits in advance + // + Sd->mBitBuf = (UINT32) (Sd->mBitBuf << NumOfBits); + + // + // Copy data needed in bytes into mSbuBitBuf + // + while (NumOfBits > Sd->mBitCount) { + + Sd->mBitBuf |= (UINT32) (Sd->mSubBitBuf << (NumOfBits = (UINT16) (NumOfBits - Sd->mBitCount))); + + if (Sd->mCompSize > 0) { + // + // Get 1 byte into SubBitBuf + // + Sd->mCompSize--; + Sd->mSubBitBuf = Sd->mSrcBase[Sd->mInBuf++]; + Sd->mBitCount = 8; + + } else { + // + // No more bits from the source, just pad zero bit. + // + Sd->mSubBitBuf = 0; + Sd->mBitCount = 8; + + } + } + + // + // Caculate additional bit count read to update mBitCount + // + Sd->mBitCount = (UINT16) (Sd->mBitCount - NumOfBits); + + // + // Copy NumOfBits of bits from mSubBitBuf into mBitBuf + // + Sd->mBitBuf |= Sd->mSubBitBuf >> Sd->mBitCount; +} + +/** + Get NumOfBits of bits out from mBitBuf + + Get NumOfBits of bits out from mBitBuf. Fill mBitBuf with subsequent + NumOfBits of bits from source. Returns NumOfBits of bits that are + popped out. + + @param Sd The global scratch data. + @param NumOfBits The number of bits to pop and read. + + @return The bits that are popped out. + +**/ +UINT32 +GlueGetBits ( + IN SCRATCH_DATA *Sd, + IN UINT16 NumOfBits + ) +{ + UINT32 OutBits; + + // + // Pop NumOfBits of Bits from Left + // + OutBits = (UINT32) (Sd->mBitBuf >> (BITBUFSIZ - NumOfBits)); + + // + // Fill up mBitBuf from source + // + FillBuf (Sd, NumOfBits); + + return OutBits; +} + +/** + Creates Huffman Code mapping table according to code length array. + + Creates Huffman Code mapping table for Extra Set, Char&Len Set + and Position Set according to code length array. + + @param Sd The global scratch data + @param NumOfChar Number of symbols in the symbol set + @param BitLen Code length array + @param TableBits The width of the mapping table + @param Table The table + + @retval 0 OK. + @retval BAD_TABLE The table is corrupted. + +**/ +UINT16 +GlueMakeTable ( + IN SCRATCH_DATA *Sd, + IN UINT16 NumOfChar, + IN UINT8 *BitLen, + IN UINT16 TableBits, + OUT UINT16 *Table + ) +{ + UINT16 Count[17]; + UINT16 Weight[17]; + UINT16 Start[18]; + UINT16 *Pointer; + UINT16 Index3; + volatile UINT16 Index; + UINT16 Len; + UINT16 Char; + UINT16 JuBits; + UINT16 Avail; + UINT16 NextCode; + UINT16 Mask; + + // + // TableBits should not be greater than 16. + // + if (TableBits >= (sizeof (Count)/sizeof (UINT16))) { + return (UINT16) BAD_TABLE; + } + + // + // Initializing Start + // + for (Index = 0; Index <= 17; Index++) { + Start[Index] = 0; + } + + // + // Initialize Count array starting from Index 0, as there is a possibility of Count array being uninitialized. + // + for (Index = 0; Index <= 16; Index++) { + Count[Index] = 0; + } + + for (Index = 0; Index < NumOfChar; Index++) { + // + // Count array index should not be greater than or equal to its size. + // + if (BitLen[Index] < (sizeof (Count)/sizeof (UINT16))) { + Count[BitLen[Index]]++; + } else { + return (UINT16) BAD_TABLE; + } + } + + Start[1] = 0; + + for (Index = 1; Index <= 16; Index++) { + Start[Index + 1] = (UINT16) (Start[Index] + (Count[Index] << (16 - Index))); + } + + if (Start[17] != 0) { + /*(1U << 16)*/ + return (UINT16) BAD_TABLE; + } + + JuBits = (UINT16) (16 - TableBits); + + for (Index = 1; Index <= TableBits; Index++) { + Start[Index] >>= JuBits; + Weight[Index] = (UINT16) (1U << (TableBits - Index)); + } + + while (Index <= 16) { + Weight[Index] = (UINT16) (1U << (16 - Index)); + Index++; + } + + Index = (UINT16) (Start[TableBits + 1] >> JuBits); + + if (Index != 0) { + Index3 = (UINT16) (1U << TableBits); + while (Index != Index3) { + Table[Index++] = 0; + } + } + + Avail = NumOfChar; + Mask = (UINT16) (1U << (15 - TableBits)); + + for (Char = 0; Char < NumOfChar; Char++) { + + Len = BitLen[Char]; + if (Len == 0) { + continue; + } + + NextCode = (UINT16) (Start[Len] + Weight[Len]); + + if (Len <= TableBits) { + + for (Index = Start[Len]; Index < NextCode; Index++) { + Table[Index] = Char; + } + + } else { + + Index3 = Start[Len]; + Pointer = &Table[Index3 >> JuBits]; + Index = (UINT16) (Len - TableBits); + + while (Index != 0) { + // + // Avail should be lesser than size of mRight and mLeft to prevent buffer overflow. + // + if ((*Pointer == 0) && (Avail < sizeof (Sd->mRight)/sizeof (UINT16)) && (Avail < sizeof (Sd->mLeft)/sizeof (UINT16))) { + Sd->mRight[Avail] = Sd->mLeft[Avail] = 0; + *Pointer = Avail++; + } + + // + // *Pointer should be lesser than size of mRight and mLeft to prevent buffer overflow. + // + if ((Index3 & Mask) && (*Pointer < (sizeof (Sd->mRight)/sizeof (UINT16)))) { + Pointer = &Sd->mRight[*Pointer]; + } else if (*Pointer < (sizeof (Sd->mLeft)/sizeof (UINT16))) { + Pointer = &Sd->mLeft[*Pointer]; + } + + Index3 <<= 1; + Index--; + } + + *Pointer = Char; + + } + + Start[Len] = NextCode; + } + // + // Succeeds + // + return 0; +} + +/** + Decodes a position value. + + Get a position value according to Position Huffman Table. + + @param Sd the global scratch data + + @return The position value decoded. + +**/ +UINT32 +GlueDecodeP ( + IN SCRATCH_DATA *Sd + ) +{ + UINT16 Val; + UINT32 Mask; + UINT32 Pos; + + Val = Sd->mPTTable[Sd->mBitBuf >> (BITBUFSIZ - 8)]; + + if (Val >= MAXNP) { + Mask = 1U << (BITBUFSIZ - 1 - 8); + + do { + + if (Sd->mBitBuf & Mask) { + Val = Sd->mRight[Val]; + } else { + Val = Sd->mLeft[Val]; + } + + Mask >>= 1; + } while (Val >= MAXNP); + } + // + // Advance what we have read + // + FillBuf (Sd, Sd->mPTLen[Val]); + + Pos = Val; + if (Val > 1) { + Pos = (UINT32) ((1U << (Val - 1)) + GetBits (Sd, (UINT16) (Val - 1))); + } + + return Pos; +} + +/** + Reads code lengths for the Extra Set or the Position Set. + + Read in the Extra Set or Pointion Set Length Arrary, then + generate the Huffman code mapping for them. + + @param Sd The global scratch data. + @param nn Number of symbols. + @param nbit Number of bits needed to represent nn. + @param Special The special symbol that needs to be taken care of. + + @retval 0 OK. + @retval BAD_TABLE Table is corrupted. + +**/ +UINT16 +GlueReadPTLen ( + IN SCRATCH_DATA *Sd, + IN UINT16 nn, + IN UINT16 nbit, + IN UINT16 Special + ) +{ + UINT16 Number; + UINT16 CharC; + volatile UINT16 Index; + UINT32 Mask; + + // + // Read Extra Set Code Length Array size + // + Number = (UINT16) GetBits (Sd, nbit); + + if ((Number > sizeof (Sd->mPTLen)) || (nn > sizeof (Sd->mPTLen))) { + // + // Fail if Number or nn is greater than size of mPTLen + // + return (UINT16) BAD_TABLE; + } + + if (Number == 0) { + // + // This represents only Huffman code used + // + CharC = (UINT16) GetBits (Sd, nbit); + + for (Index = 0; Index < 256; Index++) { + Sd->mPTTable[Index] = CharC; + } + + for (Index = 0; Index < nn; Index++) { + Sd->mPTLen[Index] = 0; + } + + return 0; + } + + Index = 0; + + while (Index < Number) { + + CharC = (UINT16) (Sd->mBitBuf >> (BITBUFSIZ - 3)); + + // + // If a code length is less than 7, then it is encoded as a 3-bit + // value. Or it is encoded as a series of "1"s followed by a + // terminating "0". The number of "1"s = Code length - 4. + // + if (CharC == 7) { + Mask = 1U << (BITBUFSIZ - 1 - 3); + while (Mask & Sd->mBitBuf) { + Mask >>= 1; + CharC += 1; + } + } + + FillBuf (Sd, (UINT16) ((CharC < 7) ? 3 : CharC - 3)); + + Sd->mPTLen[Index++] = (UINT8) CharC; + + // + // For Code&Len Set, + // After the third length of the code length concatenation, + // a 2-bit value is used to indicated the number of consecutive + // zero lengths after the third length. + // + if (Index == Special) { + CharC = (UINT16) GetBits (Sd, 2); + while ((INT16) (--CharC) >= 0) { + if (Index >= sizeof (Sd->mPTLen)) { + // + // Fail if Index is greater than or equal to mPTLen + // + return (UINT16) BAD_TABLE; + } + Sd->mPTLen[Index++] = 0; + } + } + } + + while (Index < nn) { + Sd->mPTLen[Index++] = 0; + } + + return MakeTable (Sd, nn, Sd->mPTLen, 8, Sd->mPTTable); +} + +/** + Reads code lengths for Char&Len Set. + + Read in and decode the Char&Len Set Code Length Array, then + generate the Huffman Code mapping table for the Char&Len Set. + + @param Sd the global scratch data + +**/ +VOID +GlueReadCLen ( + SCRATCH_DATA *Sd + ) +{ + UINT16 Number; + UINT16 CharC; + volatile UINT16 Index; + UINT32 Mask; + + Number = (UINT16) GetBits (Sd, CBIT); + + if (Number == 0) { + // + // This represents only Huffman code used + // + CharC = (UINT16) GetBits (Sd, CBIT); + + for (Index = 0; Index < NC; Index++) { + Sd->mCLen[Index] = 0; + } + + for (Index = 0; Index < 4096; Index++) { + Sd->mCTable[Index] = CharC; + } + + return ; + } + + Index = 0; + while (Index < Number) { + CharC = Sd->mPTTable[Sd->mBitBuf >> (BITBUFSIZ - 8)]; + if (CharC >= NT) { + Mask = 1U << (BITBUFSIZ - 1 - 8); + + do { + + if (Mask & Sd->mBitBuf) { + CharC = Sd->mRight[CharC]; + } else { + CharC = Sd->mLeft[CharC]; + } + + Mask >>= 1; + + } while (CharC >= NT); + } + // + // Advance what we have read + // + FillBuf (Sd, Sd->mPTLen[CharC]); + + if (CharC <= 2) { + + if (CharC == 0) { + CharC = 1; + } else if (CharC == 1) { + CharC = (UINT16) (GetBits (Sd, 4) + 3); + } else if (CharC == 2) { + CharC = (UINT16) (GetBits (Sd, CBIT) + 20); + } + + while ((INT16) (--CharC) >= 0) { + Sd->mCLen[Index++] = 0; + } + + } else { + + Sd->mCLen[Index++] = (UINT8) (CharC - 2); + + } + } + + while (Index < NC) { + Sd->mCLen[Index++] = 0; + } + + MakeTable (Sd, NC, Sd->mCLen, 12, Sd->mCTable); + + return ; +} + +/** + Decode a character/length value. + + Read one value from mBitBuf, Get one code from mBitBuf. If it is at block boundary, generates + Huffman code mapping table for Extra Set, Code&Len Set and + Position Set. + + @param Sd The global scratch data. + + @return The value decoded. + +**/ +UINT16 +GlueDecodeC ( + SCRATCH_DATA *Sd + ) +{ + UINT16 Index2; + UINT32 Mask; + + if (Sd->mBlockSize == 0) { + // + // Starting a new block + // Read BlockSize from block header + // + Sd->mBlockSize = (UINT16) GetBits (Sd, 16); + + // + // Read in the Extra Set Code Length Arrary, + // Generate the Huffman code mapping table for Extra Set. + // + Sd->mBadTableFlag = ReadPTLen (Sd, NT, TBIT, 3); + if (Sd->mBadTableFlag != 0) { + return 0; + } + + // + // Read in and decode the Char&Len Set Code Length Arrary, + // Generate the Huffman code mapping table for Char&Len Set. + // + ReadCLen (Sd); + + // + // Read in the Position Set Code Length Arrary, + // Generate the Huffman code mapping table for the Position Set. + // + Sd->mBadTableFlag = ReadPTLen (Sd, MAXNP, Sd->mPBit, (UINT16) (-1)); + if (Sd->mBadTableFlag != 0) { + return 0; + } + } + + // + // Get one code according to Code&Set Huffman Table + // + Sd->mBlockSize--; + Index2 = Sd->mCTable[Sd->mBitBuf >> (BITBUFSIZ - 12)]; + + if (Index2 >= NC) { + Mask = 1U << (BITBUFSIZ - 1 - 12); + + do { + if (Sd->mBitBuf & Mask) { + Index2 = Sd->mRight[Index2]; + } else { + Index2 = Sd->mLeft[Index2]; + } + + Mask >>= 1; + } while (Index2 >= NC); + } + // + // Advance what we have read + // + FillBuf (Sd, Sd->mCLen[Index2]); + + return Index2; +} + +/** + Decode the source data and put the resulting data into the destination buffer. + + Decode the source data and put the resulting data into the destination buffer. + + @param Sd The global scratch data + +**/ +VOID +GlueDecode ( + SCRATCH_DATA *Sd + ) +{ + UINT16 BytesRemain; + UINT32 DataIdx; + UINT16 CharC; + + BytesRemain = (UINT16) (-1); + + DataIdx = 0; + + for (;;) { + // + // Get one code from mBitBuf + // + CharC = DecodeC (Sd); + if (Sd->mBadTableFlag != 0) { + return ; + } + + if (CharC < 256) { + // + // Process an Original character + // + if (Sd->mOutBuf >= Sd->mOrigSize) { + return ; + } else { + // + // Write orignal character into mDstBase + // + Sd->mDstBase[Sd->mOutBuf++] = (UINT8) CharC; + } + + } else { + // + // Process a Pointer + // + CharC = (UINT16) (CharC - (UINT8_MAX + 1 - THRESHOLD)); + + // + // Get string length + // + BytesRemain = CharC; + + // + // Locate string position + // + DataIdx = Sd->mOutBuf - DecodeP (Sd) - 1; + + // + // Write BytesRemain of bytes into mDstBase + // + BytesRemain--; + while ((INT16) (BytesRemain) >= 0) { + Sd->mDstBase[Sd->mOutBuf++] = Sd->mDstBase[DataIdx++]; + if (Sd->mOutBuf >= Sd->mOrigSize) { + return ; + } + + BytesRemain--; + } + } + } + + return ; +} + +/** + Retrieves the size of the uncompressed buffer and the size of the scratch buffer. + + Retrieves the size of the uncompressed buffer and the temporary scratch buffer + required to decompress the buffer specified by Source and SourceSize. + If the size of the uncompressed buffer or the size of the scratch buffer cannot + be determined from the compressed data specified by Source and SourceData, + then RETURN_INVALID_PARAMETER is returned. Otherwise, the size of the uncompressed + buffer is returned in DestinationSize, the size of the scratch buffer is returned + in ScratchSize, and RETURN_SUCCESS is returned. + This function does not have scratch buffer available to perform a thorough + checking of the validity of the source data. It just retrieves the "Original Size" + field from the beginning bytes of the source data and output it as DestinationSize. + And ScratchSize is specific to the decompression implementation. + + If Source is NULL, then ASSERT(). + If DestinationSize is NULL, then ASSERT(). + If ScratchSize is NULL, then ASSERT(). + + @param Source The source buffer containing the compressed data. + @param SourceSize The size, in bytes, of the source buffer. + @param DestinationSize A pointer to the size, in bytes, of the uncompressed buffer + that will be generated when the compressed buffer specified + by Source and SourceSize is decompressed.. + @param ScratchSize A pointer to the size, in bytes, of the scratch buffer that + is required to decompress the compressed buffer specified + by Source and SourceSize. + + @retval RETURN_SUCCESS The size of destination buffer and the size of scratch + buffer are successull retrieved. + @retval RETURN_INVALID_PARAMETER The source data is corrupted + +**/ +RETURN_STATUS +EFIAPI +UefiDecompressGetInfo ( + IN CONST VOID *Source, + IN UINT32 SourceSize, + OUT UINT32 *DestinationSize, + OUT UINT32 *ScratchSize + ) +{ + UINT32 CompressedSize; + + ASSERT (Source != NULL); + ASSERT (DestinationSize != NULL); + ASSERT (ScratchSize != NULL); + + *ScratchSize = sizeof (SCRATCH_DATA); + + if (SourceSize < 8) { + return RETURN_INVALID_PARAMETER; + } + + CopyMem (&CompressedSize, Source, sizeof (UINT32)); + CopyMem (DestinationSize, (VOID *)((UINT8 *)Source + 4), sizeof (UINT32)); + + if (SourceSize < (CompressedSize + 8)) { + return RETURN_INVALID_PARAMETER; + } + + return RETURN_SUCCESS; +} + +/** + Decompresses a compressed source buffer. + + This function is designed so that the decompression algorithm can be implemented + without using any memory services. As a result, this function is not allowed to + call any memory allocation services in its implementation. It is the caller¡¯s r + esponsibility to allocate and free the Destination and Scratch buffers. + If the compressed source data specified by Source is sucessfully decompressed + into Destination, then RETURN_SUCCESS is returned. If the compressed source data + specified by Source is not in a valid compressed data format, + then RETURN_INVALID_PARAMETER is returned. + + If Source is NULL, then ASSERT(). + If Destination is NULL, then ASSERT(). + If the required scratch buffer size > 0 and Scratch is NULL, then ASSERT(). + + @param Source The source buffer containing the compressed data. + @param Destination The destination buffer to store the decompressed data + @param Scratch A temporary scratch buffer that is used to perform the decompression. + This is an optional parameter that may be NULL if the + required scratch buffer size is 0. + + @retval RETURN_SUCCESS Decompression is successfull + @retval RETURN_INVALID_PARAMETER The source data is corrupted + +**/ +RETURN_STATUS +EFIAPI +UefiDecompress ( + IN CONST VOID *Source, + IN OUT VOID *Destination, + IN OUT VOID *Scratch + ) +{ + volatile UINT32 Index; + UINT32 CompSize; + UINT32 OrigSize; + SCRATCH_DATA *Sd; + CONST UINT8 *Src; + UINT8 *Dst; + + ASSERT (Source != NULL); + ASSERT (Destination != NULL); + ASSERT (Scratch != NULL); + + Src = Source; + Dst = Destination; + + Sd = (SCRATCH_DATA *) Scratch; + + CompSize = Src[0] + (Src[1] << 8) + (Src[2] << 16) + (Src[3] << 24); + OrigSize = Src[4] + (Src[5] << 8) + (Src[6] << 16) + (Src[7] << 24); + + // + // If compressed file size is 0, return + // + if (OrigSize == 0) { + return RETURN_SUCCESS; + } + + Src = Src + 8; + + for (Index = 0; Index < sizeof (SCRATCH_DATA); Index++) { + ((UINT8 *) Sd)[Index] = 0; + } + // + // The length of the field 'Position Set Code Length Array Size' in Block Header. + // For EFI 1.1 de/compression algorithm(Version 1), mPBit = 4 + // For Tiano de/compression algorithm(Version 2), mPBit = 5 + // + Sd->mPBit = 4; + Sd->mSrcBase = (UINT8 *)Src; + Sd->mDstBase = Dst; + // + // CompSize and OrigSize are caculated in bytes + // + Sd->mCompSize = CompSize; + Sd->mOrigSize = OrigSize; + + // + // Fill the first BITBUFSIZ bits + // + FillBuf (Sd, BITBUFSIZ); + + // + // Decompress it + // + Decode (Sd); + + if (Sd->mBadTableFlag != 0) { + // + // Something wrong with the source + // + return RETURN_INVALID_PARAMETER; + } + + return RETURN_SUCCESS; +} diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseUefiDecompressLib/BaseUefiDecompressLib.inf b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseUefiDecompressLib/BaseUefiDecompressLib.inf new file mode 100644 index 0000000..7d2db1f --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseUefiDecompressLib/BaseUefiDecompressLib.inf @@ -0,0 +1,76 @@ +#/*++ +# +# 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: +# +# BaseUefiDecompressLib.inf +# +# Abstract: +# +# Component description file for BaseUefiDecompressLib. +# +#--*/ + +[defines] +BASE_NAME = EdkIIGlueBaseUefiDecompressLib +COMPONENT_TYPE = LIBRARY + +[sources.common] + BaseUefiDecompressLib.c + +[sources.ia32] + +[sources.x64] + +[sources.ipf] + +[sources.ebc] + + +[includes.common] + . + ..\..\Include + ..\..\include\Library + $(EDK_SOURCE)\Foundation + $(EDK_SOURCE)\Foundation\Framework + $(EDK_SOURCE)\Foundation\Efi + $(EDK_SOURCE)\Foundation\Include + $(EDK_SOURCE)\Foundation\Efi\Include + $(EDK_SOURCE)\Foundation\Framework\Include + $(EDK_SOURCE)\Foundation\Include\IndustryStandard + $(EDK_SOURCE)\Foundation\Core\Dxe + $(EDK_SOURCE)\Foundation\Library\Dxe\Include + $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include + +[libraries.common] + EdkIIGlueBaseMemoryLib + +[libraries.ia32] + + +[libraries.x64] + + +[nmake.common] + C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION + LIB_STD_FLAGS = /NOLOGO /IGNORE:4006 + +[nmake.ia32] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32 + +[nmake.x64] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64 + +[nmake.ipf] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF + +[nmake.ebc] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_EBC
\ No newline at end of file diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseUefiDecompressLib/EdkIIGlueBaseUefiDecompressLib.cif b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseUefiDecompressLib/EdkIIGlueBaseUefiDecompressLib.cif new file mode 100644 index 0000000..184d5b6 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseUefiDecompressLib/EdkIIGlueBaseUefiDecompressLib.cif @@ -0,0 +1,11 @@ +<component> + name = "EdkIIGlueBaseUefiDecompressLib" + category = ModulePart + LocalRoot = "Edk\Foundation\Library\EdkIIGlueLib\Library\BaseUefiDecompressLib" + RefName = "EdkIIGlueBaseUefiDecompressLib" +[files] +"EdkIIGlueBaseUefiDecompressLib.sdl" +"EdkIIGlueBaseUefiDecompressLib.mak" +"BaseUefiDecompressLib.inf" +"BaseUefiDecompressLib.c" +<endComponent> diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseUefiDecompressLib/EdkIIGlueBaseUefiDecompressLib.mak b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseUefiDecompressLib/EdkIIGlueBaseUefiDecompressLib.mak new file mode 100644 index 0000000..636fc18 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseUefiDecompressLib/EdkIIGlueBaseUefiDecompressLib.mak @@ -0,0 +1,80 @@ +#********************************************************************** +#********************************************************************** +#** ** +#** (C)Copyright 1985-2009, American Megatrends, Inc. ** +#** ** +#** All Rights Reserved. ** +#** ** +#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +#** ** +#** Phone: (770)-246-8600 ** +#** ** +#********************************************************************** +#********************************************************************** + +#********************************************************************** +# $Header: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGlueBaseUefiDecompressLib/EdkIIGlueBaseUefiDecompressLib.mak 1 1/20/12 3:54a Jeffch $ +# +# $Revision: 1 $ +# +# $Date: 1/20/12 3:54a $ +#********************************************************************** +# Revision History +# ---------------- +# $Log: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGlueBaseUefiDecompressLib/EdkIIGlueBaseUefiDecompressLib.mak $ +# +# 1 1/20/12 3:54a Jeffch +# Create Intel EDK 1117 Patch 7. +# +# 1 9/27/11 6:17a Wesleychen +# Intel EDK initially releases. +# +# 1 9/18/09 1:53a Iminglin +# +#********************************************************************** +#<AMI_FHDR_START> +# +# Name: EdkIIGlueBaseUefiDecompressLib.mak +# +# Description: +# +#<AMI_FHDR_END> +#********************************************************************** + + +$(EdkIIGlueBaseUefiDecompressLib_LIB) : EdkIIGlueBaseUefiDecompressLib + +EdkIIGlueBaseUefiDecompressLib : $(BUILD_DIR)\EdkIIGlueBaseUefiDecompressLib.mak EdkIIGlueBaseUefiDecompressLibBin + +$(BUILD_DIR)\EdkIIGlueBaseUefiDecompressLib.mak : $(EdkIIGlueBaseUefiDecompressLib_DIR)\$(@B).cif $(EdkIIGlueBaseUefiDecompressLib_DIR)\$(@B).mak $(BUILD_RULES) + $(CIF2MAK) $(EdkIIGlueBaseUefiDecompressLib_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS) + +EdkIIGlueBaseUefiDecompressLibBin : $(EdkIIGlueBaseMemoryLib_LIB) +!IF "$(x64_BUILD)"=="1" + $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\ + BUILD_DIR=$(BUILD_DIR)\ + /f $(BUILD_DIR)\EdkIIGlueBaseUefiDecompressLib.mak all\ + TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueBaseUefiDecompressLib_LIB)" + $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\ + BUILD_DIR=$(BUILD_DIR)\IA32\ + /f $(BUILD_DIR)\EdkIIGlueBaseUefiDecompressLib.mak all\ + TYPE=PEI_LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueBaseUefiDecompressLib_LIB)" +!ELSE + $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\ + BUILD_DIR=$(BUILD_DIR)\ + /f $(BUILD_DIR)\EdkIIGlueBaseUefiDecompressLib.mak all\ + TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueBaseUefiDecompressLib_LIB)" +!ENDIF +#********************************************************************** +#********************************************************************** +#** ** +#** (C)Copyright 1985-2009, American Megatrends, Inc. ** +#** ** +#** All Rights Reserved. ** +#** ** +#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +#** ** +#** Phone: (770)-246-8600 ** +#** ** +#********************************************************************** +#**********************************************************************
\ No newline at end of file diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseUefiDecompressLib/EdkIIGlueBaseUefiDecompressLib.sdl b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseUefiDecompressLib/EdkIIGlueBaseUefiDecompressLib.sdl new file mode 100644 index 0000000..b6bf41c --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseUefiDecompressLib/EdkIIGlueBaseUefiDecompressLib.sdl @@ -0,0 +1,26 @@ +TOKEN + Name = "EdkIIGlueBaseUefiDecompressLib_SUPPORT" + Value = "1" + Help = "Main switch to enable EdkIIGlueBaseUefiDecompressLib support in Project" + TokenType = Boolean + TargetEQU = Yes + TargetMAK = Yes + Master = Yes +End + +TOKEN + Name = "EdkIIGlueBaseUefiDecompressLib_LIB" + Value = "$$(LIB_BUILD_DIR)\EdkIIGlueBaseUefiDecompressLib.lib" + TokenType = Expression + TargetMAK = Yes +End + +PATH + Name = "EdkIIGlueBaseUefiDecompressLib_DIR" +End + +MODULE + Help = "Includes EdkIIGlueBaseUefiDecompressLib.mak to Project" + File = "EdkIIGlueBaseUefiDecompressLib.mak" +End + diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeDebugLibReportStatusCode/DebugLib.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeDebugLibReportStatusCode/DebugLib.c new file mode 100644 index 0000000..bba3b5e --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeDebugLibReportStatusCode/DebugLib.c @@ -0,0 +1,322 @@ +/*++ + +Copyright (c) 2004 - 2011, 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: + + DebugLib.c + +Abstract: + + Debug Library that fowards all messages to ReportStatusCode() + +--*/ + +#include "EdkIIGlueDxe.h" +#include "Pcd\EdkIIGluePcdDebugLib.h" + +/** + + Gets the error level. + + If DebugMaskInterface is not NULL, return the error level from DebugMaskInterface. + + If DebugMaskInterface is NULL, return the default define DebugPrintErrorLevel error level. + + @retval Debug Message Error Level + +**/ +UINTN +EFIAPI +EdkIIGlueGetDebugPrintErrorLevel ( + VOID + ) +{ + EFI_STATUS Status; + UINTN ImageDebugMask; + + if (gDebugMaskInterface != NULL) { + Status = gDebugMaskInterface->GetDebugMask (gDebugMaskInterface, &ImageDebugMask); + if (!(EFI_ERROR(Status))) { + return ImageDebugMask; + } + } + return EDKII_GLUE_DebugPrintErrorLevel; +} + +/** + + Prints a debug message to the debug output device if the specified error level is enabled. + + If any bit in ErrorLevel is also set in PcdDebugPrintErrorLevel, then print + the message specified by Format and the associated variable argument list to + the debug output device. + + If Format is NULL, then ASSERT(). + + @param ErrorLevel The error level of the debug message. + @param Format Format string for the debug message to print. + +**/ +VOID +EFIAPI +DebugPrint ( + IN UINTN ErrorLevel, + IN CONST CHAR8 *Format, + ... + ) +{ + UINT64 Buffer[EFI_STATUS_CODE_DATA_MAX_SIZE / sizeof (UINT64)]; + EFI_DEBUG_INFO *DebugInfo; + UINTN TotalSize; + UINTN Index; + VA_LIST Marker; + UINT64 *ArgumentPointer; + + // + // If Format is NULL, then ASSERT(). + // + ASSERT (Format != NULL); + + // + // Check driver Debug Level value and global debug level + // + if ((ErrorLevel & PcdGet32(PcdDebugPrintErrorLevel)) == 0) { + return; + } + + TotalSize = sizeof (EFI_DEBUG_INFO) + 12 * sizeof (UINT64) + AsciiStrLen (Format) + 1; + if (TotalSize > EFI_STATUS_CODE_DATA_MAX_SIZE) { + return; + } + + // + // Then EFI_DEBUG_INFO + // + DebugInfo = (EFI_DEBUG_INFO *)Buffer; + DebugInfo->ErrorLevel = (UINT32)ErrorLevel; + + // + // 256 byte mini Var Arg stack. That is followed by the format string. + // + VA_START (Marker, Format); + for (Index = 0, ArgumentPointer = (UINT64 *)(DebugInfo + 1); Index < 12; Index++, ArgumentPointer++) { + *ArgumentPointer = VA_ARG (Marker, UINT64); + } + VA_END (Marker); + AsciiStrCpy ((CHAR8 *)ArgumentPointer, Format); + + REPORT_STATUS_CODE_EX ( + EFI_DEBUG_CODE, + (EFI_SOFTWARE_DXE_BS_DRIVER | EFI_DC_UNSPECIFIED), + 0, + NULL, + &gEfiStatusCodeDataTypeDebugGuid, + DebugInfo, + TotalSize + ); +} + + +/** + + Prints an assert message containing a filename, line number, and description. + This may be followed by a breakpoint or a dead loop. + + Print a message of the form "ASSERT <FileName>(<LineNumber>): <Description>\n" + to the debug output device. If DEBUG_PROPERTY_ASSERT_BREAKPOINT_ENABLED bit of + PcdDebugProperyMask is set then CpuBreakpoint() is called. Otherwise, if + DEBUG_PROPERTY_ASSERT_DEADLOOP_ENABLED bit of PcdDebugProperyMask is set then + CpuDeadLoop() is called. If neither of these bits are set, then this function + returns immediately after the message is printed to the debug output device. + DebugAssert() must actively prevent recusrsion. If DebugAssert() is called while + processing another DebugAssert(), then DebugAssert() must return immediately. + + If FileName is NULL, then a <FileName> string of "(NULL) Filename" is printed. + + If Description is NULL, then a <Description> string of "(NULL) Description" is printed. + + @param FileName Pointer to the name of the source file that generated the assert condition. + @param LineNumber The line number in the source file that generated the assert condition + @param Description Pointer to the description of the assert condition. + +**/ +VOID +EFIAPI +DebugAssert ( + IN CONST CHAR8 *FileName, + IN UINTN LineNumber, + IN CONST CHAR8 *Description + ) +{ + UINT64 Buffer[EFI_STATUS_CODE_DATA_MAX_SIZE / sizeof(UINT64)]; + EFI_DEBUG_ASSERT_DATA *AssertData; + UINTN TotalSize; + CHAR8 *Temp; + + // + // Make sure it will all fit in the passed in buffer + // + TotalSize = sizeof (EFI_DEBUG_ASSERT_DATA) + AsciiStrLen (FileName) + 1 + AsciiStrLen (Description) + 1; + if (TotalSize <= EFI_STATUS_CODE_DATA_MAX_SIZE) { + // + // Fill in EFI_DEBUG_ASSERT_DATA + // + AssertData = (EFI_DEBUG_ASSERT_DATA *)Buffer; + AssertData->LineNumber = (UINT32)LineNumber; + + // + // Copy Ascii FileName including NULL. + // + Temp = AsciiStrCpy ((CHAR8 *)(AssertData + 1), FileName); + + // + // Copy Ascii Description + // + AsciiStrCpy (Temp + AsciiStrLen (FileName) + 1, Description); + + REPORT_STATUS_CODE_WITH_EXTENDED_DATA ( + (EFI_ERROR_CODE | EFI_ERROR_UNRECOVERED), + (EFI_SOFTWARE_DXE_BS_DRIVER | EFI_SW_EC_ILLEGAL_SOFTWARE_STATE), + AssertData, + TotalSize + ); + } + + // + // Generate a Breakpoint, DeadLoop, or NOP based on PCD settings + // + if ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_ASSERT_BREAKPOINT_ENABLED) != 0) { + CpuBreakpoint (); + } else if ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_ASSERT_DEADLOOP_ENABLED) != 0) { + CpuDeadLoop (); + } +} + + +/** + + Fills a target buffer with PcdDebugClearMemoryValue, and returns the target buffer. + + This function fills Length bytes of Buffer with the value specified by + PcdDebugClearMemoryValue, and returns Buffer. + + If Buffer is NULL, then ASSERT(). + + If Length is greater than (MAX_ADDRESS ?Buffer + 1), then ASSERT(). + + @param Buffer Pointer to the target buffer to fill with PcdDebugClearMemoryValue. + @param Length Number of bytes in Buffer to fill with zeros PcdDebugClearMemoryValue. + + @return Buffer + +**/ +VOID * +EFIAPI +DebugClearMemory ( + OUT VOID *Buffer, + IN UINTN Length + ) +{ + // + // If Buffer is NULL, then ASSERT(). + // + ASSERT (Buffer != NULL); + + // + // SetMem() checks for the the ASSERT() condition on Length and returns Buffer + // + return SetMem (Buffer, Length, PcdGet8(PcdDebugClearMemoryValue)); +} + + +/** + + Returns TRUE if ASSERT() macros are enabled. + + This function returns TRUE if the DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED bit of + PcdDebugProperyMask is set. Otherwise FALSE is returned. + + @retval TRUE The DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED bit of PcdDebugProperyMask is set. + @retval FALSE The DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED bit of PcdDebugProperyMask is clear. + +**/ +BOOLEAN +EFIAPI +DebugAssertEnabled ( + VOID + ) +{ + return (BOOLEAN) ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED) != 0); +} + + +/** + + Returns TRUE if DEBUG()macros are enabled. + + This function returns TRUE if the DEBUG_PROPERTY_DEBUG_PRINT_ENABLED bit of + PcdDebugProperyMask is set. Otherwise FALSE is returned. + + @retval TRUE The DEBUG_PROPERTY_DEBUG_PRINT_ENABLED bit of PcdDebugProperyMask is set. + @retval FALSE The DEBUG_PROPERTY_DEBUG_PRINT_ENABLED bit of PcdDebugProperyMask is clear. + +**/ +BOOLEAN +EFIAPI +DebugPrintEnabled ( + VOID + ) +{ + return (BOOLEAN) ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_DEBUG_PRINT_ENABLED) != 0); +} + + +/** + + Returns TRUE if DEBUG_CODE()macros are enabled. + + This function returns TRUE if the DEBUG_PROPERTY_DEBUG_CODE_ENABLED bit of + PcdDebugProperyMask is set. Otherwise FALSE is returned. + + @retval TRUE The DEBUG_PROPERTY_DEBUG_CODE_ENABLED bit of PcdDebugProperyMask is set. + @retval FALSE The DEBUG_PROPERTY_DEBUG_CODE_ENABLED bit of PcdDebugProperyMask is clear. + +**/ +BOOLEAN +EFIAPI +DebugCodeEnabled ( + VOID + ) +{ + return (BOOLEAN) ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_DEBUG_CODE_ENABLED) != 0); +} + + +/** + + Returns TRUE if DEBUG_CLEAR_MEMORY()macro is enabled. + + This function returns TRUE if the DEBUG_PROPERTY_DEBUG_CLEAR_MEMORY_ENABLED bit of + PcdDebugProperyMask is set. Otherwise FALSE is returned. + + @retval TRUE The DEBUG_PROPERTY_DEBUG_CLEAR_MEMORY_ENABLED bit of PcdDebugProperyMask is set. + @retval FALSE The DEBUG_PROPERTY_DEBUG_CLEAR_MEMORY_ENABLED bit of PcdDebugProperyMask is clear. + +**/ +BOOLEAN +EFIAPI +DebugClearMemoryEnabled ( + VOID + ) +{ + return (BOOLEAN) ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_CLEAR_MEMORY_ENABLED) != 0); +} diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeDebugLibReportStatusCode/DxeDebugLibReportStatusCode.inf b/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeDebugLibReportStatusCode/DxeDebugLibReportStatusCode.inf new file mode 100644 index 0000000..6c6741f --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeDebugLibReportStatusCode/DxeDebugLibReportStatusCode.inf @@ -0,0 +1,88 @@ +#/*++ +# +# 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: +# +# DxeDebugLibReportStatusCode.inf +# +# Abstract: +# +# Component description file for DxeDebugLibReportStatusCode. +# +#--*/ + +[defines] +BASE_NAME = EdkIIGlueDxeDebugLibReportStatusCode +COMPONENT_TYPE = LIBRARY + +[sources.common] + DebugLib.c + +[sources.ia32] + +[sources.x64] + +[sources.ipf] + +[sources.ebc] + + +[includes.common] + . + ..\..\Include + ..\..\include\Library + $(EDK_SOURCE)\Foundation + $(EDK_SOURCE)\Foundation\Framework + $(EDK_SOURCE)\Foundation\Framework\Protocol\Hii + $(EDK_SOURCE)\Foundation\Efi + $(EDK_SOURCE)\Foundation\Include + $(EDK_SOURCE)\Foundation\Efi\Include + $(EDK_SOURCE)\Foundation\Framework\Include + $(EDK_SOURCE)\Foundation\Include\IndustryStandard + $(EDK_SOURCE)\Foundation\Core\Dxe + $(EDK_SOURCE)\Foundation\Library\Dxe\Include + $(EDK_SOURCE)\Foundation\Library\Dxe\EfiIfrSupportLib + $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include + +[libraries.common] + EdkIIGlueBaseLib + EdkIIGlueBaseMemoryLib +# +# R8.x +# + EdkFrameworkGuidLib + EfiProtocolLib +# +# +# An user must specify a PEI or DXE ReportStatusCodeLib instance in module's .inf +# + +[libraries.ia32] + + +[libraries.x64] + + +[nmake.common] + C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION + LIB_STD_FLAGS = /NOLOGO /IGNORE:4006 + +[nmake.ia32] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32 + +[nmake.x64] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64 + +[nmake.ipf] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF + +[nmake.ebc] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_EBC
\ No newline at end of file diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeDebugLibReportStatusCode/EdkIIGlueDxeDebugLibReportStatusCode.cif b/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeDebugLibReportStatusCode/EdkIIGlueDxeDebugLibReportStatusCode.cif new file mode 100644 index 0000000..aef686f --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeDebugLibReportStatusCode/EdkIIGlueDxeDebugLibReportStatusCode.cif @@ -0,0 +1,11 @@ +<component> + name = "EdkIIGlueDxeDebugLibReportStatusCode" + category = ModulePart + LocalRoot = "Edk\Foundation\Library\EdkIIGlueLib\Library\DxeDebugLibReportStatusCode" + RefName = "EdkIIGlueDxeDebugLibReportStatusCode" +[files] +"EdkIIGlueDxeDebugLibReportStatusCode.sdl" +"EdkIIGlueDxeDebugLibReportStatusCode.mak" +"DxeDebugLibReportStatusCode.inf" +"DebugLib.c" +<endComponent> diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeDebugLibReportStatusCode/EdkIIGlueDxeDebugLibReportStatusCode.mak b/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeDebugLibReportStatusCode/EdkIIGlueDxeDebugLibReportStatusCode.mak new file mode 100644 index 0000000..e58f4bd --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeDebugLibReportStatusCode/EdkIIGlueDxeDebugLibReportStatusCode.mak @@ -0,0 +1,80 @@ +#********************************************************************** +#********************************************************************** +#** ** +#** (C)Copyright 1985-2009, American Megatrends, Inc. ** +#** ** +#** All Rights Reserved. ** +#** ** +#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +#** ** +#** Phone: (770)-246-8600 ** +#** ** +#********************************************************************** +#********************************************************************** + +#********************************************************************** +# $Header: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGlueDxeDebugLibReportStatusCode/EdkIIGlueDxeDebugLibReportStatusCode.mak 1 1/20/12 3:55a Jeffch $ +# +# $Revision: 1 $ +# +# $Date: 1/20/12 3:55a $ +#********************************************************************** +# Revision History +# ---------------- +# $Log: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGlueDxeDebugLibReportStatusCode/EdkIIGlueDxeDebugLibReportStatusCode.mak $ +# +# 1 1/20/12 3:55a Jeffch +# Create Intel EDK 1117 Patch 7. +# +# 1 9/27/11 6:18a Wesleychen +# Intel EDK initially releases. +# +# 1 9/18/09 1:56a Iminglin +# +#********************************************************************** +#<AMI_FHDR_START> +# +# Name: EdkIIGlueDxeDebugLibReportStatusCode.mak +# +# Description: +# +#<AMI_FHDR_END> +#********************************************************************** + + +$(EdkIIGlueDxeDebugLibReportStatusCode_LIB) : EdkIIGlueDxeDebugLibReportStatusCode + +EdkIIGlueDxeDebugLibReportStatusCode : $(BUILD_DIR)\EdkIIGlueDxeDebugLibReportStatusCode.mak EdkIIGlueDxeDebugLibReportStatusCodeBin + +$(BUILD_DIR)\EdkIIGlueDxeDebugLibReportStatusCode.mak : $(EdkIIGlueDxeDebugLibReportStatusCode_DIR)\$(@B).cif $(EdkIIGlueDxeDebugLibReportStatusCode_DIR)\$(@B).mak $(BUILD_RULES) + $(CIF2MAK) $(EdkIIGlueDxeDebugLibReportStatusCode_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS) + +EdkIIGlueDxeDebugLibReportStatusCodeBin : $(EdkIIGlueBaseLib_LIB) $(EdkIIGlueBaseMemoryLib_LIB) $(EDKFRAMEWORKGUIDLIB) $(EFIPROTOCOLLIB) +!IF "$(x64_BUILD)"=="1" + $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\ + BUILD_DIR=$(BUILD_DIR)\ + /f $(BUILD_DIR)\EdkIIGlueDxeDebugLibReportStatusCode.mak all\ + TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueDxeDebugLibReportStatusCode_LIB)" + $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\ + BUILD_DIR=$(BUILD_DIR)\IA32\ + /f $(BUILD_DIR)\EdkIIGlueDxeDebugLibReportStatusCode.mak all\ + TYPE=PEI_LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueDxeDebugLibReportStatusCode_LIB)" +!ELSE + $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\ + BUILD_DIR=$(BUILD_DIR)\ + /f $(BUILD_DIR)\EdkIIGlueDxeDebugLibReportStatusCode.mak all\ + TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueDxeDebugLibReportStatusCode_LIB)" +!ENDIF +#********************************************************************** +#********************************************************************** +#** ** +#** (C)Copyright 1985-2009, American Megatrends, Inc. ** +#** ** +#** All Rights Reserved. ** +#** ** +#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +#** ** +#** Phone: (770)-246-8600 ** +#** ** +#********************************************************************** +#********************************************************************** diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeDebugLibReportStatusCode/EdkIIGlueDxeDebugLibReportStatusCode.sdl b/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeDebugLibReportStatusCode/EdkIIGlueDxeDebugLibReportStatusCode.sdl new file mode 100644 index 0000000..312d08b --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeDebugLibReportStatusCode/EdkIIGlueDxeDebugLibReportStatusCode.sdl @@ -0,0 +1,26 @@ +TOKEN + Name = "EdkIIGlueDxeDebugLibReportStatusCode_SUPPORT" + Value = "1" + Help = "Main switch to enable EdkIIGlueDxeDebugLibReportStatusCode support in Project" + TokenType = Boolean + TargetEQU = Yes + TargetMAK = Yes + Master = Yes +End + +TOKEN + Name = "EdkIIGlueDxeDebugLibReportStatusCode_LIB" + Value = "$$(LIB_BUILD_DIR)\EdkIIGlueDxeDebugLibReportStatusCode.lib" + TokenType = Expression + TargetMAK = Yes +End + +PATH + Name = "EdkIIGlueDxeDebugLibReportStatusCode_DIR" +End + +MODULE + Help = "Includes EdkIIGlueDxeDebugLibReportStatusCode.mak to Project" + File = "EdkIIGlueDxeDebugLibReportStatusCode.mak" +End + diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeFirmwarePerformanceLib/EdkIIGlueDxeFirmwarePerformanceLib.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeFirmwarePerformanceLib/EdkIIGlueDxeFirmwarePerformanceLib.c new file mode 100644 index 0000000..f38eee7 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeFirmwarePerformanceLib/EdkIIGlueDxeFirmwarePerformanceLib.c @@ -0,0 +1,638 @@ +/*++ + +Copyright (c) 2011 - 2012, Intel Corporation. All rights reserved.<BR> +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: + + EdkIIGlueDxeFirmwarePerformanceLib.c + +Abstract: + + DXE Library for FPDT performance logging. + +--*/ + +#include "Tiano.h" +#include "EdkIIGlueDxe.h" +#include "EfiImage.h" + +#include EFI_PROTOCOL_DEFINITION (FirmwarePerformance) +#include EFI_GUID_DEFINITION (PeiPerformanceHob) +#include EFI_PROTOCOL_DEFINITION (LoadedImage) +#include EFI_GUID_DEFINITION (Hob) + +static UINT32 *mPerformancePointer; +static UINT32 mPerformanceLength; +UINT16 BdsAttemptNumber = 0; + +FIRMWARE_PERFORMANCE_PROTOCOL *FirmwarePerformance; +EFI_GUID gNullGuid = EFI_NULL_GUID; + +STATIC +VOID +GetShortPdbFileName ( + IN CHAR8 *PdbFileName, + OUT CHAR8 *GaugeString + ) +/*++ + +Routine Description: + + Shotens PDB path name + +Arguments: + + PdbFileName - PdbFileName to be shorten + +Returns: + + Pointer to Shortened PdbFileName + +--*/ +{ + UINTN Index; + UINTN Index1; + UINTN StartIndex; + UINTN EndIndex; + + if (PdbFileName == NULL) { + AsciiStrCpy (GaugeString, " "); + } else { + StartIndex = 0; + for (EndIndex = 0; PdbFileName[EndIndex] != 0; EndIndex++) + ; + + for (Index = 0; PdbFileName[Index] != 0; Index++) { + if (PdbFileName[Index] == '\\') { + StartIndex = Index + 1; + } + + if (PdbFileName[Index] == '.') { + EndIndex = Index; + } + } + + Index1 = 0; + for (Index = StartIndex; Index < EndIndex; Index++) { + GaugeString[Index1] = PdbFileName[Index]; + Index1++; + if (Index1 == STRING_EVENT_RECORD_NAME_LENGTH - 1) { + break; + } + } + + GaugeString[Index1] = 0; + } + + return ; +} + +STATIC +VOID +GetNameFromHandle ( + IN EFI_HANDLE Handle, + OUT CHAR8 *GaugeString + ) +/*++ + +Routine Description: + + retrieves PDB path name from Handle + +Arguments: + + Handle - Handle of image + GaugeString - returns pointer to PDB Filename + +Returns: + + None + +--*/ +{ + EFI_STATUS Status; + EFI_LOADED_IMAGE_PROTOCOL *Image; + CHAR8 *PdbFileName; + EFI_DRIVER_BINDING_PROTOCOL *DriverBinding; + + AsciiStrCpy (GaugeString, " "); + + // + // Get handle name from image protocol + // + Status = gBS->HandleProtocol ( + Handle, + &gEfiLoadedImageProtocolGuid, + (VOID**)&Image + ); + + if (EFI_ERROR (Status)) { + Status = gBS->OpenProtocol ( + Handle, + &gEfiDriverBindingProtocolGuid, + (VOID **) &DriverBinding, + NULL, + NULL, + EFI_OPEN_PROTOCOL_GET_PROTOCOL + ); + if (EFI_ERROR (Status)) { + return ; + } + // + // Get handle name from image protocol + // + Status = gBS->HandleProtocol ( + DriverBinding->ImageHandle, + &gEfiLoadedImageProtocolGuid, + (VOID **) &Image + ); + } + + PdbFileName = PeCoffLoaderGetPdbPointer (Image->ImageBase); + + if (PdbFileName != NULL) { + GetShortPdbFileName (PdbFileName, GaugeString); + } + + return ; +} + +EFI_STATUS +LocatePerformanceProtocol ( + VOID + ) +/*++ + +Routine Description: + + locates Performance protocol interface + +Arguments: + + None + +Returns: + + EFI_SUCCESS - Located protocol successfully + EFI_NOT_FOUND - Fail to locate protocol + +--*/ +{ + EFI_STATUS Status; + + FirmwarePerformance = NULL; + Status = gBS->LocateProtocol (&gFirmwarePerformanceProtocolGuid, NULL, (VOID **) &FirmwarePerformance); + + return Status; +} + +EFI_STATUS +EFIAPI +InsertMeasurement ( + IN FIRMWARE_PERFORMANCE_PROTOCOL *This, + IN EFI_HANDLE Handle, + IN UINT16 RecordType, + IN UINT64 Timestamp, + IN UINT16 Identifier OPTIONAL + ) +/*++ + +Routine Description: + + Logs performance data according to record type into pre-allocated buffer + +Arguments: + + This - Calling context + Handle - Handle of gauge data + RecordType - Type of FPDT record + Timestamp - Timestamp of TSC timer when even happend. + Identifier - Identifier of event records and other types of records + +Returns: + + EFI_SUCCESS - Successfully create and initialized a guage data node. + EFI_OUT_OF_RESOURCES - No enough resource to create a guage data node. + EFI_ABORTED - Type of record is not defined + +--*/ +{ + EFI_DEVICE_PATH_PROTOCOL *DevicePath; + HARDWARE_BOOT_REC *HardwareBootRec; + STRING_EVENT_REC *StringEvent; + GUID_EVENT_REC *GuidEvent; + BDS_ATTEMPT_REC *BdsAttemptRec; + EFI_GUID *GuidName; + + UINT8 PdbFileName[STRING_EVENT_RECORD_NAME_LENGTH] = { 0 }; + UINT8 NullFileName[STRING_EVENT_RECORD_NAME_LENGTH] = { 0 }; + DevicePath = NULL; + + // + // Check if pre-allocated buffer is full + // + if (mPerformanceLength + sizeof (STRING_EVENT_REC) > FIRMWARE_MAX_BUFFER) { + return EFI_OUT_OF_RESOURCES; + } + + switch (RecordType) { + case HARDWARE_BOOT_TYPE: + // + // Hardware Boot Record Table + // + HardwareBootRec = (HARDWARE_BOOT_REC*) ((UINT8*)mPerformancePointer + mPerformanceLength); + + HardwareBootRec->RecType = RecordType; + HardwareBootRec->RecLength = sizeof (HARDWARE_BOOT_REC); + HardwareBootRec->Revision = RECORD_REVISION_1; + HardwareBootRec->HardwareBoot = GetTimeInNanoSec (Timestamp); + + mPerformanceLength += sizeof (HARDWARE_BOOT_REC); + break; + + case GUID_EVENT_REC_TYPE: + case STRING_EVENT_REC_TYPE: + // + // Determine Pdb FileName associated with module logging performance + // + if (Handle != NULL) { + GetNameFromHandle (Handle, PdbFileName); + } + + GuidName = GetGuidFromHandle (Handle); + if (CompareMem (PdbFileName,NullFileName, STRING_EVENT_RECORD_NAME_LENGTH)){ + // + // String Event Record + // + StringEvent = (STRING_EVENT_REC*) ((UINT8*)mPerformancePointer + mPerformanceLength); + StringEvent->RecType = STRING_EVENT_REC_TYPE; + StringEvent->RecLength = sizeof (STRING_EVENT_REC); + StringEvent->Revision = RECORD_REVISION_1; + StringEvent->ProgressID = Identifier; + StringEvent->ApicID = GetApicId (); + StringEvent->Timestamp = GetTimeInNanoSec (Timestamp); + if (GuidName != NULL) { + (gBS->CopyMem) (&(StringEvent->Guid), GuidName, sizeof (EFI_GUID)); + } + + (gBS->CopyMem) (StringEvent->NameString, PdbFileName, STRING_EVENT_RECORD_NAME_LENGTH); + + mPerformanceLength += sizeof (STRING_EVENT_REC); + + } else { + // + // GUID Event Record + // + GuidEvent = (GUID_EVENT_REC*) ((UINT8*)mPerformancePointer + mPerformanceLength); + GuidEvent->RecType = GUID_EVENT_REC_TYPE; + GuidEvent->RecLength = sizeof (GUID_EVENT_REC); + GuidEvent->Revision = RECORD_REVISION_1; + GuidEvent->ProgressID = Identifier; + GuidEvent->ApicID = GetApicId (); + GuidEvent->Timestamp = GetTimeInNanoSec (Timestamp); + if (GuidName != NULL) { + (gBS->CopyMem) (&(GuidEvent->Guid), GuidName, sizeof (EFI_GUID)); + } + + mPerformanceLength += sizeof (GUID_EVENT_REC); + } + break; + + case BDS_ATTEMPT_EVENT_REC_TYPE: + // + // BDS Boot Attempt Record + // + DevicePath = DevicePathFromHandle (Handle); + + BdsAttemptRec = (BDS_ATTEMPT_REC*) ((UINT8*)mPerformancePointer + mPerformanceLength); + BdsAttemptRec->RecType = BDS_ATTEMPT_EVENT_REC_TYPE; + BdsAttemptRec->RecLength = sizeof (BDS_ATTEMPT_REC); + BdsAttemptRec->Revision = RECORD_REVISION_1; + BdsAttemptRec->ApicID = GetApicId (); + BdsAttemptRec->BdsAttemptNo = BdsAttemptNumber + 1; + BdsAttemptRec->Timestamp = GetTimeInNanoSec (Timestamp); + ASPrint ((CHAR8*)(&BdsAttemptRec->UEFIBootVar), sizeof(BdsAttemptRec->UEFIBootVar)+1, "BOOT%04x", Identifier); + BdsAttemptRec->DevicePathString = '0'; + mPerformanceLength += sizeof (BDS_ATTEMPT_REC); + break; + + default: + // + // Record is undefined, return EFI_ABORTED + // + return EFI_ABORTED; + break; + } + + return EFI_SUCCESS; +} + +EFI_STATUS +GetPerfBufferAddr ( + IN FIRMWARE_PERFORMANCE_PROTOCOL *This, + OUT UINT32 *PerformanceBuffer + ) +/*++ + +Routine Description: + + Retrieves pointer to performance buffer + +Arguments: + + This - Calling context + PerformanceBuffer - returns pointer to pre-allocated memory buffer + +Returns: + + EFI_SUCCESS - Located protocol successfully + EFI_NOT_FOUND - Fail to locate protocol or invalide returned pointer + +--*/ +{ + EFI_STATUS Status; + + *PerformanceBuffer = 0; + + Status = LocatePerformanceProtocol (); + if (EFI_ERROR (Status)) { + return EFI_NOT_FOUND; + } + + if (mPerformancePointer == NULL) { + return EFI_NOT_FOUND; + } + + *PerformanceBuffer = (UINT32) ((UINTN) mPerformancePointer); + + return Status; +} + +UINT32 +GetPerfBufferLength ( + IN FIRMWARE_PERFORMANCE_PROTOCOL *This + ) +/*++ + +Routine Description: + + Retrieves length of performance buffer + +Arguments: + + This - Calling context + +Returns: + + mPerformanceLength - length of pre-allocated memory buffer + +--*/ +{ + EFI_STATUS Status; + + Status = LocatePerformanceProtocol (); + if (EFI_ERROR (Status)) { + return 0; + } + + return mPerformanceLength; +} + +EFI_STATUS +StartMeasure ( + IN VOID *Handle, + IN UINT16 *Token, + IN UINT16 *Module, + IN UINT64 TimeStamp + ) +/*++ + +Routine Description: + + Start measurement according to token field and insert into pre-allocated buffer + +Arguments: + + Handle - Handle to measure + Token - Token to measure + Module - Module to measure + Timestamp - Ticker as start tick + +Returns: + + EFI_SUCCESS - Located protocol successfully, and buffer is updated with new record + EFI_NOT_FOUND - Failure in update + +--*/ +{ + EFI_STATUS Status; + UINT16 RecordType; + UINT16 Identifier; + + Status = LocatePerformanceProtocol (); + if (EFI_ERROR (Status)) { + return Status; + } + + if (!StrCmp (Token, START_IMAGE_TOK)) { + RecordType = STRING_EVENT_REC_TYPE; + Identifier = MODULE_START_ID; + } else if (!StrCmp (Token, LOAD_IMAGE_TOK)) { + RecordType = STRING_EVENT_REC_TYPE; + Identifier = MODULE_LOADIMAGE_START_ID; + } else if (!StrCmp (Token, DRIVERBINDING_START_TOK)) { + RecordType = STRING_EVENT_REC_TYPE; + Identifier = MODULE_DRIVERBINDING_START_ID; + } else if (!StrCmp (Token, DXE_TOK)) { + RecordType = STRING_EVENT_REC_TYPE; + Identifier = DXE_START_ID; + } else if (!StrCmp (Token, DXE_CORE_DISP_INIT_TOK)) { + RecordType = STRING_EVENT_REC_TYPE; + Identifier = DXE_CORE_DISP_START_ID; + } else if (!StrCmp (Token, COREDISPATCHER_TOK)) { + RecordType = STRING_EVENT_REC_TYPE; + Identifier = COREDISPATCHER_START_ID; + } else { + RecordType = PERFORMANCE_RECORD_TYPE_MAX; + Identifier = 0; + } + + Status = FirmwarePerformance->InsertMeasurement (FirmwarePerformance, Handle, RecordType, TimeStamp, Identifier); + + return Status; +} + +EFI_STATUS +EndMeasure ( + IN VOID *Handle, + IN UINT16 *Token, + IN UINT16 *Module, + IN UINT64 TimeStamp + ) +/*++ + +Routine Description: + + End measurement according to token field and insert into pre-allocated buffer + +Arguments: + + Handle - Handle to stop + Token - Token to stop + Module - Module to stop + Timestamp - Ticker as end tick + +Returns: + + EFI_SUCCESS - Located protocol successfully, and buffer is updated with new record + EFI_NOT_FOUND - Failure in update + +--*/ +{ + EFI_STATUS Status; + UINT16 RecordType; + UINT16 Identifier; + + Status = LocatePerformanceProtocol (); + if (EFI_ERROR (Status)) { + return Status; + } + + if (!StrCmp (Token, START_IMAGE_TOK)) { + RecordType = STRING_EVENT_REC_TYPE; + Identifier = MODULE_END_ID; + } else if (!StrCmp (Token, LOAD_IMAGE_TOK)) { + RecordType = STRING_EVENT_REC_TYPE; + Identifier = MODULE_LOADIMAGE_END_ID; + } else if (!StrCmp (Token, DRIVERBINDING_START_TOK)) { + RecordType = STRING_EVENT_REC_TYPE; + Identifier = MODULE_DRIVERBINDING_END_ID; + } else if (!StrCmp (Token, DXE_TOK)) { + RecordType = STRING_EVENT_REC_TYPE; + Identifier = DXE_END_ID; + } else if (!StrCmp (Token, DXE_CORE_DISP_INIT_TOK)) { + RecordType = STRING_EVENT_REC_TYPE; + Identifier = DXE_CORE_DISP_END_ID; + } else if (!StrCmp (Token, COREDISPATCHER_TOK)) { + RecordType = STRING_EVENT_REC_TYPE; + Identifier = COREDISPATCHER_END_ID; + } else { + RecordType = PERFORMANCE_RECORD_TYPE_MAX; + Identifier = 0; + } + + Status = FirmwarePerformance->InsertMeasurement (FirmwarePerformance, Handle, RecordType, TimeStamp, Identifier); + + return Status; +} + +EFI_STATUS +StartMeasureEx ( + IN VOID *Handle, + IN UINT16 *Token, + IN UINT16 *Module, + IN UINT64 TimeStamp, + IN UINT16 Identifier + ) +/*++ + +Routine Description: + + Start extended measurement according to token field and insert into pre-allocated buffer + +Arguments: + + Handle - Handle to stop + Token - Token to stop + Module - Module to stop + Timestamp - Ticker as end tick + Identifier - Identifier for a given record +Returns: + + EFI_SUCCESS - Located protocol successfully, and buffer is updated with new record + EFI_NOT_FOUND - Failure in update + +--*/ +{ + EFI_STATUS Status; + UINT16 RecordType; + + Status = LocatePerformanceProtocol (); + if (EFI_ERROR (Status)) { + return Status; + } + + if (!StrCmp (Token, HARDWARE_BOOT_TOK)) { + RecordType = HARDWARE_BOOT_TYPE; + } else if (!StrCmp (Token, EVENT_REC_TOK)) { + RecordType = STRING_EVENT_REC_TYPE; + } else if (!StrCmp (Token, BDS_ATTEMPT_TOK)) { + RecordType = BDS_ATTEMPT_EVENT_REC_TYPE; + } else { + RecordType = PERFORMANCE_RECORD_TYPE_MAX; + } + + Status = FirmwarePerformance->InsertMeasurement (FirmwarePerformance, Handle, RecordType, TimeStamp, Identifier); + + return Status; +} + +EFI_STATUS +EndMeasureEx ( + IN VOID *Handle, + IN UINT16 *Token, + IN UINT16 *Module, + IN UINT64 TimeStamp, + IN UINT16 Identifier + ) +/*++ + +Routine Description: + + End extended measurement according to token field and insert into pre-allocated buffer + +Arguments: + + Handle - Handle to stop + Token - Token to stop + Module - Module to stop + Timestamp - Ticker as end tick + Identifier - Identifier for a given record + +Returns: + + EFI_SUCCESS - Located protocol successfully, and buffer is updated with new record + EFI_NOT_FOUND - Failure in update + +--*/ +{ + EFI_STATUS Status; + UINT16 RecordType; + + Status = LocatePerformanceProtocol (); + if (EFI_ERROR (Status)) { + return Status; + } + + if (!StrCmp (Token, HARDWARE_BOOT_TOK)) { + RecordType = HARDWARE_BOOT_TYPE; + } else if (!StrCmp (Token, EVENT_REC_TOK)) { + RecordType = STRING_EVENT_REC_TYPE; + } else if (!StrCmp (Token, BDS_ATTEMPT_TOK)) { + RecordType = BDS_ATTEMPT_EVENT_REC_TYPE; + } else { + RecordType = PERFORMANCE_RECORD_TYPE_MAX; + } + + Status = FirmwarePerformance->InsertMeasurement (FirmwarePerformance, Handle, RecordType, TimeStamp, Identifier); + + return Status; +}
\ No newline at end of file diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeFirmwarePerformanceLib/EdkIIGlueDxeFirmwarePerformanceLib.cif b/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeFirmwarePerformanceLib/EdkIIGlueDxeFirmwarePerformanceLib.cif new file mode 100644 index 0000000..fbdf2e3 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeFirmwarePerformanceLib/EdkIIGlueDxeFirmwarePerformanceLib.cif @@ -0,0 +1,11 @@ +<component> + name = "EdkIIGlueDxeFirmwarePerformanceLib" + category = ModulePart + LocalRoot = "EDK\Foundation\Library\EdkIIGlueLib\Library\DxeFirmwarePerformanceLib\" + RefName = "EdkIIGlueDxeFirmwarePerformanceLib" +[files] +"EdkIIGlueDxeFirmwarePerformanceLib.sdl" +"EdkIIGlueDxeFirmwarePerformanceLib.mak" +"EdkIIGlueDxeFirmwarePerformanceLib.inf" +"EdkIIGlueDxeFirmwarePerformanceLib.c" +<endComponent>
\ No newline at end of file diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeFirmwarePerformanceLib/EdkIIGlueDxeFirmwarePerformanceLib.inf b/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeFirmwarePerformanceLib/EdkIIGlueDxeFirmwarePerformanceLib.inf new file mode 100644 index 0000000..c0e5e2e --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeFirmwarePerformanceLib/EdkIIGlueDxeFirmwarePerformanceLib.inf @@ -0,0 +1,81 @@ +#/*++ +# +# Copyright (c) 2011, Intel Corporation. All rights reserved.<BR> +# 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: +# +# EdkIIGlueDxeFirmwarePerformanceLib.inf +# +# Abstract: +# +# Component description file for DxePerformanceLib +# +#--*/ + +[defines] +BASE_NAME = EdkIIGlueDxeFirmwarePerformanceLib +COMPONENT_TYPE = LIBRARY + +[sources.common] + EdkIIGluedxeFirmwarePerformanceLib.c + +[sources.ia32] + + +[sources.x64] + + +[sources.ipf] + + +[sources.ebc] + + +[includes.common] + . + ..\..\Include + ..\..\include\Library + $(EDK_SOURCE)\Foundation + $(EDK_SOURCE)\Foundation\Framework + $(EDK_SOURCE)\Foundation\Efi + $(EDK_SOURCE)\Foundation\Include + $(EDK_SOURCE)\Foundation\Efi\Include + $(EDK_SOURCE)\Foundation\Framework\Include + $(EDK_SOURCE)\Foundation\Core\Dxe + $(EDK_SOURCE)\Foundation\Library\Dxe\Include + $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include + $(EDK_SOURCE)\Foundation\Include\IndustryStandard + +[libraries.common] + EdkIIGlueUefiDevicePathLib + EdkIIGlueUefiLib + EdkIIGlueBaseTimerLibLocalApic + EdkIIGlueBasePeCoffGetEntryPointLib + EdkIIGlueBaseTimerLibTsc + +[libraries.ia32] + +[libraries.x64] + +[nmake.common] + C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION + LIB_STD_FLAGS = /NOLOGO /IGNORE:4006 /IGNORE:4221 + +[nmake.ia32] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32 + +[nmake.x64] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64 + +[nmake.ipf] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF + +[nmake.ebc] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_EBC
\ No newline at end of file diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeFirmwarePerformanceLib/EdkIIGlueDxeFirmwarePerformanceLib.mak b/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeFirmwarePerformanceLib/EdkIIGlueDxeFirmwarePerformanceLib.mak new file mode 100644 index 0000000..d8d96d0 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeFirmwarePerformanceLib/EdkIIGlueDxeFirmwarePerformanceLib.mak @@ -0,0 +1,68 @@ +#********************************************************************** +#********************************************************************** +#** ** +#** (C)Copyright 1985-2011, American Megatrends, Inc. ** +#** ** +#** All Rights Reserved. ** +#** ** +#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +#** ** +#** Phone: (770)-246-8600 ** +#** ** +#********************************************************************** +#********************************************************************** + +#********************************************************************** +# $Header: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGlueDxeFirmwarePerformanceLib/EdkIIGlueDxeFirmwarePerformanceLib.mak 1 1/20/12 3:59a Jeffch $ +# +# $Revision: 1 $ +# +# $Date: 1/20/12 3:59a $ +#********************************************************************** +# Revision History +# ---------------- +# $Log: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGlueDxeFirmwarePerformanceLib/EdkIIGlueDxeFirmwarePerformanceLib.mak $ +# +# 1 1/20/12 3:59a Jeffch +# +# 1 11/17/11 9:32p Wesleychen +# Add firmware performance support from Intel EDK117 Client Framework +# PatchV7 package. +# +#********************************************************************** +#<AMI_FHDR_START> +# +# Name: EdkIIGlueDxeFirmwarePerformanceLib.mak +# +# Description: +# +#<AMI_FHDR_END> +#********************************************************************** +$(EdkIIGlueDxeFirmwarePerformanceLib_LIB) : EdkIIGlueDxeFirmwarePerformanceLib + +EdkIIGlueDxeFirmwarePerformanceLib : $(BUILD_DIR)\EdkIIGlueDxeFirmwarePerformanceLib.mak EdkIIGlueDxeFirmwarePerformanceLibBin + +$(BUILD_DIR)\EdkIIGlueDxeFirmwarePerformanceLib.mak : $(EdkIIGlueDxeFirmwarePerformanceLib_DIR)\$(@B).cif $(EdkIIGlueDxeFirmwarePerformanceLib_DIR)\$(@B).mak $(BUILD_RULES) + $(CIF2MAK) $(EdkIIGlueDxeFirmwarePerformanceLib_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS) + +EdkIIGlueDxeFirmwarePerformanceLibBin : $(CPUIA32LIB) + +EdkIIGlueDxeFirmwarePerformanceLibBin : $(EdkIIGlueUefiDevicePathLib_LIB) $(EdkIIGlueBasePeCoffGetEntryPointLib_LIB) $(EdkIIGlueBaseTimerLibLocalApic_LIB) $(EdkIIGlueUefiLib_LIB) $(EdkIIGlueBaseTimerLibTsc_LIB) $(EDKGUIDLIB) $(ARCHPROTOCOLLIB) + $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\ + BUILD_DIR=$(BUILD_DIR)\ + /f $(BUILD_DIR)\EdkIIGlueDxeFirmwarePerformanceLib.mak all\ + TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueDxeFirmwarePerformanceLib_LIB)" + +#********************************************************************** +#********************************************************************** +#** ** +#** (C)Copyright 1985-2011, American Megatrends, Inc. ** +#** ** +#** All Rights Reserved. ** +#** ** +#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +#** ** +#** Phone: (770)-246-8600 ** +#** ** +#********************************************************************** +#********************************************************************** diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeFirmwarePerformanceLib/EdkIIGlueDxeFirmwarePerformanceLib.sdl b/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeFirmwarePerformanceLib/EdkIIGlueDxeFirmwarePerformanceLib.sdl new file mode 100644 index 0000000..1e50421 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeFirmwarePerformanceLib/EdkIIGlueDxeFirmwarePerformanceLib.sdl @@ -0,0 +1,24 @@ +TOKEN + Name = EdkIIGlueDxeFirmwarePerformanceLib_SUPPORT + Value = 1 + TokenType = Boolean + TargetEQU = Yes + TargetMAK = Yes + Master = Yes +End + +TOKEN + Name = "EdkIIGlueDxeFirmwarePerformanceLib_LIB" + Value = "$$(LIB_BUILD_DIR)\EdkIIGlueDxeFirmwarePerformanceLib.lib" + TokenType = Expression + TargetMAK = Yes +End + +PATH + Name = "EdkIIGlueDxeFirmwarePerformanceLib_DIR" +End + +MODULE + Help = "Includes EdkIIGlueDxeFirmwarePerformanceLib.mak to Project" + File = "EdkIIGlueDxeFirmwarePerformanceLib.mak" +End
\ No newline at end of file diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeHobLib/DxeHobLib.inf b/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeHobLib/DxeHobLib.inf new file mode 100644 index 0000000..590e2f1 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeHobLib/DxeHobLib.inf @@ -0,0 +1,82 @@ +#/*++ +# +# 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: +# +# DxeHobLib.inf +# +# Abstract: +# +# Component description file for DxeHobLib. +# +#--*/ + +[defines] +BASE_NAME = EdkIIGlueDxeHobLib +COMPONENT_TYPE = LIBRARY + +[sources.common] + HobLib.c + +[sources.ia32] + +[sources.x64] + +[sources.ipf] + +[sources.ebc] + + +[includes.common] + . + ..\..\Include + ..\..\include\Library + $(EDK_SOURCE)\Foundation + $(EDK_SOURCE)\Foundation\Framework + $(EDK_SOURCE)\Foundation\Efi + $(EDK_SOURCE)\Foundation\Include + $(EDK_SOURCE)\Foundation\Efi\Include + $(EDK_SOURCE)\Foundation\Framework\Include + $(EDK_SOURCE)\Foundation\Include\IndustryStandard + $(EDK_SOURCE)\Foundation\Core\Dxe + $(EDK_SOURCE)\Foundation\Library\Dxe\Include + $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include + +[libraries.common] + EdkIIGlueBaseMemoryLib + EdkIIGlueUefiLib +# +# R8.x Library, GUID needed: gEfiHobListGuid +# + EdkFrameworkGuidLib + + +[libraries.ia32] + + +[libraries.x64] + + +[nmake.common] + C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION + LIB_STD_FLAGS = /NOLOGO /IGNORE:4006 + +[nmake.ia32] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32 + +[nmake.x64] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64 + +[nmake.ipf] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF + +[nmake.ebc] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_EBC
\ No newline at end of file diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeHobLib/EdkIIGlueDxeHobLib.cif b/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeHobLib/EdkIIGlueDxeHobLib.cif new file mode 100644 index 0000000..a5444f6 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeHobLib/EdkIIGlueDxeHobLib.cif @@ -0,0 +1,11 @@ +<component> + name = "EdkIIGlueDxeHobLib" + category = ModulePart + LocalRoot = "Edk\Foundation\Library\EdkIIGlueLib\Library\DxeHobLib" + RefName = "EdkIIGlueDxeHobLib" +[files] +"EdkIIGlueDxeHobLib.sdl" +"EdkIIGlueDxeHobLib.mak" +"DxeHobLib.inf" +"HobLib.c" +<endComponent> diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeHobLib/EdkIIGlueDxeHobLib.mak b/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeHobLib/EdkIIGlueDxeHobLib.mak new file mode 100644 index 0000000..19e9823 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeHobLib/EdkIIGlueDxeHobLib.mak @@ -0,0 +1,80 @@ +#********************************************************************** +#********************************************************************** +#** ** +#** (C)Copyright 1985-2009, American Megatrends, Inc. ** +#** ** +#** All Rights Reserved. ** +#** ** +#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +#** ** +#** Phone: (770)-246-8600 ** +#** ** +#********************************************************************** +#********************************************************************** + +#********************************************************************** +# $Header: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGlueDxeHobLib/EdkIIGlueDxeHobLib.mak 1 1/20/12 3:55a Jeffch $ +# +# $Revision: 1 $ +# +# $Date: 1/20/12 3:55a $ +#********************************************************************** +# Revision History +# ---------------- +# $Log: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGlueDxeHobLib/EdkIIGlueDxeHobLib.mak $ +# +# 1 1/20/12 3:55a Jeffch +# Create Intel EDK 1117 Patch 7. +# +# 1 9/27/11 6:17a Wesleychen +# Intel EDK initially releases. +# +# 1 9/18/09 1:54a Iminglin +# +#********************************************************************** +#<AMI_FHDR_START> +# +# Name: EdkIIGlueDxeHobLib.mak +# +# Description: +# +#<AMI_FHDR_END> +#********************************************************************** + + +$(EdkIIGlueDxeHobLib_LIB) : EdkIIGlueDxeHobLib + +EdkIIGlueDxeHobLib : $(BUILD_DIR)\EdkIIGlueDxeHobLib.mak EdkIIGlueDxeHobLibBin + +$(BUILD_DIR)\EdkIIGlueDxeHobLib.mak : $(EdkIIGlueDxeHobLib_DIR)\$(@B).cif $(EdkIIGlueDxeHobLib_DIR)\$(@B).mak $(BUILD_RULES) + $(CIF2MAK) $(EdkIIGlueDxeHobLib_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS) + +EdkIIGlueDxeHobLibBin : $(EdkIIGlueBaseMemoryLib_LIB) $(EdkIIGlueUefiLib_LIB) $(EDKFRAMEWORKGUIDLIB) +!IF "$(x64_BUILD)"=="1" + $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\ + BUILD_DIR=$(BUILD_DIR)\ + /f $(BUILD_DIR)\EdkIIGlueDxeHobLib.mak all\ + TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueDxeHobLib_LIB)" + $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\ + BUILD_DIR=$(BUILD_DIR)\IA32\ + /f $(BUILD_DIR)\EdkIIGlueDxeHobLib.mak all\ + TYPE=PEI_LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueDxeHobLib_LIB)" +!ELSE + $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\ + BUILD_DIR=$(BUILD_DIR)\ + /f $(BUILD_DIR)\EdkIIGlueDxeHobLib.mak all\ + TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueDxeHobLib_LIB)" +!ENDIF +#********************************************************************** +#********************************************************************** +#** ** +#** (C)Copyright 1985-2009, American Megatrends, Inc. ** +#** ** +#** All Rights Reserved. ** +#** ** +#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +#** ** +#** Phone: (770)-246-8600 ** +#** ** +#********************************************************************** +#********************************************************************** diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeHobLib/EdkIIGlueDxeHobLib.sdl b/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeHobLib/EdkIIGlueDxeHobLib.sdl new file mode 100644 index 0000000..a581d6f --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeHobLib/EdkIIGlueDxeHobLib.sdl @@ -0,0 +1,26 @@ +TOKEN + Name = "EdkIIGlueDxeHobLib_SUPPORT" + Value = "1" + Help = "Main switch to enable EdkIIGlueDxeHobLib support in Project" + TokenType = Boolean + TargetEQU = Yes + TargetMAK = Yes + Master = Yes +End + +TOKEN + Name = "EdkIIGlueDxeHobLib_LIB" + Value = "$$(LIB_BUILD_DIR)\EdkIIGlueDxeHobLib.lib" + TokenType = Expression + TargetMAK = Yes +End + +PATH + Name = "EdkIIGlueDxeHobLib_DIR" +End + +MODULE + Help = "Includes EdkIIGlueDxeHobLib.mak to Project" + File = "EdkIIGlueDxeHobLib.mak" +End + diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeHobLib/HobLib.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeHobLib/HobLib.c new file mode 100644 index 0000000..8cc17a8 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeHobLib/HobLib.c @@ -0,0 +1,501 @@ +/*++ + +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: + + HobLib.c + +Abstract: + + HOB Library. + +--*/ + +#include "EdkIIGlueDxe.h" + + +STATIC VOID *mHobList = NULL; + +/** + The constructor function caches the pointer to HOB list. + + The constructor function gets the start address of HOB list from system configuration table. + It will ASSERT() if that operation fails and it will always return EFI_SUCCESS. + + @param ImageHandle The firmware allocated handle for the EFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS. + +**/ +EFI_STATUS +EFIAPI +HobLibConstructor ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + Status = EfiGetSystemConfigurationTable (&gEfiHobListGuid, &mHobList); + ASSERT_EFI_ERROR (Status); + ASSERT (mHobList != NULL); + return Status; +} + +/** + Returns the pointer to the HOB list. + + This function returns the pointer to first HOB in the list. + + @return The pointer to the HOB list. + +**/ +VOID * +EFIAPI +GetHobList ( + VOID + ) +{ + return mHobList; +} + +/** + Returns the next instance of a HOB type from the starting HOB. + + This function searches the first instance of a HOB type from the starting HOB pointer. + If there does not exist such HOB type from the starting HOB pointer, it will return NULL. + In contrast with macro GET_NEXT_HOB(), this function does not skip the starting HOB pointer + unconditionally: it returns HobStart back if HobStart itself meets the requirement; + caller is required to use GET_NEXT_HOB() if it wishes to skip current HobStart. + If HobStart is NULL, then ASSERT(). + + @param Type The HOB type to return. + @param HobStart The starting HOB pointer to search from. + + @return The next instance of a HOB type from the starting HOB. + +**/ +VOID * +EFIAPI +GetNextHob ( + IN UINT16 Type, + IN CONST VOID *HobStart + ) +{ + EFI_PEI_HOB_POINTERS Hob; + + ASSERT (HobStart != NULL); + + Hob.Raw = (UINT8 *) HobStart; + // + // Parse the HOB list until end of list or matching type is found. + // + while (!END_OF_HOB_LIST (Hob)) { + if (Hob.Header->HobType == Type) { + return Hob.Raw; + } + Hob.Raw = GET_NEXT_HOB (Hob); + } + return NULL; +} + +/** + Returns the first instance of a HOB type among the whole HOB list. + + This function searches the first instance of a HOB type among the whole HOB list. + If there does not exist such HOB type in the HOB list, it will return NULL. + + @param Type The HOB type to return. + + @return The next instance of a HOB type from the starting HOB. + +**/ +VOID * +EFIAPI +GetFirstHob ( + IN UINT16 Type + ) +{ + VOID *HobList; + + HobList = GetHobList (); + return GetNextHob (Type, HobList); +} + +/** + This function searches the first instance of a HOB from the starting HOB pointer. + Such HOB should satisfy two conditions: + its HOB type is EFI_HOB_TYPE_GUID_EXTENSION and its GUID Name equals to the input Guid. + If there does not exist such HOB from the starting HOB pointer, it will return NULL. + Caller is required to apply GET_GUID_HOB_DATA () and GET_GUID_HOB_DATA_SIZE () + to extract the data section and its size info respectively. + In contrast with macro GET_NEXT_HOB(), this function does not skip the starting HOB pointer + unconditionally: it returns HobStart back if HobStart itself meets the requirement; + caller is required to use GET_NEXT_HOB() if it wishes to skip current HobStart. + If Guid is NULL, then ASSERT(). + If HobStart is NULL, then ASSERT(). + + @param Guid The GUID to match with in the HOB list. + @param HobStart A pointer to a Guid. + + @return The next instance of the matched GUID HOB from the starting HOB. + +**/ +VOID * +EFIAPI +GlueGetNextGuidHob ( + IN CONST EFI_GUID *Guid, + IN CONST VOID *HobStart + ) +{ + EFI_PEI_HOB_POINTERS GuidHob; + + GuidHob.Raw = (UINT8 *) HobStart; + while ((GuidHob.Raw = GetNextHob (EFI_HOB_TYPE_GUID_EXTENSION, GuidHob.Raw)) != NULL) { + if (CompareGuid (Guid, &GuidHob.Guid->Name)) { + break; + } + GuidHob.Raw = GET_NEXT_HOB (GuidHob); + } + return GuidHob.Raw; +} + +/** + This function searches the first instance of a HOB among the whole HOB list. + Such HOB should satisfy two conditions: + its HOB type is EFI_HOB_TYPE_GUID_EXTENSION and its GUID Name equals to the input Guid. + If there does not exist such HOB from the starting HOB pointer, it will return NULL. + Caller is required to apply GET_GUID_HOB_DATA () and GET_GUID_HOB_DATA_SIZE () + to extract the data section and its size info respectively. + If Guid is NULL, then ASSERT(). + + @param Guid The GUID to match with in the HOB list. + + @return The first instance of the matched GUID HOB among the whole HOB list. + +**/ +VOID * +EFIAPI +GlueGetFirstGuidHob ( + IN CONST EFI_GUID *Guid + ) +{ + VOID *HobList; + + HobList = GetHobList (); + return GetNextGuidHob (Guid, HobList); +} + +/** + Get the Boot Mode from the HOB list. + + This function returns the system boot mode information from the + PHIT HOB in HOB list. + + @param VOID + + @return The Boot Mode. + +**/ +EFI_BOOT_MODE +EFIAPI +GetBootModeHob ( + VOID + ) +{ + EFI_HOB_HANDOFF_INFO_TABLE *HandOffHob; + + HandOffHob = (EFI_HOB_HANDOFF_INFO_TABLE *) GetHobList (); + + return HandOffHob->BootMode; +} + +/** + Builds a HOB for a loaded PE32 module. + + This function builds a HOB for a loaded PE32 module. + It can only be invoked during PEI phase; + for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase. + If ModuleName is NULL, then ASSERT(). + If there is no additional space for HOB creation, then ASSERT(). + + @param ModuleName The GUID File Name of the module. + @param MemoryAllocationModule The 64 bit physical address of the module. + @param ModuleLength The length of the module in bytes. + @param EntryPoint The 64 bit physical address of the module's entry point. + +**/ +VOID +EFIAPI +GlueBuildModuleHob ( + IN CONST EFI_GUID *ModuleName, + IN EFI_PHYSICAL_ADDRESS MemoryAllocationModule, + IN UINT64 ModuleLength, + IN EFI_PHYSICAL_ADDRESS EntryPoint + ) +{ + // + // PEI HOB is read only for DXE phase + // + ASSERT (FALSE); +} + +/** + Builds a HOB that describes a chunk of system memory. + + This function builds a HOB that describes a chunk of system memory. + It can only be invoked during PEI phase; + for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase. + If there is no additional space for HOB creation, then ASSERT(). + + @param ResourceType The type of resource described by this HOB. + @param ResourceAttribute The resource attributes of the memory described by this HOB. + @param PhysicalStart The 64 bit physical address of memory described by this HOB. + @param NumberOfBytes The length of the memory described by this HOB in bytes. + +**/ +VOID +EFIAPI +BuildResourceDescriptorHob ( + IN EFI_RESOURCE_TYPE ResourceType, + IN EFI_RESOURCE_ATTRIBUTE_TYPE ResourceAttribute, + IN EFI_PHYSICAL_ADDRESS PhysicalStart, + IN UINT64 NumberOfBytes + ) +{ + // + // PEI HOB is read only for DXE phase + // + ASSERT (FALSE); +} + +/** + Builds a GUID HOB with a certain data length. + + This function builds a customized HOB tagged with a GUID for identification + and returns the start address of GUID HOB data so that caller can fill the customized data. + The HOB Header and Name field is already stripped. + It can only be invoked during PEI phase; + for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase. + If Guid is NULL, then ASSERT(). + If there is no additional space for HOB creation, then ASSERT(). + If DataLength >= (0x10000 - sizeof (EFI_HOB_GUID_TYPE)), then ASSERT(). + + @param Guid The GUID to tag the customized HOB. + @param DataLength The size of the data payload for the GUID HOB. + + @return The start address of GUID HOB data. + +**/ +VOID * +EFIAPI +BuildGuidHob ( + IN CONST EFI_GUID *Guid, + IN UINTN DataLength + ) +{ + // + // PEI HOB is read only for DXE phase + // + ASSERT (FALSE); + return NULL; +} + +/** + Copies a data buffer to a newly-built HOB. + + This function builds a customized HOB tagged with a GUID for identification, + copies the input data to the HOB data field and returns the start address of the GUID HOB data. + The HOB Header and Name field is already stripped. + It can only be invoked during PEI phase; + for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase. + If Guid is NULL, then ASSERT(). + If Data is NULL and DataLength > 0, then ASSERT(). + If there is no additional space for HOB creation, then ASSERT(). + If DataLength >= (0x10000 - sizeof (EFI_HOB_GUID_TYPE)), then ASSERT(). + + @param Guid The GUID to tag the customized HOB. + @param Data The data to be copied into the data field of the GUID HOB. + @param DataLength The size of the data payload for the GUID HOB. + + @return The start address of GUID HOB data. + +**/ +VOID * +EFIAPI +BuildGuidDataHob ( + IN CONST EFI_GUID *Guid, + IN VOID *Data, + IN UINTN DataLength + ) +{ + // + // PEI HOB is read only for DXE phase + // + ASSERT (FALSE); + return NULL; +} + +/** + Builds a Firmware Volume HOB. + + This function builds a Firmware Volume HOB. + It can only be invoked during PEI phase; + for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase. + If there is no additional space for HOB creation, then ASSERT(). + + @param BaseAddress The base address of the Firmware Volume. + @param Length The size of the Firmware Volume in bytes. + +**/ +VOID +EFIAPI +BuildFvHob ( + IN EFI_PHYSICAL_ADDRESS BaseAddress, + IN UINT64 Length + ) +{ + // + // PEI HOB is read only for DXE phase + // + ASSERT (FALSE); +} + +/** + Builds a Capsule Volume HOB. + + This function builds a Capsule Volume HOB. + It can only be invoked during PEI phase; + for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase. + If there is no additional space for HOB creation, then ASSERT(). + + @param BaseAddress The base address of the Capsule Volume. + @param Length The size of the Capsule Volume in bytes. + +**/ +VOID +EFIAPI +BuildCvHob ( + IN EFI_PHYSICAL_ADDRESS BaseAddress, + IN UINT64 Length + ) +{ + // + // PEI HOB is read only for DXE phase + // + ASSERT (FALSE); +} + +/** + Builds a HOB for the CPU. + + This function builds a HOB for the CPU. + It can only be invoked during PEI phase; + for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase. + If there is no additional space for HOB creation, then ASSERT(). + + @param SizeOfMemorySpace The maximum physical memory addressability of the processor. + @param SizeOfIoSpace The maximum physical I/O addressability of the processor. + +**/ +VOID +EFIAPI +BuildCpuHob ( + IN UINT8 SizeOfMemorySpace, + IN UINT8 SizeOfIoSpace + ) +{ + // + // PEI HOB is read only for DXE phase + // + ASSERT (FALSE); +} + +/** + Builds a HOB for the Stack. + + This function builds a HOB for the stack. + It can only be invoked during PEI phase; + for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase. + If there is no additional space for HOB creation, then ASSERT(). + + @param BaseAddress The 64 bit physical address of the Stack. + @param Length The length of the stack in bytes. + +**/ +VOID +EFIAPI +BuildStackHob ( + IN EFI_PHYSICAL_ADDRESS BaseAddress, + IN UINT64 Length + ) +{ + // + // PEI HOB is read only for DXE phase + // + ASSERT (FALSE); +} + +/** + Builds a HOB for the BSP store. + + This function builds a HOB for BSP store. + It can only be invoked during PEI phase; + for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase. + If there is no additional space for HOB creation, then ASSERT(). + + @param BaseAddress The 64 bit physical address of the BSP. + @param Length The length of the BSP store in bytes. + @param MemoryType Type of memory allocated by this HOB. + +**/ +VOID +EFIAPI +BuildBspStoreHob ( + IN EFI_PHYSICAL_ADDRESS BaseAddress, + IN UINT64 Length, + IN EFI_MEMORY_TYPE MemoryType + ) +{ + // + // PEI HOB is read only for DXE phase + // + ASSERT (FALSE); +} + +/** + Builds a HOB for the memory allocation. + + This function builds a HOB for the memory allocation. + It can only be invoked during PEI phase; + for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase. + If there is no additional space for HOB creation, then ASSERT(). + + @param BaseAddress The 64 bit physical address of the memory. + @param Length The length of the memory allocation in bytes. + @param MemoryType Type of memory allocated by this HOB. + +**/ +VOID +EFIAPI +GlueBuildMemoryAllocationHob ( + IN EFI_PHYSICAL_ADDRESS BaseAddress, + IN UINT64 Length, + IN EFI_MEMORY_TYPE MemoryType + ) +{ + // + // PEI HOB is read only for DXE phase + // + ASSERT (FALSE); +} diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeMemoryAllocationLib/DxeMemoryAllocationLib.inf b/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeMemoryAllocationLib/DxeMemoryAllocationLib.inf new file mode 100644 index 0000000..68ebf65 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeMemoryAllocationLib/DxeMemoryAllocationLib.inf @@ -0,0 +1,79 @@ +#/*++ +# +# 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: +# +# DxeMemoryAllocationLib.inf +# +# Abstract: +# +# Component description file for DxeMemoryAllocationLib. +# +#--*/ + +[defines] +BASE_NAME = EdkIIGlueDxeMemoryAllocationLib +COMPONENT_TYPE = LIBRARY + +[sources.common] + MemoryAllocationLib.c + +[sources.ia32] + +[sources.x64] + +[sources.ipf] + +[sources.ebc] + + +[includes.common] + . + ..\..\Include + ..\..\include\Library + $(EDK_SOURCE)\Foundation + $(EDK_SOURCE)\Foundation\Framework + $(EDK_SOURCE)\Foundation\Efi + $(EDK_SOURCE)\Foundation\Include + $(EDK_SOURCE)\Foundation\Efi\Include + $(EDK_SOURCE)\Foundation\Framework\Include + $(EDK_SOURCE)\Foundation\Include\IndustryStandard + $(EDK_SOURCE)\Foundation\Core\Dxe + $(EDK_SOURCE)\Foundation\Library\Dxe\Include + $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include + +[libraries.common] + EdkIIGlueBaseMemoryLib + EdkIIGlueUefiBootServicesTableLib + EfiProtocolLib + + +[libraries.ia32] + + +[libraries.x64] + + +[nmake.common] + C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION + LIB_STD_FLAGS = /NOLOGO /IGNORE:4006 + +[nmake.ia32] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32 + +[nmake.x64] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64 + +[nmake.ipf] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF + +[nmake.ebc] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_EBC
\ No newline at end of file diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeMemoryAllocationLib/EdkIIGlueDxeMemoryAllocationLib.cif b/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeMemoryAllocationLib/EdkIIGlueDxeMemoryAllocationLib.cif new file mode 100644 index 0000000..f08f575 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeMemoryAllocationLib/EdkIIGlueDxeMemoryAllocationLib.cif @@ -0,0 +1,11 @@ +<component> + name = "EdkIIGlueDxeMemoryAllocationLib" + category = ModulePart + LocalRoot = "Edk\Foundation\Library\EdkIIGlueLib\Library\DxeMemoryAllocationLib" + RefName = "EdkIIGlueDxeMemoryAllocationLib" +[files] +"EdkIIGlueDxeMemoryAllocationLib.sdl" +"EdkIIGlueDxeMemoryAllocationLib.mak" +"DxeMemoryAllocationLib.inf" +"MemoryAllocationLib.c" +<endComponent> diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeMemoryAllocationLib/EdkIIGlueDxeMemoryAllocationLib.mak b/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeMemoryAllocationLib/EdkIIGlueDxeMemoryAllocationLib.mak new file mode 100644 index 0000000..f88e68f --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeMemoryAllocationLib/EdkIIGlueDxeMemoryAllocationLib.mak @@ -0,0 +1,80 @@ +#********************************************************************** +#********************************************************************** +#** ** +#** (C)Copyright 1985-2009, American Megatrends, Inc. ** +#** ** +#** All Rights Reserved. ** +#** ** +#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +#** ** +#** Phone: (770)-246-8600 ** +#** ** +#********************************************************************** +#********************************************************************** + +#********************************************************************** +# $Header: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGlueDxeMemoryAllocationLib/EdkIIGlueDxeMemoryAllocationLib.mak 1 1/20/12 3:55a Jeffch $ +# +# $Revision: 1 $ +# +# $Date: 1/20/12 3:55a $ +#********************************************************************** +# Revision History +# ---------------- +# $Log: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGlueDxeMemoryAllocationLib/EdkIIGlueDxeMemoryAllocationLib.mak $ +# +# 1 1/20/12 3:55a Jeffch +# Create Intel EDK 1117 Patch 7. +# +# 1 9/27/11 6:17a Wesleychen +# Intel EDK initially releases. +# +# 1 9/18/09 1:54a Iminglin +# +#********************************************************************** +#<AMI_FHDR_START> +# +# Name: EdkIIGlueDxeMemoryAllocationLib.mak +# +# Description: +# +#<AMI_FHDR_END> +#********************************************************************** + + +$(EdkIIGlueDxeMemoryAllocationLib_LIB) : EdkIIGlueDxeMemoryAllocationLib + +EdkIIGlueDxeMemoryAllocationLib : $(BUILD_DIR)\EdkIIGlueDxeMemoryAllocationLib.mak EdkIIGlueDxeMemoryAllocationLibBin + +$(BUILD_DIR)\EdkIIGlueDxeMemoryAllocationLib.mak : $(EdkIIGlueDxeMemoryAllocationLib_DIR)\$(@B).cif $(EdkIIGlueDxeMemoryAllocationLib_DIR)\$(@B).mak $(BUILD_RULES) + $(CIF2MAK) $(EdkIIGlueDxeMemoryAllocationLib_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS) + +EdkIIGlueDxeMemoryAllocationLibBin : $(EdkIIGlueBaseMemoryLib_LIB) $(EdkIIGlueUefiBootServicesTableLib_LIB) $(EFIPROTOCOLLIB) +!IF "$(x64_BUILD)"=="1" + $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\ + BUILD_DIR=$(BUILD_DIR)\ + /f $(BUILD_DIR)\EdkIIGlueDxeMemoryAllocationLib.mak all\ + TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueDxeMemoryAllocationLib_LIB)" + $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\ + BUILD_DIR=$(BUILD_DIR)\IA32\ + /f $(BUILD_DIR)\EdkIIGlueDxeMemoryAllocationLib.mak all\ + TYPE=PEI_LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueDxeMemoryAllocationLib_LIB)" +!ELSE + $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\ + BUILD_DIR=$(BUILD_DIR)\ + /f $(BUILD_DIR)\EdkIIGlueDxeMemoryAllocationLib.mak all\ + TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueDxeMemoryAllocationLib_LIB)" +!ENDIF +#********************************************************************** +#********************************************************************** +#** ** +#** (C)Copyright 1985-2009, American Megatrends, Inc. ** +#** ** +#** All Rights Reserved. ** +#** ** +#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +#** ** +#** Phone: (770)-246-8600 ** +#** ** +#********************************************************************** +#********************************************************************** diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeMemoryAllocationLib/EdkIIGlueDxeMemoryAllocationLib.sdl b/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeMemoryAllocationLib/EdkIIGlueDxeMemoryAllocationLib.sdl new file mode 100644 index 0000000..191f45e --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeMemoryAllocationLib/EdkIIGlueDxeMemoryAllocationLib.sdl @@ -0,0 +1,26 @@ +TOKEN + Name = "EdkIIGlueDxeMemoryAllocationLib_SUPPORT" + Value = "1" + Help = "Main switch to enable EdkIIGlueDxeMemoryAllocationLib support in Project" + TokenType = Boolean + TargetEQU = Yes + TargetMAK = Yes + Master = Yes +End + +TOKEN + Name = "EdkIIGlueDxeMemoryAllocationLib_LIB" + Value = "$$(LIB_BUILD_DIR)\EdkIIGlueDxeMemoryAllocationLib.lib" + TokenType = Expression + TargetMAK = Yes +End + +PATH + Name = "EdkIIGlueDxeMemoryAllocationLib_DIR" +End + +MODULE + Help = "Includes EdkIIGlueDxeMemoryAllocationLib.mak to Project" + File = "EdkIIGlueDxeMemoryAllocationLib.mak" +End + diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeMemoryAllocationLib/MemoryAllocationLib.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeMemoryAllocationLib/MemoryAllocationLib.c new file mode 100644 index 0000000..21a781c --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeMemoryAllocationLib/MemoryAllocationLib.c @@ -0,0 +1,1079 @@ +/*++ + +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: + + MemoryAllocationLib.c + +Abstract: + + Support routines for memory allocation routines for use with drivers. + +--*/ + +#include "EdkIIGlueDxe.h" + + +/** + Allocates one or more 4KB pages of a certain memory type. + + Allocates the number of 4KB pages of a certain memory type and returns a pointer to the allocated + buffer. The buffer returned is aligned on a 4KB boundary. If Pages is 0, then NULL is returned. + If there is not enough memory remaining to satisfy the request, then NULL is returned. + + @param MemoryType The type of memory to allocate. + @param Pages The number of 4 KB pages to allocate. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +InternalAllocatePages ( + IN EFI_MEMORY_TYPE MemoryType, + IN UINTN Pages + ) +{ + EFI_STATUS Status; + EFI_PHYSICAL_ADDRESS Memory; + + if (Pages == 0) { + return NULL; + } + + Status = (gBS->AllocatePages) (AllocateAnyPages, MemoryType, Pages, &Memory); + if (EFI_ERROR (Status)) { + Memory = 0; + } + return (VOID *) (UINTN) Memory; +} + +/** + Allocates one or more 4KB pages of type EfiBootServicesData. + + Allocates the number of 4KB pages of type EfiBootServicesData and returns a pointer to the + allocated buffer. The buffer returned is aligned on a 4KB boundary. If Pages is 0, then NULL + is returned. If there is not enough memory remaining to satisfy the request, then NULL is + returned. + + @param Pages The number of 4 KB pages to allocate. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +GlueAllocatePages ( + IN UINTN Pages + ) +{ + return InternalAllocatePages (EfiBootServicesData, Pages); +} + +/** + Allocates one or more 4KB pages of type EfiRuntimeServicesData. + + Allocates the number of 4KB pages of type EfiRuntimeServicesData and returns a pointer to the + allocated buffer. The buffer returned is aligned on a 4KB boundary. If Pages is 0, then NULL + is returned. If there is not enough memory remaining to satisfy the request, then NULL is + returned. + + @param Pages The number of 4 KB pages to allocate. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +AllocateRuntimePages ( + IN UINTN Pages + ) +{ + return InternalAllocatePages (EfiRuntimeServicesData, Pages); +} + +/** + Allocates one or more 4KB pages of type EfiReservedMemoryType. + + Allocates the number of 4KB pages of type EfiReservedMemoryType and returns a pointer to the + allocated buffer. The buffer returned is aligned on a 4KB boundary. If Pages is 0, then NULL + is returned. If there is not enough memory remaining to satisfy the request, then NULL is + returned. + + @param Pages The number of 4 KB pages to allocate. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +AllocateReservedPages ( + IN UINTN Pages + ) +{ + return InternalAllocatePages (EfiReservedMemoryType, Pages); +} + +/** + Frees one or more 4KB pages that were previously allocated with one of the page allocation + functions in the Memory Allocation Library. + + Frees the number of 4KB pages specified by Pages from the buffer specified by Buffer. Buffer + must have been allocated on a previous call to the page allocation services of the Memory + Allocation Library. + If Buffer was not allocated with a page allocation function in the Memory Allocation Library, + then ASSERT(). + If Pages is zero, then ASSERT(). + + @param Buffer Pointer to the buffer of pages to free. + @param Pages The number of 4 KB pages to free. + +**/ +VOID +EFIAPI +GlueFreePages ( + IN VOID *Buffer, + IN UINTN Pages + ) +{ + EFI_STATUS Status; + + ASSERT (Pages != 0); + Status = (gBS->FreePages) ((EFI_PHYSICAL_ADDRESS) (UINTN) Buffer, Pages); + ASSERT_EFI_ERROR (Status); +} + +/** + Allocates one or more 4KB pages of a certain memory type at a specified alignment. + + Allocates the number of 4KB pages specified by Pages of a certain memory type with an alignment + specified by Alignment. The allocated buffer is returned. If Pages is 0, then NULL is returned. + If there is not enough memory at the specified alignment remaining to satisfy the request, then + NULL is returned. + If Alignment is not a power of two and Alignment is not zero, then ASSERT(). + + @param MemoryType The type of memory to allocate. + @param Pages The number of 4 KB pages to allocate. + @param Alignment The requested alignment of the allocation. Must be a power of two. + If Alignment is zero, then byte alignment is used. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +InternalAllocateAlignedPages ( + IN EFI_MEMORY_TYPE MemoryType, + IN UINTN Pages, + IN UINTN Alignment + ) +{ + EFI_STATUS Status; + EFI_PHYSICAL_ADDRESS Memory; + UINTN AlignedMemory; + UINTN AlignmentMask; + UINTN UnalignedPages; + UINTN RealPages; + + // + // Alignment must be a power of two or zero. + // + ASSERT ((Alignment & (Alignment - 1)) == 0); + + if (Pages == 0) { + return NULL; + } + if (Alignment > EFI_PAGE_SIZE) { + // + // Caculate the total number of pages since alignment is larger than page size. + // + AlignmentMask = Alignment - 1; + RealPages = Pages + EFI_SIZE_TO_PAGES (Alignment); + // + // Make sure that Pages plus EFI_SIZE_TO_PAGES (Alignment) does not overflow. + // + ASSERT (RealPages > Pages); + + Status = (gBS->AllocatePages) (AllocateAnyPages, MemoryType, RealPages, &Memory); + if (EFI_ERROR (Status)) { + return NULL; + } + AlignedMemory = ((UINTN) Memory + AlignmentMask) & ~AlignmentMask; + UnalignedPages = EFI_SIZE_TO_PAGES ((UINTN) Memory - AlignedMemory); + if (UnalignedPages > 0) { + // + // Free first unaligned page(s). + // + Status = (gBS->FreePages) (Memory, UnalignedPages); + ASSERT_EFI_ERROR (Status); + } + Memory = (EFI_PHYSICAL_ADDRESS) (AlignedMemory + EFI_PAGES_TO_SIZE (Pages)); + UnalignedPages = RealPages - Pages - UnalignedPages; + if (UnalignedPages > 0) { + // + // Free last unaligned page(s). + // + Status = (gBS->FreePages) (Memory, UnalignedPages); + ASSERT_EFI_ERROR (Status); + } + } else { + // + // Do not over-allocate pages in this case. + // + Status = (gBS->AllocatePages) (AllocateAnyPages, MemoryType, Pages, &Memory); + if (EFI_ERROR (Status)) { + return NULL; + } + AlignedMemory = (UINTN) Memory; + } + return (VOID *) AlignedMemory; +} + +/** + Allocates one or more 4KB pages of type EfiBootServicesData at a specified alignment. + + Allocates the number of 4KB pages specified by Pages of type EfiBootServicesData with an + alignment specified by Alignment. The allocated buffer is returned. If Pages is 0, then NULL is + returned. If there is not enough memory at the specified alignment remaining to satisfy the + request, then NULL is returned. + If Alignment is not a power of two and Alignment is not zero, then ASSERT(). + + @param Pages The number of 4 KB pages to allocate. + @param Alignment The requested alignment of the allocation. Must be a power of two. + If Alignment is zero, then byte alignment is used. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +AllocateAlignedPages ( + IN UINTN Pages, + IN UINTN Alignment + ) +{ + return InternalAllocateAlignedPages (EfiBootServicesData, Pages, Alignment); +} + +/** + Allocates one or more 4KB pages of type EfiRuntimeServicesData at a specified alignment. + + Allocates the number of 4KB pages specified by Pages of type EfiRuntimeServicesData with an + alignment specified by Alignment. The allocated buffer is returned. If Pages is 0, then NULL is + returned. If there is not enough memory at the specified alignment remaining to satisfy the + request, then NULL is returned. + If Alignment is not a power of two and Alignment is not zero, then ASSERT(). + + @param Pages The number of 4 KB pages to allocate. + @param Alignment The requested alignment of the allocation. Must be a power of two. + If Alignment is zero, then byte alignment is used. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +AllocateAlignedRuntimePages ( + IN UINTN Pages, + IN UINTN Alignment + ) +{ + return InternalAllocateAlignedPages (EfiRuntimeServicesData, Pages, Alignment); +} + +/** + Allocates one or more 4KB pages of type EfiReservedMemoryType at a specified alignment. + + Allocates the number of 4KB pages specified by Pages of type EfiReservedMemoryType with an + alignment specified by Alignment. The allocated buffer is returned. If Pages is 0, then NULL is + returned. If there is not enough memory at the specified alignment remaining to satisfy the + request, then NULL is returned. + If Alignment is not a power of two and Alignment is not zero, then ASSERT(). + + @param Pages The number of 4 KB pages to allocate. + @param Alignment The requested alignment of the allocation. Must be a power of two. + If Alignment is zero, then byte alignment is used. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +AllocateAlignedReservedPages ( + IN UINTN Pages, + IN UINTN Alignment + ) +{ + return InternalAllocateAlignedPages (EfiReservedMemoryType, Pages, Alignment); +} + +/** + Frees one or more 4KB pages that were previously allocated with one of the aligned page + allocation functions in the Memory Allocation Library. + + Frees the number of 4KB pages specified by Pages from the buffer specified by Buffer. Buffer + must have been allocated on a previous call to the aligned page allocation services of the Memory + Allocation Library. + If Buffer was not allocated with an aligned page allocation function in the Memory Allocation + Library, then ASSERT(). + If Pages is zero, then ASSERT(). + + @param Buffer Pointer to the buffer of pages to free. + @param Pages The number of 4 KB pages to free. + +**/ +VOID +EFIAPI +FreeAlignedPages ( + IN VOID *Buffer, + IN UINTN Pages + ) +{ + EFI_STATUS Status; + + ASSERT (Pages != 0); + Status = (gBS->FreePages) ((EFI_PHYSICAL_ADDRESS) (UINTN) Buffer, Pages); + ASSERT_EFI_ERROR (Status); +} + +/** + Allocates a buffer of a certain pool type. + + Allocates the number bytes specified by AllocationSize of a certain pool type and returns a + pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is + returned. If there is not enough memory remaining to satisfy the request, then NULL is returned. + + @param MemoryType The type of memory to allocate. + @param AllocationSize The number of bytes to allocate. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +InternalAllocatePool ( + IN EFI_MEMORY_TYPE MemoryType, + IN UINTN AllocationSize + ) +{ + EFI_STATUS Status; + VOID *Memory; + + Status = (gBS->AllocatePool) (MemoryType, AllocationSize, &Memory); + if (EFI_ERROR (Status)) { + Memory = NULL; + } + return Memory; +} + +/** + Allocates a buffer of type EfiBootServicesData. + + Allocates the number bytes specified by AllocationSize of type EfiBootServicesData and returns a + pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is + returned. If there is not enough memory remaining to satisfy the request, then NULL is returned. + + @param AllocationSize The number of bytes to allocate. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +GlueAllocatePool ( + IN UINTN AllocationSize + ) +{ + return InternalAllocatePool (EfiBootServicesData, AllocationSize); +} + +/** + Allocates a buffer of type EfiRuntimeServicesData. + + Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData and returns + a pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is + returned. If there is not enough memory remaining to satisfy the request, then NULL is returned. + + @param AllocationSize The number of bytes to allocate. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +AllocateRuntimePool ( + IN UINTN AllocationSize + ) +{ + return InternalAllocatePool (EfiRuntimeServicesData, AllocationSize); +} + +/** + Allocates a buffer of type EfieservedMemoryType. + + Allocates the number bytes specified by AllocationSize of type EfieservedMemoryType and returns + a pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is + returned. If there is not enough memory remaining to satisfy the request, then NULL is returned. + + @param AllocationSize The number of bytes to allocate. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +AllocateReservedPool ( + IN UINTN AllocationSize + ) +{ + return InternalAllocatePool (EfiReservedMemoryType, AllocationSize); +} + +/** + Allocates and zeros a buffer of a certian pool type. + + Allocates the number bytes specified by AllocationSize of a certian pool type, clears the buffer + with zeros, and returns a pointer to the allocated buffer. If AllocationSize is 0, then a valid + buffer of 0 size is returned. If there is not enough memory remaining to satisfy the request, + then NULL is returned. + + @param PoolType The type of memory to allocate. + @param AllocationSize The number of bytes to allocate and zero. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +InternalAllocateZeroPool ( + IN EFI_MEMORY_TYPE PoolType, + IN UINTN AllocationSize + ) +{ + VOID *Memory; + + Memory = InternalAllocatePool (PoolType, AllocationSize); + if (Memory != NULL) { + Memory = ZeroMem (Memory, AllocationSize); + } + return Memory; +} + +/** + Allocates and zeros a buffer of type EfiBootServicesData. + + Allocates the number bytes specified by AllocationSize of type EfiBootServicesData, clears the + buffer with zeros, and returns a pointer to the allocated buffer. If AllocationSize is 0, then a + valid buffer of 0 size is returned. If there is not enough memory remaining to satisfy the + request, then NULL is returned. + + @param AllocationSize The number of bytes to allocate and zero. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +GlueAllocateZeroPool ( + IN UINTN AllocationSize + ) +{ + return InternalAllocateZeroPool (EfiBootServicesData, AllocationSize); +} + +/** + Allocates and zeros a buffer of type EfiRuntimeServicesData. + + Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData, clears the + buffer with zeros, and returns a pointer to the allocated buffer. If AllocationSize is 0, then a + valid buffer of 0 size is returned. If there is not enough memory remaining to satisfy the + request, then NULL is returned. + + @param AllocationSize The number of bytes to allocate and zero. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +AllocateRuntimeZeroPool ( + IN UINTN AllocationSize + ) +{ + return InternalAllocateZeroPool (EfiRuntimeServicesData, AllocationSize); +} + +/** + Allocates and zeros a buffer of type EfiReservedMemoryType. + + Allocates the number bytes specified by AllocationSize of type EfiReservedMemoryType, clears the + buffer with zeros, and returns a pointer to the allocated buffer. If AllocationSize is 0, then a + valid buffer of 0 size is returned. If there is not enough memory remaining to satisfy the + request, then NULL is returned. + + @param AllocationSize The number of bytes to allocate and zero. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +AllocateReservedZeroPool ( + IN UINTN AllocationSize + ) +{ + return InternalAllocateZeroPool (EfiReservedMemoryType, AllocationSize); +} + +/** + Copies a buffer to an allocated buffer of a certian pool type. + + Allocates the number bytes specified by AllocationSize of a certian pool type, copies + AllocationSize bytes from Buffer to the newly allocated buffer, and returns a pointer to the + allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there + is not enough memory remaining to satisfy the request, then NULL is returned. + If Buffer is NULL, then ASSERT(). + If AllocationSize is greater than (MAX_ADDRESS ?Buffer + 1), then ASSERT(). + + @param PoolType The type of pool to allocate. + @param AllocationSize The number of bytes to allocate and zero. + @param Buffer The buffer to copy to the allocated buffer. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +InternalAllocateCopyPool ( + IN EFI_MEMORY_TYPE PoolType, + IN UINTN AllocationSize, + IN CONST VOID *Buffer + ) +{ + VOID *Memory; + + ASSERT (Buffer != NULL); + ASSERT (AllocationSize <= (MAX_ADDRESS - (UINTN) Buffer + 1)); + + Memory = InternalAllocatePool (PoolType, AllocationSize); + if (Memory != NULL) { + Memory = CopyMem (Memory, Buffer, AllocationSize); + } + return Memory; +} + +/** + Copies a buffer to an allocated buffer of type EfiBootServicesData. + + Allocates the number bytes specified by AllocationSize of type EfiBootServicesData, copies + AllocationSize bytes from Buffer to the newly allocated buffer, and returns a pointer to the + allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there + is not enough memory remaining to satisfy the request, then NULL is returned. + If Buffer is NULL, then ASSERT(). + If AllocationSize is greater than (MAX_ADDRESS ?Buffer + 1), then ASSERT(). + + @param AllocationSize The number of bytes to allocate and zero. + @param Buffer The buffer to copy to the allocated buffer. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +GlueAllocateCopyPool ( + IN UINTN AllocationSize, + IN CONST VOID *Buffer + ) +{ + return InternalAllocateCopyPool (EfiBootServicesData, AllocationSize, Buffer); +} + +/** + Copies a buffer to an allocated buffer of type EfiRuntimeServicesData. + + Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData, copies + AllocationSize bytes from Buffer to the newly allocated buffer, and returns a pointer to the + allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there + is not enough memory remaining to satisfy the request, then NULL is returned. + If Buffer is NULL, then ASSERT(). + If AllocationSize is greater than (MAX_ADDRESS ?Buffer + 1), then ASSERT(). + + @param AllocationSize The number of bytes to allocate and zero. + @param Buffer The buffer to copy to the allocated buffer. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +AllocateRuntimeCopyPool ( + IN UINTN AllocationSize, + IN CONST VOID *Buffer + ) +{ + return InternalAllocateCopyPool (EfiRuntimeServicesData, AllocationSize, Buffer); +} + +/** + Copies a buffer to an allocated buffer of type EfiReservedMemoryType. + + Allocates the number bytes specified by AllocationSize of type EfiReservedMemoryType, copies + AllocationSize bytes from Buffer to the newly allocated buffer, and returns a pointer to the + allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there + is not enough memory remaining to satisfy the request, then NULL is returned. + If Buffer is NULL, then ASSERT(). + If AllocationSize is greater than (MAX_ADDRESS ?Buffer + 1), then ASSERT(). + + @param AllocationSize The number of bytes to allocate and zero. + @param Buffer The buffer to copy to the allocated buffer. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +AllocateReservedCopyPool ( + IN UINTN AllocationSize, + IN CONST VOID *Buffer + ) +{ + return InternalAllocateCopyPool (EfiReservedMemoryType, AllocationSize, Buffer); +} + +/** + Frees a buffer that was previously allocated with one of the pool allocation functions in the + Memory Allocation Library. + + Frees the buffer specified by Buffer. Buffer must have been allocated on a previous call to the + pool allocation services of the Memory Allocation Library. + If Buffer was not allocated with a pool allocation function in the Memory Allocation Library, + then ASSERT(). + + @param Buffer Pointer to the buffer to free. + +**/ +VOID +EFIAPI +GlueFreePool ( + IN VOID *Buffer + ) +{ + EFI_STATUS Status; + + Status = (gBS->FreePool) (Buffer); + ASSERT_EFI_ERROR (Status); +} + +/** + Allocates a buffer of a certain pool type at a specified alignment. + + Allocates the number bytes specified by AllocationSize of a certain pool type with an alignment + specified by Alignment. The allocated buffer is returned. If AllocationSize is 0, then a valid + buffer of 0 size is returned. If there is not enough memory at the specified alignment remaining + to satisfy the request, then NULL is returned. + If Alignment is not a power of two and Alignment is not zero, then ASSERT(). + + @param PoolType The type of pool to allocate. + @param AllocationSize The number of bytes to allocate. + @param Alignment The requested alignment of the allocation. Must be a power of two. If Alignment is zero, then byte alignment is used. + If Alignment is zero, then byte alignment is used. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +InternalAllocateAlignedPool ( + IN EFI_MEMORY_TYPE PoolType, + IN UINTN AllocationSize, + IN UINTN Alignment + ) +{ + VOID *RawAddress; + UINTN AlignedAddress; + UINTN AlignmentMask; + UINTN OverAllocationSize; + UINTN RealAllocationSize; + VOID **FreePointer; + + // + // Alignment must be a power of two or zero. + // + ASSERT ((Alignment & (Alignment - 1)) == 0); + + if (Alignment == 0) { + AlignmentMask = Alignment; + } else { + AlignmentMask = Alignment - 1; + } + // + // Calculate the extra memory size, over-allocate memory pool and get the aligned memory address. + // + OverAllocationSize = sizeof (RawAddress) + AlignmentMask; + RealAllocationSize = AllocationSize + OverAllocationSize; + // + // Make sure that AllocationSize plus OverAllocationSize does not overflow. + // + ASSERT (RealAllocationSize > AllocationSize); + + RawAddress = InternalAllocatePool (PoolType, RealAllocationSize); + if (RawAddress == NULL) { + return NULL; + } + AlignedAddress = ((UINTN) RawAddress + OverAllocationSize) & ~AlignmentMask; + // + // Save the original memory address just before the aligned address. + // + FreePointer = (VOID **)(AlignedAddress - sizeof (RawAddress)); + *FreePointer = RawAddress; + + return (VOID *) AlignedAddress; +} + +/** + Allocates a buffer of type EfiBootServicesData at a specified alignment. + + Allocates the number bytes specified by AllocationSize of type EfiBootServicesData with an + alignment specified by Alignment. The allocated buffer is returned. If AllocationSize is 0, + then a valid buffer of 0 size is returned. If there is not enough memory at the specified + alignment remaining to satisfy the request, then NULL is returned. + If Alignment is not a power of two and Alignment is not zero, then ASSERT(). + + @param AllocationSize The number of bytes to allocate. + @param Alignment The requested alignment of the allocation. Must be a power of two. + If Alignment is zero, then byte alignment is used. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +AllocateAlignedPool ( + IN UINTN AllocationSize, + IN UINTN Alignment + ) +{ + return InternalAllocateAlignedPool (EfiBootServicesData, AllocationSize, Alignment); +} + +/** + Allocates a buffer of type EfiRuntimeServicesData at a specified alignment. + + Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData with an + alignment specified by Alignment. The allocated buffer is returned. If AllocationSize is 0, + then a valid buffer of 0 size is returned. If there is not enough memory at the specified + alignment remaining to satisfy the request, then NULL is returned. + If Alignment is not a power of two and Alignment is not zero, then ASSERT(). + + @param AllocationSize The number of bytes to allocate. + @param Alignment The requested alignment of the allocation. Must be a power of two. + If Alignment is zero, then byte alignment is used. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +AllocateAlignedRuntimePool ( + IN UINTN AllocationSize, + IN UINTN Alignment + ) +{ + return InternalAllocateAlignedPool (EfiRuntimeServicesData, AllocationSize, Alignment); +} + +/** + Allocates a buffer of type EfieservedMemoryType at a specified alignment. + + Allocates the number bytes specified by AllocationSize of type EfieservedMemoryType with an + alignment specified by Alignment. The allocated buffer is returned. If AllocationSize is 0, + then a valid buffer of 0 size is returned. If there is not enough memory at the specified + alignment remaining to satisfy the request, then NULL is returned. + If Alignment is not a power of two and Alignment is not zero, then ASSERT(). + + @param AllocationSize The number of bytes to allocate. + @param Alignment The requested alignment of the allocation. Must be a power of two. + If Alignment is zero, then byte alignment is used. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +AllocateAlignedReservedPool ( + IN UINTN AllocationSize, + IN UINTN Alignment + ) +{ + return InternalAllocateAlignedPool (EfiReservedMemoryType, AllocationSize, Alignment); +} + +/** + Allocates and zeros a buffer of a certain pool type at a specified alignment. + + Allocates the number bytes specified by AllocationSize of a certain pool type with an alignment + specified by Alignment, clears the buffer with zeros, and returns a pointer to the allocated + buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there is not + enough memory at the specified alignment remaining to satisfy the request, then NULL is returned. + If Alignment is not a power of two and Alignment is not zero, then ASSERT(). + + @param PoolType The type of pool to allocate. + @param AllocationSize The number of bytes to allocate. + @param Alignment The requested alignment of the allocation. Must be a power of two. + If Alignment is zero, then byte alignment is used. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +InternalAllocateAlignedZeroPool ( + IN EFI_MEMORY_TYPE PoolType, + IN UINTN AllocationSize, + IN UINTN Alignment + ) +{ + VOID *Memory; + Memory = InternalAllocateAlignedPool (PoolType, AllocationSize, Alignment); + if (Memory != NULL) { + Memory = ZeroMem (Memory, AllocationSize); + } + return Memory; +} + +/** + Allocates and zeros a buffer of type EfiBootServicesData at a specified alignment. + + Allocates the number bytes specified by AllocationSize of type EfiBootServicesData with an + alignment specified by Alignment, clears the buffer with zeros, and returns a pointer to the + allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there + is not enough memory at the specified alignment remaining to satisfy the request, then NULL is + returned. + If Alignment is not a power of two and Alignment is not zero, then ASSERT(). + + @param AllocationSize The number of bytes to allocate. + @param Alignment The requested alignment of the allocation. Must be a power of two. + If Alignment is zero, then byte alignment is used. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +AllocateAlignedZeroPool ( + IN UINTN AllocationSize, + IN UINTN Alignment + ) +{ + return InternalAllocateAlignedZeroPool (EfiBootServicesData, AllocationSize, Alignment); +} + +/** + Allocates and zeros a buffer of type EfiRuntimeServicesData at a specified alignment. + + Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData with an + alignment specified by Alignment, clears the buffer with zeros, and returns a pointer to the + allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there + is not enough memory at the specified alignment remaining to satisfy the request, then NULL is + returned. + If Alignment is not a power of two and Alignment is not zero, then ASSERT(). + + @param AllocationSize The number of bytes to allocate. + @param Alignment The requested alignment of the allocation. Must be a power of two. + If Alignment is zero, then byte alignment is used. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +AllocateAlignedRuntimeZeroPool ( + IN UINTN AllocationSize, + IN UINTN Alignment + ) +{ + return InternalAllocateAlignedZeroPool (EfiRuntimeServicesData, AllocationSize, Alignment); +} + +/** + Allocates and zeros a buffer of type EfieservedMemoryType at a specified alignment. + + Allocates the number bytes specified by AllocationSize of type EfieservedMemoryType with an + alignment specified by Alignment, clears the buffer with zeros, and returns a pointer to the + allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there + is not enough memory at the specified alignment remaining to satisfy the request, then NULL is + returned. + If Alignment is not a power of two and Alignment is not zero, then ASSERT(). + + @param AllocationSize The number of bytes to allocate. + @param Alignment The requested alignment of the allocation. Must be a power of two. + If Alignment is zero, then byte alignment is used. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +AllocateAlignedReservedZeroPool ( + IN UINTN AllocationSize, + IN UINTN Alignment + ) +{ + return InternalAllocateAlignedZeroPool (EfiReservedMemoryType, AllocationSize, Alignment); +} + +/** + Copies a buffer to an allocated buffer of a certain pool type at a specified alignment. + + Allocates the number bytes specified by AllocationSize of a certain pool type with an alignment + specified by Alignment. The allocated buffer is returned. If AllocationSize is 0, then a valid + buffer of 0 size is returned. If there is not enough memory at the specified alignment remaining + to satisfy the request, then NULL is returned. + If Alignment is not a power of two and Alignment is not zero, then ASSERT(). + + @param PoolType The type of pool to allocate. + @param AllocationSize The number of bytes to allocate. + @param Buffer The buffer to copy to the allocated buffer. + @param Alignment The requested alignment of the allocation. Must be a power of two. + If Alignment is zero, then byte alignment is used. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +InternalAllocateAlignedCopyPool ( + IN EFI_MEMORY_TYPE PoolType, + IN UINTN AllocationSize, + IN CONST VOID *Buffer, + IN UINTN Alignment + ) +{ + VOID *Memory; + + ASSERT (Buffer != NULL); + ASSERT (AllocationSize <= (MAX_ADDRESS - (UINTN) Buffer + 1)); + + Memory = InternalAllocateAlignedPool (PoolType, AllocationSize, Alignment); + if (Memory != NULL) { + Memory = CopyMem (Memory, Buffer, AllocationSize); + } + return Memory; +} + +/** + Copies a buffer to an allocated buffer of type EfiBootServicesData at a specified alignment. + + Allocates the number bytes specified by AllocationSize of type EfiBootServicesData type with an + alignment specified by Alignment. The allocated buffer is returned. If AllocationSize is 0, + then a valid buffer of 0 size is returned. If there is not enough memory at the specified + alignment remaining to satisfy the request, then NULL is returned. + If Alignment is not a power of two and Alignment is not zero, then ASSERT(). + + @param AllocationSize The number of bytes to allocate. + @param Buffer The buffer to copy to the allocated buffer. + @param Alignment The requested alignment of the allocation. Must be a power of two. + If Alignment is zero, then byte alignment is used. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +AllocateAlignedCopyPool ( + IN UINTN AllocationSize, + IN CONST VOID *Buffer, + IN UINTN Alignment + ) +{ + return InternalAllocateAlignedCopyPool (EfiBootServicesData, AllocationSize, Buffer, Alignment); +} + +/** + Copies a buffer to an allocated buffer of type EfiRuntimeServicesData at a specified alignment. + + Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData type with an + alignment specified by Alignment. The allocated buffer is returned. If AllocationSize is 0, + then a valid buffer of 0 size is returned. If there is not enough memory at the specified + alignment remaining to satisfy the request, then NULL is returned. + If Alignment is not a power of two and Alignment is not zero, then ASSERT(). + + @param AllocationSize The number of bytes to allocate. + @param Buffer The buffer to copy to the allocated buffer. + @param Alignment The requested alignment of the allocation. Must be a power of two. + If Alignment is zero, then byte alignment is used. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +AllocateAlignedRuntimeCopyPool ( + IN UINTN AllocationSize, + IN CONST VOID *Buffer, + IN UINTN Alignment + ) +{ + return InternalAllocateAlignedCopyPool (EfiRuntimeServicesData, AllocationSize, Buffer, Alignment); +} + +/** + Copies a buffer to an allocated buffer of type EfiReservedMemoryType at a specified alignment. + + Allocates the number bytes specified by AllocationSize of type EfiReservedMemoryType type with an + alignment specified by Alignment. The allocated buffer is returned. If AllocationSize is 0, + then a valid buffer of 0 size is returned. If there is not enough memory at the specified + alignment remaining to satisfy the request, then NULL is returned. + If Alignment is not a power of two and Alignment is not zero, then ASSERT(). + + @param AllocationSize The number of bytes to allocate. + @param Buffer The buffer to copy to the allocated buffer. + @param Alignment The requested alignment of the allocation. Must be a power of two. + If Alignment is zero, then byte alignment is used. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +AllocateAlignedReservedCopyPool ( + IN UINTN AllocationSize, + IN CONST VOID *Buffer, + IN UINTN Alignment + ) +{ + return InternalAllocateAlignedCopyPool (EfiReservedMemoryType, AllocationSize, Buffer, Alignment); +} + +/** + Frees a buffer that was previously allocated with one of the aligned pool allocation functions + in the Memory Allocation Library. + + Frees the buffer specified by Buffer. Buffer must have been allocated on a previous call to the + aligned pool allocation services of the Memory Allocation Library. + If Buffer was not allocated with an aligned pool allocation function in the Memory Allocation + Library, then ASSERT(). + + @param Buffer Pointer to the buffer to free. + +**/ +VOID +EFIAPI +FreeAlignedPool ( + IN VOID *Buffer + ) +{ + VOID *RawAddress; + VOID **FreePointer; + EFI_STATUS Status; + + // + // Get the pre-saved original address in the over-allocate pool. + // + FreePointer = (VOID **)((UINTN) Buffer - sizeof (RawAddress)); + RawAddress = *FreePointer; + + Status = (gBS->FreePool) (RawAddress); + ASSERT_EFI_ERROR (Status); +} diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeReportStatusCodeLib/DxeReportStatusCodeLib.inf b/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeReportStatusCodeLib/DxeReportStatusCodeLib.inf new file mode 100644 index 0000000..a2eed0a --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeReportStatusCodeLib/DxeReportStatusCodeLib.inf @@ -0,0 +1,92 @@ +#/*++ +# +# 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: +# +# DxeReportStatusCodeLib.inf +# +# Abstract: +# +# Component description file for DxeReportStatusCodeLib. +# +#--*/ + +[defines] +BASE_NAME = EdkIIGlueDxeReportStatusCodeLib +COMPONENT_TYPE = LIBRARY + +[sources.common] + ReportStatusCodeLib.c + +[sources.ia32] + +[sources.x64] + +[sources.ipf] + +[sources.ebc] + + +[includes.common] + . + ..\..\Include + ..\..\include\Library + $(EDK_SOURCE)\Foundation + $(EDK_SOURCE)\Foundation\Framework + $(EDK_SOURCE)\Foundation\Efi + $(EDK_SOURCE)\Foundation\Include + $(EDK_SOURCE)\Foundation\Efi\Include + $(EDK_SOURCE)\Foundation\Framework\Include + $(EDK_SOURCE)\Foundation\Include\IndustryStandard + $(EDK_SOURCE)\Foundation\Core\Dxe + $(EDK_SOURCE)\Foundation\Library\Dxe\Include + $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include + $(EDK_SOURCE)\Foundation\Framework\Guid\DataHubRecords + $(EDK_SOURCE)\Foundation\Framework\Guid\StatusCodeDataTypeId + $(EDK_SOURCE)\Foundation\Core\Dxe\ArchProtocol\StatusCode + +[libraries.common] + EdkIIGlueBaseLib + EdkIIGlueBaseIoLibIntrinsic + EdkIIGlueBaseMemoryLib + EdkIIGlueUefiBootServicesTableLib +# +# when EFI_SPECIFICATION_VERSION < 0x00020000, gRT is used +# + EdkIIGlueUefiRuntimeServicesTableLib +# R8.x lib + EfiProtocolLib +# Possibly, gEfiCallerIdGuid might be used. + EdkGuidLib + ArchProtocolLib + + +[libraries.ia32] + + +[libraries.x64] + + +[nmake.common] + C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION + LIB_STD_FLAGS = /NOLOGO /IGNORE:4006 + +[nmake.ia32] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32 + +[nmake.x64] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64 + +[nmake.ipf] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF + +[nmake.ebc] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_EBC
\ No newline at end of file diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeReportStatusCodeLib/EdkIIGlueDxeReportStatusCodeLib.cif b/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeReportStatusCodeLib/EdkIIGlueDxeReportStatusCodeLib.cif new file mode 100644 index 0000000..af45c64 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeReportStatusCodeLib/EdkIIGlueDxeReportStatusCodeLib.cif @@ -0,0 +1,11 @@ +<component> + name = "EdkIIGlueDxeReportStatusCodeLib" + category = ModulePart + LocalRoot = "Edk\Foundation\Library\EdkIIGlueLib\Library\DxeReportStatusCodeLib" + RefName = "EdkIIGlueDxeReportStatusCodeLib" +[files] +"EdkIIGlueDxeReportStatusCodeLib.sdl" +"EdkIIGlueDxeReportStatusCodeLib.mak" +"DxeReportStatusCodeLib.inf" +"ReportStatusCodeLib.c" +<endComponent> diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeReportStatusCodeLib/EdkIIGlueDxeReportStatusCodeLib.mak b/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeReportStatusCodeLib/EdkIIGlueDxeReportStatusCodeLib.mak new file mode 100644 index 0000000..e2056f8 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeReportStatusCodeLib/EdkIIGlueDxeReportStatusCodeLib.mak @@ -0,0 +1,91 @@ +#********************************************************************** +#********************************************************************** +#** ** +#** (C)Copyright 1985-2009, American Megatrends, Inc. ** +#** ** +#** All Rights Reserved. ** +#** ** +#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +#** ** +#** Phone: (770)-246-8600 ** +#** ** +#********************************************************************** +#********************************************************************** + +#********************************************************************** +# $Header: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGlueDxeReportStatusCodeLib/EdkIIGlueDxeReportStatusCodeLib.mak 1 1/20/12 3:55a Jeffch $ +# +# $Revision: 1 $ +# +# $Date: 1/20/12 3:55a $ +#********************************************************************** +# Revision History +# ---------------- +# $Log: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGlueDxeReportStatusCodeLib/EdkIIGlueDxeReportStatusCodeLib.mak $ +# +# 1 1/20/12 3:55a Jeffch +# Create Intel EDK 1117 Patch 7. +# +# 1 9/27/11 6:17a Wesleychen +# Intel EDK initially releases. +# +# 1 9/18/09 1:55a Iminglin +# +#********************************************************************** +#<AMI_FHDR_START> +# +# Name: EdkIIGlueDxeReportStatusCodeLib.mak +# +# Description: +# +#<AMI_FHDR_END> +#********************************************************************** + + +$(EdkIIGlueDxeReportStatusCodeLib_LIB) : EdkIIGlueDxeReportStatusCodeLib + +EdkIIGlueDxeReportStatusCodeLib : $(BUILD_DIR)\EdkIIGlueDxeReportStatusCodeLib.mak EdkIIGlueDxeReportStatusCodeLibBin + +$(BUILD_DIR)\EdkIIGlueDxeReportStatusCodeLib.mak : $(EdkIIGlueDxeReportStatusCodeLib_DIR)\$(@B).cif $(EdkIIGlueDxeReportStatusCodeLib_DIR)\$(@B).mak $(BUILD_RULES) + $(CIF2MAK) $(EdkIIGlueDxeReportStatusCodeLib_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS) + +EdkIIGlueDxeReportStatusCodeLib_LIB_LINKS=$(EdkIIGlueBaseLib_LIB)\ +$(EdkIIGlueBaseMemoryLib_LIB)\ +$(EdkIIGlueUefiBootServicesTableLib_LIB)\ +$(EdkIIGlueUefiRuntimeServicesTableLib_LIB)\ +$(EFIPROTOCOLLIB)\ +$(EDKGUIDLIB)\ +$(ARCHPROTOCOLLIB)\ +!IF "$(PROCESSOR)"=="IA32" || "$(PROCESSOR)"=="x64" +$(EdkIIGlueBaseIoLibIntrinsic_LIB) +!ENDIF + +EdkIIGlueDxeReportStatusCodeLibBin : $(EdkIIGlueDxeReportStatusCodeLib_LIB_LINKS) +!IF "$(x64_BUILD)"=="1" + $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\ + BUILD_DIR=$(BUILD_DIR)\ + /f $(BUILD_DIR)\EdkIIGlueDxeReportStatusCodeLib.mak all\ + TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueDxeReportStatusCodeLib_LIB)" + $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\ + BUILD_DIR=$(BUILD_DIR)\IA32\ + /f $(BUILD_DIR)\EdkIIGlueDxeReportStatusCodeLib.mak all\ + TYPE=PEI_LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueDxeReportStatusCodeLib_LIB)" +!ELSE + $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\ + BUILD_DIR=$(BUILD_DIR)\ + /f $(BUILD_DIR)\EdkIIGlueDxeReportStatusCodeLib.mak all\ + TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueDxeReportStatusCodeLib_LIB)" +!ENDIF +#********************************************************************** +#********************************************************************** +#** ** +#** (C)Copyright 1985-2009, American Megatrends, Inc. ** +#** ** +#** All Rights Reserved. ** +#** ** +#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +#** ** +#** Phone: (770)-246-8600 ** +#** ** +#********************************************************************** +#********************************************************************** diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeReportStatusCodeLib/EdkIIGlueDxeReportStatusCodeLib.sdl b/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeReportStatusCodeLib/EdkIIGlueDxeReportStatusCodeLib.sdl new file mode 100644 index 0000000..cd4a486 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeReportStatusCodeLib/EdkIIGlueDxeReportStatusCodeLib.sdl @@ -0,0 +1,26 @@ +TOKEN + Name = "EdkIIGlueDxeReportStatusCodeLib_SUPPORT" + Value = "1" + Help = "Main switch to enable EdkIIGlueDxeReportStatusCodeLib support in Project" + TokenType = Boolean + TargetEQU = Yes + TargetMAK = Yes + Master = Yes +End + +TOKEN + Name = "EdkIIGlueDxeReportStatusCodeLib_LIB" + Value = "$$(LIB_BUILD_DIR)\EdkIIGlueDxeReportStatusCodeLib.lib" + TokenType = Expression + TargetMAK = Yes +End + +PATH + Name = "EdkIIGlueDxeReportStatusCodeLib_DIR" +End + +MODULE + Help = "Includes EdkIIGlueDxeReportStatusCodeLib.mak to Project" + File = "EdkIIGlueDxeReportStatusCodeLib.mak" +End + diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeReportStatusCodeLib/ReportStatusCodeLib.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeReportStatusCodeLib/ReportStatusCodeLib.c new file mode 100644 index 0000000..a69d14d --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeReportStatusCodeLib/ReportStatusCodeLib.c @@ -0,0 +1,605 @@ +/*++ + +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: + + ReportStatusCodeLib.c + +Abstract: + + Report Status Code Library for DXE Phase. + +--*/ + +#include "EdkIIGlueDxe.h" +#include "Pcd\EdkIIGluePcdReportStatusCodeLib.h" + + +#if (EFI_SPECIFICATION_VERSION >= 0x00020000) +// +// Global pointer to the Status Code Protocol +// +static EFI_STATUS_CODE_PROTOCOL *gStatusCode = NULL; + +#endif + +/** + Internal worker function that reports a status code through the Status Code Protocol + + This function checks to see if a Status Code Protocol is present in the handle + database. If a Status Code Protocol is not present, then EFI_UNSUPPORTED is + returned. If a Status Code Protocol is present, then it is cached in gStatusCode, + and the ReportStatusCode() service of the Status Code Protocol is called passing in + Type, Value, Instance, CallerId, and Data. The result of this call is returned. + + @param Type Status code type. + @param Value Status code value. + @param Instance Status code instance number. + @param CallerId Pointer to a GUID that identifies the caller of this + function. This is an optional parameter that may be + NULL. + @param Data Pointer to the extended data buffer. This is an + optional parameter that may be NULL. + + @retval EFI_SUCCESS The status code was reported. + @retval EFI_OUT_OF_RESOURCES There were not enough resources to report the status code. + @retval EFI_UNSUPPORTED Status Code Protocol is not available. + +**/ +EFI_STATUS +InternalReportStatusCode ( + IN EFI_STATUS_CODE_TYPE Type, + IN EFI_STATUS_CODE_VALUE Value, + IN UINT32 Instance, + IN CONST EFI_GUID *CallerId OPTIONAL, + IN EFI_STATUS_CODE_DATA *Data OPTIONAL + ) +{ +#if (EFI_SPECIFICATION_VERSION >= 0x00020000) + + EFI_STATUS Status; + + // + // If gStatusCode is NULL, then see if a Status Code Protocol instance is present + // in the handle database. + // + if (gStatusCode == NULL) { + Status = gBS->LocateProtocol (&gEfiStatusCodeRuntimeProtocolGuid, NULL, (VOID **)&gStatusCode); + if (EFI_ERROR (Status) || gStatusCode == NULL) { + return EFI_UNSUPPORTED; + } + } + + // + // A Status Code Protocol is present in the handle database, so pass in all the + // parameters to the ReportStatusCode() service of the Status Code Protocol + // + return (gStatusCode->ReportStatusCode) (Type, Value, Instance, (EFI_GUID *)CallerId, Data); + +#else + + return (gRT->ReportStatusCode) (Type, Value, Instance, (EFI_GUID *)CallerId, Data); + +#endif + +} + + +/** + Computes and returns the size, in bytes, of a device path. + + @param DevicePath A pointer to a device path. + + @return The size, in bytes, of DevicePath. + +**/ +UINTN +InternalReportStatusCodeDevicePathSize ( + IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath + ) +{ + CONST EFI_DEVICE_PATH_PROTOCOL *Start; + + // + // Search for the end of the device path structure + // + Start = DevicePath; + while (!EfiIsDevicePathEnd (DevicePath)) { + DevicePath = EfiNextDevicePathNode (DevicePath); + } + + // + // Subtract the start node from the end node and add in the size of the end node + // + return ((UINTN) DevicePath - (UINTN) Start) + DevicePathNodeLength (DevicePath); +} + + +/** + Converts a status code to an 8-bit POST code value. + + Converts the status code specified by CodeType and Value to an 8-bit POST code + and returns the 8-bit POST code in PostCode. If CodeType is an + EFI_PROGRESS_CODE or CodeType is an EFI_ERROR_CODE, then bits 0..4 of PostCode + are set to bits 16..20 of Value, and bits 5..7 of PostCode are set to bits + 24..26 of Value., and TRUE is returned. Otherwise, FALSE is returned. + + If PostCode is NULL, then ASSERT(). + + @param CodeType The type of status code being converted. + @param Value The status code value being converted. + @param PostCode A pointer to the 8-bit POST code value to return. + + @retval TRUE The status code specified by CodeType and Value was converted + to an 8-bit POST code and returned in PostCode. + @retval FALSE The status code specified by CodeType and Value could not be + converted to an 8-bit POST code value. + +**/ +BOOLEAN +EFIAPI +GlueCodeTypeToPostCode ( + IN EFI_STATUS_CODE_TYPE CodeType, + IN EFI_STATUS_CODE_VALUE Value, + OUT UINT8 *PostCode + ) +{ + // + // If PostCode is NULL, then ASSERT() + // + ASSERT (PostCode != NULL); + + // + // Convert Value to an 8 bit post code + // + if (((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_PROGRESS_CODE) || + ((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE) ) { + *PostCode = (UINT8) (((Value & EFI_STATUS_CODE_CLASS_MASK) >> 24) << 5); + *PostCode |= (UINT8) (((Value & EFI_STATUS_CODE_SUBCLASS_MASK) >> 16) & 0x1f); + return TRUE; + } + return FALSE; +} + + +/** + Extracts ASSERT() information from a status code structure. + + Converts the status code specified by CodeType, Value, and Data to the ASSERT() + arguments specified by Filename, Description, and LineNumber. If CodeType is + an EFI_ERROR_CODE, and CodeType has a severity of EFI_ERROR_UNRECOVERED, and + Value has an operation mask of EFI_SW_EC_ILLEGAL_SOFTWARE_STATE, extract + Filename, Description, and LineNumber from the optional data area of the + status code buffer specified by Data. The optional data area of Data contains + a Null-terminated ASCII string for the FileName, followed by a Null-terminated + ASCII string for the Description, followed by a 32-bit LineNumber. If the + ASSERT() information could be extracted from Data, then return TRUE. + Otherwise, FALSE is returned. + + If Data is NULL, then ASSERT(). + If Filename is NULL, then ASSERT(). + If Description is NULL, then ASSERT(). + If LineNumber is NULL, then ASSERT(). + + @param CodeType The type of status code being converted. + @param Value The status code value being converted. + @param Data Pointer to status code data buffer. + @param Filename Pointer to the source file name that generated the ASSERT(). + @param Description Pointer to the description of the ASSERT(). + @param LineNumber Pointer to source line number that generated the ASSERT(). + + @retval TRUE The status code specified by CodeType, Value, and Data was + converted ASSERT() arguments specified by Filename, Description, + and LineNumber. + @retval FALSE The status code specified by CodeType, Value, and Data could + not be converted to ASSERT() arguments. + +**/ +BOOLEAN +EFIAPI +GlueReportStatusCodeExtractAssertInfo ( + IN EFI_STATUS_CODE_TYPE CodeType, + IN EFI_STATUS_CODE_VALUE Value, + IN CONST EFI_STATUS_CODE_DATA *Data, + OUT CHAR8 **Filename, + OUT CHAR8 **Description, + OUT UINT32 *LineNumber + ) +{ + EFI_DEBUG_ASSERT_DATA *AssertData; + + ASSERT (Data != NULL); + ASSERT (Filename != NULL); + ASSERT (Description != NULL); + ASSERT (LineNumber != NULL); + + if (((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE) && + ((CodeType & EFI_STATUS_CODE_SEVERITY_MASK) == EFI_ERROR_UNRECOVERED) && + ((Value & EFI_STATUS_CODE_OPERATION_MASK) == EFI_SW_EC_ILLEGAL_SOFTWARE_STATE)) { + AssertData = (EFI_DEBUG_ASSERT_DATA *)(Data + 1); + *Filename = (CHAR8 *)(AssertData + 1); + *Description = *Filename + AsciiStrLen (*Filename) + 1; + *LineNumber = AssertData->LineNumber; + return TRUE; + } + return FALSE; +} + + +/** + Extracts DEBUG() information from a status code structure. + + Converts the status code specified by Data to the DEBUG() arguments specified + by ErrorLevel, Marker, and Format. If type GUID in Data is + EFI_STATUS_CODE_DATA_TYPE_DEBUG_GUID, then extract ErrorLevel, Marker, and + Format from the optional data area of the status code buffer specified by Data. + The optional data area of Data contains a 32-bit ErrorLevel followed by Marker + which is 12 UINTN parameters, followed by a Null-terminated ASCII string for + the Format. If the DEBUG() information could be extracted from Data, then + return TRUE. Otherwise, FALSE is returned. + + If Data is NULL, then ASSERT(). + If ErrorLevel is NULL, then ASSERT(). + If Marker is NULL, then ASSERT(). + If Format is NULL, then ASSERT(). + + @param Data Pointer to status code data buffer. + @param ErrorLevel Pointer to error level mask for a debug message. + @param Marker Pointer to the variable argument list associated with Format. + @param Format Pointer to a Null-terminated ASCII format string of a + debug message. + + @retval TRUE The status code specified by Data was converted DEBUG() arguments + specified by ErrorLevel, Marker, and Format. + @retval FALSE The status code specified by Data could not be converted to + DEBUG() arguments. + +**/ +BOOLEAN +EFIAPI +GlueReportStatusCodeExtractDebugInfo ( + IN CONST EFI_STATUS_CODE_DATA *Data, + OUT UINT32 *ErrorLevel, + OUT VA_LIST *Marker, + OUT CHAR8 **Format + ) +{ + EFI_DEBUG_INFO *DebugInfo; + + ASSERT (Data != NULL); + ASSERT (ErrorLevel != NULL); + ASSERT (Marker != NULL); + ASSERT (Format != NULL); + + // + // If the GUID type is not EFI_STATUS_CODE_DATA_TYPE_DEBUG_GUID then return FALSE + // + if (!CompareGuid (&Data->Type, &gEfiStatusCodeDataTypeDebugGuid)) { + return FALSE; + } + + // + // Retrieve the debug information from the status code record + // + DebugInfo = (EFI_DEBUG_INFO *)(Data + 1); + + *ErrorLevel = DebugInfo->ErrorLevel; + + // + // The first 12 * UINTN bytes of the string are really an + // argument stack to support varargs on the Format string. + // + *Marker = (VA_LIST) (DebugInfo + 1); + *Format = (CHAR8 *)(((UINT64 *)*Marker) + 12); + + return TRUE; +} + + +/** + Reports a status code. + + Reports the status code specified by the parameters Type and Value. Status + code also require an instance, caller ID, and extended data. This function + passed in a zero instance, NULL extended data, and a caller ID of + gEfiCallerIdGuid, which is the GUID for the module. + + ReportStatusCode()must actively prevent recusrsion. If ReportStatusCode() + is called while processing another any other Report Status Code Library function, + then ReportStatusCode() must return immediately. + + @param Type Status code type. + @param Value Status code value. + + @retval EFI_SUCCESS The status code was reported. + @retval EFI_DEVICE_ERROR There status code could not be reported due to a + device error. + @retval EFI_UNSUPPORTED Report status code is not supported + +**/ +EFI_STATUS +EFIAPI +GlueReportStatusCode ( + IN EFI_STATUS_CODE_TYPE Type, + IN EFI_STATUS_CODE_VALUE Value + ) +{ + return InternalReportStatusCode (Type, Value, 0, &gEfiCallerIdGuid, NULL); +} + + +/** + Reports a status code with a Device Path Protocol as the extended data. + + Allocates and fills in the extended data section of a status code with the + Device Path Protocol specified by DevicePath. This function is responsible + for allocating a buffer large enough for the standard header and the device + path. The standard header is filled in with a GUID of + gEfiStatusCodeSpecificDataGuid. The status code is reported with a zero + instance and a caller ID of gEfiCallerIdGuid. + + ReportStatusCodeWithDevicePath()must actively prevent recursion. If + ReportStatusCodeWithDevicePath() is called while processing another any other + Report Status Code Library function, then ReportStatusCodeWithDevicePath() + must return EFI_DEVICE_ERROR immediately. + + If DevicePath is NULL, then ASSERT(). + + @param Type Status code type. + @param Value Status code value. + @param DevicePath Pointer to the Device Path Protocol to be reported. + + @retval EFI_SUCCESS The status code was reported with the extended + data specified by DevicePath. + @retval EFI_OUT_OF_RESOURCES There were not enough resources to allocate the + extended data section. + @retval EFI_UNSUPPORTED Report status code is not supported + +**/ +EFI_STATUS +EFIAPI +GlueReportStatusCodeWithDevicePath ( + IN EFI_STATUS_CODE_TYPE Type, + IN EFI_STATUS_CODE_VALUE Value, + IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath + ) +{ + ASSERT (DevicePath != NULL); + return ReportStatusCodeWithExtendedData ( + Type, + Value, + (VOID *)DevicePath, + InternalReportStatusCodeDevicePathSize (DevicePath) + ); +} + + +/** + Reports a status code with an extended data buffer. + + Allocates and fills in the extended data section of a status code with the + extended data specified by ExtendedData and ExtendedDataSize. ExtendedData + is assumed to be one of the data structures specified in Related Definitions. + These data structure do not have the standard header, so this function is + responsible for allocating a buffer large enough for the standard header and + the extended data passed into this function. The standard header is filled + in with a GUID of gEfiStatusCodeSpecificDataGuid. The status code is reported + with a zero instance and a caller ID of gEfiCallerIdGuid. + + ReportStatusCodeWithExtendedData()must actively prevent recursion. If + ReportStatusCodeWithExtendedData() is called while processing another any other + Report Status Code Library function, then ReportStatusCodeWithExtendedData() + must return EFI_DEVICE_ERROR immediately. + + If ExtendedData is NULL, then ASSERT(). + If ExtendedDataSize is 0, then ASSERT(). + + @param Type Status code type. + @param Value Status code value. + @param ExtendedData Pointer to the extended data buffer to be reported. + @param ExtendedDataSize The size, in bytes, of the extended data buffer to + be reported. + + @retval EFI_SUCCESS The status code was reported with the extended + data specified by ExtendedData and ExtendedDataSize. + @retval EFI_OUT_OF_RESOURCES There were not enough resources to allocate the + extended data section. + @retval EFI_UNSUPPORTED Report status code is not supported + +**/ +EFI_STATUS +EFIAPI +GlueReportStatusCodeWithExtendedData ( + IN EFI_STATUS_CODE_TYPE Type, + IN EFI_STATUS_CODE_VALUE Value, + IN CONST VOID *ExtendedData, + IN UINTN ExtendedDataSize + ) +{ + ASSERT (ExtendedData != NULL); + ASSERT (ExtendedDataSize != 0); + return ReportStatusCodeEx ( + Type, + Value, + 0, + NULL, + NULL, + ExtendedData, + ExtendedDataSize + ); +} + + +/** + Reports a status code with full parameters. + + The function reports a status code. If ExtendedData is NULL and ExtendedDataSize + is 0, then an extended data buffer is not reported. If ExtendedData is not + NULL and ExtendedDataSize is not 0, then an extended data buffer is allocated. + ExtendedData is assumed not have the standard status code header, so this function + is responsible for allocating a buffer large enough for the standard header and + the extended data passed into this function. The standard header is filled in + with a GUID specified by ExtendedDataGuid. If ExtendedDataGuid is NULL, then a + GUID of gEfiStatusCodeSpecificDatauid is used. The status code is reported with + an instance specified by Instance and a caller ID specified by CallerId. If + CallerId is NULL, then a caller ID of gEfiCallerIdGuid is used. + + ReportStatusCodeEx()must actively prevent recursion. If ReportStatusCodeEx() + is called while processing another any other Report Status Code Library function, + then ReportStatusCodeEx() must return EFI_DEVICE_ERROR immediately. + + If ExtendedData is NULL and ExtendedDataSize is not zero, then ASSERT(). + If ExtendedData is not NULL and ExtendedDataSize is zero, then ASSERT(). + + @param Type Status code type. + @param Value Status code value. + @param Instance Status code instance number. + @param CallerId Pointer to a GUID that identifies the caller of this + function. If this parameter is NULL, then a caller + ID of gEfiCallerIdGuid is used. + @param ExtendedDataGuid Pointer to the GUID for the extended data buffer. + If this parameter is NULL, then a the status code + standard header is filled in with + gEfiStatusCodeSpecificDataGuid. + @param ExtendedData Pointer to the extended data buffer. This is an + optional parameter that may be NULL. + @param ExtendedDataSize The size, in bytes, of the extended data buffer. + + @retval EFI_SUCCESS The status code was reported. + @retval EFI_OUT_OF_RESOURCES There were not enough resources to allocate + the extended data section if it was specified. + @retval EFI_UNSUPPORTED Report status code is not supported + +**/ +EFI_STATUS +EFIAPI +GlueReportStatusCodeEx ( + IN EFI_STATUS_CODE_TYPE Type, + IN EFI_STATUS_CODE_VALUE Value, + IN UINT32 Instance, + IN CONST EFI_GUID *CallerId OPTIONAL, + IN CONST EFI_GUID *ExtendedDataGuid OPTIONAL, + IN CONST VOID *ExtendedData OPTIONAL, + IN UINTN ExtendedDataSize + ) +{ + EFI_STATUS Status; + EFI_STATUS_CODE_DATA *StatusCodeData; + + ASSERT (!((ExtendedData == NULL) && (ExtendedDataSize != 0))); + ASSERT (!((ExtendedData != NULL) && (ExtendedDataSize == 0))); + + // + // Allocate space for the Status Code Header and its buffer + // + StatusCodeData = NULL; + (gBS->AllocatePool) (EfiBootServicesData, sizeof (EFI_STATUS_CODE_DATA) + ExtendedDataSize, (VOID **)&StatusCodeData); + if (StatusCodeData == NULL) { + return EFI_OUT_OF_RESOURCES; + } + + // + // Fill in the extended data header + // + StatusCodeData->HeaderSize = sizeof (EFI_STATUS_CODE_DATA); + StatusCodeData->Size = (UINT16)ExtendedDataSize; + if (ExtendedDataGuid == NULL) { + ExtendedDataGuid = &gEfiStatusCodeSpecificDataGuid; + } + CopyGuid (&StatusCodeData->Type, ExtendedDataGuid); + + // + // Fill in the extended data buffer + // + CopyMem (StatusCodeData + 1, ExtendedData, ExtendedDataSize); + + // + // Report the status code + // + if (CallerId == NULL) { + CallerId = &gEfiCallerIdGuid; + } + Status = InternalReportStatusCode (Type, Value, Instance, CallerId, StatusCodeData); + + // + // Free the allocated buffer + // + (gBS->FreePool) (StatusCodeData); + + return Status; +} + + +/** + Returns TRUE if status codes of type EFI_PROGRESS_CODE are enabled + + This function returns TRUE if the REPORT_STATUS_CODE_PROPERTY_PROGRESS_CODE_ENABLED + bit of PcdReportStatusCodeProperyMask is set. Otherwise FALSE is returned. + + @retval TRUE The REPORT_STATUS_CODE_PROPERTY_PROGRESS_CODE_ENABLED bit of + PcdReportStatusCodeProperyMask is set. + @retval FALSE The REPORT_STATUS_CODE_PROPERTY_PROGRESS_CODE_ENABLED bit of + PcdReportStatusCodeProperyMask is clear. + +**/ +BOOLEAN +EFIAPI +GlueReportProgressCodeEnabled ( + VOID + ) +{ + return ((PcdGet8(PcdReportStatusCodePropertyMask) & REPORT_STATUS_CODE_PROPERTY_PROGRESS_CODE_ENABLED) != 0); +} + + +/** + Returns TRUE if status codes of type EFI_ERROR_CODE are enabled + + This function returns TRUE if the REPORT_STATUS_CODE_PROPERTY_ERROR_CODE_ENABLED + bit of PcdReportStatusCodeProperyMask is set. Otherwise FALSE is returned. + + @retval TRUE The REPORT_STATUS_CODE_PROPERTY_ERROR_CODE_ENABLED bit of + PcdReportStatusCodeProperyMask is set. + @retval FALSE The REPORT_STATUS_CODE_PROPERTY_ERROR_CODE_ENABLED bit of + PcdReportStatusCodeProperyMask is clear. + +**/ +BOOLEAN +EFIAPI +GlueReportErrorCodeEnabled ( + VOID + ) +{ + return ((PcdGet8(PcdReportStatusCodePropertyMask) & REPORT_STATUS_CODE_PROPERTY_ERROR_CODE_ENABLED) != 0); +} + + +/** + Returns TRUE if status codes of type EFI_DEBUG_CODE are enabled + + This function returns TRUE if the REPORT_STATUS_CODE_PROPERTY_DEBUG_CODE_ENABLED + bit of PcdReportStatusCodeProperyMask is set. Otherwise FALSE is returned. + + @retval TRUE The REPORT_STATUS_CODE_PROPERTY_DEBUG_CODE_ENABLED bit of + PcdReportStatusCodeProperyMask is set. + @retval FALSE The REPORT_STATUS_CODE_PROPERTY_DEBUG_CODE_ENABLED bit of + PcdReportStatusCodeProperyMask is clear. + +**/ +BOOLEAN +EFIAPI +GlueReportDebugCodeEnabled ( + VOID + ) +{ + return ((PcdGet8(PcdReportStatusCodePropertyMask) & REPORT_STATUS_CODE_PROPERTY_DEBUG_CODE_ENABLED) != 0); +} diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeServicesTableLib/DxeServicesTableLib.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeServicesTableLib/DxeServicesTableLib.c new file mode 100644 index 0000000..99bdb3c --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeServicesTableLib/DxeServicesTableLib.c @@ -0,0 +1,60 @@ +/*++ + +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: + + DxeServicesTableLib.c + +Abstract: + + Dxe Services Table Lib + +--*/ + +#include "EdkIIGlueDxe.h" + +// +// Cache copy of the DXE Services Table +// +EFI_DXE_SERVICES *gDS = NULL; + +/** + The constructor function caches the pointer of DXE Services Table. + + The constructor function caches the pointer of DXE Services Table. + It will ASSERT() if that operation fails. + It will ASSERT() if the pointer of DXE Services Table is NULL. + It will always return EFI_SUCCESS. + + @param ImageHandle The firmware allocated handle for the EFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS. + +**/ +EFI_STATUS +DxeServicesTableLibConstructor ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + // + // Cache copy of the DXE Services Table + // + Status = EfiGetSystemConfigurationTable (&gEfiDxeServicesTableGuid, (VOID **) &gDS); + ASSERT_EFI_ERROR (Status); + ASSERT (gDS != NULL); + + return Status; +} diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeServicesTableLib/DxeServicesTableLib.inf b/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeServicesTableLib/DxeServicesTableLib.inf new file mode 100644 index 0000000..08c4f04 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeServicesTableLib/DxeServicesTableLib.inf @@ -0,0 +1,77 @@ +#/*++ +# +# 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: +# +# DxeServicesTableLib.inf +# +# Abstract: +# +# Component description file for DxeServicesTableLib. +# +#--*/ + +[defines] +BASE_NAME = EdkIIGlueDxeServicesTableLib +COMPONENT_TYPE = LIBRARY + +[sources.common] + DxeServicesTableLib.c + +[sources.ia32] + +[sources.x64] + +[sources.ipf] + +[sources.ebc] + + +[includes.common] + . + ..\..\Include + ..\..\include\Library + $(EDK_SOURCE)\Foundation + $(EDK_SOURCE)\Foundation\Framework + $(EDK_SOURCE)\Foundation\Efi + $(EDK_SOURCE)\Foundation\Include + $(EDK_SOURCE)\Foundation\Efi\Include + $(EDK_SOURCE)\Foundation\Framework\Include + $(EDK_SOURCE)\Foundation\Include\IndustryStandard + $(EDK_SOURCE)\Foundation\Core\Dxe + $(EDK_SOURCE)\Foundation\Library\Dxe\Include + $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include + $(EDK_SOURCE)\Foundation\Framework\Guid\DataHubRecords + $(EDK_SOURCE)\Foundation\Framework\Guid\StatusCodeDataTypeId + +[libraries.common] + EdkIIGlueUefiLib + EfiProtocolLib + +[libraries.ia32] + +[libraries.x64] + +[nmake.common] + C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION + LIB_STD_FLAGS = /NOLOGO /IGNORE:4006 + +[nmake.ia32] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32 + +[nmake.x64] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64 + +[nmake.ipf] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF + +[nmake.ebc] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_EBC
\ No newline at end of file diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeServicesTableLib/EdkIIGlueDxeServicesTableLib.cif b/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeServicesTableLib/EdkIIGlueDxeServicesTableLib.cif new file mode 100644 index 0000000..e7794f7 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeServicesTableLib/EdkIIGlueDxeServicesTableLib.cif @@ -0,0 +1,11 @@ +<component> + name = "EdkIIGlueDxeServicesTableLib" + category = ModulePart + LocalRoot = "Edk\Foundation\Library\EdkIIGlueLib\Library\DxeServicesTableLib" + RefName = "EdkIIGlueDxeServicesTableLib" +[files] +"EdkIIGlueDxeServicesTableLib.sdl" +"EdkIIGlueDxeServicesTableLib.mak" +"DxeServicesTableLib.inf" +"DxeServicesTableLib.c" +<endComponent> diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeServicesTableLib/EdkIIGlueDxeServicesTableLib.mak b/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeServicesTableLib/EdkIIGlueDxeServicesTableLib.mak new file mode 100644 index 0000000..7d62e5d --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeServicesTableLib/EdkIIGlueDxeServicesTableLib.mak @@ -0,0 +1,80 @@ +#********************************************************************** +#********************************************************************** +#** ** +#** (C)Copyright 1985-2009, American Megatrends, Inc. ** +#** ** +#** All Rights Reserved. ** +#** ** +#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +#** ** +#** Phone: (770)-246-8600 ** +#** ** +#********************************************************************** +#********************************************************************** + +#********************************************************************** +# $Header: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGlueDxeServicesTableLib/EdkIIGlueDxeServicesTableLib.mak 1 1/20/12 3:55a Jeffch $ +# +# $Revision: 1 $ +# +# $Date: 1/20/12 3:55a $ +#********************************************************************** +# Revision History +# ---------------- +# $Log: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGlueDxeServicesTableLib/EdkIIGlueDxeServicesTableLib.mak $ +# +# 1 1/20/12 3:55a Jeffch +# Create Intel EDK 1117 Patch 7. +# +# 1 9/27/11 6:17a Wesleychen +# Intel EDK initially releases. +# +# 1 9/18/09 1:55a Iminglin +# +#********************************************************************** +#<AMI_FHDR_START> +# +# Name: EdkIIGlueDxeServicesTableLib.mak +# +# Description: +# +#<AMI_FHDR_END> +#********************************************************************** + + +$(EdkIIGlueDxeServicesTableLib_LIB) : EdkIIGlueDxeServicesTableLib + +EdkIIGlueDxeServicesTableLib : $(BUILD_DIR)\EdkIIGlueDxeServicesTableLib.mak EdkIIGlueDxeServicesTableLibBin + +$(BUILD_DIR)\EdkIIGlueDxeServicesTableLib.mak : $(EdkIIGlueDxeServicesTableLib_DIR)\$(@B).cif $(EdkIIGlueDxeServicesTableLib_DIR)\$(@B).mak $(BUILD_RULES) + $(CIF2MAK) $(EdkIIGlueDxeServicesTableLib_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS) + +EdkIIGlueDxeServicesTableLibBin : $(EdkIIGlueUefiLib_LIB) $(EFIPROTOCOLLIB) +!IF "$(x64_BUILD)"=="1" + $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\ + BUILD_DIR=$(BUILD_DIR)\ + /f $(BUILD_DIR)\EdkIIGlueDxeServicesTableLib.mak all\ + TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueDxeServicesTableLib_LIB)" + $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\ + BUILD_DIR=$(BUILD_DIR)\IA32\ + /f $(BUILD_DIR)\EdkIIGlueDxeServicesTableLib.mak all\ + TYPE=PEI_LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueDxeServicesTableLib_LIB)" +!ELSE + $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\ + BUILD_DIR=$(BUILD_DIR)\ + /f $(BUILD_DIR)\EdkIIGlueDxeServicesTableLib.mak all\ + TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueDxeServicesTableLib_LIB)" +!ENDIF +#********************************************************************** +#********************************************************************** +#** ** +#** (C)Copyright 1985-2009, American Megatrends, Inc. ** +#** ** +#** All Rights Reserved. ** +#** ** +#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +#** ** +#** Phone: (770)-246-8600 ** +#** ** +#********************************************************************** +#**********************************************************************
\ No newline at end of file diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeServicesTableLib/EdkIIGlueDxeServicesTableLib.sdl b/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeServicesTableLib/EdkIIGlueDxeServicesTableLib.sdl new file mode 100644 index 0000000..095f01a --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeServicesTableLib/EdkIIGlueDxeServicesTableLib.sdl @@ -0,0 +1,26 @@ +TOKEN + Name = "EdkIIGlueDxeServicesTableLib_SUPPORT" + Value = "1" + Help = "Main switch to enable EdkIIGlueDxeServicesTableLib support in Project" + TokenType = Boolean + TargetEQU = Yes + TargetMAK = Yes + Master = Yes +End + +TOKEN + Name = "EdkIIGlueDxeServicesTableLib_LIB" + Value = "$$(LIB_BUILD_DIR)\EdkIIGlueDxeServicesTableLib.lib" + TokenType = Expression + TargetMAK = Yes +End + +PATH + Name = "EdkIIGlueDxeServicesTableLib_DIR" +End + +MODULE + Help = "Includes EdkIIGlueDxeServicesTableLib.mak to Project" + File = "EdkIIGlueDxeServicesTableLib.mak" +End + diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeSmbusLib/DxeSmbusLib.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeSmbusLib/DxeSmbusLib.c new file mode 100644 index 0000000..8d5e10f --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeSmbusLib/DxeSmbusLib.c @@ -0,0 +1,107 @@ +/*++ + +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: + + DxeSmbusLib.c + +Abstract: + + Dxe Smbus Lib internal functions + +--*/ + +#include "DxeSmbusLibInternal.h" + +// +// Globle varible to cache pointer to Smbus protocol. +// +STATIC EFI_SMBUS_HC_PROTOCOL *mSmbus = NULL; + +/** + The constructor function caches the pointer to Smbus protocol. + + The constructor function locates Smbus protocol from protocol database. + It will ASSERT() if that operation fails and it will always return EFI_SUCCESS. + + @param ImageHandle The firmware allocated handle for the EFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS. + +**/ +EFI_STATUS +EFIAPI +SmbusLibConstructor ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + Status = gBS->LocateProtocol (&gEfiSmbusProtocolGuid, NULL, (VOID**) &mSmbus); + ASSERT_EFI_ERROR (Status); + ASSERT (mSmbus != NULL); + + return Status; +} + +/** + Executes an SMBus operation to an SMBus controller. + + This function provides a standard way to execute Smbus script + as defined in the SmBus Specification. The data can either be of + the Length byte, word, or a block of data. + + @param SmbusOperation Signifies which particular SMBus hardware protocol instance that it will use to + execute the SMBus transactions. + @param SmBusAddress Address that encodes the SMBUS Slave Address, + SMBUS Command, SMBUS Data Length, and PEC. + @param Length Signifies the number of bytes that this operation will do. The maximum number of + bytes can be revision specific and operation specific. + @param Buffer Contains the value of data to execute to the SMBus slave device. Not all operations + require this argument. The length of this buffer is identified by Length. + @param Status Return status for the executed command. + This is an optional parameter and may be NULL. + + @return The actual number of bytes that are executed for this operation.. + +**/ +UINTN +InternalSmBusExec ( + IN EFI_SMBUS_OPERATION SmbusOperation, + IN UINTN SmBusAddress, + IN UINTN Length, + IN OUT VOID *Buffer, + OUT RETURN_STATUS *Status OPTIONAL + ) +{ + RETURN_STATUS ReturnStatus; + EFI_SMBUS_DEVICE_ADDRESS SmbusDeviceAddress; + + SmbusDeviceAddress.SmbusDeviceAddress = SMBUS_LIB_SLAVE_ADDRESS (SmBusAddress); + + ReturnStatus = mSmbus->Execute ( + mSmbus, + SmbusDeviceAddress, + SMBUS_LIB_COMMAND (SmBusAddress), + SmbusOperation, + SMBUS_LIB_PEC (SmBusAddress), + &Length, + Buffer + ); + if (Status != NULL) { + *Status = ReturnStatus; + } + + return Length; +} diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeSmbusLib/DxeSmbusLib.inf b/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeSmbusLib/DxeSmbusLib.inf new file mode 100644 index 0000000..518d63d --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeSmbusLib/DxeSmbusLib.inf @@ -0,0 +1,80 @@ +#/*++ +# +# 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: +# +# DxeSmbusLib.inf +# +# Abstract: +# +# Component description file for DxeSmbusLib. +# +#--*/ + +[defines] +BASE_NAME = EdkIIGlueDxeSmbusLib +COMPONENT_TYPE = LIBRARY + +[sources.common] + DxeSmbusLib.c + SmbusLib.c + +[sources.ia32] + +[sources.x64] + +[sources.ipf] + +[sources.ebc] + + +[includes.common] + . + ..\..\Include + ..\..\include\Library + $(EDK_SOURCE)\Foundation + $(EDK_SOURCE)\Foundation\Framework + $(EDK_SOURCE)\Foundation\Efi + $(EDK_SOURCE)\Foundation\Include + $(EDK_SOURCE)\Foundation\Efi\Include + $(EDK_SOURCE)\Foundation\Framework\Include + $(EDK_SOURCE)\Foundation\Include\IndustryStandard + $(EDK_SOURCE)\Foundation\Core\Dxe + $(EDK_SOURCE)\Foundation\Library\Dxe\Include + $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include + $(EDK_SOURCE)\Foundation\Framework\Guid\DataHubRecords + $(EDK_SOURCE)\Foundation\Framework\Guid\StatusCodeDataTypeId + +[libraries.common] + EdkIIGlueBaseMemoryLib + EdkIIGlueUefiBootServicesTableLib + EfiProtocolLib + EdkFrameworkProtocolLib + +[libraries.ia32] + +[libraries.x64] + +[nmake.common] + C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION + LIB_STD_FLAGS = /NOLOGO /IGNORE:4006 + +[nmake.ia32] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32 + +[nmake.x64] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64 + +[nmake.ipf] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF + +[nmake.ebc] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_EBC diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeSmbusLib/DxeSmbusLibInternal.h b/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeSmbusLib/DxeSmbusLibInternal.h new file mode 100644 index 0000000..c704b07 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeSmbusLib/DxeSmbusLibInternal.h @@ -0,0 +1,67 @@ +/*++ + +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: + + DxeSmbusLibInternal.h + +Abstract: + + Declarations of internal functions in DxeSmbusLib. + +--*/ + +#ifndef __DXE_SMBUS_LIB_INTERNAL_H__ +#define __DXE_SMBUS_LIB_INTERNAL_H__ + +#include "EdkIIGlueDxe.h" + +#define SMBUS_LIB_SLAVE_ADDRESS(SmBusAddress) (((SmBusAddress) >> 1) & 0x7f) +#define SMBUS_LIB_COMMAND(SmBusAddress) (((SmBusAddress) >> 8) & 0xff) +#define SMBUS_LIB_LENGTH(SmBusAddress) (((SmBusAddress) >> 16) & 0x3f) +#define SMBUS_LIB_PEC(SmBusAddress) ((BOOLEAN) (((SmBusAddress) & SMBUS_LIB_PEC_BIT) != 0)) +#define SMBUS_LIB_RESEARVED(SmBusAddress) ((SmBusAddress) & ~(((1 << 22) - 2) | SMBUS_LIB_PEC_BIT)) + +// +// Declaration for internal functions +// +/** + Executes an SMBus operation to an SMBus controller. + + This function provides a standard way to execute Smbus script + as defined in the SmBus Specification. The data can either be of + the Length byte, word, or a block of data. + + @param SmbusOperation Signifies which particular SMBus hardware protocol instance that it will use to + execute the SMBus transactions. + @param SmBusAddress Address that encodes the SMBUS Slave Address, + SMBUS Command, SMBUS Data Length, and PEC. + @param Length Signifies the number of bytes that this operation will do. The maximum number of + bytes can be revision specific and operation specific. + @param Buffer Contains the value of data to execute to the SMBus slave device. Not all operations + require this argument. The length of this buffer is identified by Length. + @param Status Return status for the executed command. + This is an optional parameter and may be NULL. + + @return The actual number of bytes that are executed for this operation. + +**/ +UINTN +InternalSmBusExec ( + IN EFI_SMBUS_OPERATION SmbusOperation, + IN UINTN SmBusAddress, + IN UINTN Length, + IN OUT VOID *Buffer, + OUT RETURN_STATUS *Status OPTIONAL + ); + +#endif diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeSmbusLib/EdkIIGlueDxeSmbusLib.cif b/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeSmbusLib/EdkIIGlueDxeSmbusLib.cif new file mode 100644 index 0000000..595b2b0 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeSmbusLib/EdkIIGlueDxeSmbusLib.cif @@ -0,0 +1,13 @@ +<component> + name = "EdkIIGlueDxeSmbusLib" + category = ModulePart + LocalRoot = "Edk\Foundation\Library\EdkIIGlueLib\Library\DxeSmbusLib" + RefName = "EdkIIGlueDxeSmbusLib" +[files] +"EdkIIGlueDxeSmbusLib.sdl" +"EdkIIGlueDxeSmbusLib.mak" +"DxeSmbusLib.inf" +"DxeSmbusLib.c" +"SmbusLib.c" +"DxeSmbusLibInternal.h" +<endComponent> diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeSmbusLib/EdkIIGlueDxeSmbusLib.mak b/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeSmbusLib/EdkIIGlueDxeSmbusLib.mak new file mode 100644 index 0000000..9212712 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeSmbusLib/EdkIIGlueDxeSmbusLib.mak @@ -0,0 +1,80 @@ +#********************************************************************** +#********************************************************************** +#** ** +#** (C)Copyright 1985-2009, American Megatrends, Inc. ** +#** ** +#** All Rights Reserved. ** +#** ** +#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +#** ** +#** Phone: (770)-246-8600 ** +#** ** +#********************************************************************** +#********************************************************************** + +#********************************************************************** +# $Header: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGlueDxeSmbusLib/EdkIIGlueDxeSmbusLib.mak 1 1/20/12 3:55a Jeffch $ +# +# $Revision: 1 $ +# +# $Date: 1/20/12 3:55a $ +#********************************************************************** +# Revision History +# ---------------- +# $Log: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGlueDxeSmbusLib/EdkIIGlueDxeSmbusLib.mak $ +# +# 1 1/20/12 3:55a Jeffch +# Create Intel EDK 1117 Patch 7. +# +# 1 9/27/11 6:17a Wesleychen +# Intel EDK initially releases. +# +# 1 9/18/09 1:55a Iminglin +# +#********************************************************************** +#<AMI_FHDR_START> +# +# Name: EdkIIGlueDxeSmbusLib.mak +# +# Description: +# +#<AMI_FHDR_END> +#********************************************************************** + + +$(EdkIIGlueDxeSmbusLib_LIB) : EdkIIGlueDxeSmbusLib + +EdkIIGlueDxeSmbusLib : $(BUILD_DIR)\EdkIIGlueDxeSmbusLib.mak EdkIIGlueDxeSmbusLibBin + +$(BUILD_DIR)\EdkIIGlueDxeSmbusLib.mak : $(EdkIIGlueDxeSmbusLib_DIR)\$(@B).cif $(EdkIIGlueDxeSmbusLib_DIR)\$(@B).mak $(BUILD_RULES) + $(CIF2MAK) $(EdkIIGlueDxeSmbusLib_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS) + +EdkIIGlueDxeSmbusLibBin : $(EdkIIGlueBaseMemoryLib_LIB) $(EdkIIGlueUefiBootServicesTableLib_LIB) $(EFIPROTOCOLLIB) $(EDKFRAMEWORKPROTOCOLLIB) +!IF "$(x64_BUILD)"=="1" + $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\ + BUILD_DIR=$(BUILD_DIR)\ + /f $(BUILD_DIR)\EdkIIGlueDxeSmbusLib.mak all\ + TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueDxeSmbusLib_LIB)" + $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\ + BUILD_DIR=$(BUILD_DIR)\IA32\ + /f $(BUILD_DIR)\EdkIIGlueDxeSmbusLib.mak all\ + TYPE=PEI_LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueDxeSmbusLib_LIB)" +!ELSE + $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\ + BUILD_DIR=$(BUILD_DIR)\ + /f $(BUILD_DIR)\EdkIIGlueDxeSmbusLib.mak all\ + TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueDxeSmbusLib_LIB)" +!ENDIF +#********************************************************************** +#********************************************************************** +#** ** +#** (C)Copyright 1985-2009, American Megatrends, Inc. ** +#** ** +#** All Rights Reserved. ** +#** ** +#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +#** ** +#** Phone: (770)-246-8600 ** +#** ** +#********************************************************************** +#**********************************************************************
\ No newline at end of file diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeSmbusLib/EdkIIGlueDxeSmbusLib.sdl b/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeSmbusLib/EdkIIGlueDxeSmbusLib.sdl new file mode 100644 index 0000000..1a6173a --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeSmbusLib/EdkIIGlueDxeSmbusLib.sdl @@ -0,0 +1,26 @@ +TOKEN + Name = "EdkIIGlueDxeSmbusLib_SUPPORT" + Value = "1" + Help = "Main switch to enable EdkIIGlueDxeSmbusLib support in Project" + TokenType = Boolean + TargetEQU = Yes + TargetMAK = Yes + Master = Yes +End + +TOKEN + Name = "EdkIIGlueDxeSmbusLib_LIB" + Value = "$$(LIB_BUILD_DIR)\EdkIIGlueDxeSmbusLib.lib" + TokenType = Expression + TargetMAK = Yes +End + +PATH + Name = "EdkIIGlueDxeSmbusLib_DIR" +End + +MODULE + Help = "Includes EdkIIGlueDxeSmbusLib.mak to Project" + File = "EdkIIGlueDxeSmbusLib.mak" +End + diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeSmbusLib/SmbusLib.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeSmbusLib/SmbusLib.c new file mode 100644 index 0000000..00fdf32 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeSmbusLib/SmbusLib.c @@ -0,0 +1,475 @@ +/*++ + +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: + + DxeSmbus.c + +Abstract: + + Dxe Smbus Lib Interfaces + +--*/ + +#include "DxeSmbusLibInternal.h" + +/** + Executes an SMBUS quick read command. + + Executes an SMBUS quick read command on the SMBUS device specified by SmBusAddress. + Only the SMBUS slave address field of SmBusAddress is required. + If Status is not NULL, then the status of the executed command is returned in Status. + If PEC is set in SmBusAddress, then ASSERT(). + If Command in SmBusAddress is not zero, then ASSERT(). + If Length in SmBusAddress is not zero, then ASSERT(). + If any reserved bits of SmBusAddress are set, then ASSERT(). + + @param SmBusAddress Address that encodes the SMBUS Slave Address, + SMBUS Command, SMBUS Data Length, and PEC. + @param Status Return status for the executed command. + This is an optional parameter and may be NULL. + +**/ +VOID +EFIAPI +SmBusQuickRead ( + IN UINTN SmBusAddress, + OUT RETURN_STATUS *Status OPTIONAL + ) +{ + ASSERT (!SMBUS_LIB_PEC (SmBusAddress)); + ASSERT (SMBUS_LIB_COMMAND (SmBusAddress) == 0); + ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) == 0); + ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0); + + InternalSmBusExec (EfiSmbusQuickRead, SmBusAddress, 0, NULL, Status); +} + +/** + Executes an SMBUS quick write command. + + Executes an SMBUS quick write command on the SMBUS device specified by SmBusAddress. + Only the SMBUS slave address field of SmBusAddress is required. + If Status is not NULL, then the status of the executed command is returned in Status. + If PEC is set in SmBusAddress, then ASSERT(). + If Command in SmBusAddress is not zero, then ASSERT(). + If Length in SmBusAddress is not zero, then ASSERT(). + If any reserved bits of SmBusAddress are set, then ASSERT(). + + @param SmBusAddress Address that encodes the SMBUS Slave Address, + SMBUS Command, SMBUS Data Length, and PEC. + @param Status Return status for the executed command. + This is an optional parameter and may be NULL. + +**/ +VOID +EFIAPI +SmBusQuickWrite ( + IN UINTN SmBusAddress, + OUT RETURN_STATUS *Status OPTIONAL + ) +{ + ASSERT (!SMBUS_LIB_PEC (SmBusAddress)); + ASSERT (SMBUS_LIB_COMMAND (SmBusAddress) == 0); + ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) == 0); + ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0); + + InternalSmBusExec (EfiSmbusQuickWrite, SmBusAddress, 0, NULL, Status); +} + +/** + Executes an SMBUS receive byte command. + + Executes an SMBUS receive byte command on the SMBUS device specified by SmBusAddress. + Only the SMBUS slave address field of SmBusAddress is required. + The byte received from the SMBUS is returned. + If Status is not NULL, then the status of the executed command is returned in Status. + If Command in SmBusAddress is not zero, then ASSERT(). + If Length in SmBusAddress is not zero, then ASSERT(). + If any reserved bits of SmBusAddress are set, then ASSERT(). + + @param SmBusAddress Address that encodes the SMBUS Slave Address, + SMBUS Command, SMBUS Data Length, and PEC. + @param Status Return status for the executed command. + This is an optional parameter and may be NULL. + + @return The byte received from the SMBUS. + +**/ +UINT8 +EFIAPI +SmBusReceiveByte ( + IN UINTN SmBusAddress, + OUT RETURN_STATUS *Status OPTIONAL + ) +{ + UINT8 Byte; + + ASSERT (SMBUS_LIB_COMMAND (SmBusAddress) == 0); + ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) == 0); + ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0); + + InternalSmBusExec (EfiSmbusReceiveByte, SmBusAddress, 1, &Byte, Status); + + return Byte; +} + +/** + Executes an SMBUS send byte command. + + Executes an SMBUS send byte command on the SMBUS device specified by SmBusAddress. + The byte specified by Value is sent. + Only the SMBUS slave address field of SmBusAddress is required. Value is returned. + If Status is not NULL, then the status of the executed command is returned in Status. + If Command in SmBusAddress is not zero, then ASSERT(). + If Length in SmBusAddress is not zero, then ASSERT(). + If any reserved bits of SmBusAddress are set, then ASSERT(). + + @param SmBusAddress Address that encodes the SMBUS Slave Address, + SMBUS Command, SMBUS Data Length, and PEC. + @param Value The 8-bit value to send. + @param Status Return status for the executed command. + This is an optional parameter and may be NULL. + + @return The parameter of Value. + +**/ +UINT8 +EFIAPI +SmBusSendByte ( + IN UINTN SmBusAddress, + IN UINT8 Value, + OUT RETURN_STATUS *Status OPTIONAL + ) +{ + UINT8 Byte; + + ASSERT (SMBUS_LIB_COMMAND (SmBusAddress) == 0); + ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) == 0); + ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0); + + Byte = Value; + InternalSmBusExec (EfiSmbusSendByte, SmBusAddress, 1, &Byte, Status); + + return Value; +} + +/** + Executes an SMBUS read data byte command. + + Executes an SMBUS read data byte command on the SMBUS device specified by SmBusAddress. + Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required. + The 8-bit value read from the SMBUS is returned. + If Status is not NULL, then the status of the executed command is returned in Status. + If Length in SmBusAddress is not zero, then ASSERT(). + If any reserved bits of SmBusAddress are set, then ASSERT(). + + @param SmBusAddress Address that encodes the SMBUS Slave Address, + SMBUS Command, SMBUS Data Length, and PEC. + @param Status Return status for the executed command. + This is an optional parameter and may be NULL. + + @return The byte read from the SMBUS. + +**/ +UINT8 +EFIAPI +SmBusReadDataByte ( + IN UINTN SmBusAddress, + OUT RETURN_STATUS *Status OPTIONAL + ) +{ + UINT8 Byte; + + ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) == 0); + ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0); + + InternalSmBusExec (EfiSmbusReadByte, SmBusAddress, 1, &Byte, Status); + + return Byte; +} + +/** + Executes an SMBUS write data byte command. + + Executes an SMBUS write data byte command on the SMBUS device specified by SmBusAddress. + The 8-bit value specified by Value is written. + Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required. + Value is returned. + If Status is not NULL, then the status of the executed command is returned in Status. + If Length in SmBusAddress is not zero, then ASSERT(). + If any reserved bits of SmBusAddress are set, then ASSERT(). + + @param SmBusAddress Address that encodes the SMBUS Slave Address, + SMBUS Command, SMBUS Data Length, and PEC. + @param Value The 8-bit value to write. + @param Status Return status for the executed command. + This is an optional parameter and may be NULL. + + @return The parameter of Value. + +**/ +UINT8 +EFIAPI +SmBusWriteDataByte ( + IN UINTN SmBusAddress, + IN UINT8 Value, + OUT RETURN_STATUS *Status OPTIONAL + ) +{ + UINT8 Byte; + + ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) == 0); + ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0); + + Byte = Value; + InternalSmBusExec (EfiSmbusWriteByte, SmBusAddress, 1, &Byte, Status); + + return Value; +} + +/** + Executes an SMBUS read data word command. + + Executes an SMBUS read data word command on the SMBUS device specified by SmBusAddress. + Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required. + The 16-bit value read from the SMBUS is returned. + If Status is not NULL, then the status of the executed command is returned in Status. + If Length in SmBusAddress is not zero, then ASSERT(). + If any reserved bits of SmBusAddress are set, then ASSERT(). + + @param SmBusAddress Address that encodes the SMBUS Slave Address, + SMBUS Command, SMBUS Data Length, and PEC. + @param Status Return status for the executed command. + This is an optional parameter and may be NULL. + + @return The byte read from the SMBUS. + +**/ +UINT16 +EFIAPI +SmBusReadDataWord ( + IN UINTN SmBusAddress, + OUT RETURN_STATUS *Status OPTIONAL + ) +{ + UINT16 Word; + + ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) == 0); + ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0); + + InternalSmBusExec (EfiSmbusReadWord, SmBusAddress, 2, &Word, Status); + + return Word; +} + +/** + Executes an SMBUS write data word command. + + Executes an SMBUS write data word command on the SMBUS device specified by SmBusAddress. + The 16-bit value specified by Value is written. + Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required. + Value is returned. + If Status is not NULL, then the status of the executed command is returned in Status. + If Length in SmBusAddress is not zero, then ASSERT(). + If any reserved bits of SmBusAddress are set, then ASSERT(). + + @param SmBusAddress Address that encodes the SMBUS Slave Address, + SMBUS Command, SMBUS Data Length, and PEC. + @param Value The 16-bit value to write. + @param Status Return status for the executed command. + This is an optional parameter and may be NULL. + + @return The parameter of Value. + +**/ +UINT16 +EFIAPI +SmBusWriteDataWord ( + IN UINTN SmBusAddress, + IN UINT16 Value, + OUT RETURN_STATUS *Status OPTIONAL + ) +{ + UINT16 Word; + + ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) == 0); + ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0); + + Word = Value; + InternalSmBusExec (EfiSmbusWriteWord, SmBusAddress, 2, &Word, Status); + + return Value; +} + +/** + Executes an SMBUS process call command. + + Executes an SMBUS process call command on the SMBUS device specified by SmBusAddress. + The 16-bit value specified by Value is written. + Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required. + The 16-bit value returned by the process call command is returned. + If Status is not NULL, then the status of the executed command is returned in Status. + If Length in SmBusAddress is not zero, then ASSERT(). + If any reserved bits of SmBusAddress are set, then ASSERT(). + + @param SmBusAddress Address that encodes the SMBUS Slave Address, + SMBUS Command, SMBUS Data Length, and PEC. + @param Value The 16-bit value to write. + @param Status Return status for the executed command. + This is an optional parameter and may be NULL. + + @return The 16-bit value returned by the process call command. + +**/ +UINT16 +EFIAPI +SmBusProcessCall ( + IN UINTN SmBusAddress, + IN UINT16 Value, + OUT RETURN_STATUS *Status OPTIONAL + ) +{ + ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) == 0); + ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0); + + InternalSmBusExec (EfiSmbusProcessCall, SmBusAddress, 2, &Value, Status); + + return Value; +} + +/** + Executes an SMBUS read block command. + + Executes an SMBUS read block command on the SMBUS device specified by SmBusAddress. + Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required. + Bytes are read from the SMBUS and stored in Buffer. + The number of bytes read is returned, and will never return a value larger than 32-bytes. + If Status is not NULL, then the status of the executed command is returned in Status. + It is the caller's responsibility to make sure Buffer is large enough for the total number of bytes read. + SMBUS supports a maximum transfer size of 32 bytes, so Buffer does not need to be any larger than 32 bytes. + If Length in SmBusAddress is not zero, then ASSERT(). + If Buffer is NULL, then ASSERT(). + If any reserved bits of SmBusAddress are set, then ASSERT(). + + @param SmBusAddress Address that encodes the SMBUS Slave Address, + SMBUS Command, SMBUS Data Length, and PEC. + @param Buffer Pointer to the buffer to store the bytes read from the SMBUS. + @param Status Return status for the executed command. + This is an optional parameter and may be NULL. + + @return The number of bytes read. + +**/ +UINTN +EFIAPI +SmBusReadBlock ( + IN UINTN SmBusAddress, + OUT VOID *Buffer, + OUT RETURN_STATUS *Status OPTIONAL + ) +{ + ASSERT (Buffer != NULL); + ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) == 0); + ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0); + + return InternalSmBusExec (EfiSmbusReadBlock, SmBusAddress, 0x20, Buffer, Status); +} + +/** + Executes an SMBUS write block command. + + Executes an SMBUS write block command on the SMBUS device specified by SmBusAddress. + The SMBUS slave address, SMBUS command, and SMBUS length fields of SmBusAddress are required. + Bytes are written to the SMBUS from Buffer. + The number of bytes written is returned, and will never return a value larger than 32-bytes. + If Status is not NULL, then the status of the executed command is returned in Status. + If Length in SmBusAddress is zero or greater than 32, then ASSERT(). + If Buffer is NULL, then ASSERT(). + If any reserved bits of SmBusAddress are set, then ASSERT(). + + @param SmBusAddress Address that encodes the SMBUS Slave Address, + SMBUS Command, SMBUS Data Length, and PEC. + @param Buffer Pointer to the buffer to store the bytes read from the SMBUS. + @param Status Return status for the executed command. + This is an optional parameter and may be NULL. + + @return The number of bytes written. + +**/ +UINTN +EFIAPI +SmBusWriteBlock ( + IN UINTN SmBusAddress, + OUT VOID *Buffer, + OUT RETURN_STATUS *Status OPTIONAL + ) +{ + UINTN Length; + + ASSERT (Buffer != NULL); + ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) >= 1); + ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) <= 32); + ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0); + + Length = SMBUS_LIB_LENGTH (SmBusAddress); + return InternalSmBusExec (EfiSmbusWriteBlock, SmBusAddress, Length, Buffer, Status); +} + +/** + Executes an SMBUS block process call command. + + Executes an SMBUS block process call command on the SMBUS device specified by SmBusAddress. + The SMBUS slave address, SMBUS command, and SMBUS length fields of SmBusAddress are required. + Bytes are written to the SMBUS from WriteBuffer. Bytes are then read from the SMBUS into ReadBuffer. + If Status is not NULL, then the status of the executed command is returned in Status. + It is the caller's responsibility to make sure ReadBuffer is large enough for the total number of bytes read. + SMBUS supports a maximum transfer size of 32 bytes, so Buffer does not need to be any larger than 32 bytes. + If Length in SmBusAddress is zero or greater than 32, then ASSERT(). + If WriteBuffer is NULL, then ASSERT(). + If ReadBuffer is NULL, then ASSERT(). + If any reserved bits of SmBusAddress are set, then ASSERT(). + + @param SmBusAddress Address that encodes the SMBUS Slave Address, + SMBUS Command, SMBUS Data Length, and PEC. + @param WriteBuffer Pointer to the buffer of bytes to write to the SMBUS. + @param ReadBuffer Pointer to the buffer of bytes to read from the SMBUS. + @param Status Return status for the executed command. + This is an optional parameter and may be NULL. + + @return The number of bytes written. + +**/ +UINTN +EFIAPI +SmBusBlockProcessCall ( + IN UINTN SmBusAddress, + IN VOID *WriteBuffer, + OUT VOID *ReadBuffer, + OUT RETURN_STATUS *Status OPTIONAL + ) +{ + UINTN Length; + + ASSERT (WriteBuffer != NULL); + ASSERT (ReadBuffer != NULL); + ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) >= 1); + ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) <= 32); + ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0); + + Length = SMBUS_LIB_LENGTH (SmBusAddress); + // + // Assuming that ReadBuffer is large enough to save another memory copy. + // + ReadBuffer = CopyMem (ReadBuffer, WriteBuffer, Length); + return InternalSmBusExec (EfiSmbusBWBRProcessCall, SmBusAddress, Length, ReadBuffer, Status); +} diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/EdkDxeRuntimeDriverLib/Common/RuntimeLib.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/EdkDxeRuntimeDriverLib/Common/RuntimeLib.c new file mode 100644 index 0000000..e0b434b --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/EdkDxeRuntimeDriverLib/Common/RuntimeLib.c @@ -0,0 +1,261 @@ +/*++ + +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: + + RuntimeLib.c + +Abstract: + + Runtime lib + +--*/ + +#include "..\RuntimeLibInternal.h" + +// +// Driver Lib Module Globals +// +STATIC EFI_EVENT mRuntimeNotifyEvent; +STATIC EFI_EVENT mEfiVirtualNotifyEvent; +STATIC BOOLEAN mEfiGoneVirtual = FALSE; +STATIC BOOLEAN mEfiAtRuntime = FALSE; + +EFI_RUNTIME_SERVICES *mRT = NULL; + +VOID +EFIAPI +RuntimeDriverExitBootServices ( + IN EFI_EVENT Event, + IN VOID *Context + ) +/*++ + +Routine Description: + + Set AtRuntime flag as TRUE after ExitBootServices + +Arguments: + + Event - The Event that is being processed + + Context - Event Context + +Returns: + + None + +--*/ +{ + EFI_EVENT_NOTIFY ChildNotifyEventHandler; + UINTN Index; + + for (Index = 0; + _gDriverExitBootServicesEvent[Index] != NULL; + Index++) { + ChildNotifyEventHandler = _gDriverExitBootServicesEvent[Index]; + ChildNotifyEventHandler (Event, NULL); + } + + mEfiAtRuntime = TRUE; +} + +STATIC +VOID +EFIAPI +RuntimeLibVirtualNotifyEvent ( + IN EFI_EVENT Event, + IN VOID *Context + ) +/*++ + +Routine Description: + + Fixup internal data so that EFI can be call in virtual mode. + Call the passed in Child Notify event and convert any pointers in + lib to virtual mode. + +Arguments: + + Event - The Event that is being processed + + Context - Event Context + +Returns: + + None + +--*/ +{ + UINTN Index; + EFI_EVENT_NOTIFY ChildNotifyEventHandler; + + for (Index = 0; + _gDriverSetVirtualAddressMapEvent[Index] != NULL; + Index++) { + ChildNotifyEventHandler = _gDriverSetVirtualAddressMapEvent[Index]; + ChildNotifyEventHandler (Event, NULL); + } + + // + // Update global for Runtime Services Table and IO + // + EfiConvertInternalPointer ((VOID **) &mRT); + + // + // Clear out BootService globals + // + gBS = NULL; + gST = NULL; + mEfiGoneVirtual = TRUE; +} + +EFI_STATUS +EFIAPI +RuntimeDriverLibConstruct ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +/*++ + +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 except EFI_ALREADY_STARTED if already started. + +--*/ +{ + EFI_STATUS Status; + + mRT = SystemTable->RuntimeServices; + + // + // Register our ExitBootServices () notify function + // + Status = gBS->CreateEvent ( + EFI_EVENT_SIGNAL_EXIT_BOOT_SERVICES, + EFI_TPL_NOTIFY, + RuntimeDriverExitBootServices, + NULL, + &mRuntimeNotifyEvent + ); + + ASSERT_EFI_ERROR (Status); + + // + // Register SetVirtualAddressMap () notify function + // + Status = gBS->CreateEvent ( + EFI_EVENT_SIGNAL_VIRTUAL_ADDRESS_CHANGE, + EFI_TPL_NOTIFY, + RuntimeLibVirtualNotifyEvent, + NULL, + &mEfiVirtualNotifyEvent + ); + + ASSERT_EFI_ERROR (Status); + + return EFI_SUCCESS; +} + +EFI_STATUS +EFIAPI +RuntimeDriverLibDeconstruct ( + 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 Status; + + // + // Close our ExitBootServices () notify function + // + Status = gBS->CloseEvent (mRuntimeNotifyEvent); + ASSERT_EFI_ERROR (Status); + + // + // Close SetVirtualAddressMap () notify function + // + Status = gBS->CloseEvent (mEfiVirtualNotifyEvent); + ASSERT_EFI_ERROR (Status); + + return EFI_SUCCESS; +} + +BOOLEAN +EfiAtRuntime ( + VOID + ) +/*++ + +Routine Description: + Return TRUE if ExitBootServices () has been called + +Arguments: + NONE + +Returns: + TRUE - If ExitBootServices () has been called + +--*/ +{ + return mEfiAtRuntime; +} + +BOOLEAN +EfiGoneVirtual ( + VOID + ) +/*++ + +Routine Description: + Return TRUE if SetVirtualAddressMap () has been called + +Arguments: + NONE + +Returns: + TRUE - If SetVirtualAddressMap () has been called + +--*/ +{ + return mEfiGoneVirtual; +} + diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/EdkDxeRuntimeDriverLib/Common/RuntimeService.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/EdkDxeRuntimeDriverLib/Common/RuntimeService.c new file mode 100644 index 0000000..83b718c --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/EdkDxeRuntimeDriverLib/Common/RuntimeService.c @@ -0,0 +1,481 @@ +/*++ + +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: + + RuntimeService.c + +Abstract: + + Runtime Lib + +--*/ + +#include "..\RuntimeLibInternal.h" + +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 + +--*/ +{ + mRT->ResetSystem (ResetType, ResetStatus, DataSize, ResetData); +} + +// +// The following functions hide the mRT local global from the call to +// runtime service in the EFI system table. +// +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 + +--*/ +{ + return mRT->GetTime (Time, Capabilities); +} + +EFI_STATUS +EfiSetTime ( + IN EFI_TIME *Time + ) +/*++ + +Routine Description: + + Sets the current local time and date information. + +Arguments: + + Time - A pointer to the current time. + +Returns: + + Status code + +--*/ +{ + return mRT->SetTime (Time); +} + +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 + +--*/ +{ + return mRT->GetWakeupTime (Enabled, Pending, Time); +} + +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 + +--*/ +{ + return mRT->SetWakeupTime (Enable, Time); +} + + + + +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 + +--*/ +{ + return mRT->GetVariable (VariableName, VendorGuid, Attributes, DataSize, Data); +} + +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 + +--*/ +{ + return mRT->GetNextVariableName (VariableNameSize, VariableName, VendorGuid); +} + +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 + +--*/ +{ + return mRT->SetVariable (VariableName, VendorGuid, Attributes, DataSize, Data); +} + +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 + +--*/ +{ + return mRT->GetNextHighMonotonicCount (HighCount); +} + +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 + +--*/ +{ + return mRT->ConvertPointer (DebugDisposition, Address); +} + +EFI_STATUS +EfiConvertInternalPointer ( + IN OUT VOID *Address + ) +/*++ + +Routine Description: + + Call EfiConvertPointer() to convert internal pointer. + +Arguments: + + 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 + +--*/ +{ + return EfiConvertPointer (0x0, Address); +} + +EFI_STATUS +EfiConvertList ( + IN UINTN DebugDisposition, + IN OUT 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 + +--*/ +{ + LIST_ENTRY *Link; + LIST_ENTRY *NextLink; + + // + // Convert all the ForwardLink & BackLink pointers in the list + // + Link = ListHead; + do { + NextLink = Link->ForwardLink; + + EfiConvertPointer ( + Link->ForwardLink == ListHead ? DebugDisposition : 0, + (VOID **) &Link->ForwardLink + ); + + EfiConvertPointer ( + Link->BackLink == ListHead ? DebugDisposition : 0, + (VOID **) &Link->BackLink + ); + + Link = NextLink; + } while (Link != ListHead); + return EFI_SUCCESS; +} + + +/** + Change the runtime addressing mode of EFI firmware from physical to virtual. + + @param MemoryMapSize The size in bytes of VirtualMap. + @param DescriptorSize The size in bytes of an entry in the VirtualMap. + @param DescriptorVersion The version of the structure entries in VirtualMap. + @param VirtualMap An array of memory descriptors which contain new virtual + address mapping information for all runtime ranges. Type + EFI_MEMORY_DESCRIPTOR is defined in the + GetMemoryMap() function description. + + @retval EFI_SUCCESS The virtual address map has been applied. + @retval EFI_UNSUPPORTED EFI firmware is not at runtime, or the EFI firmware is already in + virtual address mapped mode. + @retval EFI_INVALID_PARAMETER DescriptorSize or DescriptorVersion is + invalid. + @retval EFI_NO_MAPPING A virtual address was not supplied for a range in the memory + map that requires a mapping. + @retval EFI_NOT_FOUND A virtual address was supplied for an address that is not found + in the memory map. +**/ +EFI_STATUS +EFIAPI +EfiSetVirtualAddressMap ( + IN UINTN MemoryMapSize, + IN UINTN DescriptorSize, + IN UINT32 DescriptorVersion, + IN CONST EFI_MEMORY_DESCRIPTOR *VirtualMap + ) +{ + return mRT->SetVirtualAddressMap ( + MemoryMapSize, + DescriptorSize, + DescriptorVersion, + (EFI_MEMORY_DESCRIPTOR *) VirtualMap + ); +} + + +EFI_STATUS +EfiUpdateCapsule ( + IN UEFI_CAPSULE_HEADER **CapsuleHeaderArray, + IN UINTN CapsuleCount, + IN EFI_PHYSICAL_ADDRESS ScatterGatherList OPTIONAL + ) +{ +#if (EFI_SPECIFICATION_VERSION >= 0x00020000) + return mRT->UpdateCapsule ( + CapsuleHeaderArray, + CapsuleCount, + ScatterGatherList + ); +#else + return EFI_UNSUPPORTED; +#endif +} + +EFI_STATUS +EfiQueryCapsuleCapabilities ( + IN UEFI_CAPSULE_HEADER **CapsuleHeaderArray, + IN UINTN CapsuleCount, + OUT UINT64 *MaximumCapsuleSize, + OUT EFI_RESET_TYPE *ResetType + ) +{ +#if (EFI_SPECIFICATION_VERSION >= 0x00020000) + return mRT->QueryCapsuleCapabilities ( + CapsuleHeaderArray, + CapsuleCount, + MaximumCapsuleSize, + ResetType + ); +#else + return EFI_UNSUPPORTED; +#endif +} + + +EFI_STATUS +EfiQueryVariableInfo ( + IN UINT32 Attributes, + OUT UINT64 *MaximumVariableStorageSize, + OUT UINT64 *RemainingVariableStorageSize, + OUT UINT64 *MaximumVariableSize + ) +{ +#if (EFI_SPECIFICATION_VERSION >= 0x00020000) + return mRT->QueryVariableInfo ( + Attributes, + MaximumVariableStorageSize, + RemainingVariableStorageSize, + MaximumVariableSize + ); +#else + return EFI_UNSUPPORTED; +#endif +} diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/EdkDxeRuntimeDriverLib/EdkDxeRuntimeDriverLib.inf b/EDK/Foundation/Library/EdkIIGlueLib/Library/EdkDxeRuntimeDriverLib/EdkDxeRuntimeDriverLib.inf new file mode 100644 index 0000000..170d1ae --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/EdkDxeRuntimeDriverLib/EdkDxeRuntimeDriverLib.inf @@ -0,0 +1,83 @@ +#/*++ +# +# 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: +# +# EdkDxeRuntimeDriverLib.inf +# +# Abstract: +# +# Component description file for EdkDxeRuntimeDriverLib. +# +#--*/ + +[defines] +BASE_NAME = EdkIIGlueEdkDxeRuntimeDriverLib +COMPONENT_TYPE = LIBRARY + +[sources.common] + Common\RuntimeLib.c + Common\RuntimeService.c + +[sources.ia32] + +[sources.x64] + +[sources.ipf] + +[sources.ebc] + + +[includes.common] + . + ..\..\Include + ..\..\include\Library + $(EDK_SOURCE)\Foundation + $(EDK_SOURCE)\Foundation\Framework + $(EDK_SOURCE)\Foundation\Efi + $(EDK_SOURCE)\Foundation\Include + $(EDK_SOURCE)\Foundation\Efi\Include + $(EDK_SOURCE)\Foundation\Framework\Include + $(EDK_SOURCE)\Foundation\Include\IndustryStandard + $(EDK_SOURCE)\Foundation\Core\Dxe + $(EDK_SOURCE)\Foundation\Library\Dxe\Include + $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include + $(EDK_SOURCE)\Foundation\Framework\Guid\DataHubRecords + $(EDK_SOURCE)\Foundation\Framework\Guid\StatusCodeDataTypeId + +[libraries.common] + EdkIIGlueUefiLib + EdkIIGlueBaseLib + EdkIIGlueUefiBootServicesTableLib +# +# R8.x Library +# + EfiProtocolLib + +[libraries.ia32] + +[libraries.x64] + +[nmake.common] + C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION + LIB_STD_FLAGS = /NOLOGO /IGNORE:4006 + +[nmake.ia32] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32 + +[nmake.x64] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64 + +[nmake.ipf] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF + +[nmake.ebc] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_EBC diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/EdkDxeRuntimeDriverLib/EdkIIGlueEdkDxeRuntimeDriverLib.cif b/EDK/Foundation/Library/EdkIIGlueLib/Library/EdkDxeRuntimeDriverLib/EdkIIGlueEdkDxeRuntimeDriverLib.cif new file mode 100644 index 0000000..ed2fd0e --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/EdkDxeRuntimeDriverLib/EdkIIGlueEdkDxeRuntimeDriverLib.cif @@ -0,0 +1,13 @@ +<component> + name = "EdkIIGlueEdkDxeRuntimeDriverLib" + category = ModulePart + LocalRoot = "Edk\Foundation\Library\EdkIIGlueLib\Library\EdkDxeRuntimeDriverLib" + RefName = "EdkIIGlueEdkDxeRuntimeDriverLib" +[files] +"EdkIIGlueEdkDxeRuntimeDriverLib.sdl" +"EdkIIGlueEdkDxeRuntimeDriverLib.mak" +"EdkDxeRuntimeDriverLib.inf" +"Common\RuntimeLib.c" +"Common\RuntimeService.c" +"RuntimeLibInternal.h" +<endComponent> diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/EdkDxeRuntimeDriverLib/EdkIIGlueEdkDxeRuntimeDriverLib.mak b/EDK/Foundation/Library/EdkIIGlueLib/Library/EdkDxeRuntimeDriverLib/EdkIIGlueEdkDxeRuntimeDriverLib.mak new file mode 100644 index 0000000..1811347 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/EdkDxeRuntimeDriverLib/EdkIIGlueEdkDxeRuntimeDriverLib.mak @@ -0,0 +1,103 @@ +#********************************************************************** +#********************************************************************** +#** ** +#** (C)Copyright 1985-2009, American Megatrends, Inc. ** +#** ** +#** All Rights Reserved. ** +#** ** +#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +#** ** +#** Phone: (770)-246-8600 ** +#** ** +#********************************************************************** +#********************************************************************** + +#********************************************************************** +# $Header: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGlueEdkDxeRuntimeDriverLib/EdkIIGlueEdkDxeRuntimeDriverLib.mak 1 1/20/12 3:56a Jeffch $ +# +# $Revision: 1 $ +# +# $Date: 1/20/12 3:56a $ +#********************************************************************** +# Revision History +# ---------------- +# $Log: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGlueEdkDxeRuntimeDriverLib/EdkIIGlueEdkDxeRuntimeDriverLib.mak $ +# +# 1 1/20/12 3:56a Jeffch +# Create Intel EDK 1117 Patch 7. +# +# 1 9/27/11 6:18a Wesleychen +# Intel EDK initially releases. +# +# 1 9/18/09 1:55a Iminglin +# +#********************************************************************** +#<AMI_FHDR_START> +# +# Name: EdkIIGlueEdkDxeRuntimeDriverLib.mak +# +# Description: +# +#<AMI_FHDR_END> +#********************************************************************** + + +EdkIIGlueEdkDxeRuntimeDriverLib_OBJECTS= + +!IF "$(PROCESSOR)"=="IA32" || "$(PROCESSOR)"=="x64" || "$(PROCESSOR)"=="EBC" +EdkIIGlueEdkDxeRuntimeDriverLib_OBJECTS=$(EdkIIGlueEdkDxeRuntimeDriverLib_OBJECTS)\ +$$(BUILD_DIR)\$(EdkIIGlueEdkDxeRuntimeDriverLib_DIR)\Common\RuntimeLib.obj\ +$$(BUILD_DIR)\$(EdkIIGlueEdkDxeRuntimeDriverLib_DIR)\Common\RuntimeService.obj +!ELSEIF "$(PROCESSOR)"=="IPF" +EdkIIGlueEdkDxeRuntimeDriverLib_OBJECTS=$(EdkIIGlueEdkDxeRuntimeDriverLib_OBJECTS)\ +$$(BUILD_DIR)\$(EdkIIGlueEdkDxeRuntimeDriverLib_DIR)\Ipf\RuntimeLib.obj\ +$$(BUILD_DIR)\$(EdkIIGlueEdkDxeRuntimeDriverLib_DIR)\Ipf\RuntimeService.obj +!ENDIF + +$(EdkIIGlueEdkDxeRuntimeDriverLib_LIB) : EdkIIGlueEdkDxeRuntimeDriverLib + +EdkIIGlueEdkDxeRuntimeDriverLib : $(BUILD_DIR)\EdkIIGlueEdkDxeRuntimeDriverLib.mak EdkIIGlueEdkDxeRuntimeDriverLibBin + +$(BUILD_DIR)\EdkIIGlueEdkDxeRuntimeDriverLib.mak : $(EdkIIGlueEdkDxeRuntimeDriverLib_DIR)\$(@B).cif $(EdkIIGlueEdkDxeRuntimeDriverLib_DIR)\$(@B).mak $(BUILD_RULES) + $(CIF2MAK) $(EdkIIGlueEdkDxeRuntimeDriverLib_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS) + +EdkIIGlueEdkDxeRuntimeDriverLib_LIB_LINKS=$(EdkIIGlueUefiLib_LIB)\ +$(EdkIIGlueBaseLib_LIB)\ +$(EdkIIGlueUefiBootServicesTableLib_LIB)\ +$(EFIPROTOCOLLIB)\ +!IF "$(PROCESSOR)"=="IPF" +$(EdkIIGlueEdkDxeSalLib_LIB) +!ENDIF + +EdkIIGlueEdkDxeRuntimeDriverLibBin : $(EdkIIGlueEdkDxeRuntimeDriverLib_LIB_LINKS) +!IF "$(x64_BUILD)"=="1" + $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\ + BUILD_DIR=$(BUILD_DIR)\ + /f $(BUILD_DIR)\EdkIIGlueEdkDxeRuntimeDriverLib.mak all\ + TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueEdkDxeRuntimeDriverLib_LIB)"\ + "OBJECTS=$(EdkIIGlueEdkDxeRuntimeDriverLib_OBJECTS)" + $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\ + BUILD_DIR=$(BUILD_DIR)\IA32\ + /f $(BUILD_DIR)\EdkIIGlueEdkDxeRuntimeDriverLib.mak all\ + TYPE=PEI_LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueEdkDxeRuntimeDriverLib_LIB)"\ + "OBJECTS=$(EdkIIGlueEdkDxeRuntimeDriverLib_OBJECTS)" +!ELSE + $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\ + BUILD_DIR=$(BUILD_DIR)\ + /f $(BUILD_DIR)\EdkIIGlueEdkDxeRuntimeDriverLib.mak all\ + TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueEdkDxeRuntimeDriverLib_LIB)"\ + "OBJECTS=$(EdkIIGlueEdkDxeRuntimeDriverLib_OBJECTS)" +!ENDIF +#********************************************************************** +#********************************************************************** +#** ** +#** (C)Copyright 1985-2009, American Megatrends, Inc. ** +#** ** +#** All Rights Reserved. ** +#** ** +#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +#** ** +#** Phone: (770)-246-8600 ** +#** ** +#********************************************************************** +#********************************************************************** diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/EdkDxeRuntimeDriverLib/EdkIIGlueEdkDxeRuntimeDriverLib.sdl b/EDK/Foundation/Library/EdkIIGlueLib/Library/EdkDxeRuntimeDriverLib/EdkIIGlueEdkDxeRuntimeDriverLib.sdl new file mode 100644 index 0000000..c42a416 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/EdkDxeRuntimeDriverLib/EdkIIGlueEdkDxeRuntimeDriverLib.sdl @@ -0,0 +1,26 @@ +TOKEN + Name = "EdkIIGlueEdkDxeRuntimeDriverLib_SUPPORT" + Value = "1" + Help = "Main switch to enable EdkIIGlueEdkDxeRuntimeDriverLib support in Project" + TokenType = Boolean + TargetEQU = Yes + TargetMAK = Yes + Master = Yes +End + +TOKEN + Name = "EdkIIGlueEdkDxeRuntimeDriverLib_LIB" + Value = "$$(LIB_BUILD_DIR)\EdkIIGlueEdkDxeRuntimeDriverLib.lib" + TokenType = Expression + TargetMAK = Yes +End + +PATH + Name = "EdkIIGlueEdkDxeRuntimeDriverLib_DIR" +End + +MODULE + Help = "Includes EdkIIGlueEdkDxeRuntimeDriverLib.mak to Project" + File = "EdkIIGlueEdkDxeRuntimeDriverLib.mak" +End + diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/EdkDxeRuntimeDriverLib/RuntimeLibInternal.h b/EDK/Foundation/Library/EdkIIGlueLib/Library/EdkDxeRuntimeDriverLib/RuntimeLibInternal.h new file mode 100644 index 0000000..3f37861 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/EdkDxeRuntimeDriverLib/RuntimeLibInternal.h @@ -0,0 +1,35 @@ +/*++ + +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: + + RuntimeLibInternal.h + +Abstract: + + Runtime Lib internal header file + +--*/ + +#ifndef __RUNTIMELIBINTERNAL_H__ +#define __RUNTIMELIBINTERNAL_H__ + +#include "EdkIIGlueDxe.h" + +EFI_STATUS +EfiConvertInternalPointer ( + IN OUT VOID *Address + ); + +extern EFI_RUNTIME_SERVICES *mRT; + +#endif //__RUNTIMELIBINTERNAL_H__ diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/HiiLib/EdkIIGlueHiiLib.cif b/EDK/Foundation/Library/EdkIIGlueLib/Library/HiiLib/EdkIIGlueHiiLib.cif new file mode 100644 index 0000000..0eef635 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/HiiLib/EdkIIGlueHiiLib.cif @@ -0,0 +1,11 @@ +<component> + name = "EdkIIGlueHiiLib" + category = ModulePart + LocalRoot = "Edk\Foundation\Library\EdkIIGlueLib\Library\HiiLib" + RefName = "EdkIIGlueHiiLib" +[files] +"EdkIIGlueHiiLib.sdl" +"EdkIIGlueHiiLib.mak" +"HiiLib.inf" +"HiiLib.c" +<endComponent> diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/HiiLib/EdkIIGlueHiiLib.mak b/EDK/Foundation/Library/EdkIIGlueLib/Library/HiiLib/EdkIIGlueHiiLib.mak new file mode 100644 index 0000000..a69c5c4 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/HiiLib/EdkIIGlueHiiLib.mak @@ -0,0 +1,80 @@ +#********************************************************************** +#********************************************************************** +#** ** +#** (C)Copyright 1985-2009, American Megatrends, Inc. ** +#** ** +#** All Rights Reserved. ** +#** ** +#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +#** ** +#** Phone: (770)-246-8600 ** +#** ** +#********************************************************************** +#********************************************************************** + +#********************************************************************** +# $Header: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGlueHiiLib/EdkIIGlueHiiLib.mak 1 1/20/12 3:56a Jeffch $ +# +# $Revision: 1 $ +# +# $Date: 1/20/12 3:56a $ +#********************************************************************** +# Revision History +# ---------------- +# $Log: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGlueHiiLib/EdkIIGlueHiiLib.mak $ +# +# 1 1/20/12 3:56a Jeffch +# Create Intel EDK 1117 Patch 7. +# +# 1 9/27/11 6:18a Wesleychen +# Intel EDK initially releases. +# +# 1 9/18/09 1:56a Iminglin +# +#********************************************************************** +#<AMI_FHDR_START> +# +# Name: EdkIIGlueHiiLib.mak +# +# Description: +# +#<AMI_FHDR_END> +#********************************************************************** + + +$(EdkIIGlueHiiLib_LIB) : EdkIIGlueHiiLib + +EdkIIGlueHiiLib : $(BUILD_DIR)\EdkIIGlueHiiLib.mak EdkIIGlueHiiLibBin + +$(BUILD_DIR)\EdkIIGlueHiiLib.mak : $(EdkIIGlueHiiLib_DIR)\$(@B).cif $(EdkIIGlueHiiLib_DIR)\$(@B).mak $(BUILD_RULES) + $(CIF2MAK) $(EdkIIGlueHiiLib_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS) + +EdkIIGlueHiiLibBin : $(EdkIIGlueDxeMemoryAllocationLib_LIB) $(EFIPROTOCOLLIB) +!IF "$(x64_BUILD)"=="1" + $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\ + BUILD_DIR=$(BUILD_DIR)\ + /f $(BUILD_DIR)\EdkIIGlueHiiLib.mak all\ + TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueHiiLib_LIB)" + $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\ + BUILD_DIR=$(BUILD_DIR)\IA32\ + /f $(BUILD_DIR)\EdkIIGlueHiiLib.mak all\ + TYPE=PEI_LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueHiiLib_LIB)" +!ELSE + $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\ + BUILD_DIR=$(BUILD_DIR)\ + /f $(BUILD_DIR)\EdkIIGlueHiiLib.mak all\ + TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueHiiLib_LIB)" +!ENDIF +#********************************************************************** +#********************************************************************** +#** ** +#** (C)Copyright 1985-2009, American Megatrends, Inc. ** +#** ** +#** All Rights Reserved. ** +#** ** +#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +#** ** +#** Phone: (770)-246-8600 ** +#** ** +#********************************************************************** +#**********************************************************************
\ No newline at end of file diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/HiiLib/EdkIIGlueHiiLib.sdl b/EDK/Foundation/Library/EdkIIGlueLib/Library/HiiLib/EdkIIGlueHiiLib.sdl new file mode 100644 index 0000000..31c6c1d --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/HiiLib/EdkIIGlueHiiLib.sdl @@ -0,0 +1,26 @@ +TOKEN + Name = "EdkIIGlueHiiLib_SUPPORT" + Value = "1" + Help = "Main switch to enable EdkIIGlueHiiLib support in Project" + TokenType = Boolean + TargetEQU = Yes + TargetMAK = Yes + Master = Yes +End + +TOKEN + Name = "EdkIIGlueHiiLib_LIB" + Value = "$$(LIB_BUILD_DIR)\EdkIIGlueHiiLib.lib" + TokenType = Expression + TargetMAK = Yes +End + +PATH + Name = "EdkIIGlueHiiLib_DIR" +End + +MODULE + Help = "Includes EdkIIGlueHiiLib.mak to Project" + File = "EdkIIGlueHiiLib.mak" +End + diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/HiiLib/HiiLib.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/HiiLib/HiiLib.c new file mode 100644 index 0000000..3424d91 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/HiiLib/HiiLib.c @@ -0,0 +1,75 @@ +/*++ + +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: + + HiiLib.c + +Abstract: + + HII Library implementation that uses DXE protocols and services. + +--*/ + +#include "EdkIIGlueDxe.h" + +#if (EFI_SPECIFICATION_VERSION < 0x0002000A) +/** + This function allocates pool for an EFI_HII_PACKAGES structure + with enough space for the variable argument list of package pointers. + The allocated structure is initialized using NumberOfPackages, Guid, + and the variable length argument list of package pointers. + + @param NumberOfPackages The number of HII packages to prepare. + @param Guid Package GUID. + + @return The allocated and initialized packages. + +**/ +EFI_HII_PACKAGES * +EFIAPI +GluePreparePackages ( + IN UINTN NumberOfPackages, + IN CONST EFI_GUID *Guid OPTIONAL, + ... + ) +{ + VA_LIST Args; + EFI_HII_PACKAGES *HiiPackages; + VOID **Package; + UINTN Index; + + ASSERT (NumberOfPackages > 0); + + HiiPackages = AllocateZeroPool (sizeof (EFI_HII_PACKAGES) + NumberOfPackages * sizeof (VOID *)); + ASSERT (HiiPackages != NULL); + if (HiiPackages == NULL) { + return HiiPackages; + } + + HiiPackages->GuidId = (EFI_GUID *) Guid; + HiiPackages->NumberOfPackages = NumberOfPackages; + Package = (VOID **) (((UINT8 *) HiiPackages) + sizeof (EFI_HII_PACKAGES)); + + VA_START (Args, Guid); + + for (Index = 0; Index < NumberOfPackages; Index++) { + *Package = VA_ARG (Args, VOID *); + Package++; + } + + VA_END (Args); + + return HiiPackages; + +} +#endif diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/HiiLib/HiiLib.inf b/EDK/Foundation/Library/EdkIIGlueLib/Library/HiiLib/HiiLib.inf new file mode 100644 index 0000000..8e57c64 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/HiiLib/HiiLib.inf @@ -0,0 +1,77 @@ +#/*++ +# +# 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: +# +# HiiLib.inf +# +# Abstract: +# +# Component description file for HiiLib. +# +#--*/ + +[defines] +BASE_NAME = EdkIIGlueHiiLib +COMPONENT_TYPE = LIBRARY + +[sources.common] + HiiLib.c + +[sources.ia32] + +[sources.x64] + +[sources.ipf] + +[sources.ebc] + + +[includes.common] + . + ..\..\Include + ..\..\include\Library + $(EDK_SOURCE)\Foundation + $(EDK_SOURCE)\Foundation\Framework + $(EDK_SOURCE)\Foundation\Framework\Protocol\Hii + $(EDK_SOURCE)\Foundation\Efi + $(EDK_SOURCE)\Foundation\Include + $(EDK_SOURCE)\Foundation\Efi\Include + $(EDK_SOURCE)\Foundation\Framework\Include + $(EDK_SOURCE)\Foundation\Include\IndustryStandard + $(EDK_SOURCE)\Foundation\Core\Dxe + $(EDK_SOURCE)\Foundation\Library\Dxe\Include + $(EDK_SOURCE)\Foundation\Library\Dxe\EfiIfrSupportLib + $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include + +[libraries.common] + EdkIIGlueDxeMemoryAllocationLib + EfiProtocolLib + +[libraries.ia32] + +[libraries.x64] + +[nmake.common] + C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION + LIB_STD_FLAGS = /NOLOGO /IGNORE:4006 + +[nmake.ia32] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32 + +[nmake.x64] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64 + +[nmake.ipf] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF + +[nmake.ebc] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_EBC
\ No newline at end of file diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiDebugLibReportStatusCode/DebugLib.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiDebugLibReportStatusCode/DebugLib.c new file mode 100644 index 0000000..ac846dc --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiDebugLibReportStatusCode/DebugLib.c @@ -0,0 +1,336 @@ +/*++ + +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: + + DebugLib.c + +Abstract: + + Debug Library that fowards all messages to ReportStatusCode() + +--*/ + +#include "EdkIIGluePeim.h" +#include EFI_PPI_CONSUMER (DebugMask) +#include "Pcd\EdkIIGluePcdDebugLib.h" + +/** + + Gets the error level. + + If DebugMaskInterface is not NULL, return the error level from DebugMaskInterface. + + If DebugMaskInterface is NULL, return the default define DebugPrintErrorLevel error level. + + @retval Debug Message Error Level + +**/ +UINTN +EFIAPI +EdkIIGlueGetDebugPrintErrorLevel ( + VOID + ) +{ + EFI_STATUS Status; + EFI_DEBUG_MASK_PPI *DebugMaskPpi; + EFI_PEI_SERVICES **PeiServices; + + PeiServices = GetPeiServicesTablePointer (); + // + // Locate the Debug Mask PPI. + // + Status = (*PeiServices)->LocatePpi ( + PeiServices, + &gEfiDebugMaskPpiGuid, + 0, + NULL, + &DebugMaskPpi + ); + + // + // Check driver debug mask value and global mask + // + if (!EFI_ERROR (Status)) { + return DebugMaskPpi->ImageDebugMask; + } + return EDKII_GLUE_DebugPrintErrorLevel; +} + +/** + + Prints a debug message to the debug output device if the specified error level is enabled. + + If any bit in ErrorLevel is also set in PcdDebugPrintErrorLevel, then print + the message specified by Format and the associated variable argument list to + the debug output device. + + If Format is NULL, then ASSERT(). + + @param ErrorLevel The error level of the debug message. + @param Format Format string for the debug message to print. + +**/ +VOID +EFIAPI +DebugPrint ( + IN UINTN ErrorLevel, + IN CONST CHAR8 *Format, + ... + ) +{ + UINT64 Buffer[EFI_STATUS_CODE_DATA_MAX_SIZE / sizeof (UINT64)]; + EFI_DEBUG_INFO *DebugInfo; + UINTN TotalSize; + UINTN Index; + VA_LIST Marker; + UINT64 *ArgumentPointer; + + // + // If Format is NULL, then ASSERT(). + // + ASSERT (Format != NULL); + + // + // Check driver Debug Level value and global debug level + // + if ((ErrorLevel & PcdGet32(PcdDebugPrintErrorLevel)) == 0) { + return; + } + + TotalSize = sizeof (EFI_DEBUG_INFO) + 12 * sizeof (UINT64) + AsciiStrLen (Format) + 1; + if (TotalSize > EFI_STATUS_CODE_DATA_MAX_SIZE) { + return; + } + + // + // Then EFI_DEBUG_INFO + // + DebugInfo = (EFI_DEBUG_INFO *)Buffer; + DebugInfo->ErrorLevel = (UINT32)ErrorLevel; + + // + // 256 byte mini Var Arg stack. That is followed by the format string. + // + VA_START (Marker, Format); + for (Index = 0, ArgumentPointer = (UINT64 *)(DebugInfo + 1); Index < 12; Index++, ArgumentPointer++) { + *ArgumentPointer = VA_ARG (Marker, UINT64); + } + VA_END (Marker); + AsciiStrCpy ((CHAR8 *)ArgumentPointer, Format); + + REPORT_STATUS_CODE_EX ( + EFI_DEBUG_CODE, + (EFI_SOFTWARE_DXE_BS_DRIVER | EFI_DC_UNSPECIFIED), + 0, + NULL, + &gEfiStatusCodeDataTypeDebugGuid, + DebugInfo, + TotalSize + ); +} + + +/** + + Prints an assert message containing a filename, line number, and description. + This may be followed by a breakpoint or a dead loop. + + Print a message of the form "ASSERT <FileName>(<LineNumber>): <Description>\n" + to the debug output device. If DEBUG_PROPERTY_ASSERT_BREAKPOINT_ENABLED bit of + PcdDebugProperyMask is set then CpuBreakpoint() is called. Otherwise, if + DEBUG_PROPERTY_ASSERT_DEADLOOP_ENABLED bit of PcdDebugProperyMask is set then + CpuDeadLoop() is called. If neither of these bits are set, then this function + returns immediately after the message is printed to the debug output device. + DebugAssert() must actively prevent recusrsion. If DebugAssert() is called while + processing another DebugAssert(), then DebugAssert() must return immediately. + + If FileName is NULL, then a <FileName> string of "(NULL) Filename" is printed. + + If Description is NULL, then a <Description> string of "(NULL) Description" is printed. + + @param FileName Pointer to the name of the source file that generated the assert condition. + @param LineNumber The line number in the source file that generated the assert condition + @param Description Pointer to the description of the assert condition. + +**/ +VOID +EFIAPI +DebugAssert ( + IN CONST CHAR8 *FileName, + IN UINTN LineNumber, + IN CONST CHAR8 *Description + ) +{ + UINT64 Buffer[EFI_STATUS_CODE_DATA_MAX_SIZE / sizeof(UINT64)]; + EFI_DEBUG_ASSERT_DATA *AssertData; + UINTN TotalSize; + CHAR8 *Temp; + + // + // Make sure it will all fit in the passed in buffer + // + TotalSize = sizeof (EFI_DEBUG_ASSERT_DATA) + AsciiStrLen (FileName) + 1 + AsciiStrLen (Description) + 1; + if (TotalSize <= EFI_STATUS_CODE_DATA_MAX_SIZE) { + // + // Fill in EFI_DEBUG_ASSERT_DATA + // + AssertData = (EFI_DEBUG_ASSERT_DATA *)Buffer; + AssertData->LineNumber = (UINT32)LineNumber; + + // + // Copy Ascii FileName including NULL. + // + Temp = AsciiStrCpy ((CHAR8 *)(AssertData + 1), FileName); + + // + // Copy Ascii Description + // + AsciiStrCpy (Temp + AsciiStrLen (FileName) + 1, Description); + + REPORT_STATUS_CODE_WITH_EXTENDED_DATA ( + (EFI_ERROR_CODE | EFI_ERROR_UNRECOVERED), + (EFI_SOFTWARE_DXE_BS_DRIVER | EFI_SW_EC_ILLEGAL_SOFTWARE_STATE), + AssertData, + TotalSize + ); + } + + // + // Generate a Breakpoint, DeadLoop, or NOP based on PCD settings + // + if ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_ASSERT_BREAKPOINT_ENABLED) != 0) { + CpuBreakpoint (); + } else if ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_ASSERT_DEADLOOP_ENABLED) != 0) { + CpuDeadLoop (); + } +} + + +/** + + Fills a target buffer with PcdDebugClearMemoryValue, and returns the target buffer. + + This function fills Length bytes of Buffer with the value specified by + PcdDebugClearMemoryValue, and returns Buffer. + + If Buffer is NULL, then ASSERT(). + + If Length is greater than (MAX_ADDRESS ?Buffer + 1), then ASSERT(). + + @param Buffer Pointer to the target buffer to fill with PcdDebugClearMemoryValue. + @param Length Number of bytes in Buffer to fill with zeros PcdDebugClearMemoryValue. + + @return Buffer + +**/ +VOID * +EFIAPI +DebugClearMemory ( + OUT VOID *Buffer, + IN UINTN Length + ) +{ + // + // If Buffer is NULL, then ASSERT(). + // + ASSERT (Buffer != NULL); + + // + // SetMem() checks for the the ASSERT() condition on Length and returns Buffer + // + return SetMem (Buffer, Length, PcdGet8(PcdDebugClearMemoryValue)); +} + + +/** + + Returns TRUE if ASSERT() macros are enabled. + + This function returns TRUE if the DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED bit of + PcdDebugProperyMask is set. Otherwise FALSE is returned. + + @retval TRUE The DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED bit of PcdDebugProperyMask is set. + @retval FALSE The DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED bit of PcdDebugProperyMask is clear. + +**/ +BOOLEAN +EFIAPI +DebugAssertEnabled ( + VOID + ) +{ + return ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED) != 0); +} + + +/** + + Returns TRUE if DEBUG()macros are enabled. + + This function returns TRUE if the DEBUG_PROPERTY_DEBUG_PRINT_ENABLED bit of + PcdDebugProperyMask is set. Otherwise FALSE is returned. + + @retval TRUE The DEBUG_PROPERTY_DEBUG_PRINT_ENABLED bit of PcdDebugProperyMask is set. + @retval FALSE The DEBUG_PROPERTY_DEBUG_PRINT_ENABLED bit of PcdDebugProperyMask is clear. + +**/ +BOOLEAN +EFIAPI +DebugPrintEnabled ( + VOID + ) +{ + return ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_DEBUG_PRINT_ENABLED) != 0); +} + + +/** + + Returns TRUE if DEBUG_CODE()macros are enabled. + + This function returns TRUE if the DEBUG_PROPERTY_DEBUG_CODE_ENABLED bit of + PcdDebugProperyMask is set. Otherwise FALSE is returned. + + @retval TRUE The DEBUG_PROPERTY_DEBUG_CODE_ENABLED bit of PcdDebugProperyMask is set. + @retval FALSE The DEBUG_PROPERTY_DEBUG_CODE_ENABLED bit of PcdDebugProperyMask is clear. + +**/ +BOOLEAN +EFIAPI +DebugCodeEnabled ( + VOID + ) +{ + return ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_DEBUG_CODE_ENABLED) != 0); +} + + +/** + + Returns TRUE if DEBUG_CLEAR_MEMORY()macro is enabled. + + This function returns TRUE if the DEBUG_PROPERTY_DEBUG_CLEAR_MEMORY_ENABLED bit of + PcdDebugProperyMask is set. Otherwise FALSE is returned. + + @retval TRUE The DEBUG_PROPERTY_DEBUG_CLEAR_MEMORY_ENABLED bit of PcdDebugProperyMask is set. + @retval FALSE The DEBUG_PROPERTY_DEBUG_CLEAR_MEMORY_ENABLED bit of PcdDebugProperyMask is clear. + +**/ +BOOLEAN +EFIAPI +DebugClearMemoryEnabled ( + VOID + ) +{ + return ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_CLEAR_MEMORY_ENABLED) != 0); +} diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiDebugLibReportStatusCode/EdkIIGluePeiDebugLibReportStatusCode.cif b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiDebugLibReportStatusCode/EdkIIGluePeiDebugLibReportStatusCode.cif new file mode 100644 index 0000000..1022964 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiDebugLibReportStatusCode/EdkIIGluePeiDebugLibReportStatusCode.cif @@ -0,0 +1,11 @@ +<component> + name = "EdkIIGluePeiDebugLibReportStatusCode" + category = ModulePart + LocalRoot = "Edk\Foundation\Library\EdkIIGlueLib\Library\PeiDebugLibReportStatusCode" + RefName = "EdkIIGluePeiDebugLibReportStatusCode" +[files] +"EdkIIGluePeiDebugLibReportStatusCode.sdl" +"EdkIIGluePeiDebugLibReportStatusCode.mak" +"PeiDebugLibReportStatusCode.inf" +"DebugLib.c" +<endComponent> diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiDebugLibReportStatusCode/EdkIIGluePeiDebugLibReportStatusCode.mak b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiDebugLibReportStatusCode/EdkIIGluePeiDebugLibReportStatusCode.mak new file mode 100644 index 0000000..1eeb2cb --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiDebugLibReportStatusCode/EdkIIGluePeiDebugLibReportStatusCode.mak @@ -0,0 +1,80 @@ +#********************************************************************** +#********************************************************************** +#** ** +#** (C)Copyright 1985-2009, American Megatrends, Inc. ** +#** ** +#** All Rights Reserved. ** +#** ** +#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +#** ** +#** Phone: (770)-246-8600 ** +#** ** +#********************************************************************** +#********************************************************************** + +#********************************************************************** +# $Header: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGluePeiDebugLibReportStatusCode/EdkIIGluePeiDebugLibReportStatusCode.mak 1 1/20/12 3:56a Jeffch $ +# +# $Revision: 1 $ +# +# $Date: 1/20/12 3:56a $ +#********************************************************************** +# Revision History +# ---------------- +# $Log: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGluePeiDebugLibReportStatusCode/EdkIIGluePeiDebugLibReportStatusCode.mak $ +# +# 1 1/20/12 3:56a Jeffch +# Create Intel EDK 1117 Patch 7. +# +# 1 9/27/11 6:18a Wesleychen +# Intel EDK initially releases. +# +# 1 9/18/09 1:56a Iminglin +# +#********************************************************************** +#<AMI_FHDR_START> +# +# Name: EdkIIGluePeiDebugLibReportStatusCode.mak +# +# Description: +# +#<AMI_FHDR_END> +#********************************************************************** + + +$(EdkIIGluePeiDebugLibReportStatusCode_LIB) : EdkIIGluePeiDebugLibReportStatusCode + +EdkIIGluePeiDebugLibReportStatusCode : $(BUILD_DIR)\EdkIIGluePeiDebugLibReportStatusCode.mak EdkIIGluePeiDebugLibReportStatusCodeBin + +$(BUILD_DIR)\EdkIIGluePeiDebugLibReportStatusCode.mak : $(EdkIIGluePeiDebugLibReportStatusCode_DIR)\$(@B).cif $(EdkIIGluePeiDebugLibReportStatusCode_DIR)\$(@B).mak $(BUILD_RULES) + $(CIF2MAK) $(EdkIIGluePeiDebugLibReportStatusCode_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS) + +EdkIIGluePeiDebugLibReportStatusCodeBin : $(EdkIIGlueBaseLib_LIB) $(EdkIIGlueBaseMemoryLib_LIB) $(EDKFRAMEWORKGUIDLIB) $(EFIPROTOCOLLIB) $(EDKPPILIB) +!IF "$(x64_BUILD)"=="1" + $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\ + BUILD_DIR=$(BUILD_DIR)\ + /f $(BUILD_DIR)\EdkIIGluePeiDebugLibReportStatusCode.mak all\ + TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGluePeiDebugLibReportStatusCode_LIB)" + $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\ + BUILD_DIR=$(BUILD_DIR)\IA32\ + /f $(BUILD_DIR)\EdkIIGluePeiDebugLibReportStatusCode.mak all\ + TYPE=PEI_LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGluePeiDebugLibReportStatusCode_LIB)" +!ELSE + $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\ + BUILD_DIR=$(BUILD_DIR)\ + /f $(BUILD_DIR)\EdkIIGluePeiDebugLibReportStatusCode.mak all\ + TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGluePeiDebugLibReportStatusCode_LIB)" +!ENDIF +#********************************************************************** +#********************************************************************** +#** ** +#** (C)Copyright 1985-2009, American Megatrends, Inc. ** +#** ** +#** All Rights Reserved. ** +#** ** +#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +#** ** +#** Phone: (770)-246-8600 ** +#** ** +#********************************************************************** +#********************************************************************** diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiDebugLibReportStatusCode/EdkIIGluePeiDebugLibReportStatusCode.sdl b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiDebugLibReportStatusCode/EdkIIGluePeiDebugLibReportStatusCode.sdl new file mode 100644 index 0000000..fe8a1e9 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiDebugLibReportStatusCode/EdkIIGluePeiDebugLibReportStatusCode.sdl @@ -0,0 +1,26 @@ +TOKEN + Name = "EdkIIGluePeiDebugLibReportStatusCode_SUPPORT" + Value = "1" + Help = "Main switch to enable EdkIIGluePeiDebugLibReportStatusCode support in Project" + TokenType = Boolean + TargetEQU = Yes + TargetMAK = Yes + Master = Yes +End + +TOKEN + Name = "EdkIIGluePeiDebugLibReportStatusCode_LIB" + Value = "$$(LIB_BUILD_DIR)\EdkIIGluePeiDebugLibReportStatusCode.lib" + TokenType = Expression + TargetMAK = Yes +End + +PATH + Name = "EdkIIGluePeiDebugLibReportStatusCode_DIR" +End + +MODULE + Help = "Includes EdkIIGluePeiDebugLibReportStatusCode.mak to Project" + File = "EdkIIGluePeiDebugLibReportStatusCode.mak" +End + diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiDebugLibReportStatusCode/PeiDebugLibReportStatusCode.inf b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiDebugLibReportStatusCode/PeiDebugLibReportStatusCode.inf new file mode 100644 index 0000000..8ec6663 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiDebugLibReportStatusCode/PeiDebugLibReportStatusCode.inf @@ -0,0 +1,90 @@ +#/*++ +# +# 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: +# +# PeiDebugLibReportStatusCode.inf +# +# Abstract: +# +# Component description file for PeiDebugLibReportStatusCode. +# +#--*/ + +[defines] +BASE_NAME = EdkIIGluePeiDebugLibReportStatusCode +COMPONENT_TYPE = LIBRARY + +[sources.common] + DebugLib.c + +[sources.ia32] + +[sources.x64] + +[sources.ipf] + +[sources.ebc] + + +[includes.common] + . + ..\..\Include + ..\..\include\Library + $(EDK_SOURCE)\Foundation + $(EDK_SOURCE)\Foundation\Framework + $(EDK_SOURCE)\Foundation\Framework\Protocol\Hii + $(EDK_SOURCE)\Foundation\Efi + $(EDK_SOURCE)\Foundation\Include + $(EDK_SOURCE)\Foundation\Efi\Include + $(EDK_SOURCE)\Foundation\Framework\Include + $(EDK_SOURCE)\Foundation\Include\IndustryStandard + $(EDK_SOURCE)\Foundation\Core\Dxe + $(EDK_SOURCE)\Foundation\Library\Dxe\Include + $(EDK_SOURCE)\Foundation\Library\Dxe\EfiIfrSupportLib + $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include + $(EDK_SOURCE)\Foundation\Include\Pei + +[libraries.common] + EdkIIGlueBaseLib + EdkIIGlueBaseMemoryLib +# +# R8.x +# + EdkFrameworkGuidLib + EfiProtocolLib + EdkPpiLib +# +# +# An user must specify a PEI or DXE ReportStatusCodeLib instance in module's .inf +# + +[libraries.ia32] + + +[libraries.x64] + + +[nmake.common] + C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION + LIB_STD_FLAGS = /NOLOGO /IGNORE:4006 + +[nmake.ia32] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32 + +[nmake.x64] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64 + +[nmake.ipf] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF + +[nmake.ebc] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_EBC
\ No newline at end of file diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiDxePostCodeLibReportStatusCode/EdkIIGluePeiDxePostCodeLibReportStatusCode.cif b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiDxePostCodeLibReportStatusCode/EdkIIGluePeiDxePostCodeLibReportStatusCode.cif new file mode 100644 index 0000000..ada48e4 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiDxePostCodeLibReportStatusCode/EdkIIGluePeiDxePostCodeLibReportStatusCode.cif @@ -0,0 +1,11 @@ +<component> + name = "EdkIIGluePeiDxePostCodeLibReportStatusCode" + category = ModulePart + LocalRoot = "Edk\Foundation\Library\EdkIIGlueLib\Library\PeiDxePostCodeLibReportStatusCode" + RefName = "EdkIIGluePeiDxePostCodeLibReportStatusCode" +[files] +"EdkIIGluePeiDxePostCodeLibReportStatusCode.sdl" +"EdkIIGluePeiDxePostCodeLibReportStatusCode.mak" +"PeiDxePostCodeLibReportStatusCode.inf" +"PostCode.c" +<endComponent> diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiDxePostCodeLibReportStatusCode/EdkIIGluePeiDxePostCodeLibReportStatusCode.mak b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiDxePostCodeLibReportStatusCode/EdkIIGluePeiDxePostCodeLibReportStatusCode.mak new file mode 100644 index 0000000..92a03b3 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiDxePostCodeLibReportStatusCode/EdkIIGluePeiDxePostCodeLibReportStatusCode.mak @@ -0,0 +1,80 @@ +#********************************************************************** +#********************************************************************** +#** ** +#** (C)Copyright 1985-2009, American Megatrends, Inc. ** +#** ** +#** All Rights Reserved. ** +#** ** +#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +#** ** +#** Phone: (770)-246-8600 ** +#** ** +#********************************************************************** +#********************************************************************** + +#********************************************************************** +# $Header: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGluePeiDxePostCodeLibReportStatusCode/EdkIIGluePeiDxePostCodeLibReportStatusCode.mak 1 1/20/12 3:56a Jeffch $ +# +# $Revision: 1 $ +# +# $Date: 1/20/12 3:56a $ +#********************************************************************** +# Revision History +# ---------------- +# $Log: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGluePeiDxePostCodeLibReportStatusCode/EdkIIGluePeiDxePostCodeLibReportStatusCode.mak $ +# +# 1 1/20/12 3:56a Jeffch +# Create Intel EDK 1117 Patch 7. +# +# 1 9/27/11 6:18a Wesleychen +# Intel EDK initially releases. +# +# 1 9/18/09 1:56a Iminglin +# +#********************************************************************** +#<AMI_FHDR_START> +# +# Name: EdkIIGluePeiDxePostCodeLibReportStatusCode.mak +# +# Description: +# +#<AMI_FHDR_END> +#********************************************************************** + + +$(EdkIIGluePeiDxePostCodeLibReportStatusCode_LIB) : EdkIIGluePeiDxePostCodeLibReportStatusCode + +EdkIIGluePeiDxePostCodeLibReportStatusCode : $(BUILD_DIR)\EdkIIGluePeiDxePostCodeLibReportStatusCode.mak EdkIIGluePeiDxePostCodeLibReportStatusCodeBin + +$(BUILD_DIR)\EdkIIGluePeiDxePostCodeLibReportStatusCode.mak : $(EdkIIGluePeiDxePostCodeLibReportStatusCode_DIR)\$(@B).cif $(EdkIIGluePeiDxePostCodeLibReportStatusCode_DIR)\$(@B).mak $(BUILD_RULES) + $(CIF2MAK) $(EdkIIGluePeiDxePostCodeLibReportStatusCode_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS) + +EdkIIGluePeiDxePostCodeLibReportStatusCodeBin : +!IF "$(x64_BUILD)"=="1" + $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\ + BUILD_DIR=$(BUILD_DIR)\ + /f $(BUILD_DIR)\EdkIIGluePeiDxePostCodeLibReportStatusCode.mak all\ + TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGluePeiDxePostCodeLibReportStatusCode_LIB)" + $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\ + BUILD_DIR=$(BUILD_DIR)\IA32\ + /f $(BUILD_DIR)\EdkIIGluePeiDxePostCodeLibReportStatusCode.mak all\ + TYPE=PEI_LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGluePeiDxePostCodeLibReportStatusCode_LIB)" +!ELSE + $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\ + BUILD_DIR=$(BUILD_DIR)\ + /f $(BUILD_DIR)\EdkIIGluePeiDxePostCodeLibReportStatusCode.mak all\ + TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGluePeiDxePostCodeLibReportStatusCode_LIB)" +!ENDIF +#********************************************************************** +#********************************************************************** +#** ** +#** (C)Copyright 1985-2009, American Megatrends, Inc. ** +#** ** +#** All Rights Reserved. ** +#** ** +#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +#** ** +#** Phone: (770)-246-8600 ** +#** ** +#********************************************************************** +#********************************************************************** diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiDxePostCodeLibReportStatusCode/EdkIIGluePeiDxePostCodeLibReportStatusCode.sdl b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiDxePostCodeLibReportStatusCode/EdkIIGluePeiDxePostCodeLibReportStatusCode.sdl new file mode 100644 index 0000000..386b4b6 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiDxePostCodeLibReportStatusCode/EdkIIGluePeiDxePostCodeLibReportStatusCode.sdl @@ -0,0 +1,26 @@ +TOKEN + Name = "EdkIIGluePeiDxePostCodeLibReportStatusCode_SUPPORT" + Value = "1" + Help = "Main switch to enable EdkIIGluePeiDxePostCodeLibReportStatusCode support in Project" + TokenType = Boolean + TargetEQU = Yes + TargetMAK = Yes + Master = Yes +End + +TOKEN + Name = "EdkIIGluePeiDxePostCodeLibReportStatusCode_LIB" + Value = "$$(LIB_BUILD_DIR)\EdkIIGluePeiDxePostCodeLibReportStatusCode.lib" + TokenType = Expression + TargetMAK = Yes +End + +PATH + Name = "EdkIIGluePeiDxePostCodeLibReportStatusCode_DIR" +End + +MODULE + Help = "Includes EdkIIGluePeiDxePostCodeLibReportStatusCode.mak to Project" + File = "EdkIIGluePeiDxePostCodeLibReportStatusCode.mak" +End + diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiDxePostCodeLibReportStatusCode/PeiDxePostCodeLibReportStatusCode.inf b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiDxePostCodeLibReportStatusCode/PeiDxePostCodeLibReportStatusCode.inf new file mode 100644 index 0000000..8916894 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiDxePostCodeLibReportStatusCode/PeiDxePostCodeLibReportStatusCode.inf @@ -0,0 +1,81 @@ +#/*++ +# +# 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: +# +# PeiDxePostCodeLibReportStatusCode.inf +# +# Abstract: +# +# Component description file for PeiDxePostCodeLibReportStatusCode. +# +#--*/ + +[defines] +BASE_NAME = EdkIIGluePeiDxePostCodeLibReportStatusCode +COMPONENT_TYPE = LIBRARY + +[sources.common] + PostCode.c + +[sources.ia32] + +[sources.x64] + +[sources.ipf] + +[sources.ebc] + + +[includes.common] + . + ..\..\Include + ..\..\include\Library + $(EDK_SOURCE)\Foundation + $(EDK_SOURCE)\Foundation\Framework + $(EDK_SOURCE)\Foundation\Framework\Protocol\Hii + $(EDK_SOURCE)\Foundation\Efi + $(EDK_SOURCE)\Foundation\Include + $(EDK_SOURCE)\Foundation\Efi\Include + $(EDK_SOURCE)\Foundation\Framework\Include + $(EDK_SOURCE)\Foundation\Include\IndustryStandard + $(EDK_SOURCE)\Foundation\Core\Dxe + $(EDK_SOURCE)\Foundation\Library\Dxe\Include + $(EDK_SOURCE)\Foundation\Library\Dxe\EfiIfrSupportLib + $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include + +[libraries.common] +# +# An user must specify a PEI or DXE ReportStatusCodeLib instance in module's .inf +# + EfiProtocolLib + +[libraries.ia32] + + +[libraries.x64] + + +[nmake.common] + C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION + LIB_STD_FLAGS = /NOLOGO /IGNORE:4006 + +[nmake.ia32] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32 + +[nmake.x64] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64 + +[nmake.ipf] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF + +[nmake.ebc] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_EBC
\ No newline at end of file diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiDxePostCodeLibReportStatusCode/PostCode.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiDxePostCodeLibReportStatusCode/PostCode.c new file mode 100644 index 0000000..6fcb711 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiDxePostCodeLibReportStatusCode/PostCode.c @@ -0,0 +1,161 @@ +/*++ + +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: + + PostCode.c + +Abstract: + + Post Code Lib + +--*/ + +#include "EdkIIGlueDxe.h" +#include "Pcd\EdkIIGluePcdPostCodeLib.h" + +/** + Converts POST code value to status code value. + + This macro converts the post code to status code value. Bits 0..4 of PostCode + are mapped to bits 16..20 of status code value, and bits 5..7 of PostCode are mapped to bits + 24..26 of status code value. + + @param PostCode POST code value. + + @return The converted status code value. + +**/ +#define POST_CODE_TO_STATUS_CODE_VALUE(PostCode) \ + ((EFI_STATUS_CODE_VALUE) (((PostCode & 0x1f) << 16) | ((PostCode & 0x3) << 19))) + +/** + Sends an 32-bit value to a POST card. + + Sends the 32-bit value specified by Value to a POST card, and returns Value. + Some implementations of this library function may perform I/O operations + directly to a POST card device. Other implementations may send Value to + ReportStatusCode(), and the status code reporting mechanism will eventually + display the 32-bit value on the status reporting device. + + PostCode() must actively prevent recursion. If PostCode() is called while + processing another any other Report Status Code Library function, then + PostCode() must return Value immediately. + + @param Value The 32-bit value to write to the POST card. + + @return Value + +**/ +UINT32 +EFIAPI +GluePostCode ( + IN UINT32 Value + ) +{ + REPORT_STATUS_CODE (EFI_PROGRESS_CODE, POST_CODE_TO_STATUS_CODE_VALUE (Value)); + return Value; +} + + +/** + Sends an 32-bit value to a POST and associated ASCII string. + + Sends the 32-bit value specified by Value to a POST card, and returns Value. + If Description is not NULL, then the ASCII string specified by Description is + also passed to the handler that displays the POST card value. Some + implementations of this library function may perform I/O operations directly + to a POST card device. Other implementations may send Value to ReportStatusCode(), + and the status code reporting mechanism will eventually display the 32-bit + value on the status reporting device. + + PostCodeWithDescription()must actively prevent recursion. If + PostCodeWithDescription() is called while processing another any other Report + Status Code Library function, then PostCodeWithDescription() must return Value + immediately. + + @param Value The 32-bit value to write to the POST card. + @param Description Pointer to an ASCII string that is a description of the + POST code value. This is an optional parameter that may + be NULL. + + @return Value + +**/ +UINT32 +EFIAPI +GluePostCodeWithDescription ( + IN UINT32 Value, + IN CONST CHAR8 *Description OPTIONAL + ) +{ + if (Description == NULL) { + REPORT_STATUS_CODE ( + EFI_PROGRESS_CODE, + POST_CODE_TO_STATUS_CODE_VALUE (Value) + ); + } else { + REPORT_STATUS_CODE_WITH_EXTENDED_DATA ( + EFI_PROGRESS_CODE, + POST_CODE_TO_STATUS_CODE_VALUE (Value), + Description, + AsciiStrSize (Description) + ); + } + + return Value; +} + + +/** + Returns TRUE if POST Codes are enabled. + + This function returns TRUE if the POST_CODE_PROPERTY_POST_CODE_ENABLED + bit of PcdPostCodePropertyMask is set. Otherwise FALSE is returned. + + @retval TRUE The POST_CODE_PROPERTY_POST_CODE_ENABLED bit of + PcdPostCodeProperyMask is set. + @retval FALSE The POST_CODE_PROPERTY_POST_CODE_ENABLED bit of + PcdPostCodeProperyMask is clear. + +**/ +BOOLEAN +EFIAPI +GluePostCodeEnabled ( + VOID + ) +{ + return ((PcdGet8(PcdPostCodePropertyMask) & POST_CODE_PROPERTY_POST_CODE_ENABLED) != 0); +} + + +/** + Returns TRUE if POST code descriptions are enabled. + + This function returns TRUE if the + POST_CODE_PROPERTY_POST_CODE_ENABLED bit of + PcdPostCodePropertyMask is set. Otherwise FALSE is returned. + + @retval TRUE The POST_CODE_PROPERTY_POST_CODE_ENABLED + bit of PcdPostCodeProperyMask is set. + @retval FALSE The POST_CODE_PROPERTY_POST_CODE_ENABLED + bit of PcdPostCodeProperyMask is clear. + +**/ +BOOLEAN +EFIAPI +GluePostCodeDescriptionEnabled ( + VOID + ) +{ + return ((PcdGet8(PcdPostCodePropertyMask) & POST_CODE_PROPERTY_POST_CODE_ENABLED) != 0); +} diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiFirmwarePerformanceLib/EdkIIGluePeiFirmwarePerformanceLib.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiFirmwarePerformanceLib/EdkIIGluePeiFirmwarePerformanceLib.c new file mode 100644 index 0000000..5990272 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiFirmwarePerformanceLib/EdkIIGluePeiFirmwarePerformanceLib.c @@ -0,0 +1,452 @@ +/*++ + +Copyright (c) 2011 - 2012, Intel Corporation. All rights reserved.<BR> +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: + + EdkIIGluePeiFirmwarePerformanceLib.c + +Abstract: + + PEI Library for FPDT performance logging. + +--*/ + +#include "EdkIIGluePeim.h" +#include EFI_GUID_DEFINITION (PeiPerformanceHob) + +// +// MAX perfomance HOB Entries +// +#define MAX_FIRMWARE_PERFORMANCE_ENTRIES 80 + +EFI_STATUS +PeiPerfMeasureEx ( + IN VOID *FileHeader, + IN UINT16 *Token, + IN BOOLEAN EntryExit, + IN UINT64 TimeStamp, + IN UINT16 Identifier + ) +/*++ + +Routine Description: + + Log an extended timestamp value into pre-allocated hob. + +Arguments: + + FileHeader - Pointer to the file header + + Token - Pointer to Token Name + + EntryExit - Indicates start or stop measurement + + Timestamp - The TSC value + + Identifier - Identifier of the record + +Returns: + + EFI_BUFFER_TOO_SMALL - Allocate buffer is not enough to hold new records + + EFI_SUCCESS - Successfully updated the record in hob + +--*/ +{ + EFI_STATUS Status; + EFI_PEI_PPI_DESCRIPTOR *PerfHobDescriptor; + PEI_FIRMWARE_PERFORMANCE_HOB *FirmwarePerformanceHob; + PEI_GUID_EVENT_REC *PeiGuidRec; + EFI_PEI_SERVICES **PeiServices; + UINTN BufferSize; + EFI_PEI_HOB_POINTERS Hob; + + PeiServices = GetPeiServicesTablePointer (); + // + // Locate the Pei Performance Log Hob. + // + Status = (*PeiServices)->LocatePpi ( + PeiServices, + &gPeiFirmwarePerformanceGuid, + 0, + &PerfHobDescriptor, + NULL + ); + if (EFI_ERROR (Status)) { + BufferSize = (UINT16) (sizeof (PEI_FIRMWARE_PERFORMANCE_HOB) + + ((MAX_FIRMWARE_PERFORMANCE_ENTRIES-1) * sizeof (PEI_GUID_EVENT_REC)) + + sizeof(EFI_PEI_PPI_DESCRIPTOR) + ); + + Hob.Raw = BuildGuidHob ( + &gPeiFirmwarePerformanceGuid, + BufferSize + ); + + if (Hob.Raw == NULL) { + return EFI_BUFFER_TOO_SMALL; + } + + FirmwarePerformanceHob = (VOID *) (Hob.Raw); + FirmwarePerformanceHob->NumberOfEntries = 0; + FirmwarePerformanceHob->Reserved = 0; + + PerfHobDescriptor = (EFI_PEI_PPI_DESCRIPTOR *)((UINT8 *)(FirmwarePerformanceHob+1) + + (sizeof (PEI_GUID_EVENT_REC) * + (MAX_FIRMWARE_PERFORMANCE_ENTRIES-1)) + ); + PerfHobDescriptor->Flags = (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST); + PerfHobDescriptor->Guid = &gPeiFirmwarePerformanceGuid; + PerfHobDescriptor->Ppi = NULL; + + (*PeiServices)->InstallPpi (PeiServices, PerfHobDescriptor); + ASSERT_EFI_ERROR (Status); + } + + FirmwarePerformanceHob = (PEI_FIRMWARE_PERFORMANCE_HOB *)(((UINT8 *)(PerfHobDescriptor)) - + ((sizeof (PEI_GUID_EVENT_REC) * + (MAX_FIRMWARE_PERFORMANCE_ENTRIES-1)) + + sizeof (PEI_FIRMWARE_PERFORMANCE_HOB) + ) + ); + + // + // return if pre-allocated performance hob has filled up + // + if (FirmwarePerformanceHob->NumberOfEntries >= MAX_FIRMWARE_PERFORMANCE_ENTRIES) { + return EFI_BUFFER_TOO_SMALL; + } + + PeiGuidRec = &(FirmwarePerformanceHob->GuidEventRecord[FirmwarePerformanceHob->NumberOfEntries]); + ((*PeiServices)->SetMem) (PeiGuidRec, sizeof (PEI_GUID_EVENT_REC), 0); + + // + // If not NULL pointer, copy the file name + // + if (FileHeader != NULL) { + PeiGuidRec->Guid = ((EFI_FFS_FILE_HEADER *)FileHeader)->Name; + } + // + // Record the time stamp nanosec value. + // + PeiGuidRec->Timestamp = GetTimeInNanoSec (TimeStamp); + + // + // Copy the progress ID + // + PeiGuidRec->ProgressID = Identifier; + + // + // Record the APIC Id + // + PeiGuidRec->ApicID = GetApicId (); + + // + // Increment the number of valid log entries. + // + FirmwarePerformanceHob->NumberOfEntries++; + + return EFI_SUCCESS; +} + +EFI_STATUS +PeiPerfMeasure ( + IN VOID *FileHeader, + IN UINT16 *Token, + IN BOOLEAN EntryExit, + IN UINT64 TimeStamp + ) +/*++ + +Routine Description: + + Log a timestamp value into pre-allocated buffer. + Creates performance hob if not already installed + +Arguments: + + FileHeader - Pointer to the file header + + Token - Pointer to Token Name + + EntryExit - Indicates start or stop measurement + + TimeStamp - The start time or the stop time + +Returns: + + EFI_BUFFER_TOO_SMALL - Allocate buffer is not enough to hold new records + + EFI_UNSUPPORTED - Unable to recognize used token + + EFI_SUCCESS - Successfully updated the record in hob + +--*/ +{ + EFI_STATUS Status; + PEI_FIRMWARE_PERFORMANCE_HOB *FirmwarePerformanceHob; + EFI_PEI_PPI_DESCRIPTOR *PerfHobDescriptor; + PEI_GUID_EVENT_REC *PeiGuidRec; + EFI_PEI_SERVICES **PeiServices; + UINTN BufferSize; + EFI_PEI_HOB_POINTERS Hob; + + PeiServices = GetPeiServicesTablePointer (); + // + // Locate the Pei Performance Log Hob. + // + Status = (*PeiServices)->LocatePpi ( + PeiServices, + &gPeiFirmwarePerformanceGuid, + 0, + &PerfHobDescriptor, + NULL + ); + + if (EFI_ERROR (Status)) { + + BufferSize = (UINT16) (sizeof (PEI_FIRMWARE_PERFORMANCE_HOB) + + ((MAX_FIRMWARE_PERFORMANCE_ENTRIES-1) * sizeof (PEI_GUID_EVENT_REC)) + + sizeof(EFI_PEI_PPI_DESCRIPTOR) + ); + + Hob.Raw = BuildGuidHob ( + &gPeiFirmwarePerformanceGuid, + BufferSize + ); + + if (Hob.Raw == NULL) { + return EFI_BUFFER_TOO_SMALL; + } + + FirmwarePerformanceHob = (VOID *) (Hob.Raw); + FirmwarePerformanceHob->NumberOfEntries = 0; + FirmwarePerformanceHob->Reserved = 0; + + PerfHobDescriptor = (EFI_PEI_PPI_DESCRIPTOR *)((UINT8 *)(FirmwarePerformanceHob+1) + + (sizeof (PEI_GUID_EVENT_REC) * + (MAX_FIRMWARE_PERFORMANCE_ENTRIES-1)) + ); + PerfHobDescriptor->Flags = (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST); + PerfHobDescriptor->Guid = &gPeiFirmwarePerformanceGuid; + PerfHobDescriptor->Ppi = NULL; + + (*PeiServices)->InstallPpi (PeiServices, PerfHobDescriptor); + ASSERT_EFI_ERROR (Status); + } + + FirmwarePerformanceHob = (PEI_FIRMWARE_PERFORMANCE_HOB *)(((UINT8 *)(PerfHobDescriptor)) - + ((sizeof (PEI_GUID_EVENT_REC) * + (MAX_FIRMWARE_PERFORMANCE_ENTRIES-1)) + + sizeof (PEI_FIRMWARE_PERFORMANCE_HOB)) + ); + + if (FirmwarePerformanceHob->NumberOfEntries >= MAX_FIRMWARE_PERFORMANCE_ENTRIES) { + return EFI_BUFFER_TOO_SMALL; + } + + PeiGuidRec = &(FirmwarePerformanceHob->GuidEventRecord[FirmwarePerformanceHob->NumberOfEntries]); + ((*PeiServices)->SetMem) (PeiGuidRec, sizeof (PEI_GUID_EVENT_REC), 0); + + // + // If not NULL pointer, copy the file name + // + if (FileHeader != NULL) { + PeiGuidRec->Guid = ((EFI_FFS_FILE_HEADER *)FileHeader)->Name; + } + // + // Record the time stamp nanosec value. + // + PeiGuidRec->Timestamp = GetTimeInNanoSec (TimeStamp); + + // + // Record the Progress Id + // Tokens are used by PEI core to log various phases of PEI + // + if (!StrCmp (Token, L"PEIM")) { + if (!EntryExit) { + PeiGuidRec->ProgressID = PEIM_START_ID; + } else { + PeiGuidRec->ProgressID = PEIM_END_ID; + } + } else if (!StrCmp (Token, L"PreMem")) { + if (!EntryExit) { + PeiGuidRec->ProgressID = PREMEM_START_ID; + } else { + PeiGuidRec->ProgressID = PREMEM_END_ID; + } + } else if (!StrCmp (Token, L"DisMem")) { + if (!EntryExit) { + PeiGuidRec->ProgressID = DISMEM_START_ID; + } else { + PeiGuidRec->ProgressID = DISMEM_END_ID; + } + } else if (!StrCmp (Token, L"PostMem")) { + if (!EntryExit) { + PeiGuidRec->ProgressID = POSTMEM_START_ID; + } else { + PeiGuidRec->ProgressID = POSTMEM_END_ID; + } + } else { + return EFI_UNSUPPORTED; + } + // + // Record the APIC Id + // + PeiGuidRec->ApicID = GetApicId (); + + // + // Increment the number of valid log entries. + // + FirmwarePerformanceHob->NumberOfEntries++; + + return EFI_SUCCESS; +} + +EFI_STATUS +StartMeasure ( + IN VOID *Handle, + IN UINT16 *Token, + IN UINT16 *Module, + IN UINT64 TimeStamp + ) +/*++ + +Routine Description: + + Start measurement according to token field and insert into pre-allocated buffer + +Arguments: + + Handle - Handle to measure + Token - Token to measure + Module - Module to measure + Timestamp - Ticker as start tick + +Returns: + + EFI_SUCCESS - Located hob successfully, and buffer is updated with new record + EFI_UNSUPPORTED - Failure in update + EFI_BUFFER_TOO_SMALL - Allocate buffer is not enough to hold new records + +--*/ +{ + EFI_STATUS Status; + + Status = PeiPerfMeasure (Handle, Token, FALSE, TimeStamp); + return Status; +} + +EFI_STATUS +EndMeasure ( + IN VOID *Handle, + IN UINT16 *Token, + IN UINT16 *Module, + IN UINT64 TimeStamp + ) +/*++ + +Routine Description: + + End measurement according to token field and insert into pre-allocated buffer + +Arguments: + + Handle - Handle to stop + Token - Token to stop + Module - Module to stop + Timestamp - Ticker as end tick + +Returns: + + EFI_SUCCESS - Located hob successfully, and buffer is updated with new record + EFI_UNSUPPORTED - Failure in update + EFI_BUFFER_TOO_SMALL - Allocate buffer is not enough to hold new records + +--*/ +{ + EFI_STATUS Status; + + Status = PeiPerfMeasure (Handle, Token, TRUE, TimeStamp); + return Status; +} + +EFI_STATUS +StartMeasureEx ( + IN VOID *Handle, + IN UINT16 *Token, + IN UINT16 *Module, + IN UINT64 TimeStamp, + IN UINT16 Identifier + ) +/*++ + +Routine Description: + + Start extended measurement according to token field and insert into pre-allocated buffer + +Arguments: + + Handle - Handle to stop + Token - Token to stop + Module - Module to stop + Timestamp - Ticker as end tick + Identifier - Identifier for a given record + +Returns: + + EFI_SUCCESS - Located hob successfully, and buffer is updated with new record + EFI_UNSUPPORTED - Failure in update + EFI_BUFFER_TOO_SMALL - Allocate buffer is not enough to hold new records + +--*/ +{ + EFI_STATUS Status; + + Status = PeiPerfMeasureEx (Handle, Token, FALSE, TimeStamp, Identifier); + return Status; +} + +EFI_STATUS +EndMeasureEx ( + IN VOID *Handle, + IN UINT16 *Token, + IN UINT16 *Module, + IN UINT64 TimeStamp, + IN UINT16 Identifier + ) +/*++ + +Routine Description: + + End extended measurement according to token field and insert into pre-allocated buffer + +Arguments: + + Handle - Handle to stop + Token - Token to stop + Module - Module to stop + Timestamp - Ticker as end tick + Identifier - Identifier for a given record + +Returns: + + EFI_SUCCESS - Located hob successfully, and buffer is updated with new record + EFI_UNSUPPORTED - Failure in update + EFI_BUFFER_TOO_SMALL - Allocate buffer is not enough to hold new records + +--*/ +{ + EFI_STATUS Status; + + Status = PeiPerfMeasureEx (Handle, Token, TRUE, TimeStamp, Identifier); + return Status; +}
\ No newline at end of file diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiFirmwarePerformanceLib/EdkIIGluePeiFirmwarePerformanceLib.cif b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiFirmwarePerformanceLib/EdkIIGluePeiFirmwarePerformanceLib.cif new file mode 100644 index 0000000..ccfaff0 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiFirmwarePerformanceLib/EdkIIGluePeiFirmwarePerformanceLib.cif @@ -0,0 +1,11 @@ +<component> + name = "EdkIIGluePeiFirmwarePerformanceLib" + category = ModulePart + LocalRoot = "EDK\Foundation\Library\EdkIIGlueLib\Library\PeiFirmwarePerformanceLib\" + RefName = "EdkIIGluePeiFirmwarePerformanceLib" +[files] +"EdkIIGluePeiFirmwarePerformanceLib.sdl" +"EdkIIGluePeiFirmwarePerformanceLib.mak" +"EdkIIGluePeiFirmwarePerformanceLib.inf" +"EdkIIGluePeiFirmwarePerformanceLib.c" +<endComponent>
\ No newline at end of file diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiFirmwarePerformanceLib/EdkIIGluePeiFirmwarePerformanceLib.inf b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiFirmwarePerformanceLib/EdkIIGluePeiFirmwarePerformanceLib.inf new file mode 100644 index 0000000..d692147 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiFirmwarePerformanceLib/EdkIIGluePeiFirmwarePerformanceLib.inf @@ -0,0 +1,77 @@ +#/*++ +# +# Copyright (c) 2011, Intel Corporation. All rights reserved.<BR> +# 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: +# +# EdkIIGluePeiFirmwarePerformanceLib.inf +# +# Abstract: +# +# Component description file for PeiFirmwarePerformanceLib +# +#--*/ + +[defines] +BASE_NAME = EdkIIGluePeiFirmwarePerformanceLib +COMPONENT_TYPE = LIBRARY + +[sources.common] + EdkIIGluePeiFirmwarePerformanceLib.c + +[sources.ia32] + + +[sources.x64] + + +[sources.ipf] + + +[sources.ebc] + + +[includes.common] + . + ..\..\Include + ..\..\include\Library + $(EDK_SOURCE)\Foundation + $(EDK_SOURCE)\Foundation\Include\Pei + $(EDK_SOURCE)\Foundation\Framework + $(EDK_SOURCE)\Foundation\Efi + $(EDK_SOURCE)\Foundation\Include + $(EDK_SOURCE)\Foundation\Efi\Include + $(EDK_SOURCE)\Foundation\Framework\Include + $(EDK_SOURCE)\Foundation\Library\Dxe\Include + +[libraries.common] + EdkIIGlueBaseTimerLibLocalApic + EdkIIGlueBaseTimerLibTsc + EdkIIGluePeiHobLib + +[libraries.ia32] + +[libraries.x64] + +[nmake.common] + C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION + LIB_STD_FLAGS = /NOLOGO /IGNORE:4006 /IGNORE:4221 + +[nmake.ia32] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32 + +[nmake.x64] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64 + +[nmake.ipf] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF + +[nmake.ebc] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_EBC
\ No newline at end of file diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiFirmwarePerformanceLib/EdkIIGluePeiFirmwarePerformanceLib.mak b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiFirmwarePerformanceLib/EdkIIGluePeiFirmwarePerformanceLib.mak new file mode 100644 index 0000000..99a1d78 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiFirmwarePerformanceLib/EdkIIGluePeiFirmwarePerformanceLib.mak @@ -0,0 +1,74 @@ +#********************************************************************** +#********************************************************************** +#** ** +#** (C)Copyright 1985-2011, American Megatrends, Inc. ** +#** ** +#** All Rights Reserved. ** +#** ** +#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +#** ** +#** Phone: (770)-246-8600 ** +#** ** +#********************************************************************** +#********************************************************************** + +#********************************************************************** +# $Header: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGluePeiFirmwarePerformanceLib/EdkIIGluePeiFirmwarePerformanceLib.mak 1 1/20/12 3:58a Jeffch $ +# +# $Revision: 1 $ +# +# $Date: 1/20/12 3:58a $ +#********************************************************************** +# Revision History +# ---------------- +# $Log: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGluePeiFirmwarePerformanceLib/EdkIIGluePeiFirmwarePerformanceLib.mak $ +# +# 1 1/20/12 3:58a Jeffch +# Create Intel EDK 1117 Patch 7. +# +# 1 11/17/11 9:31p Wesleychen +# EdkIIGluePeiFirmwarePerformanceLib +# +#********************************************************************** +#<AMI_FHDR_START> +# +# Name: EdkIIGluePeiFirmwarePerformanceLib.mak +# +# Description: +# +#<AMI_FHDR_END> +#********************************************************************** +$(EdkIIGluePeiFirmwarePerformanceLib_LIB) : EdkIIGluePeiFirmwarePerformanceLib + +EdkIIGluePeiFirmwarePerformanceLib : $(BUILD_DIR)\EdkIIGluePeiFirmwarePerformanceLib.mak EdkIIGluePeiFirmwarePerformanceLibBin + +$(BUILD_DIR)\EdkIIGluePeiFirmwarePerformanceLib.mak : $(EdkIIGluePeiFirmwarePerformanceLib_DIR)\$(@B).cif $(EdkIIGluePeiFirmwarePerformanceLib_DIR)\$(@B).mak $(BUILD_RULES) + $(CIF2MAK) $(EdkIIGluePeiFirmwarePerformanceLib_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS) + +EdkIIGluePeiFirmwarePerformanceLibBin : $(CPUIA32LIB) + +EdkIIGluePeiFirmwarePerformanceLibBin : $(EdkIIGlueBaseTimerLibLocalApic_LIB) $(EdkIIGlueBaseTimerLibTsc_LIB) $(EdkIIGluePeiHobLib_LIB) $(EDKGUIDLIB) $(ARCHPROTOCOLLIB) +!IF "$(x64_BUILD)"=="1" + $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\ + BUILD_DIR=$(BUILD_DIR)\IA32\ + /f $(BUILD_DIR)\EdkIIGluePeiFirmwarePerformanceLib.mak all\ + TYPE=PEI_LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGluePeiFirmwarePerformanceLib_LIB)" +!ELSE + $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\ + BUILD_DIR=$(BUILD_DIR)\ + /f $(BUILD_DIR)\EdkIIGluePeiFirmwarePerformanceLib.mak all\ + TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGluePeiFirmwarePerformanceLib_LIB)" +!ENDIF +#********************************************************************** +#********************************************************************** +#** ** +#** (C)Copyright 1985-2011, American Megatrends, Inc. ** +#** ** +#** All Rights Reserved. ** +#** ** +#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +#** ** +#** Phone: (770)-246-8600 ** +#** ** +#********************************************************************** +#********************************************************************** diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiFirmwarePerformanceLib/EdkIIGluePeiFirmwarePerformanceLib.sdl b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiFirmwarePerformanceLib/EdkIIGluePeiFirmwarePerformanceLib.sdl new file mode 100644 index 0000000..1ba2d0b --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiFirmwarePerformanceLib/EdkIIGluePeiFirmwarePerformanceLib.sdl @@ -0,0 +1,24 @@ +TOKEN + Name = EdkIIGluePeiFirmwarePerformanceLib_SUPPORT + Value = 1 + TokenType = Boolean + TargetEQU = Yes + TargetMAK = Yes + Master = Yes +End + +TOKEN + Name = "EdkIIGluePeiFirmwarePerformanceLib_LIB" + Value = "$$(LIB_BUILD_DIR)\EdkIIGluePeiFirmwarePerformanceLib.lib" + TokenType = Expression + TargetMAK = Yes +End + +PATH + Name = "EdkIIGluePeiFirmwarePerformanceLib_DIR" +End + +MODULE + Help = "Includes EdkIIGluePeiFirmwarePerformanceLib.mak to Project" + File = "EdkIIGluePeiFirmwarePerformanceLib.mak" +End
\ No newline at end of file diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiHobLib/EdkIIGluePeiHobLib.cif b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiHobLib/EdkIIGluePeiHobLib.cif new file mode 100644 index 0000000..38bd79c --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiHobLib/EdkIIGluePeiHobLib.cif @@ -0,0 +1,11 @@ +<component> + name = "EdkIIGluePeiHobLib" + category = ModulePart + LocalRoot = "Edk\Foundation\Library\EdkIIGlueLib\Library\PeiHobLib" + RefName = "EdkIIGluePeiHobLib" +[files] +"EdkIIGluePeiHobLib.sdl" +"EdkIIGluePeiHobLib.mak" +"PeiHobLib.inf" +"HobLib.c" +<endComponent> diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiHobLib/EdkIIGluePeiHobLib.mak b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiHobLib/EdkIIGluePeiHobLib.mak new file mode 100644 index 0000000..9b3f50b --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiHobLib/EdkIIGluePeiHobLib.mak @@ -0,0 +1,80 @@ +#********************************************************************** +#********************************************************************** +#** ** +#** (C)Copyright 1985-2009, American Megatrends, Inc. ** +#** ** +#** All Rights Reserved. ** +#** ** +#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +#** ** +#** Phone: (770)-246-8600 ** +#** ** +#********************************************************************** +#********************************************************************** + +#********************************************************************** +# $Header: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGluePeiHobLib/EdkIIGluePeiHobLib.mak 1 1/20/12 3:56a Jeffch $ +# +# $Revision: 1 $ +# +# $Date: 1/20/12 3:56a $ +#********************************************************************** +# Revision History +# ---------------- +# $Log: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGluePeiHobLib/EdkIIGluePeiHobLib.mak $ +# +# 1 1/20/12 3:56a Jeffch +# Create Intel EDK 1117 Patch 7. +# +# 1 9/27/11 6:18a Wesleychen +# Intel EDK initially releases. +# +# 1 9/18/09 1:56a Iminglin +# +#********************************************************************** +#<AMI_FHDR_START> +# +# Name: EdkIIGluePeiHobLib.mak +# +# Description: +# +#<AMI_FHDR_END> +#********************************************************************** + + +$(EdkIIGluePeiHobLib_LIB) : EdkIIGluePeiHobLib + +EdkIIGluePeiHobLib : $(BUILD_DIR)\EdkIIGluePeiHobLib.mak EdkIIGluePeiHobLibBin + +$(BUILD_DIR)\EdkIIGluePeiHobLib.mak : $(EdkIIGluePeiHobLib_DIR)\$(@B).cif $(EdkIIGluePeiHobLib_DIR)\$(@B).mak $(BUILD_RULES) + $(CIF2MAK) $(EdkIIGluePeiHobLib_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS) + +EdkIIGluePeiHobLibBin : $(EdkIIGlueBaseMemoryLib_LIB) $(EdkIIGluePeiServicesLib_LIB) +!IF "$(x64_BUILD)"=="1" + $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\ + BUILD_DIR=$(BUILD_DIR)\ + /f $(BUILD_DIR)\EdkIIGluePeiHobLib.mak all\ + TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGluePeiHobLib_LIB)" + $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\ + BUILD_DIR=$(BUILD_DIR)\IA32\ + /f $(BUILD_DIR)\EdkIIGluePeiHobLib.mak all\ + TYPE=PEI_LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGluePeiHobLib_LIB)" +!ELSE + $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\ + BUILD_DIR=$(BUILD_DIR)\ + /f $(BUILD_DIR)\EdkIIGluePeiHobLib.mak all\ + TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGluePeiHobLib_LIB)" +!ENDIF +#********************************************************************** +#********************************************************************** +#** ** +#** (C)Copyright 1985-2009, American Megatrends, Inc. ** +#** ** +#** All Rights Reserved. ** +#** ** +#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +#** ** +#** Phone: (770)-246-8600 ** +#** ** +#********************************************************************** +#********************************************************************** diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiHobLib/EdkIIGluePeiHobLib.sdl b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiHobLib/EdkIIGluePeiHobLib.sdl new file mode 100644 index 0000000..50a1dfd --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiHobLib/EdkIIGluePeiHobLib.sdl @@ -0,0 +1,26 @@ +TOKEN + Name = "EdkIIGluePeiHobLib_SUPPORT" + Value = "1" + Help = "Main switch to enable EdkIIGluePeiHobLib support in Project" + TokenType = Boolean + TargetEQU = Yes + TargetMAK = Yes + Master = Yes +End + +TOKEN + Name = "EdkIIGluePeiHobLib_LIB" + Value = "$$(LIB_BUILD_DIR)\EdkIIGluePeiHobLib.lib" + TokenType = Expression + TargetMAK = Yes +End + +PATH + Name = "EdkIIGluePeiHobLib_DIR" +End + +MODULE + Help = "Includes EdkIIGluePeiHobLib.mak to Project" + File = "EdkIIGluePeiHobLib.mak" +End + diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiHobLib/HobLib.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiHobLib/HobLib.c new file mode 100644 index 0000000..cff5f91 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiHobLib/HobLib.c @@ -0,0 +1,573 @@ +/*++ + +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: + + HobLib.c + +Abstract: + + HOB Library. + +--*/ + +#include "EdkIIGluePeim.h" + +/** + Returns the pointer to the HOB list. + + This function returns the pointer to first HOB in the list. + + @return The pointer to the HOB list. + +**/ +VOID * +EFIAPI +GetHobList ( + VOID + ) +{ + EFI_STATUS Status; + VOID *HobList; + + Status = PeiServicesGetHobList (&HobList); + ASSERT_EFI_ERROR (Status); + ASSERT (HobList != NULL); + + return HobList; +} + +/** + Returns the next instance of a HOB type from the starting HOB. + + This function searches the first instance of a HOB type from the starting HOB pointer. + If there does not exist such HOB type from the starting HOB pointer, it will return NULL. + In contrast with macro GET_NEXT_HOB(), this function does not skip the starting HOB pointer + unconditionally: it returns HobStart back if HobStart itself meets the requirement; + caller is required to use GET_NEXT_HOB() if it wishes to skip current HobStart. + If HobStart is NULL, then ASSERT(). + + @param Type The HOB type to return. + @param HobStart The starting HOB pointer to search from. + + @return The next instance of a HOB type from the starting HOB. + +**/ +VOID * +EFIAPI +GetNextHob ( + IN UINT16 Type, + IN CONST VOID *HobStart + ) +{ + EFI_PEI_HOB_POINTERS Hob; + + ASSERT (HobStart != NULL); + + Hob.Raw = (UINT8 *) HobStart; + // + // Parse the HOB list until end of list or matching type is found. + // + while (!END_OF_HOB_LIST (Hob)) { + if (Hob.Header->HobType == Type) { + return Hob.Raw; + } + Hob.Raw = GET_NEXT_HOB (Hob); + } + return NULL; +} + +/** + Returns the first instance of a HOB type among the whole HOB list. + + This function searches the first instance of a HOB type among the whole HOB list. + If there does not exist such HOB type in the HOB list, it will return NULL. + + @param Type The HOB type to return. + + @return The next instance of a HOB type from the starting HOB. + +**/ +VOID * +EFIAPI +GetFirstHob ( + IN UINT16 Type + ) +{ + VOID *HobList; + + HobList = GetHobList (); + return GetNextHob (Type, HobList); +} + +/** + This function searches the first instance of a HOB from the starting HOB pointer. + Such HOB should satisfy two conditions: + its HOB type is EFI_HOB_TYPE_GUID_EXTENSION and its GUID Name equals to the input Guid. + If there does not exist such HOB from the starting HOB pointer, it will return NULL. + Caller is required to apply GET_GUID_HOB_DATA () and GET_GUID_HOB_DATA_SIZE () + to extract the data section and its size info respectively. + In contrast with macro GET_NEXT_HOB(), this function does not skip the starting HOB pointer + unconditionally: it returns HobStart back if HobStart itself meets the requirement; + caller is required to use GET_NEXT_HOB() if it wishes to skip current HobStart. + If Guid is NULL, then ASSERT(). + If HobStart is NULL, then ASSERT(). + + @param Guid The GUID to match with in the HOB list. + @param HobStart A pointer to a Guid. + + @return The next instance of the matched GUID HOB from the starting HOB. + +**/ +VOID * +EFIAPI +GlueGetNextGuidHob ( + IN CONST EFI_GUID *Guid, + IN CONST VOID *HobStart + ) +{ + EFI_PEI_HOB_POINTERS GuidHob; + + GuidHob.Raw = (UINT8 *) HobStart; + while ((GuidHob.Raw = GetNextHob (EFI_HOB_TYPE_GUID_EXTENSION, GuidHob.Raw)) != NULL) { + if (CompareGuid (Guid, &GuidHob.Guid->Name)) { + break; + } + GuidHob.Raw = GET_NEXT_HOB (GuidHob); + } + return GuidHob.Raw; +} + +/** + This function searches the first instance of a HOB among the whole HOB list. + Such HOB should satisfy two conditions: + its HOB type is EFI_HOB_TYPE_GUID_EXTENSION and its GUID Name equals to the input Guid. + If there does not exist such HOB from the starting HOB pointer, it will return NULL. + Caller is required to apply GET_GUID_HOB_DATA () and GET_GUID_HOB_DATA_SIZE () + to extract the data section and its size info respectively. + If Guid is NULL, then ASSERT(). + + @param Guid The GUID to match with in the HOB list. + + @return The first instance of the matched GUID HOB among the whole HOB list. + +**/ +VOID * +EFIAPI +GlueGetFirstGuidHob ( + IN CONST EFI_GUID *Guid + ) +{ + VOID *HobList; + + HobList = GetHobList (); + return GetNextGuidHob (Guid, HobList); +} + +/** + Get the Boot Mode from the HOB list. + + This function returns the system boot mode information from the + PHIT HOB in HOB list. + + @param VOID + + @return The Boot Mode. + +**/ +EFI_BOOT_MODE +EFIAPI +GetBootModeHob ( + VOID + ) +{ + EFI_STATUS Status; + EFI_BOOT_MODE BootMode; + + Status = PeiServicesGetBootMode (&BootMode); + ASSERT_EFI_ERROR (Status); + + return BootMode; +} + +/** + Adds a new HOB to the HOB List. + + This internal function enables PEIMs to create various types of HOBs. + + @param Type Type of the new HOB. + @param Length Length of the new HOB to allocate. + + @return The address of new HOB. + +**/ +STATIC +VOID * +InternalPeiCreateHob ( + IN UINT16 Type, + IN UINT16 Length + ) +{ + EFI_STATUS Status; + VOID *Hob; + + Status = PeiServicesCreateHob (Type, Length, &Hob); + // + // Assume the process of HOB building is always successful. + // + ASSERT_EFI_ERROR (Status); + return Hob; +} + +/** + Builds a HOB for a loaded PE32 module. + + This function builds a HOB for a loaded PE32 module. + It can only be invoked during PEI phase; + for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase. + If ModuleName is NULL, then ASSERT(). + If there is no additional space for HOB creation, then ASSERT(). + + @param ModuleName The GUID File Name of the module. + @param MemoryAllocationModule The 64 bit physical address of the module. + @param ModuleLength The length of the module in bytes. + @param EntryPoint The 64 bit physical address of the module's entry point. + +**/ +VOID +EFIAPI +GlueBuildModuleHob ( + IN CONST EFI_GUID *ModuleName, + IN EFI_PHYSICAL_ADDRESS MemoryAllocationModule, + IN UINT64 ModuleLength, + IN EFI_PHYSICAL_ADDRESS EntryPoint + ) +{ + EFI_HOB_MEMORY_ALLOCATION_MODULE *Hob; + + Hob = InternalPeiCreateHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, sizeof (EFI_HOB_MEMORY_ALLOCATION_MODULE)); + + CopyGuid (&(Hob->MemoryAllocationHeader.Name), &gEfiHobMemoryAllocModuleGuid); + Hob->MemoryAllocationHeader.MemoryBaseAddress = MemoryAllocationModule; + Hob->MemoryAllocationHeader.MemoryLength = ModuleLength; + Hob->MemoryAllocationHeader.MemoryType = EfiBootServicesCode; + + // + // Zero the reserved space to match HOB spec + // + ZeroMem (Hob->MemoryAllocationHeader.Reserved, sizeof (Hob->MemoryAllocationHeader.Reserved)); + + CopyGuid (&Hob->ModuleName, ModuleName); + Hob->EntryPoint = EntryPoint; +} + +/** + Builds a HOB that describes a chunk of system memory. + + This function builds a HOB that describes a chunk of system memory. + It can only be invoked during PEI phase; + for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase. + If there is no additional space for HOB creation, then ASSERT(). + + @param ResourceType The type of resource described by this HOB. + @param ResourceAttribute The resource attributes of the memory described by this HOB. + @param PhysicalStart The 64 bit physical address of memory described by this HOB. + @param NumberOfBytes The length of the memory described by this HOB in bytes. + +**/ +VOID +EFIAPI +BuildResourceDescriptorHob ( + IN EFI_RESOURCE_TYPE ResourceType, + IN EFI_RESOURCE_ATTRIBUTE_TYPE ResourceAttribute, + IN EFI_PHYSICAL_ADDRESS PhysicalStart, + IN UINT64 NumberOfBytes + ) +{ + EFI_HOB_RESOURCE_DESCRIPTOR *Hob; + + Hob = InternalPeiCreateHob (EFI_HOB_TYPE_RESOURCE_DESCRIPTOR, sizeof (EFI_HOB_RESOURCE_DESCRIPTOR)); + + Hob->ResourceType = ResourceType; + Hob->ResourceAttribute = ResourceAttribute; + Hob->PhysicalStart = PhysicalStart; + Hob->ResourceLength = NumberOfBytes; +} + +/** + Builds a GUID HOB with a certain data length. + + This function builds a customized HOB tagged with a GUID for identification + and returns the start address of GUID HOB data so that caller can fill the customized data. + The HOB Header and Name field is already stripped. + It can only be invoked during PEI phase; + for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase. + If Guid is NULL, then ASSERT(). + If there is no additional space for HOB creation, then ASSERT(). + If DataLength >= (0x10000 - sizeof (EFI_HOB_GUID_TYPE)), then ASSERT(). + + @param Guid The GUID to tag the customized HOB. + @param DataLength The size of the data payload for the GUID HOB. + + @return The start address of GUID HOB data. + +**/ +VOID * +EFIAPI +BuildGuidHob ( + IN CONST EFI_GUID *Guid, + IN UINTN DataLength + ) +{ + EFI_HOB_GUID_TYPE *Hob; + + // + // Make sure that data length is not too long. + // + ASSERT (DataLength <= (0xffff - sizeof (EFI_HOB_GUID_TYPE))); + + Hob = InternalPeiCreateHob (EFI_HOB_TYPE_GUID_EXTENSION, (UINT16) (sizeof (EFI_HOB_GUID_TYPE) + DataLength)); + CopyGuid (&Hob->Name, Guid); + return Hob + 1; +} + +/** + Copies a data buffer to a newly-built HOB. + + This function builds a customized HOB tagged with a GUID for identification, + copies the input data to the HOB data field and returns the start address of the GUID HOB data. + The HOB Header and Name field is already stripped. + It can only be invoked during PEI phase; + for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase. + If Guid is NULL, then ASSERT(). + If Data is NULL and DataLength > 0, then ASSERT(). + If there is no additional space for HOB creation, then ASSERT(). + If DataLength >= (0x10000 - sizeof (EFI_HOB_GUID_TYPE)), then ASSERT(). + + @param Guid The GUID to tag the customized HOB. + @param Data The data to be copied into the data field of the GUID HOB. + @param DataLength The size of the data payload for the GUID HOB. + + @return The start address of GUID HOB data. + +**/ +VOID * +EFIAPI +BuildGuidDataHob ( + IN CONST EFI_GUID *Guid, + IN VOID *Data, + IN UINTN DataLength + ) +{ + VOID *HobData; + + ASSERT (Data != NULL || DataLength == 0); + + HobData = BuildGuidHob (Guid, DataLength); + + return CopyMem (HobData, Data, DataLength); +} + +/** + Builds a Firmware Volume HOB. + + This function builds a Firmware Volume HOB. + It can only be invoked during PEI phase; + for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase. + If there is no additional space for HOB creation, then ASSERT(). + + @param BaseAddress The base address of the Firmware Volume. + @param Length The size of the Firmware Volume in bytes. + +**/ +VOID +EFIAPI +BuildFvHob ( + IN EFI_PHYSICAL_ADDRESS BaseAddress, + IN UINT64 Length + ) +{ + EFI_HOB_FIRMWARE_VOLUME *Hob; + + // + // Check FV Signature + // + ASSERT (((EFI_FIRMWARE_VOLUME_HEADER*)((UINTN)BaseAddress))->Signature == EFI_FVH_SIGNATURE); + Hob = InternalPeiCreateHob (EFI_HOB_TYPE_FV, sizeof (EFI_HOB_FIRMWARE_VOLUME)); + + Hob->BaseAddress = BaseAddress; + Hob->Length = Length; +} + +/** + Builds a Capsule Volume HOB. + + This function builds a Capsule Volume HOB. + It can only be invoked during PEI phase; + for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase. + If there is no additional space for HOB creation, then ASSERT(). + + @param BaseAddress The base address of the Capsule Volume. + @param Length The size of the Capsule Volume in bytes. + +**/ +VOID +EFIAPI +BuildCvHob ( + IN EFI_PHYSICAL_ADDRESS BaseAddress, + IN UINT64 Length + ) +{ + EFI_HOB_CAPSULE_VOLUME *Hob; + + Hob = InternalPeiCreateHob (EFI_HOB_TYPE_CV, sizeof (EFI_HOB_CAPSULE_VOLUME)); + + Hob->BaseAddress = BaseAddress; + Hob->Length = Length; +} + +/** + Builds a HOB for the CPU. + + This function builds a HOB for the CPU. + It can only be invoked during PEI phase; + for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase. + If there is no additional space for HOB creation, then ASSERT(). + + @param SizeOfMemorySpace The maximum physical memory addressability of the processor. + @param SizeOfIoSpace The maximum physical I/O addressability of the processor. + +**/ +VOID +EFIAPI +BuildCpuHob ( + IN UINT8 SizeOfMemorySpace, + IN UINT8 SizeOfIoSpace + ) +{ + EFI_HOB_CPU *Hob; + + Hob = InternalPeiCreateHob (EFI_HOB_TYPE_CPU, sizeof (EFI_HOB_CPU)); + + Hob->SizeOfMemorySpace = SizeOfMemorySpace; + Hob->SizeOfIoSpace = SizeOfIoSpace; + + // + // Zero the reserved space to match HOB spec + // + ZeroMem (Hob->Reserved, sizeof (Hob->Reserved)); +} + +/** + Builds a HOB for the Stack. + + This function builds a HOB for the stack. + It can only be invoked during PEI phase; + for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase. + If there is no additional space for HOB creation, then ASSERT(). + + @param BaseAddress The 64 bit physical address of the Stack. + @param Length The length of the stack in bytes. + +**/ +VOID +EFIAPI +BuildStackHob ( + IN EFI_PHYSICAL_ADDRESS BaseAddress, + IN UINT64 Length + ) +{ + EFI_HOB_MEMORY_ALLOCATION_STACK *Hob; + + Hob = InternalPeiCreateHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, sizeof (EFI_HOB_MEMORY_ALLOCATION_STACK)); + + CopyGuid (&(Hob->AllocDescriptor.Name), &gEfiHobMemoryAllocStackGuid); + Hob->AllocDescriptor.MemoryBaseAddress = BaseAddress; + Hob->AllocDescriptor.MemoryLength = Length; + Hob->AllocDescriptor.MemoryType = EfiBootServicesData; + + // + // Zero the reserved space to match HOB spec + // + ZeroMem (Hob->AllocDescriptor.Reserved, sizeof (Hob->AllocDescriptor.Reserved)); +} + +/** + Builds a HOB for the BSP store. + + This function builds a HOB for BSP store. + It can only be invoked during PEI phase; + for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase. + If there is no additional space for HOB creation, then ASSERT(). + + @param BaseAddress The 64 bit physical address of the BSP. + @param Length The length of the BSP store in bytes. + @param MemoryType Type of memory allocated by this HOB. + +**/ +VOID +EFIAPI +BuildBspStoreHob ( + IN EFI_PHYSICAL_ADDRESS BaseAddress, + IN UINT64 Length, + IN EFI_MEMORY_TYPE MemoryType + ) +{ + EFI_HOB_MEMORY_ALLOCATION_BSP_STORE *Hob; + + Hob = InternalPeiCreateHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, sizeof (EFI_HOB_MEMORY_ALLOCATION_BSP_STORE)); + + CopyGuid (&(Hob->AllocDescriptor.Name), &gEfiHobMemoryAllocBspStoreGuid); + Hob->AllocDescriptor.MemoryBaseAddress = BaseAddress; + Hob->AllocDescriptor.MemoryLength = Length; + Hob->AllocDescriptor.MemoryType = MemoryType; + + // + // Zero the reserved space to match HOB spec + // + ZeroMem (Hob->AllocDescriptor.Reserved, sizeof (Hob->AllocDescriptor.Reserved)); +} + +/** + Builds a HOB for the memory allocation. + + This function builds a HOB for the memory allocation. + It can only be invoked during PEI phase; + for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase. + If there is no additional space for HOB creation, then ASSERT(). + + @param BaseAddress The 64 bit physical address of the memory. + @param Length The length of the memory allocation in bytes. + @param MemoryType Type of memory allocated by this HOB. + +**/ +VOID +EFIAPI +GlueBuildMemoryAllocationHob ( + IN EFI_PHYSICAL_ADDRESS BaseAddress, + IN UINT64 Length, + IN EFI_MEMORY_TYPE MemoryType + ) +{ + EFI_HOB_MEMORY_ALLOCATION *Hob; + + Hob = InternalPeiCreateHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, sizeof (EFI_HOB_MEMORY_ALLOCATION)); + + ZeroMem (&(Hob->AllocDescriptor.Name), sizeof (EFI_GUID)); + Hob->AllocDescriptor.MemoryBaseAddress = BaseAddress; + Hob->AllocDescriptor.MemoryLength = Length; + Hob->AllocDescriptor.MemoryType = MemoryType; + // + // Zero the reserved space to match HOB spec + // + ZeroMem (Hob->AllocDescriptor.Reserved, sizeof (Hob->AllocDescriptor.Reserved)); +} diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiHobLib/PeiHobLib.inf b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiHobLib/PeiHobLib.inf new file mode 100644 index 0000000..27cfdc0 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiHobLib/PeiHobLib.inf @@ -0,0 +1,81 @@ +#/*++ +# +# 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: +# +# PeiHobLib.inf +# +# Abstract: +# +# Component description file for PeiHobLib. +# +#--*/ + +[defines] +BASE_NAME = EdkIIGluePeiHobLib +COMPONENT_TYPE = LIBRARY + +[sources.common] + HobLib.c + +[sources.ia32] + +[sources.x64] + +[sources.ipf] + +[sources.ebc] + + +[includes.common] + . + ..\..\Include + ..\..\include\Library + $(EDK_SOURCE)\Foundation + $(EDK_SOURCE)\Foundation\Library\Pei\Include + $(EDK_SOURCE)\Foundation\Framework + $(EDK_SOURCE)\Foundation\Include\Pei + $(EDK_SOURCE)\Foundation\Efi + $(EDK_SOURCE)\Foundation\Include + $(EDK_SOURCE)\Foundation\Include\Pei + $(EDK_SOURCE)\Foundation\Efi\Include + $(EDK_SOURCE)\Foundation\Framework\Include + $(EDK_SOURCE)\Foundation\Include\IndustryStandard + $(EDK_SOURCE)\Foundation\Core\Dxe + $(EDK_SOURCE)\Foundation\Library\Pei\Include + $(EDK_SOURCE)\Foundation\Library\Dxe\Include + $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include + +[libraries.common] + EdkIIGlueBaseMemoryLib + EdkIIGluePeiServicesLib + +[libraries.ia32] + + +[libraries.x64] + + +[nmake.common] + C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION + LIB_STD_FLAGS = /NOLOGO /IGNORE:4006 + +[nmake.ia32] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32 + +[nmake.x64] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64 + +[nmake.ipf] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF + +[nmake.ebc] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_EBC
\ No newline at end of file diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiMemoryAllocationLib/EdkIIGluePeiMemoryAllocationLib.cif b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiMemoryAllocationLib/EdkIIGluePeiMemoryAllocationLib.cif new file mode 100644 index 0000000..cb5fddf --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiMemoryAllocationLib/EdkIIGluePeiMemoryAllocationLib.cif @@ -0,0 +1,11 @@ +<component> + name = "EdkIIGluePeiMemoryAllocationLib" + category = ModulePart + LocalRoot = "Edk\Foundation\Library\EdkIIGlueLib\Library\PeiMemoryAllocationLib" + RefName = "EdkIIGluePeiMemoryAllocationLib" +[files] +"EdkIIGluePeiMemoryAllocationLib.sdl" +"EdkIIGluePeiMemoryAllocationLib.mak" +"PeiMemoryAllocationLib.inf" +"MemoryAllocationLib.c" +<endComponent> diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiMemoryAllocationLib/EdkIIGluePeiMemoryAllocationLib.mak b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiMemoryAllocationLib/EdkIIGluePeiMemoryAllocationLib.mak new file mode 100644 index 0000000..9d15d3a --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiMemoryAllocationLib/EdkIIGluePeiMemoryAllocationLib.mak @@ -0,0 +1,80 @@ +#********************************************************************** +#********************************************************************** +#** ** +#** (C)Copyright 1985-2009, American Megatrends, Inc. ** +#** ** +#** All Rights Reserved. ** +#** ** +#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +#** ** +#** Phone: (770)-246-8600 ** +#** ** +#********************************************************************** +#********************************************************************** + +#********************************************************************** +# $Header: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGluePeiMemoryAllocationLib/EdkIIGluePeiMemoryAllocationLib.mak 1 1/20/12 3:56a Jeffch $ +# +# $Revision: 1 $ +# +# $Date: 1/20/12 3:56a $ +#********************************************************************** +# Revision History +# ---------------- +# $Log: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGluePeiMemoryAllocationLib/EdkIIGluePeiMemoryAllocationLib.mak $ +# +# 1 1/20/12 3:56a Jeffch +# Create Intel EDK 1117 Patch 7. +# +# 1 9/27/11 6:19a Wesleychen +# Intel EDK initially releases. +# +# 1 9/18/09 1:57a Iminglin +# +#********************************************************************** +#<AMI_FHDR_START> +# +# Name: EdkIIGluePeiMemoryAllocationLib.mak +# +# Description: +# +#<AMI_FHDR_END> +#********************************************************************** + + +$(EdkIIGluePeiMemoryAllocationLib_LIB) : EdkIIGluePeiMemoryAllocationLib + +EdkIIGluePeiMemoryAllocationLib : $(BUILD_DIR)\EdkIIGluePeiMemoryAllocationLib.mak EdkIIGluePeiMemoryAllocationLibBin + +$(BUILD_DIR)\EdkIIGluePeiMemoryAllocationLib.mak : $(EdkIIGluePeiMemoryAllocationLib_DIR)\$(@B).cif $(EdkIIGluePeiMemoryAllocationLib_DIR)\$(@B).mak $(BUILD_RULES) + $(CIF2MAK) $(EdkIIGluePeiMemoryAllocationLib_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS) + +EdkIIGluePeiMemoryAllocationLibBin : $(EdkIIGlueBaseMemoryLib_LIB) $(EdkIIGluePeiServicesTablePointerLibMm7_LIB) +!IF "$(x64_BUILD)"=="1" + $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\ + BUILD_DIR=$(BUILD_DIR)\ + /f $(BUILD_DIR)\EdkIIGluePeiMemoryAllocationLib.mak all\ + TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGluePeiMemoryAllocationLib_LIB)" + $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\ + BUILD_DIR=$(BUILD_DIR)\IA32\ + /f $(BUILD_DIR)\EdkIIGluePeiMemoryAllocationLib.mak all\ + TYPE=PEI_LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGluePeiMemoryAllocationLib_LIB)" +!ELSE + $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\ + BUILD_DIR=$(BUILD_DIR)\ + /f $(BUILD_DIR)\EdkIIGluePeiMemoryAllocationLib.mak all\ + TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGluePeiMemoryAllocationLib_LIB)" +!ENDIF +#********************************************************************** +#********************************************************************** +#** ** +#** (C)Copyright 1985-2009, American Megatrends, Inc. ** +#** ** +#** All Rights Reserved. ** +#** ** +#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +#** ** +#** Phone: (770)-246-8600 ** +#** ** +#********************************************************************** +#**********************************************************************
\ No newline at end of file diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiMemoryAllocationLib/EdkIIGluePeiMemoryAllocationLib.sdl b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiMemoryAllocationLib/EdkIIGluePeiMemoryAllocationLib.sdl new file mode 100644 index 0000000..d382d83 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiMemoryAllocationLib/EdkIIGluePeiMemoryAllocationLib.sdl @@ -0,0 +1,26 @@ +TOKEN + Name = "EdkIIGluePeiMemoryAllocationLib_SUPPORT" + Value = "1" + Help = "Main switch to enable EdkIIGluePeiMemoryAllocationLib support in Project" + TokenType = Boolean + TargetEQU = Yes + TargetMAK = Yes + Master = Yes +End + +TOKEN + Name = "EdkIIGluePeiMemoryAllocationLib_LIB" + Value = "$$(LIB_BUILD_DIR)\EdkIIGluePeiMemoryAllocationLib.lib" + TokenType = Expression + TargetMAK = Yes +End + +PATH + Name = "EdkIIGluePeiMemoryAllocationLib_DIR" +End + +MODULE + Help = "Includes EdkIIGluePeiMemoryAllocationLib.mak to Project" + File = "EdkIIGluePeiMemoryAllocationLib.mak" +End + diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiMemoryAllocationLib/MemoryAllocationLib.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiMemoryAllocationLib/MemoryAllocationLib.c new file mode 100644 index 0000000..50ff6ff --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiMemoryAllocationLib/MemoryAllocationLib.c @@ -0,0 +1,1080 @@ +/*++ + +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: + + MemoryAllocationLib.c + +Abstract: + + Support routines for memory allocation routines for use with drivers. + +--*/ + +#include "EdkIIGluePeim.h" + +/** + Allocates one or more 4KB pages of a certain memory type. + + Allocates the number of 4KB pages of a certain memory type and returns a pointer to the allocated + buffer. The buffer returned is aligned on a 4KB boundary. If Pages is 0, then NULL is returned. + If there is not enough memory remaining to satisfy the request, then NULL is returned. + + @param MemoryType The type of memory to allocate. + @param Pages The number of 4 KB pages to allocate. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +InternalAllocatePages ( + IN EFI_MEMORY_TYPE MemoryType, + IN UINTN Pages + ) +{ + EFI_STATUS Status; + EFI_PHYSICAL_ADDRESS Memory; + EFI_PEI_SERVICES **PeiServices; + + if (Pages == 0) { + return NULL; + } + + PeiServices = GetPeiServicesTablePointer (); + Status = ((*PeiServices)->AllocatePages) (PeiServices, MemoryType, Pages, &Memory); + if (EFI_ERROR (Status)) { + Memory = 0; + } + return (VOID *) (UINTN) Memory; +} + +/** + Allocates one or more 4KB pages of type EfiBootServicesData. + + Allocates the number of 4KB pages of type EfiBootServicesData and returns a pointer to the + allocated buffer. The buffer returned is aligned on a 4KB boundary. If Pages is 0, then NULL + is returned. If there is not enough memory remaining to satisfy the request, then NULL is + returned. + + @param Pages The number of 4 KB pages to allocate. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +GlueAllocatePages ( + IN UINTN Pages + ) +{ + return InternalAllocatePages (EfiBootServicesData, Pages); +} + +/** + Allocates one or more 4KB pages of type EfiRuntimeServicesData. + + Allocates the number of 4KB pages of type EfiRuntimeServicesData and returns a pointer to the + allocated buffer. The buffer returned is aligned on a 4KB boundary. If Pages is 0, then NULL + is returned. If there is not enough memory remaining to satisfy the request, then NULL is + returned. + + @param Pages The number of 4 KB pages to allocate. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +AllocateRuntimePages ( + IN UINTN Pages + ) +{ + return InternalAllocatePages (EfiRuntimeServicesData, Pages); +} + +/** + Allocates one or more 4KB pages of type EfiReservedMemoryType. + + Allocates the number of 4KB pages of type EfiReservedMemoryType and returns a pointer to the + allocated buffer. The buffer returned is aligned on a 4KB boundary. If Pages is 0, then NULL + is returned. If there is not enough memory remaining to satisfy the request, then NULL is + returned. + + @param Pages The number of 4 KB pages to allocate. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +AllocateReservedPages ( + IN UINTN Pages + ) +{ + return InternalAllocatePages (EfiReservedMemoryType, Pages); +} + +/** + Frees one or more 4KB pages that were previously allocated with one of the page allocation + functions in the Memory Allocation Library. + + Frees the number of 4KB pages specified by Pages from the buffer specified by Buffer. Buffer + must have been allocated on a previous call to the page allocation services of the Memory + Allocation Library. + If Buffer was not allocated with a page allocation function in the Memory Allocation Library, + then ASSERT(). + If Pages is zero, then ASSERT(). + + @param Buffer Pointer to the buffer of pages to free. + @param Pages The number of 4 KB pages to free. + +**/ +VOID +EFIAPI +GlueFreePages ( + IN VOID *Buffer, + IN UINTN Pages + ) +{ + // + // PEI phase does not support to free pages, so leave it as NOP. + // +} + +/** + Allocates one or more 4KB pages of a certain memory type at a specified alignment. + + Allocates the number of 4KB pages specified by Pages of a certain memory type with an alignment + specified by Alignment. The allocated buffer is returned. If Pages is 0, then NULL is returned. + If there is not enough memory at the specified alignment remaining to satisfy the request, then + NULL is returned. + If Alignment is not a power of two and Alignment is not zero, then ASSERT(). + + @param MemoryType The type of memory to allocate. + @param Pages The number of 4 KB pages to allocate. + @param Alignment The requested alignment of the allocation. Must be a power of two. + If Alignment is zero, then byte alignment is used. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +InternalAllocateAlignedPages ( + IN EFI_MEMORY_TYPE MemoryType, + IN UINTN Pages, + IN UINTN Alignment + ) +{ + VOID *Memory; + UINTN AlignmentMask; + + // + // Alignment must be a power of two or zero. + // + ASSERT ((Alignment & (Alignment - 1)) == 0); + + if (Pages == 0) { + return NULL; + } + // + // Make sure that Pages plus EFI_SIZE_TO_PAGES (Alignment) does not overflow. + // + ASSERT (Pages <= (MAX_ADDRESS - EFI_SIZE_TO_PAGES (Alignment))); + // + // We would rather waste some memory to save PEI code size. + // + Memory = InternalAllocatePages (MemoryType, Pages + EFI_SIZE_TO_PAGES (Alignment)); + if (Alignment == 0) { + AlignmentMask = Alignment; + } else { + AlignmentMask = Alignment - 1; + } + return (VOID *) (UINTN) (((UINTN) Memory + AlignmentMask) & ~AlignmentMask); +} + +/** + Allocates one or more 4KB pages of type EfiBootServicesData at a specified alignment. + + Allocates the number of 4KB pages specified by Pages of type EfiBootServicesData with an + alignment specified by Alignment. The allocated buffer is returned. If Pages is 0, then NULL is + returned. If there is not enough memory at the specified alignment remaining to satisfy the + request, then NULL is returned. + If Alignment is not a power of two and Alignment is not zero, then ASSERT(). + + @param Pages The number of 4 KB pages to allocate. + @param Alignment The requested alignment of the allocation. Must be a power of two. + If Alignment is zero, then byte alignment is used. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +AllocateAlignedPages ( + IN UINTN Pages, + IN UINTN Alignment + ) +{ + return InternalAllocateAlignedPages (EfiBootServicesData, Pages, Alignment); +} + +/** + Allocates one or more 4KB pages of type EfiRuntimeServicesData at a specified alignment. + + Allocates the number of 4KB pages specified by Pages of type EfiRuntimeServicesData with an + alignment specified by Alignment. The allocated buffer is returned. If Pages is 0, then NULL is + returned. If there is not enough memory at the specified alignment remaining to satisfy the + request, then NULL is returned. + If Alignment is not a power of two and Alignment is not zero, then ASSERT(). + + @param Pages The number of 4 KB pages to allocate. + @param Alignment The requested alignment of the allocation. Must be a power of two. + If Alignment is zero, then byte alignment is used. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +AllocateAlignedRuntimePages ( + IN UINTN Pages, + IN UINTN Alignment + ) +{ + return InternalAllocateAlignedPages (EfiRuntimeServicesData, Pages, Alignment); +} + +/** + Allocates one or more 4KB pages of type EfiReservedMemoryType at a specified alignment. + + Allocates the number of 4KB pages specified by Pages of type EfiReservedMemoryType with an + alignment specified by Alignment. The allocated buffer is returned. If Pages is 0, then NULL is + returned. If there is not enough memory at the specified alignment remaining to satisfy the + request, then NULL is returned. + If Alignment is not a power of two and Alignment is not zero, then ASSERT(). + + @param Pages The number of 4 KB pages to allocate. + @param Alignment The requested alignment of the allocation. Must be a power of two. + If Alignment is zero, then byte alignment is used. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +AllocateAlignedReservedPages ( + IN UINTN Pages, + IN UINTN Alignment + ) +{ + return InternalAllocateAlignedPages (EfiReservedMemoryType, Pages, Alignment); +} + +/** + Frees one or more 4KB pages that were previously allocated with one of the aligned page + allocation functions in the Memory Allocation Library. + + Frees the number of 4KB pages specified by Pages from the buffer specified by Buffer. Buffer + must have been allocated on a previous call to the aligned page allocation services of the Memory + Allocation Library. + If Buffer was not allocated with an aligned page allocation function in the Memory Allocation + Library, then ASSERT(). + If Pages is zero, then ASSERT(). + + @param Buffer Pointer to the buffer of pages to free. + @param Pages The number of 4 KB pages to free. + +**/ +VOID +EFIAPI +FreeAlignedPages ( + IN VOID *Buffer, + IN UINTN Pages + ) +{ + // + // PEI phase does not support to free pages, so leave it as NOP. + // +} + +/** + Allocates a buffer of a certain pool type. + + Allocates the number bytes specified by AllocationSize of a certain pool type and returns a + pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is + returned. If there is not enough memory remaining to satisfy the request, then NULL is returned. + + @param MemoryType The type of memory to allocate. + @param AllocationSize The number of bytes to allocate. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +InternalAllocatePool ( + IN EFI_MEMORY_TYPE MemoryType, + IN UINTN AllocationSize + ) +{ + // + // If we need lots of small runtime/reserved memory type from PEI in the future, + // we can consider providing a more complex algorithm that allocates runtime pages and + // provide pool allocations from those pages. + // + return InternalAllocatePages (MemoryType, EFI_SIZE_TO_PAGES (AllocationSize)); +} + +/** + Allocates a buffer of type EfiBootServicesData. + + Allocates the number bytes specified by AllocationSize of type EfiBootServicesData and returns a + pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is + returned. If there is not enough memory remaining to satisfy the request, then NULL is returned. + + @param AllocationSize The number of bytes to allocate. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +GlueAllocatePool ( + IN UINTN AllocationSize + ) +{ + EFI_STATUS Status; + EFI_PEI_SERVICES **PeiServices; + VOID *Buffer; + + PeiServices = GetPeiServicesTablePointer (); + + Status = ((*PeiServices)->AllocatePool) (PeiServices, AllocationSize, &Buffer); + if (EFI_ERROR (Status)) { + Buffer = NULL; + } + return Buffer; +} + +/** + Allocates a buffer of type EfiRuntimeServicesData. + + Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData and returns + a pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is + returned. If there is not enough memory remaining to satisfy the request, then NULL is returned. + + @param AllocationSize The number of bytes to allocate. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +AllocateRuntimePool ( + IN UINTN AllocationSize + ) +{ + return InternalAllocatePool (EfiRuntimeServicesData, AllocationSize); +} + +/** + Allocates a buffer of type EfieservedMemoryType. + + Allocates the number bytes specified by AllocationSize of type EfieservedMemoryType and returns + a pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is + returned. If there is not enough memory remaining to satisfy the request, then NULL is returned. + + @param AllocationSize The number of bytes to allocate. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +AllocateReservedPool ( + IN UINTN AllocationSize + ) +{ + return InternalAllocatePool (EfiReservedMemoryType, AllocationSize); +} + +/** + Allocates and zeros a buffer of a certian pool type. + + Allocates the number bytes specified by AllocationSize of a certian pool type, clears the buffer + with zeros, and returns a pointer to the allocated buffer. If AllocationSize is 0, then a valid + buffer of 0 size is returned. If there is not enough memory remaining to satisfy the request, + then NULL is returned. + + @param PoolType The type of memory to allocate. + @param AllocationSize The number of bytes to allocate and zero. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +InternalAllocateZeroPool ( + IN EFI_MEMORY_TYPE PoolType, + IN UINTN AllocationSize + ) +{ + VOID *Memory; + + Memory = InternalAllocatePool (PoolType, AllocationSize); + if (Memory != NULL) { + Memory = ZeroMem (Memory, AllocationSize); + } + return Memory; +} + +/** + Allocates and zeros a buffer of type EfiBootServicesData. + + Allocates the number bytes specified by AllocationSize of type EfiBootServicesData, clears the + buffer with zeros, and returns a pointer to the allocated buffer. If AllocationSize is 0, then a + valid buffer of 0 size is returned. If there is not enough memory remaining to satisfy the + request, then NULL is returned. + + @param AllocationSize The number of bytes to allocate and zero. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +GlueAllocateZeroPool ( + IN UINTN AllocationSize + ) +{ + VOID *Memory; + + Memory = AllocatePool (AllocationSize); + if (Memory != NULL) { + Memory = ZeroMem (Memory, AllocationSize); + } + return Memory; +} + +/** + Allocates and zeros a buffer of type EfiRuntimeServicesData. + + Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData, clears the + buffer with zeros, and returns a pointer to the allocated buffer. If AllocationSize is 0, then a + valid buffer of 0 size is returned. If there is not enough memory remaining to satisfy the + request, then NULL is returned. + + @param AllocationSize The number of bytes to allocate and zero. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +AllocateRuntimeZeroPool ( + IN UINTN AllocationSize + ) +{ + return InternalAllocateZeroPool (EfiRuntimeServicesData, AllocationSize); +} + +/** + Allocates and zeros a buffer of type EfiReservedMemoryType. + + Allocates the number bytes specified by AllocationSize of type EfiReservedMemoryType, clears the + buffer with zeros, and returns a pointer to the allocated buffer. If AllocationSize is 0, then a + valid buffer of 0 size is returned. If there is not enough memory remaining to satisfy the + request, then NULL is returned. + + @param AllocationSize The number of bytes to allocate and zero. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +AllocateReservedZeroPool ( + IN UINTN AllocationSize + ) +{ + return InternalAllocateZeroPool (EfiReservedMemoryType, AllocationSize); +} + +/** + Copies a buffer to an allocated buffer of a certian pool type. + + Allocates the number bytes specified by AllocationSize of a certian pool type, copies + AllocationSize bytes from Buffer to the newly allocated buffer, and returns a pointer to the + allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there + is not enough memory remaining to satisfy the request, then NULL is returned. + If Buffer is NULL, then ASSERT(). + If AllocationSize is greater than (MAX_ADDRESS ?Buffer + 1), then ASSERT(). + + @param PoolType The type of pool to allocate. + @param AllocationSize The number of bytes to allocate and zero. + @param Buffer The buffer to copy to the allocated buffer. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +InternalAllocateCopyPool ( + IN EFI_MEMORY_TYPE PoolType, + IN UINTN AllocationSize, + IN CONST VOID *Buffer + ) +{ + VOID *Memory; + + ASSERT (Buffer != NULL); + ASSERT (AllocationSize <= (MAX_ADDRESS - (UINTN) Buffer + 1)); + + Memory = InternalAllocatePool (PoolType, AllocationSize); + if (Memory != NULL) { + Memory = CopyMem (Memory, Buffer, AllocationSize); + } + return Memory; +} + +/** + Copies a buffer to an allocated buffer of type EfiBootServicesData. + + Allocates the number bytes specified by AllocationSize of type EfiBootServicesData, copies + AllocationSize bytes from Buffer to the newly allocated buffer, and returns a pointer to the + allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there + is not enough memory remaining to satisfy the request, then NULL is returned. + If Buffer is NULL, then ASSERT(). + If AllocationSize is greater than (MAX_ADDRESS ?Buffer + 1), then ASSERT(). + + @param AllocationSize The number of bytes to allocate and zero. + @param Buffer The buffer to copy to the allocated buffer. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +GlueAllocateCopyPool ( + IN UINTN AllocationSize, + IN CONST VOID *Buffer + ) +{ + VOID *Memory; + + ASSERT (Buffer != NULL); + ASSERT (AllocationSize <= (MAX_ADDRESS - (UINTN) Buffer + 1)); + + Memory = AllocatePool (AllocationSize); + if (Memory != NULL) { + Memory = CopyMem (Memory, Buffer, AllocationSize); + } + return Memory; +} + +/** + Copies a buffer to an allocated buffer of type EfiRuntimeServicesData. + + Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData, copies + AllocationSize bytes from Buffer to the newly allocated buffer, and returns a pointer to the + allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there + is not enough memory remaining to satisfy the request, then NULL is returned. + If Buffer is NULL, then ASSERT(). + If AllocationSize is greater than (MAX_ADDRESS ?Buffer + 1), then ASSERT(). + + @param AllocationSize The number of bytes to allocate and zero. + @param Buffer The buffer to copy to the allocated buffer. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +AllocateRuntimeCopyPool ( + IN UINTN AllocationSize, + IN CONST VOID *Buffer + ) +{ + return InternalAllocateCopyPool (EfiRuntimeServicesData, AllocationSize, Buffer); +} + +/** + Copies a buffer to an allocated buffer of type EfiReservedMemoryType. + + Allocates the number bytes specified by AllocationSize of type EfiReservedMemoryType, copies + AllocationSize bytes from Buffer to the newly allocated buffer, and returns a pointer to the + allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there + is not enough memory remaining to satisfy the request, then NULL is returned. + If Buffer is NULL, then ASSERT(). + If AllocationSize is greater than (MAX_ADDRESS ?Buffer + 1), then ASSERT(). + + @param AllocationSize The number of bytes to allocate and zero. + @param Buffer The buffer to copy to the allocated buffer. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +AllocateReservedCopyPool ( + IN UINTN AllocationSize, + IN CONST VOID *Buffer + ) +{ + return InternalAllocateCopyPool (EfiReservedMemoryType, AllocationSize, Buffer); +} + +/** + Frees a buffer that was previously allocated with one of the pool allocation functions in the + Memory Allocation Library. + + Frees the buffer specified by Buffer. Buffer must have been allocated on a previous call to the + pool allocation services of the Memory Allocation Library. + If Buffer was not allocated with a pool allocation function in the Memory Allocation Library, + then ASSERT(). + + @param Buffer Pointer to the buffer to free. + +**/ +VOID +EFIAPI +GlueFreePool ( + IN VOID *Buffer + ) +{ + // + // PEI phase does not support to free pool, so leave it as NOP. + // +} + +/** + Allocates a buffer of a certain pool type at a specified alignment. + + Allocates the number bytes specified by AllocationSize of a certain pool type with an alignment + specified by Alignment. The allocated buffer is returned. If AllocationSize is 0, then a valid + buffer of 0 size is returned. If there is not enough memory at the specified alignment remaining + to satisfy the request, then NULL is returned. + If Alignment is not a power of two and Alignment is not zero, then ASSERT(). + + @param PoolType The type of pool to allocate. + @param AllocationSize The number of bytes to allocate. + @param Alignment The requested alignment of the allocation. Must be a power of two. If Alignment is zero, then byte alignment is used. + If Alignment is zero, then byte alignment is used. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +InternalAllocateAlignedPool ( + IN EFI_MEMORY_TYPE PoolType, + IN UINTN AllocationSize, + IN UINTN Alignment + ) +{ + VOID *RawAddress; + UINTN AlignedAddress; + UINTN AlignmentMask; + + // + // Alignment must be a power of two or zero. + // + ASSERT ((Alignment & (Alignment - 1)) == 0); + + if (Alignment == 0) { + AlignmentMask = Alignment; + } else { + AlignmentMask = Alignment - 1; + } + // + // Make sure that AllocationSize plus AlignmentMask does not overflow. + // + ASSERT (AllocationSize <= (MAX_ADDRESS - AlignmentMask)); + + RawAddress = InternalAllocatePool (PoolType, AllocationSize + AlignmentMask); + + AlignedAddress = ((UINTN) RawAddress + AlignmentMask) & ~AlignmentMask; + + return (VOID *) AlignedAddress; +} + +/** + Allocates a buffer of type EfiBootServicesData at a specified alignment. + + Allocates the number bytes specified by AllocationSize of type EfiBootServicesData with an + alignment specified by Alignment. The allocated buffer is returned. If AllocationSize is 0, + then a valid buffer of 0 size is returned. If there is not enough memory at the specified + alignment remaining to satisfy the request, then NULL is returned. + If Alignment is not a power of two and Alignment is not zero, then ASSERT(). + + @param AllocationSize The number of bytes to allocate. + @param Alignment The requested alignment of the allocation. Must be a power of two. + If Alignment is zero, then byte alignment is used. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +AllocateAlignedPool ( + IN UINTN AllocationSize, + IN UINTN Alignment + ) +{ + VOID *RawAddress; + UINTN AlignedAddress; + UINTN AlignmentMask; + + // + // Alignment must be a power of two or zero. + // + ASSERT ((Alignment & (Alignment - 1)) == 0); + + if (Alignment == 0) { + AlignmentMask = Alignment; + } else { + AlignmentMask = Alignment - 1; + } + + // + // Make sure that AllocationSize plus AlignmentMask does not overflow. + // + ASSERT (AllocationSize <= (MAX_ADDRESS - AlignmentMask)); + + RawAddress = AllocatePool (AllocationSize + AlignmentMask); + + AlignedAddress = ((UINTN) RawAddress + AlignmentMask) & ~AlignmentMask; + + return (VOID *) AlignedAddress; +} + +/** + Allocates a buffer of type EfiRuntimeServicesData at a specified alignment. + + Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData with an + alignment specified by Alignment. The allocated buffer is returned. If AllocationSize is 0, + then a valid buffer of 0 size is returned. If there is not enough memory at the specified + alignment remaining to satisfy the request, then NULL is returned. + If Alignment is not a power of two and Alignment is not zero, then ASSERT(). + + @param AllocationSize The number of bytes to allocate. + @param Alignment The requested alignment of the allocation. Must be a power of two. + If Alignment is zero, then byte alignment is used. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +AllocateAlignedRuntimePool ( + IN UINTN AllocationSize, + IN UINTN Alignment + ) +{ + return InternalAllocateAlignedPool (EfiRuntimeServicesData, AllocationSize, Alignment); +} + +/** + Allocates a buffer of type EfieservedMemoryType at a specified alignment. + + Allocates the number bytes specified by AllocationSize of type EfieservedMemoryType with an + alignment specified by Alignment. The allocated buffer is returned. If AllocationSize is 0, + then a valid buffer of 0 size is returned. If there is not enough memory at the specified + alignment remaining to satisfy the request, then NULL is returned. + If Alignment is not a power of two and Alignment is not zero, then ASSERT(). + + @param AllocationSize The number of bytes to allocate. + @param Alignment The requested alignment of the allocation. Must be a power of two. + If Alignment is zero, then byte alignment is used. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +AllocateAlignedReservedPool ( + IN UINTN AllocationSize, + IN UINTN Alignment + ) +{ + return InternalAllocateAlignedPool (EfiReservedMemoryType, AllocationSize, Alignment); +} + +/** + Allocates and zeros a buffer of a certain pool type at a specified alignment. + + Allocates the number bytes specified by AllocationSize of a certain pool type with an alignment + specified by Alignment, clears the buffer with zeros, and returns a pointer to the allocated + buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there is not + enough memory at the specified alignment remaining to satisfy the request, then NULL is returned. + If Alignment is not a power of two and Alignment is not zero, then ASSERT(). + + @param PoolType The type of pool to allocate. + @param AllocationSize The number of bytes to allocate. + @param Alignment The requested alignment of the allocation. Must be a power of two. + If Alignment is zero, then byte alignment is used. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +InternalAllocateAlignedZeroPool ( + IN EFI_MEMORY_TYPE PoolType, + IN UINTN AllocationSize, + IN UINTN Alignment + ) +{ + VOID *Memory; + + Memory = InternalAllocateAlignedPool (PoolType, AllocationSize, Alignment); + if (Memory != NULL) { + Memory = ZeroMem (Memory, AllocationSize); + } + return Memory; +} + +/** + Allocates and zeros a buffer of type EfiBootServicesData at a specified alignment. + + Allocates the number bytes specified by AllocationSize of type EfiBootServicesData with an + alignment specified by Alignment, clears the buffer with zeros, and returns a pointer to the + allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there + is not enough memory at the specified alignment remaining to satisfy the request, then NULL is + returned. + If Alignment is not a power of two and Alignment is not zero, then ASSERT(). + + @param AllocationSize The number of bytes to allocate. + @param Alignment The requested alignment of the allocation. Must be a power of two. + If Alignment is zero, then byte alignment is used. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +AllocateAlignedZeroPool ( + IN UINTN AllocationSize, + IN UINTN Alignment + ) +{ + VOID *Memory; + + Memory = AllocateAlignedPool (AllocationSize, Alignment); + if (Memory != NULL) { + Memory = ZeroMem (Memory, AllocationSize); + } + return Memory; +} + +/** + Allocates and zeros a buffer of type EfiRuntimeServicesData at a specified alignment. + + Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData with an + alignment specified by Alignment, clears the buffer with zeros, and returns a pointer to the + allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there + is not enough memory at the specified alignment remaining to satisfy the request, then NULL is + returned. + If Alignment is not a power of two and Alignment is not zero, then ASSERT(). + + @param AllocationSize The number of bytes to allocate. + @param Alignment The requested alignment of the allocation. Must be a power of two. + If Alignment is zero, then byte alignment is used. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +AllocateAlignedRuntimeZeroPool ( + IN UINTN AllocationSize, + IN UINTN Alignment + ) +{ + return InternalAllocateAlignedZeroPool (EfiRuntimeServicesData, AllocationSize, Alignment); +} + +/** + Allocates and zeros a buffer of type EfieservedMemoryType at a specified alignment. + + Allocates the number bytes specified by AllocationSize of type EfieservedMemoryType with an + alignment specified by Alignment, clears the buffer with zeros, and returns a pointer to the + allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there + is not enough memory at the specified alignment remaining to satisfy the request, then NULL is + returned. + If Alignment is not a power of two and Alignment is not zero, then ASSERT(). + + @param AllocationSize The number of bytes to allocate. + @param Alignment The requested alignment of the allocation. Must be a power of two. + If Alignment is zero, then byte alignment is used. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +AllocateAlignedReservedZeroPool ( + IN UINTN AllocationSize, + IN UINTN Alignment + ) +{ + return InternalAllocateAlignedZeroPool (EfiReservedMemoryType, AllocationSize, Alignment); +} + +/** + Copies a buffer to an allocated buffer of a certain pool type at a specified alignment. + + Allocates the number bytes specified by AllocationSize of a certain pool type with an alignment + specified by Alignment. The allocated buffer is returned. If AllocationSize is 0, then a valid + buffer of 0 size is returned. If there is not enough memory at the specified alignment remaining + to satisfy the request, then NULL is returned. + If Alignment is not a power of two and Alignment is not zero, then ASSERT(). + + @param PoolType The type of pool to allocate. + @param AllocationSize The number of bytes to allocate. + @param Buffer The buffer to copy to the allocated buffer. + @param Alignment The requested alignment of the allocation. Must be a power of two. + If Alignment is zero, then byte alignment is used. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +InternalAllocateAlignedCopyPool ( + IN EFI_MEMORY_TYPE PoolType, + IN UINTN AllocationSize, + IN CONST VOID *Buffer, + IN UINTN Alignment + ) +{ + VOID *Memory; + + ASSERT (Buffer != NULL); + ASSERT (AllocationSize <= (MAX_ADDRESS - (UINTN) Buffer + 1)); + + Memory = InternalAllocateAlignedPool (PoolType, AllocationSize, Alignment); + if (Memory != NULL) { + Memory = CopyMem (Memory, Buffer, AllocationSize); + } + return Memory; +} + +/** + Copies a buffer to an allocated buffer of type EfiBootServicesData at a specified alignment. + + Allocates the number bytes specified by AllocationSize of type EfiBootServicesData type with an + alignment specified by Alignment. The allocated buffer is returned. If AllocationSize is 0, + then a valid buffer of 0 size is returned. If there is not enough memory at the specified + alignment remaining to satisfy the request, then NULL is returned. + If Alignment is not a power of two and Alignment is not zero, then ASSERT(). + + @param AllocationSize The number of bytes to allocate. + @param Buffer The buffer to copy to the allocated buffer. + @param Alignment The requested alignment of the allocation. Must be a power of two. + If Alignment is zero, then byte alignment is used. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +AllocateAlignedCopyPool ( + IN UINTN AllocationSize, + IN CONST VOID *Buffer, + IN UINTN Alignment + ) +{ + VOID *Memory; + + ASSERT (Buffer != NULL); + ASSERT (AllocationSize <= (MAX_ADDRESS - (UINTN) Buffer + 1)); + + Memory = AllocateAlignedPool (AllocationSize, Alignment); + if (Memory != NULL) { + Memory = CopyMem (Memory, Buffer, AllocationSize); + } + return Memory; +} + +/** + Copies a buffer to an allocated buffer of type EfiRuntimeServicesData at a specified alignment. + + Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData type with an + alignment specified by Alignment. The allocated buffer is returned. If AllocationSize is 0, + then a valid buffer of 0 size is returned. If there is not enough memory at the specified + alignment remaining to satisfy the request, then NULL is returned. + If Alignment is not a power of two and Alignment is not zero, then ASSERT(). + + @param AllocationSize The number of bytes to allocate. + @param Buffer The buffer to copy to the allocated buffer. + @param Alignment The requested alignment of the allocation. Must be a power of two. + If Alignment is zero, then byte alignment is used. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +AllocateAlignedRuntimeCopyPool ( + IN UINTN AllocationSize, + IN CONST VOID *Buffer, + IN UINTN Alignment + ) +{ + return InternalAllocateAlignedCopyPool (EfiRuntimeServicesData, AllocationSize, Buffer, Alignment); +} + +/** + Copies a buffer to an allocated buffer of type EfiReservedMemoryType at a specified alignment. + + Allocates the number bytes specified by AllocationSize of type EfiReservedMemoryType type with an + alignment specified by Alignment. The allocated buffer is returned. If AllocationSize is 0, + then a valid buffer of 0 size is returned. If there is not enough memory at the specified + alignment remaining to satisfy the request, then NULL is returned. + If Alignment is not a power of two and Alignment is not zero, then ASSERT(). + + @param AllocationSize The number of bytes to allocate. + @param Buffer The buffer to copy to the allocated buffer. + @param Alignment The requested alignment of the allocation. Must be a power of two. + If Alignment is zero, then byte alignment is used. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +AllocateAlignedReservedCopyPool ( + IN UINTN AllocationSize, + IN CONST VOID *Buffer, + IN UINTN Alignment + ) +{ + return InternalAllocateAlignedCopyPool (EfiReservedMemoryType, AllocationSize, Buffer, Alignment); +} + +/** + Frees a buffer that was previously allocated with one of the aligned pool allocation functions + in the Memory Allocation Library. + + Frees the buffer specified by Buffer. Buffer must have been allocated on a previous call to the + aligned pool allocation services of the Memory Allocation Library. + If Buffer was not allocated with an aligned pool allocation function in the Memory Allocation + Library, then ASSERT(). + + @param Buffer Pointer to the buffer to free. + +**/ +VOID +EFIAPI +FreeAlignedPool ( + IN VOID *Buffer + ) +{ + // + // PEI phase does not support to free pool, so leave it as NOP. + // +} diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiMemoryAllocationLib/PeiMemoryAllocationLib.inf b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiMemoryAllocationLib/PeiMemoryAllocationLib.inf new file mode 100644 index 0000000..f576bc5 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiMemoryAllocationLib/PeiMemoryAllocationLib.inf @@ -0,0 +1,85 @@ +#/*++ +# +# 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: +# +# PeiMemoryAllocationLib.inf +# +# Abstract: +# +# Component description file for PeiMemoryAllocationLib. +# +#--*/ + +[defines] +BASE_NAME = EdkIIGluePeiMemoryAllocationLib +COMPONENT_TYPE = LIBRARY + +[sources.common] + MemoryAllocationLib.c + +[sources.ia32] + + +[sources.x64] + + +[sources.ipf] + + +[sources.ebc] + + +[includes.common] + . + ..\..\Include + ..\..\include\Library + $(EDK_SOURCE)\Foundation + $(EDK_SOURCE)\Foundation\Include\Pei + $(EDK_SOURCE)\Foundation\Framework + $(EDK_SOURCE)\Foundation\Efi + $(EDK_SOURCE)\Foundation\Include + $(EDK_SOURCE)\Foundation\Efi\Include + $(EDK_SOURCE)\Foundation\Framework\Include + $(EDK_SOURCE)\Foundation\Include\IndustryStandard + $(EDK_SOURCE)\Foundation\Core\Dxe + $(EDK_SOURCE)\Foundation\Library\Dxe\Include + $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include + +[libraries.common] + EdkIIGlueBaseMemoryLib + EdkIIGluePeiServicesTablePointerLibMm7 +# +# If necessary, EdkIIGluePeiSerivcesTablePointerLib can be used to +# replaced EdkIIGluePeiServicesTablePointerLibMm7 +# + +[libraries.ia32] + + +[libraries.x64] + + +[nmake.common] + C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION + LIB_STD_FLAGS = /NOLOGO /IGNORE:4006 + +[nmake.ia32] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32 + +[nmake.x64] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64 + +[nmake.ipf] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF + +[nmake.ebc] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_EBC
\ No newline at end of file diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiReportStatusCodeLib/EdkIIGluePeiReportStatusCodeLib.cif b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiReportStatusCodeLib/EdkIIGluePeiReportStatusCodeLib.cif new file mode 100644 index 0000000..a3b9273 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiReportStatusCodeLib/EdkIIGluePeiReportStatusCodeLib.cif @@ -0,0 +1,11 @@ +<component> + name = "EdkIIGluePeiReportStatusCodeLib" + category = ModulePart + LocalRoot = "Edk\Foundation\Library\EdkIIGlueLib\Library\PeiReportStatusCodeLib" + RefName = "EdkIIGluePeiReportStatusCodeLib" +[files] +"EdkIIGluePeiReportStatusCodeLib.sdl" +"EdkIIGluePeiReportStatusCodeLib.mak" +"PeiReportStatusCodeLib.inf" +"ReportStatusCodeLib.c" +<endComponent> diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiReportStatusCodeLib/EdkIIGluePeiReportStatusCodeLib.mak b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiReportStatusCodeLib/EdkIIGluePeiReportStatusCodeLib.mak new file mode 100644 index 0000000..f6f35d6 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiReportStatusCodeLib/EdkIIGluePeiReportStatusCodeLib.mak @@ -0,0 +1,89 @@ +#********************************************************************** +#********************************************************************** +#** ** +#** (C)Copyright 1985-2009, American Megatrends, Inc. ** +#** ** +#** All Rights Reserved. ** +#** ** +#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +#** ** +#** Phone: (770)-246-8600 ** +#** ** +#********************************************************************** +#********************************************************************** + +#********************************************************************** +# $Header: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGluePeiReportStatusCodeLib/EdkIIGluePeiReportStatusCodeLib.mak 1 1/20/12 3:57a Jeffch $ +# +# $Revision: 1 $ +# +# $Date: 1/20/12 3:57a $ +#********************************************************************** +# Revision History +# ---------------- +# $Log: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGluePeiReportStatusCodeLib/EdkIIGluePeiReportStatusCodeLib.mak $ +# +# 1 1/20/12 3:57a Jeffch +# Create Intel EDK 1117 Patch 7. +# +# 1 9/27/11 6:19a Wesleychen +# Intel EDK initially releases. +# +# 1 9/18/09 1:57a Iminglin +# +#********************************************************************** +#<AMI_FHDR_START> +# +# Name: EdkIIGluePeiReportStatusCodeLib.mak +# +# Description: +# +#<AMI_FHDR_END> +#********************************************************************** + + +$(EdkIIGluePeiReportStatusCodeLib_LIB) : EdkIIGluePeiReportStatusCodeLib + +EdkIIGluePeiReportStatusCodeLib : $(BUILD_DIR)\EdkIIGluePeiReportStatusCodeLib.mak EdkIIGluePeiReportStatusCodeLibBin + +$(BUILD_DIR)\EdkIIGluePeiReportStatusCodeLib.mak : $(EdkIIGluePeiReportStatusCodeLib_DIR)\$(@B).cif $(EdkIIGluePeiReportStatusCodeLib_DIR)\$(@B).mak $(BUILD_RULES) + $(CIF2MAK) $(EdkIIGluePeiReportStatusCodeLib_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS) + +EdkIIGluePeiReportStatusCodeLib_LIB_LINKS=$(EdkIIGlueBaseLib_LIB)\ +$(EdkIIGlueBaseMemoryLib_LIB)\ +$(EdkIIGlueBaseIoLibIntrinsic_LIB)\ +$(EDKFRAMEWORKGUIDLIB)\ +$(EDKGUIDLIB)\ +!IF "$(PROCESSOR)"=="IA32" || "$(PROCESSOR)"=="x64" +$(EdkIIGluePeiServicesTablePointerLibMm7_LIB) +!ENDIF + +EdkIIGluePeiReportStatusCodeLibBin : $(EdkIIGluePeiReportStatusCodeLib_LIB_LINKS) +!IF "$(x64_BUILD)"=="1" + $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\ + BUILD_DIR=$(BUILD_DIR)\ + /f $(BUILD_DIR)\EdkIIGluePeiReportStatusCodeLib.mak all\ + TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGluePeiReportStatusCodeLib_LIB)" + $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\ + BUILD_DIR=$(BUILD_DIR)\IA32\ + /f $(BUILD_DIR)\EdkIIGluePeiReportStatusCodeLib.mak all\ + TYPE=PEI_LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGluePeiReportStatusCodeLib_LIB)" +!ELSE + $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\ + BUILD_DIR=$(BUILD_DIR)\ + /f $(BUILD_DIR)\EdkIIGluePeiReportStatusCodeLib.mak all\ + TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGluePeiReportStatusCodeLib_LIB)" +!ENDIF +#********************************************************************** +#********************************************************************** +#** ** +#** (C)Copyright 1985-2009, American Megatrends, Inc. ** +#** ** +#** All Rights Reserved. ** +#** ** +#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +#** ** +#** Phone: (770)-246-8600 ** +#** ** +#********************************************************************** +#********************************************************************** diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiReportStatusCodeLib/EdkIIGluePeiReportStatusCodeLib.sdl b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiReportStatusCodeLib/EdkIIGluePeiReportStatusCodeLib.sdl new file mode 100644 index 0000000..b6aae58 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiReportStatusCodeLib/EdkIIGluePeiReportStatusCodeLib.sdl @@ -0,0 +1,26 @@ +TOKEN + Name = "EdkIIGluePeiReportStatusCodeLib_SUPPORT" + Value = "1" + Help = "Main switch to enable EdkIIGluePeiReportStatusCodeLib support in Project" + TokenType = Boolean + TargetEQU = Yes + TargetMAK = Yes + Master = Yes +End + +TOKEN + Name = "EdkIIGluePeiReportStatusCodeLib_LIB" + Value = "$$(LIB_BUILD_DIR)\EdkIIGluePeiReportStatusCodeLib.lib" + TokenType = Expression + TargetMAK = Yes +End + +PATH + Name = "EdkIIGluePeiReportStatusCodeLib_DIR" +End + +MODULE + Help = "Includes EdkIIGluePeiReportStatusCodeLib.mak to Project" + File = "EdkIIGluePeiReportStatusCodeLib.mak" +End + diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiReportStatusCodeLib/PeiReportStatusCodeLib.inf b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiReportStatusCodeLib/PeiReportStatusCodeLib.inf new file mode 100644 index 0000000..0e3f804 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiReportStatusCodeLib/PeiReportStatusCodeLib.inf @@ -0,0 +1,92 @@ +#/*++ +# +# 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: +# +# PeiReportStatusCodeLib.inf +# +# Abstract: +# +# Component description file for PeiReportStatusCodeLib. +# +#--*/ + +[defines] +BASE_NAME = EdkIIGluePeiReportStatusCodeLib +COMPONENT_TYPE = LIBRARY + +[sources.common] + ReportStatusCodeLib.c + +[sources.ia32] + + +[sources.x64] + + +[sources.ipf] + + +[sources.ebc] + + +[includes.common] + . + ..\..\Include + ..\..\include\Library + $(EDK_SOURCE)\Foundation + $(EDK_SOURCE)\Foundation\Include\Pei + $(EDK_SOURCE)\Foundation\Framework + $(EDK_SOURCE)\Foundation\Efi + $(EDK_SOURCE)\Foundation\Include + $(EDK_SOURCE)\Foundation\Efi\Include + $(EDK_SOURCE)\Foundation\Framework\Include + $(EDK_SOURCE)\Foundation\Include\IndustryStandard + $(EDK_SOURCE)\Foundation\Core\Dxe + $(EDK_SOURCE)\Foundation\Library\Dxe\Include + $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include + $(EDK_SOURCE)\Foundation\Framework\Guid\DataHubRecords + $(EDK_SOURCE)\Foundation\Framework\Guid\StatusCodeDataTypeId + +[libraries.common] + EdkIIGlueBaseLib + EdkIIGlueBaseMemoryLib + EdkIIGlueBaseIoLibIntrinsic + EdkIIGluePeiServicesTablePointerLibMm7 +# +# If necessary, EdkIIGluePeiServicesTablePointerLib can be used +# to replace EdkIIGluePeiServicesTablePointerLibMm7 +# + EdkFrameworkGuidLib +# Possibly, gEfiCallerIdGuid might be used. + EdkGuidLib + +[libraries.ia32] + + +[libraries.x64] + + +[nmake.common] + C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION + LIB_STD_FLAGS = /NOLOGO /IGNORE:4006 + +[nmake.ia32] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32 + +[nmake.x64] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64 + +[nmake.ipf] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF + +[nmake.ebc] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_EBC
\ No newline at end of file diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiReportStatusCodeLib/ReportStatusCodeLib.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiReportStatusCodeLib/ReportStatusCodeLib.c new file mode 100644 index 0000000..d4292f5 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiReportStatusCodeLib/ReportStatusCodeLib.c @@ -0,0 +1,527 @@ +/*++ + +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: + + ReportStatusCodeLib.c + +Abstract: + + Report Status Code Lib + +--*/ + +#include "EdkIIGluePeim.h" +#include "Pcd\EdkIIGluePcdReportStatusCodeLib.h" + +// +// Define the maximum extended data size that is supported in the PEI phase +// +#define MAX_EXTENDED_DATA_SIZE 0x200 + +/** + Internal worker function that reports a status code through the Status Code Protocol + + This function checks to see if a Status Code Protocol is present in the handle + database. If a Status Code Protocol is not present, then EFI_UNSUPPORTED is + returned. If a Status Code Protocol is present, then it is cached in gStatusCode, + and the ReportStatusCode() service of the Status Code Protocol is called passing in + Type, Value, Instance, CallerId, and Data. The result of this call is returned. + + @param Type Status code type. + @param Value Status code value. + @param Instance Status code instance number. + @param CallerId Pointer to a GUID that identifies the caller of this + function. This is an optional parameter that may be + NULL. + @param Data Pointer to the extended data buffer. This is an + optional parameter that may be NULL. + + @retval EFI_SUCCESS The status code was reported. + @retval EFI_OUT_OF_RESOURCES There were not enough resources to report the status code. + @retval EFI_UNSUPPORTED Status Code Protocol is not available. + +**/ +EFI_STATUS +InternalReportStatusCode ( + IN EFI_STATUS_CODE_TYPE Type, + IN EFI_STATUS_CODE_VALUE Value, + IN UINT32 Instance, + IN CONST EFI_GUID *CallerId OPTIONAL, + IN EFI_STATUS_CODE_DATA *Data OPTIONAL + ) +{ + EFI_PEI_SERVICES **PeiServices; + + PeiServices = GetPeiServicesTablePointer (); + return (*PeiServices)->PeiReportStatusCode ( + PeiServices, + Type, + Value, + Instance, + (EFI_GUID *)CallerId, + Data + ); +} + + +/** + Converts a status code to an 8-bit POST code value. + + Converts the status code specified by CodeType and Value to an 8-bit POST code + and returns the 8-bit POST code in PostCode. If CodeType is an + EFI_PROGRESS_CODE or CodeType is an EFI_ERROR_CODE, then bits 0..4 of PostCode + are set to bits 16..20 of Value, and bits 5..7 of PostCode are set to bits + 24..26 of Value., and TRUE is returned. Otherwise, FALSE is returned. + + If PostCode is NULL, then ASSERT(). + + @param CodeType The type of status code being converted. + @param Value The status code value being converted. + @param PostCode A pointer to the 8-bit POST code value to return. + + @retval TRUE The status code specified by CodeType and Value was converted + to an 8-bit POST code and returned in PostCode. + @retval FALSE The status code specified by CodeType and Value could not be + converted to an 8-bit POST code value. + +**/ +BOOLEAN +EFIAPI +GlueCodeTypeToPostCode ( + IN EFI_STATUS_CODE_TYPE CodeType, + IN EFI_STATUS_CODE_VALUE Value, + OUT UINT8 *PostCode + ) +{ + // + // If PostCode is NULL, then ASSERT() + // + ASSERT (PostCode != NULL); + + // + // Convert Value to an 8 bit post code + // + if (((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_PROGRESS_CODE) || + ((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE) ) { + *PostCode = (UINT8) (((Value & EFI_STATUS_CODE_CLASS_MASK) >> 24) << 5); + *PostCode |= (UINT8) (((Value & EFI_STATUS_CODE_SUBCLASS_MASK) >> 16) & 0x1f); + return TRUE; + } + return FALSE; +} + + +/** + Extracts ASSERT() information from a status code structure. + + Converts the status code specified by CodeType, Value, and Data to the ASSERT() + arguments specified by Filename, Description, and LineNumber. If CodeType is + an EFI_ERROR_CODE, and CodeType has a severity of EFI_ERROR_UNRECOVERED, and + Value has an operation mask of EFI_SW_EC_ILLEGAL_SOFTWARE_STATE, extract + Filename, Description, and LineNumber from the optional data area of the + status code buffer specified by Data. The optional data area of Data contains + a Null-terminated ASCII string for the FileName, followed by a Null-terminated + ASCII string for the Description, followed by a 32-bit LineNumber. If the + ASSERT() information could be extracted from Data, then return TRUE. + Otherwise, FALSE is returned. + + If Data is NULL, then ASSERT(). + If Filename is NULL, then ASSERT(). + If Description is NULL, then ASSERT(). + If LineNumber is NULL, then ASSERT(). + + @param CodeType The type of status code being converted. + @param Value The status code value being converted. + @param Data Pointer to status code data buffer. + @param Filename Pointer to the source file name that generated the ASSERT(). + @param Description Pointer to the description of the ASSERT(). + @param LineNumber Pointer to source line number that generated the ASSERT(). + + @retval TRUE The status code specified by CodeType, Value, and Data was + converted ASSERT() arguments specified by Filename, Description, + and LineNumber. + @retval FALSE The status code specified by CodeType, Value, and Data could + not be converted to ASSERT() arguments. + +**/ +BOOLEAN +EFIAPI +GlueReportStatusCodeExtractAssertInfo ( + IN EFI_STATUS_CODE_TYPE CodeType, + IN EFI_STATUS_CODE_VALUE Value, + IN CONST EFI_STATUS_CODE_DATA *Data, + OUT CHAR8 **Filename, + OUT CHAR8 **Description, + OUT UINT32 *LineNumber + ) +{ + EFI_DEBUG_ASSERT_DATA *AssertData; + + ASSERT (Data != NULL); + ASSERT (Filename != NULL); + ASSERT (Description != NULL); + ASSERT (LineNumber != NULL); + + if (((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE) && + ((CodeType & EFI_STATUS_CODE_SEVERITY_MASK) == EFI_ERROR_UNRECOVERED) && + ((Value & EFI_STATUS_CODE_OPERATION_MASK) == EFI_SW_EC_ILLEGAL_SOFTWARE_STATE)) { + AssertData = (EFI_DEBUG_ASSERT_DATA *)(Data + 1); + *Filename = (CHAR8 *)(AssertData + 1); + *Description = *Filename + AsciiStrLen (*Filename) + 1; + *LineNumber = AssertData->LineNumber; + return TRUE; + } + return FALSE; +} + + +/** + Extracts DEBUG() information from a status code structure. + + Converts the status code specified by Data to the DEBUG() arguments specified + by ErrorLevel, Marker, and Format. If type GUID in Data is + EFI_STATUS_CODE_DATA_TYPE_DEBUG_GUID, then extract ErrorLevel, Marker, and + Format from the optional data area of the status code buffer specified by Data. + The optional data area of Data contains a 32-bit ErrorLevel followed by Marker + which is 12 UINTN parameters, followed by a Null-terminated ASCII string for + the Format. If the DEBUG() information could be extracted from Data, then + return TRUE. Otherwise, FALSE is returned. + + If Data is NULL, then ASSERT(). + If ErrorLevel is NULL, then ASSERT(). + If Marker is NULL, then ASSERT(). + If Format is NULL, then ASSERT(). + + @param Data Pointer to status code data buffer. + @param ErrorLevel Pointer to error level mask for a debug message. + @param Marker Pointer to the variable argument list associated with Format. + @param Format Pointer to a Null-terminated ASCII format string of a + debug message. + + @retval TRUE The status code specified by Data was converted DEBUG() arguments + specified by ErrorLevel, Marker, and Format. + @retval FALSE The status code specified by Data could not be converted to + DEBUG() arguments. + +**/ +BOOLEAN +EFIAPI +GlueReportStatusCodeExtractDebugInfo ( + IN CONST EFI_STATUS_CODE_DATA *Data, + OUT UINT32 *ErrorLevel, + OUT VA_LIST *Marker, + OUT CHAR8 **Format + ) +{ + EFI_DEBUG_INFO *DebugInfo; + + ASSERT (Data != NULL); + ASSERT (ErrorLevel != NULL); + ASSERT (Marker != NULL); + ASSERT (Format != NULL); + + // + // If the GUID type is not EFI_STATUS_CODE_DATA_TYPE_DEBUG_GUID then return FALSE + // + if (!CompareGuid (&Data->Type, &gEfiStatusCodeDataTypeDebugGuid)) { + return FALSE; + } + + // + // Retrieve the debug information from the status code record + // + DebugInfo = (EFI_DEBUG_INFO *)(Data + 1); + + *ErrorLevel = DebugInfo->ErrorLevel; + + // + // The first 12 * UINTN bytes of the string are really an + // argument stack to support varargs on the Format string. + // + *Marker = (VA_LIST) (DebugInfo + 1); + *Format = (CHAR8 *)(((UINT64 *)*Marker) + 12); + + return TRUE; +} + + +/** + Reports a status code. + + Reports the status code specified by the parameters Type and Value. Status + code also require an instance, caller ID, and extended data. This function + passed in a zero instance, NULL extended data, and a caller ID of + gEfiCallerIdGuid, which is the GUID for the module. + + ReportStatusCode()must actively prevent recusrsion. If ReportStatusCode() + is called while processing another any other Report Status Code Library function, + then ReportStatusCode() must return immediately. + + @param Type Status code type. + @param Value Status code value. + + @retval EFI_SUCCESS The status code was reported. + @retval EFI_DEVICE_ERROR There status code could not be reported due to a + device error. + @retval EFI_UNSUPPORTED Report status code is not supported + +**/ +EFI_STATUS +EFIAPI +GlueReportStatusCode ( + IN EFI_STATUS_CODE_TYPE Type, + IN EFI_STATUS_CODE_VALUE Value + ) +{ + return InternalReportStatusCode (Type, Value, 0, &gEfiCallerIdGuid, NULL); +} + + +/** + Reports a status code with a Device Path Protocol as the extended data. + + Allocates and fills in the extended data section of a status code with the + Device Path Protocol specified by DevicePath. This function is responsible + for allocating a buffer large enough for the standard header and the device + path. The standard header is filled in with a GUID of + gEfiStatusCodeSpecificDataGuid. The status code is reported with a zero + instance and a caller ID of gEfiCallerIdGuid. + + ReportStatusCodeWithDevicePath()must actively prevent recursion. If + ReportStatusCodeWithDevicePath() is called while processing another any other + Report Status Code Library function, then ReportStatusCodeWithDevicePath() + must return EFI_DEVICE_ERROR immediately. + + If DevicePath is NULL, then ASSERT(). + + @param Type Status code type. + @param Value Status code value. + @param DevicePath Pointer to the Device Path Protocol to be reported. + + @retval EFI_SUCCESS The status code was reported with the extended + data specified by DevicePath. + @retval EFI_OUT_OF_RESOURCES There were not enough resources to allocate the + extended data section. + @retval EFI_UNSUPPORTED Report status code is not supported + +**/ +EFI_STATUS +EFIAPI +GlueReportStatusCodeWithDevicePath ( + IN EFI_STATUS_CODE_TYPE Type, + IN EFI_STATUS_CODE_VALUE Value, + IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath + ) +{ + ASSERT (DevicePath != NULL); + return EFI_UNSUPPORTED; +} + + +/** + Reports a status code with an extended data buffer. + + Allocates and fills in the extended data section of a status code with the + extended data specified by ExtendedData and ExtendedDataSize. ExtendedData + is assumed to be one of the data structures specified in Related Definitions. + These data structure do not have the standard header, so this function is + responsible for allocating a buffer large enough for the standard header and + the extended data passed into this function. The standard header is filled + in with a GUID of gEfiStatusCodeSpecificDataGuid. The status code is reported + with a zero instance and a caller ID of gEfiCallerIdGuid. + + ReportStatusCodeWithExtendedData()must actively prevent recursion. If + ReportStatusCodeWithExtendedData() is called while processing another any other + Report Status Code Library function, then ReportStatusCodeWithExtendedData() + must return EFI_DEVICE_ERROR immediately. + + If ExtendedData is NULL, then ASSERT(). + If ExtendedDataSize is 0, then ASSERT(). + + @param Type Status code type. + @param Value Status code value. + @param ExtendedData Pointer to the extended data buffer to be reported. + @param ExtendedDataSize The size, in bytes, of the extended data buffer to + be reported. + + @retval EFI_SUCCESS The status code was reported with the extended + data specified by ExtendedData and ExtendedDataSize. + @retval EFI_OUT_OF_RESOURCES There were not enough resources to allocate the + extended data section. + @retval EFI_UNSUPPORTED Report status code is not supported + +**/ +EFI_STATUS +EFIAPI +GlueReportStatusCodeWithExtendedData ( + IN EFI_STATUS_CODE_TYPE Type, + IN EFI_STATUS_CODE_VALUE Value, + IN CONST VOID *ExtendedData, + IN UINTN ExtendedDataSize + ) +{ + ASSERT (ExtendedData != NULL); + ASSERT (ExtendedDataSize != 0); + return ReportStatusCodeEx ( + Type, + Value, + 0, + NULL, + NULL, + ExtendedData, + ExtendedDataSize + ); +} + + +/** + Reports a status code with full parameters. + + The function reports a status code. If ExtendedData is NULL and ExtendedDataSize + is 0, then an extended data buffer is not reported. If ExtendedData is not + NULL and ExtendedDataSize is not 0, then an extended data buffer is allocated. + ExtendedData is assumed not have the standard status code header, so this function + is responsible for allocating a buffer large enough for the standard header and + the extended data passed into this function. The standard header is filled in + with a GUID specified by ExtendedDataGuid. If ExtendedDataGuid is NULL, then a + GUID of gEfiStatusCodeSpecificDatauid is used. The status code is reported with + an instance specified by Instance and a caller ID specified by CallerId. If + CallerId is NULL, then a caller ID of gEfiCallerIdGuid is used. + + ReportStatusCodeEx()must actively prevent recursion. If ReportStatusCodeEx() + is called while processing another any other Report Status Code Library function, + then ReportStatusCodeEx() must return EFI_DEVICE_ERROR immediately. + + If ExtendedData is NULL and ExtendedDataSize is not zero, then ASSERT(). + If ExtendedData is not NULL and ExtendedDataSize is zero, then ASSERT(). + + @param Type Status code type. + @param Value Status code value. + @param Instance Status code instance number. + @param CallerId Pointer to a GUID that identifies the caller of this + function. If this parameter is NULL, then a caller + ID of gEfiCallerIdGuid is used. + @param ExtendedDataGuid Pointer to the GUID for the extended data buffer. + If this parameter is NULL, then a the status code + standard header is filled in with + gEfiStatusCodeSpecificDataGuid. + @param ExtendedData Pointer to the extended data buffer. This is an + optional parameter that may be NULL. + @param ExtendedDataSize The size, in bytes, of the extended data buffer. + + @retval EFI_SUCCESS The status code was reported. + @retval EFI_OUT_OF_RESOURCES There were not enough resources to allocate + the extended data section if it was specified. + @retval EFI_UNSUPPORTED Report status code is not supported + +**/ +EFI_STATUS +EFIAPI +GlueReportStatusCodeEx ( + IN EFI_STATUS_CODE_TYPE Type, + IN EFI_STATUS_CODE_VALUE Value, + IN UINT32 Instance, + IN CONST EFI_GUID *CallerId OPTIONAL, + IN CONST EFI_GUID *ExtendedDataGuid OPTIONAL, + IN CONST VOID *ExtendedData OPTIONAL, + IN UINTN ExtendedDataSize + ) +{ + EFI_STATUS_CODE_DATA *StatusCodeData; + UINT64 Buffer[MAX_EXTENDED_DATA_SIZE / sizeof (UINT64)]; + + ASSERT (!((ExtendedData == NULL) && (ExtendedDataSize != 0))); + ASSERT (!((ExtendedData != NULL) && (ExtendedDataSize == 0))); + + if (ExtendedDataSize > (MAX_EXTENDED_DATA_SIZE - sizeof (EFI_STATUS_CODE_DATA))) { + return EFI_OUT_OF_RESOURCES; + } + StatusCodeData = (EFI_STATUS_CODE_DATA *)Buffer; + StatusCodeData->HeaderSize = sizeof (EFI_STATUS_CODE_DATA); + StatusCodeData->Size = (UINT16)ExtendedDataSize; + if (ExtendedDataGuid == NULL) { + ExtendedDataGuid = &gEfiStatusCodeSpecificDataGuid; + } + CopyGuid (&StatusCodeData->Type, ExtendedDataGuid); + CopyMem (StatusCodeData + 1, ExtendedData, ExtendedDataSize); + if (CallerId == NULL) { + CallerId = &gEfiCallerIdGuid; + } + return InternalReportStatusCode (Type, Value, Instance, CallerId, StatusCodeData); +} + + +/** + Returns TRUE if status codes of type EFI_PROGRESS_CODE are enabled + + This function returns TRUE if the REPORT_STATUS_CODE_PROPERTY_PROGRESS_CODE_ENABLED + bit of PcdReportStatusCodeProperyMask is set. Otherwise FALSE is returned. + + @retval TRUE The REPORT_STATUS_CODE_PROPERTY_PROGRESS_CODE_ENABLED bit of + PcdReportStatusCodeProperyMask is set. + @retval FALSE The REPORT_STATUS_CODE_PROPERTY_PROGRESS_CODE_ENABLED bit of + PcdReportStatusCodeProperyMask is clear. + +**/ +BOOLEAN +EFIAPI +GlueReportProgressCodeEnabled ( + VOID + ) +{ + return ((PcdGet8(PcdReportStatusCodePropertyMask) & REPORT_STATUS_CODE_PROPERTY_PROGRESS_CODE_ENABLED) != 0); +} + + +/** + Returns TRUE if status codes of type EFI_ERROR_CODE are enabled + + This function returns TRUE if the REPORT_STATUS_CODE_PROPERTY_ERROR_CODE_ENABLED + bit of PcdReportStatusCodeProperyMask is set. Otherwise FALSE is returned. + + @retval TRUE The REPORT_STATUS_CODE_PROPERTY_ERROR_CODE_ENABLED bit of + PcdReportStatusCodeProperyMask is set. + @retval FALSE The REPORT_STATUS_CODE_PROPERTY_ERROR_CODE_ENABLED bit of + PcdReportStatusCodeProperyMask is clear. + +**/ +BOOLEAN +EFIAPI +GlueReportErrorCodeEnabled ( + VOID + ) +{ + return ((PcdGet8(PcdReportStatusCodePropertyMask) & REPORT_STATUS_CODE_PROPERTY_ERROR_CODE_ENABLED) != 0); +} + + +/** + Returns TRUE if status codes of type EFI_DEBUG_CODE are enabled + + This function returns TRUE if the REPORT_STATUS_CODE_PROPERTY_DEBUG_CODE_ENABLED + bit of PcdReportStatusCodeProperyMask is set. Otherwise FALSE is returned. + + @retval TRUE The REPORT_STATUS_CODE_PROPERTY_DEBUG_CODE_ENABLED bit of + PcdReportStatusCodeProperyMask is set. + @retval FALSE The REPORT_STATUS_CODE_PROPERTY_DEBUG_CODE_ENABLED bit of + PcdReportStatusCodeProperyMask is clear. + +**/ +BOOLEAN +EFIAPI +GlueReportDebugCodeEnabled ( + VOID + ) +{ + return ((PcdGet8(PcdReportStatusCodePropertyMask) & REPORT_STATUS_CODE_PROPERTY_DEBUG_CODE_ENABLED) != 0); +} diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiResourcePublicationLib/EdkIIGluePeiResourcePublicationLib.cif b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiResourcePublicationLib/EdkIIGluePeiResourcePublicationLib.cif new file mode 100644 index 0000000..505f666 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiResourcePublicationLib/EdkIIGluePeiResourcePublicationLib.cif @@ -0,0 +1,11 @@ +<component> + name = "EdkIIGluePeiResourcePublicationLib" + category = ModulePart + LocalRoot = "Edk\Foundation\Library\EdkIIGlueLib\Library\PeiResourcePublicationLib" + RefName = "EdkIIGluePeiResourcePublicationLib" +[files] +"EdkIIGluePeiResourcePublicationLib.sdl" +"EdkIIGluePeiResourcePublicationLib.mak" +"PeiResourcePublicationLib.inf" +"PeiResourcePublicationLib.c" +<endComponent> diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiResourcePublicationLib/EdkIIGluePeiResourcePublicationLib.mak b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiResourcePublicationLib/EdkIIGluePeiResourcePublicationLib.mak new file mode 100644 index 0000000..37632da --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiResourcePublicationLib/EdkIIGluePeiResourcePublicationLib.mak @@ -0,0 +1,80 @@ +#********************************************************************** +#********************************************************************** +#** ** +#** (C)Copyright 1985-2009, American Megatrends, Inc. ** +#** ** +#** All Rights Reserved. ** +#** ** +#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +#** ** +#** Phone: (770)-246-8600 ** +#** ** +#********************************************************************** +#********************************************************************** + +#********************************************************************** +# $Header: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGluePeiResourcePublicationLib/EdkIIGluePeiResourcePublicationLib.mak 1 1/20/12 3:57a Jeffch $ +# +# $Revision: 1 $ +# +# $Date: 1/20/12 3:57a $ +#********************************************************************** +# Revision History +# ---------------- +# $Log: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGluePeiResourcePublicationLib/EdkIIGluePeiResourcePublicationLib.mak $ +# +# 1 1/20/12 3:57a Jeffch +# Create Intel EDK 1117 Patch 7. +# +# 1 9/27/11 6:19a Wesleychen +# Intel EDK initially releases. +# +# 1 9/18/09 1:57a Iminglin +# +#********************************************************************** +#<AMI_FHDR_START> +# +# Name: EdkIIGluePeiResourcePublicationLib.mak +# +# Description: +# +#<AMI_FHDR_END> +#********************************************************************** + + +$(EdkIIGluePeiResourcePublicationLib_LIB) : EdkIIGluePeiResourcePublicationLib + +EdkIIGluePeiResourcePublicationLib : $(BUILD_DIR)\EdkIIGluePeiResourcePublicationLib.mak EdkIIGluePeiResourcePublicationLibBin + +$(BUILD_DIR)\EdkIIGluePeiResourcePublicationLib.mak : $(EdkIIGluePeiResourcePublicationLib_DIR)\$(@B).cif $(EdkIIGluePeiResourcePublicationLib_DIR)\$(@B).mak $(BUILD_RULES) + $(CIF2MAK) $(EdkIIGluePeiResourcePublicationLib_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS) + +EdkIIGluePeiResourcePublicationLibBin : $(EdkIIGluePeiServicesLib_LIB) +!IF "$(x64_BUILD)"=="1" + $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\ + BUILD_DIR=$(BUILD_DIR)\ + /f $(BUILD_DIR)\EdkIIGluePeiResourcePublicationLib.mak all\ + TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGluePeiResourcePublicationLib_LIB)" + $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\ + BUILD_DIR=$(BUILD_DIR)\IA32\ + /f $(BUILD_DIR)\EdkIIGluePeiResourcePublicationLib.mak all\ + TYPE=PEI_LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGluePeiResourcePublicationLib_LIB)" +!ELSE + $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\ + BUILD_DIR=$(BUILD_DIR)\ + /f $(BUILD_DIR)\EdkIIGluePeiResourcePublicationLib.mak all\ + TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGluePeiResourcePublicationLib_LIB)" +!ENDIF +#********************************************************************** +#********************************************************************** +#** ** +#** (C)Copyright 1985-2009, American Megatrends, Inc. ** +#** ** +#** All Rights Reserved. ** +#** ** +#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +#** ** +#** Phone: (770)-246-8600 ** +#** ** +#********************************************************************** +#**********************************************************************
\ No newline at end of file diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiResourcePublicationLib/EdkIIGluePeiResourcePublicationLib.sdl b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiResourcePublicationLib/EdkIIGluePeiResourcePublicationLib.sdl new file mode 100644 index 0000000..4ccd6f1 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiResourcePublicationLib/EdkIIGluePeiResourcePublicationLib.sdl @@ -0,0 +1,26 @@ +TOKEN + Name = "EdkIIGluePeiResourcePublicationLib_SUPPORT" + Value = "1" + Help = "Main switch to enable EdkIIGluePeiResourcePublicationLib support in Project" + TokenType = Boolean + TargetEQU = Yes + TargetMAK = Yes + Master = Yes +End + +TOKEN + Name = "EdkIIGluePeiResourcePublicationLib_LIB" + Value = "$$(LIB_BUILD_DIR)\EdkIIGluePeiResourcePublicationLib.lib" + TokenType = Expression + TargetMAK = Yes +End + +PATH + Name = "EdkIIGluePeiResourcePublicationLib_DIR" +End + +MODULE + Help = "Includes EdkIIGluePeiResourcePublicationLib.mak to Project" + File = "EdkIIGluePeiResourcePublicationLib.mak" +End + diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiResourcePublicationLib/PeiResourcePublicationLib.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiResourcePublicationLib/PeiResourcePublicationLib.c new file mode 100644 index 0000000..726493d --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiResourcePublicationLib/PeiResourcePublicationLib.c @@ -0,0 +1,57 @@ +/*++ + +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: + + PeiResourcePublicationLib.c + +Abstract: + + Resource Publication Library that uses PEI Core Services to publish system memory. + +--*/ + +#include "EdkIIGluePeim.h" + +/** + + Declares the presence of permanent system memory in the platform. + + Declares that the system memory buffer specified by MemoryBegin and MemoryLength + as permanent memory that may be used for general purpose use by software. + The amount of memory available to software may be less than MemoryLength + if published memory has alignment restrictions. + + @param MemoryBegin The start address of the memory being declared. + @param MemoryLength The number of bytes of memory being declared. + + @retval RETURN_SUCCESS The memory buffer was published. + @retval RETURN_OUT_OF_RESOURCES There are not enough resources to publish the memory buffer + +**/ +RETURN_STATUS +EFIAPI +PublishSystemMemory ( + IN PHYSICAL_ADDRESS MemoryBegin, + IN UINT64 MemoryLength + ) +{ + EFI_STATUS Status; + + ASSERT (MemoryLength > 0); + ASSERT (MemoryLength <= (MAX_ADDRESS - MemoryBegin + 1)); + + Status = PeiServicesInstallPeiMemory (MemoryBegin, MemoryLength); + + return (RETURN_STATUS) Status; +} + diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiResourcePublicationLib/PeiResourcePublicationLib.inf b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiResourcePublicationLib/PeiResourcePublicationLib.inf new file mode 100644 index 0000000..a568773 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiResourcePublicationLib/PeiResourcePublicationLib.inf @@ -0,0 +1,79 @@ +#/*++ +# +# 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: +# +# PeiResourcePublication.inf +# +# Abstract: +# +# Component description file for PeiResourcePublication. +# +#--*/ + +[defines] +BASE_NAME = EdkIIGluePeiResourcePublicationLib +COMPONENT_TYPE = LIBRARY + +[sources.common] + PeiResourcePublicationLib.c + +[sources.ia32] + +[sources.x64] + +[sources.ipf] + +[sources.ebc] + + +[includes.common] + . + ..\..\Include + ..\..\include\Library + $(EDK_SOURCE)\Foundation + $(EDK_SOURCE)\Foundation\Framework + $(EDK_SOURCE)\Foundation\Include\Pei + $(EDK_SOURCE)\Foundation\Efi + $(EDK_SOURCE)\Foundation\Include + $(EDK_SOURCE)\Foundation\Include\Pei + $(EDK_SOURCE)\Foundation\Efi\Include + $(EDK_SOURCE)\Foundation\Framework\Include + $(EDK_SOURCE)\Foundation\Include\IndustryStandard + $(EDK_SOURCE)\Foundation\Core\Dxe + $(EDK_SOURCE)\Foundation\Library\Pei\Include + $(EDK_SOURCE)\Foundation\Library\Dxe\Include + $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include + +[libraries.common] + EdkIIGluePeiServicesLib + +[libraries.ia32] + + +[libraries.x64] + + +[nmake.common] + C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION + LIB_STD_FLAGS = /NOLOGO /IGNORE:4006 + +[nmake.ia32] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32 + +[nmake.x64] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64 + +[nmake.ipf] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF + +[nmake.ebc] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_EBC
\ No newline at end of file diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiServicesLib/EdkIIGluePeiServicesLib.cif b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiServicesLib/EdkIIGluePeiServicesLib.cif new file mode 100644 index 0000000..cf46ede --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiServicesLib/EdkIIGluePeiServicesLib.cif @@ -0,0 +1,11 @@ +<component> + name = "EdkIIGluePeiServicesLib" + category = ModulePart + LocalRoot = "Edk\Foundation\Library\EdkIIGlueLib\Library\PeiServicesLib" + RefName = "EdkIIGluePeiServicesLib" +[files] +"EdkIIGluePeiServicesLib.sdl" +"EdkIIGluePeiServicesLib.mak" +"PeiServicesLib.inf" +"PeiServicesLib.c" +<endComponent> diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiServicesLib/EdkIIGluePeiServicesLib.mak b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiServicesLib/EdkIIGluePeiServicesLib.mak new file mode 100644 index 0000000..c5cbc56 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiServicesLib/EdkIIGluePeiServicesLib.mak @@ -0,0 +1,88 @@ +#********************************************************************** +#********************************************************************** +#** ** +#** (C)Copyright 1985-2009, American Megatrends, Inc. ** +#** ** +#** All Rights Reserved. ** +#** ** +#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +#** ** +#** Phone: (770)-246-8600 ** +#** ** +#********************************************************************** +#********************************************************************** + +#********************************************************************** +# $Header: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGluePeiServicesLib/EdkIIGluePeiServicesLib.mak 2 2/24/12 5:01a Jeffch $ +# +# $Revision: 2 $ +# +# $Date: 2/24/12 5:01a $ +#********************************************************************** +# Revision History +# ---------------- +# $Log: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGluePeiServicesLib/EdkIIGluePeiServicesLib.mak $ +# +# 2 2/24/12 5:01a Jeffch +# +# 1 1/20/12 3:57a Jeffch +# Create Intel EDK 1117 Patch 7. +# +# 1 9/27/11 6:19a Wesleychen +# Intel EDK initially releases. +# +# 1 9/18/09 1:57a Iminglin +# +#********************************************************************** +#<AMI_FHDR_START> +# +# Name: EdkIIGluePeiServicesLib.mak +# +# Description: +# +#<AMI_FHDR_END> +#********************************************************************** + + +$(EdkIIGluePeiServicesLib_LIB) : EdkIIGluePeiServicesLib + +EdkIIGluePeiServicesLib : $(BUILD_DIR)\EdkIIGluePeiServicesLib.mak EdkIIGluePeiServicesLibBin + +$(BUILD_DIR)\EdkIIGluePeiServicesLib.mak : $(EdkIIGluePeiServicesLib_DIR)\$(@B).cif $(EdkIIGluePeiServicesLib_DIR)\$(@B).mak $(BUILD_RULES) + $(CIF2MAK) $(EdkIIGluePeiServicesLib_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS) + +EdkIIGluePeiServicesLib_LIB_LINKS=\ +$(EDKFRAMEWORKPPILIB)\ +!IF "$(PROCESSOR)"=="IA32" || "$(PROCESSOR)"=="x64" +$(EdkIIGluePeiServicesTablePointerLibMm7_LIB) +!ENDIF + +EdkIIGluePeiServicesLibBin : $(EdkIIGluePeiServicesLib_LIB_LINKS) +!IF "$(x64_BUILD)"=="1" + $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\ + BUILD_DIR=$(BUILD_DIR)\ + /f $(BUILD_DIR)\EdkIIGluePeiServicesLib.mak all\ + TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGluePeiServicesLib_LIB)" + $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\ + BUILD_DIR=$(BUILD_DIR)\IA32\ + /f $(BUILD_DIR)\EdkIIGluePeiServicesLib.mak all\ + TYPE=PEI_LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGluePeiServicesLib_LIB)" +!ELSE + $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\ + BUILD_DIR=$(BUILD_DIR)\ + /f $(BUILD_DIR)\EdkIIGluePeiServicesLib.mak all\ + TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGluePeiServicesLib_LIB)" +!ENDIF +#********************************************************************** +#********************************************************************** +#** ** +#** (C)Copyright 1985-2009, American Megatrends, Inc. ** +#** ** +#** All Rights Reserved. ** +#** ** +#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +#** ** +#** Phone: (770)-246-8600 ** +#** ** +#********************************************************************** +#********************************************************************** diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiServicesLib/EdkIIGluePeiServicesLib.sdl b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiServicesLib/EdkIIGluePeiServicesLib.sdl new file mode 100644 index 0000000..7f71919 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiServicesLib/EdkIIGluePeiServicesLib.sdl @@ -0,0 +1,26 @@ +TOKEN + Name = "EdkIIGluePeiServicesLib_SUPPORT" + Value = "1" + Help = "Main switch to enable EdkIIGluePeiServicesLib support in Project" + TokenType = Boolean + TargetEQU = Yes + TargetMAK = Yes + Master = Yes +End + +TOKEN + Name = "EdkIIGluePeiServicesLib_LIB" + Value = "$$(LIB_BUILD_DIR)\EdkIIGluePeiServicesLib.lib" + TokenType = Expression + TargetMAK = Yes +End + +PATH + Name = "EdkIIGluePeiServicesLib_DIR" +End + +MODULE + Help = "Includes EdkIIGluePeiServicesLib.mak to Project" + File = "EdkIIGluePeiServicesLib.mak" +End + diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiServicesLib/PeiServicesLib.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiServicesLib/PeiServicesLib.c new file mode 100644 index 0000000..b5df45e --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiServicesLib/PeiServicesLib.c @@ -0,0 +1,470 @@ +/*++ + +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: + + PeiServicesLib.c + +Abstract: + + PEI Services Lib + +--*/ + +#include "EdkIIGluePeim.h" + +/** + This service enables a given PEIM to register an interface into the PEI Foundation. + + @param PpiList A pointer to the list of interfaces that the caller shall install. + + @retval EFI_SUCCESS The interface was successfully installed. + @retval EFI_INVALID_PARAMETER The PpiList pointer is NULL. + @retval EFI_INVALID_PARAMETER Any of the PEI PPI descriptors in the list do not have the + EFI_PEI_PPI_DESCRIPTOR_PPI bit set in the Flags field. + @retval EFI_OUT_OF_RESOURCES There is no additional space in the PPI database. + +**/ +EFI_STATUS +EFIAPI +PeiServicesInstallPpi ( + IN EFI_PEI_PPI_DESCRIPTOR *PpiList + ) +{ + EFI_PEI_SERVICES **PeiServices; + + PeiServices = GetPeiServicesTablePointer (); + return (*PeiServices)->InstallPpi (PeiServices, PpiList); +} + +/** + This service enables PEIMs to replace an entry in the PPI database with an alternate entry. + + @param OldPpi Pointer to the old PEI PPI Descriptors. + @param NewPpi Pointer to the new PEI PPI Descriptors. + + @retval EFI_SUCCESS The interface was successfully installed. + @retval EFI_INVALID_PARAMETER The OldPpi or NewPpi is NULL. + @retval EFI_INVALID_PARAMETER Any of the PEI PPI descriptors in the list do not have the + EFI_PEI_PPI_DESCRIPTOR_PPI bit set in the Flags field. + @retval EFI_OUT_OF_RESOURCES There is no additional space in the PPI database. + @retval EFI_NOT_FOUND The PPI for which the reinstallation was requested has not been + installed. + +**/ +EFI_STATUS +EFIAPI +PeiServicesReInstallPpi ( + IN EFI_PEI_PPI_DESCRIPTOR *OldPpi, + IN EFI_PEI_PPI_DESCRIPTOR *NewPpi + ) +{ + EFI_PEI_SERVICES **PeiServices; + + PeiServices = GetPeiServicesTablePointer (); + return (*PeiServices)->ReInstallPpi (PeiServices, OldPpi, NewPpi); +} + +/** + This service enables PEIMs to discover a given instance of an interface. + + @param Guid A pointer to the GUID whose corresponding interface needs to be + found. + @param Instance The N-th instance of the interface that is required. + @param PpiDescriptor A pointer to instance of the EFI_PEI_PPI_DESCRIPTOR. + @param Ppi A pointer to the instance of the interface. + + @retval EFI_SUCCESS The interface was successfully returned. + @retval EFI_NOT_FOUND The PPI descriptor is not found in the database. + +**/ +EFI_STATUS +EFIAPI +PeiServicesLocatePpi ( + IN EFI_GUID *Guid, + IN UINTN Instance, + IN OUT EFI_PEI_PPI_DESCRIPTOR **PpiDescriptor, + IN OUT VOID **Ppi + ) +{ + EFI_PEI_SERVICES **PeiServices; + + PeiServices = GetPeiServicesTablePointer (); + return (*PeiServices)->LocatePpi (PeiServices, Guid, Instance, PpiDescriptor, Ppi); +} + +/** + This service enables PEIMs to register a given service to be invoked when another service is + installed or reinstalled. + + @param NotifyList A pointer to the list of notification interfaces that the caller + shall install. + + @retval EFI_SUCCESS The interface was successfully installed. + @retval EFI_INVALID_PARAMETER The NotifyList pointer is NULL. + @retval EFI_INVALID_PARAMETER Any of the PEI notify descriptors in the list do not have the + EFI_PEI_PPI_DESCRIPTOR_NOTIFY_TYPES bit set in the Flags field. + @retval EFI_OUT_OF_RESOURCES There is no additional space in the PPI database. + +**/ +EFI_STATUS +EFIAPI +PeiServicesNotifyPpi ( + IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyList + ) +{ + EFI_PEI_SERVICES **PeiServices; + + PeiServices = GetPeiServicesTablePointer (); + return (*PeiServices)->NotifyPpi (PeiServices, NotifyList); +} + +/** + This service enables PEIMs to ascertain the present value of the boot mode. + + @param BootMode A pointer to contain the value of the boot mode. + + @retval EFI_SUCCESS The boot mode was returned successfully. + @retval EFI_INVALID_PARAMETER BootMode is NULL. + +**/ +EFI_STATUS +EFIAPI +PeiServicesGetBootMode ( + IN OUT EFI_BOOT_MODE *BootMode + ) +{ + EFI_PEI_SERVICES **PeiServices; + + PeiServices = GetPeiServicesTablePointer (); + return (*PeiServices)->GetBootMode (PeiServices, BootMode); +} + +/** + This service enables PEIMs to update the boot mode variable. + + @param BootMode The value of the boot mode to set. + + @retval EFI_SUCCESS The value was successfully updated + +**/ +EFI_STATUS +EFIAPI +PeiServicesSetBootMode ( + IN EFI_BOOT_MODE BootMode + ) +{ + EFI_PEI_SERVICES **PeiServices; + + PeiServices = GetPeiServicesTablePointer (); + return (*PeiServices)->SetBootMode (PeiServices, BootMode); +} + +/** + This service enables a PEIM to ascertain the address of the list of HOBs in memory. + + @param HobList A pointer to the list of HOBs that the PEI Foundation will initialize. + + @retval EFI_SUCCESS The list was successfully returned. + @retval EFI_NOT_AVAILABLE_YET The HOB list is not yet published. + +**/ +EFI_STATUS +EFIAPI +PeiServicesGetHobList ( + IN OUT VOID **HobList + ) +{ + EFI_PEI_SERVICES **PeiServices; + + PeiServices = GetPeiServicesTablePointer (); + return (*PeiServices)->GetHobList (PeiServices, HobList); +} + +/** + This service enables PEIMs to create various types of HOBs. + + @param Type The type of HOB to be installed. + @param Length The length of the HOB to be added. + @param Hob The address of a pointer that will contain the HOB header. + + @retval EFI_SUCCESS The HOB was successfully created. + @retval EFI_OUT_OF_RESOURCES There is no additional space for HOB creation. + +**/ +EFI_STATUS +EFIAPI +PeiServicesCreateHob ( + IN UINT16 Type, + IN UINT16 Length, + IN OUT VOID **Hob + ) +{ + EFI_PEI_SERVICES **PeiServices; + + PeiServices = GetPeiServicesTablePointer (); + return (*PeiServices)->CreateHob (PeiServices, Type, Length, Hob); +} + +//;;## ...AMI_OVERRIDE... Support PI1.x +#if (PI_SPECIFICATION_VERSION < 0x00010000) +/** + This service enables PEIMs to discover additional firmware volumes. + + @param Instance This instance of the firmware volume to find. The value 0 is the + Boot Firmware Volume (BFV). + @param FwVolHeader Pointer to the firmware volume header of the volume to return. + + @retval EFI_SUCCESS The volume was found. + @retval EFI_NOT_FOUND The volume was not found. + @retval EFI_INVALID_PARAMETER FwVolHeader is NULL. + +**/ +EFI_STATUS +EFIAPI +PeiServicesFfsFindNextVolume ( + IN UINTN Instance, + IN OUT EFI_FIRMWARE_VOLUME_HEADER **FwVolHeader + ) +{ + EFI_PEI_SERVICES **PeiServices; + + PeiServices = GetPeiServicesTablePointer (); + return (*PeiServices)->FfsFindNextVolume (PeiServices, Instance, FwVolHeader); +} + +/** + This service enables PEIMs to discover additional firmware files. + + @param SearchType A filter to find files only of this type. + @param FwVolHeader Pointer to the firmware volume header of the volume to search. + This parameter must point to a valid FFS volume. + @param FileHeader Pointer to the current file from which to begin searching. + + @retval EFI_SUCCESS The file was found. + @retval EFI_NOT_FOUND The file was not found. + @retval EFI_NOT_FOUND The header checksum was not zero. + +**/ +EFI_STATUS +EFIAPI +PeiServicesFfsFindNextFile ( + IN EFI_FV_FILETYPE SearchType, + IN EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader, + IN OUT EFI_FFS_FILE_HEADER **FileHeader + ) +{ + EFI_PEI_SERVICES **PeiServices; + + PeiServices = GetPeiServicesTablePointer (); + return (*PeiServices)->FfsFindNextFile (PeiServices, SearchType, FwVolHeader, FileHeader); +} + +/** + This service enables PEIMs to discover sections of a given type within a valid FFS file. + + @param SearchType The value of the section type to find. + @param FfsFileHeader A pointer to the file header that contains the set of sections to + be searched. + @param SectionData A pointer to the discovered section, if successful. + + @retval EFI_SUCCESS The section was found. + @retval EFI_NOT_FOUND The section was not found. + +**/ +EFI_STATUS +EFIAPI +PeiServicesFfsFindSectionData ( + IN EFI_SECTION_TYPE SectionType, + IN EFI_FFS_FILE_HEADER *FfsFileHeader, + IN OUT VOID **SectionData + ) +{ + EFI_PEI_SERVICES **PeiServices; + + PeiServices = GetPeiServicesTablePointer (); + return (*PeiServices)->FfsFindSectionData (PeiServices, SectionType, FfsFileHeader, SectionData); +} +#endif + +/** + This service enables PEIMs to register the permanent memory configuration + that has been initialized with the PEI Foundation. + + @param MemoryBegin The value of a region of installed memory. + @param MemoryLength The corresponding length of a region of installed memory. + + @retval EFI_SUCCESS The region was successfully installed in a HOB. + @retval EFI_INVALID_PARAMETER MemoryBegin and MemoryLength are illegal for this system. + @retval EFI_OUT_OF_RESOURCES There is no additional space for HOB creation. + +**/ +EFI_STATUS +EFIAPI +PeiServicesInstallPeiMemory ( + IN EFI_PHYSICAL_ADDRESS MemoryBegin, + IN UINT64 MemoryLength + ) +{ + EFI_PEI_SERVICES **PeiServices; + + PeiServices = GetPeiServicesTablePointer (); + return (*PeiServices)->InstallPeiMemory (PeiServices, MemoryBegin, MemoryLength); +} + +/** + This service enables PEIMs to allocate memory after the permanent memory has been installed by a + PEIM. + + @param MemoryType Type of memory to allocate. + @param Pages Number of pages to allocate. + @param Memory Pointer of memory allocated. + + @retval EFI_SUCCESS The memory range was successfully allocated. + @retval EFI_INVALID_PARAMETER Type is not equal to AllocateAnyPages. + @retval EFI_NOT_AVAILABLE_YET Called with permanent memory not available. + @retval EFI_OUT_OF_RESOURCES The pages could not be allocated. + +**/ +EFI_STATUS +EFIAPI +PeiServicesAllocatePages ( + IN EFI_MEMORY_TYPE MemoryType, + IN UINTN Pages, + IN OUT EFI_PHYSICAL_ADDRESS *Memory + ) +{ + EFI_PEI_SERVICES **PeiServices; + + PeiServices = GetPeiServicesTablePointer (); + return ((*PeiServices)->AllocatePages) (PeiServices, MemoryType, Pages, Memory); +} + +/** + This service allocates memory from the Hand-Off Block (HOB) heap. + + @param Size The number of bytes to allocate from the pool. + @param Buffer If the call succeeds, a pointer to a pointer to the allocate + buffer; undefined otherwise. + + @retval EFI_SUCCESS The allocation was successful + @retval EFI_OUT_OF_RESOURCES There is not enough heap to allocate the requested size. + +**/ +EFI_STATUS +EFIAPI +PeiServicesAllocatePool ( + IN UINTN Size, + OUT VOID **Buffer + ) +{ + EFI_PEI_SERVICES **PeiServices; + + PeiServices = GetPeiServicesTablePointer (); + return ((*PeiServices)->AllocatePool) (PeiServices, Size, Buffer); +} + +/** + This service resets the entire platform, including all processors and devices, and reboots the + system. + + @retval EFI_NOT_AVAILABLE_YET The service has not been installed yet. + +**/ +EFI_STATUS +EFIAPI +PeiServicesResetSystem ( + VOID + ) +{ + EFI_PEI_SERVICES **PeiServices; + + PeiServices = GetPeiServicesTablePointer (); + return (*PeiServices)->PeiResetSystem (PeiServices); +} +/** + PCI read-modify-write operations. + + PIWG's PI specification replaces Inte's EFI Specification 1.10. + EFI_PEI_PCI_CFG_PPI defined in Inte's EFI Specification 1.10 is replaced by + EFI_PEI_PCI_CFG2_PPI in PI 1.0. "Modify" function in these two PPI are not + compatibile with each other. + + For Framework code that make the following call: + PciCfg->Modify ( + PeiServices, + PciCfg, + Width, + Address, + SetBits, + ClearBits + ); + it will be updated to the following code which call this library API: + PeiLibPciCfgModify ( + PeiServices, + PciCfg, + Width, + Address, + SetBits, + ClearBits + ); + + @param PeiServices An indirect pointer to the PEI Services Table + published by the PEI Foundation. + @param PciCfg A pointer to the this pointer of EFI_PEI_PCI_CFG_PPI. + This parameter is unused as a place holder to make + the parameter list identical to PEI_PCI_CFG_PPI_RW. + @param Width The width of the access. Enumerated in bytes. Type + EFI_PEI_PCI_CFG_PPI_WIDTH is defined in Read(). + @param Address The physical address of the access. + @param SetBits Points to value to bitwise-OR with the read configuration value. + The size of the value is determined by Width. + @param ClearBits Points to the value to negate and bitwise-AND with the read configuration value. + The size of the value is determined by Width. + + @retval EFI_SUCCESS The function completed successfully. + @retval EFI_DEVICE_ERROR There was a problem with the transaction. +**/ +EFI_STATUS +EFIAPI +PeiLibPciCfgModify ( + IN EFI_PEI_SERVICES **PeiServices, + IN PEI_PCI_CFG_PPI *PciCfg, + IN PEI_PCI_CFG_PPI_WIDTH Width, + IN UINT64 Address, + IN UINTN SetBits, + IN UINTN ClearBits + ) +{ + EFI_STATUS Status; + EFI_PEI_PCI_CFG2_PPI *PciCfg2; + + Status = (*PeiServices)->LocatePpi ( + PeiServices, + &gPeiPciCfg2PpiGuid, + 0, + NULL, + (VOID **) &PciCfg2 + ); + ASSERT_EFI_ERROR (Status); + + Status = PciCfg2->Modify ( + (CONST EFI_PEI_SERVICES **) PeiServices, + PciCfg2, + (EFI_PEI_PCI_CFG_PPI_WIDTH) Width, + Address, + &SetBits, + &ClearBits + ); + + return Status; +} diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiServicesLib/PeiServicesLib.inf b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiServicesLib/PeiServicesLib.inf new file mode 100644 index 0000000..c3ecc08 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiServicesLib/PeiServicesLib.inf @@ -0,0 +1,82 @@ +#/*++ +# +# 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: +# +# PeiServicesLib.inf +# +# Abstract: +# +# Component description file for PeiServicesLib +# +#--*/ + +[defines] +BASE_NAME = EdkIIGluePeiServicesLib +COMPONENT_TYPE = LIBRARY + +[sources.common] + PeiServicesLib.c + +[sources.ia32] + +[sources.x64] + +[sources.ipf] + +[sources.ebc] + + +[includes.common] + . + ..\..\Include + ..\..\include\Library + $(EDK_SOURCE)\Foundation + $(EDK_SOURCE)\Foundation\Framework + $(EDK_SOURCE)\Foundation\Efi + $(EDK_SOURCE)\Foundation\Include + $(EDK_SOURCE)\Foundation\Include\Pei + $(EDK_SOURCE)\Foundation\Efi\Include + $(EDK_SOURCE)\Foundation\Framework\Include + $(EDK_SOURCE)\Foundation\Include\IndustryStandard + $(EDK_SOURCE)\Foundation\Core\Dxe + $(EDK_SOURCE)\Foundation\Library\Dxe\Include + $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include + +[libraries.common] + EdkIIGluePeiServicesTablePointerLibMm7 +# +# If necessary, EdkIIGluePeiServicesTablePointerLib can be +# used to replace EdkIIGluePeiServicesTablePointerLibMm7 +# + EdkFrameworkPpiLib + +[libraries.ia32] + + +[libraries.x64] + + +[nmake.common] + C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION + LIB_STD_FLAGS = /NOLOGO /IGNORE:4006 + +[nmake.ia32] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32 + +[nmake.x64] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64 + +[nmake.ipf] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF + +[nmake.ebc] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_EBC
\ No newline at end of file diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiServicesTablePointerLib/EdkIIGluePeiServicesTablePointerLib.cif b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiServicesTablePointerLib/EdkIIGluePeiServicesTablePointerLib.cif new file mode 100644 index 0000000..525bd3a --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiServicesTablePointerLib/EdkIIGluePeiServicesTablePointerLib.cif @@ -0,0 +1,11 @@ +<component> + name = "EdkIIGluePeiServicesTablePointerLib" + category = ModulePart + LocalRoot = "Edk\Foundation\Library\EdkIIGlueLib\Library\PeiServicesTablePointerLib" + RefName = "EdkIIGluePeiServicesTablePointerLib" +[files] +"EdkIIGluePeiServicesTablePointerLib.sdl" +"EdkIIGluePeiServicesTablePointerLib.mak" +"PeiServicesTablePointerLib.inf" +"PeiServicesTablePointer.c" +<endComponent> diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiServicesTablePointerLib/EdkIIGluePeiServicesTablePointerLib.mak b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiServicesTablePointerLib/EdkIIGluePeiServicesTablePointerLib.mak new file mode 100644 index 0000000..5454fa6 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiServicesTablePointerLib/EdkIIGluePeiServicesTablePointerLib.mak @@ -0,0 +1,80 @@ +#********************************************************************** +#********************************************************************** +#** ** +#** (C)Copyright 1985-2009, American Megatrends, Inc. ** +#** ** +#** All Rights Reserved. ** +#** ** +#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +#** ** +#** Phone: (770)-246-8600 ** +#** ** +#********************************************************************** +#********************************************************************** + +#********************************************************************** +# $Header: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGluePeiServicesTablePointerLib/EdkIIGluePeiServicesTablePointerLib.mak 1 1/20/12 3:57a Jeffch $ +# +# $Revision: 1 $ +# +# $Date: 1/20/12 3:57a $ +#********************************************************************** +# Revision History +# ---------------- +# $Log: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGluePeiServicesTablePointerLib/EdkIIGluePeiServicesTablePointerLib.mak $ +# +# 1 1/20/12 3:57a Jeffch +# Create Intel EDK 1117 Patch 7. +# +# 1 9/27/11 6:19a Wesleychen +# Intel EDK initially releases. +# +# 1 9/18/09 1:58a Iminglin +# +#********************************************************************** +#<AMI_FHDR_START> +# +# Name: EdkIIGluePeiServicesTablePointerLib.mak +# +# Description: +# +#<AMI_FHDR_END> +#********************************************************************** + + +$(EdkIIGluePeiServicesTablePointerLib_LIB) : EdkIIGluePeiServicesTablePointerLib + +EdkIIGluePeiServicesTablePointerLib : $(BUILD_DIR)\EdkIIGluePeiServicesTablePointerLib.mak EdkIIGluePeiServicesTablePointerLibBin + +$(BUILD_DIR)\EdkIIGluePeiServicesTablePointerLib.mak : $(EdkIIGluePeiServicesTablePointerLib_DIR)\$(@B).cif $(EdkIIGluePeiServicesTablePointerLib_DIR)\$(@B).mak $(BUILD_RULES) + $(CIF2MAK) $(EdkIIGluePeiServicesTablePointerLib_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS) + +EdkIIGluePeiServicesTablePointerLibBin : +!IF "$(x64_BUILD)"=="1" + $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\ + BUILD_DIR=$(BUILD_DIR)\ + /f $(BUILD_DIR)\EdkIIGluePeiServicesTablePointerLib.mak all\ + TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGluePeiServicesTablePointerLib_LIB)" + $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\ + BUILD_DIR=$(BUILD_DIR)\IA32\ + /f $(BUILD_DIR)\EdkIIGluePeiServicesTablePointerLib.mak all\ + TYPE=PEI_LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGluePeiServicesTablePointerLib_LIB)" +!ELSE + $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\ + BUILD_DIR=$(BUILD_DIR)\ + /f $(BUILD_DIR)\EdkIIGluePeiServicesTablePointerLib.mak all\ + TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGluePeiServicesTablePointerLib_LIB)" +!ENDIF +#********************************************************************** +#********************************************************************** +#** ** +#** (C)Copyright 1985-2009, American Megatrends, Inc. ** +#** ** +#** All Rights Reserved. ** +#** ** +#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +#** ** +#** Phone: (770)-246-8600 ** +#** ** +#********************************************************************** +#********************************************************************** diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiServicesTablePointerLib/EdkIIGluePeiServicesTablePointerLib.sdl b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiServicesTablePointerLib/EdkIIGluePeiServicesTablePointerLib.sdl new file mode 100644 index 0000000..1a9ad48 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiServicesTablePointerLib/EdkIIGluePeiServicesTablePointerLib.sdl @@ -0,0 +1,26 @@ +TOKEN + Name = "EdkIIGluePeiServicesTablePointerLib_SUPPORT" + Value = "1" + Help = "Main switch to enable EdkIIGluePeiServicesTablePointerLib support in Project" + TokenType = Boolean + TargetEQU = Yes + TargetMAK = Yes + Master = Yes +End + +TOKEN + Name = "EdkIIGluePeiServicesTablePointerLib_LIB" + Value = "$$(LIB_BUILD_DIR)\EdkIIGluePeiServicesTablePointerLib.lib" + TokenType = Expression + TargetMAK = Yes +End + +PATH + Name = "EdkIIGluePeiServicesTablePointerLib_DIR" +End + +MODULE + Help = "Includes EdkIIGluePeiServicesTablePointerLib.mak to Project" + File = "EdkIIGluePeiServicesTablePointerLib.mak" +End + diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiServicesTablePointerLib/PeiServicesTablePointer.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiServicesTablePointerLib/PeiServicesTablePointer.c new file mode 100644 index 0000000..7e632d3 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiServicesTablePointerLib/PeiServicesTablePointer.c @@ -0,0 +1,66 @@ +/*++ + +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: + + PeiServicesTablePointer.c + +Abstract: + + PEI Services Table Pointer Library. + +--*/ + +#include "EdkIIGluePeim.h" + +static EFI_PEI_SERVICES **gPeiServices; + +/** + The function returns the pointer to PEI services. + + The function returns the pointer to PEI services. + It will ASSERT() if the pointer to PEI services is NULL. + + @retval The pointer to PeiServices. + +**/ +EFI_PEI_SERVICES ** +GetPeiServicesTablePointer ( + VOID + ) +{ + ASSERT (gPeiServices != NULL); + return gPeiServices; +} + + +/** + The constructor function caches the pointer to PEI services. + + The constructor function caches the pointer to PEI services. + It will always return EFI_SUCCESS. + + @param FfsHeader Pointer to FFS header the loaded driver. + @param PeiServices Pointer to the PEI services. + + @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS. + +**/ +EFI_STATUS +PeiServicesTablePointerLibConstructor ( + IN EFI_FFS_FILE_HEADER *FfsHeader, + IN EFI_PEI_SERVICES **PeiServices + ) +{ + gPeiServices = PeiServices; + return EFI_SUCCESS; +} diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiServicesTablePointerLib/PeiServicesTablePointerLib.inf b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiServicesTablePointerLib/PeiServicesTablePointerLib.inf new file mode 100644 index 0000000..8eb2e6d --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiServicesTablePointerLib/PeiServicesTablePointerLib.inf @@ -0,0 +1,77 @@ +#/*++ +# +# 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: +# +# PeiServiceTablePointerLib.inf +# +# Abstract: +# +# Component description file for PeiServicesTablePointerLib. +# +#--*/ + +[defines] +BASE_NAME = EdkIIGluePeiServicesTablePointerLib +COMPONENT_TYPE = LIBRARY + +[sources.common] + PeiServicesTablePointer.c + +[sources.ia32] + +[sources.x64] + +[sources.ipf] + +[sources.ebc] + + +[includes.common] + . + ..\..\Include + ..\..\include\Library + $(EDK_SOURCE)\Foundation + $(EDK_SOURCE)\Foundation\Framework + $(EDK_SOURCE)\Foundation\Include\Pei + $(EDK_SOURCE)\Foundation\Efi + $(EDK_SOURCE)\Foundation\Include + $(EDK_SOURCE)\Foundation\Efi\Include + $(EDK_SOURCE)\Foundation\Framework\Include + $(EDK_SOURCE)\Foundation\Include\IndustryStandard + $(EDK_SOURCE)\Foundation\Core\Dxe + $(EDK_SOURCE)\Foundation\Library\Dxe\Include + $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include + +[libraries.common] + + +[libraries.ia32] + + +[libraries.x64] + + +[nmake.common] + C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION + LIB_STD_FLAGS = /NOLOGO /IGNORE:4006 + +[nmake.ia32] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32 + +[nmake.x64] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64 + +[nmake.ipf] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF + +[nmake.ebc] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_EBC
\ No newline at end of file diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiServicesTablePointerLibMm7/EdkIIGluePeiServicesTablePointerLibMm7.cif b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiServicesTablePointerLibMm7/EdkIIGluePeiServicesTablePointerLibMm7.cif new file mode 100644 index 0000000..e363243 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiServicesTablePointerLibMm7/EdkIIGluePeiServicesTablePointerLibMm7.cif @@ -0,0 +1,11 @@ +<component> + name = "EdkIIGluePeiServicesTablePointerLibMm7" + category = ModulePart + LocalRoot = "Edk\Foundation\Library\EdkIIGlueLib\Library\PeiServicesTablePointerLibMm7" + RefName = "EdkIIGluePeiServicesTablePointerLibMm7" +[files] +"EdkIIGluePeiServicesTablePointerLibMm7.sdl" +"EdkIIGluePeiServicesTablePointerLibMm7.mak" +"PeiServicesTablePointerLibMm7.inf" +"PeiServicesTablePointer.c" +<endComponent> diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiServicesTablePointerLibMm7/EdkIIGluePeiServicesTablePointerLibMm7.mak b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiServicesTablePointerLibMm7/EdkIIGluePeiServicesTablePointerLibMm7.mak new file mode 100644 index 0000000..6bec27d --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiServicesTablePointerLibMm7/EdkIIGluePeiServicesTablePointerLibMm7.mak @@ -0,0 +1,80 @@ +#********************************************************************** +#********************************************************************** +#** ** +#** (C)Copyright 1985-2009, American Megatrends, Inc. ** +#** ** +#** All Rights Reserved. ** +#** ** +#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +#** ** +#** Phone: (770)-246-8600 ** +#** ** +#********************************************************************** +#********************************************************************** + +#********************************************************************** +# $Header: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGluePeiServicesTablePointerLibMm7/EdkIIGluePeiServicesTablePointerLibMm7.mak 1 1/20/12 3:57a Jeffch $ +# +# $Revision: 1 $ +# +# $Date: 1/20/12 3:57a $ +#********************************************************************** +# Revision History +# ---------------- +# $Log: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGluePeiServicesTablePointerLibMm7/EdkIIGluePeiServicesTablePointerLibMm7.mak $ +# +# 1 1/20/12 3:57a Jeffch +# Create Intel EDK 1117 Patch 7. +# +# 1 9/27/11 6:19a Wesleychen +# Intel EDK initially releases. +# +# 1 9/18/09 1:58a Iminglin +# +#********************************************************************** +#<AMI_FHDR_START> +# +# Name: EdkIIGluePeiServicesTablePointerLibMm7.mak +# +# Description: +# +#<AMI_FHDR_END> +#********************************************************************** + + +$(EdkIIGluePeiServicesTablePointerLibMm7_LIB) : EdkIIGluePeiServicesTablePointerLibMm7 + +EdkIIGluePeiServicesTablePointerLibMm7 : $(BUILD_DIR)\EdkIIGluePeiServicesTablePointerLibMm7.mak EdkIIGluePeiServicesTablePointerLibMm7Bin + +$(BUILD_DIR)\EdkIIGluePeiServicesTablePointerLibMm7.mak : $(EdkIIGluePeiServicesTablePointerLibMm7_DIR)\$(@B).cif $(EdkIIGluePeiServicesTablePointerLibMm7_DIR)\$(@B).mak $(BUILD_RULES) + $(CIF2MAK) $(EdkIIGluePeiServicesTablePointerLibMm7_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS) + +EdkIIGluePeiServicesTablePointerLibMm7Bin : $(EdkIIGlueBaseLib_LIB) +!IF "$(x64_BUILD)"=="1" + $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\ + BUILD_DIR=$(BUILD_DIR)\ + /f $(BUILD_DIR)\EdkIIGluePeiServicesTablePointerLibMm7.mak all\ + TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGluePeiServicesTablePointerLibMm7_LIB)" + $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\ + BUILD_DIR=$(BUILD_DIR)\IA32\ + /f $(BUILD_DIR)\EdkIIGluePeiServicesTablePointerLibMm7.mak all\ + TYPE=PEI_LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGluePeiServicesTablePointerLibMm7_LIB)" +!ELSE + $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\ + BUILD_DIR=$(BUILD_DIR)\ + /f $(BUILD_DIR)\EdkIIGluePeiServicesTablePointerLibMm7.mak all\ + TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGluePeiServicesTablePointerLibMm7_LIB)" +!ENDIF +#********************************************************************** +#********************************************************************** +#** ** +#** (C)Copyright 1985-2009, American Megatrends, Inc. ** +#** ** +#** All Rights Reserved. ** +#** ** +#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +#** ** +#** Phone: (770)-246-8600 ** +#** ** +#********************************************************************** +#**********************************************************************
\ No newline at end of file diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiServicesTablePointerLibMm7/EdkIIGluePeiServicesTablePointerLibMm7.sdl b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiServicesTablePointerLibMm7/EdkIIGluePeiServicesTablePointerLibMm7.sdl new file mode 100644 index 0000000..c8b62d5 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiServicesTablePointerLibMm7/EdkIIGluePeiServicesTablePointerLibMm7.sdl @@ -0,0 +1,26 @@ +TOKEN + Name = "EdkIIGluePeiServicesTablePointerLibMm7_SUPPORT" + Value = "1" + Help = "Main switch to enable EdkIIGluePeiServicesTablePointerLibMm7 support in Project" + TokenType = Boolean + TargetEQU = Yes + TargetMAK = Yes + Master = Yes +End + +TOKEN + Name = "EdkIIGluePeiServicesTablePointerLibMm7_LIB" + Value = "$$(LIB_BUILD_DIR)\EdkIIGluePeiServicesTablePointerLibMm7.lib" + TokenType = Expression + TargetMAK = Yes +End + +PATH + Name = "EdkIIGluePeiServicesTablePointerLibMm7_DIR" +End + +MODULE + Help = "Includes EdkIIGluePeiServicesTablePointerLibMm7.mak to Project" + File = "EdkIIGluePeiServicesTablePointerLibMm7.mak" +End + diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiServicesTablePointerLibMm7/PeiServicesTablePointer.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiServicesTablePointerLibMm7/PeiServicesTablePointer.c new file mode 100644 index 0000000..c6f4cf3 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiServicesTablePointerLibMm7/PeiServicesTablePointer.c @@ -0,0 +1,84 @@ +/*++ + +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: + + PeiServicesTablePointer.c + +Abstract: + + PEI Services Table Pointer Library. + +--*/ + +#include "EdkIIGluePeim.h" + +/** + The function returns the pointer to PeiServices. + + The function returns the pointer to PeiServices. + It will ASSERT() if the pointer to PeiServices is NULL. + + @retval The pointer to PeiServices. + +**/ +EFI_PEI_SERVICES ** +EFIAPI +GetPeiServicesTablePointer ( + VOID + ) +{ + EFI_PEI_SERVICES **PeiServices; +#if (PI_SPECIFICATION_VERSION >= 0x00010000) //;;## ...AMI_OVERRIDE... Support PI1.x + IA32_DESCRIPTOR Idtr; +#endif + +#if (PI_SPECIFICATION_VERSION < 0x00010000) //;;## ...AMI_OVERRIDE... Support PI1.x + PeiServices = (EFI_PEI_SERVICES **)(UINTN)AsmReadMm7 (); +#else + AsmReadIdtr (&Idtr); + PeiServices = (EFI_PEI_SERVICES **)(UINTN)(*(UINTN*)(Idtr.Base - sizeof (UINTN))); +#endif + + if ((*PeiServices)->Hdr.Signature == PEI_SERVICES_SIGNATURE) { + return PeiServices; + } else { + PeiServices = (EFI_PEI_SERVICES **)(UINTN)AsmReadMm7 (); + ASSERT (PeiServices != NULL); + return PeiServices; + } +} + +/** + The constructor function caches the pointer to PEI services. + + The constructor function caches the pointer to PEI services. + It will always return EFI_SUCCESS. + + @param FfsHeader Pointer to FFS header the loaded driver. + @param PeiServices Pointer to the PEI services. + + @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS. + +**/ +EFI_STATUS +EFIAPI +PeiServicesTablePointerLibConstructor ( + IN EFI_FFS_FILE_HEADER *FfsHeader, + IN EFI_PEI_SERVICES **PeiServices + ) +{ +#if (PI_SPECIFICATION_VERSION < 0x00010000) + AsmWriteMm7 ((UINT64)(UINTN)PeiServices); +#endif + return EFI_SUCCESS; +} diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiServicesTablePointerLibMm7/PeiServicesTablePointerLibMm7.inf b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiServicesTablePointerLibMm7/PeiServicesTablePointerLibMm7.inf new file mode 100644 index 0000000..9e66213 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiServicesTablePointerLibMm7/PeiServicesTablePointerLibMm7.inf @@ -0,0 +1,77 @@ +#/*++ +# +# 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: +# +# PeiServiceTablePointerLibMm7.inf +# +# Abstract: +# +# Component description file for PeiServicesTablePointerLibMm7. +# +#--*/ + +[defines] +BASE_NAME = EdkIIGluePeiServicesTablePointerLibMm7 +COMPONENT_TYPE = LIBRARY + +[sources.common] + PeiServicesTablePointer.c + +[sources.ia32] + +[sources.x64] + +[sources.ipf] + +[sources.ebc] + + +[includes.common] + . + ..\..\Include + ..\..\include\Library + $(EDK_SOURCE)\Foundation + $(EDK_SOURCE)\Foundation\Framework + $(EDK_SOURCE)\Foundation\Include\Pei + $(EDK_SOURCE)\Foundation\Efi + $(EDK_SOURCE)\Foundation\Include + $(EDK_SOURCE)\Foundation\Efi\Include + $(EDK_SOURCE)\Foundation\Framework\Include + $(EDK_SOURCE)\Foundation\Include\IndustryStandard + $(EDK_SOURCE)\Foundation\Core\Dxe + $(EDK_SOURCE)\Foundation\Library\Dxe\Include + $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include + +[libraries.common] + EdkIIGlueBaseLib + +[libraries.ia32] + + +[libraries.x64] + + +[nmake.common] + C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION + LIB_STD_FLAGS = /NOLOGO /IGNORE:4006 + +[nmake.ia32] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32 + +[nmake.x64] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64 + +[nmake.ipf] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF + +[nmake.ebc] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_EBC
\ No newline at end of file diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiSmbusLib/EdkIIGluePeiSmbusLib.cif b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiSmbusLib/EdkIIGluePeiSmbusLib.cif new file mode 100644 index 0000000..89f6664 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiSmbusLib/EdkIIGluePeiSmbusLib.cif @@ -0,0 +1,13 @@ +<component> + name = "EdkIIGluePeiSmbusLib" + category = ModulePart + LocalRoot = "Edk\Foundation\Library\EdkIIGlueLib\Library\PeiSmbusLib" + RefName = "EdkIIGluePeiSmbusLib" +[files] +"EdkIIGluePeiSmbusLib.sdl" +"EdkIIGluePeiSmbusLib.mak" +"PeiSmbusLib.inf" +"PeiSmbusLib.c" +"SmbusLib.c" +"PeiSmbusLibInternal.h" +<endComponent> diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiSmbusLib/EdkIIGluePeiSmbusLib.mak b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiSmbusLib/EdkIIGluePeiSmbusLib.mak new file mode 100644 index 0000000..8a62183 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiSmbusLib/EdkIIGluePeiSmbusLib.mak @@ -0,0 +1,80 @@ +#********************************************************************** +#********************************************************************** +#** ** +#** (C)Copyright 1985-2009, American Megatrends, Inc. ** +#** ** +#** All Rights Reserved. ** +#** ** +#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +#** ** +#** Phone: (770)-246-8600 ** +#** ** +#********************************************************************** +#********************************************************************** + +#********************************************************************** +# $Header: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGluePeiSmbusLib/EdkIIGluePeiSmbusLib.mak 1 1/20/12 3:57a Jeffch $ +# +# $Revision: 1 $ +# +# $Date: 1/20/12 3:57a $ +#********************************************************************** +# Revision History +# ---------------- +# $Log: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGluePeiSmbusLib/EdkIIGluePeiSmbusLib.mak $ +# +# 1 1/20/12 3:57a Jeffch +# Create Intel EDK 1117 Patch 7. +# +# 1 9/27/11 6:19a Wesleychen +# Intel EDK initially releases. +# +# 1 9/18/09 1:58a Iminglin +# +#********************************************************************** +#<AMI_FHDR_START> +# +# Name: EdkIIGluePeiSmbusLib.mak +# +# Description: +# +#<AMI_FHDR_END> +#********************************************************************** + + +$(EdkIIGluePeiSmbusLib_LIB) : EdkIIGluePeiSmbusLib + +EdkIIGluePeiSmbusLib : $(BUILD_DIR)\EdkIIGluePeiSmbusLib.mak EdkIIGluePeiSmbusLibBin + +$(BUILD_DIR)\EdkIIGluePeiSmbusLib.mak : $(EdkIIGluePeiSmbusLib_DIR)\$(@B).cif $(EdkIIGluePeiSmbusLib_DIR)\$(@B).mak $(BUILD_RULES) + $(CIF2MAK) $(EdkIIGluePeiSmbusLib_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS) + +EdkIIGluePeiSmbusLibBin : $(EdkIIGlueBaseMemoryLib_LIB) $(EdkIIGluePeiServicesTablePointerLibMm7_LIB) +!IF "$(x64_BUILD)"=="1" + $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\ + BUILD_DIR=$(BUILD_DIR)\ + /f $(BUILD_DIR)\EdkIIGluePeiSmbusLib.mak all\ + TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGluePeiSmbusLib_LIB)" + $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\ + BUILD_DIR=$(BUILD_DIR)\IA32\ + /f $(BUILD_DIR)\EdkIIGluePeiSmbusLib.mak all\ + TYPE=PEI_LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGluePeiSmbusLib_LIB)" +!ELSE + $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\ + BUILD_DIR=$(BUILD_DIR)\ + /f $(BUILD_DIR)\EdkIIGluePeiSmbusLib.mak all\ + TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGluePeiSmbusLib_LIB)" +!ENDIF +#********************************************************************** +#********************************************************************** +#** ** +#** (C)Copyright 1985-2009, American Megatrends, Inc. ** +#** ** +#** All Rights Reserved. ** +#** ** +#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +#** ** +#** Phone: (770)-246-8600 ** +#** ** +#********************************************************************** +#**********************************************************************
\ No newline at end of file diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiSmbusLib/EdkIIGluePeiSmbusLib.sdl b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiSmbusLib/EdkIIGluePeiSmbusLib.sdl new file mode 100644 index 0000000..14029a3 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiSmbusLib/EdkIIGluePeiSmbusLib.sdl @@ -0,0 +1,26 @@ +TOKEN + Name = "EdkIIGluePeiSmbusLib_SUPPORT" + Value = "1" + Help = "Main switch to enable EdkIIGluePeiSmbusLib support in Project" + TokenType = Boolean + TargetEQU = Yes + TargetMAK = Yes + Master = Yes +End + +TOKEN + Name = "EdkIIGluePeiSmbusLib_LIB" + Value = "$$(LIB_BUILD_DIR)\EdkIIGluePeiSmbusLib.lib" + TokenType = Expression + TargetMAK = Yes +End + +PATH + Name = "EdkIIGluePeiSmbusLib_DIR" +End + +MODULE + Help = "Includes EdkIIGluePeiSmbusLib.mak to Project" + File = "EdkIIGluePeiSmbusLib.mak" +End + diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiSmbusLib/PeiSmbusLib.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiSmbusLib/PeiSmbusLib.c new file mode 100644 index 0000000..4598af4 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiSmbusLib/PeiSmbusLib.c @@ -0,0 +1,104 @@ +/*++ + +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: + + PeiSmbusLib.c + +Abstract: + + PEI Smbus Lib internal functions + +--*/ + +#include "PeiSmbusLibInternal.h" + +/** + Gets Smbus PPIs. + + This internal function retrieves Smbus PPI from PPI database. + + @param PeiServices An indirect pointer to the EFI_PEI_SERVICES published by the PEI Foundation. + + @return The pointer to Smbus PPI. + +**/ +EFI_PEI_SMBUS_PPI * +InternalGetSmbusPpi ( + EFI_PEI_SERVICES **PeiServices + ) +{ + EFI_STATUS Status; + EFI_PEI_SMBUS_PPI *SmbusPpi; + + Status = (*PeiServices)->LocatePpi (PeiServices, &gEfiPeiSmbusPpiGuid, 0, NULL, (VOID **) &SmbusPpi); + ASSERT_EFI_ERROR (Status); + ASSERT (SmbusPpi != NULL); + + return SmbusPpi; +} + +/** + Executes an SMBus operation to an SMBus controller. + + This function provides a standard way to execute Smbus script + as defined in the SmBus Specification. The data can either be of + the Length byte, word, or a block of data. + + @param SmbusOperation Signifies which particular SMBus hardware protocol instance that it will use to + execute the SMBus transactions. + @param SmBusAddress Address that encodes the SMBUS Slave Address, + SMBUS Command, SMBUS Data Length, and PEC. + @param Length Signifies the number of bytes that this operation will do. The maximum number of + bytes can be revision specific and operation specific. + @param Buffer Contains the value of data to execute to the SMBus slave device. Not all operations + require this argument. The length of this buffer is identified by Length. + @param Status Return status for the executed command. + This is an optional parameter and may be NULL. + + @return The actual number of bytes that are executed for this operation.. + +**/ +UINTN +InternalSmBusExec ( + IN EFI_SMBUS_OPERATION SmbusOperation, + IN UINTN SmBusAddress, + IN UINTN Length, + IN OUT VOID *Buffer, + OUT RETURN_STATUS *Status OPTIONAL + ) +{ + EFI_PEI_SMBUS_PPI *SmbusPpi; + EFI_PEI_SERVICES **PeiServices; + RETURN_STATUS ReturnStatus; + EFI_SMBUS_DEVICE_ADDRESS SmbusDeviceAddress; + + PeiServices = GetPeiServicesTablePointer (); + SmbusPpi = InternalGetSmbusPpi (PeiServices); + SmbusDeviceAddress.SmbusDeviceAddress = SMBUS_LIB_SLAVE_ADDRESS (SmBusAddress); + + ReturnStatus = SmbusPpi->Execute ( + PeiServices, + SmbusPpi, + SmbusDeviceAddress, + SMBUS_LIB_COMMAND (SmBusAddress), + SmbusOperation, + SMBUS_LIB_PEC (SmBusAddress), + &Length, + Buffer + ); + if (Status != NULL) { + *Status = ReturnStatus; + } + + return Length; +} diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiSmbusLib/PeiSmbusLib.inf b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiSmbusLib/PeiSmbusLib.inf new file mode 100644 index 0000000..0b98e3c --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiSmbusLib/PeiSmbusLib.inf @@ -0,0 +1,84 @@ +#/*++ +# +# 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: +# +# PeiSmbusLib.inf +# +# Abstract: +# +# Component description file for PeiSmbusLib. +# +#--*/ + +[defines] +BASE_NAME = EdkIIGluePeiSmbusLib +COMPONENT_TYPE = LIBRARY + +[sources.common] + PeiSmbusLib.c + SmbusLib.c + +[sources.ia32] + +[sources.x64] + +[sources.ipf] + +[sources.ebc] + + +[includes.common] + . + ..\..\Include + ..\..\include\Library + $(EDK_SOURCE)\Foundation + $(EDK_SOURCE)\Foundation\Framework + $(EDK_SOURCE)\Foundation\Efi + $(EDK_SOURCE)\Foundation\Include + $(EDK_SOURCE)\Foundation\Efi\Include + $(EDK_SOURCE)\Foundation\Framework\Include + $(EDK_SOURCE)\Foundation\Include\IndustryStandard + $(EDK_SOURCE)\Foundation\Core\Dxe + $(EDK_SOURCE)\Foundation\Library\Dxe\Include + $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include + $(EDK_SOURCE)\Foundation\Framework\Guid\DataHubRecords + $(EDK_SOURCE)\Foundation\Framework\Guid\StatusCodeDataTypeId + $(EDK_SOURCE)\Foundation\Include\Pei + +[libraries.common] + EdkIIGlueBaseMemoryLib + EdkIIGluePeiServicesTablePointerLibMm7 +# +# If necessary, EdkIIGluePeiServicesTablePointerLib can be +# used to replace EdkIIGluePeiServicesTablePointerLibMm7 +# + + +[libraries.ia32] + +[libraries.x64] + +[nmake.common] + C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION + LIB_STD_FLAGS = /NOLOGO /IGNORE:4006 + +[nmake.ia32] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32 + +[nmake.x64] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64 + +[nmake.ipf] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF + +[nmake.ebc] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_EBC diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiSmbusLib/PeiSmbusLibInternal.h b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiSmbusLib/PeiSmbusLibInternal.h new file mode 100644 index 0000000..2826a4e --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiSmbusLib/PeiSmbusLibInternal.h @@ -0,0 +1,68 @@ +/*++ + +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: + + PeiSmbusLibInternal.h + +Abstract: + + Declarations of internal functions in PeiSmbusLib. + +--*/ + +#ifndef __PEI_SMBUS_LIB_INTERNAL_H__ +#define __PEI_SMBUS_LIB_INTERNAL_H__ + +#include "EdkIIGluePeim.h" + + +#define SMBUS_LIB_SLAVE_ADDRESS(SmBusAddress) (((SmBusAddress) >> 1) & 0x7f) +#define SMBUS_LIB_COMMAND(SmBusAddress) (((SmBusAddress) >> 8) & 0xff) +#define SMBUS_LIB_LENGTH(SmBusAddress) (((SmBusAddress) >> 16) & 0x3f) +#define SMBUS_LIB_PEC(SmBusAddress) ((BOOLEAN) (((SmBusAddress) & SMBUS_LIB_PEC_BIT) != 0)) +#define SMBUS_LIB_RESEARVED(SmBusAddress) ((SmBusAddress) & ~(((1 << 22) - 2) | SMBUS_LIB_PEC_BIT)) + +// +// Declaration for internal functions +// +/** + Executes an SMBus operation to an SMBus controller. + + This function provides a standard way to execute Smbus script + as defined in the SmBus Specification. The data can either be of + the Length byte, word, or a block of data. + + @param SmbusOperation Signifies which particular SMBus hardware protocol instance that it will use to + execute the SMBus transactions. + @param SmBusAddress Address that encodes the SMBUS Slave Address, + SMBUS Command, SMBUS Data Length, and PEC. + @param Length Signifies the number of bytes that this operation will do. The maximum number of + bytes can be revision specific and operation specific. + @param Buffer Contains the value of data to execute to the SMBus slave device. Not all operations + require this argument. The length of this buffer is identified by Length. + @param Status Return status for the executed command. + This is an optional parameter and may be NULL. + + @return The actual number of bytes that are executed for this operation. + +**/ +UINTN +InternalSmBusExec ( + IN EFI_SMBUS_OPERATION SmbusOperation, + IN UINTN SmBusAddress, + IN UINTN Length, + IN OUT VOID *Buffer, + OUT RETURN_STATUS *Status OPTIONAL + ); + +#endif diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiSmbusLib/SmbusLib.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiSmbusLib/SmbusLib.c new file mode 100644 index 0000000..bd32d53 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiSmbusLib/SmbusLib.c @@ -0,0 +1,475 @@ +/*++ + +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: + + PeiSmbus.c + +Abstract: + + Pei Smbus Lib Interfaces + +--*/ + +#include "PeiSmbusLibInternal.h" + +/** + Executes an SMBUS quick read command. + + Executes an SMBUS quick read command on the SMBUS device specified by SmBusAddress. + Only the SMBUS slave address field of SmBusAddress is required. + If Status is not NULL, then the status of the executed command is returned in Status. + If PEC is set in SmBusAddress, then ASSERT(). + If Command in SmBusAddress is not zero, then ASSERT(). + If Length in SmBusAddress is not zero, then ASSERT(). + If any reserved bits of SmBusAddress are set, then ASSERT(). + + @param SmBusAddress Address that encodes the SMBUS Slave Address, + SMBUS Command, SMBUS Data Length, and PEC. + @param Status Return status for the executed command. + This is an optional parameter and may be NULL. + +**/ +VOID +EFIAPI +SmBusQuickRead ( + IN UINTN SmBusAddress, + OUT RETURN_STATUS *Status OPTIONAL + ) +{ + ASSERT (!SMBUS_LIB_PEC (SmBusAddress)); + ASSERT (SMBUS_LIB_COMMAND (SmBusAddress) == 0); + ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) == 0); + ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0); + + InternalSmBusExec (EfiSmbusQuickRead, SmBusAddress, 0, NULL, Status); +} + +/** + Executes an SMBUS quick write command. + + Executes an SMBUS quick write command on the SMBUS device specified by SmBusAddress. + Only the SMBUS slave address field of SmBusAddress is required. + If Status is not NULL, then the status of the executed command is returned in Status. + If PEC is set in SmBusAddress, then ASSERT(). + If Command in SmBusAddress is not zero, then ASSERT(). + If Length in SmBusAddress is not zero, then ASSERT(). + If any reserved bits of SmBusAddress are set, then ASSERT(). + + @param SmBusAddress Address that encodes the SMBUS Slave Address, + SMBUS Command, SMBUS Data Length, and PEC. + @param Status Return status for the executed command. + This is an optional parameter and may be NULL. + +**/ +VOID +EFIAPI +SmBusQuickWrite ( + IN UINTN SmBusAddress, + OUT RETURN_STATUS *Status OPTIONAL + ) +{ + ASSERT (!SMBUS_LIB_PEC (SmBusAddress)); + ASSERT (SMBUS_LIB_COMMAND (SmBusAddress) == 0); + ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) == 0); + ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0); + + InternalSmBusExec (EfiSmbusQuickWrite, SmBusAddress, 0, NULL, Status); +} + +/** + Executes an SMBUS receive byte command. + + Executes an SMBUS receive byte command on the SMBUS device specified by SmBusAddress. + Only the SMBUS slave address field of SmBusAddress is required. + The byte received from the SMBUS is returned. + If Status is not NULL, then the status of the executed command is returned in Status. + If Command in SmBusAddress is not zero, then ASSERT(). + If Length in SmBusAddress is not zero, then ASSERT(). + If any reserved bits of SmBusAddress are set, then ASSERT(). + + @param SmBusAddress Address that encodes the SMBUS Slave Address, + SMBUS Command, SMBUS Data Length, and PEC. + @param Status Return status for the executed command. + This is an optional parameter and may be NULL. + + @return The byte received from the SMBUS. + +**/ +UINT8 +EFIAPI +SmBusReceiveByte ( + IN UINTN SmBusAddress, + OUT RETURN_STATUS *Status OPTIONAL + ) +{ + UINT8 Byte; + + ASSERT (SMBUS_LIB_COMMAND (SmBusAddress) == 0); + ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) == 0); + ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0); + + InternalSmBusExec (EfiSmbusReceiveByte, SmBusAddress, 1, &Byte, Status); + + return Byte; +} + +/** + Executes an SMBUS send byte command. + + Executes an SMBUS send byte command on the SMBUS device specified by SmBusAddress. + The byte specified by Value is sent. + Only the SMBUS slave address field of SmBusAddress is required. Value is returned. + If Status is not NULL, then the status of the executed command is returned in Status. + If Command in SmBusAddress is not zero, then ASSERT(). + If Length in SmBusAddress is not zero, then ASSERT(). + If any reserved bits of SmBusAddress are set, then ASSERT(). + + @param SmBusAddress Address that encodes the SMBUS Slave Address, + SMBUS Command, SMBUS Data Length, and PEC. + @param Value The 8-bit value to send. + @param Status Return status for the executed command. + This is an optional parameter and may be NULL. + + @return The parameter of Value. + +**/ +UINT8 +EFIAPI +SmBusSendByte ( + IN UINTN SmBusAddress, + IN UINT8 Value, + OUT RETURN_STATUS *Status OPTIONAL + ) +{ + UINT8 Byte; + + ASSERT (SMBUS_LIB_COMMAND (SmBusAddress) == 0); + ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) == 0); + ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0); + + Byte = Value; + InternalSmBusExec (EfiSmbusSendByte, SmBusAddress, 1, &Byte, Status); + + return Value; +} + +/** + Executes an SMBUS read data byte command. + + Executes an SMBUS read data byte command on the SMBUS device specified by SmBusAddress. + Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required. + The 8-bit value read from the SMBUS is returned. + If Status is not NULL, then the status of the executed command is returned in Status. + If Length in SmBusAddress is not zero, then ASSERT(). + If any reserved bits of SmBusAddress are set, then ASSERT(). + + @param SmBusAddress Address that encodes the SMBUS Slave Address, + SMBUS Command, SMBUS Data Length, and PEC. + @param Status Return status for the executed command. + This is an optional parameter and may be NULL. + + @return The byte read from the SMBUS. + +**/ +UINT8 +EFIAPI +SmBusReadDataByte ( + IN UINTN SmBusAddress, + OUT RETURN_STATUS *Status OPTIONAL + ) +{ + UINT8 Byte; + + ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) == 0); + ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0); + + InternalSmBusExec (EfiSmbusReadByte, SmBusAddress, 1, &Byte, Status); + + return Byte; +} + +/** + Executes an SMBUS write data byte command. + + Executes an SMBUS write data byte command on the SMBUS device specified by SmBusAddress. + The 8-bit value specified by Value is written. + Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required. + Value is returned. + If Status is not NULL, then the status of the executed command is returned in Status. + If Length in SmBusAddress is not zero, then ASSERT(). + If any reserved bits of SmBusAddress are set, then ASSERT(). + + @param SmBusAddress Address that encodes the SMBUS Slave Address, + SMBUS Command, SMBUS Data Length, and PEC. + @param Value The 8-bit value to write. + @param Status Return status for the executed command. + This is an optional parameter and may be NULL. + + @return The parameter of Value. + +**/ +UINT8 +EFIAPI +SmBusWriteDataByte ( + IN UINTN SmBusAddress, + IN UINT8 Value, + OUT RETURN_STATUS *Status OPTIONAL + ) +{ + UINT8 Byte; + + ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) == 0); + ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0); + + Byte = Value; + InternalSmBusExec (EfiSmbusWriteByte, SmBusAddress, 1, &Byte, Status); + + return Value; +} + +/** + Executes an SMBUS read data word command. + + Executes an SMBUS read data word command on the SMBUS device specified by SmBusAddress. + Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required. + The 16-bit value read from the SMBUS is returned. + If Status is not NULL, then the status of the executed command is returned in Status. + If Length in SmBusAddress is not zero, then ASSERT(). + If any reserved bits of SmBusAddress are set, then ASSERT(). + + @param SmBusAddress Address that encodes the SMBUS Slave Address, + SMBUS Command, SMBUS Data Length, and PEC. + @param Status Return status for the executed command. + This is an optional parameter and may be NULL. + + @return The byte read from the SMBUS. + +**/ +UINT16 +EFIAPI +SmBusReadDataWord ( + IN UINTN SmBusAddress, + OUT RETURN_STATUS *Status OPTIONAL + ) +{ + UINT16 Word; + + ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) == 0); + ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0); + + InternalSmBusExec (EfiSmbusReadWord, SmBusAddress, 2, &Word, Status); + + return Word; +} + +/** + Executes an SMBUS write data word command. + + Executes an SMBUS write data word command on the SMBUS device specified by SmBusAddress. + The 16-bit value specified by Value is written. + Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required. + Value is returned. + If Status is not NULL, then the status of the executed command is returned in Status. + If Length in SmBusAddress is not zero, then ASSERT(). + If any reserved bits of SmBusAddress are set, then ASSERT(). + + @param SmBusAddress Address that encodes the SMBUS Slave Address, + SMBUS Command, SMBUS Data Length, and PEC. + @param Value The 16-bit value to write. + @param Status Return status for the executed command. + This is an optional parameter and may be NULL. + + @return The parameter of Value. + +**/ +UINT16 +EFIAPI +SmBusWriteDataWord ( + IN UINTN SmBusAddress, + IN UINT16 Value, + OUT RETURN_STATUS *Status OPTIONAL + ) +{ + UINT16 Word; + + ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) == 0); + ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0); + + Word = Value; + InternalSmBusExec (EfiSmbusWriteWord, SmBusAddress, 2, &Word, Status); + + return Value; +} + +/** + Executes an SMBUS process call command. + + Executes an SMBUS process call command on the SMBUS device specified by SmBusAddress. + The 16-bit value specified by Value is written. + Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required. + The 16-bit value returned by the process call command is returned. + If Status is not NULL, then the status of the executed command is returned in Status. + If Length in SmBusAddress is not zero, then ASSERT(). + If any reserved bits of SmBusAddress are set, then ASSERT(). + + @param SmBusAddress Address that encodes the SMBUS Slave Address, + SMBUS Command, SMBUS Data Length, and PEC. + @param Value The 16-bit value to write. + @param Status Return status for the executed command. + This is an optional parameter and may be NULL. + + @return The 16-bit value returned by the process call command. + +**/ +UINT16 +EFIAPI +SmBusProcessCall ( + IN UINTN SmBusAddress, + IN UINT16 Value, + OUT RETURN_STATUS *Status OPTIONAL + ) +{ + ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) == 0); + ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0); + + InternalSmBusExec (EfiSmbusProcessCall, SmBusAddress, 2, &Value, Status); + + return Value; +} + +/** + Executes an SMBUS read block command. + + Executes an SMBUS read block command on the SMBUS device specified by SmBusAddress. + Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required. + Bytes are read from the SMBUS and stored in Buffer. + The number of bytes read is returned, and will never return a value larger than 32-bytes. + If Status is not NULL, then the status of the executed command is returned in Status. + It is the caller's responsibility to make sure Buffer is large enough for the total number of bytes read. + SMBUS supports a maximum transfer size of 32 bytes, so Buffer does not need to be any larger than 32 bytes. + If Length in SmBusAddress is not zero, then ASSERT(). + If Buffer is NULL, then ASSERT(). + If any reserved bits of SmBusAddress are set, then ASSERT(). + + @param SmBusAddress Address that encodes the SMBUS Slave Address, + SMBUS Command, SMBUS Data Length, and PEC. + @param Buffer Pointer to the buffer to store the bytes read from the SMBUS. + @param Status Return status for the executed command. + This is an optional parameter and may be NULL. + + @return The number of bytes read. + +**/ +UINTN +EFIAPI +SmBusReadBlock ( + IN UINTN SmBusAddress, + OUT VOID *Buffer, + OUT RETURN_STATUS *Status OPTIONAL + ) +{ + ASSERT (Buffer != NULL); + ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) == 0); + ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0); + + return InternalSmBusExec (EfiSmbusReadBlock, SmBusAddress, 0x20, Buffer, Status); +} + +/** + Executes an SMBUS write block command. + + Executes an SMBUS write block command on the SMBUS device specified by SmBusAddress. + The SMBUS slave address, SMBUS command, and SMBUS length fields of SmBusAddress are required. + Bytes are written to the SMBUS from Buffer. + The number of bytes written is returned, and will never return a value larger than 32-bytes. + If Status is not NULL, then the status of the executed command is returned in Status. + If Length in SmBusAddress is zero or greater than 32, then ASSERT(). + If Buffer is NULL, then ASSERT(). + If any reserved bits of SmBusAddress are set, then ASSERT(). + + @param SmBusAddress Address that encodes the SMBUS Slave Address, + SMBUS Command, SMBUS Data Length, and PEC. + @param Buffer Pointer to the buffer to store the bytes read from the SMBUS. + @param Status Return status for the executed command. + This is an optional parameter and may be NULL. + + @return The number of bytes written. + +**/ +UINTN +EFIAPI +SmBusWriteBlock ( + IN UINTN SmBusAddress, + OUT VOID *Buffer, + OUT RETURN_STATUS *Status OPTIONAL + ) +{ + UINTN Length; + + ASSERT (Buffer != NULL); + ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) >= 1); + ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) <= 32); + ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0); + + Length = SMBUS_LIB_LENGTH (SmBusAddress); + return InternalSmBusExec (EfiSmbusWriteBlock, SmBusAddress, Length, Buffer, Status); +} + +/** + Executes an SMBUS block process call command. + + Executes an SMBUS block process call command on the SMBUS device specified by SmBusAddress. + The SMBUS slave address, SMBUS command, and SMBUS length fields of SmBusAddress are required. + Bytes are written to the SMBUS from WriteBuffer. Bytes are then read from the SMBUS into ReadBuffer. + If Status is not NULL, then the status of the executed command is returned in Status. + It is the caller's responsibility to make sure ReadBuffer is large enough for the total number of bytes read. + SMBUS supports a maximum transfer size of 32 bytes, so Buffer does not need to be any larger than 32 bytes. + If Length in SmBusAddress is zero or greater than 32, then ASSERT(). + If WriteBuffer is NULL, then ASSERT(). + If ReadBuffer is NULL, then ASSERT(). + If any reserved bits of SmBusAddress are set, then ASSERT(). + + @param SmBusAddress Address that encodes the SMBUS Slave Address, + SMBUS Command, SMBUS Data Length, and PEC. + @param WriteBuffer Pointer to the buffer of bytes to write to the SMBUS. + @param ReadBuffer Pointer to the buffer of bytes to read from the SMBUS. + @param Status Return status for the executed command. + This is an optional parameter and may be NULL. + + @return The number of bytes written. + +**/ +UINTN +EFIAPI +SmBusBlockProcessCall ( + IN UINTN SmBusAddress, + IN VOID *WriteBuffer, + OUT VOID *ReadBuffer, + OUT RETURN_STATUS *Status OPTIONAL + ) +{ + UINTN Length; + + ASSERT (WriteBuffer != NULL); + ASSERT (ReadBuffer != NULL); + ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) >= 1); + ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) <= 32); + ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0); + + Length = SMBUS_LIB_LENGTH (SmBusAddress); + // + // Assuming that ReadBuffer is large enough to save another memory copy. + // + ReadBuffer = CopyMem (ReadBuffer, WriteBuffer, Length); + return InternalSmBusExec (EfiSmbusBWBRProcessCall, SmBusAddress, Length, ReadBuffer, Status); +} diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/SmmFirmwarePerformanceLib/EdkIIGlueSmmFirmwarePerformanceLib.cif b/EDK/Foundation/Library/EdkIIGlueLib/Library/SmmFirmwarePerformanceLib/EdkIIGlueSmmFirmwarePerformanceLib.cif new file mode 100644 index 0000000..ef6464a --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/SmmFirmwarePerformanceLib/EdkIIGlueSmmFirmwarePerformanceLib.cif @@ -0,0 +1,11 @@ +<component> + name = "EdkIIGlueSmmFirmwarePerformanceLib" + category = ModulePart + LocalRoot = "Edk\Foundation\Library\EdkIIGlueLib\Library\SmmFirmwarePerformanceLib" + RefName = "EdkIIGlueSmmFirmwarePerformanceLib" +[files] +"EdkIIGlueSmmFirmwarePerformanceLib.sdl" +"EdkIIGlueSmmFirmwarePerformanceLib.mak" +"EdkIIGlueSmmFirmwarePerformanceLib.inf" +"EdkIIGlueSmmPerformanceLib.c" +<endComponent> diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/SmmFirmwarePerformanceLib/EdkIIGlueSmmFirmwarePerformanceLib.inf b/EDK/Foundation/Library/EdkIIGlueLib/Library/SmmFirmwarePerformanceLib/EdkIIGlueSmmFirmwarePerformanceLib.inf new file mode 100644 index 0000000..8568f7f --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/SmmFirmwarePerformanceLib/EdkIIGlueSmmFirmwarePerformanceLib.inf @@ -0,0 +1,81 @@ +#/*++ +# +# Copyright (c) 2011 - 2012, 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: +# +# EdkIIGlueSmmFirmwarePerformanceLib.inf +# +# Abstract: +# +# Component description file for SmmFirmwarePerformanceLib +# +#--*/ + +[defines] +BASE_NAME = EdkIIGlueSmmFirmwarePerformanceLib +COMPONENT_TYPE = LIBRARY + +[sources.common] + EdkIIGlueSmmPerformanceLib.c + +[sources.ia32] + +[sources.x64] + +[sources.ipf] + +[sources.ebc] + + +[includes.common] + . + ..\..\Include + ..\..\include\Library + $(EDK_SOURCE)\Foundation + $(EDK_SOURCE)\Foundation\Framework + $(EDK_SOURCE)\Foundation\Efi + $(EDK_SOURCE)\Foundation\Include + $(EDK_SOURCE)\Foundation\Efi\Include + $(EDK_SOURCE)\Foundation\Framework\Include + $(EDK_SOURCE)\Foundation\Include\IndustryStandard + $(EDK_SOURCE)\Foundation\Core\Dxe + $(EDK_SOURCE)\Foundation\Library\Dxe\Include + $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include + +[libraries.common] + EdkIIGlueBaseTimerLibLocalApic + EdkIIGlueUefiLib + EdkIIGlueBaseTimerLibTsc + +[libraries.ia32] + +[libraries.x64] + +[libraries.ebc] + + +[nmake.common] + C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION + LIB_STD_FLAGS = $(LIB_STD_FLAGS) /IGNORE:4006 /IGNORE:4221 + +[nmake.ia32] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32 + +[nmake.x64] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64 + +[nmake.ipf] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF + +[nmake.ebc] + EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION + EBC_LIB_STD_FLAGS = $(EBC_LIB_STD_FLAGS) /IGNORE:4006 /IGNORE:4221 + EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D MDE_CPU_EBC
\ No newline at end of file diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/SmmFirmwarePerformanceLib/EdkIIGlueSmmFirmwarePerformanceLib.mak b/EDK/Foundation/Library/EdkIIGlueLib/Library/SmmFirmwarePerformanceLib/EdkIIGlueSmmFirmwarePerformanceLib.mak new file mode 100644 index 0000000..b53d2ee --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/SmmFirmwarePerformanceLib/EdkIIGlueSmmFirmwarePerformanceLib.mak @@ -0,0 +1,79 @@ +#********************************************************************** +#********************************************************************** +#** ** +#** (C)Copyright 1985-2011, American Megatrends, Inc. ** +#** ** +#** All Rights Reserved. ** +#** ** +#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +#** ** +#** Phone: (770)-246-8600 ** +#** ** +#********************************************************************** +#********************************************************************** + +#********************************************************************** +# $Header: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGlueSmmFirmwarePerformanceLib/EdkIIGlueSmmFirmwarePerformanceLib.mak 1 1/20/12 3:59a Jeffch $ +# +# $Revision: 1 $ +# +# $Date: 1/20/12 3:59a $ +#********************************************************************** +# Revision History +# ---------------- +# $Log: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGlueSmmFirmwarePerformanceLib/EdkIIGlueSmmFirmwarePerformanceLib.mak $ +# +# 1 1/20/12 3:59a Jeffch +# Create Intel EDK 1117 Patch 7. +# +# 1 9/27/11 6:22a Wesleychen +# Intel EDK initially releases. +# +# +#********************************************************************** +#<AMI_FHDR_START> +# +# Name: EdkIIGlueSmmFirmwarePerformanceLib.mak +# +# Description: +# +#<AMI_FHDR_END> +#********************************************************************** + + +$(EdkIIGlueSmmFirmwarePerformanceLib_LIB) : EdkIIGlueSmmFirmwarePerformanceLib + +EdkIIGlueSmmFirmwarePerformanceLib : $(BUILD_DIR)\EdkIIGlueSmmFirmwarePerformanceLib.mak EdkIIGlueSmmFirmwarePerformanceLibBin + +$(BUILD_DIR)\EdkIIGlueSmmFirmwarePerformanceLib.mak : $(EdkIIGlueSmmFirmwarePerformanceLib_DIR)\$(@B).cif $(EdkIIGlueSmmFirmwarePerformanceLib_DIR)\$(@B).mak $(BUILD_RULES) + $(CIF2MAK) $(EdkIIGlueSmmFirmwarePerformanceLib_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS) + +EdkIIGlueSmmFirmwarePerformanceLibBin : $(EdkIIGlueBaseTimerLibLocalApic_LIB) $(EdkIIGlueUefiLib_LIB) $(EdkIIGlueBaseTimerLibTsc_LIB) $(EDKGUIDLIB) $(ARCHPROTOCOLLIB) +!IF "$(x64_BUILD)"=="1" + $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\ + BUILD_DIR=$(BUILD_DIR)\ + /f $(BUILD_DIR)\EdkIIGlueSmmFirmwarePerformanceLib.mak all\ + TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueSmmFirmwarePerformanceLib_LIB)" + $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\ + BUILD_DIR=$(BUILD_DIR)\IA32\ + /f $(BUILD_DIR)\EdkIIGlueSmmFirmwarePerformanceLib.mak all\ + TYPE=PEI_LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueSmmFirmwarePerformanceLib_LIB)" +!ELSE + $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\ + BUILD_DIR=$(BUILD_DIR)\ + /f $(BUILD_DIR)\EdkIIGlueSmmFirmwarePerformanceLib.mak all\ + TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueSmmFirmwarePerformanceLib_LIB)" +!ENDIF +#********************************************************************** +#********************************************************************** +#** ** +#** (C)Copyright 1985-2011, American Megatrends, Inc. ** +#** ** +#** All Rights Reserved. ** +#** ** +#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +#** ** +#** Phone: (770)-246-8600 ** +#** ** +#********************************************************************** +#**********************************************************************
\ No newline at end of file diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/SmmFirmwarePerformanceLib/EdkIIGlueSmmFirmwarePerformanceLib.sdl b/EDK/Foundation/Library/EdkIIGlueLib/Library/SmmFirmwarePerformanceLib/EdkIIGlueSmmFirmwarePerformanceLib.sdl new file mode 100644 index 0000000..dd89ca3 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/SmmFirmwarePerformanceLib/EdkIIGlueSmmFirmwarePerformanceLib.sdl @@ -0,0 +1,25 @@ +TOKEN + Name = "EdkIIGlueSmmFirmwarePerformanceLib_SUPPORT" + Value = "1" + Help = "Main switch to enable EdkIIGlueSmmFirmwarePerformanceLib support in Project" + TokenType = Boolean + TargetEQU = Yes + TargetMAK = Yes + Master = Yes +End + +TOKEN + Name = "EdkIIGlueSmmFirmwarePerformanceLib_LIB" + Value = "$$(LIB_BUILD_DIR)\EdkIIGlueSmmFirmwarePerformanceLib.lib" + TokenType = Expression + TargetMAK = Yes +End + +PATH + Name = "EdkIIGlueSmmFirmwarePerformanceLib_DIR" +End + +MODULE + Help = "Includes EdkIIGlueSmmFirmwarePerformanceLib.mak to Project" + File = "EdkIIGlueSmmFirmwarePerformanceLib.mak" +End
\ No newline at end of file diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/SmmFirmwarePerformanceLib/EdkIIGlueSmmPerformanceLib.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/SmmFirmwarePerformanceLib/EdkIIGlueSmmPerformanceLib.c new file mode 100644 index 0000000..880a502 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/SmmFirmwarePerformanceLib/EdkIIGlueSmmPerformanceLib.c @@ -0,0 +1,261 @@ +/*++ + +Copyright (c) 2011 - 2012, 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: + + EdkIIGlueSmmPerformanceLib.c + +Abstract: + + SMM Library for FPDT performance logging. + +--*/ + +#include "EdkIIGlueDxe.h" +#include EFI_PROTOCOL_DEFINITION (Fpdt) +#include EFI_PROTOCOL_DEFINITION (FirmwarePerformance) + +UINT64 *mStartTicker; +UINT32 mFunctionNumber; + +RUNTIME_MODULE_PERF_RECORD *mRuntimeModulePerfRecord = NULL; +RUNTIME_FUNCTION_PERF_RECORD *mRuntimeFunctionPerfRecord = NULL; + +EFI_GUID gFpdtPerformanceProtocolGuid = FPDT_PERFORMANCE_PROTOCOL_GUID; +EFI_GUID gEfiEventReadyToBootGuid = EFI_EVENT_GROUP_READY_TO_BOOT; + +EFI_STATUS +StartMeasureEx ( + IN EFI_HANDLE Handle, + IN UINT16 *Token, + IN UINT16 *Host, + IN UINT64 Timestamp, + IN UINT16 Identifier + ) +/*++ + +Routine Description: + + Start measurement according to token field. Inserts data into pre-allocatede memory buffer + Updates FPDT table using protocol API + +Arguments: + + Handle - Handle to measure + Token - Token to measure + Host - Host to measure + Timestamp - Ticker as start tick + Identifier - Identifier for a record + +Returns: + + EFI_SUCCESS - Located protocol successfully, and buffer is updated with new record + EFI_BUFFER_TOO_SMALL - Allocated memory is not enough to store new function + EFI_NOT_FOUND - Failure in update + +--*/ +{ + EFI_STATUS Status; + UINT32 Index; + UINT32 RmptTableLength; + + FPDT_PERFORMANCE_PROTOCOL *FpdtProtocol; + VOID *TableAddress; + EFI_GUID *GuidName; + RUNTIME_PERF_TABLE_HEADER *RuntimePerfTableHeader; + + RmptTableLength = 0; + + if (!StrCmp(Token, SMM_MODULE_TOK)) { + // + // Create RMPT table. The input Identifier specifies the max number of functions in this module. + // + mFunctionNumber = Identifier; + RmptTableLength = sizeof (RUNTIME_PERF_TABLE_HEADER) + + sizeof (RUNTIME_MODULE_PERF_RECORD) + + (sizeof(RUNTIME_FUNCTION_PERF_RECORD) * mFunctionNumber); + + // + // Allocate reseved memory for RMPT table + // + Status = (gBS->AllocatePool) (EfiReservedMemoryType, RmptTableLength, &TableAddress); + ZeroMem (TableAddress, RmptTableLength); + + Status = (gBS->AllocatePool) (EfiReservedMemoryType, sizeof (UINT64) * mFunctionNumber, &mStartTicker); + ZeroMem (mStartTicker, (sizeof (UINT64) * mFunctionNumber)); + + RuntimePerfTableHeader = (RUNTIME_PERF_TABLE_HEADER *) TableAddress; + mRuntimeModulePerfRecord = (RUNTIME_MODULE_PERF_RECORD *) ((UINT8 *) TableAddress + sizeof (RUNTIME_PERF_TABLE_HEADER)); + mRuntimeFunctionPerfRecord = (RUNTIME_FUNCTION_PERF_RECORD *) ((UINT8 *) mRuntimeModulePerfRecord + sizeof (RUNTIME_MODULE_PERF_RECORD)); + + // + // Fill RMPT table header + // + RuntimePerfTableHeader->Signature = RMPT_SIG; + RuntimePerfTableHeader->Length = RmptTableLength; + + GuidName = GetGuidFromHandle (Handle); + if (GuidName != NULL) { + (gBS->CopyMem) (&(RuntimePerfTableHeader->Guid), GuidName, sizeof (EFI_GUID)); + } + // + // Fill mRuntimeModulePerfRecord. + // + mRuntimeModulePerfRecord->RuntimeRecType = RUNTIME_MODULE_REC_TYPE; + mRuntimeModulePerfRecord->Revision = RECORD_REVISION_1; + mRuntimeModulePerfRecord->Reclength = sizeof (RUNTIME_MODULE_PERF_RECORD); + + // + // Call FPDT performance protocol to add RMPT table pointer record into FPDT table. + // + Status = (gBS->LocateProtocol) ( + &gFpdtPerformanceProtocolGuid, + NULL, + &FpdtProtocol + ); + ASSERT_EFI_ERROR (Status); + + if (!EFI_ERROR(Status)) { + Status = FpdtProtocol->UpdateRecord ( + FpdtProtocol, + Handle, + RUNTIME_MODULE_TABLE_PTR_TYPE, + (UINT64) TableAddress, + 0 + ); + ASSERT_EFI_ERROR (Status); + } + } + + if (!StrCmp (Token, SMM_FUNCTION_TOK)) { + // + // Add function record into RMPT table. + // The input Identifier is the function ID. + // + // + // Add function record into Record buffer. + // + for (Index = 0; Index < mFunctionNumber; Index++) { + if (mRuntimeFunctionPerfRecord[Index].RuntimeRecType == 0) { + // + // Fucntion ID is not found in Record buffer. + // + break; + } + + if (mRuntimeFunctionPerfRecord[Index].FunctionId == Identifier) { + // + // This function ID is found in Record buffer. + // + break; + } + } + + if (Index == mFunctionNumber) { + // + // Function record buffer is not enough to store new function. + // + return EFI_BUFFER_TOO_SMALL; + } + + if (mRuntimeFunctionPerfRecord[Index].RuntimeRecType == 0) { + // + // New function ID is found. Need to add it into FunctionRecord buffer. + // + mRuntimeFunctionPerfRecord[Index].RuntimeRecType = RUNTIME_FUNCTION_REC_TYPE; + mRuntimeFunctionPerfRecord[Index].Revision = RECORD_REVISION_1; + mRuntimeFunctionPerfRecord[Index].Reclength = sizeof (RUNTIME_FUNCTION_PERF_RECORD); + mRuntimeFunctionPerfRecord[Index].FunctionId = Identifier; + } + // + // Record start tick. + // + mStartTicker[Index] = GetTimeInNanoSec (Timestamp); + } + + return EFI_SUCCESS; +} + +EFI_STATUS +EndMeasureEx ( + IN EFI_HANDLE Handle, + IN UINT16 *Token, + IN UINT16 *Host, + IN UINT64 Timestamp, + IN UINT16 Identifier + ) +/*++ + +Routine Description: + + End measurement according to token field. Inserts data into pre-allocatede memory buffer + +Arguments: + + Handle - Handle to measure + Token - Token to measure + Host - Host to measure + Timestamp - Ticker as start tick + Identifier - Identifier for a record + +Returns: + + EFI_SUCCESS - Located protocol successfully, and buffer is updated with new record + EFI_BUFFER_TOO_SMALL - Allocated memory is not enough to store new function + EFI_NOT_FOUND - Fucntion ID is not found in Record buffer. + +--*/ +{ + UINT32 Index; + + if (!StrCmp (Token, SMM_FUNCTION_TOK)) { + // + // Update function record into RMPT table. + // The input Identifier is the function ID. + // + // + // Update function record into Record buffer. + // + for (Index = 0; Index < mFunctionNumber; Index++) { + if (mRuntimeFunctionPerfRecord[Index].RuntimeRecType == 0) { + // + // Fucntion ID is not found in Record buffer. + // + return EFI_NOT_FOUND; + } + + if (mRuntimeFunctionPerfRecord[Index].FunctionId == Identifier) { + // + // This function ID has been added. + // + break; + } + } + + if (Index == mFunctionNumber) { + // + // Fucntion ID is not found in Record buffer. + // + return EFI_NOT_FOUND; + } + + mRuntimeFunctionPerfRecord[Index].FunctionCallCount++; + mRuntimeFunctionPerfRecord[Index].FunctionResidency += (GetTimeInNanoSec (Timestamp)) - mStartTicker[Index]; + // + // Update Module Record. + // + mRuntimeModulePerfRecord->ModuleCallCount++; + mRuntimeModulePerfRecord->ModuleResidency += (GetTimeInNanoSec (Timestamp)) - mStartTicker[Index]; + } + + return EFI_SUCCESS; +}
\ No newline at end of file diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/SmmRuntimeDxeReportStatusCodeLib/EdkIIGlueSmmRuntimeDxeReportStatusCodeLib.cif b/EDK/Foundation/Library/EdkIIGlueLib/Library/SmmRuntimeDxeReportStatusCodeLib/EdkIIGlueSmmRuntimeDxeReportStatusCodeLib.cif new file mode 100644 index 0000000..8de103f --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/SmmRuntimeDxeReportStatusCodeLib/EdkIIGlueSmmRuntimeDxeReportStatusCodeLib.cif @@ -0,0 +1,13 @@ +<component> + name = "EdkIIGlueSmmRuntimeDxeReportStatusCodeLib" + category = ModulePart + LocalRoot = "Edk\Foundation\Library\EdkIIGlueLib\Library\SmmRuntimeDxeReportStatusCodeLib" + RefName = "EdkIIGlueSmmRuntimeDxeReportStatusCodeLib" +[files] +"EdkIIGlueSmmRuntimeDxeReportStatusCodeLib.sdl" +"EdkIIGlueSmmRuntimeDxeReportStatusCodeLib.mak" +"SmmRuntimeDxeReportStatusCodeLib.inf" +"ReportStatusCodeLib.c" +"SmmRuntimeDxeSupport.c" +"ReportStatusCodeLibInternal.h" +<endComponent> diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/SmmRuntimeDxeReportStatusCodeLib/EdkIIGlueSmmRuntimeDxeReportStatusCodeLib.mak b/EDK/Foundation/Library/EdkIIGlueLib/Library/SmmRuntimeDxeReportStatusCodeLib/EdkIIGlueSmmRuntimeDxeReportStatusCodeLib.mak new file mode 100644 index 0000000..6792693 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/SmmRuntimeDxeReportStatusCodeLib/EdkIIGlueSmmRuntimeDxeReportStatusCodeLib.mak @@ -0,0 +1,88 @@ +#********************************************************************** +#********************************************************************** +#** ** +#** (C)Copyright 1985-2009, American Megatrends, Inc. ** +#** ** +#** All Rights Reserved. ** +#** ** +#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +#** ** +#** Phone: (770)-246-8600 ** +#** ** +#********************************************************************** +#********************************************************************** + +#********************************************************************** +# $Header: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGlueSmmRuntimeDxeReportStatusCodeLib/EdkIIGlueSmmRuntimeDxeReportStatusCodeLib.mak 1 1/20/12 3:58a Jeffch $ +# +# $Revision: 1 $ +# +# $Date: 1/20/12 3:58a $ +#********************************************************************** +# Revision History +# ---------------- +# $Log: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGlueSmmRuntimeDxeReportStatusCodeLib/EdkIIGlueSmmRuntimeDxeReportStatusCodeLib.mak $ +# +# 1 1/20/12 3:58a Jeffch +# +# 1 9/27/11 6:20a Wesleychen +# Intel EDK initially releases. +# +# 2 1/23/11 10:01p Iminglin +# EIP52651 +# EdkIIGlueSMMRuntimeDxeReportStatusCodeLib includes +# $(EdkIIGlueUefiBootServicesTableLib_LIB) which will be a problem if +# there are any DEBUG messages in SMM code after booting to OS. Instead +# of this library EdkIIGlueUefiRuntimeServicesTableLib_LIB is used. +# +# 1 9/18/09 1:58a Iminglin +# +#********************************************************************** +#<AMI_FHDR_START> +# +# Name: EdkIIGlueSmmRuntimeDxeReportStatusCodeLib.mak +# +# Description: +# +#<AMI_FHDR_END> +#********************************************************************** +#all : EdkIIGlueSmmRuntimeDxeReportStatusCodeLib + +$(EdkIIGlueSmmRuntimeDxeReportStatusCodeLib_LIB) : EdkIIGlueSmmRuntimeDxeReportStatusCodeLib + +EdkIIGlueSmmRuntimeDxeReportStatusCodeLib : $(BUILD_DIR)\EdkIIGlueSmmRuntimeDxeReportStatusCodeLib.mak EdkIIGlueSmmRuntimeDxeReportStatusCodeLibBin + +$(BUILD_DIR)\EdkIIGlueSmmRuntimeDxeReportStatusCodeLib.mak : $(EdkIIGlueSmmRuntimeDxeReportStatusCodeLib_DIR)\$(@B).cif $(EdkIIGlueSmmRuntimeDxeReportStatusCodeLib_DIR)\$(@B).mak $(BUILD_RULES) + $(CIF2MAK) $(EdkIIGlueSmmRuntimeDxeReportStatusCodeLib_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS) + + +#EdkIIGlueSmmRuntimeDxeReportStatusCodeLibBin : $(EdkIIGlueBaseLib_LIB) $(EdkIIGlueBaseMemoryLib_LIB) $(EdkIIGlueUefiBootServicesTableLib_LIB) $(EdkIIGlueUefiRuntimeServicesTableLib_LIB) $(EFIPROTOCOLLIB) $(EDKGUIDLIB) $(ARCHPROTOCOLLIB) +EdkIIGlueSmmRuntimeDxeReportStatusCodeLibBin : $(EdkIIGlueUefiRuntimeServicesTableLib_LIB) $(EDKGUIDLIB) $(ARCHPROTOCOLLIB) $(EdkIIGlueBaseIoLibIntrinsic_LIB) $(EFIGUIDLIB) +!IF "$(x64_BUILD)"=="1" + $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\ + BUILD_DIR=$(BUILD_DIR)\ + /f $(BUILD_DIR)\EdkIIGlueSmmRuntimeDxeReportStatusCodeLib.mak all\ + TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueSmmRuntimeDxeReportStatusCodeLib_LIB)" + $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\ + BUILD_DIR=$(BUILD_DIR)\IA32\ + /f $(BUILD_DIR)\EdkIIGlueSmmRuntimeDxeReportStatusCodeLib.mak all\ + TYPE=PEI_LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueSmmRuntimeDxeReportStatusCodeLib_LIB)" +!ELSE + $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\ + BUILD_DIR=$(BUILD_DIR)\ + /f $(BUILD_DIR)\EdkIIGlueSmmRuntimeDxeReportStatusCodeLib.mak all\ + TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueSmmRuntimeDxeReportStatusCodeLib_LIB)" +!ENDIF +#********************************************************************** +#********************************************************************** +#** ** +#** (C)Copyright 1985-2009, American Megatrends, Inc. ** +#** ** +#** All Rights Reserved. ** +#** ** +#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +#** ** +#** Phone: (770)-246-8600 ** +#** ** +#********************************************************************** +#**********************************************************************
\ No newline at end of file diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/SmmRuntimeDxeReportStatusCodeLib/EdkIIGlueSmmRuntimeDxeReportStatusCodeLib.sdl b/EDK/Foundation/Library/EdkIIGlueLib/Library/SmmRuntimeDxeReportStatusCodeLib/EdkIIGlueSmmRuntimeDxeReportStatusCodeLib.sdl new file mode 100644 index 0000000..8464ca1 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/SmmRuntimeDxeReportStatusCodeLib/EdkIIGlueSmmRuntimeDxeReportStatusCodeLib.sdl @@ -0,0 +1,26 @@ +TOKEN + Name = "EdkIIGlueSmmRuntimeDxeReportStatusCodeLib_SUPPORT" + Value = "1" + Help = "Main switch to enable EdkIIGlueSmmRuntimeDxeReportStatusCodeLib support in Project" + TokenType = Boolean + TargetEQU = Yes + TargetMAK = Yes + Master = Yes +End + +TOKEN + Name = "EdkIIGlueSmmRuntimeDxeReportStatusCodeLib_LIB" + Value = "$$(LIB_BUILD_DIR)\EdkIIGlueSmmRuntimeDxeReportStatusCodeLib.lib" + TokenType = Expression + TargetMAK = Yes +End + +PATH + Name = "EdkIIGlueSmmRuntimeDxeReportStatusCodeLib_DIR" +End + +MODULE + Help = "Includes EdkIIGlueSmmRuntimeDxeReportStatusCodeLib.mak to Project" + File = "EdkIIGlueSmmRuntimeDxeReportStatusCodeLib.mak" +End + diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/SmmRuntimeDxeReportStatusCodeLib/ReportStatusCodeLib.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/SmmRuntimeDxeReportStatusCodeLib/ReportStatusCodeLib.c new file mode 100644 index 0000000..6bc5277 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/SmmRuntimeDxeReportStatusCodeLib/ReportStatusCodeLib.c @@ -0,0 +1,557 @@ +/*++ + +Copyright (c) 2004 - 2009, 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: + + ReportStatusCodeLib.c + +Abstract: + + Report Status Code Library for SMM Runtime driver. + +--*/ + +#include "ReportStatusCodeLibInternal.h" + + +EFI_REPORT_STATUS_CODE mReportStatusCode = NULL; + +/** + Internal worker function that reports a status code through the Status Code Protocol + + This function checks to see if a Status Code Protocol is present in the handle + database. If a Status Code Protocol is not present, then EFI_UNSUPPORTED is + returned. If a Status Code Protocol is present, then it is cached in gStatusCode, + and the ReportStatusCode() service of the Status Code Protocol is called passing in + Type, Value, Instance, CallerId, and Data. The result of this call is returned. + + @param Type Status code type. + @param Value Status code value. + @param Instance Status code instance number. + @param CallerId Pointer to a GUID that identifies the caller of this + function. This is an optional parameter that may be + NULL. + @param Data Pointer to the extended data buffer. This is an + optional parameter that may be NULL. + + @retval EFI_SUCCESS The status code was reported. + @retval EFI_OUT_OF_RESOURCES There were not enough resources to report the status code. + @retval EFI_UNSUPPORTED Status Code Protocol is not available. + +**/ +EFI_STATUS +InternalReportStatusCode ( + IN EFI_STATUS_CODE_TYPE Type, + IN EFI_STATUS_CODE_VALUE Value, + IN UINT32 Instance, + IN CONST EFI_GUID *CallerId OPTIONAL, + IN EFI_STATUS_CODE_DATA *Data OPTIONAL + ) +{ + // + // If gStatusCode is NULL, then see if a Status Code Protocol instance is present + // in the handle database. + // + if (mReportStatusCode == NULL) { + mReportStatusCode = InternalGetReportStatusCode (); + if (mReportStatusCode == NULL) { + return EFI_UNSUPPORTED; + } + } + + // + // A Status Code Protocol is present in the handle database, so pass in all the + // parameters to the ReportStatusCode() service of the Status Code Protocol + // + return (*mReportStatusCode) (Type, Value, Instance, (EFI_GUID *)CallerId, Data); +} + + +/** + Computes and returns the size, in bytes, of a device path. + + @param DevicePath A pointer to a device path. + + @return The size, in bytes, of DevicePath. + +**/ +UINTN +InternalReportStatusCodeDevicePathSize ( + IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath + ) +{ + CONST EFI_DEVICE_PATH_PROTOCOL *Start; + + // + // Search for the end of the device path structure + // + Start = DevicePath; + while (!IsDevicePathEnd (DevicePath)) { + DevicePath = NextDevicePathNode (DevicePath); + } + + // + // Subtract the start node from the end node and add in the size of the end node + // + return ((UINTN) DevicePath - (UINTN) Start) + DevicePathNodeLength (DevicePath); +} + + +/** + Converts a status code to an 8-bit POST code value. + + Converts the status code specified by CodeType and Value to an 8-bit POST code + and returns the 8-bit POST code in PostCode. If CodeType is an + EFI_PROGRESS_CODE or CodeType is an EFI_ERROR_CODE, then bits 0..4 of PostCode + are set to bits 16..20 of Value, and bits 5..7 of PostCode are set to bits + 24..26 of Value., and TRUE is returned. Otherwise, FALSE is returned. + + If PostCode is NULL, then ASSERT(). + + @param CodeType The type of status code being converted. + @param Value The status code value being converted. + @param PostCode A pointer to the 8-bit POST code value to return. + + @retval TRUE The status code specified by CodeType and Value was converted + to an 8-bit POST code and returned in PostCode. + @retval FALSE The status code specified by CodeType and Value could not be + converted to an 8-bit POST code value. + +**/ +BOOLEAN +EFIAPI +GlueCodeTypeToPostCode ( + IN EFI_STATUS_CODE_TYPE CodeType, + IN EFI_STATUS_CODE_VALUE Value, + OUT UINT8 *PostCode + ) +{ + // + // If PostCode is NULL, then ASSERT() + // + ASSERT (PostCode != NULL); + + // + // Convert Value to an 8 bit post code + // + if (((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_PROGRESS_CODE) || + ((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE) ) { + *PostCode = (UINT8) ((((Value & EFI_STATUS_CODE_CLASS_MASK) >> 24) << 5) | + (((Value & EFI_STATUS_CODE_SUBCLASS_MASK) >> 16) & 0x1f)); + return TRUE; + } + return FALSE; +} + + +/** + Extracts ASSERT() information from a status code structure. + + Converts the status code specified by CodeType, Value, and Data to the ASSERT() + arguments specified by Filename, Description, and LineNumber. If CodeType is + an EFI_ERROR_CODE, and CodeType has a severity of EFI_ERROR_UNRECOVERED, and + Value has an operation mask of EFI_SW_EC_ILLEGAL_SOFTWARE_STATE, extract + Filename, Description, and LineNumber from the optional data area of the + status code buffer specified by Data. The optional data area of Data contains + a Null-terminated ASCII string for the FileName, followed by a Null-terminated + ASCII string for the Description, followed by a 32-bit LineNumber. If the + ASSERT() information could be extracted from Data, then return TRUE. + Otherwise, FALSE is returned. + + If Data is NULL, then ASSERT(). + If Filename is NULL, then ASSERT(). + If Description is NULL, then ASSERT(). + If LineNumber is NULL, then ASSERT(). + + @param CodeType The type of status code being converted. + @param Value The status code value being converted. + @param Data Pointer to status code data buffer. + @param Filename Pointer to the source file name that generated the ASSERT(). + @param Description Pointer to the description of the ASSERT(). + @param LineNumber Pointer to source line number that generated the ASSERT(). + + @retval TRUE The status code specified by CodeType, Value, and Data was + converted ASSERT() arguments specified by Filename, Description, + and LineNumber. + @retval FALSE The status code specified by CodeType, Value, and Data could + not be converted to ASSERT() arguments. + +**/ +BOOLEAN +EFIAPI +GlueReportStatusCodeExtractAssertInfo ( + IN EFI_STATUS_CODE_TYPE CodeType, + IN EFI_STATUS_CODE_VALUE Value, + IN CONST EFI_STATUS_CODE_DATA *Data, + OUT CHAR8 **Filename, + OUT CHAR8 **Description, + OUT UINT32 *LineNumber + ) +{ + EFI_DEBUG_ASSERT_DATA *AssertData; + + ASSERT (Data != NULL); + ASSERT (Filename != NULL); + ASSERT (Description != NULL); + ASSERT (LineNumber != NULL); + + if (((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE) && + ((CodeType & EFI_STATUS_CODE_SEVERITY_MASK) == EFI_ERROR_UNRECOVERED) && + ((Value & EFI_STATUS_CODE_OPERATION_MASK) == EFI_SW_EC_ILLEGAL_SOFTWARE_STATE)) { + AssertData = (EFI_DEBUG_ASSERT_DATA *)(Data + 1); + *Filename = (CHAR8 *)(AssertData + 1); + *Description = *Filename + AsciiStrLen (*Filename) + 1; + *LineNumber = AssertData->LineNumber; + return TRUE; + } + return FALSE; +} + + +/** + Extracts DEBUG() information from a status code structure. + + Converts the status code specified by Data to the DEBUG() arguments specified + by ErrorLevel, Marker, and Format. If type GUID in Data is + EFI_STATUS_CODE_DATA_TYPE_DEBUG_GUID, then extract ErrorLevel, Marker, and + Format from the optional data area of the status code buffer specified by Data. + The optional data area of Data contains a 32-bit ErrorLevel followed by Marker + which is 12 UINTN parameters, followed by a Null-terminated ASCII string for + the Format. If the DEBUG() information could be extracted from Data, then + return TRUE. Otherwise, FALSE is returned. + + If Data is NULL, then ASSERT(). + If ErrorLevel is NULL, then ASSERT(). + If Marker is NULL, then ASSERT(). + If Format is NULL, then ASSERT(). + + @param Data Pointer to status code data buffer. + @param ErrorLevel Pointer to error level mask for a debug message. + @param Marker Pointer to the variable argument list associated with Format. + @param Format Pointer to a Null-terminated ASCII format string of a + debug message. + + @retval TRUE The status code specified by Data was converted DEBUG() arguments + specified by ErrorLevel, Marker, and Format. + @retval FALSE The status code specified by Data could not be converted to + DEBUG() arguments. + +**/ +BOOLEAN +EFIAPI +GlueReportStatusCodeExtractDebugInfo ( + IN CONST EFI_STATUS_CODE_DATA *Data, + OUT UINT32 *ErrorLevel, + OUT VA_LIST *Marker, + OUT CHAR8 **Format + ) +{ + EFI_DEBUG_INFO *DebugInfo; + + ASSERT (Data != NULL); + ASSERT (ErrorLevel != NULL); + ASSERT (Marker != NULL); + ASSERT (Format != NULL); + + // + // If the GUID type is not EFI_STATUS_CODE_DATA_TYPE_DEBUG_GUID then return FALSE + // + if (!CompareGuid (&Data->Type, &gEfiStatusCodeDataTypeDebugGuid)) { + return FALSE; + } + + // + // Retrieve the debug information from the status code record + // + DebugInfo = (EFI_DEBUG_INFO *)(Data + 1); + + *ErrorLevel = DebugInfo->ErrorLevel; + + // + // The first 12 * UINTN bytes of the string are really an + // argument stack to support varargs on the Format string. + // + *Marker = (VA_LIST) (DebugInfo + 1); + *Format = (CHAR8 *)(((UINT64 *)*Marker) + 12); + + return TRUE; +} + + +/** + Reports a status code. + + Reports the status code specified by the parameters Type and Value. Status + code also require an instance, caller ID, and extended data. This function + passed in a zero instance, NULL extended data, and a caller ID of + gEfiCallerIdGuid, which is the GUID for the module. + + ReportStatusCode()must actively prevent recusrsion. If ReportStatusCode() + is called while processing another any other Report Status Code Library function, + then ReportStatusCode() must return immediately. + + @param Type Status code type. + @param Value Status code value. + + @retval EFI_SUCCESS The status code was reported. + @retval EFI_DEVICE_ERROR There status code could not be reported due to a + device error. + @retval EFI_UNSUPPORTED Report status code is not supported + +**/ +EFI_STATUS +EFIAPI +GlueReportStatusCode ( + IN EFI_STATUS_CODE_TYPE Type, + IN EFI_STATUS_CODE_VALUE Value + ) +{ + return InternalReportStatusCode (Type, Value, 0, &gEfiCallerIdGuid, NULL); +} + + +/** + Reports a status code with a Device Path Protocol as the extended data. + + Allocates and fills in the extended data section of a status code with the + Device Path Protocol specified by DevicePath. This function is responsible + for allocating a buffer large enough for the standard header and the device + path. The standard header is filled in with a GUID of + gEfiStatusCodeSpecificDataGuid. The status code is reported with a zero + instance and a caller ID of gEfiCallerIdGuid. + + ReportStatusCodeWithDevicePath()must actively prevent recursion. If + ReportStatusCodeWithDevicePath() is called while processing another any other + Report Status Code Library function, then ReportStatusCodeWithDevicePath() + must return EFI_DEVICE_ERROR immediately. + + If DevicePath is NULL, then ASSERT(). + + @param Type Status code type. + @param Value Status code value. + @param DevicePath Pointer to the Device Path Protocol to be reported. + + @retval EFI_SUCCESS The status code was reported with the extended + data specified by DevicePath. + @retval EFI_OUT_OF_RESOURCES There were not enough resources to allocate the + extended data section. + @retval EFI_UNSUPPORTED Report status code is not supported + +**/ +EFI_STATUS +EFIAPI +GlueReportStatusCodeWithDevicePath ( + IN EFI_STATUS_CODE_TYPE Type, + IN EFI_STATUS_CODE_VALUE Value, + IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath + ) +{ + ASSERT (DevicePath != NULL); + return ReportStatusCodeWithExtendedData ( + Type, + Value, + (VOID *)DevicePath, + InternalReportStatusCodeDevicePathSize (DevicePath) + ); +} + + +/** + Reports a status code with an extended data buffer. + + Allocates and fills in the extended data section of a status code with the + extended data specified by ExtendedData and ExtendedDataSize. ExtendedData + is assumed to be one of the data structures specified in Related Definitions. + These data structure do not have the standard header, so this function is + responsible for allocating a buffer large enough for the standard header and + the extended data passed into this function. The standard header is filled + in with a GUID of gEfiStatusCodeSpecificDataGuid. The status code is reported + with a zero instance and a caller ID of gEfiCallerIdGuid. + + ReportStatusCodeWithExtendedData()must actively prevent recursion. If + ReportStatusCodeWithExtendedData() is called while processing another any other + Report Status Code Library function, then ReportStatusCodeWithExtendedData() + must return EFI_DEVICE_ERROR immediately. + + If ExtendedData is NULL, then ASSERT(). + If ExtendedDataSize is 0, then ASSERT(). + + @param Type Status code type. + @param Value Status code value. + @param ExtendedData Pointer to the extended data buffer to be reported. + @param ExtendedDataSize The size, in bytes, of the extended data buffer to + be reported. + + @retval EFI_SUCCESS The status code was reported with the extended + data specified by ExtendedData and ExtendedDataSize. + @retval EFI_OUT_OF_RESOURCES There were not enough resources to allocate the + extended data section. + @retval EFI_UNSUPPORTED Report status code is not supported + +**/ +EFI_STATUS +EFIAPI +GlueReportStatusCodeWithExtendedData ( + IN EFI_STATUS_CODE_TYPE Type, + IN EFI_STATUS_CODE_VALUE Value, + IN CONST VOID *ExtendedData, + IN UINTN ExtendedDataSize + ) +{ + ASSERT (ExtendedData != NULL); + ASSERT (ExtendedDataSize != 0); + return ReportStatusCodeEx ( + Type, + Value, + 0, + NULL, + NULL, + ExtendedData, + ExtendedDataSize + ); +} + + +/** + Reports a status code with full parameters. + + The function reports a status code. If ExtendedData is NULL and ExtendedDataSize + is 0, then an extended data buffer is not reported. If ExtendedData is not + NULL and ExtendedDataSize is not 0, then an extended data buffer is allocated. + ExtendedData is assumed not have the standard status code header, so this function + is responsible for allocating a buffer large enough for the standard header and + the extended data passed into this function. The standard header is filled in + with a GUID specified by ExtendedDataGuid. If ExtendedDataGuid is NULL, then a + GUID of gEfiStatusCodeSpecificDatauid is used. The status code is reported with + an instance specified by Instance and a caller ID specified by CallerId. If + CallerId is NULL, then a caller ID of gEfiCallerIdGuid is used. + + ReportStatusCodeEx()must actively prevent recursion. If + ReportStatusCodeEx() is called while processing another any + other Report Status Code Library function, then + ReportStatusCodeEx() must return EFI_DEVICE_ERROR immediately. + + If ExtendedData is NULL and ExtendedDataSize is not zero, then ASSERT(). + If ExtendedData is not NULL and ExtendedDataSize is zero, then ASSERT(). + + @param Type Status code type. + @param Value Status code value. + @param Instance Status code instance number. + @param CallerId Pointer to a GUID that identifies the caller of this + function. If this parameter is NULL, then a caller + ID of gEfiCallerIdGuid is used. + @param ExtendedDataGuid Pointer to the GUID for the extended data buffer. + If this parameter is NULL, then a the status code + standard header is filled in with + gEfiStatusCodeSpecificDataGuid. + @param ExtendedData Pointer to the extended data buffer. This is an + optional parameter that may be NULL. + @param ExtendedDataSize The size, in bytes, of the extended data buffer. + + @retval EFI_SUCCESS The status code was reported. + @retval EFI_OUT_OF_RESOURCES There were not enough resources to allocate + the extended data section if it was specified. + @retval EFI_UNSUPPORTED Report status code is not supported + +**/ +EFI_STATUS +EFIAPI +GlueReportStatusCodeEx ( + IN EFI_STATUS_CODE_TYPE Type, + IN EFI_STATUS_CODE_VALUE Value, + IN UINT32 Instance, + IN CONST EFI_GUID *CallerId OPTIONAL, + IN CONST EFI_GUID *ExtendedDataGuid OPTIONAL, + IN CONST VOID *ExtendedData OPTIONAL, + IN UINTN ExtendedDataSize + ) +{ + EFI_STATUS Status; + + Status = InternalReportStatusCodeEx ( + Type, + Value, + Instance, + CallerId, + ExtendedDataGuid, + ExtendedData, + ExtendedDataSize + ); + + return Status; +} + + +/** + Returns TRUE if status codes of type EFI_PROGRESS_CODE are enabled + + This function returns TRUE if the REPORT_STATUS_CODE_PROPERTY_PROGRESS_CODE_ENABLED + bit of PcdReportStatusCodeProperyMask is set. Otherwise FALSE is returned. + + @retval TRUE The REPORT_STATUS_CODE_PROPERTY_PROGRESS_CODE_ENABLED bit of + PcdReportStatusCodeProperyMask is set. + @retval FALSE The REPORT_STATUS_CODE_PROPERTY_PROGRESS_CODE_ENABLED bit of + PcdReportStatusCodeProperyMask is clear. + +**/ +BOOLEAN +EFIAPI +GlueReportProgressCodeEnabled ( + VOID + ) +{ + return (BOOLEAN) ((PcdGet8(PcdReportStatusCodePropertyMask) & REPORT_STATUS_CODE_PROPERTY_PROGRESS_CODE_ENABLED) != 0); +} + + +/** + Returns TRUE if status codes of type EFI_ERROR_CODE are enabled + + This function returns TRUE if the REPORT_STATUS_CODE_PROPERTY_ERROR_CODE_ENABLED + bit of PcdReportStatusCodeProperyMask is set. Otherwise FALSE is returned. + + @retval TRUE The REPORT_STATUS_CODE_PROPERTY_ERROR_CODE_ENABLED bit of + PcdReportStatusCodeProperyMask is set. + @retval FALSE The REPORT_STATUS_CODE_PROPERTY_ERROR_CODE_ENABLED bit of + PcdReportStatusCodeProperyMask is clear. + +**/ +BOOLEAN +EFIAPI +GlueReportErrorCodeEnabled ( + VOID + ) +{ + return (BOOLEAN) ((PcdGet8(PcdReportStatusCodePropertyMask) & REPORT_STATUS_CODE_PROPERTY_ERROR_CODE_ENABLED) != 0); +} + + +/** + Returns TRUE if status codes of type EFI_DEBUG_CODE are enabled + + This function returns TRUE if the REPORT_STATUS_CODE_PROPERTY_DEBUG_CODE_ENABLED + bit of PcdReportStatusCodeProperyMask is set. Otherwise FALSE is returned. + + @retval TRUE The REPORT_STATUS_CODE_PROPERTY_DEBUG_CODE_ENABLED bit of + PcdReportStatusCodeProperyMask is set. + @retval FALSE The REPORT_STATUS_CODE_PROPERTY_DEBUG_CODE_ENABLED bit of + PcdReportStatusCodeProperyMask is clear. + +**/ +BOOLEAN +EFIAPI +GlueReportDebugCodeEnabled ( + VOID + ) +{ + return (BOOLEAN) ((PcdGet8(PcdReportStatusCodePropertyMask) & REPORT_STATUS_CODE_PROPERTY_DEBUG_CODE_ENABLED) != 0); +} diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/SmmRuntimeDxeReportStatusCodeLib/ReportStatusCodeLibInternal.h b/EDK/Foundation/Library/EdkIIGlueLib/Library/SmmRuntimeDxeReportStatusCodeLib/ReportStatusCodeLibInternal.h new file mode 100644 index 0000000..2bc0e03 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/SmmRuntimeDxeReportStatusCodeLib/ReportStatusCodeLibInternal.h @@ -0,0 +1,128 @@ +/*++ + +Copyright (c) 2004 - 2009, 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: + + ReportStatusCodeLibInternal.h + +Abstract: + + Internal Header file of Report Status Code Library for RUNTIME + DXE Phase. + +--*/ + +#ifndef __REPORT_STATUS_CODE_LIB_INTERNAL__H +#define __REPORT_STATUS_CODE_LIB_INTERNAL__H + +#include "EdkIIGlueDxe.h" + +/** + Locatet he report status code service. + + @return EFI_REPORT_STATUS_CODE function point to + ReportStatusCode. +**/ +EFI_REPORT_STATUS_CODE +InternalGetReportStatusCode ( + VOID + ); + +/** + Internal worker function that reports a status code through the Status Code Protocol + + This function checks to see if a Status Code Protocol is present in the handle + database. If a Status Code Protocol is not present, then EFI_UNSUPPORTED is + returned. If a Status Code Protocol is present, then it is cached in gStatusCode, + and the ReportStatusCode() service of the Status Code Protocol is called passing in + Type, Value, Instance, CallerId, and Data. The result of this call is returned. + + @param Type Status code type. + @param Value Status code value. + @param Instance Status code instance number. + @param CallerId Pointer to a GUID that identifies the caller of this + function. This is an optional parameter that may be + NULL. + @param Data Pointer to the extended data buffer. This is an + optional parameter that may be NULL. + + @retval EFI_SUCCESS The status code was reported. + @retval EFI_OUT_OF_RESOURCES There were not enough resources to report the status code. + @retval EFI_UNSUPPORTED Status Code Protocol is not available. + +**/ +EFI_STATUS +InternalReportStatusCode ( + IN EFI_STATUS_CODE_TYPE Type, + IN EFI_STATUS_CODE_VALUE Value, + IN UINT32 Instance, + IN CONST EFI_GUID *CallerId OPTIONAL, + IN EFI_STATUS_CODE_DATA *Data OPTIONAL + ); + +/** + Reports a status code with full parameters. + + The function reports a status code. If ExtendedData is NULL and ExtendedDataSize + is 0, then an extended data buffer is not reported. If ExtendedData is not + NULL and ExtendedDataSize is not 0, then an extended data buffer is allocated. + ExtendedData is assumed not have the standard status code header, so this function + is responsible for allocating a buffer large enough for the standard header and + the extended data passed into this function. The standard header is filled in + with a GUID specified by ExtendedDataGuid. If ExtendedDataGuid is NULL, then a + GUID of gEfiStatusCodeSpecificDatauid is used. The status code is reported with + an instance specified by Instance and a caller ID specified by CallerId. If + CallerId is NULL, then a caller ID of gEfiCallerIdGuid is used. + + ReportStatusCodeEx()must actively prevent recursion. If ReportStatusCodeEx() + is called while processing another any other Report Status Code Library function, + then ReportStatusCodeEx() must return EFI_DEVICE_ERROR immediately. + + If ExtendedData is NULL and ExtendedDataSize is not zero, then ASSERT(). + If ExtendedData is not NULL and ExtendedDataSize is zero, then ASSERT(). + + @param Type Status code type. + @param Value Status code value. + @param Instance Status code instance number. + @param CallerId Pointer to a GUID that identifies the caller of this + function. If this parameter is NULL, then a caller + ID of gEfiCallerIdGuid is used. + @param ExtendedDataGuid Pointer to the GUID for the extended data buffer. + If this parameter is NULL, then a the status code + standard header is filled in with + gEfiStatusCodeSpecificDataGuid. + @param ExtendedData Pointer to the extended data buffer. This is an + optional parameter that may be NULL. + @param ExtendedDataSize The size, in bytes, of the extended data buffer. + + @retval EFI_SUCCESS The status code was reported. + @retval EFI_OUT_OF_RESOURCES There were not enough resources to allocate + the extended data section if it was specified. + @retval EFI_UNSUPPORTED Report status code is not supported + +**/ +EFI_STATUS +EFIAPI +InternalReportStatusCodeEx ( + IN EFI_STATUS_CODE_TYPE Type, + IN EFI_STATUS_CODE_VALUE Value, + IN UINT32 Instance, + IN CONST EFI_GUID *CallerId OPTIONAL, + IN CONST EFI_GUID *ExtendedDataGuid OPTIONAL, + IN CONST VOID *ExtendedData OPTIONAL, + IN UINTN ExtendedDataSize + ); + +extern EFI_REPORT_STATUS_CODE mReportStatusCode; + +#endif // __REPORT_STATUS_CODE_LIB_INTERNAL__H + diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/SmmRuntimeDxeReportStatusCodeLib/SmmRuntimeDxeReportStatusCodeLib.inf b/EDK/Foundation/Library/EdkIIGlueLib/Library/SmmRuntimeDxeReportStatusCodeLib/SmmRuntimeDxeReportStatusCodeLib.inf new file mode 100644 index 0000000..c89be29 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/SmmRuntimeDxeReportStatusCodeLib/SmmRuntimeDxeReportStatusCodeLib.inf @@ -0,0 +1,96 @@ +#/*++ +# +# Copyright (c) 2004 - 2011, 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: +# +# SmmRuntimeDxeReportStatusCodeLib.inf +# +# Abstract: +# +# Component description file for SmmRuntimeDxeReportStatusCodeLib +# +#--*/ + +[defines] +BASE_NAME = EdkIIGlueSmmRuntimeDxeReportStatusCodeLib +COMPONENT_TYPE = LIBRARY + +[sources.common] + ReportStatusCodeLib.c + SmmRuntimeDxeSupport.c + ReportStatusCodeLibInternal.h + +[sources.ia32] + +[sources.x64] + +[sources.ipf] + +[sources.ebc] + + +[includes.common] + . + ..\..\Include + ..\..\include\Library + $(EDK_SOURCE)\Foundation + $(EDK_SOURCE)\Foundation\Framework + $(EDK_SOURCE)\Foundation\Efi + $(EDK_SOURCE)\Foundation\Include + $(EDK_SOURCE)\Foundation\Efi\Include + $(EDK_SOURCE)\Foundation\Framework\Include + $(EDK_SOURCE)\Foundation\Include\IndustryStandard + $(EDK_SOURCE)\Foundation\Core\Dxe + $(EDK_SOURCE)\Foundation\Library\Dxe\Include + $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include + $(EDK_SOURCE)\Foundation\Framework\Guid\DataHubRecords + $(EDK_SOURCE)\Foundation\Framework\Guid\StatusCodeDataTypeId + $(EDK_SOURCE)\Foundation\Core\Dxe\ArchProtocol\StatusCode + +[libraries.common] + EdkIIGlueBaseLib + EdkIIGlueBaseMemoryLib + EdkIIGlueUefiBootServicesTableLib +# +# when EFI_SPECIFICATION_VERSION < 0x00020000, gRT is used +# + EdkIIGlueUefiRuntimeServicesTableLib +# R8.x lib + EfiProtocolLib +# Possibly, gEfiCallerIdGuid might be used. + EdkGuidLib + ArchProtocolLib + EfiGuidLib + +[libraries.ia32] + +[libraries.x64] + +[libraries.ebc] + + +[nmake.common] + C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION + LIB_STD_FLAGS = $(LIB_STD_FLAGS) /IGNORE:4006 /IGNORE:4221 + +[nmake.ia32] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32 + +[nmake.x64] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64 + +[nmake.ipf] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF + +[nmake.ebc] + EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION + EBC_LIB_STD_FLAGS = $(EBC_LIB_STD_FLAGS) /IGNORE:4006 /IGNORE:4221 + EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D MDE_CPU_EBC diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/SmmRuntimeDxeReportStatusCodeLib/SmmRuntimeDxeSupport.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/SmmRuntimeDxeReportStatusCodeLib/SmmRuntimeDxeSupport.c new file mode 100644 index 0000000..07b1487 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/SmmRuntimeDxeReportStatusCodeLib/SmmRuntimeDxeSupport.c @@ -0,0 +1,698 @@ +/*++ + +Copyright (c) 2004 - 2011, 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: + + SmmRuntimeDxeSupport.c + +Abstract: + + Report Status Code Library for DXE Phase. + +--*/ + +#include "ReportStatusCodeLibInternal.h" +#include EFI_PROTOCOL_DEFINITION (SmmStatusCode) +#include EFI_GUID_DEFINITION (GlobalVariable) + +#define DEBUG_MASK_VARIABLE_NAME L"EFIDebug" + +EFI_EVENT mVirtualAddressChangeEvent; +EFI_EVENT mExitBootServicesEvent; +EFI_EVENT mSmmStatusCodeEvent = NULL; +EFI_STATUS_CODE_DATA *mStatusCodeData; +BOOLEAN mInSmm; +EFI_SMM_BASE_PROTOCOL *mSmmBase; +EFI_RUNTIME_SERVICES *mRTSmmRuntimeDxeReportStatusCodeLib; +BOOLEAN mHaveExitedBootServices = FALSE; +EFI_SMM_STATUS_CODE_PROTOCOL *mSmmStatusCode; +UINTN mErrorLevel = EDKII_GLUE_DebugPrintErrorLevel; +BOOLEAN mDebugMaskInitialized = FALSE; + +EFI_STATUS +InstallSmmDebugMaskProtocol ( + IN EFI_HANDLE ImageHandle + ); + +EFI_STATUS +InstallRuntimeDebugMaskProtocol ( + IN EFI_HANDLE ImageHandle + ); + +EFI_STATUS +UnInstallRuntimeDebugMaskProtocol ( + IN EFI_HANDLE ImageHandle + ); + +EFI_STATUS +UnInstallSmmDebugMaskProtocol ( + IN EFI_HANDLE ImageHandle + ); + +VOID +InitializeDebugMask ( + ) +/*++ + +Routine Description: + + Initialize the debug mask when the variable service is ready. + +--*/ +{ + EFI_STATUS Status; + UINTN DebugMask; + UINTN DataSize; + + DataSize = sizeof(UINTN); + Status = gRT->GetVariable( + DEBUG_MASK_VARIABLE_NAME, + &gEfiGlobalVariableGuid, + NULL, + &DataSize, + &DebugMask + ); + + if (Status != EFI_NOT_AVAILABLE_YET) { + // + // If EFI Variable Services are available, then set a flag so the EFI + // Variable will not be read again by this module. + // + mDebugMaskInitialized = TRUE; + if (!EFI_ERROR (Status)) { + // + // If the EFI Varible exists, then set this module's module's mask to + // the global level mask value. + // + mErrorLevel = DebugMask; + } + } +} + +EFI_STATUS +EFIAPI +GetDebugMask ( + IN EFI_DEBUG_MASK_PROTOCOL *This, // Calling context + IN OUT UINTN *CurrentDebugMask // Ptr to store current debug mask + ) +/*++ + +Routine Description: + DebugMask protocol member function. + Gets the current debug mask for an image, on which this protocol has been installed. + +Arguments: + + This - Indicates calling context + CurrentDebugMask - Ptr to store current debug mask + +Returns: + EFI_SUCCESS - Debug mask is retrieved successfully + EFI_INVALID_PARAMETER - CurrentDebugMask is NULL. + EFI_UNSUPPORTED - The handle on which this protocol is installed is not an image handle. + +--*/ +{ + // + // Check Parameter + // + if (CurrentDebugMask == NULL){ + return EFI_INVALID_PARAMETER; + } + + *CurrentDebugMask = mErrorLevel; + return EFI_SUCCESS; +} + +EFI_STATUS +EFIAPI +SetDebugMask ( + IN EFI_DEBUG_MASK_PROTOCOL *This, // Calling context + IN UINTN NewDebugMask // New Debug Mask value to set + ) +/*++ + +Routine Description: + DebugMask protocol member function. + Updates the current debug mask for an image, on which this protocol has been installed. + +Arguments: + + This - Calling context + NewDebugMask - New Debug Mask value to set + +Returns: + EFI_SUCCESS - Debug mask is updated with the new value successfully + EFI_UNSUPPORTED - The handle on which this protocol is installed is not an image handle. + +--*/ +{ + + if (!mDebugMaskInitialized) { + // + // If DebugMask is set, it is initialized. Don't need to init again. + // + mDebugMaskInitialized = TRUE; + } + + mErrorLevel = NewDebugMask; + return EFI_SUCCESS; +} + +// +// Debug Mask Protocol instance +// +EFI_DEBUG_MASK_PROTOCOL mDebugMaskProtocol = { + EFI_DEBUG_MASK_REVISION, + GetDebugMask, + SetDebugMask +}; + +EFI_STATUS +InstallSmmDebugMaskProtocol ( + IN EFI_HANDLE ImageHandle + ) +/*++ + +Routine Description: + + Install Smm debug mask protocol on an image handle. + +Arguments: + + ImageHandle - Image handle which debug mask protocol will install on + +Returns: + + EFI_INVALID_PARAMETER - Invalid image handle + EFI_OUT_OF_RESOURCES - No enough buffer could be allocated + EFI_SUCCESS - Debug mask protocol successfully installed + +--*/ +{ + EFI_STATUS Status; + + // + // Install Debug Mask Protocol in Image Handle + // + Status = gBS->InstallProtocolInterface ( + &ImageHandle, + &gEfiSmmDebugMaskProtocolGuid, + EFI_NATIVE_INTERFACE, + &mDebugMaskProtocol + ); + return Status; +} + +EFI_STATUS +UnInstallSmmDebugMaskProtocol ( + IN EFI_HANDLE ImageHandle + ) +/*++ + +Routine Description: + + Uninstall Smm debug mask protocol on an image handle. + +Arguments: + + ImageHandle - Image handle which debug mask protocol will uninstall on + +Returns: + + EFI_INVALID_PARAMETER - Invalid image handle + EFI_SUCCESS - Debug mask protocol successfully uninstalled + +--*/ +{ + EFI_STATUS Status; + + if (ImageHandle == NULL) { + return EFI_INVALID_PARAMETER; + } + + // + // Install Debug Mask Protocol in Image Handle + // + Status = gBS->UninstallProtocolInterface ( + &ImageHandle, + &gEfiSmmDebugMaskProtocolGuid, + &mDebugMaskProtocol + ); + + if (EFI_ERROR (Status)) { + return Status; + } + return EFI_SUCCESS; +} + +EFI_STATUS +InstallRuntimeDebugMaskProtocol ( + IN EFI_HANDLE ImageHandle + ) +/*++ + +Routine Description: + + Install Runtime debug mask protocol on an image handle. + +Arguments: + + ImageHandle - Image handle which debug mask protocol will install on + +Returns: + + EFI_INVALID_PARAMETER - Invalid image handle + EFI_OUT_OF_RESOURCES - No enough buffer could be allocated + EFI_SUCCESS - Debug mask protocol successfully installed + +--*/ +{ + EFI_STATUS Status; + + // + // Install Debug Mask Protocol in Image Handle + // + Status = gBS->InstallProtocolInterface ( + &ImageHandle, + &gEfiRuntimeDebugMaskProtocolGuid, + EFI_NATIVE_INTERFACE, + &mDebugMaskProtocol + ); + return EFI_SUCCESS; +} + +EFI_STATUS +UnInstallRuntimeDebugMaskProtocol ( + IN EFI_HANDLE ImageHandle + ) +/*++ + +Routine Description: + + Uninstall Runtime debug mask protocol on an image handle. + +Arguments: + + ImageHandle - Image handle which debug mask protocol will uninstall on + +Returns: + + EFI_INVALID_PARAMETER - Invalid image handle + EFI_SUCCESS - Debug mask protocol successfully uninstalled + +--*/ +{ + EFI_STATUS Status; + + if (ImageHandle == NULL) { + return EFI_INVALID_PARAMETER; + } + + // + // Remove Protocol from ImageHandle + // + Status = gBS->UninstallProtocolInterface ( + ImageHandle, + &gEfiDebugMaskProtocolGuid, + &mDebugMaskProtocol + ); + if (EFI_ERROR (Status)) { + return Status; + } + return EFI_SUCCESS; +} + +VOID +EFIAPI +InitializeSmmStatusCode ( + IN EFI_EVENT Event, + IN VOID *Context + ) +/*++ + +Routine Description: + + Initialize the Smm Status code point + +Arguments: + + Event The Event that is being processed + Context Event Context + +Returns: + + None + +--*/ +{ + EFI_STATUS Status; + + Status = gBS->LocateProtocol (&gEfiSmmStatusCodeProtocolGuid, NULL, (VOID **) &mSmmStatusCode); + if (EFI_ERROR (Status)) { + mSmmStatusCode = NULL; + } else { + gBS->CloseEvent (mSmmStatusCodeEvent); + } +} + +EFI_STATUS +SmmStatusCodeReport ( + 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 + ) +{ + if (mSmmStatusCode != NULL) { + (mSmmStatusCode->ReportStatusCode) (mSmmStatusCode, Type, Value, Instance, CallerId, Data); + } + return EFI_SUCCESS; +} + +/** + Locate he report status code service. + + @return EFI_REPORT_STATUS_CODE function point to + ReportStatusCode. +**/ +EFI_REPORT_STATUS_CODE +InternalGetReportStatusCode ( + VOID + ) +{ +#if (EFI_SPECIFICATION_VERSION >= 0x00020000) + EFI_STATUS_CODE_PROTOCOL *StatusCodeProtocol; + EFI_STATUS Status; +#endif + + if (mInSmm) { + return (EFI_REPORT_STATUS_CODE) SmmStatusCodeReport; +#if (EFI_SPECIFICATION_VERSION >= 0x00020000) + } else if (!mHaveExitedBootServices) { + // + // Check gBS just in case. ReportStatusCode is called before gBS is initialized. + // + if (gBS != NULL) { + Status = gBS->LocateProtocol (&gEfiStatusCodeRuntimeProtocolGuid, NULL, (VOID**)&StatusCodeProtocol); + if (!EFI_ERROR (Status) && StatusCodeProtocol != NULL) { + return StatusCodeProtocol->ReportStatusCode; + } + } + } +#elif (TIANO_RELEASE_VERSION != 0) + } else if (mRTSmmRuntimeDxeReportStatusCodeLib != NULL) { + return mRTSmmRuntimeDxeReportStatusCodeLib->ReportStatusCode; + } +#endif + + return NULL; +} + + +/** + Fixup internal report status code protocol interface. + + @param[in] Event The Event that is being processed + @param[in] Context Event Context +**/ +VOID +EFIAPI +ReportStatusCodeLibVirtualAddressChange ( + IN EFI_EVENT Event, + IN VOID *Context + ) +{ + mRTSmmRuntimeDxeReportStatusCodeLib->ConvertPointer (0, (VOID **) &gDebugMaskInterface->GetDebugMask); + mRTSmmRuntimeDxeReportStatusCodeLib->ConvertPointer (0, (VOID **) &gDebugMaskInterface); + if (NULL != mReportStatusCode) { + mRTSmmRuntimeDxeReportStatusCodeLib->ConvertPointer (0, (VOID **) &mReportStatusCode); + } + mRTSmmRuntimeDxeReportStatusCodeLib->ConvertPointer (0, (VOID **) &mStatusCodeData); + mRTSmmRuntimeDxeReportStatusCodeLib->ConvertPointer (0, (VOID **) &mRTSmmRuntimeDxeReportStatusCodeLib); +} + +/** + Update the In Runtime Indicator. + + @param[in] Event The Event that is being processed + @param[in] Context Event Context +**/ +VOID +EFIAPI +ReportStatusCodeLibExitBootServices ( + IN EFI_EVENT Event, + IN VOID *Context + ) +{ + if (!mDebugMaskInitialized) { + InitializeDebugMask (); + } + + if (mReportStatusCode == NULL) { + mReportStatusCode = InternalGetReportStatusCode (); + } + mHaveExitedBootServices = TRUE; +} + +/** + Intialize Report Status Code Lib. + + @param[in] ImageHandle The firmware allocated handle for the EFI image. + @param[in] SystemTable A pointer to the EFI System Table. + + @return EFI_STATUS always returns EFI_SUCCESS. +**/ +EFI_STATUS +EFIAPI +ReportStatusCodeLibConstruct ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + VOID *SmmStatusCodeRegistration; + + // + // SMM driver depends on the SMM BASE protocol. + // the SMM driver must be success to locate protocol. + // + Status = gBS->LocateProtocol (&gEfiSmmBaseProtocolGuid, NULL, (VOID **) &mSmmBase); + if (!EFI_ERROR (Status)) { + mSmmBase->InSmm (mSmmBase, &mInSmm); + if (mInSmm) { + Status = mSmmBase->SmmAllocatePool ( + mSmmBase, + EfiRuntimeServicesData, + sizeof (EFI_STATUS_CODE_DATA) + EFI_STATUS_CODE_DATA_MAX_SIZE, + (VOID **) &mStatusCodeData + ); + ASSERT_EFI_ERROR (Status); + Status = gBS->LocateProtocol (&gEfiSmmStatusCodeProtocolGuid, NULL, (VOID **) &mSmmStatusCode); + if (EFI_ERROR (Status)) { + mSmmStatusCode = NULL; + // + // Create the event + // + Status = gBS->CreateEvent ( + EFI_EVENT_NOTIFY_SIGNAL, + TPL_CALLBACK, + InitializeSmmStatusCode, + NULL, + &mSmmStatusCodeEvent + ); + ASSERT_EFI_ERROR (Status); + // + // Register for protocol notifactions on this event + // NOTE: Because this protocol will be installed in SMM, it is safety to + // register ProtocolNotify here. This event will be triggered in SMM later. + // + Status = gBS->RegisterProtocolNotify ( + &gEfiSmmStatusCodeProtocolGuid, + mSmmStatusCodeEvent, + &SmmStatusCodeRegistration + ); + ASSERT_EFI_ERROR (Status); + } + Status = InstallSmmDebugMaskProtocol (ImageHandle); + return EFI_SUCCESS; + } + } + + Status = InstallRuntimeDebugMaskProtocol (ImageHandle); + + // + // Library should not use the gRT directly, since it + // may be converted by other library instance. + // + mRTSmmRuntimeDxeReportStatusCodeLib = gRT; + mInSmm = FALSE; + + (gBS->AllocatePool) (EfiRuntimeServicesData, sizeof (EFI_STATUS_CODE_DATA) + EFI_STATUS_CODE_DATA_MAX_SIZE, (VOID **)&mStatusCodeData); + ASSERT (NULL != mStatusCodeData); + // + // Cache the report status code service + // + mReportStatusCode = InternalGetReportStatusCode (); + + // + // Register the call back of virtual address change + // + Status = gBS->CreateEvent ( + EFI_EVENT_SIGNAL_VIRTUAL_ADDRESS_CHANGE, + TPL_NOTIFY, + ReportStatusCodeLibVirtualAddressChange, + NULL, + &mVirtualAddressChangeEvent + ); + ASSERT_EFI_ERROR (Status); + + + // + // Register the call back of exit boot services + // + Status = gBS->CreateEvent ( + EFI_EVENT_SIGNAL_EXIT_BOOT_SERVICES, + TPL_NOTIFY, + ReportStatusCodeLibExitBootServices, + NULL, + &mExitBootServicesEvent + ); + ASSERT_EFI_ERROR (Status); + + return Status; +} + +/** + Desctructor of library will close events. + + @param ImageHandle callder module's image handle + @param SystemTable pointer to EFI system table. + @return the status of close event. +**/ +EFI_STATUS +EFIAPI +ReportStatusCodeLibDestruct ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (!mInSmm) { + // + // Close SetVirtualAddressMap () notify function + // + ASSERT (gBS != NULL); + Status = gBS->CloseEvent (mVirtualAddressChangeEvent); + ASSERT_EFI_ERROR (Status); + Status = gBS->CloseEvent (mExitBootServicesEvent); + ASSERT_EFI_ERROR (Status); + + (gBS->FreePool) (mStatusCodeData); + UnInstallRuntimeDebugMaskProtocol (ImageHandle); + } else { + if (mSmmStatusCodeEvent != NULL) { + Status = gBS->CloseEvent (mSmmStatusCodeEvent); + ASSERT_EFI_ERROR (Status); + } + mSmmBase->SmmFreePool (mSmmBase, mStatusCodeData); + UnInstallSmmDebugMaskProtocol (ImageHandle); + } + + return EFI_SUCCESS; +} + +/** + Reports a status code with full parameters. + + The function reports a status code. If ExtendedData is NULL and ExtendedDataSize + is 0, then an extended data buffer is not reported. If ExtendedData is not + NULL and ExtendedDataSize is not 0, then an extended data buffer is allocated. + ExtendedData is assumed not have the standard status code header, so this function + is responsible for allocating a buffer large enough for the standard header and + the extended data passed into this function. The standard header is filled in + with a GUID specified by ExtendedDataGuid. If ExtendedDataGuid is NULL, then a + GUID of gEfiStatusCodeSpecificDatauid is used. The status code is reported with + an instance specified by Instance and a caller ID specified by CallerId. If + CallerId is NULL, then a caller ID of gEfiCallerIdGuid is used. + + ReportStatusCodeEx()must actively prevent recursion. If ReportStatusCodeEx() + is called while processing another any other Report Status Code Library function, + then ReportStatusCodeEx() must return EFI_DEVICE_ERROR immediately. + + If ExtendedData is NULL and ExtendedDataSize is not zero, then ASSERT(). + If ExtendedData is not NULL and ExtendedDataSize is zero, then ASSERT(). + + @param Type Status code type. + @param Value Status code value. + @param Instance Status code instance number. + @param CallerId Pointer to a GUID that identifies the caller of this + function. If this parameter is NULL, then a caller + ID of gEfiCallerIdGuid is used. + @param ExtendedDataGuid Pointer to the GUID for the extended data buffer. + If this parameter is NULL, then a the status code + standard header is filled in with + gEfiStatusCodeSpecificDataGuid. + @param ExtendedData Pointer to the extended data buffer. This is an + optional parameter that may be NULL. + @param ExtendedDataSize The size, in bytes, of the extended data buffer. + + @retval EFI_SUCCESS The status code was reported. + @retval EFI_OUT_OF_RESOURCES There were not enough resources to allocate + the extended data section if it was specified. + @retval EFI_UNSUPPORTED Report status code is not supported + +**/ +EFI_STATUS +EFIAPI +InternalReportStatusCodeEx ( + IN EFI_STATUS_CODE_TYPE Type, + IN EFI_STATUS_CODE_VALUE Value, + IN UINT32 Instance, + IN CONST EFI_GUID *CallerId OPTIONAL, + IN CONST EFI_GUID *ExtendedDataGuid OPTIONAL, + IN CONST VOID *ExtendedData OPTIONAL, + IN UINTN ExtendedDataSize + ) +{ + ASSERT (!((ExtendedData == NULL) && (ExtendedDataSize != 0))); + ASSERT (!((ExtendedData != NULL) && (ExtendedDataSize == 0))); + + if (ExtendedDataSize > EFI_STATUS_CODE_DATA_MAX_SIZE) { + return EFI_OUT_OF_RESOURCES; + } + + // + // Fill in the extended data header + // + mStatusCodeData->HeaderSize = sizeof (EFI_STATUS_CODE_DATA); + mStatusCodeData->Size = (UINT16)ExtendedDataSize; + if (ExtendedDataGuid == NULL) { + ExtendedDataGuid = &gEfiStatusCodeSpecificDataGuid; + } + CopyGuid (&mStatusCodeData->Type, ExtendedDataGuid); + + // + // Fill in the extended data buffer + // + CopyMem (mStatusCodeData + 1, ExtendedData, ExtendedDataSize); + + // + // Report the status code + // + if (CallerId == NULL) { + CallerId = &gEfiCallerIdGuid; + } + return InternalReportStatusCode (Type, Value, Instance, CallerId, mStatusCodeData); +}
\ No newline at end of file diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiBootServicesTableLib/EdkIIGlueUefiBootServicesTableLib.cif b/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiBootServicesTableLib/EdkIIGlueUefiBootServicesTableLib.cif new file mode 100644 index 0000000..01bcb4d --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiBootServicesTableLib/EdkIIGlueUefiBootServicesTableLib.cif @@ -0,0 +1,11 @@ +<component> + name = "EdkIIGlueUefiBootServicesTableLib" + category = ModulePart + LocalRoot = "Edk\Foundation\Library\EdkIIGlueLib\Library\UefiBootServicesTableLib" + RefName = "EdkIIGlueUefiBootServicesTableLib" +[files] +"EdkIIGlueUefiBootServicesTableLib.sdl" +"EdkIIGlueUefiBootServicesTableLib.mak" +"UefiBootServicesTableLib.inf" +"UefiBootServicesTableLib.c" +<endComponent> diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiBootServicesTableLib/EdkIIGlueUefiBootServicesTableLib.mak b/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiBootServicesTableLib/EdkIIGlueUefiBootServicesTableLib.mak new file mode 100644 index 0000000..df0ea5b --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiBootServicesTableLib/EdkIIGlueUefiBootServicesTableLib.mak @@ -0,0 +1,80 @@ +#********************************************************************** +#********************************************************************** +#** ** +#** (C)Copyright 1985-2009, American Megatrends, Inc. ** +#** ** +#** All Rights Reserved. ** +#** ** +#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +#** ** +#** Phone: (770)-246-8600 ** +#** ** +#********************************************************************** +#********************************************************************** + +#********************************************************************** +# $Header: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGlueUefiBootServicesTableLib/EdkIIGlueUefiBootServicesTableLib.mak 1 1/20/12 3:57a Jeffch $ +# +# $Revision: 1 $ +# +# $Date: 1/20/12 3:57a $ +#********************************************************************** +# Revision History +# ---------------- +# $Log: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGlueUefiBootServicesTableLib/EdkIIGlueUefiBootServicesTableLib.mak $ +# +# 1 1/20/12 3:57a Jeffch +# Create Intel EDK 1117 Patch 7. +# +# 1 9/27/11 6:20a Wesleychen +# Intel EDK initially releases. +# +# 1 9/18/09 1:59a Iminglin +# +#********************************************************************** +#<AMI_FHDR_START> +# +# Name: EdkIIGlueUefiBootServicesTableLib.mak +# +# Description: +# +#<AMI_FHDR_END> +#********************************************************************** + + +$(EdkIIGlueUefiBootServicesTableLib_LIB) : EdkIIGlueUefiBootServicesTableLib + +EdkIIGlueUefiBootServicesTableLib : $(BUILD_DIR)\EdkIIGlueUefiBootServicesTableLib.mak EdkIIGlueUefiBootServicesTableLibBin + +$(BUILD_DIR)\EdkIIGlueUefiBootServicesTableLib.mak : $(EdkIIGlueUefiBootServicesTableLib_DIR)\$(@B).cif $(EdkIIGlueUefiBootServicesTableLib_DIR)\$(@B).mak $(BUILD_RULES) + $(CIF2MAK) $(EdkIIGlueUefiBootServicesTableLib_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS) + +EdkIIGlueUefiBootServicesTableLibBin : +!IF "$(x64_BUILD)"=="1" + $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\ + BUILD_DIR=$(BUILD_DIR)\ + /f $(BUILD_DIR)\EdkIIGlueUefiBootServicesTableLib.mak all\ + TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueUefiBootServicesTableLib_LIB)" + $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\ + BUILD_DIR=$(BUILD_DIR)\IA32\ + /f $(BUILD_DIR)\EdkIIGlueUefiBootServicesTableLib.mak all\ + TYPE=PEI_LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueUefiBootServicesTableLib_LIB)" +!ELSE + $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\ + BUILD_DIR=$(BUILD_DIR)\ + /f $(BUILD_DIR)\EdkIIGlueUefiBootServicesTableLib.mak all\ + TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueUefiBootServicesTableLib_LIB)" +!ENDIF +#********************************************************************** +#********************************************************************** +#** ** +#** (C)Copyright 1985-2009, American Megatrends, Inc. ** +#** ** +#** All Rights Reserved. ** +#** ** +#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +#** ** +#** Phone: (770)-246-8600 ** +#** ** +#********************************************************************** +#**********************************************************************
\ No newline at end of file diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiBootServicesTableLib/EdkIIGlueUefiBootServicesTableLib.sdl b/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiBootServicesTableLib/EdkIIGlueUefiBootServicesTableLib.sdl new file mode 100644 index 0000000..80d01ac --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiBootServicesTableLib/EdkIIGlueUefiBootServicesTableLib.sdl @@ -0,0 +1,26 @@ +TOKEN + Name = "EdkIIGlueUefiBootServicesTableLib_SUPPORT" + Value = "1" + Help = "Main switch to enable EdkIIGlueUefiBootServicesTableLib support in Project" + TokenType = Boolean + TargetEQU = Yes + TargetMAK = Yes + Master = Yes +End + +TOKEN + Name = "EdkIIGlueUefiBootServicesTableLib_LIB" + Value = "$$(LIB_BUILD_DIR)\EdkIIGlueUefiBootServicesTableLib.lib" + TokenType = Expression + TargetMAK = Yes +End + +PATH + Name = "EdkIIGlueUefiBootServicesTableLib_DIR" +End + +MODULE + Help = "Includes EdkIIGlueUefiBootServicesTableLib.mak to Project" + File = "EdkIIGlueUefiBootServicesTableLib.mak" +End + diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiBootServicesTableLib/UefiBootServicesTableLib.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiBootServicesTableLib/UefiBootServicesTableLib.c new file mode 100644 index 0000000..dc4a82e --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiBootServicesTableLib/UefiBootServicesTableLib.c @@ -0,0 +1,67 @@ +/*++ + +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: + + UefiBootServicesTableLib.c + +Abstract: + + UEFI Boot Services Table Library. + +--*/ + +#include "EdkIIGlueUefi.h" + +EFI_HANDLE gImageHandle; +EFI_SYSTEM_TABLE *gST; +EFI_BOOT_SERVICES *gBS; + +/** + The constructor function caches the pointer of Boot Services Table. + + The constructor function caches the pointer of Boot Services Table through System Table. + It will ASSERT() if the pointer of System Table is NULL. + It will ASSERT() if the pointer of Boot Services Table is NULL. + It will always return EFI_SUCCESS. + + @param ImageHandle The firmware allocated handle for the EFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS. + +**/ +EFI_STATUS +UefiBootServicesTableLibConstructor ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + // + // Cache the Image Handle + // + gImageHandle = ImageHandle; + + // + // Cache pointer to the EFI System Table + // + gST = SystemTable; + ASSERT (gST != NULL); + + // + // Cache pointer to the EFI Boot Services Table + // + gBS = SystemTable->BootServices; + ASSERT (gBS != NULL); + + return EFI_SUCCESS; +} diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiBootServicesTableLib/UefiBootServicesTableLib.inf b/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiBootServicesTableLib/UefiBootServicesTableLib.inf new file mode 100644 index 0000000..a554a54 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiBootServicesTableLib/UefiBootServicesTableLib.inf @@ -0,0 +1,75 @@ +#/*++ +# +# 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: +# +# UefiBootServicesTableLib.inf +# +# Abstract: +# +# Component description file for UefiBootServicesTableLib. +# +#--*/ + +[defines] +BASE_NAME = EdkIIGlueUefiBootServicesTableLib +COMPONENT_TYPE = LIBRARY + +[sources.common] + UefiBootServicesTableLib.c + +[sources.ia32] + +[sources.x64] + +[sources.ipf] + +[sources.ebc] + + +[includes.common] + . + ..\..\Include + ..\..\include\Library + $(EDK_SOURCE)\Foundation + $(EDK_SOURCE)\Foundation\Framework + $(EDK_SOURCE)\Foundation\Efi + $(EDK_SOURCE)\Foundation\Include + $(EDK_SOURCE)\Foundation\Efi\Include + $(EDK_SOURCE)\Foundation\Framework\Include + $(EDK_SOURCE)\Foundation\Include\IndustryStandard + $(EDK_SOURCE)\Foundation\Core\Dxe + $(EDK_SOURCE)\Foundation\Library\Dxe\Include + $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include + + $(EDK_SOURCE)\Foundation\Efi\Protocol\DevicePath + +[libraries.common] + +[libraries.ia32] + +[libraries.x64] + +[nmake.common] + C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION + LIB_STD_FLAGS = /NOLOGO /IGNORE:4006 + +[nmake.ia32] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32 + +[nmake.x64] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64 + +[nmake.ipf] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF + +[nmake.ebc] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_EBC
\ No newline at end of file diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiDevicePathLib/EdkIIGlueUefiDevicePathLib.cif b/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiDevicePathLib/EdkIIGlueUefiDevicePathLib.cif new file mode 100644 index 0000000..43c7a6b --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiDevicePathLib/EdkIIGlueUefiDevicePathLib.cif @@ -0,0 +1,11 @@ +<component> + name = "EdkIIGlueUefiDevicePathLib" + category = ModulePart + LocalRoot = "Edk\Foundation\Library\EdkIIGlueLib\Library\UefiDevicePathLib" + RefName = "EdkIIGlueUefiDevicePathLib" +[files] +"EdkIIGlueUefiDevicePathLib.sdl" +"EdkIIGlueUefiDevicePathLib.mak" +"UefiDevicePathLib.inf" +"UefiDevicePathLib.c" +<endComponent> diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiDevicePathLib/EdkIIGlueUefiDevicePathLib.mak b/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiDevicePathLib/EdkIIGlueUefiDevicePathLib.mak new file mode 100644 index 0000000..08b93d5 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiDevicePathLib/EdkIIGlueUefiDevicePathLib.mak @@ -0,0 +1,80 @@ +#********************************************************************** +#********************************************************************** +#** ** +#** (C)Copyright 1985-2009, American Megatrends, Inc. ** +#** ** +#** All Rights Reserved. ** +#** ** +#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +#** ** +#** Phone: (770)-246-8600 ** +#** ** +#********************************************************************** +#********************************************************************** + +#********************************************************************** +# $Header: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGlueUefiDevicePathLib/EdkIIGlueUefiDevicePathLib.mak 1 1/20/12 3:58a Jeffch $ +# +# $Revision: 1 $ +# +# $Date: 1/20/12 3:58a $ +#********************************************************************** +# Revision History +# ---------------- +# $Log: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGlueUefiDevicePathLib/EdkIIGlueUefiDevicePathLib.mak $ +# +# 1 1/20/12 3:58a Jeffch +# Create Intel EDK 1117 Patch 7. +# +# 1 9/27/11 6:20a Wesleychen +# Intel EDK initially releases. +# +# 1 9/18/09 1:59a Iminglin +# +#********************************************************************** +#<AMI_FHDR_START> +# +# Name: EdkIIGlueUefiDevicePathLib.mak +# +# Description: +# +#<AMI_FHDR_END> +#********************************************************************** + + +$(EdkIIGlueUefiDevicePathLib_LIB) : EdkIIGlueUefiDevicePathLib + +EdkIIGlueUefiDevicePathLib : $(BUILD_DIR)\EdkIIGlueUefiDevicePathLib.mak EdkIIGlueUefiDevicePathLibBin + +$(BUILD_DIR)\EdkIIGlueUefiDevicePathLib.mak : $(EdkIIGlueUefiDevicePathLib_DIR)\$(@B).cif $(EdkIIGlueUefiDevicePathLib_DIR)\$(@B).mak $(BUILD_RULES) + $(CIF2MAK) $(EdkIIGlueUefiDevicePathLib_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS) + +EdkIIGlueUefiDevicePathLibBin : $(EdkIIGlueBaseMemoryLib_LIB) $(EdkIIGlueUefiBootServicesTableLib_LIB) $(EdkIIGlueDxeMemoryAllocationLib_LIB) +!IF "$(x64_BUILD)"=="1" + $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\ + BUILD_DIR=$(BUILD_DIR)\ + /f $(BUILD_DIR)\EdkIIGlueUefiDevicePathLib.mak all\ + TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueUefiDevicePathLib_LIB)" + $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\ + BUILD_DIR=$(BUILD_DIR)\IA32\ + /f $(BUILD_DIR)\EdkIIGlueUefiDevicePathLib.mak all\ + TYPE=PEI_LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueUefiDevicePathLib_LIB)" +!ELSE + $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\ + BUILD_DIR=$(BUILD_DIR)\ + /f $(BUILD_DIR)\EdkIIGlueUefiDevicePathLib.mak all\ + TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueUefiDevicePathLib_LIB)" +!ENDIF +#********************************************************************** +#********************************************************************** +#** ** +#** (C)Copyright 1985-2009, American Megatrends, Inc. ** +#** ** +#** All Rights Reserved. ** +#** ** +#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +#** ** +#** Phone: (770)-246-8600 ** +#** ** +#********************************************************************** +#**********************************************************************
\ No newline at end of file diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiDevicePathLib/EdkIIGlueUefiDevicePathLib.sdl b/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiDevicePathLib/EdkIIGlueUefiDevicePathLib.sdl new file mode 100644 index 0000000..d8a3f85 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiDevicePathLib/EdkIIGlueUefiDevicePathLib.sdl @@ -0,0 +1,26 @@ +TOKEN + Name = "EdkIIGlueUefiDevicePathLib_SUPPORT" + Value = "1" + Help = "Main switch to enable EdkIIGlueUefiDevicePathLib support in Project" + TokenType = Boolean + TargetEQU = Yes + TargetMAK = Yes + Master = Yes +End + +TOKEN + Name = "EdkIIGlueUefiDevicePathLib_LIB" + Value = "$$(LIB_BUILD_DIR)\EdkIIGlueUefiDevicePathLib.lib" + TokenType = Expression + TargetMAK = Yes +End + +PATH + Name = "EdkIIGlueUefiDevicePathLib_DIR" +End + +MODULE + Help = "Includes EdkIIGlueUefiDevicePathLib.mak to Project" + File = "EdkIIGlueUefiDevicePathLib.mak" +End + diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiDevicePathLib/UefiDevicePathLib.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiDevicePathLib/UefiDevicePathLib.c new file mode 100644 index 0000000..a7f22bb --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiDevicePathLib/UefiDevicePathLib.c @@ -0,0 +1,533 @@ +/*++ + +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: + + UefiDevicePathLib.c + +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. + +--*/ + +#include "EdkIIGlueUefi.h" +#include "Library\EdkIIGlueMemoryAllocationLib.h" + +/** + Returns the size of a device path in bytes. + + This function returns the size, in bytes, of the device path data structure specified by + DevicePath including the end of device path node. If DevicePath is NULL, then 0 is returned. + + @param DevicePath A pointer to a device path data structure. + + @return The size of a device path in bytes. + +**/ +UINTN +EFIAPI +GlueGetDevicePathSize ( + IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath + ) +{ + CONST EFI_DEVICE_PATH_PROTOCOL *Start; + + if (DevicePath == NULL) { + return 0; + } + + // + // Search for the end of the device path structure + // + Start = DevicePath; + while (!EfiIsDevicePathEnd (DevicePath)) { + DevicePath = EfiNextDevicePathNode (DevicePath); + } + + // + // Compute the size and add back in the size of the end device path structure + // + return ((UINTN) DevicePath - (UINTN) Start) + sizeof (EFI_DEVICE_PATH_PROTOCOL); +} + +/** + Creates a new device path by appending a second device path to a first device path. + + This function allocates space for a new copy of the device path specified by DevicePath. If + DevicePath is NULL, then NULL is returned. If the memory is successfully allocated, then the + contents of DevicePath are copied to the newly allocated buffer, and a pointer to that buffer + is returned. Otherwise, NULL is returned. + + @param DevicePath A pointer to a device path data structure. + + @return A pointer to the duplicated device path. + +**/ +EFI_DEVICE_PATH_PROTOCOL * +EFIAPI +GlueDuplicateDevicePath ( + IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath + ) +{ + EFI_DEVICE_PATH_PROTOCOL *NewDevicePath; + UINTN Size; + + // + // Compute the size + // + Size = GetDevicePathSize (DevicePath); + if (Size == 0) { + return NULL; + } + + // + // Allocate space for duplicate device path + // + NewDevicePath = AllocateCopyPool (Size, DevicePath); + + return NewDevicePath; +} + +/** + Creates a new device path by appending a second device path to a first device path. + + This function creates a new device path by appending a copy of SecondDevicePath to a copy of + FirstDevicePath in a newly allocated buffer. Only the end-of-device-path device node from + SecondDevicePath is retained. The newly created device path is returned. + If FirstDevicePath is NULL, then it is ignored, and a duplicate of SecondDevicePath is returned. + If SecondDevicePath is NULL, then it is ignored, and a duplicate of FirstDevicePath is returned. + If both FirstDevicePath and SecondDevicePath are NULL, then NULL is returned. + If there is not enough memory for the newly allocated buffer, then NULL is returned. + The memory for the new device path is allocated from EFI boot services memory. It is the + responsibility of the caller to free the memory allocated. + + @param FirstDevicePath A pointer to a device path data structure. + @param SecondDevicePath A pointer to a device path data structure. + + @return A pointer to the new device path. + +**/ +EFI_DEVICE_PATH_PROTOCOL * +EFIAPI +GlueAppendDevicePath ( + IN CONST EFI_DEVICE_PATH_PROTOCOL *FirstDevicePath, OPTIONAL + IN CONST EFI_DEVICE_PATH_PROTOCOL *SecondDevicePath OPTIONAL + ) +{ + UINTN Size; + UINTN Size1; + UINTN Size2; + EFI_DEVICE_PATH_PROTOCOL *NewDevicePath; + EFI_DEVICE_PATH_PROTOCOL *DevicePath2; + + // + // If there's only 1 path, just duplicate it. + // + if (FirstDevicePath == NULL) { + return DuplicateDevicePath (SecondDevicePath); + } + + if (SecondDevicePath == NULL) { + return DuplicateDevicePath (FirstDevicePath); + } + + // + // Allocate space for the combined device path. It only has one end node of + // length EFI_DEVICE_PATH_PROTOCOL. + // + Size1 = GetDevicePathSize (FirstDevicePath); + Size2 = GetDevicePathSize (SecondDevicePath); + Size = Size1 + Size2 - sizeof (EFI_DEVICE_PATH_PROTOCOL); + + NewDevicePath = AllocatePool (Size); + + if (NewDevicePath != NULL) { + NewDevicePath = CopyMem (NewDevicePath, FirstDevicePath, Size1); + // + // Over write FirstDevicePath EndNode and do the copy + // + DevicePath2 = (EFI_DEVICE_PATH_PROTOCOL *) ((CHAR8 *) NewDevicePath + + (Size1 - sizeof (EFI_DEVICE_PATH_PROTOCOL))); + CopyMem (DevicePath2, SecondDevicePath, Size2); + } + + return NewDevicePath; +} + +/** + Creates a new path by appending the device node to the device path. + + This function creates a new device path by appending a copy of the device node specified by + DevicePathNode to a copy of the device path specified by DevicePath in an allocated buffer. + The end-of-device-path device node is moved after the end of the appended device node. + If DevicePath is NULL, then NULL is returned. + If DevicePathNode is NULL, then NULL is returned. + If there is not enough memory to allocate space for the new device path, then NULL is returned. + The memory is allocated from EFI boot services memory. It is the responsibility of the caller to + free the memory allocated. + + @param DevicePath A pointer to a device path data structure. + @param DevicePathNode A pointer to a single device path node. + + @return A pointer to the new device path. + +**/ +EFI_DEVICE_PATH_PROTOCOL * +EFIAPI +GlueAppendDevicePathNode ( + IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath, OPTIONAL + IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePathNode OPTIONAL + ) +{ + EFI_DEVICE_PATH_PROTOCOL *TempDevicePath; + EFI_DEVICE_PATH_PROTOCOL *NextNode; + EFI_DEVICE_PATH_PROTOCOL *NewDevicePath; + UINTN NodeLength; + + if (DevicePath == NULL || DevicePathNode == NULL) { + return NULL; + } + // + // Build a Node that has a terminator on it + // + NodeLength = DevicePathNodeLength (DevicePathNode); + + TempDevicePath = AllocatePool (NodeLength + sizeof (EFI_DEVICE_PATH_PROTOCOL)); + if (TempDevicePath == NULL) { + return NULL; + } + TempDevicePath = CopyMem (TempDevicePath, DevicePathNode, NodeLength); + // + // Add and end device path node to convert Node to device path + // + NextNode = NextDevicePathNode (TempDevicePath); + SetDevicePathEndNode (NextNode); + // + // Append device paths + // + NewDevicePath = AppendDevicePath (DevicePath, TempDevicePath); + + FreePool (TempDevicePath); + + return NewDevicePath; +} + +/** + Creates a new device path by appending the specified device path instance to the specified device + path. + + This function creates a new device path by appending a copy of the device path instance specified + by DevicePathInstance to a copy of the device path secified by DevicePath in a allocated buffer. + The end-of-device-path device node is moved after the end of the appended device path instance + and a new end-of-device-path-instance node is inserted between. + If DevicePath is NULL, then a copy if DevicePathInstance is returned. + If DevicePathInstance is NULL, then NULL is returned. + If there is not enough memory to allocate space for the new device path, then NULL is returned. + The memory is allocated from EFI boot services memory. It is the responsibility of the caller to + free the memory allocated. + + @param DevicePath A pointer to a device path data structure. + @param DevicePathInstance A pointer to a device path instance. + + @return A pointer to the new device path. + +**/ +EFI_DEVICE_PATH_PROTOCOL * +EFIAPI +GlueAppendDevicePathInstance ( + IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath, OPTIONAL + IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePathInstance OPTIONAL + ) +{ + EFI_DEVICE_PATH_PROTOCOL *NewDevicePath; + EFI_DEVICE_PATH_PROTOCOL *TempDevicePath; + UINTN SrcSize; + UINTN InstanceSize; + + if (DevicePath == NULL) { + return DuplicateDevicePath (DevicePathInstance); + } + + if (DevicePathInstance == NULL) { + return NULL; + } + + SrcSize = GetDevicePathSize (DevicePath); + InstanceSize = GetDevicePathSize (DevicePathInstance); + + NewDevicePath = AllocatePool (SrcSize + InstanceSize); + if (NewDevicePath != NULL) { + + TempDevicePath = CopyMem (NewDevicePath, DevicePath, SrcSize);; + + while (!IsDevicePathEnd (TempDevicePath)) { + TempDevicePath = NextDevicePathNode (TempDevicePath); + } + + TempDevicePath->SubType = END_INSTANCE_DEVICE_PATH_SUBTYPE; + TempDevicePath = NextDevicePathNode (TempDevicePath); + CopyMem (TempDevicePath, DevicePathInstance, InstanceSize); + } + + return NewDevicePath; +} + +/** + Creates a copy of the current device path instance and returns a pointer to the next device path + instance. + + This function creates a copy of the current device path instance. It also updates DevicePath to + point to the next device path instance in the device path (or NULL if no more) and updates Size + to hold the size of the device path instance copy. + If DevicePath is NULL, then NULL is returned. + If there is not enough memory to allocate space for the new device path, then NULL is returned. + The memory is allocated from EFI boot services memory. It is the responsibility of the caller to + free the memory allocated. + If Size is NULL, then ASSERT(). + + @param DevicePath On input, this holds the pointer to the current device path + instance. On output, this holds the pointer to the next device + path instance or NULL if there are no more device path + instances in the device path pointer to a device path data + structure. + @param Size On output, this holds the size of the device path instance, in + bytes or zero, if DevicePath is NULL. + + @return A pointer to the current device path instance. + +**/ +EFI_DEVICE_PATH_PROTOCOL * +EFIAPI +GlueGetNextDevicePathInstance ( + IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath, + OUT UINTN *Size + ) +{ + EFI_DEVICE_PATH_PROTOCOL *DevPath; + EFI_DEVICE_PATH_PROTOCOL *ReturnValue; + UINT8 Temp; + + ASSERT (Size != NULL); + + if (DevicePath == NULL || *DevicePath == NULL) { + *Size = 0; + return NULL; + } + + // + // Find the end of the device path instance + // + DevPath = *DevicePath; + while (!IsDevicePathEndType (DevPath)) { + DevPath = NextDevicePathNode (DevPath); + } + + // + // Compute the size of the device path instance + // + *Size = ((UINTN) DevPath - (UINTN) (*DevicePath)) + sizeof (EFI_DEVICE_PATH_PROTOCOL); + + // + // Make a copy and return the device path instance + // + Temp = DevPath->SubType; + DevPath->SubType = END_ENTIRE_DEVICE_PATH_SUBTYPE; + ReturnValue = DuplicateDevicePath (*DevicePath); + DevPath->SubType = Temp; + + // + // If DevPath is the end of an entire device path, then another instance + // does not follow, so *DevicePath is set to NULL. + // + if (DevicePathSubType (DevPath) == END_ENTIRE_DEVICE_PATH_SUBTYPE) { + *DevicePath = NULL; + } else { + *DevicePath = NextDevicePathNode (DevPath); + } + + return ReturnValue; +} + +/** + Creates a copy of the current device path instance and returns a pointer to the next device path + instance. + + This function creates a new device node in a newly allocated buffer of size NodeLength and + initializes the device path node header with NodeType and NodeSubType. The new device path node + is returned. + If NodeLength is smaller than a device path header, then NULL is returned. + If there is not enough memory to allocate space for the new device path, then NULL is returned. + The memory is allocated from EFI boot services memory. It is the responsibility of the caller to + free the memory allocated. + + @param NodeType The device node type for the new device node. + @param NodeSubType The device node sub-type for the new device node. + @param NodeLength The length of the new device node. + + @return The new device path. + +**/ +EFI_DEVICE_PATH_PROTOCOL * +EFIAPI +CreateDeviceNode ( + IN UINT8 NodeType, + IN UINT8 NodeSubType, + IN UINT16 NodeLength + ) +{ + EFI_DEVICE_PATH_PROTOCOL *DevicePath; + + if (NodeLength < sizeof (EFI_DEVICE_PATH_PROTOCOL)) { + // + // NodeLength is less than the size of the header. + // + return NULL; + } + + DevicePath = AllocatePool (NodeLength); + if (DevicePath != NULL) { + DevicePath->Type = NodeType; + DevicePath->SubType = NodeSubType; + SetDevicePathNodeLength (DevicePath, NodeLength); + } + + return DevicePath; +} + +/** + Determines if a device path is single or multi-instance. + + This function returns TRUE if the device path specified by DevicePath is multi-instance. + Otherwise, FALSE is returned. If DevicePath is NULL, then FALSE is returned. + + @param DevicePath A pointer to a device path data structure. + + @retval TRUE DevicePath is multi-instance. + @retval FALSE DevicePath is not multi-instance or DevicePath is NULL. + +**/ +BOOLEAN +EFIAPI +GlueIsDevicePathMultiInstance ( + IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath + ) +{ + CONST EFI_DEVICE_PATH_PROTOCOL *Node; + + if (DevicePath == NULL) { + return FALSE; + } + + Node = DevicePath; + while (!EfiIsDevicePathEnd (Node)) { + if (EfiIsDevicePathEndInstance (Node)) { + return TRUE; + } + + Node = EfiNextDevicePathNode (Node); + } + + return FALSE; +} + + +/** + Retrieves the device path protocol from a handle. + + This function returns the device path protocol from the handle specified by Handle. If Handle is + NULL or Handle does not contain a device path protocol, then NULL is returned. + + @param Handle The handle from which to retrieve the device path protocol. + + @return The device path protocol from the handle specified by Handle. + +**/ +EFI_DEVICE_PATH_PROTOCOL * +EFIAPI +GlueDevicePathFromHandle ( + IN EFI_HANDLE Handle + ) +{ + EFI_DEVICE_PATH_PROTOCOL *DevicePath; + EFI_STATUS Status; + + Status = gBS->HandleProtocol ( + Handle, + &gEfiDevicePathProtocolGuid, + (VOID *) &DevicePath + ); + if (EFI_ERROR (Status)) { + DevicePath = NULL; + } + return DevicePath; +} + +/** + Allocates a device path for a file and appends it to an existing device path. + + If Device is a valid device handle that contains a device path protocol, then a device path for + the file specified by FileName is allocated and appended to the device path associated with the + handle Device. The allocated device path is returned. If Device is NULL or Device is a handle + that does not support the device path protocol, then a device path containing a single device + path node for the file specified by FileName is allocated and returned. + If FileName is NULL, then ASSERT(). + + @param Device A pointer to a device handle. This parameter is optional and + may be NULL. + @param FileName A pointer to a Null-terminated Unicode string. + + @return The allocated device path. + +**/ +EFI_DEVICE_PATH_PROTOCOL * +EFIAPI +GlueFileDevicePath ( + IN EFI_HANDLE Device, OPTIONAL + IN CONST CHAR16 *FileName + ) +{ + UINTN Size; + FILEPATH_DEVICE_PATH *FilePath; + EFI_DEVICE_PATH_PROTOCOL *DevicePath; + EFI_DEVICE_PATH_PROTOCOL *FileDevicePath; + + DevicePath = NULL; + + Size = StrSize (FileName); + FileDevicePath = AllocatePool (Size + SIZE_OF_FILEPATH_DEVICE_PATH + EFI_END_DEVICE_PATH_LENGTH); + if (FileDevicePath != NULL) { + FilePath = (FILEPATH_DEVICE_PATH *) FileDevicePath; + FilePath->Header.Type = MEDIA_DEVICE_PATH; + FilePath->Header.SubType = MEDIA_FILEPATH_DP; + CopyMem (&FilePath->PathName, FileName, Size); + SetDevicePathNodeLength (&FilePath->Header, Size + SIZE_OF_FILEPATH_DEVICE_PATH); + SetDevicePathEndNode (NextDevicePathNode (&FilePath->Header)); + + if (Device != NULL) { + DevicePath = DevicePathFromHandle (Device); + } + + DevicePath = AppendDevicePath (DevicePath, FileDevicePath); + FreePool (FileDevicePath); + } + + return DevicePath; +} + diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiDevicePathLib/UefiDevicePathLib.inf b/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiDevicePathLib/UefiDevicePathLib.inf new file mode 100644 index 0000000..17af5bd --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiDevicePathLib/UefiDevicePathLib.inf @@ -0,0 +1,83 @@ +#/*++ +# +# 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: +# +# UefiDevicePathLib.inf +# +# Abstract: +# +# Component description file for UefiDevicePathLib. +# +#--*/ + +[defines] +BASE_NAME = EdkIIGlueUefiDevicePathLib +COMPONENT_TYPE = LIBRARY + +[sources.common] + UefiDevicePathLib.c + +[sources.ia32] + +[sources.x64] + +[sources.ipf] + +[sources.ebc] + + +[includes.common] + . + ..\..\Include + ..\..\include\Library + $(EDK_SOURCE)\Foundation + $(EDK_SOURCE)\Foundation\Framework + $(EDK_SOURCE)\Foundation\Efi + $(EDK_SOURCE)\Foundation\Include + $(EDK_SOURCE)\Foundation\Efi\Include + $(EDK_SOURCE)\Foundation\Framework\Include + $(EDK_SOURCE)\Foundation\Include\IndustryStandard + $(EDK_SOURCE)\Foundation\Core\Dxe + $(EDK_SOURCE)\Foundation\Library\Dxe\Include + $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include + + $(EDK_SOURCE)\Foundation\Efi\Protocol\DevicePath + +[libraries.common] + EdkIIGlueBaseMemoryLib + EdkIIGlueUefiBootServicesTableLib +# +# MemoryAllocationLib instance +# + EdkIIGlueDxeMemoryAllocationLib + +[libraries.ia32] + + +[libraries.x64] + + +[nmake.common] + C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION + LIB_STD_FLAGS = /NOLOGO /IGNORE:4006 + +[nmake.ia32] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32 + +[nmake.x64] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64 + +[nmake.ipf] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF + +[nmake.ebc] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_EBC
\ No newline at end of file diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiDriverModelLib/EdkIIGlueUefiDriverModelLib.cif b/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiDriverModelLib/EdkIIGlueUefiDriverModelLib.cif new file mode 100644 index 0000000..a5dc193 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiDriverModelLib/EdkIIGlueUefiDriverModelLib.cif @@ -0,0 +1,11 @@ +<component> + name = "EdkIIGlueUefiDriverModelLib" + category = ModulePart + LocalRoot = "Edk\Foundation\Library\EdkIIGlueLib\Library\UefiDriverModelLib" + RefName = "EdkIIGlueUefiDriverModelLib" +[files] +"EdkIIGlueUefiDriverModelLib.sdl" +"EdkIIGlueUefiDriverModelLib.mak" +"UefiDriverModelLib.inf" +"UefiDriverModelLib.c" +<endComponent> diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiDriverModelLib/EdkIIGlueUefiDriverModelLib.mak b/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiDriverModelLib/EdkIIGlueUefiDriverModelLib.mak new file mode 100644 index 0000000..70f8b12 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiDriverModelLib/EdkIIGlueUefiDriverModelLib.mak @@ -0,0 +1,80 @@ +#********************************************************************** +#********************************************************************** +#** ** +#** (C)Copyright 1985-2009, American Megatrends, Inc. ** +#** ** +#** All Rights Reserved. ** +#** ** +#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +#** ** +#** Phone: (770)-246-8600 ** +#** ** +#********************************************************************** +#********************************************************************** + +#********************************************************************** +# $Header: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGlueUefiDriverModelLib/EdkIIGlueUefiDriverModelLib.mak 1 1/20/12 3:58a Jeffch $ +# +# $Revision: 1 $ +# +# $Date: 1/20/12 3:58a $ +#********************************************************************** +# Revision History +# ---------------- +# $Log: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGlueUefiDriverModelLib/EdkIIGlueUefiDriverModelLib.mak $ +# +# 1 1/20/12 3:58a Jeffch +# Create Intel EDK 1117 Patch 7. +# +# 1 9/27/11 6:20a Wesleychen +# Intel EDK initially releases. +# +# 1 9/18/09 1:59a Iminglin +# +#********************************************************************** +#<AMI_FHDR_START> +# +# Name: EdkIIGlueUefiDriverModelLib.mak +# +# Description: +# +#<AMI_FHDR_END> +#********************************************************************** + + +$(EdkIIGlueUefiDriverModelLib_LIB) : EdkIIGlueUefiDriverModelLib + +EdkIIGlueUefiDriverModelLib : $(BUILD_DIR)\EdkIIGlueUefiDriverModelLib.mak EdkIIGlueUefiDriverModelLibBin + +$(BUILD_DIR)\EdkIIGlueUefiDriverModelLib.mak : $(EdkIIGlueUefiDriverModelLib_DIR)\$(@B).cif $(EdkIIGlueUefiDriverModelLib_DIR)\$(@B).mak $(BUILD_RULES) + $(CIF2MAK) $(EdkIIGlueUefiDriverModelLib_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS) + +EdkIIGlueUefiDriverModelLibBin : $(EdkIIGlueUefiBootServicesTableLib_LIB) +!IF "$(x64_BUILD)"=="1" + $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\ + BUILD_DIR=$(BUILD_DIR)\ + /f $(BUILD_DIR)\EdkIIGlueUefiDriverModelLib.mak all\ + TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueUefiDriverModelLib_LIB)" + $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\ + BUILD_DIR=$(BUILD_DIR)\IA32\ + /f $(BUILD_DIR)\EdkIIGlueUefiDriverModelLib.mak all\ + TYPE=PEI_LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueUefiDriverModelLib_LIB)" +!ELSE + $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\ + BUILD_DIR=$(BUILD_DIR)\ + /f $(BUILD_DIR)\EdkIIGlueUefiDriverModelLib.mak all\ + TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueUefiDriverModelLib_LIB)" +!ENDIF +#********************************************************************** +#********************************************************************** +#** ** +#** (C)Copyright 1985-2009, American Megatrends, Inc. ** +#** ** +#** All Rights Reserved. ** +#** ** +#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +#** ** +#** Phone: (770)-246-8600 ** +#** ** +#********************************************************************** +#**********************************************************************
\ No newline at end of file diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiDriverModelLib/EdkIIGlueUefiDriverModelLib.sdl b/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiDriverModelLib/EdkIIGlueUefiDriverModelLib.sdl new file mode 100644 index 0000000..bde01f2 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiDriverModelLib/EdkIIGlueUefiDriverModelLib.sdl @@ -0,0 +1,26 @@ +TOKEN + Name = "EdkIIGlueUefiDriverModelLib_SUPPORT" + Value = "1" + Help = "Main switch to enable EdkIIGlueUefiDriverModelLib support in Project" + TokenType = Boolean + TargetEQU = Yes + TargetMAK = Yes + Master = Yes +End + +TOKEN + Name = "EdkIIGlueUefiDriverModelLib_LIB" + Value = "$$(LIB_BUILD_DIR)\EdkIIGlueUefiDriverModelLib.lib" + TokenType = Expression + TargetMAK = Yes +End + +PATH + Name = "EdkIIGlueUefiDriverModelLib_DIR" +End + +MODULE + Help = "Includes EdkIIGlueUefiDriverModelLib.mak to Project" + File = "EdkIIGlueUefiDriverModelLib.mak" +End + diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiDriverModelLib/UefiDriverModelLib.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiDriverModelLib/UefiDriverModelLib.c new file mode 100644 index 0000000..8f1cbf5 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiDriverModelLib/UefiDriverModelLib.c @@ -0,0 +1,431 @@ +/*++ + +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: + + UefiDriverModelLib.c + +Abstract: + + UEFI Driver Model Library. + +--*/ + +#include "EdkIIGlueUefi.h" + + +/** + The constructor function installs the standard EFI Driver Model Protocols. + + @param[in] ImageHandle The firmware allocated handle for the EFI image. + @param[in] SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The constructor always return EFI_SUCCESS. + +**/ +EFI_STATUS +EFIAPI +UefiDriverModelLibConstructor ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status = EFI_UNSUPPORTED; + EFI_HANDLE DriverBindingHandle; + EFI_DRIVER_BINDING_PROTOCOL *DriverBinding; + + // + // Install the first Driver Bindng Protocol onto ImageHandle + // + DriverBindingHandle = ImageHandle; + + // + // See if onle one Driver Binding Protocol is advertised by the driver + // EdkIIGlueLib: _gDriverModelProtocolListEntries is always 1 + // + + // + // The Driver Binding Protocol must never be NULL + // + ASSERT(_gDriverModelProtocolList[0].DriverBinding != NULL); + + // + // Check for all 8 possible combinations of the ComponentName, DriverConfiguration, and DriverDiagnostics Protocol + // These are all checks against const pointers, so the optimizing compiler will only select one of the + // calls to InstallMultipleProtocolInterfaces() + // + if ((_gEdkIIGlueDriverModelProtocolSelection == 1) || (_gEdkIIGlueDriverModelProtocolSelection == 3)) { + if (_gDriverModelProtocolList[0].DriverDiagnostics == NULL) { + if (_gDriverModelProtocolList[0].DriverConfiguration == NULL) { + if (_gDriverModelProtocolList[0].ComponentName == NULL) { + Status = gBS->InstallMultipleProtocolInterfaces ( + &DriverBindingHandle, + &gEfiDriverBindingProtocolGuid, (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding, + NULL + ); + } else { + Status = gBS->InstallMultipleProtocolInterfaces ( + &DriverBindingHandle, + &gEfiDriverBindingProtocolGuid, (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding, + &gEfiComponentNameProtocolGuid, (EFI_COMPONENT_NAME_PROTOCOL *)_gDriverModelProtocolList[0].ComponentName, + NULL + ); + } + } else { + if (_gDriverModelProtocolList[0].ComponentName == NULL) { + Status = gBS->InstallMultipleProtocolInterfaces ( + &DriverBindingHandle, + &gEfiDriverBindingProtocolGuid, (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding, + &gEfiDriverConfigurationProtocolGuid, (EFI_DRIVER_CONFIGURATION_PROTOCOL *)_gDriverModelProtocolList[0].DriverConfiguration, + NULL + ); + } else { + Status = gBS->InstallMultipleProtocolInterfaces ( + &DriverBindingHandle, + &gEfiDriverBindingProtocolGuid, (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding, + &gEfiComponentNameProtocolGuid, (EFI_COMPONENT_NAME_PROTOCOL *)_gDriverModelProtocolList[0].ComponentName, + &gEfiDriverConfigurationProtocolGuid, (EFI_DRIVER_CONFIGURATION_PROTOCOL *)_gDriverModelProtocolList[0].DriverConfiguration, + NULL + ); + } + } + } else { + if (_gDriverModelProtocolList[0].DriverConfiguration == NULL) { + if (_gDriverModelProtocolList[0].ComponentName == NULL) { + Status = gBS->InstallMultipleProtocolInterfaces ( + &DriverBindingHandle, + &gEfiDriverBindingProtocolGuid, (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding, + &gEfiDriverDiagnosticsProtocolGuid, (EFI_DRIVER_DIAGNOSTICS_PROTOCOL *)_gDriverModelProtocolList[0].DriverDiagnostics, + NULL + ); + } else { + Status = gBS->InstallMultipleProtocolInterfaces ( + &DriverBindingHandle, + &gEfiDriverBindingProtocolGuid, (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding, + &gEfiComponentNameProtocolGuid, (EFI_COMPONENT_NAME_PROTOCOL *)_gDriverModelProtocolList[0].ComponentName, + &gEfiDriverDiagnosticsProtocolGuid, (EFI_DRIVER_DIAGNOSTICS_PROTOCOL *)_gDriverModelProtocolList[0].DriverDiagnostics, + NULL + ); + } + } else { + if (_gDriverModelProtocolList[0].ComponentName == NULL) { + Status = gBS->InstallMultipleProtocolInterfaces ( + &DriverBindingHandle, + &gEfiDriverBindingProtocolGuid, (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding, + &gEfiDriverConfigurationProtocolGuid, (EFI_DRIVER_CONFIGURATION_PROTOCOL *)_gDriverModelProtocolList[0].DriverConfiguration, + &gEfiDriverDiagnosticsProtocolGuid, (EFI_DRIVER_DIAGNOSTICS_PROTOCOL *)_gDriverModelProtocolList[0].DriverDiagnostics, + NULL + ); + } else { + Status = gBS->InstallMultipleProtocolInterfaces ( + &DriverBindingHandle, + &gEfiDriverBindingProtocolGuid, (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding, + &gEfiComponentNameProtocolGuid, (EFI_COMPONENT_NAME_PROTOCOL *)_gDriverModelProtocolList[0].ComponentName, + &gEfiDriverConfigurationProtocolGuid, (EFI_DRIVER_CONFIGURATION_PROTOCOL *)_gDriverModelProtocolList[0].DriverConfiguration, + &gEfiDriverDiagnosticsProtocolGuid, (EFI_DRIVER_DIAGNOSTICS_PROTOCOL *)_gDriverModelProtocolList[0].DriverDiagnostics, + NULL + ); + } + } + } + } // selection == 1 or 3 + + if ((_gEdkIIGlueDriverModelProtocolSelection == 2) || (_gEdkIIGlueDriverModelProtocolSelection == 3)) { + if (_gDriverModelProtocolList[0].DriverDiagnostics2== NULL) { + if (_gDriverModelProtocolList[0].DriverConfiguration2== NULL) { + if (_gDriverModelProtocolList[0].ComponentName2== NULL) { + Status = gBS->InstallMultipleProtocolInterfaces ( + &DriverBindingHandle, + &gEfiDriverBindingProtocolGuid, (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding, + NULL + ); + } else { + Status = gBS->InstallMultipleProtocolInterfaces ( + &DriverBindingHandle, + &gEfiDriverBindingProtocolGuid, (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding, + &gEfiComponentName2ProtocolGuid, (EFI_COMPONENT_NAME2_PROTOCOL *)_gDriverModelProtocolList[0].ComponentName2, + NULL + ); + } + } else { + if (_gDriverModelProtocolList[0].ComponentName2 == NULL) { + Status = gBS->InstallMultipleProtocolInterfaces ( + &DriverBindingHandle, + &gEfiDriverBindingProtocolGuid, (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding, + &gEfiDriverConfiguration2ProtocolGuid, (EFI_DRIVER_CONFIGURATION2_PROTOCOL *)_gDriverModelProtocolList[0].DriverConfiguration2, + NULL + ); + } else { + Status = gBS->InstallMultipleProtocolInterfaces ( + &DriverBindingHandle, + &gEfiDriverBindingProtocolGuid, (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding, + &gEfiComponentName2ProtocolGuid, (EFI_COMPONENT_NAME2_PROTOCOL *)_gDriverModelProtocolList[0].ComponentName2, + &gEfiDriverConfiguration2ProtocolGuid, (EFI_DRIVER_CONFIGURATION2_PROTOCOL *)_gDriverModelProtocolList[0].DriverConfiguration2, + NULL + ); + } + } + } else { + if (_gDriverModelProtocolList[0].DriverConfiguration2 == NULL) { + if (_gDriverModelProtocolList[0].ComponentName2 == NULL) { + Status = gBS->InstallMultipleProtocolInterfaces ( + &DriverBindingHandle, + &gEfiDriverBindingProtocolGuid, (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding, + &gEfiDriverDiagnostics2ProtocolGuid, (EFI_DRIVER_DIAGNOSTICS2_PROTOCOL *)_gDriverModelProtocolList[0].DriverDiagnostics2, + NULL + ); + } else { + Status = gBS->InstallMultipleProtocolInterfaces ( + &DriverBindingHandle, + &gEfiDriverBindingProtocolGuid, (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding, + &gEfiComponentName2ProtocolGuid, (EFI_COMPONENT_NAME2_PROTOCOL *)_gDriverModelProtocolList[0].ComponentName2, + &gEfiDriverDiagnostics2ProtocolGuid, (EFI_DRIVER_DIAGNOSTICS2_PROTOCOL *)_gDriverModelProtocolList[0].DriverDiagnostics2, + NULL + ); + } + } else { + if (_gDriverModelProtocolList[0].ComponentName2 == NULL) { + Status = gBS->InstallMultipleProtocolInterfaces ( + &DriverBindingHandle, + &gEfiDriverBindingProtocolGuid, (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding, + &gEfiDriverConfiguration2ProtocolGuid, (EFI_DRIVER_CONFIGURATION2_PROTOCOL *)_gDriverModelProtocolList[0].DriverConfiguration2, + &gEfiDriverDiagnostics2ProtocolGuid, (EFI_DRIVER_DIAGNOSTICS2_PROTOCOL *)_gDriverModelProtocolList[0].DriverDiagnostics2, + NULL + ); + } else { + Status = gBS->InstallMultipleProtocolInterfaces ( + &DriverBindingHandle, + &gEfiDriverBindingProtocolGuid, (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding, + &gEfiComponentName2ProtocolGuid, (EFI_COMPONENT_NAME2_PROTOCOL *)_gDriverModelProtocolList[0].ComponentName2, + &gEfiDriverConfiguration2ProtocolGuid, (EFI_DRIVER_CONFIGURATION2_PROTOCOL *)_gDriverModelProtocolList[0].DriverConfiguration2, + &gEfiDriverDiagnostics2ProtocolGuid, (EFI_DRIVER_DIAGNOSTICS2_PROTOCOL *)_gDriverModelProtocolList[0].DriverDiagnostics2, + NULL + ); + } + } + } + } // selection == 2 or 3 + + // + // ASSERT if the call to InstallMultipleProtocolInterfaces() failed + // + ASSERT_EFI_ERROR (Status); + + // + // Update the ImageHandle and DriverBindingHandle fields of the Driver Binding Protocol + // + DriverBinding = (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding; + DriverBinding->ImageHandle = ImageHandle; + DriverBinding->DriverBindingHandle = DriverBindingHandle; + + + return EFI_SUCCESS; +} + +/** + The destructor function uninstalls the standard EFI Driver Model Protocols. + + @param[in] ImageHandle The firmware allocated handle for the EFI image. + @param[in] SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The destructor always return EFI_SUCCESS. + +**/ +EFI_STATUS +EFIAPI +UefiDriverModelLibDestructor ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status = EFI_UNSUPPORTED; + EFI_HANDLE DriverBindingHandle; + + // + // See if onle one Driver Binding Protocol is advertised by the driver + // EdkIIGlueLib: _gDriverModelProtocolListEntries is always 1 + // + + // + // The Driver Binding Protocol must never be NULL + // + ASSERT(_gDriverModelProtocolList[0].DriverBinding != NULL); + + // + // Retrieve the DriverBindingHandle from the Driver Binding Protocol + // + DriverBindingHandle = _gDriverModelProtocolList[0].DriverBinding->DriverBindingHandle; + + // + // Check for all 8 possible combinations of the ComponentName, DriverConfiguration, and DriverDiagnostics Protocol + // These are all checks against const pointers, so the optimizing compiler will only select one of the + // calls to InstallMultipleProtocolInterfaces() + // + if ((_gEdkIIGlueDriverModelProtocolSelection == 1) || (_gEdkIIGlueDriverModelProtocolSelection == 3)) { + if (_gDriverModelProtocolList[0].DriverDiagnostics == NULL) { + if (_gDriverModelProtocolList[0].DriverConfiguration == NULL) { + if (_gDriverModelProtocolList[0].ComponentName == NULL) { + Status = gBS->UninstallMultipleProtocolInterfaces ( + DriverBindingHandle, + &gEfiDriverBindingProtocolGuid, (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding, + NULL + ); + } else { + Status = gBS->UninstallMultipleProtocolInterfaces ( + &DriverBindingHandle, + &gEfiDriverBindingProtocolGuid, (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding, + &gEfiComponentNameProtocolGuid, (EFI_COMPONENT_NAME_PROTOCOL *)_gDriverModelProtocolList[0].ComponentName, + NULL + ); + } + } else { + if (_gDriverModelProtocolList[0].ComponentName == NULL) { + Status = gBS->UninstallMultipleProtocolInterfaces ( + &DriverBindingHandle, + &gEfiDriverBindingProtocolGuid, (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding, + &gEfiDriverConfigurationProtocolGuid, (EFI_DRIVER_CONFIGURATION_PROTOCOL *)_gDriverModelProtocolList[0].DriverConfiguration, + NULL + ); + } else { + Status = gBS->UninstallMultipleProtocolInterfaces ( + &DriverBindingHandle, + &gEfiDriverBindingProtocolGuid, (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding, + &gEfiComponentNameProtocolGuid, (EFI_COMPONENT_NAME_PROTOCOL *)_gDriverModelProtocolList[0].ComponentName, + &gEfiDriverConfigurationProtocolGuid, (EFI_DRIVER_CONFIGURATION_PROTOCOL *)_gDriverModelProtocolList[0].DriverConfiguration, + NULL + ); + } + } + } else { + if (_gDriverModelProtocolList[0].DriverConfiguration == NULL) { + if (_gDriverModelProtocolList[0].ComponentName == NULL) { + Status = gBS->UninstallMultipleProtocolInterfaces ( + &DriverBindingHandle, + &gEfiDriverBindingProtocolGuid, (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding, + &gEfiDriverDiagnosticsProtocolGuid, (EFI_DRIVER_DIAGNOSTICS_PROTOCOL *)_gDriverModelProtocolList[0].DriverDiagnostics, + NULL + ); + } else { + Status = gBS->UninstallMultipleProtocolInterfaces ( + &DriverBindingHandle, + &gEfiDriverBindingProtocolGuid, (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding, + &gEfiComponentNameProtocolGuid, (EFI_COMPONENT_NAME_PROTOCOL *)_gDriverModelProtocolList[0].ComponentName, + &gEfiDriverDiagnosticsProtocolGuid, (EFI_DRIVER_DIAGNOSTICS_PROTOCOL *)_gDriverModelProtocolList[0].DriverDiagnostics, + NULL + ); + } + } else { + if (_gDriverModelProtocolList[0].ComponentName == NULL) { + Status = gBS->UninstallMultipleProtocolInterfaces ( + &DriverBindingHandle, + &gEfiDriverBindingProtocolGuid, (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding, + &gEfiDriverConfigurationProtocolGuid, (EFI_DRIVER_CONFIGURATION_PROTOCOL *)_gDriverModelProtocolList[0].DriverConfiguration, + &gEfiDriverDiagnosticsProtocolGuid, (EFI_DRIVER_DIAGNOSTICS_PROTOCOL *)_gDriverModelProtocolList[0].DriverDiagnostics, + NULL + ); + } else { + Status = gBS->UninstallMultipleProtocolInterfaces ( + &DriverBindingHandle, + &gEfiDriverBindingProtocolGuid, (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding, + &gEfiComponentNameProtocolGuid, (EFI_COMPONENT_NAME_PROTOCOL *)_gDriverModelProtocolList[0].ComponentName, + &gEfiDriverConfigurationProtocolGuid, (EFI_DRIVER_CONFIGURATION_PROTOCOL *)_gDriverModelProtocolList[0].DriverConfiguration, + &gEfiDriverDiagnosticsProtocolGuid, (EFI_DRIVER_DIAGNOSTICS_PROTOCOL *)_gDriverModelProtocolList[0].DriverDiagnostics, + NULL + ); + } + } + } + } // selection == 1 or 3 + + if ((_gEdkIIGlueDriverModelProtocolSelection == 2) || (_gEdkIIGlueDriverModelProtocolSelection == 3)) { + if (_gDriverModelProtocolList[0].DriverDiagnostics2 == NULL) { + if (_gDriverModelProtocolList[0].DriverConfiguration2 == NULL) { + if (_gDriverModelProtocolList[0].ComponentName2 == NULL) { + Status = gBS->UninstallMultipleProtocolInterfaces ( + DriverBindingHandle, + &gEfiDriverBindingProtocolGuid, (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding, + NULL + ); + } else { + Status = gBS->UninstallMultipleProtocolInterfaces ( + &DriverBindingHandle, + &gEfiDriverBindingProtocolGuid, (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding, + &gEfiComponentName2ProtocolGuid, (EFI_COMPONENT_NAME2_PROTOCOL *)_gDriverModelProtocolList[0].ComponentName2, + NULL + ); + } + } else { + if (_gDriverModelProtocolList[0].ComponentName2 == NULL) { + Status = gBS->UninstallMultipleProtocolInterfaces ( + &DriverBindingHandle, + &gEfiDriverBindingProtocolGuid, (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding, + &gEfiDriverConfiguration2ProtocolGuid, (EFI_DRIVER_CONFIGURATION2_PROTOCOL *)_gDriverModelProtocolList[0].DriverConfiguration2, + NULL + ); + } else { + Status = gBS->UninstallMultipleProtocolInterfaces ( + &DriverBindingHandle, + &gEfiDriverBindingProtocolGuid, (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding, + &gEfiComponentName2ProtocolGuid, (EFI_COMPONENT_NAME2_PROTOCOL *)_gDriverModelProtocolList[0].ComponentName2, + &gEfiDriverConfiguration2ProtocolGuid, (EFI_DRIVER_CONFIGURATION2_PROTOCOL *)_gDriverModelProtocolList[0].DriverConfiguration2, + NULL + ); + } + } + } else { + if (_gDriverModelProtocolList[0].DriverConfiguration2 == NULL) { + if (_gDriverModelProtocolList[0].ComponentName2 == NULL) { + Status = gBS->UninstallMultipleProtocolInterfaces ( + &DriverBindingHandle, + &gEfiDriverBindingProtocolGuid, (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding, + &gEfiDriverDiagnostics2ProtocolGuid, (EFI_DRIVER_DIAGNOSTICS2_PROTOCOL *)_gDriverModelProtocolList[0].DriverDiagnostics2, + NULL + ); + } else { + Status = gBS->UninstallMultipleProtocolInterfaces ( + &DriverBindingHandle, + &gEfiDriverBindingProtocolGuid, (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding, + &gEfiComponentName2ProtocolGuid, (EFI_COMPONENT_NAME2_PROTOCOL *)_gDriverModelProtocolList[0].ComponentName2, + &gEfiDriverDiagnostics2ProtocolGuid, (EFI_DRIVER_DIAGNOSTICS2_PROTOCOL *)_gDriverModelProtocolList[0].DriverDiagnostics2, + NULL + ); + } + } else { + if (_gDriverModelProtocolList[0].ComponentName2 == NULL) { + Status = gBS->UninstallMultipleProtocolInterfaces ( + &DriverBindingHandle, + &gEfiDriverBindingProtocolGuid, (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding, + &gEfiDriverConfiguration2ProtocolGuid, (EFI_DRIVER_CONFIGURATION2_PROTOCOL *)_gDriverModelProtocolList[0].DriverConfiguration2, + &gEfiDriverDiagnostics2ProtocolGuid, (EFI_DRIVER_DIAGNOSTICS2_PROTOCOL *)_gDriverModelProtocolList[0].DriverDiagnostics2, + NULL + ); + } else { + Status = gBS->UninstallMultipleProtocolInterfaces ( + &DriverBindingHandle, + &gEfiDriverBindingProtocolGuid, (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding, + &gEfiComponentName2ProtocolGuid, (EFI_COMPONENT_NAME2_PROTOCOL *)_gDriverModelProtocolList[0].ComponentName2, + &gEfiDriverConfiguration2ProtocolGuid, (EFI_DRIVER_CONFIGURATION2_PROTOCOL *)_gDriverModelProtocolList[0].DriverConfiguration2, + &gEfiDriverDiagnostics2ProtocolGuid, (EFI_DRIVER_DIAGNOSTICS2_PROTOCOL *)_gDriverModelProtocolList[0].DriverDiagnostics2, + NULL + ); + } + } + } + } // selection == 2 or 3 + + // + // ASSERT if the call to UninstallMultipleProtocolInterfaces() failed + // + ASSERT_EFI_ERROR (Status); + + return EFI_SUCCESS; +} diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiDriverModelLib/UefiDriverModelLib.inf b/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiDriverModelLib/UefiDriverModelLib.inf new file mode 100644 index 0000000..9b335a8 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiDriverModelLib/UefiDriverModelLib.inf @@ -0,0 +1,65 @@ +#/*++ +# +# 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: +# +# UefiDriverModelLib.inf +# +# Abstract: +# +# Component description file for UefiDriverModelLib.inf +# +#--*/ + +[defines] +BASE_NAME = EdkIIGlueUefiDriverModelLib +COMPONENT_TYPE = LIBRARY + +[sources.common] + UefiDriverModelLib.c + +[sources.ia32] + +[sources.ipf,sources.x64] + +[includes.common] + $(EDK_SOURCE)\Foundation\Framework + $(EDK_SOURCE)\Foundation + $(EDK_SOURCE)\Foundation\Efi + $(EDK_SOURCE)\Foundation\Include + $(EDK_SOURCE)\Foundation\Efi\Include + $(EDK_SOURCE)\Foundation\Framework\Include + $(EDK_SOURCE)\Foundation\Include\IndustryStandard + $(EDK_SOURCE)\Foundation\Library\EdkIIGlueLib\Include + $(EDK_SOURCE)\Foundation\Core + $(EDK_SOURCE)\Foundation\Core\Dxe + $(EDK_SOURCE)\Foundation\Library\Dxe\Include + $(EDK_SOURCE)\Foundation\Include\Pei + $(EDK_SOURCE)\Foundation\Library\Pei\Include + +[libraries.common] + EdkIIGlueUefiBootServicesTableLib + +[nmake.common] + C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION + LIB_STD_FLAGS = /NOLOGO /IGNORE:4006 + +[nmake.ia32] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32 + +[nmake.x64] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64 + +[nmake.ipf] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF + +[nmake.ebc] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_EBC diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiLib/Console.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiLib/Console.c new file mode 100644 index 0000000..a8a0635 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiLib/Console.c @@ -0,0 +1,288 @@ +/*++ + +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: + + Console.c + +Abstract: + + UEFI library functions. + +--*/ + +#include "EdkIIGlueUefi.h" + +typedef struct { + CHAR16 WChar; + UINT32 Width; +} UNICODE_WIDTH_ENTRY; + +UNICODE_WIDTH_ENTRY mUnicodeWidthTable[] = { + // + // General script area + // + {(CHAR16)0x1FFF, 1}, + /* + * Merge the blocks and replace them with the above entry as they fall to + * the same category and they are all narrow glyph. This will reduce search + * time and table size. The merge will omit the reserved code. + * + * Remove the above item if below is un-commented. + * + {(CHAR16)0x007F, 1}, // C0 controls and basic Latin. 0x0000-0x007F + {(CHAR16)0x00FF, 1}, // C1 controls and Latin-1 support. 0x0080-0x00FF + {(CHAR16)0x017F, 1}, // Latin extended-A. 0x0100-0x017F + {(CHAR16)0x024F, 1}, // Latin extended-B. 0x0180-0x024F + {(CHAR16)0x02AF, 1}, // IPA extensions. 0x0250-0x02AF + {(CHAR16)0x02FF, 1}, // Spacing modifier letters. 0x02B0-0x02FF + {(CHAR16)0x036F, 1}, // Combining diacritical marks. 0x0300-0x036F + {(CHAR16)0x03FF, 1}, // Greek. 0x0370-0x03FF + {(CHAR16)0x04FF, 1}, // Cyrillic. 0x0400-0x04FF + {(CHAR16)0x052F, 0}, // Unassigned. As Armenian in ver3.0. 0x0500-0x052F + {(CHAR16)0x058F, 1}, // Armenian. 0x0530-0x058F + {(CHAR16)0x05FF, 1}, // Hebrew. 0x0590-0x05FF + {(CHAR16)0x06FF, 1}, // Arabic. 0x0600-0x06FF + {(CHAR16)0x08FF, 0}, // Unassigned. 0x0700-0x08FF + {(CHAR16)0x097F, 1}, // Devanagari. 0x0900-0x097F + {(CHAR16)0x09FF, 1}, // Bengali. 0x0980-0x09FF + {(CHAR16)0x0A7F, 1}, // Gurmukhi. 0x0A00-0x0A7F + {(CHAR16)0x0AFF, 1}, // Gujarati. 0x0A80-0x0AFF + {(CHAR16)0x0B7F, 1}, // Oriya. 0x0B00-0x0B7F + {(CHAR16)0x0BFF, 1}, // Tamil. (See page 7-92). 0x0B80-0x0BFF + {(CHAR16)0x0C7F, 1}, // Telugu. 0x0C00-0x0C7F + {(CHAR16)0x0CFF, 1}, // Kannada. (See page 7-100). 0x0C80-0x0CFF + {(CHAR16)0x0D7F, 1}, // Malayalam (See page 7-104). 0x0D00-0x0D7F + {(CHAR16)0x0DFF, 0}, // Unassigned. 0x0D80-0x0DFF + {(CHAR16)0x0E7F, 1}, // Thai. 0x0E00-0x0E7F + {(CHAR16)0x0EFF, 1}, // Lao. 0x0E80-0x0EFF + {(CHAR16)0x0FBF, 1}, // Tibetan. 0x0F00-0x0FBF + {(CHAR16)0x109F, 0}, // Unassigned. 0x0FC0-0x109F + {(CHAR16)0x10FF, 1}, // Georgian. 0x10A0-0x10FF + {(CHAR16)0x11FF, 1}, // Hangul Jamo. 0x1100-0x11FF + {(CHAR16)0x1DFF, 0}, // Unassigned. 0x1200-0x1DFF + {(CHAR16)0x1EFF, 1}, // Latin extended additional. 0x1E00-0x1EFF + {(CHAR16)0x1FFF, 1}, // Greek extended. 0x1F00-0x1FFF + * + */ + + // + // Symbol area + // + {(CHAR16)0x2FFF, 1}, + /* + * Merge the blocks and replace them with the above entry as they fall to + * the same category and they are all narrow glyph. This will reduce search + * time and table size. The merge will omit the reserved code. + * + * Remove the above item if below is un-commented. + * + {(CHAR16)0x206F, 1}, // General punctuation. (See page7-154). 0x200-0x206F + {(CHAR16)0x209F, 1}, // Superscripts and subscripts. 0x2070-0x209F + {(CHAR16)0x20CF, 1}, // Currency symbols. 0x20A0-0x20CF + {(CHAR16)0x20FF, 1}, // Combining diacritical marks for symbols. 0x20D0-0x20FF + {(CHAR16)0x214F, 1}, // Letterlike sympbols. 0x2100-0x214F + {(CHAR16)0x218F, 1}, // Number forms. 0x2150-0x218F + {(CHAR16)0x21FF, 1}, // Arrows. 0x2190-0x21FF + {(CHAR16)0x22FF, 1}, // Mathematical operators. 0x2200-0x22FF + {(CHAR16)0x23FF, 1}, // Miscellaneous technical. 0x2300-0x23FF + {(CHAR16)0x243F, 1}, // Control pictures. 0x2400-0x243F + {(CHAR16)0x245F, 1}, // Optical character recognition. 0x2440-0x245F + {(CHAR16)0x24FF, 1}, // Enclosed alphanumerics. 0x2460-0x24FF + {(CHAR16)0x257F, 1}, // Box drawing. 0x2500-0x257F + {(CHAR16)0x259F, 1}, // Block elements. 0x2580-0x259F + {(CHAR16)0x25FF, 1}, // Geometric shapes. 0x25A0-0x25FF + {(CHAR16)0x26FF, 1}, // Miscellaneous symbols. 0x2600-0x26FF + {(CHAR16)0x27BF, 1}, // Dingbats. 0x2700-0x27BF + {(CHAR16)0x2FFF, 0}, // Reserved. 0x27C0-0x2FFF + * + */ + + // + // CJK phonetics and symbol area + // + {(CHAR16)0x33FF, 2}, + /* + * Merge the blocks and replace them with the above entry as they fall to + * the same category and they are all wide glyph. This will reduce search + * time and table size. The merge will omit the reserved code. + * + * Remove the above item if below is un-commented. + * + {(CHAR16)0x303F, 2}, // CJK symbols and punctuation. 0x3000-0x303F + {(CHAR16)0x309F, 2}, // Hiragana. 0x3040-0x309F + {(CHAR16)0x30FF, 2}, // Katakana. 0x30A0-0x30FF + {(CHAR16)0x312F, 2}, // Bopomofo. 0x3100-0x312F + {(CHAR16)0x318F, 2}, // Hangul compatibility jamo. 0x3130-0x318F + {(CHAR16)0x319F, 2}, // Kanbun. 0x3190-0x319F + {(CHAR16)0x31FF, 0}, // Reserved. As Bopomofo extended in ver3.0. 0x31A0-0x31FF + {(CHAR16)0x32FF, 2}, // Enclosed CJK letters and months. 0x3200-0x32FF + {(CHAR16)0x33FF, 2}, // CJK compatibility. 0x3300-0x33FF + * + */ + + // + // CJK ideograph area + // + {(CHAR16)0x9FFF, 2}, + /* + * Merge the blocks and replace them with the above entry as they fall to + * the same category and they are all wide glyph. This will reduce search + * time and table size. The merge will omit the reserved code. + * + * Remove the above item if below is un-commented. + * + {(CHAR16)0x4DFF, 0}, // Reserved. 0x3400-0x4DBF as CJK unified ideographs + // extension A in ver3.0. 0x3400-0x4DFF + {(CHAR16)0x9FFF, 2}, // CJK unified ideographs. 0x4E00-0x9FFF + * + */ + + // + // Reserved + // + {(CHAR16)0xABFF, 0}, // Reserved. 0xA000-0xA490 as Yi syllables. 0xA490-0xA4D0 + // as Yi radicals in ver3.0. 0xA000-0xABFF + // + // Hangul syllables + // + {(CHAR16)0xD7FF, 2}, + /* + * Merge the blocks and replace them with the above entry as they fall to + * the same category and they are all wide glyph. This will reduce search + * time and table size. The merge will omit the reserved code. + * + * Remove the above item if below is un-commented. + * + {(CHAR16)0xD7A3, 2}, // Hangul syllables. 0xAC00-0xD7A3 + {(CHAR16)0xD7FF, 0}, // Reserved. 0xD7A3-0xD7FF + * + */ + + // + // Surrogates area + // + {(CHAR16)0xDFFF, 0}, // Surrogates, not used now. 0xD800-0xDFFF + + // + // Private use area + // + {(CHAR16)0xF8FF, 0}, // Private use area. 0xE000-0xF8FF + + // + // Compatibility area and specials + // + {(CHAR16)0xFAFF, 2}, // CJK compatibility ideographs. 0xF900-0xFAFF + {(CHAR16)0xFB4F, 1}, // Alphabetic presentation forms. 0xFB00-0xFB4F + {(CHAR16)0xFDFF, 1}, // Arabic presentation forms-A. 0xFB50-0xFDFF + {(CHAR16)0xFE1F, 0}, // Reserved. As variation selectors in ver3.0. 0xFE00-0xFE1F + {(CHAR16)0xFE2F, 1}, // Combining half marks. 0xFE20-0xFE2F + {(CHAR16)0xFE4F, 2}, // CJK compatibility forms. 0xFE30-0xFE4F + {(CHAR16)0xFE6F, 1}, // Small Form Variants. 0xFE50-0xFE6F + {(CHAR16)0xFEFF, 1}, // Arabic presentation forms-B. 0xFE70-0xFEFF + {(CHAR16)0xFFEF, 1}, // Half width and full width forms. 0xFF00-0xFFEF + {(CHAR16)0xFFFF, 0}, // Speicials. 0xFFF0-0xFFFF +}; + +/** + This function computes and returns the width of the Unicode character + specified by UnicodeChar. + + @param UnicodeChar A Unicode character. + + @retval 0 The width if UnicodeChar could not be determined. + @retval 1 UnicodeChar is a narrow glyph. + @retval 2 UnicodeChar is a wide glyph. + +**/ +UINTN +EFIAPI +GlueGetGlyphWidth ( + IN CHAR16 UnicodeChar + ) +{ + UINTN Index; + UINTN Low; + UINTN High; + UNICODE_WIDTH_ENTRY *Item; + + Item = NULL; + Low = 0; + High = (sizeof (mUnicodeWidthTable)) / (sizeof (UNICODE_WIDTH_ENTRY)) - 1; + while (Low <= High) { + Index = (Low + High) >> 1; + Item = &(mUnicodeWidthTable[Index]); + if (Index == 0) { + if (UnicodeChar <= Item->WChar) { + break; + } + + return 0; + } + + if (UnicodeChar > Item->WChar) { + Low = Index + 1; + } else if (UnicodeChar <= mUnicodeWidthTable[Index - 1].WChar) { + High = Index - 1; + } else { + // + // Index - 1 < UnicodeChar <= Index. Found + // + break; + } + } + + if (Low <= High) { + return Item->Width; + } + + return 0; +} + +/** + This function computes and returns the display length of + the Null-terminated Unicode string specified by String. + If String is NULL, then 0 is returned. + If any of the widths of the Unicode characters in String + can not be determined, then 0 is returned. + + @param String A pointer to a Null-terminated Unicode string. + + @return The display length of the Null-terminated Unicode string specified by String. + +**/ +UINTN +EFIAPI +UnicodeStringDisplayLength ( + IN CONST CHAR16 *String + ) +{ + UINTN Length; + UINTN Width; + + if (String == NULL) { + return 0; + } + + Length = 0; + while (*String != 0) { + Width = GetGlyphWidth (*String); + if (Width == 0) { + return 0; + } + + Length += Width; + String++; + } + + return Length; +} diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiLib/EdkIIGlueUefiLib.cif b/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiLib/EdkIIGlueUefiLib.cif new file mode 100644 index 0000000..cc3905c --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiLib/EdkIIGlueUefiLib.cif @@ -0,0 +1,13 @@ +<component> + name = "EdkIIGlueUefiLib" + category = ModulePart + LocalRoot = "Edk\Foundation\Library\EdkIIGlueLib\Library\UefiLib" + RefName = "EdkIIGlueUefiLib" +[files] +"EdkIIGlueUefiLib.sdl" +"EdkIIGlueUefiLib.mak" +"UefiLib.inf" +"UefiLib.c" +"Console.c" +"UefiNotTiano.c" +<endComponent> diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiLib/EdkIIGlueUefiLib.mak b/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiLib/EdkIIGlueUefiLib.mak new file mode 100644 index 0000000..0c9f282 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiLib/EdkIIGlueUefiLib.mak @@ -0,0 +1,80 @@ +#********************************************************************** +#********************************************************************** +#** ** +#** (C)Copyright 1985-2009, American Megatrends, Inc. ** +#** ** +#** All Rights Reserved. ** +#** ** +#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +#** ** +#** Phone: (770)-246-8600 ** +#** ** +#********************************************************************** +#********************************************************************** + +#********************************************************************** +# $Header: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGlueUefiLib/EdkIIGlueUefiLib.mak 1 1/20/12 3:58a Jeffch $ +# +# $Revision: 1 $ +# +# $Date: 1/20/12 3:58a $ +#********************************************************************** +# Revision History +# ---------------- +# $Log: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGlueUefiLib/EdkIIGlueUefiLib.mak $ +# +# 1 1/20/12 3:58a Jeffch +# Create Intel EDK 1117 Patch 7. +# +# 1 9/27/11 6:20a Wesleychen +# Intel EDK initially releases. +# +# 1 9/18/09 1:59a Iminglin +# +#********************************************************************** +#<AMI_FHDR_START> +# +# Name: EdkIIGlueUefiLib.mak +# +# Description: +# +#<AMI_FHDR_END> +#********************************************************************** + + +$(EdkIIGlueUefiLib_LIB) : EdkIIGlueUefiLib + +EdkIIGlueUefiLib : $(BUILD_DIR)\EdkIIGlueUefiLib.mak EdkIIGlueUefiLibBin + +$(BUILD_DIR)\EdkIIGlueUefiLib.mak : $(EdkIIGlueUefiLib_DIR)\$(@B).cif $(EdkIIGlueUefiLib_DIR)\$(@B).mak $(BUILD_RULES) + $(CIF2MAK) $(EdkIIGlueUefiLib_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS) + +EdkIIGlueUefiLibBin : $(EdkIIGlueBaseLib_LIB) $(EdkIIGlueBaseMemoryLib_LIB) $(EdkIIGlueUefiBootServicesTableLib_LIB) $(EdkIIGlueDxeMemoryAllocationLib_LIB) $(EFIGUIDLIB) +!IF "$(x64_BUILD)"=="1" + $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\ + BUILD_DIR=$(BUILD_DIR)\ + /f $(BUILD_DIR)\EdkIIGlueUefiLib.mak all\ + TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueUefiLib_LIB)" + $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\ + BUILD_DIR=$(BUILD_DIR)\IA32\ + /f $(BUILD_DIR)\EdkIIGlueUefiLib.mak all\ + TYPE=PEI_LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueUefiLib_LIB)" +!ELSE + $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\ + BUILD_DIR=$(BUILD_DIR)\ + /f $(BUILD_DIR)\EdkIIGlueUefiLib.mak all\ + TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueUefiLib_LIB)" +!ENDIF +#********************************************************************** +#********************************************************************** +#** ** +#** (C)Copyright 1985-2009, American Megatrends, Inc. ** +#** ** +#** All Rights Reserved. ** +#** ** +#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +#** ** +#** Phone: (770)-246-8600 ** +#** ** +#********************************************************************** +#********************************************************************** diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiLib/EdkIIGlueUefiLib.sdl b/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiLib/EdkIIGlueUefiLib.sdl new file mode 100644 index 0000000..57d5e42 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiLib/EdkIIGlueUefiLib.sdl @@ -0,0 +1,26 @@ +TOKEN + Name = "EdkIIGlueUefiLib_SUPPORT" + Value = "1" + Help = "Main switch to enable EdkIIGlueUefiLib support in Project" + TokenType = Boolean + TargetEQU = Yes + TargetMAK = Yes + Master = Yes +End + +TOKEN + Name = "EdkIIGlueUefiLib_LIB" + Value = "$$(LIB_BUILD_DIR)\EdkIIGlueUefiLib.lib" + TokenType = Expression + TargetMAK = Yes +End + +PATH + Name = "EdkIIGlueUefiLib_DIR" +End + +MODULE + Help = "Includes EdkIIGlueUefiLib.mak to Project" + File = "EdkIIGlueUefiLib.mak" +End + diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiLib/UefiLib.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiLib/UefiLib.c new file mode 100644 index 0000000..0174a82 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiLib/UefiLib.c @@ -0,0 +1,948 @@ +/*++ + +Copyright (c) 2004 - 2011, 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. + + +**/ + +#include "EdkIIGlueUefi.h" +#include "Library\EdkIIGlueMemoryAllocationLib.h" + + +/** + This function searches the list of configuration tables stored in the EFI System + Table for a table with a GUID that matches TableGuid. If a match is found, + then a pointer to the configuration table is returned in Table, and EFI_SUCCESS + is returned. If a matching GUID is not found, then EFI_NOT_FOUND is returned. + + @param TableGuid Pointer to table's GUID type.. + @param Table Pointer to the table associated with TableGuid in the EFI System Table. + + @retval EFI_SUCCESS A configuration table matching TableGuid was found. + @retval EFI_NOT_FOUND A configuration table matching TableGuid could not be found. + +**/ +EFI_STATUS +EFIAPI +EfiGetSystemConfigurationTable ( + IN EFI_GUID *TableGuid, + OUT VOID **Table + ) +{ + EFI_SYSTEM_TABLE *SystemTable; + UINTN Index; + + ASSERT (TableGuid != NULL); + ASSERT (Table != NULL); + + SystemTable = gST; + *Table = NULL; + for (Index = 0; Index < SystemTable->NumberOfTableEntries; Index++) { + if (CompareGuid (TableGuid, &(SystemTable->ConfigurationTable[Index].VendorGuid))) { + *Table = SystemTable->ConfigurationTable[Index].VendorTable; + return EFI_SUCCESS; + } + } + + return EFI_NOT_FOUND; +} + +/** + This function causes the notification function to be executed for every protocol + of type ProtocolGuid instance that exists in the system when this function is + invoked. In addition, every time a protocol of type ProtocolGuid instance is + installed or reinstalled, the notification function is also executed. + + @param ProtocolGuid Supplies GUID of the protocol upon whose installation the event is fired. + @param NotifyTpl Supplies the task priority level of the event notifications. + @param NotifyFunction Supplies the function to notify when the event is signaled. + @param NotifyContext The context parameter to pass to NotifyFunction. + @param Registration A pointer to a memory location to receive the registration value. + + @return The notification event that was created. + +**/ +EFI_EVENT +EFIAPI +EfiCreateProtocolNotifyEvent( + IN EFI_GUID *ProtocolGuid, + IN EFI_TPL NotifyTpl, + IN EFI_EVENT_NOTIFY NotifyFunction, + IN VOID *NotifyContext, OPTIONAL + OUT VOID **Registration + ) +{ + EFI_STATUS Status; + EFI_EVENT Event; + + // + // Create the event + // + + Status = gBS->CreateEvent ( + EFI_EVENT_NOTIFY_SIGNAL, + NotifyTpl, + NotifyFunction, + NotifyContext, + &Event + ); + ASSERT_EFI_ERROR (Status); + + // + // Register for protocol notifactions on this event + // + + Status = gBS->RegisterProtocolNotify ( + ProtocolGuid, + Event, + Registration + ); + + ASSERT_EFI_ERROR (Status); + + // + // Kick the event so we will perform an initial pass of + // current installed drivers + // + + gBS->SignalEvent (Event); + return Event; +} + +/** + This function creates an event using NotifyTpl, NoifyFunction, and NotifyContext. + This event is signaled with EfiNamedEventSignal(). This provide the ability for + one or more listeners on the same event named by the GUID specified by Name. + + @param Name Supplies GUID name of the event. + @param NotifyTpl Supplies the task priority level of the event notifications. + @param NotifyFunction Supplies the function to notify when the event is signaled. + @param NotifyContext The context parameter to pass to NotifyFunction. + @param Registration A pointer to a memory location to receive the registration value. + + @retval EFI_SUCCESS A named event was created. + @retval EFI_OUT_OF_RESOURCES There are not enough resource to create the named event. + +**/ +EFI_STATUS +EFIAPI +EfiNamedEventListen ( + IN CONST EFI_GUID *Name, + IN EFI_TPL NotifyTpl, + IN EFI_EVENT_NOTIFY NotifyFunction, + IN CONST VOID *NotifyContext, OPTIONAL + OUT VOID *Registration OPTIONAL + ) +{ + EFI_STATUS Status; + EFI_EVENT Event; + VOID *RegistrationLocal; + + // + // Create event + // + Status = gBS->CreateEvent ( + EFI_EVENT_NOTIFY_SIGNAL, + NotifyTpl, + NotifyFunction, + (VOID *) NotifyContext, + &Event + ); + ASSERT_EFI_ERROR (Status); + + // + // The Registration is not optional to RegisterProtocolNotify(). + // To make it optional to EfiNamedEventListen(), may need to substitute with a local. + // + if (Registration != NULL) { + RegistrationLocal = Registration; + } else { + RegistrationLocal = &RegistrationLocal; + } + + // + // Register for an installation of protocol interface + // + + Status = gBS->RegisterProtocolNotify ( + (EFI_GUID *) Name, + Event, + RegistrationLocal + ); + ASSERT_EFI_ERROR (Status); + + return EFI_SUCCESS; +} + +/** + This function signals the named event specified by Name. The named event must + have been created with EfiNamedEventListen(). + + @param Name Supplies GUID name of the event. + + @retval EFI_SUCCESS A named event was signaled. + @retval EFI_OUT_OF_RESOURCES There are not enough resource to signal the named event. + +**/ +EFI_STATUS +EFIAPI +EfiNamedEventSignal ( + IN CONST EFI_GUID *Name + ) +{ + EFI_STATUS Status; + EFI_HANDLE Handle; + + Handle = NULL; + Status = gBS->InstallProtocolInterface ( + &Handle, + (EFI_GUID *) Name, + EFI_NATIVE_INTERFACE, + NULL + ); + ASSERT_EFI_ERROR (Status); + + Status = gBS->UninstallProtocolInterface ( + Handle, + (EFI_GUID *) Name, + NULL + ); + ASSERT_EFI_ERROR (Status); + + return EFI_SUCCESS; +} + +/** + Returns the current TPL. + + This function returns the current TPL. There is no EFI service to directly + retrieve the current TPL. Instead, the RaiseTPL() function is used to raise + the TPL to TPL_HIGH_LEVEL. This will return the current TPL. The TPL level + can then immediately be restored back to the current TPL level with a call + to RestoreTPL(). + + @param VOID + + @retvale EFI_TPL The current TPL. + +**/ +EFI_TPL +EFIAPI +EfiGetCurrentTpl ( + VOID + ) +{ + EFI_TPL Tpl; + + Tpl = gBS->RaiseTPL (EFI_TPL_HIGH_LEVEL); + gBS->RestoreTPL (Tpl); + + return Tpl; +} + + +/** + This function initializes a basic mutual exclusion lock to the released state + and returns the lock. Each lock provides mutual exclusion access at its task + priority level. Since there is no preemption or multiprocessor support in EFI, + acquiring the lock only consists of raising to the locks TPL. + + @param Lock A pointer to the lock data structure to initialize. + @param Priority EFI TPL associated with the lock. + + @return The lock. + +**/ +EFI_LOCK * +EFIAPI +GlueEfiInitializeLock ( + IN OUT EFI_LOCK *Lock, + IN EFI_TPL Priority + ) +{ + ASSERT (Lock != NULL); + ASSERT (Priority <= EFI_TPL_HIGH_LEVEL); + + Lock->Tpl = Priority; + Lock->OwnerTpl = EFI_TPL_APPLICATION; + Lock->Lock = EfiLockReleased ; + return Lock; +} + +/** + This function raises the system's current task priority level to the task + priority level of the mutual exclusion lock. Then, it places the lock in the + acquired state. + + @param Priority The task priority level of the lock. + +**/ +VOID +EFIAPI +GlueEfiAcquireLock ( + IN EFI_LOCK *Lock + ) +{ + ASSERT (Lock != NULL); + ASSERT (Lock->Lock == EfiLockReleased); + + Lock->OwnerTpl = gBS->RaiseTPL (Lock->Tpl); + Lock->Lock = EfiLockAcquired; +} + +/** + This function raises the system's current task priority level to the task + priority level of the mutual exclusion lock. Then, it attempts to place the + lock in the acquired state. + + @param Lock A pointer to the lock to acquire. + + @retval EFI_SUCCESS The lock was acquired. + @retval EFI_ACCESS_DENIED The lock could not be acquired because it is already owned. + +**/ +EFI_STATUS +EFIAPI +GlueEfiAcquireLockOrFail ( + IN EFI_LOCK *Lock + ) +{ + + ASSERT (Lock != NULL); + ASSERT (Lock->Lock != EfiLockUninitialized); + + if (Lock->Lock == EfiLockAcquired) { + // + // Lock is already owned, so bail out + // + return EFI_ACCESS_DENIED; + } + + Lock->OwnerTpl = gBS->RaiseTPL (Lock->Tpl); + + Lock->Lock = EfiLockAcquired; + + return EFI_SUCCESS; +} + +/** + This function transitions a mutual exclusion lock from the acquired state to + the released state, and restores the system's task priority level to its + previous level. + + @param Lock A pointer to the lock to release. + +**/ +VOID +EFIAPI +GlueEfiReleaseLock ( + IN EFI_LOCK *Lock + ) +{ + EFI_TPL Tpl; + + ASSERT (Lock != NULL); + ASSERT (Lock->Lock == EfiLockAcquired); + + Tpl = Lock->OwnerTpl; + + Lock->Lock = EfiLockReleased; + + gBS->RestoreTPL (Tpl); +} + +/** + Tests whether a controller handle is being managed by a specific driver. + + This function tests whether the driver specified by DriverBindingHandle is + currently managing the controller specified by ControllerHandle. This test + is performed by evaluating if the the protocol specified by ProtocolGuid is + present on ControllerHandle and is was opened by DriverBindingHandle with an + attribute of EFI_OPEN_PROTOCOL_BY_DRIVER. + If ProtocolGuid is NULL, then ASSERT(). + + @param ControllerHandle A handle for a controller to test. + @param DriverBindingHandle Specifies the driver binding handle for the + driver. + @param ProtocolGuid Specifies the protocol that the driver specified + by DriverBindingHandle opens in its Start() + function. + + @retval EFI_SUCCESS ControllerHandle is managed by the driver + specifed by DriverBindingHandle. + @retval EFI_UNSUPPORTED ControllerHandle is not managed by the driver + specifed by DriverBindingHandle. + +**/ +EFI_STATUS +EFIAPI +EfiTestManagedDevice ( + IN CONST EFI_HANDLE ControllerHandle, + IN CONST EFI_HANDLE DriverBindingHandle, + IN CONST EFI_GUID *ProtocolGuid + ) +{ + EFI_STATUS Status; + VOID *ManagedInterface; + + ASSERT (ProtocolGuid != NULL); + + Status = gBS->OpenProtocol ( + ControllerHandle, + (EFI_GUID *) ProtocolGuid, + &ManagedInterface, + DriverBindingHandle, + ControllerHandle, + EFI_OPEN_PROTOCOL_BY_DRIVER + ); + if (!EFI_ERROR (Status)) { + gBS->CloseProtocol ( + ControllerHandle, + (EFI_GUID *) ProtocolGuid, + DriverBindingHandle, + ControllerHandle + ); + return EFI_UNSUPPORTED; + } + + if (Status != EFI_ALREADY_STARTED) { + return EFI_UNSUPPORTED; + } + + return EFI_SUCCESS; +} + +/** + Tests whether a child handle is a child device of the controller. + + This function tests whether ChildHandle is one of the children of + ControllerHandle. This test is performed by checking to see if the protocol + specified by ProtocolGuid is present on ControllerHandle and opened by + ChildHandle with an attribute of EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER. + If ProtocolGuid is NULL, then ASSERT(). + + @param ControllerHandle A handle for a (parent) controller to test. + @param ChildHandle A child handle to test. + @param ConsumsedGuid Supplies the protocol that the child controller + opens on its parent controller. + + @retval EFI_SUCCESS ChildHandle is a child of the ControllerHandle. + @retval EFI_UNSUPPORTED ChildHandle is not a child of the + ControllerHandle. + +**/ +EFI_STATUS +EFIAPI +EfiTestChildHandle ( + IN CONST EFI_HANDLE ControllerHandle, + IN CONST EFI_HANDLE ChildHandle, + IN CONST EFI_GUID *ProtocolGuid + ) +{ + EFI_STATUS Status; + EFI_OPEN_PROTOCOL_INFORMATION_ENTRY *OpenInfoBuffer; + UINTN EntryCount; + UINTN Index; + + ASSERT (ProtocolGuid != NULL); + + // + // Retrieve the list of agents that are consuming the specific protocol + // on ControllerHandle. + // + Status = gBS->OpenProtocolInformation ( + ControllerHandle, + (EFI_GUID *) ProtocolGuid, + &OpenInfoBuffer, + &EntryCount + ); + if (EFI_ERROR (Status)) { + return EFI_UNSUPPORTED; + } + + // + // Inspect if ChildHandle is one of the agents. + // + Status = EFI_UNSUPPORTED; + for (Index = 0; Index < EntryCount; Index++) { + if ((OpenInfoBuffer[Index].ControllerHandle == ChildHandle) && + (OpenInfoBuffer[Index].Attributes & EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER) != 0) { + Status = EFI_SUCCESS; + break; + } + } + + FreePool (OpenInfoBuffer); + return Status; +} + +/** + Tests whether a language code has format of ISO639-2. + + @param Languages The language code to be tested. + + @retval TRUE Language code format is ISO 639-2. + @retval FALSE Language code format is not ISO639-2. + +**/ +STATIC +BOOLEAN +IsIso639LanguageCode ( + IN CONST CHAR8 *Languages + ) +{ + UINTN Index; + + // + // Find out format of Languages + // + for (Index = 0; Languages[Index] != 0 && Languages[Index] != ';' && Languages[Index] != '-'; Index++); + if (Languages[Index] != 0) { + // + // RFC4646 language code + // + return FALSE; + } + + // + // No ';' and '-', it's either ISO639-2 code (list) or single RFC4646 code + // + if (Index == 2) { + // + // Single RFC4646 language code without country code, e.g. "en" + // + return FALSE; + } + + // + // Languages in format of ISO639-2 + // + return TRUE; +} + +/** + Compare the first language instance of two language codes, either could be a + single language code or a language code list. This function assume Language1 + and Language2 has the same language code format, i.e. either ISO639-2 or RFC4646. + + @param Language1 The first language code to be tested. + @param Language2 The second language code to be tested. + + @retval TRUE Language code match. + @retval FALSE Language code mismatch. + +**/ +STATIC +BOOLEAN +CompareLanguageCode ( + IN CONST CHAR8 *Language1, + IN CONST CHAR8 *Language2 + ) +{ + UINTN Index; + + // + // Compare first two bytes of language tag + // + if ((Language1[0] != Language2[0]) || (Language1[1] != Language2[1])) { + return FALSE; + } + + if (IsIso639LanguageCode (Language1)) { + // + // ISO639-2 language code, compare the third byte of language tag + // + return (Language1[2] == Language2[2]) ? TRUE : FALSE; + } + + // + // RFC4646 language code + // + for (Index = 0; Language1[Index] != 0 && Language1[Index] != ';'; Index++); + if ((AsciiStrnCmp (Language1, Language2, Index) == 0) && (Language2[Index] == 0 || Language2[Index] == ';')) { + return TRUE; + } + + return FALSE; +} + +/** + Step to next language code of a language code list. + + @param Languages The language code list to traverse. + + @return Pointer to next language code or NULL terminator if it's the last one. + +**/ +STATIC +CONST +CHAR8 * +NextSupportedLanguage ( + IN CONST CHAR8 *Languages + ) +{ + UINTN Index; + + if (IsIso639LanguageCode (Languages)) { + // + // ISO639-2 language code + // + return (Languages + 3); + } + + // + // Search in RFC4646 language code list + // + for (Index = 0; Languages[Index] != 0 && Languages[Index] != ';'; Index++); + if (Languages[Index] == ';') { + Index++; + } + return (Languages + Index); +} + +/** + This function looks up a Unicode string in UnicodeStringTable. If Language is + a member of SupportedLanguages and a Unicode string is found in UnicodeStringTable + that matches the language code specified by Language, then it is returned in + UnicodeString. + + @param Language A pointer to the ISO 639-2 language code for the + Unicode string to look up and return. + @param SupportedLanguages A pointer to the set of ISO 639-2 language codes + that the Unicode string table supports. Language + must be a member of this set. + @param UnicodeStringTable A pointer to the table of Unicode strings. + @param UnicodeString A pointer to the Unicode string from UnicodeStringTable + that matches the language specified by Language. + + @retval EFI_SUCCESS The Unicode string that matches the language + specified by Language was found + in the table of Unicoide strings UnicodeStringTable, + and it was returned in UnicodeString. + @retval EFI_INVALID_PARAMETER Language is NULL. + @retval EFI_INVALID_PARAMETER UnicodeString is NULL. + @retval EFI_UNSUPPORTED SupportedLanguages is NULL. + @retval EFI_UNSUPPORTED UnicodeStringTable is NULL. + @retval EFI_UNSUPPORTED The language specified by Language is not a + member of SupportedLanguages. + @retval EFI_UNSUPPORTED The language specified by Language is not + supported by UnicodeStringTable. + +**/ +EFI_STATUS +EFIAPI +LookupUnicodeString ( + IN CONST CHAR8 *Language, + IN CONST CHAR8 *SupportedLanguages, + IN CONST EFI_UNICODE_STRING_TABLE *UnicodeStringTable, + OUT CHAR16 **UnicodeString + ) +{ + // + // Make sure the parameters are valid + // + if (Language == NULL || UnicodeString == NULL) { + return EFI_INVALID_PARAMETER; + } + + // + // If there are no supported languages, or the Unicode String Table is empty, then the + // Unicode String specified by Language is not supported by this Unicode String Table + // + if (SupportedLanguages == NULL || UnicodeStringTable == NULL) { + return EFI_UNSUPPORTED; + } + + // + // Make sure Language is in the set of Supported Languages + // + while (*SupportedLanguages != 0) { + if (CompareLanguageCode (Language, SupportedLanguages)) { + + // + // Search the Unicode String Table for the matching Language specifier + // + while (UnicodeStringTable->Language != NULL) { + if (CompareLanguageCode (Language, UnicodeStringTable->Language)) { + + // + // A matching string was found, so return it + // + *UnicodeString = UnicodeStringTable->UnicodeString; + return EFI_SUCCESS; + } + + UnicodeStringTable++; + } + + return EFI_UNSUPPORTED; + } + + SupportedLanguages = NextSupportedLanguage (SupportedLanguages); + } + + return EFI_UNSUPPORTED; +} + +/** + This function adds a Unicode string to UnicodeStringTable. + If Language is a member of SupportedLanguages then UnicodeString is added to + UnicodeStringTable. New buffers are allocated for both Language and + UnicodeString. The contents of Language and UnicodeString are copied into + these new buffers. These buffers are automatically freed when + FreeUnicodeStringTable() is called. + + @param Language A pointer to the ISO 639-2 language code for the Unicode + string to add. + @param SupportedLanguages A pointer to the set of ISO 639-2 language codes + that the Unicode string table supports. + Language must be a member of this set. + @param UnicodeStringTable A pointer to the table of Unicode strings. + @param UnicodeString A pointer to the Unicode string to add. + + @retval EFI_SUCCESS The Unicode string that matches the language + specified by Language was found in the table of + Unicode strings UnicodeStringTable, and it was + returned in UnicodeString. + @retval EFI_INVALID_PARAMETER Language is NULL. + @retval EFI_INVALID_PARAMETER UnicodeString is NULL. + @retval EFI_INVALID_PARAMETER UnicodeString is an empty string. + @retval EFI_UNSUPPORTED SupportedLanguages is NULL. + @retval EFI_ALREADY_STARTED A Unicode string with language Language is + already present in UnicodeStringTable. + @retval EFI_OUT_OF_RESOURCES There is not enough memory to add another + Unicode string to UnicodeStringTable. + @retval EFI_UNSUPPORTED The language specified by Language is not a + member of SupportedLanguages. + +**/ +EFI_STATUS +EFIAPI +AddUnicodeString ( + IN CONST CHAR8 *Language, + IN CONST CHAR8 *SupportedLanguages, + IN EFI_UNICODE_STRING_TABLE **UnicodeStringTable, + IN CONST CHAR16 *UnicodeString + ) +{ + UINTN NumberOfEntries; + EFI_UNICODE_STRING_TABLE *OldUnicodeStringTable; + EFI_UNICODE_STRING_TABLE *NewUnicodeStringTable; + UINTN UnicodeStringLength; + + // + // Make sure the parameter are valid + // + if (Language == NULL || UnicodeString == NULL || UnicodeStringTable == NULL) { + return EFI_INVALID_PARAMETER; + } + + // + // If there are no supported languages, then a Unicode String can not be added + // + if (SupportedLanguages == NULL) { + return EFI_UNSUPPORTED; + } + + // + // If the Unicode String is empty, then a Unicode String can not be added + // + if (UnicodeString[0] == 0) { + return EFI_INVALID_PARAMETER; + } + + // + // Make sure Language is a member of SupportedLanguages + // + while (*SupportedLanguages != 0) { + if (CompareLanguageCode (Language, SupportedLanguages)) { + + // + // Determine the size of the Unicode String Table by looking for a NULL Language entry + // + NumberOfEntries = 0; + if (*UnicodeStringTable != NULL) { + OldUnicodeStringTable = *UnicodeStringTable; + while (OldUnicodeStringTable->Language != NULL) { + if (CompareLanguageCode (Language, OldUnicodeStringTable->Language)) { + return EFI_ALREADY_STARTED; + } + + OldUnicodeStringTable++; + NumberOfEntries++; + } + } + + // + // Allocate space for a new Unicode String Table. It must hold the current number of + // entries, plus 1 entry for the new Unicode String, plus 1 entry for the end of table + // marker + // + NewUnicodeStringTable = AllocatePool ((NumberOfEntries + 2) * sizeof (EFI_UNICODE_STRING_TABLE)); + if (NewUnicodeStringTable == NULL) { + return EFI_OUT_OF_RESOURCES; + } + + // + // If the current Unicode String Table contains any entries, then copy them to the + // newly allocated Unicode String Table. + // + if (*UnicodeStringTable != NULL) { + CopyMem ( + NewUnicodeStringTable, + *UnicodeStringTable, + NumberOfEntries * sizeof (EFI_UNICODE_STRING_TABLE) + ); + } + + // + // Allocate space for a copy of the Language specifier + // + NewUnicodeStringTable[NumberOfEntries].Language = AllocateCopyPool (AsciiStrSize (Language), Language); + if (NewUnicodeStringTable[NumberOfEntries].Language == NULL) { + (gBS->FreePool) (NewUnicodeStringTable); + return EFI_OUT_OF_RESOURCES; + } + + // + // Compute the length of the Unicode String + // + for (UnicodeStringLength = 0; UnicodeString[UnicodeStringLength] != 0; UnicodeStringLength++) + ; + + // + // Allocate space for a copy of the Unicode String + // + NewUnicodeStringTable[NumberOfEntries].UnicodeString = AllocateCopyPool ( + (UnicodeStringLength + 1) * sizeof (CHAR16), + UnicodeString + ); + if (NewUnicodeStringTable[NumberOfEntries].UnicodeString == NULL) { + (gBS->FreePool) (NewUnicodeStringTable[NumberOfEntries].Language); + (gBS->FreePool) (NewUnicodeStringTable); + return EFI_OUT_OF_RESOURCES; + } + + // + // Mark the end of the Unicode String Table + // + NewUnicodeStringTable[NumberOfEntries + 1].Language = NULL; + NewUnicodeStringTable[NumberOfEntries + 1].UnicodeString = NULL; + + // + // Free the old Unicode String Table + // + if (*UnicodeStringTable != NULL) { + (gBS->FreePool) (*UnicodeStringTable); + } + + // + // Point UnicodeStringTable at the newly allocated Unicode String Table + // + *UnicodeStringTable = NewUnicodeStringTable; + + return EFI_SUCCESS; + } + + SupportedLanguages = NextSupportedLanguage (SupportedLanguages); + } + + return EFI_UNSUPPORTED; +} + +/** + This function frees the table of Unicode strings in UnicodeStringTable. + If UnicodeStringTable is NULL, then EFI_SUCCESS is returned. + Otherwise, each language code, and each Unicode string in the Unicode string + table are freed, and EFI_SUCCESS is returned. + + @param UnicodeStringTable A pointer to the table of Unicode strings. + + @retval EFI_SUCCESS The Unicode string table was freed. + +**/ +EFI_STATUS +EFIAPI +FreeUnicodeStringTable ( + IN EFI_UNICODE_STRING_TABLE *UnicodeStringTable + ) +{ + UINTN Index; + + // + // If the Unicode String Table is NULL, then it is already freed + // + if (UnicodeStringTable == NULL) { + return EFI_SUCCESS; + } + + // + // Loop through the Unicode String Table until we reach the end of table marker + // + for (Index = 0; UnicodeStringTable[Index].Language != NULL; Index++) { + + // + // Free the Language string from the Unicode String Table + // + (gBS->FreePool) (UnicodeStringTable[Index].Language); + + // + // Free the Unicode String from the Unicode String Table + // + if (UnicodeStringTable[Index].UnicodeString != NULL) { + (gBS->FreePool) (UnicodeStringTable[Index].UnicodeString); + } + } + + // + // Free the Unicode String Table itself + // + (gBS->FreePool) (UnicodeStringTable); + + return EFI_SUCCESS; +} + +/** + This function retrievesGUID name from Image Handle + + @param EFI_HANDLE Image Handle. + + @retval EFI_GUID* pointer to EFI_GUID. + +**/ +EFI_GUID * +GetGuidFromHandle ( + EFI_HANDLE Handle + ) +{ + EFI_STATUS Status; + EFI_LOADED_IMAGE_PROTOCOL *pImage; + MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvFilePath; + + if (Handle != NULL) { + Status = gBS->HandleProtocol ( + Handle, + &gEfiLoadedImageProtocolGuid, + &pImage + ); + if (!EFI_ERROR (Status)) { + if (pImage->FilePath->Type == MEDIA_DEVICE_PATH && pImage->FilePath->SubType == MEDIA_FV_FILEPATH_DP) { + // + // Determine GUID + // + FvFilePath = (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *) pImage->FilePath; + + return &FvFilePath->NameGuid; + } + } + } + + return NULL; +} diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiLib/UefiLib.inf b/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiLib/UefiLib.inf new file mode 100644 index 0000000..8ee38ac --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiLib/UefiLib.inf @@ -0,0 +1,87 @@ +#/*++ +# +# 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: +# +# UefiLib.inf +# +# Abstract: +# +# Component description file for UefiLib. +# +#--*/ + +[defines] +BASE_NAME = EdkIIGlueUefiLib +COMPONENT_TYPE = LIBRARY + +[sources.common] + UefiLib.c + Console.c + UefiNotTiano.c + +[sources.ia32] + +[sources.x64] + +[sources.ipf] + +[sources.ebc] + + +[includes.common] + . + ..\..\Include + ..\..\include\Library + $(EDK_SOURCE)\Foundation + $(EDK_SOURCE)\Foundation\Framework + $(EDK_SOURCE)\Foundation\Efi + $(EDK_SOURCE)\Foundation\Include + $(EDK_SOURCE)\Foundation\Efi\Include + $(EDK_SOURCE)\Foundation\Framework\Include + $(EDK_SOURCE)\Foundation\Include\IndustryStandard + $(EDK_SOURCE)\Foundation\Core\Dxe + $(EDK_SOURCE)\Foundation\Library\Dxe\Include + $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include + + $(EDK_SOURCE)\Foundation\Efi\Protocol\DevicePath + +[libraries.common] + EdkIIGlueBaseLib + EdkIIGlueBaseMemoryLib + EdkIIGlueUefiBootServicesTableLib +# +# MemoryAllocationLib instance +# + EdkIIGlueDxeMemoryAllocationLib + EfiGuidLib + +[libraries.ia32] + + +[libraries.x64] + + +[nmake.common] + C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION + LIB_STD_FLAGS = /NOLOGO /IGNORE:4006 + +[nmake.ia32] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32 + +[nmake.x64] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64 + +[nmake.ipf] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF + +[nmake.ebc] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_EBC
\ No newline at end of file diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiLib/UefiNotTiano.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiLib/UefiNotTiano.c new file mode 100644 index 0000000..67438ed --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiLib/UefiNotTiano.c @@ -0,0 +1,366 @@ +/*++ + +Copyright (c) 2004 - 2009, 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: + + UefiNotTiano.c + +Abstract: + + Library functions that abstract areas of conflict between Tiano an UEFI 2.0. + + Help Port Framework/Tinao code that has conflicts with UEFI 2.0 by hiding the + oldconflicts with library functions and supporting implementations of the old + (R8.5/EFI 1.10) and new (EdkII/UEFI 2.0) way. + +--*/ + +#include "EdkIIGlueUefi.h" + +/** + An empty function to pass error checking of CreateEventEx (). + + This empty function ensures that EFI_EVENT_NOTIFY_SIGNAL_ALL is error + checked correctly since it is now mapped into CreateEventEx() in UEFI 2.0. + +**/ +STATIC +VOID +EFIAPI +InternalEmptyFuntion ( + IN EFI_EVENT Event, + IN VOID *Context + ) +{ + return; +} + +/** + 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 EDK/EFI 1.10 form and EDK II/UEFI 2.0 form and allows common code to + work both ways. + + @param LegacyBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex). + + @retval EFI_SUCCESS Event was created. + @retval Other Event was not created. + +**/ +EFI_STATUS +EFIAPI +GlueEfiCreateEventLegacyBoot ( + OUT EFI_EVENT *LegacyBootEvent + ) +{ + return EfiCreateEventLegacyBootEx ( + EFI_TPL_CALLBACK, + NULL, + NULL, + LegacyBootEvent + ); +} + +/** + Create an EFI event in the Legacy Boot Event Group and allows + the caller to specify a notification function. + + This function abstracts the creation of the Legacy Boot Event. + The Framework moved from a proprietary to UEFI 2.0 based mechanism. + This library abstracts the caller from how this event is created to prevent + to code form having to change with the version of the specification supported. + If LegacyBootEvent is NULL, then ASSERT(). + + @param NotifyTpl The task priority level of the event. + @param NotifyFunction The notification function to call when the event is signaled. + @param NotifyContext The content to pass to NotifyFunction when the event is signaled. + @param LegacyBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex). + + @retval EFI_SUCCESS Event was created. + @retval Other Event was not created. + +**/ +EFI_STATUS +EFIAPI +EfiCreateEventLegacyBootEx ( + IN EFI_TPL NotifyTpl, + IN EFI_EVENT_NOTIFY NotifyFunction, OPTIONAL + IN VOID *NotifyContext, OPTIONAL + OUT EFI_EVENT *LegacyBootEvent + ) +{ + EFI_STATUS Status; + UINT32 EventType; + EFI_EVENT_NOTIFY WorkerNotifyFunction; + + ASSERT (LegacyBootEvent != NULL); + +#if (EFI_SPECIFICATION_VERSION < 0x00020000) + + if (NotifyFunction == NULL) { + EventType = EFI_EVENT_SIGNAL_LEGACY_BOOT | EFI_EVENT_NOTIFY_SIGNAL_ALL; + } else { + EventType = EFI_EVENT_SIGNAL_LEGACY_BOOT; + } + WorkerNotifyFunction = NotifyFunction; + + // + // prior to UEFI 2.0 use Tiano extension to EFI + // + Status = gBS->CreateEvent ( + EventType, + NotifyTpl, + WorkerNotifyFunction, + NotifyContext, + LegacyBootEvent + ); +#else + + EventType = EVENT_NOTIFY_SIGNAL; + if (NotifyFunction == NULL) { + // + // CreatEventEx will check NotifyFunction is NULL or not + // + WorkerNotifyFunction = InternalEmptyFuntion; + } else { + WorkerNotifyFunction = NotifyFunction; + } + + // + // For UEFI 2.0 and the future use an Event Group + // + Status = gBS->CreateEventEx ( + EventType, + NotifyTpl, + WorkerNotifyFunction, + NotifyContext, + &gEfiEventLegacyBootGuid, + LegacyBootEvent + ); +#endif + + return Status; +} + +/** + 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 EDK/EFI 1.10 form and EDK II/UEFI 2.0 form and allows common code to + work both ways. + + @param LegacyBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex). + + @retval EFI_SUCCESS Event was created. + @retval Other Event was not created. + +**/ +EFI_STATUS +EFIAPI +GlueEfiCreateEventReadyToBoot ( + OUT EFI_EVENT *ReadyToBootEvent + ) +{ + return EfiCreateEventReadyToBootEx ( + EFI_TPL_CALLBACK, + NULL, + NULL, + ReadyToBootEvent + ); +} + +/** + Create an EFI event in the Ready To Boot Event Group and allows + the caller to specify a notification function. + + This function abstracts the creation of the Ready to Boot Event. + The Framework moved from a proprietary to UEFI 2.0 based mechanism. + This library abstracts the caller from how this event is created to prevent + to code form having to change with the version of the specification supported. + If ReadyToBootEvent is NULL, then ASSERT(). + + @param NotifyTpl The task priority level of the event. + @param NotifyFunction The notification function to call when the event is signaled. + @param NotifyContext The content to pass to NotifyFunction when the event is signaled. + @param LegacyBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex). + + @retval EFI_SUCCESS Event was created. + @retval Other Event was not created. + +**/ +EFI_STATUS +EFIAPI +EfiCreateEventReadyToBootEx ( + IN EFI_TPL NotifyTpl, + IN EFI_EVENT_NOTIFY NotifyFunction, OPTIONAL + IN VOID *NotifyContext, OPTIONAL + OUT EFI_EVENT *ReadyToBootEvent + ) +{ + EFI_STATUS Status; + UINT32 EventType; + EFI_EVENT_NOTIFY WorkerNotifyFunction; + + ASSERT (ReadyToBootEvent != NULL); + +#if (EFI_SPECIFICATION_VERSION < 0x00020000) + + if (NotifyFunction == NULL) { + EventType = EFI_EVENT_SIGNAL_READY_TO_BOOT | EFI_EVENT_NOTIFY_SIGNAL_ALL; + } else { + EventType = EFI_EVENT_SIGNAL_READY_TO_BOOT; + } + WorkerNotifyFunction = NotifyFunction; + + // + // prior to UEFI 2.0 use Tiano extension to EFI + // + Status = gBS->CreateEvent ( + EventType, + NotifyTpl, + WorkerNotifyFunction, + NotifyContext, + ReadyToBootEvent + ); +#else + + EventType = EVENT_NOTIFY_SIGNAL; + + if (NotifyFunction == NULL) { + // + // CreatEventEx will check NotifyFunction is NULL or not + // + WorkerNotifyFunction = InternalEmptyFuntion; + } else { + WorkerNotifyFunction = NotifyFunction; + } + + // + // For UEFI 2.0 and the future use an Event Group + // + Status = gBS->CreateEventEx ( + EventType, + NotifyTpl, + WorkerNotifyFunction, + NotifyContext, + &gEfiEventReadyToBootGuid, + ReadyToBootEvent + ); +#endif + + return Status; +} + + +/** + Signal a Ready to Boot Event. + + Create a Ready to Boot Event. Signal it and close it. This causes other + events of the same event group to be signaled in other modules. + +**/ +VOID +EFIAPI +EfiSignalEventReadyToBoot ( + VOID + ) +{ + EFI_STATUS Status; + EFI_EVENT ReadyToBootEvent; + + Status = EfiCreateEventReadyToBoot (&ReadyToBootEvent); + if (!EFI_ERROR (Status)) { + gBS->SignalEvent (ReadyToBootEvent); + gBS->CloseEvent (ReadyToBootEvent); + } +} + +/** + Signal a Legacy Boot Event. + + Create a legacy Boot Event. Signal it and close it. This causes other + events of the same event group to be signaled in other modules. + +**/ +VOID +EFIAPI +EfiSignalEventLegacyBoot ( + VOID + ) +{ + EFI_STATUS Status; + EFI_EVENT LegacyBootEvent; + + Status = EfiCreateEventLegacyBoot (&LegacyBootEvent); + if (!EFI_ERROR (Status)) { + gBS->SignalEvent (LegacyBootEvent); + gBS->CloseEvent (LegacyBootEvent); + } +} + + +/** + Check to see if the Firmware Volume (FV) Media Device Path is valid + + @param FvDevicePathNode Pointer to FV device path to check. + + @retval NULL FvDevicePathNode is not valid. + @retval Other FvDevicePathNode is valid and pointer to NameGuid was returned. + +**/ +EFI_GUID * +EFIAPI +GlueEfiGetNameGuidFromFwVolDevicePathNode ( + IN CONST MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvDevicePathNode + ) +{ + ASSERT (FvDevicePathNode != NULL); + + if (DevicePathType (&FvDevicePathNode->Header) == MEDIA_DEVICE_PATH && + DevicePathSubType (&FvDevicePathNode->Header) == MEDIA_FV_FILEPATH_DP) { + return (EFI_GUID *) &FvDevicePathNode->NameGuid; + } + + return NULL; +} + + +/** + Initialize a Firmware Volume (FV) Media Device Path node. + + @param FvDevicePathNode Pointer to a FV device path node to initialize + @param NameGuid FV file name to use in FvDevicePathNode + +**/ +VOID +EFIAPI +GlueEfiInitializeFwVolDevicepathNode ( + IN OUT MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvDevicePathNode, + IN CONST EFI_GUID *NameGuid + ) +{ + ASSERT (FvDevicePathNode != NULL); + ASSERT (NameGuid != NULL); + + FvDevicePathNode->Header.Type = MEDIA_DEVICE_PATH; + FvDevicePathNode->Header.SubType = MEDIA_FV_FILEPATH_DP; + SetDevicePathNodeLength (&FvDevicePathNode->Header, sizeof (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH)); + + CopyGuid (&FvDevicePathNode->NameGuid, NameGuid); +} + diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiRuntimeServicesTableLib/EdkIIGlueUefiRuntimeServicesTableLib.cif b/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiRuntimeServicesTableLib/EdkIIGlueUefiRuntimeServicesTableLib.cif new file mode 100644 index 0000000..96af27f --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiRuntimeServicesTableLib/EdkIIGlueUefiRuntimeServicesTableLib.cif @@ -0,0 +1,11 @@ +<component> + name = "EdkIIGlueUefiRuntimeServicesTableLib" + category = ModulePart + LocalRoot = "Edk\Foundation\Library\EdkIIGlueLib\Library\UefiRuntimeServicesTableLib" + RefName = "EdkIIGlueUefiRuntimeServicesTableLib" +[files] +"EdkIIGlueUefiRuntimeServicesTableLib.sdl" +"EdkIIGlueUefiRuntimeServicesTableLib.mak" +"UefiRuntimeServicesTableLib.inf" +"UefiRuntimeServicesTableLib.c" +<endComponent> diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiRuntimeServicesTableLib/EdkIIGlueUefiRuntimeServicesTableLib.mak b/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiRuntimeServicesTableLib/EdkIIGlueUefiRuntimeServicesTableLib.mak new file mode 100644 index 0000000..6f35ac8 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiRuntimeServicesTableLib/EdkIIGlueUefiRuntimeServicesTableLib.mak @@ -0,0 +1,80 @@ +#********************************************************************** +#********************************************************************** +#** ** +#** (C)Copyright 1985-2009, American Megatrends, Inc. ** +#** ** +#** All Rights Reserved. ** +#** ** +#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +#** ** +#** Phone: (770)-246-8600 ** +#** ** +#********************************************************************** +#********************************************************************** + +#********************************************************************** +# $Header: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGlueUefiRuntimeServicesTableLib/EdkIIGlueUefiRuntimeServicesTableLib.mak 1 1/20/12 3:58a Jeffch $ +# +# $Revision: 1 $ +# +# $Date: 1/20/12 3:58a $ +#********************************************************************** +# Revision History +# ---------------- +# $Log: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGlueUefiRuntimeServicesTableLib/EdkIIGlueUefiRuntimeServicesTableLib.mak $ +# +# 1 1/20/12 3:58a Jeffch +# Create Intel EDK 1117 Patch 7. +# +# 1 9/27/11 6:20a Wesleychen +# Intel EDK initially releases. +# +# 1 9/18/09 1:59a Iminglin +# +#********************************************************************** +#<AMI_FHDR_START> +# +# Name: EdkIIGlueUefiRuntimeServicesTableLib.mak +# +# Description: +# +#<AMI_FHDR_END> +#********************************************************************** + + +$(EdkIIGlueUefiRuntimeServicesTableLib_LIB) : EdkIIGlueUefiRuntimeServicesTableLib + +EdkIIGlueUefiRuntimeServicesTableLib : $(BUILD_DIR)\EdkIIGlueUefiRuntimeServicesTableLib.mak EdkIIGlueUefiRuntimeServicesTableLibBin + +$(BUILD_DIR)\EdkIIGlueUefiRuntimeServicesTableLib.mak : $(EdkIIGlueUefiRuntimeServicesTableLib_DIR)\$(@B).cif $(EdkIIGlueUefiRuntimeServicesTableLib_DIR)\$(@B).mak $(BUILD_RULES) + $(CIF2MAK) $(EdkIIGlueUefiRuntimeServicesTableLib_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS) + +EdkIIGlueUefiRuntimeServicesTableLibBin : +!IF "$(x64_BUILD)"=="1" + $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\ + BUILD_DIR=$(BUILD_DIR)\ + /f $(BUILD_DIR)\EdkIIGlueUefiRuntimeServicesTableLib.mak all\ + TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueUefiRuntimeServicesTableLib_LIB)" + $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\ + BUILD_DIR=$(BUILD_DIR)\IA32\ + /f $(BUILD_DIR)\EdkIIGlueUefiRuntimeServicesTableLib.mak all\ + TYPE=PEI_LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueUefiRuntimeServicesTableLib_LIB)" +!ELSE + $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\ + BUILD_DIR=$(BUILD_DIR)\ + /f $(BUILD_DIR)\EdkIIGlueUefiRuntimeServicesTableLib.mak all\ + TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueUefiRuntimeServicesTableLib_LIB)" +!ENDIF +#********************************************************************** +#********************************************************************** +#** ** +#** (C)Copyright 1985-2009, American Megatrends, Inc. ** +#** ** +#** All Rights Reserved. ** +#** ** +#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +#** ** +#** Phone: (770)-246-8600 ** +#** ** +#********************************************************************** +#**********************************************************************
\ No newline at end of file diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiRuntimeServicesTableLib/EdkIIGlueUefiRuntimeServicesTableLib.sdl b/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiRuntimeServicesTableLib/EdkIIGlueUefiRuntimeServicesTableLib.sdl new file mode 100644 index 0000000..581b351 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiRuntimeServicesTableLib/EdkIIGlueUefiRuntimeServicesTableLib.sdl @@ -0,0 +1,26 @@ +TOKEN + Name = "EdkIIGlueUefiRuntimeServicesTableLib_SUPPORT" + Value = "1" + Help = "Main switch to enable EdkIIGlueUefiRuntimeServicesTableLib support in Project" + TokenType = Boolean + TargetEQU = Yes + TargetMAK = Yes + Master = Yes +End + +TOKEN + Name = "EdkIIGlueUefiRuntimeServicesTableLib_LIB" + Value = "$$(LIB_BUILD_DIR)\EdkIIGlueUefiRuntimeServicesTableLib.lib" + TokenType = Expression + TargetMAK = Yes +End + +PATH + Name = "EdkIIGlueUefiRuntimeServicesTableLib_DIR" +End + +MODULE + Help = "Includes EdkIIGlueUefiRuntimeServicesTableLib.mak to Project" + File = "EdkIIGlueUefiRuntimeServicesTableLib.mak" +End + diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiRuntimeServicesTableLib/UefiRuntimeServicesTableLib.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiRuntimeServicesTableLib/UefiRuntimeServicesTableLib.c new file mode 100644 index 0000000..f6abed4 --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiRuntimeServicesTableLib/UefiRuntimeServicesTableLib.c @@ -0,0 +1,52 @@ +/*++ + +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: + + UefiRuntimeServicesTableLib.c + +Abstract: + + UEFI Runtime Services Table Library. + +--*/ + +#include "EdkIIGlueUefi.h" + +EFI_RUNTIME_SERVICES *gRT = NULL; + +/** + The constructor function caches the pointer of Runtime Services Table. + + The constructor function caches the pointer of Runtime Services Table. + It will ASSERT() if the pointer of Runtime Services Table is NULL. + It will always return EFI_SUCCESS. + + @param ImageHandle The firmware allocated handle for the EFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS. + +**/ +EFI_STATUS +UefiRuntimeServicesTableLibConstructor ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + // + // Cache pointer to the EFI Runtime Services Table + // + gRT = SystemTable->RuntimeServices; + ASSERT (gRT != NULL); + return EFI_SUCCESS; +} diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiRuntimeServicesTableLib/UefiRuntimeServicesTableLib.inf b/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiRuntimeServicesTableLib/UefiRuntimeServicesTableLib.inf new file mode 100644 index 0000000..f7850bd --- /dev/null +++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiRuntimeServicesTableLib/UefiRuntimeServicesTableLib.inf @@ -0,0 +1,76 @@ +#/*++ +# +# 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: +# +# UefiRuntimeServicesTableLib.inf +# +# Abstract: +# +# Component description file for UefiRuntimeServicesTableLib. +# +#--*/ + +[defines] +BASE_NAME = EdkIIGlueUefiRuntimeServicesTableLib +COMPONENT_TYPE = LIBRARY + +[sources.common] + UefiRuntimeServicesTableLib.c + +[sources.ia32] + +[sources.x64] + +[sources.ipf] + +[sources.ebc] + + +[includes.common] + . + ..\..\Include + ..\..\include\Library + $(EDK_SOURCE)\Foundation + $(EDK_SOURCE)\Foundation\Framework + $(EDK_SOURCE)\Foundation\Efi + $(EDK_SOURCE)\Foundation\Include + $(EDK_SOURCE)\Foundation\Efi\Include + $(EDK_SOURCE)\Foundation\Framework\Include + $(EDK_SOURCE)\Foundation\Include\IndustryStandard + $(EDK_SOURCE)\Foundation\Core\Dxe + $(EDK_SOURCE)\Foundation\Library\Dxe\Include + $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include + $(EDK_SOURCE)\Foundation\Efi\Protocol\DevicePath + +[libraries.common] + +[libraries.ia32] + + +[libraries.x64] + + +[nmake.common] + C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION + LIB_STD_FLAGS = /NOLOGO /IGNORE:4006 + +[nmake.ia32] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32 + +[nmake.x64] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64 + +[nmake.ipf] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF + +[nmake.ebc] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_EBC
\ No newline at end of file |