shithub: riscv

Download patch

ref: 06bc19c28f3bd1528f669626eb9826226decabd9
parent: dcea714680fd6836380ea2b190e3b61b8323ab22
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Sat Feb 1 05:20:43 EST 2014

kernel: usb fixes for amd64

--- a/sys/src/9/pc/usbehcipc.c
+++ b/sys/src/9/pc/usbehcipc.c
@@ -153,7 +153,7 @@
 {
 	static int already = 0;
 	int i;
-	ulong io;
+	uintptr io;
 	Ctlr *ctlr;
 	Pcidev *p;
 	Ecapio *capio;
@@ -180,7 +180,7 @@
 				p->vid, p->did);
 			continue;
 		}
-		dprint("usbehci: %#x %#x: port %#lux size %#x irq %d\n",
+		dprint("usbehci: %#x %#x: port %#p size %#x irq %d\n",
 			p->vid, p->did, io, p->mem[0].size, p->intl);
 
 		ctlr = malloc(sizeof(Ctlr));
--- a/sys/src/9/pc/usbuhci.c
+++ b/sys/src/9/pc/usbuhci.c
@@ -245,7 +245,6 @@
 	Qh*	next;		/* in active or free list */
 	Td*	tds;		/* Td list in this Qh (initially, elink) */
 	char*	tag;		/* debug and align, mostly */
-	ulong	align;
 };
 
 /*
@@ -579,17 +578,18 @@
 {
 	int i;
 	Td *td;
-	Td *pool;
+	uchar *pool;
 
 	lock(&tdpool);
 	if(tdpool.free == nil){
 		ddprint("uhci: tdalloc %d Tds\n", Incr);
-		pool = xspanalloc(Incr*sizeof(Td), Align, 0);
+		pool = xspanalloc(Incr*ROUND(sizeof(Td), Align), Align, 0);
 		if(pool == nil)
 			panic("tdalloc");
 		for(i=Incr; --i>=0;){
-			pool[i].next = tdpool.free;
-			tdpool.free = &pool[i];
+			td = (Td*)(pool + i*ROUND(sizeof(Td), Align));
+			td->next = tdpool.free;
+			tdpool.free = td;
 		}
 		tdpool.nalloc += Incr;
 		tdpool.nfree += Incr;
@@ -602,7 +602,7 @@
 
 	memset(td, 0, sizeof(Td));
 	td->link = Tdterm;
-	assert(((ulong)td & 0xF) == 0);
+	assert(((uintptr)td & 0xF) == 0);
 	return td;
 }
 
@@ -659,17 +659,18 @@
 {
 	int i;
 	Qh *qh;
-	Qh *pool;
+	uchar *pool;
 
 	lock(&qhpool);
 	if(qhpool.free == nil){
 		ddprint("uhci: qhalloc %d Qhs\n", Incr);
-		pool = xspanalloc(Incr*sizeof(Qh), Align, 0);
+		pool = xspanalloc(Incr*ROUND(sizeof(Qh), Align), Align, 0);
 		if(pool == nil)
 			panic("qhalloc");
 		for(i=Incr; --i>=0;){
-			pool[i].next = qhpool.free;
-			qhpool.free = &pool[i];
+			qh = (Qh*)(pool + i*ROUND(sizeof(Qh), Align));
+			qh->next = qhpool.free;
+			qhpool.free = qh;
 		}
 		qhpool.nalloc += Incr;
 		qhpool.nfree += Incr;
@@ -696,7 +697,7 @@
 		iunlock(ctlr);
 	}
 
-	assert(((ulong)qh & 0xF) == 0);
+	assert(((uintptr)qh & 0xF) == 0);
 	return qh;
 }
 
--- a/sys/src/9/port/usbehci.c
+++ b/sys/src/9/port/usbehci.c
@@ -424,7 +424,7 @@
 	unlock(&edpool);
 
 	memset(ed, 0, sizeof(Ed));	/* safety */
-	assert(((ulong)ed & 0xF) == 0);
+	assert(((uintptr)ed & 0xF) == 0);
 	return ed;
 }
 
--