Index: freebsd/sys/dev/cadence/if_cgem.c
===================================================================
--- freebsd/sys/dev/cadence/if_cgem.c	(revision cd179c472bf1c0c6d59a05f51b41c70b39e165a8)
+++ freebsd/sys/dev/cadence/if_cgem.c	(revision 911f517d2da7856b652995eb13aefcfd0d50f47a)
@@ -127,5 +127,7 @@
 	bus_addr_t		rxring_physaddr;
 	struct mbuf		*rxring_m[CGEM_NUM_RX_DESCS];
+#ifndef __rtems__
 	bus_dmamap_t		rxring_m_dmamap[CGEM_NUM_RX_DESCS];
+#endif /* __rtems__ */
 	int			rxring_hd_ptr;	/* where to put rcv bufs */
 	int			rxring_tl_ptr;	/* where to get receives */
@@ -143,5 +145,7 @@
 	bus_addr_t		txring_physaddr;
 	struct mbuf		*txring_m[CGEM_NUM_TX_DESCS];
+#ifndef __rtems__
 	bus_dmamap_t		txring_m_dmamap[CGEM_NUM_TX_DESCS];
+#endif /* __rtems__ */
 	int			txring_hd_ptr;	/* where to put next xmits */
 	int			txring_tl_ptr;	/* next xmit mbuf to free */
@@ -426,8 +430,10 @@
 		sc->rxring[i].ctl = 0;
 		sc->rxring_m[i] = NULL;
+#ifndef __rtems__
 		err = bus_dmamap_create(sc->mbuf_dma_tag, 0,
 					&sc->rxring_m_dmamap[i]);
 		if (err)
 			return (err);
+#endif /* __rtems__ */
 	}
 	sc->rxring[CGEM_NUM_RX_DESCS - 1].addr |= CGEM_RXDESC_WRAP;
@@ -459,8 +465,10 @@
 		sc->txring[i].ctl = CGEM_TXDESC_USED;
 		sc->txring_m[i] = NULL;
+#ifndef __rtems__
 		err = bus_dmamap_create(sc->mbuf_dma_tag, 0,
 					&sc->txring_m_dmamap[i]);
 		if (err)
 			return (err);
+#endif /* __rtems__ */
 	}
 	sc->txring[CGEM_NUM_TX_DESCS - 1].ctl |= CGEM_TXDESC_WRAP;
