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()
This commit is contained in:
cinap_lenrek 2013-09-07 14:40:24 +02:00
parent 81618e61df
commit cf166c3850
4 changed files with 50 additions and 4 deletions

View file

@ -44,6 +44,8 @@ int amldebug;
extern void* amlalloc(int);
extern void amlfree(void*);
extern void amldelay(int); /* microseconds */
enum {
MemSpace = 0x00,
IoSpace = 0x01,

View file

@ -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;
}

View file

@ -0,0 +1,8 @@
#include <u.h>
#include <libc.h>
#include <aml.h>
void
amldelay(int)
{
}

View file

@ -6,6 +6,7 @@ OFILES=\
amlmapio.$O\
amlunmapio.$O\
amlalloc.$O\
amldelay.$O\
HFILES=/sys/include/aml.h