git: 9front

Download patch

ref: cc459f28a0a58c4ddf38b7025608ce7268118207
parent: 38ac4d793fc34d6a1534da501fd6065c676f2cdf
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Sat Nov 1 23:52:53 EDT 2014

pc, pc64: implement acpi reset (for efi)

x230 booted in efi only (no csp) mode hangs
when traditional i8042reset() keyboard reset
is tried.

so we try acpireset() first which discoveres
and writes the acpi reset register.

--- a/sys/src/9/pc/archacpi.c
+++ b/sys/src/9/pc/archacpi.c
@@ -862,3 +862,29 @@
 {
 	microdelay(us);
 }
+
+/*
+ * reset machine by writing acpi reset register.
+ */
+void
+acpireset(void)
+{
+	uchar *p;
+	Tbl *t;
+	int i;
+
+	for(i=0; i < ntblmap; i++){
+		t = tblmap[i];
+		if(memcmp(t->sig, "FACP", 4) != 0)
+			continue;
+		if(get32(t->len) <= 128)
+			break;
+		p = (uchar*)t;
+		if((get32(p + 112) & (1<<10)) == 0)
+			break;
+		if(p[116+0] != IoSpace)
+			break;
+		outb(get32(p+116+4), p[128]);
+		break;
+	}
+}
--- a/sys/src/9/pc/fns.h
+++ b/sys/src/9/pc/fns.h
@@ -1,6 +1,7 @@
 #include "../port/portfns.h"
 
 void	aamloop(int);
+void	acpireset(void);
 Dirtab*	addarchfile(char*, int, long(*)(Chan*,void*,long,vlong), long(*)(Chan*,void*,long,vlong));
 void	archinit(void);
 int	bios32call(BIOS32ci*, u16int[3]);
--- a/sys/src/9/pc/mp.c
+++ b/sys/src/9/pc/mp.c
@@ -585,6 +585,7 @@
 	lapicicrw(0, 0x000C0000|ApicINIT);
 
 	pcireset();
+	acpireset();
 	i8042reset();
 
 	/*
--- a/sys/src/9/pc64/fns.h
+++ b/sys/src/9/pc64/fns.h
@@ -1,6 +1,7 @@
 #include "../port/portfns.h"
 
 void	aamloop(int);
+void	acpireset(void);
 Dirtab*	addarchfile(char*, int, long(*)(Chan*,void*,long,vlong), long(*)(Chan*,void*,long,vlong));
 void	archinit(void);
 int	bios32call(BIOS32ci*, u16int[3]);
--