All of lore.kernel.org
 help / color / mirror / Atom feed
From: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
To: Anthony PERARD <anthony.perard@citrix.com>
Cc: EDK2 devel <edk2-devel@lists.sourceforge.net>,
	Xen Devel <xen-devel@lists.xen.org>
Subject: Re: [PATCH v2 07/18] OvmfPkg/XenBusDxe: Add InterlockedCompareExchange16.
Date: Wed, 10 Sep 2014 16:09:43 -0400	[thread overview]
Message-ID: <20140910200943.GH3556@laptop.dumpdata.com> (raw)
In-Reply-To: <1409849473-9268-8-git-send-email-anthony.perard@citrix.com>

On Thu, Sep 04, 2014 at 05:51:02PM +0100, Anthony PERARD wrote:
> This is a copy of InterlockedCompareExchange32 from the
> BaseSynchronizationLib.
> 
> The function will be used in the next patch.

Please spell out the name of it. Such as:

in the "OvmfPkg/XenBusDxe: Add Grant Table functions" patch.

> 
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
> 
> ---
> Change in V2:
> - Add intel compilation code
>   MSFT code is not compied over because I don't know how it works.

Not sure I understand that sentence. Which is the 'MSFT' code? The 'c'
or the assembler? Or is s/compied/copied/ ?


