On 3/28/2025 1:38 PM, Philippe Mathieu-Daudé wrote:
On 28/3/25 20:06, Farhan Ali wrote:
Add a generic QEMU API for PCI MMIO reads/writes.
The functions access little endian memory and returns
the result in host cpu endianness.
Signed-off-by: Farhan Ali <al...@linux.ibm.com>
---
include/qemu/pci-mmio.h | 116 ++++++++++++++++++++++++++++++++++++++++
1 file changed, 116 insertions(+)
create mode 100644 include/qemu/pci-mmio.h
diff --git a/include/qemu/pci-mmio.h b/include/qemu/pci-mmio.h
new file mode 100644
index 0000000000..2ef92455b1
--- /dev/null
+++ b/include/qemu/pci-mmio.h
@@ -0,0 +1,116 @@
+/*
+ * QEMU PCI MMIO API
+ *
+ * Copyright 2025 IBM Corp.
+ * Author(s): Farhan Ali <al...@linux.ibm.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#ifndef QEMU_PCI_MMIO_H
+#define QEMU_PCI_MMIO_H
+
Missing:
#include "qemu/bswap.h"
Thanks, will add this. Though I didn't have any issue compiling, but i
think we should add this.
+#ifdef __s390x__
+#include "s390x_pci_mmio.h"
+#endif
+
+static inline uint8_t qemu_pci_mmio_read_8(const void *ioaddr)
+{
+ uint8_t ret = 0;
+#ifdef __s390x__
+ ret = s390x_pci_mmio_read_8(ioaddr);
+#else
+ /* Prevent the compiler from optimizing away the load */
+ ret = *((volatile uint8_t *)ioaddr);
+#endif
+
+ return ret;
+}
+
+static inline uint16_t qemu_pci_mmio_read_16(const void *ioaddr)
+{
+ uint16_t ret = 0;
+#ifdef __s390x__
+ ret = s390x_pci_mmio_read_16(ioaddr);
+#else
+ /* Prevent the compiler from optimizing away the load */
+ ret = *((volatile uint16_t *)ioaddr);
+#endif
+
+ return le16_to_cpu(ret);
+}
Otherwise:
Reviewed-by: Philippe Mathieu-Daudé <phi...@linaro.org>