+++ /dev/null
-/** @file\r
- Implementation of synchronization functions on EBC.\r
-\r
- Copyright (c) 2006 - 2008, Intel Corporation<BR>\r
- All rights reserved. This program and the accompanying materials\r
- are licensed and made available under the terms and conditions of the BSD License\r
- which accompanies this distribution. The full text of the license may be found at\r
- http://opensource.org/licenses/bsd-license.php\r
-\r
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-**/\r
-\r
-/**\r
- Performs an atomic compare exchange operation on a 32-bit\r
- unsigned integer.\r
-\r
- Performs an atomic compare exchange operation on the 32-bit\r
- unsigned integer specified by Value. If Value is equal to\r
- CompareValue, then Value is set to ExchangeValue and\r
- CompareValue is returned. If Value is not equal to\r
- CompareValue, then Value is returned. The compare exchange\r
- operation must be performed using MP safe mechanisms.\r
-\r
- @param Value A pointer to the 32-bit value for the\r
- compare exchange operation.\r
- @param CompareValue 32-bit value used in compare operation.\r
- @param ExchangeValue 32-bit value used in exchange operation.\r
-\r
- @return The original *Value before exchange.\r
-\r
-**/\r
-UINT32\r
-EFIAPI\r
-InternalSyncCompareExchange32 (\r
- IN volatile UINT32 *Value,\r
- IN UINT32 CompareValue,\r
- IN UINT32 ExchangeValue\r
- )\r
-{\r
- return *Value != CompareValue ? *Value :\r
- ((*Value = ExchangeValue), CompareValue);\r
-}\r
-\r
-/**\r
- Performs an atomic compare exchange operation on a 64-bit unsigned integer.\r
-\r
- Performs an atomic compare exchange operation on the 64-bit unsigned integer specified \r
- by Value. If Value is equal to CompareValue, then Value is set to ExchangeValue and \r
- CompareValue is returned. If Value is not equal to CompareValue, then Value is returned. \r
- The compare exchange operation must be performed using MP safe mechanisms.\r
-\r
- @param Value A pointer to the 64-bit value for the compare exchange\r
- operation.\r
- @param CompareValue 64-bit value used in compare operation.\r
- @param ExchangeValue 64-bit value used in exchange operation.\r
-\r
- @return The original *Value before exchange.\r
-\r
-**/\r
-UINT64\r
-EFIAPI\r
-InternalSyncCompareExchange64 (\r
- IN volatile UINT64 *Value,\r
- IN UINT64 CompareValue,\r
- IN UINT64 ExchangeValue\r
- )\r
-{\r
- return *Value != CompareValue ? *Value :\r
- ((*Value = ExchangeValue), CompareValue);\r
-}\r
-\r
-/**\r
- Performs an atomic increment of an 32-bit unsigned integer.\r
-\r
- Performs an atomic increment of the 32-bit unsigned integer specified by\r
- Value and returns the incremented value. The increment operation must be\r
- performed using MP safe mechanisms. The state of the return value is not\r
- guaranteed to be MP safe.\r
-\r
- @param Value A pointer to the 32-bit value to increment.\r
-\r
- @return The incremented value.\r
-\r
-**/\r
-UINT32\r
-EFIAPI\r
-InternalSyncIncrement (\r
- IN volatile UINT32 *Value\r
- )\r
-{\r
- return ++*Value;\r
-}\r
-\r
-/**\r
- Performs an atomic decrement of an 32-bit unsigned integer.\r
-\r
- Performs an atomic decrement of the 32-bit unsigned integer specified by\r
- Value and returns the decrement value. The decrement operation must be\r
- performed using MP safe mechanisms. The state of the return value is not\r
- guaranteed to be MP safe.\r
-\r
- @param Value A pointer to the 32-bit value to decrement.\r
-\r
- @return The decrement value.\r
-\r
-**/\r
-UINT32\r
-EFIAPI\r
-InternalSyncDecrement (\r
- IN volatile UINT32 *Value\r
- )\r
-{\r
- return --*Value;\r
-}\r
+++ /dev/null
-#------------------------------------------------------------------------------\r
-#\r
-# Copyright (c) 2006 - 2008, Intel Corporation\r
-# All rights reserved. This program and the accompanying materials\r
-# are licensed and made available under the terms and conditions of the BSD License\r
-# which accompanies this distribution. The full text of the license may be found at\r
-# http://opensource.org/licenses/bsd-license.php\r
-#\r
-# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-#\r
-# Module Name:\r
-#\r
-# InterlockedCompareExchange32.S\r
-#\r
-# Abstract:\r
-#\r
-# InternalSyncCompareExchange32 function\r
-#\r
-# Notes:\r
-#\r
-#------------------------------------------------------------------------------\r
-\r
-.globl ASM_PFX(InternalSyncCompareExchange32)\r
-\r
-#------------------------------------------------------------------------------\r
-# UINT32\r
-# EFIAPI\r
-# InternalSyncCompareExchange32 (\r
-# IN UINT32 *Value,\r
-# IN UINT32 CompareValue,\r
-# IN UINT32 ExchangeValue\r
-# );\r
-#------------------------------------------------------------------------------\r
-ASM_PFX(InternalSyncCompareExchange32):\r
- movl 4(%esp), %ecx\r
- movl 8(%esp), %eax\r
- movl 12(%esp), %edx\r
- lock\r
- cmpxchgl %edx, (%ecx)\r
- ret\r
+++ /dev/null
-;------------------------------------------------------------------------------\r
-;\r
-; Copyright (c) 2006, Intel Corporation\r
-; All rights reserved. This program and the accompanying materials\r
-; are licensed and made available under the terms and conditions of the BSD License\r
-; which accompanies this distribution. The full text of the license may be found at\r
-; http://opensource.org/licenses/bsd-license.php\r
-;\r
-; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-;\r
-; Module Name:\r
-;\r
-; InterlockedCompareExchange32.Asm\r
-;\r
-; Abstract:\r
-;\r
-; InterlockedCompareExchange32 function\r
-;\r
-; Notes:\r
-;\r
-;------------------------------------------------------------------------------\r
-\r
- .486\r
- .model flat,C\r
- .code\r
-\r
-;------------------------------------------------------------------------------\r
-; UINT32\r
-; EFIAPI\r
-; InternalSyncCompareExchange32 (\r
-; IN UINT32 *Value,\r
-; IN UINT32 CompareValue,\r
-; IN UINT32 ExchangeValue\r
-; );\r
-;------------------------------------------------------------------------------\r
-InternalSyncCompareExchange32 PROC\r
- mov ecx, [esp + 4]\r
- mov eax, [esp + 8]\r
- mov edx, [esp + 12]\r
- lock cmpxchg [ecx], edx\r
- ret\r
-InternalSyncCompareExchange32 ENDP\r
-\r
- END\r
+++ /dev/null
-/** @file\r
- InterlockedCompareExchange32 function\r
-\r
- Copyright (c) 2006 - 2008, Intel Corporation<BR>\r
- All rights reserved. This program and the accompanying materials\r
- are licensed and made available under the terms and conditions of the BSD License\r
- which accompanies this distribution. The full text of the license may be found at\r
- http://opensource.org/licenses/bsd-license.php\r
-\r
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-**/\r
-\r
-\r
-\r
-\r
-/**\r
- Performs an atomic compare exchange operation on a 32-bit unsigned integer.\r
-\r
- Performs an atomic compare exchange operation on the 32-bit unsigned integer\r
- specified by Value. If Value is equal to CompareValue, then Value is set to\r
- ExchangeValue and CompareValue is returned. If Value is not equal to CompareValue,\r
- then Value is returned. The compare exchange operation must be performed using\r
- MP safe mechanisms.\r
-\r
- @param Value A pointer to the 32-bit value for the compare exchange\r
- operation.\r
- @param CompareValue 32-bit value used in compare operation.\r
- @param ExchangeValue 32-bit value used in exchange operation.\r
-\r
- @return The original *Value before exchange.\r
-\r
-**/\r
-UINT32\r
-EFIAPI\r
-InternalSyncCompareExchange32 (\r
- IN UINT32 *Value,\r
- IN UINT32 CompareValue,\r
- IN UINT32 ExchangeValue\r
- )\r
-{\r
- _asm {\r
- mov ecx, Value\r
- mov eax, CompareValue\r
- mov edx, ExchangeValue\r
- lock cmpxchg [ecx], edx\r
- }\r
-}\r
-\r
+++ /dev/null
-#------------------------------------------------------------------------------\r
-#\r
-# Copyright (c) 2006 - 2008, Intel Corporation\r
-# All rights reserved. This program and the accompanying materials\r
-# are licensed and made available under the terms and conditions of the BSD License\r
-# which accompanies this distribution. The full text of the license may be found at\r
-# http://opensource.org/licenses/bsd-license.php\r
-#\r
-# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-#\r
-# Module Name:\r
-#\r
-# InterlockedCompareExchange64.S\r
-#\r
-# Abstract:\r
-#\r
-# InternalSyncCompareExchange64 function\r
-#\r
-# Notes:\r
-#\r
-#------------------------------------------------------------------------------\r
-\r
-.globl ASM_PFX(InternalSyncCompareExchange64)\r
-\r
-#------------------------------------------------------------------------------\r
-# UINT64\r
-# EFIAPI\r
-# InternalSyncCompareExchange64 (\r
-# IN UINT64 *Value,\r
-# IN UINT64 CompareValue,\r
-# IN UINT64 ExchangeValue\r
-# );\r
-#------------------------------------------------------------------------------\r
-ASM_PFX(InternalSyncCompareExchange64):\r
- push %esi\r
- push %ebx\r
- movl 12(%esp), %esi\r
- movl 16(%esp), %eax\r
- movl 20(%esp), %edx\r
- movl 24(%esp), %ebx\r
- movl 28(%esp), %ecx\r
- lock\r
- cmpxchg8b (%esi)\r
- pop %ebx\r
- pop %esi\r
- ret\r
+++ /dev/null
-;------------------------------------------------------------------------------\r
-;\r
-; Copyright (c) 2006, Intel Corporation\r
-; All rights reserved. This program and the accompanying materials\r
-; are licensed and made available under the terms and conditions of the BSD License\r
-; which accompanies this distribution. The full text of the license may be found at\r
-; http://opensource.org/licenses/bsd-license.php\r
-;\r
-; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-;\r
-; Module Name:\r
-;\r
-; InterlockedCompareExchange64.Asm\r
-;\r
-; Abstract:\r
-;\r
-; InterlockedCompareExchange64 function\r
-;\r
-; Notes:\r
-;\r
-;------------------------------------------------------------------------------\r
-\r
- .586P\r
- .model flat,C\r
- .code\r
-\r
-;------------------------------------------------------------------------------\r
-; UINT64\r
-; EFIAPI\r
-; InternalSyncCompareExchange64 (\r
-; IN UINT64 *Value,\r
-; IN UINT64 CompareValue,\r
-; IN UINT64 ExchangeValue\r
-; );\r
-;------------------------------------------------------------------------------\r
-InternalSyncCompareExchange64 PROC USES esi ebx\r
- mov esi, [esp + 12]\r
- mov eax, [esp + 16]\r
- mov edx, [esp + 20]\r
- mov ebx, [esp + 24]\r
- mov ecx, [esp + 28]\r
- lock cmpxchg8b qword ptr [esi]\r
- ret\r
-InternalSyncCompareExchange64 ENDP\r
-\r
- END\r
+++ /dev/null
-/** @file\r
- InterlockedCompareExchange64 function\r
-\r
- Copyright (c) 2006 - 2008, Intel Corporation<BR>\r
- All rights reserved. This program and the accompanying materials\r
- are licensed and made available under the terms and conditions of the BSD License\r
- which accompanies this distribution. The full text of the license may be found at\r
- http://opensource.org/licenses/bsd-license.php\r
-\r
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-**/\r
-\r
-\r
-\r
-\r
-/**\r
- Performs an atomic compare exchange operation on a 64-bit unsigned integer.\r
-\r
- Performs an atomic compare exchange operation on the 64-bit unsigned integer specified\r
- by Value. If Value is equal to CompareValue, then Value is set to ExchangeValue and\r
- CompareValue is returned. If Value is not equal to CompareValue, then Value is returned.\r
- The compare exchange operation must be performed using MP safe mechanisms.\r
-\r
- @param Value A pointer to the 64-bit value for the compare exchange\r
- operation.\r
- @param CompareValue 64-bit value used in compare operation.\r
- @param ExchangeValue 64-bit value used in exchange operation.\r
-\r
- @return The original *Value before exchange.\r
-\r
-**/\r
-UINT64\r
-EFIAPI\r
-InternalSyncCompareExchange64 (\r
- IN UINT64 *Value,\r
- IN UINT64 CompareValue,\r
- IN UINT64 ExchangeValue\r
- )\r
-{\r
- _asm {\r
- mov esi, Value\r
- mov eax, dword ptr [CompareValue + 0]\r
- mov edx, dword ptr [CompareValue + 4]\r
- mov ebx, dword ptr [ExchangeValue + 0]\r
- mov ecx, dword ptr [ExchangeValue + 4]\r
- lock cmpxchg8b qword ptr [esi]\r
- }\r
-}\r
+++ /dev/null
-#------------------------------------------------------------------------------\r
-#\r
-# Copyright (c) 2006 - 2008, Intel Corporation\r
-# All rights reserved. This program and the accompanying materials\r
-# are licensed and made available under the terms and conditions of the BSD License\r
-# which accompanies this distribution. The full text of the license may be found at\r
-# http://opensource.org/licenses/bsd-license.php\r
-#\r
-# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-#\r
-# Module Name:\r
-#\r
-# InterlockedDecrement.S\r
-#\r
-# Abstract:\r
-#\r
-# InternalSyncDecrement function\r
-#\r
-# Notes:\r
-#\r
-#------------------------------------------------------------------------------\r
-\r
-.globl ASM_PFX(InternalSyncDecrement)\r
-\r
-#------------------------------------------------------------------------------\r
-# UINT32\r
-# EFIAPI\r
-# InternalSyncDecrement (\r
-# IN UINT32 *Value\r
-# );\r
-#------------------------------------------------------------------------------\r
-ASM_PFX(InternalSyncDecrement):\r
- movl 4(%esp), %eax\r
- lock\r
- decl (%eax)\r
- movl (%eax), %eax\r
- ret\r
+++ /dev/null
-;------------------------------------------------------------------------------\r
-;\r
-; Copyright (c) 2006, Intel Corporation\r
-; All rights reserved. This program and the accompanying materials\r
-; are licensed and made available under the terms and conditions of the BSD License\r
-; which accompanies this distribution. The full text of the license may be found at\r
-; http://opensource.org/licenses/bsd-license.php\r
-;\r
-; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-;\r
-; Module Name:\r
-;\r
-; InterlockedDecrement.Asm\r
-;\r
-; Abstract:\r
-;\r
-; InterlockedDecrement function\r
-;\r
-; Notes:\r
-;\r
-;------------------------------------------------------------------------------\r
-\r
- .386\r
- .model flat,C\r
- .code\r
-\r
-;------------------------------------------------------------------------------\r
-; UINT32\r
-; EFIAPI\r
-; InternalSyncDecrement (\r
-; IN UINT32 *Value\r
-; );\r
-;------------------------------------------------------------------------------\r
-InternalSyncDecrement PROC\r
- mov eax, [esp + 4]\r
- lock dec dword ptr [eax]\r
- mov eax, [eax]\r
- ret\r
-InternalSyncDecrement ENDP\r
-\r
- END\r
+++ /dev/null
-/** @file\r
- InterlockedDecrement function\r
-\r
- Copyright (c) 2006 - 2008, Intel Corporation<BR>\r
- All rights reserved. This program and the accompanying materials\r
- are licensed and made available under the terms and conditions of the BSD License\r
- which accompanies this distribution. The full text of the license may be found at\r
- http://opensource.org/licenses/bsd-license.php\r
-\r
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-**/\r
-\r
-\r
-\r
-\r
-/**\r
- Performs an atomic decrement of an 32-bit unsigned integer.\r
-\r
- Performs an atomic decrement of the 32-bit unsigned integer specified by\r
- Value and returns the decrement value. The decrement operation must be\r
- performed using MP safe mechanisms. The state of the return value is not\r
- guaranteed to be MP safe.\r
-\r
- @param Value A pointer to the 32-bit value to decrement.\r
-\r
- @return The decrement value.\r
-\r
-**/\r
-UINT32\r
-EFIAPI\r
-InternalSyncDecrement (\r
- IN UINT32 *Value\r
- )\r
-{\r
- _asm {\r
- mov eax, Value\r
- lock dec dword ptr [eax]\r
- mov eax, [eax]\r
- }\r
-}\r
+++ /dev/null
-#------------------------------------------------------------------------------\r
-#\r
-# Copyright (c) 2006 - 2008, Intel Corporation\r
-# All rights reserved. This program and the accompanying materials\r
-# are licensed and made available under the terms and conditions of the BSD License\r
-# which accompanies this distribution. The full text of the license may be found at\r
-# http://opensource.org/licenses/bsd-license.php\r
-#\r
-# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-#\r
-# Module Name:\r
-#\r
-# InterlockedIncrement.S\r
-#\r
-# Abstract:\r
-#\r
-# InternalSyncIncrement function\r
-#\r
-# Notes:\r
-#\r
-#------------------------------------------------------------------------------\r
-\r
-.globl ASM_PFX(InternalSyncIncrement)\r
-\r
-#------------------------------------------------------------------------------\r
-# UINT32\r
-# EFIAPI\r
-# InternalSyncIncrement (\r
-# IN UINT32 *Value\r
-# );\r
-#------------------------------------------------------------------------------\r
-ASM_PFX(InternalSyncIncrement):\r
- movl 4(%esp), %eax\r
- lock\r
- incl (%eax)\r
- movl (%eax), %eax\r
- ret\r
+++ /dev/null
-;------------------------------------------------------------------------------\r
-;\r
-; Copyright (c) 2006, Intel Corporation\r
-; All rights reserved. This program and the accompanying materials\r
-; are licensed and made available under the terms and conditions of the BSD License\r
-; which accompanies this distribution. The full text of the license may be found at\r
-; http://opensource.org/licenses/bsd-license.php\r
-;\r
-; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-;\r
-; Module Name:\r
-;\r
-; InterlockedIncrement.Asm\r
-;\r
-; Abstract:\r
-;\r
-; InterlockedIncrement function\r
-;\r
-; Notes:\r
-;\r
-;------------------------------------------------------------------------------\r
-\r
- .386\r
- .model flat,C\r
- .code\r
-\r
-;------------------------------------------------------------------------------\r
-; UINT32\r
-; EFIAPI\r
-; InternalSyncIncrement (\r
-; IN UINT32 *Value\r
-; );\r
-;------------------------------------------------------------------------------\r
-InternalSyncIncrement PROC\r
- mov eax, [esp + 4]\r
- lock inc dword ptr [eax]\r
- mov eax, [eax]\r
- ret\r
-InternalSyncIncrement ENDP\r
-\r
- END\r
+++ /dev/null
-/** @file\r
- InterLockedIncrement function\r
-\r
- Copyright (c) 2006 - 2008, Intel Corporation<BR>\r
- All rights reserved. This program and the accompanying materials\r
- are licensed and made available under the terms and conditions of the BSD License\r
- which accompanies this distribution. The full text of the license may be found at\r
- http://opensource.org/licenses/bsd-license.php\r
-\r
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-**/\r
-\r
-\r
-\r
-\r
-/**\r
- Performs an atomic increment of an 32-bit unsigned integer.\r
-\r
- Performs an atomic increment of the 32-bit unsigned integer specified by\r
- Value and returns the incremented value. The increment operation must be\r
- performed using MP safe mechanisms. The state of the return value is not\r
- guaranteed to be MP safe.\r
-\r
- @param Value A pointer to the 32-bit value to increment.\r
-\r
- @return The incremented value.\r
-\r
-**/\r
-UINT32\r
-EFIAPI\r
-InternalSyncIncrement (\r
- IN UINT32 *Value\r
- )\r
-{\r
- _asm {\r
- mov eax, Value\r
- lock inc dword ptr [eax]\r
- mov eax, [eax]\r
- }\r
-}\r
-\r
+++ /dev/null
-/// @file\r
-/// Contains an implementation of InterlockedCompareExchange32 on Itanium-\r
-/// based architecture.\r
-///\r
-/// Copyright (c) 2006 - 2008, Intel Corporation\r
-/// All rights reserved. This program and the accompanying materials\r
-/// are licensed and made available under the terms and conditions of the BSD License\r
-/// which accompanies this distribution. The full text of the license may be found at\r
-/// http://opensource.org/licenses/bsd-license.php\r
-///\r
-/// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-/// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-///\r
-/// Module Name: InterlockedCompareExchange32.s\r
-///\r
-///\r
-\r
-.auto\r
-.text\r
-\r
-.proc InternalSyncCompareExchange32\r
-.type InternalSyncCompareExchange32, @function\r
-InternalSyncCompareExchange32::\r
- zxt4 r33 = r33\r
- mov ar.ccv = r33\r
- cmpxchg4.rel r8 = [r32], r34\r
- mf\r
- br.ret.sptk.many b0\r
-.endp InternalSyncCompareExchange32\r
+++ /dev/null
-/// @file\r
-/// Contains an implementation of InterlockedCompareExchange64 on Itanium-\r
-/// based architecture.\r
-///\r
-/// Copyright (c) 2006 - 2008, Intel Corporation\r
-/// All rights reserved. This program and the accompanying materials\r
-/// are licensed and made available under the terms and conditions of the BSD License\r
-/// which accompanies this distribution. The full text of the license may be found at\r
-/// http://opensource.org/licenses/bsd-license.php\r
-///\r
-/// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-/// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-///\r
-/// Module Name: InterlockedCompareExchange64.s\r
-///\r
-///\r
-\r
-.auto\r
-.text\r
-\r
-.proc InternalSyncCompareExchange64\r
-.type InternalSyncCompareExchange64, @function\r
-InternalSyncCompareExchange64::\r
- mov ar.ccv = r33\r
- cmpxchg8.rel r8 = [r32], r34\r
- mf\r
- br.ret.sptk.many b0\r
-.endp InternalSyncCompareExchange64\r
+++ /dev/null
-/** @file\r
- Implementation of synchronization functions on Itanium.\r
-\r
- Copyright (c) 2006, Intel Corporation<BR>\r
- All rights reserved. This program and the accompanying materials\r
- are licensed and made available under the terms and conditions of the BSD License\r
- which accompanies this distribution. The full text of the license may be found at\r
- http://opensource.org/licenses/bsd-license.php\r
-\r
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-**/\r
-\r
-#include "BaseLibInternals.h"\r
-\r
-/**\r
- Performs an atomic increment of an 32-bit unsigned integer.\r
-\r
- Performs an atomic increment of the 32-bit unsigned integer specified by\r
- Value and returns the incremented value. The increment operation must be\r
- performed using MP safe mechanisms. The state of the return value is not\r
- guaranteed to be MP safe.\r
-\r
- @param Value A pointer to the 32-bit value to increment.\r
-\r
- @return The incremented value.\r
-\r
-**/\r
-UINT32\r
-EFIAPI\r
-InternalSyncIncrement (\r
- IN volatile UINT32 *Value\r
- )\r
-{\r
- UINT32 OriginalValue;\r
-\r
- do {\r
- OriginalValue = *Value;\r
- } while (OriginalValue != InternalSyncCompareExchange32 (\r
- Value,\r
- OriginalValue,\r
- OriginalValue + 1\r
- ));\r
- return OriginalValue + 1;\r
-}\r
-\r
-/**\r
- Performs an atomic decrement of an 32-bit unsigned integer.\r
-\r
- Performs an atomic decrement of the 32-bit unsigned integer specified by\r
- Value and returns the decrement value. The decrement operation must be\r
- performed using MP safe mechanisms. The state of the return value is not\r
- guaranteed to be MP safe.\r
-\r
- @param Value A pointer to the 32-bit value to decrement.\r
-\r
- @return The decrement value.\r
-\r
-**/\r
-UINT32\r
-EFIAPI\r
-InternalSyncDecrement (\r
- IN volatile UINT32 *Value\r
- )\r
-{\r
- UINT32 OriginalValue;\r
-\r
- do {\r
- OriginalValue = *Value;\r
- } while (OriginalValue != InternalSyncCompareExchange32 (\r
- Value,\r
- OriginalValue,\r
- OriginalValue - 1\r
- ));\r
- return OriginalValue - 1;\r
-}\r
+++ /dev/null
-/** @file\r
- Implementation of synchronization functions.\r
-\r
- Copyright (c) 2006 - 2008, Intel Corporation<BR>\r
- All rights reserved. This program and the accompanying materials\r
- are licensed and made available under the terms and conditions of the BSD License\r
- which accompanies this distribution. The full text of the license may be found at\r
- http://opensource.org/licenses/bsd-license.php\r
-\r
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-**/\r
-\r
-#include "BaseLibInternals.h"\r
-\r
-#define SPIN_LOCK_RELEASED ((UINTN) 1)\r
-#define SPIN_LOCK_ACQUIRED ((UINTN) 2)\r
-\r
-/**\r
- Retrieves the architecture specific spin lock alignment requirements for\r
- optimal spin lock performance.\r
-\r
- This function retrieves the spin lock alignment requirements for optimal\r
- performance on a given CPU architecture. The spin lock alignment must be a\r
- power of two and is returned by this function. If there are no alignment\r
- requirements, then 1 must be returned. The spin lock synchronization\r
- functions must function correctly if the spin lock size and alignment values\r
- returned by this function are not used at all. These values are hints to the\r
- consumers of the spin lock synchronization functions to obtain optimal spin\r
- lock performance.\r
-\r
- @return The architecture specific spin lock alignment.\r
-\r
-**/\r
-UINTN\r
-EFIAPI\r
-GetSpinLockProperties (\r
- VOID\r
- )\r
-{\r
- return 32;\r
-}\r
-\r
-/**\r
- Initializes a spin lock to the released state and returns the spin lock.\r
-\r
- This function initializes the spin lock specified by SpinLock to the released\r
- state, and returns SpinLock. Optimal performance can be achieved by calling\r
- GetSpinLockProperties() to determine the size and alignment requirements for\r
- SpinLock.\r
-\r
- If SpinLock is NULL, then ASSERT().\r
-\r
- @param SpinLock A pointer to the spin lock to initialize to the released\r
- state.\r
-\r
- @return SpinLock in release state.\r
-\r
-**/\r
-SPIN_LOCK *\r
-EFIAPI\r
-InitializeSpinLock (\r
- OUT SPIN_LOCK *SpinLock\r
- )\r
-{\r
- ASSERT (SpinLock != NULL);\r
- *SpinLock = SPIN_LOCK_RELEASED;\r
- return SpinLock;\r
-}\r
-\r
-/**\r
- Waits until a spin lock can be placed in the acquired state.\r
-\r
- This function checks the state of the spin lock specified by SpinLock. If\r
- SpinLock is in the released state, then this function places SpinLock in the\r
- acquired state and returns SpinLock. Otherwise, this function waits\r
- indefinitely for the spin lock to be released, and then places it in the\r
- acquired state and returns SpinLock. All state transitions of SpinLock must\r
- be performed using MP safe mechanisms.\r
-\r
- If SpinLock is NULL, then ASSERT().\r
- If SpinLock was not initialized with InitializeSpinLock(), then ASSERT().\r
- If PcdSpinLockTimeout is not zero, and SpinLock is can not be acquired in\r
- PcdSpinLockTimeout microseconds, then ASSERT().\r
-\r
- @param SpinLock A pointer to the spin lock to place in the acquired state.\r
-\r
- @return SpinLock acquired lock.\r
-\r
-**/\r
-SPIN_LOCK *\r
-EFIAPI\r
-AcquireSpinLock (\r
- IN OUT SPIN_LOCK *SpinLock\r
- )\r
-{\r
- UINT64 Current;\r
- UINT64 Previous;\r
- UINT64 Total;\r
- UINT64 Start;\r
- UINT64 End;\r
- UINT64 Timeout;\r
- INT64 Cycle;\r
- INT64 Delta;\r
-\r
- if (PcdGet32 (PcdSpinLockTimeout) > 0) {\r
- //\r
- // Get the current timer value\r
- //\r
- Current = GetPerformanceCounter();\r
-\r
- //\r
- // Initialize local variables\r
- //\r
- Start = 0;\r
- End = 0;\r
- Total = 0;\r
-\r
- //\r
- // Retrieve the performance counter properties and compute the number of performance\r
- // counter ticks required to reach the timeout\r
- //\r
- Timeout = DivU64x32 (\r
- MultU64x32 (\r
- GetPerformanceCounterProperties (&Start, &End),\r
- PcdGet32 (PcdSpinLockTimeout)\r
- ),\r
- 1000000\r
- );\r
- Cycle = End - Start;\r
- if (Cycle < 0) {\r
- Cycle = -Cycle;\r
- }\r
- Cycle++;\r
-\r
- while (!AcquireSpinLockOrFail (SpinLock)) {\r
- CpuPause ();\r
- Previous = Current;\r
- Current = GetPerformanceCounter();\r
- Delta = (INT64) (Current - Previous);\r
- if (Start > End) {\r
- Delta = -Delta;\r
- }\r
- if (Delta < 0) {\r
- Delta += Cycle;\r
- }\r
- Total += Delta;\r
- ASSERT (Total < Timeout);\r
- }\r
- } else {\r
- while (!AcquireSpinLockOrFail (SpinLock)) {\r
- CpuPause ();\r
- }\r
- }\r
- return SpinLock;\r
-}\r
-\r
-/**\r
- Attempts to place a spin lock in the acquired state.\r
-\r
- This function checks the state of the spin lock specified by SpinLock. If\r
- SpinLock is in the released state, then this function places SpinLock in the\r
- acquired state and returns TRUE. Otherwise, FALSE is returned. All state\r
- transitions of SpinLock must be performed using MP safe mechanisms.\r
-\r
- If SpinLock is NULL, then ASSERT().\r
- If SpinLock was not initialized with InitializeSpinLock(), then ASSERT().\r
-\r
- @param SpinLock A pointer to the spin lock to place in the acquired state.\r
-\r
- @retval TRUE SpinLock was placed in the acquired state.\r
- @retval FALSE SpinLock could not be acquired.\r
-\r
-**/\r
-BOOLEAN\r
-EFIAPI\r
-AcquireSpinLockOrFail (\r
- IN OUT SPIN_LOCK *SpinLock\r
- )\r
-{\r
- SPIN_LOCK LockValue;\r
-\r
- ASSERT (SpinLock != NULL);\r
-\r
- LockValue = *SpinLock;\r
- ASSERT (SPIN_LOCK_ACQUIRED == LockValue || SPIN_LOCK_RELEASED == LockValue);\r
-\r
- return (BOOLEAN)(\r
- InterlockedCompareExchangePointer (\r
- (VOID**)SpinLock,\r
- (VOID*)SPIN_LOCK_RELEASED,\r
- (VOID*)SPIN_LOCK_ACQUIRED\r
- ) == (VOID*)SPIN_LOCK_RELEASED\r
- );\r
-}\r
-\r
-/**\r
- Releases a spin lock.\r
-\r
- This function places the spin lock specified by SpinLock in the release state\r
- and returns SpinLock.\r
-\r
- If SpinLock is NULL, then ASSERT().\r
- If SpinLock was not initialized with InitializeSpinLock(), then ASSERT().\r
-\r
- @param SpinLock A pointer to the spin lock to release.\r
-\r
- @return SpinLock released lock.\r
-\r
-**/\r
-SPIN_LOCK *\r
-EFIAPI\r
-ReleaseSpinLock (\r
- IN OUT SPIN_LOCK *SpinLock\r
- )\r
-{\r
- SPIN_LOCK LockValue;\r
-\r
- ASSERT (SpinLock != NULL);\r
-\r
- LockValue = *SpinLock;\r
- ASSERT (SPIN_LOCK_ACQUIRED == LockValue || SPIN_LOCK_RELEASED == LockValue);\r
-\r
- *SpinLock = SPIN_LOCK_RELEASED;\r
- return SpinLock;\r
-}\r
-\r
-/**\r
- Performs an atomic increment of an 32-bit unsigned integer.\r
-\r
- Performs an atomic increment of the 32-bit unsigned integer specified by\r
- Value and returns the incremented value. The increment operation must be\r
- performed using MP safe mechanisms. The state of the return value is not\r
- guaranteed to be MP safe.\r
-\r
- If Value is NULL, then ASSERT().\r
-\r
- @param Value A pointer to the 32-bit value to increment.\r
-\r
- @return The incremented value.\r
-\r
-**/\r
-UINT32\r
-EFIAPI\r
-InterlockedIncrement (\r
- IN UINT32 *Value\r
- )\r
-{\r
- ASSERT (Value != NULL);\r
- return InternalSyncIncrement (Value);\r
-}\r
-\r
-/**\r
- Performs an atomic decrement of an 32-bit unsigned integer.\r
-\r
- Performs an atomic decrement of the 32-bit unsigned integer specified by\r
- Value and returns the decremented value. The decrement operation must be\r
- performed using MP safe mechanisms. The state of the return value is not\r
- guaranteed to be MP safe.\r
-\r
- If Value is NULL, then ASSERT().\r
-\r
- @param Value A pointer to the 32-bit value to decrement.\r
-\r
- @return The decremented value.\r
-\r
-**/\r
-UINT32\r
-EFIAPI\r
-InterlockedDecrement (\r
- IN UINT32 *Value\r
- )\r
-{\r
- ASSERT (Value != NULL);\r
- return InternalSyncDecrement (Value);\r
-}\r
-\r
-/**\r
- Performs an atomic compare exchange operation on a 32-bit unsigned integer.\r
-\r
- Performs an atomic compare exchange operation on the 32-bit unsigned integer\r
- specified by Value. If Value is equal to CompareValue, then Value is set to\r
- ExchangeValue and CompareValue is returned. If Value is not equal to CompareValue,\r
- then Value is returned. The compare exchange operation must be performed using\r
- MP safe mechanisms.\r
-\r
- If Value is NULL, then ASSERT().\r
-\r
- @param Value A pointer to the 32-bit value for the compare exchange\r
- operation.\r
- @param CompareValue 32-bit value used in compare operation.\r
- @param ExchangeValue 32-bit value used in exchange operation.\r
-\r
- @return The original *Value before exchange.\r
-\r
-**/\r
-UINT32\r
-EFIAPI\r
-InterlockedCompareExchange32 (\r
- IN OUT UINT32 *Value,\r
- IN UINT32 CompareValue,\r
- IN UINT32 ExchangeValue\r
- )\r
-{\r
- ASSERT (Value != NULL);\r
- return InternalSyncCompareExchange32 (Value, CompareValue, ExchangeValue);\r
-}\r
-\r
-/**\r
- Performs an atomic compare exchange operation on a 64-bit unsigned integer.\r
-\r
- Performs an atomic compare exchange operation on the 64-bit unsigned integer specified\r
- by Value. If Value is equal to CompareValue, then Value is set to ExchangeValue and\r
- CompareValue is returned. If Value is not equal to CompareValue, then Value is returned.\r
- The compare exchange operation must be performed using MP safe mechanisms.\r
-\r
- If Value is NULL, then ASSERT().\r
-\r
- @param Value A pointer to the 64-bit value for the compare exchange\r
- operation.\r
- @param CompareValue 64-bit value used in compare operation.\r
- @param ExchangeValue 64-bit value used in exchange operation.\r
-\r
- @return The original *Value before exchange.\r
-\r
-**/\r
-UINT64\r
-EFIAPI\r
-InterlockedCompareExchange64 (\r
- IN OUT UINT64 *Value,\r
- IN UINT64 CompareValue,\r
- IN UINT64 ExchangeValue\r
- )\r
-{\r
- ASSERT (Value != NULL);\r
- return InternalSyncCompareExchange64 (Value, CompareValue, ExchangeValue);\r
-}\r
-\r
-/**\r
- Performs an atomic compare exchange operation on a pointer value.\r
-\r
- Performs an atomic compare exchange operation on the pointer value specified\r
- by Value. If Value is equal to CompareValue, then Value is set to\r
- ExchangeValue and CompareValue is returned. If Value is not equal to\r
- CompareValue, then Value is returned. The compare exchange operation must be\r
- performed using MP safe mechanisms.\r
-\r
- If Value is NULL, then ASSERT().\r
-\r
- @param Value A pointer to the pointer value for the compare exchange\r
- operation.\r
- @param CompareValue Pointer value used in compare operation.\r
- @param ExchangeValue Pointer value used in exchange operation.\r
-\r
- @return The original *Value before exchange.\r
-**/\r
-VOID *\r
-EFIAPI\r
-InterlockedCompareExchangePointer (\r
- IN OUT VOID **Value,\r
- IN VOID *CompareValue,\r
- IN VOID *ExchangeValue\r
- )\r
-{\r
- UINT8 SizeOfValue;\r
-\r
- SizeOfValue = sizeof (*Value);\r
-\r
- switch (SizeOfValue) {\r
- case sizeof (UINT32):\r
- return (VOID*)(UINTN)InterlockedCompareExchange32 (\r
- (UINT32*)Value,\r
- (UINT32)(UINTN)CompareValue,\r
- (UINT32)(UINTN)ExchangeValue\r
- );\r
- case sizeof (UINT64):\r
- return (VOID*)(UINTN)InterlockedCompareExchange64 (\r
- (UINT64*)Value,\r
- (UINT64)(UINTN)CompareValue,\r
- (UINT64)(UINTN)ExchangeValue\r
- );\r
- default:\r
- ASSERT (FALSE);\r
- return NULL;\r
- }\r
-}\r
+++ /dev/null
-/** @file\r
- Implementation of synchronization functions.\r
-\r
- Copyright (c) 2006 - 2008, Intel Corporation<BR>\r
- All rights reserved. This program and the accompanying materials\r
- are licensed and made available under the terms and conditions of the BSD License\r
- which accompanies this distribution. The full text of the license may be found at\r
- http://opensource.org/licenses/bsd-license.php\r
-\r
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-**/\r
-\r
-\r
-\r
-\r
-#include "BaseLibInternals.h"\r
-\r
-//\r
-// GCC inline assembly for Read Write Barrier \r
-//\r
-#define _ReadWriteBarrier() do { asm volatile ("": : : "memory"); } while(0)\r
-\r
-#define SPIN_LOCK_RELEASED ((UINTN) 1)\r
-#define SPIN_LOCK_ACQUIRED ((UINTN) 2)\r
-\r
-/**\r
- Retrieves the architecture specific spin lock alignment requirements for\r
- optimal spin lock performance.\r
-\r
- This function retrieves the spin lock alignment requirements for optimal\r
- performance on a given CPU architecture. The spin lock alignment must be a\r
- power of two and is returned by this function. If there are no alignment\r
- requirements, then 1 must be returned. The spin lock synchronization\r
- functions must function correctly if the spin lock size and alignment values\r
- returned by this function are not used at all. These values are hints to the\r
- consumers of the spin lock synchronization functions to obtain optimal spin\r
- lock performance.\r
-\r
- @return The architecture specific spin lock alignment.\r
-\r
-**/\r
-UINTN\r
-EFIAPI\r
-GetSpinLockProperties (\r
- VOID\r
- )\r
-{\r
- return 32;\r
-}\r
-\r
-/**\r
- Initializes a spin lock to the released state and returns the spin lock.\r
-\r
- This function initializes the spin lock specified by SpinLock to the released\r
- state, and returns SpinLock. Optimal performance can be achieved by calling\r
- GetSpinLockProperties() to determine the size and alignment requirements for\r
- SpinLock.\r
-\r
- If SpinLock is NULL, then ASSERT().\r
-\r
- @param SpinLock A pointer to the spin lock to initialize to the released\r
- state.\r
-\r
- @return SpinLock in release state.\r
-\r
-**/\r
-SPIN_LOCK *\r
-EFIAPI\r
-InitializeSpinLock (\r
- OUT SPIN_LOCK *SpinLock\r
- )\r
-{\r
- ASSERT (SpinLock != NULL);\r
-\r
- _ReadWriteBarrier();\r
- *SpinLock = SPIN_LOCK_RELEASED;\r
- _ReadWriteBarrier();\r
-\r
- return SpinLock;\r
-}\r
-\r
-/**\r
- Waits until a spin lock can be placed in the acquired state.\r
-\r
- This function checks the state of the spin lock specified by SpinLock. If\r
- SpinLock is in the released state, then this function places SpinLock in the\r
- acquired state and returns SpinLock. Otherwise, this function waits\r
- indefinitely for the spin lock to be released, and then places it in the\r
- acquired state and returns SpinLock. All state transitions of SpinLock must\r
- be performed using MP safe mechanisms.\r
-\r
- If SpinLock is NULL, then ASSERT().\r
- If SpinLock was not initialized with InitializeSpinLock(), then ASSERT().\r
- If PcdSpinLockTimeout is not zero, and SpinLock is can not be acquired in\r
- PcdSpinLockTimeout microseconds, then ASSERT().\r
-\r
- @param SpinLock A pointer to the spin lock to place in the acquired state.\r
-\r
- @return SpinLock acquired lock.\r
-\r
-**/\r
-SPIN_LOCK *\r
-EFIAPI\r
-AcquireSpinLock (\r
- IN OUT SPIN_LOCK *SpinLock\r
- )\r
-{\r
- UINT64 Current;\r
- UINT64 Previous;\r
- UINT64 Total;\r
- UINT64 Start;\r
- UINT64 End;\r
- UINT64 Timeout;\r
- INT64 Cycle;\r
- INT64 Delta;\r
-\r
- if (PcdGet32 (PcdSpinLockTimeout) > 0) {\r
- //\r
- // Get the current timer value\r
- //\r
- Current = GetPerformanceCounter();\r
-\r
- //\r
- // Initialize local variables\r
- //\r
- Start = 0;\r
- End = 0;\r
- Total = 0;\r
-\r
- //\r
- // Retrieve the performance counter properties and compute the number of performance\r
- // counter ticks required to reach the timeout\r
- //\r
- Timeout = DivU64x32 (\r
- MultU64x32 (\r
- GetPerformanceCounterProperties (&Start, &End),\r
- PcdGet32 (PcdSpinLockTimeout)\r
- ),\r
- 1000000\r
- );\r
- Cycle = End - Start;\r
- if (Cycle < 0) {\r
- Cycle = -Cycle;\r
- }\r
- Cycle++;\r
-\r
- while (!AcquireSpinLockOrFail (SpinLock)) {\r
- CpuPause ();\r
- Previous = Current;\r
- Current = GetPerformanceCounter();\r
- Delta = (INT64) (Current - Previous);\r
- if (Start > End) {\r
- Delta = -Delta;\r
- }\r
- if (Delta < 0) {\r
- Delta += Cycle;\r
- }\r
- Total += Delta;\r
- ASSERT (Total < Timeout);\r
- }\r
- } else {\r
- while (!AcquireSpinLockOrFail (SpinLock)) {\r
- CpuPause ();\r
- }\r
- }\r
- return SpinLock;\r
-}\r
-\r
-/**\r
- Attempts to place a spin lock in the acquired state.\r
-\r
- This function checks the state of the spin lock specified by SpinLock. If\r
- SpinLock is in the released state, then this function places SpinLock in the\r
- acquired state and returns TRUE. Otherwise, FALSE is returned. All state\r
- transitions of SpinLock must be performed using MP safe mechanisms.\r
-\r
- If SpinLock is NULL, then ASSERT().\r
- If SpinLock was not initialized with InitializeSpinLock(), then ASSERT().\r
-\r
- @param SpinLock A pointer to the spin lock to place in the acquired state.\r
-\r
- @retval TRUE SpinLock was placed in the acquired state.\r
- @retval FALSE SpinLock could not be acquired.\r
-\r
-**/\r
-BOOLEAN\r
-EFIAPI\r
-AcquireSpinLockOrFail (\r
- IN OUT SPIN_LOCK *SpinLock\r
- )\r
-{\r
- SPIN_LOCK LockValue;\r
- VOID *Result;\r
- \r
- ASSERT (SpinLock != NULL);\r
-\r
- LockValue = *SpinLock;\r
- ASSERT (LockValue == SPIN_LOCK_ACQUIRED || LockValue == SPIN_LOCK_RELEASED);\r
-\r
- _ReadWriteBarrier ();\r
- Result = InterlockedCompareExchangePointer (\r
- (VOID**)SpinLock,\r
- (VOID*)SPIN_LOCK_RELEASED,\r
- (VOID*)SPIN_LOCK_ACQUIRED\r
- );\r
-\r
- _ReadWriteBarrier ();\r
- return (BOOLEAN) (Result == (VOID*) SPIN_LOCK_RELEASED);\r
-}\r
-\r
-/**\r
- Releases a spin lock.\r
-\r
- This function places the spin lock specified by SpinLock in the release state\r
- and returns SpinLock.\r
-\r
- If SpinLock is NULL, then ASSERT().\r
- If SpinLock was not initialized with InitializeSpinLock(), then ASSERT().\r
-\r
- @param SpinLock A pointer to the spin lock to release.\r
-\r
- @return SpinLock released lock.\r
-\r
-**/\r
-SPIN_LOCK *\r
-EFIAPI\r
-ReleaseSpinLock (\r
- IN OUT SPIN_LOCK *SpinLock\r
- )\r
-{\r
- SPIN_LOCK LockValue;\r
-\r
- ASSERT (SpinLock != NULL);\r
-\r
- LockValue = *SpinLock;\r
- ASSERT (LockValue == SPIN_LOCK_ACQUIRED || LockValue == SPIN_LOCK_RELEASED);\r
-\r
- _ReadWriteBarrier ();\r
- *SpinLock = SPIN_LOCK_RELEASED;\r
- _ReadWriteBarrier ();\r
-\r
- return SpinLock;\r
-}\r
-\r
-/**\r
- Performs an atomic increment of an 32-bit unsigned integer.\r
-\r
- Performs an atomic increment of the 32-bit unsigned integer specified by\r
- Value and returns the incremented value. The increment operation must be\r
- performed using MP safe mechanisms. The state of the return value is not\r
- guaranteed to be MP safe.\r
-\r
- If Value is NULL, then ASSERT().\r
-\r
- @param Value A pointer to the 32-bit value to increment.\r
-\r
- @return The incremented value.\r
-\r
-**/\r
-UINT32\r
-EFIAPI\r
-InterlockedIncrement (\r
- IN UINT32 *Value\r
- )\r
-{\r
- ASSERT (Value != NULL);\r
- return InternalSyncIncrement (Value);\r
-}\r
-\r
-/**\r
- Performs an atomic decrement of an 32-bit unsigned integer.\r
-\r
- Performs an atomic decrement of the 32-bit unsigned integer specified by\r
- Value and returns the decremented value. The decrement operation must be\r
- performed using MP safe mechanisms. The state of the return value is not\r
- guaranteed to be MP safe.\r
-\r
- If Value is NULL, then ASSERT().\r
-\r
- @param Value A pointer to the 32-bit value to decrement.\r
-\r
- @return The decremented value.\r
-\r
-**/\r
-UINT32\r
-EFIAPI\r
-InterlockedDecrement (\r
- IN UINT32 *Value\r
- )\r
-{\r
- ASSERT (Value != NULL);\r
- return InternalSyncDecrement (Value);\r
-}\r
-\r
-/**\r
- Performs an atomic compare exchange operation on a 32-bit unsigned integer.\r
-\r
- Performs an atomic compare exchange operation on the 32-bit unsigned integer\r
- specified by Value. If Value is equal to CompareValue, then Value is set to\r
- ExchangeValue and CompareValue is returned. If Value is not equal to CompareValue,\r
- then Value is returned. The compare exchange operation must be performed using\r
- MP safe mechanisms.\r
-\r
- If Value is NULL, then ASSERT().\r
-\r
- @param Value A pointer to the 32-bit value for the compare exchange\r
- operation.\r
- @param CompareValue 32-bit value used in compare operation.\r
- @param ExchangeValue 32-bit value used in exchange operation.\r
-\r
- @return The original *Value before exchange.\r
-\r
-**/\r
-UINT32\r
-EFIAPI\r
-InterlockedCompareExchange32 (\r
- IN OUT UINT32 *Value,\r
- IN UINT32 CompareValue,\r
- IN UINT32 ExchangeValue\r
- )\r
-{\r
- ASSERT (Value != NULL);\r
- return InternalSyncCompareExchange32 (Value, CompareValue, ExchangeValue);\r
-}\r
-\r
-/**\r
- Performs an atomic compare exchange operation on a 64-bit unsigned integer.\r
-\r
- Performs an atomic compare exchange operation on the 64-bit unsigned integer specified\r
- by Value. If Value is equal to CompareValue, then Value is set to ExchangeValue and\r
- CompareValue is returned. If Value is not equal to CompareValue, then Value is returned.\r
- The compare exchange operation must be performed using MP safe mechanisms.\r
-\r
- If Value is NULL, then ASSERT().\r
-\r
- @param Value A pointer to the 64-bit value for the compare exchange\r
- operation.\r
- @param CompareValue 64-bit value used in compare operation.\r
- @param ExchangeValue 64-bit value used in exchange operation.\r
-\r
- @return The original *Value before exchange.\r
-\r
-**/\r
-UINT64\r
-EFIAPI\r
-InterlockedCompareExchange64 (\r
- IN OUT UINT64 *Value,\r
- IN UINT64 CompareValue,\r
- IN UINT64 ExchangeValue\r
- )\r
-{\r
- ASSERT (Value != NULL);\r
- return InternalSyncCompareExchange64 (Value, CompareValue, ExchangeValue);\r
-}\r
-\r
-/**\r
- Performs an atomic compare exchange operation on a pointer value.\r
-\r
- Performs an atomic compare exchange operation on the pointer value specified\r
- by Value. If Value is equal to CompareValue, then Value is set to\r
- ExchangeValue and CompareValue is returned. If Value is not equal to\r
- CompareValue, then Value is returned. The compare exchange operation must be\r
- performed using MP safe mechanisms.\r
-\r
- If Value is NULL, then ASSERT().\r
-\r
- @param Value A pointer to the pointer value for the compare exchange\r
- operation.\r
- @param CompareValue Pointer value used in compare operation.\r
- @param ExchangeValue Pointer value used in exchange operation.\r
-\r
- @return The original *Value before exchange.\r
-**/\r
-VOID *\r
-EFIAPI\r
-InterlockedCompareExchangePointer (\r
- IN OUT VOID **Value,\r
- IN VOID *CompareValue,\r
- IN VOID *ExchangeValue\r
- )\r
-{\r
- UINT8 SizeOfValue;\r
-\r
- SizeOfValue = sizeof (*Value);\r
-\r
- switch (SizeOfValue) {\r
- case sizeof (UINT32):\r
- return (VOID*)(UINTN)InterlockedCompareExchange32 (\r
- (UINT32*)Value,\r
- (UINT32)(UINTN)CompareValue,\r
- (UINT32)(UINTN)ExchangeValue\r
- );\r
- case sizeof (UINT64):\r
- return (VOID*)(UINTN)InterlockedCompareExchange64 (\r
- (UINT64*)Value,\r
- (UINT64)(UINTN)CompareValue,\r
- (UINT64)(UINTN)ExchangeValue\r
- );\r
- default:\r
- ASSERT (FALSE);\r
- return NULL;\r
- }\r
-}\r
+++ /dev/null
-/** @file\r
- Implementation of synchronization functions.\r
-\r
- Copyright (c) 2006 - 2008, Intel Corporation<BR>\r
- All rights reserved. This program and the accompanying materials\r
- are licensed and made available under the terms and conditions of the BSD License\r
- which accompanies this distribution. The full text of the license may be found at\r
- http://opensource.org/licenses/bsd-license.php\r
-\r
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-**/\r
-\r
-\r
-\r
-\r
-#include "BaseLibInternals.h"\r
-\r
-/**\r
- Microsoft Visual Studio 7.1 Function Prototypes for read write barrier Intrinsics.\r
-**/\r
-\r
-void _ReadWriteBarrier (void);\r
-#pragma intrinsic(_ReadWriteBarrier)\r
-\r
-\r
-#define SPIN_LOCK_RELEASED ((UINTN) 1)\r
-#define SPIN_LOCK_ACQUIRED ((UINTN) 2)\r
-\r
-/**\r
- Retrieves the architecture specific spin lock alignment requirements for\r
- optimal spin lock performance.\r
-\r
- This function retrieves the spin lock alignment requirements for optimal\r
- performance on a given CPU architecture. The spin lock alignment must be a\r
- power of two and is returned by this function. If there are no alignment\r
- requirements, then 1 must be returned. The spin lock synchronization\r
- functions must function correctly if the spin lock size and alignment values\r
- returned by this function are not used at all. These values are hints to the\r
- consumers of the spin lock synchronization functions to obtain optimal spin\r
- lock performance.\r
-\r
- @return The architecture specific spin lock alignment.\r
-\r
-**/\r
-UINTN\r
-EFIAPI\r
-GetSpinLockProperties (\r
- VOID\r
- )\r
-{\r
- return 32;\r
-}\r
-\r
-/**\r
- Initializes a spin lock to the released state and returns the spin lock.\r
-\r
- This function initializes the spin lock specified by SpinLock to the released\r
- state, and returns SpinLock. Optimal performance can be achieved by calling\r
- GetSpinLockProperties() to determine the size and alignment requirements for\r
- SpinLock.\r
-\r
- If SpinLock is NULL, then ASSERT().\r
-\r
- @param SpinLock A pointer to the spin lock to initialize to the released\r
- state.\r
-\r
- @return SpinLock in release state.\r
-\r
-**/\r
-SPIN_LOCK *\r
-EFIAPI\r
-InitializeSpinLock (\r
- OUT SPIN_LOCK *SpinLock\r
- )\r
-{\r
- ASSERT (SpinLock != NULL);\r
-\r
- _ReadWriteBarrier();\r
- *SpinLock = SPIN_LOCK_RELEASED;\r
- _ReadWriteBarrier();\r
-\r
- return SpinLock;\r
-}\r
-\r
-/**\r
- Waits until a spin lock can be placed in the acquired state.\r
-\r
- This function checks the state of the spin lock specified by SpinLock. If\r
- SpinLock is in the released state, then this function places SpinLock in the\r
- acquired state and returns SpinLock. Otherwise, this function waits\r
- indefinitely for the spin lock to be released, and then places it in the\r
- acquired state and returns SpinLock. All state transitions of SpinLock must\r
- be performed using MP safe mechanisms.\r
-\r
- If SpinLock is NULL, then ASSERT().\r
- If SpinLock was not initialized with InitializeSpinLock(), then ASSERT().\r
- If PcdSpinLockTimeout is not zero, and SpinLock is can not be acquired in\r
- PcdSpinLockTimeout microseconds, then ASSERT().\r
-\r
- @param SpinLock A pointer to the spin lock to place in the acquired state.\r
-\r
- @return SpinLock acquired lock.\r
-\r
-**/\r
-SPIN_LOCK *\r
-EFIAPI\r
-AcquireSpinLock (\r
- IN OUT SPIN_LOCK *SpinLock\r
- )\r
-{\r
- UINT64 Current;\r
- UINT64 Previous;\r
- UINT64 Total;\r
- UINT64 Start;\r
- UINT64 End;\r
- UINT64 Timeout;\r
- INT64 Cycle;\r
- INT64 Delta;\r
-\r
- if (PcdGet32 (PcdSpinLockTimeout) > 0) {\r
- //\r
- // Get the current timer value\r
- //\r
- Current = GetPerformanceCounter();\r
-\r
- //\r
- // Initialize local variables\r
- //\r
- Start = 0;\r
- End = 0;\r
- Total = 0;\r
-\r
- //\r
- // Retrieve the performance counter properties and compute the number of performance\r
- // counter ticks required to reach the timeout\r
- //\r
- Timeout = DivU64x32 (\r
- MultU64x32 (\r
- GetPerformanceCounterProperties (&Start, &End),\r
- PcdGet32 (PcdSpinLockTimeout)\r
- ),\r
- 1000000\r
- );\r
- Cycle = End - Start;\r
- if (Cycle < 0) {\r
- Cycle = -Cycle;\r
- }\r
- Cycle++;\r
-\r
- while (!AcquireSpinLockOrFail (SpinLock)) {\r
- CpuPause ();\r
- Previous = Current;\r
- Current = GetPerformanceCounter();\r
- Delta = (INT64) (Current - Previous);\r
- if (Start > End) {\r
- Delta = -Delta;\r
- }\r
- if (Delta < 0) {\r
- Delta += Cycle;\r
- }\r
- Total += Delta;\r
- ASSERT (Total < Timeout);\r
- }\r
- } else {\r
- while (!AcquireSpinLockOrFail (SpinLock)) {\r
- CpuPause ();\r
- }\r
- }\r
- return SpinLock;\r
-}\r
-\r
-/**\r
- Attempts to place a spin lock in the acquired state.\r
-\r
- This function checks the state of the spin lock specified by SpinLock. If\r
- SpinLock is in the released state, then this function places SpinLock in the\r
- acquired state and returns TRUE. Otherwise, FALSE is returned. All state\r
- transitions of SpinLock must be performed using MP safe mechanisms.\r
-\r
- If SpinLock is NULL, then ASSERT().\r
- If SpinLock was not initialized with InitializeSpinLock(), then ASSERT().\r
-\r
- @param SpinLock A pointer to the spin lock to place in the acquired state.\r
-\r
- @retval TRUE SpinLock was placed in the acquired state.\r
- @retval FALSE SpinLock could not be acquired.\r
-\r
-**/\r
-BOOLEAN\r
-EFIAPI\r
-AcquireSpinLockOrFail (\r
- IN OUT SPIN_LOCK *SpinLock\r
- )\r
-{\r
- SPIN_LOCK LockValue;\r
- VOID *Result;\r
- \r
- ASSERT (SpinLock != NULL);\r
-\r
- LockValue = *SpinLock;\r
- ASSERT (LockValue == SPIN_LOCK_ACQUIRED || LockValue == SPIN_LOCK_RELEASED);\r
-\r
- _ReadWriteBarrier ();\r
- Result = InterlockedCompareExchangePointer (\r
- (VOID**)SpinLock,\r
- (VOID*)SPIN_LOCK_RELEASED,\r
- (VOID*)SPIN_LOCK_ACQUIRED\r
- );\r
-\r
- _ReadWriteBarrier ();\r
- return (BOOLEAN) (Result == (VOID*) SPIN_LOCK_RELEASED);\r
-}\r
-\r
-/**\r
- Releases a spin lock.\r
-\r
- This function places the spin lock specified by SpinLock in the release state\r
- and returns SpinLock.\r
-\r
- If SpinLock is NULL, then ASSERT().\r
- If SpinLock was not initialized with InitializeSpinLock(), then ASSERT().\r
-\r
- @param SpinLock A pointer to the spin lock to release.\r
-\r
- @return SpinLock released lock.\r
-\r
-**/\r
-SPIN_LOCK *\r
-EFIAPI\r
-ReleaseSpinLock (\r
- IN OUT SPIN_LOCK *SpinLock\r
- )\r
-{\r
- SPIN_LOCK LockValue;\r
-\r
- ASSERT (SpinLock != NULL);\r
-\r
- LockValue = *SpinLock;\r
- ASSERT (LockValue == SPIN_LOCK_ACQUIRED || LockValue == SPIN_LOCK_RELEASED);\r
-\r
- _ReadWriteBarrier ();\r
- *SpinLock = SPIN_LOCK_RELEASED;\r
- _ReadWriteBarrier ();\r
-\r
- return SpinLock;\r
-}\r
-\r
-/**\r
- Performs an atomic increment of an 32-bit unsigned integer.\r
-\r
- Performs an atomic increment of the 32-bit unsigned integer specified by\r
- Value and returns the incremented value. The increment operation must be\r
- performed using MP safe mechanisms. The state of the return value is not\r
- guaranteed to be MP safe.\r
-\r
- If Value is NULL, then ASSERT().\r
-\r
- @param Value A pointer to the 32-bit value to increment.\r
-\r
- @return The incremented value.\r
-\r
-**/\r
-UINT32\r
-EFIAPI\r
-InterlockedIncrement (\r
- IN UINT32 *Value\r
- )\r
-{\r
- ASSERT (Value != NULL);\r
- return InternalSyncIncrement (Value);\r
-}\r
-\r
-/**\r
- Performs an atomic decrement of an 32-bit unsigned integer.\r
-\r
- Performs an atomic decrement of the 32-bit unsigned integer specified by\r
- Value and returns the decremented value. The decrement operation must be\r
- performed using MP safe mechanisms. The state of the return value is not\r
- guaranteed to be MP safe.\r
-\r
- If Value is NULL, then ASSERT().\r
-\r
- @param Value A pointer to the 32-bit value to decrement.\r
-\r
- @return The decremented value.\r
-\r
-**/\r
-UINT32\r
-EFIAPI\r
-InterlockedDecrement (\r
- IN UINT32 *Value\r
- )\r
-{\r
- ASSERT (Value != NULL);\r
- return InternalSyncDecrement (Value);\r
-}\r
-\r
-/**\r
- Performs an atomic compare exchange operation on a 32-bit unsigned integer.\r
-\r
- Performs an atomic compare exchange operation on the 32-bit unsigned integer\r
- specified by Value. If Value is equal to CompareValue, then Value is set to\r
- ExchangeValue and CompareValue is returned. If Value is not equal to CompareValue,\r
- then Value is returned. The compare exchange operation must be performed using\r
- MP safe mechanisms.\r
-\r
- If Value is NULL, then ASSERT().\r
-\r
- @param Value A pointer to the 32-bit value for the compare exchange\r
- operation.\r
- @param CompareValue 32-bit value used in compare operation.\r
- @param ExchangeValue 32-bit value used in exchange operation.\r
-\r
- @return The original *Value before exchange.\r
-\r
-**/\r
-UINT32\r
-EFIAPI\r
-InterlockedCompareExchange32 (\r
- IN OUT UINT32 *Value,\r
- IN UINT32 CompareValue,\r
- IN UINT32 ExchangeValue\r
- )\r
-{\r
- ASSERT (Value != NULL);\r
- return InternalSyncCompareExchange32 (Value, CompareValue, ExchangeValue);\r
-}\r
-\r
-/**\r
- Performs an atomic compare exchange operation on a 64-bit unsigned integer.\r
-\r
- Performs an atomic compare exchange operation on the 64-bit unsigned integer specified\r
- by Value. If Value is equal to CompareValue, then Value is set to ExchangeValue and\r
- CompareValue is returned. If Value is not equal to CompareValue, then Value is returned.\r
- The compare exchange operation must be performed using MP safe mechanisms.\r
-\r
- If Value is NULL, then ASSERT().\r
-\r
- @param Value A pointer to the 64-bit value for the compare exchange\r
- operation.\r
- @param CompareValue 64-bit value used in compare operation.\r
- @param ExchangeValue 64-bit value used in exchange operation.\r
-\r
- @return The original *Value before exchange.\r
-\r
-**/\r
-UINT64\r
-EFIAPI\r
-InterlockedCompareExchange64 (\r
- IN OUT UINT64 *Value,\r
- IN UINT64 CompareValue,\r
- IN UINT64 ExchangeValue\r
- )\r
-{\r
- ASSERT (Value != NULL);\r
- return InternalSyncCompareExchange64 (Value, CompareValue, ExchangeValue);\r
-}\r
-\r
-/**\r
- Performs an atomic compare exchange operation on a pointer value.\r
-\r
- Performs an atomic compare exchange operation on the pointer value specified\r
- by Value. If Value is equal to CompareValue, then Value is set to\r
- ExchangeValue and CompareValue is returned. If Value is not equal to\r
- CompareValue, then Value is returned. The compare exchange operation must be\r
- performed using MP safe mechanisms.\r
-\r
- If Value is NULL, then ASSERT().\r
-\r
- @param Value A pointer to the pointer value for the compare exchange\r
- operation.\r
- @param CompareValue Pointer value used in compare operation.\r
- @param ExchangeValue Pointer value used in exchange operation.\r
-\r
- @return The original *Value before exchange.\r
-**/\r
-VOID *\r
-EFIAPI\r
-InterlockedCompareExchangePointer (\r
- IN OUT VOID **Value,\r
- IN VOID *CompareValue,\r
- IN VOID *ExchangeValue\r
- )\r
-{\r
- UINT8 SizeOfValue;\r
-\r
- SizeOfValue = sizeof (*Value);\r
-\r
- switch (SizeOfValue) {\r
- case sizeof (UINT32):\r
- return (VOID*)(UINTN)InterlockedCompareExchange32 (\r
- (UINT32*)Value,\r
- (UINT32)(UINTN)CompareValue,\r
- (UINT32)(UINTN)ExchangeValue\r
- );\r
- case sizeof (UINT64):\r
- return (VOID*)(UINTN)InterlockedCompareExchange64 (\r
- (UINT64*)Value,\r
- (UINT64)(UINTN)CompareValue,\r
- (UINT64)(UINTN)ExchangeValue\r
- );\r
- default:\r
- ASSERT (FALSE);\r
- return NULL;\r
- }\r
-}\r
+++ /dev/null
-#------------------------------------------------------------------------------\r
-#\r
-# Copyright (c) 2006 - 2008, Intel Corporation\r
-# All rights reserved. This program and the accompanying materials\r
-# are licensed and made available under the terms and conditions of the BSD License\r
-# which accompanies this distribution. The full text of the license may be found at\r
-# http://opensource.org/licenses/bsd-license.php\r
-#\r
-# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-#\r
-# Module Name:\r
-#\r
-# InterlockedCompareExchange32.S\r
-#\r
-# Abstract:\r
-#\r
-# InterlockedCompareExchange32 function\r
-#\r
-# Notes:\r
-#\r
-#------------------------------------------------------------------------------\r
-\r
-#------------------------------------------------------------------------------\r
-# UINT32\r
-# EFIAPI\r
-# InterlockedCompareExchange32 (\r
-# IN UINT32 *Value,\r
-# IN UINT32 CompareValue,\r
-# IN UINT32 ExchangeValue\r
-# );\r
-#------------------------------------------------------------------------------\r
-.global ASM_PFX(InternalSyncCompareExchange32)\r
-ASM_PFX(InternalSyncCompareExchange32):\r
- mov %edx, %eax\r
- lock cmpxchg %r8d, (%rcx)\r
- ret\r
+++ /dev/null
-;------------------------------------------------------------------------------\r
-;\r
-; Copyright (c) 2006, Intel Corporation\r
-; All rights reserved. This program and the accompanying materials\r
-; are licensed and made available under the terms and conditions of the BSD License\r
-; which accompanies this distribution. The full text of the license may be found at\r
-; http://opensource.org/licenses/bsd-license.php\r
-;\r
-; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-;\r
-; Module Name:\r
-;\r
-; InterlockedCompareExchange32.Asm\r
-;\r
-; Abstract:\r
-;\r
-; InterlockedCompareExchange32 function\r
-;\r
-; Notes:\r
-;\r
-;------------------------------------------------------------------------------\r
-\r
- .code\r
-\r
-;------------------------------------------------------------------------------\r
-; UINT32\r
-; EFIAPI\r
-; InterlockedCompareExchange32 (\r
-; IN UINT32 *Value,\r
-; IN UINT32 CompareValue,\r
-; IN UINT32 ExchangeValue\r
-; );\r
-;------------------------------------------------------------------------------\r
-InternalSyncCompareExchange32 PROC\r
- mov eax, edx\r
- lock cmpxchg [rcx], r8d\r
- ret\r
-InternalSyncCompareExchange32 ENDP\r
-\r
- END\r
+++ /dev/null
-/** @file\r
- InterlockedCompareExchange32 function\r
-\r
- Copyright (c) 2006 - 2008, Intel Corporation<BR>\r
- All rights reserved. This program and the accompanying materials\r
- are licensed and made available under the terms and conditions of the BSD License\r
- which accompanies this distribution. The full text of the license may be found at\r
- http://opensource.org/licenses/bsd-license.php\r
-\r
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-**/\r
-\r
-/**\r
- Microsoft Visual Studio 7.1 Function Prototypes for I/O Intrinsics.\r
-**/\r
-\r
-long _InterlockedCompareExchange(\r
- long volatile * Destination,\r
- long Exchange,\r
- long Comperand\r
-);\r
-\r
-#pragma intrinsic(_InterlockedCompareExchange)\r
-\r
-/**\r
- Performs an atomic compare exchange operation on a 32-bit unsigned integer.\r
-\r
- Performs an atomic compare exchange operation on the 32-bit unsigned integer\r
- specified by Value. If Value is equal to CompareValue, then Value is set to\r
- ExchangeValue and CompareValue is returned. If Value is not equal to CompareValue,\r
- then Value is returned. The compare exchange operation must be performed using\r
- MP safe mechanisms.\r
-\r
- @param Value A pointer to the 32-bit value for the compare exchange\r
- operation.\r
- @param CompareValue 32-bit value used in compare operation.\r
- @param ExchangeValue 32-bit value used in exchange operation.\r
-\r
- @return The original *Value before exchange.\r
-\r
-**/\r
-UINT32\r
-EFIAPI\r
-InternalSyncCompareExchange32 (\r
- IN UINT32 *Value,\r
- IN UINT32 CompareValue,\r
- IN UINT32 ExchangeValue\r
- )\r
-{\r
- return _InterlockedCompareExchange (Value, ExchangeValue, CompareValue);\r
-}\r
-\r
+++ /dev/null
-#------------------------------------------------------------------------------\r
-#\r
-# Copyright (c) 2006 - 2008, Intel Corporation\r
-# All rights reserved. This program and the accompanying materials\r
-# are licensed and made available under the terms and conditions of the BSD License\r
-# which accompanies this distribution. The full text of the license may be found at\r
-# http://opensource.org/licenses/bsd-license.php\r
-#\r
-# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-#\r
-# Module Name:\r
-#\r
-# InterlockedCompareExchange64.S\r
-#\r
-# Abstract:\r
-#\r
-# InterlockedCompareExchange64 function\r
-#\r
-# Notes:\r
-#\r
-#------------------------------------------------------------------------------\r
-\r
-\r
-#------------------------------------------------------------------------------\r
-# UINT64\r
-# EFIAPI\r
-# InterlockedCompareExchange64 (\r
-# IN UINT64 *Value,\r
-# IN UINT64 CompareValue,\r
-# IN UINT64 ExchangeValue\r
-# );\r
-#------------------------------------------------------------------------------\r
-.global ASM_PFX(InternalSyncCompareExchange64)\r
-.align 16\r
-ASM_PFX(InternalSyncCompareExchange64):\r
- mov %rdx, %rax\r
- lock cmpxchg %r8,(%rcx)\r
- ret\r
+++ /dev/null
-;------------------------------------------------------------------------------\r
-;\r
-; Copyright (c) 2006, Intel Corporation\r
-; All rights reserved. This program and the accompanying materials\r
-; are licensed and made available under the terms and conditions of the BSD License\r
-; which accompanies this distribution. The full text of the license may be found at\r
-; http://opensource.org/licenses/bsd-license.php\r
-;\r
-; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-;\r
-; Module Name:\r
-;\r
-; InterlockedCompareExchange64.Asm\r
-;\r
-; Abstract:\r
-;\r
-; InterlockedCompareExchange64 function\r
-;\r
-; Notes:\r
-;\r
-;------------------------------------------------------------------------------\r
-\r
- .code\r
-\r
-;------------------------------------------------------------------------------\r
-; UINT64\r
-; EFIAPI\r
-; InterlockedCompareExchange64 (\r
-; IN UINT64 *Value,\r
-; IN UINT64 CompareValue,\r
-; IN UINT64 ExchangeValue\r
-; );\r
-;------------------------------------------------------------------------------\r
-InternalSyncCompareExchange64 PROC\r
- mov rax, rdx\r
- lock cmpxchg [rcx], r8\r
- ret\r
-InternalSyncCompareExchange64 ENDP\r
-\r
- END\r
+++ /dev/null
-/** @file\r
- InterlockedCompareExchange64 function\r
-\r
- Copyright (c) 2006 - 2008, Intel Corporation<BR>\r
- All rights reserved. This program and the accompanying materials\r
- are licensed and made available under the terms and conditions of the BSD License\r
- which accompanies this distribution. The full text of the license may be found at\r
- http://opensource.org/licenses/bsd-license.php\r
-\r
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-**/\r
-\r
-/**\r
- Microsoft Visual Studio 7.1 Function Prototypes for I/O Intrinsics.\r
-**/\r
-\r
-__int64 _InterlockedCompareExchange64(\r
- __int64 volatile * Destination,\r
- __int64 Exchange,\r
- __int64 Comperand\r
-);\r
-\r
-#pragma intrinsic(_InterlockedCompareExchange64)\r
-\r
-/**\r
- Performs an atomic compare exchange operation on a 64-bit unsigned integer.\r
-\r
- Performs an atomic compare exchange operation on the 64-bit unsigned integer specified\r
- by Value. If Value is equal to CompareValue, then Value is set to ExchangeValue and\r
- CompareValue is returned. If Value is not equal to CompareValue, then Value is returned.\r
- The compare exchange operation must be performed using MP safe mechanisms.\r
-\r
- @param Value A pointer to the 64-bit value for the compare exchange\r
- operation.\r
- @param CompareValue 64-bit value used in compare operation.\r
- @param ExchangeValue 64-bit value used in exchange operation.\r
-\r
- @return The original *Value before exchange.\r
-\r
-**/\r
-UINT64\r
-EFIAPI\r
-InternalSyncCompareExchange64 (\r
- IN UINT64 *Value,\r
- IN UINT64 CompareValue,\r
- IN UINT64 ExchangeValue\r
- )\r
-{\r
- return _InterlockedCompareExchange64 (Value, ExchangeValue, CompareValue);\r
-}\r
-\r
+++ /dev/null
-#------------------------------------------------------------------------------\r
-#\r
-# Copyright (c) 2006 - 2008, Intel Corporation\r
-# All rights reserved. This program and the accompanying materials\r
-# are licensed and made available under the terms and conditions of the BSD License\r
-# which accompanies this distribution. The full text of the license may be found at\r
-# http://opensource.org/licenses/bsd-license.php\r
-#\r
-# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-#\r
-# Module Name:\r
-#\r
-# InterlockedDecrement.S\r
-#\r
-# Abstract:\r
-#\r
-# InterlockedDecrement function\r
-#\r
-# Notes:\r
-#\r
-#------------------------------------------------------------------------------\r
-\r
-\r
-#------------------------------------------------------------------------------\r
-# UINT32\r
-# EFIAPI\r
-# InterlockedDecrement (\r
-# IN UINT32 *Value\r
-# );\r
-#------------------------------------------------------------------------------\r
-.global ASM_PFX(InternalSyncDecrement)\r
-ASM_PFX(InternalSyncDecrement):\r
- lock decl (%rcx)\r
- mov (%rcx), %eax\r
- ret\r
+++ /dev/null
-;------------------------------------------------------------------------------\r
-;\r
-; Copyright (c) 2006, Intel Corporation\r
-; All rights reserved. This program and the accompanying materials\r
-; are licensed and made available under the terms and conditions of the BSD License\r
-; which accompanies this distribution. The full text of the license may be found at\r
-; http://opensource.org/licenses/bsd-license.php\r
-;\r
-; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-;\r
-; Module Name:\r
-;\r
-; InterlockedDecrement.Asm\r
-;\r
-; Abstract:\r
-;\r
-; InterlockedDecrement function\r
-;\r
-; Notes:\r
-;\r
-;------------------------------------------------------------------------------\r
-\r
- .code\r
-\r
-;------------------------------------------------------------------------------\r
-; UINT32\r
-; EFIAPI\r
-; InterlockedDecrement (\r
-; IN UINT32 *Value\r
-; );\r
-;------------------------------------------------------------------------------\r
-InternalSyncDecrement PROC\r
- lock dec dword ptr [rcx]\r
- mov eax, [rcx]\r
- ret\r
-InternalSyncDecrement ENDP\r
-\r
- END\r
+++ /dev/null
-/** @file\r
- InterlockedDecrement function\r
-\r
- Copyright (c) 2006 - 2008, Intel Corporation<BR>\r
- All rights reserved. This program and the accompanying materials\r
- are licensed and made available under the terms and conditions of the BSD License\r
- which accompanies this distribution. The full text of the license may be found at\r
- http://opensource.org/licenses/bsd-license.php\r
-\r
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-**/\r
-\r
-/**\r
- Microsoft Visual Studio 7.1 Function Prototypes for I/O Intrinsics.\r
-**/\r
-\r
-long _InterlockedDecrement(\r
- long * lpAddend\r
-);\r
-\r
-#pragma intrinsic(_InterlockedDecrement)\r
-\r
-/**\r
- Performs an atomic decrement of an 32-bit unsigned integer.\r
-\r
- Performs an atomic decrement of the 32-bit unsigned integer specified by\r
- Value and returns the decrement value. The decrement operation must be\r
- performed using MP safe mechanisms. The state of the return value is not\r
- guaranteed to be MP safe.\r
-\r
- @param Value A pointer to the 32-bit value to decrement.\r
-\r
- @return The decrement value.\r
-\r
-**/\r
-UINT32\r
-EFIAPI\r
-InternalSyncDecrement (\r
- IN UINT32 *Value\r
- )\r
-{\r
- return _InterlockedDecrement (Value);\r
-}\r
-\r
+++ /dev/null
-#------------------------------------------------------------------------------\r
-#\r
-# Copyright (c) 2006 - 2008, Intel Corporation\r
-# All rights reserved. This program and the accompanying materials\r
-# are licensed and made available under the terms and conditions of the BSD License\r
-# which accompanies this distribution. The full text of the license may be found at\r
-# http://opensource.org/licenses/bsd-license.php\r
-#\r
-# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-#\r
-# Module Name:\r
-#\r
-# InterlockedIncrement.S\r
-#\r
-# Abstract:\r
-#\r
-# InterlockedIncrement function\r
-#\r
-# Notes:\r
-#\r
-#------------------------------------------------------------------------------\r
-\r
-\r
-#------------------------------------------------------------------------------\r
-# UINT32\r
-# EFIAPI\r
-# InterlockedIncrement (\r
-# IN UINT32 *Value\r
-# );\r
-#------------------------------------------------------------------------------\r
-.global ASM_PFX(InternalSyncIncrement)\r
-ASM_PFX(InternalSyncIncrement):\r
- lock incl (%rcx)\r
- mov (%rcx), %eax\r
- ret\r
+++ /dev/null
-;------------------------------------------------------------------------------\r
-;\r
-; Copyright (c) 2006, Intel Corporation\r
-; All rights reserved. This program and the accompanying materials\r
-; are licensed and made available under the terms and conditions of the BSD License\r
-; which accompanies this distribution. The full text of the license may be found at\r
-; http://opensource.org/licenses/bsd-license.php\r
-;\r
-; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-;\r
-; Module Name:\r
-;\r
-; InterlockedIncrement.Asm\r
-;\r
-; Abstract:\r
-;\r
-; InterlockedIncrement function\r
-;\r
-; Notes:\r
-;\r
-;------------------------------------------------------------------------------\r
-\r
- .code\r
-\r
-;------------------------------------------------------------------------------\r
-; UINT32\r
-; EFIAPI\r
-; InterlockedIncrement (\r
-; IN UINT32 *Value\r
-; );\r
-;------------------------------------------------------------------------------\r
-InternalSyncIncrement PROC\r
- lock inc dword ptr [rcx]\r
- mov eax, [rcx]\r
- ret\r
-InternalSyncIncrement ENDP\r
-\r
- END\r
+++ /dev/null
-/** @file\r
- InterLockedIncrement function\r
-\r
- Copyright (c) 2006 - 2008, Intel Corporation<BR>\r
- All rights reserved. This program and the accompanying materials\r
- are licensed and made available under the terms and conditions of the BSD License\r
- which accompanies this distribution. The full text of the license may be found at\r
- http://opensource.org/licenses/bsd-license.php\r
-\r
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-**/\r
-\r
-/**\r
- Microsoft Visual Studio 7.1 Function Prototypes for I/O Intrinsics.\r
-**/\r
-\r
-long _InterlockedIncrement(\r
- long * lpAddend\r
-);\r
-\r
-#pragma intrinsic(_InterlockedIncrement)\r
-\r
-/**\r
- Performs an atomic increment of an 32-bit unsigned integer.\r
-\r
- Performs an atomic increment of the 32-bit unsigned integer specified by\r
- Value and returns the incremented value. The increment operation must be\r
- performed using MP safe mechanisms. The state of the return value is not\r
- guaranteed to be MP safe.\r
-\r
- @param Value A pointer to the 32-bit value to increment.\r
-\r
- @return The incremented value.\r
-\r
-**/\r
-UINT32\r
-EFIAPI\r
-InternalSyncIncrement (\r
- IN UINT32 *Value\r
- )\r
-{\r
- return _InterlockedIncrement (Value);\r
-}\r
-\r