Browse Source

Plan 9 from Bell Labs 2007-11-29

David du Colombier 16 years ago
parent
commit
0e89eb7dea

+ 6 - 6
dist/replica/_plan9.db

@@ -260,7 +260,7 @@
 386/bin/games/jukefs - 775 sys sys 1105589129 165320
 386/bin/games/mahjongg - 775 sys sys 1191381911 165242
 386/bin/games/memo - 775 sys sys 1179372089 156656
-386/bin/games/mp3dec - 755 sys sys 1196207154 355822
+386/bin/games/mp3dec - 775 sys sys 1196207154 355822
 386/bin/games/mp3enc - 775 sys sys 1196220182 530357
 386/bin/games/playlistfs - 775 sys sys 1105589129 148484
 386/bin/games/sokoban - 775 sys sys 1179372090 165514
@@ -1412,7 +1412,7 @@ lib/face/48x48x4/x/xigh.1 - 664 sys sys 1142019024 1204
 lib/face/48x48x4/y - 20000000775 sys sys 1020895714 0
 lib/face/48x48x4/z - 20000000775 sys sys 1020895714 0
 lib/face/48x48x8 - 20000000775 sys sys 1123100641 0
-lib/face/48x48x8/.dict - 664 sys sys 1192767500 4266
+lib/face/48x48x8/.dict - 664 sys sys 1196265401 4295
 lib/face/48x48x8/Z - 20000000775 sys sys 1020895714 0
 lib/face/48x48x8/a - 20000000775 sys sys 1056983599 0
 lib/face/48x48x8/a/alcortes.1 - 664 sys sys 1176753392 976
@@ -7430,6 +7430,7 @@ sys/man/1/mc - 664 sys sys 1113743326 552
 sys/man/1/mk - 664 sys sys 1113743328 13198
 sys/man/1/mkdir - 664 sys sys 1082593141 717
 sys/man/1/mlmgr - 664 sys sys 1116513886 2542
+sys/man/1/mp3dec - 664 sys sys 1196227746 4987
 sys/man/1/mp3enc - 664 sys sys 1196208904 3236
 sys/man/1/ms2html - 664 sys sys 1138458899 1252
 sys/man/1/mug - 664 sys sys 1158800370 1424
@@ -8065,7 +8066,7 @@ sys/src/9/pc/apbootstrap.s - 664 sys sys 1131293655 3037
 sys/src/9/pc/apic.c - 664 sys sys 1174415344 8991
 sys/src/9/pc/apm.c - 664 sys sys 1131290210 3723
 sys/src/9/pc/apmjump.s - 664 sys sys 1032058947 1527
-sys/src/9/pc/archmp.c - 664 sys sys 1174614168 2407
+sys/src/9/pc/archmp.c - 664 sys sys 1196264189 2410
 sys/src/9/pc/audio.h - 664 sys sys 1015014513 343
 sys/src/9/pc/bios32.c - 664 sys sys 1173287378 3029
 sys/src/9/pc/cga.c - 664 sys sys 1015014513 1843
@@ -13286,7 +13287,7 @@ sys/src/cmd/replica/db.c - 664 sys sys 1019340165 2989
 sys/src/cmd/replica/mkfile - 664 sys sys 1032060527 647
 sys/src/cmd/replica/revdump.c - 664 sys sys 1018321112 651
 sys/src/cmd/replica/revproto.c - 664 sys sys 1081202241 8932
-sys/src/cmd/replica/updatedb.c - 664 sys sys 1068497831 3045
+sys/src/cmd/replica/updatedb.c - 664 sys sys 1196273470 3837
 sys/src/cmd/replica/util.c - 664 sys sys 1022274716 1997
 sys/src/cmd/resample.c - 664 sys sys 1039753039 6268
 sys/src/cmd/rio - 20000000775 sys sys 1080134231 0
@@ -14525,7 +14526,7 @@ sys/src/games/mahjongg/mahjongg.c - 664 sys sys 1191355577 3869
 sys/src/games/mahjongg/mahjongg.h - 664 sys sys 1191355577 2092
 sys/src/games/mahjongg/mkfile - 664 sys sys 1191354593 241
 sys/src/games/memo.c - 664 sys sys 1130853201 6471
-sys/src/games/mkfile - 664 sys sys 1140203009 595
+sys/src/games/mkfile - 664 sys sys 1196228150 621
 sys/src/games/mp3dec - 20000000775 sys sys 1196207939 0
 sys/src/games/mp3dec/audio.c - 664 sys sys 956186249 5802
 sys/src/games/mp3dec/audio.h - 664 sys sys 956186249 2275
@@ -15848,4 +15849,3 @@ usr/glenda/lib/profile - 664 glenda glenda 1105128663 890
 usr/glenda/readme.acme - 664 glenda glenda 1019860628 4753
 usr/glenda/readme.rio - 664 glenda glenda 1019860628 6370
 usr/glenda/tmp - 20000000775 glenda glenda 1018802620 0
-386/bin/games/mp3dec - 775 sys sys 1196207154 355822

+ 5 - 4
dist/replica/plan9.db

@@ -1412,7 +1412,7 @@ lib/face/48x48x4/x/xigh.1 - 664 sys sys 1142019024 1204
 lib/face/48x48x4/y - 20000000775 sys sys 1020895714 0
 lib/face/48x48x4/z - 20000000775 sys sys 1020895714 0
 lib/face/48x48x8 - 20000000775 sys sys 1123100641 0
-lib/face/48x48x8/.dict - 664 sys sys 1192767500 4266
+lib/face/48x48x8/.dict - 664 sys sys 1196265401 4295
 lib/face/48x48x8/Z - 20000000775 sys sys 1020895714 0
 lib/face/48x48x8/a - 20000000775 sys sys 1056983599 0
 lib/face/48x48x8/a/alcortes.1 - 664 sys sys 1176753392 976
