[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 06/10] qemu/bitops.h: add bitrev8 implementation
From: |
Mark Cave-Ayland |
Subject: |
[PATCH v2 06/10] qemu/bitops.h: add bitrev8 implementation |
Date: |
Fri, 25 Jun 2021 07:53:57 +0100 |
This will be required for an upcoming checksum calculation.
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
---
include/qemu/bitops.h | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/include/qemu/bitops.h b/include/qemu/bitops.h
index 03213ce952..110c56e099 100644
--- a/include/qemu/bitops.h
+++ b/include/qemu/bitops.h
@@ -618,4 +618,26 @@ static inline uint64_t half_unshuffle64(uint64_t x)
return x;
}
+/**
+ * bitrev8:
+ * @x: 8-bit value to be reversed
+ *
+ * Given an input value with bits::
+ *
+ * ABCDEFGH
+ *
+ * return the value with its bits reversed from left to right::
+ *
+ * HGFEDCBA
+ *
+ * Returns: the bit-reversed value.
+ */
+static inline uint8_t bitrev8(uint8_t x)
+{
+ x = ((x >> 1) & 0x55) | ((x << 1) & 0xaa);
+ x = ((x >> 2) & 0x33) | ((x << 2) & 0xcc);
+ x = (x >> 4) | (x << 4) ;
+ return x;
+}
+
#endif
--
2.20.1
- [PATCH v2 00/10] dp8393x: fixes for MacOS toolbox ROM, Mark Cave-Ayland, 2021/06/25
- [PATCH v2 03/10] hw/mips/jazz: move PROM and checksum calculation from dp8393x device to board, Mark Cave-Ayland, 2021/06/25
- [PATCH v2 02/10] dp8393x: convert to trace-events, Mark Cave-Ayland, 2021/06/25
- [PATCH v2 04/10] hw/m68k/q800: move PROM and checksum calculation from dp8393x device to board, Mark Cave-Ayland, 2021/06/25
- [PATCH v2 06/10] qemu/bitops.h: add bitrev8 implementation,
Mark Cave-Ayland <=
- [PATCH v2 01/10] dp8393x: checkpatch fixes, Mark Cave-Ayland, 2021/06/25
- [PATCH v2 05/10] dp8393x: remove onboard PROM containing MAC address and checksum, Mark Cave-Ayland, 2021/06/25
- [PATCH v2 09/10] dp8393x: fix CAM descriptor entry index, Mark Cave-Ayland, 2021/06/25
- [PATCH v2 07/10] hw/m68k/q800: fix PROM checksum and MAC address storage, Mark Cave-Ayland, 2021/06/25
- [PATCH v2 08/10] dp8393x: don't force 32-bit register access, Mark Cave-Ayland, 2021/06/25
- [PATCH v2 10/10] hw/mips/jazz: specify correct endian for dp8393x device, Mark Cave-Ayland, 2021/06/25
- Re: [PATCH v2 00/10] dp8393x: fixes for MacOS toolbox ROM, Finn Thain, 2021/06/26