acpi: use Tblsz enum instead of sizeof(Tbl) due to alignment, enable use tsc on terminal kernel (thank erik)

This commit is contained in:
cinap_lenrek 2013-06-19 22:26:27 +02:00
parent 40bc0b9de7
commit 5bb8203bf6
3 changed files with 18 additions and 10 deletions

View file

@ -37,6 +37,10 @@ struct Tbl {
uchar data[];
};
enum {
Tblsz = 4+4+1+1+6+8+4+4+4,
};
static Rsd *rsd;
/* physical addresses visited by maptable() */
@ -82,7 +86,7 @@ get64(uchar *p){
static uint
tbldlen(Tbl *t){
return get32(t->len) - sizeof(Tbl);
return get32(t->len) - Tblsz;
}
static void
@ -109,7 +113,7 @@ maptable(uvlong xpa)
if((t = vmap(pa, 8)) == nil)
return;
l = get32(t->len);
if(l < sizeof(Tbl)){
if(l < Tblsz){
vunmap(t, 8);
return;
}
@ -396,7 +400,7 @@ Foundapic:
a->addr = va;
a->lintr[0] = ApicIMASK;
a->lintr[1] = ApicIMASK;
a->flags = (p[4] & PcmpEN);
a->flags = p[4] & PcmpEN;
if(a->flags & PcmpEN){
a->machno = machno++;
@ -515,7 +519,7 @@ identify(void)
return 1;
if((cp = getconf("*nomp")) != nil && strcmp(cp, "0") != 0)
return 1;
if(cpuserver && m->havetsc)
if(m->havetsc)
archacpi.fastclock = tscticks;
return 0;
}

View file

@ -395,7 +395,7 @@ identify(void)
return 1;
}
if(cpuserver && m->havetsc)
if(m->havetsc)
archmp.fastclock = tscticks;
return 0;

View file

@ -25,6 +25,10 @@ struct Tbl {
uchar data[];
};
enum {
Tblsz = 4+4+1+1+6+8+4+4+4,
};
void*
amlalloc(int n){
return mallocz(n, 1);
@ -64,15 +68,15 @@ loadacpi(void)
amlinit();
for(;;){
t = malloc(sizeof(*t));
if((n = readn(fd, t, sizeof(*t))) <= 0)
if((n = readn(fd, t, Tblsz)) <= 0)
break;
if(n != sizeof(*t))
if(n != Tblsz)
return -1;
l = get32(t->len);
if(l < sizeof(*t))
if(l < Tblsz)
return -1;
t = realloc(t, l);
l -= sizeof(*t);
l -= Tblsz;
t = realloc(t, sizeof(*t) + l);
if(readn(fd, t->data, l) != l)
return -1;
if(memcmp("DSDT", t->sig, 4) == 0)