summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xrc/bin/xargs2
-rw-r--r--sys/src/cmd/aux/icanhasmsi.c60
-rw-r--r--sys/src/games/xs.c4
3 files changed, 64 insertions, 2 deletions
diff --git a/rc/bin/xargs b/rc/bin/xargs
index 0387f2712..4255b3440 100755
--- a/rc/bin/xargs
+++ b/rc/bin/xargs
@@ -19,3 +19,5 @@ while(~ $1 -*) {
}
while(x = `{read -n $nargs})
$* $x
+if(! ~ $#x 0)
+ $* $x
diff --git a/sys/src/cmd/aux/icanhasmsi.c b/sys/src/cmd/aux/icanhasmsi.c
new file mode 100644
index 000000000..eac4acc57
--- /dev/null
+++ b/sys/src/cmd/aux/icanhasmsi.c
@@ -0,0 +1,60 @@
+#include <u.h>
+#include <libc.h>
+
+int
+pcicfg16r(int fd, ushort *s, vlong offset)
+{
+ char buf[2];
+
+ if(pread(fd, buf, 2, offset) < 2) return -1;
+ *s = buf[0] | (buf[1] << 8);
+ return 0;
+}
+
+void
+main()
+{
+ int fd;
+ long n;
+ Dir *dir;
+ char *p, *s;
+ uchar cap, c;
+ ushort sh;
+
+ fd = open("/dev/pci", OREAD);
+ if(fd < 0) sysfatal("open /dev/pci: %r");
+ n = dirreadall(fd, &dir);
+ if(n < 0) sysfatal("dirreadall /dev/pci: %r");
+ close(fd);
+ for(; n--; dir++) {
+ p = dir->name + strlen(dir->name) - 3;
+ if(strcmp(p, "raw") != 0)
+ continue;
+ s = smprint("/dev/pci/%s", dir->name);
+ fd = open(s, OREAD);
+ if(fd < 0) {
+ fprint(2, "open %s: %r", s);
+ free(s);
+ continue;
+ }
+ if(pcicfg16r(fd, &sh, 0) < 0) goto err;
+ if(sh == 0xFFFF) goto end;
+ if(pcicfg16r(fd, &sh, 0x06) < 0) goto err;
+ if((sh & (1<<4)) == 0) goto end;
+ cap = 0x33;
+ for(;;) {
+ if(pread(fd, &cap, 1, cap+1) < 0) goto err;
+ if(cap == 0) goto end;
+ if(pread(fd, &c, 1, cap) < 0) goto err;
+ if(c == 0x05) break;
+ }
+ s[strlen(s) - 3] = 0;
+ print("%s\n", s+9);
+ goto end;
+ err:
+ fprint(2, "read %s: %r", s);
+ end:
+ free(s);
+ close(fd);
+ }
+}
diff --git a/sys/src/games/xs.c b/sys/src/games/xs.c
index ef8451816..4a1a72284 100644
--- a/sys/src/games/xs.c
+++ b/sys/src/games/xs.c
@@ -848,7 +848,7 @@ threadmain(int argc, char *argv[])
snprint(buf, sizeof(buf), "/sys/games/lib/%dscores", N);
scores = open(buf, OWRITE);
if(scores < 0)
- sysfatal("can't open %s: %r", buf);
+ print("can't open %s: %r\n", buf);
tb = 0;
if(screen->depth < 3){
tb = allocimage(display, Rect(0,0,16,16), 0, 1, -1);
@@ -881,7 +881,7 @@ threadmain(int argc, char *argv[])
points = 0;
memset(board, 0, sizeof(board));
redraw(0);
- if(play()){
+ if(play() && scores >= 0){
endtime = time(0);
fprint(scores, "%ld\t%s\t%lud\t%ld\n",
points, getuser(), starttime, endtime-starttime);