[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 15/18] qemu/bitops.h: add bitrev8 implementation
From: |
Philippe Mathieu-Daudé |
Subject: |
[PULL 15/18] qemu/bitops.h: add bitrev8 implementation |
Date: |
Fri, 2 Jul 2021 15:35:54 +0200 |
From: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
This will be required for an upcoming checksum calculation.
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Tested-by: Finn Thain <fthain@linux-m68k.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Message-Id: <20210625065401.30170-7-mark.cave-ayland@ilande.co.uk>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
include/qemu/bitops.h | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/include/qemu/bitops.h b/include/qemu/bitops.h
index 03213ce952c..110c56e0993 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.31.1
- [PULL 06/18] hw/pci-host/bonito: Allow PCI config accesses smaller than 32-bit, (continued)
- [PULL 06/18] hw/pci-host/bonito: Allow PCI config accesses smaller than 32-bit, Philippe Mathieu-Daudé, 2021/07/02
- [PULL 07/18] tests/acceptance: Test Linux on the Fuloong 2E machine, Philippe Mathieu-Daudé, 2021/07/02
- [PULL 08/18] g364fb: use RAM memory region for framebuffer, Philippe Mathieu-Daudé, 2021/07/02
- [PULL 09/18] g364fb: add VMStateDescription for G364SysBusState, Philippe Mathieu-Daudé, 2021/07/02
- [PULL 10/18] dp8393x: checkpatch fixes, Philippe Mathieu-Daudé, 2021/07/02
- [PULL 11/18] dp8393x: convert to trace-events, Philippe Mathieu-Daudé, 2021/07/02
- [PULL 12/18] hw/mips/jazz: move PROM and checksum calculation from dp8393x device to board, Philippe Mathieu-Daudé, 2021/07/02
- [PULL 13/18] hw/m68k/q800: move PROM and checksum calculation from dp8393x device to board, Philippe Mathieu-Daudé, 2021/07/02
- [PULL 14/18] dp8393x: remove onboard PROM containing MAC address and checksum, Philippe Mathieu-Daudé, 2021/07/02
- [PULL 15/18] qemu/bitops.h: add bitrev8 implementation,
Philippe Mathieu-Daudé <=
- [PULL 16/18] hw/m68k/q800: fix PROM checksum and MAC address storage, Philippe Mathieu-Daudé, 2021/07/02
- [PULL 17/18] hw/mips/jazz: specify correct endian for dp8393x device, Philippe Mathieu-Daudé, 2021/07/02
- [PULL 18/18] hw/mips/jazz: Map the UART devices unconditionally, Philippe Mathieu-Daudé, 2021/07/02
- Re: [PULL 00/18] MIPS patches for 2021-07-02, Peter Maydell, 2021/07/04