shithub: riscv

Download patch

ref: 6498ce3bf29b5350975a0cd22bca8bcac19c4377
parent: d3512f60df5d7a2ea5c4cad3cdef797f1f95a182
author: cinap_lenrek <[email protected]>
date: Sat Apr 4 11:47:50 EDT 2020

ether8003: use physical addresses for ISAConfig ether->mem

Fix the inconsistent use of ether->mem. Always use physical
addresses. Let ether8390 convert to virtual addresses using
KADDR() when we have to copy data in/out.

--- a/sys/src/9/pc/ether8003.c
+++ b/sys/src/9/pc/ether8003.c
@@ -88,7 +88,7 @@
 	 */
 	if(memcmp(&ea[1], &ic[1], 5) == 0){
 		memset(ic, 0, sizeof(ic));
-		ic[Msr] = (((ulong)ether->mem)>>13) & 0x3F;
+		ic[Msr] = (ether->mem>>13) & 0x3F;
 	}
 	else{
 		/*
@@ -100,7 +100,7 @@
 		inb(port+Msr);				/* wiggle bus */
 		if(inb(port+Gp2) != 0xAA){
 			memset(ic, 0, sizeof(ic));
-			ic[Msr] = (((ulong)ether->mem)>>13) & 0x3F;
+			ic[Msr] = (ether->mem>>13) & 0x3F;
 		}
 		else
 			ether->irq = irq8003[((ic[Irr]>>5) & 0x3)|(ic[Icr] & 0x4)];
@@ -122,7 +122,7 @@
 			ctlr->width = 1;
 	}
 
-	ether->mem = (ulong)KADDR((ic[Msr] & 0x3F)<<13);
+	ether->mem = (ic[Msr] & 0x3F)<<13;
 	if(ctlr->width == 2)
 		ether->mem |= (ic[Laar] & 0x1F)<<19;
 	else
@@ -163,7 +163,7 @@
 	irq = inb(port+0x0D);
 	outb(port+Hcr, hcr);
 
-	ether->mem = (ulong)KADDR(0xC0000+((((addr>>2) & 0x30)|(addr & 0x0F))<<13));
+	ether->mem = 0xC0000+((((addr>>2) & 0x30)|(addr & 0x0F))<<13);
 	ether->size = 8192*(1<<((addr>>4) & 0x03));
 	ether->irq = irq8216[((irq>>4) & 0x04)|((irq>>2) & 0x03)];
 
@@ -262,9 +262,8 @@
 	}
 	dp8390setea(ether);
 
-	if(umbrwmalloc(PADDR(ether->mem), ether->size, 0) == 0)
-		print("ether8003: warning - 0x%luX unavailable\n",
-			PADDR(ether->mem));
+	if(umbrwmalloc(ether->mem, ether->size, 0) == 0)
+		print("ether8003: warning - 0x%luX unavailable\n", ether->mem);
 
 	return 0;
 }
--- a/sys/src/9/pc/ether8390.c
+++ b/sys/src/9/pc/ether8390.c
@@ -377,7 +377,7 @@
 	for(curr = getcurr(ctlr); ctlr->nxtpkt != curr; curr = getcurr(ctlr)){
 		data = ctlr->nxtpkt*Dp8390BufSz;
 		if(ctlr->ram)
-			memmove(&hdr, (void*)(ether->mem+data), sizeof(Hdr));
+			memmove(&hdr, (uchar*)KADDR(ether->mem) + data, sizeof(Hdr));
 		else
 			_dp8390read(ctlr, &hdr, data, sizeof(Hdr));
 
@@ -422,7 +422,7 @@
 			if((data+len) >= ctlr->pstop*Dp8390BufSz){
 				count = ctlr->pstop*Dp8390BufSz - data;
 				if(ctlr->ram)
-					memmove(p, (void*)(ether->mem+data), count);
+					memmove(p, (uchar*)KADDR(ether->mem) + data, count);
 				else
 					_dp8390read(ctlr, p, data, count);
 				p += count;
@@ -431,7 +431,7 @@
 			}
 			if(len){
 				if(ctlr->ram)
-					memmove(p, (void*)(ether->mem+data), len);
+					memmove(p, (uchar*)KADDR(ether->mem) + data, len);
 				else
 					_dp8390read(ctlr, p, data, len);
 			}
@@ -476,21 +476,13 @@
 		return;
 
 	/*
-	 * Make sure the packet is of minimum length;
 	 * copy it to the card's memory by the appropriate means;
 	 * start the transmission.
 	 */
 	len = BLEN(bp);
 	rp = bp->rp;
-	if(len < ETHERMINTU){
-		rp = minpkt;
-		memmove(rp, bp->rp, len);
-		memset(rp+len, 0, ETHERMINTU-len);
-		len = ETHERMINTU;
-	}
-
 	if(ctlr->ram)
-		memmove((void*)(ether->mem+ctlr->tstart*Dp8390BufSz), rp, len);
+		memmove((uchar*)KADDR(ether->mem) + ctlr->tstart*Dp8390BufSz, rp, len);
 	else
 		dp8390write(ctlr, ctlr->tstart*Dp8390BufSz, rp, len);
 	freeb(bp);