diff -r 61d4d9f4d55e sys/include/aml.h
--- a/sys/include/aml.h	Sun Jul 14 01:56:51 2013 +0200
+++ b/sys/include/aml.h	Sun Jul 14 15:25:14 2013 +0400
@@ -1,6 +1,17 @@
 #pragma	lib	"libaml.a"
 #pragma	src	"/sys/src/libaml"
 
+enum {
+	MemSpace	= 0x00,
+	IoSpace		= 0x01,
+	PcicfgSpace	= 0x02,
+	EbctlSpace	= 0x03,
+	SmbusSpace	= 0x04,
+	CmosSpace	= 0x05,
+	PcibarSpace	= 0x06,
+	IpmiSpace	= 0x07,
+};
+
 /*
  *	b	uchar*	buffer		amllen() returns number of bytes
  *	s	char*	string		amllen() is strlen()
@@ -24,6 +35,7 @@
 void*		amlwalk(void *dot, char *name);
 int		amleval(void *dot, char *fmt, ...);
 void		amlenum(void *dot, char *seg, int (*proc)(void *, void *), void *arg);
+void	*amlmkbuf(void *, int);
 
 void*		amlroot;
 int		amldebug;
@@ -33,4 +45,6 @@
 
 /* to be provided by operating system */
 extern void*	amlalloc(int);
-extern void	amlfree(void*);
+extern void		amlfree(void*);
+extern int	 	amlio(uchar, char, uvlong*, uvlong, int);
+extern void 	amldelay(int);
diff -r 61d4d9f4d55e sys/src/9/pc/archacpi.c
--- a/sys/src/9/pc/archacpi.c	Sun Jul 14 01:56:51 2013 +0200
+++ b/sys/src/9/pc/archacpi.c	Sun Jul 14 15:25:14 2013 +0400
@@ -41,6 +41,17 @@
 	Tblsz	= 4+4+1+1+6+8+4+4+4,
 };
 
+enum { 
+	FadtSmi = 12,
+	FadtAcpiEn = 16,
+	FadtPstateCnt = 19
+};
+
+enum {
+	GoFullRetard = 1
+};
+
+static int acpimode;
 static Rsd *rsd;
 
 /* physical addresses visited by maptable() */
@@ -66,6 +77,17 @@
 	free(p);
 }
 
+int 
+amlio(uchar, char, uvlong*, uvlong, int){
+	/* we don't do AML IO in the kernel */
+	return -1;
+}
+
+void 
+amldelay(int n){
+	microdelay(n);
+}
+
 static ushort
 get16(uchar *p){
 	return p[1]<<8 | p[0];
@@ -464,6 +486,20 @@
 	 * Ininitalize local APIC and start application processors.
 	 */
 	mpinit();
+
+	/* enable acpi */
+	if(acpimode != GoFullRetard)
+		return;
+	for(i=0; i<ntblmap; i++){
+		t = tblmap[i];
+		if(memcmp(t->sig, "FACP", 4) == 0){
+			p = t->data;
+			print("smi_cmd: 0x%x acpi_enable: 0x%x pstate_cnt: 0x%x\n",
+				get32(&p[FadtSmi]), p[FadtAcpiEn], p[FadtPstateCnt]);
+			outb(get32(&p[FadtSmi]), p[FadtAcpiEn]);
+			break;
+		}
+	}	
 }
 
 static int identify(void);
@@ -480,6 +516,33 @@
 .timerset=	lapictimerset,
 };
 
