git: 9front

Download patch

ref: b9d26a293eec4be3e9c46b6ce40d01a61646b8b8
parent: 7e1359767cc2d701ffe13b6a728592de1a7bc6d1
author: cinap_lenrek <cinap_lenrek@gmx.de>
date: Wed Jun 19 18:26:27 EDT 2013

acpi: use Tblsz enum instead of sizeof(Tbl) due to alignment, enable use tsc on terminal kernel (thank erik)

--- a/sys/src/9/pc/archacpi.c
+++ b/sys/src/9/pc/archacpi.c
@@ -37,6 +37,10 @@
 	uchar	data[];
 };
 
+enum {
+	Tblsz	= 4+4+1+1+6+8+4+4+4,
+};
+
 static Rsd *rsd;
 
 /* physical addresses visited by maptable() */
@@ -82,7 +86,7 @@
 
 static uint
 tbldlen(Tbl *t){
-	return get32(t->len) - sizeof(Tbl);
+	return get32(t->len) - Tblsz;
 }
 
 static void
@@ -109,7 +113,7 @@
 	if((t = vmap(pa, 8)) == nil)
 		return;
 	l = get32(t->len);
-	if(l < sizeof(Tbl)){
+	if(l < Tblsz){
 		vunmap(t, 8);
 		return;
 	}
@@ -396,7 +400,7 @@
 			a->addr = va;
 			a->lintr[0] = ApicIMASK;
 			a->lintr[1] = ApicIMASK;
-			a->flags = (p[4] & PcmpEN);
+			a->flags = p[4] & PcmpEN;
 			if(a->flags & PcmpEN){
 				a->machno = machno++;
 
@@ -515,7 +519,7 @@
 		return 1;
 	if((cp = getconf("*nomp")) != nil && strcmp(cp, "0") != 0)
 		return 1;
-	if(cpuserver && m->havetsc)
+	if(m->havetsc)
 		archacpi.fastclock = tscticks;
 	return 0;
 }
--- a/sys/src/9/pc/archmp.c
+++ b/sys/src/9/pc/archmp.c
@@ -395,7 +395,7 @@
 		return 1;
 	}
 
-	if(cpuserver && m->havetsc)
+	if(m->havetsc)
 		archmp.fastclock = tscticks;
 
 	return 0;
--- a/sys/src/cmd/scram.c
+++ b/sys/src/cmd/scram.c
@@ -25,6 +25,10 @@
 	uchar	data[];
 };
 
+enum {
+	Tblsz	= 4+4+1+1+6+8+4+4+4,
+};
+
 void*
 amlalloc(int n){
 	return mallocz(n, 1);
@@ -64,15 +68,15 @@
 	amlinit();
 	for(;;){
 		t = malloc(sizeof(*t));
-		if((n = readn(fd, t, sizeof(*t))) <= 0)
+		if((n = readn(fd, t, Tblsz)) <= 0)
 			break;
-		if(n != sizeof(*t))
+		if(n != Tblsz)
 			return -1;
 		l = get32(t->len);
-		if(l < sizeof(*t))
+		if(l < Tblsz)
 			return -1;
-		t = realloc(t, l);
-		l -= sizeof(*t);
+		l -= Tblsz;
+		t = realloc(t, sizeof(*t) + l);
 		if(readn(fd, t->data, l) != l)
 			return -1;
 		if(memcmp("DSDT", t->sig, 4) == 0)
--