Subject: Re: emuxki on macppc
To: None <mrg@eterna.com.au>
From: Izumi Tsutsui <tsutsui@ceres.dti.ne.jp>
List: tech-kern
Date: 05/23/2004 18:37:53
In article <22084.1085301224@splode.eterna.com.au>
mrg@eterna.com.au wrote:

> anyone ever installed an emuxki on macppc?

Maybe some byteswap ops are needed around DMA ops?

I wonder how many PCI sound devices are working on big-endian machines...
(or machines which don't have DMA-coherent cache)
---
Izumi Tsutsui
tsutsui@ceres.dti.ne.jp

--- emuxki.c.orig	2004-05-23 18:29:30.000000000 +0900
+++ emuxki.c	2004-05-23 18:34:00.000000000 +0900
@@ -739,7 +739,7 @@
 	silentpage = DMAADDR(sc->silentpage) << 1;
 	ptb = KERNADDR(sc->ptb);
 	for (i = 0; i < EMU_MAXPTE; i++)
-		ptb[i] = silentpage | i;
+		ptb[i] = htole32(silentpage | i);
 
 	/* Write PTB address and set TCB to none */
 	emuxki_write(sc, 0, EMU_PTB, DMAADDR(sc->ptb));
@@ -860,11 +860,11 @@
 		numblocks++;
 
 	for (i = 0; i < EMU_MAXPTE; i++)
-		if ((ptb[i] & EMU_CHAN_MAP_PTE_MASK) == silentpage) {
+		if ((le32toh(ptb[i]) & EMU_CHAN_MAP_PTE_MASK) == silentpage) {
 			/* We look for a free PTE */
 			s = splaudio();
 			for (j = 0; j < numblocks; j++)
-				if ((ptb[i + j] & EMU_CHAN_MAP_PTE_MASK)
+				if ((le32toh(ptb[i + j]) & EMU_CHAN_MAP_PTE_MASK)
 				    != silentpage)
 					break;
 			if (j == numblocks) {
@@ -875,9 +875,9 @@
 				}
 				for (j = 0; j < numblocks; j++)
 					ptb[i + j] =
-						(((DMAADDR(mem->dmamem) +
+					    htole32((((DMAADDR(mem->dmamem) +
 						 j * EMU_PTESIZE)) << 1)
-						| (i + j);
+						| (i + j));
 				LIST_INSERT_HEAD(&(sc->mem), mem, next);
 				splx(s);
 				return (KERNADDR(mem->dmamem));
@@ -2050,7 +2050,7 @@
 				numblocks++;
 			for (i = 0; i < numblocks; i++)
 				ptb[mem->ptbidx + i] =
-					silentpage | (mem->ptbidx + i);
+				    htole32(silentpage | (mem->ptbidx + i));
 		}
 		LIST_REMOVE(mem, next);
 		splx(s);