Pārlūkot izejas kodu

Plan 9 from Bell Labs 2013-02-14

David du Colombier 11 gadi atpakaļ
vecāks
revīzija
e1beec1a8a

+ 1 - 8
sys/src/9/bcm/mem.h

@@ -5,19 +5,11 @@
 #define MiB		1048576u		/* Mebi 0x0000000000100000 */
 #define GiB		1073741824u		/* Gibi 000000000040000000 */
 
-#define HOWMANY(x, y)	(((x)+((y)-1))/(y))
-#define ROUNDUP(x, y)	(HOWMANY((x), (y))*(y))	/* ceiling */
-#define ROUNDDN(x, y)	(((x)/(y))*(y))		/* floor */
-#define MIN(a, b)	((a) < (b)? (a): (b))
-#define MAX(a, b)	((a) > (b)? (a): (b))
-
 /*
  * Sizes
  */
 #define	BY2PG		(4*KiB)			/* bytes per page */
 #define	PGSHIFT		12			/* log(BY2PG) */
-#define	PGROUND(s)	ROUNDUP(s, BY2PG)
-#define	ROUND(s, sz)	(((s)+(sz-1))&~(sz-1))
 
 #define	MAXMACH		1			/* max # cpus system can run */
 #define	MACHSIZE	BY2PG
@@ -51,6 +43,7 @@
 
 #define	UZERO		0			/* user segment */
 #define	UTZERO		(UZERO+BY2PG)		/* user text start */
+#define UTROUND(t)	ROUNDUP((t), BY2PG)
 #define	USTKTOP		0x20000000		/* user segment end +1 */
 #define	USTKSIZE	(8*1024*1024)		/* user stack size */
 #define	TSTKTOP		(USTKTOP-USTKSIZE)	/* sysexec temporary stack */

+ 0 - 3
sys/src/9/bcm/mkfile

@@ -130,6 +130,3 @@ reboot.h:D:	rebootcode.s arm.s arm.h mem.h
 	 xd -1x reboot.out |
 		sed -e '1,2d' -e 's/^[0-9a-f]+ //' -e 's/ ([0-9a-f][0-9a-f])/0x\1,/g'
 	 echo '};'} > reboot.h
-
-$CONF.clean:
-	rm -rf $p$CONF s$p$CONF errstr.h reboot.h $CONF.c boot$CONF.c

+ 0 - 1
sys/src/9/bcm/mmu.c

@@ -6,7 +6,6 @@
 
 #include "arm.h"
 
-#define FEXT(d, o, w)	(((d)>>(o)) & ((1<<(w))-1))
 #define L1X(va)		FEXT((va), 20, 12)
 #define L2X(va)		FEXT((va), 12, 8)
 

+ 3 - 17
sys/src/9/kw/mem.h

@@ -5,39 +5,24 @@
 #define MiB		1048576u		/* Mebi 0x0000000000100000 */
 #define GiB		1073741824u		/* Gibi 000000000040000000 */
 
-#define HOWMANY(x, y)	(((x)+((y)-1))/(y))
-#define ROUNDUP(x, y)	(HOWMANY((x), (y))*(y))	/* ceiling */
-#define ROUNDDN(x, y)	(((x)/(y))*(y))		/* floor */
-#define MIN(a, b)	((a) < (b)? (a): (b))
-#define MAX(a, b)	((a) > (b)? (a): (b))
-
 /*
  * Not sure where these macros should go.
  * This probably isn't right but will do for now.
  * The macro names are problematic too.
  */
 /*
- * In B(o), 'o' is the bit offset in the register.
+ * In BITN(o), 'o' is the bit offset in the register.
  * For multi-bit fields use F(v, o, w) where 'v' is the value
  * of the bit-field of width 'w' with LSb at bit offset 'o'.
  */
-#define B(o)		(1<<(o))
+#define BITN(o)		(1<<(o))
 #define F(v, o, w)	(((v) & ((1<<(w))-1))<<(o))
 
