]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[hyperv] Use generic set_bit() function
authorMichael Brown <mcb30@ipxe.org>
Wed, 16 Mar 2016 21:24:13 +0000 (21:24 +0000)
committerMichael Brown <mcb30@ipxe.org>
Wed, 16 Mar 2016 22:33:41 +0000 (22:33 +0000)
Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/arch/i386/include/bits/hyperv.h
src/arch/x86_64/include/bits/hyperv.h
src/interface/hyperv/vmbus.c

index 3565c8a83c07a1f5b3e09038c21aebd99aef2e23..0ba58afb7e823641261aeec222259f2bb3d53ebe 100644 (file)
@@ -46,27 +46,4 @@ hv_call ( struct hv_hypervisor *hv, unsigned int code, const void *in,
        return result;
 }
 
-/**
- * Set bit atomically
- *
- * @v bits             Bit field
- * @v bit              Bit to set
- */
-static inline __attribute__ (( always_inline )) void
-hv_set_bit ( void *bits, unsigned int bit ) {
-       struct {
-               uint32_t dword[ ( bit / 32 ) + 1 ];
-       } *dwords = bits;
-
-       /* Set bit using "lock bts".  Inform compiler that any memory
-        * from the start of the bit field up to and including the
-        * dword containing this bit may be modified.  (This is
-        * overkill but shouldn't matter in practice since we're
-        * unlikely to subsequently read other bits from the same bit
-        * field.)
-        */
-       __asm__ __volatile__ ( "lock bts %1, %0"
-                              : "+m" ( *dwords ) : "Ir" ( bit ) );
-}
-
 #endif /* _BITS_HYPERV_H */
index 845c182f7ad6b7333643a87b216919a0431ce029..975b1eee0f7e81583846d7b1c9c9aa086ad8e7da 100644 (file)
@@ -49,27 +49,4 @@ hv_call ( struct hv_hypervisor *hv, unsigned int code, const void *in,
        return result;
 }
 
-/**
- * Set bit atomically
- *
- * @v bits             Bit field
- * @v bit              Bit to set
- */
-static inline __attribute__ (( always_inline )) void
-hv_set_bit ( void *bits, unsigned int bit ) {
-       struct {
-               uint64_t qword[ ( bit / 64 ) + 1 ];
-       } *qwords = bits;
-
-       /* Set bit using "lock bts".  Inform compiler that any memory
-        * from the start of the bit field up to and including the
-        * qword containing this bit may be modified.  (This is
-        * overkill but shouldn't matter in practice since we're
-        * unlikely to subsequently read other bits from the same bit
-        * field.)
-        */
-       __asm__ __volatile__ ( "lock bts %1, %0"
-                              : "+m" ( *qwords ) : "Ir" ( bit ) );
-}
-
 #endif /* _BITS_HYPERV_H */
index 795929eae0cf322aa48d76d24fce125a6a91c34b..fd809dda47777ed7efdad1f1b6a10cb08c473b49 100644 (file)
@@ -39,6 +39,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
 #include <ipxe/nap.h>
 #include <ipxe/malloc.h>
 #include <ipxe/iobuf.h>
+#include <ipxe/bitops.h>
 #include <ipxe/hyperv.h>
 #include <ipxe/vmbus.h>
 
@@ -559,7 +560,7 @@ static void vmbus_signal_monitor ( struct vmbus_device *vmdev ) {
        group = ( vmdev->monitor / ( 8 * sizeof ( trigger->pending ) ));
        bit = ( vmdev->monitor % ( 8 * sizeof ( trigger->pending ) ) );
        trigger = &vmbus->monitor_out->trigger[group];
-       hv_set_bit ( trigger, bit );
+       set_bit ( bit, trigger );
 }
 
 /**
@@ -720,7 +721,7 @@ static int vmbus_send ( struct vmbus_device *vmdev,
                return 0;
 
        /* Set channel bit in interrupt page */
-       hv_set_bit ( vmbus->intr->out, vmdev->channel );
+       set_bit ( vmdev->channel, vmbus->intr->out );
 
        /* Signal the host */
        vmdev->signal ( vmdev );