Subject: Re: 1.6 -> 1.6.1 OFB_ENABLE_CACHE lossage
To: Christian Groessler <cpg@aladdin.de>
From: Allen Briggs <briggs@wasabisystems.com>
List: port-macppc
Date: 04/26/2003 22:00:53
--UlVJffcvxoiEqYs2
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

On Sun, Apr 27, 2003 at 12:46:26AM +0200, Christian Groessler wrote:
> I just found out (by trial-and-error), that the change to
> sys/arch/powerpc/include/mpc6xx/vmparam.h is the one which breaks
> OFB_ENABLE_CACHE.

Ah, yes.  The USER_SR now conflicts with the ofb's BAT because the
corresponding ofb patch wasn't pulled up.  Try this one.  It combines
revisions 1.29, 1.30, and 1.33.

-allen

-- 
 Allen Briggs                     briggs@wasabisystems.com
 Wasabi Systems, Inc.             http://www.wasabisystems.com/

--UlVJffcvxoiEqYs2
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename=diffs

--- ofb.c
+++ ofb.c
@@ -250,11 +250,24 @@
 	OF_call_method_1("color!", dc->dc_ih, 4, 255, 255, 255, 255);
 
 	/* Enable write-through cache. */
-	if (ofb_enable_cache && battable[0xc].batu == 0) {
-		battable[0xc].batl = BATL(addr & 0xf0000000, BAT_W, BAT_PP_RW);
-		battable[0xc].batu = BATL(0xc0000000, BAT_BL_256M, BAT_Vs);
-		addr &= 0x0fffffff;
-		addr |= 0xc0000000;
+	if (ofb_enable_cache) {
+		vaddr_t va;
+		/*
+		 * Let's try to find an empty BAT to use 
+		 */
+		for (va = SEGMENT_LENGTH; va < (USER_SR << ADDR_SR_SHFT);
+		     va += SEGMENT_LENGTH) {
+			if (battable[va >> ADDR_SR_SHFT].batu == 0) {
+				battable[va >> ADDR_SR_SHFT].batl =
+				    BATL(addr & 0xf0000000,
+					 BAT_W | BAT_M | BAT_G, BAT_PP_RW);
+				battable[va >> ADDR_SR_SHFT].batu =
+				    BATL(va, BAT_BL_256M, BAT_Vs);
+				addr &= 0x0fffffff;
+				addr |= va;
+				break;
+			}
+		}
 	}
 
 	/* initialize rasops */

--UlVJffcvxoiEqYs2--