vmx: add fmt checking, fix fmt errors, remove duplication for vmdebug
This commit is contained in:
parent
07805ac892
commit
de5770c352
6 changed files with 15 additions and 31 deletions
|
@ -11,6 +11,7 @@ enum {
|
||||||
VMDEAD,
|
VMDEAD,
|
||||||
};
|
};
|
||||||
extern int state;
|
extern int state;
|
||||||
|
extern int debug;
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
BY2PG = 4096
|
BY2PG = 4096
|
||||||
|
|
|
@ -368,7 +368,7 @@ movcr(ExitInfo *ei)
|
||||||
case 0:
|
case 0:
|
||||||
switch(q >> 4 & 3){
|
switch(q >> 4 & 3){
|
||||||
case 0:
|
case 0:
|
||||||
vmdebug("illegal CR0 write, value %#ux", rget(x86reg[q >> 8 & 15]));
|
vmdebug("illegal CR0 write, value %#ux", (u32int)rget(x86reg[q >> 8 & 15]));
|
||||||
rset("cr0real", rget(x86reg[q >> 8 & 15]));
|
rset("cr0real", rget(x86reg[q >> 8 & 15]));
|
||||||
skipinstr(ei);
|
skipinstr(ei);
|
||||||
break;
|
break;
|
||||||
|
@ -390,7 +390,7 @@ movcr(ExitInfo *ei)
|
||||||
case 4:
|
case 4:
|
||||||
switch(q >> 4 & 3){
|
switch(q >> 4 & 3){
|
||||||
case 0:
|
case 0:
|
||||||
vmdebug("illegal CR4 write, value %#ux", rget(x86reg[q >> 8 & 15]));
|
vmdebug("illegal CR4 write, value %#ux", (u32int)rget(x86reg[q >> 8 & 15]));
|
||||||
rset("cr4real", rget(x86reg[q >> 8 & 15]));
|
rset("cr4real", rget(x86reg[q >> 8 & 15]));
|
||||||
skipinstr(ei);
|
skipinstr(ei);
|
||||||
break;
|
break;
|
||||||
|
@ -405,7 +405,7 @@ movcr(ExitInfo *ei)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
vmerror("access to unknown control register CR%d", ei->qual & 15);
|
vmerror("access to unknown control register CR%ud", q & 15);
|
||||||
postexc("#ud", NOERRC);
|
postexc("#ud", NOERRC);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,8 @@ void pitadvance(void);
|
||||||
void rtcadvance(void);
|
void rtcadvance(void);
|
||||||
void settimer(vlong targ);
|
void settimer(vlong targ);
|
||||||
void vmerror(char *, ...);
|
void vmerror(char *, ...);
|
||||||
void vmdebug(char *, ...);
|
#pragma varargck argpos vmerror 1
|
||||||
|
#define vmdebug if(!debug) {} else vmerror
|
||||||
int ctl(char *, ...);
|
int ctl(char *, ...);
|
||||||
void registermmio(uvlong, uvlong, uvlong (*)(int, uvlong, uvlong));
|
void registermmio(uvlong, uvlong, uvlong (*)(int, uvlong, uvlong));
|
||||||
void irqline(int, int);
|
void irqline(int, int);
|
||||||
|
|
|
@ -118,7 +118,7 @@ idegoio(IDE *d, int wr)
|
||||||
|
|
||||||
addr = getlba(d);
|
addr = getlba(d);
|
||||||
if(addr < 0){
|
if(addr < 0){
|
||||||
vmerror("ide%d: access to invalid sector address (access to CHS=(%#.4ux,%#ux,%#.2ux); geometry is (%#.4ux,%#ux,%#.2ux)", d-ide, d->cyl, d->head&0xf, d->sec, d->lcyl, d->lhead, d->lsec);
|
vmerror("ide%zd: access to invalid sector address (access to CHS=(%#.4ux,%#ux,%#.2ux); geometry is (%#.4ux,%#ux,%#.2ux)", d-ide, d->cyl, d->head&0xf, d->sec, d->lcyl, d->lhead, d->lsec);
|
||||||
postexc("#bp", NOERRC);
|
postexc("#bp", NOERRC);
|
||||||
d->stat = IDEDRDY | IDEDSC | IDEDRQ | IDEERR;
|
d->stat = IDEDRDY | IDEDSC | IDEDRQ | IDEERR;
|
||||||
d->err = IDEIDNF;
|
d->err = IDEIDNF;
|
||||||
|
@ -325,7 +325,7 @@ ideioproc(void *dp)
|
||||||
qunlock(io);
|
qunlock(io);
|
||||||
werrstr("eof");
|
werrstr("eof");
|
||||||
if(getsector(a+i, p) < 0 && pread(d->fd, p, 512, (a+i)*512) < 512){
|
if(getsector(a+i, p) < 0 && pread(d->fd, p, 512, (a+i)*512) < 512){
|
||||||
vmerror("ide%d: read: %r", d - ide);
|
vmerror("ide%zd: read: %r", d - ide);
|
||||||
qlock(io);
|
qlock(io);
|
||||||
io->err = IDEUNC;
|
io->err = IDEUNC;
|
||||||
qunlock(io);
|
qunlock(io);
|
||||||
|
@ -355,7 +355,7 @@ idecmd(IDE *d, u8int cmd)
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
if((d->flags & IDEPRESENT) == 0){
|
if((d->flags & IDEPRESENT) == 0){
|
||||||
vmerror("ide%d: command %#ux issued to absent drive", d-ide, cmd);
|
vmerror("ide%zd: command %#ux issued to absent drive", d-ide, cmd);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -435,7 +435,7 @@ idecmd(IDE *d, u8int cmd)
|
||||||
case 0x66: d->flags |= IDEKEEPFEAT; break; /* retain settings */
|
case 0x66: d->flags |= IDEKEEPFEAT; break; /* retain settings */
|
||||||
case 0xcc: d->flags &= ~IDEKEEPFEAT; break; /* revert to default on reset */
|
case 0xcc: d->flags &= ~IDEKEEPFEAT; break; /* revert to default on reset */
|
||||||
default:
|
default:
|
||||||
vmerror("ide%d: unknown feature %#ux", d-ide, d->feat);
|
vmerror("ide%zd: unknown feature %#ux", d-ide, d->feat);
|
||||||
d->stat = IDEDRDY|IDEDSC|IDEERR;
|
d->stat = IDEDRDY|IDEDSC|IDEERR;
|
||||||
d->err = IDEABRT;
|
d->err = IDEABRT;
|
||||||
return;
|
return;
|
||||||
|
@ -443,7 +443,7 @@ idecmd(IDE *d, u8int cmd)
|
||||||
d->stat = IDEDRDY|IDEDSC;
|
d->stat = IDEDRDY|IDEDSC;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
vmerror("ide%d: unknown command %#ux", d-ide, cmd);
|
vmerror("ide%zd: unknown command %#ux", d-ide, cmd);
|
||||||
d->stat = IDEDRDY|IDEDSC|IDEERR;
|
d->stat = IDEDRDY|IDEDSC|IDEERR;
|
||||||
d->err = IDEABRT;
|
d->err = IDEABRT;
|
||||||
}
|
}
|
||||||
|
|
|
@ -292,7 +292,7 @@ picio(int isin, u16int port, u32int val, int sz, void *)
|
||||||
p->imr = 0;
|
p->imr = 0;
|
||||||
p->prio = 7;
|
p->prio = 7;
|
||||||
p->flags = 0;
|
p->flags = 0;
|
||||||
if((val & 0x0b) != 0x01) vmerror("PIC%ld ICW1 with unsupported value %#ux", p-pic, val);
|
if((val & 0x0b) != 0x01) vmerror("PIC%zd ICW1 with unsupported value %#ux", p-pic, (u32int)val);
|
||||||
p->init = 1;
|
p->init = 1;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -347,7 +347,7 @@ picio(int isin, u16int port, u32int val, int sz, void *)
|
||||||
case 0xa1:
|
case 0xa1:
|
||||||
switch(p->init){
|
switch(p->init){
|
||||||
default:
|
default:
|
||||||
vmerror("write to PIC%ld in init=%d state", p-pic, p->init);
|
vmerror("write to PIC%zd in init=%d state", p-pic, p->init);
|
||||||
return 0;
|
return 0;
|
||||||
case 1:
|
case 1:
|
||||||
p->base = val;
|
p->base = val;
|
||||||
|
@ -355,11 +355,11 @@ picio(int isin, u16int port, u32int val, int sz, void *)
|
||||||
return 0;
|
return 0;
|
||||||
case 2:
|
case 2:
|
||||||
if(p == &pic[0] && val != 4 || p == &pic[1] && val != 2)
|
if(p == &pic[0] && val != 4 || p == &pic[1] && val != 2)
|
||||||
vmerror("PIC%ld ICW3 with unsupported value %#ux", p-pic, val);
|
vmerror("PIC%zd ICW3 with unsupported value %#ux", p-pic, val);
|
||||||
p->init = 3;
|
p->init = 3;
|
||||||
return 0;
|
return 0;
|
||||||
case 3:
|
case 3:
|
||||||
if((val & 0xfd) != 1) vmerror("PIC%ld ICW4 with unsupported value %#ux", p-pic, val);
|
if((val & 0xfd) != 1) vmerror("PIC%zd ICW4 with unsupported value %#ux", p-pic, val);
|
||||||
if((val & 2) != 0) p->flags |= AEOI;
|
if((val & 2) != 0) p->flags |= AEOI;
|
||||||
p->init = 4;
|
p->init = 4;
|
||||||
picupdate(p);
|
picupdate(p);
|
||||||
|
|
|
@ -48,23 +48,6 @@ vmerror(char *fmt, ...)
|
||||||
fmtfdflush(&f);
|
fmtfdflush(&f);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
vmdebug(char *fmt, ...)
|
|
||||||
{
|
|
||||||
Fmt f;
|
|
||||||
char buf[256];
|
|
||||||
va_list arg;
|
|
||||||
|
|
||||||
if(debug == 0)
|
|
||||||
return;
|
|
||||||
fmtfdinit(&f, 2, buf, sizeof buf);
|
|
||||||
va_start(arg, fmt);
|
|
||||||
fmtvprint(&f, fmt, arg);
|
|
||||||
va_end(arg);
|
|
||||||
fmtprint(&f, "\n");
|
|
||||||
fmtfdflush(&f);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
int
|
||||||
ctl(char *fmt, ...)
|
ctl(char *fmt, ...)
|
||||||
{
|
{
|
||||||
|
@ -616,7 +599,6 @@ threadmain(int argc, char **argv)
|
||||||
waitch = chancreate(sizeof(char *), 32);
|
waitch = chancreate(sizeof(char *), 32);
|
||||||
sleepch = chancreate(sizeof(ulong), 32);
|
sleepch = chancreate(sizeof(ulong), 32);
|
||||||
notifch = chancreate(sizeof(VmxNotif), 16);
|
notifch = chancreate(sizeof(VmxNotif), 16);
|
||||||
debug = 0;
|
|
||||||
|
|
||||||
ARGBEGIN {
|
ARGBEGIN {
|
||||||
case 'm':
|
case 'm':
|
||||||
|
|
Loading…
Reference in a new issue