shithub: riscv

Download patch

ref: bb95002c2d47ab00764a183c200c7fd9ecb3c12a
parent: 670493fe5ee39e4c819864006e3a5392c0f96248
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Sat Nov 1 22:52:53 EST 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]);