diff -r 2066a6e5b2e9 sys/include/aml.h
--- a/sys/include/aml.h	Wed Jun 05 19:11:41 2013 -0400
+++ b/sys/include/aml.h	Thu Jun 06 19:30:16 2013 +0000
@@ -33,4 +33,7 @@
 
 /* to be provided by operating system */
 extern void*	amlalloc(int);
-extern void	amlfree(void*);
+extern void		amlfree(void*);
+extern void 	acpi_read(uchar, int, int, uvlong *);
+extern void 	acpi_write(uchar, int, int, uvlong);
+extern void 	acpi_delay(int);
\ No newline at end of file
diff -r 2066a6e5b2e9 sys/src/9/pc/archacpi.c
--- a/sys/src/9/pc/archacpi.c	Wed Jun 05 19:11:41 2013 -0400
+++ b/sys/src/9/pc/archacpi.c	Thu Jun 06 19:30:16 2013 +0000
@@ -41,6 +41,10 @@
 static int ntbltab;
 static Tbl *tbltab[64];
 
+extern void acpiec_init(void *, void *);
+extern uchar acpiec_read(uchar);
+extern void acpiec_write(uchar, uvlong);
+
 void*
 amlalloc(int n){
 	void *p;
@@ -79,7 +83,6 @@
 	return get32(t->len) - sizeof(Tbl);
 }
 
