This atomically test and clear a bit.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Anthony PERARD <anthony.per...@citrix.com>
---
 OvmfPkg/XenbusDxe/X64/TestAndClearBit.S | 10 ++++++++++
 OvmfPkg/XenbusDxe/XenbusDxe.h           | 11 +++++++++++
 OvmfPkg/XenbusDxe/XenbusDxe.inf         |  1 +
 3 files changed, 22 insertions(+)
 create mode 100644 OvmfPkg/XenbusDxe/X64/TestAndClearBit.S

diff --git a/OvmfPkg/XenbusDxe/X64/TestAndClearBit.S 
b/OvmfPkg/XenbusDxe/X64/TestAndClearBit.S
new file mode 100644
index 0000000..e266f68
--- /dev/null
+++ b/OvmfPkg/XenbusDxe/X64/TestAndClearBit.S
@@ -0,0 +1,10 @@
+# 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/XenbusDxe.h b/OvmfPkg/XenbusDxe/XenbusDxe.h
index 975fb6b..50d0925 100644
--- a/OvmfPkg/XenbusDxe/XenbusDxe.h
+++ b/OvmfPkg/XenbusDxe/XenbusDxe.h
@@ -94,4 +94,15 @@ struct _XENBUS_DEVICE {
   shared_info_t                 *SharedInfo;
 };
 
+/*
+ * Helpers
+ */
+
+INT32
+EFIAPI
+TestAndClearBit (
+  IN INT32 Bit,
+  IN volatile VOID *Address
+  );
+
 #endif
diff --git a/OvmfPkg/XenbusDxe/XenbusDxe.inf b/OvmfPkg/XenbusDxe/XenbusDxe.inf
index d4007db..dc27c13 100644
--- a/OvmfPkg/XenbusDxe/XenbusDxe.inf
+++ b/OvmfPkg/XenbusDxe/XenbusDxe.inf
@@ -43,6 +43,7 @@
   X64/hypercall.S
   X64/hypercall.asm
   X64/InterlockedCompareExchange16.c | GCC
+  X64/TestAndClearBit.S
 
 [LibraryClasses]
   UefiDriverEntryPoint
-- 
Anthony PERARD


------------------------------------------------------------------------------
Want fast and easy access to all the code in your enterprise? Index and
search up to 200,000 lines of code with a free copy of Black Duck
Code Sight - the same software that powers the world's largest code
search on Ohloh, the Black Duck Open Hub! Try it now.
http://p.sf.net/sfu/bds
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/edk2-devel

Reply via email to