shithub: riscv

Download patch

ref: cf166c38502cdde9ca2ab5de3c4dad70b58328c2
parent: 81618e61df9a640f756d6f9194904d0c817b98b9
author: cinap_lenrek <[email protected]>
date: Sat Sep 7 10:40:24 EDT 2013

libaml: amldelay(), _OSI(), fix bug in Load() (from plhk's acpi patch)

export amldelay() for microsecond sleeps.

implement _OSI() method.

fix rwreg argument in evalload()

--- a/sys/include/aml.h
+++ b/sys/include/aml.h
@@ -44,6 +44,8 @@
 extern void*	amlalloc(int);
 extern void	amlfree(void*);
 
+extern void	amldelay(int);	/* microseconds */
+
 enum {
 	MemSpace	= 0x00,
 	IoSpace		= 0x01,
--- a/sys/src/libaml/aml.c
+++ b/sys/src/libaml/aml.c
@@ -1788,7 +1788,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;
 
@@ -1819,6 +1819,20 @@
 	return tid;
 }
 
+static void*
+evalstall(void)
+{
+	amldelay(ival(FP->arg[0]));
+	return nil;
+}
+
+static void*
+evalsleep(void)
+{
+	amldelay(ival(FP->arg[0])*1000);
+	return nil;
+}
+
 static Op optab[] = {
 	[Obad]		"",			"",		evalbad,
 	[Onop]		"Noop",			"",		evalnop,
@@ -1906,8 +1920,8 @@
 
 	[Oacq]		"Acquire",		"@2",		evalnop,
 	[Orel]		"Release",		"@",		evalnop,
-	[Ostall]	"Stall",		"i",		evalnop,
-	[Osleep]	"Sleep",		"i",		evalnop,
+	[Ostall]	"Stall",		"i",		evalstall,
+	[Osleep]	"Sleep",		"i",		evalsleep,
 	[Oload] 	"Load", 		"*@}", 		evalload,
 	[Ounload]	"Unload",		"@",		evalnop,
 };
@@ -2036,6 +2050,27 @@
 	}
 }
 
+static void*
+evalosi(void)
+{
+	static char *w[] = { 
+		"Windows 2001",
+		"Windows 2001 SP1",
+		"Windows 2001 SP2",
+		"Windows 2006",
+	};
+	char *s;
+	int i;
+
+	s = deref(FP->arg[0]);
+	if(s == nil || TAG(s) != 's')
+		return nil;
+	for(i = 0; i < nelem(w); i++)
+		if(strcmp(s, w[i]) == 0)
+			return mki(0xFFFFFFFF);
+	return nil;
+}
+
 void
 amlinit(void)
 {
@@ -2065,7 +2100,7 @@
 
 		m = mk('m', sizeof(Method));
 		m->narg = 1;
-		m->eval = evalnop;
+		m->eval = evalosi;
 		m->name = n;
 		n->v = m;
 	}
--- /dev/null
+++ b/sys/src/libaml/amldelay.c
@@ -1,0 +1,8 @@
+#include <u.h>
+#include <libc.h>
+#include <aml.h>
+
+void
+amldelay(int)
+{
+}
--- a/sys/src/libaml/mkfile
+++ b/sys/src/libaml/mkfile
@@ -6,6 +6,7 @@
 	amlmapio.$O\
 	amlunmapio.$O\
 	amlalloc.$O\
+	amldelay.$O\
 
 HFILES=/sys/include/aml.h