ref: 416aed9b662ad9e7ffa9a0bd608b29a878676a7f
parent: 469bbab4609f4b3267536ab3060efbc36515e3f5
parent: d07fb3261f596766b47f868fc6c088ec8f286cd5
author: 23hiro <23hiro@gmail.com>
date: Tue Jul 24 05:17:11 EDT 2018
merge
--- a/sys/src/9/pc/archacpi.c
+++ b/sys/src/9/pc/archacpi.c
@@ -788,7 +788,7 @@
return 1;
pa = (uintptr)strtoull(cp, nil, 16);
if(pa <= 1)
- rsd = sigsearch("RSD PTR ");
+ rsd = rsdsearch();
else if(pa < MemMin)
rsd = KADDR(pa);
else
--- a/sys/src/9/pc/archmp.c
+++ b/sys/src/9/pc/archmp.c
@@ -395,7 +395,7 @@
* if correct, check the version.
* To do: check extended table checksum.
*/
- if((_mp_ = sigsearch("_MP_")) == nil || checksum(_mp_, _MP_sz) != 0 || _mp_->physaddr == 0)
+ if((_mp_ = sigsearch("_MP_", _MP_sz)) == nil || _mp_->physaddr == 0)
return 1;
len = PCMPsz;
--- a/sys/src/9/pc/bios32.c
+++ b/sys/src/9/pc/bios32.c
@@ -54,9 +54,7 @@
BIOS32sdh *sdh;
VFLAG("bios32link\n");
- if((sdh = sigsearch("_32_")) == nil)
- return -1;
- if(checksum(sdh, sizeof(BIOS32sdh)))
+ if((sdh = sigsearch("_32_", sizeof(BIOS32sdh))) == nil)
return -1;
VFLAG("sdh @ %#p, entry %#ux\n", sdh, l32get(sdh->physaddr));
--- a/sys/src/9/pc/fns.h
+++ b/sys/src/9/pc/fns.h
@@ -171,10 +171,11 @@
void* rampage(void);
int rdmsr(int, vlong*);
void realmode(Ureg*);
+void* rsdsearch(void);
void screeninit(void);
void (*screenputs)(char*, int);
void setconfenv(void);
-void* sigsearch(char*);
+void* sigsearch(char*, int);
void syncclock(void);
void* tmpmap(Page*);
void tmpunmap(void*);
--- a/sys/src/9/pc/memory.c
+++ b/sys/src/9/pc/memory.c
@@ -21,8 +21,9 @@
MemUPA = 0, /* unbacked physical address */
MemRAM = 1, /* physical memory */
MemUMB = 2, /* upper memory block (<16MB) */
- MemReserved = 3,
- NMemType = 4,
+ MemACPI = 3, /* ACPI tables */
+ MemReserved = 4,
+ NMemType = 5,
KB = 1024,
@@ -75,6 +76,13 @@
&mapumbrw[nelem(mapumbrw)-1],
};
+static Map mapacpi[16];
+static RMap rmapacpi = {
+ "ACPI tables",
+ mapacpi,
+ &mapacpi[nelem(mapacpi)-1],
+};
+
void
mapprint(RMap *rmap)
{
@@ -101,6 +109,7 @@
mapprint(&rmapumb);
mapprint(&rmapumbrw);
mapprint(&rmapupa);
+ mapprint(&rmapacpi);
}
static void
@@ -327,16 +336,20 @@
}
static void*
-sigscan(uchar* addr, int len, char* signature)
+sigscan(uchar *addr, int len, char *sig, int size, int step)
{
- int sl;
uchar *e, *p;
+ int sl;
- e = addr+len;
- sl = strlen(signature);
- for(p = addr; p+sl < e; p += 16)
- if(memcmp(p, signature, sl) == 0)
- return p;
+ sl = strlen(sig);
+ e = addr+len-(size > sl ? size : sl);
+ for(p = addr; p <= e; p += step){
+ if(memcmp(p, sig, sl) != 0)
+ continue;
+ if(size && checksum(p, size) != 0)
+ continue;
+ return p;
+ }
return nil;
}
@@ -359,7 +372,7 @@
}
void*
-sigsearch(char* signature)
+sigsearch(char* signature, int size)
{
uintptr p;
uchar *bda;
@@ -376,20 +389,46 @@
bda = KADDR(0x400);
if(memcmp(KADDR(0xfffd9), "EISA", 4) == 0){
if((p = (bda[0x0f]<<8)|bda[0x0e]) != 0){
- if((r = sigscan(KADDR(p<<4), 1024, signature)) != nil)
+ if((r = sigscan(KADDR(p<<4), 1024, signature, size, 16)) != nil)
return r;
}
}
- if((r = sigscan(KADDR(convmemsize()), 1024, signature)) != nil)
+ if((r = sigscan(KADDR(convmemsize()), 1024, signature, size, 16)) != nil)
return r;
/* hack for virtualbox: look in KiB below 0xa0000 */
- if((r = sigscan(KADDR(0xa0000-1024), 1024, signature)) != nil)
+ if((r = sigscan(KADDR(0xa0000-1024), 1024, signature, size, 16)) != nil)
return r;
- return sigscan(KADDR(0xe0000), 0x20000, signature);
+ return sigscan(KADDR(0xe0000), 0x20000, signature, size, 16);
}
+void*
+rsdsearch(void)
+{
+ static char signature[] = "RSD PTR ";
+ uchar *v, *p;
+ Map *m;
+
+ if((p = sigsearch(signature, 36)) != nil)
+ return p;
+ if((p = sigsearch(signature, 20)) != nil)
+ return p;
+ for(m = rmapacpi.map; m < rmapacpi.mapend && m->size; m++){
+ if(m->size > 0x7FFFFFFF)
+ continue;
+ if((v = vmap(m->addr, m->size)) != nil){
+ p = sigscan(v, m->size, signature, 36, 4);
+ if(p == nil)
+ p = sigscan(v, m->size, signature, 20, 4);
+ vunmap(v, m->size);
+ if(p != nil)
+ return vmap(m->addr + (p - v), 64);
+ }
+ }
+ return nil;
+}
+
static void
lowraminit(void)
{
@@ -683,6 +722,10 @@
mapfree(&rmapupa, base, len);
flags = 0;
break;
+ case MemACPI:
+ mapfree(&rmapacpi, base, len);
+ flags = 0;
+ break;
default:
case MemReserved:
flags = 0;
@@ -774,7 +817,18 @@
*/
if(last < base)
map(last, base-last, MemUPA);
- map(base, len, (e->type == 1) ? MemRAM : MemReserved);
+
+ switch(e->type){
+ case 1:
+ map(base, len, MemRAM);
+ break;
+ case 3:
+ map(base, len, MemACPI);
+ break;
+ default:
+ map(base, len, MemReserved);
+ }
+
last = base + len;
if(last == 0)
break;
--- a/sys/src/9/pc/pci.c
+++ b/sys/src/9/pc/pci.c
@@ -748,7 +748,7 @@
Pcidev *sbpci, *pci;
uchar *p, pin, irq, link, *map;
- if((p = sigsearch("$PIR")) == nil)
+ if((p = sigsearch("$PIR", 0)) == nil)
return;
r = (Router*)p;
--- a/sys/src/9/pc64/fns.h
+++ b/sys/src/9/pc64/fns.h
@@ -170,10 +170,11 @@
void* rampage(void);
int rdmsr(int, vlong*);
void realmode(Ureg*);
+void* rsdsearch(void);
void screeninit(void);
void (*screenputs)(char*, int);
void setconfenv(void);
-void* sigsearch(char*);
+void* sigsearch(char*, int);
void syncclock(void);
void syscallentry(void);
void touser(void*);
--- a/sys/src/9/pc64/memory.c
+++ b/sys/src/9/pc64/memory.c
@@ -20,8 +20,9 @@
MemUPA = 0, /* unbacked physical address */
MemRAM = 1, /* physical memory */
MemUMB = 2, /* upper memory block (<16MB) */
- MemReserved = 3,
- NMemType = 4,
+ MemACPI = 3, /* ACPI tables */
+ MemReserved = 4,
+ NMemType = 5,
KB = 1024,
};
@@ -72,6 +73,13 @@
&mapumbrw[nelem(mapumbrw)-1],
};
+static Map mapacpi[16];
+static RMap rmapacpi = {
+ "ACPI tables",
+ mapacpi,
+ &mapacpi[nelem(mapacpi)-1],
+};
+
void
mapprint(RMap *rmap)
{
@@ -98,6 +106,7 @@
mapprint(&rmapumb);
mapprint(&rmapumbrw);
mapprint(&rmapupa);
+ mapprint(&rmapacpi);
}
static void
@@ -324,16 +333,20 @@
}
static void*
-sigscan(uchar* addr, int len, char* signature)
+sigscan(uchar *addr, int len, char *sig, int size, int step)
{
- int sl;
uchar *e, *p;
+ int sl;
- e = addr+len;
- sl = strlen(signature);
- for(p = addr; p+sl < e; p += 16)
- if(memcmp(p, signature, sl) == 0)
- return p;
+ sl = strlen(sig);
+ e = addr+len-(size > sl ? size : sl);
+ for(p = addr; p <= e; p += step){
+ if(memcmp(p, sig, sl) != 0)
+ continue;
+ if(size && checksum(p, size) != 0)
+ continue;
+ return p;
+ }
return nil;
}
@@ -356,7 +369,7 @@
}
void*
-sigsearch(char* signature)
+sigsearch(char* signature, int size)
{
uintptr p;
uchar *bda;
@@ -373,20 +386,46 @@
bda = KADDR(0x400);
if(memcmp(KADDR(0xfffd9), "EISA", 4) == 0){
if((p = (bda[0x0f]<<8)|bda[0x0e]) != 0){
- if((r = sigscan(KADDR(p<<4), 1024, signature)) != nil)
+ if((r = sigscan(KADDR(p<<4), 1024, signature, size, 16)) != nil)
return r;
}
}
- if((r = sigscan(KADDR(convmemsize()), 1024, signature)) != nil)
+ if((r = sigscan(KADDR(convmemsize()), 1024, signature, size, 16)) != nil)
return r;
/* hack for virtualbox: look in KiB below 0xa0000 */
- if((r = sigscan(KADDR(0xa0000-1024), 1024, signature)) != nil)
+ if((r = sigscan(KADDR(0xa0000-1024), 1024, signature, size, 16)) != nil)
return r;
- return sigscan(KADDR(0xe0000), 0x20000, signature);
+ return sigscan(KADDR(0xe0000), 0x20000, signature, size, 16);
}
+void*
+rsdsearch(void)
+{
+ static char signature[] = "RSD PTR ";
+ uchar *v, *p;
+ Map *m;
+
+ if((p = sigsearch(signature, 36)) != nil)
+ return p;
+ if((p = sigsearch(signature, 20)) != nil)
+ return p;
+ for(m = rmapacpi.map; m < rmapacpi.mapend && m->size; m++){
+ if(m->size > 0x7FFFFFFF)
+ continue;
+ if((v = vmap(m->addr, m->size)) != nil){
+ p = sigscan(v, m->size, signature, 36, 4);
+ if(p == nil)
+ p = sigscan(v, m->size, signature, 20, 4);
+ vunmap(v, m->size);
+ if(p != nil)
+ return vmap(m->addr + (p - v), 64);
+ }
+ }
+ return nil;
+}
+
static void
lowraminit(void)
{
@@ -514,8 +553,12 @@
mapfree(&rmapupa, base, len);
flags = 0;
break;
- default:
+ case MemACPI:
+ mapfree(&rmapacpi, base, len);
+ flags = 0;
+ break;
case MemReserved:
+ default:
flags = 0;
break;
}
@@ -584,7 +627,16 @@
*/
if(last < base)
map(last, base-last, MemUPA);
- map(base, len, (e->type == 1) ? MemRAM : MemReserved);
+ switch(e->type){
+ case 1:
+ map(base, len, MemRAM);
+ break;
+ case 3:
+ map(base, len, MemACPI);
+ break;
+ default:
+ map(base, len, MemReserved);
+ }
last = base + len;
if(last == 0)
break;
--- a/sys/src/9/port/devmnt.c
+++ b/sys/src/9/port/devmnt.c
@@ -307,6 +307,9 @@
Mnt *m;
Mntrpc *r;
+ if(ac != nil && ac->mchan != c)
+ error(Ebadusefd);
+
m = c->mux;
if(m == nil){
mntversion(c, nil, 0, 0);
--- a/sys/src/9/port/devmouse.c
+++ b/sys/src/9/port/devmouse.c
@@ -291,7 +291,7 @@
b = 16;
else if (b == 16)
b = 8;
- sprint(buf, "m%11d %11d %11d %11lud ",
+ sprint(buf, "m%11d %11d %11d %11ld ",
m.xy.x, m.xy.y, b, m.msec);
mouse.lastcounter = m.counter;
@@ -448,7 +448,7 @@
if(*p == 0)
error(Eshort);
b = strtol(p, &p, 0);
- msec = strtol(p, 0, 0);
+ msec = (ulong)strtoll(p, 0, 0);
if(msec == 0)
msec = TK2MS(MACHP(0)->ticks);
--- a/sys/src/cmd/ndb/dnserver.c
+++ b/sys/src/cmd/ndb/dnserver.c
@@ -67,34 +67,34 @@
Oquery;
return;
}
- } else
- if(norecursion) {
- /* we don't recurse and we're not authoritative */
- repp->flags = Rok | Fresp | Oquery;
- return;
- }
+ }
+ if(myarea == nil && norecursion) {
+ /* we don't recurse and we're not authoritative */
+ repp->flags = Rok | Fresp | Oquery;
+ neg = nil;
+ } else {
+ /*
+ * get the answer if we can, in *repp
+ */
+ if(reqp->flags & Frecurse)
+ neg = doextquery(repp, req, Recurse);
+ else
+ neg = doextquery(repp, req, Dontrecurse);
- /*
- * get the answer if we can, in *repp
- */
- if(reqp->flags & Frecurse)
- neg = doextquery(repp, req, Recurse);
- else
- neg = doextquery(repp, req, Dontrecurse);
+ /* authority is transitive */
+ if(myarea != nil || (repp->an && repp->an->auth))
+ repp->flags |= Fauth;
- /* authority is transitive */
- if(myarea != nil || (repp->an && repp->an->auth))
- repp->flags |= Fauth;
-
- /* pass on error codes */
- if(repp->an == nil){
- dp = dnlookup(repp->qd->owner->name, repp->qd->owner->class, 0);
- if(dp->rr == nil)
- if(reqp->flags & Frecurse)
- repp->flags |= dp->respcode | Fauth;
+ /* pass on error codes */
+ if(repp->an == nil){
+ dp = dnlookup(repp->qd->owner->name, repp->qd->owner->class, 0);
+ if(dp->rr == nil)
+ if(reqp->flags & Frecurse)
+ repp->flags |= dp->respcode | Fauth;
+ }
}
- if(myarea == nil)
+ if(myarea == nil){
/*
* add name server if we know
*/
@@ -120,6 +120,7 @@
if(repp->ns)
break;
}
+ }
/*
* add ip addresses as hints
@@ -135,7 +136,7 @@
* add an soa to the authority section to help client
* with negative caching
*/
- if(repp->an == nil)
+ if(repp->an == nil){
if(myarea != nil){
rrcopy(myarea->soarr, &tp);
rrcat(&repp->ns, tp);
@@ -146,6 +147,7 @@
}
repp->flags |= neg->negrcode;
}
+ }
/*
* get rid of duplicates
--- a/sys/src/cmd/ssh.c
+++ b/sys/src/cmd/ssh.c
@@ -1151,7 +1151,9 @@
fmtinstall('k', kfmt);
tty.term = getenv("TERM");
- raw = tty.term != nil && *tty.term != 0;
+ if(tty.term == nil)
+ tty.term = "";
+ raw = *tty.term != 0;
ARGBEGIN {
case 'd':
--- a/sys/src/cmd/vnc/devmouse.c
+++ b/sys/src/cmd/vnc/devmouse.c
@@ -191,7 +191,7 @@
m = mouse.Mousestate;
unlock(&mouse);
- sprint(buf, "m%11d %11d %11d %11lud ",
+ sprint(buf, "m%11d %11d %11d %11ld ",
m.xy.x, m.xy.y, m.buttons, m.msec);
mouse.lastcounter = m.counter;
--- a/sys/src/games/dmid.c
+++ b/sys/src/games/dmid.c
@@ -31,7 +31,7 @@
struct Inst{
int fixed;
int dbl;
- uchar fine;
+ int fine;
uchar n;
uchar i[13];
uchar i2[13];
@@ -225,13 +225,16 @@
void
setoct(Opl *o)
{
- int n, b, f;
+ int n, b, f, d;
+ double e;
- n = o->n + o->c->bend / 0x1000 & 0x7f;
- f = freq[n] + (o->c->bend % 0x1000) * (freq[n+1] - freq[n]) / 0x1000;
- f = (f * (1 << 20)) / 49716;
- //if(o->i == o->c->i->i2)
- // f += o->c->i->fine; /* nope */
+ d = o->c->bend;
+ d += o->i == o->c->i->i2 ? o->c->i->fine : 0;
+ n = o->n + d / 0x1000 & 0x7f;
+ e = freq[n] + (d % 0x1000) * (freq[n+1] - freq[n]) / 0x1000;
+ if(o->c->i->fixed)
+ e = (double)(int)e;
+ f = (e * (1 << 20)) / 49716;
for(b=1; b<8; b++, f>>=1)
if(f < 1024)
break;
@@ -448,7 +451,7 @@
i->fixed = n & 1<<0;
i->dbl = opl2 ? 0 : n & 1<<2;
get8(nil);
- i->fine = get8(nil) / 2 - 64;
+ i->fine = (get8(nil) - 128) * 64;
i->n = get8(nil);
bread(i->i, sizeof i->i);
get8(nil);
--- a/sys/src/games/doom/d_main.c
+++ b/sys/src/games/doom/d_main.c
@@ -635,6 +635,11 @@
gamemode = indetermined;
return;
}
+ if(gamemode != indetermined && rfork(RFPROC|RFFDG) == 0){
+ close(2);
+ execl("/bin/games/wadfs", "wadfs", wadfile, nil);
+ sysfatal("execl: %r");
+ }
strncpy(basedefault, wadfile, sizeof(basedefault)-5);
basedefault[sizeof(basedefault)-5] = '\0';
slash = strrchr(basedefault, '/');
--- a/sys/src/games/doom/i_sound.c
+++ b/sys/src/games/doom/i_sound.c
@@ -462,15 +462,7 @@
case 0:
dup(mpfd[1], 1);
for(n=3; n<20; n++) close(n);
- close(0);
- snprint(name, sizeof(name), "/tmp/doom.%d", getpid());
- if(create(name, ORDWR|ORCLOSE, 0666) != 0)
- sysfatal("create: %r");
- n = W_LumpLength(m->lumpnum);
- if(write(0, m->data, n) != n)
- sysfatal("write: %r");
- if(seek(0, 0, 0) != 0)
- sysfatal("seek: %r");
+ snprint(name, sizeof(name), "/mnt/wad/d_%s", m->name);
if(bind("/fd/1", "/dev/audio", MREPL) < 0)
sysfatal("bind: %r");
while(loop && fork() > 0){
--- a/sys/src/libdraw/event.c
+++ b/sys/src/libdraw/event.c
@@ -396,7 +396,7 @@
m.buttons = b;
m.xy.x = atoi((char*)eb->buf+1+0*12);
m.xy.y = atoi((char*)eb->buf+1+1*12);
- m.msec = atoi((char*)eb->buf+1+3*12);
+ m.msec = (ulong)atoll((char*)eb->buf+1+3*12);
if (logfid)
fprint(logfid, "b: %d xy: %P\n", m.buttons, m.xy);
free(eb);
@@ -470,6 +470,6 @@
m->xy.x = atoi(buf+1+0*12);
m->xy.y = atoi(buf+1+1*12);
m->buttons = atoi(buf+1+2*12);
- m->msec = atoi(buf+1+3*12);
+ m->msec = (ulong)atoll(buf+1+3*12);
return n;
}
--- a/sys/src/libdraw/mouse.c
+++ b/sys/src/libdraw/mouse.c
@@ -73,7 +73,7 @@
m.xy.x = atoi(buf+1+0*12);
m.xy.y = atoi(buf+1+1*12);
m.buttons = atoi(buf+1+2*12);
- m.msec = atoi(buf+1+3*12);
+ m.msec = (ulong)atoll(buf+1+3*12);
if(send(mc->c, &m) < 0)
continue;
/*