-#define FCLR(d, o, w)	((d) & ~(((1<<(w))-1)<<(o)))
-#define FEXT(d, o, w)	(((d)>>(o)) & ((1<<(w))-1))
-#define FINS(d, o, w, v) (FCLR((d), (o), (w))|F((v), (o), (w)))
-#define FSET(d, o, w)	((d)|(((1<<(w))-1)<<(o)))
-
-#define FMASK(o, w)	(((1<<(w))-1)<<(o))
-
 /*
  * Sizes
  */
 #define	BY2PG		(4*KiB)			/* bytes per page */
 #define	PGSHIFT		12			/* log(BY2PG) */
-#define	PGROUND(s)	ROUNDUP(s, BY2PG)
-#define	ROUND(s, sz)	(((s)+(sz-1))&~(sz-1))
 
 #define	MAXMACH		1			/* max # cpus system can run */
 #define	MACHSIZE	BY2PG
@@ -69,6 +54,7 @@
 
 #define	UZERO		0			/* user segment */
 #define	UTZERO		(UZERO+BY2PG)		/* user text start */
+#define UTROUND(t)	ROUNDUP((t), BY2PG)
 #define	USTKTOP		KZERO			/* user segment end +1 */
 #define	USTKSIZE	(8*1024*1024)		/* user stack size */
 #define	TSTKTOP		(USTKTOP-USTKSIZE)	/* sysexec temporary stack */

+ 2 - 4
sys/src/9/kw/mkfile

@@ -103,8 +103,9 @@ install-in-flash:V: /$objtype/$p$CONF paqdisk
 /$objtype/$p$CONF:D: $p$CONF s$p$CONF
 	cp -x $p$CONF s$p$CONF /$objtype/ &
 	for(i in $EXTRACOPIES)
-		{ echo $i: && 9fs $i && cp $p$CONF s$p$CONF /n/$i/$objtype } &
+		{ 9fs $i && cp $p$CONF s$p$CONF /n/$i/$objtype && echo -n $i... & }
 	wait
+	echo
 	touch $target
 
 paqdisk:
@@ -153,6 +154,3 @@ reboot.h:D:	rebootcode.s arm.s arm.h mem.h
 	 echo '};'} > reboot.h
 errstr.h:D:	../port/mkerrstr ../port/error.h
 	rc ../port/mkerrstr > errstr.h
-
-plug.clean:
-	rm -rf $p$CONF s$p$CONF armpaq paqdisk $CONF.c boot$CONF.c ../boot/libboot.a5

+ 2 - 9
sys/src/9/mtx/mem.h

@@ -5,12 +5,6 @@
 #define MiB		1048576u		/* Mebi 0x0000000000100000 */
 #define GiB		1073741824u		/* Gibi 000000000040000000 */
 
-#define HOWMANY(x, y)	(((x)+((y)-1))/(y))
-#define ROUNDUP(x, y)	(HOWMANY((x), (y))*(y))	/* ceiling */
-#define ROUNDDN(x, y)	(((x)/(y))*(y))		/* floor */
-#define MIN(a, b)	((a) < (b)? (a): (b))
-#define MAX(a, b)	((a) > (b)? (a): (b))
-
 /*
  * Sizes
  */
@@ -18,12 +12,10 @@
 #define	BI2BY		8			/* bits per byte */
 #define	BI2WD		32			/* bits per word */
 #define	BY2WD		4			/* bytes per word */
-#define 	BY2V		8			/* bytes per vlong */
+#define BY2V		8			/* bytes per vlong */
 #define	BY2PG		4096		/* bytes per page */
 #define	WD2PG		(BY2PG/BY2WD)	/* words per page */
 #define	PGSHIFT		12			/* log(BY2PG) */