@@ -478,6 +486,10 @@
 {
 	struct mbuf *m = NULL;
+#ifndef __rtems__
 	bus_dma_segment_t segs[TX_MAX_DMA_SEGS];
 	int nsegs;
+#else /* __rtems__ */
+	bus_dma_segment_t segs[1];
+#endif /* __rtems__ */
 
 	CGEM_ASSERT_LOCKED(sc);
@@ -493,4 +505,5 @@
 		m->m_pkthdr.rcvif = sc->ifp;
 
+#ifndef __rtems__
 		/* Load map and plug in physical address. */
 		if (bus_dmamap_load_mbuf_sg(sc->mbuf_dma_tag, 
@@ -501,10 +514,16 @@
 			break;
 		}
+#endif /* __rtems__ */
 		sc->rxring_m[sc->rxring_hd_ptr] = m;
 
+#ifndef __rtems__
 		/* Sync cache with receive buffer. */
 		bus_dmamap_sync(sc->mbuf_dma_tag,
 				sc->rxring_m_dmamap[sc->rxring_hd_ptr],
 				BUS_DMASYNC_PREREAD);
+#else /* __rtems__ */
+		rtems_cache_invalidate_multiple_data_lines(m->m_data, m->m_len);
+		segs[0].ds_addr = mtod(m, bus_addr_t);
+#endif /* __rtems__ */
 
 		/* Write rx descriptor and increment head pointer. */
@@ -543,4 +562,5 @@
 		sc->rxring_m[sc->rxring_tl_ptr] = NULL;
 
+#ifndef __rtems__
 		/* Sync cache with receive buffer. */
 		bus_dmamap_sync(sc->mbuf_dma_tag,
@@ -551,4 +571,7 @@
 		bus_dmamap_unload(sc->mbuf_dma_tag,
 		  	sc->rxring_m_dmamap[sc->rxring_tl_ptr]);
+#else /* __rtems__ */
+		rtems_cache_invalidate_multiple_data_lines(m->m_data, m->m_len);
+#endif /* __rtems__ */
 
 		/* Increment tail pointer. */
@@ -640,4 +663,5 @@
 		CGEM_TXDESC_USED) != 0) {
 
+#ifndef __rtems__
 		/* Sync cache.  nop? */
 		bus_dmamap_sync(sc->mbuf_dma_tag,
@@ -648,4 +672,5 @@
 		bus_dmamap_unload(sc->mbuf_dma_tag,
 				  sc->txring_m_dmamap[sc->txring_tl_ptr]);
+#endif /* __rtems__ */
 
 		/* Free up the mbuf. */
@@ -702,4 +727,31 @@
 }
 
+#ifdef __rtems__
+static int
+cgem_get_segs_for_tx(struct mbuf *m, bus_dma_segment_t segs[TX_MAX_DMA_SEGS],
+    int *nsegs)
+{
+	int i = 0;
+
+	do {
+		if (m->m_len > 0) {
+			segs[i].ds_addr = mtod(m, bus_addr_t);
+			segs[i].ds_len = m->m_len;
+			rtems_cache_flush_multiple_data_lines(m->m_data, m->m_len);
+			++i;
+		}
+
+		m = m->m_next;
+
+		if (m == NULL) {
+			*nsegs = i;
+
+			return (0);
+		}
+	} while (i < TX_MAX_DMA_SEGS);
+
+	return (EFBIG);
+}
+#endif /* __rtems__ */
 /* Start transmits. */
 static void
@@ -739,8 +791,12 @@
 			break;
 
+#ifndef __rtems__
 		/* Load DMA map. */
 		err = bus_dmamap_load_mbuf_sg(sc->mbuf_dma_tag,
 				      sc->txring_m_dmamap[sc->txring_hd_ptr],
 				      m, segs, &nsegs, BUS_DMA_NOWAIT);
+#else /* __rtems__ */
+		err = cgem_get_segs_for_tx(m, segs, &nsegs);
+#endif /* __rtems__ */
 		if (err == EFBIG) {
 			/* Too many segments!  defrag and try again. */
@@ -753,7 +809,11 @@
 			}
 			m = m2;
+#ifndef __rtems__
 			err = bus_dmamap_load_mbuf_sg(sc->mbuf_dma_tag,
 				      sc->txring_m_dmamap[sc->txring_hd_ptr],
 				      m, segs, &nsegs, BUS_DMA_NOWAIT);
+#else /* __rtems__ */
+			err = cgem_get_segs_for_tx(m, segs, &nsegs);
+#endif /* __rtems__ */
 			sc->txdefrags++;
 		}
@@ -766,8 +826,10 @@
 		sc->txring_m[sc->txring_hd_ptr] = m;
 
+#ifndef __rtems__
 		/* Sync tx buffer with cache. */
 		bus_dmamap_sync(sc->mbuf_dma_tag,
 				sc->txring_m_dmamap[sc->txring_hd_ptr],
 				BUS_DMASYNC_PREWRITE);
+#endif /* __rtems__ */
 
 		/* Set wrap flag if next packet might run off end of ring. */
@@ -1128,6 +1190,8 @@
 		sc->txring[i].addr = 0;
 		if (sc->txring_m[i]) {
+#ifndef __rtems__
 			bus_dmamap_unload(sc->mbuf_dma_tag,
 					  sc->txring_m_dmamap[i]);
+#endif /* __rtems__ */
 			m_freem(sc->txring_m[i]);
 			sc->txring_m[i] = NULL;
@@ -1145,7 +1209,9 @@
 		sc->rxring[i].ctl = 0;
 		if (sc->rxring_m[i]) {
+#ifndef __rtems__
 			/* Unload dmamap. */
 			bus_dmamap_unload(sc->mbuf_dma_tag,
 				  sc->rxring_m_dmamap[sc->rxring_tl_ptr]);
+#endif /* __rtems__ */
 
 			m_freem(sc->rxring_m[i]);
@@ -1766,5 +1832,7 @@
 {
 	struct cgem_softc *sc = device_get_softc(dev);
+#ifndef __rtems__
 	int i;
+#endif /* __rtems__ */
 
 	if (sc == NULL)
@@ -1808,4 +1876,5 @@
 				sc->rxring_dma_map);
 		sc->rxring = NULL;
+#ifndef __rtems__
 		for (i = 0; i < CGEM_NUM_RX_DESCS; i++)
 			if (sc->rxring_m_dmamap[i] != NULL) {
@@ -1814,4 +1883,5 @@
 				sc->rxring_m_dmamap[i] = NULL;
 			}
+#endif /* __rtems__ */
 	}
 	if (sc->txring != NULL) {
@@ -1823,4 +1893,5 @@
 				sc->txring_dma_map);
 		sc->txring = NULL;
+#ifndef __rtems__
 		for (i = 0; i < CGEM_NUM_TX_DESCS; i++)
 			if (sc->txring_m_dmamap[i] != NULL) {
@@ -1829,4 +1900,5 @@
 				sc->txring_m_dmamap[i] = NULL;
 			}
+#endif /* __rtems__ */
 	}
 	if (sc->desc_dma_tag != NULL) {
