Browse Source

update all the types to the standard types.

note that longs in plan 9 are 32 bits, hence the change
of ulong and long to uint32_t and int32_t

Signed-off-by: Ronald G. Minnich <rminnich@gmail.com>
Ronald G. Minnich 9 years ago
parent
commit
a70b8e9158
100 changed files with 2248 additions and 2222 deletions
  1. 29 29
      sys/src/9/386/devether.c
  2. 32 32
      sys/src/9/386/devrtc.c
  3. 11 11
      sys/src/9/386/ether8169.c
  4. 34 34
      sys/src/9/386/ether82557.c
  5. 26 26
      sys/src/9/386/ether82563.c
  6. 30 30
      sys/src/9/386/etherigbe.c
  7. 50 50
      sys/src/9/386/etherm10g.c
  8. 6 6
      sys/src/9/386/kbd.c
  9. 37 37
      sys/src/9/386/pci.c
  10. 4 4
      sys/src/9/386/random.c
  11. 7 7
      sys/src/9/386/uarti8250.c
  12. 3 3
      sys/src/9/386/uartpci.c
  13. 15 15
      sys/src/9/boot/aux.c
  14. 13 13
      sys/src/9/boot/boot.c
  15. 3 3
      sys/src/9/boot/bootauth.c
  16. 2 2
      sys/src/9/boot/bootcache.c
  17. 15 15
      sys/src/9/boot/bootip.c
  18. 18 18
      sys/src/9/boot/doauthenticate.c
  19. 3 3
      sys/src/9/boot/embed.c
  20. 2 2
      sys/src/9/boot/getpasswd.c
  21. 13 13
      sys/src/9/boot/local.c
  22. 1 1
      sys/src/9/boot/nopsession.c
  23. 3 3
      sys/src/9/boot/paq.c
  24. 1 1
      sys/src/9/boot/sac.c
  25. 10 10
      sys/src/9/boot/settime.c
  26. 20 18
      sys/src/9/ip/arp.c
  27. 14 14
      sys/src/9/ip/chandial.c
  28. 58 57
      sys/src/9/ip/devip.c
  29. 47 46
      sys/src/9/ip/ethermedium.c
  30. 26 26
      sys/src/9/ip/gre.c
  31. 38 38
      sys/src/9/ip/icmp.c
  32. 35 33
      sys/src/9/ip/icmp6.c
  33. 4 4
      sys/src/9/ip/inferno.c
  34. 32 32
      sys/src/9/ip/ip.c
  35. 29 29
      sys/src/9/ip/ipaux.c
  36. 85 83
      sys/src/9/ip/ipifc.c
  37. 42 39
      sys/src/9/ip/iproute.c
  38. 18 18
      sys/src/9/ip/ipv6.c
  39. 2 2
      sys/src/9/ip/loopbackmedium.c
  40. 6 5
      sys/src/9/ip/netdevmedium.c
  41. 8 8
      sys/src/9/ip/netlog.c
  42. 2 2
      sys/src/9/ip/nullmedium.c
  43. 4 4
      sys/src/9/ip/pktmedium.c
  44. 15 15
      sys/src/9/ip/ptclbsum.c
  45. 162 160
      sys/src/9/ip/tcp.c
  46. 49 49
      sys/src/9/ip/udp.c
  47. 9 9
      sys/src/9/k10/acore.c
  48. 2 2
      sys/src/9/k10/apic.c
  49. 2 2
      sys/src/9/k10/arch.c
  50. 4 4
      sys/src/9/k10/archk10.c
  51. 4 4
      sys/src/9/k10/archk8.c
  52. 1 1
      sys/src/9/k10/asm.c
  53. 8 8
      sys/src/9/k10/cga.c
  54. 10 10
      sys/src/9/k10/crap.c
  55. 57 55
      sys/src/9/k10/devacpi.c
  56. 30 30
      sys/src/9/k10/devarch.c
  57. 23 23
      sys/src/9/k10/ether82563.c
  58. 8 8
      sys/src/9/k10/etherbcm.c
  59. 16 16
      sys/src/9/k10/fpu.c
  60. 1 1
      sys/src/9/k10/i8254.c
  61. 2 2
      sys/src/9/k10/init9.c
  62. 2 2
      sys/src/9/k10/ioapic.c
  63. 15 15
      sys/src/9/k10/main.c
  64. 4 4
      sys/src/9/k10/mmu.c
  65. 8 8
      sys/src/9/k10/mp.c
  66. 2 2
      sys/src/9/k10/msi.c
  67. 1 1
      sys/src/9/k10/multiboot.c
  68. 5 5
      sys/src/9/k10/physalloc.c
  69. 4 4
      sys/src/9/k10/pmcio.c
  70. 16 16
      sys/src/9/k10/qmalloc.c
  71. 15 15
      sys/src/9/k10/ratrace.c
  72. 75 74
      sys/src/9/k10/root/cpu.c
  73. 5 5
      sys/src/9/k10/syscall.c
  74. 5 5
      sys/src/9/k10/tcore.c
  75. 17 17
      sys/src/9/k10/trap.c
  76. 5 5
      sys/src/9/port/alarm.c
  77. 42 41
      sys/src/9/port/alloc.c
  78. 4 4
      sys/src/9/port/allocb.c
  79. 12 12
      sys/src/9/port/cache.c
  80. 39 39
      sys/src/9/port/chan.c
  81. 29 24
      sys/src/9/port/dev.c
  82. 131 131
      sys/src/9/port/devaoe.c
  83. 21 20
      sys/src/9/port/devcap.c
  84. 47 46
      sys/src/9/port/devcec.c
  85. 25 25
      sys/src/9/port/devcmd.c
  86. 124 124
      sys/src/9/port/devcons.c
  87. 10 10
      sys/src/9/port/devdup.c
  88. 18 18
      sys/src/9/port/devenv.c
  89. 14 14
      sys/src/9/port/devkexec.c
  90. 14 14
      sys/src/9/port/devkprof.c
  91. 45 45
      sys/src/9/port/devmnt.c
  92. 19 19
      sys/src/9/port/devpci.c
  93. 14 14
      sys/src/9/port/devpipe.c
  94. 14 14
      sys/src/9/port/devpmc.c
  95. 28 28
      sys/src/9/port/devprobe.c
  96. 48 48
      sys/src/9/port/devproc.c
  97. 19 18
      sys/src/9/port/devroot.c
  98. 60 60
      sys/src/9/port/devsd.c
  99. 29 29
      sys/src/9/port/devsegment.c
  100. 22 22
      sys/src/9/port/devsrv.c

+ 29 - 29
sys/src/9/386/devether.c

@@ -21,10 +21,10 @@
 static Ether *etherxx[MaxEther];
 
 Chan*
-etherattach(char* spec)
+etherattach(int8_t* spec)
 {
-	ulong ctlrno;
-	char *p;
+	uint32_t ctlrno;
+	int8_t *p;
 	Chan *chan;
 
 	ctlrno = 0;
@@ -49,13 +49,13 @@ etherattach(char* spec)
 }
 
 static Walkqid*
-etherwalk(Chan* chan, Chan* nchan, char** name, int nname)
+etherwalk(Chan* chan, Chan* nchan, int8_t** name, int nname)
 {
 	return netifwalk(etherxx[chan->devno], chan, nchan, name, nname);
 }
 
-static long
-etherstat(Chan* chan, uchar* dp, long n)
+static int32_t
+etherstat(Chan* chan, uint8_t* dp, int32_t n)
 {
 	return netifstat(etherxx[chan->devno], chan, dp, n);
 }
@@ -67,7 +67,7 @@ etheropen(Chan* chan, int omode)
 }
 
 static void
-ethercreate(Chan*, char*, int, int)
+ethercreate(Chan*, int8_t*, int, int)
 {
 }
 
@@ -77,11 +77,11 @@ etherclose(Chan* chan)
 	netifclose(etherxx[chan->devno], chan);
 }
 
-static long
-etherread(Chan* chan, void* buf, long n, vlong off)
+static int32_t
+etherread(Chan* chan, void* buf, int32_t n, int64_t off)
 {
 	Ether *ether;
-	ulong offset = off;
+	uint32_t offset = off;
 
 	ether = etherxx[chan->devno];
 	if((chan->qid.type & QTDIR) == 0 && ether->ifstat){
@@ -99,13 +99,13 @@ etherread(Chan* chan, void* buf, long n, vlong off)
 }
 
 static Block*
-etherbread(Chan* chan, long n, vlong offset)
+etherbread(Chan* chan, int32_t n, int64_t offset)
 {
 	return netifbread(etherxx[chan->devno], chan, n, offset);
 }
 
-static long
-etherwstat(Chan* chan, uchar* dp, long n)
+static int32_t
+etherwstat(Chan* chan, uint8_t* dp, int32_t n)
 {
 	return netifwstat(etherxx[chan->devno], chan, dp, n);
 }
@@ -141,7 +141,7 @@ Block*
 etheriq(Ether* ether, Block* bp, int fromwire)
 {
 	Etherpkt *pkt;
-	ushort type;
+	uint16_t type;
 	int len, multi, tome, fromme;
 	Netfile **ep, *f, **fp, *fx;
 	Block *xbp;
@@ -249,8 +249,8 @@ etheroq(Ether* ether, Block* bp)
 	return len;
 }
 
-static long
-etherwrite(Chan* chan, void* buf, long n, vlong)
+static int32_t
+etherwrite(Chan* chan, void* buf, int32_t n, int64_t)
 {
 	Ether *ether;
 	Block *bp;
@@ -298,11 +298,11 @@ etherwrite(Chan* chan, void* buf, long n, vlong)
 	return etheroq(ether, bp);
 }
 
-static long
-etherbwrite(Chan* chan, Block* bp, vlong)
+static int32_t
+etherbwrite(Chan* chan, Block* bp, int64_t)
 {
 	Ether *ether;
-	long n;
+	int32_t n;
 
 	n = BLEN(bp);
 	if(NETTYPE(chan->qid.path) != Ndataqid){
@@ -330,12 +330,12 @@ etherbwrite(Chan* chan, Block* bp, vlong)
 }
 
 static struct {
-	char*	type;
+	int8_t*	type;
 	int	(*reset)(Ether*);
 } cards[MaxEther+1];
 
 void
-addethercard(char* t, int (*r)(Ether*))
+addethercard(int8_t* t, int (*r)(Ether*))
 {
 	static int ncard;
 
@@ -347,10 +347,10 @@ addethercard(char* t, int (*r)(Ether*))
 }
 
 int
-parseether(uchar *to, char *from)
+parseether(uint8_t *to, int8_t *from)
 {
-	char nip[4];
-	char *p;
+	int8_t nip[4];
+	int8_t *p;
 	int i;
 
 	p = from;
@@ -374,7 +374,7 @@ etherprobe(int cardno, int ctlrno)
 {
 	int i, j;
 	Ether *ether;
-	char buf[128], name[32];
+	int8_t buf[128], name[32];
 
 	ether = malloc(sizeof(Ether));
 	memset(ether, 0, sizeof(Ether));
@@ -491,7 +491,7 @@ etherreset(void)
 static void
 ethershutdown(void)
 {
-	char name[32];
+	int8_t name[32];
 	int i;
 	Ether *ether;
 
@@ -515,11 +515,11 @@ ethershutdown(void)
 #define POLY 0xedb88320
 
 /* really slow 32 bit crc for ethers */
-ulong
-ethercrc(uchar *p, int len)
+uint32_t
+ethercrc(uint8_t *p, int len)
 {
 	int i, j;
-	ulong crc, b;
+	uint32_t crc, b;
 
 	crc = 0xffffffff;
 	for(i = 0; i < len; i++){

+ 32 - 32
sys/src/9/386/devrtc.c

@@ -60,8 +60,8 @@ Dirtab rtcdir[]={
 	"rtc",		{Qrtc, 0},	0,	0664,
 };
 
-static ulong rtc2sec(Rtc*);
-static void sec2rtc(ulong, Rtc*);
+static uint32_t rtc2sec(Rtc*);
+static void sec2rtc(uint32_t, Rtc*);
 
 void
 rtcinit(void)
@@ -71,19 +71,19 @@ rtcinit(void)
 }
 
 static Chan*
-rtcattach(char* spec)
+rtcattach(int8_t* spec)
 {
 	return devattach('r', spec);
 }
 
 static Walkqid*	 
-rtcwalk(Chan* c, Chan *nc, char** name, int nname)
+rtcwalk(Chan* c, Chan *nc, int8_t** name, int nname)
 {
 	return devwalk(c, nc, name, nname, rtcdir, nelem(rtcdir), devgen);
 }
 
-static long	 
-rtcstat(Chan* c, uchar* dp, long n)
+static int32_t	 
+rtcstat(Chan* c, uint8_t* dp, int32_t n)
 {
 	return devstat(c, dp, n, rtcdir, nelem(rtcdir), devgen);
 }
@@ -92,7 +92,7 @@ static Chan*
 rtcopen(Chan* c, int omode)
 {
 	omode = openmode(omode);
-	switch((ulong)c->qid.path){
+	switch((uint32_t)c->qid.path){
 	case Qrtc:
 		if(strcmp(up->user, eve)!=0 && omode!=OREAD)
 			error(Eperm);
@@ -111,10 +111,10 @@ rtcclose(Chan*)
 
 #define GETBCD(o) ((bcdclock[o]&0xf) + 10*(bcdclock[o]>>4))
 
-static long	 
+static int32_t	 
 rtcextract(void)
 {
-	uchar bcdclock[Nbcd];
+	uint8_t bcdclock[Nbcd];
 	Rtc rtc;
 	int i;
 
@@ -159,11 +159,11 @@ rtcextract(void)
 
 static Lock nvrtlock;
 
-long
+int32_t
 rtctime(void)
 {
 	int i;
-	long t, ot;
+	int32_t t, ot;
 
 	ilock(&nvrtlock);
 
@@ -181,17 +181,17 @@ rtctime(void)
 	return t;
 }
 
-static long	 
-rtcread(Chan* c, void* buf, long n, vlong off)
+static int32_t	 
+rtcread(Chan* c, void* buf, int32_t n, int64_t off)
 {
-	ulong t;
-	char *a, *start;
-	ulong offset = off;
+	uint32_t t;
+	int8_t *a, *start;
+	uint32_t offset = off;
 
 	if(c->qid.type & QTDIR)
 		return devdirread(c, buf, n, rtcdir, nelem(rtcdir), devgen);
 
-	switch((ulong)c->qid.path){
+	switch((uint32_t)c->qid.path){
 	case Qrtc:
 		t = rtctime();
 		n = readnum(offset, buf, n, t, 12);
@@ -228,22 +228,22 @@ rtcread(Chan* c, void* buf, long n, vlong off)
 
 #define PUTBCD(n,o) bcdclock[o] = (n % 10) | (((n / 10) % 10)<<4)
 
-static long	 
-rtcwrite(Chan* c, void* buf, long n, vlong off)
+static int32_t	 
+rtcwrite(Chan* c, void* buf, int32_t n, int64_t off)
 {
 	int t;
-	char *a, *start;
+	int8_t *a, *start;
 	Rtc rtc;
-	ulong secs;
-	uchar bcdclock[Nbcd];
-	char *cp, *ep;
-	ulong offset = off;
+	uint32_t secs;
+	uint8_t bcdclock[Nbcd];
+	int8_t *cp, *ep;
+	uint32_t offset = off;
 
 	if(offset!=0)
 		error(Ebadarg);
 
 
-	switch((ulong)c->qid.path){
+	switch((uint32_t)c->qid.path){
 	case Qrtc:
 		/*
 		 *  read the time
@@ -362,10 +362,10 @@ yrsize(int y)
 /*
  *  compute seconds since Jan 1 1970
  */
-static ulong
+static uint32_t
 rtc2sec(Rtc *rtc)
 {
-	ulong secs;
+	uint32_t secs;
 	int i;
 	int *d2m;
 
@@ -398,10 +398,10 @@ rtc2sec(Rtc *rtc)
  *  compute rtc from seconds since Jan 1 1970
  */
 static void
-sec2rtc(ulong secs, Rtc *rtc)
+sec2rtc(uint32_t secs, Rtc *rtc)
 {
 	int d;
-	long hms, day;
+	int32_t hms, day;
 	int *d2m;
 
 	/*
@@ -446,10 +446,10 @@ sec2rtc(ulong secs, Rtc *rtc)
 	return;
 }
 
-uchar
+uint8_t
 nvramread(int addr)
 {
-	uchar data;
+	uint8_t data;
 
 	ilock(&nvrtlock);
 	outb(Paddr, addr);
@@ -460,7 +460,7 @@ nvramread(int addr)
 }
 
 void
-nvramwrite(int addr, uchar data)
+nvramwrite(int addr, uint8_t data)
 {
 	ilock(&nvrtlock);
 	outb(Paddr, addr);

+ 11 - 11
sys/src/9/386/ether8169.c

@@ -257,7 +257,7 @@ typedef struct Ctlr {
 	int	phyv;			/* PHY version */
 	int	pcie;			/* flag: pci-express device? */
 
-	uvlong	mchash;			/* multicast hash */
+	uint64_t	mchash;			/* multicast hash */
 
 	Mii*	mii;
 
@@ -422,11 +422,11 @@ enum {
 	Bytemask = (1<<8) - 1,
 };
 
-static ulong
-ethercrcbe(uchar *addr, long len)
+static uint32_t
+ethercrcbe(uint8_t *addr, int32_t len)
 {
 	int i, j;
-	ulong c, crc, carry;
+	uint32_t c, crc, carry;
 
 	crc = ~0UL;
 	for (i = 0; i < len; i++) {
@@ -442,15 +442,15 @@ ethercrcbe(uchar *addr, long len)
 	return crc;
 }
 
-static ulong
-swabl(ulong l)
+static uint32_t
+swabl(uint32_t l)
 {
 	return l>>24 | (l>>8) & (Bytemask<<8) |
 		(l<<8) & (Bytemask<<16) | l<<24;
 }
 
 static void
-rtl8169multicast(void* ether, uchar *eaddr, int add)
+rtl8169multicast(void* ether, uint8_t *eaddr, int add)
 {
 	Ether *edev;
 	Ctlr *ctlr;
@@ -479,13 +479,13 @@ rtl8169multicast(void* ether, uchar *eaddr, int add)
 	iunlock(&ctlr->ilock);
 }
 
-static long
-rtl8169ifstat(Ether* edev, void* a, long n, ulong offset)
+static int32_t
+rtl8169ifstat(Ether* edev, void* a, int32_t n, uint32_t offset)
 {
 	Ctlr *ctlr;
 	Dtcc *dtcc;
 	int timeo;
-	char *alloc, *e, *p;
+	int8_t *alloc, *e, *p;
 
 	ctlr = edev->ctlr;
 	qlock(&ctlr->slock);
@@ -1151,7 +1151,7 @@ rtl8169pnp(Ether* edev)
 {
 	u32int r;
 	Ctlr *ctlr;
-	uchar ea[Eaddrlen];
+	uint8_t ea[Eaddrlen];
 
 	if(rtl8169ctlrhead == nil)
 		rtl8169pci();

+ 34 - 34
sys/src/9/386/ether82557.c

@@ -111,12 +111,12 @@ enum {					/* Mcr */
 
 typedef struct Rfd {
 	int	field;
-	ulong	link;
-	ulong	rbd;
-	ushort	count;
-	ushort	size;
+	uint32_t	link;
+	uint32_t	rbd;
+	uint16_t	count;
+	uint16_t	size;
 
-	uchar	data[1700];
+	uint8_t	data[1700];
 } Rfd;
 
 enum {					/* field */
@@ -147,20 +147,20 @@ enum {					/* count */
 
 typedef struct Cb Cb;
 typedef struct Cb {
-	ushort	status;
-	ushort	command;
-	ulong	link;
+	uint16_t	status;
+	uint16_t	command;
+	uint32_t	link;
 	union {
-		uchar	data[24];	/* CbIAS + CbConfigure */
+		uint8_t	data[24];	/* CbIAS + CbConfigure */
 		struct {
-			ulong	tbd;
-			ushort	count;
-			uchar	threshold;
-			uchar	number;
-
-			ulong	tba;
-			ushort	tbasz;
-			ushort	pad;
+			uint32_t	tbd;
+			uint16_t	count;
+			uint8_t	threshold;
+			uint8_t	number;
+
+			uint32_t	tba;
+			uint16_t	tbasz;
+			uint16_t	pad;
 		};
 	};
 
@@ -204,7 +204,7 @@ typedef struct Ctlr {
 	int	active;
 
 	int	eepromsz;		/* address size in bits */
-	ushort*	eeprom;
+	uint16_t*	eeprom;
 
 	Lock	miilock;
 
@@ -220,7 +220,7 @@ typedef struct Ctlr {
 	Lock	cblock;			/* transmit side */
 	int	action;
 	int	nop;
-	uchar	configdata[24];
+	uint8_t	configdata[24];
 	int	threshold;
 	int	ncb;
 	Cb*	cbr;
@@ -231,13 +231,13 @@ typedef struct Ctlr {
 	int	cbqmaxhw;
 
 	Lock	dlock;			/* dump statistical counters */
-	ulong	dump[17];
+	uint32_t	dump[17];
 } Ctlr;
 
 static Ctlr* ctlrhead;
 static Ctlr* ctlrtail;
 
-static uchar configdata[24] = {
+static uint8_t configdata[24] = {
 	0x16,				/* byte count */
 	0x08,				/* Rx/Tx FIFO limit */
 	0x00,				/* adaptive IFS */
@@ -268,8 +268,8 @@ static uchar configdata[24] = {
 #define csr16r(c, r)	(ins((c)->port+(r)))
 #define csr32r(c, r)	(inl((c)->port+(r)))
 #define csr8w(c, r, b)	(outb((c)->port+(r), (int)(b)))
-#define csr16w(c, r, w)	(outs((c)->port+(r), (ushort)(w)))
-#define csr32w(c, r, l)	(outl((c)->port+(r), (ulong)(l)))
+#define csr16w(c, r, w)	(outs((c)->port+(r), (uint16_t)(w)))
+#define csr32w(c, r, l)	(outl((c)->port+(r), (uint32_t)(l)))
 
 static void
 command(Ctlr* ctlr, int c, int v)
@@ -332,7 +332,7 @@ command(Ctlr* ctlr, int c, int v)
 }
 
 static Block*
-rfdalloc(ulong link)
+rfdalloc(uint32_t link)
 {
 	Block *bp;
 	Rfd *rfd;
@@ -384,7 +384,7 @@ static void
 attach(Ether* ether)
 {
 	Ctlr *ctlr;
-	char name[KNAMELEN];
+	int8_t name[KNAMELEN];
 
 	ctlr = ether->ctlr;
 	lock(&ctlr->slock);
@@ -408,13 +408,13 @@ attach(Ether* ether)
 	unlock(&ctlr->slock);
 }
 
-static long
-ifstat(Ether* ether, void* a, long n, ulong offset)
+static int32_t
+ifstat(Ether* ether, void* a, int32_t n, uint32_t offset)
 {
-	char *p;
+	int8_t *p;
 	int i, len, phyaddr;
 	Ctlr *ctlr;
-	ulong dump[17];
+	uint32_t dump[17];
 
 	ctlr = ether->ctlr;
 	lock(&ctlr->dlock);
@@ -593,7 +593,7 @@ promiscuous(void* arg, int on)
 }
 
 static void
-multicast(void* ether, uchar *addr, int add)
+multicast(void* ether, uint8_t *addr, int add)
 {
 	USED(addr);
 	/*
@@ -773,7 +773,7 @@ ctlrinit(Ctlr* ctlr)
 	int i;
 	Block *bp;
 	Rfd *rfd;
-	ulong link;
+	uint32_t link;
 
 	/*
 	 * Create the Receive Frame Area (RFA) as a ring of allocated
@@ -919,7 +919,7 @@ reread:
 
 	if(ctlr->eepromsz == 0){
 		ctlr->eepromsz = 8-size;
-		ctlr->eeprom = malloc((1<<ctlr->eepromsz)*sizeof(ushort));
+		ctlr->eeprom = malloc((1<<ctlr->eepromsz)*sizeof(uint16_t));
 		goto reread;
 	}
 
@@ -992,7 +992,7 @@ i82557pci(void)
 	}
 }
 
-static char* mediatable[9] = {
+static int8_t* mediatable[9] = {
 	"10BASE-T",				/* TP */
 	"10BASE-2",				/* BNC */
 	"10BASE-5",				/* AUI */
@@ -1047,7 +1047,7 @@ reset(Ether* ether)
 {
 	int anar, anlpar, bmcr, bmsr, i, k, medium, phyaddr, x;
 	unsigned short sum;
-	uchar ea[Eaddrlen];
+	uint8_t ea[Eaddrlen];
 	Ctlr *ctlr;
 
 	if(ctlrhead == nil)

+ 26 - 26
sys/src/9/386/ether82563.c

@@ -446,7 +446,7 @@ static int rbtab[] = {
 	1514,
 };
 
-static char *tname[] = {
+static int8_t *tname[] = {
 	"any",
 	"i82563",
 	"i82566",
@@ -464,7 +464,7 @@ struct Ctlr {
 	Ctlr	*next;
 	int	active;
 	int	type;
-	ushort	eeprom[0x40];
+	uint16_t	eeprom[0x40];
 
 	QLock	alock;			/* attach */
 	int	attached;
@@ -493,8 +493,8 @@ struct Ctlr {
 	uint	tcpcs;
 	uint	speeds[4];
 
-	uchar	ra[Eaddrlen];		/* receive address */
-	ulong	mta[128];		/* multicast table array */
+	uint8_t	ra[Eaddrlen];		/* receive address */
+	uint32_t	mta[128];		/* multicast table array */
 
 	Rendez	rrendez;
 	int	rim;
@@ -529,7 +529,7 @@ static Ctlr* i82563ctlrtail;
 static Lock i82563rblock;		/* free receive Blocks */
 static Block* i82563rbpool;
 
-static char* statistics[] = {
+static int8_t* statistics[] = {
 	"CRC Error",
 	"Alignment Error",
 	"Symbol Error",
@@ -605,13 +605,13 @@ static char* statistics[] = {
 	"Interrupt Rx Overrun",
 };
 
-static long
-i82563ifstat(Ether* edev, void* a, long n, ulong offset)
+static int32_t
+i82563ifstat(Ether* edev, void* a, int32_t n, uint32_t offset)
 {
 	Ctlr *ctlr;
-	char *s, *p, *e, *stat;
+	int8_t *s, *p, *e, *stat;
 	int i, r;
-	uvlong tuvl, ruvl;
+	uint64_t tuvl, ruvl;
 
 	ctlr = edev->ctlr;
 	qlock(&ctlr->slock);
@@ -628,10 +628,10 @@ i82563ifstat(Ether* edev, void* a, long n, ulong offset)
 		case Torl:
 		case Totl:
 			ruvl = r;
-			ruvl += (uvlong)csr32r(ctlr, Statistics+(i+1)*4) << 32;
+			ruvl += (uint64_t)csr32r(ctlr, Statistics+(i+1)*4) << 32;
 			tuvl = ruvl;
 			tuvl += ctlr->statistics[i];
-			tuvl += (uvlong)ctlr->statistics[i+1] << 32;
+			tuvl += (uint64_t)ctlr->statistics[i+1] << 32;
 			if(tuvl == 0)
 				continue;
 			ctlr->statistics[i] = tuvl;
@@ -693,11 +693,11 @@ static Cmdtab i82563ctlmsg[] = {
 	CMradv,	"radv",	2,
 };
 
-static long
-i82563ctl(Ether* edev, void* buf, long n)
+static int32_t
+i82563ctl(Ether* edev, void* buf, int32_t n)
 {
-	ulong v;
-	char *p;
+	uint32_t v;
+	int8_t *p;
 	Ctlr *ctlr;
 	Cmdbuf *cb;
 	Cmdtab *ct;
@@ -753,7 +753,7 @@ i82563promiscuous(void* arg, int on)
 }
 
 static void
-i82563multicast(void* arg, uchar* addr, int on)
+i82563multicast(void* arg, uint8_t* addr, int on)
 {
 	int bit, x;
 	Ctlr *ctlr;
@@ -800,7 +800,7 @@ i82563rballoc(void)
 static void
 i82563rbfree(Block* b)
 {
-	b->rp = b->wp = (uchar*)ROUNDUP((uintptr)b->base, 4*KiB);
+	b->rp = b->wp = (uint8_t*)ROUNDUP((uintptr)b->base, 4*KiB);
  	b->flag &= ~(Bpktck|Btcpck|Budpck|Bipck);
 	ilock(&i82563rblock);
 	b->next = i82563rbpool;
@@ -1138,7 +1138,7 @@ phyread(Ctlr *c, int reg)
 }
 
 static uint
-phywrite(Ctlr *c, int reg, ushort val)
+phywrite(Ctlr *c, int reg, uint16_t val)
 {
 	uint phy, i;
 
@@ -1223,7 +1223,7 @@ i82563attach(Ether* edev)
 {
 	Block *bp;
 	Ctlr *ctlr;
-	char name[KNAMELEN];
+	int8_t name[KNAMELEN];
 
 	ctlr = edev->ctlr;
 	qlock(&ctlr->alock);
@@ -1405,7 +1405,7 @@ i82563shutdown(Ether* ether)
 	i82563detach(ether->ctlr);
 }
 
-static ushort
+static uint16_t
 eeread(Ctlr *ctlr, int adr)
 {
 	csr32w(ctlr, Eerd, EEstart | adr << 2);
@@ -1417,7 +1417,7 @@ eeread(Ctlr *ctlr, int adr)
 static int
 eeload(Ctlr *ctlr)
 {
-	ushort sum;
+	uint16_t sum;
 	int data, adr;
 
 	sum = 0;
@@ -1432,7 +1432,7 @@ eeload(Ctlr *ctlr)
 static int
 fcycle(Ctlr *, Flash *f)
 {
-	ushort s, i;
+	uint16_t s, i;
 
 	s = f->reg[Fsts];
 	if((s&Fvalid) == 0)
@@ -1450,7 +1450,7 @@ fcycle(Ctlr *, Flash *f)
 static int
 fread(Ctlr *c, Flash *f, int ladr)
 {
-	ushort s;
+	uint16_t s;
 
 	delay(1);
 	if(fcycle(c, f) == -1)
@@ -1475,8 +1475,8 @@ fread(Ctlr *c, Flash *f, int ladr)
 static int
 fload(Ctlr *c)
 {
-	ulong data, io, r, adr;
-	ushort sum;
+	uint32_t data, io, r, adr;
+	uint16_t sum;
 	Flash f;
 
 	io = c->pcidev->mem[1].bar & ~0x0f;
@@ -1559,7 +1559,7 @@ static void
 i82563pci(void)
 {
 	int type;
-	ulong io;
+	uint32_t io;
 	void *mem;
 	Pcidev *p;
 	Ctlr *ctlr;

+ 30 - 30
sys/src/9/386/etherigbe.c

@@ -364,11 +364,11 @@ enum {					/* Receive Delay Timer Ring */
 
 typedef struct Rd {			/* Receive Descriptor */
 	uint	addr[2];
-	ushort	length;
-	ushort	checksum;
-	uchar	status;
-	uchar	errors;
-	ushort	special;
+	uint16_t	length;
+	uint16_t	checksum;
+	uint8_t	status;
+	uint8_t	errors;
+	uint16_t	special;
 } Rd;
 
 enum {					/* Rd status */
@@ -396,12 +396,12 @@ struct Td {				/* Transmit Descriptor */
 	union {
 		uint	addr[2];	/* Data */
 		struct {		/* Context */
-			uchar	ipcss;
-			uchar	ipcso;
-			ushort	ipcse;
-			uchar	tucss;
-			uchar	tucso;
-			ushort	tucse;
+			uint8_t	ipcss;
+			uint8_t	ipcso;
+			uint16_t	ipcse;
+			uint8_t	tucss;
+			uint8_t	tucso;
+			uint16_t	tucse;
 		};
 	};
 	uint	control;
@@ -459,7 +459,7 @@ typedef struct Ctlr {
 	int	started;
 	int	id;
 	int	cls;
-	ushort	eeprom[0x40];
+	uint16_t	eeprom[0x40];
 
 	QLock	alock;			/* attach */
 	void*	alloc;			/* receive/transmit descriptors */
@@ -489,8 +489,8 @@ typedef struct Ctlr {
 	uint	ipcs;
 	uint	tcpcs;
 
-	uchar	ra[Eaddrlen];		/* receive address */
-	ulong	mta[128];		/* multicast table array */
+	uint8_t	ra[Eaddrlen];		/* receive address */
+	uint32_t	mta[128];		/* multicast table array */
 
 	Rendez	rrendez;
 	int	rim;
@@ -523,7 +523,7 @@ static Ctlr* igbectlrtail;
 static Lock igberblock;		/* free receive Blocks */
 static Block* igberbpool;
 
-static char* statistics[Nstatistics] = {
+static int8_t* statistics[Nstatistics] = {
 	"CRC Error",
 	"Alignment Error",
 	"Symbol Error",
@@ -590,13 +590,13 @@ static char* statistics[Nstatistics] = {
 	"TCP Segmentation Context Fail",
 };
 
-static long
-igbeifstat(Ether* edev, void* a, long n, ulong offset)
+static int32_t
+igbeifstat(Ether* edev, void* a, int32_t n, uint32_t offset)
 {
 	Ctlr *ctlr;
-	char *p, *s;
+	int8_t *p, *s;
 	int i, l, r;
-	uvlong tuvl, ruvl;
+	uint64_t tuvl, ruvl;
 
 	ctlr = edev->ctlr;
 	qlock(&ctlr->slock);
@@ -612,10 +612,10 @@ igbeifstat(Ether* edev, void* a, long n, ulong offset)
 		case Torl:
 		case Totl:
 			ruvl = r;
-			ruvl += ((uvlong)csr32r(ctlr, Statistics+(i+1)*4))<<32;
+			ruvl += ((uint64_t)csr32r(ctlr, Statistics+(i+1)*4))<<32;
 			tuvl = ruvl;
 			tuvl += ctlr->statistics[i];
-			tuvl += ((uvlong)ctlr->statistics[i+1])<<32;
+			tuvl += ((uint64_t)ctlr->statistics[i+1])<<32;
 			if(tuvl == 0)
 				continue;
 			ctlr->statistics[i] = tuvl;
@@ -679,11 +679,11 @@ static Cmdtab igbectlmsg[] = {
 	CMrdtr,	"rdtr",	2,
 };
 
-static long
-igbectl(Ether* edev, void* buf, long n)
+static int32_t
+igbectl(Ether* edev, void* buf, int32_t n)
 {
 	int v;
-	char *p;
+	int8_t *p;
 	Ctlr *ctlr;
 	Cmdbuf *cb;
 	Cmdtab *ct;
@@ -734,7 +734,7 @@ igbepromiscuous(void* arg, int on)
 }
 
 static void
-igbemulticast(void* arg, uchar* addr, int on)
+igbemulticast(void* arg, uint8_t* addr, int on)
 {
 	int bit, x;
 	Ctlr *ctlr;
@@ -1179,7 +1179,7 @@ igbeattach(Ether* edev)
 {
 	Block *bp;
 	Ctlr *ctlr;
-	char name[KNAMELEN];
+	int8_t name[KNAMELEN];
 
 	ctlr = edev->ctlr;
 	qlock(&ctlr->alock);
@@ -1540,9 +1540,9 @@ igbemii(Ctlr* ctlr)
 }
 
 static int
-at93c46io(Ctlr* ctlr, char* op, int data)
+at93c46io(Ctlr* ctlr, int8_t* op, int data)
 {
-	char *lp, *p;
+	int8_t *lp, *p;
 	int i, loop, eecd, r;
 
 	eecd = csr32r(ctlr, Eecd);
@@ -1617,8 +1617,8 @@ at93c46io(Ctlr* ctlr, char* op, int data)
 static int
 at93c46r(Ctlr* ctlr)
 {
-	ushort sum;
-	char rop[20];
+	uint16_t sum;
+	int8_t rop[20];
 	int addr, areq, bits, data, eecd, i;
 
 	eecd = csr32r(ctlr, Eecd);

+ 50 - 50
sys/src/9/386/etherm10g.c

@@ -40,7 +40,7 @@
 #include "etherm10g4k.i"
 
 static int 	debug		= 0;
-static char	Etimeout[]	= "timeout";
+static int8_t	Etimeout[]	= "timeout";
 
 enum {
 	Epromsz	= 256,
@@ -102,10 +102,10 @@ enum {
 
 typedef union {
 	uint	i[2];
-	uchar	c[8];
+	uint8_t	c[8];
 } Cmd;
 
-typedef ulong Slot;
+typedef uint32_t Slot;
 typedef struct {
 	u16int	cksum;
 	u16int	len;
@@ -123,10 +123,10 @@ typedef struct {
 	u32int	low;
 	u16int	hdroff;
 	u16int	len;
-	uchar	pad;
-	uchar	nrdma;
-	uchar	chkoff;
-	uchar	flags;
+	uint8_t	pad;
+	uint8_t	nrdma;
+	uint8_t	chkoff;
+	uint8_t	flags;
 } Send;
 
 typedef struct {
@@ -171,19 +171,19 @@ typedef struct {
 
 /* dma mapped.  unix network byte order. */
 typedef struct {
-	uchar	txcnt[4];
-	uchar	linkstat[4];
-	uchar	dlink[4];
-	uchar	derror[4];
-	uchar	drunt[4];
-	uchar	doverrun[4];
-	uchar	dnosm[4];
-	uchar	dnobg[4];
-	uchar	nrdma[4];
-	uchar	txstopped;
-	uchar	down;
-	uchar	updated;
-	uchar	valid;
+	uint8_t	txcnt[4];
+	uint8_t	linkstat[4];
+	uint8_t	dlink[4];
+	uint8_t	derror[4];
+	uint8_t	drunt[4];
+	uint8_t	doverrun[4];
+	uint8_t	dnosm[4];
+	uint8_t	dnobg[4];
+	uint8_t	nrdma[4];
+	uint8_t	txstopped;
+	uint8_t	down;
+	uint8_t	updated;
+	uint8_t	valid;
 } Stats;
 
 enum {
@@ -340,7 +340,7 @@ setpcie(Pcidev *p)
 static int
 whichfw(Pcidev *p)
 {
-	char *s;
+	int8_t *s;
 	int i, off, lanes, ecrc;
 	u32int cap;
 
@@ -388,7 +388,7 @@ static int
 parseeprom(Ctlr *c)
 {
 	int i, j, k, l, bits;
-	char *s;
+	int8_t *s;
 
 	dprint("m10g eprom:\n");
 	s = c->eprom;
@@ -416,16 +416,16 @@ static u16int
 pbit16(u16int i)
 {
 	u16int j;
-	uchar *p;
+	uint8_t *p;
 
-	p = (uchar*)&j;
+	p = (uint8_t*)&j;
 	p[1] = i;
 	p[0] = i>>8;
 	return j;
 }
 
 static u16int
-gbit16(uchar i[2])
+gbit16(uint8_t i[2])
 {
 	u16int j;
 
@@ -438,9 +438,9 @@ static u32int
 pbit32(u32int i)
 {
 	u32int j;
-	uchar *p;
+	uint8_t *p;
 
-	p = (uchar*)&j;
+	p = (uint8_t*)&j;
 	p[3] = i;
 	p[2] = i>>8;
 	p[1] = i>>16;
@@ -449,7 +449,7 @@ pbit32(u32int i)
 }
 
 static u32int
-gbit32(uchar i[4])
+gbit32(uint8_t i[4])
 {
 	u32int j;
 
@@ -518,7 +518,7 @@ cmd(Ctlr *c, int type, u64int data)
 }
 
 u32int
-maccmd(Ctlr *c, int type, uchar *m)
+maccmd(Ctlr *c, int type, uint8_t *m)
 {
 	u32int buf[16], i;
 	Cmd *cmd;
@@ -704,13 +704,13 @@ kickthebaby(Pcidev *p, Ctlr *c)
 }
 
 typedef struct {
-	uchar	len[4];
-	uchar	type[4];
-	char	version[128];
-	uchar	globals[4];
-	uchar	ramsz[4];
-	uchar	specs[4];
-	uchar	specssz[4];
+	uint8_t	len[4];
+	uint8_t	type[4];
+	int8_t	version[128];
+	uint8_t	globals[4];
+	uint8_t	ramsz[4];
+	uint8_t	specs[4];
+	uint8_t	specssz[4];
 } Fwhdr;
 
 enum {
@@ -720,7 +720,7 @@ enum {
 	Tmcp0	= 0x4d435030,
 };
 
-static char *
+static int8_t *
 fwtype(u32int type)
 {
 	switch(type){
@@ -889,7 +889,7 @@ smbfree(Block *b)
 {
 	Bpool *p;
 
-	b->rp = b->wp = (uchar*)ROUNDUP((uintptr)b->base, 4*KiB);
+	b->rp = b->wp = (uint8_t*)ROUNDUP((uintptr)b->base, 4*KiB);
  	b->flag &= ~(Bpktck|Btcpck|Budpck|Bipck);
 
 	p = &smpool;
@@ -906,7 +906,7 @@ bgbfree(Block *b)
 {
 	Bpool *p;
 
-	b->rp = b->wp = (uchar*)ROUNDUP((uintptr)b->base, 4*KiB);
+	b->rp = b->wp = (uint8_t*)ROUNDUP((uintptr)b->base, 4*KiB);
  	b->flag &= ~(Bpktck|Btcpck|Budpck|Bipck);
 
 	p = &bgpool;
@@ -1052,7 +1052,7 @@ nextblock(Ctlr *c)
 	k = sp->cksum;
 	s[i] = 0;
 	d->i++;
-	l = gbit16((uchar*)&l);
+	l = gbit16((uint8_t*)&l);
 //dprint("nextb: i=%d l=%d\n", d->i, l);
 	rx = whichrx(c, l);
 	if(rx->i >= rx->cnt){
@@ -1211,7 +1211,7 @@ m10gtransmit(Ether *e)
 {
 	u16int slen;
 	u32int i, cnt, rdma, nseg, count, end, bus, len, segsz;
-	uchar flags;
+	uint8_t flags;
 	Block *b;
 	Ctlr *c;
 	Send *s, *s0, *s0m8;
@@ -1329,7 +1329,7 @@ static void
 m10gattach(Ether *e)
 {
 	Ctlr *c;
-	char name[12];
+	int8_t name[12];
 
 	dprint("m10gattach\n");
 
@@ -1380,11 +1380,11 @@ lstcount(Block *b)
 	return i;
 }
 
-static long
-m10gifstat(Ether *e, void *v, long n, ulong off)
+static int32_t
+m10gifstat(Ether *e, void *v, int32_t n, uint32_t off)
 {
 	int l, lim;
-	char *p;
+	int8_t *p;
 	Ctlr *c;
 	Stats s;
 
@@ -1417,7 +1417,7 @@ m10gifstat(Ether *e, void *v, long n, ulong off)
 		c->tx.cnt, c->tx.n, c->tx.i,
 		c->sm.cnt, c->sm.i, c->sm.pool->n, lstcount(c->sm.pool->head),
 		c->bg.cnt, c->bg.i, c->bg.pool->n, lstcount(c->bg.pool->head),
-		c->tx.segsz, gbit32((uchar*)c->coal));
+		c->tx.segsz, gbit32((uint8_t*)c->coal));
 
 	n = readstr(off, v, n, p);
 	free(p);
@@ -1484,8 +1484,8 @@ static Cmdtab ctab[] = {
 	CMrxring,	"rxring",	1,
 };
 
-static long
-m10gctl(Ether *e, void *v, long n)
+static int32_t
+m10gctl(Ether *e, void *v, int32_t n)
 {
 	int i;
 	Cmdbuf *c;
@@ -1554,10 +1554,10 @@ m10gpromiscuous(void *v, int on)
 }
 
 static int	mcctab[]  = { CSleavemc, CSjoinmc };
-static char	*mcntab[] = { "leave", "join" };
+static int8_t	*mcntab[] = { "leave", "join" };
 
 static void
-m10gmulticast(void *v, uchar *ea, int on)
+m10gmulticast(void *v, uint8_t *ea, int on)
 {
 	Ether *e;
 	int i;

+ 6 - 6
sys/src/9/386/kbd.c

@@ -184,7 +184,7 @@ void (*kbdmouse)(int);
 static int nokbd = 1;
 
 static Lock i8042lock;
-static uchar ccc;
+static uint8_t ccc;
 static void (*auxputc)(int, int);
 
 /*
@@ -225,7 +225,7 @@ inready(void)
 void
 i8042reset(void)
 {
-	ushort *s = KADDR(0x472);
+	uint16_t *s = KADDR(0x472);
 	int i, x;
 
 	if(nokbd)
@@ -289,7 +289,7 @@ i8042auxcmd(int cmd)
 }
 
 int
-i8042auxcmds(uchar *cmd, int ncmd)
+i8042auxcmds(uint8_t *cmd, int ncmd)
 {
 	int i;
 
@@ -500,7 +500,7 @@ i8042intr(Ureg*, void*)
 void
 i8042auxenable(void (*putc)(int, int))
 {
-	char *err = "i8042: aux init failed\n";
+	int8_t *err = "i8042: aux init failed\n";
 
 	/* enable kbd/aux xfers and interrupts */
 	ccc &= ~Cauxdis;
@@ -525,7 +525,7 @@ i8042auxenable(void (*putc)(int, int))
 	iunlock(&i8042lock);
 }
 
-static char *initfailed = "i8042: kbdinit failed\n";
+static int8_t *initfailed = "i8042: kbdinit failed\n";
 
 static int
 outbyte(int port, int c)
@@ -594,7 +594,7 @@ kbdenable(void)
 }
 
 void
-kbdputmap(ushort m, ushort scanc, Rune r)
+kbdputmap(uint16_t m, uint16_t scanc, Rune r)
 {
 	if(scanc >= Nscan)
 		error(Ebadarg);

+ 37 - 37
sys/src/9/386/pci.c

@@ -47,7 +47,7 @@ static Pcidev* pciroot;
 static Pcidev* pcilist;
 static Pcidev* pcitail;
 
-static char* bustypes[] = {
+static int8_t* bustypes[] = {
 	"CBUSI",
 	"CBUSII",
 	"EISA",
@@ -73,7 +73,7 @@ static	int	pcicfgrw(int, int, int, int, int);
 static int
 tbdffmt(Fmt* fmt)
 {
-	char *p;
+	int8_t *p;
 	int l, r;
 	uint type, tbdf;
 
@@ -102,10 +102,10 @@ tbdffmt(Fmt* fmt)
 	return r;
 }
 
-static ulong
+static uint32_t
 pcibarsize(Pcidev *p, int rno)
 {
-	ulong v, size;
+	uint32_t v, size;
 
 	v = pcicfgr32(p, rno);
 	pcicfgw32(p, rno, 0xFFFFFFF0);
@@ -253,10 +253,10 @@ pcilscan(int bno, Pcidev** list)
 	return maxubn;
 }
 
-static uchar 
-pIIxget(Pcidev *router, uchar link)
+static uint8_t 
+pIIxget(Pcidev *router, uint8_t link)
 {
-	uchar pirq;
+	uint8_t pirq;
 
 	/* link should be 0x60, 0x61, 0x62, 0x63 */
 	pirq = pcicfgr8(router, link);
@@ -264,15 +264,15 @@ pIIxget(Pcidev *router, uchar link)
 }
 
 static void 
-pIIxset(Pcidev *router, uchar link, uchar irq)
+pIIxset(Pcidev *router, uint8_t link, uint8_t irq)
 {
 	pcicfgw8(router, link, irq);
 }
 
-static uchar 
-viaget(Pcidev *router, uchar link)
+static uint8_t 
+viaget(Pcidev *router, uint8_t link)
 {
-	uchar pirq;
+	uint8_t pirq;
 
 	/* link should be 1, 2, 3, 5 */
 	pirq = (link < 6)? pcicfgr8(router, 0x55 + (link>>1)): 0;
@@ -281,9 +281,9 @@ viaget(Pcidev *router, uchar link)
 }
 
 static void 
-viaset(Pcidev *router, uchar link, uchar irq)
+viaset(Pcidev *router, uint8_t link, uint8_t irq)
 {
-	uchar pirq;
+	uint8_t pirq;
 
 	pirq = pcicfgr8(router, 0x55 + (link >> 1));
 	pirq &= (link & 1)? 0x0f: 0xf0;
@@ -294,10 +294,10 @@ viaset(Pcidev *router, uchar link, uchar irq)
 typedef struct Bridge Bridge;
 struct Bridge
 {
-	ushort	vid;
-	ushort	did;
-	uchar	(*get)(Pcidev *, uchar);
-	void	(*set)(Pcidev *, uchar, uchar);	
+	uint16_t	vid;
+	uint16_t	did;
+	uint8_t	(*get)(Pcidev *, uint8_t);
+	void	(*set)(Pcidev *, uint8_t, uint8_t);	
 };
 
 static Bridge southbridges[] = {
@@ -312,32 +312,32 @@ static Bridge southbridges[] = {
 
 typedef struct Slot Slot;
 struct Slot {
-	uchar	bus;			// Pci bus number
-	uchar	dev;			// Pci device number
-	uchar	maps[12];		// Avoid structs!  Link and mask.
-	uchar	slot;			// Add-in/built-in slot
-	uchar	reserved;
+	uint8_t	bus;			// Pci bus number
+	uint8_t	dev;			// Pci device number
+	uint8_t	maps[12];		// Avoid structs!  Link and mask.
+	uint8_t	slot;			// Add-in/built-in slot
+	uint8_t	reserved;
 };
 
 typedef struct Router Router;
 struct Router {
-	uchar	signature[4];		// Routing table signature
-	uchar	version[2];		// Version number
-	uchar	size[2];		// Total table size
-	uchar	bus;			// Interrupt router bus number
-	uchar	devfn;			// Router's devfunc
-	uchar	pciirqs[2];		// Exclusive PCI irqs
-	uchar	compat[4];		// Compatible PCI interrupt router
-	uchar	miniport[4];		// Miniport data
-	uchar	reserved[11];
-	uchar	checksum;
+	uint8_t	signature[4];		// Routing table signature
+	uint8_t	version[2];		// Version number
+	uint8_t	size[2];		// Total table size
+	uint8_t	bus;			// Interrupt router bus number
+	uint8_t	devfn;			// Router's devfunc
+	uint8_t	pciirqs[2];		// Exclusive PCI irqs
+	uint8_t	compat[4];		// Compatible PCI interrupt router
+	uint8_t	miniport[4];		// Miniport data
+	uint8_t	reserved[11];
+	uint8_t	checksum;
 };
 
 
 static void
 pcirouting(void)
 {
-	uchar *p, pin, irq, link, *map;
+	uint8_t *p, pin, irq, link, *map;
 	int size, i, fn, tbdf;
 	Bridge *southbridge;
 	Pcidev *sbpci, *pci;
@@ -345,11 +345,11 @@ pcirouting(void)
 	Slot *e;
 
 	// Search for PCI interrupt routing table in BIOS
-	for(p = (uchar *)KADDR(0xf0000); p < (uchar *)KADDR(0xfffff); p += 16)
+	for(p = (uint8_t *)KADDR(0xf0000); p < (uint8_t *)KADDR(0xfffff); p += 16)
 		if(p[0] == '$' && p[1] == 'P' && p[2] == 'I' && p[3] == 'R')
 			break;
 
-	if(p >= (uchar *)KADDR(0xfffff))
+	if(p >= (uint8_t *)KADDR(0xfffff))
 		return;
 
 	r = (Router *)p;
@@ -379,11 +379,11 @@ pcirouting(void)
 		return;
 
 	size = (r->size[1] << 8)|r->size[0];
-	for(e = (Slot *)&r[1]; (uchar *)e < p + size; e++) {
+	for(e = (Slot *)&r[1]; (uint8_t *)e < p + size; e++) {
 		if(0){
 			print("%.2ux/%.2ux %.2ux: ", e->bus, e->dev, e->slot);
 			for (i = 0; i != 4; i++) {
-				uchar *m = &e->maps[i * 3];
+				uint8_t *m = &e->maps[i * 3];
 				print("[%d] %.2ux %.4ux ",
 					i, m[0], (m[2] << 8)|m[1]);
 			}

+ 4 - 4
sys/src/9/386/random.c

@@ -101,11 +101,11 @@ randominit(void)
 /*
  *  consume random bytes from a circular buffer
  */
-ulong
-randomread(void *xp, ulong n)
+uint32_t
+randomread(void *xp, uint32_t n)
 {
-	uchar *e, *p;
-	ulong x;
+	uint8_t *e, *p;
+	uint32_t x;
 
 	p = xp;
 

+ 7 - 7
sys/src/9/386/uarti8250.c

@@ -162,12 +162,12 @@ static Uart i8250uart[2] = {
 #define csr8w(c, r, v)	outb((c)->io+(r), (c)->sticky[(r)]|(v))
 #define csr8o(c, r, v)	outb((c)->io+(r), (v))
 
-static long
-i8250status(Uart* uart, void* buf, long n, long offset)
+static int32_t
+i8250status(Uart* uart, void* buf, int32_t n, int32_t offset)
 {
-	char *p;
+	int8_t *p;
 	Ctlr *ctlr;
-	uchar ier, lcr, mcr, msr;
+	uint8_t ier, lcr, mcr, msr;
 
 	ctlr = uart->regs;
 	p = malloc(READSTR);
@@ -404,7 +404,7 @@ i8250bits(Uart* uart, int bits)
 static int
 i8250baud(Uart* uart, int baud)
 {
-	ulong bgc;
+	uint32_t bgc;
 	Ctlr *ctlr;
 
 	/*
@@ -740,12 +740,12 @@ PhysUart i8250physuart = {
 };
 
 Uart*
-i8250console(char* cfg)
+i8250console(int8_t* cfg)
 {
 	int i;
 	Uart *uart;
 	Ctlr *ctlr;
-	char *cmd, *p;
+	int8_t *cmd, *p;
 
 	/*
 	 * Before i8250pnp() is run can only set the console

+ 3 - 3
sys/src/9/386/uartpci.c

@@ -20,11 +20,11 @@ extern PhysUart pciphysuart;
 extern void* i8250alloc(int, int, int);
 
 static Uart*
-uartpci(int ctlrno, Pcidev* p, int barno, int n, int freq, char* name)
+uartpci(int ctlrno, Pcidev* p, int barno, int n, int freq, int8_t* name)
 {
 	int i, io;
 	void *ctlr;
-	char buf[64];
+	int8_t buf[64];
 	Uart *head, *uart;
 
 	io = p->mem[barno].bar & ~0x01;
@@ -59,7 +59,7 @@ static Uart*
 uartpcipnp(void)
 {
 	Pcidev *p;
-	char *name;
+	int8_t *name;
 	int ctlrno, n, subid;
 	Uart *head, *tail, *uart;
 

+ 15 - 15
sys/src/9/boot/aux.c

@@ -52,7 +52,7 @@ plumb(char *dir, char *dest, int *efd, char *here)
  */
 
 int
-sendmsg(int fd, char *msg)
+sendmsg(int fd, int8_t *msg)
 {
 	int n;
 
@@ -63,9 +63,9 @@ sendmsg(int fd, char *msg)
 }
 
 void
-warning(char *s)
+warning(int8_t *s)
 {
-	char buf[ERRMAX];
+	int8_t buf[ERRMAX];
 
 	buf[0] = '\0';
 	errstr(buf, sizeof buf);
@@ -73,9 +73,9 @@ warning(char *s)
 }
 
 void
-fatal(char *s)
+fatal(int8_t *s)
 {
-	char buf[ERRMAX];
+	int8_t buf[ERRMAX];
 
 	buf[0] = '\0';
 	errstr(buf, sizeof buf);
@@ -84,7 +84,7 @@ fatal(char *s)
 }
 
 int
-readfile(char *name, char *buf, int len)
+readfile(int8_t *name, int8_t *buf, int len)
 {
 	int f, n;
 
@@ -100,7 +100,7 @@ readfile(char *name, char *buf, int len)
 }
 
 int
-writefile(char *name, char *buf, int len)
+writefile(int8_t *name, int8_t *buf, int len)
 {
 	int f, n;
 
@@ -113,10 +113,10 @@ writefile(char *name, char *buf, int len)
 }
 
 void
-setenv(char *name, char *val)
+setenv(int8_t *name, int8_t *val)
 {
 	int f;
-	char ename[64];
+	int8_t ename[64];
 
 	snprint(ename, sizeof ename, "#e/%s", name);
 	f = create(ename, 1, 0666);
@@ -129,11 +129,11 @@ setenv(char *name, char *val)
 }
 
 void
-srvcreate(char *name, int fd)
+srvcreate(int8_t *name, int fd)
 {
-	char *srvname;
+	int8_t *srvname;
 	int f;
-	char buf[64];
+	int8_t buf[64];
 
 	srvname = strrchr(name, '/');
 	if(srvname)
@@ -152,7 +152,7 @@ srvcreate(char *name, int fd)
 }
 
 void
-catchint(void *a, char *note)
+catchint(void *a, int8_t *note)
 {
 	USED(a);
 	if(strcmp(note, "alarm") == 0)
@@ -161,10 +161,10 @@ catchint(void *a, char *note)
 }
 
 int
-outin(char *prompt, char *def, int len)
+outin(int8_t *prompt, int8_t *def, int len)
 {
 	int n;
-	char buf[256];
+	int8_t buf[256];
 
 	if(len >= sizeof buf)
 		len = sizeof(buf)-1;

+ 13 - 13
sys/src/9/boot/boot.c

@@ -13,19 +13,19 @@
 #include <fcall.h>
 #include "../boot/boot.h"
 
-char	cputype[64];
-char	sys[2*64];
-char 	reply[256];
+int8_t	cputype[64];
+int8_t	sys[2*64];
+int8_t 	reply[256];
 int	printcol;
 int	mflag;
 int	fflag;
 int	kflag;
 
-char	*bargv[Nbarg];
+int8_t	*bargv[Nbarg];
 int	bargc;
 
 static void	swapproc(void);
-static Method	*rootserver(char*);
+static Method	*rootserver(int8_t*);
 static void	usbinit(void);
 static void	kbmap(void);
 
@@ -190,11 +190,11 @@ print("\n");
 }
 
 static Method*
-findmethod(char *a)
+findmethod(int8_t *a)
 {
 	Method *mp;
 	int i, j;
-	char *cp;
+	int8_t *cp;
 
 	if((i = strlen(a)) == 0)
 		return nil;
@@ -217,11 +217,11 @@ findmethod(char *a)
  *  ask user from whence cometh the root file system
  */
 static Method*
-rootserver(char *arg)
+rootserver(int8_t *arg)
 {
-	char prompt[256];
+	int8_t prompt[256];
 	Method *mp;
-	char *cp;
+	int8_t *cp;
 	int n;
 
 	/* look for required reply */
@@ -313,7 +313,7 @@ old9p(int fd)
 static void
 usbinit(void)
 {
-	static char usbd[] = "/boot/usbd";
+	static int8_t usbd[] = "/boot/usbd";
 
 	if(access("#u/usb/ctl", 0) >= 0 && bind("#u", "/dev", MAFTER) >= 0 &&
 	    access(usbd, AEXIST) >= 0)
@@ -323,9 +323,9 @@ usbinit(void)
 static void
 kbmap(void)
 {
-	char *f;
+	int8_t *f;
 	int n, in, out;
-	char buf[1024];
+	int8_t buf[1024];
 
 	f = getenv("kbmap");
 	if(f == nil)

+ 3 - 3
sys/src/9/boot/bootauth.c

@@ -13,13 +13,13 @@
 #include <fcall.h>
 #include "../boot/boot.h"
 
-char	*authaddr;
+int8_t	*authaddr;
 static void glenda(void);
 
 void
 authentication(int cpuflag)
 {
-	char *argv[16], **av;
+	int8_t *argv[16], **av;
 	int ac;
 
 	if(access("/boot/factotum", AEXEC) < 0){
@@ -67,7 +67,7 @@ static void
 glenda(void)
 {
 	int fd;
-	char *s;
+	int8_t *s;
 
 	s = getenv("user");
 	if(s == nil)

+ 2 - 2
sys/src/9/boot/bootcache.c

@@ -11,13 +11,13 @@
 #include <libc.h>
 #include <../boot/boot.h>
 
-uchar statbuf[Statsz];
+uint8_t statbuf[Statsz];
 
 int
 cache(int fd)
 {
 	int argc, i, p[2];
-	char *argv[5], bd[32], buf[256], partition[64], *pp;
+	int8_t *argv[5], bd[32], buf[256], partition[64], *pp;
 
 	if(stat("/boot/cfs", statbuf, sizeof statbuf) < 0)
 		return fd;

+ 15 - 15
sys/src/9/boot/bootip.c

@@ -13,13 +13,13 @@
 
 #include "boot.h"
 
-static	uchar	fsip[IPaddrlen];
-	uchar	auip[IPaddrlen];
-static	char	mpoint[32];
+static	uint8_t	fsip[IPaddrlen];
+	uint8_t	auip[IPaddrlen];
+static	int8_t	mpoint[32];
 
-static int isvalidip(uchar*);
-static void netndb(char*, uchar*);
-static void netenv(char*, uchar*);
+static int isvalidip(uint8_t*);
+static void netndb(int8_t*, uint8_t*);
+static void netenv(int8_t*, uint8_t*);
 
 
 void
@@ -121,9 +121,9 @@ print("ipconfig...");
 }
 
 static void
-setauthaddr(char *proto, int port)
+setauthaddr(int8_t *proto, int port)
 {
-	char buf[128];
+	int8_t buf[128];
 
 	snprint(buf, sizeof buf, "%s!%I!%d", proto, auip, port);
 	authaddr = strdup(buf);
@@ -140,7 +140,7 @@ int
 connecttcp(void)
 {
 	int fd;
-	char buf[64];
+	int8_t buf[64];
 
 	snprint(buf, sizeof buf, "tcp!%I!564", fsip);
 	fd = dial(buf, 0, 0, 0);
@@ -150,7 +150,7 @@ connecttcp(void)
 }
 
 static int
-isvalidip(uchar *ip)
+isvalidip(uint8_t *ip)
 {
 	if(ipcmp(ip, IPnoaddr) == 0)
 		return 0;
@@ -160,10 +160,10 @@ isvalidip(uchar *ip)
 }
 
 static void
-netenv(char *attr, uchar *ip)
+netenv(int8_t *attr, uint8_t *ip)
 {
 	int fd, n;
-	char buf[128];
+	int8_t buf[128];
 
 	ipmove(ip, IPnoaddr);
 	snprint(buf, sizeof(buf), "#e/%s", attr);
@@ -180,11 +180,11 @@ netenv(char *attr, uchar *ip)
 }
 
 static void
-netndb(char *attr, uchar *ip)
+netndb(int8_t *attr, uint8_t *ip)
 {
 	int fd, n, c;
-	char buf[1024];
-	char *p;
+	int8_t buf[1024];
+	int8_t *p;
 
 	ipmove(ip, IPnoaddr);
 	snprint(buf, sizeof(buf), "%s/ndb", mpoint);

+ 18 - 18
sys/src/9/boot/doauthenticate.c

@@ -12,14 +12,14 @@
 #include <auth.h>
 #include "../boot/boot.h"
 
-static char *pbmsg = "AS protocol botch";
-static char *ccmsg = "can't connect to AS";
+static int8_t *pbmsg = "AS protocol botch";
+static int8_t *ccmsg = "can't connect to AS";
 
-long
-readn(int fd, void *buf, long len)
+int32_t
+readn(int fd, void *buf, int32_t len)
 {
 	int m, n;
-	char *p;
+	int8_t *p;
 
 	p = buf;
 	for(n = 0; n < len; n += m){
@@ -30,13 +30,13 @@ readn(int fd, void *buf, long len)
 	return n;
 }
 
-static char*
-fromauth(Method *mp, char *trbuf, char *tbuf)
+static int8_t*
+fromauth(Method *mp, int8_t *trbuf, int8_t *tbuf)
 {
 	int afd;
-	char t;
-	char *msg;
-	static char error[2*ERRMAX];
+	int8_t t;
+	int8_t *msg;
+	static int8_t error[2*ERRMAX];
 
 	if(mp->auth == 0)
 		fatal("no method for accessing auth server");
@@ -81,9 +81,9 @@ fromauth(Method *mp, char *trbuf, char *tbuf)
 void
 doauthenticate(int fd, Method *mp)
 {
-	char *msg;
-	char trbuf[TICKREQLEN];
-	char tbuf[2*TICKETLEN];
+	int8_t *msg;
+	int8_t trbuf[TICKREQLEN];
+	int8_t tbuf[2*TICKETLEN];
 
 	print("session...");
 	if(fsession(fd, trbuf, sizeof trbuf) < 0)
@@ -106,14 +106,14 @@ doauthenticate(int fd, Method *mp)
 	fprint(2, "no authentication server (%s), using your key as server key\n", msg);
 }
 
-char*
-checkkey(Method *mp, char *name, char *key)
+int8_t*
+checkkey(Method *mp, int8_t *name, int8_t *key)
 {
-	char *msg;
+	int8_t *msg;
 	Ticketreq tr;
 	Ticket t;
-	char trbuf[TICKREQLEN];
-	char tbuf[TICKETLEN];
+	int8_t trbuf[TICKREQLEN];
+	int8_t tbuf[TICKETLEN];
 
 	memset(&tr, 0, sizeof tr);
 	tr.type = AuthTreq;

+ 3 - 3
sys/src/9/boot/embed.c

@@ -11,7 +11,7 @@
 #include <libc.h>
 #include <../boot/boot.h>
 
-static char *paqfile;
+static int8_t *paqfile;
 
 void
 configembed(Method *m)
@@ -35,7 +35,7 @@ connectembed(void)
 {
 	int i, p[2];
 	Dir *dir;
-	char **arg, **argp;
+	int8_t **arg, **argp;
 
 	dir = dirstat("/boot/paqfs");
 	if(dir == nil)
@@ -58,7 +58,7 @@ connectembed(void)
 	case -1:
 		fatal("fork");
 	case 0:
-		arg = malloc((bargc+5)*sizeof(char*));
+		arg = malloc((bargc+5)*sizeof(int8_t*));
 		argp = arg;
 		*argp++ = "/boot/paqfs";
 		*argp++ = "-iv";

+ 2 - 2
sys/src/9/boot/getpasswd.c

@@ -12,9 +12,9 @@
 #include <../boot/boot.h>
 
 void
-getpasswd(char *p, int len)
+getpasswd(int8_t *p, int len)
 {
-	char c;
+	int8_t c;
 	int i, n, fd;
 
 	fd = open("#c/consctl", OWRITE);

+ 13 - 13
sys/src/9/boot/local.c

@@ -11,14 +11,14 @@
 #include <libc.h>
 #include <../boot/boot.h>
 
-static char diskname[64];
-static char *disk;
-static char **args;
+static int8_t diskname[64];
+static int8_t *disk;
+static int8_t **args;
 
 void
 configlocal(Method *mp)
 {
-	char *p;
+	int8_t *p;
 	int n;
 
 	if(*sys == '/' || *sys == '#'){
@@ -61,9 +61,9 @@ int
 connectlocalkfs(void)
 {
 	int i, pid, fd, p[2];
-	char partition[64];
-	char *dev;
-	char **arg, **argp;
+	int8_t partition[64];
+	int8_t *dev;
+	int8_t **arg, **argp;
 	Dir *d;
 
 	if(stat("/boot/kfs", statbuf, sizeof statbuf) < 0)
@@ -108,7 +108,7 @@ connectlocalkfs(void)
 	case -1:
 		fatal("fork");
 	case 0:
-		arg = malloc((bargc+5)*sizeof(char*));
+		arg = malloc((bargc+5)*sizeof(int8_t*));
 		argp = arg;
 		*argp++ = "kfs";
 		*argp++ = "-f";
@@ -139,7 +139,7 @@ connectlocalkfs(void)
 }
 
 void
-run(char *file, ...)
+run(int8_t *file, ...)
 {
 	int i, pid;
 
@@ -158,7 +158,7 @@ run(char *file, ...)
 }
 
 static int
-print1(int fd, char *s)
+print1(int fd, int8_t *s)
 {
 	return write(fd, s, strlen(s));
 }
@@ -182,10 +182,10 @@ int
 connectlocalfossil(void)
 {
 	int fd;
-	char *venti, *f[32], *p;
+	int8_t *venti, *f[32], *p;
 	int nf;
-	char partition[128], buf[512];
-	char *dev;
+	int8_t partition[128], buf[512];
+	int8_t *dev;
 
 	if(stat("/boot/fossil", statbuf, sizeof statbuf) < 0)
 		return -1;

+ 1 - 1
sys/src/9/boot/nopsession.c

@@ -19,7 +19,7 @@ static void
 rpc(int fd, int type)
 {
 	int n, l;
-	char buf[128], *p;
+	int8_t buf[128], *p;
 
 	hdr.type = type;
 	hdr.tag = NOTAG;

+ 3 - 3
sys/src/9/boot/paq.c

@@ -11,7 +11,7 @@
 #include <libc.h>
 #include <../boot/boot.h>
 
-char *fparts[] =
+int8_t *fparts[] =
 {
 	"add bootldr	0x0000000 0x0040000",
 	"add params	0x0040000 0x0080000",
@@ -43,7 +43,7 @@ int
 connectpaq(void)
 {
 	int  p[2];
-	char **arg, **argp;
+	int8_t **arg, **argp;
 
 	print("paq...");
 	if(pipe(p)<0)
@@ -52,7 +52,7 @@ connectpaq(void)
 	case -1:
 		fatal("fork");
 	case 0:
-		arg = malloc(10*sizeof(char*));
+		arg = malloc(10*sizeof(int8_t*));
 		argp = arg;
 		*argp++ = "paqfs";
 		*argp++ = "-v";

+ 1 - 1
sys/src/9/boot/sac.c

@@ -20,7 +20,7 @@ void
 configsac(Method *mp)
 {
 	int fd;
-	char cmd[64];
+	int8_t cmd[64];
 
 	USED(mp);
 

+ 10 - 10
sys/src/9/boot/settime.c

@@ -13,17 +13,17 @@
 #include <fcall.h>
 #include "../boot/boot.h"
 
-static long lusertime(char*);
+static int32_t lusertime(int8_t*);
 
-char *timeserver = "#s/boot";
+int8_t *timeserver = "#s/boot";
 
 void
-settime(int islocal, int afd, char *rp)
+settime(int islocal, int afd, int8_t *rp)
 {
 	int n, f;
 	int timeset;
 	Dir dir[2];
-	char timebuf[64];
+	int8_t timebuf[64];
 
 	print("time...");
 	timeset = 0;
@@ -58,7 +58,7 @@ settime(int islocal, int afd, char *rp)
 		close(f);
 		if(stat("/tmp", statbuf, sizeof statbuf) < 0)
 			fatal("stat");
-		convM2D(statbuf, sizeof statbuf, &dir[0], (char*)&dir[1]);
+		convM2D(statbuf, sizeof statbuf, &dir[0], (int8_t*)&dir[1]);
 		sprint(timebuf, "%ld", dir[0].atime);
 		unmount(0, "/tmp");
 	}
@@ -75,7 +75,7 @@ settime(int islocal, int afd, char *rp)
 #define SEC2DAY (24L*SEC2HOUR)
 
 int
-g2(char **pp)
+g2(int8_t **pp)
 {
 	int v;
 
@@ -112,11 +112,11 @@ yrsize(int y)
 /*
  *  compute seconds since Jan 1 1970
  */
-static long
-lusertime(char *argbuf)
+static int32_t
+lusertime(int8_t *argbuf)
 {
-	char *buf;
-	ulong secs;
+	int8_t *buf;
+	uint32_t secs;
 	int i, y, m;
 	int *d2m;
 

+ 20 - 18
sys/src/9/ip/arp.c

@@ -30,7 +30,7 @@ enum
 	AWAIT		= 2,
 };
 
-char *arpstate[] =
+int8_t *arpstate[] =
 {
 	"UNUSED",
 	"OK",
@@ -52,7 +52,7 @@ struct Arp
 	Block 	*dropf, *dropl;
 };
 
-char *Ebadarp = "bad arp";
+int8_t *Ebadarp = "bad arp";
 
 #define haship(s) ((s)[IPaddrlen-1]%NHASH)
 
@@ -73,7 +73,7 @@ arpinit(Fs *f)
  *  create a new arp entry for an ip address.
  */
 static Arpent*
-newarp6(Arp *arp, uchar *ip, Ipifc *ifc, int addrxt)
+newarp6(Arp *arp, uint8_t *ip, Ipifc *ifc, int addrxt)
 {
 	uint t;
 	Block *next, *xp;
@@ -211,12 +211,13 @@ cleanarpent(Arp *arp, Arpent *a)
  *  waiting for ip->mac to be resolved.
  */
 Arpent*
-arpget(Arp *arp, Block *bp, int version, Ipifc *ifc, uchar *ip, uchar *mac)
+arpget(Arp *arp, Block *bp, int version, Ipifc *ifc, uint8_t *ip,
+       uint8_t *mac)
 {
 	int hash;
 	Arpent *a;
 	Medium *type;
-	uchar v6ip[IPaddrlen];
+	uint8_t v6ip[IPaddrlen];
 
 	if(version == V4){
 		v4tov6(v6ip, ip);
@@ -275,7 +276,7 @@ arprelease(Arp *arp, Arpent*)
  * called with arp locked
  */
 Block*
-arpresolve(Arp *arp, Arpent *a, Medium *type, uchar *mac)
+arpresolve(Arp *arp, Arpent *a, Medium *type, uint8_t *mac)
 {
 	Block *bp;
 	Arpent *f, **l;
@@ -303,7 +304,8 @@ arpresolve(Arp *arp, Arpent *a, Medium *type, uchar *mac)
 }
 
 void
-arpenter(Fs *fs, int version, uchar *ip, uchar *mac, int n, int refresh)
+arpenter(Fs *fs, int version, uint8_t *ip, uint8_t *mac, int n,
+	 int refresh)
 {
 	Arp *arp;
 	Route *r;
@@ -311,7 +313,7 @@ arpenter(Fs *fs, int version, uchar *ip, uchar *mac, int n, int refresh)
 	Ipifc *ifc;
 	Medium *type;
 	Block *bp, *next;
-	uchar v6ip[IPaddrlen];
+	uint8_t v6ip[IPaddrlen];
 
 	arp = fs->arp;
 
@@ -407,7 +409,7 @@ arpenter(Fs *fs, int version, uchar *ip, uchar *mac, int n, int refresh)
 }
 
 int
-arpwrite(Fs *fs, char *s, int len)
+arpwrite(Fs *fs, int8_t *s, int len)
 {
 	int n;
 	Route *r;
@@ -415,8 +417,8 @@ arpwrite(Fs *fs, char *s, int len)
 	Block *bp;
 	Arpent *a, *fl, **l;
 	Medium *type;
-	char *f[4], buf[256];
-	uchar ip[IPaddrlen], mac[MAClen];
+	int8_t *f[4], buf[256];
+	uint8_t ip[IPaddrlen], mac[MAClen];
 
 	arp = fs->arp;
 
@@ -525,21 +527,21 @@ enum
 	Alinelen=	90,
 };
 
-char *aformat = "%-6.6s %-8.8s %-40.40I %-32.32s\n";
+int8_t *aformat = "%-6.6s %-8.8s %-40.40I %-32.32s\n";
 
 static void
-convmac(char *p, uchar *mac, int n)
+convmac(int8_t *p, uint8_t *mac, int n)
 {
 	while(n-- > 0)
 		p += sprint(p, "%2.2ux", *mac++);
 }
 
 int
-arpread(Arp *arp, char *p, ulong offset, int len)
+arpread(Arp *arp, int8_t *p, uint32_t offset, int len)
 {
 	Arpent *a;
 	int n;
-	char mac[2*MAClen+1];
+	int8_t mac[2*MAClen+1];
 
 	if(offset % Alinelen)
 		return 0;
@@ -572,9 +574,9 @@ rxmitsols(Arp *arp)
 	Block *next, *xp;
 	Arpent *a, *b, **l;
 	Fs *f;
-	uchar ipsrc[IPaddrlen];
+	uint8_t ipsrc[IPaddrlen];
 	Ipifc *ifc = nil;
-	long nrxt;
+	int32_t nrxt;
 
 	qlock(arp);
 	f = arp->f;
@@ -670,7 +672,7 @@ static void
 rxmitproc(void *v)
 {
 	Arp *arp = v;
-	long wakeupat;
+	int32_t wakeupat;
 
 	arp->rxmitp = up;
 	//print("arp rxmitproc started\n");

+ 14 - 14
sys/src/9/ip/chandial.c

@@ -16,8 +16,8 @@
 #include	"../ip/ip.h"
 
 typedef struct DS DS;
-static Chan*	call(char*, char*, DS*);
-static void	_dial_string_parse(char*, DS*);
+static Chan*	call(int8_t*, int8_t*, DS*);
+static void	_dial_string_parse(int8_t*, DS*);
 
 enum
 {
@@ -26,12 +26,12 @@ enum
 
 struct DS
 {
-	char	buf[Maxstring];			/* dist string */
-	char	*netdir;
-	char	*proto;
-	char	*rem;
-	char	*local;				/* other args */
-	char	*dir;
+	int8_t	buf[Maxstring];			/* dist string */
+	int8_t	*netdir;
+	int8_t	*proto;
+	int8_t	*rem;
+	int8_t	*local;				/* other args */
+	int8_t	*dir;
 	Chan	**ctlp;
 };
 
@@ -39,10 +39,10 @@ struct DS
  *  the dialstring is of the form '[/net/]proto!dest'
  */
 Chan*
-chandial(char *dest, char *local, char *dir, Chan **ctlp)
+chandial(int8_t *dest, int8_t *local, int8_t *dir, Chan **ctlp)
 {
 	DS ds;
-	char clone[Maxpath];
+	int8_t clone[Maxpath];
 
 	ds.local = local;
 	ds.dir = dir;
@@ -58,11 +58,11 @@ chandial(char *dest, char *local, char *dir, Chan **ctlp)
 }
 
 static Chan*
-call(char *clone, char *dest, DS *ds)
+call(int8_t *clone, int8_t *dest, DS *ds)
 {
 	int n;
 	Chan *dchan, *cchan;
-	char name[Maxpath], data[Maxpath], *p;
+	int8_t name[Maxpath], data[Maxpath], *p;
 
 	cchan = namec(clone, Aopen, ORDWR, 0);
 
@@ -104,9 +104,9 @@ call(char *clone, char *dest, DS *ds)
  *  parse a dial string
  */
 static void
-_dial_string_parse(char *str, DS *ds)
+_dial_string_parse(int8_t *str, DS *ds)
 {
-	char *p, *p2;
+	int8_t *p, *p2;
 
 	strncpy(ds->buf, str, Maxstring);
 	ds->buf[Maxstring-1] = 0;

+ 58 - 57
sys/src/9/ip/devip.c

@@ -58,7 +58,7 @@ enum
 #define PROTO(x) 	( (((ulong)(x).path) >> Shiftproto) & Maskproto )
 #define QID(p, c, y) 	( ((p)<<(Shiftproto)) | ((c)<<Shiftconv) | (y) )
 
-static char network[] = "network";
+static int8_t network[] = "network";
 
 QLock	fslock;
 Fs	*ipfs[Nfs];	/* attached fs's */
@@ -66,14 +66,14 @@ Queue	*qlog;
 
 extern	void nullmediumlink(void);
 extern	void pktmediumlink(void);
-	long ndbwrite(Fs *f, char *a, ulong off, int n);
+	int32_t ndbwrite(Fs *f, int8_t *a, uint32_t off, int n);
 
 static int
 ip3gen(Chan *c, int i, Dir *dp)
 {
 	Qid q;
 	Conv *cv;
-	char *p;
+	int8_t *p;
 
 	cv = ipfs[c->devno]->p[PROTO(c->qid)]->conv[CONV(c->qid)];
 	if(cv->owner == nil)
@@ -136,11 +136,11 @@ static int
 ip1gen(Chan *c, int i, Dir *dp)
 {
 	Qid q;
-	char *p;
+	int8_t *p;
 	int prot;
 	int len = 0;
 	Fs *f;
-	extern ulong	kerndate;
+	extern uint32_t	kerndate;
 
 	f = ipfs[c->devno];
 
@@ -180,7 +180,7 @@ ip1gen(Chan *c, int i, Dir *dp)
 }
 
 static int
-ipgen(Chan *c, char*, Dirtab*, int, int s, Dir *dp)
+ipgen(Chan *c, int8_t*, Dirtab*, int, int s, Dir *dp)
 {
 	Qid q;
 	Conv *cv;
@@ -292,7 +292,7 @@ ipgetfs(int dev)
 }
 
 IPaux*
-newipaux(char *owner, char *tag)
+newipaux(int8_t *owner, int8_t *tag)
 {
 	IPaux *a;
 	int n;
@@ -310,7 +310,7 @@ newipaux(char *owner, char *tag)
 #define ATTACHER(c) (((IPaux*)((c)->aux))->owner)
 
 static Chan*
-ipattach(char* spec)
+ipattach(int8_t* spec)
 {
 	Chan *c;
 	int devno;
@@ -330,7 +330,7 @@ ipattach(char* spec)
 }
 
 static Walkqid*
-ipwalk(Chan* c, Chan *nc, char **name, int nname)
+ipwalk(Chan* c, Chan *nc, int8_t **name, int nname)
 {
 	IPaux *a = c->aux;
 	Walkqid* w;
@@ -341,8 +341,8 @@ ipwalk(Chan* c, Chan *nc, char **name, int nname)
 	return w;
 }
 
-static long
-ipstat(Chan* c, uchar* db, long n)
+static int32_t
+ipstat(Chan* c, uint8_t* db, int32_t n)
 {
 	return devstat(c, db, n, nil, 0, ipgen);
 }
@@ -515,7 +515,7 @@ ipopen(Chan* c, int omode)
 }
 
 static void
-ipcreate(Chan*, char*, int, int)
+ipcreate(Chan*, int8_t*, int, int)
 {
 	error(Eperm);
 }
@@ -526,8 +526,8 @@ ipremove(Chan*)
 	error(Eperm);
 }
 
-static long
-ipwstat(Chan *c, uchar *dp, long n)
+static int32_t
+ipwstat(Chan *c, uint8_t *dp, int32_t n)
 {
 	Dir d;
 	Conv *cv;
@@ -623,13 +623,13 @@ enum
 	Statelen=	32*1024,
 };
 
-static long
-ipread(Chan *ch, void *a, long n, vlong off)
+static int32_t
+ipread(Chan *ch, void *a, int32_t n, int64_t off)
 {
 	Conv *c;
 	Proto *x;
-	char *buf, *p;
-	long offset, rv;
+	int8_t *buf, *p;
+	int32_t offset, rv;
 	Fs *f;
 
 	f = ipfs[ch->devno];
@@ -715,7 +715,7 @@ ipread(Chan *ch, void *a, long n, vlong off)
 }
 
 static Block*
-ipbread(Chan* ch, long n, vlong offset)
+ipbread(Chan* ch, int32_t n, int64_t offset)
 {
 	Conv *c;
 	Proto *x;
@@ -744,7 +744,7 @@ setladdr(Conv* c)
 /*
  *  set a local port making sure the quad of raddr,rport,laddr,lport is unique
  */
-char*
+int8_t*
 setluniqueport(Conv* c, int lport)
 {
 	Proto *p;
@@ -782,7 +782,7 @@ void
 setlport(Conv* c)
 {
 	Proto *p;
-	ushort *pp;
+	uint16_t *pp;
 	int x, found;
 
 	p = c->p;
@@ -827,13 +827,13 @@ setlport(Conv* c)
  *  set a local address and port from a string of the form
  *	[address!]port[!r]
  */
-char*
-setladdrport(Conv* c, char* str, int announcing)
+int8_t*
+setladdrport(Conv* c, int8_t* str, int announcing)
 {
-	char *p;
-	char *rv;
-	ushort lport;
-	uchar addr[IPaddrlen];
+	int8_t *p;
+	int8_t *rv;
+	uint16_t lport;
+	uint8_t addr[IPaddrlen];
 
 	rv = nil;
 
@@ -882,10 +882,10 @@ setladdrport(Conv* c, char* str, int announcing)
 	return rv;
 }
 
-static char*
-setraddrport(Conv* c, char* str)
+static int8_t*
+setraddrport(Conv* c, int8_t* str)
 {
-	char *p;
+	int8_t *p;
 
 	p = strchr(str, '!');
 	if(p == nil)
@@ -904,10 +904,10 @@ setraddrport(Conv* c, char* str)
 /*
  *  called by protocol connect routine to set addresses
  */
-char*
-Fsstdconnect(Conv *c, char *argv[], int argc)
+int8_t*
+Fsstdconnect(Conv *c, int8_t *argv[], int argc)
 {
-	char *p;
+	int8_t *p;
 
 	switch(argc) {
 	default:
@@ -948,7 +948,7 @@ connected(void* a)
 static void
 connectctlmsg(Proto *x, Conv *c, Cmdbuf *cb)
 {
-	char *p;
+	int8_t *p;
 
 	if(c->state != 0)
 		error(Econinuse);
@@ -976,8 +976,8 @@ connectctlmsg(Proto *x, Conv *c, Cmdbuf *cb)
 /*
  *  called by protocol announce routine to set addresses
  */
-char*
-Fsstdannounce(Conv* c, char* argv[], int argc)
+int8_t*
+Fsstdannounce(Conv* c, int8_t* argv[], int argc)
 {
 	memset(c->raddr, 0, sizeof(c->raddr));
 	c->rport = 0;
@@ -1001,7 +1001,7 @@ announced(void* a)
 static void
 announcectlmsg(Proto *x, Conv *c, Cmdbuf *cb)
 {
-	char *p;
+	int8_t *p;
 
 	if(c->state != 0)
 		error(Econinuse);
@@ -1029,8 +1029,8 @@ announcectlmsg(Proto *x, Conv *c, Cmdbuf *cb)
 /*
  *  called by protocol bind routine to set addresses
  */
-char*
-Fsstdbind(Conv* c, char* argv[], int argc)
+int8_t*
+Fsstdbind(Conv* c, int8_t* argv[], int argc)
 {
 	switch(argc){
 	default:
@@ -1044,7 +1044,7 @@ Fsstdbind(Conv* c, char* argv[], int argc)
 static void
 bindctlmsg(Proto *x, Conv *c, Cmdbuf *cb)
 {
-	char *p;
+	int8_t *p;
 
 	if(x->bind == nil)
 		p = Fsstdbind(c, cb->f, cb->nf);
@@ -1072,17 +1072,17 @@ ttlctlmsg(Conv *c, Cmdbuf *cb)
 		c->ttl = atoi(cb->f[1]);
 }
 
-static long
-ipwrite(Chan* ch, void *v, long n, vlong off)
+static int32_t
+ipwrite(Chan* ch, void *v, int32_t n, int64_t off)
 {
 	Conv *c;
 	Proto *x;
-	char *p;
+	int8_t *p;
 	Cmdbuf *cb;
-	uchar ia[IPaddrlen], ma[IPaddrlen];
+	uint8_t ia[IPaddrlen], ma[IPaddrlen];
 	Fs *f;
-	char *a;
-	ulong offset = off;
+	int8_t *a;
+	uint32_t offset = off;
 
 	a = v;
 	f = ipfs[ch->devno];
@@ -1169,8 +1169,8 @@ ipwrite(Chan* ch, void *v, long n, vlong off)
 	return n;
 }
 
-static long
-ipbwrite(Chan* ch, Block* bp, vlong offset)
+static int32_t
+ipbwrite(Chan* ch, Block* bp, int64_t offset)
 {
 	Conv *c;
 	Proto *x;
@@ -1250,7 +1250,7 @@ Fsproto(Fs *f, Proto *p)
  *  built in
  */
 int
-Fsbuiltinproto(Fs* f, uchar proto)
+Fsbuiltinproto(Fs* f, uint8_t proto)
 {
 	return f->t2p[proto] != nil;
 }
@@ -1259,7 +1259,7 @@ Fsbuiltinproto(Fs* f, uchar proto)
  *  called with protocol locked
  */
 Conv*
-Fsprotoclone(Proto *p, char *user)
+Fsprotoclone(Proto *p, int8_t *user)
 {
 	Conv *c, **pp, **ep;
 
@@ -1326,7 +1326,7 @@ retry:
 }
 
 int
-Fsconnected(Conv* c, char* msg)
+Fsconnected(Conv* c, int8_t* msg)
 {
 	if(msg != nil && *msg != '\0')
 		strncpy(c->cerr, msg, ERRMAX-1);
@@ -1347,7 +1347,7 @@ Fsconnected(Conv* c, char* msg)
 }
 
 Proto*
-Fsrcvpcol(Fs* f, uchar proto)
+Fsrcvpcol(Fs* f, uint8_t proto)
 {
 	if(f->ipmux)
 		return f->ipmux;
@@ -1356,7 +1356,7 @@ Fsrcvpcol(Fs* f, uchar proto)
 }
 
 Proto*
-Fsrcvpcolx(Fs *f, uchar proto)
+Fsrcvpcolx(Fs *f, uint8_t proto)
 {
 	return f->t2p[proto];
 }
@@ -1365,7 +1365,8 @@ Fsrcvpcolx(Fs *f, uchar proto)
  *  called with protocol locked
  */
 Conv*
-Fsnewcall(Conv *c, uchar *raddr, ushort rport, uchar *laddr, ushort lport, uchar version)
+Fsnewcall(Conv *c, uint8_t *raddr, uint16_t rport, uint8_t *laddr,
+	  uint16_t lport, uint8_t version)
 {
 	Conv *nc;
 	Conv **l;
@@ -1402,8 +1403,8 @@ Fsnewcall(Conv *c, uchar *raddr, ushort rport, uchar *laddr, ushort lport, uchar
 	return nc;
 }
 
-long
-ndbwrite(Fs *f, char *a, ulong off, int n)
+int32_t
+ndbwrite(Fs *f, int8_t *a, uint32_t off, int n)
 {
 	if(off > strlen(f->ndb))
 		error(Eio);
@@ -1416,7 +1417,7 @@ ndbwrite(Fs *f, char *a, ulong off, int n)
 	return n;
 }
 
-ulong
+uint32_t
 scalednconv(void)
 {
 	if(cpuserver && conf.npage*PGSZ >= 128*MB)

+ 47 - 46
sys/src/9/ip/ethermedium.c

@@ -20,34 +20,35 @@
 typedef struct Etherhdr Etherhdr;
 struct Etherhdr
 {
-	uchar	d[6];
-	uchar	s[6];
-	uchar	t[2];
+	uint8_t	d[6];
+	uint8_t	s[6];
+	uint8_t	t[2];
 };
 
-static uchar ipbroadcast[IPaddrlen] = {
+static uint8_t ipbroadcast[IPaddrlen] = {
 	0xff,0xff,0xff,0xff,
 	0xff,0xff,0xff,0xff,
 	0xff,0xff,0xff,0xff,
 	0xff,0xff,0xff,0xff,
 };
 
-static uchar etherbroadcast[] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
+static uint8_t etherbroadcast[] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
 
 static void	etherread4(void *a);
 static void	etherread6(void *a);
-static void	etherbind(Ipifc *ifc, int argc, char **argv);
+static void	etherbind(Ipifc *ifc, int argc, int8_t **argv);
 static void	etherunbind(Ipifc *ifc);
-static void	etherbwrite(Ipifc *ifc, Block *bp, int version, uchar *ip);
-static void	etheraddmulti(Ipifc *ifc, uchar *a, uchar *ia);
-static void	etherremmulti(Ipifc *ifc, uchar *a, uchar *ia);
-static Block*	multicastarp(Fs *f, Arpent *a, Medium*, uchar *mac);
+static void	etherbwrite(Ipifc *ifc, Block *bp, int version,
+			       uint8_t *ip);
+static void	etheraddmulti(Ipifc *ifc, uint8_t *a, uint8_t *ia);
+static void	etherremmulti(Ipifc *ifc, uint8_t *a, uint8_t *ia);
+static Block*	multicastarp(Fs *f, Arpent *a, Medium*, uint8_t *mac);
 static void	sendarp(Ipifc *ifc, Arpent *a);
-static void	sendgarp(Ipifc *ifc, uchar*);
-static int	multicastea(uchar *ea, uchar *ip);
+static void	sendgarp(Ipifc *ifc, uint8_t*);
+static int	multicastea(uint8_t *ea, uint8_t *ip);
 static void	recvarpproc(void*);
 static void	resolveaddr6(Ipifc *ifc, Arpent *a);
-static void	etherpref2addr(uchar *pref, uchar *ea);
+static void	etherpref2addr(uint8_t *pref, uint8_t *ea);
 
 Medium ethermedium =
 {
@@ -129,35 +130,35 @@ enum
 typedef struct Etherarp Etherarp;
 struct Etherarp
 {
-	uchar	d[6];
-	uchar	s[6];
-	uchar	type[2];
-	uchar	hrd[2];
-	uchar	pro[2];
-	uchar	hln;
-	uchar	pln;
-	uchar	op[2];
-	uchar	sha[6];
-	uchar	spa[4];
-	uchar	tha[6];
-	uchar	tpa[4];
+	uint8_t	d[6];
+	uint8_t	s[6];
+	uint8_t	type[2];
+	uint8_t	hrd[2];
+	uint8_t	pro[2];
+	uint8_t	hln;
+	uint8_t	pln;
+	uint8_t	op[2];
+	uint8_t	sha[6];
+	uint8_t	spa[4];
+	uint8_t	tha[6];
+	uint8_t	tpa[4];
 };
 
-static char *nbmsg = "nonblocking";
+static int8_t *nbmsg = "nonblocking";
 
 /*
  *  called to bind an IP ifc to an ethernet device
  *  called with ifc wlock'd
  */
 static void
-etherbind(Ipifc *ifc, int argc, char **argv)
+etherbind(Ipifc *ifc, int argc, int8_t **argv)
 {
 	Chan *mchan4, *cchan4, *achan, *mchan6, *cchan6, *schan;
-	char addr[Maxpath];	//char addr[2*KNAMELEN];
-	char dir[Maxpath];	//char dir[2*KNAMELEN];
-	char *buf;
+	int8_t addr[Maxpath];	//char addr[2*KNAMELEN];
+	int8_t dir[Maxpath];	//char dir[2*KNAMELEN];
+	int8_t *buf;
 	int n;
-	char *ptr;
+	int8_t *ptr;
 	Etherrock *er;
 
 	if(argc < 2)
@@ -297,11 +298,11 @@ etherunbind(Ipifc *ifc)
  *  called by ipoput with a single block to write with ifc rlock'd
  */
 static void
-etherbwrite(Ipifc *ifc, Block *bp, int version, uchar *ip)
+etherbwrite(Ipifc *ifc, Block *bp, int version, uint8_t *ip)
 {
 	Etherhdr *eh;
 	Arpent *a;
-	uchar mac[6];
+	uint8_t mac[6];
 	Etherrock *er = ifc->arg;
 
 	/* get mac address of destination */
@@ -432,10 +433,10 @@ etherread6(void *a)
 }
 
 static void
-etheraddmulti(Ipifc *ifc, uchar *a, uchar *)
+etheraddmulti(Ipifc *ifc, uint8_t *a, uint8_t *)
 {
-	uchar mac[6];
-	char buf[64];
+	uint8_t mac[6];
+	int8_t buf[64];
 	Etherrock *er = ifc->arg;
 	int version;
 
@@ -454,10 +455,10 @@ etheraddmulti(Ipifc *ifc, uchar *a, uchar *)
 }
 
 static void
-etherremmulti(Ipifc *ifc, uchar *a, uchar *)
+etherremmulti(Ipifc *ifc, uint8_t *a, uint8_t *)
 {
-	uchar mac[6];
-	char buf[64];
+	uint8_t mac[6];
+	int8_t buf[64];
 	Etherrock *er = ifc->arg;
 	int version;
 
@@ -534,7 +535,7 @@ resolveaddr6(Ipifc *ifc, Arpent *a)
 	int sflag;
 	Block *bp;
 	Etherrock *er = ifc->arg;
-	uchar ipsrc[IPaddrlen];
+	uint8_t ipsrc[IPaddrlen];
 
 	/* don't do anything if it's been less than a second since the last */
 	if(NOW - a->ctime < ReTransTimer){
@@ -569,7 +570,7 @@ resolveaddr6(Ipifc *ifc, Arpent *a)
  *  send a gratuitous arp to refresh arp caches
  */
 static void
-sendgarp(Ipifc *ifc, uchar *ip)
+sendgarp(Ipifc *ifc, uint8_t *ip)
 {
 	int n;
 	Block *bp;
@@ -609,8 +610,8 @@ recvarp(Ipifc *ifc)
 	int n;
 	Block *ebp, *rbp;
 	Etherarp *e, *r;
-	uchar ip[IPaddrlen];
-	static uchar eprinted[4];
+	uint8_t ip[IPaddrlen];
+	static uint8_t eprinted[4];
 	Etherrock *er = ifc->arg;
 
 	ebp = er->achan->dev->bread(er->achan, ifc->maxtu, 0);
@@ -716,7 +717,7 @@ recvarpproc(void *v)
 }
 
 static int
-multicastea(uchar *ea, uchar *ip)
+multicastea(uint8_t *ea, uint8_t *ip)
 {
 	int x;
 
@@ -747,7 +748,7 @@ multicastea(uchar *ea, uchar *ip)
  *  IP address.
  */
 static Block*
-multicastarp(Fs *f, Arpent *a, Medium *medium, uchar *mac)
+multicastarp(Fs *f, Arpent *a, Medium *medium, uint8_t *mac)
 {
 	/* is it broadcast? */
 	switch(ipforme(f, a->ip)){
@@ -781,7 +782,7 @@ ethermediumlink(void)
 
 
 static void
-etherpref2addr(uchar *pref, uchar *ea)
+etherpref2addr(uint8_t *pref, uint8_t *ea)
 {
 	pref[8] = ea[0] | 0x2;
 	pref[9] = ea[1];

+ 26 - 26
sys/src/9/ip/gre.c

@@ -33,20 +33,20 @@ enum
 typedef struct GREhdr
 {
 	/* ip header */
-	uchar	vihl;		/* Version and header length */
-	uchar	tos;		/* Type of service */
-	uchar	len[2];		/* packet length (including headers) */
-	uchar	id[2];		/* Identification */
-	uchar	frag[2];	/* Fragment information */
-	uchar	Unused;
-	uchar	proto;		/* Protocol */
-	uchar	cksum[2];	/* checksum */
-	uchar	src[4];		/* Ip source */
-	uchar	dst[4];		/* Ip destination */
+	uint8_t	vihl;		/* Version and header length */
+	uint8_t	tos;		/* Type of service */
+	uint8_t	len[2];		/* packet length (including headers) */
+	uint8_t	id[2];		/* Identification */
+	uint8_t	frag[2];	/* Fragment information */
+	uint8_t	Unused;
+	uint8_t	proto;		/* Protocol */
+	uint8_t	cksum[2];	/* checksum */
+	uint8_t	src[4];		/* Ip source */
+	uint8_t	dst[4];		/* Ip destination */
 
 	/* gre header */
-	uchar	flags[2];
-	uchar	eproto[2];	/* encapsulation protocol */
+	uint8_t	flags[2];
+	uint8_t	eproto[2];	/* encapsulation protocol */
 } GREhdr;
 
 typedef struct GREpriv GREpriv;
@@ -55,17 +55,17 @@ struct GREpriv
 	int		raw;			/* Raw GRE mode */
 
 	/* non-MIB stats */
-	ulong		csumerr;		/* checksum errors */
-	ulong		lenerr;			/* short packet */
+	uint32_t		csumerr;		/* checksum errors */
+	uint32_t		lenerr;			/* short packet */
 };
 
 static void grekick(void *x, Block *bp);
 
-static char*
-greconnect(Conv *c, char **argv, int argc)
+static int8_t*
+greconnect(Conv *c, int8_t **argv, int argc)
 {
 	Proto *p;
-	char *err;
+	int8_t *err;
 	Conv *tc, **cp, **ecp;
 
 	err = Fsstdconnect(c, argv, argc);
@@ -106,14 +106,14 @@ grecreate(Conv *c)
 }
 
 static int
-grestate(Conv *c, char *state, int n)
+grestate(Conv *c, int8_t *state, int n)
 {
 	USED(c);
 	return snprint(state, n, "%s\n", "Datagram");
 }
 
-static char*
-greannounce(Conv*, char**, int)
+static int8_t*
+greannounce(Conv*, int8_t**, int)
 {
 	return "pktifc does not support announce";
 }
@@ -135,7 +135,7 @@ grekick(void *x, Block *bp)
 {
 	Conv *c = x;
 	GREhdr *ghp;
-	uchar laddr[IPaddrlen], raddr[IPaddrlen];
+	uint8_t laddr[IPaddrlen], raddr[IPaddrlen];
 
 	if(bp == nil)
 		return;
@@ -179,8 +179,8 @@ greiput(Proto *gre, Ipifc*, Block *bp)
 	int len;
 	GREhdr *ghp;
 	Conv *c, **p;
-	ushort eproto;
-	uchar raddr[IPaddrlen];
+	uint16_t eproto;
+	uint8_t raddr[IPaddrlen];
 	GREpriv *gpriv;
 
 	gpriv = gre->priv;
@@ -237,7 +237,7 @@ greiput(Proto *gre, Ipifc*, Block *bp)
 }
 
 int
-grestats(Proto *gre, char *buf, int len)
+grestats(Proto *gre, int8_t *buf, int len)
 {
 	GREpriv *gpriv;
 
@@ -246,8 +246,8 @@ grestats(Proto *gre, char *buf, int len)
 	return snprint(buf, len, "gre: len %lud\n", gpriv->lenerr);
 }
 
-char*
-grectl(Conv *c, char **f, int n)
+int8_t*
+grectl(Conv *c, int8_t **f, int n)
 {
 	GREpriv *gpriv;
 

+ 38 - 38
sys/src/9/ip/icmp.c

@@ -17,22 +17,22 @@
 #include "ip.h"
 
 typedef struct Icmp {
-	uchar	vihl;		/* Version and header length */
-	uchar	tos;		/* Type of service */
-	uchar	length[2];	/* packet length */
-	uchar	id[2];		/* Identification */
-	uchar	frag[2];	/* Fragment information */
-	uchar	ttl;		/* Time to live */
-	uchar	proto;		/* Protocol */
-	uchar	ipcksum[2];	/* Header checksum */
-	uchar	src[4];		/* Ip source */
-	uchar	dst[4];		/* Ip destination */
-	uchar	type;
-	uchar	code;
-	uchar	cksum[2];
-	uchar	icmpid[2];
-	uchar	seq[2];
-	uchar	data[1];
+	uint8_t	vihl;		/* Version and header length */
+	uint8_t	tos;		/* Type of service */
+	uint8_t	length[2];	/* packet length */
+	uint8_t	id[2];		/* Identification */
+	uint8_t	frag[2];	/* Fragment information */
+	uint8_t	ttl;		/* Time to live */
+	uint8_t	proto;		/* Protocol */
+	uint8_t	ipcksum[2];	/* Header checksum */
+	uint8_t	src[4];		/* Ip source */
+	uint8_t	dst[4];		/* Ip destination */
+	uint8_t	type;
+	uint8_t	code;
+	uint8_t	cksum[2];
+	uint8_t	icmpid[2];
+	uint8_t	seq[2];
+	uint8_t	data[1];
 } Icmp;
 
 enum {			/* Packet Types */
@@ -106,11 +106,11 @@ static char *statnames[Nstats] =
 typedef struct Icmppriv Icmppriv;
 struct Icmppriv
 {
-	ulong	stats[Nstats];
+	uint32_t	stats[Nstats];
 
 	/* message counts */
-	ulong	in[Maxtype+1];
-	ulong	out[Maxtype+1];
+	uint32_t	in[Maxtype+1];
+	uint32_t	out[Maxtype+1];
 };
 
 static void icmpkick(void *x, Block*);
@@ -122,10 +122,10 @@ icmpcreate(Conv *c)
 	c->wq = qbypass(icmpkick, c);
 }
 
-extern char*
-icmpconnect(Conv *c, char **argv, int argc)
+extern int8_t*
+icmpconnect(Conv *c, int8_t **argv, int argc)
 {
-	char *e;
+	int8_t *e;
 
 	e = Fsstdconnect(c, argv, argc);
 	if(e != nil)
@@ -136,7 +136,7 @@ icmpconnect(Conv *c, char **argv, int argc)
 }
 
 extern int
-icmpstate(Conv *c, char *state, int n)
+icmpstate(Conv *c, int8_t *state, int n)
 {
 	USED(c);
 	return snprint(state, n, "%s qin %d qout %d\n",
@@ -146,10 +146,10 @@ icmpstate(Conv *c, char *state, int n)
 	);
 }
 
-extern char*
-icmpannounce(Conv *c, char **argv, int argc)
+extern int8_t*
+icmpannounce(Conv *c, int8_t **argv, int argc)
 {
-	char *e;
+	int8_t *e;
 
 	e = Fsstdannounce(c, argv, argc);
 	if(e != nil)
@@ -200,7 +200,7 @@ icmpkick(void *x, Block *bp)
 }
 
 extern void
-icmpttlexceeded(Fs *f, uchar *ia, Block *bp)
+icmpttlexceeded(Fs *f, uint8_t *ia, Block *bp)
 {
 	Block	*nbp;
 	Icmp	*p, *np;
@@ -232,7 +232,7 @@ icmpunreachable(Fs *f, Block *bp, int code, int seq)
 	Block	*nbp;
 	Icmp	*p, *np;
 	int	i;
-	uchar	addr[IPaddrlen];
+	uint8_t	addr[IPaddrlen];
 
 	p = (Icmp *)bp->rp;
 
@@ -281,8 +281,8 @@ goticmpkt(Proto *icmp, Block *bp)
 {
 	Conv	**c, *s;
 	Icmp	*p;
-	uchar	dst[IPaddrlen];
-	ushort	recid;
+	uint8_t	dst[IPaddrlen];
+	uint16_t	recid;
 
 	p = (Icmp *) bp->rp;
 	v4tov6(dst, p->src);
@@ -305,7 +305,7 @@ static Block *
 mkechoreply(Block *bp)
 {
 	Icmp	*q;
-	uchar	ip[4];
+	uint8_t	ip[4];
 
 	q = (Icmp *)bp->rp;
 	q->vihl = IP_VER4;
@@ -336,8 +336,8 @@ icmpiput(Proto *icmp, Ipifc*, Block *bp)
 	Icmp	*p;
 	Block	*r;
 	Proto	*pr;
-	char	*msg;
-	char	m2[128];
+	int8_t	*msg;
+	int8_t	m2[128];
 	Icmppriv *ipriv;
 
 	ipriv = icmp->priv;
@@ -431,12 +431,12 @@ raise:
 }
 
 void
-icmpadvise(Proto *icmp, Block *bp, char *msg)
+icmpadvise(Proto *icmp, Block *bp, int8_t *msg)
 {
 	Conv	**c, *s;
 	Icmp	*p;
-	uchar	dst[IPaddrlen];
-	ushort	recid;
+	uint8_t	dst[IPaddrlen];
+	uint16_t	recid;
 
 	p = (Icmp *) bp->rp;
 	v4tov6(dst, p->dst);
@@ -455,10 +455,10 @@ icmpadvise(Proto *icmp, Block *bp, char *msg)
 }
 
 int
-icmpstats(Proto *icmp, char *buf, int len)
+icmpstats(Proto *icmp, int8_t *buf, int len)
 {
 	Icmppriv *priv;
-	char *p, *e;
+	int8_t *p, *e;
 	int i;
 
 	priv = icmp->priv;

+ 35 - 33
sys/src/9/ip/icmp6.c

@@ -82,11 +82,11 @@ typedef struct Ndpkt Ndpkt;
 typedef struct NdiscC NdiscC;
 
 struct ICMPpkt {
-	uchar	type;
-	uchar	code;
-	uchar	cksum[2];
-	uchar	icmpid[2];
-	uchar	seq[2];
+	uint8_t	type;
+	uint8_t	code;
+	uint8_t	cksum[2];
+	uint8_t	icmpid[2];
+	uint8_t	seq[2];
 };
 
 struct IPICMP {
@@ -97,25 +97,25 @@ struct IPICMP {
 struct NdiscC
 {
 	IPICMP;
-	uchar	target[IPaddrlen];
+	uint8_t	target[IPaddrlen];
 };
 
 struct Ndpkt
 {
 	NdiscC;
-	uchar	otype;
-	uchar	olen;		/* length in units of 8 octets(incl type, code),
+	uint8_t	otype;
+	uint8_t	olen;		/* length in units of 8 octets(incl type, code),
 				 * 1 for IEEE 802 addresses */
-	uchar	lnaddr[6];	/* link-layer address */
+	uint8_t	lnaddr[6];	/* link-layer address */
 };
 
 typedef struct Icmppriv6
 {
-	ulong	stats[Nstats6];
+	uint32_t	stats[Nstats6];
 
 	/* message counts */
-	ulong	in[Maxtype6+1];
-	ulong	out[Maxtype6+1];
+	uint32_t	in[Maxtype6+1];
+	uint32_t	out[Maxtype6+1];
 } Icmppriv6;
 
 typedef struct Icmpcb6
@@ -211,9 +211,9 @@ newIPICMP(int packetlen)
 }
 
 void
-icmpadvise6(Proto *icmp, Block *bp, char *msg)
+icmpadvise6(Proto *icmp, Block *bp, int8_t *msg)
 {
-	ushort recid;
+	uint16_t recid;
 	Conv **c, *s;
 	IPICMP *p;
 
@@ -234,7 +234,7 @@ icmpadvise6(Proto *icmp, Block *bp, char *msg)
 static void
 icmpkick6(void *x, Block *bp)
 {
-	uchar laddr[IPaddrlen], raddr[IPaddrlen];
+	uint8_t laddr[IPaddrlen], raddr[IPaddrlen];
 	Conv *c = x;
 	IPICMP *p;
 	Icmppriv6 *ipriv = c->p->priv;
@@ -277,8 +277,8 @@ icmpkick6(void *x, Block *bp)
 	ipoput6(c->p->f, bp, 0, c->ttl, c->tos, nil);
 }
 
-char*
-icmpctl6(Conv *c, char **argv, int argc)
+int8_t*
+icmpctl6(Conv *c, int8_t **argv, int argc)
 {
 	Icmpcb6 *icb;
 
@@ -293,8 +293,8 @@ icmpctl6(Conv *c, char **argv, int argc)
 static void
 goticmpkt6(Proto *icmp, Block *bp, int muxkey)
 {
-	ushort recid;
-	uchar *addr;
+	uint16_t recid;
+	uint8_t *addr;
 	Conv **c, *s;
 	IPICMP *p = (IPICMP *)bp->rp;
 
@@ -322,7 +322,7 @@ goticmpkt6(Proto *icmp, Block *bp, int muxkey)
 static Block *
 mkechoreply6(Block *bp, Ipifc *ifc)
 {
-	uchar addr[IPaddrlen];
+	uint8_t addr[IPaddrlen];
 	IPICMP *p = (IPICMP *)(bp->rp);
 
 	ipmove(addr, p->src);
@@ -343,7 +343,8 @@ mkechoreply6(Block *bp, Ipifc *ifc)
  * 	and tuni == TARG_UNI => neighbor reachability.
  */
 extern void
-icmpns(Fs *f, uchar* src, int suni, uchar* targ, int tuni, uchar* mac)
+icmpns(Fs *f, uint8_t* src, int suni, uint8_t* targ, int tuni,
+       uint8_t* mac)
 {
 	Block *nbp;
 	Ndpkt *np;
@@ -386,7 +387,8 @@ icmpns(Fs *f, uchar* src, int suni, uchar* targ, int tuni, uchar* mac)
  * sends out an ICMPv6 neighbor advertisement. pktflags == RSO flags.
  */
 extern void
-icmpna(Fs *f, uchar* src, uchar* dst, uchar* targ, uchar* mac, uchar flags)
+icmpna(Fs *f, uint8_t* src, uint8_t* dst, uint8_t* targ, uint8_t* mac,
+       uint8_t flags)
 {
 	Block *nbp;
 	Ndpkt *np;
@@ -558,7 +560,7 @@ valid(Proto *icmp, Ipifc *ifc, Block *bp, Icmppriv6 *ipriv)
 {
 	int sz, osz, unsp, n, ttl, iplen;
 	int pktsz = BLEN(bp);
-	uchar *packet = bp->rp;
+	uint8_t *packet = bp->rp;
 	IPICMP *p = (IPICMP *) packet;
 	Ndpkt *np;
 
@@ -689,7 +691,7 @@ err:
 }
 
 static int
-targettype(Fs *f, Ipifc *ifc, uchar *target)
+targettype(Fs *f, Ipifc *ifc, uint8_t *target)
 {
 	Iplifc *lifc;
 	int t;
@@ -715,10 +717,10 @@ static void
 icmpiput6(Proto *icmp, Ipifc *ipifc, Block *bp)
 {
 	int refresh = 1;
-	char *msg, m2[128];
-	uchar pktflags;
-	uchar *packet = bp->rp;
-	uchar lsrc[IPaddrlen];
+	int8_t *msg, m2[128];
+	uint8_t pktflags;
+	uint8_t *packet = bp->rp;
+	uint8_t lsrc[IPaddrlen];
 	Block *r;
 	IPICMP *p = (IPICMP *)packet;
 	Icmppriv6 *ipriv = icmp->priv;
@@ -854,10 +856,10 @@ raise:
 }
 
 int
-icmpstats6(Proto *icmp6, char *buf, int len)
+icmpstats6(Proto *icmp6, int8_t *buf, int len)
 {
 	Icmppriv6 *priv;
-	char *p, *e;
+	int8_t *p, *e;
 	int i;
 
 	priv = icmp6->priv;
@@ -878,9 +880,9 @@ icmpstats6(Proto *icmp6, char *buf, int len)
 
 
 /* import from icmp.c */
-extern int	icmpstate(Conv *c, char *state, int n);
-extern char*	icmpannounce(Conv *c, char **argv, int argc);
-extern char*	icmpconnect(Conv *c, char **argv, int argc);
+extern int	icmpstate(Conv *c, int8_t *state, int n);
+extern int8_t*	icmpannounce(Conv *c, int8_t **argv, int argc);
+extern int8_t*	icmpconnect(Conv *c, int8_t **argv, int argc);
 extern void	icmpclose(Conv *c);
 
 void

+ 4 - 4
sys/src/9/ip/inferno.c

@@ -19,7 +19,7 @@
  *  some hacks for commonality twixt inferno and plan9
  */
 
-char*
+int8_t*
 commonuser(void)
 {
 	return up->user;
@@ -31,20 +31,20 @@ commonfdtochan(int fd, int mode, int a, int b)
 	return fdtochan(fd, mode, a, b);
 }
 
-char*
+int8_t*
 commonerror(void)
 {
 	return up->errstr;
 }
 
-char*
+int8_t*
 bootp(Ipifc*)
 {
 	return "unimplmented";
 }
 
 int
-bootpread(char*, ulong, int)
+bootpread(int8_t*, uint32_t, int)
 {
 	return	0;
 }

+ 32 - 32
sys/src/9/ip/ip.c

@@ -37,16 +37,16 @@ enum
 
 struct Ip4hdr
 {
-	uchar	vihl;		/* Version and header length */
-	uchar	tos;		/* Type of service */
-	uchar	length[2];	/* packet length */
-	uchar	id[2];		/* ip->identification */
-	uchar	frag[2];	/* Fragment information */
-	uchar	ttl;		/* Time to live */
-	uchar	proto;		/* Protocol */
-	uchar	cksum[2];	/* Header checksum */
-	uchar	src[4];		/* IP source */
-	uchar	dst[4];		/* IP destination */
+	uint8_t	vihl;		/* Version and header length */
+	uint8_t	tos;		/* Type of service */
+	uint8_t	length[2];	/* packet length */
+	uint8_t	id[2];		/* ip->identification */
+	uint8_t	frag[2];	/* Fragment information */
+	uint8_t	ttl;		/* Time to live */
+	uint8_t	proto;		/* Protocol */
+	uint8_t	cksum[2];	/* Header checksum */
+	uint8_t	src[4];		/* IP source */
+	uint8_t	dst[4];		/* IP destination */
 };
 
 /* MIB II counters */
@@ -79,32 +79,32 @@ struct Fragment4
 {
 	Block*	blist;
 	Fragment4*	next;
-	ulong 	src;
-	ulong 	dst;
-	ushort	id;
-	ulong 	age;
+	uint32_t 	src;
+	uint32_t 	dst;
+	uint16_t	id;
+	uint32_t 	age;
 };
 
 struct Fragment6
 {
 	Block*	blist;
 	Fragment6*	next;
-	uchar 	src[IPaddrlen];
-	uchar 	dst[IPaddrlen];
+	uint8_t 	src[IPaddrlen];
+	uint8_t 	dst[IPaddrlen];
 	uint	id;
-	ulong 	age;
+	uint32_t 	age;
 };
 
 struct Ipfrag
 {
-	ushort	foff;
-	ushort	flen;
+	uint16_t	foff;
+	uint16_t	flen;
 };
 
 /* an instance of IP */
 struct IP
 {
-	ulong		stats[Nstats];
+	uint32_t		stats[Nstats];
 
 	QLock		fraglock4;
 	Fragment4*	flisthead4;
@@ -149,7 +149,7 @@ static char *statnames[] =
  */
 #define BKFG(xp)	((Ipfrag*)((xp)->base))
 
-ushort		ipcsum(uchar*);
+uint16_t		ipcsum(uint8_t*);
 Block*		ip4reassemble(IP*, int, Block*, Ip4hdr*);
 void		ipfragfree4(IP*, Fragment4*);
 Fragment4*	ipfragallo4(IP*);
@@ -233,8 +233,8 @@ int
 ipoput4(Fs *f, Block *bp, int gating, int ttl, int tos, Conv *c)
 {
 	Ipifc *ifc;
-	uchar *gate;
-	ulong fragoff;
+	uint8_t *gate;
+	uint32_t fragoff;
 	Block *xp, *nb;
 	Ip4hdr *eh, *feh;
 	int lid, len, seglen, chunk, dlen, blklen, offset, medialen;
@@ -420,9 +420,9 @@ ipiput4(Fs *f, Ipifc *ifc, Block *bp)
 	int hop, tos, proto, olen;
 	Ip4hdr *h;
 	Proto *p;
-	ushort frag;
+	uint16_t frag;
 	int notforme;
-	uchar *dp, v6dst[IPaddrlen];
+	uint8_t *dp, v6dst[IPaddrlen];
 	IP *ip;
 	Route *r;
 
@@ -560,10 +560,10 @@ if(r->ifc == nil) panic("nil route rfc");
 }
 
 int
-ipstats(Fs *f, char *buf, int len)
+ipstats(Fs *f, int8_t *buf, int len)
 {
 	IP *ip;
-	char *p, *e;
+	int8_t *p, *e;
 	int i;
 
 	ip = f->ip;
@@ -580,9 +580,9 @@ Block*
 ip4reassemble(IP *ip, int offset, Block *bp, Ip4hdr *ih)
 {
 	int fend;
-	ushort id;
+	uint16_t id;
 	Fragment4 *f, *fnext;
-	ulong src, dst;
+	uint32_t src, dst;
 	Block *bl, **l, *last, *prev;
 	int ovlap, len, fragsize, pktposn;
 
@@ -792,11 +792,11 @@ ipfragallo4(IP *ip)
 	return f;
 }
 
-ushort
-ipcsum(uchar *addr)
+uint16_t
+ipcsum(uint8_t *addr)
 {
 	int len;
-	ulong sum;
+	uint32_t sum;
 
 	sum = 0;
 	len = (addr[0]&0xf)<<2;

+ 29 - 29
sys/src/9/ip/ipaux.c

@@ -43,26 +43,26 @@ char *v6hdrtypes[Maxhdrtype] =
 /*
  *  well known IPv6 addresses
  */
-uchar v6Unspecified[IPaddrlen] = {
+uint8_t v6Unspecified[IPaddrlen] = {
 	0, 0, 0, 0,
 	0, 0, 0, 0,
 	0, 0, 0, 0,
 	0, 0, 0, 0
 };
-uchar v6loopback[IPaddrlen] = {
+uint8_t v6loopback[IPaddrlen] = {
 	0, 0, 0, 0,
 	0, 0, 0, 0,
 	0, 0, 0, 0,
 	0, 0, 0, 0x01
 };
 
-uchar v6linklocal[IPaddrlen] = {
+uint8_t v6linklocal[IPaddrlen] = {
 	0xfe, 0x80, 0, 0,
 	0, 0, 0, 0,
 	0, 0, 0, 0,
 	0, 0, 0, 0
 };
-uchar v6linklocalmask[IPaddrlen] = {
+uint8_t v6linklocalmask[IPaddrlen] = {
 	0xff, 0xff, 0xff, 0xff,
 	0xff, 0xff, 0xff, 0xff,
 	0, 0, 0, 0,
@@ -70,13 +70,13 @@ uchar v6linklocalmask[IPaddrlen] = {
 };
 int v6llpreflen = 8;	/* link-local prefix length in bytes */
 
-uchar v6multicast[IPaddrlen] = {
+uint8_t v6multicast[IPaddrlen] = {
 	0xff, 0, 0, 0,
 	0, 0, 0, 0,
 	0, 0, 0, 0,
 	0, 0, 0, 0
 };
-uchar v6multicastmask[IPaddrlen] = {
+uint8_t v6multicastmask[IPaddrlen] = {
 	0xff, 0, 0, 0,
 	0, 0, 0, 0,
 	0, 0, 0, 0,
@@ -84,19 +84,19 @@ uchar v6multicastmask[IPaddrlen] = {
 };
 int v6mcpreflen = 1;	/* multicast prefix length */
 
-uchar v6allnodesN[IPaddrlen] = {
+uint8_t v6allnodesN[IPaddrlen] = {
 	0xff, 0x01, 0, 0,
 	0, 0, 0, 0,
 	0, 0, 0, 0,
 	0, 0, 0, 0x01
 };
-uchar v6allroutersN[IPaddrlen] = {
+uint8_t v6allroutersN[IPaddrlen] = {
 	0xff, 0x01, 0, 0,
 	0, 0, 0, 0,
 	0, 0, 0, 0,
 	0, 0, 0, 0x02
 };
-uchar v6allnodesNmask[IPaddrlen] = {
+uint8_t v6allnodesNmask[IPaddrlen] = {
 	0xff, 0xff, 0, 0,
 	0, 0, 0, 0,
 	0, 0, 0, 0,
@@ -104,19 +104,19 @@ uchar v6allnodesNmask[IPaddrlen] = {
 };
 int v6aNpreflen = 2;	/* all nodes (N) prefix */
 
-uchar v6allnodesL[IPaddrlen] = {
+uint8_t v6allnodesL[IPaddrlen] = {
 	0xff, 0x02, 0, 0,
 	0, 0, 0, 0,
 	0, 0, 0, 0,
 	0, 0, 0, 0x01
 };
-uchar v6allroutersL[IPaddrlen] = {
+uint8_t v6allroutersL[IPaddrlen] = {
 	0xff, 0x02, 0, 0,
 	0, 0, 0, 0,
 	0, 0, 0, 0,
 	0, 0, 0, 0x02
 };
-uchar v6allnodesLmask[IPaddrlen] = {
+uint8_t v6allnodesLmask[IPaddrlen] = {
 	0xff, 0xff, 0, 0,
 	0, 0, 0, 0,
 	0, 0, 0, 0,
@@ -124,13 +124,13 @@ uchar v6allnodesLmask[IPaddrlen] = {
 };
 int v6aLpreflen = 2;	/* all nodes (L) prefix */
 
-uchar v6solicitednode[IPaddrlen] = {
+uint8_t v6solicitednode[IPaddrlen] = {
 	0xff, 0x02, 0, 0,
 	0, 0, 0, 0,
 	0, 0, 0, 0x01,
 	0xff, 0, 0, 0
 };
-uchar v6solicitednodemask[IPaddrlen] = {
+uint8_t v6solicitednodemask[IPaddrlen] = {
 	0xff, 0xff, 0xff, 0xff,
 	0xff, 0xff, 0xff, 0xff,
 	0xff, 0xff, 0xff, 0xff,
@@ -138,12 +138,12 @@ uchar v6solicitednodemask[IPaddrlen] = {
 };
 int v6snpreflen = 13;
 
-ushort
+uint16_t
 ptclcsum(Block *bp, int offset, int len)
 {
-	uchar *addr;
-	ulong losum, hisum;
-	ushort csum;
+	uint8_t *addr;
+	uint32_t losum, hisum;
+	uint16_t csum;
 	int odd, blocklen, x;
 
 	/* Correct to front of data area */
@@ -200,10 +200,10 @@ enum
 	Isprefix= 16,
 };
 
-#define CLASS(p) ((*(uchar*)(p))>>6)
+#define CLASS(p) ((*(uint8_t*)(p))>>6)
 
 void
-ipv62smcast(uchar *smcast, uchar *a)
+ipv62smcast(uint8_t *smcast, uint8_t *a)
 {
 	assert(IPaddrlen == 16);
 	memmove(smcast, v6solicitednode, IPaddrlen);
@@ -217,10 +217,10 @@ ipv62smcast(uchar *smcast, uchar *a)
  *  parse a hex mac address
  */
 int
-parsemac(uchar *to, char *from, int len)
+parsemac(uint8_t *to, int8_t *from, int len)
 {
-	char nip[4];
-	char *p;
+	int8_t nip[4];
+	int8_t *p;
 	int i;
 
 	p = from;
@@ -244,8 +244,8 @@ parsemac(uchar *to, char *from, int len)
 /*
  *  hashing tcp, udp, ... connections
  */
-ulong
-iphash(uchar *sa, ushort sp, uchar *da, ushort dp)
+uint32_t
+iphash(uint8_t *sa, uint16_t sp, uint8_t *da, uint16_t dp)
 {
 	return ((sa[IPaddrlen-1]<<24) ^ (sp << 16) ^ (da[IPaddrlen-1]<<8) ^ dp ) % Nhash;
 }
@@ -253,7 +253,7 @@ iphash(uchar *sa, ushort sp, uchar *da, ushort dp)
 void
 iphtadd(Ipht *ht, Conv *c)
 {
-	ulong hv;
+	uint32_t hv;
 	Iphash *h;
 
 	hv = iphash(c->raddr, c->rport, c->laddr, c->lport);
@@ -284,7 +284,7 @@ iphtadd(Ipht *ht, Conv *c)
 void
 iphtrem(Ipht *ht, Conv *c)
 {
-	ulong hv;
+	uint32_t hv;
 	Iphash **l, *h;
 
 	hv = iphash(c->raddr, c->rport, c->laddr, c->lport);
@@ -307,9 +307,9 @@ iphtrem(Ipht *ht, Conv *c)
  *	announced && *,*
  */
 Conv*
-iphtlook(Ipht *ht, uchar *sa, ushort sp, uchar *da, ushort dp)
+iphtlook(Ipht *ht, uint8_t *sa, uint16_t sp, uint8_t *da, uint16_t dp)
 {
-	ulong hv;
+	uint32_t hv;
 	Iphash *h;
 	Conv *c;
 

+ 85 - 83
sys/src/9/ip/ipifc.c

@@ -34,11 +34,11 @@ Medium *media[Maxmedia] = { 0 };
  */
 struct Ipself
 {
-	uchar	a[IPaddrlen];
+	uint8_t	a[IPaddrlen];
 	Ipself	*hnext;		/* next address in the hash table */
 	Iplink	*link;		/* binding twixt Ipself and Ipifc */
-	ulong	expire;
-	uchar	type;		/* type of address */
+	uint32_t	expire;
+	uint8_t	type;		/* type of address */
 	int	ref;
 	Ipself	*next;		/* free list */
 };
@@ -59,21 +59,22 @@ typedef struct Ipmcast Ipmcast;
 struct Ipmcast
 {
 	Ipmcast	*next;
-	uchar	ma[IPaddrlen];	/* multicast address */
-	uchar	ia[IPaddrlen];	/* interface address */
+	uint8_t	ma[IPaddrlen];	/* multicast address */
+	uint8_t	ia[IPaddrlen];	/* interface address */
 };
 
 /* quick hash for ip addresses */
 #define hashipa(a) ( ( ((a)[IPaddrlen-2]<<8) | (a)[IPaddrlen-1] )%NHASH )
 
-static char tifc[] = "ifc ";
+static int8_t tifc[] = "ifc ";
 
-static void	addselfcache(Fs *f, Ipifc *ifc, Iplifc *lifc, uchar *a, int type);
-static void	remselfcache(Fs *f, Ipifc *ifc, Iplifc *lifc, uchar *a);
-static char*	ipifcjoinmulti(Ipifc *ifc, char **argv, int argc);
-static char*	ipifcleavemulti(Ipifc *ifc, char **argv, int argc);
-static void	ipifcregisterproxy(Fs*, Ipifc*, uchar*);
-static char*	ipifcremlifc(Ipifc*, Iplifc*);
+static void	addselfcache(Fs *f, Ipifc *ifc, Iplifc *lifc, uint8_t *a,
+				int type);
+static void	remselfcache(Fs *f, Ipifc *ifc, Iplifc *lifc, uint8_t *a);
+static int8_t*	ipifcjoinmulti(Ipifc *ifc, int8_t **argv, int argc);
+static int8_t*	ipifcleavemulti(Ipifc *ifc, int8_t **argv, int argc);
+static void	ipifcregisterproxy(Fs*, Ipifc*, uint8_t*);
+static int8_t*	ipifcremlifc(Ipifc*, Iplifc*);
 
 /*
  *  link in a new medium
@@ -94,7 +95,7 @@ addipmedium(Medium *med)
  *  find the medium with this name
  */
 Medium*
-ipfindmedium(char *name)
+ipfindmedium(int8_t *name)
 {
 	Medium **mp;
 
@@ -108,8 +109,8 @@ ipfindmedium(char *name)
  *  attach a device (or pkt driver) to the interface.
  *  called with c locked
  */
-static char*
-ipifcbind(Conv *c, char **argv, int argc)
+static int8_t*
+ipifcbind(Conv *c, int8_t **argv, int argc)
 {
 	Ipifc *ifc;
 	Medium *medium;
@@ -178,10 +179,10 @@ ipifcbind(Conv *c, char **argv, int argc)
  *  detach a device from an interface, close the interface
  *  called with ifc->conv closed
  */
-static char*
+static int8_t*
 ipifcunbind(Ipifc *ifc)
 {
-	char *err;
+	int8_t *err;
 
 	if(waserror()){
 		wunlock(ifc);
@@ -223,14 +224,14 @@ ipifcunbind(Ipifc *ifc)
 	return nil;
 }
 
-char sfixedformat[] = "device %s maxtu %d sendra %d recvra %d mflag %d oflag"
+int8_t sfixedformat[] = "device %s maxtu %d sendra %d recvra %d mflag %d oflag"
 " %d maxraint %d minraint %d linkmtu %d reachtime %d rxmitra %d ttl %d routerlt"
 " %d pktin %lud pktout %lud errin %lud errout %lud\n";
 
-char slineformat[] = "	%-40I %-10M %-40I %-12lud %-12lud\n";
+int8_t slineformat[] = "	%-40I %-10M %-40I %-12lud %-12lud\n";
 
 static int
-ipifcstate(Conv *c, char *state, int n)
+ipifcstate(Conv *c, int8_t *state, int n)
 {
 	Ipifc *ifc;
 	Iplifc *lifc;
@@ -255,7 +256,7 @@ ipifcstate(Conv *c, char *state, int n)
 }
 
 static int
-ipifclocal(Conv *c, char *state, int n)
+ipifclocal(Conv *c, int8_t *state, int n)
 {
 	Ipifc *ifc;
 	Iplifc *lifc;
@@ -353,8 +354,8 @@ ipifcclose(Conv *c)
 /*
  *  change an interface's mtu
  */
-char*
-ipifcsetmtu(Ipifc *ifc, char **argv, int argc)
+int8_t*
+ipifcsetmtu(Ipifc *ifc, int8_t **argv, int argc)
 {
 	int mtu;
 
@@ -370,12 +371,12 @@ ipifcsetmtu(Ipifc *ifc, char **argv, int argc)
 /*
  *  add an address to an interface.
  */
-char*
-ipifcadd(Ipifc *ifc, char **argv, int argc, int tentative, Iplifc *lifcp)
+int8_t*
+ipifcadd(Ipifc *ifc, int8_t **argv, int argc, int tentative, Iplifc *lifcp)
 {
 	int i, type, mtu, sendnbrdisc = 0;
-	uchar ip[IPaddrlen], mask[IPaddrlen], rem[IPaddrlen];
-	uchar bcast[IPaddrlen], net[IPaddrlen];
+	uint8_t ip[IPaddrlen], mask[IPaddrlen], rem[IPaddrlen];
+	uint8_t bcast[IPaddrlen], net[IPaddrlen];
 	Iplifc *lifc, **l;
 	Fs *f;
 
@@ -545,7 +546,7 @@ out:
  *  remove a logical interface from an ifc
  *  always called with ifc wlock'd
  */
-static char*
+static int8_t*
 ipifcremlifc(Ipifc *ifc, Iplifc *lifc)
 {
 	Iplifc **l;
@@ -589,11 +590,11 @@ ipifcremlifc(Ipifc *ifc, Iplifc *lifc)
  *  remove an address from an interface.
  *  called with c->car locked
  */
-char*
-ipifcrem(Ipifc *ifc, char **argv, int argc)
+int8_t*
+ipifcrem(Ipifc *ifc, int8_t **argv, int argc)
 {
-	char *rv;
-	uchar ip[IPaddrlen], mask[IPaddrlen], rem[IPaddrlen];
+	int8_t *rv;
+	uint8_t ip[IPaddrlen], mask[IPaddrlen], rem[IPaddrlen];
 	Iplifc *lifc;
 
 	if(argc < 3)
@@ -630,7 +631,8 @@ ipifcrem(Ipifc *ifc, char **argv, int argc)
  * TRIP linecards
  */
 void
-ipifcaddroute(Fs *f, int vers, uchar *addr, uchar *mask, uchar *gate, int type)
+ipifcaddroute(Fs *f, int vers, uint8_t *addr, uint8_t *mask, uint8_t *gate,
+	      int type)
 {
 	Medium *medium;
 	Conv **cp, **e;
@@ -648,7 +650,7 @@ ipifcaddroute(Fs *f, int vers, uchar *addr, uchar *mask, uchar *gate, int type)
 }
 
 void
-ipifcremroute(Fs *f, int vers, uchar *addr, uchar *mask)
+ipifcremroute(Fs *f, int vers, uint8_t *addr, uint8_t *mask)
 {
 	Medium *medium;
 	Conv **cp, **e;
@@ -670,10 +672,10 @@ ipifcremroute(Fs *f, int vers, uchar *addr, uchar *mask)
  *  addresses.  This is a macro that means, remove all the old interfaces
  *  and add a new one.
  */
-static char*
-ipifcconnect(Conv* c, char **argv, int argc)
+static int8_t*
+ipifcconnect(Conv* c, int8_t **argv, int argc)
 {
-	char *err;
+	int8_t *err;
 	Ipifc *ifc;
 
 	ifc = (Ipifc*)c->ptcl;
@@ -702,8 +704,8 @@ ipifcconnect(Conv* c, char **argv, int argc)
 	return nil;
 }
 
-char*
-ipifcra6(Ipifc *ifc, char **argv, int argc)
+int8_t*
+ipifcra6(Ipifc *ifc, int8_t **argv, int argc)
 {
 	int i, argsleft, vmax = ifc->rp.maxraint, vmin = ifc->rp.minraint;
 
@@ -756,8 +758,8 @@ ipifcra6(Ipifc *ifc, char **argv, int argc)
  *  non-standard control messages.
  *  called with c->car locked.
  */
-static char*
-ipifcctl(Conv* c, char**argv, int argc)
+static int8_t*
+ipifcctl(Conv* c, int8_t**argv, int argc)
 {
 	Ipifc *ifc;
 	int i;
@@ -796,7 +798,7 @@ ipifcctl(Conv* c, char**argv, int argc)
 }
 
 int
-ipifcstats(Proto *ipifc, char *buf, int len)
+ipifcstats(Proto *ipifc, int8_t *buf, int len)
 {
 	return ipstats(ipifc->f, buf, len);
 }
@@ -835,7 +837,7 @@ ipifcinit(Fs *f)
  *	called with c->car locked
  */
 static void
-addselfcache(Fs *f, Ipifc *ifc, Iplifc *lifc, uchar *a, int type)
+addselfcache(Fs *f, Ipifc *ifc, Iplifc *lifc, uint8_t *a, int type)
 {
 	Ipself *p;
 	Iplink *lp;
@@ -906,7 +908,7 @@ static void
 iplinkfree(Iplink *p)
 {
 	Iplink **l, *np;
-	ulong now = NOW;
+	uint32_t now = NOW;
 
 	l = &freeiplink;
 	for(np = *l; np; np = *l){
@@ -926,7 +928,7 @@ static void
 ipselffree(Ipself *p)
 {
 	Ipself **l, *np;
-	ulong now = NOW;
+	uint32_t now = NOW;
 
 	l = &freeipself;
 	for(np = *l; np; np = *l){
@@ -948,7 +950,7 @@ ipselffree(Ipself *p)
  *	called with c->car locked
  */
 static void
-remselfcache(Fs *f, Ipifc *ifc, Iplifc *lifc, uchar *a)
+remselfcache(Fs *f, Ipifc *ifc, Iplifc *lifc, uint8_t *a)
 {
 	Ipself *p, **l;
 	Iplink *link, **l_self, **l_lifc;
@@ -1026,19 +1028,19 @@ out:
 	qunlock(f->self);
 }
 
-static char *stformat = "%-44.44I %2.2d %4.4s\n";
+static int8_t *stformat = "%-44.44I %2.2d %4.4s\n";
 enum
 {
 	Nstformat= 41,
 };
 
-long
-ipselftabread(Fs *f, char *cp, ulong offset, int n)
+int32_t
+ipselftabread(Fs *f, int8_t *cp, uint32_t offset, int n)
 {
 	int i, m, nifc, off;
 	Ipself *p;
 	Iplink *link;
-	char state[8];
+	int8_t state[8];
 
 	m = 0;
 	off = offset;
@@ -1061,7 +1063,7 @@ ipselftabread(Fs *f, char *cp, ulong offset, int n)
 }
 
 int
-iptentative(Fs *f, uchar *addr)
+iptentative(Fs *f, uint8_t *addr)
 {
  	Ipself *p;
 
@@ -1081,7 +1083,7 @@ iptentative(Fs *f, uchar *addr)
  *	Rmcast
  */
 int
-ipforme(Fs *f, uchar *addr)
+ipforme(Fs *f, uint8_t *addr)
 {
 	Ipself *p;
 
@@ -1102,12 +1104,12 @@ ipforme(Fs *f, uchar *addr)
  *  return nil.
  */
 Ipifc*
-findipifc(Fs *f, uchar *remote, int type)
+findipifc(Fs *f, uint8_t *remote, int type)
 {
 	Ipifc *ifc, *x;
 	Iplifc *lifc;
 	Conv **cp, **e;
-	uchar gnet[IPaddrlen], xmask[IPaddrlen];
+	uint8_t gnet[IPaddrlen], xmask[IPaddrlen];
 
 	x = nil;
 	memset(xmask, 0, IPaddrlen);
@@ -1153,7 +1155,7 @@ enum {
 };
 
 int
-v6addrtype(uchar *addr)
+v6addrtype(uint8_t *addr)
 {
 	if(islinklocal(addr) ||
 	    isv6mcast(addr) && (addr[1] & 0xF) <= Link_local_scop)
@@ -1166,7 +1168,7 @@ v6addrtype(uchar *addr)
 			(lifc)->origint + (lifc)->preflt >= NOW/1000)
 
 static void
-findprimaryipv6(Fs *f, uchar *local)
+findprimaryipv6(Fs *f, uint8_t *local)
 {
 	int atype, atypel;
 	Conv **cp, **e;
@@ -1201,7 +1203,7 @@ findprimaryipv6(Fs *f, uchar *local)
  *  returns first ip address configured
  */
 static void
-findprimaryipv4(Fs *f, uchar *local)
+findprimaryipv4(Fs *f, uint8_t *local)
 {
 	Conv **cp, **e;
 	Ipifc *ifc;
@@ -1225,11 +1227,11 @@ findprimaryipv4(Fs *f, uchar *local)
  *  local and return the ifc for that address
  */
 void
-findlocalip(Fs *f, uchar *local, uchar *remote)
+findlocalip(Fs *f, uint8_t *local, uint8_t *remote)
 {
 	int version, atype = unspecifiedv6, atypel = unknownv6;
 	int atyper, deprecated;
-	uchar gate[IPaddrlen], gnet[IPaddrlen];
+	uint8_t gate[IPaddrlen], gnet[IPaddrlen];
 	Ipifc *ifc;
 	Iplifc *lifc;
 	Route *r;
@@ -1310,7 +1312,7 @@ out:
  *  return first v4 address associated with an interface
  */
 int
-ipv4local(Ipifc *ifc, uchar *addr)
+ipv4local(Ipifc *ifc, uint8_t *addr)
 {
 	Iplifc *lifc;
 
@@ -1327,7 +1329,7 @@ ipv4local(Ipifc *ifc, uchar *addr)
  *  return first v6 address associated with an interface
  */
 int
-ipv6local(Ipifc *ifc, uchar *addr)
+ipv6local(Ipifc *ifc, uint8_t *addr)
 {
 	Iplifc *lifc;
 
@@ -1341,7 +1343,7 @@ ipv6local(Ipifc *ifc, uchar *addr)
 }
 
 int
-ipv6anylocal(Ipifc *ifc, uchar *addr)
+ipv6anylocal(Ipifc *ifc, uint8_t *addr)
 {
 	Iplifc *lifc;
 
@@ -1358,7 +1360,7 @@ ipv6anylocal(Ipifc *ifc, uchar *addr)
  *  see if this address is bound to the interface
  */
 Iplifc*
-iplocalonifc(Ipifc *ifc, uchar *ip)
+iplocalonifc(Ipifc *ifc, uint8_t *ip)
 {
 	Iplifc *lifc;
 
@@ -1373,10 +1375,10 @@ iplocalonifc(Ipifc *ifc, uchar *ip)
  *  See if we're proxying for this address on this interface
  */
 int
-ipproxyifc(Fs *f, Ipifc *ifc, uchar *ip)
+ipproxyifc(Fs *f, Ipifc *ifc, uint8_t *ip)
 {
 	Route *r;
-	uchar net[IPaddrlen];
+	uint8_t net[IPaddrlen];
 	Iplifc *lifc;
 
 	/* see if this is a direct connected pt to pt address */
@@ -1397,7 +1399,7 @@ ipproxyifc(Fs *f, Ipifc *ifc, uchar *ip)
  *  return multicast version if any
  */
 int
-ipismulticast(uchar *ip)
+ipismulticast(uint8_t *ip)
 {
 	if(isv4(ip)){
 		if(ip[IPv4off] >= 0xe0 && ip[IPv4off] < 0xf0)
@@ -1408,7 +1410,7 @@ ipismulticast(uchar *ip)
 	return 0;
 }
 int
-ipisbm(uchar *ip)
+ipisbm(uint8_t *ip)
 {
 	if(isv4(ip)){
 		if(ip[IPv4off] >= 0xe0 && ip[IPv4off] < 0xf0)
@@ -1426,7 +1428,7 @@ ipisbm(uchar *ip)
  *  add a multicast address to an interface, called with c->car locked
  */
 void
-ipifcaddmulti(Conv *c, uchar *ma, uchar *ia)
+ipifcaddmulti(Conv *c, uint8_t *ma, uint8_t *ia)
 {
 	Ipifc *ifc;
 	Iplifc *lifc;
@@ -1467,7 +1469,7 @@ ipifcaddmulti(Conv *c, uchar *ma, uchar *ia)
  *  remove a multicast address from an interface, called with c->car locked
  */
 void
-ipifcremmulti(Conv *c, uchar *ma, uchar *ia)
+ipifcremmulti(Conv *c, uint8_t *ma, uint8_t *ia)
 {
 	Ipmulti *multi, **l;
 	Iplifc *lifc;
@@ -1510,28 +1512,28 @@ ipifcremmulti(Conv *c, uchar *ma, uchar *ia)
 /*
  *  make lifc's join and leave multicast groups
  */
-static char*
-ipifcjoinmulti(Ipifc *ifc, char **argv, int argc)
+static int8_t*
+ipifcjoinmulti(Ipifc *ifc, int8_t **argv, int argc)
 {
 	USED(ifc, argv, argc);
 	return nil;
 }
 
-static char*
-ipifcleavemulti(Ipifc *ifc, char **argv, int argc)
+static int8_t*
+ipifcleavemulti(Ipifc *ifc, int8_t **argv, int argc)
 {
 	USED(ifc, argv, argc);
 	return nil;
 }
 
 static void
-ipifcregisterproxy(Fs *f, Ipifc *ifc, uchar *ip)
+ipifcregisterproxy(Fs *f, Ipifc *ifc, uint8_t *ip)
 {
 	Conv **cp, **e;
 	Ipifc *nifc;
 	Iplifc *lifc;
 	Medium *medium;
-	uchar net[IPaddrlen];
+	uint8_t net[IPaddrlen];
 
 	/* register the address on any network that will proxy for us */
 	e = &f->ipifc->conv[f->ipifc->nc];
@@ -1585,7 +1587,7 @@ ipifcregisterproxy(Fs *f, Ipifc *ifc, uchar *ip)
 
 /* added for new v6 mesg types */
 static void
-adddefroute6(Fs *f, uchar *gate, int force)
+adddefroute6(Fs *f, uint8_t *gate, int force)
 {
 	Route *r;
 
@@ -1605,15 +1607,15 @@ enum {
 	Ngates = 3,
 };
 
-char*
-ipifcadd6(Ipifc *ifc, char**argv, int argc)
+int8_t*
+ipifcadd6(Ipifc *ifc, int8_t**argv, int argc)
 {
 	int plen = 64;
-	long origint = NOW / 1000, preflt = ~0L, validlt = ~0L;
-	char addr[40], preflen[6];
-	char *params[3];
-	uchar autoflag = 1, onlink = 1;
-	uchar prefix[IPaddrlen];
+	int32_t origint = NOW / 1000, preflt = ~0L, validlt = ~0L;
+	int8_t addr[40], preflen[6];
+	int8_t *params[3];
+	uint8_t autoflag = 1, onlink = 1;
+	uint8_t prefix[IPaddrlen];
 	Iplifc *lifc;
 
 	switch(argc) {

+ 42 - 39
sys/src/9/ip/iproute.c

@@ -24,7 +24,7 @@ static void	calcd(Route*);
 Route*	v4freelist;
 Route*	v6freelist;
 RWlock	routelock;
-ulong	v4routegeneration, v6routegeneration;
+uint32_t	v4routegeneration, v6routegeneration;
 
 static void
 freeroute(Route *r)
@@ -90,7 +90,7 @@ addqueue(Route **q, Route *r)
  *  compare 2 v6 addresses
  */
 static int
-lcmp(ulong *a, ulong *b)
+lcmp(uint32_t *a, uint32_t *b)
 {
 	int i;
 
@@ -297,12 +297,13 @@ addnode(Fs *f, Route **cur, Route *new)
 #define	V4H(a)	((a&0x07ffffff)>>(32-Lroot-5))
 
 void
-v4addroute(Fs *f, char *tag, uchar *a, uchar *mask, uchar *gate, int type)
+v4addroute(Fs *f, int8_t *tag, uint8_t *a, uint8_t *mask, uint8_t *gate,
+	   int type)
 {
 	Route *p;
-	ulong sa;
-	ulong m;
-	ulong ea;
+	uint32_t sa;
+	uint32_t m;
+	uint32_t ea;
 	int h, eh;
 
 	m = nhgetl(mask);
@@ -335,11 +336,12 @@ v4addroute(Fs *f, char *tag, uchar *a, uchar *mask, uchar *gate, int type)
 #define ISDFLT(a, mask, tag) ((ipcmp((a),v6Unspecified)==0) && (ipcmp((mask),v6Unspecified)==0) && (strcmp((tag), "ra")!=0))
 
 void
-v6addroute(Fs *f, char *tag, uchar *a, uchar *mask, uchar *gate, int type)
+v6addroute(Fs *f, int8_t *tag, uint8_t *a, uint8_t *mask, uint8_t *gate,
+	   int type)
 {
 	Route *p;
-	ulong sa[IPllen], ea[IPllen];
-	ulong x, y;
+	uint32_t sa[IPllen], ea[IPllen];
+	uint32_t x, y;
 	int h, eh;
 
 	/*
@@ -406,12 +408,12 @@ looknode(Route **cur, Route *r)
 }
 
 void
-v4delroute(Fs *f, uchar *a, uchar *mask, int dolock)
+v4delroute(Fs *f, uint8_t *a, uint8_t *mask, int dolock)
 {
 	Route **r, *p;
 	Route rt;
 	int h, eh;
-	ulong m;
+	uint32_t m;
 
 	m = nhgetl(mask);
 	rt.v4.address = nhgetl(a) & m;
@@ -447,12 +449,12 @@ v4delroute(Fs *f, uchar *a, uchar *mask, int dolock)
 }
 
 void
-v6delroute(Fs *f, uchar *a, uchar *mask, int dolock)
+v6delroute(Fs *f, uint8_t *a, uint8_t *mask, int dolock)
 {
 	Route **r, *p;
 	Route rt;
 	int h, eh;
-	ulong x, y;
+	uint32_t x, y;
 
 	for(h = 0; h < IPllen; h++){
 		x = nhgetl(a+4*h);
@@ -491,11 +493,11 @@ v6delroute(Fs *f, uchar *a, uchar *mask, int dolock)
 }
 
 Route*
-v4lookup(Fs *f, uchar *a, Conv *c)
+v4lookup(Fs *f, uint8_t *a, Conv *c)
 {
 	Route *p, *q;
-	ulong la;
-	uchar gate[IPaddrlen];
+	uint32_t la;
+	uint8_t gate[IPaddrlen];
 	Ipifc *ifc;
 
 	if(c != nil && c->r != nil && c->r->ifc != nil && c->rgen == v4routegeneration)
@@ -535,13 +537,13 @@ v4lookup(Fs *f, uchar *a, Conv *c)
 }
 
 Route*
-v6lookup(Fs *f, uchar *a, Conv *c)
+v6lookup(Fs *f, uint8_t *a, Conv *c)
 {
 	Route *p, *q;
-	ulong la[IPllen];
+	uint32_t la[IPllen];
 	int h;
-	ulong x, y;
-	uchar gate[IPaddrlen];
+	uint32_t x, y;
+	uint8_t gate[IPaddrlen];
 	Ipifc *ifc;
 
 	if(memcmp(a, v4prefix, IPv4off) == 0){
@@ -606,7 +608,7 @@ next:		;
 }
 
 void
-routetype(int type, char *p)
+routetype(int type, int8_t *p)
 {
 	memset(p, ' ', 4);
 	p[4] = 0;
@@ -626,10 +628,11 @@ routetype(int type, char *p)
 		*p = 'p';
 }
 
-char *rformat = "%-15I %-4M %-15I %4.4s %4.4s %3s\n";
+int8_t *rformat = "%-15I %-4M %-15I %4.4s %4.4s %3s\n";
 
 void
-convroute(Route *r, uchar *addr, uchar *mask, uchar *gate, char *t, int *nifc)
+convroute(Route *r, uint8_t *addr, uint8_t *mask, uint8_t *gate, int8_t *t,
+          int *nifc)
 {
 	int i;
 
@@ -663,9 +666,9 @@ static void
 sprintroute(Route *r, Routewalk *rw)
 {
 	int nifc, n;
-	char t[5], *iname, ifbuf[5];
-	uchar addr[IPaddrlen], mask[IPaddrlen], gate[IPaddrlen];
-	char *p;
+	int8_t t[5], *iname, ifbuf[5];
+	uint8_t addr[IPaddrlen], mask[IPaddrlen], gate[IPaddrlen];
+	int8_t *p;
 
 	convroute(r, addr, mask, gate, t, &nifc);
 	iname = "-";
@@ -732,8 +735,8 @@ ipwalkroutes(Fs *f, Routewalk *rw)
 	runlock(&routelock);
 }
 
-long
-routeread(Fs *f, char *p, ulong offset, int n)
+int32_t
+routeread(Fs *f, int8_t *p, uint32_t offset, int n)
 {
 	Routewalk rw;
 
@@ -753,10 +756,10 @@ routeread(Fs *f, char *p, ulong offset, int n)
 void
 delroute(Fs *f, Route *r, int dolock)
 {
-	uchar addr[IPaddrlen];
-	uchar mask[IPaddrlen];
-	uchar gate[IPaddrlen];
-	char t[5];
+	uint8_t addr[IPaddrlen];
+	uint8_t mask[IPaddrlen];
+	uint8_t gate[IPaddrlen];
+	int8_t t[5];
 	int nifc;
 
 	convroute(r, addr, mask, gate, t, &nifc);
@@ -771,7 +774,7 @@ delroute(Fs *f, Route *r, int dolock)
  *  returns 0 if nothing is deleted, 1 otherwise
  */
 int
-routeflush(Fs *f, Route *r, char *tag)
+routeflush(Fs *f, Route *r, int8_t *tag)
 {
 	if(r == nil)
 		return 0;
@@ -790,15 +793,15 @@ routeflush(Fs *f, Route *r, char *tag)
 	return 0;
 }
 
-long
-routewrite(Fs *f, Chan *c, char *p, int n)
+int32_t
+routewrite(Fs *f, Chan *c, int8_t *p, int n)
 {
 	int h, changed;
-	char *tag;
+	int8_t *tag;
 	Cmdbuf *cb;
-	uchar addr[IPaddrlen];
-	uchar mask[IPaddrlen];
-	uchar gate[IPaddrlen];
+	uint8_t addr[IPaddrlen];
+	uint8_t mask[IPaddrlen];
+	uint8_t gate[IPaddrlen];
 	IPaux *a, *na;
 
 	cb = parsecmd(p, n);

+ 18 - 18
sys/src/9/ip/ipv6.c

@@ -45,7 +45,7 @@ Fragment6*	ipfragallo6(IP*);
 void		ipfragfree6(IP*, Fragment6*);
 Block*		procopts(Block *bp);
 static Block*	procxtns(IP *ip, Block *bp, int doreasm);
-int		unfraglen(Block *bp, uchar *nexthdr, int setfh);
+int		unfraglen(Block *bp, uint8_t *nexthdr, int setfh);
 
 /* MIB II counters */
 enum
@@ -100,32 +100,32 @@ struct Fragment4
 {
 	Block*	blist;
 	Fragment4*	next;
-	ulong 	src;
-	ulong 	dst;
-	ushort	id;
-	ulong 	age;
+	uint32_t 	src;
+	uint32_t 	dst;
+	uint16_t	id;
+	uint32_t 	age;
 };
 
 struct Fragment6
 {
 	Block*	blist;
 	Fragment6*	next;
-	uchar 	src[IPaddrlen];
-	uchar 	dst[IPaddrlen];
+	uint8_t 	src[IPaddrlen];
+	uint8_t 	dst[IPaddrlen];
 	uint	id;
-	ulong 	age;
+	uint32_t 	age;
 };
 
 struct Ipfrag
 {
-	ushort	foff;
-	ushort	flen;
+	uint16_t	foff;
+	uint16_t	flen;
 };
 
 /* an instance of IP */
 struct IP
 {
-	ulong		stats[Nstats];
+	uint32_t		stats[Nstats];
 
 	QLock		fraglock4;
 	Fragment4*	flisthead4;
@@ -145,7 +145,7 @@ ipoput6(Fs *f, Block *bp, int gating, int ttl, int tos, Conv *c)
 {
 	int medialen, len, chunk, uflen, flen, seglen, lid, offset, fragoff;
 	int morefrags, blklen, rv = 0, tentative;
-	uchar *gate, nexthdr;
+	uint8_t *gate, nexthdr;
 	Block *xp, *nb;
 	Fraghdr6 fraghdr;
 	IP *ip;
@@ -339,8 +339,8 @@ void
 ipiput6(Fs *f, Ipifc *ifc, Block *bp)
 {
 	int hl, hop, tos, notforme, tentative;
-	uchar proto;
-	uchar v6dst[IPaddrlen];
+	uint8_t proto;
+	uint8_t v6dst[IPaddrlen];
 	IP *ip;
 	Ip6hdr *h;
 	Proto *p;
@@ -506,7 +506,7 @@ static Block*
 procxtns(IP *ip, Block *bp, int doreasm)
 {
 	int offset;
-	uchar proto;
+	uint8_t proto;
 	Ip6hdr *h;
 
 	h = (Ip6hdr *)bp->rp;
@@ -531,9 +531,9 @@ procxtns(IP *ip, Block *bp, int doreasm)
  * field of the last header in the "Unfragmentable part" is set to FH.
  */
 int
-unfraglen(Block *bp, uchar *nexthdr, int setfh)
+unfraglen(Block *bp, uint8_t *nexthdr, int setfh)
 {
-	uchar *p, *q;
+	uint8_t *p, *q;
 	int ufl, hs;
 
 	p = bp->rp;
@@ -572,7 +572,7 @@ ip6reassemble(IP* ip, int uflen, Block* bp, Ip6hdr* ih)
 {
 	int fend, offset, ovlap, len, fragsize, pktposn;
 	uint id;
-	uchar src[IPaddrlen], dst[IPaddrlen];
+	uint8_t src[IPaddrlen], dst[IPaddrlen];
 	Block *bl, **l, *last, *prev;
 	Fraghdr6 *fraghdr;
 	Fragment6 *f, *fnext;

+ 2 - 2
sys/src/9/ip/loopbackmedium.c

@@ -32,7 +32,7 @@ struct LB
 static void loopbackread(void *a);
 
 static void
-loopbackbind(Ipifc *ifc, int, char**)
+loopbackbind(Ipifc *ifc, int, int8_t**)
 {
 	LB *lb;
 
@@ -64,7 +64,7 @@ loopbackunbind(Ipifc *ifc)
 }
 
 static void
-loopbackbwrite(Ipifc *ifc, Block *bp, int, uchar*)
+loopbackbwrite(Ipifc *ifc, Block *bp, int, uint8_t*)
 {
 	LB *lb;
 

+ 6 - 5
sys/src/9/ip/netdevmedium.c

@@ -16,9 +16,10 @@
 
 #include "ip.h"
 
-static void	netdevbind(Ipifc *ifc, int argc, char **argv);
+static void	netdevbind(Ipifc *ifc, int argc, int8_t **argv);
 static void	netdevunbind(Ipifc *ifc);
-static void	netdevbwrite(Ipifc *ifc, Block *bp, int version, uchar *ip);
+static void	netdevbwrite(Ipifc *ifc, Block *bp, int version,
+				uint8_t *ip);
 static void	netdevread(void *a);
 
 typedef struct	Netdevrock Netdevrock;
@@ -47,7 +48,7 @@ Medium netdevmedium =
  *  called with ifc qlock'd
  */
 static void
-netdevbind(Ipifc *ifc, int argc, char **argv)
+netdevbind(Ipifc *ifc, int argc, int8_t **argv)
 {
 	Chan *mchan;
 	Netdevrock *er;
@@ -91,7 +92,7 @@ netdevunbind(Ipifc *ifc)
  *  called by ipoput with a single block to write
  */
 static void
-netdevbwrite(Ipifc *ifc, Block *bp, int, uchar*)
+netdevbwrite(Ipifc *ifc, Block *bp, int, uint8_t*)
 {
 	Netdevrock *er = ifc->arg;
 
@@ -113,7 +114,7 @@ netdevread(void *a)
 	Ipifc *ifc;
 	Block *bp;
 	Netdevrock *er;
-	char *argv[1];
+	int8_t *argv[1];
 
 	ifc = a;
 	er = ifc->arg;

+ 8 - 8
sys/src/9/ip/netlog.c

@@ -39,7 +39,7 @@ struct Netlog {
 };
 
 typedef struct Netlogflag {
-	char*	name;
+	int8_t*	name;
 	int	mask;
 } Netlogflag;
 
@@ -63,7 +63,7 @@ static Netlogflag flags[] =
 	{ nil,		0, },
 };
 
-char Ebadnetctl[] = "too few arguments for netlog control message";
+int8_t Ebadnetctl[] = "too few arguments for netlog control message";
 
 enum
 {
@@ -129,11 +129,11 @@ netlogready(void *a)
 	return f->alog->len;
 }
 
-long
-netlogread(Fs *f, void *a, ulong, long n)
+int32_t
+netlogread(Fs *f, void *a, uint32_t, int32_t n)
 {
 	int i, d;
-	char *p, *rptr;
+	int8_t *p, *rptr;
 
 	qlock(f->alog);
 	if(waserror()){
@@ -175,7 +175,7 @@ netlogread(Fs *f, void *a, ulong, long n)
 }
 
 void
-netlogctl(Fs *f, char* s, int n)
+netlogctl(Fs *f, int8_t* s, int n)
 {
 	int i, set;
 	Netlogflag *fp;
@@ -234,9 +234,9 @@ netlogctl(Fs *f, char* s, int n)
 }
 
 void
-netlog(Fs *f, int mask, char *fmt, ...)
+netlog(Fs *f, int mask, int8_t *fmt, ...)
 {
-	char buf[128], *t, *fp;
+	int8_t buf[128], *t, *fp;
 	int i, n;
 	va_list arg;
 

+ 2 - 2
sys/src/9/ip/nullmedium.c

@@ -17,7 +17,7 @@
 #include "ip.h"
 
 static void
-nullbind(Ipifc*, int, char**)
+nullbind(Ipifc*, int, int8_t**)
 {
 	error("cannot bind null device");
 }
@@ -28,7 +28,7 @@ nullunbind(Ipifc*)
 }
 
 static void
-nullbwrite(Ipifc*, Block*, int, uchar*)
+nullbwrite(Ipifc*, Block*, int, uint8_t*)
 {
 	error("nullbwrite");
 }

+ 4 - 4
sys/src/9/ip/pktmedium.c

@@ -17,9 +17,9 @@
 #include "ip.h"
 
 
-static void	pktbind(Ipifc*, int, char**);
+static void	pktbind(Ipifc*, int, int8_t**);
 static void	pktunbind(Ipifc*);
-static void	pktbwrite(Ipifc*, Block*, int, uchar*);
+static void	pktbwrite(Ipifc*, Block*, int, uint8_t*);
 static void	pktin(Fs*, Ipifc*, Block*);
 
 Medium pktmedium =
@@ -41,7 +41,7 @@ Medium pktmedium =
  *  called with ifc wlock'd
  */
 static void
-pktbind(Ipifc*, int, char**)
+pktbind(Ipifc*, int, int8_t**)
 {
 }
 
@@ -57,7 +57,7 @@ pktunbind(Ipifc*)
  *  called by ipoput with a single packet to write
  */
 static void
-pktbwrite(Ipifc *ifc, Block *bp, int, uchar*)
+pktbwrite(Ipifc *ifc, Block *bp, int, uint8_t*)
 {
 	/* enqueue onto the conversation's rq */
 	bp = concatblock(bp);

+ 15 - 15
sys/src/9/ip/ptclbsum.c

@@ -15,15 +15,15 @@
 #include	"../port/error.h"
 #include	"ip.h"
 
-static	short	endian	= 1;
-static	uchar*	aendian	= (uchar*)&endian;
+static	int16_t	endian	= 1;
+static	uint8_t*	aendian	= (uint8_t*)&endian;
 #define	LITTLE	*aendian
 
-ushort
-ptclbsum(uchar *addr, int len)
+uint16_t
+ptclbsum(uint8_t *addr, int len)
 {
-	ulong losum, hisum, mdsum, x;
-	ulong t1, t2;
+	uint32_t losum, hisum, mdsum, x;
+	uint32_t t1, t2;
 
 	losum = 0;
 	hisum = 0;
@@ -39,20 +39,20 @@ ptclbsum(uchar *addr, int len)
 		x = 1;
 	}
 	while(len >= 16) {
-		t1 = *(ushort*)(addr+0);
-		t2 = *(ushort*)(addr+2);	mdsum += t1;
-		t1 = *(ushort*)(addr+4);	mdsum += t2;
-		t2 = *(ushort*)(addr+6);	mdsum += t1;
-		t1 = *(ushort*)(addr+8);	mdsum += t2;
-		t2 = *(ushort*)(addr+10);	mdsum += t1;
-		t1 = *(ushort*)(addr+12);	mdsum += t2;
-		t2 = *(ushort*)(addr+14);	mdsum += t1;
+		t1 = *(uint16_t*)(addr+0);
+		t2 = *(uint16_t*)(addr+2);	mdsum += t1;
+		t1 = *(uint16_t*)(addr+4);	mdsum += t2;
+		t2 = *(uint16_t*)(addr+6);	mdsum += t1;
+		t1 = *(uint16_t*)(addr+8);	mdsum += t2;
+		t2 = *(uint16_t*)(addr+10);	mdsum += t1;
+		t1 = *(uint16_t*)(addr+12);	mdsum += t2;
+		t2 = *(uint16_t*)(addr+14);	mdsum += t1;
 		mdsum += t2;
 		len -= 16;
 		addr += 16;
 	}
 	while(len >= 2) {
-		mdsum += *(ushort*)addr;
+		mdsum += *(uint16_t*)addr;
 		len -= 2;
 		addr += 2;
 	}

+ 162 - 160
sys/src/9/ip/tcp.c

@@ -94,7 +94,7 @@ enum
 };
 
 /* Must correspond to the enumeration above */
-char *tcpstates[] =
+int8_t *tcpstates[] =
 {
 	"Closed", 	"Listen", 	"Syn_sent", "Syn_received",
 	"Established", 	"Finwait1",	"Finwait2", "Close_wait",
@@ -121,47 +121,47 @@ struct Tcptimer
 typedef struct Tcp4hdr Tcp4hdr;
 struct Tcp4hdr
 {
-	uchar	vihl;		/* Version and header length */
-	uchar	tos;		/* Type of service */
-	uchar	length[2];	/* packet length */
-	uchar	id[2];		/* Identification */
-	uchar	frag[2];	/* Fragment information */
-	uchar	Unused;
-	uchar	proto;
-	uchar	tcplen[2];
-	uchar	tcpsrc[4];
-	uchar	tcpdst[4];
-	uchar	tcpsport[2];
-	uchar	tcpdport[2];
-	uchar	tcpseq[4];
-	uchar	tcpack[4];
-	uchar	tcpflag[2];
-	uchar	tcpwin[2];
-	uchar	tcpcksum[2];
-	uchar	tcpurg[2];
+	uint8_t	vihl;		/* Version and header length */
+	uint8_t	tos;		/* Type of service */
+	uint8_t	length[2];	/* packet length */
+	uint8_t	id[2];		/* Identification */
+	uint8_t	frag[2];	/* Fragment information */
+	uint8_t	Unused;
+	uint8_t	proto;
+	uint8_t	tcplen[2];
+	uint8_t	tcpsrc[4];
+	uint8_t	tcpdst[4];
+	uint8_t	tcpsport[2];
+	uint8_t	tcpdport[2];
+	uint8_t	tcpseq[4];
+	uint8_t	tcpack[4];
+	uint8_t	tcpflag[2];
+	uint8_t	tcpwin[2];
+	uint8_t	tcpcksum[2];
+	uint8_t	tcpurg[2];
 	/* Options segment */
-	uchar	tcpopt[1];
+	uint8_t	tcpopt[1];
 };
 
 typedef struct Tcp6hdr Tcp6hdr;
 struct Tcp6hdr
 {
-	uchar	vcf[4];
-	uchar	ploadlen[2];
-	uchar	proto;
-	uchar	ttl;
-	uchar	tcpsrc[IPaddrlen];
-	uchar	tcpdst[IPaddrlen];
-	uchar	tcpsport[2];
-	uchar	tcpdport[2];
-	uchar	tcpseq[4];
-	uchar	tcpack[4];
-	uchar	tcpflag[2];
-	uchar	tcpwin[2];
-	uchar	tcpcksum[2];
-	uchar	tcpurg[2];
+	uint8_t	vcf[4];
+	uint8_t	ploadlen[2];
+	uint8_t	proto;
+	uint8_t	ttl;
+	uint8_t	tcpsrc[IPaddrlen];
+	uint8_t	tcpdst[IPaddrlen];
+	uint8_t	tcpsport[2];
+	uint8_t	tcpdport[2];
+	uint8_t	tcpseq[4];
+	uint8_t	tcpack[4];
+	uint8_t	tcpflag[2];
+	uint8_t	tcpwin[2];
+	uint8_t	tcpcksum[2];
+	uint8_t	tcpurg[2];
 	/* Options segment */
-	uchar	tcpopt[1];
+	uint8_t	tcpopt[1];
 };
 
 /*
@@ -173,16 +173,16 @@ struct Tcp6hdr
 typedef struct Tcp Tcp;
 struct	Tcp
 {
-	ushort	source;
-	ushort	dest;
-	ulong	seq;
-	ulong	ack;
-	uchar	flags;
-	ushort	ws;	/* window scale option (if not zero) */
-	ulong	wnd;
-	ushort	urg;
-	ushort	mss;	/* max segment size option (if not zero) */
-	ushort	len;	/* size of data */
+	uint16_t	source;
+	uint16_t	dest;
+	uint32_t	seq;
+	uint32_t	ack;
+	uint8_t	flags;
+	uint16_t	ws;	/* window scale option (if not zero) */
+	uint32_t	wnd;
+	uint16_t	urg;
+	uint16_t	mss;	/* max segment size option (if not zero) */
+	uint16_t	len;	/* size of data */
 };
 
 /*
@@ -195,7 +195,7 @@ struct Reseq
 	Reseq	*next;
 	Tcp	seg;
 	Block	*bp;
-	ushort	length;
+	uint16_t	length;
 };
 
 /*
@@ -204,55 +204,55 @@ struct Reseq
 typedef struct Tcpctl Tcpctl;
 struct Tcpctl
 {
-	uchar	state;			/* Connection state */
-	uchar	type;			/* Listening or active connection */
-	uchar	code;			/* Icmp code */
+	uint8_t	state;			/* Connection state */
+	uint8_t	type;			/* Listening or active connection */
+	uint8_t	code;			/* Icmp code */
 	struct {
-		ulong	una;		/* Unacked data pointer */
-		ulong	nxt;		/* Next sequence expected */
-		ulong	ptr;		/* Data pointer */
-		ulong	wnd;		/* Tcp send window */
-		ulong	urg;		/* Urgent data pointer */
-		ulong	wl2;
+		uint32_t	una;		/* Unacked data pointer */
+		uint32_t	nxt;		/* Next sequence expected */
+		uint32_t	ptr;		/* Data pointer */
+		uint32_t	wnd;		/* Tcp send window */
+		uint32_t	urg;		/* Urgent data pointer */
+		uint32_t	wl2;
 		int	scale;		/* how much to right shift window in xmitted packets */
 		/* to implement tahoe and reno TCP */
-		ulong	dupacks;	/* number of duplicate acks rcvd */
+		uint32_t	dupacks;	/* number of duplicate acks rcvd */
 		int	recovery;	/* loss recovery flag */
-		ulong	rxt;		/* right window marker for recovery */
+		uint32_t	rxt;		/* right window marker for recovery */
 	} snd;
 	struct {
-		ulong	nxt;		/* Receive pointer to next uchar slot */
-		ulong	wnd;		/* Receive window incoming */
-		ulong	urg;		/* Urgent pointer */
+		uint32_t	nxt;		/* Receive pointer to next uchar slot */
+		uint32_t	wnd;		/* Receive window incoming */
+		uint32_t	urg;		/* Urgent pointer */
 		int	blocked;
 		int	una;		/* unacked data segs, for delayed acks */
 		int	scale;		/* how much to left shift window in rcved packets */
 	} rcv;
-	ulong	iss;			/* Initial sequence number */
+	uint32_t	iss;			/* Initial sequence number */
 	int	sawwsopt;		/* true if we saw a wsopt on the incoming SYN */
-	ulong	cwind;			/* Congestion window */
-	ulong	abcbytes;		/* appropriate byte counting */
+	uint32_t	cwind;			/* Congestion window */
+	uint32_t	abcbytes;		/* appropriate byte counting */
 	int	scale;			/* desired snd.scale */
-	ulong	ssthresh;		/* Slow start threshold */
+	uint32_t	ssthresh;		/* Slow start threshold */
 	int	resent;			/* Bytes just resent */
 	int	irs;			/* Initial received squence */
-	ushort	mss;			/* Mean segment size */
+	uint16_t	mss;			/* Mean segment size */
 	int	rerecv;			/* Overlap of data rerecevived */
-	ulong	window;			/* Recevive window */
-	uchar	backoff;		/* Exponential backoff counter */
+	uint32_t	window;			/* Recevive window */
+	uint8_t	backoff;		/* Exponential backoff counter */
 	int	backedoff;		/* ms we've backed off for rexmits */
-	uchar	flags;			/* State flags */
+	uint8_t	flags;			/* State flags */
 	Reseq	*reseq;			/* Resequencing queue */
 	Tcptimer	timer;			/* Activity timer */
 	Tcptimer	acktimer;		/* Acknowledge timer */
 	Tcptimer	rtt_timer;		/* Round trip timer */
 	Tcptimer	katimer;		/* keep alive timer */
-	ulong	rttseq;			/* Round trip sequence */
+	uint32_t	rttseq;			/* Round trip sequence */
 	int	srtt;			/* Shortened round trip */
 	int	mdev;			/* Mean deviation of round trip */
 	int	kacounter;		/* count down for keep alive */
 	uint	sndsyntime;		/* time syn sent */
-	ulong	time;			/* time Finwait2 or Syn_received was sent */
+	uint32_t	time;			/* time Finwait2 or Syn_received was sent */
 	int	nochecksum;		/* non-zero means don't send checksums */
 	int	flgcnt;			/* number of flags in the sequence (FIN,SEQ) */
 
@@ -280,22 +280,22 @@ struct Limbo
 {
 	Limbo	*next;
 
-	uchar	laddr[IPaddrlen];
-	uchar	raddr[IPaddrlen];
-	ushort	lport;
-	ushort	rport;
-	ulong	irs;		/* initial received sequence */
-	ulong	iss;		/* initial sent sequence */
-	ushort	mss;		/* mss from the other end */
-	ushort	rcvscale;	/* how much to scale rcvd windows */
-	ushort	sndscale;	/* how much to scale sent windows */
-	ulong	lastsend;	/* last time we sent a synack */
-	uchar	version;	/* v4 or v6 */
-	uchar	rexmits;	/* number of retransmissions */
+	uint8_t	laddr[IPaddrlen];
+	uint8_t	raddr[IPaddrlen];
+	uint16_t	lport;
+	uint16_t	rport;
+	uint32_t	irs;		/* initial received sequence */
+	uint32_t	iss;		/* initial sent sequence */
+	uint16_t	mss;		/* mss from the other end */
+	uint16_t	rcvscale;	/* how much to scale rcvd windows */
+	uint16_t	sndscale;	/* how much to scale sent windows */
+	uint32_t	lastsend;	/* last time we sent a synack */
+	uint8_t	version;	/* v4 or v6 */
+	uint8_t	rexmits;	/* number of retransmissions */
 };
 
 int	tcp_irtt = DEF_RTT;	/* Initial guess at round trip time */
-ushort	tcp_mss = DEF_MSS;	/* Maximum segment size to be sent */
+uint16_t	tcp_mss = DEF_MSS;	/* Maximum segment size to be sent */
 
 enum {
 	/* MIB stats */
@@ -357,7 +357,7 @@ struct Tcppriv
 	QLock	apl;
 	int	ackprocstarted;
 
-	ulong	stats[Nstats];
+	uint32_t	stats[Nstats];
 };
 
 /*
@@ -371,9 +371,9 @@ struct Tcppriv
  */
 int tcpporthogdefense = 0;
 
-static int addreseq(Tcpctl*, Tcppriv*, Tcp*, Block*, ushort);
-static void getreseq(Tcpctl*, Tcp*, Block**, ushort*);
-static void localclose(Conv*, char*);
+static int addreseq(Tcpctl*, Tcppriv*, Tcp*, Block*, uint16_t);
+static void getreseq(Tcpctl*, Tcp*, Block**, uint16_t*);
+static void localclose(Conv*, int8_t*);
 static void procsyn(Conv*, Tcp*);
 static void tcpacktimer(void*);
 static void tcpiput(Proto*, Ipifc*, Block*);
@@ -382,22 +382,22 @@ static void tcpoutput(Conv*);
 static void tcprcvwin(Conv*);
 static void tcprxmit(Conv*);
 static void tcpsetkacounter(Tcpctl*);
-static void tcpsetscale(Conv*, Tcpctl*, ushort, ushort);
+static void tcpsetscale(Conv*, Tcpctl*, uint16_t, uint16_t);
 static void tcpsettimer(Tcpctl*);
 static void tcpsndsyn(Conv*, Tcpctl*);
 static void tcpstart(Conv*, int);
 static void tcpsynackrtt(Conv*);
 static void tcptimeout(void*);
-static int tcptrim(Tcpctl*, Tcp*, Block**, ushort*);
+static int tcptrim(Tcpctl*, Tcp*, Block**, uint16_t*);
 
 static void limborexmit(Proto*);
-static void limbo(Conv*, uchar*, uchar*, Tcp*, int);
+static void limbo(Conv*, uint8_t*, uint8_t*, Tcp*, int);
 
 static void
-tcpsetstate(Conv *s, uchar newstate)
+tcpsetstate(Conv *s, uint8_t newstate)
 {
 	Tcpctl *tcb;
-	uchar oldstate;
+	uint8_t oldstate;
 	Tcppriv *tpriv;
 
 	tpriv = s->p->priv;
@@ -431,10 +431,10 @@ tcpsetstate(Conv *s, uchar newstate)
 		Fsconnected(s, nil);
 }
 
-static char*
-tcpconnect(Conv *c, char **argv, int argc)
+static int8_t*
+tcpconnect(Conv *c, int8_t **argv, int argc)
 {
-	char *e;
+	int8_t *e;
 	Tcpctl *tcb;
 
 	tcb = (Tcpctl*)(c->ptcl);
@@ -450,7 +450,7 @@ tcpconnect(Conv *c, char **argv, int argc)
 }
 
 static int
-tcpstate(Conv *c, char *state, int n)
+tcpstate(Conv *c, int8_t *state, int n)
 {
 	Tcpctl *tcb;
 
@@ -478,10 +478,10 @@ tcpinuse(Conv *c)
 	return tcb->state != Closed;
 }
 
-static char*
-tcpannounce(Conv *c, char **argv, int argc)
+static int8_t*
+tcpannounce(Conv *c, int8_t **argv, int argc)
 {
-	char *e;
+	int8_t *e;
 	Tcpctl *tcb;
 
 	tcb = (Tcpctl*)(c->ptcl);
@@ -634,7 +634,7 @@ tcpwqsize(int maxwin)
 static void
 tcplimitmaxburst(Tcpctl *tcb)
 {
-	ulong cwindmax;
+	uint32_t cwindmax;
 	cwindmax = tcb->snd.nxt - tcb->snd.una + 3*tcb->mss;
 	if(tcb->cwind > cwindmax){
 		if(tcb->ssthresh < tcb->cwind)
@@ -646,7 +646,7 @@ tcplimitmaxburst(Tcpctl *tcb)
 static void
 tcpcongestion(Tcpctl *tcb)
 {
-	ulong inflight;
+	uint32_t inflight;
 	inflight = tcb->snd.nxt - tcb->snd.una;
 	if(inflight > tcb->cwind)
 		inflight = tcb->cwind;
@@ -656,7 +656,7 @@ tcpcongestion(Tcpctl *tcb)
 }
 
 static void
-tcpabcincr(Tcpctl *tcb, ulong acked, ulong limit)
+tcpabcincr(Tcpctl *tcb, uint32_t acked, uint32_t limit)
 {
 	tcb->abcbytes += acked;
 	if(tcb->abcbytes >= limit){
@@ -781,7 +781,7 @@ backoff(int n)
 }
 
 static void
-localclose(Conv *s, char *reason)	/* called with tcb locked */
+localclose(Conv *s, int8_t *reason)	/* called with tcb locked */
 {
 	Tcpctl *tcb;
 	Reseq *rp,*rp1;
@@ -818,7 +818,7 @@ localclose(Conv *s, char *reason)	/* called with tcb locked */
 
 /* mtu (- TCP + IP hdr len) of 1st hop */
 static int
-tcpmtu(Proto *tcp, uchar *addr, int version, int *scale)
+tcpmtu(Proto *tcp, uint8_t *addr, int version, int *scale)
 {
 	Ipifc *ifc;
 	int mtu;
@@ -932,7 +932,7 @@ tcpstart(Conv *s, int mode)
 {
 	Tcpctl *tcb;
 	Tcppriv *tpriv;
-	char kpname[KNAMELEN];
+	int8_t kpname[KNAMELEN];
 
 	tpriv = s->p->priv;
 
@@ -968,10 +968,10 @@ tcpstart(Conv *s, int mode)
 	}
 }
 
-static char*
-tcpflag(ushort flag)
+static int8_t*
+tcpflag(uint16_t flag)
 {
-	static char buf[128];
+	static int8_t buf[128];
 
 	sprint(buf, "%d", flag>>10);	/* Head len */
 	if(flag & URG)
@@ -995,9 +995,9 @@ htontcp6(Tcp *tcph, Block *data, Tcp6hdr *ph, Tcpctl *tcb)
 {
 	int dlen;
 	Tcp6hdr *h;
-	ushort csum;
-	ushort hdrlen, optpad = 0;
-	uchar *opt;
+	uint16_t csum;
+	uint16_t hdrlen, optpad = 0;
+	uint8_t *opt;
 
 	hdrlen = TCP6_HDRSIZE;
 	if(tcph->flags & SYN){
@@ -1079,9 +1079,9 @@ htontcp4(Tcp *tcph, Block *data, Tcp4hdr *ph, Tcpctl *tcb)
 {
 	int dlen;
 	Tcp4hdr *h;
-	ushort csum;
-	ushort hdrlen, optpad = 0;
-	uchar *opt;
+	uint16_t csum;
+	uint16_t hdrlen, optpad = 0;
+	uint8_t *opt;
 
 	hdrlen = TCP4_HDRSIZE;
 	if(tcph->flags & SYN){
@@ -1152,9 +1152,9 @@ static int
 ntohtcp6(Tcp *tcph, Block **bpp)
 {
 	Tcp6hdr *h;
-	uchar *optr;
-	ushort hdrlen;
-	ushort optlen;
+	uint8_t *optr;
+	uint16_t hdrlen;
+	uint16_t optlen;
 	int n;
 
 	*bpp = pullupblock(*bpp, TCP6_PKT+TCP6_HDRSIZE);
@@ -1214,9 +1214,9 @@ static int
 ntohtcp4(Tcp *tcph, Block **bpp)
 {
 	Tcp4hdr *h;
-	uchar *optr;
-	ushort hdrlen;
-	ushort optlen;
+	uint8_t *optr;
+	uint16_t hdrlen;
+	uint16_t optlen;
 	int n;
 
 	*bpp = pullupblock(*bpp, TCP4_PKT+TCP4_HDRSIZE);
@@ -1295,10 +1295,12 @@ tcpsndsyn(Conv *s, Tcpctl *tcb)
 }
 
 void
-sndrst(Proto *tcp, uchar *source, uchar *dest, ushort length, Tcp *seg, uchar version, char *reason)
+sndrst(Proto *tcp, uint8_t *source, uint8_t *dest, uint16_t length,
+       Tcp *seg,
+       uint8_t version, int8_t *reason)
 {
 	Block *hbp;
-	uchar rflags;
+	uint8_t rflags;
 	Tcppriv *tpriv;
 	Tcp4hdr ph4;
 	Tcp6hdr ph6;
@@ -1381,7 +1383,7 @@ sndrst(Proto *tcp, uchar *source, uchar *dest, ushort length, Tcp *seg, uchar ve
  *  send a reset to the remote side and close the conversation
  *  called with s qlocked
  */
-static char*
+static int8_t*
 tcphangup(Conv *s)
 {
 	Tcp seg;
@@ -1505,7 +1507,7 @@ sndsynack(Proto *tcp, Limbo *lp)
  *  called with proto locked
  */
 static void
-limbo(Conv *s, uchar *source, uchar *dest, Tcp *seg, int version)
+limbo(Conv *s, uint8_t *source, uint8_t *dest, Tcp *seg, int version)
 {
 	Limbo *lp, **l;
 	Tcppriv *tpriv;
@@ -1568,7 +1570,7 @@ limborexmit(Proto *tcp)
 	Limbo **l, *lp;
 	int h;
 	int seen;
-	ulong now;
+	uint32_t now;
 
 	tpriv = tcp->priv;
 
@@ -1614,7 +1616,7 @@ limborexmit(Proto *tcp)
  *  called with proto locked
  */
 static void
-limborst(Conv *s, Tcp *segp, uchar *src, uchar *dst, uchar version)
+limborst(Conv *s, Tcp *segp, uint8_t *src, uint8_t *dst, uint8_t version)
 {
 	Limbo *lp, **l;
 	int h;
@@ -1650,7 +1652,7 @@ limborst(Conv *s, Tcp *segp, uchar *src, uchar *dst, uchar version)
  *  called with proto locked
  */
 static Conv*
-tcpincoming(Conv *s, Tcp *segp, uchar *src, uchar *dst, uchar version)
+tcpincoming(Conv *s, Tcp *segp, uint8_t *src, uint8_t *dst, uint8_t version)
 {
 	Conv *new;
 	Tcpctl *tcb;
@@ -1774,7 +1776,7 @@ tcpincoming(Conv *s, Tcp *segp, uchar *src, uchar *dst, uchar version)
 }
 
 static int
-seq_within(ulong x, ulong low, ulong high)
+seq_within(uint32_t x, uint32_t low, uint32_t high)
 {
 	if(low <= high){
 		if(low <= x && x <= high)
@@ -1788,25 +1790,25 @@ seq_within(ulong x, ulong low, ulong high)
 }
 
 static int
-seq_lt(ulong x, ulong y)
+seq_lt(uint32_t x, uint32_t y)
 {
 	return (int)(x-y) < 0;
 }
 
 static int
-seq_le(ulong x, ulong y)
+seq_le(uint32_t x, uint32_t y)
 {
 	return (int)(x-y) <= 0;
 }
 
 static int
-seq_gt(ulong x, ulong y)
+seq_gt(uint32_t x, uint32_t y)
 {
 	return (int)(x-y) > 0;
 }
 
 static int
-seq_ge(ulong x, ulong y)
+seq_ge(uint32_t x, uint32_t y)
 {
 	return (int)(x-y) >= 0;
 }
@@ -1838,7 +1840,7 @@ update(Conv *s, Tcp *seg)
 {
 	int rtt, delta;
 	Tcpctl *tcb;
-	ulong acked;
+	uint32_t acked;
 	Tcppriv *tpriv;
 
 	tpriv = s->p->priv;
@@ -1980,12 +1982,12 @@ tcpiput(Proto *tcp, Ipifc*, Block *bp)
 	Tcp6hdr *h6;
 	int hdrlen;
 	Tcpctl *tcb;
-	ushort length;
-	uchar source[IPaddrlen], dest[IPaddrlen];
+	uint16_t length;
+	uint8_t source[IPaddrlen], dest[IPaddrlen];
 	Conv *s;
 	Fs *f;
 	Tcppriv *tpriv;
-	uchar version;
+	uint8_t version;
 
 	f = tcp->f;
 	tpriv = tcp->priv;
@@ -2465,10 +2467,10 @@ tcpoutput(Conv *s)
 	Tcpctl *tcb;
 	Block *hbp, *bp;
 	int sndcnt;
-	ulong ssize, dsize, sent;
+	uint32_t ssize, dsize, sent;
 	Fs *f;
 	Tcppriv *tpriv;
-	uchar version;
+	uint8_t version;
 
 	f = s->p->f;
 	tpriv = s->p->priv;
@@ -2757,8 +2759,8 @@ tcpkeepalive(void *v)
 /*
  *  start keepalive timer
  */
-static char*
-tcpstartka(Conv *s, char **f, int n)
+static int8_t*
+tcpstartka(Conv *s, int8_t **f, int n)
 {
 	Tcpctl *tcb;
 	int x;
@@ -2780,8 +2782,8 @@ tcpstartka(Conv *s, char **f, int n)
 /*
  *  turn checksums on/off
  */
-static char*
-tcpsetchecksum(Conv *s, char **f, int)
+static int8_t*
+tcpsetchecksum(Conv *s, int8_t **f, int)
 {
 	Tcpctl *tcb;
 
@@ -2799,7 +2801,7 @@ static void
 tcprxmit(Conv *s)
 {
 	Tcpctl *tcb;
-	ulong tcwind, tptr;
+	uint32_t tcwind, tptr;
 	tcb = (Tcpctl*)s->ptcl;
 	tcb->flags |= RETRAN|FORCE;
 
@@ -2902,7 +2904,7 @@ procsyn(Conv *s, Tcp *seg)
 }
 
 static int
-addreseq(Tcpctl *tcb, Tcppriv *tpriv, Tcp *seg, Block *bp, ushort length)
+addreseq(Tcpctl *tcb, Tcppriv *tpriv, Tcp *seg, Block *bp, uint16_t length)
 {
 	Reseq *rp, *rp1;
 	int i, rqlen, qmax;
@@ -2969,7 +2971,7 @@ addreseq(Tcpctl *tcb, Tcppriv *tpriv, Tcp *seg, Block *bp, ushort length)
 }
 
 static void
-getreseq(Tcpctl *tcb, Tcp *seg, Block **bp, ushort *length)
+getreseq(Tcpctl *tcb, Tcp *seg, Block **bp, uint16_t *length)
 {
 	Reseq *rp;
 
@@ -2987,10 +2989,10 @@ getreseq(Tcpctl *tcb, Tcp *seg, Block **bp, ushort *length)
 }
 
 static int
-tcptrim(Tcpctl *tcb, Tcp *seg, Block **bp, ushort *length)
+tcptrim(Tcpctl *tcb, Tcp *seg, Block **bp, uint16_t *length)
 {
-	ushort len;
-	uchar accept;
+	uint16_t len;
+	uint8_t accept;
 	int dupcnt, excess;
 
 	accept = 0;
@@ -3033,7 +3035,7 @@ tcptrim(Tcpctl *tcb, Tcp *seg, Block **bp, ushort *length)
 			dupcnt--;
 		}
 		if(dupcnt > 0){
-			pullblock(bp, (ushort)dupcnt);
+			pullblock(bp, (uint16_t)dupcnt);
 			seg->seq += dupcnt;
 			*length -= dupcnt;
 
@@ -3058,14 +3060,14 @@ tcptrim(Tcpctl *tcb, Tcp *seg, Block **bp, ushort *length)
 }
 
 static void
-tcpadvise(Proto *tcp, Block *bp, char *msg)
+tcpadvise(Proto *tcp, Block *bp, int8_t *msg)
 {
 	Tcp4hdr *h4;
 	Tcp6hdr *h6;
 	Tcpctl *tcb;
-	uchar source[IPaddrlen];
-	uchar dest[IPaddrlen];
-	ushort psource, pdest;
+	uint8_t source[IPaddrlen];
+	uint8_t dest[IPaddrlen];
+	uint16_t psource, pdest;
 	Conv *s, **p;
 
 	h4 = (Tcp4hdr*)(bp->rp);
@@ -3110,8 +3112,8 @@ tcpadvise(Proto *tcp, Block *bp, char *msg)
 	freeblist(bp);
 }
 
-static char*
-tcpporthogdefensectl(char *val)
+static int8_t*
+tcpporthogdefensectl(int8_t *val)
 {
 	if(strcmp(val, "on") == 0)
 		tcpporthogdefense = 1;
@@ -3123,8 +3125,8 @@ tcpporthogdefensectl(char *val)
 }
 
 /* called with c qlocked */
-static char*
-tcpctl(Conv* c, char** f, int n)
+static int8_t*
+tcpctl(Conv* c, int8_t** f, int n)
 {
 	if(n == 1 && strcmp(f[0], "hangup") == 0)
 		return tcphangup(c);
@@ -3138,10 +3140,10 @@ tcpctl(Conv* c, char** f, int n)
 }
 
 static int
-tcpstats(Proto *tcp, char *buf, int len)
+tcpstats(Proto *tcp, int8_t *buf, int len)
 {
 	Tcppriv *priv;
-	char *p, *e;
+	int8_t *p, *e;
 	int i;
 
 	priv = tcp->priv;
@@ -3243,7 +3245,7 @@ tcpinit(Fs *fs)
 }
 
 static void
-tcpsetscale(Conv *s, Tcpctl *tcb, ushort rcvscale, ushort sndscale)
+tcpsetscale(Conv *s, Tcpctl *tcb, uint16_t rcvscale, uint16_t sndscale)
 {
 	if(rcvscale){
 		tcb->rcv.scale = rcvscale & 0xff;

+ 49 - 49
sys/src/9/ip/udp.c

@@ -44,48 +44,48 @@ typedef struct Udp4hdr Udp4hdr;
 struct Udp4hdr
 {
 	/* ip header */
-	uchar	vihl;		/* Version and header length */
-	uchar	tos;		/* Type of service */
-	uchar	length[2];	/* packet length */
-	uchar	id[2];		/* Identification */
-	uchar	frag[2];	/* Fragment information */
-	uchar	Unused;
-	uchar	udpproto;	/* Protocol */
-	uchar	udpplen[2];	/* Header plus data length */
-	uchar	udpsrc[IPv4addrlen];	/* Ip source */
-	uchar	udpdst[IPv4addrlen];	/* Ip destination */
+	uint8_t	vihl;		/* Version and header length */
+	uint8_t	tos;		/* Type of service */
+	uint8_t	length[2];	/* packet length */
+	uint8_t	id[2];		/* Identification */
+	uint8_t	frag[2];	/* Fragment information */
+	uint8_t	Unused;
+	uint8_t	udpproto;	/* Protocol */
+	uint8_t	udpplen[2];	/* Header plus data length */
+	uint8_t	udpsrc[IPv4addrlen];	/* Ip source */
+	uint8_t	udpdst[IPv4addrlen];	/* Ip destination */
 
 	/* udp header */
-	uchar	udpsport[2];	/* Source port */
-	uchar	udpdport[2];	/* Destination port */
-	uchar	udplen[2];	/* data length */
-	uchar	udpcksum[2];	/* Checksum */
+	uint8_t	udpsport[2];	/* Source port */
+	uint8_t	udpdport[2];	/* Destination port */
+	uint8_t	udplen[2];	/* data length */
+	uint8_t	udpcksum[2];	/* Checksum */
 };
 
 typedef struct Udp6hdr Udp6hdr;
 struct Udp6hdr {
-	uchar viclfl[4];
-	uchar len[2];
-	uchar nextheader;
-	uchar hoplimit;
-	uchar udpsrc[IPaddrlen];
-	uchar udpdst[IPaddrlen];
+	uint8_t viclfl[4];
+	uint8_t len[2];
+	uint8_t nextheader;
+	uint8_t hoplimit;
+	uint8_t udpsrc[IPaddrlen];
+	uint8_t udpdst[IPaddrlen];
 
 	/* udp header */
-	uchar	udpsport[2];	/* Source port */
-	uchar	udpdport[2];	/* Destination port */
-	uchar	udplen[2];	/* data length */
-	uchar	udpcksum[2];	/* Checksum */
+	uint8_t	udpsport[2];	/* Source port */
+	uint8_t	udpdport[2];	/* Destination port */
+	uint8_t	udplen[2];	/* data length */
+	uint8_t	udpcksum[2];	/* Checksum */
 };
 
 /* MIB II counters */
 typedef struct Udpstats Udpstats;
 struct Udpstats
 {
-	ulong	udpInDatagrams;
-	ulong	udpNoPorts;
-	ulong	udpInErrors;
-	ulong	udpOutDatagrams;
+	uint32_t	udpInDatagrams;
+	uint32_t	udpNoPorts;
+	uint32_t	udpInErrors;
+	uint32_t	udpOutDatagrams;
 };
 
 typedef struct Udppriv Udppriv;
@@ -97,11 +97,11 @@ struct Udppriv
 	Udpstats	ustats;
 
 	/* non-MIB stats */
-	ulong		csumerr;		/* checksum errors */
-	ulong		lenerr;			/* short packet */
+	uint32_t		csumerr;		/* checksum errors */
+	uint32_t		lenerr;			/* short packet */
 };
 
-void (*etherprofiler)(char *name, int qlen);
+void (*etherprofiler)(int8_t *name, int qlen);
 void udpkick(void *x, Block *bp);
 
 /*
@@ -114,10 +114,10 @@ struct Udpcb
 	uchar	headers;
 };
 
-static char*
-udpconnect(Conv *c, char **argv, int argc)
+static int8_t*
+udpconnect(Conv *c, int8_t **argv, int argc)
 {
-	char *e;
+	int8_t *e;
 	Udppriv *upriv;
 
 	upriv = c->p->priv;
@@ -132,7 +132,7 @@ udpconnect(Conv *c, char **argv, int argc)
 
 
 static int
-udpstate(Conv *c, char *state, int n)
+udpstate(Conv *c, int8_t *state, int n)
 {
 	return snprint(state, n, "%s qin %d qout %d\n",
 		c->inuse ? "Open" : "Closed",
@@ -141,10 +141,10 @@ udpstate(Conv *c, char *state, int n)
 	);
 }
 
-static char*
-udpannounce(Conv *c, char** argv, int argc)
+static int8_t*
+udpannounce(Conv *c, int8_t** argv, int argc)
 {
-	char *e;
+	int8_t *e;
 	Udppriv *upriv;
 
 	upriv = c->p->priv;
@@ -192,8 +192,8 @@ udpkick(void *x, Block *bp)
 	Conv *c = x;
 	Udp4hdr *uh4;
 	Udp6hdr *uh6;
-	ushort rport;
-	uchar laddr[IPaddrlen], raddr[IPaddrlen];
+	uint16_t rport;
+	uint8_t laddr[IPaddrlen], raddr[IPaddrlen];
 	Udpcb *ucb;
 	int dlen, ptcllen;
 	Udppriv *upriv;
@@ -354,13 +354,13 @@ udpiput(Proto *udp, Ipifc *ifc, Block *bp)
 	Udp6hdr *uh6;
 	Conv *c;
 	Udpcb *ucb;
-	uchar raddr[IPaddrlen], laddr[IPaddrlen];
-	ushort rport, lport;
+	uint8_t raddr[IPaddrlen], laddr[IPaddrlen];
+	uint16_t rport, lport;
 	Udppriv *upriv;
 	Fs *f;
 	int version;
 	int ottl, oviclfl, olen;
-	uchar *p;
+	uint8_t *p;
 
 	upriv = udp->priv;
 	f = udp->f;
@@ -545,8 +545,8 @@ udpiput(Proto *udp, Ipifc *ifc, Block *bp)
 
 }
 
-char*
-udpctl(Conv *c, char **f, int n)
+int8_t*
+udpctl(Conv *c, int8_t **f, int n)
 {
 	Udpcb *ucb;
 
@@ -568,12 +568,12 @@ udpctl(Conv *c, char **f, int n)
 }
 
 void
-udpadvise(Proto *udp, Block *bp, char *msg)
+udpadvise(Proto *udp, Block *bp, int8_t *msg)
 {
 	Udp4hdr *h4;
 	Udp6hdr *h6;
-	uchar source[IPaddrlen], dest[IPaddrlen];
-	ushort psource, pdest;
+	uint8_t source[IPaddrlen], dest[IPaddrlen];
+	uint16_t psource, pdest;
 	Conv *s, **p;
 	int version;
 
@@ -623,7 +623,7 @@ udpadvise(Proto *udp, Block *bp, char *msg)
 }
 
 int
-udpstats(Proto *udp, char *buf, int len)
+udpstats(Proto *udp, int8_t *buf, int len)
 {
 	Udppriv *upriv;
 

+ 9 - 9
sys/src/9/k10/acore.c

@@ -40,9 +40,9 @@
  * saving, so it does not have to be restored.
  */
 
-extern char* acfpunm(Ureg* ureg, void*);
-extern char* acfpumf(Ureg* ureg, void*);
-extern char* acfpuxf(Ureg* ureg, void*);
+extern int8_t* acfpunm(Ureg* ureg, void*);
+extern int8_t* acfpumf(Ureg* ureg, void*);
+extern int8_t* acfpuxf(Ureg* ureg, void*);
 extern void acfpusysprocsetup(Proc*);
 
 extern void _acsysret(void);
@@ -57,7 +57,7 @@ ACVctl *acvctl[256];
 static void
 testiccfn(void)
 {
-	print("called: %s\n", (char*)m->icc->data);
+	print("called: %s\n", (int8_t*)m->icc->data);
 }
 
 void
@@ -72,7 +72,7 @@ testicc(int i)
 		}
 		print("calling core %d... ", i);
 		mp->icc->flushtlb = 0;
-		snprint((char*)mp->icc->data, ICCLNSZ, "<%d>", i);
+		snprint((int8_t*)mp->icc->data, ICCLNSZ, "<%d>", i);
 		mfence();
 		mp->icc->fn = testiccfn;
 		mwait(&mp->icc->fn);
@@ -86,10 +86,10 @@ testicc(int i)
 static void
 acstackok(void)
 {
-	char dummy;
-	char *sstart;
+	int8_t dummy;
+	int8_t *sstart;
 
-	sstart = (char *)m - PGSZ - 4*PTSZ - MACHSTKSZ;
+	sstart = (int8_t *)m - PGSZ - 4*PTSZ - MACHSTKSZ;
 	if(&dummy < sstart + 4*KiB){
 		print("ac kernel stack overflow, cpu%d stopped\n", m->machno);
 		DONE();
@@ -168,7 +168,7 @@ actrapret(void)
 void
 actrap(Ureg *u)
 {
-	char *n;
+	int8_t *n;
 	ACVctl *v;
 
 	n = nil;

+ 2 - 2
sys/src/9/k10/apic.c

@@ -348,11 +348,11 @@ apictimerenab(void)
 }
 
 void
-apictimerset(uvlong next)
+apictimerset(uint64_t next)
 {
 	Mpl pl;
 	Apic *apic;
-	vlong period;
+	int64_t period;
 
 	apic = &xlapic[(apicrget(Id)>>24) & 0xff];
 

+ 2 - 2
sys/src/9/k10/arch.c

@@ -48,7 +48,7 @@ decref(Ref *r)
 void
 procrestore(Proc *p)
 {
-	uvlong t;
+	uint64_t t;
 
 	if(p->kp)
 		return;
@@ -67,7 +67,7 @@ procrestore(Proc *p)
 void
 procsave(Proc *p)
 {
-	uvlong t;
+	uint64_t t;
 
 	cycles(&t);
 	p->pcycles += t;

+ 4 - 4
sys/src/9/k10/archk10.c

@@ -64,11 +64,11 @@ cpuidinfo(u32int eax, u32int ecx, u32int info[4])
 	return 1;
 }
 
-static vlong
+static int64_t
 cpuidhz(u32int info[2][4])
 {
 	int f, r;
-	vlong hz;
+	int64_t hz;
 	u64int msr;
 
 	if(memcmp(&info[0][1], "GenuntelineI", 12) == 0){
@@ -218,10 +218,10 @@ cpuiddump(void)
 	}
 }
 
-vlong
+int64_t
 archhz(void)
 {
-	vlong hz;
+	int64_t hz;
 	u32int info[2][4];
 
 	if(!cpuidinfo(0, 0, info[0]) || !cpuidinfo(1, 0, info[1]))

+ 4 - 4
sys/src/9/k10/archk8.c

@@ -64,11 +64,11 @@ cpuidinfo(u32int eax)
 	return m->cpuinfo[eax];
 }
 
-static vlong
+static int64_t
 cpuidhz(u32int* info[2])
 {
 	int f, r;
-	vlong hz;
+	int64_t hz;
 	u64int msr;
 
 	if(memcmp(&info[0][1], "GenuntelineI", 12) == 0){
@@ -213,10 +213,10 @@ cpuiddump(void)
 	}
 }
 
-vlong
+int64_t
 archhz(void)
 {
-	vlong hz;
+	int64_t hz;
 	u32int *info[2];
 
 	if((info[0] = cpuidinfo(0)) == 0 || (info[1] = cpuidinfo(1)) == 0)

+ 1 - 1
sys/src/9/k10/asm.c

@@ -265,7 +265,7 @@ asmmapinit(uintmem addr, uintmem size, int type)
 }
 
 void
-asmmodinit(u32int start, u32int end, char* s)
+asmmodinit(u32int start, u32int end, int8_t* s)
 {
 	DBG("asmmodinit: %#ux -> %#ux: <%s> %#ux\n",
 		start, end, s, ROUNDUP(end, 4096));

+ 8 - 8
sys/src/9/k10/cga.c

@@ -64,7 +64,7 @@ cgaregw(int index, int data)
 static void
 cgacursor(void)
 {
-	uchar *cga;
+	uint8_t *cga;
 
 	cgaregw(0x0e, (cgapos/2>>8) & 0xff);
 	cgaregw(0x0f, cgapos/2 & 0xff);
@@ -81,7 +81,7 @@ void
 cgaputc(int c)
 {
 	int i;
-	uchar *cga, *p;
+	uint8_t *cga, *p;
 
 	cga = CGA;
 
@@ -122,9 +122,9 @@ cgaputc(int c)
 void
 cgaprinthex(uintptr x)
 {
-	char str[30];
-	char *s;
-	static char dig[] = "0123456789abcdef";
+	int8_t str[30];
+	int8_t *s;
+	static int8_t dig[] = "0123456789abcdef";
 
 	str[29] = 0;
 	s = &str[29];
@@ -138,7 +138,7 @@ cgaprinthex(uintptr x)
 }
 
 void
-cgaconsputs(char* s, int n)
+cgaconsputs(int8_t* s, int n)
 {
 	ilock(&cgalock);
 	while(n-- > 0)
@@ -149,9 +149,9 @@ cgaconsputs(char* s, int n)
 void
 cgapost(int code)
 {
-	uchar *cga;
+	uint8_t *cga;
 
-	static char hex[] = "0123456789ABCDEF";
+	static int8_t hex[] = "0123456789ABCDEF";
 
 	cga = CGA;
 	cga[Width*Height-Postcodelen*2] = hex[(code>>4) & 0x0f];

+ 10 - 10
sys/src/9/k10/crap.c

@@ -32,21 +32,21 @@ int nconf = nelem(confname);
  */
 #define	CONFADDR	PTR2UINT(KADDR(0x0001200))
 
-#define BOOTLINE	((char*)CONFADDR)
+#define BOOTLINE	((int8_t*)CONFADDR)
 #define BOOTLINELEN	64
-#define BOOTARGS	((char*)(CONFADDR+BOOTLINELEN))
+#define BOOTARGS	((int8_t*)(CONFADDR+BOOTLINELEN))
 #define	BOOTARGSLEN	(4096-0x200-BOOTLINELEN)
 #define	MAXCONF		64
 
-char *confname[MAXCONF];
-char *confval[MAXCONF];
+int8_t *confname[MAXCONF];
+int8_t *confval[MAXCONF];
 int nconf;
 
 void
 crapoptions(void)
 {
-	long i, n;
-	char *cp, *line[MAXCONF], *p, *q;
+	int32_t i, n;
+	int8_t *cp, *line[MAXCONF], *p, *q;
 
 	/*
 	 *  parse configuration args from dos file plan9.ini
@@ -81,8 +81,8 @@ crapoptions(void)
 	}
 }
 
-char*
-getconf(char *name)
+int8_t*
+getconf(int8_t *name)
 {
 	int i;
 
@@ -105,9 +105,9 @@ confsetenv(void)
 }
 
 int
-isaconfig(char *class, int ctlrno, ISAConf *isa)
+isaconfig(int8_t *class, int ctlrno, ISAConf *isa)
 {
-	char cc[32], *p;
+	int8_t cc[32], *p;
 	int i;
 
 	snprint(cc, sizeof cc, "%s%d", class, ctlrno);

+ 57 - 55
sys/src/9/k10/devacpi.c

@@ -29,12 +29,12 @@
 
 #define l16get(p)	(((p)[1]<<8)|(p)[0])
 #define l32get(p)	(((u32int)l16get(p+2)<<16)|l16get(p))
-static Atable* acpifadt(uchar*, int);
-static Atable* acpitable(uchar*, int);
-static Atable* acpimadt(uchar*, int);
-static Atable* acpimsct(uchar*, int);
-static Atable* acpisrat(uchar*, int);
-static Atable* acpislit(uchar*, int);
+static Atable* acpifadt(uint8_t*, int);
+static Atable* acpitable(uint8_t*, int);
+static Atable* acpimadt(uint8_t*, int);
+static Atable* acpimsct(uint8_t*, int);
+static Atable* acpisrat(uint8_t*, int);
+static Atable* acpislit(uint8_t*, int);
 
 #pragma	varargck	type	"G"	Gas*
 
@@ -82,15 +82,15 @@ static Reg*	reg;	/* region used for I/O */
 static Gpe*	gpes;	/* General purpose events */
 static int	ngpes;
 
-static char* regnames[] = {
+static int8_t* regnames[] = {
 	"mem", "io", "pcicfg", "embed",
 	"smb", "cmos", "pcibar",
 };
 
-static char*
+static int8_t*
 acpiregstr(int id)
 {
-	static char buf[20];	/* BUG */
+	static int8_t buf[20];	/* BUG */
 
 	if(id >= 0 && id < nelem(regnames))
 		return regnames[id];
@@ -99,7 +99,7 @@ acpiregstr(int id)
 }
 
 static int
-acpiregid(char *s)
+acpiregid(int8_t *s)
 {
 	int i;
 
@@ -297,8 +297,9 @@ static Regio cfgio =
 /*
  * Copy memory, 1/2/4/8-bytes at a time, to/from a region.
  */
-static long
-regcpy(Regio *dio, uintptr da, Regio *sio, uintptr sa, long len, int align)
+static int32_t
+regcpy(Regio *dio, uintptr da, Regio *sio, uintptr sa, int32_t len,
+       int align)
 {
 	int n, i;
 
@@ -337,8 +338,8 @@ regcpy(Regio *dio, uintptr da, Regio *sio, uintptr sa, long len, int align)
  * Perform I/O within region in access units of accsz bytes.
  * All units in bytes.
  */
-static long
-regio(Reg *r, void *p, ulong len, uintptr off, int iswr)
+static int32_t
+regio(Reg *r, void *p, uint32_t len, uintptr off, int iswr)
 {
 	Regio rio;
 	uintptr rp;
@@ -391,7 +392,7 @@ regio(Reg *r, void *p, ulong len, uintptr off, int iswr)
 }
 
 static Atable*
-newtable(uchar *p)
+newtable(uint8_t *p)
 {
 	Atable *t;
 	Sdthdr *h;
@@ -486,7 +487,7 @@ static void
 loaddsdt(uintptr pa)
 {
 	int n;
-	uchar *dsdtp;
+	uint8_t *dsdtp;
 
 	dsdtp = sdtmap(pa, &n, 1);
 	if(dsdtp == nil)
@@ -496,7 +497,7 @@ loaddsdt(uintptr pa)
 }
 
 static void
-gasget(Gas *gas, uchar *p)
+gasget(Gas *gas, uint8_t *p)
 {
 	gas->spc = p[0];
 	gas->len = p[1];
@@ -562,7 +563,7 @@ dumpfadt(Fadt *fp)
 }
 
 static Atable*
-acpifadt(uchar *p, int)
+acpifadt(uint8_t *p, int)
 {
 	Fadt *fp;
 
@@ -648,9 +649,9 @@ dumpmsct(Msct *msct)
  * Else we should remove this code.
  */
 static Atable*
-acpimsct(uchar *p, int len)
+acpimsct(uint8_t *p, int len)
 {
-	uchar *pe;
+	uint8_t *pe;
 	Mdom **stl, *st;
 	int off;
 
@@ -706,10 +707,10 @@ dumpsrat(Srat *st)
 }
 
 static Atable*
-acpisrat(uchar *p, int len)
+acpisrat(uint8_t *p, int len)
 {
 	Srat **stl, *st;
-	uchar *pe;
+	uint8_t *pe;
 	int stlen, flags;
 
 	if(srat != nil){
@@ -794,9 +795,9 @@ cmpslitent(void* v1, void* v2)
 }
 
 static Atable*
-acpislit(uchar *p, int len)
+acpislit(uint8_t *p, int len)
 {
-	uchar *pe;
+	uint8_t *pe;
 	int i, j, k;
 	SlEntry *se;
 
@@ -936,9 +937,9 @@ dumpmadt(Madt *apics)
 }
 
 static Atable*
-acpimadt(uchar *p, int len)
+acpimadt(uint8_t *p, int len)
 {
-	uchar *pe;
+	uint8_t *pe;
 	Apicst *st, *l, **stl;
 	int stlen, id;
 
@@ -1016,7 +1017,7 @@ acpimadt(uchar *p, int len)
 				free(st);
 				st = nil;
 			}else
-				kstrdup(&st->lsapic.puids, (char*)p+16);
+				kstrdup(&st->lsapic.puids, (int8_t*)p+16);
 			break;
 		case ASintsrc:
 			st->intsrc.flags = l16get(p+2);
@@ -1059,7 +1060,7 @@ acpimadt(uchar *p, int len)
  * Map the table and keep it there.
  */
 static Atable*
-acpitable(uchar *p, int len)
+acpitable(uint8_t *p, int len)
 {
 	if(len < Sdthdrsz)
 		return nil;
@@ -1067,7 +1068,7 @@ acpitable(uchar *p, int len)
 }
 
 static void
-dumptable(char *sig, uchar *p, int l)
+dumptable(int8_t *sig, uint8_t *p, int l)
 {
 	int n, i;
 
@@ -1089,13 +1090,13 @@ dumptable(char *sig, uchar *p, int l)
 	}
 }
 
-static char*
-seprinttable(char *s, char *e, Atable *t)
+static int8_t*
+seprinttable(int8_t *s, int8_t *e, Atable *t)
 {
-	uchar *p;
+	uint8_t *p;
 	int i, n;
 
-	p = (uchar*)t->tbl;	/* include header */
+	p = (uint8_t*)t->tbl;	/* include header */
 	n = Sdthdrsz + t->dlen;
 	s = seprint(s, e, "%s @ %#p\n", t->sig, p);
 	for(i = 0; i < n; i++){
@@ -1113,12 +1114,12 @@ seprinttable(char *s, char *e, Atable *t)
  * (XXX: should be able to search for sig, oemid, oemtblid)
  */
 static int
-acpixsdtload(char *sig)
+acpixsdtload(int8_t *sig)
 {
 	int i, l, t, unmap, found;
 	uintptr dhpa;
-	uchar *sdt;
-	char tsig[5];
+	uint8_t *sdt;
+	int8_t tsig[5];
 
 	found = 0;
 	for(i = 0; i < xsdt->len; i += xsdt->asize){
@@ -1148,7 +1149,7 @@ acpixsdtload(char *sig)
 }
 
 static void*
-rsdscan(u8int* addr, int len, char* signature)
+rsdscan(u8int* addr, int len, int8_t* signature)
 {
 	int sl;
 	u8int *e, *p;
@@ -1165,7 +1166,7 @@ rsdscan(u8int* addr, int len, char* signature)
 }
 
 static void*
-rsdsearch(char* signature)
+rsdsearch(int8_t* signature)
 {
 	uintptr p;
 	u8int *bda;
@@ -1176,7 +1177,7 @@ rsdsearch(char* signature)
 	 * 1) in the first KB of the EBDA;
 	 * 2) in the BIOS ROM between 0xE0000 and 0xFFFFF.
 	 */
-	if(strncmp((char*)KADDR(0xFFFD9), "EISA", 4) == 0){
+	if(strncmp((int8_t*)KADDR(0xFFFD9), "EISA", 4) == 0){
 		bda = BIOSSEG(0x40);
 		if((p = (bda[0x0F]<<8)|bda[0x0E])){
 			if(rsd = rsdscan(KADDR(p), 1024, signature))
@@ -1249,7 +1250,7 @@ acpirsdptr(void)
 }
 
 static int
-acpigen(Chan *c, char*, Dirtab *tab, int ntab, int i, Dir *dp)
+acpigen(Chan *c, int8_t*, Dirtab *tab, int ntab, int i, Dir *dp)
 {
 	Qid qid;
 
@@ -1272,7 +1273,7 @@ acpigen(Chan *c, char*, Dirtab *tab, int ntab, int i, Dir *dp)
 static int
 Gfmt(Fmt* f)
 {
-	static char* rnames[] = {
+	static int8_t* rnames[] = {
 			"mem", "io", "pcicfg", "embed",
 			"smb", "cmos", "pcibar", "ipmi"};
 	Gas *g;
@@ -1290,9 +1291,10 @@ Gfmt(Fmt* f)
 		break;
 	case Rpcicfg:
 		fmtprint(f, "[pci ");
-		fmtprint(f, "dev %#ulx ", (ulong)(g->addr >> 32) & 0xFFFF);
-		fmtprint(f, "fn %#ulx ", (ulong)(g->addr & 0xFFFF0000) >> 16);
-		fmtprint(f, "adr %#ulx ", (ulong)(g->addr &0xFFFF));
+		fmtprint(f, "dev %#ulx ", (uint32_t)(g->addr >> 32) & 0xFFFF);
+		fmtprint(f, "fn %#ulx ",
+			 (uint32_t)(g->addr & 0xFFFF0000) >> 16);
+		fmtprint(f, "adr %#ulx ", (uint32_t)(g->addr &0xFFFF));
 		break;
 	case Rfixedhw:
 		fmtprint(f, "[hw ");
@@ -1505,7 +1507,7 @@ acpiinit(void)
 }
 
 static Chan*
-acpiattach(char *spec)
+acpiattach(int8_t *spec)
 {
 	int i;
 
@@ -1551,13 +1553,13 @@ acpiattach(char *spec)
 }
 
 static Walkqid*
-acpiwalk(Chan *c, Chan *nc, char **name, int nname)
+acpiwalk(Chan *c, Chan *nc, int8_t **name, int nname)
 {
 	return devwalk(c, nc, name, nname, acpidir, nelem(acpidir), acpigen);
 }
 
-static long
-acpistat(Chan *c, uchar *dp, long n)
+static int32_t
+acpistat(Chan *c, uint8_t *dp, int32_t n)
 {
 	return devstat(c, dp, n, acpidir, nelem(acpidir), acpigen);
 }
@@ -1573,15 +1575,15 @@ acpiclose(Chan *)
 {
 }
 
-static char*ttext;
+static int8_t*ttext;
 static int tlen;
 
-static long
-acpiread(Chan *c, void *a, long n, vlong off)
+static int32_t
+acpiread(Chan *c, void *a, int32_t n, int64_t off)
 {
-	long q;
+	int32_t q;
 	Atable *t;
-	char *ns, *s, *e, *ntext;
+	int8_t *ns, *s, *e, *ntext;
 
 	q = c->qid.path;
 	switch(q){
@@ -1625,8 +1627,8 @@ acpiread(Chan *c, void *a, long n, vlong off)
 	return -1;
 }
 
-static long
-acpiwrite(Chan *c, void *a, long n, vlong off)
+static int32_t
+acpiwrite(Chan *c, void *a, int32_t n, int64_t off)
 {
 	Cmdtab *ct;
 	Cmdbuf *cb;

+ 30 - 30
sys/src/9/k10/devarch.c

@@ -21,9 +21,9 @@ struct IOMap
 {
 	IOMap	*next;
 	int	reserved;
-	char	tag[13];
-	ulong	start;
-	ulong	end;
+	int8_t	tag[13];
+	uint32_t	start;
+	uint32_t	end;
 };
 
 static struct
@@ -48,7 +48,7 @@ enum {
 	Qmax = 16,
 };
 
-typedef long Rdwrfn(Chan*, void*, long, vlong);
+typedef int32_t Rdwrfn(Chan*, void*, int32_t, int64_t);
 
 static Rdwrfn *readfn[Qmax];
 static Rdwrfn *writefn[Qmax];
@@ -71,7 +71,7 @@ int narchdir = Qbase;
  * like change the Qid version.  Changing the Qid path is disallowed.
  */
 Dirtab*
-addarchfile(char *name, int perm, Rdwrfn *rdfn, Rdwrfn *wrfn)
+addarchfile(int8_t *name, int perm, Rdwrfn *rdfn, Rdwrfn *wrfn)
 {
 	int i;
 	Dirtab d;
@@ -106,7 +106,7 @@ addarchfile(char *name, int perm, Rdwrfn *rdfn, Rdwrfn *wrfn)
 void
 ioinit(void)
 {
-	char *excluded;
+	int8_t *excluded;
 	int i;
 
 	for(i = 0; i < nelem(iomap.maps)-1; i++)
@@ -121,11 +121,11 @@ ioinit(void)
 					// entry is needed for swappable devs.
 
 	if ((excluded = getconf("ioexclude")) != nil) {
-		char *s;
+		int8_t *s;
 
 		s = excluded;
 		while (s && *s != '\0' && *s != '\n') {
-			char *ends;
+			int8_t *ends;
 			int io_s, io_e;
 
 			io_s = (int)strtol(s, &ends, 0);
@@ -150,7 +150,7 @@ ioinit(void)
 // This is in particular useful for exchangable cards, such
 // as pcmcia and cardbus cards.
 int
-ioreserve(int, int size, int align, char *tag)
+ioreserve(int, int size, int align, int8_t *tag)
 {
 	IOMap *map, **l;
 	int i, port;
@@ -200,7 +200,7 @@ ioreserve(int, int size, int align, char *tag)
 //	alloced to.  if port < 0, find a free region.
 //
 int
-ioalloc(int port, int size, int align, char *tag)
+ioalloc(int port, int size, int align, int8_t *tag)
 {
 	IOMap *map, **l;
 	int i;
@@ -316,19 +316,19 @@ checkport(int start, int end)
 }
 
 static Chan*
-archattach(char* spec)
+archattach(int8_t* spec)
 {
 	return devattach('P', spec);
 }
 
 Walkqid*
-archwalk(Chan* c, Chan *nc, char** name, int nname)
+archwalk(Chan* c, Chan *nc, int8_t** name, int nname)
 {
 	return devwalk(c, nc, name, nname, archdir, narchdir, devgen);
 }
 
-static long
-archstat(Chan* c, uchar* dp, long n)
+static int32_t
+archstat(Chan* c, uint8_t* dp, int32_t n)
 {
 	return devstat(c, dp, n, archdir, narchdir, devgen);
 }
@@ -447,16 +447,16 @@ archread(Chan *c, void *a, long n, vlong offset)
 	return n;
 }
 
-static long
-archwrite(Chan *c, void *a, long n, vlong offset)
+static int32_t
+archwrite(Chan *c, void *a, int32_t n, int64_t offset)
 {
-	char *p;
+	int8_t *p;
 	int port;
-	ushort *sp;
-	ulong *lp;
+	uint16_t *sp;
+	uint32_t *lp;
 	Rdwrfn *fn;
 
-	switch((ulong)c->qid.path){
+	switch((uint32_t)c->qid.path){
 
 	case Qiob:
 		p = a;
@@ -522,10 +522,10 @@ nop(void)
 
 void (*coherence)(void) = mfence;
 
-static long
-cputyperead(Chan*, void *a, long n, vlong off)
+static int32_t
+cputyperead(Chan*, void *a, int32_t n, int64_t off)
 {
-	char buf[512], *s, *e;
+	int8_t buf[512], *s, *e;
 	int i, k;
 
 	e = buf+sizeof buf;
@@ -572,8 +572,8 @@ archreset(void)
 /*
  *  return value and speed of timer
  */
-uvlong
-fastticks(uvlong* hz)
+uint64_t
+fastticks(uint64_t* hz)
 {
 	if(hz != nil)
 		*hz = m->cpuhz;
@@ -590,15 +590,15 @@ ulong
  *  set next timer interrupt
  */
 void
-timerset(uvlong x)
+timerset(uint64_t x)
 {
-	extern void apictimerset(uvlong);
+	extern void apictimerset(uint64_t);
 
 	apictimerset(x);
 }
 
 void
-cycles(uvlong* t)
+cycles(uint64_t* t)
 {
 	*t = rdtsc();
 }
@@ -619,10 +619,10 @@ delay(int millisecs)
  *  performance measurement ticks.  must be low overhead.
  *  doesn't have to count over a second.
  */
-ulong
+uint32_t
 perfticks(void)
 {
-	uvlong x;
+	uint64_t x;
 
 //	if(m->havetsc)
 		cycles(&x);

+ 23 - 23
sys/src/9/k10/ether82563.c

@@ -510,7 +510,7 @@ struct Ctlrtype {
 	int	type;
 	int	mtu;
 	int	flag;
-	char	*name;
+	int8_t	*name;
 };
 
 static Ctlrtype cttab[Nctlrtype] = {
@@ -572,7 +572,7 @@ struct Ctlr {
 	uint	speeds[4];
 	uint	phyerrata;
 
-	uchar	ra[Eaddrlen];		/* receive address */
+	uint8_t	ra[Eaddrlen];		/* receive address */
 	u32int	mta[128];		/* multicast table array */
 
 	Rendez	rrendez;
@@ -609,7 +609,7 @@ static Lock i82563rblock;		/* free receive Blocks */
 static Block* i82563rbpool;
 
 
-static char *statistics[Nstatistics] = {
+static int8_t *statistics[Nstatistics] = {
 	"CRC Error",
 	"Alignment Error",
 	"Symbol Error",
@@ -685,7 +685,7 @@ static char *statistics[Nstatistics] = {
 	"Interrupt Rx Overrun",
 };
 
-static char*
+static int8_t*
 cname(Ctlr* c)
 {
 	if (c->type == Iany)
@@ -693,13 +693,13 @@ cname(Ctlr* c)
 	return cttab[c->type].name;
 }
 
-static long
-i82563ifstat(Ether *edev, void *a, long n, ulong offset)
+static int32_t
+i82563ifstat(Ether *edev, void *a, int32_t n, uint32_t offset)
 {
 	Ctlr *ctlr;
-	char *s, *p, *e, *stat;
+	int8_t *s, *p, *e, *stat;
 	int i, r;
-	uvlong tuvl, ruvl;
+	uint64_t tuvl, ruvl;
 
 	ctlr = edev->ctlr;
 	qlock(&ctlr->slock);
@@ -720,10 +720,10 @@ i82563ifstat(Ether *edev, void *a, long n, ulong offset)
 		case Torl:
 		case Totl:
 			ruvl = r;
-			ruvl += (uvlong)csr32r(ctlr, Statistics+(i+1)*4) << 32;
+			ruvl += (uint64_t)csr32r(ctlr, Statistics+(i+1)*4) << 32;
 			tuvl = ruvl;
 			tuvl += ctlr->statistics[i];
-			tuvl += (uvlong)ctlr->statistics[i+1] << 32;
+			tuvl += (uint64_t)ctlr->statistics[i+1] << 32;
 			if(tuvl == 0)
 				continue;
 			ctlr->statistics[i] = tuvl;
@@ -795,7 +795,7 @@ i82563promiscuous(void* arg, int on)
 }
 
 static void
-i82563multicast(void* arg, uchar* addr, int on)
+i82563multicast(void* arg, uint8_t* addr, int on)
 {
 	int bit, x;
 	Ctlr *ctlr;
@@ -842,7 +842,7 @@ i82563rballoc(void)
 static void
 i82563rbfree(Block* b)
 {
-	b->rp = b->wp = (uchar*)ROUNDUP((uintptr)b->base, PGSZ);
+	b->rp = b->wp = (uint8_t*)ROUNDUP((uintptr)b->base, PGSZ);
  	b->flag &= ~(Bipck | Budpck | Btcpck | Bpktck);
 	ilock(&i82563rblock);
 	b->next = i82563rbpool;
@@ -989,8 +989,8 @@ i82563replenish(Ctlr* ctlr)
 		}
 		bp = i82563rballoc();
 		if(bp == nil){
-			vlong now;
-			static vlong lasttime;
+			int64_t now;
+			static int64_t lasttime;
 
 			/* don't flood the console */
 			now = tk2ms(sys->ticks);
@@ -1421,7 +1421,7 @@ i82563tproc(void *v)
 static void
 i82563attach(Ether* edev)
 {
-	char name[KNAMELEN];
+	int8_t name[KNAMELEN];
 	Block *bp;
 	Ctlr *ctlr;
 
@@ -1712,17 +1712,17 @@ fload(Ctlr *c)
 }
 
 static void
-defaultea(Ctlr *ctlr, uchar *ra)
+defaultea(Ctlr *ctlr, uint8_t *ra)
 {
 	uint i, r;
-	uvlong u;
-	static uchar nilea[Eaddrlen];
+	uint64_t u;
+	static uint8_t nilea[Eaddrlen];
 
 	if(memcmp(ra, nilea, Eaddrlen) != 0)
 		return;
 	if(cttab[ctlr->type].flag & Fflashea){
 		/* intel mb bug */
-		u = (uvlong)csr32r(ctlr, Rah)<<32u | (u32int)csr32r(ctlr, Ral);
+		u = (uint64_t)csr32r(ctlr, Rah)<<32u | (u32int)csr32r(ctlr, Ral);
 		for(i = 0; i < Eaddrlen; i++)
 			ra[i] = u >> 8*i;
 	}
@@ -1739,7 +1739,7 @@ defaultea(Ctlr *ctlr, uchar *ra)
 static int
 i82563reset(Ctlr *ctlr)
 {
-	uchar *ra;
+	uint8_t *ra;
 	int i, r;
 
 	if(i82563detach(ctlr))
@@ -1803,10 +1803,10 @@ static Cmdtab i82563ctlmsg[] = {
 	CMan,	"an",	1,
 };
 
-static long
-i82563ctl(Ether *edev, void *buf, long n)
+static int32_t
+i82563ctl(Ether *edev, void *buf, int32_t n)
 {
-	char *p;
+	int8_t *p;
 	u32int v;
 	Ctlr *ctlr;
 	Cmdbuf *cb;

+ 8 - 8
sys/src/9/k10/etherbcm.c

@@ -39,7 +39,7 @@ struct Ctlr {
 	u32int	*nic, *status;
 
 	u32int	*recvret, *recvprod, *sendr;
-	ulong	port;
+	uint32_t	port;
 	uint	recvreti, recvprodi, sendri, sendcleani;
 	Block	**sends;
 	Block	**rxs;
@@ -220,7 +220,7 @@ typedef struct Ctlrtype Ctlrtype;
 struct Ctlrtype {
 	int	mtu;
 	int	flag;
-	char	*name;
+	int8_t	*name;
 };
 
 static Ctlrtype cttab[Nctlrtype] = {
@@ -239,16 +239,16 @@ static Ctlrtype cttab[Nctlrtype] = {
 static Ctlr *bcmhead;
 static int debug=1;
 
-static char*
+static int8_t*
 cname(Ctlr *c)
 {
 	return cttab[c->type].name;
 }
 
-static long
-bcmifstat(Ether *edev, void *a, long n, ulong offset)
+static int32_t
+bcmifstat(Ether *edev, void *a, int32_t n, uint32_t offset)
 {
-	char *s, *p, *e;
+	int8_t *s, *p, *e;
 	Ctlr *c;
 
 	c = edev->ctlr;
@@ -813,7 +813,7 @@ bcmpci(void)
 		ctlr->port = p->mem[0].bar & ~0x0F;
 		mem = vmap(ctlr->port, p->mem[0].size);
 		if(mem == nil) {
-			print("bcm: can't map %#p\n", (uvlong)ctlr->port);
+			print("bcm: can't map %#p\n", (uint64_t)ctlr->port);
 			free(ctlr);
 			continue;
 		}
@@ -843,7 +843,7 @@ bcmpromiscuous(void* arg, int on)
 }
 
 static void
-bcmmulticast(void*, uchar*, int)
+bcmmulticast(void*, uint8_t*, int)
 {
 }
 

+ 16 - 16
sys/src/9/k10/fpu.c

@@ -86,9 +86,9 @@ extern void _ldmxcsr(u32int);
 extern void _stts(void);
 
 int
-fpudevprocio(Proc* proc, void* a, long n, uintptr offset, int write)
+fpudevprocio(Proc* proc, void* a, int32_t n, uintptr offset, int write)
 {
-	uchar *p;
+	uint8_t *p;
 
 	/*
 	 * Called from procdevtab.read and procdevtab.write
@@ -259,12 +259,12 @@ acfpusysprocsetup(Proc *p)
 	}
 }
 
-static char*
+static int8_t*
 fpunote(void)
 {
-	ushort fsw;
+	uint16_t fsw;
 	Fxsave *fpusave;
-	char *m;
+	int8_t *m;
 
 	/*
 	 * The Sff bit is sticky, meaning it should be explicitly
@@ -302,12 +302,12 @@ fpunote(void)
 	return up->genbuf;
 }
 
-char*
+int8_t*
 xfpuxf(Ureg* ureg, void*)
 {
 	u32int mxcsr;
 	Fxsave *fpusave;
-	char *m;
+	int8_t *m;
 
 	/*
 	 * #XF - SIMD Floating Point Exception (Vector 18).
@@ -354,20 +354,20 @@ xfpuxf(Ureg* ureg, void*)
 void
 fpuxf(Ureg *ureg, void *p)
 {
-	char *n;
+	int8_t *n;
 
 	n = xfpuxf(ureg, p);
 	if(n != nil)
 		postnote(up, 1, n, NDebug);
 }
 
-char*
+int8_t*
 acfpuxf(Ureg *ureg, void *p)
 {
 	return xfpuxf(ureg, p);
 }
 
-static char*
+static int8_t*
 xfpumf(Ureg* ureg, void*)
 {
 	Fxsave *fpusave;
@@ -406,20 +406,20 @@ xfpumf(Ureg* ureg, void*)
 void
 fpumf(Ureg *ureg, void *p)
 {
-	char *n;
+	int8_t *n;
 
 	n = xfpumf(ureg, p);
 	if(n != nil)
 		postnote(up, 1, n, NDebug);
 }
 
-char*
+int8_t*
 acfpumf(Ureg *ureg, void *p)
 {
 	return xfpumf(ureg, p);
 }
 
-static char*
+static int8_t*
 xfpunm(Ureg* ureg, void*)
 {
 	Fxsave *fpusave;
@@ -488,14 +488,14 @@ xfpunm(Ureg* ureg, void*)
 void
 fpunm(Ureg *ureg, void *p)
 {
-	char *n;
+	int8_t *n;
 
 	n = xfpunm(ureg, p);
 	if(n != nil)
 		postnote(up, 1, n, NDebug);
 }
 
-char*
+int8_t*
 acfpunm(Ureg *ureg, void *p)
 {
 	return xfpunm(ureg, p);
@@ -506,7 +506,7 @@ fpuinit(void)
 {
 	u64int r;
 	Fxsave *fxsave;
-	uchar buf[sizeof(Fxsave)+15];
+	uint8_t buf[sizeof(Fxsave)+15];
 
 	/*
 	 * It's assumed there is an integrated FPU, so Em is cleared;

+ 1 - 1
sys/src/9/k10/i8254.c

@@ -87,7 +87,7 @@ i8254set(int port, int hz)
 	}
 }
 
-vlong
+int64_t
 i8254hz(u32int info[2][4])
 {
 	u32int ax;

+ 2 - 2
sys/src/9/k10/init9.c

@@ -7,10 +7,10 @@
  * in the LICENSE file.
  */
 
-extern void startboot(char*, char**);
+extern void startboot(int8_t*, int8_t**);
 
 void
-main(char* argv0)
+main(int8_t* argv0)
 {
 	startboot(argv0, &argv0);
 }

+ 2 - 2
sys/src/9/k10/ioapic.c

@@ -303,7 +303,7 @@ static int
 intrenablemsi(Vctl* v, Pcidev *p)
 {
 	uint vno, lo, hi;
-	uvlong msivec;
+	uint64_t msivec;
 
 	vno = nextvec();
 
@@ -313,7 +313,7 @@ intrenablemsi(Vctl* v, Pcidev *p)
 	if(lo & Lm)
 		lo |= MTlp;
 
-	msivec = (uvlong)hi<<32 | lo;
+	msivec = (uint64_t)hi<<32 | lo;
 	if(pcimsienable(p, msivec) == -1)
 		return -1;
 	v->isr = apicisr;

+ 15 - 15
sys/src/9/k10/main.c

@@ -36,18 +36,18 @@ usize sizeofSys = sizeof(Sys);
  * set it all up.
  */
 static int oargc;
-static char* oargv[20];
-static char oargb[128];
+static int8_t* oargv[20];
+static int8_t oargb[128];
 static int oargblen;
 
 static int maxcores = 1024;	/* max # of cores given as an argument */
 static int numtcs = 32;		/* initial # of TCs */
 
-char dbgflg[256];
+int8_t dbgflg[256];
 static int vflag = 0;
 
 void
-optionsinit(char* s)
+optionsinit(int8_t* s)
 {
 	oargblen = strecpy(oargb, oargb+sizeof(oargb), s) - oargb;
 	oargc = tokenize(oargb, oargv, nelem(oargv)-1);
@@ -55,9 +55,9 @@ optionsinit(char* s)
 }
 
 static void
-options(int argc, char* argv[])
+options(int argc, int8_t* argv[])
 {
-	char *p;
+	int8_t *p;
 	int n, o;
 
 	/*
@@ -94,7 +94,7 @@ options(int argc, char* argv[])
 void
 squidboy(int apicno)
 {
-	vlong hz;
+	int64_t hz;
 
 	sys->machptr[m->machno] = m;
 	/*
@@ -200,7 +200,7 @@ nixsquids(void)
 {
 	Mach *mp;
 	int i;
-	uvlong now, start;
+	uint64_t now, start;
 
 	for(i = 1; i < MACHMAX; i++)
 		if((mp = sys->machptr[i]) != nil && mp->online){
@@ -253,7 +253,7 @@ HERE(void)
 void
 main(u32int ax, u32int bx)
 {
-	vlong hz;
+	int64_t hz;
 
 	memset(edata, 0, end - edata);
 
@@ -369,7 +369,7 @@ print("schedinit...\n");
 void
 init0(void)
 {
-	char buf[2*KNAMELEN];
+	int8_t buf[2*KNAMELEN];
 
 	up->nerrlab = 0;
 
@@ -408,8 +408,8 @@ void
 bootargs(uintptr base)
 {
 	int i;
-	ulong ssize;
-	char **av, *p;
+	uint32_t ssize;
+	int8_t **av, *p;
 
 	/*
 	 * Push the boot args onto the stack.
@@ -430,9 +430,9 @@ bootargs(uintptr base)
 	 * not the usual (int argc, char* argv[]), but argv0 is
 	 * unused so it doesn't matter (at the moment...).
 	 */
-	av = (char**)(p - (oargc+2)*sizeof(char*));
+	av = (int8_t**)(p - (oargc+2)*sizeof(int8_t*));
 	ssize = base + BIGPGSZ - PTR2UINT(av);
-	*av++ = (char*)oargc;
+	*av++ = (int8_t*)oargc;
 	for(i = 0; i < oargc; i++)
 		*av++ = (oargv[i] - oargb) + (p - base) + (USTKTOP - BIGPGSZ);
 	*av = nil;
@@ -555,7 +555,7 @@ shutdown(int ispanic)
 }
 
 void
-reboot(void*, void*, long)
+reboot(void*, void*, int32_t)
 {
 	panic("reboot\n");
 }

+ 4 - 4
sys/src/9/k10/mmu.c

@@ -266,7 +266,7 @@ checkpte(uintmem ppn, void *a)
 	int l;
 	PTE *pte, *pml4;
 	u64int addr;
-	char buf[240], *s;
+	int8_t buf[240], *s;
 
 	addr = PTR2UINT(a);
 	pml4 = UINT2PTR(m->pml4->va);
@@ -385,7 +385,7 @@ mmuput(uintptr va, Page *pg, uint attr)
 	Page *page, *prev;
 	Mpl pl;
 	uintmem pa, ppn;
-	char buf[80];
+	int8_t buf[80];
 
 	ppn = 0;
 	pa = pg->pa;
@@ -488,7 +488,7 @@ static Lock vmaplock;
 #define PTX(v)		PTLX((v), 0)
 
 int
-mmukmapsync(uvlong va)
+mmukmapsync(uint64_t va)
 {
 	USED(va);
 
@@ -777,7 +777,7 @@ Page mach0pml4;
 void
 mmuinit(void)
 {
-	uchar *p;
+	uint8_t *p;
 	Page *page;
 	u64int o, pa, r, sz;
 

+ 8 - 8
sys/src/9/k10/mp.c

@@ -45,7 +45,7 @@ typedef struct {				/* MP Configuration Table */
 } PCMP;
 
 typedef struct {
-	char	type[6];
+	int8_t	type[6];
 	int	polarity;			/* default for this bus */
 	int	trigger;			/* default for this bus */
 } Mpbus;
@@ -58,10 +58,10 @@ static Mpbus* mpbus[Nbus];
 int mpisabusno = -1;
 
 static void
-mpintrprint(char* s, u8int* p)
+mpintrprint(int8_t* s, u8int* p)
 {
-	char buf[128], *b, *e;
-	char format[] = " type %d flags %#ux bus %d IRQ %d APIC %d INTIN %d\n";
+	int8_t buf[128], *b, *e;
+	int8_t format[] = " type %d flags %#ux bus %d IRQ %d APIC %d INTIN %d\n";
 
 	b = buf;
 	e = b + sizeof(buf);
@@ -190,7 +190,7 @@ mpparse(PCMP* pcmp, int maxcores)
 	int devno, i, n;
 
 	p = pcmp->entries;
-	e = ((uchar*)pcmp)+l16get(pcmp->length);
+	e = ((uint8_t*)pcmp)+l16get(pcmp->length);
 	while(p < e) switch(*p){
 	default:
 		print("mpparse: unknown PCMP type %d (e-p %#ld)\n", *p, e-p);
@@ -244,7 +244,7 @@ mpparse(PCMP* pcmp, int maxcores)
 		}
 		if(mpbus[p[1]] == nil)
 			print("mpparse: bus %d type %6.6s unknown\n",
-				p[1], (char*)p+2);
+				p[1], (int8_t*)p+2);
 
 		p += 8;
 		break;
@@ -372,7 +372,7 @@ sigchecksum(void* address, int length)
 }
 
 static void*
-sigscan(u8int* address, int length, char* signature)
+sigscan(u8int* address, int length, int8_t* signature)
 {
 	u8int *e, *p;
 	int siglength;
@@ -389,7 +389,7 @@ sigscan(u8int* address, int length, char* signature)
 }
 
 static void*
-sigsearch(char* signature)
+sigsearch(int8_t* signature)
 {
 	uintptr p;
 	u8int *bda;

+ 2 - 2
sys/src/9/k10/msi.c

@@ -69,9 +69,9 @@ blacklist(Pcidev *p)
 }
 
 int
-pcimsienable(Pcidev *p, uvlong vec)
+pcimsienable(Pcidev *p, uint64_t vec)
 {
-	char *s;
+	int8_t *s;
 	uint c, f, d, datao, lopri, dmode, logical;
 
 	c = msicap(p);

+ 1 - 1
sys/src/9/k10/multiboot.c

@@ -67,7 +67,7 @@ struct MMap {
 int
 multiboot(u32int magic, u32int pmbi, int vflag)
 {
-	char *p;
+	int8_t *p;
 	int i, n;
 	Mbi *mbi;
 	Mod *mod;

+ 5 - 5
sys/src/9/k10/physalloc.c

@@ -39,8 +39,8 @@ enum {
 
 typedef struct Buddy Buddy;
 struct Buddy {
-	short	tag;		/* Used or Avail */
-	short	kval;
+	int16_t	tag;		/* Used or Avail */
+	int16_t	kval;
 	uint	next;
 	uint	prev;
 	void	*p;
@@ -71,8 +71,8 @@ static Bal bal[Ndoms];
 static int ndoms;
 static Lock budlock;
 
-char*
-seprintphysstats(char *s,  char *e)
+int8_t*
+seprintphysstats(int8_t *s,  int8_t *e)
 {
 	Bal *b;
 	int i;
@@ -224,7 +224,7 @@ phystag(uintmem data)
 	return nil;
 }
 
-static uchar lg2table[256] = {
+static uint8_t lg2table[256] = {
 	0, 0, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3,
 	4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
 	5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,

+ 4 - 4
sys/src/9/k10/pmcio.c

@@ -140,8 +140,8 @@ static int
 setctl(PmcCtl *p, int regno)
 {
 	u64int v, e, u;
-	char *toks[2];
-	char str[KNAMELEN];
+	int8_t *toks[2];
+	int8_t str[KNAMELEN];
 
 	if (regno >= pmcnregs())
 		error("invalid reg");
@@ -194,7 +194,7 @@ setctl(PmcCtl *p, int regno)
 }
 
 int
-pmcctlstr(char *str, int nstr, PmcCtl *p)
+pmcctlstr(int8_t *str, int nstr, PmcCtl *p)
 {
 	int ns;
 
@@ -218,7 +218,7 @@ pmcctlstr(char *str, int nstr, PmcCtl *p)
 }
 
 int
-pmcdescstr(char *str, int nstr)
+pmcdescstr(int8_t *str, int nstr)
 {
 	PmcCtlCtrId *pi;
 	int ns;

+ 16 - 16
sys/src/9/k10/qmalloc.c

@@ -123,7 +123,7 @@ static	Lock		mainlock;
 #define QLIST	quicklist
 
 static void*
-qmallocalign(usize nbytes, uintptr align, long offset, usize span)
+qmallocalign(usize nbytes, uintptr align, int32_t offset, usize span)
 {
 	Qlist *qlist;
 	uintptr aligned;
@@ -368,7 +368,7 @@ qfreeinternal(void* ap)
 	rover = q;
 }
 
-ulong
+uint32_t
 msize(void* ap)
 {
 	Header *p;
@@ -385,9 +385,9 @@ msize(void* ap)
 }
 
 static void
-mallocreadfmt(char* s, char* e)
+mallocreadfmt(int8_t* s, int8_t* e)
 {
-	char *p;
+	int8_t *p;
 	Header *q;
 	int i, n, t;
 	Qlist *qlist;
@@ -396,9 +396,9 @@ mallocreadfmt(char* s, char* e)
 		"%llud memory\n"
 		"%d pagesize\n"
 		"%llud kernel\n",
-		(uvlong)conf.npage*PGSZ,
+		(uint64_t)conf.npage*PGSZ,
 		PGSZ,
-		(uvlong)conf.npage-conf.upages);
+		(uint64_t)conf.npage-conf.upages);
 
 	t = 0;
 	for(i = 0; i <= NQUICK; i++) {
@@ -442,10 +442,10 @@ mallocreadfmt(char* s, char* e)
 	MUNLOCK;
 }
 
-long
-mallocreadsummary(Chan*, void *a, long n, long offset)
+int32_t
+mallocreadsummary(Chan*, void *a, int32_t n, int32_t offset)
 {
-	char *alloc;
+	int8_t *alloc;
 
 	alloc = malloc(16*READSTR);
 	mallocreadfmt(alloc, alloc+16*READSTR);
@@ -511,7 +511,7 @@ free(void* ap)
 }
 
 void*
-malloc(ulong size)
+malloc(uint32_t size)
 {
 	void* v;
 
@@ -522,7 +522,7 @@ malloc(ulong size)
 }
 
 void*
-mallocz(ulong size, int clr)
+mallocz(uint32_t size, int clr)
 {
 	void *v;
 
@@ -533,7 +533,7 @@ mallocz(ulong size, int clr)
 }
 
 void*
-mallocalign(ulong nbytes, ulong align, long offset, ulong span)
+mallocalign(uint32_t nbytes, uint32_t align, int32_t offset, uint32_t span)
 {
 	void *v;
 
@@ -547,7 +547,7 @@ mallocalign(ulong nbytes, ulong align, long offset, ulong span)
 }
 
 void*
-smalloc(ulong size)
+smalloc(uint32_t size)
 {
 	void *v;
 
@@ -559,11 +559,11 @@ smalloc(ulong size)
 }
 
 void*
-realloc(void* ap, ulong size)
+realloc(void* ap, uint32_t size)
 {
 	void *v;
 	Header *p;
-	ulong osize;
+	uint32_t osize;
 	uint nunits, ounits;
 
 	/*
@@ -639,7 +639,7 @@ realloc(void* ap, ulong size)
 }
 
 void
-setmalloctag(void*, ulong)
+setmalloctag(void*, uint32_t)
 {
 }
 

+ 15 - 15
sys/src/9/k10/ratrace.c

@@ -24,19 +24,19 @@ int nread = 0;
 
 typedef struct Str Str;
 struct Str {
-	char	*buf;
+	int8_t	*buf;
 	int	len;
 };
 
 void
-die(char *s)
+die(int8_t *s)
 {
 	fprint(2, "%s\n", s);
 	exits(s);
 }
 
 void
-cwrite(int fd, char *path, char *cmd, int len)
+cwrite(int fd, int8_t *path, int8_t *cmd, int len)
 {
 	if (write(fd, cmd, len) < len) {
 		fprint(2, "cwrite: %s: failed %d bytes: %r\n", path, len);
@@ -49,7 +49,7 @@ void
 reader(void *v)
 {
 	int cfd, tfd, forking = 0, pid, newpid;
-	char *ctl, *truss;
+	int8_t *ctl, *truss;
 	Str *s;
 
 	pid = (int)(uintptr)v;
@@ -64,7 +64,7 @@ reader(void *v)
 	cwrite(cfd, truss, "startsyscall", 12);
 
 	s = mallocz(sizeof(Str) + Bufsize, 1);
-	s->buf = (char *)&s[1];
+	s->buf = (int8_t *)&s[1];
 	while((s->len = pread(tfd, s->buf, Bufsize - 1, 0)) > 0){
 		if (forking && s->buf[1] == '=' && s->buf[3] != '-') {
 			forking = 0;
@@ -78,12 +78,12 @@ reader(void *v)
 		 * no false positives.
 		 */
 		if (strstr(s->buf, " Rfork") != nil) {
-			char *a[8];
-			char *rf;
+			int8_t *a[8];
+			int8_t *rf;
 
 			rf = strdup(s->buf);
          		if (tokenize(rf, a, 8) == 5) {
-				ulong flags;
+				uint32_t flags;
 
 				flags = strtoul(a[4], 0, 16);
 				if (flags & RFPROC)
@@ -94,7 +94,7 @@ reader(void *v)
 		sendp(out, s);
 		cwrite(cfd, truss, "startsyscall", 12);
 		s = mallocz(sizeof(Str) + Bufsize, 1);
-		s->buf = (char *)&s[1];
+		s->buf = (int8_t *)&s[1];
 	}
 	sendp(quit, nil);
 	threadexitsall(nil);
@@ -147,11 +147,11 @@ usage(void)
 }
 
 void
-threadmain(int argc, char **argv)
+threadmain(int argc, int8_t **argv)
 {
 	int pid;
-	char *cmd = nil;
-	char **args = nil;
+	int8_t *cmd = nil;
+	int8_t **args = nil;
 
 	/*
 	 * don't bother with fancy arg processing, because it picks up options
@@ -189,9 +189,9 @@ threadmain(int argc, char **argv)
 		pid = atoi(argv[1]);
 	}
 
-	out   = chancreate(sizeof(char*), 0);
-	quit  = chancreate(sizeof(char*), 0);
-	forkc = chancreate(sizeof(ulong *), 0);
+	out   = chancreate(sizeof(int8_t*), 0);
+	quit  = chancreate(sizeof(int8_t*), 0);
+	forkc = chancreate(sizeof(uint32_t *), 0);
 	nread++;
 	procrfork(writer, nil, Stacksize, 0);
 	reader((void*)pid);

+ 75 - 74
sys/src/9/k10/root/cpu.c

@@ -25,46 +25,46 @@
 #define MaxStr 128
 
 void	remoteside(int);
-void	fatal(int, char*, ...);
+void	fatal(int, int8_t*, ...);
 void	lclnoteproc(int);
 void	rmtnoteproc(void);
-void	catcher(void*, char*);
+void	catcher(void*, int8_t*);
 void	usage(void);
-void	writestr(int, char*, char*, int);
-int	readstr(int, char*, int);
-char	*rexcall(int*, char*, char*);
-int	setamalg(char*);
-char *keyspec = "";
+void	writestr(int, int8_t*, int8_t*, int);
+int	readstr(int, int8_t*, int);
+int8_t	*rexcall(int*, int8_t*, int8_t*);
+int	setamalg(int8_t*);
+int8_t *keyspec = "";
 
 int 	notechan;
 int	exportpid;
-char	*system;
+int8_t	*system;
 int	cflag;
 int	dbg;
-char	*user;
-char	*patternfile;
+int8_t	*user;
+int8_t	*patternfile;
 int	Nflag;
 
-char	*srvname = "ncpu";
-char	*exportfs = "/bin/exportfs";
-char	*ealgs = "rc4_256 sha1";
+int8_t	*srvname = "ncpu";
+int8_t	*exportfs = "/bin/exportfs";
+int8_t	*ealgs = "rc4_256 sha1";
 
 /* message size for exportfs; may be larger so we can do big graphics in CPU window */
 int	msgsize = Maxfdata+IOHDRSZ;
 
 /* authentication mechanisms */
 static int	netkeyauth(int);
-static int	netkeysrvauth(int, char*);
+static int	netkeysrvauth(int, int8_t*);
 static int	p9auth(int);
-static int	srvp9auth(int, char*);
+static int	srvp9auth(int, int8_t*);
 static int	noauth(int);
-static int	srvnoauth(int, char*);
+static int	srvnoauth(int, int8_t*);
 
 typedef struct AuthMethod AuthMethod;
 struct AuthMethod {
-	char	*name;			/* name of method */
+	int8_t	*name;			/* name of method */
 	int	(*cf)(int);		/* client side authentication */
-	int	(*sf)(int, char*);	/* server side authentication */
+	int	(*sf)(int, int8_t*);	/* server side authentication */
 } authmethod[] =
 {
 	{ "p9",		p9auth,		srvp9auth,},
@@ -74,9 +74,9 @@ struct AuthMethod {
 };
 AuthMethod *am = authmethod;	/* default is p9 */
 
-char *p9authproto = "p9any";
+int8_t *p9authproto = "p9any";
 
-int setam(char*);
+int setam(int8_t*);
 
 void
 usage(void)
@@ -215,10 +215,10 @@ main(int argc, char **argv)
 }
 
 void
-fatal(int syserr, char *fmt, ...)
+fatal(int syserr, int8_t *fmt, ...)
 {
 	Fmt f;
-	char *str;
+	int8_t *str;
 	va_list arg;
 
 	fmtstrinit(&f);
@@ -234,9 +234,9 @@ fatal(int syserr, char *fmt, ...)
 	exits(str);
 }
 
-char *negstr = "negotiating authentication method";
+int8_t *negstr = "negotiating authentication method";
 
-char bug[256];
+int8_t bug[256];
 
 int
 old9p(int fd)
@@ -280,7 +280,7 @@ old9p(int fd)
 void
 remoteside(int old)
 {
-	char user[MaxStr], home[MaxStr], buf[MaxStr], xdir[MaxStr], cmd[MaxStr];
+	int8_t user[MaxStr], home[MaxStr], buf[MaxStr], xdir[MaxStr], cmd[MaxStr];
 	int i, n, fd, badchdir, gotcmd;
 
 	rfork(RFENVG);
@@ -369,13 +369,13 @@ remoteside(int old)
 	fatal(1, "exec shell");
 }
 
-char*
-rexcall(int *fd, char *host, char *service)
+int8_t*
+rexcall(int *fd, int8_t *host, int8_t *service)
 {
-	char *na;
-	char dir[MaxStr];
-	char err[ERRMAX];
-	char msg[MaxStr];
+	int8_t *na;
+	int8_t dir[MaxStr];
+	int8_t err[ERRMAX];
+	int8_t msg[MaxStr];
 	int n;
 
 	na = netmkaddr(host, 0, service);
@@ -404,7 +404,7 @@ rexcall(int *fd, char *host, char *service)
 }
 
 void
-writestr(int fd, char *str, char *thing, int ignore)
+writestr(int fd, int8_t *str, int8_t *thing, int ignore)
 {
 	int l, n;
 
@@ -415,7 +415,7 @@ writestr(int fd, char *str, char *thing, int ignore)
 }
 
 int
-readstr(int fd, char *str, int len)
+readstr(int fd, int8_t *str, int len)
 {
 	int n;
 
@@ -432,10 +432,10 @@ readstr(int fd, char *str, int len)
 }
 
 static int
-readln(char *buf, int n)
+readln(int8_t *buf, int n)
 {
 	int i;
-	char *p;
+	int8_t *p;
 
 	n--;	/* room for \0 */
 	p = buf;
@@ -456,8 +456,8 @@ readln(char *buf, int n)
 static int
 netkeyauth(int fd)
 {
-	char chall[32];
-	char resp[32];
+	int8_t chall[32];
+	int8_t resp[32];
 
 	strecpy(chall, chall+sizeof chall, getuser());
 	print("user[%s]: ", chall);
@@ -481,9 +481,9 @@ netkeyauth(int fd)
 }
 
 static int
-netkeysrvauth(int fd, char *user)
+netkeysrvauth(int fd, int8_t *user)
 {
-	char response[32];
+	int8_t response[32];
 	Chalstate *ch;
 	int tries;
 	AuthInfo *ai;
@@ -515,7 +515,7 @@ netkeysrvauth(int fd, char *user)
 }
 
 static void
-mksecret(char *t, uchar *f)
+mksecret(int8_t *t, uint8_t *f)
 {
 	sprint(t, "%2.2ux%2.2ux%2.2ux%2.2ux%2.2ux%2.2ux%2.2ux%2.2ux%2.2ux%2.2ux",
 		f[0], f[1], f[2], f[3], f[4], f[5], f[6], f[7], f[8], f[9]);
@@ -527,10 +527,10 @@ mksecret(char *t, uchar *f)
 static int
 p9auth(int fd)
 {
-	uchar key[16];
-	uchar digest[SHA1dlen];
-	char fromclientsecret[21];
-	char fromserversecret[21];
+	uint8_t key[16];
+	uint8_t digest[SHA1dlen];
+	int8_t fromclientsecret[21];
+	int8_t fromserversecret[21];
 	int i;
 	AuthInfo *ai;
 
@@ -562,10 +562,10 @@ p9auth(int fd)
 	return i;
 }
 
-static char*
+static int8_t*
 gethostowner(void)
 {
-	static char hostowner[64];
+	static int8_t hostowner[64];
 	int fd;
 	int n;
 
@@ -581,11 +581,11 @@ gethostowner(void)
 }
 
 static int
-chuid(char* to)
+chuid(int8_t* to)
 {
 	int fd, r;
-	char *cap, *p;
-	uchar hash[SHA1dlen];
+	int8_t *cap, *p;
+	uint8_t hash[SHA1dlen];
 
 	if((fd = open("#¤/caphash", OWRITE)) < 0){
 		werrstr("open #¤/caphash: %r");
@@ -594,7 +594,8 @@ chuid(char* to)
 	
 	cap = smprint("%s@Why can't we all just get along?", to);
 	p = strrchr(cap, '@');
-	hmac_sha1((uchar*)cap, p-cap, (uchar*)p+1, strlen(p+1), hash, nil);
+	hmac_sha1((uint8_t*)cap, p-cap, (uint8_t*)p+1, strlen(p+1), hash,
+		  nil);
 	if(write(fd, hash, SHA1dlen) < 0){
 		free(cap);
 		werrstr("write #¤/caphash: %r");
@@ -620,7 +621,7 @@ chuid(char* to)
 static int
 noauth(int fd)
 {
-	char response[32];
+	int8_t response[32];
 
 	ealgs = nil;
 	writestr(fd, user, "noauth user", 1);
@@ -632,7 +633,7 @@ noauth(int fd)
 }
 
 static int
-srvnoauth(int fd, char *user)
+srvnoauth(int fd, int8_t *user)
 {
 	int ufd;
 
@@ -658,9 +659,9 @@ srvnoauth(int fd, char *user)
 }
 
 void
-loghex(uchar *p, int n)
+loghex(uint8_t *p, int n)
 {
-	char buf[100];
+	int8_t buf[100];
 	int i;
 
 	for(i = 0; i < n; i++)
@@ -669,12 +670,12 @@ loghex(uchar *p, int n)
 }
 
 static int
-srvp9auth(int fd, char *user)
+srvp9auth(int fd, int8_t *user)
 {
-	uchar key[16];
-	uchar digest[SHA1dlen];
-	char fromclientsecret[21];
-	char fromserversecret[21];
+	uint8_t key[16];
+	uint8_t digest[SHA1dlen];
+	int8_t fromclientsecret[21];
+	int8_t fromserversecret[21];
 	int i;
 	AuthInfo *ai;
 
@@ -714,7 +715,7 @@ srvp9auth(int fd, char *user)
  *  set authentication mechanism
  */
 int
-setam(char *name)
+setam(int8_t *name)
 {
 	for(am = authmethod; am->name != nil; am++)
 		if(strcmp(am->name, name) == 0)
@@ -727,7 +728,7 @@ setam(char *name)
  *  set authentication mechanism and encryption/hash algs
  */
 int
-setamalg(char *s)
+setamalg(int8_t *s)
 {
 	ealgs = strchr(s, ' ');
 	if(ealgs != nil)
@@ -735,7 +736,7 @@ setamalg(char *s)
 	return setam(s);
 }
 
-char *rmtnotefile = "/mnt/term/dev/cpunote";
+int8_t *rmtnotefile = "/mnt/term/dev/cpunote";
 
 /*
  *  loop reading /mnt/term/dev/note looking for notes.
@@ -745,7 +746,7 @@ void
 rmtnoteproc(void)
 {
 	int n, fd, pid, notepid;
-	char buf[256];
+	int8_t buf[256];
 
 	/* new proc returns to start shell */
 	pid = rfork(RFPROC|RFFDG|RFNOTEG|RFNAMEG|RFMEM);
@@ -812,7 +813,7 @@ typedef struct Note Note;
 struct Note
 {
 	Note *next;
-	char msg[ERRMAX];
+	int8_t msg[ERRMAX];
 };
 
 typedef struct Request Request;
@@ -840,7 +841,7 @@ struct {
 int
 fsreply(int fd, Fcall *f)
 {
-	uchar buf[IOHDRSZ+Maxfdata];
+	uint8_t buf[IOHDRSZ+Maxfdata];
 	int n;
 
 	if(dbg)
@@ -928,7 +929,7 @@ int
 fsstat(int fd, Fid *fid, Fcall *f)
 {
 	Dir d;
-	uchar statbuf[256];
+	uint8_t statbuf[256];
 
 	memset(&d, 0, sizeof(d));
 	d.name = fstab[fid->file].name;
@@ -947,7 +948,7 @@ int
 fsread(int fd, Fid *fid, Fcall *f)
 {
 	Dir d;
-	uchar buf[256];
+	uint8_t buf[256];
 	Request *rp;
 
 	switch(fid->file){
@@ -964,7 +965,7 @@ fsread(int fd, Fid *fid, Fcall *f)
 			d.mode = fstab[Qcpunote].perm;
 			d.atime = d.mtime = time(0);
 			f->count = convD2M(&d, buf, sizeof buf);
-			f->data = (char*)buf;
+			f->data = (int8_t*)buf;
 		} else
 			f->count = 0;
 		return fsreply(fd, f);
@@ -984,14 +985,14 @@ fsread(int fd, Fid *fid, Fcall *f)
 	}
 }
 
-char Eperm[] = "permission denied";
-char Enofile[] = "out of files";
-char Enotdir[] = "not a directory";
+int8_t Eperm[] = "permission denied";
+int8_t Enofile[] = "out of files";
+int8_t Enotdir[] = "not a directory";
 
 void
 notefs(int fd)
 {
-	uchar buf[IOHDRSZ+Maxfdata];
+	uint8_t buf[IOHDRSZ+Maxfdata];
 	int i, n, ncpunote;
 	Fcall f;
 	Qid wqid[MAXWELEM];
@@ -1137,10 +1138,10 @@ err:
 	close(fd);
 }
 
-char 	notebuf[ERRMAX];
+int8_t 	notebuf[ERRMAX];
 
 void
-catcher(void*, char *text)
+catcher(void*, int8_t *text)
 {
 	int n;
 

+ 5 - 5
sys/src/9/k10/syscall.c

@@ -25,8 +25,8 @@
 typedef struct {
 	uintptr	ip;
 	Ureg*	arg0;
-	char*	arg1;
-	char	msg[ERRMAX];
+	int8_t*	arg1;
+	int8_t	msg[ERRMAX];
 	Ureg*	old;
 	Ureg	ureg;
 } NFrame;
@@ -233,10 +233,10 @@ void
 syscall(int badscallnr, Ureg* ureg)
 {
 	unsigned int scallnr = (unsigned int) badscallnr;
-	char *e;
+	int8_t *e;
 	uintptr	sp;
 	int s;
-	vlong startns, stopns;
+	int64_t startns, stopns;
 	Ar0 ar0;
 	static Ar0 zar0;
 
@@ -389,7 +389,7 @@ sysexecstack(uintptr stack, int argc)
 }
 
 void*
-sysexecregs(uintptr entry, ulong ssize, ulong nargs)
+sysexecregs(uintptr entry, uint32_t ssize, uint32_t nargs)
 {
 	uintptr *sp;
 	Ureg *ureg;

+ 5 - 5
sys/src/9/k10/tcore.c

@@ -136,9 +136,9 @@ extern int notify(Ureg*);
  * interrupted while issuing the ICC.
  */
 int
-runac(Mach *mp, APfunc func, int flushtlb, void *a, long n)
+runac(Mach *mp, APfunc func, int flushtlb, void *a, int32_t n)
 {
-	uchar *dpg, *spg;
+	uint8_t *dpg, *spg;
 
 	if (n > sizeof(mp->icc->data))
 		panic("runac: args too long");
@@ -235,8 +235,8 @@ runacore(void)
 	Ureg *ureg;
 	void (*fn)(void);
 	int rc, flush, s;
-	char *n;
-	uvlong t1;
+	int8_t *n;
+	uint64_t t1;
 
 	if(waserror())
 		panic("runacore: error: %s\n", up->errstr);
@@ -325,7 +325,7 @@ ToTC:
 extern ACVctl *acvctl[];
 
 void
-actrapenable(int vno, char* (*f)(Ureg*, void*), void* a, char *name)
+actrapenable(int vno, int8_t* (*f)(Ureg*, void*), void* a, int8_t *name)
 {
 	ACVctl *v;
 

+ 17 - 17
sys/src/9/k10/trap.c

@@ -35,13 +35,13 @@ static Vctl *vctl[256];
 
 typedef struct Intrtime Intrtime;
 struct Intrtime {
-	uvlong	count;
-	uvlong	cycles;
+	uint64_t	count;
+	uint64_t	cycles;
 };
 static Intrtime intrtimes[256];
 
 void*
-intrenable(int irq, void (*f)(Ureg*, void*), void* a, int tbdf, char *name)
+intrenable(int irq, void (*f)(Ureg*, void*), void* a, int tbdf, int8_t *name)
 {
 	int vno;
 	Vctl *v;
@@ -119,12 +119,12 @@ intrdisable(void* vector)
 	return 0;
 }
 
-static long
-irqallocread(Chan*, void *vbuf, long n, vlong offset)
+static int32_t
+irqallocread(Chan*, void *vbuf, int32_t n, int64_t offset)
 {
-	char *buf, *p, str[2*(11+1)+2*(20+1)+(KNAMELEN+1)+(8+1)+1];
+	int8_t *buf, *p, str[2*(11+1)+2*(20+1)+(KNAMELEN+1)+(8+1)+1];
 	int m, vno;
-	long oldn;
+	int32_t oldn;
 	Intrtime *t;
 	Vctl *v;
 
@@ -162,7 +162,7 @@ irqallocread(Chan*, void *vbuf, long n, vlong offset)
 }
 
 void
-trapenable(int vno, void (*f)(Ureg*, void*), void* a, char *name)
+trapenable(int vno, void (*f)(Ureg*, void*), void* a, int8_t *name)
 {
 	Vctl *v;
 
@@ -218,7 +218,7 @@ trapinit(void)
 	addarchfile("irqalloc", 0444, irqallocread, nil);
 }
 
-static char* excname[32] = {
+static int8_t* excname[32] = {
 	"#DE",					/* Divide-by-Zero Error */
 	"#DB",					/* Debug */
 	"#NMI",					/* Non-Maskable-Interrupt */
@@ -259,7 +259,7 @@ static char* excname[32] = {
 void
 intrtime(int vno)
 {
-	ulong diff, x;		/* should be uvlong */
+	uint32_t diff, x;		/* should be uvlong */
 
 	x = perfticks();
 	diff = x - m->perf.intrts;
@@ -284,7 +284,7 @@ void (*_pmcupdate)(Mach *m) = pmcnop;
 void
 kexit(Ureg*)
 {
- 	uvlong t;
+ 	uint64_t t;
 	Tos *tos;
 	Mach *mp;
 
@@ -338,7 +338,7 @@ void
 trap(Ureg* ureg)
 {
 	int clockintr, vno, user;
-	char buf[ERRMAX];
+	int8_t buf[ERRMAX];
 	Vctl *ctl, *v;
 
 	vno = ureg->type;
@@ -527,9 +527,9 @@ callwithureg(void (*fn)(Ureg*))
 static void
 dumpstackwithureg(Ureg* ureg)
 {
-	char *s;
+	int8_t *s;
 	uintptr l, v, i, estack;
-	extern ulong etext;
+	extern uint32_t etext;
 	int x;
 
 	if((s = getconf("*nodumpstack")) != nil && atoi(s) != 0){
@@ -581,7 +581,7 @@ dumpstack(void)
 static void
 debugbpt(Ureg* ureg, void*)
 {
-	char buf[ERRMAX];
+	int8_t buf[ERRMAX];
 
 	if(up == 0)
 		panic("kernel bpt");
@@ -613,7 +613,7 @@ faultamd64(Ureg* ureg, void*)
 {
 	u64int addr;
 	int read, user, insyscall;
-	char buf[ERRMAX];
+	int8_t buf[ERRMAX];
 
 	addr = m->cr2;
 	user = userureg(ureg);
@@ -673,7 +673,7 @@ userpc(Ureg* ureg)
  * TODO: fix this because the segment registers are wrong for 64-bit mode. 
  */
 void
-setregisters(Ureg* ureg, char* pureg, char* uva, int n)
+setregisters(Ureg* ureg, int8_t* pureg, int8_t* uva, int n)
 {
 	u64int cs, flags, ss;
 	u16int ds, es, fs, gs;

+ 5 - 5
sys/src/9/port/alarm.c

@@ -20,7 +20,7 @@ void
 alarmkproc(void*)
 {
 	Proc *rp;
-	ulong now;
+	uint32_t now;
 
 	for(;;){
 		now = sys->ticks;
@@ -52,7 +52,7 @@ void
 checkalarms(void)
 {
 	Proc *p;
-	ulong now;
+	uint32_t now;
 
 	p = alarms.head;
 	now = sys->ticks;
@@ -61,11 +61,11 @@ checkalarms(void)
 		wakeup(&alarmr);
 }
 
-ulong
-procalarm(ulong time)
+uint32_t
+procalarm(uint32_t time)
 {
 	Proc **l, *f;
-	ulong when, old;
+	uint32_t when, old;
 
 	if(up->alarm)
 		old = tk2ms(up->alarm - sys->ticks);

+ 42 - 41
sys/src/9/port/alloc.c

@@ -18,16 +18,16 @@ extern void* xalloc(ulong);
 extern void xinit(void);
 extern int xmerge(void*, void*);
 
-static void poolprint(Pool*, char*, ...);
-static void ppanic(Pool*, char*, ...);
+static void poolprint(Pool*, int8_t*, ...);
+static void ppanic(Pool*, int8_t*, ...);
 static void plock(Pool*);
 static void punlock(Pool*);
 
 typedef struct Private	Private;
 struct Private {
 	Lock		lk;
-	char*		end;
-	char		msg[256];	/* a rock for messages to be printed at unlock */
+	int8_t*		end;
+	int8_t		msg[256];	/* a rock for messages to be printed at unlock */
 };
 
 static Private pmainpriv;
@@ -74,7 +74,7 @@ Pool*	imagmem = &pimagmem;
  * we have the save the message and print it once we let go.
  */
 static void
-poolprint(Pool *p, char *fmt, ...)
+poolprint(Pool *p, int8_t *fmt, ...)
 {
 	va_list v;
 	Private *pv;
@@ -86,11 +86,11 @@ poolprint(Pool *p, char *fmt, ...)
 }
 
 static void
-ppanic(Pool *p, char *fmt, ...)
+ppanic(Pool *p, int8_t *fmt, ...)
 {
 	va_list v;
 	Private *pv;
-	char msg[sizeof pv->msg];
+	int8_t msg[sizeof pv->msg];
 
 	pv = p->private;
 	va_start(v, fmt);
@@ -116,7 +116,7 @@ static void
 punlock(Pool *p)
 {
 	Private *pv;
-	char msg[sizeof pv->msg];
+	int8_t msg[sizeof pv->msg];
 
 	pv = p->private;
 	if(pv->end == pv->msg){
@@ -130,8 +130,8 @@ punlock(Pool *p)
 	iprint("%.*s", sizeof pv->msg, msg);
 }
 
-static char*
-poolsummary(Pool* p, char* s, char* e)
+static int8_t*
+poolsummary(Pool* p, int8_t* s, int8_t* e)
 {
 	return seprint(s, e, "%s max %lud cur %lud free %lud alloc %lud\n",
 		p->name, p->maxsize, p->cursize, p->curfree, p->curalloc);
@@ -140,7 +140,7 @@ poolsummary(Pool* p, char* s, char* e)
 void
 mallocsummary(void)
 {
-	char buf[256], *p;
+	int8_t buf[256], *p;
 
 	p = poolsummary(mainmem, buf, buf+sizeof(buf));
 	poolsummary(imagmem, p, buf+sizeof(buf));
@@ -148,10 +148,10 @@ mallocsummary(void)
 	print(buf);
 }
 
-long
-mallocreadsummary(Chan*, void *a, long n, long offset)
+int32_t
+mallocreadsummary(Chan*, void *a, int32_t n, int32_t offset)
 {
-	char buf[256], *p;
+	int8_t buf[256], *p;
 
 	p = poolsummary(mainmem, buf, buf+sizeof(buf));
 	poolsummary(imagmem, p, buf+sizeof(buf));
@@ -201,18 +201,18 @@ enum {
 
 
 void*
-smalloc(ulong size)
+smalloc(uint32_t size)
 {
 	void *v;
 
 	for(;;) {
-		v = poolalloc(mainmem, size+Npadlong*sizeof(ulong));
+		v = poolalloc(mainmem, size+Npadlong*sizeof(uint32_t));
 		if(v != nil)
 			break;
 		tsleep(&up->sleep, return0, 0, 100);
 	}
 	if(Npadlong){
-		v = (ulong*)v+Npadlong;
+		v = (uint32_t*)v+Npadlong;
 		setmalloctag(v, getcallerpc(&size));
 	}
 	memset(v, 0, size);
@@ -220,15 +220,15 @@ smalloc(ulong size)
 }
 
 void*
-malloc(ulong size)
+malloc(uint32_t size)
 {
 	void *v;
 
-	v = poolalloc(mainmem, size+Npadlong*sizeof(ulong));
+	v = poolalloc(mainmem, size+Npadlong*sizeof(uint32_t));
 	if(v == nil)
 		return nil;
 	if(Npadlong){
-		v = (ulong*)v+Npadlong;
+		v = (uint32_t*)v+Npadlong;
 		setmalloctag(v, getcallerpc(&size));
 		setrealloctag(v, 0);
 	}
@@ -237,13 +237,13 @@ malloc(ulong size)
 }
 
 void*
-mallocz(ulong size, int clr)
+mallocz(uint32_t size, int clr)
 {
 	void *v;
 
-	v = poolalloc(mainmem, size+Npadlong*sizeof(ulong));
+	v = poolalloc(mainmem, size+Npadlong*sizeof(uint32_t));
 	if(Npadlong && v != nil){
-		v = (ulong*)v+Npadlong;
+		v = (uint32_t*)v+Npadlong;
 		setmalloctag(v, getcallerpc(&size));
 		setrealloctag(v, 0);
 	}
@@ -253,13 +253,14 @@ mallocz(ulong size, int clr)
 }
 
 void*
-mallocalign(ulong size, ulong align, long offset, ulong span)
+mallocalign(uint32_t size, uint32_t align, int32_t offset, uint32_t span)
 {
 	void *v;
 
-	v = poolallocalign(mainmem, size+Npadlong*sizeof(ulong), align, offset-Npadlong*sizeof(ulong), span);
+	v = poolallocalign(mainmem, size+Npadlong*sizeof(uint32_t), align,
+			   offset-Npadlong*sizeof(uint32_t), span);
 	if(Npadlong && v != nil){
-		v = (ulong*)v+Npadlong;
+		v = (uint32_t*)v+Npadlong;
 		setmalloctag(v, getcallerpc(&size));
 		setrealloctag(v, 0);
 	}
@@ -270,21 +271,21 @@ void
 free(void *v)
 {
 	if(v != nil)
-		poolfree(mainmem, (ulong*)v-Npadlong);
+		poolfree(mainmem, (uint32_t*)v-Npadlong);
 }
 
 void*
-realloc(void *v, ulong size)
+realloc(void *v, uint32_t size)
 {
 	void *nv;
 
 	if(v != nil)
-		v = (ulong*)v-Npadlong;
+		v = (uint32_t*)v-Npadlong;
 	if(Npadlong !=0 && size != 0)
-		size += Npadlong*sizeof(ulong);
+		size += Npadlong*sizeof(uint32_t);
 
 	if(nv = poolrealloc(mainmem, v, size)){
-		nv = (ulong*)nv+Npadlong;
+		nv = (uint32_t*)nv+Npadlong;
 		setrealloctag(nv, getcallerpc(&v));
 		if(v == nil)
 			setmalloctag(nv, getcallerpc(&v));
@@ -292,16 +293,16 @@ realloc(void *v, ulong size)
 	return nv;
 }
 
-ulong
+uint32_t
 msize(void *v)
 {
-	return poolmsize(mainmem, (ulong*)v-Npadlong)-Npadlong*sizeof(ulong);
+	return poolmsize(mainmem, (uint32_t*)v-Npadlong)-Npadlong*sizeof(uint32_t);
 }
 
 void
-setmalloctag(void *v, ulong pc)
+setmalloctag(void *v, uint32_t pc)
 {
-	ulong *u;
+	uint32_t *u;
 	USED(v, pc);
 	if(Npadlong <= MallocOffset || v == nil)
 		return;
@@ -310,9 +311,9 @@ setmalloctag(void *v, ulong pc)
 }
 
 void
-setrealloctag(void *v, ulong pc)
+setrealloctag(void *v, uint32_t pc)
 {
-	ulong *u;
+	uint32_t *u;
 	USED(v, pc);
 	if(Npadlong <= ReallocOffset || v == nil)
 		return;
@@ -320,20 +321,20 @@ setrealloctag(void *v, ulong pc)
 	u[-Npadlong+ReallocOffset] = pc;
 }
 
-ulong
+uint32_t
 getmalloctag(void *v)
 {
 	USED(v);
 	if(Npadlong <= MallocOffset)
 		return ~0;
-	return ((ulong*)v)[-Npadlong+MallocOffset];
+	return ((uint32_t*)v)[-Npadlong+MallocOffset];
 }
 
-ulong
+uint32_t
 getrealloctag(void *v)
 {
 	USED(v);
 	if(Npadlong <= ReallocOffset)
-		return ((ulong*)v)[-Npadlong+ReallocOffset];
+		return ((uint32_t*)v)[-Npadlong+ReallocOffset];
 	return ~0;
 }

+ 4 - 4
sys/src/9/port/allocb.c

@@ -29,7 +29,7 @@ static Block*
 _allocb(int size)
 {
 	Block *b;
-	uchar *p;
+	uint8_t *p;
 	int n;
 
 	n = BLOCKALIGN + ROUNDUP(size+Hdrspc, BLOCKALIGN) + sizeof(Block);
@@ -44,7 +44,7 @@ _allocb(int size)
 	b->flag = 0;
 
 	/* align base and bounds of data */
-	b->lim = (uchar*)(PTR2UINT(b) & ~(BLOCKALIGN-1));
+	b->lim = (uint8_t*)(PTR2UINT(b) & ~(BLOCKALIGN-1));
 
 	/* align start of writable data, leaving space below for added headers */
 	b->rp = b->lim - ROUNDUP(size, BLOCKALIGN);
@@ -117,7 +117,7 @@ void
 freeb(Block *b)
 {
 	void *dead = (void*)Bdead;
-	uchar *p;
+	uint8_t *p;
 
 	if(b == nil)
 		return;
@@ -149,7 +149,7 @@ freeb(Block *b)
 }
 
 void
-checkb(Block *b, char *msg)
+checkb(Block *b, int8_t *msg)
 {
 	void *dead = (void*)Bdead;
 

+ 12 - 12
sys/src/9/port/cache.c

@@ -25,7 +25,7 @@ typedef struct Extent Extent;
 struct Extent
 {
 	int	bid;
-	ulong	start;
+	uint32_t	start;
 	int	len;
 	Page	*cache;
 	Extent	*next;
@@ -274,14 +274,14 @@ cdev(Mntcache *mc, Chan *c)
 }
 
 int
-cread(Chan *c, uchar *buf, int len, vlong off)
+cread(Chan *c, uint8_t *buf, int len, int64_t off)
 {
 	KMap *k;
 	Page *p;
 	Mntcache *mc;
 	Extent *e, **t;
 	int o, l, total;
-	ulong offset;
+	uint32_t offset;
 
 	if(off+len > maxcache)
 		return 0;
@@ -332,7 +332,7 @@ cread(Chan *c, uchar *buf, int len, vlong off)
 			nexterror();
 		}
 
-		memmove(buf, (uchar*)VA(k) + o, l);
+		memmove(buf, (uint8_t*)VA(k) + o, l);
 
 		poperror();
 		kunmap(k);
@@ -354,7 +354,7 @@ cread(Chan *c, uchar *buf, int len, vlong off)
 }
 
 Extent*
-cchain(uchar *buf, ulong offset, int len, Extent **tail)
+cchain(uint8_t *buf, uint32_t offset, int len, Extent **tail)
 {
 	int l;
 	Page *p;
@@ -421,7 +421,7 @@ cchain(uchar *buf, ulong offset, int len, Extent **tail)
 }
 
 int
-cpgmove(Extent *e, uchar *buf, int boff, int len)
+cpgmove(Extent *e, uint8_t *buf, int boff, int len)
 {
 	Page *p;
 	KMap *k;
@@ -436,7 +436,7 @@ cpgmove(Extent *e, uchar *buf, int boff, int len)
 		nexterror();
 	}
 
-	memmove((uchar*)VA(k)+boff, buf, len);
+	memmove((uint8_t*)VA(k)+boff, buf, len);
 
 	poperror();
 	kunmap(k);
@@ -446,13 +446,13 @@ cpgmove(Extent *e, uchar *buf, int boff, int len)
 }
 
 void
-cupdate(Chan *c, uchar *buf, int len, vlong off)
+cupdate(Chan *c, uint8_t *buf, int len, int64_t off)
 {
 	Mntcache *mc;
 	Extent *tail;
 	Extent *e, *f, *p;
 	int o, ee, eblock;
-	ulong offset;
+	uint32_t offset;
 
 	if(off > maxcache || len == 0)
 		return;
@@ -537,13 +537,13 @@ if(f && p->start + p->len > f->start) print("CACHE: p->start=%uld p->len=%d f->s
 }
 
 void
-cwrite(Chan* c, uchar *buf, int len, vlong off)
+cwrite(Chan* c, uint8_t *buf, int len, int64_t off)
 {
 	int o, eo;
 	Mntcache *mc;
-	ulong eblock, ee;
+	uint32_t eblock, ee;
 	Extent *p, *f, *e, *tail;
-	ulong offset;
+	uint32_t offset;
 
 	if(off > maxcache || len == 0)
 		return;

+ 39 - 39
sys/src/9/port/chan.c

@@ -32,17 +32,17 @@ typedef struct Elemlist Elemlist;
 
 struct Elemlist
 {
-	char	*aname;	/* original name */
-	char	*name;	/* copy of name, so '/' can be overwritten */
+	int8_t	*aname;	/* original name */
+	int8_t	*name;	/* copy of name, so '/' can be overwritten */
 	int	nelems;
-	char	**elems;
+	int8_t	**elems;
 	int	*off;
 	int	mustbedir;
 	int	nerror;
 	int	prefix;
 };
 
-char*
+int8_t*
 chanpath(Chan *c)
 {
 	if(c == nil)
@@ -55,7 +55,7 @@ chanpath(Chan *c)
 }
 
 int
-isdotdot(char *p)
+isdotdot(int8_t *p)
 {
 	return p[0]=='.' && p[1]=='.' && p[2]=='\0';
 }
@@ -67,7 +67,7 @@ isdotdot(char *p)
  * save a string in up->genbuf;
  */
 void
-kstrcpy(char *s, char *t, int ns)
+kstrcpy(int8_t *s, int8_t *t, int ns)
 {
 	int nt;
 
@@ -93,7 +93,7 @@ kstrcpy(char *s, char *t, int ns)
 }
 
 int
-emptystr(char *s)
+emptystr(int8_t *s)
 {
 	if(s == nil)
 		return 1;
@@ -106,10 +106,10 @@ emptystr(char *s)
  * Atomically replace *p with copy of s
  */
 void
-kstrdup(char **p, char *s)
+kstrdup(int8_t **p, int8_t *s)
 {
 	int n;
-	char *t, *prev;
+	int8_t *t, *prev;
 
 	n = strlen(s)+1;
 	/* if it's a user, we can wait for memory; if not, something's very wrong */
@@ -171,7 +171,7 @@ newchan(void)
 Ref npath;
 
 Path*
-newpath(char *s)
+newpath(int8_t *s)
 {
 	int i;
 	Path *p;
@@ -259,7 +259,7 @@ pathclose(Path *p)
 static void
 fixdotdotname(Path *p)
 {
-	char *r;
+	int8_t *r;
 
 	if(p->s[0] == '#'){
 		r = strchr(p->s, '/');
@@ -293,9 +293,9 @@ uniquepath(Path *p)
 }
 
 static Path*
-addelem(Path *p, char *s, Chan *from)
+addelem(Path *p, int8_t *s, Chan *from)
 {
-	char *t;
+	int8_t *t;
 	int a, i;
 	Chan *c, **tt;
 
@@ -543,7 +543,7 @@ newmhead(Chan *from)
 }
 
 int
-cmount(Chan **newp, Chan *old, int flag, char *spec)
+cmount(Chan **newp, Chan *old, int flag, int8_t *spec)
 {
 	int order, flg;
 	Chan *new;
@@ -846,7 +846,7 @@ undomount(Chan *c, Path *path)
  * Call dev walk but catch errors.
  */
 static Walkqid*
-ewalk(Chan *c, Chan *nc, char **name, int nname)
+ewalk(Chan *c, Chan *nc, int8_t **name, int nname)
 {
 	Walkqid *wq;
 
@@ -861,9 +861,9 @@ ewalk(Chan *c, Chan *nc, char **name, int nname)
  * Either walks all the way or not at all.  No partial results in *cp.
  * *nerror is the number of names to display in an error message.
  */
-static char Edoesnotexist[] = "does not exist";
+static int8_t Edoesnotexist[] = "does not exist";
 int
-walk(Chan **cp, char **names, int nnames, int nomount, int *nerror)
+walk(Chan **cp, int8_t **names, int nnames, int nomount, int *nerror)
 {
 	int dc, devno, didmount, dotdot, i, n, nhave, ntry;
 	Chan *c, *nc, *mtpt;
@@ -1069,13 +1069,13 @@ saveregisters(void)
 static void
 growparse(Elemlist *e)
 {
-	char **new;
+	int8_t **new;
 	int *inew;
 	enum { Delta = 8 };
 
 	if(e->nelems % Delta == 0){
-		new = smalloc((e->nelems+Delta) * sizeof(char*));
-		memmove(new, e->elems, e->nelems*sizeof(char*));
+		new = smalloc((e->nelems+Delta) * sizeof(int8_t*));
+		memmove(new, e->elems, e->nelems*sizeof(int8_t*));
 		free(e->elems);
 		e->elems = new;
 		inew = smalloc((e->nelems+Delta+1) * sizeof(int));
@@ -1095,9 +1095,9 @@ growparse(Elemlist *e)
  * rather than a directory.
  */
 static void
-parsename(char *aname, Elemlist *e)
+parsename(int8_t *aname, Elemlist *e)
 {
-	char *name, *slash;
+	int8_t *name, *slash;
 
 	kstrdup(&e->name, aname);
 	name = e->name;
@@ -1136,9 +1136,9 @@ parsename(char *aname, Elemlist *e)
 }
 
 static void*
-memrchr(void *va, int c, long n)
+memrchr(void *va, int c, int32_t n)
 {
-	uchar *a, *e;
+	uint8_t *a, *e;
 
 	a = va;
 	for(e=a+n-1; e>a; e--)
@@ -1148,9 +1148,9 @@ memrchr(void *va, int c, long n)
 }
 
 static void
-namelenerror(char *aname, int len, char *err)
+namelenerror(int8_t *aname, int len, int8_t *err)
 {
-	char *ename, *name, *next;
+	int8_t *ename, *name, *next;
 	int i, errlen;
 
 	/*
@@ -1193,7 +1193,7 @@ namelenerror(char *aname, int len, char *err)
 }
 
 void
-nameerror(char *name, char *err)
+nameerror(int8_t *name, int8_t *err)
 {
 	namelenerror(name, strlen(name), err);
 }
@@ -1215,7 +1215,7 @@ nameerror(char *name, char *err)
  * correct name so they can rewrite the stat info.
  */
 Chan*
-namec(char *aname, int amode, int omode, int perm)
+namec(int8_t *aname, int amode, int omode, int perm)
 {
 	int len, n, nomount;
 	Chan *c, *cnew;
@@ -1223,8 +1223,8 @@ namec(char *aname, int amode, int omode, int perm)
 	Elemlist e;
 	Rune r;
 	Mhead *mh;
-	char *createerr, tmperrbuf[ERRMAX];
-	char *name;
+	int8_t *createerr, tmperrbuf[ERRMAX];
+	int8_t *name;
 	Dev *dev;
 
 	if(aname[0] == '\0')
@@ -1583,8 +1583,8 @@ if(c->umh != nil){
 /*
  * name is valid. skip leading / and ./ as much as possible
  */
-char*
-skipslash(char *name)
+int8_t*
+skipslash(int8_t *name)
 {
 	while(name[0]=='/' || (name[0]=='.' && (name[1]==0 || name[1]=='/')))
 		name++;
@@ -1615,10 +1615,10 @@ char isfrog[256]={
  * (Otherwise a malicious thread could remove the NUL, causing us
  * to access unchecked addresses.)
  */
-static char*
-validname0(char *aname, int slashok, int dup, uintptr pc)
+static int8_t*
+validname0(int8_t *aname, int slashok, int dup, uintptr pc)
 {
-	char *ename, *name, *s;
+	int8_t *ename, *name, *s;
 	int c, n;
 	Rune r;
 
@@ -1646,7 +1646,7 @@ validname0(char *aname, int slashok, int dup, uintptr pc)
 
 	while(*name){
 		/* all characters above '~' are ok */
-		c = *(uchar*)name;
+		c = *(uint8_t*)name;
 		if(c >= Runeself)
 			name += chartorune(&r, name);
 		else{
@@ -1663,13 +1663,13 @@ validname0(char *aname, int slashok, int dup, uintptr pc)
 }
 
 void
-validname(char *aname, int slashok)
+validname(int8_t *aname, int slashok)
 {
 	validname0(aname, slashok, 0, getcallerpc(&aname));
 }
 
-char*
-validnamedup(char *aname, int slashok)
+int8_t*
+validnamedup(int8_t *aname, int slashok)
 {
 	return validname0(aname, slashok, 1, getcallerpc(&aname));
 }

+ 29 - 24
sys/src/9/port/dev.c

@@ -14,10 +14,10 @@
 #include	"fns.h"
 #include	"../port/error.h"
 
-extern ulong	kerndate;
+extern uint32_t	kerndate;
 
 void
-mkqid(Qid *q, vlong path, ulong vers, int type)
+mkqid(Qid *q, int64_t path, uint32_t vers, int type)
 {
 	q->type = type;
 	q->vers = vers;
@@ -25,7 +25,9 @@ mkqid(Qid *q, vlong path, ulong vers, int type)
 }
 
 void
-devdir(Chan *c, Qid qid, char *n, vlong length, char *user, long perm, Dir *db)
+devdir(Chan *c, Qid qid, int8_t *n, int64_t length, int8_t *user,
+       int32_t perm,
+       Dir *db)
 {
 	db->name = n;
 	if(c->flag&CMSG)
@@ -84,7 +86,7 @@ devdir(Chan *c, Qid qid, char *n, vlong length, char *user, long perm, Dir *db)
  * the zeroth element of the table MUST be the directory itself for ..
 */
 int
-devgen(Chan *c, char *name, Dirtab *tab, int ntab, int i, Dir *dp)
+devgen(Chan *c, int8_t *name, Dirtab *tab, int ntab, int i, Dir *dp)
 {
 	if(tab == 0)
 		return -1;
@@ -124,10 +126,10 @@ devshutdown(void)
 }
 
 Chan*
-devattach(int dc, char *spec)
+devattach(int dc, int8_t *spec)
 {
 	Chan *c;
-	char *buf;
+	int8_t *buf;
 
 	/*
 	 * There are no error checks here because
@@ -176,11 +178,12 @@ devclone(Chan *c)
 }
 
 Walkqid*
-devwalk(Chan *c, Chan *nc, char **name, int nname, Dirtab *tab, int ntab, Devgen *gen)
+devwalk(Chan *c, Chan *nc, int8_t **name, int nname, Dirtab *tab, int ntab,
+	Devgen *gen)
 {
 	int i, j, alloc;
 	Walkqid *wq;
-	char *n;
+	int8_t *n;
 	Dir dir;
 
 	if(nname > 0)
@@ -280,12 +283,13 @@ Done:
 	return wq;
 }
 
-long
-devstat(Chan *c, uchar *db, long n, Dirtab *tab, int ntab, Devgen *gen)
+int32_t
+devstat(Chan *c, uint8_t *db, int32_t n, Dirtab *tab, int ntab,
+	Devgen *gen)
 {
 	int i;
 	Dir dir;
-	char *p, *elem;
+	int8_t *p, *elem;
 
 	for(i=0;; i++){
 		switch((*gen)(c, nil, tab, ntab, i, &dir)){
@@ -323,10 +327,11 @@ devstat(Chan *c, uchar *db, long n, Dirtab *tab, int ntab, Devgen *gen)
 	}
 }
 
-long
-devdirread(Chan *c, char *d, long n, Dirtab *tab, int ntab, Devgen *gen)
+int32_t
+devdirread(Chan *c, int8_t *d, int32_t n, Dirtab *tab, int ntab,
+	   Devgen *gen)
 {
-	long m, dsz;
+	int32_t m, dsz;
 	Dir dir;
 
 	for(m=0; m<n; c->dri++) {
@@ -338,7 +343,7 @@ devdirread(Chan *c, char *d, long n, Dirtab *tab, int ntab, Devgen *gen)
 			break;
 
 		case 1:
-			dsz = convD2M(&dir, (uchar*)d, n-m);
+			dsz = convD2M(&dir, (uint8_t*)d, n-m);
 			if(dsz <= BIT16SZ){	/* <= not < because this isn't stat; read is stuck */
 				if(m == 0)
 					error(Eshort);
@@ -357,7 +362,7 @@ devdirread(Chan *c, char *d, long n, Dirtab *tab, int ntab, Devgen *gen)
  * error(Eperm) if open permission not granted for up->user.
  */
 void
-devpermcheck(char *fileuid, int perm, int omode)
+devpermcheck(int8_t *fileuid, int perm, int omode)
 {
 	int t;
 	static int access[] = { 0400, 0200, 0600, 0100 };
@@ -405,13 +410,13 @@ Return:
 }
 
 void
-devcreate(Chan*, char*, int, int)
+devcreate(Chan*, int8_t*, int, int)
 {
 	error(Eperm);
 }
 
 Block*
-devbread(Chan *c, long n, vlong offset)
+devbread(Chan *c, int32_t n, int64_t offset)
 {
 	Block *bp;
 
@@ -427,10 +432,10 @@ devbread(Chan *c, long n, vlong offset)
 	return bp;
 }
 
-long
-devbwrite(Chan *c, Block *bp, vlong offset)
+int32_t
+devbwrite(Chan *c, Block *bp, int64_t offset)
 {
-	long n;
+	int32_t n;
 
 	if(waserror()) {
 		freeb(bp);
@@ -449,8 +454,8 @@ devremove(Chan*)
 	error(Eperm);
 }
 
-long
-devwstat(Chan*, uchar*, long)
+int32_t
+devwstat(Chan*, uint8_t*, int32_t)
 {
 	error(Eperm);
 	return 0;
@@ -463,7 +468,7 @@ devpower(int)
 }
 
 int
-devconfig(int, char *, DevConf *)
+devconfig(int, int8_t *, DevConf *)
 {
 	error(Eperm);
 	return 0;

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

@@ -120,7 +120,7 @@ enum {
 	Djumbo	= 1<<7,
 };
 
-static char *flagname[] = {
+static int8_t *flagname[] = {
 	"llba",
 	"smart",
 	"power",
@@ -133,28 +133,28 @@ static char *flagname[] = {
 };
 
 typedef struct {
-	uchar	flag;
-	uchar	lostjumbo;
+	uint8_t	flag;
+	uint8_t	lostjumbo;
 	int	datamtu;
 
 	Chan	*cc;
 	Chan	*dc;
 	Chan	*mtu;		/* open early to prevent bind issues. */
-	char	path[Maxpath];
-	uchar	ea[Eaddrlen];
+	int8_t	path[Maxpath];
+	uint8_t	ea[Eaddrlen];
 } Netlink;
 
 typedef struct {
 	Netlink	*nl;
 	int	nea;
-	ulong	eaidx;
-	uchar	eatab[Nea][Eaddrlen];
-	ulong	npkt;
-	ulong	resent;
-	uchar	flag;
-
-	ulong	rttavg;
-	ulong	mintimer;
+	uint32_t	eaidx;
+	uint8_t	eatab[Nea][Eaddrlen];
+	uint32_t	npkt;
+	uint32_t	resent;
+	uint8_t	flag;
+
+	uint32_t	rttavg;
+	uint32_t	mintimer;
 } Devlink;
 
 typedef struct Srb Srb;
@@ -173,12 +173,12 @@ struct Srb {
 
 typedef struct {
 	int	tag;
-	ulong	bcnt;
-	ulong	dlen;
-	vlong	lba;
-	ulong	ticksent;
+	uint32_t	bcnt;
+	uint32_t	dlen;
+	int64_t	lba;
+	uint32_t	ticksent;
 	int	nhdr;
-	uchar	hdr[ETHERMINTU];
+	uint8_t	hdr[ETHERMINTU];
 	void	*dp;
 	Devlink	*dl;
 	Netlink	*nl;
@@ -259,11 +259,11 @@ static int	debug;
 static int	autodiscover	= 1;
 static int	rediscover;
 
-char 	Enotup[] 	= "aoe device is down";
-char	Echange[]	= "media or partition has changed";
+int8_t 	Enotup[] 	= "aoe device is down";
+int8_t	Echange[]	= "media or partition has changed";
 
 static Srb*
-srballoc(ulong sz)
+srballoc(uint32_t sz)
 {
 	Srb *srb;
 
@@ -274,7 +274,7 @@ srballoc(ulong sz)
 }
 
 static Srb*
-srbkalloc(void *db, ulong)
+srbkalloc(void *db, uint32_t)
 {
 	Srb *srb;
 
@@ -287,7 +287,7 @@ srbkalloc(void *db, ulong)
 #define srbfree(srb) free(srb)
 
 static void
-srberror(Srb *srb, char *s)
+srberror(Srb *srb, int8_t *s)
 {
 	srb->error = s;
 	srb->nout--;
@@ -296,7 +296,7 @@ srberror(Srb *srb, char *s)
 }
 
 static void
-frameerror(Aoedev *d, Frame *f, char *s)
+frameerror(Aoedev *d, Frame *f, int8_t *s)
 {
 	Srb *srb;
 
@@ -309,7 +309,7 @@ frameerror(Aoedev *d, Frame *f, char *s)
 	d->nout--;
 }
 
-static char*
+static int8_t*
 unitname(Aoedev *d)
 {
 	uprint("%d.%d", d->major, d->minor);
@@ -322,11 +322,11 @@ eventlogready(void*)
 	return *events.rp;
 }
 
-static long
-eventlogread(void *a, long n)
+static int32_t
+eventlogread(void *a, int32_t n)
 {
 	int len;
-	char *p, *buf;
+	int8_t *p, *buf;
 
 	buf = smalloc(Eventlen);
 	qlock(&events);
@@ -362,10 +362,10 @@ eventlogread(void *a, long n)
 }
 
 static int
-eventlog(char *fmt, ...)
+eventlog(int8_t *fmt, ...)
 {
 	int dragrp, n;
-	char *p;
+	int8_t *p;
 	va_list arg;
 
 	lock(&events);
@@ -425,7 +425,7 @@ newtag(Aoedev *d)
 }
 
 static void
-downdev(Aoedev *d, char *err)
+downdev(Aoedev *d, int8_t *err)
 {
 	Frame *f, *e;
 
@@ -456,9 +456,9 @@ allocfb(Frame *f)
 }
 
 static void
-putlba(Aoeata *a, vlong lba)
+putlba(Aoeata *a, int64_t lba)
 {
-	uchar *c;
+	uint8_t *c;
 
 	c = a->lba;
 	c[0] = lba;
@@ -472,7 +472,7 @@ putlba(Aoeata *a, vlong lba)
 static Devlink*
 pickdevlink(Aoedev *d)
 {
-	ulong i, n;
+	uint32_t i, n;
 	Devlink *l;
 
 	for(i = 0; i < d->ndl; i++){
@@ -532,7 +532,7 @@ hset(Aoedev *d, Frame *f, Aoehdr *h, int cmd)
 static int
 resend(Aoedev *d, Frame *f)
 {
-	ulong n;
+	uint32_t n;
 	Aoeata *a;
 
 	a = (Aoeata*)f->hdr;
@@ -594,10 +594,10 @@ discover(int major, int minor)
 static void
 aoesweepproc(void*)
 {
-	ulong i, tx, timeout, nbc;
-	vlong starttick;
+	uint32_t i, tx, timeout, nbc;
+	int64_t starttick;
 	enum { Nms = 100, Nbcms = 30*1000, };
-	uchar *ea;
+	uint8_t *ea;
 	Aoeata *a;
 	Aoedev *d;
 	Devlink *l;
@@ -678,13 +678,13 @@ fmtæ(Fmt *f)
 	return fmtstrcpy(f, buf);
 }
 
-static void netbind(char *path);
+static void netbind(int8_t *path);
 
 static void
 aoecfg(void)
 {
 	int n, i;
-	char *p, *f[32], buf[24];
+	int8_t *p, *f[32], buf[24];
 
 	if((p = getconf("aoeif")) == nil || (n = tokenize(p, f, nelem(f))) < 1)
 		return;
@@ -723,7 +723,7 @@ aoeinit(void)
 }
 
 static Chan*
-aoeattach(char *spec)
+aoeattach(int8_t *spec)
 {
 	Chan *c;
 
@@ -736,7 +736,7 @@ aoeattach(char *spec)
 }
 
 static Aoedev*
-unit2dev(ulong unit)
+unit2dev(uint32_t unit)
 {
 	int i;
 	Aoedev *d;
@@ -755,12 +755,12 @@ unit2dev(ulong unit)
 }
 
 static int
-unitgen(Chan *c, ulong type, Dir *dp)
+unitgen(Chan *c, uint32_t type, Dir *dp)
 {
 	int perm, t;
-	ulong vers;
-	vlong size;
-	char *p;
+	uint32_t vers;
+	int64_t size;
+	int8_t *p;
 	Aoedev *d;
 	Qid q;
 
@@ -804,11 +804,11 @@ unitgen(Chan *c, ulong type, Dir *dp)
 }
 
 static int
-topgen(Chan *c, ulong type, Dir *d)
+topgen(Chan *c, uint32_t type, Dir *d)
 {
 	int perm;
-	vlong size;
-	char *p;
+	int64_t size;
+	int8_t *p;
 	Qid q;
 
 	perm = 0444;
@@ -831,7 +831,7 @@ topgen(Chan *c, ulong type, Dir *d)
 }
 
 static int
-aoegen(Chan *c, char *, Dirtab *, int, int s, Dir *dp)
+aoegen(Chan *c, int8_t *, Dirtab *, int, int s, Dir *dp)
 {
 	int i;
 	Aoedev *d;
@@ -914,13 +914,13 @@ aoegen(Chan *c, char *, Dirtab *, int, int s, Dir *dp)
 }
 
 static Walkqid*
-aoewalk(Chan *c, Chan *nc, char **name, int nname)
+aoewalk(Chan *c, Chan *nc, int8_t **name, int nname)
 {
 	return devwalk(c, nc, name, nname, nil, 0, aoegen);
 }
 
-static long
-aoestat(Chan *c, uchar *db, long n)
+static int32_t
+aoestat(Chan *c, uint8_t *db, int32_t n)
 {
 	return devstat(c, db, n, nil, 0, aoegen);
 }
@@ -968,8 +968,8 @@ aoeclose(Chan *c)
 static void
 atarw(Aoedev *d, Frame *f)
 {
-	ulong bcnt;
-	char extbit, writebit;
+	uint32_t bcnt;
+	int8_t extbit, writebit;
 	Aoeata *ah;
 	Srb *srb;
 
@@ -1010,7 +1010,7 @@ atarw(Aoedev *d, Frame *f)
 
 	/* mark tracking fields and load out */
 	srb->nout++;
-	srb->dp = (uchar*)srb->dp + bcnt;
+	srb->dp = (uint8_t*)srb->dp + bcnt;
 	srb->len -= bcnt;
 	srb->sector += bcnt / Aoesectsz;
 	if(srb->len == 0)
@@ -1026,11 +1026,11 @@ atarw(Aoedev *d, Frame *f)
 	poperror();
 }
 
-static char*
+static int8_t*
 aoeerror(Aoehdr *h)
 {
 	int n;
-	static char *errs[] = {
+	static int8_t *errs[] = {
 		"aoe protocol error: unknown",
 		"aoe protocol error: bad command code",
 		"aoe protocol error: bad argument param",
@@ -1144,10 +1144,10 @@ strategy(Aoedev *d, Srb *srb)
 
 #define iskaddr(a)	((uintptr)(a) > KZERO)
 
-static long
-rw(Aoedev *d, int write, uchar *db, long len, uvlong off)
+static int32_t
+rw(Aoedev *d, int write, uint8_t *db, int32_t len, uint64_t off)
 {
-	long n, nlen, copy;
+	int32_t n, nlen, copy;
 	enum { Srbsz = 1<<18, };
 	Srb *srb;
 
@@ -1194,21 +1194,21 @@ rw(Aoedev *d, int write, uchar *db, long len, uvlong off)
 	return len;
 }
 
-static long
-readmem(ulong off, void *dst, long n, void *src, long size)
+static int32_t
+readmem(uint32_t off, void *dst, int32_t n, void *src, int32_t size)
 {
 	if(off >= size)
 		return 0;
 	if(off + n > size)
 		n = size - off;
-	memmove(dst, (uchar*)src + off, n);
+	memmove(dst, (uint8_t*)src + off, n);
 	return n;
 }
 
-static char *
-pflag(char *s, char *e, uchar f)
+static int8_t *
+pflag(int8_t *s, int8_t *e, uint8_t f)
 {
-	uchar i, m;
+	uint8_t i, m;
 
 	for(i = 0; i < 8; i++){
 		m = 1 << i;
@@ -1219,10 +1219,10 @@ pflag(char *s, char *e, uchar f)
 }
 
 static int
-pstat(Aoedev *d, char *db, int len, int off)
+pstat(Aoedev *d, int8_t *db, int len, int off)
 {
 	int i;
-	char *state, *s, *p, *e;
+	int8_t *state, *s, *p, *e;
 
 	s = p = malloc(READSTR);
 	e = p + READSTR;
@@ -1250,8 +1250,8 @@ pstat(Aoedev *d, char *db, int len, int off)
 	return i;
 }
 
-static long
-unitread(Chan *c, void *db, long len, vlong off)
+static int32_t
+unitread(Chan *c, void *db, int32_t len, int64_t off)
 {
 	Aoedev *d;
 
@@ -1280,7 +1280,7 @@ static int
 devlinkread(Chan *c, void *db, int len, int off)
 {
 	int i;
-	char *s, *p, *e;
+	int8_t *s, *p, *e;
 	Aoedev *d;
 	Devlink *l;
 
@@ -1316,11 +1316,11 @@ devlinkread(Chan *c, void *db, int len, int off)
 	return i;
 }
 
-static long
+static int32_t
 topctlread(Chan *, void *db, int len, int off)
 {
 	int i;
-	char *s, *p, *e;
+	int8_t *s, *p, *e;
 	Netlink *n;
 
 	s = p = malloc(READSTR);
@@ -1348,8 +1348,8 @@ topctlread(Chan *, void *db, int len, int off)
 	return i;
 }
 
-static long
-aoeread(Chan *c, void *db, long n, vlong off)
+static int32_t
+aoeread(Chan *c, void *db, int32_t n, int64_t off)
 {
 	switch(TYPE(c->qid)){
 	default:
@@ -1373,10 +1373,10 @@ aoeread(Chan *c, void *db, long n, vlong off)
 	}
 }
 
-static long
-configwrite(Aoedev *d, void *db, long len)
+static int32_t
+configwrite(Aoedev *d, void *db, int32_t len)
 {
-	char *s;
+	int8_t *s;
 	Aoeqc *ch;
 	Frame *f;
 	Srb *srb;
@@ -1478,7 +1478,7 @@ devmaxdata(Aoedev *d)
 }
 
 static int
-toggle(char *s, int init)
+toggle(int8_t *s, int init)
 {
 	if(s == nil)
 		return init ^ 1;
@@ -1487,11 +1487,11 @@ toggle(char *s, int init)
 
 static void ataident(Aoedev*);
 
-static long
-unitctlwrite(Aoedev *d, void *db, long n)
+static int32_t
+unitctlwrite(Aoedev *d, void *db, int32_t n)
 {
 	uint maxbcnt, m;
-	uvlong bsize;
+	uint64_t bsize;
 	enum {
 		Failio,
 		Ident,
@@ -1575,11 +1575,11 @@ unitctlwrite(Aoedev *d, void *db, long n)
 	return n;
 }
 
-static long
-unitwrite(Chan *c, void *db, long n, vlong off)
+static int32_t
+unitwrite(Chan *c, void *db, int32_t n, int64_t off)
 {
-	long rv;
-	char *buf;
+	int32_t rv;
+	int8_t *buf;
 	Aoedev *d;
 
 	d = unit2dev(UNIT(c->qid));
@@ -1605,7 +1605,7 @@ unitwrite(Chan *c, void *db, long n, vlong off)
 }
 
 static Netlink*
-addnet(char *path, Chan *cc, Chan *dc, Chan *mtu, uchar *ea)
+addnet(int8_t *path, Chan *cc, Chan *dc, Chan *mtu, uint8_t *ea)
 {
 	Netlink *nl, *e;
 
@@ -1657,7 +1657,7 @@ dropunit(void)
 }
 
 static Aoedev*
-newdev(long major, long minor, int n)
+newdev(int32_t major, int32_t minor, int n)
 {
 	Aoedev *d;
 	Frame *f, *e;
@@ -1706,7 +1706,7 @@ mm2dev(int major, int minor)
 
 /* Find the device in our list.  If not known, add it */
 static Aoedev*
-getdev(long major, long minor, int n)
+getdev(int32_t major, int32_t minor, int n)
 {
 	Aoedev *d;
 
@@ -1728,10 +1728,10 @@ getdev(long major, long minor, int n)
 	return d;
 }
 
-static ushort
+static uint16_t
 gbit16(void *a)
 {
-	uchar *i;
+	uint8_t *i;
 
 	i = a;
 	return i[1] << 8 | i[0];
@@ -1741,7 +1741,7 @@ static u32int
 gbit32(void *a)
 {
 	u32int j;
-	uchar *i;
+	uint8_t *i;
 
 	i = a;
 	j  = i[3] << 24;
@@ -1751,13 +1751,13 @@ gbit32(void *a)
 	return j;
 }
 
-static uvlong
+static uint64_t
 gbit64(void *a)
 {
-	uchar *i;
+	uint8_t *i;
 
 	i = a;
-	return (uvlong)gbit32(i+4) << 32 | gbit32(a);
+	return (uint64_t)gbit32(i+4) << 32 | gbit32(a);
 }
 
 static void
@@ -1790,7 +1790,7 @@ static int
 getmtu(Chan *m)
 {
 	int n, mtu;
-	char buf[36];
+	int8_t buf[36];
 
 	mtu = 1514;
 	if(m == nil || waserror())
@@ -1805,10 +1805,10 @@ getmtu(Chan *m)
 }
 
 static int
-newdlea(Devlink *l, uchar *ea)
+newdlea(Devlink *l, uint8_t *ea)
 {
 	int i;
-	uchar *t;
+	uint8_t *t;
 
 	for(i = 0; i < Nea; i++){
 		t = l->eatab[i];
@@ -1847,7 +1847,7 @@ newdevlink(Aoedev *d, Netlink *n, Aoeqc *c)
 }
 
 static void
-errrsp(Block *b, char *s)
+errrsp(Block *b, int8_t *s)
 {
 	int n;
 	Aoedev *d;
@@ -1959,10 +1959,10 @@ qcfgrsp(Block *b, Netlink *nl)
 }
 
 void
-aoeidmove(char *p, ushort *u, unsigned n)
+aoeidmove(int8_t *p, uint16_t *u, unsigned n)
 {
 	int i;
-	char *op, *e, *s;
+	int8_t *op, *e, *s;
 
 	op = p;
 	/*
@@ -1970,7 +1970,7 @@ aoeidmove(char *p, ushort *u, unsigned n)
 	 * so dereferencing a[i] would cause an alignment exception on
 	 * some machines.
 	 */
-	s = (char *)u;
+	s = (int8_t *)u;
 	for(i = 0; i < n; i += 2){
 		*p++ = s[i + 1];
 		*p++ = s[i];
@@ -1985,11 +1985,11 @@ aoeidmove(char *p, ushort *u, unsigned n)
 	memmove(op, p, n - (e - p));
 }
 
-static vlong
-aoeidentify(Aoedev *d, ushort *id)
+static int64_t
+aoeidentify(Aoedev *d, uint16_t *id)
 {
 	int i;
-	vlong s;
+	int64_t s;
 
 	d->flag &= ~(Dllba|Dpower|Dsmart|Dnop|Dup);
 
@@ -2025,10 +2025,10 @@ newvers(Aoedev *d)
 }
 
 static int
-identify(Aoedev *d, ushort *id)
+identify(Aoedev *d, uint16_t *id)
 {
-	vlong osectors, s;
-	uchar oserial[21];
+	int64_t osectors, s;
+	uint8_t oserial[21];
 
 	s = aoeidentify(d, id);
 	if(s == -1)
@@ -2055,7 +2055,7 @@ static void
 atarsp(Block *b)
 {
 	unsigned n;
-	short major;
+	int16_t major;
 	Aoeata *ahin, *ahout;
 	Aoedev *d;
 	Frame *f;
@@ -2096,14 +2096,14 @@ atarsp(Block *b)
 					d, BLEN(b), n);
 				goto bail;
 			}
-			memmove(f->dp, (uchar *)ahin + AOEATASZ, n);
+			memmove(f->dp, (uint8_t *)ahin + AOEATASZ, n);
 		case Cwr:
 		case Cwrext:
 			if(n > Dbcnt)
 				f->nl->lostjumbo = 0;
 			if(f->bcnt -= n){
 				f->lba += n / Aoesectsz;
-				f->dp = (uchar*)f->dp + n;
+				f->dp = (uint8_t*)f->dp + n;
 				resend(d, f);
 				goto bail;
 			}
@@ -2114,7 +2114,7 @@ atarsp(Block *b)
 					d, BLEN(b), n);
 				goto bail;
 			}
-			identify(d, (ushort*)((uchar *)ahin + AOEATASZ));
+			identify(d, (uint16_t*)((uint8_t *)ahin + AOEATASZ));
 			break;
 		default:
 			eventlog("%æ: unknown ata command %.2ux \n",
@@ -2138,7 +2138,7 @@ static void
 netrdaoeproc(void *v)
 {
 	int idx;
-	char name[Maxpath+1], *s;
+	int8_t name[Maxpath+1], *s;
 	Aoehdr *h;
 	Block *b;
 	Netlink *nl;
@@ -2191,12 +2191,12 @@ netrdaoeproc(void *v)
 }
 
 static void
-getaddr(char *path, uchar *ea)
+getaddr(int8_t *path, uint8_t *ea)
 {
 	int n;
-	char buf[2*Eaddrlen+1];
+	int8_t buf[2*Eaddrlen+1];
 	Chan *c;
-	extern int parseether(uchar*, char*);
+	extern int parseether(uint8_t*, int8_t*);
 
 	uprint("%s/addr", path);
 	c = namec(up->genbuf, Aopen, OREAD, 0);
@@ -2215,10 +2215,10 @@ getaddr(char *path, uchar *ea)
 }
 
 static void
-netbind(char *path)
+netbind(int8_t *path)
 {
-	char addr[Maxpath];
-	uchar ea[2*Eaddrlen+1];
+	int8_t addr[Maxpath];
+	uint8_t ea[2*Eaddrlen+1];
 	Chan *dc, *cc, *mtu;
 	Netlink *nl;
 
@@ -2255,7 +2255,7 @@ unbound(void *v)
 }
 
 static void
-netunbind(char *path)
+netunbind(int8_t *path)
 {
 	int i, idx;
 	Aoedev *d, *p, *next;
@@ -2355,7 +2355,7 @@ netunbind(char *path)
 }
 
 static void
-removedev(char *name)
+removedev(int8_t *name)
 {
 	int i;
 	Aoedev *d, *p;
@@ -2385,11 +2385,11 @@ found:
 }
 
 static void
-discoverstr(char *f)
+discoverstr(int8_t *f)
 {
-	ushort shelf, slot;
-	ulong sh;
-	char *s;
+	uint16_t shelf, slot;
+	uint32_t sh;
+	int8_t *s;
 
 	if(f == 0){
 		discover(0xffff, 0xff);
@@ -2410,8 +2410,8 @@ discoverstr(char *f)
 }
 
 
-static long
-topctlwrite(void *db, long n)
+static int32_t
+topctlwrite(void *db, int32_t n)
 {
 	enum {
 		Autodiscover,
@@ -2423,7 +2423,7 @@ topctlwrite(void *db, long n)
 		Remove,
 		Unbind,
 	};
-	char *f;
+	int8_t *f;
 	Cmdbuf *cb;
 	Cmdtab *ct;
 	static Cmdtab cmds[] = {
@@ -2473,8 +2473,8 @@ topctlwrite(void *db, long n)
 	return n;
 }
 
-static long
-aoewrite(Chan *c, void *db, long n, vlong off)
+static int32_t
+aoewrite(Chan *c, void *db, int32_t n, int64_t off)
 {
 	switch(TYPE(c->qid)){
 	default:

+ 21 - 20
sys/src/9/port/devcap.c

@@ -30,8 +30,8 @@ typedef struct Caphash	Caphash;
 struct Caphash
 {
 	Caphash	*next;
-	char		hash[Hashlen];
-	ulong		ticks;
+	int8_t		hash[Hashlen];
+	uint32_t		ticks;
 };
 
 struct
@@ -58,13 +58,13 @@ Dirtab capdir[] =
 int ncapdir = nelem(capdir);
 
 static Chan*
-capattach(char *spec)
+capattach(int8_t *spec)
 {
 	return devattach(L'¤', spec);
 }
 
 static Walkqid*
-capwalk(Chan *c, Chan *nc, char **name, int nname)
+capwalk(Chan *c, Chan *nc, int8_t **name, int nname)
 {
 	return devwalk(c, nc, name, nname, capdir, ncapdir, devgen);
 }
@@ -79,8 +79,8 @@ capremove(Chan *c)
 }
 
 
-static long
-capstat(Chan *c, uchar *db, long n)
+static int32_t
+capstat(Chan *c, uint8_t *db, int32_t n)
 {
 	return devstat(c, db, n, capdir, ncapdir, devgen);
 }
@@ -100,7 +100,7 @@ capopen(Chan *c, int omode)
 		return c;
 	}
 
-	switch((ulong)c->qid.path){
+	switch((uint32_t)c->qid.path){
 	case Qhash:
 		if(!iseve())
 			error(Eperm);
@@ -128,7 +128,7 @@ hashstr(uchar *hash)
  */
 
 static Caphash*
-remcap(uchar *hash)
+remcap(uint8_t *hash)
 {
 	Caphash *t, **l;
 
@@ -153,7 +153,7 @@ remcap(uchar *hash)
 
 /* add a capability, throwing out any old ones */
 static void
-addcap(uchar *hash)
+addcap(uint8_t *hash)
 {
 	Caphash *p, *t, **l;
 
@@ -188,10 +188,10 @@ capclose(Chan*)
 {
 }
 
-static long
-capread(Chan *c, void *va, long n, vlong)
+static int32_t
+capread(Chan *c, void *va, int32_t n, int64_t)
 {
-	switch((ulong)c->qid.path){
+	switch((uint32_t)c->qid.path){
 	case Qdir:
 		return devdirread(c, va, n, capdir, ncapdir, devgen);
 
@@ -202,16 +202,16 @@ capread(Chan *c, void *va, long n, vlong)
 	return n;
 }
 
-static long
-capwrite(Chan *c, void *va, long n, vlong)
+static int32_t
+capwrite(Chan *c, void *va, int32_t n, int64_t)
 {
 	Caphash *p;
-	char *cp;
-	uchar hash[Hashlen];
-	char *key, *from, *to;
-	char err[256];
+	int8_t *cp;
+	uint8_t hash[Hashlen];
+	int8_t *key, *from, *to;
+	int8_t err[256];
 
-	switch((ulong)c->qid.path){
+	switch((uint32_t)c->qid.path){
 	case Qhash:
 		if(!iseve())
 			error(Eperm);
@@ -238,7 +238,8 @@ capwrite(Chan *c, void *va, long n, vlong)
 			error(Eshort);
 		*key++ = 0;
 
-		hmac_sha1((uchar*)from, strlen(from), (uchar*)key, strlen(key), hash, nil);
+		hmac_sha1((uint8_t*)from, strlen(from), (uint8_t*)key,
+			  strlen(key), hash, nil);
 
 		p = remcap(hash);
 		if(p == nil){

+ 47 - 46
sys/src/9/port/devcec.c

@@ -51,7 +51,7 @@ enum {
 	Copen,
 };
 
-static char *cstate[] = {
+static int8_t *cstate[] = {
 	"unused",
 	"initb",
 	"login",
@@ -62,19 +62,19 @@ typedef struct {
 	Chan	*dc;
 	Chan	*cc;
 	Dev	*d;
-	uchar	ea[6];
-	char	path[32];
+	uint8_t	ea[6];
+	int8_t	path[32];
 } If;
 
 typedef struct {
-	uchar	dst[6];
-	uchar	src[6];
-	uchar	etype[2];
-	uchar	type;
-	uchar	conn;
-	uchar	seq;
-	uchar	len;
-	uchar	data[0x100];
+	uint8_t	dst[6];
+	uint8_t	src[6];
+	uint8_t	etype[2];
+	uint8_t	type;
+	uint8_t	conn;
+	uint8_t	seq;
+	uint8_t	len;
+	uint8_t	data[0x100];
 } Pkt;
 
 typedef struct {
@@ -97,8 +97,8 @@ typedef struct {
 	char	passwd[32];	/* password typed by connection */
 } Conn;
 
-extern int parseether(uchar *, char *);
-extern Chan *chandial(char *, char *, char *, Chan **);
+extern int parseether(uint8_t *, int8_t *);
+extern Chan *chandial(int8_t *, int8_t *, int8_t *, Chan **);
 
 enum {
 	Qdir = 0,
@@ -118,16 +118,16 @@ enum {
 };
 
 static 	If 	ifs[4];
-static 	char 	name[Namelen];
+static 	int8_t 	name[Namelen];
 static	int	shelf = -1;
 static 	Conn 	conn[Nconns];
 static	int	tflag;
-static	char	passwd[Namelen];
+static	int8_t	passwd[Namelen];
 static	int	xmit;
 static	int	rsnd;
 static	Rendez	trendez;
 static	int	tcond;
-static	uchar	broadcast[6] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
+static	uint8_t	broadcast[6] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
 static 	Dirtab	cecdir[] = {
 	".",		{ Qdir, 0, QTDIR },	0,	DMDIR | 0555,
 	"cecstat",	{ Qstat},		1,	0444,
@@ -152,9 +152,9 @@ static	Cmdtab	ceccmd[] = {
  * Avoid outputting debugging to ourselves. Assumes a serial port.
  */
 static int
-cecprint(char *fmt, ...)
+cecprint(int8_t *fmt, ...)
 {
-	char buf[PRINTSIZE];
+	int8_t buf[PRINTSIZE];
 	int n;
 	va_list arg;
 
@@ -166,9 +166,9 @@ cecprint(char *fmt, ...)
 }
 
 static void
-getaddr(char *path, uchar *ea)
+getaddr(int8_t *path, uint8_t *ea)
 {
-	char buf[6*2];
+	int8_t buf[6*2];
 	int n;
 	Chan *c;
 
@@ -187,7 +187,7 @@ getaddr(char *path, uchar *ea)
 	cclose(c);
 }
 
-static char *types[Tlast+1] = {
+static int8_t *types[Tlast+1] = {
 	"Tinita", "Tinitb", "Tinitc", "Tdata", "Tack",
 	"Tdiscover", "Toffer", "Treset", "*GOK*",
 };
@@ -230,7 +230,7 @@ trace(Block *bp)
 }
 
 static Block*
-sethdr(If *ifc, uchar *ea, Pkt **npp, int len)
+sethdr(If *ifc, uint8_t *ea, Pkt **npp, int len)
 {
 	Block *bp;
 	Pkt *np;
@@ -299,7 +299,7 @@ resend(Conn *cp)
 }
 
 static void
-reset(If *ifc, uchar conn)
+reset(If *ifc, uint8_t conn)
 {
 	Block *bp;
 	Pkt *p;
@@ -324,7 +324,7 @@ ack(Conn *cp)
 static void
 start(Conn *cp)
 {
-	char buf[250];
+	int8_t buf[250];
 	int n, c;
 
 	if(cp->bp)
@@ -341,7 +341,7 @@ start(Conn *cp)
 }
 
 static void
-cecputs(char *str, int n)
+cecputs(int8_t *str, int n)
 {
 	int i, c, wake;
 	Conn *cp;
@@ -370,7 +370,7 @@ cecputs(char *str, int n)
 }
 
 static void
-conputs(Conn *c, char *s)
+conputs(Conn *c, int8_t *s)
 {
 	for(; *s; s++)
 		cbput(c, *s);
@@ -438,7 +438,7 @@ cecqlen(void*)
 static void
 discover(If *ifc, Pkt *p)
 {
-	uchar *addr;
+	uint8_t *addr;
 	Block *bp;
 	Pkt *np;
 
@@ -448,7 +448,8 @@ discover(If *ifc, Pkt *p)
 		addr = broadcast;
 	bp = sethdr(ifc, addr, &np, 0);
 	np->type = Toffer;
-	np->len = snprint((char *)np->data, sizeof np->data, "%d %s", shelf, name);
+	np->len = snprint((int8_t *)np->data, sizeof np->data, "%d %s",
+			  shelf, name);
 	trace(bp);
 	ifc->d->bwrite(ifc->dc, bp, 0);
 }
@@ -467,7 +468,7 @@ connidx(int cno)
 }
 
 static Conn*
-findconn(uchar *ea, uchar cno)
+findconn(uint8_t *ea, uint8_t cno)
 {
 	Conn *cp, *ncp;
 
@@ -486,7 +487,7 @@ findconn(uchar *ea, uchar cno)
 }
 
 static void
-checkpw(Conn *cp, char *str, int len)
+checkpw(Conn *cp, int8_t *str, int len)
 {
 	int i, c;
 
@@ -542,9 +543,9 @@ incoming(Conn *cp, If *ifc, Pkt *p)
 	cp->rcvseq = p->seq;
 	if(cp->state == Copen){
 		for (i = 0; i < p->len; i++)
-			kbdcr2nl(nil, (char)p->data[i]);
+			kbdcr2nl(nil, (int8_t)p->data[i]);
 	}else if(cp->state == Clogin)
-		checkpw(cp, (char *)p->data, p->len);
+		checkpw(cp, (int8_t *)p->data, p->len);
 }
 
 static void
@@ -664,7 +665,7 @@ exit:
 }
 
 static Chan *
-cecattach(char *spec)
+cecattach(int8_t *spec)
 {
 	Chan *c;
 	static QLock q;
@@ -682,13 +683,13 @@ cecattach(char *spec)
 }
 
 static Walkqid*
-cecwalk(Chan *c, Chan *nc, char **name, int nname)
+cecwalk(Chan *c, Chan *nc, int8_t **name, int nname)
 {
 	return devwalk(c, nc, name, nname, cecdir, nelem(cecdir), devgen);
 }
 
-static long
-cecstat(Chan *c, uchar *dp, long n)
+static int32_t
+cecstat(Chan *c, uint8_t *dp, int32_t n)
 {
 	return devstat(c, dp, n, cecdir, nelem(cecdir), devgen);
 }
@@ -704,10 +705,10 @@ cecclose(Chan*)
 {
 }
 
-static long
-cecread(Chan *c, void *a, long n, vlong offset)
+static int32_t
+cecread(Chan *c, void *a, int32_t n, int64_t offset)
 {
-	char *p;
+	int8_t *p;
 	int j;
 	Conn *cp;
 	If *ifc;
@@ -761,10 +762,10 @@ cecfixup(void)
 */
 
 static void
-cecon(char *path)
+cecon(int8_t *path)
 {
-	char buf[64];
-	uchar ea[6];
+	int8_t buf[64];
+	uint8_t ea[6];
 	Chan *dc, *cc;
 	If *ifc, *nifc;
 
@@ -799,7 +800,7 @@ cecon(char *path)
 }
 
 static void
-cecoff(char *path)
+cecoff(int8_t *path)
 {
 	int all, n;
 	If *ifc, *e;
@@ -831,8 +832,8 @@ rst(Conn *c)
 	qunlock(c);
 }
 
-static long
-cecwrite(Chan *c, void *a, long n, vlong)
+static int32_t
+cecwrite(Chan *c, void *a, int32_t n, int64_t)
 {
 	Cmdbuf *cb;
 	Cmdtab *cp;
@@ -867,7 +868,7 @@ cecwrite(Chan *c, void *a, long n, vlong)
 			shelf = atoi(cb->f[1]);
 			break;
 		case CMwrite:
-			cecputs((char*)a+6,n-6);
+			cecputs((int8_t*)a+6,n-6);
 			break;
 		case CMreset:
 			rst(connidx(atoi(cb->f[1])));

+ 25 - 25
sys/src/9/port/devcmd.c

@@ -44,18 +44,18 @@ struct Conv
 	int	fd[3];	/* stdin, stdout, and stderr */
 	int	count[3];	/* number of readers on stdin/stdout/stderr */
 	int	perm;
-	ulong esz;
-	char*	owner;
-	char*	state;
+	uint32_t esz;
+	int8_t*	owner;
+	int8_t*	state;
 	Cmdbuf*	cmd;
-	char*	dir;
+	int8_t*	dir;
 	QLock	l;	/* protects state changes */
 	Queue*	waitq;
 	void*	child;
-	char*	error;	/* on start up */
+	int8_t*	error;	/* on start up */
 	int	nice;
-	short	killonclose;
-	short	killed;
+	int16_t	killonclose;
+	int16_t	killed;
 	Rendez	startr;
 	Proc *p;
 };
@@ -68,7 +68,7 @@ static struct
 	Conv**	conv;
 } cmd;
 
-static	Conv*	cmdclone(char*);
+static	Conv*	cmdclone(int8_t*);
 static	void	cmdproc(void*);
 
 static int
@@ -113,7 +113,7 @@ cmd3gen(Chan *c, int i, Dir *dp)
 }
 
 static int
-cmdgen(Chan *c, char *name, Dirtab *d, int nd, int s, Dir *dp)
+cmdgen(Chan *c, int8_t *name, Dirtab *d, int nd, int s, Dir *dp)
 {
 	Qid q;
 	Conv *cv;
@@ -191,7 +191,7 @@ cmdinit(void)
 }
 
 static Chan *
-cmdattach(char *spec)
+cmdattach(int8_t *spec)
 {
 	Chan *c;
 
@@ -203,13 +203,13 @@ cmdattach(char *spec)
 }
 
 static Walkqid*
-cmdwalk(Chan *c, Chan *nc, char **name, int nname)
+cmdwalk(Chan *c, Chan *nc, int8_t **name, int nname)
 {
 	return devwalk(c, nc, name, nname, 0, 0, cmdgen);
 }
 
-static long
-cmdstat(Chan *c, uchar *db, long n)
+static int32_t
+cmdstat(Chan *c, uint8_t *db, int32_t n)
 {
 	return devstat(c, db, n, 0, 0, cmdgen);
 }
@@ -219,7 +219,7 @@ cmdopen(Chan *c, int omode)
 {
 	int perm;
 	Conv *cv;
-	char *user;
+	int8_t *user;
 
 	perm = 0;
 	omode = openmode(omode);
@@ -383,14 +383,14 @@ cmdclose(Chan *c)
 	}
 }
 
-static long
-cmdread(Chan *ch, void *a, long n, vlong offset)
+static int32_t
+cmdread(Chan *ch, void *a, int32_t n, int64_t offset)
 {
 	Conv *c;
 	Proc *p;
-	char *s, *cmds;
+	int8_t *s, *cmds;
 	int fd;
-	char buf[256];
+	int8_t buf[256];
 
 	USED(offset);
 
@@ -479,8 +479,8 @@ Cmdtab cmdtab[] = {
 	CMkillonclose, "killonclose", 0,
 };
 
-static long
-cmdwrite(Chan *ch, void *a, long n, vlong offset)
+static int32_t
+cmdwrite(Chan *ch, void *a, int32_t n, int64_t offset)
 {
 	int i, r;
 	Conv *c;
@@ -580,8 +580,8 @@ cmdwrite(Chan *ch, void *a, long n, vlong offset)
 	return n;
 }
 
-static long
-cmdwstat(Chan *c, uchar *dp, long n)
+static int32_t
+cmdwstat(Chan *c, uint8_t *dp, int32_t n)
 {
 	Dir *d;
 	Conv *cv;
@@ -599,7 +599,7 @@ cmdwstat(Chan *c, uchar *dp, long n)
 			free(d);
 			nexterror();
 		}
-		n = convM2D(dp, n, d, (char*)&d[1]);
+		n = convM2D(dp, n, d, (int8_t*)&d[1]);
 		if(n == 0)
 			error(Eshortstat);
 		cv = cmd.conv[CONV(c->qid)];
@@ -617,7 +617,7 @@ cmdwstat(Chan *c, uchar *dp, long n)
 }
 
 static Conv*
-cmdclone(char *user)
+cmdclone(int8_t *user)
 {
 	Conv *c, **pp, **ep;
 	int i;
@@ -666,7 +666,7 @@ cmdproc(void *a)
 {
 	Conv *c;
 	int n;
-	char status[ERRMAX];
+	int8_t status[ERRMAX];
 	void *t;
 
 	c = a;

+ 124 - 124
sys/src/9/port/devcons.c

@@ -31,15 +31,15 @@ struct Consdev
 {
 	Chan*	c;			/* external file */
 	Queue*	q;			/* i/o queue, if any */
-	void	(*fn)(char*, int);	/* i/o function when no queue */
+	void	(*fn)(int8_t*, int);	/* i/o function when no queue */
 	int	flags;
 };
 
 void	(*consdebug)(void) = nil;
-void	(*consputs)(char*, int) = nil;
+void	(*consputs)(int8_t*, int) = nil;
 
-static void kmesgputs(char *, int);
-static void kprintputs(char*, int);
+static void kmesgputs(int8_t *, int);
+static void kprintputs(int8_t*, int);
 
 static	Lock	consdevslock;
 static	int	nconsdevs = 3;
@@ -58,7 +58,7 @@ static	Queue*	kbdq;		/* unprocessed console input */
 static	Queue*	lineq;		/* processed console input */
 static	Queue*	serialoq;	/* serial console output */
 static	Queue*	kprintoq;	/* console output, for /dev/kprint */
-static	ulong	kprintinuse;	/* test and set whether /dev/kprint is open */
+static	uint32_t	kprintinuse;	/* test and set whether /dev/kprint is open */
 
 int	panicking;
 
@@ -89,14 +89,14 @@ static struct
 	.ie	= kbd.istage + sizeof(kbd.istage),
 };
 
-char	*sysname;
-vlong	fasthz;
+int8_t	*sysname;
+int64_t	fasthz;
 
 static void	seedrand(void);
-static int	readtime(ulong, char*, int);
-static int	readbintime(char*, int);
-static int	writetime(char*, int);
-static int	writebintime(char*, int);
+static int	readtime(uint32_t, int8_t*, int);
+static int	readbintime(int8_t*, int);
+static int	writetime(int8_t*, int);
+static int	writebintime(int8_t*, int);
 
 enum
 {
@@ -114,14 +114,14 @@ Cmdtab rebootmsg[] =
 
 /* To keep the rest of the kernel unware of new consdevs for now */
 static void
-kprintputs(char *s, int n)
+kprintputs(int8_t *s, int n)
 {
 	if(consputs != nil)
 		consputs(s, n);
 }
 
 int
-addconsdev(Queue *q, void (*fn)(char*,int), int i, int flags)
+addconsdev(Queue *q, void (*fn)(int8_t*,int), int i, int flags)
 {
 	Consdev *c;
 
@@ -152,7 +152,7 @@ delconsdevs(void)
 static void
 conskbdqproc(void *a)
 {
-	char buf[64];
+	int8_t buf[64];
 	Queue *q;
 	int nr;
 
@@ -236,7 +236,7 @@ consactive(void)
 void
 prflush(void)
 {
-	ulong now;
+	uint32_t now;
 
 	now = m->ticks;
 	while(consactive())
@@ -250,12 +250,12 @@ prflush(void)
  */
 struct {
 	Lock lk;
-	char buf[16384];
+	int8_t buf[16384];
 	uint n;
 } kmesg;
 
 static void
-kmesgputs(char *str, int n)
+kmesgputs(int8_t *str, int n)
 {
 	uint nn, d;
 
@@ -284,7 +284,7 @@ kmesgputs(char *str, int n)
 }
 
 static void
-consdevputs(Consdev *c, char *s, int n, int usewrite)
+consdevputs(Consdev *c, int8_t *s, int n, int usewrite)
 {
 	Chan *cc;
 	Queue *q;
@@ -307,10 +307,10 @@ consdevputs(Consdev *c, char *s, int n, int usewrite)
  *   interspersed with other messages.
  */
 static void
-putstrn0(char *str, int n, int usewrite)
+putstrn0(int8_t *str, int n, int usewrite)
 {
 	Consdev *c;
-	char *s, *t;
+	int8_t *s, *t;
 	int i, len, m;
 
 	if(!islo())
@@ -339,17 +339,17 @@ putstrn0(char *str, int n, int usewrite)
 }
 
 void
-putstrn(char *str, int n)
+putstrn(int8_t *str, int n)
 {
 	putstrn0(str, n, 0);
 }
 
 int
-print(char *fmt, ...)
+print(int8_t *fmt, ...)
 {
 	int n;
 	va_list arg;
-	char buf[PRINTSIZE];
+	int8_t buf[PRINTSIZE];
 
 	va_start(arg, fmt);
 	n = vseprint(buf, buf+sizeof(buf), fmt, arg) - buf;
@@ -383,12 +383,12 @@ iprintcanlock(Lock *l)
 }
 
 int
-iprint(char *fmt, ...)
+iprint(int8_t *fmt, ...)
 {
 	Mpl pl;
 	int i, n, locked;
 	va_list arg;
-	char buf[PRINTSIZE];
+	int8_t buf[PRINTSIZE];
 
 	pl = splhi();
 	va_start(arg, fmt);
@@ -411,12 +411,12 @@ iprint(char *fmt, ...)
 
 #pragma profile 0
 void
-panic(char *fmt, ...)
+panic(int8_t *fmt, ...)
 {
 	int n;
 	Mpl pl;
 	va_list arg;
-	char buf[PRINTSIZE];
+	int8_t buf[PRINTSIZE];
 
 	consdevs[1].q = nil;	/* don't try to write to /dev/kprint */
 
@@ -444,9 +444,9 @@ panic(char *fmt, ...)
 #pragma profile 1
 /* libmp at least contains a few calls to sysfatal; simulate with panic */
 void
-sysfatal(char *fmt, ...)
+sysfatal(int8_t *fmt, ...)
 {
-	char err[256];
+	int8_t err[256];
 	va_list arg;
 
 	va_start(arg, fmt);
@@ -456,18 +456,18 @@ sysfatal(char *fmt, ...)
 }
 
 void
-_assert(char *fmt)
+_assert(int8_t *fmt)
 {
 	panic("assert failed at %#p: %s", getcallerpc(&fmt), fmt);
 }
 
 int
-pprint(char *fmt, ...)
+pprint(int8_t *fmt, ...)
 {
 	int n;
 	Chan *c;
 	va_list arg;
-	char buf[2*PRINTSIZE];
+	int8_t buf[2*PRINTSIZE];
 
 	if(up == nil || up->fgrp == nil)
 		return 0;
@@ -493,11 +493,11 @@ pprint(char *fmt, ...)
 }
 
 static void
-echo(char *buf, int n)
+echo(int8_t *buf, int n)
 {
 	Mpl pl;
 	static int ctrlt, pid;
-	char *e, *p;
+	int8_t *e, *p;
 
 	if(n == 0)
 		return;
@@ -582,7 +582,7 @@ echo(char *buf, int n)
 int
 kbdcr2nl(Queue*, int ch)
 {
-	char *next;
+	int8_t *next;
 
 	ilock(&kbd.lockputc);		/* just a mutex */
 	if(ch == '\r' && !kbd.raw)
@@ -606,9 +606,9 @@ int
 kbdputc(Queue*, int ch)
 {
 	int i, n;
-	char buf[3];
+	int8_t buf[3];
 	Rune r;
-	char *next;
+	int8_t *next;
 
 	if(kbd.ir == nil)
 		return 0;		/* in case we're not inited yet */
@@ -636,7 +636,7 @@ kbdputc(Queue*, int ch)
 static void
 kbdputcclock(void)
 {
-	char *iw;
+	int8_t *iw;
 
 	/* this amortizes cost of qproduce */
 	if(kbd.iw != kbd.ir){
@@ -712,9 +712,9 @@ static Dirtab consdir[]={
 };
 
 int
-readnum(ulong off, char *buf, ulong n, ulong val, int size)
+readnum(uint32_t off, int8_t *buf, uint32_t n, uint32_t val, int size)
 {
-	char tmp[64];
+	int8_t tmp[64];
 
 	snprint(tmp, sizeof(tmp), "%*lud", size-1, val);
 	tmp[size-1] = ' ';
@@ -726,10 +726,10 @@ readnum(ulong off, char *buf, ulong n, ulong val, int size)
 	return n;
 }
 
-long
-readstr(long offset, char *buf, long n, char *str)
+int32_t
+readstr(int32_t offset, int8_t *buf, int32_t n, int8_t *str)
 {
-	long size;
+	int32_t size;
 
 	size = strlen(str);
 	if(offset >= size)
@@ -754,19 +754,19 @@ consinit(void)
 }
 
 static Chan*
-consattach(char *spec)
+consattach(int8_t *spec)
 {
 	return devattach('c', spec);
 }
 
 static Walkqid*
-conswalk(Chan *c, Chan *nc, char **name, int nname)
+conswalk(Chan *c, Chan *nc, int8_t **name, int nname)
 {
 	return devwalk(c, nc, name,nname, consdir, nelem(consdir), devgen);
 }
 
-static long
-consstat(Chan *c, uchar *dp, long n)
+static int32_t
+consstat(Chan *c, uint8_t *dp, int32_t n)
 {
 	return devstat(c, dp, n, consdir, nelem(consdir), devgen);
 }
@@ -776,7 +776,7 @@ consopen(Chan *c, int omode)
 {
 	c->aux = nil;
 	c = devopen(c, omode, consdir, nelem(consdir), devgen);
-	switch((ulong)c->qid.path){
+	switch((uint32_t)c->qid.path){
 	case Qconsctl:
 		incref(&kbd.ctl);
 		break;
@@ -805,7 +805,7 @@ consopen(Chan *c, int omode)
 static void
 consclose(Chan *c)
 {
-	switch((ulong)c->qid.path){
+	switch((uint32_t)c->qid.path){
 	/* last close of control file turns off raw */
 	case Qconsctl:
 		if(c->flag&COPEN){
@@ -824,22 +824,22 @@ consclose(Chan *c)
 	}
 }
 
-static long
-consread(Chan *c, void *buf, long n, vlong off)
+static int32_t
+consread(Chan *c, void *buf, int32_t n, int64_t off)
 {
-	ulong l;
+	uint32_t l;
 	Mach *mp;
-	char *b, *bp, ch, *s, *e;
-	char tmp[512];		/* Qswap is 381 bytes at clu */
+	int8_t *b, *bp, ch, *s, *e;
+	int8_t tmp[512];		/* Qswap is 381 bytes at clu */
 	int i, k, id, send;
-	long offset;
+	int32_t offset;
 
 
 	if(n <= 0)
 		return n;
 
 	offset = off;
-	switch((ulong)c->qid.path){
+	switch((uint32_t)c->qid.path){
 	case Qdir:
 		return devdirread(c, buf, n, consdir, nelem(consdir), devgen);
 
@@ -1047,21 +1047,21 @@ consread(Chan *c, void *buf, long n, vlong off)
 	return -1;		/* never reached */
 }
 
-static long
-conswrite(Chan *c, void *va, long n, vlong off)
+static int32_t
+conswrite(Chan *c, void *va, int32_t n, int64_t off)
 {
-	char buf[256], ch;
-	long l, bp;
-	char *a;
+	int8_t buf[256], ch;
+	int32_t l, bp;
+	int8_t *a;
 	Mach *mp;
 	int i;
-	ulong offset;
+	uint32_t offset;
 	Cmdbuf *cb;
 	Cmdtab *ct;
 	a = va;
 	offset = off;
 
-	switch((ulong)c->qid.path){
+	switch((uint32_t)c->qid.path){
 	case Qcons:
 		/*
 		 * Can't page fault in putstrn, so copy the data locally.
@@ -1141,7 +1141,7 @@ conswrite(Chan *c, void *va, long n, vlong off)
 			rebootcmd(cb->nf-1, cb->f+1);
 			break;
 		case CMpanic:
-			*(ulong*)0=0;
+			*(uint32_t*)0=0;
 			panic("/dev/reboot");
 		}
 		poperror();
@@ -1225,7 +1225,7 @@ Dev consdevtab = {
 	devwstat,
 };
 
-static	ulong	randn;
+static	uint32_t	randn;
 
 static void
 seedrand(void)
@@ -1252,63 +1252,63 @@ rand(void)
 	return randn;
 }
 
-static uvlong uvorder = 0x0001020304050607ULL;
+static uint64_t uvorder = 0x0001020304050607ULL;
 
-static uchar*
-le2vlong(vlong *to, uchar *f)
+static uint8_t*
+le2vlong(int64_t *to, uint8_t *f)
 {
-	uchar *t, *o;
+	uint8_t *t, *o;
 	int i;
 
-	t = (uchar*)to;
-	o = (uchar*)&uvorder;
-	for(i = 0; i < sizeof(vlong); i++)
+	t = (uint8_t*)to;
+	o = (uint8_t*)&uvorder;
+	for(i = 0; i < sizeof(int64_t); i++)
 		t[o[i]] = f[i];
-	return f+sizeof(vlong);
+	return f+sizeof(int64_t);
 }
 
-static uchar*
-vlong2le(uchar *t, vlong from)
+static uint8_t*
+vlong2le(uint8_t *t, int64_t from)
 {
-	uchar *f, *o;
+	uint8_t *f, *o;
 	int i;
 
-	f = (uchar*)&from;
-	o = (uchar*)&uvorder;
-	for(i = 0; i < sizeof(vlong); i++)
+	f = (uint8_t*)&from;
+	o = (uint8_t*)&uvorder;
+	for(i = 0; i < sizeof(int64_t); i++)
 		t[i] = f[o[i]];
-	return t+sizeof(vlong);
+	return t+sizeof(int64_t);
 }
 
-static long order = 0x00010203;
+static int32_t order = 0x00010203;
 
-static uchar*
-le2long(long *to, uchar *f)
+static uint8_t*
+le2long(int32_t *to, uint8_t *f)
 {
-	uchar *t, *o;
+	uint8_t *t, *o;
 	int i;
 
-	t = (uchar*)to;
-	o = (uchar*)&order;
-	for(i = 0; i < sizeof(long); i++)
+	t = (uint8_t*)to;
+	o = (uint8_t*)&order;
+	for(i = 0; i < sizeof(int32_t); i++)
 		t[o[i]] = f[i];
-	return f+sizeof(long);
+	return f+sizeof(int32_t);
 }
 
-static uchar*
-long2le(uchar *t, long from)
+static uint8_t*
+long2le(uint8_t *t, int32_t from)
 {
-	uchar *f, *o;
+	uint8_t *f, *o;
 	int i;
 
-	f = (uchar*)&from;
-	o = (uchar*)&order;
-	for(i = 0; i < sizeof(long); i++)
+	f = (uint8_t*)&from;
+	o = (uint8_t*)&order;
+	for(i = 0; i < sizeof(int32_t); i++)
 		t[i] = f[o[i]];
-	return t+sizeof(long);
+	return t+sizeof(int32_t);
 }
 
-char *Ebadtimectl = "bad time control";
+int8_t *Ebadtimectl = "bad time control";
 
 /*
  *  like the old #c/time but with added info.  Return
@@ -1316,15 +1316,15 @@ char *Ebadtimectl = "bad time control";
  *	secs	nanosecs	fastticks	fasthz
  */
 static int
-readtime(ulong off, char *buf, int n)
+readtime(uint32_t off, int8_t *buf, int n)
 {
-	vlong nsec, ticks;
-	long sec;
-	char str[7*NUMSIZE];
+	int64_t nsec, ticks;
+	int32_t sec;
+	int8_t str[7*NUMSIZE];
 
 	nsec = todget(&ticks);
 	if(fasthz == 0LL)
-		fastticks((uvlong*)&fasthz);
+		fastticks((uint64_t*)&fasthz);
 	sec = nsec/1000000000ULL;
 	snprint(str, sizeof(str), "%*lud %*llud %*llud %*llud ",
 		NUMSIZE-1, sec,
@@ -1338,11 +1338,11 @@ readtime(ulong off, char *buf, int n)
  *  set the time in seconds
  */
 static int
-writetime(char *buf, int n)
+writetime(int8_t *buf, int n)
 {
-	char b[13];
-	long i;
-	vlong now;
+	int8_t b[13];
+	int32_t i;
+	int64_t now;
 
 	if(n >= sizeof(b))
 		error(Ebadtimectl);
@@ -1361,27 +1361,27 @@ writetime(char *buf, int n)
  *  ticks and nsec are syncronized.
  */
 static int
-readbintime(char *buf, int n)
+readbintime(int8_t *buf, int n)
 {
 	int i;
-	vlong nsec, ticks;
-	uchar *b = (uchar*)buf;
+	int64_t nsec, ticks;
+	uint8_t *b = (uint8_t*)buf;
 
 	i = 0;
 	if(fasthz == 0LL)
-		fastticks((uvlong*)&fasthz);
+		fastticks((uint64_t*)&fasthz);
 	nsec = todget(&ticks);
-	if(n >= 3*sizeof(uvlong)){
-		vlong2le(b+2*sizeof(uvlong), fasthz);
-		i += sizeof(uvlong);
+	if(n >= 3*sizeof(uint64_t)){
+		vlong2le(b+2*sizeof(uint64_t), fasthz);
+		i += sizeof(uint64_t);
 	}
-	if(n >= 2*sizeof(uvlong)){
-		vlong2le(b+sizeof(uvlong), ticks);
-		i += sizeof(uvlong);
+	if(n >= 2*sizeof(uint64_t)){
+		vlong2le(b+sizeof(uint64_t), ticks);
+		i += sizeof(uint64_t);
 	}
 	if(n >= 8){
 		vlong2le(b, nsec);
-		i += sizeof(vlong);
+		i += sizeof(int64_t);
 	}
 	return i;
 }
@@ -1393,30 +1393,30 @@ readbintime(char *buf, int n)
  *	- clock frequency
  */
 static int
-writebintime(char *buf, int n)
+writebintime(int8_t *buf, int n)
 {
-	uchar *p;
-	vlong delta;
-	long period;
+	uint8_t *p;
+	int64_t delta;
+	int32_t period;
 
 	n--;
-	p = (uchar*)buf + 1;
+	p = (uint8_t*)buf + 1;
 	switch(*buf){
 	case 'n':
-		if(n < sizeof(vlong))
+		if(n < sizeof(int64_t))
 			error(Ebadtimectl);
 		le2vlong(&delta, p);
 		todset(delta, 0, 0);
 		break;
 	case 'd':
-		if(n < sizeof(vlong)+sizeof(long))
+		if(n < sizeof(int64_t)+sizeof(int32_t))
 			error(Ebadtimectl);
 		p = le2vlong(&delta, p);
 		le2long(&period, p);
 		todset(-1, delta, period);
 		break;
 	case 'f':
-		if(n < sizeof(uvlong))
+		if(n < sizeof(uint64_t))
 			error(Ebadtimectl);
 		le2vlong(&fasthz, p);
 		todsetfreq(fasthz);

+ 10 - 10
sys/src/9/port/devdup.c

@@ -17,7 +17,7 @@
 /* Qid is (2*fd + (file is ctl))+1 */
 
 static int
-dupgen(Chan *c, char *, Dirtab*, int, int s, Dir *dp)
+dupgen(Chan *c, int8_t *, Dirtab*, int, int s, Dir *dp)
 {
 	Fgrp *fgrp = up->fgrp;
 	Chan *f;
@@ -49,19 +49,19 @@ dupgen(Chan *c, char *, Dirtab*, int, int s, Dir *dp)
 }
 
 static Chan*
-dupattach(char *spec)
+dupattach(int8_t *spec)
 {
 	return devattach('d', spec);
 }
 
 static Walkqid*
-dupwalk(Chan *c, Chan *nc, char **name, int nname)
+dupwalk(Chan *c, Chan *nc, int8_t **name, int nname)
 {
 	return devwalk(c, nc, name, nname, (Dirtab *)0, 0, dupgen);
 }
 
-static long
-dupstat(Chan *c, uchar *db, long n)
+static int32_t
+dupstat(Chan *c, uint8_t *db, int32_t n)
 {
 	return devstat(c, db, n, (Dirtab *)0, 0L, dupgen);
 }
@@ -105,10 +105,10 @@ dupclose(Chan*)
 {
 }
 
-static long
-dupread(Chan *c, void *va, long n, vlong off)
+static int32_t
+dupread(Chan *c, void *va, int32_t n, int64_t off)
 {
-	char buf[256];
+	int8_t buf[256];
 	int fd, twicefd;
 
 	if(c->qid.type & QTDIR)
@@ -125,8 +125,8 @@ dupread(Chan *c, void *va, long n, vlong off)
 	return 0;
 }
 
-static long
-dupwrite(Chan*, void*, long, vlong)
+static int32_t
+dupwrite(Chan*, void*, int32_t, int64_t)
 {
 	error(Eperm);
 	return 0;		/* not reached */

+ 18 - 18
sys/src/9/port/devenv.c

@@ -25,7 +25,7 @@ static int	envwriteable(Chan *c);
 static Egrp	confegrp;	/* global environment group containing the kernel configuration */
 
 static Evalue*
-envlookup(Egrp *eg, char *name, ulong qidpath)
+envlookup(Egrp *eg, int8_t *name, uint32_t qidpath)
 {
 	Evalue *e;
 	int i;
@@ -39,7 +39,7 @@ envlookup(Egrp *eg, char *name, ulong qidpath)
 }
 
 static int
-envgen(Chan *c, char *name, Dirtab*, int, int s, Dir *dp)
+envgen(Chan *c, int8_t *name, Dirtab*, int, int s, Dir *dp)
 {
 	Egrp *eg;
 	Evalue *e;
@@ -70,7 +70,7 @@ envgen(Chan *c, char *name, Dirtab*, int, int s, Dir *dp)
 }
 
 static Chan*
-envattach(char *spec)
+envattach(int8_t *spec)
 {
 	Chan *c;
 	Egrp *egrp = nil;
@@ -88,13 +88,13 @@ envattach(char *spec)
 }
 
 static Walkqid*
-envwalk(Chan *c, Chan *nc, char **name, int nname)
+envwalk(Chan *c, Chan *nc, int8_t **name, int nname)
 {
 	return devwalk(c, nc, name, nname, 0, 0, envgen);
 }
 
-static long
-envstat(Chan *c, uchar *db, long n)
+static int32_t
+envstat(Chan *c, uint8_t *db, int32_t n)
 {
 	if(c->qid.type & QTDIR)
 		c->qid.vers = envgrp(c)->vers;
@@ -147,7 +147,7 @@ envopen(Chan *c, int omode)
 }
 
 static void
-envcreate(Chan *c, char *name, int omode, int)
+envcreate(Chan *c, int8_t *name, int omode, int)
 {
 	Egrp *eg;
 	Evalue *e;
@@ -237,12 +237,12 @@ envclose(Chan *c)
 		envremove(c);
 }
 
-static long
-envread(Chan *c, void *a, long n, vlong off)
+static int32_t
+envread(Chan *c, void *a, int32_t n, int64_t off)
 {
 	Egrp *eg;
 	Evalue *e;
-	long offset;
+	int32_t offset;
 
 	if(c->qid.type & QTDIR)
 		return devdirread(c, a, n, 0, 0, envgen);
@@ -268,13 +268,13 @@ envread(Chan *c, void *a, long n, vlong off)
 	return n;
 }
 
-static long
-envwrite(Chan *c, void *a, long n, vlong off)
+static int32_t
+envwrite(Chan *c, void *a, int32_t n, int64_t off)
 {
-	char *s;
+	int8_t *s;
 	Egrp *eg;
 	Evalue *e;
-	long len, offset;
+	int32_t len, offset;
 
 	if(n <= 0)
 		return 0;
@@ -391,10 +391,10 @@ envwriteable(Chan *c)
  *  to let the kernel set environment variables
  */
 void
-ksetenv(char *ename, char *eval, int conf)
+ksetenv(int8_t *ename, int8_t *eval, int conf)
 {
 	Chan *c;
-	char buf[2*KNAMELEN];
+	int8_t buf[2*KNAMELEN];
 
 	snprint(buf, sizeof(buf), "#e%s/%s", conf?"c":"", ename);
 	c = namec(buf, Acreate, OWRITE, 0600);
@@ -407,12 +407,12 @@ ksetenv(char *ename, char *eval, int conf)
  * The strings alternate between name and value.  A zero length name string
  * indicates the end of the list
  */
-char *
+int8_t *
 getconfenv(void)
 {
 	Egrp *eg = &confegrp;
 	Evalue *e;
-	char *p, *q;
+	int8_t *p, *q;
 	int i, n;
 
 	rlock(eg);

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

@@ -32,7 +32,7 @@ static int	kexecwriteable(Chan *c);
 static Kexecgrp	kgrp;	/* global kexec group containing the kernel configuration */
 
 static Kvalue*
-kexeclookup(Kexecgrp *kg, uintptr addr, ulong qidpath)
+kexeclookup(Kexecgrp *kg, uintptr addr, uint32_t qidpath)
 {
 	Kvalue *e;
 	int i;
@@ -46,7 +46,7 @@ kexeclookup(Kexecgrp *kg, uintptr addr, ulong qidpath)
 }
 
 static int
-kexecgen(Chan *c, char *name, Dirtab*, int, int s, Dir *dp)
+kexecgen(Chan *c, int8_t *name, Dirtab*, int, int s, Dir *dp)
 {
 	Kexecgrp *kg;
 	Kvalue *e;
@@ -92,7 +92,7 @@ kexecgen(Chan *c, char *name, Dirtab*, int, int s, Dir *dp)
 #define QPATH(p,d,t)    ((p)<<16 | (d)<<8 | (t)<<0)
 
 static Chan*
-kexecattach(char *spec)
+kexecattach(int8_t *spec)
 {
 	Chan *c;
 //	Kexecgrp *kgrp = nil;
@@ -105,16 +105,16 @@ kexecattach(char *spec)
 }
 
 static Walkqid*
-kexecwalk(Chan *c, Chan *nc, char **name, int nname)
+kexecwalk(Chan *c, Chan *nc, int8_t **name, int nname)
 {
 	return devwalk(c, nc, name, nname, 0, 0, kexecgen);
 }
 
 
-static long
-kexecstat(Chan *c, uchar *db, long n)
+static int32_t
+kexecstat(Chan *c, uint8_t *db, int32_t n)
 {
-	long nn;
+	int32_t nn;
 
 	if(c->qid.type & QTDIR)
 		c->qid.vers = kexecgrp(c)->vers;
@@ -167,7 +167,7 @@ kexecopen(Chan *c, int omode)
 }
 
 static void
-kexeccreate(Chan *c, char *name, int omode, int)
+kexeccreate(Chan *c, int8_t *name, int omode, int)
 {
 	Kexecgrp *kg;
 	Kvalue *e;
@@ -256,12 +256,12 @@ kexecclose(Chan *c)
 		kexecremove(c);
 }
 
-static long
-kexecread(Chan *c, void *a, long n, vlong off)
+static int32_t
+kexecread(Chan *c, void *a, int32_t n, int64_t off)
 {
 	Kexecgrp *kg;
 	Kvalue *e;
-	long offset;
+	int32_t offset;
 
 	if(c->qid.type & QTDIR)
 		return devdirread(c, a, n, 0, 0, kexecgen);
@@ -313,12 +313,12 @@ the first thing to do is to make this just work.
 
 */
 
-static long
-kexecwrite(Chan *c, void *a, long n, vlong off)
+static int32_t
+kexecwrite(Chan *c, void *a, int32_t n, int64_t off)
 {
 	Kexecgrp *kg;
 	Kvalue *e;
-	long offset;
+	int32_t offset;
 
 	if(n <= 0)
 		return 0;

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

@@ -40,9 +40,9 @@ Dirtab kproftab[]={
 };
 
 static Chan*
-kprofattach(char *spec)
+kprofattach(int8_t *spec)
 {
-	ulong n;
+	uint32_t n;
 
 	/* allocate when first used */
 	kprof.minpc = KTZERO;
@@ -96,13 +96,13 @@ kprofinit(void)
 }
 
 static Walkqid*
-kprofwalk(Chan *c, Chan *nc, char **name, int nname)
+kprofwalk(Chan *c, Chan *nc, int8_t **name, int nname)
 {
 	return devwalk(c, nc, name, nname, kproftab, nelem(kproftab), devgen);
 }
 
-static long
-kprofstat(Chan *c, uchar *db, long n)
+static int32_t
+kprofstat(Chan *c, uint8_t *db, int32_t n)
 {
 	return devstat(c, db, n, kproftab, nelem(kproftab), devgen);
 }
@@ -125,13 +125,13 @@ kprofclose(Chan*)
 {
 }
 
-static long
-kprofread(Chan *c, void *va, long n, vlong off)
+static int32_t
+kprofread(Chan *c, void *va, int32_t n, int64_t off)
 {
-	ulong end;
-	ulong w, *bp;
-	uchar *a, *ea;
-	ulong offset = off;
+	uint32_t end;
+	uint32_t w, *bp;
+	uint8_t *a, *ea;
+	uint32_t offset = off;
 
 	switch((int)c->qid.path){
 	case Kprofdirqid:
@@ -167,13 +167,13 @@ kprofread(Chan *c, void *va, long n, vlong off)
 	return n;
 }
 
-static long
-kprofwrite(Chan *c, void *a, long n, vlong)
+static int32_t
+kprofwrite(Chan *c, void *a, int32_t n, int64_t)
 {
 	switch((int)(c->qid.path)){
 	case Kprofctlqid:
 		if(strncmp(a, "startclr", 8) == 0){
-			memset((char *)kprof.buf, 0, kprof.nbuf*SZ);
+			memset((int8_t *)kprof.buf, 0, kprof.nbuf*SZ);
 			kprof.time = 1;
 		}else if(strncmp(a, "start", 5) == 0)
 			kprof.time = 1;

+ 45 - 45
sys/src/9/port/devmnt.c

@@ -35,13 +35,13 @@ struct Mntrpc
 	Fcall 	reply;		/* Incoming reply */
 	Mnt*	m;		/* Mount device during rpc */
 	Rendez	r;		/* Place to hang out */
-	uchar*	rpc;		/* I/O Data buffer */
+	uint8_t*	rpc;		/* I/O Data buffer */
 	uint	rpclen;		/* len of buffer */
 	Block	*b;		/* reply blocks */
-	char	done;		/* Rpc completed */
-	uvlong	stime;		/* start time for mnt statistics */
-	ulong	reqlen;		/* request length for mnt statistics */
-	ulong	replen;		/* reply length for mnt statistics */
+	int8_t	done;		/* Rpc completed */
+	uint64_t	stime;		/* start time for mnt statistics */
+	uint32_t	reqlen;		/* request length for mnt statistics */
+	uint32_t	replen;		/* reply length for mnt statistics */
 	Mntrpc*	flushed;	/* message this one flushes */
 };
 
@@ -65,15 +65,15 @@ struct Mntalloc
 }mntalloc;
 
 Mnt*	mntchk(Chan*);
-void	mntdirfix(uchar*, Chan*);
-Mntrpc*	mntflushalloc(Mntrpc*, ulong);
+void	mntdirfix(uint8_t*, Chan*);
+Mntrpc*	mntflushalloc(Mntrpc*, uint32_t);
 void	mntflushfree(Mnt*, Mntrpc*);
 void	mntfree(Mntrpc*);
 void	mntgate(Mnt*);
 void	mntpntfree(Mnt*);
 void	mntqrm(Mnt*, Mntrpc*);
-Mntrpc*	mntralloc(Chan*, ulong);
-long	mntrdwr(int, Chan*, void*, long, vlong);
+Mntrpc*	mntralloc(Chan*, uint32_t);
+int32_t	mntrdwr(int, Chan*, void*, int32_t, int64_t);
 int	mntrpcread(Mnt*, Mntrpc*);
 void	mountio(Mnt*, Mntrpc*);
 void	mountmux(Mnt*, Mntrpc*);
@@ -81,11 +81,11 @@ void	mountrpc(Mnt*, Mntrpc*);
 int	rpcattn(void*);
 Chan*	mntchan(void);
 
-char	Esbadstat[] = "invalid directory entry received from server";
-char	Enoversion[] = "version not established for mount channel";
+int8_t	Esbadstat[] = "invalid directory entry received from server";
+int8_t	Enoversion[] = "version not established for mount channel";
 
 
-void (*mntstats)(int, Chan*, uvlong, ulong);
+void (*mntstats)(int, Chan*, uint64_t, uint32_t);
 
 static void
 mntreset(void)
@@ -105,16 +105,16 @@ mntreset(void)
  * Version is not multiplexed: message sent only once per connection.
  */
 usize
-mntversion(Chan *c, u32int msize, char *version, usize returnlen)
+mntversion(Chan *c, u32int msize, int8_t *version, usize returnlen)
 {
 	Fcall f;
-	uchar *msg;
+	uint8_t *msg;
 	Mnt *mnt;
-	char *v;
-	long l, n;
+	int8_t *v;
+	int32_t l, n;
 	usize k;
-	vlong oo;
-	char buf[128];
+	int64_t oo;
+	int8_t buf[128];
 
 	qlock(&c->umqlock);	/* make sure no one else does this until we've established ourselves */
 	if(waserror()){
@@ -257,7 +257,7 @@ mntversion(Chan *c, u32int msize, char *version, usize returnlen)
 }
 
 Chan*
-mntauth(Chan *c, char *spec)
+mntauth(Chan *c, int8_t *spec)
 {
 	Mnt *mnt;
 	Mntrpc *r;
@@ -309,7 +309,7 @@ mntauth(Chan *c, char *spec)
 }
 
 static Chan*
-mntattach(char *muxattach)
+mntattach(int8_t *muxattach)
 {
 	Mnt *mnt;
 	Chan *c;
@@ -317,7 +317,7 @@ mntattach(char *muxattach)
 	struct bogus{
 		Chan	*chan;
 		Chan	*authchan;
-		char	*spec;
+		int8_t	*spec;
 		int	flags;
 	}bogus;
 
@@ -390,7 +390,7 @@ mntchan(void)
 }
 
 static Walkqid*
-mntwalk(Chan *c, Chan *nc, char **name, int nname)
+mntwalk(Chan *c, Chan *nc, int8_t **name, int nname)
 {
 	int i, alloc;
 	Mnt *mnt;
@@ -432,7 +432,7 @@ mntwalk(Chan *c, Chan *nc, char **name, int nname)
 	r->request.fid = c->fid;
 	r->request.newfid = nc->fid;
 	r->request.nwname = nname;
-	memmove(r->request.wname, name, nname*sizeof(char*));
+	memmove(r->request.wname, name, nname*sizeof(int8_t*));
 
 	mountrpc(mnt, r);
 
@@ -472,8 +472,8 @@ mntwalk(Chan *c, Chan *nc, char **name, int nname)
 	return wq;
 }
 
-static long
-mntstat(Chan *c, uchar *dp, long n)
+static int32_t
+mntstat(Chan *c, uint8_t *dp, int32_t n)
 {
 	Mnt *mnt;
 	Mntrpc *r;
@@ -507,7 +507,7 @@ mntstat(Chan *c, uchar *dp, long n)
 }
 
 static Chan*
-mntopencreate(int type, Chan *c, char *name, int omode, int perm)
+mntopencreate(int type, Chan *c, int8_t *name, int omode, int perm)
 {
 	Mnt *mnt;
 	Mntrpc *r;
@@ -550,7 +550,7 @@ mntopen(Chan *c, int omode)
 }
 
 static void
-mntcreate(Chan *c, char *name, int omode, int perm)
+mntcreate(Chan *c, int8_t *name, int omode, int perm)
 {
 	mntopencreate(Tcreate, c, name, omode, perm);
 }
@@ -625,8 +625,8 @@ mntremove(Chan *c)
 	mntclunk(c, Tremove);
 }
 
-static long
-mntwstat(Chan *c, uchar *dp, long n)
+static int32_t
+mntwstat(Chan *c, uint8_t *dp, int32_t n)
 {
 	Mnt *mnt;
 	Mntrpc *r;
@@ -647,10 +647,10 @@ mntwstat(Chan *c, uchar *dp, long n)
 	return n;
 }
 
-static long
-mntread(Chan *c, void *buf, long n, vlong off)
+static int32_t
+mntread(Chan *c, void *buf, int32_t n, int64_t off)
 {
-	uchar *p, *e;
+	uint8_t *p, *e;
 	int nc, cache, isdir;
 	usize dirlen;
 
@@ -691,20 +691,20 @@ mntread(Chan *c, void *buf, long n, vlong off)
 	return n;
 }
 
-static long
-mntwrite(Chan *c, void *buf, long n, vlong off)
+static int32_t
+mntwrite(Chan *c, void *buf, int32_t n, int64_t off)
 {
 	return mntrdwr(Twrite, c, buf, n, off);
 }
 
-long
-mntrdwr(int type, Chan *c, void *buf, long n, vlong off)
+int32_t
+mntrdwr(int type, Chan *c, void *buf, int32_t n, int64_t off)
 {
 	Mnt *mnt;
  	Mntrpc *r;
-	char *uba;
+	int8_t *uba;
 	int cache;
-	ulong cnt, nr, nreq;
+	uint32_t cnt, nr, nreq;
 
 	mnt = mntchk(c);
 	uba = buf;
@@ -733,9 +733,9 @@ mntrdwr(int type, Chan *c, void *buf, long n, vlong off)
 			nr = nreq;
 
 		if(type == Tread)
-			r->b = bl2mem((uchar*)uba, r->b, nr);
+			r->b = bl2mem((uint8_t*)uba, r->b, nr);
 		else if(cache)
-			mfcwrite(c, (uchar*)uba, nr, off);
+			mfcwrite(c, (uint8_t*)uba, nr, off);
 
 		poperror();
 		mntfree(r);
@@ -752,7 +752,7 @@ mntrdwr(int type, Chan *c, void *buf, long n, vlong off)
 void
 mountrpc(Mnt *mnt, Mntrpc *r)
 {
-	char *sn, *cn;
+	int8_t *sn, *cn;
 	int t;
 
 	r->reply.tag = 0;
@@ -986,7 +986,7 @@ mountmux(Mnt *mnt, Mntrpc *r)
  * requests from it
  */
 Mntrpc*
-mntflushalloc(Mntrpc *r, ulong iounit)
+mntflushalloc(Mntrpc *r, uint32_t iounit)
 {
 	Mntrpc *fr;
 
@@ -1030,7 +1030,7 @@ int
 alloctag(void)
 {
 	int i, j;
-	ulong v;
+	uint32_t v;
 
 	for(i = 0; i < NMASK; i++){
 		v = mntalloc.tagmask[i];
@@ -1053,7 +1053,7 @@ freetag(int t)
 }
 
 Mntrpc*
-mntralloc(Chan *c, ulong msize)
+mntralloc(Chan *c, uint32_t msize)
 {
 	Mntrpc *new;
 
@@ -1171,7 +1171,7 @@ mntchk(Chan *c)
  * the first two in the Dir encoding after the count.
  */
 void
-mntdirfix(uchar *dirbuf, Chan *c)
+mntdirfix(uint8_t *dirbuf, Chan *c)
 {
 	uint r;
 

+ 19 - 19
sys/src/9/port/devpci.c

@@ -55,7 +55,7 @@ pcidirgen(Chan *c, int t, int tbdf, Dir *dp)
 }
 
 static int
-pcigen(Chan *c, char *, Dirtab*, int, int s, Dir *dp)
+pcigen(Chan *c, int8_t *, Dirtab*, int, int s, Dir *dp)
 {
 	int tbdf;
 	Pcidev *p;
@@ -87,7 +87,7 @@ pcigen(Chan *c, char *, Dirtab*, int, int s, Dir *dp)
 		return pcidirgen(c, s+Qpcictl, p->tbdf, dp);
 	case Qpcictl:
 	case Qpciraw:
-		tbdf = MKBUS(BusPCI, 0, 0, 0)|BUSBDF((ulong)c->qid.path);
+		tbdf = MKBUS(BusPCI, 0, 0, 0)|BUSBDF((uint32_t)c->qid.path);
 		p = pcimatchtbdf(tbdf);
 		if(p == nil)
 			return -1;
@@ -99,19 +99,19 @@ pcigen(Chan *c, char *, Dirtab*, int, int s, Dir *dp)
 }
 
 static Chan*
-pciattach(char *spec)
+pciattach(int8_t *spec)
 {
 	return devattach(pcidevtab.dc, spec);
 }
 
 Walkqid*
-pciwalk(Chan* c, Chan *nc, char** name, int nname)
+pciwalk(Chan* c, Chan *nc, int8_t** name, int nname)
 {
 	return devwalk(c, nc, name, nname, (Dirtab *)0, 0, pcigen);
 }
 
-static long
-pcistat(Chan* c, uchar* dp, long n)
+static int32_t
+pcistat(Chan* c, uint8_t* dp, int32_t n)
 {
 	return devstat(c, dp, n, (Dirtab *)0, 0L, pcigen);
 }
@@ -132,12 +132,12 @@ pciclose(Chan*)
 {
 }
 
-static long
-pciread(Chan *c, void *va, long n, vlong offset)
+static int32_t
+pciread(Chan *c, void *va, int32_t n, int64_t offset)
 {
-	char buf[256], *ebuf, *w, *a;
+	int8_t buf[256], *ebuf, *w, *a;
 	int i, tbdf, r;
-	ulong x;
+	uint32_t x;
 	Pcidev *p;
 
 	a = va;
@@ -146,7 +146,7 @@ pciread(Chan *c, void *va, long n, vlong offset)
 	case Qpcidir:
 		return devdirread(c, a, n, (Dirtab *)0, 0L, pcigen);
 	case Qpcictl:
-		tbdf = MKBUS(BusPCI, 0, 0, 0)|BUSBDF((ulong)c->qid.path);
+		tbdf = MKBUS(BusPCI, 0, 0, 0)|BUSBDF((uint32_t)c->qid.path);
 		p = pcimatchtbdf(tbdf);
 		if(p == nil)
 			error(Egreg);
@@ -162,7 +162,7 @@ pciread(Chan *c, void *va, long n, vlong offset)
 		*w = '\0';
 		return readstr(offset, a, n, buf);
 	case Qpciraw:
-		tbdf = MKBUS(BusPCI, 0, 0, 0)|BUSBDF((ulong)c->qid.path);
+		tbdf = MKBUS(BusPCI, 0, 0, 0)|BUSBDF((uint32_t)c->qid.path);
 		p = pcimatchtbdf(tbdf);
 		if(p == nil)
 			error(Egreg);
@@ -194,24 +194,24 @@ pciread(Chan *c, void *va, long n, vlong offset)
 	return n;
 }
 
-static long
-pciwrite(Chan *c, void *va, long n, vlong offset)
+static int32_t
+pciwrite(Chan *c, void *va, int32_t n, int64_t offset)
 {
-	char buf[256];
-	uchar *a;
+	int8_t buf[256];
+	uint8_t *a;
 	int i, r, tbdf;
-	ulong x;
+	uint32_t x;
 	Pcidev *p;
 
 	if(n >= sizeof(buf))
 		n = sizeof(buf)-1;
 	a = va;
-	strncpy(buf, (char*)a, n);
+	strncpy(buf, (int8_t*)a, n);
 	buf[n] = 0;
 
 	switch(TYPE(c->qid)){
 	case Qpciraw:
-		tbdf = MKBUS(BusPCI, 0, 0, 0)|BUSBDF((ulong)c->qid.path);
+		tbdf = MKBUS(BusPCI, 0, 0, 0)|BUSBDF((uint32_t)c->qid.path);
 		p = pcimatchtbdf(tbdf);
 		if(p == nil)
 			error(Egreg);

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

@@ -66,7 +66,7 @@ pipeinit(void)
  *  create a pipe, no streams are created until an open
  */
 static Chan*
-pipeattach(char *spec)
+pipeattach(int8_t *spec)
 {
 	Pipe *p;
 	Chan *c;
@@ -100,7 +100,7 @@ pipeattach(char *spec)
 }
 
 static int
-pipegen(Chan *c, char*, Dirtab *tab, int ntab, int i, Dir *dp)
+pipegen(Chan *c, int8_t*, Dirtab *tab, int ntab, int i, Dir *dp)
 {
 	Qid q;
 	int len;
@@ -116,7 +116,7 @@ pipegen(Chan *c, char*, Dirtab *tab, int ntab, int i, Dir *dp)
 
 	tab += i;
 	p = c->aux;
-	switch((ulong)tab->qid.path){
+	switch((uint32_t)tab->qid.path){
 	case Qdata0:
 		len = qlen(p->q[0]);
 		break;
@@ -134,7 +134,7 @@ pipegen(Chan *c, char*, Dirtab *tab, int ntab, int i, Dir *dp)
 
 
 static Walkqid*
-pipewalk(Chan *c, Chan *nc, char **name, int nname)
+pipewalk(Chan *c, Chan *nc, int8_t **name, int nname)
 {
 	Walkqid *wq;
 	Pipe *p;
@@ -160,8 +160,8 @@ pipewalk(Chan *c, Chan *nc, char **name, int nname)
 	return wq;
 }
 
-static long
-pipestat(Chan *c, uchar *db, long n)
+static int32_t
+pipestat(Chan *c, uint8_t *db, int32_t n)
 {
 	Pipe *p;
 	Dir dir;
@@ -275,8 +275,8 @@ pipeclose(Chan *c)
 		qunlock(p);
 }
 
-static long
-piperead(Chan *c, void *va, long n, vlong)
+static int32_t
+piperead(Chan *c, void *va, int32_t n, int64_t)
 {
 	Pipe *p;
 
@@ -296,7 +296,7 @@ piperead(Chan *c, void *va, long n, vlong)
 }
 
 static Block*
-pipebread(Chan *c, long n, vlong offset)
+pipebread(Chan *c, int32_t n, int64_t offset)
 {
 	Pipe *p;
 
@@ -316,8 +316,8 @@ pipebread(Chan *c, long n, vlong offset)
  *  a write to a closed pipe causes a note to be sent to
  *  the process.
  */
-static long
-pipewrite(Chan *c, void *va, long n, vlong)
+static int32_t
+pipewrite(Chan *c, void *va, int32_t n, int64_t)
 {
 	Pipe *p;
 
@@ -349,10 +349,10 @@ pipewrite(Chan *c, void *va, long n, vlong)
 	return n;
 }
 
-static long
-pipebwrite(Chan *c, Block *bp, vlong)
+static int32_t
+pipebwrite(Chan *c, Block *bp, int64_t)
 {
-	long n;
+	int32_t n;
 	Pipe *p;
 
 	if(waserror()) {

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

@@ -134,14 +134,14 @@ pmcinit(void)
 }
 
 static Chan *
-pmcattach(char *spec)
+pmcattach(int8_t *spec)
 {
 	if (pmctab == nil)
 		error(Enomem);
 	return devattach(L'ε', spec);
 }
 int
-pmcgen(Chan *c, char *name, Dirtab*, int, int s, Dir *dp)
+pmcgen(Chan *c, int8_t *name, Dirtab*, int, int s, Dir *dp)
 {
 	int t, i, n;
 	Dirtab *l, *d;
@@ -187,13 +187,13 @@ pmcgen(Chan *c, char *name, Dirtab*, int, int s, Dir *dp)
 }
 
 static Walkqid*
-pmcwalk(Chan *c, Chan *nc, char **name, int nname)
+pmcwalk(Chan *c, Chan *nc, int8_t **name, int nname)
 {
 	return devwalk(c, nc, name, nname, nil, 0, pmcgen);
 }
 
-static long
-pmcstat(Chan *c, uchar *dp, long n)
+static int32_t
+pmcstat(Chan *c, uint8_t *dp, int32_t n)
 {
 	return devstat(c, dp, n, nil, 0, pmcgen);
 }
@@ -213,12 +213,12 @@ pmcclose(Chan *)
 
 
 
-static long
-pmcread(Chan *c, void *a, long n, vlong offset)
+static int32_t
+pmcread(Chan *c, void *a, int32_t n, int64_t offset)
 {
-	ulong type, id;
+	uint32_t type, id;
 	PmcCtl p;
-	char *s;
+	int8_t *s;
 	u64int v;
 	u64int coreno;
 
@@ -329,13 +329,13 @@ acpmcsetctr(void)
 }
 
 
-static long
-pmcwrite(Chan *c, void *a, long n, vlong)
+static int32_t
+pmcwrite(Chan *c, void *a, int32_t n, int64_t)
 {
 	Cmdbuf *cb;
 	Cmdtab *ct;
-	ulong type;
-	char str[64];	/* 0x0000000000000000\0 */
+	uint32_t type;
+	int8_t str[64];	/* 0x0000000000000000\0 */
 	AcPmcArg p;
 	AcCtrArg ctr;
 	u64int coreno;
@@ -374,7 +374,7 @@ pmcwrite(Chan *c, void *a, long n, vlong)
 
 	/* TODO: should iterate through multiple lines */
 	if (strncmp(str, "set ", 4) == 0){
-		memmove(p.descstr, (char *)str + 4, n - 4);
+		memmove(p.descstr, (int8_t *)str + 4, n - 4);
 		p.descstr[n - 4] = '\0';
 		p.nodesc = 0;
 	} else {

+ 28 - 28
sys/src/9/port/devprobe.c

@@ -35,12 +35,12 @@ enum {
 
 typedef struct Probelog Probelog;
 struct Probelog {
-	uvlong ticks;
+	uint64_t ticks;
 	/* yeah, waste a whole int on something stupid but ... */
 	int info;
-	ulong pc;
+	uint32_t pc;
 	/* these are different depending on type */
-	long dat[4];
+	int32_t dat[4];
 };
 
 static Rendez probesleep;
@@ -51,11 +51,11 @@ static Probelog *probelog = nil;
 /* probe indices. These are just unsigned longs. You mask them
  * to get an index. This makes fifo empty/full etc. trivial.
  */
-static ulong pw = 0, pr = 0;
+static uint32_t pw = 0, pr = 0;
 static int probesactive = 0;
 static unsigned long logsize = defaultlogsize, logmask = defaultlogsize - 1;
 
-static char eventname[] = {
+static int8_t eventname[] = {
 	[ProbeEntry] = 'E',
 	[ProbeExit] = 'X'
 };
@@ -66,7 +66,7 @@ static Dirtab probedir[]={
 	"probe",	{Qdata},	0,		0440,
 };
 
-char hex[] = {
+int8_t hex[] = {
 	'0',
 	'1',
 	'2',
@@ -87,7 +87,7 @@ char hex[] = {
 
 /* big-endian ... */
 void
-hex32(ulong l, char *c)
+hex32(uint32_t l, int8_t *c)
 {
 	int i;
 	for(i = 8; i; i--){
@@ -97,7 +97,7 @@ hex32(ulong l, char *c)
 }
 
 void
-hex64(uvlong l, char *c)
+hex64(uint64_t l, int8_t *c)
 {
 	hex32(l>>32, c);
 	hex32(l, &c[8]);
@@ -114,8 +114,8 @@ logfull(void)
 	return (pw - pr) >= logsize;
 }
 
-static ulong
-idx(ulong f)
+static uint32_t
+idx(uint32_t f)
 {
 	return f & logmask;
 }
@@ -124,7 +124,7 @@ idx(ulong f)
 static struct Probelog *
 newpl(void)
 {
-	ulong index;
+	uint32_t index;
 
 	if (logfull()){
 		wakeup(&probesleep);
@@ -148,7 +148,7 @@ probeentry(Probe *p)
 	if (! pl)
 		return;
 	cycles(&pl->ticks);
-	pl->pc = (ulong)p->func;
+	pl->pc = (uint32_t)p->func;
 	pl->dat[0] = p->argp[0];
 	pl->dat[1] = p->argp[1];
 	pl->dat[2] = p->argp[2];
@@ -165,25 +165,25 @@ probeexit(Probe *p)
 	if (! pl)
 		return;
 	cycles(&pl->ticks);
-	pl->pc = (ulong)p->func;
+	pl->pc = (uint32_t)p->func;
 	pl->dat[0] = p->rval;
 	pl->info = ProbeExit;
 }
 
 static Chan*
-probeattach(char *spec)
+probeattach(int8_t *spec)
 {
 	return devattach('+', spec);
 }
 
 static Walkqid*
-probewalk(Chan *c, Chan *nc, char **name, int nname)
+probewalk(Chan *c, Chan *nc, int8_t **name, int nname)
 {
 	return devwalk(c, nc, name, nname, probedir, nelem(probedir), devgen);
 }
 
-static long
-probestat(Chan *c, uchar *db, long n)
+static int32_t
+probestat(Chan *c, uint8_t *db, int32_t n)
 {
 	return devstat(c, db, n, probedir, nelem(probedir), devgen);
 }
@@ -209,18 +209,18 @@ probeclose(Chan *)
 {
 }
 
-static long
-proberead(Chan *c, void *a, long n, vlong offset)
+static int32_t
+proberead(Chan *c, void *a, int32_t n, int64_t offset)
 {
-	char *buf;
-	char *cp = a;
+	int8_t *buf;
+	int8_t *cp = a;
 	struct Probelog *pl;
 	Probe *p;
 	int i;
 	static QLock gate;
 	if(c->qid.type == QTDIR)
 		return devdirread(c, a, n, probedir, nelem(probedir), devgen);
-	switch((ulong)c->qid.path){
+	switch((uint32_t)c->qid.path){
 	default:
 		error("proberead: bad qid");
 	case Qctl:
@@ -287,11 +287,11 @@ proberead(Chan *c, void *a, long n, vlong offset)
 	return n;
 }
 
-static long
-probewrite(Chan *c, void *a, long n, vlong)
+static int32_t
+probewrite(Chan *c, void *a, int32_t n, int64_t)
 {
-	char *tok[5];
-	char *ep, *s = nil;
+	int8_t *tok[5];
+	int8_t *ep, *s = nil;
 	Probe *p, **pp;
 	int ntok;
 
@@ -301,7 +301,7 @@ probewrite(Chan *c, void *a, long n, vlong)
 		if(s != nil) free(s);
 		nexterror();
 	}
-	switch((ulong)c->qid.path){
+	switch((uint32_t)c->qid.path){
 	default:
 		error("proberead: bad qid");
 	case Qctl:
@@ -317,7 +317,7 @@ probewrite(Chan *c, void *a, long n, vlong)
 					break;
 			p = *pp;
 			if(!strcmp(tok[2], "new")){
-				ulong addr;
+				uint32_t addr;
 				void *func;
 				addr = strtoul(tok[1], &ep, 0);
 				func = (void*)addr;

+ 48 - 48
sys/src/9/port/devproc.c

@@ -146,7 +146,7 @@ Cmdtab proccmd[] = {
 };
 
 /* Segment type from portdat.h */
-static char *sname[]={ "Text", "Data", "Bss", "Stack", "Shared", "Phys", };
+static int8_t *sname[]={ "Text", "Data", "Bss", "Stack", "Shared", "Phys", };
 
 /*
  * Qids are, in path:
@@ -166,7 +166,7 @@ static char *sname[]={ "Text", "Data", "Bss", "Stack", "Shared", "Phys", };
 #define PID(q)		((q).vers)
 #define NOTEID(q)	((q).vers)
 
-static void	procctlreq(Proc*, char*, int);
+static void	procctlreq(Proc*, int8_t*, int);
 static int	procctlmemio(Proc*, uintptr, int, void*, int);
 static Chan*	proctext(Chan*, Proc*);
 static Segment* txt2data(Proc*, Segment*);
@@ -174,7 +174,7 @@ static int	procstopped(void*);
 static void	mntscan(Mntwalk*, Proc*);
 
 static Traceevent *tevents;
-static char *tpids, *tpidsc, *tpidse;
+static int8_t *tpids, *tpidsc, *tpidse;
 static Lock tlock;
 static int topens;
 static int tproduced, tconsumed;
@@ -199,14 +199,14 @@ profclock(Ureg *ur, Timer *)
 }
 
 static int
-procgen(Chan *c, char *name, Dirtab *tab, int, int s, Dir *dp)
+procgen(Chan *c, int8_t *name, Dirtab *tab, int, int s, Dir *dp)
 {
 	Qid qid;
 	Proc *p;
-	char *ename;
+	int8_t *ename;
 	Segment *q;
 	int pid;
-	ulong path, perm, len;
+	uint32_t path, perm, len;
 
 	if(s == DEVDOTDOT){
 		mkqid(&qid, Qdir, 0, QTDIR);
@@ -309,7 +309,7 @@ notrace(Proc*, Tevent, vlong)
 static Lock tlck;
 
 static void
-_proctrace(Proc* p, Tevent etype, vlong ts)
+_proctrace(Proc* p, Tevent etype, int64_t ts)
 {
 	Traceevent *te;
 	int tp;
@@ -353,19 +353,19 @@ procinit(void)
 }
 
 static Chan*
-procattach(char *spec)
+procattach(int8_t *spec)
 {
 	return devattach('p', spec);
 }
 
 static Walkqid*
-procwalk(Chan *c, Chan *nc, char **name, int nname)
+procwalk(Chan *c, Chan *nc, int8_t **name, int nname)
 {
 	return devwalk(c, nc, name, nname, 0, 0, procgen);
 }
 
-static long
-procstat(Chan *c, uchar *db, long n)
+static int32_t
+procstat(Chan *c, uint8_t *db, int32_t n)
 {
 	return devstat(c, db, n, 0, 0, procgen);
 }
@@ -542,8 +542,8 @@ procopen(Chan *c, int omode)
 	return tc;
 }
 
-static long
-procwstat(Chan *c, uchar *db, long n)
+static int32_t
+procwstat(Chan *c, uint8_t *db, int32_t n)
 {
 	Proc *p;
 	Dir *d;
@@ -573,7 +573,7 @@ procwstat(Chan *c, uchar *db, long n)
 		error(Eperm);
 
 	d = smalloc(sizeof(Dir)+n);
-	n = convM2D(db, n, &d[0], (char*)&d[1]);
+	n = convM2D(db, n, &d[0], (int8_t*)&d[1]);
 	if(n == 0)
 		error(Eshortstat);
 	if(!emptystr(d->uid) && strcmp(d->uid, p->user) != 0){
@@ -594,8 +594,8 @@ procwstat(Chan *c, uchar *db, long n)
 }
 
 
-static long
-procoffset(long offset, char *va, int *np)
+static int32_t
+procoffset(int32_t offset, int8_t *va, int *np)
 {
 	if(offset > 0) {
 		offset -= *np;
@@ -612,13 +612,13 @@ procoffset(long offset, char *va, int *np)
 static int
 procqidwidth(Chan *c)
 {
-	char buf[32];
+	int8_t buf[32];
 
 	return sprint(buf, "%lud", c->qid.vers);
 }
 
 int
-procfdprint(Chan *c, int fd, int w, char *s, int ns)
+procfdprint(Chan *c, int fd, int w, int8_t *s, int ns)
 {
 	int n;
 
@@ -634,13 +634,13 @@ procfdprint(Chan *c, int fd, int w, char *s, int ns)
 }
 
 static int
-procfds(Proc *p, char *va, int count, long offset)
+procfds(Proc *p, int8_t *va, int count, int32_t offset)
 {
 	Fgrp *f;
 	Chan *c;
-	char buf[256];
+	int8_t buf[256];
 	int n, i, w, ww;
-	char *a;
+	int8_t *a;
 
 	/* print to buf to avoid holding fgrp lock while writing to user space */
 	if(count > sizeof buf)
@@ -706,7 +706,7 @@ procclose(Chan * c)
 }
 
 static void
-int2flag(int flag, char *s)
+int2flag(int flag, int8_t *s)
 {
 	if(flag == 0){
 		*s = '\0';
@@ -725,10 +725,10 @@ int2flag(int flag, char *s)
 }
 
 static int
-procargs(Proc *p, char *buf, int nbuf)
+procargs(Proc *p, int8_t *buf, int nbuf)
 {
 	int j, k, m;
-	char *a;
+	int8_t *a;
 	int n;
 
 	a = p->args;
@@ -756,20 +756,20 @@ eventsavailable(void *)
 	return tproduced > tconsumed;
 }
 
-static long
-procread(Chan *c, void *va, long n, vlong off)
+static int32_t
+procread(Chan *c, void *va, int32_t n, int64_t off)
 {
 	Proc *p;
 	Mach *ac, *wired;
-	long l, r;
+	int32_t l, r;
 	Waitq *wq;
 	Ureg kur;
-	uchar *rptr;
+	uint8_t *rptr;
 	Confmem *cm;
 	Mntwalk *mw;
 	Segment *sg, *s;
 	int i, j, navail, pid, rsize;
-	char flag[10], *sps, *srv, statbuf[NSEG*64];
+	int8_t flag[10], *sps, *srv, statbuf[NSEG*64];
 	uintptr offset, u;
 	int tesz;
 
@@ -799,7 +799,7 @@ procread(Chan *c, void *va, long n, vlong off)
 			tconsumed++;
 			navail--;
 		}
-		return rptr - (uchar*)va;
+		return rptr - (uint8_t*)va;
 	}
 
 	if(QID(c->qid) == Qtracepids)
@@ -890,7 +890,7 @@ procread(Chan *c, void *va, long n, vlong off)
 		}
 		if(offset+n > i)
 			n = i - offset;
-		memmove(va, ((char*)s->profile)+offset, n);
+		memmove(va, ((int8_t*)s->profile)+offset, n);
 		psdecref(p);
 		return n;
 
@@ -932,12 +932,12 @@ procread(Chan *c, void *va, long n, vlong off)
 		}
 		if(offset+n > sizeof(Proc))
 			n = sizeof(Proc) - offset;
-		memmove(va, ((char*)p)+offset, n);
+		memmove(va, ((int8_t*)p)+offset, n);
 		psdecref(p);
 		return n;
 
 	case Qregs:
-		rptr = (uchar*)p->dbgreg;
+		rptr = (uint8_t*)p->dbgreg;
 		rsize = sizeof(Ureg);
 	regread:
 		if(rptr == 0){
@@ -957,7 +957,7 @@ procread(Chan *c, void *va, long n, vlong off)
 	case Qkregs:
 		memset(&kur, 0, sizeof(Ureg));
 		setkernur(&kur, p);
-		rptr = (uchar*)&kur;
+		rptr = (uint8_t*)&kur;
 		rsize = sizeof(Ureg);
 		goto regread;
 
@@ -1167,12 +1167,12 @@ mntscan(Mntwalk *mw, Proc *p)
 	runlock(&pg->ns);
 }
 
-static long
-procwrite(Chan *c, void *va, long n, vlong off)
+static int32_t
+procwrite(Chan *c, void *va, int32_t n, int64_t off)
 {
 	Proc *p, *t;
 	int i, id, l;
-	char *args, buf[ERRMAX];
+	int8_t *args, buf[ERRMAX];
 	uintptr offset;
 
 	if(c->qid.type & QTDIR)
@@ -1234,7 +1234,7 @@ procwrite(Chan *c, void *va, long n, vlong off)
 			n = sizeof(Ureg) - offset;
 		if(p->dbgreg == 0)
 			error(Enoreg);
-		setregisters(p->dbgreg, (char*)(p->dbgreg)+offset, va, n);
+		setregisters(p->dbgreg, (int8_t*)(p->dbgreg)+offset, va, n);
 		break;
 
 	case Qfpregs:
@@ -1423,12 +1423,12 @@ procctlclosefiles(Proc *p, int all, int fd)
 	closefgrp(f);
 }
 
-static char *
-parsetime(vlong *rt, char *s)
+static int8_t *
+parsetime(int64_t *rt, int8_t *s)
 {
-	uvlong ticks;
-	ulong l;
-	char *e, *p;
+	uint64_t ticks;
+	uint32_t l;
+	int8_t *e, *p;
 	static int p10[] = {100000000, 10000000, 1000000, 100000, 10000, 1000, 100, 10, 1};
 
 	if (s == nil)
@@ -1457,14 +1457,14 @@ parsetime(vlong *rt, char *s)
 }
 
 static void
-procctlreq(Proc *p, char *va, int n)
+procctlreq(Proc *p, int8_t *va, int n)
 {
 	Segment *s;
 	int npc, pri, core;
 	Cmdbuf *cb;
 	Cmdtab *ct;
-	vlong time;
-	char *e;
+	int64_t time;
+	int8_t *e;
 
 	if(p->kp)	/* no ctl requests to kprocs */
 		error(Eperm);
@@ -1674,7 +1674,7 @@ procctlmemio(Proc *p, uintptr offset, int n, void *va, int read)
 	Page *pg;
 	Segment *s;
 	uintptr soff, l;	/* hmmmm */
-	uchar *b;
+	uint8_t *b;
 	uintmem pgsz;
 
 	for(;;) {
@@ -1718,7 +1718,7 @@ procctlmemio(Proc *p, uintptr offset, int n, void *va, int read)
 		kunmap(k);
 		nexterror();
 	}
-	b = (uchar*)VA(k);
+	b = (uint8_t*)VA(k);
 	b += offset&(pgsz-1);
 	if(read == 1)
 		memmove(va, b, n);	/* This can fault */

+ 19 - 18
sys/src/9/port/devroot.c

@@ -28,7 +28,7 @@ struct Dirlist
 {
 	uint base;
 	Dirtab *dir;
-	uchar **data;
+	uint8_t **data;
 	int ndir;
 	int mdir;
 };
@@ -37,7 +37,7 @@ static Dirtab rootdir[Nrootfiles] = {
 	"#/",	{Qdir, 0, QTDIR},	0,		DMDIR|0555,
 	"boot",	{Qboot, 0, QTDIR},	0,		DMDIR|0555,
 };
-static uchar *rootdata[Nrootfiles];
+static uint8_t *rootdata[Nrootfiles];
 static Dirlist rootlist =
 {
 	0,
@@ -50,7 +50,7 @@ static Dirlist rootlist =
 static Dirtab bootdir[Nbootfiles] = {
 	"boot",	{Qboot, 0, QTDIR},	0,		DMDIR|0555,
 };
-static uchar *bootdata[Nbootfiles];
+static uint8_t *bootdata[Nbootfiles];
 static Dirlist bootlist =
 {
 	Qboot,
@@ -64,7 +64,8 @@ static Dirlist bootlist =
  *  add a file to the list
  */
 static void
-addlist(Dirlist *l, char *name, uchar *contents, ulong len, int perm)
+addlist(Dirlist *l, int8_t *name, uint8_t *contents, uint32_t len,
+        int perm)
 {
 	Dirtab *d;
 
@@ -86,7 +87,7 @@ addlist(Dirlist *l, char *name, uchar *contents, ulong len, int perm)
  *  add a root file
  */
 void
-addbootfile(char *name, uchar *contents, ulong len)
+addbootfile(int8_t *name, uint8_t *contents, uint32_t len)
 {
 	addlist(&bootlist, name, contents, len, 0555);
 }
@@ -95,7 +96,7 @@ addbootfile(char *name, uchar *contents, ulong len)
  *  add a root directory
  */
 static void
-addrootdir(char *name)
+addrootdir(int8_t *name)
 {
 	addlist(&rootlist, name, nil, 0, DMDIR|0555);
 }
@@ -116,13 +117,13 @@ rootreset(void)
 }
 
 static Chan*
-rootattach(char *spec)
+rootattach(int8_t *spec)
 {
 	return devattach('/', spec);
 }
 
 static int
-rootgen(Chan *c, char *name, Dirtab*, int, int s, Dir *dp)
+rootgen(Chan *c, int8_t *name, Dirtab*, int, int s, Dir *dp)
 {
 	int t;
 	Dirtab *d;
@@ -171,13 +172,13 @@ panic("whoops");
 }
 
 static Walkqid*
-rootwalk(Chan *c, Chan *nc, char **name, int nname)
+rootwalk(Chan *c, Chan *nc, int8_t **name, int nname)
 {
 	return devwalk(c,  nc, name, nname, nil, 0, rootgen);
 }
 
-static long
-rootstat(Chan *c, uchar *dp, long n)
+static int32_t
+rootstat(Chan *c, uint8_t *dp, int32_t n)
 {
 	return devstat(c, dp, n, nil, 0, rootgen);
 }
@@ -196,14 +197,14 @@ rootclose(Chan*)
 {
 }
 
-static long
-rootread(Chan *c, void *buf, long n, vlong off)
+static int32_t
+rootread(Chan *c, void *buf, int32_t n, int64_t off)
 {
-	ulong t;
+	uint32_t t;
 	Dirtab *d;
 	Dirlist *l;
-	uchar *data;
-	ulong offset = off;
+	uint8_t *data;
+	uint32_t offset = off;
 
 	t = c->qid.path;
 	switch(t){
@@ -233,8 +234,8 @@ rootread(Chan *c, void *buf, long n, vlong off)
 	return n;
 }
 
-static long
-rootwrite(Chan*, void*, long, vlong)
+static int32_t
+rootwrite(Chan*, void*, int32_t, int64_t)
 {
 	error(Egreg);
 	return 0;

+ 60 - 60
sys/src/9/port/devsd.c

@@ -22,9 +22,9 @@
 extern Dev sddevtab;
 extern SDifc* sdifc[];
 
-static char Echange[] = "media or partition has changed";
+static int8_t Echange[] = "media or partition has changed";
 
-static char devletters[] = "0123456789"
+static int8_t devletters[] = "0123456789"
 	"abcdefghijklmnopqrstuvwxyz"
 	"ABCDEFGHIJKLMNOPQRSTUVWXYZ";
 
@@ -80,7 +80,7 @@ enum {
 
 
 static void
-sdaddpart(SDunit* unit, char* name, uvlong start, uvlong end)
+sdaddpart(SDunit* unit, int8_t* name, uint64_t start, uint64_t end)
 {
 	SDpart *pp;
 	int i, partno;
@@ -143,7 +143,7 @@ sdaddpart(SDunit* unit, char* name, uvlong start, uvlong end)
 }
 
 static void
-sddelpart(SDunit* unit, char* name)
+sddelpart(SDunit* unit, int8_t* name)
 {
 	int i;
 	SDpart *pp;
@@ -184,8 +184,8 @@ static int
 sdinitpart(SDunit* unit)
 {
 	int nf;
-	uvlong start, end;
-	char *f[4], *p, *q, buf[10];
+	uint64_t start, end;
+	int8_t *f[4], *p, *q, buf[10];
 
 	if(unit->sectors > 0){
 		unit->sectors = unit->secsize = 0;
@@ -241,7 +241,7 @@ sdinitpart(SDunit* unit)
 static int
 sdindex(int idno)
 {
-	char *p;
+	int8_t *p;
 
 	p = strchr(devletters, idno);
 	if(p == nil)
@@ -269,7 +269,7 @@ static SDunit*
 sdgetunit(SDev* sdev, int subno)
 {
 	SDunit *unit;
-	char buf[32];
+	int8_t buf[32];
 
 	/*
 	 * Associate a unit with a given device and sub-unit
@@ -389,7 +389,7 @@ static int
 sd2gen(Chan* c, int i, Dir* dp)
 {
 	Qid q;
-	vlong l;
+	int64_t l;
 	SDpart *pp;
 	SDperm *perm;
 	SDunit *unit;
@@ -428,7 +428,7 @@ sd2gen(Chan* c, int i, Dir* dp)
 
 	case Qpart:
 		pp = &unit->part[PART(c->qid)];
-		l = (pp->end - pp->start) * (vlong)unit->secsize;
+		l = (pp->end - pp->start) * (int64_t)unit->secsize;
 		mkqid(&q, QID(DEV(c->qid), UNIT(c->qid), PART(c->qid), Qpart),
 			unit->vers+pp->vers, QTFILE);
 		if(emptystr(pp->user))
@@ -457,10 +457,10 @@ sd1gen(Chan* c, int i, Dir* dp)
 }
 
 static int
-sdgen(Chan* c, char*, Dirtab*, int, int s, Dir* dp)
+sdgen(Chan* c, int8_t*, Dirtab*, int, int s, Dir* dp)
 {
 	Qid q;
-	vlong l;
+	int64_t l;
 	int i, r;
 	SDpart *pp;
 	SDunit *unit;
@@ -593,10 +593,10 @@ sdgen(Chan* c, char*, Dirtab*, int, int s, Dir* dp)
 }
 
 static Chan*
-sdattach(char* spec)
+sdattach(int8_t* spec)
 {
 	Chan *c;
-	char *p;
+	int8_t *p;
 	SDev *sdev;
 	int idno, subno;
 
@@ -628,13 +628,13 @@ sdattach(char* spec)
 }
 
 static Walkqid*
-sdwalk(Chan* c, Chan* nc, char** name, int nname)
+sdwalk(Chan* c, Chan* nc, int8_t** name, int nname)
 {
 	return devwalk(c, nc, name, nname, nil, 0, sdgen);
 }
 
-static long
-sdstat(Chan* c, uchar* db, long n)
+static int32_t
+sdstat(Chan* c, uint8_t* db, int32_t n)
 {
 	return devstat(c, db, n, nil, 0, sdgen);
 }
@@ -645,7 +645,7 @@ sdopen(Chan* c, int omode)
 	SDpart *pp;
 	SDunit *unit;
 	SDev *sdev;
-	uchar tp;
+	uint8_t tp;
 
 	c = devopen(c, omode, 0, 0, sdgen);
 	if((tp = TYPE(c->qid)) != Qctl && tp != Qraw && tp != Qpart)
@@ -713,16 +713,16 @@ sdclose(Chan* c)
 	}
 }
 
-static long
-sdbio(Chan* c, int write, char* a, long len, vlong off)
+static int32_t
+sdbio(Chan* c, int write, int8_t* a, int32_t len, int64_t off)
 {
 	int nchange;
-	uchar *b;
+	uint8_t *b;
 	SDpart *pp;
 	SDunit *unit;
 	SDev *sdev;
-	vlong bno;
-	long l, max, nb, offset;
+	int64_t bno;
+	int32_t l, max, nb, offset;
 
 	sdev = sdgetdev(DEV(c->qid));
 	if(sdev == nil){
@@ -838,8 +838,8 @@ sdbio(Chan* c, int write, char* a, long len, vlong off)
 	return len;
 }
 
-static long
-sdrio(SDreq* r, void* a, long n)
+static int32_t
+sdrio(SDreq* r, void* a, int32_t n)
 {
 	void *data;
 
@@ -905,10 +905,10 @@ sdsetsense(SDreq *r, int status, int key, int asc, int ascq)
 }
 
 int
-sdmodesense(SDreq *r, uchar *cmd, void *info, int ilen)
+sdmodesense(SDreq *r, uint8_t *cmd, void *info, int ilen)
 {
 	int len;
-	uchar *data;
+	uint8_t *data;
 
 	/*
 	 * Fake a vendor-specific request with page code 0,
@@ -936,8 +936,8 @@ sdmodesense(SDreq *r, uchar *cmd, void *info, int ilen)
 int
 sdfakescsi(SDreq *r, void *info, int ilen)
 {
-	uchar *cmd, *p;
-	uvlong len;
+	uint8_t *cmd, *p;
+	uint64_t len;
 	SDunit *unit;
 
 	cmd = r->cmd;
@@ -1026,7 +1026,7 @@ sdfakescsi(SDreq *r, void *info, int ilen)
 		*p++ = len>>16;
 		*p++ = len>>8;
 		*p++ = len;
-		r->rlen = p - (uchar*)r->data;
+		r->rlen = p - (uint8_t*)r->data;
 		return sdsetsense(r, SDok, 0, 0, 0);
 
 	case 0x9E:	/* long read capacity */
@@ -1052,7 +1052,7 @@ sdfakescsi(SDreq *r, void *info, int ilen)
 		*p++ = len>>16;
 		*p++ = len>>8;
 		*p++ = len;
-		r->rlen = p - (uchar*)r->data;
+		r->rlen = p - (uint8_t*)r->data;
 		return sdsetsense(r, SDok, 0, 0, 0);
 
 	case 0x5A:	/* mode sense */
@@ -1066,14 +1066,14 @@ sdfakescsi(SDreq *r, void *info, int ilen)
 	}
 }
 
-static long
-sdread(Chan *c, void *a, long n, vlong off)
+static int32_t
+sdread(Chan *c, void *a, int32_t n, int64_t off)
 {
-	char *p, *e, *buf;
+	int8_t *p, *e, *buf;
 	SDpart *pp;
 	SDunit *unit;
 	SDev *sdev;
-	long offset;
+	int32_t offset;
 	int i, l, m, status;
 
 	offset = off;
@@ -1109,7 +1109,7 @@ sdread(Chan *c, void *a, long n, vlong off)
 		m = 16*1024;	/* room for register dumps */
 		p = malloc(m);
 		l = snprint(p, m, "inquiry %.48s\n",
-			(char*)unit->inquiry+8);
+			(int8_t*)unit->inquiry+8);
 		qlock(&unit->ctl);
 		/*
 		 * If there's a device specific routine it must
@@ -1176,17 +1176,17 @@ sdread(Chan *c, void *a, long n, vlong off)
 
 static void legacytopctl(Cmdbuf*);
 
-static long
-sdwrite(Chan* c, void* a, long n, vlong off)
+static int32_t
+sdwrite(Chan* c, void* a, int32_t n, int64_t off)
 {
-	char *f0;
+	int8_t *f0;
 	int i;
 	Cmdbuf *cb;
 	SDifc *ifc;
 	SDreq *req;
 	SDunit *unit;
 	SDev *sdev;
-	uvlong end, start;
+	uint64_t end, start;
 
 	switch(TYPE(c->qid)){
 	default:
@@ -1343,8 +1343,8 @@ sdwrite(Chan* c, void* a, long n, vlong off)
 	return n;
 }
 
-static long
-sdwstat(Chan* c, uchar* dp, long n)
+static int32_t
+sdwstat(Chan* c, uint8_t* dp, int32_t n)
 {
 	Dir *d;
 	SDpart *pp;
@@ -1389,7 +1389,7 @@ sdwstat(Chan* c, uchar* dp, long n)
 		error(Eperm);
 
 	d = smalloc(sizeof(Dir)+n);
-	n = convM2D(dp, n, &d[0], (char*)&d[1]);
+	n = convM2D(dp, n, &d[0], (int8_t*)&d[1]);
 	if(n == 0)
 		error(Eshortstat);
 	if(!emptystr(d[0].uid))
@@ -1405,10 +1405,10 @@ sdwstat(Chan* c, uchar* dp, long n)
 }
 
 static int
-configure(char* spec, DevConf* cf)
+configure(int8_t* spec, DevConf* cf)
 {
 	SDev *s, *sdev;
-	char *p;
+	int8_t *p;
 	int i;
 
 	if(sdindex(*spec) < 0)
@@ -1436,7 +1436,7 @@ configure(char* spec, DevConf* cf)
 }
 
 static int
-unconfigure(char* spec)
+unconfigure(int8_t* spec)
 {
 	int i;
 	SDev *sdev;
@@ -1476,7 +1476,7 @@ unconfigure(char* spec)
 }
 
 static int
-sdconfig(int on, char* spec, DevConf* cf)
+sdconfig(int on, int8_t* spec, DevConf* cf)
 {
 	if(on)
 		return configure(spec, cf);
@@ -1512,12 +1512,12 @@ Dev sddevtab = {
 typedef struct Confdata Confdata;
 struct Confdata {
 	int	on;
-	char*	spec;
+	int8_t*	spec;
 	DevConf	cf;
 };
 
 static void
-parseswitch(Confdata* cd, char* option)
+parseswitch(Confdata* cd, int8_t* option)
 {
 	if(!strcmp("on", option))
 		cd->on = 1;
@@ -1528,7 +1528,7 @@ parseswitch(Confdata* cd, char* option)
 }
 
 static void
-parsespec(Confdata* cd, char* option)
+parsespec(Confdata* cd, int8_t* option)
 {
 	if(strlen(option) > 1)
 		error(Ebadarg);
@@ -1553,9 +1553,9 @@ getnewport(DevConf* dc)
 }
 
 static void
-parseport(Confdata* cd, char* option)
+parseport(Confdata* cd, int8_t* option)
 {
-	char *e;
+	int8_t *e;
 	Devport *p;
 
 	if(cd->cf.nports == 0 || cd->cf.ports[cd->cf.nports-1].port != (ulong)-1)
@@ -1568,9 +1568,9 @@ parseport(Confdata* cd, char* option)
 }
 
 static void
-parsesize(Confdata* cd, char* option)
+parsesize(Confdata* cd, int8_t* option)
 {
-	char *e;
+	int8_t *e;
 	Devport *p;
 
 	if(cd->cf.nports == 0 || cd->cf.ports[cd->cf.nports-1].size != -1)
@@ -1583,9 +1583,9 @@ parsesize(Confdata* cd, char* option)
 }
 
 static void
-parseirq(Confdata* cd, char* option)
+parseirq(Confdata* cd, int8_t* option)
 {
-	char *e;
+	int8_t *e;
 
 	cd->cf.intnum = strtoul(option, &e, 0);
 	if(e == nil || *e != '\0')
@@ -1593,14 +1593,14 @@ parseirq(Confdata* cd, char* option)
 }
 
 static void
-parsetype(Confdata* cd, char* option)
+parsetype(Confdata* cd, int8_t* option)
 {
 	cd->cf.type = option;
 }
 
 static struct {
-	char	*name;
-	void	(*parse)(Confdata*, char*);
+	int8_t	*name;
+	void	(*parse)(Confdata*, int8_t*);
 } options[] = {
 	"switch",	parseswitch,
 	"spec",		parsespec,
@@ -1613,7 +1613,7 @@ static struct {
 static void
 legacytopctl(Cmdbuf *cb)
 {
-	char *opt;
+	int8_t *opt;
 	int i, j;
 	Confdata cd;
 

+ 29 - 29
sys/src/9/port/devsegment.c

@@ -70,8 +70,8 @@ static Globalseg *globalseg[100];
 static Lock globalseglock;
 Segment *heapseg;
 
-	Segment* (*_globalsegattach)(Proc*, char*);
-static	Segment* globalsegattach(Proc*, char*);
+	Segment* (*_globalsegattach)(Proc*, int8_t*);
+static	Segment* globalsegattach(Proc*, int8_t*);
 static	int	cmddone(void*);
 static	void	segmentkproc(void*);
 static	void	docmd(Globalseg*, int);
@@ -115,11 +115,11 @@ putgseg(Globalseg *g)
 }
 
 static int
-segmentgen(Chan *c, char*, Dirtab*, int, int s, Dir *dp)
+segmentgen(Chan *c, int8_t*, Dirtab*, int, int s, Dir *dp)
 {
 	Qid q;
 	Globalseg *g;
-	ulong size;
+	uint32_t size;
 
 	switch(TYPE(c)) {
 	case Qtopdir:
@@ -203,19 +203,19 @@ segmentinit(void)
 }
 
 static Chan*
-segmentattach(char *spec)
+segmentattach(int8_t *spec)
 {
 	return devattach('g', spec);
 }
 
 static Walkqid*
-segmentwalk(Chan *c, Chan *nc, char **name, int nname)
+segmentwalk(Chan *c, Chan *nc, int8_t **name, int nname)
 {
 	return devwalk(c, nc, name, nname, 0, 0, segmentgen);
 }
 
-static long
-segmentstat(Chan *c, uchar *db, long n)
+static int32_t
+segmentstat(Chan *c, uint8_t *db, int32_t n)
 {
 	return devstat(c, db, n, 0, 0, segmentgen);
 }
@@ -296,11 +296,11 @@ segmentclose(Chan *c)
 }
 
 static void
-segmentcreate(Chan *c, char *name, int omode, int perm)
+segmentcreate(Chan *c, int8_t *name, int omode, int perm)
 {
 	int x, xfree;
 	Globalseg *g;
-	char *ep;
+	int8_t *ep;
 
 	if(TYPE(c) != Qtopdir)
 		error(Eperm);
@@ -363,7 +363,7 @@ segmentcreate(Chan *c, char *name, int omode, int perm)
 
 enum{PTRSIZE = 19};	/* "0x1234567812345678 " */
 static int
-readptr(char *buf, long n, uintptr val)
+readptr(int8_t *buf, int32_t n, uintptr val)
 {
 	if(n < PTRSIZE)
 		return 0;
@@ -381,15 +381,15 @@ znotempty(void *x)
 	return zs->end != 0;
 }
 
-static long
-segmentread(Chan *c, void *a, long n, vlong voff)
+static int32_t
+segmentread(Chan *c, void *a, int32_t n, int64_t voff)
 {
 	Globalseg *g;
 	Zseg *zs;
 	uintptr va;
-	char *p, *s;
-	long tot;
-	char buf[64];
+	int8_t *p, *s;
+	int32_t tot;
+	int8_t buf[64];
 
 	if(c->qid.type == QTDIR)
 		return devdirread(c, a, n, (Dirtab *)0, 0L, segmentgen);
@@ -473,12 +473,12 @@ segmentread(Chan *c, void *a, long n, vlong voff)
  * back when the segment is destroyed.
  * BUG: what if we overlap other segments attached by the user?
  */
-static ulong
-placeseg(ulong len)
+static uint32_t
+placeseg(uint32_t len)
 {
 	static Lock lck;
-	static ulong va = HEAPTOP;
-	ulong v;
+	static uint32_t va = HEAPTOP;
+	uint32_t v;
 
 	len += BIGPGSZ;	/* so we fault upon overflows */
 	lock(&lck);
@@ -490,15 +490,15 @@ placeseg(ulong len)
 	return v;
 }
 
-static long
-segmentwrite(Chan *c, void *a, long n, vlong voff)
+static int32_t
+segmentwrite(Chan *c, void *a, int32_t n, int64_t voff)
 {
 	Cmdbuf *cb;
 	Globalseg *g;
 	uintptr va, len, top;
 	int i;
 	struct{
-		char *name;
+		int8_t *name;
 		int type;
 	}segs[] = {
 		{"kmsg", SG_SHARED|SG_ZIO|SG_KZIO},
@@ -591,8 +591,8 @@ segmentwrite(Chan *c, void *a, long n, vlong voff)
 	return n;
 }
 
-static long
-segmentwstat(Chan *c, uchar *dp, long n)
+static int32_t
+segmentwstat(Chan *c, uint8_t *dp, int32_t n)
 {
 	Globalseg *g;
 	Dir *d;
@@ -613,7 +613,7 @@ segmentwstat(Chan *c, uchar *dp, long n)
 		free(d);
 		nexterror();
 	}
-	n = convM2D(dp, n, &d[0], (char*)&d[1]);
+	n = convM2D(dp, n, &d[0], (int8_t*)&d[1]);
 	if(!emptystr(d->uid) && strcmp(d->uid, g->uid) != 0)
 		kstrdup(&g->uid, d->uid);
 	if(d->mode != ~0UL)
@@ -648,7 +648,7 @@ segmentremove(Chan *c)
  *  called by segattach()
  */
 static Segment*
-globalsegattach(Proc *p, char *name)
+globalsegattach(Proc *p, int8_t *name)
 {
 	int x;
 	Globalseg *g;
@@ -738,10 +738,10 @@ segmentkproc(void *arg)
 				done = 1;
 				break;
 			case Cread:
-				memmove(g->data, (char*)g->off, g->dlen);
+				memmove(g->data, (int8_t*)g->off, g->dlen);
 				break;
 			case Cwrite:
-				memmove((char*)g->off, g->data, g->dlen);
+				memmove((int8_t*)g->off, g->data, g->dlen);
 				break;
 			}
 			poperror();

+ 22 - 22
sys/src/9/port/devsrv.c

@@ -18,12 +18,12 @@
 typedef struct Srv Srv;
 struct Srv
 {
-	char	*name;
-	char	*owner;
-	ulong	perm;
+	int8_t	*name;
+	int8_t	*owner;
+	uint32_t	perm;
 	Chan	*chan;
 	Srv	*link;
-	ulong	path;
+	uint32_t	path;
 };
 
 static QLock	srvlk;
@@ -31,7 +31,7 @@ static Srv	*srv;
 static int	qidpath;
 
 static int
-srvgen(Chan *c, char*, Dirtab*, int, int s, Dir *dp)
+srvgen(Chan *c, int8_t*, Dirtab*, int, int s, Dir *dp)
 {
 	Srv *sp;
 	Qid q;
@@ -65,19 +65,19 @@ srvinit(void)
 }
 
 static Chan*
-srvattach(char *spec)
+srvattach(int8_t *spec)
 {
 	return devattach('s', spec);
 }
 
 static Walkqid*
-srvwalk(Chan *c, Chan *nc, char **name, int nname)
+srvwalk(Chan *c, Chan *nc, int8_t **name, int nname)
 {
 	return devwalk(c, nc, name, nname, 0, 0, srvgen);
 }
 
 static Srv*
-srvlookup(char *name, ulong qidpath)
+srvlookup(int8_t *name, uint32_t qidpath)
 {
 	Srv *sp;
 	for(sp = srv; sp; sp = sp->link)
@@ -86,17 +86,17 @@ srvlookup(char *name, ulong qidpath)
 	return nil;
 }
 
-static long
-srvstat(Chan *c, uchar *db, long n)
+static int32_t
+srvstat(Chan *c, uint8_t *db, int32_t n)
 {
 	return devstat(c, db, n, 0, 0, srvgen);
 }
 
-char*
+int8_t*
 srvname(Chan *c)
 {
 	Srv *sp;
-	char *s;
+	int8_t *s;
 
 	for(sp = srv; sp; sp = sp->link)
 		if(sp->chan == c){
@@ -146,10 +146,10 @@ srvopen(Chan *c, int omode)
 }
 
 static void
-srvcreate(Chan *c, char *name, int omode, int perm)
+srvcreate(Chan *c, int8_t *name, int omode, int perm)
 {
 	Srv *sp;
-	char *sname;
+	int8_t *sname;
 
 	if(openmode(omode) != OWRITE)
 		error(Eperm);
@@ -238,12 +238,12 @@ srvremove(Chan *c)
 	free(sp);
 }
 
-static long
-srvwstat(Chan *c, uchar *dp, long n)
+static int32_t
+srvwstat(Chan *c, uint8_t *dp, int32_t n)
 {
 	Dir d;
 	Srv *sp;
-	char *strs;
+	int8_t *strs;
 
 	if(c->qid.type & QTDIR)
 		error(Eperm);
@@ -299,20 +299,20 @@ srvclose(Chan *c)
 	}
 }
 
-static long
-srvread(Chan *c, void *va, long n, vlong)
+static int32_t
+srvread(Chan *c, void *va, int32_t n, int64_t)
 {
 	isdir(c);
 	return devdirread(c, va, n, 0, 0, srvgen);
 }
 
-static long
-srvwrite(Chan *c, void *va, long n, vlong)
+static int32_t
+srvwrite(Chan *c, void *va, int32_t n, int64_t)
 {
 	Srv *sp;
 	Chan *c1;
 	int fd;
-	char buf[32];
+	int8_t buf[32];
 
 	if(n >= sizeof buf)
 		error(Egreg);

Some files were not shown because too many files changed in this diff