> ---
>  OvmfPkg/XenBusDxe/InterlockedCompareExchange16.h   | 15 ++++++++
>  .../XenBusDxe/InterlockedCompareExchange16Intel.c  | 32 +++++++++++++++++
>  .../XenBusDxe/X64/InterlockedCompareExchange16.asm | 41 ++++++++++++++++++++++
>  .../XenBusDxe/X64/InterlockedCompareExchange16.c   | 41 ++++++++++++++++++++++
>  OvmfPkg/XenBusDxe/XenBusDxe.inf                    |  4 +++
>  5 files changed, 133 insertions(+)
>  create mode 100644 OvmfPkg/XenBusDxe/InterlockedCompareExchange16.h
>  create mode 100644 OvmfPkg/XenBusDxe/InterlockedCompareExchange16Intel.c
>  create mode 100644 OvmfPkg/XenBusDxe/X64/InterlockedCompareExchange16.asm
>  create mode 100644 OvmfPkg/XenBusDxe/X64/InterlockedCompareExchange16.c
> 
> diff --git a/OvmfPkg/XenBusDxe/InterlockedCompareExchange16.h b/OvmfPkg/XenBusDxe/InterlockedCompareExchange16.h
> new file mode 100644
> index 0000000..9067882
> --- /dev/null
> +++ b/OvmfPkg/XenBusDxe/InterlockedCompareExchange16.h
> @@ -0,0 +1,15 @@
> +UINT16
> +EFIAPI
> +InternalSyncCompareExchange16 (
> +  IN      UINT16                    *Value,
> +  IN      UINT16                    CompareValue,
> +  IN      UINT16                    ExchangeValue
> +  );
> +
> +UINT16
> +EFIAPI
> +InterlockedCompareExchange16 (
> +  IN OUT volatile  UINT16           *Value,
> +  IN      UINT16                    CompareValue,
> +  IN      UINT16                    ExchangeValue
> +  );
> diff --git a/OvmfPkg/XenBusDxe/InterlockedCompareExchange16Intel.c b/OvmfPkg/XenBusDxe/InterlockedCompareExchange16Intel.c
> new file mode 100644
> index 0000000..bb40e70
> --- /dev/null
> +++ b/OvmfPkg/XenBusDxe/InterlockedCompareExchange16Intel.c
> @@ -0,0 +1,32 @@
> +#include "InterlockedCompareExchange16.h"
> +
> +/**
> +  Performs an atomic compare exchange operation on a 16-bit unsigned integer.
> +
> +  Performs an atomic compare exchange operation on the 16-bit unsigned integer
> +  specified by Value.  If Value is equal to CompareValue, then Value is set to
> +  ExchangeValue and CompareValue is returned.  If Value is not equal to CompareValue,
> +  then Value is returned.  The compare exchange operation must be performed using
> +  MP safe mechanisms.
> +
> +  If Value is NULL, then ASSERT().
> +
> +  @param  Value         A pointer to the 16-bit value for the compare exchange
> +                        operation.
> +  @param  CompareValue  16-bit value used in compare operation.
> +  @param  ExchangeValue 16-bit value used in exchange operation.
> +
> +  @return The original *Value before exchange.
> +
> +**/
> +UINT16
> +EFIAPI
> +InterlockedCompareExchange16 (
> +  IN OUT  UINT16                    *Value,
> +  IN      UINT16                    CompareValue,
> +  IN      UINT16                    ExchangeValue
> +  )
> +{
> +  ASSERT (Value != NULL);
> +  return InternalSyncCompareExchange16 (Value, CompareValue, ExchangeValue);
> +}
> diff --git a/OvmfPkg/XenBusDxe/X64/InterlockedCompareExchange16.asm b/OvmfPkg/XenBusDxe/X64/InterlockedCompareExchange16.asm
> new file mode 100644
> index 0000000..b23e421
> --- /dev/null
> +++ b/OvmfPkg/XenBusDxe/X64/InterlockedCompareExchange16.asm
> @@ -0,0 +1,41 @@
> +;------------------------------------------------------------------------------
> +;
> +; Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
> +; This program and the accompanying materials
> +; are licensed and made available under the terms and conditions of the BSD License
> +; which accompanies this distribution.  The full text of the license may be found at
> +; http://opensource.org/licenses/bsd-license.php.
> +;
> +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
> +;
> +; Module Name:
> +;
> +;   InterlockedCompareExchange16.Asm
> +;
> +; Abstract:
> +;
> +;   InterlockedCompareExchange16 function
> +;
> +; Notes:
> +;
> +;------------------------------------------------------------------------------
> +
> +    .code
> +
> +;------------------------------------------------------------------------------
> +; UINT16
> +; EFIAPI
> +; InterlockedCompareExchange16 (
> +;   IN      UINT16                    *Value,
> +;   IN      UINT16                    CompareValue,
> +;   IN      UINT16                    ExchangeValue
> +;   );
> +;------------------------------------------------------------------------------
> +InternalSyncCompareExchange16   PROC
> +    mov     eax, edx
> +    lock    cmpxchg [rcx], r8w
> +    ret
> +InternalSyncCompareExchange16   ENDP
> +
> +    END
> diff --git a/OvmfPkg/XenBusDxe/X64/InterlockedCompareExchange16.c b/OvmfPkg/XenBusDxe/X64/InterlockedCompareExchange16.c
> new file mode 100644
> index 0000000..64962ba
> --- /dev/null
> +++ b/OvmfPkg/XenBusDxe/X64/InterlockedCompareExchange16.c
> @@ -0,0 +1,41 @@
> +// Took from BaseSynchronizationLib, and replaced 32 by 16
> +/**
> +  Performs an atomic compare exchange operation on a 16-bit unsigned integer.
> +
> +  Performs an atomic compare exchange operation on the 16-bit unsigned integer
> +  specified by Value.  If Value is equal to CompareValue, then Value is set to
> +  ExchangeValue and CompareValue is returned.  If Value is not equal to CompareValue,
> +  then Value is returned.  The compare exchange operation must be performed using
> +  MP safe mechanisms.
> +
> +
> +  @param  Value         A pointer to the 16-bit value for the compare exchange
> +                        operation.
> +  @param  CompareValue  16-bit value used in compare operation.
> +  @param  ExchangeValue 16-bit value used in exchange operation.
> +
> +  @return The original *Value before exchange.
> +
> +**/
> +UINT16
> +EFIAPI
> +InterlockedCompareExchange16 (
> +  IN OUT volatile  UINT16           *Value,
> +  IN      UINT16                    CompareValue,
> +  IN      UINT16                    ExchangeValue
> +  )
> +{
> +  __asm__ __volatile__ (
> +    "lock                 \n\t"
> +    "cmpxchgw    %3, %1       "
> +    : "=a" (CompareValue),    // %0
> +      "=m" (*Value)           // %1
> +    : "a"  (CompareValue),    // %2
> +      "r"  (ExchangeValue),   // %3 
> +      "m"  (*Value)
> +    : "memory",
> +      "cc"
> +    );
> +    
> +  return CompareValue;
> +}
> diff --git a/OvmfPkg/XenBusDxe/XenBusDxe.inf b/OvmfPkg/XenBusDxe/XenBusDxe.inf
> index aed2359..612c3db 100644
> --- a/OvmfPkg/XenBusDxe/XenBusDxe.inf
> +++ b/OvmfPkg/XenBusDxe/XenBusDxe.inf
> @@ -33,10 +33,14 @@
>    ComponentName.h
>    XenHypercall.c
>    XenHypercall.h
> +  InterlockedCompareExchange16.h
>  
>  [Sources.X64]
>    X64/hypercall.S
>    X64/hypercall.asm
> +  X64/InterlockedCompareExchange16.c | GCC
> +  X64/InterlockedCompareExchange16.asm | INTEL
> +  InterlockedCompareExchange16Intel.c | INTEL
>  
>  [LibraryClasses]
>    UefiDriverEntryPoint
> -- 
> Anthony PERARD
> 
> 
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.xen.org
> http://lists.xen.org/xen-devel

  parent reply	other threads:[~2014-09-10 20:09 UTC|newest]