-#define 	ROUND(s, sz)	(((s)+(sz-1))&~(sz-1))
-#define 	PGROUND(s)	ROUND(s, BY2PG)
 #define	CACHELINELOG	4
 #define	CACHELINESZ	(1<<CACHELINELOG)
 #define	BLOCKALIGN	CACHELINESZ
@@ -179,6 +171,7 @@
 
 #define	UZERO	0			/* base of user address space */
 #define	UTZERO	(UZERO+BY2PG)		/* first address in user text */
+#define UTROUND(t)	ROUNDUP((t), 0x100000)
 #define	USTKTOP	(TSTKTOP-TSTKSIZ*BY2PG)	/* byte just beyond user stack */
 #define	TSTKTOP	KZERO	/* top of temporary stack */
 #define	TSTKSIZ 100

+ 2 - 17
sys/src/9/omap/mem.h

@@ -5,39 +5,24 @@
 #define MiB		1048576u		/* Mebi 0x0000000000100000 */
 #define GiB		1073741824u		/* Gibi 000000000040000000 */
 
-#define HOWMANY(x, y)	(((x)+((y)-1))/(y))
-#define ROUNDUP(x, y)	(HOWMANY((x), (y))*(y))	/* ceiling */
-#define ROUNDDN(x, y)	(((x)/(y))*(y))		/* floor */
-#define MIN(a, b)	((a) < (b)? (a): (b))
-#define MAX(a, b)	((a) > (b)? (a): (b))
-
 /*
  * Not sure where these macros should go.
  * This probably isn't right but will do for now.
  * The macro names are problematic too.
  */
 /*
- * In B(o), 'o' is the bit offset in the register.
+ * In BITN(o), 'o' is the bit offset in the register.
  * For multi-bit fields use F(v, o, w) where 'v' is the value
  * of the bit-field of width 'w' with LSb at bit offset 'o'.
  */
-#define B(o)		(1<<(o))
+#define BITN(o)		(1<<(o))
 #define F(v, o, w)	(((v) & ((1<<(w))-1))<<(o))
 
-#define FCLR(d, o, w)	((d) & ~(((1<<(w))-1)<<(o)))
-#define FEXT(d, o, w)	(((d)>>(o)) & ((1<<(w))-1))
-#define FINS(d, o, w, v) (FCLR((d), (o), (w))|F((v), (o), (w)))
-#define FSET(d, o, w)	((d)|(((1<<(w))-1)<<(o)))
-
-#define FMASK(o, w)	(((1<<(w))-1)<<(o))
-
 /*
  * Sizes
  */
 #define	BY2PG		(4*KiB)			/* bytes per page */
 #define	PGSHIFT		12			/* log(BY2PG) */
-#define	PGROUND(s)	ROUNDUP(s, BY2PG)
-#define	ROUND(s, sz)	(((s)+(sz-1))&~(sz-1))
 
 #define	MAXMACH		1			/* max # cpus system can run */
 #define	MACHSIZE	BY2PG

+ 0 - 2
sys/src/9/pc/etherif.h

@@ -33,5 +33,3 @@ extern int parseether(uchar*, char*);
 
 #define NEXT(x, l)	(((x)+1)%(l))
 #define PREV(x, l)	(((x) == 0) ? (l)-1: (x)-1)
-#define	HOWMANY(x, y)	(((x)+((y)-1))/(y))
-#define ROUNDUP(x, y)	(HOWMANY((x), (y))*(y))

+ 1 - 5
sys/src/9/pc/mem.h

@@ -2,9 +2,6 @@
  * Memory and machine-specific definitions.  Used in C and assembler.
  */
 
-#define MIN(a, b)	((a) < (b)? (a): (b))
-#define MAX(a, b)	((a) > (b)? (a): (b))
-
 /*
  * Sizes
  */
@@ -16,8 +13,6 @@
 #define	WD2PG		(BY2PG/BY2WD)		/* words per page */
 #define	BY2XPG		(4096*1024)		/* bytes per big page */
 #define	PGSHIFT		12			/* log(BY2PG) */
