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,
|
||||
};
|
||||
extern int state;
|
||||
extern int debug;
|
||||
|
||||
enum {
|
||||
BY2PG = 4096
|
||||
|
|
|
@ -368,7 +368,7 @@ movcr(ExitInfo *ei)
|
|||
case 0:
|
||||
switch(q >> 4 & 3){
|
||||
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]));
|
||||
skipinstr(ei);
|
||||
break;
|
||||
|
@ -390,7 +390,7 @@ movcr(ExitInfo *ei)
|
|||
case 4:
|
||||
switch(q >> 4 & 3){
|
||||
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]));
|
||||
skipinstr(ei);
|
||||
break;
|
||||
|
@ -405,7 +405,7 @@ movcr(ExitInfo *ei)
|
|||
}
|
||||
break;
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,7 +11,8 @@ void pitadvance(void);
|
|||
void rtcadvance(void);
|
||||
void settimer(vlong targ);
|
||||
void vmerror(char *, ...);
|
||||
void vmdebug(char *, ...);
|
||||
#pragma varargck argpos vmerror 1
|
||||
#define vmdebug if(!debug) {} else vmerror
|
||||
int ctl(char *, ...);
|
||||
void registermmio(uvlong, uvlong, uvlong (*)(int, uvlong, uvlong));
|
||||
void irqline(int, int);
|
||||
|
|
|
@ -118,7 +118,7 @@ idegoio(IDE *d, int wr)
|
|||
|
||||
addr = getlba(d);
|
||||
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);
|
||||
d->stat = IDEDRDY | IDEDSC | IDEDRQ | IDEERR;
|
||||
d->err = IDEIDNF;
|
||||
|
@ -325,7 +325,7 @@ ideioproc(void *dp)
|
|||
qunlock(io);
|
||||
werrstr("eof");
|
||||
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);
|
||||
io->err = IDEUNC;
|
||||
qunlock(io);
|
||||
|
@ -355,7 +355,7 @@ idecmd(IDE *d, u8int cmd)
|
|||
break;
|
||||
default:
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -435,7 +435,7 @@ idecmd(IDE *d, u8int cmd)
|
|||
case 0x66: d->flags |= IDEKEEPFEAT; break; /* retain settings */
|
||||
case 0xcc: d->flags &= ~IDEKEEPFEAT; break; /* revert to default on reset */
|
||||
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->err = IDEABRT;
|
||||
return;
|
||||
|
@ -443,7 +443,7 @@ idecmd(IDE *d, u8int cmd)
|
|||
d->stat = IDEDRDY|IDEDSC;
|
||||
break;
|
||||
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->err = IDEABRT;
|
||||
}
|
||||
|
|
|
@ -292,7 +292,7 @@ picio(int isin, u16int port, u32int val, int sz, void *)
|
|||
p->imr = 0;
|
||||
p->prio = 7;
|
||||
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;
|
||||
return 0;
|
||||
}
|
||||
|
@ -347,7 +347,7 @@ picio(int isin, u16int port, u32int val, int sz, void *)
|
|||
case 0xa1:
|
||||
switch(p->init){
|
||||
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;
|
||||
case 1:
|
||||
p->base = val;
|
||||
|
@ -355,11 +355,11 @@ picio(int isin, u16int port, u32int val, int sz, void *)
|
|||
return 0;
|
||||
case 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;
|
||||
return 0;
|
||||
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;
|
||||
p->init = 4;
|
||||
picupdate(p);
|
||||
|
|
|
@ -48,23 +48,6 @@ vmerror(char *fmt, ...)
|
|||
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
|
||||
ctl(char *fmt, ...)
|
||||
{
|
||||
|
@ -616,7 +599,6 @@ threadmain(int argc, char **argv)
|
|||
waitch = chancreate(sizeof(char *), 32);
|
||||
sleepch = chancreate(sizeof(ulong), 32);
|
||||
notifch = chancreate(sizeof(VmxNotif), 16);
|
||||
debug = 0;
|
||||
|
||||
ARGBEGIN {
|
||||
case 'm':
|
||||
|
|
Loading…
Reference in a new issue