diff --git a/sys/include/aml.h b/sys/include/aml.h index 915e1e4e2..d1864a60c 100644 --- a/sys/include/aml.h +++ b/sys/include/aml.h @@ -44,6 +44,8 @@ int amldebug; extern void* amlalloc(int); extern void amlfree(void*); +extern void amldelay(int); /* microseconds */ + enum { MemSpace = 0x00, IoSpace = 0x01, diff --git a/sys/src/libaml/aml.c b/sys/src/libaml/aml.c index 7487ab9c5..0de0297a9 100644 --- a/sys/src/libaml/aml.c +++ b/sys/src/libaml/aml.c @@ -1788,7 +1788,7 @@ evalload(void) 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 @@ evalload(void) 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 @@ static Op optab[] = { [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 @@ amlnew(char tag, int len) } } +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 @@ amlinit(void) m = mk('m', sizeof(Method)); m->narg = 1; - m->eval = evalnop; + m->eval = evalosi; m->name = n; n->v = m; } diff --git a/sys/src/libaml/amldelay.c b/sys/src/libaml/amldelay.c new file mode 100644 index 000000000..804352bf5 --- /dev/null +++ b/sys/src/libaml/amldelay.c @@ -0,0 +1,8 @@ +#include +#include +#include + +void +amldelay(int) +{ +} diff --git a/sys/src/libaml/mkfile b/sys/src/libaml/mkfile index d012bb52c..f4a048bc1 100644 --- a/sys/src/libaml/mkfile +++ b/sys/src/libaml/mkfile @@ -6,6 +6,7 @@ OFILES=\ amlmapio.$O\ amlunmapio.$O\ amlalloc.$O\ + amldelay.$O\ HFILES=/sys/include/aml.h