-
 static Tbl*
 findtable(void *sig){
 	int i;
@@ -95,7 +98,7 @@
 	uchar *p, *e;
 	uintptr pa;
 	u32int l;
-	Tbl *t;
+	Tbl *t, *tt;
 
 	pa = xpa;
 	if((uvlong)pa != xpa || pa == 0)
@@ -105,7 +108,13 @@
 	if((t = vmap(pa, 8)) == nil)
 		return;
 	l = get32(t->len);
-	if(l < sizeof(Tbl) || findtable(t->sig)){
+	if(l < sizeof(Tbl) /*|| findtable(t->sig)*/){
+		vunmap(t, 8);
+		return;
+	}
+	/* duplicate */
+	if ((tt = findtable(t->sig)) &&
+		!memcmp(tt->oemtid, t->oemtid, 8)) {
 		vunmap(t, 8);
 		return;
 	}
@@ -119,6 +128,7 @@
 
 	tbltab[ntbltab++] = t;
 
+	print("%c%c%c%c, ", t->sig[0], t->sig[1], t->sig[2], t->sig[3]);
 	p = (uchar*)t;
 	e = p + l;
 	if(memcmp("RSDT", t->sig, 4) == 0){
@@ -147,11 +157,13 @@
 {
 	if(rsd == nil || ntbltab > 0)
 		return;
+	print("Mapped tables: ");
 	if(!checksum(rsd, 20))
 		maptable(get32(rsd->raddr));
 	if(rsd->rev >= 2)
 		if(!checksum(rsd, 36))
 			maptable(get64(rsd->xaddr));
+	print("\n");
 }
 
 static Apic*
@@ -289,6 +301,25 @@
 	return BUSBNO(pdev->bridge->tbdf);
 }
 
+static int 
+findec(void *dot, void *)
+{
+	void *p;
+	char *id;
+
+	id = nil;
+	p = nil;
+	if(amleval(dot, "", &p) == 0)
+		id = eisaid(p);
+
+	/* EC is all we care about */
+	if(id && (!strcmp(id, "PNP0C09"))) {
+		acpiec_init(dot, nil);
+		return 0;
+	}
+	return -1;
+}
+
 static int
 enumprt(void *dot, void *)
 {
@@ -326,6 +357,65 @@
 	return 1;
 }
 
+void 
+acpi_read(uchar space, int off, int len, uvlong *buf)
+{
+	uintptr pa;
+	void *p;
+
+	pa = off;
+	//print("acpi_read: space %d off 0x%x len %d\n", space, off, len);
+	switch (space) {
+		case 0x00: // MemSpace
+			if (p = vmap(pa, len)) {
+				memmove(buf, p, sizeof(uvlong));
+				vunmap(p, len);
+			}
+			break;
+		case 0x01: // IoSpace
+			*buf = inb(off);
+			break;
+		case 0x03: // EbctlSpace
+			*buf = acpiec_read(off);
+			break;
+		default:
+			print("reading from space %d not implemented\n", space);
+			*buf = 0;
+	}
+}
+
+void 
+acpi_write(uchar space, int off, int len, uvlong val)
+{
+	uintptr pa;
+	void *p;
+
+	pa = off;
+	//print("acpi_write: space %d off 0x%x len %d\n", space, off, len);
+	switch (space) {
+		case 0x00:
+			//print("pa = 0x%ulx\n", pa);
+			if (p = vmap(pa, len)) {
+				memmove(p, &val, sizeof(uvlong));
+				vunmap(p, len);
+			}
+			break;
+		case 0x01:
+			outb(off, val);
+			break;
+		case 0x03: 
+			acpiec_write(off, val);
+			break;
+		default:
+			print("writing to space %d not implemented\n", space);
+	}
+}
+
+void acpi_delay(int n)
+{
+	microdelay(n);
+}
+
 static void
 acpiinit(void)
 {
@@ -342,9 +432,13 @@
 
 	if(t = findtable("DSDT"))
 		amlload(t->data, tbldlen(t));
+
 	if(t = findtable("SSDT"))
 		amlload(t->data, tbldlen(t));
 
+	if(t = findtable("ECDT"))
+		acpiec_init(nil, t->data);
+		
 	/* set APIC mode */
 	amleval(amlwalk(amlroot, "_PIC"), "i", 1, nil);
 
@@ -428,6 +522,9 @@
 	for(i=0; i<16; i++)
 		addirq(i, BusISA, 0, i, 0);
 
+	/* look for EC if not yet found */
+	amlenum(amlroot, "_HID", findec, nil);
+
 	/* free the AML interpreter */
 	amlexit();
 
@@ -479,6 +576,34 @@
 	return p - (uchar*)v;
 }
 
+static long
+writeacpiec(Chan*, void *a, long n, vlong off)
+{
+	acpi_write(0x03, off, n, *((uvlong*)a));
+	return n;
+}
+
+static long
+readacpiec(Chan*, void *v, long n, vlong off)
+{
+	acpi_read(0x03, off, n, v);
+	return 1;
+}
+
+static long
+readacpimem(Chan*, void *v, long n, vlong off)
+{
+	acpi_read(0x00, off, n, v);
+	return 1;
+}
+
+static long
+writeacpimem(Chan*, void *a, long n, vlong off)
+{
+	acpi_write(0x00, off, n, *((uvlong*)a));
+	return n;
+}
+
 static int
 identify(void)
 {
@@ -491,6 +616,8 @@
 	if(checksum(rsd, 20) && checksum(rsd, 36))
 		return 1;
 	addarchfile("acpitbls", 0444, readtbls, nil);
+	addarchfile("acpiec", 0664, readacpiec, writeacpiec);
+	addarchfile("acpimem", 0664, readacpimem, writeacpimem);
 	if(strcmp(cp, "0") == 0)
 		return 1;
 	if((cp = getconf("*nomp")) != nil && strcmp(cp, "0") != 0)
diff -r 2066a6e5b2e9 sys/src/9/pc/pcf
--- a/sys/src/9/pc/pcf	Wed Jun 05 19:11:41 2013 -0400
+++ b/sys/src/9/pc/pcf	Thu Jun 06 19:30:16 2013 +0000
@@ -84,6 +84,7 @@
 misc
 	archacpi	mp apic
 	archmp		mp apic
+	acpiec 		mp apic
 	mtrr
 
 	sdaoe
diff -r 2066a6e5b2e9 sys/src/libaml/aml.c
--- a/sys/src/libaml/aml.c	Wed Jun 05 19:11:41 2013 -0400
+++ b/sys/src/libaml/aml.c	Thu Jun 06 19:30:16 2013 +0000
@@ -439,6 +439,7 @@
 rwreg(void *reg, int off, int len, uvlong v, int write)
 {
 	Region *r;
+	uvlong ret;
 	uchar *p;
 	int i;
 
@@ -461,13 +462,18 @@
 		r = reg;
 		if((off+len) > r->len)
 			break;
+		if(write)
+			acpi_write(r->space, r->off + off, len, v);
+		else
+			acpi_read(r->space, r->off + off, len, &ret);
+
 		if(amldebug){
 			print("rwreg: %s %-8s [%llux+%x]/%d %llux\n", 
 				write ? "W" : "R", 
 				spacename[r->space],
 				r->off, off, len, v);
 		}
-		break;
+		return (write ? v : ret);
 	}
 
 	return ~0;
@@ -1736,6 +1742,23 @@
 	return 0;
 }
 
+static void*
+evalosi(void){
+	static char *w[] = { 
+		"Windows 2001",
+		"Windows 2001 SP1",
+		"Windows 2001 SP2",
+		"Windows 2006",
+	};
+	char *arg = (char*)(amlval(FP->arg[0]));
+	int i, res = 0;
+
+	for(i = 0; !res && (i < 4); i++)
+		res = !strcmp(w[i], arg);
+
+	return mki(res);
+}
+
 void
 amlinit(void){
 	Name *n;
@@ -1753,6 +1776,7 @@
 	getname(amlroot, "_SB", 1);
 	getname(amlroot, "_TZ", 1);
 	getname(amlroot, "_SI", 1);
+	getname(amlroot, "_GL", 1);
 
 	if(n = getname(amlroot, "_REV", 1))
 		n->v = mki(2);
@@ -1763,7 +1787,7 @@
 
 		m = mk('m', sizeof(Method));
 		m->narg = 1;
-		m->eval = evalnop;
+		m->eval = evalosi;
 		m->name = n;
 		n->v = m;
 	}