@@ -7430,6 +7430,7 @@ sys/man/1/mc - 664 sys sys 1113743326 552
 sys/man/1/mk - 664 sys sys 1113743328 13198
 sys/man/1/mkdir - 664 sys sys 1082593141 717
 sys/man/1/mlmgr - 664 sys sys 1116513886 2542
+sys/man/1/mp3dec - 664 sys sys 1196227746 4987
 sys/man/1/mp3enc - 664 sys sys 1196208904 3236
 sys/man/1/ms2html - 664 sys sys 1138458899 1252
 sys/man/1/mug - 664 sys sys 1158800370 1424
@@ -8065,7 +8066,7 @@ sys/src/9/pc/apbootstrap.s - 664 sys sys 1131293655 3037
 sys/src/9/pc/apic.c - 664 sys sys 1174415344 8991
 sys/src/9/pc/apm.c - 664 sys sys 1131290210 3723
 sys/src/9/pc/apmjump.s - 664 sys sys 1032058947 1527
-sys/src/9/pc/archmp.c - 664 sys sys 1174614168 2407
+sys/src/9/pc/archmp.c - 664 sys sys 1196264189 2410
 sys/src/9/pc/audio.h - 664 sys sys 1015014513 343
 sys/src/9/pc/bios32.c - 664 sys sys 1173287378 3029
 sys/src/9/pc/cga.c - 664 sys sys 1015014513 1843
@@ -13286,7 +13287,7 @@ sys/src/cmd/replica/db.c - 664 sys sys 1019340165 2989
 sys/src/cmd/replica/mkfile - 664 sys sys 1032060527 647
 sys/src/cmd/replica/revdump.c - 664 sys sys 1018321112 651
 sys/src/cmd/replica/revproto.c - 664 sys sys 1081202241 8932
-sys/src/cmd/replica/updatedb.c - 664 sys sys 1068497831 3045
+sys/src/cmd/replica/updatedb.c - 664 sys sys 1196273470 3837
 sys/src/cmd/replica/util.c - 664 sys sys 1022274716 1997
 sys/src/cmd/resample.c - 664 sys sys 1039753039 6268
 sys/src/cmd/rio - 20000000775 sys sys 1080134231 0
@@ -14525,7 +14526,7 @@ sys/src/games/mahjongg/mahjongg.c - 664 sys sys 1191355577 3869
 sys/src/games/mahjongg/mahjongg.h - 664 sys sys 1191355577 2092
 sys/src/games/mahjongg/mkfile - 664 sys sys 1191354593 241
 sys/src/games/memo.c - 664 sys sys 1130853201 6471
-sys/src/games/mkfile - 664 sys sys 1140203009 595
+sys/src/games/mkfile - 664 sys sys 1196228150 621
 sys/src/games/mp3dec - 20000000775 sys sys 1196207939 0
 sys/src/games/mp3dec/audio.c - 664 sys sys 956186249 5802
 sys/src/games/mp3dec/audio.h - 664 sys sys 956186249 2275

+ 6 - 0
dist/replica/plan9.log

@@ -17492,3 +17492,9 @@
 1196213404 3 c sys/src/libframe/frinsert.c - 664 sys sys 1196212625 6722
 1196220604 0 c 386/bin/games/mp3enc - 775 sys sys 1196220182 530357
 1196224204 0 m 386/bin/games/mp3dec - 775 sys sys 1196207154 355822
+1196227804 0 a sys/man/1/mp3dec - 664 sys sys 1196227746 4987
+1196227804 1 c sys/src/games/mkfile - 664 sys sys 1196228150 621
+1196263808 0 c sys/src/9/pc/archmp.c - 664 sys sys 1196264189 2410
+1196265604 0 c lib/face/48x48x8/.dict - 664 sys sys 1196265401 4295
+1196265604 1 c sys/src/9/pc/archmp.c - 664 sys sys 1196264189 2410
+1196274605 0 c sys/src/cmd/replica/updatedb.c - 664 sys sys 1196273470 3837

+ 1 - 0
lib/face/48x48x8/.dict

@@ -35,6 +35,7 @@ cl/unknown u/unknown.cl
 cmu.edu/pstanley p/pstanley.1
 cn/unknown u/unknown.cn
 comcast.net/unknown c/comcast.1
+coraid.com/mennis m/mennis.1
 coraid.com/quanstro q/quanstro.1
 cr/unknown u/unknown.cr
 cwru.edu/noah.evans n/noah.1

+ 224 - 0
sys/man/1/mp3dec

