From 9730cac8a1f5d205b1e7472bfc692a7f8f2aff7b Mon Sep 17 00:00:00 2001 From: mdkinney Date: Wed, 4 Oct 2006 23:50:23 +0000 Subject: [PATCH] Use intrinsic git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@1669 6f19259b-4bc3-4df7-8a09-765794883524 --- .../X64/InterlockedCompareExchange32.c | 40 +++++++++++++++++++ .../X64/InterlockedCompareExchange64.c | 39 ++++++++++++++++++ .../BaseLib/X64/InterlockedDecrement.c | 35 ++++++++++++++++ .../BaseLib/X64/InterlockedIncrement.c | 35 ++++++++++++++++ MdePkg/Library/BaseLib/X64/ReadMsr64.c | 34 ++++++++++++++++ MdePkg/Library/BaseLib/X64/WriteMsr64.c | 35 ++++++++++++++++ 6 files changed, 218 insertions(+) create mode 100644 MdePkg/Library/BaseLib/X64/InterlockedCompareExchange32.c create mode 100644 MdePkg/Library/BaseLib/X64/InterlockedCompareExchange64.c create mode 100644 MdePkg/Library/BaseLib/X64/InterlockedDecrement.c create mode 100644 MdePkg/Library/BaseLib/X64/InterlockedIncrement.c create mode 100644 MdePkg/Library/BaseLib/X64/ReadMsr64.c create mode 100644 MdePkg/Library/BaseLib/X64/WriteMsr64.c diff --git a/MdePkg/Library/BaseLib/X64/InterlockedCompareExchange32.c b/MdePkg/Library/BaseLib/X64/InterlockedCompareExchange32.c new file mode 100644 index 0000000000..c8857dbca5 --- /dev/null +++ b/MdePkg/Library/BaseLib/X64/InterlockedCompareExchange32.c @@ -0,0 +1,40 @@ +/** @file + InterlockedCompareExchange32 function + + 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. + +**/ + +#if _MSC_EXTENSIONS + +// +// Microsoft Visual Studio 7.1 Function Prototypes for I/O Intrinsics +// +long _InterlockedCompareExchange( + long volatile * Destination, + long Exchange, + long Comperand +); + +#pragma intrinsic(_InterlockedCompareExchange) + +UINT32 +EFIAPI +InternalSyncCompareExchange32 ( + IN UINT32 *Value, + IN UINT32 CompareValue, + IN UINT32 ExchangeValue + ) +{ + return _InterlockedCompareExchange (Value, ExchangeValue, CompareValue); +} + + +#endif diff --git a/MdePkg/Library/BaseLib/X64/InterlockedCompareExchange64.c b/MdePkg/Library/BaseLib/X64/InterlockedCompareExchange64.c new file mode 100644 index 0000000000..8cd90b393b --- /dev/null +++ b/MdePkg/Library/BaseLib/X64/InterlockedCompareExchange64.c @@ -0,0 +1,39 @@ +/** @file + InterlockedCompareExchange64 function + + 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. + +**/ + +#if _MSC_EXTENSIONS + +// +// Microsoft Visual Studio 7.1 Function Prototypes for I/O Intrinsics +// +__int64 _InterlockedCompareExchange64( + __int64 volatile * Destination, + __int64 Exchange, + __int64 Comperand +); + +#pragma intrinsic(_InterlockedCompareExchange64) + +UINT64 +EFIAPI +InternalSyncCompareExchange64 ( + IN UINT64 *Value, + IN UINT64 CompareValue, + IN UINT64 ExchangeValue + ) +{ + return _InterlockedCompareExchange64 (Value, ExchangeValue, CompareValue); +} + +#endif diff --git a/MdePkg/Library/BaseLib/X64/InterlockedDecrement.c b/MdePkg/Library/BaseLib/X64/InterlockedDecrement.c new file mode 100644 index 0000000000..bc171a79cc --- /dev/null +++ b/MdePkg/Library/BaseLib/X64/InterlockedDecrement.c @@ -0,0 +1,35 @@ +/** @file + InterlockedDecrement function + + 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. + +**/ + +#if _MSC_EXTENSIONS + +// +// Microsoft Visual Studio 7.1 Function Prototypes for I/O Intrinsics +// +long _InterlockedDecrement( + long * lpAddend +); + +#pragma intrinsic(_InterlockedDecrement) + +UINT32 +EFIAPI +InternalSyncDecrement ( + IN UINT32 *Value + ) +{ + return _InterlockedDecrement (Value); +} + +#endif diff --git a/MdePkg/Library/BaseLib/X64/InterlockedIncrement.c b/MdePkg/Library/BaseLib/X64/InterlockedIncrement.c new file mode 100644 index 0000000000..b5651bc003 --- /dev/null +++ b/MdePkg/Library/BaseLib/X64/InterlockedIncrement.c @@ -0,0 +1,35 @@ +/** @file + InterLockedIncrement function + + 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. + +**/ + +#if _MSC_EXTENSIONS + +// +// Microsoft Visual Studio 7.1 Function Prototypes for I/O Intrinsics +// +long _InterlockedIncrement( + long * lpAddend +); + +#pragma intrinsic(_InterlockedIncrement) + +UINT32 +EFIAPI +InternalSyncIncrement ( + IN UINT32 *Value + ) +{ + return _InterlockedIncrement (Value); +} + +#endif diff --git a/MdePkg/Library/BaseLib/X64/ReadMsr64.c b/MdePkg/Library/BaseLib/X64/ReadMsr64.c new file mode 100644 index 0000000000..b1fdff97c0 --- /dev/null +++ b/MdePkg/Library/BaseLib/X64/ReadMsr64.c @@ -0,0 +1,34 @@ +/** @file + CpuBreakpoint function. + + 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. + +**/ + +#if _MSC_EXTENSIONS + +// +// Microsoft Visual Studio 7.1 Function Prototypes for I/O Intrinsics +// +unsigned __int64 __readmsr (int register); + +#pragma intrinsic(__readmsr) + + +UINT64 +EFIAPI +AsmReadMsr64 ( + IN UINT32 Index + ) +{ + return __readmsr (Index); +} + +#endif diff --git a/MdePkg/Library/BaseLib/X64/WriteMsr64.c b/MdePkg/Library/BaseLib/X64/WriteMsr64.c new file mode 100644 index 0000000000..8e5d90fec4 --- /dev/null +++ b/MdePkg/Library/BaseLib/X64/WriteMsr64.c @@ -0,0 +1,35 @@ +/** @file + CpuBreakpoint function. + + 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. + +**/ + +#if _MSC_EXTENSIONS + +// +// Microsoft Visual Studio 7.1 Function Prototypes for I/O Intrinsics +// +void __writemsr (unsigned long Register, unsigned __int64 Value); + +#pragma intrinsic(__writemsr) + +UINT64 +EFIAPI +AsmWriteMsr64 ( + IN UINT32 Index, + IN UINT64 Value + ) +{ + __writemsr (Index, Value); + return Value; +} + +#endif