Thread overview: 50+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1409849473-9268-1-git-send-email-anthony.perard@citrix.com>
2014-09-04 16:50 ` [PATCH v2 01/18] OvmfPkg: Add public headers from Xen Project Anthony PERARD
2014-09-04 16:50 ` [PATCH v2 02/18] OvmfPkg: Add basic skeleton for the XenBus bus driver Anthony PERARD
2014-09-04 16:50 ` [PATCH v2 03/18] OvmfPkg/XenBusDxe: Add device state struct and create an ExitBoot services event Anthony PERARD
2014-09-04 16:50 ` [PATCH v2 04/18] OvmfPkg/XenBusDxe: Add support to make Xen Hypercalls Anthony PERARD
2014-09-04 16:51 ` [PATCH v2 05/18] OvmfPkg/XenBusDxe: Open PciIo protocol Anthony PERARD
2014-09-04 16:51 ` [PATCH v2 06/18] OvmfPkg: Introduce XenBus Protocol Anthony PERARD
2014-09-04 16:51 ` [PATCH v2 07/18] OvmfPkg/XenBusDxe: Add InterlockedCompareExchange16 Anthony PERARD
2014-09-04 16:51 ` [PATCH v2 08/18] OvmfPkg/XenBusDxe: Add Grant Table functions Anthony PERARD
2014-09-04 16:51 ` [PATCH v2 09/18] OvmfPkg/XenBusDxe: Add Event Channel Notify Anthony PERARD
2014-09-04 16:51 ` [PATCH v2 10/18] OvmfPkg/XenBusDxe: Add TestAndClearBit Anthony PERARD
2014-09-04 16:51 ` [PATCH v2 11/18] OvmfPkg/XenBusDxe: Add XenStore client implementation Anthony PERARD
2014-09-04 16:51 ` [PATCH v2 12/18] OvmfPkg/XenBusDxe: Add an helper AsciiStrDup Anthony PERARD
2014-09-04 16:51 ` [PATCH v2 13/18] OvmfPkg/XenBusDxe: Add XenStore function into the XenBus protocol Anthony PERARD
2014-09-04 16:51 ` [PATCH v2 14/18] OvmfPkg/XenBusDxe: Indroduce XenBus support itself Anthony PERARD
2014-09-04 16:51 ` [PATCH v2 15/18] OvmfPkg/XenBusDxe: Add Event Channel into XenBus protocol Anthony PERARD
2014-09-04 16:51 ` [PATCH v2 16/18] OvmfPkg/XenPvBlkDxe: Xen PV Block device, initial skeleton Anthony PERARD
2014-09-04 16:51 ` [PATCH v2 17/18] OvmfPkg/XenPvBlkDxe: Add BlockFront client Anthony PERARD
2014-09-04 16:51 ` [PATCH v2 18/18] OvmfPkg/XenPvBlkDxe: Add BlockIo Anthony PERARD
2014-09-04 18:01 ` [edk2] [PATCH v2 00/18] Introducing Xen PV block driver to OVMF Laszlo Ersek
     [not found] ` <5408A8E3.2020805@redhat.com>
2014-09-05 13:34   ` Anthony PERARD
     [not found]   ` <20140905133440.GB1654@perard.uk.xensource.com>
2014-09-05 19:30     ` Jordan Justen
2014-09-05 21:14     ` Laszlo Ersek
     [not found]     ` <CAFe8ug86UtwYQY-1P5wp6tQ_2Yi2fwgNU7+knHV0JH4SDz07jQ@mail.gmail.com>
2014-09-08 15:36       ` Anthony PERARD
     [not found] ` <1409849473-9268-2-git-send-email-anthony.perard@citrix.com>
2014-09-10 19:43   ` [PATCH v2 01/18] OvmfPkg: Add public headers from Xen Project Konrad Rzeszutek Wilk
     [not found] ` <1409849473-9268-3-git-send-email-anthony.perard@citrix.com>
2014-09-10 19:49   ` [PATCH v2 02/18] OvmfPkg: Add basic skeleton for the XenBus bus driver Konrad Rzeszutek Wilk
     [not found] ` <1409849473-9268-4-git-send-email-anthony.perard@citrix.com>
2014-09-10 19:58   ` [PATCH v2 03/18] OvmfPkg/XenBusDxe: Add device state struct and create an ExitBoot services event Konrad Rzeszutek Wilk
2014-09-18 10:33     ` Anthony PERARD
     [not found] ` <1409849473-9268-5-git-send-email-anthony.perard@citrix.com>
