programmer/physmap: Introduce generic mmio_chip_read/write functions
Export these functions from the `internal` programmer. They can be used
used for other memory-mapping programmers as well. For instance PCI ex-
ansion ROMs that can be programmed through their ROM BAR mapping.
Change-Id: Ibd9b93914e16d586c0144a81fe70b30a2abffd94
Signed-off-by: Nico Huber <nico.h@gmx.de>
Reviewed-on: https://review.sourcearcade.org/c/flashprog/+/528
Reviewed-by: Arthur Heymans <arthur@aheymans.xyz>
diff --git a/include/programmer/physmap.h b/include/programmer/physmap.h
new file mode 100644
index 0000000..5654153
--- /dev/null
+++ b/include/programmer/physmap.h
@@ -0,0 +1,54 @@
+/*
+ * This file is part of the flashprog project.
+ *
+ * Copyright (C) 2026 Nico Huber <nico.h@gmx.de>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+#ifndef __PROGRAMMER_PHYSMAP_H__
+#define __PROGRAMMER_PHYSMAP_H__
+
+#include <stdint.h>
+
+#include "flash.h" /* for chipaddr, *sigh* */
+#include "hwaccess_physmap.h"
+
+struct par_master;
+static inline void mmio_chip_writeb(const struct par_master *par, uint8_t val, chipaddr addr)
+{
+ mmio_writeb(val, (void *)addr);
+}
+static inline void mmio_chip_writew(const struct par_master *par, uint16_t val, chipaddr addr)
+{
+ mmio_writew(val, (void *)addr);
+}
+static inline void mmio_chip_writel(const struct par_master *par, uint32_t val, chipaddr addr)
+{
+ mmio_writel(val, (void *)addr);
+}
+static inline uint8_t mmio_chip_readb(const struct par_master *par, const chipaddr addr)
+{
+ return mmio_readb((void *)addr);
+}
+static inline uint16_t mmio_chip_readw(const struct par_master *par, const chipaddr addr)
+{
+ return mmio_readw((void *)addr);
+}
+static inline uint32_t mmio_chip_readl(const struct par_master *par, const chipaddr addr)
+{
+ return mmio_readl((void *)addr);
+}
+static inline void mmio_chip_readn(const struct par_master *par, uint8_t *buf, const chipaddr addr, size_t len)
+{
+ mmio_readn((void *)addr, buf, len);
+}
+
+#endif /* __PROGRAMMER_PHYSMAP_H__ */