-#define	ROUND(s, sz)	(((s)+((sz)-1))&~((sz)-1))
-#define	PGROUND(s)	ROUND(s, BY2PG)
 #define CACHELINESZ	32			/* pentium & later */
 #define	BLOCKALIGN	8
 #define FPalign		16			/* required for FXSAVE */
@@ -51,6 +46,7 @@
 #define	VMAPSIZE	(0x10000000-VPTSIZE-KMAPSIZE)
 #define	UZERO		0			/* base of user address space */
 #define	UTZERO		(UZERO+BY2PG)		/* first address in user text */
+#define UTROUND(t)	ROUNDUP((t), BY2PG)
 #define	USTKTOP		(VMAP-BY2PG)		/* byte just beyond user stack */
 #define	USTKSIZE	(16*1024*1024)		/* size of user stack */
 #define	TSTKTOP		(USTKTOP-USTKSIZE)	/* end of new stack in sysexec */

+ 0 - 3
sys/src/9/pc/sdata.c

@@ -9,9 +9,6 @@
 
 #include "../port/sd.h"
 
-#define	HOWMANY(x, y)	(((x)+((y)-1))/(y))
-#define ROUNDUP(x, y)	(HOWMANY((x), (y))*(y))
-
 extern SDifc sdataifc;
 
 enum {

+ 6 - 0
sys/src/9/pcboot/expand.h

@@ -1,3 +1,9 @@
+/* normally defined in ../port/portdat.h */
+#define	ROUND(s, sz)	(((s)+(sz-1))&~(sz-1))
+#define	PGROUND(s)	ROUNDUP(s, BY2PG)
+#define HOWMANY(x, y)	(((x)+((y)-1))/(y))
+#define ROUNDUP(x, y)	(HOWMANY((x), (y))*(y))	/* ceiling */
+
 void cgainit(void);
 void cgaputc(int);
 int inb(int);

+ 1 - 5
sys/src/9/pcboot/mem.h

@@ -2,9 +2,6 @@
  * Memory and machine-specific definitions.  Used in C and assembler.
  */
 
-#define MIN(a, b)	((a) < (b)? (a): (b))
-#define MAX(a, b)	((a) > (b)? (a): (b))
-
 /*
  * Sizes
  */
@@ -16,8 +13,6 @@
 #define	WD2PG		(BY2PG/BY2WD)		/* words per page */
 #define	BY2XPG		(4096*1024)		/* bytes per big page */
 #define	PGSHIFT		12			/* log(BY2PG) */
-#define	ROUND(s, sz)	(((s)+((sz)-1))&~((sz)-1))
-#define	PGROUND(s)	ROUND(s, BY2PG)
 #define CACHELINESZ	32			/* pentium & later */
 #define	BLOCKALIGN	8
 
@@ -53,6 +48,7 @@
 #define	VMAPSIZE	(0x10000000-VPTSIZE-KMAPSIZE)
 #define	UZERO		0			/* base of user address space */
 #define	UTZERO		(UZERO+BY2PG)		/* first address in user text */
+#define UTROUND(t)	ROUNDUP((t), BY2PG)
 #define	USTKTOP		(VMAP-BY2PG)		/* byte just beyond user stack */
 #define	USTKSIZE	(16*1024*1024)		/* size of user stack */
 #define	TSTKTOP		(USTKTOP-USTKSIZE)	/* end of new stack in sysexec */

+ 22 - 0
sys/src/9/port/portdat.h

@@ -58,6 +58,28 @@ typedef int    Devgen(Chan*, char*, Dirtab*, int, int, Dir*);
 
 #include <fcall.h>
 
+#define HOWMANY(x, y)	(((x)+((y)-1))/(y))
+#define ROUNDUP(x, y)	(HOWMANY((x), (y))*(y))	/* ceiling */
+#define ROUNDDN(x, y)	(((x)/(y))*(y))		/* floor */
+#define	ROUND(s, sz)	(((s)+(sz-1))&~(sz-1))
+#define	PGROUND(s)	ROUNDUP(s, BY2PG)
+#define MIN(a, b)	((a) < (b)? (a): (b))
+#define MAX(a, b)	((a) > (b)? (a): (b))
+
+/*
+ * For multi-bit fields use FIELD(v, o, w) where 'v' is the value
+ * of the bit-field of width 'w' with LSb at bit offset 'o'.
+ */
+#define FIELD(v, o, w)	(((v) & ((1<<(w))-1))<<(o))
+
+#define FCLR(d, o, w)	((d) & ~(((1<<(w))-1)<<(o)))
+#define FEXT(d, o, w)	(((d)>>(o)) & ((1<<(w))-1))
+#define FINS(d, o, w, v) (FCLR((d), (o), (w))|FIELD((v), (o), (w)))
+#define FSET(d, o, w)	((d)|(((1<<(w))-1)<<(o)))
+
+#define FMASK(o, w)	(((1<<(w))-1)<<(o))
+
+/* let each port override any of these */
 #ifndef KMESGSIZE
 #define KMESGSIZE (16*1024)
 #endif

+ 1 - 1
sys/src/9/port/portmkfile

@@ -30,7 +30,7 @@ all:V:
 		mk 'CONF='$i
 
 clean:V:
-	rm -f *.[$OS] *.root.s *.rootc.c cfs.h fs.h init.h conf.h *.out *.m errstr.h
+	rm -f *.[$OS] *.root.s *.rootc.c cfs.h fs.h init.h conf.h reboot.h reboot.list *.out *.m errstr.h
 	for(i in $CONFLIST $CRAPLIST)
 		mk $i.clean
 

+ 1 - 1
sys/src/9/port/sysproc.c

@@ -295,7 +295,7 @@ sysexec(ulong *arg)
 
 	data = l2be(exec.data);
 	bss = l2be(exec.bss);
-	t = (UTZERO+sizeof(Exec)+text+(BY2PG-1)) & ~(BY2PG-1);
+	t = UTROUND(UTZERO+sizeof(Exec)+text);
 	d = (t + data + (BY2PG-1)) & ~(BY2PG-1);
 	bssend = t + data + bss;
 	b = (bssend + (BY2PG-1)) & ~(BY2PG-1);

+ 0 - 2
sys/src/9/ppc/etherif.h

@@ -31,5 +31,3 @@ extern ulong ethercrc(uchar*, int);
 
 #define NEXT(x, l)	(((x)+1)%(l))
 #define PREV(x, l)	(((x) == 0) ? (l)-1: (x)-1)
-#define	HOWMANY(x, y)	(((x)+((y)-1))/(y))
-#define ROUNDUP(x, y)	(HOWMANY((x), (y))*(y))

+ 1 - 5
sys/src/9/ppc/mem.h

@@ -8,9 +8,6 @@
 #include "blast.h"
 #endif
 
-#define MIN(a, b)	((a) < (b)? (a): (b))
-#define MAX(a, b)	((a) > (b)? (a): (b))
-
 /*
  * Sizes
  */
@@ -22,8 +19,6 @@
 #define	BY2PG		4096			/* bytes per page */
 #define	WD2PG		(BY2PG/BY2WD)		/* words per page */
 #define	PGSHIFT		12			/* log(BY2PG) */
-#define ROUND(s, sz)	(((s)+(sz-1))&~(sz-1))
-#define PGROUND(s)	ROUND(s, BY2PG)
 #define	CACHELINELOG	5
 #define	CACHELINESZ	(1<<CACHELINELOG)
 #define	BLOCKALIGN	CACHELINESZ
@@ -212,6 +207,7 @@
 #define	KTZERO		0x80100000		/* first address in kernel text */
 #define	UZERO		0			/* base of user address space */
 #define	UTZERO		(UZERO+BY2PG)		/* first address in user text */
+#define UTROUND(t)	ROUNDUP((t), 0x100000)
 #define	USTKTOP		(TSTKTOP-TSTKSIZ*BY2PG)	/* byte just beyond user stack */
 #define	TSTKTOP		KZERO			/* top of temporary stack */
 #define	TSTKSIZ		100

+ 2 - 17
sys/src/9/teg2/mem.h

@@ -5,39 +5,24 @@
 #define MiB		1048576u		/* Mebi 0x0000000000100000 */
 #define GiB		1073741824u		/* Gibi 000000000040000000 */
 
-#define HOWMANY(x, y)	(((x)+((y)-1))/(y))
-#define ROUNDUP(x, y)	(HOWMANY((x), (y))*(y))	/* ceiling */
-#define ROUNDDN(x, y)	(((x)/(y))*(y))		/* floor */
-#define MIN(a, b)	((a) < (b)? (a): (b))
-#define MAX(a, b)	((a) > (b)? (a): (b))
-
 /*
  * Not sure where these macros should go.
  * This probably isn't right but will do for now.
  * The macro names are problematic too.
  */
 /*
- * In B(o), 'o' is the bit offset in the register.
+ * In BITN(o), 'o' is the bit offset in the register.
  * For multi-bit fields use F(v, o, w) where 'v' is the value
  * of the bit-field of width 'w' with LSb at bit offset 'o'.
  */
-#define B(o)		(1<<(o))
+#define BITN(o)		(1<<(o))
 #define F(v, o, w)	(((v) & ((1<<(w))-1))<<(o))
 
-#define FCLR(d, o, w)	((d) & ~(((1<<(w))-1)<<(o)))
-#define FEXT(d, o, w)	(((d)>>(o)) & ((1<<(w))-1))
-#define FINS(d, o, w, v) (FCLR((d), (o), (w))|F((v), (o), (w)))
-#define FSET(d, o, w)	((d)|(((1<<(w))-1)<<(o)))
-
-#define FMASK(o, w)	(((1<<(w))-1)<<(o))
-
 /*
  * Sizes
  */
 #define	BY2PG		(4*KiB)			/* bytes per page */
 #define	PGSHIFT		12			/* log(BY2PG) */
-#define	PGROUND(s)	ROUNDUP(s, BY2PG)
-#define	ROUND(s, sz)	(((s)+(sz-1))&~(sz-1))
 
 /* max # of cpus system can run.  tegra2 cpu ids are two bits wide. */
 #define	MAXMACH		4

+ 0 - 4
sys/src/9/teg2/mkfile

@@ -90,7 +90,6 @@ $p$CONF:DQ:	$CONF.c $OBJ $LIB mkfile
 
 s$p$CONF:DQ:	$CONF.$O $OBJ $LIB
 	echo '# linking 9 kernel with symbols'
-#	$LD -o $target -R4096 -T$loadaddr -l -a $OBJ $CONF.$O $LIB >$target.list
 	$LD -o $target -R4096 -T$loadaddr -l $OBJ $CONF.$O $LIB
 	size $target
 
@@ -149,6 +148,3 @@ reboot.h:D:	rebootcode.s cache.v7.s arm.s arm.h mem.h
 	 echo '};'} > reboot.h
 errstr.h:D:	../port/mkerrstr ../port/error.h
 	rc ../port/mkerrstr > errstr.h
-
-$CONF.clean:
-	rm -rf $p$CONF s$p$CONF errstr.h reboot.h $CONF.c boot$CONF.c

+ 1 - 1
sys/src/cmd/usb/disk/ums.h

@@ -59,7 +59,7 @@ struct Umsc
 	long	off;		/* offset within a block */
 	long	nb;		/* byte count */
 
-	uchar 	rawcmd[10];
+	uchar 	rawcmd[16];
 	uchar	phase;
 	char	*inq;
 	Ums	*ums;