Browse Source

[hyperv] Use generic set_bit() function

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 9 years ago
parent
commit
9bab13a772

+ 0
- 23
src/arch/i386/include/bits/hyperv.h View File

46
 	return result;
46
 	return result;
47
 }
47
 }
48
 
48
 
49
-/**
50
- * Set bit atomically
51
- *
52
- * @v bits		Bit field
53
- * @v bit		Bit to set
54
- */
55
-static inline __attribute__ (( always_inline )) void
56
-hv_set_bit ( void *bits, unsigned int bit ) {
57
-	struct {
58
-		uint32_t dword[ ( bit / 32 ) + 1 ];
59
-	} *dwords = bits;
60
-
61
-	/* Set bit using "lock bts".  Inform compiler that any memory
62
-	 * from the start of the bit field up to and including the
63
-	 * dword containing this bit may be modified.  (This is
64
-	 * overkill but shouldn't matter in practice since we're
65
-	 * unlikely to subsequently read other bits from the same bit
66
-	 * field.)
67
-	 */
68
-	__asm__ __volatile__ ( "lock bts %1, %0"
69
-			       : "+m" ( *dwords ) : "Ir" ( bit ) );
70
-}
71
-
72
 #endif /* _BITS_HYPERV_H */
49
 #endif /* _BITS_HYPERV_H */

+ 0
- 23
src/arch/x86_64/include/bits/hyperv.h View File

49
 	return result;
49
 	return result;
50
 }
50
 }
51
 
51
 
52
-/**
53
- * Set bit atomically
54
- *
55
- * @v bits		Bit field
56
- * @v bit		Bit to set
57
- */
58
-static inline __attribute__ (( always_inline )) void
59
-hv_set_bit ( void *bits, unsigned int bit ) {
60
-	struct {
61
-		uint64_t qword[ ( bit / 64 ) + 1 ];
62
-	} *qwords = bits;
63
-
64
-	/* Set bit using "lock bts".  Inform compiler that any memory
65
-	 * from the start of the bit field up to and including the
66
-	 * qword containing this bit may be modified.  (This is
67
-	 * overkill but shouldn't matter in practice since we're
68
-	 * unlikely to subsequently read other bits from the same bit
69
-	 * field.)
70
-	 */
71
-	__asm__ __volatile__ ( "lock bts %1, %0"
72
-			       : "+m" ( *qwords ) : "Ir" ( bit ) );
73
-}
74
-
75
 #endif /* _BITS_HYPERV_H */
52
 #endif /* _BITS_HYPERV_H */

+ 3
- 2
src/interface/hyperv/vmbus.c View File

39
 #include <ipxe/nap.h>
39
 #include <ipxe/nap.h>
40
 #include <ipxe/malloc.h>
40
 #include <ipxe/malloc.h>
41
 #include <ipxe/iobuf.h>
41
 #include <ipxe/iobuf.h>
42
+#include <ipxe/bitops.h>
42
 #include <ipxe/hyperv.h>
43
 #include <ipxe/hyperv.h>
43
 #include <ipxe/vmbus.h>
44
 #include <ipxe/vmbus.h>
44
 
45
 
559
 	group = ( vmdev->monitor / ( 8 * sizeof ( trigger->pending ) ));
560
 	group = ( vmdev->monitor / ( 8 * sizeof ( trigger->pending ) ));
560
 	bit = ( vmdev->monitor % ( 8 * sizeof ( trigger->pending ) ) );
561
 	bit = ( vmdev->monitor % ( 8 * sizeof ( trigger->pending ) ) );
561
 	trigger = &vmbus->monitor_out->trigger[group];
562
 	trigger = &vmbus->monitor_out->trigger[group];
562
-	hv_set_bit ( trigger, bit );
563
+	set_bit ( bit, trigger );
563
 }
564
 }
564
 
565
 
565
 /**
566
 /**
720
 		return 0;
721
 		return 0;
721
 
722
 
722
 	/* Set channel bit in interrupt page */
723
 	/* Set channel bit in interrupt page */
723
-	hv_set_bit ( vmbus->intr->out, vmdev->channel );
724
+	set_bit ( vmdev->channel, vmbus->intr->out );
724
 
725
 
725
 	/* Signal the host */
726
 	/* Signal the host */
726
 	vmdev->signal ( vmdev );
727
 	vmdev->signal ( vmdev );

Loading…
Cancel
Save