@@ -0,0 +1,224 @@
+.TH MP3DEC 1
+.SH NAME
+mp3dec \- play audio MPEG 1.0/2.0 file (layers 1, 2 and 3)
+.SH SYNOPSIS
+.B mp3dec
+[
+.B \-0124cmqsvy
+] [
+.BI \-a " dev"
+] [
+.BI \-b " size"
+] [
+.BI \-d " n"
+] [
+.BI \-f " factor"
+] [
+.BI \-g " gain"
+] [
+.BI \-h " n"
+] [
+.BI \-k " num"
+] [
+.BI \-n " num"
+] [
+.B -o
+.B [shl]
+] [
+.BI \-p " proxy"
+] [
+.BI \-r " rate"
+]
+.IR file " ...
+.SH DESCRIPTION
+.I Mp3dec
+reads one or more
+.IR file s
+(which may be URLs)
+and, by default, plays them on the audio device.
+The output format is raw (headerless) linear PCM audio data,
+16-bit, stereo, in host byte order.
+.IR File
+is assumed to contain a valid MPEG-1/2 audio layer-1, -2 or -3 bit stream.
+Any name starting with
+.L http://
+is recognized as a URL.
+.LP
+Interrupting
+.I mp3dec
+will skip to the next argument
+.IR file .
+Two interrupts within a second will terminate
+.IR mp3dec .
+.LP
+Options are:
+.TF "-f fact"
+.TP
+.B "-0 -1"
+Decode only channel 0 (left) or channel 1 (right),
+respectively.  These options are available for stereo MPEG streams only.
+.TP
+.B "-2 -4"
+Down-sample with ratio 2:1 (22 kHz) or 4:1 (11 kHz),
+respectively.
+Saves some CPU cycles, but the 4:1 ratio, at least, sounds ugly.
+.TP
+.BI "-a " dev
+Specify the audio device to use.  The default is
+.BR /dev/audio .
+Use this option if you have multiple audio devices and
+the default is not what you want.
+.TP
+.BI "-b " size
+Use an audio output buffer of
+.I size
+Kbytes.  This is useful to work around short periods of heavy
+system activity, which would normally cause the audio output
+to be interrupted.
+You should specify a buffer size of at least 1024
+(i.e. 1 Mb, which equals about 6 seconds of audio data) or more;
+less than about 300 does not make much sense.  The default is 0,
+which turns buffering off.
+.TP
+.B -c
+Check for filter range violations, and report them for each frame
+if any occur.
+.TP
+.BI "-d " n
+Only play every
+.IR n 'th
+frame.  This will cause the MPEG stream to be played
+.I n
+times faster, which can be used for special
+effects.  Can also be combined with the
+.B -h
+option to play 3 out of 4 frames etc.
+Sound quality will be poor.
+.TP
+.BI "-f " factor
+Change scale factor (default: 32768).
+.TP
+.BI "-g " gain
+Set audio hardware output gain (default: don't change).
+.TP
+.BI "-h " n
+Play each frame
+.I n
+times.  This will cause the MPEG stream
+to be played at
+.RI 1/ n 'th
+speed
+.RI ( n
+times slower), which can be
+used for special effects.  Can also be combined with the
+.B -d
+option to double every third frame or things like that.
+Sound quality will be poor.
+.TP
+.BI "-k " num
+Skip the first
+.I num
+frames.  By default the decoding starts at the first frame.
+.TP
+.B -m
+Mix both channels.
+This option is available for stereo MPEG layer-3 streams only.  It takes less
+CPU time than full stereo decoding.
+.TP
+.BI "-n " num
+Decode only
+.I num
+frames.  By default the complete stream is decoded.
+.TP
+.B -o
+Direct audio output to the speaker
+.RB ( s ),
+headphones
+.RB ( h ),
+or line-out
+.RB ( l ).
+.TP
+.BI "-p " proxy
+The specified
+.I proxy
+will be used for HTTP requests.  It
+should be specified as a full URL (``http://host.domain:port/''),
+but the
+.L http://
+prefix, the port number and the trailing
+slash are optional (the default port is 80).  Specifying
+.B none
+means not to use any proxy.
+In the absence of
+.BR -p ,
+.I mp3dec
+looks for environment variables named
+.BR MP3_HTTP_PROXY ,
+.BR http_proxy ,
+and
+.BR HTTP_PROXY ,
+in that order.
+.TP
+.B -q
+Quiet: suppress diagnostic messages.
+.TP
+.BI "-r " rate
+Set sample rate (default: automatic).  You may want to
+change this if you need a constant bitrate independent of the MPEG stream rate.
+.I Mp3dec
+automagically converts the rate.
+You should then combine this with \-\-stereo or \-\-mono.
+.TP
+.B -s
+Write the decoded audio samples to standard output.
+.TP
+.BI "-u " auth
+HTTP authentication to use when fetching files via HTTP.
+The format used is
+.IB user : password.
+.TP
+.B -v
+Increase the verbosity level
+(e.g., prints the frame numbers during decoding).
+.TP
+.B -y
+Try to resync and continue decoding if an error occurs in
+the input file.  Also try to recover from certain broken
+headers.  Useful if you have a broken MPEG file, on which
+.I mp3dec
+normally gives up saying `Illegal header'.  Be careful:
+Broken locations in MPEG files might cause sharp, loud pops or
+clicks, which might damage your speakers if played too loud.
+.TP
+.B \-z
+Shuffle play: randomly shuffles the argument files.
+.TP
+.B -Z
+Fully random play.
+.TP
+.B --stereo
+Force stereo output.
+.TP
+.B --reopen
+Forces reopening the audio device after every song.
+.TP
+.B --8bit
+Forces 8-bit output.
+.SH BUGS
+It's another GNU behemoth, lightly tamed.
+.PP
+It's slow.
+.PP
+MPEG-2 Layers 1 and 2 are not tested and may not work.
+Free-format streams are not supported.
+No CRC error checking is performed.
+.SH SOURCE
+.B /sys/src/games/mp3dec
+.SH "SEE ALSO"
+.IR mp3enc (1),
+.IR juke (7),
+.IR playlistfs (7)
+.br
+.B http://www.sfs.nphil.uni-tuebingen.de/~hipp/mpg123.html
+.br
+.B http://ftp.tu-clausthal.de/pub/unix/audio/mpg123

+ 1 - 1
sys/src/9/pc/archmp.c

@@ -43,7 +43,7 @@ mpsearch(void)
 	 */
 	bda = KADDR(0x400);
 	if((p = (bda[0x0F]<<8)|bda[0x0E])){
-		if(mp = mpscan(KADDR(p), 1024))
+		if(mp = mpscan(KADDR(p<<4), 1024))
 			return mp;
 	}
 	else{

+ 101 - 77
sys/src/9/pc/etherm10g.c

@@ -1,6 +1,10 @@
 /*
  * myricom 10 Gb ethernet driver
  * © 2007 erik quanstrom, coraid
+ *
+ * the card is big endian.
+ * we use u64int rather than uintptr to hold addresses so that
+ * we don't get "warning: stupid shift" on 32-bit architectures.
  */
 #include "u.h"
 #include "../port/lib.h"
@@ -11,14 +15,16 @@
 #include "../port/error.h"
 #include "../port/netif.h"
 
-#include "etherif.h"
+#include "../pc/etherif.h"
 
-#define	K	* 1024
-#define	MB	* 1024 K
+#ifndef KiB
+#define KiB		1024u			/* Kibi 0x0000000000000400 */
+#define MiB		1048576u		/* Mebi 0x0000000000100000 */
+#endif /* KiB */
 
 #define	dprint(...)	if(debug) print(__VA_ARGS__)
-#define	pcicapdbg(...)	
-#define malign(n)	xspanalloc(n, 4 K, 0)
+#define	pcicapdbg(...)
+#define malign(n)	mallocalign((n), 4*KiB, 0, 0)
 
 #include "etherm10g2k.i"
 #include "etherm10g4k.i"
@@ -33,7 +39,7 @@ enum {
 	Maxmtu	= 9000,
 	Noconf	= 0xffffffff,
 
-	Fwoffset= 1 MB,
+	Fwoffset= 1*MiB,
 	Cmdoff	= 0xf80000,	/* command port offset */
 	Fwsubmt	= 0xfc0000,	/* firmware submission command port offset */
 	Rdmaoff	= 0xfc01c0,	/* rdma command port offset */
@@ -89,10 +95,11 @@ typedef union {
 	uchar	c[8];
 } Cmd;
 
+typedef ulong Slot;
 typedef struct {
 	u16int	cksum;
 	u16int	len;
-} Slot;
+} Slotparts;
 
 enum {
 	SFsmall	= 1,
@@ -137,8 +144,8 @@ typedef struct {
 	uint	cnt;
 } Bpool;
 
-Bpool	smpool 	= { .size = 128, };
-Bpool	bgpool	= { .size = Maxmtu, };
+static Bpool	smpool 	= { .size = 128, };
+static Bpool	bgpool	= { .size = Maxmtu, };
 
 typedef struct {
 	Bpool	*pool;		/* free buffers */
@@ -177,7 +184,7 @@ enum {
 
 typedef struct {
 	Slot 	*entry;
-	uintptr	busaddr;
+	u64int	busaddr;
 	uint	m;
 	uint	n;
 	uint	i;
@@ -188,7 +195,7 @@ typedef struct Ctlr {
 	QLock;
 	int	state;
 	int	kprocs;
-	uintptr	port;
+	u64int	port;
 	Pcidev*	pcidev;
 	Ctlr*	next;
 	int	active;
@@ -208,16 +215,16 @@ typedef struct Ctlr {
 
 	QLock	cmdl;
 	Cmd	*cmd;		/* address of command return */
-	uintptr	cprt;		/* bus address of command */
+	u64int	cprt;		/* bus address of command */
 
-	uintptr	boot;		/* boot address */
+	u64int	boot;		/* boot address */
 
 	Done	done;
 	Tx	tx;
 	Rx	sm;
 	Rx	bg;
 	Stats	*stats;
-	uintptr	statsprt;
+	u64int	statsprt;
 
 	Rendez	rxrendez;
 	Rendez	txrendez;
@@ -261,7 +268,7 @@ enum {
 	PcieMRD	= 0x7000,	/* maximum read size */
 };
 
-int
+static int
 pcicap(Pcidev *p, int cap)
 {
 	int i, c, off;
@@ -290,7 +297,7 @@ pcicap(Pcidev *p, int cap)
  * this function doesn't work because pcicgr32 doesn't have access
  * to the pcie extended configuration space.
  */
-int
+static int
 pciecap(Pcidev *p, int cap)
 {
 	uint off, i;
@@ -299,7 +306,7 @@ pciecap(Pcidev *p, int cap)
 	while(((i = pcicfgr32(p, off))&0xffff) != cap){
 		off = i >> 20;
 		print("pciecap offset = %ud\n",  off);
-		if(off < 0x100 || off >= 4 K - 1)
+		if(off < 0x100 || off >= 4*KiB - 1)
 			return 0;
 	}
 	print("pciecap found = %ud\n",  off);
@@ -350,21 +357,21 @@ whichfw(Pcidev *p)
 	print("m10g %d lanes; ecrc=%d; ", lanes, ecrc);
 	if(s = getconf("myriforce")){
 		i = atoi(s);
-		if(i != 4 K || i != 2 K)
-			i = 2 K;
+		if(i != 4*KiB || i != 2*KiB)
+			i = 2*KiB;
 		print("fw=%d [forced]\n", i);
 		return i;
 	}
 	if(lanes <= 4){
 		print("fw = 4096 [lanes]\n");
-		return 4 K;
+		return 4*KiB;
 	}
 	if(ecrc & 10){
 		print("fw = 4096 [ecrc set]\n");
-		return 4K;
+		return 4*KiB;
 	}
 	print("fw = 4096 [default]\n");
-	return 4 K;
+	return 4*KiB;
 }
 
 static int
@@ -395,7 +402,7 @@ parseeprom(Ctlr *c)
 	return 0;
 }
 
-u16int
+static u16int
 pbit16(u16int i)
 {
 	u16int j;
@@ -407,7 +414,7 @@ pbit16(u16int i)
 	return j;
 }
 
-u16int
+static u16int
 gbit16(uchar i[2])
 {
 	u16int j;
@@ -417,7 +424,7 @@ gbit16(uchar i[2])
 	return j;
 }
 
-u32int
+static u32int
 pbit32(u32int i)
 {
 	u32int j;
@@ -460,9 +467,9 @@ prepcmd(uint *cmd, int i)
  * response (low)
  * 40 byte = 5 int pad.
  */
-	
+
 u32int
-cmd(Ctlr *c, int type, u32int data)
+cmd(Ctlr *c, int type, u64int data)
 {
 	u32int buf[16], i;
 	Cmd *cmd;
@@ -473,6 +480,8 @@ cmd(Ctlr *c, int type, u32int data)
 	memset(buf, 0, sizeof buf);
 	buf[0] = type;
 	buf[1] = data;
+	buf[2] = data >> 32;
+	buf[4] = c->cprt >> 32;
 	buf[5] = c->cprt;
 	prepcmd(buf, 6);
 	coherence();
@@ -511,6 +520,7 @@ maccmd(Ctlr *c, int type, uchar *m)
 	buf[0] = type;
 	buf[1] = m[0]<<24 | m[1]<<16 | m[2]<<8 | m[3];
 	buf[2] = m[4]<< 8 | m[5];
+	buf[4] = c->cprt >> 32;
 	buf[5] = c->cprt;
 	prepcmd(buf, 6);
 	coherence();
@@ -541,9 +551,9 @@ enum {
 	DMAread	= 0x10000,
 	DMAwrite= 0x1,
 };
-	
+
 u32int
-dmatestcmd(Ctlr *c, int type, u32int addr, int len)
+dmatestcmd(Ctlr *c, int type, u64int addr, int len)
 {
 	u32int buf[16], i;
 
@@ -551,7 +561,9 @@ dmatestcmd(Ctlr *c, int type, u32int addr, int len)
 	memset(c->cmd, Noconf, sizeof *c->cmd);
 	buf[0] = Cdmatest;
 	buf[1] = addr;
+	buf[2] = addr >> 32;
 	buf[3] = len * type;
+	buf[4] = c->cprt >> 32;
 	buf[5] = c->cprt;
 	prepcmd(buf, 6);
 	coherence();
@@ -581,8 +593,10 @@ rdmacmd(Ctlr *c, int on)
 	memset(buf, 0, sizeof buf);
 	c->cmd->i[0] = 0;
 	coherence();
+	buf[0] = c->cprt >> 32;
 	buf[1] = c->cprt;
 	buf[2] = Noconf;
+	buf[3] = c->cprt >> 32;
 	buf[4] = c->cprt;
 	buf[5] = on;
 	prepcmd(buf, 6);
@@ -608,7 +622,7 @@ loadfw(Ctlr *c, int *align)
 	uint *f, *s, sz;
 	int i;
 
-	if((*align = whichfw(c->pcidev)) == 4 K){
+	if((*align = whichfw(c->pcidev)) == 4*KiB){
 		f = (u32int*)fw4k;
 		sz = sizeof fw4k;
 	}else{
@@ -637,7 +651,7 @@ bootfw(Ctlr *c)
 	memset(buf, 0, sizeof buf);
 	c->cmd->i[0] = 0;
 	coherence();
-	buf[0] = 0;		/* upper 32 bits of dma target address */
+	buf[0] = c->cprt >> 32;	/* upper dma target address */
 	buf[1] = c->cprt;	/* lower */
 	buf[2] = Noconf;	/* writeback */
 	buf[3] = Fwoffset + 8,
@@ -663,15 +677,15 @@ bootfw(Ctlr *c)
 	return 0;
 }
 
-int
+static int
 kickthebaby(Pcidev *p, Ctlr *c)
 {
 	/* don't kick the baby! */
 	u32int code;
 
-	pcicfgw8(p,  0x10+c->boot, 0x3);
-	pcicfgw32(p, 0x18+c->boot, 0xfffffff0);
-	code = pcicfgr32(p, 0x14+c->boot);
+	pcicfgw8(p,  0x10 + c->boot, 0x3);
+	pcicfgw32(p, 0x18 + c->boot, 0xfffffff0);
+	code = pcicfgr32(p, 0x14 + c->boot);
 
 	dprint("reboot status = %ux\n", code);
 	if(code != 0xfffffff0)
@@ -696,7 +710,7 @@ enum {
 	Tmcp0	= 0x4d435030,
 };
 
-char*
+static char *
 fwtype(u32int type)
 {
 	switch(type){
@@ -712,7 +726,7 @@ fwtype(u32int type)
 	return "*GOK*";
 }
 
-int
+static int
 chkfw(Ctlr *c)
 {
 	uintptr off;
@@ -720,9 +734,9 @@ chkfw(Ctlr *c)
 	u32int type;
 
 	off = gbit32(c->ram+0x3c);
-	dprint("firmware %ulx\n", off);
+	dprint("firmware %llux\n", (u64int)off);
 	if((off&3) || off + sizeof *h > c->ramsz){
-		print("!m10g: bad firmware %ulx\n", off);
+		print("!m10g: bad firmware %llux\n", (u64int)off);
 		return -1;
 	}
 	h = (Fwhdr*)(c->ram + off);
@@ -752,7 +766,7 @@ reset(Ether *e, Ctlr *c)
 	chkfw(c);
 	cmd(c, Creset, 0);
 
-	cmd(c, CSintrqsz, c->done.n*sizeof *c->done.entry);
+	cmd(c, CSintrqsz, c->done.n * sizeof *c->done.entry);
 	cmd(c, CSintrqdma, c->done.busaddr);
 	c->irqack =   (u32int*)(c->ram + cmd(c, CGirqackoff, 0));
 	/* required only if we're not doing msi? */
@@ -799,12 +813,13 @@ ctlrfree(Ctlr *c)
 static int
 setmem(Pcidev *p, Ctlr *c)
 {
-	u32int i, raddr;
+	u32int i;
+	u64int raddr;
 	Done *d;
 	void *mem;
 
 	c->tx.segsz = 2048;
-	c->ramsz = 2 MB - (2*48 K + 32 K) - 0x100;
+	c->ramsz = 2*MiB - (2*48*KiB + 32*KiB) - 0x100;
 	if(c->ramsz > p->mem[0].size)
 		return -1;
 
@@ -814,7 +829,7 @@ setmem(Pcidev *p, Ctlr *c)
 		print("m10g: can't map %8.8lux\n", p->mem[0].bar);
 		return -1;
 	}
-	dprint("%ux <- vmap(mem[0].size = %ux)\n", raddr, p->mem[0].size);
+	dprint("%llux <- vmap(mem[0].size = %ux)\n", raddr, p->mem[0].size);
 	c->port = raddr;
 	c->ram = mem;
 	c->cmd = malign(sizeof *c->cmd);
@@ -906,7 +921,8 @@ replenish(Rx *rx)
 		idx = rx->cnt & rx->m;
 		for(i = 0; i < 8; i++){
 			b = balloc(rx);
-			buf[i*2 + 1] = pbit32(PCIWADDR(b->wp));
+			buf[i*2]   = pbit32((u64int)PCIWADDR(b->wp) >> 32);
+			buf[i*2+1] = pbit32(PCIWADDR(b->wp));
 			rx->host[idx+i] = b;
 			assert(b);
 		}
@@ -919,7 +935,7 @@ replenish(Rx *rx)
 		print("should panic? pool->n = %d\n", p->n);
 }
 
-/* 
+/*
  * future:
  * if (c->mtrr >= 0) {
  *	c->tx.wcfifo = c->ram+0x200000;
@@ -933,7 +949,7 @@ nextpow(int j)
 {
 	int i;
 
-	for(i = 0; j > (1<<i); i++)
+	for(i = 0; j > (1 << i); i++)
 		;
 	return 1 << i;
 }
@@ -956,7 +972,7 @@ open0(Ether *e, Ctlr *c)
 	Block *b;
 	int i, sz, entries;
 
-	entries = cmd(c, CGsendrgsz, 0)/sizeof *c->tx.lanai;
+	entries = cmd(c, CGsendrgsz, 0) / sizeof *c->tx.lanai;
 	c->tx.lanai = (Send*)(c->ram + cmd(c, CGsendoff, 0));
 	c->tx.host  = emalign(entries * sizeof *c->tx.host);
 	c->tx.bring = emalign(entries * sizeof *c->tx.bring);
@@ -1010,15 +1026,17 @@ nextblock(Ctlr *c)
 	Done *d;
 	Rx *rx;
 	Slot *s;
+	Slotparts *sp;
 
 	d = &c->done;
 	s = d->entry;
 	i = d->i & d->m;
-	l = s[i].len;
+	sp = (Slotparts *)(s + i);
+	l = sp->len;
 	if(l == 0)
 		return 0;
-	k = s[i].cksum;
-	*(u32int*)(s+i) = 0;
+	k = sp->cksum;
+	s[i] = 0;
 	d->i++;
 	l = gbit16((uchar*)&l);
 //dprint("nextb: i=%d l=%d\n", d->i, l);
@@ -1049,12 +1067,14 @@ rxcansleep(void *v)
 {
 	Ctlr *c;
 	Slot *s;
+	Slotparts *sp;
 	Done *d;
 
 	c = v;
 	d = &c->done;
 	s = c->done.entry;
-	if(s[d->i & d->m].len != 0)
+	sp = (Slotparts *)(s + (d->i & d->m));
+	if(sp->len != 0)
 		return -1;
 	c->irqack[0] = pbit32(3);
 	return 0;
@@ -1078,7 +1098,7 @@ m10rx(void *v)
 	}
 }
 
-void
+static void
 txcleanup(Tx *tx, u32int n)
 {
 	Block *b;
@@ -1088,8 +1108,10 @@ txcleanup(Tx *tx, u32int n)
 		return;
 	l = 0;
 	m = tx->m;
-	/* if tx->cnt == tx->i, yet tx->npkt == n-1 we just */
-	/* caught ourselves and myricom card updating. */
+	/*
+	 * if tx->cnt == tx->i, yet tx->npkt == n-1, we just
+	 * caught ourselves and myricom card updating.
+	 */
 	for(;; tx->cnt++){
 		j = tx->cnt & tx->m;
 		if(b = tx->bring[j]){
@@ -1119,7 +1141,7 @@ txcansleep(void *v)
 	return 0;
 }
 
-void
+static void
 txproc(void *v)
 {
 	Ether *e;
@@ -1130,12 +1152,12 @@ txproc(void *v)
 	c = e->ctlr;
 	tx = &c->tx;
 	for(;;){
- 		sleep(&c->txrendez, txcansleep, c); 		
+ 		sleep(&c->txrendez, txcansleep, c);
 		txcleanup(tx, gbit32(c->stats->txcnt));
 	}
 }
 
-void
+static void
 submittx(Tx *tx, int n)
 {
 	Send *l, *h;
@@ -1151,7 +1173,7 @@ submittx(Tx *tx, int n)
 //	coherence();
 }
 
-int
+static int
 nsegments(Block *b, int segsz)
 {
 	uintptr bus, end, slen, len;
@@ -1187,10 +1209,10 @@ m10gtransmit(Ether *e)
 
 	qlock(tx);
 	count = 0;
-	s = tx->host+(tx->i & tx->m);
+	s = tx->host + (tx->i & tx->m);
 	cnt = tx->cnt;
-	s0 =   tx->host+(cnt & tx->m);
-	s0m8 = tx->host+(cnt - 8 & tx->m);
+	s0 =   tx->host + (cnt & tx->m);
+	s0m8 = tx->host + ((cnt - 8) & tx->m);
 	i = tx->i;
 	for(; s >= s0 || s < s0m8; i += nseg){
 		if((b = qget(e->oq)) == nil)
@@ -1222,8 +1244,8 @@ m10gtransmit(Ether *e)
 			submittx(tx, count);
 			count = 0;
 			cnt = tx->cnt;
-			s0 =   tx->host+(cnt & tx->m);
-			s0m8 = tx->host+(cnt - 8 & tx->m);
+			s0 =   tx->host + (cnt & tx->m);
+			s0m8 = tx->host + ((cnt - 8) & tx->m);
 		}
 	}
 	qunlock(tx);
@@ -1343,7 +1365,7 @@ lstcount(Block *b)
 		i++;
 	return i;
 }
-		
+
 static long
 m10gifstat(Ether *e, void *v, long n, ulong off)
 {
@@ -1359,8 +1381,8 @@ m10gifstat(Ether *e, void *v, long n, ulong off)
 	/* no point in locking this because this is done via dma. */
 	memmove(&s, c->stats, sizeof s);
 
-	// l += 
-	snprint(p+l, lim, 
+	// l +=
+	snprint(p+l, lim,
 		"txcnt = %ud\n"	  "linkstat = %ud\n" 	"dlink = %ud\n"
 		"derror = %ud\n"  "drunt = %ud\n" 	"doverrun = %ud\n"
 		"dnosm = %ud\n"	  "dnobg = %ud\n"	"nrdma = %ud\n"
@@ -1368,8 +1390,10 @@ m10gifstat(Ether *e, void *v, long n, ulong off)
 		"valid = %ud\n\n"
 		"tx pkt = %uld\n" "tx bytes = %lld\n"
 		"tx cnt = %ud\n"  "tx n = %ud\n"	"tx i = %ud\n"
-		"sm cnt = %ud\n"  "sm i = %ud\n"	"sm n = %ud\n"		"sm lst = %ud\n"
-		"bg cnt = %ud\n"  "bg i = %ud\n"	"bg n = %ud\n"		"bg lst = %ud\n"
+		"sm cnt = %ud\n"  "sm i = %ud\n"	"sm n = %ud\n"
+		"sm lst = %ud\n"
+		"bg cnt = %ud\n"  "bg i = %ud\n"	"bg n = %ud\n"
+		"bg lst = %ud\n"
 		"segsz = %ud\n"   "coal = %d\n",
 		gbit32(s.txcnt),  gbit32(s.linkstat),	gbit32(s.dlink),
 		gbit32(s.derror), gbit32(s.drunt),	gbit32(s.doverrun),
@@ -1386,7 +1410,7 @@ m10gifstat(Ether *e, void *v, long n, ulong off)
 	return n;
 }
 
-//void
+//static void
 //summary(Ether *e)
 //{
 //	char *buf;
@@ -1411,18 +1435,21 @@ m10gifstat(Ether *e, void *v, long n, ulong off)
 //	free(buf);
 //}
 
-void
+static void
 rxring(Ctlr *c)
 {
 	Done *d;
 	Slot *s;
+	Slotparts *sp;
 	int i;
 
 	d = &c->done;
 	s = d->entry;
-	for(i = 0; i < d->n; i++)
-		if(s[i].len)
-			iprint("s[%d] = %d\n", i, s[i].len);
+	for(i = 0; i < d->n; i++) {
+		sp = (Slotparts *)(s + i);
+		if(sp->len)
+			iprint("s[%d] = %d\n", i, sp->len);
+	}
 }
 
 enum {
@@ -1462,10 +1489,7 @@ m10gctl(Ether *e, void *v, long n)
 	t = lookupcmd(c, ctab, nelem(ctab));
 	switch(t->index){
 	case CMdebug:
-		if(strcmp(c->f[1], "on") == 0)
-			debug = 1;
-		else
-			debug = 0;
+		debug = (strcmp(c->f[1], "on") == 0);
 		break;
 	case CMcoal:
 		i = atoi(c->f[1]);

+ 1 - 0
sys/src/9/pc/pci.c

@@ -658,6 +658,7 @@ static Bridge southbridges[] = {
 
 	{ 0x1022, 0x746B, nil, nil },		/* AMD 8111 */
 	{ 0x10DE, 0x00D1, nil, nil },		/* NVIDIA nForce 3 */
+	{ 0x10DE, 0x00E0, nil, nil },		/* NVIDIA nForce 3 250 Series */
 	{ 0x1166, 0x0200, nil, nil },		/* ServerWorks ServerSet III LE */
 	{ 0x1002, 0x4377, nil, nil },		/* ATI Radeon Xpress 200M */
 	{ 0x1002, 0x4372, nil, nil },		/* ATI SB400 */

+ 9 - 0
sys/src/9/port/aoe.h

@@ -44,8 +44,11 @@ typedef struct {
 	uchar	minor;
 	uchar	cmd;
 	uchar	tag[4];
+	uchar	payload[];
 } Aoehdr;
 
+#define AOEHDRSZ	offsetof(Aoehdr, payload[0])
+
 typedef struct {
 	Aoehdr;
 	uchar	aflag;
@@ -54,8 +57,11 @@ typedef struct {
 	uchar	cmdstat;
 	uchar	lba[6];
 	uchar	res[2];
+	uchar	payload[];
 } Aoeata;
 
+#define AOEATASZ	offsetof(Aoeata, payload[0])
+
 typedef struct {
 	Aoehdr;
 	uchar	bufcnt[2];
@@ -63,7 +69,10 @@ typedef struct {
 	uchar	scnt;
 	uchar	verccmd;
 	uchar	cslen[2];
+	uchar	payload[];
 } Aoeqc;
 
+#define AOEQCSZ		offsetof(Aoeqc, payload[0])
+
 extern char Echange[];
 extern char Enotup[];

+ 14 - 14
sys/src/9/port/devaoe.c

@@ -23,7 +23,7 @@
 
 enum {
 	Maxunits	= 0xff,
-	Maxframes	= 24,
+	Maxframes	= 128,
 	Ndevlink	= 6,
 	Nea		= 6,
 	Nnetlink	= 6,
@@ -967,7 +967,7 @@ atarw(Aoedev *d, Frame *f)
 	bcnt = d->maxbcnt;
 	if(bcnt > srb->len)
 		bcnt = srb->len;
-	f->nhdr = sizeof *ah;
+	f->nhdr = AOEATASZ;
 	memset(f->hdr, 0, f->nhdr);
 	ah = (Aoeata*)f->hdr;
 	if(hset(d, f, ah, ACata) == -1)
@@ -1370,7 +1370,7 @@ configwrite(Aoedev *d, void *db, long len)
 
 	if(!UP(d))
 		error(Enotup);
-	if(len > ETHERMAXTU-sizeof *ch)
+	if(len > ETHERMAXTU - AOEQCSZ)
 		error(Etoobig);
 	srb = srballoc(len);
 	s = malloc(len);
@@ -1396,7 +1396,7 @@ configwrite(Aoedev *d, void *db, long len)
 		tsleep(&up->sleep, return0, 0, 100);
 		poperror();
 	}
-	f->nhdr = sizeof *ch;
+	f->nhdr = AOEQCSZ;
 	memset(f->hdr, 0, f->nhdr);
 	ch = (Aoeqc*)f->hdr;
 	if(hset(d, f, ch, ACconfig) == -1)
@@ -1460,7 +1460,7 @@ devmaxdata(Aoedev *d)
 	}
 	if(mtu == 100000)
 		mtu = 0;
-	mtu -= sizeof(Aoeata);
+	mtu -= AOEATASZ;
 	return mtu;
 }
 
@@ -1533,7 +1533,7 @@ unitctlwrite(Aoedev *d, void *db, long n)
 			if(ct->index == Maxbno)
 				m *= Aoesectsz;
 			else{
-				m -= sizeof(Aoeata);
+				m -= AOEATASZ;
 				m &= ~(Aoesectsz-1);
 			}
 			if(m > maxbcnt)
@@ -1650,7 +1650,7 @@ newdev(long major, long minor, int n)
 	Frame *f, *e;
 
 	d = mallocz(sizeof *d, 1);
-	f = mallocz(sizeof *f*n, 1);
+	f = mallocz(sizeof *f * n, 1);
 	if (!d || !f) {
 		free(d);
 		free(f);
@@ -1757,7 +1757,7 @@ ataident(Aoedev *d)
 	f = freeframe(d);
 	if(f == nil)
 		return;
-	f->nhdr = sizeof *a;
+	f->nhdr = AOEATASZ;
 	memset(f->hdr, 0, f->nhdr);
 	a = (Aoeata*)f->hdr;
 	if(hset(d, f, a, ACata) == -1)
@@ -1877,7 +1877,7 @@ qcfgrsp(Block *b, Netlink *nl)
 			return;
 		}
 		cslen = nhgets(ch->cslen);
-		blen = BLEN(b) - sizeof *ch;
+		blen = BLEN(b) - AOEQCSZ;
 		if(cslen < blen)
 			eventlog("%æ: cfgrsp: tag %.8ux oversized %d %d\n",
 				d, n, cslen, blen);
@@ -1928,7 +1928,7 @@ qcfgrsp(Block *b, Netlink *nl)
 	d->nconfig = n;
 	memmove(d->config, ch + 1, n);
 	if(l != 0 && d->flag & Djumbo){
-		n = getmtu(nl->mtu) - sizeof(Aoeata);
+		n = getmtu(nl->mtu) - AOEATASZ;
 		n /= Aoesectsz;
 		if(n > ch->scnt)
 			n = ch->scnt;
@@ -2072,12 +2072,12 @@ atarsp(Block *b)
 		switch(ahout->cmdstat){
 		case Crd:
 		case Crdext:
-			if(BLEN(b) - sizeof *ahin < n){
+			if(BLEN(b) - AOEATASZ < n){
 				eventlog("%æ: runt read blen %ld expect %d\n",
 					d, BLEN(b), n);
 				goto bail;
 			}
-			memmove(f->dp, ahin+1, n);
+			memmove(f->dp, (uchar *)ahin + AOEATASZ, n);
 		case Cwr:
 		case Cwrext:
 			if(n > Dbcnt)
@@ -2090,12 +2090,12 @@ atarsp(Block *b)
 			}
 			break;
 		case Cid:
-			if(BLEN(b) - sizeof *ahin < 512){
+			if(BLEN(b) - AOEATASZ < 512){
 				eventlog("%æ: runt identify blen %ld expect %d\n",
 					d, BLEN(b), n);
 				goto bail;
 			}
-			identify(d, (ushort*)(ahin + 1));
+			identify(d, (ushort*)((uchar *)ahin + AOEATASZ));
 			break;
 		default:
 			eventlog("%æ: unknown ata command %.2ux \n",

+ 1 - 0
sys/src/boot/pc/pci.c

@@ -364,6 +364,7 @@ static bridge_t southbridges[] = {
 	{ 0x1002, 0x4372, nil, nil },		// ATI SB400
 	{ 0x1022, 0x746B, nil, nil },		// AMD 8111
 	{ 0x10DE, 0x00D1, nil, nil },		// NVIDIA nForce 3
+	{ 0x10DE, 0x00E0, nil, nil },		// NVIDIA nForce 3 250 Series
 	{ 0x1166, 0x0200, nil, nil },		// ServerWorks ServerSet III LE
 };
 

+ 34 - 1
sys/src/cmd/replica/updatedb.c

@@ -96,6 +96,39 @@ walk(char *new, char *old, Dir *xd, void*)
 	}
 }
 
+void
+warn(char *msg, void*)
+{
+	char *p;
+
+	fprint(2, "warning: %s\n", msg);
+
+	/* find the %r in "can't open foo: %r" */
+	p = strstr(msg, ": ");
+	if(p)
+		p += 2;
+
+	/*
+	 * if the error is about a remote server failing,
+	 * then there's no point in continuing to look
+	 * for changes -- we'll think everything got deleted!
+	 *
+	 * actual errors i see are:
+	 *	"i/o on hungup channel" for a local hangup
+	 *	"i/o on hungup channel" for a timeout (yank the network wire)
+	 *	"'/n/sources/plan9' Hangup" for a remote hangup
+	 * the rest is paranoia.
+	 */
+	if(p){
+		if(cistrstr(p, "hungup") || cistrstr(p, "Hangup")
+		|| cistrstr(p, "rpc error")
+		|| cistrstr(p, "shut down")
+		|| cistrstr(p, "i/o")
+		|| cistrstr(p, "connection"))
+			sysfatal("suspected network or i/o error - bailing out");
+	}
+}
+
 void
 usage(void)
 {
@@ -151,7 +184,7 @@ main(int argc, char **argv)
 	nmatch = argc-1;
 
 	db = opendb(argv[0]);
-	if(rdproto(proto, root, walk, nil, nil) < 0)
+	if(rdproto(proto, root, walk, warn, nil) < 0)
 		sysfatal("rdproto: %r");
 
 	if(!changesonly){

+ 3 - 0
sys/src/games/mkfile

@@ -14,6 +14,9 @@ BIN=/$objtype/bin/games
 
 DIRS=\
 	mahjongg\
+	mp3dec\
+	mp3enc\
+	music\
 	sokoban\
 	sudoku\