+/* ACPI backdoor */
+static long
+readacpimem(Chan*, void *v, long n, vlong off)
+{
+	void *p;
+
+	p = vmap(off, n);
+	if(p == nil)
+		return 0;
+	memmove(v, p, n);
+	vunmap(p, n);
+	return n;
+}
+
+static long
+writeacpimem(Chan*, void *a, long n, vlong off)
+{
+	void *p;
+
+	p = vmap(off, n);
+	if(p == nil)
+		return 0;
+	memmove(p, a, n);
+	vunmap(p, n);
+	return n;
+}
+
 static long
 readtbls(Chan*, void *v, long n, vlong o)
 {
@@ -515,11 +578,15 @@
 
 	if((cp = getconf("*acpi")) == nil)
 		return 1;
+	if(strcmp(cp, "2") == 0)
+		acpimode = GoFullRetard;
 	if((rsd = sigsearch("RSD PTR ")) == nil)
 		return 1;
 	if(checksum(rsd, 20) && checksum(rsd, 36))
 		return 1;
 	addarchfile("acpitbls", 0444, readtbls, nil);
+	if(acpimode == GoFullRetard)
+		addarchfile("acpimem", 0664, readacpimem, writeacpimem);
 	if(strcmp(cp, "0") == 0)
 		return 1;
 	if((cp = getconf("*nomp")) != nil && strcmp(cp, "0") != 0)
diff -r 61d4d9f4d55e sys/src/cmd/scram.c
--- a/sys/src/cmd/scram.c	Sun Jul 14 01:56:51 2013 +0200
+++ b/sys/src/cmd/scram.c	Sun Jul 14 15:25:14 2013 +0400
@@ -39,6 +39,11 @@
 	free(p);
 }
 
+int
+amlio(uchar, char, uvlong*, uvlong, int){
+	return -1;
+}
+
 static ulong
 get32(uchar *p){
 	return p[3]<<24 | p[2]<<16 | p[1]<<8 | p[0];
diff -r 61d4d9f4d55e sys/src/libaml/aml.c
--- a/sys/src/libaml/aml.c	Sun Jul 14 01:56:51 2013 +0200
+++ b/sys/src/libaml/aml.c	Sun Jul 14 15:25:14 2013 +0400
@@ -28,17 +28,6 @@
 #define TAG(d)	D2H(d)->tag
 #define SIZE(d)	D2H(d)->size
 
-enum {
-	MemSpace	= 0x00,
-	IoSpace		= 0x01,
-	PcicfgSpace	= 0x02,
-	EbctlSpace	= 0x03,
-	SmbusSpace	= 0x04,
-	CmosSpace	= 0x05,
-	PcibarSpace	= 0x06,
-	IpmiSpace	= 0x07,
-};
-
 static char *spacename[] = {
 	"Mem", 
 	"Io",
@@ -289,6 +278,9 @@
 	Heap *h;
 	int a;
 
+	if(size < 0) {
+		print("mk(%c,%d): something bad is happening\n", tag, size);
+	}
 	a = sizeof(Heap) + size;
 	h = amlalloc(a);
 	h->size = size;
@@ -316,6 +308,14 @@
 	return r;
 }
 
+void*
+amlmkbuf(void *p, int len)
+{
+	uchar *r = mk('b', len);
+	memmove(r, p, len);
+	return r;
+}
+
 static int
 pkglen(uchar *p, uchar *e, uchar **np)
 {
@@ -472,9 +472,22 @@
 				spacename[r->space],
 				r->off, off, len, v);
 		}
-		/* TODO: map region */
+		if(r->space != MemSpace){
+			if(amlio(r->space, write ? 'W' : 'R', &v, r->off+off, len) == -1)
+				break;
+			return v;
+		}
+
+		if(write){
+			amlio(r->space, 'W', &v, r->off+off, len);
+			break;
+		}
+		r->va = amlalloc(r->len);
+		if(amlio(r->space, 'R', (uvlong*)r->va, r->off, r->len) == -1)
+			break;
+
 		if(r->va != nil){
-			p = r->va + off;
+			p = r->va;
 			goto RWMem;
 		}
 		break;
@@ -1710,7 +1723,7 @@
 		if(FP->arg[0] == nil)
 			return nil;
 
-		l = rwreg(FP->arg[0], LenOffset, 32, 0, 0);
+		l = rwreg(FP->arg[0], LenOffset, 4, 0, 0);
 		if(l <= HdrLen)
 			return nil;
 
@@ -1942,6 +1955,24 @@
 	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)
 {
@@ -1971,7 +2002,7 @@
 
 		m = mk('m', sizeof(Method));
 		m->narg = 1;
-		m->eval = evalnop;
+		m->eval = evalosi;
 		m->name = n;
 		n->v = m;
 	}
@@ -2029,6 +2060,9 @@
 	e = mk('E', sizeof(Env));
 	for(i=0;*fmt;fmt++){
 		switch(*fmt){
+		case 'b':
+			e->arg[i++] = va_arg(a, void*);
+			break;
 		case 's':
 			e->arg[i++] = mks(va_arg(a, char*));
 			break;
