git: 9front

Download patch

ref: 222ab5464dbd7d48b95fc9ff9f75fafd152a893e
parent: 4036cfaed7302890f4cb93503c0b5612e2043e04
author: cinap_lenrek <cinap_lenrek@gmx.de>
date: Tue Jun 19 12:30:11 EDT 2012

acpi: work arround missing _BBN, check _HID

--- a/sys/src/9/pc/archacpi.c
+++ b/sys/src/9/pc/archacpi.c
@@ -281,6 +281,26 @@
 	bus->aintr = ai;
 }
 
+static char*
+eisaid(void *v)
+{
+	static char id[8];
+	ulong b, l;
+	int i;
+
+	if(amltag(v) == 's')
+		return v;
+	b = amlint(v);
+	for(l = 0, i=24; i>=0; i -= 8, b >>= 8)
+		l |= (b & 0xFF) << i;
+	id[7] = 0;
+	for(i=6; i>=3; i--, l >>= 4)
+		id[i] = "0123456789ABCDEF"[l & 0xF];
+	for(i=2; i>=0; i--, l >>= 5)
+		id[i] = '@' + (l & 0x1F);
+	return id;
+}
+
 static int
 pcibusno(void *dot)
 {
@@ -287,18 +307,24 @@
 	int bno, adr, tbdf;
 	Pcidev *pdev;
 	void *p, *x;
+	char *id;
 
-	p = nil;
-	if(x = amlwalk(dot, "^_BBN")){
-		if(amleval(x, "", &p) < 0)
-			return -1;
-		return amlint(p);
+	id = nil;
+	if(x = amlwalk(dot, "^_HID")){
+		p = nil;
+		if(amleval(x, "", &p) == 0)
+			id = eisaid(p);
 	}
-	if((x = amlwalk(dot, "^_ADR")) == nil)
-		return -1;
+	if((x = amlwalk(dot, "^_BBN")) == nil)
+		if((x = amlwalk(dot, "^_ADR")) == nil)
+			return -1;
+	p = nil;
 	if(amleval(x, "", &p) < 0)
 		return -1;
 	adr = amlint(p);
+	/* if root bridge, then we are done here */
+	if(id && (strcmp(id, "PNP0A03")==0 || strcmp(id, "PNP0A08")==0))
+		return adr;
 	x = amlwalk(dot, "^");
 	if(x == nil || x == dot)
 		return -1;
--