diff options
author | Anthony PERARD <anthony.perard@citrix.com> | 2014-10-29 06:50:35 +0000 |
---|---|---|
committer | jljusten <jljusten@Edk2> | 2014-10-29 06:50:35 +0000 |
commit | 6342f1fea881996666b4f1a9e7f132c484e03ff0 (patch) | |
tree | ec1c09ac24a16fbf9803ad4379c3d41eee35826f /OvmfPkg/XenBusDxe | |
parent | f1259bba3647beb30b7c5e2e7dbe6ba060814912 (diff) | |
download | edk2-6342f1fea881996666b4f1a9e7f132c484e03ff0.tar.gz edk2-6342f1fea881996666b4f1a9e7f132c484e03ff0.tar.bz2 edk2-6342f1fea881996666b4f1a9e7f132c484e03ff0.zip |
OvmfPkg/XenBusDxe: Add TestAndClearBit.
This atomically test's and clear's a bit.
Change in V3:
- adding IA32 support. (not yet reviewed)
both XenBusDxe/Ia32/TestAndClearBit.{S,asm} are new
Change in V2:
- Adding .asm version
- Comment the function
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@16266 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'OvmfPkg/XenBusDxe')
-rw-r--r-- | OvmfPkg/XenBusDxe/Ia32/TestAndClearBit.S | 13 | ||||
-rw-r--r-- | OvmfPkg/XenBusDxe/Ia32/TestAndClearBit.asm | 17 | ||||
-rw-r--r-- | OvmfPkg/XenBusDxe/X64/TestAndClearBit.S | 12 | ||||
-rw-r--r-- | OvmfPkg/XenBusDxe/X64/TestAndClearBit.asm | 16 | ||||
-rw-r--r-- | OvmfPkg/XenBusDxe/XenBusDxe.h | 19 | ||||
-rw-r--r-- | OvmfPkg/XenBusDxe/XenBusDxe.inf | 4 |
6 files changed, 81 insertions, 0 deletions
diff --git a/OvmfPkg/XenBusDxe/Ia32/TestAndClearBit.S b/OvmfPkg/XenBusDxe/Ia32/TestAndClearBit.S new file mode 100644 index 0000000000..58dfa8ba57 --- /dev/null +++ b/OvmfPkg/XenBusDxe/Ia32/TestAndClearBit.S @@ -0,0 +1,13 @@ +# INT32
+# EFIAPI
+# TestAndClearBit (
+# IN INT32 Bit,
+# IN volatile VOID* Address
+# );
+ASM_GLOBAL ASM_PFX(TestAndClearBit)
+ASM_PFX(TestAndClearBit):
+ mov 4(%esp), %ecx
+ mov 8(%esp), %edx
+ lock btrl %ecx, (%edx)
+ sbbl %eax, %eax
+ ret
diff --git a/OvmfPkg/XenBusDxe/Ia32/TestAndClearBit.asm b/OvmfPkg/XenBusDxe/Ia32/TestAndClearBit.asm new file mode 100644 index 0000000000..ac809020a6 --- /dev/null +++ b/OvmfPkg/XenBusDxe/Ia32/TestAndClearBit.asm @@ -0,0 +1,17 @@ +.code
+
+; INT32
+; EFIAPI
+; TestAndClearBit (
+; IN INT32 Bit,
+; IN volatile VOID* Address
+; );
+TestAndClearBit PROC
+ mov ecx, [esp + 4]
+ mov edx, [esp + 8]
+ lock btr [edx], ecx
+ sbb eax, eax
+ ret
+TestAndClearBit ENDP
+
+END
diff --git a/OvmfPkg/XenBusDxe/X64/TestAndClearBit.S b/OvmfPkg/XenBusDxe/X64/TestAndClearBit.S new file mode 100644 index 0000000000..0372e83bdd --- /dev/null +++ b/OvmfPkg/XenBusDxe/X64/TestAndClearBit.S @@ -0,0 +1,12 @@ +# 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 0000000000..3a2587913e --- /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 64579bb832..d80c118acf 100644 --- a/OvmfPkg/XenBusDxe/XenBusDxe.h +++ b/OvmfPkg/XenBusDxe/XenBusDxe.h @@ -97,4 +97,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 0af1946e26..742b7c615b 100644 --- a/OvmfPkg/XenBusDxe/XenBusDxe.inf +++ b/OvmfPkg/XenBusDxe/XenBusDxe.inf @@ -48,12 +48,16 @@ Ia32/hypercall.asm
Ia32/InterlockedCompareExchange16.S
Ia32/InterlockedCompareExchange16.asm
+ Ia32/TestAndClearBit.S
+ Ia32/TestAndClearBit.asm
[Sources.X64]
X64/hypercall.S
X64/hypercall.asm
X64/InterlockedCompareExchange16.S
X64/InterlockedCompareExchange16.asm
+ X64/TestAndClearBit.S
+ X64/TestAndClearBit.asm
[LibraryClasses]
UefiDriverEntryPoint
|