[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH v2 10/18] OvmfPkg/XenBusDxe: Add TestAndClearBit.



On Thu, Sep 04, 2014 at 05:51:05PM +0100, Anthony PERARD wrote:
> This atomically test and clear a bit.

test's and clear's a bit.

> 
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Anthony PERARD <anthony.perard@xxxxxxxxxx>

Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@xxxxxxxxxx>
> 
> ---
> Change in V2:
> - Adding .asm version
> - Comment the function
> ---
>  OvmfPkg/XenBusDxe/X64/TestAndClearBit.S   | 13 +++++++++++++
>  OvmfPkg/XenBusDxe/X64/TestAndClearBit.asm | 16 ++++++++++++++++
>  OvmfPkg/XenBusDxe/XenBusDxe.h             | 19 +++++++++++++++++++
>  OvmfPkg/XenBusDxe/XenBusDxe.inf           |  2 ++
>  4 files changed, 50 insertions(+)
>  create mode 100644 OvmfPkg/XenBusDxe/X64/TestAndClearBit.S
>  create mode 100644 OvmfPkg/XenBusDxe/X64/TestAndClearBit.asm
> 
> diff --git a/OvmfPkg/XenBusDxe/X64/TestAndClearBit.S 
> b/OvmfPkg/XenBusDxe/X64/TestAndClearBit.S
> new file mode 100644
> index 0000000..cd9c5ed
> --- /dev/null
> +++ b/OvmfPkg/XenBusDxe/X64/TestAndClearBit.S
> @@ -0,0 +1,13 @@
> +
> +# INT32
> +# EFIAPI
> +# TestAndClearBit (
> +#   IN  INT32 Bit,                // rcx
> +#   IN  volatile VOID* Address    // rdx
> +#   );
> +ASM_GLOBAL ASM_PFX(TestAndClearBit)
> +ASM_PFX(TestAndClearBit):
> +  lock
> +  btrl %ecx, (%rdx)
> +  sbbl %eax, %eax
> +  ret
> diff --git a/OvmfPkg/XenBusDxe/X64/TestAndClearBit.asm 
> b/OvmfPkg/XenBusDxe/X64/TestAndClearBit.asm
> new file mode 100644
> index 0000000..c7fc83d
> --- /dev/null
> +++ b/OvmfPkg/XenBusDxe/X64/TestAndClearBit.asm
> @@ -0,0 +1,16 @@
> +.code
> +
> +; INT32
> +; EFIAPI
> +; TestAndClearBit (
> +;   IN  INT32 Bit,                // rcx
> +;   IN  volatile VOID* Address    // rdx
> +;   );
> +TestAndClearBit PROC
> +  lock
> +  btr [rdx], ecx
> +  sbb eax, eax
> +  ret
> +TestAndClearBit ENDP
> +
> +END
> diff --git a/OvmfPkg/XenBusDxe/XenBusDxe.h b/OvmfPkg/XenBusDxe/XenBusDxe.h
> index 878e7c5..d690914 100644
> --- a/OvmfPkg/XenBusDxe/XenBusDxe.h
> +++ b/OvmfPkg/XenBusDxe/XenBusDxe.h
> @@ -113,4 +113,23 @@ struct _XENBUS_DEVICE {
>    shared_info_t                 *SharedInfo;
>  };
>  
> +/*
> + * Helpers
> + */
> +
> +/**
> +  Atomically test and clear a bit.
> +
> +  @param Bit      Bit index to test in *Address
> +  @param Address  The Address to the buffer that contain the bit to test.
> +
> +  @return Value of the Bit before it was cleared.
> +**/
> +INT32
> +EFIAPI
> +TestAndClearBit (
> +  IN INT32 Bit,
> +  IN volatile VOID *Address
> +  );
> +
>  #endif
> diff --git a/OvmfPkg/XenBusDxe/XenBusDxe.inf b/OvmfPkg/XenBusDxe/XenBusDxe.inf
> index 13623bd..e8f362a 100644
> --- a/OvmfPkg/XenBusDxe/XenBusDxe.inf
> +++ b/OvmfPkg/XenBusDxe/XenBusDxe.inf
> @@ -45,6 +45,8 @@
>    X64/InterlockedCompareExchange16.c | GCC
>    X64/InterlockedCompareExchange16.asm | INTEL
>    InterlockedCompareExchange16Intel.c | INTEL
> +  X64/TestAndClearBit.S
> +  X64/TestAndClearBit.asm
>  
>  [LibraryClasses]
>    UefiDriverEntryPoint
> -- 
> Anthony PERARD
> 
> 
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@xxxxxxxxxxxxx
> http://lists.xen.org/xen-devel

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.