2014-09-10 20:01   ` [PATCH v2 04/18] OvmfPkg/XenBusDxe: Add support to make Xen Hypercalls Konrad Rzeszutek Wilk
     [not found] ` <1409849473-9268-6-git-send-email-anthony.perard@citrix.com>
2014-09-10 20:03   ` [PATCH v2 05/18] OvmfPkg/XenBusDxe: Open PciIo protocol Konrad Rzeszutek Wilk
     [not found] ` <1409849473-9268-7-git-send-email-anthony.perard@citrix.com>
2014-09-10 20:05   ` [PATCH v2 06/18] OvmfPkg: Introduce XenBus Protocol Konrad Rzeszutek Wilk
     [not found] ` <1409849473-9268-8-git-send-email-anthony.perard@citrix.com>
2014-09-10 20:09   ` Konrad Rzeszutek Wilk [this message]
2014-09-18 10:55     ` [PATCH v2 07/18] OvmfPkg/XenBusDxe: Add InterlockedCompareExchange16 Anthony PERARD
     [not found] ` <1409849473-9268-9-git-send-email-anthony.perard@citrix.com>
2014-09-10 20:12   ` [PATCH v2 08/18] OvmfPkg/XenBusDxe: Add Grant Table functions Konrad Rzeszutek Wilk
     [not found] ` <1409849473-9268-10-git-send-email-anthony.perard@citrix.com>
2014-09-10 20:15   ` [PATCH v2 09/18] OvmfPkg/XenBusDxe: Add Event Channel Notify Konrad Rzeszutek Wilk
2014-09-18 10:56     ` Anthony PERARD
     [not found] ` <1409849473-9268-11-git-send-email-anthony.perard@citrix.com>
2014-09-10 20:18   ` [PATCH v2 10/18] OvmfPkg/XenBusDxe: Add TestAndClearBit Konrad Rzeszutek Wilk
     [not found] ` <1409849473-9268-12-git-send-email-anthony.perard@citrix.com>
2014-09-10 20:48   ` [PATCH v2 11/18] OvmfPkg/XenBusDxe: Add XenStore client implementation Konrad Rzeszutek Wilk
2014-09-18 11:10     ` Anthony PERARD
     [not found] ` <1409849473-9268-13-git-send-email-anthony.perard@citrix.com>
2014-09-10 20:50   ` [PATCH v2 12/18] OvmfPkg/XenBusDxe: Add an helper AsciiStrDup Konrad Rzeszutek Wilk
     [not found] ` <1409849473-9268-14-git-send-email-anthony.perard@citrix.com>
2014-09-10 20:54   ` [PATCH v2 13/18] OvmfPkg/XenBusDxe: Add XenStore function into the XenBus protocol Konrad Rzeszutek Wilk
     [not found] ` <1409849473-9268-15-git-send-email-anthony.perard@citrix.com>
2014-09-11 17:10   ` [PATCH v2 14/18] OvmfPkg/XenBusDxe: Indroduce XenBus support itself Konrad Rzeszutek Wilk
2014-09-18 11:26     ` Anthony PERARD
     [not found] ` <1409849473-9268-16-git-send-email-anthony.perard@citrix.com>
2014-09-12 13:58   ` [PATCH v2 15/18] OvmfPkg/XenBusDxe: Add Event Channel into XenBus protocol Konrad Rzeszutek Wilk
2014-09-18 11:28     ` Anthony PERARD
     [not found] ` <1409849473-9268-17-git-send-email-anthony.perard@citrix.com>
2014-09-12 14:03   ` [PATCH v2 16/18] OvmfPkg/XenPvBlkDxe: Xen PV Block device, initial skeleton Konrad Rzeszutek Wilk
2014-09-18 11:31     ` Anthony PERARD
     [not found] ` <1409849473-9268-18-git-send-email-anthony.perard@citrix.com>
2014-09-12 14:47   ` [PATCH v2 17/18] OvmfPkg/XenPvBlkDxe: Add BlockFront client Konrad Rzeszutek Wilk
2014-09-18 11:53     ` Anthony PERARD
     [not found] ` <1409849473-9268-19-git-send-email-anthony.perard@citrix.com>
2014-09-12 14:57   ` [PATCH v2 18/18] OvmfPkg/XenPvBlkDxe: Add BlockIo Konrad Rzeszutek Wilk
2014-09-18 15:00     ` Anthony PERARD

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20140910200943.GH3556@laptop.dumpdata.com \
    --to=konrad.wilk@oracle.com \
    --cc=anthony.perard@citrix.com \
    --cc=edk2-devel@lists.sourceforge.net \
    --cc=xen-devel@lists.xen.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.