[libbsd/6-freebsd-12 PATCH] i386/pc686: Fix kernel bus DMA for the PC686 BSP

chrisj at rtems.org chrisj at rtems.org
Wed Oct 4 05:25:40 UTC 2023


From: Chris Johns <chrisj at rtems.org>

The x86 provides it own bus space support. Use the generic
bus space calls. This however requires the BUS_SPACE_MEM tag
be provided for all architectures. Make the generic value
match the x86 value.
---
 rtemsbsd/include/machine/bus.h        | 9 +++++++++
 rtemsbsd/rtems/rtems-kernel-bus-dma.c | 6 +++++-
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/rtemsbsd/include/machine/bus.h b/rtemsbsd/include/machine/bus.h
index a0c3d63a..8a61a7d0 100644
--- a/rtemsbsd/include/machine/bus.h
+++ b/rtemsbsd/include/machine/bus.h
@@ -167,6 +167,15 @@
 
 #endif /* BSP_HAS_PC_PCI */
 
+/*
+ * Provide a memory tag for the DMA bus interface
+ */
+#ifdef BSP_BUS_SPACE_MEM
+#define BUS_SPACE_MEM BSP_BUS_SPACE_MEM
+#else
+#define BUS_SPACE_MEM 1
+#endif
+
 /*
  * Bus address alignment.
  */
diff --git a/rtemsbsd/rtems/rtems-kernel-bus-dma.c b/rtemsbsd/rtems/rtems-kernel-bus-dma.c
index 1d28f62c..9c9194b0 100644
--- a/rtemsbsd/rtems/rtems-kernel-bus-dma.c
+++ b/rtemsbsd/rtems/rtems-kernel-bus-dma.c
@@ -63,6 +63,10 @@
 #include <bsp/linker-symbols.h>
 #endif
 
+#ifdef X86_BUS_SPACE_MEM
+#define BUS_SPACE_MEM X86_BUS_SPACE_MEM
+#endif
+
 /*
  * Convenience function for manipulating driver locks from busdma (during
  * busdma_swi, for example).  Drivers that don't provide their own locks
@@ -261,7 +265,7 @@ bus_dmamem_alloc(bus_dma_tag_t dmat, void** vaddr, int flags,
 		unsigned char* mem = *vaddr;
 		int len = dmat->maxsize;
 		while (len-- > 0) {
-			bsp_bus_space_write_1(mem, 0);
+			bus_space_write_1(BUS_SPACE_MEM, mem, 0, 0);
 			mem++;
 		}
 	}
-- 
2.37.1



More information about the devel mailing list