1 #include <u.h>
2 #include <libc.h>
3 #include <bio.h>
4
5 #include "pci.h"
6 #include "vga.h"
7
8 int vflag, Vflag;
9
10 void
error(char * format,...)11 error(char* format, ...)
12 {
13 char buf[512], *out;
14 va_list arg;
15 int n;
16
17 sequencer(0, 1);
18 n = sprint(buf, "%s: ", argv0);
19 va_start(arg, format);
20 out = vseprint(buf+n, buf+sizeof(buf)-n, format, arg);
21 va_end(arg);
22 if(vflag)
23 Bprint(&stdout, "%s", buf+n);
24 Bflush(&stdout);
25 write(2, buf, out-buf);
26 exits("error");
27 }
28
29 void
trace(char * format,...)30 trace(char* format, ...)
31 {
32 char buf[512];
33 va_list arg;
34
35 if(vflag || Vflag){
36 if(curprintindex){
37 curprintindex = 0;
38 Bprint(&stdout, "\n");
39 }
40 va_start(arg, format);
41 vseprint(buf, buf+sizeof(buf), format, arg);
42 va_end(arg);
43 Bprint(&stdout, "%s", buf);
44 if(Vflag)
45 print("%s", buf);
46 }
47 }
48