ref: de5770c3523e8ecb4f639417bf6f7592ed703c37
parent: 07805ac8927ca8034a2e1bc39ef1b6a20f80806c
author: cinap_lenrek <[email protected]>
date: Tue Dec 8 07:40:28 EST 2020
vmx: add fmt checking, fix fmt errors, remove duplication for vmdebug
--- a/sys/src/cmd/vmx/dat.h
+++ b/sys/src/cmd/vmx/dat.h
@@ -11,6 +11,7 @@
VMDEAD,
};
extern int state;
+extern int debug;
enum {
BY2PG = 4096
--- a/sys/src/cmd/vmx/exith.c
+++ b/sys/src/cmd/vmx/exith.c
@@ -368,7 +368,7 @@
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 @@
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 @@
}
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);
}
}
--- a/sys/src/cmd/vmx/fns.h
+++ b/sys/src/cmd/vmx/fns.h
@@ -11,7 +11,8 @@
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);
--- a/sys/src/cmd/vmx/ide.c
+++ b/sys/src/cmd/vmx/ide.c
@@ -118,7 +118,7 @@
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 @@
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 @@
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 @@
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 @@
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;
}
--- a/sys/src/cmd/vmx/io.c
+++ b/sys/src/cmd/vmx/io.c
@@ -292,7 +292,7 @@
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 @@
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 @@
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);
--- a/sys/src/cmd/vmx/vmx.c
+++ b/sys/src/cmd/vmx/vmx.c
@@ -48,23 +48,6 @@
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 @@
waitch = chancreate(sizeof(char *), 32);
sleepch = chancreate(sizeof(ulong), 32);
notifch = chancreate(sizeof(VmxNotif), 16);
- debug = 0;
ARGBEGIN {
case 'm':