VirtualBox

Ignore:
Timestamp:
Mar 12, 2019 12:40:12 PM (6 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
129295
Message:

EFI: First step in UDK2018 merge. Does not build yet.

Location:
trunk/src/VBox/Devices/EFI/FirmwareNew
Files:
20 added
2 deleted
26 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/EFI/FirmwareNew

  • trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/BaseSynchronizationLib/BaseSynchronizationLib.inf

    r58466 r77662  
    22#  Base Synchronization Library implementation.
    33#
    4 #  Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.<BR>
     4#  Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.<BR>
    55#  Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
    66#
     
    3131
    3232[Sources.IA32]
     33  Ia32/InternalGetSpinLockProperties.c | MSFT
    3334  Ia32/InterlockedCompareExchange64.c | MSFT
    3435  Ia32/InterlockedCompareExchange32.c | MSFT
     36  Ia32/InterlockedCompareExchange16.c | MSFT
    3537  Ia32/InterlockedDecrement.c | MSFT
    3638  Ia32/InterlockedIncrement.c | MSFT
    3739  SynchronizationMsc.c  | MSFT
    3840
     41  Ia32/InterlockedCompareExchange64.nasm| INTEL
    3942  Ia32/InterlockedCompareExchange64.asm | INTEL
     43  Ia32/InterlockedCompareExchange32.nasm| INTEL
    4044  Ia32/InterlockedCompareExchange32.asm | INTEL
     45  Ia32/InterlockedCompareExchange16.nasm| INTEL
     46  Ia32/InterlockedCompareExchange16.asm | INTEL
     47  Ia32/InterlockedDecrement.nasm| INTEL
    4148  Ia32/InterlockedDecrement.asm | INTEL
     49  Ia32/InterlockedIncrement.nasm| INTEL
    4250  Ia32/InterlockedIncrement.asm | INTEL
    4351  Synchronization.c | INTEL
    4452
     53  Ia32/InternalGetSpinLockProperties.c | GCC
    4554  Ia32/GccInline.c | GCC
    4655  SynchronizationGcc.c  | GCC
    4756
    4857[Sources.X64]
     58  Ia32/InternalGetSpinLockProperties.c | MSFT
    4959  X64/InterlockedCompareExchange64.c | MSFT
    5060  X64/InterlockedCompareExchange32.c | MSFT
     61  X64/InterlockedCompareExchange16.c | MSFT
    5162
     63  X64/InterlockedCompareExchange64.nasm| INTEL
    5264  X64/InterlockedCompareExchange64.asm | INTEL
     65  X64/InterlockedCompareExchange32.nasm| INTEL
    5366  X64/InterlockedCompareExchange32.asm | INTEL
     67  X64/InterlockedCompareExchange16.nasm| INTEL
     68  X64/InterlockedCompareExchange16.asm | INTEL
    5469
    5570  X64/InterlockedDecrement.c | MSFT
     
    5772  SynchronizationMsc.c | MSFT
    5873
     74  X64/InterlockedDecrement.nasm| INTEL
    5975  X64/InterlockedDecrement.asm | INTEL
     76  X64/InterlockedIncrement.nasm| INTEL
    6077  X64/InterlockedIncrement.asm | INTEL
    6178  Synchronization.c | INTEL
    6279
     80  Ia32/InternalGetSpinLockProperties.c | GCC
    6381  X64/GccInline.c | GCC
    6482  SynchronizationGcc.c  | GCC
     
    6886  Ipf/InterlockedCompareExchange64.s
    6987  Ipf/InterlockedCompareExchange32.s
     88  Ipf/InterlockedCompareExchange16.s
     89
     90  Ipf/InternalGetSpinLockProperties.c | MSFT
     91  Ipf/InternalGetSpinLockProperties.c | GCC
    7092
    7193  Synchronization.c     | INTEL
     
    79101[Sources.ARM]
    80102  Synchronization.c
    81   Arm/Synchronization.c
     103  Arm/Synchronization.asm       | RVCT
     104  Arm/Synchronization.S         | GCC
    82105
    83106[Sources.AARCH64]
    84107  Synchronization.c
    85   AArch64/Synchronization.c
     108  AArch64/Synchronization.S
    86109
    87110[Packages]
  • trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/BaseSynchronizationLib/BaseSynchronizationLib.uni

    r58464 r77662  
    1 // /** @file
     1// /** @file
    22// Base Synchronization Library implementation.
    33//
  • trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/BaseSynchronizationLib/BaseSynchronizationLibInternals.h

    r48674 r77662  
    22  Declaration of internal functions in BaseSynchronizationLib.
    33
    4   Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
     4  Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>
    55  This program and the accompanying materials
    66  are licensed and made available under the terms and conditions of the BSD License
     
    6464
    6565/**
     66  Performs an atomic compare exchange operation on a 16-bit unsigned integer.
     67
     68  Performs an atomic compare exchange operation on the 16-bit unsigned integer
     69  specified by Value.  If Value is equal to CompareValue, then Value is set to
     70  ExchangeValue and CompareValue is returned.  If Value is not equal to CompareValue,
     71  then Value is returned.  The compare exchange operation must be performed using
     72  MP safe mechanisms.
     73
     74  @param  Value         A pointer to the 16-bit value for the compare exchange
     75                        operation.
     76  @param  CompareValue  A 16-bit value used in compare operation.
     77  @param  ExchangeValue A 16-bit value used in exchange operation.
     78
     79  @return The original *Value before exchange.
     80
     81**/
     82UINT16
     83EFIAPI
     84InternalSyncCompareExchange16 (
     85  IN      volatile UINT16           *Value,
     86  IN      UINT16                    CompareValue,
     87  IN      UINT16                    ExchangeValue
     88  );
     89
     90
     91/**
    6692  Performs an atomic compare exchange operation on a 32-bit unsigned integer.
    6793
     
    113139  );
    114140
     141/**
     142  Internal function to retrieve the architecture specific spin lock alignment
     143  requirements for optimal spin lock performance.
     144
     145  @return The architecture specific spin lock alignment.
     146
     147**/
     148UINTN
     149InternalGetSpinLockProperties (
     150  VOID
     151  );
     152
    115153#endif
  • trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/BaseSynchronizationLib/Ebc/Synchronization.c

    r58466 r77662  
    1212
    1313**/
     14
     15/**
     16  Performs an atomic compare exchange operation on a 16-bit
     17  unsigned integer.
     18
     19  Performs an atomic compare exchange operation on the 16-bit
     20  unsigned integer specified by Value.  If Value is equal to
     21  CompareValue, then Value is set to ExchangeValue and
     22  CompareValue is returned.  If Value is not equal to
     23  CompareValue, then Value is returned. The compare exchange
     24  operation must be performed using MP safe mechanisms.
     25
     26  @param  Value         A pointer to the 16-bit value for the
     27                        compare exchange operation.
     28  @param  CompareValue  16-bit value used in compare operation.
     29  @param  ExchangeValue 16-bit value used in exchange operation.
     30
     31  @return The original *Value before exchange.
     32
     33**/
     34UINT16
     35EFIAPI
     36InternalSyncCompareExchange16 (
     37  IN      volatile UINT16           *Value,
     38  IN      UINT16                    CompareValue,
     39  IN      UINT16                    ExchangeValue
     40  )
     41{
     42  return *Value != CompareValue ? *Value :
     43           ((*Value = ExchangeValue), CompareValue);
     44}
    1445
    1546/**
  • trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/BaseSynchronizationLib/Ia32/GccInline.c

    r58466 r77662  
    8686
    8787  return Result;
     88}
     89
     90/**
     91  Performs an atomic compare exchange operation on a 16-bit unsigned integer.
     92
     93  Performs an atomic compare exchange operation on the 16-bit unsigned integer
     94  specified by Value.  If Value is equal to CompareValue, then Value is set to
     95  ExchangeValue and CompareValue is returned.  If Value is not equal to CompareValue,
     96  then Value is returned.  The compare exchange operation must be performed using
     97  MP safe mechanisms.
     98
     99
     100  @param  Value         A pointer to the 16-bit value for the compare exchange
     101                        operation.
     102  @param  CompareValue  16-bit value used in compare operation.
     103  @param  ExchangeValue 16-bit value used in exchange operation.
     104
     105  @return The original *Value before exchange.
     106
     107**/
     108UINT16
     109EFIAPI
     110InternalSyncCompareExchange16 (
     111  IN OUT volatile  UINT16           *Value,
     112  IN      UINT16                    CompareValue,
     113  IN      UINT16                    ExchangeValue
     114  )
     115{
     116
     117  __asm__ __volatile__ (
     118    "                     \n\t"
     119    "lock                 \n\t"
     120    "cmpxchgw    %1, %2   \n\t"
     121    : "=a" (CompareValue)
     122    : "q"  (ExchangeValue),
     123      "m"  (*Value),
     124      "0"  (CompareValue)
     125    : "memory",
     126      "cc"
     127    );
     128
     129  return CompareValue;
    88130}
    89131
  • trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/BaseSynchronizationLib/Ia32/InterlockedCompareExchange32.asm

    r48674 r77662  
    11;------------------------------------------------------------------------------
    22;
    3 ; Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
     3; Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>
    44; This program and the accompanying materials
    55; are licensed and made available under the terms and conditions of the BSD License
     
    3030; EFIAPI
    3131; InternalSyncCompareExchange32 (
    32 ;   IN      UINT32                    *Value,
     32;   IN      volatile UINT32           *Value,
    3333;   IN      UINT32                    CompareValue,
    3434;   IN      UINT32                    ExchangeValue
  • trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/BaseSynchronizationLib/Ia32/InterlockedCompareExchange32.c

    r48674 r77662  
    22  InterlockedCompareExchange32 function
    33
    4   Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
     4  Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>
    55  This program and the accompanying materials
    66  are licensed and made available under the terms and conditions of the BSD License
     
    3636EFIAPI
    3737InternalSyncCompareExchange32 (
    38   IN      UINT32                    *Value,
     38  IN      volatile UINT32           *Value,
    3939  IN      UINT32                    CompareValue,
    4040  IN      UINT32                    ExchangeValue
  • trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/BaseSynchronizationLib/Ia32/InterlockedCompareExchange64.asm

    r48674 r77662  
    11;------------------------------------------------------------------------------
    22;
    3 ; Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
     3; Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>
    44; This program and the accompanying materials
    55; are licensed and made available under the terms and conditions of the BSD License
     
    3030; EFIAPI
    3131; InternalSyncCompareExchange64 (
    32 ;   IN      UINT64                    *Value,
     32;   IN      volatile UINT64           *Value,
    3333;   IN      UINT64                    CompareValue,
    3434;   IN      UINT64                    ExchangeValue
  • trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/BaseSynchronizationLib/Ia32/InterlockedCompareExchange64.c

    r48674 r77662  
    22  InterlockedCompareExchange64 function
    33
    4   Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
     4  Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>
    55  This program and the accompanying materials
    66  are licensed and made available under the terms and conditions of the BSD License
     
    3535EFIAPI
    3636InternalSyncCompareExchange64 (
    37   IN      UINT64                    *Value,
     37  IN      volatile UINT64           *Value,
    3838  IN      UINT64                    CompareValue,
    3939  IN      UINT64                    ExchangeValue
  • trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/BaseSynchronizationLib/Ia32/InterlockedDecrement.asm

    r48674 r77662  
    11;------------------------------------------------------------------------------
    22;
    3 ; Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
     3; Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>
    44; This program and the accompanying materials
    55; are licensed and made available under the terms and conditions of the BSD License
     
    3030; EFIAPI
    3131; InternalSyncDecrement (
    32 ;   IN      UINT32                    *Value
     32;   IN      volatile UINT32           *Value
    3333;   );
    3434;------------------------------------------------------------------------------
  • trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/BaseSynchronizationLib/Ia32/InterlockedDecrement.c

    r48674 r77662  
    22  InterlockedDecrement function
    33
    4   Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
     4  Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>
    55  This program and the accompanying materials
    66  are licensed and made available under the terms and conditions of the BSD License
     
    3232EFIAPI
    3333InternalSyncDecrement (
    34   IN      UINT32                    *Value
     34  IN      volatile UINT32           *Value
    3535  )
    3636{
  • trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/BaseSynchronizationLib/Ia32/InterlockedIncrement.asm

    r48674 r77662  
    11;------------------------------------------------------------------------------
    22;
    3 ; Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
     3; Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>
    44; This program and the accompanying materials
    55; are licensed and made available under the terms and conditions of the BSD License
     
    3030; EFIAPI
    3131; InternalSyncIncrement (
    32 ;   IN      UINT32                    *Value
     32;   IN      volatile UINT32           *Value
    3333;   );
    3434;------------------------------------------------------------------------------
  • trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/BaseSynchronizationLib/Ia32/InterlockedIncrement.c

    r48674 r77662  
    22  InterLockedIncrement function
    33
    4   Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
     4  Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>
    55  This program and the accompanying materials
    66  are licensed and made available under the terms and conditions of the BSD License
     
    3232EFIAPI
    3333InternalSyncIncrement (
    34   IN      UINT32                    *Value
     34  IN      volatile UINT32           *Value
    3535  )
    3636{
  • trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/BaseSynchronizationLib/Synchronization.c

    r58466 r77662  
    22  Implementation of synchronization functions.
    33
    4   Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>
     4  Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>
    55  This program and the accompanying materials
    66  are licensed and made available under the terms and conditions of the BSD License
     
    105105  INT64   Delta;
    106106
    107   if (PcdGet32 (PcdSpinLockTimeout) > 0) {
     107  if (PcdGet32 (PcdSpinLockTimeout) == 0) {
     108    while (!AcquireSpinLockOrFail (SpinLock)) {
     109      CpuPause ();
     110    }
     111  } else if (!AcquireSpinLockOrFail (SpinLock)) {
    108112    //
    109113    // Get the current timer value
     
    149153      ASSERT (Total < Timeout);
    150154    }
    151   } else {
    152     while (!AcquireSpinLockOrFail (SpinLock)) {
    153       CpuPause ();
    154     }
    155155  }
    156156  return SpinLock;
     
    245245EFIAPI
    246246InterlockedIncrement (
    247   IN      UINT32                    *Value
     247  IN      volatile UINT32           *Value
    248248  )
    249249{
     
    270270EFIAPI
    271271InterlockedDecrement (
    272   IN      UINT32                    *Value
     272  IN      volatile UINT32           *Value
    273273  )
    274274{
    275275  ASSERT (Value != NULL);
    276276  return InternalSyncDecrement (Value);
     277}
     278
     279/**
     280  Performs an atomic compare exchange operation on a 16-bit unsigned integer.
     281
     282  Performs an atomic compare exchange operation on the 16-bit unsigned integer
     283  specified by Value.  If Value is equal to CompareValue, then Value is set to
     284  ExchangeValue and CompareValue is returned.  If Value is not equal to CompareValue,
     285  then Value is returned.  The compare exchange operation must be performed using
     286  MP safe mechanisms.
     287
     288  If Value is NULL, then ASSERT().
     289
     290  @param  Value         A pointer to the 16-bit value for the compare exchange
     291                        operation.
     292  @param  CompareValue  16-bit value used in compare operation.
     293  @param  ExchangeValue 16-bit value used in exchange operation.
     294
     295  @return The original *Value before exchange.
     296
     297**/
     298UINT16
     299EFIAPI
     300InterlockedCompareExchange16 (
     301  IN OUT  volatile UINT16           *Value,
     302  IN      UINT16                    CompareValue,
     303  IN      UINT16                    ExchangeValue
     304  )
     305{
     306  ASSERT (Value != NULL);
     307  return InternalSyncCompareExchange16 (Value, CompareValue, ExchangeValue);
    277308}
    278309
     
    299330EFIAPI
    300331InterlockedCompareExchange32 (
    301   IN OUT  UINT32                    *Value,
     332  IN OUT  volatile UINT32           *Value,
    302333  IN      UINT32                    CompareValue,
    303334  IN      UINT32                    ExchangeValue
     
    329360EFIAPI
    330361InterlockedCompareExchange64 (
    331   IN OUT  UINT64                    *Value,
     362  IN OUT  volatile UINT64           *Value,
    332363  IN      UINT64                    CompareValue,
    333364  IN      UINT64                    ExchangeValue
     
    359390EFIAPI
    360391InterlockedCompareExchangePointer (
    361   IN OUT  VOID                      **Value,
     392  IN OUT  VOID                      * volatile *Value,
    362393  IN      VOID                      *CompareValue,
    363394  IN      VOID                      *ExchangeValue
     
    371402    case sizeof (UINT32):
    372403      return (VOID*)(UINTN)InterlockedCompareExchange32 (
    373                              (UINT32*)Value,
     404                             (volatile UINT32 *)Value,
    374405                             (UINT32)(UINTN)CompareValue,
    375406                             (UINT32)(UINTN)ExchangeValue
     
    377408    case sizeof (UINT64):
    378409      return (VOID*)(UINTN)InterlockedCompareExchange64 (
    379                              (UINT64*)Value,
     410                             (volatile UINT64 *)Value,
    380411                             (UINT64)(UINTN)CompareValue,
    381412                             (UINT64)(UINTN)ExchangeValue
  • trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/BaseSynchronizationLib/SynchronizationGcc.c

    r58466 r77662  
    22  Implementation of synchronization functions.
    33
    4   Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>
     4  Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>
    55  Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
    66  This program and the accompanying materials
     
    4646  )
    4747{
    48   return 32;
     48  return InternalGetSpinLockProperties ();
    4949}
    5050
     
    115115  INT64   Delta;
    116116
    117   if (PcdGet32 (PcdSpinLockTimeout) > 0) {
     117  if (PcdGet32 (PcdSpinLockTimeout) == 0) {
     118    while (!AcquireSpinLockOrFail (SpinLock)) {
     119      CpuPause ();
     120    }
     121  } else if (!AcquireSpinLockOrFail (SpinLock)) {
    118122    //
    119123    // Get the current timer value
     
    159163      ASSERT (Total < Timeout);
    160164    }
    161   } else {
    162     while (!AcquireSpinLockOrFail (SpinLock)) {
    163       CpuPause ();
    164     }
    165165  }
    166166  return SpinLock;
     
    261261EFIAPI
    262262InterlockedIncrement (
    263   IN      UINT32                    *Value
     263  IN      volatile UINT32           *Value
    264264  )
    265265{
     
    286286EFIAPI
    287287InterlockedDecrement (
    288   IN      UINT32                    *Value
     288  IN      volatile UINT32           *Value
    289289  )
    290290{
    291291  ASSERT (Value != NULL);
    292292  return InternalSyncDecrement (Value);
     293}
     294
     295/**
     296  Performs an atomic compare exchange operation on a 16-bit unsigned integer.
     297
     298  Performs an atomic compare exchange operation on the 16-bit unsigned integer
     299  specified by Value.  If Value is equal to CompareValue, then Value is set to
     300  ExchangeValue and CompareValue is returned.  If Value is not equal to CompareValue,
     301  then Value is returned.  The compare exchange operation must be performed using
     302  MP safe mechanisms.
     303
     304  If Value is NULL, then ASSERT().
     305
     306  @param  Value         A pointer to the 16-bit value for the compare exchange
     307                        operation.
     308  @param  CompareValue  A 16-bit value used in compare operation.
     309  @param  ExchangeValue A 16-bit value used in exchange operation.
     310
     311  @return The original *Value before exchange.
     312
     313**/
     314UINT16
     315EFIAPI
     316InterlockedCompareExchange16 (
     317  IN OUT  volatile UINT16           *Value,
     318  IN      UINT16                    CompareValue,
     319  IN      UINT16                    ExchangeValue
     320  )
     321{
     322  ASSERT (Value != NULL);
     323  return InternalSyncCompareExchange16 (Value, CompareValue, ExchangeValue);
    293324}
    294325
     
    315346EFIAPI
    316347InterlockedCompareExchange32 (
    317   IN OUT  UINT32                    *Value,
     348  IN OUT  volatile UINT32           *Value,
    318349  IN      UINT32                    CompareValue,
    319350  IN      UINT32                    ExchangeValue
     
    345376EFIAPI
    346377InterlockedCompareExchange64 (
    347   IN OUT  UINT64                    *Value,
     378  IN OUT  volatile UINT64           *Value,
    348379  IN      UINT64                    CompareValue,
    349380  IN      UINT64                    ExchangeValue
     
    375406EFIAPI
    376407InterlockedCompareExchangePointer (
    377   IN OUT  VOID                      **Value,
     408  IN OUT  VOID                      * volatile *Value,
    378409  IN      VOID                      *CompareValue,
    379410  IN      VOID                      *ExchangeValue
     
    387418    case sizeof (UINT32):
    388419      return (VOID*)(UINTN)InterlockedCompareExchange32 (
    389                              (UINT32*)Value,
     420                             (volatile UINT32 *)Value,
    390421                             (UINT32)(UINTN)CompareValue,
    391422                             (UINT32)(UINTN)ExchangeValue
     
    393424    case sizeof (UINT64):
    394425      return (VOID*)(UINTN)InterlockedCompareExchange64 (
    395                              (UINT64*)Value,
     426                             (volatile UINT64 *)Value,
    396427                             (UINT64)(UINTN)CompareValue,
    397428                             (UINT64)(UINTN)ExchangeValue
  • trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/BaseSynchronizationLib/SynchronizationMsc.c

    r58466 r77662  
    22  Implementation of synchronization functions.
    33
    4   Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>
     4  Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>
    55  This program and the accompanying materials
    66  are licensed and made available under the terms and conditions of the BSD License
     
    4848  )
    4949{
    50   return 32;
     50  return InternalGetSpinLockProperties ();
    5151}
    5252
     
    117117  INT64   Delta;
    118118
    119   if (PcdGet32 (PcdSpinLockTimeout) > 0) {
     119  if (PcdGet32 (PcdSpinLockTimeout) == 0) {
     120    while (!AcquireSpinLockOrFail (SpinLock)) {
     121      CpuPause ();
     122    }
     123  } else if (!AcquireSpinLockOrFail (SpinLock)) {
    120124    //
    121125    // Get the current timer value
     
    161165      ASSERT (Total < Timeout);
    162166    }
    163   } else {
    164     while (!AcquireSpinLockOrFail (SpinLock)) {
    165       CpuPause ();
    166     }
    167167  }
    168168  return SpinLock;
     
    263263EFIAPI
    264264InterlockedIncrement (
    265   IN      UINT32                    *Value
     265  IN      volatile UINT32           *Value
    266266  )
    267267{
     
    288288EFIAPI
    289289InterlockedDecrement (
    290   IN      UINT32                    *Value
     290  IN      volatile UINT32           *Value
    291291  )
    292292{
    293293  ASSERT (Value != NULL);
    294294  return InternalSyncDecrement (Value);
     295}
     296
     297/**
     298  Performs an atomic compare exchange operation on a 16-bit unsigned integer.
     299
     300  Performs an atomic compare exchange operation on the 16-bit unsigned integer
     301  specified by Value.  If Value is equal to CompareValue, then Value is set to
     302  ExchangeValue and CompareValue is returned.  If Value is not equal to CompareValue,
     303  then Value is returned.  The compare exchange operation must be performed using
     304  MP safe mechanisms.
     305
     306  If Value is NULL, then ASSERT().
     307
     308  @param  Value         A pointer to the 16-bit value for the compare exchange
     309                        operation.
     310  @param  CompareValue  A 16-bit value used in a compare operation.
     311  @param  ExchangeValue A 16-bit value used in an exchange operation.
     312
     313  @return The original *Value before exchange.
     314
     315**/
     316UINT16
     317EFIAPI
     318InterlockedCompareExchange16 (
     319  IN OUT  volatile UINT16           *Value,
     320  IN      UINT16                    CompareValue,
     321  IN      UINT16                    ExchangeValue
     322  )
     323{
     324  ASSERT (Value != NULL);
     325  return InternalSyncCompareExchange16 (Value, CompareValue, ExchangeValue);
    295326}
    296327
     
    317348EFIAPI
    318349InterlockedCompareExchange32 (
    319   IN OUT  UINT32                    *Value,
     350  IN OUT  volatile UINT32           *Value,
    320351  IN      UINT32                    CompareValue,
    321352  IN      UINT32                    ExchangeValue
     
    347378EFIAPI
    348379InterlockedCompareExchange64 (
    349   IN OUT  UINT64                    *Value,
     380  IN OUT  volatile UINT64           *Value,
    350381  IN      UINT64                    CompareValue,
    351382  IN      UINT64                    ExchangeValue
     
    377408EFIAPI
    378409InterlockedCompareExchangePointer (
    379   IN OUT  VOID                      **Value,
     410  IN OUT  VOID                      * volatile *Value,
    380411  IN      VOID                      *CompareValue,
    381412  IN      VOID                      *ExchangeValue
     
    389420    case sizeof (UINT32):
    390421      return (VOID*)(UINTN)InterlockedCompareExchange32 (
    391                              (UINT32*)Value,
     422                             (volatile UINT32*)Value,
    392423                             (UINT32)(UINTN)CompareValue,
    393424                             (UINT32)(UINTN)ExchangeValue
     
    395426    case sizeof (UINT64):
    396427      return (VOID*)(UINTN)InterlockedCompareExchange64 (
    397                              (UINT64*)Value,
     428                             (volatile UINT64*)Value,
    398429                             (UINT64)(UINTN)CompareValue,
    399430                             (UINT64)(UINTN)ExchangeValue
  • trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/BaseSynchronizationLib/X64/GccInline.c

    r58466 r77662  
    9090
    9191/**
     92  Performs an atomic compare exchange operation on a 16-bit unsigned integer.
     93
     94  Performs an atomic compare exchange operation on the 16-bit unsigned integer
     95  specified by Value.  If Value is equal to CompareValue, then Value is set to
     96  ExchangeValue and CompareValue is returned.  If Value is not equal to CompareValue,
     97  then Value is returned.  The compare exchange operation must be performed using
     98  MP safe mechanisms.
     99
     100
     101  @param  Value         A pointer to the 16-bit value for the compare exchange
     102                        operation.
     103  @param  CompareValue  16-bit value used in compare operation.
     104  @param  ExchangeValue 16-bit value used in exchange operation.
     105
     106  @return The original *Value before exchange.
     107
     108**/
     109UINT16
     110EFIAPI
     111InternalSyncCompareExchange16 (
     112  IN OUT volatile  UINT16           *Value,
     113  IN      UINT16                    CompareValue,
     114  IN      UINT16                    ExchangeValue
     115  )
     116{
     117
     118
     119  __asm__ __volatile__ (
     120    "lock                 \n\t"
     121    "cmpxchgw    %3, %1       "
     122    : "=a" (CompareValue),
     123      "=m" (*Value)
     124    : "a"  (CompareValue),
     125      "r"  (ExchangeValue),
     126      "m"  (*Value)
     127    : "memory",
     128      "cc"
     129    );
     130
     131  return CompareValue;
     132}
     133
     134
     135/**
    92136  Performs an atomic compare exchange operation on a 32-bit unsigned integer.
    93137
  • trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/BaseSynchronizationLib/X64/InterlockedCompareExchange32.asm

    r48674 r77662  
    11;------------------------------------------------------------------------------
    22;
    3 ; Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
     3; Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>
    44; This program and the accompanying materials
    55; are licensed and made available under the terms and conditions of the BSD License
     
    2727; UINT32
    2828; EFIAPI
    29 ; InterlockedCompareExchange32 (
    30 ;   IN      UINT32                    *Value,
     29; InternalSyncCompareExchange32 (
     30;   IN      volatile UINT32           *Value,
    3131;   IN      UINT32                    CompareValue,
    3232;   IN      UINT32                    ExchangeValue
  • trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/BaseSynchronizationLib/X64/InterlockedCompareExchange32.c

    r48674 r77662  
    22  InterlockedCompareExchange32 function
    33
    4   Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
     4  Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>
    55  This program and the accompanying materials
    66  are licensed and made available under the terms and conditions of the BSD License
     
    4545EFIAPI
    4646InternalSyncCompareExchange32 (
    47   IN      UINT32                    *Value,
     47  IN      volatile UINT32           *Value,
    4848  IN      UINT32                    CompareValue,
    4949  IN      UINT32                    ExchangeValue
  • trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/BaseSynchronizationLib/X64/InterlockedCompareExchange64.asm

    r48674 r77662  
    11;------------------------------------------------------------------------------
    22;
    3 ; Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
     3; Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>
    44; This program and the accompanying materials
    55; are licensed and made available under the terms and conditions of the BSD License
     
    2727; UINT64
    2828; EFIAPI
    29 ; InterlockedCompareExchange64 (
    30 ;   IN      UINT64                    *Value,
     29; InternalSyncCompareExchange64 (
     30;   IN      volatile UINT64           *Value,
    3131;   IN      UINT64                    CompareValue,
    3232;   IN      UINT64                    ExchangeValue
  • trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/BaseSynchronizationLib/X64/InterlockedCompareExchange64.c

    r48674 r77662  
    22  InterlockedCompareExchange64 function
    33
    4   Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
     4  Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>
    55  This program and the accompanying materials
    66  are licensed and made available under the terms and conditions of the BSD License
     
    4444EFIAPI
    4545InternalSyncCompareExchange64 (
    46   IN      UINT64                    *Value,
     46  IN      volatile UINT64           *Value,
    4747  IN      UINT64                    CompareValue,
    4848  IN      UINT64                    ExchangeValue
  • trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/BaseSynchronizationLib/X64/InterlockedDecrement.asm

    r48674 r77662  
    11;------------------------------------------------------------------------------
    22;
    3 ; Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
     3; Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>
    44; This program and the accompanying materials
    55; are licensed and made available under the terms and conditions of the BSD License
     
    2727; UINT32
    2828; EFIAPI
    29 ; InterlockedDecrement (
    30 ;   IN      UINT32                    *Value
     29; InternalSyncDecrement (
     30;   IN      volatile UINT32           *Value
    3131;   );
    3232;------------------------------------------------------------------------------
  • trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/BaseSynchronizationLib/X64/InterlockedDecrement.c

    r48674 r77662  
    22  InterlockedDecrement function
    33
    4   Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
     4  Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>
    55  This program and the accompanying materials
    66  are licensed and made available under the terms and conditions of the BSD License
     
    3939EFIAPI
    4040InternalSyncDecrement (
    41   IN      UINT32                    *Value
     41  IN      volatile UINT32           *Value
    4242  )
    4343{
    44   return _InterlockedDecrement (Value);
     44  return _InterlockedDecrement ((long *)(UINTN)(Value));
    4545}
    4646
  • trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/BaseSynchronizationLib/X64/InterlockedIncrement.asm

    r48674 r77662  
    11;------------------------------------------------------------------------------
    22;
    3 ; Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
     3; Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>
    44; This program and the accompanying materials
    55; are licensed and made available under the terms and conditions of the BSD License
     
    2727; UINT32
    2828; EFIAPI
    29 ; InterlockedIncrement (
    30 ;   IN      UINT32                    *Value
     29; InternalSyncIncrement (
     30;   IN      volatile UINT32           *Value
    3131;   );
    3232;------------------------------------------------------------------------------
  • trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/BaseSynchronizationLib/X64/InterlockedIncrement.c

    r48674 r77662  
    22  InterLockedIncrement function
    33
    4   Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR>
     4  Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>
    55  This program and the accompanying materials
    66  are licensed and made available under the terms and conditions of the BSD License
     
    3939EFIAPI
    4040InternalSyncIncrement (
    41   IN      UINT32                    *Value
     41  IN      volatile UINT32           *Value
    4242  )
    4343{
    44   return _InterlockedIncrement (Value);
     44  return _InterlockedIncrement ((long *)(UINTN)(Value));
    4545}
    4646
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette