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:
parent
81618e61df
commit
cf166c3850
4 changed files with 50 additions and 4 deletions
|
@ -44,6 +44,8 @@ int amldebug;
|
||||||
extern void* amlalloc(int);
|
extern void* amlalloc(int);
|
||||||
extern void amlfree(void*);
|
extern void amlfree(void*);
|
||||||
|
|
||||||
|
extern void amldelay(int); /* microseconds */
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
MemSpace = 0x00,
|
MemSpace = 0x00,
|
||||||
IoSpace = 0x01,
|
IoSpace = 0x01,
|
||||||
|
|
|
@ -1788,7 +1788,7 @@ evalload(void)
|
||||||
if(FP->arg[0] == nil)
|
if(FP->arg[0] == nil)
|
||||||
return nil;
|
return nil;
|
||||||
|
|
||||||
l = rwreg(FP->arg[0], LenOffset, 32, 0, 0);
|
l = rwreg(FP->arg[0], LenOffset, 4, 0, 0);
|
||||||
if(l <= HdrLen)
|
if(l <= HdrLen)
|
||||||
return nil;
|
return nil;
|
||||||
|
|
||||||
|
@ -1819,6 +1819,20 @@ evalload(void)
|
||||||
return tid;
|
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[] = {
|
static Op optab[] = {
|
||||||
[Obad] "", "", evalbad,
|
[Obad] "", "", evalbad,
|
||||||
[Onop] "Noop", "", evalnop,
|
[Onop] "Noop", "", evalnop,
|
||||||
|
@ -1906,8 +1920,8 @@ static Op optab[] = {
|
||||||
|
|
||||||
[Oacq] "Acquire", "@2", evalnop,
|
[Oacq] "Acquire", "@2", evalnop,
|
||||||
[Orel] "Release", "@", evalnop,
|
[Orel] "Release", "@", evalnop,
|
||||||
[Ostall] "Stall", "i", evalnop,
|
[Ostall] "Stall", "i", evalstall,
|
||||||
[Osleep] "Sleep", "i", evalnop,
|
[Osleep] "Sleep", "i", evalsleep,
|
||||||
[Oload] "Load", "*@}", evalload,
|
[Oload] "Load", "*@}", evalload,
|
||||||
[Ounload] "Unload", "@", evalnop,
|
[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
|
void
|
||||||
amlinit(void)
|
amlinit(void)
|
||||||
{
|
{
|
||||||
|
@ -2065,7 +2100,7 @@ amlinit(void)
|
||||||
|
|
||||||
m = mk('m', sizeof(Method));
|
m = mk('m', sizeof(Method));
|
||||||
m->narg = 1;
|
m->narg = 1;
|
||||||
m->eval = evalnop;
|
m->eval = evalosi;
|
||||||
m->name = n;
|
m->name = n;
|
||||||
n->v = m;
|
n->v = m;
|
||||||
}
|
}
|
||||||
|
|
8
sys/src/libaml/amldelay.c
Normal file
8
sys/src/libaml/amldelay.c
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
#include <u.h>
|
||||||
|
#include <libc.h>
|
||||||
|
#include <aml.h>
|
||||||
|
|
||||||
|
void
|
||||||
|
amldelay(int)
|
||||||
|
{
|
||||||
|
}
|
|
@ -6,6 +6,7 @@ OFILES=\
|
||||||
amlmapio.$O\
|
amlmapio.$O\
|
||||||
amlunmapio.$O\
|
amlunmapio.$O\
|
||||||
amlalloc.$O\
|
amlalloc.$O\
|
||||||
|
amldelay.$O\
|
||||||
|
|
||||||
HFILES=/sys/include/aml.h
|
HFILES=/sys/include/aml.h
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue